@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,91 @@
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 RadioContext = react.createContext(null);
11
+ function useRadioContext() {
12
+ const context = react.useContext(RadioContext);
13
+ if (!context) {
14
+ throw new Error(
15
+ "Radio compound components must be used within a <RadioGroup> provider."
16
+ );
17
+ }
18
+ return context;
19
+ }
20
+ function RadioGroup({
21
+ children,
22
+ label,
23
+ className,
24
+ ...options
25
+ }) {
26
+ const radioGroup = core.useRadioGroup(options);
27
+ const propGetterReturn = radioGroup.getRadioGroupProps();
28
+ const ariaProps = chunkLJK6KK2H_cjs.mapAccessibilityToAria(propGetterReturn.accessibility);
29
+ if (label) {
30
+ ariaProps["aria-label"] = label;
31
+ }
32
+ return /* @__PURE__ */ jsxRuntime.jsx(RadioContext.Provider, { value: radioGroup, children: /* @__PURE__ */ jsxRuntime.jsx(
33
+ "div",
34
+ {
35
+ ...ariaProps,
36
+ className: chunk5DKE5YQD_cjs.cn("entropix-radio-group", className),
37
+ "data-orientation": options.orientation ?? "vertical",
38
+ children
39
+ }
40
+ ) });
41
+ }
42
+ function RadioItem({
43
+ value,
44
+ disabled,
45
+ label,
46
+ children,
47
+ className
48
+ }) {
49
+ const { getRadioProps, selectedValue } = useRadioContext();
50
+ const propGetterReturn = getRadioProps(value, { disabled });
51
+ const ariaProps = chunkLJK6KK2H_cjs.mapAccessibilityToAria(propGetterReturn.accessibility);
52
+ const isChecked = value === selectedValue;
53
+ const actionMap = react.useMemo(
54
+ () => ({}),
55
+ []
56
+ );
57
+ const onKeyDown = chunkLDOP6DVX_cjs.useKeyboardHandler(
58
+ propGetterReturn.keyboardConfig,
59
+ actionMap
60
+ );
61
+ const handleClick = react.useCallback(() => {
62
+ propGetterReturn.onAction?.();
63
+ }, [propGetterReturn.onAction]);
64
+ return /* @__PURE__ */ jsxRuntime.jsxs(
65
+ "button",
66
+ {
67
+ type: "button",
68
+ ...ariaProps,
69
+ className: chunk5DKE5YQD_cjs.cn("entropix-radio-item", className),
70
+ onClick: handleClick,
71
+ onKeyDown,
72
+ "data-state": isChecked ? "checked" : "unchecked",
73
+ "data-disabled": disabled || void 0,
74
+ children: [
75
+ /* @__PURE__ */ jsxRuntime.jsx(
76
+ "span",
77
+ {
78
+ className: "entropix-radio-item__indicator",
79
+ "data-state": isChecked ? "checked" : "unchecked"
80
+ }
81
+ ),
82
+ (label || children) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "entropix-radio-item__label", children: label || children })
83
+ ]
84
+ }
85
+ );
86
+ }
87
+
88
+ exports.RadioGroup = RadioGroup;
89
+ exports.RadioItem = RadioItem;
90
+ //# sourceMappingURL=chunk-KGIUECLG.cjs.map
91
+ //# sourceMappingURL=chunk-KGIUECLG.cjs.map
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+
5
+ // src/utils/use-keyboard-handler.ts
6
+ function useKeyboardHandler(keyboardConfig, actionMap) {
7
+ const handler = react.useCallback(
8
+ (event) => {
9
+ if (!keyboardConfig) return;
10
+ const intent = keyboardConfig.getIntent(event.key, {
11
+ shift: event.shiftKey,
12
+ meta: event.metaKey,
13
+ alt: event.altKey
14
+ });
15
+ if (intent && actionMap[intent]) {
16
+ event.preventDefault();
17
+ actionMap[intent]();
18
+ }
19
+ },
20
+ [keyboardConfig, actionMap]
21
+ );
22
+ if (!keyboardConfig) return void 0;
23
+ return handler;
24
+ }
25
+
26
+ exports.useKeyboardHandler = useKeyboardHandler;
27
+ //# sourceMappingURL=chunk-LDOP6DVX.cjs.map
28
+ //# sourceMappingURL=chunk-LDOP6DVX.cjs.map
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ // src/utils/map-accessibility-to-aria.ts
4
+ var ARIA_MAP = {
5
+ role: "role",
6
+ label: "aria-label",
7
+ labelledBy: "aria-labelledby",
8
+ describedBy: "aria-describedby",
9
+ disabled: "aria-disabled",
10
+ expanded: "aria-expanded",
11
+ selected: "aria-selected",
12
+ checked: "aria-checked",
13
+ pressed: "aria-pressed",
14
+ busy: "aria-busy",
15
+ modal: "aria-modal",
16
+ hasPopup: "aria-haspopup",
17
+ controls: "aria-controls",
18
+ owns: "aria-owns",
19
+ live: "aria-live",
20
+ orientation: "aria-orientation",
21
+ tabIndex: "tabIndex",
22
+ hidden: "aria-hidden",
23
+ valueNow: "aria-valuenow",
24
+ valueMin: "aria-valuemin",
25
+ valueMax: "aria-valuemax",
26
+ valueText: "aria-valuetext",
27
+ required: "aria-required",
28
+ invalid: "aria-invalid"
29
+ };
30
+ function mapAccessibilityToAria(props) {
31
+ const result = {};
32
+ for (const [key, attrName] of Object.entries(ARIA_MAP)) {
33
+ const value = props[key];
34
+ if (value !== void 0) {
35
+ result[attrName] = value;
36
+ }
37
+ }
38
+ return result;
39
+ }
40
+
41
+ exports.mapAccessibilityToAria = mapAccessibilityToAria;
42
+ //# sourceMappingURL=chunk-LJK6KK2H.cjs.map
43
+ //# sourceMappingURL=chunk-LJK6KK2H.cjs.map
@@ -0,0 +1,84 @@
1
+ import { useKeyboardHandler } from './chunk-BN57JPKV.js';
2
+ import { mapAccessibilityToAria } from './chunk-Y2M2LJGJ.js';
3
+ import { cn } from './chunk-6UAQCHIW.js';
4
+ import { forwardRef, useMemo, useCallback } from 'react';
5
+ import { useButton } from '@entropix/core';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ var Button = forwardRef(function Button2({
9
+ disabled,
10
+ loading,
11
+ onPress,
12
+ as: Component = "button",
13
+ variant,
14
+ size,
15
+ className,
16
+ style,
17
+ children,
18
+ onClick,
19
+ onKeyDown: externalOnKeyDown,
20
+ ...rest
21
+ }, ref) {
22
+ const elementType = typeof Component === "string" ? Component : "div";
23
+ const { isDisabled, isLoading, getButtonProps } = useButton({
24
+ disabled,
25
+ loading,
26
+ onPress,
27
+ elementType
28
+ });
29
+ const propGetterReturn = getButtonProps();
30
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
31
+ const actionMap = useMemo(
32
+ () => ({
33
+ activate: propGetterReturn.onAction ?? (() => {
34
+ })
35
+ }),
36
+ [propGetterReturn.onAction]
37
+ );
38
+ const onKeyDown = useKeyboardHandler(
39
+ propGetterReturn.keyboardConfig,
40
+ actionMap
41
+ );
42
+ const handleClick = useCallback(
43
+ (event) => {
44
+ propGetterReturn.onAction?.();
45
+ onClick?.(event);
46
+ },
47
+ [propGetterReturn.onAction, onClick]
48
+ );
49
+ const handleKeyDown = useCallback(
50
+ (event) => {
51
+ onKeyDown?.(event);
52
+ externalOnKeyDown?.(event);
53
+ },
54
+ [onKeyDown, externalOnKeyDown]
55
+ );
56
+ const dataState = isLoading ? "loading" : isDisabled ? "disabled" : void 0;
57
+ return /* @__PURE__ */ jsx(
58
+ Component,
59
+ {
60
+ ref,
61
+ className: cn(
62
+ "entropix-button",
63
+ variant && `entropix-button--${variant}`,
64
+ size && `entropix-button--${size}`,
65
+ className
66
+ ),
67
+ style,
68
+ ...ariaProps,
69
+ ...rest,
70
+ type: Component === "button" ? "button" : void 0,
71
+ disabled: Component === "button" && isDisabled ? true : void 0,
72
+ onClick: propGetterReturn.onAction || onClick ? handleClick : void 0,
73
+ onKeyDown: onKeyDown || externalOnKeyDown ? handleKeyDown : void 0,
74
+ "data-state": dataState,
75
+ "data-variant": variant,
76
+ "data-size": size,
77
+ children
78
+ }
79
+ );
80
+ });
81
+
82
+ export { Button };
83
+ //# sourceMappingURL=chunk-OT2HJUCB.js.map
84
+ //# sourceMappingURL=chunk-OT2HJUCB.js.map
@@ -0,0 +1,87 @@
1
+ import { useKeyboardHandler } from './chunk-BN57JPKV.js';
2
+ import { mapAccessibilityToAria } from './chunk-Y2M2LJGJ.js';
3
+ import { cn } from './chunk-6UAQCHIW.js';
4
+ import { forwardRef, useMemo, useCallback } from 'react';
5
+ import { useToggle } from '@entropix/core';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ var Toggle = forwardRef(
9
+ function Toggle2(props, ref) {
10
+ return /* @__PURE__ */ jsx(ToggleInner, { ...props, ref, role: "checkbox", componentClass: "entropix-toggle" });
11
+ }
12
+ );
13
+ var ToggleInner = forwardRef(
14
+ function ToggleInner2({
15
+ checked,
16
+ defaultChecked,
17
+ onChange,
18
+ disabled,
19
+ label,
20
+ role = "checkbox",
21
+ componentClass = "entropix-toggle",
22
+ className,
23
+ style,
24
+ children,
25
+ onClick,
26
+ onKeyDown: externalOnKeyDown,
27
+ ...rest
28
+ }, ref) {
29
+ const { isChecked, isDisabled, getToggleProps } = useToggle({
30
+ checked,
31
+ defaultChecked,
32
+ onChange,
33
+ disabled,
34
+ role
35
+ });
36
+ const propGetterReturn = getToggleProps();
37
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
38
+ if (label && !children) {
39
+ ariaProps["aria-label"] = label;
40
+ }
41
+ const actionMap = useMemo(
42
+ () => ({
43
+ toggle: propGetterReturn.onAction ?? (() => {
44
+ })
45
+ }),
46
+ [propGetterReturn.onAction]
47
+ );
48
+ const onKeyDown = useKeyboardHandler(
49
+ propGetterReturn.keyboardConfig,
50
+ actionMap
51
+ );
52
+ const handleClick = useCallback(
53
+ (event) => {
54
+ propGetterReturn.onAction?.();
55
+ onClick?.(event);
56
+ },
57
+ [propGetterReturn.onAction, onClick]
58
+ );
59
+ const handleKeyDown = useCallback(
60
+ (event) => {
61
+ onKeyDown?.(event);
62
+ externalOnKeyDown?.(event);
63
+ },
64
+ [onKeyDown, externalOnKeyDown]
65
+ );
66
+ return /* @__PURE__ */ jsx(
67
+ "button",
68
+ {
69
+ ref,
70
+ type: "button",
71
+ className: cn(componentClass, className),
72
+ style,
73
+ ...ariaProps,
74
+ ...rest,
75
+ disabled: isDisabled || void 0,
76
+ onClick: propGetterReturn.onAction || onClick ? handleClick : void 0,
77
+ onKeyDown: onKeyDown || externalOnKeyDown ? handleKeyDown : void 0,
78
+ "data-state": isChecked ? "checked" : "unchecked",
79
+ children: children ?? label ?? (isChecked ? "On" : "Off")
80
+ }
81
+ );
82
+ }
83
+ );
84
+
85
+ export { Toggle, ToggleInner };
86
+ //# sourceMappingURL=chunk-PILZGMQG.js.map
87
+ //# sourceMappingURL=chunk-PILZGMQG.js.map
@@ -0,0 +1,92 @@
1
+ import { useKeyboardHandler } from './chunk-BN57JPKV.js';
2
+ import { mapAccessibilityToAria } from './chunk-Y2M2LJGJ.js';
3
+ import { cn } from './chunk-6UAQCHIW.js';
4
+ import { useMenu } from '@entropix/core';
5
+ import { createContext, useCallback, useContext } from 'react';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ var MenuContext = createContext(null);
9
+ function useMenuContext() {
10
+ const context = useContext(MenuContext);
11
+ if (!context) {
12
+ throw new Error(
13
+ "Menu compound components must be used within a <Menu> provider."
14
+ );
15
+ }
16
+ return context;
17
+ }
18
+ function Menu({ children, ...options }) {
19
+ const menu = useMenu(options);
20
+ return /* @__PURE__ */ jsx(MenuContext.Provider, { value: menu, children });
21
+ }
22
+ function MenuTrigger({ children, className }) {
23
+ const { getTriggerProps, toggle, open } = useMenuContext();
24
+ const propGetterReturn = getTriggerProps();
25
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
26
+ const handleClick = useCallback(() => {
27
+ propGetterReturn.onAction?.();
28
+ }, [propGetterReturn.onAction]);
29
+ const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
30
+ activate: toggle,
31
+ moveDown: open,
32
+ moveUp: open
33
+ });
34
+ return /* @__PURE__ */ jsx(
35
+ "button",
36
+ {
37
+ ...ariaProps,
38
+ className: cn("entropix-menu-trigger", className),
39
+ onClick: handleClick,
40
+ onKeyDown,
41
+ children
42
+ }
43
+ );
44
+ }
45
+ function MenuContent({ children, className }) {
46
+ const { isOpen, getMenuProps, close } = useMenuContext();
47
+ const propGetterReturn = getMenuProps();
48
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
49
+ const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
50
+ dismiss: close
51
+ });
52
+ if (!isOpen) return null;
53
+ return /* @__PURE__ */ jsx(
54
+ "div",
55
+ {
56
+ ...ariaProps,
57
+ className: cn("entropix-menu-content", className),
58
+ onKeyDown,
59
+ "data-state": "open",
60
+ children
61
+ }
62
+ );
63
+ }
64
+ function MenuItem({
65
+ index,
66
+ onSelect,
67
+ disabled,
68
+ children,
69
+ className
70
+ }) {
71
+ const { getItemProps, activeIndex } = useMenuContext();
72
+ const propGetterReturn = getItemProps(index, { onSelect, disabled });
73
+ const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
74
+ const handleClick = useCallback(() => {
75
+ propGetterReturn.onAction?.();
76
+ }, [propGetterReturn.onAction]);
77
+ return /* @__PURE__ */ jsx(
78
+ "div",
79
+ {
80
+ ...ariaProps,
81
+ className: cn("entropix-menu-item", className),
82
+ onClick: handleClick,
83
+ "data-state": activeIndex === index ? "active" : "inactive",
84
+ "data-disabled": disabled || void 0,
85
+ children
86
+ }
87
+ );
88
+ }
89
+
90
+ export { Menu, MenuContent, MenuItem, MenuTrigger };
91
+ //# sourceMappingURL=chunk-PN42JF6U.js.map
92
+ //# sourceMappingURL=chunk-PN42JF6U.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 Checkbox = react.forwardRef(
11
+ function Checkbox2({
12
+ checked,
13
+ defaultChecked,
14
+ onChange,
15
+ disabled,
16
+ label,
17
+ indeterminate = false,
18
+ className,
19
+ style,
20
+ children,
21
+ onClick,
22
+ onKeyDown: externalOnKeyDown,
23
+ ...rest
24
+ }, ref) {
25
+ const { isChecked, isDisabled, getToggleProps } = core.useToggle({
26
+ checked,
27
+ defaultChecked,
28
+ onChange,
29
+ disabled,
30
+ role: "checkbox"
31
+ });
32
+ const propGetterReturn = getToggleProps();
33
+ const ariaProps = chunkLJK6KK2H_cjs.mapAccessibilityToAria(propGetterReturn.accessibility);
34
+ if (indeterminate) {
35
+ ariaProps["aria-checked"] = "mixed";
36
+ }
37
+ if (label && !children) {
38
+ ariaProps["aria-label"] = label;
39
+ }
40
+ const actionMap = react.useMemo(
41
+ () => ({
42
+ toggle: propGetterReturn.onAction ?? (() => {
43
+ })
44
+ }),
45
+ [propGetterReturn.onAction]
46
+ );
47
+ const onKeyDown = chunkLDOP6DVX_cjs.useKeyboardHandler(
48
+ propGetterReturn.keyboardConfig,
49
+ actionMap
50
+ );
51
+ const handleClick = react.useCallback(
52
+ (event) => {
53
+ propGetterReturn.onAction?.();
54
+ onClick?.(event);
55
+ },
56
+ [propGetterReturn.onAction, onClick]
57
+ );
58
+ const handleKeyDown = react.useCallback(
59
+ (event) => {
60
+ onKeyDown?.(event);
61
+ externalOnKeyDown?.(event);
62
+ },
63
+ [onKeyDown, externalOnKeyDown]
64
+ );
65
+ const dataState = indeterminate ? "indeterminate" : isChecked ? "checked" : "unchecked";
66
+ return /* @__PURE__ */ jsxRuntime.jsxs(
67
+ "button",
68
+ {
69
+ ref,
70
+ type: "button",
71
+ className: chunk5DKE5YQD_cjs.cn("entropix-checkbox", className),
72
+ style,
73
+ ...ariaProps,
74
+ ...rest,
75
+ disabled: isDisabled || void 0,
76
+ onClick: propGetterReturn.onAction || onClick ? handleClick : void 0,
77
+ onKeyDown: onKeyDown || externalOnKeyDown ? handleKeyDown : void 0,
78
+ "data-state": dataState,
79
+ children: [
80
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "entropix-checkbox__indicator", "data-state": dataState }),
81
+ (label || children) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "entropix-checkbox__label", children: label || children })
82
+ ]
83
+ }
84
+ );
85
+ }
86
+ );
87
+
88
+ exports.Checkbox = Checkbox;
89
+ //# sourceMappingURL=chunk-RPIYYBFJ.cjs.map
90
+ //# sourceMappingURL=chunk-RPIYYBFJ.cjs.map