@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
|
@@ -11,6 +11,10 @@ export function createListBoxContext(options = {}) {
|
|
|
11
11
|
const disabledKeys = new SvelteSet(options.disabledKeys ?? []);
|
|
12
12
|
const items = new Map();
|
|
13
13
|
let selectedKeys = new Set(options.initialSelection ?? []);
|
|
14
|
+
/** Where a Shift range starts: the last item selected without modifiers. */
|
|
15
|
+
let anchorId = null;
|
|
16
|
+
/** Set by a virtualized ListBox so ranges can reach rows that were never rendered. */
|
|
17
|
+
let readOrderedKeys = null;
|
|
14
18
|
const itemCallbacks = new Map();
|
|
15
19
|
// Item count tracking with subscription
|
|
16
20
|
const itemCountCallbacks = new Set();
|
|
@@ -28,8 +32,46 @@ export function createListBoxContext(options = {}) {
|
|
|
28
32
|
function unregisterItem(id) {
|
|
29
33
|
items.delete(id);
|
|
30
34
|
itemCallbacks.delete(id);
|
|
35
|
+
// A range measured from an item that no longer exists would silently select nothing.
|
|
36
|
+
// In a virtualized list, though, unregistering is just scrolling away — the anchor is
|
|
37
|
+
// still part of the collection and has to survive, or a range made across a scroll
|
|
38
|
+
// collapses to the single option that ended it. The `anchorId` check comes first so
|
|
39
|
+
// the list order is only rebuilt for the one row that could matter.
|
|
40
|
+
if (anchorId === id && !getOrderedIds().includes(id)) {
|
|
41
|
+
anchorId = null;
|
|
42
|
+
}
|
|
31
43
|
notifyItemCountChange();
|
|
32
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Ids in list order.
|
|
47
|
+
*
|
|
48
|
+
* A virtualized list registers the whole collection up front, because only its
|
|
49
|
+
* rendered window exists in the DOM and a range measured over that stops wherever the
|
|
50
|
+
* user happened to have scrolled.
|
|
51
|
+
*
|
|
52
|
+
* Otherwise: sorted by DOM position when every item has an element on the page,
|
|
53
|
+
* because registration order and render order diverge as soon as a keyed list is
|
|
54
|
+
* reordered. Falls back to registration order rather than sorting a partial set, which
|
|
55
|
+
* would interleave measured and unmeasured items into an order that matches neither.
|
|
56
|
+
*/
|
|
57
|
+
function getOrderedIds() {
|
|
58
|
+
if (readOrderedKeys)
|
|
59
|
+
return readOrderedKeys();
|
|
60
|
+
const entries = Array.from(items.entries());
|
|
61
|
+
const positioned = entries.filter(([, meta]) => meta.element?.isConnected);
|
|
62
|
+
if (positioned.length !== entries.length) {
|
|
63
|
+
return entries.map(([id]) => id);
|
|
64
|
+
}
|
|
65
|
+
positioned.sort(([, a], [, b]) => {
|
|
66
|
+
const position = a.element.compareDocumentPosition(b.element);
|
|
67
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING)
|
|
68
|
+
return -1;
|
|
69
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING)
|
|
70
|
+
return 1;
|
|
71
|
+
return 0;
|
|
72
|
+
});
|
|
73
|
+
return positioned.map(([id]) => id);
|
|
74
|
+
}
|
|
33
75
|
function getItemCount() {
|
|
34
76
|
return items.size;
|
|
35
77
|
}
|
|
@@ -179,8 +221,58 @@ export function createListBoxContext(options = {}) {
|
|
|
179
221
|
function select(id) {
|
|
180
222
|
if (isDisabled(id))
|
|
181
223
|
return;
|
|
224
|
+
// Any unmodified selection re-anchors: the next Shift range is measured from here.
|
|
225
|
+
anchorId = id;
|
|
182
226
|
commitSelection(computeNextSelection(id));
|
|
183
227
|
}
|
|
228
|
+
function extendSelectionTo(id) {
|
|
229
|
+
if (getSelectionMode() !== 'multiple')
|
|
230
|
+
return;
|
|
231
|
+
const ordered = getOrderedIds();
|
|
232
|
+
const from = ordered.indexOf(anchorId ?? id);
|
|
233
|
+
const to = ordered.indexOf(id);
|
|
234
|
+
if (from === -1 || to === -1)
|
|
235
|
+
return;
|
|
236
|
+
const [start, end] = from <= to ? [from, to] : [to, from];
|
|
237
|
+
const next = new Set();
|
|
238
|
+
for (let index = start; index <= end; index += 1) {
|
|
239
|
+
const key = ordered[index];
|
|
240
|
+
if (!isDisabled(key))
|
|
241
|
+
next.add(key);
|
|
242
|
+
}
|
|
243
|
+
// The range REPLACES the selection rather than adding to it: dragging a Shift range
|
|
244
|
+
// back and forth has to shrink it again, which only works if each extension is
|
|
245
|
+
// recomputed from the anchor.
|
|
246
|
+
commitSelection(next);
|
|
247
|
+
}
|
|
248
|
+
function selectWithModifiers(id, modifiers) {
|
|
249
|
+
if (isDisabled(id))
|
|
250
|
+
return;
|
|
251
|
+
if (modifiers?.shift && getSelectionMode() === 'multiple') {
|
|
252
|
+
// First Shift press with nothing anchored yet: the item the user was on is the
|
|
253
|
+
// start of the range.
|
|
254
|
+
if (anchorId === null) {
|
|
255
|
+
anchorId = focusedId ?? id;
|
|
256
|
+
}
|
|
257
|
+
extendSelectionTo(id);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (modifiers?.ctrlOrMeta && getSelectionMode() === 'multiple') {
|
|
261
|
+
// Toggle regardless of `selectionBehavior`: with `'replace'` a plain click clears
|
|
262
|
+
// the rest, and Ctrl/Cmd+click is how you add one item without losing them.
|
|
263
|
+
anchorId = id;
|
|
264
|
+
const next = new Set(selectedKeys);
|
|
265
|
+
if (next.has(id)) {
|
|
266
|
+
next.delete(id);
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
next.add(id);
|
|
270
|
+
}
|
|
271
|
+
commitSelection(next);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
select(id);
|
|
275
|
+
}
|
|
184
276
|
function selectAll() {
|
|
185
277
|
if (getSelectionMode() !== 'multiple')
|
|
186
278
|
return;
|
|
@@ -201,8 +293,17 @@ export function createListBoxContext(options = {}) {
|
|
|
201
293
|
onSelect: (id) => {
|
|
202
294
|
select(id);
|
|
203
295
|
},
|
|
204
|
-
onFocusChange: (id) => {
|
|
296
|
+
onFocusChange: (id, _element, intent) => {
|
|
205
297
|
setFocusedId(id);
|
|
298
|
+
if (!intent?.extend || id === null)
|
|
299
|
+
return;
|
|
300
|
+
// With nothing anchored, a Shift+Arrow starts its range at the item the user was
|
|
301
|
+
// standing on — which only `intent.from` still knows, since focusing the new item
|
|
302
|
+
// already moved `focusedId`.
|
|
303
|
+
if (anchorId === null) {
|
|
304
|
+
anchorId = intent.from ?? id;
|
|
305
|
+
}
|
|
306
|
+
extendSelectionTo(id);
|
|
206
307
|
},
|
|
207
308
|
// `selectAll` checks the selection mode at call time so runtime mode
|
|
208
309
|
// changes are respected.
|
|
@@ -231,6 +332,12 @@ export function createListBoxContext(options = {}) {
|
|
|
231
332
|
getItemCount,
|
|
232
333
|
subscribeToItemCount,
|
|
233
334
|
select,
|
|
335
|
+
selectWithModifiers,
|
|
336
|
+
extendSelectionTo,
|
|
337
|
+
getAnchorId: () => anchorId,
|
|
338
|
+
setOrderedKeys: (read) => {
|
|
339
|
+
readOrderedKeys = read;
|
|
340
|
+
},
|
|
234
341
|
selectAll,
|
|
235
342
|
setSelection,
|
|
236
343
|
setFocusedId,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" generics="T extends object = object">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
4
|
import { onMount, tick, untrack } from 'svelte';
|
|
4
5
|
import { createListBoxContext, type ListBoxContext } from './context';
|
|
5
6
|
import { trackInteractionModality } from '../../primitives/input-modality';
|
|
@@ -10,72 +11,99 @@
|
|
|
10
11
|
* @template T - The type of items when using dynamic rendering with the `items` prop.
|
|
11
12
|
*/
|
|
12
13
|
type ListBoxProps = {
|
|
13
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The behavior of the selection: 'toggle' lets the user remove a selection, and 'replace' always
|
|
16
|
+
* selects.
|
|
17
|
+
*/
|
|
14
18
|
selectionBehavior?: 'toggle' | 'replace';
|
|
15
|
-
/**
|
|
19
|
+
/** The content while the list is empty. It can be a string or a Snippet. */
|
|
16
20
|
emptyPlaceholder?: string | Snippet;
|
|
17
|
-
/**
|
|
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
|
+
*/
|
|
18
25
|
items?: Iterable<T>;
|
|
19
|
-
/**
|
|
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. */
|
|
20
35
|
disabledKeys?: Iterable<string | number>;
|
|
21
|
-
/**
|
|
36
|
+
/** The selection mode: 'single' permits one selection, and 'multiple' permits more than one. */
|
|
22
37
|
selectionMode?: 'single' | 'multiple';
|
|
23
|
-
/**
|
|
38
|
+
/** The selected keys. By default it goes in the two directions: use `bind:value`. */
|
|
24
39
|
value?: Iterable<string | number>;
|
|
25
|
-
/**
|
|
40
|
+
/** The selection at the start, for when you give no `value`. */
|
|
26
41
|
defaultValue?: Iterable<string | number>;
|
|
27
42
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* the new selection
|
|
31
|
-
* case
|
|
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.
|
|
32
47
|
*/
|
|
33
48
|
controlledValue?: boolean;
|
|
34
|
-
/**
|
|
49
|
+
/** The content of the listbox. It can be static children, or a snippet that receives one item. */
|
|
35
50
|
children?: Snippet | Snippet<[T]>;
|
|
36
51
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
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.
|
|
40
55
|
*
|
|
41
|
-
*
|
|
42
|
-
* array,
|
|
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.
|
|
43
58
|
*/
|
|
44
59
|
header?: Snippet;
|
|
45
|
-
/** CSS class
|
|
60
|
+
/** The CSS class names of the listbox container. */
|
|
46
61
|
class?: string;
|
|
47
|
-
/**
|
|
62
|
+
/** The id of the listbox element. */
|
|
48
63
|
id?: string;
|
|
49
|
-
/**
|
|
64
|
+
/** The accessible name of the listbox. A screen reader announces it. */
|
|
50
65
|
'aria-label'?: string;
|
|
51
|
-
/**
|
|
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. */
|
|
52
72
|
onChange?: (value: Set<string | number>) => void;
|
|
53
|
-
/**
|
|
73
|
+
/** Stops the DOM focus control on the root container, for a composition with a virtual focus. */
|
|
54
74
|
disableFocusHandling?: boolean;
|
|
55
|
-
/**
|
|
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
|
+
*/
|
|
56
79
|
loop?: boolean;
|
|
57
|
-
/**
|
|
80
|
+
/** When the user types a character, the focus moves to the option whose text agrees with it. */
|
|
58
81
|
typeahead?: boolean;
|
|
59
82
|
/**
|
|
60
|
-
*
|
|
83
|
+
* Makes only the rows near the viewport, and not all of the rows.
|
|
61
84
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
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.
|
|
64
87
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* row
|
|
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.
|
|
68
92
|
*
|
|
69
|
-
* The listbox element
|
|
70
|
-
*
|
|
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.
|
|
71
95
|
*/
|
|
72
96
|
virtualizer?: { rowHeight?: number; overscan?: number };
|
|
73
|
-
}
|
|
97
|
+
} & Omit<
|
|
98
|
+
HTMLAttributes<HTMLDivElement>,
|
|
99
|
+
'class' | 'children' | 'role' | 'id' | 'aria-label' | 'aria-labelledby' | 'onchange'
|
|
100
|
+
>;
|
|
74
101
|
|
|
75
102
|
let {
|
|
76
103
|
selectionBehavior = 'toggle',
|
|
77
104
|
emptyPlaceholder = 'No items selected',
|
|
78
105
|
items,
|
|
106
|
+
getItemKey,
|
|
79
107
|
disabledKeys,
|
|
80
108
|
selectionMode = 'single',
|
|
81
109
|
value = $bindable(),
|
|
@@ -86,13 +114,20 @@
|
|
|
86
114
|
class: className = '',
|
|
87
115
|
id,
|
|
88
116
|
'aria-label': ariaLabel,
|
|
117
|
+
'aria-labelledby': ariaLabelledBy,
|
|
89
118
|
onChange,
|
|
90
119
|
disableFocusHandling = false,
|
|
91
120
|
loop = false,
|
|
92
121
|
typeahead = false,
|
|
93
122
|
virtualizer,
|
|
94
123
|
context = $bindable(),
|
|
95
|
-
element = $bindable()
|
|
124
|
+
element = $bindable(),
|
|
125
|
+
onkeydown: onKeyDownExternal,
|
|
126
|
+
onmousedown: onMouseDownExternal,
|
|
127
|
+
onfocusin: onFocusInExternal,
|
|
128
|
+
onfocusout: onFocusOutExternal,
|
|
129
|
+
onscroll: onScrollExternal,
|
|
130
|
+
...restProps
|
|
96
131
|
}: ListBoxProps & { context?: ListBoxContext; element?: HTMLElement } = $props();
|
|
97
132
|
|
|
98
133
|
let listboxElement: HTMLElement;
|
|
@@ -312,6 +347,29 @@
|
|
|
312
347
|
});
|
|
313
348
|
}
|
|
314
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
|
+
|
|
315
373
|
$effect(() => {
|
|
316
374
|
if (!isVirtual || !listboxElement) return;
|
|
317
375
|
|
|
@@ -324,6 +382,7 @@
|
|
|
324
382
|
const element = listboxElement;
|
|
325
383
|
|
|
326
384
|
measureRows();
|
|
385
|
+
labelPositions();
|
|
327
386
|
|
|
328
387
|
const observer = new ResizeObserver(() => {
|
|
329
388
|
untrack(() => {
|
|
@@ -332,6 +391,7 @@
|
|
|
332
391
|
}
|
|
333
392
|
});
|
|
334
393
|
measureRows();
|
|
394
|
+
labelPositions();
|
|
335
395
|
});
|
|
336
396
|
|
|
337
397
|
observer.observe(element);
|
|
@@ -400,6 +460,16 @@
|
|
|
400
460
|
// on its input) can reach a row the window hasn't rendered yet.
|
|
401
461
|
ctx.setScrollIndexIntoView(scrollIndexIntoView);
|
|
402
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
|
+
});
|
|
403
473
|
let hasMounted = $state(false);
|
|
404
474
|
const registeredItemCount = $derived(hasMounted ? itemCount : ctx.getItemCount());
|
|
405
475
|
const shouldShowEmptyPlaceholder = $derived(
|
|
@@ -441,6 +511,24 @@
|
|
|
441
511
|
ctx.setFocusVisible(true);
|
|
442
512
|
}
|
|
443
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
|
+
}
|
|
444
532
|
</script>
|
|
445
533
|
|
|
446
534
|
<div
|
|
@@ -449,15 +537,17 @@
|
|
|
449
537
|
{id}
|
|
450
538
|
aria-multiselectable={selectionMode === 'multiple'}
|
|
451
539
|
aria-label={ariaLabel}
|
|
540
|
+
aria-labelledby={ariaLabelledBy}
|
|
452
541
|
class={className}
|
|
453
542
|
tabindex={disableFocusHandling ? undefined : focusWithin ? -1 : 0}
|
|
454
543
|
data-focus-within={focusWithin || undefined}
|
|
455
544
|
use:keyboardAction
|
|
456
|
-
onfocusin={handleFocusIn}
|
|
457
|
-
onfocusout={handleFocusOut}
|
|
458
|
-
onmousedown={handleMouseDown}
|
|
459
|
-
onkeydown={handleKeyDown}
|
|
460
|
-
onscroll={handleScroll}
|
|
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}
|
|
461
551
|
>
|
|
462
552
|
{#if header}
|
|
463
553
|
{@render header()}
|
|
@@ -1,71 +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
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* the new selection
|
|
23
|
-
* case
|
|
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.
|
|
24
39
|
*/
|
|
25
40
|
controlledValue?: boolean;
|
|
26
|
-
/**
|
|
41
|
+
/** The content of the listbox. It can be static children, or a snippet that receives one item. */
|
|
27
42
|
children?: Snippet | Snippet<[T]>;
|
|
28
43
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
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.
|
|
32
47
|
*
|
|
33
|
-
*
|
|
34
|
-
* array,
|
|
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.
|
|
35
50
|
*/
|
|
36
51
|
header?: Snippet;
|
|
37
|
-
/** CSS class
|
|
52
|
+
/** The CSS class names of the listbox container. */
|
|
38
53
|
class?: string;
|
|
39
|
-
/**
|
|
54
|
+
/** The id of the listbox element. */
|
|
40
55
|
id?: string;
|
|
41
|
-
/**
|
|
56
|
+
/** The accessible name of the listbox. A screen reader announces it. */
|
|
42
57
|
'aria-label'?: string;
|
|
43
|
-
/**
|
|
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. */
|
|
44
64
|
onChange?: (value: Set<string | number>) => void;
|
|
45
|
-
/**
|
|
65
|
+
/** Stops the DOM focus control on the root container, for a composition with a virtual focus. */
|
|
46
66
|
disableFocusHandling?: boolean;
|
|
47
|
-
/**
|
|
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
|
+
*/
|
|
48
71
|
loop?: boolean;
|
|
49
|
-
/**
|
|
72
|
+
/** When the user types a character, the focus moves to the option whose text agrees with it. */
|
|
50
73
|
typeahead?: boolean;
|
|
51
74
|
/**
|
|
52
|
-
*
|
|
75
|
+
* Makes only the rows near the viewport, and not all of the rows.
|
|
53
76
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
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.
|
|
56
79
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* row
|
|
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.
|
|
60
84
|
*
|
|
61
|
-
* The listbox element
|
|
62
|
-
*
|
|
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.
|
|
63
87
|
*/
|
|
64
88
|
virtualizer?: {
|
|
65
89
|
rowHeight?: number;
|
|
66
90
|
overscan?: number;
|
|
67
91
|
};
|
|
68
|
-
} & {
|
|
92
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, "children" | "class" | "id" | "role" | "aria-label" | "aria-labelledby" | "onchange"> & {
|
|
69
93
|
context?: ListBoxContext;
|
|
70
94
|
element?: HTMLElement;
|
|
71
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:
|
package/dist/menu/README.md
CHANGED
|
@@ -12,6 +12,7 @@ primitives as `Popover`.
|
|
|
12
12
|
- Use `Menu.Root` to share open state and the trigger reference.
|
|
13
13
|
- Use `Menu.Trigger` as the opener button. `ArrowDown`/`Enter`/`Space` open the menu and focus the
|
|
14
14
|
first item; `ArrowUp` opens and focuses the last item.
|
|
15
|
+
- Use `Menu.ContextTrigger` in place of `Menu.Trigger` to open the menu from a surface, and not from a button. It opens from a right click, a long press, the `Shift+F10` keys, or the `ContextMenu` key.
|
|
15
16
|
- Use `Menu.Content` inside `Menu.Root`. It renders the `role="menu"` panel in a portal and
|
|
16
17
|
positions it against the trigger (default placement `bottom-start`).
|
|
17
18
|
- Use `Menu.Item` for actions. Provide `onAction`, and optionally `disabled`, `closeOnSelect`, or
|
|
@@ -29,9 +30,33 @@ primitives as `Popover`.
|
|
|
29
30
|
typed text.
|
|
30
31
|
- Escape closes the current (topmost) menu and returns focus to its trigger. `Tab` and outside
|
|
31
32
|
interaction close the whole menu chain. Within a submenu, `ArrowLeft` closes just that level.
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
- A submenu uses a safe triangle for the pointer. While the pointer moves at an angle to the open submenu, the items that the pointer goes over do not close it. This continues for a short time. Thus the user gets to the submenu, and the submenu stays open.
|
|
34
|
+
|
|
35
|
+
## Context menus
|
|
36
|
+
|
|
37
|
+
`Menu.ContextTrigger` is a surface, not a button: it renders a plain element so it can wrap
|
|
38
|
+
arbitrary — sometimes interactive — content. It opens the menu three ways, and each anchors the
|
|
39
|
+
panel differently:
|
|
40
|
+
|
|
41
|
+
- A right click puts the menu at the pointer, against it. For a context menu, `Menu.Content` makes its default `offset` `0`. The panel opens down and to the right, like a native menu. Right
|
|
42
|
+
clicking again re-anchors the open menu instead of closing and reopening it.
|
|
43
|
+
- **Long press** on touch or pen — anchored at the finger. It is what makes the menu reachable at
|
|
44
|
+
all on a phone, where `contextmenu` is unreliable. The action stops the `click` event and the `contextmenu` event of the same gesture. The surface also sets `-webkit-touch-callout: none; user-select: none` in its style attribute. Thus iOS shows the menu and not the text callout. Turn either off with `longPress={false}` / `preventTouchCallout={false}`.
|
|
45
|
+
- **`Shift+F10` or the `ContextMenu` key** — anchored to the surface itself, with the first item
|
|
46
|
+
focused. There is no pointer involved, so reusing the last cursor position would put the panel
|
|
47
|
+
somewhere the keyboard user never pointed at.
|
|
48
|
+
|
|
49
|
+
A left press anywhere — including on the surface itself — dismisses it, like a native menu.
|
|
50
|
+
|
|
51
|
+
### Accessibility
|
|
52
|
+
|
|
53
|
+
By default, the surface is a tab stop (`tabindex={0}`), thus a keyboard user can go to it. Give `tabindex={-1}` when the surface is in a component that already controls the focus with a roving tabindex, for example a table or a tree.
|
|
54
|
+
|
|
55
|
+
It carries `aria-keyshortcuts="Shift+F10"` and nothing else. `aria-haspopup` and `aria-expanded`
|
|
56
|
+
are **not** global ARIA properties: on a generic element they would be invalid, so the component
|
|
57
|
+
does not claim them. That is a real limit, not an oversight — **a context menu must never be the
|
|
58
|
+
only route to an action.** Give the same `Menu.Root` a visible `Menu.Trigger`, or expose the same
|
|
59
|
+
actions elsewhere in the UI.
|
|
35
60
|
|
|
36
61
|
## onOpenChange details
|
|
37
62
|
|
|
@@ -40,13 +65,24 @@ primitives as `Popover`.
|
|
|
40
65
|
- `onOpenChange(open, details)`
|
|
41
66
|
- `details.reason`: `trigger-press | imperative-action | none | escape-key | outside-press | focus-out | item-select`
|
|
42
67
|
- `details.event?`: native event that triggered the change when available
|
|
43
|
-
- `details.cancel()`:
|
|
68
|
+
- `details.cancel()`: stops the change of the open state
|
|
44
69
|
- `details.isCanceled`: reflects cancellation state inside the callback
|
|
45
70
|
|
|
46
71
|
## Anatomy
|
|
47
72
|
|
|
48
73
|
Import the component and compose its parts:
|
|
49
74
|
|
|
75
|
+
A context menu swaps the trigger and keeps everything else:
|
|
76
|
+
|
|
77
|
+
```svelte
|
|
78
|
+
<Menu.Root>
|
|
79
|
+
<Menu.ContextTrigger>Right click anywhere in this card</Menu.ContextTrigger>
|
|
80
|
+
<Menu.Content>
|
|
81
|
+
<Menu.Item onAction={edit}>Edit</Menu.Item>
|
|
82
|
+
</Menu.Content>
|
|
83
|
+
</Menu.Root>
|
|
84
|
+
```
|
|
85
|
+
|
|
50
86
|
```svelte
|
|
51
87
|
<Menu.Root>
|
|
52
88
|
<Menu.Trigger>Options</Menu.Trigger>
|
|
@@ -74,6 +110,7 @@ Import the component and compose its parts:
|
|
|
74
110
|
|
|
75
111
|
- `Menu.Root`
|
|
76
112
|
- `Menu.Trigger`
|
|
113
|
+
- `Menu.ContextTrigger`
|
|
77
114
|
- `Menu.Content`
|
|
78
115
|
- `Menu.Item`
|
|
79
116
|
- `Menu.Separator`
|