@leonardaustin/ui 0.25.0 → 0.26.1
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 +11 -0
- package/dist/components/app-shell/AppShell.d.ts +3 -3
- package/dist/components/app-shell/AppShell.js +82 -0
- package/dist/components/app-shell/AuthLayout.d.ts +3 -3
- package/dist/components/app-shell/AuthLayout.js +16 -0
- package/dist/components/app-shell/BackLink.d.ts +3 -3
- package/dist/components/app-shell/BackLink.js +19 -0
- package/dist/components/app-shell/BottomNav.d.ts +3 -2
- package/dist/components/app-shell/BottomNav.js +37 -0
- package/dist/components/app-shell/Breadcrumbs.d.ts +3 -2
- package/dist/components/app-shell/Breadcrumbs.js +46 -0
- package/dist/components/app-shell/CommandPalette.d.ts +3 -2
- package/dist/components/app-shell/CommandPalette.js +119 -0
- package/dist/components/app-shell/MobileDrawer.d.ts +3 -3
- package/dist/components/app-shell/MobileDrawer.js +128 -0
- package/dist/components/app-shell/Sidebar.d.ts +3 -3
- package/dist/components/app-shell/Sidebar.js +355 -0
- package/dist/components/app-shell/ThemeMenu.d.ts +3 -2
- package/dist/components/app-shell/ThemeMenu.js +273 -0
- package/dist/components/app-shell/TopBar.d.ts +3 -3
- package/dist/components/app-shell/TopBar.js +129 -0
- package/dist/components/app-shell/commandPaletteEvents.js +16 -0
- package/dist/components/app-shell/navigation.js +21 -0
- package/dist/components/app-shell/themeMenuEvents.js +7 -0
- package/dist/components/charts/AreaChart.d.ts +4 -3
- package/dist/components/charts/AreaChart.js +217 -0
- package/dist/components/charts/BarChart.d.ts +4 -3
- package/dist/components/charts/BarChart.js +91 -0
- package/dist/components/charts/DonutChart.d.ts +4 -3
- package/dist/components/charts/DonutChart.js +172 -0
- package/dist/components/charts/RadarChart.d.ts +4 -3
- package/dist/components/charts/RadarChart.js +142 -0
- package/dist/components/charts/RadialBarChart.d.ts +4 -3
- package/dist/components/charts/RadialBarChart.js +219 -0
- package/dist/components/charts/SparkLine.d.ts +4 -3
- package/dist/components/charts/SparkLine.js +39 -0
- package/dist/components/charts/StackedBarChart.d.ts +4 -3
- package/dist/components/charts/StackedBarChart.js +249 -0
- package/dist/components/charts/VerticalBarChart.d.ts +4 -3
- package/dist/components/charts/VerticalBarChart.js +143 -0
- package/dist/components/charts/chartUtils.js +68 -0
- package/dist/components/tables/ColumnPicker.d.ts +3 -3
- package/dist/components/tables/ColumnPicker.js +59 -0
- package/dist/components/tables/Pagination.d.ts +3 -3
- package/dist/components/tables/Pagination.js +56 -0
- package/dist/components/tables/ResourceTable.d.ts +3 -3
- package/dist/components/tables/ResourceTable.js +88 -0
- package/dist/components/tables/Table.js +95 -0
- package/dist/components/tables/sortRows.js +11 -0
- package/dist/components/ui/Accordion.d.ts +2 -1
- package/dist/components/ui/Accordion.js +35 -0
- package/dist/components/ui/Alert.d.ts +3 -2
- package/dist/components/ui/Alert.js +51 -0
- package/dist/components/ui/AttachmentList.d.ts +5 -5
- package/dist/components/ui/AttachmentList.js +90 -0
- package/dist/components/ui/AudioPlayer.d.ts +5 -2
- package/dist/components/ui/AudioPlayer.js +447 -0
- package/dist/components/ui/AuthCard.d.ts +3 -3
- package/dist/components/ui/AuthCard.js +39 -0
- package/dist/components/ui/AuthorByline.d.ts +3 -3
- package/dist/components/ui/AuthorByline.js +23 -0
- package/dist/components/ui/Avatar.d.ts +3 -2
- package/dist/components/ui/Avatar.js +36 -0
- package/dist/components/ui/Badge.d.ts +3 -2
- package/dist/components/ui/Badge.js +47 -0
- package/dist/components/ui/Button.d.ts +3 -3
- package/dist/components/ui/Button.js +83 -0
- package/dist/components/ui/Calendar.d.ts +3 -3
- package/dist/components/ui/Calendar.js +344 -0
- package/dist/components/ui/CalendarGrid.d.ts +3 -2
- package/dist/components/ui/CalendarGrid.js +136 -0
- package/dist/components/ui/Card.d.ts +6 -5
- package/dist/components/ui/Card.js +53 -0
- package/dist/components/ui/CharacterCount.d.ts +3 -3
- package/dist/components/ui/CharacterCount.js +27 -0
- package/dist/components/ui/Checkbox.d.ts +10 -8
- package/dist/components/ui/Checkbox.js +52 -0
- package/dist/components/ui/CodeInput.d.ts +7 -4
- package/dist/components/ui/CodeInput.js +97 -0
- package/dist/components/ui/Combobox.d.ts +8 -6
- package/dist/components/ui/Combobox.js +213 -0
- package/dist/components/ui/CopyButton.d.ts +1 -1
- package/dist/components/ui/CopyButton.js +57 -0
- package/dist/components/ui/DangerZone.d.ts +3 -3
- package/dist/components/ui/DangerZone.js +23 -0
- package/dist/components/ui/DatePartsInput.d.ts +6 -4
- package/dist/components/ui/DatePartsInput.js +138 -0
- package/dist/components/ui/DatePicker.d.ts +9 -4
- package/dist/components/ui/DatePicker.js +84 -0
- package/dist/components/ui/DateRangePicker.d.ts +7 -4
- package/dist/components/ui/DateRangePicker.js +143 -0
- package/dist/components/ui/DateTimePicker.d.ts +7 -4
- package/dist/components/ui/DateTimePicker.js +267 -0
- package/dist/components/ui/DetailPanel.d.ts +3 -3
- package/dist/components/ui/DetailPanel.js +183 -0
- package/dist/components/ui/Dialog.d.ts +3 -3
- package/dist/components/ui/Dialog.js +411 -0
- package/dist/components/ui/DialogActions.d.ts +3 -3
- package/dist/components/ui/DialogActions.js +35 -0
- package/dist/components/ui/Disclosure.d.ts +3 -3
- package/dist/components/ui/Disclosure.js +45 -0
- package/dist/components/ui/DividerLabel.d.ts +3 -3
- package/dist/components/ui/DividerLabel.js +20 -0
- package/dist/components/ui/DropdownMenu.d.ts +3 -3
- package/dist/components/ui/DropdownMenu.js +229 -0
- package/dist/components/ui/EmptyState.d.ts +3 -3
- package/dist/components/ui/EmptyState.js +31 -0
- package/dist/components/ui/ErrorBoundary.js +46 -0
- package/dist/components/ui/FieldContext.js +8 -0
- package/dist/components/ui/Fieldset.d.ts +2 -2
- package/dist/components/ui/Fieldset.js +39 -0
- package/dist/components/ui/FilterButton.d.ts +4 -7
- package/dist/components/ui/FilterButton.js +17 -0
- package/dist/components/ui/FilterDropdown.d.ts +4 -4
- package/dist/components/ui/FilterDropdown.js +18 -0
- package/dist/components/ui/FormField.d.ts +4 -4
- package/dist/components/ui/FormField.js +68 -0
- package/dist/components/ui/Grid.d.ts +1 -1
- package/dist/components/ui/Grid.js +19 -0
- package/dist/components/ui/GridItem.d.ts +1 -1
- package/dist/components/ui/GridItem.js +16 -0
- package/dist/components/ui/Inline.d.ts +1 -1
- package/dist/components/ui/Inline.js +24 -0
- package/dist/components/ui/Kbd.d.ts +3 -2
- package/dist/components/ui/Kbd.js +13 -0
- package/dist/components/ui/ListItemLink.d.ts +3 -3
- package/dist/components/ui/ListItemLink.js +44 -0
- package/dist/components/ui/LoadingSpinner.d.ts +3 -2
- package/dist/components/ui/LoadingSpinner.js +19 -0
- package/dist/components/ui/MessageBubble.d.ts +2 -2
- package/dist/components/ui/MessageBubble.js +41 -0
- package/dist/components/ui/MetadataGrid.d.ts +5 -3
- package/dist/components/ui/MetadataGrid.js +76 -0
- package/dist/components/ui/MetricCard.d.ts +3 -3
- package/dist/components/ui/MetricCard.js +51 -0
- package/dist/components/ui/NavTabs.d.ts +2 -2
- package/dist/components/ui/NavTabs.js +29 -0
- package/dist/components/ui/OAuthButton.d.ts +2 -2
- package/dist/components/ui/OAuthButton.js +55 -0
- package/dist/components/ui/OverlineLabel.d.ts +3 -3
- package/dist/components/ui/OverlineLabel.js +13 -0
- package/dist/components/ui/PageHeader.d.ts +3 -3
- package/dist/components/ui/PageHeader.js +33 -0
- package/dist/components/ui/PageSection.d.ts +3 -3
- package/dist/components/ui/PageSection.js +31 -0
- package/dist/components/ui/PaginationBar.d.ts +3 -3
- package/dist/components/ui/PaginationBar.js +62 -0
- package/dist/components/ui/PasswordInput.d.ts +3 -3
- package/dist/components/ui/PasswordInput.js +62 -0
- package/dist/components/ui/PasswordRequirements.d.ts +3 -2
- package/dist/components/ui/PasswordRequirements.js +34 -0
- package/dist/components/ui/Popover.d.ts +3 -3
- package/dist/components/ui/Popover.js +53 -0
- package/dist/components/ui/ProfileHeader.d.ts +3 -3
- package/dist/components/ui/ProfileHeader.js +54 -0
- package/dist/components/ui/ProgressBar.d.ts +3 -3
- package/dist/components/ui/ProgressBar.js +42 -0
- package/dist/components/ui/ProseContent.d.ts +3 -3
- package/dist/components/ui/ProseContent.js +13 -0
- package/dist/components/ui/QrCode.d.ts +3 -3
- package/dist/components/ui/QrCode.js +47 -0
- package/dist/components/ui/Radio.d.ts +9 -6
- package/dist/components/ui/Radio.js +58 -0
- package/dist/components/ui/RadioPill.d.ts +7 -4
- package/dist/components/ui/RadioPill.js +53 -0
- package/dist/components/ui/ReorderList.d.ts +3 -3
- package/dist/components/ui/ReorderList.js +123 -0
- package/dist/components/ui/SearchInput.d.ts +7 -5
- package/dist/components/ui/SearchInput.js +49 -0
- package/dist/components/ui/SectionHeader.d.ts +3 -3
- package/dist/components/ui/SectionHeader.js +13 -0
- package/dist/components/ui/Select.d.ts +4 -4
- package/dist/components/ui/Select.js +117 -0
- package/dist/components/ui/SelectDropdown.d.ts +8 -3
- package/dist/components/ui/SelectDropdown.js +206 -0
- package/dist/components/ui/SettingRow.d.ts +5 -5
- package/dist/components/ui/SettingRow.js +25 -0
- package/dist/components/ui/SideSheet.d.ts +3 -3
- package/dist/components/ui/SideSheet.js +164 -0
- package/dist/components/ui/Skeleton.d.ts +3 -3
- package/dist/components/ui/Skeleton.js +18 -0
- package/dist/components/ui/Slider.d.ts +11 -6
- package/dist/components/ui/Slider.js +58 -0
- package/dist/components/ui/SplitPaneLayout.d.ts +5 -5
- package/dist/components/ui/SplitPaneLayout.js +22 -0
- package/dist/components/ui/Stack.d.ts +1 -1
- package/dist/components/ui/Stack.js +18 -0
- package/dist/components/ui/StatusDot.d.ts +3 -2
- package/dist/components/ui/StatusDot.js +24 -0
- package/dist/components/ui/StepProgress.d.ts +3 -2
- package/dist/components/ui/StepProgress.js +33 -0
- package/dist/components/ui/Tabs.d.ts +5 -5
- package/dist/components/ui/Tabs.js +63 -0
- package/dist/components/ui/TextInput.d.ts +4 -4
- package/dist/components/ui/TextInput.js +57 -0
- package/dist/components/ui/Textarea.d.ts +3 -3
- package/dist/components/ui/Textarea.js +59 -0
- package/dist/components/ui/ThemePreview.d.ts +3 -3
- package/dist/components/ui/ThemePreview.js +28 -0
- package/dist/components/ui/TimeInput.d.ts +7 -6
- package/dist/components/ui/TimeInput.js +22 -0
- package/dist/components/ui/Timeline.d.ts +3 -2
- package/dist/components/ui/Timeline.js +29 -0
- package/dist/components/ui/Toast.js +121 -0
- package/dist/components/ui/Toggle.d.ts +5 -3
- package/dist/components/ui/Toggle.js +34 -0
- package/dist/components/ui/Toolbar.d.ts +3 -3
- package/dist/components/ui/Toolbar.js +70 -0
- package/dist/components/ui/Tooltip.js +91 -0
- package/dist/components/ui/TranscriptLine.d.ts +3 -3
- package/dist/components/ui/TranscriptLine.js +40 -0
- package/dist/components/ui/UploadDropzone.d.ts +3 -5
- package/dist/components/ui/UploadDropzone.js +55 -0
- package/dist/components/ui/badgeColors.js +5 -0
- package/dist/components/ui/calendar/AgendaView.js +140 -0
- package/dist/components/ui/calendar/MonthView.js +321 -0
- package/dist/components/ui/calendar/TimeGrid.js +501 -0
- package/dist/components/ui/calendar/TimelineView.js +311 -0
- package/dist/components/ui/calendar/context.js +10 -0
- package/dist/components/ui/calendar/items.js +152 -0
- package/dist/components/ui/calendar/types.js +38 -0
- package/dist/components/ui/calendar/useGridInteraction.js +393 -0
- package/dist/components/ui/useFieldControl.d.ts +1 -1
- package/dist/components/ui/useFieldControl.js +17 -0
- package/dist/config/theme.js +219 -0
- package/dist/core.css +2933 -0
- package/dist/hooks/useAnchoredPopup.js +162 -0
- package/dist/hooks/useApplyTheme.js +16 -0
- package/dist/hooks/useControllableState.d.ts +14 -0
- package/dist/hooks/useControllableState.js +10 -0
- package/dist/hooks/useDismiss.js +24 -0
- package/dist/hooks/useFocusTrap.js +42 -0
- package/dist/hooks/useOverlayStack.js +23 -0
- package/dist/hooks/usePopover.js +47 -0
- package/dist/hooks/usePortalContainer.js +14 -0
- package/dist/hooks/useSettings.js +8 -0
- package/dist/hooks/useTheme.js +8 -0
- package/dist/hooks/useTypeahead.js +19 -0
- package/dist/index.js +133 -12884
- package/dist/lib/anchorPlacement.js +75 -0
- package/dist/lib/calendar.js +666 -0
- package/dist/lib/cn.js +228 -0
- package/dist/lib/codeInput.js +51 -0
- package/dist/lib/dateParts.js +31 -0
- package/dist/lib/dialogDrag.js +45 -0
- package/dist/lib/dialogResize.js +47 -0
- package/dist/lib/formatDate.js +29 -0
- package/dist/lib/formatMediaTime.js +7 -0
- package/dist/lib/layout.js +29 -0
- package/dist/lib/math.js +6 -0
- package/dist/lib/mergeRefs.d.ts +6 -0
- package/dist/lib/mergeRefs.js +17 -0
- package/dist/lib/months.js +30 -0
- package/dist/lib/overlayStack.js +47 -0
- package/dist/lib/panelResize.js +8 -0
- package/dist/lib/passwordRequirements.js +23 -0
- package/dist/lib/qrCode.js +570 -0
- package/dist/lib/tones.js +104 -0
- package/dist/lib/typeahead.js +31 -0
- package/dist/providers/ControlSizeContext.js +9 -0
- package/dist/providers/ControlSizeProvider.js +11 -0
- package/dist/providers/SettingsContext.js +53 -0
- package/dist/providers/SettingsProvider.js +249 -0
- package/dist/providers/ThemeContext.js +5 -0
- package/dist/providers/ThemeProvider.js +17 -0
- package/dist/providers/accentColors.js +75 -0
- package/dist/providers/themeClasses.d.ts +1 -0
- package/dist/providers/themeClasses.js +20 -0
- package/dist/styles.css +228 -176
- package/dist/themes/cyber-brutal-dark.css +53 -0
- package/dist/themes/cyber-brutal-light.css +75 -0
- package/dist/themes/glass-dark.css +217 -0
- package/dist/themes/glass-light.css +215 -0
- package/dist/themes/hashi.css +66 -0
- package/dist/themes/light-inverted.css +32 -0
- package/dist/themes/light.css +1 -0
- package/dist/themes/monokai.css +51 -0
- package/dist/themes/solarized.css +55 -0
- package/package.json +3 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { useControllableState as t } from "../../hooks/useControllableState.js";
|
|
3
|
+
import { TextInput as n } from "./TextInput.js";
|
|
4
|
+
import { datePartsError as r } from "../../lib/dateParts.js";
|
|
5
|
+
import { useEffect as i, useId as a, useRef as o, useState as s } from "react";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { ChevronDown as u } from "lucide-react";
|
|
8
|
+
//#region src/components/ui/DatePartsInput.tsx
|
|
9
|
+
var d = {
|
|
10
|
+
day: "",
|
|
11
|
+
month: "",
|
|
12
|
+
year: ""
|
|
13
|
+
};
|
|
14
|
+
function f({ value: f, defaultValue: p = d, onValueChange: m, label: h, hint: g, error: _, id: v, name: y, disabled: b, required: x, className: S, inputProps: C, minYear: w = 1900, maxYear: T = 2100, ref: E, ...D }) {
|
|
15
|
+
let O = a(), [k, A] = t({
|
|
16
|
+
value: f,
|
|
17
|
+
defaultValue: p,
|
|
18
|
+
onChange: m
|
|
19
|
+
}), j = o({}), [M, N] = s(!1);
|
|
20
|
+
if (!Number.isInteger(w) || !Number.isInteger(T) || w < 1 || T > 9999 || w > T) throw RangeError("DatePartsInput requires year bounds between 1 and 9999, with minYear <= maxYear");
|
|
21
|
+
let P = r(k, {
|
|
22
|
+
required: x,
|
|
23
|
+
minYear: w,
|
|
24
|
+
maxYear: T
|
|
25
|
+
}), F = k.day !== "" && k.month !== "" && k.year.length >= 4, I = _ || (M || F ? P : void 0);
|
|
26
|
+
i(() => {
|
|
27
|
+
Object.values(j.current).forEach((e) => e?.setCustomValidity(P ?? ""));
|
|
28
|
+
}, [P]);
|
|
29
|
+
let L = [
|
|
30
|
+
31,
|
|
31
|
+
Number(k.year) % 4 == 0 && (Number(k.year) % 100 != 0 || Number(k.year) % 400 == 0) ? 29 : 28,
|
|
32
|
+
31,
|
|
33
|
+
30,
|
|
34
|
+
31,
|
|
35
|
+
30,
|
|
36
|
+
31,
|
|
37
|
+
31,
|
|
38
|
+
30,
|
|
39
|
+
31,
|
|
40
|
+
30,
|
|
41
|
+
31
|
|
42
|
+
][Number(k.month) - 1] ?? 31, R = {
|
|
43
|
+
day: Array.from({ length: L }, (e, t) => String(t + 1)),
|
|
44
|
+
month: Array.from({ length: 12 }, (e, t) => String(t + 1)),
|
|
45
|
+
year: Array.from({ length: T - w + 1 }, (e, t) => String(T - t))
|
|
46
|
+
}, z = v ?? O, B = [g && `${z}-hint`, I && `${z}-error`].filter(Boolean).join(" ") || void 0, V = [D["aria-describedby"], B].filter(Boolean).join(" ") || void 0;
|
|
47
|
+
return /* @__PURE__ */ l("fieldset", {
|
|
48
|
+
ref: E,
|
|
49
|
+
...D,
|
|
50
|
+
id: z,
|
|
51
|
+
disabled: b,
|
|
52
|
+
className: e("space-y-2", S),
|
|
53
|
+
"aria-describedby": V,
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ l("legend", {
|
|
56
|
+
className: "ui-field-label text-xs font-medium",
|
|
57
|
+
children: [h, x && /* @__PURE__ */ c("span", { children: " (required)" })]
|
|
58
|
+
}),
|
|
59
|
+
g && /* @__PURE__ */ c("p", {
|
|
60
|
+
id: `${z}-hint`,
|
|
61
|
+
className: "text-text-tertiary text-xs",
|
|
62
|
+
children: g
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ c("div", {
|
|
65
|
+
className: "ui-date-parts",
|
|
66
|
+
children: [
|
|
67
|
+
"day",
|
|
68
|
+
"month",
|
|
69
|
+
"year"
|
|
70
|
+
].map((e) => /* @__PURE__ */ l("div", {
|
|
71
|
+
className: "ui-date-part",
|
|
72
|
+
children: [/* @__PURE__ */ c(n, {
|
|
73
|
+
inputMode: "numeric",
|
|
74
|
+
"data-1p-ignore": "true",
|
|
75
|
+
...C?.[e],
|
|
76
|
+
ref: (t) => {
|
|
77
|
+
j.current[e] = t;
|
|
78
|
+
let n = C?.[e]?.ref;
|
|
79
|
+
if (typeof n == "function") return n(t);
|
|
80
|
+
n && (n.current = t);
|
|
81
|
+
},
|
|
82
|
+
onBlur: (t) => {
|
|
83
|
+
N(!0), C?.[e]?.onBlur?.(t);
|
|
84
|
+
},
|
|
85
|
+
onInvalid: (t) => {
|
|
86
|
+
N(!0), C?.[e]?.onInvalid?.(t);
|
|
87
|
+
},
|
|
88
|
+
type: "text",
|
|
89
|
+
id: `${z}-${e}`,
|
|
90
|
+
label: e[0].toUpperCase() + e.slice(1),
|
|
91
|
+
name: y ? `${y}.${e}` : void 0,
|
|
92
|
+
value: k[e],
|
|
93
|
+
required: x,
|
|
94
|
+
"aria-invalid": I ? !0 : C?.[e]?.["aria-invalid"],
|
|
95
|
+
"aria-describedby": [B, C?.[e]?.["aria-describedby"]].filter(Boolean).join(" ") || void 0,
|
|
96
|
+
onChange: (t) => {
|
|
97
|
+
A({
|
|
98
|
+
...k,
|
|
99
|
+
[e]: t.target.value
|
|
100
|
+
}), C?.[e]?.onChange?.(t);
|
|
101
|
+
}
|
|
102
|
+
}), /* @__PURE__ */ l("div", {
|
|
103
|
+
className: "ui-date-part-selector",
|
|
104
|
+
children: [/* @__PURE__ */ c(u, {
|
|
105
|
+
"aria-hidden": "true",
|
|
106
|
+
className: "h-3.5 w-3.5"
|
|
107
|
+
}), /* @__PURE__ */ l("select", {
|
|
108
|
+
"aria-label": `Choose ${e}`,
|
|
109
|
+
disabled: b || C?.[e]?.disabled || C?.[e]?.readOnly,
|
|
110
|
+
value: R[e].includes(String(Number(k[e]))) ? String(Number(k[e])) : "",
|
|
111
|
+
onChange: (t) => {
|
|
112
|
+
A({
|
|
113
|
+
...k,
|
|
114
|
+
[e]: t.target.value
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
children: [/* @__PURE__ */ l("option", {
|
|
118
|
+
value: "",
|
|
119
|
+
disabled: !0,
|
|
120
|
+
children: ["Choose ", e]
|
|
121
|
+
}), R[e].map((e) => /* @__PURE__ */ c("option", {
|
|
122
|
+
value: e,
|
|
123
|
+
children: e
|
|
124
|
+
}, e))]
|
|
125
|
+
})]
|
|
126
|
+
})]
|
|
127
|
+
}, e))
|
|
128
|
+
}),
|
|
129
|
+
I && /* @__PURE__ */ c("p", {
|
|
130
|
+
id: `${z}-error`,
|
|
131
|
+
className: "text-danger-fg text-xs",
|
|
132
|
+
children: I
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
export { f as DatePartsInput };
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef } from "react";
|
|
1
2
|
import { type ControlSize } from "../../providers/ControlSizeContext";
|
|
2
|
-
export interface DatePickerProps {
|
|
3
|
+
export interface DatePickerProps extends Omit<ComponentPropsWithRef<"div">, "children" | "defaultValue" | "onChange"> {
|
|
3
4
|
/** Optional zone for instant-backed dates. Birth dates/civil dates should use DatePartsInput. */
|
|
4
5
|
timeZone?: string;
|
|
5
6
|
/** Inherit ControlSizeProvider or override this trigger’s sizing. */
|
|
6
7
|
controlSize?: ControlSize;
|
|
7
8
|
label?: string;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
/** Selected date (controlled). */
|
|
10
|
+
value?: Date | null;
|
|
11
|
+
/** Initially selected date when uncontrolled. */
|
|
12
|
+
defaultValue?: Date | null;
|
|
13
|
+
/** Called with the chosen date. */
|
|
14
|
+
onValueChange?: (date: Date | null) => void;
|
|
10
15
|
placeholder?: string;
|
|
11
16
|
/** Format function for display. Defaults to "MMM D, YYYY". */
|
|
12
17
|
format?: (date: Date) => string;
|
|
13
18
|
}
|
|
14
|
-
export declare function DatePicker({ controlSize, label, timeZone, value,
|
|
19
|
+
export declare function DatePicker({ controlSize, label, timeZone, value: valueProp, defaultValue, onValueChange, placeholder, format, ref, ...rest }: DatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { mergeRefs as t } from "../../lib/mergeRefs.js";
|
|
3
|
+
import { useControlSize as n } from "../../providers/ControlSizeContext.js";
|
|
4
|
+
import { useControllableState as r } from "../../hooks/useControllableState.js";
|
|
5
|
+
import { usePopover as i } from "../../hooks/usePopover.js";
|
|
6
|
+
import { calendarDateParts as a } from "../../lib/calendar.js";
|
|
7
|
+
import { MONTHS_SHORT as o } from "../../lib/months.js";
|
|
8
|
+
import { CalendarGrid as s } from "./CalendarGrid.js";
|
|
9
|
+
import { useMemo as c, useState as l } from "react";
|
|
10
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
11
|
+
import { Calendar as f } from "lucide-react";
|
|
12
|
+
//#region src/components/ui/DatePicker.tsx
|
|
13
|
+
function p(e, t) {
|
|
14
|
+
let { year: n, month: r, day: i } = a(e, t);
|
|
15
|
+
return `${o[r - 1]} ${i}, ${n}`;
|
|
16
|
+
}
|
|
17
|
+
function m({ controlSize: o, label: m, timeZone: h, value: g, defaultValue: _ = null, onValueChange: v, placeholder: y = "Select date...", format: b, ref: x, ...S }) {
|
|
18
|
+
let C = n(o), [w, T] = r({
|
|
19
|
+
value: g,
|
|
20
|
+
defaultValue: _,
|
|
21
|
+
onChange: v
|
|
22
|
+
}), { open: E, show: D, close: O, rootRef: k, anchorRef: A, triggerRef: j, popupRef: M, labelId: N, popupId: P, triggerAria: F } = i({
|
|
23
|
+
haspopup: "dialog",
|
|
24
|
+
labelled: !!m
|
|
25
|
+
}), I = a(w ?? /* @__PURE__ */ new Date(), h), [L, R] = l(I.year), [z, B] = l(I.month - 1);
|
|
26
|
+
function V(e) {
|
|
27
|
+
T(e), O("select");
|
|
28
|
+
}
|
|
29
|
+
function H() {
|
|
30
|
+
if (E) {
|
|
31
|
+
O("toggle");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
w && (R(a(w, h).year), B(a(w, h).month - 1)), D();
|
|
35
|
+
}
|
|
36
|
+
let U = c(() => t(k, x), [k, x]);
|
|
37
|
+
return /* @__PURE__ */ d("div", {
|
|
38
|
+
...S,
|
|
39
|
+
className: e("flex flex-col gap-1.5", S.className),
|
|
40
|
+
ref: U,
|
|
41
|
+
children: [m && /* @__PURE__ */ u("span", {
|
|
42
|
+
id: N,
|
|
43
|
+
className: "ui-field-label text-xs font-medium",
|
|
44
|
+
children: m
|
|
45
|
+
}), /* @__PURE__ */ d("div", {
|
|
46
|
+
className: "relative",
|
|
47
|
+
ref: A,
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ u("button", {
|
|
50
|
+
type: "button",
|
|
51
|
+
ref: j,
|
|
52
|
+
...F,
|
|
53
|
+
onClick: H,
|
|
54
|
+
"data-control-size": C,
|
|
55
|
+
className: e("ui-sized-control flex h-7 w-full cursor-pointer items-center rounded-md text-xs", "bg-bg-secondary border-border text-text-primary border", "hover:bg-bg-hover hover:border-border-strong", "transition-colors duration-[100ms]", "px-2 pr-7"),
|
|
56
|
+
children: w ? b ? b(w) : p(w, h) : /* @__PURE__ */ u("span", {
|
|
57
|
+
className: "text-text-placeholder",
|
|
58
|
+
children: y
|
|
59
|
+
})
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ u(f, { className: "text-text-tertiary pointer-events-none absolute top-1/2 right-2 h-3 w-3 -translate-y-1/2" }),
|
|
62
|
+
E && /* @__PURE__ */ u("div", {
|
|
63
|
+
ref: M,
|
|
64
|
+
id: P,
|
|
65
|
+
role: "dialog",
|
|
66
|
+
"aria-label": "Choose date",
|
|
67
|
+
className: e("ui-glass ui-glass-popover bg-bg-tertiary border-border-strong animate-scale-in fixed top-0 left-0 z-[100] rounded-md border shadow-lg", "p-3"),
|
|
68
|
+
children: /* @__PURE__ */ u(s, {
|
|
69
|
+
timeZone: h,
|
|
70
|
+
year: L,
|
|
71
|
+
month: z,
|
|
72
|
+
selected: w,
|
|
73
|
+
onSelect: V,
|
|
74
|
+
onMonthChange: (e, t) => {
|
|
75
|
+
R(e), B(t);
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
})]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { m as DatePicker };
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef } from "react";
|
|
1
2
|
import { type ControlSize } from "../../providers/ControlSizeContext";
|
|
2
3
|
export interface DateRange {
|
|
3
4
|
start: Date | null;
|
|
4
5
|
end: Date | null;
|
|
5
6
|
}
|
|
6
|
-
export interface DateRangePickerProps {
|
|
7
|
+
export interface DateRangePickerProps extends Omit<ComponentPropsWithRef<"div">, "defaultValue" | "placeholder" | "children" | "onChange"> {
|
|
7
8
|
/** Inherit ControlSizeProvider or override this trigger’s sizing. */
|
|
8
9
|
controlSize?: ControlSize;
|
|
9
10
|
/** Visible label above the trigger. */
|
|
10
11
|
label?: string;
|
|
11
12
|
/** Selected range (controlled); start and end are null while unset. */
|
|
12
|
-
value
|
|
13
|
+
value?: DateRange;
|
|
14
|
+
/** Initially selected range when uncontrolled. */
|
|
15
|
+
defaultValue?: DateRange;
|
|
13
16
|
/** Called with the new range once both ends are chosen. */
|
|
14
|
-
|
|
17
|
+
onValueChange?: (range: DateRange) => void;
|
|
15
18
|
/** Text shown when no range is selected. Defaults to "Select date range...". */
|
|
16
19
|
placeholder?: string;
|
|
17
20
|
}
|
|
18
|
-
export declare function DateRangePicker({ controlSize, label, value,
|
|
21
|
+
export declare function DateRangePicker({ controlSize, label, value: valueProp, defaultValue, onValueChange, placeholder, ref, className, ...rest }: DateRangePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { mergeRefs as t } from "../../lib/mergeRefs.js";
|
|
3
|
+
import { useControlSize as n } from "../../providers/ControlSizeContext.js";
|
|
4
|
+
import { useControllableState as r } from "../../hooks/useControllableState.js";
|
|
5
|
+
import { usePopover as i } from "../../hooks/usePopover.js";
|
|
6
|
+
import { MONTHS_SHORT as a } from "../../lib/months.js";
|
|
7
|
+
import { CalendarGrid as o } from "./CalendarGrid.js";
|
|
8
|
+
import { useMemo as s, useState as c } from "react";
|
|
9
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
10
|
+
import { Calendar as d } from "lucide-react";
|
|
11
|
+
//#region src/components/ui/DateRangePicker.tsx
|
|
12
|
+
function f(e) {
|
|
13
|
+
return `${a[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;
|
|
14
|
+
}
|
|
15
|
+
function p(e) {
|
|
16
|
+
return e.start && e.end ? `${f(e.start)} – ${f(e.end)}` : e.start ? f(e.start) : "";
|
|
17
|
+
}
|
|
18
|
+
var m = {
|
|
19
|
+
start: null,
|
|
20
|
+
end: null
|
|
21
|
+
};
|
|
22
|
+
function h({ controlSize: a, label: f, value: h, defaultValue: g = m, onValueChange: _, placeholder: v = "Select date range...", ref: y, className: b, ...x }) {
|
|
23
|
+
let S = n(a), [C, w] = r({
|
|
24
|
+
value: h,
|
|
25
|
+
defaultValue: g,
|
|
26
|
+
onChange: _
|
|
27
|
+
}), { open: T, show: E, close: D, rootRef: O, anchorRef: k, triggerRef: A, popupRef: j, labelId: M, popupId: N, triggerAria: P } = i({
|
|
28
|
+
haspopup: "dialog",
|
|
29
|
+
labelled: !!f
|
|
30
|
+
}), F = s(() => t(y, O), [y, O]), I = /* @__PURE__ */ new Date(), [L, R] = c(C.start?.getFullYear() ?? I.getFullYear()), [z, B] = c(C.start?.getMonth() ?? I.getMonth()), [V, H] = c(null), [U, W] = c("start"), [G, K] = c(C.start), [q, J] = c(C.end), Y = z === 11 ? L + 1 : L, X = z === 11 ? 0 : z + 1;
|
|
31
|
+
function Z() {
|
|
32
|
+
if (T) {
|
|
33
|
+
D("toggle");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
K(C.start), J(C.end), W("start"), C.start && (R(C.start.getFullYear()), B(C.start.getMonth())), E();
|
|
37
|
+
}
|
|
38
|
+
function Q(e) {
|
|
39
|
+
U === "start" ? (K(e), J(null), W("end")) : (G && e < G ? (J(G), K(e)) : J(e), W("start"), w({
|
|
40
|
+
start: G && e < G ? e : G,
|
|
41
|
+
end: G && e < G ? G : e
|
|
42
|
+
}), D("select"));
|
|
43
|
+
}
|
|
44
|
+
function $() {
|
|
45
|
+
z === 0 ? (R(L - 1), B(11)) : B(z - 1);
|
|
46
|
+
}
|
|
47
|
+
function ee() {
|
|
48
|
+
z === 11 ? (R(L + 1), B(0)) : B(z + 1);
|
|
49
|
+
}
|
|
50
|
+
let te = C.start || C.end ? p(C) : "";
|
|
51
|
+
return /* @__PURE__ */ u("div", {
|
|
52
|
+
...x,
|
|
53
|
+
ref: F,
|
|
54
|
+
className: e("flex flex-col gap-1.5", b),
|
|
55
|
+
children: [f && /* @__PURE__ */ l("span", {
|
|
56
|
+
id: M,
|
|
57
|
+
className: "ui-field-label text-xs font-medium",
|
|
58
|
+
children: f
|
|
59
|
+
}), /* @__PURE__ */ u("div", {
|
|
60
|
+
className: "relative",
|
|
61
|
+
ref: k,
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ l("button", {
|
|
64
|
+
type: "button",
|
|
65
|
+
ref: A,
|
|
66
|
+
...P,
|
|
67
|
+
onClick: Z,
|
|
68
|
+
"data-control-size": S,
|
|
69
|
+
className: e("ui-sized-control flex h-7 w-full cursor-pointer items-center rounded-md text-xs", "bg-bg-secondary border-border text-text-primary border", "hover:bg-bg-hover hover:border-border-strong", "transition-colors duration-[100ms]", "px-2 pr-7"),
|
|
70
|
+
children: te || /* @__PURE__ */ l("span", {
|
|
71
|
+
className: "text-text-placeholder",
|
|
72
|
+
children: v
|
|
73
|
+
})
|
|
74
|
+
}),
|
|
75
|
+
/* @__PURE__ */ l(d, { className: "text-text-tertiary pointer-events-none absolute top-1/2 right-2 h-3 w-3 -translate-y-1/2" }),
|
|
76
|
+
T && /* @__PURE__ */ u("div", {
|
|
77
|
+
ref: j,
|
|
78
|
+
id: N,
|
|
79
|
+
role: "dialog",
|
|
80
|
+
"aria-label": "Choose date range",
|
|
81
|
+
className: e("ui-glass ui-glass-popover bg-bg-tertiary border-border-strong animate-scale-in fixed top-0 left-0 z-[100] rounded-md border shadow-lg", "p-3"),
|
|
82
|
+
children: [/* @__PURE__ */ u("div", {
|
|
83
|
+
className: "mb-2 flex items-center justify-between",
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ l("button", {
|
|
86
|
+
type: "button",
|
|
87
|
+
onClick: $,
|
|
88
|
+
"aria-label": "Previous month",
|
|
89
|
+
className: "text-text-tertiary hover:text-text-primary hover:bg-bg-hover flex h-6 w-6 cursor-pointer items-center justify-center rounded-md transition-colors duration-[100ms]",
|
|
90
|
+
children: /* @__PURE__ */ l("span", {
|
|
91
|
+
className: "text-xs",
|
|
92
|
+
children: "‹"
|
|
93
|
+
})
|
|
94
|
+
}),
|
|
95
|
+
/* @__PURE__ */ l("span", {
|
|
96
|
+
className: "text-text-tertiary text-2xs",
|
|
97
|
+
"aria-live": "polite",
|
|
98
|
+
children: U === "start" ? "Select start date" : "Select end date"
|
|
99
|
+
}),
|
|
100
|
+
/* @__PURE__ */ l("button", {
|
|
101
|
+
type: "button",
|
|
102
|
+
onClick: ee,
|
|
103
|
+
"aria-label": "Next month",
|
|
104
|
+
className: "text-text-tertiary hover:text-text-primary hover:bg-bg-hover flex h-6 w-6 cursor-pointer items-center justify-center rounded-md transition-colors duration-[100ms]",
|
|
105
|
+
children: /* @__PURE__ */ l("span", {
|
|
106
|
+
className: "text-xs",
|
|
107
|
+
children: "›"
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}), /* @__PURE__ */ u("div", {
|
|
112
|
+
className: "flex gap-4",
|
|
113
|
+
children: [/* @__PURE__ */ l(o, {
|
|
114
|
+
year: L,
|
|
115
|
+
month: z,
|
|
116
|
+
rangeStart: G,
|
|
117
|
+
rangeEnd: q,
|
|
118
|
+
hoverDate: U === "end" ? V : null,
|
|
119
|
+
onSelect: Q,
|
|
120
|
+
onMonthChange: (e, t) => {
|
|
121
|
+
R(e), B(t);
|
|
122
|
+
},
|
|
123
|
+
onHover: H
|
|
124
|
+
}), /* @__PURE__ */ l(o, {
|
|
125
|
+
year: Y,
|
|
126
|
+
month: X,
|
|
127
|
+
rangeStart: G,
|
|
128
|
+
rangeEnd: q,
|
|
129
|
+
hoverDate: U === "end" ? V : null,
|
|
130
|
+
onSelect: Q,
|
|
131
|
+
onMonthChange: (e, t) => {
|
|
132
|
+
t === 0 ? (R(e - 1), B(11)) : (R(e), B(t - 1));
|
|
133
|
+
},
|
|
134
|
+
onHover: H
|
|
135
|
+
})]
|
|
136
|
+
})]
|
|
137
|
+
})
|
|
138
|
+
]
|
|
139
|
+
})]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { h as DateRangePicker };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef } from "react";
|
|
1
2
|
import { type ControlSize } from "../../providers/ControlSizeContext";
|
|
2
|
-
export interface DateTimePickerProps {
|
|
3
|
+
export interface DateTimePickerProps extends Omit<ComponentPropsWithRef<"div">, "defaultValue" | "placeholder" | "children" | "onChange"> {
|
|
3
4
|
/** IANA zone for display/input. Values and callbacks are real instants. */
|
|
4
5
|
timeZone?: string;
|
|
5
6
|
/** Inherit ControlSizeProvider or override this trigger’s sizing. */
|
|
@@ -7,10 +8,12 @@ export interface DateTimePickerProps {
|
|
|
7
8
|
/** Visible label above the trigger. */
|
|
8
9
|
label?: string;
|
|
9
10
|
/** Selected date and time (controlled), or null. */
|
|
10
|
-
value
|
|
11
|
+
value?: Date | null;
|
|
12
|
+
/** Initially selected instant when uncontrolled. */
|
|
13
|
+
defaultValue?: Date | null;
|
|
11
14
|
/** Called with the chosen instant. */
|
|
12
|
-
|
|
15
|
+
onValueChange?: (date: Date | null) => void;
|
|
13
16
|
/** Text shown when no value is selected. Defaults to "Select date & time...". */
|
|
14
17
|
placeholder?: string;
|
|
15
18
|
}
|
|
16
|
-
export declare function DateTimePicker(props: DateTimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function DateTimePicker({ value: valueProp, defaultValue, onValueChange, ...props }: DateTimePickerProps): import("react/jsx-runtime").JSX.Element;
|