@marktiderman/genesis-ui-native 2.0.0
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/chunk-BAU4YQZV.js +760 -0
- package/dist/chunk-BAU4YQZV.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +10 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-HNIEFTEL.js +43 -0
- package/dist/chunk-HNIEFTEL.js.map +1 -0
- package/dist/chunk-N4WHTQIO.js +20 -0
- package/dist/chunk-N4WHTQIO.js.map +1 -0
- package/dist/chunk-OHZD7KRO.js +11 -0
- package/dist/chunk-OHZD7KRO.js.map +1 -0
- package/dist/chunk-PTJ2KCLM.js +160 -0
- package/dist/chunk-PTJ2KCLM.js.map +1 -0
- package/dist/chunk-TXJT55JC.js +2213 -0
- package/dist/chunk-TXJT55JC.js.map +1 -0
- package/dist/chunk-ULS7I6ZS.js +183 -0
- package/dist/chunk-ULS7I6ZS.js.map +1 -0
- package/dist/chunk-ZVF6PONU.js +522 -0
- package/dist/chunk-ZVF6PONU.js.map +1 -0
- package/dist/components/index.d.ts +908 -0
- package/dist/components/index.js +8 -0
- package/dist/components/index.js.map +1 -0
- package/dist/data/index.d.ts +117 -0
- package/dist/data/index.js +770 -0
- package/dist/data/index.js.map +1 -0
- package/dist/hooks/index.d.ts +31 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/index.d.ts +364 -0
- package/dist/layouts/index.js +8 -0
- package/dist/layouts/index.js.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +4 -0
- package/dist/utils.js.map +1 -0
- package/package.json +127 -0
- package/src/components/__tests__/accordion.test.tsx +122 -0
- package/src/components/__tests__/chip-group.test.tsx +45 -0
- package/src/components/__tests__/combobox.test.tsx +97 -0
- package/src/components/__tests__/drawer.test.tsx +98 -0
- package/src/components/__tests__/empty-state.test.tsx +66 -0
- package/src/components/__tests__/header-card.test.tsx +31 -0
- package/src/components/__tests__/layout.test.tsx +109 -0
- package/src/components/__tests__/list-item.test.tsx +31 -0
- package/src/components/__tests__/number-input.test.tsx +46 -0
- package/src/components/__tests__/pagination.test.tsx +43 -0
- package/src/components/__tests__/search-bar.test.tsx +41 -0
- package/src/components/__tests__/segmented-empty-alert.test.tsx +79 -0
- package/src/components/__tests__/slider.test.tsx +134 -0
- package/src/components/__tests__/stepper.test.tsx +25 -0
- package/src/components/__tests__/toast.test.tsx +63 -0
- package/src/components/accordion.tsx +223 -0
- package/src/components/alert.tsx +131 -0
- package/src/components/avatar.tsx +68 -0
- package/src/components/badge.tsx +80 -0
- package/src/components/button.tsx +118 -0
- package/src/components/card.tsx +120 -0
- package/src/components/checkbox.tsx +60 -0
- package/src/components/chip-group.tsx +127 -0
- package/src/components/combobox.tsx +137 -0
- package/src/components/date-time-picker.tsx +127 -0
- package/src/components/dialog.tsx +131 -0
- package/src/components/drawer.tsx +131 -0
- package/src/components/dropdown-menu.tsx +133 -0
- package/src/components/empty-state.tsx +161 -0
- package/src/components/header-card.tsx +116 -0
- package/src/components/index.ts +259 -0
- package/src/components/inline-alert.tsx +150 -0
- package/src/components/input.tsx +51 -0
- package/src/components/label.tsx +35 -0
- package/src/components/layout/box.tsx +115 -0
- package/src/components/layout/flex.ts +24 -0
- package/src/components/layout/grid.tsx +73 -0
- package/src/components/layout/index.ts +27 -0
- package/src/components/layout/inline.tsx +63 -0
- package/src/components/layout/spacing.ts +116 -0
- package/src/components/layout/stack.tsx +58 -0
- package/src/components/list-item.tsx +108 -0
- package/src/components/number-input.tsx +119 -0
- package/src/components/pagination.tsx +132 -0
- package/src/components/popover.tsx +198 -0
- package/src/components/progress.tsx +50 -0
- package/src/components/radio-group.tsx +92 -0
- package/src/components/refresh-control.tsx +73 -0
- package/src/components/search-bar.tsx +128 -0
- package/src/components/section-list.tsx +54 -0
- package/src/components/segmented-control.tsx +79 -0
- package/src/components/select.tsx +178 -0
- package/src/components/separator.tsx +31 -0
- package/src/components/sheet.tsx +192 -0
- package/src/components/skeleton.tsx +104 -0
- package/src/components/slider.tsx +223 -0
- package/src/components/stepper.tsx +96 -0
- package/src/components/switch.tsx +35 -0
- package/src/components/tabs.tsx +147 -0
- package/src/components/text.tsx +62 -0
- package/src/components/textarea.tsx +52 -0
- package/src/components/toast.tsx +228 -0
- package/src/components/toggle.tsx +85 -0
- package/src/components/tooltip.tsx +104 -0
- package/src/data/NativeDataFilters.tsx +100 -0
- package/src/data/NativeDataPageShell.tsx +111 -0
- package/src/data/NativeDetailPanel.tsx +130 -0
- package/src/data/NativeEmptyState.tsx +46 -0
- package/src/data/NativeResourceForm.tsx +157 -0
- package/src/data/NativeResourceFormField.tsx +280 -0
- package/src/data/NativeResourcePage.tsx +505 -0
- package/src/data/index.ts +9 -0
- package/src/hooks/index.ts +16 -0
- package/src/hooks/use-genesis-extension.ts +81 -0
- package/src/hooks/use-reduced-motion.ts +32 -0
- package/src/hooks/use-theme-mode.ts +31 -0
- package/src/index.ts +5 -0
- package/src/layouts/__tests__/auth.test.tsx +150 -0
- package/src/layouts/__tests__/nav-bar.test.tsx +86 -0
- package/src/layouts/__tests__/notifications-page.test.tsx +94 -0
- package/src/layouts/__tests__/screen-container.test.tsx +79 -0
- package/src/layouts/__tests__/settings-page.test.tsx +107 -0
- package/src/layouts/__tests__/settings-sub-page.test.tsx +53 -0
- package/src/layouts/auth.tsx +352 -0
- package/src/layouts/index.ts +61 -0
- package/src/layouts/nav-bar.tsx +200 -0
- package/src/layouts/notifications-page.tsx +274 -0
- package/src/layouts/screen-container.tsx +213 -0
- package/src/layouts/settings-page.tsx +195 -0
- package/src/layouts/settings-sub-page.tsx +183 -0
- package/src/nativewind.d.ts +40 -0
- package/src/utils.ts +6 -0
|
@@ -0,0 +1,2213 @@
|
|
|
1
|
+
import { cn } from './chunk-OHZD7KRO.js';
|
|
2
|
+
import { __require } from './chunk-DGUM43GV.js';
|
|
3
|
+
import { View, Text, AccessibilityInfo, Animated, Pressable, Modal, Dimensions, PanResponder, TextInput, ScrollView, Image, Platform } from 'react-native';
|
|
4
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
import { createContext, useState, useEffect, useCallback, useMemo, useRef, useContext, Children, cloneElement, isValidElement } from 'react';
|
|
6
|
+
import { cva } from 'class-variance-authority';
|
|
7
|
+
|
|
8
|
+
function NativeHeaderCard({
|
|
9
|
+
title,
|
|
10
|
+
description,
|
|
11
|
+
body,
|
|
12
|
+
footer,
|
|
13
|
+
className,
|
|
14
|
+
titleClassName,
|
|
15
|
+
descriptionClassName,
|
|
16
|
+
bodyClassName,
|
|
17
|
+
footerClassName,
|
|
18
|
+
testID
|
|
19
|
+
}) {
|
|
20
|
+
return /* @__PURE__ */ jsxs(
|
|
21
|
+
View,
|
|
22
|
+
{
|
|
23
|
+
testID,
|
|
24
|
+
accessibilityRole: "summary",
|
|
25
|
+
className: cn(
|
|
26
|
+
"rounded-xl border border-border bg-card shadow-sm",
|
|
27
|
+
className
|
|
28
|
+
),
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsxs(View, { className: "flex-col gap-1.5 p-6", children: [
|
|
31
|
+
typeof title === "string" ? /* @__PURE__ */ jsx(
|
|
32
|
+
Text,
|
|
33
|
+
{
|
|
34
|
+
testID: testID ? `${testID}-title` : void 0,
|
|
35
|
+
className: cn(
|
|
36
|
+
"text-2xl font-semibold leading-none tracking-tight text-card-foreground",
|
|
37
|
+
titleClassName
|
|
38
|
+
),
|
|
39
|
+
children: title
|
|
40
|
+
}
|
|
41
|
+
) : title,
|
|
42
|
+
description !== void 0 && description !== null ? typeof description === "string" ? /* @__PURE__ */ jsx(
|
|
43
|
+
Text,
|
|
44
|
+
{
|
|
45
|
+
testID: testID ? `${testID}-description` : void 0,
|
|
46
|
+
className: cn(
|
|
47
|
+
"text-sm text-muted-foreground",
|
|
48
|
+
descriptionClassName
|
|
49
|
+
),
|
|
50
|
+
children: description
|
|
51
|
+
}
|
|
52
|
+
) : description : null
|
|
53
|
+
] }),
|
|
54
|
+
body !== void 0 && body !== null ? /* @__PURE__ */ jsx(
|
|
55
|
+
View,
|
|
56
|
+
{
|
|
57
|
+
testID: testID ? `${testID}-body` : void 0,
|
|
58
|
+
className: cn("px-6 pb-6", bodyClassName),
|
|
59
|
+
children: body
|
|
60
|
+
}
|
|
61
|
+
) : null,
|
|
62
|
+
footer !== void 0 && footer !== null ? /* @__PURE__ */ jsx(
|
|
63
|
+
View,
|
|
64
|
+
{
|
|
65
|
+
testID: testID ? `${testID}-footer` : void 0,
|
|
66
|
+
className: cn(
|
|
67
|
+
"flex-row items-center gap-2 border-t border-border px-6 py-4",
|
|
68
|
+
footerClassName
|
|
69
|
+
),
|
|
70
|
+
children: footer
|
|
71
|
+
}
|
|
72
|
+
) : null
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
var ToastContext = createContext(null);
|
|
78
|
+
var nextId = 1;
|
|
79
|
+
function NativeToastProvider({
|
|
80
|
+
children,
|
|
81
|
+
position = "bottom",
|
|
82
|
+
disableAnimation = false
|
|
83
|
+
}) {
|
|
84
|
+
const [queue, setQueue] = useState([]);
|
|
85
|
+
const [reducedMotion, setReducedMotion] = useState(false);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
let mounted = true;
|
|
88
|
+
AccessibilityInfo.isReduceMotionEnabled().then((v) => {
|
|
89
|
+
if (mounted) setReducedMotion(v);
|
|
90
|
+
});
|
|
91
|
+
const sub = AccessibilityInfo.addEventListener(
|
|
92
|
+
"reduceMotionChanged",
|
|
93
|
+
(v) => mounted && setReducedMotion(v)
|
|
94
|
+
);
|
|
95
|
+
return () => {
|
|
96
|
+
mounted = false;
|
|
97
|
+
sub.remove();
|
|
98
|
+
};
|
|
99
|
+
}, []);
|
|
100
|
+
const dismiss = useCallback((id) => {
|
|
101
|
+
setQueue((q) => id == null ? q.slice(1) : q.filter((t) => t.id !== id));
|
|
102
|
+
}, []);
|
|
103
|
+
const show = useCallback((opts) => {
|
|
104
|
+
const id = nextId++;
|
|
105
|
+
setQueue((q) => [...q, { ...opts, id }]);
|
|
106
|
+
return id;
|
|
107
|
+
}, []);
|
|
108
|
+
const value = useMemo(() => ({ show, dismiss }), [show, dismiss]);
|
|
109
|
+
const current = queue[0];
|
|
110
|
+
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
|
|
111
|
+
children,
|
|
112
|
+
current ? /* @__PURE__ */ jsx(
|
|
113
|
+
ToastView,
|
|
114
|
+
{
|
|
115
|
+
toast: current,
|
|
116
|
+
position,
|
|
117
|
+
animate: !disableAnimation && !reducedMotion,
|
|
118
|
+
onDismiss: () => dismiss(current.id)
|
|
119
|
+
},
|
|
120
|
+
current.id
|
|
121
|
+
) : null
|
|
122
|
+
] });
|
|
123
|
+
}
|
|
124
|
+
function ToastView({ toast, position, animate, onDismiss }) {
|
|
125
|
+
const opacity = useRef(new Animated.Value(animate ? 0 : 1)).current;
|
|
126
|
+
const offset = useRef(new Animated.Value(animate ? 16 : 0)).current;
|
|
127
|
+
const onDismissRef = useRef(onDismiss);
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
onDismissRef.current = onDismiss;
|
|
130
|
+
}, [onDismiss]);
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (animate) {
|
|
133
|
+
Animated.parallel([
|
|
134
|
+
Animated.timing(opacity, {
|
|
135
|
+
toValue: 1,
|
|
136
|
+
duration: 180,
|
|
137
|
+
useNativeDriver: true
|
|
138
|
+
}),
|
|
139
|
+
Animated.timing(offset, {
|
|
140
|
+
toValue: 0,
|
|
141
|
+
duration: 180,
|
|
142
|
+
useNativeDriver: true
|
|
143
|
+
})
|
|
144
|
+
]).start();
|
|
145
|
+
}
|
|
146
|
+
const duration = toast.duration ?? 3500;
|
|
147
|
+
if (duration > 0) {
|
|
148
|
+
const t = setTimeout(() => onDismissRef.current(), duration);
|
|
149
|
+
return () => clearTimeout(t);
|
|
150
|
+
}
|
|
151
|
+
return void 0;
|
|
152
|
+
}, [animate, offset, opacity, toast.duration]);
|
|
153
|
+
const variantClasses2 = {
|
|
154
|
+
default: "bg-foreground",
|
|
155
|
+
success: "bg-primary",
|
|
156
|
+
destructive: "bg-destructive"
|
|
157
|
+
};
|
|
158
|
+
const textClass = {
|
|
159
|
+
default: "text-background",
|
|
160
|
+
success: "text-primary-foreground",
|
|
161
|
+
destructive: "text-destructive-foreground"
|
|
162
|
+
};
|
|
163
|
+
const variant = toast.variant ?? "default";
|
|
164
|
+
const positionClass = position === "top" ? "top-12 self-center" : "bottom-10 self-center";
|
|
165
|
+
return /* @__PURE__ */ jsx(
|
|
166
|
+
Animated.View,
|
|
167
|
+
{
|
|
168
|
+
accessible: true,
|
|
169
|
+
accessibilityRole: "alert",
|
|
170
|
+
accessibilityLiveRegion: "polite",
|
|
171
|
+
accessibilityLabel: toast.description ? `${toast.title}. ${toast.description}` : toast.title,
|
|
172
|
+
className: cn(
|
|
173
|
+
"absolute left-4 right-4 items-center",
|
|
174
|
+
positionClass
|
|
175
|
+
),
|
|
176
|
+
style: { opacity, transform: [{ translateY: offset }] },
|
|
177
|
+
children: /* @__PURE__ */ jsxs(
|
|
178
|
+
Pressable,
|
|
179
|
+
{
|
|
180
|
+
testID: toast.testID ?? "native-toast",
|
|
181
|
+
accessibilityRole: "button",
|
|
182
|
+
accessibilityLabel: "Dismiss notification",
|
|
183
|
+
accessibilityHint: "Dismisses this toast",
|
|
184
|
+
onPress: onDismiss,
|
|
185
|
+
className: cn(
|
|
186
|
+
"min-h-[44px] min-w-[200px] rounded-lg px-4 py-3 shadow-lg",
|
|
187
|
+
variantClasses2[variant]
|
|
188
|
+
),
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ jsx(Text, { className: cn("text-base font-semibold", textClass[variant]), children: toast.title }),
|
|
191
|
+
toast.description ? /* @__PURE__ */ jsx(Text, { className: cn("mt-0.5 text-sm", textClass[variant], "opacity-90"), children: toast.description }) : null
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
function useToast() {
|
|
199
|
+
const ctx = useContext(ToastContext);
|
|
200
|
+
if (!ctx) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
"useToast() must be used inside <NativeToastProvider>. Mount the provider near the root."
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
return ctx;
|
|
206
|
+
}
|
|
207
|
+
var GORHOM = (() => {
|
|
208
|
+
try {
|
|
209
|
+
const mod = __require("@gorhom/bottom-sheet");
|
|
210
|
+
return {
|
|
211
|
+
BottomSheetModal: mod.BottomSheetModal,
|
|
212
|
+
BottomSheetView: mod.BottomSheetView,
|
|
213
|
+
BottomSheetBackdrop: mod.BottomSheetBackdrop
|
|
214
|
+
};
|
|
215
|
+
} catch {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
})();
|
|
219
|
+
function NativeSheet({
|
|
220
|
+
open,
|
|
221
|
+
onOpenChange,
|
|
222
|
+
snapPoints = ["50%", "90%"],
|
|
223
|
+
initialSnapIndex = 0,
|
|
224
|
+
disableBackdropDismiss = false,
|
|
225
|
+
children,
|
|
226
|
+
testID
|
|
227
|
+
}) {
|
|
228
|
+
if (GORHOM) {
|
|
229
|
+
return /* @__PURE__ */ jsx(
|
|
230
|
+
GorhomSheet,
|
|
231
|
+
{
|
|
232
|
+
gorhom: GORHOM,
|
|
233
|
+
open,
|
|
234
|
+
onOpenChange,
|
|
235
|
+
snapPoints,
|
|
236
|
+
initialSnapIndex,
|
|
237
|
+
disableBackdropDismiss,
|
|
238
|
+
testID,
|
|
239
|
+
children
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return /* @__PURE__ */ jsx(
|
|
244
|
+
FallbackSheet,
|
|
245
|
+
{
|
|
246
|
+
open,
|
|
247
|
+
onOpenChange,
|
|
248
|
+
disableBackdropDismiss,
|
|
249
|
+
testID,
|
|
250
|
+
children
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
function GorhomSheet({
|
|
255
|
+
gorhom,
|
|
256
|
+
open,
|
|
257
|
+
onOpenChange,
|
|
258
|
+
snapPoints,
|
|
259
|
+
initialSnapIndex,
|
|
260
|
+
disableBackdropDismiss,
|
|
261
|
+
testID,
|
|
262
|
+
children
|
|
263
|
+
}) {
|
|
264
|
+
const ref = useRef(null);
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
if (open) ref.current?.present();
|
|
267
|
+
else ref.current?.dismiss();
|
|
268
|
+
}, [open]);
|
|
269
|
+
const { BottomSheetModal, BottomSheetView, BottomSheetBackdrop } = gorhom;
|
|
270
|
+
return /* @__PURE__ */ jsx(
|
|
271
|
+
BottomSheetModal,
|
|
272
|
+
{
|
|
273
|
+
ref,
|
|
274
|
+
snapPoints,
|
|
275
|
+
index: initialSnapIndex,
|
|
276
|
+
onDismiss: () => onOpenChange(false),
|
|
277
|
+
enablePanDownToClose: !disableBackdropDismiss,
|
|
278
|
+
backdropComponent: (p) => /* @__PURE__ */ jsx(
|
|
279
|
+
BottomSheetBackdrop,
|
|
280
|
+
{
|
|
281
|
+
...p,
|
|
282
|
+
appearsOnIndex: 0,
|
|
283
|
+
disappearsOnIndex: -1,
|
|
284
|
+
pressBehavior: disableBackdropDismiss ? "none" : "close"
|
|
285
|
+
}
|
|
286
|
+
),
|
|
287
|
+
children: /* @__PURE__ */ jsx(BottomSheetView, { testID: testID ?? "native-sheet", children })
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
function FallbackSheet({
|
|
292
|
+
open,
|
|
293
|
+
onOpenChange,
|
|
294
|
+
disableBackdropDismiss,
|
|
295
|
+
testID,
|
|
296
|
+
children
|
|
297
|
+
}) {
|
|
298
|
+
const [reducedMotion, setReducedMotion] = useState(false);
|
|
299
|
+
useEffect(() => {
|
|
300
|
+
AccessibilityInfo.isReduceMotionEnabled().then(setReducedMotion);
|
|
301
|
+
}, []);
|
|
302
|
+
return /* @__PURE__ */ jsx(
|
|
303
|
+
Modal,
|
|
304
|
+
{
|
|
305
|
+
visible: open,
|
|
306
|
+
transparent: true,
|
|
307
|
+
animationType: reducedMotion ? "none" : "slide",
|
|
308
|
+
onRequestClose: () => onOpenChange(false),
|
|
309
|
+
children: /* @__PURE__ */ jsx(
|
|
310
|
+
Pressable,
|
|
311
|
+
{
|
|
312
|
+
className: "flex-1 justify-end bg-black/50",
|
|
313
|
+
onPress: () => {
|
|
314
|
+
if (!disableBackdropDismiss) onOpenChange(false);
|
|
315
|
+
},
|
|
316
|
+
children: /* @__PURE__ */ jsx(Pressable, { onPress: () => {
|
|
317
|
+
}, children: /* @__PURE__ */ jsxs(
|
|
318
|
+
View,
|
|
319
|
+
{
|
|
320
|
+
testID: testID ?? "native-sheet",
|
|
321
|
+
accessibilityViewIsModal: true,
|
|
322
|
+
accessibilityRole: "alert",
|
|
323
|
+
className: cn(
|
|
324
|
+
"min-h-[200px] rounded-t-2xl border-t border-border bg-background p-4 shadow-lg"
|
|
325
|
+
),
|
|
326
|
+
children: [
|
|
327
|
+
/* @__PURE__ */ jsx(View, { className: "mb-3 self-center h-1 w-12 rounded-full bg-muted" }),
|
|
328
|
+
children
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
) })
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
var PopoverContext = createContext(null);
|
|
338
|
+
function NativePopover({
|
|
339
|
+
open: controlled,
|
|
340
|
+
defaultOpen,
|
|
341
|
+
onOpenChange,
|
|
342
|
+
children
|
|
343
|
+
}) {
|
|
344
|
+
const [uncontrolled, setUncontrolled] = useState(defaultOpen ?? false);
|
|
345
|
+
const open = controlled ?? uncontrolled;
|
|
346
|
+
const anchorRef = useRef(null);
|
|
347
|
+
const [anchorRect, setAnchorRect] = useState(null);
|
|
348
|
+
const setOpen = useCallback(
|
|
349
|
+
(next) => {
|
|
350
|
+
if (controlled === void 0) setUncontrolled(next);
|
|
351
|
+
onOpenChange?.(next);
|
|
352
|
+
},
|
|
353
|
+
[controlled, onOpenChange]
|
|
354
|
+
);
|
|
355
|
+
const measureAnchor = useCallback(() => {
|
|
356
|
+
anchorRef.current?.measureInWindow((x, y, width, height) => {
|
|
357
|
+
setAnchorRect({ x, y, width, height });
|
|
358
|
+
});
|
|
359
|
+
}, []);
|
|
360
|
+
const value = useMemo(
|
|
361
|
+
() => ({ open, setOpen, anchorRef, anchorRect, measureAnchor }),
|
|
362
|
+
[open, setOpen, anchorRect, measureAnchor]
|
|
363
|
+
);
|
|
364
|
+
return /* @__PURE__ */ jsx(PopoverContext.Provider, { value, children });
|
|
365
|
+
}
|
|
366
|
+
function NativePopoverTrigger({
|
|
367
|
+
children,
|
|
368
|
+
testID
|
|
369
|
+
}) {
|
|
370
|
+
const ctx = useContext(PopoverContext);
|
|
371
|
+
if (!ctx)
|
|
372
|
+
throw new Error("NativePopoverTrigger must be used inside <NativePopover>.");
|
|
373
|
+
return /* @__PURE__ */ jsx(
|
|
374
|
+
View,
|
|
375
|
+
{
|
|
376
|
+
ref: (instance) => {
|
|
377
|
+
ctx.anchorRef.current = instance ?? null;
|
|
378
|
+
},
|
|
379
|
+
collapsable: false,
|
|
380
|
+
children: /* @__PURE__ */ jsx(
|
|
381
|
+
Pressable,
|
|
382
|
+
{
|
|
383
|
+
testID: testID ?? "native-popover-trigger",
|
|
384
|
+
accessibilityRole: "button",
|
|
385
|
+
accessibilityHint: "Opens a popover",
|
|
386
|
+
onPress: () => {
|
|
387
|
+
ctx.measureAnchor();
|
|
388
|
+
ctx.setOpen(!ctx.open);
|
|
389
|
+
},
|
|
390
|
+
className: "min-h-[44px] min-w-[44px] items-center justify-center",
|
|
391
|
+
children
|
|
392
|
+
}
|
|
393
|
+
)
|
|
394
|
+
}
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
function NativePopoverContent({
|
|
398
|
+
className,
|
|
399
|
+
children,
|
|
400
|
+
side,
|
|
401
|
+
sideOffset = 8,
|
|
402
|
+
testID
|
|
403
|
+
}) {
|
|
404
|
+
const ctx = useContext(PopoverContext);
|
|
405
|
+
if (!ctx)
|
|
406
|
+
throw new Error("NativePopoverContent must be used inside <NativePopover>.");
|
|
407
|
+
if (!ctx.open || !ctx.anchorRect) return null;
|
|
408
|
+
const { x, y, width, height } = ctx.anchorRect;
|
|
409
|
+
const resolvedSide = side ?? (y > 500 ? "top" : "bottom");
|
|
410
|
+
const computedTop = resolvedSide === "bottom" ? y + height + sideOffset : Math.max(0, y - sideOffset - 8);
|
|
411
|
+
return /* @__PURE__ */ jsx(
|
|
412
|
+
Modal,
|
|
413
|
+
{
|
|
414
|
+
visible: ctx.open,
|
|
415
|
+
transparent: true,
|
|
416
|
+
animationType: "fade",
|
|
417
|
+
onRequestClose: () => ctx.setOpen(false),
|
|
418
|
+
children: /* @__PURE__ */ jsx(
|
|
419
|
+
Pressable,
|
|
420
|
+
{
|
|
421
|
+
accessibilityLabel: "Close popover",
|
|
422
|
+
className: "flex-1",
|
|
423
|
+
onPress: () => ctx.setOpen(false),
|
|
424
|
+
children: /* @__PURE__ */ jsx(
|
|
425
|
+
View,
|
|
426
|
+
{
|
|
427
|
+
pointerEvents: "box-none",
|
|
428
|
+
style: {
|
|
429
|
+
position: "absolute",
|
|
430
|
+
left: x,
|
|
431
|
+
top: computedTop,
|
|
432
|
+
minWidth: width
|
|
433
|
+
},
|
|
434
|
+
children: /* @__PURE__ */ jsx(Pressable, { onPress: () => {
|
|
435
|
+
}, children: /* @__PURE__ */ jsx(
|
|
436
|
+
View,
|
|
437
|
+
{
|
|
438
|
+
testID: testID ?? "native-popover-content",
|
|
439
|
+
accessibilityViewIsModal: true,
|
|
440
|
+
className: cn(
|
|
441
|
+
"max-w-[280px] rounded-md border border-border bg-popover p-3 shadow-md",
|
|
442
|
+
className
|
|
443
|
+
),
|
|
444
|
+
children
|
|
445
|
+
}
|
|
446
|
+
) })
|
|
447
|
+
}
|
|
448
|
+
)
|
|
449
|
+
}
|
|
450
|
+
)
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
function NativeDrawer({
|
|
455
|
+
open,
|
|
456
|
+
onOpenChange,
|
|
457
|
+
side = "left",
|
|
458
|
+
width,
|
|
459
|
+
children,
|
|
460
|
+
className,
|
|
461
|
+
testID
|
|
462
|
+
}) {
|
|
463
|
+
const screen = Dimensions.get("window");
|
|
464
|
+
const drawerWidth = width ?? Math.min(screen.width * 0.8, 360);
|
|
465
|
+
const [reducedMotion, setReducedMotion] = useState(false);
|
|
466
|
+
const translate = useRef(new Animated.Value(side === "left" ? -drawerWidth : drawerWidth)).current;
|
|
467
|
+
useEffect(() => {
|
|
468
|
+
AccessibilityInfo.isReduceMotionEnabled().then(setReducedMotion);
|
|
469
|
+
}, []);
|
|
470
|
+
useEffect(() => {
|
|
471
|
+
Animated.timing(translate, {
|
|
472
|
+
toValue: open ? 0 : side === "left" ? -drawerWidth : drawerWidth,
|
|
473
|
+
duration: reducedMotion ? 0 : 220,
|
|
474
|
+
useNativeDriver: true
|
|
475
|
+
}).start();
|
|
476
|
+
}, [drawerWidth, open, reducedMotion, side, translate]);
|
|
477
|
+
const panResponder = useMemo(
|
|
478
|
+
() => PanResponder.create({
|
|
479
|
+
onMoveShouldSetPanResponder: (_, g) => Math.abs(g.dx) > 8,
|
|
480
|
+
onPanResponderMove: (_, g) => {
|
|
481
|
+
if (side === "left") {
|
|
482
|
+
translate.setValue(Math.min(0, g.dx));
|
|
483
|
+
} else {
|
|
484
|
+
translate.setValue(Math.max(0, g.dx));
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
onPanResponderRelease: (_, g) => {
|
|
488
|
+
const dismiss = side === "left" ? g.dx < -drawerWidth / 3 : g.dx > drawerWidth / 3;
|
|
489
|
+
if (dismiss) {
|
|
490
|
+
onOpenChange(false);
|
|
491
|
+
} else {
|
|
492
|
+
Animated.timing(translate, {
|
|
493
|
+
toValue: 0,
|
|
494
|
+
duration: 180,
|
|
495
|
+
useNativeDriver: true
|
|
496
|
+
}).start();
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}),
|
|
500
|
+
[drawerWidth, onOpenChange, side, translate]
|
|
501
|
+
);
|
|
502
|
+
return /* @__PURE__ */ jsx(
|
|
503
|
+
Modal,
|
|
504
|
+
{
|
|
505
|
+
visible: open,
|
|
506
|
+
transparent: true,
|
|
507
|
+
animationType: "none",
|
|
508
|
+
onRequestClose: () => onOpenChange(false),
|
|
509
|
+
children: /* @__PURE__ */ jsx(
|
|
510
|
+
Pressable,
|
|
511
|
+
{
|
|
512
|
+
accessibilityLabel: "Close drawer",
|
|
513
|
+
className: "flex-1 bg-black/40",
|
|
514
|
+
onPress: () => onOpenChange(false),
|
|
515
|
+
children: /* @__PURE__ */ jsx(Pressable, { onPress: () => {
|
|
516
|
+
}, style: { flex: 1 }, children: /* @__PURE__ */ jsx(
|
|
517
|
+
Animated.View,
|
|
518
|
+
{
|
|
519
|
+
testID: testID ?? "native-drawer",
|
|
520
|
+
accessibilityViewIsModal: true,
|
|
521
|
+
...panResponder.panHandlers,
|
|
522
|
+
style: {
|
|
523
|
+
position: "absolute",
|
|
524
|
+
top: 0,
|
|
525
|
+
bottom: 0,
|
|
526
|
+
[side]: 0,
|
|
527
|
+
width: drawerWidth,
|
|
528
|
+
transform: [{ translateX: translate }]
|
|
529
|
+
},
|
|
530
|
+
className: cn(
|
|
531
|
+
"border-border bg-background p-4 shadow-lg",
|
|
532
|
+
side === "left" ? "border-r" : "border-l",
|
|
533
|
+
className
|
|
534
|
+
),
|
|
535
|
+
children: /* @__PURE__ */ jsx(View, { className: "flex-1", children })
|
|
536
|
+
}
|
|
537
|
+
) })
|
|
538
|
+
}
|
|
539
|
+
)
|
|
540
|
+
}
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
var AccordionContext = createContext(null);
|
|
544
|
+
function NativeAccordion({
|
|
545
|
+
type = "single",
|
|
546
|
+
value: controlled,
|
|
547
|
+
defaultValue = [],
|
|
548
|
+
onValueChange,
|
|
549
|
+
className,
|
|
550
|
+
children,
|
|
551
|
+
testID
|
|
552
|
+
}) {
|
|
553
|
+
const [uncontrolled, setUncontrolled] = useState(defaultValue);
|
|
554
|
+
const expanded = controlled ?? uncontrolled;
|
|
555
|
+
const toggle = (v) => {
|
|
556
|
+
let next;
|
|
557
|
+
if (type === "single") {
|
|
558
|
+
next = expanded.includes(v) ? [] : [v];
|
|
559
|
+
} else {
|
|
560
|
+
next = expanded.includes(v) ? expanded.filter((x) => x !== v) : [...expanded, v];
|
|
561
|
+
}
|
|
562
|
+
if (controlled === void 0) setUncontrolled(next);
|
|
563
|
+
onValueChange?.(next);
|
|
564
|
+
};
|
|
565
|
+
const isAccordionItem = (node) => isValidElement(node) && node.type === NativeAccordionItem;
|
|
566
|
+
const items = Children.toArray(children);
|
|
567
|
+
const lastItemIndex = (() => {
|
|
568
|
+
for (let i = items.length - 1; i >= 0; i -= 1) {
|
|
569
|
+
if (isAccordionItem(items[i])) return i;
|
|
570
|
+
}
|
|
571
|
+
return -1;
|
|
572
|
+
})();
|
|
573
|
+
const annotated = items.map((child, idx) => {
|
|
574
|
+
if (!isAccordionItem(child)) return child;
|
|
575
|
+
if (idx !== lastItemIndex) return child;
|
|
576
|
+
if (child.props.isLast !== void 0) return child;
|
|
577
|
+
return cloneElement(child, { isLast: true });
|
|
578
|
+
});
|
|
579
|
+
return /* @__PURE__ */ jsx(AccordionContext.Provider, { value: { type, expanded, toggle }, children: /* @__PURE__ */ jsx(View, { testID, className: cn("rounded-md border border-border", className), children: annotated }) });
|
|
580
|
+
}
|
|
581
|
+
var AccordionItemCtx = createContext(null);
|
|
582
|
+
function NativeAccordionItem({
|
|
583
|
+
value,
|
|
584
|
+
className,
|
|
585
|
+
isLast,
|
|
586
|
+
children
|
|
587
|
+
}) {
|
|
588
|
+
const ctx = useContext(AccordionContext);
|
|
589
|
+
if (!ctx)
|
|
590
|
+
throw new Error("NativeAccordionItem must be used inside <NativeAccordion>.");
|
|
591
|
+
const isExpanded = ctx.expanded.includes(value);
|
|
592
|
+
return /* @__PURE__ */ jsx(
|
|
593
|
+
AccordionItemCtx.Provider,
|
|
594
|
+
{
|
|
595
|
+
value: { value, isExpanded, toggle: () => ctx.toggle(value) },
|
|
596
|
+
children: /* @__PURE__ */ jsx(
|
|
597
|
+
View,
|
|
598
|
+
{
|
|
599
|
+
className: cn(
|
|
600
|
+
"border-border",
|
|
601
|
+
!isLast && "border-b",
|
|
602
|
+
className
|
|
603
|
+
),
|
|
604
|
+
children
|
|
605
|
+
}
|
|
606
|
+
)
|
|
607
|
+
}
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
function NativeAccordionTrigger({
|
|
611
|
+
className,
|
|
612
|
+
children,
|
|
613
|
+
testID
|
|
614
|
+
}) {
|
|
615
|
+
const ctx = useContext(AccordionItemCtx);
|
|
616
|
+
if (!ctx)
|
|
617
|
+
throw new Error(
|
|
618
|
+
"NativeAccordionTrigger must be used inside <NativeAccordionItem>."
|
|
619
|
+
);
|
|
620
|
+
return /* @__PURE__ */ jsxs(
|
|
621
|
+
Pressable,
|
|
622
|
+
{
|
|
623
|
+
testID: testID ?? `accordion-trigger-${ctx.value}`,
|
|
624
|
+
accessibilityRole: "button",
|
|
625
|
+
accessibilityState: { expanded: ctx.isExpanded },
|
|
626
|
+
onPress: ctx.toggle,
|
|
627
|
+
className: cn(
|
|
628
|
+
"min-h-[44px] flex-row items-center justify-between p-4",
|
|
629
|
+
className
|
|
630
|
+
),
|
|
631
|
+
children: [
|
|
632
|
+
typeof children === "string" ? /* @__PURE__ */ jsx(Text, { className: "flex-1 text-base font-medium text-foreground", children }) : children,
|
|
633
|
+
/* @__PURE__ */ jsx(Text, { className: "text-muted-foreground", accessibilityElementsHidden: true, children: ctx.isExpanded ? "\u2212" : "+" })
|
|
634
|
+
]
|
|
635
|
+
}
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
function NativeAccordionContent({
|
|
639
|
+
className,
|
|
640
|
+
children,
|
|
641
|
+
testID
|
|
642
|
+
}) {
|
|
643
|
+
const ctx = useContext(AccordionItemCtx);
|
|
644
|
+
if (!ctx)
|
|
645
|
+
throw new Error(
|
|
646
|
+
"NativeAccordionContent must be used inside <NativeAccordionItem>."
|
|
647
|
+
);
|
|
648
|
+
if (!ctx.isExpanded) return null;
|
|
649
|
+
return /* @__PURE__ */ jsx(
|
|
650
|
+
View,
|
|
651
|
+
{
|
|
652
|
+
testID: testID ?? `accordion-content-${ctx.value}`,
|
|
653
|
+
className: cn("px-4 pb-4", className),
|
|
654
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx(Text, { className: "text-sm text-muted-foreground", children }) : children
|
|
655
|
+
}
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
var defaultFilter = (o, q) => o.label.toLowerCase().includes(q.toLowerCase()) || (o.description?.toLowerCase().includes(q.toLowerCase()) ?? false);
|
|
659
|
+
function NativeCombobox({
|
|
660
|
+
options,
|
|
661
|
+
value,
|
|
662
|
+
onChange,
|
|
663
|
+
placeholder,
|
|
664
|
+
placeholderTextColor,
|
|
665
|
+
filter = defaultFilter,
|
|
666
|
+
emptyContent,
|
|
667
|
+
defaultQuery = "",
|
|
668
|
+
className,
|
|
669
|
+
testID
|
|
670
|
+
}) {
|
|
671
|
+
const [query, setQuery] = useState(() => {
|
|
672
|
+
if (defaultQuery) return defaultQuery;
|
|
673
|
+
const selected = options.find((o) => o.value === value);
|
|
674
|
+
return selected?.label ?? "";
|
|
675
|
+
});
|
|
676
|
+
const [open, setOpen] = useState(false);
|
|
677
|
+
const filtered = useMemo(
|
|
678
|
+
() => query ? options.filter((o) => filter(o, query)) : options,
|
|
679
|
+
[filter, options, query]
|
|
680
|
+
);
|
|
681
|
+
return /* @__PURE__ */ jsxs(View, { testID, className: cn("relative", className), children: [
|
|
682
|
+
/* @__PURE__ */ jsx(
|
|
683
|
+
TextInput,
|
|
684
|
+
{
|
|
685
|
+
testID: testID ? `${testID}-input` : "combobox-input",
|
|
686
|
+
value: query,
|
|
687
|
+
onChangeText: (t) => {
|
|
688
|
+
setQuery(t);
|
|
689
|
+
if (!open) setOpen(true);
|
|
690
|
+
},
|
|
691
|
+
onFocus: () => setOpen(true),
|
|
692
|
+
onBlur: () => {
|
|
693
|
+
setTimeout(() => setOpen(false), 120);
|
|
694
|
+
},
|
|
695
|
+
placeholder: placeholder ?? "Search...",
|
|
696
|
+
placeholderTextColor,
|
|
697
|
+
accessibilityRole: "search",
|
|
698
|
+
accessibilityLabel: placeholder ?? "Search",
|
|
699
|
+
className: cn(
|
|
700
|
+
"min-h-[44px] rounded-md border border-input bg-background px-3 text-base text-foreground"
|
|
701
|
+
)
|
|
702
|
+
}
|
|
703
|
+
),
|
|
704
|
+
open ? /* @__PURE__ */ jsx(
|
|
705
|
+
View,
|
|
706
|
+
{
|
|
707
|
+
className: cn(
|
|
708
|
+
"mt-1 max-h-[280px] rounded-md border border-border bg-background shadow-md"
|
|
709
|
+
),
|
|
710
|
+
children: filtered.length === 0 ? /* @__PURE__ */ jsx(View, { className: "p-3", testID: testID ? `${testID}-empty` : void 0, children: emptyContent ?? /* @__PURE__ */ jsx(Text, { className: "text-sm text-muted-foreground", children: "No results." }) }) : /* @__PURE__ */ jsx(ScrollView, { keyboardShouldPersistTaps: "handled", children: filtered.map((opt) => /* @__PURE__ */ jsxs(
|
|
711
|
+
Pressable,
|
|
712
|
+
{
|
|
713
|
+
testID: testID ? `${testID}-option-${String(opt.value)}` : void 0,
|
|
714
|
+
accessibilityRole: "button",
|
|
715
|
+
accessibilityState: { selected: opt.value === value },
|
|
716
|
+
onPress: () => {
|
|
717
|
+
onChange(opt.value);
|
|
718
|
+
setQuery(opt.label);
|
|
719
|
+
setOpen(false);
|
|
720
|
+
},
|
|
721
|
+
className: "min-h-[44px] flex-col justify-center px-3 py-2",
|
|
722
|
+
children: [
|
|
723
|
+
/* @__PURE__ */ jsx(Text, { className: "text-base text-foreground", children: opt.label }),
|
|
724
|
+
opt.description ? /* @__PURE__ */ jsx(Text, { className: "text-xs text-muted-foreground", children: opt.description }) : null
|
|
725
|
+
]
|
|
726
|
+
},
|
|
727
|
+
String(opt.value)
|
|
728
|
+
)) })
|
|
729
|
+
}
|
|
730
|
+
) : null
|
|
731
|
+
] });
|
|
732
|
+
}
|
|
733
|
+
function resolveDateTimePicker() {
|
|
734
|
+
try {
|
|
735
|
+
return __require("@react-native-community/datetimepicker").default;
|
|
736
|
+
} catch {
|
|
737
|
+
return null;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
function PickerButton({
|
|
741
|
+
value,
|
|
742
|
+
onChange,
|
|
743
|
+
mode,
|
|
744
|
+
formatLabel,
|
|
745
|
+
disabled,
|
|
746
|
+
className,
|
|
747
|
+
testID
|
|
748
|
+
}) {
|
|
749
|
+
const Picker = resolveDateTimePicker();
|
|
750
|
+
const [showAndroid, setShowAndroid] = useState(false);
|
|
751
|
+
const isIOS = Platform.OS === "ios";
|
|
752
|
+
const label = useMemo(() => {
|
|
753
|
+
if (formatLabel) return formatLabel(value);
|
|
754
|
+
if (mode === "date") return value.toDateString();
|
|
755
|
+
return value.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
756
|
+
}, [formatLabel, mode, value]);
|
|
757
|
+
if (!Picker) {
|
|
758
|
+
return /* @__PURE__ */ jsxs(
|
|
759
|
+
Text,
|
|
760
|
+
{
|
|
761
|
+
testID,
|
|
762
|
+
className: cn(
|
|
763
|
+
"min-h-[44px] rounded-md border border-input bg-background px-3 py-3 text-base text-muted-foreground",
|
|
764
|
+
className
|
|
765
|
+
),
|
|
766
|
+
children: [
|
|
767
|
+
label,
|
|
768
|
+
" (picker module not installed)"
|
|
769
|
+
]
|
|
770
|
+
}
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
774
|
+
/* @__PURE__ */ jsx(
|
|
775
|
+
Pressable,
|
|
776
|
+
{
|
|
777
|
+
testID: testID ?? `native-${mode}-picker`,
|
|
778
|
+
accessibilityRole: "button",
|
|
779
|
+
accessibilityLabel: `Pick a ${mode}`,
|
|
780
|
+
accessibilityValue: { text: label },
|
|
781
|
+
accessibilityState: { disabled },
|
|
782
|
+
disabled,
|
|
783
|
+
onPress: () => {
|
|
784
|
+
if (!isIOS) setShowAndroid(true);
|
|
785
|
+
},
|
|
786
|
+
className: cn(
|
|
787
|
+
"min-h-[44px] flex-row items-center rounded-md border border-input bg-background px-3",
|
|
788
|
+
disabled && "opacity-50",
|
|
789
|
+
className
|
|
790
|
+
),
|
|
791
|
+
children: /* @__PURE__ */ jsx(Text, { className: "flex-1 text-base text-foreground", children: label })
|
|
792
|
+
}
|
|
793
|
+
),
|
|
794
|
+
isIOS || showAndroid ? /* @__PURE__ */ jsx(
|
|
795
|
+
Picker,
|
|
796
|
+
{
|
|
797
|
+
testID: testID ? `${testID}-picker` : void 0,
|
|
798
|
+
value,
|
|
799
|
+
mode,
|
|
800
|
+
display: isIOS ? "compact" : "default",
|
|
801
|
+
onChange: (_e, d) => {
|
|
802
|
+
if (!isIOS) setShowAndroid(false);
|
|
803
|
+
if (d) onChange(d);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
) : null
|
|
807
|
+
] });
|
|
808
|
+
}
|
|
809
|
+
function NativeDatePicker(props) {
|
|
810
|
+
return /* @__PURE__ */ jsx(PickerButton, { ...props, mode: "date" });
|
|
811
|
+
}
|
|
812
|
+
function NativeTimePicker(props) {
|
|
813
|
+
return /* @__PURE__ */ jsx(PickerButton, { ...props, mode: "time" });
|
|
814
|
+
}
|
|
815
|
+
function clamp(v, min, max) {
|
|
816
|
+
if (min !== void 0 && v < min) return min;
|
|
817
|
+
if (max !== void 0 && v > max) return max;
|
|
818
|
+
return v;
|
|
819
|
+
}
|
|
820
|
+
function NativeNumberInput({
|
|
821
|
+
value,
|
|
822
|
+
onChange,
|
|
823
|
+
min,
|
|
824
|
+
max,
|
|
825
|
+
step = 1,
|
|
826
|
+
precision = 0,
|
|
827
|
+
disabled,
|
|
828
|
+
readOnlyInput,
|
|
829
|
+
className,
|
|
830
|
+
inputClassName,
|
|
831
|
+
testID
|
|
832
|
+
}) {
|
|
833
|
+
const setValue = useCallback(
|
|
834
|
+
(next) => {
|
|
835
|
+
if (Number.isNaN(next)) return;
|
|
836
|
+
onChange(clamp(next, min, max));
|
|
837
|
+
},
|
|
838
|
+
[max, min, onChange]
|
|
839
|
+
);
|
|
840
|
+
const decBlocked = disabled || min !== void 0 && value <= min;
|
|
841
|
+
const incBlocked = disabled || max !== void 0 && value >= max;
|
|
842
|
+
return /* @__PURE__ */ jsxs(
|
|
843
|
+
View,
|
|
844
|
+
{
|
|
845
|
+
testID: testID ?? "native-number-input",
|
|
846
|
+
accessibilityRole: "adjustable",
|
|
847
|
+
accessibilityValue: { now: value, min, max },
|
|
848
|
+
className: cn(
|
|
849
|
+
"flex-row items-stretch overflow-hidden rounded-md border border-input bg-background",
|
|
850
|
+
className
|
|
851
|
+
),
|
|
852
|
+
children: [
|
|
853
|
+
/* @__PURE__ */ jsx(
|
|
854
|
+
Pressable,
|
|
855
|
+
{
|
|
856
|
+
testID: testID ? `${testID}-decrement` : "number-input-decrement",
|
|
857
|
+
accessibilityRole: "button",
|
|
858
|
+
accessibilityLabel: "Decrement",
|
|
859
|
+
disabled: decBlocked,
|
|
860
|
+
onPress: () => setValue(value - step),
|
|
861
|
+
className: cn(
|
|
862
|
+
"min-h-[44px] min-w-[44px] items-center justify-center px-3",
|
|
863
|
+
decBlocked && "opacity-40"
|
|
864
|
+
),
|
|
865
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-xl font-semibold text-foreground", children: "\u2212" })
|
|
866
|
+
}
|
|
867
|
+
),
|
|
868
|
+
/* @__PURE__ */ jsx(
|
|
869
|
+
TextInput,
|
|
870
|
+
{
|
|
871
|
+
testID: testID ? `${testID}-field` : "number-input-field",
|
|
872
|
+
value: value.toFixed(precision),
|
|
873
|
+
editable: !disabled && !readOnlyInput,
|
|
874
|
+
keyboardType: "numeric",
|
|
875
|
+
accessibilityLabel: "Numeric value",
|
|
876
|
+
onChangeText: (t) => {
|
|
877
|
+
const parsed = Number(t.replace(/[^0-9.\-]/g, ""));
|
|
878
|
+
setValue(parsed);
|
|
879
|
+
},
|
|
880
|
+
className: cn(
|
|
881
|
+
"min-w-[64px] flex-1 border-x border-input bg-background text-center text-base text-foreground",
|
|
882
|
+
inputClassName
|
|
883
|
+
)
|
|
884
|
+
}
|
|
885
|
+
),
|
|
886
|
+
/* @__PURE__ */ jsx(
|
|
887
|
+
Pressable,
|
|
888
|
+
{
|
|
889
|
+
testID: testID ? `${testID}-increment` : "number-input-increment",
|
|
890
|
+
accessibilityRole: "button",
|
|
891
|
+
accessibilityLabel: "Increment",
|
|
892
|
+
disabled: incBlocked,
|
|
893
|
+
onPress: () => setValue(value + step),
|
|
894
|
+
className: cn(
|
|
895
|
+
"min-h-[44px] min-w-[44px] items-center justify-center px-3",
|
|
896
|
+
incBlocked && "opacity-40"
|
|
897
|
+
),
|
|
898
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-xl font-semibold text-foreground", children: "+" })
|
|
899
|
+
}
|
|
900
|
+
)
|
|
901
|
+
]
|
|
902
|
+
}
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
function NativeStepper({
|
|
906
|
+
steps,
|
|
907
|
+
current,
|
|
908
|
+
className,
|
|
909
|
+
testID
|
|
910
|
+
}) {
|
|
911
|
+
return /* @__PURE__ */ jsxs(
|
|
912
|
+
View,
|
|
913
|
+
{
|
|
914
|
+
testID: testID ?? "native-stepper",
|
|
915
|
+
accessibilityRole: "progressbar",
|
|
916
|
+
accessibilityValue: { now: current + 1, min: 1, max: steps.length },
|
|
917
|
+
className: cn("w-full", className),
|
|
918
|
+
children: [
|
|
919
|
+
/* @__PURE__ */ jsx(View, { className: "flex-row items-center", children: steps.map((s, i) => {
|
|
920
|
+
const isCompleted = i < current;
|
|
921
|
+
const isCurrent = i === current;
|
|
922
|
+
return /* @__PURE__ */ jsxs(View, { className: "flex-1 flex-row items-center", children: [
|
|
923
|
+
/* @__PURE__ */ jsx(
|
|
924
|
+
View,
|
|
925
|
+
{
|
|
926
|
+
testID: testID ? `${testID}-dot-${i}` : void 0,
|
|
927
|
+
accessibilityLabel: `Step ${i + 1}: ${s.label}`,
|
|
928
|
+
accessibilityState: { selected: isCurrent },
|
|
929
|
+
className: cn(
|
|
930
|
+
"h-7 w-7 items-center justify-center rounded-full border",
|
|
931
|
+
isCompleted && "bg-primary border-primary",
|
|
932
|
+
isCurrent && "bg-background border-primary",
|
|
933
|
+
!isCompleted && !isCurrent && "bg-background border-border"
|
|
934
|
+
),
|
|
935
|
+
children: /* @__PURE__ */ jsx(
|
|
936
|
+
Text,
|
|
937
|
+
{
|
|
938
|
+
className: cn(
|
|
939
|
+
"text-xs font-semibold",
|
|
940
|
+
isCompleted && "text-primary-foreground",
|
|
941
|
+
isCurrent && "text-primary",
|
|
942
|
+
!isCompleted && !isCurrent && "text-muted-foreground"
|
|
943
|
+
),
|
|
944
|
+
children: i + 1
|
|
945
|
+
}
|
|
946
|
+
)
|
|
947
|
+
}
|
|
948
|
+
),
|
|
949
|
+
i < steps.length - 1 ? /* @__PURE__ */ jsx(
|
|
950
|
+
View,
|
|
951
|
+
{
|
|
952
|
+
className: cn(
|
|
953
|
+
"mx-1 h-0.5 flex-1",
|
|
954
|
+
isCompleted ? "bg-primary" : "bg-border"
|
|
955
|
+
)
|
|
956
|
+
}
|
|
957
|
+
) : null
|
|
958
|
+
] }, i);
|
|
959
|
+
}) }),
|
|
960
|
+
/* @__PURE__ */ jsx(View, { className: "mt-2 flex-row", children: steps.map((s, i) => /* @__PURE__ */ jsx(View, { className: "flex-1 px-1", children: /* @__PURE__ */ jsx(
|
|
961
|
+
Text,
|
|
962
|
+
{
|
|
963
|
+
className: cn(
|
|
964
|
+
"text-center text-xs",
|
|
965
|
+
i === current ? "font-semibold text-foreground" : "text-muted-foreground"
|
|
966
|
+
),
|
|
967
|
+
numberOfLines: 1,
|
|
968
|
+
children: s.label
|
|
969
|
+
}
|
|
970
|
+
) }, i)) })
|
|
971
|
+
]
|
|
972
|
+
}
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
function snap(v, step, min, max) {
|
|
976
|
+
const clamped = Math.min(max, Math.max(min, v));
|
|
977
|
+
if (step <= 0) return clamped;
|
|
978
|
+
const stepped = Math.round((clamped - min) / step) * step + min;
|
|
979
|
+
return Math.min(max, Math.max(min, stepped));
|
|
980
|
+
}
|
|
981
|
+
function useTrackWidth() {
|
|
982
|
+
const [width, setWidth] = useState(0);
|
|
983
|
+
const onLayout = (e) => {
|
|
984
|
+
const w = e.nativeEvent?.layout?.width;
|
|
985
|
+
if (typeof w === "number") setWidth(w);
|
|
986
|
+
};
|
|
987
|
+
return { width, onLayout };
|
|
988
|
+
}
|
|
989
|
+
function NativeSlider({
|
|
990
|
+
value,
|
|
991
|
+
onChange,
|
|
992
|
+
min = 0,
|
|
993
|
+
max = 100,
|
|
994
|
+
step = 1,
|
|
995
|
+
className,
|
|
996
|
+
trackClassName,
|
|
997
|
+
fillClassName,
|
|
998
|
+
thumbClassName,
|
|
999
|
+
testID
|
|
1000
|
+
}) {
|
|
1001
|
+
const { width, onLayout } = useTrackWidth();
|
|
1002
|
+
const startValue = useRef(value);
|
|
1003
|
+
const responder = useMemo(
|
|
1004
|
+
() => PanResponder.create({
|
|
1005
|
+
onStartShouldSetPanResponder: () => true,
|
|
1006
|
+
onMoveShouldSetPanResponder: () => true,
|
|
1007
|
+
onPanResponderGrant: () => {
|
|
1008
|
+
startValue.current = value;
|
|
1009
|
+
},
|
|
1010
|
+
onPanResponderMove: (_e, g) => {
|
|
1011
|
+
if (width <= 0) return;
|
|
1012
|
+
const delta = g.dx / width * (max - min);
|
|
1013
|
+
onChange(snap(startValue.current + delta, step, min, max));
|
|
1014
|
+
}
|
|
1015
|
+
}),
|
|
1016
|
+
[max, min, onChange, step, value, width]
|
|
1017
|
+
);
|
|
1018
|
+
const ratio = width === 0 ? 0 : (value - min) / (max - min);
|
|
1019
|
+
const fillWidth = Math.round(ratio * width);
|
|
1020
|
+
return /* @__PURE__ */ jsxs(
|
|
1021
|
+
View,
|
|
1022
|
+
{
|
|
1023
|
+
testID: testID ?? "native-slider",
|
|
1024
|
+
accessibilityRole: "adjustable",
|
|
1025
|
+
accessibilityValue: { now: value, min, max },
|
|
1026
|
+
onLayout,
|
|
1027
|
+
className: cn("h-11 w-full justify-center", className),
|
|
1028
|
+
...responder.panHandlers,
|
|
1029
|
+
children: [
|
|
1030
|
+
/* @__PURE__ */ jsx(View, { className: cn("h-1.5 rounded-full bg-muted", trackClassName) }),
|
|
1031
|
+
/* @__PURE__ */ jsx(
|
|
1032
|
+
View,
|
|
1033
|
+
{
|
|
1034
|
+
className: cn(
|
|
1035
|
+
"absolute h-1.5 rounded-full bg-primary",
|
|
1036
|
+
fillClassName
|
|
1037
|
+
),
|
|
1038
|
+
style: { width: fillWidth }
|
|
1039
|
+
}
|
|
1040
|
+
),
|
|
1041
|
+
/* @__PURE__ */ jsx(
|
|
1042
|
+
View,
|
|
1043
|
+
{
|
|
1044
|
+
testID: testID ? `${testID}-thumb` : void 0,
|
|
1045
|
+
accessibilityElementsHidden: true,
|
|
1046
|
+
importantForAccessibility: "no-hide-descendants",
|
|
1047
|
+
className: cn(
|
|
1048
|
+
"absolute h-6 w-6 rounded-full border-2 border-primary bg-background shadow",
|
|
1049
|
+
thumbClassName
|
|
1050
|
+
),
|
|
1051
|
+
style: { left: Math.max(0, fillWidth - 12) }
|
|
1052
|
+
}
|
|
1053
|
+
)
|
|
1054
|
+
]
|
|
1055
|
+
}
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
function NativeRangeSlider({
|
|
1059
|
+
value,
|
|
1060
|
+
onChange,
|
|
1061
|
+
min = 0,
|
|
1062
|
+
max = 100,
|
|
1063
|
+
step = 1,
|
|
1064
|
+
className,
|
|
1065
|
+
trackClassName,
|
|
1066
|
+
fillClassName,
|
|
1067
|
+
thumbClassName,
|
|
1068
|
+
testID
|
|
1069
|
+
}) {
|
|
1070
|
+
const { width, onLayout } = useTrackWidth();
|
|
1071
|
+
const startLow = useRef(value[0]);
|
|
1072
|
+
const startHigh = useRef(value[1]);
|
|
1073
|
+
const lowResponder = useMemo(
|
|
1074
|
+
() => PanResponder.create({
|
|
1075
|
+
onStartShouldSetPanResponder: () => true,
|
|
1076
|
+
onMoveShouldSetPanResponder: () => true,
|
|
1077
|
+
onPanResponderGrant: () => {
|
|
1078
|
+
startLow.current = value[0];
|
|
1079
|
+
},
|
|
1080
|
+
onPanResponderMove: (_e, g) => {
|
|
1081
|
+
if (width <= 0) return;
|
|
1082
|
+
const delta = g.dx / width * (max - min);
|
|
1083
|
+
const next = snap(startLow.current + delta, step, min, value[1]);
|
|
1084
|
+
onChange([next, value[1]]);
|
|
1085
|
+
}
|
|
1086
|
+
}),
|
|
1087
|
+
[max, min, onChange, step, value, width]
|
|
1088
|
+
);
|
|
1089
|
+
const highResponder = useMemo(
|
|
1090
|
+
() => PanResponder.create({
|
|
1091
|
+
onStartShouldSetPanResponder: () => true,
|
|
1092
|
+
onMoveShouldSetPanResponder: () => true,
|
|
1093
|
+
onPanResponderGrant: () => {
|
|
1094
|
+
startHigh.current = value[1];
|
|
1095
|
+
},
|
|
1096
|
+
onPanResponderMove: (_e, g) => {
|
|
1097
|
+
if (width <= 0) return;
|
|
1098
|
+
const delta = g.dx / width * (max - min);
|
|
1099
|
+
const next = snap(startHigh.current + delta, step, value[0], max);
|
|
1100
|
+
onChange([value[0], next]);
|
|
1101
|
+
}
|
|
1102
|
+
}),
|
|
1103
|
+
[max, min, onChange, step, value, width]
|
|
1104
|
+
);
|
|
1105
|
+
const lowRatio = width === 0 ? 0 : (value[0] - min) / (max - min);
|
|
1106
|
+
const highRatio = width === 0 ? 0 : (value[1] - min) / (max - min);
|
|
1107
|
+
const lowX = Math.round(lowRatio * width);
|
|
1108
|
+
const highX = Math.round(highRatio * width);
|
|
1109
|
+
return /* @__PURE__ */ jsxs(
|
|
1110
|
+
View,
|
|
1111
|
+
{
|
|
1112
|
+
testID: testID ?? "native-range-slider",
|
|
1113
|
+
onLayout,
|
|
1114
|
+
className: cn("h-11 w-full justify-center", className),
|
|
1115
|
+
children: [
|
|
1116
|
+
/* @__PURE__ */ jsx(View, { className: cn("h-1.5 rounded-full bg-muted", trackClassName) }),
|
|
1117
|
+
/* @__PURE__ */ jsx(
|
|
1118
|
+
View,
|
|
1119
|
+
{
|
|
1120
|
+
className: cn(
|
|
1121
|
+
"absolute h-1.5 rounded-full bg-primary",
|
|
1122
|
+
fillClassName
|
|
1123
|
+
),
|
|
1124
|
+
style: { left: lowX, width: highX - lowX }
|
|
1125
|
+
}
|
|
1126
|
+
),
|
|
1127
|
+
/* @__PURE__ */ jsx(
|
|
1128
|
+
View,
|
|
1129
|
+
{
|
|
1130
|
+
testID: testID ? `${testID}-thumb-low` : void 0,
|
|
1131
|
+
accessibilityRole: "adjustable",
|
|
1132
|
+
accessibilityValue: { now: value[0], min, max: value[1] },
|
|
1133
|
+
className: cn(
|
|
1134
|
+
"absolute h-6 w-6 rounded-full border-2 border-primary bg-background shadow",
|
|
1135
|
+
thumbClassName
|
|
1136
|
+
),
|
|
1137
|
+
style: { left: Math.max(0, lowX - 12) },
|
|
1138
|
+
...lowResponder.panHandlers
|
|
1139
|
+
}
|
|
1140
|
+
),
|
|
1141
|
+
/* @__PURE__ */ jsx(
|
|
1142
|
+
View,
|
|
1143
|
+
{
|
|
1144
|
+
testID: testID ? `${testID}-thumb-high` : void 0,
|
|
1145
|
+
accessibilityRole: "adjustable",
|
|
1146
|
+
accessibilityValue: { now: value[1], min: value[0], max },
|
|
1147
|
+
className: cn(
|
|
1148
|
+
"absolute h-6 w-6 rounded-full border-2 border-primary bg-background shadow",
|
|
1149
|
+
thumbClassName
|
|
1150
|
+
),
|
|
1151
|
+
style: { left: Math.max(0, highX - 12) },
|
|
1152
|
+
...highResponder.panHandlers
|
|
1153
|
+
}
|
|
1154
|
+
)
|
|
1155
|
+
]
|
|
1156
|
+
}
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
function NativeSegmentedControl({
|
|
1160
|
+
options,
|
|
1161
|
+
value,
|
|
1162
|
+
onChange,
|
|
1163
|
+
disabled,
|
|
1164
|
+
className,
|
|
1165
|
+
testID
|
|
1166
|
+
}) {
|
|
1167
|
+
return /* @__PURE__ */ jsx(
|
|
1168
|
+
View,
|
|
1169
|
+
{
|
|
1170
|
+
testID: testID ?? "native-segmented",
|
|
1171
|
+
accessibilityRole: "radiogroup",
|
|
1172
|
+
className: cn(
|
|
1173
|
+
"flex-row rounded-md border border-border bg-muted p-0.5",
|
|
1174
|
+
disabled && "opacity-50",
|
|
1175
|
+
className
|
|
1176
|
+
),
|
|
1177
|
+
children: options.map((opt) => {
|
|
1178
|
+
const selected = opt.value === value;
|
|
1179
|
+
return /* @__PURE__ */ jsx(
|
|
1180
|
+
Pressable,
|
|
1181
|
+
{
|
|
1182
|
+
testID: testID ? `${testID}-option-${String(opt.value)}` : `segmented-option-${String(opt.value)}`,
|
|
1183
|
+
disabled,
|
|
1184
|
+
accessibilityRole: "radio",
|
|
1185
|
+
accessibilityState: { selected, disabled },
|
|
1186
|
+
onPress: () => onChange(opt.value),
|
|
1187
|
+
className: cn(
|
|
1188
|
+
"min-h-[36px] flex-1 items-center justify-center rounded px-3 py-1",
|
|
1189
|
+
selected && "bg-background shadow-sm"
|
|
1190
|
+
),
|
|
1191
|
+
children: /* @__PURE__ */ jsx(
|
|
1192
|
+
Text,
|
|
1193
|
+
{
|
|
1194
|
+
className: cn(
|
|
1195
|
+
"text-sm",
|
|
1196
|
+
selected ? "font-semibold text-foreground" : "text-muted-foreground"
|
|
1197
|
+
),
|
|
1198
|
+
children: opt.label
|
|
1199
|
+
}
|
|
1200
|
+
)
|
|
1201
|
+
},
|
|
1202
|
+
String(opt.value)
|
|
1203
|
+
);
|
|
1204
|
+
})
|
|
1205
|
+
}
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
var ChipContext = createContext(null);
|
|
1209
|
+
function NativeChipGroup({
|
|
1210
|
+
mode = "multiple",
|
|
1211
|
+
value,
|
|
1212
|
+
onChange,
|
|
1213
|
+
disabled,
|
|
1214
|
+
className,
|
|
1215
|
+
children,
|
|
1216
|
+
testID
|
|
1217
|
+
}) {
|
|
1218
|
+
const selected = new Set(
|
|
1219
|
+
mode === "single" ? typeof value === "string" ? [value] : [] : Array.isArray(value) ? value : []
|
|
1220
|
+
);
|
|
1221
|
+
const toggle = (v) => {
|
|
1222
|
+
if (mode === "single") {
|
|
1223
|
+
onChange(v);
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1226
|
+
const next = new Set(selected);
|
|
1227
|
+
if (next.has(v)) next.delete(v);
|
|
1228
|
+
else next.add(v);
|
|
1229
|
+
onChange(Array.from(next));
|
|
1230
|
+
};
|
|
1231
|
+
return /* @__PURE__ */ jsx(ChipContext.Provider, { value: { mode, selected, toggle, disabled }, children: /* @__PURE__ */ jsx(
|
|
1232
|
+
View,
|
|
1233
|
+
{
|
|
1234
|
+
testID: testID ?? "native-chip-group",
|
|
1235
|
+
accessibilityRole: mode === "single" ? "radiogroup" : void 0,
|
|
1236
|
+
className: cn("flex-row flex-wrap gap-2", className),
|
|
1237
|
+
children
|
|
1238
|
+
}
|
|
1239
|
+
) });
|
|
1240
|
+
}
|
|
1241
|
+
function NativeChip({
|
|
1242
|
+
value,
|
|
1243
|
+
className,
|
|
1244
|
+
children,
|
|
1245
|
+
testID
|
|
1246
|
+
}) {
|
|
1247
|
+
const ctx = useContext(ChipContext);
|
|
1248
|
+
if (!ctx)
|
|
1249
|
+
throw new Error("NativeChip must be used inside <NativeChipGroup>.");
|
|
1250
|
+
const isSelected = ctx.selected.has(value);
|
|
1251
|
+
return /* @__PURE__ */ jsx(
|
|
1252
|
+
Pressable,
|
|
1253
|
+
{
|
|
1254
|
+
testID: testID ?? `chip-${value}`,
|
|
1255
|
+
accessibilityRole: ctx.mode === "single" ? "radio" : "checkbox",
|
|
1256
|
+
accessibilityState: { selected: isSelected, disabled: ctx.disabled },
|
|
1257
|
+
disabled: ctx.disabled,
|
|
1258
|
+
onPress: () => ctx.toggle(value),
|
|
1259
|
+
className: cn(
|
|
1260
|
+
"min-h-[44px] flex-row items-center rounded-full border px-3.5 py-1.5",
|
|
1261
|
+
isSelected ? "border-primary bg-primary/10" : "border-border bg-background",
|
|
1262
|
+
ctx.disabled && "opacity-50",
|
|
1263
|
+
className
|
|
1264
|
+
),
|
|
1265
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx(
|
|
1266
|
+
Text,
|
|
1267
|
+
{
|
|
1268
|
+
className: cn(
|
|
1269
|
+
"text-sm",
|
|
1270
|
+
isSelected ? "font-semibold text-primary" : "text-foreground"
|
|
1271
|
+
),
|
|
1272
|
+
children
|
|
1273
|
+
}
|
|
1274
|
+
) : children
|
|
1275
|
+
}
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
function buildWindow(page, total, maxVisible) {
|
|
1279
|
+
if (total <= maxVisible) return Array.from({ length: total }, (_, i) => i);
|
|
1280
|
+
const half = Math.floor(maxVisible / 2);
|
|
1281
|
+
let start = Math.max(0, page - half);
|
|
1282
|
+
let end = Math.min(total, start + maxVisible);
|
|
1283
|
+
if (end - start < maxVisible) start = Math.max(0, end - maxVisible);
|
|
1284
|
+
return Array.from({ length: end - start }, (_, i) => start + i);
|
|
1285
|
+
}
|
|
1286
|
+
function NativePagination({
|
|
1287
|
+
pageCount,
|
|
1288
|
+
page,
|
|
1289
|
+
onChange,
|
|
1290
|
+
maxVisible = 5,
|
|
1291
|
+
className,
|
|
1292
|
+
testID
|
|
1293
|
+
}) {
|
|
1294
|
+
if (pageCount <= 0) return null;
|
|
1295
|
+
const window = buildWindow(page, pageCount, maxVisible);
|
|
1296
|
+
const showLeadingEllipsis = window[0] > 0;
|
|
1297
|
+
const showTrailingEllipsis = window[window.length - 1] < pageCount - 1;
|
|
1298
|
+
return /* @__PURE__ */ jsxs(
|
|
1299
|
+
View,
|
|
1300
|
+
{
|
|
1301
|
+
testID: testID ?? "native-pagination",
|
|
1302
|
+
accessibilityLabel: `Page ${page + 1} of ${pageCount}`,
|
|
1303
|
+
className: cn("flex-row items-center gap-1", className),
|
|
1304
|
+
children: [
|
|
1305
|
+
/* @__PURE__ */ jsx(
|
|
1306
|
+
PageButton,
|
|
1307
|
+
{
|
|
1308
|
+
testID: testID ? `${testID}-prev` : "pagination-prev",
|
|
1309
|
+
label: "\u2039",
|
|
1310
|
+
a11y: "Previous page",
|
|
1311
|
+
disabled: page <= 0,
|
|
1312
|
+
onPress: () => onChange(Math.max(0, page - 1))
|
|
1313
|
+
}
|
|
1314
|
+
),
|
|
1315
|
+
showLeadingEllipsis ? /* @__PURE__ */ jsx(Ellipsis, {}) : null,
|
|
1316
|
+
window.map((i) => /* @__PURE__ */ jsx(
|
|
1317
|
+
PageButton,
|
|
1318
|
+
{
|
|
1319
|
+
testID: testID ? `${testID}-page-${i}` : `pagination-page-${i}`,
|
|
1320
|
+
label: String(i + 1),
|
|
1321
|
+
a11y: `Page ${i + 1}`,
|
|
1322
|
+
selected: i === page,
|
|
1323
|
+
onPress: () => onChange(i)
|
|
1324
|
+
},
|
|
1325
|
+
i
|
|
1326
|
+
)),
|
|
1327
|
+
showTrailingEllipsis ? /* @__PURE__ */ jsx(Ellipsis, {}) : null,
|
|
1328
|
+
/* @__PURE__ */ jsx(
|
|
1329
|
+
PageButton,
|
|
1330
|
+
{
|
|
1331
|
+
testID: testID ? `${testID}-next` : "pagination-next",
|
|
1332
|
+
label: "\u203A",
|
|
1333
|
+
a11y: "Next page",
|
|
1334
|
+
disabled: page >= pageCount - 1,
|
|
1335
|
+
onPress: () => onChange(Math.min(pageCount - 1, page + 1))
|
|
1336
|
+
}
|
|
1337
|
+
)
|
|
1338
|
+
]
|
|
1339
|
+
}
|
|
1340
|
+
);
|
|
1341
|
+
}
|
|
1342
|
+
function PageButton({ testID, label, a11y, selected, disabled, onPress }) {
|
|
1343
|
+
return /* @__PURE__ */ jsx(
|
|
1344
|
+
Pressable,
|
|
1345
|
+
{
|
|
1346
|
+
testID,
|
|
1347
|
+
accessibilityRole: "button",
|
|
1348
|
+
accessibilityLabel: a11y,
|
|
1349
|
+
accessibilityState: { selected, disabled },
|
|
1350
|
+
disabled,
|
|
1351
|
+
onPress,
|
|
1352
|
+
className: cn(
|
|
1353
|
+
"min-h-[44px] min-w-[44px] items-center justify-center rounded-md border px-2",
|
|
1354
|
+
selected ? "border-primary bg-primary" : "border-border bg-background",
|
|
1355
|
+
disabled && "opacity-40"
|
|
1356
|
+
),
|
|
1357
|
+
children: /* @__PURE__ */ jsx(
|
|
1358
|
+
Text,
|
|
1359
|
+
{
|
|
1360
|
+
className: cn(
|
|
1361
|
+
"text-sm font-medium",
|
|
1362
|
+
selected ? "text-primary-foreground" : "text-foreground"
|
|
1363
|
+
),
|
|
1364
|
+
children: label
|
|
1365
|
+
}
|
|
1366
|
+
)
|
|
1367
|
+
}
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
function Ellipsis() {
|
|
1371
|
+
return /* @__PURE__ */ jsx(
|
|
1372
|
+
Text,
|
|
1373
|
+
{
|
|
1374
|
+
accessibilityElementsHidden: true,
|
|
1375
|
+
className: "px-1 text-sm text-muted-foreground",
|
|
1376
|
+
children: "\u2026"
|
|
1377
|
+
}
|
|
1378
|
+
);
|
|
1379
|
+
}
|
|
1380
|
+
var variantClasses = {
|
|
1381
|
+
info: "bg-secondary border-border",
|
|
1382
|
+
success: "bg-primary/10 border-primary/30",
|
|
1383
|
+
warning: "bg-warning/10 border-warning/30",
|
|
1384
|
+
destructive: "bg-destructive/10 border-destructive/30"
|
|
1385
|
+
};
|
|
1386
|
+
var titleClasses = {
|
|
1387
|
+
info: "text-foreground",
|
|
1388
|
+
success: "text-primary",
|
|
1389
|
+
warning: "text-warning",
|
|
1390
|
+
destructive: "text-destructive"
|
|
1391
|
+
};
|
|
1392
|
+
function NativeInlineAlert({
|
|
1393
|
+
variant = "info",
|
|
1394
|
+
title,
|
|
1395
|
+
description,
|
|
1396
|
+
icon,
|
|
1397
|
+
onDismiss,
|
|
1398
|
+
className,
|
|
1399
|
+
testID
|
|
1400
|
+
}) {
|
|
1401
|
+
return /* @__PURE__ */ jsxs(
|
|
1402
|
+
View,
|
|
1403
|
+
{
|
|
1404
|
+
testID: testID ?? `inline-alert-${variant}`,
|
|
1405
|
+
accessibilityRole: "alert",
|
|
1406
|
+
className: cn(
|
|
1407
|
+
"flex-row gap-3 rounded-md border p-3",
|
|
1408
|
+
variantClasses[variant],
|
|
1409
|
+
className
|
|
1410
|
+
),
|
|
1411
|
+
children: [
|
|
1412
|
+
icon ? /* @__PURE__ */ jsx(View, { className: "pt-0.5", children: icon }) : null,
|
|
1413
|
+
/* @__PURE__ */ jsxs(View, { className: "flex-1", children: [
|
|
1414
|
+
title ? /* @__PURE__ */ jsx(Text, { className: cn("text-sm font-semibold", titleClasses[variant]), children: title }) : null,
|
|
1415
|
+
description ? /* @__PURE__ */ jsx(Text, { className: "mt-0.5 text-sm text-foreground/80", children: description }) : null
|
|
1416
|
+
] }),
|
|
1417
|
+
onDismiss ? /* @__PURE__ */ jsx(
|
|
1418
|
+
Pressable,
|
|
1419
|
+
{
|
|
1420
|
+
testID: testID ? `${testID}-dismiss` : void 0,
|
|
1421
|
+
accessibilityRole: "button",
|
|
1422
|
+
accessibilityLabel: "Dismiss",
|
|
1423
|
+
onPress: onDismiss,
|
|
1424
|
+
hitSlop: 8,
|
|
1425
|
+
className: "min-h-[24px] min-w-[24px] items-center justify-center",
|
|
1426
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-muted-foreground", children: "\u2715" })
|
|
1427
|
+
}
|
|
1428
|
+
) : null
|
|
1429
|
+
]
|
|
1430
|
+
}
|
|
1431
|
+
);
|
|
1432
|
+
}
|
|
1433
|
+
function NativeBanner({
|
|
1434
|
+
variant = "info",
|
|
1435
|
+
title,
|
|
1436
|
+
description,
|
|
1437
|
+
icon,
|
|
1438
|
+
onDismiss,
|
|
1439
|
+
className,
|
|
1440
|
+
testID
|
|
1441
|
+
}) {
|
|
1442
|
+
return /* @__PURE__ */ jsxs(
|
|
1443
|
+
View,
|
|
1444
|
+
{
|
|
1445
|
+
testID: testID ?? `banner-${variant}`,
|
|
1446
|
+
accessibilityRole: "alert",
|
|
1447
|
+
accessibilityLiveRegion: "polite",
|
|
1448
|
+
className: cn(
|
|
1449
|
+
"flex-row items-start gap-3 border-b px-4 py-3",
|
|
1450
|
+
variantClasses[variant],
|
|
1451
|
+
className
|
|
1452
|
+
),
|
|
1453
|
+
children: [
|
|
1454
|
+
icon ? /* @__PURE__ */ jsx(View, { className: "pt-0.5", children: icon }) : null,
|
|
1455
|
+
/* @__PURE__ */ jsxs(View, { className: "flex-1", children: [
|
|
1456
|
+
title ? /* @__PURE__ */ jsx(Text, { className: cn("text-sm font-semibold", titleClasses[variant]), children: title }) : null,
|
|
1457
|
+
description ? /* @__PURE__ */ jsx(Text, { className: "mt-0.5 text-sm text-foreground/80", children: description }) : null
|
|
1458
|
+
] }),
|
|
1459
|
+
onDismiss ? /* @__PURE__ */ jsx(
|
|
1460
|
+
Pressable,
|
|
1461
|
+
{
|
|
1462
|
+
testID: testID ? `${testID}-dismiss` : void 0,
|
|
1463
|
+
accessibilityRole: "button",
|
|
1464
|
+
accessibilityLabel: "Dismiss",
|
|
1465
|
+
onPress: onDismiss,
|
|
1466
|
+
hitSlop: 8,
|
|
1467
|
+
className: "min-h-[24px] min-w-[24px] items-center justify-center",
|
|
1468
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-muted-foreground", children: "\u2715" })
|
|
1469
|
+
}
|
|
1470
|
+
) : null
|
|
1471
|
+
]
|
|
1472
|
+
}
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
function NativeSearchBar({
|
|
1476
|
+
value,
|
|
1477
|
+
onChange,
|
|
1478
|
+
onSubmit,
|
|
1479
|
+
placeholder = "Search",
|
|
1480
|
+
placeholderTextColor,
|
|
1481
|
+
onVoicePress,
|
|
1482
|
+
showCancel = true,
|
|
1483
|
+
cancelLabel = "Cancel",
|
|
1484
|
+
className,
|
|
1485
|
+
testID
|
|
1486
|
+
}) {
|
|
1487
|
+
const [focused, setFocused] = useState(false);
|
|
1488
|
+
const inputRef = useRef(null);
|
|
1489
|
+
return /* @__PURE__ */ jsxs(
|
|
1490
|
+
View,
|
|
1491
|
+
{
|
|
1492
|
+
testID: testID ?? "native-search-bar",
|
|
1493
|
+
className: cn("flex-row items-center gap-2", className),
|
|
1494
|
+
children: [
|
|
1495
|
+
/* @__PURE__ */ jsxs(View, { className: "flex-1 flex-row items-center rounded-md border border-input bg-background px-3", children: [
|
|
1496
|
+
/* @__PURE__ */ jsx(Text, { accessibilityElementsHidden: true, className: "text-sm text-muted-foreground", children: "\u{1F50D}" }),
|
|
1497
|
+
/* @__PURE__ */ jsx(
|
|
1498
|
+
TextInput,
|
|
1499
|
+
{
|
|
1500
|
+
ref: inputRef,
|
|
1501
|
+
testID: testID ? `${testID}-input` : "search-input",
|
|
1502
|
+
value,
|
|
1503
|
+
onChangeText: onChange,
|
|
1504
|
+
onFocus: () => setFocused(true),
|
|
1505
|
+
onBlur: () => setFocused(false),
|
|
1506
|
+
onSubmitEditing: () => onSubmit?.(value),
|
|
1507
|
+
placeholder,
|
|
1508
|
+
placeholderTextColor,
|
|
1509
|
+
accessibilityLabel: placeholder,
|
|
1510
|
+
returnKeyType: "search",
|
|
1511
|
+
autoCorrect: false,
|
|
1512
|
+
autoCapitalize: "none",
|
|
1513
|
+
clearButtonMode: "never",
|
|
1514
|
+
className: "ml-2 min-h-[44px] flex-1 text-base text-foreground"
|
|
1515
|
+
}
|
|
1516
|
+
),
|
|
1517
|
+
value.length > 0 ? /* @__PURE__ */ jsx(
|
|
1518
|
+
Pressable,
|
|
1519
|
+
{
|
|
1520
|
+
testID: testID ? `${testID}-clear` : "search-clear",
|
|
1521
|
+
accessibilityRole: "button",
|
|
1522
|
+
accessibilityLabel: "Clear search",
|
|
1523
|
+
hitSlop: 8,
|
|
1524
|
+
onPress: () => onChange(""),
|
|
1525
|
+
className: "ml-1 min-h-[24px] min-w-[24px] items-center justify-center",
|
|
1526
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-sm text-muted-foreground", children: "\u2715" })
|
|
1527
|
+
}
|
|
1528
|
+
) : null,
|
|
1529
|
+
onVoicePress ? /* @__PURE__ */ jsx(
|
|
1530
|
+
Pressable,
|
|
1531
|
+
{
|
|
1532
|
+
testID: testID ? `${testID}-voice` : "search-voice",
|
|
1533
|
+
accessibilityRole: "button",
|
|
1534
|
+
accessibilityLabel: "Voice search",
|
|
1535
|
+
hitSlop: 8,
|
|
1536
|
+
onPress: onVoicePress,
|
|
1537
|
+
className: "ml-2 min-h-[24px] min-w-[24px] items-center justify-center",
|
|
1538
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-sm text-muted-foreground", children: "\u{1F3A4}" })
|
|
1539
|
+
}
|
|
1540
|
+
) : null
|
|
1541
|
+
] }),
|
|
1542
|
+
showCancel && focused ? /* @__PURE__ */ jsx(
|
|
1543
|
+
Pressable,
|
|
1544
|
+
{
|
|
1545
|
+
testID: testID ? `${testID}-cancel` : "search-cancel",
|
|
1546
|
+
accessibilityRole: "button",
|
|
1547
|
+
accessibilityLabel: cancelLabel,
|
|
1548
|
+
onPress: () => {
|
|
1549
|
+
onChange("");
|
|
1550
|
+
inputRef.current?.blur();
|
|
1551
|
+
setFocused(false);
|
|
1552
|
+
},
|
|
1553
|
+
className: "min-h-[44px] items-center justify-center px-2",
|
|
1554
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-primary", children: cancelLabel })
|
|
1555
|
+
}
|
|
1556
|
+
) : null
|
|
1557
|
+
]
|
|
1558
|
+
}
|
|
1559
|
+
);
|
|
1560
|
+
}
|
|
1561
|
+
function resolveRefreshControl() {
|
|
1562
|
+
try {
|
|
1563
|
+
const rn = __require("react-native");
|
|
1564
|
+
return rn.RefreshControl;
|
|
1565
|
+
} catch {
|
|
1566
|
+
return null;
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
var useGenesisThemeRef = (() => {
|
|
1570
|
+
try {
|
|
1571
|
+
const provider = __require("@marktiderman/genesis-design-system/providers/native");
|
|
1572
|
+
return provider.useGenesisTheme ?? null;
|
|
1573
|
+
} catch {
|
|
1574
|
+
return null;
|
|
1575
|
+
}
|
|
1576
|
+
})();
|
|
1577
|
+
function NativeRefreshControl(props) {
|
|
1578
|
+
const RC = resolveRefreshControl();
|
|
1579
|
+
const theme = useGenesisThemeRef ? useGenesisThemeRef() : null;
|
|
1580
|
+
const themePrimary = theme?.colors?.primary;
|
|
1581
|
+
if (!RC) return null;
|
|
1582
|
+
return /* @__PURE__ */ jsx(
|
|
1583
|
+
RC,
|
|
1584
|
+
{
|
|
1585
|
+
tintColor: props.tintColor ?? themePrimary,
|
|
1586
|
+
colors: props.colors ?? (themePrimary ? [themePrimary] : void 0),
|
|
1587
|
+
...props,
|
|
1588
|
+
testID: props.testID ?? "native-refresh-control"
|
|
1589
|
+
}
|
|
1590
|
+
);
|
|
1591
|
+
}
|
|
1592
|
+
function NativeAvatar({
|
|
1593
|
+
className,
|
|
1594
|
+
src,
|
|
1595
|
+
alt,
|
|
1596
|
+
fallback,
|
|
1597
|
+
size = 40,
|
|
1598
|
+
...props
|
|
1599
|
+
}) {
|
|
1600
|
+
const [hasError, setHasError] = useState(false);
|
|
1601
|
+
useEffect(() => {
|
|
1602
|
+
setHasError(false);
|
|
1603
|
+
}, [src]);
|
|
1604
|
+
const showImage = src && !hasError;
|
|
1605
|
+
return /* @__PURE__ */ jsx(
|
|
1606
|
+
View,
|
|
1607
|
+
{
|
|
1608
|
+
className: cn(
|
|
1609
|
+
"items-center justify-center overflow-hidden rounded-full bg-muted",
|
|
1610
|
+
className
|
|
1611
|
+
),
|
|
1612
|
+
style: [{ width: size, height: size }],
|
|
1613
|
+
accessibilityLabel: alt || fallback || "Avatar",
|
|
1614
|
+
...props,
|
|
1615
|
+
children: showImage ? /* @__PURE__ */ jsx(
|
|
1616
|
+
Image,
|
|
1617
|
+
{
|
|
1618
|
+
source: { uri: src },
|
|
1619
|
+
className: "h-full w-full",
|
|
1620
|
+
resizeMode: "cover",
|
|
1621
|
+
onError: () => setHasError(true),
|
|
1622
|
+
accessibilityLabel: alt
|
|
1623
|
+
}
|
|
1624
|
+
) : /* @__PURE__ */ jsx(
|
|
1625
|
+
Text,
|
|
1626
|
+
{
|
|
1627
|
+
className: "text-sm font-medium text-muted-foreground",
|
|
1628
|
+
style: {
|
|
1629
|
+
fontSize: Math.round(size * 0.4),
|
|
1630
|
+
lineHeight: Math.round(size * 0.5)
|
|
1631
|
+
},
|
|
1632
|
+
children: fallback || "?"
|
|
1633
|
+
}
|
|
1634
|
+
)
|
|
1635
|
+
}
|
|
1636
|
+
);
|
|
1637
|
+
}
|
|
1638
|
+
function NativeProgress({
|
|
1639
|
+
className,
|
|
1640
|
+
value = 0,
|
|
1641
|
+
trackClassName,
|
|
1642
|
+
indicatorClassName,
|
|
1643
|
+
...props
|
|
1644
|
+
}) {
|
|
1645
|
+
const safeValue = Number.isFinite(value) ? value : 0;
|
|
1646
|
+
const clampedValue = Math.min(100, Math.max(0, safeValue));
|
|
1647
|
+
return /* @__PURE__ */ jsx(
|
|
1648
|
+
View,
|
|
1649
|
+
{
|
|
1650
|
+
className: cn(
|
|
1651
|
+
"h-2 w-full overflow-hidden rounded-full bg-muted",
|
|
1652
|
+
trackClassName,
|
|
1653
|
+
className
|
|
1654
|
+
),
|
|
1655
|
+
accessibilityRole: "progressbar",
|
|
1656
|
+
accessibilityLabel: `${clampedValue}% complete`,
|
|
1657
|
+
accessibilityValue: { min: 0, max: 100, now: clampedValue },
|
|
1658
|
+
...props,
|
|
1659
|
+
children: /* @__PURE__ */ jsx(
|
|
1660
|
+
View,
|
|
1661
|
+
{
|
|
1662
|
+
className: cn("h-full rounded-full bg-primary", indicatorClassName),
|
|
1663
|
+
style: { width: `${clampedValue}%` }
|
|
1664
|
+
}
|
|
1665
|
+
)
|
|
1666
|
+
}
|
|
1667
|
+
);
|
|
1668
|
+
}
|
|
1669
|
+
function NativeDialog({ open, onOpenChange, children }) {
|
|
1670
|
+
return /* @__PURE__ */ jsx(
|
|
1671
|
+
Modal,
|
|
1672
|
+
{
|
|
1673
|
+
visible: open,
|
|
1674
|
+
transparent: true,
|
|
1675
|
+
animationType: "fade",
|
|
1676
|
+
onRequestClose: () => onOpenChange?.(false),
|
|
1677
|
+
children: /* @__PURE__ */ jsx(
|
|
1678
|
+
Pressable,
|
|
1679
|
+
{
|
|
1680
|
+
className: "flex-1 items-center justify-center bg-black/50",
|
|
1681
|
+
onPress: () => onOpenChange?.(false),
|
|
1682
|
+
children: /* @__PURE__ */ jsx(Pressable, { onPress: () => {
|
|
1683
|
+
}, children })
|
|
1684
|
+
}
|
|
1685
|
+
)
|
|
1686
|
+
}
|
|
1687
|
+
);
|
|
1688
|
+
}
|
|
1689
|
+
function NativeDialogContent({
|
|
1690
|
+
className,
|
|
1691
|
+
children,
|
|
1692
|
+
...props
|
|
1693
|
+
}) {
|
|
1694
|
+
return /* @__PURE__ */ jsx(
|
|
1695
|
+
View,
|
|
1696
|
+
{
|
|
1697
|
+
className: cn(
|
|
1698
|
+
"w-80 gap-4 rounded-lg border border-border bg-background p-6 shadow-lg",
|
|
1699
|
+
className
|
|
1700
|
+
),
|
|
1701
|
+
...props,
|
|
1702
|
+
children
|
|
1703
|
+
}
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
function NativeDialogHeader({
|
|
1707
|
+
className,
|
|
1708
|
+
children
|
|
1709
|
+
}) {
|
|
1710
|
+
return /* @__PURE__ */ jsx(View, { className: cn("gap-1.5", className), children });
|
|
1711
|
+
}
|
|
1712
|
+
function NativeDialogTitle({
|
|
1713
|
+
className,
|
|
1714
|
+
children
|
|
1715
|
+
}) {
|
|
1716
|
+
return /* @__PURE__ */ jsx(Text, { className: cn("text-lg font-semibold text-foreground", className), children });
|
|
1717
|
+
}
|
|
1718
|
+
function NativeDialogDescription({
|
|
1719
|
+
className,
|
|
1720
|
+
children
|
|
1721
|
+
}) {
|
|
1722
|
+
return /* @__PURE__ */ jsx(Text, { className: cn("text-sm text-muted-foreground", className), children });
|
|
1723
|
+
}
|
|
1724
|
+
function NativeDialogFooter({
|
|
1725
|
+
className,
|
|
1726
|
+
children
|
|
1727
|
+
}) {
|
|
1728
|
+
return /* @__PURE__ */ jsx(View, { className: cn("flex-row justify-end gap-2", className), children });
|
|
1729
|
+
}
|
|
1730
|
+
var DropdownMenuContext = createContext(null);
|
|
1731
|
+
function useDropdownMenuContext() {
|
|
1732
|
+
const ctx = useContext(DropdownMenuContext);
|
|
1733
|
+
if (!ctx) throw new Error("DropdownMenu compound components must be used within NativeDropdownMenu");
|
|
1734
|
+
return ctx;
|
|
1735
|
+
}
|
|
1736
|
+
function NativeDropdownMenu({ children }) {
|
|
1737
|
+
const [open, setOpen] = useState(false);
|
|
1738
|
+
return /* @__PURE__ */ jsx(DropdownMenuContext.Provider, { value: { open, setOpen }, children: /* @__PURE__ */ jsx(View, { children }) });
|
|
1739
|
+
}
|
|
1740
|
+
function NativeDropdownMenuTrigger({
|
|
1741
|
+
className,
|
|
1742
|
+
children,
|
|
1743
|
+
...props
|
|
1744
|
+
}) {
|
|
1745
|
+
const { setOpen } = useDropdownMenuContext();
|
|
1746
|
+
return /* @__PURE__ */ jsx(Pressable, { className: cn(className), onPress: () => setOpen(true), ...props, children });
|
|
1747
|
+
}
|
|
1748
|
+
function NativeDropdownMenuContent({
|
|
1749
|
+
className,
|
|
1750
|
+
children
|
|
1751
|
+
}) {
|
|
1752
|
+
const { open, setOpen } = useDropdownMenuContext();
|
|
1753
|
+
if (!open) return null;
|
|
1754
|
+
return /* @__PURE__ */ jsx(Modal, { transparent: true, animationType: "fade", onRequestClose: () => setOpen(false), children: /* @__PURE__ */ jsx(Pressable, { className: "flex-1", onPress: () => setOpen(false), children: /* @__PURE__ */ jsx(View, { className: "flex-1 items-center justify-center", children: /* @__PURE__ */ jsx(Pressable, { onPress: () => {
|
|
1755
|
+
}, children: /* @__PURE__ */ jsx(
|
|
1756
|
+
View,
|
|
1757
|
+
{
|
|
1758
|
+
className: cn(
|
|
1759
|
+
"min-w-[8rem] rounded-md border border-border bg-popover p-1 shadow-md",
|
|
1760
|
+
className
|
|
1761
|
+
),
|
|
1762
|
+
children
|
|
1763
|
+
}
|
|
1764
|
+
) }) }) }) });
|
|
1765
|
+
}
|
|
1766
|
+
function NativeDropdownMenuItem({
|
|
1767
|
+
className,
|
|
1768
|
+
children,
|
|
1769
|
+
onPress,
|
|
1770
|
+
disabled,
|
|
1771
|
+
...props
|
|
1772
|
+
}) {
|
|
1773
|
+
return /* @__PURE__ */ jsx(
|
|
1774
|
+
Pressable,
|
|
1775
|
+
{
|
|
1776
|
+
className: cn(
|
|
1777
|
+
"flex-row items-center rounded-sm px-2 py-1.5",
|
|
1778
|
+
disabled && "opacity-50",
|
|
1779
|
+
className
|
|
1780
|
+
),
|
|
1781
|
+
onPress,
|
|
1782
|
+
disabled,
|
|
1783
|
+
accessibilityRole: "menuitem",
|
|
1784
|
+
accessibilityState: { disabled },
|
|
1785
|
+
...props,
|
|
1786
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx(Text, { className: "text-sm text-popover-foreground", children }) : children
|
|
1787
|
+
}
|
|
1788
|
+
);
|
|
1789
|
+
}
|
|
1790
|
+
var RadioGroupContext = createContext(null);
|
|
1791
|
+
function useRadioGroup() {
|
|
1792
|
+
const context = useContext(RadioGroupContext);
|
|
1793
|
+
if (!context)
|
|
1794
|
+
throw new Error("RadioGroup components must be used within <NativeRadioGroup>");
|
|
1795
|
+
return context;
|
|
1796
|
+
}
|
|
1797
|
+
function NativeRadioGroup({
|
|
1798
|
+
className,
|
|
1799
|
+
value: controlledValue,
|
|
1800
|
+
defaultValue = "",
|
|
1801
|
+
onValueChange: controlledOnValueChange,
|
|
1802
|
+
children,
|
|
1803
|
+
...props
|
|
1804
|
+
}) {
|
|
1805
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
1806
|
+
const value = controlledValue ?? uncontrolledValue;
|
|
1807
|
+
const onValueChange = controlledValue !== void 0 ? controlledOnValueChange ?? (() => {
|
|
1808
|
+
}) : (v) => {
|
|
1809
|
+
setUncontrolledValue(v);
|
|
1810
|
+
controlledOnValueChange?.(v);
|
|
1811
|
+
};
|
|
1812
|
+
return /* @__PURE__ */ jsx(RadioGroupContext.Provider, { value: { value, onValueChange }, children: /* @__PURE__ */ jsx(View, { className: cn("gap-2", className), ...props, children }) });
|
|
1813
|
+
}
|
|
1814
|
+
function NativeRadioGroupItem({
|
|
1815
|
+
className,
|
|
1816
|
+
value,
|
|
1817
|
+
disabled,
|
|
1818
|
+
...props
|
|
1819
|
+
}) {
|
|
1820
|
+
const { value: selectedValue, onValueChange } = useRadioGroup();
|
|
1821
|
+
const isSelected = selectedValue === value;
|
|
1822
|
+
return /* @__PURE__ */ jsx(
|
|
1823
|
+
Pressable,
|
|
1824
|
+
{
|
|
1825
|
+
className: cn(
|
|
1826
|
+
"h-5 w-5 items-center justify-center rounded-full border border-primary",
|
|
1827
|
+
disabled && "opacity-50",
|
|
1828
|
+
className
|
|
1829
|
+
),
|
|
1830
|
+
onPress: () => onValueChange(value),
|
|
1831
|
+
disabled,
|
|
1832
|
+
accessibilityRole: "radio",
|
|
1833
|
+
accessibilityState: { checked: isSelected, disabled },
|
|
1834
|
+
...props,
|
|
1835
|
+
children: isSelected ? /* @__PURE__ */ jsx(View, { className: "h-2.5 w-2.5 rounded-full bg-primary" }) : null
|
|
1836
|
+
}
|
|
1837
|
+
);
|
|
1838
|
+
}
|
|
1839
|
+
var TabsContext = createContext(null);
|
|
1840
|
+
function useTabs() {
|
|
1841
|
+
const context = useContext(TabsContext);
|
|
1842
|
+
if (!context)
|
|
1843
|
+
throw new Error("Tabs components must be used within <NativeTabs>");
|
|
1844
|
+
return context;
|
|
1845
|
+
}
|
|
1846
|
+
function NativeTabs({
|
|
1847
|
+
className,
|
|
1848
|
+
defaultValue,
|
|
1849
|
+
value: controlledValue,
|
|
1850
|
+
onValueChange: controlledOnValueChange,
|
|
1851
|
+
children,
|
|
1852
|
+
...props
|
|
1853
|
+
}) {
|
|
1854
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
1855
|
+
const value = controlledValue ?? uncontrolledValue;
|
|
1856
|
+
const onValueChange = controlledOnValueChange ?? setUncontrolledValue;
|
|
1857
|
+
return /* @__PURE__ */ jsx(TabsContext.Provider, { value: { value, onValueChange }, children: /* @__PURE__ */ jsx(View, { className: cn("w-full", className), ...props, children }) });
|
|
1858
|
+
}
|
|
1859
|
+
function NativeTabsList({ className, children }) {
|
|
1860
|
+
return /* @__PURE__ */ jsx(
|
|
1861
|
+
View,
|
|
1862
|
+
{
|
|
1863
|
+
className: cn(
|
|
1864
|
+
"flex-row items-center rounded-md bg-muted p-1",
|
|
1865
|
+
className
|
|
1866
|
+
),
|
|
1867
|
+
accessibilityRole: "tablist",
|
|
1868
|
+
children
|
|
1869
|
+
}
|
|
1870
|
+
);
|
|
1871
|
+
}
|
|
1872
|
+
function NativeTabsTrigger({
|
|
1873
|
+
className,
|
|
1874
|
+
value,
|
|
1875
|
+
children,
|
|
1876
|
+
disabled,
|
|
1877
|
+
...props
|
|
1878
|
+
}) {
|
|
1879
|
+
const { value: selectedValue, onValueChange } = useTabs();
|
|
1880
|
+
const isActive = selectedValue === value;
|
|
1881
|
+
return /* @__PURE__ */ jsx(
|
|
1882
|
+
Pressable,
|
|
1883
|
+
{
|
|
1884
|
+
className: cn(
|
|
1885
|
+
"flex-1 items-center justify-center rounded-sm px-3 py-1.5",
|
|
1886
|
+
isActive && "bg-background shadow-sm",
|
|
1887
|
+
disabled && "opacity-50",
|
|
1888
|
+
className
|
|
1889
|
+
),
|
|
1890
|
+
onPress: () => onValueChange(value),
|
|
1891
|
+
disabled,
|
|
1892
|
+
accessibilityRole: "tab",
|
|
1893
|
+
accessibilityState: { selected: isActive },
|
|
1894
|
+
...props,
|
|
1895
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx(
|
|
1896
|
+
Text,
|
|
1897
|
+
{
|
|
1898
|
+
className: cn(
|
|
1899
|
+
"text-sm font-medium",
|
|
1900
|
+
isActive ? "text-foreground" : "text-muted-foreground"
|
|
1901
|
+
),
|
|
1902
|
+
children
|
|
1903
|
+
}
|
|
1904
|
+
) : children
|
|
1905
|
+
}
|
|
1906
|
+
);
|
|
1907
|
+
}
|
|
1908
|
+
function NativeTabsContent({
|
|
1909
|
+
className,
|
|
1910
|
+
value,
|
|
1911
|
+
children
|
|
1912
|
+
}) {
|
|
1913
|
+
const { value: selectedValue } = useTabs();
|
|
1914
|
+
if (selectedValue !== value) return null;
|
|
1915
|
+
return /* @__PURE__ */ jsx(View, { className: cn("mt-2", className), children });
|
|
1916
|
+
}
|
|
1917
|
+
var toggleVariants = cva(
|
|
1918
|
+
"items-center justify-center rounded-md",
|
|
1919
|
+
{
|
|
1920
|
+
variants: {
|
|
1921
|
+
variant: {
|
|
1922
|
+
default: "bg-transparent",
|
|
1923
|
+
outline: "border border-input bg-transparent"
|
|
1924
|
+
},
|
|
1925
|
+
size: {
|
|
1926
|
+
default: "h-10 px-3",
|
|
1927
|
+
sm: "h-9 px-2.5",
|
|
1928
|
+
lg: "h-11 px-5"
|
|
1929
|
+
}
|
|
1930
|
+
},
|
|
1931
|
+
defaultVariants: {
|
|
1932
|
+
variant: "default",
|
|
1933
|
+
size: "default"
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
);
|
|
1937
|
+
function NativeToggle({
|
|
1938
|
+
className,
|
|
1939
|
+
variant,
|
|
1940
|
+
size,
|
|
1941
|
+
pressed: controlledPressed,
|
|
1942
|
+
defaultPressed = false,
|
|
1943
|
+
onPressedChange,
|
|
1944
|
+
disabled,
|
|
1945
|
+
children,
|
|
1946
|
+
...props
|
|
1947
|
+
}) {
|
|
1948
|
+
const [uncontrolledPressed, setUncontrolledPressed] = useState(defaultPressed);
|
|
1949
|
+
const isPressed = controlledPressed ?? uncontrolledPressed;
|
|
1950
|
+
function handlePress() {
|
|
1951
|
+
const next = !isPressed;
|
|
1952
|
+
if (controlledPressed === void 0) {
|
|
1953
|
+
setUncontrolledPressed(next);
|
|
1954
|
+
}
|
|
1955
|
+
onPressedChange?.(next);
|
|
1956
|
+
}
|
|
1957
|
+
return /* @__PURE__ */ jsx(
|
|
1958
|
+
Pressable,
|
|
1959
|
+
{
|
|
1960
|
+
className: cn(
|
|
1961
|
+
toggleVariants({ variant, size }),
|
|
1962
|
+
isPressed && "bg-accent",
|
|
1963
|
+
disabled && "opacity-50",
|
|
1964
|
+
className
|
|
1965
|
+
),
|
|
1966
|
+
onPress: handlePress,
|
|
1967
|
+
disabled,
|
|
1968
|
+
accessibilityRole: "togglebutton",
|
|
1969
|
+
accessibilityState: { checked: isPressed, disabled },
|
|
1970
|
+
...props,
|
|
1971
|
+
children
|
|
1972
|
+
}
|
|
1973
|
+
);
|
|
1974
|
+
}
|
|
1975
|
+
var TooltipContext = createContext(null);
|
|
1976
|
+
function useTooltipContext() {
|
|
1977
|
+
const ctx = useContext(TooltipContext);
|
|
1978
|
+
if (!ctx) throw new Error("Tooltip compound components must be used within NativeTooltip");
|
|
1979
|
+
return ctx;
|
|
1980
|
+
}
|
|
1981
|
+
function NativeTooltip({ children }) {
|
|
1982
|
+
const [visible, setVisible] = useState(false);
|
|
1983
|
+
return /* @__PURE__ */ jsx(TooltipContext.Provider, { value: { visible, setVisible }, children: /* @__PURE__ */ jsx(View, { children }) });
|
|
1984
|
+
}
|
|
1985
|
+
function NativeTooltipTrigger({
|
|
1986
|
+
className,
|
|
1987
|
+
children,
|
|
1988
|
+
...props
|
|
1989
|
+
}) {
|
|
1990
|
+
const { setVisible } = useTooltipContext();
|
|
1991
|
+
const timerRef = useRef(void 0);
|
|
1992
|
+
useEffect(() => {
|
|
1993
|
+
return () => {
|
|
1994
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
1995
|
+
};
|
|
1996
|
+
}, []);
|
|
1997
|
+
return /* @__PURE__ */ jsx(
|
|
1998
|
+
Pressable,
|
|
1999
|
+
{
|
|
2000
|
+
className: cn(className),
|
|
2001
|
+
accessibilityRole: "button",
|
|
2002
|
+
accessibilityLabel: "Show tooltip",
|
|
2003
|
+
onLongPress: () => {
|
|
2004
|
+
setVisible(true);
|
|
2005
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
2006
|
+
timerRef.current = setTimeout(() => setVisible(false), 2e3);
|
|
2007
|
+
},
|
|
2008
|
+
...props,
|
|
2009
|
+
children
|
|
2010
|
+
}
|
|
2011
|
+
);
|
|
2012
|
+
}
|
|
2013
|
+
function NativeTooltipContent({
|
|
2014
|
+
className,
|
|
2015
|
+
children
|
|
2016
|
+
}) {
|
|
2017
|
+
const { visible } = useTooltipContext();
|
|
2018
|
+
if (!visible) return null;
|
|
2019
|
+
return /* @__PURE__ */ jsx(
|
|
2020
|
+
View,
|
|
2021
|
+
{
|
|
2022
|
+
className: cn(
|
|
2023
|
+
"absolute bottom-full left-0 mb-1 rounded-md bg-foreground px-3 py-1.5 shadow-md",
|
|
2024
|
+
className
|
|
2025
|
+
),
|
|
2026
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx(Text, { className: "text-xs text-background", children }) : children
|
|
2027
|
+
}
|
|
2028
|
+
);
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
// src/components/layout/flex.ts
|
|
2032
|
+
var alignClasses = {
|
|
2033
|
+
start: "items-start",
|
|
2034
|
+
center: "items-center",
|
|
2035
|
+
end: "items-end",
|
|
2036
|
+
stretch: "items-stretch"
|
|
2037
|
+
};
|
|
2038
|
+
var justifyClasses = {
|
|
2039
|
+
start: "justify-start",
|
|
2040
|
+
center: "justify-center",
|
|
2041
|
+
end: "justify-end",
|
|
2042
|
+
between: "justify-between",
|
|
2043
|
+
around: "justify-around"
|
|
2044
|
+
};
|
|
2045
|
+
|
|
2046
|
+
// src/components/layout/spacing.ts
|
|
2047
|
+
var spaceScale = {
|
|
2048
|
+
none: 0,
|
|
2049
|
+
xs: 4,
|
|
2050
|
+
sm: 8,
|
|
2051
|
+
md: 12,
|
|
2052
|
+
lg: 16,
|
|
2053
|
+
xl: 24,
|
|
2054
|
+
"2xl": 32,
|
|
2055
|
+
"3xl": 48
|
|
2056
|
+
};
|
|
2057
|
+
var TAILWIND_UNIT_PX = 4;
|
|
2058
|
+
var SPACING_CLASSES = {
|
|
2059
|
+
gap: { none: "gap-0", xs: "gap-1", sm: "gap-2", md: "gap-3", lg: "gap-4", xl: "gap-6", "2xl": "gap-8", "3xl": "gap-12" },
|
|
2060
|
+
p: { none: "p-0", xs: "p-1", sm: "p-2", md: "p-3", lg: "p-4", xl: "p-6", "2xl": "p-8", "3xl": "p-12" },
|
|
2061
|
+
px: { none: "px-0", xs: "px-1", sm: "px-2", md: "px-3", lg: "px-4", xl: "px-6", "2xl": "px-8", "3xl": "px-12" },
|
|
2062
|
+
py: { none: "py-0", xs: "py-1", sm: "py-2", md: "py-3", lg: "py-4", xl: "py-6", "2xl": "py-8", "3xl": "py-12" },
|
|
2063
|
+
pt: { none: "pt-0", xs: "pt-1", sm: "pt-2", md: "pt-3", lg: "pt-4", xl: "pt-6", "2xl": "pt-8", "3xl": "pt-12" },
|
|
2064
|
+
pb: { none: "pb-0", xs: "pb-1", sm: "pb-2", md: "pb-3", lg: "pb-4", xl: "pb-6", "2xl": "pb-8", "3xl": "pb-12" },
|
|
2065
|
+
pl: { none: "pl-0", xs: "pl-1", sm: "pl-2", md: "pl-3", lg: "pl-4", xl: "pl-6", "2xl": "pl-8", "3xl": "pl-12" },
|
|
2066
|
+
pr: { none: "pr-0", xs: "pr-1", sm: "pr-2", md: "pr-3", lg: "pr-4", xl: "pr-6", "2xl": "pr-8", "3xl": "pr-12" },
|
|
2067
|
+
m: { none: "m-0", xs: "m-1", sm: "m-2", md: "m-3", lg: "m-4", xl: "m-6", "2xl": "m-8", "3xl": "m-12" },
|
|
2068
|
+
mx: { none: "mx-0", xs: "mx-1", sm: "mx-2", md: "mx-3", lg: "mx-4", xl: "mx-6", "2xl": "mx-8", "3xl": "mx-12" },
|
|
2069
|
+
my: { none: "my-0", xs: "my-1", sm: "my-2", md: "my-3", lg: "my-4", xl: "my-6", "2xl": "my-8", "3xl": "my-12" },
|
|
2070
|
+
mt: { none: "mt-0", xs: "mt-1", sm: "mt-2", md: "mt-3", lg: "mt-4", xl: "mt-6", "2xl": "mt-8", "3xl": "mt-12" },
|
|
2071
|
+
mb: { none: "mb-0", xs: "mb-1", sm: "mb-2", md: "mb-3", lg: "mb-4", xl: "mb-6", "2xl": "mb-8", "3xl": "mb-12" },
|
|
2072
|
+
ml: { none: "ml-0", xs: "ml-1", sm: "ml-2", md: "ml-3", lg: "ml-4", xl: "ml-6", "2xl": "ml-8", "3xl": "ml-12" },
|
|
2073
|
+
mr: { none: "mr-0", xs: "mr-1", sm: "mr-2", md: "mr-3", lg: "mr-4", xl: "mr-6", "2xl": "mr-8", "3xl": "mr-12" }
|
|
2074
|
+
};
|
|
2075
|
+
function spacingClass(prefix, token) {
|
|
2076
|
+
const cls = SPACING_CLASSES[prefix][token];
|
|
2077
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2078
|
+
const expected = `${prefix}-${spaceScale[token] / TAILWIND_UNIT_PX}`;
|
|
2079
|
+
if (cls !== expected) {
|
|
2080
|
+
throw new Error(
|
|
2081
|
+
`spacingClass map drift: ${prefix}/${token} \u2192 "${cls}" but spaceScale implies "${expected}". Update SPACING_CLASSES.`
|
|
2082
|
+
);
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
return cls;
|
|
2086
|
+
}
|
|
2087
|
+
function Stack({
|
|
2088
|
+
gap = "md",
|
|
2089
|
+
align,
|
|
2090
|
+
justify,
|
|
2091
|
+
className,
|
|
2092
|
+
children,
|
|
2093
|
+
...props
|
|
2094
|
+
}) {
|
|
2095
|
+
return /* @__PURE__ */ jsx(
|
|
2096
|
+
View,
|
|
2097
|
+
{
|
|
2098
|
+
className: cn(
|
|
2099
|
+
"flex-col",
|
|
2100
|
+
spacingClass("gap", gap),
|
|
2101
|
+
align && alignClasses[align],
|
|
2102
|
+
justify && justifyClasses[justify],
|
|
2103
|
+
className
|
|
2104
|
+
),
|
|
2105
|
+
...props,
|
|
2106
|
+
children
|
|
2107
|
+
}
|
|
2108
|
+
);
|
|
2109
|
+
}
|
|
2110
|
+
function Inline({
|
|
2111
|
+
gap = "md",
|
|
2112
|
+
align = "center",
|
|
2113
|
+
justify,
|
|
2114
|
+
wrap = false,
|
|
2115
|
+
className,
|
|
2116
|
+
children,
|
|
2117
|
+
...props
|
|
2118
|
+
}) {
|
|
2119
|
+
return /* @__PURE__ */ jsx(
|
|
2120
|
+
View,
|
|
2121
|
+
{
|
|
2122
|
+
className: cn(
|
|
2123
|
+
"flex-row",
|
|
2124
|
+
wrap && "flex-wrap",
|
|
2125
|
+
spacingClass("gap", gap),
|
|
2126
|
+
alignClasses[align],
|
|
2127
|
+
justify && justifyClasses[justify],
|
|
2128
|
+
className
|
|
2129
|
+
),
|
|
2130
|
+
...props,
|
|
2131
|
+
children
|
|
2132
|
+
}
|
|
2133
|
+
);
|
|
2134
|
+
}
|
|
2135
|
+
var backgroundClasses = {
|
|
2136
|
+
transparent: "bg-transparent",
|
|
2137
|
+
surface: "bg-card",
|
|
2138
|
+
canvas: "bg-background",
|
|
2139
|
+
inverse: "bg-foreground"
|
|
2140
|
+
};
|
|
2141
|
+
function Box({
|
|
2142
|
+
p,
|
|
2143
|
+
px,
|
|
2144
|
+
py,
|
|
2145
|
+
pt,
|
|
2146
|
+
pb,
|
|
2147
|
+
pl,
|
|
2148
|
+
pr,
|
|
2149
|
+
m,
|
|
2150
|
+
mx,
|
|
2151
|
+
my,
|
|
2152
|
+
mt,
|
|
2153
|
+
mb,
|
|
2154
|
+
ml,
|
|
2155
|
+
mr,
|
|
2156
|
+
bg,
|
|
2157
|
+
className,
|
|
2158
|
+
children,
|
|
2159
|
+
...props
|
|
2160
|
+
}) {
|
|
2161
|
+
return /* @__PURE__ */ jsx(
|
|
2162
|
+
View,
|
|
2163
|
+
{
|
|
2164
|
+
className: cn(
|
|
2165
|
+
p != null && spacingClass("p", p),
|
|
2166
|
+
px != null && spacingClass("px", px),
|
|
2167
|
+
py != null && spacingClass("py", py),
|
|
2168
|
+
pt != null && spacingClass("pt", pt),
|
|
2169
|
+
pb != null && spacingClass("pb", pb),
|
|
2170
|
+
pl != null && spacingClass("pl", pl),
|
|
2171
|
+
pr != null && spacingClass("pr", pr),
|
|
2172
|
+
m != null && spacingClass("m", m),
|
|
2173
|
+
mx != null && spacingClass("mx", mx),
|
|
2174
|
+
my != null && spacingClass("my", my),
|
|
2175
|
+
mt != null && spacingClass("mt", mt),
|
|
2176
|
+
mb != null && spacingClass("mb", mb),
|
|
2177
|
+
ml != null && spacingClass("ml", ml),
|
|
2178
|
+
mr != null && spacingClass("mr", mr),
|
|
2179
|
+
bg != null && backgroundClasses[bg],
|
|
2180
|
+
className
|
|
2181
|
+
),
|
|
2182
|
+
...props,
|
|
2183
|
+
children
|
|
2184
|
+
}
|
|
2185
|
+
);
|
|
2186
|
+
}
|
|
2187
|
+
function chunk(items, size) {
|
|
2188
|
+
const rows = [];
|
|
2189
|
+
for (let i = 0; i < items.length; i += size) {
|
|
2190
|
+
rows.push(items.slice(i, i + size));
|
|
2191
|
+
}
|
|
2192
|
+
return rows;
|
|
2193
|
+
}
|
|
2194
|
+
function Grid({
|
|
2195
|
+
columns = 2,
|
|
2196
|
+
gap = "md",
|
|
2197
|
+
className,
|
|
2198
|
+
children,
|
|
2199
|
+
...props
|
|
2200
|
+
}) {
|
|
2201
|
+
const cols = Number.isFinite(columns) ? Math.max(1, Math.floor(columns)) : 1;
|
|
2202
|
+
const items = Children.toArray(children);
|
|
2203
|
+
const rows = chunk(items, cols);
|
|
2204
|
+
const gapClass = spacingClass("gap", gap);
|
|
2205
|
+
return /* @__PURE__ */ jsx(View, { className: cn("flex-col", gapClass, className), ...props, children: rows.map((row, rowIndex) => /* @__PURE__ */ jsxs(View, { className: cn("flex-row", gapClass), children: [
|
|
2206
|
+
row.map((child, cellIndex) => /* @__PURE__ */ jsx(View, { className: "flex-1", children: child }, `cell-${cellIndex}`)),
|
|
2207
|
+
Array.from({ length: cols - row.length }).map((_, padIndex) => /* @__PURE__ */ jsx(View, { className: "flex-1" }, `pad-${padIndex}`))
|
|
2208
|
+
] }, `row-${rowIndex}`)) });
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
export { Box, Grid, Inline, NativeAccordion, NativeAccordionContent, NativeAccordionItem, NativeAccordionTrigger, NativeAvatar, NativeBanner, NativeChip, NativeChipGroup, NativeCombobox, NativeDatePicker, NativeDialog, NativeDialogContent, NativeDialogDescription, NativeDialogFooter, NativeDialogHeader, NativeDialogTitle, NativeDrawer, NativeDropdownMenu, NativeDropdownMenuContent, NativeDropdownMenuItem, NativeDropdownMenuTrigger, NativeHeaderCard, NativeInlineAlert, NativeNumberInput, NativePagination, NativePopover, NativePopoverContent, NativePopoverTrigger, NativeProgress, NativeRadioGroup, NativeRadioGroupItem, NativeRangeSlider, NativeRefreshControl, NativeSearchBar, NativeSegmentedControl, NativeSheet, NativeSlider, NativeStepper, NativeTabs, NativeTabsContent, NativeTabsList, NativeTabsTrigger, NativeTimePicker, NativeToastProvider, NativeToggle, NativeTooltip, NativeTooltipContent, NativeTooltipTrigger, Stack, spaceScale, spacingClass, toggleVariants, useToast };
|
|
2212
|
+
//# sourceMappingURL=chunk-TXJT55JC.js.map
|
|
2213
|
+
//# sourceMappingURL=chunk-TXJT55JC.js.map
|