@react-typed-forms/schemas-rn 1.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/README.md +292 -0
- package/lib/components/Icon.d.ts +7 -0
- package/lib/components/RNButton.d.ts +18 -0
- package/lib/components/RNCheckbox.d.ts +12 -0
- package/lib/components/RNDateTimePickerRenderer.d.ts +10 -0
- package/lib/components/RNDialog.d.ts +14 -0
- package/lib/components/RNHtmlRenderer.d.ts +5 -0
- package/lib/components/RNRadioItem.d.ts +12 -0
- package/lib/components/RNSelectRenderer.d.ts +5 -0
- package/lib/components/RNText.d.ts +7 -0
- package/lib/components/RNTextInput.d.ts +6 -0
- package/lib/index.cjs +1017 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +979 -0
- package/lib/index.js.map +1 -0
- package/lib/tailwind.d.ts +4 -0
- package/lib/utils/index.d.ts +2 -0
- package/package.json +96 -0
- package/tsconfig.json +21 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,979 @@
|
|
|
1
|
+
import { createSelectConversion, defaultTailwindTheme } from '@react-typed-forms/schemas-html';
|
|
2
|
+
import { TextInput, Pressable, View, Dimensions, Platform, StyleSheet, Text, useWindowDimensions } from 'react-native';
|
|
3
|
+
import * as CheckboxPrimitive from '@rn-primitives/checkbox';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { clsx } from 'clsx';
|
|
7
|
+
import { twMerge } from 'tailwind-merge';
|
|
8
|
+
import { cssInterop } from 'nativewind';
|
|
9
|
+
import { FontAwesome, FontAwesome5, FontAwesome6 } from '@expo/vector-icons';
|
|
10
|
+
import { IconLibrary, createDataRenderer, FieldType, DataRenderType, rendererClass, deepMerge } from '@react-typed-forms/schemas';
|
|
11
|
+
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
|
12
|
+
import { jsx, jsxs } from 'nativewind/jsx-runtime';
|
|
13
|
+
import { useComponentTracking, useControl, useComputed } from '@react-typed-forms/core';
|
|
14
|
+
import * as RadioGroupPrimitive from '@rn-primitives/radio-group';
|
|
15
|
+
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
16
|
+
import { fromDate, getLocalTimeZone, toTime, toCalendarDate, toCalendarDateTime, now, parseTime, parseAbsolute, parseDate, DateFormatter } from '@internationalized/date';
|
|
17
|
+
import RenderHtml from 'react-native-render-html';
|
|
18
|
+
import * as SelectPrimitive from '@rn-primitives/select';
|
|
19
|
+
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
20
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
21
|
+
import { ScrollView } from 'react-native-gesture-handler';
|
|
22
|
+
import { cva } from 'class-variance-authority';
|
|
23
|
+
import * as Slot from '@rn-primitives/slot';
|
|
24
|
+
import * as DialogPrimitive from '@rn-primitives/dialog';
|
|
25
|
+
|
|
26
|
+
function _extends() {
|
|
27
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
28
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
29
|
+
var t = arguments[e];
|
|
30
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
31
|
+
}
|
|
32
|
+
return n;
|
|
33
|
+
}, _extends.apply(null, arguments);
|
|
34
|
+
}
|
|
35
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
36
|
+
if (null == r) return {};
|
|
37
|
+
var t = {};
|
|
38
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
39
|
+
if (e.includes(n)) continue;
|
|
40
|
+
t[n] = r[n];
|
|
41
|
+
}
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function cn(...inputs) {
|
|
46
|
+
return twMerge(clsx(inputs));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
cssInterop(FontAwesome, {
|
|
50
|
+
className: {
|
|
51
|
+
target: "style",
|
|
52
|
+
nativeStyleToProp: {}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
cssInterop(MaterialIcons, {
|
|
56
|
+
className: {
|
|
57
|
+
target: "style",
|
|
58
|
+
nativeStyleToProp: {}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
function Icon({
|
|
62
|
+
name,
|
|
63
|
+
className = "!text-[16px] text-black-500",
|
|
64
|
+
iconLibrary
|
|
65
|
+
}) {
|
|
66
|
+
var _effect = useComponentTracking();
|
|
67
|
+
try {
|
|
68
|
+
switch (iconLibrary) {
|
|
69
|
+
case IconLibrary.Material:
|
|
70
|
+
return jsx(MaterialIcons, {
|
|
71
|
+
name: name,
|
|
72
|
+
className: className
|
|
73
|
+
});
|
|
74
|
+
default:
|
|
75
|
+
return jsx(FontAwesome, {
|
|
76
|
+
name: name,
|
|
77
|
+
className: className
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
} finally {
|
|
81
|
+
_effect();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const _excluded$8 = ["className"];
|
|
86
|
+
const RNCheckbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
87
|
+
let {
|
|
88
|
+
className
|
|
89
|
+
} = _ref,
|
|
90
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
91
|
+
return jsx(CheckboxPrimitive.Root, _extends({
|
|
92
|
+
ref: ref,
|
|
93
|
+
className: cn("web:peer h-4 w-4 native:h-[20] native:w-[20] shrink-0 rounded-sm native:rounded border border-primary web:ring-offset-background web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className)
|
|
94
|
+
}, props, {
|
|
95
|
+
children: jsx(CheckboxPrimitive.Indicator, {
|
|
96
|
+
className: cn("items-center justify-center h-full w-full"),
|
|
97
|
+
children: jsx(Icon, {
|
|
98
|
+
name: "check",
|
|
99
|
+
className: "text-primary-500"
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
}));
|
|
103
|
+
});
|
|
104
|
+
RNCheckbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
105
|
+
|
|
106
|
+
const _excluded$7 = ["className", "placeholderClassName"];
|
|
107
|
+
const RNTextInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
108
|
+
let {
|
|
109
|
+
className,
|
|
110
|
+
placeholderClassName
|
|
111
|
+
} = _ref,
|
|
112
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
113
|
+
const editable = !props.disabled;
|
|
114
|
+
const readonly = props.readOnly ? true : undefined;
|
|
115
|
+
return jsx(TextInput, _extends({
|
|
116
|
+
ref: ref
|
|
117
|
+
}, props, {
|
|
118
|
+
className: cn("web:flex h-10 native:h-[54px] web:w-full rounded-md border bg-background px-3 web:py-2 text-base lg:text-sm native:text-lg native:leading-[1.25] text-foreground placeholder:text-muted-foreground web:ring-offset-background file:border-0 file:bg-transparent file:font-medium web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2", !editable && "opacity-50 web:cursor-not-allowed", className),
|
|
119
|
+
placeholderClassName: cn("text-muted-foreground", placeholderClassName),
|
|
120
|
+
editable: editable,
|
|
121
|
+
readOnly: readonly
|
|
122
|
+
}));
|
|
123
|
+
});
|
|
124
|
+
RNTextInput.displayName = "RNInput";
|
|
125
|
+
|
|
126
|
+
const _excluded$6 = ["className", "checked", "onChange"];
|
|
127
|
+
const RNRadioItem = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
128
|
+
let {
|
|
129
|
+
className,
|
|
130
|
+
checked,
|
|
131
|
+
onChange
|
|
132
|
+
} = _ref,
|
|
133
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
134
|
+
return jsx(Pressable, _extends({
|
|
135
|
+
ref: ref,
|
|
136
|
+
onPress: onChange,
|
|
137
|
+
className: cn("aspect-square h-4 w-4 native:h-5 native:w-5 rounded-full justify-center items-center border border-primary text-primary web:ring-offset-background web:focus:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2", props.disabled && "web:cursor-not-allowed opacity-50", className)
|
|
138
|
+
}, props, {
|
|
139
|
+
children: jsx(View, {
|
|
140
|
+
className: "flex items-center justify-center",
|
|
141
|
+
children: checked && jsx(View, {
|
|
142
|
+
className: "aspect-square h-[9px] w-[9px] native:h-[10] native:w-[10] bg-primary rounded-full"
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
}));
|
|
146
|
+
});
|
|
147
|
+
RNRadioItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
148
|
+
|
|
149
|
+
const _excluded$5 = ["control", "mode", "locale", "is24Hour", "className"];
|
|
150
|
+
function createRNDateTimePickerRenderer(options = {}) {
|
|
151
|
+
return createDataRenderer(p => {
|
|
152
|
+
const mode = p.field.type == FieldType.DateTime ? "datetime" : p.field.type == FieldType.Time ? "time" : "date";
|
|
153
|
+
return jsx(RNDateTimePicker, _extends({}, p, {
|
|
154
|
+
control: p.control.as(),
|
|
155
|
+
mode: mode,
|
|
156
|
+
className: options.inputClass
|
|
157
|
+
}));
|
|
158
|
+
}, {
|
|
159
|
+
schemaType: [FieldType.Date, FieldType.DateTime, FieldType.Time],
|
|
160
|
+
renderType: DataRenderType.DateTime
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function RNDateTimePicker(_ref) {
|
|
164
|
+
var _effect = useComponentTracking();
|
|
165
|
+
try {
|
|
166
|
+
let {
|
|
167
|
+
control,
|
|
168
|
+
mode,
|
|
169
|
+
locale = "en-AU",
|
|
170
|
+
is24Hour = true,
|
|
171
|
+
className
|
|
172
|
+
} = _ref,
|
|
173
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
174
|
+
const disabled = control.disabled;
|
|
175
|
+
const {
|
|
176
|
+
maximumDate,
|
|
177
|
+
minimumDate
|
|
178
|
+
} = props;
|
|
179
|
+
const isVisible = useControl(false);
|
|
180
|
+
const innerPickerValue = getInnerPickerValue();
|
|
181
|
+
const formattedDate = getFormattedDate();
|
|
182
|
+
const handleConfirm = date => {
|
|
183
|
+
control.touched = true;
|
|
184
|
+
const zonedDateTime = fromDate(date, getLocalTimeZone());
|
|
185
|
+
try {
|
|
186
|
+
switch (mode) {
|
|
187
|
+
case "date":
|
|
188
|
+
control.value = toCalendarDate(zonedDateTime).toString();
|
|
189
|
+
break;
|
|
190
|
+
case "datetime":
|
|
191
|
+
control.value = zonedDateTime.toAbsoluteString();
|
|
192
|
+
break;
|
|
193
|
+
case "time":
|
|
194
|
+
control.value = toTime(zonedDateTime).toString();
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
} catch (_) {}
|
|
198
|
+
hidePicker();
|
|
199
|
+
};
|
|
200
|
+
// Fix IOS propagating
|
|
201
|
+
function onPress() {
|
|
202
|
+
!disabled && (isVisible.value = true);
|
|
203
|
+
}
|
|
204
|
+
return jsxs(View, {
|
|
205
|
+
children: [jsxs(Pressable, {
|
|
206
|
+
className: "pointer-events-auto flex flex-row",
|
|
207
|
+
onPress: onPress,
|
|
208
|
+
children: [jsx(RNTextInput, {
|
|
209
|
+
className: cn(className, "flex-1"),
|
|
210
|
+
disabled: disabled,
|
|
211
|
+
readOnly: true,
|
|
212
|
+
value: formattedDate != null ? formattedDate : "",
|
|
213
|
+
placeholder: "dd/mm/yyyy",
|
|
214
|
+
onPress: onPress
|
|
215
|
+
}), jsx(View, {
|
|
216
|
+
className: "flex flex-row bg-[#F5F5F5] size-[54px] items-center justify-center border border-[#E7E7E8]",
|
|
217
|
+
children: jsx(FontAwesome5, {
|
|
218
|
+
name: "calendar-alt",
|
|
219
|
+
size: 20,
|
|
220
|
+
color: "#343534"
|
|
221
|
+
})
|
|
222
|
+
})]
|
|
223
|
+
}), jsx(DateTimePickerModal, {
|
|
224
|
+
date: innerPickerValue != null ? innerPickerValue : new Date(),
|
|
225
|
+
is24Hour: is24Hour,
|
|
226
|
+
disabled: disabled,
|
|
227
|
+
maximumDate: maximumDate,
|
|
228
|
+
minimumDate: minimumDate,
|
|
229
|
+
isVisible: isVisible.value,
|
|
230
|
+
mode: mode,
|
|
231
|
+
locale: locale,
|
|
232
|
+
onConfirm: handleConfirm,
|
|
233
|
+
onCancel: hidePicker,
|
|
234
|
+
onHide: hidePicker
|
|
235
|
+
})]
|
|
236
|
+
});
|
|
237
|
+
function getInnerPickerValue() {
|
|
238
|
+
const dateString = control.value;
|
|
239
|
+
if (!dateString) return null;
|
|
240
|
+
try {
|
|
241
|
+
switch (mode) {
|
|
242
|
+
case "date":
|
|
243
|
+
return parseDate(dateString).toDate(getLocalTimeZone());
|
|
244
|
+
case "datetime":
|
|
245
|
+
return parseAbsolute(dateString, getLocalTimeZone()).toDate();
|
|
246
|
+
case "time":
|
|
247
|
+
return toCalendarDateTime(now(getLocalTimeZone()), parseTime(dateString)).toDate(getLocalTimeZone());
|
|
248
|
+
}
|
|
249
|
+
} catch (_) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function getFormattedDate() {
|
|
254
|
+
if (!innerPickerValue) return null;
|
|
255
|
+
let options = {};
|
|
256
|
+
try {
|
|
257
|
+
switch (mode) {
|
|
258
|
+
case "date":
|
|
259
|
+
options = {
|
|
260
|
+
day: "2-digit",
|
|
261
|
+
month: "2-digit",
|
|
262
|
+
year: "numeric",
|
|
263
|
+
timeZone: getLocalTimeZone()
|
|
264
|
+
};
|
|
265
|
+
break;
|
|
266
|
+
case "datetime":
|
|
267
|
+
options = {
|
|
268
|
+
day: "2-digit",
|
|
269
|
+
month: "2-digit",
|
|
270
|
+
year: "numeric",
|
|
271
|
+
hour: "2-digit",
|
|
272
|
+
minute: "2-digit",
|
|
273
|
+
hour12: false,
|
|
274
|
+
timeZone: getLocalTimeZone()
|
|
275
|
+
};
|
|
276
|
+
break;
|
|
277
|
+
case "time":
|
|
278
|
+
options = {
|
|
279
|
+
timeStyle: "short",
|
|
280
|
+
hour12: false,
|
|
281
|
+
timeZone: getLocalTimeZone()
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
} catch (_) {
|
|
285
|
+
options = {};
|
|
286
|
+
}
|
|
287
|
+
return new DateFormatter(locale, options).format(innerPickerValue);
|
|
288
|
+
}
|
|
289
|
+
function hidePicker() {
|
|
290
|
+
isVisible.value = false;
|
|
291
|
+
}
|
|
292
|
+
} finally {
|
|
293
|
+
_effect();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function RNHtmlRenderer({
|
|
298
|
+
className,
|
|
299
|
+
html
|
|
300
|
+
}) {
|
|
301
|
+
var _effect = useComponentTracking();
|
|
302
|
+
try {
|
|
303
|
+
if (!html) return;
|
|
304
|
+
const source = {
|
|
305
|
+
html: html
|
|
306
|
+
};
|
|
307
|
+
return jsx(View, {
|
|
308
|
+
className: className,
|
|
309
|
+
children: jsx(RenderHtml, {
|
|
310
|
+
contentWidth: Dimensions.get("window").width,
|
|
311
|
+
source: source
|
|
312
|
+
})
|
|
313
|
+
});
|
|
314
|
+
} finally {
|
|
315
|
+
_effect();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const _excluded$4 = ["state", "options", "className", "convert", "required", "emptyText", "requiredText", "portalHost"],
|
|
320
|
+
_excluded2$2 = ["className", "children"],
|
|
321
|
+
_excluded3$2 = ["className", "children", "position", "portalHost"],
|
|
322
|
+
_excluded4$2 = ["className"],
|
|
323
|
+
_excluded5 = ["className", "children"],
|
|
324
|
+
_excluded6 = ["className"];
|
|
325
|
+
function createRNSelectRenderer(options = {}) {
|
|
326
|
+
return createDataRenderer((props, asArray) => {
|
|
327
|
+
var _props$options;
|
|
328
|
+
const renderOptions = props.definition.renderOptions;
|
|
329
|
+
return jsx(RNSelectRenderer, {
|
|
330
|
+
className: rendererClass(props.className, options.className),
|
|
331
|
+
state: props.control,
|
|
332
|
+
id: props.id,
|
|
333
|
+
readonly: props.readonly,
|
|
334
|
+
options: (_props$options = props.options) != null ? _props$options : [],
|
|
335
|
+
required: props.required,
|
|
336
|
+
emptyText: options.emptyText,
|
|
337
|
+
requiredText: options.requiredText,
|
|
338
|
+
convert: createSelectConversion(props.field.type),
|
|
339
|
+
portalHost: renderOptions.portalHost
|
|
340
|
+
});
|
|
341
|
+
}, {
|
|
342
|
+
options: true,
|
|
343
|
+
schemaType: [FieldType.String, FieldType.Int],
|
|
344
|
+
renderType: DataRenderType.Dropdown
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
function RNSelectRenderer(_ref) {
|
|
348
|
+
var _effect = useComponentTracking();
|
|
349
|
+
try {
|
|
350
|
+
let {
|
|
351
|
+
state,
|
|
352
|
+
options,
|
|
353
|
+
convert,
|
|
354
|
+
required,
|
|
355
|
+
emptyText = "N/A",
|
|
356
|
+
requiredText = "Please select",
|
|
357
|
+
portalHost
|
|
358
|
+
} = _ref,
|
|
359
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
360
|
+
const insets = useSafeAreaInsets();
|
|
361
|
+
const contentInsets = {
|
|
362
|
+
top: insets.top,
|
|
363
|
+
bottom: Platform.select({
|
|
364
|
+
ios: insets.bottom,
|
|
365
|
+
android: insets.bottom + 24
|
|
366
|
+
}),
|
|
367
|
+
left: 12,
|
|
368
|
+
right: 12
|
|
369
|
+
};
|
|
370
|
+
const {
|
|
371
|
+
value,
|
|
372
|
+
disabled
|
|
373
|
+
} = state;
|
|
374
|
+
const optionStringMap = useMemo(() => Object.fromEntries(options.map(x => [convert(x.value), x.value])), [options]);
|
|
375
|
+
const optionGroups = useMemo(() => Array.from(new Set(options.filter(x => x.group).map(x => x.group))), [options]);
|
|
376
|
+
const selectedOption = useComputed(() => {
|
|
377
|
+
return options.filter(x => x.value === value).map(x => ({
|
|
378
|
+
value: convert(x.value).toString(),
|
|
379
|
+
label: x.name
|
|
380
|
+
})).at(0);
|
|
381
|
+
});
|
|
382
|
+
return jsxs(Select, _extends({}, props, {
|
|
383
|
+
disabled: disabled,
|
|
384
|
+
"aria-disabled": disabled,
|
|
385
|
+
defaultValue: {
|
|
386
|
+
value: value,
|
|
387
|
+
label: required ? requiredText : emptyText
|
|
388
|
+
},
|
|
389
|
+
onValueChange: o => {
|
|
390
|
+
if (!o) return;
|
|
391
|
+
state.value = optionStringMap[o.value];
|
|
392
|
+
},
|
|
393
|
+
value: selectedOption.value,
|
|
394
|
+
children: [jsx(SelectTrigger, {
|
|
395
|
+
className: "bg-white",
|
|
396
|
+
children: jsx(SelectValue, {
|
|
397
|
+
placeholder: required ? requiredText : emptyText
|
|
398
|
+
})
|
|
399
|
+
}), jsx(SelectContent, {
|
|
400
|
+
insets: contentInsets,
|
|
401
|
+
className: "bg-white w-[250px]",
|
|
402
|
+
portalHost: Platform.select({
|
|
403
|
+
ios: portalHost
|
|
404
|
+
}),
|
|
405
|
+
children: jsxs(ScrollView, {
|
|
406
|
+
className: "max-h-64",
|
|
407
|
+
children: [optionGroups.map(x => jsxs(SelectGroup, {
|
|
408
|
+
children: [jsx(SelectLabel, {
|
|
409
|
+
children: x
|
|
410
|
+
}), options.filter(o => o.group === x).map(renderOption)]
|
|
411
|
+
}, x)), options.filter(x => !x.group).map(renderOption)]
|
|
412
|
+
})
|
|
413
|
+
})]
|
|
414
|
+
}));
|
|
415
|
+
function renderOption(x, i) {
|
|
416
|
+
return jsx(SelectItem, {
|
|
417
|
+
value: convert(x.value).toString(),
|
|
418
|
+
label: x.name,
|
|
419
|
+
disabled: !!x.disabled,
|
|
420
|
+
children: x.name
|
|
421
|
+
}, i);
|
|
422
|
+
}
|
|
423
|
+
} finally {
|
|
424
|
+
_effect();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
const Select = SelectPrimitive.Root;
|
|
428
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
429
|
+
const SelectValue = SelectPrimitive.Value;
|
|
430
|
+
const SelectTrigger = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
431
|
+
let {
|
|
432
|
+
className,
|
|
433
|
+
children
|
|
434
|
+
} = _ref2,
|
|
435
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded2$2);
|
|
436
|
+
return jsxs(SelectPrimitive.Trigger, _extends({
|
|
437
|
+
ref: ref,
|
|
438
|
+
className: cn("flex flex-row h-10 native:h-12 items-center text-sm justify-between border border-[#E7E7E8] bg-background px-3 py-2 web:ring-offset-background text-muted-foreground web:focus:outline-none web:focus:ring-2 web:focus:ring-ring web:focus:ring-offset-2 [&>span]:line-clamp-1", props.disabled && "web:cursor-not-allowed opacity-50", className)
|
|
439
|
+
}, props, {
|
|
440
|
+
children: [jsx(Pressable, {
|
|
441
|
+
children: children
|
|
442
|
+
}), jsx(Icon, {
|
|
443
|
+
name: "chevron-down",
|
|
444
|
+
className: "!text-[12px] text-foreground text-accent"
|
|
445
|
+
})]
|
|
446
|
+
}));
|
|
447
|
+
});
|
|
448
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
449
|
+
const SelectContent = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
450
|
+
let {
|
|
451
|
+
className,
|
|
452
|
+
children,
|
|
453
|
+
position = "popper",
|
|
454
|
+
portalHost
|
|
455
|
+
} = _ref3,
|
|
456
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded3$2);
|
|
457
|
+
const {
|
|
458
|
+
open
|
|
459
|
+
} = SelectPrimitive.useRootContext();
|
|
460
|
+
return jsx(SelectPrimitive.Portal, {
|
|
461
|
+
hostName: portalHost,
|
|
462
|
+
children: jsx(SelectPrimitive.Overlay, {
|
|
463
|
+
style: Platform.OS !== "web" ? StyleSheet.absoluteFill : undefined,
|
|
464
|
+
children: jsx(Animated.View, {
|
|
465
|
+
className: "z-50",
|
|
466
|
+
entering: FadeIn,
|
|
467
|
+
exiting: FadeOut,
|
|
468
|
+
children: jsx(SelectPrimitive.Content, _extends({
|
|
469
|
+
ref: ref,
|
|
470
|
+
className: cn("relative z-50 max-h-96 min-w-[8rem] rounded-md border border-border bg-popover shadow-md shadow-foreground/10 py-2 px-1 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", open ? "web:zoom-in-95 web:animate-in web:fade-in-0" : "web:zoom-out-95 web:animate-out web:fade-out-0", className),
|
|
471
|
+
position: position
|
|
472
|
+
}, props, {
|
|
473
|
+
children: jsx(SelectPrimitive.Viewport, {
|
|
474
|
+
className: cn("p-1", position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),
|
|
475
|
+
children: children
|
|
476
|
+
})
|
|
477
|
+
}))
|
|
478
|
+
})
|
|
479
|
+
})
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
483
|
+
const SelectLabel = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
484
|
+
let {
|
|
485
|
+
className
|
|
486
|
+
} = _ref4,
|
|
487
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded4$2);
|
|
488
|
+
return jsx(SelectPrimitive.Label, _extends({
|
|
489
|
+
ref: ref,
|
|
490
|
+
className: cn("py-1.5 native:pb-2 pl-2 native:pl-2 pr-2 text-popover-foreground text-sm native:text-base font-semibold", className)
|
|
491
|
+
}, props));
|
|
492
|
+
});
|
|
493
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
494
|
+
const SelectItem = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
495
|
+
let {
|
|
496
|
+
className
|
|
497
|
+
} = _ref5,
|
|
498
|
+
props = _objectWithoutPropertiesLoose(_ref5, _excluded5);
|
|
499
|
+
return jsxs(SelectPrimitive.Item, _extends({
|
|
500
|
+
ref: ref,
|
|
501
|
+
className: cn("relative web:group flex flex-row w-full web:cursor-default web:select-none items-center rounded-sm py-1.5 native:py-2 pl-8 native:pl-10 pr-2 web:hover:bg-accent/50 active:bg-accent web:outline-none web:focus:bg-accent", props.disabled && "web:pointer-events-none opacity-50", className)
|
|
502
|
+
}, props, {
|
|
503
|
+
children: [jsx(View, {
|
|
504
|
+
className: "absolute left-2 native:left-3.5 flex h-3.5 native:pt-px w-3.5 items-center justify-center",
|
|
505
|
+
children: jsx(SelectPrimitive.ItemIndicator, {
|
|
506
|
+
children: jsx(Icon, {
|
|
507
|
+
name: "check",
|
|
508
|
+
className: "text-[12px] text-popover-foreground"
|
|
509
|
+
})
|
|
510
|
+
})
|
|
511
|
+
}), jsx(SelectPrimitive.ItemText, {
|
|
512
|
+
className: "text-sm native:text-lg text-popover-foreground native:text-base web:group-focus:text-accent-foreground"
|
|
513
|
+
})]
|
|
514
|
+
}));
|
|
515
|
+
});
|
|
516
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
517
|
+
const SelectSeparator = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
518
|
+
let {
|
|
519
|
+
className
|
|
520
|
+
} = _ref6,
|
|
521
|
+
props = _objectWithoutPropertiesLoose(_ref6, _excluded6);
|
|
522
|
+
return jsx(SelectPrimitive.Separator, _extends({
|
|
523
|
+
ref: ref,
|
|
524
|
+
className: cn("-mx-1 my-1 h-px bg-muted", className)
|
|
525
|
+
}, props));
|
|
526
|
+
});
|
|
527
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
528
|
+
|
|
529
|
+
const _excluded$3 = ["inline", "textClass", "children", "notWrapInText", "androidRippleColor", "nonTextContent", "onClick"],
|
|
530
|
+
_excluded2$1 = ["className", "html", "children", "textClass", "text", "style", "inline"],
|
|
531
|
+
_excluded3$1 = ["className", "html", "children", "textClass", "text", "style", "inline"],
|
|
532
|
+
_excluded4$1 = ["id", "type", "onChangeValue", "onChangeChecked", "checked", "value"];
|
|
533
|
+
const reactNativeHtml = {
|
|
534
|
+
I: RNIcon,
|
|
535
|
+
B: RNSpan,
|
|
536
|
+
Button: RNButton$1,
|
|
537
|
+
Label: RNLabel,
|
|
538
|
+
Span: RNSpan,
|
|
539
|
+
H1: RNSpan,
|
|
540
|
+
Div: RNDiv,
|
|
541
|
+
Input: RNInput
|
|
542
|
+
};
|
|
543
|
+
const defaultRnTailwindTheme = deepMerge({
|
|
544
|
+
data: {
|
|
545
|
+
checkOptions: {
|
|
546
|
+
entryClass: "flex flex-row items-center gap-[8px]"
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
label: {
|
|
550
|
+
labelContainer: c => jsx(View, {
|
|
551
|
+
className: "flex flex-row gap-4 items-center",
|
|
552
|
+
children: c
|
|
553
|
+
})
|
|
554
|
+
},
|
|
555
|
+
array: {
|
|
556
|
+
removableClass: "flex flex-col gap-y-2"
|
|
557
|
+
},
|
|
558
|
+
action: {
|
|
559
|
+
buttonClass: "flex flex-row gap-2 bg-primary-500 rounded-lg p-3 web:hover:opacity-90 active:opacity-90",
|
|
560
|
+
textClass: "text-white"
|
|
561
|
+
},
|
|
562
|
+
adornment: {
|
|
563
|
+
accordion: {
|
|
564
|
+
className: "flex flex-row items-center gap-2 my-2 p-0"
|
|
565
|
+
},
|
|
566
|
+
helpText: {
|
|
567
|
+
iconName: "info-circle",
|
|
568
|
+
iconClass: "text-[12px]",
|
|
569
|
+
triggerContainerClass: "flex flex-row gap-2 items-baseline",
|
|
570
|
+
triggerLabelClass: "text-sm font-bold",
|
|
571
|
+
contentTextClass: "text-white font-semibold text-sm"
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
html: reactNativeHtml,
|
|
575
|
+
extraRenderers: options => {
|
|
576
|
+
var _options$data;
|
|
577
|
+
const renderers = [createRNSelectRenderer((_options$data = options.data) == null ? void 0 : _options$data.selectOptions)];
|
|
578
|
+
if (Platform.OS !== "web") {
|
|
579
|
+
renderers.push(createRNDateTimePickerRenderer(options.data));
|
|
580
|
+
}
|
|
581
|
+
return renderers;
|
|
582
|
+
}
|
|
583
|
+
}, defaultTailwindTheme);
|
|
584
|
+
function RNIcon({
|
|
585
|
+
iconName,
|
|
586
|
+
className,
|
|
587
|
+
iconLibrary
|
|
588
|
+
}) {
|
|
589
|
+
var _effect = useComponentTracking();
|
|
590
|
+
try {
|
|
591
|
+
return iconName ? jsx(Icon, {
|
|
592
|
+
name: iconName,
|
|
593
|
+
className: className,
|
|
594
|
+
iconLibrary: iconLibrary
|
|
595
|
+
}) : undefined;
|
|
596
|
+
} finally {
|
|
597
|
+
_effect();
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
function RNSpan(props) {
|
|
601
|
+
var _effect2 = useComponentTracking();
|
|
602
|
+
try {
|
|
603
|
+
return jsx(Text, _extends({}, props));
|
|
604
|
+
} finally {
|
|
605
|
+
_effect2();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
function RNButton$1(_ref) {
|
|
609
|
+
var _effect3 = useComponentTracking();
|
|
610
|
+
try {
|
|
611
|
+
let {
|
|
612
|
+
inline,
|
|
613
|
+
textClass,
|
|
614
|
+
children,
|
|
615
|
+
notWrapInText,
|
|
616
|
+
androidRippleColor,
|
|
617
|
+
nonTextContent,
|
|
618
|
+
onClick
|
|
619
|
+
} = _ref,
|
|
620
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
621
|
+
if (inline) {
|
|
622
|
+
return jsx(Text, _extends({}, props, {
|
|
623
|
+
className: textClass,
|
|
624
|
+
onPress: onClick,
|
|
625
|
+
children: children
|
|
626
|
+
}));
|
|
627
|
+
}
|
|
628
|
+
return jsx(Pressable, _extends({}, props, {
|
|
629
|
+
onPress: () => {
|
|
630
|
+
onClick == null || onClick();
|
|
631
|
+
},
|
|
632
|
+
android_ripple: {
|
|
633
|
+
color: androidRippleColor
|
|
634
|
+
},
|
|
635
|
+
children: notWrapInText || nonTextContent ? children : jsx(Text, {
|
|
636
|
+
className: textClass,
|
|
637
|
+
children: children
|
|
638
|
+
})
|
|
639
|
+
}));
|
|
640
|
+
} finally {
|
|
641
|
+
_effect3();
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
function RNLabel(_ref2) {
|
|
645
|
+
var _effect4 = useComponentTracking();
|
|
646
|
+
try {
|
|
647
|
+
let {
|
|
648
|
+
className,
|
|
649
|
+
children,
|
|
650
|
+
textClass,
|
|
651
|
+
style
|
|
652
|
+
} = _ref2,
|
|
653
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded2$1);
|
|
654
|
+
return jsx(View, _extends({
|
|
655
|
+
className: className,
|
|
656
|
+
style: style
|
|
657
|
+
}, props, {
|
|
658
|
+
children: jsx(Text, {
|
|
659
|
+
className: textClass,
|
|
660
|
+
children: children
|
|
661
|
+
})
|
|
662
|
+
}));
|
|
663
|
+
} finally {
|
|
664
|
+
_effect4();
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
function RNDiv(_ref3) {
|
|
668
|
+
var _effect5 = useComponentTracking();
|
|
669
|
+
try {
|
|
670
|
+
let {
|
|
671
|
+
className,
|
|
672
|
+
html,
|
|
673
|
+
children,
|
|
674
|
+
textClass,
|
|
675
|
+
text,
|
|
676
|
+
style,
|
|
677
|
+
inline
|
|
678
|
+
} = _ref3,
|
|
679
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded3$1);
|
|
680
|
+
if (html != null) {
|
|
681
|
+
return jsx(RNHtmlRenderer, _extends({}, props, {
|
|
682
|
+
html: html
|
|
683
|
+
}));
|
|
684
|
+
}
|
|
685
|
+
if (inline) {
|
|
686
|
+
return jsx(Text, {
|
|
687
|
+
style: style,
|
|
688
|
+
className: textClass,
|
|
689
|
+
children: text != null ? text : children
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
if (text != null) {
|
|
693
|
+
return jsx(View, _extends({
|
|
694
|
+
className: className,
|
|
695
|
+
style: style
|
|
696
|
+
}, props, {
|
|
697
|
+
children: jsx(Text, {
|
|
698
|
+
className: textClass,
|
|
699
|
+
children: text
|
|
700
|
+
})
|
|
701
|
+
}));
|
|
702
|
+
}
|
|
703
|
+
return jsx(View, _extends({
|
|
704
|
+
className: className,
|
|
705
|
+
style: style,
|
|
706
|
+
children: children
|
|
707
|
+
}, props));
|
|
708
|
+
} finally {
|
|
709
|
+
_effect5();
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
function RNInput(props) {
|
|
713
|
+
var _effect6 = useComponentTracking();
|
|
714
|
+
try {
|
|
715
|
+
const {
|
|
716
|
+
id,
|
|
717
|
+
type,
|
|
718
|
+
onChangeValue,
|
|
719
|
+
onChangeChecked,
|
|
720
|
+
checked,
|
|
721
|
+
value
|
|
722
|
+
} = props,
|
|
723
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded4$1);
|
|
724
|
+
switch (type) {
|
|
725
|
+
case "radio":
|
|
726
|
+
return jsx(RNRadioItem, _extends({}, rest, {
|
|
727
|
+
checked: !!checked,
|
|
728
|
+
onChange: () => onChangeChecked == null ? void 0 : onChangeChecked(!checked)
|
|
729
|
+
}));
|
|
730
|
+
case "checkbox":
|
|
731
|
+
return jsx(RNCheckbox, _extends({}, rest, {
|
|
732
|
+
checked: !!checked,
|
|
733
|
+
onCheckedChange: e => onChangeChecked == null ? void 0 : onChangeChecked(!checked)
|
|
734
|
+
}), id);
|
|
735
|
+
default:
|
|
736
|
+
return jsx(RNTextInput, _extends({}, rest, {
|
|
737
|
+
value: typeof value == "number" ? value.toString() : value,
|
|
738
|
+
onChangeText: t => onChangeValue == null ? void 0 : onChangeValue(t)
|
|
739
|
+
}));
|
|
740
|
+
}
|
|
741
|
+
} finally {
|
|
742
|
+
_effect6();
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
const _excluded$2 = ["className", "asChild"];
|
|
747
|
+
const TextClassContext = /*#__PURE__*/React.createContext(undefined);
|
|
748
|
+
const RNText = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
749
|
+
let {
|
|
750
|
+
className,
|
|
751
|
+
asChild = false
|
|
752
|
+
} = _ref,
|
|
753
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
754
|
+
const textClass = React.useContext(TextClassContext);
|
|
755
|
+
const Component = asChild ? Slot.Text : Text;
|
|
756
|
+
return jsx(Component, _extends({
|
|
757
|
+
className: cn("text-base text-foreground web:select-text", textClass, className),
|
|
758
|
+
ref: ref
|
|
759
|
+
}, props));
|
|
760
|
+
});
|
|
761
|
+
RNText.displayName = "RNText";
|
|
762
|
+
|
|
763
|
+
const _excluded$1 = ["className", "variant", "size"];
|
|
764
|
+
const buttonVariants = cva("group flex items-center justify-center rounded-md web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2", {
|
|
765
|
+
variants: {
|
|
766
|
+
variant: {
|
|
767
|
+
default: "bg-primary web:hover:opacity-90 active:opacity-90",
|
|
768
|
+
destructive: "bg-destructive web:hover:opacity-90 active:opacity-90",
|
|
769
|
+
outline: "border border-input bg-background web:hover:bg-accent web:hover:text-accent-foreground active:bg-accent",
|
|
770
|
+
secondary: "bg-secondary web:hover:opacity-80 active:opacity-80",
|
|
771
|
+
ghost: "web:hover:bg-accent web:hover:text-accent-foreground active:bg-accent",
|
|
772
|
+
link: "web:underline-offset-4 web:hover:underline web:focus:underline"
|
|
773
|
+
},
|
|
774
|
+
size: {
|
|
775
|
+
default: "h-10 px-4 py-2 native:h-12 native:px-5 native:py-3",
|
|
776
|
+
sm: "h-9 rounded-md px-3",
|
|
777
|
+
lg: "h-11 rounded-md px-8 native:h-14",
|
|
778
|
+
icon: "h-10 w-10"
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
defaultVariants: {
|
|
782
|
+
variant: "default",
|
|
783
|
+
size: "default"
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
const buttonTextVariants = cva("web:whitespace-nowrap text-sm native:text-base font-medium text-foreground web:transition-colors", {
|
|
787
|
+
variants: {
|
|
788
|
+
variant: {
|
|
789
|
+
default: "text-primary-foreground",
|
|
790
|
+
destructive: "text-destructive-foreground",
|
|
791
|
+
outline: "group-active:text-accent-foreground",
|
|
792
|
+
secondary: "text-secondary-foreground group-active:text-secondary-foreground",
|
|
793
|
+
ghost: "group-active:text-accent-foreground",
|
|
794
|
+
link: "text-primary group-active:underline"
|
|
795
|
+
},
|
|
796
|
+
size: {
|
|
797
|
+
default: "",
|
|
798
|
+
sm: "",
|
|
799
|
+
lg: "native:text-lg",
|
|
800
|
+
icon: ""
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
defaultVariants: {
|
|
804
|
+
variant: "default",
|
|
805
|
+
size: "default"
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
const RNButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
809
|
+
let {
|
|
810
|
+
className,
|
|
811
|
+
variant,
|
|
812
|
+
size
|
|
813
|
+
} = _ref,
|
|
814
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
815
|
+
return jsx(TextClassContext.Provider, {
|
|
816
|
+
value: buttonTextVariants({
|
|
817
|
+
variant,
|
|
818
|
+
size,
|
|
819
|
+
className: "web:pointer-events-none"
|
|
820
|
+
}),
|
|
821
|
+
children: jsx(Pressable, _extends({
|
|
822
|
+
className: cn(props.disabled && "opacity-50 web:pointer-events-none", buttonVariants({
|
|
823
|
+
variant,
|
|
824
|
+
size,
|
|
825
|
+
className
|
|
826
|
+
})),
|
|
827
|
+
ref: ref,
|
|
828
|
+
role: "button"
|
|
829
|
+
}, props))
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
RNButton.displayName = "Button";
|
|
833
|
+
|
|
834
|
+
const _excluded = ["className"],
|
|
835
|
+
_excluded2 = ["className", "children"],
|
|
836
|
+
_excluded3 = ["className", "children", "portalHost", "closeOnOutsidePress"],
|
|
837
|
+
_excluded4 = ["className"];
|
|
838
|
+
const Dialog = DialogPrimitive.Root;
|
|
839
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
840
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
841
|
+
const DialogClose = DialogPrimitive.Close;
|
|
842
|
+
const DialogOverlayWeb = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
843
|
+
let {
|
|
844
|
+
className
|
|
845
|
+
} = _ref,
|
|
846
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
847
|
+
const {
|
|
848
|
+
open
|
|
849
|
+
} = DialogPrimitive.useRootContext();
|
|
850
|
+
return jsx(DialogPrimitive.Overlay, _extends({
|
|
851
|
+
className: cn("bg-black/80 flex justify-center items-center p-2 absolute top-0 right-0 bottom-0 left-0", open ? "web:animate-in web:fade-in-0" : "web:animate-out web:fade-out-0", className)
|
|
852
|
+
}, props, {
|
|
853
|
+
ref: ref
|
|
854
|
+
}));
|
|
855
|
+
});
|
|
856
|
+
DialogOverlayWeb.displayName = "DialogOverlayWeb";
|
|
857
|
+
const DialogOverlayNative = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
858
|
+
let {
|
|
859
|
+
className,
|
|
860
|
+
children
|
|
861
|
+
} = _ref2,
|
|
862
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
863
|
+
return jsx(DialogPrimitive.Overlay, _extends({
|
|
864
|
+
style: StyleSheet.absoluteFill,
|
|
865
|
+
className: cn("flex bg-black/80 justify-center items-center p-2", className)
|
|
866
|
+
}, props, {
|
|
867
|
+
ref: ref,
|
|
868
|
+
children: jsx(Animated.View, {
|
|
869
|
+
entering: FadeIn.duration(150),
|
|
870
|
+
exiting: FadeOut.duration(150),
|
|
871
|
+
children: jsx(Pressable, {
|
|
872
|
+
children: children
|
|
873
|
+
})
|
|
874
|
+
})
|
|
875
|
+
}));
|
|
876
|
+
});
|
|
877
|
+
DialogOverlayNative.displayName = "DialogOverlayNative";
|
|
878
|
+
const DialogOverlay = Platform.select({
|
|
879
|
+
web: DialogOverlayWeb,
|
|
880
|
+
default: DialogOverlayNative
|
|
881
|
+
});
|
|
882
|
+
const DialogContent = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
883
|
+
let {
|
|
884
|
+
className,
|
|
885
|
+
children,
|
|
886
|
+
portalHost,
|
|
887
|
+
closeOnOutsidePress
|
|
888
|
+
} = _ref3,
|
|
889
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
890
|
+
const {
|
|
891
|
+
open
|
|
892
|
+
} = DialogPrimitive.useRootContext();
|
|
893
|
+
return jsx(DialogPortal, {
|
|
894
|
+
hostName: portalHost,
|
|
895
|
+
children: jsx(DialogOverlay, {
|
|
896
|
+
closeOnPress: closeOnOutsidePress,
|
|
897
|
+
children: jsx(DialogPrimitive.Content, _extends({
|
|
898
|
+
ref: ref,
|
|
899
|
+
className: cn("max-w-lg gap-4 border border-[#E7E7E8] web:cursor-default bg-white p-6 shadow-lg web:duration-200 rounded-lg", open ? "web:animate-in web:fade-in-0 web:zoom-in-95" : "web:animate-out web:fade-out-0 web:zoom-out-95", className)
|
|
900
|
+
}, props, {
|
|
901
|
+
children: children
|
|
902
|
+
}))
|
|
903
|
+
})
|
|
904
|
+
});
|
|
905
|
+
});
|
|
906
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
907
|
+
const DialogTitle = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
908
|
+
let {
|
|
909
|
+
className
|
|
910
|
+
} = _ref4,
|
|
911
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded4);
|
|
912
|
+
return jsx(DialogPrimitive.Title, _extends({
|
|
913
|
+
ref: ref,
|
|
914
|
+
className: cn(className)
|
|
915
|
+
}, props));
|
|
916
|
+
});
|
|
917
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
918
|
+
function RNDialog({
|
|
919
|
+
title,
|
|
920
|
+
trigger,
|
|
921
|
+
content,
|
|
922
|
+
footer,
|
|
923
|
+
open,
|
|
924
|
+
onOpenChange,
|
|
925
|
+
closeOnOutsidePress = false,
|
|
926
|
+
containerClass,
|
|
927
|
+
portalHost
|
|
928
|
+
}) {
|
|
929
|
+
var _effect = useComponentTracking();
|
|
930
|
+
try {
|
|
931
|
+
const dialogOpen = open != null ? open : useControl(false);
|
|
932
|
+
const {
|
|
933
|
+
width
|
|
934
|
+
} = useWindowDimensions();
|
|
935
|
+
return jsxs(Dialog, {
|
|
936
|
+
open: dialogOpen.value,
|
|
937
|
+
onOpenChange: o => {
|
|
938
|
+
if (onOpenChange) {
|
|
939
|
+
onOpenChange(o);
|
|
940
|
+
} else {
|
|
941
|
+
dialogOpen.value = o;
|
|
942
|
+
}
|
|
943
|
+
},
|
|
944
|
+
children: [trigger && jsx(DialogTrigger, {
|
|
945
|
+
asChild: true,
|
|
946
|
+
children: trigger
|
|
947
|
+
}), jsxs(DialogContent, {
|
|
948
|
+
closeOnOutsidePress: closeOnOutsidePress,
|
|
949
|
+
className: cn("min-w-[200px] min-h-[200px]", containerClass),
|
|
950
|
+
style: {
|
|
951
|
+
maxWidth: width - 16
|
|
952
|
+
},
|
|
953
|
+
portalHost: Platform.select({
|
|
954
|
+
ios: portalHost
|
|
955
|
+
}),
|
|
956
|
+
children: [jsxs(View, {
|
|
957
|
+
className: "flex flex-row gap-[10px] justify-between items-start",
|
|
958
|
+
children: [jsx(DialogTitle, {
|
|
959
|
+
asChild: true,
|
|
960
|
+
className: "flex-1 flex-shrink title2",
|
|
961
|
+
children: title
|
|
962
|
+
}), jsx(DialogClose, {
|
|
963
|
+
className: "web:group rounded-sm web:ring-offset-background web:transition-opacity web:hover:opacity-100 web:focus:outline-none web:focus:ring-2 web:focus:ring-ring web:focus:ring-offset-2 web:disabled:pointer-events-none",
|
|
964
|
+
children: jsx(FontAwesome6, {
|
|
965
|
+
name: "xmark-circle",
|
|
966
|
+
size: 24,
|
|
967
|
+
color: "#267151"
|
|
968
|
+
})
|
|
969
|
+
})]
|
|
970
|
+
}), content, footer]
|
|
971
|
+
})]
|
|
972
|
+
});
|
|
973
|
+
} finally {
|
|
974
|
+
_effect();
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
export { Icon, RNButton, RNCheckbox, RNDialog, RNHtmlRenderer, RNRadioItem, RNText, RNTextInput, TextClassContext, buttonTextVariants, buttonVariants, createRNDateTimePickerRenderer, createRNSelectRenderer, defaultRnTailwindTheme, reactNativeHtml };
|
|
979
|
+
//# sourceMappingURL=index.js.map
|