fluentui-svelte 0.6.0 → 0.7.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.
- package/dist/components/app-surface/app-surface.svelte +96 -0
- package/dist/components/app-surface/app-surface.svelte.d.ts +22 -0
- package/dist/components/app-surface/docs/llms.md +73 -0
- package/dist/components/app-surface/types.d.ts +19 -0
- package/dist/components/app-surface/types.js +1 -0
- package/dist/components/app-window/app-window.d.ts +3 -0
- package/dist/components/app-window/app-window.js +3 -0
- package/dist/components/app-window/app-window.svelte +193 -0
- package/dist/components/app-window/app-window.svelte.d.ts +25 -0
- package/dist/components/app-window/docs/llms.md +119 -0
- package/dist/components/app-window/types.d.ts +66 -0
- package/dist/components/app-window/types.js +1 -0
- package/dist/components/auto-suggest-box/auto-suggest-box.svelte +47 -31
- package/dist/components/auto-suggest-box/auto-suggest-box.svelte.d.ts +2 -2
- package/dist/components/auto-suggest-box/docs/llms.md +34 -33
- package/dist/components/auto-suggest-box/option.svelte +6 -4
- package/dist/components/auto-suggest-box/types.d.ts +13 -16
- package/dist/components/avatar/avatar.svelte +4 -3
- package/dist/components/avatar/docs/llms.md +1 -1
- package/dist/components/avatar/type.d.ts +1 -1
- package/dist/components/badge/badge-icon.svelte +2 -2
- package/dist/components/badge/badge.svelte +2 -2
- package/dist/components/badge/docs/llms.md +2 -2
- package/dist/components/badge/types.d.ts +2 -2
- package/dist/components/breadcrumb/breadcrumb-button.svelte +2 -2
- package/dist/components/breadcrumb/breadcrumb-divider.svelte +2 -2
- package/dist/components/breadcrumb/breadcrumb-item.svelte +2 -2
- package/dist/components/breadcrumb/breadcrumb.svelte +10 -5
- package/dist/components/breadcrumb/docs/llms.md +11 -11
- package/dist/components/breadcrumb/types.d.ts +7 -7
- package/dist/components/button/button.svelte +2 -2
- package/dist/components/button/docs/llms.md +17 -17
- package/dist/components/button/split-button.svelte +7 -7
- package/dist/components/button/types.d.ts +5 -5
- package/dist/components/calendar-date-picker/calendar-date-picker.svelte +98 -10
- package/dist/components/calendar-date-picker/calendar-date-picker.svelte.d.ts +1 -1
- package/dist/components/calendar-date-picker/docs/llms.md +19 -14
- package/dist/components/calendar-date-picker/types.d.ts +22 -8
- package/dist/components/calendar-view/calendar-view-days.svelte +3 -2
- package/dist/components/calendar-view/calendar-view-grid.js +8 -3
- package/dist/components/calendar-view/calendar-view-item.svelte +10 -4
- package/dist/components/calendar-view/calendar-view-months.svelte +3 -2
- package/dist/components/calendar-view/calendar-view-years.svelte +3 -2
- package/dist/components/calendar-view/calendar-view.svelte +11 -4
- package/dist/components/calendar-view/calendar-view.svelte.js +5 -0
- package/dist/components/calendar-view/docs/llms.md +20 -19
- package/dist/components/calendar-view/types.d.ts +6 -1
- package/dist/components/card/card-footer.svelte +2 -2
- package/dist/components/card/card-header.svelte +5 -4
- package/dist/components/card/card-preview.svelte +13 -2
- package/dist/components/card/card.svelte +5 -5
- package/dist/components/card/docs/llms.md +22 -21
- package/dist/components/card/types.d.ts +8 -4
- package/dist/components/checkbox/checkbox.svelte +47 -26
- package/dist/components/checkbox/checkbox.svelte.d.ts +3 -24
- package/dist/components/checkbox/docs/llms.md +24 -23
- package/dist/components/checkbox/types.d.ts +10 -23
- package/dist/components/date-picker/date-picker.svelte +98 -27
- package/dist/components/date-picker/date-picker.svelte.d.ts +1 -1
- package/dist/components/date-picker/docs/llms.md +23 -20
- package/dist/components/date-picker/types.d.ts +24 -15
- package/dist/components/dialog/dialog-actions.svelte +2 -2
- package/dist/components/dialog/dialog-content.svelte +2 -2
- package/dist/components/dialog/dialog-surface.svelte +102 -9
- package/dist/components/dialog/dialog-title.svelte +2 -2
- package/dist/components/dialog/dialog-trigger.svelte +2 -2
- package/dist/components/dialog/dialog.svelte +22 -11
- package/dist/components/dialog/docs/llms.md +56 -19
- package/dist/components/dialog/types.d.ts +25 -7
- package/dist/components/divider/divider.svelte +6 -4
- package/dist/components/divider/types.d.ts +1 -1
- package/dist/components/dropdown/docs/llms.md +30 -28
- package/dist/components/dropdown/dropdown-option.svelte +17 -5
- package/dist/components/dropdown/dropdown.svelte +182 -84
- package/dist/components/dropdown/dropdown.svelte.d.ts +1 -1
- package/dist/components/dropdown/types.d.ts +26 -20
- package/dist/components/dropdown-select/docs/llms.md +24 -22
- package/dist/components/dropdown-select/dropdown-select-option.svelte +2 -2
- package/dist/components/dropdown-select/dropdown-select.svelte +42 -7
- package/dist/components/dropdown-select/types.d.ts +4 -4
- package/dist/components/expander/docs/llms.md +3 -3
- package/dist/components/expander/expander.svelte +13 -8
- package/dist/components/expander/types.d.ts +5 -5
- package/dist/components/flyout/docs/llms.md +1 -1
- package/dist/components/flyout/flyout.svelte +17 -6
- package/dist/components/flyout/types.d.ts +1 -1
- package/dist/components/hyperlink/docs/llms.md +6 -6
- package/dist/components/hyperlink/hyperlink.svelte +13 -4
- package/dist/components/hyperlink/types.d.ts +1 -1
- package/dist/components/info-bar/docs/llms.md +11 -10
- package/dist/components/info-bar/info-bar.svelte +3 -2
- package/dist/components/info-bar/types.d.ts +4 -0
- package/dist/components/label/docs/llms.md +75 -22
- package/dist/components/label/label-context.d.ts +14 -0
- package/dist/components/label/label-context.js +10 -0
- package/dist/components/label/label.svelte +153 -30
- package/dist/components/label/label.svelte.d.ts +1 -1
- package/dist/components/label/types.d.ts +48 -4
- package/dist/components/list-view/docs/llms.md +103 -33
- package/dist/components/list-view/list-view-item-branch.svelte +257 -0
- package/dist/components/list-view/list-view-item-branch.svelte.d.ts +4 -0
- package/dist/components/list-view/list-view-item.svelte +164 -46
- package/dist/components/list-view/list-view-item.svelte.d.ts +5 -5
- package/dist/components/list-view/list-view.svelte +73 -25
- package/dist/components/list-view/types.d.ts +71 -8
- package/dist/components/list-view/utils.d.ts +10 -0
- package/dist/components/list-view/utils.js +17 -1
- package/dist/components/menu/docs/llms.md +98 -15
- package/dist/components/menu/menu-command-bar-item.svelte +61 -0
- package/dist/components/menu/menu-command-bar-item.svelte.d.ts +14 -0
- package/dist/components/menu/menu-command-bar.svelte +218 -0
- package/dist/components/menu/menu-command-bar.svelte.d.ts +21 -0
- package/dist/components/menu/menu-group.svelte +6 -3
- package/dist/components/menu/menu-item-checkbox.svelte +5 -4
- package/dist/components/menu/menu-item-radio.svelte +5 -4
- package/dist/components/menu/menu-item-switch.svelte +5 -4
- package/dist/components/menu/menu-item.svelte +5 -5
- package/dist/components/menu/menu-item.svelte.d.ts +2 -3
- package/dist/components/menu/menu-list.svelte +10 -1
- package/dist/components/menu/menu-popover.svelte +9 -5
- package/dist/components/menu/menu-trigger.svelte +2 -1
- package/dist/components/menu/menu.svelte.js +1 -0
- package/dist/components/menu/types.d.ts +62 -7
- package/dist/components/number-box/docs/llms.md +6 -4
- package/dist/components/number-box/number-box.svelte +35 -29
- package/dist/components/number-box/number-box.svelte.d.ts +1 -1
- package/dist/components/number-box/types.d.ts +1 -1
- package/dist/components/persona/docs/llms.md +29 -25
- package/dist/components/persona/persona.svelte +8 -6
- package/dist/components/persona/types.d.ts +4 -3
- package/dist/components/progress-bar/docs/llms.md +13 -13
- package/dist/components/progress-bar/progress-bar.svelte +6 -6
- package/dist/components/progress-bar/types.d.ts +4 -4
- package/dist/components/progress-ring/docs/llms.md +14 -14
- package/dist/components/progress-ring/progress-ring.svelte +5 -5
- package/dist/components/progress-ring/types.d.ts +3 -3
- package/dist/components/radio-button/docs/llms.md +11 -8
- package/dist/components/radio-button/radio-button.svelte +38 -12
- package/dist/components/radio-button/radio-button.svelte.d.ts +1 -1
- package/dist/components/radio-button/types.d.ts +11 -8
- package/dist/components/rating/docs/llms.md +15 -14
- package/dist/components/rating/rating.svelte +66 -29
- package/dist/components/rating/rating.svelte.d.ts +1 -1
- package/dist/components/rating/types.d.ts +8 -8
- package/dist/components/side-nav/docs/llms.md +110 -0
- package/dist/components/side-nav/side-nav-branch.svelte +43 -0
- package/dist/components/side-nav/side-nav-branch.svelte.d.ts +4 -0
- package/dist/components/side-nav/side-nav-item.svelte +75 -0
- package/dist/components/side-nav/side-nav-item.svelte.d.ts +25 -0
- package/dist/components/side-nav/side-nav-list.svelte +32 -0
- package/dist/components/side-nav/side-nav-list.svelte.d.ts +7 -0
- package/dist/components/side-nav/side-nav.d.ts +2 -0
- package/dist/components/side-nav/side-nav.js +2 -0
- package/dist/components/side-nav/side-nav.svelte +355 -0
- package/dist/components/side-nav/side-nav.svelte.d.ts +24 -0
- package/dist/components/side-nav/types.d.ts +149 -0
- package/dist/components/side-nav/types.js +1 -0
- package/dist/components/skeleton/docs/llms.md +1 -1
- package/dist/components/skeleton/skeleton.svelte +2 -2
- package/dist/components/skeleton/types.d.ts +1 -1
- package/dist/components/slider/docs/llms.md +31 -28
- package/dist/components/slider/slider.svelte +126 -61
- package/dist/components/slider/slider.svelte.d.ts +1 -3
- package/dist/components/slider/types.d.ts +21 -14
- package/dist/components/tab-view/docs/llms.md +7 -7
- package/dist/components/tab-view/tab-view-tab.svelte +16 -14
- package/dist/components/tab-view/tab-view.svelte +16 -9
- package/dist/components/tab-view/types.d.ts +6 -6
- package/dist/components/table/docs/llms.md +38 -33
- package/dist/components/table/table-body.svelte +2 -2
- package/dist/components/table/table-cell-actions.svelte +8 -2
- package/dist/components/table/table-cell-layout.svelte +2 -2
- package/dist/components/table/table-cell.svelte +2 -2
- package/dist/components/table/table-header-cell.svelte +2 -2
- package/dist/components/table/table-header.svelte +2 -2
- package/dist/components/table/table-row.svelte +2 -2
- package/dist/components/table/table-selection-cell.svelte +6 -6
- package/dist/components/table/table.svelte +2 -2
- package/dist/components/table/types.d.ts +11 -11
- package/dist/components/tag/docs/llms.md +26 -26
- package/dist/components/tag/tag-group.svelte +2 -2
- package/dist/components/tag/tag.svelte +13 -12
- package/dist/components/tag/types.d.ts +6 -4
- package/dist/components/tag-picker/docs/llms.md +61 -55
- package/dist/components/tag-picker/option-group.svelte +17 -4
- package/dist/components/tag-picker/option-group.svelte.d.ts +1 -1
- package/dist/components/tag-picker/option.svelte +15 -4
- package/dist/components/tag-picker/tag-picker.svelte +137 -65
- package/dist/components/tag-picker/tag-picker.svelte.d.ts +2 -2
- package/dist/components/tag-picker/types.d.ts +36 -16
- package/dist/components/text-box/docs/llms.md +31 -4
- package/dist/components/text-box/text-box-button.svelte +3 -3
- package/dist/components/text-box/text-box-button.svelte.d.ts +1 -1
- package/dist/components/text-box/text-box.svelte +41 -14
- package/dist/components/text-box/types.d.ts +5 -5
- package/dist/components/textarea/docs/llms.md +4 -3
- package/dist/components/textarea/textarea.svelte +14 -6
- package/dist/components/textarea/types.d.ts +2 -4
- package/dist/components/time-picker/docs/llms.md +18 -15
- package/dist/components/time-picker/time-picker.svelte +133 -33
- package/dist/components/time-picker/time-picker.svelte.d.ts +1 -1
- package/dist/components/time-picker/types.d.ts +23 -13
- package/dist/components/title-bar/docs/llms.md +382 -0
- package/dist/components/title-bar/title-bar-left-controls.svelte +215 -0
- package/dist/components/title-bar/title-bar-left-controls.svelte.d.ts +22 -0
- package/dist/components/title-bar/title-bar-right-controls.svelte +190 -0
- package/dist/components/title-bar/title-bar-right-controls.svelte.d.ts +27 -0
- package/dist/components/title-bar/title-bar.d.ts +3 -0
- package/dist/components/title-bar/title-bar.js +4 -0
- package/dist/components/title-bar/title-bar.svelte +224 -0
- package/dist/components/title-bar/title-bar.svelte.d.ts +26 -0
- package/dist/components/title-bar/types.d.ts +165 -0
- package/dist/components/title-bar/types.js +1 -0
- package/dist/components/toggle-switch/docs/llms.md +11 -9
- package/dist/components/toggle-switch/toggle-switch.svelte +23 -14
- package/dist/components/toggle-switch/toggle-switch.svelte.d.ts +1 -1
- package/dist/components/toggle-switch/types.d.ts +12 -10
- package/dist/components/tooltip/docs/llms.md +1 -1
- package/dist/components/tooltip/tooltip.svelte +5 -4
- package/dist/components/tooltip/types.d.ts +1 -1
- package/dist/components/top-nav/docs/llms.md +1 -1
- package/dist/components/top-nav/top-nav-item.svelte +2 -2
- package/dist/components/top-nav/top-nav.svelte +2 -2
- package/dist/components/top-nav/types.d.ts +2 -2
- package/dist/components/tree-view/docs/llms.md +11 -11
- package/dist/components/tree-view/tree-view-item-content.svelte +3 -3
- package/dist/components/tree-view/tree-view-item.svelte +13 -5
- package/dist/components/tree-view/tree-view.svelte +20 -5
- package/dist/components/tree-view/tree-view.svelte.d.ts +1 -1
- package/dist/components/tree-view/tree-view.svelte.js +31 -3
- package/dist/components/tree-view/types.d.ts +7 -3
- package/dist/index.d.ts +18 -0
- package/dist/index.js +20 -0
- package/dist/internal/components/dynamic-carousel/dynamic-carousel.svelte +26 -5
- package/dist/internal/components/dynamic-carousel/dynamic-carousel.svelte.d.ts +2 -0
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +1 -0
- package/dist/internal/native-field.svelte.d.ts +44 -0
- package/dist/internal/native-field.svelte.js +85 -0
- package/dist/internal/utils.d.ts +16 -2
- package/dist/internal/utils.js +25 -3
- package/dist/types/index.d.ts +3 -3
- package/package.json +50 -36
|
@@ -65,19 +65,19 @@ The status prop allows you to set the status of the progress ring for visual fee
|
|
|
65
65
|
<!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
|
|
66
66
|
<!-- props:ProgressRingProps -->
|
|
67
67
|
|
|
68
|
-
| Name | Type
|
|
69
|
-
| ------------------------- |
|
|
70
|
-
| `value` _bindable_ | `number`
|
|
71
|
-
| `min` | `number`
|
|
72
|
-
| `max` | `number`
|
|
73
|
-
| `indeterminate` | `boolean`
|
|
74
|
-
| `hideRail` | `boolean`
|
|
75
|
-
| `size` | `number`
|
|
76
|
-
| `ref` _bindable_ | `SVGElement`
|
|
77
|
-
| `railElement` _bindable_ | `SVGCircleElement`
|
|
78
|
-
| `trackElement` _bindable_ | `SVGCircleElement`
|
|
79
|
-
| `status` | `'paused'` | `'error'`
|
|
80
|
-
| `class` | `string`
|
|
81
|
-
| Element Attributes |
|
|
68
|
+
| Name | Type | Default | Description |
|
|
69
|
+
| ------------------------- | -------------------------------- | ------- | ------------------------------------------------------------------ |
|
|
70
|
+
| `value` _bindable_ | `number` | `0` | The current value of the progress ring. |
|
|
71
|
+
| `min` | `number` | `0` | The minimum value of the progress ring. |
|
|
72
|
+
| `max` | `number` | `100` | The maximum value of the progress ring. |
|
|
73
|
+
| `indeterminate` | `boolean` | | Spins the ring continuously instead of reporting a value. |
|
|
74
|
+
| `hideRail` | `boolean` | | Whether to hide the rail element. |
|
|
75
|
+
| `size` | `number` | `32` | The size of the progress ring in pixels. |
|
|
76
|
+
| `ref` _bindable_ | `SVGElement` | `null` | | The DOM reference of the progress ring element. |
|
|
77
|
+
| `railElement` _bindable_ | `SVGCircleElement` | `null` | | The DOM reference of the rail element. |
|
|
78
|
+
| `trackElement` _bindable_ | `SVGCircleElement` | `null` | | The DOM reference of the track element. |
|
|
79
|
+
| `status` | `'paused'` | `'error'` | | The current status of the progress ring, which recolors the track. |
|
|
80
|
+
| `class` | `string` | | The class to apply to the progress ring. |
|
|
81
|
+
| Element Attributes | | | |
|
|
82
82
|
|
|
83
83
|
<!-- /props:ProgressRingProps -->
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
'aria-label': ariaLabel,
|
|
13
13
|
indeterminate,
|
|
14
14
|
value = $bindable(0),
|
|
15
|
-
ref = $bindable(),
|
|
16
|
-
railElement = $bindable(),
|
|
17
|
-
trackElement = $bindable(),
|
|
15
|
+
ref = $bindable(null),
|
|
16
|
+
railElement = $bindable(null),
|
|
17
|
+
trackElement = $bindable(null),
|
|
18
18
|
...attributes
|
|
19
19
|
}: ProgressRingProps = $props();
|
|
20
20
|
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
```
|
|
40
40
|
-->
|
|
41
41
|
<svg
|
|
42
|
+
{...attributes}
|
|
42
43
|
bind:this={ref}
|
|
43
44
|
tabindex="-1"
|
|
44
45
|
class={['progress-ring', status && `status-${status}`, classes, { indeterminate }]}
|
|
@@ -50,8 +51,7 @@
|
|
|
50
51
|
aria-valuemin={!indeterminate ? min : undefined}
|
|
51
52
|
aria-valuemax={!indeterminate ? max : undefined}
|
|
52
53
|
aria-valuenow={!indeterminate ? checkValue : undefined}
|
|
53
|
-
style="--ring-circumference: {circumference}px;"
|
|
54
|
-
{...attributes}
|
|
54
|
+
style="{attributes?.style ?? ''}; --ring-circumference: {circumference}px;"
|
|
55
55
|
>
|
|
56
56
|
{#if !hideRail}
|
|
57
57
|
<circle
|
|
@@ -26,15 +26,15 @@ export type ProgressRingProps = {
|
|
|
26
26
|
/** The DOM reference of the progress ring element.
|
|
27
27
|
* @bindable
|
|
28
28
|
*/
|
|
29
|
-
ref?: SVGElement;
|
|
29
|
+
ref?: SVGElement | null;
|
|
30
30
|
/** The DOM reference of the rail element.
|
|
31
31
|
* @bindable
|
|
32
32
|
*/
|
|
33
|
-
railElement?: SVGCircleElement;
|
|
33
|
+
railElement?: SVGCircleElement | null;
|
|
34
34
|
/** The DOM reference of the track element.
|
|
35
35
|
* @bindable
|
|
36
36
|
*/
|
|
37
|
-
trackElement?: SVGCircleElement;
|
|
37
|
+
trackElement?: SVGCircleElement | null;
|
|
38
38
|
/** The current status of the progress ring, which recolors the track. */
|
|
39
39
|
status?: ProgressStatus;
|
|
40
40
|
/** The class to apply to the progress ring. */
|
|
@@ -52,18 +52,21 @@ The checked prop allows you to control the checked state of the radio button. Th
|
|
|
52
52
|
<RadioButton label="Unchecked Option" value="G" />
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
HTML attributes, including class, id and ARIA attributes, apply to the control element. Bind ref to access that control. Use wrapperAttributes and wrapperRef for the outer container.
|
|
56
|
+
|
|
55
57
|
## Component Props
|
|
56
58
|
|
|
57
59
|
<!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
|
|
58
60
|
<!-- props:RadioButtonProps -->
|
|
59
61
|
|
|
60
|
-
| Name | Type
|
|
61
|
-
| ---------------------------- |
|
|
62
|
-
| `label` | `string`
|
|
63
|
-
| `group` _bindable_ | `unknown`
|
|
64
|
-
| `checked` _bindable_ | `boolean` | `false` | Whether the radio button is selected. |
|
|
65
|
-
| `ref` _bindable_ | `HTMLInputElement` | | The DOM reference of the radio button element. |
|
|
66
|
-
| `
|
|
67
|
-
|
|
|
62
|
+
| Name | Type | Default | Description |
|
|
63
|
+
| ---------------------------- | -------------------------------- | ------- | ------------------------------------------------------------------------------------ |
|
|
64
|
+
| `label` | `string` | | The label displayed next to the radio button. Inside a `Label`, it is not rendered |
|
|
65
|
+
| `group` _bindable_ | `unknown` | | Bindable value representing a group of radio inputs that the input will be bound to. |
|
|
66
|
+
| `checked` _bindable_ | `boolean` | `null` | `false` | Whether the radio button is selected. |
|
|
67
|
+
| `ref` _bindable_ | `HTMLInputElement` | `null` | | The DOM reference of the radio button element. |
|
|
68
|
+
| `wrapperAttributes` | `HTMLAttributes` | | The attributes to spread on the wrapper element. |
|
|
69
|
+
| `wrapperRef` _bindable_ | `HTMLDivElement` | `null` | | The DOM reference of the wrapper element. |
|
|
70
|
+
| Element Attributes (`input`) | | | |
|
|
68
71
|
|
|
69
72
|
<!-- /props:RadioButtonProps -->
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { claimLabel } from '../label/label-context.js';
|
|
2
3
|
import { PREFIX } from '../../internal/constants.js';
|
|
3
4
|
import type { RadioButtonProps } from './types.js';
|
|
4
5
|
|
|
@@ -6,17 +7,30 @@
|
|
|
6
7
|
const COMPONENT_NAME = 'radio-button';
|
|
7
8
|
const ID = `${PREFIX}${COMPONENT_NAME}-${FALLBACK_ID}`;
|
|
8
9
|
|
|
10
|
+
const labelContext = claimLabel(() => id);
|
|
11
|
+
|
|
9
12
|
let {
|
|
10
|
-
ref = $bindable(),
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
ref = $bindable(null),
|
|
14
|
+
wrapperRef = $bindable(null),
|
|
15
|
+
group = $bindable(null),
|
|
16
|
+
id = labelContext?.fieldId ?? ID,
|
|
13
17
|
label,
|
|
14
18
|
name = id,
|
|
15
19
|
value,
|
|
16
|
-
checked = $bindable(
|
|
17
|
-
|
|
20
|
+
checked = $bindable(null),
|
|
21
|
+
wrapperAttributes,
|
|
18
22
|
...attributes
|
|
19
23
|
}: RadioButtonProps = $props();
|
|
24
|
+
|
|
25
|
+
/** What `bind:group` reads and writes. Without a group, `checked` decides: an empty group (`null`) matches no value. */
|
|
26
|
+
const binding = {
|
|
27
|
+
get group() {
|
|
28
|
+
return group ?? (checked ? value : null);
|
|
29
|
+
},
|
|
30
|
+
set group(selected) {
|
|
31
|
+
group = selected;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
20
34
|
</script>
|
|
21
35
|
|
|
22
36
|
<!--
|
|
@@ -37,12 +51,13 @@
|
|
|
37
51
|
```
|
|
38
52
|
-->
|
|
39
53
|
|
|
40
|
-
<
|
|
41
|
-
<input type="radio" {id} {name} {value} {checked} bind:this={ref} bind:group
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
<div {...wrapperAttributes} class={['fs-radio-button', wrapperAttributes?.class]} bind:this={wrapperRef}>
|
|
55
|
+
<input {...attributes} type="radio" {id} {name} {value} {checked} bind:this={ref} bind:group={binding.group} />
|
|
56
|
+
<!-- Inside a Label, the Label names the field instead. -->
|
|
57
|
+
{#if label && !labelContext}
|
|
58
|
+
<label for={id}>{label}</label>
|
|
44
59
|
{/if}
|
|
45
|
-
</
|
|
60
|
+
</div>
|
|
46
61
|
|
|
47
62
|
<style>
|
|
48
63
|
.fs-radio-button {
|
|
@@ -100,6 +115,15 @@
|
|
|
100
115
|
}
|
|
101
116
|
}
|
|
102
117
|
}
|
|
118
|
+
&:is(:user-invalid, [aria-invalid='true']) {
|
|
119
|
+
border-color: var(--fs-system-critical);
|
|
120
|
+
&:hover {
|
|
121
|
+
border-color: var(--fs-system-critical);
|
|
122
|
+
}
|
|
123
|
+
& + label {
|
|
124
|
+
color: var(--fs-system-critical);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
103
127
|
}
|
|
104
128
|
&:has(input:disabled) {
|
|
105
129
|
pointer-events: none;
|
|
@@ -115,12 +139,14 @@
|
|
|
115
139
|
&:has(input:focus-visible) {
|
|
116
140
|
outline: 0.125rem var(--fs-focus-stroke-outer) solid;
|
|
117
141
|
outline-offset: 0.125rem;
|
|
118
|
-
&:has(
|
|
142
|
+
&:has(> label) {
|
|
119
143
|
border-radius: 0.063rem;
|
|
120
144
|
outline-offset: 0.313rem;
|
|
121
145
|
}
|
|
122
146
|
}
|
|
123
|
-
&
|
|
147
|
+
& > label {
|
|
148
|
+
flex-grow: 1;
|
|
149
|
+
cursor: pointer;
|
|
124
150
|
font-size: inherit;
|
|
125
151
|
color: inherit;
|
|
126
152
|
padding: 0px 0.75rem;
|
|
@@ -14,6 +14,6 @@ import type { RadioButtonProps } from './types.ts';
|
|
|
14
14
|
* <RadioButton label="Radio Button label" />
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
declare const RadioButton: import("svelte").Component<RadioButtonProps, {}, "ref" | "group" | "
|
|
17
|
+
declare const RadioButton: import("svelte").Component<RadioButtonProps, {}, "ref" | "checked" | "group" | "wrapperRef">;
|
|
18
18
|
type RadioButton = ReturnType<typeof RadioButton>;
|
|
19
19
|
export default RadioButton;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
-
import type { PolymorphicProps } from '../../types/index.js';
|
|
1
|
+
import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
3
2
|
/** @propsmith RadioButtonProps */
|
|
4
3
|
export type RadioButtonProps = {
|
|
5
|
-
/** The label displayed next to the radio button. */
|
|
4
|
+
/** The label displayed next to the radio button. Inside a `Label`, it is not rendered */
|
|
6
5
|
label?: string;
|
|
7
6
|
/** Bindable value representing a group of radio inputs that the input will be bound to.
|
|
8
7
|
* @bindable
|
|
@@ -12,13 +11,17 @@ export type RadioButtonProps = {
|
|
|
12
11
|
* @default false
|
|
13
12
|
* @bindable
|
|
14
13
|
*/
|
|
15
|
-
checked?: boolean;
|
|
14
|
+
checked?: boolean | null;
|
|
16
15
|
/** The DOM reference of the radio button element.
|
|
17
16
|
* @bindable
|
|
18
17
|
*/
|
|
19
|
-
ref?: HTMLInputElement;
|
|
20
|
-
/** The attributes to spread on the
|
|
21
|
-
* @type
|
|
18
|
+
ref?: HTMLInputElement | null;
|
|
19
|
+
/** The attributes to spread on the wrapper element.
|
|
20
|
+
* @type HTMLAttributes
|
|
22
21
|
*/
|
|
23
|
-
|
|
22
|
+
wrapperAttributes?: HTMLAttributes<HTMLDivElement>;
|
|
23
|
+
/** The DOM reference of the wrapper element.
|
|
24
|
+
* @bindable
|
|
25
|
+
*/
|
|
26
|
+
wrapperRef?: HTMLDivElement | null;
|
|
24
27
|
} & HTMLInputAttributes;
|
|
@@ -87,24 +87,25 @@ Use `itemLabel` to customize the accessible label of each radio input.
|
|
|
87
87
|
<Rating value={3} itemLabel={(rating) => `${rating} out of 5 stars`} />
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
+
The root is the control element. HTML attributes, class and ref apply to that element. There is no separate wrapper API.
|
|
91
|
+
|
|
90
92
|
## Component Props
|
|
91
93
|
|
|
92
94
|
<!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
|
|
93
95
|
<!-- props:RatingProps -->
|
|
94
96
|
|
|
95
|
-
| Name
|
|
96
|
-
|
|
|
97
|
-
| `value` _bindable_
|
|
98
|
-
| `max`
|
|
99
|
-
| `step`
|
|
100
|
-
| `size`
|
|
101
|
-
| `iconFilled`
|
|
102
|
-
| `iconOutline`
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `HTMLAttributes<HTMLDivElement>` without `onchange` | | | |
|
|
97
|
+
| Name | Type | Default | Description |
|
|
98
|
+
| ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
99
|
+
| `value` _bindable_ | `number` | `0` | The current rating. Fractions are drawn in quarters until the user rates. |
|
|
100
|
+
| `max` | `number` | `5` | The number of items displayed. Must be a whole number greater than 1. |
|
|
101
|
+
| `step` | `1` | `0.5` | `1` | The precision of the rating. `0.5` allows half-filled items. |
|
|
102
|
+
| `size` | `'small'` | `'medium'` | `'large'` | `'extra-large'` | `'extra-large'` | The size of the rating items. |
|
|
103
|
+
| `iconFilled` | `Component` | | The icon of a filled item. Falls back to a filled star. Partially filled items are clipped, so it also works with half steps. |
|
|
104
|
+
| `iconOutline` | `Component` | | The icon of an empty item. Falls back to an outlined star. |
|
|
105
|
+
| `itemLabel` | `(rating: number) => string` | `` (rating) => `${rating}` `` | Generates the accessible label of the radio input for a rating value. |
|
|
106
|
+
| `onChange` | `(value: number) => void` | | Called when the user changes the rating. |
|
|
107
|
+
| `wrapperRef` _bindable_ | `HTMLDivElement` | `null` | | The DOM reference of the radiogroup element. |
|
|
108
|
+
| `wrapperAttributes` | `HTMLAttributes` | | The attributes to spread on the radiogroup element. This is where its `aria-label`, `aria-labelledby`, `aria-invalid`, `id` and `class` go. |
|
|
109
|
+
| `HTMLInputAttributes` without `type`, `value`, `checked`, `max`, `step`, `size`, `style`, `aria-label`, `aria-invalid`, `children` | | | |
|
|
109
110
|
|
|
110
111
|
<!-- /props:RatingProps -->
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { claimLabel } from '../label/label-context.js';
|
|
3
|
+
import { invokeHandlers } from '../../internal/index.js';
|
|
2
4
|
import { PREFIX } from '../../internal/constants.js';
|
|
3
5
|
import StarFilled from 'fluentui-icons-svelte/StarFilled.svelte';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
+
import StarHalfRegular from 'fluentui-icons-svelte/StarHalfRegular.svelte';
|
|
7
|
+
import StarOneQuarterRegular from 'fluentui-icons-svelte/StarOneQuarterRegular.svelte';
|
|
6
8
|
import StarRegular from 'fluentui-icons-svelte/StarRegular.svelte';
|
|
7
|
-
import
|
|
9
|
+
import StarThreeQuarterRegular from 'fluentui-icons-svelte/StarThreeQuarterRegular.svelte';
|
|
8
10
|
import type { RatingProps } from './types.js';
|
|
9
11
|
|
|
10
12
|
const FALLBACK_ID = $props.id();
|
|
@@ -12,6 +14,8 @@
|
|
|
12
14
|
const ID = `${PREFIX}${COMPONENT_NAME}-${FALLBACK_ID}`;
|
|
13
15
|
const VALUE_ID = `${ID}-value`;
|
|
14
16
|
|
|
17
|
+
const labelContext = claimLabel(() => undefined);
|
|
18
|
+
|
|
15
19
|
let {
|
|
16
20
|
value = $bindable(0),
|
|
17
21
|
max = 5,
|
|
@@ -19,12 +23,15 @@
|
|
|
19
23
|
size = 'extra-large',
|
|
20
24
|
iconFilled,
|
|
21
25
|
iconOutline,
|
|
22
|
-
|
|
26
|
+
id = ID,
|
|
27
|
+
class: classes,
|
|
28
|
+
name = id,
|
|
23
29
|
itemLabel = (rating) => `${rating}`,
|
|
24
30
|
onChange,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
wrapperRef = $bindable(null),
|
|
32
|
+
wrapperAttributes,
|
|
33
|
+
onclick,
|
|
34
|
+
onpointerenter,
|
|
28
35
|
...attributes
|
|
29
36
|
}: RatingProps = $props();
|
|
30
37
|
|
|
@@ -51,9 +58,9 @@
|
|
|
51
58
|
|
|
52
59
|
function iconFor(snapped: number) {
|
|
53
60
|
if (snapped >= 1) return StarFilled;
|
|
54
|
-
if (snapped >= 0.75) return
|
|
55
|
-
if (snapped >= 0.5) return
|
|
56
|
-
if (snapped >= 0.25) return
|
|
61
|
+
if (snapped >= 0.75) return StarThreeQuarterRegular;
|
|
62
|
+
if (snapped >= 0.5) return StarHalfRegular;
|
|
63
|
+
if (snapped >= 0.25) return StarOneQuarterRegular;
|
|
57
64
|
return StarRegular;
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -62,6 +69,19 @@
|
|
|
62
69
|
value = next;
|
|
63
70
|
onChange?.(next);
|
|
64
71
|
}
|
|
72
|
+
|
|
73
|
+
/** The value of the checked radio. Clicks select, the arrow keys included; a form reset unchecks every radio, which the binding reports as `null`. */
|
|
74
|
+
let checked = $derived<number | null>(checkedValue);
|
|
75
|
+
|
|
76
|
+
$effect(() => {
|
|
77
|
+
if (checked !== null) return;
|
|
78
|
+
rated = false;
|
|
79
|
+
value = 0;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
function hover(event: PointerEvent & { currentTarget: HTMLInputElement }, item: number) {
|
|
83
|
+
invokeHandlers(event, [], [() => (hovered = item), onpointerenter]);
|
|
84
|
+
}
|
|
65
85
|
</script>
|
|
66
86
|
|
|
67
87
|
<!--
|
|
@@ -81,13 +101,15 @@
|
|
|
81
101
|
```
|
|
82
102
|
-->
|
|
83
103
|
<div
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
aria-
|
|
90
|
-
aria-
|
|
104
|
+
{...wrapperAttributes}
|
|
105
|
+
class={['fs-rating', `size-${size}`, wrapperAttributes?.class]}
|
|
106
|
+
bind:this={wrapperRef}
|
|
107
|
+
role="radiogroup"
|
|
108
|
+
onpointerleave={(e) => invokeHandlers(e, [], [() => (hovered = undefined), wrapperAttributes?.onpointerleave])}
|
|
109
|
+
aria-labelledby={wrapperAttributes?.['aria-labelledby'] ?? labelContext?.labelId}
|
|
110
|
+
aria-label={wrapperAttributes?.['aria-label'] ??
|
|
111
|
+
(wrapperAttributes?.['aria-labelledby'] || labelContext ? undefined : 'Rating')}
|
|
112
|
+
aria-describedby={[wrapperAttributes?.['aria-describedby'], VALUE_ID].filter(Boolean).join(' ')}
|
|
91
113
|
>
|
|
92
114
|
<span id={VALUE_ID} hidden>Current rating: {value} out of {_max}.</span>
|
|
93
115
|
{#each items as item (item)}
|
|
@@ -96,35 +118,39 @@
|
|
|
96
118
|
{#if custom}
|
|
97
119
|
{@const Outline = iconOutline ?? StarRegular}
|
|
98
120
|
{@const Filled = iconFilled ?? StarFilled}
|
|
99
|
-
<span class=
|
|
121
|
+
<span class={['rating-icon custom', { selected: fill > 0 }]} style="--rating-fill: {fill * 100}%">
|
|
100
122
|
<Outline aria-hidden="true" />
|
|
101
123
|
<span class="filled"><Filled aria-hidden="true" /></span>
|
|
102
124
|
</span>
|
|
103
125
|
{:else}
|
|
104
126
|
{@const Icon = iconFor(fill)}
|
|
105
|
-
<span class=
|
|
127
|
+
<span class={['rating-icon', { selected: fill > 0 }]}><Icon aria-hidden="true" /></span>
|
|
106
128
|
{/if}
|
|
107
129
|
{#if step === 0.5}
|
|
108
130
|
<input
|
|
109
|
-
|
|
110
|
-
|
|
131
|
+
{...attributes}
|
|
132
|
+
{id}
|
|
111
133
|
{name}
|
|
134
|
+
class={['half-value', classes]}
|
|
135
|
+
type="radio"
|
|
112
136
|
value={item - 0.5}
|
|
113
|
-
checked={checkedValue === item - 0.5}
|
|
114
137
|
aria-label={itemLabel(item - 0.5)}
|
|
115
|
-
|
|
116
|
-
|
|
138
|
+
bind:group={checked}
|
|
139
|
+
onclick={(e) => invokeHandlers(e, [], [() => value !== item - 0.5 && select(item - 0.5), onclick])}
|
|
140
|
+
onpointerenter={(e) => hover(e, item - 0.5)}
|
|
117
141
|
/>
|
|
118
142
|
{/if}
|
|
119
143
|
<input
|
|
120
|
-
|
|
121
|
-
type="radio"
|
|
144
|
+
{...attributes}
|
|
122
145
|
{name}
|
|
146
|
+
{id}
|
|
147
|
+
class={['full-value', classes]}
|
|
148
|
+
type="radio"
|
|
123
149
|
value={item}
|
|
124
|
-
checked={checkedValue === item}
|
|
125
150
|
aria-label={itemLabel(item)}
|
|
126
|
-
|
|
127
|
-
|
|
151
|
+
bind:group={checked}
|
|
152
|
+
onclick={(e) => invokeHandlers(e, [], [() => value !== item && select(item), onclick])}
|
|
153
|
+
onpointerenter={(e) => hover(e, item)}
|
|
128
154
|
/>
|
|
129
155
|
</span>
|
|
130
156
|
{/each}
|
|
@@ -148,6 +174,17 @@
|
|
|
148
174
|
&.size-large {
|
|
149
175
|
--rating-size: 20px;
|
|
150
176
|
}
|
|
177
|
+
|
|
178
|
+
&:is([aria-invalid='true'], :has(input:user-invalid)) .rating-icon {
|
|
179
|
+
color: var(--fs-system-critical);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&:has(input:disabled) .rating-icon {
|
|
183
|
+
color: var(--fs-text-disabled);
|
|
184
|
+
& .filled {
|
|
185
|
+
color: inherit;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
151
188
|
}
|
|
152
189
|
|
|
153
190
|
.rating-item {
|
|
@@ -14,6 +14,6 @@ import type { RatingProps } from './types.ts';
|
|
|
14
14
|
* <Rating bind:value step={0.5} size="medium" />
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
declare const Rating: import("svelte").Component<RatingProps, {}, "
|
|
17
|
+
declare const Rating: import("svelte").Component<RatingProps, {}, "value" | "wrapperRef">;
|
|
18
18
|
type Rating = ReturnType<typeof Rating>;
|
|
19
19
|
export default Rating;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Component } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
3
3
|
/** @propsmith RatingProps */
|
|
4
4
|
export type RatingProps = {
|
|
5
5
|
/** The current rating. Fractions are drawn in quarters until the user rates.
|
|
@@ -27,18 +27,18 @@ export type RatingProps = {
|
|
|
27
27
|
* @type Component
|
|
28
28
|
*/
|
|
29
29
|
iconOutline?: Component;
|
|
30
|
-
/** The name of the radio inputs. Generated when not provided. */
|
|
31
|
-
name?: string;
|
|
32
30
|
/** Generates the accessible label of the radio input for a rating value.
|
|
33
31
|
* @default (rating) => `${rating}`
|
|
34
32
|
*/
|
|
35
33
|
itemLabel?: (rating: number) => string;
|
|
36
34
|
/** Called when the user changes the rating. */
|
|
37
35
|
onChange?: (value: number) => void;
|
|
38
|
-
/** The
|
|
39
|
-
class?: string;
|
|
40
|
-
/** The DOM reference of the rating element.
|
|
36
|
+
/** The DOM reference of the radiogroup element.
|
|
41
37
|
* @bindable
|
|
42
38
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
wrapperRef?: HTMLDivElement | null;
|
|
40
|
+
/** The attributes to spread on the radiogroup element. This is where its `aria-label`, `aria-labelledby`, `aria-invalid`, `id` and `class` go.
|
|
41
|
+
* @type HTMLAttributes
|
|
42
|
+
*/
|
|
43
|
+
wrapperAttributes?: HTMLAttributes<HTMLDivElement>;
|
|
44
|
+
} & Omit<HTMLInputAttributes, 'type' | 'value' | 'checked' | 'max' | 'step' | 'size' | 'style' | 'aria-label' | 'aria-invalid' | 'children'>;
|