@spectrum-web-components/swatch 1.1.0 → 1.1.1
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/package.json +8 -8
- package/sp-swatch-group.d.ts +6 -0
- package/sp-swatch-group.dev.js +5 -0
- package/sp-swatch-group.dev.js.map +7 -0
- package/sp-swatch-group.js +2 -0
- package/sp-swatch-group.js.map +7 -0
- package/sp-swatch.d.ts +6 -0
- package/sp-swatch.dev.js +5 -0
- package/sp-swatch.dev.js.map +7 -0
- package/sp-swatch.js +2 -0
- package/sp-swatch.js.map +7 -0
- package/src/Swatch.d.ts +43 -0
- package/src/Swatch.dev.js +243 -0
- package/src/Swatch.dev.js.map +7 -0
- package/src/Swatch.js +48 -0
- package/src/Swatch.js.map +7 -0
- package/src/SwatchGroup.d.ts +39 -0
- package/src/SwatchGroup.dev.js +268 -0
- package/src/SwatchGroup.dev.js.map +7 -0
- package/src/SwatchGroup.js +7 -0
- package/src/SwatchGroup.js.map +7 -0
- package/src/index.d.ts +2 -0
- package/src/index.dev.js +4 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -0
- package/src/index.js.map +7 -0
- package/src/spectrum-swatch-group.css.d.ts +2 -0
- package/src/spectrum-swatch-group.css.dev.js +7 -0
- package/src/spectrum-swatch-group.css.dev.js.map +7 -0
- package/src/spectrum-swatch-group.css.js +4 -0
- package/src/spectrum-swatch-group.css.js.map +7 -0
- package/src/spectrum-swatch.css.d.ts +2 -0
- package/src/spectrum-swatch.css.dev.js +7 -0
- package/src/spectrum-swatch.css.dev.js.map +7 -0
- package/src/spectrum-swatch.css.js +4 -0
- package/src/spectrum-swatch.css.js.map +7 -0
- package/src/swatch-group-overrides.css.d.ts +2 -0
- package/src/swatch-group-overrides.css.dev.js +7 -0
- package/src/swatch-group-overrides.css.dev.js.map +7 -0
- package/src/swatch-group-overrides.css.js +4 -0
- package/src/swatch-group-overrides.css.js.map +7 -0
- package/src/swatch-group.css.d.ts +2 -0
- package/src/swatch-group.css.dev.js +7 -0
- package/src/swatch-group.css.dev.js.map +7 -0
- package/src/swatch-group.css.js +4 -0
- package/src/swatch-group.css.js.map +7 -0
- package/src/swatch-overrides.css.d.ts +2 -0
- package/src/swatch-overrides.css.dev.js +7 -0
- package/src/swatch-overrides.css.dev.js.map +7 -0
- package/src/swatch-overrides.css.js +4 -0
- package/src/swatch-overrides.css.js.map +7 -0
- package/src/swatch.css.d.ts +2 -0
- package/src/swatch.css.dev.js +7 -0
- package/src/swatch.css.dev.js.map +7 -0
- package/src/swatch.css.js +4 -0
- package/src/swatch.css.js.map +7 -0
- package/stories/swatch-group.stories.js +183 -0
- package/stories/swatch-group.stories.js.map +7 -0
- package/stories/swatch-sizes.stories.js +40 -0
- package/stories/swatch-sizes.stories.js.map +7 -0
- package/stories/swatch.stories.js +109 -0
- package/stories/swatch.stories.js.map +7 -0
- package/test/benchmark/basic-test.js +8 -0
- package/test/benchmark/basic-test.js.map +7 -0
- package/test/swatch-group.test-vrt.js +5 -0
- package/test/swatch-group.test-vrt.js.map +7 -0
- package/test/swatch-group.test.js +377 -0
- package/test/swatch-group.test.js.map +7 -0
- package/test/swatch-memory.test.js +8 -0
- package/test/swatch-memory.test.js.map +7 -0
- package/test/swatch-sizes.test-vrt.js +5 -0
- package/test/swatch-sizes.test-vrt.js.map +7 -0
- package/test/swatch.test-vrt.js +5 -0
- package/test/swatch.test-vrt.js.map +7 -0
- package/test/swatch.test.js +155 -0
- package/test/swatch.test.js.map +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/swatch",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@lit-labs/observers": "^2.0.2",
|
|
72
|
-
"@spectrum-web-components/base": "^1.1.
|
|
73
|
-
"@spectrum-web-components/icon": "^1.1.
|
|
74
|
-
"@spectrum-web-components/icons-ui": "^1.1.
|
|
75
|
-
"@spectrum-web-components/opacity-checkerboard": "^1.1.
|
|
76
|
-
"@spectrum-web-components/reactive-controllers": "^1.1.
|
|
77
|
-
"@spectrum-web-components/shared": "^1.1.
|
|
72
|
+
"@spectrum-web-components/base": "^1.1.1",
|
|
73
|
+
"@spectrum-web-components/icon": "^1.1.1",
|
|
74
|
+
"@spectrum-web-components/icons-ui": "^1.1.1",
|
|
75
|
+
"@spectrum-web-components/opacity-checkerboard": "^1.1.1",
|
|
76
|
+
"@spectrum-web-components/reactive-controllers": "^1.1.1",
|
|
77
|
+
"@spectrum-web-components/shared": "^1.1.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@spectrum-css/swatch": "7.0.0-s2-foundations.17",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"./sp-*.js",
|
|
87
87
|
"./**/*.dev.js"
|
|
88
88
|
],
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "44870aa95001c1b995456d994ae31bbe7277fac9"
|
|
90
90
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-swatch-group.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 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*/\nimport { SwatchGroup } from './src/SwatchGroup.dev.js'\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-swatch-group', SwatchGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-swatch-group': SwatchGroup;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAWA,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAE9B,cAAc,mBAAmB,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-swatch-group.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 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*/\nimport { SwatchGroup } from './src/SwatchGroup.js';\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-swatch-group', SwatchGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-swatch-group': SwatchGroup;\n }\n}\n"],
|
|
5
|
+
"mappings": "aAWA,OAAS,eAAAA,MAAmB,uBAC5B,OAAS,iBAAAC,MAAqB,sDAE9BA,EAAc,kBAAmBD,CAAW",
|
|
6
|
+
"names": ["SwatchGroup", "defineElement"]
|
|
7
|
+
}
|
package/sp-swatch.d.ts
ADDED
package/sp-swatch.dev.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-swatch.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 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*/\nimport { Swatch } from './src/Swatch.dev.js'\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-swatch', Swatch);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-swatch': Swatch;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAWA,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAE9B,cAAc,aAAa,MAAM;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/sp-swatch.js
ADDED
package/sp-swatch.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-swatch.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 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*/\nimport { Swatch } from './src/Swatch.js';\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-swatch', Swatch);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-swatch': Swatch;\n }\n}\n"],
|
|
5
|
+
"mappings": "aAWA,OAAS,UAAAA,MAAc,kBACvB,OAAS,iBAAAC,MAAqB,sDAE9BA,EAAc,YAAaD,CAAM",
|
|
6
|
+
"names": ["Swatch", "defineElement"]
|
|
7
|
+
}
|
package/src/Swatch.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CSSResultArray, PropertyValues, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
+
import { Focusable } from '@spectrum-web-components/shared/src/focusable.js';
|
|
3
|
+
import '@spectrum-web-components/icons-ui/icons/sp-icon-dash75.js';
|
|
4
|
+
import '@spectrum-web-components/icons-ui/icons/sp-icon-dash100.js';
|
|
5
|
+
import '@spectrum-web-components/icons-ui/icons/sp-icon-dash200.js';
|
|
6
|
+
import '@spectrum-web-components/icons-ui/icons/sp-icon-dash300.js';
|
|
7
|
+
export type SwatchBorder = 'light' | 'none' | undefined;
|
|
8
|
+
export type SwatchRounding = 'none' | 'full' | undefined;
|
|
9
|
+
export type SwatchShape = 'rectangle' | undefined;
|
|
10
|
+
declare const Swatch_base: typeof Focusable & {
|
|
11
|
+
new (...args: any[]): import("@spectrum-web-components/base").SizedElementInterface;
|
|
12
|
+
prototype: import("@spectrum-web-components/base").SizedElementInterface;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @element sp-swatch
|
|
16
|
+
*/
|
|
17
|
+
export declare class Swatch extends Swatch_base {
|
|
18
|
+
static get styles(): CSSResultArray;
|
|
19
|
+
border: SwatchBorder;
|
|
20
|
+
color: string;
|
|
21
|
+
label: string;
|
|
22
|
+
mixedValue: boolean;
|
|
23
|
+
nothing: boolean;
|
|
24
|
+
role: string;
|
|
25
|
+
rounding: SwatchRounding;
|
|
26
|
+
selected: boolean;
|
|
27
|
+
shape: SwatchShape;
|
|
28
|
+
get value(): string;
|
|
29
|
+
set value(value: string);
|
|
30
|
+
private _value?;
|
|
31
|
+
get focusElement(): HTMLElement;
|
|
32
|
+
toggle(force?: boolean): void;
|
|
33
|
+
private handleClick;
|
|
34
|
+
protected handleKeydown(event: KeyboardEvent): void;
|
|
35
|
+
private handleKeypress;
|
|
36
|
+
protected handleKeyup(event: KeyboardEvent): void;
|
|
37
|
+
protected renderDisabled: () => TemplateResult;
|
|
38
|
+
protected renderMixedValue: () => TemplateResult;
|
|
39
|
+
protected render(): TemplateResult;
|
|
40
|
+
protected willUpdate(changes: PropertyValues): void;
|
|
41
|
+
protected firstUpdated(changes: PropertyValues): void;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
+
if (decorator = decorators[i])
|
|
8
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
+
if (kind && result) __defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
html,
|
|
14
|
+
SizedMixin
|
|
15
|
+
} from "@spectrum-web-components/base";
|
|
16
|
+
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
17
|
+
import {
|
|
18
|
+
ifDefined,
|
|
19
|
+
when
|
|
20
|
+
} from "@spectrum-web-components/base/src/directives.js";
|
|
21
|
+
import { Focusable } from "@spectrum-web-components/shared/src/focusable.js";
|
|
22
|
+
import opacityCheckerboardStyles from "@spectrum-web-components/opacity-checkerboard/src/opacity-checkerboard.css.js";
|
|
23
|
+
import "@spectrum-web-components/icons-ui/icons/sp-icon-dash75.js";
|
|
24
|
+
import "@spectrum-web-components/icons-ui/icons/sp-icon-dash100.js";
|
|
25
|
+
import "@spectrum-web-components/icons-ui/icons/sp-icon-dash200.js";
|
|
26
|
+
import "@spectrum-web-components/icons-ui/icons/sp-icon-dash300.js";
|
|
27
|
+
import styles from "./swatch.css.js";
|
|
28
|
+
import dashStyles from "@spectrum-web-components/icon/src/spectrum-icon-dash.css.js";
|
|
29
|
+
import dashSmallOverrides from "@spectrum-web-components/icon/src/icon-dash-overrides.css.js";
|
|
30
|
+
const dashIcon = {
|
|
31
|
+
xs: () => html`
|
|
32
|
+
<sp-icon-dash75
|
|
33
|
+
slot="icon"
|
|
34
|
+
class="mixedValueIcon spectrum-UIIcon-Dash75"
|
|
35
|
+
></sp-icon-dash75>
|
|
36
|
+
`,
|
|
37
|
+
s: () => html`
|
|
38
|
+
<sp-icon-dash100
|
|
39
|
+
slot="icon"
|
|
40
|
+
class="mixedValueIcon spectrum-UIIcon-Dash100"
|
|
41
|
+
></sp-icon-dash100>
|
|
42
|
+
`,
|
|
43
|
+
m: () => html`
|
|
44
|
+
<sp-icon-dash200
|
|
45
|
+
slot="icon"
|
|
46
|
+
class="mixedValueIcon spectrum-UIIcon-Dash200"
|
|
47
|
+
></sp-icon-dash200>
|
|
48
|
+
`,
|
|
49
|
+
l: () => html`
|
|
50
|
+
<sp-icon-dash300
|
|
51
|
+
slot="icon"
|
|
52
|
+
class="mixedValueIcon spectrum-UIIcon-Dash300"
|
|
53
|
+
></sp-icon-dash300>
|
|
54
|
+
`
|
|
55
|
+
};
|
|
56
|
+
export class Swatch extends SizedMixin(Focusable, {
|
|
57
|
+
validSizes: ["xs", "s", "m", "l"],
|
|
58
|
+
noDefaultSize: true
|
|
59
|
+
}) {
|
|
60
|
+
constructor() {
|
|
61
|
+
super(...arguments);
|
|
62
|
+
this.color = "";
|
|
63
|
+
this.label = "";
|
|
64
|
+
this.mixedValue = false;
|
|
65
|
+
this.nothing = false;
|
|
66
|
+
this.role = "button";
|
|
67
|
+
this.selected = false;
|
|
68
|
+
this.renderDisabled = () => {
|
|
69
|
+
return html`
|
|
70
|
+
<svg
|
|
71
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
72
|
+
class="disabledIcon"
|
|
73
|
+
viewBox="0 0 20 20"
|
|
74
|
+
>
|
|
75
|
+
<path
|
|
76
|
+
d="M9.889,1a8.889,8.889,0,1,0,8.889,8.889A8.889,8.889,0,0,0,9.889,1Zm6.667,8.889a6.635,6.635,0,0,1-1.233,3.863l-9.3-9.3A6.667,6.667,0,0,1,16.556,9.889Zm-13.333,0A6.636,6.636,0,0,1,4.455,6.026l9.3,9.3A6.667,6.667,0,0,1,3.222,9.889Z"
|
|
77
|
+
stroke="none"
|
|
78
|
+
fill="var(--spectrum-swatch-disabled-icon-color)"
|
|
79
|
+
/>
|
|
80
|
+
<path
|
|
81
|
+
d="M 9.888889312744141 1 C 4.979689598083496 1 1 4.979689598083496 1 9.888889312744141 C 1 14.7980899810791 4.979689598083496 18.77777862548828 9.888889312744141 18.77777862548828 C 14.7980899810791 18.77777862548828 18.77777862548828 14.7980899810791 18.77777862548828 9.888889312744141 C 18.77777862548828 4.979689598083496 14.7980899810791 1 9.888889312744141 1 M 15.32277870178223 13.75166893005371 L 6.02610969543457 4.454998970031738 C 8.059318542480469 3.009572982788086 10.72937774658203 2.820217132568359 12.9462194442749 3.964249610900879 C 15.16304969787598 5.10828971862793 16.55568885803223 7.394259452819824 16.5555591583252 9.888889312744141 C 16.55776977539062 11.27357959747314 16.126708984375 12.62425994873047 15.32277870178223 13.75166893005371 M 9.888258934020996 16.55648612976074 C 8.843273162841797 16.55648612976074 7.794573783874512 16.31111145019531 6.831318855285645 15.8139591217041 C 4.614439010620117 14.66977882385254 3.221879959106445 12.38361930847168 3.222219467163086 9.888889312744141 C 3.220088958740234 8.504219055175781 3.651140213012695 7.153559684753418 4.454998970031738 6.02610969543457 L 13.75166893005371 15.32333946228027 C 12.60186290740967 16.14075088500977 11.24825286865234 16.55648612976074 9.888258934020996 16.55648612976074 M 9.888889312744141 0 C 15.34163951873779 0 19.77777862548828 4.436139106750488 19.77777862548828 9.888889312744141 C 19.77777862548828 15.34163951873779 15.34163951873779 19.77777862548828 9.888889312744141 19.77777862548828 C 4.436139106750488 19.77777862548828 0 15.34163951873779 0 9.888889312744141 C 0 4.436139106750488 4.436139106750488 0 9.888889312744141 0 Z M 15.10232830047607 12.11699867248535 C 15.40205764770508 11.41858959197998 15.55679702758789 10.66494941711426 15.5555591583252 9.89048957824707 C 15.5556697845459 7.759209632873535 14.38009929656982 5.829549789428711 12.48761940002441 4.852889060974121 C 11.68764972686768 4.440059661865234 10.78924942016602 4.22184944152832 9.889529228210449 4.22184944152832 C 9.114802360534668 4.22184944152832 8.360831260681152 4.377038955688477 7.661839485168457 4.676509857177734 L 15.10232830047607 12.11699867248535 Z M 12.11597919464111 15.10181331634521 L 4.675475120544434 7.660861015319824 C 4.375750541687012 8.359296798706055 4.221027374267578 9.112875938415527 4.222219467163086 9.887349128723145 C 4.221929550170898 12.01874923706055 5.397418975830078 13.94855880737305 7.289958953857422 14.92533874511719 C 8.08997917175293 15.3382396697998 8.988459587097168 15.55648994445801 9.888258934020996 15.55648994445801 C 10.66298007965088 15.55648994445801 11.41698551177979 15.40128421783447 12.11597919464111 15.10181331634521 Z"
|
|
82
|
+
stroke="none"
|
|
83
|
+
fill="var(--spectrum-swatch-disabled-icon-stroke-color)"
|
|
84
|
+
/>
|
|
85
|
+
</svg>
|
|
86
|
+
`;
|
|
87
|
+
};
|
|
88
|
+
this.renderMixedValue = () => {
|
|
89
|
+
return dashIcon[this.size]();
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
static get styles() {
|
|
93
|
+
return [
|
|
94
|
+
opacityCheckerboardStyles,
|
|
95
|
+
styles,
|
|
96
|
+
dashStyles,
|
|
97
|
+
dashSmallOverrides
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
get value() {
|
|
101
|
+
return this._value || this.color || this.label;
|
|
102
|
+
}
|
|
103
|
+
set value(value) {
|
|
104
|
+
if (value === this._value) return;
|
|
105
|
+
const oldValue = this.value;
|
|
106
|
+
this._value = value;
|
|
107
|
+
this.requestUpdate("value", oldValue);
|
|
108
|
+
}
|
|
109
|
+
get focusElement() {
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
toggle(force) {
|
|
113
|
+
this.selected = force != null ? force : !this.selected;
|
|
114
|
+
}
|
|
115
|
+
handleClick() {
|
|
116
|
+
if (this.disabled || this.mixedValue) return;
|
|
117
|
+
this.toggle();
|
|
118
|
+
const applyDefault = this.dispatchEvent(
|
|
119
|
+
new Event("change", {
|
|
120
|
+
cancelable: true,
|
|
121
|
+
bubbles: true
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
if (!applyDefault) {
|
|
125
|
+
this.toggle();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
handleKeydown(event) {
|
|
129
|
+
const { code } = event;
|
|
130
|
+
switch (code) {
|
|
131
|
+
case "Space":
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
this.addEventListener("keyup", this.handleKeyup);
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
handleKeypress(event) {
|
|
140
|
+
const { code } = event;
|
|
141
|
+
switch (code) {
|
|
142
|
+
case "Enter":
|
|
143
|
+
case "NumpadEnter":
|
|
144
|
+
this.click();
|
|
145
|
+
break;
|
|
146
|
+
default:
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
handleKeyup(event) {
|
|
151
|
+
const { code } = event;
|
|
152
|
+
switch (code) {
|
|
153
|
+
case "Space":
|
|
154
|
+
this.removeEventListener("keyup", this.handleKeyup);
|
|
155
|
+
this.click();
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
render() {
|
|
162
|
+
return html`
|
|
163
|
+
<div
|
|
164
|
+
class="opacity-checkerboard fill"
|
|
165
|
+
style=${ifDefined(
|
|
166
|
+
this.color ? `--spectrum-picked-color: ${this.color}` : void 0
|
|
167
|
+
)}
|
|
168
|
+
>
|
|
169
|
+
<slot name="image"></slot>
|
|
170
|
+
${when(this.disabled, this.renderDisabled)}
|
|
171
|
+
${when(this.mixedValue, this.renderMixedValue)}
|
|
172
|
+
</div>
|
|
173
|
+
`;
|
|
174
|
+
}
|
|
175
|
+
willUpdate(changes) {
|
|
176
|
+
var _a;
|
|
177
|
+
if (!this.getAttribute("role")) {
|
|
178
|
+
this.setAttribute("role", "button");
|
|
179
|
+
}
|
|
180
|
+
if (changes.has("selected") || changes.has("role")) {
|
|
181
|
+
const selectedAttribute = this.role === "button" ? "aria-pressed" : "aria-checked";
|
|
182
|
+
const removedSelectedAttribute = this.role === "button" ? "aria-checked" : "aria-pressed";
|
|
183
|
+
if (changes.has("role")) {
|
|
184
|
+
this.removeAttribute(removedSelectedAttribute);
|
|
185
|
+
}
|
|
186
|
+
this.setAttribute(
|
|
187
|
+
selectedAttribute,
|
|
188
|
+
this.selected ? "true" : "false"
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
if (changes.has("label") || changes.has("color") || changes.has("mixedValue")) {
|
|
192
|
+
if (this.label !== this.color && ((_a = this.label) == null ? void 0 : _a.length)) {
|
|
193
|
+
this.setAttribute("aria-label", this.label);
|
|
194
|
+
} else if (this.color) {
|
|
195
|
+
this.setAttribute("aria-label", this.color);
|
|
196
|
+
} else if (this.mixedValue) {
|
|
197
|
+
this.setAttribute("aria-label", "Mixed");
|
|
198
|
+
} else {
|
|
199
|
+
this.removeAttribute("aria-label");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
firstUpdated(changes) {
|
|
204
|
+
super.firstUpdated(changes);
|
|
205
|
+
this.addEventListener("click", this.handleClick);
|
|
206
|
+
this.addEventListener("keydown", this.handleKeydown);
|
|
207
|
+
this.addEventListener("keypress", this.handleKeypress);
|
|
208
|
+
if (!this.hasAttribute("tabindex")) {
|
|
209
|
+
this.setAttribute("tabindex", "0");
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
__decorateClass([
|
|
214
|
+
property({ reflect: true })
|
|
215
|
+
], Swatch.prototype, "border", 2);
|
|
216
|
+
__decorateClass([
|
|
217
|
+
property()
|
|
218
|
+
], Swatch.prototype, "color", 2);
|
|
219
|
+
__decorateClass([
|
|
220
|
+
property()
|
|
221
|
+
], Swatch.prototype, "label", 2);
|
|
222
|
+
__decorateClass([
|
|
223
|
+
property({ type: Boolean, reflect: true, attribute: "mixed-value" })
|
|
224
|
+
], Swatch.prototype, "mixedValue", 2);
|
|
225
|
+
__decorateClass([
|
|
226
|
+
property({ type: Boolean, reflect: true })
|
|
227
|
+
], Swatch.prototype, "nothing", 2);
|
|
228
|
+
__decorateClass([
|
|
229
|
+
property({ reflect: true })
|
|
230
|
+
], Swatch.prototype, "role", 2);
|
|
231
|
+
__decorateClass([
|
|
232
|
+
property({ reflect: true })
|
|
233
|
+
], Swatch.prototype, "rounding", 2);
|
|
234
|
+
__decorateClass([
|
|
235
|
+
property({ type: Boolean, reflect: true })
|
|
236
|
+
], Swatch.prototype, "selected", 2);
|
|
237
|
+
__decorateClass([
|
|
238
|
+
property({ reflect: true })
|
|
239
|
+
], Swatch.prototype, "shape", 2);
|
|
240
|
+
__decorateClass([
|
|
241
|
+
property()
|
|
242
|
+
], Swatch.prototype, "value", 1);
|
|
243
|
+
//# sourceMappingURL=Swatch.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["Swatch.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 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*/\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport {\n ifDefined,\n when,\n} from '@spectrum-web-components/base/src/directives.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport opacityCheckerboardStyles from '@spectrum-web-components/opacity-checkerboard/src/opacity-checkerboard.css.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-dash75.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-dash100.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-dash200.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-dash300.js';\n\nimport styles from './swatch.css.js';\nimport dashStyles from '@spectrum-web-components/icon/src/spectrum-icon-dash.css.js';\nimport dashSmallOverrides from '@spectrum-web-components/icon/src/icon-dash-overrides.css.js';\n\nexport type SwatchBorder = 'light' | 'none' | undefined;\nexport type SwatchRounding = 'none' | 'full' | undefined;\nexport type SwatchShape = 'rectangle' | undefined;\n\nconst dashIcon: Record<string, () => TemplateResult> = {\n xs: () => html`\n <sp-icon-dash75\n slot=\"icon\"\n class=\"mixedValueIcon spectrum-UIIcon-Dash75\"\n ></sp-icon-dash75>\n `,\n s: () => html`\n <sp-icon-dash100\n slot=\"icon\"\n class=\"mixedValueIcon spectrum-UIIcon-Dash100\"\n ></sp-icon-dash100>\n `,\n m: () => html`\n <sp-icon-dash200\n slot=\"icon\"\n class=\"mixedValueIcon spectrum-UIIcon-Dash200\"\n ></sp-icon-dash200>\n `,\n l: () => html`\n <sp-icon-dash300\n slot=\"icon\"\n class=\"mixedValueIcon spectrum-UIIcon-Dash300\"\n ></sp-icon-dash300>\n `,\n};\n\n/**\n * @element sp-swatch\n */\nexport class Swatch extends SizedMixin(Focusable, {\n validSizes: ['xs', 's', 'm', 'l'],\n noDefaultSize: true,\n}) {\n public static override get styles(): CSSResultArray {\n return [\n opacityCheckerboardStyles,\n styles,\n dashStyles,\n dashSmallOverrides,\n ];\n }\n\n @property({ reflect: true })\n public border: SwatchBorder;\n\n @property()\n public color = '';\n\n @property()\n public label = '';\n\n @property({ type: Boolean, reflect: true, attribute: 'mixed-value' })\n public mixedValue = false;\n\n @property({ type: Boolean, reflect: true })\n public nothing = false;\n\n @property({ reflect: true })\n public override role = 'button';\n\n @property({ reflect: true })\n public rounding: SwatchRounding;\n\n @property({ type: Boolean, reflect: true })\n public selected = false;\n\n @property({ reflect: true })\n public shape: SwatchShape;\n\n @property()\n get value(): string {\n return this._value || this.color || this.label;\n }\n\n set value(value: string) {\n if (value === this._value) return;\n const oldValue = this.value;\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n private _value?: string;\n\n public override get focusElement(): HTMLElement {\n return this;\n }\n\n public toggle(force?: boolean): void {\n this.selected = force ?? !this.selected;\n }\n\n private handleClick(): void {\n if (this.disabled || this.mixedValue) return;\n this.toggle();\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n bubbles: true,\n })\n );\n if (!applyDefault) {\n this.toggle();\n }\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n event.preventDefault();\n this.addEventListener('keyup', this.handleKeyup);\n break;\n /* c8 ignore next 2 */\n default:\n break;\n }\n }\n\n private handleKeypress(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Enter':\n case 'NumpadEnter':\n this.click();\n break;\n /* c8 ignore next 2 */\n default:\n break;\n }\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n this.removeEventListener('keyup', this.handleKeyup);\n this.click();\n break;\n /* c8 ignore next 2 */\n default:\n break;\n }\n }\n\n protected renderDisabled = (): TemplateResult => {\n return html`\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"disabledIcon\"\n viewBox=\"0 0 20 20\"\n >\n <path\n d=\"M9.889,1a8.889,8.889,0,1,0,8.889,8.889A8.889,8.889,0,0,0,9.889,1Zm6.667,8.889a6.635,6.635,0,0,1-1.233,3.863l-9.3-9.3A6.667,6.667,0,0,1,16.556,9.889Zm-13.333,0A6.636,6.636,0,0,1,4.455,6.026l9.3,9.3A6.667,6.667,0,0,1,3.222,9.889Z\"\n stroke=\"none\"\n fill=\"var(--spectrum-swatch-disabled-icon-color)\"\n />\n <path\n d=\"M 9.888889312744141 1 C 4.979689598083496 1 1 4.979689598083496 1 9.888889312744141 C 1 14.7980899810791 4.979689598083496 18.77777862548828 9.888889312744141 18.77777862548828 C 14.7980899810791 18.77777862548828 18.77777862548828 14.7980899810791 18.77777862548828 9.888889312744141 C 18.77777862548828 4.979689598083496 14.7980899810791 1 9.888889312744141 1 M 15.32277870178223 13.75166893005371 L 6.02610969543457 4.454998970031738 C 8.059318542480469 3.009572982788086 10.72937774658203 2.820217132568359 12.9462194442749 3.964249610900879 C 15.16304969787598 5.10828971862793 16.55568885803223 7.394259452819824 16.5555591583252 9.888889312744141 C 16.55776977539062 11.27357959747314 16.126708984375 12.62425994873047 15.32277870178223 13.75166893005371 M 9.888258934020996 16.55648612976074 C 8.843273162841797 16.55648612976074 7.794573783874512 16.31111145019531 6.831318855285645 15.8139591217041 C 4.614439010620117 14.66977882385254 3.221879959106445 12.38361930847168 3.222219467163086 9.888889312744141 C 3.220088958740234 8.504219055175781 3.651140213012695 7.153559684753418 4.454998970031738 6.02610969543457 L 13.75166893005371 15.32333946228027 C 12.60186290740967 16.14075088500977 11.24825286865234 16.55648612976074 9.888258934020996 16.55648612976074 M 9.888889312744141 0 C 15.34163951873779 0 19.77777862548828 4.436139106750488 19.77777862548828 9.888889312744141 C 19.77777862548828 15.34163951873779 15.34163951873779 19.77777862548828 9.888889312744141 19.77777862548828 C 4.436139106750488 19.77777862548828 0 15.34163951873779 0 9.888889312744141 C 0 4.436139106750488 4.436139106750488 0 9.888889312744141 0 Z M 15.10232830047607 12.11699867248535 C 15.40205764770508 11.41858959197998 15.55679702758789 10.66494941711426 15.5555591583252 9.89048957824707 C 15.5556697845459 7.759209632873535 14.38009929656982 5.829549789428711 12.48761940002441 4.852889060974121 C 11.68764972686768 4.440059661865234 10.78924942016602 4.22184944152832 9.889529228210449 4.22184944152832 C 9.114802360534668 4.22184944152832 8.360831260681152 4.377038955688477 7.661839485168457 4.676509857177734 L 15.10232830047607 12.11699867248535 Z M 12.11597919464111 15.10181331634521 L 4.675475120544434 7.660861015319824 C 4.375750541687012 8.359296798706055 4.221027374267578 9.112875938415527 4.222219467163086 9.887349128723145 C 4.221929550170898 12.01874923706055 5.397418975830078 13.94855880737305 7.289958953857422 14.92533874511719 C 8.08997917175293 15.3382396697998 8.988459587097168 15.55648994445801 9.888258934020996 15.55648994445801 C 10.66298007965088 15.55648994445801 11.41698551177979 15.40128421783447 12.11597919464111 15.10181331634521 Z\"\n stroke=\"none\"\n fill=\"var(--spectrum-swatch-disabled-icon-stroke-color)\"\n />\n </svg>\n `;\n };\n\n protected renderMixedValue = (): TemplateResult => {\n return dashIcon[this.size]();\n };\n\n protected override render(): TemplateResult {\n return html`\n <div\n class=\"opacity-checkerboard fill\"\n style=${ifDefined(\n this.color\n ? `--spectrum-picked-color: ${this.color}`\n : undefined\n )}\n >\n <slot name=\"image\"></slot>\n ${when(this.disabled, this.renderDisabled)}\n ${when(this.mixedValue, this.renderMixedValue)}\n </div>\n `;\n }\n\n protected override willUpdate(changes: PropertyValues): void {\n if (!this.getAttribute('role')) {\n this.setAttribute('role', 'button');\n }\n if (changes.has('selected') || changes.has('role')) {\n const selectedAttribute =\n this.role === 'button' ? 'aria-pressed' : 'aria-checked';\n const removedSelectedAttribute =\n this.role === 'button' ? 'aria-checked' : 'aria-pressed';\n if (changes.has('role')) {\n this.removeAttribute(removedSelectedAttribute);\n }\n this.setAttribute(\n selectedAttribute,\n this.selected ? 'true' : 'false'\n );\n }\n\n // aria-label should be in sync with changes in label and color.\n if (\n changes.has('label') ||\n changes.has('color') ||\n changes.has('mixedValue')\n ) {\n if (this.label !== this.color && this.label?.length) {\n this.setAttribute('aria-label', this.label);\n } else if (this.color) {\n this.setAttribute('aria-label', this.color);\n } else if (this.mixedValue) {\n this.setAttribute('aria-label', 'Mixed');\n } else {\n this.removeAttribute('aria-label');\n }\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.addEventListener('click', this.handleClick);\n this.addEventListener('keydown', this.handleKeydown);\n this.addEventListener('keypress', this.handleKeypress);\n if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0');\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAWA;AAAA,EAEI;AAAA,EAEA;AAAA,OAEG;AACP,SAAS,gBAAgB;AACzB;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAC1B,OAAO,+BAA+B;AACtC,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AAEP,OAAO,YAAY;AACnB,OAAO,gBAAgB;AACvB,OAAO,wBAAwB;AAM/B,MAAM,WAAiD;AAAA,EACnD,IAAI,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMV,GAAG,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,GAAG,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,GAAG,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAMb;AAKO,aAAM,eAAe,WAAW,WAAW;AAAA,EAC9C,YAAY,CAAC,MAAM,KAAK,KAAK,GAAG;AAAA,EAChC,eAAe;AACnB,CAAC,EAAE;AAAA,EAHI;AAAA;AAiBH,SAAO,QAAQ;AAGf,SAAO,QAAQ;AAGf,SAAO,aAAa;AAGpB,SAAO,UAAU;AAGjB,SAAgB,OAAO;AAMvB,SAAO,WAAW;AAgFlB,SAAU,iBAAiB,MAAsB;AAC7C,aAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkBX;AAEA,SAAU,mBAAmB,MAAsB;AAC/C,aAAO,SAAS,KAAK,IAAI,EAAE;AAA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KAAK,WAAW;AAC/C,SAAK,iBAAiB,WAAW,KAAK,aAAa;AACnD,SAAK,iBAAiB,YAAY,KAAK,cAAc;AACrD,QAAI,CAAC,KAAK,aAAa,UAAU,GAAG;AAChC,WAAK,aAAa,YAAY,GAAG;AAAA,IACrC;AAAA,EACJ;AACJ;AA5LW;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAblB,OAcF;AAGA;AAAA,EADN,SAAS;AAAA,GAhBD,OAiBF;AAGA;AAAA,EADN,SAAS;AAAA,GAnBD,OAoBF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,cAAc,CAAC;AAAA,GAtB3D,OAuBF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAzBjC,OA0BF;AAGS;AAAA,EADf,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GA5BlB,OA6BO;AAGT;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GA/BlB,OAgCF;AAGA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAlCjC,OAmCF;AAGA;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GArClB,OAsCF;AAGH;AAAA,EADH,SAAS;AAAA,GAxCD,OAyCL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/Swatch.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var i=(d,a,e,t)=>{for(var r=t>1?void 0:t?p(a,e):a,o=d.length-1,n;o>=0;o--)(n=d[o])&&(r=(t?n(a,e,r):n(r))||r);return t&&r&&u(a,e,r),r};import{html as l,SizedMixin as h}from"@spectrum-web-components/base";import{property as s}from"@spectrum-web-components/base/src/decorators.js";import{ifDefined as b,when as c}from"@spectrum-web-components/base/src/directives.js";import{Focusable as m}from"@spectrum-web-components/shared/src/focusable.js";import v from"@spectrum-web-components/opacity-checkerboard/src/opacity-checkerboard.css.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-dash75.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-dash100.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-dash200.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-dash300.js";import f from"./swatch.css.js";import y from"@spectrum-web-components/icon/src/spectrum-icon-dash.css.js";import C from"@spectrum-web-components/icon/src/icon-dash-overrides.css.js";const x={xs:()=>l`
|
|
2
|
+
<sp-icon-dash75
|
|
3
|
+
slot="icon"
|
|
4
|
+
class="mixedValueIcon spectrum-UIIcon-Dash75"
|
|
5
|
+
></sp-icon-dash75>
|
|
6
|
+
`,s:()=>l`
|
|
7
|
+
<sp-icon-dash100
|
|
8
|
+
slot="icon"
|
|
9
|
+
class="mixedValueIcon spectrum-UIIcon-Dash100"
|
|
10
|
+
></sp-icon-dash100>
|
|
11
|
+
`,m:()=>l`
|
|
12
|
+
<sp-icon-dash200
|
|
13
|
+
slot="icon"
|
|
14
|
+
class="mixedValueIcon spectrum-UIIcon-Dash200"
|
|
15
|
+
></sp-icon-dash200>
|
|
16
|
+
`,l:()=>l`
|
|
17
|
+
<sp-icon-dash300
|
|
18
|
+
slot="icon"
|
|
19
|
+
class="mixedValueIcon spectrum-UIIcon-Dash300"
|
|
20
|
+
></sp-icon-dash300>
|
|
21
|
+
`};export class Swatch extends h(m,{validSizes:["xs","s","m","l"],noDefaultSize:!0}){constructor(){super(...arguments);this.color="";this.label="";this.mixedValue=!1;this.nothing=!1;this.role="button";this.selected=!1;this.renderDisabled=()=>l`
|
|
22
|
+
<svg
|
|
23
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
24
|
+
class="disabledIcon"
|
|
25
|
+
viewBox="0 0 20 20"
|
|
26
|
+
>
|
|
27
|
+
<path
|
|
28
|
+
d="M9.889,1a8.889,8.889,0,1,0,8.889,8.889A8.889,8.889,0,0,0,9.889,1Zm6.667,8.889a6.635,6.635,0,0,1-1.233,3.863l-9.3-9.3A6.667,6.667,0,0,1,16.556,9.889Zm-13.333,0A6.636,6.636,0,0,1,4.455,6.026l9.3,9.3A6.667,6.667,0,0,1,3.222,9.889Z"
|
|
29
|
+
stroke="none"
|
|
30
|
+
fill="var(--spectrum-swatch-disabled-icon-color)"
|
|
31
|
+
/>
|
|
32
|
+
<path
|
|
33
|
+
d="M 9.888889312744141 1 C 4.979689598083496 1 1 4.979689598083496 1 9.888889312744141 C 1 14.7980899810791 4.979689598083496 18.77777862548828 9.888889312744141 18.77777862548828 C 14.7980899810791 18.77777862548828 18.77777862548828 14.7980899810791 18.77777862548828 9.888889312744141 C 18.77777862548828 4.979689598083496 14.7980899810791 1 9.888889312744141 1 M 15.32277870178223 13.75166893005371 L 6.02610969543457 4.454998970031738 C 8.059318542480469 3.009572982788086 10.72937774658203 2.820217132568359 12.9462194442749 3.964249610900879 C 15.16304969787598 5.10828971862793 16.55568885803223 7.394259452819824 16.5555591583252 9.888889312744141 C 16.55776977539062 11.27357959747314 16.126708984375 12.62425994873047 15.32277870178223 13.75166893005371 M 9.888258934020996 16.55648612976074 C 8.843273162841797 16.55648612976074 7.794573783874512 16.31111145019531 6.831318855285645 15.8139591217041 C 4.614439010620117 14.66977882385254 3.221879959106445 12.38361930847168 3.222219467163086 9.888889312744141 C 3.220088958740234 8.504219055175781 3.651140213012695 7.153559684753418 4.454998970031738 6.02610969543457 L 13.75166893005371 15.32333946228027 C 12.60186290740967 16.14075088500977 11.24825286865234 16.55648612976074 9.888258934020996 16.55648612976074 M 9.888889312744141 0 C 15.34163951873779 0 19.77777862548828 4.436139106750488 19.77777862548828 9.888889312744141 C 19.77777862548828 15.34163951873779 15.34163951873779 19.77777862548828 9.888889312744141 19.77777862548828 C 4.436139106750488 19.77777862548828 0 15.34163951873779 0 9.888889312744141 C 0 4.436139106750488 4.436139106750488 0 9.888889312744141 0 Z M 15.10232830047607 12.11699867248535 C 15.40205764770508 11.41858959197998 15.55679702758789 10.66494941711426 15.5555591583252 9.89048957824707 C 15.5556697845459 7.759209632873535 14.38009929656982 5.829549789428711 12.48761940002441 4.852889060974121 C 11.68764972686768 4.440059661865234 10.78924942016602 4.22184944152832 9.889529228210449 4.22184944152832 C 9.114802360534668 4.22184944152832 8.360831260681152 4.377038955688477 7.661839485168457 4.676509857177734 L 15.10232830047607 12.11699867248535 Z M 12.11597919464111 15.10181331634521 L 4.675475120544434 7.660861015319824 C 4.375750541687012 8.359296798706055 4.221027374267578 9.112875938415527 4.222219467163086 9.887349128723145 C 4.221929550170898 12.01874923706055 5.397418975830078 13.94855880737305 7.289958953857422 14.92533874511719 C 8.08997917175293 15.3382396697998 8.988459587097168 15.55648994445801 9.888258934020996 15.55648994445801 C 10.66298007965088 15.55648994445801 11.41698551177979 15.40128421783447 12.11597919464111 15.10181331634521 Z"
|
|
34
|
+
stroke="none"
|
|
35
|
+
fill="var(--spectrum-swatch-disabled-icon-stroke-color)"
|
|
36
|
+
/>
|
|
37
|
+
</svg>
|
|
38
|
+
`;this.renderMixedValue=()=>x[this.size]()}static get styles(){return[v,f,y,C]}get value(){return this._value||this.color||this.label}set value(e){if(e===this._value)return;const t=this.value;this._value=e,this.requestUpdate("value",t)}get focusElement(){return this}toggle(e){this.selected=e!=null?e:!this.selected}handleClick(){if(this.disabled||this.mixedValue)return;this.toggle(),this.dispatchEvent(new Event("change",{cancelable:!0,bubbles:!0}))||this.toggle()}handleKeydown(e){const{code:t}=e;switch(t){case"Space":e.preventDefault(),this.addEventListener("keyup",this.handleKeyup);break;default:break}}handleKeypress(e){const{code:t}=e;switch(t){case"Enter":case"NumpadEnter":this.click();break;default:break}}handleKeyup(e){const{code:t}=e;switch(t){case"Space":this.removeEventListener("keyup",this.handleKeyup),this.click();break;default:break}}render(){return l`
|
|
39
|
+
<div
|
|
40
|
+
class="opacity-checkerboard fill"
|
|
41
|
+
style=${b(this.color?`--spectrum-picked-color: ${this.color}`:void 0)}
|
|
42
|
+
>
|
|
43
|
+
<slot name="image"></slot>
|
|
44
|
+
${c(this.disabled,this.renderDisabled)}
|
|
45
|
+
${c(this.mixedValue,this.renderMixedValue)}
|
|
46
|
+
</div>
|
|
47
|
+
`}willUpdate(e){var t;if(this.getAttribute("role")||this.setAttribute("role","button"),e.has("selected")||e.has("role")){const r=this.role==="button"?"aria-pressed":"aria-checked",o=this.role==="button"?"aria-checked":"aria-pressed";e.has("role")&&this.removeAttribute(o),this.setAttribute(r,this.selected?"true":"false")}(e.has("label")||e.has("color")||e.has("mixedValue"))&&(this.label!==this.color&&((t=this.label)!=null&&t.length)?this.setAttribute("aria-label",this.label):this.color?this.setAttribute("aria-label",this.color):this.mixedValue?this.setAttribute("aria-label","Mixed"):this.removeAttribute("aria-label"))}firstUpdated(e){super.firstUpdated(e),this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeydown),this.addEventListener("keypress",this.handleKeypress),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0")}}i([s({reflect:!0})],Swatch.prototype,"border",2),i([s()],Swatch.prototype,"color",2),i([s()],Swatch.prototype,"label",2),i([s({type:Boolean,reflect:!0,attribute:"mixed-value"})],Swatch.prototype,"mixedValue",2),i([s({type:Boolean,reflect:!0})],Swatch.prototype,"nothing",2),i([s({reflect:!0})],Swatch.prototype,"role",2),i([s({reflect:!0})],Swatch.prototype,"rounding",2),i([s({type:Boolean,reflect:!0})],Swatch.prototype,"selected",2),i([s({reflect:!0})],Swatch.prototype,"shape",2),i([s()],Swatch.prototype,"value",1);
|
|
48
|
+
//# sourceMappingURL=Swatch.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["Swatch.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 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*/\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport {\n ifDefined,\n when,\n} from '@spectrum-web-components/base/src/directives.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport opacityCheckerboardStyles from '@spectrum-web-components/opacity-checkerboard/src/opacity-checkerboard.css.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-dash75.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-dash100.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-dash200.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-dash300.js';\n\nimport styles from './swatch.css.js';\nimport dashStyles from '@spectrum-web-components/icon/src/spectrum-icon-dash.css.js';\nimport dashSmallOverrides from '@spectrum-web-components/icon/src/icon-dash-overrides.css.js';\n\nexport type SwatchBorder = 'light' | 'none' | undefined;\nexport type SwatchRounding = 'none' | 'full' | undefined;\nexport type SwatchShape = 'rectangle' | undefined;\n\nconst dashIcon: Record<string, () => TemplateResult> = {\n xs: () => html`\n <sp-icon-dash75\n slot=\"icon\"\n class=\"mixedValueIcon spectrum-UIIcon-Dash75\"\n ></sp-icon-dash75>\n `,\n s: () => html`\n <sp-icon-dash100\n slot=\"icon\"\n class=\"mixedValueIcon spectrum-UIIcon-Dash100\"\n ></sp-icon-dash100>\n `,\n m: () => html`\n <sp-icon-dash200\n slot=\"icon\"\n class=\"mixedValueIcon spectrum-UIIcon-Dash200\"\n ></sp-icon-dash200>\n `,\n l: () => html`\n <sp-icon-dash300\n slot=\"icon\"\n class=\"mixedValueIcon spectrum-UIIcon-Dash300\"\n ></sp-icon-dash300>\n `,\n};\n\n/**\n * @element sp-swatch\n */\nexport class Swatch extends SizedMixin(Focusable, {\n validSizes: ['xs', 's', 'm', 'l'],\n noDefaultSize: true,\n}) {\n public static override get styles(): CSSResultArray {\n return [\n opacityCheckerboardStyles,\n styles,\n dashStyles,\n dashSmallOverrides,\n ];\n }\n\n @property({ reflect: true })\n public border: SwatchBorder;\n\n @property()\n public color = '';\n\n @property()\n public label = '';\n\n @property({ type: Boolean, reflect: true, attribute: 'mixed-value' })\n public mixedValue = false;\n\n @property({ type: Boolean, reflect: true })\n public nothing = false;\n\n @property({ reflect: true })\n public override role = 'button';\n\n @property({ reflect: true })\n public rounding: SwatchRounding;\n\n @property({ type: Boolean, reflect: true })\n public selected = false;\n\n @property({ reflect: true })\n public shape: SwatchShape;\n\n @property()\n get value(): string {\n return this._value || this.color || this.label;\n }\n\n set value(value: string) {\n if (value === this._value) return;\n const oldValue = this.value;\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n private _value?: string;\n\n public override get focusElement(): HTMLElement {\n return this;\n }\n\n public toggle(force?: boolean): void {\n this.selected = force ?? !this.selected;\n }\n\n private handleClick(): void {\n if (this.disabled || this.mixedValue) return;\n this.toggle();\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n bubbles: true,\n })\n );\n if (!applyDefault) {\n this.toggle();\n }\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n event.preventDefault();\n this.addEventListener('keyup', this.handleKeyup);\n break;\n /* c8 ignore next 2 */\n default:\n break;\n }\n }\n\n private handleKeypress(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Enter':\n case 'NumpadEnter':\n this.click();\n break;\n /* c8 ignore next 2 */\n default:\n break;\n }\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n const { code } = event;\n switch (code) {\n case 'Space':\n this.removeEventListener('keyup', this.handleKeyup);\n this.click();\n break;\n /* c8 ignore next 2 */\n default:\n break;\n }\n }\n\n protected renderDisabled = (): TemplateResult => {\n return html`\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"disabledIcon\"\n viewBox=\"0 0 20 20\"\n >\n <path\n d=\"M9.889,1a8.889,8.889,0,1,0,8.889,8.889A8.889,8.889,0,0,0,9.889,1Zm6.667,8.889a6.635,6.635,0,0,1-1.233,3.863l-9.3-9.3A6.667,6.667,0,0,1,16.556,9.889Zm-13.333,0A6.636,6.636,0,0,1,4.455,6.026l9.3,9.3A6.667,6.667,0,0,1,3.222,9.889Z\"\n stroke=\"none\"\n fill=\"var(--spectrum-swatch-disabled-icon-color)\"\n />\n <path\n d=\"M 9.888889312744141 1 C 4.979689598083496 1 1 4.979689598083496 1 9.888889312744141 C 1 14.7980899810791 4.979689598083496 18.77777862548828 9.888889312744141 18.77777862548828 C 14.7980899810791 18.77777862548828 18.77777862548828 14.7980899810791 18.77777862548828 9.888889312744141 C 18.77777862548828 4.979689598083496 14.7980899810791 1 9.888889312744141 1 M 15.32277870178223 13.75166893005371 L 6.02610969543457 4.454998970031738 C 8.059318542480469 3.009572982788086 10.72937774658203 2.820217132568359 12.9462194442749 3.964249610900879 C 15.16304969787598 5.10828971862793 16.55568885803223 7.394259452819824 16.5555591583252 9.888889312744141 C 16.55776977539062 11.27357959747314 16.126708984375 12.62425994873047 15.32277870178223 13.75166893005371 M 9.888258934020996 16.55648612976074 C 8.843273162841797 16.55648612976074 7.794573783874512 16.31111145019531 6.831318855285645 15.8139591217041 C 4.614439010620117 14.66977882385254 3.221879959106445 12.38361930847168 3.222219467163086 9.888889312744141 C 3.220088958740234 8.504219055175781 3.651140213012695 7.153559684753418 4.454998970031738 6.02610969543457 L 13.75166893005371 15.32333946228027 C 12.60186290740967 16.14075088500977 11.24825286865234 16.55648612976074 9.888258934020996 16.55648612976074 M 9.888889312744141 0 C 15.34163951873779 0 19.77777862548828 4.436139106750488 19.77777862548828 9.888889312744141 C 19.77777862548828 15.34163951873779 15.34163951873779 19.77777862548828 9.888889312744141 19.77777862548828 C 4.436139106750488 19.77777862548828 0 15.34163951873779 0 9.888889312744141 C 0 4.436139106750488 4.436139106750488 0 9.888889312744141 0 Z M 15.10232830047607 12.11699867248535 C 15.40205764770508 11.41858959197998 15.55679702758789 10.66494941711426 15.5555591583252 9.89048957824707 C 15.5556697845459 7.759209632873535 14.38009929656982 5.829549789428711 12.48761940002441 4.852889060974121 C 11.68764972686768 4.440059661865234 10.78924942016602 4.22184944152832 9.889529228210449 4.22184944152832 C 9.114802360534668 4.22184944152832 8.360831260681152 4.377038955688477 7.661839485168457 4.676509857177734 L 15.10232830047607 12.11699867248535 Z M 12.11597919464111 15.10181331634521 L 4.675475120544434 7.660861015319824 C 4.375750541687012 8.359296798706055 4.221027374267578 9.112875938415527 4.222219467163086 9.887349128723145 C 4.221929550170898 12.01874923706055 5.397418975830078 13.94855880737305 7.289958953857422 14.92533874511719 C 8.08997917175293 15.3382396697998 8.988459587097168 15.55648994445801 9.888258934020996 15.55648994445801 C 10.66298007965088 15.55648994445801 11.41698551177979 15.40128421783447 12.11597919464111 15.10181331634521 Z\"\n stroke=\"none\"\n fill=\"var(--spectrum-swatch-disabled-icon-stroke-color)\"\n />\n </svg>\n `;\n };\n\n protected renderMixedValue = (): TemplateResult => {\n return dashIcon[this.size]();\n };\n\n protected override render(): TemplateResult {\n return html`\n <div\n class=\"opacity-checkerboard fill\"\n style=${ifDefined(\n this.color\n ? `--spectrum-picked-color: ${this.color}`\n : undefined\n )}\n >\n <slot name=\"image\"></slot>\n ${when(this.disabled, this.renderDisabled)}\n ${when(this.mixedValue, this.renderMixedValue)}\n </div>\n `;\n }\n\n protected override willUpdate(changes: PropertyValues): void {\n if (!this.getAttribute('role')) {\n this.setAttribute('role', 'button');\n }\n if (changes.has('selected') || changes.has('role')) {\n const selectedAttribute =\n this.role === 'button' ? 'aria-pressed' : 'aria-checked';\n const removedSelectedAttribute =\n this.role === 'button' ? 'aria-checked' : 'aria-pressed';\n if (changes.has('role')) {\n this.removeAttribute(removedSelectedAttribute);\n }\n this.setAttribute(\n selectedAttribute,\n this.selected ? 'true' : 'false'\n );\n }\n\n // aria-label should be in sync with changes in label and color.\n if (\n changes.has('label') ||\n changes.has('color') ||\n changes.has('mixedValue')\n ) {\n if (this.label !== this.color && this.label?.length) {\n this.setAttribute('aria-label', this.label);\n } else if (this.color) {\n this.setAttribute('aria-label', this.color);\n } else if (this.mixedValue) {\n this.setAttribute('aria-label', 'Mixed');\n } else {\n this.removeAttribute('aria-label');\n }\n }\n }\n\n protected override firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.addEventListener('click', this.handleClick);\n this.addEventListener('keydown', this.handleKeydown);\n this.addEventListener('keypress', this.handleKeypress);\n if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0');\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAWA,OAEI,QAAAA,EAEA,cAAAC,MAEG,gCACP,OAAS,YAAAC,MAAgB,kDACzB,OACI,aAAAC,EACA,QAAAC,MACG,kDACP,OAAS,aAAAC,MAAiB,mDAC1B,OAAOC,MAA+B,gFACtC,MAAO,4DACP,MAAO,6DACP,MAAO,6DACP,MAAO,6DAEP,OAAOC,MAAY,kBACnB,OAAOC,MAAgB,8DACvB,OAAOC,MAAwB,+DAM/B,MAAMC,EAAiD,CACnD,GAAI,IAAMV;AAAA;AAAA;AAAA;AAAA;AAAA,MAMV,EAAG,IAAMA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMT,EAAG,IAAMA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMT,EAAG,IAAMA;AAAA;AAAA;AAAA;AAAA;AAAA,KAMb,EAKO,aAAM,eAAeC,EAAWI,EAAW,CAC9C,WAAY,CAAC,KAAM,IAAK,IAAK,GAAG,EAChC,cAAe,EACnB,CAAC,CAAE,CAHI,kCAiBH,KAAO,MAAQ,GAGf,KAAO,MAAQ,GAGf,KAAO,WAAa,GAGpB,KAAO,QAAU,GAGjB,KAAgB,KAAO,S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EAAA,CADNlB,EAAS,GAhBD,OAiBF,qBAGAkB,EAAA,CADNlB,EAAS,GAnBD,OAoBF,qBAGAkB,EAAA,CADNlB,EAAS,CAAE,KAAM,QAAS,QAAS,GAAM,UAAW,aAAc,CAAC,GAtB3D,OAuBF,0BAGAkB,EAAA,CADNlB,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAzBjC,OA0BF,uBAGSkB,EAAA,CADflB,EAAS,CAAE,QAAS,EAAK,CAAC,GA5BlB,OA6BO,oBAGTkB,EAAA,CADNlB,EAAS,CAAE,QAAS,EAAK,CAAC,GA/BlB,OAgCF,wBAGAkB,EAAA,CADNlB,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAlCjC,OAmCF,wBAGAkB,EAAA,CADNlB,EAAS,CAAE,QAAS,EAAK,CAAC,GArClB,OAsCF,qBAGHkB,EAAA,CADHlB,EAAS,GAxCD,OAyCL",
|
|
6
|
+
"names": ["html", "SizedMixin", "property", "ifDefined", "when", "Focusable", "opacityCheckerboardStyles", "styles", "dashStyles", "dashSmallOverrides", "dashIcon", "value", "oldValue", "force", "event", "code", "changes", "_a", "selectedAttribute", "removedSelectedAttribute", "__decorateClass"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CSSResultArray, ElementSize, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
+
import { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';
|
|
3
|
+
import type { Swatch, SwatchBorder, SwatchRounding, SwatchShape } from './Swatch.js';
|
|
4
|
+
export type SwatchGroupSizes = Exclude<ElementSize, 'xxs' | 'xl' | 'xxl'>;
|
|
5
|
+
export type SwatchSelects = 'single' | 'multiple' | undefined;
|
|
6
|
+
declare const SwatchGroup_base: typeof SpectrumElement & {
|
|
7
|
+
new (...args: any[]): import("@spectrum-web-components/base").SizedElementInterface;
|
|
8
|
+
prototype: import("@spectrum-web-components/base").SizedElementInterface;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @element sp-swatch-group
|
|
12
|
+
*
|
|
13
|
+
* @slot - Swatch elements to manage as a group
|
|
14
|
+
*/
|
|
15
|
+
export declare class SwatchGroup extends SwatchGroup_base {
|
|
16
|
+
static get styles(): CSSResultArray;
|
|
17
|
+
border: SwatchBorder;
|
|
18
|
+
density: 'compact' | 'spacious' | undefined;
|
|
19
|
+
rounding: SwatchRounding;
|
|
20
|
+
get selected(): string[];
|
|
21
|
+
set selected(selected: string[]);
|
|
22
|
+
private _selected;
|
|
23
|
+
selects: SwatchSelects;
|
|
24
|
+
private selectedSet;
|
|
25
|
+
shape: SwatchShape;
|
|
26
|
+
swatches: Swatch[];
|
|
27
|
+
constructor();
|
|
28
|
+
rovingTabindexController: RovingTabindexController<Swatch>;
|
|
29
|
+
focus(options?: FocusOptions): void;
|
|
30
|
+
protected handleChange(event: Event & {
|
|
31
|
+
target: Swatch;
|
|
32
|
+
}): void;
|
|
33
|
+
private manageChange;
|
|
34
|
+
private getPassthroughSwatchActions;
|
|
35
|
+
private getSelectionSwatchActions;
|
|
36
|
+
protected render(): TemplateResult;
|
|
37
|
+
protected willUpdate(changes: PropertyValues<this>): void;
|
|
38
|
+
}
|
|
39
|
+
export {};
|