@entropix/react 0.3.0 → 1.0.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.
Files changed (121) hide show
  1. package/dist/accordion.cjs +27 -0
  2. package/dist/accordion.css +57 -0
  3. package/dist/accordion.d.cts +30 -0
  4. package/dist/accordion.d.ts +30 -0
  5. package/dist/accordion.js +6 -0
  6. package/dist/button.cjs +15 -0
  7. package/dist/button.css +113 -0
  8. package/dist/button.d.cts +25 -0
  9. package/dist/button.d.ts +25 -0
  10. package/dist/button.js +6 -0
  11. package/dist/checkbox.cjs +15 -0
  12. package/dist/checkbox.css +89 -0
  13. package/dist/checkbox.d.cts +26 -0
  14. package/dist/checkbox.d.ts +26 -0
  15. package/dist/checkbox.js +6 -0
  16. package/dist/chunk-2MKJZEUK.cjs +4 -0
  17. package/dist/chunk-34IVVIO3.cjs +119 -0
  18. package/dist/chunk-36ZHHJYV.js +79 -0
  19. package/dist/chunk-5DKE5YQD.cjs +10 -0
  20. package/dist/chunk-664P2RGR.js +108 -0
  21. package/dist/chunk-6NKHMBF3.cjs +97 -0
  22. package/dist/chunk-6UAQCHIW.js +8 -0
  23. package/dist/chunk-7AUIZOEH.cjs +84 -0
  24. package/dist/chunk-AVCBDUKH.js +3 -0
  25. package/dist/chunk-B5JZHE4I.cjs +90 -0
  26. package/dist/chunk-BN57JPKV.js +26 -0
  27. package/dist/chunk-BY4E26CV.js +114 -0
  28. package/dist/chunk-CL6JXZIY.js +88 -0
  29. package/dist/chunk-CTT3LXMZ.js +76 -0
  30. package/dist/chunk-EASSPJBG.cjs +110 -0
  31. package/dist/chunk-EWY7MSXF.cjs +94 -0
  32. package/dist/chunk-FJGLK3I4.js +89 -0
  33. package/dist/chunk-GTVBKK3W.js +88 -0
  34. package/dist/chunk-GZXXUFCJ.cjs +15 -0
  35. package/dist/chunk-IXH7OVN3.cjs +86 -0
  36. package/dist/chunk-KGIUECLG.cjs +91 -0
  37. package/dist/chunk-LDOP6DVX.cjs +28 -0
  38. package/dist/chunk-LJK6KK2H.cjs +43 -0
  39. package/dist/chunk-OT2HJUCB.js +84 -0
  40. package/dist/chunk-PILZGMQG.js +87 -0
  41. package/dist/chunk-PN42JF6U.js +92 -0
  42. package/dist/chunk-RPIYYBFJ.cjs +90 -0
  43. package/dist/chunk-S6DVQAH4.cjs +240 -0
  44. package/dist/chunk-U5CZHO6D.js +13 -0
  45. package/dist/chunk-UGCCJI2F.js +111 -0
  46. package/dist/chunk-W6N4D4N4.js +230 -0
  47. package/dist/chunk-Y2M2LJGJ.js +41 -0
  48. package/dist/chunk-YJG5KX6O.cjs +81 -0
  49. package/dist/chunk-ZG4PZBSL.cjs +113 -0
  50. package/dist/dialog.cjs +39 -0
  51. package/dist/dialog.css +89 -0
  52. package/dist/dialog.d.cts +62 -0
  53. package/dist/dialog.d.ts +62 -0
  54. package/dist/dialog.js +6 -0
  55. package/dist/index.cjs +170 -1223
  56. package/dist/index.css +994 -1015
  57. package/dist/index.d.cts +17 -477
  58. package/dist/index.d.ts +17 -477
  59. package/dist/index.js +19 -1189
  60. package/dist/input.cjs +15 -0
  61. package/dist/input.css +135 -0
  62. package/dist/input.d.cts +37 -0
  63. package/dist/input.d.ts +37 -0
  64. package/dist/input.js +6 -0
  65. package/dist/layout.cjs +25 -0
  66. package/dist/layout.css +176 -0
  67. package/dist/layout.d.cts +108 -0
  68. package/dist/layout.d.ts +108 -0
  69. package/dist/layout.js +4 -0
  70. package/dist/menu.cjs +27 -0
  71. package/dist/menu.css +51 -0
  72. package/dist/menu.d.cts +31 -0
  73. package/dist/menu.d.ts +31 -0
  74. package/dist/menu.js +6 -0
  75. package/dist/radio.cjs +19 -0
  76. package/dist/radio.css +93 -0
  77. package/dist/radio.d.cts +37 -0
  78. package/dist/radio.d.ts +37 -0
  79. package/dist/radio.js +6 -0
  80. package/dist/select.cjs +27 -0
  81. package/dist/select.css +114 -0
  82. package/dist/select.d.cts +59 -0
  83. package/dist/select.d.ts +59 -0
  84. package/dist/select.js +6 -0
  85. package/dist/styles/accordion.css +1 -69
  86. package/dist/styles/button.css +1 -135
  87. package/dist/styles/checkbox.css +1 -121
  88. package/dist/styles/dialog.css +1 -104
  89. package/dist/styles/index.css +1 -16
  90. package/dist/styles/input.css +1 -178
  91. package/dist/styles/layout.css +1 -127
  92. package/dist/styles/menu.css +1 -64
  93. package/dist/styles/radio.css +1 -130
  94. package/dist/styles/select.css +1 -150
  95. package/dist/styles/switch.css +1 -52
  96. package/dist/styles/tabs.css +1 -86
  97. package/dist/styles/toggle.css +1 -47
  98. package/dist/switch.cjs +16 -0
  99. package/dist/switch.css +89 -0
  100. package/dist/switch.d.cts +14 -0
  101. package/dist/switch.d.ts +14 -0
  102. package/dist/switch.js +7 -0
  103. package/dist/tabs.cjs +27 -0
  104. package/dist/tabs.css +69 -0
  105. package/dist/tabs.d.cts +31 -0
  106. package/dist/tabs.d.ts +31 -0
  107. package/dist/tabs.js +6 -0
  108. package/dist/textarea.cjs +15 -0
  109. package/dist/textarea.css +135 -0
  110. package/dist/textarea.d.cts +41 -0
  111. package/dist/textarea.d.ts +41 -0
  112. package/dist/textarea.js +6 -0
  113. package/dist/toggle.cjs +19 -0
  114. package/dist/toggle.css +41 -0
  115. package/dist/toggle.d.cts +34 -0
  116. package/dist/toggle.d.ts +34 -0
  117. package/dist/toggle.js +6 -0
  118. package/package.json +135 -4
  119. package/dist/index.cjs.map +0 -1
  120. package/dist/index.css.map +0 -1
  121. package/dist/index.js.map +0 -1
@@ -0,0 +1,79 @@
1
+ import { useKeyboardHandler } from './chunk-BN57JPKV.js';
2
+ import { mapAccessibilityToAria } from './chunk-Y2M2LJGJ.js';
3
+ import { cn } from './chunk-6UAQCHIW.js';
4
+ import { useTabs } from '@entropix/core';
5
+ import { createContext, useCallback, useContext } from 'react';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ var TabsContext = createContext(null);
9
+ function useTabsContext() {
10
+ const context = useContext(TabsContext);
11
+ if (!context) {
12
+ throw new Error(
13
+ "Tabs compound components must be used within a <Tabs> provider."
14
+ );
15
+ }
16
+ return context;
17
+ }
18
+ function Tabs({
19
+ children,
20
+ className,
21
+ orientation = "horizontal",
22
+ activationMode = "automatic",
23
+ ...options
24
+ }) {
25
+ const tabs = useTabs({ ...options, orientation, activationMode });
26
+ return /* @__PURE__ */ jsx(TabsContext.Provider, { value: { ...tabs, orientation, activationMode }, children: /* @__PURE__ */ jsx("div", { className: cn("entropix-tabs", className), "data-orientation": orientation, children }) });
27
+ }
28
+ function TabList({ children, className }) {
29
+ const { getTabListProps } = useTabsContext();
30
+ const propGetterReturn = getTabListProps();
31
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
32
+ return /* @__PURE__ */ jsx("div", { ...ariaProps, className: cn("entropix-tablist", className), children });
33
+ }
34
+ function Tab({ value, children, className }) {
35
+ const { getTabProps, select, selectedKey, orientation } = useTabsContext();
36
+ const propGetterReturn = getTabProps(value);
37
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
38
+ const baseId = ariaProps["aria-controls"] ? String(ariaProps["aria-controls"]).replace(`-panel-${value}`, "") : "";
39
+ const handleClick = useCallback(() => {
40
+ propGetterReturn.onAction?.();
41
+ }, [propGetterReturn.onAction]);
42
+ const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
43
+ activate: () => select(value)
44
+ });
45
+ return /* @__PURE__ */ jsx(
46
+ "button",
47
+ {
48
+ ...ariaProps,
49
+ id: `${baseId}-tab-${value}`,
50
+ className: cn("entropix-tab", className),
51
+ onClick: handleClick,
52
+ onKeyDown,
53
+ "data-state": selectedKey === value ? "active" : "inactive",
54
+ "data-orientation": orientation,
55
+ children
56
+ }
57
+ );
58
+ }
59
+ function TabPanel({ value, children, className }) {
60
+ const { getTabPanelProps, selectedKey } = useTabsContext();
61
+ const propGetterReturn = getTabPanelProps(value);
62
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
63
+ const baseId = ariaProps["aria-labelledby"] ? String(ariaProps["aria-labelledby"]).replace(`-tab-${value}`, "") : "";
64
+ if (selectedKey !== value) return null;
65
+ return /* @__PURE__ */ jsx(
66
+ "div",
67
+ {
68
+ ...ariaProps,
69
+ id: `${baseId}-panel-${value}`,
70
+ className: cn("entropix-tabpanel", className),
71
+ "data-state": "active",
72
+ children
73
+ }
74
+ );
75
+ }
76
+
77
+ export { Tab, TabList, TabPanel, Tabs };
78
+ //# sourceMappingURL=chunk-36ZHHJYV.js.map
79
+ //# sourceMappingURL=chunk-36ZHHJYV.js.map
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ // src/utils/cn.ts
4
+ function cn(...classes) {
5
+ return classes.filter(Boolean).join(" ");
6
+ }
7
+
8
+ exports.cn = cn;
9
+ //# sourceMappingURL=chunk-5DKE5YQD.cjs.map
10
+ //# sourceMappingURL=chunk-5DKE5YQD.cjs.map
@@ -0,0 +1,108 @@
1
+ import { mapAccessibilityToAria } from './chunk-Y2M2LJGJ.js';
2
+ import { cn } from './chunk-6UAQCHIW.js';
3
+ import { forwardRef, useCallback } from 'react';
4
+ import { useInput } from '@entropix/core';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+
7
+ var Input = forwardRef(function Input2({
8
+ value,
9
+ defaultValue,
10
+ onChange,
11
+ disabled,
12
+ readOnly,
13
+ required,
14
+ invalid,
15
+ label,
16
+ helperText,
17
+ errorMessage,
18
+ variant = "default",
19
+ size = "md",
20
+ className,
21
+ type,
22
+ placeholder,
23
+ name,
24
+ ...rest
25
+ }, ref) {
26
+ const isInvalid = invalid || !!errorMessage;
27
+ const {
28
+ value: inputValue,
29
+ isDisabled,
30
+ isReadOnly,
31
+ isRequired,
32
+ isInvalid: _,
33
+ getInputProps,
34
+ getLabelProps,
35
+ getHelperTextProps,
36
+ getErrorMessageProps
37
+ } = useInput({
38
+ value,
39
+ defaultValue,
40
+ onChange,
41
+ disabled,
42
+ readOnly,
43
+ required,
44
+ invalid: isInvalid,
45
+ type,
46
+ placeholder,
47
+ name
48
+ });
49
+ const propGetterReturn = getInputProps();
50
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
51
+ const labelProps = getLabelProps();
52
+ const helperProps = getHelperTextProps();
53
+ const errorProps = getErrorMessageProps();
54
+ const handleChange = useCallback(
55
+ (event) => {
56
+ onChange?.(event.target.value);
57
+ },
58
+ [onChange]
59
+ );
60
+ const dataState = isInvalid ? "invalid" : isDisabled ? "disabled" : void 0;
61
+ return /* @__PURE__ */ jsxs(
62
+ "div",
63
+ {
64
+ className: cn("entropix-input-wrapper", className),
65
+ "data-state": dataState,
66
+ "data-variant": variant,
67
+ "data-size": size,
68
+ children: [
69
+ label && /* @__PURE__ */ jsxs(
70
+ "label",
71
+ {
72
+ className: "entropix-input-label",
73
+ id: labelProps.id,
74
+ htmlFor: labelProps.htmlFor,
75
+ children: [
76
+ label,
77
+ isRequired && /* @__PURE__ */ jsx("span", { className: "entropix-input-required", children: "*" })
78
+ ]
79
+ }
80
+ ),
81
+ /* @__PURE__ */ jsx(
82
+ "input",
83
+ {
84
+ ref,
85
+ className: "entropix-input",
86
+ ...ariaProps,
87
+ ...rest,
88
+ type,
89
+ name,
90
+ placeholder,
91
+ value: inputValue,
92
+ onChange: handleChange,
93
+ disabled: isDisabled || void 0,
94
+ readOnly: isReadOnly || void 0,
95
+ "data-state": dataState,
96
+ "data-variant": variant,
97
+ "data-size": size
98
+ }
99
+ ),
100
+ isInvalid && errorMessage ? /* @__PURE__ */ jsx("span", { className: "entropix-input-error", ...errorProps, children: errorMessage }) : helperText ? /* @__PURE__ */ jsx("span", { className: "entropix-input-helper", ...helperProps, children: helperText }) : null
101
+ ]
102
+ }
103
+ );
104
+ });
105
+
106
+ export { Input };
107
+ //# sourceMappingURL=chunk-664P2RGR.js.map
108
+ //# sourceMappingURL=chunk-664P2RGR.js.map
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ var chunkLDOP6DVX_cjs = require('./chunk-LDOP6DVX.cjs');
4
+ var chunkLJK6KK2H_cjs = require('./chunk-LJK6KK2H.cjs');
5
+ var chunk5DKE5YQD_cjs = require('./chunk-5DKE5YQD.cjs');
6
+ var core = require('@entropix/core');
7
+ var react = require('react');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+
10
+ var MenuContext = react.createContext(null);
11
+ function useMenuContext() {
12
+ const context = react.useContext(MenuContext);
13
+ if (!context) {
14
+ throw new Error(
15
+ "Menu compound components must be used within a <Menu> provider."
16
+ );
17
+ }
18
+ return context;
19
+ }
20
+ function Menu({ children, ...options }) {
21
+ const menu = core.useMenu(options);
22
+ return /* @__PURE__ */ jsxRuntime.jsx(MenuContext.Provider, { value: menu, children });
23
+ }
24
+ function MenuTrigger({ children, className }) {
25
+ const { getTriggerProps, toggle, open } = useMenuContext();
26
+ const propGetterReturn = getTriggerProps();
27
+ const ariaProps = chunkLJK6KK2H_cjs.mapAccessibilityToAria(propGetterReturn.accessibility);
28
+ const handleClick = react.useCallback(() => {
29
+ propGetterReturn.onAction?.();
30
+ }, [propGetterReturn.onAction]);
31
+ const onKeyDown = chunkLDOP6DVX_cjs.useKeyboardHandler(propGetterReturn.keyboardConfig, {
32
+ activate: toggle,
33
+ moveDown: open,
34
+ moveUp: open
35
+ });
36
+ return /* @__PURE__ */ jsxRuntime.jsx(
37
+ "button",
38
+ {
39
+ ...ariaProps,
40
+ className: chunk5DKE5YQD_cjs.cn("entropix-menu-trigger", className),
41
+ onClick: handleClick,
42
+ onKeyDown,
43
+ children
44
+ }
45
+ );
46
+ }
47
+ function MenuContent({ children, className }) {
48
+ const { isOpen, getMenuProps, close } = useMenuContext();
49
+ const propGetterReturn = getMenuProps();
50
+ const ariaProps = chunkLJK6KK2H_cjs.mapAccessibilityToAria(propGetterReturn.accessibility);
51
+ const onKeyDown = chunkLDOP6DVX_cjs.useKeyboardHandler(propGetterReturn.keyboardConfig, {
52
+ dismiss: close
53
+ });
54
+ if (!isOpen) return null;
55
+ return /* @__PURE__ */ jsxRuntime.jsx(
56
+ "div",
57
+ {
58
+ ...ariaProps,
59
+ className: chunk5DKE5YQD_cjs.cn("entropix-menu-content", className),
60
+ onKeyDown,
61
+ "data-state": "open",
62
+ children
63
+ }
64
+ );
65
+ }
66
+ function MenuItem({
67
+ index,
68
+ onSelect,
69
+ disabled,
70
+ children,
71
+ className
72
+ }) {
73
+ const { getItemProps, activeIndex } = useMenuContext();
74
+ const propGetterReturn = getItemProps(index, { onSelect, disabled });
75
+ const ariaProps = chunkLJK6KK2H_cjs.mapAccessibilityToAria(propGetterReturn.accessibility);
76
+ const handleClick = react.useCallback(() => {
77
+ propGetterReturn.onAction?.();
78
+ }, [propGetterReturn.onAction]);
79
+ return /* @__PURE__ */ jsxRuntime.jsx(
80
+ "div",
81
+ {
82
+ ...ariaProps,
83
+ className: chunk5DKE5YQD_cjs.cn("entropix-menu-item", className),
84
+ onClick: handleClick,
85
+ "data-state": activeIndex === index ? "active" : "inactive",
86
+ "data-disabled": disabled || void 0,
87
+ children
88
+ }
89
+ );
90
+ }
91
+
92
+ exports.Menu = Menu;
93
+ exports.MenuContent = MenuContent;
94
+ exports.MenuItem = MenuItem;
95
+ exports.MenuTrigger = MenuTrigger;
96
+ //# sourceMappingURL=chunk-6NKHMBF3.cjs.map
97
+ //# sourceMappingURL=chunk-6NKHMBF3.cjs.map
@@ -0,0 +1,8 @@
1
+ // src/utils/cn.ts
2
+ function cn(...classes) {
3
+ return classes.filter(Boolean).join(" ");
4
+ }
5
+
6
+ export { cn };
7
+ //# sourceMappingURL=chunk-6UAQCHIW.js.map
8
+ //# sourceMappingURL=chunk-6UAQCHIW.js.map
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ var chunkLDOP6DVX_cjs = require('./chunk-LDOP6DVX.cjs');
4
+ var chunkLJK6KK2H_cjs = require('./chunk-LJK6KK2H.cjs');
5
+ var chunk5DKE5YQD_cjs = require('./chunk-5DKE5YQD.cjs');
6
+ var core = require('@entropix/core');
7
+ var react = require('react');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+
10
+ var TabsContext = react.createContext(null);
11
+ function useTabsContext() {
12
+ const context = react.useContext(TabsContext);
13
+ if (!context) {
14
+ throw new Error(
15
+ "Tabs compound components must be used within a <Tabs> provider."
16
+ );
17
+ }
18
+ return context;
19
+ }
20
+ function Tabs({
21
+ children,
22
+ className,
23
+ orientation = "horizontal",
24
+ activationMode = "automatic",
25
+ ...options
26
+ }) {
27
+ const tabs = core.useTabs({ ...options, orientation, activationMode });
28
+ return /* @__PURE__ */ jsxRuntime.jsx(TabsContext.Provider, { value: { ...tabs, orientation, activationMode }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunk5DKE5YQD_cjs.cn("entropix-tabs", className), "data-orientation": orientation, children }) });
29
+ }
30
+ function TabList({ children, className }) {
31
+ const { getTabListProps } = useTabsContext();
32
+ const propGetterReturn = getTabListProps();
33
+ const ariaProps = chunkLJK6KK2H_cjs.mapAccessibilityToAria(propGetterReturn.accessibility);
34
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ...ariaProps, className: chunk5DKE5YQD_cjs.cn("entropix-tablist", className), children });
35
+ }
36
+ function Tab({ value, children, className }) {
37
+ const { getTabProps, select, selectedKey, orientation } = useTabsContext();
38
+ const propGetterReturn = getTabProps(value);
39
+ const ariaProps = chunkLJK6KK2H_cjs.mapAccessibilityToAria(propGetterReturn.accessibility);
40
+ const baseId = ariaProps["aria-controls"] ? String(ariaProps["aria-controls"]).replace(`-panel-${value}`, "") : "";
41
+ const handleClick = react.useCallback(() => {
42
+ propGetterReturn.onAction?.();
43
+ }, [propGetterReturn.onAction]);
44
+ const onKeyDown = chunkLDOP6DVX_cjs.useKeyboardHandler(propGetterReturn.keyboardConfig, {
45
+ activate: () => select(value)
46
+ });
47
+ return /* @__PURE__ */ jsxRuntime.jsx(
48
+ "button",
49
+ {
50
+ ...ariaProps,
51
+ id: `${baseId}-tab-${value}`,
52
+ className: chunk5DKE5YQD_cjs.cn("entropix-tab", className),
53
+ onClick: handleClick,
54
+ onKeyDown,
55
+ "data-state": selectedKey === value ? "active" : "inactive",
56
+ "data-orientation": orientation,
57
+ children
58
+ }
59
+ );
60
+ }
61
+ function TabPanel({ value, children, className }) {
62
+ const { getTabPanelProps, selectedKey } = useTabsContext();
63
+ const propGetterReturn = getTabPanelProps(value);
64
+ const ariaProps = chunkLJK6KK2H_cjs.mapAccessibilityToAria(propGetterReturn.accessibility);
65
+ const baseId = ariaProps["aria-labelledby"] ? String(ariaProps["aria-labelledby"]).replace(`-tab-${value}`, "") : "";
66
+ if (selectedKey !== value) return null;
67
+ return /* @__PURE__ */ jsxRuntime.jsx(
68
+ "div",
69
+ {
70
+ ...ariaProps,
71
+ id: `${baseId}-panel-${value}`,
72
+ className: chunk5DKE5YQD_cjs.cn("entropix-tabpanel", className),
73
+ "data-state": "active",
74
+ children
75
+ }
76
+ );
77
+ }
78
+
79
+ exports.Tab = Tab;
80
+ exports.TabList = TabList;
81
+ exports.TabPanel = TabPanel;
82
+ exports.Tabs = Tabs;
83
+ //# sourceMappingURL=chunk-7AUIZOEH.cjs.map
84
+ //# sourceMappingURL=chunk-7AUIZOEH.cjs.map
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=chunk-AVCBDUKH.js.map
3
+ //# sourceMappingURL=chunk-AVCBDUKH.js.map
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ var chunkLDOP6DVX_cjs = require('./chunk-LDOP6DVX.cjs');
4
+ var chunkLJK6KK2H_cjs = require('./chunk-LJK6KK2H.cjs');
5
+ var chunk5DKE5YQD_cjs = require('./chunk-5DKE5YQD.cjs');
6
+ var react = require('react');
7
+ var core = require('@entropix/core');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+
10
+ var Toggle = react.forwardRef(
11
+ function Toggle2(props, ref) {
12
+ return /* @__PURE__ */ jsxRuntime.jsx(ToggleInner, { ...props, ref, role: "checkbox", componentClass: "entropix-toggle" });
13
+ }
14
+ );
15
+ var ToggleInner = react.forwardRef(
16
+ function ToggleInner2({
17
+ checked,
18
+ defaultChecked,
19
+ onChange,
20
+ disabled,
21
+ label,
22
+ role = "checkbox",
23
+ componentClass = "entropix-toggle",
24
+ className,
25
+ style,
26
+ children,
27
+ onClick,
28
+ onKeyDown: externalOnKeyDown,
29
+ ...rest
30
+ }, ref) {
31
+ const { isChecked, isDisabled, getToggleProps } = core.useToggle({
32
+ checked,
33
+ defaultChecked,
34
+ onChange,
35
+ disabled,
36
+ role
37
+ });
38
+ const propGetterReturn = getToggleProps();
39
+ const ariaProps = chunkLJK6KK2H_cjs.mapAccessibilityToAria(propGetterReturn.accessibility);
40
+ if (label && !children) {
41
+ ariaProps["aria-label"] = label;
42
+ }
43
+ const actionMap = react.useMemo(
44
+ () => ({
45
+ toggle: propGetterReturn.onAction ?? (() => {
46
+ })
47
+ }),
48
+ [propGetterReturn.onAction]
49
+ );
50
+ const onKeyDown = chunkLDOP6DVX_cjs.useKeyboardHandler(
51
+ propGetterReturn.keyboardConfig,
52
+ actionMap
53
+ );
54
+ const handleClick = react.useCallback(
55
+ (event) => {
56
+ propGetterReturn.onAction?.();
57
+ onClick?.(event);
58
+ },
59
+ [propGetterReturn.onAction, onClick]
60
+ );
61
+ const handleKeyDown = react.useCallback(
62
+ (event) => {
63
+ onKeyDown?.(event);
64
+ externalOnKeyDown?.(event);
65
+ },
66
+ [onKeyDown, externalOnKeyDown]
67
+ );
68
+ return /* @__PURE__ */ jsxRuntime.jsx(
69
+ "button",
70
+ {
71
+ ref,
72
+ type: "button",
73
+ className: chunk5DKE5YQD_cjs.cn(componentClass, className),
74
+ style,
75
+ ...ariaProps,
76
+ ...rest,
77
+ disabled: isDisabled || void 0,
78
+ onClick: propGetterReturn.onAction || onClick ? handleClick : void 0,
79
+ onKeyDown: onKeyDown || externalOnKeyDown ? handleKeyDown : void 0,
80
+ "data-state": isChecked ? "checked" : "unchecked",
81
+ children: children ?? label ?? (isChecked ? "On" : "Off")
82
+ }
83
+ );
84
+ }
85
+ );
86
+
87
+ exports.Toggle = Toggle;
88
+ exports.ToggleInner = ToggleInner;
89
+ //# sourceMappingURL=chunk-B5JZHE4I.cjs.map
90
+ //# sourceMappingURL=chunk-B5JZHE4I.cjs.map
@@ -0,0 +1,26 @@
1
+ import { useCallback } from 'react';
2
+
3
+ // src/utils/use-keyboard-handler.ts
4
+ function useKeyboardHandler(keyboardConfig, actionMap) {
5
+ const handler = useCallback(
6
+ (event) => {
7
+ if (!keyboardConfig) return;
8
+ const intent = keyboardConfig.getIntent(event.key, {
9
+ shift: event.shiftKey,
10
+ meta: event.metaKey,
11
+ alt: event.altKey
12
+ });
13
+ if (intent && actionMap[intent]) {
14
+ event.preventDefault();
15
+ actionMap[intent]();
16
+ }
17
+ },
18
+ [keyboardConfig, actionMap]
19
+ );
20
+ if (!keyboardConfig) return void 0;
21
+ return handler;
22
+ }
23
+
24
+ export { useKeyboardHandler };
25
+ //# sourceMappingURL=chunk-BN57JPKV.js.map
26
+ //# sourceMappingURL=chunk-BN57JPKV.js.map
@@ -0,0 +1,114 @@
1
+ import { useKeyboardHandler } from './chunk-BN57JPKV.js';
2
+ import { mapAccessibilityToAria } from './chunk-Y2M2LJGJ.js';
3
+ import { cn } from './chunk-6UAQCHIW.js';
4
+ import { useSelect } from '@entropix/core';
5
+ import { createContext, useCallback, useContext } from 'react';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
+
8
+ var SelectContext = createContext(null);
9
+ function useSelectContext() {
10
+ const context = useContext(SelectContext);
11
+ if (!context) {
12
+ throw new Error(
13
+ "Select compound components must be used within a <Select> provider."
14
+ );
15
+ }
16
+ return context;
17
+ }
18
+ function Select({ children, label, className, ...options }) {
19
+ const select = useSelect(options);
20
+ const labelProps = select.getLabelProps();
21
+ return /* @__PURE__ */ jsx(SelectContext.Provider, { value: select, children: /* @__PURE__ */ jsxs("div", { className: cn("entropix-select", className), children: [
22
+ label && /* @__PURE__ */ jsx(
23
+ "label",
24
+ {
25
+ className: "entropix-select-label",
26
+ id: labelProps.id,
27
+ htmlFor: labelProps.htmlFor,
28
+ children: label
29
+ }
30
+ ),
31
+ children
32
+ ] }) });
33
+ }
34
+ function SelectTrigger({
35
+ placeholder = "Select...",
36
+ children,
37
+ className
38
+ }) {
39
+ const { getTriggerProps, toggle, open, selectedValue, isDisabled } = useSelectContext();
40
+ const propGetterReturn = getTriggerProps();
41
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
42
+ const handleClick = useCallback(() => {
43
+ propGetterReturn.onAction?.();
44
+ }, [propGetterReturn.onAction]);
45
+ const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
46
+ activate: toggle,
47
+ moveDown: open,
48
+ moveUp: open
49
+ });
50
+ return /* @__PURE__ */ jsxs(
51
+ "button",
52
+ {
53
+ type: "button",
54
+ ...ariaProps,
55
+ className: cn("entropix-select-trigger", className),
56
+ onClick: handleClick,
57
+ onKeyDown,
58
+ disabled: isDisabled || void 0,
59
+ children: [
60
+ /* @__PURE__ */ jsx("span", { className: "entropix-select-trigger__value", children: children ?? (selectedValue || placeholder) }),
61
+ /* @__PURE__ */ jsx("span", { className: "entropix-select-trigger__chevron", "aria-hidden": "true", children: "\u25BE" })
62
+ ]
63
+ }
64
+ );
65
+ }
66
+ function SelectContent({ children, className }) {
67
+ const { isOpen, getListboxProps, close } = useSelectContext();
68
+ const propGetterReturn = getListboxProps();
69
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
70
+ const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
71
+ dismiss: close
72
+ });
73
+ if (!isOpen) return null;
74
+ return /* @__PURE__ */ jsx(
75
+ "div",
76
+ {
77
+ ...ariaProps,
78
+ className: cn("entropix-select-content", className),
79
+ onKeyDown,
80
+ "data-state": "open",
81
+ children
82
+ }
83
+ );
84
+ }
85
+ function SelectOption({
86
+ value,
87
+ index,
88
+ disabled,
89
+ children,
90
+ className
91
+ }) {
92
+ const { getOptionProps, selectedValue } = useSelectContext();
93
+ const propGetterReturn = getOptionProps(value, index ?? 0, { disabled });
94
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
95
+ const isSelected = value === selectedValue;
96
+ const handleClick = useCallback(() => {
97
+ propGetterReturn.onAction?.();
98
+ }, [propGetterReturn.onAction]);
99
+ return /* @__PURE__ */ jsx(
100
+ "div",
101
+ {
102
+ ...ariaProps,
103
+ className: cn("entropix-select-option", className),
104
+ onClick: handleClick,
105
+ "data-state": isSelected ? "selected" : "unselected",
106
+ "data-disabled": disabled || void 0,
107
+ children
108
+ }
109
+ );
110
+ }
111
+
112
+ export { Select, SelectContent, SelectOption, SelectTrigger };
113
+ //# sourceMappingURL=chunk-BY4E26CV.js.map
114
+ //# sourceMappingURL=chunk-BY4E26CV.js.map