@dimasbaguspm/versaur 0.0.15 → 0.0.17

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 (59) hide show
  1. package/dist/js/bottom-sheet-CHRSxXRE.js +501 -0
  2. package/dist/js/{switch-input-Bx6_2zG9.js → email-input-CVyrFzqL.js} +592 -807
  3. package/dist/js/enforce-subpath-import.js +5 -2
  4. package/dist/js/feedbacks/index.js +1 -1
  5. package/dist/js/{form-layout-4ASWdXn8.js → form-layout-Dhlv-FZL.js} +1 -1
  6. package/dist/js/forms/index.js +17 -14
  7. package/dist/js/{index-DOdDlCoL.js → index-C1uJQB34.js} +2 -2
  8. package/dist/js/index.js +40 -37
  9. package/dist/js/layouts/index.js +1 -1
  10. package/dist/js/modal-FqewbVts.js +150 -0
  11. package/dist/js/navigation/index.js +1 -1
  12. package/dist/js/overlays/index.js +4 -4
  13. package/dist/js/primitive/index.js +11 -11
  14. package/dist/js/{skeleton-BNZyaRjo.js → skeleton-QEyPZAuF.js} +1 -1
  15. package/dist/js/{tabs-BbOkYchB.js → tabs-DYcTvVao.js} +1 -1
  16. package/dist/js/tile-B9bt2AY6.js +1776 -0
  17. package/dist/types/forms/chip-multiple-input/chip-multiple-input.atoms.d.ts +10 -0
  18. package/dist/types/forms/chip-multiple-input/chip-multiple-input.d.ts +5 -0
  19. package/dist/types/forms/chip-multiple-input/index.d.ts +2 -0
  20. package/dist/types/forms/{chip-input → chip-multiple-input}/types.d.ts +16 -4
  21. package/dist/types/forms/chip-single-input/chip-single-input.atoms.d.ts +10 -0
  22. package/dist/types/forms/chip-single-input/chip-single-input.d.ts +5 -0
  23. package/dist/types/forms/chip-single-input/index.d.ts +1 -0
  24. package/dist/types/forms/chip-single-input/types.d.ts +67 -0
  25. package/dist/types/forms/date-single-picker-input/date-single-picker-input.d.ts +1 -8
  26. package/dist/types/forms/date-single-picker-input/index.d.ts +1 -1
  27. package/dist/types/forms/date-single-picker-input/types.d.ts +12 -66
  28. package/dist/types/forms/email-input/email-input.d.ts +8 -0
  29. package/dist/types/forms/email-input/index.d.ts +2 -0
  30. package/dist/types/forms/email-input/types.d.ts +6 -0
  31. package/dist/types/forms/index.d.ts +5 -1
  32. package/dist/types/forms/price-input/index.d.ts +2 -0
  33. package/dist/types/forms/price-input/price-input.d.ts +6 -0
  34. package/dist/types/forms/price-input/types.d.ts +15 -0
  35. package/dist/types/forms/price-input/use-price-input.d.ts +6 -0
  36. package/dist/types/forms/search-input/index.d.ts +2 -0
  37. package/dist/types/forms/search-input/search-input.d.ts +8 -0
  38. package/dist/types/forms/search-input/types.d.ts +35 -0
  39. package/dist/types/forms/segment-multiple-input/types.d.ts +1 -5
  40. package/dist/types/forms/segment-single-input/types.d.ts +1 -5
  41. package/dist/types/overlays/modal/types.d.ts +1 -1
  42. package/dist/types/primitive/anchor/types.d.ts +8 -2
  43. package/dist/types/primitive/index.d.ts +1 -0
  44. package/package.json +1 -1
  45. package/dist/js/bottom-sheet-Difan0U1.js +0 -340
  46. package/dist/js/calendar-CUjVZ7Ap.js +0 -811
  47. package/dist/js/menu-Bm-yPIMN.js +0 -310
  48. package/dist/js/tile-DLmZbkgG.js +0 -891
  49. package/dist/types/forms/chip-input/chip-input.atoms.d.ts +0 -10
  50. package/dist/types/forms/chip-input/chip-input.d.ts +0 -5
  51. package/dist/types/forms/chip-input/index.d.ts +0 -2
  52. package/dist/types/forms/date-range-picker-input/date-range-picker-input.d.ts +0 -10
  53. package/dist/types/forms/date-range-picker-input/index.d.ts +0 -2
  54. package/dist/types/forms/date-range-picker-input/types.d.ts +0 -64
  55. package/dist/types/forms/date-range-picker-input/use-date-range-picker.d.ts +0 -13
  56. package/dist/types/forms/date-single-picker-input/date-single-picker-input.atoms.d.ts +0 -13
  57. package/dist/types/forms/date-single-picker-input/date-single-picker-input.docked.d.ts +0 -14
  58. package/dist/types/forms/date-single-picker-input/date-single-picker-input.modal.d.ts +0 -15
  59. package/dist/types/forms/date-single-picker-input/use-date-single-picker.d.ts +0 -10
@@ -1,811 +0,0 @@
1
- import { c as cva, j as jsxRuntimeExports, a as cn } from "./index-DOdDlCoL.js";
2
- import React__default, { forwardRef, useState, useRef, useEffect, useCallback, createContext, useContext } from "react";
3
- import { X, ChevronLeft, ChevronRight } from "lucide-react";
4
- const calculatorRootVariants = cva(
5
- "flex flex-col w-full max-w-xs rounded-lg bg-background",
6
- {
7
- variants: {
8
- disabled: {
9
- true: "opacity-60 pointer-events-none",
10
- false: ""
11
- }
12
- },
13
- defaultVariants: {
14
- disabled: !1
15
- }
16
- }
17
- ), calculatorButtonVariants = cva(
18
- "flex-1 min-w-0 h-12 m-0.5 rounded text-lg font-medium transition-colors select-none",
19
- {
20
- variants: {
21
- variant: {
22
- default: "bg-neutral text-foreground hover:bg-neutral-soft hover:text-neutral",
23
- action: "bg-primary text-white hover:bg-primary-soft hover:text-primary",
24
- operator: "bg-secondary text-white hover:bg-secondary-soft hover:text-secondary",
25
- danger: "bg-danger text-white hover:bg-danger-soft hover:text-danger"
26
- },
27
- disabled: {
28
- true: "opacity-50 pointer-events-none",
29
- false: ""
30
- }
31
- },
32
- defaultVariants: {
33
- variant: "default",
34
- disabled: !1
35
- }
36
- }
37
- ), CalculatorButton = forwardRef(({ variant: r = "default", className: e, ...t }, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
38
- "button",
39
- {
40
- ref: i,
41
- type: "button",
42
- className: cn(
43
- calculatorButtonVariants({ variant: r, disabled: t.disabled }),
44
- e
45
- ),
46
- ...t
47
- }
48
- ));
49
- function getIconColorFromVariant(r = "primary") {
50
- const e = r.split("-");
51
- if (e.length === 1)
52
- switch (e[0]) {
53
- case "ghost":
54
- case "neutral":
55
- case "outline":
56
- return "ghost";
57
- default:
58
- return "neutral";
59
- }
60
- if (e?.[1] === "outline") return "inherit";
61
- switch (e[0]) {
62
- case "primary":
63
- return "primary";
64
- case "secondary":
65
- return "secondary";
66
- case "tertiary":
67
- return "tertiary";
68
- case "ghost":
69
- return "ghost";
70
- case "neutral":
71
- return "ghost";
72
- case "success":
73
- return "success";
74
- case "info":
75
- return "info";
76
- case "warning":
77
- return "warning";
78
- case "danger":
79
- return "danger";
80
- default:
81
- return "neutral";
82
- }
83
- }
84
- const buttonIconVariants = cva(
85
- "inline-flex items-center justify-center font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none active:scale-[0.98] select-none",
86
- {
87
- variants: {
88
- variant: {
89
- // Core variants using Versaur color system
90
- primary: "bg-primary text-white hover:bg-primary/90 focus-visible:ring-primary-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
91
- secondary: "bg-secondary text-white hover:bg-secondary/90 focus-visible:ring-secondary-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
92
- tertiary: "bg-tertiary text-white hover:bg-tertiary/90 focus-visible:ring-tertiary-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
93
- ghost: "bg-white text-foreground hover:bg-ghost-soft focus-visible:ring-ghost-soft focus-visible:ring-offset-white",
94
- neutral: "bg-neutral text-foreground border border-border hover:bg-neutral/80 focus-visible:ring-foreground-soft focus-visible:ring-offset-white shadow-sm",
95
- // Outline variants
96
- "primary-outline": "border border-primary text-primary bg-white hover:bg-primary hover:text-white focus-visible:ring-primary-soft focus-visible:ring-offset-white transition-all",
97
- "secondary-outline": "border border-secondary text-secondary bg-white hover:bg-secondary hover:text-white focus-visible:ring-secondary-soft focus-visible:ring-offset-white transition-all",
98
- "tertiary-outline": "border border-tertiary text-tertiary bg-white hover:bg-tertiary hover:text-white focus-visible:ring-tertiary-soft focus-visible:ring-offset-white transition-all",
99
- "ghost-outline": "border border-ghost text-ghost bg-white hover:bg-ghost hover:text-white focus-visible:ring-ghost-soft focus-visible:ring-offset-white transition-all",
100
- "neutral-outline": "border border-neutral text-foreground bg-white hover:bg-neutral hover:text-foreground focus-visible:ring-foreground-soft focus-visible:ring-offset-white transition-all",
101
- // Ghost variants (subtle)
102
- "primary-ghost": "text-primary bg-white hover:bg-primary-light focus-visible:ring-primary-light focus-visible:ring-offset-white",
103
- "secondary-ghost": "text-secondary bg-white hover:bg-secondary-light focus-visible:ring-secondary-light focus-visible:ring-offset-white",
104
- "tertiary-ghost": "text-tertiary bg-white hover:bg-tertiary-light focus-visible:ring-tertiary-light focus-visible:ring-offset-white",
105
- "neutral-ghost": "text-foreground bg-white hover:bg-neutral-light focus-visible:ring-foreground-light focus-visible:ring-offset-white",
106
- // Semantic variants
107
- success: "bg-success text-white hover:bg-success/90 focus-visible:ring-success-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
108
- "success-outline": "border border-success text-success bg-white hover:bg-success hover:text-white focus-visible:ring-success-soft focus-visible:ring-offset-white transition-all",
109
- "success-ghost": "text-success bg-white hover:bg-success-light focus-visible:ring-success-light focus-visible:ring-offset-white",
110
- info: "bg-info text-white hover:bg-info/90 focus-visible:ring-info-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
111
- "info-outline": "border border-info text-info bg-white hover:bg-info hover:text-white focus-visible:ring-info-soft focus-visible:ring-offset-white transition-all",
112
- "info-ghost": "text-info bg-white hover:bg-info-light focus-visible:ring-info-light focus-visible:ring-offset-white",
113
- warning: "bg-warning text-white hover:bg-warning/90 focus-visible:ring-warning-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
114
- "warning-outline": "border border-warning text-warning bg-white hover:bg-warning hover:text-white focus-visible:ring-warning-soft focus-visible:ring-offset-white transition-all",
115
- "warning-ghost": "text-warning bg-white hover:bg-warning-light focus-visible:ring-warning-light focus-visible:ring-offset-white",
116
- danger: "bg-danger text-white hover:bg-danger/90 focus-visible:ring-danger-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
117
- "danger-outline": "border border-danger text-danger bg-white hover:bg-danger hover:text-white focus-visible:ring-danger-soft focus-visible:ring-offset-white transition-all",
118
- "danger-ghost": "text-danger bg-white hover:bg-danger-light focus-visible:ring-danger-light focus-visible:ring-offset-white",
119
- // Utility variants
120
- outline: "border border-border text-foreground bg-white hover:bg-accent-soft focus-visible:ring-accent-soft focus-visible:ring-offset-white transition-all",
121
- destructive: "bg-danger text-white hover:bg-danger/90 focus-visible:ring-danger-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md"
122
- },
123
- size: {
124
- xs: "h-6 w-6",
125
- sm: "h-8 w-8",
126
- md: "h-10 w-10",
127
- lg: "h-12 w-12",
128
- xl: "h-14 w-14"
129
- },
130
- shape: {
131
- rounded: "rounded-md",
132
- square: "rounded-sm",
133
- circle: "rounded-full"
134
- }
135
- },
136
- defaultVariants: {
137
- variant: "primary",
138
- size: "md",
139
- shape: "rounded"
140
- }
141
- }
142
- ), iconVariants = cva("inline-flex items-center justify-center", {
143
- variants: {
144
- size: {
145
- xs: "w-3 h-3",
146
- sm: "w-4 h-4",
147
- md: "w-5 h-5",
148
- lg: "w-6 h-6",
149
- xl: "w-8 h-8"
150
- },
151
- color: {
152
- primary: "text-primary",
153
- secondary: "text-secondary",
154
- tertiary: "text-tertiary",
155
- ghost: "text-ghost",
156
- neutral: "text-neutral",
157
- success: "text-success",
158
- info: "text-info",
159
- warning: "text-warning",
160
- danger: "text-danger",
161
- inherit: ""
162
- }
163
- },
164
- defaultVariants: {
165
- size: "md",
166
- color: "primary"
167
- }
168
- }), Icon = React__default.forwardRef(function({ as: e, color: t = "primary", size: i = "md", className: l, ...n }, a) {
169
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
170
- e,
171
- {
172
- ref: a,
173
- className: iconVariants({ color: t, size: i, className: l }),
174
- ...n
175
- }
176
- );
177
- }), ButtonIcon = React__default.forwardRef(
178
- function({
179
- className: e,
180
- variant: t = "primary",
181
- size: i = "md",
182
- shape: l = "rounded",
183
- disabled: n = !1,
184
- as: a,
185
- "aria-label": c,
186
- ...f
187
- }, d) {
188
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
189
- "button",
190
- {
191
- ref: d,
192
- type: "button",
193
- className: cn(
194
- buttonIconVariants({
195
- variant: t,
196
- size: i,
197
- shape: l
198
- }),
199
- e
200
- ),
201
- disabled: n,
202
- "aria-disabled": n,
203
- "aria-label": c,
204
- inert: n ? !0 : void 0,
205
- ...f,
206
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
207
- Icon,
208
- {
209
- as: a,
210
- size: i,
211
- color: getIconColorFromVariant(t)
212
- }
213
- )
214
- }
215
- );
216
- }
217
- );
218
- function useCalculator({
219
- initialValue = "",
220
- disabled,
221
- onChange
222
- }) {
223
- const [input, setInput] = useState(String(initialValue)), inputRef = useRef(null);
224
- useEffect(() => {
225
- setInput(String(initialValue));
226
- }, [initialValue]);
227
- const evaluate = useCallback((expr) => {
228
- try {
229
- if (!/^[-+*/.\d\s]+$/.test(expr)) return "";
230
- const result = eval(expr);
231
- return result?.toString() ?? "";
232
- } catch {
233
- return "";
234
- }
235
- }, []), handleButton = useCallback(
236
- (r) => {
237
- if (!disabled)
238
- if (r === "C")
239
- setInput("");
240
- else if (r === "⌫")
241
- setInput((e) => e.slice(0, -1));
242
- else if (r === "=") {
243
- const e = evaluate(input);
244
- setInput(e);
245
- } else
246
- setInput((e) => e + r);
247
- },
248
- [disabled, input, evaluate]
249
- );
250
- useEffect(() => {
251
- if (onChange) {
252
- const r = evaluate(input);
253
- onChange(r);
254
- }
255
- }, [evaluate, input, onChange]), useEffect(() => {
256
- if (disabled) return;
257
- const r = (e) => {
258
- if (document.activeElement !== inputRef.current && document.activeElement?.tagName !== "BODY")
259
- return;
260
- const t = e.key;
261
- t === "Enter" || t === "=" ? (handleButton("="), e.preventDefault()) : t === "Backspace" ? (handleButton("⌫"), e.preventDefault()) : t === "Escape" || t === "C" || t === "c" ? (handleButton("C"), e.preventDefault()) : (/^[0-9]$/.test(t) || ["/", "*", "-", "+", "."].includes(t)) && (handleButton(t), e.preventDefault());
262
- };
263
- return window.addEventListener("keydown", r), () => window.removeEventListener("keydown", r);
264
- }, [handleButton, disabled]), useEffect(() => {
265
- disabled || inputRef.current?.focus();
266
- }, [disabled]);
267
- const handleInput = (r) => {
268
- const e = r.target.value.replace(/[^\d+\-*/.]/g, "");
269
- setInput(e);
270
- };
271
- return {
272
- input,
273
- inputRef,
274
- handleButton,
275
- handleInput
276
- };
277
- }
278
- const BUTTONS = [
279
- ["7", "8", "9", "/"],
280
- ["4", "5", "6", "*"],
281
- ["1", "2", "3", "-"],
282
- ["0", ".", "=", "+"]
283
- ], Calculator = forwardRef(
284
- ({
285
- initialValue: r = "",
286
- onChange: e,
287
- disabled: t,
288
- className: i,
289
- "aria-label": l
290
- }, n) => {
291
- const { input: a, inputRef: c, handleButton: f, handleInput: d } = useCalculator({
292
- initialValue: r,
293
- disabled: t,
294
- onChange: e
295
- });
296
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
297
- "div",
298
- {
299
- ref: n,
300
- className: cn(calculatorRootVariants({ disabled: t }), i),
301
- "aria-label": l || "Calculator",
302
- role: "region",
303
- children: [
304
- /* @__PURE__ */ jsxRuntimeExports.jsx(
305
- "input",
306
- {
307
- ref: c,
308
- className: "w-full mb-3 px-3 py-2 rounded border border-[var(--color-neutral)] bg-[var(--color-neutral-soft)] text-right text-xl font-mono focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)]",
309
- value: a,
310
- onChange: d,
311
- disabled: t,
312
- inputMode: "decimal",
313
- "aria-label": "Calculator input"
314
- }
315
- ),
316
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1 mb-3", children: BUTTONS.map((w, v) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full", children: w.map((h) => h === "⌫" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
317
- ButtonIcon,
318
- {
319
- as: X,
320
- variant: "danger-ghost",
321
- "aria-label": "Backspace",
322
- size: "md",
323
- onClick: () => f("⌫"),
324
- disabled: t
325
- },
326
- "backspace"
327
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
328
- CalculatorButton,
329
- {
330
- variant: h === "=" ? "action" : h === "C" ? "danger" : ["/", "*", "-", "+", "/"].includes(h) ? "operator" : "default",
331
- onClick: () => f(h),
332
- disabled: t,
333
- "aria-label": h,
334
- children: h
335
- },
336
- h
337
- )) }, v)) })
338
- ]
339
- }
340
- );
341
- }
342
- );
343
- Calculator.displayName = "Calculator";
344
- const buttonVariants = cva(
345
- "inline-flex items-center justify-center gap-2 rounded-md font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none active:scale-[0.98] select-none",
346
- {
347
- variants: {
348
- variant: {
349
- // Core variants using Versaur color system
350
- primary: "bg-primary text-white hover:bg-primary/90 focus-visible:ring-primary-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
351
- secondary: "bg-secondary text-white hover:bg-secondary/90 focus-visible:ring-secondary-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
352
- tertiary: "bg-tertiary text-white hover:bg-tertiary/90 focus-visible:ring-tertiary-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
353
- ghost: "bg-white text-foreground hover:bg-ghost-soft focus-visible:ring-ghost-soft focus-visible:ring-offset-white",
354
- neutral: "bg-neutral text-foreground border border-border hover:bg-neutral/80 focus-visible:ring-foreground-soft focus-visible:ring-offset-white shadow-sm",
355
- // Outline variants
356
- "primary-outline": "border border-primary text-primary bg-white hover:bg-primary hover:text-white focus-visible:ring-primary-soft focus-visible:ring-offset-white transition-all",
357
- "secondary-outline": "border border-secondary text-secondary bg-white hover:bg-secondary hover:text-white focus-visible:ring-secondary-soft focus-visible:ring-offset-white transition-all",
358
- "tertiary-outline": "border border-tertiary text-tertiary bg-white hover:bg-tertiary hover:text-white focus-visible:ring-tertiary-soft focus-visible:ring-offset-white transition-all",
359
- "ghost-outline": "border border-ghost text-ghost bg-white hover:bg-ghost hover:text-white focus-visible:ring-ghost-soft focus-visible:ring-offset-white transition-all",
360
- "neutral-outline": "border border-neutral text-foreground bg-white hover:bg-neutral hover:text-foreground focus-visible:ring-foreground-soft focus-visible:ring-offset-white transition-all",
361
- // Ghost variants (subtle)
362
- "primary-ghost": "text-primary bg-white hover:bg-primary-light focus-visible:ring-primary-light focus-visible:ring-offset-white",
363
- "secondary-ghost": "text-secondary bg-white hover:bg-secondary-light focus-visible:ring-secondary-light focus-visible:ring-offset-white",
364
- "tertiary-ghost": "text-tertiary bg-white hover:bg-tertiary-light focus-visible:ring-tertiary-light focus-visible:ring-offset-white",
365
- "neutral-ghost": "text-foreground bg-white hover:bg-neutral/70 focus-visible:ring-foreground-soft focus-visible:ring-offset-white",
366
- // Semantic variants
367
- success: "bg-success text-white hover:bg-success/90 focus-visible:ring-success-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
368
- "success-outline": "border border-success text-success bg-white hover:bg-success hover:text-white focus-visible:ring-success-soft focus-visible:ring-offset-white transition-all",
369
- "success-ghost": "text-success bg-white hover:bg-success-light focus-visible:ring-success-light focus-visible:ring-offset-white",
370
- info: "bg-info text-white hover:bg-info/90 focus-visible:ring-info-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
371
- "info-outline": "border border-info text-info bg-white hover:bg-info hover:text-white focus-visible:ring-info-soft focus-visible:ring-offset-white transition-all",
372
- "info-ghost": "text-info bg-white hover:bg-info-light focus-visible:ring-info-light focus-visible:ring-offset-white",
373
- warning: "bg-warning text-white hover:bg-warning/90 focus-visible:ring-warning-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
374
- "warning-outline": "border border-warning text-warning bg-white hover:bg-warning hover:text-white focus-visible:ring-warning-soft focus-visible:ring-offset-white transition-all",
375
- "warning-ghost": "text-warning bg-white hover:bg-warning-light focus-visible:ring-warning-light focus-visible:ring-offset-white",
376
- danger: "bg-danger text-white hover:bg-danger/90 focus-visible:ring-danger-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md",
377
- "danger-outline": "border border-danger text-danger bg-white hover:bg-danger hover:text-white focus-visible:ring-danger-soft focus-visible:ring-offset-white transition-all",
378
- "danger-ghost": "text-danger bg-white hover:bg-danger-light focus-visible:ring-danger-light focus-visible:ring-offset-white",
379
- // Utility variants
380
- outline: "border border-border text-foreground bg-white hover:bg-accent-soft focus-visible:ring-accent-soft focus-visible:ring-offset-white transition-all",
381
- destructive: "bg-danger text-white hover:bg-danger/90 focus-visible:ring-danger-soft focus-visible:ring-offset-white shadow-sm hover:shadow-md"
382
- },
383
- size: {
384
- sm: "h-8 px-3 text-sm min-w-[2.25rem]",
385
- md: "h-10 px-4 text-sm min-w-[2.5rem]",
386
- lg: "h-12 px-8 text-lg min-w-[2.75rem]"
387
- }
388
- },
389
- defaultVariants: {
390
- variant: "primary",
391
- size: "md"
392
- }
393
- }
394
- ), Button = React__default.forwardRef(
395
- function r({
396
- className: e,
397
- variant: t = "primary",
398
- size: i = "md",
399
- disabled: l = !1,
400
- type: n = "button",
401
- children: a,
402
- ...c
403
- }, f) {
404
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
405
- "button",
406
- {
407
- ref: f,
408
- type: n,
409
- className: cn(buttonVariants({ variant: t, size: i }), e),
410
- disabled: l,
411
- "aria-disabled": l,
412
- inert: l ? !0 : void 0,
413
- ...c,
414
- children: a
415
- }
416
- );
417
- }
418
- ), textVariants = cva("", {
419
- variants: {
420
- color: {
421
- primary: "text-primary",
422
- secondary: "text-secondary",
423
- tertiary: "text-tertiary",
424
- ghost: "text-ghost",
425
- neutral: "text-ghost",
426
- success: "text-success",
427
- info: "text-info",
428
- warning: "text-warning",
429
- danger: "text-danger",
430
- inherit: "",
431
- gray: "text-gray-500",
432
- black: "text-black",
433
- white: "text-white"
434
- },
435
- hasUnderline: {
436
- true: "underline",
437
- false: ""
438
- },
439
- isCapitalize: {
440
- true: "capitalize",
441
- false: ""
442
- },
443
- align: {
444
- left: "text-left",
445
- center: "text-center",
446
- right: "text-right",
447
- justify: "text-justify"
448
- },
449
- italic: {
450
- true: "italic",
451
- false: ""
452
- },
453
- clamp: {
454
- 1: "line-clamp-1",
455
- 2: "line-clamp-2",
456
- 3: "line-clamp-3",
457
- 4: "line-clamp-4",
458
- 5: "line-clamp-5",
459
- none: ""
460
- },
461
- ellipsis: {
462
- true: "truncate",
463
- false: ""
464
- },
465
- as: {
466
- h1: "font-bold text-4xl leading-loose",
467
- h2: "font-semibold text-3xl leading-relaxed",
468
- h3: "font-medium text-2xl leading-relaxed",
469
- h4: "font-bold text-xl leading-normal",
470
- h5: "font-semibold text-lg leading-normal",
471
- h6: "font-medium text-base leading-normal",
472
- p: "font-normal text-base leading-normal",
473
- span: "font-normal text-base leading-normal",
474
- label: "font-normal text-xs leading-normal"
475
- }
476
- },
477
- defaultVariants: {
478
- color: "neutral",
479
- hasUnderline: !1,
480
- isCapitalize: !1,
481
- align: "left",
482
- italic: !1,
483
- clamp: "none",
484
- ellipsis: !1,
485
- as: "span"
486
- }
487
- }), Text = forwardRef(
488
- ({
489
- as: r = "span",
490
- color: e = "ghost",
491
- hasUnderline: t = !1,
492
- isCapitalize: i = !1,
493
- align: l = "left",
494
- italic: n = !1,
495
- clamp: a = "none",
496
- ellipsis: c = !1,
497
- fontSize: f,
498
- fontWeight: d,
499
- className: w,
500
- children: v,
501
- ...h
502
- }, p) => {
503
- const u = [
504
- "h1",
505
- "h2",
506
- "h3",
507
- "h4",
508
- "h5",
509
- "h6",
510
- "p",
511
- "span",
512
- "label"
513
- ].includes(r) ? r : "span", b = f ? `text-${f}` : "", m = d ? `font-${d}` : "";
514
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
515
- r,
516
- {
517
- ref: p,
518
- className: cn(
519
- textVariants({
520
- color: e,
521
- hasUnderline: t,
522
- isCapitalize: i,
523
- align: l,
524
- italic: n,
525
- clamp: a,
526
- ellipsis: c,
527
- // @ts-expect-error - `as` is not a valid variant
528
- as: u
529
- }),
530
- b,
531
- m,
532
- w
533
- ),
534
- ...h,
535
- children: v
536
- }
537
- );
538
- }
539
- ), CalendarContext = createContext(null);
540
- function useCalendarContext() {
541
- const r = useContext(CalendarContext);
542
- if (!r)
543
- throw new Error(
544
- "useCalendarContext must be used within CalendarContext.Provider"
545
- );
546
- return r;
547
- }
548
- const CalendarHeader = () => {
549
- const { value: r, year: e, month: t, setMonth: i } = useCalendarContext();
550
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between px-4 pt-4 pb-2", children: [
551
- /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fontSize: "base", fontWeight: "semibold", className: "ml-2", children: r ? r instanceof Date ? r.toLocaleDateString(void 0, {
552
- year: "numeric",
553
- month: "long"
554
- }) : Array.isArray(r) && r[0] ? r[0].toLocaleDateString(void 0, {
555
- year: "numeric",
556
- month: "long"
557
- }) : `${e} ${new Date(e, t).toLocaleString(void 0, { month: "long" })}` : `${e} ${new Date(e, t).toLocaleString(void 0, { month: "long" })}` }),
558
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
559
- /* @__PURE__ */ jsxRuntimeExports.jsx(
560
- ButtonIcon,
561
- {
562
- as: ChevronLeft,
563
- variant: "ghost",
564
- size: "sm",
565
- "aria-label": "Previous month",
566
- onClick: () => i(t === 0 ? 11 : t - 1)
567
- }
568
- ),
569
- /* @__PURE__ */ jsxRuntimeExports.jsx(
570
- ButtonIcon,
571
- {
572
- as: ChevronRight,
573
- variant: "ghost",
574
- size: "sm",
575
- "aria-label": "Next month",
576
- onClick: () => i(t === 11 ? 0 : t + 1)
577
- }
578
- )
579
- ] })
580
- ] });
581
- }, CalendarWeekdays = () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-7 px-4 text-ghost-500 mb-3", children: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((r) => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fontSize: "xs", color: "ghost", align: "center", children: r }, r)) }), CalendarDaysSingle = () => {
582
- const r = useCalendarContext(), { year: e, month: t, value: i, onChange: l, setMonth: n, setYear: a } = r, c = (o, x) => new Date(o, x + 1, 0).getDate(), d = ((o, x) => new Date(o, x, 1).getDay())(e, t), w = c(e, t), v = t - 1 < 0 ? 11 : t - 1, h = t === 0 ? e - 1 : e, p = c(e, v), y = t === 11 ? 0 : t + 1, u = t === 11 ? e + 1 : e, b = [];
583
- for (let o = 0; o < d; o++) {
584
- const x = p - d + o + 1;
585
- b.push(
586
- /* @__PURE__ */ jsxRuntimeExports.jsx(
587
- ButtonIcon,
588
- {
589
- as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { as: "span", fontSize: "sm", color: "tertiary", children: x }),
590
- size: "sm",
591
- "aria-label": "Previous month day",
592
- variant: "ghost",
593
- onClick: () => {
594
- l?.(new Date(h, v, x)), n(v), a(h);
595
- }
596
- },
597
- "prev-" + o
598
- )
599
- );
600
- }
601
- for (let o = 1; o <= w; o++) {
602
- const x = i instanceof Date && i.getFullYear() === e && i.getMonth() === t && i.getDate() === o;
603
- b.push(
604
- /* @__PURE__ */ jsxRuntimeExports.jsx(
605
- ButtonIcon,
606
- {
607
- as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
608
- Text,
609
- {
610
- as: "span",
611
- fontSize: "sm",
612
- color: x ? "inherit" : "ghost",
613
- className: x ? "bg-primary text-white rounded-full" : "",
614
- children: o
615
- }
616
- ),
617
- variant: x ? "primary" : "ghost",
618
- size: "sm",
619
- "aria-label": `Select ${e}-${t + 1}-${o}`,
620
- "aria-current": x ? "date" : void 0,
621
- onClick: () => {
622
- l?.(new Date(e, t, o));
623
- }
624
- },
625
- o
626
- )
627
- );
628
- }
629
- const m = d + w;
630
- for (let o = 0; o < (m % 7 === 0 ? 0 : 7 - m % 7); o++)
631
- b.push(
632
- /* @__PURE__ */ jsxRuntimeExports.jsx(
633
- ButtonIcon,
634
- {
635
- as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { as: "span", fontSize: "sm", color: "tertiary", children: o + 1 }),
636
- size: "sm",
637
- "aria-label": "Next month day",
638
- variant: "ghost",
639
- onClick: () => {
640
- l?.(new Date(u, y, o + 1)), n(y), a(u);
641
- }
642
- },
643
- "next-" + o
644
- )
645
- );
646
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-7 gap-2 px-4 pb-4", children: b });
647
- }, CalendarDaysRange = () => {
648
- const { year: r, month: e, value: t, onChange: i, setMonth: l, setYear: n } = useCalendarContext(), a = (s, g) => new Date(s, g + 1, 0).getDate(), f = ((s, g) => new Date(s, g, 1).getDay())(r, e), d = a(r, e), w = e - 1 < 0 ? 11 : e - 1, v = e === 0 ? r - 1 : r, h = a(r, w), p = e === 11 ? 0 : e + 1, y = e === 11 ? r + 1 : r, u = [], b = () => {
649
- if (!Array.isArray(t)) return [null, null];
650
- const [s, g] = t;
651
- return !s && !g ? [null, null] : s && g ? s <= g ? [s, g] : [g, s] : [s, g];
652
- }, [m, o] = b(), x = (s) => {
653
- if (!m || !o) return !1;
654
- const g = new Date(r, e, s);
655
- return g >= m && g <= o;
656
- }, I = (s) => m ? m.getFullYear() === r && m.getMonth() === e && m.getDate() === s : !1, B = (s) => o ? o.getFullYear() === r && o.getMonth() === e && o.getDate() === s : !1;
657
- for (let s = 0; s < f; s++) {
658
- const g = h - f + s + 1;
659
- u.push(
660
- /* @__PURE__ */ jsxRuntimeExports.jsx(
661
- ButtonIcon,
662
- {
663
- as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { as: "span", fontSize: "sm", color: "tertiary", children: g }),
664
- size: "sm",
665
- "aria-label": "Previous month day",
666
- variant: "ghost",
667
- onClick: () => {
668
- i?.([null, null]), l(w), n(v);
669
- }
670
- },
671
- "prev-" + s
672
- )
673
- );
674
- }
675
- for (let s = 1; s <= d; s++) {
676
- const g = x(s), R = I(s), E = B(s);
677
- u.push(
678
- /* @__PURE__ */ jsxRuntimeExports.jsx(
679
- ButtonIcon,
680
- {
681
- as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
682
- Text,
683
- {
684
- as: "span",
685
- fontSize: "sm",
686
- color: g || R || E ? "inherit" : "ghost",
687
- className: cn(
688
- g && " bg-primary text-white",
689
- R && "rounded-l-full bg-primary text-white",
690
- E && "rounded-r-full bg-primary text-white"
691
- ),
692
- children: s
693
- }
694
- ),
695
- variant: R || E || g ? "primary" : "ghost",
696
- size: "sm",
697
- "aria-label": `Select ${r}-${e + 1}-${s}`,
698
- "aria-current": R || E ? "date" : void 0,
699
- onClick: () => {
700
- if (!Array.isArray(t) || !t[0] || t[0] && t[1])
701
- i?.([new Date(r, e, s), null]);
702
- else if (t[0] && !t[1]) {
703
- const j = t[0], C = new Date(r, e, s);
704
- j.getTime() === C.getTime() ? i?.([j, C]) : i?.(j < C ? [j, C] : [C, j]);
705
- }
706
- }
707
- },
708
- s
709
- )
710
- );
711
- }
712
- const D = f + d;
713
- for (let s = 0; s < (D % 7 === 0 ? 0 : 7 - D % 7); s++)
714
- u.push(
715
- /* @__PURE__ */ jsxRuntimeExports.jsx(
716
- ButtonIcon,
717
- {
718
- as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { as: "span", fontSize: "sm", color: "tertiary", children: s + 1 }),
719
- size: "sm",
720
- "aria-label": "Next month day",
721
- variant: "ghost",
722
- onClick: () => {
723
- i?.([null, null]), l(p), n(y);
724
- }
725
- },
726
- "next-" + s
727
- )
728
- );
729
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-7 gap-2 px-4 pb-4", children: u });
730
- }, CalendarDays = () => {
731
- const { type: r } = useCalendarContext();
732
- return r === "range" ? /* @__PURE__ */ jsxRuntimeExports.jsx(CalendarDaysRange, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(CalendarDaysSingle, {});
733
- };
734
- function useCalendar({
735
- value: r,
736
- type: e,
737
- onChange: t,
738
- initialYear: i,
739
- initialMonth: l
740
- }) {
741
- const [n, a] = useState(l), [c, f] = useState(i), [d, w] = useState([
742
- null,
743
- null
744
- ]);
745
- let v = r;
746
- e === "range" && !r && (v = d);
747
- const h = useCallback(() => {
748
- const u = n === 0 ? 11 : n - 1, b = n === 0 ? c - 1 : c;
749
- a(u), f(b), e === "single" && t?.(new Date(b, u, 1));
750
- }, [n, c, e, t]), p = useCallback(() => {
751
- const u = n === 11 ? 0 : n + 1, b = n === 11 ? c + 1 : c;
752
- a(u), f(b), e === "single" && t?.(new Date(b, u, 1));
753
- }, [n, c, e, t]), y = useCallback(
754
- (u) => {
755
- e === "single" ? t?.(u) : e === "range" && (w(u), t?.(u));
756
- },
757
- [e, t]
758
- );
759
- return {
760
- year: c,
761
- month: n,
762
- value: v,
763
- setMonth: a,
764
- setYear: f,
765
- onChange: y,
766
- handlePrevMonth: h,
767
- handleNextMonth: p
768
- };
769
- }
770
- const CalendarRoot = ({
771
- value: r,
772
- onChange: e,
773
- className: t,
774
- type: i = "single",
775
- ...l
776
- }) => {
777
- const n = /* @__PURE__ */ new Date(), a = useCalendar({
778
- value: r,
779
- onChange: e,
780
- type: i,
781
- initialYear: n.getFullYear(),
782
- initialMonth: n.getMonth()
783
- });
784
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
785
- CalendarContext.Provider,
786
- {
787
- value: {
788
- year: a.year,
789
- month: a.month,
790
- value: a.value,
791
- type: i,
792
- setMonth: a.setMonth,
793
- setYear: a.setYear,
794
- onChange: a.onChange
795
- },
796
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("select-none", t), ...l, children: [
797
- /* @__PURE__ */ jsxRuntimeExports.jsx(CalendarHeader, {}),
798
- /* @__PURE__ */ jsxRuntimeExports.jsx(CalendarWeekdays, {}),
799
- /* @__PURE__ */ jsxRuntimeExports.jsx(CalendarDays, {})
800
- ] })
801
- }
802
- );
803
- }, Calendar = Object.assign(CalendarRoot, {});
804
- export {
805
- Button as B,
806
- Calculator as C,
807
- Icon as I,
808
- Text as T,
809
- ButtonIcon as a,
810
- Calendar as b
811
- };