@locus-ui/components 0.0.13 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -21,11 +21,18 @@ function getComponentProps(props, ...propDefs) {
21
21
  delete restProps[key];
22
22
  if (prop.type === "boolean" || prop.type === "string" || prop.type === "number" || prop.type === "value | array" || prop.type === "reactNode" || prop.type === "function") {
23
23
  extractedProps[key] = value;
24
- if (prop.cssProperty && value !== void 0 && value !== null) {
25
- style = {
26
- ...style,
27
- [prop.cssProperty]: prop.type === "boolean" ? value ? "1" : "0" : value
28
- };
24
+ if (prop.cssProperty) {
25
+ if (value !== void 0 && value !== null) {
26
+ style = {
27
+ ...style,
28
+ [prop.cssProperty]: prop.type === "boolean" ? value ? "1" : "0" : value
29
+ };
30
+ } else if (prop.default !== void 0) {
31
+ style = {
32
+ ...style,
33
+ [prop.cssProperty]: prop.type === "boolean" ? prop.default ? "1" : "0" : prop.default
34
+ };
35
+ }
29
36
  }
30
37
  if (prop.dataAttr) {
31
38
  if (value) dataAttrs[`data-${prop.dataAttr}`] = value;
@@ -87,7 +94,7 @@ function getComponentProps(props, ...propDefs) {
87
94
  }
88
95
 
89
96
  // src/components/accordion/accordion-context.ts
90
- var _react = require('react'); var React2 = _interopRequireWildcard(_react); var React4 = _interopRequireWildcard(_react); var React5 = _interopRequireWildcard(_react); var React11 = _interopRequireWildcard(_react); var React12 = _interopRequireWildcard(_react); var React14 = _interopRequireWildcard(_react); var React13 = _interopRequireWildcard(_react); var React17 = _interopRequireWildcard(_react); var React15 = _interopRequireWildcard(_react); var React16 = _interopRequireWildcard(_react); var React19 = _interopRequireWildcard(_react); var React18 = _interopRequireWildcard(_react); var React25 = _interopRequireWildcard(_react); var React22 = _interopRequireWildcard(_react); var React23 = _interopRequireWildcard(_react); var React24 = _interopRequireWildcard(_react); var React26 = _interopRequireWildcard(_react); var React27 = _interopRequireWildcard(_react); var React28 = _interopRequireWildcard(_react); var React30 = _interopRequireWildcard(_react); var React29 = _interopRequireWildcard(_react); var React31 = _interopRequireWildcard(_react); var React32 = _interopRequireWildcard(_react);
97
+ var _react = require('react'); var React2 = _interopRequireWildcard(_react); var React4 = _interopRequireWildcard(_react); var React5 = _interopRequireWildcard(_react); var React11 = _interopRequireWildcard(_react); var React12 = _interopRequireWildcard(_react); var React13 = _interopRequireWildcard(_react); var React15 = _interopRequireWildcard(_react); var React14 = _interopRequireWildcard(_react); var React18 = _interopRequireWildcard(_react); var React16 = _interopRequireWildcard(_react); var React17 = _interopRequireWildcard(_react); var React20 = _interopRequireWildcard(_react); var React19 = _interopRequireWildcard(_react); var React26 = _interopRequireWildcard(_react); var React23 = _interopRequireWildcard(_react); var React24 = _interopRequireWildcard(_react); var React25 = _interopRequireWildcard(_react); var React27 = _interopRequireWildcard(_react); var React28 = _interopRequireWildcard(_react); var React29 = _interopRequireWildcard(_react); var React31 = _interopRequireWildcard(_react); var React30 = _interopRequireWildcard(_react); var React32 = _interopRequireWildcard(_react); var React37 = _interopRequireWildcard(_react);
91
98
  var AccordionContext = React2.default.createContext(null);
92
99
  function useAccordionContext() {
93
100
  const context = React2.default.useContext(AccordionContext);
@@ -1470,18 +1477,10 @@ var Text = React2.default.forwardRef(
1470
1477
  props,
1471
1478
  TextPropsDefs,
1472
1479
  MarginPropDefs,
1473
- PaddingPropDefs
1474
- );
1475
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1476
- "p",
1477
- {
1478
- ref,
1479
- ...dataAttrs,
1480
- className: _clsx2.default.call(void 0, "lcs-text", className),
1481
- ...rest,
1482
- children
1483
- }
1480
+ PaddingPropDefs,
1481
+ ColorPropDef
1484
1482
  );
1483
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { ref, ...dataAttrs, className: _clsx2.default.call(void 0, "text", className), ...rest, children });
1485
1484
  }
1486
1485
  );
1487
1486
 
@@ -1672,6 +1671,96 @@ var Container = React11.forwardRef((props, ref) => {
1672
1671
  });
1673
1672
  Container.displayName = "Container";
1674
1673
 
1674
+ // src/components/flex/flex.tsx
1675
+
1676
+
1677
+
1678
+ // src/components/flex/flex.props.ts
1679
+ var FlexGapValues = ["0", "1", "2", "3", "4", "5", "6", "8"];
1680
+ var FlexDirectionValues = [
1681
+ "row",
1682
+ "row-reverse",
1683
+ "column",
1684
+ "column-reverse"
1685
+ ];
1686
+ var FlexJustifyValues = [
1687
+ "start",
1688
+ "end",
1689
+ "center",
1690
+ "between",
1691
+ "around",
1692
+ "evenly"
1693
+ ];
1694
+ var FlexAlignValues = [
1695
+ "start",
1696
+ "end",
1697
+ "center",
1698
+ "stretch",
1699
+ "baseline"
1700
+ ];
1701
+ var FlexWrapValues = ["nowrap", "wrap", "wrap-reverse"];
1702
+ var FlexPropsDefs = {
1703
+ /**
1704
+ * Sets the gap between flex items.
1705
+ */
1706
+ gap: {
1707
+ type: "enum | string",
1708
+ values: FlexGapValues,
1709
+ dataAttr: "gap",
1710
+ responsive: true
1711
+ },
1712
+ /**
1713
+ * Sets the justification of flex items along the main axis.
1714
+ */
1715
+ justify: {
1716
+ type: "enum",
1717
+ values: FlexJustifyValues,
1718
+ dataAttr: "justify",
1719
+ responsive: true
1720
+ },
1721
+ /**
1722
+ * Sets the direction of flex items.
1723
+ */
1724
+ direction: {
1725
+ type: "enum",
1726
+ values: FlexDirectionValues,
1727
+ dataAttr: "direction",
1728
+ responsive: true
1729
+ },
1730
+ /**
1731
+ * Sets the alignment of flex items along the cross axis.
1732
+ */
1733
+ align: {
1734
+ type: "enum",
1735
+ values: FlexAlignValues,
1736
+ dataAttr: "align",
1737
+ responsive: true
1738
+ },
1739
+ /**
1740
+ * Sets the wrapping behavior of flex items.
1741
+ */
1742
+ wrap: {
1743
+ type: "enum",
1744
+ values: FlexWrapValues,
1745
+ dataAttr: "wrap",
1746
+ responsive: true
1747
+ }
1748
+ };
1749
+
1750
+ // src/components/flex/flex.tsx
1751
+
1752
+ var Flex = React12.forwardRef((props, ref) => {
1753
+ const { className, dataAttrs, children, ...rest } = getComponentProps(
1754
+ props,
1755
+ FlexPropsDefs,
1756
+ MarginPropDefs,
1757
+ PaddingPropDefs,
1758
+ SpacingPropDef
1759
+ );
1760
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, className: _clsx2.default.call(void 0, "flex", className), ...dataAttrs, ...rest, children });
1761
+ });
1762
+ Flex.displayName = "Flex";
1763
+
1675
1764
  // src/components/panel/panel.tsx
1676
1765
 
1677
1766
 
@@ -1702,7 +1791,7 @@ var PanelPropsDefs = {
1702
1791
 
1703
1792
  // src/components/panel/panel.tsx
1704
1793
 
1705
- var Panel = React12.forwardRef((props, ref) => {
1794
+ var Panel = React13.forwardRef((props, ref) => {
1706
1795
  const { className, dataAttrs, children, ...rest } = getComponentProps(
1707
1796
  props,
1708
1797
  PanelPropsDefs,
@@ -1710,7 +1799,8 @@ var Panel = React12.forwardRef((props, ref) => {
1710
1799
  PaddingPropDefs,
1711
1800
  SpacingPropDef,
1712
1801
  RadiusPropDefs,
1713
- RoundnessPropDef
1802
+ RoundnessPropDef,
1803
+ ColorPropDef
1714
1804
  );
1715
1805
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1716
1806
  "div",
@@ -1731,11 +1821,11 @@ Panel.displayName = "Panel";
1731
1821
 
1732
1822
  // src/components/portal/portal-context.tsx
1733
1823
 
1734
- var PortalContext = React13.createContext(
1824
+ var PortalContext = React14.createContext(
1735
1825
  void 0
1736
1826
  );
1737
1827
  function usePortalContext() {
1738
- const context = React13.useContext(PortalContext);
1828
+ const context = React14.useContext(PortalContext);
1739
1829
  if (!context) {
1740
1830
  throw new Error("`usePortalContext` must be used within a `Portal.Root`");
1741
1831
  }
@@ -1783,7 +1873,7 @@ var PortalBackdropPropsDefs = {
1783
1873
 
1784
1874
  // src/components/portal/backdrop/portal-backdrop.tsx
1785
1875
 
1786
- var PortalBackdrop = React14.forwardRef(
1876
+ var PortalBackdrop = React15.forwardRef(
1787
1877
  (props, ref) => {
1788
1878
  const context = usePortalContext();
1789
1879
  const { className, dataAttrs, ...rest } = getComponentProps(
@@ -1811,11 +1901,11 @@ var _reactdom = require('react-dom'); var _reactdom2 = _interopRequireDefault(_r
1811
1901
 
1812
1902
  // src/components/theme/theme-context.tsx
1813
1903
 
1814
- var ThemeContext = React15.createContext(
1904
+ var ThemeContext = React16.createContext(
1815
1905
  void 0
1816
1906
  );
1817
1907
  function useTheme() {
1818
- const context = React15.useContext(ThemeContext);
1908
+ const context = React16.useContext(ThemeContext);
1819
1909
  if (!context) {
1820
1910
  throw new Error("`useTheme` must be used within a `Theme`");
1821
1911
  }
@@ -1833,9 +1923,9 @@ function useAnchorPosition({
1833
1923
  alignOffset = 0,
1834
1924
  enabled = true
1835
1925
  }) {
1836
- const [position, setPosition] = React16.useState(null);
1837
- const [, _forceUpdate] = React16.useReducer((x) => x + 1, 0);
1838
- const updatePosition = React16.useCallback(() => {
1926
+ const [position, setPosition] = React17.useState(null);
1927
+ const [, _forceUpdate] = React17.useReducer((x) => x + 1, 0);
1928
+ const updatePosition = React17.useCallback(() => {
1839
1929
  const anchor = anchorRef.current;
1840
1930
  const content = contentRef.current;
1841
1931
  if (!anchor || !content || !enabled) {
@@ -1896,7 +1986,7 @@ function useAnchorPosition({
1896
1986
  );
1897
1987
  setPosition({ top, left });
1898
1988
  }, [anchorRef, contentRef, side, align, sideOffset, alignOffset, enabled]);
1899
- React16.useEffect(() => {
1989
+ React17.useEffect(() => {
1900
1990
  if (!enabled) {
1901
1991
  setPosition(null);
1902
1992
  return;
@@ -1978,11 +2068,11 @@ var PortalContentPropsDefs = {
1978
2068
 
1979
2069
  // src/components/portal/content/portal-content.tsx
1980
2070
 
1981
- var PortalContent = React17.forwardRef(
2071
+ var PortalContent = React18.forwardRef(
1982
2072
  (props, ref) => {
1983
2073
  const portalContext = usePortalContext();
1984
- const themeContext = React17.useContext(ThemeContext);
1985
- const contentRef = React17.useRef(null);
2074
+ const themeContext = React18.useContext(ThemeContext);
2075
+ const contentRef = React18.useRef(null);
1986
2076
  const {
1987
2077
  side = "bottom",
1988
2078
  align = "center",
@@ -2004,7 +2094,7 @@ var PortalContent = React17.forwardRef(
2004
2094
  alignOffset: parseInt(alignOffset, 10) || 0,
2005
2095
  enabled: anchored && portalContext.open
2006
2096
  });
2007
- const setRefs = React17.useCallback(
2097
+ const setRefs = React18.useCallback(
2008
2098
  (node) => {
2009
2099
  contentRef.current = node;
2010
2100
  if (typeof ref === "function") {
@@ -2015,7 +2105,7 @@ var PortalContent = React17.forwardRef(
2015
2105
  },
2016
2106
  [ref]
2017
2107
  );
2018
- React17.useEffect(() => {
2108
+ React18.useEffect(() => {
2019
2109
  if (!portalContext.open) return;
2020
2110
  function onKeyDown(e) {
2021
2111
  if (e.key === "Escape") {
@@ -2027,7 +2117,7 @@ var PortalContent = React17.forwardRef(
2027
2117
  document.removeEventListener("keydown", onKeyDown);
2028
2118
  };
2029
2119
  }, [portalContext.open, portalContext.onOpenChange]);
2030
- React17.useEffect(() => {
2120
+ React18.useEffect(() => {
2031
2121
  if (!portalContext.open || !anchored) return;
2032
2122
  function onClickOutside(e) {
2033
2123
  const target = e.target;
@@ -2099,11 +2189,11 @@ PortalContent.displayName = "Portal.Content";
2099
2189
  // src/components/portal/trigger/portal-trigger.tsx
2100
2190
 
2101
2191
 
2102
- var PortalTrigger = React18.forwardRef(
2192
+ var PortalTrigger = React19.forwardRef(
2103
2193
  ({ children, asChild, onClick, ...props }, ref) => {
2104
2194
  const context = usePortalContext();
2105
- const internalRef = React18.useRef(null);
2106
- React18.useEffect(() => {
2195
+ const internalRef = React19.useRef(null);
2196
+ React19.useEffect(() => {
2107
2197
  if (internalRef.current) {
2108
2198
  context.triggerRef.current = internalRef.current;
2109
2199
  }
@@ -2112,7 +2202,7 @@ var PortalTrigger = React18.forwardRef(
2112
2202
  _optionalChain([context, 'access', _33 => _33.onOpenChange, 'optionalCall', _34 => _34(!context.open)]);
2113
2203
  _optionalChain([onClick, 'optionalCall', _35 => _35(event)]);
2114
2204
  };
2115
- const setRefs = React18.useCallback(
2205
+ const setRefs = React19.useCallback(
2116
2206
  (node) => {
2117
2207
  internalRef.current = node;
2118
2208
  if (typeof ref === "function") {
@@ -2124,8 +2214,8 @@ var PortalTrigger = React18.forwardRef(
2124
2214
  },
2125
2215
  [ref, context.triggerRef]
2126
2216
  );
2127
- if (asChild && React18.isValidElement(children)) {
2128
- return React18.cloneElement(children, {
2217
+ if (asChild && React19.isValidElement(children)) {
2218
+ return React19.cloneElement(children, {
2129
2219
  ref: setRefs,
2130
2220
  onClick: handleClick,
2131
2221
  ...props
@@ -2189,8 +2279,8 @@ var PortalRoot = (props) => {
2189
2279
  defaultValue: defaultOpen,
2190
2280
  onChange: onOpenChange
2191
2281
  });
2192
- const triggerRef = React19.useRef(null);
2193
- const value = React19.useMemo(
2282
+ const triggerRef = React20.useRef(null);
2283
+ const value = React20.useMemo(
2194
2284
  () => ({
2195
2285
  open,
2196
2286
  onOpenChange: setOpen,
@@ -2345,11 +2435,11 @@ var ProgressBar = Object.assign(ProgressBarRoot, {
2345
2435
 
2346
2436
  // src/components/select/select-context.tsx
2347
2437
 
2348
- var SelectContext = React22.createContext(
2438
+ var SelectContext = React23.createContext(
2349
2439
  null
2350
2440
  );
2351
2441
  function useSelectContext() {
2352
- const context = React22.useContext(SelectContext);
2442
+ const context = React23.useContext(SelectContext);
2353
2443
  if (!context) {
2354
2444
  throw new Error("Select components must be used within a Select.Root");
2355
2445
  }
@@ -2359,7 +2449,7 @@ function useSelectContext() {
2359
2449
  // src/components/select/utils/user-composed-refs.ts
2360
2450
 
2361
2451
  function useComposedRefs(...refs) {
2362
- return React23.useCallback(
2452
+ return React24.useCallback(
2363
2453
  (node) => {
2364
2454
  refs.forEach((ref) => {
2365
2455
  if (typeof ref === "function") {
@@ -2377,7 +2467,7 @@ function useComposedRefs(...refs) {
2377
2467
 
2378
2468
 
2379
2469
 
2380
- var SelectViewport = React24.forwardRef(
2470
+ var SelectViewport = React25.forwardRef(
2381
2471
  (props, ref) => {
2382
2472
  const { className, children, ...rest } = props;
2383
2473
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref, className: _clsx2.default.call(void 0, "select-viewport", className), ...rest, children });
@@ -2387,7 +2477,7 @@ SelectViewport.displayName = "Select.Viewport";
2387
2477
 
2388
2478
  // src/components/select/content/select-content.tsx
2389
2479
 
2390
- var SelectContent = React25.forwardRef(
2480
+ var SelectContent = React26.forwardRef(
2391
2481
  (props, forwardedRef) => {
2392
2482
  const {
2393
2483
  className,
@@ -2400,10 +2490,10 @@ var SelectContent = React25.forwardRef(
2400
2490
  } = props;
2401
2491
  const context = useSelectContext();
2402
2492
  const composedRef = useComposedRefs(forwardedRef, context.contentRef);
2403
- React25.useEffect(() => {
2493
+ React26.useEffect(() => {
2404
2494
  context.itemValues.current = [];
2405
2495
  }, [context.open]);
2406
- React25.useEffect(() => {
2496
+ React26.useEffect(() => {
2407
2497
  if (!context.open) return;
2408
2498
  const handleClickOutside = (event) => {
2409
2499
  const target = event.target;
@@ -2414,7 +2504,7 @@ var SelectContent = React25.forwardRef(
2414
2504
  document.addEventListener("mousedown", handleClickOutside);
2415
2505
  return () => document.removeEventListener("mousedown", handleClickOutside);
2416
2506
  }, [context.open]);
2417
- React25.useEffect(() => {
2507
+ React26.useEffect(() => {
2418
2508
  if (!context.open) return;
2419
2509
  const handleKeyDown = (event) => {
2420
2510
  const items = context.itemValues.current;
@@ -2467,10 +2557,10 @@ var SelectContent = React25.forwardRef(
2467
2557
  document.addEventListener("keydown", handleKeyDown);
2468
2558
  return () => document.removeEventListener("keydown", handleKeyDown);
2469
2559
  }, [context.open, context.highlightedIndex]);
2470
- const [contentWidth, setContentWidth] = React25.useState();
2560
+ const [contentWidth, setContentWidth] = React26.useState();
2471
2561
  const labelInside = context.labelPosition === "inside";
2472
2562
  const anchorRef = labelInside ? context.rootRef : context.triggerRef;
2473
- React25.useLayoutEffect(() => {
2563
+ React26.useLayoutEffect(() => {
2474
2564
  if (context.open && anchorRef.current) {
2475
2565
  setContentWidth(anchorRef.current.getBoundingClientRect().width);
2476
2566
  }
@@ -2518,7 +2608,7 @@ var SelectGroupsPropDefs = {
2518
2608
 
2519
2609
  // src/components/select/group/select-group.tsx
2520
2610
 
2521
- var SelectGroup = React26.forwardRef(
2611
+ var SelectGroup = React27.forwardRef(
2522
2612
  (props, ref) => {
2523
2613
  const { className, children, dataAttrs, ...rest } = getComponentProps(
2524
2614
  props,
@@ -2582,7 +2672,7 @@ var SelectItemPropDefs = {
2582
2672
 
2583
2673
  // src/components/select/item/select-item.tsx
2584
2674
 
2585
- var SelectItem = React27.forwardRef(
2675
+ var SelectItem = React28.forwardRef(
2586
2676
  (props, ref) => {
2587
2677
  const context = useSelectContext();
2588
2678
  const { value, disabled, children, className, ...rest } = getComponentProps(
@@ -2590,12 +2680,12 @@ var SelectItem = React27.forwardRef(
2590
2680
  SelectItemPropDefs
2591
2681
  );
2592
2682
  const selected = context.value === value;
2593
- React27.useEffect(() => {
2683
+ React28.useEffect(() => {
2594
2684
  if (selected && children) {
2595
2685
  context.setDisplayValue(children);
2596
2686
  }
2597
2687
  }, [selected]);
2598
- React27.useEffect(() => {
2688
+ React28.useEffect(() => {
2599
2689
  if (!value) return;
2600
2690
  if (!disabled) {
2601
2691
  const values = context.itemValues.current;
@@ -2672,14 +2762,14 @@ var SelectLabelPropDefs = {
2672
2762
 
2673
2763
  // src/components/select/label/select-label.tsx
2674
2764
 
2675
- var SelectLabel = React28.forwardRef(
2765
+ var SelectLabel = React29.forwardRef(
2676
2766
  (props, ref) => {
2677
2767
  const context = useSelectContext();
2678
2768
  const { className, children, position, dataAttrs } = getComponentProps(
2679
2769
  props,
2680
2770
  SelectLabelPropDefs
2681
2771
  );
2682
- React28.useLayoutEffect(() => {
2772
+ React29.useLayoutEffect(() => {
2683
2773
  _optionalChain([context, 'access', _47 => _47.setLabelPosition, 'optionalCall', _48 => _48(_nullishCoalesce(position, () => ( "top")))]);
2684
2774
  }, [position, context.setLabelPosition]);
2685
2775
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -2714,7 +2804,7 @@ SelectLabel.displayName = "Select.Label";
2714
2804
 
2715
2805
 
2716
2806
 
2717
- var SelectValue = React29.forwardRef(
2807
+ var SelectValue = React30.forwardRef(
2718
2808
  (props, ref) => {
2719
2809
  const { className, placeholder: placeholderProp, ...rest } = props;
2720
2810
  const context = useSelectContext();
@@ -2766,7 +2856,7 @@ var SelectTriggerPropsDefs = {};
2766
2856
 
2767
2857
  // src/components/select/trigger/select-trigger.tsx
2768
2858
 
2769
- var SelectTrigger = React30.forwardRef(
2859
+ var SelectTrigger = React31.forwardRef(
2770
2860
  (props, forwardedRef) => {
2771
2861
  const {
2772
2862
  className,
@@ -3018,7 +3108,7 @@ SelectRoot.displayName = "Select.Root";
3018
3108
 
3019
3109
 
3020
3110
 
3021
- var SelectSeparator = React31.forwardRef(
3111
+ var SelectSeparator = React32.forwardRef(
3022
3112
  (props, ref) => {
3023
3113
  const { className, ...rest } = props;
3024
3114
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -3094,17 +3184,364 @@ var Separator = (props) => {
3094
3184
  };
3095
3185
  Separator.displayName = "Separator";
3096
3186
 
3187
+ // src/components/switch/indicator/switch-indicator.tsx
3188
+
3189
+
3190
+
3191
+ // src/components/switch/switch-context.ts
3192
+
3193
+ var SwitchContext = React2.default.createContext(
3194
+ null
3195
+ );
3196
+ function useSwitchContext() {
3197
+ const context = React2.default.useContext(SwitchContext);
3198
+ if (!context) {
3199
+ throw new Error("Switch components must be used within a Switch.Root");
3200
+ }
3201
+ return context;
3202
+ }
3203
+
3204
+ // src/components/switch/root/switch-root.props.ts
3205
+ var SwitchVariants = ["solid", "outlined", "muted"];
3206
+ var SwitchRootPropsDefs = {
3207
+ /**
3208
+ * Sets the variant style of the switch ("solid" or "outlined").
3209
+ */
3210
+ variant: {
3211
+ type: "enum",
3212
+ values: SwitchVariants,
3213
+ dataAttr: "variant"
3214
+ },
3215
+ /**
3216
+ * Sets the checked state of the switch.
3217
+ *
3218
+ * When using an uncontrolled switch, use `defaultChecked` instead.
3219
+ * @default undefined
3220
+ */
3221
+ checked: {
3222
+ type: "boolean",
3223
+ dataAttr: "checked"
3224
+ },
3225
+ /**
3226
+ * The value of the switch (checked state).
3227
+ */
3228
+ value: {
3229
+ type: "boolean"
3230
+ },
3231
+ /**
3232
+ * Sets the default checked state of the switch.
3233
+ * @default undefined
3234
+ */
3235
+ defaultChecked: {
3236
+ type: "boolean"
3237
+ },
3238
+ /**
3239
+ * Disables the switch component.
3240
+ * @default undefined
3241
+ */
3242
+ disabled: {
3243
+ type: "boolean",
3244
+ dataAttr: "disabled"
3245
+ },
3246
+ /**
3247
+ * Makes the switch read-only.
3248
+ * @default undefined
3249
+ */
3250
+ readonly: {
3251
+ type: "boolean",
3252
+ dataAttr: "readonly"
3253
+ },
3254
+ /**
3255
+ * Marks the switch as required.
3256
+ * @default undefined
3257
+ */
3258
+ required: {
3259
+ type: "boolean",
3260
+ dataAttr: "required"
3261
+ },
3262
+ /**
3263
+ * Sets the name attribute of the switch input for form control.
3264
+ * @default undefined
3265
+ */
3266
+ name: {
3267
+ type: "string"
3268
+ },
3269
+ /**
3270
+ * Callback fired when the checked state changes.
3271
+ *
3272
+ * @param value - The new checked state.
3273
+ */
3274
+ onCheckedChange: {
3275
+ type: "function"
3276
+ }
3277
+ };
3278
+
3279
+ // src/components/switch/indicator/switch-indicator.props.ts
3280
+ var SwitchIndicatorPropDefs = {
3281
+ /**
3282
+ * Sets the variant style of the switch ("solid" or "outlined").
3283
+ */
3284
+ variant: {
3285
+ type: "enum",
3286
+ values: SwitchVariants,
3287
+ dataAttr: "variant"
3288
+ }
3289
+ };
3290
+
3291
+ // src/components/switch/indicator/switch-indicator.tsx
3292
+
3293
+ var SwitchIndicator = React2.default.forwardRef((props, ref) => {
3294
+ const {
3295
+ value,
3296
+ setValue,
3297
+ hovered,
3298
+ color,
3299
+ disabled,
3300
+ readonly,
3301
+ focused,
3302
+ variant: contextVariant
3303
+ } = useSwitchContext();
3304
+ const { size, variant, className, style, dataAttrs } = getComponentProps(
3305
+ props,
3306
+ SwitchIndicatorPropDefs,
3307
+ SizePropDef
3308
+ );
3309
+ const indicatorVariant = variant || contextVariant;
3310
+ const handleKeyDown = (event) => {
3311
+ if (disabled || readonly) return;
3312
+ if (event.key === " " || event.key === "Enter") {
3313
+ event.preventDefault();
3314
+ setValue(!value);
3315
+ }
3316
+ };
3317
+ const indicatorProps = {
3318
+ ...value && { "data-checked": true },
3319
+ ...disabled && { "data-disabled": true },
3320
+ ...readonly && { "data-readonly": true },
3321
+ ...(variant || contextVariant) && { "data-variant": indicatorVariant }
3322
+ };
3323
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3324
+ "div",
3325
+ {
3326
+ ref,
3327
+ style,
3328
+ role: "switch",
3329
+ "data-size": size,
3330
+ "data-color": color,
3331
+ "data-hovered": hovered,
3332
+ "aria-disabled": disabled,
3333
+ "data-focused": focused,
3334
+ "aria-readonly": readonly,
3335
+ onKeyDown: handleKeyDown,
3336
+ tabIndex: disabled || readonly ? -1 : 0,
3337
+ className: _clsx2.default.call(void 0, "switch-indicator", className),
3338
+ ...indicatorProps,
3339
+ ...dataAttrs
3340
+ }
3341
+ );
3342
+ });
3343
+ SwitchIndicator.displayName = "Switch.Indicator";
3344
+
3345
+ // src/components/switch/label/switch-label.tsx
3346
+
3347
+
3348
+
3349
+ // src/components/switch/label/switch-label.props.ts
3350
+ var labelPositions3 = ["top", "left", "right", "bottom"];
3351
+ var SwitchLabelPropDefs = {
3352
+ /**
3353
+ * Sets the position of the label relative to the switch.
3354
+ *
3355
+ * @example position="left" // positions the label to the left of the switch
3356
+ * @example position="top" // positions the label above the switch
3357
+ */
3358
+ position: {
3359
+ type: "enum",
3360
+ values: labelPositions3,
3361
+ dataAttr: "position"
3362
+ }
3363
+ };
3364
+
3365
+ // src/components/switch/label/switch-label.tsx
3366
+
3367
+ var SwitchLabel = React2.default.forwardRef(
3368
+ (props, ref) => {
3369
+ const context = useSwitchContext();
3370
+ const { className, children, position } = getComponentProps(
3371
+ props,
3372
+ SwitchLabelPropDefs
3373
+ );
3374
+ React2.default.useLayoutEffect(() => {
3375
+ _optionalChain([context, 'access', _50 => _50.setLabelPosition, 'optionalCall', _51 => _51(_nullishCoalesce(position, () => ( "right")))]);
3376
+ }, [position, context.setLabelPosition]);
3377
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3378
+ "label",
3379
+ {
3380
+ ref,
3381
+ htmlFor: context.labelId,
3382
+ className: _clsx2.default.call(void 0, "switch-label", className),
3383
+ ...position && { [`data-position`]: position },
3384
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text, { children })
3385
+ }
3386
+ );
3387
+ }
3388
+ );
3389
+ SwitchLabel.displayName = "Switch.Label";
3390
+
3391
+ // src/components/switch/root/switch-root.tsx
3392
+
3393
+
3394
+
3395
+
3396
+
3397
+
3398
+
3399
+
3400
+ var ALLOWED_CHILDREN7 = [
3401
+ SwitchLabel.displayName,
3402
+ SwitchIndicator.displayName
3403
+ ];
3404
+ var SwitchRoot = (props) => {
3405
+ const {
3406
+ name,
3407
+ size,
3408
+ color,
3409
+ variant,
3410
+ checked,
3411
+ dataAttrs,
3412
+ onCheckedChange,
3413
+ value: valueProp,
3414
+ disabled = false,
3415
+ required = false,
3416
+ readonly = false,
3417
+ defaultChecked = false
3418
+ } = getComponentProps(
3419
+ props,
3420
+ SwitchRootPropsDefs,
3421
+ AlignPropDef,
3422
+ MarginPropDefs,
3423
+ SizePropDef,
3424
+ ColorPropDef
3425
+ );
3426
+ const [value, setValue] = useControllableState({
3427
+ value: valueProp || checked,
3428
+ defaultValue: defaultChecked,
3429
+ onChange: onCheckedChange
3430
+ });
3431
+ const labelId = _react.useId.call(void 0, );
3432
+ const [labelPosition, setLabelPosition] = _react.useState.call(void 0, "right");
3433
+ const [hovered, setHovered] = _react.useState.call(void 0, false);
3434
+ const [focused, setFocused] = _react.useState.call(void 0, false);
3435
+ const validChildren = filterChildren(props.children, ALLOWED_CHILDREN7, {
3436
+ parentDisplayName: SwitchRoot.displayName
3437
+ });
3438
+ const { restDataAttrs } = _react.useMemo.call(void 0, () => {
3439
+ const { ["data-color"]: _, ...restDataAttrs2 } = dataAttrs || {};
3440
+ return { restDataAttrs: restDataAttrs2 };
3441
+ }, [dataAttrs]);
3442
+ const { indicator, otherChildren } = _react.useMemo.call(void 0, () => {
3443
+ const indicatorIndex = validChildren.findIndex(
3444
+ (child) => _react.isValidElement.call(void 0, child) && child.type.displayName === SwitchIndicator.displayName
3445
+ );
3446
+ if (indicatorIndex > -1) {
3447
+ return {
3448
+ indicator: validChildren[indicatorIndex],
3449
+ otherChildren: validChildren.filter((_, i) => i !== indicatorIndex)
3450
+ };
3451
+ }
3452
+ return {
3453
+ indicator: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SwitchIndicator, { size }),
3454
+ otherChildren: validChildren
3455
+ };
3456
+ }, [validChildren, size]);
3457
+ const contextValue = _react.useMemo.call(void 0,
3458
+ () => ({
3459
+ name,
3460
+ value,
3461
+ color,
3462
+ setValue,
3463
+ onCheckedChange,
3464
+ labelId,
3465
+ labelPosition,
3466
+ setLabelPosition,
3467
+ variant,
3468
+ hovered,
3469
+ setHovered,
3470
+ focused,
3471
+ setFocused,
3472
+ disabled,
3473
+ readonly,
3474
+ required
3475
+ }),
3476
+ [
3477
+ name,
3478
+ value,
3479
+ color,
3480
+ onCheckedChange,
3481
+ setValue,
3482
+ labelId,
3483
+ labelPosition,
3484
+ hovered,
3485
+ focused,
3486
+ disabled,
3487
+ readonly,
3488
+ required
3489
+ ]
3490
+ );
3491
+ const handleClick = () => {
3492
+ if (disabled || readonly) return;
3493
+ setValue(!value);
3494
+ };
3495
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SwitchContext.Provider, { value: contextValue, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3496
+ "div",
3497
+ {
3498
+ className: _clsx2.default.call(void 0, "switch-root", props.className),
3499
+ onClick: () => handleClick(),
3500
+ onFocus: () => setFocused(true),
3501
+ onBlur: () => setFocused(false),
3502
+ onMouseEnter: () => setHovered(true),
3503
+ onMouseLeave: () => setHovered(false),
3504
+ ...restDataAttrs,
3505
+ children: [
3506
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3507
+ "div",
3508
+ {
3509
+ className: "switch-container",
3510
+ "data-size": size,
3511
+ "data-color": color,
3512
+ "data-checked": value,
3513
+ "data-hovered": hovered,
3514
+ "data-focused": focused,
3515
+ "data-variant": variant,
3516
+ children: indicator
3517
+ }
3518
+ ),
3519
+ otherChildren,
3520
+ name && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "input", { type: "hidden", name, value: String(value) })
3521
+ ]
3522
+ }
3523
+ ) });
3524
+ };
3525
+ SwitchRoot.displayName = "Switch";
3526
+
3527
+ // src/components/switch/switch.tsx
3528
+ var Switch = Object.assign(SwitchRoot, {
3529
+ Root: SwitchRoot,
3530
+ Label: SwitchLabel,
3531
+ Indicator: SwitchIndicator
3532
+ });
3533
+
3097
3534
  // src/components/theme/theme.tsx
3098
3535
 
3099
3536
 
3100
- var Theme = React32.forwardRef((props, ref) => {
3101
- const context = React32.useContext(ThemeContext);
3537
+ var Theme = React37.forwardRef((props, ref) => {
3538
+ const context = React37.useContext(ThemeContext);
3102
3539
  const isRoot = context === void 0;
3103
3540
  if (isRoot) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThemeRoot, { ...props, ref });
3104
3541
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThemeSub, { ...props, ref });
3105
3542
  });
3106
3543
  Theme.displayName = "Theme";
3107
- var ThemeRoot = React32.forwardRef((props, ref) => {
3544
+ var ThemeRoot = React37.forwardRef((props, ref) => {
3108
3545
  const {
3109
3546
  appearance: themeAppearance,
3110
3547
  radius: themeRadius,
@@ -3113,15 +3550,15 @@ var ThemeRoot = React32.forwardRef((props, ref) => {
3113
3550
  children,
3114
3551
  ...rest
3115
3552
  } = props;
3116
- const [appearance, setAppearance] = React32.useState(
3553
+ const [appearance, setAppearance] = React37.useState(
3117
3554
  _nullishCoalesce(themeAppearance, () => ( "light"))
3118
3555
  );
3119
- const [radius, setRadius] = React32.useState(_nullishCoalesce(themeRadius, () => ( "md")));
3120
- const [roundness2, setRoundness] = React32.useState(
3556
+ const [radius, setRadius] = React37.useState(_nullishCoalesce(themeRadius, () => ( "md")));
3557
+ const [roundness2, setRoundness] = React37.useState(
3121
3558
  _nullishCoalesce(themeRoundness, () => ( "3"))
3122
3559
  );
3123
- const [spacing, setSpacing] = React32.useState(_nullishCoalesce(themeSpacing, () => ( "md")));
3124
- const value = React32.useMemo(
3560
+ const [spacing, setSpacing] = React37.useState(_nullishCoalesce(themeSpacing, () => ( "md")));
3561
+ const value = React37.useMemo(
3125
3562
  () => ({
3126
3563
  appearance,
3127
3564
  radius,
@@ -3148,8 +3585,8 @@ var ThemeRoot = React32.forwardRef((props, ref) => {
3148
3585
  ) });
3149
3586
  });
3150
3587
  ThemeRoot.displayName = "ThemeRoot";
3151
- var ThemeSub = React32.forwardRef((props, ref) => {
3152
- const context = React32.useContext(ThemeContext);
3588
+ var ThemeSub = React37.forwardRef((props, ref) => {
3589
+ const context = React37.useContext(ThemeContext);
3153
3590
  const {
3154
3591
  appearance,
3155
3592
  radius,
@@ -3225,7 +3662,7 @@ function ThemeControl({ position = "bottom" }) {
3225
3662
  {
3226
3663
  variant: "solid",
3227
3664
  value: appearance,
3228
- onValueChange: (change) => _optionalChain([onAppearanceChange, 'optionalCall', _50 => _50(change)]),
3665
+ onValueChange: (change) => _optionalChain([onAppearanceChange, 'optionalCall', _52 => _52(change)]),
3229
3666
  children: [
3230
3667
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Select.Label, { position: "inside", children: "Theme Settings" }),
3231
3668
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Select.Trigger, {}),
@@ -3241,7 +3678,7 @@ function ThemeControl({ position = "bottom" }) {
3241
3678
  {
3242
3679
  variant: "solid",
3243
3680
  value: radius,
3244
- onValueChange: (change) => _optionalChain([onRadiusChange, 'optionalCall', _51 => _51(change)]),
3681
+ onValueChange: (change) => _optionalChain([onRadiusChange, 'optionalCall', _53 => _53(change)]),
3245
3682
  children: [
3246
3683
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Select.Label, { position: "inside", children: "Radius" }),
3247
3684
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Select.Trigger, {}),
@@ -3262,7 +3699,7 @@ function ThemeControl({ position = "bottom" }) {
3262
3699
  {
3263
3700
  variant: "solid",
3264
3701
  value: roundness2,
3265
- onValueChange: (change) => _optionalChain([onRoundnessChange, 'optionalCall', _52 => _52(change)]),
3702
+ onValueChange: (change) => _optionalChain([onRoundnessChange, 'optionalCall', _54 => _54(change)]),
3266
3703
  children: [
3267
3704
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Select.Label, { className: "min-w-40!", position: "inside", children: "Roundness" }),
3268
3705
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Select.Trigger, {}),
@@ -3282,7 +3719,7 @@ function ThemeControl({ position = "bottom" }) {
3282
3719
  {
3283
3720
  variant: "solid",
3284
3721
  value: spacing,
3285
- onValueChange: (change) => _optionalChain([onSpacingChange, 'optionalCall', _53 => _53(change)]),
3722
+ onValueChange: (change) => _optionalChain([onSpacingChange, 'optionalCall', _55 => _55(change)]),
3286
3723
  children: [
3287
3724
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Select.Label, { position: "inside", children: "Spacing" }),
3288
3725
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Select.Trigger, {}),
@@ -3316,5 +3753,7 @@ function ThemeControl({ position = "bottom" }) {
3316
3753
 
3317
3754
 
3318
3755
 
3319
- exports.Accordion = Accordion; exports.Badge = Badge; exports.Box = Box; exports.Button = Button; exports.Checkbox = Checkbox; exports.Container = Container; exports.Panel = Panel; exports.Portal = Portal; exports.ProgressBar = ProgressBar; exports.Select = Select; exports.Separator = Separator; exports.Text = Text; exports.Theme = Theme; exports.ThemeControl = ThemeControl; exports.useTheme = useTheme;
3756
+
3757
+
3758
+ exports.Accordion = Accordion; exports.Badge = Badge; exports.Box = Box; exports.Button = Button; exports.Checkbox = Checkbox; exports.Container = Container; exports.Flex = Flex; exports.Panel = Panel; exports.Portal = Portal; exports.ProgressBar = ProgressBar; exports.Select = Select; exports.Separator = Separator; exports.Switch = Switch; exports.Text = Text; exports.Theme = Theme; exports.ThemeControl = ThemeControl; exports.useTheme = useTheme;
3320
3759
  //# sourceMappingURL=index.js.map