@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,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-axis pointer drag, for panels that follow the finger and settle on
|
|
3
|
+
* release (drawers, sheets, swipe-to-open edges).
|
|
4
|
+
*
|
|
5
|
+
* The action deliberately owns as little policy as possible: it reports a signed
|
|
6
|
+
* displacement and a release velocity, and leaves clamping, snapping and
|
|
7
|
+
* dismissal thresholds to the caller. Everything that can be decided without a
|
|
8
|
+
* DOM is exported as a pure function so it can be unit-tested directly.
|
|
9
|
+
*
|
|
10
|
+
* Two behaviours are worth calling out, because they are what separates a usable
|
|
11
|
+
* sheet from an infuriating one:
|
|
12
|
+
*
|
|
13
|
+
* 1. The gesture is CLAIMED, not assumed. Nothing happens until the finger has
|
|
14
|
+
* moved past a small threshold, mostly along the axis, and no scrollable
|
|
15
|
+
* region between the touch and the panel could have consumed that movement.
|
|
16
|
+
* Without the last check, a bottom sheet with a scrolling body drags itself
|
|
17
|
+
* off screen the moment you try to scroll it.
|
|
18
|
+
* 2. `touch-action` is left alone by default. Setting `none` on the panel would
|
|
19
|
+
* kill native scrolling for every descendant — `touch-action` intersects down
|
|
20
|
+
* the ancestor chain, so a child cannot opt back in. Horizontal drawers can
|
|
21
|
+
* safely pass `pan-y` (children keep scrolling vertically, we take the
|
|
22
|
+
* horizontal axis); vertical ones rely on `preventDefault` once claimed.
|
|
23
|
+
*/
|
|
24
|
+
/** Axis a panel anchored to `side` travels along. */
|
|
25
|
+
export function getSwipeAxis(side) {
|
|
26
|
+
return side === 'left' || side === 'right' ? 'x' : 'y';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sign of the OUTWARD direction along the axis — the way the panel moves to leave
|
|
30
|
+
* the screen. A bottom drawer exits downward (+y), a left drawer leftward (-x).
|
|
31
|
+
* Displacements reported by the action are already multiplied by this, so
|
|
32
|
+
* "positive means closer to dismissed" holds for every side.
|
|
33
|
+
*/
|
|
34
|
+
export function getOutwardSign(side) {
|
|
35
|
+
return side === 'bottom' || side === 'right' ? 1 : -1;
|
|
36
|
+
}
|
|
37
|
+
/** Window (ms) over which the release velocity is measured. */
|
|
38
|
+
export const RELEASE_VELOCITY_WINDOW_MS = 100;
|
|
39
|
+
/**
|
|
40
|
+
* Release velocity in px/ms (signed, positive = outward) over the trailing
|
|
41
|
+
* `windowMs` before `now`.
|
|
42
|
+
*
|
|
43
|
+
* Returns `0` when there is no recent movement — no samples, or the newest one is
|
|
44
|
+
* already older than the window, which is what a finger held still before lifting
|
|
45
|
+
* looks like. Samples sharing a timestamp with a non-zero displacement yield
|
|
46
|
+
* `±Infinity`; callers treat that as a flick.
|
|
47
|
+
*
|
|
48
|
+
* (The Clock wheel has a sibling of this function measuring `scrollTop` instead;
|
|
49
|
+
* they are kept separate so gesture work cannot regress the picker.)
|
|
50
|
+
*/
|
|
51
|
+
export function getReleaseVelocity(samples, now, windowMs = RELEASE_VELOCITY_WINDOW_MS) {
|
|
52
|
+
if (samples.length === 0)
|
|
53
|
+
return 0;
|
|
54
|
+
const newest = samples[samples.length - 1];
|
|
55
|
+
if (now - newest.time > windowMs)
|
|
56
|
+
return 0;
|
|
57
|
+
// Oldest sample still inside the window.
|
|
58
|
+
let referenceIndex = samples.length - 1;
|
|
59
|
+
while (referenceIndex > 0 && now - samples[referenceIndex - 1].time <= windowMs) {
|
|
60
|
+
referenceIndex -= 1;
|
|
61
|
+
}
|
|
62
|
+
// Only reach OUTSIDE the window when the newest sample is alone in it and
|
|
63
|
+
// there is nothing to measure against. Stepping back unconditionally (as the
|
|
64
|
+
// Clock's sibling does) lets one stale buffered sample stretch the elapsed
|
|
65
|
+
// time and flatten a genuine flick to a crawl.
|
|
66
|
+
if (referenceIndex === samples.length - 1 && referenceIndex > 0) {
|
|
67
|
+
referenceIndex -= 1;
|
|
68
|
+
}
|
|
69
|
+
const reference = samples[referenceIndex];
|
|
70
|
+
const distance = newest.position - reference.position;
|
|
71
|
+
const elapsed = newest.time - reference.time;
|
|
72
|
+
if (elapsed <= 0) {
|
|
73
|
+
if (distance === 0)
|
|
74
|
+
return 0;
|
|
75
|
+
return distance > 0 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
76
|
+
}
|
|
77
|
+
return distance / elapsed;
|
|
78
|
+
}
|
|
79
|
+
/** How far (ms of travel) a flick is projected past the release point. */
|
|
80
|
+
export const RELEASE_MOMENTUM_MS = 180;
|
|
81
|
+
/**
|
|
82
|
+
* Where the panel would come to rest if the flick kept its speed for
|
|
83
|
+
* `momentumMs`. Used to pick a snap point that respects intent: a short but fast
|
|
84
|
+
* flick should skip ahead, a long slow drag should not.
|
|
85
|
+
*
|
|
86
|
+
* Infinite velocities (samples with identical timestamps) project to the
|
|
87
|
+
* corresponding infinity, which callers clamp against their own bounds.
|
|
88
|
+
*/
|
|
89
|
+
export function projectRelease(position, velocity, momentumMs = RELEASE_MOMENTUM_MS) {
|
|
90
|
+
if (!Number.isFinite(velocity))
|
|
91
|
+
return velocity > 0 ? Infinity : -Infinity;
|
|
92
|
+
return position + velocity * momentumMs;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Diminishing-returns resistance for dragging past a bound, so the panel keeps
|
|
96
|
+
* moving (the gesture stays alive) without following the finger 1:1.
|
|
97
|
+
*
|
|
98
|
+
* Asymptotic: no matter how far the finger travels, the result stays below
|
|
99
|
+
* `dimension`. `factor` is the initial stiffness — lower is stiffer.
|
|
100
|
+
*/
|
|
101
|
+
export function applyRubberBand(overshoot, dimension, factor = 0.55) {
|
|
102
|
+
if (overshoot <= 0)
|
|
103
|
+
return 0;
|
|
104
|
+
if (dimension <= 0)
|
|
105
|
+
return 0;
|
|
106
|
+
return (1 - 1 / ((overshoot * factor) / dimension + 1)) * dimension;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Marks a subtree as not starting a swipe (sliders, carousels, drag handles).
|
|
110
|
+
*
|
|
111
|
+
* Valueless — or any value other than `"mouse"` — opts the subtree out for every
|
|
112
|
+
* input type. `"mouse"` opts it out for a mouse only, which is how a region can
|
|
113
|
+
* stay swipeable under a finger while a mouse drag inside it selects text: on
|
|
114
|
+
* touch there is no drag-to-select to protect, so the two never compete.
|
|
115
|
+
*/
|
|
116
|
+
export const SWIPE_IGNORE_ATTRIBUTE = 'data-hk-swipe-ignore';
|
|
117
|
+
/** Whether `target` sits in a subtree that opts out of swipes for `pointerType`. */
|
|
118
|
+
function isSwipeIgnored(target, pointerType) {
|
|
119
|
+
const ignored = target.closest(`[${SWIPE_IGNORE_ATTRIBUTE}]`);
|
|
120
|
+
if (!ignored)
|
|
121
|
+
return false;
|
|
122
|
+
if (ignored.getAttribute(SWIPE_IGNORE_ATTRIBUTE) === 'mouse')
|
|
123
|
+
return pointerType === 'mouse';
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
function isScrollableOn(element, axis) {
|
|
127
|
+
const style = getComputedStyle(element);
|
|
128
|
+
const overflow = axis === 'y' ? style.overflowY : style.overflowX;
|
|
129
|
+
return /(auto|scroll|overlay)/.test(overflow);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Whether a scrollable region between `target` and `node` (inclusive) could
|
|
133
|
+
* absorb a drag of `delta` px along `axis`, and so should keep the gesture.
|
|
134
|
+
*
|
|
135
|
+
* `delta` is raw finger movement, not outward displacement: a finger moving down
|
|
136
|
+
* scrolls the content up, which only a scroller with room above can do.
|
|
137
|
+
*/
|
|
138
|
+
function scrollerCanConsume(target, node, axis, delta) {
|
|
139
|
+
let element = target;
|
|
140
|
+
while (element) {
|
|
141
|
+
if (element instanceof HTMLElement && isScrollableOn(element, axis)) {
|
|
142
|
+
if (axis === 'y') {
|
|
143
|
+
const max = element.scrollHeight - element.clientHeight;
|
|
144
|
+
if (max > 0) {
|
|
145
|
+
// Sub-pixel scroll offsets are common on zoomed/HiDPI viewports;
|
|
146
|
+
// the 1px slack keeps "at the bound" from flickering.
|
|
147
|
+
if (delta > 0 && element.scrollTop > 0)
|
|
148
|
+
return true;
|
|
149
|
+
if (delta < 0 && element.scrollTop < max - 1)
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
const max = element.scrollWidth - element.clientWidth;
|
|
155
|
+
if (max > 0) {
|
|
156
|
+
if (delta > 0 && element.scrollLeft > 0)
|
|
157
|
+
return true;
|
|
158
|
+
if (delta < 0 && element.scrollLeft < max - 1)
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (element === node)
|
|
164
|
+
break;
|
|
165
|
+
element = element.parentElement;
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Svelte action wiring a single-axis drag on `node`.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```svelte
|
|
174
|
+
* <div use:swipeGesture={{ side: 'bottom', onMove: ({ displacement }) => (offset = displacement) }}>
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
export function swipeGesture(node, options) {
|
|
178
|
+
let current = options;
|
|
179
|
+
let pointerId = null;
|
|
180
|
+
let startX = 0;
|
|
181
|
+
let startY = 0;
|
|
182
|
+
let startTarget = null;
|
|
183
|
+
let claimed = false;
|
|
184
|
+
let samples = [];
|
|
185
|
+
let suppressClickTimer = null;
|
|
186
|
+
let suppressClickListener = null;
|
|
187
|
+
function axis() {
|
|
188
|
+
return getSwipeAxis(current.side);
|
|
189
|
+
}
|
|
190
|
+
function applyTouchAction() {
|
|
191
|
+
const value = current.touchAction ?? null;
|
|
192
|
+
if (value === null) {
|
|
193
|
+
node.style.removeProperty('touch-action');
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
node.style.touchAction = value;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Removes the pending click suppression, if any.
|
|
200
|
+
*
|
|
201
|
+
* Must also run on `destroy`: the timeout below normally lifts the listener a
|
|
202
|
+
* macrotask later, but a gesture that ends by unmounting the node never gets
|
|
203
|
+
* there — and a capture-phase listener left on `window` goes on to swallow the
|
|
204
|
+
* next click anywhere on the page.
|
|
205
|
+
*/
|
|
206
|
+
function clearClickSuppression() {
|
|
207
|
+
if (suppressClickTimer !== null) {
|
|
208
|
+
clearTimeout(suppressClickTimer);
|
|
209
|
+
suppressClickTimer = null;
|
|
210
|
+
}
|
|
211
|
+
if (suppressClickListener) {
|
|
212
|
+
window.removeEventListener('click', suppressClickListener, true);
|
|
213
|
+
suppressClickListener = null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* A claimed drag that started on a button must not also activate it on release.
|
|
218
|
+
* One capture-phase listener, lifted on the next macrotask in case no click ever
|
|
219
|
+
* follows (a drag that ended outside the element it started on).
|
|
220
|
+
*/
|
|
221
|
+
function suppressNextClick() {
|
|
222
|
+
clearClickSuppression();
|
|
223
|
+
suppressClickListener = (event) => {
|
|
224
|
+
event.preventDefault();
|
|
225
|
+
event.stopPropagation();
|
|
226
|
+
clearClickSuppression();
|
|
227
|
+
};
|
|
228
|
+
window.addEventListener('click', suppressClickListener, true);
|
|
229
|
+
suppressClickTimer = setTimeout(clearClickSuppression, 0);
|
|
230
|
+
}
|
|
231
|
+
function detachWindowListeners() {
|
|
232
|
+
window.removeEventListener('pointermove', handleMove);
|
|
233
|
+
window.removeEventListener('pointerup', handleUp);
|
|
234
|
+
window.removeEventListener('pointercancel', handleCancel);
|
|
235
|
+
}
|
|
236
|
+
function reset() {
|
|
237
|
+
if (claimed && pointerId !== null && node.hasPointerCapture?.(pointerId)) {
|
|
238
|
+
node.releasePointerCapture(pointerId);
|
|
239
|
+
}
|
|
240
|
+
detachWindowListeners();
|
|
241
|
+
pointerId = null;
|
|
242
|
+
startTarget = null;
|
|
243
|
+
claimed = false;
|
|
244
|
+
samples = [];
|
|
245
|
+
}
|
|
246
|
+
function handleDown(event) {
|
|
247
|
+
if (current.enabled === false)
|
|
248
|
+
return;
|
|
249
|
+
// A gesture is already in flight (second finger, or a stale capture).
|
|
250
|
+
if (pointerId !== null)
|
|
251
|
+
return;
|
|
252
|
+
if (event.pointerType === 'mouse' && event.button !== 0)
|
|
253
|
+
return;
|
|
254
|
+
if (!(event.target instanceof Element))
|
|
255
|
+
return;
|
|
256
|
+
if (isSwipeIgnored(event.target, event.pointerType))
|
|
257
|
+
return;
|
|
258
|
+
pointerId = event.pointerId;
|
|
259
|
+
startX = event.clientX;
|
|
260
|
+
startY = event.clientY;
|
|
261
|
+
startTarget = event.target;
|
|
262
|
+
claimed = false;
|
|
263
|
+
samples = [{ time: performance.now(), position: 0 }];
|
|
264
|
+
window.addEventListener('pointermove', handleMove, { passive: false });
|
|
265
|
+
window.addEventListener('pointerup', handleUp);
|
|
266
|
+
window.addEventListener('pointercancel', handleCancel);
|
|
267
|
+
}
|
|
268
|
+
function handleMove(event) {
|
|
269
|
+
if (pointerId === null || event.pointerId !== pointerId)
|
|
270
|
+
return;
|
|
271
|
+
const currentAxis = axis();
|
|
272
|
+
const deltaX = event.clientX - startX;
|
|
273
|
+
const deltaY = event.clientY - startY;
|
|
274
|
+
const main = currentAxis === 'x' ? deltaX : deltaY;
|
|
275
|
+
const cross = currentAxis === 'x' ? deltaY : deltaX;
|
|
276
|
+
if (!claimed) {
|
|
277
|
+
const threshold = current.threshold ?? 4;
|
|
278
|
+
if (Math.abs(main) < threshold && Math.abs(cross) < threshold)
|
|
279
|
+
return;
|
|
280
|
+
// Mostly a cross-axis movement: this is someone else's gesture.
|
|
281
|
+
if (Math.abs(cross) > Math.abs(main)) {
|
|
282
|
+
reset();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (startTarget && scrollerCanConsume(startTarget, node, currentAxis, main)) {
|
|
286
|
+
reset();
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
claimed = true;
|
|
290
|
+
try {
|
|
291
|
+
node.setPointerCapture(pointerId);
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
// Capture is an optimisation (it keeps events flowing when the finger
|
|
295
|
+
// leaves the panel); the window listeners work without it.
|
|
296
|
+
}
|
|
297
|
+
current.onStart?.(event);
|
|
298
|
+
}
|
|
299
|
+
const displacement = main * getOutwardSign(current.side);
|
|
300
|
+
samples.push({ time: performance.now(), position: displacement });
|
|
301
|
+
// Keep only what the release-velocity window can still use as a baseline.
|
|
302
|
+
while (samples.length > 2 && performance.now() - samples[1].time > RELEASE_VELOCITY_WINDOW_MS) {
|
|
303
|
+
samples.shift();
|
|
304
|
+
}
|
|
305
|
+
// Stops the browser from turning the claimed drag into a scroll or a
|
|
306
|
+
// text selection. Non-cancelable once a native scroll has begun, which is
|
|
307
|
+
// exactly when we should not be dragging anyway.
|
|
308
|
+
if (event.cancelable)
|
|
309
|
+
event.preventDefault();
|
|
310
|
+
current.onMove?.({ displacement, event });
|
|
311
|
+
}
|
|
312
|
+
function handleUp(event) {
|
|
313
|
+
if (pointerId === null || event.pointerId !== pointerId)
|
|
314
|
+
return;
|
|
315
|
+
const wasClaimed = claimed;
|
|
316
|
+
const displacement = (axis() === 'x' ? event.clientX - startX : event.clientY - startY) *
|
|
317
|
+
getOutwardSign(current.side);
|
|
318
|
+
const velocity = getReleaseVelocity(samples, performance.now());
|
|
319
|
+
reset();
|
|
320
|
+
if (!wasClaimed)
|
|
321
|
+
return;
|
|
322
|
+
suppressNextClick();
|
|
323
|
+
current.onEnd?.({ displacement, velocity, event });
|
|
324
|
+
}
|
|
325
|
+
function handleCancel(event) {
|
|
326
|
+
if (pointerId === null || event.pointerId !== pointerId)
|
|
327
|
+
return;
|
|
328
|
+
const wasClaimed = claimed;
|
|
329
|
+
reset();
|
|
330
|
+
if (wasClaimed)
|
|
331
|
+
current.onCancel?.();
|
|
332
|
+
}
|
|
333
|
+
node.addEventListener('pointerdown', handleDown);
|
|
334
|
+
applyTouchAction();
|
|
335
|
+
return {
|
|
336
|
+
update(newOptions) {
|
|
337
|
+
const touchActionChanged = (newOptions.touchAction ?? null) !== (current.touchAction ?? null);
|
|
338
|
+
current = newOptions;
|
|
339
|
+
if (touchActionChanged)
|
|
340
|
+
applyTouchAction();
|
|
341
|
+
// Disabling mid-gesture must not leave the pointer captured.
|
|
342
|
+
if (current.enabled === false && pointerId !== null)
|
|
343
|
+
reset();
|
|
344
|
+
},
|
|
345
|
+
destroy() {
|
|
346
|
+
node.removeEventListener('pointerdown', handleDown);
|
|
347
|
+
clearClickSuppression();
|
|
348
|
+
reset();
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a string for searching: lower case, and without the diacritics.
|
|
3
|
+
*
|
|
4
|
+
* Decomposing first (`NFD`) splits an accented letter into the letter plus its combining
|
|
5
|
+
* mark, so stripping the marks leaves the plain letter — `Á` becomes `a`. Used by the
|
|
6
|
+
* combobox's default filter, so a list can be searched the way people type.
|
|
7
|
+
*/
|
|
8
|
+
export declare function foldForSearch(value: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a string for searching: lower case, and without the diacritics.
|
|
3
|
+
*
|
|
4
|
+
* Decomposing first (`NFD`) splits an accented letter into the letter plus its combining
|
|
5
|
+
* mark, so stripping the marks leaves the plain letter — `Á` becomes `a`. Used by the
|
|
6
|
+
* combobox's default filter, so a list can be searched the way people type.
|
|
7
|
+
*/
|
|
8
|
+
export function foldForSearch(value) {
|
|
9
|
+
return value
|
|
10
|
+
.normalize('NFD')
|
|
11
|
+
.replace(/\p{Diacritic}/gu, '')
|
|
12
|
+
.toLowerCase();
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The focus state of a trigger after its floating panel closes.
|
|
3
|
+
*
|
|
4
|
+
* Shared by Popover and Menu, whose close reasons differ only in which of them return the
|
|
5
|
+
* focus to the trigger. The rule for the attributes is the same for both: the trigger shows
|
|
6
|
+
* `data-focused` and `data-focus-visible` only while it holds the focus. Written by hand for
|
|
7
|
+
* a trigger that does not hold it, they would clear only on a blur of the trigger — and a
|
|
8
|
+
* trigger that never took the focus never blurs.
|
|
9
|
+
*/
|
|
10
|
+
export declare function clearTriggerFocusState(trigger: HTMLElement): void;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the last interaction left the focus on nothing: the body, or no element at all.
|
|
13
|
+
*
|
|
14
|
+
* An outside press on a heading, on a paragraph or on the background moves the focus to the
|
|
15
|
+
* body, and a keyboard user then has nowhere to continue from — Space and Enter open nothing.
|
|
16
|
+
* The focus returns to the trigger in that case, and only in that case: a press on a button or
|
|
17
|
+
* an input keeps the focus the user just gave it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function focusFellToBody(): boolean;
|
|
20
|
+
export type ApplyTriggerCloseFocusStateOptions = {
|
|
21
|
+
/**
|
|
22
|
+
* Whether the close reason returns the focus to the trigger on its own. An outside press
|
|
23
|
+
* never does, and it is handled here: the focus returns only when the press left it on
|
|
24
|
+
* nothing.
|
|
25
|
+
*/
|
|
26
|
+
refocus: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare function applyTriggerCloseFocusState(trigger: HTMLElement, reason: string, event: Event | undefined, options: ApplyTriggerCloseFocusStateOptions): void;
|
|
29
|
+
export declare function addTriggerBlurCleanup(trigger: HTMLElement, once?: boolean): () => void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { focusWithModality, resolveCloseInteractionModality } from './input-modality.js';
|
|
2
|
+
/**
|
|
3
|
+
* The focus state of a trigger after its floating panel closes.
|
|
4
|
+
*
|
|
5
|
+
* Shared by Popover and Menu, whose close reasons differ only in which of them return the
|
|
6
|
+
* focus to the trigger. The rule for the attributes is the same for both: the trigger shows
|
|
7
|
+
* `data-focused` and `data-focus-visible` only while it holds the focus. Written by hand for
|
|
8
|
+
* a trigger that does not hold it, they would clear only on a blur of the trigger — and a
|
|
9
|
+
* trigger that never took the focus never blurs.
|
|
10
|
+
*/
|
|
11
|
+
export function clearTriggerFocusState(trigger) {
|
|
12
|
+
delete trigger.dataset.focused;
|
|
13
|
+
delete trigger.dataset.focusVisible;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Whether the last interaction left the focus on nothing: the body, or no element at all.
|
|
17
|
+
*
|
|
18
|
+
* An outside press on a heading, on a paragraph or on the background moves the focus to the
|
|
19
|
+
* body, and a keyboard user then has nowhere to continue from — Space and Enter open nothing.
|
|
20
|
+
* The focus returns to the trigger in that case, and only in that case: a press on a button or
|
|
21
|
+
* an input keeps the focus the user just gave it.
|
|
22
|
+
*/
|
|
23
|
+
export function focusFellToBody() {
|
|
24
|
+
const active = document.activeElement;
|
|
25
|
+
return !active || active === document.body || active === document.documentElement;
|
|
26
|
+
}
|
|
27
|
+
export function applyTriggerCloseFocusState(trigger, reason, event, options) {
|
|
28
|
+
const closeModality = resolveCloseInteractionModality(reason, event);
|
|
29
|
+
if (options.refocus || (reason === 'outside-press' && focusFellToBody())) {
|
|
30
|
+
focusWithModality(trigger, closeModality);
|
|
31
|
+
}
|
|
32
|
+
const holdsFocus = document.activeElement === trigger;
|
|
33
|
+
if (holdsFocus) {
|
|
34
|
+
trigger.dataset.focused = 'true';
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
delete trigger.dataset.focused;
|
|
38
|
+
}
|
|
39
|
+
if (holdsFocus && closeModality === 'keyboard') {
|
|
40
|
+
trigger.dataset.focusVisible = 'true';
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
delete trigger.dataset.focusVisible;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function addTriggerBlurCleanup(trigger, once = false) {
|
|
47
|
+
const handleBlur = () => {
|
|
48
|
+
clearTriggerFocusState(trigger);
|
|
49
|
+
if (once) {
|
|
50
|
+
trigger.removeEventListener('blur', handleBlur);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
trigger.addEventListener('blur', handleBlur);
|
|
54
|
+
return () => {
|
|
55
|
+
trigger.removeEventListener('blur', handleBlur);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Progress
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`Progress` shows the status of a task that takes time. It holds a value between `min` and `max`, or no value while the end of the task is not known. A screen reader reads its name and its value.
|
|
6
|
+
|
|
7
|
+
## Anatomy
|
|
8
|
+
|
|
9
|
+
- `Progress.Root`
|
|
10
|
+
- `Progress.Label`
|
|
11
|
+
- `Progress.Track`
|
|
12
|
+
- `Progress.Indicator`
|
|
13
|
+
- `Progress.Value`
|
|
14
|
+
|
|
15
|
+
```svelte
|
|
16
|
+
<Progress.Root value={31}>
|
|
17
|
+
<Progress.Label>Export data</Progress.Label>
|
|
18
|
+
<Progress.Value />
|
|
19
|
+
<Progress.Track>
|
|
20
|
+
<Progress.Indicator />
|
|
21
|
+
</Progress.Track>
|
|
22
|
+
</Progress.Root>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage guidelines
|
|
26
|
+
|
|
27
|
+
- Give the bar a name with `Progress.Label`, or with `aria-label` on the root.
|
|
28
|
+
- Give `value={null}` while the end of the task is not known. Animate the indicator with CSS on `data-indeterminate`.
|
|
29
|
+
- Give `format` to show the value in a unit. Without it, the text is the position in the range as a percentage.
|
|
30
|
+
- Read `percent` and `status` from `bind:context` for a shape of your own, such as a ring.
|
|
31
|
+
- Put `aria-busy="true"` on the region that the task fills. The bar says how far the task is; it does not say what the task changes.
|
|
32
|
+
|
|
33
|
+
## API reference
|
|
34
|
+
|
|
35
|
+
- `Progress.Root`
|
|
36
|
+
- `value: number | null`
|
|
37
|
+
- `min?: number` (0), `max?: number` (100)
|
|
38
|
+
- `format?: Intl.NumberFormatOptions`
|
|
39
|
+
- `getValueText?: (formattedValue, value) => string`
|
|
40
|
+
- `aria-valuetext?: string`
|
|
41
|
+
- `orientation?: 'horizontal' | 'vertical'` (horizontal)
|
|
42
|
+
- `element?`, `context?`
|
|
43
|
+
- `Progress.Value`
|
|
44
|
+
- `children?: Snippet<[{ formattedValue, value, status }]>`
|
|
45
|
+
|
|
46
|
+
## Accessibility
|
|
47
|
+
|
|
48
|
+
- `Progress.Root` has `role="progressbar"` with `aria-valuemin`, `aria-valuemax`, `aria-valuenow` and `aria-valuetext`.
|
|
49
|
+
- An indeterminate progress has no `aria-valuenow` and no `aria-valuetext`. A number for a task with no known end would be false.
|
|
50
|
+
- `Progress.Label` writes `aria-labelledby` on the bar. An `aria-labelledby` that you give stands.
|
|
51
|
+
- `Progress.Value` is `aria-hidden`: the bar already gives the value to the screen reader.
|
|
52
|
+
- The value follows the locale of `LocaleProvider`, and the runtime locale without one.
|
|
53
|
+
- The bar takes no focus, and it has no focus state. It is not in the focus contract.
|
|
54
|
+
- The indicator fills from the start edge of the text direction: a right-to-left page fills from the right.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import type ProgressIndicatorComponent from './indicator/progress-indicator.svelte';
|
|
3
|
+
import type ProgressLabelComponent from './label/progress-label.svelte';
|
|
4
|
+
import type ProgressRootComponent from './root/progress-root.svelte';
|
|
5
|
+
import type ProgressTrackComponent from './track/progress-track.svelte';
|
|
6
|
+
import type ProgressValueComponent from './value/progress-value.svelte';
|
|
7
|
+
export * as Progress from './index.parts.js';
|
|
8
|
+
export { default as ProgressRoot } from './root/progress-root.svelte';
|
|
9
|
+
export { default as ProgressLabel } from './label/progress-label.svelte';
|
|
10
|
+
export { default as ProgressTrack } from './track/progress-track.svelte';
|
|
11
|
+
export { default as ProgressIndicator } from './indicator/progress-indicator.svelte';
|
|
12
|
+
export { default as ProgressValue } from './value/progress-value.svelte';
|
|
13
|
+
export type ProgressRootProps = ComponentProps<typeof ProgressRootComponent>;
|
|
14
|
+
export type ProgressLabelProps = ComponentProps<typeof ProgressLabelComponent>;
|
|
15
|
+
export type ProgressTrackProps = ComponentProps<typeof ProgressTrackComponent>;
|
|
16
|
+
export type ProgressIndicatorProps = ComponentProps<typeof ProgressIndicatorComponent>;
|
|
17
|
+
export type ProgressValueProps = ComponentProps<typeof ProgressValueComponent>;
|
|
18
|
+
export type { ProgressValueState } from './types.js';
|
|
19
|
+
export { getProgressContext, setProgressContext, useProgressContext, type ProgressContext, type ProgressOrientation, type ProgressStatus } from './root/context.js';
|
|
20
|
+
import * as ProgressParts from './index.parts.js';
|
|
21
|
+
export default ProgressParts;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * as Progress from './index.parts.js';
|
|
2
|
+
export { default as ProgressRoot } from './root/progress-root.svelte';
|
|
3
|
+
export { default as ProgressLabel } from './label/progress-label.svelte';
|
|
4
|
+
export { default as ProgressTrack } from './track/progress-track.svelte';
|
|
5
|
+
export { default as ProgressIndicator } from './indicator/progress-indicator.svelte';
|
|
6
|
+
export { default as ProgressValue } from './value/progress-value.svelte';
|
|
7
|
+
export { getProgressContext, setProgressContext, useProgressContext } from './root/context.js';
|
|
8
|
+
import * as ProgressParts from './index.parts.js';
|
|
9
|
+
export default ProgressParts;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Root } from './root/progress-root.svelte';
|
|
2
|
+
export { default as Label } from './label/progress-label.svelte';
|
|
3
|
+
export { default as Track } from './track/progress-track.svelte';
|
|
4
|
+
export { default as Indicator } from './indicator/progress-indicator.svelte';
|
|
5
|
+
export { default as Value } from './value/progress-value.svelte';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Root } from './root/progress-root.svelte';
|
|
2
|
+
export { default as Label } from './label/progress-label.svelte';
|
|
3
|
+
export { default as Track } from './track/progress-track.svelte';
|
|
4
|
+
export { default as Indicator } from './indicator/progress-indicator.svelte';
|
|
5
|
+
export { default as Value } from './value/progress-value.svelte';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ProgressIndicatorProps } from '../types.js';
|
|
3
|
+
import { useProgressContext } from '../root/context';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Progress.Indicator — the part of the track that the task has done.
|
|
7
|
+
*
|
|
8
|
+
* It sizes itself to the percentage: the width from the start edge of a horizontal track, and
|
|
9
|
+
* the height from the bottom of a vertical one. The start edge follows the direction of the
|
|
10
|
+
* text, thus a right-to-left page fills from the right. An indeterminate progress gets no
|
|
11
|
+
* size: your CSS animates it.
|
|
12
|
+
*/
|
|
13
|
+
let { children, class: className = '', style, ...restProps }: ProgressIndicatorProps = $props();
|
|
14
|
+
|
|
15
|
+
const progress = useProgressContext('Progress.Indicator');
|
|
16
|
+
|
|
17
|
+
const sizeStyle = $derived.by(() => {
|
|
18
|
+
if (progress.percent === null) return '';
|
|
19
|
+
if (progress.orientation === 'vertical') {
|
|
20
|
+
return `position: absolute; inset-inline: 0; bottom: 0; height: ${progress.percent}%;`;
|
|
21
|
+
}
|
|
22
|
+
return `position: absolute; inset-block: 0; inset-inline-start: 0; width: ${progress.percent}%;`;
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<div
|
|
27
|
+
{...restProps}
|
|
28
|
+
class={className}
|
|
29
|
+
style="{sizeStyle}{style ? ` ${style}` : ''}"
|
|
30
|
+
data-progress-indicator="true"
|
|
31
|
+
data-orientation={progress.orientation}
|
|
32
|
+
data-progressing={progress.status === 'progressing' || undefined}
|
|
33
|
+
data-complete={progress.status === 'complete' || undefined}
|
|
34
|
+
data-indeterminate={progress.status === 'indeterminate' || undefined}
|
|
35
|
+
>
|
|
36
|
+
{@render children?.()}
|
|
37
|
+
</div>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ProgressLabelProps } from '../types.js';
|
|
3
|
+
import { useProgressContext } from '../root/context';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Progress.Label — the name of the task.
|
|
7
|
+
*
|
|
8
|
+
* It registers its id with the root, which gives it to the progress bar as `aria-labelledby`.
|
|
9
|
+
* A bare text beside the bar leaves the bar unnamed: a `role="progressbar"` takes its name
|
|
10
|
+
* from `aria-labelledby` or `aria-label`, never from the text near it. It renders a `<span>`
|
|
11
|
+
* and not a `<label>`, because a `<label>` names a form control, and a progress bar is none.
|
|
12
|
+
*/
|
|
13
|
+
let { children, class: className = '', id: idProp, ...restProps }: ProgressLabelProps = $props();
|
|
14
|
+
|
|
15
|
+
const progress = useProgressContext('Progress.Label');
|
|
16
|
+
const generatedId = $props.id();
|
|
17
|
+
const id = $derived(idProp ?? generatedId);
|
|
18
|
+
|
|
19
|
+
// The returned unregister runs on destroy, and again whenever the id changes.
|
|
20
|
+
$effect(() => progress.registerLabel(id));
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<span
|
|
24
|
+
{...restProps}
|
|
25
|
+
{id}
|
|
26
|
+
class={className}
|
|
27
|
+
data-progress-label="true"
|
|
28
|
+
data-orientation={progress.orientation}
|
|
29
|
+
data-progressing={progress.status === 'progressing' || undefined}
|
|
30
|
+
data-complete={progress.status === 'complete' || undefined}
|
|
31
|
+
data-indeterminate={progress.status === 'indeterminate' || undefined}
|
|
32
|
+
>
|
|
33
|
+
{@render children?.()}
|
|
34
|
+
</span>
|