@arshad-shah/cynosure 0.2.0 → 0.3.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/README.md +3 -3
- package/dist/components/Accordion/Accordion.d.ts +14 -0
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/Announcer/Announcer.d.ts +1 -0
- package/dist/components/Announcer/Announcer.js.map +1 -1
- package/dist/components/AppShell/AppShell.d.ts +22 -1
- package/dist/components/AppShell/AppShell.js +95 -83
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/AppShell/index.d.ts +1 -1
- package/dist/components/AspectRatio/AspectRatio.d.ts +29 -0
- package/dist/components/AspectRatio/AspectRatio.js +21 -0
- package/dist/components/AspectRatio/AspectRatio.js.map +1 -0
- package/dist/components/AspectRatio/index.d.ts +1 -0
- package/dist/components/Avatar/Avatar.d.ts +96 -0
- package/dist/components/Avatar/Avatar.js +90 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Badge/Badge.d.ts +6 -0
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +55 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +85 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -0
- package/dist/components/Breadcrumbs/index.d.ts +1 -0
- package/dist/components/Button/Button.d.ts +13 -2
- package/dist/components/Button/Button.js +28 -26
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.d.ts +65 -7
- package/dist/components/Calendar/Calendar.js +207 -95
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Calendar/dates.d.ts +4 -0
- package/dist/components/Calendar/dates.js +41 -27
- package/dist/components/Calendar/dates.js.map +1 -1
- package/dist/components/Calendar/index.d.ts +1 -1
- package/dist/components/Card/Card.d.ts +27 -0
- package/dist/components/Card/Card.js +48 -36
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Card/index.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +8 -1
- package/dist/components/Checkbox/Checkbox.js +7 -6
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checkbox/ChoiceRow.d.ts +17 -1
- package/dist/components/Checkbox/ChoiceRow.js +19 -18
- package/dist/components/Checkbox/ChoiceRow.js.map +1 -1
- package/dist/components/Checklist/Checklist.d.ts +65 -0
- package/dist/components/Checklist/Checklist.js +163 -0
- package/dist/components/Checklist/Checklist.js.map +1 -0
- package/dist/components/Checklist/index.d.ts +1 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +5 -0
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/ColorField/ColorField.d.ts +12 -0
- package/dist/components/ColorField/ColorField.js +19 -19
- package/dist/components/ColorField/ColorField.js.map +1 -1
- package/dist/components/ColorSwatches/ColorSwatches.d.ts +5 -0
- package/dist/components/ColorSwatches/ColorSwatches.js +6 -6
- package/dist/components/ColorSwatches/ColorSwatches.js.map +1 -1
- package/dist/components/Combobox/Combobox.d.ts +20 -1
- package/dist/components/Combobox/Combobox.js +38 -34
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/CommandPalette/CommandPalette.d.ts +9 -0
- package/dist/components/CommandPalette/CommandPalette.js +10 -10
- package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
- package/dist/components/CompareSlider/CompareSlider.d.ts +4 -0
- package/dist/components/CompareSlider/CompareSlider.js +4 -4
- package/dist/components/CompareSlider/CompareSlider.js.map +1 -1
- package/dist/components/Container/Container.d.ts +44 -0
- package/dist/components/Container/Container.js +24 -0
- package/dist/components/Container/Container.js.map +1 -0
- package/dist/components/Container/index.d.ts +1 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +11 -0
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.d.ts +8 -0
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/DateField/DateField.d.ts +17 -0
- package/dist/components/DateField/DateField.js +6 -6
- package/dist/components/DateField/DateField.js.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.d.ts +3 -0
- package/dist/components/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/components/Dialog/Dialog.d.ts +16 -2
- package/dist/components/Dialog/Dialog.js +82 -70
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Disclosure/Disclosure.d.ts +7 -0
- package/dist/components/Disclosure/Disclosure.js.map +1 -1
- package/dist/components/Divider/Divider.d.ts +59 -0
- package/dist/components/Divider/Divider.js +32 -0
- package/dist/components/Divider/Divider.js.map +1 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/DocumentViewport/DocumentViewport.d.ts +8 -0
- package/dist/components/DocumentViewport/DocumentViewport.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.d.ts +3 -0
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/Field/Field.d.ts +6 -0
- package/dist/components/Field/Field.js.map +1 -1
- package/dist/components/FileDrop/FileDrop.d.ts +8 -0
- package/dist/components/FileDrop/FileDrop.js.map +1 -1
- package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +4 -0
- package/dist/components/FloatingToolbar/FloatingToolbar.js +4 -4
- package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +33 -7
- package/dist/components/Grid/Grid.js +46 -25
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/Grid/index.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +57 -0
- package/dist/components/Heading/Heading.js +33 -0
- package/dist/components/Heading/Heading.js.map +1 -0
- package/dist/components/Heading/index.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.js.map +1 -1
- package/dist/components/IconButton/IconButton.d.ts +1 -0
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/Image/Image.d.ts +62 -0
- package/dist/components/Image/Image.js +75 -0
- package/dist/components/Image/Image.js.map +1 -0
- package/dist/components/Image/index.d.ts +1 -0
- package/dist/components/Inline/Inline.d.ts +7 -3
- package/dist/components/Inline/Inline.js +19 -13
- package/dist/components/Inline/Inline.js.map +1 -1
- package/dist/components/Kbd/Kbd.d.ts +2 -0
- package/dist/components/Kbd/Kbd.js.map +1 -1
- package/dist/components/KeyValueEditor/KeyValueEditor.d.ts +7 -0
- package/dist/components/KeyValueEditor/KeyValueEditor.js +8 -8
- package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
- package/dist/components/Link/Link.d.ts +7 -0
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/LoadingDots/LoadingDots.d.ts +2 -0
- package/dist/components/LoadingDots/LoadingDots.js.map +1 -1
- package/dist/components/Menu/Menu.d.ts +13 -1
- package/dist/components/Menu/Menu.js +37 -35
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/Notice/Notice.d.ts +5 -0
- package/dist/components/Notice/Notice.js.map +1 -1
- package/dist/components/NumberField/NumberField.d.ts +17 -0
- package/dist/components/NumberField/NumberField.js +8 -8
- package/dist/components/NumberField/NumberField.js.map +1 -1
- package/dist/components/PageHeader/PageHeader.d.ts +61 -0
- package/dist/components/PageHeader/PageHeader.js +63 -0
- package/dist/components/PageHeader/PageHeader.js.map +1 -0
- package/dist/components/PageHeader/index.d.ts +1 -0
- package/dist/components/Pagination/Pagination.d.ts +77 -0
- package/dist/components/Pagination/Pagination.js +120 -0
- package/dist/components/Pagination/Pagination.js.map +1 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/PanZoomCanvas/PanZoomCanvas.d.ts +4 -0
- package/dist/components/PanZoomCanvas/PanZoomCanvas.js.map +1 -1
- package/dist/components/Popover/Popover.d.ts +10 -0
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts +5 -0
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/ProgressOverlay/ProgressOverlay.d.ts +3 -0
- package/dist/components/ProgressOverlay/ProgressOverlay.js.map +1 -1
- package/dist/components/Prose/Prose.d.ts +1 -0
- package/dist/components/Prose/Prose.js.map +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +13 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +9 -0
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/Select/Select.d.ts +18 -1
- package/dist/components/Select/Select.js +97 -88
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/SelectionFrame/SelectionFrame.d.ts +6 -0
- package/dist/components/SelectionFrame/SelectionFrame.js.map +1 -1
- package/dist/components/SideNav/SideNav.d.ts +37 -1
- package/dist/components/SideNav/SideNav.js +100 -73
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SideNav/index.d.ts +1 -1
- package/dist/components/SignaturePad/SignaturePad.d.ts +3 -0
- package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.d.ts +1 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/components/Slider/Slider.d.ts +11 -0
- package/dist/components/Slider/Slider.js +6 -6
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/SortableList/SortableList.d.ts +6 -0
- package/dist/components/SortableList/SortableList.js.map +1 -1
- package/dist/components/SplitPane/SplitPane.d.ts +5 -0
- package/dist/components/SplitPane/SplitPane.js +4 -4
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/components/Stack/Stack.d.ts +7 -3
- package/dist/components/Stack/Stack.js +18 -12
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/index.d.ts +1 -0
- package/dist/components/Stack/space.d.ts +18 -0
- package/dist/components/Stack/space.js +12 -0
- package/dist/components/Stack/space.js.map +1 -0
- package/dist/components/Steps/Steps.d.ts +4 -0
- package/dist/components/Steps/Steps.js.map +1 -1
- package/dist/components/Table/Table.d.ts +12 -0
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +14 -0
- package/dist/components/Tabs/Tabs.js +4 -4
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/TagInput/TagInput.d.ts +18 -0
- package/dist/components/TagInput/TagInput.js +5 -5
- package/dist/components/TagInput/TagInput.js.map +1 -1
- package/dist/components/Text/Text.d.ts +72 -0
- package/dist/components/Text/Text.js +30 -0
- package/dist/components/Text/Text.js.map +1 -0
- package/dist/components/Text/index.d.ts +1 -0
- package/dist/components/TextArea/TextArea.d.ts +10 -0
- package/dist/components/TextArea/TextArea.js +4 -4
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/TextField/TextField.d.ts +13 -0
- package/dist/components/TextField/TextField.js +4 -4
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/ThemeToggle/ThemeToggle.d.ts +4 -0
- package/dist/components/ThemeToggle/ThemeToggle.js.map +1 -1
- package/dist/components/TimeField/TimeField.d.ts +62 -8
- package/dist/components/TimeField/TimeField.js +308 -72
- package/dist/components/TimeField/TimeField.js.map +1 -1
- package/dist/components/Toast/Toast.d.ts +25 -1
- package/dist/components/Toast/Toast.js +134 -125
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Toast/index.d.ts +1 -1
- package/dist/components/Toolbar/Toolbar.d.ts +3 -0
- package/dist/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Tree/Tree.d.ts +8 -0
- package/dist/components/Tree/Tree.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.d.ts +8 -0
- package/dist/components/VirtualList/VirtualList.js +4 -4
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/ZoomControls/ZoomControls.d.ts +4 -0
- package/dist/components/ZoomControls/ZoomControls.js.map +1 -1
- package/dist/foundations/ChoiceBase/ChoiceBase.d.ts +1 -0
- package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
- package/dist/foundations/HiddenValue/HiddenValue.d.ts +3 -0
- package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
- package/dist/foundations/Icon/Icon.d.ts +3 -0
- package/dist/foundations/Icon/Icon.js.map +1 -1
- package/dist/foundations/image-outcome.d.ts +15 -0
- package/dist/foundations/image-outcome.js +39 -0
- package/dist/foundations/image-outcome.js.map +1 -0
- package/dist/foundations/option-icon.d.ts +26 -0
- package/dist/foundations/option-icon.js +16 -0
- package/dist/foundations/option-icon.js.map +1 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +476 -474
- package/dist/icons/keywords.d.ts +249 -0
- package/dist/icons/keywords.js +1728 -0
- package/dist/icons/keywords.js.map +1 -0
- package/dist/index.d.ts +20 -9
- package/dist/index.js +240 -213
- package/dist/styles/aspect-ratio.css +1 -0
- package/dist/styles/avatar.css +1 -0
- package/dist/styles/breadcrumbs.css +1 -0
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/checklist.css +1 -0
- package/dist/styles/container.css +1 -0
- package/dist/styles/divider.css +1 -0
- package/dist/styles/generated-css.d.ts +1 -1
- package/dist/styles/generated-css.js +1 -1
- package/dist/styles/generated-css.js.map +1 -1
- package/dist/styles/grid.css +1 -1
- package/dist/styles/heading.css +1 -0
- package/dist/styles/image.css +1 -0
- package/dist/styles/menu.css +1 -1
- package/dist/styles/page-header.css +1 -0
- package/dist/styles/pagination.css +1 -0
- package/dist/styles/side-nav.css +1 -1
- package/dist/styles/stack.css +1 -1
- package/dist/styles/text.css +1 -0
- package/dist/styles/time-field.css +1 -1
- package/dist/styles/toast.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme/CynosureTheme.d.ts +4 -0
- package/dist/theme/CynosureTheme.js.map +1 -1
- package/dist/tokens/to-css.js +12 -12
- package/dist/tokens/to-css.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,42 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var s = /^(\d{4})-(\d{2})-(\d{2})$/,
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
if (!
|
|
6
|
-
const [t,
|
|
7
|
-
Number(
|
|
8
|
-
Number(
|
|
9
|
-
Number(
|
|
10
|
-
], o = new Date(t,
|
|
11
|
-
return o.setFullYear(t), o.getMonth() ===
|
|
2
|
+
var s = /^(\d{4})-(\d{2})-(\d{2})$/, c = (e, n = 2) => String(e).padStart(n, "0"), l = (e) => `${c(e.getFullYear(), 4)}-${c(e.getMonth() + 1)}-${c(e.getDate())}`;
|
|
3
|
+
function u(e) {
|
|
4
|
+
const n = s.exec(e.trim());
|
|
5
|
+
if (!n) return null;
|
|
6
|
+
const [t, a, r] = [
|
|
7
|
+
Number(n[1]),
|
|
8
|
+
Number(n[2]),
|
|
9
|
+
Number(n[3])
|
|
10
|
+
], o = new Date(t, a - 1, r);
|
|
11
|
+
return o.setFullYear(t), o.getMonth() === a - 1 && o.getDate() === r ? o : null;
|
|
12
12
|
}
|
|
13
|
-
var
|
|
14
|
-
const t =
|
|
15
|
-
return t.setDate(t.getDate() +
|
|
13
|
+
var g = (e) => u(e) !== null, D = (e, n) => {
|
|
14
|
+
const t = u(e);
|
|
15
|
+
return t.setDate(t.getDate() + n), l(t);
|
|
16
16
|
};
|
|
17
|
-
function
|
|
18
|
-
const t =
|
|
19
|
-
t.setDate(1), t.setMonth(t.getMonth() +
|
|
17
|
+
function f(e, n) {
|
|
18
|
+
const t = u(e), a = t.getDate();
|
|
19
|
+
t.setDate(1), t.setMonth(t.getMonth() + n);
|
|
20
20
|
const r = new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate();
|
|
21
|
-
return t.setDate(Math.min(
|
|
21
|
+
return t.setDate(Math.min(a, r)), l(t);
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
function
|
|
23
|
+
var i = (e, n, t) => n && e < n ? n : t && e > t ? t : e;
|
|
24
|
+
function d(e) {
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
26
|
+
const n = new Intl.Locale(e ?? navigator.language), t = n.getWeekInfo?.() ?? n.weekInfo;
|
|
27
27
|
if (t) return t.firstDay % 7;
|
|
28
28
|
} catch {
|
|
29
29
|
}
|
|
30
30
|
return 1;
|
|
31
31
|
}
|
|
32
|
+
function h(e, n) {
|
|
33
|
+
const t = u(`${n}-01`), a = new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate();
|
|
34
|
+
return `${n}-${c(Math.min(Number(e.slice(8)), a))}`;
|
|
35
|
+
}
|
|
36
|
+
function w(e) {
|
|
37
|
+
try {
|
|
38
|
+
const n = new Intl.Locale(e ?? navigator.language), t = (n.getWeekInfo?.() ?? n.weekInfo)?.weekend;
|
|
39
|
+
if (t) return t.map((a) => a % 7);
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
return [6, 0];
|
|
43
|
+
}
|
|
32
44
|
export {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
D as addDays,
|
|
46
|
+
f as addMonths,
|
|
47
|
+
i as clampDate,
|
|
48
|
+
d as firstDayOfWeek,
|
|
49
|
+
u as fromISODate,
|
|
50
|
+
h as inMonth,
|
|
51
|
+
g as isISODate,
|
|
52
|
+
l as toISODate,
|
|
53
|
+
w as weekendDays
|
|
40
54
|
};
|
|
41
55
|
|
|
42
56
|
//# sourceMappingURL=dates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.js","names":["ISO","pad","n","width","toISODate","date","fromISODate","iso","m","y","mo","d","isISODate","addDays","days","addMonths","months","day","last","clampDate","min","max","firstDayOfWeek","locale","loc","info"],"sources":["../../../src/components/Calendar/dates.ts"],"sourcesContent":["/**\n * Plain calendar dates as ISO strings (`2026-11-10`): no time and no time zone, so a date picked in Dublin is the same\n * date in Lahore. Strings compare in date order, and they are what forms and APIs already exchange.\n */\n\nconst ISO = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst pad = (n: number, width = 2) => String(n).padStart(width, \"0\");\n\n/** `2026-11-10` from a Date's local year, month and day. */\nexport const toISODate = (date: Date) =>\n `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;\n\n/** A Date at local midnight, or null when `iso` is not a real date (2026-02-30 is not). */\nexport function fromISODate(iso: string): Date | null {\n const m = ISO.exec(iso.trim());\n if (!m) return null;\n const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];\n const date = new Date(y, mo - 1, d);\n date.setFullYear(y); // years below 100 would otherwise be read as 19xx\n return date.getMonth() === mo - 1 && date.getDate() === d ? date : null;\n}\n\n/** Whether `iso` is a real date, written `YYYY-MM-DD`. */\nexport const isISODate = (iso: string) => fromISODate(iso) !== null;\n\nexport const addDays = (iso: string, days: number) => {\n const date = fromISODate(iso) as Date;\n date.setDate(date.getDate() + days);\n return toISODate(date);\n};\n\n/** Months later (or earlier), keeping the day where it exists: 31 January plus a month is 28 or 29 February. */\nexport function addMonths(iso: string, months: number) {\n const date = fromISODate(iso) as Date;\n const day = date.getDate();\n date.setDate(1);\n date.setMonth(date.getMonth() + months);\n const last = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();\n date.setDate(Math.min(day, last));\n return toISODate(date);\n}\n\n/** `iso` kept within `min` and `max` (either may be absent). */\nexport const clampDate = (iso: string, min?: string, max?: string) =>\n min && iso < min ? min : max && iso > max ? max : iso;\n\n/** The weekday a week starts on in `locale` (0 Sunday to 6 Saturday), where the browser knows it; else Monday. */\nexport function firstDayOfWeek(locale?: string): number {\n try {\n // `getWeekInfo()` is the standard; `weekInfo` is the older accessor some engines still have.\n const loc = new Intl.Locale(locale ?? navigator.language) as Intl.Locale & {\n getWeekInfo?: () => { firstDay: number };\n weekInfo?: { firstDay: number };\n };\n const info = loc.getWeekInfo?.() ?? loc.weekInfo;\n if (info) return info.firstDay % 7;\n } catch {\n // An unknown locale falls through to Monday.\n }\n return 1;\n}\n"],"mappings":";AAKA,IAAMA,IAAM,6BACNC,IAAA,CAAOC,GAAWC,IAAQ,MAAM,OAAOD,CAAC,EAAE,SAASC,GAAO,GAAG,GAGtDC,IAAA,CAAaC,MACxB,GAAGJ,EAAII,EAAK,YAAY,GAAG,CAAC,CAAA,IAAKJ,EAAII,EAAK,SAAS,IAAI,CAAC,CAAA,IAAKJ,EAAII,EAAK,QAAQ,CAAC,CAAA;AAGjF,SAAgBC,EAAYC,GAA0B;AACpD,QAAMC,IAAIR,EAAI,KAAKO,EAAI,KAAK,CAAC;AAC7B,MAAI,CAACC,EAAG,QAAO;AACf,QAAM,CAACC,GAAGC,GAAIC,CAAA,IAAK;AAAA,IAAC,OAAOH,EAAE,CAAA,CAAE;AAAA,IAAG,OAAOA,EAAE,CAAA,CAAE;AAAA,IAAG,OAAOA,EAAE,CAAA,CAAE;AAAA,EAAC,GACtDH,IAAO,IAAI,KAAKI,GAAGC,IAAK,GAAGC,CAAC;AAClC,SAAAN,EAAK,YAAYI,CAAC,GACXJ,EAAK,SAAS,MAAMK,IAAK,KAAKL,EAAK,QAAQ,MAAMM,IAAIN,IAAO;AACrE;AAGA,IAAaO,IAAA,CAAaL,MAAgBD,EAAYC,CAAG,MAAM,MAElDM,IAAA,CAAWN,GAAaO,MAAiB;AACpD,QAAMT,IAAOC,EAAYC,CAAG;AAC5B,SAAAF,EAAK,QAAQA,EAAK,QAAQ,IAAIS,CAAI,GAC3BV,EAAUC,CAAI;AACvB;AAGA,SAAgBU,EAAUR,GAAaS,GAAgB;AACrD,QAAMX,IAAOC,EAAYC,CAAG,GACtBU,IAAMZ,EAAK,QAAQ;AACzB,EAAAA,EAAK,QAAQ,CAAC,GACdA,EAAK,SAASA,EAAK,SAAS,IAAIW,CAAM;AACtC,QAAME,IAAO,IAAI,KAAKb,EAAK,YAAY,GAAGA,EAAK,SAAS,IAAI,GAAG,CAAC,EAAE,QAAQ;AAC1E,SAAAA,EAAK,QAAQ,KAAK,IAAIY,GAAKC,CAAI,CAAC,GACzBd,EAAUC,CAAI;AACvB;AAGA,IAAac,IAAA,CAAaZ,GAAaa,GAAcC,MACnDD,KAAOb,IAAMa,IAAMA,IAAMC,KAAOd,IAAMc,IAAMA,IAAMd;AAGpD,SAAgBe,EAAeC,GAAyB;AACtD,MAAI;AAEF,UAAMC,IAAM,IAAI,KAAK,OAAOD,KAAU,UAAU,QAAQ,GAIlDE,IAAOD,EAAI,cAAc,KAAKA,EAAI;AACxC,QAAIC,EAAM,QAAOA,EAAK,WAAW;AAAA,EACnC,QAAQ;AAAA,EAER;AACA,SAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"dates.js","names":["ISO","pad","n","width","toISODate","date","fromISODate","iso","m","y","mo","d","isISODate","addDays","days","addMonths","months","day","last","clampDate","min","max","firstDayOfWeek","locale","loc","info","inMonth","month","first","weekendDays","weekend"],"sources":["../../../src/components/Calendar/dates.ts"],"sourcesContent":["/**\n * Plain calendar dates as ISO strings (`2026-11-10`): no time and no time zone, so a date picked in Dublin is the same\n * date in Lahore. Strings compare in date order, and they are what forms and APIs already exchange.\n */\n\nconst ISO = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst pad = (n: number, width = 2) => String(n).padStart(width, \"0\");\n\n/** `2026-11-10` from a Date's local year, month and day. */\nexport const toISODate = (date: Date) =>\n `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;\n\n/** A Date at local midnight, or null when `iso` is not a real date (2026-02-30 is not). */\nexport function fromISODate(iso: string): Date | null {\n const m = ISO.exec(iso.trim());\n if (!m) return null;\n const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];\n const date = new Date(y, mo - 1, d);\n date.setFullYear(y); // years below 100 would otherwise be read as 19xx\n return date.getMonth() === mo - 1 && date.getDate() === d ? date : null;\n}\n\n/** Whether `iso` is a real date, written `YYYY-MM-DD`. */\nexport const isISODate = (iso: string) => fromISODate(iso) !== null;\n\nexport const addDays = (iso: string, days: number) => {\n const date = fromISODate(iso) as Date;\n date.setDate(date.getDate() + days);\n return toISODate(date);\n};\n\n/** Months later (or earlier), keeping the day where it exists: 31 January plus a month is 28 or 29 February. */\nexport function addMonths(iso: string, months: number) {\n const date = fromISODate(iso) as Date;\n const day = date.getDate();\n date.setDate(1);\n date.setMonth(date.getMonth() + months);\n const last = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();\n date.setDate(Math.min(day, last));\n return toISODate(date);\n}\n\n/** `iso` kept within `min` and `max` (either may be absent). */\nexport const clampDate = (iso: string, min?: string, max?: string) =>\n min && iso < min ? min : max && iso > max ? max : iso;\n\n/** The weekday a week starts on in `locale` (0 Sunday to 6 Saturday), where the browser knows it; else Monday. */\nexport function firstDayOfWeek(locale?: string): number {\n try {\n // `getWeekInfo()` is the standard; `weekInfo` is the older accessor some engines still have.\n const loc = new Intl.Locale(locale ?? navigator.language) as Intl.Locale & {\n getWeekInfo?: () => { firstDay: number };\n weekInfo?: { firstDay: number };\n };\n const info = loc.getWeekInfo?.() ?? loc.weekInfo;\n if (info) return info.firstDay % 7;\n } catch {\n // An unknown locale falls through to Monday.\n }\n return 1;\n}\n\n/** The day of `iso` in `month` (`YYYY-MM`), or that month's last day when it is shorter. */\nexport function inMonth(iso: string, month: string) {\n const first = fromISODate(`${month}-01`) as Date;\n const last = new Date(first.getFullYear(), first.getMonth() + 1, 0).getDate();\n return `${month}-${pad(Math.min(Number(iso.slice(8)), last))}`;\n}\n\n/** The weekend's weekdays in `locale` (0 Sunday to 6 Saturday), where the browser knows them; else Saturday and Sunday. */\nexport function weekendDays(locale?: string): number[] {\n try {\n const loc = new Intl.Locale(locale ?? navigator.language) as Intl.Locale & {\n getWeekInfo?: () => { weekend?: number[] };\n weekInfo?: { weekend?: number[] };\n };\n const weekend = (loc.getWeekInfo?.() ?? loc.weekInfo)?.weekend;\n if (weekend) return weekend.map((day) => day % 7);\n } catch {\n // An unknown locale falls through to Saturday and Sunday.\n }\n return [6, 0];\n}\n"],"mappings":";AAKA,IAAMA,IAAM,6BACNC,IAAA,CAAOC,GAAWC,IAAQ,MAAM,OAAOD,CAAC,EAAE,SAASC,GAAO,GAAG,GAGtDC,IAAA,CAAaC,MACxB,GAAGJ,EAAII,EAAK,YAAY,GAAG,CAAC,CAAA,IAAKJ,EAAII,EAAK,SAAS,IAAI,CAAC,CAAA,IAAKJ,EAAII,EAAK,QAAQ,CAAC,CAAA;AAGjF,SAAgBC,EAAYC,GAA0B;AACpD,QAAMC,IAAIR,EAAI,KAAKO,EAAI,KAAK,CAAC;AAC7B,MAAI,CAACC,EAAG,QAAO;AACf,QAAM,CAACC,GAAGC,GAAIC,CAAA,IAAK;AAAA,IAAC,OAAOH,EAAE,CAAA,CAAE;AAAA,IAAG,OAAOA,EAAE,CAAA,CAAE;AAAA,IAAG,OAAOA,EAAE,CAAA,CAAE;AAAA,EAAC,GACtDH,IAAO,IAAI,KAAKI,GAAGC,IAAK,GAAGC,CAAC;AAClC,SAAAN,EAAK,YAAYI,CAAC,GACXJ,EAAK,SAAS,MAAMK,IAAK,KAAKL,EAAK,QAAQ,MAAMM,IAAIN,IAAO;AACrE;AAGA,IAAaO,IAAA,CAAaL,MAAgBD,EAAYC,CAAG,MAAM,MAElDM,IAAA,CAAWN,GAAaO,MAAiB;AACpD,QAAMT,IAAOC,EAAYC,CAAG;AAC5B,SAAAF,EAAK,QAAQA,EAAK,QAAQ,IAAIS,CAAI,GAC3BV,EAAUC,CAAI;AACvB;AAGA,SAAgBU,EAAUR,GAAaS,GAAgB;AACrD,QAAMX,IAAOC,EAAYC,CAAG,GACtBU,IAAMZ,EAAK,QAAQ;AACzB,EAAAA,EAAK,QAAQ,CAAC,GACdA,EAAK,SAASA,EAAK,SAAS,IAAIW,CAAM;AACtC,QAAME,IAAO,IAAI,KAAKb,EAAK,YAAY,GAAGA,EAAK,SAAS,IAAI,GAAG,CAAC,EAAE,QAAQ;AAC1E,SAAAA,EAAK,QAAQ,KAAK,IAAIY,GAAKC,CAAI,CAAC,GACzBd,EAAUC,CAAI;AACvB;AAGA,IAAac,IAAA,CAAaZ,GAAaa,GAAcC,MACnDD,KAAOb,IAAMa,IAAMA,IAAMC,KAAOd,IAAMc,IAAMA,IAAMd;AAGpD,SAAgBe,EAAeC,GAAyB;AACtD,MAAI;AAEF,UAAMC,IAAM,IAAI,KAAK,OAAOD,KAAU,UAAU,QAAQ,GAIlDE,IAAOD,EAAI,cAAc,KAAKA,EAAI;AACxC,QAAIC,EAAM,QAAOA,EAAK,WAAW;AAAA,EACnC,QAAQ;AAAA,EAER;AACA,SAAO;AACT;AAGA,SAAgBC,EAAQnB,GAAaoB,GAAe;AAClD,QAAMC,IAAQtB,EAAY,GAAGqB,CAAA,KAAU,GACjCT,IAAO,IAAI,KAAKU,EAAM,YAAY,GAAGA,EAAM,SAAS,IAAI,GAAG,CAAC,EAAE,QAAQ;AAC5E,SAAO,GAAGD,CAAA,IAAS1B,EAAI,KAAK,IAAI,OAAOM,EAAI,MAAM,CAAC,CAAC,GAAGW,CAAI,CAAC,CAAA;AAC7D;AAGA,SAAgBW,EAAYN,GAA2B;AACrD,MAAI;AACF,UAAMC,IAAM,IAAI,KAAK,OAAOD,KAAU,UAAU,QAAQ,GAIlDO,KAAWN,EAAI,cAAc,KAAKA,EAAI,WAAW;AACvD,QAAIM,EAAS,QAAOA,EAAQ,IAAA,CAAKb,MAAQA,IAAM,CAAC;AAAA,EAClD,QAAQ;AAAA,EAER;AACA,SAAO,CAAC,GAAG,CAAC;AACd"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Calendar, type CalendarDayState, type CalendarLabels, type CalendarProps, type CalendarTokens, } from "./Calendar.js";
|
|
1
|
+
export { Calendar, type CalendarDayMark, type CalendarDayState, type CalendarLabels, type CalendarProps, type CalendarTokens, } from "./Calendar.js";
|
|
2
2
|
export { addDays, addMonths, fromISODate, isISODate, toISODate } from "./dates.js";
|
|
@@ -1,28 +1,55 @@
|
|
|
1
1
|
import { type CSSProperties, type MouseEventHandler, type ReactNode } from "react";
|
|
2
2
|
import type { Tone } from "../../tokens/schema.js";
|
|
3
|
+
export interface CardTokens {
|
|
4
|
+
bg: string;
|
|
5
|
+
border: string;
|
|
6
|
+
radius: string;
|
|
7
|
+
shadow: string;
|
|
8
|
+
softMix: string;
|
|
9
|
+
edgeWidth: string;
|
|
10
|
+
}
|
|
11
|
+
declare module "../../tokens/schema.js" {
|
|
12
|
+
interface ComponentTokens {
|
|
13
|
+
card: CardTokens;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
3
16
|
export interface CardProps {
|
|
4
17
|
/** `surface` raised panel, `outline` border only, `soft` tone-tinted fill. */
|
|
5
18
|
variant?: "surface" | "outline" | "soft";
|
|
19
|
+
/** Space between the card's edge and its content. Default "md". */
|
|
6
20
|
padding?: "none" | "sm" | "md" | "lg";
|
|
21
|
+
/** Semantic colour. Default "neutral". */
|
|
7
22
|
tone?: Tone;
|
|
23
|
+
/**
|
|
24
|
+
* A coloured edge on the card's inline-start side (left in left-to-right text), e.g. a task's category. A tone name
|
|
25
|
+
* uses that tone's colour; any other string is a CSS colour. Colour alone carries no meaning for many people: say
|
|
26
|
+
* the same thing in the card's text or a Badge. Default: no edge.
|
|
27
|
+
*/
|
|
28
|
+
edge?: Tone | (string & {});
|
|
8
29
|
/** Element for a static card. Ignored when `href` or `onClick` makes the whole card interactive. */
|
|
9
30
|
as?: "div" | "section" | "article" | "li" | "aside";
|
|
10
31
|
/** Makes the whole card a link (rendered through LinkBase, so unsafe schemes are not linked). */
|
|
11
32
|
href?: string;
|
|
33
|
+
/** With `href`: where it opens, e.g. `_blank`. */
|
|
12
34
|
target?: string;
|
|
13
35
|
/** Makes the whole card a button. */
|
|
14
36
|
onClick?: MouseEventHandler<HTMLElement>;
|
|
37
|
+
/** With `onClick` (and no `href`): the card cannot be pressed. */
|
|
15
38
|
disabled?: boolean;
|
|
16
39
|
/**
|
|
17
40
|
* Buttons that sit on the card but act on their own (a game card's 2-player mode, a file card's menu). They are placed
|
|
18
41
|
* over the card's top end, outside its one link or button, so nothing interactive is nested.
|
|
19
42
|
*/
|
|
20
43
|
actions?: ReactNode;
|
|
44
|
+
/** Added to the card element, for layout. */
|
|
21
45
|
className?: string;
|
|
22
46
|
/** Layout only. */
|
|
23
47
|
style?: CSSProperties;
|
|
48
|
+
/** The card's content. Keep it non-interactive when the card is a link or a button. */
|
|
24
49
|
children?: ReactNode;
|
|
50
|
+
/** Accessible name of the card, set on the card element. */
|
|
25
51
|
"aria-label"?: string;
|
|
52
|
+
/** Set on the card element, to find it in tests. */
|
|
26
53
|
"data-testid"?: string;
|
|
27
54
|
}
|
|
28
55
|
/** Content container. With `href` or `onClick` the whole card is one link or button (no nested controls). */
|
|
@@ -1,57 +1,69 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { ButtonBase as
|
|
3
|
-
import { LinkBase as
|
|
4
|
-
import { forwardRef as
|
|
5
|
-
import { jsx as
|
|
6
|
-
var
|
|
2
|
+
import { ButtonBase as w } from "../../foundations/ButtonBase/ButtonBase.js";
|
|
3
|
+
import { LinkBase as R } from "../../foundations/LinkBase/LinkBase.js";
|
|
4
|
+
import { forwardRef as b } from "react";
|
|
5
|
+
import { jsx as t, jsxs as v } from "react/jsx-runtime";
|
|
6
|
+
var E = [
|
|
7
|
+
"accent",
|
|
8
|
+
"neutral",
|
|
9
|
+
"danger",
|
|
10
|
+
"success",
|
|
11
|
+
"warning",
|
|
12
|
+
"info"
|
|
13
|
+
], u = b(function(a, c) {
|
|
7
14
|
if (a.actions !== void 0 && (a.href !== void 0 || a.onClick)) {
|
|
8
|
-
const { actions:
|
|
9
|
-
return /* @__PURE__ */
|
|
15
|
+
const { actions: x, style: B, ...j } = a;
|
|
16
|
+
return /* @__PURE__ */ v("div", {
|
|
10
17
|
className: "cy-card-frame cy-reset",
|
|
11
|
-
style:
|
|
12
|
-
children: [/* @__PURE__ */
|
|
13
|
-
ref:
|
|
14
|
-
...
|
|
15
|
-
}), /* @__PURE__ */
|
|
18
|
+
style: B,
|
|
19
|
+
children: [/* @__PURE__ */ t(u, {
|
|
20
|
+
ref: c,
|
|
21
|
+
...j
|
|
22
|
+
}), /* @__PURE__ */ t("div", {
|
|
16
23
|
className: "cy-card-actions cy-reset",
|
|
17
|
-
children:
|
|
24
|
+
children: x
|
|
18
25
|
})]
|
|
19
26
|
});
|
|
20
27
|
}
|
|
21
|
-
const { variant:
|
|
22
|
-
...
|
|
23
|
-
className:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
const { variant: f = "surface", padding: y = "md", tone: g = "neutral", as: h = "div", href: n, target: N, onClick: r, disabled: C, actions: s, edge: e, className: o, style: l, children: d, ...k } = a, m = !!e && !E.includes(e), i = {
|
|
29
|
+
...k,
|
|
30
|
+
className: o ? `cy-card ${o}` : "cy-card",
|
|
31
|
+
style: m ? {
|
|
32
|
+
"--_edge": e,
|
|
33
|
+
...l
|
|
34
|
+
} : l,
|
|
35
|
+
"data-edge": e ? m ? "custom" : e : void 0,
|
|
36
|
+
"data-variant": f,
|
|
37
|
+
"data-padding": y,
|
|
38
|
+
"data-tone": g
|
|
27
39
|
};
|
|
28
|
-
return
|
|
29
|
-
ref:
|
|
40
|
+
return n !== void 0 ? /* @__PURE__ */ t(R, {
|
|
41
|
+
ref: c,
|
|
30
42
|
...i,
|
|
31
|
-
href:
|
|
32
|
-
target:
|
|
43
|
+
href: n,
|
|
44
|
+
target: N,
|
|
33
45
|
"data-interactive": "",
|
|
34
|
-
onClick:
|
|
35
|
-
children:
|
|
36
|
-
}) :
|
|
37
|
-
ref:
|
|
46
|
+
onClick: r,
|
|
47
|
+
children: d
|
|
48
|
+
}) : r ? /* @__PURE__ */ t(w, {
|
|
49
|
+
ref: c,
|
|
38
50
|
...i,
|
|
39
|
-
onClick:
|
|
40
|
-
disabled:
|
|
51
|
+
onClick: r,
|
|
52
|
+
disabled: C,
|
|
41
53
|
"data-interactive": "",
|
|
42
|
-
children:
|
|
43
|
-
}) : /* @__PURE__ */
|
|
44
|
-
ref:
|
|
54
|
+
children: d
|
|
55
|
+
}) : /* @__PURE__ */ v(h, {
|
|
56
|
+
ref: c,
|
|
45
57
|
...i,
|
|
46
|
-
children: [
|
|
58
|
+
children: [d, s !== void 0 && /* @__PURE__ */ t("div", {
|
|
47
59
|
className: "cy-card-actions cy-reset",
|
|
48
|
-
children:
|
|
60
|
+
children: s
|
|
49
61
|
})]
|
|
50
62
|
});
|
|
51
63
|
});
|
|
52
|
-
|
|
64
|
+
u.displayName = "Card";
|
|
53
65
|
export {
|
|
54
|
-
|
|
66
|
+
u as Card
|
|
55
67
|
};
|
|
56
68
|
|
|
57
69
|
//# sourceMappingURL=Card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.js","names":["Tag","ButtonBase","LinkBase","forwardRef","jsx","jsxs","Card","props","ref","actions","style","card","variant","padding","tone","as","href","target","onClick","disabled","className","children","rest","common"],"sources":["../../../src/components/Card/Card.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ElementType,\n forwardRef,\n type MouseEventHandler,\n type ReactNode,\n} from \"react\";\nimport { ButtonBase } from \"../../foundations/ButtonBase/ButtonBase.js\";\nimport { LinkBase } from \"../../foundations/LinkBase/LinkBase.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\n\nexport interface CardProps {\n /** `surface` raised panel, `outline` border only, `soft` tone-tinted fill. */\n variant?: \"surface\" | \"outline\" | \"soft\";\n padding?: \"none\" | \"sm\" | \"md\" | \"lg\";\n tone?: Tone;\n /** Element for a static card. Ignored when `href` or `onClick` makes the whole card interactive. */\n as?: \"div\" | \"section\" | \"article\" | \"li\" | \"aside\";\n /** Makes the whole card a link (rendered through LinkBase, so unsafe schemes are not linked). */\n href?: string;\n target?: string;\n /** Makes the whole card a button. */\n onClick?: MouseEventHandler<HTMLElement>;\n disabled?: boolean;\n /**\n * Buttons that sit on the card but act on their own (a game card's 2-player mode, a file card's menu). They are placed\n * over the card's top end, outside its one link or button, so nothing interactive is nested.\n */\n actions?: ReactNode;\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n children?: ReactNode;\n \"aria-label\"?: string;\n \"data-testid\"?: string;\n}\n\n/** Content container. With `href` or `onClick` the whole card is one link or button (no nested controls). */\nexport const Card = forwardRef<HTMLElement, CardProps>(function CardRender(props, ref) {\n // With actions, the card itself stays one target and the actions are its siblings in a shared frame. Layout\n // (`style`) goes on the frame; the card fills it.\n if (props.actions !== undefined && (props.href !== undefined || props.onClick)) {\n const { actions, style, ...card } = props;\n return (\n <div className=\"cy-card-frame cy-reset\" style={style}>\n <Card ref={ref} {...card} />\n <div className=\"cy-card-actions cy-reset\">{actions}</div>\n </div>\n );\n }\n const {\n variant = \"surface\",\n padding = \"md\",\n tone = \"neutral\",\n as = \"div\",\n href,\n target,\n onClick,\n disabled,\n actions,\n className,\n children,\n ...rest\n } = props;\n const common = {\n ...rest,\n className: className ? `cy-card ${className}` : \"cy-card\",\n \"data-variant\": variant,\n \"data-padding\": padding,\n \"data-tone\": tone,\n };\n if (href !== undefined)\n return (\n <LinkBase\n ref={ref as never}\n {...common}\n href={href}\n target={target}\n data-interactive=\"\"\n onClick={onClick}\n >\n {children}\n </LinkBase>\n );\n if (onClick)\n return (\n <ButtonBase ref={ref as never} {...common} onClick={onClick} disabled={disabled} data-interactive=\"\">\n {children}\n </ButtonBase>\n );\n const Tag = as as ElementType;\n return (\n <Tag ref={ref} {...common}>\n {children}\n {actions !== undefined && <div className=\"cy-card-actions cy-reset\">{actions}</div>}\n </Tag>\n );\n});\nCard.displayName = \"Card\";\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Card.js","names":["Tag","ButtonBase","LinkBase","forwardRef","jsx","jsxs","TONES","Card","props","ref","actions","style","card","variant","padding","tone","as","href","target","onClick","disabled","edge","className","children","rest","custom","common"],"sources":["../../../src/components/Card/Card.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ElementType,\n forwardRef,\n type MouseEventHandler,\n type ReactNode,\n} from \"react\";\nimport { ButtonBase } from \"../../foundations/ButtonBase/ButtonBase.js\";\nimport { LinkBase } from \"../../foundations/LinkBase/LinkBase.js\";\nimport type { Tone } from \"../../tokens/schema.js\";\n\nexport interface CardTokens {\n bg: string;\n border: string;\n radius: string;\n shadow: string;\n softMix: string;\n edgeWidth: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n card: CardTokens;\n }\n}\n\nconst TONES: readonly string[] = [\"accent\", \"neutral\", \"danger\", \"success\", \"warning\", \"info\"];\n\nexport interface CardProps {\n /** `surface` raised panel, `outline` border only, `soft` tone-tinted fill. */\n variant?: \"surface\" | \"outline\" | \"soft\";\n /** Space between the card's edge and its content. Default \"md\". */\n padding?: \"none\" | \"sm\" | \"md\" | \"lg\";\n /** Semantic colour. Default \"neutral\". */\n tone?: Tone;\n /**\n * A coloured edge on the card's inline-start side (left in left-to-right text), e.g. a task's category. A tone name\n * uses that tone's colour; any other string is a CSS colour. Colour alone carries no meaning for many people: say\n * the same thing in the card's text or a Badge. Default: no edge.\n */\n edge?: Tone | (string & {});\n /** Element for a static card. Ignored when `href` or `onClick` makes the whole card interactive. */\n as?: \"div\" | \"section\" | \"article\" | \"li\" | \"aside\";\n /** Makes the whole card a link (rendered through LinkBase, so unsafe schemes are not linked). */\n href?: string;\n /** With `href`: where it opens, e.g. `_blank`. */\n target?: string;\n /** Makes the whole card a button. */\n onClick?: MouseEventHandler<HTMLElement>;\n /** With `onClick` (and no `href`): the card cannot be pressed. */\n disabled?: boolean;\n /**\n * Buttons that sit on the card but act on their own (a game card's 2-player mode, a file card's menu). They are placed\n * over the card's top end, outside its one link or button, so nothing interactive is nested.\n */\n actions?: ReactNode;\n /** Added to the card element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n /** The card's content. Keep it non-interactive when the card is a link or a button. */\n children?: ReactNode;\n /** Accessible name of the card, set on the card element. */\n \"aria-label\"?: string;\n /** Set on the card element, to find it in tests. */\n \"data-testid\"?: string;\n}\n\n/** Content container. With `href` or `onClick` the whole card is one link or button (no nested controls). */\nexport const Card = forwardRef<HTMLElement, CardProps>(function CardRender(props, ref) {\n // With actions, the card itself stays one target and the actions are its siblings in a shared frame. Layout\n // (`style`) goes on the frame; the card fills it.\n if (props.actions !== undefined && (props.href !== undefined || props.onClick)) {\n const { actions, style, ...card } = props;\n return (\n <div className=\"cy-card-frame cy-reset\" style={style}>\n <Card ref={ref} {...card} />\n <div className=\"cy-card-actions cy-reset\">{actions}</div>\n </div>\n );\n }\n const {\n variant = \"surface\",\n padding = \"md\",\n tone = \"neutral\",\n as = \"div\",\n href,\n target,\n onClick,\n disabled,\n actions,\n edge,\n className,\n style,\n children,\n ...rest\n } = props;\n // A tone name is mapped to its token in CSS; any other colour is handed over as a private custom property.\n const custom = !!edge && !TONES.includes(edge);\n const common = {\n ...rest,\n className: className ? `cy-card ${className}` : \"cy-card\",\n style: custom ? ({ \"--_edge\": edge, ...style } as CSSProperties) : style,\n \"data-edge\": edge ? (custom ? \"custom\" : edge) : undefined,\n \"data-variant\": variant,\n \"data-padding\": padding,\n \"data-tone\": tone,\n };\n if (href !== undefined)\n return (\n <LinkBase\n ref={ref as never}\n {...common}\n href={href}\n target={target}\n data-interactive=\"\"\n onClick={onClick}\n >\n {children}\n </LinkBase>\n );\n if (onClick)\n return (\n <ButtonBase ref={ref as never} {...common} onClick={onClick} disabled={disabled} data-interactive=\"\">\n {children}\n </ButtonBase>\n );\n const Tag = as as ElementType;\n return (\n <Tag ref={ref} {...common}>\n {children}\n {actions !== undefined && <div className=\"cy-card-actions cy-reset\">{actions}</div>}\n </Tag>\n );\n});\nCard.displayName = \"Card\";\n"],"mappings":";;;;;AA0BA,IAAMM,IAA2B;AAAA,EAAC;AAAA,EAAU;AAAA,EAAW;AAAA,EAAU;AAAA,EAAW;AAAA,EAAW;AAAM,GA2ChFC,IAAOJ,EAAmC,SAAoBK,GAAOC,GAAK;AAGrF,MAAID,EAAM,YAAY,WAAcA,EAAM,SAAS,UAAaA,EAAM,UAAU;AAC9E,UAAM,EAAE,SAAAE,GAAS,OAAAC,GAAO,GAAGC,EAAA,IAASJ;AACpC,WACE,gBAAAH,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MAAgC,OAAAM;AAAA,MAA/C,UAAA,CACE,gBAAAP,EAACG,GAAD;AAAA,QAAW,KAAAE;AAAA,QAAK,GAAIG;AAAA,MAAO,CAAA,GAC3B,gBAAAR,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAA4B,UAAAM;AAAA,MAAa,CAAA,CACrD;AAAA,I;A,EAET;AACA,QAAM,EACJ,SAAAG,IAAU,WACV,SAAAC,IAAU,MACV,MAAAC,IAAO,WACP,IAAAC,IAAK,OACL,MAAAC,GACA,QAAAC,GACA,SAAAC,GACA,UAAAC,GACA,SAAAV,GACA,MAAAW,GACA,WAAAC,GACA,OAAAX,GACA,UAAAY,GACA,GAAGC,EAAA,IACDhB,GAEEiB,IAAS,CAAC,CAACJ,KAAQ,CAACf,EAAM,SAASe,CAAI,GACvCK,IAAS;AAAA,IACb,GAAGF;AAAA,IACH,WAAWF,IAAY,WAAWA,CAAA,KAAc;AAAA,IAChD,OAAOG,IAAU;AAAA,MAAE,WAAWJ;AAAA,MAAM,GAAGV;AAAA,IAAM,IAAsBA;AAAA,IACnE,aAAaU,IAAQI,IAAS,WAAWJ,IAAQ;AAAA,IACjD,gBAAgBR;AAAA,IAChB,gBAAgBC;AAAA,IAChB,aAAaC;AAAA,EACf;AACA,SAAIE,MAAS,SAET,gBAAAb,EAACF,GAAD;AAAA,IACO,KAAAO;AAAA,IACL,GAAIiB;AAAA,IACE,MAAAT;AAAA,IACE,QAAAC;AAAA,IACR,oBAAiB;AAAA,IACR,SAAAC;AAAA,IAER,UAAAI;AAAA,EACO,CAAA,IAEVJ,IAEA,gBAAAf,EAACH,GAAD;AAAA,IAAiB,KAAAQ;AAAA,IAAc,GAAIiB;AAAA,IAAiB,SAAAP;AAAA,IAAmB,UAAAC;AAAA,IAAU,oBAAiB;AAAA,IAC/F,UAAAG;AAAA,EACS,CAAA,IAId,gBAAAlB,EAACL,GAAD;AAAA,IAAU,KAAAS;AAAA,IAAK,GAAIiB;AAAA,IAAnB,UAAA,CACGH,GACAb,MAAY,UAAa,gBAAAN,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MAA4B,UAAAM;AAAA,IAAa,CAAA,CAC/E;AAAA,E;AAET,CAAC;AACDH,EAAK,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Card, type CardProps } from "./Card.js";
|
|
1
|
+
export { Card, type CardProps, type CardTokens } from "./Card.js";
|
|
@@ -3,6 +3,8 @@ export interface CheckboxTokens {
|
|
|
3
3
|
size: string;
|
|
4
4
|
radius: string;
|
|
5
5
|
border: string;
|
|
6
|
+
doneColor: string;
|
|
7
|
+
strikeWidth: string;
|
|
6
8
|
}
|
|
7
9
|
declare module "../../tokens/schema.js" {
|
|
8
10
|
interface ComponentTokens {
|
|
@@ -12,6 +14,11 @@ declare module "../../tokens/schema.js" {
|
|
|
12
14
|
export interface CheckboxProps extends ChoiceRowProps {
|
|
13
15
|
/** Mixed state (announced as "mixed"), e.g. a partially selected "select all". */
|
|
14
16
|
indeterminate?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Checklist style: while the box is checked, the label is struck through and muted (and the description muted), so
|
|
19
|
+
* a done task reads as done. Not applied while `indeterminate`. Default false.
|
|
20
|
+
*/
|
|
21
|
+
strikeWhenChecked?: boolean;
|
|
15
22
|
}
|
|
16
23
|
/** Checkbox on a native input: forms, reset, required and keyboard come for free. */
|
|
17
|
-
export declare function Checkbox(props: CheckboxProps): import("react").JSX.Element;
|
|
24
|
+
export declare function Checkbox({ strikeWhenChecked, ...props }: CheckboxProps): import("react").JSX.Element;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { ChoiceRow as
|
|
3
|
-
import { jsx as
|
|
4
|
-
function
|
|
5
|
-
return /* @__PURE__ */ r
|
|
2
|
+
import { ChoiceRow as r } from "./ChoiceRow.js";
|
|
3
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
4
|
+
function n({ strikeWhenChecked: o = !1, ...e }) {
|
|
5
|
+
return /* @__PURE__ */ i(r, {
|
|
6
6
|
kind: "checkbox",
|
|
7
|
-
|
|
7
|
+
strike: o,
|
|
8
|
+
...e
|
|
8
9
|
});
|
|
9
10
|
}
|
|
10
11
|
export {
|
|
11
|
-
|
|
12
|
+
n as Checkbox
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","names":["ChoiceRow","jsx","Checkbox","props"],"sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { ChoiceRow, type ChoiceRowProps } from \"./ChoiceRow.js\";\n\nexport interface CheckboxTokens {\n size: string;\n radius: string;\n border: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n checkbox: CheckboxTokens;\n }\n}\n\nexport interface CheckboxProps extends ChoiceRowProps {\n /** Mixed state (announced as \"mixed\"), e.g. a partially selected \"select all\". */\n indeterminate?: boolean;\n}\n\n/** Checkbox on a native input: forms, reset, required and keyboard come for free. */\nexport function Checkbox(props: CheckboxProps) {\n return <ChoiceRow kind=\"checkbox\" {...props} />;\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":["ChoiceRow","jsx","Checkbox","strikeWhenChecked","props"],"sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { ChoiceRow, type ChoiceRowProps } from \"./ChoiceRow.js\";\n\nexport interface CheckboxTokens {\n size: string;\n radius: string;\n border: string;\n doneColor: string;\n strikeWidth: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n checkbox: CheckboxTokens;\n }\n}\n\nexport interface CheckboxProps extends ChoiceRowProps {\n /** Mixed state (announced as \"mixed\"), e.g. a partially selected \"select all\". */\n indeterminate?: boolean;\n /**\n * Checklist style: while the box is checked, the label is struck through and muted (and the description muted), so\n * a done task reads as done. Not applied while `indeterminate`. Default false.\n */\n strikeWhenChecked?: boolean;\n}\n\n/** Checkbox on a native input: forms, reset, required and keyboard come for free. */\nexport function Checkbox({ strikeWhenChecked = false, ...props }: CheckboxProps) {\n return <ChoiceRow kind=\"checkbox\" strike={strikeWhenChecked} {...props} />;\n}\n"],"mappings":";;;AA2BA,SAAgBE,EAAS,EAAE,mBAAAC,IAAoB,IAAO,GAAGC,EAAA,GAAwB;AAC/E,SAAO,gBAAAH,EAACD,GAAD;AAAA,IAAW,MAAK;AAAA,IAAW,QAAQG;AAAA,IAAmB,GAAIC;AAAA,EAAQ,CAAA;AAC3E"}
|
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
2
|
import type { Size, Tone } from "../../tokens/schema.js";
|
|
3
3
|
export interface ChoiceRowProps {
|
|
4
|
+
/** The control's label. Pressing it toggles the control. */
|
|
4
5
|
label: ReactNode;
|
|
6
|
+
/** Help text shown under the label and read with the control. */
|
|
5
7
|
description?: ReactNode | undefined;
|
|
8
|
+
/** Controlled: whether it is on. */
|
|
6
9
|
checked?: boolean | undefined;
|
|
10
|
+
/** On at first, when uncontrolled. */
|
|
7
11
|
defaultChecked?: boolean | undefined;
|
|
12
|
+
/** Called when the person turns it on or off, with the new state. */
|
|
8
13
|
onChange?: ((checked: boolean) => void) | undefined;
|
|
14
|
+
/** Name it is submitted under in a form, when on. */
|
|
9
15
|
name?: string | undefined;
|
|
16
|
+
/** The value submitted with `name` when on. The browser sends "on" when this is not set. */
|
|
10
17
|
value?: string | undefined;
|
|
18
|
+
/** It must be on for the form to submit. */
|
|
11
19
|
required?: boolean | undefined;
|
|
20
|
+
/** It cannot be changed and is not submitted with a form. */
|
|
12
21
|
disabled?: boolean | undefined;
|
|
22
|
+
/** Size of the control and its text. Default "md". */
|
|
13
23
|
size?: Size | undefined;
|
|
24
|
+
/** Fill colour when on. Default "accent". */
|
|
14
25
|
tone?: Tone | undefined;
|
|
26
|
+
/** Id of the native input; one is generated when not set. */
|
|
15
27
|
id?: string | undefined;
|
|
28
|
+
/** Added to the root element (the label that wraps the row), for layout. */
|
|
16
29
|
className?: string | undefined;
|
|
30
|
+
/** Layout only, applied to the root element. */
|
|
17
31
|
style?: CSSProperties | undefined;
|
|
18
32
|
}
|
|
19
33
|
/** Shared row for Checkbox and Switch: a native checkbox over a drawn control, with a fully clickable label. */
|
|
20
|
-
export declare function ChoiceRow({ kind, label, description, checked, defaultChecked, onChange, indeterminate, size, tone, id, className, style, ...input }: ChoiceRowProps & {
|
|
34
|
+
export declare function ChoiceRow({ kind, label, description, checked, defaultChecked, onChange, indeterminate, strike, size, tone, id, className, style, ...input }: ChoiceRowProps & {
|
|
21
35
|
kind: "checkbox" | "switch" | "radio";
|
|
22
36
|
indeterminate?: boolean | undefined;
|
|
37
|
+
/** Checkbox only (`strikeWhenChecked`): kept out of `ChoiceRowProps`, so Switch and RadioGroup do not gain it. */
|
|
38
|
+
strike?: boolean | undefined;
|
|
23
39
|
}): import("react").JSX.Element;
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Icon as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { Icon as l } from "../../foundations/Icon/Icon.js";
|
|
3
|
+
import { check as N } from "../../icons/check.js";
|
|
4
|
+
import { ChoiceBase as w } from "../../foundations/ChoiceBase/ChoiceBase.js";
|
|
5
|
+
import { useField as v } from "../../foundations/field.js";
|
|
6
6
|
import { minus as I } from "../../icons/minus.js";
|
|
7
7
|
import { Fragment as g, jsx as c, jsxs as i } from "react/jsx-runtime";
|
|
8
|
-
function
|
|
9
|
-
const e =
|
|
10
|
-
id:
|
|
8
|
+
function z({ kind: a, label: t, description: s, checked: o, defaultChecked: m, onChange: h, indeterminate: n, strike: b, size: y = "md", tone: p = "accent", id: f, className: r, style: x, ...d }) {
|
|
9
|
+
const e = v({
|
|
10
|
+
id: f,
|
|
11
11
|
description: s
|
|
12
12
|
});
|
|
13
13
|
return /* @__PURE__ */ i("label", {
|
|
14
14
|
htmlFor: e.id,
|
|
15
15
|
className: `cy-choice${r ? ` ${r}` : ""}`,
|
|
16
|
-
"data-size":
|
|
17
|
-
"data-tone":
|
|
18
|
-
"data-disabled":
|
|
19
|
-
|
|
16
|
+
"data-size": y,
|
|
17
|
+
"data-tone": p,
|
|
18
|
+
"data-disabled": d.disabled ? "" : void 0,
|
|
19
|
+
"data-strike": b ? "" : void 0,
|
|
20
|
+
style: x,
|
|
20
21
|
children: [/* @__PURE__ */ i("span", {
|
|
21
22
|
className: `cy-${a}`,
|
|
22
|
-
children: [/* @__PURE__ */ c(
|
|
23
|
-
...
|
|
23
|
+
children: [/* @__PURE__ */ c(w, {
|
|
24
|
+
...d,
|
|
24
25
|
id: e.id,
|
|
25
26
|
type: a === "radio" ? "radio" : "checkbox",
|
|
26
27
|
role: a === "switch" ? "switch" : void 0,
|
|
@@ -28,11 +29,11 @@ function B({ kind: a, label: t, description: s, checked: o, defaultChecked: m, o
|
|
|
28
29
|
"aria-labelledby": e.labelId,
|
|
29
30
|
"aria-describedby": e.describedBy,
|
|
30
31
|
...o !== void 0 ? { checked: o } : { defaultChecked: m },
|
|
31
|
-
onChange: (
|
|
32
|
-
}), a === "checkbox" ? /* @__PURE__ */ i(g, { children: [/* @__PURE__ */ c(
|
|
33
|
-
icon:
|
|
32
|
+
onChange: (u) => h?.(u.currentTarget.checked)
|
|
33
|
+
}), a === "checkbox" ? /* @__PURE__ */ i(g, { children: [/* @__PURE__ */ c(l, {
|
|
34
|
+
icon: N,
|
|
34
35
|
className: "cy-checkbox-mark"
|
|
35
|
-
}), /* @__PURE__ */ c(
|
|
36
|
+
}), /* @__PURE__ */ c(l, {
|
|
36
37
|
icon: I,
|
|
37
38
|
className: "cy-checkbox-dash"
|
|
38
39
|
})] }) : a === "switch" ? /* @__PURE__ */ c("span", { className: "cy-reset cy-switch-thumb" }) : null]
|
|
@@ -51,7 +52,7 @@ function B({ kind: a, label: t, description: s, checked: o, defaultChecked: m, o
|
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
export {
|
|
54
|
-
|
|
55
|
+
z as ChoiceRow
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
//# sourceMappingURL=ChoiceRow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceRow.js","names":["_Fragment","Icon","
|
|
1
|
+
{"version":3,"file":"ChoiceRow.js","names":["_Fragment","Icon","check","ChoiceBase","useField","minus","Fragment","jsx","jsxs","ChoiceRow","kind","label","description","checked","defaultChecked","onChange","indeterminate","strike","size","tone","id","className","style","input","field","e"],"sources":["../../../src/components/Checkbox/ChoiceRow.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { ChoiceBase } from \"../../foundations/ChoiceBase/ChoiceBase.js\";\nimport { useField } from \"../../foundations/field.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport { check } from \"../../icons/check.js\";\nimport { minus } from \"../../icons/minus.js\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\n\nexport interface ChoiceRowProps {\n /** The control's label. Pressing it toggles the control. */\n label: ReactNode;\n /** Help text shown under the label and read with the control. */\n description?: ReactNode | undefined;\n /** Controlled: whether it is on. */\n checked?: boolean | undefined;\n /** On at first, when uncontrolled. */\n defaultChecked?: boolean | undefined;\n /** Called when the person turns it on or off, with the new state. */\n onChange?: ((checked: boolean) => void) | undefined;\n /** Name it is submitted under in a form, when on. */\n name?: string | undefined;\n /** The value submitted with `name` when on. The browser sends \"on\" when this is not set. */\n value?: string | undefined;\n /** It must be on for the form to submit. */\n required?: boolean | undefined;\n /** It cannot be changed and is not submitted with a form. */\n disabled?: boolean | undefined;\n /** Size of the control and its text. Default \"md\". */\n size?: Size | undefined;\n /** Fill colour when on. Default \"accent\". */\n tone?: Tone | undefined;\n /** Id of the native input; one is generated when not set. */\n id?: string | undefined;\n /** Added to the root element (the label that wraps the row), for layout. */\n className?: string | undefined;\n /** Layout only, applied to the root element. */\n style?: CSSProperties | undefined;\n}\n\n/** Shared row for Checkbox and Switch: a native checkbox over a drawn control, with a fully clickable label. */\nexport function ChoiceRow({\n kind,\n label,\n description,\n checked,\n defaultChecked,\n onChange,\n indeterminate,\n strike,\n size = \"md\",\n tone = \"accent\",\n id,\n className,\n style,\n ...input\n}: ChoiceRowProps & {\n kind: \"checkbox\" | \"switch\" | \"radio\";\n indeterminate?: boolean | undefined;\n /** Checkbox only (`strikeWhenChecked`): kept out of `ChoiceRowProps`, so Switch and RadioGroup do not gain it. */\n strike?: boolean | undefined;\n}) {\n const field = useField({ id, description });\n return (\n <label\n htmlFor={field.id}\n className={`cy-choice${className ? ` ${className}` : \"\"}`}\n data-size={size}\n data-tone={tone}\n data-disabled={input.disabled ? \"\" : undefined}\n data-strike={strike ? \"\" : undefined}\n style={style}\n >\n <span className={`cy-${kind}`}>\n <ChoiceBase\n {...input}\n id={field.id}\n type={kind === \"radio\" ? \"radio\" : \"checkbox\"}\n role={kind === \"switch\" ? \"switch\" : undefined}\n indeterminate={indeterminate ?? false}\n aria-labelledby={field.labelId}\n aria-describedby={field.describedBy}\n {...(checked !== undefined ? { checked } : { defaultChecked })}\n onChange={(e) => onChange?.(e.currentTarget.checked)}\n />\n {kind === \"checkbox\" ? (\n <>\n <Icon icon={check} className=\"cy-checkbox-mark\" />\n <Icon icon={minus} className=\"cy-checkbox-dash\" />\n </>\n ) : kind === \"switch\" ? (\n <span className=\"cy-reset cy-switch-thumb\" />\n ) : null}\n </span>\n <span className=\"cy-choice-text\">\n <span id={field.labelId} className=\"cy-choice-label\">\n {label}\n </span>\n {description && (\n <span id={field.descriptionId} className=\"cy-choice-description\">\n {description}\n </span>\n )}\n </span>\n </label>\n );\n}\n"],"mappings":";;;;;;;AAwCA,SAAgBS,EAAU,EACxB,MAAAC,GACA,OAAAC,GACA,aAAAC,GACA,SAAAC,GACA,gBAAAC,GACA,UAAAC,GACA,eAAAC,GACA,QAAAC,GACA,MAAAC,IAAO,MACP,MAAAC,IAAO,UACP,IAAAC,GACA,WAAAC,GACA,OAAAC,GACA,GAAGC,EAAA,GAMF;AACD,QAAMC,IAAQpB,EAAS;AAAA,IAAE,IAAAgB;AAAA,IAAI,aAAAR;AAAA,EAAY,CAAC;AAC1C,SACE,gBAAAJ,EAAC,SAAD;AAAA,IACE,SAASgB,EAAM;AAAA,IACf,WAAW,YAAYH,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACrD,aAAWH;AAAA,IACX,aAAWC;AAAA,IACX,iBAAeI,EAAM,WAAW,KAAK;AAAA,IACrC,eAAaN,IAAS,KAAK;AAAA,IACpB,OAAAK;AAAA,IAPT,UAAA,CASE,gBAAAd,EAAC,QAAD;AAAA,MAAM,WAAW,MAAME,CAAA;AAAA,MAAvB,UAAA,CACE,gBAAAH,EAACJ,GAAD;AAAA,QACE,GAAIoB;AAAA,QACJ,IAAIC,EAAM;AAAA,QACV,MAAMd,MAAS,UAAU,UAAU;AAAA,QACnC,MAAMA,MAAS,WAAW,WAAW;AAAA,QACrC,eAAeM,KAAiB;AAAA,QAChC,mBAAiBQ,EAAM;AAAA,QACvB,oBAAkBA,EAAM;AAAA,QACxB,GAAKX,MAAY,SAAY,EAAE,SAAAA,EAAQ,IAAI,EAAE,gBAAAC,EAAe;AAAA,QAC5D,UAAA,CAAWW,MAAMV,IAAWU,EAAE,cAAc,OAAO;AAAA,MACpD,CAAA,GACAf,MAAS,aACR,gBAAAF,EAAAR,GAAA,EAAA,UAAA,CACE,gBAAAO,EAACN,GAAD;AAAA,QAAM,MAAMC;AAAA,QAAO,WAAU;AAAA,MAAoB,CAAA,GACjD,gBAAAK,EAACN,GAAD;AAAA,QAAM,MAAMI;AAAA,QAAO,WAAU;AAAA,MAAoB,CAAA,CACjD,EAAA,CAAA,IACAK,MAAS,WACX,gBAAAH,EAAC,QAAD,EAAM,WAAU,2BAA4B,CAAA,IAC1C,IACA;AAAA,IACN,CAAA,GAAA,gBAAAC,EAAC,QAAD;AAAA,MAAM,WAAU;AAAA,MAAhB,UAAA,CACE,gBAAAD,EAAC,QAAD;AAAA,QAAM,IAAIiB,EAAM;AAAA,QAAS,WAAU;AAAA,QAChC,UAAAb;AAAA,MACG,CAAA,GACLC,KACC,gBAAAL,EAAC,QAAD;AAAA,QAAM,IAAIiB,EAAM;AAAA,QAAe,WAAU;AAAA,QACtC,UAAAZ;AAAA,MACG,CAAA,CAEJ;AAAA,IACD,CAAA,CAAA;AAAA,E;AAEX"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type CSSProperties } from "react";
|
|
2
|
+
export interface ChecklistTokens {
|
|
3
|
+
/** Space between rows, and between the rows and the add field. */
|
|
4
|
+
gap: string;
|
|
5
|
+
/** Space between a row's checkbox, name and buttons. */
|
|
6
|
+
rowGap: string;
|
|
7
|
+
}
|
|
8
|
+
declare module "../../tokens/schema.js" {
|
|
9
|
+
interface ComponentTokens {
|
|
10
|
+
checklist: ChecklistTokens;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface ChecklistItem {
|
|
14
|
+
/** Stable and unique: React keys, focus and reordering follow it. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** The row's name. */
|
|
17
|
+
label: string;
|
|
18
|
+
/** Whether it is ticked. */
|
|
19
|
+
done: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ChecklistLabels {
|
|
22
|
+
/** Name and placeholder of the field that adds a row. Default "Add an item". */
|
|
23
|
+
add: string;
|
|
24
|
+
/** Name of the button next to that field. Default "Add". */
|
|
25
|
+
addButton: string;
|
|
26
|
+
/** Name of a row's rename button, and of the field it opens. Default "Rename Buy milk". */
|
|
27
|
+
rename: (name: string) => string;
|
|
28
|
+
/** Name of a row's remove button. Default "Remove Buy milk". */
|
|
29
|
+
remove: (name: string) => string;
|
|
30
|
+
}
|
|
31
|
+
export interface ChecklistProps {
|
|
32
|
+
/** What the rows are ("Subtasks"). Names the list; shown above it unless `labelHidden`. */
|
|
33
|
+
label: string;
|
|
34
|
+
/** Visually hide the label (it still names the list). Default false. */
|
|
35
|
+
labelHidden?: boolean;
|
|
36
|
+
/** The rows, when you control them: `{ id, label, done }`. */
|
|
37
|
+
items?: ChecklistItem[] | undefined;
|
|
38
|
+
/** Starting rows when uncontrolled. */
|
|
39
|
+
defaultItems?: ChecklistItem[];
|
|
40
|
+
/** Called with the full list after each change: a row added, ticked, renamed, removed or moved. */
|
|
41
|
+
onChange?: ((items: ChecklistItem[]) => void) | undefined;
|
|
42
|
+
/** Makes the id of a new row. Default: `crypto.randomUUID()`, or a time-based id where that is missing. */
|
|
43
|
+
createId?: () => string;
|
|
44
|
+
/** The most rows the list may hold; the add field turns off when it is full. */
|
|
45
|
+
maxItems?: number | undefined;
|
|
46
|
+
/** Rows get a grip to drag, or to move with Space and the arrow keys (SortableList). Default false. */
|
|
47
|
+
reorderable?: boolean;
|
|
48
|
+
/** Turns off every checkbox, field and button. Default false. */
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
/** Shows the rows as they are: nothing can be ticked, added, renamed, removed or moved. Default false. */
|
|
51
|
+
readOnly?: boolean;
|
|
52
|
+
/** Size of the checkboxes, text, fields and buttons. Default "md". */
|
|
53
|
+
size?: "sm" | "md";
|
|
54
|
+
/** Replace the built-in English text. */
|
|
55
|
+
labels?: Partial<ChecklistLabels>;
|
|
56
|
+
/** Added to the root element, for layout. */
|
|
57
|
+
className?: string;
|
|
58
|
+
/** Layout only. Restyle through --cy-checklist-* tokens. */
|
|
59
|
+
style?: CSSProperties;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A list of rows people add, tick, rename and remove: a task's subtasks, a packing list, the steps of a recipe.
|
|
63
|
+
* Built from Checkbox, TextField and IconButton; with `reorderable` the rows sit in a SortableList.
|
|
64
|
+
*/
|
|
65
|
+
export declare const Checklist: import("react").ForwardRefExoticComponent<ChecklistProps & import("react").RefAttributes<HTMLDivElement>>;
|