@bricks-toolkit/toolkit 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-62JXQJBD.cjs +533 -0
- package/dist/chunk-6LBTRQZD.mjs +806 -0
- package/dist/chunk-M6XPQ5BE.cjs +808 -0
- package/dist/chunk-UPSMZISM.mjs +567 -0
- package/dist/chunk-YV3WWKQY.cjs +569 -0
- package/dist/chunk-Z5FRCULF.mjs +531 -0
- package/dist/date-picker/index.cjs +2 -2
- package/dist/date-picker/index.mjs +1 -1
- package/dist/date-time-picker/index.cjs +2 -2
- package/dist/date-time-picker/index.mjs +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.mjs +3 -3
- package/dist/time-picker/index.cjs +2 -2
- package/dist/time-picker/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/Button.types-BsQYqZml.d.ts +0 -27
- package/dist/Button.types-D-srlWFf.d.mts +0 -27
- package/dist/TextInput.types-DRI8HQza.d.mts +0 -32
- package/dist/TextInput.types-DRI8HQza.d.ts +0 -32
- package/dist/Tooltip.types-PbUasE3C.d.mts +0 -36
- package/dist/Tooltip.types-PbUasE3C.d.ts +0 -36
- package/dist/avatar/index.d.mts +0 -29
- package/dist/avatar/index.d.ts +0 -29
- package/dist/badge/index.d.mts +0 -57
- package/dist/badge/index.d.ts +0 -57
- package/dist/breadcrumbs/index.d.mts +0 -32
- package/dist/breadcrumbs/index.d.ts +0 -32
- package/dist/button/index.d.mts +0 -8
- package/dist/button/index.d.ts +0 -8
- package/dist/card/index.d.mts +0 -42
- package/dist/card/index.d.ts +0 -42
- package/dist/checkbox/index.d.mts +0 -36
- package/dist/checkbox/index.d.ts +0 -36
- package/dist/chunk-E6KUCC56.mjs +0 -804
- package/dist/chunk-FK5HAWIU.cjs +0 -531
- package/dist/chunk-HG4BPC2T.cjs +0 -806
- package/dist/chunk-LKNQH36V.mjs +0 -529
- package/dist/chunk-M5V2IWA6.mjs +0 -565
- package/dist/chunk-WVRXSANT.cjs +0 -567
- package/dist/combo-box/index.d.mts +0 -62
- package/dist/combo-box/index.d.ts +0 -62
- package/dist/date-picker/index.d.mts +0 -52
- package/dist/date-picker/index.d.ts +0 -52
- package/dist/date-time-picker/index.d.mts +0 -52
- package/dist/date-time-picker/index.d.ts +0 -52
- package/dist/dialog/index.d.mts +0 -61
- package/dist/dialog/index.d.ts +0 -61
- package/dist/dropdown-menu/index.d.mts +0 -34
- package/dist/dropdown-menu/index.d.ts +0 -34
- package/dist/email/index.d.mts +0 -38
- package/dist/email/index.d.ts +0 -38
- package/dist/file-upload/index.d.mts +0 -27
- package/dist/file-upload/index.d.ts +0 -27
- package/dist/header/index.d.mts +0 -28
- package/dist/header/index.d.ts +0 -28
- package/dist/icon-button/index.d.mts +0 -16
- package/dist/icon-button/index.d.ts +0 -16
- package/dist/image/index.d.mts +0 -48
- package/dist/image/index.d.ts +0 -48
- package/dist/index.d.mts +0 -142
- package/dist/index.d.ts +0 -142
- package/dist/link/index.d.mts +0 -25
- package/dist/link/index.d.ts +0 -25
- package/dist/loader/index.d.mts +0 -21
- package/dist/loader/index.d.ts +0 -21
- package/dist/modal/index.d.mts +0 -116
- package/dist/modal/index.d.ts +0 -116
- package/dist/multi-select/index.d.mts +0 -59
- package/dist/multi-select/index.d.ts +0 -59
- package/dist/otp-input/index.d.mts +0 -57
- package/dist/otp-input/index.d.ts +0 -57
- package/dist/password-input/index.d.mts +0 -32
- package/dist/password-input/index.d.ts +0 -32
- package/dist/phone/index.d.mts +0 -41
- package/dist/phone/index.d.ts +0 -41
- package/dist/radio-button/index.d.mts +0 -56
- package/dist/radio-button/index.d.ts +0 -56
- package/dist/search-input/index.d.mts +0 -22
- package/dist/search-input/index.d.ts +0 -22
- package/dist/select/index.d.mts +0 -36
- package/dist/select/index.d.ts +0 -36
- package/dist/sidebar/index.d.mts +0 -96
- package/dist/sidebar/index.d.ts +0 -96
- package/dist/skeleton/index.d.mts +0 -76
- package/dist/skeleton/index.d.ts +0 -76
- package/dist/styles.d.mts +0 -2
- package/dist/styles.d.ts +0 -2
- package/dist/table/index.d.mts +0 -92
- package/dist/table/index.d.ts +0 -92
- package/dist/tabs/index.d.mts +0 -26
- package/dist/tabs/index.d.ts +0 -26
- package/dist/text-input/index.d.mts +0 -7
- package/dist/text-input/index.d.ts +0 -7
- package/dist/theme-provider/index.d.mts +0 -122
- package/dist/theme-provider/index.d.ts +0 -122
- package/dist/theme.css +0 -62
- package/dist/time-picker/index.d.mts +0 -51
- package/dist/time-picker/index.d.ts +0 -51
- package/dist/toaster/index.d.mts +0 -28
- package/dist/toaster/index.d.ts +0 -28
- package/dist/tooltip/index.d.mts +0 -7
- package/dist/tooltip/index.d.ts +0 -7
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
import { parseISODate, toISODateString, buildCalendarGrid, getYearRange, MONTH_NAMES, DAY_NAMES_SHORT, isSameDay, isDisabledDate, MONTH_NAMES_SHORT, formatDate } from './chunk-4PRNRENN.mjs';
|
|
2
|
+
import { cn } from './chunk-OCPFOFJ4.mjs';
|
|
3
|
+
import { forwardRef, useId, useState, useMemo, useEffect, useCallback, useRef } from 'react';
|
|
4
|
+
import { CalendarIcon, XMarkIcon, ClockIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronDownIcon } from '@heroicons/react/24/outline';
|
|
5
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function parseTime(v) {
|
|
8
|
+
const parts = (v || "00:00").split(":");
|
|
9
|
+
const numbers = parts.map(Number);
|
|
10
|
+
const h = numbers[0];
|
|
11
|
+
const m = numbers[1];
|
|
12
|
+
return {
|
|
13
|
+
hours: h === void 0 || isNaN(h) ? 0 : h,
|
|
14
|
+
minutes: m === void 0 || isNaN(m) ? 0 : m
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function pad(n) {
|
|
18
|
+
return String(n).padStart(2, "0");
|
|
19
|
+
}
|
|
20
|
+
function toTimeString(h, m) {
|
|
21
|
+
return `${pad(h)}:${pad(m)}`;
|
|
22
|
+
}
|
|
23
|
+
function formatTimeDisplay(v, use12) {
|
|
24
|
+
if (!v) return "";
|
|
25
|
+
const { hours, minutes } = parseTime(v);
|
|
26
|
+
if (use12) {
|
|
27
|
+
const ap = hours >= 12 ? "PM" : "AM";
|
|
28
|
+
return `${pad(hours % 12 || 12)}:${pad(minutes)} ${ap}`;
|
|
29
|
+
}
|
|
30
|
+
return toTimeString(hours, minutes);
|
|
31
|
+
}
|
|
32
|
+
function parseDT(v) {
|
|
33
|
+
if (!v) return { date: "", time: "" };
|
|
34
|
+
const [date, time] = v.split("T");
|
|
35
|
+
return { date: date ?? "", time: time ?? "" };
|
|
36
|
+
}
|
|
37
|
+
function formatDTDisplay(v, locale, use12) {
|
|
38
|
+
if (!v) return "";
|
|
39
|
+
const { date, time } = parseDT(v);
|
|
40
|
+
const d = parseISODate(date);
|
|
41
|
+
const datePart = d ? formatDate(d, locale) : date;
|
|
42
|
+
const timePart = formatTimeDisplay(time, use12);
|
|
43
|
+
return timePart ? `${datePart} ${timePart}` : datePart;
|
|
44
|
+
}
|
|
45
|
+
var ITEM_H = 36;
|
|
46
|
+
var sizeClasses = {
|
|
47
|
+
xs: "h-6 px-2 text-xs",
|
|
48
|
+
sm: "h-8 px-3 text-sm",
|
|
49
|
+
md: "h-10 px-3 text-sm",
|
|
50
|
+
lg: "h-11 px-4 text-base",
|
|
51
|
+
xl: "h-12 px-4 text-lg"
|
|
52
|
+
};
|
|
53
|
+
var labelSizeClasses = {
|
|
54
|
+
xs: "text-xs",
|
|
55
|
+
sm: "text-xs",
|
|
56
|
+
md: "text-sm",
|
|
57
|
+
lg: "text-sm",
|
|
58
|
+
xl: "text-base"
|
|
59
|
+
};
|
|
60
|
+
var variantClasses = {
|
|
61
|
+
default: "rounded-md border border-border bg-surface shadow-sm focus-within:ring-2 focus-within:ring-primary/40 transition-all duration-200",
|
|
62
|
+
filled: "rounded-md border border-transparent bg-surface-secondary focus-within:bg-surface focus-within:ring-2 focus-within:ring-primary/40 transition-all duration-200",
|
|
63
|
+
flushed: "rounded-none border-0 border-b border-border bg-transparent",
|
|
64
|
+
unstyled: "border-0 bg-transparent p-0"
|
|
65
|
+
};
|
|
66
|
+
var stateVariantClasses = {
|
|
67
|
+
default: {
|
|
68
|
+
default: "border-border focus-within:border-primary",
|
|
69
|
+
filled: "focus-within:border-primary",
|
|
70
|
+
flushed: "border-border",
|
|
71
|
+
unstyled: ""
|
|
72
|
+
},
|
|
73
|
+
error: {
|
|
74
|
+
default: "border-error focus-within:ring-error/20",
|
|
75
|
+
filled: "bg-error/5 focus-within:ring-error/20",
|
|
76
|
+
flushed: "border-error",
|
|
77
|
+
unstyled: ""
|
|
78
|
+
},
|
|
79
|
+
success: {
|
|
80
|
+
default: "border-success focus-within:ring-success/20",
|
|
81
|
+
filled: "bg-success/5 focus-within:ring-success/20",
|
|
82
|
+
flushed: "border-success",
|
|
83
|
+
unstyled: ""
|
|
84
|
+
},
|
|
85
|
+
warning: {
|
|
86
|
+
default: "border-warning focus-within:ring-warning/20",
|
|
87
|
+
filled: "bg-warning/5 focus-within:ring-warning/20",
|
|
88
|
+
flushed: "border-warning",
|
|
89
|
+
unstyled: ""
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var stateMsgClasses = {
|
|
93
|
+
default: "text-text-muted",
|
|
94
|
+
error: "text-error font-medium",
|
|
95
|
+
success: "text-success font-medium",
|
|
96
|
+
warning: "text-warning font-medium"
|
|
97
|
+
};
|
|
98
|
+
function ScrollColumn({
|
|
99
|
+
items,
|
|
100
|
+
selected,
|
|
101
|
+
onSelect,
|
|
102
|
+
label
|
|
103
|
+
}) {
|
|
104
|
+
const ref = useRef(null);
|
|
105
|
+
const scrollTo = useCallback(
|
|
106
|
+
(beh = "smooth") => {
|
|
107
|
+
if (!ref.current) return;
|
|
108
|
+
const idx = items.indexOf(selected);
|
|
109
|
+
if (idx < 0) return;
|
|
110
|
+
if (typeof ref.current.scrollTo === "function") {
|
|
111
|
+
ref.current.scrollTo({ top: Math.max(0, idx * ITEM_H - ITEM_H * 2), behavior: beh });
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
[items, selected]
|
|
115
|
+
);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
scrollTo("instant");
|
|
118
|
+
}, []);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
scrollTo("smooth");
|
|
121
|
+
}, [scrollTo]);
|
|
122
|
+
const step = (dir) => {
|
|
123
|
+
const idx = items.indexOf(selected);
|
|
124
|
+
const next = items[(idx + dir + items.length) % items.length];
|
|
125
|
+
if (next) onSelect(next);
|
|
126
|
+
};
|
|
127
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-0.5", role: "group", "aria-label": label, children: [
|
|
128
|
+
/* @__PURE__ */ jsx(
|
|
129
|
+
"button",
|
|
130
|
+
{
|
|
131
|
+
type: "button",
|
|
132
|
+
onClick: () => {
|
|
133
|
+
step(-1);
|
|
134
|
+
},
|
|
135
|
+
className: "p-1 rounded hover:bg-hover text-text-secondary",
|
|
136
|
+
"aria-label": `Prev ${label}`,
|
|
137
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "w-4 h-4" })
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
141
|
+
/* @__PURE__ */ jsx(
|
|
142
|
+
"div",
|
|
143
|
+
{
|
|
144
|
+
className: "absolute inset-x-0 rounded-lg bg-primary/10 border-y border-primary/20 pointer-events-none",
|
|
145
|
+
style: { top: ITEM_H * 2, height: ITEM_H }
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/* @__PURE__ */ jsxs("div", { ref, className: "overflow-y-auto", style: { height: ITEM_H * 5, width: 52 }, children: [
|
|
149
|
+
/* @__PURE__ */ jsx("div", { style: { height: ITEM_H * 2 } }),
|
|
150
|
+
items.map((item) => /* @__PURE__ */ jsx(
|
|
151
|
+
"button",
|
|
152
|
+
{
|
|
153
|
+
type: "button",
|
|
154
|
+
onClick: () => {
|
|
155
|
+
onSelect(item);
|
|
156
|
+
},
|
|
157
|
+
style: { height: ITEM_H },
|
|
158
|
+
className: cn(
|
|
159
|
+
"w-full flex items-center justify-center rounded-lg text-sm font-medium hover:bg-hover transition-colors",
|
|
160
|
+
selected === item ? "text-primary font-bold" : "text-text-secondary"
|
|
161
|
+
),
|
|
162
|
+
"aria-pressed": selected === item,
|
|
163
|
+
children: item
|
|
164
|
+
},
|
|
165
|
+
item
|
|
166
|
+
)),
|
|
167
|
+
/* @__PURE__ */ jsx("div", { style: { height: ITEM_H * 2 } })
|
|
168
|
+
] })
|
|
169
|
+
] }),
|
|
170
|
+
/* @__PURE__ */ jsx(
|
|
171
|
+
"button",
|
|
172
|
+
{
|
|
173
|
+
type: "button",
|
|
174
|
+
onClick: () => {
|
|
175
|
+
step(1);
|
|
176
|
+
},
|
|
177
|
+
className: "p-1 rounded hover:bg-hover text-text-secondary",
|
|
178
|
+
"aria-label": `Next ${label}`,
|
|
179
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "w-4 h-4" })
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
] });
|
|
183
|
+
}
|
|
184
|
+
function AddonIcon({
|
|
185
|
+
children,
|
|
186
|
+
side,
|
|
187
|
+
size,
|
|
188
|
+
onClick,
|
|
189
|
+
asButton = false,
|
|
190
|
+
ariaLabel
|
|
191
|
+
}) {
|
|
192
|
+
const sz = {
|
|
193
|
+
xs: "w-3.5 h-3.5",
|
|
194
|
+
sm: "w-4 h-4",
|
|
195
|
+
md: "w-4 h-4",
|
|
196
|
+
lg: "w-5 h-5",
|
|
197
|
+
xl: "w-5 h-5"
|
|
198
|
+
};
|
|
199
|
+
const base = cn(
|
|
200
|
+
"absolute top-1/2 -translate-y-1/2 text-text-secondary flex items-center justify-center",
|
|
201
|
+
side === "left" ? "left-3" : "right-3",
|
|
202
|
+
sz[size]
|
|
203
|
+
);
|
|
204
|
+
if (asButton && onClick)
|
|
205
|
+
return /* @__PURE__ */ jsx(
|
|
206
|
+
"button",
|
|
207
|
+
{
|
|
208
|
+
type: "button",
|
|
209
|
+
onClick,
|
|
210
|
+
className: cn(base, "cursor-pointer hover:text-text"),
|
|
211
|
+
tabIndex: -1,
|
|
212
|
+
"aria-label": ariaLabel,
|
|
213
|
+
children
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn(base, "pointer-events-none"), "aria-label": ariaLabel, children });
|
|
217
|
+
}
|
|
218
|
+
var DateTimePicker = forwardRef(
|
|
219
|
+
({
|
|
220
|
+
label,
|
|
221
|
+
required = false,
|
|
222
|
+
helperText,
|
|
223
|
+
errorMessage,
|
|
224
|
+
successMessage,
|
|
225
|
+
warningMessage,
|
|
226
|
+
variant = "default",
|
|
227
|
+
size = "md",
|
|
228
|
+
state = "default",
|
|
229
|
+
fullWidth = true,
|
|
230
|
+
leftElement,
|
|
231
|
+
rightElement,
|
|
232
|
+
prefix,
|
|
233
|
+
suffix,
|
|
234
|
+
wrapperClassName,
|
|
235
|
+
inputGroupClassName,
|
|
236
|
+
inputClassName,
|
|
237
|
+
labelClassName,
|
|
238
|
+
helperClassName,
|
|
239
|
+
className,
|
|
240
|
+
clearable,
|
|
241
|
+
isLoading,
|
|
242
|
+
disabled,
|
|
243
|
+
value,
|
|
244
|
+
defaultValue,
|
|
245
|
+
onChange,
|
|
246
|
+
onDateTimeChange,
|
|
247
|
+
placeholder = "Select date & time",
|
|
248
|
+
locale = "en-US",
|
|
249
|
+
minDate,
|
|
250
|
+
maxDate,
|
|
251
|
+
disabledDates,
|
|
252
|
+
minuteStep = 1,
|
|
253
|
+
use12Hour = false,
|
|
254
|
+
id: idProp,
|
|
255
|
+
name,
|
|
256
|
+
"aria-label": ariaLabel,
|
|
257
|
+
"aria-describedby": ariaDescribedby
|
|
258
|
+
}, ref) => {
|
|
259
|
+
const genId = useId();
|
|
260
|
+
const inputId = idProp ?? genId;
|
|
261
|
+
const popoverId = `${inputId}-popover`;
|
|
262
|
+
const helperId = `${inputId}-helper`;
|
|
263
|
+
const stateMessageId = `${inputId}-state`;
|
|
264
|
+
const isControlled = value !== void 0;
|
|
265
|
+
const [internalValue, setInternalValue] = useState(defaultValue ?? "");
|
|
266
|
+
const displayValue = isControlled ? value : internalValue;
|
|
267
|
+
const { date: selDateStr, time: selTimeStr } = parseDT(displayValue);
|
|
268
|
+
const selDate = parseISODate(selDateStr);
|
|
269
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
270
|
+
const [tab, setTab] = useState("date");
|
|
271
|
+
const today = useMemo(() => /* @__PURE__ */ new Date(), []);
|
|
272
|
+
const [viewYear, setViewYear] = useState(selDate?.getFullYear() ?? today.getFullYear());
|
|
273
|
+
const [viewMonth, setViewMonth] = useState(selDate?.getMonth() ?? today.getMonth());
|
|
274
|
+
const [viewMode, setViewMode] = useState("day");
|
|
275
|
+
const { hours: sH, minutes: sM } = parseTime(selTimeStr || "00:00");
|
|
276
|
+
const [pickerHour, setPickerHour] = useState(pad(use12Hour ? sH % 12 || 12 : sH));
|
|
277
|
+
const [pickerMinute, setPickerMinute] = useState(pad(sM));
|
|
278
|
+
const [pickerAmpm, setPickerAmpm] = useState(sH >= 12 ? "PM" : "AM");
|
|
279
|
+
useEffect(() => {
|
|
280
|
+
if (!isOpen) return;
|
|
281
|
+
const h = (e) => {
|
|
282
|
+
const wrapper = ref?.current;
|
|
283
|
+
if (wrapper && !wrapper.contains(e.target)) {
|
|
284
|
+
setIsOpen(false);
|
|
285
|
+
setViewMode("day");
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
document.addEventListener("mousedown", h);
|
|
289
|
+
return () => {
|
|
290
|
+
document.removeEventListener("mousedown", h);
|
|
291
|
+
};
|
|
292
|
+
}, [isOpen]);
|
|
293
|
+
const [prevVal, setPrevVal] = useState(displayValue);
|
|
294
|
+
if (displayValue !== prevVal) {
|
|
295
|
+
setPrevVal(displayValue);
|
|
296
|
+
if (selDate) {
|
|
297
|
+
setViewYear(selDate.getFullYear());
|
|
298
|
+
setViewMonth(selDate.getMonth());
|
|
299
|
+
}
|
|
300
|
+
const { hours, minutes } = parseTime(selTimeStr || "00:00");
|
|
301
|
+
setPickerHour(pad(use12Hour ? hours % 12 || 12 : hours));
|
|
302
|
+
setPickerMinute(pad(minutes));
|
|
303
|
+
setPickerAmpm(hours >= 12 ? "PM" : "AM");
|
|
304
|
+
}
|
|
305
|
+
const commit = useCallback(
|
|
306
|
+
(dateStr, timeStr) => {
|
|
307
|
+
const combined = `${dateStr}T${timeStr}`;
|
|
308
|
+
if (!isControlled) setInternalValue(combined);
|
|
309
|
+
onChange?.(combined);
|
|
310
|
+
const d = parseISODate(dateStr);
|
|
311
|
+
if (d) {
|
|
312
|
+
const { hours, minutes } = parseTime(timeStr);
|
|
313
|
+
d.setHours(hours, minutes);
|
|
314
|
+
onDateTimeChange?.(d);
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
[isControlled, onChange, onDateTimeChange]
|
|
318
|
+
);
|
|
319
|
+
const handleDateSelect = (date) => {
|
|
320
|
+
if (isDisabledDate(date, minDate, maxDate, disabledDates)) return;
|
|
321
|
+
const time = selTimeStr || toTimeString(parseInt(pickerHour), parseInt(pickerMinute));
|
|
322
|
+
commit(toISODateString(date), time);
|
|
323
|
+
setTab("time");
|
|
324
|
+
};
|
|
325
|
+
const applyTime = useCallback(
|
|
326
|
+
(h, m, ap) => {
|
|
327
|
+
let hours24 = parseInt(h);
|
|
328
|
+
if (use12Hour) {
|
|
329
|
+
if (ap === "AM" && hours24 === 12) hours24 = 0;
|
|
330
|
+
if (ap === "PM" && hours24 !== 12) hours24 += 12;
|
|
331
|
+
}
|
|
332
|
+
const dateStr = selDateStr || toISODateString(today);
|
|
333
|
+
commit(dateStr, toTimeString(hours24, parseInt(m)));
|
|
334
|
+
},
|
|
335
|
+
[use12Hour, selDateStr, commit, today]
|
|
336
|
+
);
|
|
337
|
+
const handleHour = (h) => {
|
|
338
|
+
setPickerHour(h);
|
|
339
|
+
applyTime(h, pickerMinute, pickerAmpm);
|
|
340
|
+
};
|
|
341
|
+
const handleMinute = (m) => {
|
|
342
|
+
setPickerMinute(m);
|
|
343
|
+
applyTime(pickerHour, m, pickerAmpm);
|
|
344
|
+
};
|
|
345
|
+
const handleAmpm = (ap) => {
|
|
346
|
+
const a = ap;
|
|
347
|
+
setPickerAmpm(a);
|
|
348
|
+
applyTime(pickerHour, pickerMinute, a);
|
|
349
|
+
};
|
|
350
|
+
const handleNow = () => {
|
|
351
|
+
const now = /* @__PURE__ */ new Date();
|
|
352
|
+
const dateStr = toISODateString(now);
|
|
353
|
+
const timeStr = toTimeString(now.getHours(), now.getMinutes());
|
|
354
|
+
if (!isControlled) setInternalValue(`${dateStr}T${timeStr}`);
|
|
355
|
+
onChange?.(`${dateStr}T${timeStr}`);
|
|
356
|
+
onDateTimeChange?.(now);
|
|
357
|
+
setIsOpen(false);
|
|
358
|
+
};
|
|
359
|
+
const handleClear = () => {
|
|
360
|
+
if (!isControlled) setInternalValue("");
|
|
361
|
+
onChange?.("");
|
|
362
|
+
onDateTimeChange?.(null);
|
|
363
|
+
};
|
|
364
|
+
const hourItems = use12Hour ? Array.from({ length: 12 }, (_, i) => pad(i + 1)) : Array.from({ length: 24 }, (_, i) => pad(i));
|
|
365
|
+
const minuteItems = Array.from(
|
|
366
|
+
{ length: Math.ceil(60 / minuteStep) },
|
|
367
|
+
(_, i) => pad(i * minuteStep)
|
|
368
|
+
);
|
|
369
|
+
const showClear = clearable && displayValue.length > 0 && !disabled && !isLoading;
|
|
370
|
+
const rightPad = {
|
|
371
|
+
xs: "pr-6",
|
|
372
|
+
sm: "pr-8",
|
|
373
|
+
md: "pr-9",
|
|
374
|
+
lg: "pr-10",
|
|
375
|
+
xl: "pr-11"
|
|
376
|
+
};
|
|
377
|
+
const calendarGrid = buildCalendarGrid(viewYear, viewMonth);
|
|
378
|
+
const yearRange = getYearRange(viewYear);
|
|
379
|
+
const stateMessage = state === "error" ? errorMessage : state === "success" ? successMessage : state === "warning" ? warningMessage : void 0;
|
|
380
|
+
const describedBy = [helperText ? helperId : null, stateMessage ? stateMessageId : null, ariaDescribedby ?? null].filter(Boolean).join(" ") || void 0;
|
|
381
|
+
const prevMonth = () => {
|
|
382
|
+
if (viewMonth === 0) {
|
|
383
|
+
setViewMonth(11);
|
|
384
|
+
setViewYear((y) => y - 1);
|
|
385
|
+
} else setViewMonth((m) => m - 1);
|
|
386
|
+
};
|
|
387
|
+
const nextMonth = () => {
|
|
388
|
+
if (viewMonth === 11) {
|
|
389
|
+
setViewMonth(0);
|
|
390
|
+
setViewYear((y) => y + 1);
|
|
391
|
+
} else setViewMonth((m) => m + 1);
|
|
392
|
+
};
|
|
393
|
+
return /* @__PURE__ */ jsxs(
|
|
394
|
+
"div",
|
|
395
|
+
{
|
|
396
|
+
ref,
|
|
397
|
+
className: cn(
|
|
398
|
+
"flex flex-col gap-1 relative",
|
|
399
|
+
fullWidth ? "w-full" : "w-fit",
|
|
400
|
+
wrapperClassName,
|
|
401
|
+
className
|
|
402
|
+
),
|
|
403
|
+
children: [
|
|
404
|
+
label !== void 0 && /* @__PURE__ */ jsxs(
|
|
405
|
+
"label",
|
|
406
|
+
{
|
|
407
|
+
htmlFor: inputId,
|
|
408
|
+
className: cn(
|
|
409
|
+
"font-black leading-none text-text uppercase tracking-widest",
|
|
410
|
+
labelSizeClasses[size],
|
|
411
|
+
labelClassName
|
|
412
|
+
),
|
|
413
|
+
children: [
|
|
414
|
+
label,
|
|
415
|
+
required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "ml-1 text-error", children: "*" })
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
),
|
|
419
|
+
/* @__PURE__ */ jsxs(
|
|
420
|
+
"div",
|
|
421
|
+
{
|
|
422
|
+
className: cn("flex items-stretch", fullWidth ? "w-full" : "w-fit", inputGroupClassName),
|
|
423
|
+
children: [
|
|
424
|
+
prefix && /* @__PURE__ */ jsx("span", { className: "inline-flex items-center border border-border bg-surface-secondary px-3 text-sm text-text-secondary rounded-l-md border-r-0", children: prefix }),
|
|
425
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex flex-1 items-center", children: [
|
|
426
|
+
/* @__PURE__ */ jsx(AddonIcon, { side: "left", size, children: leftElement ?? /* @__PURE__ */ jsx(CalendarIcon, { className: "w-full h-full" }) }),
|
|
427
|
+
/* @__PURE__ */ jsx(
|
|
428
|
+
"button",
|
|
429
|
+
{
|
|
430
|
+
id: inputId,
|
|
431
|
+
type: "button",
|
|
432
|
+
role: "combobox",
|
|
433
|
+
"aria-expanded": isOpen,
|
|
434
|
+
"aria-haspopup": "dialog",
|
|
435
|
+
"aria-controls": popoverId,
|
|
436
|
+
"aria-label": ariaLabel ?? label ?? "Date time picker",
|
|
437
|
+
"aria-describedby": describedBy,
|
|
438
|
+
"aria-required": required,
|
|
439
|
+
"aria-invalid": state === "error" ? true : void 0,
|
|
440
|
+
disabled: Boolean(disabled) || Boolean(isLoading),
|
|
441
|
+
onClick: () => {
|
|
442
|
+
if (!disabled && !isLoading) setIsOpen((p) => !p);
|
|
443
|
+
},
|
|
444
|
+
name,
|
|
445
|
+
className: cn(
|
|
446
|
+
"w-full flex items-center text-left cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
|
|
447
|
+
sizeClasses[size],
|
|
448
|
+
variantClasses[variant],
|
|
449
|
+
stateVariantClasses[state][variant],
|
|
450
|
+
"pl-9",
|
|
451
|
+
showClear || rightElement ? rightPad[size] : "",
|
|
452
|
+
prefix && suffix ? "rounded-none" : prefix ? "rounded-l-none" : suffix ? "rounded-r-none" : "",
|
|
453
|
+
inputClassName
|
|
454
|
+
),
|
|
455
|
+
children: displayValue ? /* @__PURE__ */ jsx("span", { className: "text-text truncate", children: formatDTDisplay(displayValue, locale, use12Hour) }) : /* @__PURE__ */ jsx("span", { className: "text-text-muted", children: placeholder })
|
|
456
|
+
}
|
|
457
|
+
),
|
|
458
|
+
isLoading ? /* @__PURE__ */ jsx(AddonIcon, { side: "right", size, children: /* @__PURE__ */ jsxs(
|
|
459
|
+
"svg",
|
|
460
|
+
{
|
|
461
|
+
className: "animate-spin h-full w-full text-text-muted",
|
|
462
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
463
|
+
fill: "none",
|
|
464
|
+
viewBox: "0 0 24 24",
|
|
465
|
+
children: [
|
|
466
|
+
/* @__PURE__ */ jsx(
|
|
467
|
+
"circle",
|
|
468
|
+
{
|
|
469
|
+
className: "opacity-25",
|
|
470
|
+
cx: "12",
|
|
471
|
+
cy: "12",
|
|
472
|
+
r: "10",
|
|
473
|
+
stroke: "currentColor",
|
|
474
|
+
strokeWidth: "4"
|
|
475
|
+
}
|
|
476
|
+
),
|
|
477
|
+
/* @__PURE__ */ jsx(
|
|
478
|
+
"path",
|
|
479
|
+
{
|
|
480
|
+
className: "opacity-75",
|
|
481
|
+
fill: "currentColor",
|
|
482
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
483
|
+
}
|
|
484
|
+
)
|
|
485
|
+
]
|
|
486
|
+
}
|
|
487
|
+
) }) : showClear ? /* @__PURE__ */ jsx(
|
|
488
|
+
AddonIcon,
|
|
489
|
+
{
|
|
490
|
+
side: "right",
|
|
491
|
+
size,
|
|
492
|
+
asButton: true,
|
|
493
|
+
onClick: handleClear,
|
|
494
|
+
ariaLabel: "Clear date time",
|
|
495
|
+
children: /* @__PURE__ */ jsx(XMarkIcon, { className: "w-full h-full", strokeWidth: 2.5 })
|
|
496
|
+
}
|
|
497
|
+
) : rightElement ? /* @__PURE__ */ jsx(AddonIcon, { side: "right", size, children: rightElement }) : null
|
|
498
|
+
] }),
|
|
499
|
+
suffix && /* @__PURE__ */ jsx("span", { className: "inline-flex items-center border border-border bg-surface-secondary px-3 text-sm text-text-secondary rounded-r-md border-l-0", children: suffix })
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
),
|
|
503
|
+
helperText && /* @__PURE__ */ jsx(
|
|
504
|
+
"p",
|
|
505
|
+
{
|
|
506
|
+
id: helperId,
|
|
507
|
+
className: cn("text-xs leading-tight text-text-muted font-medium", helperClassName),
|
|
508
|
+
children: helperText
|
|
509
|
+
}
|
|
510
|
+
),
|
|
511
|
+
stateMessage && /* @__PURE__ */ jsx(
|
|
512
|
+
"p",
|
|
513
|
+
{
|
|
514
|
+
id: stateMessageId,
|
|
515
|
+
role: state === "error" ? "alert" : void 0,
|
|
516
|
+
className: cn(
|
|
517
|
+
"text-xs leading-tight mt-0.5 font-medium",
|
|
518
|
+
stateMsgClasses[state],
|
|
519
|
+
helperClassName
|
|
520
|
+
),
|
|
521
|
+
children: stateMessage
|
|
522
|
+
}
|
|
523
|
+
),
|
|
524
|
+
/* @__PURE__ */ jsxs(
|
|
525
|
+
"div",
|
|
526
|
+
{
|
|
527
|
+
id: popoverId,
|
|
528
|
+
role: "dialog",
|
|
529
|
+
"aria-label": "Date and time picker",
|
|
530
|
+
"aria-modal": "true",
|
|
531
|
+
className: cn(
|
|
532
|
+
"absolute top-full left-0 z-50 mt-1 w-72 bg-surface border border-border rounded-xl shadow-xl",
|
|
533
|
+
"transition-all duration-200 origin-top",
|
|
534
|
+
isOpen ? "opacity-100 scale-100 pointer-events-auto" : "opacity-0 scale-95 pointer-events-none"
|
|
535
|
+
),
|
|
536
|
+
children: [
|
|
537
|
+
/* @__PURE__ */ jsx("div", { className: "flex border-b border-border", children: ["date", "time"].map((t) => /* @__PURE__ */ jsxs(
|
|
538
|
+
"button",
|
|
539
|
+
{
|
|
540
|
+
type: "button",
|
|
541
|
+
onClick: () => {
|
|
542
|
+
setTab(t);
|
|
543
|
+
},
|
|
544
|
+
className: cn(
|
|
545
|
+
"flex-1 flex items-center justify-center gap-1.5 py-2.5 text-xs font-bold uppercase tracking-wider transition-colors",
|
|
546
|
+
tab === t ? "text-primary border-b-2 border-primary -mb-px" : "text-text-muted hover:text-text"
|
|
547
|
+
),
|
|
548
|
+
children: [
|
|
549
|
+
t === "date" ? /* @__PURE__ */ jsx(CalendarIcon, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ jsx(ClockIcon, { className: "w-3.5 h-3.5" }),
|
|
550
|
+
t
|
|
551
|
+
]
|
|
552
|
+
},
|
|
553
|
+
t
|
|
554
|
+
)) }),
|
|
555
|
+
/* @__PURE__ */ jsxs("div", { className: "p-3", children: [
|
|
556
|
+
tab === "date" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
557
|
+
viewMode === "day" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
558
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
559
|
+
/* @__PURE__ */ jsx(
|
|
560
|
+
"button",
|
|
561
|
+
{
|
|
562
|
+
type: "button",
|
|
563
|
+
onClick: prevMonth,
|
|
564
|
+
className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary",
|
|
565
|
+
"aria-label": "Previous month",
|
|
566
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "w-4 h-4" })
|
|
567
|
+
}
|
|
568
|
+
),
|
|
569
|
+
/* @__PURE__ */ jsxs(
|
|
570
|
+
"button",
|
|
571
|
+
{
|
|
572
|
+
type: "button",
|
|
573
|
+
onClick: () => {
|
|
574
|
+
setViewMode("month");
|
|
575
|
+
},
|
|
576
|
+
className: "text-sm font-bold text-text hover:text-primary px-2 py-1 rounded-lg hover:bg-hover",
|
|
577
|
+
children: [
|
|
578
|
+
MONTH_NAMES[viewMonth],
|
|
579
|
+
" ",
|
|
580
|
+
viewYear
|
|
581
|
+
]
|
|
582
|
+
}
|
|
583
|
+
),
|
|
584
|
+
/* @__PURE__ */ jsx(
|
|
585
|
+
"button",
|
|
586
|
+
{
|
|
587
|
+
type: "button",
|
|
588
|
+
onClick: nextMonth,
|
|
589
|
+
className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary",
|
|
590
|
+
"aria-label": "Next month",
|
|
591
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "w-4 h-4" })
|
|
592
|
+
}
|
|
593
|
+
)
|
|
594
|
+
] }),
|
|
595
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 mb-1", children: DAY_NAMES_SHORT.map((d) => /* @__PURE__ */ jsx(
|
|
596
|
+
"div",
|
|
597
|
+
{
|
|
598
|
+
className: "text-center text-xs font-semibold text-text-muted py-1",
|
|
599
|
+
children: d
|
|
600
|
+
},
|
|
601
|
+
d
|
|
602
|
+
)) }),
|
|
603
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 gap-y-0.5", children: calendarGrid.flat().map((date, idx) => {
|
|
604
|
+
if (!date) return /* @__PURE__ */ jsx("div", {}, idx);
|
|
605
|
+
const isSel = selDate ? isSameDay(date, selDate) : false;
|
|
606
|
+
const isToday = isSameDay(date, today);
|
|
607
|
+
const isDis = isDisabledDate(date, minDate, maxDate, disabledDates);
|
|
608
|
+
return /* @__PURE__ */ jsx(
|
|
609
|
+
"button",
|
|
610
|
+
{
|
|
611
|
+
type: "button",
|
|
612
|
+
onClick: () => {
|
|
613
|
+
handleDateSelect(date);
|
|
614
|
+
},
|
|
615
|
+
disabled: isDis,
|
|
616
|
+
className: cn(
|
|
617
|
+
"mx-auto flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium transition-colors",
|
|
618
|
+
isSel ? "bg-primary text-white font-bold" : isToday ? "ring-2 ring-primary text-primary" : "text-text hover:bg-hover",
|
|
619
|
+
isDis && "opacity-30 cursor-not-allowed"
|
|
620
|
+
),
|
|
621
|
+
children: date.getDate()
|
|
622
|
+
},
|
|
623
|
+
idx
|
|
624
|
+
);
|
|
625
|
+
}) })
|
|
626
|
+
] }),
|
|
627
|
+
viewMode === "month" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
628
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
629
|
+
/* @__PURE__ */ jsx(
|
|
630
|
+
"button",
|
|
631
|
+
{
|
|
632
|
+
type: "button",
|
|
633
|
+
onClick: () => {
|
|
634
|
+
setViewYear((y) => y - 1);
|
|
635
|
+
},
|
|
636
|
+
className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary",
|
|
637
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "w-4 h-4" })
|
|
638
|
+
}
|
|
639
|
+
),
|
|
640
|
+
/* @__PURE__ */ jsx(
|
|
641
|
+
"button",
|
|
642
|
+
{
|
|
643
|
+
type: "button",
|
|
644
|
+
onClick: () => {
|
|
645
|
+
setViewMode("year");
|
|
646
|
+
},
|
|
647
|
+
className: "text-sm font-bold text-text hover:text-primary px-2 py-1 rounded-lg hover:bg-hover",
|
|
648
|
+
children: viewYear
|
|
649
|
+
}
|
|
650
|
+
),
|
|
651
|
+
/* @__PURE__ */ jsx(
|
|
652
|
+
"button",
|
|
653
|
+
{
|
|
654
|
+
type: "button",
|
|
655
|
+
onClick: () => {
|
|
656
|
+
setViewYear((y) => y + 1);
|
|
657
|
+
},
|
|
658
|
+
className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary",
|
|
659
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "w-4 h-4" })
|
|
660
|
+
}
|
|
661
|
+
)
|
|
662
|
+
] }),
|
|
663
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-1", children: MONTH_NAMES_SHORT.map((m, i) => /* @__PURE__ */ jsx(
|
|
664
|
+
"button",
|
|
665
|
+
{
|
|
666
|
+
type: "button",
|
|
667
|
+
onClick: () => {
|
|
668
|
+
setViewMonth(i);
|
|
669
|
+
setViewMode("day");
|
|
670
|
+
},
|
|
671
|
+
className: cn(
|
|
672
|
+
"py-2 rounded-lg text-sm font-medium transition-colors",
|
|
673
|
+
i === viewMonth ? "bg-primary text-white" : "text-text hover:bg-hover"
|
|
674
|
+
),
|
|
675
|
+
children: m
|
|
676
|
+
},
|
|
677
|
+
m
|
|
678
|
+
)) })
|
|
679
|
+
] }),
|
|
680
|
+
viewMode === "year" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
681
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
682
|
+
/* @__PURE__ */ jsx(
|
|
683
|
+
"button",
|
|
684
|
+
{
|
|
685
|
+
type: "button",
|
|
686
|
+
onClick: () => {
|
|
687
|
+
setViewYear((y) => y - 12);
|
|
688
|
+
},
|
|
689
|
+
className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary",
|
|
690
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "w-4 h-4" })
|
|
691
|
+
}
|
|
692
|
+
),
|
|
693
|
+
/* @__PURE__ */ jsxs("span", { className: "text-sm font-bold text-text", children: [
|
|
694
|
+
yearRange[0],
|
|
695
|
+
" \u2013 ",
|
|
696
|
+
yearRange[yearRange.length - 1]
|
|
697
|
+
] }),
|
|
698
|
+
/* @__PURE__ */ jsx(
|
|
699
|
+
"button",
|
|
700
|
+
{
|
|
701
|
+
type: "button",
|
|
702
|
+
onClick: () => {
|
|
703
|
+
setViewYear((y) => y + 12);
|
|
704
|
+
},
|
|
705
|
+
className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary",
|
|
706
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "w-4 h-4" })
|
|
707
|
+
}
|
|
708
|
+
)
|
|
709
|
+
] }),
|
|
710
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-1", children: yearRange.map((yr) => /* @__PURE__ */ jsx(
|
|
711
|
+
"button",
|
|
712
|
+
{
|
|
713
|
+
type: "button",
|
|
714
|
+
onClick: () => {
|
|
715
|
+
setViewYear(yr);
|
|
716
|
+
setViewMode("month");
|
|
717
|
+
},
|
|
718
|
+
className: cn(
|
|
719
|
+
"py-2 rounded-lg text-sm font-medium transition-colors",
|
|
720
|
+
yr === selDate?.getFullYear() ? "bg-primary text-white" : "text-text hover:bg-hover",
|
|
721
|
+
yr === today.getFullYear() && yr !== selDate?.getFullYear() ? "ring-1 ring-primary text-primary" : ""
|
|
722
|
+
),
|
|
723
|
+
children: yr
|
|
724
|
+
},
|
|
725
|
+
yr
|
|
726
|
+
)) })
|
|
727
|
+
] })
|
|
728
|
+
] }),
|
|
729
|
+
tab === "time" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
|
|
730
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-bold text-text-muted uppercase tracking-widest mb-3", children: "Select Time" }),
|
|
731
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-1", children: [
|
|
732
|
+
/* @__PURE__ */ jsx(
|
|
733
|
+
ScrollColumn,
|
|
734
|
+
{
|
|
735
|
+
items: hourItems,
|
|
736
|
+
selected: pickerHour,
|
|
737
|
+
onSelect: handleHour,
|
|
738
|
+
label: "Hour"
|
|
739
|
+
}
|
|
740
|
+
),
|
|
741
|
+
/* @__PURE__ */ jsx(
|
|
742
|
+
"div",
|
|
743
|
+
{
|
|
744
|
+
className: "flex items-center self-center text-text-muted font-bold text-lg pb-2",
|
|
745
|
+
style: { height: ITEM_H },
|
|
746
|
+
children: ":"
|
|
747
|
+
}
|
|
748
|
+
),
|
|
749
|
+
/* @__PURE__ */ jsx(
|
|
750
|
+
ScrollColumn,
|
|
751
|
+
{
|
|
752
|
+
items: minuteItems,
|
|
753
|
+
selected: pickerMinute,
|
|
754
|
+
onSelect: handleMinute,
|
|
755
|
+
label: "Minute"
|
|
756
|
+
}
|
|
757
|
+
),
|
|
758
|
+
use12Hour && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
759
|
+
/* @__PURE__ */ jsx("div", { className: "w-px self-stretch bg-border mx-1" }),
|
|
760
|
+
/* @__PURE__ */ jsx(
|
|
761
|
+
ScrollColumn,
|
|
762
|
+
{
|
|
763
|
+
items: ["AM", "PM"],
|
|
764
|
+
selected: pickerAmpm,
|
|
765
|
+
onSelect: handleAmpm,
|
|
766
|
+
label: "AM/PM"
|
|
767
|
+
}
|
|
768
|
+
)
|
|
769
|
+
] })
|
|
770
|
+
] }),
|
|
771
|
+
/* @__PURE__ */ jsx("div", { className: "mt-3 pt-3 border-t border-border w-full text-center", children: /* @__PURE__ */ jsx("span", { className: "text-sm font-bold text-primary font-mono", children: selTimeStr ? formatTimeDisplay(selTimeStr, use12Hour) : "\u2013\u2013:\u2013\u2013" }) })
|
|
772
|
+
] })
|
|
773
|
+
] }),
|
|
774
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 pb-3 pt-1 gap-2", children: [
|
|
775
|
+
/* @__PURE__ */ jsx(
|
|
776
|
+
"button",
|
|
777
|
+
{
|
|
778
|
+
type: "button",
|
|
779
|
+
onClick: handleNow,
|
|
780
|
+
className: "flex-1 py-1.5 rounded-lg text-xs font-bold text-primary border border-primary/30 hover:bg-primary/10 transition-colors",
|
|
781
|
+
children: "Now"
|
|
782
|
+
}
|
|
783
|
+
),
|
|
784
|
+
/* @__PURE__ */ jsx(
|
|
785
|
+
"button",
|
|
786
|
+
{
|
|
787
|
+
type: "button",
|
|
788
|
+
onClick: () => {
|
|
789
|
+
setIsOpen(false);
|
|
790
|
+
setViewMode("day");
|
|
791
|
+
},
|
|
792
|
+
className: "flex-1 py-1.5 rounded-lg text-xs font-bold bg-primary text-white hover:bg-primary/90 transition-colors",
|
|
793
|
+
children: "Apply"
|
|
794
|
+
}
|
|
795
|
+
)
|
|
796
|
+
] })
|
|
797
|
+
]
|
|
798
|
+
}
|
|
799
|
+
)
|
|
800
|
+
]
|
|
801
|
+
}
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
);
|
|
805
|
+
|
|
806
|
+
export { DateTimePicker };
|