@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,164 @@
|
|
|
1
|
+
import { mapAccessibilityToRN } from './chunk-73BDGPZT.js';
|
|
2
|
+
import { useTheme } from './chunk-ZYOTKLBG.js';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { View, Text, TextInput } from 'react-native';
|
|
5
|
+
import { useInput } from '@entropix/core';
|
|
6
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
function Textarea({
|
|
9
|
+
value,
|
|
10
|
+
defaultValue,
|
|
11
|
+
onChange,
|
|
12
|
+
disabled,
|
|
13
|
+
readOnly,
|
|
14
|
+
required,
|
|
15
|
+
invalid,
|
|
16
|
+
label,
|
|
17
|
+
helperText,
|
|
18
|
+
errorMessage,
|
|
19
|
+
placeholder,
|
|
20
|
+
numberOfLines = 4,
|
|
21
|
+
size = "md",
|
|
22
|
+
style,
|
|
23
|
+
inputStyle,
|
|
24
|
+
textStyle,
|
|
25
|
+
testID
|
|
26
|
+
}) {
|
|
27
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
28
|
+
const {
|
|
29
|
+
value: inputValue,
|
|
30
|
+
isDisabled,
|
|
31
|
+
isReadOnly,
|
|
32
|
+
isInvalid,
|
|
33
|
+
setValue,
|
|
34
|
+
getInputProps
|
|
35
|
+
} = useInput({
|
|
36
|
+
value,
|
|
37
|
+
defaultValue,
|
|
38
|
+
onChange,
|
|
39
|
+
disabled,
|
|
40
|
+
readOnly,
|
|
41
|
+
required,
|
|
42
|
+
invalid,
|
|
43
|
+
type: "text",
|
|
44
|
+
placeholder
|
|
45
|
+
});
|
|
46
|
+
const propGetterReturn = getInputProps();
|
|
47
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
48
|
+
const handleChangeText = useCallback(
|
|
49
|
+
(text) => {
|
|
50
|
+
setValue(text);
|
|
51
|
+
},
|
|
52
|
+
[setValue]
|
|
53
|
+
);
|
|
54
|
+
const sizeStyles = getSizeStyles(size, bt);
|
|
55
|
+
const showError = isInvalid && errorMessage;
|
|
56
|
+
return /* @__PURE__ */ jsxs(View, { style: [{ gap: bt.entropixSpacing1 }, style], children: [
|
|
57
|
+
label ? /* @__PURE__ */ jsxs(
|
|
58
|
+
Text,
|
|
59
|
+
{
|
|
60
|
+
style: [
|
|
61
|
+
{
|
|
62
|
+
fontSize: sizeStyles.labelFontSize,
|
|
63
|
+
fontWeight: "500",
|
|
64
|
+
color: t.entropixColorTextPrimary
|
|
65
|
+
},
|
|
66
|
+
textStyle
|
|
67
|
+
],
|
|
68
|
+
children: [
|
|
69
|
+
label,
|
|
70
|
+
required ? " *" : ""
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
) : null,
|
|
74
|
+
/* @__PURE__ */ jsx(
|
|
75
|
+
TextInput,
|
|
76
|
+
{
|
|
77
|
+
...rnAccessibility,
|
|
78
|
+
testID,
|
|
79
|
+
value: inputValue,
|
|
80
|
+
onChangeText: handleChangeText,
|
|
81
|
+
placeholder,
|
|
82
|
+
placeholderTextColor: t.entropixColorTextTertiary,
|
|
83
|
+
editable: !isDisabled && !isReadOnly,
|
|
84
|
+
multiline: true,
|
|
85
|
+
numberOfLines,
|
|
86
|
+
textAlignVertical: "top",
|
|
87
|
+
style: [
|
|
88
|
+
{
|
|
89
|
+
paddingVertical: sizeStyles.paddingVertical,
|
|
90
|
+
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
91
|
+
fontSize: sizeStyles.fontSize,
|
|
92
|
+
borderWidth: 1,
|
|
93
|
+
borderColor: showError ? t.entropixColorBorderDanger : t.entropixColorBorderDefault,
|
|
94
|
+
borderRadius: bt.entropixRadiusMd,
|
|
95
|
+
backgroundColor: t.entropixColorBgPrimary,
|
|
96
|
+
color: t.entropixColorTextPrimary,
|
|
97
|
+
minHeight: numberOfLines * (sizeStyles.fontSize + 8)
|
|
98
|
+
},
|
|
99
|
+
isDisabled && { opacity: 0.5 },
|
|
100
|
+
inputStyle
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
showError ? /* @__PURE__ */ jsx(
|
|
105
|
+
Text,
|
|
106
|
+
{
|
|
107
|
+
style: [
|
|
108
|
+
{
|
|
109
|
+
fontSize: sizeStyles.helperFontSize,
|
|
110
|
+
color: t.entropixColorTextDanger
|
|
111
|
+
},
|
|
112
|
+
textStyle
|
|
113
|
+
],
|
|
114
|
+
accessibilityRole: "alert",
|
|
115
|
+
accessibilityLiveRegion: "polite",
|
|
116
|
+
children: errorMessage
|
|
117
|
+
}
|
|
118
|
+
) : helperText ? /* @__PURE__ */ jsx(
|
|
119
|
+
Text,
|
|
120
|
+
{
|
|
121
|
+
style: [
|
|
122
|
+
{
|
|
123
|
+
fontSize: sizeStyles.helperFontSize,
|
|
124
|
+
color: t.entropixColorTextSecondary
|
|
125
|
+
},
|
|
126
|
+
textStyle
|
|
127
|
+
],
|
|
128
|
+
children: helperText
|
|
129
|
+
}
|
|
130
|
+
) : null
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
function getSizeStyles(size, bt) {
|
|
134
|
+
switch (size) {
|
|
135
|
+
case "sm":
|
|
136
|
+
return {
|
|
137
|
+
paddingVertical: bt.entropixSpacing1,
|
|
138
|
+
paddingHorizontal: bt.entropixSpacing2,
|
|
139
|
+
fontSize: bt.entropixFontSizeXs,
|
|
140
|
+
labelFontSize: bt.entropixFontSizeXs,
|
|
141
|
+
helperFontSize: bt.entropixFontSizeXs - 1
|
|
142
|
+
};
|
|
143
|
+
case "lg":
|
|
144
|
+
return {
|
|
145
|
+
paddingVertical: bt.entropixSpacing3,
|
|
146
|
+
paddingHorizontal: bt.entropixSpacing4,
|
|
147
|
+
fontSize: bt.entropixFontSizeBase,
|
|
148
|
+
labelFontSize: bt.entropixFontSizeBase,
|
|
149
|
+
helperFontSize: bt.entropixFontSizeSm
|
|
150
|
+
};
|
|
151
|
+
default:
|
|
152
|
+
return {
|
|
153
|
+
paddingVertical: bt.entropixSpacing2,
|
|
154
|
+
paddingHorizontal: bt.entropixSpacing3,
|
|
155
|
+
fontSize: bt.entropixFontSizeSm,
|
|
156
|
+
labelFontSize: bt.entropixFontSizeSm,
|
|
157
|
+
helperFontSize: bt.entropixFontSizeXs
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export { Textarea };
|
|
163
|
+
//# sourceMappingURL=chunk-64DK6YFL.js.map
|
|
164
|
+
//# sourceMappingURL=chunk-64DK6YFL.js.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// src/utils/map-accessibility-to-rn.ts
|
|
2
|
+
var RN_ROLE_MAP = {
|
|
3
|
+
button: "button",
|
|
4
|
+
checkbox: "checkbox",
|
|
5
|
+
switch: "switch",
|
|
6
|
+
dialog: "none",
|
|
7
|
+
// Modal component handles dialog semantics
|
|
8
|
+
alertdialog: "alert",
|
|
9
|
+
link: "link",
|
|
10
|
+
tab: "tab",
|
|
11
|
+
tablist: "tablist",
|
|
12
|
+
menu: "menu",
|
|
13
|
+
menuitem: "menuitem",
|
|
14
|
+
radio: "radio",
|
|
15
|
+
radiogroup: "radiogroup",
|
|
16
|
+
slider: "adjustable",
|
|
17
|
+
spinbutton: "spinbutton",
|
|
18
|
+
textbox: "text",
|
|
19
|
+
combobox: "combobox",
|
|
20
|
+
progressbar: "progressbar",
|
|
21
|
+
alert: "alert",
|
|
22
|
+
status: "text",
|
|
23
|
+
tooltip: "text",
|
|
24
|
+
none: "none",
|
|
25
|
+
presentation: "none"
|
|
26
|
+
};
|
|
27
|
+
function mapAccessibilityToRN(props) {
|
|
28
|
+
const result = { accessible: true };
|
|
29
|
+
if (props.role) {
|
|
30
|
+
result.accessibilityRole = RN_ROLE_MAP[props.role] ?? props.role;
|
|
31
|
+
}
|
|
32
|
+
if (props.label) {
|
|
33
|
+
result.accessibilityLabel = props.label;
|
|
34
|
+
}
|
|
35
|
+
if (props.describedBy) {
|
|
36
|
+
result.accessibilityHint = props.describedBy;
|
|
37
|
+
}
|
|
38
|
+
if (props.labelledBy) {
|
|
39
|
+
result.accessibilityLabelledBy = props.labelledBy;
|
|
40
|
+
}
|
|
41
|
+
const state = {};
|
|
42
|
+
let hasState = false;
|
|
43
|
+
if (props.disabled !== void 0) {
|
|
44
|
+
state.disabled = props.disabled;
|
|
45
|
+
hasState = true;
|
|
46
|
+
}
|
|
47
|
+
if (props.expanded !== void 0) {
|
|
48
|
+
state.expanded = props.expanded;
|
|
49
|
+
hasState = true;
|
|
50
|
+
}
|
|
51
|
+
if (props.selected !== void 0) {
|
|
52
|
+
state.selected = props.selected;
|
|
53
|
+
hasState = true;
|
|
54
|
+
}
|
|
55
|
+
if (props.checked !== void 0) {
|
|
56
|
+
state.checked = props.checked;
|
|
57
|
+
hasState = true;
|
|
58
|
+
}
|
|
59
|
+
if (props.busy !== void 0) {
|
|
60
|
+
state.busy = props.busy;
|
|
61
|
+
hasState = true;
|
|
62
|
+
}
|
|
63
|
+
if (hasState) {
|
|
64
|
+
result.accessibilityState = state;
|
|
65
|
+
}
|
|
66
|
+
if (props.valueNow !== void 0 || props.valueMin !== void 0 || props.valueMax !== void 0 || props.valueText !== void 0) {
|
|
67
|
+
result.accessibilityValue = {};
|
|
68
|
+
if (props.valueNow !== void 0)
|
|
69
|
+
result.accessibilityValue.now = props.valueNow;
|
|
70
|
+
if (props.valueMin !== void 0)
|
|
71
|
+
result.accessibilityValue.min = props.valueMin;
|
|
72
|
+
if (props.valueMax !== void 0)
|
|
73
|
+
result.accessibilityValue.max = props.valueMax;
|
|
74
|
+
if (props.valueText !== void 0)
|
|
75
|
+
result.accessibilityValue.text = props.valueText;
|
|
76
|
+
}
|
|
77
|
+
if (props.live) {
|
|
78
|
+
result.accessibilityLiveRegion = props.live === "off" ? "none" : props.live;
|
|
79
|
+
}
|
|
80
|
+
if (props.hidden) {
|
|
81
|
+
result.accessibilityElementsHidden = true;
|
|
82
|
+
result.importantForAccessibility = "no-hide-descendants";
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { mapAccessibilityToRN };
|
|
88
|
+
//# sourceMappingURL=chunk-73BDGPZT.js.map
|
|
89
|
+
//# sourceMappingURL=chunk-73BDGPZT.js.map
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkP5NAXMSC_cjs = require('./chunk-P5NAXMSC.cjs');
|
|
4
|
+
var chunkBOUIB4OY_cjs = require('./chunk-BOUIB4OY.cjs');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
var core = require('@entropix/core');
|
|
7
|
+
var react = require('react');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
var SelectContext = react.createContext(null);
|
|
11
|
+
function useSelectContext() {
|
|
12
|
+
const context = react.useContext(SelectContext);
|
|
13
|
+
if (!context) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
"Select compound components must be used within a <Select> provider."
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
20
|
+
function Select({
|
|
21
|
+
label,
|
|
22
|
+
style,
|
|
23
|
+
textStyle,
|
|
24
|
+
children,
|
|
25
|
+
testID,
|
|
26
|
+
...options
|
|
27
|
+
}) {
|
|
28
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
29
|
+
const select = core.useSelect(options);
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectContext.Provider, { value: select, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
31
|
+
reactNative.View,
|
|
32
|
+
{
|
|
33
|
+
testID,
|
|
34
|
+
style: [{ gap: bt.entropixSpacing1 }, style],
|
|
35
|
+
children: [
|
|
36
|
+
label ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
37
|
+
reactNative.Text,
|
|
38
|
+
{
|
|
39
|
+
style: [
|
|
40
|
+
{
|
|
41
|
+
fontSize: bt.entropixFontSizeSm,
|
|
42
|
+
fontWeight: "500",
|
|
43
|
+
color: t.entropixColorTextPrimary
|
|
44
|
+
},
|
|
45
|
+
textStyle
|
|
46
|
+
],
|
|
47
|
+
children: label
|
|
48
|
+
}
|
|
49
|
+
) : null,
|
|
50
|
+
children
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
) });
|
|
54
|
+
}
|
|
55
|
+
function SelectTrigger({
|
|
56
|
+
placeholder = "Select...",
|
|
57
|
+
displayValue,
|
|
58
|
+
style,
|
|
59
|
+
textStyle,
|
|
60
|
+
...rest
|
|
61
|
+
}) {
|
|
62
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
63
|
+
const { selectedValue, isDisabled, isOpen, getTriggerProps } = useSelectContext();
|
|
64
|
+
const propGetterReturn = getTriggerProps();
|
|
65
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
66
|
+
const handlePress = react.useCallback(() => {
|
|
67
|
+
propGetterReturn.onAction?.();
|
|
68
|
+
}, [propGetterReturn.onAction]);
|
|
69
|
+
const hasValue = selectedValue !== "";
|
|
70
|
+
const label = displayValue ?? (hasValue ? selectedValue : placeholder);
|
|
71
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
72
|
+
reactNative.Pressable,
|
|
73
|
+
{
|
|
74
|
+
...rnAccessibility,
|
|
75
|
+
...rest,
|
|
76
|
+
disabled: isDisabled,
|
|
77
|
+
onPress: isDisabled ? void 0 : handlePress,
|
|
78
|
+
style: [
|
|
79
|
+
{
|
|
80
|
+
flexDirection: "row",
|
|
81
|
+
alignItems: "center",
|
|
82
|
+
justifyContent: "space-between",
|
|
83
|
+
paddingVertical: bt.entropixSpacing2,
|
|
84
|
+
paddingHorizontal: bt.entropixSpacing3,
|
|
85
|
+
borderWidth: 1,
|
|
86
|
+
borderColor: isOpen ? t.entropixColorActionPrimaryDefault : t.entropixColorBorderDefault,
|
|
87
|
+
borderRadius: bt.entropixRadiusMd,
|
|
88
|
+
backgroundColor: t.entropixColorBgPrimary
|
|
89
|
+
},
|
|
90
|
+
isDisabled && { opacity: 0.5 },
|
|
91
|
+
style
|
|
92
|
+
],
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
95
|
+
reactNative.Text,
|
|
96
|
+
{
|
|
97
|
+
style: [
|
|
98
|
+
{
|
|
99
|
+
fontSize: bt.entropixFontSizeSm,
|
|
100
|
+
color: hasValue ? t.entropixColorTextPrimary : t.entropixColorTextTertiary,
|
|
101
|
+
flex: 1
|
|
102
|
+
},
|
|
103
|
+
textStyle
|
|
104
|
+
],
|
|
105
|
+
numberOfLines: 1,
|
|
106
|
+
children: label
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
110
|
+
reactNative.Text,
|
|
111
|
+
{
|
|
112
|
+
style: {
|
|
113
|
+
fontSize: bt.entropixFontSizeXs,
|
|
114
|
+
color: t.entropixColorTextSecondary,
|
|
115
|
+
marginLeft: bt.entropixSpacing2
|
|
116
|
+
},
|
|
117
|
+
children: "\u25BC"
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function SelectContent({ children, style, testID }) {
|
|
125
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
126
|
+
const { isOpen, close, getListboxProps } = useSelectContext();
|
|
127
|
+
const propGetterReturn = getListboxProps();
|
|
128
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
129
|
+
if (!isOpen) return null;
|
|
130
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
131
|
+
reactNative.Modal,
|
|
132
|
+
{
|
|
133
|
+
visible: isOpen,
|
|
134
|
+
transparent: true,
|
|
135
|
+
animationType: "fade",
|
|
136
|
+
onRequestClose: close,
|
|
137
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
138
|
+
reactNative.Pressable,
|
|
139
|
+
{
|
|
140
|
+
style: {
|
|
141
|
+
flex: 1,
|
|
142
|
+
justifyContent: "center",
|
|
143
|
+
alignItems: "center",
|
|
144
|
+
backgroundColor: "rgba(0,0,0,0.3)"
|
|
145
|
+
},
|
|
146
|
+
onPress: close,
|
|
147
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
148
|
+
reactNative.Pressable,
|
|
149
|
+
{
|
|
150
|
+
onPress: () => {
|
|
151
|
+
},
|
|
152
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
153
|
+
reactNative.View,
|
|
154
|
+
{
|
|
155
|
+
...rnAccessibility,
|
|
156
|
+
testID,
|
|
157
|
+
style: [
|
|
158
|
+
{
|
|
159
|
+
minWidth: 240,
|
|
160
|
+
maxHeight: 300,
|
|
161
|
+
padding: bt.entropixSpacing1,
|
|
162
|
+
backgroundColor: t.entropixColorBgPrimary,
|
|
163
|
+
borderWidth: 1,
|
|
164
|
+
borderColor: t.entropixColorBorderDefault,
|
|
165
|
+
borderRadius: bt.entropixRadiusMd,
|
|
166
|
+
shadowColor: "#000",
|
|
167
|
+
shadowOffset: { width: 0, height: 4 },
|
|
168
|
+
shadowOpacity: 0.15,
|
|
169
|
+
shadowRadius: 12,
|
|
170
|
+
elevation: 8
|
|
171
|
+
},
|
|
172
|
+
style
|
|
173
|
+
],
|
|
174
|
+
children
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
function SelectOption({
|
|
185
|
+
value,
|
|
186
|
+
index,
|
|
187
|
+
disabled,
|
|
188
|
+
style,
|
|
189
|
+
textStyle,
|
|
190
|
+
children,
|
|
191
|
+
...rest
|
|
192
|
+
}) {
|
|
193
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
194
|
+
const { getOptionProps } = useSelectContext();
|
|
195
|
+
const propGetterReturn = getOptionProps(value, index ?? 0, { disabled });
|
|
196
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
197
|
+
const isSelected = propGetterReturn.accessibility.selected === true;
|
|
198
|
+
const handlePress = react.useCallback(() => {
|
|
199
|
+
propGetterReturn.onAction?.();
|
|
200
|
+
}, [propGetterReturn.onAction]);
|
|
201
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
202
|
+
reactNative.Pressable,
|
|
203
|
+
{
|
|
204
|
+
...rnAccessibility,
|
|
205
|
+
...rest,
|
|
206
|
+
disabled,
|
|
207
|
+
onPress: propGetterReturn.onAction ? handlePress : void 0,
|
|
208
|
+
style: [
|
|
209
|
+
{
|
|
210
|
+
flexDirection: "row",
|
|
211
|
+
alignItems: "center",
|
|
212
|
+
paddingVertical: bt.entropixSpacing2,
|
|
213
|
+
paddingHorizontal: bt.entropixSpacing3,
|
|
214
|
+
borderRadius: bt.entropixRadiusSm,
|
|
215
|
+
backgroundColor: isSelected ? t.entropixColorBgSecondary : "transparent"
|
|
216
|
+
},
|
|
217
|
+
disabled && { opacity: 0.5 },
|
|
218
|
+
style
|
|
219
|
+
],
|
|
220
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
221
|
+
reactNative.Text,
|
|
222
|
+
{
|
|
223
|
+
style: [
|
|
224
|
+
{
|
|
225
|
+
fontSize: bt.entropixFontSizeSm,
|
|
226
|
+
fontWeight: isSelected ? "600" : "400",
|
|
227
|
+
color: t.entropixColorTextPrimary
|
|
228
|
+
},
|
|
229
|
+
textStyle
|
|
230
|
+
],
|
|
231
|
+
children
|
|
232
|
+
}
|
|
233
|
+
) : children
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
exports.Select = Select;
|
|
239
|
+
exports.SelectContent = SelectContent;
|
|
240
|
+
exports.SelectOption = SelectOption;
|
|
241
|
+
exports.SelectTrigger = SelectTrigger;
|
|
242
|
+
//# sourceMappingURL=chunk-B5YFEA66.cjs.map
|
|
243
|
+
//# sourceMappingURL=chunk-B5YFEA66.cjs.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var native = require('@entropix/tokens/native');
|
|
5
|
+
var light = require('@entropix/tokens/native/light');
|
|
6
|
+
var dark = require('@entropix/tokens/native/dark');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
// src/theme/theme-context.tsx
|
|
10
|
+
var ThemeContext = react.createContext({
|
|
11
|
+
mode: "light",
|
|
12
|
+
brand: "default",
|
|
13
|
+
tokens: light.tokens,
|
|
14
|
+
baseTokens: native.tokens
|
|
15
|
+
});
|
|
16
|
+
var brandRegistry = {
|
|
17
|
+
default: {
|
|
18
|
+
light: light.tokens,
|
|
19
|
+
dark: dark.tokens
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function registerBrand(name, themes) {
|
|
23
|
+
brandRegistry[name] = themes;
|
|
24
|
+
}
|
|
25
|
+
function EntropixProvider({
|
|
26
|
+
mode = "light",
|
|
27
|
+
brand = "default",
|
|
28
|
+
tokens: tokenOverride,
|
|
29
|
+
children
|
|
30
|
+
}) {
|
|
31
|
+
const value = react.useMemo(() => {
|
|
32
|
+
let resolvedTokens;
|
|
33
|
+
if (tokenOverride) {
|
|
34
|
+
resolvedTokens = tokenOverride;
|
|
35
|
+
} else {
|
|
36
|
+
const brandThemes = brandRegistry[brand] ?? brandRegistry.default;
|
|
37
|
+
resolvedTokens = brandThemes[mode] ?? brandThemes.light;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
mode,
|
|
41
|
+
brand,
|
|
42
|
+
tokens: resolvedTokens,
|
|
43
|
+
baseTokens: native.tokens
|
|
44
|
+
};
|
|
45
|
+
}, [mode, brand, tokenOverride]);
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value, children });
|
|
47
|
+
}
|
|
48
|
+
function useTheme() {
|
|
49
|
+
return react.useContext(ThemeContext);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.EntropixProvider = EntropixProvider;
|
|
53
|
+
exports.registerBrand = registerBrand;
|
|
54
|
+
exports.useTheme = useTheme;
|
|
55
|
+
//# sourceMappingURL=chunk-BOUIB4OY.cjs.map
|
|
56
|
+
//# sourceMappingURL=chunk-BOUIB4OY.cjs.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { mapAccessibilityToRN } from './chunk-73BDGPZT.js';
|
|
2
|
+
import { useTheme } from './chunk-ZYOTKLBG.js';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { Pressable, View, Text } from 'react-native';
|
|
5
|
+
import { useToggle } from '@entropix/core';
|
|
6
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
function Checkbox({
|
|
9
|
+
checked,
|
|
10
|
+
defaultChecked,
|
|
11
|
+
onChange,
|
|
12
|
+
disabled,
|
|
13
|
+
indeterminate,
|
|
14
|
+
label,
|
|
15
|
+
size = "md",
|
|
16
|
+
style,
|
|
17
|
+
textStyle,
|
|
18
|
+
children,
|
|
19
|
+
...rest
|
|
20
|
+
}) {
|
|
21
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
22
|
+
const { isChecked, isDisabled, getToggleProps } = useToggle({
|
|
23
|
+
checked,
|
|
24
|
+
defaultChecked,
|
|
25
|
+
onChange,
|
|
26
|
+
disabled,
|
|
27
|
+
role: "checkbox"
|
|
28
|
+
});
|
|
29
|
+
const propGetterReturn = getToggleProps();
|
|
30
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
31
|
+
if (indeterminate) {
|
|
32
|
+
rnAccessibility.accessibilityState = {
|
|
33
|
+
...rnAccessibility.accessibilityState,
|
|
34
|
+
checked: "mixed"
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (label) {
|
|
38
|
+
rnAccessibility.accessibilityLabel = label;
|
|
39
|
+
}
|
|
40
|
+
const handlePress = useCallback(() => {
|
|
41
|
+
propGetterReturn.onAction?.();
|
|
42
|
+
}, [propGetterReturn.onAction]);
|
|
43
|
+
const sizeStyles = getSizeStyles(size, bt);
|
|
44
|
+
const isActive = indeterminate || isChecked;
|
|
45
|
+
return /* @__PURE__ */ jsxs(
|
|
46
|
+
Pressable,
|
|
47
|
+
{
|
|
48
|
+
...rnAccessibility,
|
|
49
|
+
...rest,
|
|
50
|
+
disabled: isDisabled,
|
|
51
|
+
onPress: isDisabled ? void 0 : handlePress,
|
|
52
|
+
style: [
|
|
53
|
+
{
|
|
54
|
+
flexDirection: "row",
|
|
55
|
+
alignItems: "center",
|
|
56
|
+
gap: bt.entropixSpacing2
|
|
57
|
+
},
|
|
58
|
+
isDisabled && { opacity: 0.5 },
|
|
59
|
+
style
|
|
60
|
+
],
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsx(
|
|
63
|
+
View,
|
|
64
|
+
{
|
|
65
|
+
style: {
|
|
66
|
+
width: sizeStyles.boxSize,
|
|
67
|
+
height: sizeStyles.boxSize,
|
|
68
|
+
borderWidth: 2,
|
|
69
|
+
borderColor: isActive ? t.entropixColorActionPrimaryDefault : t.entropixColorBorderDefault,
|
|
70
|
+
borderRadius: bt.entropixRadiusSm,
|
|
71
|
+
backgroundColor: isActive ? t.entropixColorActionPrimaryDefault : "transparent",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
justifyContent: "center"
|
|
74
|
+
},
|
|
75
|
+
children: indeterminate ? /* @__PURE__ */ jsx(
|
|
76
|
+
Text,
|
|
77
|
+
{
|
|
78
|
+
style: {
|
|
79
|
+
fontSize: sizeStyles.indicatorFontSize,
|
|
80
|
+
fontWeight: "700",
|
|
81
|
+
color: t.entropixColorTextInverse,
|
|
82
|
+
lineHeight: sizeStyles.boxSize - 2
|
|
83
|
+
},
|
|
84
|
+
children: "\u2013"
|
|
85
|
+
}
|
|
86
|
+
) : isChecked ? /* @__PURE__ */ jsx(
|
|
87
|
+
Text,
|
|
88
|
+
{
|
|
89
|
+
style: {
|
|
90
|
+
fontSize: sizeStyles.indicatorFontSize,
|
|
91
|
+
fontWeight: "700",
|
|
92
|
+
color: t.entropixColorTextInverse,
|
|
93
|
+
lineHeight: sizeStyles.boxSize - 2
|
|
94
|
+
},
|
|
95
|
+
children: "\u2713"
|
|
96
|
+
}
|
|
97
|
+
) : null
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
typeof children === "string" ? /* @__PURE__ */ jsx(
|
|
101
|
+
Text,
|
|
102
|
+
{
|
|
103
|
+
style: [
|
|
104
|
+
{
|
|
105
|
+
fontSize: sizeStyles.fontSize,
|
|
106
|
+
color: t.entropixColorTextPrimary
|
|
107
|
+
},
|
|
108
|
+
textStyle
|
|
109
|
+
],
|
|
110
|
+
children
|
|
111
|
+
}
|
|
112
|
+
) : children != null ? children : label ? /* @__PURE__ */ jsx(
|
|
113
|
+
Text,
|
|
114
|
+
{
|
|
115
|
+
style: [
|
|
116
|
+
{
|
|
117
|
+
fontSize: sizeStyles.fontSize,
|
|
118
|
+
color: t.entropixColorTextPrimary
|
|
119
|
+
},
|
|
120
|
+
textStyle
|
|
121
|
+
],
|
|
122
|
+
children: label
|
|
123
|
+
}
|
|
124
|
+
) : null
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function getSizeStyles(size, bt) {
|
|
130
|
+
switch (size) {
|
|
131
|
+
case "sm":
|
|
132
|
+
return {
|
|
133
|
+
boxSize: 16,
|
|
134
|
+
indicatorFontSize: 10,
|
|
135
|
+
fontSize: bt.entropixFontSizeXs
|
|
136
|
+
};
|
|
137
|
+
case "lg":
|
|
138
|
+
return {
|
|
139
|
+
boxSize: 24,
|
|
140
|
+
indicatorFontSize: 16,
|
|
141
|
+
fontSize: bt.entropixFontSizeBase
|
|
142
|
+
};
|
|
143
|
+
default:
|
|
144
|
+
return {
|
|
145
|
+
boxSize: 20,
|
|
146
|
+
indicatorFontSize: 13,
|
|
147
|
+
fontSize: bt.entropixFontSizeSm
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export { Checkbox };
|
|
153
|
+
//# sourceMappingURL=chunk-C6HF6QXK.js.map
|
|
154
|
+
//# sourceMappingURL=chunk-C6HF6QXK.js.map
|