@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,600 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "sp-swatch-group.ts",
8
+ "declarations": [],
9
+ "exports": [
10
+ {
11
+ "kind": "custom-element-definition",
12
+ "name": "sp-swatch-group",
13
+ "declaration": {
14
+ "name": "SwatchGroup",
15
+ "module": "/src/SwatchGroup.js"
16
+ }
17
+ }
18
+ ]
19
+ },
20
+ {
21
+ "kind": "javascript-module",
22
+ "path": "sp-swatch.ts",
23
+ "declarations": [],
24
+ "exports": [
25
+ {
26
+ "kind": "custom-element-definition",
27
+ "name": "sp-swatch",
28
+ "declaration": {
29
+ "name": "Swatch",
30
+ "module": "/src/Swatch.js"
31
+ }
32
+ }
33
+ ]
34
+ },
35
+ {
36
+ "kind": "javascript-module",
37
+ "path": "src/Swatch.ts",
38
+ "declarations": [
39
+ {
40
+ "kind": "class",
41
+ "description": "",
42
+ "name": "Swatch",
43
+ "members": [
44
+ {
45
+ "kind": "field",
46
+ "name": "border",
47
+ "type": {
48
+ "text": "SwatchBorder"
49
+ },
50
+ "privacy": "public",
51
+ "attribute": "border",
52
+ "reflects": true
53
+ },
54
+ {
55
+ "kind": "field",
56
+ "name": "color",
57
+ "type": {
58
+ "text": "string"
59
+ },
60
+ "privacy": "public",
61
+ "default": "''",
62
+ "attribute": "color"
63
+ },
64
+ {
65
+ "kind": "field",
66
+ "name": "label",
67
+ "type": {
68
+ "text": "string"
69
+ },
70
+ "privacy": "public",
71
+ "default": "''",
72
+ "attribute": "label"
73
+ },
74
+ {
75
+ "kind": "field",
76
+ "name": "mixedValue",
77
+ "type": {
78
+ "text": "boolean"
79
+ },
80
+ "privacy": "public",
81
+ "default": "false",
82
+ "attribute": "mixed-value",
83
+ "reflects": true
84
+ },
85
+ {
86
+ "kind": "field",
87
+ "name": "nothing",
88
+ "type": {
89
+ "text": "boolean"
90
+ },
91
+ "privacy": "public",
92
+ "default": "false",
93
+ "attribute": "nothing",
94
+ "reflects": true
95
+ },
96
+ {
97
+ "kind": "field",
98
+ "name": "role",
99
+ "type": {
100
+ "text": "string"
101
+ },
102
+ "privacy": "public",
103
+ "default": "'button'",
104
+ "attribute": "role",
105
+ "reflects": true
106
+ },
107
+ {
108
+ "kind": "field",
109
+ "name": "rounding",
110
+ "type": {
111
+ "text": "SwatchRounding"
112
+ },
113
+ "privacy": "public",
114
+ "attribute": "rounding",
115
+ "reflects": true
116
+ },
117
+ {
118
+ "kind": "field",
119
+ "name": "selected",
120
+ "type": {
121
+ "text": "boolean"
122
+ },
123
+ "privacy": "public",
124
+ "default": "false",
125
+ "attribute": "selected",
126
+ "reflects": true
127
+ },
128
+ {
129
+ "kind": "field",
130
+ "name": "shape",
131
+ "type": {
132
+ "text": "SwatchShape"
133
+ },
134
+ "privacy": "public",
135
+ "attribute": "shape",
136
+ "reflects": true
137
+ },
138
+ {
139
+ "kind": "field",
140
+ "name": "value",
141
+ "type": {
142
+ "text": "string"
143
+ },
144
+ "attribute": "value"
145
+ },
146
+ {
147
+ "kind": "field",
148
+ "name": "_value",
149
+ "type": {
150
+ "text": "string | undefined"
151
+ },
152
+ "privacy": "private"
153
+ },
154
+ {
155
+ "kind": "field",
156
+ "name": "focusElement",
157
+ "type": {
158
+ "text": "HTMLElement"
159
+ },
160
+ "privacy": "public"
161
+ },
162
+ {
163
+ "kind": "method",
164
+ "name": "toggle",
165
+ "privacy": "public",
166
+ "return": {
167
+ "type": {
168
+ "text": "void"
169
+ }
170
+ },
171
+ "parameters": [
172
+ {
173
+ "name": "force",
174
+ "optional": true,
175
+ "type": {
176
+ "text": "boolean"
177
+ }
178
+ }
179
+ ]
180
+ },
181
+ {
182
+ "kind": "method",
183
+ "name": "handleClick",
184
+ "privacy": "private",
185
+ "return": {
186
+ "type": {
187
+ "text": "void"
188
+ }
189
+ }
190
+ },
191
+ {
192
+ "kind": "method",
193
+ "name": "handleKeydown",
194
+ "privacy": "protected",
195
+ "return": {
196
+ "type": {
197
+ "text": "void"
198
+ }
199
+ },
200
+ "parameters": [
201
+ {
202
+ "name": "event",
203
+ "type": {
204
+ "text": "KeyboardEvent"
205
+ }
206
+ }
207
+ ]
208
+ },
209
+ {
210
+ "kind": "method",
211
+ "name": "handleKeypress",
212
+ "privacy": "private",
213
+ "return": {
214
+ "type": {
215
+ "text": "void"
216
+ }
217
+ },
218
+ "parameters": [
219
+ {
220
+ "name": "event",
221
+ "type": {
222
+ "text": "KeyboardEvent"
223
+ }
224
+ }
225
+ ]
226
+ },
227
+ {
228
+ "kind": "method",
229
+ "name": "handleKeyup",
230
+ "privacy": "protected",
231
+ "return": {
232
+ "type": {
233
+ "text": "void"
234
+ }
235
+ },
236
+ "parameters": [
237
+ {
238
+ "name": "event",
239
+ "type": {
240
+ "text": "KeyboardEvent"
241
+ }
242
+ }
243
+ ]
244
+ },
245
+ {
246
+ "kind": "field",
247
+ "name": "renderDisabled",
248
+ "privacy": "protected"
249
+ },
250
+ {
251
+ "kind": "field",
252
+ "name": "renderMixedValue",
253
+ "privacy": "protected"
254
+ }
255
+ ],
256
+ "events": [
257
+ {
258
+ "name": "change",
259
+ "type": {
260
+ "text": "Event"
261
+ }
262
+ }
263
+ ],
264
+ "attributes": [
265
+ {
266
+ "name": "border",
267
+ "type": {
268
+ "text": "SwatchBorder"
269
+ },
270
+ "fieldName": "border"
271
+ },
272
+ {
273
+ "name": "color",
274
+ "type": {
275
+ "text": "string"
276
+ },
277
+ "default": "''",
278
+ "fieldName": "color"
279
+ },
280
+ {
281
+ "name": "label",
282
+ "type": {
283
+ "text": "string"
284
+ },
285
+ "default": "''",
286
+ "fieldName": "label"
287
+ },
288
+ {
289
+ "name": "mixed-value",
290
+ "type": {
291
+ "text": "boolean"
292
+ },
293
+ "default": "false",
294
+ "fieldName": "mixedValue"
295
+ },
296
+ {
297
+ "name": "nothing",
298
+ "type": {
299
+ "text": "boolean"
300
+ },
301
+ "default": "false",
302
+ "fieldName": "nothing"
303
+ },
304
+ {
305
+ "name": "role",
306
+ "type": {
307
+ "text": "string"
308
+ },
309
+ "default": "'button'",
310
+ "fieldName": "role"
311
+ },
312
+ {
313
+ "name": "rounding",
314
+ "type": {
315
+ "text": "SwatchRounding"
316
+ },
317
+ "fieldName": "rounding"
318
+ },
319
+ {
320
+ "name": "selected",
321
+ "type": {
322
+ "text": "boolean"
323
+ },
324
+ "default": "false",
325
+ "fieldName": "selected"
326
+ },
327
+ {
328
+ "name": "shape",
329
+ "type": {
330
+ "text": "SwatchShape"
331
+ },
332
+ "fieldName": "shape"
333
+ },
334
+ {
335
+ "name": "value",
336
+ "type": {
337
+ "text": "string"
338
+ },
339
+ "fieldName": "value"
340
+ }
341
+ ],
342
+ "mixins": [
343
+ {
344
+ "name": "SizedMixin",
345
+ "package": "@spectrum-web-components/base"
346
+ }
347
+ ],
348
+ "superclass": {
349
+ "name": "Focusable",
350
+ "package": "@spectrum-web-components/shared/src/focusable.js"
351
+ },
352
+ "tagName": "sp-swatch",
353
+ "customElement": true
354
+ }
355
+ ],
356
+ "exports": [
357
+ {
358
+ "kind": "js",
359
+ "name": "Swatch",
360
+ "declaration": {
361
+ "name": "Swatch",
362
+ "module": "src/Swatch.ts"
363
+ }
364
+ }
365
+ ]
366
+ },
367
+ {
368
+ "kind": "javascript-module",
369
+ "path": "src/SwatchGroup.ts",
370
+ "declarations": [
371
+ {
372
+ "kind": "class",
373
+ "description": "",
374
+ "name": "SwatchGroup",
375
+ "slots": [
376
+ {
377
+ "description": "Swatch elements to manage as a group",
378
+ "name": ""
379
+ }
380
+ ],
381
+ "members": [
382
+ {
383
+ "kind": "field",
384
+ "name": "border",
385
+ "type": {
386
+ "text": "SwatchBorder"
387
+ },
388
+ "privacy": "public",
389
+ "attribute": "border",
390
+ "reflects": true
391
+ },
392
+ {
393
+ "kind": "field",
394
+ "name": "rounding",
395
+ "type": {
396
+ "text": "SwatchRounding"
397
+ },
398
+ "privacy": "public",
399
+ "attribute": "rounding",
400
+ "reflects": true
401
+ },
402
+ {
403
+ "kind": "field",
404
+ "name": "selected",
405
+ "type": {
406
+ "text": "string[]"
407
+ },
408
+ "privacy": "public",
409
+ "attribute": "selected"
410
+ },
411
+ {
412
+ "kind": "field",
413
+ "name": "_selected",
414
+ "type": {
415
+ "text": "string[]"
416
+ },
417
+ "privacy": "private",
418
+ "default": "[]"
419
+ },
420
+ {
421
+ "kind": "field",
422
+ "name": "selects",
423
+ "type": {
424
+ "text": "'single' | 'multiple' | undefined"
425
+ },
426
+ "privacy": "public",
427
+ "attribute": "selects"
428
+ },
429
+ {
430
+ "kind": "field",
431
+ "name": "selectedSet",
432
+ "privacy": "private",
433
+ "default": "new Set<string>()"
434
+ },
435
+ {
436
+ "kind": "field",
437
+ "name": "shape",
438
+ "type": {
439
+ "text": "SwatchShape"
440
+ },
441
+ "privacy": "public",
442
+ "attribute": "shape",
443
+ "reflects": true
444
+ },
445
+ {
446
+ "kind": "field",
447
+ "name": "rovingTabindexController",
448
+ "default": "new RovingTabindexController<Swatch>(this, {\n focusInIndex: (elements: Swatch[]) => {\n let firstEnabledIndex = -1;\n const firstSelectedIndex = elements.findIndex((el, index) => {\n if (!elements[firstEnabledIndex] && !el.disabled) {\n firstEnabledIndex = index;\n }\n return el.selected && !el.disabled;\n });\n return elements[firstSelectedIndex]\n ? firstSelectedIndex\n : firstEnabledIndex;\n },\n elements: () => [...this.children] as Swatch[],\n isFocusableElement: (el: Swatch) => !el.disabled,\n })"
449
+ },
450
+ {
451
+ "kind": "method",
452
+ "name": "focus",
453
+ "privacy": "public",
454
+ "return": {
455
+ "type": {
456
+ "text": "void"
457
+ }
458
+ },
459
+ "parameters": [
460
+ {
461
+ "name": "options",
462
+ "optional": true,
463
+ "type": {
464
+ "text": "FocusOptions"
465
+ }
466
+ }
467
+ ]
468
+ },
469
+ {
470
+ "kind": "method",
471
+ "name": "handleChange",
472
+ "privacy": "protected",
473
+ "return": {
474
+ "type": {
475
+ "text": "void"
476
+ }
477
+ },
478
+ "parameters": [
479
+ {
480
+ "name": "event",
481
+ "type": {
482
+ "text": "Event & { target: Swatch }"
483
+ }
484
+ }
485
+ ]
486
+ },
487
+ {
488
+ "kind": "field",
489
+ "name": "manageChange",
490
+ "privacy": "private"
491
+ },
492
+ {
493
+ "kind": "method",
494
+ "name": "getPassthroughSwatchActions",
495
+ "privacy": "private",
496
+ "return": {
497
+ "type": {
498
+ "text": "((swatch: Swatch) => void)[]"
499
+ }
500
+ },
501
+ "parameters": [
502
+ {
503
+ "name": "changes",
504
+ "type": {
505
+ "text": "PropertyValues"
506
+ }
507
+ }
508
+ ]
509
+ },
510
+ {
511
+ "kind": "method",
512
+ "name": "getSelectionSwatchActions",
513
+ "privacy": "private",
514
+ "return": {
515
+ "type": {
516
+ "text": "((swatch: Swatch) => void)[]"
517
+ }
518
+ },
519
+ "parameters": [
520
+ {
521
+ "name": "changes",
522
+ "type": {
523
+ "text": "PropertyValues"
524
+ }
525
+ }
526
+ ]
527
+ }
528
+ ],
529
+ "events": [
530
+ {
531
+ "name": "change",
532
+ "type": {
533
+ "text": "Event"
534
+ }
535
+ }
536
+ ],
537
+ "attributes": [
538
+ {
539
+ "name": "border",
540
+ "type": {
541
+ "text": "SwatchBorder"
542
+ },
543
+ "fieldName": "border"
544
+ },
545
+ {
546
+ "name": "rounding",
547
+ "type": {
548
+ "text": "SwatchRounding"
549
+ },
550
+ "fieldName": "rounding"
551
+ },
552
+ {
553
+ "name": "selected",
554
+ "type": {
555
+ "text": "string[]"
556
+ },
557
+ "fieldName": "selected"
558
+ },
559
+ {
560
+ "name": "selects",
561
+ "type": {
562
+ "text": "'single' | 'multiple' | undefined"
563
+ },
564
+ "fieldName": "selects"
565
+ },
566
+ {
567
+ "name": "shape",
568
+ "type": {
569
+ "text": "SwatchShape"
570
+ },
571
+ "fieldName": "shape"
572
+ }
573
+ ],
574
+ "mixins": [
575
+ {
576
+ "name": "SizedMixin",
577
+ "package": "@spectrum-web-components/base"
578
+ }
579
+ ],
580
+ "superclass": {
581
+ "name": "SpectrumElement",
582
+ "package": "@spectrum-web-components/base"
583
+ },
584
+ "tagName": "sp-swatch-group",
585
+ "customElement": true
586
+ }
587
+ ],
588
+ "exports": [
589
+ {
590
+ "kind": "js",
591
+ "name": "SwatchGroup",
592
+ "declaration": {
593
+ "name": "SwatchGroup",
594
+ "module": "src/SwatchGroup.ts"
595
+ }
596
+ }
597
+ ]
598
+ }
599
+ ]
600
+ }
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@spectrum-web-components/swatch",
3
+ "version": "0.1.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Web component implementation of a Spectrum design Swatch",
8
+ "license": "Apache-2.0",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/adobe/spectrum-web-components.git",
12
+ "directory": "packages/swatch"
13
+ },
14
+ "author": "",
15
+ "homepage": "https://adobe.github.io/spectrum-web-components/components/swatch",
16
+ "bugs": {
17
+ "url": "https://github.com/adobe/spectrum-web-components/issues"
18
+ },
19
+ "main": "src/index.js",
20
+ "module": "src/index.js",
21
+ "type": "module",
22
+ "exports": {
23
+ ".": "./src/index.js",
24
+ "./src/*": "./src/*",
25
+ "./package.json": "./package.json",
26
+ "./sp-swatch": "./sp-swatch.js",
27
+ "./sp-swatch.js": "./sp-swatch.js",
28
+ "./sp-swatch-group": "./sp-swatch-group.js",
29
+ "./sp-swatch-group.js": "./sp-swatch-group.js"
30
+ },
31
+ "scripts": {
32
+ "test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
33
+ },
34
+ "files": [
35
+ "**/*.d.ts",
36
+ "**/*.js",
37
+ "**/*.js.map",
38
+ "custom-elements.json",
39
+ "!stories/",
40
+ "!test/"
41
+ ],
42
+ "keywords": [
43
+ "spectrum css",
44
+ "web components",
45
+ "lit-element",
46
+ "lit-html"
47
+ ],
48
+ "dependencies": {
49
+ "@spectrum-web-components/base": "^0.5.8",
50
+ "@spectrum-web-components/reactive-controllers": "^0.2.4",
51
+ "@spectrum-web-components/shared": "^0.14.3",
52
+ "tslib": "^2.0.0"
53
+ },
54
+ "devDependencies": {
55
+ "@spectrum-css/swatch": "^1.1.1",
56
+ "@spectrum-css/swatchgroup": "^1.1.1"
57
+ },
58
+ "types": "./src/index.d.ts",
59
+ "customElements": "custom-elements.json",
60
+ "sideEffects": [
61
+ "./sp-*.js"
62
+ ],
63
+ "gitHead": "e5cd4a0db2201b8126eb9133ac3c24172d086359"
64
+ }
@@ -0,0 +1,6 @@
1
+ import { SwatchGroup } from './src/SwatchGroup.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'sp-swatch-group': SwatchGroup;
5
+ }
6
+ }
@@ -0,0 +1,14 @@
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 { SwatchGroup } from './src/SwatchGroup.js';
13
+ customElements.define('sp-swatch-group', SwatchGroup);
14
+ //# sourceMappingURL=sp-swatch-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sp-swatch-group.js","sourceRoot":"","sources":["sp-swatch-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,WAAW,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 { SwatchGroup } from './src/SwatchGroup.js';\n\ncustomElements.define('sp-swatch-group', SwatchGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-swatch-group': SwatchGroup;\n }\n}\n"]}
package/sp-swatch.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Swatch } from './src/Swatch.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'sp-swatch': Swatch;
5
+ }
6
+ }