@flipova/foundation 1.13.0 → 1.14.0

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,1396 @@
1
+ import { useTheme } from '../chunk-BO65GO53.mjs';
2
+ export { ThemeProvider, createTheme, useTheme } from '../chunk-BO65GO53.mjs';
3
+ import { radii, spacing } from '../chunk-BSVXX52E.mjs';
4
+ export { breakpoints, colors, motion, opacity, radii, shadows, spacing, typography, zIndex } from '../chunk-BSVXX52E.mjs';
5
+ import React, { useState } from 'react';
6
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
+ import * as LucideIcons from 'lucide-react';
8
+
9
+ // foundation/web/utils/themeUtils.ts
10
+ var resolveWebSpacing = (val) => {
11
+ if (val === void 0 || val === null) return void 0;
12
+ if (typeof val === "number") return `${val}px`;
13
+ if (typeof val === "string" && val in spacing) return `${spacing[val]}px`;
14
+ const namedMap = {
15
+ xs: 4,
16
+ sm: 8,
17
+ md: 16,
18
+ lg: 24,
19
+ xl: 32,
20
+ xxl: 48
21
+ };
22
+ if (typeof val === "string" && val in namedMap) return `${namedMap[val]}px`;
23
+ return val;
24
+ };
25
+ var resolveWebRadius = (val) => {
26
+ if (val === void 0 || val === null) return void 0;
27
+ if (typeof val === "number") return `${val}px`;
28
+ if (typeof val === "string" && val in radii) return `${radii[val]}px`;
29
+ return val;
30
+ };
31
+ var resolveWebColor = (theme, colorKey) => {
32
+ if (!colorKey) return theme.foreground;
33
+ if (colorKey === "text" || colorKey === "primaryText") return theme.foreground;
34
+ if (colorKey === "textMuted" || colorKey === "mutedText") return theme.mutedForeground;
35
+ if (colorKey === "surface" || colorKey === "card") return theme.card;
36
+ if (colorKey in theme) {
37
+ const val = theme[colorKey];
38
+ if (typeof val === "string") return val;
39
+ }
40
+ return colorKey;
41
+ };
42
+ var Box = React.forwardRef(
43
+ ({
44
+ padding,
45
+ p,
46
+ paddingTop,
47
+ pt,
48
+ paddingBottom,
49
+ pb,
50
+ paddingLeft,
51
+ pl,
52
+ paddingRight,
53
+ pr,
54
+ paddingHorizontal,
55
+ px,
56
+ paddingVertical,
57
+ py,
58
+ margin,
59
+ m,
60
+ marginTop,
61
+ mt,
62
+ marginBottom,
63
+ mb,
64
+ borderRadius,
65
+ bg,
66
+ backgroundColor,
67
+ borderWidth,
68
+ borderColor,
69
+ flex,
70
+ width,
71
+ height,
72
+ maxWidth,
73
+ maxHeight,
74
+ display,
75
+ position,
76
+ style,
77
+ children,
78
+ ...rest
79
+ }, ref) => {
80
+ const { theme } = useTheme();
81
+ const resolvedBg = bg || backgroundColor;
82
+ const finalBg = resolvedBg ? resolveWebColor(theme, resolvedBg) : void 0;
83
+ const finalBorderColor = borderColor ? resolveWebColor(theme, borderColor) : void 0;
84
+ const computedStyle = {
85
+ boxSizing: "border-box",
86
+ padding: resolveWebSpacing(padding ?? p),
87
+ paddingTop: resolveWebSpacing(paddingTop ?? pt ?? paddingVertical ?? py),
88
+ paddingBottom: resolveWebSpacing(paddingBottom ?? pb ?? paddingVertical ?? py),
89
+ paddingLeft: resolveWebSpacing(paddingLeft ?? pl ?? paddingHorizontal ?? px),
90
+ paddingRight: resolveWebSpacing(paddingRight ?? pr ?? paddingHorizontal ?? px),
91
+ margin: resolveWebSpacing(margin ?? m),
92
+ marginTop: resolveWebSpacing(marginTop ?? mt),
93
+ marginBottom: resolveWebSpacing(marginBottom ?? mb),
94
+ borderRadius: resolveWebRadius(borderRadius),
95
+ backgroundColor: finalBg,
96
+ borderWidth: typeof borderWidth === "number" ? `${borderWidth}px` : borderWidth,
97
+ borderColor: finalBorderColor,
98
+ borderStyle: borderWidth || borderColor ? "solid" : void 0,
99
+ flex,
100
+ width,
101
+ height,
102
+ maxWidth,
103
+ maxHeight,
104
+ display,
105
+ position,
106
+ ...style
107
+ };
108
+ return /* @__PURE__ */ jsx("div", { ref, style: computedStyle, ...rest, children });
109
+ }
110
+ );
111
+ Box.displayName = "Box";
112
+ var Stack = ({
113
+ gap,
114
+ align,
115
+ justify,
116
+ style,
117
+ children,
118
+ ...rest
119
+ }) => {
120
+ return /* @__PURE__ */ jsx(
121
+ Box,
122
+ {
123
+ style: {
124
+ display: "flex",
125
+ flexDirection: "column",
126
+ alignItems: align,
127
+ justifyContent: justify,
128
+ gap: resolveWebSpacing(gap),
129
+ ...style
130
+ },
131
+ ...rest,
132
+ children
133
+ }
134
+ );
135
+ };
136
+ var Inline = ({
137
+ gap,
138
+ align = "center",
139
+ justify,
140
+ wrap = false,
141
+ style,
142
+ children,
143
+ ...rest
144
+ }) => {
145
+ return /* @__PURE__ */ jsx(
146
+ Box,
147
+ {
148
+ style: {
149
+ display: "flex",
150
+ flexDirection: "row",
151
+ alignItems: align,
152
+ justifyContent: justify,
153
+ flexWrap: wrap ? "wrap" : "nowrap",
154
+ gap: resolveWebSpacing(gap),
155
+ ...style
156
+ },
157
+ ...rest,
158
+ children
159
+ }
160
+ );
161
+ };
162
+ var Center = ({ style, children, ...rest }) => /* @__PURE__ */ jsx(
163
+ Box,
164
+ {
165
+ style: {
166
+ display: "flex",
167
+ justifyContent: "center",
168
+ alignItems: "center",
169
+ ...style
170
+ },
171
+ ...rest,
172
+ children
173
+ }
174
+ );
175
+ var Scroll = ({
176
+ direction = "vertical",
177
+ hideScrollbar = false,
178
+ style,
179
+ children,
180
+ ...rest
181
+ }) => {
182
+ const overflowY = direction === "vertical" || direction === "both" ? "auto" : "hidden";
183
+ const overflowX = direction === "horizontal" || direction === "both" ? "auto" : "hidden";
184
+ return /* @__PURE__ */ jsx(
185
+ Box,
186
+ {
187
+ style: {
188
+ overflowY,
189
+ overflowX,
190
+ WebkitOverflowScrolling: "touch",
191
+ scrollbarWidth: hideScrollbar ? "none" : void 0,
192
+ msOverflowStyle: hideScrollbar ? "none" : void 0,
193
+ ...style
194
+ },
195
+ ...rest,
196
+ children
197
+ }
198
+ );
199
+ };
200
+ var Divider = ({
201
+ orientation = "horizontal",
202
+ color,
203
+ size = 1,
204
+ style
205
+ }) => {
206
+ const { theme } = useTheme();
207
+ const borderCol = color ? color in theme ? theme[color] : color : theme.border;
208
+ const isHorizontal = orientation === "horizontal";
209
+ return /* @__PURE__ */ jsx(
210
+ "div",
211
+ {
212
+ style: {
213
+ backgroundColor: borderCol,
214
+ width: isHorizontal ? "100%" : typeof size === "number" ? `${size}px` : size,
215
+ height: isHorizontal ? typeof size === "number" ? `${size}px` : size : "100%",
216
+ margin: 0,
217
+ padding: 0,
218
+ border: "none",
219
+ flexShrink: 0,
220
+ ...style
221
+ }
222
+ }
223
+ );
224
+ };
225
+ var Button = ({
226
+ label,
227
+ variant = "primary",
228
+ size = "md",
229
+ loading = false,
230
+ disabled = false,
231
+ fullWidth = false,
232
+ leftIcon,
233
+ rightIcon,
234
+ style,
235
+ children,
236
+ ...rest
237
+ }) => {
238
+ const { theme } = useTheme();
239
+ const sizeMap = {
240
+ sm: { padding: "4px 12px", fontSize: "13px", height: "32px" },
241
+ md: { padding: "8px 16px", fontSize: "14px", height: "40px" },
242
+ lg: { padding: "12px 24px", fontSize: "16px", height: "48px" }
243
+ };
244
+ const currentSize = sizeMap[size] || sizeMap.md;
245
+ const getVariantStyles = () => {
246
+ switch (variant) {
247
+ case "secondary":
248
+ return {
249
+ backgroundColor: theme.secondary,
250
+ color: theme.secondaryForeground,
251
+ border: "none"
252
+ };
253
+ case "outline":
254
+ return {
255
+ backgroundColor: "transparent",
256
+ color: theme.foreground,
257
+ border: `1px solid ${theme.border}`
258
+ };
259
+ case "ghost":
260
+ return {
261
+ backgroundColor: "transparent",
262
+ color: theme.foreground,
263
+ border: "none"
264
+ };
265
+ case "destructive":
266
+ return {
267
+ backgroundColor: theme.destructive,
268
+ color: theme.destructiveForeground,
269
+ border: "none"
270
+ };
271
+ case "primary":
272
+ default:
273
+ return {
274
+ backgroundColor: theme.primary,
275
+ color: theme.primaryForeground,
276
+ border: "none"
277
+ };
278
+ }
279
+ };
280
+ const variantStyle = getVariantStyles();
281
+ return /* @__PURE__ */ jsx(
282
+ "button",
283
+ {
284
+ disabled: disabled || loading,
285
+ style: {
286
+ display: "inline-flex",
287
+ alignItems: "center",
288
+ justifyContent: "center",
289
+ gap: "6px",
290
+ borderRadius: resolveWebRadius("md") || "8px",
291
+ fontWeight: 600,
292
+ fontFamily: "inherit",
293
+ cursor: disabled || loading ? "not-allowed" : "pointer",
294
+ opacity: disabled ? 0.6 : 1,
295
+ transition: "all 0.15s ease-in-out",
296
+ width: fullWidth ? "100%" : "auto",
297
+ ...currentSize,
298
+ ...variantStyle,
299
+ ...style
300
+ },
301
+ ...rest,
302
+ children: loading ? /* @__PURE__ */ jsx(
303
+ "span",
304
+ {
305
+ style: {
306
+ width: "16px",
307
+ height: "16px",
308
+ border: "2px solid currentColor",
309
+ borderRightColor: "transparent",
310
+ borderRadius: "50%",
311
+ display: "inline-block",
312
+ animation: "spin 0.6s linear infinite"
313
+ }
314
+ }
315
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
316
+ leftIcon,
317
+ children || label,
318
+ rightIcon
319
+ ] })
320
+ }
321
+ );
322
+ };
323
+ var Text = ({
324
+ variant = "body",
325
+ size,
326
+ weight,
327
+ color = "primary",
328
+ align,
329
+ as,
330
+ style,
331
+ children,
332
+ ...rest
333
+ }) => {
334
+ const { theme } = useTheme();
335
+ const resolveColor = () => {
336
+ if (color === "primary") return theme.foreground;
337
+ if (color === "secondary") return theme.secondary;
338
+ if (color === "muted") return theme.mutedForeground;
339
+ if (color === "error") return theme.error;
340
+ if (color === "success") return theme.success;
341
+ return resolveWebColor(theme, color);
342
+ };
343
+ const getVariantStyles = () => {
344
+ switch (variant) {
345
+ case "heading":
346
+ return { fontSize: size ? getSize(size) : "24px", fontWeight: 700, Component: as || "h2" };
347
+ case "subheading":
348
+ return { fontSize: size ? getSize(size) : "18px", fontWeight: 600, Component: as || "h3" };
349
+ case "caption":
350
+ return { fontSize: size ? getSize(size) : "12px", fontWeight: 400, Component: as || "span" };
351
+ case "code":
352
+ return { fontSize: size ? getSize(size) : "13px", fontWeight: 400, Component: as || "code" };
353
+ case "label":
354
+ return { fontSize: size ? getSize(size) : "14px", fontWeight: 600, Component: as || "label" };
355
+ case "body":
356
+ default:
357
+ return { fontSize: size ? getSize(size) : "14px", fontWeight: 400, Component: as || "p" };
358
+ }
359
+ };
360
+ const getSize = (s) => {
361
+ const map = {
362
+ xs: "11px",
363
+ sm: "13px",
364
+ md: "15px",
365
+ lg: "18px",
366
+ xl: "24px",
367
+ xxl: "32px"
368
+ };
369
+ return map[s] || "14px";
370
+ };
371
+ const weightMap = {
372
+ light: 300,
373
+ regular: 400,
374
+ medium: 500,
375
+ semibold: 600,
376
+ bold: 700
377
+ };
378
+ const variantInfo = getVariantStyles();
379
+ const Tag = variantInfo.Component;
380
+ return /* @__PURE__ */ jsx(
381
+ Tag,
382
+ {
383
+ style: {
384
+ margin: 0,
385
+ padding: 0,
386
+ color: resolveColor(),
387
+ fontSize: variantInfo.fontSize,
388
+ fontWeight: weight ? weightMap[weight] : variantInfo.fontWeight,
389
+ fontFamily: variant === "code" ? "monospace" : "inherit",
390
+ textAlign: align,
391
+ ...style
392
+ },
393
+ ...rest,
394
+ children
395
+ }
396
+ );
397
+ };
398
+ var Card = ({
399
+ padding = "lg",
400
+ borderRadius = "md",
401
+ bordered = true,
402
+ elevation = "none",
403
+ style,
404
+ children,
405
+ ...rest
406
+ }) => {
407
+ const { theme } = useTheme();
408
+ const paddingVal = resolveWebSpacing(padding) || "16px";
409
+ const radiusVal = resolveWebRadius(borderRadius) || "8px";
410
+ const shadowMap = {
411
+ none: "none",
412
+ sm: "0 1px 3px rgba(0,0,0,0.1)",
413
+ md: "0 4px 6px rgba(0,0,0,0.1)",
414
+ lg: "0 10px 15px rgba(0,0,0,0.1)"
415
+ };
416
+ return /* @__PURE__ */ jsx(
417
+ "div",
418
+ {
419
+ style: {
420
+ backgroundColor: theme.card,
421
+ color: theme.foreground,
422
+ padding: paddingVal,
423
+ borderRadius: radiusVal,
424
+ border: bordered ? `1px solid ${theme.border}` : "none",
425
+ boxShadow: shadowMap[elevation],
426
+ boxSizing: "border-box",
427
+ ...style
428
+ },
429
+ ...rest,
430
+ children
431
+ }
432
+ );
433
+ };
434
+ var Badge = ({
435
+ label,
436
+ variant = "primary",
437
+ size = "md",
438
+ style,
439
+ children,
440
+ ...rest
441
+ }) => {
442
+ const { theme } = useTheme();
443
+ const getVariantStyles = () => {
444
+ switch (variant) {
445
+ case "secondary":
446
+ return { backgroundColor: theme.secondary, color: theme.secondaryForeground, border: "none" };
447
+ case "success":
448
+ return { backgroundColor: theme.success, color: "#ffffff", border: "none" };
449
+ case "warning":
450
+ return { backgroundColor: theme.warning, color: "#ffffff", border: "none" };
451
+ case "error":
452
+ return { backgroundColor: theme.error, color: "#ffffff", border: "none" };
453
+ case "outline":
454
+ return { backgroundColor: "transparent", color: theme.foreground, border: `1px solid ${theme.border}` };
455
+ case "primary":
456
+ default:
457
+ return { backgroundColor: theme.primary, color: theme.primaryForeground, border: "none" };
458
+ }
459
+ };
460
+ const isSmall = size === "sm";
461
+ return /* @__PURE__ */ jsx(
462
+ "span",
463
+ {
464
+ style: {
465
+ display: "inline-flex",
466
+ alignItems: "center",
467
+ justifyContent: "center",
468
+ padding: isSmall ? "2px 8px" : "4px 10px",
469
+ fontSize: isSmall ? "11px" : "12px",
470
+ fontWeight: 600,
471
+ borderRadius: "9999px",
472
+ lineHeight: 1,
473
+ whiteSpace: "nowrap",
474
+ ...getVariantStyles(),
475
+ ...style
476
+ },
477
+ ...rest,
478
+ children: children || label
479
+ }
480
+ );
481
+ };
482
+ var Avatar = ({
483
+ src,
484
+ name,
485
+ size = "md",
486
+ shape = "circle",
487
+ style
488
+ }) => {
489
+ const { theme } = useTheme();
490
+ const getSizePx = () => {
491
+ if (typeof size === "number") return size;
492
+ const map = { sm: 32, md: 40, lg: 56, xl: 72 };
493
+ return map[size] || 40;
494
+ };
495
+ const dim = getSizePx();
496
+ const getInitials = (n) => {
497
+ if (!n) return "?";
498
+ const parts = n.trim().split(" ");
499
+ if (parts.length >= 2) return `${parts[0][0]}${parts[1][0]}`.toUpperCase();
500
+ return n.slice(0, 2).toUpperCase();
501
+ };
502
+ return /* @__PURE__ */ jsx(
503
+ "div",
504
+ {
505
+ style: {
506
+ width: `${dim}px`,
507
+ height: `${dim}px`,
508
+ borderRadius: shape === "circle" ? "50%" : "8px",
509
+ backgroundColor: theme.primary,
510
+ color: theme.primaryForeground,
511
+ display: "inline-flex",
512
+ alignItems: "center",
513
+ justifyContent: "center",
514
+ fontWeight: 600,
515
+ fontSize: `${Math.round(dim * 0.4)}px`,
516
+ overflow: "hidden",
517
+ flexShrink: 0,
518
+ ...style
519
+ },
520
+ children: src ? /* @__PURE__ */ jsx(
521
+ "img",
522
+ {
523
+ src,
524
+ alt: name || "Avatar",
525
+ style: { width: "100%", height: "100%", objectFit: "cover" }
526
+ }
527
+ ) : getInitials(name)
528
+ }
529
+ );
530
+ };
531
+ var TextInput = ({
532
+ label,
533
+ error,
534
+ helperText,
535
+ leftIcon,
536
+ rightIcon,
537
+ containerStyle,
538
+ style,
539
+ disabled,
540
+ ...rest
541
+ }) => {
542
+ const { theme } = useTheme();
543
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "4px", width: "100%", ...containerStyle }, children: [
544
+ label && /* @__PURE__ */ jsx("label", { style: { fontSize: "13px", fontWeight: 600, color: theme.foreground }, children: label }),
545
+ /* @__PURE__ */ jsxs(
546
+ "div",
547
+ {
548
+ style: {
549
+ display: "flex",
550
+ alignItems: "center",
551
+ gap: "8px",
552
+ padding: "0 12px",
553
+ height: "40px",
554
+ borderRadius: "8px",
555
+ border: `1px solid ${error ? theme.error : theme.border}`,
556
+ backgroundColor: theme.card,
557
+ color: theme.foreground,
558
+ opacity: disabled ? 0.6 : 1,
559
+ boxSizing: "border-box"
560
+ },
561
+ children: [
562
+ leftIcon,
563
+ /* @__PURE__ */ jsx(
564
+ "input",
565
+ {
566
+ disabled,
567
+ style: {
568
+ flex: 1,
569
+ border: "none",
570
+ outline: "none",
571
+ backgroundColor: "transparent",
572
+ color: "inherit",
573
+ fontSize: "14px",
574
+ fontFamily: "inherit",
575
+ width: "100%",
576
+ ...style
577
+ },
578
+ ...rest
579
+ }
580
+ ),
581
+ rightIcon
582
+ ]
583
+ }
584
+ ),
585
+ (error || helperText) && /* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: error ? theme.error : theme.mutedForeground }, children: error || helperText })
586
+ ] });
587
+ };
588
+ var TextArea = ({
589
+ label,
590
+ error,
591
+ helperText,
592
+ containerStyle,
593
+ style,
594
+ disabled,
595
+ rows = 4,
596
+ ...rest
597
+ }) => {
598
+ const { theme } = useTheme();
599
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "4px", width: "100%", ...containerStyle }, children: [
600
+ label && /* @__PURE__ */ jsx("label", { style: { fontSize: "13px", fontWeight: 600, color: theme.foreground }, children: label }),
601
+ /* @__PURE__ */ jsx(
602
+ "textarea",
603
+ {
604
+ disabled,
605
+ rows,
606
+ style: {
607
+ width: "100%",
608
+ padding: "12px",
609
+ borderRadius: "8px",
610
+ border: `1px solid ${error ? theme.error : theme.border}`,
611
+ backgroundColor: theme.card,
612
+ color: theme.foreground,
613
+ fontSize: "14px",
614
+ fontFamily: "inherit",
615
+ outline: "none",
616
+ resize: "vertical",
617
+ opacity: disabled ? 0.6 : 1,
618
+ boxSizing: "border-box",
619
+ ...style
620
+ },
621
+ ...rest
622
+ }
623
+ ),
624
+ (error || helperText) && /* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: error ? theme.error : theme.mutedForeground }, children: error || helperText })
625
+ ] });
626
+ };
627
+ var Select = ({
628
+ label,
629
+ options = [],
630
+ error,
631
+ containerStyle,
632
+ style,
633
+ disabled,
634
+ children,
635
+ ...rest
636
+ }) => {
637
+ const { theme } = useTheme();
638
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "4px", width: "100%", ...containerStyle }, children: [
639
+ label && /* @__PURE__ */ jsx("label", { style: { fontSize: "13px", fontWeight: 600, color: theme.foreground }, children: label }),
640
+ /* @__PURE__ */ jsxs(
641
+ "select",
642
+ {
643
+ disabled,
644
+ style: {
645
+ width: "100%",
646
+ height: "40px",
647
+ padding: "0 12px",
648
+ borderRadius: "8px",
649
+ border: `1px solid ${error ? theme.error : theme.border}`,
650
+ backgroundColor: theme.card,
651
+ color: theme.foreground,
652
+ fontSize: "14px",
653
+ fontFamily: "inherit",
654
+ outline: "none",
655
+ cursor: disabled ? "not-allowed" : "pointer",
656
+ opacity: disabled ? 0.6 : 1,
657
+ boxSizing: "border-box",
658
+ ...style
659
+ },
660
+ ...rest,
661
+ children: [
662
+ options.map((opt) => /* @__PURE__ */ jsx("option", { value: opt.value, children: opt.label }, opt.value)),
663
+ children
664
+ ]
665
+ }
666
+ ),
667
+ error && /* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: theme.error }, children: error })
668
+ ] });
669
+ };
670
+ var Checkbox = ({
671
+ label,
672
+ checked,
673
+ onCheckedChange,
674
+ onChange,
675
+ disabled,
676
+ style,
677
+ ...rest
678
+ }) => {
679
+ const { theme } = useTheme();
680
+ const handleChange = (e) => {
681
+ onChange?.(e);
682
+ onCheckedChange?.(e.target.checked);
683
+ };
684
+ return /* @__PURE__ */ jsxs(
685
+ "label",
686
+ {
687
+ style: {
688
+ display: "inline-flex",
689
+ alignItems: "center",
690
+ gap: "6px",
691
+ cursor: disabled ? "not-allowed" : "pointer",
692
+ opacity: disabled ? 0.6 : 1,
693
+ fontSize: "14px",
694
+ color: theme.foreground,
695
+ userSelect: "none",
696
+ ...style
697
+ },
698
+ children: [
699
+ /* @__PURE__ */ jsx(
700
+ "input",
701
+ {
702
+ type: "checkbox",
703
+ checked,
704
+ disabled,
705
+ onChange: handleChange,
706
+ style: {
707
+ width: "18px",
708
+ height: "18px",
709
+ accentColor: theme.primary,
710
+ cursor: "inherit",
711
+ borderRadius: "4px"
712
+ },
713
+ ...rest
714
+ }
715
+ ),
716
+ label && /* @__PURE__ */ jsx("span", { children: label })
717
+ ]
718
+ }
719
+ );
720
+ };
721
+ var Switch = ({
722
+ checked = false,
723
+ onCheckedChange,
724
+ disabled = false,
725
+ label,
726
+ style
727
+ }) => {
728
+ const { theme } = useTheme();
729
+ return /* @__PURE__ */ jsxs(
730
+ "label",
731
+ {
732
+ style: {
733
+ display: "inline-flex",
734
+ alignItems: "center",
735
+ gap: "8px",
736
+ cursor: disabled ? "not-allowed" : "pointer",
737
+ opacity: disabled ? 0.6 : 1,
738
+ userSelect: "none",
739
+ ...style
740
+ },
741
+ children: [
742
+ /* @__PURE__ */ jsx(
743
+ "div",
744
+ {
745
+ onClick: () => !disabled && onCheckedChange?.(!checked),
746
+ style: {
747
+ width: "40px",
748
+ height: "22px",
749
+ borderRadius: "11px",
750
+ backgroundColor: checked ? theme.primary : theme.border,
751
+ position: "relative",
752
+ transition: "background-color 0.2s ease",
753
+ padding: "2px",
754
+ boxSizing: "border-box"
755
+ },
756
+ children: /* @__PURE__ */ jsx(
757
+ "div",
758
+ {
759
+ style: {
760
+ width: "18px",
761
+ height: "18px",
762
+ borderRadius: "50%",
763
+ backgroundColor: "#ffffff",
764
+ transform: checked ? "translateX(18px)" : "translateX(0)",
765
+ transition: "transform 0.2s ease",
766
+ boxShadow: "0 1px 3px rgba(0,0,0,0.2)"
767
+ }
768
+ }
769
+ )
770
+ }
771
+ ),
772
+ label && /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", color: theme.foreground }, children: label })
773
+ ]
774
+ }
775
+ );
776
+ };
777
+ var Spinner = ({
778
+ size = "md",
779
+ color,
780
+ style
781
+ }) => {
782
+ const { theme } = useTheme();
783
+ const getSizePx = () => {
784
+ if (typeof size === "number") return size;
785
+ const map = { sm: 16, md: 24, lg: 36 };
786
+ return map[size] || 24;
787
+ };
788
+ const dim = getSizePx();
789
+ const strokeCol = color ? color in theme ? theme[color] : color : theme.primary;
790
+ return /* @__PURE__ */ jsx(
791
+ "svg",
792
+ {
793
+ width: dim,
794
+ height: dim,
795
+ viewBox: "0 0 24 24",
796
+ fill: "none",
797
+ stroke: strokeCol,
798
+ strokeWidth: "3",
799
+ strokeLinecap: "round",
800
+ strokeLinejoin: "round",
801
+ style: {
802
+ animation: "spin 0.8s linear infinite",
803
+ ...style
804
+ },
805
+ children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
806
+ }
807
+ );
808
+ };
809
+ var Icon = ({
810
+ name,
811
+ size = 20,
812
+ color,
813
+ style,
814
+ ...rest
815
+ }) => {
816
+ const { theme } = useTheme();
817
+ const iconColor = color ? resolveWebColor(theme, color) : theme.foreground;
818
+ const formatName = (str) => str.replace(/(^\w|-\w|_\w)/g, (m) => m.replace(/[-_]/, "").toUpperCase());
819
+ const pascalName = formatName(name);
820
+ const IconComponent = LucideIcons[pascalName] || LucideIcons.HelpCircle;
821
+ return /* @__PURE__ */ jsx(IconComponent, { size, color: iconColor, style, ...rest });
822
+ };
823
+ var IconButton = ({
824
+ name,
825
+ size = "md",
826
+ variant = "ghost",
827
+ disabled = false,
828
+ style,
829
+ ...rest
830
+ }) => {
831
+ const { theme } = useTheme();
832
+ const dimMap = { sm: 32, md: 40, lg: 48 };
833
+ const iconSizeMap = { sm: 16, md: 20, lg: 24 };
834
+ const dim = dimMap[size];
835
+ const iconSize = iconSizeMap[size];
836
+ const getVariantStyle = () => {
837
+ switch (variant) {
838
+ case "primary":
839
+ return { backgroundColor: theme.primary, color: theme.primaryForeground, border: "none" };
840
+ case "secondary":
841
+ return { backgroundColor: theme.secondary, color: theme.secondaryForeground, border: "none" };
842
+ case "outline":
843
+ return { backgroundColor: "transparent", color: theme.foreground, border: `1px solid ${theme.border}` };
844
+ case "ghost":
845
+ default:
846
+ return { backgroundColor: "transparent", color: theme.foreground, border: "none" };
847
+ }
848
+ };
849
+ return /* @__PURE__ */ jsx(
850
+ "button",
851
+ {
852
+ disabled,
853
+ style: {
854
+ width: `${dim}px`,
855
+ height: `${dim}px`,
856
+ borderRadius: "8px",
857
+ display: "inline-flex",
858
+ alignItems: "center",
859
+ justifyContent: "center",
860
+ cursor: disabled ? "not-allowed" : "pointer",
861
+ opacity: disabled ? 0.5 : 1,
862
+ transition: "background-color 0.15s ease",
863
+ boxSizing: "border-box",
864
+ ...getVariantStyle(),
865
+ ...style
866
+ },
867
+ ...rest,
868
+ children: /* @__PURE__ */ jsx(Icon, { name, size: iconSize, color: "currentColor" })
869
+ }
870
+ );
871
+ };
872
+ var Tabs = ({
873
+ items,
874
+ activeId,
875
+ onChange,
876
+ style
877
+ }) => {
878
+ const { theme } = useTheme();
879
+ return /* @__PURE__ */ jsx(
880
+ "div",
881
+ {
882
+ style: {
883
+ display: "flex",
884
+ alignItems: "center",
885
+ gap: "8px",
886
+ borderBottom: `1px solid ${theme.border}`,
887
+ ...style
888
+ },
889
+ children: items.map((tab) => {
890
+ const isActive = tab.id === activeId;
891
+ return /* @__PURE__ */ jsxs(
892
+ "button",
893
+ {
894
+ onClick: () => onChange(tab.id),
895
+ style: {
896
+ display: "inline-flex",
897
+ alignItems: "center",
898
+ gap: "4px",
899
+ padding: "8px 16px",
900
+ fontSize: "14px",
901
+ fontWeight: isActive ? 600 : 400,
902
+ color: isActive ? theme.primary : theme.mutedForeground,
903
+ border: "none",
904
+ borderBottom: `2px solid ${isActive ? theme.primary : "transparent"}`,
905
+ backgroundColor: "transparent",
906
+ cursor: "pointer",
907
+ marginBottom: "-1px",
908
+ transition: "all 0.15s ease"
909
+ },
910
+ children: [
911
+ tab.icon,
912
+ tab.label
913
+ ]
914
+ },
915
+ tab.id
916
+ );
917
+ })
918
+ }
919
+ );
920
+ };
921
+ var ProgressBar = ({
922
+ progress,
923
+ color,
924
+ height = 8,
925
+ style
926
+ }) => {
927
+ const { theme } = useTheme();
928
+ const clamped = Math.min(Math.max(progress, 0), 100);
929
+ const barColor = color ? color in theme ? theme[color] : color : theme.primary;
930
+ return /* @__PURE__ */ jsx(
931
+ "div",
932
+ {
933
+ style: {
934
+ width: "100%",
935
+ height: `${height}px`,
936
+ backgroundColor: theme.border,
937
+ borderRadius: `${height / 2}px`,
938
+ overflow: "hidden",
939
+ ...style
940
+ },
941
+ children: /* @__PURE__ */ jsx(
942
+ "div",
943
+ {
944
+ style: {
945
+ width: `${clamped}%`,
946
+ height: "100%",
947
+ backgroundColor: barColor,
948
+ transition: "width 0.3s ease"
949
+ }
950
+ }
951
+ )
952
+ }
953
+ );
954
+ };
955
+ var Accordion = ({
956
+ title,
957
+ defaultOpen = false,
958
+ children,
959
+ style
960
+ }) => {
961
+ const { theme } = useTheme();
962
+ const [isOpen, setIsOpen] = useState(defaultOpen);
963
+ return /* @__PURE__ */ jsxs(
964
+ "div",
965
+ {
966
+ style: {
967
+ border: `1px solid ${theme.border}`,
968
+ borderRadius: "8px",
969
+ overflow: "hidden",
970
+ backgroundColor: theme.card,
971
+ ...style
972
+ },
973
+ children: [
974
+ /* @__PURE__ */ jsxs(
975
+ "button",
976
+ {
977
+ onClick: () => setIsOpen(!isOpen),
978
+ style: {
979
+ width: "100%",
980
+ display: "flex",
981
+ alignItems: "center",
982
+ justifyContent: "space-between",
983
+ padding: "16px",
984
+ backgroundColor: "transparent",
985
+ border: "none",
986
+ color: theme.foreground,
987
+ fontSize: "14px",
988
+ fontWeight: 600,
989
+ cursor: "pointer",
990
+ textAlign: "left"
991
+ },
992
+ children: [
993
+ /* @__PURE__ */ jsx("span", { children: title }),
994
+ /* @__PURE__ */ jsx(
995
+ "span",
996
+ {
997
+ style: {
998
+ transform: isOpen ? "rotate(180deg)" : "rotate(0deg)",
999
+ transition: "transform 0.2s ease"
1000
+ },
1001
+ children: "\u25BC"
1002
+ }
1003
+ )
1004
+ ]
1005
+ }
1006
+ ),
1007
+ isOpen && /* @__PURE__ */ jsx("div", { style: { padding: "16px", borderTop: `1px solid ${theme.border}` }, children })
1008
+ ]
1009
+ }
1010
+ );
1011
+ };
1012
+ var Chip = ({
1013
+ label,
1014
+ onDismiss,
1015
+ onClick,
1016
+ style
1017
+ }) => {
1018
+ const { theme } = useTheme();
1019
+ return /* @__PURE__ */ jsxs(
1020
+ "span",
1021
+ {
1022
+ onClick,
1023
+ style: {
1024
+ display: "inline-flex",
1025
+ alignItems: "center",
1026
+ gap: resolveWebSpacing("xs") || "4px",
1027
+ padding: `4px ${resolveWebSpacing("sm") || "8px"}`,
1028
+ fontSize: "12px",
1029
+ fontWeight: 500,
1030
+ borderRadius: resolveWebRadius("full") || "9999px",
1031
+ backgroundColor: theme.secondary,
1032
+ color: theme.secondaryForeground,
1033
+ cursor: onClick ? "pointer" : "default",
1034
+ userSelect: "none",
1035
+ ...style
1036
+ },
1037
+ children: [
1038
+ label,
1039
+ onDismiss && /* @__PURE__ */ jsx(
1040
+ "button",
1041
+ {
1042
+ onClick: (e) => {
1043
+ e.stopPropagation();
1044
+ onDismiss();
1045
+ },
1046
+ style: {
1047
+ border: "none",
1048
+ background: "transparent",
1049
+ color: "inherit",
1050
+ cursor: "pointer",
1051
+ padding: 0,
1052
+ fontSize: "12px",
1053
+ lineHeight: 1
1054
+ },
1055
+ children: "\u2715"
1056
+ }
1057
+ )
1058
+ ]
1059
+ }
1060
+ );
1061
+ };
1062
+ var Separator = (props) => /* @__PURE__ */ jsx(Divider, { ...props });
1063
+ var Image = ({
1064
+ src,
1065
+ alt = "",
1066
+ aspectRatio,
1067
+ borderRadius,
1068
+ style,
1069
+ ...rest
1070
+ }) => {
1071
+ return /* @__PURE__ */ jsx(
1072
+ "img",
1073
+ {
1074
+ src,
1075
+ alt,
1076
+ style: {
1077
+ width: "100%",
1078
+ height: aspectRatio ? "auto" : "100%",
1079
+ aspectRatio: aspectRatio ? `${aspectRatio}` : void 0,
1080
+ borderRadius: typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
1081
+ objectFit: "cover",
1082
+ display: "block",
1083
+ ...style
1084
+ },
1085
+ ...rest
1086
+ }
1087
+ );
1088
+ };
1089
+ var Video = ({
1090
+ src,
1091
+ poster,
1092
+ borderRadius,
1093
+ controls = true,
1094
+ autoPlay = false,
1095
+ loop = false,
1096
+ style,
1097
+ ...rest
1098
+ }) => {
1099
+ return /* @__PURE__ */ jsx(
1100
+ "video",
1101
+ {
1102
+ src,
1103
+ poster,
1104
+ controls,
1105
+ autoPlay,
1106
+ loop,
1107
+ style: {
1108
+ width: "100%",
1109
+ height: "auto",
1110
+ borderRadius: typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
1111
+ display: "block",
1112
+ ...style
1113
+ },
1114
+ ...rest
1115
+ }
1116
+ );
1117
+ };
1118
+ var RootLayout = ({ children, style }) => {
1119
+ const { theme } = useTheme();
1120
+ return /* @__PURE__ */ jsx(
1121
+ "div",
1122
+ {
1123
+ style: {
1124
+ minHeight: "100vh",
1125
+ width: "100%",
1126
+ backgroundColor: theme.background,
1127
+ color: theme.foreground,
1128
+ margin: 0,
1129
+ padding: 0,
1130
+ boxSizing: "border-box",
1131
+ ...style
1132
+ },
1133
+ children
1134
+ }
1135
+ );
1136
+ };
1137
+ var AuthLayout = ({
1138
+ title,
1139
+ subtitle,
1140
+ logo,
1141
+ children,
1142
+ style
1143
+ }) => {
1144
+ const { theme } = useTheme();
1145
+ return /* @__PURE__ */ jsx(
1146
+ "div",
1147
+ {
1148
+ style: {
1149
+ minHeight: "100vh",
1150
+ width: "100%",
1151
+ display: "flex",
1152
+ alignItems: "center",
1153
+ justifyContent: "center",
1154
+ backgroundColor: theme.background,
1155
+ padding: "24px",
1156
+ boxSizing: "border-box",
1157
+ ...style
1158
+ },
1159
+ children: /* @__PURE__ */ jsxs(
1160
+ "div",
1161
+ {
1162
+ style: {
1163
+ width: "100%",
1164
+ maxWidth: "420px",
1165
+ backgroundColor: theme.card,
1166
+ borderRadius: "16px",
1167
+ border: `1px solid ${theme.border}`,
1168
+ padding: "32px",
1169
+ boxSizing: "border-box"
1170
+ },
1171
+ children: [
1172
+ logo && /* @__PURE__ */ jsx("div", { style: { display: "flex", justifyContent: "center", marginBottom: "24px" }, children: logo }),
1173
+ title && /* @__PURE__ */ jsx("h1", { style: { margin: "0 0 8px 0", fontSize: "24px", fontWeight: 700, color: theme.foreground, textAlign: "center" }, children: title }),
1174
+ subtitle && /* @__PURE__ */ jsx("p", { style: { margin: "0 0 24px 0", fontSize: "14px", color: theme.mutedForeground, textAlign: "center" }, children: subtitle }),
1175
+ children
1176
+ ]
1177
+ }
1178
+ )
1179
+ }
1180
+ );
1181
+ };
1182
+ var DashboardLayout = ({
1183
+ sidebar,
1184
+ header,
1185
+ children,
1186
+ sidebarWidth = 260,
1187
+ headerHeight = 64,
1188
+ style
1189
+ }) => {
1190
+ const { theme } = useTheme();
1191
+ const widthVal = typeof sidebarWidth === "number" ? `${sidebarWidth}px` : sidebarWidth;
1192
+ const heightVal = typeof headerHeight === "number" ? `${headerHeight}px` : headerHeight;
1193
+ return /* @__PURE__ */ jsxs(
1194
+ "div",
1195
+ {
1196
+ style: {
1197
+ display: "flex",
1198
+ minHeight: "100vh",
1199
+ width: "100%",
1200
+ backgroundColor: theme.background,
1201
+ color: theme.foreground,
1202
+ ...style
1203
+ },
1204
+ children: [
1205
+ sidebar && /* @__PURE__ */ jsx(
1206
+ "aside",
1207
+ {
1208
+ style: {
1209
+ width: widthVal,
1210
+ flexShrink: 0,
1211
+ borderRight: `1px solid ${theme.border}`,
1212
+ backgroundColor: theme.card
1213
+ },
1214
+ children: sidebar
1215
+ }
1216
+ ),
1217
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1, display: "flex", flexDirection: "column", minWidth: 0 }, children: [
1218
+ header && /* @__PURE__ */ jsx(
1219
+ "header",
1220
+ {
1221
+ style: {
1222
+ height: heightVal,
1223
+ flexShrink: 0,
1224
+ borderBottom: `1px solid ${theme.border}`,
1225
+ backgroundColor: theme.card,
1226
+ display: "flex",
1227
+ alignItems: "center",
1228
+ padding: "0 24px"
1229
+ },
1230
+ children: header
1231
+ }
1232
+ ),
1233
+ /* @__PURE__ */ jsx("main", { style: { flex: 1, padding: "24px", overflowY: "auto" }, children })
1234
+ ] })
1235
+ ]
1236
+ }
1237
+ );
1238
+ };
1239
+ var SidebarLayout = ({
1240
+ sidebar,
1241
+ sidebarPosition = "left",
1242
+ width = 280,
1243
+ children,
1244
+ style
1245
+ }) => {
1246
+ const { theme } = useTheme();
1247
+ const widthVal = typeof width === "number" ? `${width}px` : width;
1248
+ return /* @__PURE__ */ jsxs(
1249
+ "div",
1250
+ {
1251
+ style: {
1252
+ display: "flex",
1253
+ flexDirection: sidebarPosition === "left" ? "row" : "row-reverse",
1254
+ width: "100%",
1255
+ minHeight: "100vh",
1256
+ backgroundColor: theme.background,
1257
+ ...style
1258
+ },
1259
+ children: [
1260
+ /* @__PURE__ */ jsx(
1261
+ "aside",
1262
+ {
1263
+ style: {
1264
+ width: widthVal,
1265
+ flexShrink: 0,
1266
+ backgroundColor: theme.card,
1267
+ borderRight: sidebarPosition === "left" ? `1px solid ${theme.border}` : "none",
1268
+ borderLeft: sidebarPosition === "right" ? `1px solid ${theme.border}` : "none"
1269
+ },
1270
+ children: sidebar
1271
+ }
1272
+ ),
1273
+ /* @__PURE__ */ jsx("main", { style: { flex: 1, minWidth: 0, padding: "24px" }, children })
1274
+ ]
1275
+ }
1276
+ );
1277
+ };
1278
+ var HeaderContentLayout = ({
1279
+ header,
1280
+ children,
1281
+ headerHeight = 64,
1282
+ style
1283
+ }) => {
1284
+ const { theme } = useTheme();
1285
+ const heightVal = typeof headerHeight === "number" ? `${headerHeight}px` : headerHeight;
1286
+ return /* @__PURE__ */ jsxs(
1287
+ "div",
1288
+ {
1289
+ style: {
1290
+ display: "flex",
1291
+ flexDirection: "column",
1292
+ minHeight: "100vh",
1293
+ width: "100%",
1294
+ backgroundColor: theme.background,
1295
+ ...style
1296
+ },
1297
+ children: [
1298
+ /* @__PURE__ */ jsx(
1299
+ "header",
1300
+ {
1301
+ style: {
1302
+ height: heightVal,
1303
+ borderBottom: `1px solid ${theme.border}`,
1304
+ backgroundColor: theme.card,
1305
+ display: "flex",
1306
+ alignItems: "center",
1307
+ padding: "0 24px",
1308
+ flexShrink: 0
1309
+ },
1310
+ children: header
1311
+ }
1312
+ ),
1313
+ /* @__PURE__ */ jsx("main", { style: { flex: 1, padding: "24px" }, children })
1314
+ ]
1315
+ }
1316
+ );
1317
+ };
1318
+ var CenteredLayout = ({
1319
+ maxWidth = 1200,
1320
+ children,
1321
+ style
1322
+ }) => {
1323
+ const { theme } = useTheme();
1324
+ const maxW = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
1325
+ return /* @__PURE__ */ jsx(
1326
+ "div",
1327
+ {
1328
+ style: {
1329
+ width: "100%",
1330
+ minHeight: "100vh",
1331
+ backgroundColor: theme.background,
1332
+ display: "flex",
1333
+ justifyContent: "center",
1334
+ padding: "24px",
1335
+ boxSizing: "border-box",
1336
+ ...style
1337
+ },
1338
+ children: /* @__PURE__ */ jsx("div", { style: { width: "100%", maxWidth: maxW, boxSizing: "border-box" }, children })
1339
+ }
1340
+ );
1341
+ };
1342
+ var GridLayout = ({
1343
+ columns = 3,
1344
+ gap = 16,
1345
+ children,
1346
+ style
1347
+ }) => {
1348
+ const gapVal = typeof gap === "number" ? `${gap}px` : gap;
1349
+ const colVal = typeof columns === "number" ? `repeat(${columns}, 1fr)` : columns;
1350
+ return /* @__PURE__ */ jsx(
1351
+ "div",
1352
+ {
1353
+ style: {
1354
+ display: "grid",
1355
+ gridTemplateColumns: colVal,
1356
+ gap: gapVal,
1357
+ width: "100%",
1358
+ boxSizing: "border-box",
1359
+ ...style
1360
+ },
1361
+ children
1362
+ }
1363
+ );
1364
+ };
1365
+ var FlexLayout = ({
1366
+ direction = "row",
1367
+ align = "stretch",
1368
+ justify = "flex-start",
1369
+ gap = 0,
1370
+ wrap = false,
1371
+ children,
1372
+ style
1373
+ }) => {
1374
+ const gapVal = typeof gap === "number" ? `${gap}px` : gap;
1375
+ return /* @__PURE__ */ jsx(
1376
+ "div",
1377
+ {
1378
+ style: {
1379
+ display: "flex",
1380
+ flexDirection: direction,
1381
+ alignItems: align,
1382
+ justifyContent: justify,
1383
+ gap: gapVal,
1384
+ flexWrap: wrap ? "wrap" : "nowrap",
1385
+ width: "100%",
1386
+ boxSizing: "border-box",
1387
+ ...style
1388
+ },
1389
+ children
1390
+ }
1391
+ );
1392
+ };
1393
+
1394
+ export { Accordion, AuthLayout, Avatar, Badge, Box, Button, Card, Center, CenteredLayout, Checkbox, Chip, DashboardLayout, Divider, FlexLayout, GridLayout, HeaderContentLayout, Icon, IconButton, Image, Inline, ProgressBar, RootLayout, Scroll, Select, Separator, SidebarLayout, Spinner, Stack, Switch, Tabs, Text, TextArea, TextInput, Video };
1395
+ //# sourceMappingURL=index.mjs.map
1396
+ //# sourceMappingURL=index.mjs.map