@bricks-toolkit/toolkit 0.1.19 → 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.
Files changed (100) hide show
  1. package/dist/chunk-4PRNRENN.mjs +104 -0
  2. package/dist/chunk-62JXQJBD.cjs +533 -0
  3. package/dist/chunk-6LBTRQZD.mjs +806 -0
  4. package/dist/chunk-J53N2LAE.cjs +115 -0
  5. package/dist/chunk-M6XPQ5BE.cjs +808 -0
  6. package/dist/chunk-UPSMZISM.mjs +567 -0
  7. package/dist/chunk-YV3WWKQY.cjs +569 -0
  8. package/dist/chunk-Z5FRCULF.mjs +531 -0
  9. package/dist/date-picker/index.cjs +3 -2
  10. package/dist/date-picker/index.mjs +2 -1
  11. package/dist/date-time-picker/index.cjs +12 -0
  12. package/dist/date-time-picker/index.mjs +3 -0
  13. package/dist/index.cjs +27 -21
  14. package/dist/index.mjs +7 -5
  15. package/dist/time-picker/index.cjs +2 -2
  16. package/dist/time-picker/index.mjs +1 -1
  17. package/package.json +11 -1
  18. package/dist/Button.types-BsQYqZml.d.ts +0 -27
  19. package/dist/Button.types-D-srlWFf.d.mts +0 -27
  20. package/dist/TextInput.types-DRI8HQza.d.mts +0 -32
  21. package/dist/TextInput.types-DRI8HQza.d.ts +0 -32
  22. package/dist/Tooltip.types-PbUasE3C.d.mts +0 -36
  23. package/dist/Tooltip.types-PbUasE3C.d.ts +0 -36
  24. package/dist/avatar/index.d.mts +0 -29
  25. package/dist/avatar/index.d.ts +0 -29
  26. package/dist/badge/index.d.mts +0 -57
  27. package/dist/badge/index.d.ts +0 -57
  28. package/dist/breadcrumbs/index.d.mts +0 -32
  29. package/dist/breadcrumbs/index.d.ts +0 -32
  30. package/dist/button/index.d.mts +0 -8
  31. package/dist/button/index.d.ts +0 -8
  32. package/dist/card/index.d.mts +0 -42
  33. package/dist/card/index.d.ts +0 -42
  34. package/dist/checkbox/index.d.mts +0 -36
  35. package/dist/checkbox/index.d.ts +0 -36
  36. package/dist/chunk-7WNJ7L4Z.mjs +0 -335
  37. package/dist/chunk-DHC5LI2P.cjs +0 -338
  38. package/dist/chunk-VKQDW7C2.mjs +0 -336
  39. package/dist/chunk-W2ZAPLQH.cjs +0 -337
  40. package/dist/combo-box/index.d.mts +0 -62
  41. package/dist/combo-box/index.d.ts +0 -62
  42. package/dist/date-picker/index.d.mts +0 -32
  43. package/dist/date-picker/index.d.ts +0 -32
  44. package/dist/dialog/index.d.mts +0 -61
  45. package/dist/dialog/index.d.ts +0 -61
  46. package/dist/dropdown-menu/index.d.mts +0 -34
  47. package/dist/dropdown-menu/index.d.ts +0 -34
  48. package/dist/email/index.d.mts +0 -38
  49. package/dist/email/index.d.ts +0 -38
  50. package/dist/file-upload/index.d.mts +0 -27
  51. package/dist/file-upload/index.d.ts +0 -27
  52. package/dist/header/index.d.mts +0 -28
  53. package/dist/header/index.d.ts +0 -28
  54. package/dist/icon-button/index.d.mts +0 -16
  55. package/dist/icon-button/index.d.ts +0 -16
  56. package/dist/image/index.d.mts +0 -48
  57. package/dist/image/index.d.ts +0 -48
  58. package/dist/index.d.mts +0 -141
  59. package/dist/index.d.ts +0 -141
  60. package/dist/link/index.d.mts +0 -25
  61. package/dist/link/index.d.ts +0 -25
  62. package/dist/loader/index.d.mts +0 -21
  63. package/dist/loader/index.d.ts +0 -21
  64. package/dist/modal/index.d.mts +0 -116
  65. package/dist/modal/index.d.ts +0 -116
  66. package/dist/multi-select/index.d.mts +0 -59
  67. package/dist/multi-select/index.d.ts +0 -59
  68. package/dist/otp-input/index.d.mts +0 -57
  69. package/dist/otp-input/index.d.ts +0 -57
  70. package/dist/password-input/index.d.mts +0 -32
  71. package/dist/password-input/index.d.ts +0 -32
  72. package/dist/phone/index.d.mts +0 -41
  73. package/dist/phone/index.d.ts +0 -41
  74. package/dist/radio-button/index.d.mts +0 -56
  75. package/dist/radio-button/index.d.ts +0 -56
  76. package/dist/search-input/index.d.mts +0 -22
  77. package/dist/search-input/index.d.ts +0 -22
  78. package/dist/select/index.d.mts +0 -36
  79. package/dist/select/index.d.ts +0 -36
  80. package/dist/sidebar/index.d.mts +0 -96
  81. package/dist/sidebar/index.d.ts +0 -96
  82. package/dist/skeleton/index.d.mts +0 -76
  83. package/dist/skeleton/index.d.ts +0 -76
  84. package/dist/styles.d.mts +0 -2
  85. package/dist/styles.d.ts +0 -2
  86. package/dist/table/index.d.mts +0 -92
  87. package/dist/table/index.d.ts +0 -92
  88. package/dist/tabs/index.d.mts +0 -26
  89. package/dist/tabs/index.d.ts +0 -26
  90. package/dist/text-input/index.d.mts +0 -7
  91. package/dist/text-input/index.d.ts +0 -7
  92. package/dist/theme-provider/index.d.mts +0 -122
  93. package/dist/theme-provider/index.d.ts +0 -122
  94. package/dist/theme.css +0 -62
  95. package/dist/time-picker/index.d.mts +0 -32
  96. package/dist/time-picker/index.d.ts +0 -32
  97. package/dist/toaster/index.d.mts +0 -28
  98. package/dist/toaster/index.d.ts +0 -28
  99. package/dist/tooltip/index.d.mts +0 -7
  100. package/dist/tooltip/index.d.ts +0 -7
@@ -0,0 +1,567 @@
1
+ import { parseISODate, buildCalendarGrid, getYearRange, formatDate, MONTH_NAMES, DAY_NAMES_SHORT, isSameDay, isDisabledDate, MONTH_NAMES_SHORT, toISODateString } from './chunk-4PRNRENN.mjs';
2
+ import { cn } from './chunk-OCPFOFJ4.mjs';
3
+ import { forwardRef, useId, useState, useMemo, useRef, useEffect } from 'react';
4
+ import { CalendarIcon, XMarkIcon, ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline';
5
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
+
7
+ var sizeClasses = {
8
+ xs: "h-6 px-2 text-xs",
9
+ sm: "h-8 px-3 text-sm",
10
+ md: "h-10 px-3 text-sm",
11
+ lg: "h-11 px-4 text-base",
12
+ xl: "h-12 px-4 text-lg"
13
+ };
14
+ var labelSizeClasses = {
15
+ xs: "text-xs",
16
+ sm: "text-xs",
17
+ md: "text-sm",
18
+ lg: "text-sm",
19
+ xl: "text-base"
20
+ };
21
+ var variantClasses = {
22
+ default: "rounded-md border border-border bg-surface shadow-sm focus-within:outline-none focus-within:ring-2 focus-within:ring-primary/40 transition-all duration-200",
23
+ 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",
24
+ flushed: "rounded-none border-0 border-b border-border bg-transparent",
25
+ unstyled: "border-0 bg-transparent p-0"
26
+ };
27
+ var stateVariantClasses = {
28
+ default: {
29
+ default: "border-border focus-within:border-primary",
30
+ filled: "focus-within:border-primary",
31
+ flushed: "border-border focus-within:border-primary",
32
+ unstyled: ""
33
+ },
34
+ error: {
35
+ default: "border-error focus-within:border-error focus-within:ring-error/20",
36
+ filled: "bg-error/5 focus-within:border-error focus-within:ring-error/20",
37
+ flushed: "border-error",
38
+ unstyled: ""
39
+ },
40
+ success: {
41
+ default: "border-success focus-within:border-success focus-within:ring-success/20",
42
+ filled: "bg-success/5 focus-within:border-success focus-within:ring-success/20",
43
+ flushed: "border-success",
44
+ unstyled: ""
45
+ },
46
+ warning: {
47
+ default: "border-warning focus-within:border-warning focus-within:ring-warning/20",
48
+ filled: "bg-warning/5 focus-within:border-warning focus-within:ring-warning/20",
49
+ flushed: "border-warning",
50
+ unstyled: ""
51
+ }
52
+ };
53
+ var stateMessageClasses = {
54
+ default: "text-text-muted",
55
+ error: "text-error font-medium",
56
+ success: "text-success font-medium",
57
+ warning: "text-warning font-medium"
58
+ };
59
+ function AddonIcon({ children, side, size, onClick, asButton = false, ariaLabel }) {
60
+ const iconSize = {
61
+ xs: "w-3.5 h-3.5",
62
+ sm: "w-4 h-4",
63
+ md: "w-4 h-4",
64
+ lg: "w-5 h-5",
65
+ xl: "w-5 h-5"
66
+ };
67
+ const base = cn(
68
+ "absolute top-1/2 -translate-y-1/2 text-text-secondary flex items-center justify-center",
69
+ side === "left" ? "left-3" : "right-3",
70
+ iconSize[size]
71
+ );
72
+ if (asButton && onClick) {
73
+ return /* @__PURE__ */ jsx(
74
+ "button",
75
+ {
76
+ type: "button",
77
+ onClick,
78
+ className: cn(base, "cursor-pointer hover:text-text transition-colors"),
79
+ tabIndex: -1,
80
+ "aria-label": ariaLabel,
81
+ children
82
+ }
83
+ );
84
+ }
85
+ return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn(base, "pointer-events-none"), "aria-label": ariaLabel, children });
86
+ }
87
+ function Addon({ children, side }) {
88
+ return /* @__PURE__ */ jsx(
89
+ "span",
90
+ {
91
+ "aria-hidden": "true",
92
+ className: cn(
93
+ "inline-flex items-center border border-border bg-surface-secondary px-3 text-sm text-text-secondary select-none",
94
+ side === "left" ? "rounded-l-md border-r-0" : "rounded-r-md border-l-0"
95
+ ),
96
+ children
97
+ }
98
+ );
99
+ }
100
+ var DatePicker = forwardRef(
101
+ ({
102
+ label,
103
+ required = false,
104
+ helperText,
105
+ errorMessage,
106
+ successMessage,
107
+ warningMessage,
108
+ variant = "default",
109
+ size = "md",
110
+ state = "default",
111
+ fullWidth = true,
112
+ leftElement,
113
+ rightElement,
114
+ prefix,
115
+ suffix,
116
+ wrapperClassName,
117
+ inputGroupClassName,
118
+ inputClassName,
119
+ labelClassName,
120
+ helperClassName,
121
+ id: idProp,
122
+ disabled,
123
+ className,
124
+ clearable,
125
+ isLoading,
126
+ value,
127
+ defaultValue,
128
+ onChange,
129
+ onDateChange,
130
+ placeholder = "Select date",
131
+ minDate,
132
+ maxDate,
133
+ disabledDates,
134
+ locale = "en-US",
135
+ name,
136
+ "aria-label": ariaLabel,
137
+ "aria-describedby": ariaDescribedby
138
+ }, ref) => {
139
+ const generatedId = useId();
140
+ const inputId = idProp ?? generatedId;
141
+ const helperId = `${inputId}-helper`;
142
+ const stateMessageId = `${inputId}-state`;
143
+ const popoverId = `${inputId}-popover`;
144
+ const isControlled = value !== void 0;
145
+ const [internalValue, setInternalValue] = useState(defaultValue ?? "");
146
+ const displayValue = isControlled ? value : internalValue;
147
+ const selectedDate = parseISODate(displayValue);
148
+ const today = useMemo(() => /* @__PURE__ */ new Date(), []);
149
+ const [isOpen, setIsOpen] = useState(false);
150
+ const [viewYear, setViewYear] = useState(selectedDate?.getFullYear() ?? today.getFullYear());
151
+ const [viewMonth, setViewMonth] = useState(selectedDate?.getMonth() ?? today.getMonth());
152
+ const [viewMode, setViewMode] = useState("day");
153
+ const popoverRef = useRef(null);
154
+ const [prevDisplay, setPrevDisplay] = useState(displayValue);
155
+ if (displayValue !== prevDisplay) {
156
+ setPrevDisplay(displayValue);
157
+ if (selectedDate) {
158
+ setViewYear(selectedDate.getFullYear());
159
+ setViewMonth(selectedDate.getMonth());
160
+ }
161
+ }
162
+ useEffect(() => {
163
+ if (!isOpen) return;
164
+ function handleClick(e) {
165
+ const wrapper = ref?.current;
166
+ if (wrapper && !wrapper.contains(e.target)) {
167
+ setIsOpen(false);
168
+ setViewMode("day");
169
+ }
170
+ }
171
+ document.addEventListener("mousedown", handleClick);
172
+ return () => {
173
+ document.removeEventListener("mousedown", handleClick);
174
+ };
175
+ }, [isOpen]);
176
+ const handleSelect = (date) => {
177
+ if (isDisabledDate(date, minDate, maxDate, disabledDates)) return;
178
+ const iso = toISODateString(date);
179
+ if (!isControlled) setInternalValue(iso);
180
+ onChange?.(iso);
181
+ onDateChange?.(date);
182
+ setIsOpen(false);
183
+ setViewMode("day");
184
+ };
185
+ const handleClear = () => {
186
+ if (!isControlled) setInternalValue("");
187
+ onChange?.("");
188
+ onDateChange?.(null);
189
+ };
190
+ const toggleOpen = () => {
191
+ if (disabled || isLoading) return;
192
+ setIsOpen((prev) => !prev);
193
+ setViewMode("day");
194
+ if (!isOpen && selectedDate) {
195
+ setViewYear(selectedDate.getFullYear());
196
+ setViewMonth(selectedDate.getMonth());
197
+ }
198
+ };
199
+ const prevMonth = () => {
200
+ if (viewMonth === 0) {
201
+ setViewMonth(11);
202
+ setViewYear((y) => y - 1);
203
+ } else setViewMonth((m) => m - 1);
204
+ };
205
+ const nextMonth = () => {
206
+ if (viewMonth === 11) {
207
+ setViewMonth(0);
208
+ setViewYear((y) => y + 1);
209
+ } else setViewMonth((m) => m + 1);
210
+ };
211
+ const showClear = clearable && displayValue.length > 0 && !disabled && !isLoading;
212
+ const hasLeftElement = leftElement !== void 0;
213
+ const hasRightElement = rightElement !== void 0 || Boolean(showClear) || Boolean(isLoading);
214
+ const stateMessage = state === "error" ? errorMessage : state === "success" ? successMessage : state === "warning" ? warningMessage : void 0;
215
+ const describedBy = [helperText ? helperId : null, stateMessage ? stateMessageId : null, ariaDescribedby ?? null].filter(Boolean).join(" ") || void 0;
216
+ const calendarGrid = buildCalendarGrid(viewYear, viewMonth);
217
+ const yearRange = getYearRange(viewYear);
218
+ const leftPad = {
219
+ xs: "pl-6",
220
+ sm: "pl-8",
221
+ md: "pl-9",
222
+ lg: "pl-10",
223
+ xl: "pl-11"
224
+ };
225
+ const rightPad = {
226
+ xs: "pr-6",
227
+ sm: "pr-8",
228
+ md: "pr-9",
229
+ lg: "pr-10",
230
+ xl: "pr-11"
231
+ };
232
+ const paddingClasses = cn(
233
+ hasLeftElement && leftPad[size],
234
+ (hasRightElement || showClear) && rightPad[size]
235
+ );
236
+ return /* @__PURE__ */ jsxs(
237
+ "div",
238
+ {
239
+ ref,
240
+ className: cn(
241
+ "flex flex-col gap-1 relative",
242
+ fullWidth ? "w-full" : "w-fit",
243
+ wrapperClassName,
244
+ className
245
+ ),
246
+ children: [
247
+ label !== void 0 && /* @__PURE__ */ jsxs(
248
+ "label",
249
+ {
250
+ htmlFor: inputId,
251
+ className: cn(
252
+ "font-black leading-none text-text uppercase tracking-widest",
253
+ labelSizeClasses[size],
254
+ labelClassName
255
+ ),
256
+ children: [
257
+ label,
258
+ required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "ml-1 text-error", children: "*" })
259
+ ]
260
+ }
261
+ ),
262
+ /* @__PURE__ */ jsxs(
263
+ "div",
264
+ {
265
+ className: cn("flex items-stretch", fullWidth ? "w-full" : "w-fit", inputGroupClassName),
266
+ children: [
267
+ prefix !== void 0 && /* @__PURE__ */ jsx(Addon, { side: "left", children: prefix }),
268
+ /* @__PURE__ */ jsxs("div", { className: "relative flex flex-1 items-center", children: [
269
+ /* @__PURE__ */ jsx(AddonIcon, { side: "left", size, children: leftElement ?? /* @__PURE__ */ jsx(CalendarIcon, { className: "w-full h-full" }) }),
270
+ /* @__PURE__ */ jsx(
271
+ "button",
272
+ {
273
+ id: inputId,
274
+ type: "button",
275
+ role: "combobox",
276
+ "aria-expanded": isOpen,
277
+ "aria-haspopup": "dialog",
278
+ "aria-controls": popoverId,
279
+ "aria-label": ariaLabel ?? label ?? "Date picker",
280
+ "aria-describedby": describedBy,
281
+ "aria-required": required,
282
+ "aria-invalid": state === "error" ? true : void 0,
283
+ disabled: Boolean(disabled) || Boolean(isLoading),
284
+ onClick: toggleOpen,
285
+ name,
286
+ className: cn(
287
+ "w-full flex items-center text-left transition-colors duration-150 cursor-pointer",
288
+ "disabled:cursor-not-allowed disabled:opacity-50",
289
+ sizeClasses[size],
290
+ variantClasses[variant],
291
+ stateVariantClasses[state][variant],
292
+ "pl-9",
293
+ hasRightElement || showClear ? rightPad[size] : "",
294
+ paddingClasses,
295
+ inputClassName,
296
+ prefix !== void 0 && suffix !== void 0 ? "rounded-none" : prefix !== void 0 ? "rounded-l-none" : suffix !== void 0 ? "rounded-r-none" : ""
297
+ ),
298
+ children: displayValue && selectedDate ? /* @__PURE__ */ jsx("span", { className: "text-text truncate", children: formatDate(selectedDate, locale) }) : /* @__PURE__ */ jsx("span", { className: "text-text-muted", children: placeholder })
299
+ }
300
+ ),
301
+ isLoading ? /* @__PURE__ */ jsx(AddonIcon, { side: "right", size, children: /* @__PURE__ */ jsxs(
302
+ "svg",
303
+ {
304
+ className: "animate-spin h-full w-full text-text-muted",
305
+ xmlns: "http://www.w3.org/2000/svg",
306
+ fill: "none",
307
+ viewBox: "0 0 24 24",
308
+ children: [
309
+ /* @__PURE__ */ jsx(
310
+ "circle",
311
+ {
312
+ className: "opacity-25",
313
+ cx: "12",
314
+ cy: "12",
315
+ r: "10",
316
+ stroke: "currentColor",
317
+ strokeWidth: "4"
318
+ }
319
+ ),
320
+ /* @__PURE__ */ jsx(
321
+ "path",
322
+ {
323
+ className: "opacity-75",
324
+ fill: "currentColor",
325
+ 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"
326
+ }
327
+ )
328
+ ]
329
+ }
330
+ ) }) : showClear ? /* @__PURE__ */ jsx(
331
+ AddonIcon,
332
+ {
333
+ side: "right",
334
+ size,
335
+ asButton: true,
336
+ onClick: handleClear,
337
+ ariaLabel: "Clear date",
338
+ children: /* @__PURE__ */ jsx(XMarkIcon, { className: "w-full h-full", strokeWidth: 2.5 })
339
+ }
340
+ ) : rightElement ? /* @__PURE__ */ jsx(AddonIcon, { side: "right", size, children: rightElement }) : null
341
+ ] }),
342
+ suffix !== void 0 && /* @__PURE__ */ jsx(Addon, { side: "right", children: suffix })
343
+ ]
344
+ }
345
+ ),
346
+ helperText !== void 0 && /* @__PURE__ */ jsx(
347
+ "p",
348
+ {
349
+ id: helperId,
350
+ className: cn("text-xs leading-tight text-text-muted font-medium", helperClassName),
351
+ children: helperText
352
+ }
353
+ ),
354
+ stateMessage !== void 0 && /* @__PURE__ */ jsx(
355
+ "p",
356
+ {
357
+ id: stateMessageId,
358
+ role: state === "error" ? "alert" : void 0,
359
+ className: cn(
360
+ "text-xs leading-tight mt-0.5 font-medium",
361
+ stateMessageClasses[state],
362
+ helperClassName
363
+ ),
364
+ children: stateMessage
365
+ }
366
+ ),
367
+ /* @__PURE__ */ jsx(
368
+ "div",
369
+ {
370
+ id: popoverId,
371
+ ref: popoverRef,
372
+ role: "dialog",
373
+ "aria-label": "Date picker calendar",
374
+ "aria-modal": "true",
375
+ className: cn(
376
+ "absolute top-full left-0 z-50 mt-1 w-72",
377
+ "bg-surface border border-border rounded-xl shadow-xl",
378
+ "transition-all duration-200 origin-top",
379
+ isOpen ? "opacity-100 scale-100 pointer-events-auto" : "opacity-0 scale-95 pointer-events-none"
380
+ ),
381
+ children: /* @__PURE__ */ jsxs("div", { className: "p-3", children: [
382
+ viewMode === "day" && /* @__PURE__ */ jsxs(Fragment, { children: [
383
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
384
+ /* @__PURE__ */ jsx(
385
+ "button",
386
+ {
387
+ type: "button",
388
+ onClick: prevMonth,
389
+ className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary hover:text-text transition-colors",
390
+ "aria-label": "Previous month",
391
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "w-4 h-4" })
392
+ }
393
+ ),
394
+ /* @__PURE__ */ jsxs(
395
+ "button",
396
+ {
397
+ type: "button",
398
+ onClick: () => {
399
+ setViewMode("month");
400
+ },
401
+ className: "text-sm font-bold text-text hover:text-primary transition-colors px-2 py-1 rounded-lg hover:bg-hover",
402
+ children: [
403
+ MONTH_NAMES[viewMonth],
404
+ " ",
405
+ viewYear
406
+ ]
407
+ }
408
+ ),
409
+ /* @__PURE__ */ jsx(
410
+ "button",
411
+ {
412
+ type: "button",
413
+ onClick: nextMonth,
414
+ className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary hover:text-text transition-colors",
415
+ "aria-label": "Next month",
416
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "w-4 h-4" })
417
+ }
418
+ )
419
+ ] }),
420
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 mb-1", children: DAY_NAMES_SHORT.map((d) => /* @__PURE__ */ jsx("div", { className: "text-center text-xs font-semibold text-text-muted py-1", children: d }, d)) }),
421
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 gap-y-0.5", children: calendarGrid.flat().map((date, idx) => {
422
+ if (!date) return /* @__PURE__ */ jsx("div", {}, idx);
423
+ const isSelected = selectedDate ? isSameDay(date, selectedDate) : false;
424
+ const isToday = isSameDay(date, today);
425
+ const isDisabled = isDisabledDate(date, minDate, maxDate, disabledDates);
426
+ return /* @__PURE__ */ jsx(
427
+ "button",
428
+ {
429
+ type: "button",
430
+ onClick: () => {
431
+ handleSelect(date);
432
+ },
433
+ disabled: isDisabled,
434
+ "aria-label": date.toDateString(),
435
+ "aria-pressed": isSelected,
436
+ className: cn(
437
+ "mx-auto flex h-8 w-8 items-center justify-center rounded-full text-sm transition-colors duration-150 font-medium",
438
+ isSelected ? "bg-primary text-white font-bold shadow-sm" : isToday ? "ring-2 ring-primary text-primary" : "text-text hover:bg-hover",
439
+ isDisabled && "opacity-30 cursor-not-allowed"
440
+ ),
441
+ children: date.getDate()
442
+ },
443
+ idx
444
+ );
445
+ }) })
446
+ ] }),
447
+ viewMode === "month" && /* @__PURE__ */ jsxs(Fragment, { children: [
448
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
449
+ /* @__PURE__ */ jsx(
450
+ "button",
451
+ {
452
+ type: "button",
453
+ onClick: () => {
454
+ setViewYear((y) => y - 1);
455
+ },
456
+ className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary hover:text-text transition-colors",
457
+ "aria-label": "Previous year",
458
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "w-4 h-4" })
459
+ }
460
+ ),
461
+ /* @__PURE__ */ jsx(
462
+ "button",
463
+ {
464
+ type: "button",
465
+ onClick: () => {
466
+ setViewMode("year");
467
+ },
468
+ className: "text-sm font-bold text-text hover:text-primary transition-colors px-2 py-1 rounded-lg hover:bg-hover",
469
+ children: viewYear
470
+ }
471
+ ),
472
+ /* @__PURE__ */ jsx(
473
+ "button",
474
+ {
475
+ type: "button",
476
+ onClick: () => {
477
+ setViewYear((y) => y + 1);
478
+ },
479
+ className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary hover:text-text transition-colors",
480
+ "aria-label": "Next year",
481
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "w-4 h-4" })
482
+ }
483
+ )
484
+ ] }),
485
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-1", children: MONTH_NAMES_SHORT.map((m, i) => {
486
+ const isActive = i === viewMonth && viewYear === (selectedDate?.getFullYear() ?? -1);
487
+ return /* @__PURE__ */ jsx(
488
+ "button",
489
+ {
490
+ type: "button",
491
+ onClick: () => {
492
+ setViewMonth(i);
493
+ setViewMode("day");
494
+ },
495
+ className: cn(
496
+ "py-2 rounded-lg text-sm font-medium transition-colors",
497
+ isActive ? "bg-primary text-white" : "text-text hover:bg-hover"
498
+ ),
499
+ children: m
500
+ },
501
+ m
502
+ );
503
+ }) })
504
+ ] }),
505
+ viewMode === "year" && /* @__PURE__ */ jsxs(Fragment, { children: [
506
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
507
+ /* @__PURE__ */ jsx(
508
+ "button",
509
+ {
510
+ type: "button",
511
+ onClick: () => {
512
+ setViewYear((y) => y - 12);
513
+ },
514
+ className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary hover:text-text transition-colors",
515
+ "aria-label": "Previous decade",
516
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "w-4 h-4" })
517
+ }
518
+ ),
519
+ /* @__PURE__ */ jsxs("span", { className: "text-sm font-bold text-text", children: [
520
+ yearRange[0],
521
+ " \u2013 ",
522
+ yearRange[yearRange.length - 1]
523
+ ] }),
524
+ /* @__PURE__ */ jsx(
525
+ "button",
526
+ {
527
+ type: "button",
528
+ onClick: () => {
529
+ setViewYear((y) => y + 12);
530
+ },
531
+ className: "p-1.5 rounded-lg hover:bg-hover text-text-secondary hover:text-text transition-colors",
532
+ "aria-label": "Next decade",
533
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "w-4 h-4" })
534
+ }
535
+ )
536
+ ] }),
537
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-1", children: yearRange.map((yr) => {
538
+ const isActive = yr === (selectedDate?.getFullYear() ?? -1);
539
+ return /* @__PURE__ */ jsx(
540
+ "button",
541
+ {
542
+ type: "button",
543
+ onClick: () => {
544
+ setViewYear(yr);
545
+ setViewMode("month");
546
+ },
547
+ className: cn(
548
+ "py-2 rounded-lg text-sm font-medium transition-colors",
549
+ isActive ? "bg-primary text-white" : "text-text hover:bg-hover",
550
+ yr === today.getFullYear() && !isActive ? "ring-1 ring-primary text-primary" : ""
551
+ ),
552
+ children: yr
553
+ },
554
+ yr
555
+ );
556
+ }) })
557
+ ] })
558
+ ] })
559
+ }
560
+ )
561
+ ]
562
+ }
563
+ );
564
+ }
565
+ );
566
+
567
+ export { DatePicker };