fluentui-svelte 0.5.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 +17 -2
- package/dist/components/dialog/dialog-content.svelte +2 -2
- package/dist/components/dialog/dialog-content.svelte.d.ts +1 -1
- package/dist/components/dialog/dialog-surface.svelte +130 -8
- package/dist/components/dialog/dialog-title.svelte +23 -6
- package/dist/components/dialog/dialog-trigger.svelte +8 -2
- package/dist/components/dialog/dialog-trigger.svelte.d.ts +1 -1
- package/dist/components/dialog/dialog.svelte +22 -11
- package/dist/components/dialog/docs/llms.md +56 -19
- package/dist/components/dialog/types.d.ts +31 -9
- package/dist/components/dialog/utils.d.ts +2 -0
- package/dist/components/dialog/utils.js +1 -0
- 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 +111 -0
- package/dist/components/rating/rating.svelte +247 -0
- package/dist/components/rating/rating.svelte.d.ts +19 -0
- package/dist/components/rating/types.d.ts +44 -0
- package/dist/components/rating/types.js +1 -0
- 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 +383 -0
- package/dist/components/tag/tag-group.d.ts +2 -0
- package/dist/components/tag/tag-group.js +2 -0
- package/dist/components/tag/tag-group.svelte +117 -0
- package/dist/components/tag/tag-group.svelte.d.ts +20 -0
- package/dist/components/tag/tag.svelte +459 -0
- package/dist/components/tag/tag.svelte.d.ts +19 -0
- package/dist/components/tag/types.d.ts +137 -0
- package/dist/components/tag/types.js +1 -0
- package/dist/components/tag-picker/docs/llms.md +298 -0
- package/dist/components/tag-picker/option-group.svelte +51 -0
- package/dist/components/tag-picker/option-group.svelte.d.ts +4 -0
- package/dist/components/tag-picker/option.svelte +82 -0
- package/dist/components/tag-picker/option.svelte.d.ts +4 -0
- package/dist/components/tag-picker/tag-picker.d.ts +2 -0
- package/dist/components/tag-picker/tag-picker.js +2 -0
- package/dist/components/tag-picker/tag-picker.svelte +716 -0
- package/dist/components/tag-picker/tag-picker.svelte.d.ts +21 -0
- package/dist/components/tag-picker/types.d.ts +142 -0
- package/dist/components/tag-picker/types.js +1 -0
- 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 +25 -0
- package/dist/index.js +32 -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/constants.d.ts +0 -4
- package/dist/internal/constants.js +0 -4002
- 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 +51 -37
|
@@ -66,7 +66,7 @@ The `as` prop lets you choose the HTML tag used to render the skeleton. Possible
|
|
|
66
66
|
| `animation` | `'wave'` | `'pulse'` | `'wave'` | The animation played while the content is loading. |
|
|
67
67
|
| `shape` | `'circular'` | `'rounded'` | `'square'` | `'rounded'` | The skeleton can have a circular, rounded or square shape. |
|
|
68
68
|
| `justify` | `boolean` | | The skeleton is justified to the full width of the container. |
|
|
69
|
-
| `ref` _bindable_ | `HTMLElement`
|
|
69
|
+
| `ref` _bindable_ | `HTMLElement` | `null` | | The DOM reference of the skeleton element. |
|
|
70
70
|
| HTML Attributes | | | |
|
|
71
71
|
|
|
72
72
|
<!-- /props:SkeletonProps -->
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
shape = 'rounded',
|
|
9
9
|
justify,
|
|
10
10
|
class: classes,
|
|
11
|
-
ref = $bindable(),
|
|
11
|
+
ref = $bindable(null),
|
|
12
12
|
...attributes
|
|
13
13
|
}: SkeletonProps<Tag> = $props();
|
|
14
14
|
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
-->
|
|
37
37
|
<svelte:element
|
|
38
38
|
this={as}
|
|
39
|
+
{...attributes}
|
|
39
40
|
bind:this={ref}
|
|
40
41
|
aria-hidden="true"
|
|
41
42
|
class={['fs-skeleton', animation, shape, classes, { justify }]}
|
|
42
|
-
{...attributes}
|
|
43
43
|
></svelte:element>
|
|
44
44
|
|
|
45
45
|
<style>
|
|
@@ -50,38 +50,41 @@ Set the `disabled` prop to prevent interaction with the slider.
|
|
|
50
50
|
<Slider value={30} disabled />
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
The root is the control element. HTML attributes, class and ref apply to that element. There is no separate wrapper API.
|
|
54
|
+
|
|
53
55
|
## Component Props
|
|
54
56
|
|
|
55
57
|
<!-- DO NOT EDIT THIS SECTION (propsmith generated) -->
|
|
56
58
|
<!-- props:SliderProps -->
|
|
57
59
|
|
|
58
|
-
| Name
|
|
59
|
-
|
|
|
60
|
-
| `value` _bindable_
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `ref` _bindable_
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
|
|
|
60
|
+
| Name | Type | Default | Description |
|
|
61
|
+
| -------------------------------------------- | --------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
62
|
+
| `value` _bindable_ | `number` | `0` | The current value of the slider. |
|
|
63
|
+
| `defaultValue` | `number` | `min` | The value a form reset returns the slider to. A range input without one would fall back to an empty value. |
|
|
64
|
+
| `min` | `number` | `0` | The minimum value of the slider. |
|
|
65
|
+
| `max` | `number` | `100` | The maximum value of the slider. |
|
|
66
|
+
| `step` | `number` | `1` | How much the value moves on every step. |
|
|
67
|
+
| `ticks` | `number[]` | `[]` | The values the tick marks are drawn at. |
|
|
68
|
+
| `tickPlacement` | `'around'` | `'before'` | `'after'` | `'around'` | Where the tick marks sit relative to the rail. |
|
|
69
|
+
| `prefix` | `string` | `''` | Text prepended to the value in the tooltip. |
|
|
70
|
+
| `suffix` | `string` | `''` | Text appended to the value in the tooltip. |
|
|
71
|
+
| `track` | `boolean` | `true` | Whether to fill the rail up to the current value. |
|
|
72
|
+
| `orientation` | `'horizontal'` | `'vertical'` | `'horizontal'` | The direction the slider runs in. |
|
|
73
|
+
| `reverse` | `boolean` | `false` | Runs the slider from the maximum to the minimum instead. |
|
|
74
|
+
| `disabled` | `boolean` | `false` | Disables the user interaction. |
|
|
75
|
+
| `sync` | `boolean` | | Snaps the thumb to the pointer as soon as it is pressed, instead of stepping towards it. Without it, a value between two steps is drawn as it is, while the native input, and so the form, holds the nearest step. |
|
|
76
|
+
| `tooltip` | `boolean` | `true` | Whether to show the value in a tooltip while dragging. |
|
|
77
|
+
| `tooltipPlacement` | `Placement` | `'top'` | Where the tooltip is placed relative to the thumb. |
|
|
78
|
+
| `tooltipContent` | `string` | `Snippet` | `Component` | | Custom content for the tooltip, replacing the plain value. |
|
|
79
|
+
| `onChange` | `(value: number) => void` | | Called whenever the value changes. |
|
|
80
|
+
| `ref` _bindable_ | `HTMLInputElement` | `null` | | The DOM reference of the native range input that holds the value and takes the keyboard focus. The other attributes of the slider are applied to it. |
|
|
81
|
+
| `wrapperRef` _bindable_ | `HTMLDivElement` | `null` | | The DOM reference of the element that draws the slider. |
|
|
82
|
+
| `wrapperAttributes` | `HTMLAttributes` | | The attributes to spread on the element that draws the slider. |
|
|
83
|
+
| `thumbRef` _bindable_ | `HTMLElement` | `null` | | The DOM reference of the thumb element. |
|
|
84
|
+
| `tooltipRef` _bindable_ | `HTMLElement` | `null` | | The DOM reference of the tooltip element. |
|
|
85
|
+
| `railRef` _bindable_ | `HTMLElement` | `null` | | The DOM reference of the rail element. |
|
|
86
|
+
| `trackRef` _bindable_ | `HTMLElement` | `null` | | The DOM reference of the track element. |
|
|
87
|
+
| `tickBarRef` _bindable_ | `HTMLElement` | `null` | | The DOM reference of the tick bar element. |
|
|
88
|
+
| `HiddenInputAttributes<HTMLInputAttributes>` | | | |
|
|
86
89
|
|
|
87
90
|
<!-- /props:SliderProps -->
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
</script>
|
|
3
3
|
|
|
4
4
|
<script lang="ts">
|
|
5
|
+
import { claimLabel } from '../label/label-context.js';
|
|
5
6
|
import { untrack } from 'svelte';
|
|
6
7
|
import { watch } from 'runed';
|
|
7
8
|
import { Tooltip } from '../../index.js';
|
|
8
|
-
import {
|
|
9
|
+
import { dispatchFieldEvents, invokeHandlers } from '../../internal/index.js';
|
|
9
10
|
import type { Attachment } from 'svelte/attachments';
|
|
10
11
|
import type { MouseOrTouchEvent, SliderProps } from './types.js';
|
|
11
12
|
|
|
13
|
+
const labelContext = claimLabel(() => id);
|
|
14
|
+
|
|
12
15
|
let {
|
|
13
16
|
value = $bindable(0),
|
|
14
17
|
min = 0,
|
|
@@ -27,15 +30,17 @@
|
|
|
27
30
|
tooltipPlacement = 'top',
|
|
28
31
|
tooltipContent,
|
|
29
32
|
onChange,
|
|
30
|
-
|
|
31
|
-
ref = $bindable(),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
id = labelContext?.fieldId,
|
|
34
|
+
ref = $bindable(null),
|
|
35
|
+
wrapperRef = $bindable(null),
|
|
36
|
+
wrapperAttributes,
|
|
37
|
+
thumbRef = $bindable(null),
|
|
38
|
+
tooltipRef = $bindable(null),
|
|
39
|
+
railRef = $bindable(null),
|
|
40
|
+
trackRef = $bindable(null),
|
|
41
|
+
tickBarRef = $bindable(null),
|
|
42
|
+
defaultValue = min,
|
|
43
|
+
onkeydown,
|
|
39
44
|
...attributes
|
|
40
45
|
}: SliderProps = $props();
|
|
41
46
|
|
|
@@ -63,15 +68,23 @@
|
|
|
63
68
|
}
|
|
64
69
|
);
|
|
65
70
|
|
|
71
|
+
/** A slider that nothing else names falls back to a generic name. */
|
|
72
|
+
const named = $derived(
|
|
73
|
+
!!(attributes['aria-label'] || attributes['aria-labelledby'] || ref?.labels?.length || labelContext)
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
/** A `fieldset` disables the slider without its `disabled` prop, and only the native input knows. */
|
|
77
|
+
const inert = () => disabled || !!ref?.matches(':disabled');
|
|
78
|
+
|
|
66
79
|
let dragging = $state(false);
|
|
67
80
|
let holding = $state(false);
|
|
81
|
+
/** Whether the pointer moved the value since it was pressed, which the release reports as a `change`. */
|
|
82
|
+
let moved = false;
|
|
68
83
|
let thumbClientWidth = $state(20);
|
|
69
84
|
let percentage = $derived(valueToPercentage(value));
|
|
70
85
|
let directionAwareReverse = $derived(
|
|
71
|
-
|
|
72
|
-
?
|
|
73
|
-
? reverse
|
|
74
|
-
: !reverse
|
|
86
|
+
wrapperRef && orientation === 'horizontal' && window.getComputedStyle(wrapperRef).direction === 'rtl'
|
|
87
|
+
? !reverse
|
|
75
88
|
: reverse
|
|
76
89
|
);
|
|
77
90
|
|
|
@@ -80,6 +93,8 @@
|
|
|
80
93
|
}
|
|
81
94
|
|
|
82
95
|
function cancelMove() {
|
|
96
|
+
if (moved) dispatchFieldEvents(ref, ['change']);
|
|
97
|
+
moved = false;
|
|
83
98
|
holding = false;
|
|
84
99
|
dragging = false;
|
|
85
100
|
}
|
|
@@ -92,7 +107,7 @@
|
|
|
92
107
|
}
|
|
93
108
|
|
|
94
109
|
function calculateValue(event: MouseOrTouchEvent) {
|
|
95
|
-
if (
|
|
110
|
+
if (inert() || !railRef) return;
|
|
96
111
|
const { top, bottom, left, right, width, height } = railRef.getBoundingClientRect();
|
|
97
112
|
const percentageX = (event as TouchEvent).touches
|
|
98
113
|
? (event as TouchEvent).touches[0].clientX
|
|
@@ -105,6 +120,8 @@
|
|
|
105
120
|
const startingPos =
|
|
106
121
|
orientation === 'horizontal' ? (directionAwareReverse ? right : left) : directionAwareReverse ? top : bottom;
|
|
107
122
|
const length = orientation === 'horizontal' ? width : height;
|
|
123
|
+
// A rail without length (e.g. a vertical slider in a parent with no height) has no scale to read the pointer on.
|
|
124
|
+
if (!length) return;
|
|
108
125
|
|
|
109
126
|
let nextStep =
|
|
110
127
|
min +
|
|
@@ -117,26 +134,31 @@
|
|
|
117
134
|
) *
|
|
118
135
|
step;
|
|
119
136
|
|
|
137
|
+
nextStep = Math.min(Math.max(nextStep, min), max);
|
|
138
|
+
if (nextStep === value) return;
|
|
139
|
+
|
|
120
140
|
value = nextStep;
|
|
141
|
+
moved = true;
|
|
142
|
+
dispatchFieldEvents(ref, ['input']);
|
|
121
143
|
}
|
|
122
144
|
|
|
145
|
+
/** The arrows follow the direction the slider is drawn in, so they replace the stepping of the native input. */
|
|
123
146
|
function handleArrowKeys(event: KeyboardEvent) {
|
|
124
147
|
const { key } = event;
|
|
148
|
+
const increase = key === 'ArrowRight' || key === 'ArrowUp';
|
|
125
149
|
|
|
126
|
-
if (key
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
} else
|
|
134
|
-
|
|
135
|
-
stepDown();
|
|
136
|
-
} else {
|
|
137
|
-
stepUp();
|
|
138
|
-
}
|
|
150
|
+
if (!increase && key !== 'ArrowLeft' && key !== 'ArrowDown') return;
|
|
151
|
+
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
const previous = value;
|
|
154
|
+
|
|
155
|
+
if (increase !== reverse) {
|
|
156
|
+
stepUp();
|
|
157
|
+
} else {
|
|
158
|
+
stepDown();
|
|
139
159
|
}
|
|
160
|
+
|
|
161
|
+
if (value !== previous) dispatchFieldEvents(ref);
|
|
140
162
|
}
|
|
141
163
|
|
|
142
164
|
function handleTouchStart(event: TouchEvent) {
|
|
@@ -179,7 +201,7 @@
|
|
|
179
201
|
});
|
|
180
202
|
</script>
|
|
181
203
|
|
|
182
|
-
<!--
|
|
204
|
+
<!--
|
|
183
205
|
@component
|
|
184
206
|
A slider allows users to select a value from a continuous or discrete range by moving a thumb along a track. It supports horizontal and vertical orientations, ticks, tooltips, and reverse direction.
|
|
185
207
|
|
|
@@ -192,8 +214,6 @@
|
|
|
192
214
|
<Slider value={50} min={0} max={100} />
|
|
193
215
|
<Slider orientation="vertical" step={10} ticks={[0, 25, 50, 75, 100]} />
|
|
194
216
|
```
|
|
195
|
-
|
|
196
|
-
@status WIP
|
|
197
217
|
-->
|
|
198
218
|
<svelte:window
|
|
199
219
|
onmousemove={handleMove}
|
|
@@ -203,27 +223,34 @@
|
|
|
203
223
|
ontouchcancel={cancelMove}
|
|
204
224
|
/>
|
|
205
225
|
|
|
226
|
+
<!-- The pointer works on the drawing; the keyboard, assistive technologies and forms work on the native input inside the thumb. -->
|
|
206
227
|
<div
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
228
|
+
{...wrapperAttributes}
|
|
229
|
+
class={[
|
|
230
|
+
'fs-slider',
|
|
231
|
+
`orientation-${orientation}`,
|
|
232
|
+
{ disabled },
|
|
233
|
+
directionAwareReverse && 'reverse',
|
|
234
|
+
wrapperAttributes?.class
|
|
235
|
+
]}
|
|
236
|
+
bind:this={wrapperRef}
|
|
237
|
+
ontouchstart={(e) => invokeHandlers(e, [inert()], [handleTouchStart, wrapperAttributes?.ontouchstart])}
|
|
238
|
+
onmousedown={(e) =>
|
|
239
|
+
invokeHandlers(
|
|
240
|
+
e,
|
|
241
|
+
[inert()],
|
|
242
|
+
[
|
|
243
|
+
() => {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
ref?.focus();
|
|
246
|
+
holding = true;
|
|
247
|
+
dragging = true;
|
|
248
|
+
},
|
|
249
|
+
wrapperAttributes?.onmousedown
|
|
250
|
+
]
|
|
251
|
+
)}
|
|
224
252
|
style="--slider-percentage: {percentage}%; --slider-thumb-offset: {thumbClientWidth / 2 -
|
|
225
|
-
linearScale([0, 50], [6, thumbClientWidth / 2])(percentage)}px;"
|
|
226
|
-
{...attributes}
|
|
253
|
+
linearScale([0, 50], [6, thumbClientWidth / 2])(percentage)}px; {wrapperAttributes?.style ?? ''}"
|
|
227
254
|
>
|
|
228
255
|
{#if tooltip && !disabled}
|
|
229
256
|
<Tooltip
|
|
@@ -236,8 +263,8 @@
|
|
|
236
263
|
class="slider-tooltip"
|
|
237
264
|
animationFrame
|
|
238
265
|
>
|
|
239
|
-
{#snippet children(args,
|
|
240
|
-
{@render sliderThumb(args,
|
|
266
|
+
{#snippet children(args, attach)}
|
|
267
|
+
{@render sliderThumb(args, attach)}
|
|
241
268
|
{/snippet}
|
|
242
269
|
</Tooltip>
|
|
243
270
|
{:else}
|
|
@@ -257,17 +284,38 @@
|
|
|
257
284
|
{/each}
|
|
258
285
|
</div>
|
|
259
286
|
{/if}
|
|
260
|
-
<input type="range" hidden {min} {max} {step} {disabled} {value} bind:this={inputRef} />
|
|
261
287
|
</div>
|
|
262
288
|
|
|
263
|
-
{#snippet sliderThumb(
|
|
289
|
+
{#snippet sliderThumb(
|
|
290
|
+
attrs: Record<string, unknown> | undefined = undefined,
|
|
291
|
+
attach: Attachment | undefined = undefined
|
|
292
|
+
)}
|
|
264
293
|
<div
|
|
265
|
-
class="slider-thumb"
|
|
266
294
|
{...attrs}
|
|
267
|
-
{
|
|
295
|
+
class={['slider-thumb', attrs?.class]}
|
|
296
|
+
{@attach attach}
|
|
268
297
|
bind:this={thumbRef}
|
|
269
298
|
bind:clientWidth={thumbClientWidth}
|
|
270
|
-
|
|
299
|
+
>
|
|
300
|
+
<!-- The field: where the thumb is, so its focus and validation message are too. -->
|
|
301
|
+
<input
|
|
302
|
+
{...attributes}
|
|
303
|
+
{id}
|
|
304
|
+
class="native-field"
|
|
305
|
+
type="range"
|
|
306
|
+
min={_range.min}
|
|
307
|
+
max={_range.max}
|
|
308
|
+
step={_range.step}
|
|
309
|
+
{disabled}
|
|
310
|
+
aria-label={named ? attributes['aria-label'] : 'Slider'}
|
|
311
|
+
aria-orientation={orientation}
|
|
312
|
+
aria-valuetext={prefix || suffix ? `${prefix}${value}${suffix}` : attributes['aria-valuetext']}
|
|
313
|
+
{defaultValue}
|
|
314
|
+
bind:value
|
|
315
|
+
bind:this={ref}
|
|
316
|
+
onkeydown={(e) => invokeHandlers(e, [disabled], [handleArrowKeys, onkeydown])}
|
|
317
|
+
/>
|
|
318
|
+
</div>
|
|
271
319
|
{/snippet}
|
|
272
320
|
|
|
273
321
|
<style>
|
|
@@ -280,9 +328,16 @@
|
|
|
280
328
|
min-inline-size: 32px;
|
|
281
329
|
min-block-size: 32px;
|
|
282
330
|
|
|
283
|
-
& :focus-visible {
|
|
284
|
-
outline:
|
|
285
|
-
|
|
331
|
+
& .slider-thumb:has(> .native-field:focus-visible) {
|
|
332
|
+
outline: 0.125rem var(--fs-focus-stroke-outer) solid;
|
|
333
|
+
outline-offset: 0.125rem;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
&:has(.native-field:is(:user-invalid, [aria-invalid='true'])) {
|
|
337
|
+
& .slider-track,
|
|
338
|
+
& .slider-thumb::before {
|
|
339
|
+
background-color: var(--fs-system-critical);
|
|
340
|
+
}
|
|
286
341
|
}
|
|
287
342
|
|
|
288
343
|
&.orientation-horizontal {
|
|
@@ -387,7 +442,7 @@
|
|
|
387
442
|
}
|
|
388
443
|
}
|
|
389
444
|
|
|
390
|
-
|
|
445
|
+
&:is(.disabled, :has(.native-field:disabled)) {
|
|
391
446
|
& .slider-rail {
|
|
392
447
|
background-color: var(--fs-accent-fill-disabled);
|
|
393
448
|
}
|
|
@@ -450,6 +505,16 @@
|
|
|
450
505
|
}
|
|
451
506
|
}
|
|
452
507
|
|
|
508
|
+
.native-field {
|
|
509
|
+
position: absolute;
|
|
510
|
+
inset: 0;
|
|
511
|
+
inline-size: 100%;
|
|
512
|
+
block-size: 100%;
|
|
513
|
+
margin: 0;
|
|
514
|
+
opacity: 0;
|
|
515
|
+
pointer-events: none;
|
|
516
|
+
}
|
|
517
|
+
|
|
453
518
|
.slider-thumb {
|
|
454
519
|
display: flex;
|
|
455
520
|
justify-content: center;
|
|
@@ -11,9 +11,7 @@ import type { SliderProps } from './types.ts';
|
|
|
11
11
|
* <Slider value={50} min={0} max={100} />
|
|
12
12
|
* <Slider orientation="vertical" step={10} ticks={[0, 25, 50, 75, 100]} />
|
|
13
13
|
* ```
|
|
14
|
-
*
|
|
15
|
-
* @status WIP
|
|
16
14
|
*/
|
|
17
|
-
declare const Slider: import("svelte").Component<SliderProps, {}, "ref" | "value" | "
|
|
15
|
+
declare const Slider: import("svelte").Component<SliderProps, {}, "ref" | "value" | "wrapperRef" | "thumbRef" | "tooltipRef" | "railRef" | "trackRef" | "tickBarRef">;
|
|
18
16
|
type Slider = ReturnType<typeof Slider>;
|
|
19
17
|
export default Slider;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Placement } from '@floating-ui/dom';
|
|
2
2
|
import type { Component, Snippet } from 'svelte';
|
|
3
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
4
|
+
import type { HiddenInputAttributes } from '../../internal/index.js';
|
|
4
5
|
/** @propsmith SliderProps */
|
|
5
6
|
export type SliderProps = {
|
|
6
7
|
/** The current value of the slider.
|
|
@@ -8,6 +9,10 @@ export type SliderProps = {
|
|
|
8
9
|
* @bindable
|
|
9
10
|
*/
|
|
10
11
|
value?: number;
|
|
12
|
+
/** The value a form reset returns the slider to. A range input without one would fall back to an empty value.
|
|
13
|
+
* @default min
|
|
14
|
+
*/
|
|
15
|
+
defaultValue?: number;
|
|
11
16
|
/** The minimum value of the slider.
|
|
12
17
|
* @default 0
|
|
13
18
|
*/
|
|
@@ -52,7 +57,7 @@ export type SliderProps = {
|
|
|
52
57
|
* @default false
|
|
53
58
|
*/
|
|
54
59
|
disabled?: boolean;
|
|
55
|
-
/** Snaps the thumb to the pointer as soon as it is pressed, instead of stepping towards it. */
|
|
60
|
+
/** Snaps the thumb to the pointer as soon as it is pressed, instead of stepping towards it. Without it, a value between two steps is drawn as it is, while the native input, and so the form, holds the nearest step. */
|
|
56
61
|
sync?: boolean;
|
|
57
62
|
/** Whether to show the value in a tooltip while dragging.
|
|
58
63
|
* @default true
|
|
@@ -68,35 +73,37 @@ export type SliderProps = {
|
|
|
68
73
|
tooltipContent?: string | Snippet | Component;
|
|
69
74
|
/** Called whenever the value changes. */
|
|
70
75
|
onChange?: (value: number) => void;
|
|
71
|
-
/** The
|
|
72
|
-
class?: string;
|
|
73
|
-
/** The DOM reference of the slider element.
|
|
76
|
+
/** The DOM reference of the native range input that holds the value and takes the keyboard focus. The other attributes of the slider are applied to it.
|
|
74
77
|
* @bindable
|
|
75
78
|
*/
|
|
76
|
-
ref?:
|
|
77
|
-
/** The DOM reference of the
|
|
79
|
+
ref?: HTMLInputElement | null;
|
|
80
|
+
/** The DOM reference of the element that draws the slider.
|
|
78
81
|
* @bindable
|
|
79
82
|
*/
|
|
80
|
-
|
|
83
|
+
wrapperRef?: HTMLDivElement | null;
|
|
84
|
+
/** The attributes to spread on the element that draws the slider.
|
|
85
|
+
* @type HTMLAttributes
|
|
86
|
+
*/
|
|
87
|
+
wrapperAttributes?: HTMLAttributes<HTMLDivElement>;
|
|
81
88
|
/** The DOM reference of the thumb element.
|
|
82
89
|
* @bindable
|
|
83
90
|
*/
|
|
84
|
-
thumbRef?: HTMLElement;
|
|
91
|
+
thumbRef?: HTMLElement | null;
|
|
85
92
|
/** The DOM reference of the tooltip element.
|
|
86
93
|
* @bindable
|
|
87
94
|
*/
|
|
88
|
-
tooltipRef?: HTMLElement;
|
|
95
|
+
tooltipRef?: HTMLElement | null;
|
|
89
96
|
/** The DOM reference of the rail element.
|
|
90
97
|
* @bindable
|
|
91
98
|
*/
|
|
92
|
-
railRef?: HTMLElement;
|
|
99
|
+
railRef?: HTMLElement | null;
|
|
93
100
|
/** The DOM reference of the track element.
|
|
94
101
|
* @bindable
|
|
95
102
|
*/
|
|
96
|
-
trackRef?: HTMLElement;
|
|
103
|
+
trackRef?: HTMLElement | null;
|
|
97
104
|
/** The DOM reference of the tick bar element.
|
|
98
105
|
* @bindable
|
|
99
106
|
*/
|
|
100
|
-
tickBarRef?: HTMLElement;
|
|
101
|
-
} &
|
|
107
|
+
tickBarRef?: HTMLElement | null;
|
|
108
|
+
} & HiddenInputAttributes<HTMLInputAttributes>;
|
|
102
109
|
export type MouseOrTouchEvent = MouseEvent | TouchEvent;
|
|
@@ -20,7 +20,7 @@ A tab strip expects a `value` on every tab and an `activeTab` to match it agains
|
|
|
20
20
|
let activeTab = $state('document');
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
|
-
<TabView bind:activeTab
|
|
23
|
+
<TabView bind:activeTab listAttributes={{ 'aria-label': 'Workspaces' }}>
|
|
24
24
|
<TabViewTab id="tab-document" value="document">Document</TabViewTab>
|
|
25
25
|
<TabViewTab id="tab-mail" value="mail">Mail</TabViewTab>
|
|
26
26
|
</TabView>
|
|
@@ -104,16 +104,16 @@ A disabled tab cannot be selected, and the arrow keys pass over it rather than l
|
|
|
104
104
|
|
|
105
105
|
| Name | Type | Default | Description |
|
|
106
106
|
| -------------------------- | ------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
107
|
-
| `ref` _bindable_ | `HTMLDivElement`
|
|
108
|
-
| `listRef` _bindable_ | `HTMLDivElement`
|
|
109
|
-
| `
|
|
107
|
+
| `ref` _bindable_ | `HTMLDivElement` | `null` | | The DOM reference of the element wrapping the strip. |
|
|
108
|
+
| `listRef` _bindable_ | `HTMLDivElement` | `null` | | The DOM reference of the tab list. |
|
|
109
|
+
| `listAttributes` | `HTMLAttributes` | | The Attributes to spread on the tab list element, where the `tablist` role and its label belong. |
|
|
110
110
|
| `activeTab` _bindable_ | `string` | | The value of the selected tab. |
|
|
111
111
|
| `onTabChange` | `(event: Event, value: string) => void` | | Fired when the selected tab changes. |
|
|
112
112
|
| `closable` | `boolean` | `false` | Every tab shows a close button, unless the tab opts out of it. |
|
|
113
113
|
| `onTabClose` | `(event: Event, value: string) => void` | | Fired when a tab asks to be closed. Removing the tab is left to the consumer. |
|
|
114
114
|
| `showNewTabButton` | `boolean` | `false` | Shows the button that adds a new tab at the end of the strip. |
|
|
115
115
|
| `onNewTab` | `(event: MouseEvent) => void` | | Fired when the new tab button is activated. |
|
|
116
|
-
| `
|
|
116
|
+
| `newTabButtonAttributes` | `HTMLButtonAttributes` | | The props to spread on the new tab button. |
|
|
117
117
|
| `tabWidthMode` | `'equal'` | `'size-to-content'` | `'compact'` | `'equal'` | How the tabs take their width: sharing the strip evenly, sizing to their own content, or shrinking to the icon of every tab but the selected one. |
|
|
118
118
|
| `disableTabspot` | `boolean` | `false` | Opts the strip out of the tabspot focus management, to wire your own. |
|
|
119
119
|
| Element Attributes (`div`) | | | |
|
|
@@ -127,7 +127,7 @@ A disabled tab cannot be selected, and the arrow keys pass over it rather than l
|
|
|
127
127
|
|
|
128
128
|
| Name | Type | Default | Description |
|
|
129
129
|
| -------------------------- | --------------------------------------- | ------- | --------------------------------------------------------------------------------------- |
|
|
130
|
-
| `ref` _bindable_ | `HTMLDivElement`
|
|
130
|
+
| `ref` _bindable_ | `HTMLDivElement` | `null` | | The DOM reference of the tab element. |
|
|
131
131
|
| `value` | `string` | | The value that identifies the tab. Defaults to a generated id. |
|
|
132
132
|
| `icon` | `Snippet` | `Component` | | The icon to display before the label. |
|
|
133
133
|
| `closable` | `boolean` | | Shows the close button of the tab. Falls back to the `closable` of the strip. |
|
|
@@ -143,4 +143,4 @@ The strip is a single tab stop. `ArrowLeft` and `ArrowRight` walk the tabs, `Hom
|
|
|
143
143
|
|
|
144
144
|
## Accessibility
|
|
145
145
|
|
|
146
|
-
The strip renders a `tablist` and every tab a `tab`, so give the list a name through the `aria-label` you pass in `
|
|
146
|
+
The strip renders a `tablist` and every tab a `tab`, so give the list a name through the `aria-label` you pass in `listAttributes`. Since you render what a tab opens, give that element a `tabpanel` role and point its `aria-labelledby` at the `id` of its tab.
|