@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.
- package/dist/accordion.cjs +26 -0
- package/dist/accordion.d.cts +34 -0
- package/dist/accordion.d.ts +34 -0
- package/dist/accordion.js +5 -0
- package/dist/button.cjs +14 -0
- package/dist/button.d.cts +35 -0
- package/dist/button.d.ts +35 -0
- package/dist/button.js +5 -0
- package/dist/checkbox.cjs +14 -0
- package/dist/checkbox.d.cts +41 -0
- package/dist/checkbox.d.ts +41 -0
- package/dist/checkbox.js +5 -0
- package/dist/chunk-2SQB7RNT.cjs +110 -0
- package/dist/chunk-3MHE2C74.js +143 -0
- package/dist/chunk-45KMMZUT.js +131 -0
- package/dist/chunk-64DK6YFL.js +164 -0
- package/dist/chunk-73BDGPZT.js +89 -0
- package/dist/chunk-B5YFEA66.cjs +243 -0
- package/dist/chunk-BOUIB4OY.cjs +56 -0
- package/dist/chunk-C6HF6QXK.js +154 -0
- package/dist/chunk-CXQNNEPC.js +249 -0
- package/dist/chunk-EFRYMWJB.js +86 -0
- package/dist/chunk-FQUZIDVS.cjs +174 -0
- package/dist/chunk-G7WPUTB6.cjs +258 -0
- package/dist/chunk-HH3CEDSH.js +122 -0
- package/dist/chunk-IRQWSFCZ.cjs +156 -0
- package/dist/chunk-KU24A5PQ.js +92 -0
- package/dist/chunk-OMKUPSHJ.cjs +95 -0
- package/dist/chunk-P5NAXMSC.cjs +91 -0
- package/dist/chunk-PKDXWKLO.cjs +245 -0
- package/dist/chunk-PVTPOJRU.js +155 -0
- package/dist/chunk-Q7TEJ62Q.cjs +160 -0
- package/dist/chunk-THX22NZW.cjs +146 -0
- package/dist/chunk-UHVTF2Y4.js +172 -0
- package/dist/chunk-UYXJHKYK.cjs +166 -0
- package/dist/chunk-VP567WZL.js +237 -0
- package/dist/chunk-XBNX4SLA.js +105 -0
- package/dist/chunk-XND7AIKO.cjs +133 -0
- package/dist/chunk-XSOLJOBG.js +238 -0
- package/dist/chunk-Z2MBHXUQ.cjs +127 -0
- package/dist/chunk-ZPAOLIIG.cjs +88 -0
- package/dist/chunk-ZYOTKLBG.js +52 -0
- package/dist/dialog.cjs +38 -0
- package/dist/dialog.d.cts +83 -0
- package/dist/dialog.d.ts +83 -0
- package/dist/dialog.js +5 -0
- package/dist/index.cjs +187 -2063
- package/dist/index.d.cts +21 -651
- package/dist/index.d.ts +21 -651
- package/dist/index.js +15 -2025
- package/dist/input.cjs +14 -0
- package/dist/input.d.cts +57 -0
- package/dist/input.d.ts +57 -0
- package/dist/input.js +5 -0
- package/dist/layout.cjs +25 -0
- package/dist/layout.d.cts +108 -0
- package/dist/layout.d.ts +108 -0
- package/dist/layout.js +4 -0
- package/dist/menu.cjs +26 -0
- package/dist/menu.d.cts +34 -0
- package/dist/menu.d.ts +34 -0
- package/dist/menu.js +5 -0
- package/dist/radio.cjs +18 -0
- package/dist/radio.d.cts +55 -0
- package/dist/radio.d.ts +55 -0
- package/dist/radio.js +5 -0
- package/dist/select.cjs +26 -0
- package/dist/select.d.cts +86 -0
- package/dist/select.d.ts +86 -0
- package/dist/select.js +5 -0
- package/dist/switch.cjs +14 -0
- package/dist/switch.d.cts +27 -0
- package/dist/switch.d.ts +27 -0
- package/dist/switch.js +5 -0
- package/dist/tabs.cjs +26 -0
- package/dist/tabs.d.cts +33 -0
- package/dist/tabs.d.ts +33 -0
- package/dist/tabs.js +5 -0
- package/dist/textarea.cjs +14 -0
- package/dist/textarea.d.cts +55 -0
- package/dist/textarea.d.ts +55 -0
- package/dist/textarea.js +5 -0
- package/dist/theme.cjs +20 -0
- package/dist/theme.d.cts +59 -0
- package/dist/theme.d.ts +59 -0
- package/dist/theme.js +3 -0
- package/dist/toggle.cjs +18 -0
- package/dist/toggle.d.cts +41 -0
- package/dist/toggle.d.ts +41 -0
- package/dist/toggle.js +5 -0
- package/package.json +146 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { mapAccessibilityToRN } from './chunk-73BDGPZT.js';
|
|
2
|
+
import { useTheme } from './chunk-ZYOTKLBG.js';
|
|
3
|
+
import { useDialog } from '@entropix/core';
|
|
4
|
+
import { createContext, useCallback, useContext } from 'react';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
import { Pressable, Modal, View, Text, StyleSheet } from 'react-native';
|
|
7
|
+
|
|
8
|
+
var DialogContext = createContext(null);
|
|
9
|
+
function useDialogContext() {
|
|
10
|
+
const context = useContext(DialogContext);
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
"Dialog compound components must be used within a <Dialog> provider."
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return context;
|
|
17
|
+
}
|
|
18
|
+
function Dialog({
|
|
19
|
+
children,
|
|
20
|
+
isOpen,
|
|
21
|
+
defaultOpen,
|
|
22
|
+
onOpenChange,
|
|
23
|
+
closeOnOverlayPress,
|
|
24
|
+
closeOnEscape,
|
|
25
|
+
modal,
|
|
26
|
+
role
|
|
27
|
+
}) {
|
|
28
|
+
const dialog = useDialog({
|
|
29
|
+
isOpen,
|
|
30
|
+
defaultOpen,
|
|
31
|
+
onOpenChange,
|
|
32
|
+
closeOnOverlayPress,
|
|
33
|
+
closeOnEscape,
|
|
34
|
+
modal,
|
|
35
|
+
role
|
|
36
|
+
});
|
|
37
|
+
return /* @__PURE__ */ jsx(DialogContext.Provider, { value: dialog, children });
|
|
38
|
+
}
|
|
39
|
+
function DialogTrigger({
|
|
40
|
+
children,
|
|
41
|
+
style,
|
|
42
|
+
...rest
|
|
43
|
+
}) {
|
|
44
|
+
const { getTriggerProps } = useDialogContext();
|
|
45
|
+
const propGetterReturn = getTriggerProps();
|
|
46
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
47
|
+
const handlePress = useCallback(() => {
|
|
48
|
+
propGetterReturn.onAction?.();
|
|
49
|
+
}, [propGetterReturn.onAction]);
|
|
50
|
+
return /* @__PURE__ */ jsx(
|
|
51
|
+
Pressable,
|
|
52
|
+
{
|
|
53
|
+
...rnAccessibility,
|
|
54
|
+
...rest,
|
|
55
|
+
onPress: handlePress,
|
|
56
|
+
style,
|
|
57
|
+
children
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
function DialogContent({
|
|
62
|
+
children,
|
|
63
|
+
style,
|
|
64
|
+
cardStyle,
|
|
65
|
+
animationType = "fade",
|
|
66
|
+
transparent = true,
|
|
67
|
+
...rest
|
|
68
|
+
}) {
|
|
69
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
70
|
+
const { isOpen, close, ids, getContentProps } = useDialogContext();
|
|
71
|
+
const propGetterReturn = getContentProps();
|
|
72
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
73
|
+
return /* @__PURE__ */ jsx(
|
|
74
|
+
Modal,
|
|
75
|
+
{
|
|
76
|
+
visible: isOpen,
|
|
77
|
+
transparent,
|
|
78
|
+
animationType,
|
|
79
|
+
onRequestClose: close,
|
|
80
|
+
supportedOrientations: ["portrait", "landscape"],
|
|
81
|
+
children: /* @__PURE__ */ jsx(
|
|
82
|
+
View,
|
|
83
|
+
{
|
|
84
|
+
...rest,
|
|
85
|
+
style: [
|
|
86
|
+
{
|
|
87
|
+
flex: 1,
|
|
88
|
+
justifyContent: "center",
|
|
89
|
+
alignItems: "center",
|
|
90
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
91
|
+
},
|
|
92
|
+
style
|
|
93
|
+
],
|
|
94
|
+
children: /* @__PURE__ */ jsx(
|
|
95
|
+
View,
|
|
96
|
+
{
|
|
97
|
+
...rnAccessibility,
|
|
98
|
+
nativeID: ids.content,
|
|
99
|
+
style: [
|
|
100
|
+
{
|
|
101
|
+
backgroundColor: t.entropixColorBgPrimary,
|
|
102
|
+
borderRadius: bt.entropixRadiusLg,
|
|
103
|
+
padding: bt.entropixSpacing6,
|
|
104
|
+
width: "90%",
|
|
105
|
+
maxWidth: 480,
|
|
106
|
+
shadowColor: "#000",
|
|
107
|
+
shadowOffset: { width: 0, height: 4 },
|
|
108
|
+
shadowOpacity: 0.15,
|
|
109
|
+
shadowRadius: 12,
|
|
110
|
+
elevation: 8
|
|
111
|
+
},
|
|
112
|
+
cardStyle
|
|
113
|
+
],
|
|
114
|
+
children
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
function DialogTitle({ children, style, ...rest }) {
|
|
123
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
124
|
+
const { ids } = useDialogContext();
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
Text,
|
|
127
|
+
{
|
|
128
|
+
...rest,
|
|
129
|
+
nativeID: ids.title,
|
|
130
|
+
style: [
|
|
131
|
+
{
|
|
132
|
+
fontSize: 18,
|
|
133
|
+
fontWeight: "600",
|
|
134
|
+
color: t.entropixColorTextPrimary,
|
|
135
|
+
marginBottom: bt.entropixSpacing2
|
|
136
|
+
},
|
|
137
|
+
style
|
|
138
|
+
],
|
|
139
|
+
accessibilityRole: "header",
|
|
140
|
+
children
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
function DialogDescription({
|
|
145
|
+
children,
|
|
146
|
+
style,
|
|
147
|
+
...rest
|
|
148
|
+
}) {
|
|
149
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
150
|
+
const { ids } = useDialogContext();
|
|
151
|
+
return /* @__PURE__ */ jsx(
|
|
152
|
+
Text,
|
|
153
|
+
{
|
|
154
|
+
...rest,
|
|
155
|
+
nativeID: ids.description,
|
|
156
|
+
style: [
|
|
157
|
+
{
|
|
158
|
+
fontSize: bt.entropixFontSizeSm,
|
|
159
|
+
color: t.entropixColorTextSecondary,
|
|
160
|
+
lineHeight: 20,
|
|
161
|
+
marginBottom: bt.entropixSpacing4
|
|
162
|
+
},
|
|
163
|
+
style
|
|
164
|
+
],
|
|
165
|
+
children
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
function DialogClose({ children, style, ...rest }) {
|
|
170
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
171
|
+
const { getCloseProps } = useDialogContext();
|
|
172
|
+
const propGetterReturn = getCloseProps();
|
|
173
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
174
|
+
const handlePress = useCallback(() => {
|
|
175
|
+
propGetterReturn.onAction?.();
|
|
176
|
+
}, [propGetterReturn.onAction]);
|
|
177
|
+
return /* @__PURE__ */ jsx(
|
|
178
|
+
Pressable,
|
|
179
|
+
{
|
|
180
|
+
...rnAccessibility,
|
|
181
|
+
...rest,
|
|
182
|
+
onPress: handlePress,
|
|
183
|
+
style: [
|
|
184
|
+
{
|
|
185
|
+
position: "absolute",
|
|
186
|
+
top: bt.entropixSpacing3,
|
|
187
|
+
right: bt.entropixSpacing3,
|
|
188
|
+
width: 32,
|
|
189
|
+
height: 32,
|
|
190
|
+
alignItems: "center",
|
|
191
|
+
justifyContent: "center",
|
|
192
|
+
borderRadius: bt.entropixRadiusSm
|
|
193
|
+
},
|
|
194
|
+
style
|
|
195
|
+
],
|
|
196
|
+
accessibilityRole: "button",
|
|
197
|
+
children: children ?? /* @__PURE__ */ jsx(
|
|
198
|
+
Text,
|
|
199
|
+
{
|
|
200
|
+
style: {
|
|
201
|
+
fontSize: 16,
|
|
202
|
+
color: t.entropixColorTextSecondary
|
|
203
|
+
},
|
|
204
|
+
children: "\u2715"
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
function DialogOverlay({ style, testID }) {
|
|
211
|
+
const { isOpen, getOverlayProps } = useDialogContext();
|
|
212
|
+
const propGetterReturn = getOverlayProps();
|
|
213
|
+
const handlePress = useCallback(() => {
|
|
214
|
+
propGetterReturn.onAction?.();
|
|
215
|
+
}, [propGetterReturn.onAction]);
|
|
216
|
+
if (!isOpen) return null;
|
|
217
|
+
return /* @__PURE__ */ jsx(
|
|
218
|
+
Pressable,
|
|
219
|
+
{
|
|
220
|
+
testID,
|
|
221
|
+
accessible: false,
|
|
222
|
+
importantForAccessibility: "no",
|
|
223
|
+
onPress: propGetterReturn.onAction ? handlePress : void 0,
|
|
224
|
+
style: [
|
|
225
|
+
{
|
|
226
|
+
...StyleSheet.absoluteFillObject,
|
|
227
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
228
|
+
},
|
|
229
|
+
style
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogTitle, DialogTrigger };
|
|
236
|
+
//# sourceMappingURL=chunk-VP567WZL.js.map
|
|
237
|
+
//# sourceMappingURL=chunk-VP567WZL.js.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { mapAccessibilityToRN } from './chunk-73BDGPZT.js';
|
|
2
|
+
import { useTheme } from './chunk-ZYOTKLBG.js';
|
|
3
|
+
import { View, Pressable, Text } from 'react-native';
|
|
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({ children, style, ...options }) {
|
|
19
|
+
const tabs = useTabs(options);
|
|
20
|
+
return /* @__PURE__ */ jsx(TabsContext.Provider, { value: tabs, children: /* @__PURE__ */ jsx(View, { style, children }) });
|
|
21
|
+
}
|
|
22
|
+
function TabList({ children, style }) {
|
|
23
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
24
|
+
const { getTabListProps } = useTabsContext();
|
|
25
|
+
const propGetterReturn = getTabListProps();
|
|
26
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
View,
|
|
29
|
+
{
|
|
30
|
+
...rnAccessibility,
|
|
31
|
+
style: [
|
|
32
|
+
{
|
|
33
|
+
flexDirection: "row",
|
|
34
|
+
gap: bt.entropixSpacing1,
|
|
35
|
+
borderBottomWidth: 1,
|
|
36
|
+
borderBottomColor: t.entropixColorBorderDefault
|
|
37
|
+
},
|
|
38
|
+
style
|
|
39
|
+
],
|
|
40
|
+
children
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
function Tab({ value, children, style, textStyle, ...rest }) {
|
|
45
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
46
|
+
const { getTabProps, selectedKey } = useTabsContext();
|
|
47
|
+
const propGetterReturn = getTabProps(value);
|
|
48
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
49
|
+
const isActive = selectedKey === value;
|
|
50
|
+
const isDisabled = propGetterReturn.accessibility.disabled === true;
|
|
51
|
+
const handlePress = useCallback(() => {
|
|
52
|
+
propGetterReturn.onAction?.();
|
|
53
|
+
}, [propGetterReturn.onAction]);
|
|
54
|
+
return /* @__PURE__ */ jsx(
|
|
55
|
+
Pressable,
|
|
56
|
+
{
|
|
57
|
+
...rnAccessibility,
|
|
58
|
+
...rest,
|
|
59
|
+
onPress: propGetterReturn.onAction ? handlePress : void 0,
|
|
60
|
+
style: [
|
|
61
|
+
{
|
|
62
|
+
paddingVertical: bt.entropixSpacing2,
|
|
63
|
+
paddingHorizontal: bt.entropixSpacing4,
|
|
64
|
+
borderBottomWidth: 2,
|
|
65
|
+
borderBottomColor: isActive ? t.entropixColorActionPrimaryDefault : "transparent"
|
|
66
|
+
},
|
|
67
|
+
isDisabled && { opacity: 0.5 },
|
|
68
|
+
style
|
|
69
|
+
],
|
|
70
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx(
|
|
71
|
+
Text,
|
|
72
|
+
{
|
|
73
|
+
style: [
|
|
74
|
+
{
|
|
75
|
+
fontSize: bt.entropixFontSizeSm,
|
|
76
|
+
fontWeight: "500",
|
|
77
|
+
color: isActive ? t.entropixColorActionPrimaryDefault : t.entropixColorTextSecondary
|
|
78
|
+
},
|
|
79
|
+
textStyle
|
|
80
|
+
],
|
|
81
|
+
children
|
|
82
|
+
}
|
|
83
|
+
) : children
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
function TabPanel({ value, children, style }) {
|
|
88
|
+
const { baseTokens: bt } = useTheme();
|
|
89
|
+
const { getTabPanelProps, selectedKey } = useTabsContext();
|
|
90
|
+
const propGetterReturn = getTabPanelProps(value);
|
|
91
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
92
|
+
if (selectedKey !== value) return null;
|
|
93
|
+
return /* @__PURE__ */ jsx(
|
|
94
|
+
View,
|
|
95
|
+
{
|
|
96
|
+
...rnAccessibility,
|
|
97
|
+
style: [{ padding: bt.entropixSpacing4 }, style],
|
|
98
|
+
children
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { Tab, TabList, TabPanel, Tabs };
|
|
104
|
+
//# sourceMappingURL=chunk-XBNX4SLA.js.map
|
|
105
|
+
//# sourceMappingURL=chunk-XBNX4SLA.js.map
|
|
@@ -0,0 +1,133 @@
|
|
|
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 Button({
|
|
11
|
+
onPress,
|
|
12
|
+
disabled,
|
|
13
|
+
loading,
|
|
14
|
+
variant = "primary",
|
|
15
|
+
size = "md",
|
|
16
|
+
style,
|
|
17
|
+
textStyle,
|
|
18
|
+
children,
|
|
19
|
+
...rest
|
|
20
|
+
}) {
|
|
21
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
22
|
+
const { isDisabled, isLoading, getButtonProps } = core.useButton({
|
|
23
|
+
disabled,
|
|
24
|
+
loading,
|
|
25
|
+
onPress,
|
|
26
|
+
elementType: "div"
|
|
27
|
+
});
|
|
28
|
+
const propGetterReturn = getButtonProps();
|
|
29
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
30
|
+
const handlePress = react.useCallback(() => {
|
|
31
|
+
propGetterReturn.onAction?.();
|
|
32
|
+
}, [propGetterReturn.onAction]);
|
|
33
|
+
const sizeStyles = getSizeStyle(size, bt);
|
|
34
|
+
const variantStyles = getVariantStyle(variant, t);
|
|
35
|
+
const labelColor = getVariantTextColor(variant, t);
|
|
36
|
+
const isInactive = isDisabled || isLoading;
|
|
37
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
38
|
+
reactNative.Pressable,
|
|
39
|
+
{
|
|
40
|
+
...rnAccessibility,
|
|
41
|
+
...rest,
|
|
42
|
+
disabled: isInactive,
|
|
43
|
+
onPress: isInactive ? void 0 : handlePress,
|
|
44
|
+
style: [
|
|
45
|
+
baseStyle,
|
|
46
|
+
sizeStyles.container,
|
|
47
|
+
variantStyles,
|
|
48
|
+
isInactive && { opacity: 0.5 },
|
|
49
|
+
style
|
|
50
|
+
],
|
|
51
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
52
|
+
reactNative.Text,
|
|
53
|
+
{
|
|
54
|
+
style: [
|
|
55
|
+
{ color: labelColor, fontSize: sizeStyles.fontSize, fontWeight: "500" },
|
|
56
|
+
textStyle
|
|
57
|
+
],
|
|
58
|
+
children
|
|
59
|
+
}
|
|
60
|
+
) : children
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
var baseStyle = {
|
|
65
|
+
flexDirection: "row",
|
|
66
|
+
alignItems: "center",
|
|
67
|
+
justifyContent: "center"
|
|
68
|
+
};
|
|
69
|
+
function getSizeStyle(size, bt) {
|
|
70
|
+
switch (size) {
|
|
71
|
+
case "sm":
|
|
72
|
+
return {
|
|
73
|
+
container: {
|
|
74
|
+
paddingVertical: bt.entropixSpacing1,
|
|
75
|
+
paddingHorizontal: bt.entropixSpacing3,
|
|
76
|
+
borderRadius: bt.entropixRadiusSm,
|
|
77
|
+
gap: bt.entropixButtonGap
|
|
78
|
+
},
|
|
79
|
+
fontSize: bt.entropixFontSizeXs
|
|
80
|
+
};
|
|
81
|
+
case "lg":
|
|
82
|
+
return {
|
|
83
|
+
container: {
|
|
84
|
+
paddingVertical: bt.entropixSpacing3,
|
|
85
|
+
paddingHorizontal: bt.entropixSpacing6,
|
|
86
|
+
borderRadius: bt.entropixRadiusLg,
|
|
87
|
+
gap: bt.entropixButtonGap
|
|
88
|
+
},
|
|
89
|
+
fontSize: bt.entropixFontSizeBase
|
|
90
|
+
};
|
|
91
|
+
default:
|
|
92
|
+
return {
|
|
93
|
+
container: {
|
|
94
|
+
paddingVertical: bt.entropixButtonPaddingY,
|
|
95
|
+
paddingHorizontal: bt.entropixButtonPaddingX,
|
|
96
|
+
borderRadius: bt.entropixButtonBorderRadius,
|
|
97
|
+
gap: bt.entropixButtonGap
|
|
98
|
+
},
|
|
99
|
+
fontSize: bt.entropixButtonFontSize
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function getVariantStyle(variant, t) {
|
|
104
|
+
switch (variant) {
|
|
105
|
+
case "primary":
|
|
106
|
+
return { backgroundColor: t.entropixButtonPrimaryBg, borderWidth: 1, borderColor: t.entropixButtonPrimaryBorder };
|
|
107
|
+
case "secondary":
|
|
108
|
+
return { backgroundColor: t.entropixButtonSecondaryBg, borderWidth: 1, borderColor: t.entropixButtonSecondaryBorder };
|
|
109
|
+
case "outline":
|
|
110
|
+
return { backgroundColor: "transparent", borderWidth: 1, borderColor: t.entropixColorBorderDefault };
|
|
111
|
+
case "ghost":
|
|
112
|
+
return { backgroundColor: "transparent", borderWidth: 1, borderColor: "transparent" };
|
|
113
|
+
case "danger":
|
|
114
|
+
return { backgroundColor: t.entropixButtonDangerBg, borderWidth: 1, borderColor: t.entropixButtonDangerBorder };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function getVariantTextColor(variant, t) {
|
|
118
|
+
switch (variant) {
|
|
119
|
+
case "primary":
|
|
120
|
+
return t.entropixButtonPrimaryText;
|
|
121
|
+
case "secondary":
|
|
122
|
+
return t.entropixButtonSecondaryText;
|
|
123
|
+
case "outline":
|
|
124
|
+
case "ghost":
|
|
125
|
+
return t.entropixColorTextPrimary;
|
|
126
|
+
case "danger":
|
|
127
|
+
return t.entropixButtonDangerText;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
exports.Button = Button;
|
|
132
|
+
//# sourceMappingURL=chunk-XND7AIKO.cjs.map
|
|
133
|
+
//# sourceMappingURL=chunk-XND7AIKO.cjs.map
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { mapAccessibilityToRN } from './chunk-73BDGPZT.js';
|
|
2
|
+
import { useTheme } from './chunk-ZYOTKLBG.js';
|
|
3
|
+
import { View, Text, Pressable, Modal } from 'react-native';
|
|
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({
|
|
19
|
+
label,
|
|
20
|
+
style,
|
|
21
|
+
textStyle,
|
|
22
|
+
children,
|
|
23
|
+
testID,
|
|
24
|
+
...options
|
|
25
|
+
}) {
|
|
26
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
27
|
+
const select = useSelect(options);
|
|
28
|
+
return /* @__PURE__ */ jsx(SelectContext.Provider, { value: select, children: /* @__PURE__ */ jsxs(
|
|
29
|
+
View,
|
|
30
|
+
{
|
|
31
|
+
testID,
|
|
32
|
+
style: [{ gap: bt.entropixSpacing1 }, style],
|
|
33
|
+
children: [
|
|
34
|
+
label ? /* @__PURE__ */ jsx(
|
|
35
|
+
Text,
|
|
36
|
+
{
|
|
37
|
+
style: [
|
|
38
|
+
{
|
|
39
|
+
fontSize: bt.entropixFontSizeSm,
|
|
40
|
+
fontWeight: "500",
|
|
41
|
+
color: t.entropixColorTextPrimary
|
|
42
|
+
},
|
|
43
|
+
textStyle
|
|
44
|
+
],
|
|
45
|
+
children: label
|
|
46
|
+
}
|
|
47
|
+
) : null,
|
|
48
|
+
children
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
) });
|
|
52
|
+
}
|
|
53
|
+
function SelectTrigger({
|
|
54
|
+
placeholder = "Select...",
|
|
55
|
+
displayValue,
|
|
56
|
+
style,
|
|
57
|
+
textStyle,
|
|
58
|
+
...rest
|
|
59
|
+
}) {
|
|
60
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
61
|
+
const { selectedValue, isDisabled, isOpen, getTriggerProps } = useSelectContext();
|
|
62
|
+
const propGetterReturn = getTriggerProps();
|
|
63
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
64
|
+
const handlePress = useCallback(() => {
|
|
65
|
+
propGetterReturn.onAction?.();
|
|
66
|
+
}, [propGetterReturn.onAction]);
|
|
67
|
+
const hasValue = selectedValue !== "";
|
|
68
|
+
const label = displayValue ?? (hasValue ? selectedValue : placeholder);
|
|
69
|
+
return /* @__PURE__ */ jsxs(
|
|
70
|
+
Pressable,
|
|
71
|
+
{
|
|
72
|
+
...rnAccessibility,
|
|
73
|
+
...rest,
|
|
74
|
+
disabled: isDisabled,
|
|
75
|
+
onPress: isDisabled ? void 0 : handlePress,
|
|
76
|
+
style: [
|
|
77
|
+
{
|
|
78
|
+
flexDirection: "row",
|
|
79
|
+
alignItems: "center",
|
|
80
|
+
justifyContent: "space-between",
|
|
81
|
+
paddingVertical: bt.entropixSpacing2,
|
|
82
|
+
paddingHorizontal: bt.entropixSpacing3,
|
|
83
|
+
borderWidth: 1,
|
|
84
|
+
borderColor: isOpen ? t.entropixColorActionPrimaryDefault : t.entropixColorBorderDefault,
|
|
85
|
+
borderRadius: bt.entropixRadiusMd,
|
|
86
|
+
backgroundColor: t.entropixColorBgPrimary
|
|
87
|
+
},
|
|
88
|
+
isDisabled && { opacity: 0.5 },
|
|
89
|
+
style
|
|
90
|
+
],
|
|
91
|
+
children: [
|
|
92
|
+
/* @__PURE__ */ jsx(
|
|
93
|
+
Text,
|
|
94
|
+
{
|
|
95
|
+
style: [
|
|
96
|
+
{
|
|
97
|
+
fontSize: bt.entropixFontSizeSm,
|
|
98
|
+
color: hasValue ? t.entropixColorTextPrimary : t.entropixColorTextTertiary,
|
|
99
|
+
flex: 1
|
|
100
|
+
},
|
|
101
|
+
textStyle
|
|
102
|
+
],
|
|
103
|
+
numberOfLines: 1,
|
|
104
|
+
children: label
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
Text,
|
|
109
|
+
{
|
|
110
|
+
style: {
|
|
111
|
+
fontSize: bt.entropixFontSizeXs,
|
|
112
|
+
color: t.entropixColorTextSecondary,
|
|
113
|
+
marginLeft: bt.entropixSpacing2
|
|
114
|
+
},
|
|
115
|
+
children: "\u25BC"
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
function SelectContent({ children, style, testID }) {
|
|
123
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
124
|
+
const { isOpen, close, getListboxProps } = useSelectContext();
|
|
125
|
+
const propGetterReturn = getListboxProps();
|
|
126
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
127
|
+
if (!isOpen) return null;
|
|
128
|
+
return /* @__PURE__ */ jsx(
|
|
129
|
+
Modal,
|
|
130
|
+
{
|
|
131
|
+
visible: isOpen,
|
|
132
|
+
transparent: true,
|
|
133
|
+
animationType: "fade",
|
|
134
|
+
onRequestClose: close,
|
|
135
|
+
children: /* @__PURE__ */ jsx(
|
|
136
|
+
Pressable,
|
|
137
|
+
{
|
|
138
|
+
style: {
|
|
139
|
+
flex: 1,
|
|
140
|
+
justifyContent: "center",
|
|
141
|
+
alignItems: "center",
|
|
142
|
+
backgroundColor: "rgba(0,0,0,0.3)"
|
|
143
|
+
},
|
|
144
|
+
onPress: close,
|
|
145
|
+
children: /* @__PURE__ */ jsx(
|
|
146
|
+
Pressable,
|
|
147
|
+
{
|
|
148
|
+
onPress: () => {
|
|
149
|
+
},
|
|
150
|
+
children: /* @__PURE__ */ jsx(
|
|
151
|
+
View,
|
|
152
|
+
{
|
|
153
|
+
...rnAccessibility,
|
|
154
|
+
testID,
|
|
155
|
+
style: [
|
|
156
|
+
{
|
|
157
|
+
minWidth: 240,
|
|
158
|
+
maxHeight: 300,
|
|
159
|
+
padding: bt.entropixSpacing1,
|
|
160
|
+
backgroundColor: t.entropixColorBgPrimary,
|
|
161
|
+
borderWidth: 1,
|
|
162
|
+
borderColor: t.entropixColorBorderDefault,
|
|
163
|
+
borderRadius: bt.entropixRadiusMd,
|
|
164
|
+
shadowColor: "#000",
|
|
165
|
+
shadowOffset: { width: 0, height: 4 },
|
|
166
|
+
shadowOpacity: 0.15,
|
|
167
|
+
shadowRadius: 12,
|
|
168
|
+
elevation: 8
|
|
169
|
+
},
|
|
170
|
+
style
|
|
171
|
+
],
|
|
172
|
+
children
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
function SelectOption({
|
|
183
|
+
value,
|
|
184
|
+
index,
|
|
185
|
+
disabled,
|
|
186
|
+
style,
|
|
187
|
+
textStyle,
|
|
188
|
+
children,
|
|
189
|
+
...rest
|
|
190
|
+
}) {
|
|
191
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
192
|
+
const { getOptionProps } = useSelectContext();
|
|
193
|
+
const propGetterReturn = getOptionProps(value, index ?? 0, { disabled });
|
|
194
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
195
|
+
const isSelected = propGetterReturn.accessibility.selected === true;
|
|
196
|
+
const handlePress = useCallback(() => {
|
|
197
|
+
propGetterReturn.onAction?.();
|
|
198
|
+
}, [propGetterReturn.onAction]);
|
|
199
|
+
return /* @__PURE__ */ jsx(
|
|
200
|
+
Pressable,
|
|
201
|
+
{
|
|
202
|
+
...rnAccessibility,
|
|
203
|
+
...rest,
|
|
204
|
+
disabled,
|
|
205
|
+
onPress: propGetterReturn.onAction ? handlePress : void 0,
|
|
206
|
+
style: [
|
|
207
|
+
{
|
|
208
|
+
flexDirection: "row",
|
|
209
|
+
alignItems: "center",
|
|
210
|
+
paddingVertical: bt.entropixSpacing2,
|
|
211
|
+
paddingHorizontal: bt.entropixSpacing3,
|
|
212
|
+
borderRadius: bt.entropixRadiusSm,
|
|
213
|
+
backgroundColor: isSelected ? t.entropixColorBgSecondary : "transparent"
|
|
214
|
+
},
|
|
215
|
+
disabled && { opacity: 0.5 },
|
|
216
|
+
style
|
|
217
|
+
],
|
|
218
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx(
|
|
219
|
+
Text,
|
|
220
|
+
{
|
|
221
|
+
style: [
|
|
222
|
+
{
|
|
223
|
+
fontSize: bt.entropixFontSizeSm,
|
|
224
|
+
fontWeight: isSelected ? "600" : "400",
|
|
225
|
+
color: t.entropixColorTextPrimary
|
|
226
|
+
},
|
|
227
|
+
textStyle
|
|
228
|
+
],
|
|
229
|
+
children
|
|
230
|
+
}
|
|
231
|
+
) : children
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export { Select, SelectContent, SelectOption, SelectTrigger };
|
|
237
|
+
//# sourceMappingURL=chunk-XSOLJOBG.js.map
|
|
238
|
+
//# sourceMappingURL=chunk-XSOLJOBG.js.map
|