@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
|
@@ -1,64 +1,133 @@
|
|
|
1
1
|
<script lang="ts" generics="T extends object = object">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import {
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import { onMount, tick, untrack } from 'svelte';
|
|
4
5
|
import { createListBoxContext, type ListBoxContext } from './context';
|
|
5
6
|
import { trackInteractionModality } from '../../primitives/input-modality';
|
|
7
|
+
import { computeListWindow, scrollTopForIndex } from '../../primitives/list-virtualizer';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Props for the ListBox component.
|
|
9
11
|
* @template T - The type of items when using dynamic rendering with the `items` prop.
|
|
10
12
|
*/
|
|
11
13
|
type ListBoxProps = {
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The behavior of the selection: 'toggle' lets the user remove a selection, and 'replace' always
|
|
16
|
+
* selects.
|
|
17
|
+
*/
|
|
13
18
|
selectionBehavior?: 'toggle' | 'replace';
|
|
14
|
-
/**
|
|
19
|
+
/** The content while the list is empty. It can be a string or a Snippet. */
|
|
15
20
|
emptyPlaceholder?: string | Snippet;
|
|
16
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* The items, for a list that the component makes from an array. Use it with a snippet that
|
|
23
|
+
* receives one item.
|
|
24
|
+
*/
|
|
17
25
|
items?: Iterable<T>;
|
|
18
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Reads the key of an item. This is the same value as the `id` of `ListBox.Item`.
|
|
28
|
+
*
|
|
29
|
+
* You need it only with `virtualizer`. Without it, a Shift range is measured over the options in
|
|
30
|
+
* the DOM. In a virtualized list, those are only the rows near the viewport, thus the range
|
|
31
|
+
* stops at the scroll position of the user.
|
|
32
|
+
*/
|
|
33
|
+
getItemKey?: (item: T) => string | number;
|
|
34
|
+
/** The keys of the items that must be disabled. The user cannot select them. */
|
|
19
35
|
disabledKeys?: Iterable<string | number>;
|
|
20
|
-
/**
|
|
36
|
+
/** The selection mode: 'single' permits one selection, and 'multiple' permits more than one. */
|
|
21
37
|
selectionMode?: 'single' | 'multiple';
|
|
22
|
-
/**
|
|
38
|
+
/** The selected keys. By default it goes in the two directions: use `bind:value`. */
|
|
23
39
|
value?: Iterable<string | number>;
|
|
24
|
-
/**
|
|
40
|
+
/** The selection at the start, for when you give no `value`. */
|
|
25
41
|
defaultValue?: Iterable<string | number>;
|
|
26
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Give your own code full control of the selection. The component stops to write back to
|
|
44
|
+
* `value`, and it reports only through `onChange`. Thus the parent can refuse a change: the
|
|
45
|
+
* parent does not send the new selection down. The default is off, because `bind:value` is the
|
|
46
|
+
* usual case and it needs the write-back.
|
|
47
|
+
*/
|
|
48
|
+
controlledValue?: boolean;
|
|
49
|
+
/** The content of the listbox. It can be static children, or a snippet that receives one item. */
|
|
27
50
|
children?: Snippet | Snippet<[T]>;
|
|
28
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* The rows in the listbox above the items, for example an action row such as "Create …". They
|
|
53
|
+
* are not in `children`, because from an array of items the component calls that snippet one
|
|
54
|
+
* time for each item.
|
|
55
|
+
*
|
|
56
|
+
* In a virtualized list, the keyboard does not go into these rows. There, the keys move through
|
|
57
|
+
* the array of the items, and these rows are not in it.
|
|
58
|
+
*/
|
|
59
|
+
header?: Snippet;
|
|
60
|
+
/** The CSS class names of the listbox container. */
|
|
29
61
|
class?: string;
|
|
30
|
-
/**
|
|
62
|
+
/** The id of the listbox element. */
|
|
31
63
|
id?: string;
|
|
32
|
-
/**
|
|
64
|
+
/** The accessible name of the listbox. A screen reader announces it. */
|
|
33
65
|
'aria-label'?: string;
|
|
34
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* The id of an element that the user sees, and that gives the listbox its name. Use it in place
|
|
68
|
+
* of `aria-label` when the list already has a heading.
|
|
69
|
+
*/
|
|
70
|
+
'aria-labelledby'?: string;
|
|
71
|
+
/** The component calls it when the selection changes. */
|
|
35
72
|
onChange?: (value: Set<string | number>) => void;
|
|
36
|
-
/**
|
|
73
|
+
/** Stops the DOM focus control on the root container, for a composition with a virtual focus. */
|
|
37
74
|
disableFocusHandling?: boolean;
|
|
38
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* At the last item, the arrow keys move the focus to the first item, and at the first item, to
|
|
77
|
+
* the last one.
|
|
78
|
+
*/
|
|
39
79
|
loop?: boolean;
|
|
40
|
-
/**
|
|
80
|
+
/** When the user types a character, the focus moves to the option whose text agrees with it. */
|
|
41
81
|
typeahead?: boolean;
|
|
42
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Makes only the rows near the viewport, and not all of the rows.
|
|
84
|
+
*
|
|
85
|
+
* The component obeys it only with `items`. The listbox must control the loop to cut it, thus a
|
|
86
|
+
* list written as static children is never virtualized.
|
|
87
|
+
*
|
|
88
|
+
* All of the rows must have the same height. This is what lets the component calculate the
|
|
89
|
+
* scrollbar without a measurement of each row. The component measures the height from the first
|
|
90
|
+
* row, but `rowHeight` replaces that measurement. Thus a list with your own styles needs no
|
|
91
|
+
* fixed number.
|
|
92
|
+
*
|
|
93
|
+
* The listbox element is the element that scrolls. Give it a maximum height and `overflow-y:
|
|
94
|
+
* auto`. A long list without a virtualizer needs the same.
|
|
95
|
+
*/
|
|
96
|
+
virtualizer?: { rowHeight?: number; overscan?: number };
|
|
97
|
+
} & Omit<
|
|
98
|
+
HTMLAttributes<HTMLDivElement>,
|
|
99
|
+
'class' | 'children' | 'role' | 'id' | 'aria-label' | 'aria-labelledby' | 'onchange'
|
|
100
|
+
>;
|
|
43
101
|
|
|
44
102
|
let {
|
|
45
103
|
selectionBehavior = 'toggle',
|
|
46
104
|
emptyPlaceholder = 'No items selected',
|
|
47
105
|
items,
|
|
106
|
+
getItemKey,
|
|
48
107
|
disabledKeys,
|
|
49
108
|
selectionMode = 'single',
|
|
50
109
|
value = $bindable(),
|
|
51
110
|
defaultValue,
|
|
111
|
+
controlledValue = false,
|
|
52
112
|
children,
|
|
113
|
+
header,
|
|
53
114
|
class: className = '',
|
|
54
115
|
id,
|
|
55
116
|
'aria-label': ariaLabel,
|
|
117
|
+
'aria-labelledby': ariaLabelledBy,
|
|
56
118
|
onChange,
|
|
57
119
|
disableFocusHandling = false,
|
|
58
120
|
loop = false,
|
|
59
121
|
typeahead = false,
|
|
122
|
+
virtualizer,
|
|
60
123
|
context = $bindable(),
|
|
61
|
-
element = $bindable()
|
|
124
|
+
element = $bindable(),
|
|
125
|
+
onkeydown: onKeyDownExternal,
|
|
126
|
+
onmousedown: onMouseDownExternal,
|
|
127
|
+
onfocusin: onFocusInExternal,
|
|
128
|
+
onfocusout: onFocusOutExternal,
|
|
129
|
+
onscroll: onScrollExternal,
|
|
130
|
+
...restProps
|
|
62
131
|
}: ListBoxProps & { context?: ListBoxContext; element?: HTMLElement } = $props();
|
|
63
132
|
|
|
64
133
|
let listboxElement: HTMLElement;
|
|
@@ -73,10 +142,12 @@
|
|
|
73
142
|
return new Set(val);
|
|
74
143
|
}
|
|
75
144
|
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
|
|
145
|
+
// In controlled mode the parent owns the selection: `select` only emits `onChange`
|
|
146
|
+
// and the sync effect below applies whatever the parent passes down. Controlled-ness
|
|
147
|
+
// is NOT inferred from `value` being defined: `bind:value={keys}` and `value={keys}`
|
|
148
|
+
// are indistinguishable at runtime, so inferring it silently broke every `bind:value`.
|
|
149
|
+
// It is opt-in via `controlledValue` instead.
|
|
150
|
+
const isControlled = untrack(() => controlledValue);
|
|
80
151
|
|
|
81
152
|
const ctx = createListBoxContext({
|
|
82
153
|
get selectionMode() {
|
|
@@ -142,6 +213,263 @@
|
|
|
142
213
|
|
|
143
214
|
const itemsArray = $derived(items ? Array.from(items) : []);
|
|
144
215
|
const hasDynamicItems = $derived(items !== undefined);
|
|
216
|
+
|
|
217
|
+
// --- Virtualization -----------------------------------------------------
|
|
218
|
+
// Only the rows near the viewport are rendered; the rest is two numbers — a spacer that
|
|
219
|
+
// holds the scrollbar at the height of the full list, and an offset that puts the
|
|
220
|
+
// rendered block where those rows would have been.
|
|
221
|
+
const isVirtual = $derived(Boolean(virtualizer) && hasDynamicItems);
|
|
222
|
+
|
|
223
|
+
let scrollTop = $state(0);
|
|
224
|
+
let viewportHeight = $state(0);
|
|
225
|
+
/**
|
|
226
|
+
* The distance from one row's top edge to the next one's, measured off two rendered rows.
|
|
227
|
+
*
|
|
228
|
+
* Measured rather than declared because the row's height comes from the consumer's own
|
|
229
|
+
* styles — and measured as a *distance*, not as height + `row-gap`, because that sum was
|
|
230
|
+
* wrong by about a pixel and the error is cumulative: the offset of row N is N times it,
|
|
231
|
+
* so a thousand rows down the window was placed a thousand pixels away from where the
|
|
232
|
+
* scrollbar said it was and the list rendered blank.
|
|
233
|
+
*/
|
|
234
|
+
let measuredPitch = $state(0);
|
|
235
|
+
/** The row's own height, for deciding when a row is fully inside the viewport. */
|
|
236
|
+
let measuredRowHeight = $state(0);
|
|
237
|
+
/**
|
|
238
|
+
* The listbox's own `row-gap`, applied to the rendered window so the rows keep the
|
|
239
|
+
* spacing the consumer styled them with.
|
|
240
|
+
*
|
|
241
|
+
* Read from the style rather than derived from the pitch on purpose: deriving it would
|
|
242
|
+
* close a circle — the gap would come from a distance the gap itself produces — and the
|
|
243
|
+
* list would settle on whatever it measured first, gap and all.
|
|
244
|
+
*/
|
|
245
|
+
let measuredGap = $state(0);
|
|
246
|
+
/** The scroller's own top padding, which sits between `scrollTop` and the first row. */
|
|
247
|
+
let measuredPadding = $state(0);
|
|
248
|
+
|
|
249
|
+
const rowHeight = $derived(virtualizer?.rowHeight ?? measuredRowHeight);
|
|
250
|
+
const pitch = $derived(
|
|
251
|
+
virtualizer?.rowHeight !== undefined ? virtualizer.rowHeight + measuredGap : measuredPitch
|
|
252
|
+
);
|
|
253
|
+
// What the maths needs is the distance between rows; expressing it as height + gap keeps
|
|
254
|
+
// `computeListWindow`'s signature honest about what a row occupies.
|
|
255
|
+
const gap = $derived(Math.max(0, pitch - rowHeight));
|
|
256
|
+
/**
|
|
257
|
+
* Rows rendered on the very first pass, before anything has been measured.
|
|
258
|
+
*
|
|
259
|
+
* Without it the list would deadlock: the window needs a row height, the height comes
|
|
260
|
+
* from measuring rendered rows, and nothing is rendered until there's a window. A
|
|
261
|
+
* viewport's worth is enough to measure and to fill the first paint.
|
|
262
|
+
*/
|
|
263
|
+
const BOOTSTRAP_ROWS = 20;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The viewport to size the window against, never taller than the screen.
|
|
267
|
+
*
|
|
268
|
+
* `clientHeight` is the height of the scroller, which is only meaningful once something
|
|
269
|
+
* constrains it. A popover applies its max height *after* it opens, so on the first pass
|
|
270
|
+
* the list is as tall as its own content — and a "viewport" of 28.000px asks for a
|
|
271
|
+
* window of every row there is. That is how opening a 1122-row list mounted 1122 rows
|
|
272
|
+
* (~7s) before shrinking back to 19: virtualized in the end, but only after paying for
|
|
273
|
+
* the whole list.
|
|
274
|
+
*
|
|
275
|
+
* A list can legitimately be as tall as the screen, never taller, so the screen is the
|
|
276
|
+
* cap. The ResizeObserver corrects the number the moment the real constraint lands.
|
|
277
|
+
*/
|
|
278
|
+
const effectiveViewportHeight = $derived(
|
|
279
|
+
typeof window === 'undefined' ? viewportHeight : Math.min(viewportHeight, window.innerHeight)
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
const listWindow = $derived(
|
|
283
|
+
isVirtual && rowHeight > 0 && pitch > 0
|
|
284
|
+
? computeListWindow({
|
|
285
|
+
count: itemsArray.length,
|
|
286
|
+
itemHeight: rowHeight,
|
|
287
|
+
gap,
|
|
288
|
+
viewportHeight: effectiveViewportHeight,
|
|
289
|
+
scrollTop,
|
|
290
|
+
overscan: virtualizer?.overscan ?? 8,
|
|
291
|
+
padding: measuredPadding
|
|
292
|
+
})
|
|
293
|
+
: undefined
|
|
294
|
+
);
|
|
295
|
+
const visibleItems = $derived.by(() => {
|
|
296
|
+
if (listWindow) {
|
|
297
|
+
return itemsArray.slice(listWindow.from, listWindow.to + 1);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return isVirtual ? itemsArray.slice(0, BOOTSTRAP_ROWS) : itemsArray;
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
/** Below this a re-measurement is noise, not a correction worth re-rendering for. */
|
|
304
|
+
const MEASUREMENT_EPSILON = 0.5;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Reads the row geometry off what is actually on screen.
|
|
308
|
+
*
|
|
309
|
+
* Only ever *writes* the measurements — reading them here would close a loop with the
|
|
310
|
+
* window that renders the rows it measures (an effect that reads and writes the same
|
|
311
|
+
* state re-runs until Svelte gives up).
|
|
312
|
+
*/
|
|
313
|
+
function measureRows() {
|
|
314
|
+
if (!listboxElement || !isVirtual) return;
|
|
315
|
+
|
|
316
|
+
const rows = listboxElement.querySelectorAll<HTMLElement>('[data-listbox-window] > *');
|
|
317
|
+
const first = rows[0]?.getBoundingClientRect();
|
|
318
|
+
if (!first || first.height <= 0) return;
|
|
319
|
+
|
|
320
|
+
// Two rows give the pitch exactly, gap included. With only one, fall back to its
|
|
321
|
+
// height plus the declared gap — the same guess as before, but now it is the
|
|
322
|
+
// exception rather than the rule.
|
|
323
|
+
const second = rows[1]?.getBoundingClientRect();
|
|
324
|
+
const style = getComputedStyle(listboxElement);
|
|
325
|
+
const declaredGap = Number.parseFloat(style.rowGap);
|
|
326
|
+
const declaredPadding = Number.parseFloat(style.paddingTop);
|
|
327
|
+
const nextPitch = second
|
|
328
|
+
? second.top - first.top
|
|
329
|
+
: first.height + (Number.isFinite(declaredGap) ? declaredGap : 0);
|
|
330
|
+
|
|
331
|
+
const nextGap = Number.isFinite(declaredGap) ? declaredGap : 0;
|
|
332
|
+
const nextPadding = Number.isFinite(declaredPadding) ? declaredPadding : 0;
|
|
333
|
+
|
|
334
|
+
untrack(() => {
|
|
335
|
+
if (Math.abs(first.height - measuredRowHeight) > MEASUREMENT_EPSILON) {
|
|
336
|
+
measuredRowHeight = first.height;
|
|
337
|
+
}
|
|
338
|
+
if (nextPitch > 0 && Math.abs(nextPitch - measuredPitch) > MEASUREMENT_EPSILON) {
|
|
339
|
+
measuredPitch = nextPitch;
|
|
340
|
+
}
|
|
341
|
+
if (Math.abs(nextGap - measuredGap) > MEASUREMENT_EPSILON) {
|
|
342
|
+
measuredGap = nextGap;
|
|
343
|
+
}
|
|
344
|
+
if (Math.abs(nextPadding - measuredPadding) > MEASUREMENT_EPSILON) {
|
|
345
|
+
measuredPadding = nextPadding;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Tells assistive technology how big the list really is.
|
|
352
|
+
*
|
|
353
|
+
* A virtualized listbox holds a handful of options, so the position and count a browser
|
|
354
|
+
* computes from the DOM describe the window rather than the collection — a screen reader
|
|
355
|
+
* announces "1 of 8" for a list of two thousand. ARIA has `aria-setsize` /
|
|
356
|
+
* `aria-posinset` for exactly this case, and only the list knows the real numbers.
|
|
357
|
+
*
|
|
358
|
+
* Written onto the rendered rows rather than passed down because the rows come from the
|
|
359
|
+
* consumer's snippet; it is the same set of nodes the measurement above already reads,
|
|
360
|
+
* and it re-runs whenever the window moves or the collection changes.
|
|
361
|
+
*/
|
|
362
|
+
function labelPositions() {
|
|
363
|
+
if (!listboxElement || !isVirtual) return;
|
|
364
|
+
const rows = listboxElement.querySelectorAll<HTMLElement>('[data-listbox-window] > *');
|
|
365
|
+
const setSize = String(itemsArray.length);
|
|
366
|
+
const from = listWindow?.from ?? 0;
|
|
367
|
+
rows.forEach((row, offset) => {
|
|
368
|
+
row.setAttribute('aria-setsize', setSize);
|
|
369
|
+
row.setAttribute('aria-posinset', String(from + offset + 1));
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
$effect(() => {
|
|
374
|
+
if (!isVirtual || !listboxElement) return;
|
|
375
|
+
|
|
376
|
+
// Re-measure whenever the rendered set changes — a list that was filtered, a window
|
|
377
|
+
// that moved — so a first measurement taken mid-animation gets corrected instead of
|
|
378
|
+
// misplacing every row after it. Reads nothing it writes.
|
|
379
|
+
void itemsArray.length;
|
|
380
|
+
void listWindow?.from;
|
|
381
|
+
|
|
382
|
+
const element = listboxElement;
|
|
383
|
+
|
|
384
|
+
measureRows();
|
|
385
|
+
labelPositions();
|
|
386
|
+
|
|
387
|
+
const observer = new ResizeObserver(() => {
|
|
388
|
+
untrack(() => {
|
|
389
|
+
if (element.clientHeight !== viewportHeight) {
|
|
390
|
+
viewportHeight = element.clientHeight;
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
measureRows();
|
|
394
|
+
labelPositions();
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
observer.observe(element);
|
|
398
|
+
viewportHeight = element.clientHeight;
|
|
399
|
+
|
|
400
|
+
return () => observer.disconnect();
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
function handleScroll() {
|
|
404
|
+
if (isVirtual && listboxElement) {
|
|
405
|
+
scrollTop = listboxElement.scrollTop;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Brings a row into view by index, mounting it if the window didn't reach it.
|
|
411
|
+
*
|
|
412
|
+
* This is what makes keyboard navigation work over rows that aren't rendered: the caller
|
|
413
|
+
* moves its focus by index over the whole list and asks for the row, and by the time the
|
|
414
|
+
* promise resolves the element exists and can be pointed at with `aria-activedescendant`.
|
|
415
|
+
*/
|
|
416
|
+
async function scrollIndexIntoView(
|
|
417
|
+
index: number,
|
|
418
|
+
options?: { align?: 'nearest' | 'center' }
|
|
419
|
+
): Promise<boolean> {
|
|
420
|
+
// Nothing to compute before the first measurement: a zero row height or an unmeasured
|
|
421
|
+
// viewport would send the list to an offset with no rows in it, which is what a blank
|
|
422
|
+
// list is.
|
|
423
|
+
if (!isVirtual || !listboxElement || rowHeight <= 0 || effectiveViewportHeight <= 0) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const next = scrollTopForIndex({
|
|
428
|
+
index,
|
|
429
|
+
count: itemsArray.length,
|
|
430
|
+
itemHeight: rowHeight,
|
|
431
|
+
gap,
|
|
432
|
+
viewportHeight: effectiveViewportHeight,
|
|
433
|
+
scrollTop,
|
|
434
|
+
padding: measuredPadding,
|
|
435
|
+
align: options?.align
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
if (next === null) {
|
|
439
|
+
// Already where it should be.
|
|
440
|
+
await tick();
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
listboxElement.scrollTop = next;
|
|
445
|
+
// Read it back instead of trusting the assignment: the browser clamps to the real
|
|
446
|
+
// scroll range, and a state that disagrees with the element renders a window the
|
|
447
|
+
// viewport isn't looking at.
|
|
448
|
+
scrollTop = listboxElement.scrollTop;
|
|
449
|
+
|
|
450
|
+
// The window is derived from `scrollTop`, so the row exists only after the update.
|
|
451
|
+
await tick();
|
|
452
|
+
|
|
453
|
+
// Whether it actually landed. A scroll asked for before the list has its final
|
|
454
|
+
// height gets clamped to a range that doesn't exist yet, and the caller needs to
|
|
455
|
+
// know so it can ask again rather than assume the row is where it wanted it.
|
|
456
|
+
return Math.abs(scrollTop - next) < 1;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// Published on the context so a composite widget (a ComboBox, whose keyboard focus lives
|
|
460
|
+
// on its input) can reach a row the window hasn't rendered yet.
|
|
461
|
+
ctx.setScrollIndexIntoView(scrollIndexIntoView);
|
|
462
|
+
ctx.setVirtualized(() => isVirtual);
|
|
463
|
+
|
|
464
|
+
// Only for a virtualized list: an unvirtualized one has every row on the page, and DOM
|
|
465
|
+
// order is the more truthful source there — it survives a keyed reorder that the items
|
|
466
|
+
// array has not caught up with.
|
|
467
|
+
$effect(() => {
|
|
468
|
+
const read = getItemKey;
|
|
469
|
+
if (!isVirtual || !read) return;
|
|
470
|
+
ctx.setOrderedKeys(() => itemsArray.map(read));
|
|
471
|
+
return () => ctx.setOrderedKeys(null);
|
|
472
|
+
});
|
|
145
473
|
let hasMounted = $state(false);
|
|
146
474
|
const registeredItemCount = $derived(hasMounted ? itemCount : ctx.getItemCount());
|
|
147
475
|
const shouldShowEmptyPlaceholder = $derived(
|
|
@@ -183,6 +511,24 @@
|
|
|
183
511
|
ctx.setFocusVisible(true);
|
|
184
512
|
}
|
|
185
513
|
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Runs the listbox's own handler and then the consumer's.
|
|
517
|
+
*
|
|
518
|
+
* The rest props are spread last so a consumer can reach the element, but that also
|
|
519
|
+
* means an `onkeydown` of theirs would replace the one driving focus modality and
|
|
520
|
+
* keyboard navigation. Composing keeps both, with the consumer able to opt out of the
|
|
521
|
+
* rest by calling `stopImmediatePropagation`.
|
|
522
|
+
*/
|
|
523
|
+
function compose<E extends Event>(
|
|
524
|
+
internal: (event: E) => void,
|
|
525
|
+
external: ((event: E) => void) | null | undefined
|
|
526
|
+
) {
|
|
527
|
+
return (event: E) => {
|
|
528
|
+
internal(event);
|
|
529
|
+
external?.(event);
|
|
530
|
+
};
|
|
531
|
+
}
|
|
186
532
|
</script>
|
|
187
533
|
|
|
188
534
|
<div
|
|
@@ -191,16 +537,43 @@
|
|
|
191
537
|
{id}
|
|
192
538
|
aria-multiselectable={selectionMode === 'multiple'}
|
|
193
539
|
aria-label={ariaLabel}
|
|
540
|
+
aria-labelledby={ariaLabelledBy}
|
|
194
541
|
class={className}
|
|
195
542
|
tabindex={disableFocusHandling ? undefined : focusWithin ? -1 : 0}
|
|
196
543
|
data-focus-within={focusWithin || undefined}
|
|
197
544
|
use:keyboardAction
|
|
198
|
-
onfocusin={handleFocusIn}
|
|
199
|
-
onfocusout={handleFocusOut}
|
|
200
|
-
onmousedown={handleMouseDown}
|
|
201
|
-
onkeydown={handleKeyDown}
|
|
545
|
+
onfocusin={compose(handleFocusIn, onFocusInExternal)}
|
|
546
|
+
onfocusout={compose(handleFocusOut, onFocusOutExternal)}
|
|
547
|
+
onmousedown={compose(handleMouseDown, onMouseDownExternal)}
|
|
548
|
+
onkeydown={compose(handleKeyDown, onKeyDownExternal)}
|
|
549
|
+
onscroll={compose(handleScroll, onScrollExternal)}
|
|
550
|
+
{...restProps}
|
|
202
551
|
>
|
|
203
|
-
{#if
|
|
552
|
+
{#if header}
|
|
553
|
+
{@render header()}
|
|
554
|
+
{/if}
|
|
555
|
+
|
|
556
|
+
{#if items && children && isVirtual}
|
|
557
|
+
<!-- The spacer carries the height of the whole list so the scrollbar matches it; the
|
|
558
|
+
window is placed at the offset the first rendered row would have had. It repeats the
|
|
559
|
+
listbox's own gap so rows sit exactly where the maths says they do. -->
|
|
560
|
+
<!-- `flex: 0 0 auto` because the listbox is usually a flex column: without it the
|
|
561
|
+
spacer is shrunk to the viewport height and there is nothing left to scroll. -->
|
|
562
|
+
<div
|
|
563
|
+
data-listbox-spacer
|
|
564
|
+
style="position: relative; flex: 0 0 auto; height: {listWindow?.contentHeight ?? 0}px"
|
|
565
|
+
>
|
|
566
|
+
<div
|
|
567
|
+
data-listbox-window
|
|
568
|
+
style="position: absolute; top: {listWindow?.offset ??
|
|
569
|
+
0}px; left: 0; right: 0; display: flex; flex-direction: column; gap: {measuredGap}px"
|
|
570
|
+
>
|
|
571
|
+
{#each visibleItems as item (item)}
|
|
572
|
+
{@render (children as Snippet<[T]>)(item)}
|
|
573
|
+
{/each}
|
|
574
|
+
</div>
|
|
575
|
+
</div>
|
|
576
|
+
{:else if items && children}
|
|
204
577
|
{#each itemsArray as item (item)}
|
|
205
578
|
{@render (children as Snippet<[T]>)(item)}
|
|
206
579
|
{/each}
|
|
@@ -1,38 +1,95 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
3
|
import { type ListBoxContext } from './context';
|
|
3
4
|
declare function $$render<T extends object = object>(): {
|
|
4
5
|
props: {
|
|
5
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* The behavior of the selection: 'toggle' lets the user remove a selection, and 'replace' always
|
|
8
|
+
* selects.
|
|
9
|
+
*/
|
|
6
10
|
selectionBehavior?: "toggle" | "replace";
|
|
7
|
-
/**
|
|
11
|
+
/** The content while the list is empty. It can be a string or a Snippet. */
|
|
8
12
|
emptyPlaceholder?: string | Snippet;
|
|
9
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* The items, for a list that the component makes from an array. Use it with a snippet that
|
|
15
|
+
* receives one item.
|
|
16
|
+
*/
|
|
10
17
|
items?: Iterable<T>;
|
|
11
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Reads the key of an item. This is the same value as the `id` of `ListBox.Item`.
|
|
20
|
+
*
|
|
21
|
+
* You need it only with `virtualizer`. Without it, a Shift range is measured over the options in
|
|
22
|
+
* the DOM. In a virtualized list, those are only the rows near the viewport, thus the range
|
|
23
|
+
* stops at the scroll position of the user.
|
|
24
|
+
*/
|
|
25
|
+
getItemKey?: (item: T) => string | number;
|
|
26
|
+
/** The keys of the items that must be disabled. The user cannot select them. */
|
|
12
27
|
disabledKeys?: Iterable<string | number>;
|
|
13
|
-
/**
|
|
28
|
+
/** The selection mode: 'single' permits one selection, and 'multiple' permits more than one. */
|
|
14
29
|
selectionMode?: "single" | "multiple";
|
|
15
|
-
/**
|
|
30
|
+
/** The selected keys. By default it goes in the two directions: use `bind:value`. */
|
|
16
31
|
value?: Iterable<string | number>;
|
|
17
|
-
/**
|
|
32
|
+
/** The selection at the start, for when you give no `value`. */
|
|
18
33
|
defaultValue?: Iterable<string | number>;
|
|
19
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Give your own code full control of the selection. The component stops to write back to
|
|
36
|
+
* `value`, and it reports only through `onChange`. Thus the parent can refuse a change: the
|
|
37
|
+
* parent does not send the new selection down. The default is off, because `bind:value` is the
|
|
38
|
+
* usual case and it needs the write-back.
|
|
39
|
+
*/
|
|
40
|
+
controlledValue?: boolean;
|
|
41
|
+
/** The content of the listbox. It can be static children, or a snippet that receives one item. */
|
|
20
42
|
children?: Snippet | Snippet<[T]>;
|
|
21
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* The rows in the listbox above the items, for example an action row such as "Create …". They
|
|
45
|
+
* are not in `children`, because from an array of items the component calls that snippet one
|
|
46
|
+
* time for each item.
|
|
47
|
+
*
|
|
48
|
+
* In a virtualized list, the keyboard does not go into these rows. There, the keys move through
|
|
49
|
+
* the array of the items, and these rows are not in it.
|
|
50
|
+
*/
|
|
51
|
+
header?: Snippet;
|
|
52
|
+
/** The CSS class names of the listbox container. */
|
|
22
53
|
class?: string;
|
|
23
|
-
/**
|
|
54
|
+
/** The id of the listbox element. */
|
|
24
55
|
id?: string;
|
|
25
|
-
/**
|
|
56
|
+
/** The accessible name of the listbox. A screen reader announces it. */
|
|
26
57
|
'aria-label'?: string;
|
|
27
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* The id of an element that the user sees, and that gives the listbox its name. Use it in place
|
|
60
|
+
* of `aria-label` when the list already has a heading.
|
|
61
|
+
*/
|
|
62
|
+
'aria-labelledby'?: string;
|
|
63
|
+
/** The component calls it when the selection changes. */
|
|
28
64
|
onChange?: (value: Set<string | number>) => void;
|
|
29
|
-
/**
|
|
65
|
+
/** Stops the DOM focus control on the root container, for a composition with a virtual focus. */
|
|
30
66
|
disableFocusHandling?: boolean;
|
|
31
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* At the last item, the arrow keys move the focus to the first item, and at the first item, to
|
|
69
|
+
* the last one.
|
|
70
|
+
*/
|
|
32
71
|
loop?: boolean;
|
|
33
|
-
/**
|
|
72
|
+
/** When the user types a character, the focus moves to the option whose text agrees with it. */
|
|
34
73
|
typeahead?: boolean;
|
|
35
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Makes only the rows near the viewport, and not all of the rows.
|
|
76
|
+
*
|
|
77
|
+
* The component obeys it only with `items`. The listbox must control the loop to cut it, thus a
|
|
78
|
+
* list written as static children is never virtualized.
|
|
79
|
+
*
|
|
80
|
+
* All of the rows must have the same height. This is what lets the component calculate the
|
|
81
|
+
* scrollbar without a measurement of each row. The component measures the height from the first
|
|
82
|
+
* row, but `rowHeight` replaces that measurement. Thus a list with your own styles needs no
|
|
83
|
+
* fixed number.
|
|
84
|
+
*
|
|
85
|
+
* The listbox element is the element that scrolls. Give it a maximum height and `overflow-y:
|
|
86
|
+
* auto`. A long list without a virtualizer needs the same.
|
|
87
|
+
*/
|
|
88
|
+
virtualizer?: {
|
|
89
|
+
rowHeight?: number;
|
|
90
|
+
overscan?: number;
|
|
91
|
+
};
|
|
92
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, "children" | "class" | "id" | "role" | "aria-label" | "aria-labelledby" | "onchange"> & {
|
|
36
93
|
context?: ListBoxContext;
|
|
37
94
|
element?: HTMLElement;
|
|
38
95
|
};
|
|
@@ -30,12 +30,7 @@ renders no markup of its own.
|
|
|
30
30
|
|
|
31
31
|
## SSR and hydration
|
|
32
32
|
|
|
33
|
-
In server-rendered apps an explicit `locale` is effectively **required**. Without it, the
|
|
34
|
-
server formats with the Node process locale while the client formats with the visitor's
|
|
35
|
-
`navigator.language`; when they differ, the server HTML and the first client render
|
|
36
|
-
disagree — date segment order (`dd/MM` vs `MM/dd`), hour cycle (12h vs 24h) and number
|
|
37
|
-
formats (decimal/group separators) all shift — which produces hydration mismatches and
|
|
38
|
-
visible content flicker.
|
|
33
|
+
In server-rendered apps an explicit `locale` is effectively **required**. Without it, the server uses the locale of the Node process and the client uses `navigator.language`. When the two are different, the HTML of the server and the first render of the client do not agree. The sequence of the date segments changes (`dd/MM` or `MM/dd`), and so do the hour cycle (12h or 24h) and the number format. The result is a hydration error and a flash of different content.
|
|
39
34
|
|
|
40
35
|
Resolve the locale on the server (typically from the `Accept-Language` request header, or
|
|
41
36
|
the user's saved preference) and pass it explicitly so both passes agree:
|