@entropix/react-native 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 (93) hide show
  1. package/dist/accordion.cjs +26 -0
  2. package/dist/accordion.d.cts +34 -0
  3. package/dist/accordion.d.ts +34 -0
  4. package/dist/accordion.js +5 -0
  5. package/dist/button.cjs +14 -0
  6. package/dist/button.d.cts +35 -0
  7. package/dist/button.d.ts +35 -0
  8. package/dist/button.js +5 -0
  9. package/dist/checkbox.cjs +14 -0
  10. package/dist/checkbox.d.cts +41 -0
  11. package/dist/checkbox.d.ts +41 -0
  12. package/dist/checkbox.js +5 -0
  13. package/dist/chunk-2SQB7RNT.cjs +110 -0
  14. package/dist/chunk-3MHE2C74.js +143 -0
  15. package/dist/chunk-45KMMZUT.js +131 -0
  16. package/dist/chunk-64DK6YFL.js +164 -0
  17. package/dist/chunk-73BDGPZT.js +89 -0
  18. package/dist/chunk-B5YFEA66.cjs +243 -0
  19. package/dist/chunk-BOUIB4OY.cjs +56 -0
  20. package/dist/chunk-C6HF6QXK.js +154 -0
  21. package/dist/chunk-CXQNNEPC.js +249 -0
  22. package/dist/chunk-EFRYMWJB.js +86 -0
  23. package/dist/chunk-FQUZIDVS.cjs +174 -0
  24. package/dist/chunk-G7WPUTB6.cjs +258 -0
  25. package/dist/chunk-HH3CEDSH.js +122 -0
  26. package/dist/chunk-IRQWSFCZ.cjs +156 -0
  27. package/dist/chunk-KU24A5PQ.js +92 -0
  28. package/dist/chunk-OMKUPSHJ.cjs +95 -0
  29. package/dist/chunk-P5NAXMSC.cjs +91 -0
  30. package/dist/chunk-PKDXWKLO.cjs +245 -0
  31. package/dist/chunk-PVTPOJRU.js +155 -0
  32. package/dist/chunk-Q7TEJ62Q.cjs +160 -0
  33. package/dist/chunk-THX22NZW.cjs +146 -0
  34. package/dist/chunk-UHVTF2Y4.js +172 -0
  35. package/dist/chunk-UYXJHKYK.cjs +166 -0
  36. package/dist/chunk-VP567WZL.js +237 -0
  37. package/dist/chunk-XBNX4SLA.js +105 -0
  38. package/dist/chunk-XND7AIKO.cjs +133 -0
  39. package/dist/chunk-XSOLJOBG.js +238 -0
  40. package/dist/chunk-Z2MBHXUQ.cjs +127 -0
  41. package/dist/chunk-ZPAOLIIG.cjs +88 -0
  42. package/dist/chunk-ZYOTKLBG.js +52 -0
  43. package/dist/dialog.cjs +38 -0
  44. package/dist/dialog.d.cts +83 -0
  45. package/dist/dialog.d.ts +83 -0
  46. package/dist/dialog.js +5 -0
  47. package/dist/index.cjs +187 -2063
  48. package/dist/index.d.cts +21 -651
  49. package/dist/index.d.ts +21 -651
  50. package/dist/index.js +15 -2025
  51. package/dist/input.cjs +14 -0
  52. package/dist/input.d.cts +57 -0
  53. package/dist/input.d.ts +57 -0
  54. package/dist/input.js +5 -0
  55. package/dist/layout.cjs +25 -0
  56. package/dist/layout.d.cts +108 -0
  57. package/dist/layout.d.ts +108 -0
  58. package/dist/layout.js +4 -0
  59. package/dist/menu.cjs +26 -0
  60. package/dist/menu.d.cts +34 -0
  61. package/dist/menu.d.ts +34 -0
  62. package/dist/menu.js +5 -0
  63. package/dist/radio.cjs +18 -0
  64. package/dist/radio.d.cts +55 -0
  65. package/dist/radio.d.ts +55 -0
  66. package/dist/radio.js +5 -0
  67. package/dist/select.cjs +26 -0
  68. package/dist/select.d.cts +86 -0
  69. package/dist/select.d.ts +86 -0
  70. package/dist/select.js +5 -0
  71. package/dist/switch.cjs +14 -0
  72. package/dist/switch.d.cts +27 -0
  73. package/dist/switch.d.ts +27 -0
  74. package/dist/switch.js +5 -0
  75. package/dist/tabs.cjs +26 -0
  76. package/dist/tabs.d.cts +33 -0
  77. package/dist/tabs.d.ts +33 -0
  78. package/dist/tabs.js +5 -0
  79. package/dist/textarea.cjs +14 -0
  80. package/dist/textarea.d.cts +55 -0
  81. package/dist/textarea.d.ts +55 -0
  82. package/dist/textarea.js +5 -0
  83. package/dist/theme.cjs +20 -0
  84. package/dist/theme.d.cts +59 -0
  85. package/dist/theme.d.ts +59 -0
  86. package/dist/theme.js +3 -0
  87. package/dist/toggle.cjs +18 -0
  88. package/dist/toggle.d.cts +41 -0
  89. package/dist/toggle.d.ts +41 -0
  90. package/dist/toggle.js +5 -0
  91. package/package.json +146 -4
  92. package/dist/index.cjs.map +0 -1
  93. package/dist/index.js.map +0 -1
@@ -0,0 +1,258 @@
1
+ 'use strict';
2
+
3
+ var chunkBOUIB4OY_cjs = require('./chunk-BOUIB4OY.cjs');
4
+ var reactNative = require('react-native');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var react = require('react');
7
+
8
+ function Stack({
9
+ gap,
10
+ align,
11
+ fullWidth,
12
+ style,
13
+ children,
14
+ ...rest
15
+ }) {
16
+ const { baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
17
+ const gapValue = getGapValue(gap, bt);
18
+ const alignMap = {
19
+ start: "flex-start",
20
+ center: "center",
21
+ end: "flex-end",
22
+ stretch: "stretch"
23
+ };
24
+ return /* @__PURE__ */ jsxRuntime.jsx(
25
+ reactNative.View,
26
+ {
27
+ style: [
28
+ { flexDirection: "column" },
29
+ gapValue !== void 0 && { gap: gapValue },
30
+ gapValue === void 0 && { gap: bt.entropixSpaceLayoutStack },
31
+ align && { alignItems: alignMap[align] },
32
+ fullWidth && { width: "100%" },
33
+ style
34
+ ],
35
+ ...rest,
36
+ children
37
+ }
38
+ );
39
+ }
40
+ function getGapValue(gap, bt) {
41
+ if (!gap) return void 0;
42
+ switch (gap) {
43
+ case "none":
44
+ return 0;
45
+ case "xs":
46
+ return bt.entropixSpacing1;
47
+ case "sm":
48
+ return bt.entropixSpacing2;
49
+ case "md":
50
+ return bt.entropixSpacing4;
51
+ case "lg":
52
+ return bt.entropixSpacing6;
53
+ case "xl":
54
+ return bt.entropixSpacing8;
55
+ case "2xl":
56
+ return bt.entropixSpacing12;
57
+ }
58
+ }
59
+ function Inline({
60
+ gap,
61
+ align,
62
+ justify,
63
+ wrap,
64
+ style,
65
+ children,
66
+ ...rest
67
+ }) {
68
+ const { baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
69
+ const gapValue = getGapValue2(gap, bt);
70
+ const alignMap = {
71
+ start: "flex-start",
72
+ center: "center",
73
+ end: "flex-end",
74
+ stretch: "stretch",
75
+ baseline: "baseline"
76
+ };
77
+ const justifyMap = {
78
+ start: "flex-start",
79
+ center: "center",
80
+ end: "flex-end",
81
+ between: "space-between",
82
+ around: "space-around"
83
+ };
84
+ return /* @__PURE__ */ jsxRuntime.jsx(
85
+ reactNative.View,
86
+ {
87
+ style: [
88
+ {
89
+ flexDirection: "row",
90
+ alignItems: "center"
91
+ },
92
+ gapValue !== void 0 && { gap: gapValue },
93
+ gapValue === void 0 && { gap: bt.entropixSpaceLayoutInline },
94
+ align && { alignItems: alignMap[align] },
95
+ justify && { justifyContent: justifyMap[justify] },
96
+ wrap && { flexWrap: "wrap" },
97
+ style
98
+ ],
99
+ ...rest,
100
+ children
101
+ }
102
+ );
103
+ }
104
+ function getGapValue2(gap, bt) {
105
+ if (!gap) return void 0;
106
+ switch (gap) {
107
+ case "none":
108
+ return 0;
109
+ case "xs":
110
+ return bt.entropixSpacing1;
111
+ case "sm":
112
+ return bt.entropixSpacing2;
113
+ case "md":
114
+ return bt.entropixSpacing4;
115
+ case "lg":
116
+ return bt.entropixSpacing6;
117
+ case "xl":
118
+ return bt.entropixSpacing8;
119
+ case "2xl":
120
+ return bt.entropixSpacing12;
121
+ }
122
+ }
123
+ var BREAKPOINTS = {
124
+ sm: 640,
125
+ md: 768,
126
+ lg: 1024,
127
+ xl: 1280,
128
+ "2xl": 1536
129
+ };
130
+ var BREAKPOINT_ORDER = ["base", "sm", "md", "lg", "xl", "2xl"];
131
+ function useBreakpoint() {
132
+ const getBreakpoint = react.useCallback(() => {
133
+ const { width } = reactNative.Dimensions.get("window");
134
+ if (width >= BREAKPOINTS["2xl"]) return "2xl";
135
+ if (width >= BREAKPOINTS.xl) return "xl";
136
+ if (width >= BREAKPOINTS.lg) return "lg";
137
+ if (width >= BREAKPOINTS.md) return "md";
138
+ if (width >= BREAKPOINTS.sm) return "sm";
139
+ return "base";
140
+ }, []);
141
+ const [breakpoint, setBreakpoint] = react.useState(getBreakpoint);
142
+ react.useEffect(() => {
143
+ const subscription = reactNative.Dimensions.addEventListener("change", ({ window }) => {
144
+ const width = window.width;
145
+ let next = "base";
146
+ if (width >= BREAKPOINTS["2xl"]) next = "2xl";
147
+ else if (width >= BREAKPOINTS.xl) next = "xl";
148
+ else if (width >= BREAKPOINTS.lg) next = "lg";
149
+ else if (width >= BREAKPOINTS.md) next = "md";
150
+ else if (width >= BREAKPOINTS.sm) next = "sm";
151
+ setBreakpoint((prev) => prev !== next ? next : prev);
152
+ });
153
+ return () => subscription.remove();
154
+ }, []);
155
+ return breakpoint;
156
+ }
157
+ function useBreakpointValue(breakpoint) {
158
+ const current = useBreakpoint();
159
+ const currentIndex = BREAKPOINT_ORDER.indexOf(current);
160
+ const targetIndex = BREAKPOINT_ORDER.indexOf(breakpoint);
161
+ return currentIndex >= targetIndex;
162
+ }
163
+ function useScreenDimensions() {
164
+ const [dimensions, setDimensions] = react.useState(() => reactNative.Dimensions.get("window"));
165
+ react.useEffect(() => {
166
+ const subscription = reactNative.Dimensions.addEventListener("change", ({ window }) => {
167
+ setDimensions(window);
168
+ });
169
+ return () => subscription.remove();
170
+ }, []);
171
+ return { width: dimensions.width, height: dimensions.height };
172
+ }
173
+ var maxWidthMap = {
174
+ xs: 480,
175
+ sm: 640,
176
+ md: 768,
177
+ lg: 1024,
178
+ xl: 1280,
179
+ full: void 0
180
+ };
181
+ function Container({
182
+ maxWidth = "lg",
183
+ center,
184
+ style,
185
+ children,
186
+ ...rest
187
+ }) {
188
+ const { baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
189
+ const breakpoint = useBreakpoint();
190
+ const maxW = maxWidthMap[maxWidth];
191
+ let pageMargin = bt.entropixSpaceLayoutPageMargin;
192
+ if (breakpoint === "lg" || breakpoint === "xl" || breakpoint === "2xl") {
193
+ pageMargin = bt.entropixSpaceLayoutPageMarginLg;
194
+ } else if (breakpoint === "md") {
195
+ pageMargin = bt.entropixSpaceLayoutPageMarginMd;
196
+ }
197
+ return /* @__PURE__ */ jsxRuntime.jsx(
198
+ reactNative.View,
199
+ {
200
+ style: [
201
+ {
202
+ width: "100%",
203
+ paddingHorizontal: pageMargin
204
+ },
205
+ maxW !== void 0 && { maxWidth: maxW, alignSelf: "center" },
206
+ center && { alignItems: "center" },
207
+ style
208
+ ],
209
+ ...rest,
210
+ children
211
+ }
212
+ );
213
+ }
214
+ function Divider({
215
+ orientation = "horizontal",
216
+ spacing,
217
+ style,
218
+ ...rest
219
+ }) {
220
+ const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
221
+ const spacingMap = {
222
+ sm: bt.entropixSpacing2,
223
+ md: bt.entropixSpacing4,
224
+ lg: bt.entropixSpacing6
225
+ };
226
+ const spacingValue = spacing ? spacingMap[spacing] : 0;
227
+ const isVertical = orientation === "vertical";
228
+ const dividerStyle = isVertical ? {
229
+ width: 1,
230
+ alignSelf: "stretch",
231
+ backgroundColor: t.entropixColorBorderDefault,
232
+ marginHorizontal: spacingValue
233
+ } : {
234
+ height: 1,
235
+ width: "100%",
236
+ backgroundColor: t.entropixColorBorderDefault,
237
+ marginVertical: spacingValue
238
+ };
239
+ return /* @__PURE__ */ jsxRuntime.jsx(
240
+ reactNative.View,
241
+ {
242
+ accessibilityRole: isVertical ? "none" : void 0,
243
+ style: [dividerStyle, style],
244
+ ...rest
245
+ }
246
+ );
247
+ }
248
+
249
+ exports.BREAKPOINTS = BREAKPOINTS;
250
+ exports.Container = Container;
251
+ exports.Divider = Divider;
252
+ exports.Inline = Inline;
253
+ exports.Stack = Stack;
254
+ exports.useBreakpoint = useBreakpoint;
255
+ exports.useBreakpointValue = useBreakpointValue;
256
+ exports.useScreenDimensions = useScreenDimensions;
257
+ //# sourceMappingURL=chunk-G7WPUTB6.cjs.map
258
+ //# sourceMappingURL=chunk-G7WPUTB6.cjs.map
@@ -0,0 +1,122 @@
1
+ import { mapAccessibilityToRN } from './chunk-73BDGPZT.js';
2
+ import { useTheme } from './chunk-ZYOTKLBG.js';
3
+ import { useMenu } from '@entropix/core';
4
+ import { createContext, useCallback, useContext } from 'react';
5
+ import { jsx } from 'react/jsx-runtime';
6
+ import { Pressable, View, Text } from 'react-native';
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, style, ...rest }) {
23
+ const { getTriggerProps } = useMenuContext();
24
+ const propGetterReturn = getTriggerProps();
25
+ const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
26
+ const handlePress = useCallback(() => {
27
+ propGetterReturn.onAction?.();
28
+ }, [propGetterReturn.onAction]);
29
+ return /* @__PURE__ */ jsx(
30
+ Pressable,
31
+ {
32
+ ...rnAccessibility,
33
+ ...rest,
34
+ onPress: handlePress,
35
+ style,
36
+ children
37
+ }
38
+ );
39
+ }
40
+ function MenuContent({ children, style, testID }) {
41
+ const { tokens: t, baseTokens: bt } = useTheme();
42
+ const { isOpen, getMenuProps } = useMenuContext();
43
+ const propGetterReturn = getMenuProps();
44
+ const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
45
+ if (!isOpen) return null;
46
+ return /* @__PURE__ */ jsx(
47
+ View,
48
+ {
49
+ ...rnAccessibility,
50
+ testID,
51
+ style: [
52
+ {
53
+ minWidth: 160,
54
+ padding: bt.entropixSpacing1,
55
+ backgroundColor: t.entropixColorBgPrimary,
56
+ borderWidth: 1,
57
+ borderColor: t.entropixColorBorderDefault,
58
+ borderRadius: bt.entropixRadiusMd,
59
+ shadowColor: "#000",
60
+ shadowOffset: { width: 0, height: 2 },
61
+ shadowOpacity: 0.1,
62
+ shadowRadius: 8,
63
+ elevation: 4
64
+ },
65
+ style
66
+ ],
67
+ children
68
+ }
69
+ );
70
+ }
71
+ function wrapStringChildren(children, style) {
72
+ if (typeof children === "string" || typeof children === "number") {
73
+ return /* @__PURE__ */ jsx(Text, { style, children });
74
+ }
75
+ return children;
76
+ }
77
+ function MenuItem({
78
+ index,
79
+ onSelect,
80
+ disabled,
81
+ children,
82
+ style,
83
+ textStyle,
84
+ ...rest
85
+ }) {
86
+ const { tokens: t, baseTokens: bt } = useTheme();
87
+ const { getItemProps } = useMenuContext();
88
+ const propGetterReturn = getItemProps(index, { onSelect, disabled });
89
+ const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
90
+ const handlePress = useCallback(() => {
91
+ propGetterReturn.onAction?.();
92
+ }, [propGetterReturn.onAction]);
93
+ return /* @__PURE__ */ jsx(
94
+ Pressable,
95
+ {
96
+ ...rnAccessibility,
97
+ ...rest,
98
+ disabled,
99
+ onPress: propGetterReturn.onAction ? handlePress : void 0,
100
+ style: [
101
+ {
102
+ flexDirection: "row",
103
+ alignItems: "center",
104
+ paddingVertical: bt.entropixSpacing2,
105
+ paddingHorizontal: bt.entropixSpacing3,
106
+ borderRadius: bt.entropixRadiusSm,
107
+ opacity: disabled ? 0.5 : 1
108
+ },
109
+ style
110
+ ],
111
+ children: wrapStringChildren(children, {
112
+ fontSize: bt.entropixFontSizeSm,
113
+ color: t.entropixColorTextPrimary,
114
+ ...textStyle
115
+ })
116
+ }
117
+ );
118
+ }
119
+
120
+ export { Menu, MenuContent, MenuItem, MenuTrigger };
121
+ //# sourceMappingURL=chunk-HH3CEDSH.js.map
122
+ //# sourceMappingURL=chunk-HH3CEDSH.js.map
@@ -0,0 +1,156 @@
1
+ 'use strict';
2
+
3
+ var chunkP5NAXMSC_cjs = require('./chunk-P5NAXMSC.cjs');
4
+ var chunkBOUIB4OY_cjs = require('./chunk-BOUIB4OY.cjs');
5
+ var react = require('react');
6
+ var reactNative = require('react-native');
7
+ var core = require('@entropix/core');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+
10
+ function Checkbox({
11
+ checked,
12
+ defaultChecked,
13
+ onChange,
14
+ disabled,
15
+ indeterminate,
16
+ label,
17
+ size = "md",
18
+ style,
19
+ textStyle,
20
+ children,
21
+ ...rest
22
+ }) {
23
+ const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
24
+ const { isChecked, isDisabled, getToggleProps } = core.useToggle({
25
+ checked,
26
+ defaultChecked,
27
+ onChange,
28
+ disabled,
29
+ role: "checkbox"
30
+ });
31
+ const propGetterReturn = getToggleProps();
32
+ const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
33
+ if (indeterminate) {
34
+ rnAccessibility.accessibilityState = {
35
+ ...rnAccessibility.accessibilityState,
36
+ checked: "mixed"
37
+ };
38
+ }
39
+ if (label) {
40
+ rnAccessibility.accessibilityLabel = label;
41
+ }
42
+ const handlePress = react.useCallback(() => {
43
+ propGetterReturn.onAction?.();
44
+ }, [propGetterReturn.onAction]);
45
+ const sizeStyles = getSizeStyles(size, bt);
46
+ const isActive = indeterminate || isChecked;
47
+ return /* @__PURE__ */ jsxRuntime.jsxs(
48
+ reactNative.Pressable,
49
+ {
50
+ ...rnAccessibility,
51
+ ...rest,
52
+ disabled: isDisabled,
53
+ onPress: isDisabled ? void 0 : handlePress,
54
+ style: [
55
+ {
56
+ flexDirection: "row",
57
+ alignItems: "center",
58
+ gap: bt.entropixSpacing2
59
+ },
60
+ isDisabled && { opacity: 0.5 },
61
+ style
62
+ ],
63
+ children: [
64
+ /* @__PURE__ */ jsxRuntime.jsx(
65
+ reactNative.View,
66
+ {
67
+ style: {
68
+ width: sizeStyles.boxSize,
69
+ height: sizeStyles.boxSize,
70
+ borderWidth: 2,
71
+ borderColor: isActive ? t.entropixColorActionPrimaryDefault : t.entropixColorBorderDefault,
72
+ borderRadius: bt.entropixRadiusSm,
73
+ backgroundColor: isActive ? t.entropixColorActionPrimaryDefault : "transparent",
74
+ alignItems: "center",
75
+ justifyContent: "center"
76
+ },
77
+ children: indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(
78
+ reactNative.Text,
79
+ {
80
+ style: {
81
+ fontSize: sizeStyles.indicatorFontSize,
82
+ fontWeight: "700",
83
+ color: t.entropixColorTextInverse,
84
+ lineHeight: sizeStyles.boxSize - 2
85
+ },
86
+ children: "\u2013"
87
+ }
88
+ ) : isChecked ? /* @__PURE__ */ jsxRuntime.jsx(
89
+ reactNative.Text,
90
+ {
91
+ style: {
92
+ fontSize: sizeStyles.indicatorFontSize,
93
+ fontWeight: "700",
94
+ color: t.entropixColorTextInverse,
95
+ lineHeight: sizeStyles.boxSize - 2
96
+ },
97
+ children: "\u2713"
98
+ }
99
+ ) : null
100
+ }
101
+ ),
102
+ typeof children === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
103
+ reactNative.Text,
104
+ {
105
+ style: [
106
+ {
107
+ fontSize: sizeStyles.fontSize,
108
+ color: t.entropixColorTextPrimary
109
+ },
110
+ textStyle
111
+ ],
112
+ children
113
+ }
114
+ ) : children != null ? children : label ? /* @__PURE__ */ jsxRuntime.jsx(
115
+ reactNative.Text,
116
+ {
117
+ style: [
118
+ {
119
+ fontSize: sizeStyles.fontSize,
120
+ color: t.entropixColorTextPrimary
121
+ },
122
+ textStyle
123
+ ],
124
+ children: label
125
+ }
126
+ ) : null
127
+ ]
128
+ }
129
+ );
130
+ }
131
+ function getSizeStyles(size, bt) {
132
+ switch (size) {
133
+ case "sm":
134
+ return {
135
+ boxSize: 16,
136
+ indicatorFontSize: 10,
137
+ fontSize: bt.entropixFontSizeXs
138
+ };
139
+ case "lg":
140
+ return {
141
+ boxSize: 24,
142
+ indicatorFontSize: 16,
143
+ fontSize: bt.entropixFontSizeBase
144
+ };
145
+ default:
146
+ return {
147
+ boxSize: 20,
148
+ indicatorFontSize: 13,
149
+ fontSize: bt.entropixFontSizeSm
150
+ };
151
+ }
152
+ }
153
+
154
+ exports.Checkbox = Checkbox;
155
+ //# sourceMappingURL=chunk-IRQWSFCZ.cjs.map
156
+ //# sourceMappingURL=chunk-IRQWSFCZ.cjs.map
@@ -0,0 +1,92 @@
1
+ import { mapAccessibilityToRN } from './chunk-73BDGPZT.js';
2
+ import { useTheme } from './chunk-ZYOTKLBG.js';
3
+ import { useCallback } from 'react';
4
+ import { Pressable, Text } from 'react-native';
5
+ import { useToggle } from '@entropix/core';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ function Toggle(props) {
9
+ return /* @__PURE__ */ jsx(ToggleInner, { ...props, role: "checkbox" });
10
+ }
11
+ function ToggleInner({
12
+ checked,
13
+ defaultChecked,
14
+ onChange,
15
+ disabled,
16
+ label,
17
+ role = "checkbox",
18
+ style,
19
+ textStyle,
20
+ children,
21
+ ...rest
22
+ }) {
23
+ const { tokens: t, baseTokens: bt } = useTheme();
24
+ const { isDisabled, getToggleProps } = useToggle({
25
+ checked,
26
+ defaultChecked,
27
+ onChange,
28
+ disabled,
29
+ role
30
+ });
31
+ const propGetterReturn = getToggleProps();
32
+ const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
33
+ const isChecked = propGetterReturn.accessibility.checked === true;
34
+ if (label) {
35
+ rnAccessibility.accessibilityLabel = label;
36
+ }
37
+ const handlePress = useCallback(() => {
38
+ propGetterReturn.onAction?.();
39
+ }, [propGetterReturn.onAction]);
40
+ return /* @__PURE__ */ jsx(
41
+ Pressable,
42
+ {
43
+ ...rnAccessibility,
44
+ ...rest,
45
+ disabled: isDisabled,
46
+ onPress: isDisabled ? void 0 : handlePress,
47
+ style: [
48
+ {
49
+ flexDirection: "row",
50
+ alignItems: "center",
51
+ justifyContent: "center",
52
+ paddingVertical: bt.entropixSpacing2,
53
+ paddingHorizontal: bt.entropixSpacing3,
54
+ borderWidth: 1,
55
+ borderColor: isChecked ? "transparent" : t.entropixColorBorderDefault,
56
+ borderRadius: bt.entropixRadiusMd,
57
+ backgroundColor: isChecked ? t.entropixColorActionPrimaryDefault : t.entropixColorBgPrimary
58
+ },
59
+ isDisabled && { opacity: 0.5 },
60
+ style
61
+ ],
62
+ children: typeof children === "string" ? /* @__PURE__ */ jsx(
63
+ Text,
64
+ {
65
+ style: [
66
+ {
67
+ fontSize: bt.entropixFontSizeSm,
68
+ fontWeight: "500",
69
+ color: isChecked ? t.entropixColorTextInverse : t.entropixColorTextPrimary
70
+ },
71
+ textStyle
72
+ ],
73
+ children
74
+ }
75
+ ) : children != null ? children : /* @__PURE__ */ jsx(
76
+ Text,
77
+ {
78
+ style: {
79
+ fontSize: bt.entropixFontSizeSm,
80
+ fontWeight: "500",
81
+ color: isChecked ? t.entropixColorTextInverse : t.entropixColorTextPrimary
82
+ },
83
+ children: isChecked ? "On" : "Off"
84
+ }
85
+ )
86
+ }
87
+ );
88
+ }
89
+
90
+ export { Toggle, ToggleInner };
91
+ //# sourceMappingURL=chunk-KU24A5PQ.js.map
92
+ //# sourceMappingURL=chunk-KU24A5PQ.js.map