@jcsoftdev/ui 0.3.0 → 0.4.0
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/CHANGELOG.md +103 -1
- package/README.md +55 -2
- package/bin/ui-theme.mjs +13 -2
- package/dist/atoms/checkbox/checkbox.js +3 -1
- package/dist/atoms/chip/chip.d.ts +11 -3
- package/dist/atoms/chip/chip.js +8 -1
- package/dist/atoms/chip/index.d.ts +1 -1
- package/dist/atoms/chip/index.js +2 -0
- package/dist/atoms/due-chip/due-chip.d.ts +31 -0
- package/dist/atoms/due-chip/due-chip.js +41 -0
- package/dist/atoms/due-chip/index.d.ts +2 -0
- package/dist/atoms/due-chip/index.js +6 -0
- package/dist/atoms/due-chip/model.d.ts +25 -0
- package/dist/atoms/due-chip/model.js +44 -0
- package/dist/atoms/icon-button/icon-button.d.ts +22 -0
- package/dist/atoms/icon-button/icon-button.js +38 -0
- package/dist/atoms/icon-button/index.d.ts +1 -0
- package/dist/atoms/icon-button/index.js +8 -0
- package/dist/atoms/index.d.ts +5 -0
- package/dist/atoms/index.js +5 -0
- package/dist/atoms/internal/hit-area.d.ts +6 -0
- package/dist/atoms/internal/hit-area.js +4 -0
- package/dist/atoms/kbd/index.d.ts +1 -0
- package/dist/atoms/kbd/index.js +4 -0
- package/dist/atoms/kbd/kbd.d.ts +7 -0
- package/dist/atoms/kbd/kbd.js +17 -0
- package/dist/atoms/radio-group/radio-group.js +6 -2
- package/dist/atoms/seal/index.d.ts +1 -0
- package/dist/atoms/seal/index.js +4 -0
- package/dist/atoms/seal/seal.d.ts +30 -0
- package/dist/atoms/seal/seal.js +71 -0
- package/dist/atoms/spinner/index.d.ts +1 -0
- package/dist/atoms/spinner/index.js +5 -0
- package/dist/atoms/spinner/spinner.d.ts +19 -0
- package/dist/atoms/spinner/spinner.js +31 -0
- package/dist/atoms/switch/switch.js +3 -1
- package/dist/calendar/date-calendar/date-calendar.d.ts +32 -0
- package/dist/calendar/date-calendar/date-calendar.js +189 -0
- package/dist/calendar/date-calendar/index.d.ts +1 -0
- package/dist/calendar/date-calendar/index.js +6 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +1 -0
- package/dist/calendar/internal/date-utils.d.ts +26 -0
- package/dist/calendar/internal/date-utils.js +95 -1
- package/dist/containers/aside/aside.d.ts +14 -0
- package/dist/containers/aside/aside.js +25 -0
- package/dist/containers/aside/index.d.ts +1 -0
- package/dist/containers/aside/index.js +5 -0
- package/dist/containers/banner/banner.d.ts +4 -1
- package/dist/containers/banner/banner.js +9 -1
- package/dist/containers/description-list/description-list.d.ts +29 -6
- package/dist/containers/description-list/description-list.js +47 -6
- package/dist/containers/feed/feed.d.ts +23 -0
- package/dist/containers/feed/feed.js +77 -0
- package/dist/containers/feed/index.d.ts +2 -0
- package/dist/containers/feed/index.js +10 -0
- package/dist/containers/feed/model.d.ts +19 -0
- package/dist/containers/feed/model.js +38 -0
- package/dist/containers/index.d.ts +6 -0
- package/dist/containers/index.js +6 -0
- package/dist/containers/kpi/kpi.d.ts +50 -8
- package/dist/containers/kpi/kpi.js +91 -39
- package/dist/containers/list-detail/index.d.ts +1 -0
- package/dist/containers/list-detail/index.js +20 -0
- package/dist/containers/list-detail/list-detail.d.ts +55 -0
- package/dist/containers/list-detail/list-detail.js +221 -0
- package/dist/containers/note/index.d.ts +1 -0
- package/dist/containers/note/index.js +4 -0
- package/dist/containers/note/note.d.ts +13 -0
- package/dist/containers/note/note.js +27 -0
- package/dist/containers/section/index.d.ts +1 -0
- package/dist/containers/section/index.js +6 -0
- package/dist/containers/section/section.d.ts +68 -0
- package/dist/containers/section/section.js +198 -0
- package/dist/containers/shortcuts/index.d.ts +1 -0
- package/dist/containers/shortcuts/index.js +8 -0
- package/dist/containers/shortcuts/shortcuts.d.ts +18 -0
- package/dist/containers/shortcuts/shortcuts.js +50 -0
- package/dist/containers/table/selection.d.ts +9 -0
- package/dist/containers/table/selection.js +20 -0
- package/dist/containers/table/table.d.ts +66 -4
- package/dist/containers/table/table.js +128 -7
- package/dist/containers/timeline/index.d.ts +1 -1
- package/dist/containers/timeline/index.js +4 -2
- package/dist/containers/timeline/timeline.d.ts +32 -5
- package/dist/containers/timeline/timeline.js +154 -90
- package/dist/forms/chip-group/chip-group.d.ts +54 -0
- package/dist/forms/chip-group/chip-group.js +114 -0
- package/dist/forms/chip-group/index.d.ts +1 -0
- package/dist/forms/chip-group/index.js +6 -0
- package/dist/forms/combobox/combobox.d.ts +60 -0
- package/dist/forms/combobox/combobox.js +281 -0
- package/dist/forms/combobox/index.d.ts +1 -0
- package/dist/forms/combobox/index.js +6 -0
- package/dist/forms/date-picker/date-picker.d.ts +40 -0
- package/dist/forms/date-picker/date-picker.js +183 -0
- package/dist/forms/date-picker/date-time-picker.d.ts +43 -0
- package/dist/forms/date-picker/date-time-picker.js +121 -0
- package/dist/forms/date-picker/index.d.ts +2 -0
- package/dist/forms/date-picker/index.js +10 -0
- package/dist/forms/date-picker/model.d.ts +35 -0
- package/dist/forms/date-picker/model.js +83 -0
- package/dist/forms/dropzone/dropzone.d.ts +30 -2
- package/dist/forms/dropzone/dropzone.js +153 -23
- package/dist/forms/field/field.d.ts +16 -10
- package/dist/forms/field/field.js +41 -5
- package/dist/forms/index.d.ts +4 -0
- package/dist/forms/index.js +4 -0
- package/dist/forms/input/index.d.ts +1 -1
- package/dist/forms/input/index.js +4 -1
- package/dist/forms/input/input.d.ts +21 -5
- package/dist/forms/input/input.js +74 -9
- package/dist/forms/input-icon/input-icon.d.ts +1 -1
- package/dist/forms/internal/listbox-items.d.ts +18 -0
- package/dist/forms/internal/listbox-items.js +88 -0
- package/dist/forms/internal/listbox.d.ts +44 -0
- package/dist/forms/internal/listbox.js +74 -0
- package/dist/forms/number-stepper/model.d.ts +16 -0
- package/dist/forms/number-stepper/model.js +23 -0
- package/dist/forms/number-stepper/number-stepper.d.ts +36 -6
- package/dist/forms/number-stepper/number-stepper.js +86 -37
- package/dist/forms/select-menu/index.d.ts +1 -0
- package/dist/forms/select-menu/index.js +6 -0
- package/dist/forms/select-menu/select-menu.d.ts +35 -0
- package/dist/forms/select-menu/select-menu.js +230 -0
- package/dist/i18n/strings.d.ts +89 -0
- package/dist/i18n/strings.js +54 -2
- package/dist/i18n/ui-strings-provider.d.ts +1 -1
- package/dist/i18n/ui-strings-provider.js +6 -2
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/stepper/index.d.ts +1 -1
- package/dist/navigation/stepper/index.js +3 -1
- package/dist/navigation/stepper/stepper.d.ts +8 -0
- package/dist/navigation/stepper/stepper.js +68 -45
- package/dist/navigation/tabs/index.d.ts +1 -0
- package/dist/navigation/tabs/index.js +6 -0
- package/dist/navigation/tabs/tabs-nav.d.ts +37 -0
- package/dist/navigation/tabs/tabs-nav.js +57 -0
- package/dist/navigation/wizard/index.d.ts +1 -0
- package/dist/navigation/wizard/index.js +6 -0
- package/dist/navigation/wizard/model.d.ts +33 -0
- package/dist/navigation/wizard/model.js +34 -0
- package/dist/navigation/wizard/wizard.d.ts +45 -0
- package/dist/navigation/wizard/wizard.js +169 -0
- package/dist/overlays/alert-dialog/alert-dialog.d.ts +103 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +342 -0
- package/dist/overlays/alert-dialog/index.d.ts +1 -0
- package/dist/overlays/alert-dialog/index.js +26 -0
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +17 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +12 -4
- package/dist/overlays/dropdown-menu/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/index.js +8 -2
- package/dist/overlays/index.d.ts +2 -0
- package/dist/overlays/index.js +2 -0
- package/dist/overlays/testing/index.d.ts +5 -0
- package/dist/overlays/testing/index.js +4 -0
- package/dist/overlays/toaster/index.d.ts +2 -1
- package/dist/overlays/toaster/index.js +4 -2
- package/dist/overlays/toaster/toast-store.d.ts +6 -2
- package/dist/overlays/toaster/toast.d.ts +3 -0
- package/dist/overlays/toaster/toast.js +3 -0
- package/dist/overlays/toaster/toaster.d.ts +3 -0
- package/dist/overlays/toaster/toaster.js +36 -3
- package/dist/overlays/tooltip/index.d.ts +1 -0
- package/dist/overlays/tooltip/index.js +4 -0
- package/dist/overlays/tooltip/model.d.ts +10 -0
- package/dist/overlays/tooltip/model.js +13 -0
- package/dist/overlays/tooltip/tooltip.d.ts +41 -0
- package/dist/overlays/tooltip/tooltip.js +116 -0
- package/dist/primitives/use-dismissable-layer.js +1 -1
- package/dist/states/error-state/error-state.d.ts +6 -1
- package/dist/states/error-state/error-state.js +13 -9
- package/dist/states/skeleton/skeleton.d.ts +8 -2
- package/dist/states/skeleton/skeleton.js +44 -2
- package/package.json +2 -2
- package/scripts/build-theme.mjs +12 -1
- package/src/atoms/checkbox/checkbox.tsx +3 -1
- package/src/atoms/chip/chip.tsx +18 -3
- package/src/atoms/chip/index.ts +2 -0
- package/src/atoms/due-chip/due-chip.tsx +75 -0
- package/src/atoms/due-chip/index.ts +2 -0
- package/src/atoms/due-chip/model.ts +67 -0
- package/src/atoms/icon-button/icon-button.tsx +58 -0
- package/src/atoms/icon-button/index.ts +6 -0
- package/src/atoms/index.ts +5 -0
- package/src/atoms/internal/hit-area.ts +7 -0
- package/src/atoms/kbd/index.ts +1 -0
- package/src/atoms/kbd/kbd.tsx +20 -0
- package/src/atoms/radio-group/radio-group.tsx +8 -2
- package/src/atoms/seal/index.ts +1 -0
- package/src/atoms/seal/seal.tsx +107 -0
- package/src/atoms/spinner/index.ts +1 -0
- package/src/atoms/spinner/spinner.tsx +49 -0
- package/src/atoms/switch/switch.tsx +3 -1
- package/src/calendar/date-calendar/date-calendar.tsx +230 -0
- package/src/calendar/date-calendar/index.ts +5 -0
- package/src/calendar/index.ts +1 -0
- package/src/calendar/internal/date-utils.ts +115 -0
- package/src/containers/aside/aside.tsx +40 -0
- package/src/containers/aside/index.ts +1 -0
- package/src/containers/banner/banner.tsx +18 -1
- package/src/containers/description-list/description-list.tsx +85 -9
- package/src/containers/feed/feed.tsx +99 -0
- package/src/containers/feed/index.ts +8 -0
- package/src/containers/feed/model.ts +54 -0
- package/src/containers/index.ts +6 -0
- package/src/containers/kpi/kpi.tsx +161 -62
- package/src/containers/list-detail/index.ts +15 -0
- package/src/containers/list-detail/list-detail.tsx +293 -0
- package/src/containers/note/index.ts +1 -0
- package/src/containers/note/note.tsx +38 -0
- package/src/containers/section/index.ts +11 -0
- package/src/containers/section/section.tsx +281 -0
- package/src/containers/shortcuts/index.ts +6 -0
- package/src/containers/shortcuts/shortcuts.tsx +92 -0
- package/src/containers/table/selection.ts +26 -0
- package/src/containers/table/table.tsx +215 -13
- package/src/containers/timeline/index.ts +3 -0
- package/src/containers/timeline/timeline.tsx +204 -93
- package/src/forms/chip-group/chip-group.tsx +184 -0
- package/src/forms/chip-group/index.ts +8 -0
- package/src/forms/combobox/combobox.tsx +359 -0
- package/src/forms/combobox/index.ts +7 -0
- package/src/forms/date-picker/date-picker.tsx +239 -0
- package/src/forms/date-picker/date-time-picker.tsx +178 -0
- package/src/forms/date-picker/index.ts +10 -0
- package/src/forms/date-picker/model.ts +108 -0
- package/src/forms/dropzone/dropzone.tsx +217 -35
- package/src/forms/field/field.tsx +72 -7
- package/src/forms/index.ts +4 -0
- package/src/forms/input/index.ts +8 -1
- package/src/forms/input/input.tsx +97 -12
- package/src/forms/input-icon/input-icon.tsx +1 -1
- package/src/forms/internal/listbox-items.tsx +103 -0
- package/src/forms/internal/listbox.ts +124 -0
- package/src/forms/number-stepper/model.ts +35 -0
- package/src/forms/number-stepper/number-stepper.tsx +132 -42
- package/src/forms/select-menu/index.ts +7 -0
- package/src/forms/select-menu/select-menu.tsx +280 -0
- package/src/i18n/strings.ts +89 -0
- package/src/i18n/ui-strings-provider.tsx +15 -4
- package/src/navigation/index.ts +1 -0
- package/src/navigation/stepper/index.ts +7 -1
- package/src/navigation/stepper/stepper.tsx +41 -5
- package/src/navigation/tabs/index.ts +7 -0
- package/src/navigation/tabs/tabs-nav.tsx +131 -0
- package/src/navigation/wizard/index.ts +7 -0
- package/src/navigation/wizard/model.ts +61 -0
- package/src/navigation/wizard/wizard.tsx +222 -0
- package/src/overlays/alert-dialog/alert-dialog.tsx +486 -0
- package/src/overlays/alert-dialog/index.ts +19 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +29 -4
- package/src/overlays/dropdown-menu/index.ts +3 -0
- package/src/overlays/index.ts +2 -0
- package/src/overlays/testing/index.ts +5 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toast-store.ts +6 -2
- package/src/overlays/toaster/toast.ts +6 -0
- package/src/overlays/toaster/toaster.tsx +44 -2
- package/src/overlays/tooltip/index.ts +1 -0
- package/src/overlays/tooltip/model.ts +18 -0
- package/src/overlays/tooltip/tooltip.tsx +166 -0
- package/src/primitives/use-dismissable-layer.ts +7 -2
- package/src/states/error-state/error-state.tsx +19 -8
- package/src/states/skeleton/skeleton.tsx +68 -2
- package/styles/tailwind.css +33 -30
- package/styles/theme.css +33 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,108 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.4.0 (2026-10-21)
|
|
4
|
+
|
|
5
|
+
### Blocks for application screens
|
|
6
|
+
|
|
7
|
+
New components, all additive and source compatible, with no new runtime dependency. Defaults come
|
|
8
|
+
from `UiStringsProvider` (en/es), layout follows container queries, and hit areas follow
|
|
9
|
+
`data-density="touch"`. Guide with examples: `/docs/blocks/`.
|
|
10
|
+
|
|
11
|
+
#### Added
|
|
12
|
+
|
|
13
|
+
- **Atoms.** `Spinner` (`size`, `label`, decorative `label={false}`), `Kbd`, `IconButton`
|
|
14
|
+
(required `label`, `variant`, `size`, `loading`, `asChild`, `iconButtonSizeClasses`), `DueChip`
|
|
15
|
+
(`date`, `today`, `soonDays`, `done`, `locale`) and `Seal` (`title`, `icon`, `tone`, `label`).
|
|
16
|
+
- **Overlays.** `Tooltip` (`content`, `shortcut`, `side`, `align`, `openDelay`, `closeDelay`,
|
|
17
|
+
controlled `open`) and `AlertDialog` (`role="alertdialog"`, `tone`, async `onConfirm` with a
|
|
18
|
+
pending state and inline failure message, focus on Cancel).
|
|
19
|
+
- **Forms.** `SelectMenu` (custom listbox select over `options`), `Combobox` (filter, async
|
|
20
|
+
`onSearchChange`, `loading`, `clearable`, `valueLabel`), `DatePicker` and `DateTimePicker` (ISO
|
|
21
|
+
values, `min`, `max`, `isDateDisabled`, locale-derived format and week start, time-zone safe) and
|
|
22
|
+
`ChipGroup` (multiple or single toggle chips with roving focus).
|
|
23
|
+
- **Calendar.** `DateCalendar`, the standalone keyboard date grid behind the pickers.
|
|
24
|
+
- **Navigation.** `Wizard` (`steps`, async `canAdvance`, `onBeforeNext`, `onComplete`) and
|
|
25
|
+
`TabsNav` / `TabsNavLink` (link strip with `aria-current="page"`, `renderLink`, `asChild`).
|
|
26
|
+
- **Containers.** `Section`, `Note`, `Aside` / `AsideHeader`, `ListDetail` (with its parts and
|
|
27
|
+
`useListDetail`), `Feed` / `FeedEvent` and `Shortcuts` / `ShortcutsItem`.
|
|
28
|
+
- **Banner `appearance="outline"`.** Page surface where only the border carries the tone (default
|
|
29
|
+
`soft`).
|
|
30
|
+
- **`DescriptionList`** `layout` (`auto`, `inline`, `stacked`), `columns` (1 to 3), `valueAlign` and
|
|
31
|
+
`DescriptionListItem` (dash placeholder for `null`, `undefined`, `false` and `""`).
|
|
32
|
+
- **`Chip` `size="sm"`** and `chipSizeClasses`; `ref` is a regular prop.
|
|
33
|
+
- **`Skeleton` variants** `list`, `kpis`, `key-value` and `bar`, with `count`.
|
|
34
|
+
- **`ErrorState` `actions`.**
|
|
35
|
+
- **Toast tones.** `toast.info`, `toast.warning`, `toast.danger` and `toastToneClasses`.
|
|
36
|
+
- **`resetToasts()`** in the new `@jcsoftdev/ui/overlays/testing` entry, for resetting the toast
|
|
37
|
+
store between tests.
|
|
38
|
+
- **Form gaps found while migrating an app.** `Input` takes `start` / `end` adornments, a
|
|
39
|
+
30px `size="xs"` and `variant="bare"`; `Dropzone` has `mode="field"` (a real labelled
|
|
40
|
+
`<input type="file">` with `accept`, `multiple`, `onChange` and removable selections);
|
|
41
|
+
`NumberStepper` has a string mode (`mode="string"`: empty state, caller-owned text, change event);
|
|
42
|
+
`Field` accepts a node `label` and several children.
|
|
43
|
+
- **Table.** `flush` (`true`, `"start"`, `"end"`) drops the outer cell padding so the first and last
|
|
44
|
+
column sit on the container edge; `stickyHeader`; `maxHeight` (the capped wrapper is focusable);
|
|
45
|
+
row selection with `selectedKeys`, `defaultSelectedKeys`, `onSelectedKeysChange`, `rowKey` on
|
|
46
|
+
`TableRow` / `TableLinkRow` (`aria-selected`), `TableSelectCell` and `TableSelectAllCell` (checked,
|
|
47
|
+
mixed, unchecked); `TableActionsCell`, which wraps inline actions under a narrow table container
|
|
48
|
+
(a named container query) or swaps them for an overflow `menu` you pass.
|
|
49
|
+
- **Section parts.** `Section.Header`, `.Title`, `.Count`, `.Description`, `.Actions` and `.Body`
|
|
50
|
+
next to the props API; a part as a direct child switches to composed rendering.
|
|
51
|
+
- **Kpi parts and chrome.** `Kpi.Label`, `.Value` (`mono`, `suffix`, `trend`) and `.Description`;
|
|
52
|
+
`card` (border and radius); `trailing` (content at the end of the label row that stays exposed to
|
|
53
|
+
assistive tech, unlike the decorative `icon`).
|
|
54
|
+
- **Timeline** `status` per item (`done`, `current`, `error`, `pending`) with a glyph, a spoken state
|
|
55
|
+
and `aria-current="step"`, and `Timeline.Item` children next to `items`.
|
|
56
|
+
- **Stepper** `status` per step (`done`, `current`, `error`, `pending`) with a check or cross and a
|
|
57
|
+
spoken state; the default stays `current` for `currentStepId` and `pending` otherwise.
|
|
58
|
+
- **AlertDialog** `confirmDisabled` and `cancelDisabled`, and a compound API: `AlertDialog.Root`,
|
|
59
|
+
`.Trigger`, `.Content`, `.Header`, `.Title`, `.Description`, `.Body`, `.Footer`, `.Cancel` and
|
|
60
|
+
`.Action`. Cancel and Action close the dialog after their `onClick` unless it calls
|
|
61
|
+
`preventDefault()`; use the props API for an async confirm with a pending state.
|
|
62
|
+
- **ListDetail** `onBack`.
|
|
63
|
+
- **DueChip** `state` forces `overdue`, `soon`, `ok` or `done` whatever the date says.
|
|
64
|
+
- **Seal** `tone="institutional"` (strong neutral, ink frame) and any tone declared in
|
|
65
|
+
`tonePalettes`, by name, as `Kpi` does.
|
|
66
|
+
- **DropdownMenu** `bare` content (layering and size limits only, so a custom menu draws its own
|
|
67
|
+
surface), `DropdownMenuAnchor`, and `dropdownMenuItemClasses` / `dropdownMenuSurfaceClasses`.
|
|
68
|
+
- **UI strings** (en/es) for the new components: `noResults`, `clear`, `selectPlaceholder`,
|
|
69
|
+
`calendar`, `openCalendar`, `previousMonth`, `nextMonth`, `time`, `locale`, the day, month and
|
|
70
|
+
year placeholders, `back`, `next`, `finish`, `stepOf`, `steps`, `aside`, `backToList`, `overdue`,
|
|
71
|
+
`dueSoon`, `stepDone`, `stepError`, `selectRow`, `selectAll` and `rowActions`.
|
|
72
|
+
|
|
73
|
+
#### Changed (behavior to check when upgrading)
|
|
74
|
+
|
|
75
|
+
- **`ErrorState` markup.** The retry button now sits inside a wrapper `div` that also holds
|
|
76
|
+
`actions`. Selectors or tests that expect the button as a direct child need updating.
|
|
77
|
+
- **Toast tint.** Success and error toasts are tinted with their tone (`*-soft` surface, tone
|
|
78
|
+
border, status glyph) instead of the inverted neutral look. `default` is unchanged and roles are
|
|
79
|
+
unchanged (only error is an alert).
|
|
80
|
+
- **`Checkbox` and `Switch` touch target.** The 44px target is an invisible `::after` of the control
|
|
81
|
+
instead of a larger root, so under touch density the layout box is 40px (it was 44px) and the hit
|
|
82
|
+
target can overlap a neighbour by 2px per side. Default density is unchanged.
|
|
83
|
+
- **`Section` `divider` is off by default.** A kit whose section header always drew a hairline
|
|
84
|
+
needs `divider`.
|
|
85
|
+
- **`RadioGroup`** radios now carry `aria-labelledby` and `aria-describedby`, so they have
|
|
86
|
+
accessible names without relying on `<label for>`.
|
|
87
|
+
- **`theme.css` no longer emits self-referencing variables.** Entries such as
|
|
88
|
+
`--radius-input: var(--radius-input)` (radii, shadows, `--font-sans`) now sit in an
|
|
89
|
+
`@theme reference inline` block, so the utilities resolve to the raw token and nothing is declared
|
|
90
|
+
in Tailwind's theme layer. Consumers no longer need to reorder layers; verified on Tailwind 4.3.3.
|
|
91
|
+
- **Locale reaches the date pickers.** `UiStringsProvider` ignores `undefined` and empty entries
|
|
92
|
+
instead of letting them overwrite the preset, so `strings={{ locale: undefined }}` no longer sends
|
|
93
|
+
Intl to the system locale; its context is shared across duplicate module copies.
|
|
94
|
+
- **`Combobox` `required`** sets `aria-required` only and no longer blocks native submit before your
|
|
95
|
+
own validation; `nativeRequired` opts back in.
|
|
96
|
+
- **`Section` and titleless wrappers.** A `Section` with no title no longer takes a heading level or
|
|
97
|
+
tightens the spacing of what it wraps, so a titled section inside a wrapper keeps the level it
|
|
98
|
+
would have had without it (it moves up one level compared with the earlier 0.3.0 previews).
|
|
99
|
+
- **`ListDetail` back action.** It calls `onBack` and never `onValueChange(null)`; `onValueChange`
|
|
100
|
+
is typed `(value: string) => void`. Both only affect the earlier 0.3.0 previews, since `ListDetail`
|
|
101
|
+
is new in 0.3.0.
|
|
102
|
+
- **`Table` selected rows.** A row with a `rowKey` in a table with selection props reports
|
|
103
|
+
`aria-selected` and highlights; tables without selection props render as before.
|
|
104
|
+
- **Escape inside the library's own comboboxes.** The dismissable-layer primitive no longer treats
|
|
105
|
+
the library's own open `role="combobox"` widgets as a foreign layer, so Escape closes them.
|
|
4
106
|
|
|
5
107
|
### Components for app shells
|
|
6
108
|
|
package/README.md
CHANGED
|
@@ -52,6 +52,8 @@ npx ui-theme build my-tokens.json --out src/theme # optional: your own look (d
|
|
|
52
52
|
@source "../node_modules/@jcsoftdev/ui/dist"; /* lets Tailwind see the classes used by the components */
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
Import order is free: `theme.css` declares nothing in Tailwind's `theme` layer that points back at itself (tokens such as `--radius-input` are mapped with `@theme reference inline`, so `rounded-input` reads the raw variable directly). `tokens.css` and `base.css` can sit unlayered, or in a layer of your own (`@import "…/tokens.css" layer(ui);`) declared before or after `theme`, with no `@layer` reordering and no re-declared names. Verified with Tailwind 4.3.3.
|
|
56
|
+
|
|
55
57
|
```tsx
|
|
56
58
|
import { Button } from "@jcsoftdev/ui/atoms/button";
|
|
57
59
|
<Button variant="primary">Save</Button>;
|
|
@@ -147,9 +149,60 @@ older components already ship (NumberStepper, Carousel, AI set) are not routed t
|
|
|
147
149
|
| --- | --- |
|
|
148
150
|
| `Button` | `loadingLabel` (shown instead of the children while `loading`, announced through a status region), `block` (full width), `size="lg"` (52px at normal density, scaled like the other controls). |
|
|
149
151
|
| `Field` | `optional` appends the localized "(optional)" marker to the label; `error` also accepts `null`. |
|
|
150
|
-
| `Banner` | `title`; a default glyph per tone when `icon` is not passed (`icon={null}` hides it, so status never relies on color alone); only `danger` is `role="alert"`, the rest are `role="status"`; the `info` tone uses the `info` tokens. |
|
|
152
|
+
| `Banner` | `appearance="outline"` (page surface, only the border carries the tone; default `soft`), `title`; a default glyph per tone when `icon` is not passed (`icon={null}` hides it, so status never relies on color alone); only `danger` is `role="alert"`, the rest are `role="status"`; the `info` tone uses the `info` tokens. |
|
|
151
153
|
| `Chip` | `icon`, `statusIcon` (prefixes `info`, `success`, `warning`, `danger` chips with their glyph), and an `info` tone. |
|
|
152
|
-
| `ErrorState` | `title` and `description` (`message` keeps working as the headline)
|
|
154
|
+
| `ErrorState` | `title` and `description` (`message` keeps working as the headline), `actions`; an `Error` or any non-renderable value is never printed, a generic localized sentence is shown instead. |
|
|
155
|
+
|
|
156
|
+
## Blocks for application screens (additive)
|
|
157
|
+
|
|
158
|
+
New components, all zero-dependency, localized through `UiStringsProvider`, laid out with container
|
|
159
|
+
queries and sized for touch density. Props, accessibility notes and type-checked examples:
|
|
160
|
+
https://ui.jcsoftdev.com/docs/blocks/
|
|
161
|
+
|
|
162
|
+
| Component | Entry | What it is |
|
|
163
|
+
| --- | --- | --- |
|
|
164
|
+
| `Spinner`, `Kbd` | `atoms` | Loading ring (`size`, `label`, `label={false}` for decorative) and a styled `<kbd>`. |
|
|
165
|
+
| `IconButton` | `atoms` | Square `Button` with a required `label` (`aria-label`), `variant`, `size`, `loading`. |
|
|
166
|
+
| `DueChip` | `atoms` | Due-date chip: overdue, soon (`soonDays`) and ok states with a glyph and sr-only suffix; time-zone safe. |
|
|
167
|
+
| `Seal` | `atoms` | Stamp mark: `title`, `icon`, `tone`, optional named `label`. |
|
|
168
|
+
| `Tooltip` | `overlays` | Hover and focus tip: `content`, `shortcut`, `side`, `openDelay`, `closeDelay`; `role="tooltip"`. |
|
|
169
|
+
| `AlertDialog` | `overlays` | `role="alertdialog"` with cancel and confirm, `tone="danger"`, async `onConfirm` with a pending state. |
|
|
170
|
+
| `SelectMenu` | `forms` | Custom listbox select over `options` (groups, disabled options, typeahead, hidden `name` input). |
|
|
171
|
+
| `Combobox` | `forms` | Filterable, async-friendly (`onSearchChange`, `loading`), `clearable`, `emptyText`. |
|
|
172
|
+
| `DatePicker`, `DateTimePicker` | `forms` | Typed masked input plus calendar popover; ISO values, `min`, `max`, `isDateDisabled`, locale week start. |
|
|
173
|
+
| `DateCalendar` | `calendar` | Standalone keyboard date grid behind the pickers. |
|
|
174
|
+
| `ChipGroup` | `forms` | Multi or single toggle chips (`aria-pressed`, roving focus, `count`, `name`). |
|
|
175
|
+
| `Wizard` | `navigation` | `Stepper` plus Back/Next/Finish: `steps`, async `canAdvance`, `onBeforeNext`, `onComplete`. |
|
|
176
|
+
| `TabsNav`, `TabsNavLink` | `navigation` | Link-mode sub-navigation strip (`aria-current="page"`, `renderLink` or `asChild`). |
|
|
177
|
+
| `Section`, `Note`, `Aside` | `containers` | Titled block with `actions` and optional `divider`, a text note with a `tone`, and a complementary region. |
|
|
178
|
+
| `ListDetail` | `containers` | Master-detail that collapses to one pane under 641px of its own width. |
|
|
179
|
+
| `Feed`, `FeedEvent` | `containers` | Activity log with a mark, text and `<time>` (absolute or `relative`). |
|
|
180
|
+
| `Shortcuts`, `ShortcutsItem` | `containers` | Link or button tiles with `icon`, `count`, `kbd`. |
|
|
181
|
+
|
|
182
|
+
Additive props on existing components:
|
|
183
|
+
|
|
184
|
+
| Component | Added |
|
|
185
|
+
| --- | --- |
|
|
186
|
+
| `DescriptionList` | `layout` (`auto`, `inline`, `stacked`), `columns` (1 to 3), `valueAlign` (`end`, `start`); `DescriptionListItem` with a dash placeholder for empty values. |
|
|
187
|
+
| `Chip` | `size="sm"` (compact; a tag is `<Chip size="sm" square>`). |
|
|
188
|
+
| `Skeleton` | `variant` `list`, `kpis`, `key-value`, `bar` and `count`. |
|
|
189
|
+
| `ErrorState` | `actions` node, rendered in the same row as the retry button (the retry button now sits inside a wrapper `div`). |
|
|
190
|
+
| `RadioGroup` | Each radio is named by its label and described by its description. |
|
|
191
|
+
| `Checkbox`, `Switch` | The 44px touch target is an invisible `::after`; under touch density the layout box stays 40px. |
|
|
192
|
+
| `Table` | `flush` (`true`, `"start"`, `"end"`), `stickyHeader`, `maxHeight`, selection (`selectedKeys`, `defaultSelectedKeys`, `onSelectedKeysChange`, `rowKey`, `TableSelectCell`, `TableSelectAllCell`), `TableActionsCell` (wraps, or swaps for your overflow `menu`, under a narrow table container). |
|
|
193
|
+
| `Section` | Parts `Section.Header`, `.Title`, `.Count`, `.Description`, `.Actions`, `.Body` next to the props; a titleless wrapper takes no heading level. |
|
|
194
|
+
| `Kpi` | Parts `Kpi.Label`, `.Value` (`mono`, `suffix`, `trend`), `.Description`; `card` chrome; `trailing` slot. |
|
|
195
|
+
| `Timeline` | `status` per item (`done`, `current`, `error`, `pending`) and `Timeline.Item` children. |
|
|
196
|
+
| `Stepper` | `status` per step with a glyph and a spoken state. |
|
|
197
|
+
| `AlertDialog` | `confirmDisabled`, `cancelDisabled`; compound `AlertDialog.Root`, `.Trigger`, `.Content`, `.Title`, `.Description`, `.Cancel`, `.Action`. |
|
|
198
|
+
| `ListDetail` | `onBack` for the back action; `onValueChange` never receives `null`. |
|
|
199
|
+
| `DueChip` | `state` forces `overdue`, `soon`, `ok` or `done`. |
|
|
200
|
+
| `Seal` | `tone="institutional"` and any `tonePalettes` tone by name. |
|
|
201
|
+
| `DropdownMenu` | `DropdownMenuContent bare` (no panel look), `DropdownMenuAnchor`, `dropdownMenuItemClasses`, `dropdownMenuSurfaceClasses` for custom menus. |
|
|
202
|
+
| `toast` | `toast.info`, `toast.warning`, `toast.danger`; success, info, warning and error toasts are tinted with a glyph. |
|
|
203
|
+
|
|
204
|
+
In tests, reset the toast store with `import { resetToasts } from "@jcsoftdev/ui/overlays/testing"`
|
|
205
|
+
(kept off the `overlays` entry so production bundles never carry it).
|
|
153
206
|
|
|
154
207
|
## ConfirmAction and ResponsiveList
|
|
155
208
|
|
package/bin/ui-theme.mjs
CHANGED
|
@@ -792,12 +792,23 @@ function buildThemeCss(tokens2) {
|
|
|
792
792
|
);
|
|
793
793
|
const tail = utilities.length ? `
|
|
794
794
|
${utilities.join("\n\n")}
|
|
795
|
+
` : "";
|
|
796
|
+
const selfReference = (l) => {
|
|
797
|
+
const m = /^\s*(--[\w-]+): var\((--[\w-]+)\);$/.exec(l);
|
|
798
|
+
return m !== null && m[1] === m[2];
|
|
799
|
+
};
|
|
800
|
+
const mapped = lines.filter((l) => !selfReference(l));
|
|
801
|
+
const same = lines.filter(selfReference);
|
|
802
|
+
const reference = same.length ? `
|
|
803
|
+
@theme reference inline {
|
|
804
|
+
${same.join("\n")}
|
|
805
|
+
}
|
|
795
806
|
` : "";
|
|
796
807
|
return `/* Generated by ui-theme from "${tokens2.name}". Do not edit. */
|
|
797
808
|
@theme inline {
|
|
798
|
-
${
|
|
809
|
+
${mapped.join("\n")}
|
|
799
810
|
}
|
|
800
|
-
${tail}`;
|
|
811
|
+
${reference}${tail}`;
|
|
801
812
|
}
|
|
802
813
|
function buildFontsCss(tokens2) {
|
|
803
814
|
const imports = (tokens2.type?.fonts ?? []).filter((f) => f.source === "google").map((f) => `@import url("https://fonts.googleapis.com/css2?family=${f.spec}&display=swap");`);
|
|
@@ -6,6 +6,7 @@ import { cn } from "../../utils/cn.js";
|
|
|
6
6
|
import { composeHandlers, useComposedRefs } from "../../utils/compose.js";
|
|
7
7
|
import { BubbleInput, useFormBubble, useFormReset } from "../../utils/form-bubble.js";
|
|
8
8
|
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
9
|
+
import { touchHitArea } from "../internal/hit-area.js";
|
|
9
10
|
function getState(checked) {
|
|
10
11
|
return checked === "indeterminate" ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
11
12
|
}
|
|
@@ -56,7 +57,8 @@ function Checkbox({
|
|
|
56
57
|
...props,
|
|
57
58
|
ref: composedRef,
|
|
58
59
|
className: cn(
|
|
59
|
-
|
|
60
|
+
touchHitArea,
|
|
61
|
+
"group inline-flex size-10 shrink-0 items-center justify-center disabled:cursor-not-allowed disabled:opacity-50",
|
|
60
62
|
classNames?.root,
|
|
61
63
|
className
|
|
62
64
|
),
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
2
|
export type ChipBuiltinTone = "neutral" | "danger" | "warning" | "success" | "accent" | "info" | "solid" | "outline";
|
|
3
3
|
/** A built-in tone, or the name of a tone declared in `tonePalettes`. */
|
|
4
4
|
export type ChipTone = ChipBuiltinTone | (string & {});
|
|
5
5
|
/** Class map behind each `tone`; exported so apps can extend or reuse it. */
|
|
6
6
|
export declare const chipToneClasses: Readonly<Record<ChipBuiltinTone, string>>;
|
|
7
|
-
export
|
|
7
|
+
export type ChipSize = "sm" | "md";
|
|
8
|
+
/** Class map behind each `size`; exported like `chipToneClasses`. */
|
|
9
|
+
export declare const chipSizeClasses: Readonly<Record<ChipSize, string>>;
|
|
10
|
+
export interface ChipProps extends ComponentPropsWithRef<"span"> {
|
|
8
11
|
tone?: ChipTone;
|
|
12
|
+
/**
|
|
13
|
+
* `sm` is the compact tag: it grows with its content, tightens the padding and uses tabular
|
|
14
|
+
* numerals, so codes, counts and ids line up. Pair it with `square` and a neutral tone for a tag.
|
|
15
|
+
*/
|
|
16
|
+
size?: ChipSize;
|
|
9
17
|
/** Use the smaller chip radius instead of a full pill. */
|
|
10
18
|
square?: boolean;
|
|
11
19
|
/** Leading decorative icon; wins over `statusIcon`. */
|
|
@@ -17,4 +25,4 @@ export interface ChipProps extends ComponentPropsWithoutRef<"span"> {
|
|
|
17
25
|
/** Accessible name of the remove button. Defaults to the localized "Remove". */
|
|
18
26
|
removeLabel?: string;
|
|
19
27
|
}
|
|
20
|
-
export declare function Chip({ tone, square, icon, statusIcon: withStatusIcon, onRemove, removeLabel, className, style, children, ...props }: ChipProps): import("react").JSX.Element;
|
|
28
|
+
export declare function Chip({ tone, size, square, icon, statusIcon: withStatusIcon, onRemove, removeLabel, className, style, children, ...props }: ChipProps): import("react").JSX.Element;
|
package/dist/atoms/chip/chip.js
CHANGED
|
@@ -15,10 +15,15 @@ const chipToneClasses = {
|
|
|
15
15
|
solid: "bg-accent text-on-accent",
|
|
16
16
|
outline: "bg-transparent text-ink-2 shadow-[inset_0_0_0_1px_var(--line-strong)]"
|
|
17
17
|
};
|
|
18
|
+
const chipSizeClasses = {
|
|
19
|
+
md: "h-6 px-2.5 font-[650] text-fs-120",
|
|
20
|
+
sm: "h-auto min-h-5 px-1.5 py-px font-medium text-fs-115 tabular-nums"
|
|
21
|
+
};
|
|
18
22
|
const statusTones = /* @__PURE__ */ new Set(["info", "success", "warning", "danger"]);
|
|
19
23
|
const builtinTones = new Set(Object.keys(chipToneClasses));
|
|
20
24
|
function Chip({
|
|
21
25
|
tone = "neutral",
|
|
26
|
+
size = "md",
|
|
22
27
|
square,
|
|
23
28
|
icon,
|
|
24
29
|
statusIcon: withStatusIcon,
|
|
@@ -37,7 +42,8 @@ function Chip({
|
|
|
37
42
|
"span",
|
|
38
43
|
{
|
|
39
44
|
className: cn(
|
|
40
|
-
"inline-flex
|
|
45
|
+
"inline-flex max-w-full items-center gap-1.5 overflow-hidden whitespace-nowrap leading-none [&_svg]:size-3",
|
|
46
|
+
chipSizeClasses[size],
|
|
41
47
|
square ? "rounded-chip" : "rounded-badge",
|
|
42
48
|
custom ? "bg-(--tone-c-soft) text-(--tone-c-ink)" : chipToneClasses[tone] ?? chipToneClasses.neutral,
|
|
43
49
|
(interactive || onRemove) && "in-data-[density=touch]:min-h-11",
|
|
@@ -65,5 +71,6 @@ function Chip({
|
|
|
65
71
|
}
|
|
66
72
|
export {
|
|
67
73
|
Chip,
|
|
74
|
+
chipSizeClasses,
|
|
68
75
|
chipToneClasses
|
|
69
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Chip, type ChipBuiltinTone, type ChipProps, type ChipTone, chipToneClasses, } from "./chip.js";
|
|
1
|
+
export { Chip, type ChipBuiltinTone, type ChipProps, type ChipSize, type ChipTone, chipSizeClasses, chipToneClasses, } from "./chip.js";
|
package/dist/atoms/chip/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type ChipProps } from "../chip/chip.js";
|
|
3
|
+
import { type DueState } from "./model.js";
|
|
4
|
+
export type { DueState } from "./model.js";
|
|
5
|
+
export interface DueChipProps extends Omit<ChipProps, "tone" | "children" | "onRemove" | "statusIcon"> {
|
|
6
|
+
/** Due date: "2026-03-04", a naive date-time "2026-03-04T17:00", or an ISO instant (read in the viewer's zone). */
|
|
7
|
+
date: string;
|
|
8
|
+
/**
|
|
9
|
+
* Reference day ("YYYY-MM-DD") the state is measured from. Defaults to the viewer's today;
|
|
10
|
+
* pass it for deterministic output (server render, tests, "as of" views).
|
|
11
|
+
*/
|
|
12
|
+
today?: string | undefined;
|
|
13
|
+
/** Days ahead (inclusive of today) that count as `soon`. Defaults to 3. */
|
|
14
|
+
soonDays?: number | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Forces the state regardless of the date, for a status the date alone cannot tell (a
|
|
17
|
+
* payment that is late by policy, a hold). `done` is the neutral finished look. Wins over `done`.
|
|
18
|
+
*/
|
|
19
|
+
state?: DueState | "done" | undefined;
|
|
20
|
+
/** A finished item is never overdue or soon: the chip stays neutral. */
|
|
21
|
+
done?: boolean | undefined;
|
|
22
|
+
/** Replaces the formatted date text. */
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
locale?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A due date as a chip: neutral while it is far off, warning from `soonDays` before, danger once
|
|
28
|
+
* past. The tone is never the only signal: overdue and soon chips carry a status glyph and a
|
|
29
|
+
* screen-reader state. Renders `<time datetime>`; an unreadable date is shown as given.
|
|
30
|
+
*/
|
|
31
|
+
export declare function DueChip({ date, today, soonDays, done, state: forced, locale, children, ...props }: DueChipProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { todayIso } from "../../calendar/internal/date-utils.js";
|
|
4
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
5
|
+
import { Chip } from "../chip/chip.js";
|
|
6
|
+
import { dueCalendarDate, dueStatus, formatDueDay } from "./model.js";
|
|
7
|
+
const toneFor = {
|
|
8
|
+
overdue: "danger",
|
|
9
|
+
soon: "warning",
|
|
10
|
+
ok: "neutral"
|
|
11
|
+
};
|
|
12
|
+
function DueChip({
|
|
13
|
+
date,
|
|
14
|
+
today,
|
|
15
|
+
soonDays,
|
|
16
|
+
done = false,
|
|
17
|
+
state: forced,
|
|
18
|
+
locale,
|
|
19
|
+
children,
|
|
20
|
+
...props
|
|
21
|
+
}) {
|
|
22
|
+
const strings = useUiStrings();
|
|
23
|
+
const reference = today ?? todayIso();
|
|
24
|
+
const day = dueCalendarDate(date);
|
|
25
|
+
const status = day ? dueStatus(date, { today: reference, soonDays }) : null;
|
|
26
|
+
if (!day || !status) return /* @__PURE__ */ jsx(Chip, { ...props, children: children ?? date });
|
|
27
|
+
const resolved = forced ?? (done ? "done" : status.state);
|
|
28
|
+
const state = resolved === "done" ? "ok" : resolved;
|
|
29
|
+
const tone = toneFor[state];
|
|
30
|
+
const stateText = state === "overdue" ? strings.overdue : state === "soon" ? strings.dueSoon : null;
|
|
31
|
+
return /* @__PURE__ */ jsxs(Chip, { tone, statusIcon: true, "data-state": resolved, ...props, children: [
|
|
32
|
+
/* @__PURE__ */ jsx("time", { dateTime: date, children: children ?? formatDueDay(day, dueCalendarDate(reference) ?? reference, locale ?? strings.locale) }),
|
|
33
|
+
stateText ? /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
|
|
34
|
+
", ",
|
|
35
|
+
stateText
|
|
36
|
+
] }) : null
|
|
37
|
+
] });
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
DueChip
|
|
41
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type DueState = "overdue" | "soon" | "ok";
|
|
2
|
+
/**
|
|
3
|
+
* The calendar day ("YYYY-MM-DD") a due value falls on. A date or a naive date-time
|
|
4
|
+
* ("2026-03-04T17:00") already names its day and is read as written, so it never shifts with the
|
|
5
|
+
* viewer's zone. An instant with `Z` or an offset names a moment, so it lands on the viewer's
|
|
6
|
+
* local day. Anything else is `null`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function dueCalendarDate(value: string): string | null;
|
|
9
|
+
/** Whole days from `from` to `to` (both "YYYY-MM-DD"); negative when `to` is earlier. */
|
|
10
|
+
export declare function daysBetween(from: string, to: string): number;
|
|
11
|
+
export interface DueStatus {
|
|
12
|
+
state: DueState;
|
|
13
|
+
/** Days until the due day; negative once overdue, 0 on the day itself. */
|
|
14
|
+
days: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `overdue` once the due day is before `today`, `soon` from today through `soonDays` days ahead,
|
|
18
|
+
* `ok` beyond. `today` is a calendar day (default: the viewer's today). `null` for an unreadable value.
|
|
19
|
+
*/
|
|
20
|
+
export declare function dueStatus(value: string, { today, soonDays, }?: {
|
|
21
|
+
today?: string | undefined;
|
|
22
|
+
soonDays?: number | undefined;
|
|
23
|
+
}): DueStatus | null;
|
|
24
|
+
/** "Mar 4" (with the year when it is not the reference year), formatted in UTC so the day never shifts. */
|
|
25
|
+
export declare function formatDueDay(day: string, reference: string, locale?: string): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { isIsoDate, parseDate, todayIso } from "../../calendar/internal/date-utils.js";
|
|
2
|
+
const NAIVE = /^(\d{4}-\d{2}-\d{2})(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)?$/;
|
|
3
|
+
function dueCalendarDate(value) {
|
|
4
|
+
const naive = NAIVE.exec(value);
|
|
5
|
+
if (naive) {
|
|
6
|
+
const day = naive[1];
|
|
7
|
+
return isIsoDate(day) ? day : null;
|
|
8
|
+
}
|
|
9
|
+
if (/^\d{4}-\d{2}-\d{2}T[\d:.]+(?:Z|[+-]\d{2}:?\d{2})$/.test(value)) {
|
|
10
|
+
const instant = new Date(value);
|
|
11
|
+
return Number.isNaN(instant.getTime()) ? null : todayIso(instant);
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const DAY_MS = 864e5;
|
|
16
|
+
function daysBetween(from, to) {
|
|
17
|
+
return Math.round((parseDate(to).getTime() - parseDate(from).getTime()) / DAY_MS);
|
|
18
|
+
}
|
|
19
|
+
function dueStatus(value, {
|
|
20
|
+
today = todayIso(),
|
|
21
|
+
soonDays = 3
|
|
22
|
+
} = {}) {
|
|
23
|
+
const day = dueCalendarDate(value);
|
|
24
|
+
const reference = dueCalendarDate(today);
|
|
25
|
+
if (!day || !reference) return null;
|
|
26
|
+
const days = daysBetween(reference, day);
|
|
27
|
+
const state = days < 0 ? "overdue" : days <= soonDays ? "soon" : "ok";
|
|
28
|
+
return { state, days };
|
|
29
|
+
}
|
|
30
|
+
function formatDueDay(day, reference, locale) {
|
|
31
|
+
const sameYear = day.slice(0, 4) === reference.slice(0, 4);
|
|
32
|
+
return new Intl.DateTimeFormat(locale, {
|
|
33
|
+
day: "numeric",
|
|
34
|
+
month: "short",
|
|
35
|
+
...sameYear ? {} : { year: "numeric" },
|
|
36
|
+
timeZone: "UTC"
|
|
37
|
+
}).format(parseDate(day));
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
daysBetween,
|
|
41
|
+
dueCalendarDate,
|
|
42
|
+
dueStatus,
|
|
43
|
+
formatDueDay
|
|
44
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
2
|
+
import { type ButtonSize, type ButtonVariant } from "../button/button.js";
|
|
3
|
+
export type IconButtonSize = ButtonSize;
|
|
4
|
+
/** Width behind each `size`; the height comes from the matching `Button` size, so the button is square. */
|
|
5
|
+
export declare const iconButtonSizeClasses: Readonly<Record<IconButtonSize, string>>;
|
|
6
|
+
export interface IconButtonProps extends Omit<ComponentPropsWithRef<"button">, "aria-label" | "aria-labelledby" | "children"> {
|
|
7
|
+
/** Accessible name, announced in place of the icon. Required: an icon alone names nothing. */
|
|
8
|
+
label: string;
|
|
9
|
+
variant?: ButtonVariant;
|
|
10
|
+
size?: IconButtonSize;
|
|
11
|
+
/** Swaps the icon for a spinner and disables the button; announces the localized `loading` string. */
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
/** Render the child element (via Slot) instead of a `<button>`, e.g. a link wrapping the icon. */
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
/** The icon (an `svg`, an `Icon`, or any element). It is decorative: `label` names the button. */
|
|
16
|
+
children: ComponentPropsWithRef<"button">["children"];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Square, icon-only button with the same variants, sizes, focus ring and touch density as
|
|
20
|
+
* `Button`. The control grows with `data-density="touch"` because its box is the Button height.
|
|
21
|
+
*/
|
|
22
|
+
export declare function IconButton({ label, variant, size, loading, asChild, className, children, ...props }: IconButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { Button } from "../button/button.js";
|
|
5
|
+
import { Spinner } from "../spinner/spinner.js";
|
|
6
|
+
const iconButtonSizeClasses = {
|
|
7
|
+
sm: "w-control-sm",
|
|
8
|
+
md: "w-control [&_svg]:size-4",
|
|
9
|
+
lg: "w-control-lg [&_svg]:size-4"
|
|
10
|
+
};
|
|
11
|
+
function IconButton({
|
|
12
|
+
label,
|
|
13
|
+
variant = "secondary",
|
|
14
|
+
size = "md",
|
|
15
|
+
loading,
|
|
16
|
+
asChild,
|
|
17
|
+
className,
|
|
18
|
+
children,
|
|
19
|
+
...props
|
|
20
|
+
}) {
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
Button,
|
|
23
|
+
{
|
|
24
|
+
...props,
|
|
25
|
+
"aria-label": label,
|
|
26
|
+
variant,
|
|
27
|
+
size,
|
|
28
|
+
loading,
|
|
29
|
+
asChild,
|
|
30
|
+
className: cn("shrink-0 px-0", iconButtonSizeClasses[size], className),
|
|
31
|
+
children: loading && !asChild ? /* @__PURE__ */ jsx(Spinner, { size: "sm", label: false }) : children
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
IconButton,
|
|
37
|
+
iconButtonSizeClasses
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IconButton, type IconButtonProps, type IconButtonSize, iconButtonSizeClasses, } from "./icon-button.js";
|
package/dist/atoms/index.d.ts
CHANGED
|
@@ -4,12 +4,17 @@ export * from "./big-date/index.js";
|
|
|
4
4
|
export * from "./button/index.js";
|
|
5
5
|
export * from "./checkbox/index.js";
|
|
6
6
|
export * from "./chip/index.js";
|
|
7
|
+
export * from "./due-chip/index.js";
|
|
7
8
|
export * from "./icon/index.js";
|
|
9
|
+
export * from "./icon-button/index.js";
|
|
10
|
+
export * from "./kbd/index.js";
|
|
8
11
|
export * from "./led/index.js";
|
|
9
12
|
export * from "./number-value/index.js";
|
|
10
13
|
export * from "./pressable-feedback/index.js";
|
|
11
14
|
export * from "./progress/index.js";
|
|
12
15
|
export * from "./radio-group/index.js";
|
|
16
|
+
export * from "./seal/index.js";
|
|
17
|
+
export * from "./spinner/index.js";
|
|
13
18
|
export * from "./status-dot/index.js";
|
|
14
19
|
export * from "./status-pill/index.js";
|
|
15
20
|
export * from "./switch/index.js";
|
package/dist/atoms/index.js
CHANGED
|
@@ -4,12 +4,17 @@ export * from "./big-date/index.js";
|
|
|
4
4
|
export * from "./button/index.js";
|
|
5
5
|
export * from "./checkbox/index.js";
|
|
6
6
|
export * from "./chip/index.js";
|
|
7
|
+
export * from "./due-chip/index.js";
|
|
7
8
|
export * from "./icon/index.js";
|
|
9
|
+
export * from "./icon-button/index.js";
|
|
10
|
+
export * from "./kbd/index.js";
|
|
8
11
|
export * from "./led/index.js";
|
|
9
12
|
export * from "./number-value/index.js";
|
|
10
13
|
export * from "./pressable-feedback/index.js";
|
|
11
14
|
export * from "./progress/index.js";
|
|
12
15
|
export * from "./radio-group/index.js";
|
|
16
|
+
export * from "./seal/index.js";
|
|
17
|
+
export * from "./spinner/index.js";
|
|
13
18
|
export * from "./status-dot/index.js";
|
|
14
19
|
export * from "./status-pill/index.js";
|
|
15
20
|
export * from "./switch/index.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invisible 44px hit target for a small control under `data-density="touch"`. It is a pseudo
|
|
3
|
+
* element centred on the control, so the visual box and the layout never change; the control must
|
|
4
|
+
* be `relative`. Default density adds nothing.
|
|
5
|
+
*/
|
|
6
|
+
export declare const touchHitArea = "relative in-data-[density=touch]:after:absolute in-data-[density=touch]:after:top-1/2 in-data-[density=touch]:after:left-1/2 in-data-[density=touch]:after:size-11 in-data-[density=touch]:after:-translate-1/2 in-data-[density=touch]:after:content-['']";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const touchHitArea = "relative in-data-[density=touch]:after:absolute in-data-[density=touch]:after:top-1/2 in-data-[density=touch]:after:left-1/2 in-data-[density=touch]:after:size-11 in-data-[density=touch]:after:-translate-1/2 in-data-[density=touch]:after:content-['']";
|
|
2
|
+
export {
|
|
3
|
+
touchHitArea
|
|
4
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Kbd, type KbdProps } from "./kbd.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
2
|
+
export type KbdProps = ComponentPropsWithRef<"kbd">;
|
|
3
|
+
/**
|
|
4
|
+
* A keyboard key or shortcut hint (`⌘K`, `Esc`). Purely presentational: put it next to the
|
|
5
|
+
* action's label, never as the only way to tell what a control does.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Kbd({ className, ...props }: KbdProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
function Kbd({ className, ...props }) {
|
|
4
|
+
return /* @__PURE__ */ jsx(
|
|
5
|
+
"kbd",
|
|
6
|
+
{
|
|
7
|
+
...props,
|
|
8
|
+
className: cn(
|
|
9
|
+
"inline-flex min-w-5 items-center justify-center rounded-xs border-divider bg-surface-2 px-1.25 py-0.5 font-mono text-count text-ink-2",
|
|
10
|
+
className
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
Kbd
|
|
17
|
+
};
|