@human-kit/ui 1.0.0-beta.1 → 1.0.0-beta.11
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 +27 -16
- package/dist/FOCUS_STATE_CONTRACT.md +17 -4
- package/dist/FOCUS_STATE_REVIEW_TEMPLATE.md +8 -8
- package/dist/accordion/README.md +3 -3
- package/dist/accordion/types.d.ts +37 -23
- 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 +5 -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/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 +118 -40
- package/dist/checkbox/root/checkbox-root.svelte.d.ts +17 -10
- 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/wheel-column/clock-wheel-column.svelte +1 -1
- package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +1 -1
- package/dist/collapsible/README.md +3 -3
- package/dist/collapsible/types.d.ts +10 -7
- 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 +3 -3
- 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 +11 -8
- package/dist/combobox/list/combobox-listbox.svelte.d.ts +14 -9
- 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 +26 -17
- package/dist/combobox/root/combobox.svelte.d.ts +26 -17
- package/dist/combobox/status/README.md +1 -1
- 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 +4 -5
- package/dist/combobox/tag-remove/combobox-tag-remove.svelte.d.ts +4 -5
- package/dist/combobox/tags/README.md +1 -1
- package/dist/combobox/tags/combobox-tags.svelte +11 -11
- package/dist/combobox/tags/combobox-tags.svelte.d.ts +11 -11
- package/dist/combobox/trigger/README.md +7 -7
- package/dist/datepicker/README.md +4 -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 +1 -1
- 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/dialog/README.md +1 -1
- package/dist/dialog/close/dialog-close.svelte +3 -3
- package/dist/dialog/close/dialog-close.svelte.d.ts +3 -3
- package/dist/dialog/content/dialog-content.svelte +4 -4
- package/dist/dialog/content/dialog-content.svelte.d.ts +4 -4
- package/dist/dialog/description/dialog-description.svelte +3 -3
- package/dist/dialog/description/dialog-description.svelte.d.ts +3 -3
- 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/dialog-root.svelte +49 -11
- package/dist/dialog/root/dialog-root.svelte.d.ts +11 -9
- package/dist/dialog/title/dialog-title.svelte +3 -3
- package/dist/dialog/title/dialog-title.svelte.d.ts +3 -3
- package/dist/dialog/trigger/README.md +1 -1
- package/dist/drawer/README.md +3 -3
- package/dist/drawer/body/drawer-body.svelte +2 -2
- package/dist/drawer/body/drawer-body.svelte.d.ts +2 -2
- package/dist/drawer/close/drawer-close.svelte +3 -3
- package/dist/drawer/close/drawer-close.svelte.d.ts +3 -3
- package/dist/drawer/content/drawer-content.svelte +12 -9
- package/dist/drawer/content/drawer-content.svelte.d.ts +12 -9
- package/dist/drawer/description/drawer-description.svelte +3 -3
- package/dist/drawer/description/drawer-description.svelte.d.ts +3 -3
- package/dist/drawer/indent/drawer-indent-background.svelte +1 -1
- package/dist/drawer/indent/drawer-indent-background.svelte.d.ts +1 -1
- package/dist/drawer/indent/drawer-indent.svelte +2 -2
- package/dist/drawer/indent/drawer-indent.svelte.d.ts +2 -2
- package/dist/drawer/overlay/drawer-overlay.svelte +1 -1
- package/dist/drawer/overlay/drawer-overlay.svelte.d.ts +1 -1
- package/dist/drawer/portal/drawer-portal.svelte +1 -1
- package/dist/drawer/portal/drawer-portal.svelte.d.ts +1 -1
- package/dist/drawer/root/context.d.ts +1 -1
- package/dist/drawer/root/drawer-root.svelte +40 -25
- package/dist/drawer/root/drawer-root.svelte.d.ts +25 -23
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte +3 -3
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte.d.ts +3 -3
- package/dist/drawer/title/drawer-title.svelte +3 -3
- package/dist/drawer/title/drawer-title.svelte.d.ts +3 -3
- package/dist/drawer/trigger/drawer-trigger.svelte +6 -6
- package/dist/drawer/trigger/drawer-trigger.svelte.d.ts +6 -6
- package/dist/drawer/viewport/drawer-viewport.svelte +2 -2
- package/dist/drawer/viewport/drawer-viewport.svelte.d.ts +2 -2
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte +1 -1
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte.d.ts +1 -1
- package/dist/dropzone/README.md +4 -6
- package/dist/index.d.ts +22 -0
- package/dist/index.js +21 -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 +35 -17
- 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 +26 -1
- package/dist/listbox/root/context.js +108 -1
- package/dist/listbox/root/listbox.svelte +129 -39
- package/dist/listbox/root/listbox.svelte.d.ts +57 -33
- package/dist/locale-provider/README.md +1 -6
- package/dist/menu/README.md +41 -4
- package/dist/menu/content/menu-content.svelte +28 -13
- 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 +1 -1
- 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-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 +21 -15
- package/dist/popover/content/popover-content.svelte.d.ts +19 -14
- package/dist/popover/overlay/popover-overlay.svelte +1 -1
- 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 +13 -10
- package/dist/popover/root/popover-root.svelte.d.ts +13 -10
- 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 +42 -8
- package/dist/primitives/floating.js +70 -6
- 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 +2 -0
- package/dist/primitives/index.js +2 -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 +24 -16
- 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 +24 -0
- package/dist/primitives/scroll-lock.js +75 -6
- 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 +32 -18
- package/dist/switch/root/switch-root.svelte.d.ts +23 -18
- 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/cell/table-cell.svelte +27 -8
- package/dist/table/checkbox/table-checkbox.svelte +3 -0
- package/dist/table/checkbox-indicator/README.md +1 -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/index.d.ts +1 -1
- package/dist/table/index.js +1 -1
- package/dist/table/interactive-cell/table-interactive-cell.svelte +26 -8
- 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 +113 -17
- package/dist/table/root/table-root.svelte +36 -6
- package/dist/table/row/table-row.svelte +7 -7
- package/dist/table/sort-trigger/README.md +1 -1
- package/dist/table/types.d.ts +26 -14
- package/dist/tabs/types.d.ts +6 -6
- 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/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 +20 -11
- package/dist/toggle-group/root/toggle-group-root.svelte +20 -15
- 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 -9
- 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 +459 -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/types.d.ts +19 -10
- package/package.json +56 -1
|
@@ -15,7 +15,13 @@ import { TOP_LAYER_SELECTOR } from './click-outside';
|
|
|
15
15
|
* region staying reachable behind a modal — is intentional: status/alert content is transient
|
|
16
16
|
* and announcing it is the whole point.
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* An element that opts out of the hide, without being a live region itself: a toast viewport,
|
|
20
|
+
* whose toasts are announced by a live region beside it, but whose buttons must stay reachable
|
|
21
|
+
* behind a modal.
|
|
22
|
+
*/
|
|
23
|
+
export const HIDE_OUTSIDE_EXEMPT_ATTRIBUTE = 'data-hk-hide-outside-exempt';
|
|
24
|
+
const LIVE_REGION_SELECTOR = `[aria-live], [role="status"], [role="alert"], [role="log"], [${HIDE_OUTSIDE_EXEMPT_ATTRIBUTE}]`;
|
|
19
25
|
/**
|
|
20
26
|
* Elements the MutationObserver must never hide when they appear while a modal is active:
|
|
21
27
|
* - top layers (dialog/popover/menu — the shared `TOP_LAYER_SELECTOR` from click-outside):
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps a wheel event inside a floating panel.
|
|
3
|
+
*
|
|
4
|
+
* A non-modal popover closes when the page scrolls under it, and a wheel over a list that
|
|
5
|
+
* has reached its end would scroll the page. So the event scrolls the panel, or a scrollable
|
|
6
|
+
* element inside it, while one of them can still move in that direction, and it is consumed
|
|
7
|
+
* otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare function containWheel(event: WheelEvent, panel: HTMLElement): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function canElementScrollInDirection(element, deltaY) {
|
|
2
|
+
const isScrollingDown = deltaY > 0;
|
|
3
|
+
const isScrollingUp = deltaY < 0;
|
|
4
|
+
const canScrollDown = element.scrollTop < element.scrollHeight - element.clientHeight;
|
|
5
|
+
const canScrollUp = element.scrollTop > 0;
|
|
6
|
+
return (isScrollingDown && canScrollDown) || (isScrollingUp && canScrollUp);
|
|
7
|
+
}
|
|
8
|
+
function isScrollableElement(element) {
|
|
9
|
+
const { overflowY } = getComputedStyle(element);
|
|
10
|
+
return (['auto', 'scroll', 'overlay'].includes(overflowY) && element.scrollHeight > element.clientHeight);
|
|
11
|
+
}
|
|
12
|
+
function hasScrollableDescendantForWheel(boundary, target, deltaY) {
|
|
13
|
+
let current = target instanceof HTMLElement ? target : target instanceof Node ? target.parentElement : null;
|
|
14
|
+
while (current) {
|
|
15
|
+
if (isScrollableElement(current) && canElementScrollInDirection(current, deltaY)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (current === boundary) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
current = current.parentElement;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Keeps a wheel event inside a floating panel.
|
|
27
|
+
*
|
|
28
|
+
* A non-modal popover closes when the page scrolls under it, and a wheel over a list that
|
|
29
|
+
* has reached its end would scroll the page. So the event scrolls the panel, or a scrollable
|
|
30
|
+
* element inside it, while one of them can still move in that direction, and it is consumed
|
|
31
|
+
* otherwise.
|
|
32
|
+
*/
|
|
33
|
+
export function containWheel(event, panel) {
|
|
34
|
+
if (hasScrollableDescendantForWheel(panel, event.target, event.deltaY) ||
|
|
35
|
+
(isScrollableElement(panel) && canElementScrollInDirection(panel, event.deltaY))) {
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
event.stopPropagation();
|
|
41
|
+
}
|
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
import { type Placement as FloatingPlacement } from '@floating-ui/dom';
|
|
1
|
+
import { type Placement as FloatingPlacement, type VirtualElement } from '@floating-ui/dom';
|
|
2
|
+
/**
|
|
3
|
+
* What a floating panel can be positioned against: a real element, or a virtual
|
|
4
|
+
* one — an object that only knows how to report a rect. Floating UI supports
|
|
5
|
+
* both natively, in `computePosition` and in `autoUpdate` (which checks for a
|
|
6
|
+
* real element before observing it for resizes, and falls back to the virtual
|
|
7
|
+
* element's `contextElement` for the ancestor scroll listeners).
|
|
8
|
+
*/
|
|
9
|
+
export type FloatingAnchor = HTMLElement | VirtualElement | null;
|
|
10
|
+
/**
|
|
11
|
+
* A zero-size anchor at a viewport point, for panels that follow the pointer
|
|
12
|
+
* instead of an element — a context menu at the cursor, a toolbar at a text
|
|
13
|
+
* selection.
|
|
14
|
+
*
|
|
15
|
+
* `contextElement` should be the surface the point was measured on: without it
|
|
16
|
+
* `autoUpdate` has no node whose scroll ancestors it can watch, so the panel
|
|
17
|
+
* would not track a scrolling container.
|
|
18
|
+
*
|
|
19
|
+
* Coordinates are viewport-relative (`clientX`/`clientY`) and positioning uses
|
|
20
|
+
* the `fixed` strategy, so the panel stays where the pointer was — which is what
|
|
21
|
+
* a native context menu does.
|
|
22
|
+
*
|
|
23
|
+
* Because the rect has no size, `--trigger-width` / `--trigger-height` resolve to
|
|
24
|
+
* `0px` on the panel. Everything else (`flip`, `shift`, `size`, the
|
|
25
|
+
* `--available-*` custom properties and `--transform-origin`) works unchanged,
|
|
26
|
+
* which is the whole reason to go through Floating UI rather than assigning
|
|
27
|
+
* `left`/`top` by hand.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createPointAnchor(x: number, y: number, contextElement?: Element | null): VirtualElement;
|
|
2
30
|
/**
|
|
3
31
|
* Placement options for floating elements.
|
|
4
32
|
* Follows the specification with logical 'start'/'end' values.
|
|
@@ -14,11 +42,11 @@ export type ExtendedPlacement = Placement | 'bottom left' | 'bottom right' | 'to
|
|
|
14
42
|
export type FloatingOptions = {
|
|
15
43
|
/** Offset along the main axis from the anchor. */
|
|
16
44
|
offset?: number;
|
|
17
|
-
/**
|
|
45
|
+
/** The position against the anchor element. */
|
|
18
46
|
placement?: ExtendedPlacement;
|
|
19
|
-
/**
|
|
47
|
+
/** Moves the panel to the opposite side when the space is not sufficient. */
|
|
20
48
|
shouldFlip?: boolean;
|
|
21
|
-
/**
|
|
49
|
+
/** The element that gives the limits of the position. */
|
|
22
50
|
boundaryElement?: Element | null;
|
|
23
51
|
/**
|
|
24
52
|
* Minimum gap kept between the floating element and the boundary edges, in
|
|
@@ -27,6 +55,12 @@ export type FloatingOptions = {
|
|
|
27
55
|
* so a panel that shrinks to fit still leaves the gutter visible.
|
|
28
56
|
*/
|
|
29
57
|
collisionPadding?: number;
|
|
58
|
+
/**
|
|
59
|
+
* An arrow element inside the floating element. The action moves it along the edge that faces
|
|
60
|
+
* the anchor, with `left` or `top`, and it writes the side in `data-placement`. The offset from
|
|
61
|
+
* that edge is for the CSS of the arrow.
|
|
62
|
+
*/
|
|
63
|
+
arrow?: HTMLElement | null;
|
|
30
64
|
/** Callback when position is updated. */
|
|
31
65
|
onPositionUpdate?: (x: number, y: number, placement: FloatingPlacement) => void;
|
|
32
66
|
};
|
|
@@ -40,9 +74,9 @@ export type FloatingOptions = {
|
|
|
40
74
|
* - `--available-height`: Available height between trigger and viewport edge
|
|
41
75
|
* - `--transform-origin`: Coordinates for animations (e.g., "center top")
|
|
42
76
|
*/
|
|
43
|
-
export declare function createFloating(anchorElement:
|
|
77
|
+
export declare function createFloating(anchorElement: FloatingAnchor, options?: FloatingOptions): (floatingElement: HTMLElement) => {
|
|
44
78
|
update(newOptions: {
|
|
45
|
-
anchor:
|
|
79
|
+
anchor: FloatingAnchor;
|
|
46
80
|
} & FloatingOptions): void;
|
|
47
81
|
destroy(): void;
|
|
48
82
|
};
|
|
@@ -58,10 +92,10 @@ export declare function createFloating(anchorElement: HTMLElement | null, option
|
|
|
58
92
|
* - `--transform-origin`: Coordinates for animations (e.g., "center top")
|
|
59
93
|
*/
|
|
60
94
|
export declare function floating(floatingElement: HTMLElement, options: {
|
|
61
|
-
anchor:
|
|
95
|
+
anchor: FloatingAnchor;
|
|
62
96
|
} & FloatingOptions): {
|
|
63
97
|
update(newOptions: {
|
|
64
|
-
anchor:
|
|
98
|
+
anchor: FloatingAnchor;
|
|
65
99
|
} & FloatingOptions): void;
|
|
66
100
|
destroy(): void;
|
|
67
101
|
};
|
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
import { computePosition, flip, shift, offset as offsetMiddleware, size, autoUpdate } from '@floating-ui/dom';
|
|
1
|
+
import { arrow as arrowMiddleware, computePosition, flip, shift, limitShift, offset as offsetMiddleware, size, autoUpdate } from '@floating-ui/dom';
|
|
2
|
+
/**
|
|
3
|
+
* A zero-size anchor at a viewport point, for panels that follow the pointer
|
|
4
|
+
* instead of an element — a context menu at the cursor, a toolbar at a text
|
|
5
|
+
* selection.
|
|
6
|
+
*
|
|
7
|
+
* `contextElement` should be the surface the point was measured on: without it
|
|
8
|
+
* `autoUpdate` has no node whose scroll ancestors it can watch, so the panel
|
|
9
|
+
* would not track a scrolling container.
|
|
10
|
+
*
|
|
11
|
+
* Coordinates are viewport-relative (`clientX`/`clientY`) and positioning uses
|
|
12
|
+
* the `fixed` strategy, so the panel stays where the pointer was — which is what
|
|
13
|
+
* a native context menu does.
|
|
14
|
+
*
|
|
15
|
+
* Because the rect has no size, `--trigger-width` / `--trigger-height` resolve to
|
|
16
|
+
* `0px` on the panel. Everything else (`flip`, `shift`, `size`, the
|
|
17
|
+
* `--available-*` custom properties and `--transform-origin`) works unchanged,
|
|
18
|
+
* which is the whole reason to go through Floating UI rather than assigning
|
|
19
|
+
* `left`/`top` by hand.
|
|
20
|
+
*/
|
|
21
|
+
export function createPointAnchor(x, y, contextElement) {
|
|
22
|
+
return {
|
|
23
|
+
getBoundingClientRect: () => new DOMRect(x, y, 0, 0),
|
|
24
|
+
...(contextElement ? { contextElement } : {})
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function isVirtualAnchor(anchor) {
|
|
28
|
+
return anchor !== null && !(anchor instanceof Element);
|
|
29
|
+
}
|
|
2
30
|
/** Viewport gutter applied when no `collisionPadding` is given. */
|
|
3
31
|
const DEFAULT_COLLISION_PADDING = 8;
|
|
4
32
|
/**
|
|
@@ -108,7 +136,25 @@ export function floating(floatingElement, options) {
|
|
|
108
136
|
return [
|
|
109
137
|
offsetMiddleware(offset),
|
|
110
138
|
...(shouldFlip ? [flip({ boundary: boundaryElement || undefined, padding })] : []),
|
|
111
|
-
shift
|
|
139
|
+
// `shift`'s main axis is the one running ALONG the placement edge, and its
|
|
140
|
+
// cross axis is off by default. For `top`/`bottom` that main axis is x, so a
|
|
141
|
+
// dropdown too wide for the viewport is pulled back into view. For
|
|
142
|
+
// `left`/`right` it is y — nothing pulls it back horizontally, so a panel
|
|
143
|
+
// that fits on neither side stays wherever the placement put it, which for
|
|
144
|
+
// `left-*` means off the left edge entirely.
|
|
145
|
+
//
|
|
146
|
+
// Submenus are exactly that case: they open `right-start` and flip to
|
|
147
|
+
// `left-start`, and on a narrow viewport neither side has room. Enabled only
|
|
148
|
+
// for the horizontal placements, because on `top`/`bottom` the cross axis is
|
|
149
|
+
// vertical and shifting there would slide a dropdown over its own trigger —
|
|
150
|
+
// which `flip` already handles better. `limitShift` keeps the panel from
|
|
151
|
+
// sliding so far that it detaches from its anchor.
|
|
152
|
+
shift((state) => ({
|
|
153
|
+
boundary: boundaryElement || undefined,
|
|
154
|
+
padding,
|
|
155
|
+
crossAxis: state.placement.startsWith('left') || state.placement.startsWith('right'),
|
|
156
|
+
limiter: limitShift()
|
|
157
|
+
})),
|
|
112
158
|
size({
|
|
113
159
|
padding,
|
|
114
160
|
apply({ rects, availableWidth, availableHeight, elements, placement }) {
|
|
@@ -123,14 +169,21 @@ export function floating(floatingElement, options) {
|
|
|
123
169
|
floatingEl.style.maxWidth = `${clampedAvailableWidth}px`;
|
|
124
170
|
floatingEl.style.maxHeight = `${clampedAvailableHeight}px`;
|
|
125
171
|
}
|
|
126
|
-
})
|
|
172
|
+
}),
|
|
173
|
+
...(currentOptions.arrow ? [arrowMiddleware({ element: currentOptions.arrow })] : [])
|
|
127
174
|
];
|
|
128
175
|
}
|
|
176
|
+
function applyArrowPosition(arrowElement, data, finalPlacement) {
|
|
177
|
+
const side = finalPlacement.split('-')[0];
|
|
178
|
+
arrowElement.dataset.placement = side;
|
|
179
|
+
arrowElement.style.left = data?.x !== undefined ? `${data.x}px` : '';
|
|
180
|
+
arrowElement.style.top = data?.y !== undefined ? `${data.y}px` : '';
|
|
181
|
+
}
|
|
129
182
|
async function updatePosition() {
|
|
130
183
|
const anchor = currentOptions.anchor;
|
|
131
184
|
if (!anchor || !floatingElement)
|
|
132
185
|
return;
|
|
133
|
-
const { x, y, placement: finalPlacement } = await computePosition(anchor, floatingElement, {
|
|
186
|
+
const { x, y, placement: finalPlacement, middlewareData } = await computePosition(anchor, floatingElement, {
|
|
134
187
|
placement: normalizeExtendedPlacement(currentOptions.placement || 'bottom'),
|
|
135
188
|
middleware: buildMiddleware(),
|
|
136
189
|
strategy: 'fixed' // Use fixed strategy for portal-rendered elements
|
|
@@ -139,6 +192,9 @@ export function floating(floatingElement, options) {
|
|
|
139
192
|
left: `${x}px`,
|
|
140
193
|
top: `${y}px`
|
|
141
194
|
});
|
|
195
|
+
if (currentOptions.arrow) {
|
|
196
|
+
applyArrowPosition(currentOptions.arrow, middlewareData.arrow, finalPlacement);
|
|
197
|
+
}
|
|
142
198
|
currentOptions.onPositionUpdate?.(x, y, finalPlacement);
|
|
143
199
|
}
|
|
144
200
|
function stop() {
|
|
@@ -156,13 +212,21 @@ export function floating(floatingElement, options) {
|
|
|
156
212
|
return {
|
|
157
213
|
update(newOptions) {
|
|
158
214
|
const anchorChanged = newOptions.anchor !== currentOptions.anchor;
|
|
215
|
+
// Two virtual anchors on the same context element are two points on one surface: a
|
|
216
|
+
// panel that follows the pointer makes one per move. The listeners of `autoUpdate`
|
|
217
|
+
// are on the context element, thus they stay, and only the position runs again.
|
|
218
|
+
const sameSurface = anchorChanged &&
|
|
219
|
+
isVirtualAnchor(newOptions.anchor) &&
|
|
220
|
+
isVirtualAnchor(currentOptions.anchor) &&
|
|
221
|
+
newOptions.anchor.contextElement !== undefined &&
|
|
222
|
+
newOptions.anchor.contextElement === currentOptions.anchor.contextElement;
|
|
159
223
|
currentOptions = newOptions;
|
|
160
|
-
if (anchorChanged) {
|
|
224
|
+
if (anchorChanged && !(sameSurface && cleanup)) {
|
|
161
225
|
// Re-subscribe autoUpdate to the new anchor (or stop when it's gone).
|
|
162
226
|
start();
|
|
163
227
|
}
|
|
164
228
|
else if (cleanup) {
|
|
165
|
-
// Same anchor, new placement/offset/boundary: reposition immediately.
|
|
229
|
+
// Same anchor, new placement/offset/boundary/arrow: reposition immediately.
|
|
166
230
|
void updatePosition();
|
|
167
231
|
}
|
|
168
232
|
},
|
|
@@ -7,6 +7,8 @@ export type FocusTrapOptions = {
|
|
|
7
7
|
restoreFocus?: boolean;
|
|
8
8
|
initialFocus?: HTMLElement | string | (() => HTMLElement | null | undefined);
|
|
9
9
|
};
|
|
10
|
+
/** The elements in `container` that a `Tab` can reach, in DOM order. */
|
|
11
|
+
export declare function getFocusableElements(container: HTMLElement): HTMLElement[];
|
|
10
12
|
/**
|
|
11
13
|
* Svelte action that traps focus within an element.
|
|
12
14
|
*
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Focus trap primitive.
|
|
3
3
|
* Traps keyboard focus within a container element.
|
|
4
4
|
*/
|
|
5
|
+
import { HIDE_OUTSIDE_EXEMPT_ATTRIBUTE } from './aria-hide-outside';
|
|
5
6
|
import { focusWithModality, getInteractionModality } from './input-modality';
|
|
6
7
|
const FOCUSABLE_SELECTOR = [
|
|
7
8
|
'a[href]',
|
|
@@ -49,7 +50,8 @@ function resolveInitialFocus(container, initialFocus) {
|
|
|
49
50
|
}
|
|
50
51
|
return initialFocus;
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
/** The elements in `container` that a `Tab` can reach, in DOM order. */
|
|
54
|
+
export function getFocusableElements(container) {
|
|
53
55
|
return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)).filter((element) =>
|
|
54
56
|
// getClientRects covers display:none and detached nodes while still
|
|
55
57
|
// accepting position:fixed descendants (whose offsetParent is null).
|
|
@@ -81,6 +83,10 @@ export function focusTrap(node, options = true) {
|
|
|
81
83
|
// nested overlay must not intercept it.
|
|
82
84
|
if (!isTopmostTrap(node))
|
|
83
85
|
return;
|
|
86
|
+
// A surface that stays reachable behind the modal, such as a toast viewport, manages its
|
|
87
|
+
// own Tab while the focus is in it, and sends the focus back on its own.
|
|
88
|
+
if (document.activeElement?.closest(`[${HIDE_OUTSIDE_EXEMPT_ATTRIBUTE}]`))
|
|
89
|
+
return;
|
|
84
90
|
const focusableElements = getFocusableElements(node);
|
|
85
91
|
if (focusableElements.length === 0) {
|
|
86
92
|
event.preventDefault();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps a `focusVisible` value honest while the element holds focus.
|
|
3
|
+
*
|
|
4
|
+
* `shouldShowFocusVisible` reads the modality at the moment it is called, so a component that
|
|
5
|
+
* only calls it from its focus handler holds a snapshot. A pointer press seeds `false`, and a
|
|
6
|
+
* key press after it flips the modality — and the `:focus-visible` of the browser — with nothing
|
|
7
|
+
* to tell the component. This subscribes for as long as the element has focus, and it re-reads
|
|
8
|
+
* on each change, which is what React Aria and Base UI do.
|
|
9
|
+
*/
|
|
10
|
+
export declare function watchFocusVisible(options: {
|
|
11
|
+
isFocused: () => boolean;
|
|
12
|
+
element: () => HTMLElement | null;
|
|
13
|
+
set: (focusVisible: boolean) => void;
|
|
14
|
+
}): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { shouldShowFocusVisible, subscribeInputModality } from './input-modality.js';
|
|
2
|
+
/**
|
|
3
|
+
* Keeps a `focusVisible` value honest while the element holds focus.
|
|
4
|
+
*
|
|
5
|
+
* `shouldShowFocusVisible` reads the modality at the moment it is called, so a component that
|
|
6
|
+
* only calls it from its focus handler holds a snapshot. A pointer press seeds `false`, and a
|
|
7
|
+
* key press after it flips the modality — and the `:focus-visible` of the browser — with nothing
|
|
8
|
+
* to tell the component. This subscribes for as long as the element has focus, and it re-reads
|
|
9
|
+
* on each change, which is what React Aria and Base UI do.
|
|
10
|
+
*/
|
|
11
|
+
export function watchFocusVisible(options) {
|
|
12
|
+
$effect(() => {
|
|
13
|
+
if (!options.isFocused())
|
|
14
|
+
return;
|
|
15
|
+
return subscribeInputModality(() => {
|
|
16
|
+
options.set(shouldShowFocusVisible(options.element()));
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -6,4 +6,6 @@ export * from './scroll-lock.js';
|
|
|
6
6
|
export * from './aria-hide-outside.js';
|
|
7
7
|
export * from './click-outside.js';
|
|
8
8
|
export * from './input-modality.js';
|
|
9
|
+
export * from './focus-visible.svelte.js';
|
|
10
|
+
export * from './long-press.js';
|
|
9
11
|
export * from './swipe-gesture.js';
|
package/dist/primitives/index.js
CHANGED
|
@@ -7,4 +7,6 @@ export * from './scroll-lock.js';
|
|
|
7
7
|
export * from './aria-hide-outside.js';
|
|
8
8
|
export * from './click-outside.js';
|
|
9
9
|
export * from './input-modality.js';
|
|
10
|
+
export * from './focus-visible.svelte.js';
|
|
11
|
+
export * from './long-press.js';
|
|
10
12
|
export * from './swipe-gesture.js';
|
|
@@ -2,6 +2,13 @@ export type InputModality = 'keyboard' | 'pointer' | 'virtual';
|
|
|
2
2
|
export declare function initInputModality(target?: HTMLElement | null): void;
|
|
3
3
|
export declare function trackInteractionModality(event?: Event, target?: HTMLElement | null): void;
|
|
4
4
|
export declare function getInteractionModality(): InputModality;
|
|
5
|
+
/**
|
|
6
|
+
* Calls `listener` whenever the interaction modality changes, and returns the unsubscribe
|
|
7
|
+
* function. Components use it to re-read `shouldShowFocusVisible` for an element that already
|
|
8
|
+
* holds focus: the browser re-evaluates `:focus-visible` on its own, and this is what lets a
|
|
9
|
+
* component notice.
|
|
10
|
+
*/
|
|
11
|
+
export declare function subscribeInputModality(listener: (modality: InputModality) => void): () => void;
|
|
5
12
|
export declare function shouldShowFocusVisible(target: HTMLElement | null): boolean;
|
|
6
13
|
export declare function focusWithModality(target: HTMLElement, modality: InputModality, options?: FocusOptions): void;
|
|
7
14
|
export declare function resolveCloseInteractionModality(reason: string, event?: Event): InputModality;
|
|
@@ -8,6 +8,20 @@ let currentModality = 'virtual';
|
|
|
8
8
|
const RECENT_INPUT_WINDOW_MS = 50;
|
|
9
9
|
let lastInputEventTime = Number.NEGATIVE_INFINITY;
|
|
10
10
|
const listenedWindows = new WeakSet();
|
|
11
|
+
/**
|
|
12
|
+
* Notified whenever the modality changes. `data-focus-visible` is otherwise a snapshot taken
|
|
13
|
+
* when the element took focus, so a pointer press followed by a key press left the ring off
|
|
14
|
+
* while the browser had already flipped `:focus-visible` back on.
|
|
15
|
+
*/
|
|
16
|
+
const modalityListeners = new Set();
|
|
17
|
+
function setModality(next) {
|
|
18
|
+
if (currentModality === next)
|
|
19
|
+
return;
|
|
20
|
+
currentModality = next;
|
|
21
|
+
for (const listener of [...modalityListeners]) {
|
|
22
|
+
listener(next);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
11
25
|
let forcedFocusTarget = null;
|
|
12
26
|
let forcedFocusModality = null;
|
|
13
27
|
function isModifierOnlyKey(event) {
|
|
@@ -29,11 +43,11 @@ function ensureWindowListeners(win) {
|
|
|
29
43
|
lastInputEventTime = Date.now();
|
|
30
44
|
if (!isKeyboardModalityKey(event))
|
|
31
45
|
return;
|
|
32
|
-
|
|
46
|
+
setModality('keyboard');
|
|
33
47
|
};
|
|
34
48
|
const onPointerDown = () => {
|
|
35
49
|
lastInputEventTime = Date.now();
|
|
36
|
-
|
|
50
|
+
setModality('pointer');
|
|
37
51
|
};
|
|
38
52
|
const onFocusIn = (event) => {
|
|
39
53
|
// A programmatic focus with an explicit modality (`focusWithModality`) must keep it —
|
|
@@ -45,7 +59,7 @@ function ensureWindowListeners(win) {
|
|
|
45
59
|
return;
|
|
46
60
|
// No recent keyboard/pointer input: this focus move came from an assistive technology
|
|
47
61
|
// (or a script), so focus rings must show again.
|
|
48
|
-
|
|
62
|
+
setModality('virtual');
|
|
49
63
|
};
|
|
50
64
|
win.addEventListener('keydown', onKeyDown, true);
|
|
51
65
|
win.addEventListener('pointerdown', onPointerDown, true);
|
|
@@ -90,12 +104,25 @@ export function trackInteractionModality(event, target) {
|
|
|
90
104
|
initInputModality(target);
|
|
91
105
|
const inferred = inferModalityFromEvent(event);
|
|
92
106
|
if (inferred) {
|
|
93
|
-
|
|
107
|
+
setModality(inferred);
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
export function getInteractionModality() {
|
|
97
111
|
return currentModality;
|
|
98
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Calls `listener` whenever the interaction modality changes, and returns the unsubscribe
|
|
115
|
+
* function. Components use it to re-read `shouldShowFocusVisible` for an element that already
|
|
116
|
+
* holds focus: the browser re-evaluates `:focus-visible` on its own, and this is what lets a
|
|
117
|
+
* component notice.
|
|
118
|
+
*/
|
|
119
|
+
export function subscribeInputModality(listener) {
|
|
120
|
+
initInputModality();
|
|
121
|
+
modalityListeners.add(listener);
|
|
122
|
+
return () => {
|
|
123
|
+
modalityListeners.delete(listener);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
99
126
|
export function shouldShowFocusVisible(target) {
|
|
100
127
|
if (!target)
|
|
101
128
|
return false;
|
|
@@ -111,7 +138,7 @@ export function focusWithModality(target, modality, options) {
|
|
|
111
138
|
// If it is consumed later, currentModality still preserves the same modality as fallback.
|
|
112
139
|
forcedFocusTarget = target;
|
|
113
140
|
forcedFocusModality = modality;
|
|
114
|
-
|
|
141
|
+
setModality(modality);
|
|
115
142
|
if (modality === 'pointer') {
|
|
116
143
|
const pointerFocusOptions = {
|
|
117
144
|
...(options ?? {}),
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { type Writable } from 'svelte/store';
|
|
2
2
|
export type KeyboardNavigationOrientation = 'vertical' | 'horizontal' | 'both';
|
|
3
|
+
/**
|
|
4
|
+
* Why the focus moved, for consumers that do more than move a highlight.
|
|
5
|
+
*
|
|
6
|
+
* `extend` is set when the key was pressed with Shift held — the multi-select
|
|
7
|
+
* listbox pattern, where arrowing extends the selection from an anchor instead of
|
|
8
|
+
* just walking it. Programmatic moves (`focusNext()`, `focusById()`) carry no
|
|
9
|
+
* intent at all, so a consumer that ignores this argument behaves exactly as before.
|
|
10
|
+
*/
|
|
11
|
+
export type NavigationIntent = {
|
|
12
|
+
extend?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The item focus moved away from. Reported because the consumer cannot recover it
|
|
15
|
+
* afterwards: `focusItem` focuses the element before it notifies, and the focused
|
|
16
|
+
* element's own `focus` handler has already overwritten the consumer's idea of where
|
|
17
|
+
* focus was by the time this runs.
|
|
18
|
+
*/
|
|
19
|
+
from?: string | number | null;
|
|
20
|
+
};
|
|
3
21
|
export type KeyboardNavigationOptions = {
|
|
4
22
|
/**
|
|
5
23
|
* Orientation of the navigation
|
|
@@ -26,7 +44,7 @@ export type KeyboardNavigationOptions = {
|
|
|
26
44
|
/**
|
|
27
45
|
* Callback when focused item changes
|
|
28
46
|
*/
|
|
29
|
-
onFocusChange?: (id: string | number | null, element: HTMLElement | null) => void;
|
|
47
|
+
onFocusChange?: (id: string | number | null, element: HTMLElement | null, intent?: NavigationIntent) => void;
|
|
30
48
|
/**
|
|
31
49
|
* Callback for Ctrl+A (select all)
|
|
32
50
|
*/
|
|
@@ -53,14 +71,20 @@ export type KeyboardNavigationReturn = {
|
|
|
53
71
|
destroy: () => void;
|
|
54
72
|
};
|
|
55
73
|
/** Programmatic navigation methods */
|
|
56
|
-
focusNext: () => void;
|
|
57
|
-
focusPrevious: () => void;
|
|
58
|
-
focusFirst: () => void;
|
|
59
|
-
focusLast: () => void;
|
|
74
|
+
focusNext: (intent?: NavigationIntent) => void;
|
|
75
|
+
focusPrevious: (intent?: NavigationIntent) => void;
|
|
76
|
+
focusFirst: (intent?: NavigationIntent) => void;
|
|
77
|
+
focusLast: (intent?: NavigationIntent) => void;
|
|
60
78
|
focusById: (id: string | number) => void;
|
|
61
79
|
setCurrentId: (id: string | number | null) => void;
|
|
62
80
|
/** Update items (call after DOM changes) */
|
|
63
81
|
updateItems: () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Searches with a printable character, the same as a key press on the container. For a
|
|
84
|
+
* widget that opens on a character typed outside the container, such as a select: the
|
|
85
|
+
* character is applied once the items exist.
|
|
86
|
+
*/
|
|
87
|
+
typeahead: (char: string) => void;
|
|
64
88
|
};
|
|
65
89
|
/**
|
|
66
90
|
* Creates a keyboard navigation controller for list-like components.
|
|
@@ -95,11 +95,14 @@ export function createKeyboardNavigation(options = {}) {
|
|
|
95
95
|
}
|
|
96
96
|
return rawId;
|
|
97
97
|
}
|
|
98
|
-
function focusItem(element) {
|
|
98
|
+
function focusItem(element, intent) {
|
|
99
|
+
let previousId = null;
|
|
100
|
+
focusedId.subscribe((value) => (previousId = value))();
|
|
101
|
+
const resolvedIntent = intent ? { ...intent, from: previousId } : undefined;
|
|
99
102
|
if (!element) {
|
|
100
103
|
focusedId.set(null);
|
|
101
104
|
focusedElement.set(null);
|
|
102
|
-
onFocusChange?.(null, null);
|
|
105
|
+
onFocusChange?.(null, null, resolvedIntent);
|
|
103
106
|
return;
|
|
104
107
|
}
|
|
105
108
|
const id = getItemId(element);
|
|
@@ -108,7 +111,7 @@ export function createKeyboardNavigation(options = {}) {
|
|
|
108
111
|
// Note: tabIndex is controlled by Svelte via isFocused state
|
|
109
112
|
// We just call focus() and notify - the component will react to onFocusChange
|
|
110
113
|
element.focus();
|
|
111
|
-
onFocusChange?.(id, element);
|
|
114
|
+
onFocusChange?.(id, element, resolvedIntent);
|
|
112
115
|
}
|
|
113
116
|
function getCurrentIndex() {
|
|
114
117
|
// The live DOM focus wins: a native focus change (mouse click, script `.focus()`, focus
|
|
@@ -126,7 +129,7 @@ export function createKeyboardNavigation(options = {}) {
|
|
|
126
129
|
focusedElement.subscribe((el) => (currentElement = el))();
|
|
127
130
|
return currentElement ? items.indexOf(currentElement) : -1;
|
|
128
131
|
}
|
|
129
|
-
function focusNext() {
|
|
132
|
+
function focusNext(intent) {
|
|
130
133
|
items = getItems();
|
|
131
134
|
if (items.length === 0)
|
|
132
135
|
return;
|
|
@@ -141,9 +144,9 @@ export function createKeyboardNavigation(options = {}) {
|
|
|
141
144
|
else {
|
|
142
145
|
nextIdx = Math.min(currentIdx + 1, items.length - 1);
|
|
143
146
|
}
|
|
144
|
-
focusItem(items[nextIdx]);
|
|
147
|
+
focusItem(items[nextIdx], intent);
|
|
145
148
|
}
|
|
146
|
-
function focusPrevious() {
|
|
149
|
+
function focusPrevious(intent) {
|
|
147
150
|
items = getItems();
|
|
148
151
|
if (items.length === 0)
|
|
149
152
|
return;
|
|
@@ -158,19 +161,19 @@ export function createKeyboardNavigation(options = {}) {
|
|
|
158
161
|
else {
|
|
159
162
|
prevIdx = Math.max(currentIdx - 1, 0);
|
|
160
163
|
}
|
|
161
|
-
focusItem(items[prevIdx]);
|
|
164
|
+
focusItem(items[prevIdx], intent);
|
|
162
165
|
}
|
|
163
|
-
function focusFirst() {
|
|
166
|
+
function focusFirst(intent) {
|
|
164
167
|
items = getItems();
|
|
165
168
|
if (items.length === 0)
|
|
166
169
|
return;
|
|
167
|
-
focusItem(items[0]);
|
|
170
|
+
focusItem(items[0], intent);
|
|
168
171
|
}
|
|
169
|
-
function focusLast() {
|
|
172
|
+
function focusLast(intent) {
|
|
170
173
|
items = getItems();
|
|
171
174
|
if (items.length === 0)
|
|
172
175
|
return;
|
|
173
|
-
focusItem(items[items.length - 1]);
|
|
176
|
+
focusItem(items[items.length - 1], intent);
|
|
174
177
|
}
|
|
175
178
|
function focusById(id) {
|
|
176
179
|
items = getItems();
|
|
@@ -248,14 +251,18 @@ export function createKeyboardNavigation(options = {}) {
|
|
|
248
251
|
: orientation === 'vertical'
|
|
249
252
|
? ['ArrowUp']
|
|
250
253
|
: ['ArrowUp', 'ArrowLeft'];
|
|
254
|
+
// Shift turns a move into an extension of the selection from the anchor — the
|
|
255
|
+
// multi-select listbox pattern. The move itself is unchanged; only consumers that
|
|
256
|
+
// read the intent do anything extra with it.
|
|
257
|
+
const intent = event.shiftKey ? { extend: true } : undefined;
|
|
251
258
|
if (nextKeys.includes(key)) {
|
|
252
259
|
event.preventDefault();
|
|
253
|
-
focusNext();
|
|
260
|
+
focusNext(intent);
|
|
254
261
|
return;
|
|
255
262
|
}
|
|
256
263
|
if (prevKeys.includes(key)) {
|
|
257
264
|
event.preventDefault();
|
|
258
|
-
focusPrevious();
|
|
265
|
+
focusPrevious(intent);
|
|
259
266
|
return;
|
|
260
267
|
}
|
|
261
268
|
// NOTE: key repeat is only suppressed for keys this handler actually consumes
|
|
@@ -265,12 +272,12 @@ export function createKeyboardNavigation(options = {}) {
|
|
|
265
272
|
if (homeEndKeys) {
|
|
266
273
|
if (key === 'Home') {
|
|
267
274
|
event.preventDefault();
|
|
268
|
-
focusFirst();
|
|
275
|
+
focusFirst(intent);
|
|
269
276
|
return;
|
|
270
277
|
}
|
|
271
278
|
if (key === 'End') {
|
|
272
279
|
event.preventDefault();
|
|
273
|
-
focusLast();
|
|
280
|
+
focusLast(intent);
|
|
274
281
|
return;
|
|
275
282
|
}
|
|
276
283
|
}
|
|
@@ -351,7 +358,8 @@ export function createKeyboardNavigation(options = {}) {
|
|
|
351
358
|
focusLast,
|
|
352
359
|
focusById,
|
|
353
360
|
setCurrentId,
|
|
354
|
-
updateItems
|
|
361
|
+
updateItems,
|
|
362
|
+
typeahead: handleTypeahead
|
|
355
363
|
};
|
|
356
364
|
}
|
|
357
365
|
/**
|