@grupor5/raya 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -4
- package/dist/atoms/avatar/index.d.mts +12 -0
- package/dist/atoms/avatar/index.d.ts +12 -0
- package/dist/atoms/avatar/index.js +99 -0
- package/dist/atoms/avatar/index.mjs +76 -0
- package/dist/atoms/badge/index.d.mts +16 -0
- package/dist/atoms/badge/index.d.ts +16 -0
- package/dist/atoms/badge/index.js +149 -0
- package/dist/atoms/badge/index.mjs +146 -0
- package/dist/atoms/button/index.d.mts +11 -0
- package/dist/atoms/button/index.d.ts +11 -0
- package/dist/atoms/button/index.js +307 -0
- package/dist/atoms/button/index.mjs +301 -0
- package/dist/atoms/checkbox/index.d.mts +6 -0
- package/dist/atoms/checkbox/index.d.ts +6 -0
- package/dist/atoms/checkbox/index.js +98 -0
- package/dist/atoms/checkbox/index.mjs +75 -0
- package/dist/atoms/input/index.d.mts +12 -0
- package/dist/atoms/input/index.d.ts +12 -0
- package/dist/atoms/input/index.js +104 -0
- package/dist/atoms/input/index.mjs +82 -0
- package/dist/atoms/label/index.d.mts +8 -0
- package/dist/atoms/label/index.d.ts +8 -0
- package/dist/atoms/label/index.js +77 -0
- package/dist/atoms/label/index.mjs +54 -0
- package/dist/atoms/radio/index.d.mts +7 -0
- package/dist/atoms/radio/index.d.ts +7 -0
- package/dist/atoms/radio/index.js +97 -0
- package/dist/atoms/radio/index.mjs +73 -0
- package/dist/atoms/switch/index.d.mts +6 -0
- package/dist/atoms/switch/index.d.ts +6 -0
- package/dist/atoms/switch/index.js +97 -0
- package/dist/atoms/switch/index.mjs +74 -0
- package/dist/atoms/tag/index.d.mts +14 -0
- package/dist/atoms/tag/index.d.ts +14 -0
- package/dist/atoms/tag/index.js +128 -0
- package/dist/atoms/tag/index.mjs +122 -0
- package/dist/atoms/textarea/index.d.mts +11 -0
- package/dist/atoms/textarea/index.d.ts +11 -0
- package/dist/atoms/textarea/index.js +125 -0
- package/dist/atoms/textarea/index.mjs +103 -0
- package/dist/atoms/typography/index.d.mts +20 -0
- package/dist/atoms/typography/index.d.ts +20 -0
- package/dist/atoms/typography/index.js +140 -0
- package/dist/atoms/typography/index.mjs +115 -0
- package/dist/hooks/index.d.mts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +17 -0
- package/dist/hooks/index.mjs +15 -0
- package/dist/hooks/use-pagination.d.mts +10 -0
- package/dist/hooks/use-pagination.d.ts +10 -0
- package/dist/hooks/use-pagination.js +54 -0
- package/dist/hooks/use-pagination.mjs +51 -0
- package/dist/hooks/use-toast.d.mts +2 -0
- package/dist/hooks/use-toast.d.ts +2 -0
- package/dist/hooks/use-toast.js +2 -0
- package/dist/hooks/use-toast.mjs +1 -0
- package/dist/hooks/useModal.d.mts +7 -0
- package/dist/hooks/useModal.d.ts +7 -0
- package/dist/hooks/useModal.js +17 -0
- package/dist/hooks/useModal.mjs +15 -0
- package/dist/index.d.mts +50 -1298
- package/dist/index.d.ts +50 -1298
- package/dist/molecules/accordion/index.d.mts +17 -0
- package/dist/molecules/accordion/index.d.ts +17 -0
- package/dist/molecules/accordion/index.js +154 -0
- package/dist/molecules/accordion/index.mjs +128 -0
- package/dist/molecules/alert/index.d.mts +14 -0
- package/dist/molecules/alert/index.d.ts +14 -0
- package/dist/molecules/alert/index.js +425 -0
- package/dist/molecules/alert/index.mjs +402 -0
- package/dist/molecules/card/index.d.mts +10 -0
- package/dist/molecules/card/index.d.ts +10 -0
- package/dist/molecules/card/index.js +128 -0
- package/dist/molecules/card/index.mjs +101 -0
- package/dist/molecules/chart/index.d.mts +80 -0
- package/dist/molecules/chart/index.d.ts +80 -0
- package/dist/molecules/chart/index.js +300 -0
- package/dist/molecules/chart/index.mjs +272 -0
- package/dist/molecules/data-table/index.d.mts +57 -0
- package/dist/molecules/data-table/index.d.ts +57 -0
- package/dist/molecules/data-table/index.js +1456 -0
- package/dist/molecules/data-table/index.mjs +1430 -0
- package/dist/molecules/date-picker/index.d.mts +12 -0
- package/dist/molecules/date-picker/index.d.ts +12 -0
- package/dist/molecules/date-picker/index.js +756 -0
- package/dist/molecules/date-picker/index.mjs +734 -0
- package/dist/molecules/dropdown/index.d.mts +21 -0
- package/dist/molecules/dropdown/index.d.ts +21 -0
- package/dist/molecules/dropdown/index.js +221 -0
- package/dist/molecules/dropdown/index.mjs +198 -0
- package/dist/molecules/form/index.d.mts +19 -0
- package/dist/molecules/form/index.d.ts +19 -0
- package/dist/molecules/form/index.js +139 -0
- package/dist/molecules/form/index.mjs +114 -0
- package/dist/molecules/pagination/index.d.mts +15 -0
- package/dist/molecules/pagination/index.d.ts +15 -0
- package/dist/molecules/pagination/index.js +605 -0
- package/dist/molecules/pagination/index.mjs +583 -0
- package/dist/molecules/progress-bar/index.d.mts +15 -0
- package/dist/molecules/progress-bar/index.d.ts +15 -0
- package/dist/molecules/progress-bar/index.js +166 -0
- package/dist/molecules/progress-bar/index.mjs +144 -0
- package/dist/molecules/select/index.d.mts +15 -0
- package/dist/molecules/select/index.d.ts +15 -0
- package/dist/molecules/select/index.js +201 -0
- package/dist/molecules/select/index.mjs +169 -0
- package/dist/molecules/stepper/index.d.mts +67 -0
- package/dist/molecules/stepper/index.d.ts +67 -0
- package/dist/molecules/stepper/index.js +287 -0
- package/dist/molecules/stepper/index.mjs +260 -0
- package/dist/molecules/tabs/index.d.mts +9 -0
- package/dist/molecules/tabs/index.d.ts +9 -0
- package/dist/molecules/tabs/index.js +112 -0
- package/dist/molecules/tabs/index.mjs +86 -0
- package/dist/tokens/badge.d.mts +39 -0
- package/dist/tokens/badge.d.ts +39 -0
- package/dist/tokens/badge.js +61 -0
- package/dist/tokens/badge.mjs +59 -0
- package/dist/tokens/buttons.d.mts +277 -0
- package/dist/tokens/buttons.d.ts +277 -0
- package/dist/tokens/buttons.js +191 -0
- package/dist/tokens/buttons.mjs +173 -0
- package/dist/tokens/colors.d.mts +65 -0
- package/dist/tokens/colors.d.ts +65 -0
- package/dist/tokens/colors.js +68 -0
- package/dist/tokens/colors.mjs +66 -0
- package/dist/tokens/effects.d.mts +124 -0
- package/dist/tokens/effects.d.ts +124 -0
- package/dist/tokens/effects.js +130 -0
- package/dist/tokens/effects.mjs +115 -0
- package/dist/tokens/grids.d.mts +331 -0
- package/dist/tokens/grids.d.ts +331 -0
- package/dist/tokens/grids.js +305 -0
- package/dist/tokens/grids.mjs +292 -0
- package/dist/tokens/icons.d.mts +134 -0
- package/dist/tokens/icons.d.ts +134 -0
- package/dist/tokens/icons.js +108 -0
- package/dist/tokens/icons.mjs +97 -0
- package/dist/tokens/index.d.mts +6 -0
- package/dist/tokens/index.d.ts +6 -0
- package/dist/tokens/index.js +775 -0
- package/dist/tokens/index.mjs +743 -0
- package/dist/tokens/progress-bar.d.mts +31 -0
- package/dist/tokens/progress-bar.d.ts +31 -0
- package/dist/tokens/progress-bar.js +70 -0
- package/dist/tokens/progress-bar.mjs +68 -0
- package/dist/tokens/spacing.d.mts +90 -0
- package/dist/tokens/spacing.d.ts +90 -0
- package/dist/tokens/spacing.js +120 -0
- package/dist/tokens/spacing.mjs +109 -0
- package/dist/tokens/stroke.d.mts +292 -0
- package/dist/tokens/stroke.d.ts +292 -0
- package/dist/tokens/stroke.js +202 -0
- package/dist/tokens/stroke.mjs +186 -0
- package/dist/tokens/tab.d.mts +31 -0
- package/dist/tokens/tab.d.ts +31 -0
- package/dist/tokens/tab.js +48 -0
- package/dist/tokens/tab.mjs +46 -0
- package/dist/tokens/tag.d.mts +53 -0
- package/dist/tokens/tag.d.ts +53 -0
- package/dist/tokens/tag.js +80 -0
- package/dist/tokens/tag.mjs +78 -0
- package/dist/tokens/typography.d.mts +394 -0
- package/dist/tokens/typography.d.ts +394 -0
- package/dist/tokens/typography.js +302 -0
- package/dist/tokens/typography.mjs +292 -0
- package/dist/utils/classNames.d.mts +3 -0
- package/dist/utils/classNames.d.ts +3 -0
- package/dist/utils/classNames.js +8 -0
- package/dist/utils/classNames.mjs +6 -0
- package/dist/utils/cn.d.mts +5 -0
- package/dist/utils/cn.d.ts +5 -0
- package/dist/utils/cn.js +11 -0
- package/dist/utils/cn.mjs +9 -0
- package/dist/utils/index.d.mts +3 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +15 -0
- package/dist/utils/index.mjs +12 -0
- package/package.json +34 -1
|
@@ -0,0 +1,734 @@
|
|
|
1
|
+
import * as React2 from 'react';
|
|
2
|
+
import React2__default, { forwardRef, useMemo } from 'react';
|
|
3
|
+
import { format, subDays, endOfMonth, startOfMonth, endOfYear, startOfYear, subMonths, subYears, isEqual, addYears } from 'date-fns';
|
|
4
|
+
import { CalendarIcon } from '@grupor5/raya-icons';
|
|
5
|
+
import { clsx } from 'clsx';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
8
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
import { ChevronRight, Check, Circle, ChevronLeftIcon, ChevronRightIcon } from 'lucide-react';
|
|
10
|
+
import { DayPicker, useDayPicker } from 'react-day-picker';
|
|
11
|
+
import { es } from 'date-fns/locale';
|
|
12
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
13
|
+
|
|
14
|
+
var __defProp = Object.defineProperty;
|
|
15
|
+
var __defProps = Object.defineProperties;
|
|
16
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
17
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
18
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
19
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
20
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
21
|
+
var __spreadValues = (a, b) => {
|
|
22
|
+
for (var prop in b || (b = {}))
|
|
23
|
+
if (__hasOwnProp.call(b, prop))
|
|
24
|
+
__defNormalProp(a, prop, b[prop]);
|
|
25
|
+
if (__getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
27
|
+
if (__propIsEnum.call(b, prop))
|
|
28
|
+
__defNormalProp(a, prop, b[prop]);
|
|
29
|
+
}
|
|
30
|
+
return a;
|
|
31
|
+
};
|
|
32
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
33
|
+
var __objRest = (source, exclude) => {
|
|
34
|
+
var target = {};
|
|
35
|
+
for (var prop in source)
|
|
36
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
37
|
+
target[prop] = source[prop];
|
|
38
|
+
if (source != null && __getOwnPropSymbols)
|
|
39
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
40
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
41
|
+
target[prop] = source[prop];
|
|
42
|
+
}
|
|
43
|
+
return target;
|
|
44
|
+
};
|
|
45
|
+
function cn(...inputs) {
|
|
46
|
+
return twMerge(clsx(inputs));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/tokens/buttons.ts
|
|
50
|
+
var buttonSizeClasses = {
|
|
51
|
+
sm: {
|
|
52
|
+
base: "h-8 px-2 py-1 text-sm rounded-[10px]",
|
|
53
|
+
icon: "h-8 w-8 rounded-[10px]",
|
|
54
|
+
iconSize: "w-4 h-4"
|
|
55
|
+
},
|
|
56
|
+
md: {
|
|
57
|
+
base: "h-10 px-4 py-2 text-base rounded-xl",
|
|
58
|
+
icon: "h-10 w-10 rounded-xl",
|
|
59
|
+
iconSize: "w-5 h-5"
|
|
60
|
+
},
|
|
61
|
+
lg: {
|
|
62
|
+
base: "h-12 px-6 py-3 text-lg rounded-2xl",
|
|
63
|
+
icon: "h-12 w-12 rounded-2xl",
|
|
64
|
+
iconSize: "w-[22px] h-[22px]"
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var buttonVariantClasses = {
|
|
68
|
+
// Primary variants
|
|
69
|
+
primary: {
|
|
70
|
+
primary: "bg-primary text-primary-foreground shadow-sm hover:bg-primary/90 active:bg-[hsl(var(--primary-pressed))] disabled:bg-neutral-300 disabled:text-neutral-500",
|
|
71
|
+
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/90 active:bg-secondary/80 disabled:bg-neutral-300 disabled:text-neutral-500",
|
|
72
|
+
success: "bg-emerald-600 text-white shadow-sm hover:bg-emerald-700 active:bg-emerald-800 disabled:bg-neutral-300 disabled:text-neutral-500",
|
|
73
|
+
warning: "bg-amber-600 text-white shadow-sm hover:bg-amber-700 active:bg-amber-800 disabled:bg-neutral-300 disabled:text-neutral-500",
|
|
74
|
+
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/80 disabled:bg-neutral-300 disabled:text-neutral-500",
|
|
75
|
+
neutral: "bg-neutral-700 text-white shadow-sm hover:bg-neutral-800 active:bg-neutral-900 disabled:bg-neutral-300 disabled:text-neutral-500"
|
|
76
|
+
},
|
|
77
|
+
// Secondary variants (outlined)
|
|
78
|
+
secondary: {
|
|
79
|
+
primary: "border border-primary text-primary bg-transparent hover:bg-primary/10 active:bg-primary/20 disabled:border-neutral-300 disabled:text-neutral-500 disabled:bg-transparent",
|
|
80
|
+
secondary: "border border-secondary text-secondary bg-transparent hover:bg-secondary/10 active:bg-secondary/20 disabled:border-neutral-300 disabled:text-neutral-500 disabled:bg-transparent",
|
|
81
|
+
success: "border border-emerald-600 text-emerald-600 bg-transparent hover:bg-emerald-50 active:bg-emerald-100 disabled:border-neutral-300 disabled:text-neutral-500 disabled:bg-transparent",
|
|
82
|
+
warning: "border border-amber-600 text-amber-600 bg-transparent hover:bg-amber-50 active:bg-amber-100 disabled:border-neutral-300 disabled:text-neutral-500 disabled:bg-transparent",
|
|
83
|
+
destructive: "border border-destructive text-destructive bg-transparent hover:bg-destructive/10 active:bg-destructive/20 disabled:border-neutral-300 disabled:text-neutral-500 disabled:bg-transparent",
|
|
84
|
+
neutral: "border border-neutral-700 text-neutral-700 bg-transparent hover:bg-neutral-50 active:bg-neutral-100 disabled:border-neutral-300 disabled:text-neutral-500 disabled:bg-transparent"
|
|
85
|
+
},
|
|
86
|
+
// Ghost variants (text only)
|
|
87
|
+
ghost: {
|
|
88
|
+
primary: "text-primary bg-transparent hover:bg-primary/10 active:bg-primary/20 disabled:text-neutral-500 disabled:bg-transparent",
|
|
89
|
+
secondary: "text-secondary bg-transparent hover:bg-secondary/10 active:bg-secondary/20 disabled:text-neutral-500 disabled:bg-transparent",
|
|
90
|
+
success: "text-emerald-600 bg-transparent hover:bg-emerald-50 active:bg-emerald-100 disabled:text-neutral-500 disabled:bg-transparent",
|
|
91
|
+
warning: "text-amber-600 bg-transparent hover:bg-amber-50 active:bg-amber-100 disabled:text-neutral-500 disabled:bg-transparent",
|
|
92
|
+
destructive: "text-destructive bg-transparent hover:bg-destructive/10 active:bg-destructive/20 disabled:text-neutral-500 disabled:bg-transparent",
|
|
93
|
+
neutral: "text-neutral-700 bg-transparent hover:bg-neutral-100 active:bg-neutral-200 disabled:text-neutral-500 disabled:bg-transparent"
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var buttonBaseClasses = "inline-flex items-center justify-center gap-2 whitespace-nowrap font-regular transition-all duration-200 focus-visible:outline-none disabled:pointer-events-none disabled:cursor-not-allowed focus-visible:border-2 focus-visible:border-[--stroke-color-focus-border]";
|
|
97
|
+
var buttonLoadingClasses = {
|
|
98
|
+
spinner: "animate-spin",
|
|
99
|
+
container: "flex items-center justify-center gap-2",
|
|
100
|
+
text: "opacity-70"
|
|
101
|
+
};
|
|
102
|
+
var getButtonSizeClasses = (size, isIcon) => {
|
|
103
|
+
return isIcon ? buttonSizeClasses[size].icon : buttonSizeClasses[size].base;
|
|
104
|
+
};
|
|
105
|
+
var getButtonVariantClasses = (variant, color) => {
|
|
106
|
+
var _a;
|
|
107
|
+
if (variant === "icon") {
|
|
108
|
+
return buttonVariantClasses.ghost[color];
|
|
109
|
+
}
|
|
110
|
+
return ((_a = buttonVariantClasses[variant]) == null ? void 0 : _a[color]) || "";
|
|
111
|
+
};
|
|
112
|
+
var getButtonIconSize = (size) => {
|
|
113
|
+
return buttonSizeClasses[size].iconSize;
|
|
114
|
+
};
|
|
115
|
+
var defaultButtonConfig = {
|
|
116
|
+
variant: "primary",
|
|
117
|
+
size: "md",
|
|
118
|
+
color: "primary",
|
|
119
|
+
type: "button"
|
|
120
|
+
};
|
|
121
|
+
var LoadingSpinner = ({
|
|
122
|
+
size,
|
|
123
|
+
className
|
|
124
|
+
}) => {
|
|
125
|
+
const sizeClasses = {
|
|
126
|
+
sm: "w-4 h-4",
|
|
127
|
+
md: "w-5 h-5",
|
|
128
|
+
lg: "w-6 h-6"
|
|
129
|
+
};
|
|
130
|
+
return /* @__PURE__ */ jsx("div", { className: cn(buttonLoadingClasses.spinner, sizeClasses[size], className), children: /* @__PURE__ */ jsxs("svg", { fill: "none", viewBox: "0 0 24 24", className: "w-full h-full", children: [
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
"circle",
|
|
133
|
+
{
|
|
134
|
+
className: "opacity-25",
|
|
135
|
+
cx: "12",
|
|
136
|
+
cy: "12",
|
|
137
|
+
r: "10",
|
|
138
|
+
stroke: "currentColor"
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ jsx(
|
|
142
|
+
"path",
|
|
143
|
+
{
|
|
144
|
+
className: "opacity-75",
|
|
145
|
+
fill: "currentColor",
|
|
146
|
+
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"
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
] }) });
|
|
150
|
+
};
|
|
151
|
+
var Button = forwardRef((_a, ref) => {
|
|
152
|
+
var _b = _a, {
|
|
153
|
+
variant = defaultButtonConfig.variant,
|
|
154
|
+
size = defaultButtonConfig.size,
|
|
155
|
+
color = defaultButtonConfig.color,
|
|
156
|
+
disabled = false,
|
|
157
|
+
loading = false,
|
|
158
|
+
loadingText,
|
|
159
|
+
icon,
|
|
160
|
+
iconLeft,
|
|
161
|
+
iconRight,
|
|
162
|
+
className,
|
|
163
|
+
children,
|
|
164
|
+
type = defaultButtonConfig.type,
|
|
165
|
+
"aria-label": ariaLabel,
|
|
166
|
+
"aria-describedby": ariaDescribedBy,
|
|
167
|
+
asChild = false,
|
|
168
|
+
onClick
|
|
169
|
+
} = _b, props = __objRest(_b, [
|
|
170
|
+
"variant",
|
|
171
|
+
"size",
|
|
172
|
+
"color",
|
|
173
|
+
"disabled",
|
|
174
|
+
"loading",
|
|
175
|
+
"loadingText",
|
|
176
|
+
"icon",
|
|
177
|
+
"iconLeft",
|
|
178
|
+
"iconRight",
|
|
179
|
+
"className",
|
|
180
|
+
"children",
|
|
181
|
+
"type",
|
|
182
|
+
"aria-label",
|
|
183
|
+
"aria-describedby",
|
|
184
|
+
"asChild",
|
|
185
|
+
"onClick"
|
|
186
|
+
]);
|
|
187
|
+
const isIconOnly = variant === "icon" || !!(!children && (icon || iconLeft || iconRight));
|
|
188
|
+
const buttonClasses = useMemo(() => {
|
|
189
|
+
const sizeClasses = getButtonSizeClasses(size, isIconOnly);
|
|
190
|
+
const variantClasses = getButtonVariantClasses(variant, color);
|
|
191
|
+
return cn(
|
|
192
|
+
buttonBaseClasses,
|
|
193
|
+
sizeClasses,
|
|
194
|
+
variantClasses,
|
|
195
|
+
className
|
|
196
|
+
);
|
|
197
|
+
}, [variant, size, color, isIconOnly, className]);
|
|
198
|
+
const buttonContent = useMemo(() => {
|
|
199
|
+
if (loading) {
|
|
200
|
+
return /* @__PURE__ */ jsxs("div", { className: buttonLoadingClasses.container, children: [
|
|
201
|
+
/* @__PURE__ */ jsx(LoadingSpinner, { size }),
|
|
202
|
+
loadingText && /* @__PURE__ */ jsx("span", { className: buttonLoadingClasses.text, children: loadingText })
|
|
203
|
+
] });
|
|
204
|
+
}
|
|
205
|
+
const iconSizeClass = getButtonIconSize(size);
|
|
206
|
+
const renderIcon = (iconNode) => {
|
|
207
|
+
if (React2__default.isValidElement(iconNode)) {
|
|
208
|
+
return React2__default.cloneElement(iconNode, {
|
|
209
|
+
className: cn(iconSizeClass, iconNode.props.className),
|
|
210
|
+
"aria-hidden": true
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return iconNode;
|
|
214
|
+
};
|
|
215
|
+
if (isIconOnly) {
|
|
216
|
+
return renderIcon(icon || iconLeft || iconRight);
|
|
217
|
+
}
|
|
218
|
+
return /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center justify-center gap-2", children: [
|
|
219
|
+
iconLeft && renderIcon(iconLeft),
|
|
220
|
+
children && /* @__PURE__ */ jsx("span", { children }),
|
|
221
|
+
iconRight && renderIcon(iconRight)
|
|
222
|
+
] });
|
|
223
|
+
}, [loading, loadingText, isIconOnly, icon, iconLeft, iconRight, children, size]);
|
|
224
|
+
const accessibilityProps = useMemo(() => {
|
|
225
|
+
const props2 = {};
|
|
226
|
+
if (isIconOnly && !ariaLabel) {
|
|
227
|
+
console.warn("Icon-only buttons should have an aria-label for accessibility");
|
|
228
|
+
}
|
|
229
|
+
if (ariaLabel) {
|
|
230
|
+
props2["aria-label"] = ariaLabel;
|
|
231
|
+
}
|
|
232
|
+
if (ariaDescribedBy) {
|
|
233
|
+
props2["aria-describedby"] = ariaDescribedBy;
|
|
234
|
+
}
|
|
235
|
+
if (loading) {
|
|
236
|
+
props2["aria-busy"] = true;
|
|
237
|
+
props2["aria-disabled"] = true;
|
|
238
|
+
}
|
|
239
|
+
if (disabled || loading) {
|
|
240
|
+
props2["aria-disabled"] = true;
|
|
241
|
+
}
|
|
242
|
+
return props2;
|
|
243
|
+
}, [isIconOnly, ariaLabel, ariaDescribedBy, loading, disabled]);
|
|
244
|
+
const handleClick = (event) => {
|
|
245
|
+
if (disabled || loading) {
|
|
246
|
+
event.preventDefault();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
onClick == null ? void 0 : onClick(event);
|
|
250
|
+
};
|
|
251
|
+
if (asChild) {
|
|
252
|
+
return /* @__PURE__ */ jsx(
|
|
253
|
+
Slot,
|
|
254
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
255
|
+
ref,
|
|
256
|
+
className: buttonClasses
|
|
257
|
+
}, accessibilityProps), props), {
|
|
258
|
+
children
|
|
259
|
+
})
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ jsxs(
|
|
263
|
+
"button",
|
|
264
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
265
|
+
ref,
|
|
266
|
+
type,
|
|
267
|
+
className: buttonClasses,
|
|
268
|
+
disabled: disabled || loading,
|
|
269
|
+
onClick: handleClick
|
|
270
|
+
}, accessibilityProps), props), {
|
|
271
|
+
children: [
|
|
272
|
+
loading && /* @__PURE__ */ jsxs(
|
|
273
|
+
"svg",
|
|
274
|
+
{
|
|
275
|
+
className: "animate-spin -ml-1 mr-3 h-5 w-5 text-white",
|
|
276
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
277
|
+
fill: "none",
|
|
278
|
+
viewBox: "0 0 24 24",
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ jsx(
|
|
281
|
+
"circle",
|
|
282
|
+
{
|
|
283
|
+
className: "opacity-25",
|
|
284
|
+
cx: "12",
|
|
285
|
+
cy: "12",
|
|
286
|
+
r: "10",
|
|
287
|
+
stroke: "currentColor"
|
|
288
|
+
}
|
|
289
|
+
),
|
|
290
|
+
/* @__PURE__ */ jsx(
|
|
291
|
+
"path",
|
|
292
|
+
{
|
|
293
|
+
className: "opacity-75",
|
|
294
|
+
fill: "currentColor",
|
|
295
|
+
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"
|
|
296
|
+
}
|
|
297
|
+
)
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
loading && loadingText ? /* @__PURE__ */ jsx("span", { className: buttonLoadingClasses.text, children: loadingText }) : buttonContent
|
|
302
|
+
]
|
|
303
|
+
})
|
|
304
|
+
);
|
|
305
|
+
});
|
|
306
|
+
Button.displayName = "Button";
|
|
307
|
+
function CustomCaption() {
|
|
308
|
+
const { goToMonth, nextMonth, previousMonth, months } = useDayPicker();
|
|
309
|
+
const displayMonth = months[0];
|
|
310
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center w-full mb-4 px-1", children: [
|
|
311
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
|
|
312
|
+
/* @__PURE__ */ jsx(
|
|
313
|
+
"button",
|
|
314
|
+
{
|
|
315
|
+
type: "button",
|
|
316
|
+
disabled: !previousMonth,
|
|
317
|
+
onClick: () => previousMonth && goToMonth(previousMonth),
|
|
318
|
+
className: "p-1 rounded-md hover:bg-accent",
|
|
319
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "h-4 w-4" })
|
|
320
|
+
}
|
|
321
|
+
),
|
|
322
|
+
/* @__PURE__ */ jsx("span", { className: "w-24 text-center text-sm font-medium", children: format(displayMonth.date, "MMMM", { locale: es }) }),
|
|
323
|
+
/* @__PURE__ */ jsx(
|
|
324
|
+
"button",
|
|
325
|
+
{
|
|
326
|
+
type: "button",
|
|
327
|
+
disabled: !nextMonth,
|
|
328
|
+
onClick: () => nextMonth && goToMonth(nextMonth),
|
|
329
|
+
className: "p-1 rounded-md hover:bg-accent",
|
|
330
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4" })
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
] }),
|
|
334
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
|
|
335
|
+
/* @__PURE__ */ jsx(
|
|
336
|
+
"button",
|
|
337
|
+
{
|
|
338
|
+
type: "button",
|
|
339
|
+
onClick: () => goToMonth(subYears(displayMonth.date, 1)),
|
|
340
|
+
className: "p-1 rounded-md hover:bg-accent",
|
|
341
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "h-4 w-4" })
|
|
342
|
+
}
|
|
343
|
+
),
|
|
344
|
+
/* @__PURE__ */ jsx("span", { className: "w-16 text-center text-sm font-medium", children: format(displayMonth.date, "yyyy", { locale: es }) }),
|
|
345
|
+
/* @__PURE__ */ jsx(
|
|
346
|
+
"button",
|
|
347
|
+
{
|
|
348
|
+
type: "button",
|
|
349
|
+
onClick: () => goToMonth(addYears(displayMonth.date, 1)),
|
|
350
|
+
className: "p-1 rounded-md hover:bg-accent",
|
|
351
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4" })
|
|
352
|
+
}
|
|
353
|
+
)
|
|
354
|
+
] })
|
|
355
|
+
] });
|
|
356
|
+
}
|
|
357
|
+
function Calendar(_a) {
|
|
358
|
+
var _b = _a, {
|
|
359
|
+
className,
|
|
360
|
+
classNames,
|
|
361
|
+
showOutsideDays = true
|
|
362
|
+
} = _b, props = __objRest(_b, [
|
|
363
|
+
"className",
|
|
364
|
+
"classNames",
|
|
365
|
+
"showOutsideDays"
|
|
366
|
+
]);
|
|
367
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
368
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
369
|
+
.day-range-start[aria-selected="true"] {
|
|
370
|
+
background-color: hsl(var(--primary)) !important;
|
|
371
|
+
color: #ffffff !important;
|
|
372
|
+
border-top-left-radius: 0.375rem;
|
|
373
|
+
border-bottom-left-radius: 0.375rem;
|
|
374
|
+
}
|
|
375
|
+
.day-range-start[aria-selected="true"] button {
|
|
376
|
+
color: #ffffff !important;
|
|
377
|
+
}
|
|
378
|
+
.day-range-end[aria-selected="true"] {
|
|
379
|
+
background-color: hsl(var(--primary)) !important;
|
|
380
|
+
color: #ffffff !important;
|
|
381
|
+
border-top-right-radius: 0.375rem;
|
|
382
|
+
border-bottom-right-radius: 0.375rem;
|
|
383
|
+
}
|
|
384
|
+
.day-range-end[aria-selected="true"] button {
|
|
385
|
+
color: #ffffff !important;
|
|
386
|
+
}
|
|
387
|
+
.day-range-middle[aria-selected="true"] {
|
|
388
|
+
background-color: #eeedf1 !important;
|
|
389
|
+
color: hsl(var(--primary-900)) !important;
|
|
390
|
+
border-radius: 0;
|
|
391
|
+
}
|
|
392
|
+
` }),
|
|
393
|
+
/* @__PURE__ */ jsx(
|
|
394
|
+
DayPicker,
|
|
395
|
+
__spreadValues({
|
|
396
|
+
showOutsideDays,
|
|
397
|
+
className: cn("p-3", className),
|
|
398
|
+
classNames: __spreadValues({
|
|
399
|
+
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
|
|
400
|
+
month: "space-y-4",
|
|
401
|
+
caption_label: "hidden",
|
|
402
|
+
nav: "hidden",
|
|
403
|
+
day_button: "relative flex size-9 items-center justify-center whitespace-nowrap rounded-md p-0 text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 hover:bg-accent hover:text-accent-foreground",
|
|
404
|
+
day: "h-9 w-9 p-0 font-normal",
|
|
405
|
+
range_start: "day-range-start",
|
|
406
|
+
range_end: "day-range-end",
|
|
407
|
+
range_middle: "day-range-middle"
|
|
408
|
+
}, classNames),
|
|
409
|
+
components: {
|
|
410
|
+
MonthCaption: CustomCaption
|
|
411
|
+
}
|
|
412
|
+
}, props)
|
|
413
|
+
)
|
|
414
|
+
] });
|
|
415
|
+
}
|
|
416
|
+
var DropdownMenu = DropdownMenuPrimitive.Root;
|
|
417
|
+
var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
418
|
+
var DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
419
|
+
var DropdownMenuSubTrigger = React2.forwardRef((_a, ref) => {
|
|
420
|
+
var _b = _a, { className, inset, children } = _b, props = __objRest(_b, ["className", "inset", "children"]);
|
|
421
|
+
return /* @__PURE__ */ jsxs(
|
|
422
|
+
DropdownMenuPrimitive.SubTrigger,
|
|
423
|
+
__spreadProps(__spreadValues({
|
|
424
|
+
ref,
|
|
425
|
+
className: cn(
|
|
426
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
|
|
427
|
+
inset && "pl-8",
|
|
428
|
+
className
|
|
429
|
+
)
|
|
430
|
+
}, props), {
|
|
431
|
+
children: [
|
|
432
|
+
children,
|
|
433
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto h-4 w-4" })
|
|
434
|
+
]
|
|
435
|
+
})
|
|
436
|
+
);
|
|
437
|
+
});
|
|
438
|
+
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
|
439
|
+
var DropdownMenuSubContent = React2.forwardRef((_a, ref) => {
|
|
440
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
441
|
+
return /* @__PURE__ */ jsx(
|
|
442
|
+
DropdownMenuPrimitive.SubContent,
|
|
443
|
+
__spreadValues({
|
|
444
|
+
ref,
|
|
445
|
+
className: cn(
|
|
446
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
447
|
+
className
|
|
448
|
+
)
|
|
449
|
+
}, props)
|
|
450
|
+
);
|
|
451
|
+
});
|
|
452
|
+
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
|
453
|
+
var DropdownMenuContent = React2.forwardRef((_a, ref) => {
|
|
454
|
+
var _b = _a, { className, sideOffset = 4 } = _b, props = __objRest(_b, ["className", "sideOffset"]);
|
|
455
|
+
return /* @__PURE__ */ jsx(DropdownMenuPortal, { children: /* @__PURE__ */ jsx(
|
|
456
|
+
DropdownMenuPrimitive.Content,
|
|
457
|
+
__spreadValues({
|
|
458
|
+
ref,
|
|
459
|
+
sideOffset,
|
|
460
|
+
className: cn(
|
|
461
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-background p-1 text-popover-foreground shadow-md",
|
|
462
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
463
|
+
className
|
|
464
|
+
)
|
|
465
|
+
}, props)
|
|
466
|
+
) });
|
|
467
|
+
});
|
|
468
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
469
|
+
var DropdownMenuItem = React2.forwardRef((_a, ref) => {
|
|
470
|
+
var _b = _a, { className, inset } = _b, props = __objRest(_b, ["className", "inset"]);
|
|
471
|
+
return /* @__PURE__ */ jsx(
|
|
472
|
+
DropdownMenuPrimitive.Item,
|
|
473
|
+
__spreadValues({
|
|
474
|
+
ref,
|
|
475
|
+
className: cn(
|
|
476
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
477
|
+
inset && "pl-8",
|
|
478
|
+
className
|
|
479
|
+
)
|
|
480
|
+
}, props)
|
|
481
|
+
);
|
|
482
|
+
});
|
|
483
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
484
|
+
var DropdownMenuCheckboxItem = React2.forwardRef((_a, ref) => {
|
|
485
|
+
var _b = _a, { className, children, checked } = _b, props = __objRest(_b, ["className", "children", "checked"]);
|
|
486
|
+
return /* @__PURE__ */ jsxs(
|
|
487
|
+
DropdownMenuPrimitive.CheckboxItem,
|
|
488
|
+
__spreadProps(__spreadValues({
|
|
489
|
+
ref,
|
|
490
|
+
className: cn(
|
|
491
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
492
|
+
className
|
|
493
|
+
),
|
|
494
|
+
checked
|
|
495
|
+
}, props), {
|
|
496
|
+
children: [
|
|
497
|
+
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
|
|
498
|
+
children
|
|
499
|
+
]
|
|
500
|
+
})
|
|
501
|
+
);
|
|
502
|
+
});
|
|
503
|
+
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
504
|
+
var DropdownMenuRadioItem = React2.forwardRef((_a, ref) => {
|
|
505
|
+
var _b = _a, { className, children } = _b, props = __objRest(_b, ["className", "children"]);
|
|
506
|
+
return /* @__PURE__ */ jsxs(
|
|
507
|
+
DropdownMenuPrimitive.RadioItem,
|
|
508
|
+
__spreadProps(__spreadValues({
|
|
509
|
+
ref,
|
|
510
|
+
className: cn(
|
|
511
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
512
|
+
className
|
|
513
|
+
)
|
|
514
|
+
}, props), {
|
|
515
|
+
children: [
|
|
516
|
+
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }),
|
|
517
|
+
children
|
|
518
|
+
]
|
|
519
|
+
})
|
|
520
|
+
);
|
|
521
|
+
});
|
|
522
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
523
|
+
var DropdownMenuLabel = React2.forwardRef((_a, ref) => {
|
|
524
|
+
var _b = _a, { className, inset } = _b, props = __objRest(_b, ["className", "inset"]);
|
|
525
|
+
return /* @__PURE__ */ jsx(
|
|
526
|
+
DropdownMenuPrimitive.Label,
|
|
527
|
+
__spreadValues({
|
|
528
|
+
ref,
|
|
529
|
+
className: cn(
|
|
530
|
+
"px-2 py-1.5 text-sm font-semibold",
|
|
531
|
+
inset && "pl-8",
|
|
532
|
+
className
|
|
533
|
+
)
|
|
534
|
+
}, props)
|
|
535
|
+
);
|
|
536
|
+
});
|
|
537
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
538
|
+
var DropdownMenuSeparator = React2.forwardRef((_a, ref) => {
|
|
539
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
540
|
+
return /* @__PURE__ */ jsx(
|
|
541
|
+
DropdownMenuPrimitive.Separator,
|
|
542
|
+
__spreadValues({
|
|
543
|
+
ref,
|
|
544
|
+
className: cn("-mx-1 my-1 h-px bg-muted", className)
|
|
545
|
+
}, props)
|
|
546
|
+
);
|
|
547
|
+
});
|
|
548
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
549
|
+
var Input = React2.forwardRef(
|
|
550
|
+
(_a, ref) => {
|
|
551
|
+
var _b = _a, { className, type, error, helperText, label, required, id, icon } = _b, props = __objRest(_b, ["className", "type", "error", "helperText", "label", "required", "id", "icon"]);
|
|
552
|
+
const inputId = id || `input-${React2.useId()}`;
|
|
553
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
554
|
+
label && /* @__PURE__ */ jsx(
|
|
555
|
+
"label",
|
|
556
|
+
{
|
|
557
|
+
htmlFor: inputId,
|
|
558
|
+
className: cn(
|
|
559
|
+
"text-body-xs font-normal leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
560
|
+
required && "after:content-['*'] after:text-destructive after:ml-1"
|
|
561
|
+
),
|
|
562
|
+
children: label
|
|
563
|
+
}
|
|
564
|
+
),
|
|
565
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
566
|
+
icon && /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3", children: icon }),
|
|
567
|
+
/* @__PURE__ */ jsx(
|
|
568
|
+
"input",
|
|
569
|
+
__spreadValues({
|
|
570
|
+
id: inputId,
|
|
571
|
+
type,
|
|
572
|
+
className: cn(
|
|
573
|
+
"flex h-10 w-full rounded-lg border border-primary-300 bg-background py-2 pr-3",
|
|
574
|
+
"text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium",
|
|
575
|
+
"placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
576
|
+
"focus-visible:shadow-focus active:shadow-pressed",
|
|
577
|
+
error && "border-destructive focus-visible:shadow-destructive",
|
|
578
|
+
icon ? "pl-10" : "pl-3",
|
|
579
|
+
className
|
|
580
|
+
),
|
|
581
|
+
ref,
|
|
582
|
+
"aria-invalid": error ? "true" : "false",
|
|
583
|
+
"aria-describedby": error ? `${inputId}-error` : helperText ? `${inputId}-helper` : void 0
|
|
584
|
+
}, props)
|
|
585
|
+
)
|
|
586
|
+
] }),
|
|
587
|
+
helperText && !error && /* @__PURE__ */ jsx("p", { id: `${inputId}-helper`, className: "text-body-xs text-muted-foreground", children: helperText }),
|
|
588
|
+
error && /* @__PURE__ */ jsx("p", { id: `${inputId}-error`, className: "text-body-xs text-destructive", children: typeof error === "string" ? error : "Este campo tiene errores" })
|
|
589
|
+
] });
|
|
590
|
+
}
|
|
591
|
+
);
|
|
592
|
+
Input.displayName = "Input";
|
|
593
|
+
function DatePickerWithRange({
|
|
594
|
+
className,
|
|
595
|
+
date,
|
|
596
|
+
onDateChange,
|
|
597
|
+
label
|
|
598
|
+
}) {
|
|
599
|
+
const [month, setMonth] = React2.useState((date == null ? void 0 : date.from) || /* @__PURE__ */ new Date());
|
|
600
|
+
const [open, setOpen] = React2.useState(false);
|
|
601
|
+
const [inputValue, setInputValue] = React2.useState("");
|
|
602
|
+
React2.useEffect(() => {
|
|
603
|
+
if (date == null ? void 0 : date.from) {
|
|
604
|
+
if (date.to) {
|
|
605
|
+
setInputValue(
|
|
606
|
+
`${format(date.from, "dd/MM/yyyy")} - ${format(date.to, "dd/MM/yyyy")}`
|
|
607
|
+
);
|
|
608
|
+
} else {
|
|
609
|
+
setInputValue(format(date.from, "dd/MM/yyyy"));
|
|
610
|
+
}
|
|
611
|
+
} else {
|
|
612
|
+
setInputValue("");
|
|
613
|
+
}
|
|
614
|
+
}, [date]);
|
|
615
|
+
const handleInputChange = (e) => {
|
|
616
|
+
setInputValue(e.target.value);
|
|
617
|
+
};
|
|
618
|
+
const handleInputBlur = () => {
|
|
619
|
+
const parts = inputValue.split(" - ");
|
|
620
|
+
const from = new Date(parts[0]);
|
|
621
|
+
const to = parts[1] ? new Date(parts[1]) : from;
|
|
622
|
+
if (!isNaN(from.getTime())) {
|
|
623
|
+
onDateChange({ from, to: parts[1] ? to : void 0 });
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
const today = /* @__PURE__ */ new Date();
|
|
627
|
+
const presets = [
|
|
628
|
+
{ label: "Hoy", range: { from: today, to: today } },
|
|
629
|
+
{ label: "Ayer", range: { from: subDays(today, 1), to: subDays(today, 1) } },
|
|
630
|
+
{ label: "La semana pasada", range: { from: subDays(today, 6), to: today } },
|
|
631
|
+
{ label: "El mes pasado", range: { from: subDays(today, 29), to: today } },
|
|
632
|
+
{
|
|
633
|
+
label: "Este mes",
|
|
634
|
+
range: { from: startOfMonth(today), to: endOfMonth(today) }
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
label: "El mes anterior",
|
|
638
|
+
range: {
|
|
639
|
+
from: startOfMonth(subMonths(today, 1)),
|
|
640
|
+
to: endOfMonth(subMonths(today, 1))
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
{ label: "Este a\xF1o", range: { from: startOfYear(today), to: endOfYear(today) } },
|
|
644
|
+
{
|
|
645
|
+
label: "El a\xF1o pasado",
|
|
646
|
+
range: {
|
|
647
|
+
from: startOfYear(subYears(today, 1)),
|
|
648
|
+
to: endOfYear(subYears(today, 1))
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
];
|
|
652
|
+
const handlePresetClick = (range) => {
|
|
653
|
+
onDateChange(range);
|
|
654
|
+
setMonth(range.from || /* @__PURE__ */ new Date());
|
|
655
|
+
};
|
|
656
|
+
const isCustomDate = React2.useMemo(() => {
|
|
657
|
+
if (!date || !date.from) return false;
|
|
658
|
+
return !presets.some(
|
|
659
|
+
(p) => isEqual(p.range.from, date.from || /* @__PURE__ */ new Date(0)) && isEqual(p.range.to || /* @__PURE__ */ new Date(0), date.to || /* @__PURE__ */ new Date(0))
|
|
660
|
+
);
|
|
661
|
+
}, [date, presets]);
|
|
662
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("grid gap-2", className), children: [
|
|
663
|
+
label && /* @__PURE__ */ jsx("label", { className: "text-body-xs font-normal text-neutral-900", children: label }),
|
|
664
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
665
|
+
/* @__PURE__ */ jsx(
|
|
666
|
+
Input,
|
|
667
|
+
{
|
|
668
|
+
type: "text",
|
|
669
|
+
value: inputValue,
|
|
670
|
+
onChange: handleInputChange,
|
|
671
|
+
onBlur: handleInputBlur,
|
|
672
|
+
placeholder: "dd/mm/aa - dd/mm/aa",
|
|
673
|
+
className: "w-[300px] placeholder:text-primary-500"
|
|
674
|
+
}
|
|
675
|
+
),
|
|
676
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { open, onOpenChange: setOpen, children: [
|
|
677
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
678
|
+
"button",
|
|
679
|
+
{
|
|
680
|
+
type: "button",
|
|
681
|
+
onClick: () => setOpen(true),
|
|
682
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2",
|
|
683
|
+
children: /* @__PURE__ */ jsx(CalendarIcon, { className: "h-4 w-4 text-neutral-600" })
|
|
684
|
+
}
|
|
685
|
+
) }),
|
|
686
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { className: "w-auto p-0", align: "end", children: /* @__PURE__ */ jsxs("div", { className: "flex rounded-lg border border-neutral-200 bg-white shadow-lg", children: [
|
|
687
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-1 border-r border-neutral-200 p-2 bg-neutral-50", children: [
|
|
688
|
+
presets.map((preset) => {
|
|
689
|
+
const isSelected = (date == null ? void 0 : date.from) && (date == null ? void 0 : date.to) && isEqual(preset.range.from, date.from) && isEqual(preset.range.to, date.to);
|
|
690
|
+
return /* @__PURE__ */ jsx(
|
|
691
|
+
Button,
|
|
692
|
+
{
|
|
693
|
+
variant: isSelected ? "primary" : "ghost",
|
|
694
|
+
size: "sm",
|
|
695
|
+
onClick: () => handlePresetClick(preset.range),
|
|
696
|
+
className: "w-full justify-start",
|
|
697
|
+
children: preset.label
|
|
698
|
+
},
|
|
699
|
+
preset.label
|
|
700
|
+
);
|
|
701
|
+
}),
|
|
702
|
+
/* @__PURE__ */ jsx(
|
|
703
|
+
Button,
|
|
704
|
+
{
|
|
705
|
+
variant: isCustomDate ? "primary" : "ghost",
|
|
706
|
+
size: "sm",
|
|
707
|
+
className: "w-full justify-start",
|
|
708
|
+
onClick: () => {
|
|
709
|
+
},
|
|
710
|
+
children: "Personalizado"
|
|
711
|
+
}
|
|
712
|
+
)
|
|
713
|
+
] }),
|
|
714
|
+
/* @__PURE__ */ jsx(
|
|
715
|
+
Calendar,
|
|
716
|
+
{
|
|
717
|
+
initialFocus: true,
|
|
718
|
+
mode: "range",
|
|
719
|
+
defaultMonth: date == null ? void 0 : date.from,
|
|
720
|
+
selected: date,
|
|
721
|
+
onSelect: onDateChange,
|
|
722
|
+
numberOfMonths: 1,
|
|
723
|
+
month,
|
|
724
|
+
onMonthChange: setMonth,
|
|
725
|
+
className: "border-none"
|
|
726
|
+
}
|
|
727
|
+
)
|
|
728
|
+
] }) })
|
|
729
|
+
] })
|
|
730
|
+
] })
|
|
731
|
+
] });
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
export { DatePickerWithRange };
|