@human-kit/ui 1.0.0-beta.0 → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -16
- package/dist/FOCUS_STATE_CONTRACT.md +18 -4
- package/dist/FOCUS_STATE_REVIEW_TEMPLATE.md +8 -8
- package/dist/accordion/README.md +3 -3
- package/dist/accordion/root/accordion-root.svelte +15 -3
- package/dist/accordion/root/context.svelte.js +4 -4
- package/dist/accordion/types.d.ts +40 -19
- package/dist/autocomplete/README.md +6 -7
- package/dist/autocomplete/empty/autocomplete-empty.svelte +1 -1
- package/dist/autocomplete/empty/autocomplete-empty.svelte.d.ts +1 -1
- package/dist/autocomplete/input/autocomplete-input.svelte +3 -3
- package/dist/autocomplete/input/autocomplete-input.svelte.d.ts +3 -3
- package/dist/autocomplete/item/autocomplete-item.svelte +10 -0
- package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte +2 -2
- package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte.d.ts +2 -2
- package/dist/autocomplete/list/autocomplete-list.svelte +2 -2
- package/dist/autocomplete/list/autocomplete-list.svelte.d.ts +11 -3
- package/dist/autocomplete/root/autocomplete.svelte +7 -7
- package/dist/autocomplete/root/autocomplete.svelte.d.ts +7 -7
- package/dist/autocomplete/status/autocomplete-status.svelte +1 -1
- package/dist/autocomplete/status/autocomplete-status.svelte.d.ts +1 -1
- package/dist/avatar/README.md +52 -0
- package/dist/avatar/count/avatar-count.svelte +56 -0
- package/dist/avatar/count/avatar-count.svelte.d.ts +4 -0
- package/dist/avatar/fallback/avatar-fallback.svelte +67 -0
- package/dist/avatar/fallback/avatar-fallback.svelte.d.ts +4 -0
- package/dist/avatar/group/avatar-group.svelte +65 -0
- package/dist/avatar/group/avatar-group.svelte.d.ts +4 -0
- package/dist/avatar/group/context.d.ts +15 -0
- package/dist/avatar/group/context.js +15 -0
- package/dist/avatar/image/avatar-image.svelte +104 -0
- package/dist/avatar/image/avatar-image.svelte.d.ts +4 -0
- package/dist/avatar/index.d.ts +22 -0
- package/dist/avatar/index.js +10 -0
- package/dist/avatar/index.parts.d.ts +5 -0
- package/dist/avatar/index.parts.js +5 -0
- package/dist/avatar/root/avatar-root.svelte +79 -0
- package/dist/avatar/root/avatar-root.svelte.d.ts +4 -0
- package/dist/avatar/root/context.d.ts +14 -0
- package/dist/avatar/root/context.js +15 -0
- package/dist/avatar/types.d.ts +84 -0
- package/dist/avatar/types.js +1 -0
- package/dist/breadcrumbs/README.md +65 -0
- package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte +62 -0
- package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte.d.ts +4 -0
- package/dist/breadcrumbs/index.d.ts +23 -0
- package/dist/breadcrumbs/index.js +10 -0
- package/dist/breadcrumbs/index.parts.d.ts +6 -0
- package/dist/breadcrumbs/index.parts.js +6 -0
- package/dist/breadcrumbs/item/breadcrumbs-item.svelte +42 -0
- package/dist/breadcrumbs/item/breadcrumbs-item.svelte.d.ts +4 -0
- package/dist/breadcrumbs/link/breadcrumbs-link.svelte +47 -0
- package/dist/breadcrumbs/link/breadcrumbs-link.svelte.d.ts +4 -0
- package/dist/breadcrumbs/list/breadcrumbs-list.svelte +31 -0
- package/dist/breadcrumbs/list/breadcrumbs-list.svelte.d.ts +4 -0
- package/dist/breadcrumbs/root/breadcrumbs-root.svelte +112 -0
- package/dist/breadcrumbs/root/breadcrumbs-root.svelte.d.ts +4 -0
- package/dist/breadcrumbs/root/context.d.ts +19 -0
- package/dist/breadcrumbs/root/context.js +15 -0
- package/dist/breadcrumbs/separator/breadcrumbs-separator.svelte +35 -0
- package/dist/breadcrumbs/separator/breadcrumbs-separator.svelte.d.ts +4 -0
- package/dist/breadcrumbs/types.d.ts +80 -0
- package/dist/breadcrumbs/types.js +1 -0
- package/dist/button/README.md +1 -1
- package/dist/button/root/button-root.svelte +37 -7
- package/dist/button/root/button-root.svelte.d.ts +19 -4
- package/dist/calendar/README.md +3 -3
- package/dist/calendar/body-cell/calendar-body-cell.svelte +7 -0
- package/dist/calendar/grid-header/calendar-grid-header.svelte +3 -4
- package/dist/calendar/grid-header/calendar-grid-header.svelte.d.ts +3 -4
- package/dist/calendar/root/calendar-root.svelte +8 -2
- package/dist/calendar/root/calendar-root.svelte.d.ts +8 -2
- package/dist/calendar/root/context.svelte.js +8 -2
- package/dist/calendar/trigger-next/README.md +1 -1
- package/dist/calendar/trigger-previous/README.md +1 -1
- package/dist/checkbox/README.md +1 -1
- package/dist/checkbox/indicator/README.md +1 -1
- package/dist/checkbox/indicator/checkbox-indicator.svelte +1 -0
- package/dist/checkbox/indicator/checkbox-indicator.svelte.d.ts +1 -0
- package/dist/checkbox/root/README.md +2 -2
- package/dist/checkbox/root/checkbox-root.svelte +133 -38
- package/dist/checkbox/root/checkbox-root.svelte.d.ts +21 -1
- package/dist/checkbox-group/README.md +95 -0
- package/dist/checkbox-group/index.d.ts +15 -0
- package/dist/checkbox-group/index.js +6 -0
- package/dist/checkbox-group/index.parts.d.ts +4 -0
- package/dist/checkbox-group/index.parts.js +7 -0
- package/dist/checkbox-group/label/checkbox-group-label.svelte +36 -0
- package/dist/checkbox-group/label/checkbox-group-label.svelte.d.ts +4 -0
- package/dist/checkbox-group/root/checkbox-group-root.svelte +118 -0
- package/dist/checkbox-group/root/checkbox-group-root.svelte.d.ts +4 -0
- package/dist/checkbox-group/root/context.svelte.d.ts +52 -0
- package/dist/checkbox-group/root/context.svelte.js +251 -0
- package/dist/checkbox-group/types.d.ts +57 -0
- package/dist/checkbox-group/types.js +1 -0
- package/dist/clock/README.md +3 -3
- package/dist/clock/axis/README.md +1 -1
- package/dist/clock/root/README.md +1 -1
- package/dist/clock/root/create-time-selection-state.svelte.d.ts +5 -0
- package/dist/clock/root/create-time-selection-state.svelte.js +113 -10
- package/dist/clock/root/wheel-options.d.ts +7 -3
- package/dist/clock/root/wheel-options.js +7 -15
- package/dist/clock/wheel-column/clock-wheel-column.svelte +10 -2
- package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +2 -1
- package/dist/collapsible/README.md +3 -3
- package/dist/collapsible/root/collapsible-root.svelte +9 -4
- package/dist/collapsible/types.d.ts +13 -1
- package/dist/combobox/README.md +2 -2
- package/dist/combobox/button/README.md +6 -6
- package/dist/combobox/input/README.md +1 -1
- package/dist/combobox/input/combobox-input.svelte +15 -4
- package/dist/combobox/input/combobox-input.svelte.d.ts +3 -3
- package/dist/combobox/item/combobox-listboxitem.svelte +4 -2
- package/dist/combobox/item/combobox-listboxitem.svelte.d.ts +4 -2
- package/dist/combobox/item-indicator/README.md +1 -1
- package/dist/combobox/item-indicator/combobox-item-indicator.svelte +2 -2
- package/dist/combobox/item-indicator/combobox-item-indicator.svelte.d.ts +2 -2
- package/dist/combobox/list/combobox-listbox.svelte +98 -3
- package/dist/combobox/list/combobox-listbox.svelte.d.ts +28 -3
- package/dist/combobox/popover/README.md +1 -1
- package/dist/combobox/popover/combobox-popover.svelte +4 -56
- package/dist/combobox/root/README.md +24 -24
- package/dist/combobox/root/combobox.svelte +138 -56
- package/dist/combobox/root/combobox.svelte.d.ts +31 -11
- package/dist/combobox/root/context.d.ts +12 -0
- package/dist/combobox/status/README.md +3 -3
- package/dist/combobox/status/combobox-status.svelte +1 -1
- package/dist/combobox/status/combobox-status.svelte.d.ts +1 -1
- package/dist/combobox/tag/README.md +1 -1
- package/dist/combobox/tag/combobox-tag.svelte +1 -1
- package/dist/combobox/tag/combobox-tag.svelte.d.ts +1 -1
- package/dist/combobox/tag-remove/README.md +1 -1
- package/dist/combobox/tag-remove/combobox-tag-remove.svelte +14 -3
- package/dist/combobox/tag-remove/combobox-tag-remove.svelte.d.ts +7 -1
- package/dist/combobox/tags/README.md +1 -1
- package/dist/combobox/tags/combobox-tags.svelte +15 -12
- package/dist/combobox/tags/combobox-tags.svelte.d.ts +12 -10
- package/dist/combobox/trigger/README.md +7 -7
- package/dist/combobox/trigger/combobox-trigger.svelte +4 -1
- package/dist/datepicker/README.md +5 -4
- package/dist/datepicker/input/date-picker-input.svelte +3 -4
- package/dist/datepicker/input/date-picker-input.svelte.d.ts +3 -4
- package/dist/datepicker/root/date-picker-root.svelte +38 -2
- package/dist/datepicker/root/date-picker-root.svelte.d.ts +2 -0
- package/dist/datepicker/root/draft-evaluation.d.ts +7 -0
- package/dist/datepicker/root/draft-evaluation.js +2 -2
- package/dist/datepicker/trigger/README.md +1 -1
- package/dist/daterangepicker/README.md +3 -3
- package/dist/daterangepicker/input/date-range-picker-input.svelte +3 -4
- package/dist/daterangepicker/input/date-range-picker-input.svelte.d.ts +3 -4
- package/dist/daterangepicker/root/date-range-picker-root.svelte +19 -1
- package/dist/daterangepicker/root/date-range-picker-root.svelte.d.ts +2 -0
- package/dist/dialog/README.md +10 -2
- package/dist/dialog/close/dialog-close.svelte +57 -0
- package/dist/dialog/close/dialog-close.svelte.d.ts +19 -0
- package/dist/dialog/content/dialog-content.svelte +6 -4
- package/dist/dialog/content/dialog-content.svelte.d.ts +4 -4
- package/dist/dialog/description/dialog-description.svelte +46 -0
- package/dist/dialog/description/dialog-description.svelte.d.ts +20 -0
- package/dist/dialog/index.d.ts +9 -0
- package/dist/dialog/index.js +3 -0
- package/dist/dialog/index.parts.d.ts +3 -0
- package/dist/dialog/index.parts.js +3 -0
- package/dist/dialog/overlay/dialog-overlay.svelte +1 -1
- package/dist/dialog/overlay/dialog-overlay.svelte.d.ts +1 -1
- package/dist/dialog/portal/dialog-portal.svelte +1 -1
- package/dist/dialog/portal/dialog-portal.svelte.d.ts +1 -1
- package/dist/dialog/root/README.md +1 -1
- package/dist/dialog/root/context.d.ts +8 -0
- package/dist/dialog/root/dialog-root.svelte +100 -20
- package/dist/dialog/root/dialog-root.svelte.d.ts +15 -6
- package/dist/dialog/root/dialog-stack.d.ts +6 -22
- package/dist/dialog/root/dialog-stack.js +4 -33
- package/dist/dialog/title/dialog-title.svelte +43 -0
- package/dist/dialog/title/dialog-title.svelte.d.ts +21 -0
- package/dist/dialog/trigger/README.md +1 -1
- package/dist/drawer/README.md +111 -0
- package/dist/drawer/body/drawer-body.svelte +47 -0
- package/dist/drawer/body/drawer-body.svelte.d.ts +32 -0
- package/dist/drawer/close/drawer-close.svelte +52 -0
- package/dist/drawer/close/drawer-close.svelte.d.ts +20 -0
- package/dist/drawer/content/drawer-content.svelte +600 -0
- package/dist/drawer/content/drawer-content.svelte.d.ts +31 -0
- package/dist/drawer/description/drawer-description.svelte +40 -0
- package/dist/drawer/description/drawer-description.svelte.d.ts +20 -0
- package/dist/drawer/indent/drawer-indent-background.svelte +36 -0
- package/dist/drawer/indent/drawer-indent-background.svelte.d.ts +17 -0
- package/dist/drawer/indent/drawer-indent.svelte +59 -0
- package/dist/drawer/indent/drawer-indent.svelte.d.ts +32 -0
- package/dist/drawer/index.d.ts +49 -0
- package/dist/drawer/index.js +25 -0
- package/dist/drawer/index.parts.d.ts +14 -0
- package/dist/drawer/index.parts.js +15 -0
- package/dist/drawer/overlay/drawer-overlay.svelte +67 -0
- package/dist/drawer/overlay/drawer-overlay.svelte.d.ts +12 -0
- package/dist/drawer/portal/drawer-portal.svelte +57 -0
- package/dist/drawer/portal/drawer-portal.svelte.d.ts +13 -0
- package/dist/drawer/root/context.d.ts +81 -0
- package/dist/drawer/root/context.js +20 -0
- package/dist/drawer/root/drawer-root.svelte +348 -0
- package/dist/drawer/root/drawer-root.svelte.d.ts +79 -0
- package/dist/drawer/root/drawer-stack.svelte.d.ts +73 -0
- package/dist/drawer/root/drawer-stack.svelte.js +113 -0
- package/dist/drawer/root/handle.svelte.d.ts +39 -0
- package/dist/drawer/root/handle.svelte.js +64 -0
- package/dist/drawer/root/keyboard-context.d.ts +13 -0
- package/dist/drawer/root/keyboard-context.js +8 -0
- package/dist/drawer/root/presence-context.d.ts +22 -0
- package/dist/drawer/root/presence-context.js +8 -0
- package/dist/drawer/root/snap-points.d.ts +68 -0
- package/dist/drawer/root/snap-points.js +120 -0
- package/dist/drawer/root/starting-style.svelte.d.ts +18 -0
- package/dist/drawer/root/starting-style.svelte.js +38 -0
- package/dist/drawer/root/types.d.ts +36 -0
- package/dist/drawer/root/types.js +1 -0
- package/dist/drawer/root/viewport-context.d.ts +2 -0
- package/dist/drawer/root/viewport-context.js +16 -0
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte +143 -0
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte.d.ts +22 -0
- package/dist/drawer/title/drawer-title.svelte +37 -0
- package/dist/drawer/title/drawer-title.svelte.d.ts +21 -0
- package/dist/drawer/trigger/drawer-trigger.svelte +90 -0
- package/dist/drawer/trigger/drawer-trigger.svelte.d.ts +41 -0
- package/dist/drawer/viewport/drawer-viewport.svelte +69 -0
- package/dist/drawer/viewport/drawer-viewport.svelte.d.ts +15 -0
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte +88 -0
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte.d.ts +29 -0
- package/dist/dropzone/README.md +4 -6
- package/dist/hooks/use-virtual-focus.svelte.d.ts +9 -0
- package/dist/hooks/use-virtual-focus.svelte.js +7 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.js +23 -0
- package/dist/input/input.svelte +6 -6
- package/dist/input/input.svelte.d.ts +6 -6
- package/dist/internal/environment.d.ts +11 -0
- package/dist/internal/environment.js +14 -0
- package/dist/internal/localized-strings.d.ts +152 -0
- package/dist/internal/localized-strings.js +152 -0
- package/dist/internal/number-precision.d.ts +9 -0
- package/dist/internal/number-precision.js +27 -0
- package/dist/listbox/README.md +20 -1
- package/dist/listbox/item/listbox-item.svelte +43 -18
- package/dist/listbox/item/listbox-item.svelte.d.ts +24 -15
- package/dist/listbox/root/README.md +1 -1
- package/dist/listbox/root/context.d.ts +56 -1
- package/dist/listbox/root/context.js +118 -1
- package/dist/listbox/root/listbox.svelte +400 -27
- package/dist/listbox/root/listbox.svelte.d.ts +73 -16
- package/dist/locale-provider/README.md +1 -6
- package/dist/menu/README.md +41 -4
- package/dist/menu/content/menu-content.svelte +31 -14
- package/dist/menu/content/menu-content.svelte.d.ts +14 -9
- package/dist/menu/context-trigger/menu-context-trigger.svelte +194 -0
- package/dist/menu/context-trigger/menu-context-trigger.svelte.d.ts +35 -0
- package/dist/menu/group/menu-group-label.svelte +1 -1
- package/dist/menu/group/menu-group-label.svelte.d.ts +1 -1
- package/dist/menu/index.d.ts +4 -1
- package/dist/menu/index.js +1 -0
- package/dist/menu/index.parts.d.ts +1 -0
- package/dist/menu/index.parts.js +1 -0
- package/dist/menu/item/menu-item.svelte +11 -8
- package/dist/menu/item/menu-item.svelte.d.ts +11 -8
- package/dist/menu/overlay/menu-overlay.svelte +2 -2
- package/dist/menu/overlay/menu-overlay.svelte.d.ts +1 -1
- package/dist/menu/root/context.d.ts +24 -3
- package/dist/menu/root/focus-state.d.ts +2 -2
- package/dist/menu/root/focus-state.js +8 -32
- package/dist/menu/root/menu-root.svelte +14 -8
- package/dist/menu/root/menu-root.svelte.d.ts +14 -8
- package/dist/menu/root/menu-state.svelte.d.ts +1 -1
- package/dist/menu/root/menu-state.svelte.js +24 -1
- package/dist/menu/separator/menu-separator.svelte +1 -1
- package/dist/menu/separator/menu-separator.svelte.d.ts +1 -1
- package/dist/menu/submenu/menu-submenu-root.svelte +10 -7
- package/dist/menu/submenu/menu-submenu-root.svelte.d.ts +10 -7
- package/dist/numberfield/root/README.md +1 -1
- package/dist/numberfield/root/number-field-root.svelte +2 -1
- package/dist/numberfield/root/number-utils.js +1 -20
- package/dist/numberfield/scrub-area-cursor/README.md +1 -1
- package/dist/popover/README.md +1 -1
- package/dist/popover/content/popover-content.svelte +22 -16
- package/dist/popover/content/popover-content.svelte.d.ts +19 -14
- package/dist/popover/overlay/popover-overlay.svelte +2 -2
- package/dist/popover/overlay/popover-overlay.svelte.d.ts +1 -1
- package/dist/popover/root/README.md +1 -1
- package/dist/popover/root/focus-state.d.ts +2 -2
- package/dist/popover/root/focus-state.js +7 -34
- package/dist/popover/root/popover-root.svelte +29 -14
- package/dist/popover/root/popover-root.svelte.d.ts +16 -5
- package/dist/popover/trigger/README.md +1 -1
- package/dist/primitives/aria-hide-outside.d.ts +13 -0
- package/dist/primitives/aria-hide-outside.js +7 -1
- package/dist/primitives/contain-wheel.d.ts +9 -0
- package/dist/primitives/contain-wheel.js +41 -0
- package/dist/primitives/floating.d.ts +49 -8
- package/dist/primitives/floating.js +75 -7
- package/dist/primitives/focus-trap.d.ts +2 -0
- package/dist/primitives/focus-trap.js +7 -1
- package/dist/primitives/focus-visible.svelte.d.ts +14 -0
- package/dist/primitives/focus-visible.svelte.js +19 -0
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.js +3 -0
- package/dist/primitives/input-modality.d.ts +7 -0
- package/dist/primitives/input-modality.js +32 -5
- package/dist/primitives/keyboard-navigation.d.ts +29 -5
- package/dist/primitives/keyboard-navigation.js +27 -17
- package/dist/primitives/layer-stack.d.ts +29 -0
- package/dist/primitives/layer-stack.js +35 -0
- package/dist/primitives/list-virtualizer.d.ts +75 -0
- package/dist/primitives/list-virtualizer.js +59 -0
- package/dist/primitives/long-press.d.ts +59 -0
- package/dist/primitives/long-press.js +142 -0
- package/dist/primitives/presence.svelte.js +6 -1
- package/dist/primitives/scroll-lock.d.ts +47 -3
- package/dist/primitives/scroll-lock.js +191 -9
- package/dist/primitives/swipe-gesture.d.ts +126 -0
- package/dist/primitives/swipe-gesture.js +351 -0
- package/dist/primitives/text.d.ts +8 -0
- package/dist/primitives/text.js +13 -0
- package/dist/primitives/trigger-focus-state.d.ts +29 -0
- package/dist/primitives/trigger-focus-state.js +57 -0
- package/dist/progress/README.md +54 -0
- package/dist/progress/index.d.ts +21 -0
- package/dist/progress/index.js +9 -0
- package/dist/progress/index.parts.d.ts +5 -0
- package/dist/progress/index.parts.js +5 -0
- package/dist/progress/indicator/progress-indicator.svelte +37 -0
- package/dist/progress/indicator/progress-indicator.svelte.d.ts +4 -0
- package/dist/progress/label/progress-label.svelte +34 -0
- package/dist/progress/label/progress-label.svelte.d.ts +4 -0
- package/dist/progress/root/context.d.ts +26 -0
- package/dist/progress/root/context.js +15 -0
- package/dist/progress/root/progress-root.svelte +136 -0
- package/dist/progress/root/progress-root.svelte.d.ts +4 -0
- package/dist/progress/root/progress-utils.d.ts +12 -0
- package/dist/progress/root/progress-utils.js +41 -0
- package/dist/progress/track/progress-track.svelte +27 -0
- package/dist/progress/track/progress-track.svelte.d.ts +4 -0
- package/dist/progress/types.d.ts +81 -0
- package/dist/progress/types.js +1 -0
- package/dist/progress/value/progress-value.svelte +36 -0
- package/dist/progress/value/progress-value.svelte.d.ts +4 -0
- package/dist/radio-group/README.md +103 -0
- package/dist/radio-group/index.d.ts +18 -0
- package/dist/radio-group/index.js +9 -0
- package/dist/radio-group/index.parts.d.ts +4 -0
- package/dist/radio-group/index.parts.js +4 -0
- package/dist/radio-group/indicator/radio-group-indicator.svelte +43 -0
- package/dist/radio-group/indicator/radio-group-indicator.svelte.d.ts +12 -0
- package/dist/radio-group/item/context.d.ts +18 -0
- package/dist/radio-group/item/context.js +15 -0
- package/dist/radio-group/item/radio-group-item.svelte +377 -0
- package/dist/radio-group/item/radio-group-item.svelte.d.ts +35 -0
- package/dist/radio-group/label/radio-group-label.svelte +37 -0
- package/dist/radio-group/label/radio-group-label.svelte.d.ts +4 -0
- package/dist/radio-group/root/context.svelte.d.ts +57 -0
- package/dist/radio-group/root/context.svelte.js +284 -0
- package/dist/radio-group/root/radio-group-root.svelte +193 -0
- package/dist/radio-group/root/radio-group-root.svelte.d.ts +4 -0
- package/dist/radio-group/types.d.ts +50 -0
- package/dist/radio-group/types.js +1 -0
- package/dist/select/README.md +129 -0
- package/dist/select/index.d.ts +30 -0
- package/dist/select/index.js +16 -0
- package/dist/select/index.parts.d.ts +8 -0
- package/dist/select/index.parts.js +9 -0
- package/dist/select/item/select-item.svelte +68 -0
- package/dist/select/item/select-item.svelte.d.ts +10 -0
- package/dist/select/item-indicator/select-item-indicator.svelte +55 -0
- package/dist/select/item-indicator/select-item-indicator.svelte.d.ts +4 -0
- package/dist/select/label/select-label.svelte +46 -0
- package/dist/select/label/select-label.svelte.d.ts +4 -0
- package/dist/select/list/select-list.svelte +241 -0
- package/dist/select/list/select-list.svelte.d.ts +62 -0
- package/dist/select/popover/select-popover.svelte +80 -0
- package/dist/select/popover/select-popover.svelte.d.ts +9 -0
- package/dist/select/root/context.d.ts +106 -0
- package/dist/select/root/context.js +22 -0
- package/dist/select/root/select-root.svelte +544 -0
- package/dist/select/root/select-root.svelte.d.ts +25 -0
- package/dist/select/trigger/select-trigger.svelte +192 -0
- package/dist/select/trigger/select-trigger.svelte.d.ts +4 -0
- package/dist/select/types.d.ts +133 -0
- package/dist/select/types.js +1 -0
- package/dist/select/value/select-value.svelte +61 -0
- package/dist/select/value/select-value.svelte.d.ts +4 -0
- package/dist/separator/README.md +35 -0
- package/dist/separator/index.d.ts +7 -0
- package/dist/separator/index.js +3 -0
- package/dist/separator/separator.svelte +254 -0
- package/dist/separator/separator.svelte.d.ts +45 -0
- package/dist/separator/types.d.ts +1 -0
- package/dist/separator/types.js +1 -0
- package/dist/slider/README.md +61 -0
- package/dist/slider/fill/slider-fill.svelte +40 -0
- package/dist/slider/fill/slider-fill.svelte.d.ts +4 -0
- package/dist/slider/index.d.ts +9 -0
- package/dist/slider/index.js +8 -0
- package/dist/slider/index.parts.d.ts +6 -0
- package/dist/slider/index.parts.js +6 -0
- package/dist/slider/label/slider-label.svelte +44 -0
- package/dist/slider/label/slider-label.svelte.d.ts +4 -0
- package/dist/slider/output/slider-output.svelte +46 -0
- package/dist/slider/output/slider-output.svelte.d.ts +4 -0
- package/dist/slider/root/context.d.ts +106 -0
- package/dist/slider/root/context.js +15 -0
- package/dist/slider/root/slider-root.svelte +545 -0
- package/dist/slider/root/slider-root.svelte.d.ts +4 -0
- package/dist/slider/root/slider-utils.d.ts +57 -0
- package/dist/slider/root/slider-utils.js +88 -0
- package/dist/slider/thumb/slider-thumb.svelte +276 -0
- package/dist/slider/thumb/slider-thumb.svelte.d.ts +4 -0
- package/dist/slider/track/slider-track.svelte +60 -0
- package/dist/slider/track/slider-track.svelte.d.ts +4 -0
- package/dist/slider/types.d.ts +144 -0
- package/dist/slider/types.js +1 -0
- package/dist/switch/root/README.md +2 -2
- package/dist/switch/root/switch-root.svelte +49 -21
- package/dist/switch/root/switch-root.svelte.d.ts +26 -14
- package/dist/switch/thumb/switch-thumb.svelte +1 -1
- package/dist/switch/thumb/switch-thumb.svelte.d.ts +1 -1
- package/dist/table/README.md +16 -9
- package/dist/table/body/table-body.svelte +84 -9
- package/dist/table/cell/table-cell.svelte +27 -10
- package/dist/table/checkbox/table-checkbox.svelte +3 -0
- package/dist/table/checkbox-indicator/README.md +1 -1
- package/dist/table/column/table-column.svelte +5 -1
- package/dist/table/column-header-cell/table-column-header-cell.svelte +24 -0
- package/dist/table/column-resizer/README.md +2 -2
- package/dist/table/column-resizer/table-column-resizer.svelte +1 -5
- package/dist/table/index.d.ts +1 -1
- package/dist/table/index.js +1 -1
- package/dist/table/interactive-cell/table-interactive-cell.svelte +26 -10
- package/dist/table/root/README.md +1 -1
- package/dist/table/root/context.svelte.d.ts +17 -0
- package/dist/table/root/context.svelte.js +212 -66
- package/dist/table/root/table-root.svelte +36 -6
- package/dist/table/row/table-row.svelte +14 -14
- package/dist/table/sort-trigger/README.md +1 -1
- package/dist/table/sort-trigger/table-sort-trigger.svelte +5 -1
- package/dist/table/types.d.ts +32 -14
- package/dist/tabs/root/tabs-root.svelte +20 -6
- package/dist/tabs/types.d.ts +9 -0
- package/dist/timepicker/README.md +3 -2
- package/dist/timepicker/input/README.md +1 -1
- package/dist/timepicker/input/time-picker-input.svelte +66 -5
- package/dist/timepicker/input/time-picker-input.svelte.d.ts +18 -1
- package/dist/timepicker/root/README.md +1 -1
- package/dist/timepicker/root/time-picker-root.svelte +11 -0
- package/dist/timepicker/root/time-picker-root.svelte.d.ts +2 -0
- package/dist/timepicker/trigger/README.md +1 -1
- package/dist/toast/README.md +75 -0
- package/dist/toast/action/toast-action.svelte +42 -0
- package/dist/toast/action/toast-action.svelte.d.ts +4 -0
- package/dist/toast/close/toast-close.svelte +41 -0
- package/dist/toast/close/toast-close.svelte.d.ts +4 -0
- package/dist/toast/content/toast-content.svelte +24 -0
- package/dist/toast/content/toast-content.svelte.d.ts +4 -0
- package/dist/toast/description/toast-description.svelte +41 -0
- package/dist/toast/description/toast-description.svelte.d.ts +4 -0
- package/dist/toast/index.d.ts +34 -0
- package/dist/toast/index.js +15 -0
- package/dist/toast/index.parts.d.ts +9 -0
- package/dist/toast/index.parts.js +9 -0
- package/dist/toast/positioner/toast-positioner.svelte +75 -0
- package/dist/toast/positioner/toast-positioner.svelte.d.ts +4 -0
- package/dist/toast/provider/context.d.ts +36 -0
- package/dist/toast/provider/context.js +22 -0
- package/dist/toast/provider/toast-manager.svelte.d.ts +113 -0
- package/dist/toast/provider/toast-manager.svelte.js +210 -0
- package/dist/toast/provider/toast-provider.svelte +98 -0
- package/dist/toast/provider/toast-provider.svelte.d.ts +4 -0
- package/dist/toast/root/context.d.ts +18 -0
- package/dist/toast/root/context.js +15 -0
- package/dist/toast/root/toast-root.svelte +296 -0
- package/dist/toast/root/toast-root.svelte.d.ts +4 -0
- package/dist/toast/title/toast-title.svelte +38 -0
- package/dist/toast/title/toast-title.svelte.d.ts +4 -0
- package/dist/toast/types.d.ts +100 -0
- package/dist/toast/types.js +1 -0
- package/dist/toast/viewport/toast-viewport.svelte +389 -0
- package/dist/toast/viewport/toast-viewport.svelte.d.ts +4 -0
- package/dist/toggle/README.md +1 -1
- package/dist/toggle/root/toggle-root.svelte +28 -0
- package/dist/toggle/root/toggle-root.svelte.d.ts +19 -0
- package/dist/toggle-group/README.md +12 -4
- package/dist/toggle-group/index.d.ts +2 -0
- package/dist/toggle-group/index.parts.d.ts +1 -0
- package/dist/toggle-group/index.parts.js +4 -0
- package/dist/toggle-group/root/context.svelte.d.ts +1 -1
- package/dist/toggle-group/root/context.svelte.js +24 -8
- package/dist/toggle-group/root/toggle-group-root.svelte +24 -4
- package/dist/toggle-group/root/toggle-group-teardown-order-child.svelte +13 -0
- package/dist/toggle-group/root/toggle-group-teardown-order-child.svelte.d.ts +7 -0
- package/dist/toggle-group/types.d.ts +9 -0
- package/dist/tooltip/README.md +53 -0
- package/dist/tooltip/arrow/tooltip-arrow.svelte +36 -0
- package/dist/tooltip/arrow/tooltip-arrow.svelte.d.ts +4 -0
- package/dist/tooltip/content/tooltip-content.svelte +148 -0
- package/dist/tooltip/content/tooltip-content.svelte.d.ts +4 -0
- package/dist/tooltip/index.d.ts +8 -0
- package/dist/tooltip/index.js +7 -0
- package/dist/tooltip/index.parts.d.ts +5 -0
- package/dist/tooltip/index.parts.js +5 -0
- package/dist/tooltip/provider/tooltip-provider.svelte +36 -0
- package/dist/tooltip/provider/tooltip-provider.svelte.d.ts +4 -0
- package/dist/tooltip/root/context.d.ts +46 -0
- package/dist/tooltip/root/context.js +22 -0
- package/dist/tooltip/root/safe-polygon.d.ts +26 -0
- package/dist/tooltip/root/safe-polygon.js +66 -0
- package/dist/tooltip/root/tooltip-group.d.ts +26 -0
- package/dist/tooltip/root/tooltip-group.js +41 -0
- package/dist/tooltip/root/tooltip-root.svelte +461 -0
- package/dist/tooltip/root/tooltip-root.svelte.d.ts +4 -0
- package/dist/tooltip/trigger/tooltip-trigger.svelte +52 -0
- package/dist/tooltip/trigger/tooltip-trigger.svelte.d.ts +4 -0
- package/dist/tooltip/types.d.ts +105 -0
- package/dist/tooltip/types.js +1 -0
- package/dist/transfer-list/README.md +110 -0
- package/dist/transfer-list/index.d.ts +33 -0
- package/dist/transfer-list/index.js +18 -0
- package/dist/transfer-list/index.parts.d.ts +9 -0
- package/dist/transfer-list/index.parts.js +10 -0
- package/dist/transfer-list/item/transfer-list-item.svelte +74 -0
- package/dist/transfer-list/item/transfer-list-item.svelte.d.ts +35 -0
- package/dist/transfer-list/list/transfer-list-list.svelte +162 -0
- package/dist/transfer-list/list/transfer-list-list.svelte.d.ts +56 -0
- package/dist/transfer-list/list/transfer-list-source.svelte +13 -0
- package/dist/transfer-list/list/transfer-list-source.svelte.d.ts +36 -0
- package/dist/transfer-list/list/transfer-list-target.svelte +14 -0
- package/dist/transfer-list/list/transfer-list-target.svelte.d.ts +36 -0
- package/dist/transfer-list/move/transfer-list-move-all.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-all.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-move-button.svelte +103 -0
- package/dist/transfer-list/move/transfer-list-move-button.svelte.d.ts +25 -0
- package/dist/transfer-list/move/transfer-list-move-down.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-down.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-move-selected.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-selected.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-move-up.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-up.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-reorder-button.svelte +83 -0
- package/dist/transfer-list/move/transfer-list-reorder-button.svelte.d.ts +21 -0
- package/dist/transfer-list/root/context.d.ts +70 -0
- package/dist/transfer-list/root/context.js +24 -0
- package/dist/transfer-list/root/transfer-list-root.svelte +345 -0
- package/dist/transfer-list/root/transfer-list-root.svelte.d.ts +68 -0
- package/dist/transfer-list/root/types.d.ts +22 -0
- package/dist/transfer-list/root/types.js +4 -0
- package/dist/transfer-list/status/transfer-list-status.svelte +70 -0
- package/dist/transfer-list/status/transfer-list-status.svelte.d.ts +15 -0
- package/dist/tree/README.md +3 -3
- package/dist/tree/checkbox-indicator/README.md +1 -1
- package/dist/tree/root/README.md +1 -1
- package/dist/tree/root/context.svelte.js +6 -0
- package/dist/tree/root/tree-root.svelte +22 -8
- package/dist/tree/types.d.ts +23 -1
- package/package.json +282 -224
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack, type Snippet } from 'svelte';
|
|
3
|
+
import { readable } from 'svelte/store';
|
|
4
|
+
import { resolveLocalizedString } from '../../internal/localized-strings';
|
|
5
|
+
import { isRtl } from '../../internal/rtl';
|
|
6
|
+
import { getLocaleContext } from '../../locale-provider/context';
|
|
7
|
+
import { watchFocusVisible } from '../../primitives/focus-visible.svelte';
|
|
8
|
+
import {
|
|
9
|
+
shouldShowFocusVisible,
|
|
10
|
+
trackInteractionModality
|
|
11
|
+
} from '../../primitives/input-modality';
|
|
12
|
+
import { useSliderContext, type SliderChangeDetails } from '../root/context';
|
|
13
|
+
import type { SliderThumbProps, SliderThumbRenderState } from '../types';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Slider.Thumb — the handle of one value.
|
|
17
|
+
*
|
|
18
|
+
* The element the user sees is a `<div>` positioned along the track. Inside it, a native
|
|
19
|
+
* `<input type="range">` fills the thumb, invisible, and it is what has the focus and the ARIA
|
|
20
|
+
* state. The native input gives the role and the value to a screen reader, and it receives
|
|
21
|
+
* the swipe of a mobile screen reader as an `input` event. The keyboard is handled here and
|
|
22
|
+
* not by the input, so that the steps, the large steps and the text direction are the same in
|
|
23
|
+
* every browser.
|
|
24
|
+
*/
|
|
25
|
+
let {
|
|
26
|
+
index: indexProp,
|
|
27
|
+
name,
|
|
28
|
+
'aria-label': ariaLabel,
|
|
29
|
+
'aria-labelledby': ariaLabelledBy,
|
|
30
|
+
children,
|
|
31
|
+
class: className = '',
|
|
32
|
+
element = $bindable<HTMLDivElement | null>(null),
|
|
33
|
+
style,
|
|
34
|
+
onpointerdown,
|
|
35
|
+
...restProps
|
|
36
|
+
}: SliderThumbProps = $props();
|
|
37
|
+
|
|
38
|
+
const ctx = useSliderContext('Slider.Thumb');
|
|
39
|
+
const localeStore = getLocaleContext()?.locale ?? readable<string | undefined>(undefined);
|
|
40
|
+
|
|
41
|
+
let thumbRef: HTMLDivElement | null = $state(null);
|
|
42
|
+
let inputRef: HTMLInputElement | null = $state(null);
|
|
43
|
+
|
|
44
|
+
const registration = ctx.registerThumb({
|
|
45
|
+
index: untrack(() => indexProp),
|
|
46
|
+
inputRef: () => inputRef
|
|
47
|
+
});
|
|
48
|
+
const index = registration.index;
|
|
49
|
+
const inputId = ctx.getThumbInputId(index);
|
|
50
|
+
|
|
51
|
+
$effect(() => {
|
|
52
|
+
element = thumbRef;
|
|
53
|
+
return () => {
|
|
54
|
+
element = null;
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
$effect(() => registration.unregister);
|
|
59
|
+
|
|
60
|
+
const value = $derived(ctx.values[index] ?? ctx.min);
|
|
61
|
+
const percent = $derived(ctx.getPercent(value));
|
|
62
|
+
const text = $derived(ctx.formatValue(value));
|
|
63
|
+
const valueText = $derived(ctx.getValueText(value, index));
|
|
64
|
+
const dragging = $derived(ctx.draggingIndex === index);
|
|
65
|
+
const focused = $derived(ctx.focusedIndex === index);
|
|
66
|
+
const focusVisible = $derived(focused && ctx.isFocusVisible);
|
|
67
|
+
const active = $derived(ctx.activeIndex === index);
|
|
68
|
+
|
|
69
|
+
// Two thumbs with the same name are two sliders the screen reader cannot tell apart. A range
|
|
70
|
+
// of two gets "Minimum" and "Maximum" when the consumer gives no name of its own.
|
|
71
|
+
const defaultLabel = $derived.by(() => {
|
|
72
|
+
if (ctx.values.length !== 2) return undefined;
|
|
73
|
+
return resolveLocalizedString($localeStore, index === 0 ? 'slider.minimum' : 'slider.maximum');
|
|
74
|
+
});
|
|
75
|
+
const ownLabel = $derived(ariaLabel ?? (ariaLabelledBy ? undefined : defaultLabel));
|
|
76
|
+
const ownLabelSource = $derived(ariaLabelledBy ?? (ownLabel ? inputId : null));
|
|
77
|
+
// The name of the group: the label, the ids the consumer gave, or the root element itself
|
|
78
|
+
// when it carries an `aria-label`.
|
|
79
|
+
const groupLabelSource = $derived(
|
|
80
|
+
ctx.ariaLabelledBy ?? ctx.labelId ?? (ctx.ariaLabel ? ctx.rootId : null)
|
|
81
|
+
);
|
|
82
|
+
const inputAriaLabel = $derived(
|
|
83
|
+
ownLabel ?? (groupLabelSource === ctx.rootId ? ctx.ariaLabel : undefined)
|
|
84
|
+
);
|
|
85
|
+
const inputLabelledBy = $derived.by(() => {
|
|
86
|
+
if (!ownLabelSource) {
|
|
87
|
+
return groupLabelSource && groupLabelSource !== ctx.rootId ? groupLabelSource : undefined;
|
|
88
|
+
}
|
|
89
|
+
return groupLabelSource ? `${ownLabelSource} ${groupLabelSource}` : ownLabelSource;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// The native input keeps the value: a screen reader reads it from there, and a form sends it.
|
|
93
|
+
$effect(() => {
|
|
94
|
+
if (!inputRef) return;
|
|
95
|
+
const nextValue = String(value);
|
|
96
|
+
if (inputRef.value !== nextValue) inputRef.value = nextValue;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// The focus ring must appear when a pointer press is followed by a key press, and the
|
|
100
|
+
// modality alone changes there: no focus event fires to re-read it.
|
|
101
|
+
watchFocusVisible({
|
|
102
|
+
isFocused: () => focused,
|
|
103
|
+
element: () => inputRef,
|
|
104
|
+
set: (visible) => ctx.setFocusVisible(visible)
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const positionStyle = $derived.by(() => {
|
|
108
|
+
if (ctx.orientation === 'vertical') {
|
|
109
|
+
return `position: absolute; bottom: ${percent}%; left: 50%; translate: -50% 50%;`;
|
|
110
|
+
}
|
|
111
|
+
// A physical `left`, because the `translate` that centers the thumb is physical too.
|
|
112
|
+
const left = ctx.isRtl ? 100 - percent : percent;
|
|
113
|
+
return `position: absolute; left: ${left}%; top: 50%; translate: -50% -50%;`;
|
|
114
|
+
});
|
|
115
|
+
// The thumb the user touched last draws above the others: two thumbs at the same value
|
|
116
|
+
// would hide the one that just moved.
|
|
117
|
+
const resolvedStyle = $derived(
|
|
118
|
+
`${positionStyle} touch-action: none;${active ? ' z-index: 1;' : ''}${style ? ` ${style}` : ''}`
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// The keyboard reports `onChange` on each key press, and `onChangeEnd` one time at the
|
|
122
|
+
// release, thus a held key does not report an end on each repeat.
|
|
123
|
+
let keyboardChanged = false;
|
|
124
|
+
|
|
125
|
+
function commitKeyboard(event: Event) {
|
|
126
|
+
if (!keyboardChanged) return;
|
|
127
|
+
keyboardChanged = false;
|
|
128
|
+
ctx.commitValue({ reason: 'keyboard', index, event });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function handleKeyDown(event: KeyboardEvent) {
|
|
132
|
+
if (event.defaultPrevented) return;
|
|
133
|
+
if (event.ctrlKey || event.metaKey || event.altKey) return;
|
|
134
|
+
|
|
135
|
+
const horizontal = ctx.orientation === 'horizontal';
|
|
136
|
+
const rtl = horizontal && isRtl(thumbRef);
|
|
137
|
+
let direction: -1 | 1 | null = null;
|
|
138
|
+
let large = event.shiftKey;
|
|
139
|
+
let absolute: number | null = null;
|
|
140
|
+
|
|
141
|
+
switch (event.key) {
|
|
142
|
+
case 'ArrowRight':
|
|
143
|
+
direction = rtl ? -1 : 1;
|
|
144
|
+
break;
|
|
145
|
+
case 'ArrowLeft':
|
|
146
|
+
direction = rtl ? 1 : -1;
|
|
147
|
+
break;
|
|
148
|
+
case 'ArrowUp':
|
|
149
|
+
direction = 1;
|
|
150
|
+
break;
|
|
151
|
+
case 'ArrowDown':
|
|
152
|
+
direction = -1;
|
|
153
|
+
break;
|
|
154
|
+
case 'PageUp':
|
|
155
|
+
direction = 1;
|
|
156
|
+
large = true;
|
|
157
|
+
break;
|
|
158
|
+
case 'PageDown':
|
|
159
|
+
direction = -1;
|
|
160
|
+
large = true;
|
|
161
|
+
break;
|
|
162
|
+
case 'Home':
|
|
163
|
+
absolute = ctx.min;
|
|
164
|
+
break;
|
|
165
|
+
case 'End':
|
|
166
|
+
absolute = ctx.max;
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// The native input would step on its own, in its own amounts.
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
trackInteractionModality(event, inputRef);
|
|
175
|
+
if (focused) ctx.setFocusVisible(true);
|
|
176
|
+
if (ctx.isReadOnly) return;
|
|
177
|
+
|
|
178
|
+
if (absolute !== null) {
|
|
179
|
+
if (ctx.setValueAt(index, absolute, { reason: 'keyboard', index, event })) {
|
|
180
|
+
keyboardChanged = true;
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (direction !== null && ctx.stepValueAt(index, direction, { large, event })) {
|
|
185
|
+
keyboardChanged = true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function handleKeyUp(event: KeyboardEvent) {
|
|
190
|
+
commitKeyboard(event);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// A change that did not come through the keyboard handler: a mobile screen reader swipe, or
|
|
194
|
+
// a browser feature that writes the native input.
|
|
195
|
+
function handleInput(event: Event) {
|
|
196
|
+
if (!inputRef) return;
|
|
197
|
+
const nextValue = Number(inputRef.value);
|
|
198
|
+
if (Number.isFinite(nextValue) && nextValue !== value && !ctx.isReadOnly) {
|
|
199
|
+
const details: SliderChangeDetails = { reason: 'input', index, event };
|
|
200
|
+
if (ctx.setValueAt(index, nextValue, details)) ctx.commitValue(details);
|
|
201
|
+
}
|
|
202
|
+
// Re-sync when the change was refused, or clamped by a neighbor.
|
|
203
|
+
inputRef.value = String(ctx.values[index] ?? ctx.min);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function handleFocus() {
|
|
207
|
+
ctx.setThumbFocus(index, true);
|
|
208
|
+
ctx.setFocusVisible(shouldShowFocusVisible(inputRef));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function handleBlur(event: FocusEvent) {
|
|
212
|
+
// A key still held when the focus leaves has no release to wait for.
|
|
213
|
+
commitKeyboard(event);
|
|
214
|
+
ctx.setThumbFocus(index, false);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function handlePointerDown(
|
|
218
|
+
event: PointerEvent & { currentTarget: EventTarget & HTMLDivElement }
|
|
219
|
+
) {
|
|
220
|
+
onpointerdown?.(event);
|
|
221
|
+
if (event.defaultPrevented) return;
|
|
222
|
+
// The thumb keeps its value at the press; only a move changes it.
|
|
223
|
+
ctx.startDrag(event, index);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const renderState = $derived<SliderThumbRenderState>({ value, text, index, dragging, focused });
|
|
227
|
+
</script>
|
|
228
|
+
|
|
229
|
+
<div
|
|
230
|
+
{...restProps}
|
|
231
|
+
bind:this={thumbRef}
|
|
232
|
+
class={className}
|
|
233
|
+
style={resolvedStyle}
|
|
234
|
+
data-slider-thumb="true"
|
|
235
|
+
data-index={index}
|
|
236
|
+
data-orientation={ctx.orientation}
|
|
237
|
+
data-disabled={ctx.isDisabled || undefined}
|
|
238
|
+
data-readonly={ctx.isReadOnly || undefined}
|
|
239
|
+
data-invalid={ctx.isInvalid || undefined}
|
|
240
|
+
data-dragging={dragging || undefined}
|
|
241
|
+
data-focused={focused || undefined}
|
|
242
|
+
data-focus-visible={focusVisible || undefined}
|
|
243
|
+
onpointerdown={handlePointerDown}
|
|
244
|
+
>
|
|
245
|
+
<input
|
|
246
|
+
bind:this={inputRef}
|
|
247
|
+
type="range"
|
|
248
|
+
id={inputId}
|
|
249
|
+
name={name ?? ctx.name}
|
|
250
|
+
form={ctx.form}
|
|
251
|
+
min={ctx.min}
|
|
252
|
+
max={ctx.max}
|
|
253
|
+
step={ctx.step}
|
|
254
|
+
value={String(value)}
|
|
255
|
+
disabled={ctx.isDisabled}
|
|
256
|
+
aria-orientation={ctx.orientation}
|
|
257
|
+
aria-valuenow={value}
|
|
258
|
+
aria-valuetext={valueText}
|
|
259
|
+
aria-label={inputAriaLabel}
|
|
260
|
+
aria-labelledby={inputLabelledBy}
|
|
261
|
+
aria-describedby={ctx.ariaDescribedBy}
|
|
262
|
+
aria-readonly={ctx.isReadOnly || undefined}
|
|
263
|
+
aria-invalid={ctx.isInvalid || undefined}
|
|
264
|
+
data-slider-input="true"
|
|
265
|
+
data-index={index}
|
|
266
|
+
style="position:absolute;inset:0;width:100%;height:100%;margin:0;padding:0;border:0;opacity:0;cursor:inherit;pointer-events:none;"
|
|
267
|
+
onkeydown={handleKeyDown}
|
|
268
|
+
onkeyup={handleKeyUp}
|
|
269
|
+
oninput={handleInput}
|
|
270
|
+
onfocus={handleFocus}
|
|
271
|
+
onblur={handleBlur}
|
|
272
|
+
/>
|
|
273
|
+
{#if children}
|
|
274
|
+
{@render (children as Snippet<[SliderThumbRenderState]>)(renderState)}
|
|
275
|
+
{/if}
|
|
276
|
+
</div>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useSliderContext } from '../root/context';
|
|
3
|
+
import type { SliderTrackProps } from '../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Slider.Track — the rail, and the surface of the pointer.
|
|
7
|
+
*
|
|
8
|
+
* A press on it moves the nearest thumb to the pointer and starts a drag. The thumbs sit in
|
|
9
|
+
* it, positioned along it in percent of the value. It is `position: relative` for that, and
|
|
10
|
+
* `touch-action: none` so that a touch drag moves the thumb and not the page.
|
|
11
|
+
*/
|
|
12
|
+
let {
|
|
13
|
+
children,
|
|
14
|
+
class: className = '',
|
|
15
|
+
element = $bindable<HTMLDivElement | null>(null),
|
|
16
|
+
style,
|
|
17
|
+
onpointerdown,
|
|
18
|
+
...restProps
|
|
19
|
+
}: SliderTrackProps = $props();
|
|
20
|
+
|
|
21
|
+
const ctx = useSliderContext('Slider.Track');
|
|
22
|
+
let trackRef: HTMLDivElement | null = $state(null);
|
|
23
|
+
|
|
24
|
+
$effect(() => {
|
|
25
|
+
element = trackRef;
|
|
26
|
+
ctx.setTrackRef(trackRef);
|
|
27
|
+
return () => {
|
|
28
|
+
ctx.setTrackRef(null);
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// The consumer style comes last, thus it can replace the two defaults.
|
|
33
|
+
const resolvedStyle = $derived(
|
|
34
|
+
`position: relative; touch-action: none;${style ? ` ${style}` : ''}`
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
function handlePointerDown(
|
|
38
|
+
event: PointerEvent & { currentTarget: EventTarget & HTMLDivElement }
|
|
39
|
+
) {
|
|
40
|
+
onpointerdown?.(event);
|
|
41
|
+
if (event.defaultPrevented) return;
|
|
42
|
+
ctx.startDrag(event);
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<div
|
|
47
|
+
{...restProps}
|
|
48
|
+
bind:this={trackRef}
|
|
49
|
+
class={className}
|
|
50
|
+
style={resolvedStyle}
|
|
51
|
+
data-slider-track="true"
|
|
52
|
+
data-orientation={ctx.orientation}
|
|
53
|
+
data-disabled={ctx.isDisabled || undefined}
|
|
54
|
+
data-readonly={ctx.isReadOnly || undefined}
|
|
55
|
+
data-invalid={ctx.isInvalid || undefined}
|
|
56
|
+
data-dragging={ctx.draggingIndex !== null || undefined}
|
|
57
|
+
onpointerdown={handlePointerDown}
|
|
58
|
+
>
|
|
59
|
+
{@render children?.()}
|
|
60
|
+
</div>
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { SliderChangeDetails, SliderContext, SliderOrientation } from './root/context';
|
|
4
|
+
export type { SliderChangeDetails, SliderOrientation };
|
|
5
|
+
export type SliderValue = number | number[];
|
|
6
|
+
export type SliderRootProps = {
|
|
7
|
+
/** A stable id, from which the component makes its internal ARIA ids. Give one on a server. */
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The value: one number for one thumb, and an array in ascending order for a range with more
|
|
11
|
+
* thumbs. You can bind it with `bind:value`.
|
|
12
|
+
*/
|
|
13
|
+
value?: SliderValue;
|
|
14
|
+
/** The value at the start, for when you give no `value`. The default is `min`. */
|
|
15
|
+
defaultValue?: SliderValue;
|
|
16
|
+
/**
|
|
17
|
+
* Give your own code full control of the value. The component stops to write back to `value`,
|
|
18
|
+
* and it reports only through `onChange`. Thus the parent can refuse a change: the parent does
|
|
19
|
+
* not send the new value down. The default is off, because `bind:value` is the usual case and
|
|
20
|
+
* it needs the write-back.
|
|
21
|
+
*/
|
|
22
|
+
controlledValue?: boolean;
|
|
23
|
+
/** The component calls it on each change, also on each move of a drag. */
|
|
24
|
+
onChange?: (value: SliderValue, details: SliderChangeDetails) => void;
|
|
25
|
+
/**
|
|
26
|
+
* The component calls it when a sequence of changes ends: at the release of a key, and at the
|
|
27
|
+
* end of a drag. A change from assistive technology ends at once. Use it for work that must
|
|
28
|
+
* not run on each move.
|
|
29
|
+
*/
|
|
30
|
+
onChangeEnd?: (value: SliderValue, details: SliderChangeDetails) => void;
|
|
31
|
+
/** The lowest value. The default is 0. */
|
|
32
|
+
min?: number;
|
|
33
|
+
/** The highest value. The default is 100. */
|
|
34
|
+
max?: number;
|
|
35
|
+
/** The distance between two values. The default is 1. */
|
|
36
|
+
step?: number;
|
|
37
|
+
/**
|
|
38
|
+
* The distance of `PageUp`, `PageDown` and `Shift+Arrow`. The default is one tenth of the
|
|
39
|
+
* range, and never less than one step.
|
|
40
|
+
*/
|
|
41
|
+
largeStep?: number;
|
|
42
|
+
/** The steps that two thumbs of a range keep between them. The default is 0: they can meet. */
|
|
43
|
+
minStepsBetweenThumbs?: number;
|
|
44
|
+
/** The direction of the track. The default is horizontal. */
|
|
45
|
+
orientation?: SliderOrientation;
|
|
46
|
+
/** Disables the slider. The native inputs are disabled, and the thumbs leave the tab order. */
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
/** Keeps the thumbs in the tab order, but the value does not change. */
|
|
49
|
+
readonly?: boolean;
|
|
50
|
+
/** Marks the value as invalid. The thumbs get `aria-invalid`. */
|
|
51
|
+
invalid?: boolean;
|
|
52
|
+
/** The name of the native inputs. A `Slider.Thumb` can give its own. */
|
|
53
|
+
name?: string;
|
|
54
|
+
/** The id of the form that the native inputs belong to, when the slider is outside it. */
|
|
55
|
+
form?: string;
|
|
56
|
+
/** The format of the value in `Slider.Output` and in the text that a screen reader reads. */
|
|
57
|
+
formatOptions?: Intl.NumberFormatOptions;
|
|
58
|
+
/**
|
|
59
|
+
* The text that a screen reader reads for a value, in place of the formatted number. The
|
|
60
|
+
* second argument is the index of the thumb.
|
|
61
|
+
*/
|
|
62
|
+
getValueText?: (value: number, index: number) => string;
|
|
63
|
+
/** The accessible name of the slider, for when there is no `Slider.Label`. */
|
|
64
|
+
'aria-label'?: string;
|
|
65
|
+
/** The id of the element that gives the slider its name, in place of `Slider.Label`. */
|
|
66
|
+
'aria-labelledby'?: string;
|
|
67
|
+
/** The id of the element that describes the slider, for example an error message. */
|
|
68
|
+
'aria-describedby'?: string;
|
|
69
|
+
/** The content: the label, the output and the track. */
|
|
70
|
+
children?: Snippet;
|
|
71
|
+
/** The CSS class names of the root element. */
|
|
72
|
+
class?: string;
|
|
73
|
+
/** A bindable reference to the root element. */
|
|
74
|
+
element?: HTMLDivElement | null;
|
|
75
|
+
/** A bindable reference to the context, for a composition of your own. */
|
|
76
|
+
context?: SliderContext;
|
|
77
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children' | 'id' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-describedby' | 'onchange'>;
|
|
78
|
+
export type SliderLabelProps = Omit<HTMLAttributes<HTMLSpanElement>, 'class'> & {
|
|
79
|
+
/** The CSS class names of the label. */
|
|
80
|
+
class?: string;
|
|
81
|
+
};
|
|
82
|
+
export type SliderOutputRenderState = {
|
|
83
|
+
/** The values, one per thumb. */
|
|
84
|
+
values: number[];
|
|
85
|
+
/** The text of each value, in the locale and the `formatOptions`. */
|
|
86
|
+
texts: string[];
|
|
87
|
+
/** The text of the whole value: one number, or a range in the locale. */
|
|
88
|
+
text: string;
|
|
89
|
+
};
|
|
90
|
+
export type SliderOutputProps = Omit<HTMLAttributes<HTMLOutputElement>, 'class' | 'children'> & {
|
|
91
|
+
/**
|
|
92
|
+
* The content. As a snippet with one argument, it receives the render state: `values`, `texts`
|
|
93
|
+
* and `text`. Without it, the component shows `text`.
|
|
94
|
+
*/
|
|
95
|
+
children?: Snippet<[SliderOutputRenderState]>;
|
|
96
|
+
/** The CSS class names of the element. */
|
|
97
|
+
class?: string;
|
|
98
|
+
};
|
|
99
|
+
export type SliderTrackProps = Omit<HTMLAttributes<HTMLDivElement>, 'class'> & {
|
|
100
|
+
/** The CSS class names of the track. */
|
|
101
|
+
class?: string;
|
|
102
|
+
/** A bindable reference to the track element. */
|
|
103
|
+
element?: HTMLDivElement | null;
|
|
104
|
+
};
|
|
105
|
+
export type SliderFillProps = Omit<HTMLAttributes<HTMLDivElement>, 'class'> & {
|
|
106
|
+
/** The CSS class names of the fill. */
|
|
107
|
+
class?: string;
|
|
108
|
+
};
|
|
109
|
+
export type SliderThumbRenderState = {
|
|
110
|
+
/** The value of the thumb. */
|
|
111
|
+
value: number;
|
|
112
|
+
/** The text of the value. */
|
|
113
|
+
text: string;
|
|
114
|
+
/** The index of the thumb. */
|
|
115
|
+
index: number;
|
|
116
|
+
/** Whether the thumb is under a pointer drag. */
|
|
117
|
+
dragging: boolean;
|
|
118
|
+
/** Whether the native input of the thumb has the focus. */
|
|
119
|
+
focused: boolean;
|
|
120
|
+
};
|
|
121
|
+
export type SliderThumbProps = Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children' | 'aria-label' | 'aria-labelledby'> & {
|
|
122
|
+
/**
|
|
123
|
+
* The index of the thumb, for a range. Without it, the thumbs take the indexes in mount order.
|
|
124
|
+
*/
|
|
125
|
+
index?: number;
|
|
126
|
+
/** The `name` of the native input of this thumb. It replaces the `name` of the root. */
|
|
127
|
+
name?: string;
|
|
128
|
+
/**
|
|
129
|
+
* The name of this thumb, before the name of the slider. A range of two thumbs without one
|
|
130
|
+
* gets "Minimum" and "Maximum" in the locale.
|
|
131
|
+
*/
|
|
132
|
+
'aria-label'?: string;
|
|
133
|
+
/** The id of the element that names this thumb, in place of `aria-label`. */
|
|
134
|
+
'aria-labelledby'?: string;
|
|
135
|
+
/**
|
|
136
|
+
* The content. As a snippet with one argument, it receives the render state: `value`, `text`,
|
|
137
|
+
* `index`, `dragging` and `focused`.
|
|
138
|
+
*/
|
|
139
|
+
children?: Snippet<[SliderThumbRenderState]> | Snippet;
|
|
140
|
+
/** The CSS class names of the thumb. */
|
|
141
|
+
class?: string;
|
|
142
|
+
/** A bindable reference to the thumb element. */
|
|
143
|
+
element?: HTMLDivElement | null;
|
|
144
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
### Switch.Root
|
|
6
6
|
|
|
7
7
|
Name: `Switch.Root`
|
|
8
|
-
Description:
|
|
8
|
+
Description: The root of a boolean switch. It holds the checked state and the focus, and it keeps the hidden input correct.
|
|
9
9
|
|
|
10
10
|
| Prop | Type | Default | Description |
|
|
11
11
|
| ----------------- | --------------------------------- | ------------- | ---------------------------------------------------------- |
|
|
@@ -20,7 +20,7 @@ Description: Interactive boolean switch root that owns checked, focus, and hidde
|
|
|
20
20
|
| `readonly` | `boolean` | `false` | Allows focus but blocks user-driven state changes. |
|
|
21
21
|
| `required` | `boolean` | `false` | Marks the hidden input as required and exposes data state. |
|
|
22
22
|
| `children` | `Snippet` | `undefined` | Composed switch parts such as `Switch.Thumb`. |
|
|
23
|
-
| `class` | `string` | `''` | CSS class names
|
|
23
|
+
| `class` | `string` | `''` | The CSS class names of the root element. |
|
|
24
24
|
| `...restProps` | `HTMLAttributes<HTMLSpanElement>` | `-` | Additional attributes forwarded to the switch root span. |
|
|
25
25
|
|
|
26
26
|
### Context utilities
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
shouldShowFocusVisible,
|
|
6
6
|
trackInteractionModality
|
|
7
7
|
} from '../../primitives/input-modality';
|
|
8
|
+
import { watchFocusVisible } from '../../primitives/focus-visible.svelte';
|
|
8
9
|
import { setSwitchContext, type SwitchContext } from './context';
|
|
9
10
|
|
|
10
11
|
type SwitchRootProps = Omit<
|
|
@@ -21,35 +22,47 @@
|
|
|
21
22
|
| 'onkeydown'
|
|
22
23
|
| 'value'
|
|
23
24
|
> & {
|
|
24
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* The id of the hidden input, thus a `label[for]` element can point at the switch. If you give
|
|
27
|
+
* none, the component makes one.
|
|
28
|
+
*/
|
|
25
29
|
id?: string;
|
|
26
|
-
/**
|
|
30
|
+
/** A bindable reference to the root element. */
|
|
27
31
|
element?: HTMLSpanElement | null;
|
|
28
|
-
/**
|
|
32
|
+
/** The name that the form submits while the switch is on. */
|
|
29
33
|
name?: string;
|
|
30
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* The value that the form submits while the switch is on. It does not change the visual state.
|
|
36
|
+
*/
|
|
31
37
|
value?: string;
|
|
32
|
-
/**
|
|
38
|
+
/** The id of the form of the hidden input. */
|
|
33
39
|
form?: string;
|
|
34
|
-
/**
|
|
40
|
+
/** The checked state. By default it goes in the two directions: use `bind:checked`. */
|
|
35
41
|
checked?: boolean;
|
|
36
|
-
/**
|
|
42
|
+
/** The checked state at the start, for when you give no `checked`. */
|
|
37
43
|
defaultChecked?: boolean;
|
|
38
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Give your own code full control of the state. The component stops to write back to `checked`,
|
|
46
|
+
* and it reports only through `onCheckedChange`. Thus the parent can refuse a change: the parent
|
|
47
|
+
* does not send the new value down. The default is off, because `bind:checked` is the usual case
|
|
48
|
+
* and it needs the write-back.
|
|
49
|
+
*/
|
|
50
|
+
controlledChecked?: boolean;
|
|
51
|
+
/** The component calls it when the user changes the switch. */
|
|
39
52
|
onCheckedChange?: (checked: boolean) => void;
|
|
40
|
-
/**
|
|
53
|
+
/** Stops the interaction with the switch and removes it from the focus order. */
|
|
41
54
|
disabled?: boolean;
|
|
42
|
-
/** Keeps the switch focusable
|
|
55
|
+
/** Keeps the switch focusable, but stops the changes of the state. */
|
|
43
56
|
readonly?: boolean;
|
|
44
|
-
/**
|
|
57
|
+
/** Makes the hidden input required for the form validation. */
|
|
45
58
|
required?: boolean;
|
|
46
59
|
children?: Snippet;
|
|
47
60
|
class?: string;
|
|
48
|
-
/**
|
|
61
|
+
/** The accessible name, for when the user sees no name. */
|
|
49
62
|
'aria-label'?: string;
|
|
50
|
-
/**
|
|
63
|
+
/** The id of the element that gives the switch its name. */
|
|
51
64
|
'aria-labelledby'?: string;
|
|
52
|
-
/**
|
|
65
|
+
/** Replaces the default position in the tab order. */
|
|
53
66
|
tabindex?: number;
|
|
54
67
|
onclick?: HTMLAttributes<HTMLSpanElement>['onclick'];
|
|
55
68
|
onkeydown?: HTMLAttributes<HTMLSpanElement>['onkeydown'];
|
|
@@ -87,6 +100,7 @@
|
|
|
87
100
|
form,
|
|
88
101
|
checked = $bindable(),
|
|
89
102
|
defaultChecked = false,
|
|
103
|
+
controlledChecked = false,
|
|
90
104
|
onCheckedChange,
|
|
91
105
|
disabled = false,
|
|
92
106
|
readonly = false,
|
|
@@ -123,6 +137,14 @@
|
|
|
123
137
|
let pressedKey: 'Enter' | 'Space' | null = $state(null);
|
|
124
138
|
let focused = $state(false);
|
|
125
139
|
let focusVisible = $state(false);
|
|
140
|
+
|
|
141
|
+
// The focus ring must appear when a pointer press is followed by a key press, and the
|
|
142
|
+
// modality alone changes there — no focus event fires to re-read it.
|
|
143
|
+
watchFocusVisible({
|
|
144
|
+
isFocused: () => focused,
|
|
145
|
+
element: () => rootRef,
|
|
146
|
+
set: (visible) => (focusVisible = visible)
|
|
147
|
+
});
|
|
126
148
|
let rootRef: HTMLSpanElement | null = $state(null);
|
|
127
149
|
let inputRef: HTMLInputElement | null = $state(null);
|
|
128
150
|
|
|
@@ -141,14 +163,20 @@
|
|
|
141
163
|
}
|
|
142
164
|
});
|
|
143
165
|
|
|
144
|
-
// Controlled-ness is
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
//
|
|
148
|
-
|
|
166
|
+
// Controlled-ness is NOT inferred from `checked` being defined: `bind:checked={value}`
|
|
167
|
+
// and `checked={value}` are indistinguishable at runtime, so inferring it silently
|
|
168
|
+
// broke every `bind:checked` seeded with `false`. It is opt-in via `controlledChecked`.
|
|
169
|
+
// Write the initial state back so `bind:` parents see the resolved default. Read
|
|
170
|
+
// untracked: this is a deliberate one-time seed at init, not a reactive mirror.
|
|
171
|
+
if (!untrack(() => controlledChecked)) {
|
|
149
172
|
checked = initialChecked;
|
|
150
173
|
}
|
|
151
|
-
|
|
174
|
+
|
|
175
|
+
// `checked` wins whenever it is supplied — that covers both `bind:checked` and a plain
|
|
176
|
+
// `checked={...}` — and the internal state only carries the fully uncontrolled case.
|
|
177
|
+
const currentChecked = $derived(
|
|
178
|
+
controlledChecked ? Boolean(checked) : (checked ?? checkedInternal)
|
|
179
|
+
);
|
|
152
180
|
const currentUnchecked = $derived(!currentChecked);
|
|
153
181
|
|
|
154
182
|
function clearPressState() {
|
|
@@ -159,7 +187,7 @@
|
|
|
159
187
|
function publishChecked(nextChecked: boolean, event?: Event) {
|
|
160
188
|
const previousChecked = currentChecked;
|
|
161
189
|
|
|
162
|
-
if (!
|
|
190
|
+
if (!controlledChecked) {
|
|
163
191
|
checkedInternal = nextChecked;
|
|
164
192
|
checked = nextChecked;
|
|
165
193
|
}
|