@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* of available results to screen readers as the query changes.
|
|
4
4
|
*/
|
|
5
5
|
type AutocompleteStatusProps = {
|
|
6
|
-
/**
|
|
6
|
+
/** Makes the announced message from the number of the items that the user sees. */
|
|
7
7
|
formatMessage?: (count: number) => string;
|
|
8
8
|
};
|
|
9
9
|
declare const AutocompleteStatus: import("svelte").Component<AutocompleteStatusProps, {}, "">;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Avatar
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`Avatar` is a picture of a person or a thing, with a fallback for when the picture is not there. The image loads off the screen first, and it shows once it is there: a broken image icon never shows. The fallback shows in its place, at once or after a delay.
|
|
6
|
+
|
|
7
|
+
## Anatomy
|
|
8
|
+
|
|
9
|
+
- `Avatar.Root`
|
|
10
|
+
- `Avatar.Image`
|
|
11
|
+
- `Avatar.Fallback`
|
|
12
|
+
- `Avatar.Group`
|
|
13
|
+
- `Avatar.Count`
|
|
14
|
+
|
|
15
|
+
```svelte
|
|
16
|
+
<Avatar.Root class="size-10 rounded-full">
|
|
17
|
+
<Avatar.Image src="/ada.jpg" alt="Ada Lovelace" />
|
|
18
|
+
<Avatar.Fallback delay={600}>AL</Avatar.Fallback>
|
|
19
|
+
</Avatar.Root>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage guidelines
|
|
23
|
+
|
|
24
|
+
- Give `alt` the name of the person or the thing. Give an empty `alt` when the name is beside the avatar already. The fallback follows the `alt`: it takes the name, or it hides.
|
|
25
|
+
- Give `delay` to the fallback, such as 600, thus a fast image does not flash initials first.
|
|
26
|
+
- Style the root by `data-status`: `loading`, `loaded` or `error`.
|
|
27
|
+
- Read the status with `onStatusChange` on the root.
|
|
28
|
+
- Give `loading="lazy"` to the image on a long list: the load starts when the avatar comes into view.
|
|
29
|
+
- Put a row of avatars in `Avatar.Group` with an `aria-label` and a `max`, and an `Avatar.Count` for the ones past the limit.
|
|
30
|
+
|
|
31
|
+
## API reference
|
|
32
|
+
|
|
33
|
+
- `Avatar.Root`
|
|
34
|
+
- `onStatusChange?: (status: 'loading' | 'loaded' | 'error') => void`
|
|
35
|
+
- `element?: HTMLSpanElement | null` (bindable)
|
|
36
|
+
- `Avatar.Image`
|
|
37
|
+
- `src?: string | null`, `alt: string`
|
|
38
|
+
- `element?: HTMLImageElement | null` (bindable)
|
|
39
|
+
- `Avatar.Fallback`
|
|
40
|
+
- `delay?: number` (`0`)
|
|
41
|
+
- `element?: HTMLSpanElement | null` (bindable)
|
|
42
|
+
- `Avatar.Group`
|
|
43
|
+
- `max?: number`, `aria-label?: string`
|
|
44
|
+
- `Avatar.Count`
|
|
45
|
+
- `children?: Snippet<[{ overflow, count, max }]>`, `aria-label?: string` ("N more", localized)
|
|
46
|
+
|
|
47
|
+
## Accessibility
|
|
48
|
+
|
|
49
|
+
- The image is an `<img>` with your `alt`. The root has no role of its own.
|
|
50
|
+
- The fallback takes the name of the image: it is a `role="img"` named with the `alt`. A screen reader hears the name, and not the letters of the initials. An empty `alt` hides it. Without an image, it is plain content.
|
|
51
|
+
- `Avatar.Group` is a `role="group"` named with your `aria-label`. `Avatar.Count` is a `role="img"` named "N more".
|
|
52
|
+
- Nothing in the avatar is focusable.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { readable } from 'svelte/store';
|
|
3
|
+
import { resolveLocalizedString } from '../../internal/localized-strings';
|
|
4
|
+
import { useLocaleContextOptional } from '../../locale-provider/context';
|
|
5
|
+
import type { AvatarCountProps } from '../types.js';
|
|
6
|
+
import { useAvatarGroupContext } from '../group/context';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Avatar.Count — the count of avatars past the `max` of the group, such as `+3`.
|
|
10
|
+
*
|
|
11
|
+
* It renders only while the group has more avatars than it shows. The screen reader hears
|
|
12
|
+
* "3 more", in the locale of `LocaleProvider`, and not "plus three".
|
|
13
|
+
*/
|
|
14
|
+
let {
|
|
15
|
+
children,
|
|
16
|
+
class: className = '',
|
|
17
|
+
'aria-label': ariaLabelProp,
|
|
18
|
+
element = $bindable<HTMLSpanElement | null>(null),
|
|
19
|
+
...restProps
|
|
20
|
+
}: AvatarCountProps = $props();
|
|
21
|
+
|
|
22
|
+
const group = useAvatarGroupContext('Avatar.Count');
|
|
23
|
+
|
|
24
|
+
const localeContext = useLocaleContextOptional();
|
|
25
|
+
const emptyLocaleStore = readable<string | undefined>(undefined);
|
|
26
|
+
const localeStore = localeContext?.locale ?? emptyLocaleStore;
|
|
27
|
+
const ariaLabel = $derived(
|
|
28
|
+
ariaLabelProp ?? resolveLocalizedString($localeStore, 'avatar.more', { count: group.overflow })
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
let countRef: HTMLSpanElement | null = $state(null);
|
|
32
|
+
|
|
33
|
+
$effect(() => {
|
|
34
|
+
element = countRef;
|
|
35
|
+
return () => {
|
|
36
|
+
element = null;
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
{#if group.overflow > 0}
|
|
42
|
+
<span
|
|
43
|
+
{...restProps}
|
|
44
|
+
bind:this={countRef}
|
|
45
|
+
role="img"
|
|
46
|
+
aria-label={ariaLabel}
|
|
47
|
+
class={className}
|
|
48
|
+
data-avatar-count="true"
|
|
49
|
+
>
|
|
50
|
+
{#if children}
|
|
51
|
+
{@render children({ overflow: group.overflow, count: group.count, max: group.max })}
|
|
52
|
+
{:else}
|
|
53
|
+
+{group.overflow}
|
|
54
|
+
{/if}
|
|
55
|
+
</span>
|
|
56
|
+
{/if}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { AvatarFallbackProps } from '../types.js';
|
|
3
|
+
import { useAvatarContext } from '../root/context';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Avatar.Fallback — what shows in place of the image: initials, an icon, a color.
|
|
7
|
+
*
|
|
8
|
+
* It shows while the image is not on the screen. `delay` holds it back while the image
|
|
9
|
+
* loads, thus a fast image does not flash a fallback first. It shows at once when the image
|
|
10
|
+
* fails, or when there is no image.
|
|
11
|
+
*
|
|
12
|
+
* It takes the name of the image: with an `alt` on `Avatar.Image`, the fallback is a
|
|
13
|
+
* `role="img"` with that `alt` as its name, thus a screen reader hears "Ada Lovelace" and not
|
|
14
|
+
* the letters of her initials. An empty `alt` makes the fallback decorative, the same as it
|
|
15
|
+
* makes the image.
|
|
16
|
+
*/
|
|
17
|
+
let {
|
|
18
|
+
children,
|
|
19
|
+
class: className = '',
|
|
20
|
+
delay = 0,
|
|
21
|
+
element = $bindable<HTMLSpanElement | null>(null),
|
|
22
|
+
...restProps
|
|
23
|
+
}: AvatarFallbackProps = $props();
|
|
24
|
+
|
|
25
|
+
const avatar = useAvatarContext('Avatar.Fallback');
|
|
26
|
+
|
|
27
|
+
let fallbackRef: HTMLSpanElement | null = $state(null);
|
|
28
|
+
// True once `delay` has passed since the load started. It resets with each load.
|
|
29
|
+
let delayPassed = $state(false);
|
|
30
|
+
|
|
31
|
+
$effect(() => {
|
|
32
|
+
element = fallbackRef;
|
|
33
|
+
return () => {
|
|
34
|
+
element = null;
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
$effect(() => {
|
|
39
|
+
if (avatar.status !== 'loading' || delay <= 0) return;
|
|
40
|
+
delayPassed = false;
|
|
41
|
+
const timer = setTimeout(() => {
|
|
42
|
+
delayPassed = true;
|
|
43
|
+
}, delay);
|
|
44
|
+
return () => clearTimeout(timer);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const shown = $derived(
|
|
48
|
+
avatar.status === 'error' || (avatar.status === 'loading' && (delay <= 0 || delayPassed))
|
|
49
|
+
);
|
|
50
|
+
// `undefined` without an image: the fallback is then the content, with no name of its own.
|
|
51
|
+
const name = $derived(avatar.alt);
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
{#if shown}
|
|
55
|
+
<span
|
|
56
|
+
{...restProps}
|
|
57
|
+
bind:this={fallbackRef}
|
|
58
|
+
role={name ? 'img' : undefined}
|
|
59
|
+
aria-label={name || undefined}
|
|
60
|
+
aria-hidden={name === '' ? 'true' : undefined}
|
|
61
|
+
class={className}
|
|
62
|
+
data-avatar-fallback="true"
|
|
63
|
+
data-status={avatar.status}
|
|
64
|
+
>
|
|
65
|
+
{@render children?.()}
|
|
66
|
+
</span>
|
|
67
|
+
{/if}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { AvatarGroupProps } from '../types.js';
|
|
3
|
+
import { setAvatarGroupContext, type AvatarGroupContext } from './context';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Avatar.Group — a row of avatars, such as the people on a task.
|
|
7
|
+
*
|
|
8
|
+
* It is a `role="group"`: give it a name with `aria-label`, thus a screen reader user knows
|
|
9
|
+
* what the row is. `max` limits the avatars on the screen. The ones past it render nothing,
|
|
10
|
+
* and `Avatar.Count` says how many they are.
|
|
11
|
+
*/
|
|
12
|
+
let {
|
|
13
|
+
children,
|
|
14
|
+
class: className = '',
|
|
15
|
+
max,
|
|
16
|
+
element = $bindable<HTMLDivElement | null>(null),
|
|
17
|
+
...restProps
|
|
18
|
+
}: AvatarGroupProps = $props();
|
|
19
|
+
|
|
20
|
+
let groupRef: HTMLDivElement | null = $state(null);
|
|
21
|
+
let ids = $state<string[]>([]);
|
|
22
|
+
|
|
23
|
+
const limit = $derived(max === undefined || max < 0 ? Infinity : Math.floor(max));
|
|
24
|
+
|
|
25
|
+
const context: AvatarGroupContext = {
|
|
26
|
+
get count() {
|
|
27
|
+
return ids.length;
|
|
28
|
+
},
|
|
29
|
+
get max() {
|
|
30
|
+
return limit;
|
|
31
|
+
},
|
|
32
|
+
get overflow() {
|
|
33
|
+
return Math.max(0, ids.length - limit);
|
|
34
|
+
},
|
|
35
|
+
register(id) {
|
|
36
|
+
ids = [...ids, id];
|
|
37
|
+
return () => {
|
|
38
|
+
ids = ids.filter((candidate) => candidate !== id);
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
indexOf(id) {
|
|
42
|
+
return ids.indexOf(id);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
setAvatarGroupContext(context);
|
|
47
|
+
|
|
48
|
+
$effect(() => {
|
|
49
|
+
element = groupRef;
|
|
50
|
+
return () => {
|
|
51
|
+
element = null;
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<div
|
|
57
|
+
{...restProps}
|
|
58
|
+
bind:this={groupRef}
|
|
59
|
+
role="group"
|
|
60
|
+
class={className}
|
|
61
|
+
data-avatar-group="true"
|
|
62
|
+
data-overflow={context.overflow > 0 || undefined}
|
|
63
|
+
>
|
|
64
|
+
{@render children?.()}
|
|
65
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type AvatarGroupContext = {
|
|
2
|
+
/** The count of avatars in the group, on the screen or not. */
|
|
3
|
+
readonly count: number;
|
|
4
|
+
/** The count of avatars on the screen. `Infinity` without a limit. */
|
|
5
|
+
readonly max: number;
|
|
6
|
+
/** The count of avatars past the limit. */
|
|
7
|
+
readonly overflow: number;
|
|
8
|
+
/** Registers an avatar, and answers its place in the group. The returned function unregisters it. */
|
|
9
|
+
register: (id: string) => () => void;
|
|
10
|
+
/** The place of an avatar in the group, or -1 when it is not registered. */
|
|
11
|
+
indexOf: (id: string) => number;
|
|
12
|
+
};
|
|
13
|
+
export declare function setAvatarGroupContext(context: AvatarGroupContext): void;
|
|
14
|
+
export declare function getAvatarGroupContext(): AvatarGroupContext | undefined;
|
|
15
|
+
export declare function useAvatarGroupContext(part?: string): AvatarGroupContext;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const KEY = Symbol('avatar-group');
|
|
3
|
+
export function setAvatarGroupContext(context) {
|
|
4
|
+
setContext(KEY, context);
|
|
5
|
+
}
|
|
6
|
+
export function getAvatarGroupContext() {
|
|
7
|
+
return getContext(KEY);
|
|
8
|
+
}
|
|
9
|
+
export function useAvatarGroupContext(part = 'Avatar') {
|
|
10
|
+
const context = getAvatarGroupContext();
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error(`${part} must be used within Avatar.Group.`);
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import type { AvatarImageProps } from '../types.js';
|
|
4
|
+
import { useAvatarContext } from '../root/context';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Avatar.Image — the picture.
|
|
8
|
+
*
|
|
9
|
+
* It loads the image off the screen first, and it renders the `<img>` once the image is
|
|
10
|
+
* there: a broken image icon, or a blank box, never shows. Without a `src`, or when the
|
|
11
|
+
* image fails, the status is `error` and `Avatar.Fallback` shows in its place. With
|
|
12
|
+
* `loading="lazy"`, the load waits for the root to come into view.
|
|
13
|
+
*/
|
|
14
|
+
let {
|
|
15
|
+
src,
|
|
16
|
+
alt,
|
|
17
|
+
loading = 'eager',
|
|
18
|
+
class: className = '',
|
|
19
|
+
element = $bindable<HTMLImageElement | null>(null),
|
|
20
|
+
crossorigin,
|
|
21
|
+
referrerpolicy,
|
|
22
|
+
...restProps
|
|
23
|
+
}: AvatarImageProps = $props();
|
|
24
|
+
|
|
25
|
+
const avatar = useAvatarContext('Avatar.Image');
|
|
26
|
+
|
|
27
|
+
let imageRef: HTMLImageElement | null = $state(null);
|
|
28
|
+
|
|
29
|
+
// The fallback takes the name of the image, thus a failed image is not a nameless avatar.
|
|
30
|
+
$effect(() => {
|
|
31
|
+
const name = alt;
|
|
32
|
+
untrack(() => avatar.setAlt(name));
|
|
33
|
+
return () => avatar.setAlt(undefined);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
$effect(() => {
|
|
37
|
+
element = imageRef;
|
|
38
|
+
return () => {
|
|
39
|
+
element = null;
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// A lazy image waits for the root to come into view. Without an observer, it loads at once.
|
|
44
|
+
let inView = $state(false);
|
|
45
|
+
$effect(() => {
|
|
46
|
+
const root = avatar.element;
|
|
47
|
+
if (loading !== 'lazy' || !root || typeof IntersectionObserver === 'undefined') {
|
|
48
|
+
inView = true;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
inView = false;
|
|
52
|
+
const observer = new IntersectionObserver((entries) => {
|
|
53
|
+
if (entries.some((entry) => entry.isIntersecting)) {
|
|
54
|
+
inView = true;
|
|
55
|
+
observer.disconnect();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
observer.observe(root);
|
|
59
|
+
return () => observer.disconnect();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// The status is set in `untrack`: the setter reads the status to skip a repeat, and a read
|
|
63
|
+
// here would make the load depend on its own result.
|
|
64
|
+
$effect(() => {
|
|
65
|
+
const source = src;
|
|
66
|
+
if (!source) {
|
|
67
|
+
untrack(() => avatar.setStatus('error'));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (!inView) {
|
|
71
|
+
untrack(() => avatar.setStatus('loading'));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// The same request the `<img>` makes, thus the browser serves the `<img>` from its cache.
|
|
75
|
+
const loader = new Image();
|
|
76
|
+
if (crossorigin !== undefined && crossorigin !== null) loader.crossOrigin = crossorigin;
|
|
77
|
+
if (referrerpolicy) loader.referrerPolicy = referrerpolicy;
|
|
78
|
+
loader.onload = () => avatar.setStatus('loaded');
|
|
79
|
+
loader.onerror = () => avatar.setStatus('error');
|
|
80
|
+
loader.src = source;
|
|
81
|
+
// An image from the cache is complete at once: no `loading` frame for the fallback.
|
|
82
|
+
untrack(() => {
|
|
83
|
+
if (loader.complete && loader.naturalWidth > 0) avatar.setStatus('loaded');
|
|
84
|
+
else avatar.setStatus('loading');
|
|
85
|
+
});
|
|
86
|
+
return () => {
|
|
87
|
+
loader.onload = null;
|
|
88
|
+
loader.onerror = null;
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
{#if avatar.status === 'loaded' && src}
|
|
94
|
+
<img
|
|
95
|
+
{...restProps}
|
|
96
|
+
bind:this={imageRef}
|
|
97
|
+
{src}
|
|
98
|
+
{alt}
|
|
99
|
+
{crossorigin}
|
|
100
|
+
{referrerpolicy}
|
|
101
|
+
class={className}
|
|
102
|
+
data-avatar-image="true"
|
|
103
|
+
/>
|
|
104
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import type AvatarCountComponent from './count/avatar-count.svelte';
|
|
3
|
+
import type AvatarFallbackComponent from './fallback/avatar-fallback.svelte';
|
|
4
|
+
import type AvatarGroupComponent from './group/avatar-group.svelte';
|
|
5
|
+
import type AvatarImageComponent from './image/avatar-image.svelte';
|
|
6
|
+
import type AvatarRootComponent from './root/avatar-root.svelte';
|
|
7
|
+
export * as Avatar from './index.parts.js';
|
|
8
|
+
export { default as AvatarRoot } from './root/avatar-root.svelte';
|
|
9
|
+
export { default as AvatarImage } from './image/avatar-image.svelte';
|
|
10
|
+
export { default as AvatarFallback } from './fallback/avatar-fallback.svelte';
|
|
11
|
+
export { default as AvatarGroup } from './group/avatar-group.svelte';
|
|
12
|
+
export { default as AvatarCount } from './count/avatar-count.svelte';
|
|
13
|
+
export type AvatarRootProps = ComponentProps<typeof AvatarRootComponent>;
|
|
14
|
+
export type AvatarImageProps = ComponentProps<typeof AvatarImageComponent>;
|
|
15
|
+
export type AvatarFallbackProps = ComponentProps<typeof AvatarFallbackComponent>;
|
|
16
|
+
export type AvatarGroupProps = ComponentProps<typeof AvatarGroupComponent>;
|
|
17
|
+
export type AvatarCountProps = ComponentProps<typeof AvatarCountComponent>;
|
|
18
|
+
export type { AvatarCountState } from './types.js';
|
|
19
|
+
export { getAvatarGroupContext, setAvatarGroupContext, useAvatarGroupContext, type AvatarGroupContext } from './group/context.js';
|
|
20
|
+
export { getAvatarContext, setAvatarContext, useAvatarContext, type AvatarContext, type AvatarStatus } from './root/context.js';
|
|
21
|
+
import * as AvatarParts from './index.parts.js';
|
|
22
|
+
export default AvatarParts;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * as Avatar from './index.parts.js';
|
|
2
|
+
export { default as AvatarRoot } from './root/avatar-root.svelte';
|
|
3
|
+
export { default as AvatarImage } from './image/avatar-image.svelte';
|
|
4
|
+
export { default as AvatarFallback } from './fallback/avatar-fallback.svelte';
|
|
5
|
+
export { default as AvatarGroup } from './group/avatar-group.svelte';
|
|
6
|
+
export { default as AvatarCount } from './count/avatar-count.svelte';
|
|
7
|
+
export { getAvatarGroupContext, setAvatarGroupContext, useAvatarGroupContext } from './group/context.js';
|
|
8
|
+
export { getAvatarContext, setAvatarContext, useAvatarContext } from './root/context.js';
|
|
9
|
+
import * as AvatarParts from './index.parts.js';
|
|
10
|
+
export default AvatarParts;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Root } from './root/avatar-root.svelte';
|
|
2
|
+
export { default as Image } from './image/avatar-image.svelte';
|
|
3
|
+
export { default as Fallback } from './fallback/avatar-fallback.svelte';
|
|
4
|
+
export { default as Group } from './group/avatar-group.svelte';
|
|
5
|
+
export { default as Count } from './count/avatar-count.svelte';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Root } from './root/avatar-root.svelte';
|
|
2
|
+
export { default as Image } from './image/avatar-image.svelte';
|
|
3
|
+
export { default as Fallback } from './fallback/avatar-fallback.svelte';
|
|
4
|
+
export { default as Group } from './group/avatar-group.svelte';
|
|
5
|
+
export { default as Count } from './count/avatar-count.svelte';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { AvatarRootProps } from '../types.js';
|
|
3
|
+
import { getAvatarGroupContext } from '../group/context';
|
|
4
|
+
import { setAvatarContext, type AvatarContext, type AvatarStatus } from './context';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Avatar.Root — a picture of a person or a thing, with a fallback for when the picture is
|
|
8
|
+
* not there.
|
|
9
|
+
*
|
|
10
|
+
* It holds the status of the image and gives it to the parts: `Avatar.Image` shows once the
|
|
11
|
+
* image is on the screen, and `Avatar.Fallback` shows while it is not. The root is a plain
|
|
12
|
+
* `<span>` with no role: the name is on the image as `alt`, or on the fallback as text.
|
|
13
|
+
*
|
|
14
|
+
* In an `Avatar.Group`, it takes a place in the order, and it renders nothing past the
|
|
15
|
+
* `max` of the group: a hidden avatar loads no image.
|
|
16
|
+
*/
|
|
17
|
+
let {
|
|
18
|
+
children,
|
|
19
|
+
class: className = '',
|
|
20
|
+
element = $bindable<HTMLSpanElement | null>(null),
|
|
21
|
+
onStatusChange,
|
|
22
|
+
...restProps
|
|
23
|
+
}: AvatarRootProps = $props();
|
|
24
|
+
|
|
25
|
+
let rootRef: HTMLSpanElement | null = $state(null);
|
|
26
|
+
let status = $state<AvatarStatus>('loading');
|
|
27
|
+
let alt = $state<string | undefined>(undefined);
|
|
28
|
+
|
|
29
|
+
// Registered at creation, not in an effect: the place in the group must be known before the
|
|
30
|
+
// first render, or an avatar past the limit would paint once and go.
|
|
31
|
+
const group = getAvatarGroupContext();
|
|
32
|
+
const groupId = $props.id();
|
|
33
|
+
const unregister = group?.register(groupId);
|
|
34
|
+
$effect(() => () => unregister?.());
|
|
35
|
+
const index = $derived(group ? group.indexOf(groupId) : -1);
|
|
36
|
+
const hidden = $derived(group !== undefined && index >= group.max);
|
|
37
|
+
|
|
38
|
+
const context: AvatarContext = {
|
|
39
|
+
get status() {
|
|
40
|
+
return status;
|
|
41
|
+
},
|
|
42
|
+
setStatus(next) {
|
|
43
|
+
if (status === next) return;
|
|
44
|
+
status = next;
|
|
45
|
+
onStatusChange?.(next);
|
|
46
|
+
},
|
|
47
|
+
get alt() {
|
|
48
|
+
return alt;
|
|
49
|
+
},
|
|
50
|
+
setAlt(next) {
|
|
51
|
+
alt = next;
|
|
52
|
+
},
|
|
53
|
+
get element() {
|
|
54
|
+
return rootRef;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
setAvatarContext(context);
|
|
59
|
+
|
|
60
|
+
$effect(() => {
|
|
61
|
+
element = rootRef;
|
|
62
|
+
return () => {
|
|
63
|
+
element = null;
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
{#if !hidden}
|
|
69
|
+
<span
|
|
70
|
+
{...restProps}
|
|
71
|
+
bind:this={rootRef}
|
|
72
|
+
class={className}
|
|
73
|
+
data-avatar-root="true"
|
|
74
|
+
data-status={status}
|
|
75
|
+
data-index={index < 0 ? undefined : index}
|
|
76
|
+
>
|
|
77
|
+
{@render children?.()}
|
|
78
|
+
</span>
|
|
79
|
+
{/if}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** `loading` until the image answers, then `loaded` or `error`. `error` without a `src` too. */
|
|
2
|
+
export type AvatarStatus = 'loading' | 'loaded' | 'error';
|
|
3
|
+
export type AvatarContext = {
|
|
4
|
+
status: AvatarStatus;
|
|
5
|
+
setStatus: (status: AvatarStatus) => void;
|
|
6
|
+
/** The `alt` of the image, thus the fallback can take its name. `undefined` without an image. */
|
|
7
|
+
alt: string | undefined;
|
|
8
|
+
setAlt: (alt: string | undefined) => void;
|
|
9
|
+
/** The root element, for a lazy image that waits for it to come into view. */
|
|
10
|
+
readonly element: HTMLElement | null;
|
|
11
|
+
};
|
|
12
|
+
export declare function setAvatarContext(context: AvatarContext): void;
|
|
13
|
+
export declare function getAvatarContext(): AvatarContext | undefined;
|
|
14
|
+
export declare function useAvatarContext(part?: string): AvatarContext;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const KEY = Symbol('avatar');
|
|
3
|
+
export function setAvatarContext(context) {
|
|
4
|
+
setContext(KEY, context);
|
|
5
|
+
}
|
|
6
|
+
export function getAvatarContext() {
|
|
7
|
+
return getContext(KEY);
|
|
8
|
+
}
|
|
9
|
+
export function useAvatarContext(part = 'Avatar') {
|
|
10
|
+
const context = getAvatarContext();
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error(`${part} must be used within Avatar.Root.`);
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes, HTMLImgAttributes } from 'svelte/elements';
|
|
3
|
+
import type { AvatarStatus } from './root/context.js';
|
|
4
|
+
export type { AvatarContext, AvatarStatus } from './root/context.js';
|
|
5
|
+
export type { AvatarGroupContext } from './group/context.js';
|
|
6
|
+
export type AvatarGroupProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'role'> & {
|
|
7
|
+
/** The avatars, and an `Avatar.Count` for the ones past `max`. */
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
/** The CSS class names of the element. */
|
|
10
|
+
class?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The count of avatars on the screen. The ones past it render nothing, and `Avatar.Count`
|
|
13
|
+
* says how many they are. Without it, every avatar is on the screen.
|
|
14
|
+
*/
|
|
15
|
+
max?: number;
|
|
16
|
+
/**
|
|
17
|
+
* The name of the group, such as "Assignees". A group with no name is a group a screen
|
|
18
|
+
* reader cannot tell apart from the content around it.
|
|
19
|
+
*/
|
|
20
|
+
'aria-label'?: string;
|
|
21
|
+
/** The group element. Use `bind:element` to read it. */
|
|
22
|
+
element?: HTMLDivElement | null;
|
|
23
|
+
};
|
|
24
|
+
export type AvatarCountState = {
|
|
25
|
+
/** The count of avatars past `max`. */
|
|
26
|
+
overflow: number;
|
|
27
|
+
/** The count of avatars in the group. */
|
|
28
|
+
count: number;
|
|
29
|
+
/** The limit of the group. */
|
|
30
|
+
max: number;
|
|
31
|
+
};
|
|
32
|
+
export type AvatarCountProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class' | 'aria-label'> & {
|
|
33
|
+
/** The content in place of `+N`. It gets the overflow, the count and the limit. */
|
|
34
|
+
children?: Snippet<[AvatarCountState]>;
|
|
35
|
+
/** The CSS class names of the element. */
|
|
36
|
+
class?: string;
|
|
37
|
+
/** The name for the screen reader. Without it, "N more" in the locale of `LocaleProvider`. */
|
|
38
|
+
'aria-label'?: string;
|
|
39
|
+
/** The count element, while it is on the screen. Use `bind:element` to read it. */
|
|
40
|
+
element?: HTMLSpanElement | null;
|
|
41
|
+
};
|
|
42
|
+
export type AvatarRootProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
|
|
43
|
+
/** `Avatar.Image` and `Avatar.Fallback`. */
|
|
44
|
+
children?: Snippet;
|
|
45
|
+
/** The CSS class names of the element. */
|
|
46
|
+
class?: string;
|
|
47
|
+
/** The root element. Use `bind:element` to read it. */
|
|
48
|
+
element?: HTMLSpanElement | null;
|
|
49
|
+
/** Called when the image starts to load, loads, or fails. */
|
|
50
|
+
onStatusChange?: (status: AvatarStatus) => void;
|
|
51
|
+
};
|
|
52
|
+
export type AvatarImageProps = Omit<HTMLImgAttributes, 'class' | 'src' | 'alt' | 'loading'> & {
|
|
53
|
+
/** The address of the image. Without it, the fallback shows. */
|
|
54
|
+
src?: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* `lazy` starts the load when the avatar comes into view, and not on mount. Use it on a long
|
|
57
|
+
* list of avatars, thus the ones below the fold do not all load at once.
|
|
58
|
+
*/
|
|
59
|
+
loading?: 'eager' | 'lazy';
|
|
60
|
+
/**
|
|
61
|
+
* The text in place of the image. Give the name of the person or the thing. Give an empty
|
|
62
|
+
* string when the name is beside the avatar already, thus a screen reader does not read it
|
|
63
|
+
* twice.
|
|
64
|
+
*/
|
|
65
|
+
alt: string;
|
|
66
|
+
/** The CSS class names of the element. */
|
|
67
|
+
class?: string;
|
|
68
|
+
/** The image element, once the image is on the screen. Use `bind:element` to read it. */
|
|
69
|
+
element?: HTMLImageElement | null;
|
|
70
|
+
};
|
|
71
|
+
export type AvatarFallbackProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
|
|
72
|
+
/** The content in place of the image, such as initials or an icon. */
|
|
73
|
+
children?: Snippet;
|
|
74
|
+
/** The CSS class names of the element. */
|
|
75
|
+
class?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The time in milliseconds before the fallback shows while the image loads. A fallback that
|
|
78
|
+
* flashes before a fast image is noise: 300 or 600 hides it on a good connection. It shows at
|
|
79
|
+
* once when the image fails, or when there is no image.
|
|
80
|
+
*/
|
|
81
|
+
delay?: number;
|
|
82
|
+
/** The fallback element, while it is on the screen. Use `bind:element` to read it. */
|
|
83
|
+
element?: HTMLSpanElement | null;
|
|
84
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|