@human-kit/ui 1.0.0-beta.5 → 1.0.0-beta.7
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 +19 -17
- 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 +2 -2
- 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/button/README.md +1 -1
- package/dist/button/root/button-root.svelte +24 -10
- package/dist/button/root/button-root.svelte.d.ts +15 -10
- 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 +11 -8
- package/dist/combobox/popover/README.md +1 -1
- 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 +36 -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 +25 -23
- 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 +4 -0
- package/dist/index.js +4 -0
- package/dist/input/input.svelte +6 -6
- package/dist/input/input.svelte.d.ts +6 -6
- package/dist/listbox/README.md +3 -10
- package/dist/listbox/item/listbox-item.svelte +24 -15
- 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 +1 -1
- package/dist/listbox/root/listbox.svelte +50 -38
- package/dist/listbox/root/listbox.svelte.d.ts +50 -38
- package/dist/locale-provider/README.md +1 -6
- package/dist/menu/README.md +6 -15
- package/dist/menu/content/menu-content.svelte +14 -10
- package/dist/menu/content/menu-content.svelte.d.ts +14 -10
- package/dist/menu/context-trigger/menu-context-trigger.svelte +8 -9
- package/dist/menu/context-trigger/menu-context-trigger.svelte.d.ts +8 -9
- 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/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 +6 -3
- 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/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/scrub-area-cursor/README.md +1 -1
- package/dist/popover/README.md +1 -1
- package/dist/popover/content/popover-content.svelte +19 -14
- 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/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/floating.d.ts +3 -3
- 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 +1 -0
- package/dist/primitives/index.js +1 -0
- package/dist/primitives/input-modality.d.ts +7 -0
- package/dist/primitives/input-modality.js +32 -5
- package/dist/primitives/scroll-lock.js +37 -8
- 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/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 +15 -10
- 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/root/README.md +1 -1
- package/dist/table/root/table-root.svelte +29 -6
- package/dist/table/sort-trigger/README.md +1 -1
- package/dist/table/types.d.ts +21 -20
- 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/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 +8 -10
- 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/types.d.ts +7 -6
- package/dist/transfer-list/README.md +6 -17
- package/dist/transfer-list/item/transfer-list-item.svelte +4 -4
- package/dist/transfer-list/item/transfer-list-item.svelte.d.ts +4 -4
- package/dist/transfer-list/list/transfer-list-list.svelte +12 -12
- package/dist/transfer-list/list/transfer-list-list.svelte.d.ts +12 -12
- package/dist/transfer-list/move/transfer-list-move-button.svelte +4 -4
- package/dist/transfer-list/move/transfer-list-move-button.svelte.d.ts +4 -4
- package/dist/transfer-list/move/transfer-list-reorder-button.svelte +3 -3
- package/dist/transfer-list/move/transfer-list-reorder-button.svelte.d.ts +3 -3
- package/dist/transfer-list/root/transfer-list-root.svelte +23 -20
- package/dist/transfer-list/root/transfer-list-root.svelte.d.ts +23 -20
- package/dist/transfer-list/status/transfer-list-status.svelte +1 -1
- package/dist/transfer-list/status/transfer-list-status.svelte.d.ts +1 -1
- 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 +11 -1
|
@@ -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 {};
|
package/dist/clock/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
`Clock`
|
|
5
|
+
`Clock` is a time picker with wheels. Each wheel is a spinbutton column for the hour, the minute, the second, or the day period. Use it alone, or put it in a `TimePicker` with `TimePicker.Clock`.
|
|
6
6
|
|
|
7
7
|
## Anatomy
|
|
8
8
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
</Clock.Root>
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
If you give no `column` snippet, the component makes the default columns:
|
|
28
28
|
|
|
29
29
|
```svelte
|
|
30
30
|
<Clock.Root value="09:00" granularity="minute" hourCycle={24} />
|
|
@@ -69,7 +69,7 @@ Visible columns are resolved automatically in stable order: `hour → minute?
|
|
|
69
69
|
|
|
70
70
|
## Notes
|
|
71
71
|
|
|
72
|
-
- `Clock.WheelColumn` needs an explicit height (it is an `overflow-y: auto` scroll container). Without a height class it
|
|
72
|
+
- `Clock.WheelColumn` needs an explicit height (it is an `overflow-y: auto` scroll container). Without a height class, it uses the Tailwind utility `h-55` (`13.75rem`). That class works only in a Tailwind project. Without Tailwind, set the height yourself. Read the WheelColumn README.
|
|
73
73
|
- Locale is read from `LocaleProvider` when available.
|
|
74
74
|
- Internally, values are normalized to 24-hour representation; 12-hour rendering only affects UI segments.
|
|
75
75
|
- `granularity='hour'` emits `HH:00` values.
|
|
@@ -17,7 +17,7 @@ Description: Visual overlay band for `Clock.Root`; it is presentational (`aria-h
|
|
|
17
17
|
### Context utilities
|
|
18
18
|
|
|
19
19
|
Name: `useClockContext`
|
|
20
|
-
Description:
|
|
20
|
+
Description: Makes sure that `Clock.Axis` is in a `Clock.Root`.
|
|
21
21
|
|
|
22
22
|
| Prop | Type | Default | Description |
|
|
23
23
|
| ----------------- | -------------------- | ------- | ------------------------------------------------ |
|
|
@@ -22,7 +22,7 @@ Description: Standalone wheel-based time state container that resolves visible c
|
|
|
22
22
|
| `disabled` | `boolean` | `false` | Disables wheel interaction and value updates. |
|
|
23
23
|
| `column` | `Snippet<[ClockColumnInfo]>` | `undefined` | Optional custom renderer for each resolved column. |
|
|
24
24
|
| `children` | `Snippet` | `undefined` | Optional additional content rendered inside the root. |
|
|
25
|
-
| `class` | `string` | `''` | CSS class names
|
|
25
|
+
| `class` | `string` | `''` | The CSS class names of the root element. |
|
|
26
26
|
| `element` | `HTMLDivElement \| null` | `bindable` | Reference to the root DOM element. |
|
|
27
27
|
| `aria-label` | `string` | `undefined` | Accessible label for the root group. |
|
|
28
28
|
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
| 'onclick'
|
|
32
32
|
> & {
|
|
33
33
|
type: ClockEditableSegmentType;
|
|
34
|
-
/**
|
|
34
|
+
/** It receives the option, and a boolean that is true for the selected value of the column. */
|
|
35
35
|
children?: Snippet<[TimePickerWheelOption, boolean]>;
|
|
36
36
|
class?: string;
|
|
37
37
|
'aria-label'?: string;
|
|
@@ -8,7 +8,7 @@ type TimePickerWheelOption = {
|
|
|
8
8
|
};
|
|
9
9
|
type TimePickerWheelColumnProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'role' | 'tabindex' | 'aria-label' | 'onkeydown' | 'onfocusin' | 'onfocusout' | 'onmousedown' | 'onclick'> & {
|
|
10
10
|
type: ClockEditableSegmentType;
|
|
11
|
-
/**
|
|
11
|
+
/** It receives the option, and a boolean that is true for the selected value of the column. */
|
|
12
12
|
children?: Snippet<[TimePickerWheelOption, boolean]>;
|
|
13
13
|
class?: string;
|
|
14
14
|
'aria-label'?: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
`Collapsible` is a headless
|
|
5
|
+
`Collapsible` is a headless disclosure component: a button that shows and hides one panel. You can control the open state, or the component can control it. It also has a disabled state.
|
|
6
6
|
|
|
7
7
|
## Anatomy
|
|
8
8
|
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
## Usage Guidelines
|
|
21
21
|
|
|
22
22
|
- Use `open` / `onOpenChange` for controlled state and `defaultOpen` for uncontrolled state.
|
|
23
|
-
- Use `disabled` to
|
|
23
|
+
- Use `disabled` to stop the trigger. It cannot open or close the panel.
|
|
24
24
|
- Use `forceMount` on `Collapsible.Panel` when collapsed content must stay in the DOM.
|
|
25
25
|
- For grouped disclosures where only one section opens at a time, use `Accordion` instead.
|
|
26
26
|
|
|
@@ -28,4 +28,4 @@
|
|
|
28
28
|
|
|
29
29
|
- `Collapsible.Trigger` renders button semantics with `aria-expanded` and `aria-controls` pointing at the panel, following the WAI-ARIA disclosure pattern.
|
|
30
30
|
- `Collapsible.Panel` is `hidden` + `inert` while collapsed and carries the `id` referenced by the trigger.
|
|
31
|
-
- Enter
|
|
31
|
+
- The `Enter` key and the `Space` key open and close the panel, like a native button.
|