diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..2358dbf
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,10 @@
+# https://editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+indent_style = tab
+indent_size = 2
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..d64c4ca
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,2 @@
+coverage/
+dist/
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
new file mode 100644
index 0000000..788bf07
--- /dev/null
+++ b/.eslintrc.cjs
@@ -0,0 +1,15 @@
+/** @type {import('eslint').Linter.Config} */ const config = {
+ extends: ['standard'],
+ rules: {
+ // Necessary to use tabs for indentation.
+ 'no-tabs': ['error', { allowIndentationTabs: true }],
+ indent: ['error', 'tab', { SwitchCase: 1 }],
+ // Other rules.
+ 'comma-dangle': ['error', 'always-multiline'],
+ 'space-before-function-paren': ['error', 'always'],
+ // Avoids false errors like “'HTMLElement' is not defined.”.
+ 'no-undef': 'off',
+ },
+}
+
+module.exports = config
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..57798ba
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.github/ISSUE_TEMPLATE/01_bug_report.md b/.github/ISSUE_TEMPLATE/01_bug_report.md
new file mode 100644
index 0000000..cea6d81
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/01_bug_report.md
@@ -0,0 +1,20 @@
+---
+name: Bug report
+about: Something isn’t working as expected
+---
+
+## Steps to reproduce
+
+
+
+## Current result
+
+
+
+## Expected result
+
+
+
+## Environment
+
+- **yet-another-color-picker** version:
diff --git a/.github/ISSUE_TEMPLATE/02_feature_request.md b/.github/ISSUE_TEMPLATE/02_feature_request.md
new file mode 100644
index 0000000..4610416
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/02_feature_request.md
@@ -0,0 +1,12 @@
+---
+name: Feature request
+about: Something is missing
+---
+
+## Description
+
+
+
+## Motivation
+
+
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..9589aa6
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,51 @@
+name: main
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ types: [opened, reopened, synchronize]
+
+jobs:
+ test-unit:
+ # Skip this job if the head commit’s message contains the string “[skip ci]”.
+ if: "!contains(github.event.head_commit.message, '[skip ci]')"
+ name: Tests & build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3 # https://github.com/actions/checkout
+ - uses: actions/setup-node@v3 # https://github.com/actions/setup-node
+ with:
+ node-version: '16'
+ - uses: actions/cache@v3 # https://github.com/actions/cache
+ with:
+ path: |
+ **/node_modules
+ dist
+ key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
+ - run: npm install
+ - run: npm run lint
+ - run: npm run build
+ - run: npm test
+ env:
+ CI: true
+
+ release:
+ # The release job runs only on pushes to or merges into the release branches configured in the semantic-release configuration.
+ if: "github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/next-major' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/alpha'"
+ needs: test-unit
+ name: Publish package
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/cache@v3
+ with:
+ path: |
+ **/node_modules
+ dist
+ key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
+ - env:
+ GH_TOKEN: ${{ secrets.GH_TOKEN }}
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+ run: npx semantic-release
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ba2a97b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+node_modules
+coverage
diff --git a/.husky/commit-msg b/.husky/commit-msg
new file mode 100644
index 0000000..5426a93
--- /dev/null
+++ b/.husky/commit-msg
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+npx commitlint --edit $1
diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100644
index 0000000..6d395b8
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+npm run lint:fix
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..c178376
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,132 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, caste, color, religion, or sexual
+identity and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the overall
+ community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or advances of
+ any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email address,
+ without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at
+[philipprudloff@fastmail.com](mailto:philipprudloff@fastmail.com).
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series of
+actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or permanent
+ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within the
+community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.1, available at
+[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
+
+Community Impact Guidelines were inspired by
+[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
+
+For answers to common questions about this code of conduct, see the FAQ at
+[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
+[https://www.contributor-covenant.org/translations][translations].
+
+[homepage]: https://www.contributor-covenant.org
+[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
+[Mozilla CoC]: https://github.com/mozilla/diversity
+[FAQ]: https://www.contributor-covenant.org/faq
+[translations]: https://www.contributor-covenant.org/translations
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..32ba929
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,63 @@
+# Contributing guidelines
+
+Hello there!
+
+This project follows a [code of conduct](https://github.com/kleinfreund/yet-another-color-picker/blob/main/CODE_OF_CONDUCT.md). Please read it. All contributions are subject to it.
+
+## Prerequisites
+
+The following software will be required to contribute to this project:
+
+- git
+- Node.js (version 16 or higher)
+- npm (version 8 or higher)
+
+## Development
+
+### Install dependencies
+
+```sh
+npm install
+```
+
+### Stard development server with a small demo
+
+```sh
+npm start
+```
+
+### Run tests
+
+```sh
+npm test
+```
+
+### Build the contents of the `dist` directory
+
+```sh
+npm run build
+```
+
+### Committing changes
+
+This project follows the [Angular convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular) for naming commits.
+
+**Examples**:
+
+```
+feat: adds support for Lab/LCH color formats
+```
+
+```
+fix: fixes a bug with color conversions to RGB
+```
+
+```
+docs: expands examples
+```
+
+## Pull request guidelines
+
+- In case of submitting a contribution for a new feature, please explain briefly why you think the feature is necessary. Ideally, an issue for a feature request was submitted and approved beforehand, but this is not a requirement.
+- In case of submitting a contribution that changes or introduces a user interface, ensure that the user interface remains accessible: It must be navigable using a pointer device (e.g. mouse, track pad), a keyboard, and a screen reader. This can be tested manually and with the help of automated accessibility checkers such as axe.
+- Please provide unit tests for feature or bug fix contributions.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..b5daa23
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,7 @@
+Copyright 2022 Philipp Rudloff
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d3cfcc3
--- /dev/null
+++ b/README.md
@@ -0,0 +1,217 @@
+# color-picker
+
+[![Tests passing](https://github.com/kleinfreund/yet-another-color-picker/workflows/main/badge.svg)](https://github.com/kleinfreund/yet-another-color-picker/actions)
+
+A color picker web component.
+
+This package’s files are distributed in the ES module format and have not been transpiled.
+
+Links:
+
+- [demo](https://yet-another-color-picker.netlify.app)
+- [**npmjs.com**/package/yet-another-color-picker](https://www.npmjs.com/package/yet-another-color-picker)
+ - [on BundlePhobia](https://bundlephobia.com/result?p=yet-another-color-picker)
+- [**github.com**/kleinfreund/yet-another-color-picker](https://github.com/kleinfreund/yet-another-color-picker)
+ - [code of conduct](https://github.com/kleinfreund/yet-another-color-picker/blob/main/CODE_OF_CONDUCT.md)
+ - [contributing guidelines](https://github.com/kleinfreund/yet-another-color-picker/blob/main/CONTRIBUTING.md)
+
+## Contents
+
+- [Installation](#installation)
+- [Usage](#usage)
+- [Documentation](#documentation)
+ - [Props](#props)
+ - [`data-color`](#data-color)
+ - [`data-visible-formats`](#data-visible-formats)
+ - [`data-default-format`](#data-default-format)
+ - [`data-alpha-channel`](#data-alpha-channel)
+ - [`id`](#id)
+ - [Events](#events)
+ - [`color-change`](#color-change)
+- [Versioning](#versioning)
+- [Contributing](#contributing)
+- [Design](#design)
+
+## Installation
+
+```sh
+npm install yet-another-color-picker
+```
+
+## Usage
+
+Import the `ColorPicker` custom element class and define it.
+
+HTML:
+```html
+
+```
+
+JavaScript:
+```js
+import { ColorPicker } from 'yet-another-color-picker'
+
+window.customElements.define('color-picker', ColorPicker)
+```
+
+## Documentation
+
+### Props
+
+#### `data-color`
+
+- **Description**: Sets the color of the color picker. You can pass any valid CSS color string.
+- **Type**: `string` (any valid CSS color string)
+- **Required**: `false`
+- **Default**: `'#ffffffff'`
+- **Usage**:
+
+ HTML:
+ ```html
+
+ ```
+
+ HTML:
+ ```html
+
+ ```
+
+ JavaScript:
+ ```js
+ colorPicker.setAttribute('data-color', 'hsl(270 100% 50% / 0.8)')
+ ```
+
+#### `data-visible-formats`
+
+- **Description**: A comma-separated string of visible color formats. Controls for which formats the color `input` elements are shown and in which order the formats will be cycled through when activating the format switch button.
+- **Type**: `string` (a comma-separated list of `VisibleColorFormat`s)
+- **Required**: `false`
+- **Default**: `'hex,hsl,hwb,rgb'`
+- **Usage**:
+
+ HTML:
+ ```html
+
+ ```
+
+#### `data-default-format`
+
+- **Description**: The color format to show by default when rendering the color picker. Must be one of the formats specified in `data-visible-formats`.
+- **Type**: `VisibleColorFormat`
+- **Required**: `false`
+- **Default**: `'hsl'`
+- **Usage**:
+
+ HTML:
+ ```html
+
+ ```
+
+#### `data-alpha-channel`
+
+- **Description**: Whether to show input controls for a color’s alpha channel. If set to `'hide'`, the alpha range input and the alpha channel input are hidden, the “Copy color” button will copy a CSS color value without alpha channel, and the object emitted in a `color-change` event will have a `cssColor` property value without alpha channel.
+- **Type**: `'show'` or `'hide'`
+- **Required**: `false`
+- **Default**: `'show'`
+- **Usage**:
+
+ HTML:
+ ```html
+
+ ```
+
+#### `id`
+
+- **Description**: The ID value will be used to prefix all `input` elements’ `id` and `label` elements’ `for` attribute values. Set this prop if you use multiple instances of the component on one page.
+- **Type**: `string`
+- **Required**: `false`
+- **Default**: `'color-picker'`
+- **Usage**:
+
+ HTML:
+ ```html
+
+ ```
+
+### Events
+
+#### `color-change`
+
+- **Description**: The custom event that is emitted each time the internal colors object is updated.
+- **Data**: The custom event emits an object whose `detail` property contains both the internal colors object and a CSS color value as a string based on the currently active format. The `cssColor` property will respect `data-alpha-channel`.
+
+ ```ts
+ {
+ colors: {
+ hex: string
+ hsl: ColorHsl
+ hsv: ColorHsv
+ hwb: ColorHwb
+ rgb: ColorRgb
+ }
+ cssColor: string
+ }
+ ```
+
+- **Usage**:
+
+ HTML:
+ ```html
+
+ ```
+
+ JavaScript:
+ ```js
+ import { ColorPicker } from 'yet-another-color-picker'
+ /** @typedef {import('yet-another-color-picker').ColorChangeDetail} ColorChangeDetail */
+
+ window.customElements.define('color-picker', ColorPicker)
+
+ const colorPicker = document.querySelector('color-picker')
+ colorPicker.addEventListener('color-change', colorChangeListener)
+
+ /**
+ * @param {CustomEvent} event
+ */
+ function colorChangeListener (event) {
+ console.log(event.detail)
+ }
+ ```
+
+## Versioning
+
+This package uses [semantic versioning](https://semver.org).
+
+## Contributing
+
+See [CONTRIBUTING.md](https://github.com/kleinfreund/yet-another-color-picker/blob/main/CONTRIBUTING.md).
+
+## Design
+
+The color picker consists of the following main elements:
+
+- **Color space**:
+
+ For fine-tuning the saturation and lightness/value, a slice of the HSV cylinder for the currently selected hue is shown.
+
+ The HSV cylinder is more convenient for this task than the HSL cylinder as it shows a color at 100% saturation and 100% value in the top right corner (i.e. one can drag the color space thumb into the corner as a quasi shortcut). The HSL cylinder’s slice has this color at the halfway point of the Y axis (i.e. at 50% lightness) which isn’t easy to select.
+
+- **Hue slider**:
+
+ A slider for selecting the current hue. This rotates the HSV cylinder; thus, it changes the slice of the HSV cylinder that’s shown in the color space.
+
+- **Alpha slider**:
+
+ A slider for selecting the current alpha value.
+
+- **Copy button**:
+
+ Copies the color formatted as a CSS color string in the active format.
+
+- **Color inputs**:
+
+ A set of text fields which allow you to enter the individual components of each color. The text fields are shown based on the active format.
+
+- **Switch format button**:
+
+ Cycles through the available color formats (currently HEX, HSL, HWB, and RGB).
diff --git a/commitlint.config.cjs b/commitlint.config.cjs
new file mode 100644
index 0000000..c1426e2
--- /dev/null
+++ b/commitlint.config.cjs
@@ -0,0 +1,9 @@
+/** @type {import('@commitlint/types').UserConfig} */ const config = {
+ extends: ['@commitlint/config-conventional'],
+ rules: {
+ 'body-max-line-length': [0, 'always', Infinity],
+ 'footer-max-line-length': [0, 'always', Infinity],
+ },
+}
+
+module.exports = config
diff --git a/dist/ColorPicker.css b/dist/ColorPicker.css
new file mode 100644
index 0000000..b57ddf9
--- /dev/null
+++ b/dist/ColorPicker.css
@@ -0,0 +1 @@
+.cp-color-picker{--cp-color:hsl(calc(var(--cp-hsl-h, 0) * 360) calc(var(--cp-hsl-s, 0) * 100%) calc(var(--cp-hsl-l, 1) * 100%) / var(--cp-hsl-a, 1));--cp-focus-color:#19f;--cp-focus-outline:2px solid var(--cp-focus-color);--cp-border-width:1px;--cp-border-color:#000;--cp-border:var(--cp-border-width) solid var(--cp-border-color);--cp-spacing:6px;max-width:var(--cp-color-space-width,300px);padding:var(--cp-spacing);display:grid;grid-gap:var(--cp-spacing);grid-template-columns:1fr min-content;font-size:.8em;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;background-color:#fff}.cp-color-picker *,.cp-color-picker ::after,.cp-color-picker ::before{box-sizing:border-box}.cp-color-picker button::-moz-focus-inner{border:none;padding:0}.cp-color-picker :focus{outline:var(--cp-focus-outline)}.cp-color-space{grid-column:1/-1;position:relative;background-color:hsl(calc(var(--cp-hsl-h,0) * 360) 100% 50%);background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,transparent);overflow:hidden;aspect-ratio:1/0.6}.cp-thumb{--cp-thumb-size:calc(var(--cp-spacing) * 4);box-sizing:border-box;position:absolute;left:0;bottom:0;width:var(--cp-thumb-size);height:var(--cp-thumb-size);margin-left:calc(-1 * var(--cp-thumb-size)/ 2);margin-bottom:calc(-1 * var(--cp-thumb-size)/ 2);border:3px solid #fff;border-radius:50%;box-shadow:0 0 0 var(--cp-border-width) #000;transform:rotate(0)}.cp-thumb:focus{outline-color:transparent;box-shadow:0 0 0 var(--cp-border-width) #000,0 0 0 3px var(--cp-focus-color)}.cp-range-input-label{--cp-slider-track-width:100%;--cp-slider-track-height:calc(var(--cp-spacing) * 3);display:block}.cp-range-input-group{display:flex;flex-direction:column;justify-content:center}.cp-range-input-group>:not(:first-child){margin-top:var(--cp-spacing)}.cp-range-input,.cp-range-input::-webkit-slider-thumb{-webkit-appearance:none}.cp-range-input{display:block;width:var(--cp-slider-track-width);height:var(--cp-slider-track-height);margin-right:0;margin-left:0;margin-top:calc(var(--cp-spacing)/ 2 + 1px);margin-bottom:calc(var(--cp-spacing)/ 2 + 1px);padding:0;border:none;background:0 0}.cp-range-input:focus{outline:0}.cp-range-input::-moz-focus-outer{border:none}.cp-range-input--alpha{background-color:#fff;background-image:linear-gradient(45deg,#eee 25%,transparent 25%,transparent 75%,#eee 75%,#eee),linear-gradient(45deg,#eee 25%,transparent 25%,transparent 75%,#eee 75%,#eee);background-size:calc(var(--cp-spacing) * 2) calc(var(--cp-spacing) * 2);background-position:0 0,var(--cp-spacing) var(--cp-spacing)}.cp-range-input::-moz-range-track{box-sizing:content-box;width:var(--cp-slider-track-width);height:var(--cp-slider-track-height);border:var(--cp-border)}.cp-range-input::-webkit-slider-runnable-track{box-sizing:content-box;width:var(--cp-slider-track-width);height:var(--cp-slider-track-height);border:var(--cp-border)}.cp-range-input::-ms-track{box-sizing:content-box;width:var(--cp-slider-track-width);height:var(--cp-slider-track-height);border:var(--cp-border)}.cp-range-input:focus::-moz-range-track{outline:var(--cp-focus-outline)}.cp-range-input:focus::-webkit-slider-runnable-track{outline:var(--cp-focus-outline)}.cp-range-input:focus::-ms-track{outline:var(--cp-focus-outline)}.cp-range-input--alpha::-moz-range-track{background-image:linear-gradient(to right,transparent,var(--cp-color))}.cp-range-input--alpha::-webkit-slider-runnable-track{background-image:linear-gradient(to right,transparent,var(--cp-color))}.cp-range-input--alpha::-ms-track{background-image:linear-gradient(to right,transparent,var(--cp-color))}.cp-range-input--hue::-moz-range-track{background-image:linear-gradient(to right,red calc(100% * 0/360),#ff0 calc(100% * 60/360),#0f0 calc(100% * 120/360),#0ff calc(100% * 180/360),#00f calc(100% * 240/360),#f0f calc(100% * 300/360),red calc(100% * 360/360))}.cp-range-input--hue::-webkit-slider-runnable-track{background-image:linear-gradient(to right,red calc(100% * 0/360),#ff0 calc(100% * 60/360),#0f0 calc(100% * 120/360),#0ff calc(100% * 180/360),#00f calc(100% * 240/360),#f0f calc(100% * 300/360),red calc(100% * 360/360))}.cp-range-input--hue::-ms-track{background-image:linear-gradient(to right,red calc(100% * 0/360),#ff0 calc(100% * 60/360),#0f0 calc(100% * 120/360),#0ff calc(100% * 180/360),#00f calc(100% * 240/360),#f0f calc(100% * 300/360),red calc(100% * 360/360))}.cp-range-input::-moz-range-thumb{box-sizing:content-box;width:var(--cp-slider-track-height);height:var(--cp-slider-track-height);border:3px solid #fff;border-radius:50%;background-color:transparent;box-shadow:0 0 0 var(--cp-border-width) #000;isolation:isolate}.cp-range-input::-webkit-slider-thumb{box-sizing:content-box;width:var(--cp-slider-track-height);height:var(--cp-slider-track-height);margin-top:calc(-1 * (var(--cp-spacing)/ 2));border:3px solid #fff;border-radius:50%;background-color:transparent;box-shadow:0 0 0 var(--cp-border-width) #000;isolation:isolate}.cp-range-input::-ms-thumb{box-sizing:content-box;width:var(--cp-slider-track-height);height:var(--cp-slider-track-height);margin-top:calc(-1 * (var(--cp-spacing)/ 2));border:3px solid #fff;border-radius:50%;background-color:transparent;box-shadow:0 0 0 var(--cp-border-width) #000;isolation:isolate}.cp-copy-button{justify-self:center;align-self:center;position:relative;overflow:hidden;display:flex;align-items:center;justify-content:center;width:calc(var(--cp-spacing) * 6);height:calc(var(--cp-spacing) * 6);border:var(--cp-border-width) solid transparent;border-radius:50%;background-color:#fff}.cp-copy-button:enabled:focus{outline:0;border-color:var(--cp-border-color);box-shadow:0 0 0 2px var(--cp-focus-color)}.cp-copy-button:enabled:hover{background-color:#0002}.cp-color-input-wrapper{grid-column:1/-1;display:flex;align-items:center}.cp-color-input-wrapper>:not(:first-child){margin-left:var(--cp-spacing)}.cp-color-input-group{flex-grow:1;display:grid;grid-auto-flow:column;column-gap:var(--cp-spacing)}.cp-color-input-label{text-align:center}.cp-color-input{width:100%;margin:0;margin-top:calc(var(--cp-spacing)/ 2);padding:var(--cp-spacing);border:var(--cp-border);font:inherit;text-align:center;color:inherit;background-color:#fff}.cp-switch-format-button{display:flex;justify-content:center;align-items:center;margin:0;padding:var(--cp-spacing);border:var(--cp-border-width) solid transparent;border-radius:50%;font:inherit;color:inherit;background-color:#fff}.cp-switch-format-button:enabled:focus{border-color:var(--cp-border-color)}.cp-switch-format-button:enabled:hover{background-color:#0002}.cp-visually-hidden{position:absolute!important;overflow:hidden!important;clip:rect(0 0 0 0)!important;width:1px!important;height:1px!important;margin:-1px!important;padding:0!important;border:0!important;white-space:nowrap!important}
\ No newline at end of file
diff --git a/dist/ColorPicker.js b/dist/ColorPicker.js
new file mode 100644
index 0000000..27acb48
--- /dev/null
+++ b/dist/ColorPicker.js
@@ -0,0 +1,142 @@
+var t;const e=window,s=e.trustedTypes,i=s?s.createPolicy("lit-html",{createHTML:t=>t}):void 0,o=`lit$${(Math.random()+"").slice(9)}$`,n="?"+o,r=`<${n}>`,l=document,h=(t="")=>l.createComment(t),a=t=>null===t||"object"!=typeof t&&"function"!=typeof t,u=Array.isArray,c=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,p=/-->/g,d=/>/g,v=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),m=/'/g,g=/"/g,f=/^(?:script|style|textarea|title)$/i,$=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),b=Symbol.for("lit-noChange"),A=Symbol.for("lit-nothing"),y=new WeakMap,_=l.createTreeWalker(l,129,null,!1),w=(t,e)=>{const s=t.length-1,n=[];let l,h=2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==i?i.createHTML(u):u,n]};class x{constructor({strings:t,_$litType$:e},i){let r;this.parts=[];let l=0,a=0;const u=t.length-1,c=this.parts,[p,d]=w(t,e);if(this.el=x.createElement(p,i),_.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(r=_.nextNode())&&c.length0){r.textContent=s?s.emptyScript:"";for(let s=0;su(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==A&&a(this._$AH)?this._$AA.nextSibling.data=t:this.T(l.createTextNode(t)),this._$AH=t}$(t){var e;const{values:s,_$litType$:i}=t,o="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=x.createElement(i.h,this.options)),i);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===o)this._$AH.p(s);else{const t=new T(o,this),e=t.v(this.options);t.p(s),this.T(e),this._$AH=t}}_$AC(t){let e=y.get(t.strings);return void 0===e&&y.set(t.strings,e=new x(t)),e}k(t){u(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const o of t)i===e.length?e.push(s=new S(this.O(h()),this.O(h()),this,this.options)):s=e[i],s._$AI(o),i++;i2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=A}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,s,i){const o=this.strings;let n=!1;if(void 0===o)t=C(this,t,e,0),n=!a(t)||t!==this._$AH&&t!==b,n&&(this._$AH=t);else{const i=t;let r,l;for(t=o[0],r=0;r4?2:1;for(let t=0;tparseInt(t,16)/255));return{r:o[0],g:o[1],b:o[2],a:o[3]}}function Q(t){const e=t.l<.5?t.l*(1+t.s):t.l+t.s-t.l*t.s,s=2*t.l-e;return{r:K(s,e,t.h+1/3),g:K(s,e,t.h),b:K(s,e,t.h-1/3),a:t.a}}function K(t,e,s){return s<0?s+=1:s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t}function X(t){return{r:Y(5,t),g:Y(3,t),b:Y(1,t),a:t.a}}function Y(t,e){const s=(t+6*e.h)%6;return e.v-e.v*e.s*Math.max(0,Math.min(s,4-s,1))}function Z(t){return{h:t.h,s:1===t.b?0:1-t.w/(1-t.b),v:1-t.b,a:t.a}}function G(t){const e=Math.min(t.r,t.g,t.b),s=Math.max(t.r,t.g,t.b);let i;return i=s===e?0:s===t.r?(0+(t.g-t.b)/(s-e))/6:s===t.g?(2+(t.b-t.r)/(s-e))/6:(4+(t.r-t.g)/(s-e))/6,i<0&&(i+=1),{h:i,w:e,b:1-s,a:t.a}}function J(t){const e=G(t),s=e.w,i=1-e.b,o=(i+s)/2;let n;return n=0===i||1===s?0:(i-o)/Math.min(o,1-o),{h:e.h,s:n,l:o,a:t.a}}function tt(t){return"#"+Object.values(t).map((t=>{const e=255*t,s=Math.round(e).toString(16);return 1===s.length?"0"+s:s})).join("")}const et={hex:[["hsl",t=>st(t,[z,J])],["hsv",t=>st(t,[z,G,Z])],["hwb",t=>st(t,[z,G])],["rgb",z]],hsl:[["hex",t=>st(t,[Q,tt])],["hsv",function(t){const e=t.l+t.s*Math.min(t.l,1-t.l),s=0===e?0:2-2*t.l/e;return{h:t.h,s,v:e,a:t.a}}],["hwb",t=>st(t,[Q,G])],["rgb",Q]],hsv:[["hex",t=>st(t,[X,tt])],["hsl",function(t){const e=t.v-t.v*t.s/2,s=Math.min(e,1-e),i=0===s?0:(t.v-e)/s;return{h:t.h,s:i,l:e,a:t.a}}],["hwb",function(t){return{h:t.h,w:(1-t.s)*t.v,b:1-t.v,a:t.a}}],["rgb",X]],hwb:[["hex",t=>st(t,[Z,X,tt])],["hsl",t=>st(t,[Z,X,J])],["hsv",Z],["rgb",t=>st(t,[Z,X])]],rgb:[["hex",tt],["hsl",J],["hsv",t=>st(t,[G,Z])],["hwb",G]]};function st(t,e){return e.reduce(((t,e)=>e(t)),t)}function it(t){const e={};for(const s in t)e[s]=t[s];return e}const ot={hex:(t,e)=>e&&[5,9].includes(t.length)?t.substring(0,t.length-(t.length-1)/4):t,hsl:(t,e)=>`hsl(${F(360*t.h)} ${F(100*t.s)}% ${F(100*t.l)}%`+(e?")":` / ${F(t.a)})`),hwb:(t,e)=>`hwb(${F(360*t.h)} ${F(100*t.w)}% ${F(100*t.b)}%`+(e?")":` / ${F(t.a)})`),rgb:(t,e)=>`rgb(${F(255*t.r)} ${F(255*t.g)} ${F(255*t.b)}`+(e?")":` / ${F(t.a)})`)};function nt(t,e,s){return ot[e](t,s)}function rt(t){return/^#(?:(?:[A-F0-9]{2}){3,4}|[A-F0-9]{3,4})$/i.test(t)}const lt={"data-alpha-channel":{type:String,default:()=>"show"},"data-color":{type:String,default:()=>"#ffffffff"},"data-default-format":{type:String,default:()=>"hsl"},"data-visible-formats":{type:Array,default:()=>["hex","hsl","hwb","rgb"]},id:{type:String,default:()=>"color-picker"}},ht=Object.entries(lt);class at extends HTMLElement{static observedAttributes=Object.keys(lt);#t=null;#e=null;#s=!1;#i={hex:"#ffffffff",hsl:{h:0,s:0,l:1,a:1},hsv:{h:0,s:0,v:1,a:1},hwb:{h:0,w:1,b:0,a:1},rgb:{r:1,g:1,b:1,a:1}};#o=!1;#n="hsl";#r=[];#l="";#h=[];constructor(){super(),window.customElements.whenDefined(this.localName).then((()=>{this.#o=!0}))}get[Symbol.toStringTag](){return"ColorPicker"}connectedCallback(){if(!this.isConnected)return;this.ownerDocument.addEventListener("mousemove",this.#a,{passive:!1}),this.ownerDocument.addEventListener("touchmove",this.#u,{passive:!1}),this.ownerDocument.addEventListener("mouseup",this.#c),this.ownerDocument.addEventListener("touchend",this.#c);const t=this.#p("data-visible-formats"),e=this.#p("data-default-format");this.#n=t.includes(e)?e:t[0];for(const t of at.observedAttributes)this.#d(t,this.#p(t))}disconnectedCallback(){this.ownerDocument.removeEventListener("mousemove",this.#a),this.ownerDocument.removeEventListener("touchmove",this.#u),this.ownerDocument.removeEventListener("mouseup",this.#c),this.ownerDocument.removeEventListener("touchend",this.#c)}attributeChangedCallback(t,e,s){e!==s&&this.#o&&this.#d(t,s)}#d(t,e){this.#h.push({name:t,value:e}),queueMicrotask((()=>{this.#v()}))}#v(){if(0!==this.#h.length){for(const{name:t,value:e}of this.#h)this.#m(t,e);this.#h=[],this.#g()}}#m(t,e){if("data-color"===t){const s=null!==e?e:this.#f(t);this.#$(s)}else if("data-alpha-channel"===t){const s=null!==e?e:this.#f(t);this.#b(s),this.#A(s)}}#$(t){const e=function(t){if(rt(t))return{format:"hex",color:t};if(!t.includes("(")){const e=document.createElement("canvas").getContext("2d");e.fillStyle=t;const s=e.fillStyle;return"#000000"===s&&"black"!==t?null:{format:"hex",color:s}}const[e,s]=t.split("("),i=e.substring(0,3),o=s.replace(/[,/)]/g," ").replace(/\s+/g," ").trim().split(" ");3===o.length&&o.push("1");const n=i.split("").concat("a"),r=Object.fromEntries(n.map(((t,e)=>[t,q[i][t].from(o[e])])));return{format:i,color:r}}(t);null!==e&&this.#y(e.format,e.color)}#y(t,e){let s=e;if("hide"===this.#p("data-alpha-channel"))if("string"!=typeof e)e.a=1,s=e;else if([5,9].includes(e.length)){const t=(e.length-1)/4;s=e.substring(0,e.length-t)+"f".repeat(t)}else[4,7].includes(e.length)&&(s=e+"f".repeat((e.length-1)/3));(function(t,e){if("string"==typeof t||"string"==typeof e)return t===e;for(const s in t)if(t[s]!==e[s])return!1;return!0})(this.#i[t],s)||(this.#_(t,s),this.#w())}#_(t,e){this.#i[t]=e;for(const[e,s]of et[t])this.#i[e]=s(this.#i[t]);this.#A(this.#p("data-alpha-channel")),this.#g()}#w(){const t=this.#x(),e=new CustomEvent("color-change",{detail:t});this.dispatchEvent(e)}#C(){this.style.setProperty("--cp-hsl-h",String(this.#i.hsl.h)),this.style.setProperty("--cp-hsl-s",String(this.#i.hsl.s)),this.style.setProperty("--cp-hsl-l",String(this.#i.hsl.l)),this.style.setProperty("--cp-hsl-a",String(this.#i.hsl.a)),null!==this.#t&&null!==this.#e&&(this.#t.style.position="relative",this.#t.style.backgroundColor="hsl(calc(var(--cp-hsl-h) * 360) 100% 50%)",this.#t.style.backgroundImage="linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)",this.#e.style.boxSizing="border-box",this.#e.style.position="absolute",this.#e.style.left=100*this.#i.hsv.s+"%",this.#e.style.bottom=100*this.#i.hsv.v+"%")}#b(t){const e=Object.keys(this.#i[this.#n]);this.#r="hex"!==this.#n&&"hide"===t?e.slice(0,3):e}#A(t){const e=this.#i.hex;this.#l="hide"===t&&[5,9].includes(e.length)?e.substring(0,e.length-(e.length-1)/4):e}#g(){if(!this.isConnected)return;this.#T();const t=function(t,e,s,i,o,n,r,l,h,a,u,c,p,d,v,m,g){const f=()=>$`
+
+ `,b=()=>$`
+
+ `,A=()=>$`
+