@entropix/react-native 1.0.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 -2084
- package/dist/index.d.cts +21 -672
- package/dist/index.d.ts +21 -672
- package/dist/index.js +15 -2045
- 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,160 @@
|
|
|
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 AccordionContext = react.createContext(null);
|
|
11
|
+
function useAccordionContext() {
|
|
12
|
+
const context = react.useContext(AccordionContext);
|
|
13
|
+
if (!context) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
"Accordion compound components must be used within an <Accordion> provider."
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
20
|
+
var AccordionItemContext = react.createContext(null);
|
|
21
|
+
function useAccordionItemContext() {
|
|
22
|
+
const context = react.useContext(AccordionItemContext);
|
|
23
|
+
if (context === null) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
"AccordionTrigger and AccordionPanel must be used within an <AccordionItem>."
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return context;
|
|
29
|
+
}
|
|
30
|
+
function Accordion({ children, style, ...options }) {
|
|
31
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
32
|
+
const accordion = core.useAccordion(options);
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AccordionContext.Provider, { value: accordion, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
34
|
+
reactNative.View,
|
|
35
|
+
{
|
|
36
|
+
style: [
|
|
37
|
+
{
|
|
38
|
+
borderWidth: 1,
|
|
39
|
+
borderColor: t.entropixColorBorderDefault,
|
|
40
|
+
borderRadius: bt.entropixRadiusLg,
|
|
41
|
+
overflow: "hidden"
|
|
42
|
+
},
|
|
43
|
+
style
|
|
44
|
+
],
|
|
45
|
+
children
|
|
46
|
+
}
|
|
47
|
+
) });
|
|
48
|
+
}
|
|
49
|
+
function AccordionItem({
|
|
50
|
+
value,
|
|
51
|
+
isLast = false,
|
|
52
|
+
children,
|
|
53
|
+
style
|
|
54
|
+
}) {
|
|
55
|
+
const { tokens: t } = chunkBOUIB4OY_cjs.useTheme();
|
|
56
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AccordionItemContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
57
|
+
reactNative.View,
|
|
58
|
+
{
|
|
59
|
+
style: [
|
|
60
|
+
{
|
|
61
|
+
borderBottomWidth: isLast ? 0 : 1,
|
|
62
|
+
borderBottomColor: t.entropixColorBorderDefault
|
|
63
|
+
},
|
|
64
|
+
style
|
|
65
|
+
],
|
|
66
|
+
children
|
|
67
|
+
}
|
|
68
|
+
) });
|
|
69
|
+
}
|
|
70
|
+
function AccordionTrigger({
|
|
71
|
+
children,
|
|
72
|
+
style,
|
|
73
|
+
textStyle,
|
|
74
|
+
...rest
|
|
75
|
+
}) {
|
|
76
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
77
|
+
const itemKey = useAccordionItemContext();
|
|
78
|
+
const { getItemTriggerProps, isExpanded } = useAccordionContext();
|
|
79
|
+
const propGetterReturn = getItemTriggerProps(itemKey);
|
|
80
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
81
|
+
const expanded = isExpanded(itemKey);
|
|
82
|
+
const handlePress = react.useCallback(() => {
|
|
83
|
+
propGetterReturn.onAction?.();
|
|
84
|
+
}, [propGetterReturn.onAction]);
|
|
85
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
86
|
+
reactNative.Pressable,
|
|
87
|
+
{
|
|
88
|
+
...rnAccessibility,
|
|
89
|
+
...rest,
|
|
90
|
+
onPress: propGetterReturn.onAction ? handlePress : void 0,
|
|
91
|
+
style: [
|
|
92
|
+
{
|
|
93
|
+
flexDirection: "row",
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
justifyContent: "space-between",
|
|
96
|
+
paddingVertical: bt.entropixSpacing4,
|
|
97
|
+
paddingHorizontal: bt.entropixSpacing4
|
|
98
|
+
},
|
|
99
|
+
style
|
|
100
|
+
],
|
|
101
|
+
children: [
|
|
102
|
+
typeof children === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
103
|
+
reactNative.Text,
|
|
104
|
+
{
|
|
105
|
+
style: [
|
|
106
|
+
{
|
|
107
|
+
fontSize: bt.entropixFontSizeSm,
|
|
108
|
+
fontWeight: "500",
|
|
109
|
+
color: t.entropixColorTextPrimary,
|
|
110
|
+
flex: 1
|
|
111
|
+
},
|
|
112
|
+
textStyle
|
|
113
|
+
],
|
|
114
|
+
children
|
|
115
|
+
}
|
|
116
|
+
) : children,
|
|
117
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
118
|
+
reactNative.Text,
|
|
119
|
+
{
|
|
120
|
+
style: {
|
|
121
|
+
fontSize: 12,
|
|
122
|
+
color: t.entropixColorTextSecondary,
|
|
123
|
+
marginLeft: bt.entropixSpacing2
|
|
124
|
+
},
|
|
125
|
+
children: expanded ? "\u2212" : "+"
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
function AccordionPanel({ children, style }) {
|
|
133
|
+
const { baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
134
|
+
const itemKey = useAccordionItemContext();
|
|
135
|
+
const { getItemPanelProps, isExpanded } = useAccordionContext();
|
|
136
|
+
const propGetterReturn = getItemPanelProps(itemKey);
|
|
137
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
138
|
+
if (!isExpanded(itemKey)) return null;
|
|
139
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
140
|
+
reactNative.View,
|
|
141
|
+
{
|
|
142
|
+
...rnAccessibility,
|
|
143
|
+
style: [
|
|
144
|
+
{
|
|
145
|
+
paddingHorizontal: bt.entropixSpacing4,
|
|
146
|
+
paddingBottom: bt.entropixSpacing4
|
|
147
|
+
},
|
|
148
|
+
style
|
|
149
|
+
],
|
|
150
|
+
children
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
exports.Accordion = Accordion;
|
|
156
|
+
exports.AccordionItem = AccordionItem;
|
|
157
|
+
exports.AccordionPanel = AccordionPanel;
|
|
158
|
+
exports.AccordionTrigger = AccordionTrigger;
|
|
159
|
+
//# sourceMappingURL=chunk-Q7TEJ62Q.cjs.map
|
|
160
|
+
//# sourceMappingURL=chunk-Q7TEJ62Q.cjs.map
|
|
@@ -0,0 +1,146 @@
|
|
|
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 RadioGroupContext = react.createContext(null);
|
|
11
|
+
function useRadioGroupContext() {
|
|
12
|
+
const context = react.useContext(RadioGroupContext);
|
|
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
|
+
label,
|
|
22
|
+
style,
|
|
23
|
+
textStyle,
|
|
24
|
+
children,
|
|
25
|
+
testID,
|
|
26
|
+
...options
|
|
27
|
+
}) {
|
|
28
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
29
|
+
const radioGroup = core.useRadioGroup(options);
|
|
30
|
+
const propGetterReturn = radioGroup.getRadioGroupProps();
|
|
31
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
32
|
+
if (label) {
|
|
33
|
+
rnAccessibility.accessibilityLabel = label;
|
|
34
|
+
}
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RadioGroupContext.Provider, { value: radioGroup, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
36
|
+
reactNative.View,
|
|
37
|
+
{
|
|
38
|
+
...rnAccessibility,
|
|
39
|
+
testID,
|
|
40
|
+
style: [
|
|
41
|
+
{
|
|
42
|
+
gap: bt.entropixSpacing2
|
|
43
|
+
},
|
|
44
|
+
style
|
|
45
|
+
],
|
|
46
|
+
children: [
|
|
47
|
+
label ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
48
|
+
reactNative.Text,
|
|
49
|
+
{
|
|
50
|
+
style: [
|
|
51
|
+
{
|
|
52
|
+
fontSize: bt.entropixFontSizeSm,
|
|
53
|
+
fontWeight: "500",
|
|
54
|
+
color: t.entropixColorTextPrimary
|
|
55
|
+
},
|
|
56
|
+
textStyle
|
|
57
|
+
],
|
|
58
|
+
children: label
|
|
59
|
+
}
|
|
60
|
+
) : null,
|
|
61
|
+
children
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
) });
|
|
65
|
+
}
|
|
66
|
+
function RadioItem({
|
|
67
|
+
value,
|
|
68
|
+
disabled,
|
|
69
|
+
style,
|
|
70
|
+
textStyle,
|
|
71
|
+
children,
|
|
72
|
+
...rest
|
|
73
|
+
}) {
|
|
74
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
75
|
+
const { getRadioProps } = useRadioGroupContext();
|
|
76
|
+
const propGetterReturn = getRadioProps(value, { disabled });
|
|
77
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
78
|
+
const isChecked = propGetterReturn.accessibility.checked === true;
|
|
79
|
+
const isDisabled = propGetterReturn.accessibility.disabled === true;
|
|
80
|
+
const handlePress = react.useCallback(() => {
|
|
81
|
+
propGetterReturn.onAction?.();
|
|
82
|
+
}, [propGetterReturn.onAction]);
|
|
83
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
84
|
+
reactNative.Pressable,
|
|
85
|
+
{
|
|
86
|
+
...rnAccessibility,
|
|
87
|
+
...rest,
|
|
88
|
+
disabled: isDisabled,
|
|
89
|
+
onPress: isDisabled ? void 0 : handlePress,
|
|
90
|
+
style: [
|
|
91
|
+
{
|
|
92
|
+
flexDirection: "row",
|
|
93
|
+
alignItems: "center",
|
|
94
|
+
gap: bt.entropixSpacing2
|
|
95
|
+
},
|
|
96
|
+
isDisabled && { opacity: 0.5 },
|
|
97
|
+
style
|
|
98
|
+
],
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
101
|
+
reactNative.View,
|
|
102
|
+
{
|
|
103
|
+
style: {
|
|
104
|
+
width: 20,
|
|
105
|
+
height: 20,
|
|
106
|
+
borderRadius: 10,
|
|
107
|
+
borderWidth: 2,
|
|
108
|
+
borderColor: isChecked ? t.entropixColorActionPrimaryDefault : t.entropixColorBorderDefault,
|
|
109
|
+
alignItems: "center",
|
|
110
|
+
justifyContent: "center"
|
|
111
|
+
},
|
|
112
|
+
children: isChecked ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
113
|
+
reactNative.View,
|
|
114
|
+
{
|
|
115
|
+
style: {
|
|
116
|
+
width: 10,
|
|
117
|
+
height: 10,
|
|
118
|
+
borderRadius: 5,
|
|
119
|
+
backgroundColor: t.entropixColorActionPrimaryDefault
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
) : null
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
typeof children === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
126
|
+
reactNative.Text,
|
|
127
|
+
{
|
|
128
|
+
style: [
|
|
129
|
+
{
|
|
130
|
+
fontSize: bt.entropixFontSizeSm,
|
|
131
|
+
color: t.entropixColorTextPrimary
|
|
132
|
+
},
|
|
133
|
+
textStyle
|
|
134
|
+
],
|
|
135
|
+
children
|
|
136
|
+
}
|
|
137
|
+
) : children
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
exports.RadioGroup = RadioGroup;
|
|
144
|
+
exports.RadioItem = RadioItem;
|
|
145
|
+
//# sourceMappingURL=chunk-THX22NZW.cjs.map
|
|
146
|
+
//# sourceMappingURL=chunk-THX22NZW.cjs.map
|
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
var KEYBOARD_TYPE_MAP = {
|
|
9
|
+
text: "default",
|
|
10
|
+
email: "email-address",
|
|
11
|
+
password: "default",
|
|
12
|
+
number: "numeric",
|
|
13
|
+
tel: "phone-pad",
|
|
14
|
+
url: "url",
|
|
15
|
+
search: "default"
|
|
16
|
+
};
|
|
17
|
+
function Input({
|
|
18
|
+
value,
|
|
19
|
+
defaultValue,
|
|
20
|
+
onChange,
|
|
21
|
+
disabled,
|
|
22
|
+
readOnly,
|
|
23
|
+
required,
|
|
24
|
+
invalid,
|
|
25
|
+
label,
|
|
26
|
+
helperText,
|
|
27
|
+
errorMessage,
|
|
28
|
+
placeholder,
|
|
29
|
+
type = "text",
|
|
30
|
+
size = "md",
|
|
31
|
+
style,
|
|
32
|
+
inputStyle,
|
|
33
|
+
textStyle,
|
|
34
|
+
testID,
|
|
35
|
+
variant: _variant
|
|
36
|
+
}) {
|
|
37
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
38
|
+
const {
|
|
39
|
+
value: inputValue,
|
|
40
|
+
isDisabled,
|
|
41
|
+
isReadOnly,
|
|
42
|
+
isInvalid,
|
|
43
|
+
setValue,
|
|
44
|
+
getInputProps
|
|
45
|
+
} = useInput({
|
|
46
|
+
value,
|
|
47
|
+
defaultValue,
|
|
48
|
+
onChange,
|
|
49
|
+
disabled,
|
|
50
|
+
readOnly,
|
|
51
|
+
required,
|
|
52
|
+
invalid,
|
|
53
|
+
type,
|
|
54
|
+
placeholder
|
|
55
|
+
});
|
|
56
|
+
const propGetterReturn = getInputProps();
|
|
57
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
58
|
+
const handleChangeText = useCallback(
|
|
59
|
+
(text) => {
|
|
60
|
+
setValue(text);
|
|
61
|
+
},
|
|
62
|
+
[setValue]
|
|
63
|
+
);
|
|
64
|
+
const sizeStyles = getSizeStyles(size, bt);
|
|
65
|
+
const showError = isInvalid && errorMessage;
|
|
66
|
+
return /* @__PURE__ */ jsxs(View, { style: [{ gap: bt.entropixSpacing1 }, style], children: [
|
|
67
|
+
label ? /* @__PURE__ */ jsxs(
|
|
68
|
+
Text,
|
|
69
|
+
{
|
|
70
|
+
style: [
|
|
71
|
+
{
|
|
72
|
+
fontSize: sizeStyles.labelFontSize,
|
|
73
|
+
fontWeight: "500",
|
|
74
|
+
color: t.entropixColorTextPrimary
|
|
75
|
+
},
|
|
76
|
+
textStyle
|
|
77
|
+
],
|
|
78
|
+
children: [
|
|
79
|
+
label,
|
|
80
|
+
required ? " *" : ""
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
) : null,
|
|
84
|
+
/* @__PURE__ */ jsx(
|
|
85
|
+
TextInput,
|
|
86
|
+
{
|
|
87
|
+
...rnAccessibility,
|
|
88
|
+
testID,
|
|
89
|
+
value: inputValue,
|
|
90
|
+
onChangeText: handleChangeText,
|
|
91
|
+
placeholder,
|
|
92
|
+
placeholderTextColor: t.entropixColorTextTertiary,
|
|
93
|
+
editable: !isDisabled && !isReadOnly,
|
|
94
|
+
secureTextEntry: type === "password",
|
|
95
|
+
keyboardType: KEYBOARD_TYPE_MAP[type] ?? "default",
|
|
96
|
+
style: [
|
|
97
|
+
{
|
|
98
|
+
paddingVertical: sizeStyles.paddingVertical,
|
|
99
|
+
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
100
|
+
fontSize: sizeStyles.fontSize,
|
|
101
|
+
borderWidth: 1,
|
|
102
|
+
borderColor: showError ? t.entropixColorBorderDanger : t.entropixColorBorderDefault,
|
|
103
|
+
borderRadius: bt.entropixRadiusMd,
|
|
104
|
+
backgroundColor: t.entropixColorBgPrimary,
|
|
105
|
+
color: t.entropixColorTextPrimary
|
|
106
|
+
},
|
|
107
|
+
isDisabled && { opacity: 0.5 },
|
|
108
|
+
inputStyle
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
showError ? /* @__PURE__ */ jsx(
|
|
113
|
+
Text,
|
|
114
|
+
{
|
|
115
|
+
style: [
|
|
116
|
+
{
|
|
117
|
+
fontSize: sizeStyles.helperFontSize,
|
|
118
|
+
color: t.entropixColorTextDanger
|
|
119
|
+
},
|
|
120
|
+
textStyle
|
|
121
|
+
],
|
|
122
|
+
accessibilityRole: "alert",
|
|
123
|
+
accessibilityLiveRegion: "polite",
|
|
124
|
+
children: errorMessage
|
|
125
|
+
}
|
|
126
|
+
) : helperText ? /* @__PURE__ */ jsx(
|
|
127
|
+
Text,
|
|
128
|
+
{
|
|
129
|
+
style: [
|
|
130
|
+
{
|
|
131
|
+
fontSize: sizeStyles.helperFontSize,
|
|
132
|
+
color: t.entropixColorTextSecondary
|
|
133
|
+
},
|
|
134
|
+
textStyle
|
|
135
|
+
],
|
|
136
|
+
children: helperText
|
|
137
|
+
}
|
|
138
|
+
) : null
|
|
139
|
+
] });
|
|
140
|
+
}
|
|
141
|
+
function getSizeStyles(size, bt) {
|
|
142
|
+
switch (size) {
|
|
143
|
+
case "sm":
|
|
144
|
+
return {
|
|
145
|
+
paddingVertical: bt.entropixSpacing1,
|
|
146
|
+
paddingHorizontal: bt.entropixSpacing2,
|
|
147
|
+
fontSize: bt.entropixFontSizeXs,
|
|
148
|
+
labelFontSize: bt.entropixFontSizeXs,
|
|
149
|
+
helperFontSize: bt.entropixFontSizeXs - 1
|
|
150
|
+
};
|
|
151
|
+
case "lg":
|
|
152
|
+
return {
|
|
153
|
+
paddingVertical: bt.entropixSpacing3,
|
|
154
|
+
paddingHorizontal: bt.entropixSpacing4,
|
|
155
|
+
fontSize: bt.entropixFontSizeBase,
|
|
156
|
+
labelFontSize: bt.entropixFontSizeBase,
|
|
157
|
+
helperFontSize: bt.entropixFontSizeSm
|
|
158
|
+
};
|
|
159
|
+
default:
|
|
160
|
+
return {
|
|
161
|
+
paddingVertical: bt.entropixSpacing2,
|
|
162
|
+
paddingHorizontal: bt.entropixSpacing3,
|
|
163
|
+
fontSize: bt.entropixFontSizeSm,
|
|
164
|
+
labelFontSize: bt.entropixFontSizeSm,
|
|
165
|
+
helperFontSize: bt.entropixFontSizeXs
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export { Input };
|
|
171
|
+
//# sourceMappingURL=chunk-UHVTF2Y4.js.map
|
|
172
|
+
//# sourceMappingURL=chunk-UHVTF2Y4.js.map
|
|
@@ -0,0 +1,166 @@
|
|
|
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 Textarea({
|
|
11
|
+
value,
|
|
12
|
+
defaultValue,
|
|
13
|
+
onChange,
|
|
14
|
+
disabled,
|
|
15
|
+
readOnly,
|
|
16
|
+
required,
|
|
17
|
+
invalid,
|
|
18
|
+
label,
|
|
19
|
+
helperText,
|
|
20
|
+
errorMessage,
|
|
21
|
+
placeholder,
|
|
22
|
+
numberOfLines = 4,
|
|
23
|
+
size = "md",
|
|
24
|
+
style,
|
|
25
|
+
inputStyle,
|
|
26
|
+
textStyle,
|
|
27
|
+
testID
|
|
28
|
+
}) {
|
|
29
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
30
|
+
const {
|
|
31
|
+
value: inputValue,
|
|
32
|
+
isDisabled,
|
|
33
|
+
isReadOnly,
|
|
34
|
+
isInvalid,
|
|
35
|
+
setValue,
|
|
36
|
+
getInputProps
|
|
37
|
+
} = core.useInput({
|
|
38
|
+
value,
|
|
39
|
+
defaultValue,
|
|
40
|
+
onChange,
|
|
41
|
+
disabled,
|
|
42
|
+
readOnly,
|
|
43
|
+
required,
|
|
44
|
+
invalid,
|
|
45
|
+
type: "text",
|
|
46
|
+
placeholder
|
|
47
|
+
});
|
|
48
|
+
const propGetterReturn = getInputProps();
|
|
49
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
50
|
+
const handleChangeText = react.useCallback(
|
|
51
|
+
(text) => {
|
|
52
|
+
setValue(text);
|
|
53
|
+
},
|
|
54
|
+
[setValue]
|
|
55
|
+
);
|
|
56
|
+
const sizeStyles = getSizeStyles(size, bt);
|
|
57
|
+
const showError = isInvalid && errorMessage;
|
|
58
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [{ gap: bt.entropixSpacing1 }, style], children: [
|
|
59
|
+
label ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
60
|
+
reactNative.Text,
|
|
61
|
+
{
|
|
62
|
+
style: [
|
|
63
|
+
{
|
|
64
|
+
fontSize: sizeStyles.labelFontSize,
|
|
65
|
+
fontWeight: "500",
|
|
66
|
+
color: t.entropixColorTextPrimary
|
|
67
|
+
},
|
|
68
|
+
textStyle
|
|
69
|
+
],
|
|
70
|
+
children: [
|
|
71
|
+
label,
|
|
72
|
+
required ? " *" : ""
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
) : null,
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
77
|
+
reactNative.TextInput,
|
|
78
|
+
{
|
|
79
|
+
...rnAccessibility,
|
|
80
|
+
testID,
|
|
81
|
+
value: inputValue,
|
|
82
|
+
onChangeText: handleChangeText,
|
|
83
|
+
placeholder,
|
|
84
|
+
placeholderTextColor: t.entropixColorTextTertiary,
|
|
85
|
+
editable: !isDisabled && !isReadOnly,
|
|
86
|
+
multiline: true,
|
|
87
|
+
numberOfLines,
|
|
88
|
+
textAlignVertical: "top",
|
|
89
|
+
style: [
|
|
90
|
+
{
|
|
91
|
+
paddingVertical: sizeStyles.paddingVertical,
|
|
92
|
+
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
93
|
+
fontSize: sizeStyles.fontSize,
|
|
94
|
+
borderWidth: 1,
|
|
95
|
+
borderColor: showError ? t.entropixColorBorderDanger : t.entropixColorBorderDefault,
|
|
96
|
+
borderRadius: bt.entropixRadiusMd,
|
|
97
|
+
backgroundColor: t.entropixColorBgPrimary,
|
|
98
|
+
color: t.entropixColorTextPrimary,
|
|
99
|
+
minHeight: numberOfLines * (sizeStyles.fontSize + 8)
|
|
100
|
+
},
|
|
101
|
+
isDisabled && { opacity: 0.5 },
|
|
102
|
+
inputStyle
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
showError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
107
|
+
reactNative.Text,
|
|
108
|
+
{
|
|
109
|
+
style: [
|
|
110
|
+
{
|
|
111
|
+
fontSize: sizeStyles.helperFontSize,
|
|
112
|
+
color: t.entropixColorTextDanger
|
|
113
|
+
},
|
|
114
|
+
textStyle
|
|
115
|
+
],
|
|
116
|
+
accessibilityRole: "alert",
|
|
117
|
+
accessibilityLiveRegion: "polite",
|
|
118
|
+
children: errorMessage
|
|
119
|
+
}
|
|
120
|
+
) : helperText ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
121
|
+
reactNative.Text,
|
|
122
|
+
{
|
|
123
|
+
style: [
|
|
124
|
+
{
|
|
125
|
+
fontSize: sizeStyles.helperFontSize,
|
|
126
|
+
color: t.entropixColorTextSecondary
|
|
127
|
+
},
|
|
128
|
+
textStyle
|
|
129
|
+
],
|
|
130
|
+
children: helperText
|
|
131
|
+
}
|
|
132
|
+
) : null
|
|
133
|
+
] });
|
|
134
|
+
}
|
|
135
|
+
function getSizeStyles(size, bt) {
|
|
136
|
+
switch (size) {
|
|
137
|
+
case "sm":
|
|
138
|
+
return {
|
|
139
|
+
paddingVertical: bt.entropixSpacing1,
|
|
140
|
+
paddingHorizontal: bt.entropixSpacing2,
|
|
141
|
+
fontSize: bt.entropixFontSizeXs,
|
|
142
|
+
labelFontSize: bt.entropixFontSizeXs,
|
|
143
|
+
helperFontSize: bt.entropixFontSizeXs - 1
|
|
144
|
+
};
|
|
145
|
+
case "lg":
|
|
146
|
+
return {
|
|
147
|
+
paddingVertical: bt.entropixSpacing3,
|
|
148
|
+
paddingHorizontal: bt.entropixSpacing4,
|
|
149
|
+
fontSize: bt.entropixFontSizeBase,
|
|
150
|
+
labelFontSize: bt.entropixFontSizeBase,
|
|
151
|
+
helperFontSize: bt.entropixFontSizeSm
|
|
152
|
+
};
|
|
153
|
+
default:
|
|
154
|
+
return {
|
|
155
|
+
paddingVertical: bt.entropixSpacing2,
|
|
156
|
+
paddingHorizontal: bt.entropixSpacing3,
|
|
157
|
+
fontSize: bt.entropixFontSizeSm,
|
|
158
|
+
labelFontSize: bt.entropixFontSizeSm,
|
|
159
|
+
helperFontSize: bt.entropixFontSizeXs
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
exports.Textarea = Textarea;
|
|
165
|
+
//# sourceMappingURL=chunk-UYXJHKYK.cjs.map
|
|
166
|
+
//# sourceMappingURL=chunk-UYXJHKYK.cjs.map
|