@human-kit/ui 1.0.0-beta.0 → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -16
- package/dist/FOCUS_STATE_CONTRACT.md +18 -4
- package/dist/FOCUS_STATE_REVIEW_TEMPLATE.md +8 -8
- package/dist/accordion/README.md +3 -3
- package/dist/accordion/root/accordion-root.svelte +15 -3
- package/dist/accordion/root/context.svelte.js +4 -4
- package/dist/accordion/types.d.ts +40 -19
- package/dist/autocomplete/README.md +6 -7
- package/dist/autocomplete/empty/autocomplete-empty.svelte +1 -1
- package/dist/autocomplete/empty/autocomplete-empty.svelte.d.ts +1 -1
- package/dist/autocomplete/input/autocomplete-input.svelte +3 -3
- package/dist/autocomplete/input/autocomplete-input.svelte.d.ts +3 -3
- package/dist/autocomplete/item/autocomplete-item.svelte +10 -0
- package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte +2 -2
- package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte.d.ts +2 -2
- package/dist/autocomplete/list/autocomplete-list.svelte +2 -2
- package/dist/autocomplete/list/autocomplete-list.svelte.d.ts +11 -3
- package/dist/autocomplete/root/autocomplete.svelte +7 -7
- package/dist/autocomplete/root/autocomplete.svelte.d.ts +7 -7
- package/dist/autocomplete/status/autocomplete-status.svelte +1 -1
- package/dist/autocomplete/status/autocomplete-status.svelte.d.ts +1 -1
- package/dist/avatar/README.md +52 -0
- package/dist/avatar/count/avatar-count.svelte +56 -0
- package/dist/avatar/count/avatar-count.svelte.d.ts +4 -0
- package/dist/avatar/fallback/avatar-fallback.svelte +67 -0
- package/dist/avatar/fallback/avatar-fallback.svelte.d.ts +4 -0
- package/dist/avatar/group/avatar-group.svelte +65 -0
- package/dist/avatar/group/avatar-group.svelte.d.ts +4 -0
- package/dist/avatar/group/context.d.ts +15 -0
- package/dist/avatar/group/context.js +15 -0
- package/dist/avatar/image/avatar-image.svelte +104 -0
- package/dist/avatar/image/avatar-image.svelte.d.ts +4 -0
- package/dist/avatar/index.d.ts +22 -0
- package/dist/avatar/index.js +10 -0
- package/dist/avatar/index.parts.d.ts +5 -0
- package/dist/avatar/index.parts.js +5 -0
- package/dist/avatar/root/avatar-root.svelte +79 -0
- package/dist/avatar/root/avatar-root.svelte.d.ts +4 -0
- package/dist/avatar/root/context.d.ts +14 -0
- package/dist/avatar/root/context.js +15 -0
- package/dist/avatar/types.d.ts +84 -0
- package/dist/avatar/types.js +1 -0
- package/dist/breadcrumbs/README.md +65 -0
- package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte +62 -0
- package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte.d.ts +4 -0
- package/dist/breadcrumbs/index.d.ts +23 -0
- package/dist/breadcrumbs/index.js +10 -0
- package/dist/breadcrumbs/index.parts.d.ts +6 -0
- package/dist/breadcrumbs/index.parts.js +6 -0
- package/dist/breadcrumbs/item/breadcrumbs-item.svelte +42 -0
- package/dist/breadcrumbs/item/breadcrumbs-item.svelte.d.ts +4 -0
- package/dist/breadcrumbs/link/breadcrumbs-link.svelte +47 -0
- package/dist/breadcrumbs/link/breadcrumbs-link.svelte.d.ts +4 -0
- package/dist/breadcrumbs/list/breadcrumbs-list.svelte +31 -0
- package/dist/breadcrumbs/list/breadcrumbs-list.svelte.d.ts +4 -0
- package/dist/breadcrumbs/root/breadcrumbs-root.svelte +112 -0
- package/dist/breadcrumbs/root/breadcrumbs-root.svelte.d.ts +4 -0
- package/dist/breadcrumbs/root/context.d.ts +19 -0
- package/dist/breadcrumbs/root/context.js +15 -0
- package/dist/breadcrumbs/separator/breadcrumbs-separator.svelte +35 -0
- package/dist/breadcrumbs/separator/breadcrumbs-separator.svelte.d.ts +4 -0
- package/dist/breadcrumbs/types.d.ts +80 -0
- package/dist/breadcrumbs/types.js +1 -0
- package/dist/button/README.md +1 -1
- package/dist/button/root/button-root.svelte +37 -7
- package/dist/button/root/button-root.svelte.d.ts +19 -4
- package/dist/calendar/README.md +3 -3
- package/dist/calendar/body-cell/calendar-body-cell.svelte +7 -0
- package/dist/calendar/grid-header/calendar-grid-header.svelte +3 -4
- package/dist/calendar/grid-header/calendar-grid-header.svelte.d.ts +3 -4
- package/dist/calendar/root/calendar-root.svelte +8 -2
- package/dist/calendar/root/calendar-root.svelte.d.ts +8 -2
- package/dist/calendar/root/context.svelte.js +8 -2
- package/dist/calendar/trigger-next/README.md +1 -1
- package/dist/calendar/trigger-previous/README.md +1 -1
- package/dist/checkbox/README.md +1 -1
- package/dist/checkbox/indicator/README.md +1 -1
- package/dist/checkbox/indicator/checkbox-indicator.svelte +1 -0
- package/dist/checkbox/indicator/checkbox-indicator.svelte.d.ts +1 -0
- package/dist/checkbox/root/README.md +2 -2
- package/dist/checkbox/root/checkbox-root.svelte +133 -38
- package/dist/checkbox/root/checkbox-root.svelte.d.ts +21 -1
- package/dist/checkbox-group/README.md +95 -0
- package/dist/checkbox-group/index.d.ts +15 -0
- package/dist/checkbox-group/index.js +6 -0
- package/dist/checkbox-group/index.parts.d.ts +4 -0
- package/dist/checkbox-group/index.parts.js +7 -0
- package/dist/checkbox-group/label/checkbox-group-label.svelte +36 -0
- package/dist/checkbox-group/label/checkbox-group-label.svelte.d.ts +4 -0
- package/dist/checkbox-group/root/checkbox-group-root.svelte +118 -0
- package/dist/checkbox-group/root/checkbox-group-root.svelte.d.ts +4 -0
- package/dist/checkbox-group/root/context.svelte.d.ts +52 -0
- package/dist/checkbox-group/root/context.svelte.js +251 -0
- package/dist/checkbox-group/types.d.ts +57 -0
- package/dist/checkbox-group/types.js +1 -0
- package/dist/clock/README.md +3 -3
- package/dist/clock/axis/README.md +1 -1
- package/dist/clock/root/README.md +1 -1
- package/dist/clock/root/create-time-selection-state.svelte.d.ts +5 -0
- package/dist/clock/root/create-time-selection-state.svelte.js +113 -10
- package/dist/clock/root/wheel-options.d.ts +7 -3
- package/dist/clock/root/wheel-options.js +7 -15
- package/dist/clock/wheel-column/clock-wheel-column.svelte +10 -2
- package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +2 -1
- package/dist/collapsible/README.md +3 -3
- package/dist/collapsible/root/collapsible-root.svelte +9 -4
- package/dist/collapsible/types.d.ts +13 -1
- package/dist/combobox/README.md +2 -2
- package/dist/combobox/button/README.md +6 -6
- package/dist/combobox/input/README.md +1 -1
- package/dist/combobox/input/combobox-input.svelte +15 -4
- package/dist/combobox/input/combobox-input.svelte.d.ts +3 -3
- package/dist/combobox/item/combobox-listboxitem.svelte +4 -2
- package/dist/combobox/item/combobox-listboxitem.svelte.d.ts +4 -2
- package/dist/combobox/item-indicator/README.md +1 -1
- package/dist/combobox/item-indicator/combobox-item-indicator.svelte +2 -2
- package/dist/combobox/item-indicator/combobox-item-indicator.svelte.d.ts +2 -2
- package/dist/combobox/list/combobox-listbox.svelte +98 -3
- package/dist/combobox/list/combobox-listbox.svelte.d.ts +28 -3
- package/dist/combobox/popover/README.md +1 -1
- package/dist/combobox/popover/combobox-popover.svelte +4 -56
- package/dist/combobox/root/README.md +24 -24
- package/dist/combobox/root/combobox.svelte +138 -56
- package/dist/combobox/root/combobox.svelte.d.ts +31 -11
- package/dist/combobox/root/context.d.ts +12 -0
- package/dist/combobox/status/README.md +3 -3
- package/dist/combobox/status/combobox-status.svelte +1 -1
- package/dist/combobox/status/combobox-status.svelte.d.ts +1 -1
- package/dist/combobox/tag/README.md +1 -1
- package/dist/combobox/tag/combobox-tag.svelte +1 -1
- package/dist/combobox/tag/combobox-tag.svelte.d.ts +1 -1
- package/dist/combobox/tag-remove/README.md +1 -1
- package/dist/combobox/tag-remove/combobox-tag-remove.svelte +14 -3
- package/dist/combobox/tag-remove/combobox-tag-remove.svelte.d.ts +7 -1
- package/dist/combobox/tags/README.md +1 -1
- package/dist/combobox/tags/combobox-tags.svelte +15 -12
- package/dist/combobox/tags/combobox-tags.svelte.d.ts +12 -10
- package/dist/combobox/trigger/README.md +7 -7
- package/dist/combobox/trigger/combobox-trigger.svelte +4 -1
- package/dist/datepicker/README.md +5 -4
- package/dist/datepicker/input/date-picker-input.svelte +3 -4
- package/dist/datepicker/input/date-picker-input.svelte.d.ts +3 -4
- package/dist/datepicker/root/date-picker-root.svelte +38 -2
- package/dist/datepicker/root/date-picker-root.svelte.d.ts +2 -0
- package/dist/datepicker/root/draft-evaluation.d.ts +7 -0
- package/dist/datepicker/root/draft-evaluation.js +2 -2
- package/dist/datepicker/trigger/README.md +1 -1
- package/dist/daterangepicker/README.md +3 -3
- package/dist/daterangepicker/input/date-range-picker-input.svelte +3 -4
- package/dist/daterangepicker/input/date-range-picker-input.svelte.d.ts +3 -4
- package/dist/daterangepicker/root/date-range-picker-root.svelte +19 -1
- package/dist/daterangepicker/root/date-range-picker-root.svelte.d.ts +2 -0
- package/dist/dialog/README.md +10 -2
- package/dist/dialog/close/dialog-close.svelte +57 -0
- package/dist/dialog/close/dialog-close.svelte.d.ts +19 -0
- package/dist/dialog/content/dialog-content.svelte +6 -4
- package/dist/dialog/content/dialog-content.svelte.d.ts +4 -4
- package/dist/dialog/description/dialog-description.svelte +46 -0
- package/dist/dialog/description/dialog-description.svelte.d.ts +20 -0
- package/dist/dialog/index.d.ts +9 -0
- package/dist/dialog/index.js +3 -0
- package/dist/dialog/index.parts.d.ts +3 -0
- package/dist/dialog/index.parts.js +3 -0
- package/dist/dialog/overlay/dialog-overlay.svelte +1 -1
- package/dist/dialog/overlay/dialog-overlay.svelte.d.ts +1 -1
- package/dist/dialog/portal/dialog-portal.svelte +1 -1
- package/dist/dialog/portal/dialog-portal.svelte.d.ts +1 -1
- package/dist/dialog/root/README.md +1 -1
- package/dist/dialog/root/context.d.ts +8 -0
- package/dist/dialog/root/dialog-root.svelte +100 -20
- package/dist/dialog/root/dialog-root.svelte.d.ts +15 -6
- package/dist/dialog/root/dialog-stack.d.ts +6 -22
- package/dist/dialog/root/dialog-stack.js +4 -33
- package/dist/dialog/title/dialog-title.svelte +43 -0
- package/dist/dialog/title/dialog-title.svelte.d.ts +21 -0
- package/dist/dialog/trigger/README.md +1 -1
- package/dist/drawer/README.md +111 -0
- package/dist/drawer/body/drawer-body.svelte +47 -0
- package/dist/drawer/body/drawer-body.svelte.d.ts +32 -0
- package/dist/drawer/close/drawer-close.svelte +52 -0
- package/dist/drawer/close/drawer-close.svelte.d.ts +20 -0
- package/dist/drawer/content/drawer-content.svelte +600 -0
- package/dist/drawer/content/drawer-content.svelte.d.ts +31 -0
- package/dist/drawer/description/drawer-description.svelte +40 -0
- package/dist/drawer/description/drawer-description.svelte.d.ts +20 -0
- package/dist/drawer/indent/drawer-indent-background.svelte +36 -0
- package/dist/drawer/indent/drawer-indent-background.svelte.d.ts +17 -0
- package/dist/drawer/indent/drawer-indent.svelte +59 -0
- package/dist/drawer/indent/drawer-indent.svelte.d.ts +32 -0
- package/dist/drawer/index.d.ts +49 -0
- package/dist/drawer/index.js +25 -0
- package/dist/drawer/index.parts.d.ts +14 -0
- package/dist/drawer/index.parts.js +15 -0
- package/dist/drawer/overlay/drawer-overlay.svelte +67 -0
- package/dist/drawer/overlay/drawer-overlay.svelte.d.ts +12 -0
- package/dist/drawer/portal/drawer-portal.svelte +57 -0
- package/dist/drawer/portal/drawer-portal.svelte.d.ts +13 -0
- package/dist/drawer/root/context.d.ts +81 -0
- package/dist/drawer/root/context.js +20 -0
- package/dist/drawer/root/drawer-root.svelte +348 -0
- package/dist/drawer/root/drawer-root.svelte.d.ts +79 -0
- package/dist/drawer/root/drawer-stack.svelte.d.ts +73 -0
- package/dist/drawer/root/drawer-stack.svelte.js +113 -0
- package/dist/drawer/root/handle.svelte.d.ts +39 -0
- package/dist/drawer/root/handle.svelte.js +64 -0
- package/dist/drawer/root/keyboard-context.d.ts +13 -0
- package/dist/drawer/root/keyboard-context.js +8 -0
- package/dist/drawer/root/presence-context.d.ts +22 -0
- package/dist/drawer/root/presence-context.js +8 -0
- package/dist/drawer/root/snap-points.d.ts +68 -0
- package/dist/drawer/root/snap-points.js +120 -0
- package/dist/drawer/root/starting-style.svelte.d.ts +18 -0
- package/dist/drawer/root/starting-style.svelte.js +38 -0
- package/dist/drawer/root/types.d.ts +36 -0
- package/dist/drawer/root/types.js +1 -0
- package/dist/drawer/root/viewport-context.d.ts +2 -0
- package/dist/drawer/root/viewport-context.js +16 -0
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte +143 -0
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte.d.ts +22 -0
- package/dist/drawer/title/drawer-title.svelte +37 -0
- package/dist/drawer/title/drawer-title.svelte.d.ts +21 -0
- package/dist/drawer/trigger/drawer-trigger.svelte +90 -0
- package/dist/drawer/trigger/drawer-trigger.svelte.d.ts +41 -0
- package/dist/drawer/viewport/drawer-viewport.svelte +69 -0
- package/dist/drawer/viewport/drawer-viewport.svelte.d.ts +15 -0
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte +88 -0
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte.d.ts +29 -0
- package/dist/dropzone/README.md +4 -6
- package/dist/hooks/use-virtual-focus.svelte.d.ts +9 -0
- package/dist/hooks/use-virtual-focus.svelte.js +7 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.js +23 -0
- package/dist/input/input.svelte +6 -6
- package/dist/input/input.svelte.d.ts +6 -6
- package/dist/internal/environment.d.ts +11 -0
- package/dist/internal/environment.js +14 -0
- package/dist/internal/localized-strings.d.ts +152 -0
- package/dist/internal/localized-strings.js +152 -0
- package/dist/internal/number-precision.d.ts +9 -0
- package/dist/internal/number-precision.js +27 -0
- package/dist/listbox/README.md +20 -1
- package/dist/listbox/item/listbox-item.svelte +43 -18
- package/dist/listbox/item/listbox-item.svelte.d.ts +24 -15
- package/dist/listbox/root/README.md +1 -1
- package/dist/listbox/root/context.d.ts +56 -1
- package/dist/listbox/root/context.js +118 -1
- package/dist/listbox/root/listbox.svelte +400 -27
- package/dist/listbox/root/listbox.svelte.d.ts +73 -16
- package/dist/locale-provider/README.md +1 -6
- package/dist/menu/README.md +41 -4
- package/dist/menu/content/menu-content.svelte +31 -14
- package/dist/menu/content/menu-content.svelte.d.ts +14 -9
- package/dist/menu/context-trigger/menu-context-trigger.svelte +194 -0
- package/dist/menu/context-trigger/menu-context-trigger.svelte.d.ts +35 -0
- package/dist/menu/group/menu-group-label.svelte +1 -1
- package/dist/menu/group/menu-group-label.svelte.d.ts +1 -1
- package/dist/menu/index.d.ts +4 -1
- package/dist/menu/index.js +1 -0
- package/dist/menu/index.parts.d.ts +1 -0
- package/dist/menu/index.parts.js +1 -0
- package/dist/menu/item/menu-item.svelte +11 -8
- package/dist/menu/item/menu-item.svelte.d.ts +11 -8
- package/dist/menu/overlay/menu-overlay.svelte +2 -2
- package/dist/menu/overlay/menu-overlay.svelte.d.ts +1 -1
- package/dist/menu/root/context.d.ts +24 -3
- package/dist/menu/root/focus-state.d.ts +2 -2
- package/dist/menu/root/focus-state.js +8 -32
- package/dist/menu/root/menu-root.svelte +14 -8
- package/dist/menu/root/menu-root.svelte.d.ts +14 -8
- package/dist/menu/root/menu-state.svelte.d.ts +1 -1
- package/dist/menu/root/menu-state.svelte.js +24 -1
- package/dist/menu/separator/menu-separator.svelte +1 -1
- package/dist/menu/separator/menu-separator.svelte.d.ts +1 -1
- package/dist/menu/submenu/menu-submenu-root.svelte +10 -7
- package/dist/menu/submenu/menu-submenu-root.svelte.d.ts +10 -7
- package/dist/numberfield/root/README.md +1 -1
- package/dist/numberfield/root/number-field-root.svelte +2 -1
- package/dist/numberfield/root/number-utils.js +1 -20
- package/dist/numberfield/scrub-area-cursor/README.md +1 -1
- package/dist/popover/README.md +1 -1
- package/dist/popover/content/popover-content.svelte +22 -16
- package/dist/popover/content/popover-content.svelte.d.ts +19 -14
- package/dist/popover/overlay/popover-overlay.svelte +2 -2
- package/dist/popover/overlay/popover-overlay.svelte.d.ts +1 -1
- package/dist/popover/root/README.md +1 -1
- package/dist/popover/root/focus-state.d.ts +2 -2
- package/dist/popover/root/focus-state.js +7 -34
- package/dist/popover/root/popover-root.svelte +29 -14
- package/dist/popover/root/popover-root.svelte.d.ts +16 -5
- package/dist/popover/trigger/README.md +1 -1
- package/dist/primitives/aria-hide-outside.d.ts +13 -0
- package/dist/primitives/aria-hide-outside.js +7 -1
- package/dist/primitives/contain-wheel.d.ts +9 -0
- package/dist/primitives/contain-wheel.js +41 -0
- package/dist/primitives/floating.d.ts +49 -8
- package/dist/primitives/floating.js +75 -7
- package/dist/primitives/focus-trap.d.ts +2 -0
- package/dist/primitives/focus-trap.js +7 -1
- package/dist/primitives/focus-visible.svelte.d.ts +14 -0
- package/dist/primitives/focus-visible.svelte.js +19 -0
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.js +3 -0
- package/dist/primitives/input-modality.d.ts +7 -0
- package/dist/primitives/input-modality.js +32 -5
- package/dist/primitives/keyboard-navigation.d.ts +29 -5
- package/dist/primitives/keyboard-navigation.js +27 -17
- package/dist/primitives/layer-stack.d.ts +29 -0
- package/dist/primitives/layer-stack.js +35 -0
- package/dist/primitives/list-virtualizer.d.ts +75 -0
- package/dist/primitives/list-virtualizer.js +59 -0
- package/dist/primitives/long-press.d.ts +59 -0
- package/dist/primitives/long-press.js +142 -0
- package/dist/primitives/presence.svelte.js +6 -1
- package/dist/primitives/scroll-lock.d.ts +47 -3
- package/dist/primitives/scroll-lock.js +191 -9
- package/dist/primitives/swipe-gesture.d.ts +126 -0
- package/dist/primitives/swipe-gesture.js +351 -0
- package/dist/primitives/text.d.ts +8 -0
- package/dist/primitives/text.js +13 -0
- package/dist/primitives/trigger-focus-state.d.ts +29 -0
- package/dist/primitives/trigger-focus-state.js +57 -0
- package/dist/progress/README.md +54 -0
- package/dist/progress/index.d.ts +21 -0
- package/dist/progress/index.js +9 -0
- package/dist/progress/index.parts.d.ts +5 -0
- package/dist/progress/index.parts.js +5 -0
- package/dist/progress/indicator/progress-indicator.svelte +37 -0
- package/dist/progress/indicator/progress-indicator.svelte.d.ts +4 -0
- package/dist/progress/label/progress-label.svelte +34 -0
- package/dist/progress/label/progress-label.svelte.d.ts +4 -0
- package/dist/progress/root/context.d.ts +26 -0
- package/dist/progress/root/context.js +15 -0
- package/dist/progress/root/progress-root.svelte +136 -0
- package/dist/progress/root/progress-root.svelte.d.ts +4 -0
- package/dist/progress/root/progress-utils.d.ts +12 -0
- package/dist/progress/root/progress-utils.js +41 -0
- package/dist/progress/track/progress-track.svelte +27 -0
- package/dist/progress/track/progress-track.svelte.d.ts +4 -0
- package/dist/progress/types.d.ts +81 -0
- package/dist/progress/types.js +1 -0
- package/dist/progress/value/progress-value.svelte +36 -0
- package/dist/progress/value/progress-value.svelte.d.ts +4 -0
- package/dist/radio-group/README.md +103 -0
- package/dist/radio-group/index.d.ts +18 -0
- package/dist/radio-group/index.js +9 -0
- package/dist/radio-group/index.parts.d.ts +4 -0
- package/dist/radio-group/index.parts.js +4 -0
- package/dist/radio-group/indicator/radio-group-indicator.svelte +43 -0
- package/dist/radio-group/indicator/radio-group-indicator.svelte.d.ts +12 -0
- package/dist/radio-group/item/context.d.ts +18 -0
- package/dist/radio-group/item/context.js +15 -0
- package/dist/radio-group/item/radio-group-item.svelte +377 -0
- package/dist/radio-group/item/radio-group-item.svelte.d.ts +35 -0
- package/dist/radio-group/label/radio-group-label.svelte +37 -0
- package/dist/radio-group/label/radio-group-label.svelte.d.ts +4 -0
- package/dist/radio-group/root/context.svelte.d.ts +57 -0
- package/dist/radio-group/root/context.svelte.js +284 -0
- package/dist/radio-group/root/radio-group-root.svelte +193 -0
- package/dist/radio-group/root/radio-group-root.svelte.d.ts +4 -0
- package/dist/radio-group/types.d.ts +50 -0
- package/dist/radio-group/types.js +1 -0
- package/dist/select/README.md +129 -0
- package/dist/select/index.d.ts +30 -0
- package/dist/select/index.js +16 -0
- package/dist/select/index.parts.d.ts +8 -0
- package/dist/select/index.parts.js +9 -0
- package/dist/select/item/select-item.svelte +68 -0
- package/dist/select/item/select-item.svelte.d.ts +10 -0
- package/dist/select/item-indicator/select-item-indicator.svelte +55 -0
- package/dist/select/item-indicator/select-item-indicator.svelte.d.ts +4 -0
- package/dist/select/label/select-label.svelte +46 -0
- package/dist/select/label/select-label.svelte.d.ts +4 -0
- package/dist/select/list/select-list.svelte +241 -0
- package/dist/select/list/select-list.svelte.d.ts +62 -0
- package/dist/select/popover/select-popover.svelte +80 -0
- package/dist/select/popover/select-popover.svelte.d.ts +9 -0
- package/dist/select/root/context.d.ts +106 -0
- package/dist/select/root/context.js +22 -0
- package/dist/select/root/select-root.svelte +544 -0
- package/dist/select/root/select-root.svelte.d.ts +25 -0
- package/dist/select/trigger/select-trigger.svelte +192 -0
- package/dist/select/trigger/select-trigger.svelte.d.ts +4 -0
- package/dist/select/types.d.ts +133 -0
- package/dist/select/types.js +1 -0
- package/dist/select/value/select-value.svelte +61 -0
- package/dist/select/value/select-value.svelte.d.ts +4 -0
- package/dist/separator/README.md +35 -0
- package/dist/separator/index.d.ts +7 -0
- package/dist/separator/index.js +3 -0
- package/dist/separator/separator.svelte +254 -0
- package/dist/separator/separator.svelte.d.ts +45 -0
- package/dist/separator/types.d.ts +1 -0
- package/dist/separator/types.js +1 -0
- package/dist/slider/README.md +61 -0
- package/dist/slider/fill/slider-fill.svelte +40 -0
- package/dist/slider/fill/slider-fill.svelte.d.ts +4 -0
- package/dist/slider/index.d.ts +9 -0
- package/dist/slider/index.js +8 -0
- package/dist/slider/index.parts.d.ts +6 -0
- package/dist/slider/index.parts.js +6 -0
- package/dist/slider/label/slider-label.svelte +44 -0
- package/dist/slider/label/slider-label.svelte.d.ts +4 -0
- package/dist/slider/output/slider-output.svelte +46 -0
- package/dist/slider/output/slider-output.svelte.d.ts +4 -0
- package/dist/slider/root/context.d.ts +106 -0
- package/dist/slider/root/context.js +15 -0
- package/dist/slider/root/slider-root.svelte +545 -0
- package/dist/slider/root/slider-root.svelte.d.ts +4 -0
- package/dist/slider/root/slider-utils.d.ts +57 -0
- package/dist/slider/root/slider-utils.js +88 -0
- package/dist/slider/thumb/slider-thumb.svelte +276 -0
- package/dist/slider/thumb/slider-thumb.svelte.d.ts +4 -0
- package/dist/slider/track/slider-track.svelte +60 -0
- package/dist/slider/track/slider-track.svelte.d.ts +4 -0
- package/dist/slider/types.d.ts +144 -0
- package/dist/slider/types.js +1 -0
- package/dist/switch/root/README.md +2 -2
- package/dist/switch/root/switch-root.svelte +49 -21
- package/dist/switch/root/switch-root.svelte.d.ts +26 -14
- package/dist/switch/thumb/switch-thumb.svelte +1 -1
- package/dist/switch/thumb/switch-thumb.svelte.d.ts +1 -1
- package/dist/table/README.md +16 -9
- package/dist/table/body/table-body.svelte +84 -9
- package/dist/table/cell/table-cell.svelte +27 -10
- package/dist/table/checkbox/table-checkbox.svelte +3 -0
- package/dist/table/checkbox-indicator/README.md +1 -1
- package/dist/table/column/table-column.svelte +5 -1
- package/dist/table/column-header-cell/table-column-header-cell.svelte +24 -0
- package/dist/table/column-resizer/README.md +2 -2
- package/dist/table/column-resizer/table-column-resizer.svelte +1 -5
- package/dist/table/index.d.ts +1 -1
- package/dist/table/index.js +1 -1
- package/dist/table/interactive-cell/table-interactive-cell.svelte +26 -10
- package/dist/table/root/README.md +1 -1
- package/dist/table/root/context.svelte.d.ts +17 -0
- package/dist/table/root/context.svelte.js +212 -66
- package/dist/table/root/table-root.svelte +36 -6
- package/dist/table/row/table-row.svelte +14 -14
- package/dist/table/sort-trigger/README.md +1 -1
- package/dist/table/sort-trigger/table-sort-trigger.svelte +5 -1
- package/dist/table/types.d.ts +32 -14
- package/dist/tabs/root/tabs-root.svelte +20 -6
- package/dist/tabs/types.d.ts +9 -0
- package/dist/timepicker/README.md +3 -2
- package/dist/timepicker/input/README.md +1 -1
- package/dist/timepicker/input/time-picker-input.svelte +66 -5
- package/dist/timepicker/input/time-picker-input.svelte.d.ts +18 -1
- package/dist/timepicker/root/README.md +1 -1
- package/dist/timepicker/root/time-picker-root.svelte +11 -0
- package/dist/timepicker/root/time-picker-root.svelte.d.ts +2 -0
- package/dist/timepicker/trigger/README.md +1 -1
- package/dist/toast/README.md +75 -0
- package/dist/toast/action/toast-action.svelte +42 -0
- package/dist/toast/action/toast-action.svelte.d.ts +4 -0
- package/dist/toast/close/toast-close.svelte +41 -0
- package/dist/toast/close/toast-close.svelte.d.ts +4 -0
- package/dist/toast/content/toast-content.svelte +24 -0
- package/dist/toast/content/toast-content.svelte.d.ts +4 -0
- package/dist/toast/description/toast-description.svelte +41 -0
- package/dist/toast/description/toast-description.svelte.d.ts +4 -0
- package/dist/toast/index.d.ts +34 -0
- package/dist/toast/index.js +15 -0
- package/dist/toast/index.parts.d.ts +9 -0
- package/dist/toast/index.parts.js +9 -0
- package/dist/toast/positioner/toast-positioner.svelte +75 -0
- package/dist/toast/positioner/toast-positioner.svelte.d.ts +4 -0
- package/dist/toast/provider/context.d.ts +36 -0
- package/dist/toast/provider/context.js +22 -0
- package/dist/toast/provider/toast-manager.svelte.d.ts +113 -0
- package/dist/toast/provider/toast-manager.svelte.js +210 -0
- package/dist/toast/provider/toast-provider.svelte +98 -0
- package/dist/toast/provider/toast-provider.svelte.d.ts +4 -0
- package/dist/toast/root/context.d.ts +18 -0
- package/dist/toast/root/context.js +15 -0
- package/dist/toast/root/toast-root.svelte +296 -0
- package/dist/toast/root/toast-root.svelte.d.ts +4 -0
- package/dist/toast/title/toast-title.svelte +38 -0
- package/dist/toast/title/toast-title.svelte.d.ts +4 -0
- package/dist/toast/types.d.ts +100 -0
- package/dist/toast/types.js +1 -0
- package/dist/toast/viewport/toast-viewport.svelte +389 -0
- package/dist/toast/viewport/toast-viewport.svelte.d.ts +4 -0
- package/dist/toggle/README.md +1 -1
- package/dist/toggle/root/toggle-root.svelte +28 -0
- package/dist/toggle/root/toggle-root.svelte.d.ts +19 -0
- package/dist/toggle-group/README.md +12 -4
- package/dist/toggle-group/index.d.ts +2 -0
- package/dist/toggle-group/index.parts.d.ts +1 -0
- package/dist/toggle-group/index.parts.js +4 -0
- package/dist/toggle-group/root/context.svelte.d.ts +1 -1
- package/dist/toggle-group/root/context.svelte.js +24 -8
- package/dist/toggle-group/root/toggle-group-root.svelte +24 -4
- package/dist/toggle-group/root/toggle-group-teardown-order-child.svelte +13 -0
- package/dist/toggle-group/root/toggle-group-teardown-order-child.svelte.d.ts +7 -0
- package/dist/toggle-group/types.d.ts +9 -0
- package/dist/tooltip/README.md +53 -0
- package/dist/tooltip/arrow/tooltip-arrow.svelte +36 -0
- package/dist/tooltip/arrow/tooltip-arrow.svelte.d.ts +4 -0
- package/dist/tooltip/content/tooltip-content.svelte +148 -0
- package/dist/tooltip/content/tooltip-content.svelte.d.ts +4 -0
- package/dist/tooltip/index.d.ts +8 -0
- package/dist/tooltip/index.js +7 -0
- package/dist/tooltip/index.parts.d.ts +5 -0
- package/dist/tooltip/index.parts.js +5 -0
- package/dist/tooltip/provider/tooltip-provider.svelte +36 -0
- package/dist/tooltip/provider/tooltip-provider.svelte.d.ts +4 -0
- package/dist/tooltip/root/context.d.ts +46 -0
- package/dist/tooltip/root/context.js +22 -0
- package/dist/tooltip/root/safe-polygon.d.ts +26 -0
- package/dist/tooltip/root/safe-polygon.js +66 -0
- package/dist/tooltip/root/tooltip-group.d.ts +26 -0
- package/dist/tooltip/root/tooltip-group.js +41 -0
- package/dist/tooltip/root/tooltip-root.svelte +461 -0
- package/dist/tooltip/root/tooltip-root.svelte.d.ts +4 -0
- package/dist/tooltip/trigger/tooltip-trigger.svelte +52 -0
- package/dist/tooltip/trigger/tooltip-trigger.svelte.d.ts +4 -0
- package/dist/tooltip/types.d.ts +105 -0
- package/dist/tooltip/types.js +1 -0
- package/dist/transfer-list/README.md +110 -0
- package/dist/transfer-list/index.d.ts +33 -0
- package/dist/transfer-list/index.js +18 -0
- package/dist/transfer-list/index.parts.d.ts +9 -0
- package/dist/transfer-list/index.parts.js +10 -0
- package/dist/transfer-list/item/transfer-list-item.svelte +74 -0
- package/dist/transfer-list/item/transfer-list-item.svelte.d.ts +35 -0
- package/dist/transfer-list/list/transfer-list-list.svelte +162 -0
- package/dist/transfer-list/list/transfer-list-list.svelte.d.ts +56 -0
- package/dist/transfer-list/list/transfer-list-source.svelte +13 -0
- package/dist/transfer-list/list/transfer-list-source.svelte.d.ts +36 -0
- package/dist/transfer-list/list/transfer-list-target.svelte +14 -0
- package/dist/transfer-list/list/transfer-list-target.svelte.d.ts +36 -0
- package/dist/transfer-list/move/transfer-list-move-all.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-all.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-move-button.svelte +103 -0
- package/dist/transfer-list/move/transfer-list-move-button.svelte.d.ts +25 -0
- package/dist/transfer-list/move/transfer-list-move-down.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-down.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-move-selected.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-selected.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-move-up.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-up.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-reorder-button.svelte +83 -0
- package/dist/transfer-list/move/transfer-list-reorder-button.svelte.d.ts +21 -0
- package/dist/transfer-list/root/context.d.ts +70 -0
- package/dist/transfer-list/root/context.js +24 -0
- package/dist/transfer-list/root/transfer-list-root.svelte +345 -0
- package/dist/transfer-list/root/transfer-list-root.svelte.d.ts +68 -0
- package/dist/transfer-list/root/types.d.ts +22 -0
- package/dist/transfer-list/root/types.js +4 -0
- package/dist/transfer-list/status/transfer-list-status.svelte +70 -0
- package/dist/transfer-list/status/transfer-list-status.svelte.d.ts +15 -0
- package/dist/tree/README.md +3 -3
- package/dist/tree/checkbox-indicator/README.md +1 -1
- package/dist/tree/root/README.md +1 -1
- package/dist/tree/root/context.svelte.js +6 -0
- package/dist/tree/root/tree-root.svelte +22 -8
- package/dist/tree/types.d.ts +23 -1
- package/package.json +282 -224
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { untrack, type Snippet } from 'svelte';
|
|
2
|
+
import { onDestroy, untrack, type Snippet } from 'svelte';
|
|
3
3
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
4
|
import {
|
|
5
5
|
shouldShowFocusVisible,
|
|
6
6
|
trackInteractionModality
|
|
7
7
|
} from '../../primitives/input-modality';
|
|
8
|
+
import { watchFocusVisible } from '../../primitives/focus-visible.svelte';
|
|
9
|
+
import { getCheckboxGroupContext } from '../../checkbox-group/root/context.svelte';
|
|
8
10
|
import { setCheckboxContext, type CheckboxContext, type CheckboxState } from './context';
|
|
9
11
|
|
|
10
12
|
type CheckboxRootProps = Omit<
|
|
@@ -25,21 +27,41 @@
|
|
|
25
27
|
element?: HTMLSpanElement | null;
|
|
26
28
|
name?: string;
|
|
27
29
|
value?: string;
|
|
28
|
-
/**
|
|
30
|
+
/** The id of the form of the hidden input. */
|
|
29
31
|
form?: string;
|
|
32
|
+
/** The checked state. By default it goes in the two directions: use `bind:checked`. */
|
|
30
33
|
checked?: boolean;
|
|
34
|
+
/** The checked state at the start, for when you give no `checked`. */
|
|
31
35
|
defaultChecked?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Give your own code full control of `checked`. The component stops to write back to the prop,
|
|
38
|
+
* and it reports only through `onCheckedChange`. Thus the parent can refuse a change: the parent
|
|
39
|
+
* does not send the new value down. The default is off, because `bind:checked` is the usual case
|
|
40
|
+
* and it needs the write-back.
|
|
41
|
+
*/
|
|
42
|
+
controlledChecked?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The indeterminate state. By default it goes in the two directions: use `bind:indeterminate`.
|
|
45
|
+
*/
|
|
32
46
|
indeterminate?: boolean;
|
|
47
|
+
/** The indeterminate state at the start, for when you give no `indeterminate`. */
|
|
33
48
|
defaultIndeterminate?: boolean;
|
|
49
|
+
/** Give your own code full control of `indeterminate`. Read `controlledChecked`. */
|
|
50
|
+
controlledIndeterminate?: boolean;
|
|
51
|
+
/** The component calls it when the user changes the checked state. */
|
|
34
52
|
onCheckedChange?: (checked: boolean) => void;
|
|
53
|
+
/** The component calls it when the user changes the indeterminate state. From the indeterminate state, the first user action makes the checkbox checked. */
|
|
35
54
|
onIndeterminateChange?: (indeterminate: boolean) => void;
|
|
36
55
|
disabled?: boolean;
|
|
37
56
|
readonly?: boolean;
|
|
38
57
|
required?: boolean;
|
|
39
58
|
children?: Snippet;
|
|
40
59
|
class?: string;
|
|
60
|
+
/** The accessible name, for when the user sees no name. */
|
|
41
61
|
'aria-label'?: string;
|
|
62
|
+
/** The id of the element that gives the checkbox its name. */
|
|
42
63
|
'aria-labelledby'?: string;
|
|
64
|
+
/** Replaces the default position in the tab order. */
|
|
43
65
|
tabindex?: number;
|
|
44
66
|
onclick?: HTMLAttributes<HTMLSpanElement>['onclick'];
|
|
45
67
|
onkeydown?: HTMLAttributes<HTMLSpanElement>['onkeydown'];
|
|
@@ -88,8 +110,10 @@
|
|
|
88
110
|
form,
|
|
89
111
|
checked = $bindable(),
|
|
90
112
|
defaultChecked = false,
|
|
113
|
+
controlledChecked = false,
|
|
91
114
|
indeterminate = $bindable(),
|
|
92
115
|
defaultIndeterminate = false,
|
|
116
|
+
controlledIndeterminate = false,
|
|
93
117
|
onCheckedChange,
|
|
94
118
|
onIndeterminateChange,
|
|
95
119
|
disabled = false,
|
|
@@ -121,6 +145,13 @@
|
|
|
121
145
|
const inputId = instanceId;
|
|
122
146
|
const rootId = `${instanceId}-root`;
|
|
123
147
|
|
|
148
|
+
// Inside a `CheckboxGroup.Root` the group owns the checked state, and this checkbox becomes
|
|
149
|
+
// one entry of its `value` array. Outside one the context is undefined and every path below
|
|
150
|
+
// keeps the standalone behavior.
|
|
151
|
+
const checkboxGroup = getCheckboxGroupContext();
|
|
152
|
+
const registrationOwner = Symbol('checkbox-root');
|
|
153
|
+
let registeredValue = untrack(() => value);
|
|
154
|
+
|
|
124
155
|
const initialChecked = untrack(() => checked ?? defaultChecked);
|
|
125
156
|
const initialIndeterminate = untrack(() => indeterminate ?? defaultIndeterminate);
|
|
126
157
|
const initialState = resolveState(initialChecked, initialIndeterminate);
|
|
@@ -134,6 +165,35 @@
|
|
|
134
165
|
let rootRef: HTMLSpanElement | null = $state(null);
|
|
135
166
|
let inputRef: HTMLInputElement | null = $state(null);
|
|
136
167
|
|
|
168
|
+
// Registered while the script runs, before the element exists, so the group knows the
|
|
169
|
+
// checkbox at its first render. The effect below repeats it with the element attached,
|
|
170
|
+
// which is what gives the group its DOM order.
|
|
171
|
+
untrack(() => {
|
|
172
|
+
checkboxGroup?.registerCheckbox(registeredValue, {
|
|
173
|
+
isDisabled: disabled,
|
|
174
|
+
owner: registrationOwner
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
$effect(() => {
|
|
179
|
+
if (!checkboxGroup) return;
|
|
180
|
+
|
|
181
|
+
if (registeredValue !== value) {
|
|
182
|
+
checkboxGroup.unregisterCheckbox(registeredValue);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
registeredValue = value;
|
|
186
|
+
checkboxGroup.registerCheckbox(value, {
|
|
187
|
+
isDisabled: disabled,
|
|
188
|
+
element: rootRef,
|
|
189
|
+
owner: registrationOwner
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
onDestroy(() => {
|
|
194
|
+
checkboxGroup?.unregisterCheckbox(registeredValue);
|
|
195
|
+
});
|
|
196
|
+
|
|
137
197
|
$effect(() => {
|
|
138
198
|
element = rootRef;
|
|
139
199
|
return () => {
|
|
@@ -141,31 +201,51 @@
|
|
|
141
201
|
};
|
|
142
202
|
});
|
|
143
203
|
|
|
204
|
+
// A grouped checkbox adds the disabled and read-only state of the group to its own.
|
|
205
|
+
// `required` is NOT among them: native `required` on a checkbox demands THAT box, so
|
|
206
|
+
// spreading it would turn "at least one" into "every one". The group carries that
|
|
207
|
+
// meaning itself, with `aria-required` on its own element.
|
|
208
|
+
const renderedDisabled = $derived(
|
|
209
|
+
checkboxGroup ? checkboxGroup.isCheckboxDisabled(value) : disabled
|
|
210
|
+
);
|
|
211
|
+
const renderedReadOnly = $derived(readonly || Boolean(checkboxGroup?.isReadOnly));
|
|
212
|
+
const renderedRequired = $derived(required);
|
|
213
|
+
const renderedName = $derived(name ?? checkboxGroup?.name);
|
|
214
|
+
|
|
144
215
|
$effect(() => {
|
|
145
|
-
if (!
|
|
216
|
+
if (!renderedDisabled && !renderedReadOnly) return;
|
|
146
217
|
clearPressState();
|
|
147
|
-
if (
|
|
218
|
+
if (renderedDisabled) {
|
|
148
219
|
focusVisible = false;
|
|
149
220
|
}
|
|
150
221
|
});
|
|
151
222
|
|
|
152
|
-
// Controlled-ness is
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
//
|
|
157
|
-
|
|
223
|
+
// Controlled-ness is NOT inferred from the props being defined: `bind:checked={value}`
|
|
224
|
+
// and `checked={value}` are indistinguishable at runtime, so inferring it silently
|
|
225
|
+
// broke every `bind:checked` seeded with `false`. It is opt-in per prop instead.
|
|
226
|
+
// Write the initial state back so `bind:` parents see the resolved default. Read
|
|
227
|
+
// untracked: this is a deliberate one-time seed at init, not a reactive mirror.
|
|
228
|
+
// Skipped when grouped: there the group holds the checked state, and seeding the prop would
|
|
229
|
+
// report a value the group never agreed to.
|
|
230
|
+
if (!checkboxGroup && !untrack(() => controlledChecked)) {
|
|
158
231
|
checked = initialState === 'checked';
|
|
159
232
|
}
|
|
160
233
|
|
|
161
|
-
if (!
|
|
234
|
+
if (!untrack(() => controlledIndeterminate)) {
|
|
162
235
|
indeterminate = initialState === 'indeterminate';
|
|
163
236
|
}
|
|
164
237
|
|
|
238
|
+
// The prop wins whenever it is supplied — that covers both `bind:` and a plain
|
|
239
|
+
// value — and the internal state only carries the fully uncontrolled case. A group
|
|
240
|
+
// outranks all of it.
|
|
165
241
|
const currentState = $derived.by(() =>
|
|
166
242
|
resolveState(
|
|
167
|
-
|
|
168
|
-
|
|
243
|
+
checkboxGroup
|
|
244
|
+
? checkboxGroup.isSelected(value)
|
|
245
|
+
: controlledChecked
|
|
246
|
+
? Boolean(checked)
|
|
247
|
+
: (checked ?? checkedInternal),
|
|
248
|
+
controlledIndeterminate ? Boolean(indeterminate) : (indeterminate ?? indeterminateInternal)
|
|
169
249
|
)
|
|
170
250
|
);
|
|
171
251
|
|
|
@@ -173,6 +253,14 @@
|
|
|
173
253
|
const currentIndeterminate = $derived(currentState === 'indeterminate');
|
|
174
254
|
const currentUnchecked = $derived(currentState === 'unchecked');
|
|
175
255
|
|
|
256
|
+
// The focus ring must appear when a pointer press is followed by a key press, and the modality
|
|
257
|
+
// alone changes there — no focus event fires to re-read it.
|
|
258
|
+
watchFocusVisible({
|
|
259
|
+
isFocused: () => focused,
|
|
260
|
+
element: () => rootRef,
|
|
261
|
+
set: (visible) => (focusVisible = visible)
|
|
262
|
+
});
|
|
263
|
+
|
|
176
264
|
function clearPressState() {
|
|
177
265
|
pressed = false;
|
|
178
266
|
pressedKey = null;
|
|
@@ -183,18 +271,25 @@
|
|
|
183
271
|
const nextIndeterminate = nextState === 'indeterminate';
|
|
184
272
|
const previousChecked = currentChecked;
|
|
185
273
|
const previousIndeterminate = currentIndeterminate;
|
|
186
|
-
|
|
187
|
-
|
|
274
|
+
let didChangeChecked = nextChecked !== previousChecked;
|
|
275
|
+
|
|
276
|
+
if (checkboxGroup) {
|
|
277
|
+
// The group owns the checked state, so the standalone `checked` prop is not written
|
|
278
|
+
// back. The group reports the whole selection through its own `value` and `onChange`,
|
|
279
|
+
// and it answers whether it took the change — a group that refuses one must not make
|
|
280
|
+
// this checkbox announce it.
|
|
281
|
+
didChangeChecked = checkboxGroup.setValueSelected(value, nextChecked) !== null;
|
|
282
|
+
} else if (!controlledChecked) {
|
|
188
283
|
checkedInternal = nextChecked;
|
|
189
284
|
checked = nextChecked;
|
|
190
285
|
}
|
|
191
286
|
|
|
192
|
-
if (!
|
|
287
|
+
if (!controlledIndeterminate) {
|
|
193
288
|
indeterminateInternal = nextIndeterminate;
|
|
194
289
|
indeterminate = nextIndeterminate;
|
|
195
290
|
}
|
|
196
291
|
|
|
197
|
-
if (
|
|
292
|
+
if (didChangeChecked) {
|
|
198
293
|
onCheckedChange?.(nextChecked);
|
|
199
294
|
}
|
|
200
295
|
|
|
@@ -208,7 +303,7 @@
|
|
|
208
303
|
}
|
|
209
304
|
|
|
210
305
|
function setState(nextState: CheckboxState, event?: Event) {
|
|
211
|
-
if (
|
|
306
|
+
if (renderedDisabled || renderedReadOnly) return;
|
|
212
307
|
publishState(nextState, event);
|
|
213
308
|
}
|
|
214
309
|
|
|
@@ -217,7 +312,7 @@
|
|
|
217
312
|
}
|
|
218
313
|
|
|
219
314
|
function requestNativeToggle(event?: Event) {
|
|
220
|
-
if (
|
|
315
|
+
if (renderedDisabled || renderedReadOnly) return;
|
|
221
316
|
if (!inputRef) {
|
|
222
317
|
toggle(event);
|
|
223
318
|
return;
|
|
@@ -230,7 +325,7 @@
|
|
|
230
325
|
trackInteractionModality(event, rootRef);
|
|
231
326
|
|
|
232
327
|
if (event.defaultPrevented) return;
|
|
233
|
-
if (
|
|
328
|
+
if (renderedDisabled || renderedReadOnly) {
|
|
234
329
|
event.preventDefault();
|
|
235
330
|
return;
|
|
236
331
|
}
|
|
@@ -288,7 +383,7 @@
|
|
|
288
383
|
trackInteractionModality(event, rootRef);
|
|
289
384
|
focusVisible = false;
|
|
290
385
|
|
|
291
|
-
if (
|
|
386
|
+
if (renderedDisabled || renderedReadOnly) {
|
|
292
387
|
event.preventDefault();
|
|
293
388
|
clearPressState();
|
|
294
389
|
return;
|
|
@@ -311,7 +406,7 @@
|
|
|
311
406
|
}
|
|
312
407
|
|
|
313
408
|
function handlePointerEnter(event: PointerEvent) {
|
|
314
|
-
if (
|
|
409
|
+
if (renderedDisabled || renderedReadOnly) return;
|
|
315
410
|
|
|
316
411
|
if ((event.buttons & 1) === 1 && pressedKey === null) {
|
|
317
412
|
pressed = true;
|
|
@@ -328,7 +423,7 @@
|
|
|
328
423
|
trackInteractionModality(event, rootRef);
|
|
329
424
|
focusVisible = false;
|
|
330
425
|
|
|
331
|
-
if (
|
|
426
|
+
if (renderedDisabled || renderedReadOnly) {
|
|
332
427
|
event.preventDefault();
|
|
333
428
|
clearPressState();
|
|
334
429
|
return;
|
|
@@ -367,7 +462,7 @@
|
|
|
367
462
|
const target = event.currentTarget;
|
|
368
463
|
if (!(target instanceof HTMLInputElement)) return;
|
|
369
464
|
|
|
370
|
-
if (
|
|
465
|
+
if (renderedDisabled || renderedReadOnly) {
|
|
371
466
|
target.checked = currentChecked;
|
|
372
467
|
target.indeterminate = currentIndeterminate;
|
|
373
468
|
return;
|
|
@@ -440,13 +535,13 @@
|
|
|
440
535
|
return currentIndeterminate;
|
|
441
536
|
},
|
|
442
537
|
get isDisabled() {
|
|
443
|
-
return
|
|
538
|
+
return renderedDisabled;
|
|
444
539
|
},
|
|
445
540
|
get isReadOnly() {
|
|
446
|
-
return
|
|
541
|
+
return renderedReadOnly;
|
|
447
542
|
},
|
|
448
543
|
get required() {
|
|
449
|
-
return
|
|
544
|
+
return renderedRequired;
|
|
450
545
|
},
|
|
451
546
|
get focused() {
|
|
452
547
|
return focused;
|
|
@@ -464,11 +559,11 @@
|
|
|
464
559
|
bind:this={rootRef}
|
|
465
560
|
id={rootId}
|
|
466
561
|
role="checkbox"
|
|
467
|
-
tabindex={
|
|
562
|
+
tabindex={renderedDisabled ? undefined : (tabindex ?? 0)}
|
|
468
563
|
aria-checked={currentIndeterminate ? 'mixed' : currentChecked ? 'true' : 'false'}
|
|
469
|
-
aria-disabled={
|
|
470
|
-
aria-readonly={
|
|
471
|
-
aria-required={
|
|
564
|
+
aria-disabled={renderedDisabled || undefined}
|
|
565
|
+
aria-readonly={renderedReadOnly || undefined}
|
|
566
|
+
aria-required={renderedRequired || undefined}
|
|
472
567
|
aria-label={ariaLabel}
|
|
473
568
|
aria-labelledby={ariaLabelledby}
|
|
474
569
|
data-checkbox-root="true"
|
|
@@ -476,9 +571,9 @@
|
|
|
476
571
|
data-unchecked={currentUnchecked || undefined}
|
|
477
572
|
data-indeterminate={currentIndeterminate || undefined}
|
|
478
573
|
data-pressed={pressed || undefined}
|
|
479
|
-
data-disabled={
|
|
480
|
-
data-readonly={
|
|
481
|
-
data-required={
|
|
574
|
+
data-disabled={renderedDisabled || undefined}
|
|
575
|
+
data-readonly={renderedReadOnly || undefined}
|
|
576
|
+
data-required={renderedRequired || undefined}
|
|
482
577
|
data-focused={focused || undefined}
|
|
483
578
|
data-focus-visible={focusVisible || undefined}
|
|
484
579
|
onclick={composeEventHandlers(onClickExternal ?? undefined, handleClick)}
|
|
@@ -503,13 +598,13 @@
|
|
|
503
598
|
id={inputId}
|
|
504
599
|
tabindex={-1}
|
|
505
600
|
type="checkbox"
|
|
506
|
-
{
|
|
601
|
+
name={renderedName}
|
|
507
602
|
{value}
|
|
508
603
|
{form}
|
|
509
604
|
checked={currentChecked}
|
|
510
|
-
{
|
|
511
|
-
{
|
|
512
|
-
{
|
|
605
|
+
disabled={renderedDisabled}
|
|
606
|
+
required={renderedRequired}
|
|
607
|
+
readonly={renderedReadOnly}
|
|
513
608
|
aria-hidden="true"
|
|
514
609
|
data-checkbox-input="true"
|
|
515
610
|
onclick={handleInputClick}
|
|
@@ -5,21 +5,41 @@ type CheckboxRootProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'cla
|
|
|
5
5
|
element?: HTMLSpanElement | null;
|
|
6
6
|
name?: string;
|
|
7
7
|
value?: string;
|
|
8
|
-
/**
|
|
8
|
+
/** The id of the form of the hidden input. */
|
|
9
9
|
form?: string;
|
|
10
|
+
/** The checked state. By default it goes in the two directions: use `bind:checked`. */
|
|
10
11
|
checked?: boolean;
|
|
12
|
+
/** The checked state at the start, for when you give no `checked`. */
|
|
11
13
|
defaultChecked?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Give your own code full control of `checked`. The component stops to write back to the prop,
|
|
16
|
+
* and it reports only through `onCheckedChange`. Thus the parent can refuse a change: the parent
|
|
17
|
+
* does not send the new value down. The default is off, because `bind:checked` is the usual case
|
|
18
|
+
* and it needs the write-back.
|
|
19
|
+
*/
|
|
20
|
+
controlledChecked?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The indeterminate state. By default it goes in the two directions: use `bind:indeterminate`.
|
|
23
|
+
*/
|
|
12
24
|
indeterminate?: boolean;
|
|
25
|
+
/** The indeterminate state at the start, for when you give no `indeterminate`. */
|
|
13
26
|
defaultIndeterminate?: boolean;
|
|
27
|
+
/** Give your own code full control of `indeterminate`. Read `controlledChecked`. */
|
|
28
|
+
controlledIndeterminate?: boolean;
|
|
29
|
+
/** The component calls it when the user changes the checked state. */
|
|
14
30
|
onCheckedChange?: (checked: boolean) => void;
|
|
31
|
+
/** The component calls it when the user changes the indeterminate state. From the indeterminate state, the first user action makes the checkbox checked. */
|
|
15
32
|
onIndeterminateChange?: (indeterminate: boolean) => void;
|
|
16
33
|
disabled?: boolean;
|
|
17
34
|
readonly?: boolean;
|
|
18
35
|
required?: boolean;
|
|
19
36
|
children?: Snippet;
|
|
20
37
|
class?: string;
|
|
38
|
+
/** The accessible name, for when the user sees no name. */
|
|
21
39
|
'aria-label'?: string;
|
|
40
|
+
/** The id of the element that gives the checkbox its name. */
|
|
22
41
|
'aria-labelledby'?: string;
|
|
42
|
+
/** Replaces the default position in the tab order. */
|
|
23
43
|
tabindex?: number;
|
|
24
44
|
onclick?: HTMLAttributes<HTMLSpanElement>['onclick'];
|
|
25
45
|
onkeydown?: HTMLAttributes<HTMLSpanElement>['onkeydown'];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# CheckboxGroup
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`CheckboxGroup` coordinates several `Checkbox.Root` boxes as one field. It holds an array value,
|
|
6
|
+
and it shares a `name` for form submission. It also spreads group-wide disabled, read-only and
|
|
7
|
+
required state, and it reports the counts a parent "select all" checkbox needs.
|
|
8
|
+
|
|
9
|
+
## Anatomy
|
|
10
|
+
|
|
11
|
+
- `CheckboxGroup.Root`
|
|
12
|
+
- `CheckboxGroup.Label`
|
|
13
|
+
- `CheckboxGroup.Item`
|
|
14
|
+
- `CheckboxGroup.Indicator`
|
|
15
|
+
|
|
16
|
+
```svelte
|
|
17
|
+
<CheckboxGroup.Root name="colors" defaultValue={['red']}>
|
|
18
|
+
<CheckboxGroup.Label>Colors</CheckboxGroup.Label>
|
|
19
|
+
<Checkbox.Root value="red">
|
|
20
|
+
<Checkbox.Indicator>x</Checkbox.Indicator>
|
|
21
|
+
Red
|
|
22
|
+
</Checkbox.Root>
|
|
23
|
+
<Checkbox.Root value="green">
|
|
24
|
+
<Checkbox.Indicator>x</Checkbox.Indicator>
|
|
25
|
+
Green
|
|
26
|
+
</Checkbox.Root>
|
|
27
|
+
</CheckboxGroup.Root>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage guidelines
|
|
31
|
+
|
|
32
|
+
- Use `bind:value` to hand the group your state, or plain `value` + `onChange` to own it
|
|
33
|
+
yourself. There is no flag to declare which: supplying `value` makes it the source of
|
|
34
|
+
truth either way, and `onChange` always reports.
|
|
35
|
+
- A parent that holds `value` and refuses a change — it sends no new value down — still sees the
|
|
36
|
+
group move. The group then goes back to the value of the parent at the next render. Refuse a
|
|
37
|
+
change with a render, and not with silence.
|
|
38
|
+
- Give the group a `name` to submit the checked values as one field. Each `Checkbox.Root` puts its
|
|
39
|
+
own `value` on a hidden input under that name, which is what a native checkbox group does.
|
|
40
|
+
- `CheckboxGroup.Item` is `Checkbox.Root` under the namespace of the group, and the two names
|
|
41
|
+
are the same component. A checkbox works on its own, thus it keeps its own name too.
|
|
42
|
+
- Every box in a group must provide a unique `value`. The default value of a checkbox is
|
|
43
|
+
`on`, so two boxes without a `value` collide and the group reports it.
|
|
44
|
+
- Read `allSelected` and `someSelected` from the context to drive a parent "select all" checkbox,
|
|
45
|
+
and call `selectAll()` or `clearAll()` from it. Keep that parent checkbox **outside** the group:
|
|
46
|
+
it commands the group and is not one of its values.
|
|
47
|
+
|
|
48
|
+
## API reference
|
|
49
|
+
|
|
50
|
+
`CheckboxGroup.Root` supports:
|
|
51
|
+
|
|
52
|
+
- `value?: string[]`
|
|
53
|
+
- `defaultValue?: string[]`
|
|
54
|
+
- `onChange?: (value: string[]) => void`
|
|
55
|
+
- `name?: string`
|
|
56
|
+
- `disabled?: boolean`
|
|
57
|
+
- `readonly?: boolean`
|
|
58
|
+
- `required?: boolean`
|
|
59
|
+
- `orientation?: 'horizontal' | 'vertical'`
|
|
60
|
+
- `context?: CheckboxGroupContext`
|
|
61
|
+
- `children?: Snippet`
|
|
62
|
+
- `...restProps: HTMLAttributes<HTMLDivElement>`
|
|
63
|
+
|
|
64
|
+
## Accessibility
|
|
65
|
+
|
|
66
|
+
- `CheckboxGroup.Root` renders `role="group"`.
|
|
67
|
+
- `required` gives `data-required` only. It marks no element with `aria-required`, because
|
|
68
|
+
`role="group"` does not support that property. It also never goes down to the boxes. Native
|
|
69
|
+
`required` on a checkbox demands that one box. It would thus turn "at least one" into
|
|
70
|
+
"every one". Put the word in the group label, and give the reason with `aria-describedby`.
|
|
71
|
+
- Provide an accessible group name with `CheckboxGroup.Label`, or with `aria-label` on the root for
|
|
72
|
+
a name the user does not see. Two labels read as one name, in the order they appear. An
|
|
73
|
+
`aria-labelledby` that the caller gives stands, thus an element of your own wins.
|
|
74
|
+
- `CheckboxGroup.Label` renders a span, and not a `<label>`: a `<label>` names one control, thus it
|
|
75
|
+
cannot name a set.
|
|
76
|
+
- The id reaches the group through the context. The server cannot do that: the group tag is
|
|
77
|
+
already written when the label registers. Thus `aria-labelledby` appears at hydration. Give
|
|
78
|
+
`aria-label` as well when the name must be there on the first paint.
|
|
79
|
+
- Every checkbox keeps its own tab stop, and `Space` toggles the focused one. The group adds no
|
|
80
|
+
arrow-key navigation. This matches the APG, React Aria and Base UI: React Aria gives each
|
|
81
|
+
checkbox of a group `tabindex="0"`, measured on its own live example. Arrow keys and one tab
|
|
82
|
+
stop for a full set belong to a radio group, which is the `radiogroup` role.
|
|
83
|
+
|
|
84
|
+
## Notes
|
|
85
|
+
|
|
86
|
+
- Grouped checkboxes ignore their standalone `checked` and `defaultChecked` props. The group holds
|
|
87
|
+
the checked state and reports it through its own `value`.
|
|
88
|
+
- A checkbox that becomes disabled keeps its place in the value. This parts with `ToggleGroup`,
|
|
89
|
+
which drops a disabled selection. A checked and disabled checkbox is a state the platform
|
|
90
|
+
supports, and dropping it would rewrite the value a form was seeded with.
|
|
91
|
+
- Removing one `Checkbox.Root` from a mounted group is a real change, and the group reports the
|
|
92
|
+
shorter value. The removal of the full group is not a change, and it reports nothing. Without
|
|
93
|
+
this rule, a move to a different screen would look like the user clearing the boxes.
|
|
94
|
+
- Values are strings only. A grouped checkbox carries its value on a native `<input>`, which stores
|
|
95
|
+
it as a string. A number would thus let `value={[1]}` miss a checkbox declared as `value="1"`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import type CheckboxIndicatorComponent from '../checkbox/indicator/checkbox-indicator.svelte';
|
|
3
|
+
import type CheckboxRootComponent from '../checkbox/root/checkbox-root.svelte';
|
|
4
|
+
import type CheckboxGroupLabelComponent from './label/checkbox-group-label.svelte';
|
|
5
|
+
import type CheckboxGroupRootComponent from './root/checkbox-group-root.svelte';
|
|
6
|
+
export * as CheckboxGroup from './index.parts.js';
|
|
7
|
+
export { default as CheckboxGroupRoot } from './root/checkbox-group-root.svelte';
|
|
8
|
+
export { default as CheckboxGroupLabel } from './label/checkbox-group-label.svelte';
|
|
9
|
+
export type CheckboxGroupRootProps = ComponentProps<typeof CheckboxGroupRootComponent>;
|
|
10
|
+
export type CheckboxGroupLabelProps = ComponentProps<typeof CheckboxGroupLabelComponent>;
|
|
11
|
+
export type CheckboxGroupItemProps = ComponentProps<typeof CheckboxRootComponent>;
|
|
12
|
+
export type CheckboxGroupIndicatorProps = ComponentProps<typeof CheckboxIndicatorComponent>;
|
|
13
|
+
export { createCheckboxGroupContext, getCheckboxGroupContext, setCheckboxGroupContext, type CheckboxGroupContext, type CheckboxGroupOrientation, type CheckboxGroupValue, type CreateCheckboxGroupContextOptions } from './root/context.svelte';
|
|
14
|
+
import * as CheckboxGroupParts from './index.parts.js';
|
|
15
|
+
export default CheckboxGroupParts;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as CheckboxGroup from './index.parts.js';
|
|
2
|
+
export { default as CheckboxGroupRoot } from './root/checkbox-group-root.svelte';
|
|
3
|
+
export { default as CheckboxGroupLabel } from './label/checkbox-group-label.svelte';
|
|
4
|
+
export { createCheckboxGroupContext, getCheckboxGroupContext, setCheckboxGroupContext } from './root/context.svelte';
|
|
5
|
+
import * as CheckboxGroupParts from './index.parts.js';
|
|
6
|
+
export default CheckboxGroupParts;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as Root } from './root/checkbox-group-root.svelte';
|
|
2
|
+
export { default as Label } from './label/checkbox-group-label.svelte';
|
|
3
|
+
export { default as Item } from '../checkbox/root/checkbox-root.svelte';
|
|
4
|
+
export { default as Indicator } from '../checkbox/indicator/checkbox-indicator.svelte';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as Root } from './root/checkbox-group-root.svelte';
|
|
2
|
+
export { default as Label } from './label/checkbox-group-label.svelte';
|
|
3
|
+
// `Item` and `Indicator` are `Checkbox.Root` and `Checkbox.Indicator` under the namespace of the
|
|
4
|
+
// group. A checkbox works on its own, so it keeps its own name; this pair only gives every group
|
|
5
|
+
// in the library the same shape — `Group.Root` with `Group.Item` inside.
|
|
6
|
+
export { default as Item } from '../checkbox/root/checkbox-root.svelte';
|
|
7
|
+
export { default as Indicator } from '../checkbox/indicator/checkbox-indicator.svelte';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { CheckboxGroupLabelProps } from '../types.js';
|
|
3
|
+
import { getCheckboxGroupContext } from '../root/context.svelte';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* CheckboxGroup.Label — the accessible name of the group.
|
|
7
|
+
*
|
|
8
|
+
* It registers its id with the root, which gives it to the group element as
|
|
9
|
+
* `aria-labelledby`. A bare heading beside the group leaves the group unnamed: a
|
|
10
|
+
* `role="group"` takes its name from `aria-labelledby` or `aria-label`, never from the text
|
|
11
|
+
* near it. It renders a `<span>` and not a `<label>`, because a `<label>` names one control.
|
|
12
|
+
*/
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
class: className = '',
|
|
16
|
+
id: idProp,
|
|
17
|
+
...restProps
|
|
18
|
+
}: CheckboxGroupLabelProps = $props();
|
|
19
|
+
|
|
20
|
+
const checkboxGroup = getCheckboxGroupContext();
|
|
21
|
+
|
|
22
|
+
if (!checkboxGroup) {
|
|
23
|
+
throw new Error('CheckboxGroup.Label must be used within CheckboxGroup.Root.');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const group = checkboxGroup;
|
|
27
|
+
const generatedId = $props.id();
|
|
28
|
+
const id = $derived(idProp ?? generatedId);
|
|
29
|
+
|
|
30
|
+
// The returned unregister runs on destroy, and again whenever the id changes.
|
|
31
|
+
$effect(() => group.registerLabel(id));
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<span {...restProps} {id} class={className} data-checkbox-group-label="true">
|
|
35
|
+
{@render children?.()}
|
|
36
|
+
</span>
|