@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
|
@@ -1,42 +1,47 @@
|
|
|
1
1
|
import { type Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
type SwitchRootProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class' | 'id' | 'role' | 'aria-checked' | 'aria-disabled' | 'aria-readonly' | 'aria-required' | 'onclick' | 'onkeydown' | 'value'> & {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* The id of the hidden input, thus a `label[for]` element can point at the switch. If you give
|
|
6
|
+
* none, the component makes one.
|
|
7
|
+
*/
|
|
5
8
|
id?: string;
|
|
6
|
-
/**
|
|
9
|
+
/** A bindable reference to the root element. */
|
|
7
10
|
element?: HTMLSpanElement | null;
|
|
8
|
-
/**
|
|
11
|
+
/** The name that the form submits while the switch is on. */
|
|
9
12
|
name?: string;
|
|
10
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* The value that the form submits while the switch is on. It does not change the visual state.
|
|
15
|
+
*/
|
|
11
16
|
value?: string;
|
|
12
|
-
/**
|
|
17
|
+
/** The id of the form of the hidden input. */
|
|
13
18
|
form?: string;
|
|
14
|
-
/**
|
|
19
|
+
/** The checked state. By default it goes in the two directions: use `bind:checked`. */
|
|
15
20
|
checked?: boolean;
|
|
16
|
-
/**
|
|
21
|
+
/** The checked state at the start, for when you give no `checked`. */
|
|
17
22
|
defaultChecked?: boolean;
|
|
18
23
|
/**
|
|
19
|
-
*
|
|
20
|
-
* and
|
|
21
|
-
* not
|
|
22
|
-
*
|
|
24
|
+
* Give your own code full control of the state. The component stops to write back to `checked`,
|
|
25
|
+
* and it reports only through `onCheckedChange`. Thus the parent can refuse a change: the parent
|
|
26
|
+
* does not send the new value down. The default is off, because `bind:checked` is the usual case
|
|
27
|
+
* and it needs the write-back.
|
|
23
28
|
*/
|
|
24
29
|
controlledChecked?: boolean;
|
|
25
|
-
/**
|
|
30
|
+
/** The component calls it when the user changes the switch. */
|
|
26
31
|
onCheckedChange?: (checked: boolean) => void;
|
|
27
|
-
/**
|
|
32
|
+
/** Stops the interaction with the switch and removes it from the focus order. */
|
|
28
33
|
disabled?: boolean;
|
|
29
|
-
/** Keeps the switch focusable
|
|
34
|
+
/** Keeps the switch focusable, but stops the changes of the state. */
|
|
30
35
|
readonly?: boolean;
|
|
31
|
-
/**
|
|
36
|
+
/** Makes the hidden input required for the form validation. */
|
|
32
37
|
required?: boolean;
|
|
33
38
|
children?: Snippet;
|
|
34
39
|
class?: string;
|
|
35
|
-
/**
|
|
40
|
+
/** The accessible name, for when the user sees no name. */
|
|
36
41
|
'aria-label'?: string;
|
|
37
|
-
/**
|
|
42
|
+
/** The id of the element that gives the switch its name. */
|
|
38
43
|
'aria-labelledby'?: string;
|
|
39
|
-
/**
|
|
44
|
+
/** Replaces the default position in the tab order. */
|
|
40
45
|
tabindex?: number;
|
|
41
46
|
onclick?: HTMLAttributes<HTMLSpanElement>['onclick'];
|
|
42
47
|
onkeydown?: HTMLAttributes<HTMLSpanElement>['onkeydown'];
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { useSwitchContext } from '../root/context';
|
|
5
5
|
|
|
6
6
|
type SwitchThumbProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
|
|
7
|
-
/**
|
|
7
|
+
/** The content of the thumb. */
|
|
8
8
|
children?: Snippet;
|
|
9
9
|
class?: string;
|
|
10
10
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
type SwitchThumbProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
|
|
4
|
-
/**
|
|
4
|
+
/** The content of the thumb. */
|
|
5
5
|
children?: Snippet;
|
|
6
6
|
class?: string;
|
|
7
7
|
};
|
package/dist/table/README.md
CHANGED
|
@@ -6,7 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
`Table` is a headless interactive table primitive with grid-style keyboard navigation, row selection, explicit sortable header triggers, and a composable part-based API.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The table barrel exports the prop types of each public Table part.
|
|
10
|
+
|
|
11
|
+
These are `TableRootProps`, `TableColumnProps`, `TableHeaderProps`, `TableBodyProps`,
|
|
12
|
+
`TableFooterProps`, `TableRowProps`, `TableColumnHeaderCellProps`, `TableSortTriggerProps`,
|
|
13
|
+
`TableColumnResizerProps`, `TableCellProps`, `TableEmptyStateProps`, `TableCheckboxProps`,
|
|
14
|
+
and `TableCheckboxIndicatorProps`.
|
|
10
15
|
|
|
11
16
|
## Anatomy
|
|
12
17
|
|
|
@@ -88,8 +93,8 @@ All public Table part prop types are exported from the table barrel, including `
|
|
|
88
93
|
## Usage guidelines
|
|
89
94
|
|
|
90
95
|
- Use `Table.Root` as the stateful container for focus, selection, and sorting state.
|
|
91
|
-
- Use `keyboardNavigation` to choose how far the roving tab stop reaches into the body: `'grid'` (default) makes every body cell a focus target, `'row'` makes the row the only one, and `'none'` leaves the body inert.
|
|
92
|
-
- Use `selectionBehavior="toggle"` to
|
|
96
|
+
- Use `keyboardNavigation` to choose how far the roving tab stop reaches into the body: `'grid'` (default) makes every body cell a focus target, `'row'` makes the row the only one, and `'none'` leaves the body inert. The cell navigation has a cost: one focus registration and one focus state for each cell. A virtualized table does this again for each row that it makes. Use `'row'` when the body is a list, and not a surface where the user works. Use `'none'` only when nothing in the body does an action. The header keeps its own navigation in every mode.
|
|
97
|
+
- Use `selectionBehavior="toggle"` to let the user remove the selection of a selected row. Use `selectionBehavior="replace"` to keep a selected row selected when the user presses it again.
|
|
93
98
|
- `Table.Column` is a logical-only wrapper for column metadata; it does not render DOM by itself and should wrap a single `Table.ColumnHeaderCell`.
|
|
94
99
|
- Wrap each header cell in `Table.Column` so the table can register stable column metadata.
|
|
95
100
|
- Add `Table.ColumnResizer` inside `Table.ColumnHeaderCell` to make the owning `Table.Column` resizable.
|
|
@@ -102,16 +107,16 @@ All public Table part prop types are exported from the table barrel, including `
|
|
|
102
107
|
- Use `defaultHiddenColumns` for uncontrolled initial column visibility.
|
|
103
108
|
- Use `columnWidths` / `onColumnWidthsChange` for controlled column width state. Width specs can be px, `%`, or `fr`.
|
|
104
109
|
- Use `defaultColumnWidths` and `Table.Column.defaultWidth` to seed uncontrolled initial widths that can still be resized by the user.
|
|
105
|
-
- Use `Table.Column.width` when a column
|
|
106
|
-
- In resizable tables, unspecified columns behave like an implicit `1fr` width before interaction.
|
|
110
|
+
- Use `Table.Column.width` when a column must keep an exact width. A column with a fixed width does not change its width, also with a `Table.ColumnResizer` in it.
|
|
111
|
+
- In resizable tables, unspecified columns behave like an implicit `1fr` width before interaction. At the first width change, the component sets each visible column in px. The last column takes the difference, down to its minimum width. After that, the table becomes wider than its container.
|
|
107
112
|
- Setting `sortDescriptor` back to `undefined` clears the controlled sort state, matching React Aria Table semantics.
|
|
108
113
|
- Set `Table.Column.textValue` when the spoken column label should differ from the column id; `Table.Root` uses it for polite sort announcements.
|
|
109
114
|
- Use `Table.EmptyState` inside `Table.Body` instead of conditionally rendering freeform body content.
|
|
110
115
|
- Use `Table.Checkbox` when you need explicit selection UI inside cells instead of relying only on row or cell presses.
|
|
111
|
-
- Use `Table.CheckboxIndicator` to
|
|
112
|
-
- Use `Table.InteractiveCell` for body
|
|
116
|
+
- Use `Table.CheckboxIndicator` to make your own marks for the checked state and the indeterminate state.
|
|
117
|
+
- Use `Table.InteractiveCell` for a body cell that has its own controls. While the focus is on the cell, the grid keyboard operation is the same as in `Table.Cell`. While the focus is on a control in the cell, that control gets the keys and the pointer.
|
|
113
118
|
- `Table.Checkbox` auto-hides in header cells unless `selectionMode="multiple"`, and auto-hides everywhere when `selectionMode="none"`.
|
|
114
|
-
-
|
|
119
|
+
- A hidden column is not in the grid navigation, not in the column count, and not in the width changes. It keeps its width, thus you can show it again with that width.
|
|
115
120
|
- Dedicated utility columns like selection checkboxes should usually set an explicit `width`, `minWidth`, and `maxWidth` on `Table.Column` so sibling resizes do not redistribute their space.
|
|
116
121
|
- When `selectionMode` changes to `none`, the component clears any existing row selection internally.
|
|
117
122
|
- v1 leaves text selection and `Ctrl+C` behavior browser-native; the table does not implement custom copy handling or force a text-selection policy.
|
|
@@ -134,10 +139,10 @@ All public Table part prop types are exported from the table barrel, including `
|
|
|
134
139
|
- `Table.Root` renders an interactive `grid` over native table markup.
|
|
135
140
|
- Keyboard navigation uses roving `tabindex` across header and body cells.
|
|
136
141
|
- Under `keyboardNavigation="row"` the body's roving tab stop sits on the rows: arrows walk rows, `Enter` presses one and `Space` toggles its selection. Focusable content inside body cells becomes a regular tab stop instead, since no roving focus reaches it there.
|
|
137
|
-
-
|
|
142
|
+
- A body row can also take the focus when the horizontal navigation goes past the start or the end of the row. If the user continues to push the left key or the right key, the focus goes to the cell at the opposite edge.
|
|
138
143
|
- `Table.Checkbox` can receive DOM focus directly while still participating in the table's roving-focus grid.
|
|
139
144
|
- First-column body cells become `rowheader` when their associated column has `rowHeader`.
|
|
140
145
|
- Disabled rows remain rendered and non-selectable, but are skipped by focus navigation.
|
|
141
146
|
- `Table.SortTrigger` renders the trigger button, while the header cell remains the roving-focus target for arrow-key grid navigation.
|
|
142
147
|
- Sort changes are mirrored into a polite live region so screen readers announce direction changes more reliably than `aria-sort` alone.
|
|
143
|
-
- Column resize handles are keyboard accessible separators.
|
|
148
|
+
- Column resize handles are keyboard accessible separators. Push `Enter` to start the resize mode. Use the horizontal arrow keys to change the width. Push `Home` for the minimum width, and `End` for the width of the content. Push `Enter` again to leave the resize mode. The focus stays on the handle.
|
|
@@ -13,7 +13,7 @@ Public prop type: `TableCheckboxIndicatorProps`
|
|
|
13
13
|
| -------------- | --------------------------------- | ----------- | ------------------------------------------------------------------------------- |
|
|
14
14
|
| `forceMount` | `boolean` | `false` | Keeps the indicator mounted while hidden when the checkbox is unchecked. |
|
|
15
15
|
| `children` | `Snippet` | `undefined` | Rendered indicator content, such as a check icon or dash icon. |
|
|
16
|
-
| `class` | `string` | `''` | CSS class names
|
|
16
|
+
| `class` | `string` | `''` | The CSS class names of the indicator container. |
|
|
17
17
|
| `...restProps` | `HTMLAttributes<HTMLSpanElement>` | `-` | Additional native attributes forwarded to the composed checkbox indicator span. |
|
|
18
18
|
|
|
19
19
|
## Usage notes
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
shouldShowFocusVisible,
|
|
12
12
|
trackInteractionModality
|
|
13
13
|
} from '../../primitives/input-modality';
|
|
14
|
+
|
|
15
|
+
import { watchFocusVisible } from '../../primitives/focus-visible.svelte';
|
|
14
16
|
import { isRtl } from '../../internal/rtl';
|
|
15
17
|
|
|
16
18
|
let { children, class: className = '', ...restProps }: TableColumnHeaderCellProps = $props();
|
|
@@ -174,6 +176,28 @@
|
|
|
174
176
|
isFocusVisibleWithin = false;
|
|
175
177
|
}
|
|
176
178
|
|
|
179
|
+
function getFocusedDescendant() {
|
|
180
|
+
if (!element) return null;
|
|
181
|
+
const active = element.ownerDocument.activeElement;
|
|
182
|
+
if (!(active instanceof HTMLElement) || active === element) return null;
|
|
183
|
+
return element.contains(active) ? active : null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
watchFocusVisible({
|
|
187
|
+
isFocused: () => isElementFocused,
|
|
188
|
+
element: () => element ?? null,
|
|
189
|
+
set: (visible) => {
|
|
190
|
+
isElementFocusVisible = visible;
|
|
191
|
+
table.setFocusVisible(visible);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
watchFocusVisible({
|
|
196
|
+
isFocused: () => isFocusWithin,
|
|
197
|
+
element: getFocusedDescendant,
|
|
198
|
+
set: (visible) => (isFocusVisibleWithin = visible)
|
|
199
|
+
});
|
|
200
|
+
|
|
177
201
|
function handleClick() {
|
|
178
202
|
// A drag-resize that just ended emits a residual click on the header;
|
|
179
203
|
// consume the one-shot suppression flag BEFORE focusing the cell.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
### Table.ColumnResizer
|
|
8
8
|
|
|
9
9
|
Name: `Table.ColumnResizer`
|
|
10
|
-
Description:
|
|
10
|
+
Description: The handle that changes the width of the current `Table.Column`. Put it in a `Table.ColumnHeaderCell`. It changes the width of the column of the `Table.Column` context around it.
|
|
11
11
|
|
|
12
12
|
Public prop type: `TableColumnResizerProps`
|
|
13
13
|
|
|
@@ -25,7 +25,7 @@ Public prop type: `TableColumnResizerProps`
|
|
|
25
25
|
- The handle resolves the active column from `Table.Column` context. It does not accept a separate `columnId` prop.
|
|
26
26
|
- Width state lives in `Table.Root` through `columnWidths` / `defaultColumnWidths`.
|
|
27
27
|
- Pointer resizing uses Pointer Events, so mouse, touch, and pen interactions share the same behavior.
|
|
28
|
-
-
|
|
28
|
+
- The keyboard changes the width in a resize mode. Move the focus to the handle and push `Enter` to start that mode. Use the `ArrowLeft` key and the `ArrowRight` key, with `Shift` for a larger step, to change the width. Push `Home` for the minimum width, and `End` for the width of the content. Push `Enter` again to keep the width. The focus stays on the handle.
|
|
29
29
|
- While keyboard resize mode is active, pressing `Escape` restores the starting width, exits resize mode, and returns focus to the owning header cell.
|
|
30
30
|
- Keyboard resizing uses the same resize lifecycle callbacks as pointer resizing and announces committed widths through a polite live region.
|
|
31
31
|
- During pointer drag, pressing `Escape` restores the starting width and cancels the resize interaction.
|
|
@@ -37,7 +37,7 @@ Public prop type: `TableRootProps`
|
|
|
37
37
|
| `aria-labelledby` | `string` | `undefined` | Id reference for an external label. |
|
|
38
38
|
| `class` | `string` | `''` | Class names for the root table element. |
|
|
39
39
|
| `context` | `TableContext` | `undefined` | Bindable reference to the active internal table context instance. |
|
|
40
|
-
| `element` | `HTMLTableElement` | `undefined` |
|
|
40
|
+
| `element` | `HTMLTableElement` | `undefined` | A bindable reference to the table element. |
|
|
41
41
|
| `children` | `Snippet` | `undefined` | Composed table parts. |
|
|
42
42
|
|
|
43
43
|
### Behavior notes
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
shouldShowFocusVisible,
|
|
22
22
|
trackInteractionModality
|
|
23
23
|
} from '../../primitives/input-modality';
|
|
24
|
+
import { watchFocusVisible } from '../../primitives/focus-visible.svelte';
|
|
24
25
|
import { visuallyHiddenStyle } from '../utils/visually-hidden-style';
|
|
25
26
|
import type { TableRootProps } from '../types.js';
|
|
26
27
|
import {
|
|
@@ -499,30 +500,52 @@
|
|
|
499
500
|
focusWithin =
|
|
500
501
|
!!tableElement && !!document.activeElement && tableElement.contains(document.activeElement);
|
|
501
502
|
if (!focusWithin) {
|
|
502
|
-
|
|
503
|
+
setFocusVisible(false);
|
|
503
504
|
ctx.setFocusedCell(null);
|
|
504
505
|
}
|
|
505
506
|
}
|
|
506
507
|
|
|
507
508
|
function handleFocusIn(event: FocusEvent) {
|
|
508
509
|
focusWithin = true;
|
|
509
|
-
|
|
510
|
+
setFocusVisible(shouldShowFocusVisible(event.target as HTMLElement | null));
|
|
510
511
|
}
|
|
511
512
|
|
|
513
|
+
// Every part of the table reads one focus-visible value, and each writes it from its own
|
|
514
|
+
// focus handler. One watch on the focused descendant therefore serves them all: a key press
|
|
515
|
+
// that follows a pointer press brings the ring back on the cell, the row and the checkbox
|
|
516
|
+
// at once.
|
|
517
|
+
function getFocusedDescendant() {
|
|
518
|
+
if (!tableElement) return null;
|
|
519
|
+
const active = tableElement.ownerDocument.activeElement;
|
|
520
|
+
if (!(active instanceof HTMLElement)) return null;
|
|
521
|
+
return tableElement.contains(active) ? active : null;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function setFocusVisible(visible: boolean) {
|
|
525
|
+
focusVisible = visible;
|
|
526
|
+
ctx.setFocusVisible(visible);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
watchFocusVisible({
|
|
530
|
+
isFocused: () => focusWithin,
|
|
531
|
+
element: getFocusedDescendant,
|
|
532
|
+
set: setFocusVisible
|
|
533
|
+
});
|
|
534
|
+
|
|
512
535
|
function handleFocusOut() {
|
|
513
536
|
queueMicrotask(syncFocusWithin);
|
|
514
537
|
}
|
|
515
538
|
|
|
516
539
|
function handleMouseDown(event: MouseEvent) {
|
|
517
540
|
trackInteractionModality(event, event.target as HTMLElement | null);
|
|
518
|
-
|
|
541
|
+
setFocusVisible(false);
|
|
519
542
|
}
|
|
520
543
|
|
|
544
|
+
// No focus-visible write here: `trackInteractionModality` reports the key to the modality,
|
|
545
|
+
// and the watch above answers. A key that carries a modifier is not a modality change, and
|
|
546
|
+
// must leave the ring as the pointer left it.
|
|
521
547
|
function handleKeyDown(event: KeyboardEvent) {
|
|
522
548
|
trackInteractionModality(event, event.target as HTMLElement | null);
|
|
523
|
-
if (focusWithin) {
|
|
524
|
-
focusVisible = true;
|
|
525
|
-
}
|
|
526
549
|
}
|
|
527
550
|
</script>
|
|
528
551
|
|
|
@@ -13,7 +13,7 @@ Public prop type: `TableSortTriggerProps`
|
|
|
13
13
|
|
|
14
14
|
| Prop | Type | Default | Description |
|
|
15
15
|
| -------------- | --------------------------------------------------- | ----------- | --------------------------------------------------------------------------------- |
|
|
16
|
-
| `children` | `Snippet<[TableSortTriggerRenderState]> \| Snippet` | `undefined` |
|
|
16
|
+
| `children` | `Snippet<[TableSortTriggerRenderState]> \| Snippet` | `undefined` | The content of the button. The snippet receives the current `sortDirection`. |
|
|
17
17
|
| `class` | `string` | `''` | CSS class names for the button. |
|
|
18
18
|
| `...restProps` | `HTMLButtonAttributes` | `-` | Additional native button attributes, excluding reserved trigger button semantics. |
|
|
19
19
|
|
package/dist/table/types.d.ts
CHANGED
|
@@ -11,10 +11,10 @@ export type TableColumnProps = {
|
|
|
11
11
|
minWidth?: number;
|
|
12
12
|
maxWidth?: number;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* the
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* Keeps the column at an edge of the horizontal scroll: `'left'` at the start, and `'right'` at
|
|
15
|
+
* the end. More than one column can go to the same side. They go in the sequence of the document.
|
|
16
|
+
* The table calculates the position of each one from the widths of the columns already at that
|
|
17
|
+
* side.
|
|
18
18
|
*/
|
|
19
19
|
pin?: TableColumnPin;
|
|
20
20
|
children?: Snippet;
|
|
@@ -90,14 +90,16 @@ export type TableFooterProps = Omit<HTMLAttributes<HTMLTableSectionElement>, 'ch
|
|
|
90
90
|
export type TableRootProps = Omit<HTMLAttributes<HTMLTableElement>, 'children'> & {
|
|
91
91
|
selectionMode?: TableSelectionMode;
|
|
92
92
|
/**
|
|
93
|
-
* How far the roving tab stop
|
|
93
|
+
* How far the roving tab stop goes into the body. The default is `'grid'`.
|
|
94
94
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
95
|
+
* The cell navigation has a cost. Each body cell registers itself and calculates its own focus
|
|
96
|
+
* state. A virtualized table does this again for each block of rows that it makes while the user
|
|
97
|
+
* scrolls.
|
|
98
|
+
*
|
|
99
|
+
* With `'row'`, the keyboard still reaches the body, at one focus target for each row. With
|
|
100
|
+
* `'none'`, the body takes no focus. Use `'none'` only when nothing in the body does an action.
|
|
101
|
+
* In each mode, the header keeps its own navigation, and with it the sort control and the width
|
|
102
|
+
* control.
|
|
101
103
|
*/
|
|
102
104
|
keyboardNavigation?: TableKeyboardNavigation;
|
|
103
105
|
selectionBehavior?: TableSelectionBehavior;
|
|
@@ -112,16 +114,15 @@ export type TableRootProps = Omit<HTMLAttributes<HTMLTableElement>, 'children'>
|
|
|
112
114
|
columnWidths?: Map<string, TableColumnWidth>;
|
|
113
115
|
defaultColumnWidths?: Iterable<readonly [string, TableColumnWidth]>;
|
|
114
116
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
+
* The width that the table keeps with `min-width` on the server, in px, before the columns
|
|
118
|
+
* register their own widths.
|
|
119
|
+
*
|
|
120
|
+
* On the server, the `<table>` element goes to the output before the column children register.
|
|
121
|
+
* Thus the table does not know its own minimum width, and it takes the width of its container. At
|
|
122
|
+
* the hydration, the column widths can make the table wider, and the layout moves.
|
|
117
123
|
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* minimum width yet and renders at the container width. On hydration the
|
|
121
|
-
* resolved column widths can push the table wider, producing a layout
|
|
122
|
-
* shift. Set this to the sum of the columns' resolved widths to reserve
|
|
123
|
-
* that space up-front and avoid the jump. Ignored once the real columns
|
|
124
|
-
* register on the client.
|
|
124
|
+
* Set this prop to the sum of the column widths to keep that space from the start. On the client,
|
|
125
|
+
* the component ignores it after the columns register.
|
|
125
126
|
*/
|
|
126
127
|
ssrMinTableWidth?: number;
|
|
127
128
|
disabledKeys?: Iterable<TableSelectionKey>;
|
package/dist/tabs/types.d.ts
CHANGED
|
@@ -6,15 +6,15 @@ export type TabsRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'c
|
|
|
6
6
|
keyboardActivation?: TabsKeyboardActivation;
|
|
7
7
|
orientation?: TabsOrientation;
|
|
8
8
|
disabled?: boolean;
|
|
9
|
-
/**
|
|
9
|
+
/** The value of the selected tab. By default it goes in the two directions: use `bind:value`. */
|
|
10
10
|
value?: TabsValue | null;
|
|
11
|
-
/**
|
|
11
|
+
/** The selected value at the start, for when you give no `value`. */
|
|
12
12
|
defaultValue?: TabsValue | null;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* the new value
|
|
17
|
-
* needs the write-back
|
|
14
|
+
* Give your own code full control of the state. The component stops to write back to `value`, and
|
|
15
|
+
* it reports only through `onChange`. Thus the parent can refuse a change: the parent does not
|
|
16
|
+
* send the new value down. The default is off, because `bind:value` is the usual case and it
|
|
17
|
+
* needs the write-back.
|
|
18
18
|
*/
|
|
19
19
|
controlledValue?: boolean;
|
|
20
20
|
disabledKeys?: Iterable<TabsValue>;
|
|
@@ -63,7 +63,8 @@
|
|
|
63
63
|
- `defaultOpen?: boolean`
|
|
64
64
|
- `onOpenChange?: (open: boolean, details: { reason, event?, cancel(), isCanceled }) => void`
|
|
65
65
|
- Null-first empty contract: when `value` and `defaultValue` are omitted, the empty state is `null`.
|
|
66
|
-
- `TimePicker.Input` exposes `aria-invalid` and `data-invalid` when the current segment draft is not committeable
|
|
66
|
+
- `TimePicker.Input` exposes `aria-invalid` and `data-invalid` when the current segment draft is not committeable, or when the consumer passes `aria-invalid`.
|
|
67
|
+
- `TimePicker.Input` accepts `id` and `name`. Either one renders a hidden but focusable proxy input that carries them. Thus a `<label for>` reaches the segments, and a native form submit reads the committed value. The group keeps `${id}-group`. Autofill is not supported on the proxy (`autocomplete="off"`).
|
|
67
68
|
|
|
68
69
|
## Popover API
|
|
69
70
|
|
|
@@ -83,7 +84,7 @@
|
|
|
83
84
|
|
|
84
85
|
- `TimePicker.Clock` resolves visible wheel columns from root state (`granularity`, `hourCycle`) in stable order: `hour → minute? → second? → dayPeriod?`.
|
|
85
86
|
- `class?: string` uses default layout (`flex gap-2`) when omitted.
|
|
86
|
-
- `column?: Snippet<[ClockColumnInfo]>`
|
|
87
|
+
- `column?: Snippet<[ClockColumnInfo]>` lets you make your own content for each column.
|
|
87
88
|
- `ClockColumnInfo` shape:
|
|
88
89
|
- `type: 'hour' | 'minute' | 'second' | 'dayPeriod'`
|
|
89
90
|
- `label?: string`
|
|
@@ -11,5 +11,5 @@ Description: Group wrapper for rendered time segments; manages focus entry and s
|
|
|
11
11
|
| -------------- | ---------------------------------- | ----------- | ----------------------------------------------------- |
|
|
12
12
|
| `children` | `Snippet<[TimePickerSegmentPart]>` | `undefined` | Optional custom renderer for each segment part. |
|
|
13
13
|
| `class` | `string` | `''` | CSS class names for the group element. |
|
|
14
|
-
| `aria-label` | `string` | `undefined` |
|
|
14
|
+
| `aria-label` | `string` | `undefined` | The accessible name of the input. group. |
|
|
15
15
|
| `...restProps` | `HTMLAttributes<HTMLDivElement>` | `-` | Additional attributes forwarded to the group element. |
|
|
@@ -12,17 +12,37 @@
|
|
|
12
12
|
|
|
13
13
|
type TimePickerInputProps = Omit<
|
|
14
14
|
HTMLAttributes<HTMLDivElement>,
|
|
15
|
-
'children' | 'class' | 'id' | 'role' | 'tabindex'
|
|
15
|
+
'children' | 'class' | 'id' | 'role' | 'tabindex' | 'aria-invalid'
|
|
16
16
|
> & {
|
|
17
|
+
/**
|
|
18
|
+
* The id of the hidden proxy input. A `<label for>` points to it, and the segmented group
|
|
19
|
+
* then takes a derived id.
|
|
20
|
+
*/
|
|
21
|
+
id?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Name of the hidden proxy input for form submission. The proxy shows only the committed
|
|
24
|
+
* value. It does not support autofill: it renders with `autocomplete="off"`, thus browsers
|
|
25
|
+
* and password managers do not write into it. The user gives the time through the editable
|
|
26
|
+
* segments.
|
|
27
|
+
*/
|
|
28
|
+
name?: string;
|
|
17
29
|
children?: Snippet<[TimePickerSegmentPart]>;
|
|
18
30
|
class?: string;
|
|
19
31
|
'aria-label'?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Marks the input as invalid. The group is also invalid while a segment draft is not
|
|
34
|
+
* committable.
|
|
35
|
+
*/
|
|
36
|
+
'aria-invalid'?: HTMLAttributes<HTMLDivElement>['aria-invalid'];
|
|
20
37
|
};
|
|
21
38
|
|
|
22
39
|
let {
|
|
40
|
+
id,
|
|
41
|
+
name,
|
|
23
42
|
children,
|
|
24
43
|
class: className = '',
|
|
25
44
|
'aria-label': ariaLabel,
|
|
45
|
+
'aria-invalid': ariaInvalid,
|
|
26
46
|
onmousedown: onMouseDownExternal,
|
|
27
47
|
onfocus: onFocusExternal,
|
|
28
48
|
onblur: onBlurExternal,
|
|
@@ -32,7 +52,28 @@
|
|
|
32
52
|
|
|
33
53
|
const timePicker = useTimePickerContext();
|
|
34
54
|
const segments = $derived(timePicker.getSegments());
|
|
35
|
-
|
|
55
|
+
// With an `id` the group keeps a derived one: the id itself belongs to the proxy input, so
|
|
56
|
+
// a `<label for>` points at something focusable. Mirrors `DatePicker.Input`.
|
|
57
|
+
const groupId = $derived(id ? `${id}-group` : `${timePicker.id}-input`);
|
|
58
|
+
const proxyValue = $derived(timePicker.value ?? '');
|
|
59
|
+
// Invalid is either half: the consumer's (a form rule) or an uncommittable segment draft.
|
|
60
|
+
const isInvalid = $derived(
|
|
61
|
+
ariaInvalid === true || ariaInvalid === 'true' || timePicker.isInvalidDraft
|
|
62
|
+
);
|
|
63
|
+
const shouldRenderProxyInput = $derived(Boolean(id || name));
|
|
64
|
+
const proxyInputStyle =
|
|
65
|
+
'position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;';
|
|
66
|
+
|
|
67
|
+
function handleProxyFocus(event: FocusEvent) {
|
|
68
|
+
if (timePicker.isDisabled) {
|
|
69
|
+
(event.currentTarget as HTMLElement | null)?.blur();
|
|
70
|
+
timePicker.syncFocusWithin();
|
|
71
|
+
timePicker.setFocusVisible(false);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
timePicker.setFocusVisible(shouldShowFocusVisible(event.currentTarget as HTMLElement));
|
|
75
|
+
timePicker.focusNextPlaceholderOrLastSegment();
|
|
76
|
+
}
|
|
36
77
|
|
|
37
78
|
function handleMouseDown(event: MouseEvent) {
|
|
38
79
|
if (timePicker.isDisabled) return;
|
|
@@ -83,15 +124,35 @@
|
|
|
83
124
|
}
|
|
84
125
|
</script>
|
|
85
126
|
|
|
127
|
+
{#if shouldRenderProxyInput}
|
|
128
|
+
<!--
|
|
129
|
+
A focusable stand-in for the segmented group: it carries the `id` a `<label for>` points
|
|
130
|
+
at and the `name` a native form submit reads, and hands focus straight to the segments.
|
|
131
|
+
-->
|
|
132
|
+
<input
|
|
133
|
+
{id}
|
|
134
|
+
{name}
|
|
135
|
+
value={proxyValue}
|
|
136
|
+
readonly
|
|
137
|
+
tabindex="-1"
|
|
138
|
+
autocomplete="off"
|
|
139
|
+
disabled={timePicker.isDisabled || undefined}
|
|
140
|
+
aria-hidden="true"
|
|
141
|
+
aria-invalid={ariaInvalid}
|
|
142
|
+
style={proxyInputStyle}
|
|
143
|
+
onfocus={handleProxyFocus}
|
|
144
|
+
/>
|
|
145
|
+
{/if}
|
|
146
|
+
|
|
86
147
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
87
148
|
<!-- svelte-ignore a11y_role_supports_aria_props -->
|
|
88
149
|
<div
|
|
89
|
-
id={
|
|
150
|
+
id={groupId}
|
|
90
151
|
class={className}
|
|
91
152
|
{...restProps}
|
|
92
153
|
role="group"
|
|
93
154
|
aria-label={ariaLabel}
|
|
94
|
-
aria-invalid={
|
|
155
|
+
aria-invalid={isInvalid || undefined}
|
|
95
156
|
aria-required={timePicker.isRequired || undefined}
|
|
96
157
|
tabindex={timePicker.isDisabled || timePicker.focusWithin ? -1 : 0}
|
|
97
158
|
data-disabled={timePicker.isDisabled || undefined}
|
|
@@ -99,7 +160,7 @@
|
|
|
99
160
|
data-open={timePicker.open || undefined}
|
|
100
161
|
data-focus-visible={timePicker.focusVisible || undefined}
|
|
101
162
|
data-focus-within={timePicker.focusWithin || undefined}
|
|
102
|
-
data-invalid={
|
|
163
|
+
data-invalid={isInvalid || undefined}
|
|
103
164
|
onmousedown={composeEventHandlers(handleMouseDown, onMouseDownExternal ?? undefined)}
|
|
104
165
|
onfocus={composeEventHandlers(handleFocus, onFocusExternal ?? undefined)}
|
|
105
166
|
onblur={composeEventHandlers(handleBlur, onBlurExternal ?? undefined)}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import { type TimePickerSegmentPart } from '../root/context';
|
|
4
|
-
type TimePickerInputProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'id' | 'role' | 'tabindex'> & {
|
|
4
|
+
type TimePickerInputProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'id' | 'role' | 'tabindex' | 'aria-invalid'> & {
|
|
5
|
+
/**
|
|
6
|
+
* The id of the hidden proxy input. A `<label for>` points to it, and the segmented group
|
|
7
|
+
* then takes a derived id.
|
|
8
|
+
*/
|
|
9
|
+
id?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Name of the hidden proxy input for form submission. The proxy shows only the committed
|
|
12
|
+
* value. It does not support autofill: it renders with `autocomplete="off"`, thus browsers
|
|
13
|
+
* and password managers do not write into it. The user gives the time through the editable
|
|
14
|
+
* segments.
|
|
15
|
+
*/
|
|
16
|
+
name?: string;
|
|
5
17
|
children?: Snippet<[TimePickerSegmentPart]>;
|
|
6
18
|
class?: string;
|
|
7
19
|
'aria-label'?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Marks the input as invalid. The group is also invalid while a segment draft is not
|
|
22
|
+
* committable.
|
|
23
|
+
*/
|
|
24
|
+
'aria-invalid'?: HTMLAttributes<HTMLDivElement>['aria-invalid'];
|
|
8
25
|
};
|
|
9
26
|
declare const TimePickerInput: import("svelte").Component<TimePickerInputProps, {}, "">;
|
|
10
27
|
type TimePickerInput = ReturnType<typeof TimePickerInput>;
|
|
@@ -26,7 +26,7 @@ Description: State container for segmented time input, popover lifecycle, wheel
|
|
|
26
26
|
| `readonly` | `boolean` | `false` | Prevents value changes while keeping focus/navigation. |
|
|
27
27
|
| `required` | `boolean` | `false` | Propagates required state to input accessibility attributes. |
|
|
28
28
|
| `children` | `Snippet` | `undefined` | Composed `TimePicker` parts. |
|
|
29
|
-
| `class` | `string` | `''` | CSS class names
|
|
29
|
+
| `class` | `string` | `''` | The CSS class names of the root element. |
|
|
30
30
|
| `element` | `HTMLDivElement \| null` | `bindable` | Reference to the root DOM element. |
|
|
31
31
|
| `aria-label` | `string` | `undefined` | Accessible label for the root wrapper. |
|
|
32
32
|
|
|
@@ -10,5 +10,5 @@ Description: Button part that toggles `TimePicker.Popover` and synchronizes focu
|
|
|
10
10
|
| Prop | Type | Default | Description |
|
|
11
11
|
| -------------- | ---------------------- | ----------- | ------------------------------------------------------ |
|
|
12
12
|
| `children` | `Snippet` | `undefined` | Optional trigger content. |
|
|
13
|
-
| `class` | `string` | `''` | CSS class names
|
|
13
|
+
| `class` | `string` | `''` | The CSS class names of the trigger button. |
|
|
14
14
|
| `...restProps` | `HTMLButtonAttributes` | `-` | Additional button attributes forwarded to the trigger. |
|
package/dist/toggle/README.md
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
## Accessibility
|
|
37
37
|
|
|
38
38
|
- `Toggle.Root` renders a native `<button type="button">`.
|
|
39
|
-
- The selected state
|
|
39
|
+
- The component gives the selected state to assistive technology with `aria-pressed="true" | "false"`.
|
|
40
40
|
- Native keyboard activation is supported with `Enter` and `Space`.
|
|
41
41
|
- `data-focus-visible` follows the shared modality contract and is only exposed for keyboard or virtual focus.
|
|
42
42
|
|