react-native-better-html 1.0.17 → 1.0.19
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/index.d.mts +86 -10
- package/dist/index.d.ts +86 -10
- package/dist/index.js +987 -555
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +871 -442
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,49 +36,56 @@ __export(index_exports, {
|
|
|
36
36
|
Icon: () => Icon_default,
|
|
37
37
|
Image: () => Image_default,
|
|
38
38
|
InputField: () => InputField_default,
|
|
39
|
+
ListItem: () => ListItem_default,
|
|
39
40
|
Loader: () => Loader_default,
|
|
40
41
|
ScreenHolder: () => ScreenHolder_default,
|
|
41
42
|
StatusBar: () => StatusBar_default,
|
|
43
|
+
Switch: () => Switch_default,
|
|
42
44
|
Text: () => Text_default,
|
|
43
45
|
View: () => View_default,
|
|
46
|
+
alertControls: () => alertControls,
|
|
47
|
+
alertsPlugin: () => alertsPlugin,
|
|
44
48
|
asyncStoragePlugin: () => asyncStoragePlugin,
|
|
45
|
-
colorThemeControls: () =>
|
|
46
|
-
countries: () =>
|
|
47
|
-
darkenColor: () =>
|
|
49
|
+
colorThemeControls: () => import_react_better_core17.colorThemeControls,
|
|
50
|
+
countries: () => import_react_better_core17.countries,
|
|
51
|
+
darkenColor: () => import_react_better_core17.darkenColor,
|
|
52
|
+
defaultAlertsPluginOptions: () => defaultAlertsPluginOptions,
|
|
48
53
|
defaultAsyncStoragePluginOptions: () => defaultAsyncStoragePluginOptions,
|
|
49
|
-
desaturateColor: () =>
|
|
50
|
-
eventPreventDefault: () =>
|
|
51
|
-
eventPreventStop: () =>
|
|
52
|
-
eventStopPropagation: () =>
|
|
53
|
-
formatPhoneNumber: () =>
|
|
54
|
+
desaturateColor: () => import_react_better_core17.desaturateColor,
|
|
55
|
+
eventPreventDefault: () => import_react_better_core17.eventPreventDefault,
|
|
56
|
+
eventPreventStop: () => import_react_better_core17.eventPreventStop,
|
|
57
|
+
eventStopPropagation: () => import_react_better_core17.eventStopPropagation,
|
|
58
|
+
formatPhoneNumber: () => import_react_better_core17.formatPhoneNumber,
|
|
54
59
|
generateAsyncStorage: () => generateAsyncStorage,
|
|
55
|
-
generateRandomString: () =>
|
|
60
|
+
generateRandomString: () => import_react_better_core17.generateRandomString,
|
|
56
61
|
getFormErrorObject: () => getFormErrorObject,
|
|
57
|
-
getPluralWord: () =>
|
|
58
|
-
lightenColor: () =>
|
|
59
|
-
loaderControls: () =>
|
|
62
|
+
getPluralWord: () => import_react_better_core17.getPluralWord,
|
|
63
|
+
lightenColor: () => import_react_better_core17.lightenColor,
|
|
64
|
+
loaderControls: () => import_react_better_core17.loaderControls,
|
|
60
65
|
pressStrength: () => pressStrength,
|
|
61
|
-
saturateColor: () =>
|
|
66
|
+
saturateColor: () => import_react_better_core17.saturateColor,
|
|
67
|
+
useAlertControls: () => useAlertControls,
|
|
62
68
|
useBetterComponentsContext: () => useBetterComponentsContext,
|
|
63
|
-
useBooleanState: () =>
|
|
64
|
-
useDebounceState: () =>
|
|
69
|
+
useBooleanState: () => import_react_better_core17.useBooleanState,
|
|
70
|
+
useDebounceState: () => import_react_better_core17.useDebounceState,
|
|
65
71
|
useDevice: () => useDevice,
|
|
66
72
|
useEventEmitter: () => useEventEmitter,
|
|
67
73
|
useForm: () => useForm,
|
|
68
74
|
useKeyboard: () => useKeyboard,
|
|
69
|
-
useLoader: () =>
|
|
70
|
-
useLoaderControls: () =>
|
|
71
|
-
useTheme: () =>
|
|
75
|
+
useLoader: () => import_react_better_core17.useLoader,
|
|
76
|
+
useLoaderControls: () => import_react_better_core17.useLoaderControls,
|
|
77
|
+
useTheme: () => import_react_better_core17.useTheme
|
|
72
78
|
});
|
|
73
79
|
module.exports = __toCommonJS(index_exports);
|
|
74
|
-
var
|
|
80
|
+
var import_react_better_core17 = require("react-better-core");
|
|
75
81
|
|
|
76
82
|
// src/components/BetterComponentsProvider.tsx
|
|
77
|
-
var
|
|
78
|
-
var
|
|
83
|
+
var import_react12 = require("react");
|
|
84
|
+
var import_react_better_core11 = require("react-better-core");
|
|
79
85
|
|
|
80
86
|
// src/constants/app.ts
|
|
81
87
|
var appConfig = {};
|
|
88
|
+
var defaultAlertDuration = 2.3 * 1e3;
|
|
82
89
|
|
|
83
90
|
// src/constants/theme.ts
|
|
84
91
|
var theme = {};
|
|
@@ -120,115 +127,15 @@ var icons = {
|
|
|
120
127
|
// src/constants/assets.ts
|
|
121
128
|
var assets = {};
|
|
122
129
|
|
|
123
|
-
// src/components/
|
|
124
|
-
var
|
|
125
|
-
var
|
|
126
|
-
var externalBetterCoreContextValue;
|
|
127
|
-
var externalBetterComponentsContextValue;
|
|
128
|
-
var useBetterComponentsContext = () => {
|
|
129
|
-
const coreContext = (0, import_react_better_core.useBetterCoreContext)();
|
|
130
|
-
const context = (0, import_react.useContext)(betterComponentsContext);
|
|
131
|
-
if (context === void 0)
|
|
132
|
-
throw new Error(
|
|
133
|
-
"`useBetterComponentsContext()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
134
|
-
);
|
|
135
|
-
const { plugins, componentsState, ...rest } = context;
|
|
136
|
-
return {
|
|
137
|
-
...coreContext,
|
|
138
|
-
...rest
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
function BetterComponentsProviderInternalContent({ children }) {
|
|
142
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
143
|
-
}
|
|
144
|
-
function BetterComponentsProviderInternal({
|
|
145
|
-
config,
|
|
146
|
-
plugins,
|
|
147
|
-
children
|
|
148
|
-
}) {
|
|
149
|
-
const betterCoreContext = (0, import_react_better_core.useBetterCoreContext)();
|
|
150
|
-
const [sideMenuIsCollapsed, setSideMenuIsCollapsed] = (0, import_react_better_core.useBooleanState)();
|
|
151
|
-
const [sideMenuIsOpenMobile, setSideMenuIsOpenMobile] = (0, import_react_better_core.useBooleanState)();
|
|
152
|
-
const readyConfig = (0, import_react.useMemo)(
|
|
153
|
-
() => ({
|
|
154
|
-
app: {
|
|
155
|
-
...appConfig,
|
|
156
|
-
...config?.app
|
|
157
|
-
},
|
|
158
|
-
sideMenuIsCollapsed,
|
|
159
|
-
setSideMenuIsCollapsed,
|
|
160
|
-
sideMenuIsOpenMobile,
|
|
161
|
-
setSideMenuIsOpenMobile,
|
|
162
|
-
plugins: plugins ?? [],
|
|
163
|
-
componentsState: {}
|
|
164
|
-
}),
|
|
165
|
-
[config, sideMenuIsCollapsed, sideMenuIsOpenMobile, plugins]
|
|
166
|
-
);
|
|
167
|
-
(0, import_react.useEffect)(() => {
|
|
168
|
-
if (!plugins) return;
|
|
169
|
-
plugins.forEach((plugin) => {
|
|
170
|
-
plugin.initialize?.();
|
|
171
|
-
});
|
|
172
|
-
}, []);
|
|
173
|
-
externalBetterCoreContextValue = betterCoreContext;
|
|
174
|
-
externalBetterComponentsContextValue = readyConfig;
|
|
175
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(betterComponentsContext.Provider, { value: readyConfig, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BetterComponentsProviderInternalContent, { children }) });
|
|
176
|
-
}
|
|
177
|
-
function BetterComponentsProvider({ config, ...props }) {
|
|
178
|
-
const coreConfig = (0, import_react.useMemo)(
|
|
179
|
-
() => ({
|
|
180
|
-
theme: {
|
|
181
|
-
...theme,
|
|
182
|
-
...config?.theme
|
|
183
|
-
},
|
|
184
|
-
// colorTheme: config?.colorTheme ?? (localStorage.getItem("theme") === "dark" ? "dark" : "light"),
|
|
185
|
-
colorTheme: config?.colorTheme ?? "light",
|
|
186
|
-
icons: {
|
|
187
|
-
...icons,
|
|
188
|
-
...config?.icons
|
|
189
|
-
},
|
|
190
|
-
assets: {
|
|
191
|
-
...assets,
|
|
192
|
-
...config?.assets
|
|
193
|
-
},
|
|
194
|
-
loaders: config?.loaders
|
|
195
|
-
}),
|
|
196
|
-
[config]
|
|
197
|
-
);
|
|
198
|
-
const componentsConfig = (0, import_react.useMemo)(
|
|
199
|
-
() => ({
|
|
200
|
-
app: config?.app
|
|
201
|
-
}),
|
|
202
|
-
[config]
|
|
203
|
-
);
|
|
204
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_better_core.BetterCoreProvider, { config: coreConfig, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BetterComponentsProviderInternal, { config: componentsConfig, ...props }) });
|
|
205
|
-
}
|
|
206
|
-
var BetterComponentsProvider_default = (0, import_react.memo)(BetterComponentsProvider);
|
|
207
|
-
|
|
208
|
-
// src/utils/variableFunctions.ts
|
|
209
|
-
var checkBetterCoreContextValue = (value, functionsName) => {
|
|
210
|
-
if (value === void 0) {
|
|
211
|
-
throw new Error(
|
|
212
|
-
`\`${functionsName}()\` must be used within a \`<BetterCoreProvider>\`. Make sure to add one at the root of your component tree.`
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
return value !== void 0;
|
|
216
|
-
};
|
|
217
|
-
var pressStrength = () => {
|
|
218
|
-
if (!checkBetterCoreContextValue(externalBetterCoreContextValue, "pressStrength")) return void 0;
|
|
219
|
-
return {
|
|
220
|
-
p05: externalBetterCoreContextValue.colorTheme === "dark" ? 0.85 : 0.95,
|
|
221
|
-
p1: externalBetterCoreContextValue.colorTheme === "dark" ? 0.6 : 0.8,
|
|
222
|
-
p2: externalBetterCoreContextValue.colorTheme === "dark" ? 0.5 : 0.7,
|
|
223
|
-
p3: externalBetterCoreContextValue.colorTheme === "dark" ? 0.4 : 0.6
|
|
224
|
-
};
|
|
225
|
-
};
|
|
130
|
+
// src/components/alerts/AlertsHolder.tsx
|
|
131
|
+
var import_react11 = require("react");
|
|
132
|
+
var import_react_better_core10 = require("react-better-core");
|
|
226
133
|
|
|
227
134
|
// src/utils/hooks.ts
|
|
228
|
-
var
|
|
135
|
+
var import_react = require("react");
|
|
229
136
|
var import_react_native = require("react-native");
|
|
230
137
|
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
231
|
-
var
|
|
138
|
+
var import_react_better_core = require("react-better-core");
|
|
232
139
|
|
|
233
140
|
// src/constants/css.ts
|
|
234
141
|
var cssProps = /* @__PURE__ */ new Set([
|
|
@@ -421,7 +328,7 @@ var animateTransitionProps = /* @__PURE__ */ new Set([
|
|
|
421
328
|
|
|
422
329
|
// src/utils/hooks.ts
|
|
423
330
|
function useDevice() {
|
|
424
|
-
const theme2 = (0,
|
|
331
|
+
const theme2 = (0, import_react_better_core.useTheme)();
|
|
425
332
|
const safeAreaInsets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
|
|
426
333
|
const screenDimensions = import_react_native.Dimensions.get("screen");
|
|
427
334
|
const windowDimensions = import_react_native.Dimensions.get("window");
|
|
@@ -446,10 +353,10 @@ function useDevice() {
|
|
|
446
353
|
};
|
|
447
354
|
}
|
|
448
355
|
function useKeyboard() {
|
|
449
|
-
const [keyboardOpened, setKeyboardOpened] = (0,
|
|
450
|
-
const [keyboardWillOpen, setKeyboardWillOpen] = (0,
|
|
451
|
-
const [keyboardHeight, setKeyboardHeight] = (0,
|
|
452
|
-
(0,
|
|
356
|
+
const [keyboardOpened, setKeyboardOpened] = (0, import_react_better_core.useBooleanState)();
|
|
357
|
+
const [keyboardWillOpen, setKeyboardWillOpen] = (0, import_react_better_core.useBooleanState)();
|
|
358
|
+
const [keyboardHeight, setKeyboardHeight] = (0, import_react.useState)(0);
|
|
359
|
+
(0, import_react.useEffect)(() => {
|
|
453
360
|
const keyboardDidShow = (event) => {
|
|
454
361
|
setKeyboardOpened.setTrue();
|
|
455
362
|
setKeyboardHeight(event.endCoordinates.height);
|
|
@@ -476,7 +383,7 @@ function useKeyboard() {
|
|
|
476
383
|
};
|
|
477
384
|
}
|
|
478
385
|
function useComponentPropsGrouper(props, prefix) {
|
|
479
|
-
return (0,
|
|
386
|
+
return (0, import_react.useMemo)(() => {
|
|
480
387
|
const style = {};
|
|
481
388
|
const withPrefixStyle = {};
|
|
482
389
|
const restProps = {};
|
|
@@ -502,14 +409,14 @@ function useComponentPropsGrouper(props, prefix) {
|
|
|
502
409
|
}
|
|
503
410
|
function useForm(options) {
|
|
504
411
|
const { defaultValues, requiredFields, additional, onSubmit, validate } = options;
|
|
505
|
-
const inputFieldRefs = (0,
|
|
412
|
+
const inputFieldRefs = (0, import_react.useRef)(
|
|
506
413
|
{}
|
|
507
414
|
);
|
|
508
|
-
const [values, setValues] = (0,
|
|
509
|
-
const [errors, setErrors] = (0,
|
|
510
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
415
|
+
const [values, setValues] = (0, import_react.useState)(defaultValues);
|
|
416
|
+
const [errors, setErrors] = (0, import_react.useState)({});
|
|
417
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react_better_core.useBooleanState)();
|
|
511
418
|
const numberOfInputFields = Object.keys(defaultValues).length;
|
|
512
|
-
const setFieldValue = (0,
|
|
419
|
+
const setFieldValue = (0, import_react.useCallback)(
|
|
513
420
|
(field, value) => {
|
|
514
421
|
setValues((oldValue) => ({
|
|
515
422
|
...oldValue,
|
|
@@ -522,7 +429,7 @@ function useForm(options) {
|
|
|
522
429
|
},
|
|
523
430
|
[]
|
|
524
431
|
);
|
|
525
|
-
const setFieldsValue = (0,
|
|
432
|
+
const setFieldsValue = (0, import_react.useCallback)((values2) => {
|
|
526
433
|
setValues((oldValue) => ({
|
|
527
434
|
...oldValue,
|
|
528
435
|
...values2
|
|
@@ -533,15 +440,15 @@ function useForm(options) {
|
|
|
533
440
|
return newErrors;
|
|
534
441
|
});
|
|
535
442
|
}, []);
|
|
536
|
-
const focusField = (0,
|
|
443
|
+
const focusField = (0, import_react.useCallback)((field) => {
|
|
537
444
|
inputFieldRefs.current[field]?.focus();
|
|
538
445
|
}, []);
|
|
539
|
-
const validateForm = (0,
|
|
446
|
+
const validateForm = (0, import_react.useCallback)(() => {
|
|
540
447
|
const validationErrors = validate?.(values) || {};
|
|
541
448
|
setErrors(validationErrors);
|
|
542
449
|
return validationErrors;
|
|
543
450
|
}, [validate, values]);
|
|
544
|
-
const onSubmitFunction = (0,
|
|
451
|
+
const onSubmitFunction = (0, import_react.useCallback)(
|
|
545
452
|
async (event) => {
|
|
546
453
|
event?.preventDefault();
|
|
547
454
|
setIsSubmitting.setTrue();
|
|
@@ -559,7 +466,7 @@ function useForm(options) {
|
|
|
559
466
|
},
|
|
560
467
|
[values, validateForm, onSubmit, focusField]
|
|
561
468
|
);
|
|
562
|
-
const getInputFieldProps = (0,
|
|
469
|
+
const getInputFieldProps = (0, import_react.useCallback)(
|
|
563
470
|
(field) => {
|
|
564
471
|
const thisInputFieldIndex = Object.keys(values).findIndex((key) => key === field);
|
|
565
472
|
const isLastInputField = thisInputFieldIndex === numberOfInputFields - 1;
|
|
@@ -584,19 +491,35 @@ function useForm(options) {
|
|
|
584
491
|
},
|
|
585
492
|
[values, setFieldValue, errors, requiredFields, additional, onSubmitFunction]
|
|
586
493
|
);
|
|
587
|
-
const
|
|
494
|
+
const getSwitchProps = (0, import_react.useCallback)(
|
|
495
|
+
(field, insideListItem) => {
|
|
496
|
+
return insideListItem ? {
|
|
497
|
+
switchIsEnabled: values[field],
|
|
498
|
+
switchOnChange: (value) => {
|
|
499
|
+
setFieldValue(field, value);
|
|
500
|
+
}
|
|
501
|
+
} : {
|
|
502
|
+
isEnabled: values[field],
|
|
503
|
+
onChange: (value) => {
|
|
504
|
+
setFieldValue(field, value);
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
},
|
|
508
|
+
[values, setFieldValue]
|
|
509
|
+
);
|
|
510
|
+
const reset = (0, import_react.useCallback)(() => {
|
|
588
511
|
setValues(defaultValues);
|
|
589
512
|
setErrors({});
|
|
590
513
|
}, [defaultValues]);
|
|
591
|
-
const isDirty = (0,
|
|
514
|
+
const isDirty = (0, import_react.useMemo)(
|
|
592
515
|
() => Object.keys(defaultValues).some((key) => defaultValues[key] !== values[key]),
|
|
593
516
|
[defaultValues, values]
|
|
594
517
|
);
|
|
595
|
-
const isValid = (0,
|
|
518
|
+
const isValid = (0, import_react.useMemo)(() => {
|
|
596
519
|
const validationErrors = validate?.(values) || {};
|
|
597
520
|
return Object.keys(validationErrors).length === 0;
|
|
598
521
|
}, [validate, values]);
|
|
599
|
-
const canSubmit = (0,
|
|
522
|
+
const canSubmit = (0, import_react.useMemo)(() => {
|
|
600
523
|
const requiredFieldsHaveValues = requiredFields?.every((field) => values[field] !== void 0 && values[field] !== "") ?? true;
|
|
601
524
|
return isValid && requiredFieldsHaveValues;
|
|
602
525
|
}, [isValid, requiredFields]);
|
|
@@ -607,6 +530,7 @@ function useForm(options) {
|
|
|
607
530
|
setFieldValue,
|
|
608
531
|
setFieldsValue,
|
|
609
532
|
getInputFieldProps,
|
|
533
|
+
getSwitchProps,
|
|
610
534
|
focusField,
|
|
611
535
|
inputFieldRefs: inputFieldRefs.current,
|
|
612
536
|
validate: validateForm,
|
|
@@ -630,42 +554,11 @@ function useEventEmitter() {
|
|
|
630
554
|
};
|
|
631
555
|
}
|
|
632
556
|
|
|
633
|
-
// src/utils/functions.ts
|
|
634
|
-
var getFormErrorObject = (formValues) => {
|
|
635
|
-
return {};
|
|
636
|
-
};
|
|
637
|
-
|
|
638
|
-
// src/utils/asyncStorage.ts
|
|
639
|
-
var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
|
|
640
|
-
function generateAsyncStorage() {
|
|
641
|
-
return {
|
|
642
|
-
setItem: async (name, value) => {
|
|
643
|
-
if (value) await import_async_storage.default.setItem(name.toString(), JSON.stringify(value));
|
|
644
|
-
else await import_async_storage.default.removeItem(name.toString());
|
|
645
|
-
},
|
|
646
|
-
getItem: async (name) => {
|
|
647
|
-
const item = await import_async_storage.default.getItem(name.toString());
|
|
648
|
-
if (item === null) return void 0;
|
|
649
|
-
try {
|
|
650
|
-
return JSON.parse(item);
|
|
651
|
-
} catch (error) {
|
|
652
|
-
return void 0;
|
|
653
|
-
}
|
|
654
|
-
},
|
|
655
|
-
removeItem: async (name) => {
|
|
656
|
-
await import_async_storage.default.removeItem(name.toString());
|
|
657
|
-
},
|
|
658
|
-
removeAllItems: () => {
|
|
659
|
-
import_async_storage.default.clear();
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
}
|
|
663
|
-
|
|
664
557
|
// src/components/View.tsx
|
|
665
|
-
var
|
|
558
|
+
var import_react2 = require("react");
|
|
666
559
|
var import_react_native2 = require("react-native");
|
|
667
|
-
var
|
|
668
|
-
var
|
|
560
|
+
var import_react_better_core2 = require("react-better-core");
|
|
561
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
669
562
|
var touchableHighlightStyleMoveToContent = [
|
|
670
563
|
"width",
|
|
671
564
|
"backgroundColor",
|
|
@@ -717,8 +610,8 @@ var ViewComponent = function View({
|
|
|
717
610
|
children,
|
|
718
611
|
...props
|
|
719
612
|
}) {
|
|
720
|
-
const theme2 = (0,
|
|
721
|
-
const style = (0,
|
|
613
|
+
const theme2 = (0, import_react_better_core2.useTheme)();
|
|
614
|
+
const style = (0, import_react2.useMemo)(
|
|
722
615
|
() => ({
|
|
723
616
|
flexDirection: isRow ? "row" : "column",
|
|
724
617
|
...props,
|
|
@@ -731,7 +624,7 @@ var ViewComponent = function View({
|
|
|
731
624
|
}),
|
|
732
625
|
[isRow, props]
|
|
733
626
|
);
|
|
734
|
-
const touchableHighlightStyle = (0,
|
|
627
|
+
const touchableHighlightStyle = (0, import_react2.useMemo)(
|
|
735
628
|
() => ({
|
|
736
629
|
...style,
|
|
737
630
|
...touchableHighlightStyleMoveToContent.reduce((previousValue, currentValue) => {
|
|
@@ -744,21 +637,21 @@ var ViewComponent = function View({
|
|
|
744
637
|
}),
|
|
745
638
|
[style]
|
|
746
639
|
);
|
|
747
|
-
const touchableHighlightContentProps = (0,
|
|
640
|
+
const touchableHighlightContentProps = (0, import_react2.useMemo)(
|
|
748
641
|
() => touchableHighlightStyleMoveToContent.reduce((previousValue, currentValue) => {
|
|
749
642
|
previousValue[currentValue] = props[currentValue];
|
|
750
643
|
return previousValue;
|
|
751
644
|
}, {}),
|
|
752
645
|
[props]
|
|
753
646
|
);
|
|
754
|
-
const touchableNativeFeedbackHolderStyle = (0,
|
|
647
|
+
const touchableNativeFeedbackHolderStyle = (0, import_react2.useMemo)(
|
|
755
648
|
() => touchableNativeFeedbackStyleMoveToHolder.reduce((previousValue, currentValue) => {
|
|
756
649
|
previousValue[currentValue] = props[currentValue];
|
|
757
650
|
return previousValue;
|
|
758
651
|
}, {}),
|
|
759
652
|
[props]
|
|
760
653
|
);
|
|
761
|
-
const touchableNativeFeedbackContentStyle = (0,
|
|
654
|
+
const touchableNativeFeedbackContentStyle = (0, import_react2.useMemo)(
|
|
762
655
|
() => ({
|
|
763
656
|
...style,
|
|
764
657
|
...touchableNativeFeedbackStyleMoveToHolder.reduce(
|
|
@@ -773,7 +666,7 @@ var ViewComponent = function View({
|
|
|
773
666
|
}),
|
|
774
667
|
[style]
|
|
775
668
|
);
|
|
776
|
-
const pressEvents = (0,
|
|
669
|
+
const pressEvents = (0, import_react2.useMemo)(
|
|
777
670
|
() => !disabled ? {
|
|
778
671
|
onPress: (event) => {
|
|
779
672
|
onPress?.(event);
|
|
@@ -787,7 +680,7 @@ var ViewComponent = function View({
|
|
|
787
680
|
);
|
|
788
681
|
const androidBoxShadow = import_react_native2.Platform.OS === "android" ? props.shadowOffsetWidth !== void 0 || props.shadowOffsetHeight !== void 0 ? `${props.shadowOffsetWidth ?? 0}px ${props.shadowOffsetHeight ?? 0}px ${props.shadowRadius}px ${props.shadowColor?.toString() ?? "#000000"}` : void 0 : void 0;
|
|
789
682
|
const isPressable = onPress || onPressIn || onPressOut || onLongPress || onPressWithValue;
|
|
790
|
-
return isPressable ? pressType === "opacity" ? /* @__PURE__ */ (0,
|
|
683
|
+
return isPressable ? pressType === "opacity" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
791
684
|
import_react_native2.TouchableOpacity,
|
|
792
685
|
{
|
|
793
686
|
style,
|
|
@@ -797,7 +690,7 @@ var ViewComponent = function View({
|
|
|
797
690
|
...props,
|
|
798
691
|
children
|
|
799
692
|
}
|
|
800
|
-
) : pressType === "highlight" ? import_react_native2.Platform.OS === "ios" ? /* @__PURE__ */ (0,
|
|
693
|
+
) : pressType === "highlight" ? import_react_native2.Platform.OS === "ios" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
801
694
|
import_react_native2.TouchableHighlight,
|
|
802
695
|
{
|
|
803
696
|
activeOpacity: pressStrength2,
|
|
@@ -805,7 +698,7 @@ var ViewComponent = function View({
|
|
|
805
698
|
style: touchableHighlightStyle,
|
|
806
699
|
...pressEvents,
|
|
807
700
|
...props,
|
|
808
|
-
children: /* @__PURE__ */ (0,
|
|
701
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
809
702
|
ViewComponent,
|
|
810
703
|
{
|
|
811
704
|
width: "100%",
|
|
@@ -820,7 +713,7 @@ var ViewComponent = function View({
|
|
|
820
713
|
}
|
|
821
714
|
)
|
|
822
715
|
}
|
|
823
|
-
) : import_react_native2.Platform.OS === "android" ? /* @__PURE__ */ (0,
|
|
716
|
+
) : import_react_native2.Platform.OS === "android" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
824
717
|
ViewComponent,
|
|
825
718
|
{
|
|
826
719
|
...touchableNativeFeedbackHolderStyle,
|
|
@@ -832,7 +725,7 @@ var ViewComponent = function View({
|
|
|
832
725
|
boxShadow: androidBoxShadow,
|
|
833
726
|
overflow: "hidden",
|
|
834
727
|
pointerEvents: "box-none",
|
|
835
|
-
children: /* @__PURE__ */ (0,
|
|
728
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
836
729
|
import_react_native2.TouchableNativeFeedback,
|
|
837
730
|
{
|
|
838
731
|
...pressEvents,
|
|
@@ -843,15 +736,15 @@ var ViewComponent = function View({
|
|
|
843
736
|
),
|
|
844
737
|
useForeground: true,
|
|
845
738
|
touchSoundDisabled: true,
|
|
846
|
-
children: /* @__PURE__ */ (0,
|
|
739
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ViewComponent, { flex: 1, ...touchableNativeFeedbackContentStyle, children })
|
|
847
740
|
}
|
|
848
741
|
)
|
|
849
742
|
}
|
|
850
|
-
) : /* @__PURE__ */ (0,
|
|
743
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { boxShadow: androidBoxShadow, style, ...props, children });
|
|
851
744
|
};
|
|
852
745
|
ViewComponent.box = function Box({ withShadow, ...props }) {
|
|
853
|
-
const theme2 = (0,
|
|
854
|
-
const shadowProps = (0,
|
|
746
|
+
const theme2 = (0, import_react_better_core2.useTheme)();
|
|
747
|
+
const shadowProps = (0, import_react2.useMemo)(
|
|
855
748
|
() => withShadow ? {
|
|
856
749
|
shadowOpacity: 0.2,
|
|
857
750
|
shadowOffsetHeight: 10,
|
|
@@ -860,7 +753,7 @@ ViewComponent.box = function Box({ withShadow, ...props }) {
|
|
|
860
753
|
} : {},
|
|
861
754
|
[]
|
|
862
755
|
);
|
|
863
|
-
return /* @__PURE__ */ (0,
|
|
756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
864
757
|
ViewComponent,
|
|
865
758
|
{
|
|
866
759
|
width: "100%",
|
|
@@ -875,18 +768,52 @@ ViewComponent.box = function Box({ withShadow, ...props }) {
|
|
|
875
768
|
}
|
|
876
769
|
);
|
|
877
770
|
};
|
|
878
|
-
var View2 = (0,
|
|
771
|
+
var View2 = (0, import_react2.memo)(ViewComponent);
|
|
879
772
|
View2.box = ViewComponent.box;
|
|
880
773
|
var View_default = View2;
|
|
881
774
|
|
|
775
|
+
// src/components/alerts/Alert.tsx
|
|
776
|
+
var import_react10 = require("react");
|
|
777
|
+
var import_react_better_core9 = require("react-better-core");
|
|
778
|
+
|
|
779
|
+
// src/plugins/alerts.ts
|
|
780
|
+
var defaultAlertsPluginOptions = {
|
|
781
|
+
align: "right",
|
|
782
|
+
defaultDuration: "auto",
|
|
783
|
+
defaultDisplay: {},
|
|
784
|
+
withCloseButton: true
|
|
785
|
+
};
|
|
786
|
+
var alertsPlugin = (options) => ({
|
|
787
|
+
name: "alerts",
|
|
788
|
+
initialize: () => {
|
|
789
|
+
},
|
|
790
|
+
getConfig: () => ({
|
|
791
|
+
...defaultAlertsPluginOptions,
|
|
792
|
+
...options
|
|
793
|
+
})
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
// src/plugins/asyncStorage.ts
|
|
797
|
+
var defaultAsyncStoragePluginOptions = {};
|
|
798
|
+
var asyncStoragePlugin = (options) => ({
|
|
799
|
+
name: "asyncStorage",
|
|
800
|
+
initialize: () => {
|
|
801
|
+
console.log("asyncStorage plugin initialized");
|
|
802
|
+
},
|
|
803
|
+
getConfig: () => ({
|
|
804
|
+
...defaultAsyncStoragePluginOptions,
|
|
805
|
+
...options
|
|
806
|
+
})
|
|
807
|
+
});
|
|
808
|
+
|
|
882
809
|
// src/components/Text.tsx
|
|
883
|
-
var
|
|
810
|
+
var import_react3 = require("react");
|
|
884
811
|
var import_react_native3 = require("react-native");
|
|
885
|
-
var
|
|
886
|
-
var
|
|
812
|
+
var import_react_better_core3 = require("react-better-core");
|
|
813
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
887
814
|
var TextComponent = function Text({ selectionColor, children, ...props }) {
|
|
888
|
-
const theme2 = (0,
|
|
889
|
-
const style = (0,
|
|
815
|
+
const theme2 = (0, import_react_better_core3.useTheme)();
|
|
816
|
+
const style = (0, import_react3.useMemo)(
|
|
890
817
|
() => ({
|
|
891
818
|
fontSize: 16,
|
|
892
819
|
color: theme2.colors.textPrimary,
|
|
@@ -894,27 +821,27 @@ var TextComponent = function Text({ selectionColor, children, ...props }) {
|
|
|
894
821
|
}),
|
|
895
822
|
[theme2, props]
|
|
896
823
|
);
|
|
897
|
-
return /* @__PURE__ */ (0,
|
|
824
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.Text, { selectionColor: selectionColor ?? theme2.colors.primary, style, ...props, children });
|
|
898
825
|
};
|
|
899
826
|
TextComponent.title = function Title(props) {
|
|
900
|
-
return /* @__PURE__ */ (0,
|
|
827
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TextComponent, { fontSize: 32, fontWeight: 700, ...props });
|
|
901
828
|
};
|
|
902
829
|
TextComponent.subtitle = function Subtitle(props) {
|
|
903
|
-
return /* @__PURE__ */ (0,
|
|
830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TextComponent, { fontSize: 24, fontWeight: 700, ...props });
|
|
904
831
|
};
|
|
905
832
|
TextComponent.body = function Body(props) {
|
|
906
|
-
const theme2 = (0,
|
|
907
|
-
return /* @__PURE__ */ (0,
|
|
833
|
+
const theme2 = (0, import_react_better_core3.useTheme)();
|
|
834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TextComponent, { color: theme2.colors.textSecondary, ...props });
|
|
908
835
|
};
|
|
909
836
|
TextComponent.caption = function Caption(props) {
|
|
910
|
-
const theme2 = (0,
|
|
911
|
-
return /* @__PURE__ */ (0,
|
|
837
|
+
const theme2 = (0, import_react_better_core3.useTheme)();
|
|
838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TextComponent, { fontSize: 14, color: theme2.colors.textSecondary, ...props });
|
|
912
839
|
};
|
|
913
840
|
TextComponent.unknown = function Unknown(props) {
|
|
914
|
-
const theme2 = (0,
|
|
915
|
-
return /* @__PURE__ */ (0,
|
|
841
|
+
const theme2 = (0, import_react_better_core3.useTheme)();
|
|
842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TextComponent, { fontStyle: "italic", textAlign: "center", color: theme2.colors.textSecondary, ...props });
|
|
916
843
|
};
|
|
917
|
-
var Text2 = (0,
|
|
844
|
+
var Text2 = (0, import_react3.memo)(TextComponent);
|
|
918
845
|
Text2.title = TextComponent.title;
|
|
919
846
|
Text2.subtitle = TextComponent.subtitle;
|
|
920
847
|
Text2.body = TextComponent.body;
|
|
@@ -922,67 +849,167 @@ Text2.caption = TextComponent.caption;
|
|
|
922
849
|
Text2.unknown = TextComponent.unknown;
|
|
923
850
|
var Text_default = Text2;
|
|
924
851
|
|
|
925
|
-
// src/components/
|
|
926
|
-
var
|
|
927
|
-
var
|
|
928
|
-
var
|
|
852
|
+
// src/components/Icon.tsx
|
|
853
|
+
var import_react4 = require("react");
|
|
854
|
+
var import_react_native4 = require("react-native");
|
|
855
|
+
var import_react_native_svg = require("react-native-svg");
|
|
856
|
+
var import_react_better_core5 = require("react-better-core");
|
|
857
|
+
var import_expo_symbols = require("expo-symbols");
|
|
929
858
|
|
|
930
|
-
// src/
|
|
931
|
-
var
|
|
932
|
-
var
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
View: (0, import_react5.memo)(function View3({ transformOriginX, transformOriginY, children, ...props }) {
|
|
937
|
-
const initialProps = useComponentPropsGrouper(props, "initial");
|
|
938
|
-
const animateProps2 = useComponentPropsGrouper(props, "animate");
|
|
939
|
-
const whileTapProps = useComponentPropsGrouper(props, "whileTap");
|
|
940
|
-
const transitionProps = useComponentPropsGrouper(props, "transition");
|
|
941
|
-
const transition = (0, import_react5.useMemo)(
|
|
942
|
-
() => ({
|
|
943
|
-
type: "timing",
|
|
944
|
-
duration: defaultTransitionDuration,
|
|
945
|
-
...transitionProps.withPrefixStyle
|
|
946
|
-
}),
|
|
947
|
-
[transitionProps.withPrefixStyle]
|
|
948
|
-
);
|
|
949
|
-
const transformOrigin = (0, import_react5.useMemo)(
|
|
950
|
-
() => transformOriginX !== void 0 || transformOriginY !== void 0 ? {
|
|
951
|
-
x: transformOriginX ?? 0,
|
|
952
|
-
y: transformOriginY ?? 0
|
|
953
|
-
} : void 0,
|
|
954
|
-
[transformOriginX, transformOriginY]
|
|
859
|
+
// src/utils/variableFunctions.ts
|
|
860
|
+
var import_react_better_core4 = require("react-better-core");
|
|
861
|
+
var checkBetterCoreContextValue = (value, functionsName) => {
|
|
862
|
+
if (value === void 0) {
|
|
863
|
+
throw new Error(
|
|
864
|
+
`\`${functionsName}()\` must be used within a \`<BetterCoreProvider>\`. Make sure to add one at the root of your component tree.`
|
|
955
865
|
);
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
whileTap: whileTapProps.withPrefixStyle,
|
|
964
|
-
transformOrigin,
|
|
965
|
-
children
|
|
966
|
-
}
|
|
866
|
+
}
|
|
867
|
+
return value !== void 0;
|
|
868
|
+
};
|
|
869
|
+
var checkBetterComponentsContextValue = (value, functionsName) => {
|
|
870
|
+
if (value === void 0) {
|
|
871
|
+
throw new Error(
|
|
872
|
+
`\`${functionsName}()\` must be used within a \`<BetterComponentsProvider>\`. Make sure to add one at the root of your component tree.`
|
|
967
873
|
);
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
const
|
|
976
|
-
()
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
874
|
+
}
|
|
875
|
+
return value !== void 0;
|
|
876
|
+
};
|
|
877
|
+
var alertControls = {
|
|
878
|
+
createAlert: (alert) => {
|
|
879
|
+
if (!checkBetterComponentsContextValue(externalBetterComponentsContextValue, "alertControls.createAlert"))
|
|
880
|
+
return void 0;
|
|
881
|
+
const readyAlert = {
|
|
882
|
+
id: (0, import_react_better_core4.generateRandomString)(36),
|
|
883
|
+
...alert
|
|
884
|
+
};
|
|
885
|
+
externalBetterComponentsContextValue.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
886
|
+
return readyAlert;
|
|
887
|
+
},
|
|
888
|
+
removeAlert: (alertId) => {
|
|
889
|
+
if (!checkBetterComponentsContextValue(externalBetterComponentsContextValue, "alertControls.removeAlert"))
|
|
890
|
+
return;
|
|
891
|
+
externalBetterComponentsContextValue.setAlerts(
|
|
892
|
+
(oldValue) => oldValue.filter((alert) => alert.id !== alertId)
|
|
982
893
|
);
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
var pressStrength = () => {
|
|
897
|
+
if (!checkBetterCoreContextValue(externalBetterCoreContextValue, "pressStrength")) return void 0;
|
|
898
|
+
return {
|
|
899
|
+
p05: externalBetterCoreContextValue.colorTheme === "dark" ? 0.85 : 0.95,
|
|
900
|
+
p1: externalBetterCoreContextValue.colorTheme === "dark" ? 0.6 : 0.8,
|
|
901
|
+
p2: externalBetterCoreContextValue.colorTheme === "dark" ? 0.5 : 0.7,
|
|
902
|
+
p3: externalBetterCoreContextValue.colorTheme === "dark" ? 0.4 : 0.6
|
|
903
|
+
};
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
// src/components/Icon.tsx
|
|
907
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
908
|
+
var import_react5 = require("react");
|
|
909
|
+
function Icon({ name, nameIOS, size = 16, color, ...props }) {
|
|
910
|
+
const theme2 = (0, import_react_better_core5.useTheme)();
|
|
911
|
+
const { icons: icons2 } = (0, import_react_better_core5.useBetterCoreContext)();
|
|
912
|
+
const svgColor = color ?? theme2.colors.textPrimary;
|
|
913
|
+
(0, import_react4.useEffect)(() => {
|
|
914
|
+
if (!icons2[name.toString()])
|
|
915
|
+
console.warn(
|
|
916
|
+
`The icon \`${name}\` you are trying to use does not exist. Make sure to add it to the \`icons\` object in \`<BetterComponentsProvider>\` config value prop.`
|
|
917
|
+
);
|
|
918
|
+
}, [icons2, name]);
|
|
919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
920
|
+
View_default,
|
|
921
|
+
{
|
|
922
|
+
width: size + (parseFloat(props.padding?.toString() ?? "0") ?? 0) + (parseFloat(props.paddingHorizontal?.toString() ?? "0") ?? 0),
|
|
923
|
+
height: size + (parseFloat(props.padding?.toString() ?? "0") ?? 0) + (parseFloat(props.paddingVertical?.toString() ?? "0") ?? 0),
|
|
924
|
+
alignItems: "center",
|
|
925
|
+
justifyContent: "center",
|
|
926
|
+
pressType: "opacity",
|
|
927
|
+
pressStrength: pressStrength().p2,
|
|
928
|
+
...props,
|
|
929
|
+
children: import_react_native4.Platform.OS === "ios" && nameIOS ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_expo_symbols.SymbolView, { name: nameIOS, tintColor: svgColor, size: size * 1.12 }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
930
|
+
import_react_native_svg.Svg,
|
|
931
|
+
{
|
|
932
|
+
width: size,
|
|
933
|
+
height: size,
|
|
934
|
+
viewBox: `0 0 ${icons2[name.toString()]?.width ?? 0} ${icons2[name.toString()]?.height ?? 0}`,
|
|
935
|
+
fill: "none",
|
|
936
|
+
children: icons2[name.toString()]?.paths.map(({ type, ...path }) => /* @__PURE__ */ (0, import_react5.createElement)(
|
|
937
|
+
import_react_native_svg.Path,
|
|
938
|
+
{
|
|
939
|
+
...path,
|
|
940
|
+
fill: type === "fill" ? svgColor : void 0,
|
|
941
|
+
stroke: type === "stroke" ? svgColor : void 0,
|
|
942
|
+
key: path.d
|
|
943
|
+
}
|
|
944
|
+
))
|
|
945
|
+
}
|
|
946
|
+
)
|
|
947
|
+
}
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
var Icon_default = (0, import_react4.memo)(Icon);
|
|
951
|
+
|
|
952
|
+
// src/components/Button.tsx
|
|
953
|
+
var import_react9 = require("react");
|
|
954
|
+
var import_react_native7 = require("react-native");
|
|
955
|
+
var import_react_better_core8 = require("react-better-core");
|
|
956
|
+
|
|
957
|
+
// src/components/Animate.tsx
|
|
958
|
+
var import_react6 = require("react");
|
|
959
|
+
var import_motion = require("@legendapp/motion");
|
|
960
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
961
|
+
var defaultTransitionDuration = 0.15 * 1e3;
|
|
962
|
+
var Animate = {
|
|
963
|
+
View: (0, import_react6.memo)(function View3({ transformOriginX, transformOriginY, children, ...props }) {
|
|
964
|
+
const initialProps = useComponentPropsGrouper(props, "initial");
|
|
965
|
+
const animateProps2 = useComponentPropsGrouper(props, "animate");
|
|
966
|
+
const whileTapProps = useComponentPropsGrouper(props, "whileTap");
|
|
967
|
+
const transitionProps = useComponentPropsGrouper(props, "transition");
|
|
968
|
+
const transition = (0, import_react6.useMemo)(
|
|
969
|
+
() => ({
|
|
970
|
+
type: "timing",
|
|
971
|
+
duration: defaultTransitionDuration,
|
|
972
|
+
...transitionProps.withPrefixStyle
|
|
973
|
+
}),
|
|
974
|
+
[transitionProps.withPrefixStyle]
|
|
975
|
+
);
|
|
976
|
+
const transformOrigin = (0, import_react6.useMemo)(
|
|
977
|
+
() => transformOriginX !== void 0 || transformOriginY !== void 0 ? {
|
|
978
|
+
x: transformOriginX ?? 0,
|
|
979
|
+
y: transformOriginY ?? 0
|
|
980
|
+
} : void 0,
|
|
981
|
+
[transformOriginX, transformOriginY]
|
|
982
|
+
);
|
|
983
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
984
|
+
import_motion.Motion.View,
|
|
985
|
+
{
|
|
986
|
+
style: initialProps.style,
|
|
987
|
+
initial: initialProps.withPrefixStyle,
|
|
988
|
+
animate: animateProps2.withPrefixStyle,
|
|
989
|
+
transition,
|
|
990
|
+
whileTap: whileTapProps.withPrefixStyle,
|
|
991
|
+
transformOrigin,
|
|
992
|
+
children
|
|
993
|
+
}
|
|
994
|
+
);
|
|
995
|
+
return Object.keys(whileTapProps.withPrefixStyle).length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_motion.Motion.Pressable, { children: content }) : content;
|
|
996
|
+
}),
|
|
997
|
+
Text: (0, import_react6.memo)(function Text3({ transformOriginX, transformOriginY, children, ...props }) {
|
|
998
|
+
const initialProps = useComponentPropsGrouper(props, "initial");
|
|
999
|
+
const animateProps2 = useComponentPropsGrouper(props, "animate");
|
|
1000
|
+
const whileTapProps = useComponentPropsGrouper(props, "whileTap");
|
|
1001
|
+
const transitionProps = useComponentPropsGrouper(props, "transition");
|
|
1002
|
+
const transition = (0, import_react6.useMemo)(
|
|
1003
|
+
() => ({
|
|
1004
|
+
type: "timing",
|
|
1005
|
+
duration: defaultTransitionDuration,
|
|
1006
|
+
...transitionProps.withPrefixStyle
|
|
1007
|
+
}),
|
|
1008
|
+
[transitionProps.withPrefixStyle]
|
|
1009
|
+
);
|
|
1010
|
+
const transformOrigin = (0, import_react6.useMemo)(
|
|
1011
|
+
() => transformOriginX !== void 0 || transformOriginY !== void 0 ? {
|
|
1012
|
+
x: transformOriginX ?? 0,
|
|
986
1013
|
y: transformOriginY ?? 0
|
|
987
1014
|
} : void 0,
|
|
988
1015
|
[transformOriginX, transformOriginY]
|
|
@@ -1005,16 +1032,16 @@ var Animate = {
|
|
|
1005
1032
|
var Animate_default = Animate;
|
|
1006
1033
|
|
|
1007
1034
|
// src/components/Loader.tsx
|
|
1008
|
-
var
|
|
1009
|
-
var
|
|
1010
|
-
var
|
|
1035
|
+
var import_react7 = require("react");
|
|
1036
|
+
var import_react_native5 = require("react-native");
|
|
1037
|
+
var import_react_better_core6 = require("react-better-core");
|
|
1011
1038
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1012
1039
|
var LoaderComponent = function Loader({ size = "small", color, ...props }) {
|
|
1013
|
-
const theme2 = (0,
|
|
1014
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(View_default, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1040
|
+
const theme2 = (0, import_react_better_core6.useTheme)();
|
|
1041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(View_default, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.ActivityIndicator, { size, color: color ?? theme2.colors.textPrimary }) });
|
|
1015
1042
|
};
|
|
1016
1043
|
LoaderComponent.box = function Box2({ text = "Loading...", size = "large", color, ...props }) {
|
|
1017
|
-
const theme2 = (0,
|
|
1044
|
+
const theme2 = (0, import_react_better_core6.useTheme)();
|
|
1018
1045
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1019
1046
|
View_default,
|
|
1020
1047
|
{
|
|
@@ -1031,7 +1058,7 @@ LoaderComponent.box = function Box2({ text = "Loading...", size = "large", color
|
|
|
1031
1058
|
);
|
|
1032
1059
|
};
|
|
1033
1060
|
LoaderComponent.text = function LoaderText({ text = "Loading...", size, color, ...props }) {
|
|
1034
|
-
const theme2 = (0,
|
|
1061
|
+
const theme2 = (0, import_react_better_core6.useTheme)();
|
|
1035
1062
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1036
1063
|
View_default,
|
|
1037
1064
|
{
|
|
@@ -1048,20 +1075,89 @@ LoaderComponent.text = function LoaderText({ text = "Loading...", size, color, .
|
|
|
1048
1075
|
}
|
|
1049
1076
|
);
|
|
1050
1077
|
};
|
|
1051
|
-
var Loader2 = (0,
|
|
1078
|
+
var Loader2 = (0, import_react7.memo)(LoaderComponent);
|
|
1052
1079
|
Loader2.box = LoaderComponent.box;
|
|
1053
1080
|
Loader2.text = LoaderComponent.text;
|
|
1054
1081
|
var Loader_default = Loader2;
|
|
1055
1082
|
|
|
1056
|
-
// src/components/
|
|
1083
|
+
// src/components/Image.tsx
|
|
1084
|
+
var import_react8 = require("react");
|
|
1085
|
+
var import_react_better_core7 = require("react-better-core");
|
|
1086
|
+
var import_react_native6 = require("react-native");
|
|
1057
1087
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1088
|
+
var ImageComponent = function Image({ name, source, withDevFittingMode, ...props }) {
|
|
1089
|
+
const { assets: assets2 } = (0, import_react_better_core7.useBetterCoreContext)();
|
|
1090
|
+
const style = (0, import_react8.useMemo)(
|
|
1091
|
+
() => ({
|
|
1092
|
+
width: 100,
|
|
1093
|
+
height: 100,
|
|
1094
|
+
...withDevFittingMode ? {
|
|
1095
|
+
borderWidth: 1,
|
|
1096
|
+
borderColor: "#eb39f7"
|
|
1097
|
+
} : {},
|
|
1098
|
+
...props
|
|
1099
|
+
}),
|
|
1100
|
+
[withDevFittingMode, props]
|
|
1101
|
+
);
|
|
1102
|
+
(0, import_react8.useEffect)(() => {
|
|
1103
|
+
if (!name) return;
|
|
1104
|
+
if (!assets2[name.toString()])
|
|
1105
|
+
console.warn(
|
|
1106
|
+
`The asset \`${name}\` you are trying to use does not exist. Make sure to add it to the \`assets\` object in \`<BetterComponentsProvider>\` config value prop.`
|
|
1107
|
+
);
|
|
1108
|
+
}, [assets2, name]);
|
|
1109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.Image, { source: name ? assets2[name.toString()] : source, style, ...props });
|
|
1110
|
+
};
|
|
1111
|
+
ImageComponent.profileImage = function ProfileImage({
|
|
1112
|
+
size = 50,
|
|
1113
|
+
letters,
|
|
1114
|
+
color,
|
|
1115
|
+
backgroundColor,
|
|
1116
|
+
...props
|
|
1117
|
+
}) {
|
|
1118
|
+
const theme2 = (0, import_react_better_core7.useTheme)();
|
|
1119
|
+
return letters ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1120
|
+
View_default,
|
|
1121
|
+
{
|
|
1122
|
+
width: size,
|
|
1123
|
+
height: size,
|
|
1124
|
+
backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
|
|
1125
|
+
borderWidth: 1,
|
|
1126
|
+
borderColor: theme2.colors.border,
|
|
1127
|
+
borderRadius: 999,
|
|
1128
|
+
alignItems: "center",
|
|
1129
|
+
justifyContent: "center",
|
|
1130
|
+
...props,
|
|
1131
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text_default, { fontSize: size / 2.5, fontWeight: 700, color: color ?? theme2.colors.textPrimary, marginTop: 1, children: letters.toUpperCase().slice(0, 2) })
|
|
1132
|
+
}
|
|
1133
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1134
|
+
ImageComponent,
|
|
1135
|
+
{
|
|
1136
|
+
width: size,
|
|
1137
|
+
height: size,
|
|
1138
|
+
borderWidth: 1,
|
|
1139
|
+
borderColor: theme2.colors.border,
|
|
1140
|
+
borderRadius: 999,
|
|
1141
|
+
objectFit: "cover",
|
|
1142
|
+
...props
|
|
1143
|
+
}
|
|
1144
|
+
);
|
|
1145
|
+
};
|
|
1146
|
+
var Image2 = (0, import_react8.memo)(ImageComponent);
|
|
1147
|
+
Image2.profileImage = ImageComponent.profileImage;
|
|
1148
|
+
var Image_default = Image2;
|
|
1149
|
+
|
|
1150
|
+
// src/components/Button.tsx
|
|
1151
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1058
1152
|
var ButtonComponent = function Button({
|
|
1153
|
+
value,
|
|
1059
1154
|
text,
|
|
1060
1155
|
textFontSize = 16,
|
|
1061
1156
|
textFontWeight = 700,
|
|
1062
1157
|
textDecorationLine,
|
|
1063
1158
|
textColor,
|
|
1064
1159
|
icon,
|
|
1160
|
+
iconIOS,
|
|
1065
1161
|
iconPosition = "left",
|
|
1066
1162
|
iconColor,
|
|
1067
1163
|
iconSize,
|
|
@@ -1076,10 +1172,12 @@ var ButtonComponent = function Button({
|
|
|
1076
1172
|
flex,
|
|
1077
1173
|
alignSelf,
|
|
1078
1174
|
disabled,
|
|
1175
|
+
onPress,
|
|
1176
|
+
onPressWithValue,
|
|
1079
1177
|
...props
|
|
1080
1178
|
}) {
|
|
1081
|
-
const theme2 = (0,
|
|
1082
|
-
const isLoadingLoader = (0,
|
|
1179
|
+
const theme2 = (0, import_react_better_core8.useTheme)();
|
|
1180
|
+
const isLoadingLoader = (0, import_react_better_core8.useLoader)(loaderName);
|
|
1083
1181
|
const isLoadingElement = isLoading || isLoadingLoader;
|
|
1084
1182
|
const isDisabled = disabled || isLoadingElement;
|
|
1085
1183
|
const lineHeight = 20;
|
|
@@ -1087,7 +1185,24 @@ var ButtonComponent = function Button({
|
|
|
1087
1185
|
const paddingVertical = props.paddingVertical ? parseFloat(props.paddingVertical.toString()) : theme2.styles.space;
|
|
1088
1186
|
const paddingHorizontal = props.paddingHorizontal ? parseFloat(props.paddingHorizontal.toString()) : theme2.styles.space + theme2.styles.gap;
|
|
1089
1187
|
const buttonHeight = paddingVertical + lineHeight + paddingVertical;
|
|
1090
|
-
|
|
1188
|
+
const onPressElement = (0, import_react9.useCallback)(
|
|
1189
|
+
(event) => {
|
|
1190
|
+
onPress?.(event);
|
|
1191
|
+
onPressWithValue?.(value);
|
|
1192
|
+
},
|
|
1193
|
+
[onPress, onPressWithValue, value]
|
|
1194
|
+
);
|
|
1195
|
+
const iconComponent = icon ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(View_default, { height: 20, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1196
|
+
Icon_default,
|
|
1197
|
+
{
|
|
1198
|
+
name: icon,
|
|
1199
|
+
nameIOS: iconIOS,
|
|
1200
|
+
color: iconColor ?? textColor ?? theme2.colors.base,
|
|
1201
|
+
size: iconSize ?? textFontSize ?? 16
|
|
1202
|
+
}
|
|
1203
|
+
) }) : void 0;
|
|
1204
|
+
const imageComponent = image ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Image_default, { name: image, width: imageWidth ?? textFontSize ?? 16, height: imageHeight }) : void 0;
|
|
1205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1091
1206
|
Animate_default.View,
|
|
1092
1207
|
{
|
|
1093
1208
|
position: "relative",
|
|
@@ -1095,12 +1210,12 @@ var ButtonComponent = function Button({
|
|
|
1095
1210
|
alignSelf: alignSelf ?? (isSmall === "left" ? "flex-start" : isSmall === "right" ? "flex-end" : isSmall === "center" ? "center" : isSmall ? "baseline" : void 0),
|
|
1096
1211
|
initialOpacity: 1,
|
|
1097
1212
|
animateOpacity: animateOpacity ?? (disabled ? 0.6 : 1),
|
|
1098
|
-
children: /* @__PURE__ */ (0,
|
|
1213
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1099
1214
|
View_default,
|
|
1100
1215
|
{
|
|
1101
1216
|
position: "relative",
|
|
1102
1217
|
width: !isSmall ? "100%" : void 0,
|
|
1103
|
-
height:
|
|
1218
|
+
height: import_react_native7.Platform.OS === "android" ? buttonHeight : void 0,
|
|
1104
1219
|
alignItems: "center",
|
|
1105
1220
|
justifyContent: "center",
|
|
1106
1221
|
backgroundColor: theme2.colors.primary,
|
|
@@ -1108,22 +1223,29 @@ var ButtonComponent = function Button({
|
|
|
1108
1223
|
paddingVertical,
|
|
1109
1224
|
paddingHorizontal,
|
|
1110
1225
|
disabled: isDisabled,
|
|
1226
|
+
onPress: onPressElement,
|
|
1111
1227
|
...props,
|
|
1112
1228
|
children: [
|
|
1113
|
-
/* @__PURE__ */ (0,
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1229
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Animate_default.View, { initialOpacity: 1, animateOpacity: isLoadingElement ? 0 : 1, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(View_default, { isRow: true, alignItems: "center", justifyContent: "center", gap: theme2.styles.gap, children: [
|
|
1230
|
+
iconPosition === "left" && iconComponent,
|
|
1231
|
+
imagePosition === "left" && imageComponent,
|
|
1232
|
+
text && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1233
|
+
Text_default,
|
|
1234
|
+
{
|
|
1235
|
+
fontSize: textFontSize,
|
|
1236
|
+
fontWeight: textFontWeight,
|
|
1237
|
+
textDecorationLine,
|
|
1238
|
+
textDecorationColor: color,
|
|
1239
|
+
textAlign: "center",
|
|
1240
|
+
lineHeight,
|
|
1241
|
+
color,
|
|
1242
|
+
children: text
|
|
1243
|
+
}
|
|
1244
|
+
),
|
|
1245
|
+
iconPosition === "right" && iconComponent,
|
|
1246
|
+
imagePosition === "right" && imageComponent
|
|
1247
|
+
] }) }),
|
|
1248
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1127
1249
|
Animate_default.View,
|
|
1128
1250
|
{
|
|
1129
1251
|
position: "absolute",
|
|
@@ -1134,7 +1256,7 @@ var ButtonComponent = function Button({
|
|
|
1134
1256
|
justifyContent: "center",
|
|
1135
1257
|
initialOpacity: 0,
|
|
1136
1258
|
animateOpacity: isLoadingElement ? 1 : 0,
|
|
1137
|
-
children: /* @__PURE__ */ (0,
|
|
1259
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Loader_default, { color })
|
|
1138
1260
|
}
|
|
1139
1261
|
)
|
|
1140
1262
|
]
|
|
@@ -1142,54 +1264,361 @@ var ButtonComponent = function Button({
|
|
|
1142
1264
|
)
|
|
1143
1265
|
}
|
|
1144
1266
|
);
|
|
1145
|
-
};
|
|
1146
|
-
ButtonComponent.secondary = function Secondary(props) {
|
|
1147
|
-
const theme2 = (0,
|
|
1148
|
-
return /* @__PURE__ */ (0,
|
|
1149
|
-
ButtonComponent,
|
|
1150
|
-
{
|
|
1151
|
-
backgroundColor: theme2.colors.backgroundContent,
|
|
1152
|
-
borderWidth: 1,
|
|
1153
|
-
borderColor: theme2.colors.border,
|
|
1154
|
-
textColor: theme2.colors.textPrimary,
|
|
1155
|
-
pressStrength: pressStrength().p05,
|
|
1156
|
-
animateOpacity: props.disabled ? 0.4 : 1,
|
|
1157
|
-
...props
|
|
1158
|
-
}
|
|
1267
|
+
};
|
|
1268
|
+
ButtonComponent.secondary = function Secondary(props) {
|
|
1269
|
+
const theme2 = (0, import_react_better_core8.useTheme)();
|
|
1270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1271
|
+
ButtonComponent,
|
|
1272
|
+
{
|
|
1273
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
1274
|
+
borderWidth: 1,
|
|
1275
|
+
borderColor: theme2.colors.border,
|
|
1276
|
+
textColor: theme2.colors.textPrimary,
|
|
1277
|
+
pressStrength: pressStrength().p05,
|
|
1278
|
+
animateOpacity: props.disabled ? 0.4 : 1,
|
|
1279
|
+
...props
|
|
1280
|
+
}
|
|
1281
|
+
);
|
|
1282
|
+
};
|
|
1283
|
+
ButtonComponent.destructive = function Destructive(props) {
|
|
1284
|
+
const theme2 = (0, import_react_better_core8.useTheme)();
|
|
1285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ButtonComponent, { backgroundColor: theme2.colors.error, ...props });
|
|
1286
|
+
};
|
|
1287
|
+
ButtonComponent.text = function ButtonText(props) {
|
|
1288
|
+
const theme2 = (0, import_react_better_core8.useTheme)();
|
|
1289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1290
|
+
ButtonComponent,
|
|
1291
|
+
{
|
|
1292
|
+
width: "auto",
|
|
1293
|
+
textFontWeight: 400,
|
|
1294
|
+
textColor: theme2.colors.textPrimary,
|
|
1295
|
+
textDecorationLine: "underline",
|
|
1296
|
+
backgroundColor: "transparent",
|
|
1297
|
+
paddingHorizontal: theme2.styles.space,
|
|
1298
|
+
paddingVertical: theme2.styles.gap,
|
|
1299
|
+
isSmall: true,
|
|
1300
|
+
pressType: "opacity",
|
|
1301
|
+
...props
|
|
1302
|
+
}
|
|
1303
|
+
);
|
|
1304
|
+
};
|
|
1305
|
+
ButtonComponent.icon = function ButtonIcon({ size = 16, ...props }) {
|
|
1306
|
+
const theme2 = (0, import_react_better_core8.useTheme)();
|
|
1307
|
+
const buttonSize = size + theme2.styles.space;
|
|
1308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1309
|
+
ButtonComponent,
|
|
1310
|
+
{
|
|
1311
|
+
width: buttonSize,
|
|
1312
|
+
height: buttonSize,
|
|
1313
|
+
textColor: theme2.colors.textPrimary,
|
|
1314
|
+
backgroundColor: "transparent",
|
|
1315
|
+
hitSlop: theme2.styles.gap / 2,
|
|
1316
|
+
borderRadius: 999,
|
|
1317
|
+
iconSize: size,
|
|
1318
|
+
paddingVertical: 0,
|
|
1319
|
+
paddingHorizontal: 0,
|
|
1320
|
+
pressType: "opacity",
|
|
1321
|
+
...props
|
|
1322
|
+
}
|
|
1323
|
+
);
|
|
1324
|
+
};
|
|
1325
|
+
var Button2 = (0, import_react9.memo)(ButtonComponent);
|
|
1326
|
+
Button2.secondary = ButtonComponent.secondary;
|
|
1327
|
+
Button2.destructive = ButtonComponent.destructive;
|
|
1328
|
+
Button2.text = ButtonComponent.text;
|
|
1329
|
+
Button2.icon = ButtonComponent.icon;
|
|
1330
|
+
var Button_default = Button2;
|
|
1331
|
+
|
|
1332
|
+
// src/components/alerts/Alert.tsx
|
|
1333
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1334
|
+
var getAlertDurationFromAuto = (duration, alert) => {
|
|
1335
|
+
if (duration === "auto") {
|
|
1336
|
+
const titleLength = alert.title?.length ?? 0;
|
|
1337
|
+
const messageLength = alert.message?.length ?? 0;
|
|
1338
|
+
return Math.max(defaultAlertDuration, (titleLength + messageLength) * 30);
|
|
1339
|
+
}
|
|
1340
|
+
return duration;
|
|
1341
|
+
};
|
|
1342
|
+
function Alert({ alert }) {
|
|
1343
|
+
const theme2 = (0, import_react_better_core9.useTheme)();
|
|
1344
|
+
const alertControls2 = useAlertControls();
|
|
1345
|
+
const alertsPlugin2 = usePlugin("alerts");
|
|
1346
|
+
const pluginConfig = alertsPlugin2?.getConfig() ?? {};
|
|
1347
|
+
const defaultAlertDurationNumber = getAlertDurationFromAuto(
|
|
1348
|
+
alert.duration ?? pluginConfig.defaultDuration ?? defaultAlertsPluginOptions.defaultDuration,
|
|
1349
|
+
alert
|
|
1350
|
+
);
|
|
1351
|
+
const defaultAlertDisplay = alert.display ?? pluginConfig.defaultDisplay?.[alert.type] ?? defaultAlertsPluginOptions.defaultDisplay[alert.type] ?? "default";
|
|
1352
|
+
const calledOnCloseRef = (0, import_react10.useRef)(false);
|
|
1353
|
+
const [isRemoved, setIsRemoved] = (0, import_react_better_core9.useBooleanState)();
|
|
1354
|
+
const onPressCloseAlert = (0, import_react10.useCallback)(() => {
|
|
1355
|
+
setIsRemoved.setTrue();
|
|
1356
|
+
setTimeout(() => {
|
|
1357
|
+
alertControls2.removeAlert(alert.id);
|
|
1358
|
+
if (!calledOnCloseRef.current) {
|
|
1359
|
+
alert.onClose?.(alert);
|
|
1360
|
+
calledOnCloseRef.current = true;
|
|
1361
|
+
}
|
|
1362
|
+
}, defaultTransitionDuration);
|
|
1363
|
+
}, [alert]);
|
|
1364
|
+
const alertData = (0, import_react10.useMemo)(
|
|
1365
|
+
() => ({
|
|
1366
|
+
info: {
|
|
1367
|
+
icon: "infoI",
|
|
1368
|
+
iconIOS: "info",
|
|
1369
|
+
backgroundColor: theme2.colors.info,
|
|
1370
|
+
title: "Info"
|
|
1371
|
+
},
|
|
1372
|
+
success: {
|
|
1373
|
+
icon: "check",
|
|
1374
|
+
backgroundColor: theme2.colors.success,
|
|
1375
|
+
title: "Success"
|
|
1376
|
+
},
|
|
1377
|
+
warning: {
|
|
1378
|
+
icon: "warningTriangle",
|
|
1379
|
+
backgroundColor: theme2.colors.warn,
|
|
1380
|
+
title: "Warning"
|
|
1381
|
+
},
|
|
1382
|
+
error: {
|
|
1383
|
+
icon: "XMark",
|
|
1384
|
+
backgroundColor: theme2.colors.error,
|
|
1385
|
+
title: "Error"
|
|
1386
|
+
}
|
|
1387
|
+
}),
|
|
1388
|
+
[theme2]
|
|
1389
|
+
);
|
|
1390
|
+
(0, import_react10.useEffect)(() => {
|
|
1391
|
+
const timeout = setTimeout(onPressCloseAlert, defaultAlertDurationNumber);
|
|
1392
|
+
return () => {
|
|
1393
|
+
clearTimeout(timeout);
|
|
1394
|
+
};
|
|
1395
|
+
}, [onPressCloseAlert, defaultAlertDurationNumber]);
|
|
1396
|
+
return defaultAlertDisplay === "prominent" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1397
|
+
Animate_default.View,
|
|
1398
|
+
{
|
|
1399
|
+
initialOpacity: 0,
|
|
1400
|
+
animateOpacity: isRemoved ? 0 : 1,
|
|
1401
|
+
initialX: 40,
|
|
1402
|
+
animateX: isRemoved ? 40 : 0,
|
|
1403
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(View_default.box, { width: "auto", withShadow: true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.space, children: [
|
|
1404
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1405
|
+
View_default,
|
|
1406
|
+
{
|
|
1407
|
+
alignItems: "center",
|
|
1408
|
+
justifyContent: "center",
|
|
1409
|
+
backgroundColor: alertData[alert.type].backgroundColor,
|
|
1410
|
+
borderRadius: 999,
|
|
1411
|
+
padding: (theme2.styles.space + theme2.styles.gap) / 2,
|
|
1412
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1413
|
+
Icon_default,
|
|
1414
|
+
{
|
|
1415
|
+
name: alertData[alert.type].icon,
|
|
1416
|
+
color: alertData[alert.type].iconColor ?? theme2.colors.base
|
|
1417
|
+
}
|
|
1418
|
+
)
|
|
1419
|
+
}
|
|
1420
|
+
),
|
|
1421
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(View_default, { children: [
|
|
1422
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { fontSize: 18, fontWeight: 700, children: alert.title ?? alertData[alert.type].title }),
|
|
1423
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default.body, { children: alert.message })
|
|
1424
|
+
] }),
|
|
1425
|
+
pluginConfig.withCloseButton && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Button_default.icon, { icon: "XMark", onPress: onPressCloseAlert })
|
|
1426
|
+
] }) })
|
|
1427
|
+
}
|
|
1428
|
+
);
|
|
1429
|
+
}
|
|
1430
|
+
var Alert_default = (0, import_react10.memo)(Alert);
|
|
1431
|
+
|
|
1432
|
+
// src/components/alerts/AlertsHolder.tsx
|
|
1433
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1434
|
+
function AlertsHolder() {
|
|
1435
|
+
const theme2 = (0, import_react_better_core10.useTheme)();
|
|
1436
|
+
const device = useDevice();
|
|
1437
|
+
const alertsPlugin2 = usePlugin("alerts");
|
|
1438
|
+
const { alerts } = useBetterComponentsContextInternal();
|
|
1439
|
+
const pluginConfig = alertsPlugin2?.getConfig() ?? {};
|
|
1440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1441
|
+
View_default,
|
|
1442
|
+
{
|
|
1443
|
+
position: "absolute",
|
|
1444
|
+
width: "100%",
|
|
1445
|
+
top: device.safeArea.afterCalculations.top + theme2.styles.gap / 2,
|
|
1446
|
+
left: 0,
|
|
1447
|
+
gap: theme2.styles.gap,
|
|
1448
|
+
alignItems: pluginConfig.align === "left" ? "flex-start" : pluginConfig.align === "center" ? "center" : pluginConfig.align === "right" ? "flex-end" : void 0,
|
|
1449
|
+
paddingHorizontal: theme2.styles.space,
|
|
1450
|
+
pointerEvents: "box-none",
|
|
1451
|
+
zIndex: 1e3,
|
|
1452
|
+
children: alerts.map((alert) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Alert_default, { alert }, alert.id))
|
|
1453
|
+
}
|
|
1454
|
+
);
|
|
1455
|
+
}
|
|
1456
|
+
var AlertsHolder_default = (0, import_react11.memo)(AlertsHolder);
|
|
1457
|
+
|
|
1458
|
+
// src/components/BetterComponentsProvider.tsx
|
|
1459
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1460
|
+
var betterComponentsContext = (0, import_react12.createContext)(void 0);
|
|
1461
|
+
var externalBetterCoreContextValue;
|
|
1462
|
+
var externalBetterComponentsContextValue;
|
|
1463
|
+
var useBetterComponentsContext = () => {
|
|
1464
|
+
const coreContext = (0, import_react_better_core11.useBetterCoreContext)();
|
|
1465
|
+
const context = (0, import_react12.useContext)(betterComponentsContext);
|
|
1466
|
+
if (context === void 0)
|
|
1467
|
+
throw new Error(
|
|
1468
|
+
"`useBetterComponentsContext()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1469
|
+
);
|
|
1470
|
+
const { plugins, componentsState, ...rest } = context;
|
|
1471
|
+
return {
|
|
1472
|
+
...coreContext,
|
|
1473
|
+
...rest
|
|
1474
|
+
};
|
|
1475
|
+
};
|
|
1476
|
+
var useBetterComponentsContextInternal = () => {
|
|
1477
|
+
const context = (0, import_react12.useContext)(betterComponentsContext);
|
|
1478
|
+
if (context === void 0)
|
|
1479
|
+
throw new Error(
|
|
1480
|
+
"`useBetterComponentsContextInternal()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1481
|
+
);
|
|
1482
|
+
return context;
|
|
1483
|
+
};
|
|
1484
|
+
var useAlertControls = () => {
|
|
1485
|
+
const context = (0, import_react12.useContext)(betterComponentsContext);
|
|
1486
|
+
if (context === void 0)
|
|
1487
|
+
throw new Error(
|
|
1488
|
+
"`useAlertControls()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1489
|
+
);
|
|
1490
|
+
const createAlert = (0, import_react12.useCallback)((alert) => {
|
|
1491
|
+
const readyAlert = {
|
|
1492
|
+
id: (0, import_react_better_core11.generateRandomString)(36),
|
|
1493
|
+
...alert
|
|
1494
|
+
};
|
|
1495
|
+
context.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
1496
|
+
return readyAlert;
|
|
1497
|
+
}, []);
|
|
1498
|
+
const removeAlert = (0, import_react12.useCallback)((alertId) => {
|
|
1499
|
+
context.setAlerts((oldValue) => oldValue.filter((alert) => alert.id !== alertId));
|
|
1500
|
+
}, []);
|
|
1501
|
+
return {
|
|
1502
|
+
createAlert,
|
|
1503
|
+
removeAlert
|
|
1504
|
+
};
|
|
1505
|
+
};
|
|
1506
|
+
var usePlugin = (pluginName) => {
|
|
1507
|
+
const context = (0, import_react12.useContext)(betterComponentsContext);
|
|
1508
|
+
if (context === void 0) {
|
|
1509
|
+
throw new Error(
|
|
1510
|
+
"`usePlugin()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1513
|
+
return (0, import_react12.useMemo)(
|
|
1514
|
+
() => context.plugins.find((plugin) => plugin.name === pluginName),
|
|
1515
|
+
[context.plugins, pluginName]
|
|
1516
|
+
);
|
|
1517
|
+
};
|
|
1518
|
+
function BetterComponentsProviderInternalContent({ children }) {
|
|
1519
|
+
const alertsPlugin2 = usePlugin("alerts");
|
|
1520
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
1521
|
+
children,
|
|
1522
|
+
alertsPlugin2 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AlertsHolder_default, {})
|
|
1523
|
+
] });
|
|
1524
|
+
}
|
|
1525
|
+
function BetterComponentsProviderInternal({
|
|
1526
|
+
config,
|
|
1527
|
+
plugins,
|
|
1528
|
+
children
|
|
1529
|
+
}) {
|
|
1530
|
+
const betterCoreContext = (0, import_react_better_core11.useBetterCoreContext)();
|
|
1531
|
+
const [alerts, setAlerts] = (0, import_react12.useState)([]);
|
|
1532
|
+
const readyConfig = (0, import_react12.useMemo)(
|
|
1533
|
+
() => ({
|
|
1534
|
+
app: {
|
|
1535
|
+
...appConfig,
|
|
1536
|
+
...config?.app
|
|
1537
|
+
},
|
|
1538
|
+
alerts,
|
|
1539
|
+
setAlerts,
|
|
1540
|
+
plugins: plugins ?? [],
|
|
1541
|
+
componentsState: {}
|
|
1542
|
+
}),
|
|
1543
|
+
[config, alerts, plugins]
|
|
1544
|
+
);
|
|
1545
|
+
(0, import_react12.useEffect)(() => {
|
|
1546
|
+
if (!plugins) return;
|
|
1547
|
+
plugins.forEach((plugin) => {
|
|
1548
|
+
plugin.initialize?.();
|
|
1549
|
+
});
|
|
1550
|
+
}, []);
|
|
1551
|
+
externalBetterCoreContextValue = betterCoreContext;
|
|
1552
|
+
externalBetterComponentsContextValue = readyConfig;
|
|
1553
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(betterComponentsContext.Provider, { value: readyConfig, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(BetterComponentsProviderInternalContent, { children }) });
|
|
1554
|
+
}
|
|
1555
|
+
function BetterComponentsProvider({ config, ...props }) {
|
|
1556
|
+
const coreConfig = (0, import_react12.useMemo)(
|
|
1557
|
+
() => ({
|
|
1558
|
+
theme: {
|
|
1559
|
+
...theme,
|
|
1560
|
+
...config?.theme
|
|
1561
|
+
},
|
|
1562
|
+
// colorTheme: config?.colorTheme ?? (localStorage.getItem("theme") === "dark" ? "dark" : "light"),
|
|
1563
|
+
colorTheme: config?.colorTheme ?? "light",
|
|
1564
|
+
icons: {
|
|
1565
|
+
...icons,
|
|
1566
|
+
...config?.icons
|
|
1567
|
+
},
|
|
1568
|
+
assets: {
|
|
1569
|
+
...assets,
|
|
1570
|
+
...config?.assets
|
|
1571
|
+
},
|
|
1572
|
+
loaders: config?.loaders
|
|
1573
|
+
}),
|
|
1574
|
+
[config]
|
|
1575
|
+
);
|
|
1576
|
+
const componentsConfig = (0, import_react12.useMemo)(
|
|
1577
|
+
() => ({
|
|
1578
|
+
app: config?.app
|
|
1579
|
+
}),
|
|
1580
|
+
[config]
|
|
1159
1581
|
);
|
|
1582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_better_core11.BetterCoreProvider, { config: coreConfig, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(BetterComponentsProviderInternal, { config: componentsConfig, ...props }) });
|
|
1583
|
+
}
|
|
1584
|
+
var BetterComponentsProvider_default = (0, import_react12.memo)(BetterComponentsProvider);
|
|
1585
|
+
|
|
1586
|
+
// src/utils/functions.ts
|
|
1587
|
+
var getFormErrorObject = (formValues) => {
|
|
1588
|
+
return {};
|
|
1160
1589
|
};
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1590
|
+
|
|
1591
|
+
// src/utils/asyncStorage.ts
|
|
1592
|
+
var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
|
|
1593
|
+
function generateAsyncStorage() {
|
|
1594
|
+
return {
|
|
1595
|
+
setItem: async (name, value) => {
|
|
1596
|
+
if (value) await import_async_storage.default.setItem(name.toString(), JSON.stringify(value));
|
|
1597
|
+
else await import_async_storage.default.removeItem(name.toString());
|
|
1598
|
+
},
|
|
1599
|
+
getItem: async (name) => {
|
|
1600
|
+
const item = await import_async_storage.default.getItem(name.toString());
|
|
1601
|
+
if (item === null) return void 0;
|
|
1602
|
+
try {
|
|
1603
|
+
return JSON.parse(item);
|
|
1604
|
+
} catch (error) {
|
|
1605
|
+
return void 0;
|
|
1606
|
+
}
|
|
1607
|
+
},
|
|
1608
|
+
removeItem: async (name) => {
|
|
1609
|
+
await import_async_storage.default.removeItem(name.toString());
|
|
1610
|
+
},
|
|
1611
|
+
removeAllItems: () => {
|
|
1612
|
+
import_async_storage.default.clear();
|
|
1179
1613
|
}
|
|
1180
|
-
|
|
1181
|
-
}
|
|
1182
|
-
var Button2 = (0, import_react7.memo)(ButtonComponent);
|
|
1183
|
-
Button2.secondary = ButtonComponent.secondary;
|
|
1184
|
-
Button2.destructive = ButtonComponent.destructive;
|
|
1185
|
-
Button2.text = ButtonComponent.text;
|
|
1186
|
-
var Button_default = Button2;
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1187
1616
|
|
|
1188
1617
|
// src/components/ScreenHolder.tsx
|
|
1189
|
-
var
|
|
1190
|
-
var
|
|
1191
|
-
var
|
|
1192
|
-
var
|
|
1618
|
+
var import_react13 = require("react");
|
|
1619
|
+
var import_react_native8 = require("react-native");
|
|
1620
|
+
var import_react_better_core12 = require("react-better-core");
|
|
1621
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1193
1622
|
var ScreenHolderComponent = ({
|
|
1194
1623
|
noScroll,
|
|
1195
1624
|
noSideSpace,
|
|
@@ -1206,17 +1635,17 @@ var ScreenHolderComponent = ({
|
|
|
1206
1635
|
withNoHeader,
|
|
1207
1636
|
children
|
|
1208
1637
|
}) => {
|
|
1209
|
-
const theme2 = (0,
|
|
1638
|
+
const theme2 = (0, import_react_better_core12.useTheme)();
|
|
1210
1639
|
const device = useDevice();
|
|
1211
1640
|
const keyboard = useKeyboard();
|
|
1212
|
-
const [isRefreshing, setIsRefreshing] = (0,
|
|
1213
|
-
const keyboardAvoidingViewStyle = (0,
|
|
1641
|
+
const [isRefreshing, setIsRefreshing] = (0, import_react_better_core12.useBooleanState)();
|
|
1642
|
+
const keyboardAvoidingViewStyle = (0, import_react13.useMemo)(
|
|
1214
1643
|
() => ({
|
|
1215
1644
|
flex: 1
|
|
1216
1645
|
}),
|
|
1217
1646
|
[]
|
|
1218
1647
|
);
|
|
1219
|
-
const onRefreshElement = (0,
|
|
1648
|
+
const onRefreshElement = (0, import_react13.useCallback)(() => {
|
|
1220
1649
|
setIsRefreshing.setTrue();
|
|
1221
1650
|
onRefresh?.();
|
|
1222
1651
|
setTimeout(() => {
|
|
@@ -1224,36 +1653,36 @@ var ScreenHolderComponent = ({
|
|
|
1224
1653
|
onRefreshEnd?.();
|
|
1225
1654
|
}, refreshTimeout * 1e3);
|
|
1226
1655
|
}, [onRefresh, onRefreshEnd, refreshTimeout]);
|
|
1227
|
-
const content = /* @__PURE__ */ (0,
|
|
1656
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1228
1657
|
View_default,
|
|
1229
1658
|
{
|
|
1230
1659
|
flex: 1,
|
|
1231
1660
|
paddingHorizontal: !noSideSpace ? theme2.styles.space : void 0,
|
|
1232
1661
|
paddingTop: theme2.styles.gap + (insideTopSafeArea ? device.safeArea.afterCalculations.top : 0),
|
|
1233
|
-
paddingBottom:
|
|
1662
|
+
paddingBottom: import_react_native8.Platform.OS === "ios" && keyboard.isOpened ? device.safeArea.afterCalculations.top : bottomSpace + (insideBottomSafeArea ? device.safeArea.afterCalculations.bottom : 0),
|
|
1234
1663
|
children
|
|
1235
1664
|
}
|
|
1236
1665
|
);
|
|
1237
1666
|
const withRefresh = onRefresh || onRefreshEnd;
|
|
1238
|
-
return /* @__PURE__ */ (0,
|
|
1239
|
-
|
|
1667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(View_default, { flex: 1, backgroundColor: backgroundColor ?? theme2.colors.backgroundBase, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1668
|
+
import_react_native8.KeyboardAvoidingView,
|
|
1240
1669
|
{
|
|
1241
1670
|
style: keyboardAvoidingViewStyle,
|
|
1242
|
-
keyboardVerticalOffset: keyboardVerticalOffset ?? (withNoHeader ?
|
|
1243
|
-
behavior:
|
|
1671
|
+
keyboardVerticalOffset: keyboardVerticalOffset ?? (withNoHeader ? import_react_native8.Platform.OS === "ios" ? 0 : theme2.styles.gap : keepFooterOnKeyboardOpened ? import_react_native8.Platform.OS === "ios" ? device.safeArea.afterCalculations.bottom : theme2.styles.gap : void 0),
|
|
1672
|
+
behavior: import_react_native8.Platform.OS === "ios" ? "padding" : "height",
|
|
1244
1673
|
children: [
|
|
1245
|
-
/* @__PURE__ */ (0,
|
|
1246
|
-
|
|
1674
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(View_default, { flex: 1, children: noScroll ? content : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1675
|
+
import_react_native8.ScrollView,
|
|
1247
1676
|
{
|
|
1248
|
-
refreshControl: withRefresh ? /* @__PURE__ */ (0,
|
|
1677
|
+
refreshControl: withRefresh ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native8.RefreshControl, { refreshing: isRefreshing, onRefresh: onRefreshElement }) : void 0,
|
|
1249
1678
|
children: content
|
|
1250
1679
|
}
|
|
1251
1680
|
) }),
|
|
1252
|
-
keepFooterOnKeyboardOpened || (
|
|
1681
|
+
keepFooterOnKeyboardOpened || (import_react_native8.Platform.OS === "ios" ? !keyboard.willOpen : !keyboard.isOpened) ? footer && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(View_default, { children: footer }) : !withNoHeader && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1253
1682
|
View_default,
|
|
1254
1683
|
{
|
|
1255
1684
|
width: "100%",
|
|
1256
|
-
height: device.safeArea.afterCalculations.bottom + (
|
|
1685
|
+
height: device.safeArea.afterCalculations.bottom + (import_react_native8.Platform.OS === "android" ? theme2.styles.gap : 0)
|
|
1257
1686
|
}
|
|
1258
1687
|
)
|
|
1259
1688
|
]
|
|
@@ -1267,149 +1696,31 @@ ScreenHolderComponent.footer = function Footer({
|
|
|
1267
1696
|
withNoHeader,
|
|
1268
1697
|
children
|
|
1269
1698
|
}) {
|
|
1270
|
-
const theme2 = (0,
|
|
1699
|
+
const theme2 = (0, import_react_better_core12.useTheme)();
|
|
1271
1700
|
const device = useDevice();
|
|
1272
1701
|
const keyboard = useKeyboard();
|
|
1273
|
-
return /* @__PURE__ */ (0,
|
|
1702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1274
1703
|
View_default,
|
|
1275
1704
|
{
|
|
1276
1705
|
backgroundColor: backgroundColor ?? theme2.colors.backgroundBase,
|
|
1277
1706
|
paddingHorizontal: !noSideSpace ? theme2.styles.space : void 0,
|
|
1278
1707
|
paddingTop: theme2.styles.gap,
|
|
1279
|
-
paddingBottom: (
|
|
1708
|
+
paddingBottom: (import_react_native8.Platform.OS === "ios" ? keyboard.willOpen : keyboard.isOpened) && withNoHeader ? theme2.styles.gap : insideBottomSafeArea ? device.safeArea.afterCalculations.bottom : void 0,
|
|
1280
1709
|
children
|
|
1281
1710
|
}
|
|
1282
1711
|
);
|
|
1283
1712
|
};
|
|
1284
|
-
var ScreenHolder = (0,
|
|
1713
|
+
var ScreenHolder = (0, import_react13.memo)(ScreenHolderComponent);
|
|
1285
1714
|
ScreenHolder.footer = ScreenHolderComponent.footer;
|
|
1286
1715
|
var ScreenHolder_default = ScreenHolder;
|
|
1287
1716
|
|
|
1288
|
-
// src/components/Image.tsx
|
|
1289
|
-
var import_react9 = require("react");
|
|
1290
|
-
var import_react_better_core8 = require("react-better-core");
|
|
1291
|
-
var import_react_native7 = require("react-native");
|
|
1292
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1293
|
-
var ImageComponent = function Image({ name, source, withDevFittingMode, ...props }) {
|
|
1294
|
-
const { assets: assets2 } = (0, import_react_better_core8.useBetterCoreContext)();
|
|
1295
|
-
const style = (0, import_react9.useMemo)(
|
|
1296
|
-
() => ({
|
|
1297
|
-
width: 100,
|
|
1298
|
-
height: 100,
|
|
1299
|
-
...withDevFittingMode ? {
|
|
1300
|
-
borderWidth: 1,
|
|
1301
|
-
borderColor: "#eb39f7"
|
|
1302
|
-
} : {},
|
|
1303
|
-
...props
|
|
1304
|
-
}),
|
|
1305
|
-
[withDevFittingMode, props]
|
|
1306
|
-
);
|
|
1307
|
-
(0, import_react9.useEffect)(() => {
|
|
1308
|
-
if (!name) return;
|
|
1309
|
-
if (!assets2[name.toString()])
|
|
1310
|
-
console.warn(
|
|
1311
|
-
`The asset \`${name}\` you are trying to use does not exist. Make sure to add it to the \`assets\` object in \`<BetterComponentsProvider>\` config value prop.`
|
|
1312
|
-
);
|
|
1313
|
-
}, [assets2, name]);
|
|
1314
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native7.Image, { source: name ? assets2[name.toString()] : source, style, ...props });
|
|
1315
|
-
};
|
|
1316
|
-
ImageComponent.profileImage = function ProfileImage({
|
|
1317
|
-
size = 50,
|
|
1318
|
-
letters,
|
|
1319
|
-
color,
|
|
1320
|
-
backgroundColor,
|
|
1321
|
-
...props
|
|
1322
|
-
}) {
|
|
1323
|
-
const theme2 = (0, import_react_better_core8.useTheme)();
|
|
1324
|
-
return letters ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1325
|
-
View_default,
|
|
1326
|
-
{
|
|
1327
|
-
width: size,
|
|
1328
|
-
height: size,
|
|
1329
|
-
backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
|
|
1330
|
-
borderWidth: 1,
|
|
1331
|
-
borderColor: theme2.colors.border,
|
|
1332
|
-
borderRadius: 999,
|
|
1333
|
-
alignItems: "center",
|
|
1334
|
-
justifyContent: "center",
|
|
1335
|
-
...props,
|
|
1336
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text_default, { fontSize: size / 2.5, fontWeight: 700, color: color ?? theme2.colors.textPrimary, marginTop: 1, children: letters.toUpperCase().slice(0, 2) })
|
|
1337
|
-
}
|
|
1338
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1339
|
-
ImageComponent,
|
|
1340
|
-
{
|
|
1341
|
-
width: size,
|
|
1342
|
-
height: size,
|
|
1343
|
-
borderWidth: 1,
|
|
1344
|
-
borderColor: theme2.colors.border,
|
|
1345
|
-
borderRadius: 999,
|
|
1346
|
-
objectFit: "cover",
|
|
1347
|
-
...props
|
|
1348
|
-
}
|
|
1349
|
-
);
|
|
1350
|
-
};
|
|
1351
|
-
var Image2 = (0, import_react9.memo)(ImageComponent);
|
|
1352
|
-
Image2.profileImage = ImageComponent.profileImage;
|
|
1353
|
-
var Image_default = Image2;
|
|
1354
|
-
|
|
1355
|
-
// src/components/Icon.tsx
|
|
1356
|
-
var import_react10 = require("react");
|
|
1357
|
-
var import_react_native8 = require("react-native");
|
|
1358
|
-
var import_react_native_svg = require("react-native-svg");
|
|
1359
|
-
var import_react_better_core9 = require("react-better-core");
|
|
1360
|
-
var import_expo_symbols = require("expo-symbols");
|
|
1361
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1362
|
-
var import_react11 = require("react");
|
|
1363
|
-
function Icon({ name, nameIOS, size = 16, color, ...props }) {
|
|
1364
|
-
const theme2 = (0, import_react_better_core9.useTheme)();
|
|
1365
|
-
const { icons: icons2 } = (0, import_react_better_core9.useBetterCoreContext)();
|
|
1366
|
-
const svgColor = color ?? theme2.colors.textPrimary;
|
|
1367
|
-
(0, import_react10.useEffect)(() => {
|
|
1368
|
-
if (!icons2[name.toString()])
|
|
1369
|
-
console.warn(
|
|
1370
|
-
`The icon \`${name}\` you are trying to use does not exist. Make sure to add it to the \`icons\` object in \`<BetterComponentsProvider>\` config value prop.`
|
|
1371
|
-
);
|
|
1372
|
-
}, [icons2, name]);
|
|
1373
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1374
|
-
View_default,
|
|
1375
|
-
{
|
|
1376
|
-
width: size + (parseFloat(props.padding?.toString() ?? "0") ?? 0) + (parseFloat(props.paddingHorizontal?.toString() ?? "0") ?? 0),
|
|
1377
|
-
height: size + (parseFloat(props.padding?.toString() ?? "0") ?? 0) + (parseFloat(props.paddingVertical?.toString() ?? "0") ?? 0),
|
|
1378
|
-
alignItems: "center",
|
|
1379
|
-
justifyContent: "center",
|
|
1380
|
-
pressType: "opacity",
|
|
1381
|
-
pressStrength: pressStrength().p2,
|
|
1382
|
-
...props,
|
|
1383
|
-
children: import_react_native8.Platform.OS === "ios" && nameIOS ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_expo_symbols.SymbolView, { name: nameIOS, tintColor: svgColor, size }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1384
|
-
import_react_native_svg.Svg,
|
|
1385
|
-
{
|
|
1386
|
-
width: size,
|
|
1387
|
-
height: size,
|
|
1388
|
-
viewBox: `0 0 ${icons2[name.toString()]?.width ?? 0} ${icons2[name.toString()]?.height ?? 0}`,
|
|
1389
|
-
fill: "none",
|
|
1390
|
-
children: icons2[name.toString()]?.paths.map(({ type, ...path }) => /* @__PURE__ */ (0, import_react11.createElement)(
|
|
1391
|
-
import_react_native_svg.Path,
|
|
1392
|
-
{
|
|
1393
|
-
...path,
|
|
1394
|
-
fill: type === "fill" ? svgColor : void 0,
|
|
1395
|
-
stroke: type === "stroke" ? svgColor : void 0,
|
|
1396
|
-
key: path.d
|
|
1397
|
-
}
|
|
1398
|
-
))
|
|
1399
|
-
}
|
|
1400
|
-
)
|
|
1401
|
-
}
|
|
1402
|
-
);
|
|
1403
|
-
}
|
|
1404
|
-
var Icon_default = (0, import_react10.memo)(Icon);
|
|
1405
|
-
|
|
1406
1717
|
// src/components/InputField.tsx
|
|
1407
|
-
var
|
|
1718
|
+
var import_react14 = require("react");
|
|
1408
1719
|
var import_react_native9 = require("react-native");
|
|
1409
1720
|
var import_datetimepicker = __toESM(require("@react-native-community/datetimepicker"));
|
|
1410
|
-
var
|
|
1411
|
-
var
|
|
1412
|
-
var InputFieldComponent = (0,
|
|
1721
|
+
var import_react_better_core13 = require("react-better-core");
|
|
1722
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1723
|
+
var InputFieldComponent = (0, import_react14.forwardRef)(
|
|
1413
1724
|
({
|
|
1414
1725
|
flex,
|
|
1415
1726
|
placeholder,
|
|
@@ -1428,7 +1739,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1428
1739
|
autoCapitalize,
|
|
1429
1740
|
autoComplete,
|
|
1430
1741
|
autoCorrect,
|
|
1431
|
-
keyboardAppearance
|
|
1742
|
+
keyboardAppearance,
|
|
1432
1743
|
keyboardType,
|
|
1433
1744
|
secureTextEntry,
|
|
1434
1745
|
returnKeyLabel,
|
|
@@ -1460,12 +1771,12 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1460
1771
|
onPressEnter,
|
|
1461
1772
|
...props
|
|
1462
1773
|
}, ref) => {
|
|
1463
|
-
const theme2 = (0,
|
|
1464
|
-
const { colorTheme } = (0,
|
|
1465
|
-
const textInputRef = (0,
|
|
1466
|
-
const [internalValue, setInternalValue] = (0,
|
|
1467
|
-
const [internalDateValue, setInternalDateValue] = (0,
|
|
1468
|
-
const [isFocused, setIsFocused] = (0,
|
|
1774
|
+
const theme2 = (0, import_react_better_core13.useTheme)();
|
|
1775
|
+
const { colorTheme } = (0, import_react_better_core13.useBetterCoreContext)();
|
|
1776
|
+
const textInputRef = (0, import_react14.useRef)(null);
|
|
1777
|
+
const [internalValue, setInternalValue] = (0, import_react14.useState)(value?.toString() || defaultValue || "");
|
|
1778
|
+
const [internalDateValue, setInternalDateValue] = (0, import_react14.useState)();
|
|
1779
|
+
const [isFocused, setIsFocused] = (0, import_react_better_core13.useBooleanState)();
|
|
1469
1780
|
const isIOSDateTime = import_react_native9.Platform.OS === "ios" && (type === "date" || type === "time");
|
|
1470
1781
|
const iconSize = 16;
|
|
1471
1782
|
const iconPadding = onPressRightIcon ? theme2.styles.gap : 0;
|
|
@@ -1474,14 +1785,14 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1474
1785
|
const readyPaddingHorizontal = paddingHorizontal ?? theme2.styles.space;
|
|
1475
1786
|
const readyPaddingVertical = paddingVertical ? parseFloat(paddingVertical.toString()) : (theme2.styles.space + theme2.styles.gap) / 2;
|
|
1476
1787
|
const readyHeight = height ?? isIOSDateTime ? void 0 : borderWidth + readyPaddingVertical + lineHeight + readyPaddingVertical + borderWidth + (import_react_native9.Platform.OS === "android" ? 2 : 0);
|
|
1477
|
-
const onChangeRNDateTimePicker = (0,
|
|
1788
|
+
const onChangeRNDateTimePicker = (0, import_react14.useCallback)(
|
|
1478
1789
|
(event, data) => {
|
|
1479
1790
|
setInternalDateValue(data);
|
|
1480
1791
|
onChange?.(data?.toISOString() ?? "");
|
|
1481
1792
|
},
|
|
1482
1793
|
[onChange]
|
|
1483
1794
|
);
|
|
1484
|
-
const onPressInputField = (0,
|
|
1795
|
+
const onPressInputField = (0, import_react14.useCallback)(
|
|
1485
1796
|
(event) => {
|
|
1486
1797
|
onPress?.(event);
|
|
1487
1798
|
if (type === "date" || type === "time") {
|
|
@@ -1509,22 +1820,22 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1509
1820
|
},
|
|
1510
1821
|
[onPress, type, internalDateValue, onChangeRNDateTimePicker]
|
|
1511
1822
|
);
|
|
1512
|
-
const onFocusElement = (0,
|
|
1823
|
+
const onFocusElement = (0, import_react14.useCallback)((event) => {
|
|
1513
1824
|
setIsFocused.setTrue();
|
|
1514
1825
|
onFocus?.(event);
|
|
1515
1826
|
}, []);
|
|
1516
|
-
const onBlurElement = (0,
|
|
1827
|
+
const onBlurElement = (0, import_react14.useCallback)((event) => {
|
|
1517
1828
|
setIsFocused.setFalse();
|
|
1518
1829
|
onBlur?.(event);
|
|
1519
1830
|
}, []);
|
|
1520
|
-
const onChangeText = (0,
|
|
1831
|
+
const onChangeText = (0, import_react14.useCallback)(
|
|
1521
1832
|
(text) => {
|
|
1522
1833
|
setInternalValue(text);
|
|
1523
1834
|
onChange?.(text);
|
|
1524
1835
|
},
|
|
1525
1836
|
[onChange]
|
|
1526
1837
|
);
|
|
1527
|
-
const textInputStyle = (0,
|
|
1838
|
+
const textInputStyle = (0, import_react14.useMemo)(
|
|
1528
1839
|
() => ({
|
|
1529
1840
|
flex: 1,
|
|
1530
1841
|
fontSize,
|
|
@@ -1549,14 +1860,14 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1549
1860
|
rightIcon
|
|
1550
1861
|
]
|
|
1551
1862
|
);
|
|
1552
|
-
const rnDateTimePickerStyle = (0,
|
|
1863
|
+
const rnDateTimePickerStyle = (0, import_react14.useMemo)(
|
|
1553
1864
|
() => ({
|
|
1554
1865
|
flex: iOSDateTimeFullSize ? 1 : void 0,
|
|
1555
1866
|
marginLeft: -8 + (iOSDateTimeFullSize ? 0 : theme2.styles.space)
|
|
1556
1867
|
}),
|
|
1557
1868
|
[iOSDateTimeFullSize]
|
|
1558
1869
|
);
|
|
1559
|
-
(0,
|
|
1870
|
+
(0, import_react14.useEffect)(() => {
|
|
1560
1871
|
if (value === void 0) return;
|
|
1561
1872
|
setInternalValue(value.toString());
|
|
1562
1873
|
try {
|
|
@@ -1564,7 +1875,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1564
1875
|
} catch (error) {
|
|
1565
1876
|
}
|
|
1566
1877
|
}, [value]);
|
|
1567
|
-
(0,
|
|
1878
|
+
(0, import_react14.useEffect)(() => {
|
|
1568
1879
|
if (type !== "date" && type !== "time") return;
|
|
1569
1880
|
const date = internalDateValue?.toISOString().split("T")[0] ?? "";
|
|
1570
1881
|
const hours = internalDateValue ? internalDateValue.getHours().toString() : "00";
|
|
@@ -1573,7 +1884,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1573
1884
|
type === "date" ? date : internalDateValue ? `${hours.length === 1 ? `0${hours}` : hours}:${minutes.length === 1 ? `0${minutes}` : minutes}` : ""
|
|
1574
1885
|
);
|
|
1575
1886
|
}, [internalDateValue]);
|
|
1576
|
-
(0,
|
|
1887
|
+
(0, import_react14.useImperativeHandle)(
|
|
1577
1888
|
ref,
|
|
1578
1889
|
() => {
|
|
1579
1890
|
return textInputRef.current;
|
|
@@ -1581,12 +1892,12 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1581
1892
|
[]
|
|
1582
1893
|
);
|
|
1583
1894
|
const withPressInputField = !!onPress || type === "date" || type === "time";
|
|
1584
|
-
const prefixSuffixBackgroundColor = colorTheme === "light" ? (0,
|
|
1585
|
-
const labelComponent = label && /* @__PURE__ */ (0,
|
|
1586
|
-
/* @__PURE__ */ (0,
|
|
1587
|
-
required && /* @__PURE__ */ (0,
|
|
1895
|
+
const prefixSuffixBackgroundColor = colorTheme === "light" ? (0, import_react_better_core13.darkenColor)(theme2.colors.backgroundContent, 0.03) : (0, import_react_better_core13.lightenColor)(theme2.colors.backgroundContent, 0.1);
|
|
1896
|
+
const labelComponent = label && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(View_default, { isRow: true, alignItems: "center", gap: 2, children: [
|
|
1897
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Text_default, { fontSize: 14, color: isError ? theme2.colors.error : theme2.colors.textSecondary, children: label }),
|
|
1898
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Text_default, { color: theme2.colors.error, children: "*" })
|
|
1588
1899
|
] });
|
|
1589
|
-
return /* @__PURE__ */ (0,
|
|
1900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1590
1901
|
Animate_default.View,
|
|
1591
1902
|
{
|
|
1592
1903
|
flex,
|
|
@@ -1596,8 +1907,8 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1596
1907
|
...props,
|
|
1597
1908
|
children: [
|
|
1598
1909
|
isIOSDateTime && !iOSDateTimeFullSize ? void 0 : labelComponent,
|
|
1599
|
-
/* @__PURE__ */ (0,
|
|
1600
|
-
prefix && /* @__PURE__ */ (0,
|
|
1910
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(View_default, { isRow: true, position: "relative", alignItems: "center", height: readyHeight, children: [
|
|
1911
|
+
prefix && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1601
1912
|
View_default,
|
|
1602
1913
|
{
|
|
1603
1914
|
isRow: true,
|
|
@@ -1612,7 +1923,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1612
1923
|
borderColor: theme2.colors.border,
|
|
1613
1924
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1614
1925
|
onPress: onPressPrefix,
|
|
1615
|
-
children: typeof prefix === "string" ? /* @__PURE__ */ (0,
|
|
1926
|
+
children: typeof prefix === "string" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1616
1927
|
Text_default,
|
|
1617
1928
|
{
|
|
1618
1929
|
fontWeight: 700,
|
|
@@ -1623,20 +1934,21 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1623
1934
|
) : prefix
|
|
1624
1935
|
}
|
|
1625
1936
|
),
|
|
1626
|
-
isIOSDateTime ? /* @__PURE__ */ (0,
|
|
1937
|
+
isIOSDateTime ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
1627
1938
|
!iOSDateTimeFullSize ? labelComponent : void 0,
|
|
1628
|
-
/* @__PURE__ */ (0,
|
|
1939
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1629
1940
|
import_datetimepicker.default,
|
|
1630
1941
|
{
|
|
1631
1942
|
value: internalDateValue ?? /* @__PURE__ */ new Date(),
|
|
1632
1943
|
mode: type,
|
|
1633
1944
|
display: iOSDateTimeFullSize ? type === "date" ? "inline" : "spinner" : "default",
|
|
1634
1945
|
accentColor: theme2.colors.primary,
|
|
1946
|
+
themeVariant: colorTheme === "dark" ? "dark" : "light",
|
|
1635
1947
|
style: rnDateTimePickerStyle,
|
|
1636
1948
|
onChange: onChangeRNDateTimePicker
|
|
1637
1949
|
}
|
|
1638
1950
|
)
|
|
1639
|
-
] }) : /* @__PURE__ */ (0,
|
|
1951
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1640
1952
|
View_default,
|
|
1641
1953
|
{
|
|
1642
1954
|
flex: 1,
|
|
@@ -1647,7 +1959,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1647
1959
|
borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1648
1960
|
pressStrength: 1,
|
|
1649
1961
|
onPress: import_react_native9.Platform.OS === "android" ? editable === false || withPressInputField ? onPressInputField : void 0 : void 0,
|
|
1650
|
-
children: /* @__PURE__ */ (0,
|
|
1962
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1651
1963
|
Animate_default.View,
|
|
1652
1964
|
{
|
|
1653
1965
|
position: "relative",
|
|
@@ -1663,7 +1975,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1663
1975
|
animateBorderColor: isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border,
|
|
1664
1976
|
overflow: "hidden",
|
|
1665
1977
|
children: [
|
|
1666
|
-
leftIcon && /* @__PURE__ */ (0,
|
|
1978
|
+
leftIcon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1667
1979
|
Icon_default,
|
|
1668
1980
|
{
|
|
1669
1981
|
position: "absolute",
|
|
@@ -1676,7 +1988,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1676
1988
|
onPress: onPressLeftIcon
|
|
1677
1989
|
}
|
|
1678
1990
|
),
|
|
1679
|
-
/* @__PURE__ */ (0,
|
|
1991
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1680
1992
|
import_react_native9.TextInput,
|
|
1681
1993
|
{
|
|
1682
1994
|
style: textInputStyle,
|
|
@@ -1694,7 +2006,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1694
2006
|
readOnly: !editable || disabled || type === "date" || type === "time",
|
|
1695
2007
|
textAlign,
|
|
1696
2008
|
editable: !disabled,
|
|
1697
|
-
keyboardAppearance,
|
|
2009
|
+
keyboardAppearance: keyboardAppearance ?? colorTheme === "dark" ? "dark" : "light",
|
|
1698
2010
|
keyboardType,
|
|
1699
2011
|
cursorColor: theme2.colors.primary,
|
|
1700
2012
|
selectionColor: theme2.colors.primary,
|
|
@@ -1709,7 +2021,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1709
2021
|
ref: textInputRef
|
|
1710
2022
|
}
|
|
1711
2023
|
),
|
|
1712
|
-
rightIcon && /* @__PURE__ */ (0,
|
|
2024
|
+
rightIcon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1713
2025
|
Icon_default,
|
|
1714
2026
|
{
|
|
1715
2027
|
position: "absolute",
|
|
@@ -1727,7 +2039,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1727
2039
|
)
|
|
1728
2040
|
}
|
|
1729
2041
|
),
|
|
1730
|
-
suffix && /* @__PURE__ */ (0,
|
|
2042
|
+
suffix && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1731
2043
|
View_default,
|
|
1732
2044
|
{
|
|
1733
2045
|
isRow: true,
|
|
@@ -1741,7 +2053,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1741
2053
|
borderColor: theme2.colors.border,
|
|
1742
2054
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1743
2055
|
onPress: onPressSuffix,
|
|
1744
|
-
children: typeof suffix === "string" ? /* @__PURE__ */ (0,
|
|
2056
|
+
children: typeof suffix === "string" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1745
2057
|
Text_default,
|
|
1746
2058
|
{
|
|
1747
2059
|
fontWeight: 700,
|
|
@@ -1753,7 +2065,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1753
2065
|
}
|
|
1754
2066
|
)
|
|
1755
2067
|
] }),
|
|
1756
|
-
infoMessage && /* @__PURE__ */ (0,
|
|
2068
|
+
infoMessage && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1757
2069
|
Animate_default.Text,
|
|
1758
2070
|
{
|
|
1759
2071
|
fontSize: 14,
|
|
@@ -1765,7 +2077,7 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1765
2077
|
children: infoMessage
|
|
1766
2078
|
}
|
|
1767
2079
|
),
|
|
1768
|
-
errorMessage && /* @__PURE__ */ (0,
|
|
2080
|
+
errorMessage && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1769
2081
|
Animate_default.Text,
|
|
1770
2082
|
{
|
|
1771
2083
|
fontSize: 14,
|
|
@@ -1782,8 +2094,8 @@ var InputFieldComponent = (0, import_react12.forwardRef)(
|
|
|
1782
2094
|
);
|
|
1783
2095
|
}
|
|
1784
2096
|
);
|
|
1785
|
-
InputFieldComponent.email = (0,
|
|
1786
|
-
return /* @__PURE__ */ (0,
|
|
2097
|
+
InputFieldComponent.email = (0, import_react14.forwardRef)(function Email(props, ref) {
|
|
2098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1787
2099
|
InputFieldComponent,
|
|
1788
2100
|
{
|
|
1789
2101
|
placeholder: "your@email.here",
|
|
@@ -1796,21 +2108,21 @@ InputFieldComponent.email = (0, import_react12.forwardRef)(function Email(props,
|
|
|
1796
2108
|
}
|
|
1797
2109
|
);
|
|
1798
2110
|
});
|
|
1799
|
-
InputFieldComponent.password = (0,
|
|
1800
|
-
const inputFieldRef = (0,
|
|
1801
|
-
const [showPassword, setShowPassword] = (0,
|
|
1802
|
-
const onPressEye = (0,
|
|
2111
|
+
InputFieldComponent.password = (0, import_react14.forwardRef)(function Password(props, ref) {
|
|
2112
|
+
const inputFieldRef = (0, import_react14.useRef)(null);
|
|
2113
|
+
const [showPassword, setShowPassword] = (0, import_react_better_core13.useBooleanState)();
|
|
2114
|
+
const onPressEye = (0, import_react14.useCallback)(() => {
|
|
1803
2115
|
setShowPassword.toggle();
|
|
1804
2116
|
inputFieldRef.current?.focus();
|
|
1805
2117
|
}, []);
|
|
1806
|
-
(0,
|
|
2118
|
+
(0, import_react14.useImperativeHandle)(
|
|
1807
2119
|
ref,
|
|
1808
2120
|
() => {
|
|
1809
2121
|
return inputFieldRef.current;
|
|
1810
2122
|
},
|
|
1811
2123
|
[]
|
|
1812
2124
|
);
|
|
1813
|
-
return /* @__PURE__ */ (0,
|
|
2125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1814
2126
|
InputFieldComponent,
|
|
1815
2127
|
{
|
|
1816
2128
|
secureTextEntry: !showPassword,
|
|
@@ -1825,12 +2137,12 @@ InputFieldComponent.password = (0, import_react12.forwardRef)(function Password(
|
|
|
1825
2137
|
}
|
|
1826
2138
|
);
|
|
1827
2139
|
});
|
|
1828
|
-
InputFieldComponent.search = (0,
|
|
1829
|
-
return /* @__PURE__ */ (0,
|
|
2140
|
+
InputFieldComponent.search = (0, import_react14.forwardRef)(function Search(props, ref) {
|
|
2141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(InputFieldComponent, { placeholder: "Search...", leftIcon: "magnifyingGlass", ...props, ref });
|
|
1830
2142
|
});
|
|
1831
|
-
InputFieldComponent.code = (0,
|
|
1832
|
-
const theme2 = (0,
|
|
1833
|
-
return /* @__PURE__ */ (0,
|
|
2143
|
+
InputFieldComponent.code = (0, import_react14.forwardRef)(function Password2({ isSmall, ...props }, ref) {
|
|
2144
|
+
const theme2 = (0, import_react_better_core13.useTheme)();
|
|
2145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1834
2146
|
InputFieldComponent,
|
|
1835
2147
|
{
|
|
1836
2148
|
flex: 1,
|
|
@@ -1845,43 +2157,157 @@ InputFieldComponent.code = (0, import_react12.forwardRef)(function Password2({ i
|
|
|
1845
2157
|
}
|
|
1846
2158
|
);
|
|
1847
2159
|
});
|
|
1848
|
-
var InputField = (0,
|
|
2160
|
+
var InputField = (0, import_react14.memo)(InputFieldComponent);
|
|
1849
2161
|
InputField.email = InputFieldComponent.email;
|
|
1850
2162
|
InputField.password = InputFieldComponent.password;
|
|
1851
2163
|
InputField.search = InputFieldComponent.search;
|
|
1852
2164
|
InputField.code = InputFieldComponent.code;
|
|
1853
2165
|
var InputField_default = InputField;
|
|
1854
2166
|
|
|
1855
|
-
// src/components/
|
|
1856
|
-
var
|
|
1857
|
-
var import_react_better_core11 = require("react-better-core");
|
|
2167
|
+
// src/components/Switch.tsx
|
|
2168
|
+
var import_react15 = require("react");
|
|
1858
2169
|
var import_react_native10 = require("react-native");
|
|
1859
|
-
var
|
|
2170
|
+
var import_react_better_core14 = require("react-better-core");
|
|
2171
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2172
|
+
function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
2173
|
+
const theme2 = (0, import_react_better_core14.useTheme)();
|
|
2174
|
+
const [enabled, setEnabled] = (0, import_react_better_core14.useBooleanState)(isEnabled ?? defaultIsEnabled);
|
|
2175
|
+
const onPressElement = (0, import_react15.useCallback)(() => {
|
|
2176
|
+
onChange?.(!enabled);
|
|
2177
|
+
setEnabled.toggle();
|
|
2178
|
+
}, [onChange, enabled]);
|
|
2179
|
+
const trackColor = (0, import_react15.useMemo)(
|
|
2180
|
+
() => ({
|
|
2181
|
+
false: theme2.colors.border,
|
|
2182
|
+
true: theme2.colors.primary
|
|
2183
|
+
}),
|
|
2184
|
+
[theme2.colors]
|
|
2185
|
+
);
|
|
2186
|
+
(0, import_react15.useEffect)(() => {
|
|
2187
|
+
if (isEnabled === void 0) return;
|
|
2188
|
+
setEnabled.setState(isEnabled);
|
|
2189
|
+
}, [isEnabled]);
|
|
2190
|
+
const ballSize = 26;
|
|
2191
|
+
const ballGap = 3;
|
|
2192
|
+
const holderWidth = ballSize * 2.1;
|
|
2193
|
+
return import_react_native10.Platform.OS === "ios" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2194
|
+
import_react_native10.Switch,
|
|
2195
|
+
{
|
|
2196
|
+
trackColor,
|
|
2197
|
+
ios_backgroundColor: theme2.colors.border,
|
|
2198
|
+
onValueChange: onPressElement,
|
|
2199
|
+
value: enabled,
|
|
2200
|
+
disabled
|
|
2201
|
+
}
|
|
2202
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2203
|
+
View_default,
|
|
2204
|
+
{
|
|
2205
|
+
width: holderWidth,
|
|
2206
|
+
borderRadius: 999,
|
|
2207
|
+
pressStrength: pressStrength().p05,
|
|
2208
|
+
disabled,
|
|
2209
|
+
onPress: !disabled ? onPressElement : void 0,
|
|
2210
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2211
|
+
Animate_default.View,
|
|
2212
|
+
{
|
|
2213
|
+
width: "100%",
|
|
2214
|
+
height: ballGap + ballSize + ballGap,
|
|
2215
|
+
borderRadius: 999,
|
|
2216
|
+
initialOpacity: 1,
|
|
2217
|
+
animateOpacity: disabled ? 0.6 : 1,
|
|
2218
|
+
initialBackgroundColor: theme2.colors.border,
|
|
2219
|
+
animateBackgroundColor: enabled ? theme2.colors.primary : theme2.colors.border,
|
|
2220
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2221
|
+
Animate_default.View,
|
|
2222
|
+
{
|
|
2223
|
+
width: ballSize,
|
|
2224
|
+
height: ballSize,
|
|
2225
|
+
top: ballGap,
|
|
2226
|
+
borderRadius: 999,
|
|
2227
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
2228
|
+
initialX: ballGap,
|
|
2229
|
+
animateX: enabled ? holderWidth - ballGap - ballSize : ballGap
|
|
2230
|
+
}
|
|
2231
|
+
)
|
|
2232
|
+
}
|
|
2233
|
+
)
|
|
2234
|
+
}
|
|
2235
|
+
);
|
|
2236
|
+
}
|
|
2237
|
+
var Switch_default = (0, import_react15.memo)(Switch);
|
|
2238
|
+
|
|
2239
|
+
// src/components/StatusBar.tsx
|
|
2240
|
+
var import_react16 = require("react");
|
|
2241
|
+
var import_react_better_core15 = require("react-better-core");
|
|
2242
|
+
var import_react_native11 = require("react-native");
|
|
2243
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1860
2244
|
function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarStyle }) {
|
|
1861
|
-
const theme2 = (0,
|
|
1862
|
-
return /* @__PURE__ */ (0,
|
|
1863
|
-
|
|
2245
|
+
const theme2 = (0, import_react_better_core15.useTheme)();
|
|
2246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2247
|
+
import_react_native11.StatusBar,
|
|
1864
2248
|
{
|
|
1865
2249
|
backgroundColor: darkStatusBar ? theme2.colors.backgroundSecondary : void 0,
|
|
1866
|
-
barStyle: barStyle ?? (
|
|
2250
|
+
barStyle: barStyle ?? (import_react_native11.Platform.OS === "android" ? androidBarStyle : iOSBarStyle),
|
|
1867
2251
|
hidden
|
|
1868
2252
|
}
|
|
1869
2253
|
);
|
|
1870
2254
|
}
|
|
1871
|
-
var StatusBar_default = (0,
|
|
2255
|
+
var StatusBar_default = (0, import_react16.memo)(StatusBar);
|
|
1872
2256
|
|
|
1873
|
-
// src/
|
|
1874
|
-
var
|
|
1875
|
-
var
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
2257
|
+
// src/components/ListItem.tsx
|
|
2258
|
+
var import_react17 = require("react");
|
|
2259
|
+
var import_react_better_core16 = require("react-better-core");
|
|
2260
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2261
|
+
function ListItem({
|
|
2262
|
+
icon,
|
|
2263
|
+
iconIOS,
|
|
2264
|
+
title,
|
|
2265
|
+
description,
|
|
2266
|
+
descriptionSelectable,
|
|
2267
|
+
rightElement,
|
|
2268
|
+
backgroundColor,
|
|
2269
|
+
insideScreenHolder,
|
|
2270
|
+
onPress,
|
|
2271
|
+
rightValue,
|
|
2272
|
+
rightValueSelectable,
|
|
2273
|
+
switchIsEnabled,
|
|
2274
|
+
switchOnChange
|
|
2275
|
+
}) {
|
|
2276
|
+
const theme2 = (0, import_react_better_core16.useTheme)();
|
|
2277
|
+
const device = useDevice();
|
|
2278
|
+
const sideSpace = theme2.styles.space;
|
|
2279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2280
|
+
View_default,
|
|
2281
|
+
{
|
|
2282
|
+
width: insideScreenHolder ? device.windowDimensions.width : "100%",
|
|
2283
|
+
backgroundColor: backgroundColor ?? theme2.colors.backgroundBase,
|
|
2284
|
+
marginHorizontal: insideScreenHolder ? -sideSpace : void 0,
|
|
2285
|
+
paddingVertical: theme2.styles.gap,
|
|
2286
|
+
paddingHorizontal: sideSpace,
|
|
2287
|
+
pressStrength: pressStrength().p05,
|
|
2288
|
+
onPress,
|
|
2289
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.space, children: [
|
|
2290
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Icon_default, { name: icon, nameIOS: iconIOS, size: 22, color: theme2.colors.primary }),
|
|
2291
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(View_default, { flex: 1, flexDirection: "row", alignItems: "center", gap: theme2.styles.gap, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(View_default, { flex: 1, children: [
|
|
2292
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text_default, { fontSize: 20, fontWeight: 700, children: title }),
|
|
2293
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text_default.body, { selectable: descriptionSelectable, children: description })
|
|
2294
|
+
] }) }),
|
|
2295
|
+
rightElement ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: rightValue !== void 0 || rightElement === "arrow" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.gap / 2, children: [
|
|
2296
|
+
rightValue !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text_default, { fontSize: 14, fontWeight: 700, selectable: rightValueSelectable, children: rightValue }),
|
|
2297
|
+
rightElement === "arrow" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2298
|
+
Icon_default,
|
|
2299
|
+
{
|
|
2300
|
+
name: "chevronRight",
|
|
2301
|
+
nameIOS: "chevron.right",
|
|
2302
|
+
color: rightValue !== void 0 ? theme2.colors.textPrimary : theme2.colors.textSecondary
|
|
2303
|
+
}
|
|
2304
|
+
)
|
|
2305
|
+
] }) : rightElement === "switch" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Switch_default, { isEnabled: switchIsEnabled, onChange: switchOnChange }) : void 0 }) : void 0
|
|
2306
|
+
] })
|
|
2307
|
+
}
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2310
|
+
var ListItem_default = (0, import_react17.memo)(ListItem);
|
|
1885
2311
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1886
2312
|
0 && (module.exports = {
|
|
1887
2313
|
Animate,
|
|
@@ -1890,15 +2316,20 @@ var asyncStoragePlugin = (options) => ({
|
|
|
1890
2316
|
Icon,
|
|
1891
2317
|
Image,
|
|
1892
2318
|
InputField,
|
|
2319
|
+
ListItem,
|
|
1893
2320
|
Loader,
|
|
1894
2321
|
ScreenHolder,
|
|
1895
2322
|
StatusBar,
|
|
2323
|
+
Switch,
|
|
1896
2324
|
Text,
|
|
1897
2325
|
View,
|
|
2326
|
+
alertControls,
|
|
2327
|
+
alertsPlugin,
|
|
1898
2328
|
asyncStoragePlugin,
|
|
1899
2329
|
colorThemeControls,
|
|
1900
2330
|
countries,
|
|
1901
2331
|
darkenColor,
|
|
2332
|
+
defaultAlertsPluginOptions,
|
|
1902
2333
|
defaultAsyncStoragePluginOptions,
|
|
1903
2334
|
desaturateColor,
|
|
1904
2335
|
eventPreventDefault,
|
|
@@ -1913,6 +2344,7 @@ var asyncStoragePlugin = (options) => ({
|
|
|
1913
2344
|
loaderControls,
|
|
1914
2345
|
pressStrength,
|
|
1915
2346
|
saturateColor,
|
|
2347
|
+
useAlertControls,
|
|
1916
2348
|
useBetterComponentsContext,
|
|
1917
2349
|
useBooleanState,
|
|
1918
2350
|
useDebounceState,
|