@m3e/chips 1.0.0-rc.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.
Files changed (45) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +539 -0
  3. package/cem.config.mjs +16 -0
  4. package/demo/index.html +183 -0
  5. package/dist/css-custom-data.json +777 -0
  6. package/dist/custom-elements.json +3307 -0
  7. package/dist/html-custom-data.json +277 -0
  8. package/dist/index.js +1516 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/index.min.js +480 -0
  11. package/dist/index.min.js.map +1 -0
  12. package/dist/src/AssistChipElement.d.ts +82 -0
  13. package/dist/src/AssistChipElement.d.ts.map +1 -0
  14. package/dist/src/ChipElement.d.ts +86 -0
  15. package/dist/src/ChipElement.d.ts.map +1 -0
  16. package/dist/src/ChipSetElement.d.ts +43 -0
  17. package/dist/src/ChipSetElement.d.ts.map +1 -0
  18. package/dist/src/ChipVariant.d.ts +3 -0
  19. package/dist/src/ChipVariant.d.ts.map +1 -0
  20. package/dist/src/FilterChipElement.d.ts +93 -0
  21. package/dist/src/FilterChipElement.d.ts.map +1 -0
  22. package/dist/src/FilterChipSetElement.d.ts +78 -0
  23. package/dist/src/FilterChipSetElement.d.ts.map +1 -0
  24. package/dist/src/InputChipElement.d.ts +104 -0
  25. package/dist/src/InputChipElement.d.ts.map +1 -0
  26. package/dist/src/InputChipSetElement.d.ts +75 -0
  27. package/dist/src/InputChipSetElement.d.ts.map +1 -0
  28. package/dist/src/SuggestionChipElement.d.ts +83 -0
  29. package/dist/src/SuggestionChipElement.d.ts.map +1 -0
  30. package/dist/src/index.d.ts +10 -0
  31. package/dist/src/index.d.ts.map +1 -0
  32. package/eslint.config.mjs +13 -0
  33. package/package.json +55 -0
  34. package/rollup.config.js +32 -0
  35. package/src/AssistChipElement.ts +103 -0
  36. package/src/ChipElement.ts +336 -0
  37. package/src/ChipSetElement.ts +60 -0
  38. package/src/ChipVariant.ts +2 -0
  39. package/src/FilterChipElement.ts +254 -0
  40. package/src/FilterChipSetElement.ts +161 -0
  41. package/src/InputChipElement.ts +287 -0
  42. package/src/InputChipSetElement.ts +360 -0
  43. package/src/SuggestionChipElement.ts +104 -0
  44. package/src/index.ts +9 -0
  45. package/tsconfig.json +9 -0
@@ -0,0 +1,103 @@
1
+ import { nothing } from "lit";
2
+ import { customElement } from "lit/decorators.js";
3
+
4
+ import {
5
+ AttachInternals,
6
+ Disabled,
7
+ DisabledInteractive,
8
+ Focusable,
9
+ FormSubmitter,
10
+ KeyboardClick,
11
+ LinkButton,
12
+ Role,
13
+ } from "@m3e/core";
14
+
15
+ import { M3eChipElement } from "./ChipElement";
16
+
17
+ /**
18
+ * @summary
19
+ * A chip users interact with to perform a smart or automated action that can span multiple applications.
20
+ *
21
+ * @description
22
+ * The `m3e-assist-chip` component presents a Material 3 assist chip, providing users with quick access to
23
+ * contextually relevant actions. It is designed for use cases like suggested actions, quick filters, or
24
+ * secondary operations, and supports accessibility, keyboard interaction, and expressive state styling
25
+ * in line with Material 3 guidelines. Appearance variants include `elevated` and `outlined`, enabling visual
26
+ * differentiation and contextual emphasis.
27
+ *
28
+ * @example
29
+ * The following example illustrates use of the `m3e-assist-chip`. In this example, multiple chips are nested inside
30
+ * a `m3e-chip-set` container to create a cohesive set of chips. The container is given the ARIA `role="group"` to convey
31
+ * to assistive technologies that the chips are part of a related set of element.
32
+ * ```html
33
+ * <m3e-chip-set role="group" aria-label="Quick actions">
34
+ * <m3e-assist-chip><m3e-icon slot="icon" name="edit"></m3e-icon>Edit</m3e-assist-chip>
35
+ * <m3e-assist-chip><m3e-icon slot="icon" name="delete"></m3e-icon>Delete</m3e-assist-chip>
36
+ * <m3e-assist-chip><m3e-icon slot="icon" name="content_copy"></m3e-icon>Copy</m3e-assist-chip>
37
+ * <m3e-assist-chip><m3e-icon slot="icon" name="share"></m3e-icon>Share</m3e-assist-chip>
38
+ * </m3e-chip-set>
39
+ * ```
40
+ *
41
+ * @tag m3e-assist-chip
42
+ *
43
+ * @slot - Renders the label of the chip.
44
+ * @slot icon - Renders an icon before the chip's label.
45
+ *
46
+ * @attr disabled - A value indicating whether the element is disabled.
47
+ * @attr disabled-interactive - A value indicating whether the element is disabled and interactive.
48
+ * @attr download - A value indicating whether the `target` of the link button will be downloaded, optionally specifying the new name of the file.
49
+ * @attr href - The URL to which the link button points.
50
+ * @attr name - The name of the element, submitted as a pair with the element's `value` as part of form data, when the element is used to submit a form.
51
+ * @attr rel - The relationship between the `target` of the link button and the document.
52
+ * @attr target - The target of the link button.
53
+ * @attr type - The type of the element.
54
+ * @attr value - A string representing the value of the chip.
55
+ * @attr variant - The appearance variant of the chip.
56
+ *
57
+ * @cssprop --m3e-chip-container-shape - Border radius of the chip container.
58
+ * @cssprop --m3e-chip-container-height - Base height of the chip container before density adjustment.
59
+ * @cssprop --m3e-chip-label-text-font-size - Font size of the chip label text.
60
+ * @cssprop --m3e-chip-label-text-font-weight - Font weight of the chip label text.
61
+ * @cssprop --m3e-chip-label-text-line-height - Line height of the chip label text.
62
+ * @cssprop --m3e-chip-label-text-tracking - Letter spacing of the chip label text.
63
+ * @cssprop --m3e-chip-label-text-color - Label text color in default state.
64
+ * @cssprop --m3e-chip-icon-color - Icon color in default state.
65
+ * @cssprop --m3e-chip-icon-size - Font size of leading/trailing icons.
66
+ * @cssprop --m3e-chip-spacing - Horizontal gap between chip content elements.
67
+ * @cssprop --m3e-chip-padding-start - Default start padding when no icon is present.
68
+ * @cssprop --m3e-chip-padding-end - Default end padding when no trailing icon is present.
69
+ * @cssprop --m3e-chip-with-icon-padding-start - Start padding when leading icon is present.
70
+ * @cssprop --m3e-chip-with-icon-padding-end - End padding when trailing icon is present.
71
+ * @cssprop --m3e-chip-disabled-label-text-color - Base color for disabled label text.
72
+ * @cssprop --m3e-chip-disabled-label-text-opacity - Opacity applied to disabled label text.
73
+ * @cssprop --m3e-chip-disabled-icon-color - Base color for disabled icons.
74
+ * @cssprop --m3e-chip-disabled-icon-opacity - Opacity applied to disabled icons.
75
+ * @cssprop --m3e-elevated-chip-container-color - Background color for elevated variant.
76
+ * @cssprop --m3e-elevated-chip-elevation - Elevation level for elevated variant.
77
+ * @cssprop --m3e-elevated-chip-hover-elevation - Elevation level on hover.
78
+ * @cssprop --m3e-elevated-chip-disabled-container-color - Background color for disabled elevated variant.
79
+ * @cssprop --m3e-elevated-chip-disabled-container-opacity - Opacity applied to disabled elevated background.
80
+ * @cssprop --m3e-elevated-chip-disabled-elevation - Elevation level for disabled elevated variant.
81
+ * @cssprop --m3e-outlined-chip-outline-thickness - Outline thickness for outlined variant.
82
+ * @cssprop --m3e-outlined-chip-outline-color - Outline color for outlined variant.
83
+ * @cssprop --m3e-outlined-chip-disabled-outline-color - Outline color for disabled outlined variant.
84
+ * @cssprop --m3e-outlined-chip-disabled-outline-opacity - Opacity applied to disabled outline.
85
+ */
86
+ @customElement("m3e-assist-chip")
87
+ export class M3eAssistChipElement extends FormSubmitter(
88
+ AttachInternals(
89
+ LinkButton(KeyboardClick(Focusable(DisabledInteractive(Disabled(Role(M3eChipElement, "button")))))),
90
+ true
91
+ )
92
+ ) {
93
+ /** @internal @inheritdoc */
94
+ protected override _renderTrailingIcon(): unknown {
95
+ return nothing;
96
+ }
97
+ }
98
+
99
+ declare global {
100
+ interface HTMLElementTagNameMap {
101
+ "m3e-assist-chip": M3eAssistChipElement;
102
+ }
103
+ }
@@ -0,0 +1,336 @@
1
+ import { css, CSSResultGroup, html, LitElement, nothing, PropertyValues, unsafeCSS } from "lit";
2
+ import { customElement, property, query } from "lit/decorators.js";
3
+
4
+ import {
5
+ DesignToken,
6
+ getTextContent,
7
+ hasAssignedNodes,
8
+ isDisabledInteractiveMixin,
9
+ isDisabledMixin,
10
+ isLinkButtonMixin,
11
+ M3eElevationElement,
12
+ M3eFocusRingElement,
13
+ M3eRippleElement,
14
+ M3eStateLayerElement,
15
+ renderPseudoLink,
16
+ Role,
17
+ } from "@m3e/core";
18
+
19
+ import { ChipVariant } from "./ChipVariant";
20
+
21
+ /**
22
+ * @summary
23
+ * A non-interactive chip used to convey small pieces of information.
24
+ *
25
+ * @description
26
+ * The `m3e-chip` component establishes the foundational structure for chips. It supports expressive styling,
27
+ * accessible interaction, and flexible content projection, aligning with Material 3 guidelines. Appearance
28
+ * variants include `elevated` and `outlined`, enabling visual differentiation and contextual emphasis.
29
+ *
30
+ * @example
31
+ * The following example illustrates use of the `m3e-chip` and `m3e-chip-set` components to present non-interactive chips.
32
+ * ```html
33
+ * <m3e-chip-set>
34
+ * <m3e-chip><m3e-icon slot="icon" name="palette"></m3e-icon>Design</m3e-chip>
35
+ * <m3e-chip><m3e-icon slot="icon" name="accessibility_new"></m3e-icon>Accessibility</m3e-chip>
36
+ * <m3e-chip><m3e-icon slot="icon" name="motion_photos_on"></m3e-icon>Motion</m3e-chip>
37
+ * <m3e-chip><m3e-icon slot="icon" name="description"></m3e-icon>Documentation</m3e-chip>
38
+ * </m3e-chip-set>
39
+ * ```
40
+ *
41
+ * @tag m3e-chip
42
+ *
43
+ * @slot - Renders the label of the chip.
44
+ * @slot icon - Renders an icon before the chip's label.
45
+ * @slot trailing-icon - Renders an icon after the chip's label.
46
+ *
47
+ * @attr value - A string representing the value of the chip.
48
+ * @attr variant - The appearance variant of the chip.
49
+ *
50
+ * @cssprop --m3e-chip-container-shape - Border radius of the chip container.
51
+ * @cssprop --m3e-chip-container-height - Base height of the chip container before density adjustment.
52
+ * @cssprop --m3e-chip-label-text-font-size - Font size of the chip label text.
53
+ * @cssprop --m3e-chip-label-text-font-weight - Font weight of the chip label text.
54
+ * @cssprop --m3e-chip-label-text-line-height - Line height of the chip label text.
55
+ * @cssprop --m3e-chip-label-text-tracking - Letter spacing of the chip label text.
56
+ * @cssprop --m3e-chip-label-text-color - Label text color in default state.
57
+ * @cssprop --m3e-chip-icon-color - Icon color in default state.
58
+ * @cssprop --m3e-chip-icon-size - Font size of leading/trailing icons.
59
+ * @cssprop --m3e-chip-spacing - Horizontal gap between chip content elements.
60
+ * @cssprop --m3e-chip-padding-start - Default start padding when no icon is present.
61
+ * @cssprop --m3e-chip-padding-end - Default end padding when no trailing icon is present.
62
+ * @cssprop --m3e-chip-with-icon-padding-start - Start padding when leading icon is present.
63
+ * @cssprop --m3e-chip-with-icon-padding-end - End padding when trailing icon is present.
64
+ * @cssprop --m3e-elevated-chip-container-color - Background color for elevated variant.
65
+ * @cssprop --m3e-elevated-chip-elevation - Elevation level for elevated variant.
66
+ * @cssprop --m3e-elevated-chip-hover-elevation - Elevation level on hover.
67
+ * @cssprop --m3e-outlined-chip-outline-thickness - Outline thickness for outlined variant.
68
+ * @cssprop --m3e-outlined-chip-outline-color - Outline color for outlined variant.
69
+ */
70
+ @customElement("m3e-chip")
71
+ export class M3eChipElement extends Role(LitElement, "none") {
72
+ /** The styles of the element. */
73
+ static override styles: CSSResultGroup = css`
74
+ :host {
75
+ display: inline-block;
76
+ vertical-align: middle;
77
+ outline: none;
78
+ }
79
+ .base {
80
+ box-sizing: border-box;
81
+ vertical-align: middle;
82
+ display: inline-flex;
83
+ align-items: center;
84
+ justify-content: center;
85
+ position: relative;
86
+ width: 100%;
87
+ transition: ${unsafeCSS(
88
+ `background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`
89
+ )};
90
+ border-radius: var(--m3e-chip-container-shape, ${DesignToken.shape.corner.small});
91
+ height: calc(var(--m3e-chip-container-height, 2rem) + ${DesignToken.density.calc(-2)});
92
+ font-size: var(--m3e-chip-label-text-font-size, ${DesignToken.typescale.standard.label.large.fontSize});
93
+ font-weight: var(--m3e-chip-label-text-font-weight, ${DesignToken.typescale.standard.label.large.fontWeight});
94
+ line-height: var(--m3e-chip-label-text-line-height, ${DesignToken.typescale.standard.label.large.lineHeight});
95
+ letter-spacing: var(--m3e-chip-label-text-tracking, ${DesignToken.typescale.standard.label.large.tracking});
96
+ }
97
+ :host(:not(m3e-chip):not(:disabled):not([disabled-interactive])) {
98
+ cursor: pointer;
99
+ }
100
+ :host(:not(m3e-chip):not(:disabled)[disabled-interactive]) {
101
+ cursor: not-allowed;
102
+ }
103
+ :host(:not(m3e-chip):not(:disabled):not([disabled-interactive])) .base {
104
+ user-select: none;
105
+ }
106
+ .touch {
107
+ position: absolute;
108
+ height: 3rem;
109
+ left: 0;
110
+ right: 0;
111
+ }
112
+ .wrapper {
113
+ width: 100%;
114
+ overflow: hidden;
115
+ display: inline-flex;
116
+ align-items: center;
117
+ column-gap: var(--m3e-chip-spacing, 0.5rem);
118
+ }
119
+ .label {
120
+ flex: 1 1 auto;
121
+ min-width: 0;
122
+ white-space: nowrap;
123
+ overflow: hidden;
124
+ text-overflow: ellipsis;
125
+ }
126
+ :host([variant="elevated"]) .base {
127
+ background-color: var(--m3e-elevated-chip-container-color, ${DesignToken.color.surfaceContainerLow});
128
+
129
+ --m3e-elevation-level: var(--m3e-elevated-chip-elevation, ${DesignToken.elevation.level1});
130
+ --m3e-elevation-hover-level: var(--m3e-elevated-chip-hover-elevation, ${DesignToken.elevation.level2});
131
+ --m3e-elevation-focus-level: var(--m3e-elevated-chip-elevation, ${DesignToken.elevation.level1});
132
+ --m3e-elevation-pressed-level: var(--m3e-elevated-chip-elevation, ${DesignToken.elevation.level1});
133
+ }
134
+ :host([variant="outlined"]) .base {
135
+ outline-width: var(--m3e-outlined-chip-outline-thickness, 1px);
136
+ outline-style: solid;
137
+ outline-offset: calc(0px - var(--m3e-outlined-chip-outline-thickness, 1px));
138
+ }
139
+ :host(:not(:disabled):not([disabled-interactive])[variant="outlined"]) .base {
140
+ outline-color: var(--m3e-outlined-chip-outline-color, ${DesignToken.color.outlineVariant});
141
+ }
142
+ :host(:disabled[variant="outlined"]) .base,
143
+ :host([disabled-interactive][variant="outlined"]) .base {
144
+ outline-color: color-mix(
145
+ in srgb,
146
+ var(--m3e-outlined-chip-disabled-outline-color, ${DesignToken.color.onSurface})
147
+ var(--m3e-outlined-chip-disabled-outline-opacity, 12%),
148
+ transparent
149
+ );
150
+ }
151
+ :host(.-with-icon) .wrapper {
152
+ padding-inline-start: var(--m3e-chip-with-icon-padding-start, 0.5rem);
153
+ }
154
+ :host(:not(.-with-icon)) .wrapper {
155
+ padding-inline-start: var(--m3e-chip-padding-start, 1rem);
156
+ }
157
+ :host(.-with-trailing-icon) .wrapper {
158
+ padding-inline-end: var(--m3e-chip-with-icon-padding-end, 0.5rem);
159
+ }
160
+ :host(:not(.-with-trailing-icon)) .wrapper {
161
+ padding-inline-end: var(--m3e-chip-padding-end, 1rem);
162
+ }
163
+ ::slotted([slot="icon"]),
164
+ ::slotted([slot="trailing-icon"]) {
165
+ flex: none;
166
+ width: 1em;
167
+ font-size: var(--m3e-chip-icon-size, 1.125rem) !important;
168
+ }
169
+ :host(:not(:disabled):not([disabled-interactive]):not([selected])) .base {
170
+ color: var(--m3e-chip-label-text-color, ${DesignToken.color.onSurface});
171
+ }
172
+ :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]),
173
+ :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) {
174
+ color: var(--m3e-chip-icon-color, ${DesignToken.color.primary});
175
+ }
176
+ :host(:disabled) .base,
177
+ :host([disabled-interactive]) .base {
178
+ color: color-mix(
179
+ in srgb,
180
+ var(--m3e-chip-disabled-label-text-color, ${DesignToken.color.onSurface})
181
+ var(--m3e-chip-disabled-label-text-opacity, 38%),
182
+ transparent
183
+ );
184
+ }
185
+ :host(:disabled) ::slotted([slot="icon"]),
186
+ :host([disabled-interactive]) ::slotted([slot="icon"]),
187
+ :host(:disabled) ::slotted([slot="trailing-icon"]),
188
+ :host([disabled-interactive]) ::slotted([slot="trailing-icon"]) {
189
+ color: color-mix(
190
+ in srgb,
191
+ var(--m3e-chip-disabled-icon-color, ${DesignToken.color.onSurface}) var(--m3e-chip-disabled-icon-opacity, 38%),
192
+ transparent
193
+ );
194
+ }
195
+ :host([variant="elevated"]:disabled) .base,
196
+ :host([variant="elevated"][disabled-interactive]) .base {
197
+ background-color: color-mix(
198
+ in srgb,
199
+ var(--m3e-elevated-chip-disabled-container-color, ${DesignToken.color.onSurface})
200
+ var(--m3e-elevated-chip-disabled-container-opacity, 12%),
201
+ transparent
202
+ );
203
+ --m3e-elevation-level: var(--m3e-elevated-chip-disabled-elevation, ${DesignToken.elevation.level0});
204
+ }
205
+ @media (prefers-reduced-motion) {
206
+ .base {
207
+ transition: none;
208
+ }
209
+ }
210
+ @media (forced-colors: active) {
211
+ .base {
212
+ transition: none;
213
+ }
214
+ :host(:not(:disabled):not([disabled-interactive]):not([selected])) .base,
215
+ :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]),
216
+ :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) {
217
+ color: CanvasText;
218
+ }
219
+ :host(:not(:disabled):not([disabled-interactive])[variant="outlined"]) .base {
220
+ outline-color: CanvasText;
221
+ }
222
+ :host(:disabled) .base,
223
+ :host([disabled-interactive]) .base,
224
+ :host(:disabled) ::slotted([slot="icon"]),
225
+ :host([disabled-interactive]) ::slotted([slot="icon"]),
226
+ :host(:disabled) ::slotted([slot="trailing-icon"]),
227
+ :host([disabled-interactive]) ::slotted([slot="trailing-icon"]) {
228
+ color: GrayText;
229
+ }
230
+ :host(:disabled[variant="outlined"]) .base,
231
+ :host([disabled-interactive][variant="outlined"]) .base {
232
+ outline-color: GrayText;
233
+ }
234
+ }
235
+ `;
236
+
237
+ /** @private */ @query(".elevation") private readonly _elevation?: M3eElevationElement;
238
+ /** @private */ @query(".focus-ring") private readonly _focusRing?: M3eFocusRingElement;
239
+ /** @private */ @query(".state-layer") private readonly _stateLayer?: M3eStateLayerElement;
240
+ /** @private */ @query(".ripple") private readonly _ripple?: M3eRippleElement;
241
+
242
+ /** @private */ #value?: string;
243
+ /** @private */ #textContent = "";
244
+
245
+ /**
246
+ * The appearance variant of the chip.
247
+ * @default "outlined"
248
+ */
249
+ @property({ reflect: true }) variant: ChipVariant = "outlined";
250
+
251
+ /** A string representing the value of the chip. */
252
+ @property() get value() {
253
+ return this.#value ?? this.#textContent;
254
+ }
255
+ set value(value: string) {
256
+ this.#value = value;
257
+ }
258
+
259
+ /** @inheritdoc */
260
+ protected override firstUpdated(_changedProperties: PropertyValues): void {
261
+ super.firstUpdated(_changedProperties);
262
+
263
+ if (this.role === "listitem") {
264
+ this.removeAttribute("tabindex");
265
+ }
266
+
267
+ [this._elevation, this._focusRing, this._stateLayer, this._ripple].forEach((x) => {
268
+ if (!x?.htmlFor) {
269
+ x?.attach(this);
270
+ }
271
+ });
272
+ }
273
+
274
+ /** @inheritdoc */
275
+ protected override render(): unknown {
276
+ const disabled = !isDisabledMixin(this) || this.disabled;
277
+ const disabledInteractive = isDisabledInteractiveMixin(this) && this.disabledInteractive;
278
+
279
+ return html`<div class="base">
280
+ <m3e-elevation class="elevation" ?disabled="${disabled || disabledInteractive}"></m3e-elevation>
281
+ <m3e-state-layer class="state-layer" ?disabled="${disabled || disabledInteractive}"></m3e-state-layer>
282
+ <m3e-focus-ring class="focus-ring" ?disabled="${disabled}"></m3e-focus-ring>
283
+ <m3e-ripple class="ripple" ?disabled="${disabled || disabledInteractive}"></m3e-ripple>
284
+ <div class="touch" aria-hidden="true"></div>
285
+ ${isLinkButtonMixin(this) ? this[renderPseudoLink]() : nothing}
286
+ <div class="wrapper">${this.#renderContent()}</div>
287
+ </div>`;
288
+ }
289
+
290
+ /** @private */
291
+ #renderContent(): unknown {
292
+ return html`${this._renderIcon()}
293
+ <div class="label">${this._renderSlot()}</div>
294
+ ${this._renderTrailingIcon()}`;
295
+ }
296
+
297
+ /** @internal */
298
+ protected _renderIcon(): unknown {
299
+ return html`<slot name="icon" aria-hidden="true" @slotchange="${this.#handleIconSlotChange}"></slot>`;
300
+ }
301
+
302
+ /** @internal */
303
+ protected _renderTrailingIcon(): unknown {
304
+ return html`<slot
305
+ name="trailing-icon"
306
+ aria-hidden="true"
307
+ @slotchange="${this.#handleTrailingIconSlotChange}"
308
+ ></slot>`;
309
+ }
310
+
311
+ /** @internal */
312
+ protected _renderSlot(): unknown {
313
+ return html`<slot @slotchange="${this.#handleSlotChange}"></slot>`;
314
+ }
315
+
316
+ /** @private */
317
+ #handleIconSlotChange(e: Event): void {
318
+ this.classList.toggle("-with-icon", hasAssignedNodes(<HTMLSlotElement>e.target));
319
+ }
320
+
321
+ /** @private */
322
+ #handleTrailingIconSlotChange(e: Event): void {
323
+ this.classList.toggle("-with-trailing-icon", hasAssignedNodes(<HTMLSlotElement>e.target));
324
+ }
325
+
326
+ /** @private */
327
+ #handleSlotChange(e: Event): void {
328
+ this.#textContent = getTextContent(<HTMLSlotElement>e.target);
329
+ }
330
+ }
331
+
332
+ declare global {
333
+ interface HTMLElementTagNameMap {
334
+ "m3e-chip": M3eChipElement;
335
+ }
336
+ }
@@ -0,0 +1,60 @@
1
+ import { css, CSSResultGroup, html, LitElement } from "lit";
2
+ import { customElement } from "lit/decorators.js";
3
+
4
+ import { Role, Vertical } from "@m3e/core";
5
+
6
+ /**
7
+ * @summary
8
+ * A container used to organize chips into a cohesive unit.
9
+ *
10
+ * @description
11
+ * The `m3e-chip-set` component provides a flexible container for grouping chips, supporting both
12
+ * horizontal and vertical layouts. It manages chip arrangement, spacing, and accessibility, and
13
+ * serves as the foundation for chip set variants such as input and filter chip sets.
14
+ *
15
+ * @example
16
+ * The following example illustrates use of the `m3e-chip` and `m3e-chip-set` components to present non-interactive chips.
17
+ * ```html
18
+ * <m3e-chip-set>
19
+ * <m3e-chip><m3e-icon slot="icon" name="palette"></m3e-icon>Design</m3e-chip>
20
+ * <m3e-chip><m3e-icon slot="icon" name="accessibility_new"></m3e-icon>Accessibility</m3e-chip>
21
+ * <m3e-chip><m3e-icon slot="icon" name="motion_photos_on"></m3e-icon>Motion</m3e-chip>
22
+ * <m3e-chip><m3e-icon slot="icon" name="description"></m3e-icon>Documentation</m3e-chip>
23
+ * </m3e-chip-set>
24
+ * ```
25
+ *
26
+ * @tag m3e-chip-set
27
+ *
28
+ * @slot - Renders the chips of the set.
29
+ *
30
+ * @attr vertical - Whether the element is oriented vertically.
31
+ *
32
+ * @cssprop --m3e-chip-set-spacing - The spacing (gap) between chips in the set.
33
+ */
34
+ @customElement("m3e-chip-set")
35
+ export class M3eChipSetElement extends Vertical(Role(LitElement, "none")) {
36
+ /** The styles of the element. */
37
+ static override styles: CSSResultGroup = css`
38
+ :host {
39
+ display: inline-flex;
40
+ flex-wrap: wrap;
41
+ vertical-align: middle;
42
+ gap: var(--m3e-chip-set-spacing, 0.5rem);
43
+ outline: none;
44
+ }
45
+ :host([vertical]) {
46
+ flex-direction: column;
47
+ }
48
+ `;
49
+
50
+ /** @inheritdoc */
51
+ protected override render(): unknown {
52
+ return html`<slot></slot>`;
53
+ }
54
+ }
55
+
56
+ declare global {
57
+ interface HTMLElementTagNameMap {
58
+ "m3e-chip-set": M3eChipSetElement;
59
+ }
60
+ }
@@ -0,0 +1,2 @@
1
+ /** Specifies the possible appearance variants of a chip. */
2
+ export type ChipVariant = "outlined" | "elevated";