@human-kit/ui 1.0.0-beta.1 → 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 +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 +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/types.d.ts +19 -10
- package/package.json +56 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
4
|
+
import type { ToastProviderProps } from '../types.js';
|
|
5
|
+
import { setToastProviderContext, type ToastProviderContext } from './context';
|
|
6
|
+
import {
|
|
7
|
+
createToastManager,
|
|
8
|
+
DEFAULT_TOAST_LIMIT,
|
|
9
|
+
DEFAULT_TOAST_TIMEOUT,
|
|
10
|
+
type InternalToastManager
|
|
11
|
+
} from './toast-manager.svelte';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Toast.Provider — the list of toasts, and the manager that adds to it.
|
|
15
|
+
*
|
|
16
|
+
* Put one around the app, thus every toast lands in the same viewport. The manager is on
|
|
17
|
+
* `bind:manager` for the page, and on `useToastManager()` for a component under the provider.
|
|
18
|
+
* Give `manager` to share one list between two providers, such as an app and a dialog in it.
|
|
19
|
+
*/
|
|
20
|
+
let {
|
|
21
|
+
timeout = DEFAULT_TOAST_TIMEOUT,
|
|
22
|
+
limit = DEFAULT_TOAST_LIMIT,
|
|
23
|
+
manager: managerProp = $bindable(),
|
|
24
|
+
children
|
|
25
|
+
}: ToastProviderProps = $props();
|
|
26
|
+
|
|
27
|
+
const manager: InternalToastManager = untrack(
|
|
28
|
+
() =>
|
|
29
|
+
(managerProp as InternalToastManager | undefined) ??
|
|
30
|
+
createToastManager({ timeout: () => timeout, limit: () => limit })
|
|
31
|
+
);
|
|
32
|
+
managerProp = manager;
|
|
33
|
+
|
|
34
|
+
// A new limit takes effect on the toasts that are already there.
|
|
35
|
+
$effect(() => {
|
|
36
|
+
void limit;
|
|
37
|
+
untrack(() => manager.syncLimit());
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
let hovering = $state(false);
|
|
41
|
+
let focused = $state(false);
|
|
42
|
+
let tapped = $state(false);
|
|
43
|
+
let viewportElement = $state<HTMLElement | null>(null);
|
|
44
|
+
const heights = new SvelteMap<string, number>();
|
|
45
|
+
let focusAfterCloseHandler: ((id: string) => void) | null = null;
|
|
46
|
+
|
|
47
|
+
const context: ToastProviderContext = {
|
|
48
|
+
manager,
|
|
49
|
+
get hovering() {
|
|
50
|
+
return hovering;
|
|
51
|
+
},
|
|
52
|
+
get focused() {
|
|
53
|
+
return focused;
|
|
54
|
+
},
|
|
55
|
+
get tapped() {
|
|
56
|
+
return tapped;
|
|
57
|
+
},
|
|
58
|
+
get expanded() {
|
|
59
|
+
return hovering || focused || tapped;
|
|
60
|
+
},
|
|
61
|
+
get viewportElement() {
|
|
62
|
+
return viewportElement;
|
|
63
|
+
},
|
|
64
|
+
get heights() {
|
|
65
|
+
return heights;
|
|
66
|
+
},
|
|
67
|
+
setHovering(value) {
|
|
68
|
+
hovering = value;
|
|
69
|
+
},
|
|
70
|
+
setFocused(value) {
|
|
71
|
+
focused = value;
|
|
72
|
+
},
|
|
73
|
+
setTapped(value) {
|
|
74
|
+
tapped = value;
|
|
75
|
+
},
|
|
76
|
+
setViewportElement(element) {
|
|
77
|
+
viewportElement = element;
|
|
78
|
+
},
|
|
79
|
+
// `untrack` because the root measures from an effect: reading the map here would make
|
|
80
|
+
// that effect depend on what it writes.
|
|
81
|
+
setHeight(id, height) {
|
|
82
|
+
untrack(() => {
|
|
83
|
+
if (height === null) heights.delete(id);
|
|
84
|
+
else if (heights.get(id) !== height) heights.set(id, height);
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
focusAfterClose(id) {
|
|
88
|
+
focusAfterCloseHandler?.(id);
|
|
89
|
+
},
|
|
90
|
+
setFocusAfterClose(handler) {
|
|
91
|
+
focusAfterCloseHandler = handler;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
setToastProviderContext(context);
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
{@render children?.()}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToastItem } from '../provider/toast-manager.svelte';
|
|
2
|
+
export type ToastContext = {
|
|
3
|
+
/** The item of this toast. */
|
|
4
|
+
readonly toast: ToastItem;
|
|
5
|
+
/** The ids of the registered titles, for `aria-labelledby`. */
|
|
6
|
+
readonly labelledBy: string | undefined;
|
|
7
|
+
/** The ids of the registered descriptions, for `aria-describedby`. */
|
|
8
|
+
readonly describedBy: string | undefined;
|
|
9
|
+
/** Registers a title id; the returned function unregisters it. */
|
|
10
|
+
registerTitle: (id: string) => () => void;
|
|
11
|
+
/** Registers a description id; the returned function unregisters it. */
|
|
12
|
+
registerDescription: (id: string) => () => void;
|
|
13
|
+
/** Closes this toast, and moves the focus on when it was in it. */
|
|
14
|
+
close: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function setToastContext(context: ToastContext): void;
|
|
17
|
+
export declare function getToastContext(): ToastContext | undefined;
|
|
18
|
+
export declare function useToastContext(part?: string): ToastContext;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const KEY = Symbol('toast');
|
|
3
|
+
export function setToastContext(context) {
|
|
4
|
+
setContext(KEY, context);
|
|
5
|
+
}
|
|
6
|
+
export function getToastContext() {
|
|
7
|
+
return getContext(KEY);
|
|
8
|
+
}
|
|
9
|
+
export function useToastContext(part = 'Toast') {
|
|
10
|
+
const context = getToastContext();
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error(`${part} must be used within Toast.Root.`);
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import { createPresence } from '../../primitives/presence.svelte';
|
|
4
|
+
import {
|
|
5
|
+
getSwipeAxis,
|
|
6
|
+
swipeGesture,
|
|
7
|
+
type SwipeSide,
|
|
8
|
+
type SwipeGestureOptions
|
|
9
|
+
} from '../../primitives/swipe-gesture';
|
|
10
|
+
import { useToastProviderContext } from '../provider/context';
|
|
11
|
+
import type { ToastRootProps } from '../types.js';
|
|
12
|
+
import { setToastContext, type ToastContext } from './context';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Toast.Root — one toast.
|
|
16
|
+
*
|
|
17
|
+
* It is a `role="dialog"` that is not modal, or an `alertdialog` for a high priority: a
|
|
18
|
+
* screen reader user who moves into the region hears its name and its description, and can
|
|
19
|
+
* press its buttons. It is a tab stop, thus the keyboard reaches it after `F6`. `Escape`
|
|
20
|
+
* closes it, and so does a swipe in one of `swipeDirection`, which follows the finger and
|
|
21
|
+
* comes back when the swipe is short. It leaves the DOM after its exit animation.
|
|
22
|
+
*/
|
|
23
|
+
const SWIPE_THRESHOLD_PX = 40;
|
|
24
|
+
const FLICK_VELOCITY_PX_MS = 0.5;
|
|
25
|
+
// A pull the wrong way gives a little, and no more: the toast behind must not come into view.
|
|
26
|
+
const INWARD_PULL_MAX_PX = 8;
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
toast,
|
|
30
|
+
children,
|
|
31
|
+
class: className = '',
|
|
32
|
+
swipeDirection = ['bottom', 'right'],
|
|
33
|
+
element = $bindable<HTMLDivElement | null>(null),
|
|
34
|
+
onkeydown,
|
|
35
|
+
style,
|
|
36
|
+
...restProps
|
|
37
|
+
}: ToastRootProps = $props();
|
|
38
|
+
|
|
39
|
+
const ctx = useToastProviderContext('Toast.Root');
|
|
40
|
+
const manager = ctx.manager;
|
|
41
|
+
|
|
42
|
+
let rootRef: HTMLDivElement | null = $state(null);
|
|
43
|
+
let titleIds = $state<string[]>([]);
|
|
44
|
+
let descriptionIds = $state<string[]>([]);
|
|
45
|
+
|
|
46
|
+
const isEnding = $derived(toast.status === 'ending');
|
|
47
|
+
// The order in the corner: the toasts on the screen, and behind them the ones that wait past
|
|
48
|
+
// the limit. A toast that waits takes the place after the stack, thus it comes forward one
|
|
49
|
+
// step when a place frees. A place of 0 would put it in front, and it would walk from there.
|
|
50
|
+
const stackOrder = $derived([
|
|
51
|
+
...manager.stackedToasts,
|
|
52
|
+
...manager.toasts.filter((candidate) => candidate.limited && !candidate.anchor)
|
|
53
|
+
]);
|
|
54
|
+
// A toast against an anchor is out of the stack: `index` is -1, and the vars read 0.
|
|
55
|
+
const liveIndex = $derived(stackOrder.findIndex((candidate) => candidate.id === toast.id));
|
|
56
|
+
const height = $derived(ctx.heights.get(toast.id) ?? null);
|
|
57
|
+
// The height of the toasts in front, for a stack that shifts the ones behind.
|
|
58
|
+
const liveOffsetY = $derived.by(() => {
|
|
59
|
+
if (liveIndex <= 0) return 0;
|
|
60
|
+
let total = 0;
|
|
61
|
+
for (const candidate of stackOrder.slice(0, liveIndex)) {
|
|
62
|
+
total += ctx.heights.get(candidate.id) ?? 0;
|
|
63
|
+
}
|
|
64
|
+
return total;
|
|
65
|
+
});
|
|
66
|
+
// A toast on its way out is out of the stack, thus the ones behind it move up at once. It
|
|
67
|
+
// keeps the place it had for its exit motion: a place of 0 would put it under the front one.
|
|
68
|
+
let lastIndex = -1;
|
|
69
|
+
let lastOffsetY = 0;
|
|
70
|
+
const index = $derived.by(() => {
|
|
71
|
+
if (isEnding) return lastIndex;
|
|
72
|
+
lastIndex = liveIndex;
|
|
73
|
+
return liveIndex;
|
|
74
|
+
});
|
|
75
|
+
const offsetY = $derived.by(() => {
|
|
76
|
+
if (isEnding) return lastOffsetY;
|
|
77
|
+
lastOffsetY = liveOffsetY;
|
|
78
|
+
return liveOffsetY;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
function close() {
|
|
82
|
+
manager.close(toast.id);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// A close from anywhere, also from the page through the manager, moves the focus on when it
|
|
86
|
+
// was in this toast. Otherwise the focus would fall to the body with the element.
|
|
87
|
+
$effect(() => {
|
|
88
|
+
if (!isEnding) return;
|
|
89
|
+
const node = rootRef;
|
|
90
|
+
const active = document.activeElement;
|
|
91
|
+
if (node && active instanceof Node && node.contains(active)) {
|
|
92
|
+
untrack(() => ctx.focusAfterClose(toast.id));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
function register(list: 'title' | 'description', id: string) {
|
|
97
|
+
untrack(() => {
|
|
98
|
+
if (list === 'title') titleIds = [...titleIds, id];
|
|
99
|
+
else descriptionIds = [...descriptionIds, id];
|
|
100
|
+
});
|
|
101
|
+
return () =>
|
|
102
|
+
untrack(() => {
|
|
103
|
+
if (list === 'title') titleIds = titleIds.filter((candidate) => candidate !== id);
|
|
104
|
+
else descriptionIds = descriptionIds.filter((candidate) => candidate !== id);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const context: ToastContext = {
|
|
109
|
+
get toast() {
|
|
110
|
+
return toast;
|
|
111
|
+
},
|
|
112
|
+
get labelledBy() {
|
|
113
|
+
return titleIds.length > 0 ? titleIds.join(' ') : undefined;
|
|
114
|
+
},
|
|
115
|
+
get describedBy() {
|
|
116
|
+
return descriptionIds.length > 0 ? descriptionIds.join(' ') : undefined;
|
|
117
|
+
},
|
|
118
|
+
registerTitle: (id) => register('title', id),
|
|
119
|
+
registerDescription: (id) => register('description', id),
|
|
120
|
+
close
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
setToastContext(context);
|
|
124
|
+
|
|
125
|
+
$effect(() => {
|
|
126
|
+
element = rootRef;
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// The size feeds the stack: the viewport clamps the toasts behind to the one in front, and
|
|
130
|
+
// each toast shifts by the heights of the ones in front of it.
|
|
131
|
+
$effect(() => {
|
|
132
|
+
const node = rootRef;
|
|
133
|
+
if (!node || typeof ResizeObserver === 'undefined') return;
|
|
134
|
+
const id = toast.id;
|
|
135
|
+
const measure = () => ctx.setHeight(id, node.offsetHeight);
|
|
136
|
+
measure();
|
|
137
|
+
const observer = new ResizeObserver(measure);
|
|
138
|
+
observer.observe(node);
|
|
139
|
+
return () => {
|
|
140
|
+
observer.disconnect();
|
|
141
|
+
ctx.setHeight(id, null);
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Mounted through the exit animation, timed from the CSS motion of the element.
|
|
146
|
+
const presence = createPresence(
|
|
147
|
+
() => !isEnding,
|
|
148
|
+
() => rootRef
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
$effect(() => {
|
|
152
|
+
if (isEnding && !presence.isMounted) {
|
|
153
|
+
untrack(() => manager.remove(toast.id));
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
function handleKeyDown(event: KeyboardEvent & { currentTarget: EventTarget & HTMLDivElement }) {
|
|
158
|
+
onkeydown?.(event);
|
|
159
|
+
if (event.defaultPrevented || event.key !== 'Escape') return;
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
close();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// --- Swipe --------------------------------------------------------------------------------
|
|
165
|
+
|
|
166
|
+
let swipeX = $state(0);
|
|
167
|
+
let swipeY = $state(0);
|
|
168
|
+
let swiping = $state(false);
|
|
169
|
+
let swipeSide = $state<SwipeSide | null>(null);
|
|
170
|
+
let dismissedBySwipe = $state(false);
|
|
171
|
+
|
|
172
|
+
function sidesByAxis(): { x: SwipeSide | null; y: SwipeSide | null } {
|
|
173
|
+
let x: SwipeSide | null = null;
|
|
174
|
+
let y: SwipeSide | null = null;
|
|
175
|
+
for (const side of swipeDirection) {
|
|
176
|
+
if (getSwipeAxis(side) === 'x') x ??= side;
|
|
177
|
+
else y ??= side;
|
|
178
|
+
}
|
|
179
|
+
return { x, y };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function gestureOptions(side: SwipeSide): SwipeGestureOptions {
|
|
183
|
+
const axis = getSwipeAxis(side);
|
|
184
|
+
const sign = side === 'right' || side === 'bottom' ? 1 : -1;
|
|
185
|
+
return {
|
|
186
|
+
side,
|
|
187
|
+
onStart: () => {
|
|
188
|
+
swiping = true;
|
|
189
|
+
swipeSide = side;
|
|
190
|
+
manager.pauseTimers();
|
|
191
|
+
},
|
|
192
|
+
onMove: ({ displacement }) => {
|
|
193
|
+
// The toast follows the finger outward. A pull the other way is a rubber band that
|
|
194
|
+
// stops short of the toast behind.
|
|
195
|
+
const pull = -displacement;
|
|
196
|
+
const outward =
|
|
197
|
+
displacement >= 0
|
|
198
|
+
? displacement
|
|
199
|
+
: -(INWARD_PULL_MAX_PX * pull) / (pull + INWARD_PULL_MAX_PX);
|
|
200
|
+
if (axis === 'x') swipeX = outward * sign;
|
|
201
|
+
else swipeY = outward * sign;
|
|
202
|
+
},
|
|
203
|
+
onEnd: ({ displacement, velocity }) => {
|
|
204
|
+
swiping = false;
|
|
205
|
+
const dismiss = displacement > SWIPE_THRESHOLD_PX || velocity > FLICK_VELOCITY_PX_MS;
|
|
206
|
+
if (dismiss) {
|
|
207
|
+
dismissedBySwipe = true;
|
|
208
|
+
close();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
swipeX = 0;
|
|
212
|
+
swipeY = 0;
|
|
213
|
+
swipeSide = null;
|
|
214
|
+
if (!ctx.expanded) manager.resumeTimers();
|
|
215
|
+
},
|
|
216
|
+
onCancel: () => {
|
|
217
|
+
swiping = false;
|
|
218
|
+
swipeX = 0;
|
|
219
|
+
swipeY = 0;
|
|
220
|
+
swipeSide = null;
|
|
221
|
+
if (!ctx.expanded) manager.resumeTimers();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
$effect(() => {
|
|
227
|
+
const node = rootRef;
|
|
228
|
+
if (!node) return;
|
|
229
|
+
const { x, y } = sidesByAxis();
|
|
230
|
+
const gestures = [x, y]
|
|
231
|
+
.filter((side): side is SwipeSide => side !== null)
|
|
232
|
+
.map((side) => swipeGesture(node, gestureOptions(side)));
|
|
233
|
+
return () => {
|
|
234
|
+
for (const gesture of gestures) gesture.destroy();
|
|
235
|
+
};
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// The browser must not turn the drag into a scroll before the gesture claims it: the axis a
|
|
239
|
+
// swipe takes is closed to the native pan, and the other one stays open. A toast holds no
|
|
240
|
+
// scrolling content of its own, thus nothing in it loses a scroll.
|
|
241
|
+
const touchAction = $derived.by(() => {
|
|
242
|
+
const { x, y } = sidesByAxis();
|
|
243
|
+
if (x && y) return 'none';
|
|
244
|
+
if (x) return 'pan-y';
|
|
245
|
+
if (y) return 'pan-x';
|
|
246
|
+
return null;
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const role = $derived(toast.priority === 'high' ? 'alertdialog' : 'dialog');
|
|
250
|
+
const inlineStyle = $derived(
|
|
251
|
+
[
|
|
252
|
+
`--toast-index: ${index < 0 ? 0 : index};`,
|
|
253
|
+
`--toast-offset-y: ${offsetY}px;`,
|
|
254
|
+
height === null ? '' : `--toast-height: ${height}px;`,
|
|
255
|
+
`--toast-swipe-movement-x: ${swipeX}px;`,
|
|
256
|
+
`--toast-swipe-movement-y: ${swipeY}px;`,
|
|
257
|
+
touchAction === null ? '' : `touch-action: ${touchAction};`,
|
|
258
|
+
style ?? ''
|
|
259
|
+
]
|
|
260
|
+
.filter(Boolean)
|
|
261
|
+
.join(' ')
|
|
262
|
+
);
|
|
263
|
+
</script>
|
|
264
|
+
|
|
265
|
+
<!-- A dialog is a tab stop here on purpose: `F6` lands on it, and the keyboard reads it whole
|
|
266
|
+
before it reaches the buttons in it. -->
|
|
267
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
268
|
+
<div
|
|
269
|
+
{...restProps}
|
|
270
|
+
bind:this={rootRef}
|
|
271
|
+
{role}
|
|
272
|
+
aria-modal="false"
|
|
273
|
+
tabindex="0"
|
|
274
|
+
aria-labelledby={context.labelledBy ?? context.describedBy}
|
|
275
|
+
aria-describedby={context.labelledBy ? context.describedBy : undefined}
|
|
276
|
+
inert={toast.limited || undefined}
|
|
277
|
+
class={className}
|
|
278
|
+
style={inlineStyle}
|
|
279
|
+
data-toast-root="true"
|
|
280
|
+
data-toast-id={toast.id}
|
|
281
|
+
data-type={toast.type}
|
|
282
|
+
data-priority={toast.priority}
|
|
283
|
+
data-front={(index === 0 && !isEnding && !toast.limited) || undefined}
|
|
284
|
+
data-anchored={Boolean(toast.anchor) || undefined}
|
|
285
|
+
data-limited={toast.limited || undefined}
|
|
286
|
+
data-expanded={ctx.expanded || undefined}
|
|
287
|
+
data-ending={isEnding || undefined}
|
|
288
|
+
data-entering={presence.isEntering || undefined}
|
|
289
|
+
data-exiting={presence.isExiting || undefined}
|
|
290
|
+
data-swiping={swiping || undefined}
|
|
291
|
+
data-swipe-direction={swipeSide ?? undefined}
|
|
292
|
+
data-swipe-dismissed={dismissedBySwipe || undefined}
|
|
293
|
+
onkeydown={handleKeyDown}
|
|
294
|
+
>
|
|
295
|
+
{@render children?.()}
|
|
296
|
+
</div>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useToastContext } from '../root/context';
|
|
3
|
+
import type { ToastTitleProps } from '../types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Toast.Title — the name of the toast.
|
|
7
|
+
*
|
|
8
|
+
* It registers its id with the root, which gives it to the toast as `aria-labelledby`. It
|
|
9
|
+
* renders a `<div>` and not a heading: a toast is not a section of the page, and a heading
|
|
10
|
+
* in it would break the outline of the page. Without children, it shows the `title` of the
|
|
11
|
+
* item.
|
|
12
|
+
*/
|
|
13
|
+
let { children, class: className = '', id: idProp, ...restProps }: ToastTitleProps = $props();
|
|
14
|
+
|
|
15
|
+
const ctx = useToastContext('Toast.Title');
|
|
16
|
+
const generatedId = $props.id();
|
|
17
|
+
const id = $derived(idProp ?? generatedId);
|
|
18
|
+
|
|
19
|
+
// Without children and without a `title` on the item there is nothing to say: the part
|
|
20
|
+
// renders nothing, and it gives no name. The description then names the toast.
|
|
21
|
+
const hasContent = $derived(Boolean(children) || Boolean(ctx.toast.title));
|
|
22
|
+
|
|
23
|
+
// The returned unregister runs on destroy, and again whenever the id changes.
|
|
24
|
+
$effect(() => {
|
|
25
|
+
if (!hasContent) return;
|
|
26
|
+
return ctx.registerTitle(id);
|
|
27
|
+
});
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
{#if hasContent}
|
|
31
|
+
<div {...restProps} {id} class={className} data-toast-title="true">
|
|
32
|
+
{#if children}
|
|
33
|
+
{@render children()}
|
|
34
|
+
{:else}
|
|
35
|
+
{ctx.toast.title}
|
|
36
|
+
{/if}
|
|
37
|
+
</div>
|
|
38
|
+
{/if}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ToastItem, ToastManager } from './provider/toast-manager.svelte.js';
|
|
4
|
+
import type { SwipeSide } from '../primitives/swipe-gesture.js';
|
|
5
|
+
export type { ToastItem, ToastManager, ToastOptions, ToastPriority, ToastPromiseOptions, ToastStatus, ToastUpdate } from './provider/toast-manager.svelte.js';
|
|
6
|
+
export type ToastProviderProps = {
|
|
7
|
+
/** The default time a toast stays, in milliseconds. `0` keeps each toast until a close. */
|
|
8
|
+
timeout?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The count of toasts on the screen. The older ones past it wait behind, hidden and inert,
|
|
11
|
+
* with their timers stopped, and they come forward as the newer ones close.
|
|
12
|
+
*/
|
|
13
|
+
limit?: number;
|
|
14
|
+
/**
|
|
15
|
+
* The manager: `add`, `update`, `close` and `promise`. Use `bind:manager` to read it in the
|
|
16
|
+
* page, or give one to share a list of toasts between two providers.
|
|
17
|
+
*/
|
|
18
|
+
manager?: ToastManager;
|
|
19
|
+
/** The app, with a `Toast.Viewport` somewhere in it. */
|
|
20
|
+
children?: Snippet;
|
|
21
|
+
};
|
|
22
|
+
export type ToastViewportProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'role' | 'tabindex'> & {
|
|
23
|
+
/** The toast to render for each item. It gets the item; render a `Toast.Root` with it. */
|
|
24
|
+
children: Snippet<[ToastItem]>;
|
|
25
|
+
/** The CSS class names of the element. */
|
|
26
|
+
class?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Renders the viewport at the end of `<body>`, thus it draws above the page. Set it to
|
|
29
|
+
* `false` to render it in place.
|
|
30
|
+
*/
|
|
31
|
+
portal?: boolean;
|
|
32
|
+
/** The bindable viewport element. */
|
|
33
|
+
element?: HTMLDivElement | null;
|
|
34
|
+
};
|
|
35
|
+
export type ToastRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'role' | 'tabindex' | 'id'> & {
|
|
36
|
+
/** The item from `Toast.Viewport`. */
|
|
37
|
+
toast: ToastItem;
|
|
38
|
+
/** The parts of the toast. */
|
|
39
|
+
children?: Snippet;
|
|
40
|
+
/** The CSS class names of the element. */
|
|
41
|
+
class?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The sides a swipe can push the toast out through: `bottom` and `right` by default. One side
|
|
44
|
+
* per axis counts. An empty array turns the swipe off. A swipe on `Toast.Close` or
|
|
45
|
+
* `Toast.Action` never starts.
|
|
46
|
+
*/
|
|
47
|
+
swipeDirection?: SwipeSide[];
|
|
48
|
+
/** The bindable toast element. */
|
|
49
|
+
element?: HTMLDivElement | null;
|
|
50
|
+
};
|
|
51
|
+
export type ToastPositionerProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
52
|
+
/** The item from `Toast.Viewport`. */
|
|
53
|
+
toast: ToastItem;
|
|
54
|
+
/** The `Toast.Root`. */
|
|
55
|
+
children?: Snippet;
|
|
56
|
+
/** The CSS class names of the element. */
|
|
57
|
+
class?: string;
|
|
58
|
+
/** The bindable positioner element. */
|
|
59
|
+
element?: HTMLDivElement | null;
|
|
60
|
+
};
|
|
61
|
+
export type ToastContentProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
62
|
+
/** The title and the description. */
|
|
63
|
+
children?: Snippet;
|
|
64
|
+
/** The CSS class names of the element. */
|
|
65
|
+
class?: string;
|
|
66
|
+
};
|
|
67
|
+
export type ToastTitleProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'id'> & {
|
|
68
|
+
/** The title. Without children, it shows the `title` of the item. */
|
|
69
|
+
children?: Snippet;
|
|
70
|
+
/** The CSS class names of the element. */
|
|
71
|
+
class?: string;
|
|
72
|
+
/** The id of the element. The component makes one when you give none. */
|
|
73
|
+
id?: string;
|
|
74
|
+
};
|
|
75
|
+
export type ToastDescriptionProps = Omit<HTMLAttributes<HTMLParagraphElement>, 'children' | 'class' | 'id'> & {
|
|
76
|
+
/** The description. Without children, it shows the `description` of the item. */
|
|
77
|
+
children?: Snippet;
|
|
78
|
+
/** The CSS class names of the element. */
|
|
79
|
+
class?: string;
|
|
80
|
+
/** The id of the element. The component makes one when you give none. */
|
|
81
|
+
id?: string;
|
|
82
|
+
};
|
|
83
|
+
export type ToastCloseProps = Omit<HTMLButtonAttributes, 'type' | 'class' | 'children'> & {
|
|
84
|
+
/** The name on the button. */
|
|
85
|
+
children?: Snippet;
|
|
86
|
+
/** The CSS class names of the element. */
|
|
87
|
+
class?: string;
|
|
88
|
+
/** The bindable button element. */
|
|
89
|
+
element?: HTMLButtonElement | null;
|
|
90
|
+
};
|
|
91
|
+
export type ToastActionProps = Omit<HTMLButtonAttributes, 'type' | 'class' | 'children'> & {
|
|
92
|
+
/** The name on the button. */
|
|
93
|
+
children?: Snippet;
|
|
94
|
+
/** The CSS class names of the element. */
|
|
95
|
+
class?: string;
|
|
96
|
+
/** Keeps the toast open after the press. By default, the press closes it. */
|
|
97
|
+
keepOpen?: boolean;
|
|
98
|
+
/** The bindable button element. */
|
|
99
|
+
element?: HTMLButtonElement | null;
|
|
100
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|