@m3e/chips 1.0.0-rc.2 → 1.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,7 +27,7 @@ Alternately, you can explicitly reference the `html-custom-data.json` and `css-c
27
27
  }
28
28
  ```
29
29
 
30
- ## 🚀 Browser Usage
30
+ ## 🚀 Native Module Support
31
31
 
32
32
  This package uses [JavaScript Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#module_specifiers). To use it directly in a browser without a bundler, use a module script similar to the following.
33
33
 
@@ -404,6 +404,21 @@
404
404
  "tagName": "m3e-assist-chip",
405
405
  "customElement": true,
406
406
  "members": [
407
+ {
408
+ "kind": "field",
409
+ "name": "formAssociated",
410
+ "static": true,
411
+ "readonly": true,
412
+ "default": "true",
413
+ "description": "Indicates that this custom element participates in form submission, validation, and form state restoration.",
414
+ "type": {
415
+ "text": "boolean"
416
+ },
417
+ "inheritedFrom": {
418
+ "name": "AttachInternals",
419
+ "module": "../core/src/shared/mixins/AttachInternals.ts"
420
+ }
421
+ },
407
422
  {
408
423
  "kind": "field",
409
424
  "name": "name",
@@ -447,18 +462,6 @@
447
462
  "module": "../core/src/shared/mixins/LinkButton.ts"
448
463
  }
449
464
  },
450
- {
451
- "kind": "field",
452
- "name": "formAssociated",
453
- "static": true,
454
- "readonly": true,
455
- "default": "formAssociated",
456
- "description": "Indicates that this custom element participates in form submission, validation, and form state restoration.",
457
- "inheritedFrom": {
458
- "name": "AttachInternals",
459
- "module": "../core/src/shared/mixins/AttachInternals.ts"
460
- }
461
- },
462
465
  {
463
466
  "kind": "field",
464
467
  "name": "[_internals]",
@@ -2097,6 +2100,57 @@
2097
2100
  "description": "The selected value(s) of the set.",
2098
2101
  "readonly": true
2099
2102
  },
2103
+ {
2104
+ "kind": "method",
2105
+ "name": "#handleSlotChange",
2106
+ "privacy": "private"
2107
+ },
2108
+ {
2109
+ "kind": "method",
2110
+ "name": "#handleKeyDown",
2111
+ "privacy": "private",
2112
+ "return": {
2113
+ "type": {
2114
+ "text": "void"
2115
+ }
2116
+ },
2117
+ "parameters": [
2118
+ {
2119
+ "name": "e",
2120
+ "type": {
2121
+ "text": "KeyboardEvent"
2122
+ }
2123
+ }
2124
+ ]
2125
+ },
2126
+ {
2127
+ "kind": "method",
2128
+ "name": "#handleChange",
2129
+ "privacy": "private",
2130
+ "return": {
2131
+ "type": {
2132
+ "text": "void"
2133
+ }
2134
+ },
2135
+ "parameters": [
2136
+ {
2137
+ "name": "e",
2138
+ "type": {
2139
+ "text": "Event"
2140
+ }
2141
+ }
2142
+ ]
2143
+ },
2144
+ {
2145
+ "kind": "method",
2146
+ "name": "#updateChipRole",
2147
+ "privacy": "private",
2148
+ "return": {
2149
+ "type": {
2150
+ "text": "void"
2151
+ }
2152
+ }
2153
+ },
2100
2154
  {
2101
2155
  "kind": "field",
2102
2156
  "name": "formAssociated",
@@ -2135,20 +2189,6 @@
2135
2189
  "module": "../core/src/shared/mixins/FormAssociated.ts"
2136
2190
  }
2137
2191
  },
2138
- {
2139
- "kind": "method",
2140
- "name": "[_updateLabels]",
2141
- "privacy": "private",
2142
- "return": {
2143
- "type": {
2144
- "text": "void"
2145
- }
2146
- },
2147
- "inheritedFrom": {
2148
- "name": "Labelled",
2149
- "module": "../core/src/shared/mixins/Labelled.ts"
2150
- }
2151
- },
2152
2192
  {
2153
2193
  "kind": "field",
2154
2194
  "name": "dirty",
@@ -2937,27 +2977,6 @@
2937
2977
  }
2938
2978
  ]
2939
2979
  },
2940
- {
2941
- "kind": "method",
2942
- "name": "dispatchEvent",
2943
- "return": {
2944
- "type": {
2945
- "text": "boolean"
2946
- }
2947
- },
2948
- "parameters": [
2949
- {
2950
- "name": "event",
2951
- "type": {
2952
- "text": "Event"
2953
- }
2954
- }
2955
- ],
2956
- "inheritedFrom": {
2957
- "name": "EventAttribute",
2958
- "module": "../core/src/shared/mixins/EventAttribute.ts"
2959
- }
2960
- },
2961
2980
  {
2962
2981
  "kind": "field",
2963
2982
  "name": "[_suppressedEventHandler]",
@@ -3464,7 +3483,7 @@
3464
3483
  "type": {
3465
3484
  "text": "readonly string[] | null"
3466
3485
  },
3467
- "description": "The selected values of the set.",
3486
+ "description": "The values of the set.",
3468
3487
  "readonly": true
3469
3488
  },
3470
3489
  {
@@ -4588,6 +4607,21 @@
4588
4607
  "tagName": "m3e-suggestion-chip",
4589
4608
  "customElement": true,
4590
4609
  "members": [
4610
+ {
4611
+ "kind": "field",
4612
+ "name": "formAssociated",
4613
+ "static": true,
4614
+ "readonly": true,
4615
+ "default": "true",
4616
+ "description": "Indicates that this custom element participates in form submission, validation, and form state restoration.",
4617
+ "type": {
4618
+ "text": "boolean"
4619
+ },
4620
+ "inheritedFrom": {
4621
+ "name": "AttachInternals",
4622
+ "module": "../core/src/shared/mixins/AttachInternals.ts"
4623
+ }
4624
+ },
4591
4625
  {
4592
4626
  "kind": "field",
4593
4627
  "name": "name",
@@ -4631,18 +4665,6 @@
4631
4665
  "module": "../core/src/shared/mixins/LinkButton.ts"
4632
4666
  }
4633
4667
  },
4634
- {
4635
- "kind": "field",
4636
- "name": "formAssociated",
4637
- "static": true,
4638
- "readonly": true,
4639
- "default": "formAssociated",
4640
- "description": "Indicates that this custom element participates in form submission, validation, and form state restoration.",
4641
- "inheritedFrom": {
4642
- "name": "AttachInternals",
4643
- "module": "../core/src/shared/mixins/AttachInternals.ts"
4644
- }
4645
- },
4646
4668
  {
4647
4669
  "kind": "field",
4648
4670
  "name": "[_internals]",
@@ -5909,25 +5931,6 @@
5909
5931
  "kind": "mixin",
5910
5932
  "description": "Mixin that adds support for custom event attributes.",
5911
5933
  "name": "EventAttribute",
5912
- "members": [
5913
- {
5914
- "kind": "method",
5915
- "name": "dispatchEvent",
5916
- "return": {
5917
- "type": {
5918
- "text": "boolean"
5919
- }
5920
- },
5921
- "parameters": [
5922
- {
5923
- "name": "event",
5924
- "type": {
5925
- "text": "Event"
5926
- }
5927
- }
5928
- ]
5929
- }
5930
- ],
5931
5934
  "parameters": [
5932
5935
  {
5933
5936
  "name": "base",
@@ -6225,6 +6228,17 @@
6225
6228
  "description": "Mixin to augment an element with behavior used to submit a form.",
6226
6229
  "name": "FormSubmitter",
6227
6230
  "members": [
6231
+ {
6232
+ "kind": "field",
6233
+ "name": "formAssociated",
6234
+ "type": {
6235
+ "text": "boolean"
6236
+ },
6237
+ "static": true,
6238
+ "readonly": true,
6239
+ "default": "true",
6240
+ "description": "Indicates that this custom element participates in form submission, validation, and form state restoration."
6241
+ },
6228
6242
  {
6229
6243
  "kind": "field",
6230
6244
  "name": "name",
@@ -6761,6 +6775,11 @@
6761
6775
  "kind": "javascript-module",
6762
6776
  "path": "../core/src/shared/mixins/Labelled.ts",
6763
6777
  "declarations": [
6778
+ {
6779
+ "kind": "variable",
6780
+ "name": "updateLabels",
6781
+ "description": "A symbol through which to update labels to reflect a control's current state."
6782
+ },
6764
6783
  {
6765
6784
  "kind": "function",
6766
6785
  "name": "isLabelledMixin",
@@ -6810,16 +6829,6 @@
6810
6829
  },
6811
6830
  "description": "The label elements that the element is associated with.",
6812
6831
  "readonly": true
6813
- },
6814
- {
6815
- "kind": "method",
6816
- "name": "[_updateLabels]",
6817
- "privacy": "private",
6818
- "return": {
6819
- "type": {
6820
- "text": "void"
6821
- }
6822
- }
6823
6832
  }
6824
6833
  ],
6825
6834
  "parameters": [
@@ -6834,6 +6843,14 @@
6834
6843
  }
6835
6844
  ],
6836
6845
  "exports": [
6846
+ {
6847
+ "kind": "js",
6848
+ "name": "updateLabels",
6849
+ "declaration": {
6850
+ "name": "updateLabels",
6851
+ "module": "../core/src/shared/mixins/Labelled.ts"
6852
+ }
6853
+ },
6837
6854
  {
6838
6855
  "kind": "js",
6839
6856
  "name": "isLabelledMixin",
package/dist/index.js CHANGED
@@ -268,6 +268,16 @@ M3eChipElement.styles = css `
268
268
  overflow: hidden;
269
269
  text-overflow: ellipsis;
270
270
  }
271
+ a {
272
+ all: unset;
273
+ display: block;
274
+ position: absolute;
275
+ top: 0px;
276
+ left: 0px;
277
+ right: 0px;
278
+ bottom: 0px;
279
+ z-index: 1;
280
+ }
271
281
  :host([variant="elevated"]) .base {
272
282
  background-color: var(--m3e-elevated-chip-container-color, ${DesignToken.color.surfaceContainerLow});
273
283
 
@@ -541,6 +551,18 @@ var _M3eFilterChipElement_instances, _M3eFilterChipElement_clickHandler, _M3eFil
541
551
  * with Material 3 guidelines. Appearance variants include `elevated` and `outlined`, enabling visual
542
552
  * differentiation and contextual emphasis.
543
553
  *
554
+ * @example
555
+ * The following example illustrates a single-select `m3e-filter-chip-set` containing multiple `m3e-filter-chip` components that
556
+ * allow a user to choose an option. You can use the `multi` attribute to enable multiselect.
557
+ * ```html
558
+ * <m3e-filter-chip-set aria-label="Filter by topic">
559
+ * <m3e-filter-chip><m3e-icon slot="icon" name="palette"></m3e-icon>Design</m3e-filter-chip>
560
+ * <m3e-filter-chip><m3e-icon slot="icon" name="accessibility_new"></m3e-icon>Accessibility</m3e-filter-chip>
561
+ * <m3e-filter-chip><m3e-icon slot="icon" name="motion_photos_on"></m3e-icon>Motion</m3e-filter-chip>
562
+ * <m3e-filter-chip><m3e-icon slot="icon" name="description"></m3e-icon>Documentation</m3e-filter-chip>
563
+ * </m3e-filter-chip-set>
564
+ * ```
565
+ *
544
566
  * @tag m3e-filter-chip
545
567
  *
546
568
  * @slot - Renders the label of the chip.
@@ -601,7 +623,7 @@ var _M3eFilterChipElement_instances, _M3eFilterChipElement_clickHandler, _M3eFil
601
623
  * @cssprop --m3e-chip-unselected-leading-icon-color - Leading icon color in unselected state.
602
624
  * @cssprop --m3e-chip-unselected-trailing-icon-color - Trailing icon color in unselected state.
603
625
  */
604
- let M3eFilterChipElement = class M3eFilterChipElement extends Selected(KeyboardClick(Focusable(DisabledInteractive(Disabled(AttachInternals(Role(M3eChipElement, "option"), true)))))) {
626
+ let M3eFilterChipElement = class M3eFilterChipElement extends Selected(KeyboardClick(Focusable(DisabledInteractive(Disabled(AttachInternals(Role(M3eChipElement, "radio"), true)))))) {
605
627
  constructor() {
606
628
  super(...arguments);
607
629
  _M3eFilterChipElement_instances.add(this);
@@ -761,7 +783,7 @@ M3eFilterChipElement = __decorate([
761
783
  t$2("m3e-filter-chip")
762
784
  ], M3eFilterChipElement);
763
785
 
764
- var _M3eFilterChipSetElement_instances, _M3eFilterChipSetElement_handleSlotChange, _M3eFilterChipSetElement_handleKeyDown, _M3eFilterChipSetElement_handleChange, _a;
786
+ var _M3eFilterChipSetElement_instances, _M3eFilterChipSetElement_handleSlotChange, _M3eFilterChipSetElement_handleKeyDown, _M3eFilterChipSetElement_handleChange, _M3eFilterChipSetElement_updateChipRole, _a;
765
787
  /**
766
788
  * A container that organizes filter chips into a cohesive group, enabling selection and
767
789
  * deselection of values used to refine content or trigger contextual behavior.
@@ -799,7 +821,7 @@ var _M3eFilterChipSetElement_instances, _M3eFilterChipSetElement_handleSlotChang
799
821
  *
800
822
  * @cssprop --m3e-chip-set-spacing - The spacing (gap) between chips in the set.
801
823
  */
802
- let M3eFilterChipSetElement = class M3eFilterChipSetElement extends Labelled(Dirty(Touched(FormAssociated(Disabled(AttachInternals(Role(M3eChipSetElement, "listbox"))))))) {
824
+ let M3eFilterChipSetElement = class M3eFilterChipSetElement extends Labelled(Dirty(Touched(FormAssociated(Disabled(AttachInternals(Role(M3eChipSetElement, "radiogroup"))))))) {
803
825
  constructor() {
804
826
  super(...arguments);
805
827
  _M3eFilterChipSetElement_instances.add(this);
@@ -860,10 +882,15 @@ let M3eFilterChipSetElement = class M3eFilterChipSetElement extends Labelled(Dir
860
882
  this[selectionManager].disabled = this.disabled;
861
883
  }
862
884
  if (changedProperties.has("multi")) {
863
- this.ariaMultiSelectable = `${this.multi}`;
885
+ this.role = this.multi ? "group" : "radiogroup";
886
+ __classPrivateFieldGet(this, _M3eFilterChipSetElement_instances, "m", _M3eFilterChipSetElement_updateChipRole).call(this);
864
887
  this[selectionManager].multi = this.multi;
865
888
  this[selectionManager].disableRovingTabIndex(this.multi);
866
889
  }
890
+ if (changedProperties.has("multi") || changedProperties.has("disabled")) {
891
+ // aria-disabled is not supported on radiogroup roles.
892
+ this.ariaDisabled = this.multi && this.disabled ? "true" : null;
893
+ }
867
894
  if (changedProperties.has("hideSelectionIndicator")) {
868
895
  this.chips.forEach((x) => x.classList.toggle("-hide-selection", this.hideSelectionIndicator));
869
896
  }
@@ -880,6 +907,7 @@ let M3eFilterChipSetElement = class M3eFilterChipSetElement extends Labelled(Dir
880
907
  _M3eFilterChipSetElement_handleSlotChange = function _M3eFilterChipSetElement_handleSlotChange() {
881
908
  const { added } = this[selectionManager].setItems([...this.querySelectorAll("m3e-filter-chip")]);
882
909
  added.forEach((x) => x.classList.toggle("-hide-selection", this.hideSelectionIndicator));
910
+ __classPrivateFieldGet(this, _M3eFilterChipSetElement_instances, "m", _M3eFilterChipSetElement_updateChipRole).call(this);
883
911
  };
884
912
  _M3eFilterChipSetElement_handleKeyDown = function _M3eFilterChipSetElement_handleKeyDown(e) {
885
913
  if (!this.multi) {
@@ -890,6 +918,9 @@ _M3eFilterChipSetElement_handleChange = function _M3eFilterChipSetElement_handle
890
918
  e.stopPropagation();
891
919
  this.dispatchEvent(new Event("change", { bubbles: true }));
892
920
  };
921
+ _M3eFilterChipSetElement_updateChipRole = function _M3eFilterChipSetElement_updateChipRole() {
922
+ this.chips.forEach((x) => (x.role = this.multi ? "button" : "radio"));
923
+ };
893
924
  __decorate([
894
925
  n$1({ type: Boolean })
895
926
  ], M3eFilterChipSetElement.prototype, "multi", void 0);
@@ -922,6 +953,19 @@ var _M3eInputChipElement_instances, _M3eInputChipElement_handleAvatarSlotChange,
922
953
  * and manage discrete values such as tags or keywords. It supports expressive styling, accessibility,
923
954
  * keyboard interaction, and appearance variants including `elevated` and `outlined`.
924
955
  *
956
+ * @example
957
+ * The following example illustrates the use of the `m3e-input-chip-set` inside a `m3e-form-field`.
958
+ * In this example, the `input` slot specifies the `input` element used to add input chips and the
959
+ * field label's `for` attribute targets the `input` element to provide an accessible label.
960
+ * ```html
961
+ * <m3e-form-field>
962
+ * <label slot="label" for="keywords">Keywords</label>
963
+ * <m3e-input-chip-set aria-label="Enter keywords">
964
+ * <input id="keywords" slot="input" placeholder="New keyword..." />
965
+ * </m3e-input-chip-set>
966
+ * </m3e-form-field>
967
+ * ```
968
+ *
925
969
  * @tag m3e-input-chip
926
970
  *
927
971
  * @slot - Renders the label of the chip.
@@ -1207,7 +1251,7 @@ let M3eInputChipSetElement = class M3eInputChipSetElement extends RequiredConstr
1207
1251
  // validating required state on change to support form-field integration.
1208
1252
  return [...this.querySelectorAll("m3e-input-chip")];
1209
1253
  }
1210
- /** The selected values of the set. */
1254
+ /** The values of the set. */
1211
1255
  get value() {
1212
1256
  const values = this.chips.map((x) => x.value);
1213
1257
  return values.length == 0 ? null : values;
@@ -1381,6 +1425,29 @@ _M3eInputChipSetElement_handleInputKeyDown = function _M3eInputChipSetElement_ha
1381
1425
  }
1382
1426
  }
1383
1427
  };
1428
+ (() => {
1429
+ const lightDomStyle = new CSSStyleSheet();
1430
+ lightDomStyle.replaceSync(css `
1431
+ m3e-input-chip-set [slot="input"]::placeholder {
1432
+ user-select: none;
1433
+ color: currentColor;
1434
+ transition: opacity ${DesignToken.motion.duration.extraLong1};
1435
+ }
1436
+ m3e-input-chip-set:not(:focus-within) [slot="input"]::placeholder {
1437
+ opacity: 0;
1438
+ transition: 0s;
1439
+ }
1440
+ m3e-input-chip-set:hover [slot="input"]::placeholder {
1441
+ transition: 0s;
1442
+ }
1443
+ @media (prefers-reduced-motion) {
1444
+ m3e-input-chip-set [slot="input"]::placeholder {
1445
+ transition: none !important;
1446
+ }
1447
+ }
1448
+ `.toString());
1449
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, lightDomStyle];
1450
+ })();
1384
1451
  /** The styles of the element. */
1385
1452
  M3eInputChipSetElement.styles = [
1386
1453
  M3eChipSetElement.styles,
@@ -1402,27 +1469,10 @@ M3eInputChipSetElement.styles = [
1402
1469
  ::slotted(m3e-input-chip) {
1403
1470
  min-width: 0;
1404
1471
  }
1405
- ::slotted([slot="input"])::placeholder {
1406
- user-select: none;
1407
- color: currentColor;
1408
- transition: opacity ${DesignToken.motion.duration.extraLong1};
1409
- }
1410
- :host(:not(:focus-within)) ::slotted([slot="input"])::placeholder {
1411
- opacity: 0;
1412
- transition: 0s;
1413
- }
1414
- :host(:hover) ::slotted([slot="input"])::placeholder {
1415
- transition: 0s;
1416
- }
1417
1472
  span[role="row"],
1418
1473
  span[role="gridcell"] {
1419
1474
  display: contents;
1420
1475
  }
1421
- @media (prefers-reduced-motion) {
1422
- ::slotted([slot="input"])::placeholder {
1423
- transition: none !important;
1424
- }
1425
- }
1426
1476
  `,
1427
1477
  ];
1428
1478
  M3eInputChipSetElement = __decorate([