@spectrum-web-components/color-area 0.0.0-20241209155954

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ ## Description
2
+
3
+ An `<sp-color-area>` allows users to visually select two properties of a color simultaneously. It's commonly used together with a color slider or color wheel.
4
+
5
+ ### Usage
6
+
7
+ [![See it on NPM!](https://img.shields.io/npm/v/@spectrum-web-components/color-area?style=for-the-badge)](https://www.npmjs.com/package/@spectrum-web-components/color-area)
8
+ [![How big is this package in your project?](https://img.shields.io/bundlephobia/minzip/@spectrum-web-components/color-area?style=for-the-badge)](https://bundlephobia.com/result?p=@spectrum-web-components/color-area)
9
+ [![Try it on webcomponents.dev](https://img.shields.io/badge/Try%20it%20on-webcomponents.dev-green?style=for-the-badge)](https://webcomponents.dev/edit/collection/fO75441E1Q5ZlI0e9pgq/crxLSSCXLFPpmUsM6GJQ/src/index.ts)
10
+
11
+ ```
12
+ yarn add @spectrum-web-components/color-area
13
+ ```
14
+
15
+ Import the side effectful registration of `<sp-color-area>` via:
16
+
17
+ ```
18
+ import '@spectrum-web-components/color-area/sp-color-area.js';
19
+ ```
20
+
21
+ When looking to leverage the `ColorArea` base class as a type and/or for extension purposes, do so via:
22
+
23
+ ```
24
+ import { ColorArea } from '@spectrum-web-components/color-area';
25
+ ```
26
+
27
+ ## Color Formatting
28
+
29
+ When using the color elements, use `el.color` to access the `color` property, which should manage itself in the colour format supplied. For example, If you supply a color in `rgb()` format, `el.color` should return the color in `rgb()` format, as well. In ColorArea, colours are formatted as hex values.
30
+
31
+ The current color formats supported are as follows:
32
+
33
+ - Hex3, Hex4, Hex6, Hex8
34
+ - HSV, HSVA
35
+ - HSL, HSLA
36
+ - RGB, RGBA
37
+ - Strings (eg "red", "blue")
38
+
39
+ ## Standard
40
+
41
+ ```html
42
+ <sp-color-area></sp-color-area>
43
+ ```
44
+
45
+ ## Variants
46
+
47
+ ### Disabled
48
+
49
+ An `<sp-color-area>` in a disabled state shows that an input exists, but is not available in that circumstance. This can be used to maintain layout continuity and communicate that the area may become available later.
50
+
51
+ ```html
52
+ <sp-color-area disabled></sp-color-area>
53
+ ```
54
+
55
+ ### Sized
56
+
57
+ An `<sp-color-area>`’s height and width can be customized appropriately for its context.
58
+
59
+ ```html
60
+ <sp-color-area
61
+ style="
62
+ width: 72px;
63
+ height: 72px"
64
+ ></sp-color-area>
65
+ ```
66
+
67
+ ## Labels
68
+
69
+ An `<sp-color-area>` renders accessible labels for each axis: _"saturation"_ and _"luminosity"_.
70
+ Specify `label-x` and `label-y` attributes to override these defaults.
71
+
72
+ ```html
73
+ <sp-color-area
74
+ label-x="Color intensity"
75
+ label-y="Color brightness"
76
+ ></sp-color-area>
77
+ ```
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@spectrum-web-components/color-area",
3
+ "version": "0.0.0-20241209155954",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "",
8
+ "license": "Apache-2.0",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/adobe/spectrum-web-components.git",
12
+ "directory": "packages/color-area"
13
+ },
14
+ "author": "",
15
+ "homepage": "https://opensource.adobe.com/spectrum-web-components/components/color-area",
16
+ "bugs": {
17
+ "url": "https://github.com/adobe/spectrum-web-components/issues"
18
+ },
19
+ "main": "src/index.js",
20
+ "module": "src/index.js",
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "development": "./src/index.dev.js",
25
+ "default": "./src/index.js"
26
+ },
27
+ "./package.json": "./package.json",
28
+ "./src/ColorArea.js": {
29
+ "development": "./src/ColorArea.dev.js",
30
+ "default": "./src/ColorArea.js"
31
+ },
32
+ "./src/color-area-overrides.css.js": "./src/color-area-overrides.css.js",
33
+ "./src/color-area.css.js": "./src/color-area.css.js",
34
+ "./src/index.js": {
35
+ "development": "./src/index.dev.js",
36
+ "default": "./src/index.js"
37
+ },
38
+ "./src/types.js": {
39
+ "development": "./src/types.dev.js",
40
+ "default": "./src/types.js"
41
+ },
42
+ "./sp-color-area.js": {
43
+ "development": "./sp-color-area.dev.js",
44
+ "default": "./sp-color-area.js"
45
+ }
46
+ },
47
+ "scripts": {
48
+ "test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
49
+ },
50
+ "files": [
51
+ "**/*.d.ts",
52
+ "**/*.js",
53
+ "**/*.js.map",
54
+ "custom-elements.json",
55
+ "!stories/",
56
+ "!test/"
57
+ ],
58
+ "keywords": [
59
+ "spectrum css",
60
+ "web components",
61
+ "lit-element",
62
+ "lit-html"
63
+ ],
64
+ "dependencies": {
65
+ "@ctrl/tinycolor": "^4.0.3",
66
+ "@spectrum-web-components/base": "0.0.0-20241209155954",
67
+ "@spectrum-web-components/color-handle": "0.0.0-20241209155954",
68
+ "@spectrum-web-components/opacity-checkerboard": "0.0.0-20241209155954",
69
+ "@spectrum-web-components/reactive-controllers": "0.0.0-20241209155954",
70
+ "@spectrum-web-components/shared": "0.0.0-20241209155954"
71
+ },
72
+ "devDependencies": {
73
+ "@spectrum-css/colorarea": "^6.0.0-s2-foundations.15"
74
+ },
75
+ "types": "./src/index.d.ts",
76
+ "customElements": "custom-elements.json",
77
+ "sideEffects": [
78
+ "./sp-*.js",
79
+ "./**/*.dev.js"
80
+ ]
81
+ }
@@ -0,0 +1,6 @@
1
+ import { ColorArea } from './src/ColorArea.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'sp-color-area': ColorArea;
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ import { ColorArea } from "./src/ColorArea.dev.js";
3
+ import { defineElement } from "@spectrum-web-components/base/src/define-element.js";
4
+ defineElement("sp-color-area", ColorArea);
5
+ //# sourceMappingURL=sp-color-area.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-color-area.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { ColorArea } from './src/ColorArea.dev.js'\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-color-area', ColorArea);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-color-area': ColorArea;\n }\n}\n"],
5
+ "mappings": ";AAYA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,cAAc,iBAAiB,SAAS;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";import{ColorArea as e}from"./src/ColorArea.js";import{defineElement as r}from"@spectrum-web-components/base/src/define-element.js";r("sp-color-area",e);
2
+ //# sourceMappingURL=sp-color-area.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["sp-color-area.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { ColorArea } from './src/ColorArea.js';\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-color-area', ColorArea);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-color-area': ColorArea;\n }\n}\n"],
5
+ "mappings": "aAYA,OAAS,aAAAA,MAAiB,qBAC1B,OAAS,iBAAAC,MAAqB,sDAE9BA,EAAc,gBAAiBD,CAAS",
6
+ "names": ["ColorArea", "defineElement"]
7
+ }
@@ -0,0 +1,65 @@
1
+ import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
2
+ import '@spectrum-web-components/color-handle/sp-color-handle.js';
3
+ import { ColorValue } from '@spectrum-web-components/reactive-controllers/src/Color.js';
4
+ /**
5
+ * @element sp-color-area
6
+ * @slot gradient - a custom gradient visually outlining the available color values
7
+ * @fires input - The value of the Color Area has changed.
8
+ * @fires change - An alteration to the value of the Color Area has been committed by the user.
9
+ */
10
+ export declare class ColorArea extends SpectrumElement {
11
+ static get styles(): CSSResultArray;
12
+ dir: 'ltr' | 'rtl';
13
+ disabled: boolean;
14
+ focused: boolean;
15
+ labelX: string;
16
+ labelY: string;
17
+ private handle;
18
+ private languageResolver;
19
+ private colorController;
20
+ get hue(): number;
21
+ set hue(value: number);
22
+ get value(): ColorValue;
23
+ get color(): ColorValue;
24
+ set color(color: ColorValue);
25
+ private activeAxis;
26
+ get x(): number;
27
+ set x(x: number);
28
+ private _x;
29
+ get y(): number;
30
+ set y(y: number);
31
+ private _y;
32
+ step: number;
33
+ inputX: HTMLInputElement;
34
+ inputY: HTMLInputElement;
35
+ private altered;
36
+ private activeKeys;
37
+ private _valueChanged;
38
+ focus(focusOptions?: FocusOptions): void;
39
+ private forwardFocus;
40
+ private handleFocus;
41
+ handleBlur(): void;
42
+ private handleKeydown;
43
+ private handleKeypress;
44
+ private handleKeyup;
45
+ private handleInput;
46
+ private handleChange;
47
+ private boundingClientRect;
48
+ _pointerDown: boolean;
49
+ private handlePointerdown;
50
+ private handlePointermove;
51
+ private handlePointerup;
52
+ /**
53
+ * Returns the value under the cursor
54
+ * @param: PointerEvent on slider
55
+ * @return: Slider value that correlates to the position under the pointer
56
+ */
57
+ private calculateHandlePosition;
58
+ private handleAreaPointerdown;
59
+ protected render(): TemplateResult;
60
+ protected firstUpdated(changed: PropertyValues): void;
61
+ protected updated(changed: PropertyValues): void;
62
+ private observer?;
63
+ connectedCallback(): void;
64
+ disconnectedCallback(): void;
65
+ }