@spectrum-web-components/swatch 0.1.0

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.
Files changed (50) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +247 -0
  3. package/custom-elements.json +600 -0
  4. package/package.json +64 -0
  5. package/sp-swatch-group.d.ts +6 -0
  6. package/sp-swatch-group.js +14 -0
  7. package/sp-swatch-group.js.map +1 -0
  8. package/sp-swatch.d.ts +6 -0
  9. package/sp-swatch.js +14 -0
  10. package/sp-swatch.js.map +1 -0
  11. package/src/Swatch.d.ts +43 -0
  12. package/src/Swatch.js +224 -0
  13. package/src/Swatch.js.map +1 -0
  14. package/src/SwatchGroup.d.ts +36 -0
  15. package/src/SwatchGroup.js +235 -0
  16. package/src/SwatchGroup.js.map +1 -0
  17. package/src/index.d.ts +2 -0
  18. package/src/index.js +14 -0
  19. package/src/index.js.map +1 -0
  20. package/src/spectrum-config.js +160 -0
  21. package/src/spectrum-swatch-group.css.d.ts +2 -0
  22. package/src/spectrum-swatch-group.css.js +21 -0
  23. package/src/spectrum-swatch-group.css.js.map +1 -0
  24. package/src/spectrum-swatch.css.d.ts +2 -0
  25. package/src/spectrum-swatch.css.js +77 -0
  26. package/src/spectrum-swatch.css.js.map +1 -0
  27. package/src/swatch-group.css.d.ts +2 -0
  28. package/src/swatch-group.css.js +21 -0
  29. package/src/swatch-group.css.js.map +1 -0
  30. package/src/swatch.css.d.ts +2 -0
  31. package/src/swatch.css.js +77 -0
  32. package/src/swatch.css.js.map +1 -0
  33. package/stories/swatch-group.stories.js +186 -0
  34. package/stories/swatch-group.stories.js.map +1 -0
  35. package/stories/swatch-sizes.stories.js +45 -0
  36. package/stories/swatch-sizes.stories.js.map +1 -0
  37. package/stories/swatch.stories.js +104 -0
  38. package/stories/swatch.stories.js.map +1 -0
  39. package/test/benchmark/basic-test.js +18 -0
  40. package/test/benchmark/basic-test.js.map +1 -0
  41. package/test/swatch-group.test-vrt.js +15 -0
  42. package/test/swatch-group.test-vrt.js.map +1 -0
  43. package/test/swatch-group.test.js +262 -0
  44. package/test/swatch-group.test.js.map +1 -0
  45. package/test/swatch-sizes.test-vrt.js +15 -0
  46. package/test/swatch-sizes.test-vrt.js.map +1 -0
  47. package/test/swatch.test-vrt.js +15 -0
  48. package/test/swatch.test-vrt.js.map +1 -0
  49. package/test/swatch.test.js +148 -0
  50. package/test/swatch.test.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swatch-group.stories.js","sourceRoot":"","sources":["swatch-group.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAE5E,OAAO,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,CAAC;AAiBzB,eAAe;IACX,KAAK,EAAE,cAAc;IACrB,SAAS,EAAE,iBAAiB;IAC5B,IAAI,EAAE,EAAE;IACR,QAAQ,EAAE;QACN,MAAM,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;YACzC,WAAW,EAAE,6CAA6C;YAC1D,KAAK,EAAE;gBACH,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;aAChC;YACD,OAAO,EAAE;gBACL,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC;aACvC;SACJ;QACD,OAAO,EAAE;YACL,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;YACzC,WAAW,EAAE,sDAAsD;YACnE,KAAK,EAAE;gBACH,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;aAChC;YACD,OAAO,EAAE;gBACL,IAAI,EAAE,cAA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AC,CAAC;AAChF,WAAW,CAAC,IAAI,GAAG;IACf,MAAM,EAAE,OAAO;CACJ,CAAC;AAChB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAgB,EAAkB,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC/E,UAAU,CAAC,IAAI,GAAG;IACd,MAAM,EAAE,MAAM;CACH,CAAC;AAChB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAgB,EAAkB,EAAE,CAC7D,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnB,YAAY,CAAC,IAAI,GAAG;IAChB,QAAQ,EAAE,MAAM;CACL,CAAC;AAChB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAgB,EAAkB,EAAE,CAC7D,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnB,YAAY,CAAC,IAAI,GAAG;IAChB,QAAQ,EAAE,MAAM;CACL,CAAC;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAgB,EAAkB,EAAE,CAC/D,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnB,cAAc,CAAC,IAAI,GAAG;IAClB,KAAK,EAAE,WAAW;CACP,CAAC","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 { html, TemplateResult } from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport '../sp-swatch-group.js';\nimport '../sp-swatch.js';\nimport type {\n SwatchBorder,\n SwatchRounding,\n SwatchShape,\n} from '../src/Swatch.js';\nimport { SwatchGroup } from '../src/SwatchGroup.js';\n\ntype Properties = {\n border: SwatchBorder | 'normal';\n density?: 'normal' | 'spacious' | 'compact';\n rounding?: SwatchRounding | 'normal';\n selected?: string[];\n selects?: 'none' | 'single' | 'multiple';\n shape?: SwatchShape | 'normal';\n};\n\nexport default {\n title: 'Swatch group',\n component: 'sp-swatch-group',\n args: {},\n argTypes: {\n border: {\n name: 'border',\n type: { name: 'string', required: false },\n description: 'The border to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'light', 'none'],\n },\n },\n density: {\n name: 'density',\n type: { name: 'string', required: false },\n description: 'The density at which to display the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'compact', 'spacious'],\n },\n },\n rounding: {\n name: 'rounding',\n type: { name: 'string', required: false },\n description: 'The rounding to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'none', 'full'],\n },\n },\n selects: {\n name: 'selects',\n type: { name: 'string', required: false },\n description:\n 'Whether the Swatch Group manages a selection, and whether it is a sinlge or multiple selection.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['none', 'single', 'multiple'],\n },\n },\n shape: {\n name: 'shape',\n type: { name: 'string', required: false },\n description: 'The shape to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'rectangle'],\n },\n },\n },\n decorators: [\n (story: () => TemplateResult): TemplateResult => html`\n <div\n @change=${async (event: Event & { target: SwatchGroup }) => {\n await 0;\n if (event.defaultPrevented) return;\n const next = event.target\n .nextElementSibling as HTMLDivElement;\n next.textContent = `Selected: ${JSON.stringify(\n event.target.selected\n )}`;\n }}\n >\n ${story()}\n <div>Selected: []</div>\n </div>\n `,\n ],\n};\n\nconst colors = [\n '--spectrum-global-color-gray-500',\n '--spectrum-global-color-red-500',\n '--spectrum-global-color-orange-500',\n '--spectrum-global-color-yellow-500',\n '--spectrum-global-color-chartreuse-500',\n '--spectrum-global-color-celery-500',\n '--spectrum-global-color-green-500',\n '--spectrum-global-color-seafoam-500',\n '--spectrum-global-color-blue-500',\n '--spectrum-global-color-indigo-500',\n '--spectrum-global-color-purple-500',\n '--spectrum-global-color-fuchsia-500',\n '--spectrum-global-color-magenta-500',\n];\n\nconst template = ({\n border,\n density,\n rounding,\n selects,\n selected = [],\n shape,\n}: Properties): TemplateResult => {\n const groupLabel = !!selects\n ? selects === 'single'\n ? 'Select a color'\n : 'Selects color(s)'\n : undefined;\n return html`\n <sp-swatch-group\n border=${ifDefined(border === 'normal' ? undefined : border)}\n density=${ifDefined(density === 'normal' ? undefined : density)}\n rounding=${ifDefined(rounding === 'normal' ? undefined : rounding)}\n selects=${ifDefined(selects === 'none' ? undefined : selects)}\n .selected=${selected}\n shape=${ifDefined(shape === 'normal' ? undefined : shape)}\n aria-label=${ifDefined(groupLabel)}\n >\n ${colors.map(\n (color) => html`\n <sp-swatch\n color=\"var(${color})\"\n label=${color}\n value=${color}\n ></sp-swatch>\n `\n )}\n </sp-swatch-group>\n `;\n};\n\nexport const Default = (args: Properties): TemplateResult => template(args);\nDefault.args = {} as Properties;\nexport const densityCompact = (args: Properties): TemplateResult =>\n template(args);\ndensityCompact.args = {\n density: 'compact',\n} as Properties;\nexport const densitySpacious = (args: Properties): TemplateResult =>\n template(args);\ndensitySpacious.args = {\n density: 'spacious',\n} as Properties;\nexport const selectsSingle = (args: Properties): TemplateResult =>\n template(args);\nselectsSingle.args = {\n selects: 'single',\n selected: ['--spectrum-global-color-yellow-500'],\n} as Properties;\nexport const selectsMultiple = (args: Properties): TemplateResult =>\n template(args);\nselectsMultiple.args = {\n selects: 'multiple',\n selected: [\n '--spectrum-global-color-celery-500',\n '--spectrum-global-color-red-500',\n '--spectrum-global-color-purple-500',\n '--spectrum-global-color-blue-500',\n ],\n} as Properties;\nexport const borderLight = (args: Properties): TemplateResult => template(args);\nborderLight.args = {\n border: 'light',\n} as Properties;\nexport const borderNone = (args: Properties): TemplateResult => template(args);\nborderNone.args = {\n border: 'none',\n} as Properties;\nexport const roundingNone = (args: Properties): TemplateResult =>\n template(args);\nroundingNone.args = {\n rounding: 'none',\n} as Properties;\nexport const roundingFull = (args: Properties): TemplateResult =>\n template(args);\nroundingFull.args = {\n rounding: 'full',\n} as Properties;\nexport const shapeRectangle = (args: Properties): TemplateResult =>\n template(args);\nshapeRectangle.args = {\n shape: 'rectangle',\n} as Properties;\n"]}
@@ -0,0 +1,45 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { html, } from '@spectrum-web-components/base';
13
+ import '../sp-swatch.js';
14
+ export default {
15
+ title: 'Swatch/Sizes',
16
+ component: 'sp-swatch',
17
+ };
18
+ const template = ({ size, color = 'rgb(255 0 0 / 0.7)', }) => html `
19
+ <div style="display: flex; gap: 5px;">
20
+ <sp-swatch color=${color} size=${size}></sp-swatch>
21
+ <sp-swatch color=${color} rounding="none" size=${size}></sp-swatch>
22
+ <sp-swatch color=${color} rounding="full" size=${size}></sp-swatch>
23
+ <sp-swatch color=${color} border="light" size=${size}></sp-swatch>
24
+ <sp-swatch color=${color} border="none" size=${size}></sp-swatch>
25
+ <sp-swatch nothing size=${size}></sp-swatch>
26
+ <sp-swatch color=${color} shape="rectangle" size=${size}></sp-swatch>
27
+ <sp-swatch
28
+ color=${color}
29
+ shape="rectangle"
30
+ size=${size}
31
+ disabled
32
+ ></sp-swatch>
33
+ <sp-swatch
34
+ rounding="full"
35
+ shape="rectangle"
36
+ size=${size}
37
+ mixed-value
38
+ ></sp-swatch>
39
+ </div>
40
+ `;
41
+ export const XS = () => template({ size: 'xs' });
42
+ export const s = () => template({ size: 's' });
43
+ export const m = () => template({ size: 'm' });
44
+ export const l = () => template({ size: 'l' });
45
+ //# sourceMappingURL=swatch-sizes.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swatch-sizes.stories.js","sourceRoot":"","sources":["swatch-sizes.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAEH,IAAI,GAEP,MAAM,+BAA+B,CAAC;AAEvC,OAAO,iBAAiB,CAAC;AAEzB,eAAe;IACX,KAAK,EAAE,cAAc;IACrB,SAAS,EAAE,WAAW;CACzB,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,EACd,IAAI,EACJ,KAAK,GAAG,oBAAoB,GAI/B,EAAkB,EAAE,CAAC,IAAI,CAAA;;2BAEC,KAAK,SAAS,IAAI;2BAClB,KAAK,yBAAyB,IAAI;2BAClC,KAAK,yBAAyB,IAAI;2BAClC,KAAK,wBAAwB,IAAI;2BACjC,KAAK,uBAAuB,IAAI;kCACzB,IAAI;2BACX,KAAK,2BAA2B,IAAI;;oBAE3C,KAAK;;mBAEN,IAAI;;;;;;mBAMJ,IAAI;;;;CAItB,CAAC;AAEF,MAAM,CAAC,MAAM,EAAE,GAAG,GAAmB,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,CAAC,GAAG,GAAmB,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,CAAC,GAAG,GAAmB,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,CAAC,GAAG,GAAmB,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC","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*/\nimport {\n ElementSize,\n html,\n TemplateResult,\n} from '@spectrum-web-components/base';\n\nimport '../sp-swatch.js';\n\nexport default {\n title: 'Swatch/Sizes',\n component: 'sp-swatch',\n};\n\nconst template = ({\n size,\n color = 'rgb(255 0 0 / 0.7)',\n}: {\n size: ElementSize;\n color?: string;\n}): TemplateResult => html`\n <div style=\"display: flex; gap: 5px;\">\n <sp-swatch color=${color} size=${size}></sp-swatch>\n <sp-swatch color=${color} rounding=\"none\" size=${size}></sp-swatch>\n <sp-swatch color=${color} rounding=\"full\" size=${size}></sp-swatch>\n <sp-swatch color=${color} border=\"light\" size=${size}></sp-swatch>\n <sp-swatch color=${color} border=\"none\" size=${size}></sp-swatch>\n <sp-swatch nothing size=${size}></sp-swatch>\n <sp-swatch color=${color} shape=\"rectangle\" size=${size}></sp-swatch>\n <sp-swatch\n color=${color}\n shape=\"rectangle\"\n size=${size}\n disabled\n ></sp-swatch>\n <sp-swatch\n rounding=\"full\"\n shape=\"rectangle\"\n size=${size}\n mixed-value\n ></sp-swatch>\n </div>\n`;\n\nexport const XS = (): TemplateResult => template({ size: 'xs' });\n\nexport const s = (): TemplateResult => template({ size: 's' });\n\nexport const m = (): TemplateResult => template({ size: 'm' });\n\nexport const l = (): TemplateResult => template({ size: 'l' });\n"]}
@@ -0,0 +1,104 @@
1
+ /*
2
+ Copyright 2022 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { html } from '@spectrum-web-components/base';
13
+ import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
14
+ import '../sp-swatch.js';
15
+ export default {
16
+ title: 'Swatch',
17
+ component: 'sp-swatch',
18
+ args: {
19
+ color: '#ff0000',
20
+ },
21
+ argTypes: {
22
+ color: { control: 'color' },
23
+ border: {
24
+ name: 'border',
25
+ type: { name: 'string', required: false },
26
+ description: 'The border to apply to the Swatch children.',
27
+ table: {
28
+ defaultValue: { summary: '' },
29
+ },
30
+ control: {
31
+ type: 'inline-radio',
32
+ options: ['normal', 'light', 'none'],
33
+ },
34
+ },
35
+ rounding: {
36
+ name: 'rounding',
37
+ type: { name: 'string', required: false },
38
+ description: 'The rounding to apply to the Swatch children.',
39
+ table: {
40
+ defaultValue: { summary: '' },
41
+ },
42
+ control: {
43
+ type: 'inline-radio',
44
+ options: ['normal', 'none', 'full'],
45
+ },
46
+ },
47
+ shape: {
48
+ name: 'shape',
49
+ type: { name: 'string', required: false },
50
+ description: 'The shape to apply to the Swatch children.',
51
+ table: {
52
+ defaultValue: { summary: '' },
53
+ },
54
+ control: {
55
+ type: 'inline-radio',
56
+ options: ['normal', 'rectangle'],
57
+ },
58
+ },
59
+ },
60
+ };
61
+ const template = ({ color, border, rounding, shape, mixedValue, nothing, }) => {
62
+ return html `
63
+ <sp-swatch
64
+ border=${ifDefined(border === 'normal' ? undefined : border)}
65
+ rounding=${ifDefined(rounding === 'normal' ? undefined : rounding)}
66
+ shape=${ifDefined(shape === 'normal' ? undefined : shape)}
67
+ color=${color}
68
+ ?mixed-value=${mixedValue}
69
+ ?nothing=${nothing}
70
+ ></sp-swatch>
71
+ `;
72
+ };
73
+ export const Default = (args) => template(args);
74
+ export const mixedValue = (args) => template(args);
75
+ mixedValue.args = {
76
+ mixedValue: true,
77
+ color: '',
78
+ };
79
+ export const nothing = (args) => template(args);
80
+ nothing.args = {
81
+ nothing: true,
82
+ color: '',
83
+ };
84
+ export const borderLight = (args) => template(args);
85
+ borderLight.args = {
86
+ border: 'light',
87
+ };
88
+ export const borderNone = (args) => template(args);
89
+ borderNone.args = {
90
+ border: 'none',
91
+ };
92
+ export const roundingNone = (args) => template(args);
93
+ roundingNone.args = {
94
+ rounding: 'none',
95
+ };
96
+ export const roundingFull = (args) => template(args);
97
+ roundingFull.args = {
98
+ rounding: 'full',
99
+ };
100
+ export const shapeRectangle = (args) => template(args);
101
+ shapeRectangle.args = {
102
+ shape: 'rectangle',
103
+ };
104
+ //# sourceMappingURL=swatch.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swatch.stories.js","sourceRoot":"","sources":["swatch.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAE5E,OAAO,iBAAiB,CAAC;AAgBzB,eAAe;IACX,KAAK,EAAE,QAAQ;IACf,SAAS,EAAE,WAAW;IACtB,IAAI,EAAE;QACF,KAAK,EAAE,SAAS;KACnB;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC3B,MAAM,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;YACzC,WAAW,EAAE,6CAA6C;YAC1D,KAAK,EAAE;gBACH,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;aAChC;YACD,OAAO,EAAE;gBACL,IAAI,EAAE,cAAc;gBACpB,OAAO,EA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AAc,CAAC,IAAI,GAAG;IAClB,KAAK,EAAE,WAAW;CACrB,CAAC","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 { html, TemplateResult } from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport '../sp-swatch.js';\nimport type {\n SwatchBorder,\n SwatchRounding,\n SwatchShape,\n} from '../src/Swatch.js';\n\ntype Properties = {\n color: string;\n border: SwatchBorder | 'normal';\n rounding: SwatchRounding | 'normal';\n shape: SwatchShape | 'normal';\n mixedValue?: boolean;\n nothing?: boolean;\n};\n\nexport default {\n title: 'Swatch',\n component: 'sp-swatch',\n args: {\n color: '#ff0000',\n },\n argTypes: {\n color: { control: 'color' },\n border: {\n name: 'border',\n type: { name: 'string', required: false },\n description: 'The border to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'light', 'none'],\n },\n },\n rounding: {\n name: 'rounding',\n type: { name: 'string', required: false },\n description: 'The rounding to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'none', 'full'],\n },\n },\n shape: {\n name: 'shape',\n type: { name: 'string', required: false },\n description: 'The shape to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'rectangle'],\n },\n },\n },\n};\n\nconst template = ({\n color,\n border,\n rounding,\n shape,\n mixedValue,\n nothing,\n}: Properties): TemplateResult => {\n return html`\n <sp-swatch\n border=${ifDefined(border === 'normal' ? undefined : border)}\n rounding=${ifDefined(rounding === 'normal' ? undefined : rounding)}\n shape=${ifDefined(shape === 'normal' ? undefined : shape)}\n color=${color}\n ?mixed-value=${mixedValue}\n ?nothing=${nothing}\n ></sp-swatch>\n `;\n};\n\nexport const Default = (args: Properties): TemplateResult => template(args);\nexport const mixedValue = (args: Properties): TemplateResult => template(args);\nmixedValue.args = {\n mixedValue: true,\n color: '',\n};\nexport const nothing = (args: Properties): TemplateResult => template(args);\nnothing.args = {\n nothing: true,\n color: '',\n};\nexport const borderLight = (args: Properties): TemplateResult => template(args);\nborderLight.args = {\n border: 'light',\n};\nexport const borderNone = (args: Properties): TemplateResult => template(args);\nborderNone.args = {\n border: 'none',\n};\nexport const roundingNone = (args: Properties): TemplateResult =>\n template(args);\nroundingNone.args = {\n rounding: 'none',\n};\nexport const roundingFull = (args: Properties): TemplateResult =>\n template(args);\nroundingFull.args = {\n rounding: 'full',\n};\nexport const shapeRectangle = (args: Properties): TemplateResult =>\n template(args);\nshapeRectangle.args = {\n shape: 'rectangle',\n};\n"]}
@@ -0,0 +1,18 @@
1
+ /*
2
+ Copyright 2022 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import '@spectrum-web-components/swatch/sp-swatch.js';
13
+ import { html } from '@spectrum-web-components/base';
14
+ import { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';
15
+ measureFixtureCreation(html `
16
+ <sp-swatch></sp-swatch>
17
+ `);
18
+ //# sourceMappingURL=basic-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic-test.js","sourceRoot":"","sources":["basic-test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,8CAA8C,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,sBAAsB,CAAC,IAAI,CAAA;;CAE1B,CAAC,CAAC","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 '@spectrum-web-components/swatch/sp-swatch.js';\nimport { html } from '@spectrum-web-components/base';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-swatch></sp-swatch>\n`);\n"]}
@@ -0,0 +1,15 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import * as stories from '../stories/swatch-group.stories.js';
13
+ import { regressVisuals } from '../../../test/visual/test.js';
14
+ regressVisuals('SwatchGroupStories', stories);
15
+ //# sourceMappingURL=swatch-group.test-vrt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swatch-group.test-vrt.js","sourceRoot":"","sources":["swatch-group.test-vrt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,KAAK,OAAO,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,cAAc,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC","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 * as stories from '../stories/swatch-group.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('SwatchGroupStories', stories);\n"]}
@@ -0,0 +1,262 @@
1
+ /*
2
+ Copyright 2022 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { elementUpdated, expect, fixture, nextFrame } from '@open-wc/testing';
13
+ import { sendKeys } from '@web/test-runner-commands';
14
+ import '../sp-swatch.js';
15
+ import { Default } from '../stories/swatch-group.stories.js';
16
+ import { spy } from 'sinon';
17
+ import { html } from '@spectrum-web-components/base';
18
+ describe('Swatch Group', () => {
19
+ let el;
20
+ beforeEach(async () => {
21
+ el = await fixture(Default(Default.args));
22
+ await elementUpdated(el);
23
+ });
24
+ it('loads default swatch accessibly', async () => {
25
+ await expect(el).to.be.accessible();
26
+ });
27
+ it('forwards `border` to children', async () => {
28
+ el.border = 'light';
29
+ await elementUpdated(el);
30
+ [...el.children].forEach((child) => {
31
+ expect(child.border).to.equal('light');
32
+ });
33
+ });
34
+ it('forwards `rounding` to children', async () => {
35
+ el.rounding = 'full';
36
+ await elementUpdated(el);
37
+ [...el.children].forEach((child) => {
38
+ expect(child.rounding).to.equal('full');
39
+ });
40
+ });
41
+ it('forwards `size` to children', async () => {
42
+ el.size = 'xs';
43
+ await elementUpdated(el);
44
+ [...el.children].forEach((child) => {
45
+ expect(child.size).to.equal('xs');
46
+ });
47
+ });
48
+ it('forwards `shape` to children', async () => {
49
+ el.shape = 'rectangle';
50
+ await elementUpdated(el);
51
+ [...el.children].forEach((child) => {
52
+ expect(child.shape).to.equal('rectangle');
53
+ });
54
+ });
55
+ it('unsets forwarding', async () => {
56
+ el.border = 'light';
57
+ el.rounding = 'full';
58
+ el.size = 'xs';
59
+ el.shape = 'rectangle';
60
+ await elementUpdated(el);
61
+ [...el.children].forEach((child) => {
62
+ expect(child.border).to.not.be.undefined;
63
+ expect(child.rounding).to.not.be.undefined;
64
+ expect(child.size).to.not.equal('m');
65
+ expect(child.shape).to.not.be.undefined;
66
+ });
67
+ el.border = undefined;
68
+ el.rounding = undefined;
69
+ el.removeAttribute('size');
70
+ el.shape = undefined;
71
+ await elementUpdated(el);
72
+ [...el.children].forEach((child) => {
73
+ expect(child.border).to.equal(undefined);
74
+ expect(child.rounding).to.equal(undefined);
75
+ expect(child.size).to.equal('m');
76
+ expect(child.shape).to.equal(undefined);
77
+ });
78
+ });
79
+ it('does not dispatch `change` events without `selects` attribute', async () => {
80
+ const selectedChild = el.querySelector(':scope > sp-swatch:nth-child(4)');
81
+ const changeSpy = spy();
82
+ el.addEventListener('change', () => changeSpy());
83
+ expect(el.selected).to.deep.equal([]);
84
+ selectedChild.click();
85
+ expect(changeSpy.called).to.be.false;
86
+ expect(el.selected).to.deep.equal([]);
87
+ });
88
+ it('dispatches `change` events as [selects="single"]', async () => {
89
+ el.selects = 'single';
90
+ const selectedChild = el.querySelector(':scope > sp-swatch:nth-child(4)');
91
+ const changeSpy = spy();
92
+ el.addEventListener('change', () => changeSpy());
93
+ expect(el.selected).to.deep.equal([]);
94
+ expect(selectedChild.selected).to.be.false;
95
+ selectedChild.click();
96
+ expect(changeSpy.calledOnce).to.be.true;
97
+ expect(el.selected).to.deep.equal([selectedChild.value]);
98
+ expect(selectedChild.selected).to.be.true;
99
+ });
100
+ it('can have `change` events prevented', async () => {
101
+ el.selects = 'single';
102
+ const selectedChild = el.querySelector(':scope > sp-swatch:nth-child(4)');
103
+ el.addEventListener('change', (event) => event.preventDefault());
104
+ expect(el.selected).to.deep.equal([]);
105
+ expect(selectedChild.selected).to.be.false;
106
+ selectedChild.click();
107
+ expect(el.selected).to.deep.equal([]);
108
+ expect(selectedChild.selected).to.be.false;
109
+ });
110
+ it('dispatches `change` events as [selects="multiple"]', async () => {
111
+ el.selects = 'multiple';
112
+ const selectedChild0 = el.querySelector(':scope > sp-swatch:nth-child(1)');
113
+ const selectedChild1 = el.querySelector(':scope > sp-swatch:nth-child(4)');
114
+ const selectedChild2 = el.querySelector(':scope > sp-swatch:nth-child(6)');
115
+ await elementUpdated(selectedChild0);
116
+ const changeSpy = spy();
117
+ el.addEventListener('change', () => changeSpy());
118
+ expect(el.selected).to.deep.equal([]);
119
+ selectedChild0.click();
120
+ selectedChild1.click();
121
+ selectedChild2.click();
122
+ expect(changeSpy.callCount).to.equal(3);
123
+ expect(el.selected).to.deep.equal([
124
+ selectedChild0.value,
125
+ selectedChild1.value,
126
+ selectedChild2.value,
127
+ ]);
128
+ });
129
+ it('filters `selected` when a selected Swatch is removed from the DOM', async () => {
130
+ el.selects = 'multiple';
131
+ const selectedChild0 = el.querySelector(':scope > sp-swatch:nth-child(1)');
132
+ const selectedChild1 = el.querySelector(':scope > sp-swatch:nth-child(4)');
133
+ const selectedChild2 = el.querySelector(':scope > sp-swatch:nth-child(6)');
134
+ await elementUpdated(selectedChild0);
135
+ expect(el.selected).to.deep.equal([]);
136
+ selectedChild0.click();
137
+ selectedChild1.click();
138
+ selectedChild2.click();
139
+ expect(el.selected).to.deep.equal([
140
+ selectedChild0.value,
141
+ selectedChild1.value,
142
+ selectedChild2.value,
143
+ ]);
144
+ selectedChild0.remove();
145
+ await elementUpdated(el);
146
+ expect(el.selected).to.deep.equal([
147
+ selectedChild1.value,
148
+ selectedChild2.value,
149
+ ]);
150
+ selectedChild2.remove();
151
+ await elementUpdated(el);
152
+ expect(el.selected).to.deep.equal([selectedChild1.value]);
153
+ selectedChild1.remove();
154
+ await elementUpdated(el);
155
+ expect(el.selected).to.deep.equal([]);
156
+ });
157
+ it('maintains a single tab stop', async () => {
158
+ const inputBefore = document.createElement('input');
159
+ const inputAfter = document.createElement('input');
160
+ el.insertAdjacentElement('beforebegin', inputBefore);
161
+ el.insertAdjacentElement('afterend', inputAfter);
162
+ inputBefore.focus();
163
+ expect(document.activeElement === el.children[0]).to.be.false;
164
+ await sendKeys({
165
+ press: 'Tab',
166
+ });
167
+ expect(document.activeElement === el.children[0]).to.be.true;
168
+ await sendKeys({
169
+ press: 'Tab',
170
+ });
171
+ expect(document.activeElement === el.children[0]).to.be.false;
172
+ await sendKeys({
173
+ press: 'Shift+Tab',
174
+ });
175
+ expect(document.activeElement === el.children[0]).to.be.true;
176
+ });
177
+ it('makes the first selected child the single tab stop', async () => {
178
+ const selectedChild = el.querySelector(':scope > sp-swatch:nth-child(4)');
179
+ expect(selectedChild.selected).to.be.false;
180
+ const inputBefore = document.createElement('input');
181
+ const inputAfter = document.createElement('input');
182
+ el.insertAdjacentElement('beforebegin', inputBefore);
183
+ el.insertAdjacentElement('afterend', inputAfter);
184
+ inputBefore.focus();
185
+ el.selects = 'single';
186
+ el.selected = [selectedChild.value];
187
+ await elementUpdated(el);
188
+ await nextFrame();
189
+ expect(selectedChild.selected).to.be.true;
190
+ expect(document.activeElement === selectedChild).to.be.false;
191
+ await sendKeys({
192
+ press: 'Tab',
193
+ });
194
+ expect(document.activeElement === selectedChild).to.be.true;
195
+ await sendKeys({
196
+ press: 'Tab',
197
+ });
198
+ expect(document.activeElement === selectedChild).to.be.false;
199
+ await sendKeys({
200
+ press: 'Shift+Tab',
201
+ });
202
+ expect(document.activeElement === selectedChild).to.be.true;
203
+ });
204
+ it('focus()es to the first Swatch', async () => {
205
+ el.focus();
206
+ expect(document.activeElement === el.children[0]).to.be.true;
207
+ });
208
+ it('focus()es to the first selected Swatch', async () => {
209
+ const selectedChild = el.querySelector(':scope > sp-swatch:nth-child(4)');
210
+ expect(selectedChild.selected).to.be.false;
211
+ el.selects = 'single';
212
+ el.selected = [selectedChild.value];
213
+ await elementUpdated(el);
214
+ await nextFrame();
215
+ expect(selectedChild.selected).to.be.true;
216
+ el.focus();
217
+ expect(document.activeElement === selectedChild).to.be.true;
218
+ });
219
+ });
220
+ describe('Swatch Group - DOM selected', () => {
221
+ it('accepts selection from DOM', async () => {
222
+ const el = await fixture(html `
223
+ <sp-swatch-group selects="multiple">
224
+ <sp-swatch value="color-0" color="red"></sp-swatch>
225
+ <sp-swatch value="color-1" color="green" selected></sp-swatch>
226
+ <sp-swatch value="color-2" color="blue"></sp-swatch>
227
+ <sp-swatch value="color-3" color="yellow" selected></sp-swatch>
228
+ </sp-swatch-group>
229
+ `);
230
+ await elementUpdated(el);
231
+ expect(el.selected).to.deep.equal(['color-1', 'color-3']);
232
+ });
233
+ it('merges `selected` and selection from DOM', async () => {
234
+ const el = await fixture(html `
235
+ <sp-swatch-group selects="multiple" .selected=${['color-1']}>
236
+ <sp-swatch value="color-0" color="red"></sp-swatch>
237
+ <sp-swatch value="color-1" color="green"></sp-swatch>
238
+ <sp-swatch value="color-2" color="blue"></sp-swatch>
239
+ <sp-swatch value="color-3" color="yellow" selected></sp-swatch>
240
+ </sp-swatch-group>
241
+ `);
242
+ await elementUpdated(el);
243
+ expect(el.selected).to.deep.equal(['color-1', 'color-3']);
244
+ });
245
+ it('lazily accepts selection from DOM', async () => {
246
+ const el = await fixture(html `
247
+ <sp-swatch-group selects="multiple">
248
+ <sp-swatch value="color-0" color="red"></sp-swatch>
249
+ <sp-swatch value="color-1" color="green"></sp-swatch>
250
+ <sp-swatch value="color-2" color="blue"></sp-swatch>
251
+ <sp-swatch value="color-3" color="yellow" selected></sp-swatch>
252
+ </sp-swatch-group>
253
+ `);
254
+ await elementUpdated(el);
255
+ const color1 = el.querySelector('[value="color-1"]');
256
+ expect(el.selected).to.deep.equal(['color-3']);
257
+ color1.selected = true;
258
+ await elementUpdated(el);
259
+ expect(el.selected).to.deep.equal(['color-3', 'color-1']);
260
+ });
261
+ });
262
+ //# sourceMappingURL=swatch-group.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swatch-group.test.js","sourceRoot":"","sources":["swatch-group.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,iBAAiB,CAAC;AAEzB,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,IAAI,EAAe,CAAC;IACpB,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,EAAE,GAAG,MAAM,OAAO,CAAc,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAEvD,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,CAA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AAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA;4DACU,CAAC,SAAS,CAAC;;;;;;SAM9D,CAAC,CAAC;QAEH,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,EAAE,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA;;;;;;;SAOzC,CAAC,CAAC;QAEH,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QACzB,MAAM,MAAM,GAAG,EAAE,CAAC,aAAa,CAAC,mBAAmB,CAAW,CAAC;QAE/D,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;QAE/C,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","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 { elementUpdated, expect, fixture, nextFrame } from '@open-wc/testing';\nimport { sendKeys } from '@web/test-runner-commands';\n\nimport '../sp-swatch.js';\nimport { Swatch, SwatchGroup } from '../';\nimport { Default } from '../stories/swatch-group.stories.js';\nimport { spy } from 'sinon';\nimport { html } from '@spectrum-web-components/base';\n\ndescribe('Swatch Group', () => {\n let el: SwatchGroup;\n beforeEach(async () => {\n el = await fixture<SwatchGroup>(Default(Default.args));\n\n await elementUpdated(el);\n });\n it('loads default swatch accessibly', async () => {\n await expect(el).to.be.accessible();\n });\n it('forwards `border` to children', async () => {\n el.border = 'light';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.border).to.equal('light');\n });\n });\n it('forwards `rounding` to children', async () => {\n el.rounding = 'full';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.rounding).to.equal('full');\n });\n });\n it('forwards `size` to children', async () => {\n el.size = 'xs';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.size).to.equal('xs');\n });\n });\n it('forwards `shape` to children', async () => {\n el.shape = 'rectangle';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.shape).to.equal('rectangle');\n });\n });\n it('unsets forwarding', async () => {\n el.border = 'light';\n el.rounding = 'full';\n el.size = 'xs';\n el.shape = 'rectangle';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.border).to.not.be.undefined;\n expect(child.rounding).to.not.be.undefined;\n expect(child.size).to.not.equal('m');\n expect(child.shape).to.not.be.undefined;\n });\n\n el.border = undefined;\n el.rounding = undefined;\n el.removeAttribute('size');\n el.shape = undefined;\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.border).to.equal(undefined);\n expect(child.rounding).to.equal(undefined);\n expect(child.size).to.equal('m');\n expect(child.shape).to.equal(undefined);\n });\n });\n it('does not dispatch `change` events without `selects` attribute', async () => {\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n\n const changeSpy = spy();\n\n el.addEventListener('change', () => changeSpy());\n\n expect(el.selected).to.deep.equal([]);\n\n selectedChild.click();\n\n expect(changeSpy.called).to.be.false;\n expect(el.selected).to.deep.equal([]);\n });\n it('dispatches `change` events as [selects=\"single\"]', async () => {\n el.selects = 'single';\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n\n const changeSpy = spy();\n\n el.addEventListener('change', () => changeSpy());\n\n expect(el.selected).to.deep.equal([]);\n expect(selectedChild.selected).to.be.false;\n\n selectedChild.click();\n\n expect(changeSpy.calledOnce).to.be.true;\n expect(el.selected).to.deep.equal([selectedChild.value]);\n expect(selectedChild.selected).to.be.true;\n });\n it('can have `change` events prevented', async () => {\n el.selects = 'single';\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n\n el.addEventListener('change', (event: Event) => event.preventDefault());\n\n expect(el.selected).to.deep.equal([]);\n expect(selectedChild.selected).to.be.false;\n\n selectedChild.click();\n\n expect(el.selected).to.deep.equal([]);\n expect(selectedChild.selected).to.be.false;\n });\n it('dispatches `change` events as [selects=\"multiple\"]', async () => {\n el.selects = 'multiple';\n const selectedChild0 = el.querySelector(\n ':scope > sp-swatch:nth-child(1)'\n ) as Swatch;\n const selectedChild1 = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n const selectedChild2 = el.querySelector(\n ':scope > sp-swatch:nth-child(6)'\n ) as Swatch;\n\n await elementUpdated(selectedChild0);\n\n const changeSpy = spy();\n\n el.addEventListener('change', () => changeSpy());\n\n expect(el.selected).to.deep.equal([]);\n\n selectedChild0.click();\n selectedChild1.click();\n selectedChild2.click();\n\n expect(changeSpy.callCount).to.equal(3);\n expect(el.selected).to.deep.equal([\n selectedChild0.value,\n selectedChild1.value,\n selectedChild2.value,\n ]);\n });\n it('filters `selected` when a selected Swatch is removed from the DOM', async () => {\n el.selects = 'multiple';\n const selectedChild0 = el.querySelector(\n ':scope > sp-swatch:nth-child(1)'\n ) as Swatch;\n const selectedChild1 = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n const selectedChild2 = el.querySelector(\n ':scope > sp-swatch:nth-child(6)'\n ) as Swatch;\n\n await elementUpdated(selectedChild0);\n\n expect(el.selected).to.deep.equal([]);\n\n selectedChild0.click();\n selectedChild1.click();\n selectedChild2.click();\n\n expect(el.selected).to.deep.equal([\n selectedChild0.value,\n selectedChild1.value,\n selectedChild2.value,\n ]);\n\n selectedChild0.remove();\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([\n selectedChild1.value,\n selectedChild2.value,\n ]);\n\n selectedChild2.remove();\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([selectedChild1.value]);\n\n selectedChild1.remove();\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([]);\n });\n it('maintains a single tab stop', async () => {\n const inputBefore = document.createElement('input');\n const inputAfter = document.createElement('input');\n el.insertAdjacentElement('beforebegin', inputBefore);\n el.insertAdjacentElement('afterend', inputAfter);\n inputBefore.focus();\n expect(document.activeElement === el.children[0]).to.be.false;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === el.children[0]).to.be.true;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === el.children[0]).to.be.false;\n await sendKeys({\n press: 'Shift+Tab',\n });\n expect(document.activeElement === el.children[0]).to.be.true;\n });\n it('makes the first selected child the single tab stop', async () => {\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n expect(selectedChild.selected).to.be.false;\n\n const inputBefore = document.createElement('input');\n const inputAfter = document.createElement('input');\n el.insertAdjacentElement('beforebegin', inputBefore);\n el.insertAdjacentElement('afterend', inputAfter);\n inputBefore.focus();\n el.selects = 'single';\n el.selected = [selectedChild.value];\n await elementUpdated(el);\n await nextFrame();\n\n expect(selectedChild.selected).to.be.true;\n\n expect(document.activeElement === selectedChild).to.be.false;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === selectedChild).to.be.true;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === selectedChild).to.be.false;\n await sendKeys({\n press: 'Shift+Tab',\n });\n expect(document.activeElement === selectedChild).to.be.true;\n });\n it('focus()es to the first Swatch', async () => {\n el.focus();\n expect(document.activeElement === el.children[0]).to.be.true;\n });\n it('focus()es to the first selected Swatch', async () => {\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n expect(selectedChild.selected).to.be.false;\n el.selects = 'single';\n el.selected = [selectedChild.value];\n await elementUpdated(el);\n await nextFrame();\n\n expect(selectedChild.selected).to.be.true;\n el.focus();\n expect(document.activeElement === selectedChild).to.be.true;\n });\n});\n\ndescribe('Swatch Group - DOM selected', () => {\n it('accepts selection from DOM', async () => {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"multiple\">\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\" selected></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n <sp-swatch value=\"color-3\" color=\"yellow\" selected></sp-swatch>\n </sp-swatch-group>\n `);\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal(['color-1', 'color-3']);\n });\n it('merges `selected` and selection from DOM', async () => {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"multiple\" .selected=${['color-1']}>\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\"></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n <sp-swatch value=\"color-3\" color=\"yellow\" selected></sp-swatch>\n </sp-swatch-group>\n `);\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal(['color-1', 'color-3']);\n });\n it('lazily accepts selection from DOM', async () => {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"multiple\">\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\"></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n <sp-swatch value=\"color-3\" color=\"yellow\" selected></sp-swatch>\n </sp-swatch-group>\n `);\n\n await elementUpdated(el);\n const color1 = el.querySelector('[value=\"color-1\"]') as Swatch;\n\n expect(el.selected).to.deep.equal(['color-3']);\n\n color1.selected = true;\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal(['color-3', 'color-1']);\n });\n});\n"]}
@@ -0,0 +1,15 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import * as stories from '../stories/swatch-sizes.stories.js';
13
+ import { regressVisuals } from '../../../test/visual/test.js';
14
+ regressVisuals('SwatchSizesStories', stories);
15
+ //# sourceMappingURL=swatch-sizes.test-vrt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swatch-sizes.test-vrt.js","sourceRoot":"","sources":["swatch-sizes.test-vrt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,KAAK,OAAO,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,cAAc,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC","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 * as stories from '../stories/swatch-sizes.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('SwatchSizesStories', stories);\n"]}
@@ -0,0 +1,15 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import * as stories from '../stories/swatch.stories.js';
13
+ import { regressVisuals } from '../../../test/visual/test.js';
14
+ regressVisuals('SwatchStories', stories);
15
+ //# sourceMappingURL=swatch.test-vrt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swatch.test-vrt.js","sourceRoot":"","sources":["swatch.test-vrt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,cAAc,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC","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 * as stories from '../stories/swatch.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('SwatchStories', stories);\n"]}