@grupor5/raya 0.2.46 → 0.2.48

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.
@@ -0,0 +1,752 @@
1
+ 'use strict';
2
+
3
+ var React4 = require('react');
4
+ var clsx = require('clsx');
5
+ var tailwindMerge = require('tailwind-merge');
6
+ var reactSlot = require('@radix-ui/react-slot');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+ var classVarianceAuthority = require('class-variance-authority');
9
+ var LabelPrimitive = require('@radix-ui/react-label');
10
+ var rayaIcons = require('@grupor5/raya-icons');
11
+ var FolderCloudIcon = require('@grupor5/raya-icons/icons/FolderCloudIcon');
12
+ var DocumentTextIcon = require('@grupor5/raya-icons/icons/DocumentTextIcon');
13
+ var DocumentDownloadIcon = require('@grupor5/raya-icons/icons/DocumentDownloadIcon');
14
+ var TrashIcon = require('@grupor5/raya-icons/icons/TrashIcon');
15
+
16
+ function _interopNamespace(e) {
17
+ if (e && e.__esModule) return e;
18
+ var n = Object.create(null);
19
+ if (e) {
20
+ Object.keys(e).forEach(function (k) {
21
+ if (k !== 'default') {
22
+ var d = Object.getOwnPropertyDescriptor(e, k);
23
+ Object.defineProperty(n, k, d.get ? d : {
24
+ enumerable: true,
25
+ get: function () { return e[k]; }
26
+ });
27
+ }
28
+ });
29
+ }
30
+ n.default = e;
31
+ return Object.freeze(n);
32
+ }
33
+
34
+ var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
35
+ var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
36
+
37
+ var __defProp = Object.defineProperty;
38
+ var __defProps = Object.defineProperties;
39
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
40
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
41
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
42
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
43
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
44
+ var __spreadValues = (a, b) => {
45
+ for (var prop in b || (b = {}))
46
+ if (__hasOwnProp.call(b, prop))
47
+ __defNormalProp(a, prop, b[prop]);
48
+ if (__getOwnPropSymbols)
49
+ for (var prop of __getOwnPropSymbols(b)) {
50
+ if (__propIsEnum.call(b, prop))
51
+ __defNormalProp(a, prop, b[prop]);
52
+ }
53
+ return a;
54
+ };
55
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
56
+ var __objRest = (source, exclude) => {
57
+ var target = {};
58
+ for (var prop in source)
59
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
60
+ target[prop] = source[prop];
61
+ if (source != null && __getOwnPropSymbols)
62
+ for (var prop of __getOwnPropSymbols(source)) {
63
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
64
+ target[prop] = source[prop];
65
+ }
66
+ return target;
67
+ };
68
+ function cn(...inputs) {
69
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
70
+ }
71
+
72
+ // src/tokens/buttons.ts
73
+ var buttonSizeClasses = {
74
+ sm: {
75
+ base: "h-8 px-2 py-1 text-sm rounded-[10px]",
76
+ icon: "h-8 w-8 rounded-[10px]",
77
+ iconSize: "w-4 h-4"
78
+ },
79
+ md: {
80
+ base: "h-10 px-4 py-2 text-base rounded-xl",
81
+ icon: "h-10 w-10 rounded-xl",
82
+ iconSize: "w-5 h-5"
83
+ },
84
+ lg: {
85
+ base: "h-12 px-6 py-3 text-lg rounded-2xl",
86
+ icon: "h-12 w-12 rounded-2xl",
87
+ iconSize: "w-[22px] h-[22px]"
88
+ }
89
+ };
90
+ var buttonVariantClasses = {
91
+ // Primary variants
92
+ primary: {
93
+ primary: "bg-primary text-primary-foreground shadow-sm hover:bg-primary/90 active:bg-[hsl(var(--primary-pressed))] disabled:bg-primary-400 disabled:text-primary-700",
94
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/90 active:bg-secondary/80 disabled:bg-primary-400 disabled:text-primary-700",
95
+ success: "bg-emerald-600 text-white shadow-sm hover:bg-emerald-700 active:bg-emerald-800 disabled:bg-primary-400 disabled:text-primary-700",
96
+ warning: "bg-amber-600 text-white shadow-sm hover:bg-amber-700 active:bg-amber-800 disabled:bg-primary-400 disabled:text-primary-700",
97
+ destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/80 disabled:bg-primary-400 disabled:text-primary-700",
98
+ neutral: "bg-neutral-700 text-white shadow-sm hover:bg-neutral-800 active:bg-neutral-900 disabled:bg-primary-400 disabled:text-primary-700"
99
+ },
100
+ // Secondary variants (outlined)
101
+ secondary: {
102
+ primary: "border border-primary text-primary bg-transparent hover:bg-primary/10 active:bg-primary/20 disabled:border-primary-400 disabled:text-primary-700 disabled:bg-transparent",
103
+ secondary: "border border-secondary text-secondary bg-transparent hover:bg-secondary/10 active:bg-secondary/20 disabled:border-primary-400 disabled:text-primary-700 disabled:bg-transparent",
104
+ success: "border border-emerald-600 text-emerald-600 bg-transparent hover:bg-emerald-50 active:bg-emerald-100 disabled:border-primary-400 disabled:text-primary-700 disabled:bg-transparent",
105
+ warning: "border border-amber-600 text-amber-600 bg-transparent hover:bg-amber-50 active:bg-amber-100 disabled:border-primary-400 disabled:text-primary-700 disabled:bg-transparent",
106
+ destructive: "border border-destructive text-destructive bg-transparent hover:bg-destructive/10 active:bg-destructive/20 disabled:border-primary-400 disabled:text-primary-700 disabled:bg-transparent",
107
+ neutral: "border border-neutral-700 text-neutral-700 bg-transparent hover:bg-neutral-50 active:bg-neutral-100 disabled:border-primary-400 disabled:text-primary-700 disabled:bg-transparent"
108
+ },
109
+ // Ghost variants (text only)
110
+ ghost: {
111
+ primary: "text-primary bg-transparent hover:bg-primary/10 active:bg-primary/20 disabled:text-primary-700 disabled:bg-transparent",
112
+ secondary: "text-secondary bg-transparent hover:bg-secondary/10 active:bg-secondary/20 disabled:text-primary-700 disabled:bg-transparent",
113
+ success: "text-emerald-600 bg-transparent hover:bg-emerald-50 active:bg-emerald-100 disabled:text-primary-700 disabled:bg-transparent",
114
+ warning: "text-amber-600 bg-transparent hover:bg-amber-50 active:bg-amber-100 disabled:text-primary-700 disabled:bg-transparent",
115
+ destructive: "text-destructive bg-transparent hover:bg-destructive/10 active:bg-destructive/20 disabled:text-primary-700 disabled:bg-transparent",
116
+ neutral: "text-neutral-700 bg-transparent hover:bg-neutral-100 active:bg-neutral-200 disabled:text-primary-700 disabled:bg-transparent"
117
+ }
118
+ };
119
+ 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]";
120
+ var buttonLoadingClasses = {
121
+ spinner: "animate-spin",
122
+ container: "flex items-center justify-center gap-2",
123
+ text: "opacity-70"
124
+ };
125
+ var getButtonSizeClasses = (size, isIcon) => {
126
+ return isIcon ? buttonSizeClasses[size].icon : buttonSizeClasses[size].base;
127
+ };
128
+ var getButtonVariantClasses = (variant, color) => {
129
+ var _a;
130
+ if (variant === "icon") {
131
+ return buttonVariantClasses.ghost[color];
132
+ }
133
+ return ((_a = buttonVariantClasses[variant]) == null ? void 0 : _a[color]) || "";
134
+ };
135
+ var getButtonIconSize = (size) => {
136
+ return buttonSizeClasses[size].iconSize;
137
+ };
138
+ var defaultButtonConfig = {
139
+ variant: "primary",
140
+ size: "md",
141
+ color: "primary",
142
+ type: "button"
143
+ };
144
+ var LoadingSpinner = ({
145
+ size,
146
+ className
147
+ }) => {
148
+ const sizeClasses = {
149
+ sm: "w-4 h-4",
150
+ md: "w-5 h-5",
151
+ lg: "w-6 h-6"
152
+ };
153
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(buttonLoadingClasses.spinner, sizeClasses[size], className), children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { fill: "none", viewBox: "0 0 24 24", className: "w-full h-full", children: [
154
+ /* @__PURE__ */ jsxRuntime.jsx(
155
+ "circle",
156
+ {
157
+ className: "opacity-25",
158
+ cx: "12",
159
+ cy: "12",
160
+ r: "10",
161
+ stroke: "currentColor"
162
+ }
163
+ ),
164
+ /* @__PURE__ */ jsxRuntime.jsx(
165
+ "path",
166
+ {
167
+ className: "opacity-75",
168
+ fill: "currentColor",
169
+ 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"
170
+ }
171
+ )
172
+ ] }) });
173
+ };
174
+ var Button = React4.forwardRef((_a, ref) => {
175
+ var _b = _a, {
176
+ variant = defaultButtonConfig.variant,
177
+ size = defaultButtonConfig.size,
178
+ color = defaultButtonConfig.color,
179
+ disabled = false,
180
+ loading = false,
181
+ loadingText,
182
+ icon,
183
+ iconLeft,
184
+ iconRight,
185
+ className,
186
+ children,
187
+ type = defaultButtonConfig.type,
188
+ "aria-label": ariaLabel,
189
+ "aria-describedby": ariaDescribedBy,
190
+ asChild = false,
191
+ onClick
192
+ } = _b, props = __objRest(_b, [
193
+ "variant",
194
+ "size",
195
+ "color",
196
+ "disabled",
197
+ "loading",
198
+ "loadingText",
199
+ "icon",
200
+ "iconLeft",
201
+ "iconRight",
202
+ "className",
203
+ "children",
204
+ "type",
205
+ "aria-label",
206
+ "aria-describedby",
207
+ "asChild",
208
+ "onClick"
209
+ ]);
210
+ const isIconOnly = variant === "icon" || !!(!children && (icon || iconLeft || iconRight));
211
+ const buttonClasses = React4.useMemo(() => {
212
+ const sizeClasses = getButtonSizeClasses(size, isIconOnly);
213
+ const variantClasses = getButtonVariantClasses(variant, color);
214
+ return cn(
215
+ buttonBaseClasses,
216
+ sizeClasses,
217
+ variantClasses,
218
+ className
219
+ );
220
+ }, [variant, size, color, isIconOnly, className]);
221
+ const buttonContent = React4.useMemo(() => {
222
+ if (loading) {
223
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: buttonLoadingClasses.container, children: [
224
+ /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner, { size }),
225
+ loadingText && /* @__PURE__ */ jsxRuntime.jsx("span", { className: buttonLoadingClasses.text, children: loadingText })
226
+ ] });
227
+ }
228
+ const iconSizeClass = getButtonIconSize(size);
229
+ const renderIcon = (iconNode) => {
230
+ if (React4__namespace.default.isValidElement(iconNode)) {
231
+ return React4__namespace.default.cloneElement(iconNode, {
232
+ className: cn(iconSizeClass, iconNode.props.className),
233
+ "aria-hidden": true
234
+ });
235
+ }
236
+ return iconNode;
237
+ };
238
+ if (isIconOnly) {
239
+ return renderIcon(icon || iconLeft || iconRight);
240
+ }
241
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center justify-center gap-2", children: [
242
+ iconLeft && renderIcon(iconLeft),
243
+ children && /* @__PURE__ */ jsxRuntime.jsx("span", { children }),
244
+ iconRight && renderIcon(iconRight)
245
+ ] });
246
+ }, [loading, loadingText, isIconOnly, icon, iconLeft, iconRight, children, size]);
247
+ const accessibilityProps = React4.useMemo(() => {
248
+ const props2 = {};
249
+ if (isIconOnly && !ariaLabel) {
250
+ console.warn("Icon-only buttons should have an aria-label for accessibility");
251
+ }
252
+ if (ariaLabel) {
253
+ props2["aria-label"] = ariaLabel;
254
+ }
255
+ if (ariaDescribedBy) {
256
+ props2["aria-describedby"] = ariaDescribedBy;
257
+ }
258
+ if (loading) {
259
+ props2["aria-busy"] = true;
260
+ props2["aria-disabled"] = true;
261
+ }
262
+ if (disabled || loading) {
263
+ props2["aria-disabled"] = true;
264
+ }
265
+ return props2;
266
+ }, [isIconOnly, ariaLabel, ariaDescribedBy, loading, disabled]);
267
+ const handleClick = (event) => {
268
+ if (disabled || loading) {
269
+ event.preventDefault();
270
+ return;
271
+ }
272
+ onClick == null ? void 0 : onClick(event);
273
+ };
274
+ if (asChild) {
275
+ return /* @__PURE__ */ jsxRuntime.jsx(
276
+ reactSlot.Slot,
277
+ __spreadProps(__spreadValues(__spreadValues({
278
+ ref,
279
+ className: buttonClasses
280
+ }, accessibilityProps), props), {
281
+ children
282
+ })
283
+ );
284
+ }
285
+ return /* @__PURE__ */ jsxRuntime.jsxs(
286
+ "button",
287
+ __spreadProps(__spreadValues(__spreadValues({
288
+ ref,
289
+ type,
290
+ className: buttonClasses,
291
+ disabled: disabled || loading,
292
+ onClick: handleClick
293
+ }, accessibilityProps), props), {
294
+ children: [
295
+ loading && /* @__PURE__ */ jsxRuntime.jsxs(
296
+ "svg",
297
+ {
298
+ className: "animate-spin -ml-1 mr-3 h-5 w-5 text-white",
299
+ xmlns: "http://www.w3.org/2000/svg",
300
+ fill: "none",
301
+ viewBox: "0 0 24 24",
302
+ children: [
303
+ /* @__PURE__ */ jsxRuntime.jsx(
304
+ "circle",
305
+ {
306
+ className: "opacity-25",
307
+ cx: "12",
308
+ cy: "12",
309
+ r: "10",
310
+ stroke: "currentColor"
311
+ }
312
+ ),
313
+ /* @__PURE__ */ jsxRuntime.jsx(
314
+ "path",
315
+ {
316
+ className: "opacity-75",
317
+ fill: "currentColor",
318
+ 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"
319
+ }
320
+ )
321
+ ]
322
+ }
323
+ ),
324
+ loading && loadingText ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: buttonLoadingClasses.text, children: loadingText }) : buttonContent
325
+ ]
326
+ })
327
+ );
328
+ });
329
+ Button.displayName = "Button";
330
+ var labelVariants = classVarianceAuthority.cva(
331
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
332
+ );
333
+ var Label = React4__namespace.forwardRef((_a, ref) => {
334
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
335
+ return /* @__PURE__ */ jsxRuntime.jsx(
336
+ LabelPrimitive__namespace.Root,
337
+ __spreadValues({
338
+ ref,
339
+ className: cn(labelVariants(), className)
340
+ }, props)
341
+ );
342
+ });
343
+ Label.displayName = LabelPrimitive__namespace.Root.displayName;
344
+ var progressBarContainerVariants = classVarianceAuthority.cva("w-full min-w-[200px]", {
345
+ variants: {
346
+ size: {
347
+ sm: "text-progress-bar-sm",
348
+ md: "text-progress-bar-md",
349
+ lg: "text-progress-bar-lg"
350
+ }
351
+ },
352
+ defaultVariants: {
353
+ size: "md"
354
+ }
355
+ });
356
+ var progressBarTrackVariants = classVarianceAuthority.cva(
357
+ "overflow-hidden rounded-full bg-progress-bar-track",
358
+ {
359
+ variants: {
360
+ size: {
361
+ sm: "h-progress-bar-sm",
362
+ md: "h-progress-bar-md",
363
+ lg: "h-progress-bar-lg"
364
+ }
365
+ },
366
+ defaultVariants: {
367
+ size: "md"
368
+ }
369
+ }
370
+ );
371
+ var progressBarIndicatorVariants = classVarianceAuthority.cva(
372
+ "h-full rounded-full bg-progress-bar-indicator transition-all duration-300 ease-in-out",
373
+ {
374
+ variants: {},
375
+ defaultVariants: {}
376
+ }
377
+ );
378
+ var ProgressBar = React4__namespace.default.forwardRef(
379
+ (_a, ref) => {
380
+ var _b = _a, {
381
+ className,
382
+ value,
383
+ label,
384
+ size,
385
+ showPercentage = true
386
+ } = _b, props = __objRest(_b, [
387
+ "className",
388
+ "value",
389
+ "label",
390
+ "size",
391
+ "showPercentage"
392
+ ]);
393
+ const progress = Math.max(0, Math.min(100, value || 0));
394
+ return /* @__PURE__ */ jsxRuntime.jsxs(
395
+ "div",
396
+ __spreadProps(__spreadValues({
397
+ ref,
398
+ className: cn(progressBarContainerVariants({ size }), className)
399
+ }, props), {
400
+ children: [
401
+ (label || showPercentage) && /* @__PURE__ */ jsxRuntime.jsxs(
402
+ "div",
403
+ {
404
+ className: cn(
405
+ "flex items-center mb-1",
406
+ label ? "justify-between" : "justify-end"
407
+ ),
408
+ children: [
409
+ label && /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-progress-bar-label font-normal", children: label }),
410
+ showPercentage && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-progress-bar-label font-normal", children: [
411
+ Math.round(progress),
412
+ "%"
413
+ ] })
414
+ ]
415
+ }
416
+ ),
417
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(progressBarTrackVariants({ size })), children: /* @__PURE__ */ jsxRuntime.jsx(
418
+ "div",
419
+ {
420
+ className: cn(progressBarIndicatorVariants()),
421
+ style: { width: `${progress}%` }
422
+ }
423
+ ) })
424
+ ]
425
+ })
426
+ );
427
+ }
428
+ );
429
+ ProgressBar.displayName = "ProgressBar";
430
+ var alertVariants = classVarianceAuthority.cva(
431
+ "relative w-full rounded-2xl px-6 py-2 flex items-center justify-between",
432
+ {
433
+ variants: {
434
+ variant: {
435
+ default: "bg-background",
436
+ danger: "bg-red-100",
437
+ success: "bg-green-10",
438
+ warning: "bg-yellow-10",
439
+ neutral: "bg-secondary-200"
440
+ }
441
+ },
442
+ defaultVariants: {
443
+ variant: "default"
444
+ }
445
+ }
446
+ );
447
+ var AlertContext = React4__namespace.createContext(null);
448
+ var useAlertContext = () => {
449
+ const context = React4__namespace.useContext(AlertContext);
450
+ if (!context) {
451
+ throw new Error("useAlertContext must be used inside an Alert");
452
+ }
453
+ return context;
454
+ };
455
+ var Alert = React4__namespace.forwardRef((_a, ref) => {
456
+ var _b = _a, { className, variant, children, isClosable, actions } = _b, props = __objRest(_b, ["className", "variant", "children", "isClosable", "actions"]);
457
+ const [isVisible, setIsVisible] = React4__namespace.useState(true);
458
+ if (!isVisible) {
459
+ return null;
460
+ }
461
+ return /* @__PURE__ */ jsxRuntime.jsx(AlertContext.Provider, { value: { variant }, children: /* @__PURE__ */ jsxRuntime.jsxs(
462
+ "div",
463
+ __spreadProps(__spreadValues({
464
+ ref,
465
+ role: "alert",
466
+ className: cn(alertVariants({ variant }), className)
467
+ }, props), {
468
+ children: [
469
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow", children }),
470
+ isClosable ? /* @__PURE__ */ jsxRuntime.jsx(
471
+ Button,
472
+ {
473
+ size: "sm",
474
+ variant: "ghost",
475
+ onClick: () => setIsVisible(false),
476
+ "aria-label": "Cerrar",
477
+ className: "border p-2 !rounded-[8px] border-primary-500 text-primary-1200 h-6 w-6",
478
+ children: /* @__PURE__ */ jsxRuntime.jsx(rayaIcons.CloseCircleIcon, { size: 16 })
479
+ }
480
+ ) : actions
481
+ ]
482
+ })
483
+ ) });
484
+ });
485
+ Alert.displayName = "Alert";
486
+ var AlertTitle = React4__namespace.forwardRef((_a, ref) => {
487
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
488
+ const { variant } = useAlertContext();
489
+ return /* @__PURE__ */ jsxRuntime.jsx(
490
+ "p",
491
+ __spreadValues({
492
+ ref,
493
+ className: cn(
494
+ "text-base font-bold leading-5",
495
+ {
496
+ "text-red-600": variant === "danger",
497
+ "text-primary-900": ["success", "warning", "neutral", "default"].includes(
498
+ variant
499
+ ) || !variant
500
+ },
501
+ className
502
+ )
503
+ }, props)
504
+ );
505
+ });
506
+ AlertTitle.displayName = "AlertTitle";
507
+ var AlertDescription = React4__namespace.forwardRef((_a, ref) => {
508
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
509
+ const { variant } = useAlertContext();
510
+ return /* @__PURE__ */ jsxRuntime.jsx(
511
+ "div",
512
+ __spreadValues({
513
+ ref,
514
+ className: cn(
515
+ "text-xs leading-5 [&_p]:leading-relaxed text-primary-900",
516
+ className
517
+ )
518
+ }, props)
519
+ );
520
+ });
521
+ AlertDescription.displayName = "AlertDescription";
522
+ var FileUploadDropzone = React4__namespace.forwardRef(
523
+ (_a, ref) => {
524
+ var _b = _a, {
525
+ className,
526
+ onSelect,
527
+ accept = ".png,.jpg,.jpeg,.pdf",
528
+ disabled = false,
529
+ subtitle = "PNG, JPG, JPEG o PDF",
530
+ buttonLabel = "Abrir explorador"
531
+ } = _b, props = __objRest(_b, [
532
+ "className",
533
+ "onSelect",
534
+ "accept",
535
+ "disabled",
536
+ "subtitle",
537
+ "buttonLabel"
538
+ ]);
539
+ const inputRef = React4__namespace.useRef(null);
540
+ const handleChange = (e) => {
541
+ const files = e.target.files;
542
+ if (files && files.length > 0) {
543
+ onSelect(Array.from(files));
544
+ }
545
+ e.target.value = "";
546
+ };
547
+ return /* @__PURE__ */ jsxRuntime.jsxs(
548
+ "div",
549
+ __spreadProps(__spreadValues({
550
+ ref,
551
+ className: cn(
552
+ "flex flex-col gap-[26px] rounded-2xl border border-primary-400 bg-white p-6",
553
+ className
554
+ )
555
+ }, props), {
556
+ children: [
557
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
558
+ /* @__PURE__ */ jsxRuntime.jsx(FolderCloudIcon.FolderCloudIcon, { className: "h-6 w-6 text-primary-600", "aria-hidden": "true" }),
559
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base text-primary-1200", children: "A\xF1adir archivos" }),
560
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-primary-600", children: subtitle })
561
+ ] }),
562
+ /* @__PURE__ */ jsxRuntime.jsx(
563
+ Button,
564
+ {
565
+ type: "button",
566
+ variant: "primary",
567
+ size: "lg",
568
+ className: "w-full",
569
+ disabled,
570
+ iconLeft: /* @__PURE__ */ jsxRuntime.jsx(DocumentDownloadIcon.DocumentDownloadIcon, {}),
571
+ onClick: () => {
572
+ var _a2;
573
+ return (_a2 = inputRef.current) == null ? void 0 : _a2.click();
574
+ },
575
+ children: buttonLabel
576
+ }
577
+ ),
578
+ /* @__PURE__ */ jsxRuntime.jsx(
579
+ "input",
580
+ {
581
+ ref: inputRef,
582
+ type: "file",
583
+ hidden: true,
584
+ accept,
585
+ disabled,
586
+ onChange: handleChange
587
+ }
588
+ )
589
+ ]
590
+ })
591
+ );
592
+ }
593
+ );
594
+ FileUploadDropzone.displayName = "FileUploadDropzone";
595
+ function formatFileSize(bytes) {
596
+ if (bytes >= 1048576) return `${Math.round(bytes / 1048576)} MB`;
597
+ if (bytes >= 1024) return `${Math.round(bytes / 1024)} KB`;
598
+ return `${bytes} B`;
599
+ }
600
+ var FileUploadItem = React4__namespace.forwardRef(
601
+ (_a, ref) => {
602
+ var _b = _a, {
603
+ className,
604
+ name,
605
+ size,
606
+ status,
607
+ progress = 0,
608
+ errorMessage,
609
+ onDelete
610
+ } = _b, props = __objRest(_b, [
611
+ "className",
612
+ "name",
613
+ "size",
614
+ "status",
615
+ "progress",
616
+ "errorMessage",
617
+ "onDelete"
618
+ ]);
619
+ return /* @__PURE__ */ jsxRuntime.jsxs(
620
+ "div",
621
+ __spreadProps(__spreadValues({
622
+ ref,
623
+ className: cn(
624
+ "flex items-start gap-4 rounded-2xl border border-primary-300 bg-white p-4",
625
+ className
626
+ )
627
+ }, props), {
628
+ children: [
629
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-6", children: [
630
+ /* @__PURE__ */ jsxRuntime.jsx(
631
+ "div",
632
+ {
633
+ className: cn(
634
+ "flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",
635
+ status === "uploaded" ? "bg-secondary-200" : status === "error" ? "bg-red-200" : "bg-primary-100"
636
+ ),
637
+ children: /* @__PURE__ */ jsxRuntime.jsx(
638
+ DocumentTextIcon.DocumentTextIcon,
639
+ {
640
+ className: cn(
641
+ "h-5 w-5",
642
+ status === "uploaded" ? "text-secondary-900" : status === "error" ? "text-red-600" : "text-primary-600"
643
+ ),
644
+ "aria-hidden": "true"
645
+ }
646
+ )
647
+ }
648
+ ),
649
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: status === "uploading" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
650
+ /* @__PURE__ */ jsxRuntime.jsx(ProgressBar, { value: progress, label: name, showPercentage: true, size: "sm" }),
651
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-primary-600", children: formatFileSize(size) })
652
+ ] }) : status === "error" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
653
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-sm text-primary-1200", children: name }),
654
+ errorMessage && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-xs text-red-600", children: [
655
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Ops!" }),
656
+ /* @__PURE__ */ jsxRuntime.jsx(
657
+ "span",
658
+ {
659
+ className: "h-1 w-1 shrink-0 rounded-full bg-red-600",
660
+ "aria-hidden": "true"
661
+ }
662
+ ),
663
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: errorMessage })
664
+ ] })
665
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
666
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-sm text-primary-1200", children: name }),
667
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-primary-600", children: formatFileSize(size) })
668
+ ] }) })
669
+ ] }),
670
+ /* @__PURE__ */ jsxRuntime.jsx(
671
+ Button,
672
+ {
673
+ type: "button",
674
+ variant: "icon",
675
+ size: "md",
676
+ icon: /* @__PURE__ */ jsxRuntime.jsx(TrashIcon.TrashIcon, {}),
677
+ onClick: onDelete,
678
+ "aria-label": "Eliminar archivo"
679
+ }
680
+ )
681
+ ]
682
+ })
683
+ );
684
+ }
685
+ );
686
+ FileUploadItem.displayName = "FileUploadItem";
687
+ var FileUpload = React4__namespace.forwardRef(
688
+ (_a, ref) => {
689
+ var _b = _a, {
690
+ className,
691
+ files,
692
+ onSelect,
693
+ onDelete,
694
+ maxFiles = 1,
695
+ accept,
696
+ subtitle,
697
+ disabled = false,
698
+ recommendations
699
+ } = _b, props = __objRest(_b, [
700
+ "className",
701
+ "files",
702
+ "onSelect",
703
+ "onDelete",
704
+ "maxFiles",
705
+ "accept",
706
+ "subtitle",
707
+ "disabled",
708
+ "recommendations"
709
+ ]);
710
+ const showDropzone = files.length < maxFiles && !files.some((f) => f.status === "uploading");
711
+ return /* @__PURE__ */ jsxRuntime.jsxs(
712
+ "div",
713
+ __spreadProps(__spreadValues({
714
+ ref,
715
+ className: cn("flex flex-col gap-4", className)
716
+ }, props), {
717
+ children: [
718
+ recommendations && recommendations.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Alert, { variant: "neutral", className: "py-4", children: /* @__PURE__ */ jsxRuntime.jsx(AlertDescription, { children: recommendations.map((text, i) => /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
719
+ text,
720
+ i < recommendations.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("br", {})
721
+ ] }, i)) }) }),
722
+ showDropzone && /* @__PURE__ */ jsxRuntime.jsx(
723
+ FileUploadDropzone,
724
+ {
725
+ onSelect,
726
+ accept,
727
+ subtitle,
728
+ disabled
729
+ }
730
+ ),
731
+ files.map((file) => /* @__PURE__ */ jsxRuntime.jsx(
732
+ FileUploadItem,
733
+ {
734
+ name: file.name,
735
+ size: file.size,
736
+ status: file.status,
737
+ progress: file.progress,
738
+ errorMessage: file.errorMessage,
739
+ onDelete: () => onDelete(file.id)
740
+ },
741
+ file.id
742
+ ))
743
+ ]
744
+ })
745
+ );
746
+ }
747
+ );
748
+ FileUpload.displayName = "FileUpload";
749
+
750
+ exports.FileUpload = FileUpload;
751
+ exports.FileUploadDropzone = FileUploadDropzone;
752
+ exports.FileUploadItem = FileUploadItem;