@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,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>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import type { CheckboxGroupRootProps } from '../types.js';
|
|
4
|
+
import { createCheckboxGroupContext, setCheckboxGroupContext } from './context.svelte';
|
|
5
|
+
|
|
6
|
+
const generatedId = $props.id();
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
id,
|
|
10
|
+
value = $bindable(),
|
|
11
|
+
defaultValue,
|
|
12
|
+
onChange,
|
|
13
|
+
name,
|
|
14
|
+
disabled: disabledProp = false,
|
|
15
|
+
readonly: readOnlyProp = false,
|
|
16
|
+
required: requiredProp = false,
|
|
17
|
+
orientation = 'vertical',
|
|
18
|
+
children,
|
|
19
|
+
class: className = '',
|
|
20
|
+
element = $bindable<HTMLDivElement | null>(null),
|
|
21
|
+
context = $bindable(),
|
|
22
|
+
'aria-labelledby': ariaLabelledBy,
|
|
23
|
+
...restProps
|
|
24
|
+
}: CheckboxGroupRootProps = $props();
|
|
25
|
+
|
|
26
|
+
const instanceId = untrack(() => id) ?? generatedId;
|
|
27
|
+
|
|
28
|
+
let rootRef: HTMLDivElement | null = $state(null);
|
|
29
|
+
|
|
30
|
+
const checkboxGroup = setCheckboxGroupContext(
|
|
31
|
+
createCheckboxGroupContext({
|
|
32
|
+
// `value` seeds the initial selection whenever it is supplied, bound or not.
|
|
33
|
+
initialValue: untrack(() => value) ?? untrack(() => defaultValue),
|
|
34
|
+
name: (() => name)(),
|
|
35
|
+
isDisabled: (() => disabledProp)(),
|
|
36
|
+
isReadOnly: (() => readOnlyProp)(),
|
|
37
|
+
isRequired: (() => requiredProp)(),
|
|
38
|
+
orientation: (() => orientation)(),
|
|
39
|
+
onValueChange: (nextValue) => {
|
|
40
|
+
// One path for both usages: with `bind:value` this reaches the parent, and
|
|
41
|
+
// without a binding the write stays local, so nothing here has to know
|
|
42
|
+
// which one the caller chose.
|
|
43
|
+
value = nextValue;
|
|
44
|
+
onChange?.(nextValue);
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
context = checkboxGroup;
|
|
50
|
+
|
|
51
|
+
// Marks the window in which a checkbox disappearing is a real change rather than the group
|
|
52
|
+
// itself coming or going. `$effect.pre` because Svelte destroys an effect's children
|
|
53
|
+
// before running that effect's own teardown, so an `onDestroy` here would fire *after*
|
|
54
|
+
// every checkbox had already unregistered: this one is created while the script runs,
|
|
55
|
+
// before the children exist, so it is first in destroy order and its cleanup lands ahead
|
|
56
|
+
// of theirs. On the server it never runs, which is right too — there the checkboxes
|
|
57
|
+
// unregister as the markup closes and nobody is listening any more.
|
|
58
|
+
$effect.pre(() => {
|
|
59
|
+
checkboxGroup.setLive(true);
|
|
60
|
+
return () => checkboxGroup.setLive(false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const disabled = $derived(checkboxGroup.isDisabled);
|
|
64
|
+
const readOnly = $derived(checkboxGroup.isReadOnly);
|
|
65
|
+
const required = $derived(checkboxGroup.isRequired);
|
|
66
|
+
const currentOrientation = $derived(checkboxGroup.orientation);
|
|
67
|
+
|
|
68
|
+
$effect(() => {
|
|
69
|
+
element = rootRef;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
$effect(() => {
|
|
73
|
+
checkboxGroup.setName(name);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
$effect(() => {
|
|
77
|
+
checkboxGroup.setDisabled(disabledProp);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
$effect(() => {
|
|
81
|
+
checkboxGroup.setReadOnly(readOnlyProp);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
$effect(() => {
|
|
85
|
+
checkboxGroup.setRequired(requiredProp);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
$effect(() => {
|
|
89
|
+
checkboxGroup.setOrientation(orientation);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// A parent that supplies `value` drives the selection, bound or not. Latched at init,
|
|
93
|
+
// not reactive — re-checking `value !== undefined` would switch this on the moment our
|
|
94
|
+
// own write-back defines it, and a `defaultValue`-only group would start following the
|
|
95
|
+
// echo of its own changes.
|
|
96
|
+
const adoptsValueProp = untrack(() => value !== undefined);
|
|
97
|
+
|
|
98
|
+
$effect(() => {
|
|
99
|
+
if (!adoptsValueProp) return;
|
|
100
|
+
checkboxGroup.setSelectedValues(value);
|
|
101
|
+
});
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<div
|
|
105
|
+
{...restProps}
|
|
106
|
+
bind:this={rootRef}
|
|
107
|
+
id={instanceId}
|
|
108
|
+
role="group"
|
|
109
|
+
aria-labelledby={ariaLabelledBy ?? checkboxGroup.labelledBy}
|
|
110
|
+
class={className}
|
|
111
|
+
data-checkbox-group-root="true"
|
|
112
|
+
data-orientation={currentOrientation}
|
|
113
|
+
data-disabled={disabled || undefined}
|
|
114
|
+
data-readonly={readOnly || undefined}
|
|
115
|
+
data-required={required || undefined}
|
|
116
|
+
>
|
|
117
|
+
{@render children?.()}
|
|
118
|
+
</div>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CheckboxGroupRootProps } from '../types.js';
|
|
2
|
+
declare const CheckboxGroupRoot: import("svelte").Component<CheckboxGroupRootProps, {}, "value" | "element" | "context">;
|
|
3
|
+
type CheckboxGroupRoot = ReturnType<typeof CheckboxGroupRoot>;
|
|
4
|
+
export default CheckboxGroupRoot;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type CheckboxGroupValue = string;
|
|
2
|
+
export type CheckboxGroupOrientation = 'horizontal' | 'vertical';
|
|
3
|
+
export type CreateCheckboxGroupContextOptions = {
|
|
4
|
+
initialValue?: CheckboxGroupValue[];
|
|
5
|
+
name?: string;
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
isReadOnly?: boolean;
|
|
8
|
+
isRequired?: boolean;
|
|
9
|
+
orientation?: CheckboxGroupOrientation;
|
|
10
|
+
onValueChange?: (value: CheckboxGroupValue[]) => void;
|
|
11
|
+
};
|
|
12
|
+
export type CheckboxGroupContext = {
|
|
13
|
+
name: string | undefined;
|
|
14
|
+
isDisabled: boolean;
|
|
15
|
+
isReadOnly: boolean;
|
|
16
|
+
isRequired: boolean;
|
|
17
|
+
orientation: CheckboxGroupOrientation;
|
|
18
|
+
/** The ids of the `CheckboxGroup.Label` parts, for `aria-labelledby` on the group. */
|
|
19
|
+
labelledBy: string | undefined;
|
|
20
|
+
selectedValues: Set<CheckboxGroupValue>;
|
|
21
|
+
/** Every registered checkbox is selected, and there is at least one. */
|
|
22
|
+
allSelected: boolean;
|
|
23
|
+
/** Some but not all registered checkboxes are selected. Drives a parent `indeterminate`. */
|
|
24
|
+
someSelected: boolean;
|
|
25
|
+
/** Registers a label id; the returned function unregisters it. */
|
|
26
|
+
registerLabel: (id: string) => () => void;
|
|
27
|
+
registerCheckbox: (value: CheckboxGroupValue, options: {
|
|
28
|
+
isDisabled?: boolean;
|
|
29
|
+
element?: HTMLElement | null;
|
|
30
|
+
owner?: symbol;
|
|
31
|
+
}) => void;
|
|
32
|
+
unregisterCheckbox: (value: CheckboxGroupValue) => void;
|
|
33
|
+
setLive: (live: boolean) => void;
|
|
34
|
+
setName: (name: string | undefined) => void;
|
|
35
|
+
setDisabled: (disabled: boolean) => void;
|
|
36
|
+
setReadOnly: (readonly: boolean) => void;
|
|
37
|
+
setRequired: (required: boolean) => void;
|
|
38
|
+
setOrientation: (orientation: CheckboxGroupOrientation) => void;
|
|
39
|
+
setSelectedValues: (value?: CheckboxGroupValue[]) => void;
|
|
40
|
+
toggleValue: (value: CheckboxGroupValue) => boolean | null;
|
|
41
|
+
setValueSelected: (value: CheckboxGroupValue, selected: boolean) => boolean | null;
|
|
42
|
+
selectAll: () => void;
|
|
43
|
+
clearAll: () => void;
|
|
44
|
+
isSelected: (value: CheckboxGroupValue) => boolean;
|
|
45
|
+
isCheckboxDisabled: (value: CheckboxGroupValue) => boolean;
|
|
46
|
+
getValue: () => CheckboxGroupValue[];
|
|
47
|
+
getEnabledValues: () => CheckboxGroupValue[];
|
|
48
|
+
};
|
|
49
|
+
export declare function valuesToArray(values: Set<CheckboxGroupValue>, order: CheckboxGroupValue[]): CheckboxGroupValue[];
|
|
50
|
+
export declare function createCheckboxGroupContext(options: CreateCheckboxGroupContextOptions): CheckboxGroupContext;
|
|
51
|
+
export declare function setCheckboxGroupContext(context: CheckboxGroupContext): CheckboxGroupContext;
|
|
52
|
+
export declare function getCheckboxGroupContext(): CheckboxGroupContext | undefined;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { getContext, setContext, untrack } from 'svelte';
|
|
2
|
+
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
|
3
|
+
import { asCommand } from '../../internal/as-command.js';
|
|
4
|
+
const CHECKBOX_GROUP_CONTEXT_KEY = Symbol('checkbox-group');
|
|
5
|
+
export function valuesToArray(values, order) {
|
|
6
|
+
const orderedValues = order.filter((value) => values.has(value));
|
|
7
|
+
const unknownValues = Array.from(values).filter((value) => !order.includes(value));
|
|
8
|
+
return [...orderedValues, ...unknownValues];
|
|
9
|
+
}
|
|
10
|
+
export function createCheckboxGroupContext(options) {
|
|
11
|
+
let name = $state(options.name);
|
|
12
|
+
let isDisabled = $state(options.isDisabled ?? false);
|
|
13
|
+
let isReadOnly = $state(options.isReadOnly ?? false);
|
|
14
|
+
let isRequired = $state(options.isRequired ?? false);
|
|
15
|
+
let orientation = $state(options.orientation ?? 'vertical');
|
|
16
|
+
let labelIds = $state([]);
|
|
17
|
+
// A `SvelteSet` carries its own reactivity, so it is mutated in place rather than
|
|
18
|
+
// reassigned: a plain Set behind `$state` would need a new instance for every change,
|
|
19
|
+
// and it would invalidate every reader of the group on each one.
|
|
20
|
+
const selectedValues = new SvelteSet(options.initialValue ?? []);
|
|
21
|
+
// Whether the group is mounted and interactive. Plain `let`, not `$state`: nothing renders
|
|
22
|
+
// from it, and the reads happen while checkboxes register and unregister, where a reactive
|
|
23
|
+
// read would only add a dependency.
|
|
24
|
+
let isLive = false;
|
|
25
|
+
const checkboxes = new SvelteMap();
|
|
26
|
+
const checkboxOrder = $state([]);
|
|
27
|
+
function getOrderedValues() {
|
|
28
|
+
const connected = [];
|
|
29
|
+
const detachedValues = [];
|
|
30
|
+
for (const value of checkboxOrder) {
|
|
31
|
+
const element = checkboxes.get(value)?.element;
|
|
32
|
+
if (element?.isConnected) {
|
|
33
|
+
connected.push({ value, element });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
detachedValues.push(value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
connected.sort((left, right) => left.element.compareDocumentPosition(right.element) & Node.DOCUMENT_POSITION_FOLLOWING
|
|
40
|
+
? -1
|
|
41
|
+
: 1);
|
|
42
|
+
return [...connected.map((entry) => entry.value), ...detachedValues];
|
|
43
|
+
}
|
|
44
|
+
function getEnabledValues() {
|
|
45
|
+
return getOrderedValues().filter((value) => checkboxes.has(value) && !isCheckboxDisabled(value));
|
|
46
|
+
}
|
|
47
|
+
function getValue() {
|
|
48
|
+
return valuesToArray(selectedValues, getOrderedValues());
|
|
49
|
+
}
|
|
50
|
+
function setSelection(nextValues, changeOptions) {
|
|
51
|
+
const order = getOrderedValues();
|
|
52
|
+
const previousValue = valuesToArray(selectedValues, order);
|
|
53
|
+
const nextValue = valuesToArray(nextValues, order);
|
|
54
|
+
const didChange = previousValue.length !== nextValue.length ||
|
|
55
|
+
previousValue.some((value, index) => value !== nextValue[index]);
|
|
56
|
+
if (!didChange)
|
|
57
|
+
return false;
|
|
58
|
+
selectedValues.clear();
|
|
59
|
+
for (const value of nextValue) {
|
|
60
|
+
selectedValues.add(value);
|
|
61
|
+
}
|
|
62
|
+
if (changeOptions?.notify !== false) {
|
|
63
|
+
options.onValueChange?.(nextValue);
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
// Unlike `ToggleGroup`, a disabled checkbox keeps its selection: a checked and disabled
|
|
68
|
+
// checkbox is a real state the platform supports, and dropping it would silently rewrite
|
|
69
|
+
// the value a form was seeded with. Only a checkbox that leaves the tree leaves the value.
|
|
70
|
+
function reconcileSelection(removedValue, changeOptions) {
|
|
71
|
+
if (removedValue === undefined || checkboxes.has(removedValue))
|
|
72
|
+
return;
|
|
73
|
+
if (!selectedValues.has(removedValue))
|
|
74
|
+
return;
|
|
75
|
+
const nextValues = new SvelteSet(selectedValues);
|
|
76
|
+
nextValues.delete(removedValue);
|
|
77
|
+
setSelection(nextValues, changeOptions);
|
|
78
|
+
}
|
|
79
|
+
function registerCheckbox(value, registerOptions) {
|
|
80
|
+
const existingCheckbox = checkboxes.get(value);
|
|
81
|
+
if (existingCheckbox !== undefined &&
|
|
82
|
+
existingCheckbox.owner !== undefined &&
|
|
83
|
+
registerOptions.owner !== undefined &&
|
|
84
|
+
existingCheckbox.owner !== registerOptions.owner) {
|
|
85
|
+
throw new Error('Checkbox.Root values must be unique within a CheckboxGroup.Root.');
|
|
86
|
+
}
|
|
87
|
+
checkboxes.set(value, {
|
|
88
|
+
value,
|
|
89
|
+
isDisabled: Boolean(registerOptions.isDisabled),
|
|
90
|
+
element: registerOptions.element,
|
|
91
|
+
owner: registerOptions.owner
|
|
92
|
+
});
|
|
93
|
+
if (existingCheckbox === undefined) {
|
|
94
|
+
checkboxOrder.push(value);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Turned on by the root as it renders and off as it goes away, which is the only way to
|
|
98
|
+
// tell the two unregistrations apart: a checkbox removed from a live group leaves a group
|
|
99
|
+
// behind that still has to show something, while a group on its way out has no one left
|
|
100
|
+
// to show anything to.
|
|
101
|
+
function setLive(live) {
|
|
102
|
+
isLive = live;
|
|
103
|
+
}
|
|
104
|
+
function unregisterCheckbox(value) {
|
|
105
|
+
if (!checkboxes.has(value))
|
|
106
|
+
return;
|
|
107
|
+
checkboxes.delete(value);
|
|
108
|
+
const index = checkboxOrder.indexOf(value);
|
|
109
|
+
if (index >= 0) {
|
|
110
|
+
checkboxOrder.splice(index, 1);
|
|
111
|
+
}
|
|
112
|
+
// Outside the live window the checkbox is leaving because the group is — on the client
|
|
113
|
+
// while it unmounts, on the server as the markup closes — and reporting a value change
|
|
114
|
+
// there would tell a consumer already on its way out that the user cleared a box.
|
|
115
|
+
if (!isLive)
|
|
116
|
+
return;
|
|
117
|
+
reconcileSelection(value);
|
|
118
|
+
}
|
|
119
|
+
function setName(nextName) {
|
|
120
|
+
if (name === nextName)
|
|
121
|
+
return;
|
|
122
|
+
name = nextName;
|
|
123
|
+
}
|
|
124
|
+
function setDisabled(disabled) {
|
|
125
|
+
if (isDisabled === disabled)
|
|
126
|
+
return;
|
|
127
|
+
isDisabled = disabled;
|
|
128
|
+
}
|
|
129
|
+
function setReadOnly(readonly) {
|
|
130
|
+
if (isReadOnly === readonly)
|
|
131
|
+
return;
|
|
132
|
+
isReadOnly = readonly;
|
|
133
|
+
}
|
|
134
|
+
function setRequired(required) {
|
|
135
|
+
if (isRequired === required)
|
|
136
|
+
return;
|
|
137
|
+
isRequired = required;
|
|
138
|
+
}
|
|
139
|
+
function setOrientation(nextOrientation) {
|
|
140
|
+
if (orientation === nextOrientation)
|
|
141
|
+
return;
|
|
142
|
+
orientation = nextOrientation;
|
|
143
|
+
}
|
|
144
|
+
function setSelectedValues(value) {
|
|
145
|
+
setSelection(new SvelteSet(value ?? []), { notify: false });
|
|
146
|
+
}
|
|
147
|
+
function setValueSelected(value, selected) {
|
|
148
|
+
if (isCheckboxDisabled(value) || isReadOnly)
|
|
149
|
+
return null;
|
|
150
|
+
if (selectedValues.has(value) === selected)
|
|
151
|
+
return null;
|
|
152
|
+
const nextValues = new SvelteSet(selectedValues);
|
|
153
|
+
if (selected) {
|
|
154
|
+
nextValues.add(value);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
nextValues.delete(value);
|
|
158
|
+
}
|
|
159
|
+
return setSelection(nextValues) ? selected : null;
|
|
160
|
+
}
|
|
161
|
+
function toggleValue(value) {
|
|
162
|
+
return setValueSelected(value, !selectedValues.has(value));
|
|
163
|
+
}
|
|
164
|
+
function selectAll() {
|
|
165
|
+
if (isReadOnly)
|
|
166
|
+
return;
|
|
167
|
+
const nextValues = new SvelteSet(selectedValues);
|
|
168
|
+
for (const value of getEnabledValues()) {
|
|
169
|
+
nextValues.add(value);
|
|
170
|
+
}
|
|
171
|
+
setSelection(nextValues);
|
|
172
|
+
}
|
|
173
|
+
function clearAll() {
|
|
174
|
+
if (isReadOnly)
|
|
175
|
+
return;
|
|
176
|
+
const nextValues = new SvelteSet(selectedValues);
|
|
177
|
+
for (const value of getEnabledValues()) {
|
|
178
|
+
nextValues.delete(value);
|
|
179
|
+
}
|
|
180
|
+
setSelection(nextValues);
|
|
181
|
+
}
|
|
182
|
+
function isSelected(value) {
|
|
183
|
+
return selectedValues.has(value);
|
|
184
|
+
}
|
|
185
|
+
function isCheckboxDisabled(value) {
|
|
186
|
+
return isDisabled || Boolean(checkboxes.get(value)?.isDisabled);
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
get name() {
|
|
190
|
+
return name;
|
|
191
|
+
},
|
|
192
|
+
get isDisabled() {
|
|
193
|
+
return isDisabled;
|
|
194
|
+
},
|
|
195
|
+
get isReadOnly() {
|
|
196
|
+
return isReadOnly;
|
|
197
|
+
},
|
|
198
|
+
get isRequired() {
|
|
199
|
+
return isRequired;
|
|
200
|
+
},
|
|
201
|
+
get orientation() {
|
|
202
|
+
return orientation;
|
|
203
|
+
},
|
|
204
|
+
get labelledBy() {
|
|
205
|
+
return labelIds.length > 0 ? labelIds.join(' ') : undefined;
|
|
206
|
+
},
|
|
207
|
+
get selectedValues() {
|
|
208
|
+
return selectedValues;
|
|
209
|
+
},
|
|
210
|
+
get allSelected() {
|
|
211
|
+
return checkboxOrder.length > 0 && checkboxOrder.every((value) => selectedValues.has(value));
|
|
212
|
+
},
|
|
213
|
+
get someSelected() {
|
|
214
|
+
const selectedCount = checkboxOrder.filter((value) => selectedValues.has(value)).length;
|
|
215
|
+
return selectedCount > 0 && selectedCount < checkboxOrder.length;
|
|
216
|
+
},
|
|
217
|
+
// `untrack` because the caller registers from an effect: reading `labelIds` here would
|
|
218
|
+
// make that effect depend on what it writes, and the pair would run without end.
|
|
219
|
+
registerLabel(id) {
|
|
220
|
+
untrack(() => {
|
|
221
|
+
labelIds = [...labelIds, id];
|
|
222
|
+
});
|
|
223
|
+
return () => untrack(() => {
|
|
224
|
+
labelIds = labelIds.filter((candidate) => candidate !== id);
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
registerCheckbox: asCommand(registerCheckbox),
|
|
228
|
+
unregisterCheckbox: asCommand(unregisterCheckbox),
|
|
229
|
+
setLive: asCommand(setLive),
|
|
230
|
+
setName: asCommand(setName),
|
|
231
|
+
setDisabled: asCommand(setDisabled),
|
|
232
|
+
setReadOnly: asCommand(setReadOnly),
|
|
233
|
+
setRequired: asCommand(setRequired),
|
|
234
|
+
setOrientation: asCommand(setOrientation),
|
|
235
|
+
setSelectedValues: asCommand(setSelectedValues),
|
|
236
|
+
toggleValue: asCommand(toggleValue),
|
|
237
|
+
setValueSelected: asCommand(setValueSelected),
|
|
238
|
+
selectAll: asCommand(selectAll),
|
|
239
|
+
clearAll: asCommand(clearAll),
|
|
240
|
+
isSelected,
|
|
241
|
+
isCheckboxDisabled,
|
|
242
|
+
getValue,
|
|
243
|
+
getEnabledValues
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
export function setCheckboxGroupContext(context) {
|
|
247
|
+
return setContext(CHECKBOX_GROUP_CONTEXT_KEY, context);
|
|
248
|
+
}
|
|
249
|
+
export function getCheckboxGroupContext() {
|
|
250
|
+
return getContext(CHECKBOX_GROUP_CONTEXT_KEY);
|
|
251
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { CheckboxGroupContext, CheckboxGroupOrientation, CheckboxGroupValue } from './root/context.svelte.js';
|
|
4
|
+
export type { CheckboxGroupContext, CheckboxGroupOrientation, CheckboxGroupValue } from './root/context.svelte.js';
|
|
5
|
+
export type CheckboxGroupRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
6
|
+
/**
|
|
7
|
+
* The selected values. When you give this prop, it is the source of truth, with `bind:value` or
|
|
8
|
+
* without it. The component writes each change here and reports it through `onChange`.
|
|
9
|
+
*
|
|
10
|
+
* Without a binding, that write stays local. Thus a parent that hears `onChange` and refuses the
|
|
11
|
+
* change — it sends no new `value` down — sees the group move. The group then goes back to the
|
|
12
|
+
* value of the parent at the next render.
|
|
13
|
+
*/
|
|
14
|
+
value?: CheckboxGroupValue[];
|
|
15
|
+
/** The selected values at the start, for when you give no `value`. */
|
|
16
|
+
defaultValue?: CheckboxGroupValue[];
|
|
17
|
+
/** The component calls it when the user changes the selection. */
|
|
18
|
+
onChange?: (value: CheckboxGroupValue[]) => void;
|
|
19
|
+
/** The `name` of the hidden input of every checkbox in the group, for form submission. */
|
|
20
|
+
name?: string;
|
|
21
|
+
/** Disables each checkbox in the group. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Shows the value of the group, and refuses each change from the user. */
|
|
24
|
+
readonly?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Records that the group needs an answer. It gives `data-required` for your styles, and it
|
|
27
|
+
* does not enforce a minimum count. It marks neither the group nor the boxes with
|
|
28
|
+
* `aria-required`: `role="group"` does not support that property, and native `required` on a
|
|
29
|
+
* box demands that one box. Say it in the group label, and give the reason with
|
|
30
|
+
* `aria-describedby`.
|
|
31
|
+
*/
|
|
32
|
+
required?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The orientation of the layout. It sets `data-orientation` for your styles. It does not change
|
|
35
|
+
* the keyboard behavior: each checkbox keeps its own tab stop.
|
|
36
|
+
*/
|
|
37
|
+
orientation?: CheckboxGroupOrientation;
|
|
38
|
+
/** The checkboxes of the group. */
|
|
39
|
+
children?: Snippet;
|
|
40
|
+
class?: string;
|
|
41
|
+
/** The id of the group element. The component makes one when you give none. */
|
|
42
|
+
id?: string;
|
|
43
|
+
/** The group element. Use `bind:element` to read it. */
|
|
44
|
+
element?: HTMLDivElement | null;
|
|
45
|
+
/**
|
|
46
|
+
* The state of the group. Use `bind:context` to read `allSelected` and `someSelected` for a
|
|
47
|
+
* parent "select all" checkbox, and to call `selectAll` and `clearAll`.
|
|
48
|
+
*/
|
|
49
|
+
context?: CheckboxGroupContext;
|
|
50
|
+
};
|
|
51
|
+
export type CheckboxGroupLabelProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class' | 'id'> & {
|
|
52
|
+
/** The name of the group. */
|
|
53
|
+
children?: Snippet;
|
|
54
|
+
class?: string;
|
|
55
|
+
/** The id of the label element. The component makes one when you give none. */
|
|
56
|
+
id?: string;
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|