@human-kit/svelte-components 1.0.0-alpha.3 → 1.0.0-alpha.5
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/dist/FOCUS_STATE_CONTRACT.md +12 -0
- package/dist/calendar/body-cell/README.md +15 -0
- package/dist/calendar/grid/README.md +13 -0
- package/dist/calendar/grid-body/README.md +13 -0
- package/dist/calendar/grid-header/README.md +13 -0
- package/dist/calendar/header-cell/README.md +14 -0
- package/dist/calendar/heading/README.md +13 -0
- package/dist/calendar/root/README.md +24 -0
- package/dist/calendar/trigger-next/README.md +14 -0
- package/dist/calendar/trigger-previous/README.md +14 -0
- package/dist/checkbox/README.md +53 -0
- package/dist/checkbox/TODO.md +16 -0
- package/dist/checkbox/index.d.ts +6 -0
- package/dist/checkbox/index.js +6 -0
- package/dist/checkbox/index.parts.d.ts +2 -0
- package/dist/checkbox/index.parts.js +2 -0
- package/dist/checkbox/indicator/README.md +23 -0
- package/dist/checkbox/indicator/checkbox-indicator.svelte +43 -0
- package/dist/checkbox/indicator/checkbox-indicator.svelte.d.ts +10 -0
- package/dist/checkbox/root/README.md +47 -0
- package/dist/checkbox/root/checkbox-label-test.svelte +10 -0
- package/dist/checkbox/root/checkbox-label-test.svelte.d.ts +18 -0
- package/dist/checkbox/root/checkbox-root.svelte +361 -0
- package/dist/checkbox/root/checkbox-root.svelte.d.ts +23 -0
- package/dist/checkbox/root/checkbox-test.svelte +59 -0
- package/dist/checkbox/root/checkbox-test.svelte.d.ts +18 -0
- package/dist/checkbox/root/context.d.ts +21 -0
- package/dist/checkbox/root/context.js +15 -0
- package/dist/clock/README.md +75 -0
- package/dist/clock/axis/README.md +24 -0
- package/dist/clock/axis/clock-axis.svelte +37 -0
- package/dist/clock/axis/clock-axis.svelte.d.ts +8 -0
- package/dist/clock/hooks/use-wheel-scroll.svelte.d.ts +16 -0
- package/dist/clock/hooks/use-wheel-scroll.svelte.js +336 -0
- package/dist/clock/index.d.ts +10 -0
- package/dist/clock/index.js +10 -0
- package/dist/clock/index.parts.d.ts +4 -0
- package/dist/clock/index.parts.js +4 -0
- package/dist/clock/root/README.md +38 -0
- package/dist/clock/root/clock-root-test.svelte +62 -0
- package/dist/clock/root/clock-root-test.svelte.d.ts +14 -0
- package/dist/clock/root/clock-root.svelte +329 -0
- package/dist/clock/root/clock-root.svelte.d.ts +25 -0
- package/dist/clock/root/context.d.ts +22 -0
- package/dist/clock/root/context.js +15 -0
- package/dist/clock/root/resolve-visible-columns.d.ts +7 -0
- package/dist/clock/root/resolve-visible-columns.js +16 -0
- package/dist/clock/root/time-utils.d.ts +48 -0
- package/dist/clock/root/time-utils.js +314 -0
- package/dist/clock/root/wheel-options.d.ts +17 -0
- package/dist/clock/root/wheel-options.js +63 -0
- package/dist/clock/wheel-column/README.md +25 -0
- package/dist/clock/wheel-column/clock-wheel-column-bindable-test.svelte +16 -0
- package/dist/clock/wheel-column/clock-wheel-column-bindable-test.svelte.d.ts +3 -0
- package/dist/clock/wheel-column/clock-wheel-column-custom-snippet-test.svelte +29 -0
- package/dist/clock/wheel-column/clock-wheel-column-custom-snippet-test.svelte.d.ts +6 -0
- package/dist/clock/wheel-column/clock-wheel-column-default-height-test.svelte +11 -0
- package/dist/clock/wheel-column/clock-wheel-column-default-height-test.svelte.d.ts +3 -0
- package/dist/clock/wheel-column/clock-wheel-column-test.svelte +38 -0
- package/dist/clock/wheel-column/clock-wheel-column-test.svelte.d.ts +12 -0
- package/dist/clock/wheel-column/clock-wheel-column-tp-test.svelte +38 -0
- package/dist/clock/wheel-column/clock-wheel-column-tp-test.svelte.d.ts +12 -0
- package/dist/clock/wheel-column/clock-wheel-column-untagged-snippet-test.svelte +29 -0
- package/dist/clock/wheel-column/clock-wheel-column-untagged-snippet-test.svelte.d.ts +6 -0
- package/dist/clock/wheel-column/clock-wheel-column.svelte +499 -0
- package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +17 -0
- package/dist/clock/wheel-item/README.md +17 -0
- package/dist/clock/wheel-item/clock-wheel-item.svelte +49 -0
- package/dist/clock/wheel-item/clock-wheel-item.svelte.d.ts +17 -0
- package/dist/combobox/list/combobox-listbox.svelte.d.ts +1 -1
- package/dist/datepicker/TODO.md +2 -2
- package/dist/datepicker/calendar/README.md +19 -0
- package/dist/datepicker/input/README.md +15 -0
- package/dist/datepicker/popover/README.md +20 -0
- package/dist/datepicker/root/README.md +38 -0
- package/dist/datepicker/segment/README.md +14 -0
- package/dist/datepicker/trigger/README.md +14 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/primitives/focus-trap.js +11 -12
- package/dist/primitives/input-modality.js +10 -1
- package/dist/table/IMPLEMENTATION_NOTES.md +8 -0
- package/dist/table/PLAN-HIDDEN-COLUMNS.md +152 -0
- package/dist/table/PLAN.md +924 -0
- package/dist/table/README.md +116 -0
- package/dist/table/SELECTION_CHECKBOX_PLAN.md +234 -0
- package/dist/table/TODO.md +100 -0
- package/dist/table/body/README.md +24 -0
- package/dist/table/body/table-body.svelte +25 -0
- package/dist/table/body/table-body.svelte.d.ts +9 -0
- package/dist/table/cell/README.md +25 -0
- package/dist/table/cell/table-cell.svelte +247 -0
- package/dist/table/cell/table-cell.svelte.d.ts +9 -0
- package/dist/table/checkbox/README.md +38 -0
- package/dist/table/checkbox/table-checkbox-test.svelte +121 -0
- package/dist/table/checkbox/table-checkbox-test.svelte.d.ts +16 -0
- package/dist/table/checkbox/table-checkbox.svelte +274 -0
- package/dist/table/checkbox/table-checkbox.svelte.d.ts +13 -0
- package/dist/table/checkbox-indicator/README.md +29 -0
- package/dist/table/checkbox-indicator/table-checkbox-indicator.svelte +22 -0
- package/dist/table/checkbox-indicator/table-checkbox-indicator.svelte.d.ts +10 -0
- package/dist/table/column/README.md +32 -0
- package/dist/table/column/table-column.svelte +108 -0
- package/dist/table/column/table-column.svelte.d.ts +18 -0
- package/dist/table/column-header-cell/README.md +28 -0
- package/dist/table/column-header-cell/table-column-header-cell.svelte +281 -0
- package/dist/table/column-header-cell/table-column-header-cell.svelte.d.ts +9 -0
- package/dist/table/column-resizer/README.md +32 -0
- package/dist/table/column-resizer/table-column-resizer-freeze-layout-test.svelte +51 -0
- package/dist/table/column-resizer/table-column-resizer-freeze-layout-test.svelte.d.ts +3 -0
- package/dist/table/column-resizer/table-column-resizer-selection-column-test.svelte +83 -0
- package/dist/table/column-resizer/table-column-resizer-selection-column-test.svelte.d.ts +3 -0
- package/dist/table/column-resizer/table-column-resizer-test.svelte +75 -0
- package/dist/table/column-resizer/table-column-resizer-test.svelte.d.ts +3 -0
- package/dist/table/column-resizer/table-column-resizer.svelte +616 -0
- package/dist/table/column-resizer/table-column-resizer.svelte.d.ts +11 -0
- package/dist/table/empty-state/README.md +25 -0
- package/dist/table/empty-state/table-empty-state.svelte +38 -0
- package/dist/table/empty-state/table-empty-state.svelte.d.ts +8 -0
- package/dist/table/footer/README.md +24 -0
- package/dist/table/footer/table-footer.svelte +19 -0
- package/dist/table/footer/table-footer.svelte.d.ts +9 -0
- package/dist/table/header/README.md +24 -0
- package/dist/table/header/table-header.svelte +19 -0
- package/dist/table/header/table-header.svelte.d.ts +9 -0
- package/dist/table/index.d.ts +16 -0
- package/dist/table/index.js +16 -0
- package/dist/table/index.parts.d.ts +12 -0
- package/dist/table/index.parts.js +12 -0
- package/dist/table/root/README.md +56 -0
- package/dist/table/root/context.d.ts +198 -0
- package/dist/table/root/context.js +1426 -0
- package/dist/table/root/table-reorder-test.svelte +64 -0
- package/dist/table/root/table-reorder-test.svelte.d.ts +3 -0
- package/dist/table/root/table-root.svelte +410 -0
- package/dist/table/root/table-root.svelte.d.ts +29 -0
- package/dist/table/root/table-test.svelte +165 -0
- package/dist/table/root/table-test.svelte.d.ts +25 -0
- package/dist/table/row/README.md +27 -0
- package/dist/table/row/table-row.svelte +321 -0
- package/dist/table/row/table-row.svelte.d.ts +13 -0
- package/dist/timepicker/IMPLEMENTATION_PLAN.md +254 -0
- package/dist/timepicker/README.md +97 -0
- package/dist/timepicker/TODO.md +86 -0
- package/dist/timepicker/clock/README.md +14 -0
- package/dist/timepicker/clock/time-picker-clock-test.svelte +45 -0
- package/dist/timepicker/clock/time-picker-clock-test.svelte.d.ts +11 -0
- package/dist/timepicker/clock/time-picker-clock.svelte +65 -0
- package/dist/timepicker/clock/time-picker-clock.svelte.d.ts +10 -0
- package/dist/timepicker/index.d.ts +14 -0
- package/dist/timepicker/index.js +14 -0
- package/dist/timepicker/index.parts.d.ts +8 -0
- package/dist/timepicker/index.parts.js +8 -0
- package/dist/timepicker/input/README.md +15 -0
- package/dist/timepicker/input/time-picker-input-forwarding-test.svelte +40 -0
- package/dist/timepicker/input/time-picker-input-forwarding-test.svelte.d.ts +3 -0
- package/dist/timepicker/input/time-picker-input.svelte +109 -0
- package/dist/timepicker/input/time-picker-input.svelte.d.ts +11 -0
- package/dist/timepicker/internal/strict-props.d.ts +4 -0
- package/dist/timepicker/internal/strict-props.js +51 -0
- package/dist/timepicker/popover/README.md +20 -0
- package/dist/timepicker/popover/time-picker-popover-unsafe-props-test.svelte +22 -0
- package/dist/timepicker/popover/time-picker-popover-unsafe-props-test.svelte.d.ts +3 -0
- package/dist/timepicker/popover/time-picker-popover.svelte +89 -0
- package/dist/timepicker/popover/time-picker-popover.svelte.d.ts +7 -0
- package/dist/timepicker/root/README.md +42 -0
- package/dist/timepicker/root/context.d.ts +51 -0
- package/dist/timepicker/root/context.js +15 -0
- package/dist/timepicker/root/time-picker-12h-test.svelte +22 -0
- package/dist/timepicker/root/time-picker-12h-test.svelte.d.ts +3 -0
- package/dist/timepicker/root/time-picker-bindable-test.svelte +25 -0
- package/dist/timepicker/root/time-picker-bindable-test.svelte.d.ts +3 -0
- package/dist/timepicker/root/time-picker-empty-test.svelte +20 -0
- package/dist/timepicker/root/time-picker-empty-test.svelte.d.ts +3 -0
- package/dist/timepicker/root/time-picker-root.svelte +625 -0
- package/dist/timepicker/root/time-picker-root.svelte.d.ts +28 -0
- package/dist/timepicker/root/time-picker-test.svelte +72 -0
- package/dist/timepicker/root/time-picker-test.svelte.d.ts +15 -0
- package/dist/timepicker/root/time-utils.d.ts +1 -0
- package/dist/timepicker/root/time-utils.js +3 -0
- package/dist/timepicker/segment/README.md +14 -0
- package/dist/timepicker/segment/time-picker-segment.svelte +365 -0
- package/dist/timepicker/segment/time-picker-segment.svelte.d.ts +9 -0
- package/dist/timepicker/trigger/README.md +14 -0
- package/dist/timepicker/trigger/time-picker-trigger-forwarding-test.svelte +35 -0
- package/dist/timepicker/trigger/time-picker-trigger-forwarding-test.svelte.d.ts +3 -0
- package/dist/timepicker/trigger/time-picker-trigger.svelte +122 -0
- package/dist/timepicker/trigger/time-picker-trigger.svelte.d.ts +9 -0
- package/package.json +21 -1
|
@@ -49,3 +49,15 @@ On overlay/popover close, transient trigger state is allowed:
|
|
|
49
49
|
## Operational Template
|
|
50
50
|
|
|
51
51
|
- Use `FOCUS_STATE_REVIEW_TEMPLATE.md` for PR/release reviews (modality matrix + component status + checklist).
|
|
52
|
+
|
|
53
|
+
## Component Coverage
|
|
54
|
+
|
|
55
|
+
The following components implement this contract:
|
|
56
|
+
|
|
57
|
+
- **Popover** — trigger + content, restore focus on close.
|
|
58
|
+
- **Dialog** — trigger + overlay/content, nested stack support.
|
|
59
|
+
- **DatePicker** — segment spinbuttons, trigger, popover (calendar).
|
|
60
|
+
- **TimePicker** — segment spinbuttons, trigger, popover (scrollable columns). Follows the same contract as DatePicker.
|
|
61
|
+
- **Calendar** — grid cells with roving tabindex.
|
|
62
|
+
- **ComboBox** — input + listbox with virtual focus.
|
|
63
|
+
- **ListBox** — items with roving tabindex.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Calendar BodyCell
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Calendar.BodyCell
|
|
6
|
+
|
|
7
|
+
Name: `Calendar.BodyCell`
|
|
8
|
+
Description: Wrapper part for date grid cells inside `Calendar.GridBody`.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| -------------- | -------------------------------------- | ----------- | --------------------------------------------------------------- |
|
|
12
|
+
| `date` | `string` | `required` | Calendar date value rendered by the cell (`YYYY-MM-DD`). |
|
|
13
|
+
| `children` | `Snippet<[string]>` | `undefined` | Optional custom renderer receiving the day label text. |
|
|
14
|
+
| `class` | `string` | `''` | CSS class names for the inner gridcell element. |
|
|
15
|
+
| `...restProps` | `HTMLAttributes<HTMLTableCellElement>` | `-` | Additional attributes forwarded to the outer table cell (`td`). |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Calendar Grid
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Calendar.Grid
|
|
6
|
+
|
|
7
|
+
Name: `Calendar.Grid`
|
|
8
|
+
Description: Calendar month table container rendered by `Calendar.Root`.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| ---------- | --------- | ----------- | --------------------------------------------- |
|
|
12
|
+
| `children` | `Snippet` | `undefined` | Optional custom month-grid content. |
|
|
13
|
+
| `class` | `string` | `''` | CSS class names for the outer grid container. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Calendar GridBody
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Calendar.GridBody
|
|
6
|
+
|
|
7
|
+
Name: `Calendar.GridBody`
|
|
8
|
+
Description: TBody container for week rows in `Calendar.Grid`.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| ---------- | ------------------- | ----------- | -------------------------------------------------------- |
|
|
12
|
+
| `children` | `Snippet<[string]>` | `undefined` | Optional custom renderer receiving each day date string. |
|
|
13
|
+
| `class` | `string` | `''` | CSS class names for the `tbody` element. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Calendar GridHeader
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Calendar.GridHeader
|
|
6
|
+
|
|
7
|
+
Name: `Calendar.GridHeader`
|
|
8
|
+
Description: Header row group for weekday labels in `Calendar.Grid`.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| ---------- | ------------------- | ----------- | ---------------------------------------------------------------- |
|
|
12
|
+
| `children` | `Snippet<[string]>` | `undefined` | Optional custom renderer receiving each localized weekday label. |
|
|
13
|
+
| `class` | `string` | `''` | CSS class names for the `thead` element. |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Calendar HeaderCell
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Calendar.HeaderCell
|
|
6
|
+
|
|
7
|
+
Name: `Calendar.HeaderCell`
|
|
8
|
+
Description: Weekday heading cell part used inside `Calendar.GridHeader`.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| -------------- | -------------------------------------- | ----------- | -------------------------------------------------- |
|
|
12
|
+
| `children` | `Snippet` | `undefined` | Optional custom header cell content. |
|
|
13
|
+
| `class` | `string` | `''` | CSS class names for the header cell element. |
|
|
14
|
+
| `...restProps` | `HTMLAttributes<HTMLTableCellElement>` | `-` | Additional attributes forwarded to the table cell. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Calendar Heading
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Calendar.Heading
|
|
6
|
+
|
|
7
|
+
Name: `Calendar.Heading`
|
|
8
|
+
Description: Label part that displays the currently visible calendar period.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| -------------- | ------------------------------------ | ------- | ------------------------------------------------------- |
|
|
12
|
+
| `class` | `string` | `''` | CSS class names for the heading element (`h2`). |
|
|
13
|
+
| `...restProps` | `HTMLAttributes<HTMLHeadingElement>` | `-` | Additional attributes forwarded to the heading element. |
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Calendar Root
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Calendar.Root
|
|
6
|
+
|
|
7
|
+
Name: `Calendar.Root`
|
|
8
|
+
Description: Root state container for date grid rendering, navigation, selection, and locale-aware formatting.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| ------------------- | ---------------------------------------------------------- | ----------- | ------------------------------------------------------------------- |
|
|
12
|
+
| `selectionMode` | `'single' \| 'range'` | `'single'` | Selection behavior and value shape. |
|
|
13
|
+
| `value` | `CalendarDateValue \| CalendarRangeValue \| undefined` | `bindable` | Controlled selected value (single date or `{ start, end }`). |
|
|
14
|
+
| `defaultValue` | `CalendarDateValue \| CalendarRangeValue \| undefined` | `undefined` | Initial value for uncontrolled mode. |
|
|
15
|
+
| `onChange` | `(value: CalendarDateValue \| CalendarRangeValue) => void` | `undefined` | Called when selection changes. |
|
|
16
|
+
| `visibleMonths` | `number` | `1` | Number of month grids rendered simultaneously. |
|
|
17
|
+
| `showOutsideDays` | `boolean` | `false` | Whether days outside the visible month remain rendered/interactive. |
|
|
18
|
+
| `isDateUnavailable` | `(date: string) => boolean` | `undefined` | Marks specific dates as unavailable. |
|
|
19
|
+
| `isDisabled` | `boolean` | `false` | Disables interaction and navigation. |
|
|
20
|
+
| `isReadOnly` | `boolean` | `false` | Keeps navigation while preventing selection updates. |
|
|
21
|
+
| `children` | `Snippet` | `undefined` | Composed `Calendar` parts. |
|
|
22
|
+
| `class` | `string` | `''` | CSS class names for the root wrapper. |
|
|
23
|
+
| `id` | `string` | `undefined` | Optional root id. |
|
|
24
|
+
| `aria-label` | `string` | `undefined` | Accessible label for the root wrapper. |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Calendar TriggerNext
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Calendar.TriggerNext
|
|
6
|
+
|
|
7
|
+
Name: `Calendar.TriggerNext`
|
|
8
|
+
Description: Button part that advances the visible calendar period.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| -------------- | ---------------------- | ----------- | ------------------------------------------------------ |
|
|
12
|
+
| `children` | `Snippet` | `undefined` | Optional trigger content. |
|
|
13
|
+
| `class` | `string` | `''` | CSS class names for the trigger button. |
|
|
14
|
+
| `...restProps` | `HTMLButtonAttributes` | `-` | Additional button attributes forwarded to the trigger. |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Calendar TriggerPrevious
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Calendar.TriggerPrevious
|
|
6
|
+
|
|
7
|
+
Name: `Calendar.TriggerPrevious`
|
|
8
|
+
Description: Button part that moves the visible calendar period backward.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| -------------- | ---------------------- | ----------- | ------------------------------------------------------ |
|
|
12
|
+
| `children` | `Snippet` | `undefined` | Optional trigger content. |
|
|
13
|
+
| `class` | `string` | `''` | CSS class names for the trigger button. |
|
|
14
|
+
| `...restProps` | `HTMLButtonAttributes` | `-` | Additional button attributes forwarded to the trigger. |
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Checkbox
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`Checkbox` is a composable tri-state checkbox with separate checked and indeterminate bindings, hidden input form support, and headless indicator rendering.
|
|
6
|
+
|
|
7
|
+
## Anatomy
|
|
8
|
+
|
|
9
|
+
- `Checkbox.Root`
|
|
10
|
+
- `Checkbox.Indicator`
|
|
11
|
+
|
|
12
|
+
```svelte
|
|
13
|
+
<Checkbox.Root aria-label="Accept terms">
|
|
14
|
+
<Checkbox.Indicator>
|
|
15
|
+
<CheckIcon />
|
|
16
|
+
</Checkbox.Indicator>
|
|
17
|
+
</Checkbox.Root>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage guidelines
|
|
21
|
+
|
|
22
|
+
- Use `isChecked` / `defaultChecked` for the checked state and `isIndeterminate` / `defaultIndeterminate` for the mixed state.
|
|
23
|
+
- `isIndeterminate` takes precedence over `isChecked`. When both are `true`, the checkbox is exposed as indeterminate.
|
|
24
|
+
- Use `value` only for form submission through the hidden native input; it does not represent the visual state.
|
|
25
|
+
- Wrap the checkbox in a native `<label>` for the simplest accessible labeling pattern.
|
|
26
|
+
|
|
27
|
+
## API reference
|
|
28
|
+
|
|
29
|
+
- `Checkbox.Root`
|
|
30
|
+
- `isChecked?: boolean`
|
|
31
|
+
- `defaultChecked?: boolean`
|
|
32
|
+
- `isIndeterminate?: boolean`
|
|
33
|
+
- `defaultIndeterminate?: boolean`
|
|
34
|
+
- `onCheckedChange?: (checked: boolean) => void`
|
|
35
|
+
- `onIndeterminateChange?: (indeterminate: boolean) => void`
|
|
36
|
+
- `isDisabled?: boolean`
|
|
37
|
+
- `isReadOnly?: boolean`
|
|
38
|
+
- `name?: string`
|
|
39
|
+
- `value?: string`
|
|
40
|
+
- `required?: boolean`
|
|
41
|
+
- `Checkbox.Indicator`
|
|
42
|
+
- `keepMounted?: boolean`
|
|
43
|
+
|
|
44
|
+
## Accessibility
|
|
45
|
+
|
|
46
|
+
- `Checkbox.Root` exposes `role="checkbox"` with `aria-checked="true" | "false" | "mixed"`.
|
|
47
|
+
- Press `Space` to toggle the checkbox.
|
|
48
|
+
- `isReadOnly` keeps the checkbox focusable while preventing state changes.
|
|
49
|
+
|
|
50
|
+
## Notes
|
|
51
|
+
|
|
52
|
+
- The first user toggle from the indeterminate state resolves to checked.
|
|
53
|
+
- A hidden checkbox input is kept in sync for form integration and `label[for]` support.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Checkbox TODO
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Track Checkbox work with a single mandatory TODO format.
|
|
6
|
+
|
|
7
|
+
## Backlog
|
|
8
|
+
|
|
9
|
+
- [x] [S][P0][Area: Architecture][Owner: Unassigned][Target: Done] Create base `root` and `indicator` parts with namespace exports.
|
|
10
|
+
- [x] [S][P0][Area: State][Owner: Unassigned][Target: Done] Implement checked, unchecked, and indeterminate state transitions.
|
|
11
|
+
- [x] [S][P0][Area: Accessibility][Owner: Unassigned][Target: Done] Add checkbox semantics, keyboard toggle, and readonly behavior.
|
|
12
|
+
- [x] [S][P0][Area: Forms][Owner: Unassigned][Target: Done] Sync a hidden native input for form submission and label targeting.
|
|
13
|
+
- [x] [S][P0][Area: Testing][Owner: Unassigned][Target: Done] Add baseline tests for root and indicator behavior.
|
|
14
|
+
- [ ] [S][P1][Area: API][Owner: Unassigned][Target: TBD] Add optional `nativeButton` rendering mode for sibling-label patterns.
|
|
15
|
+
- [ ] [S][P1][Area: Forms][Owner: Unassigned][Target: TBD] Support unchecked submission values and form reset synchronization.
|
|
16
|
+
- [ ] [C][P2][Area: Animation][Owner: Unassigned][Target: TBD] Add indicator presence data for enter and exit animations.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as Checkbox from './index.parts.ts';
|
|
2
|
+
export { default as CheckboxRoot } from './root/checkbox-root.svelte';
|
|
3
|
+
export { default as CheckboxIndicator } from './indicator/checkbox-indicator.svelte';
|
|
4
|
+
export { getCheckboxContext, setCheckboxContext, useCheckboxContext, type CheckboxContext, type CheckboxState } from './root/context.ts';
|
|
5
|
+
import * as CheckboxParts from './index.parts.ts';
|
|
6
|
+
export default CheckboxParts;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as Checkbox from './index.parts.ts';
|
|
2
|
+
export { default as CheckboxRoot } from './root/checkbox-root.svelte';
|
|
3
|
+
export { default as CheckboxIndicator } from './indicator/checkbox-indicator.svelte';
|
|
4
|
+
export { getCheckboxContext, setCheckboxContext, useCheckboxContext } from './root/context.ts';
|
|
5
|
+
import * as CheckboxParts from './index.parts.ts';
|
|
6
|
+
export default CheckboxParts;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Checkbox Indicator
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Checkbox.Indicator
|
|
6
|
+
|
|
7
|
+
Name: `Checkbox.Indicator`
|
|
8
|
+
Description: Headless presence wrapper for checkbox indicator content. It renders when the checkbox is checked or indeterminate.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| -------------- | --------------------------------- | ----------- | ------------------------------------------------------------------------ |
|
|
12
|
+
| `keepMounted` | `boolean` | `false` | Keeps the indicator mounted while hidden when the checkbox is unchecked. |
|
|
13
|
+
| `children` | `Snippet` | `undefined` | Rendered indicator content, such as a check or dash icon. |
|
|
14
|
+
| `class` | `string` | `''` | CSS class names for the indicator wrapper. |
|
|
15
|
+
| `...restProps` | `HTMLAttributes<HTMLSpanElement>` | `-` | Additional attributes forwarded to the indicator span. |
|
|
16
|
+
|
|
17
|
+
```svelte
|
|
18
|
+
<Checkbox.Root aria-label="Select row">
|
|
19
|
+
<Checkbox.Indicator>
|
|
20
|
+
<CheckIcon />
|
|
21
|
+
</Checkbox.Indicator>
|
|
22
|
+
</Checkbox.Root>
|
|
23
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
import { useCheckboxContext } from '../root/context';
|
|
6
|
+
|
|
7
|
+
type CheckboxIndicatorProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
|
|
8
|
+
keepMounted?: boolean;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
class?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
keepMounted = false,
|
|
15
|
+
children,
|
|
16
|
+
class: className = '',
|
|
17
|
+
...restProps
|
|
18
|
+
}: CheckboxIndicatorProps = $props();
|
|
19
|
+
|
|
20
|
+
const checkbox = useCheckboxContext();
|
|
21
|
+
const visible = $derived(checkbox.state !== 'unchecked');
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
{#if keepMounted || visible}
|
|
25
|
+
<span
|
|
26
|
+
{...restProps}
|
|
27
|
+
data-checkbox-indicator="true"
|
|
28
|
+
data-checked={checkbox.isChecked || undefined}
|
|
29
|
+
data-unchecked={checkbox.state === 'unchecked' || undefined}
|
|
30
|
+
data-indeterminate={checkbox.isIndeterminate || undefined}
|
|
31
|
+
data-pressed={checkbox.pressed || undefined}
|
|
32
|
+
data-disabled={checkbox.isDisabled || undefined}
|
|
33
|
+
data-readonly={checkbox.isReadOnly || undefined}
|
|
34
|
+
data-required={checkbox.required || undefined}
|
|
35
|
+
data-focused={checkbox.focused || undefined}
|
|
36
|
+
data-focus-visible={checkbox.focusVisible || undefined}
|
|
37
|
+
hidden={keepMounted && !visible}
|
|
38
|
+
aria-hidden={keepMounted && !visible ? 'true' : undefined}
|
|
39
|
+
class={cn('contents', className)}
|
|
40
|
+
>
|
|
41
|
+
{@render children?.()}
|
|
42
|
+
</span>
|
|
43
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type CheckboxIndicatorProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
|
|
4
|
+
keepMounted?: boolean;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
class?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const CheckboxIndicator: import("svelte").Component<CheckboxIndicatorProps, {}, "">;
|
|
9
|
+
type CheckboxIndicator = ReturnType<typeof CheckboxIndicator>;
|
|
10
|
+
export default CheckboxIndicator;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Checkbox Root
|
|
2
|
+
|
|
3
|
+
## API reference
|
|
4
|
+
|
|
5
|
+
### Checkbox.Root
|
|
6
|
+
|
|
7
|
+
Name: `Checkbox.Root`
|
|
8
|
+
Description: Interactive tri-state checkbox root that owns checked, indeterminate, focus, and hidden input synchronization.
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Default | Description |
|
|
11
|
+
| ----------------------- | ---------------------------------- | ------------- | ---------------------------------------------------------------- |
|
|
12
|
+
| `id` | `string` | `$props.id()` | Stable id used for the hidden input and derived root id. |
|
|
13
|
+
| `name` | `string` | `undefined` | Form field name forwarded to the hidden native input. |
|
|
14
|
+
| `value` | `string` | `'on'` | Submitted value when the checkbox is checked. |
|
|
15
|
+
| `isChecked` | `boolean` | `undefined` | Controlled checked state. Supports `bind:isChecked`. |
|
|
16
|
+
| `defaultChecked` | `boolean` | `false` | Initial checked state in uncontrolled mode. |
|
|
17
|
+
| `isIndeterminate` | `boolean` | `undefined` | Controlled indeterminate state. Supports `bind:isIndeterminate`. |
|
|
18
|
+
| `defaultIndeterminate` | `boolean` | `false` | Initial indeterminate state in uncontrolled mode. |
|
|
19
|
+
| `onCheckedChange` | `(checked: boolean) => void` | `undefined` | Called when the effective checked state changes. |
|
|
20
|
+
| `onIndeterminateChange` | `(indeterminate: boolean) => void` | `undefined` | Called when the effective indeterminate state changes. |
|
|
21
|
+
| `isDisabled` | `boolean` | `false` | Prevents focus and state changes. |
|
|
22
|
+
| `isReadOnly` | `boolean` | `false` | Allows focus but blocks user-driven state changes. |
|
|
23
|
+
| `required` | `boolean` | `false` | Marks the hidden input as required and exposes `data-required`. |
|
|
24
|
+
| `children` | `Snippet` | `undefined` | Composed checkbox parts such as `Checkbox.Indicator`. |
|
|
25
|
+
| `class` | `string` | `''` | CSS class names for the root element. |
|
|
26
|
+
| `...restProps` | `HTMLAttributes<HTMLSpanElement>` | `-` | Additional attributes forwarded to the checkbox root span. |
|
|
27
|
+
|
|
28
|
+
### Context utilities
|
|
29
|
+
|
|
30
|
+
Name: `context.ts` helpers
|
|
31
|
+
Description: Internal APIs for publishing and consuming checkbox state.
|
|
32
|
+
|
|
33
|
+
| Prop | Type | Default | Description |
|
|
34
|
+
| -------------------- | ------------------------------------ | ------- | -------------------------------------------------- |
|
|
35
|
+
| `setCheckboxContext` | `(ctx: CheckboxContext) => void` | `-` | Registers the checkbox context in root. |
|
|
36
|
+
| `getCheckboxContext` | `() => CheckboxContext \| undefined` | `-` | Returns the context when available. |
|
|
37
|
+
| `useCheckboxContext` | `() => CheckboxContext` | `-` | Returns the context and throws outside root usage. |
|
|
38
|
+
|
|
39
|
+
`CheckboxState` is the internal state union used by the root context: `'checked' | 'unchecked' | 'indeterminate'`.
|
|
40
|
+
|
|
41
|
+
```svelte
|
|
42
|
+
<Checkbox.Root bind:isChecked bind:isIndeterminate aria-label="Notifications">
|
|
43
|
+
<Checkbox.Indicator>
|
|
44
|
+
<CheckIcon />
|
|
45
|
+
</Checkbox.Indicator>
|
|
46
|
+
</Checkbox.Root>
|
|
47
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Checkbox } from '../index.ts';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<label for="notifications">Enable notifications</label>
|
|
6
|
+
<Checkbox.Root id="notifications" aria-label="Notifications">
|
|
7
|
+
<Checkbox.Indicator>
|
|
8
|
+
<span data-checkbox-icon="true">icon</span>
|
|
9
|
+
</Checkbox.Indicator>
|
|
10
|
+
</Checkbox.Root>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const CheckboxLabelTest: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type CheckboxLabelTest = InstanceType<typeof CheckboxLabelTest>;
|
|
18
|
+
export default CheckboxLabelTest;
|