@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,95 @@
|
|
|
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 Toggle(props) {
|
|
11
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ToggleInner, { ...props, role: "checkbox" });
|
|
12
|
+
}
|
|
13
|
+
function ToggleInner({
|
|
14
|
+
checked,
|
|
15
|
+
defaultChecked,
|
|
16
|
+
onChange,
|
|
17
|
+
disabled,
|
|
18
|
+
label,
|
|
19
|
+
role = "checkbox",
|
|
20
|
+
style,
|
|
21
|
+
textStyle,
|
|
22
|
+
children,
|
|
23
|
+
...rest
|
|
24
|
+
}) {
|
|
25
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
26
|
+
const { isDisabled, getToggleProps } = core.useToggle({
|
|
27
|
+
checked,
|
|
28
|
+
defaultChecked,
|
|
29
|
+
onChange,
|
|
30
|
+
disabled,
|
|
31
|
+
role
|
|
32
|
+
});
|
|
33
|
+
const propGetterReturn = getToggleProps();
|
|
34
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
35
|
+
const isChecked = propGetterReturn.accessibility.checked === true;
|
|
36
|
+
if (label) {
|
|
37
|
+
rnAccessibility.accessibilityLabel = label;
|
|
38
|
+
}
|
|
39
|
+
const handlePress = react.useCallback(() => {
|
|
40
|
+
propGetterReturn.onAction?.();
|
|
41
|
+
}, [propGetterReturn.onAction]);
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
43
|
+
reactNative.Pressable,
|
|
44
|
+
{
|
|
45
|
+
...rnAccessibility,
|
|
46
|
+
...rest,
|
|
47
|
+
disabled: isDisabled,
|
|
48
|
+
onPress: isDisabled ? void 0 : handlePress,
|
|
49
|
+
style: [
|
|
50
|
+
{
|
|
51
|
+
flexDirection: "row",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
justifyContent: "center",
|
|
54
|
+
paddingVertical: bt.entropixSpacing2,
|
|
55
|
+
paddingHorizontal: bt.entropixSpacing3,
|
|
56
|
+
borderWidth: 1,
|
|
57
|
+
borderColor: isChecked ? "transparent" : t.entropixColorBorderDefault,
|
|
58
|
+
borderRadius: bt.entropixRadiusMd,
|
|
59
|
+
backgroundColor: isChecked ? t.entropixColorActionPrimaryDefault : t.entropixColorBgPrimary
|
|
60
|
+
},
|
|
61
|
+
isDisabled && { opacity: 0.5 },
|
|
62
|
+
style
|
|
63
|
+
],
|
|
64
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
65
|
+
reactNative.Text,
|
|
66
|
+
{
|
|
67
|
+
style: [
|
|
68
|
+
{
|
|
69
|
+
fontSize: bt.entropixFontSizeSm,
|
|
70
|
+
fontWeight: "500",
|
|
71
|
+
color: isChecked ? t.entropixColorTextInverse : t.entropixColorTextPrimary
|
|
72
|
+
},
|
|
73
|
+
textStyle
|
|
74
|
+
],
|
|
75
|
+
children
|
|
76
|
+
}
|
|
77
|
+
) : children != null ? children : /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
|
+
reactNative.Text,
|
|
79
|
+
{
|
|
80
|
+
style: {
|
|
81
|
+
fontSize: bt.entropixFontSizeSm,
|
|
82
|
+
fontWeight: "500",
|
|
83
|
+
color: isChecked ? t.entropixColorTextInverse : t.entropixColorTextPrimary
|
|
84
|
+
},
|
|
85
|
+
children: isChecked ? "On" : "Off"
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
exports.Toggle = Toggle;
|
|
93
|
+
exports.ToggleInner = ToggleInner;
|
|
94
|
+
//# sourceMappingURL=chunk-OMKUPSHJ.cjs.map
|
|
95
|
+
//# sourceMappingURL=chunk-OMKUPSHJ.cjs.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/utils/map-accessibility-to-rn.ts
|
|
4
|
+
var RN_ROLE_MAP = {
|
|
5
|
+
button: "button",
|
|
6
|
+
checkbox: "checkbox",
|
|
7
|
+
switch: "switch",
|
|
8
|
+
dialog: "none",
|
|
9
|
+
// Modal component handles dialog semantics
|
|
10
|
+
alertdialog: "alert",
|
|
11
|
+
link: "link",
|
|
12
|
+
tab: "tab",
|
|
13
|
+
tablist: "tablist",
|
|
14
|
+
menu: "menu",
|
|
15
|
+
menuitem: "menuitem",
|
|
16
|
+
radio: "radio",
|
|
17
|
+
radiogroup: "radiogroup",
|
|
18
|
+
slider: "adjustable",
|
|
19
|
+
spinbutton: "spinbutton",
|
|
20
|
+
textbox: "text",
|
|
21
|
+
combobox: "combobox",
|
|
22
|
+
progressbar: "progressbar",
|
|
23
|
+
alert: "alert",
|
|
24
|
+
status: "text",
|
|
25
|
+
tooltip: "text",
|
|
26
|
+
none: "none",
|
|
27
|
+
presentation: "none"
|
|
28
|
+
};
|
|
29
|
+
function mapAccessibilityToRN(props) {
|
|
30
|
+
const result = { accessible: true };
|
|
31
|
+
if (props.role) {
|
|
32
|
+
result.accessibilityRole = RN_ROLE_MAP[props.role] ?? props.role;
|
|
33
|
+
}
|
|
34
|
+
if (props.label) {
|
|
35
|
+
result.accessibilityLabel = props.label;
|
|
36
|
+
}
|
|
37
|
+
if (props.describedBy) {
|
|
38
|
+
result.accessibilityHint = props.describedBy;
|
|
39
|
+
}
|
|
40
|
+
if (props.labelledBy) {
|
|
41
|
+
result.accessibilityLabelledBy = props.labelledBy;
|
|
42
|
+
}
|
|
43
|
+
const state = {};
|
|
44
|
+
let hasState = false;
|
|
45
|
+
if (props.disabled !== void 0) {
|
|
46
|
+
state.disabled = props.disabled;
|
|
47
|
+
hasState = true;
|
|
48
|
+
}
|
|
49
|
+
if (props.expanded !== void 0) {
|
|
50
|
+
state.expanded = props.expanded;
|
|
51
|
+
hasState = true;
|
|
52
|
+
}
|
|
53
|
+
if (props.selected !== void 0) {
|
|
54
|
+
state.selected = props.selected;
|
|
55
|
+
hasState = true;
|
|
56
|
+
}
|
|
57
|
+
if (props.checked !== void 0) {
|
|
58
|
+
state.checked = props.checked;
|
|
59
|
+
hasState = true;
|
|
60
|
+
}
|
|
61
|
+
if (props.busy !== void 0) {
|
|
62
|
+
state.busy = props.busy;
|
|
63
|
+
hasState = true;
|
|
64
|
+
}
|
|
65
|
+
if (hasState) {
|
|
66
|
+
result.accessibilityState = state;
|
|
67
|
+
}
|
|
68
|
+
if (props.valueNow !== void 0 || props.valueMin !== void 0 || props.valueMax !== void 0 || props.valueText !== void 0) {
|
|
69
|
+
result.accessibilityValue = {};
|
|
70
|
+
if (props.valueNow !== void 0)
|
|
71
|
+
result.accessibilityValue.now = props.valueNow;
|
|
72
|
+
if (props.valueMin !== void 0)
|
|
73
|
+
result.accessibilityValue.min = props.valueMin;
|
|
74
|
+
if (props.valueMax !== void 0)
|
|
75
|
+
result.accessibilityValue.max = props.valueMax;
|
|
76
|
+
if (props.valueText !== void 0)
|
|
77
|
+
result.accessibilityValue.text = props.valueText;
|
|
78
|
+
}
|
|
79
|
+
if (props.live) {
|
|
80
|
+
result.accessibilityLiveRegion = props.live === "off" ? "none" : props.live;
|
|
81
|
+
}
|
|
82
|
+
if (props.hidden) {
|
|
83
|
+
result.accessibilityElementsHidden = true;
|
|
84
|
+
result.importantForAccessibility = "no-hide-descendants";
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
exports.mapAccessibilityToRN = mapAccessibilityToRN;
|
|
90
|
+
//# sourceMappingURL=chunk-P5NAXMSC.cjs.map
|
|
91
|
+
//# sourceMappingURL=chunk-P5NAXMSC.cjs.map
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkP5NAXMSC_cjs = require('./chunk-P5NAXMSC.cjs');
|
|
4
|
+
var chunkBOUIB4OY_cjs = require('./chunk-BOUIB4OY.cjs');
|
|
5
|
+
var core = require('@entropix/core');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var reactNative = require('react-native');
|
|
9
|
+
|
|
10
|
+
var DialogContext = react.createContext(null);
|
|
11
|
+
function useDialogContext() {
|
|
12
|
+
const context = react.useContext(DialogContext);
|
|
13
|
+
if (!context) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
"Dialog compound components must be used within a <Dialog> provider."
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
20
|
+
function Dialog({
|
|
21
|
+
children,
|
|
22
|
+
isOpen,
|
|
23
|
+
defaultOpen,
|
|
24
|
+
onOpenChange,
|
|
25
|
+
closeOnOverlayPress,
|
|
26
|
+
closeOnEscape,
|
|
27
|
+
modal,
|
|
28
|
+
role
|
|
29
|
+
}) {
|
|
30
|
+
const dialog = core.useDialog({
|
|
31
|
+
isOpen,
|
|
32
|
+
defaultOpen,
|
|
33
|
+
onOpenChange,
|
|
34
|
+
closeOnOverlayPress,
|
|
35
|
+
closeOnEscape,
|
|
36
|
+
modal,
|
|
37
|
+
role
|
|
38
|
+
});
|
|
39
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DialogContext.Provider, { value: dialog, children });
|
|
40
|
+
}
|
|
41
|
+
function DialogTrigger({
|
|
42
|
+
children,
|
|
43
|
+
style,
|
|
44
|
+
...rest
|
|
45
|
+
}) {
|
|
46
|
+
const { getTriggerProps } = useDialogContext();
|
|
47
|
+
const propGetterReturn = getTriggerProps();
|
|
48
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
49
|
+
const handlePress = react.useCallback(() => {
|
|
50
|
+
propGetterReturn.onAction?.();
|
|
51
|
+
}, [propGetterReturn.onAction]);
|
|
52
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
53
|
+
reactNative.Pressable,
|
|
54
|
+
{
|
|
55
|
+
...rnAccessibility,
|
|
56
|
+
...rest,
|
|
57
|
+
onPress: handlePress,
|
|
58
|
+
style,
|
|
59
|
+
children
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
function DialogContent({
|
|
64
|
+
children,
|
|
65
|
+
style,
|
|
66
|
+
cardStyle,
|
|
67
|
+
animationType = "fade",
|
|
68
|
+
transparent = true,
|
|
69
|
+
...rest
|
|
70
|
+
}) {
|
|
71
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
72
|
+
const { isOpen, close, ids, getContentProps } = useDialogContext();
|
|
73
|
+
const propGetterReturn = getContentProps();
|
|
74
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
75
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
76
|
+
reactNative.Modal,
|
|
77
|
+
{
|
|
78
|
+
visible: isOpen,
|
|
79
|
+
transparent,
|
|
80
|
+
animationType,
|
|
81
|
+
onRequestClose: close,
|
|
82
|
+
supportedOrientations: ["portrait", "landscape"],
|
|
83
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
84
|
+
reactNative.View,
|
|
85
|
+
{
|
|
86
|
+
...rest,
|
|
87
|
+
style: [
|
|
88
|
+
{
|
|
89
|
+
flex: 1,
|
|
90
|
+
justifyContent: "center",
|
|
91
|
+
alignItems: "center",
|
|
92
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
93
|
+
},
|
|
94
|
+
style
|
|
95
|
+
],
|
|
96
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
97
|
+
reactNative.View,
|
|
98
|
+
{
|
|
99
|
+
...rnAccessibility,
|
|
100
|
+
nativeID: ids.content,
|
|
101
|
+
style: [
|
|
102
|
+
{
|
|
103
|
+
backgroundColor: t.entropixColorBgPrimary,
|
|
104
|
+
borderRadius: bt.entropixRadiusLg,
|
|
105
|
+
padding: bt.entropixSpacing6,
|
|
106
|
+
width: "90%",
|
|
107
|
+
maxWidth: 480,
|
|
108
|
+
shadowColor: "#000",
|
|
109
|
+
shadowOffset: { width: 0, height: 4 },
|
|
110
|
+
shadowOpacity: 0.15,
|
|
111
|
+
shadowRadius: 12,
|
|
112
|
+
elevation: 8
|
|
113
|
+
},
|
|
114
|
+
cardStyle
|
|
115
|
+
],
|
|
116
|
+
children
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function DialogTitle({ children, style, ...rest }) {
|
|
125
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
126
|
+
const { ids } = useDialogContext();
|
|
127
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
128
|
+
reactNative.Text,
|
|
129
|
+
{
|
|
130
|
+
...rest,
|
|
131
|
+
nativeID: ids.title,
|
|
132
|
+
style: [
|
|
133
|
+
{
|
|
134
|
+
fontSize: 18,
|
|
135
|
+
fontWeight: "600",
|
|
136
|
+
color: t.entropixColorTextPrimary,
|
|
137
|
+
marginBottom: bt.entropixSpacing2
|
|
138
|
+
},
|
|
139
|
+
style
|
|
140
|
+
],
|
|
141
|
+
accessibilityRole: "header",
|
|
142
|
+
children
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
function DialogDescription({
|
|
147
|
+
children,
|
|
148
|
+
style,
|
|
149
|
+
...rest
|
|
150
|
+
}) {
|
|
151
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
152
|
+
const { ids } = useDialogContext();
|
|
153
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
154
|
+
reactNative.Text,
|
|
155
|
+
{
|
|
156
|
+
...rest,
|
|
157
|
+
nativeID: ids.description,
|
|
158
|
+
style: [
|
|
159
|
+
{
|
|
160
|
+
fontSize: bt.entropixFontSizeSm,
|
|
161
|
+
color: t.entropixColorTextSecondary,
|
|
162
|
+
lineHeight: 20,
|
|
163
|
+
marginBottom: bt.entropixSpacing4
|
|
164
|
+
},
|
|
165
|
+
style
|
|
166
|
+
],
|
|
167
|
+
children
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
function DialogClose({ children, style, ...rest }) {
|
|
172
|
+
const { tokens: t, baseTokens: bt } = chunkBOUIB4OY_cjs.useTheme();
|
|
173
|
+
const { getCloseProps } = useDialogContext();
|
|
174
|
+
const propGetterReturn = getCloseProps();
|
|
175
|
+
const rnAccessibility = chunkP5NAXMSC_cjs.mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
176
|
+
const handlePress = react.useCallback(() => {
|
|
177
|
+
propGetterReturn.onAction?.();
|
|
178
|
+
}, [propGetterReturn.onAction]);
|
|
179
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
180
|
+
reactNative.Pressable,
|
|
181
|
+
{
|
|
182
|
+
...rnAccessibility,
|
|
183
|
+
...rest,
|
|
184
|
+
onPress: handlePress,
|
|
185
|
+
style: [
|
|
186
|
+
{
|
|
187
|
+
position: "absolute",
|
|
188
|
+
top: bt.entropixSpacing3,
|
|
189
|
+
right: bt.entropixSpacing3,
|
|
190
|
+
width: 32,
|
|
191
|
+
height: 32,
|
|
192
|
+
alignItems: "center",
|
|
193
|
+
justifyContent: "center",
|
|
194
|
+
borderRadius: bt.entropixRadiusSm
|
|
195
|
+
},
|
|
196
|
+
style
|
|
197
|
+
],
|
|
198
|
+
accessibilityRole: "button",
|
|
199
|
+
children: children ?? /* @__PURE__ */ jsxRuntime.jsx(
|
|
200
|
+
reactNative.Text,
|
|
201
|
+
{
|
|
202
|
+
style: {
|
|
203
|
+
fontSize: 16,
|
|
204
|
+
color: t.entropixColorTextSecondary
|
|
205
|
+
},
|
|
206
|
+
children: "\u2715"
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
function DialogOverlay({ style, testID }) {
|
|
213
|
+
const { isOpen, getOverlayProps } = useDialogContext();
|
|
214
|
+
const propGetterReturn = getOverlayProps();
|
|
215
|
+
const handlePress = react.useCallback(() => {
|
|
216
|
+
propGetterReturn.onAction?.();
|
|
217
|
+
}, [propGetterReturn.onAction]);
|
|
218
|
+
if (!isOpen) return null;
|
|
219
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
220
|
+
reactNative.Pressable,
|
|
221
|
+
{
|
|
222
|
+
testID,
|
|
223
|
+
accessible: false,
|
|
224
|
+
importantForAccessibility: "no",
|
|
225
|
+
onPress: propGetterReturn.onAction ? handlePress : void 0,
|
|
226
|
+
style: [
|
|
227
|
+
{
|
|
228
|
+
...reactNative.StyleSheet.absoluteFillObject,
|
|
229
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
230
|
+
},
|
|
231
|
+
style
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
exports.Dialog = Dialog;
|
|
238
|
+
exports.DialogClose = DialogClose;
|
|
239
|
+
exports.DialogContent = DialogContent;
|
|
240
|
+
exports.DialogDescription = DialogDescription;
|
|
241
|
+
exports.DialogOverlay = DialogOverlay;
|
|
242
|
+
exports.DialogTitle = DialogTitle;
|
|
243
|
+
exports.DialogTrigger = DialogTrigger;
|
|
244
|
+
//# sourceMappingURL=chunk-PKDXWKLO.cjs.map
|
|
245
|
+
//# sourceMappingURL=chunk-PKDXWKLO.cjs.map
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { mapAccessibilityToRN } from './chunk-73BDGPZT.js';
|
|
2
|
+
import { useTheme } from './chunk-ZYOTKLBG.js';
|
|
3
|
+
import { View, Pressable, Text } from 'react-native';
|
|
4
|
+
import { useAccordion } from '@entropix/core';
|
|
5
|
+
import { createContext, useCallback, useContext } from 'react';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var AccordionContext = createContext(null);
|
|
9
|
+
function useAccordionContext() {
|
|
10
|
+
const context = useContext(AccordionContext);
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
"Accordion compound components must be used within an <Accordion> provider."
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return context;
|
|
17
|
+
}
|
|
18
|
+
var AccordionItemContext = createContext(null);
|
|
19
|
+
function useAccordionItemContext() {
|
|
20
|
+
const context = useContext(AccordionItemContext);
|
|
21
|
+
if (context === null) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"AccordionTrigger and AccordionPanel must be used within an <AccordionItem>."
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return context;
|
|
27
|
+
}
|
|
28
|
+
function Accordion({ children, style, ...options }) {
|
|
29
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
30
|
+
const accordion = useAccordion(options);
|
|
31
|
+
return /* @__PURE__ */ jsx(AccordionContext.Provider, { value: accordion, children: /* @__PURE__ */ jsx(
|
|
32
|
+
View,
|
|
33
|
+
{
|
|
34
|
+
style: [
|
|
35
|
+
{
|
|
36
|
+
borderWidth: 1,
|
|
37
|
+
borderColor: t.entropixColorBorderDefault,
|
|
38
|
+
borderRadius: bt.entropixRadiusLg,
|
|
39
|
+
overflow: "hidden"
|
|
40
|
+
},
|
|
41
|
+
style
|
|
42
|
+
],
|
|
43
|
+
children
|
|
44
|
+
}
|
|
45
|
+
) });
|
|
46
|
+
}
|
|
47
|
+
function AccordionItem({
|
|
48
|
+
value,
|
|
49
|
+
isLast = false,
|
|
50
|
+
children,
|
|
51
|
+
style
|
|
52
|
+
}) {
|
|
53
|
+
const { tokens: t } = useTheme();
|
|
54
|
+
return /* @__PURE__ */ jsx(AccordionItemContext.Provider, { value, children: /* @__PURE__ */ jsx(
|
|
55
|
+
View,
|
|
56
|
+
{
|
|
57
|
+
style: [
|
|
58
|
+
{
|
|
59
|
+
borderBottomWidth: isLast ? 0 : 1,
|
|
60
|
+
borderBottomColor: t.entropixColorBorderDefault
|
|
61
|
+
},
|
|
62
|
+
style
|
|
63
|
+
],
|
|
64
|
+
children
|
|
65
|
+
}
|
|
66
|
+
) });
|
|
67
|
+
}
|
|
68
|
+
function AccordionTrigger({
|
|
69
|
+
children,
|
|
70
|
+
style,
|
|
71
|
+
textStyle,
|
|
72
|
+
...rest
|
|
73
|
+
}) {
|
|
74
|
+
const { tokens: t, baseTokens: bt } = useTheme();
|
|
75
|
+
const itemKey = useAccordionItemContext();
|
|
76
|
+
const { getItemTriggerProps, isExpanded } = useAccordionContext();
|
|
77
|
+
const propGetterReturn = getItemTriggerProps(itemKey);
|
|
78
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
79
|
+
const expanded = isExpanded(itemKey);
|
|
80
|
+
const handlePress = useCallback(() => {
|
|
81
|
+
propGetterReturn.onAction?.();
|
|
82
|
+
}, [propGetterReturn.onAction]);
|
|
83
|
+
return /* @__PURE__ */ jsxs(
|
|
84
|
+
Pressable,
|
|
85
|
+
{
|
|
86
|
+
...rnAccessibility,
|
|
87
|
+
...rest,
|
|
88
|
+
onPress: propGetterReturn.onAction ? handlePress : void 0,
|
|
89
|
+
style: [
|
|
90
|
+
{
|
|
91
|
+
flexDirection: "row",
|
|
92
|
+
alignItems: "center",
|
|
93
|
+
justifyContent: "space-between",
|
|
94
|
+
paddingVertical: bt.entropixSpacing4,
|
|
95
|
+
paddingHorizontal: bt.entropixSpacing4
|
|
96
|
+
},
|
|
97
|
+
style
|
|
98
|
+
],
|
|
99
|
+
children: [
|
|
100
|
+
typeof children === "string" ? /* @__PURE__ */ jsx(
|
|
101
|
+
Text,
|
|
102
|
+
{
|
|
103
|
+
style: [
|
|
104
|
+
{
|
|
105
|
+
fontSize: bt.entropixFontSizeSm,
|
|
106
|
+
fontWeight: "500",
|
|
107
|
+
color: t.entropixColorTextPrimary,
|
|
108
|
+
flex: 1
|
|
109
|
+
},
|
|
110
|
+
textStyle
|
|
111
|
+
],
|
|
112
|
+
children
|
|
113
|
+
}
|
|
114
|
+
) : children,
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
Text,
|
|
117
|
+
{
|
|
118
|
+
style: {
|
|
119
|
+
fontSize: 12,
|
|
120
|
+
color: t.entropixColorTextSecondary,
|
|
121
|
+
marginLeft: bt.entropixSpacing2
|
|
122
|
+
},
|
|
123
|
+
children: expanded ? "\u2212" : "+"
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
function AccordionPanel({ children, style }) {
|
|
131
|
+
const { baseTokens: bt } = useTheme();
|
|
132
|
+
const itemKey = useAccordionItemContext();
|
|
133
|
+
const { getItemPanelProps, isExpanded } = useAccordionContext();
|
|
134
|
+
const propGetterReturn = getItemPanelProps(itemKey);
|
|
135
|
+
const rnAccessibility = mapAccessibilityToRN(propGetterReturn.accessibility);
|
|
136
|
+
if (!isExpanded(itemKey)) return null;
|
|
137
|
+
return /* @__PURE__ */ jsx(
|
|
138
|
+
View,
|
|
139
|
+
{
|
|
140
|
+
...rnAccessibility,
|
|
141
|
+
style: [
|
|
142
|
+
{
|
|
143
|
+
paddingHorizontal: bt.entropixSpacing4,
|
|
144
|
+
paddingBottom: bt.entropixSpacing4
|
|
145
|
+
},
|
|
146
|
+
style
|
|
147
|
+
],
|
|
148
|
+
children
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export { Accordion, AccordionItem, AccordionPanel, AccordionTrigger };
|
|
154
|
+
//# sourceMappingURL=chunk-PVTPOJRU.js.map
|
|
155
|
+
//# sourceMappingURL=chunk-PVTPOJRU.js.map
|