@human-kit/svelte-components 1.0.0-alpha.1 → 1.0.0-alpha.3
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 +51 -0
- package/dist/FOCUS_STATE_REVIEW_TEMPLATE.md +70 -0
- package/dist/calendar/README.md +66 -0
- package/dist/calendar/TODO.md +23 -0
- package/dist/calendar/body-cell/calendar-body-cell.svelte +230 -0
- package/dist/calendar/body-cell/calendar-body-cell.svelte.d.ts +9 -0
- package/dist/calendar/grid/calendar-grid-month-scope.svelte +16 -0
- package/dist/calendar/grid/calendar-grid-month-scope.svelte.d.ts +8 -0
- package/dist/calendar/grid/calendar-grid.svelte +45 -0
- package/dist/calendar/grid/calendar-grid.svelte.d.ts +8 -0
- package/dist/calendar/grid/month-scope.d.ts +2 -0
- package/dist/calendar/grid/month-scope.js +8 -0
- package/dist/calendar/grid-body/calendar-grid-body-custom-test.svelte +13 -0
- package/dist/calendar/grid-body/calendar-grid-body-custom-test.svelte.d.ts +18 -0
- package/dist/calendar/grid-body/calendar-grid-body.svelte +36 -0
- package/dist/calendar/grid-body/calendar-grid-body.svelte.d.ts +8 -0
- package/dist/calendar/grid-header/calendar-grid-header-custom-test.svelte +13 -0
- package/dist/calendar/grid-header/calendar-grid-header-custom-test.svelte.d.ts +18 -0
- package/dist/calendar/grid-header/calendar-grid-header.svelte +31 -0
- package/dist/calendar/grid-header/calendar-grid-header.svelte.d.ts +8 -0
- package/dist/calendar/header-cell/calendar-header-cell-test.svelte +11 -0
- package/dist/calendar/header-cell/calendar-header-cell-test.svelte.d.ts +18 -0
- package/dist/calendar/header-cell/calendar-header-cell.svelte +16 -0
- package/dist/calendar/header-cell/calendar-header-cell.svelte.d.ts +8 -0
- package/dist/calendar/heading/calendar-heading.svelte +17 -0
- package/dist/calendar/heading/calendar-heading.svelte.d.ts +5 -0
- package/dist/calendar/index.d.ts +13 -0
- package/dist/calendar/index.js +13 -0
- package/dist/calendar/index.parts.d.ts +9 -0
- package/dist/calendar/index.parts.js +9 -0
- package/dist/calendar/root/calendar-root-bind-value-test.svelte +14 -0
- package/dist/calendar/root/calendar-root-bind-value-test.svelte.d.ts +3 -0
- package/dist/calendar/root/calendar-root-controlled-clear-test.svelte +20 -0
- package/dist/calendar/root/calendar-root-controlled-clear-test.svelte.d.ts +3 -0
- package/dist/calendar/root/calendar-root-test.svelte +71 -0
- package/dist/calendar/root/calendar-root-test.svelte.d.ts +13 -0
- package/dist/calendar/root/calendar-root.svelte +143 -0
- package/dist/calendar/root/calendar-root.svelte.d.ts +31 -0
- package/dist/calendar/root/context.d.ts +66 -0
- package/dist/calendar/root/context.js +727 -0
- package/dist/calendar/root/date-utils.d.ts +17 -0
- package/dist/calendar/root/date-utils.js +94 -0
- package/dist/calendar/trigger-next/calendar-trigger-next.svelte +38 -0
- package/dist/calendar/trigger-next/calendar-trigger-next.svelte.d.ts +8 -0
- package/dist/calendar/trigger-previous/calendar-trigger-previous.svelte +38 -0
- package/dist/calendar/trigger-previous/calendar-trigger-previous.svelte.d.ts +8 -0
- package/dist/combobox/README.md +40 -0
- package/dist/combobox/TODO.md +28 -175
- package/dist/combobox/button/README.md +15 -0
- package/dist/combobox/button/combobox-button.svelte +2 -0
- package/dist/combobox/input/README.md +16 -0
- package/dist/combobox/item/README.md +27 -0
- package/dist/combobox/item-indicator/README.md +15 -0
- package/dist/combobox/list/README.md +27 -0
- package/dist/combobox/popover/README.md +13 -0
- package/dist/combobox/root/README.md +44 -0
- package/dist/combobox/root/combobox.svelte +30 -0
- package/dist/combobox/tag/README.md +37 -0
- package/dist/combobox/tag-remove/README.md +14 -0
- package/dist/combobox/tags/README.md +23 -0
- package/dist/datepicker/README.md +100 -0
- package/dist/datepicker/TODO.md +28 -0
- package/dist/datepicker/calendar/date-picker-calendar-unsafe-props-test.svelte +60 -0
- package/dist/datepicker/calendar/date-picker-calendar-unsafe-props-test.svelte.d.ts +3 -0
- package/dist/datepicker/calendar/date-picker-calendar.svelte +65 -0
- package/dist/datepicker/calendar/date-picker-calendar.svelte.d.ts +10 -0
- package/dist/datepicker/index.d.ts +18 -0
- package/dist/datepicker/index.js +18 -0
- package/dist/datepicker/index.parts.d.ts +14 -0
- package/dist/datepicker/index.parts.js +14 -0
- package/dist/datepicker/input/date-picker-input.svelte +108 -0
- package/dist/datepicker/input/date-picker-input.svelte.d.ts +11 -0
- package/dist/datepicker/internal/strict-props.d.ts +2 -0
- package/dist/datepicker/internal/strict-props.js +28 -0
- package/dist/datepicker/popover/date-picker-popover-handler-test.svelte +57 -0
- package/dist/datepicker/popover/date-picker-popover-handler-test.svelte.d.ts +3 -0
- package/dist/datepicker/popover/date-picker-popover-unsafe-props-test.svelte +45 -0
- package/dist/datepicker/popover/date-picker-popover-unsafe-props-test.svelte.d.ts +18 -0
- package/dist/datepicker/popover/date-picker-popover.svelte +87 -0
- package/dist/datepicker/popover/date-picker-popover.svelte.d.ts +7 -0
- package/dist/datepicker/root/context.d.ts +43 -0
- package/dist/datepicker/root/context.js +15 -0
- package/dist/datepicker/root/date-picker-bindable-empty-test.svelte +24 -0
- package/dist/datepicker/root/date-picker-bindable-empty-test.svelte.d.ts +3 -0
- package/dist/datepicker/root/date-picker-bindable-test.svelte +41 -0
- package/dist/datepicker/root/date-picker-bindable-test.svelte.d.ts +3 -0
- package/dist/datepicker/root/date-picker-empty-test.svelte +47 -0
- package/dist/datepicker/root/date-picker-empty-test.svelte.d.ts +3 -0
- package/dist/datepicker/root/date-picker-locale-typing-test.svelte +47 -0
- package/dist/datepicker/root/date-picker-locale-typing-test.svelte.d.ts +3 -0
- package/dist/datepicker/root/date-picker-open-cancel-test.svelte +54 -0
- package/dist/datepicker/root/date-picker-open-cancel-test.svelte.d.ts +8 -0
- package/dist/datepicker/root/date-picker-root.svelte +495 -0
- package/dist/datepicker/root/date-picker-root.svelte.d.ts +24 -0
- package/dist/datepicker/root/date-picker-test.svelte +86 -0
- package/dist/datepicker/root/date-picker-test.svelte.d.ts +13 -0
- package/dist/datepicker/root/date-utils.d.ts +17 -0
- package/dist/datepicker/root/date-utils.js +138 -0
- package/dist/datepicker/root/draft-evaluation.d.ts +13 -0
- package/dist/datepicker/root/draft-evaluation.js +56 -0
- package/dist/datepicker/root/focus-controller.d.ts +3 -0
- package/dist/datepicker/root/focus-controller.js +15 -0
- package/dist/datepicker/root/open-change.d.ts +5 -0
- package/dist/datepicker/root/open-change.js +13 -0
- package/dist/datepicker/root/open-controller.d.ts +7 -0
- package/dist/datepicker/root/open-controller.js +15 -0
- package/dist/datepicker/root/segment-controller.d.ts +8 -0
- package/dist/datepicker/root/segment-controller.js +53 -0
- package/dist/datepicker/root/segment-state.d.ts +18 -0
- package/dist/datepicker/root/segment-state.js +134 -0
- package/dist/datepicker/root/value-commit.d.ts +4 -0
- package/dist/datepicker/root/value-commit.js +8 -0
- package/dist/datepicker/segment/date-picker-segment.svelte +319 -0
- package/dist/datepicker/segment/date-picker-segment.svelte.d.ts +9 -0
- package/dist/datepicker/trigger/date-picker-trigger.svelte +110 -0
- package/dist/datepicker/trigger/date-picker-trigger.svelte.d.ts +9 -0
- package/dist/dialog/README.md +35 -0
- package/dist/dialog/content/README.md +16 -0
- package/dist/dialog/content/dialog-content.svelte +6 -6
- package/dist/dialog/overlay/README.md +13 -0
- package/dist/dialog/portal/README.md +12 -0
- package/dist/dialog/root/README.md +53 -0
- package/dist/dialog/root/context.d.ts +2 -1
- package/dist/dialog/root/dialog-root.svelte +9 -2
- package/dist/dialog/trigger/README.md +12 -0
- package/dist/dialog/trigger/dialog-trigger-multi-button-test.svelte +19 -0
- package/dist/dialog/trigger/dialog-trigger-multi-button-test.svelte.d.ts +18 -0
- package/dist/dialog/trigger/dialog-trigger.svelte +18 -6
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/listbox/README.md +26 -0
- package/dist/listbox/item/README.md +24 -0
- package/dist/listbox/root/README.md +40 -0
- package/dist/listbox/root/listbox.svelte +44 -0
- package/dist/locale-provider/context.d.ts +8 -0
- package/dist/locale-provider/context.js +18 -0
- package/dist/locale-provider/index.d.ts +4 -0
- package/dist/locale-provider/index.js +4 -0
- package/dist/locale-provider/locale-provider-initial-value-test.svelte +15 -0
- package/dist/locale-provider/locale-provider-initial-value-test.svelte.d.ts +7 -0
- package/dist/locale-provider/locale-provider-test.svelte +20 -0
- package/dist/locale-provider/locale-provider-test.svelte.d.ts +6 -0
- package/dist/locale-provider/locale-provider-value-probe.svelte +22 -0
- package/dist/locale-provider/locale-provider-value-probe.svelte.d.ts +6 -0
- package/dist/locale-provider/locale-provider.svelte +23 -0
- package/dist/locale-provider/locale-provider.svelte.d.ts +8 -0
- package/dist/popover/README.md +42 -0
- package/dist/popover/content/README.md +25 -0
- package/dist/popover/content/popover-content-standalone-test.svelte +28 -0
- package/dist/popover/content/popover-content-standalone-test.svelte.d.ts +6 -0
- package/dist/popover/content/popover-content-test.svelte +2 -1
- package/dist/popover/content/popover-content-test.svelte.d.ts +2 -1
- package/dist/popover/content/popover-content.svelte +91 -18
- package/dist/popover/content/popover-content.svelte.d.ts +5 -1
- package/dist/popover/index.d.ts +1 -1
- package/dist/popover/index.js +1 -3
- package/dist/popover/root/README.md +25 -0
- package/dist/popover/root/context.d.ts +16 -7
- package/dist/popover/root/context.js +0 -2
- package/dist/popover/root/focus-state.d.ts +4 -0
- package/dist/popover/root/focus-state.js +33 -0
- package/dist/popover/root/popover-root.svelte +90 -17
- package/dist/popover/root/popover-root.svelte.d.ts +2 -1
- package/dist/popover/root/popover-test.svelte +2 -1
- package/dist/popover/root/popover-test.svelte.d.ts +2 -1
- package/dist/popover/trigger/README.md +23 -0
- package/dist/popover/trigger/popover-trigger-button.svelte +10 -7
- package/dist/popover/trigger/popover-trigger-button.svelte.d.ts +2 -3
- package/dist/popover/trigger/popover-trigger-multi-button-test.svelte +16 -0
- package/dist/popover/trigger/popover-trigger-multi-button-test.svelte.d.ts +18 -0
- package/dist/popover/trigger/popover-trigger.svelte +19 -7
- package/dist/portal/portal.svelte +3 -1
- package/dist/primitives/click-outside.d.ts +1 -1
- package/dist/primitives/click-outside.js +1 -1
- package/dist/primitives/focus-trap.d.ts +7 -2
- package/dist/primitives/focus-trap.js +40 -6
- 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 +116 -0
- package/dist/test-utils/focus-contract.d.ts +3 -0
- package/dist/test-utils/focus-contract.js +26 -0
- package/dist/utils/date-only.d.ts +11 -0
- package/dist/utils/date-only.js +53 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +16 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Focus State Contract
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
Focus-state contract for composed and interactive library components.
|
|
6
|
+
|
|
7
|
+
## Canonical Attributes
|
|
8
|
+
|
|
9
|
+
- `data-focused`: focused interactive element (real focus or logical focus for active item).
|
|
10
|
+
- `data-focus-visible`: visible focus based on keyboard/screen-reader modality.
|
|
11
|
+
- `data-focus-within`: any descendant inside the composed container has focus.
|
|
12
|
+
|
|
13
|
+
## Serialization Rules
|
|
14
|
+
|
|
15
|
+
1. Attributes are serialized as presence (`"true"`) or absence.
|
|
16
|
+
2. Never serialize `"false"`.
|
|
17
|
+
|
|
18
|
+
## Invariants
|
|
19
|
+
|
|
20
|
+
1. On containers, `data-focus-visible` implies `data-focus-within`.
|
|
21
|
+
2. On items, `data-focus-visible` implies `data-focused`.
|
|
22
|
+
3. On external blur (focus leaves scope), clear container `data-focus-within` and `data-focus-visible`.
|
|
23
|
+
|
|
24
|
+
## Modality
|
|
25
|
+
|
|
26
|
+
- Keyboard/SR: may activate `data-focus-visible`.
|
|
27
|
+
- Pointer: should not activate `data-focus-visible` by default.
|
|
28
|
+
|
|
29
|
+
Canonical implementation lives in `primitives/input-modality.ts`:
|
|
30
|
+
|
|
31
|
+
- `trackInteractionModality(event, target)` records input modality transitions.
|
|
32
|
+
- `shouldShowFocusVisible(target)` resolves whether `data-focus-visible` should be shown.
|
|
33
|
+
- `focusWithModality(target, modality)` atomically sets modality + programmatic focus restore.
|
|
34
|
+
- Keep explicit `trackInteractionModality` calls in component keyboard/pointer handlers to guarantee deterministic modality updates before local focus-state logic runs.
|
|
35
|
+
|
|
36
|
+
## Restore focus
|
|
37
|
+
|
|
38
|
+
On overlay/popover close, transient trigger state is allowed:
|
|
39
|
+
|
|
40
|
+
- `escape-key` => `data-focused=true` and `data-focus-visible=true`.
|
|
41
|
+
- `outside-press` => `data-focused=true` and `data-focus-visible` absent.
|
|
42
|
+
|
|
43
|
+
## Recommended Implementation
|
|
44
|
+
|
|
45
|
+
- Native visual baseline: `:focus`, `:focus-visible`, `:focus-within`.
|
|
46
|
+
- Use `data-*` for composed state and restore semantics.
|
|
47
|
+
- Avoid overengineering: centralize minimal synchronization utilities and validate with contract tests.
|
|
48
|
+
|
|
49
|
+
## Operational Template
|
|
50
|
+
|
|
51
|
+
- Use `FOCUS_STATE_REVIEW_TEMPLATE.md` for PR/release reviews (modality matrix + component status + checklist).
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Focus State Review Template
|
|
2
|
+
|
|
3
|
+
## Usage
|
|
4
|
+
|
|
5
|
+
Template to validate focus-related changes without adding extra CI guardrails.
|
|
6
|
+
Fill this out for PRs that modify interaction, keyboard navigation, overlays, or focus-based styling.
|
|
7
|
+
|
|
8
|
+
## 1) Review Metadata
|
|
9
|
+
|
|
10
|
+
- PR/Branch:
|
|
11
|
+
- Component(s):
|
|
12
|
+
- Reviewer:
|
|
13
|
+
- Date:
|
|
14
|
+
- Verified browsers:
|
|
15
|
+
- [ ] Chromium
|
|
16
|
+
- [ ] Firefox
|
|
17
|
+
- [ ] WebKit/Safari
|
|
18
|
+
|
|
19
|
+
## 2) Minimum Modality Matrix (per component)
|
|
20
|
+
|
|
21
|
+
> Mark **OK/NA/FAIL** and add a short note when failing.
|
|
22
|
+
|
|
23
|
+
| Scenario | What to validate | Status | Note |
|
|
24
|
+
| ---------------------------------- | --------------------------------------------------------------------------- | ------ | ---- |
|
|
25
|
+
| Keyboard (Tab/Arrow/Home/End/Page) | `data-*` and ARIA stay in sync with logical focus | | |
|
|
26
|
+
| Pointer (click/mousedown) | do not elevate `data-focus-visible` by default | | |
|
|
27
|
+
| External blur | transient state cleanup (`data-focus-within`, `data-focus-visible`) | | |
|
|
28
|
+
| Close restore (`escape-key`) | trigger: `data-focused=true`, `data-focus-visible=true` (when applicable) | | |
|
|
29
|
+
| Close restore (`outside-press`) | trigger: `data-focused=true`, `data-focus-visible` absent (when applicable) | | |
|
|
30
|
+
| Programmatic focus | does not break invariants or leave stale state | | |
|
|
31
|
+
|
|
32
|
+
## 3) Required Invariants
|
|
33
|
+
|
|
34
|
+
- [ ] Never serialize `'false'` for `data-focused`, `data-focus-visible`, `data-focus-within`.
|
|
35
|
+
- [ ] On containers: `data-focus-visible => data-focus-within`.
|
|
36
|
+
- [ ] On items: `data-focus-visible => data-focused`.
|
|
37
|
+
- [ ] No visible desync between real focus, logical focus, and `data-*` attributes.
|
|
38
|
+
|
|
39
|
+
## 4) Component Status (living status)
|
|
40
|
+
|
|
41
|
+
> Use one row per component touched or audited.
|
|
42
|
+
|
|
43
|
+
| Component | Status | Current coverage | Residual risk | Owner |
|
|
44
|
+
| ---------- | --------------------------------- | ---------------- | --------------- | ----- |
|
|
45
|
+
| DatePicker | Contract-ready / Partial / Legacy | tests + manual | low/medium/high | |
|
|
46
|
+
| Popover | Contract-ready / Partial / Legacy | tests + manual | low/medium/high | |
|
|
47
|
+
| ListBox | Contract-ready / Partial / Legacy | tests + manual | low/medium/high | |
|
|
48
|
+
| ComboBox | Contract-ready / Partial / Legacy | tests + manual | low/medium/high | |
|
|
49
|
+
| Dialog | Contract-ready / Partial / Legacy | tests + manual | low/medium/high | |
|
|
50
|
+
| Calendar | Contract-ready / Partial / Legacy | tests + manual | low/medium/high | |
|
|
51
|
+
|
|
52
|
+
## 5) PR Checklist
|
|
53
|
+
|
|
54
|
+
- [ ] If focus/keyboard/overlay behavior changed, tests were added or updated.
|
|
55
|
+
- [ ] Shared helper was used: `src/lib/test-utils/focus-contract.ts`.
|
|
56
|
+
- [ ] Focused suites for affected components were run.
|
|
57
|
+
- [ ] If the change was cross-cutting, full package test suite was run.
|
|
58
|
+
|
|
59
|
+
## 6) Suggested Commands
|
|
60
|
+
|
|
61
|
+
- Focused (example):
|
|
62
|
+
- `bun run test -- --run src/lib/datepicker src/lib/popover src/lib/listbox src/lib/combobox src/lib/dialog src/lib/calendar`
|
|
63
|
+
- Full:
|
|
64
|
+
- `bun run test -- --run`
|
|
65
|
+
|
|
66
|
+
## 7) Final Decision
|
|
67
|
+
|
|
68
|
+
- Final status: [ ] Approved [ ] Approved with risk [ ] Blocked
|
|
69
|
+
- Residual risk summary:
|
|
70
|
+
- Follow-up actions:
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Calendar
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`Calendar` provides single-date and range selection (ISO `YYYY-MM-DD`) with keyboard navigation, controlled/uncontrolled state, and part-based composition.
|
|
6
|
+
|
|
7
|
+
## Usage Guidelines
|
|
8
|
+
|
|
9
|
+
- Use `Calendar.Root` as the stateful container.
|
|
10
|
+
- `selectionMode` supports `'single'` (default) and `'range'`.
|
|
11
|
+
- In controlled mode, use `value` with `onChange`; in uncontrolled mode, use `defaultValue`.
|
|
12
|
+
- In `single` mode, `value/defaultValue` is `YYYY-MM-DD`.
|
|
13
|
+
- In `range` mode, `value/defaultValue` is `{ start?: 'YYYY-MM-DD', end?: 'YYYY-MM-DD' }`.
|
|
14
|
+
- `visibleMonths` controls how many months are rendered and how paging behaves.
|
|
15
|
+
- `showOutsideDays` controls whether days outside the current month are shown; default is `false`.
|
|
16
|
+
- `isDateUnavailable` marks specific days as non-focusable and non-selectable.
|
|
17
|
+
- Use `LocaleProvider` to localize month/day labels and first day of week.
|
|
18
|
+
- Keyboard navigation uses `Arrow` keys for day/week movement and `Home/End` for month edges.
|
|
19
|
+
|
|
20
|
+
## Accessibility
|
|
21
|
+
|
|
22
|
+
- Each `grid` exposes an accessible name using the visible month heading.
|
|
23
|
+
- Today exposes `aria-current="date"`.
|
|
24
|
+
- Unavailable cells expose `aria-disabled="true"`. According to ARIA Grid specifications, disabled cells remain focusable so that screen reader users can spatially navigate and discover them, but they are not selectable.
|
|
25
|
+
|
|
26
|
+
### Keyboard
|
|
27
|
+
|
|
28
|
+
- `ArrowRight/ArrowLeft`: move focus by +/- 1 day.
|
|
29
|
+
- `ArrowDown/ArrowUp`: move focus by +/- 7 days.
|
|
30
|
+
- `Home/End`: move focus to first/last day of month.
|
|
31
|
+
- `PageUp/PageDown`: move to previous/next month while trying to preserve day number.
|
|
32
|
+
- `Enter` or `Space`: select the focused date (if selectable).
|
|
33
|
+
- In `selectionMode="range"`, `Arrow/Page/Home/End` extend preview range while a range is pending.
|
|
34
|
+
- In `selectionMode="range"`, `Enter` or `Space` confirm the preview when pending.
|
|
35
|
+
|
|
36
|
+
## Internal Notes
|
|
37
|
+
|
|
38
|
+
- `PageUp/PageDown` try to preserve the day when crossing months; if no focusable target exists in the destination month and a range is pending, focus falls back to the reachable edge in the current month (aligned with `Home/End` behavior).
|
|
39
|
+
- In `selectionMode="range"`, the first click starts the range (`start`) and the second click confirms it (`end`), with automatic normalization for reversed selection order.
|
|
40
|
+
- In `selectionMode="range"`, hover updates a live preview before confirmation.
|
|
41
|
+
|
|
42
|
+
## Anatomy
|
|
43
|
+
|
|
44
|
+
- `Calendar.Root`
|
|
45
|
+
- `Calendar.TriggerPrevious`
|
|
46
|
+
- `Calendar.Heading`
|
|
47
|
+
- `Calendar.TriggerNext`
|
|
48
|
+
- `Calendar.Grid`
|
|
49
|
+
- `Calendar.GridHeader`
|
|
50
|
+
- `Calendar.HeaderCell`
|
|
51
|
+
- `Calendar.GridBody`
|
|
52
|
+
- `Calendar.BodyCell`
|
|
53
|
+
|
|
54
|
+
```svelte
|
|
55
|
+
<LocaleProvider locale="es-ES">
|
|
56
|
+
<Calendar.Root>
|
|
57
|
+
<Calendar.TriggerPrevious />
|
|
58
|
+
<Calendar.Heading />
|
|
59
|
+
<Calendar.TriggerNext />
|
|
60
|
+
<Calendar.Grid>
|
|
61
|
+
<Calendar.GridHeader />
|
|
62
|
+
<Calendar.GridBody />
|
|
63
|
+
</Calendar.Grid>
|
|
64
|
+
</Calendar.Root>
|
|
65
|
+
</LocaleProvider>
|
|
66
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Calendar TODO
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Track Calendar work with a single mandatory TODO format.
|
|
6
|
+
|
|
7
|
+
## Backlog
|
|
8
|
+
|
|
9
|
+
- [x] [M][P0][Area: Core API][Owner: Unassigned][Target: Done] Implement controlled/uncontrolled root (`value`, `defaultValue`, `onChange`).
|
|
10
|
+
- [x] [M][P0][Area: Navigation][Owner: Unassigned][Target: Done] Implement paginated navigation via `visibleMonths`.
|
|
11
|
+
- [x] [M][P0][Area: Selection][Owner: Unassigned][Target: Done] Implement single-date selection.
|
|
12
|
+
- [x] [M][P0][Area: State][Owner: Unassigned][Target: Done] Support `isDisabled`, `isReadOnly`, and `isDateUnavailable`.
|
|
13
|
+
- [x] [M][P0][Area: Accessibility][Owner: Unassigned][Target: Done] Deliver keyboard-accessible grid baseline.
|
|
14
|
+
- [x] [M][P0][Area: Delivery][Owner: Unassigned][Target: Done] Ship exports, docs page, and initial tests.
|
|
15
|
+
- [x] [S][P1][Area: Selection][Owner: Unassigned][Target: Done] Implement range selection.
|
|
16
|
+
- [ ] [S][P1][Area: Selection][Owner: Unassigned][Target: TBD] Implement multi-select mode.
|
|
17
|
+
- [ ] [C][P2][Area: Internationalization][Owner: Unassigned][Target: TBD] Add non-Gregorian calendar configuration.
|
|
18
|
+
- [ ] [S][P1][Area: Availability API][Owner: Unassigned][Target: TBD] Add advanced unavailable API (set/ranges/rules).
|
|
19
|
+
- [ ] [M][P0][Area: Availability API][Owner: Unassigned][Target: TBD] Keep backward compatibility with `isDateUnavailable`.
|
|
20
|
+
- [ ] [M][P0][Area: Performance][Owner: Unassigned][Target: TBD] Compile unavailability config to cached predicate with proper invalidation.
|
|
21
|
+
- [ ] [M][P0][Area: Testing][Owner: Unassigned][Target: TBD] Add coverage for unavailable parser, composition rules, and interaction flows.
|
|
22
|
+
- [ ] [S][P1][Area: Documentation][Owner: Unassigned][Target: TBD] Document advanced unavailable API with migration examples.
|
|
23
|
+
- [ ] [C][P2][Area: Demo][Owner: Unassigned][Target: TBD] Extend docs demo with unavailable strategy examples.
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
const ariaDateFormatterCache: Record<string, Intl.DateTimeFormat> = Object.create(null);
|
|
3
|
+
|
|
4
|
+
function getAriaDateFormatter(locale: string): Intl.DateTimeFormat {
|
|
5
|
+
let formatter = ariaDateFormatterCache[locale];
|
|
6
|
+
if (!formatter) {
|
|
7
|
+
formatter = new Intl.DateTimeFormat(locale, {
|
|
8
|
+
dateStyle: 'full',
|
|
9
|
+
timeZone: 'UTC'
|
|
10
|
+
});
|
|
11
|
+
ariaDateFormatterCache[locale] = formatter;
|
|
12
|
+
}
|
|
13
|
+
return formatter;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function formatAriaDateLabel(locale: string, date: string): string {
|
|
17
|
+
const [yearText, monthText, dayText] = date.split('-');
|
|
18
|
+
const year = Number(yearText);
|
|
19
|
+
const month = Number(monthText);
|
|
20
|
+
const day = Number(dayText);
|
|
21
|
+
|
|
22
|
+
if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day)) {
|
|
23
|
+
return date;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const parsed = new Date(Date.UTC(year, month - 1, day));
|
|
27
|
+
if (Number.isNaN(parsed.getTime())) return date;
|
|
28
|
+
|
|
29
|
+
return getAriaDateFormatter(locale).format(parsed);
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<script lang="ts">
|
|
34
|
+
import type { Snippet } from 'svelte';
|
|
35
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
36
|
+
import { useCalendarContext } from '../root/context';
|
|
37
|
+
import { getCalendarMonthIndex } from '../grid/month-scope';
|
|
38
|
+
import { formatCalendarDate, getTodayUtcDate, parseCalendarDate } from '../root/date-utils';
|
|
39
|
+
import {
|
|
40
|
+
shouldShowFocusVisible,
|
|
41
|
+
trackInteractionModality
|
|
42
|
+
} from '../../primitives/input-modality';
|
|
43
|
+
|
|
44
|
+
type CalendarBodyCellProps = Omit<HTMLAttributes<HTMLTableCellElement>, 'children'> & {
|
|
45
|
+
date: string;
|
|
46
|
+
children?: Snippet<[string]>;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
let { date, children, class: className = '', ...restProps }: CalendarBodyCellProps = $props();
|
|
50
|
+
|
|
51
|
+
const calendar = useCalendarContext();
|
|
52
|
+
const layoutVersion = calendar.layoutVersion;
|
|
53
|
+
const selectionVersion = calendar.selectionVersion;
|
|
54
|
+
const monthIndex = getCalendarMonthIndex();
|
|
55
|
+
|
|
56
|
+
const parsedDate = $derived(parseCalendarDate(date));
|
|
57
|
+
const dayLabel = $derived(parsedDate ? String(parsedDate.getUTCDate()) : '');
|
|
58
|
+
const isSelected = $derived.by(() => {
|
|
59
|
+
void $layoutVersion;
|
|
60
|
+
void $selectionVersion;
|
|
61
|
+
if (calendar.isDisabled || calendar.isReadOnly) return false;
|
|
62
|
+
return calendar.isSelected(date);
|
|
63
|
+
});
|
|
64
|
+
const isRangeStart = $derived.by(() => {
|
|
65
|
+
void $layoutVersion;
|
|
66
|
+
void $selectionVersion;
|
|
67
|
+
if (calendar.isDisabled || calendar.isReadOnly) return false;
|
|
68
|
+
return calendar.isRangeStart(date);
|
|
69
|
+
});
|
|
70
|
+
const isRangeEnd = $derived.by(() => {
|
|
71
|
+
void $layoutVersion;
|
|
72
|
+
void $selectionVersion;
|
|
73
|
+
if (calendar.isDisabled || calendar.isReadOnly) return false;
|
|
74
|
+
return calendar.isRangeEnd(date);
|
|
75
|
+
});
|
|
76
|
+
const isInRange = $derived.by(() => {
|
|
77
|
+
void $layoutVersion;
|
|
78
|
+
void $selectionVersion;
|
|
79
|
+
if (calendar.isDisabled || calendar.isReadOnly) return false;
|
|
80
|
+
return calendar.isInRange(date);
|
|
81
|
+
});
|
|
82
|
+
const isFocused = $derived.by(() => {
|
|
83
|
+
void $selectionVersion;
|
|
84
|
+
return calendar.focusedValue === date;
|
|
85
|
+
});
|
|
86
|
+
const isFocusVisible = $derived.by(() => {
|
|
87
|
+
void $selectionVersion;
|
|
88
|
+
return calendar.focusVisible;
|
|
89
|
+
});
|
|
90
|
+
const isVisuallyFocused = $derived(isFocused && isFocusVisible);
|
|
91
|
+
const isDisabled = $derived.by(() => {
|
|
92
|
+
void $layoutVersion;
|
|
93
|
+
void $selectionVersion;
|
|
94
|
+
return calendar.isDateDisabled(date);
|
|
95
|
+
});
|
|
96
|
+
const isUnavailable = $derived.by(() => {
|
|
97
|
+
void $layoutVersion;
|
|
98
|
+
return calendar.isDateUnavailable(date);
|
|
99
|
+
});
|
|
100
|
+
const isAriaDisabled = $derived(isDisabled || isUnavailable);
|
|
101
|
+
const isOutsideMonth = $derived.by(() => {
|
|
102
|
+
void $layoutVersion;
|
|
103
|
+
return calendar.isOutsideVisibleRange(date, monthIndex);
|
|
104
|
+
});
|
|
105
|
+
const showOutsideDays = $derived.by(() => {
|
|
106
|
+
void $layoutVersion;
|
|
107
|
+
return calendar.showOutsideDays;
|
|
108
|
+
});
|
|
109
|
+
const hidesOutsideDay = $derived(isOutsideMonth && !showOutsideDays);
|
|
110
|
+
const isSelectionDisabled = $derived(isDisabled || hidesOutsideDay);
|
|
111
|
+
const isFocusDisabled = $derived(calendar.isDisabled || hidesOutsideDay);
|
|
112
|
+
const todayDate = formatCalendarDate(getTodayUtcDate());
|
|
113
|
+
const isToday = $derived(date === todayDate);
|
|
114
|
+
const ariaDateLabel = $derived.by(() => {
|
|
115
|
+
void $layoutVersion;
|
|
116
|
+
return formatAriaDateLabel(calendar.locale, date);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
let gridCellElement = $state<HTMLDivElement | undefined>(undefined);
|
|
120
|
+
|
|
121
|
+
$effect(() => {
|
|
122
|
+
if (!isFocused || isFocusDisabled) return;
|
|
123
|
+
if (!gridCellElement) return;
|
|
124
|
+
if (document.activeElement === gridCellElement) return;
|
|
125
|
+
gridCellElement.focus();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
$effect(() => {
|
|
129
|
+
if (!isFocusDisabled) return;
|
|
130
|
+
if (!gridCellElement) return;
|
|
131
|
+
if (document.activeElement !== gridCellElement) return;
|
|
132
|
+
gridCellElement.blur();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
function handleClick() {
|
|
136
|
+
if (isFocusDisabled) return;
|
|
137
|
+
calendar.setFocusedValue(date);
|
|
138
|
+
if (!isSelectionDisabled) {
|
|
139
|
+
calendar.selectDate(date);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function handleFocus() {
|
|
144
|
+
if (isFocusDisabled) return;
|
|
145
|
+
calendar.setFocusedValue(date);
|
|
146
|
+
calendar.setFocusVisible(shouldShowFocusVisible(gridCellElement ?? null));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function handleMousedown(event: MouseEvent) {
|
|
150
|
+
trackInteractionModality(event, gridCellElement ?? null);
|
|
151
|
+
calendar.setFocusVisible(false);
|
|
152
|
+
if (isSelectionDisabled) {
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function handleMouseenter() {
|
|
158
|
+
if (isFocusDisabled) return;
|
|
159
|
+
calendar.setHoveredValue(date);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function handleMouseleave() {
|
|
163
|
+
if (isFocusDisabled) return;
|
|
164
|
+
calendar.setHoveredValue(undefined);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
168
|
+
if (isFocusDisabled) return;
|
|
169
|
+
trackInteractionModality(event, gridCellElement ?? null);
|
|
170
|
+
calendar.handleCellKeydown(event, date);
|
|
171
|
+
}
|
|
172
|
+
</script>
|
|
173
|
+
|
|
174
|
+
<td
|
|
175
|
+
role="presentation"
|
|
176
|
+
data-selected={isSelected || undefined}
|
|
177
|
+
data-focused={isFocused || undefined}
|
|
178
|
+
data-focus-visible={isVisuallyFocused || undefined}
|
|
179
|
+
data-disabled={isAriaDisabled || undefined}
|
|
180
|
+
data-unavailable={isUnavailable || undefined}
|
|
181
|
+
data-outside-month={isOutsideMonth || undefined}
|
|
182
|
+
data-range-start={isRangeStart || undefined}
|
|
183
|
+
data-range-end={isRangeEnd || undefined}
|
|
184
|
+
data-in-range={isInRange || undefined}
|
|
185
|
+
{...restProps}
|
|
186
|
+
>
|
|
187
|
+
{#if hidesOutsideDay}
|
|
188
|
+
<div
|
|
189
|
+
class={className}
|
|
190
|
+
role="presentation"
|
|
191
|
+
data-disabled={true}
|
|
192
|
+
data-outside-month={true}
|
|
193
|
+
aria-hidden="true"
|
|
194
|
+
></div>
|
|
195
|
+
{:else}
|
|
196
|
+
<div
|
|
197
|
+
bind:this={gridCellElement}
|
|
198
|
+
class={className}
|
|
199
|
+
role="gridcell"
|
|
200
|
+
tabindex={isFocusDisabled ? -1 : isFocused ? 0 : -1}
|
|
201
|
+
data-selected={isSelected || undefined}
|
|
202
|
+
data-focused={isFocused || undefined}
|
|
203
|
+
data-focus-visible={isVisuallyFocused || undefined}
|
|
204
|
+
data-disabled={isAriaDisabled || hidesOutsideDay || undefined}
|
|
205
|
+
data-unavailable={isUnavailable || undefined}
|
|
206
|
+
data-outside-month={isOutsideMonth || undefined}
|
|
207
|
+
data-range-start={isRangeStart || undefined}
|
|
208
|
+
data-range-end={isRangeEnd || undefined}
|
|
209
|
+
data-in-range={isInRange || undefined}
|
|
210
|
+
data-date={date}
|
|
211
|
+
aria-selected={isSelected}
|
|
212
|
+
aria-disabled={isAriaDisabled || hidesOutsideDay || undefined}
|
|
213
|
+
aria-current={isToday ? 'date' : undefined}
|
|
214
|
+
aria-label={ariaDateLabel}
|
|
215
|
+
style={isVisuallyFocused ? undefined : 'outline: none;'}
|
|
216
|
+
onmousedown={handleMousedown}
|
|
217
|
+
onmouseenter={handleMouseenter}
|
|
218
|
+
onmouseleave={handleMouseleave}
|
|
219
|
+
onclick={handleClick}
|
|
220
|
+
onfocus={handleFocus}
|
|
221
|
+
onkeydown={handleKeydown}
|
|
222
|
+
>
|
|
223
|
+
{#if children}
|
|
224
|
+
{@render children(date)}
|
|
225
|
+
{:else}
|
|
226
|
+
{dayLabel}
|
|
227
|
+
{/if}
|
|
228
|
+
</div>
|
|
229
|
+
{/if}
|
|
230
|
+
</td>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
type CalendarBodyCellProps = Omit<HTMLAttributes<HTMLTableCellElement>, 'children'> & {
|
|
4
|
+
date: string;
|
|
5
|
+
children?: Snippet<[string]>;
|
|
6
|
+
};
|
|
7
|
+
declare const CalendarBodyCell: import("svelte").Component<CalendarBodyCellProps, {}, "">;
|
|
8
|
+
type CalendarBodyCell = ReturnType<typeof CalendarBodyCell>;
|
|
9
|
+
export default CalendarBodyCell;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { setCalendarMonthIndex } from './month-scope';
|
|
4
|
+
|
|
5
|
+
type CalendarGridMonthScopeProps = {
|
|
6
|
+
monthIndex: number;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const props: CalendarGridMonthScopeProps = $props();
|
|
11
|
+
setCalendarMonthIndex(props.monthIndex);
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
{#if props.children}
|
|
15
|
+
{@render props.children()}
|
|
16
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type CalendarGridMonthScopeProps = {
|
|
3
|
+
monthIndex: number;
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const CalendarGridMonthScope: import("svelte").Component<CalendarGridMonthScopeProps, {}, "">;
|
|
7
|
+
type CalendarGridMonthScope = ReturnType<typeof CalendarGridMonthScope>;
|
|
8
|
+
export default CalendarGridMonthScope;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { useCalendarContext } from '../root/context';
|
|
4
|
+
import CalendarGridMonthScope from './calendar-grid-month-scope.svelte';
|
|
5
|
+
|
|
6
|
+
type CalendarGridProps = {
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
class?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let { children, class: className = '' }: CalendarGridProps = $props();
|
|
12
|
+
const calendar = useCalendarContext();
|
|
13
|
+
const layoutVersion = calendar.layoutVersion;
|
|
14
|
+
const months = $derived.by(() => {
|
|
15
|
+
void $layoutVersion;
|
|
16
|
+
return calendar.months;
|
|
17
|
+
});
|
|
18
|
+
const selectionMode = $derived.by(() => {
|
|
19
|
+
void $layoutVersion;
|
|
20
|
+
return calendar.selectionMode;
|
|
21
|
+
});
|
|
22
|
+
const isReadOnly = $derived.by(() => {
|
|
23
|
+
void $layoutVersion;
|
|
24
|
+
return calendar.isReadOnly;
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div class={className} data-calendar-grid>
|
|
29
|
+
{#each months as month (month.monthIndex)}
|
|
30
|
+
<div role="group" aria-label={month.heading} data-calendar-month={month.monthIndex}>
|
|
31
|
+
<CalendarGridMonthScope monthIndex={month.monthIndex}>
|
|
32
|
+
<table
|
|
33
|
+
role="grid"
|
|
34
|
+
aria-label={month.heading}
|
|
35
|
+
aria-readonly={isReadOnly || undefined}
|
|
36
|
+
aria-multiselectable={selectionMode === 'range' ? true : undefined}
|
|
37
|
+
>
|
|
38
|
+
{#if children}
|
|
39
|
+
{@render children()}
|
|
40
|
+
{/if}
|
|
41
|
+
</table>
|
|
42
|
+
</CalendarGridMonthScope>
|
|
43
|
+
</div>
|
|
44
|
+
{/each}
|
|
45
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type CalendarGridProps = {
|
|
3
|
+
children?: Snippet;
|
|
4
|
+
class?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const CalendarGrid: import("svelte").Component<CalendarGridProps, {}, "">;
|
|
7
|
+
type CalendarGrid = ReturnType<typeof CalendarGrid>;
|
|
8
|
+
export default CalendarGrid;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const MONTH_SCOPE_KEY = Symbol('calendar-month-scope');
|
|
3
|
+
export function setCalendarMonthIndex(monthIndex) {
|
|
4
|
+
setContext(MONTH_SCOPE_KEY, monthIndex);
|
|
5
|
+
}
|
|
6
|
+
export function getCalendarMonthIndex() {
|
|
7
|
+
return getContext(MONTH_SCOPE_KEY) ?? 0;
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Calendar from '../index';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<Calendar.Root defaultValue="2026-02-10" aria-label="Body custom test">
|
|
6
|
+
<Calendar.Grid>
|
|
7
|
+
<Calendar.GridBody>
|
|
8
|
+
{#snippet children(date)}
|
|
9
|
+
<Calendar.BodyCell {date}>{date}</Calendar.BodyCell>
|
|
10
|
+
{/snippet}
|
|
11
|
+
</Calendar.GridBody>
|
|
12
|
+
</Calendar.Grid>
|
|
13
|
+
</Calendar.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 CalendarGridBodyCustomTest: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type CalendarGridBodyCustomTest = InstanceType<typeof CalendarGridBodyCustomTest>;
|
|
18
|
+
export default CalendarGridBodyCustomTest;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { useCalendarContext } from '../root/context';
|
|
4
|
+
import { getCalendarMonthIndex } from '../grid/month-scope';
|
|
5
|
+
import CalendarBodyCell from '../body-cell/calendar-body-cell.svelte';
|
|
6
|
+
|
|
7
|
+
type CalendarGridBodyProps = {
|
|
8
|
+
children?: Snippet<[string]>;
|
|
9
|
+
class?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
let { children, class: className = '' }: CalendarGridBodyProps = $props();
|
|
13
|
+
|
|
14
|
+
const calendar = useCalendarContext();
|
|
15
|
+
const layoutVersion = calendar.layoutVersion;
|
|
16
|
+
const monthIndex = getCalendarMonthIndex();
|
|
17
|
+
const month = $derived.by(() => {
|
|
18
|
+
void $layoutVersion;
|
|
19
|
+
return calendar.months[monthIndex];
|
|
20
|
+
});
|
|
21
|
+
const weeks = $derived(month?.weeks ?? []);
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<tbody class={className}>
|
|
25
|
+
{#each weeks as week, weekIndex (weekIndex)}
|
|
26
|
+
<tr data-week={weekIndex}>
|
|
27
|
+
{#each week as day (day.date)}
|
|
28
|
+
{#if children}
|
|
29
|
+
{@render children(day.date)}
|
|
30
|
+
{:else}
|
|
31
|
+
<CalendarBodyCell date={day.date} />
|
|
32
|
+
{/if}
|
|
33
|
+
{/each}
|
|
34
|
+
</tr>
|
|
35
|
+
{/each}
|
|
36
|
+
</tbody>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type CalendarGridBodyProps = {
|
|
3
|
+
children?: Snippet<[string]>;
|
|
4
|
+
class?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const CalendarGridBody: import("svelte").Component<CalendarGridBodyProps, {}, "">;
|
|
7
|
+
type CalendarGridBody = ReturnType<typeof CalendarGridBody>;
|
|
8
|
+
export default CalendarGridBody;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Calendar from '../index';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<Calendar.Root defaultValue="2026-02-10" aria-label="Header custom test">
|
|
6
|
+
<Calendar.Grid>
|
|
7
|
+
<Calendar.GridHeader>
|
|
8
|
+
{#snippet children(day)}
|
|
9
|
+
<Calendar.HeaderCell>DAY-{day}</Calendar.HeaderCell>
|
|
10
|
+
{/snippet}
|
|
11
|
+
</Calendar.GridHeader>
|
|
12
|
+
</Calendar.Grid>
|
|
13
|
+
</Calendar.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 CalendarGridHeaderCustomTest: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type CalendarGridHeaderCustomTest = InstanceType<typeof CalendarGridHeaderCustomTest>;
|
|
18
|
+
export default CalendarGridHeaderCustomTest;
|