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