fluentui-svelte 0.4.0 → 0.6.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 (59) hide show
  1. package/README.md +1 -1
  2. package/dist/components/auto-suggest-box/docs/llms.md +76 -15
  3. package/dist/components/card/card-header.svelte +2 -2
  4. package/dist/components/dialog/dialog-actions.svelte +17 -2
  5. package/dist/components/dialog/dialog-content.svelte +2 -2
  6. package/dist/components/dialog/dialog-content.svelte.d.ts +1 -1
  7. package/dist/components/dialog/dialog-surface.svelte +32 -3
  8. package/dist/components/dialog/dialog-title.svelte +23 -6
  9. package/dist/components/dialog/dialog-trigger.svelte +8 -2
  10. package/dist/components/dialog/dialog-trigger.svelte.d.ts +1 -1
  11. package/dist/components/dialog/docs/llms.md +2 -2
  12. package/dist/components/dialog/types.d.ts +6 -2
  13. package/dist/components/dialog/utils.d.ts +2 -0
  14. package/dist/components/dialog/utils.js +1 -0
  15. package/dist/components/dropdown/dropdown.svelte +1 -0
  16. package/dist/components/list-view/docs/llms.md +79 -27
  17. package/dist/components/list-view/list-view-item.svelte +14 -11
  18. package/dist/components/list-view/list-view.svelte +3 -2
  19. package/dist/components/list-view/types.d.ts +5 -1
  20. package/dist/components/menu/docs/llms.md +16 -0
  21. package/dist/components/menu/menu-popover.svelte +7 -12
  22. package/dist/components/menu/menu-popover.svelte.d.ts +2 -10
  23. package/dist/components/menu/types.d.ts +21 -0
  24. package/dist/components/rating/docs/llms.md +110 -0
  25. package/dist/components/rating/rating.svelte +210 -0
  26. package/dist/components/rating/rating.svelte.d.ts +19 -0
  27. package/dist/components/rating/types.d.ts +44 -0
  28. package/dist/components/rating/types.js +1 -0
  29. package/dist/components/tag/docs/llms.md +383 -0
  30. package/dist/components/tag/tag-group.d.ts +2 -0
  31. package/dist/components/tag/tag-group.js +2 -0
  32. package/dist/components/tag/tag-group.svelte +117 -0
  33. package/dist/components/tag/tag-group.svelte.d.ts +20 -0
  34. package/dist/components/tag/tag.svelte +458 -0
  35. package/dist/components/tag/tag.svelte.d.ts +19 -0
  36. package/dist/components/tag/types.d.ts +135 -0
  37. package/dist/components/tag/types.js +1 -0
  38. package/dist/components/tag-picker/docs/llms.md +292 -0
  39. package/dist/components/tag-picker/option-group.svelte +38 -0
  40. package/dist/components/tag-picker/option-group.svelte.d.ts +4 -0
  41. package/dist/components/tag-picker/option.svelte +71 -0
  42. package/dist/components/tag-picker/option.svelte.d.ts +4 -0
  43. package/dist/components/tag-picker/tag-picker.d.ts +2 -0
  44. package/dist/components/tag-picker/tag-picker.js +2 -0
  45. package/dist/components/tag-picker/tag-picker.svelte +644 -0
  46. package/dist/components/tag-picker/tag-picker.svelte.d.ts +21 -0
  47. package/dist/components/tag-picker/types.d.ts +122 -0
  48. package/dist/components/tag-picker/types.js +1 -0
  49. package/dist/components/tree-view/docs/llms.md +166 -1
  50. package/dist/components/tree-view/tree-view-item-content.svelte +41 -8
  51. package/dist/components/tree-view/tree-view-item.svelte +10 -1
  52. package/dist/components/tree-view/tree-view.svelte +17 -2
  53. package/dist/components/tree-view/tree-view.svelte.js +4 -2
  54. package/dist/components/tree-view/types.d.ts +4 -0
  55. package/dist/index.d.ts +7 -0
  56. package/dist/index.js +12 -0
  57. package/dist/internal/constants.d.ts +0 -4
  58. package/dist/internal/constants.js +0 -4002
  59. package/package.json +3 -2
@@ -0,0 +1,458 @@
1
+ <script lang="ts">
2
+ import DismissRegular from 'fluentui-icons-svelte/DismissRegular.svelte';
3
+ import { RenderSoC } from '../../internal/index.js';
4
+ import { PREFIX } from '../../internal/constants.js';
5
+ import { getTagGroupContext } from './tag-group.js';
6
+ import type { TagProps } from './types.js';
7
+
8
+ const ID = $props.id();
9
+ const FALLBACK_ID = PREFIX + '-tag-' + ID;
10
+
11
+ let {
12
+ appearance,
13
+ size,
14
+ shape = 'circular',
15
+ disabled,
16
+ selected = false,
17
+ dismissible,
18
+ interactive = false,
19
+ value = FALLBACK_ID,
20
+ icon,
21
+ media,
22
+ secondaryText,
23
+ dismissIcon = DismissRegular,
24
+ dismissLabel = 'Dismiss',
25
+ onDismiss,
26
+ onclick,
27
+ onkeydown,
28
+ primaryProps,
29
+ dismissProps,
30
+ class: classes,
31
+ ref = $bindable(),
32
+ children,
33
+ ...attributes
34
+ }: TagProps = $props();
35
+
36
+ const group = getTagGroupContext();
37
+
38
+ const _appearance = $derived(appearance ?? group?.config.appearance ?? 'filled');
39
+ const _size = $derived(size ?? group?.config.size ?? 'medium');
40
+ const _dismissible = $derived(dismissible ?? group?.config.dismissible ?? false);
41
+ const _disabled = $derived(!!(disabled || group?.config.disabled));
42
+ const _selected = $derived(interactive && group ? group.state.selectedValues.includes(value) : selected);
43
+
44
+ /** A plain tag is the dismiss button itself when it is dismissible. An interactive one holds its own buttons. */
45
+ const tag = $derived(interactive ? 'div' : _dismissible ? 'button' : 'span');
46
+
47
+ const primaryId = $derived(primaryProps?.id ?? `${FALLBACK_ID}-primary`);
48
+ const dismissId = $derived(dismissProps?.id ?? `${FALLBACK_ID}-dismiss`);
49
+
50
+ /** The dismiss icon names the button, unless the consumer named the tag itself. */
51
+ const named = $derived(!!(attributes['aria-label'] || attributes['aria-labelledby']));
52
+
53
+ const dismiss = (e: MouseEvent | KeyboardEvent) => {
54
+ onDismiss?.(e, value);
55
+ group?.methods.dismiss(e, value);
56
+ };
57
+
58
+ const handleClick = (e: MouseEvent) => {
59
+ onclick?.(e);
60
+ dismiss(e);
61
+ };
62
+
63
+ const handlePrimaryClick = (e: MouseEvent) => {
64
+ onclick?.(e);
65
+ group?.methods.select(e, value);
66
+ };
67
+
68
+ const handleKeydown = (e: KeyboardEvent) => {
69
+ onkeydown?.(e);
70
+ if (_dismissible && !_disabled && (e.key === 'Delete' || e.key === 'Backspace')) dismiss(e);
71
+ };
72
+
73
+ const rootClick = $derived(tag === 'button' ? handleClick : tag === 'span' ? onclick : undefined);
74
+ </script>
75
+
76
+ <!--
77
+ @component
78
+ Fluent UI Tag: A visual representation of an attribute, person or asset.
79
+ It can be dismissible, and with `interactive` it becomes an interaction tag that has a primary action of its own.
80
+ - Usage:
81
+ ```tsx
82
+ <script>
83
+ import { Tag } from 'fluentui-svelte';
84
+ import { CalendarMonthRegular } from 'fluentui-icons-svelte';
85
+ </script>
86
+
87
+ <Tag icon={CalendarMonthRegular} dismissible onDismiss={(e, value) => remove(value)}>
88
+ Primary text
89
+ </Tag>
90
+ ```
91
+ -->
92
+ {#snippet content()}
93
+ {#if media}
94
+ <span class="fs-tag-media"><RenderSoC SoC={media} /></span>
95
+ {:else if icon}
96
+ <span class="fs-tag-icon" aria-hidden="true"><RenderSoC SoC={icon} /></span>
97
+ {/if}
98
+ <span class="fs-tag-primary-text">{@render children?.()}</span>
99
+ {#if secondaryText}
100
+ <span class="fs-tag-secondary-text">
101
+ {#if typeof secondaryText === 'string'}
102
+ {secondaryText}
103
+ {:else}
104
+ {@render secondaryText()}
105
+ {/if}
106
+ </span>
107
+ {/if}
108
+ {/snippet}
109
+
110
+ <svelte:element
111
+ this={tag}
112
+ bind:this={ref}
113
+ class={[
114
+ 'fs-tag',
115
+ _size,
116
+ _appearance,
117
+ shape,
118
+ interactive && 'interactive',
119
+ _selected && 'selected',
120
+ _disabled && 'disabled',
121
+ _dismissible && 'dismissible',
122
+ (media || icon) && 'leading',
123
+ secondaryText && 'with-secondary',
124
+ classes
125
+ ]}
126
+ type={tag === 'button' ? 'button' : undefined}
127
+ disabled={tag === 'button' ? _disabled : undefined}
128
+ {...attributes}
129
+ onclick={rootClick}
130
+ onkeydown={handleKeydown}
131
+ >
132
+ {#if interactive}
133
+ <button
134
+ type="button"
135
+ class="fs-tag-primary"
136
+ id={primaryId}
137
+ disabled={_disabled}
138
+ aria-pressed={group ? _selected : undefined}
139
+ {...primaryProps}
140
+ onclick={handlePrimaryClick}
141
+ >
142
+ {@render content()}
143
+ </button>
144
+ {#if _dismissible}
145
+ <button
146
+ type="button"
147
+ class="fs-tag-dismiss"
148
+ id={dismissId}
149
+ disabled={_disabled}
150
+ aria-label={dismissLabel}
151
+ aria-labelledby="{primaryId} {dismissId}"
152
+ {...dismissProps}
153
+ onclick={dismiss}
154
+ >
155
+ <RenderSoC SoC={dismissIcon} />
156
+ </button>
157
+ {/if}
158
+ {:else}
159
+ {@render content()}
160
+ {#if _dismissible}
161
+ <span
162
+ class="fs-tag-dismiss-icon"
163
+ role={named ? undefined : 'img'}
164
+ aria-label={named ? undefined : dismissLabel}
165
+ aria-hidden={named ? 'true' : undefined}
166
+ >
167
+ <RenderSoC SoC={dismissIcon} />
168
+ </span>
169
+ {/if}
170
+ {/if}
171
+ </svelte:element>
172
+
173
+ <style>
174
+ .fs-tag {
175
+ --tag-spacing: 0.4375rem;
176
+ --tag-icon-size: 1.25rem;
177
+ --tag-icon-gap: 0.25rem;
178
+ --tag-media-gap: 0.5rem;
179
+ --tag-dismiss-spacing: 0.3125rem;
180
+ --tag-height: 2rem;
181
+ --tag-font-size: var(--fs-body2-font-size);
182
+ --tag-line-height: var(--fs-body2-line-height);
183
+ --tag-radius: var(--fs-control-border-radius);
184
+ /* Changed from original --fs-control-fill-quaternary to --fs-control-fill-secondary */
185
+ --tag-bg: var(--fs-control-fill-secondary);
186
+ --tag-bg-hover: var(--fs-control-alt-fill-quaternary);
187
+ --tag-bg-pressed: var(--fs-control-alt-fill-secondary);
188
+ --tag-fg: var(--fs-text-primary);
189
+ --tag-border: var(--fs-control-stroke-default);
190
+ --tag-divider: var(--fs-control-stroke-secondary);
191
+ --tag-danger: var(--fs-system-critical);
192
+ --tag-danger-pressed: color-mix(in srgb, var(--fs-system-critical), black 15%);
193
+
194
+ box-sizing: border-box;
195
+ width: fit-content;
196
+ height: var(--tag-height);
197
+ margin: 0;
198
+ color: var(--tag-fg);
199
+ font-family: inherit;
200
+ font-size: var(--tag-font-size);
201
+ line-height: var(--tag-line-height);
202
+ text-align: start;
203
+ user-select: none;
204
+ border-radius: var(--tag-radius);
205
+
206
+ &.small {
207
+ --tag-spacing: 0.3125rem;
208
+ --tag-icon-size: 1rem;
209
+ --tag-icon-gap: 0.125rem;
210
+ --tag-media-gap: 0.375rem;
211
+ --tag-dismiss-spacing: 0.1875rem;
212
+ --tag-height: 1.5rem;
213
+ --tag-font-size: var(--fs-caption-font-size);
214
+ --tag-line-height: var(--fs-caption-line-height);
215
+ }
216
+ &.extra-small {
217
+ --tag-spacing: 0.3125rem;
218
+ --tag-icon-size: 0.75rem;
219
+ --tag-icon-gap: 0.125rem;
220
+ --tag-media-gap: 0.375rem;
221
+ --tag-height: 1.25rem;
222
+ --tag-font-size: var(--fs-caption-font-size);
223
+ --tag-line-height: var(--fs-caption-line-height);
224
+ }
225
+ &.circular {
226
+ --tag-radius: 9999rem;
227
+ }
228
+ &.square {
229
+ --tag-radius: 0;
230
+ }
231
+
232
+ &.outline {
233
+ --tag-bg: transparent;
234
+ --tag-bg-hover: var(--fs-subtle-fill-secondary);
235
+ --tag-bg-pressed: var(--fs-subtle-fill-tertiary);
236
+ --tag-border: var(--fs-control-stroke-secondary);
237
+ }
238
+ &.brand {
239
+ --tag-bg: var(--fs-system-attention-bg);
240
+ --tag-bg-hover: color-mix(in srgb, var(--fs-system-attention-bg), rgb(var(--fs-accent-base)) 10%);
241
+ --tag-bg-pressed: color-mix(in srgb, var(--fs-system-attention-bg), rgb(var(--fs-accent-base)) 18%);
242
+ --tag-fg: var(--fs-accent-text-primary);
243
+ --tag-divider: color-mix(in srgb, rgb(var(--fs-accent-base)), transparent 70%);
244
+ }
245
+ &.selected {
246
+ --tag-bg: var(--fs-accent-fill-default);
247
+ --tag-bg-hover: var(--fs-accent-fill-secondary);
248
+ --tag-bg-pressed: var(--fs-accent-fill-tertiary);
249
+ --tag-fg: var(--fs-text-on-accent-primary);
250
+ --tag-border: var(--fs-accent-fill-default);
251
+ --tag-divider: var(--fs-control-stroke-on-accent-secondary);
252
+ }
253
+ &.disabled {
254
+ --tag-bg: var(--fs-control-alt-fill-secondary);
255
+ --tag-bg-hover: var(--fs-control-alt-fill-secondary);
256
+ --tag-bg-pressed: var(--fs-control-alt-fill-secondary);
257
+ --tag-fg: var(--fs-text-disabled);
258
+ --tag-border: transparent;
259
+ --tag-divider: var(--fs-control-stroke-default);
260
+ &.outline {
261
+ --tag-bg: transparent;
262
+ --tag-bg-hover: transparent;
263
+ --tag-bg-pressed: transparent;
264
+ --tag-border: var(--fs-control-stroke-default);
265
+ }
266
+ }
267
+
268
+ /* A plain tag: a single box, a button when it is dismissible. */
269
+ &:not(.interactive) {
270
+ display: inline-grid;
271
+ grid-template-areas:
272
+ 'media primary dismiss'
273
+ 'media secondary dismiss';
274
+ align-items: center;
275
+ padding: 0;
276
+ padding-inline: var(--tag-spacing);
277
+ background: var(--tag-bg);
278
+ border: 1px solid var(--tag-border);
279
+ &.leading {
280
+ padding-inline-start: 0;
281
+ }
282
+ &.dismissible {
283
+ padding-inline-end: 0;
284
+ }
285
+ &:focus-visible {
286
+ outline: 0.125rem solid var(--fs-focus-stroke-outer);
287
+ outline-offset: 0.063rem;
288
+ }
289
+ }
290
+ &.disabled:not(.interactive) {
291
+ cursor: not-allowed;
292
+ }
293
+
294
+ /* An interaction tag: a primary button, followed by the dismiss button. */
295
+ &.interactive {
296
+ display: inline-flex;
297
+ align-items: center;
298
+ }
299
+
300
+ & .fs-tag-primary,
301
+ & .fs-tag-dismiss {
302
+ box-sizing: border-box;
303
+ height: 100%;
304
+ margin: 0;
305
+ padding: 0;
306
+ color: inherit;
307
+ font: inherit;
308
+ background: var(--tag-bg);
309
+ border: 1px solid var(--tag-border);
310
+ cursor: pointer;
311
+ &:hover {
312
+ background: var(--tag-bg-hover);
313
+ }
314
+ &:active {
315
+ background: var(--tag-bg-pressed);
316
+ }
317
+ &:focus-visible {
318
+ position: relative;
319
+ z-index: 1;
320
+ outline: 0.125rem solid var(--fs-focus-stroke-outer);
321
+ outline-offset: 0.063rem;
322
+ }
323
+ &:disabled {
324
+ cursor: not-allowed;
325
+ background: var(--tag-bg);
326
+ }
327
+ }
328
+ & .fs-tag-primary {
329
+ display: inline-grid;
330
+ grid-template-areas:
331
+ 'media primary'
332
+ 'media secondary';
333
+ align-items: center;
334
+ text-align: start;
335
+ border-radius: var(--tag-radius);
336
+ padding-inline: var(--tag-spacing);
337
+ }
338
+ &.leading .fs-tag-primary {
339
+ padding-inline-start: 0;
340
+ }
341
+ &.dismissible .fs-tag-primary {
342
+ border-inline-end: none;
343
+ border-start-end-radius: 0;
344
+ border-end-end-radius: 0;
345
+ }
346
+ & .fs-tag-dismiss {
347
+ display: flex;
348
+ align-items: center;
349
+ padding-inline: var(--tag-dismiss-spacing);
350
+ font-size: var(--tag-icon-size);
351
+ border-inline-start-color: var(--tag-divider);
352
+ border-start-start-radius: 0;
353
+ border-end-start-radius: 0;
354
+ border-start-end-radius: var(--tag-radius);
355
+ border-end-end-radius: var(--tag-radius);
356
+ &:hover {
357
+ color: var(--tag-danger);
358
+ }
359
+ &:active {
360
+ color: var(--tag-danger-pressed);
361
+ }
362
+ }
363
+ /* The selected hover and pressed fills are translucent: drop the opaque rim so the fill is a single colour. */
364
+ &.selected .fs-tag-primary,
365
+ &.selected .fs-tag-dismiss {
366
+ &:hover,
367
+ &:active {
368
+ border-color: transparent;
369
+ }
370
+ }
371
+ &.selected .fs-tag-dismiss {
372
+ &:hover,
373
+ &:active {
374
+ color: var(--tag-fg);
375
+ border-inline-start-color: var(--tag-divider);
376
+ }
377
+ }
378
+ &.disabled .fs-tag-dismiss:hover {
379
+ color: inherit;
380
+ }
381
+
382
+ & .fs-tag-media,
383
+ & .fs-tag-icon {
384
+ grid-area: media;
385
+ display: flex;
386
+ align-items: center;
387
+ }
388
+ & .fs-tag-media {
389
+ padding-inline: 1px var(--tag-media-gap);
390
+ }
391
+ & .fs-tag-icon {
392
+ box-sizing: content-box;
393
+ width: var(--tag-icon-size);
394
+ padding-inline: var(--tag-spacing) var(--tag-icon-gap);
395
+ font-size: var(--tag-icon-size);
396
+ }
397
+ & .fs-tag-primary-text {
398
+ grid-area: primary;
399
+ grid-row: 1 / 3;
400
+ padding-inline: 0.125rem;
401
+ white-space: nowrap;
402
+ }
403
+ &.with-secondary .fs-tag-primary-text {
404
+ grid-row: 1;
405
+ margin-block-start: -0.125rem;
406
+ font-size: var(--fs-caption-font-size);
407
+ line-height: var(--fs-caption-line-height);
408
+ }
409
+ & .fs-tag-secondary-text {
410
+ grid-area: secondary;
411
+ padding-inline: 0.125rem;
412
+ font-size: var(--fs-caption2-font-size);
413
+ line-height: var(--fs-caption2-line-height);
414
+ white-space: nowrap;
415
+ }
416
+ & .fs-tag-dismiss-icon {
417
+ grid-area: dismiss;
418
+ display: flex;
419
+ align-items: center;
420
+ align-self: stretch;
421
+ padding-inline: var(--tag-icon-gap) var(--tag-spacing);
422
+ font-size: var(--tag-icon-size);
423
+ border-start-end-radius: calc(var(--tag-radius) - 1px);
424
+ border-end-end-radius: calc(var(--tag-radius) - 1px);
425
+ &:hover {
426
+ cursor: pointer;
427
+ color: var(--tag-danger);
428
+ }
429
+ &:active {
430
+ color: var(--tag-danger-pressed);
431
+ }
432
+ }
433
+ &.selected .fs-tag-dismiss-icon:hover,
434
+ &.selected .fs-tag-dismiss-icon:active {
435
+ color: var(--tag-fg);
436
+ }
437
+ /* A selected tag lightens the area of the dismiss, as the dismiss button of an interactive one does. */
438
+ &.selected:not(.disabled) .fs-tag-dismiss-icon {
439
+ &:hover {
440
+ background: color-mix(in srgb, var(--tag-fg) 16%, transparent);
441
+ }
442
+ &:active {
443
+ background: color-mix(in srgb, var(--tag-fg) 33%, transparent);
444
+ }
445
+ }
446
+ &.disabled .fs-tag-dismiss-icon {
447
+ &:hover {
448
+ cursor: not-allowed;
449
+ color: inherit;
450
+ }
451
+ }
452
+
453
+ & :global(svg) {
454
+ width: var(--tag-icon-size);
455
+ height: var(--tag-icon-size);
456
+ }
457
+ }
458
+ </style>
@@ -0,0 +1,19 @@
1
+ import type { TagProps } from './types.ts';
2
+ /**
3
+ * Fluent UI Tag: A visual representation of an attribute, person or asset.
4
+ * It can be dismissible, and with `interactive` it becomes an interaction tag that has a primary action of its own.
5
+ * - Usage:
6
+ * ```tsx
7
+ * <script>
8
+ * import { Tag } from 'fluentui-svelte';
9
+ * import { CalendarMonthRegular } from 'fluentui-icons-svelte';
10
+ * </script>
11
+ *
12
+ * <Tag icon={CalendarMonthRegular} dismissible onDismiss={(e, value) => remove(value)}>
13
+ * Primary text
14
+ * </Tag>
15
+ * ```
16
+ */
17
+ declare const Tag: import("svelte").Component<TagProps, {}, "ref">;
18
+ type Tag = ReturnType<typeof Tag>;
19
+ export default Tag;
@@ -0,0 +1,135 @@
1
+ import type { Component, Snippet } from 'svelte';
2
+ import type { HTMLAttributes, HTMLButtonAttributes, SVGAttributes } from 'svelte/elements';
3
+ import type { FSContext } from '../../internal/index.js';
4
+ import type { PolymorphicProps, Shapes } from '../../types/index.js';
5
+ export type TagAppearance = 'filled' | 'outline' | 'brand';
6
+ export type TagSize = 'extra-small' | 'small' | 'medium';
7
+ /** @propsmith TagProps */
8
+ export type TagProps = {
9
+ /** The tag can have a filled, outlined or brand appearance. Falls back to the `appearance` of the `TagGroup` it is in.
10
+ * @default 'filled'
11
+ */
12
+ appearance?: TagAppearance;
13
+ /** The tag comes in three sizes. Falls back to the `size` of the `TagGroup` it is in.
14
+ * @default 'medium'
15
+ */
16
+ size?: TagSize;
17
+ /** The tag can have a circular, rounded or square shape.
18
+ * @default 'circular'
19
+ */
20
+ shape?: Shapes;
21
+ /** Shows that the tag cannot be interacted with. A tag inside a disabled `TagGroup` is disabled too.
22
+ * @default false
23
+ */
24
+ disabled?: boolean;
25
+ /** Paints the tag as selected. Inside a `TagGroup` an interactive tag takes its selected state from the `selectedValues` of the group instead.
26
+ * @default false
27
+ */
28
+ selected?: boolean;
29
+ /** Shows a dismiss icon and lets the tag be dismissed. Falls back to the `dismissible` of the `TagGroup` it is in.
30
+ * A tag that is not interactive becomes a single button: activating it, or pressing Delete or Backspace on it, dismisses it.
31
+ * @default false
32
+ */
33
+ dismissible?: boolean;
34
+ /** Renders the tag as an interaction tag: a primary button that carries the action, followed, when the tag is dismissible, by a separate dismiss button.
35
+ * Use it for a tag that has a primary action, and a plain tag for one that does not.
36
+ * @default false
37
+ */
38
+ interactive?: boolean;
39
+ /** Identifies the tag inside a `TagGroup`. It is what `onDismiss` and `onTagSelect` report. Falls back to a generated id. */
40
+ value?: string;
41
+ /** An icon rendered before the text. Do not use it together with `media`.
42
+ * @type Snippet | Component
43
+ */
44
+ icon?: Snippet<[SVGAttributes<SVGElement>]> | Component<SVGAttributes<SVGElement>>;
45
+ /** A visual element rendered before the text, usually an `Avatar`. Do not use it together with `icon`.
46
+ * @type Snippet | Component
47
+ */
48
+ media?: Snippet | Component;
49
+ /** A second line of text that describes or complements the main text.
50
+ * @type string | Snippet
51
+ */
52
+ secondaryText?: string | Snippet;
53
+ /** The icon of the dismiss control.
54
+ * @default DismissRegular
55
+ * @type Snippet | Component
56
+ */
57
+ dismissIcon?: Snippet<[SVGAttributes<SVGElement>]> | Component<SVGAttributes<SVGElement>>;
58
+ /** The accessible name of the dismiss control. When the tag is named through `aria-label` or `aria-labelledby`
59
+ * instead, the dismiss icon is hidden from assistive technologies.
60
+ * @default 'Dismiss'
61
+ */
62
+ dismissLabel?: string;
63
+ /** Called when the tag is dismissed. The consumer owns the data: the tag does not remove itself. */
64
+ onDismiss?: (e: MouseEvent | KeyboardEvent, value: string) => void;
65
+ /** Called when the tag is activated. On an interactive tag it is the click of the primary button. */
66
+ onclick?: (e: MouseEvent) => void;
67
+ /** Called when a key is pressed on the tag. */
68
+ onkeydown?: (e: KeyboardEvent) => void;
69
+ /** Attributes for the primary button of an interactive tag, for example `aria-haspopup`. If you give it
70
+ * a custom `id`, the dismiss button is named after it.
71
+ */
72
+ primaryProps?: Omit<HTMLButtonAttributes, 'children' | 'onclick'>;
73
+ /** Attributes for the dismiss button of an interactive tag. Use `aria-label` together with
74
+ * `aria-labelledby: undefined` to give the button a name that stands on its own.
75
+ */
76
+ dismissProps?: Omit<HTMLButtonAttributes, 'children' | 'onclick'>;
77
+ /** The primary text of the tag. */
78
+ children?: Snippet;
79
+ /** The DOM reference of the tag element.
80
+ * @bindable
81
+ */
82
+ ref?: HTMLElement;
83
+ } & Omit<PolymorphicProps<'span'>, 'children' | 'onclick' | 'onkeydown'>;
84
+ /** @propsmith TagGroupProps */
85
+ export type TagGroupProps = {
86
+ /** The size given to the tags of the group that do not set their own.
87
+ * @default 'medium'
88
+ */
89
+ size?: TagSize;
90
+ /** The appearance given to the tags of the group that do not set their own. */
91
+ appearance?: TagAppearance;
92
+ /** Disables every tag of the group.
93
+ * @default false
94
+ */
95
+ disabled?: boolean;
96
+ /** Makes the tags of the group that do not set their own dismissible. */
97
+ dismissible?: boolean;
98
+ /** The values of the selected interactive tags.
99
+ * @default []
100
+ * @bindable
101
+ */
102
+ selectedValues?: string[];
103
+ /** Called when an interactive tag of the group is activated, with the value it toggles. */
104
+ onTagSelect?: (e: MouseEvent, data: {
105
+ value: string;
106
+ selected: boolean;
107
+ }) => void;
108
+ /** Called when a tag of the group is dismissed. The consumer owns the data: the group does not remove the tag. */
109
+ onDismiss?: (e: MouseEvent | KeyboardEvent, data: {
110
+ value: string;
111
+ }) => void;
112
+ /** The role of the group. Use `list` together with `role="listitem"` on each tag when none of them is actionable.
113
+ * @default 'toolbar'
114
+ */
115
+ role?: HTMLAttributes<HTMLDivElement>['role'];
116
+ /** The tags of the group. */
117
+ children?: Snippet;
118
+ /** The DOM reference of the group element.
119
+ * @bindable
120
+ */
121
+ ref?: HTMLDivElement;
122
+ } & Omit<PolymorphicProps<'div'>, 'children' | 'role'>;
123
+ export type TagGroupContext = FSContext<{
124
+ readonly size?: TagSize;
125
+ readonly appearance?: TagAppearance;
126
+ readonly disabled?: boolean;
127
+ readonly dismissible?: boolean;
128
+ }, {
129
+ readonly selectedValues: string[];
130
+ }, null, {
131
+ /** Toggles the value in `selectedValues` and reports it. */
132
+ select: (e: MouseEvent, value: string) => void;
133
+ /** Reports the dismissed value. */
134
+ dismiss: (e: MouseEvent | KeyboardEvent, value: string) => void;
135
+ }>;
@@ -0,0 +1 @@
1
+ export {};