@chellaa/react 0.2.0 → 0.2.1

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.
@@ -1,26 +1,535 @@
1
1
  import * as React from 'react';
2
+ import { keyframes, ThemeProvider as ThemeProvider$1, useTheme as useTheme$1 } from '@emotion/react';
2
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import emotionStyled from '@emotion/styled';
3
5
 
4
- // src/theme/ThemeProvider.tsx
6
+ // src/theme/palette.ts
7
+ var lightPalette = {
8
+ mode: "light",
9
+ primary: {
10
+ light: "#818cf8",
11
+ // indigo-400
12
+ main: "#6366f1",
13
+ // indigo-500
14
+ dark: "#4f46e5",
15
+ // indigo-600
16
+ contrastText: "#ffffff"
17
+ },
18
+ secondary: {
19
+ light: "#a78bfa",
20
+ // violet-400
21
+ main: "#8b5cf6",
22
+ // violet-500
23
+ dark: "#7c3aed",
24
+ // violet-600
25
+ contrastText: "#ffffff"
26
+ },
27
+ error: {
28
+ light: "#f87171",
29
+ // red-400
30
+ main: "#ef4444",
31
+ // red-500
32
+ dark: "#dc2626",
33
+ // red-600
34
+ contrastText: "#ffffff"
35
+ },
36
+ warning: {
37
+ light: "#fbbf24",
38
+ // amber-400
39
+ main: "#f59e0b",
40
+ // amber-500
41
+ dark: "#d97706",
42
+ // amber-600
43
+ contrastText: "#18181b"
44
+ },
45
+ info: {
46
+ light: "#38bdf8",
47
+ // sky-400
48
+ main: "#0ea5e9",
49
+ // sky-500
50
+ dark: "#0284c7",
51
+ // sky-600
52
+ contrastText: "#ffffff"
53
+ },
54
+ success: {
55
+ light: "#34d399",
56
+ // emerald-400
57
+ main: "#10b981",
58
+ // emerald-500
59
+ dark: "#059669",
60
+ // emerald-600
61
+ contrastText: "#ffffff"
62
+ },
63
+ text: {
64
+ primary: "rgba(0, 0, 0, 0.87)",
65
+ secondary: "rgba(0, 0, 0, 0.6)",
66
+ disabled: "rgba(0, 0, 0, 0.38)"
67
+ },
68
+ background: {
69
+ default: "#f8fafc",
70
+ paper: "#ffffff",
71
+ surface: "#ffffff"
72
+ },
73
+ divider: "rgba(0, 0, 0, 0.12)",
74
+ action: {
75
+ active: "rgba(0, 0, 0, 0.54)",
76
+ hover: "rgba(0, 0, 0, 0.04)",
77
+ hoverOpacity: 0.04,
78
+ selected: "rgba(0, 0, 0, 0.08)",
79
+ selectedOpacity: 0.08,
80
+ disabled: "rgba(0, 0, 0, 0.26)",
81
+ disabledBackground: "rgba(0, 0, 0, 0.12)",
82
+ focus: "rgba(0, 0, 0, 0.12)",
83
+ focusOpacity: 0.12
84
+ }
85
+ };
86
+ var darkPalette = {
87
+ mode: "dark",
88
+ primary: {
89
+ light: "#a5b4fc",
90
+ // indigo-300
91
+ main: "#818cf8",
92
+ // indigo-400
93
+ dark: "#6366f1",
94
+ // indigo-500
95
+ contrastText: "#09090b"
96
+ },
97
+ secondary: {
98
+ light: "#c4b5fd",
99
+ // violet-300
100
+ main: "#a78bfa",
101
+ // violet-400
102
+ dark: "#8b5cf6",
103
+ // violet-500
104
+ contrastText: "#09090b"
105
+ },
106
+ error: {
107
+ light: "#fca5a5",
108
+ // red-300
109
+ main: "#f87171",
110
+ // red-400
111
+ dark: "#ef4444",
112
+ // red-500
113
+ contrastText: "#09090b"
114
+ },
115
+ warning: {
116
+ light: "#fde68a",
117
+ // amber-200
118
+ main: "#fbbf24",
119
+ // amber-400
120
+ dark: "#f59e0b",
121
+ // amber-500
122
+ contrastText: "#09090b"
123
+ },
124
+ info: {
125
+ light: "#7dd3fc",
126
+ // sky-300
127
+ main: "#38bdf8",
128
+ // sky-400
129
+ dark: "#0ea5e9",
130
+ // sky-500
131
+ contrastText: "#09090b"
132
+ },
133
+ success: {
134
+ light: "#6ee7b7",
135
+ // emerald-300
136
+ main: "#34d399",
137
+ // emerald-400
138
+ dark: "#10b981",
139
+ // emerald-500
140
+ contrastText: "#09090b"
141
+ },
142
+ text: {
143
+ primary: "rgba(255, 255, 255, 0.95)",
144
+ secondary: "rgba(255, 255, 255, 0.7)",
145
+ disabled: "rgba(255, 255, 255, 0.38)"
146
+ },
147
+ background: {
148
+ default: "#09090b",
149
+ paper: "#18181b",
150
+ surface: "#18181b"
151
+ },
152
+ divider: "rgba(255, 255, 255, 0.12)",
153
+ action: {
154
+ active: "rgba(255, 255, 255, 0.7)",
155
+ hover: "rgba(255, 255, 255, 0.08)",
156
+ hoverOpacity: 0.08,
157
+ selected: "rgba(255, 255, 255, 0.16)",
158
+ selectedOpacity: 0.16,
159
+ disabled: "rgba(255, 255, 255, 0.3)",
160
+ disabledBackground: "rgba(255, 255, 255, 0.12)",
161
+ focus: "rgba(255, 255, 255, 0.12)",
162
+ focusOpacity: 0.12
163
+ }
164
+ };
165
+ function createPalette(mode = "light") {
166
+ return mode === "dark" ? darkPalette : lightPalette;
167
+ }
168
+
169
+ // src/theme/typography.ts
170
+ var defaultFontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"';
171
+ var defaultTypography = {
172
+ fontFamily: defaultFontFamily,
173
+ fontSize: 14,
174
+ fontWeightLight: 300,
175
+ fontWeightRegular: 400,
176
+ fontWeightMedium: 500,
177
+ fontWeightBold: 700,
178
+ h1: {
179
+ fontFamily: defaultFontFamily,
180
+ fontWeight: 300,
181
+ fontSize: "6rem",
182
+ lineHeight: 1.167,
183
+ letterSpacing: "-0.01562em"
184
+ },
185
+ h2: {
186
+ fontFamily: defaultFontFamily,
187
+ fontWeight: 300,
188
+ fontSize: "3.75rem",
189
+ lineHeight: 1.2,
190
+ letterSpacing: "-0.00833em"
191
+ },
192
+ h3: {
193
+ fontFamily: defaultFontFamily,
194
+ fontWeight: 400,
195
+ fontSize: "3rem",
196
+ lineHeight: 1.167,
197
+ letterSpacing: "0em"
198
+ },
199
+ h4: {
200
+ fontFamily: defaultFontFamily,
201
+ fontWeight: 400,
202
+ fontSize: "2.125rem",
203
+ lineHeight: 1.235,
204
+ letterSpacing: "0.00735em"
205
+ },
206
+ h5: {
207
+ fontFamily: defaultFontFamily,
208
+ fontWeight: 500,
209
+ fontSize: "1.5rem",
210
+ lineHeight: 1.334,
211
+ letterSpacing: "0em"
212
+ },
213
+ h6: {
214
+ fontFamily: defaultFontFamily,
215
+ fontWeight: 500,
216
+ fontSize: "1.25rem",
217
+ lineHeight: 1.6,
218
+ letterSpacing: "0.0075em"
219
+ },
220
+ subtitle1: {
221
+ fontFamily: defaultFontFamily,
222
+ fontWeight: 400,
223
+ fontSize: "1rem",
224
+ lineHeight: 1.75,
225
+ letterSpacing: "0.00938em"
226
+ },
227
+ subtitle2: {
228
+ fontFamily: defaultFontFamily,
229
+ fontWeight: 500,
230
+ fontSize: "0.875rem",
231
+ lineHeight: 1.57,
232
+ letterSpacing: "0.00714em"
233
+ },
234
+ body1: {
235
+ fontFamily: defaultFontFamily,
236
+ fontWeight: 400,
237
+ fontSize: "1rem",
238
+ lineHeight: 1.5,
239
+ letterSpacing: "0.00938em"
240
+ },
241
+ body2: {
242
+ fontFamily: defaultFontFamily,
243
+ fontWeight: 400,
244
+ fontSize: "0.875rem",
245
+ lineHeight: 1.43,
246
+ letterSpacing: "0.01071em"
247
+ },
248
+ button: {
249
+ fontFamily: defaultFontFamily,
250
+ fontWeight: 500,
251
+ fontSize: "0.875rem",
252
+ lineHeight: 1.75,
253
+ letterSpacing: "0.02857em",
254
+ textTransform: "uppercase"
255
+ },
256
+ caption: {
257
+ fontFamily: defaultFontFamily,
258
+ fontWeight: 400,
259
+ fontSize: "0.75rem",
260
+ lineHeight: 1.66,
261
+ letterSpacing: "0.03333em"
262
+ },
263
+ overline: {
264
+ fontFamily: defaultFontFamily,
265
+ fontWeight: 400,
266
+ fontSize: "0.75rem",
267
+ lineHeight: 2.66,
268
+ letterSpacing: "0.08333em",
269
+ textTransform: "uppercase"
270
+ }
271
+ };
272
+
273
+ // src/theme/spacing.ts
274
+ function createSpacing(base = 8) {
275
+ return (...factors) => {
276
+ if (factors.length === 0) return `${base}px`;
277
+ return factors.map((factor) => {
278
+ if (typeof factor === "string") return factor;
279
+ return `${factor * base}px`;
280
+ }).join(" ");
281
+ };
282
+ }
283
+ var defaultSpacing = createSpacing(8);
284
+
285
+ // src/theme/breakpoints.ts
286
+ var defaultBreakpointValues = {
287
+ xs: 0,
288
+ sm: 600,
289
+ md: 900,
290
+ lg: 1200,
291
+ xl: 1536
292
+ };
293
+ var breakpointKeys = ["xs", "sm", "md", "lg", "xl"];
294
+ function createBreakpoints(customValues) {
295
+ const values = {
296
+ ...defaultBreakpointValues,
297
+ ...customValues
298
+ };
299
+ const step = 5 / 100;
300
+ const up = (key) => {
301
+ const value = typeof key === "number" ? key : values[key];
302
+ return `@media (min-width:${value}px)`;
303
+ };
304
+ const down = (key) => {
305
+ const value = typeof key === "number" ? key : values[key];
306
+ return `@media (max-width:${value - step}px)`;
307
+ };
308
+ const between = (start, end) => {
309
+ const min = typeof start === "number" ? start : values[start];
310
+ const max = typeof end === "number" ? end : values[end];
311
+ return `@media (min-width:${min}px) and (max-width:${max - step}px)`;
312
+ };
313
+ const only = (key) => {
314
+ const index = breakpointKeys.indexOf(key);
315
+ if (index === breakpointKeys.length - 1) {
316
+ return up(key);
317
+ }
318
+ const nextKey = breakpointKeys[index + 1];
319
+ return nextKey ? between(key, nextKey) : up(key);
320
+ };
321
+ return {
322
+ values,
323
+ up,
324
+ down,
325
+ between,
326
+ only
327
+ };
328
+ }
329
+ var defaultBreakpoints = createBreakpoints();
330
+
331
+ // src/theme/shadows.ts
332
+ var umbra = [
333
+ "0px 0px 0px 0px",
334
+ "0px 2px 1px -1px",
335
+ "0px 3px 1px -2px",
336
+ "0px 3px 3px -2px",
337
+ "0px 2px 4px -1px",
338
+ "0px 3px 5px -1px",
339
+ "0px 3px 5px -1px",
340
+ "0px 4px 5px -2px",
341
+ "0px 5px 5px -3px",
342
+ "0px 5px 6px -3px",
343
+ "0px 6px 6px -3px",
344
+ "0px 6px 7px -4px",
345
+ "0px 7px 8px -4px",
346
+ "0px 7px 8px -4px",
347
+ "0px 7px 9px -4px",
348
+ "0px 8px 9px -5px",
349
+ "0px 8px 10px -5px",
350
+ "0px 8px 11px -5px",
351
+ "0px 9px 11px -5px",
352
+ "0px 9px 12px -6px",
353
+ "0px 10px 13px -6px",
354
+ "0px 10px 13px -6px",
355
+ "0px 10px 14px -6px",
356
+ "0px 11px 14px -7px",
357
+ "0px 11px 15px -7px"
358
+ ];
359
+ var penumbra = [
360
+ "0px 0px 0px 0px",
361
+ "0px 1px 1px 0px",
362
+ "0px 2px 2px 0px",
363
+ "0px 3px 4px 0px",
364
+ "0px 4px 5px 0px",
365
+ "0px 5px 8px 0px",
366
+ "0px 6px 10px 0px",
367
+ "0px 7px 10px 1px",
368
+ "0px 8px 10px 1px",
369
+ "0px 9px 12px 1px",
370
+ "0px 10px 14px 1px",
371
+ "0px 11px 15px 1px",
372
+ "0px 12px 17px 2px",
373
+ "0px 13px 19px 2px",
374
+ "0px 14px 21px 2px",
375
+ "0px 15px 22px 2px",
376
+ "0px 16px 24px 2px",
377
+ "0px 17px 26px 2px",
378
+ "0px 18px 28px 2px",
379
+ "0px 19px 29px 2px",
380
+ "0px 20px 31px 3px",
381
+ "0px 21px 33px 3px",
382
+ "0px 22px 35px 3px",
383
+ "0px 23px 36px 3px",
384
+ "0px 24px 38px 3px"
385
+ ];
386
+ var ambient = [
387
+ "0px 0px 0px 0px",
388
+ "0px 1px 3px 0px",
389
+ "0px 1px 5px 0px",
390
+ "0px 1px 8px 0px",
391
+ "0px 1px 10px 0px",
392
+ "0px 1px 14px 0px",
393
+ "0px 1px 18px 0px",
394
+ "0px 2px 16px 1px",
395
+ "0px 3px 14px 2px",
396
+ "0px 3px 16px 2px",
397
+ "0px 4px 18px 3px",
398
+ "0px 4px 20px 3px",
399
+ "0px 5px 22px 4px",
400
+ "0px 5px 24px 4px",
401
+ "0px 5px 26px 4px",
402
+ "0px 6px 28px 5px",
403
+ "0px 6px 30px 5px",
404
+ "0px 6px 32px 5px",
405
+ "0px 7px 34px 6px",
406
+ "0px 7px 36px 6px",
407
+ "0px 8px 38px 7px",
408
+ "0px 8px 40px 7px",
409
+ "0px 8px 42px 7px",
410
+ "0px 9px 44px 8px",
411
+ "0px 9px 46px 8px"
412
+ ];
413
+ function createShadows() {
414
+ return umbra.map((u, i) => {
415
+ if (i === 0) return "none";
416
+ return `${u} rgba(0,0,0,0.2), ${penumbra[i]} rgba(0,0,0,0.14), ${ambient[i]} rgba(0,0,0,0.12)`;
417
+ });
418
+ }
419
+ var defaultShadows = createShadows();
420
+
421
+ // src/theme/transitions.ts
422
+ var defaultTransitions = {
423
+ easing: {
424
+ easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
425
+ easeOut: "cubic-bezier(0.0, 0, 0.2, 1)",
426
+ easeIn: "cubic-bezier(0.4, 0, 1, 1)",
427
+ sharp: "cubic-bezier(0.4, 0, 0.6, 1)"
428
+ },
429
+ duration: {
430
+ shortest: 150,
431
+ shorter: 200,
432
+ short: 250,
433
+ standard: 300,
434
+ complex: 375,
435
+ enteringScreen: 225,
436
+ leavingScreen: 195
437
+ },
438
+ create(props = ["all"], options = {}) {
439
+ const {
440
+ duration = defaultTransitions.duration.standard,
441
+ easing = defaultTransitions.easing.easeInOut,
442
+ delay = 0
443
+ } = options;
444
+ const formatDuration = (d) => typeof d === "string" ? d : `${d}ms`;
445
+ const formatDelay = (d) => typeof d === "string" ? d : `${d}ms`;
446
+ const properties = Array.isArray(props) ? props : [props];
447
+ return properties.map(
448
+ (prop) => `${prop} ${formatDuration(duration)} ${easing} ${formatDelay(delay)}`
449
+ ).join(", ");
450
+ }
451
+ };
452
+
453
+ // src/theme/zIndex.ts
454
+ var defaultZIndex = {
455
+ mobileStepper: 1e3,
456
+ fab: 1050,
457
+ speedDial: 1050,
458
+ appBar: 1100,
459
+ drawer: 1200,
460
+ modal: 1300,
461
+ snackbar: 1400,
462
+ tooltip: 1500
463
+ };
464
+
465
+ // src/theme/createTheme.ts
466
+ function isObject(item) {
467
+ return item && typeof item === "object" && !Array.isArray(item);
468
+ }
469
+ function deepMerge(target, source) {
470
+ const output = { ...target };
471
+ if (isObject(target) && isObject(source)) {
472
+ Object.keys(source).forEach((key) => {
473
+ if (isObject(source[key])) {
474
+ if (!(key in target)) {
475
+ Object.assign(output, { [key]: source[key] });
476
+ } else {
477
+ output[key] = deepMerge(target[key], source[key]);
478
+ }
479
+ } else {
480
+ Object.assign(output, { [key]: source[key] });
481
+ }
482
+ });
483
+ }
484
+ return output;
485
+ }
486
+ function createTheme(options = {}) {
487
+ const mode = options.palette?.mode ?? "light";
488
+ const basePalette = createPalette(mode);
489
+ const mergedPalette = options.palette ? deepMerge(basePalette, options.palette) : basePalette;
490
+ const mergedTypography = options.typography ? deepMerge(defaultTypography, options.typography) : defaultTypography;
491
+ const mergedBreakpoints = options.breakpoints?.values ? createBreakpoints(options.breakpoints.values) : defaultBreakpoints;
492
+ const spacing = typeof options.spacing === "function" ? options.spacing : defaultSpacing;
493
+ const shape = {
494
+ borderRadius: options.shape?.borderRadius ?? 4
495
+ };
496
+ const shadows = options.shadows ?? defaultShadows;
497
+ const transitions = options.transitions ? deepMerge(defaultTransitions, options.transitions) : defaultTransitions;
498
+ const zIndex = options.zIndex ? deepMerge(defaultZIndex, options.zIndex) : defaultZIndex;
499
+ return {
500
+ palette: mergedPalette,
501
+ typography: mergedTypography,
502
+ spacing,
503
+ shape,
504
+ breakpoints: mergedBreakpoints,
505
+ shadows,
506
+ transitions,
507
+ zIndex,
508
+ components: options.components ?? {}
509
+ };
510
+ }
511
+ var defaultTheme = createTheme({ palette: { mode: "light" } });
512
+ var defaultDarkTheme = createTheme({ palette: { mode: "dark" } });
5
513
  var ThemeContext = React.createContext(
6
514
  void 0
7
515
  );
8
516
  var COLOR_SCHEME_QUERY = "(prefers-color-scheme: dark)";
9
517
  function ThemeProvider({
10
518
  children,
11
- defaultTheme = "system",
519
+ theme: customThemeProp,
520
+ defaultTheme: defaultThemeMode = "system",
12
521
  storageKey = "chellaa-theme",
13
522
  enableSystem = true,
14
523
  tokens,
15
524
  attribute = "data-theme"
16
525
  }) {
17
526
  const parentContext = React.useContext(ThemeContext);
18
- const [theme, setThemeState] = React.useState(() => {
19
- if (typeof window === "undefined") return defaultTheme;
527
+ const [themeMode, setThemeModeState] = React.useState(() => {
528
+ if (typeof window === "undefined") return defaultThemeMode;
20
529
  try {
21
- return localStorage.getItem(storageKey) || defaultTheme;
530
+ return localStorage.getItem(storageKey) || defaultThemeMode;
22
531
  } catch {
23
- return defaultTheme;
532
+ return defaultThemeMode;
24
533
  }
25
534
  });
26
535
  const [systemTheme, setSystemTheme] = React.useState(() => {
@@ -30,11 +539,11 @@ function ThemeProvider({
30
539
  return window.matchMedia(COLOR_SCHEME_QUERY).matches ? "dark" : "light";
31
540
  });
32
541
  const resolvedTheme = React.useMemo(() => {
33
- if (theme === "system") {
542
+ if (themeMode === "system") {
34
543
  return systemTheme ?? "light";
35
544
  }
36
- return theme === "dark" ? "dark" : "light";
37
- }, [theme, systemTheme]);
545
+ return themeMode === "dark" ? "dark" : "light";
546
+ }, [themeMode, systemTheme]);
38
547
  React.useEffect(() => {
39
548
  if (!enableSystem || typeof window === "undefined" || typeof window.matchMedia !== "function") {
40
549
  return;
@@ -51,21 +560,33 @@ function ThemeProvider({
51
560
  return () => mediaQuery.removeListener(handleChange);
52
561
  }
53
562
  }, [enableSystem]);
563
+ const activeTheme = React.useMemo(() => {
564
+ if (customThemeProp) {
565
+ return createTheme({
566
+ ...customThemeProp,
567
+ palette: {
568
+ mode: resolvedTheme,
569
+ ...customThemeProp.palette || {}
570
+ }
571
+ });
572
+ }
573
+ return resolvedTheme === "dark" ? defaultDarkTheme : defaultTheme;
574
+ }, [customThemeProp, resolvedTheme]);
54
575
  React.useEffect(() => {
55
576
  if (typeof document === "undefined") return;
56
577
  if (!parentContext) {
57
578
  const root = document.documentElement;
58
579
  root.setAttribute(attribute, resolvedTheme);
59
580
  if (tokens) {
60
- for (const [key, value2] of Object.entries(tokens)) {
61
- root.style.setProperty(key, value2);
581
+ for (const [key, value] of Object.entries(tokens)) {
582
+ root.style.setProperty(key, value);
62
583
  }
63
584
  }
64
585
  }
65
586
  }, [resolvedTheme, parentContext, attribute, tokens]);
66
587
  const setTheme = React.useCallback(
67
588
  (newTheme) => {
68
- setThemeState(newTheme);
589
+ setThemeModeState(newTheme);
69
590
  try {
70
591
  localStorage.setItem(storageKey, newTheme);
71
592
  } catch {
@@ -73,18 +594,27 @@ function ThemeProvider({
73
594
  },
74
595
  [storageKey]
75
596
  );
76
- const value = React.useMemo(
597
+ const setColorMode = React.useCallback(
598
+ (mode) => {
599
+ setTheme(mode);
600
+ },
601
+ [setTheme]
602
+ );
603
+ const contextValue = React.useMemo(
77
604
  () => ({
78
- theme,
605
+ theme: themeMode,
79
606
  setTheme,
80
607
  resolvedTheme,
81
- systemTheme
608
+ systemTheme,
609
+ activeTheme,
610
+ colorMode: resolvedTheme,
611
+ setColorMode
82
612
  }),
83
- [theme, setTheme, resolvedTheme, systemTheme]
613
+ [themeMode, setTheme, resolvedTheme, systemTheme, activeTheme, setColorMode]
84
614
  );
85
615
  if (parentContext) {
86
616
  const styleObj = tokens ? tokens : void 0;
87
- return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children: /* @__PURE__ */ jsx(
617
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(ThemeProvider$1, { theme: activeTheme, children: /* @__PURE__ */ jsx(
88
618
  "div",
89
619
  {
90
620
  ...{ [attribute]: resolvedTheme },
@@ -92,43 +622,56 @@ function ThemeProvider({
92
622
  className: "cl-theme-scope",
93
623
  children
94
624
  }
95
- ) });
625
+ ) }) });
96
626
  }
97
- return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
627
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(ThemeProvider$1, { theme: activeTheme, children }) });
98
628
  }
99
629
  function useTheme() {
100
630
  const context = React.useContext(ThemeContext);
101
- if (!context) {
102
- throw new Error(
103
- "useTheme must be used within a <ThemeProvider>. Wrap your application root in <ThemeProvider>."
104
- );
631
+ const emotionTheme = useTheme$1();
632
+ if (context) {
633
+ return {
634
+ ...context,
635
+ themeObject: context.activeTheme
636
+ };
637
+ }
638
+ if (emotionTheme && emotionTheme.palette) {
639
+ return {
640
+ theme: emotionTheme.palette.mode,
641
+ setTheme: () => {
642
+ },
643
+ resolvedTheme: emotionTheme.palette.mode,
644
+ systemTheme: void 0,
645
+ activeTheme: emotionTheme,
646
+ colorMode: emotionTheme.palette.mode,
647
+ setColorMode: () => {
648
+ },
649
+ themeObject: emotionTheme
650
+ };
105
651
  }
106
- return context;
107
- }
108
-
109
- // src/theme/createTheme.ts
110
- function createTheme(config) {
111
- const { name, tokens } = config;
112
- const declarations = Object.entries(tokens).map(([property, value]) => ` ${property}: ${value};`).join("\n");
113
- const cssText = `[data-theme="${name}"] {
114
- ${declarations}
115
- }`;
116
652
  return {
117
- name,
118
- tokens,
119
- cssText
653
+ theme: "light",
654
+ setTheme: () => {
655
+ },
656
+ resolvedTheme: "light",
657
+ systemTheme: void 0,
658
+ activeTheme: defaultTheme,
659
+ colorMode: "light",
660
+ setColorMode: () => {
661
+ },
662
+ themeObject: defaultTheme
120
663
  };
121
664
  }
122
665
  function ThemeScript({
123
666
  storageKey = "chellaa-theme",
124
- defaultTheme = "system",
667
+ defaultTheme: defaultTheme2 = "system",
125
668
  attribute = "data-theme",
126
669
  nonce
127
670
  }) {
128
671
  const scriptContent = `(function() {
129
672
  try {
130
673
  var key = '${storageKey}';
131
- var def = '${defaultTheme}';
674
+ var def = '${defaultTheme2}';
132
675
  var attr = '${attribute}';
133
676
  var stored = localStorage.getItem(key);
134
677
  var theme = stored || def;
@@ -149,6 +692,303 @@ function ThemeScript({
149
692
  );
150
693
  }
151
694
 
695
+ // src/system/shouldForwardProp.ts
696
+ var defaultBlockedProps = /* @__PURE__ */ new Set([
697
+ "sx",
698
+ "theme",
699
+ "as",
700
+ "ownerState",
701
+ "slotProps"
702
+ ]);
703
+ function createShouldForwardProp(customBlocked) {
704
+ const blockedSet = new Set(defaultBlockedProps);
705
+ if (customBlocked) {
706
+ customBlocked.forEach((prop) => blockedSet.add(prop));
707
+ }
708
+ return (prop) => {
709
+ if (typeof prop === "string" && prop.startsWith("$")) {
710
+ return false;
711
+ }
712
+ return !blockedSet.has(prop);
713
+ };
714
+ }
715
+ var rootShouldForwardProp = createShouldForwardProp();
716
+
717
+ // src/system/sx.ts
718
+ var spacingProperties = {
719
+ m: ["margin"],
720
+ margin: ["margin"],
721
+ mt: ["marginTop"],
722
+ marginTop: ["marginTop"],
723
+ mr: ["marginRight"],
724
+ marginRight: ["marginRight"],
725
+ mb: ["marginBottom"],
726
+ marginBottom: ["marginBottom"],
727
+ ml: ["marginLeft"],
728
+ marginLeft: ["marginLeft"],
729
+ mx: ["marginInline"],
730
+ marginInline: ["marginInline"],
731
+ my: ["marginBlock"],
732
+ marginBlock: ["marginBlock"],
733
+ p: ["padding"],
734
+ padding: ["padding"],
735
+ pt: ["paddingTop"],
736
+ paddingTop: ["paddingTop"],
737
+ pr: ["paddingRight"],
738
+ paddingRight: ["paddingRight"],
739
+ pb: ["paddingBottom"],
740
+ paddingBottom: ["paddingBottom"],
741
+ pl: ["paddingLeft"],
742
+ paddingLeft: ["paddingLeft"],
743
+ px: ["paddingInline"],
744
+ paddingInline: ["paddingInline"],
745
+ py: ["paddingBlock"],
746
+ paddingBlock: ["paddingBlock"],
747
+ gap: ["gap"],
748
+ rowGap: ["rowGap"],
749
+ columnGap: ["columnGap"]
750
+ };
751
+ function resolvePalettePath(palette, path) {
752
+ if (!path || typeof path !== "string") return void 0;
753
+ const parts = path.split(".");
754
+ let current = palette;
755
+ for (const part of parts) {
756
+ if (current && typeof current === "object" && part in current) {
757
+ current = current[part];
758
+ } else {
759
+ return void 0;
760
+ }
761
+ }
762
+ return typeof current === "string" ? current : void 0;
763
+ }
764
+ function resolveColor(theme, value) {
765
+ if (typeof value !== "string") return value;
766
+ const resolved = resolvePalettePath(theme.palette, value);
767
+ return resolved ?? value;
768
+ }
769
+ function resolveZIndex(theme, value) {
770
+ if (typeof value === "string" && value in theme.zIndex) {
771
+ return theme.zIndex[value];
772
+ }
773
+ return value;
774
+ }
775
+ function resolveSingleProperty(theme, prop, value) {
776
+ if (value === void 0 || value === null) return {};
777
+ if (prop in spacingProperties) {
778
+ const cssProps = spacingProperties[prop];
779
+ const formatted = typeof value === "number" ? theme.spacing(value) : value;
780
+ const result = {};
781
+ for (const cssProp of cssProps) {
782
+ result[cssProp] = formatted;
783
+ }
784
+ return result;
785
+ }
786
+ if (prop === "bgcolor") {
787
+ return { backgroundColor: resolveColor(theme, value) };
788
+ }
789
+ if (prop === "color" || prop === "backgroundColor" || prop === "borderColor" || prop === "outlineColor") {
790
+ return { [prop]: resolveColor(theme, value) };
791
+ }
792
+ if (prop === "elevation") {
793
+ if (typeof value === "number" && theme.shadows[value]) {
794
+ return { boxShadow: theme.shadows[value] };
795
+ }
796
+ return {};
797
+ }
798
+ if (prop === "boxShadow") {
799
+ if (typeof value === "number" && theme.shadows[value]) {
800
+ return { boxShadow: theme.shadows[value] };
801
+ }
802
+ return { boxShadow: value };
803
+ }
804
+ if (prop === "borderRadius") {
805
+ if (typeof value === "number") {
806
+ const radius = theme.shape?.borderRadius ?? 4;
807
+ return { borderRadius: `${value * radius}px` };
808
+ }
809
+ return { borderRadius: value };
810
+ }
811
+ if (prop === "zIndex") {
812
+ return { zIndex: resolveZIndex(theme, value) };
813
+ }
814
+ return { [prop]: value };
815
+ }
816
+ function isObject2(val) {
817
+ return val !== null && typeof val === "object" && !Array.isArray(val);
818
+ }
819
+ function isResponsiveValue(val) {
820
+ if (Array.isArray(val)) return true;
821
+ if (isObject2(val)) {
822
+ return Object.keys(val).some((k) => breakpointKeys.includes(k));
823
+ }
824
+ return false;
825
+ }
826
+ function parseSxObject(theme, sxObject) {
827
+ const result = {};
828
+ for (const [key, value] of Object.entries(sxObject)) {
829
+ if (value === void 0 || value === null) continue;
830
+ if (key.startsWith("&") || key.startsWith("@") || key.startsWith(".")) {
831
+ if (typeof value === "function") {
832
+ result[key] = parseSxObject(theme, value(theme));
833
+ } else if (isObject2(value)) {
834
+ result[key] = parseSxObject(theme, value);
835
+ }
836
+ continue;
837
+ }
838
+ if (Array.isArray(value)) {
839
+ value.forEach((bpVal, index) => {
840
+ if (bpVal === void 0 || bpVal === null) return;
841
+ const bpKey = breakpointKeys[index];
842
+ if (!bpKey) return;
843
+ const resolved2 = resolveSingleProperty(theme, key, bpVal);
844
+ if (bpKey === "xs") {
845
+ Object.assign(result, resolved2);
846
+ } else {
847
+ const media = theme.breakpoints.up(bpKey);
848
+ result[media] = {
849
+ ...result[media] || {},
850
+ ...resolved2
851
+ };
852
+ }
853
+ });
854
+ continue;
855
+ }
856
+ if (isResponsiveValue(value)) {
857
+ const respObj = value;
858
+ for (const [bpKey, bpVal] of Object.entries(respObj)) {
859
+ if (bpVal === void 0 || bpVal === null) continue;
860
+ const resolved2 = resolveSingleProperty(theme, key, bpVal);
861
+ if (bpKey === "xs") {
862
+ Object.assign(result, resolved2);
863
+ } else if (breakpointKeys.includes(bpKey)) {
864
+ const media = theme.breakpoints.up(bpKey);
865
+ result[media] = {
866
+ ...result[media] || {},
867
+ ...resolved2
868
+ };
869
+ }
870
+ }
871
+ continue;
872
+ }
873
+ if (isObject2(value)) {
874
+ result[key] = parseSxObject(theme, value);
875
+ continue;
876
+ }
877
+ const resolved = resolveSingleProperty(theme, key, value);
878
+ Object.assign(result, resolved);
879
+ }
880
+ return result;
881
+ }
882
+ function parseSx(themeInput, sx) {
883
+ if (!sx) return {};
884
+ const theme = themeInput && typeof themeInput.spacing === "function" ? themeInput : defaultTheme;
885
+ if (typeof sx === "function") {
886
+ return parseSxObject(theme, sx(theme));
887
+ }
888
+ if (Array.isArray(sx)) {
889
+ return sx.reduce((acc, item) => {
890
+ if (!item) return acc;
891
+ const parsed = parseSx(theme, item);
892
+ return deepMergeStyles(acc, parsed);
893
+ }, {});
894
+ }
895
+ if (isObject2(sx)) {
896
+ return parseSxObject(theme, sx);
897
+ }
898
+ return {};
899
+ }
900
+ function deepMergeStyles(target, source) {
901
+ const result = { ...target };
902
+ for (const [key, value] of Object.entries(source)) {
903
+ if (isObject2(value) && isObject2(result[key]) && !Array.isArray(value) && !Array.isArray(result[key])) {
904
+ result[key] = deepMergeStyles(result[key], value);
905
+ } else {
906
+ result[key] = value;
907
+ }
908
+ }
909
+ return result;
910
+ }
911
+
912
+ // src/system/componentOverrides.ts
913
+ function resolveComponentOverrides(theme, options, props) {
914
+ const { name, slot = "root", overridesResolver } = options;
915
+ if (!name || !theme.components?.[name]) {
916
+ return void 0;
917
+ }
918
+ const componentConfig = theme.components[name];
919
+ const styleOverrides = componentConfig.styleOverrides;
920
+ if (!styleOverrides) {
921
+ return void 0;
922
+ }
923
+ if (overridesResolver) {
924
+ const resolved = overridesResolver(props, styleOverrides);
925
+ if (resolved) return resolved;
926
+ }
927
+ const slotLower = slot.toLowerCase();
928
+ const matchedKey = Object.keys(styleOverrides).find(
929
+ (k) => k.toLowerCase() === slotLower
930
+ );
931
+ if (matchedKey) {
932
+ const override = styleOverrides[matchedKey];
933
+ if (typeof override === "function") {
934
+ return override({ theme, ownerState: props.ownerState ?? props });
935
+ }
936
+ return override;
937
+ }
938
+ return void 0;
939
+ }
940
+ function styled(component, options = {}) {
941
+ const {
942
+ name,
943
+ slot = "Root",
944
+ label,
945
+ target,
946
+ shouldForwardProp: customShouldForwardProp,
947
+ skipSx = false
948
+ } = options;
949
+ const resolvedShouldForwardProp = customShouldForwardProp ? (prop) => rootShouldForwardProp(prop) && customShouldForwardProp(prop) : rootShouldForwardProp;
950
+ const resolvedLabel = label ?? (name ? `${name}-${slot}` : void 0);
951
+ const emotionOptions = {
952
+ shouldForwardProp: resolvedShouldForwardProp
953
+ };
954
+ if (resolvedLabel !== void 0) {
955
+ emotionOptions.label = resolvedLabel;
956
+ }
957
+ if (target !== void 0) {
958
+ emotionOptions.target = target;
959
+ }
960
+ const emotionCreator = emotionStyled(component, emotionOptions);
961
+ return (...interpolations) => {
962
+ const wrappedInterpolations = interpolations.map((interpolation) => {
963
+ if (typeof interpolation === "function") {
964
+ return (rawProps) => {
965
+ const activeTheme = rawProps.theme && typeof rawProps.theme.spacing === "function" ? rawProps.theme : defaultTheme;
966
+ return interpolation({
967
+ ...rawProps,
968
+ theme: activeTheme
969
+ });
970
+ };
971
+ }
972
+ return interpolation;
973
+ });
974
+ return emotionCreator(
975
+ ...wrappedInterpolations,
976
+ // 2. Global theme overrides from theme.components[name].styleOverrides[slot]
977
+ (props) => {
978
+ if (!name) return null;
979
+ const activeTheme = props.theme && typeof props.theme.spacing === "function" ? props.theme : defaultTheme;
980
+ return resolveComponentOverrides(activeTheme, options, props);
981
+ },
982
+ // 3. Local sx prop styles (highest precedence)
983
+ (props) => {
984
+ if (skipSx || !props.sx) return null;
985
+ const activeTheme = props.theme && typeof props.theme.spacing === "function" ? props.theme : defaultTheme;
986
+ return parseSx(activeTheme, props.sx);
987
+ }
988
+ );
989
+ };
990
+ }
991
+
152
992
  // src/utils/classNames.ts
153
993
  function classNames(...inputs) {
154
994
  const classes = [];
@@ -189,6 +1029,13 @@ function setRef(ref, value) {
189
1029
  ref.current = value;
190
1030
  }
191
1031
  }
1032
+ function useMergeRefs(...refs) {
1033
+ return React.useCallback((current) => {
1034
+ for (const ref of refs) {
1035
+ setRef(ref, current);
1036
+ }
1037
+ }, refs);
1038
+ }
192
1039
 
193
1040
  // src/primitives/Slot.tsx
194
1041
  var Slot = React.forwardRef(
@@ -258,6 +1105,252 @@ var ButtonGroupContext = React.createContext(void 0);
258
1105
  function useButtonGroupContext() {
259
1106
  return React.useContext(ButtonGroupContext);
260
1107
  }
1108
+ var enterKeyframe = keyframes`
1109
+ 0% {
1110
+ transform: scale(0);
1111
+ opacity: 0.1;
1112
+ }
1113
+ 100% {
1114
+ transform: scale(1);
1115
+ opacity: 0.3;
1116
+ }
1117
+ `;
1118
+ var exitKeyframe = keyframes`
1119
+ 0% {
1120
+ opacity: 0.3;
1121
+ }
1122
+ 100% {
1123
+ opacity: 0;
1124
+ }
1125
+ `;
1126
+ var pulsateKeyframe = keyframes`
1127
+ 0% {
1128
+ transform: scale(1);
1129
+ }
1130
+ 50% {
1131
+ transform: scale(0.92);
1132
+ }
1133
+ 100% {
1134
+ transform: scale(1);
1135
+ }
1136
+ `;
1137
+ var TouchRippleRoot = styled("span", {
1138
+ name: "ChellaaTouchRipple",
1139
+ slot: "Root"
1140
+ })({
1141
+ overflow: "hidden",
1142
+ pointerEvents: "none",
1143
+ position: "absolute",
1144
+ zIndex: 0,
1145
+ top: 0,
1146
+ right: 0,
1147
+ bottom: 0,
1148
+ left: 0,
1149
+ borderRadius: "inherit"
1150
+ });
1151
+ var StyledRippleSpan = styled("span", {
1152
+ shouldForwardProp: (prop) => prop !== "pulsating" && prop !== "leaving"
1153
+ })(({ pulsating, leaving }) => ({
1154
+ position: "absolute",
1155
+ borderRadius: "50%",
1156
+ backgroundColor: "currentColor",
1157
+ opacity: 0.3,
1158
+ animation: `${enterKeyframe} 550ms cubic-bezier(0.4, 0, 0.2, 1)`,
1159
+ ...pulsating && {
1160
+ animation: `${pulsateKeyframe} 2500ms ease-in-out infinite 200ms`
1161
+ },
1162
+ ...leaving && {
1163
+ opacity: 0,
1164
+ animation: `${exitKeyframe} 550ms cubic-bezier(0.4, 0, 0.2, 1) forwards`
1165
+ }
1166
+ }));
1167
+ var TouchRipple = React.forwardRef(
1168
+ function TouchRipple2(props, ref) {
1169
+ const { center: centerProp = false, className, ...rest } = props;
1170
+ const [ripples, setRipples] = React.useState([]);
1171
+ const nextKey = React.useRef(0);
1172
+ const containerRef = React.useRef(null);
1173
+ const start = React.useCallback(
1174
+ (event, options = {}) => {
1175
+ const { pulsate: pulsate2 = false, center = centerProp || pulsate2 } = options;
1176
+ const container = containerRef.current;
1177
+ if (!container) return;
1178
+ const rect = container.getBoundingClientRect();
1179
+ let rippleX;
1180
+ let rippleY;
1181
+ let rippleSize;
1182
+ if (center || !event || event.nativeEvent.clientX === void 0) {
1183
+ rippleX = Math.round(rect.width / 2);
1184
+ rippleY = Math.round(rect.height / 2);
1185
+ rippleSize = Math.max(rect.width, rect.height);
1186
+ } else {
1187
+ const clientX = event.nativeEvent.clientX ?? event.nativeEvent.touches?.[0]?.clientX;
1188
+ const clientY = event.nativeEvent.clientY ?? event.nativeEvent.touches?.[0]?.clientY;
1189
+ rippleX = Math.round(clientX - rect.left);
1190
+ rippleY = Math.round(clientY - rect.top);
1191
+ const sizeX = Math.max(Math.abs(container.clientWidth - rippleX), rippleX) * 2 + 2;
1192
+ const sizeY = Math.max(Math.abs(container.clientHeight - rippleY), rippleY) * 2 + 2;
1193
+ rippleSize = Math.sqrt(sizeX ** 2 + sizeY ** 2);
1194
+ }
1195
+ const currentKey = nextKey.current;
1196
+ nextKey.current += 1;
1197
+ setRipples((prev) => [
1198
+ ...prev,
1199
+ {
1200
+ key: currentKey,
1201
+ rippleX,
1202
+ rippleY,
1203
+ rippleSize,
1204
+ pulsating: pulsate2,
1205
+ leaving: false
1206
+ }
1207
+ ]);
1208
+ },
1209
+ [centerProp]
1210
+ );
1211
+ const stop = React.useCallback(() => {
1212
+ setRipples((prev) => {
1213
+ if (prev.length === 0) return prev;
1214
+ return prev.map((ripple) => ({ ...ripple, leaving: true }));
1215
+ });
1216
+ setTimeout(() => {
1217
+ setRipples((prev) => prev.filter((r) => !r.leaving));
1218
+ }, 550);
1219
+ }, []);
1220
+ const pulsate = React.useCallback(() => {
1221
+ start(void 0, { pulsate: true });
1222
+ }, [start]);
1223
+ React.useImperativeHandle(
1224
+ ref,
1225
+ () => ({
1226
+ start,
1227
+ stop,
1228
+ pulsate
1229
+ }),
1230
+ [start, stop, pulsate]
1231
+ );
1232
+ return /* @__PURE__ */ jsx(
1233
+ TouchRippleRoot,
1234
+ {
1235
+ ref: containerRef,
1236
+ className,
1237
+ "aria-hidden": "true",
1238
+ ...rest,
1239
+ children: ripples.map((item) => {
1240
+ const style = {
1241
+ width: `${item.rippleSize}px`,
1242
+ height: `${item.rippleSize}px`,
1243
+ top: `${-(item.rippleSize / 2) + item.rippleY}px`,
1244
+ left: `${-(item.rippleSize / 2) + item.rippleX}px`
1245
+ };
1246
+ return /* @__PURE__ */ jsx(
1247
+ StyledRippleSpan,
1248
+ {
1249
+ pulsating: item.pulsating,
1250
+ leaving: item.leaving,
1251
+ style
1252
+ },
1253
+ item.key
1254
+ );
1255
+ })
1256
+ }
1257
+ );
1258
+ }
1259
+ );
1260
+ TouchRipple.displayName = "TouchRipple";
1261
+ function useRipple(options = {}) {
1262
+ const { disabled = false, disableRipple = false, center = false } = options;
1263
+ const rippleRef = React.useRef(null);
1264
+ const onMouseDown = React.useCallback(
1265
+ (event) => {
1266
+ if (disabled || disableRipple) return;
1267
+ rippleRef.current?.start(event);
1268
+ },
1269
+ [disabled, disableRipple]
1270
+ );
1271
+ const onMouseUp = React.useCallback(
1272
+ (event) => {
1273
+ if (disabled || disableRipple) return;
1274
+ rippleRef.current?.stop(event);
1275
+ },
1276
+ [disabled, disableRipple]
1277
+ );
1278
+ const onMouseLeave = React.useCallback(
1279
+ (event) => {
1280
+ if (disabled || disableRipple) return;
1281
+ rippleRef.current?.stop(event);
1282
+ },
1283
+ [disabled, disableRipple]
1284
+ );
1285
+ const onTouchStart = React.useCallback(
1286
+ (event) => {
1287
+ if (disabled || disableRipple) return;
1288
+ rippleRef.current?.start(event);
1289
+ },
1290
+ [disabled, disableRipple]
1291
+ );
1292
+ const onTouchEnd = React.useCallback(
1293
+ (event) => {
1294
+ if (disabled || disableRipple) return;
1295
+ rippleRef.current?.stop(event);
1296
+ },
1297
+ [disabled, disableRipple]
1298
+ );
1299
+ const onKeyDown = React.useCallback(
1300
+ (event) => {
1301
+ if (disabled || disableRipple) return;
1302
+ if (event.key === " " || event.key === "Enter") {
1303
+ rippleRef.current?.start(void 0, { pulsate: true });
1304
+ }
1305
+ },
1306
+ [disabled, disableRipple]
1307
+ );
1308
+ const onKeyUp = React.useCallback(
1309
+ (event) => {
1310
+ if (disabled || disableRipple) return;
1311
+ if (event.key === " " || event.key === "Enter") {
1312
+ rippleRef.current?.stop();
1313
+ }
1314
+ },
1315
+ [disabled, disableRipple]
1316
+ );
1317
+ const onBlur = React.useCallback(() => {
1318
+ rippleRef.current?.stop();
1319
+ }, []);
1320
+ const getRippleHandlers = React.useCallback(
1321
+ (props = {}) => {
1322
+ return {
1323
+ ...props,
1324
+ onMouseDown: composeEventHandlers(props.onMouseDown, onMouseDown),
1325
+ onMouseUp: composeEventHandlers(props.onMouseUp, onMouseUp),
1326
+ onMouseLeave: composeEventHandlers(props.onMouseLeave, onMouseLeave),
1327
+ onTouchStart: composeEventHandlers(props.onTouchStart, onTouchStart),
1328
+ onTouchEnd: composeEventHandlers(props.onTouchEnd, onTouchEnd),
1329
+ onKeyDown: composeEventHandlers(props.onKeyDown, onKeyDown),
1330
+ onKeyUp: composeEventHandlers(props.onKeyUp, onKeyUp),
1331
+ onBlur: composeEventHandlers(props.onBlur, onBlur)
1332
+ };
1333
+ },
1334
+ [
1335
+ onMouseDown,
1336
+ onMouseUp,
1337
+ onMouseLeave,
1338
+ onTouchStart,
1339
+ onTouchEnd,
1340
+ onKeyDown,
1341
+ onKeyUp,
1342
+ onBlur
1343
+ ]
1344
+ );
1345
+ return {
1346
+ rippleRef,
1347
+ rippleProps: {
1348
+ ref: rippleRef,
1349
+ center
1350
+ },
1351
+ getRippleHandlers
1352
+ };
1353
+ }
261
1354
  function ButtonSpinner() {
262
1355
  return /* @__PURE__ */ jsxs(
263
1356
  "svg",
@@ -292,6 +1385,11 @@ function ButtonSpinner() {
292
1385
  }
293
1386
  );
294
1387
  }
1388
+ var StyledButtonRoot = styled("button", {
1389
+ name: "ChellaaButton",
1390
+ slot: "Root",
1391
+ shouldForwardProp: (prop) => prop !== "variant" && prop !== "colorScheme" && prop !== "isFullWidth" && prop !== "isLoading" && prop !== "isDisabled" && prop !== "loadingText" && prop !== "loadingPosition" && prop !== "startIcon" && prop !== "endIcon" && prop !== "disableRipple" && prop !== "asChild"
1392
+ })({});
295
1393
  var Button = React.forwardRef(
296
1394
  function Button2(props, forwardedRef) {
297
1395
  const {
@@ -312,6 +1410,8 @@ var Button = React.forwardRef(
312
1410
  type = "button",
313
1411
  onClick,
314
1412
  onKeyDown,
1413
+ disableRipple = false,
1414
+ sx,
315
1415
  ...restProps
316
1416
  } = props;
317
1417
  const buttonGroup = useButtonGroupContext();
@@ -320,6 +1420,10 @@ var Button = React.forwardRef(
320
1420
  const colorScheme = colorSchemeProp ?? buttonGroup?.colorScheme ?? "primary";
321
1421
  const isDisabled = isDisabledProp ?? disabledProp ?? buttonGroup?.isDisabled ?? false;
322
1422
  const isEffectivelyDisabled = isDisabled || isLoading;
1423
+ const { rippleProps, getRippleHandlers } = useRipple({
1424
+ disabled: isEffectivelyDisabled,
1425
+ disableRipple
1426
+ });
323
1427
  const handleClick = (event) => {
324
1428
  if (isEffectivelyDisabled) {
325
1429
  event.preventDefault();
@@ -351,12 +1455,14 @@ var Button = React.forwardRef(
351
1455
  const spinner = /* @__PURE__ */ jsx(ButtonSpinner, {});
352
1456
  if (asChild) {
353
1457
  return /* @__PURE__ */ jsx(
354
- Slot,
1458
+ StyledButtonRoot,
355
1459
  {
1460
+ as: Slot,
356
1461
  ref: forwardedRef,
357
1462
  className: buttonClassName,
358
1463
  "aria-disabled": isEffectivelyDisabled ? true : void 0,
359
1464
  "aria-busy": isLoading ? true : void 0,
1465
+ sx,
360
1466
  onClick: handleClick,
361
1467
  onKeyDown: handleKeyDown,
362
1468
  ...restProps,
@@ -365,8 +1471,13 @@ var Button = React.forwardRef(
365
1471
  );
366
1472
  }
367
1473
  const isCenterLoading = isLoading && loadingPosition === "center";
368
- return /* @__PURE__ */ jsx(
369
- "button",
1474
+ const buttonHandlers = getRippleHandlers({
1475
+ onClick: handleClick,
1476
+ onKeyDown: handleKeyDown,
1477
+ ...restProps
1478
+ });
1479
+ return /* @__PURE__ */ jsxs(
1480
+ StyledButtonRoot,
370
1481
  {
371
1482
  ref: forwardedRef,
372
1483
  type,
@@ -374,13 +1485,33 @@ var Button = React.forwardRef(
374
1485
  "aria-disabled": isEffectivelyDisabled ? true : void 0,
375
1486
  "aria-busy": isLoading ? true : void 0,
376
1487
  className: buttonClassName,
377
- onClick: handleClick,
378
- onKeyDown: handleKeyDown,
379
- ...restProps,
380
- children: isCenterLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
381
- /* @__PURE__ */ jsx("span", { className: "cl-button__spinner-wrapper--center", children: spinner }),
382
- /* @__PURE__ */ jsxs("span", { className: "cl-button__content--hidden", children: [
383
- startIcon && /* @__PURE__ */ jsx(
1488
+ sx,
1489
+ ...buttonHandlers,
1490
+ children: [
1491
+ isCenterLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
1492
+ /* @__PURE__ */ jsx("span", { className: "cl-button__spinner-wrapper--center", children: spinner }),
1493
+ /* @__PURE__ */ jsxs("span", { className: "cl-button__content--hidden", children: [
1494
+ startIcon && /* @__PURE__ */ jsx(
1495
+ "span",
1496
+ {
1497
+ className: "cl-button__icon cl-button__icon--start",
1498
+ "aria-hidden": "true",
1499
+ children: startIcon
1500
+ }
1501
+ ),
1502
+ children !== void 0 && /* @__PURE__ */ jsx("span", { className: "cl-button__label", children }),
1503
+ endIcon && /* @__PURE__ */ jsx(
1504
+ "span",
1505
+ {
1506
+ className: "cl-button__icon cl-button__icon--end",
1507
+ "aria-hidden": "true",
1508
+ children: endIcon
1509
+ }
1510
+ )
1511
+ ] })
1512
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1513
+ isLoading && loadingPosition === "start" && spinner,
1514
+ !isLoading && startIcon && /* @__PURE__ */ jsx(
384
1515
  "span",
385
1516
  {
386
1517
  className: "cl-button__icon cl-button__icon--start",
@@ -388,8 +1519,9 @@ var Button = React.forwardRef(
388
1519
  children: startIcon
389
1520
  }
390
1521
  ),
391
- children !== void 0 && /* @__PURE__ */ jsx("span", { className: "cl-button__label", children }),
392
- endIcon && /* @__PURE__ */ jsx(
1522
+ isLoading && loadingText ? /* @__PURE__ */ jsx("span", { className: "cl-button__label", children: loadingText }) : children !== void 0 ? /* @__PURE__ */ jsx("span", { className: "cl-button__label", children }) : null,
1523
+ isLoading && loadingPosition === "end" && spinner,
1524
+ !isLoading && endIcon && /* @__PURE__ */ jsx(
393
1525
  "span",
394
1526
  {
395
1527
  className: "cl-button__icon cl-button__icon--end",
@@ -397,28 +1529,9 @@ var Button = React.forwardRef(
397
1529
  children: endIcon
398
1530
  }
399
1531
  )
400
- ] })
401
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
402
- isLoading && loadingPosition === "start" && spinner,
403
- !isLoading && startIcon && /* @__PURE__ */ jsx(
404
- "span",
405
- {
406
- className: "cl-button__icon cl-button__icon--start",
407
- "aria-hidden": "true",
408
- children: startIcon
409
- }
410
- ),
411
- isLoading && loadingText ? /* @__PURE__ */ jsx("span", { className: "cl-button__label", children: loadingText }) : children !== void 0 ? /* @__PURE__ */ jsx("span", { className: "cl-button__label", children }) : null,
412
- isLoading && loadingPosition === "end" && spinner,
413
- !isLoading && endIcon && /* @__PURE__ */ jsx(
414
- "span",
415
- {
416
- className: "cl-button__icon cl-button__icon--end",
417
- "aria-hidden": "true",
418
- children: endIcon
419
- }
420
- )
421
- ] })
1532
+ ] }),
1533
+ !disableRipple && !isEffectivelyDisabled && /* @__PURE__ */ jsx(TouchRipple, { ...rippleProps })
1534
+ ]
422
1535
  }
423
1536
  );
424
1537
  }
@@ -488,7 +1601,2862 @@ var ButtonGroup = React.forwardRef(
488
1601
  }
489
1602
  );
490
1603
  ButtonGroup.displayName = "ButtonGroup";
1604
+ var StyledBoxRoot = styled("div", {
1605
+ name: "ChellaaBox",
1606
+ slot: "Root",
1607
+ shouldForwardProp: (prop) => prop !== "asChild" && prop !== "component"
1608
+ })({});
1609
+ var Box = React.forwardRef(
1610
+ function Box2(props, ref) {
1611
+ const { asChild = false, component, as, className, style, sx, children, ...rest } = props;
1612
+ const targetTag = component || as;
1613
+ const boxClassName = classNames("cl-box", className);
1614
+ if (asChild) {
1615
+ return /* @__PURE__ */ jsx(
1616
+ StyledBoxRoot,
1617
+ {
1618
+ as: Slot,
1619
+ ref,
1620
+ className: boxClassName,
1621
+ style,
1622
+ sx,
1623
+ ...rest,
1624
+ children
1625
+ }
1626
+ );
1627
+ }
1628
+ if (targetTag) {
1629
+ return /* @__PURE__ */ jsx(
1630
+ StyledBoxRoot,
1631
+ {
1632
+ as: targetTag,
1633
+ ref,
1634
+ className: boxClassName,
1635
+ style,
1636
+ sx,
1637
+ ...rest,
1638
+ children
1639
+ }
1640
+ );
1641
+ }
1642
+ return /* @__PURE__ */ jsx(
1643
+ StyledBoxRoot,
1644
+ {
1645
+ ref,
1646
+ className: boxClassName,
1647
+ style,
1648
+ sx,
1649
+ ...rest,
1650
+ children
1651
+ }
1652
+ );
1653
+ }
1654
+ );
1655
+ Box.displayName = "Box";
1656
+ var StyledStackRoot = styled("div", {
1657
+ name: "ChellaaStack",
1658
+ slot: "Root",
1659
+ shouldForwardProp: (prop) => prop !== "direction" && prop !== "spacing" && prop !== "alignItems" && prop !== "justifyContent" && prop !== "flexWrap" && prop !== "useFlexGap" && prop !== "asChild" && prop !== "component"
1660
+ })(({ theme, ownerState }) => {
1661
+ const styles = {};
1662
+ if (typeof ownerState.direction === "object") {
1663
+ Object.assign(
1664
+ styles,
1665
+ parseSx(theme, { flexDirection: ownerState.direction })
1666
+ );
1667
+ }
1668
+ if (ownerState.spacing !== void 0 && ownerState.spacing !== 0) {
1669
+ Object.assign(
1670
+ styles,
1671
+ parseSx(theme, { gap: ownerState.spacing })
1672
+ );
1673
+ }
1674
+ if (ownerState.alignItems !== void 0) {
1675
+ Object.assign(
1676
+ styles,
1677
+ parseSx(theme, { alignItems: ownerState.alignItems })
1678
+ );
1679
+ }
1680
+ if (ownerState.justifyContent !== void 0) {
1681
+ Object.assign(
1682
+ styles,
1683
+ parseSx(theme, { justifyContent: ownerState.justifyContent })
1684
+ );
1685
+ }
1686
+ if (ownerState.flexWrap !== void 0) {
1687
+ Object.assign(
1688
+ styles,
1689
+ parseSx(theme, { flexWrap: ownerState.flexWrap })
1690
+ );
1691
+ }
1692
+ return styles;
1693
+ });
1694
+ var Stack = React.forwardRef(
1695
+ function Stack2(props, ref) {
1696
+ const {
1697
+ asChild = false,
1698
+ component,
1699
+ as,
1700
+ direction = "column",
1701
+ spacing = 0,
1702
+ alignItems,
1703
+ justifyContent,
1704
+ flexWrap,
1705
+ useFlexGap = true,
1706
+ divider,
1707
+ className,
1708
+ style,
1709
+ sx,
1710
+ children,
1711
+ ...rest
1712
+ } = props;
1713
+ const ownerState = {
1714
+ direction,
1715
+ spacing,
1716
+ alignItems,
1717
+ justifyContent,
1718
+ flexWrap,
1719
+ useFlexGap
1720
+ };
1721
+ const isSimpleDirection = typeof direction === "string";
1722
+ const stackClassName = classNames(
1723
+ "cl-stack",
1724
+ isSimpleDirection && `cl-stack--${direction}`,
1725
+ className
1726
+ );
1727
+ const targetTag = component || as;
1728
+ let renderedChildren = children;
1729
+ if (divider && !asChild) {
1730
+ const validChildren = React.Children.toArray(children).filter(
1731
+ React.isValidElement
1732
+ );
1733
+ renderedChildren = validChildren.reduce(
1734
+ (acc, child, index) => {
1735
+ acc.push(child);
1736
+ if (index < validChildren.length - 1) {
1737
+ acc.push(
1738
+ React.isValidElement(divider) ? React.cloneElement(divider, {
1739
+ key: `stack-divider-${index}`
1740
+ }) : /* @__PURE__ */ jsx("span", { children: divider }, `stack-divider-${index}`)
1741
+ );
1742
+ }
1743
+ return acc;
1744
+ },
1745
+ []
1746
+ );
1747
+ }
1748
+ if (asChild) {
1749
+ return /* @__PURE__ */ jsx(
1750
+ StyledStackRoot,
1751
+ {
1752
+ as: Slot,
1753
+ ref,
1754
+ className: stackClassName,
1755
+ style,
1756
+ ownerState,
1757
+ sx,
1758
+ ...rest,
1759
+ children: renderedChildren
1760
+ }
1761
+ );
1762
+ }
1763
+ if (targetTag) {
1764
+ return /* @__PURE__ */ jsx(
1765
+ StyledStackRoot,
1766
+ {
1767
+ as: targetTag,
1768
+ ref,
1769
+ className: stackClassName,
1770
+ style,
1771
+ ownerState,
1772
+ sx,
1773
+ ...rest,
1774
+ children: renderedChildren
1775
+ }
1776
+ );
1777
+ }
1778
+ return /* @__PURE__ */ jsx(
1779
+ StyledStackRoot,
1780
+ {
1781
+ ref,
1782
+ className: stackClassName,
1783
+ style,
1784
+ ownerState,
1785
+ sx,
1786
+ ...rest,
1787
+ children: renderedChildren
1788
+ }
1789
+ );
1790
+ }
1791
+ );
1792
+ Stack.displayName = "Stack";
1793
+ var StyledFlexRoot = styled("div", {
1794
+ name: "ChellaaFlex",
1795
+ slot: "Root",
1796
+ shouldForwardProp: (prop) => prop !== "direction" && prop !== "spacing" && prop !== "gap" && prop !== "alignItems" && prop !== "align" && prop !== "justifyContent" && prop !== "justify" && prop !== "flexWrap" && prop !== "wrap" && prop !== "inline" && prop !== "center" && prop !== "asChild" && prop !== "component"
1797
+ })(({ theme, ownerState }) => {
1798
+ const isCenter = ownerState.center ?? false;
1799
+ const styles = {};
1800
+ if (typeof ownerState.direction === "object") {
1801
+ Object.assign(
1802
+ styles,
1803
+ parseSx(theme, { flexDirection: ownerState.direction })
1804
+ );
1805
+ }
1806
+ const gapValue = ownerState.gap ?? ownerState.spacing;
1807
+ if (gapValue !== void 0) {
1808
+ Object.assign(styles, parseSx(theme, { gap: gapValue }));
1809
+ }
1810
+ if (!isCenter) {
1811
+ const alignVal = ownerState.align ?? ownerState.alignItems;
1812
+ if (alignVal !== void 0) {
1813
+ Object.assign(styles, parseSx(theme, { alignItems: alignVal }));
1814
+ }
1815
+ const justifyVal = ownerState.justify ?? ownerState.justifyContent;
1816
+ if (justifyVal !== void 0) {
1817
+ Object.assign(styles, parseSx(theme, { justifyContent: justifyVal }));
1818
+ }
1819
+ }
1820
+ const wrapVal = ownerState.wrap ?? ownerState.flexWrap;
1821
+ if (wrapVal !== void 0) {
1822
+ Object.assign(styles, parseSx(theme, { flexWrap: wrapVal }));
1823
+ }
1824
+ return styles;
1825
+ });
1826
+ var Flex = React.forwardRef(
1827
+ function Flex2(props, ref) {
1828
+ const {
1829
+ asChild = false,
1830
+ component,
1831
+ as,
1832
+ direction = "row",
1833
+ spacing,
1834
+ gap,
1835
+ alignItems,
1836
+ align,
1837
+ justifyContent,
1838
+ justify,
1839
+ flexWrap,
1840
+ wrap,
1841
+ inline = false,
1842
+ center = false,
1843
+ divider,
1844
+ className,
1845
+ style,
1846
+ sx,
1847
+ children,
1848
+ ...rest
1849
+ } = props;
1850
+ const ownerState = {
1851
+ direction,
1852
+ spacing,
1853
+ gap,
1854
+ alignItems,
1855
+ align,
1856
+ justifyContent,
1857
+ justify,
1858
+ flexWrap,
1859
+ wrap,
1860
+ inline,
1861
+ center
1862
+ };
1863
+ const isSimpleDirection = typeof direction === "string";
1864
+ const flexClassName = classNames(
1865
+ "cl-flex",
1866
+ inline && "cl-flex--inline",
1867
+ center && "cl-flex--center",
1868
+ isSimpleDirection && `cl-flex--${direction}`,
1869
+ className
1870
+ );
1871
+ const targetTag = component || as;
1872
+ let renderedChildren = children;
1873
+ if (divider && !asChild) {
1874
+ const validChildren = React.Children.toArray(children).filter(
1875
+ React.isValidElement
1876
+ );
1877
+ renderedChildren = validChildren.reduce(
1878
+ (acc, child, index) => {
1879
+ acc.push(child);
1880
+ if (index < validChildren.length - 1) {
1881
+ acc.push(
1882
+ React.isValidElement(divider) ? React.cloneElement(divider, {
1883
+ key: `flex-divider-${index}`
1884
+ }) : /* @__PURE__ */ jsx("span", { children: divider }, `flex-divider-${index}`)
1885
+ );
1886
+ }
1887
+ return acc;
1888
+ },
1889
+ []
1890
+ );
1891
+ }
1892
+ if (asChild) {
1893
+ return /* @__PURE__ */ jsx(
1894
+ StyledFlexRoot,
1895
+ {
1896
+ as: Slot,
1897
+ ref,
1898
+ className: flexClassName,
1899
+ style,
1900
+ ownerState,
1901
+ sx,
1902
+ ...rest,
1903
+ children: renderedChildren
1904
+ }
1905
+ );
1906
+ }
1907
+ if (targetTag) {
1908
+ return /* @__PURE__ */ jsx(
1909
+ StyledFlexRoot,
1910
+ {
1911
+ as: targetTag,
1912
+ ref,
1913
+ className: flexClassName,
1914
+ style,
1915
+ ownerState,
1916
+ sx,
1917
+ ...rest,
1918
+ children: renderedChildren
1919
+ }
1920
+ );
1921
+ }
1922
+ return /* @__PURE__ */ jsx(
1923
+ StyledFlexRoot,
1924
+ {
1925
+ ref,
1926
+ className: flexClassName,
1927
+ style,
1928
+ ownerState,
1929
+ sx,
1930
+ ...rest,
1931
+ children: renderedChildren
1932
+ }
1933
+ );
1934
+ }
1935
+ );
1936
+ Flex.displayName = "Flex";
1937
+ var StyledContainerRoot = styled("div", {
1938
+ name: "ChellaaContainer",
1939
+ slot: "Root",
1940
+ shouldForwardProp: (prop) => prop !== "maxWidth" && prop !== "fixed" && prop !== "disableGutters" && prop !== "asChild" && prop !== "component"
1941
+ })({});
1942
+ var Container = React.forwardRef(
1943
+ function Container2(props, ref) {
1944
+ const {
1945
+ asChild = false,
1946
+ component,
1947
+ as,
1948
+ maxWidth = "lg",
1949
+ fixed = false,
1950
+ disableGutters = false,
1951
+ className,
1952
+ style,
1953
+ sx,
1954
+ children,
1955
+ ...rest
1956
+ } = props;
1957
+ const containerClassName = classNames(
1958
+ "cl-container",
1959
+ disableGutters && "cl-container--disable-gutters",
1960
+ fixed && "cl-container--fixed",
1961
+ maxWidth !== false && `cl-container--${maxWidth}`,
1962
+ className
1963
+ );
1964
+ const targetTag = component || as;
1965
+ if (asChild) {
1966
+ return /* @__PURE__ */ jsx(
1967
+ StyledContainerRoot,
1968
+ {
1969
+ as: Slot,
1970
+ ref,
1971
+ className: containerClassName,
1972
+ style,
1973
+ sx,
1974
+ ...rest,
1975
+ children
1976
+ }
1977
+ );
1978
+ }
1979
+ if (targetTag) {
1980
+ return /* @__PURE__ */ jsx(
1981
+ StyledContainerRoot,
1982
+ {
1983
+ as: targetTag,
1984
+ ref,
1985
+ className: containerClassName,
1986
+ style,
1987
+ sx,
1988
+ ...rest,
1989
+ children
1990
+ }
1991
+ );
1992
+ }
1993
+ return /* @__PURE__ */ jsx(
1994
+ StyledContainerRoot,
1995
+ {
1996
+ ref,
1997
+ className: containerClassName,
1998
+ style,
1999
+ sx,
2000
+ ...rest,
2001
+ children
2002
+ }
2003
+ );
2004
+ }
2005
+ );
2006
+ Container.displayName = "Container";
2007
+ function generateGridSizeStyles(size, columns = 12) {
2008
+ if (size === true) {
2009
+ return {
2010
+ flexBasis: 0,
2011
+ flexGrow: 1,
2012
+ maxWidth: "100%"
2013
+ };
2014
+ }
2015
+ if (size === "auto") {
2016
+ return {
2017
+ flexBasis: "auto",
2018
+ flexGrow: 0,
2019
+ maxWidth: "none"
2020
+ };
2021
+ }
2022
+ if (typeof size === "number") {
2023
+ const widthPercentage = `${Math.round(size / columns * 1e8) / 1e6}%`;
2024
+ return {
2025
+ flexBasis: widthPercentage,
2026
+ flexGrow: 0,
2027
+ maxWidth: widthPercentage
2028
+ };
2029
+ }
2030
+ return {};
2031
+ }
2032
+ var StyledGridRoot = styled("div", {
2033
+ name: "ChellaaGrid",
2034
+ slot: "Root",
2035
+ shouldForwardProp: (prop) => prop !== "container" && prop !== "item" && prop !== "columns" && prop !== "spacing" && prop !== "rowSpacing" && prop !== "columnSpacing" && prop !== "direction" && prop !== "wrap" && prop !== "alignItems" && prop !== "justifyContent" && prop !== "xs" && prop !== "sm" && prop !== "md" && prop !== "lg" && prop !== "xl" && prop !== "asChild" && prop !== "component"
2036
+ })(({ theme, ownerState }) => {
2037
+ const styles = {};
2038
+ const columns = ownerState.columns ?? 12;
2039
+ if (ownerState.container) {
2040
+ if (typeof ownerState.direction === "object") {
2041
+ Object.assign(
2042
+ styles,
2043
+ parseSx(theme, { flexDirection: ownerState.direction })
2044
+ );
2045
+ }
2046
+ if (ownerState.spacing !== void 0) {
2047
+ Object.assign(styles, parseSx(theme, { gap: ownerState.spacing }));
2048
+ }
2049
+ if (ownerState.rowSpacing !== void 0) {
2050
+ Object.assign(styles, parseSx(theme, { rowGap: ownerState.rowSpacing }));
2051
+ }
2052
+ if (ownerState.columnSpacing !== void 0) {
2053
+ Object.assign(
2054
+ styles,
2055
+ parseSx(theme, { columnGap: ownerState.columnSpacing })
2056
+ );
2057
+ }
2058
+ if (ownerState.alignItems !== void 0) {
2059
+ Object.assign(
2060
+ styles,
2061
+ parseSx(theme, { alignItems: ownerState.alignItems })
2062
+ );
2063
+ }
2064
+ if (ownerState.justifyContent !== void 0) {
2065
+ Object.assign(
2066
+ styles,
2067
+ parseSx(theme, { justifyContent: ownerState.justifyContent })
2068
+ );
2069
+ }
2070
+ }
2071
+ const bpSizes = {
2072
+ xs: ownerState.xs,
2073
+ sm: ownerState.sm,
2074
+ md: ownerState.md,
2075
+ lg: ownerState.lg,
2076
+ xl: ownerState.xl
2077
+ };
2078
+ for (const bp of breakpointKeys) {
2079
+ const size = bpSizes[bp];
2080
+ if (size !== void 0) {
2081
+ const sizeStyles = generateGridSizeStyles(size, columns);
2082
+ if (bp === "xs") {
2083
+ Object.assign(styles, sizeStyles);
2084
+ } else {
2085
+ const media = theme.breakpoints.up(bp);
2086
+ styles[media] = {
2087
+ ...styles[media] || {},
2088
+ ...sizeStyles
2089
+ };
2090
+ }
2091
+ }
2092
+ }
2093
+ return styles;
2094
+ });
2095
+ var Grid = React.forwardRef(
2096
+ function Grid2(props, ref) {
2097
+ const {
2098
+ asChild = false,
2099
+ component,
2100
+ as,
2101
+ container = false,
2102
+ item = false,
2103
+ columns = 12,
2104
+ spacing,
2105
+ rowSpacing,
2106
+ columnSpacing,
2107
+ direction = "row",
2108
+ wrap = "wrap",
2109
+ alignItems,
2110
+ justifyContent,
2111
+ xs,
2112
+ sm,
2113
+ md,
2114
+ lg,
2115
+ xl,
2116
+ className,
2117
+ style,
2118
+ sx,
2119
+ children,
2120
+ ...rest
2121
+ } = props;
2122
+ const ownerState = {
2123
+ container,
2124
+ item,
2125
+ columns,
2126
+ spacing,
2127
+ rowSpacing,
2128
+ columnSpacing,
2129
+ direction,
2130
+ wrap,
2131
+ alignItems,
2132
+ justifyContent,
2133
+ xs,
2134
+ sm,
2135
+ md,
2136
+ lg,
2137
+ xl
2138
+ };
2139
+ const isSimpleDirection = typeof direction === "string";
2140
+ const gridClassName = classNames(
2141
+ "cl-grid",
2142
+ container && "cl-grid--container",
2143
+ item && "cl-grid--item",
2144
+ wrap && `cl-grid--${wrap}`,
2145
+ isSimpleDirection && `cl-grid--direction-${direction}`,
2146
+ className
2147
+ );
2148
+ const targetTag = component || as;
2149
+ if (asChild) {
2150
+ return /* @__PURE__ */ jsx(
2151
+ StyledGridRoot,
2152
+ {
2153
+ as: Slot,
2154
+ ref,
2155
+ className: gridClassName,
2156
+ style,
2157
+ ownerState,
2158
+ sx,
2159
+ ...rest,
2160
+ children
2161
+ }
2162
+ );
2163
+ }
2164
+ if (targetTag) {
2165
+ return /* @__PURE__ */ jsx(
2166
+ StyledGridRoot,
2167
+ {
2168
+ as: targetTag,
2169
+ ref,
2170
+ className: gridClassName,
2171
+ style,
2172
+ ownerState,
2173
+ sx,
2174
+ ...rest,
2175
+ children
2176
+ }
2177
+ );
2178
+ }
2179
+ return /* @__PURE__ */ jsx(
2180
+ StyledGridRoot,
2181
+ {
2182
+ ref,
2183
+ className: gridClassName,
2184
+ style,
2185
+ ownerState,
2186
+ sx,
2187
+ ...rest,
2188
+ children
2189
+ }
2190
+ );
2191
+ }
2192
+ );
2193
+ Grid.displayName = "Grid";
2194
+ var StyledDividerRoot = styled("hr", {
2195
+ name: "ChellaaDivider",
2196
+ slot: "Root",
2197
+ shouldForwardProp: (prop) => prop !== "orientation" && prop !== "variant" && prop !== "lineStyle" && prop !== "flexItem" && prop !== "light" && prop !== "textAlign" && prop !== "hasChildren" && prop !== "asChild" && prop !== "component"
2198
+ })({});
2199
+ var Divider = React.forwardRef(
2200
+ function Divider2(props, ref) {
2201
+ const {
2202
+ asChild = false,
2203
+ component,
2204
+ as,
2205
+ orientation = "horizontal",
2206
+ variant = "fullWidth",
2207
+ lineStyle = "solid",
2208
+ flexItem = false,
2209
+ light = false,
2210
+ textAlign = "center",
2211
+ className,
2212
+ style,
2213
+ sx,
2214
+ children,
2215
+ role: roleProp,
2216
+ ...rest
2217
+ } = props;
2218
+ const hasChildren = Boolean(children);
2219
+ const dividerClassName = classNames(
2220
+ "cl-divider",
2221
+ `cl-divider--${orientation}`,
2222
+ variant !== "fullWidth" && `cl-divider--${variant}`,
2223
+ lineStyle !== "solid" && `cl-divider--${lineStyle}`,
2224
+ flexItem && "cl-divider--flex-item",
2225
+ light && "cl-divider--light",
2226
+ hasChildren && "cl-divider--with-children",
2227
+ hasChildren && `cl-divider--align-${textAlign}`,
2228
+ className
2229
+ );
2230
+ let defaultTag = "hr";
2231
+ if (orientation === "vertical" || hasChildren) {
2232
+ defaultTag = "div";
2233
+ }
2234
+ const targetTag = component || as || defaultTag;
2235
+ const isNativeHr = targetTag === "hr";
2236
+ const role = roleProp || (isNativeHr ? void 0 : "separator");
2237
+ const ariaOrientation = isNativeHr ? void 0 : orientation === "vertical" ? "vertical" : void 0;
2238
+ if (asChild) {
2239
+ return /* @__PURE__ */ jsx(
2240
+ StyledDividerRoot,
2241
+ {
2242
+ as: Slot,
2243
+ ref,
2244
+ className: dividerClassName,
2245
+ style,
2246
+ sx,
2247
+ role,
2248
+ "aria-orientation": ariaOrientation,
2249
+ ...rest,
2250
+ children: hasChildren ? /* @__PURE__ */ jsx("span", { className: "cl-divider__wrapper ChellaaDivider-wrapper", children }) : children
2251
+ }
2252
+ );
2253
+ }
2254
+ return /* @__PURE__ */ jsx(
2255
+ StyledDividerRoot,
2256
+ {
2257
+ as: targetTag,
2258
+ ref,
2259
+ className: dividerClassName,
2260
+ style,
2261
+ sx,
2262
+ role,
2263
+ "aria-orientation": ariaOrientation,
2264
+ ...rest,
2265
+ children: hasChildren ? /* @__PURE__ */ jsx("span", { className: "cl-divider__wrapper ChellaaDivider-wrapper", children }) : null
2266
+ }
2267
+ );
2268
+ }
2269
+ );
2270
+ Divider.displayName = "Divider";
2271
+ var defaultVariantMapping = {
2272
+ h1: "h1",
2273
+ h2: "h2",
2274
+ h3: "h3",
2275
+ h4: "h4",
2276
+ h5: "h5",
2277
+ h6: "h6",
2278
+ subtitle1: "h6",
2279
+ subtitle2: "h6",
2280
+ body1: "p",
2281
+ body2: "p",
2282
+ button: "span",
2283
+ caption: "span",
2284
+ overline: "span"
2285
+ };
2286
+ function resolveTypographyColor(theme, color) {
2287
+ if (!color || color === "inherit" || color === "currentColor") {
2288
+ return color;
2289
+ }
2290
+ const paletteAny = theme.palette;
2291
+ if (paletteAny[color] && typeof paletteAny[color].main === "string") {
2292
+ return paletteAny[color].main;
2293
+ }
2294
+ if (color.includes(".")) {
2295
+ const parts = color.split(".");
2296
+ let current = theme.palette;
2297
+ for (const part of parts) {
2298
+ if (current && typeof current === "object" && part in current) {
2299
+ current = current[part];
2300
+ } else {
2301
+ current = void 0;
2302
+ break;
2303
+ }
2304
+ }
2305
+ if (typeof current === "string") {
2306
+ return current;
2307
+ }
2308
+ }
2309
+ return color;
2310
+ }
2311
+ var StyledTypographyRoot = styled("span", {
2312
+ name: "ChellaaTypography",
2313
+ slot: "Root",
2314
+ shouldForwardProp: (prop) => prop !== "variant" && prop !== "align" && prop !== "color" && prop !== "gutterBottom" && prop !== "noWrap" && prop !== "lineClamp" && prop !== "asChild" && prop !== "component"
2315
+ })(({ theme, color }) => {
2316
+ if (color) {
2317
+ return {
2318
+ color: resolveTypographyColor(theme, color)
2319
+ };
2320
+ }
2321
+ return {};
2322
+ });
2323
+ var Typography = React.forwardRef(
2324
+ function Typography2(props, ref) {
2325
+ const {
2326
+ asChild = false,
2327
+ component,
2328
+ as,
2329
+ variant = "body1",
2330
+ align = "inherit",
2331
+ color,
2332
+ gutterBottom = false,
2333
+ noWrap = false,
2334
+ lineClamp,
2335
+ className,
2336
+ style,
2337
+ sx,
2338
+ children,
2339
+ ...rest
2340
+ } = props;
2341
+ const typographyClassName = classNames(
2342
+ "cl-typography",
2343
+ `cl-typography--${variant}`,
2344
+ align && align !== "inherit" && `cl-typography--align-${align}`,
2345
+ gutterBottom && "cl-typography--gutter-bottom",
2346
+ noWrap && "cl-typography--no-wrap",
2347
+ lineClamp !== void 0 && lineClamp > 0 && "cl-typography--line-clamp",
2348
+ className
2349
+ );
2350
+ const inlineStyle = {
2351
+ ...lineClamp !== void 0 && lineClamp > 0 ? { WebkitLineClamp: lineClamp } : {},
2352
+ ...style
2353
+ };
2354
+ const targetTag = component || as || defaultVariantMapping[variant] || "span";
2355
+ if (asChild) {
2356
+ return /* @__PURE__ */ jsx(
2357
+ StyledTypographyRoot,
2358
+ {
2359
+ as: Slot,
2360
+ ref,
2361
+ className: typographyClassName,
2362
+ style: inlineStyle,
2363
+ color,
2364
+ sx,
2365
+ ...rest,
2366
+ children
2367
+ }
2368
+ );
2369
+ }
2370
+ return /* @__PURE__ */ jsx(
2371
+ StyledTypographyRoot,
2372
+ {
2373
+ as: targetTag,
2374
+ ref,
2375
+ className: typographyClassName,
2376
+ style: inlineStyle,
2377
+ color,
2378
+ sx,
2379
+ ...rest,
2380
+ children
2381
+ }
2382
+ );
2383
+ }
2384
+ );
2385
+ Typography.displayName = "Typography";
2386
+ var Heading = React.forwardRef(
2387
+ function Heading2(props, ref) {
2388
+ const { level = 2, variant, component, ...rest } = props;
2389
+ const levelTag = `h${level}`;
2390
+ const resolvedVariant = variant || levelTag;
2391
+ const resolvedComponent = component || levelTag;
2392
+ return /* @__PURE__ */ jsx(
2393
+ Typography,
2394
+ {
2395
+ ref,
2396
+ component: resolvedComponent,
2397
+ variant: resolvedVariant,
2398
+ ...rest
2399
+ }
2400
+ );
2401
+ }
2402
+ );
2403
+ Heading.displayName = "Heading";
2404
+ var sizeToVariant = {
2405
+ xs: "caption",
2406
+ sm: "body2",
2407
+ md: "body1",
2408
+ lg: "subtitle1",
2409
+ xl: "h6"
2410
+ };
2411
+ var Text = React.forwardRef(
2412
+ function Text2(props, ref) {
2413
+ const { size, variant, block = false, component, ...rest } = props;
2414
+ const resolvedVariant = variant || (size ? sizeToVariant[size] : "body1");
2415
+ const defaultTag = block ? "p" : "span";
2416
+ const resolvedComponent = component || defaultTag;
2417
+ return /* @__PURE__ */ jsx(
2418
+ Typography,
2419
+ {
2420
+ ref,
2421
+ component: resolvedComponent,
2422
+ variant: resolvedVariant,
2423
+ ...rest
2424
+ }
2425
+ );
2426
+ }
2427
+ );
2428
+ Text.displayName = "Text";
2429
+ var Paragraph = React.forwardRef(
2430
+ function Paragraph2(props, ref) {
2431
+ const { component = "p", variant = "body1", gutterBottom = true, ...rest } = props;
2432
+ return /* @__PURE__ */ jsx(
2433
+ Typography,
2434
+ {
2435
+ ref,
2436
+ component,
2437
+ variant,
2438
+ gutterBottom,
2439
+ ...rest
2440
+ }
2441
+ );
2442
+ }
2443
+ );
2444
+ Paragraph.displayName = "Paragraph";
2445
+ var StyledCodeRoot = styled("code", {
2446
+ name: "ChellaaCode",
2447
+ slot: "Root",
2448
+ shouldForwardProp: (prop) => prop !== "colorScheme" && prop !== "asChild" && prop !== "component"
2449
+ })({});
2450
+ var Code = React.forwardRef(
2451
+ function Code2(props, ref) {
2452
+ const {
2453
+ asChild = false,
2454
+ component = "code",
2455
+ as,
2456
+ colorScheme = "default",
2457
+ className,
2458
+ style,
2459
+ sx,
2460
+ children,
2461
+ ...rest
2462
+ } = props;
2463
+ const codeClassName = classNames(
2464
+ "cl-code",
2465
+ colorScheme !== "default" && `cl-code--${colorScheme}`,
2466
+ className
2467
+ );
2468
+ const targetTag = component || as || "code";
2469
+ if (asChild) {
2470
+ return /* @__PURE__ */ jsx(
2471
+ StyledCodeRoot,
2472
+ {
2473
+ as: Slot,
2474
+ ref,
2475
+ className: codeClassName,
2476
+ style,
2477
+ sx,
2478
+ ...rest,
2479
+ children
2480
+ }
2481
+ );
2482
+ }
2483
+ return /* @__PURE__ */ jsx(
2484
+ StyledCodeRoot,
2485
+ {
2486
+ as: targetTag,
2487
+ ref,
2488
+ className: codeClassName,
2489
+ style,
2490
+ sx,
2491
+ ...rest,
2492
+ children
2493
+ }
2494
+ );
2495
+ }
2496
+ );
2497
+ Code.displayName = "Code";
2498
+ var MODIFIER_SYMBOLS = {
2499
+ command: "\u2318",
2500
+ cmd: "\u2318",
2501
+ shift: "\u21E7",
2502
+ option: "\u2325",
2503
+ alt: "\u2325",
2504
+ control: "\u2303",
2505
+ ctrl: "\u2303",
2506
+ enter: "\u21B5",
2507
+ escape: "Esc",
2508
+ esc: "Esc",
2509
+ tab: "\u21E5",
2510
+ backspace: "\u232B",
2511
+ delete: "\u2326",
2512
+ del: "\u2326",
2513
+ up: "\u2191",
2514
+ down: "\u2193",
2515
+ left: "\u2190",
2516
+ right: "\u2192"
2517
+ };
2518
+ var StyledKbdRoot = styled("kbd", {
2519
+ name: "ChellaaKbd",
2520
+ slot: "Root",
2521
+ shouldForwardProp: (prop) => prop !== "size" && prop !== "variant" && prop !== "modifier" && prop !== "asChild" && prop !== "component"
2522
+ })({});
2523
+ var Kbd = React.forwardRef(
2524
+ function Kbd2(props, ref) {
2525
+ const {
2526
+ asChild = false,
2527
+ component = "kbd",
2528
+ as,
2529
+ size = "md",
2530
+ variant = "outline",
2531
+ modifier,
2532
+ className,
2533
+ style,
2534
+ sx,
2535
+ children,
2536
+ ...rest
2537
+ } = props;
2538
+ const kbdClassName = classNames(
2539
+ "cl-kbd",
2540
+ `cl-kbd--${size}`,
2541
+ `cl-kbd--${variant}`,
2542
+ className
2543
+ );
2544
+ const targetTag = component || as || "kbd";
2545
+ const content = children ?? (modifier ? MODIFIER_SYMBOLS[modifier] ?? modifier : null);
2546
+ if (asChild) {
2547
+ return /* @__PURE__ */ jsx(
2548
+ StyledKbdRoot,
2549
+ {
2550
+ as: Slot,
2551
+ ref,
2552
+ className: kbdClassName,
2553
+ style,
2554
+ sx,
2555
+ ...rest,
2556
+ children: content
2557
+ }
2558
+ );
2559
+ }
2560
+ return /* @__PURE__ */ jsx(
2561
+ StyledKbdRoot,
2562
+ {
2563
+ as: targetTag,
2564
+ ref,
2565
+ className: kbdClassName,
2566
+ style,
2567
+ sx,
2568
+ ...rest,
2569
+ children: content
2570
+ }
2571
+ );
2572
+ }
2573
+ );
2574
+ Kbd.displayName = "Kbd";
2575
+ var FormFieldContext = React.createContext(void 0);
2576
+ function useFormField() {
2577
+ return React.useContext(FormFieldContext);
2578
+ }
2579
+ var InputBase = React.forwardRef(function InputBase2({ className, ownerState: _ownerState, ...props }, ref) {
2580
+ return /* @__PURE__ */ jsx(
2581
+ "input",
2582
+ {
2583
+ ref,
2584
+ className: classNames("cl-input__input", className),
2585
+ ...props
2586
+ }
2587
+ );
2588
+ });
2589
+ InputBase.displayName = "InputBase";
2590
+ var StyledInputRoot = styled("div", {
2591
+ name: "ChellaaInput",
2592
+ slot: "Root",
2593
+ shouldForwardProp: (prop) => prop !== "variant" && prop !== "size" && prop !== "fullWidth" && prop !== "error" && prop !== "disabled" && prop !== "readOnly" && prop !== "hasStartAdornment" && prop !== "hasEndAdornment" && prop !== "focused" && prop !== "asChild" && prop !== "component" && prop !== "ownerState"
2594
+ })({});
2595
+ var Input = React.forwardRef(
2596
+ function Input2(props, ref) {
2597
+ const formField = useFormField();
2598
+ const {
2599
+ asChild = false,
2600
+ component,
2601
+ as,
2602
+ variant = "outlined",
2603
+ size = "md",
2604
+ fullWidth = false,
2605
+ error: errorProp,
2606
+ disabled: disabledProp,
2607
+ readOnly: readOnlyProp,
2608
+ required: requiredProp,
2609
+ startAdornment,
2610
+ endAdornment,
2611
+ clearable = false,
2612
+ onClear,
2613
+ inputRef: inputRefProp,
2614
+ value: valueProp,
2615
+ defaultValue,
2616
+ onChange,
2617
+ type = "text",
2618
+ id: idProp,
2619
+ className,
2620
+ style,
2621
+ sx,
2622
+ inputProps,
2623
+ "aria-describedby": ariaDescribedByProp,
2624
+ ...restInputProps
2625
+ } = props;
2626
+ const id = idProp ?? formField?.id;
2627
+ const error = errorProp ?? formField?.error ?? false;
2628
+ const disabled = disabledProp ?? formField?.disabled ?? false;
2629
+ const readOnly = readOnlyProp ?? formField?.readOnly ?? false;
2630
+ const required = requiredProp ?? formField?.required ?? false;
2631
+ const ariaDescribedBy = [
2632
+ ariaDescribedByProp,
2633
+ formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
2634
+ formField?.hasHelperText ? formField.helperTextId : null
2635
+ ].filter(Boolean).join(" ") || void 0;
2636
+ const [internalValue, setInternalValue] = React.useState(() => {
2637
+ if (valueProp !== void 0) return String(valueProp);
2638
+ if (defaultValue !== void 0) return String(defaultValue);
2639
+ return "";
2640
+ });
2641
+ const isControlled = valueProp !== void 0;
2642
+ const currentValue = isControlled ? String(valueProp ?? "") : internalValue;
2643
+ const innerInputRef = React.useRef(null);
2644
+ const handleInputRef = React.useCallback(
2645
+ (node) => {
2646
+ innerInputRef.current = node;
2647
+ if (typeof inputRefProp === "function") {
2648
+ inputRefProp(node);
2649
+ } else if (inputRefProp && "current" in inputRefProp) {
2650
+ inputRefProp.current = node;
2651
+ }
2652
+ },
2653
+ [inputRefProp]
2654
+ );
2655
+ const handleChange = (event) => {
2656
+ if (!isControlled) {
2657
+ setInternalValue(event.target.value);
2658
+ }
2659
+ onChange?.(event);
2660
+ };
2661
+ const handleClear = (e) => {
2662
+ e.stopPropagation();
2663
+ if (!isControlled) {
2664
+ setInternalValue("");
2665
+ }
2666
+ if (innerInputRef.current) {
2667
+ innerInputRef.current.value = "";
2668
+ const event = new Event("input", { bubbles: true });
2669
+ innerInputRef.current.dispatchEvent(event);
2670
+ innerInputRef.current.focus();
2671
+ }
2672
+ onClear?.();
2673
+ };
2674
+ const handleWrapperClick = () => {
2675
+ if (innerInputRef.current && document.activeElement !== innerInputRef.current) {
2676
+ innerInputRef.current.focus();
2677
+ }
2678
+ };
2679
+ const showClear = clearable && !disabled && !readOnly && currentValue.length > 0;
2680
+ const clearButton = showClear ? /* @__PURE__ */ jsx(
2681
+ "button",
2682
+ {
2683
+ type: "button",
2684
+ className: "cl-input__clear",
2685
+ "aria-label": "Clear input",
2686
+ onClick: handleClear,
2687
+ children: /* @__PURE__ */ jsxs(
2688
+ "svg",
2689
+ {
2690
+ width: "14",
2691
+ height: "14",
2692
+ viewBox: "0 0 24 24",
2693
+ fill: "none",
2694
+ stroke: "currentColor",
2695
+ strokeWidth: "2.5",
2696
+ strokeLinecap: "round",
2697
+ strokeLinejoin: "round",
2698
+ children: [
2699
+ /* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
2700
+ /* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
2701
+ ]
2702
+ }
2703
+ )
2704
+ }
2705
+ ) : null;
2706
+ const inputWrapperClassName = classNames(
2707
+ "cl-input",
2708
+ `cl-input--${variant}`,
2709
+ `cl-input--${size}`,
2710
+ fullWidth && "cl-input--full-width",
2711
+ error && "cl-input--error",
2712
+ disabled && "cl-input--disabled",
2713
+ className
2714
+ );
2715
+ const targetTag = component || as;
2716
+ if (asChild) {
2717
+ return /* @__PURE__ */ jsxs(
2718
+ StyledInputRoot,
2719
+ {
2720
+ as: Slot,
2721
+ ref,
2722
+ className: inputWrapperClassName,
2723
+ style,
2724
+ sx,
2725
+ onClick: handleWrapperClick,
2726
+ children: [
2727
+ startAdornment,
2728
+ /* @__PURE__ */ jsx(
2729
+ "input",
2730
+ {
2731
+ ref: handleInputRef,
2732
+ id,
2733
+ type,
2734
+ disabled,
2735
+ readOnly,
2736
+ required,
2737
+ "aria-describedby": ariaDescribedBy,
2738
+ value: valueProp,
2739
+ defaultValue,
2740
+ onChange: handleChange,
2741
+ "aria-invalid": error ? true : void 0,
2742
+ className: "cl-input__input",
2743
+ ...inputProps,
2744
+ ...restInputProps
2745
+ }
2746
+ ),
2747
+ clearButton,
2748
+ endAdornment
2749
+ ]
2750
+ }
2751
+ );
2752
+ }
2753
+ return /* @__PURE__ */ jsxs(
2754
+ StyledInputRoot,
2755
+ {
2756
+ as: targetTag,
2757
+ ref,
2758
+ className: inputWrapperClassName,
2759
+ style,
2760
+ sx,
2761
+ onClick: handleWrapperClick,
2762
+ children: [
2763
+ startAdornment,
2764
+ /* @__PURE__ */ jsx(
2765
+ "input",
2766
+ {
2767
+ ref: handleInputRef,
2768
+ id,
2769
+ type,
2770
+ disabled,
2771
+ readOnly,
2772
+ required,
2773
+ "aria-describedby": ariaDescribedBy,
2774
+ value: valueProp,
2775
+ defaultValue,
2776
+ onChange: handleChange,
2777
+ "aria-invalid": error ? true : void 0,
2778
+ className: "cl-input__input",
2779
+ ...inputProps,
2780
+ ...restInputProps
2781
+ }
2782
+ ),
2783
+ clearButton,
2784
+ endAdornment
2785
+ ]
2786
+ }
2787
+ );
2788
+ }
2789
+ );
2790
+ Input.displayName = "Input";
2791
+ var StyledTextFieldRoot = styled("div", {
2792
+ name: "ChellaaTextField",
2793
+ slot: "Root",
2794
+ shouldForwardProp: (prop) => prop !== "fullWidth"
2795
+ })(({ fullWidth }) => ({
2796
+ display: "inline-flex",
2797
+ flexDirection: "column",
2798
+ position: "relative",
2799
+ width: fullWidth ? "100%" : "auto",
2800
+ verticalAlign: "top"
2801
+ }));
2802
+ var StyledLabel = styled("label")(
2803
+ ({ theme, error }) => ({
2804
+ display: "block",
2805
+ fontSize: "0.875rem",
2806
+ fontWeight: 500,
2807
+ lineHeight: 1.4,
2808
+ marginBottom: theme.spacing(0.75),
2809
+ color: error ? theme.palette.error.main : theme.palette.text.primary,
2810
+ userSelect: "none",
2811
+ "& .ChellaaTextField-requiredAsterisk": {
2812
+ color: theme.palette.error.main,
2813
+ marginLeft: 4
2814
+ }
2815
+ })
2816
+ );
2817
+ var StyledHelperText = styled("p")(
2818
+ ({ theme, error }) => ({
2819
+ fontSize: "0.75rem",
2820
+ lineHeight: 1.4,
2821
+ margin: 0,
2822
+ marginTop: theme.spacing(0.5),
2823
+ color: error ? theme.palette.error.main : theme.palette.text.secondary
2824
+ })
2825
+ );
2826
+ var TextField = React.forwardRef(
2827
+ function TextField2(props, ref) {
2828
+ const {
2829
+ id: idProp,
2830
+ label,
2831
+ helperText,
2832
+ errorMessage,
2833
+ error = false,
2834
+ required = false,
2835
+ fullWidth = false,
2836
+ className,
2837
+ style,
2838
+ sx,
2839
+ ...inputProps
2840
+ } = props;
2841
+ const generatedId = React.useId();
2842
+ const inputId = idProp || generatedId;
2843
+ const helperId = `${inputId}-helper`;
2844
+ const activeHelperContent = error && errorMessage ? errorMessage : helperText;
2845
+ return /* @__PURE__ */ jsxs(
2846
+ StyledTextFieldRoot,
2847
+ {
2848
+ ref,
2849
+ fullWidth,
2850
+ className,
2851
+ style,
2852
+ sx,
2853
+ children: [
2854
+ label && /* @__PURE__ */ jsxs(StyledLabel, { htmlFor: inputId, error, required, children: [
2855
+ label,
2856
+ required && /* @__PURE__ */ jsx("span", { className: "ChellaaTextField-requiredAsterisk", children: "*" })
2857
+ ] }),
2858
+ /* @__PURE__ */ jsx(
2859
+ Input,
2860
+ {
2861
+ id: inputId,
2862
+ error,
2863
+ required,
2864
+ fullWidth,
2865
+ "aria-describedby": activeHelperContent ? helperId : void 0,
2866
+ ...inputProps
2867
+ }
2868
+ ),
2869
+ activeHelperContent && /* @__PURE__ */ jsx(StyledHelperText, { id: helperId, error, children: activeHelperContent })
2870
+ ]
2871
+ }
2872
+ );
2873
+ }
2874
+ );
2875
+ TextField.displayName = "TextField";
2876
+ var StyledAdornmentRoot = styled("div", {
2877
+ name: "ChellaaInputAdornment",
2878
+ slot: "Root",
2879
+ shouldForwardProp: (prop) => prop !== "position" && prop !== "disablePointerEvents"
2880
+ })(
2881
+ ({ theme, position, disablePointerEvents }) => ({
2882
+ display: "flex",
2883
+ height: "100%",
2884
+ maxHeight: "2em",
2885
+ alignItems: "center",
2886
+ justifyContent: "center",
2887
+ whiteSpace: "nowrap",
2888
+ color: theme.palette.text.secondary,
2889
+ marginLeft: position === "end" ? theme.spacing(1) : 0,
2890
+ marginRight: position === "start" ? theme.spacing(1) : 0,
2891
+ pointerEvents: disablePointerEvents ? "none" : "auto",
2892
+ userSelect: "none"
2893
+ })
2894
+ );
2895
+ var InputAdornment = React.forwardRef(function InputAdornment2(props, ref) {
2896
+ const { position, disablePointerEvents = false, children, ...rest } = props;
2897
+ return /* @__PURE__ */ jsx(
2898
+ StyledAdornmentRoot,
2899
+ {
2900
+ ref,
2901
+ position,
2902
+ disablePointerEvents,
2903
+ ...rest,
2904
+ children
2905
+ }
2906
+ );
2907
+ });
2908
+ InputAdornment.displayName = "InputAdornment";
2909
+ var StyledTextareaContainer = styled("div", {
2910
+ name: "ChellaaTextarea",
2911
+ slot: "Root",
2912
+ shouldForwardProp: (prop) => prop !== "variant" && prop !== "size" && prop !== "fullWidth" && prop !== "error" && prop !== "disabled" && prop !== "readOnly" && prop !== "autoResize" && prop !== "resize" && prop !== "hasCount" && prop !== "asChild" && prop !== "component" && prop !== "ownerState"
2913
+ })({});
2914
+ var Textarea = React.forwardRef(
2915
+ function Textarea2(props, ref) {
2916
+ const formField = useFormField();
2917
+ const {
2918
+ asChild = false,
2919
+ component,
2920
+ as,
2921
+ variant = "outlined",
2922
+ size = "md",
2923
+ fullWidth = false,
2924
+ error: errorProp,
2925
+ disabled: disabledProp,
2926
+ readOnly: readOnlyProp,
2927
+ required: requiredProp,
2928
+ minRows = 3,
2929
+ maxRows,
2930
+ autoResize = false,
2931
+ resize = "vertical",
2932
+ showCount = false,
2933
+ maxLength,
2934
+ textareaRef: textareaRefProp,
2935
+ textareaProps = {},
2936
+ value: valueProp,
2937
+ defaultValue,
2938
+ onChange,
2939
+ id: idProp,
2940
+ className,
2941
+ style,
2942
+ sx,
2943
+ placeholder,
2944
+ name,
2945
+ rows,
2946
+ cols,
2947
+ autoFocus,
2948
+ onFocus,
2949
+ onBlur,
2950
+ onKeyDown,
2951
+ onKeyUp,
2952
+ "aria-describedby": ariaDescribedByProp,
2953
+ ...restContainerProps
2954
+ } = props;
2955
+ const id = idProp ?? formField?.id;
2956
+ const error = errorProp ?? formField?.error ?? false;
2957
+ const disabled = disabledProp ?? formField?.disabled ?? false;
2958
+ const readOnly = readOnlyProp ?? formField?.readOnly ?? false;
2959
+ const required = requiredProp ?? formField?.required ?? false;
2960
+ const ariaDescribedBy = [
2961
+ ariaDescribedByProp,
2962
+ formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
2963
+ formField?.hasHelperText ? formField.helperTextId : null
2964
+ ].filter(Boolean).join(" ") || void 0;
2965
+ const [internalValue, setInternalValue] = React.useState(() => {
2966
+ if (valueProp !== void 0) return String(valueProp);
2967
+ if (defaultValue !== void 0) return String(defaultValue);
2968
+ return "";
2969
+ });
2970
+ const isControlled = valueProp !== void 0;
2971
+ const currentValue = isControlled ? String(valueProp ?? "") : internalValue;
2972
+ const innerTextareaRef = React.useRef(null);
2973
+ const handleTextareaRef = React.useCallback(
2974
+ (node) => {
2975
+ innerTextareaRef.current = node;
2976
+ if (typeof textareaRefProp === "function") {
2977
+ textareaRefProp(node);
2978
+ } else if (textareaRefProp && "current" in textareaRefProp) {
2979
+ textareaRefProp.current = node;
2980
+ }
2981
+ },
2982
+ [textareaRefProp]
2983
+ );
2984
+ React.useLayoutEffect(() => {
2985
+ if (!autoResize || !innerTextareaRef.current) return;
2986
+ const textarea = innerTextareaRef.current;
2987
+ textarea.style.height = "auto";
2988
+ const lineHeight = parseFloat(getComputedStyle(textarea).lineHeight) || 20;
2989
+ const minHeight = minRows * lineHeight;
2990
+ const maxHeight = maxRows ? maxRows * lineHeight : Infinity;
2991
+ const calculatedHeight = Math.min(
2992
+ Math.max(textarea.scrollHeight, minHeight),
2993
+ maxHeight
2994
+ );
2995
+ textarea.style.height = `${calculatedHeight}px`;
2996
+ textarea.style.overflowY = maxRows && textarea.scrollHeight > maxHeight ? "auto" : "hidden";
2997
+ }, [currentValue, autoResize, minRows, maxRows]);
2998
+ const handleChange = (event) => {
2999
+ if (!isControlled) {
3000
+ setInternalValue(event.target.value);
3001
+ }
3002
+ onChange?.(event);
3003
+ };
3004
+ const handleWrapperClick = () => {
3005
+ if (innerTextareaRef.current && document.activeElement !== innerTextareaRef.current) {
3006
+ innerTextareaRef.current.focus();
3007
+ }
3008
+ };
3009
+ const containerClassName = classNames(
3010
+ "cl-textarea",
3011
+ `cl-textarea--${variant}`,
3012
+ `cl-textarea--${size}`,
3013
+ fullWidth && "cl-textarea--full-width",
3014
+ error && "cl-textarea--error",
3015
+ disabled && "cl-textarea--disabled",
3016
+ className
3017
+ );
3018
+ const targetTag = component || as;
3019
+ const textareaStyle = {
3020
+ resize: autoResize ? "none" : resize
3021
+ };
3022
+ const countDisplay = showCount ? /* @__PURE__ */ jsxs("div", { className: "cl-textarea__counter", "aria-live": "polite", children: [
3023
+ currentValue.length,
3024
+ maxLength ? ` / ${maxLength}` : ""
3025
+ ] }) : null;
3026
+ if (asChild) {
3027
+ return /* @__PURE__ */ jsxs(
3028
+ StyledTextareaContainer,
3029
+ {
3030
+ as: Slot,
3031
+ ref,
3032
+ className: containerClassName,
3033
+ style,
3034
+ sx,
3035
+ onClick: handleWrapperClick,
3036
+ ...restContainerProps,
3037
+ children: [
3038
+ /* @__PURE__ */ jsx(
3039
+ "textarea",
3040
+ {
3041
+ ref: handleTextareaRef,
3042
+ id,
3043
+ name,
3044
+ placeholder,
3045
+ disabled,
3046
+ readOnly,
3047
+ required,
3048
+ "aria-describedby": ariaDescribedBy,
3049
+ "aria-invalid": error ? true : void 0,
3050
+ value: valueProp,
3051
+ defaultValue,
3052
+ onChange: handleChange,
3053
+ maxLength,
3054
+ rows: rows ?? minRows,
3055
+ cols,
3056
+ autoFocus,
3057
+ onFocus,
3058
+ onBlur,
3059
+ onKeyDown,
3060
+ onKeyUp,
3061
+ style: textareaStyle,
3062
+ className: "cl-textarea__input",
3063
+ ...textareaProps
3064
+ }
3065
+ ),
3066
+ countDisplay
3067
+ ]
3068
+ }
3069
+ );
3070
+ }
3071
+ return /* @__PURE__ */ jsxs(
3072
+ StyledTextareaContainer,
3073
+ {
3074
+ as: targetTag,
3075
+ ref,
3076
+ className: containerClassName,
3077
+ style,
3078
+ sx,
3079
+ onClick: handleWrapperClick,
3080
+ ...restContainerProps,
3081
+ children: [
3082
+ /* @__PURE__ */ jsx(
3083
+ "textarea",
3084
+ {
3085
+ ref: handleTextareaRef,
3086
+ id,
3087
+ name,
3088
+ placeholder,
3089
+ disabled,
3090
+ readOnly,
3091
+ required,
3092
+ "aria-describedby": ariaDescribedBy,
3093
+ "aria-invalid": error ? true : void 0,
3094
+ value: valueProp,
3095
+ defaultValue,
3096
+ onChange: handleChange,
3097
+ maxLength,
3098
+ rows: rows ?? minRows,
3099
+ cols,
3100
+ autoFocus,
3101
+ onFocus,
3102
+ onBlur,
3103
+ onKeyDown,
3104
+ onKeyUp,
3105
+ style: textareaStyle,
3106
+ className: "cl-textarea__input",
3107
+ ...textareaProps
3108
+ }
3109
+ ),
3110
+ countDisplay
3111
+ ]
3112
+ }
3113
+ );
3114
+ }
3115
+ );
3116
+ Textarea.displayName = "Textarea";
3117
+ var StyledFormFieldRoot = styled("div", {
3118
+ name: "ChellaaFormField",
3119
+ slot: "Root",
3120
+ shouldForwardProp: (prop) => prop !== "fullWidth" && prop !== "asChild" && prop !== "component" && prop !== "error" && prop !== "disabled" && prop !== "readOnly"
3121
+ })({});
3122
+ var FormField = React.forwardRef(
3123
+ function FormField2(props, ref) {
3124
+ const {
3125
+ id: idProp,
3126
+ name,
3127
+ required = false,
3128
+ disabled = false,
3129
+ readOnly = false,
3130
+ error = false,
3131
+ fullWidth = false,
3132
+ asChild = false,
3133
+ component,
3134
+ as,
3135
+ children,
3136
+ className,
3137
+ style,
3138
+ sx,
3139
+ ...rest
3140
+ } = props;
3141
+ const generatedId = React.useId();
3142
+ const id = idProp || generatedId;
3143
+ const labelId = `${id}-label`;
3144
+ const helperTextId = `${id}-helper`;
3145
+ const errorMessageId = `${id}-error`;
3146
+ const [hasHelperText, setHasHelperText] = React.useState(false);
3147
+ const [hasErrorMessage, setHasErrorMessage] = React.useState(false);
3148
+ const contextValue = React.useMemo(
3149
+ () => ({
3150
+ id,
3151
+ name,
3152
+ required,
3153
+ disabled,
3154
+ readOnly,
3155
+ error,
3156
+ labelId,
3157
+ helperTextId,
3158
+ errorMessageId,
3159
+ hasHelperText,
3160
+ hasErrorMessage,
3161
+ setHasHelperText,
3162
+ setHasErrorMessage
3163
+ }),
3164
+ [
3165
+ id,
3166
+ name,
3167
+ required,
3168
+ disabled,
3169
+ readOnly,
3170
+ error,
3171
+ labelId,
3172
+ helperTextId,
3173
+ errorMessageId,
3174
+ hasHelperText,
3175
+ hasErrorMessage
3176
+ ]
3177
+ );
3178
+ const fieldClassName = classNames(
3179
+ "cl-form-field",
3180
+ fullWidth && "cl-form-field--full-width",
3181
+ error && "cl-form-field--error",
3182
+ disabled && "cl-form-field--disabled",
3183
+ className
3184
+ );
3185
+ const targetTag = component || as;
3186
+ if (asChild) {
3187
+ return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
3188
+ StyledFormFieldRoot,
3189
+ {
3190
+ as: Slot,
3191
+ ref,
3192
+ className: fieldClassName,
3193
+ style,
3194
+ sx,
3195
+ ...rest,
3196
+ children
3197
+ }
3198
+ ) });
3199
+ }
3200
+ return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
3201
+ StyledFormFieldRoot,
3202
+ {
3203
+ as: targetTag,
3204
+ ref,
3205
+ className: fieldClassName,
3206
+ style,
3207
+ sx,
3208
+ ...rest,
3209
+ children
3210
+ }
3211
+ ) });
3212
+ }
3213
+ );
3214
+ FormField.displayName = "FormField";
3215
+ var StyledLabelRoot = styled("label", {
3216
+ name: "ChellaaFormLabel",
3217
+ slot: "Root",
3218
+ shouldForwardProp: (prop) => prop !== "required" && prop !== "error" && prop !== "disabled" && prop !== "asChild" && prop !== "component"
3219
+ })({});
3220
+ var FormLabel = React.forwardRef(
3221
+ function FormLabel2(props, ref) {
3222
+ const {
3223
+ htmlFor: htmlForProp,
3224
+ id: idProp,
3225
+ required: requiredProp,
3226
+ error: errorProp,
3227
+ disabled: disabledProp,
3228
+ asChild = false,
3229
+ component,
3230
+ as,
3231
+ children,
3232
+ className,
3233
+ style,
3234
+ sx,
3235
+ ...rest
3236
+ } = props;
3237
+ const formField = useFormField();
3238
+ const htmlFor = htmlForProp ?? formField?.id;
3239
+ const id = idProp ?? formField?.labelId;
3240
+ const required = requiredProp ?? formField?.required ?? false;
3241
+ const error = errorProp ?? formField?.error ?? false;
3242
+ const disabled = disabledProp ?? formField?.disabled ?? false;
3243
+ const labelClassName = classNames(
3244
+ "cl-form-label",
3245
+ error && "cl-form-label--error",
3246
+ disabled && "cl-form-label--disabled",
3247
+ className
3248
+ );
3249
+ const targetTag = component || as;
3250
+ if (asChild) {
3251
+ return /* @__PURE__ */ jsx(
3252
+ StyledLabelRoot,
3253
+ {
3254
+ as: Slot,
3255
+ ref,
3256
+ htmlFor,
3257
+ id,
3258
+ className: labelClassName,
3259
+ style,
3260
+ sx,
3261
+ ...rest,
3262
+ children
3263
+ }
3264
+ );
3265
+ }
3266
+ return /* @__PURE__ */ jsxs(
3267
+ StyledLabelRoot,
3268
+ {
3269
+ as: targetTag,
3270
+ ref,
3271
+ htmlFor,
3272
+ id,
3273
+ className: labelClassName,
3274
+ style,
3275
+ sx,
3276
+ ...rest,
3277
+ children: [
3278
+ children,
3279
+ required && /* @__PURE__ */ jsx("span", { className: "cl-form-label__asterisk", "aria-hidden": "true", children: "*" })
3280
+ ]
3281
+ }
3282
+ );
3283
+ }
3284
+ );
3285
+ FormLabel.displayName = "FormLabel";
3286
+ var StyledHelperTextRoot = styled("p", {
3287
+ name: "ChellaaFormHelperText",
3288
+ slot: "Root",
3289
+ shouldForwardProp: (prop) => prop !== "disabled" && prop !== "asChild" && prop !== "component"
3290
+ })({});
3291
+ var FormHelperText = React.forwardRef(function FormHelperText2(props, ref) {
3292
+ const {
3293
+ id: idProp,
3294
+ disabled: disabledProp,
3295
+ asChild = false,
3296
+ component = "p",
3297
+ as,
3298
+ children,
3299
+ className,
3300
+ style,
3301
+ sx,
3302
+ ...rest
3303
+ } = props;
3304
+ const formField = useFormField();
3305
+ const setHasHelperText = formField?.setHasHelperText;
3306
+ React.useEffect(() => {
3307
+ setHasHelperText?.(true);
3308
+ return () => setHasHelperText?.(false);
3309
+ }, [setHasHelperText]);
3310
+ const id = idProp ?? formField?.helperTextId;
3311
+ const disabled = disabledProp ?? formField?.disabled ?? false;
3312
+ const targetTag = component || as;
3313
+ const helperClassName = classNames(
3314
+ "cl-form-helper-text",
3315
+ disabled && "cl-form-helper-text--disabled",
3316
+ className
3317
+ );
3318
+ if (asChild) {
3319
+ return /* @__PURE__ */ jsx(
3320
+ StyledHelperTextRoot,
3321
+ {
3322
+ as: Slot,
3323
+ ref,
3324
+ id,
3325
+ className: helperClassName,
3326
+ style,
3327
+ sx,
3328
+ ...rest,
3329
+ children
3330
+ }
3331
+ );
3332
+ }
3333
+ return /* @__PURE__ */ jsx(
3334
+ StyledHelperTextRoot,
3335
+ {
3336
+ as: targetTag,
3337
+ ref,
3338
+ id,
3339
+ className: helperClassName,
3340
+ style,
3341
+ sx,
3342
+ ...rest,
3343
+ children
3344
+ }
3345
+ );
3346
+ });
3347
+ FormHelperText.displayName = "FormHelperText";
3348
+ var StyledErrorMessageRoot = styled("p", {
3349
+ name: "ChellaaFormErrorMessage",
3350
+ slot: "Root",
3351
+ shouldForwardProp: (prop) => prop !== "forceMount" && prop !== "asChild" && prop !== "component"
3352
+ })({});
3353
+ var FormErrorMessage = React.forwardRef(function FormErrorMessage2(props, ref) {
3354
+ const {
3355
+ id: idProp,
3356
+ forceMount = false,
3357
+ asChild = false,
3358
+ component = "p",
3359
+ as,
3360
+ children,
3361
+ className,
3362
+ style,
3363
+ sx,
3364
+ ...rest
3365
+ } = props;
3366
+ const formField = useFormField();
3367
+ const isError = formField?.error ?? false;
3368
+ const setHasErrorMessage = formField?.setHasErrorMessage;
3369
+ React.useEffect(() => {
3370
+ if (isError || forceMount) {
3371
+ setHasErrorMessage?.(true);
3372
+ return () => setHasErrorMessage?.(false);
3373
+ }
3374
+ }, [setHasErrorMessage, isError, forceMount]);
3375
+ if (!isError && !forceMount) {
3376
+ return null;
3377
+ }
3378
+ const id = idProp ?? formField?.errorMessageId;
3379
+ const targetTag = component || as;
3380
+ const errorClassName = classNames("cl-form-error-message", className);
3381
+ if (asChild) {
3382
+ return /* @__PURE__ */ jsx(
3383
+ StyledErrorMessageRoot,
3384
+ {
3385
+ as: Slot,
3386
+ ref,
3387
+ id,
3388
+ role: "alert",
3389
+ "aria-live": "polite",
3390
+ className: errorClassName,
3391
+ style,
3392
+ sx,
3393
+ ...rest,
3394
+ children
3395
+ }
3396
+ );
3397
+ }
3398
+ return /* @__PURE__ */ jsx(
3399
+ StyledErrorMessageRoot,
3400
+ {
3401
+ as: targetTag,
3402
+ ref,
3403
+ id,
3404
+ role: "alert",
3405
+ "aria-live": "polite",
3406
+ className: errorClassName,
3407
+ style,
3408
+ sx,
3409
+ ...rest,
3410
+ children
3411
+ }
3412
+ );
3413
+ });
3414
+ FormErrorMessage.displayName = "FormErrorMessage";
3415
+ var CheckboxContext = React.createContext(void 0);
3416
+ function useCheckboxGroup() {
3417
+ return React.useContext(CheckboxContext);
3418
+ }
3419
+ var StyledCheckboxRoot = styled("label", {
3420
+ name: "ChellaaCheckbox",
3421
+ slot: "Root",
3422
+ shouldForwardProp: (prop) => prop !== "size" && prop !== "colorScheme" && prop !== "disabled" && prop !== "readOnly" && prop !== "error" && prop !== "checked" && prop !== "indeterminate" && prop !== "asChild" && prop !== "component"
3423
+ })({});
3424
+ var Checkbox = React.forwardRef(
3425
+ function Checkbox2(props, ref) {
3426
+ const group = useCheckboxGroup();
3427
+ const formField = useFormField();
3428
+ const {
3429
+ checked: checkedProp,
3430
+ defaultChecked = false,
3431
+ indeterminate = false,
3432
+ onChange: onChangeProp,
3433
+ value: valueProp,
3434
+ name: nameProp,
3435
+ size: sizeProp,
3436
+ colorScheme: colorSchemeProp,
3437
+ disabled: disabledProp,
3438
+ readOnly: readOnlyProp,
3439
+ required: requiredProp,
3440
+ error: errorProp,
3441
+ inputRef: inputRefProp,
3442
+ inputProps = {},
3443
+ asChild = false,
3444
+ component,
3445
+ as,
3446
+ children,
3447
+ className,
3448
+ style,
3449
+ sx,
3450
+ id: idProp,
3451
+ ...rest
3452
+ } = props;
3453
+ const isGroupControlled = group !== void 0 && valueProp !== void 0;
3454
+ const isCheckedInGroup = isGroupControlled ? group.value.includes(valueProp) : void 0;
3455
+ const checked = checkedProp !== void 0 ? checkedProp : isCheckedInGroup;
3456
+ const size = sizeProp ?? group?.size ?? "md";
3457
+ const colorScheme = colorSchemeProp ?? group?.colorScheme ?? "primary";
3458
+ const disabled = disabledProp ?? group?.disabled ?? formField?.disabled ?? false;
3459
+ const readOnly = readOnlyProp ?? group?.readOnly ?? formField?.readOnly ?? false;
3460
+ const error = errorProp ?? group?.error ?? formField?.error ?? false;
3461
+ const required = requiredProp ?? formField?.required ?? false;
3462
+ const name = nameProp ?? group?.name ?? formField?.name;
3463
+ const id = idProp ?? (formField ? `${formField.id}-checkbox` : void 0);
3464
+ const [uncontrolledChecked, setUncontrolledChecked] = React.useState(
3465
+ defaultChecked
3466
+ );
3467
+ const isControlled = checked !== void 0;
3468
+ const effectiveChecked = isControlled ? checked : uncontrolledChecked;
3469
+ const nativeInputRef = React.useRef(null);
3470
+ const mergedInputRef = useMergeRefs(nativeInputRef, inputRefProp);
3471
+ React.useEffect(() => {
3472
+ if (nativeInputRef.current) {
3473
+ nativeInputRef.current.indeterminate = Boolean(indeterminate);
3474
+ }
3475
+ }, [indeterminate]);
3476
+ const handleChange = (event) => {
3477
+ if (disabled || readOnly) {
3478
+ event.preventDefault();
3479
+ return;
3480
+ }
3481
+ if (isGroupControlled) {
3482
+ group.toggleValue(valueProp);
3483
+ } else if (!isControlled) {
3484
+ setUncontrolledChecked(event.target.checked);
3485
+ }
3486
+ onChangeProp?.(event);
3487
+ };
3488
+ const checkboxClassName = classNames(
3489
+ "cl-checkbox",
3490
+ `cl-checkbox--${size}`,
3491
+ `cl-checkbox--${colorScheme}`,
3492
+ effectiveChecked && "cl-checkbox--checked",
3493
+ indeterminate && "cl-checkbox--indeterminate",
3494
+ disabled && "cl-checkbox--disabled",
3495
+ error && "cl-checkbox--error",
3496
+ className
3497
+ );
3498
+ const targetTag = component || as;
3499
+ const controlBox = /* @__PURE__ */ jsx("span", { className: "cl-checkbox__control ChellaaCheckbox-Control", "aria-hidden": "true", children: indeterminate ? /* @__PURE__ */ jsx(
3500
+ "svg",
3501
+ {
3502
+ className: "cl-checkbox__icon ChellaaCheckbox-Icon ChellaaCheckbox-Icon--indeterminate",
3503
+ viewBox: "0 0 24 24",
3504
+ fill: "none",
3505
+ stroke: "currentColor",
3506
+ strokeWidth: "3.5",
3507
+ strokeLinecap: "round",
3508
+ strokeLinejoin: "round",
3509
+ "aria-hidden": "true",
3510
+ width: size === "lg" ? 18 : size === "sm" ? 12 : 14,
3511
+ height: size === "lg" ? 18 : size === "sm" ? 12 : 14,
3512
+ children: /* @__PURE__ */ jsx("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
3513
+ }
3514
+ ) : effectiveChecked ? /* @__PURE__ */ jsx(
3515
+ "svg",
3516
+ {
3517
+ className: "cl-checkbox__icon ChellaaCheckbox-Icon ChellaaCheckbox-Icon--checked",
3518
+ viewBox: "0 0 24 24",
3519
+ fill: "none",
3520
+ stroke: "currentColor",
3521
+ strokeWidth: "3.5",
3522
+ strokeLinecap: "round",
3523
+ strokeLinejoin: "round",
3524
+ "aria-hidden": "true",
3525
+ width: size === "lg" ? 18 : size === "sm" ? 12 : 14,
3526
+ height: size === "lg" ? 18 : size === "sm" ? 12 : 14,
3527
+ children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" })
3528
+ }
3529
+ ) : null });
3530
+ const ariaDescribedBy = [
3531
+ inputProps["aria-describedby"],
3532
+ formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
3533
+ formField?.hasHelperText ? formField.helperTextId : null
3534
+ ].filter(Boolean).join(" ") || void 0;
3535
+ if (asChild) {
3536
+ return /* @__PURE__ */ jsx(
3537
+ StyledCheckboxRoot,
3538
+ {
3539
+ as: Slot,
3540
+ ref,
3541
+ className: checkboxClassName,
3542
+ style,
3543
+ sx,
3544
+ ...rest,
3545
+ children
3546
+ }
3547
+ );
3548
+ }
3549
+ return /* @__PURE__ */ jsxs(
3550
+ StyledCheckboxRoot,
3551
+ {
3552
+ as: targetTag,
3553
+ ref,
3554
+ className: checkboxClassName,
3555
+ style,
3556
+ sx,
3557
+ ...rest,
3558
+ children: [
3559
+ /* @__PURE__ */ jsx(
3560
+ "input",
3561
+ {
3562
+ type: "checkbox",
3563
+ id,
3564
+ name,
3565
+ value: valueProp,
3566
+ disabled,
3567
+ readOnly,
3568
+ required,
3569
+ checked: isControlled ? effectiveChecked : void 0,
3570
+ defaultChecked: !isControlled ? defaultChecked : void 0,
3571
+ onChange: handleChange,
3572
+ ref: mergedInputRef,
3573
+ "aria-checked": indeterminate ? "mixed" : effectiveChecked,
3574
+ "aria-invalid": error ? true : void 0,
3575
+ "aria-describedby": ariaDescribedBy,
3576
+ className: "cl-checkbox__input",
3577
+ ...inputProps
3578
+ }
3579
+ ),
3580
+ controlBox,
3581
+ children && /* @__PURE__ */ jsx("span", { className: "cl-checkbox__label ChellaaCheckbox-Label", children })
3582
+ ]
3583
+ }
3584
+ );
3585
+ }
3586
+ );
3587
+ Checkbox.displayName = "Checkbox";
3588
+ function useControllableState({
3589
+ value: valueProp,
3590
+ defaultValue,
3591
+ onChange
3592
+ }) {
3593
+ const isControlled = valueProp !== void 0;
3594
+ const [uncontrolledValue, setUncontrolledValue] = React.useState(() => {
3595
+ if (defaultValue !== void 0) {
3596
+ return typeof defaultValue === "function" ? defaultValue() : defaultValue;
3597
+ }
3598
+ return void 0;
3599
+ });
3600
+ const value = isControlled ? valueProp : uncontrolledValue;
3601
+ const onChangeRef = React.useRef(onChange);
3602
+ React.useEffect(() => {
3603
+ onChangeRef.current = onChange;
3604
+ });
3605
+ const setValue = React.useCallback(
3606
+ (next) => {
3607
+ const resolvedNext = typeof next === "function" ? next(value) : next;
3608
+ if (!Object.is(value, resolvedNext)) {
3609
+ if (!isControlled) {
3610
+ setUncontrolledValue(resolvedNext);
3611
+ }
3612
+ onChangeRef.current?.(resolvedNext);
3613
+ }
3614
+ },
3615
+ [isControlled, value]
3616
+ );
3617
+ return [value, setValue];
3618
+ }
3619
+ var StyledCheckboxGroupRoot = styled("div", {
3620
+ name: "ChellaaCheckboxGroup",
3621
+ slot: "Root",
3622
+ shouldForwardProp: (prop) => prop !== "orientation" && prop !== "spacing" && prop !== "colorScheme" && prop !== "error" && prop !== "disabled" && prop !== "readOnly" && prop !== "asChild" && prop !== "component"
3623
+ })(({ theme, spacing = 2 }) => {
3624
+ const gapValue = typeof spacing === "number" ? theme.spacing(spacing) : spacing;
3625
+ return {
3626
+ gap: gapValue
3627
+ };
3628
+ });
3629
+ var CheckboxGroup = React.forwardRef(function CheckboxGroup2(props, ref) {
3630
+ const formField = useFormField();
3631
+ const {
3632
+ value: valueProp,
3633
+ defaultValue = [],
3634
+ onChange: onChangeProp,
3635
+ name: nameProp,
3636
+ size = "md",
3637
+ colorScheme = "primary",
3638
+ orientation = "vertical",
3639
+ spacing = 2,
3640
+ disabled: disabledProp,
3641
+ readOnly: readOnlyProp,
3642
+ error: errorProp,
3643
+ asChild = false,
3644
+ component,
3645
+ as,
3646
+ children,
3647
+ className,
3648
+ style,
3649
+ sx,
3650
+ ...rest
3651
+ } = props;
3652
+ const name = nameProp ?? formField?.name;
3653
+ const disabled = disabledProp ?? formField?.disabled ?? false;
3654
+ const readOnly = readOnlyProp ?? formField?.readOnly ?? false;
3655
+ const error = errorProp ?? formField?.error ?? false;
3656
+ const [value, setValue] = useControllableState({
3657
+ value: valueProp,
3658
+ defaultValue,
3659
+ onChange: onChangeProp
3660
+ });
3661
+ const toggleValue = React.useCallback(
3662
+ (itemValue) => {
3663
+ if (readOnly || disabled) return;
3664
+ const current = value || [];
3665
+ const next = current.includes(itemValue) ? current.filter((v) => v !== itemValue) : [...current, itemValue];
3666
+ setValue(next);
3667
+ },
3668
+ [value, setValue, readOnly, disabled]
3669
+ );
3670
+ const contextValue = React.useMemo(
3671
+ () => ({
3672
+ value: value || [],
3673
+ name,
3674
+ size,
3675
+ colorScheme,
3676
+ disabled,
3677
+ readOnly,
3678
+ error,
3679
+ toggleValue
3680
+ }),
3681
+ [value, name, size, colorScheme, disabled, readOnly, error, toggleValue]
3682
+ );
3683
+ const groupClassName = classNames(
3684
+ "cl-checkbox-group",
3685
+ `cl-checkbox-group--${orientation}`,
3686
+ className
3687
+ );
3688
+ const targetTag = component || as;
3689
+ if (asChild) {
3690
+ return /* @__PURE__ */ jsx(CheckboxContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
3691
+ StyledCheckboxGroupRoot,
3692
+ {
3693
+ as: Slot,
3694
+ ref,
3695
+ role: "group",
3696
+ orientation,
3697
+ spacing,
3698
+ className: groupClassName,
3699
+ style,
3700
+ sx,
3701
+ ...rest,
3702
+ children
3703
+ }
3704
+ ) });
3705
+ }
3706
+ return /* @__PURE__ */ jsx(CheckboxContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
3707
+ StyledCheckboxGroupRoot,
3708
+ {
3709
+ as: targetTag,
3710
+ ref,
3711
+ role: "group",
3712
+ orientation,
3713
+ spacing,
3714
+ className: groupClassName,
3715
+ style,
3716
+ sx,
3717
+ ...rest,
3718
+ children
3719
+ }
3720
+ ) });
3721
+ });
3722
+ CheckboxGroup.displayName = "CheckboxGroup";
3723
+ var RadioContext = React.createContext(void 0);
3724
+ function useRadioGroup() {
3725
+ return React.useContext(RadioContext);
3726
+ }
3727
+ var StyledRadioRoot = styled("label", {
3728
+ name: "ChellaaRadio",
3729
+ slot: "Root",
3730
+ shouldForwardProp: (prop) => prop !== "size" && prop !== "colorScheme" && prop !== "disabled" && prop !== "readOnly" && prop !== "error" && prop !== "checked" && prop !== "asChild" && prop !== "component"
3731
+ })({});
3732
+ var Radio = React.forwardRef(
3733
+ function Radio2(props, ref) {
3734
+ const group = useRadioGroup();
3735
+ const formField = useFormField();
3736
+ const {
3737
+ checked: checkedProp,
3738
+ defaultChecked = false,
3739
+ onChange: onChangeProp,
3740
+ value: valueProp,
3741
+ name: nameProp,
3742
+ size: sizeProp,
3743
+ colorScheme: colorSchemeProp,
3744
+ disabled: disabledProp,
3745
+ readOnly: readOnlyProp,
3746
+ required: requiredProp,
3747
+ error: errorProp,
3748
+ inputRef: inputRefProp,
3749
+ inputProps = {},
3750
+ asChild = false,
3751
+ component,
3752
+ as,
3753
+ children,
3754
+ className,
3755
+ style,
3756
+ sx,
3757
+ id: idProp,
3758
+ ...rest
3759
+ } = props;
3760
+ const isGroupControlled = group !== void 0 && valueProp !== void 0;
3761
+ const isCheckedInGroup = isGroupControlled ? group.value !== void 0 && String(group.value) === String(valueProp) : void 0;
3762
+ const checked = checkedProp !== void 0 ? checkedProp : isCheckedInGroup;
3763
+ const size = sizeProp ?? group?.size ?? "md";
3764
+ const colorScheme = colorSchemeProp ?? group?.colorScheme ?? "primary";
3765
+ const disabled = disabledProp ?? group?.disabled ?? formField?.disabled ?? false;
3766
+ const readOnly = readOnlyProp ?? group?.readOnly ?? formField?.readOnly ?? false;
3767
+ const error = errorProp ?? group?.error ?? formField?.error ?? false;
3768
+ const required = requiredProp ?? formField?.required ?? false;
3769
+ const name = nameProp ?? group?.name ?? formField?.name;
3770
+ const id = idProp ?? (formField ? `${formField.id}-radio-${valueProp ?? ""}` : void 0);
3771
+ const [uncontrolledChecked, setUncontrolledChecked] = React.useState(
3772
+ defaultChecked
3773
+ );
3774
+ const isControlled = checked !== void 0;
3775
+ const effectiveChecked = isControlled ? checked : uncontrolledChecked;
3776
+ const nativeInputRef = React.useRef(null);
3777
+ const mergedInputRef = useMergeRefs(nativeInputRef, inputRefProp);
3778
+ const handleChange = (event) => {
3779
+ if (disabled || readOnly) {
3780
+ event.preventDefault();
3781
+ return;
3782
+ }
3783
+ if (isGroupControlled && valueProp !== void 0) {
3784
+ group.onChange(valueProp);
3785
+ } else if (!isControlled) {
3786
+ setUncontrolledChecked(event.target.checked);
3787
+ }
3788
+ onChangeProp?.(event);
3789
+ };
3790
+ const radioClassName = classNames(
3791
+ "cl-radio",
3792
+ `cl-radio--${size}`,
3793
+ `cl-radio--${colorScheme}`,
3794
+ effectiveChecked && "cl-radio--checked",
3795
+ disabled && "cl-radio--disabled",
3796
+ error && "cl-radio--error",
3797
+ className
3798
+ );
3799
+ const targetTag = component || as;
3800
+ const controlBox = /* @__PURE__ */ jsx("span", { className: "cl-radio__control ChellaaRadio-Control", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "cl-radio__dot ChellaaRadio-Dot" }) });
3801
+ const ariaDescribedBy = [
3802
+ inputProps["aria-describedby"],
3803
+ formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
3804
+ formField?.hasHelperText ? formField.helperTextId : null
3805
+ ].filter(Boolean).join(" ") || void 0;
3806
+ if (asChild) {
3807
+ return /* @__PURE__ */ jsx(
3808
+ StyledRadioRoot,
3809
+ {
3810
+ as: Slot,
3811
+ ref,
3812
+ className: radioClassName,
3813
+ style,
3814
+ sx,
3815
+ ...rest,
3816
+ children
3817
+ }
3818
+ );
3819
+ }
3820
+ return /* @__PURE__ */ jsxs(
3821
+ StyledRadioRoot,
3822
+ {
3823
+ as: targetTag,
3824
+ ref,
3825
+ className: radioClassName,
3826
+ style,
3827
+ sx,
3828
+ ...rest,
3829
+ children: [
3830
+ /* @__PURE__ */ jsx(
3831
+ "input",
3832
+ {
3833
+ type: "radio",
3834
+ id,
3835
+ name,
3836
+ value: valueProp,
3837
+ disabled,
3838
+ readOnly,
3839
+ required,
3840
+ checked: isControlled ? effectiveChecked : void 0,
3841
+ defaultChecked: !isControlled ? defaultChecked : void 0,
3842
+ onChange: handleChange,
3843
+ ref: mergedInputRef,
3844
+ "aria-invalid": error ? true : void 0,
3845
+ "aria-describedby": ariaDescribedBy,
3846
+ className: "cl-radio__input",
3847
+ ...inputProps
3848
+ }
3849
+ ),
3850
+ controlBox,
3851
+ children && /* @__PURE__ */ jsx("span", { className: "cl-radio__label ChellaaRadio-Label", children })
3852
+ ]
3853
+ }
3854
+ );
3855
+ }
3856
+ );
3857
+ Radio.displayName = "Radio";
3858
+ var StyledRadioGroupRoot = styled("div", {
3859
+ name: "ChellaaRadioGroup",
3860
+ slot: "Root",
3861
+ shouldForwardProp: (prop) => prop !== "orientation" && prop !== "spacing" && prop !== "colorScheme" && prop !== "error" && prop !== "disabled" && prop !== "readOnly" && prop !== "asChild" && prop !== "component"
3862
+ })({});
3863
+ var RadioGroup = React.forwardRef(
3864
+ function RadioGroup2(props, ref) {
3865
+ const formField = useFormField();
3866
+ const {
3867
+ value: valueProp,
3868
+ defaultValue,
3869
+ onChange: onChangeProp,
3870
+ name: nameProp,
3871
+ size = "md",
3872
+ colorScheme = "primary",
3873
+ orientation = "vertical",
3874
+ spacing = 2,
3875
+ disabled: disabledProp,
3876
+ readOnly: readOnlyProp,
3877
+ error: errorProp,
3878
+ asChild = false,
3879
+ component,
3880
+ as,
3881
+ children,
3882
+ className,
3883
+ style,
3884
+ sx,
3885
+ ...rest
3886
+ } = props;
3887
+ const generatedName = React.useId();
3888
+ const name = nameProp || formField?.name || generatedName;
3889
+ const disabled = disabledProp ?? formField?.disabled ?? false;
3890
+ const readOnly = readOnlyProp ?? formField?.readOnly ?? false;
3891
+ const error = errorProp ?? formField?.error ?? false;
3892
+ const [value, setValue] = useControllableState({
3893
+ value: valueProp,
3894
+ defaultValue,
3895
+ onChange: (val) => {
3896
+ if (val !== void 0) {
3897
+ onChangeProp?.(val);
3898
+ }
3899
+ }
3900
+ });
3901
+ const handleChange = React.useCallback(
3902
+ (nextValue) => {
3903
+ if (readOnly || disabled) return;
3904
+ setValue(nextValue);
3905
+ },
3906
+ [readOnly, disabled, setValue]
3907
+ );
3908
+ const contextValue = React.useMemo(
3909
+ () => ({
3910
+ value,
3911
+ name,
3912
+ size,
3913
+ colorScheme,
3914
+ disabled,
3915
+ readOnly,
3916
+ error,
3917
+ onChange: handleChange
3918
+ }),
3919
+ [value, name, size, colorScheme, disabled, readOnly, error, handleChange]
3920
+ );
3921
+ const targetTag = component || as;
3922
+ const groupClassName = classNames(
3923
+ "cl-radio-group",
3924
+ orientation === "horizontal" ? "cl-radio-group--horizontal" : "cl-radio-group--vertical",
3925
+ className
3926
+ );
3927
+ const gapStyle = spacing !== void 0 ? {
3928
+ gap: typeof spacing === "number" ? `${spacing * 4}px` : spacing,
3929
+ ...style
3930
+ } : style;
3931
+ if (asChild) {
3932
+ return /* @__PURE__ */ jsx(RadioContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
3933
+ StyledRadioGroupRoot,
3934
+ {
3935
+ as: Slot,
3936
+ ref,
3937
+ role: "radiogroup",
3938
+ className: groupClassName,
3939
+ style: gapStyle,
3940
+ sx,
3941
+ ...rest,
3942
+ children
3943
+ }
3944
+ ) });
3945
+ }
3946
+ return /* @__PURE__ */ jsx(RadioContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
3947
+ StyledRadioGroupRoot,
3948
+ {
3949
+ as: targetTag,
3950
+ ref,
3951
+ role: "radiogroup",
3952
+ className: groupClassName,
3953
+ style: gapStyle,
3954
+ sx,
3955
+ ...rest,
3956
+ children
3957
+ }
3958
+ ) });
3959
+ }
3960
+ );
3961
+ RadioGroup.displayName = "RadioGroup";
3962
+ var StyledSwitchRoot = styled("label", {
3963
+ name: "ChellaaSwitch",
3964
+ slot: "Root",
3965
+ shouldForwardProp: (prop) => prop !== "size" && prop !== "labelPlacement" && prop !== "disabled" && prop !== "readOnly" && prop !== "error" && prop !== "loading" && prop !== "checked" && prop !== "colorScheme" && prop !== "asChild" && prop !== "component"
3966
+ })({});
3967
+ var Switch = React.forwardRef(
3968
+ function Switch2(props, ref) {
3969
+ const formField = useFormField();
3970
+ const {
3971
+ checked: checkedProp,
3972
+ defaultChecked = false,
3973
+ onChange: onChangeProp,
3974
+ value,
3975
+ name: nameProp,
3976
+ size = "md",
3977
+ colorScheme = "primary",
3978
+ disabled: disabledProp,
3979
+ readOnly: readOnlyProp,
3980
+ required: requiredProp,
3981
+ error: errorProp,
3982
+ loading = false,
3983
+ checkedIcon,
3984
+ uncheckedIcon,
3985
+ labelPlacement = "end",
3986
+ inputRef: inputRefProp,
3987
+ inputProps = {},
3988
+ asChild = false,
3989
+ component,
3990
+ as,
3991
+ children,
3992
+ className,
3993
+ style,
3994
+ sx,
3995
+ id: idProp,
3996
+ ...rest
3997
+ } = props;
3998
+ const disabled = disabledProp ?? formField?.disabled ?? loading ? true : false;
3999
+ const readOnly = readOnlyProp ?? formField?.readOnly ?? false;
4000
+ const error = errorProp ?? formField?.error ?? false;
4001
+ const required = requiredProp ?? formField?.required ?? false;
4002
+ const name = nameProp ?? formField?.name;
4003
+ const id = idProp ?? (formField ? `${formField.id}-switch` : void 0);
4004
+ const [uncontrolledChecked, setUncontrolledChecked] = React.useState(
4005
+ defaultChecked
4006
+ );
4007
+ const isControlled = checkedProp !== void 0;
4008
+ const effectiveChecked = isControlled ? checkedProp : uncontrolledChecked;
4009
+ const nativeInputRef = React.useRef(null);
4010
+ const mergedInputRef = useMergeRefs(nativeInputRef, inputRefProp);
4011
+ const handleChange = (event) => {
4012
+ if (disabled || readOnly || loading) {
4013
+ event.preventDefault();
4014
+ return;
4015
+ }
4016
+ if (!isControlled) {
4017
+ setUncontrolledChecked(event.target.checked);
4018
+ }
4019
+ onChangeProp?.(event);
4020
+ };
4021
+ const handleKeyDown = (event) => {
4022
+ if (event.key === "Enter") {
4023
+ event.preventDefault();
4024
+ nativeInputRef.current?.click();
4025
+ }
4026
+ inputProps.onKeyDown?.(event);
4027
+ };
4028
+ const switchClassName = classNames(
4029
+ "cl-switch",
4030
+ `cl-switch--${size}`,
4031
+ `cl-switch--${colorScheme}`,
4032
+ `cl-switch--placement-${labelPlacement}`,
4033
+ effectiveChecked && "cl-switch--checked",
4034
+ disabled && "cl-switch--disabled",
4035
+ error && "cl-switch--error",
4036
+ className
4037
+ );
4038
+ const targetTag = component || as;
4039
+ const thumbIcon = loading ? /* @__PURE__ */ jsx(
4040
+ "svg",
4041
+ {
4042
+ className: "cl-switch__spinner",
4043
+ viewBox: "0 0 24 24",
4044
+ fill: "none",
4045
+ "aria-hidden": "true",
4046
+ children: /* @__PURE__ */ jsx(
4047
+ "circle",
4048
+ {
4049
+ cx: "12",
4050
+ cy: "12",
4051
+ r: "9",
4052
+ stroke: "currentColor",
4053
+ strokeWidth: "3",
4054
+ strokeDasharray: "40 20",
4055
+ strokeLinecap: "round"
4056
+ }
4057
+ )
4058
+ }
4059
+ ) : effectiveChecked ? checkedIcon : uncheckedIcon;
4060
+ const trackControl = /* @__PURE__ */ jsx("span", { className: "cl-switch__track ChellaaSwitch-Track", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "cl-switch__thumb ChellaaSwitch-Thumb", children: thumbIcon }) });
4061
+ const ariaDescribedBy = [
4062
+ inputProps["aria-describedby"],
4063
+ formField?.error && formField?.hasErrorMessage ? formField.errorMessageId : null,
4064
+ formField?.hasHelperText ? formField.helperTextId : null
4065
+ ].filter(Boolean).join(" ") || void 0;
4066
+ if (asChild) {
4067
+ return /* @__PURE__ */ jsx(
4068
+ StyledSwitchRoot,
4069
+ {
4070
+ as: Slot,
4071
+ ref,
4072
+ className: switchClassName,
4073
+ style,
4074
+ sx,
4075
+ ...rest,
4076
+ children
4077
+ }
4078
+ );
4079
+ }
4080
+ return /* @__PURE__ */ jsxs(
4081
+ StyledSwitchRoot,
4082
+ {
4083
+ as: targetTag,
4084
+ ref,
4085
+ className: switchClassName,
4086
+ style,
4087
+ sx,
4088
+ ...rest,
4089
+ children: [
4090
+ /* @__PURE__ */ jsx(
4091
+ "input",
4092
+ {
4093
+ type: "checkbox",
4094
+ role: "switch",
4095
+ id,
4096
+ name,
4097
+ value,
4098
+ disabled,
4099
+ readOnly,
4100
+ required,
4101
+ checked: isControlled ? effectiveChecked : void 0,
4102
+ defaultChecked: !isControlled ? defaultChecked : void 0,
4103
+ onChange: handleChange,
4104
+ onKeyDown: handleKeyDown,
4105
+ ref: mergedInputRef,
4106
+ "aria-checked": effectiveChecked,
4107
+ "aria-invalid": error ? true : void 0,
4108
+ "aria-describedby": ariaDescribedBy,
4109
+ className: "cl-switch__input",
4110
+ ...inputProps
4111
+ }
4112
+ ),
4113
+ trackControl,
4114
+ children && /* @__PURE__ */ jsx("span", { className: "cl-switch__label ChellaaSwitch-Label", children })
4115
+ ]
4116
+ }
4117
+ );
4118
+ }
4119
+ );
4120
+ Switch.displayName = "Switch";
4121
+ var StyledPaperRoot = styled("div", {
4122
+ name: "ChellaaPaper",
4123
+ slot: "Root",
4124
+ shouldForwardProp: (prop) => prop !== "elevation" && prop !== "variant" && prop !== "square" && prop !== "asChild" && prop !== "component"
4125
+ })({});
4126
+ var Paper = React.forwardRef(
4127
+ function Paper2(props, ref) {
4128
+ const {
4129
+ asChild = false,
4130
+ component,
4131
+ as,
4132
+ elevation = 1,
4133
+ variant = "elevation",
4134
+ square = false,
4135
+ className,
4136
+ style,
4137
+ sx,
4138
+ children,
4139
+ ...rest
4140
+ } = props;
4141
+ const clampedElevation = Math.max(0, Math.min(24, elevation));
4142
+ const paperClassName = classNames(
4143
+ "cl-paper",
4144
+ square && "cl-paper--square",
4145
+ variant === "outlined" ? "cl-paper--outlined" : `cl-paper--elevation-${clampedElevation}`,
4146
+ className
4147
+ );
4148
+ const targetTag = component || as;
4149
+ if (asChild) {
4150
+ return /* @__PURE__ */ jsx(
4151
+ StyledPaperRoot,
4152
+ {
4153
+ as: Slot,
4154
+ ref,
4155
+ className: paperClassName,
4156
+ style,
4157
+ sx,
4158
+ ...rest,
4159
+ children
4160
+ }
4161
+ );
4162
+ }
4163
+ if (targetTag) {
4164
+ return /* @__PURE__ */ jsx(
4165
+ StyledPaperRoot,
4166
+ {
4167
+ as: targetTag,
4168
+ ref,
4169
+ className: paperClassName,
4170
+ style,
4171
+ sx,
4172
+ ...rest,
4173
+ children
4174
+ }
4175
+ );
4176
+ }
4177
+ return /* @__PURE__ */ jsx(
4178
+ StyledPaperRoot,
4179
+ {
4180
+ ref,
4181
+ className: paperClassName,
4182
+ style,
4183
+ sx,
4184
+ ...rest,
4185
+ children
4186
+ }
4187
+ );
4188
+ }
4189
+ );
4190
+ Paper.displayName = "Paper";
4191
+ var CardContext = React.createContext({
4192
+ size: "md"
4193
+ });
4194
+ var StyledCardRoot = styled("div", {
4195
+ name: "ChellaaCard",
4196
+ slot: "Root",
4197
+ shouldForwardProp: (prop) => prop !== "variant" && prop !== "elevation" && prop !== "hoverable" && prop !== "square" && prop !== "size" && prop !== "asChild" && prop !== "component"
4198
+ })({});
4199
+ var Card = React.forwardRef(
4200
+ function Card2(props, ref) {
4201
+ const {
4202
+ variant = "elevated",
4203
+ elevation = 1,
4204
+ size = "md",
4205
+ hoverable = false,
4206
+ square = false,
4207
+ asChild = false,
4208
+ component,
4209
+ as,
4210
+ className,
4211
+ style,
4212
+ sx,
4213
+ children,
4214
+ ...rest
4215
+ } = props;
4216
+ const cardClassName = classNames(
4217
+ "cl-card",
4218
+ `cl-card--${size}`,
4219
+ `cl-card--${variant}`,
4220
+ square && "cl-card--square",
4221
+ hoverable && "cl-card--hoverable",
4222
+ className
4223
+ );
4224
+ const targetTag = component || as;
4225
+ return /* @__PURE__ */ jsx(CardContext.Provider, { value: { size }, children: asChild ? /* @__PURE__ */ jsx(
4226
+ StyledCardRoot,
4227
+ {
4228
+ as: Slot,
4229
+ ref,
4230
+ className: cardClassName,
4231
+ style,
4232
+ sx,
4233
+ ...rest,
4234
+ children
4235
+ }
4236
+ ) : /* @__PURE__ */ jsx(
4237
+ StyledCardRoot,
4238
+ {
4239
+ as: targetTag,
4240
+ ref,
4241
+ className: cardClassName,
4242
+ style,
4243
+ sx,
4244
+ ...rest,
4245
+ children
4246
+ }
4247
+ ) });
4248
+ }
4249
+ );
4250
+ Card.displayName = "Card";
4251
+ var StyledCardHeaderRoot = styled("div", {
4252
+ name: "ChellaaCard",
4253
+ slot: "Header",
4254
+ shouldForwardProp: (prop) => prop !== "cardSize" && prop !== "asChild"
4255
+ })({});
4256
+ var CardHeader = React.forwardRef(
4257
+ function CardHeader2(props, ref) {
4258
+ const {
4259
+ avatar,
4260
+ action,
4261
+ title,
4262
+ subheader,
4263
+ titleTypographyProps,
4264
+ subheaderTypographyProps,
4265
+ asChild = false,
4266
+ className,
4267
+ style,
4268
+ sx,
4269
+ children,
4270
+ ...rest
4271
+ } = props;
4272
+ const headerClassName = classNames(
4273
+ "cl-card__header",
4274
+ "ChellaaCard-header",
4275
+ className
4276
+ );
4277
+ if (asChild) {
4278
+ return /* @__PURE__ */ jsx(
4279
+ StyledCardHeaderRoot,
4280
+ {
4281
+ as: Slot,
4282
+ ref,
4283
+ className: headerClassName,
4284
+ style,
4285
+ sx,
4286
+ ...rest,
4287
+ children
4288
+ }
4289
+ );
4290
+ }
4291
+ return /* @__PURE__ */ jsxs(
4292
+ StyledCardHeaderRoot,
4293
+ {
4294
+ ref,
4295
+ className: headerClassName,
4296
+ style,
4297
+ sx,
4298
+ ...rest,
4299
+ children: [
4300
+ avatar && /* @__PURE__ */ jsx("div", { className: "cl-card__header-avatar ChellaaCard-headerAvatar", children: avatar }),
4301
+ /* @__PURE__ */ jsxs("div", { className: "cl-card__header-content ChellaaCard-headerContent", children: [
4302
+ title != null && /* @__PURE__ */ jsx(
4303
+ "span",
4304
+ {
4305
+ className: classNames(
4306
+ "cl-card__header-title",
4307
+ "ChellaaCard-headerTitle",
4308
+ titleTypographyProps?.className
4309
+ ),
4310
+ ...titleTypographyProps,
4311
+ children: title
4312
+ }
4313
+ ),
4314
+ subheader != null && /* @__PURE__ */ jsx(
4315
+ "span",
4316
+ {
4317
+ className: classNames(
4318
+ "cl-card__header-subheader",
4319
+ "ChellaaCard-headerSubheader",
4320
+ subheaderTypographyProps?.className
4321
+ ),
4322
+ ...subheaderTypographyProps,
4323
+ children: subheader
4324
+ }
4325
+ ),
4326
+ children
4327
+ ] }),
4328
+ action && /* @__PURE__ */ jsx("div", { className: "cl-card__header-action ChellaaCard-headerAction", children: action })
4329
+ ]
4330
+ }
4331
+ );
4332
+ }
4333
+ );
4334
+ CardHeader.displayName = "CardHeader";
4335
+ var StyledCardMediaRoot = styled("div", {
4336
+ name: "ChellaaCard",
4337
+ slot: "Media",
4338
+ shouldForwardProp: (prop) => prop !== "image" && prop !== "aspectRatio"
4339
+ })({});
4340
+ var CardMedia = React.forwardRef(
4341
+ function CardMedia2(props, ref) {
4342
+ const {
4343
+ image,
4344
+ alt,
4345
+ aspectRatio = "16/9",
4346
+ component,
4347
+ className,
4348
+ style,
4349
+ sx,
4350
+ children,
4351
+ ...rest
4352
+ } = props;
4353
+ const mediaStyle = {
4354
+ ...aspectRatio ? { aspectRatio } : {},
4355
+ ...image ? { backgroundImage: `url(${image})` } : {},
4356
+ ...style
4357
+ };
4358
+ const mediaClassName = classNames(
4359
+ "cl-card__media",
4360
+ "ChellaaCard-media",
4361
+ className
4362
+ );
4363
+ return /* @__PURE__ */ jsx(
4364
+ StyledCardMediaRoot,
4365
+ {
4366
+ as: component,
4367
+ ref,
4368
+ className: mediaClassName,
4369
+ style: mediaStyle,
4370
+ sx,
4371
+ role: image && !children ? "img" : void 0,
4372
+ "aria-label": image && !children ? alt : void 0,
4373
+ ...rest,
4374
+ children
4375
+ }
4376
+ );
4377
+ }
4378
+ );
4379
+ CardMedia.displayName = "CardMedia";
4380
+ var StyledCardBodyRoot = styled("div", {
4381
+ name: "ChellaaCard",
4382
+ slot: "Body",
4383
+ shouldForwardProp: (prop) => prop !== "cardSize"
4384
+ })({});
4385
+ var CardBody = React.forwardRef(
4386
+ function CardBody2(props, ref) {
4387
+ const { children, className, style, sx, ...rest } = props;
4388
+ const bodyClassName = classNames("cl-card__body", "ChellaaCard-body", className);
4389
+ return /* @__PURE__ */ jsx(
4390
+ StyledCardBodyRoot,
4391
+ {
4392
+ ref,
4393
+ className: bodyClassName,
4394
+ style,
4395
+ sx,
4396
+ ...rest,
4397
+ children
4398
+ }
4399
+ );
4400
+ }
4401
+ );
4402
+ CardBody.displayName = "CardBody";
4403
+ var StyledCardFooterRoot = styled("div", {
4404
+ name: "ChellaaCard",
4405
+ slot: "Footer",
4406
+ shouldForwardProp: (prop) => prop !== "divider" && prop !== "cardSize"
4407
+ })({});
4408
+ var CardFooter = React.forwardRef(
4409
+ function CardFooter2(props, ref) {
4410
+ const { divider = false, children, className, style, sx, ...rest } = props;
4411
+ const footerClassName = classNames(
4412
+ "cl-card__footer",
4413
+ "ChellaaCard-footer",
4414
+ divider && "cl-card__footer--divider",
4415
+ className
4416
+ );
4417
+ return /* @__PURE__ */ jsx(
4418
+ StyledCardFooterRoot,
4419
+ {
4420
+ ref,
4421
+ className: footerClassName,
4422
+ style,
4423
+ sx,
4424
+ ...rest,
4425
+ children
4426
+ }
4427
+ );
4428
+ }
4429
+ );
4430
+ CardFooter.displayName = "CardFooter";
4431
+ var StyledCardActionsRoot = styled("div", {
4432
+ name: "ChellaaCard",
4433
+ slot: "Actions",
4434
+ shouldForwardProp: (prop) => prop !== "disableSpacing" && prop !== "cardSize"
4435
+ })({});
4436
+ var CardActions = React.forwardRef(
4437
+ function CardActions2(props, ref) {
4438
+ const { disableSpacing = false, children, className, style, sx, ...rest } = props;
4439
+ const actionsClassName = classNames(
4440
+ "cl-card__actions",
4441
+ "ChellaaCard-actions",
4442
+ disableSpacing && "cl-card__actions--disable-spacing",
4443
+ className
4444
+ );
4445
+ return /* @__PURE__ */ jsx(
4446
+ StyledCardActionsRoot,
4447
+ {
4448
+ ref,
4449
+ className: actionsClassName,
4450
+ style,
4451
+ sx,
4452
+ ...rest,
4453
+ children
4454
+ }
4455
+ );
4456
+ }
4457
+ );
4458
+ CardActions.displayName = "CardActions";
491
4459
 
492
- export { Button, ButtonGroup, ButtonGroupContext, ThemeProvider, ThemeScript, createTheme, useButtonGroupContext, useTheme };
4460
+ export { Box, Button, ButtonGroup, ButtonGroupContext, Card, CardActions, CardBody, CardFooter, CardHeader, CardMedia, Checkbox, CheckboxContext, CheckboxGroup, Code, Container, Divider, Flex, FormErrorMessage, FormField, FormFieldContext, FormHelperText, FormLabel, Grid, Heading, Input, InputAdornment, InputBase, Kbd, MODIFIER_SYMBOLS, Paper, Paragraph, Radio, RadioContext, RadioGroup, Stack, Switch, Text, TextField, Textarea, ThemeProvider, ThemeScript, TouchRipple, Typography, breakpointKeys, createBreakpoints, createPalette, createShadows, createShouldForwardProp, createSpacing, createTheme, darkPalette, defaultBreakpoints, defaultDarkTheme, defaultShadows, defaultSpacing, defaultTheme, defaultTransitions, defaultTypography, defaultZIndex, lightPalette, parseSx, resolveComponentOverrides, resolveTypographyColor, rootShouldForwardProp, styled, useButtonGroupContext, useCheckboxGroup, useFormField, useRadioGroup, useRipple, useTheme };
493
4461
  //# sourceMappingURL=index.mjs.map
494
4462
  //# sourceMappingURL=index.mjs.map