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.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import {
|
|
3
|
-
useTheme as
|
|
3
|
+
useTheme as useTheme15,
|
|
4
4
|
useLoader as useLoader2,
|
|
5
5
|
useLoaderControls,
|
|
6
6
|
countries,
|
|
@@ -8,28 +8,29 @@ import {
|
|
|
8
8
|
darkenColor as darkenColor2,
|
|
9
9
|
saturateColor,
|
|
10
10
|
desaturateColor,
|
|
11
|
-
generateRandomString,
|
|
11
|
+
generateRandomString as generateRandomString3,
|
|
12
12
|
formatPhoneNumber,
|
|
13
13
|
eventPreventDefault,
|
|
14
14
|
eventStopPropagation,
|
|
15
15
|
eventPreventStop,
|
|
16
16
|
getPluralWord,
|
|
17
|
-
useBooleanState as
|
|
17
|
+
useBooleanState as useBooleanState6,
|
|
18
18
|
useDebounceState,
|
|
19
19
|
loaderControls,
|
|
20
20
|
colorThemeControls
|
|
21
21
|
} from "react-better-core";
|
|
22
22
|
|
|
23
23
|
// src/components/BetterComponentsProvider.tsx
|
|
24
|
-
import { createContext, memo, useContext, useEffect, useMemo } from "react";
|
|
24
|
+
import { createContext, memo as memo10, useCallback as useCallback4, useContext, useEffect as useEffect5, useMemo as useMemo7, useState as useState2 } from "react";
|
|
25
25
|
import {
|
|
26
|
-
useBooleanState,
|
|
27
26
|
BetterCoreProvider,
|
|
28
|
-
useBetterCoreContext
|
|
27
|
+
useBetterCoreContext as useBetterCoreContext3,
|
|
28
|
+
generateRandomString as generateRandomString2
|
|
29
29
|
} from "react-better-core";
|
|
30
30
|
|
|
31
31
|
// src/constants/app.ts
|
|
32
32
|
var appConfig = {};
|
|
33
|
+
var defaultAlertDuration = 2.3 * 1e3;
|
|
33
34
|
|
|
34
35
|
// src/constants/theme.ts
|
|
35
36
|
var theme = {};
|
|
@@ -71,115 +72,15 @@ var icons = {
|
|
|
71
72
|
// src/constants/assets.ts
|
|
72
73
|
var assets = {};
|
|
73
74
|
|
|
74
|
-
// src/components/
|
|
75
|
-
import {
|
|
76
|
-
|
|
77
|
-
var externalBetterCoreContextValue;
|
|
78
|
-
var externalBetterComponentsContextValue;
|
|
79
|
-
var useBetterComponentsContext = () => {
|
|
80
|
-
const coreContext = useBetterCoreContext();
|
|
81
|
-
const context = useContext(betterComponentsContext);
|
|
82
|
-
if (context === void 0)
|
|
83
|
-
throw new Error(
|
|
84
|
-
"`useBetterComponentsContext()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
85
|
-
);
|
|
86
|
-
const { plugins, componentsState, ...rest } = context;
|
|
87
|
-
return {
|
|
88
|
-
...coreContext,
|
|
89
|
-
...rest
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
function BetterComponentsProviderInternalContent({ children }) {
|
|
93
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
94
|
-
}
|
|
95
|
-
function BetterComponentsProviderInternal({
|
|
96
|
-
config,
|
|
97
|
-
plugins,
|
|
98
|
-
children
|
|
99
|
-
}) {
|
|
100
|
-
const betterCoreContext = useBetterCoreContext();
|
|
101
|
-
const [sideMenuIsCollapsed, setSideMenuIsCollapsed] = useBooleanState();
|
|
102
|
-
const [sideMenuIsOpenMobile, setSideMenuIsOpenMobile] = useBooleanState();
|
|
103
|
-
const readyConfig = useMemo(
|
|
104
|
-
() => ({
|
|
105
|
-
app: {
|
|
106
|
-
...appConfig,
|
|
107
|
-
...config?.app
|
|
108
|
-
},
|
|
109
|
-
sideMenuIsCollapsed,
|
|
110
|
-
setSideMenuIsCollapsed,
|
|
111
|
-
sideMenuIsOpenMobile,
|
|
112
|
-
setSideMenuIsOpenMobile,
|
|
113
|
-
plugins: plugins ?? [],
|
|
114
|
-
componentsState: {}
|
|
115
|
-
}),
|
|
116
|
-
[config, sideMenuIsCollapsed, sideMenuIsOpenMobile, plugins]
|
|
117
|
-
);
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
if (!plugins) return;
|
|
120
|
-
plugins.forEach((plugin) => {
|
|
121
|
-
plugin.initialize?.();
|
|
122
|
-
});
|
|
123
|
-
}, []);
|
|
124
|
-
externalBetterCoreContextValue = betterCoreContext;
|
|
125
|
-
externalBetterComponentsContextValue = readyConfig;
|
|
126
|
-
return /* @__PURE__ */ jsx(betterComponentsContext.Provider, { value: readyConfig, children: /* @__PURE__ */ jsx(BetterComponentsProviderInternalContent, { children }) });
|
|
127
|
-
}
|
|
128
|
-
function BetterComponentsProvider({ config, ...props }) {
|
|
129
|
-
const coreConfig = useMemo(
|
|
130
|
-
() => ({
|
|
131
|
-
theme: {
|
|
132
|
-
...theme,
|
|
133
|
-
...config?.theme
|
|
134
|
-
},
|
|
135
|
-
// colorTheme: config?.colorTheme ?? (localStorage.getItem("theme") === "dark" ? "dark" : "light"),
|
|
136
|
-
colorTheme: config?.colorTheme ?? "light",
|
|
137
|
-
icons: {
|
|
138
|
-
...icons,
|
|
139
|
-
...config?.icons
|
|
140
|
-
},
|
|
141
|
-
assets: {
|
|
142
|
-
...assets,
|
|
143
|
-
...config?.assets
|
|
144
|
-
},
|
|
145
|
-
loaders: config?.loaders
|
|
146
|
-
}),
|
|
147
|
-
[config]
|
|
148
|
-
);
|
|
149
|
-
const componentsConfig = useMemo(
|
|
150
|
-
() => ({
|
|
151
|
-
app: config?.app
|
|
152
|
-
}),
|
|
153
|
-
[config]
|
|
154
|
-
);
|
|
155
|
-
return /* @__PURE__ */ jsx(BetterCoreProvider, { config: coreConfig, children: /* @__PURE__ */ jsx(BetterComponentsProviderInternal, { config: componentsConfig, ...props }) });
|
|
156
|
-
}
|
|
157
|
-
var BetterComponentsProvider_default = memo(BetterComponentsProvider);
|
|
158
|
-
|
|
159
|
-
// src/utils/variableFunctions.ts
|
|
160
|
-
var checkBetterCoreContextValue = (value, functionsName) => {
|
|
161
|
-
if (value === void 0) {
|
|
162
|
-
throw new Error(
|
|
163
|
-
`\`${functionsName}()\` must be used within a \`<BetterCoreProvider>\`. Make sure to add one at the root of your component tree.`
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
return value !== void 0;
|
|
167
|
-
};
|
|
168
|
-
var pressStrength = () => {
|
|
169
|
-
if (!checkBetterCoreContextValue(externalBetterCoreContextValue, "pressStrength")) return void 0;
|
|
170
|
-
return {
|
|
171
|
-
p05: externalBetterCoreContextValue.colorTheme === "dark" ? 0.85 : 0.95,
|
|
172
|
-
p1: externalBetterCoreContextValue.colorTheme === "dark" ? 0.6 : 0.8,
|
|
173
|
-
p2: externalBetterCoreContextValue.colorTheme === "dark" ? 0.5 : 0.7,
|
|
174
|
-
p3: externalBetterCoreContextValue.colorTheme === "dark" ? 0.4 : 0.6
|
|
175
|
-
};
|
|
176
|
-
};
|
|
75
|
+
// src/components/alerts/AlertsHolder.tsx
|
|
76
|
+
import { memo as memo9 } from "react";
|
|
77
|
+
import { useTheme as useTheme9 } from "react-better-core";
|
|
177
78
|
|
|
178
79
|
// src/utils/hooks.ts
|
|
179
|
-
import { useCallback, useEffect
|
|
80
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
180
81
|
import { DeviceEventEmitter, Dimensions, Keyboard } from "react-native";
|
|
181
82
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
182
|
-
import { useBooleanState
|
|
83
|
+
import { useBooleanState, useTheme } from "react-better-core";
|
|
183
84
|
|
|
184
85
|
// src/constants/css.ts
|
|
185
86
|
var cssProps = /* @__PURE__ */ new Set([
|
|
@@ -397,10 +298,10 @@ function useDevice() {
|
|
|
397
298
|
};
|
|
398
299
|
}
|
|
399
300
|
function useKeyboard() {
|
|
400
|
-
const [keyboardOpened, setKeyboardOpened] =
|
|
401
|
-
const [keyboardWillOpen, setKeyboardWillOpen] =
|
|
301
|
+
const [keyboardOpened, setKeyboardOpened] = useBooleanState();
|
|
302
|
+
const [keyboardWillOpen, setKeyboardWillOpen] = useBooleanState();
|
|
402
303
|
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
403
|
-
|
|
304
|
+
useEffect(() => {
|
|
404
305
|
const keyboardDidShow = (event) => {
|
|
405
306
|
setKeyboardOpened.setTrue();
|
|
406
307
|
setKeyboardHeight(event.endCoordinates.height);
|
|
@@ -427,7 +328,7 @@ function useKeyboard() {
|
|
|
427
328
|
};
|
|
428
329
|
}
|
|
429
330
|
function useComponentPropsGrouper(props, prefix) {
|
|
430
|
-
return
|
|
331
|
+
return useMemo(() => {
|
|
431
332
|
const style = {};
|
|
432
333
|
const withPrefixStyle = {};
|
|
433
334
|
const restProps = {};
|
|
@@ -458,7 +359,7 @@ function useForm(options) {
|
|
|
458
359
|
);
|
|
459
360
|
const [values, setValues] = useState(defaultValues);
|
|
460
361
|
const [errors, setErrors] = useState({});
|
|
461
|
-
const [isSubmitting, setIsSubmitting] =
|
|
362
|
+
const [isSubmitting, setIsSubmitting] = useBooleanState();
|
|
462
363
|
const numberOfInputFields = Object.keys(defaultValues).length;
|
|
463
364
|
const setFieldValue = useCallback(
|
|
464
365
|
(field, value) => {
|
|
@@ -535,19 +436,35 @@ function useForm(options) {
|
|
|
535
436
|
},
|
|
536
437
|
[values, setFieldValue, errors, requiredFields, additional, onSubmitFunction]
|
|
537
438
|
);
|
|
439
|
+
const getSwitchProps = useCallback(
|
|
440
|
+
(field, insideListItem) => {
|
|
441
|
+
return insideListItem ? {
|
|
442
|
+
switchIsEnabled: values[field],
|
|
443
|
+
switchOnChange: (value) => {
|
|
444
|
+
setFieldValue(field, value);
|
|
445
|
+
}
|
|
446
|
+
} : {
|
|
447
|
+
isEnabled: values[field],
|
|
448
|
+
onChange: (value) => {
|
|
449
|
+
setFieldValue(field, value);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
},
|
|
453
|
+
[values, setFieldValue]
|
|
454
|
+
);
|
|
538
455
|
const reset = useCallback(() => {
|
|
539
456
|
setValues(defaultValues);
|
|
540
457
|
setErrors({});
|
|
541
458
|
}, [defaultValues]);
|
|
542
|
-
const isDirty =
|
|
459
|
+
const isDirty = useMemo(
|
|
543
460
|
() => Object.keys(defaultValues).some((key) => defaultValues[key] !== values[key]),
|
|
544
461
|
[defaultValues, values]
|
|
545
462
|
);
|
|
546
|
-
const isValid =
|
|
463
|
+
const isValid = useMemo(() => {
|
|
547
464
|
const validationErrors = validate?.(values) || {};
|
|
548
465
|
return Object.keys(validationErrors).length === 0;
|
|
549
466
|
}, [validate, values]);
|
|
550
|
-
const canSubmit =
|
|
467
|
+
const canSubmit = useMemo(() => {
|
|
551
468
|
const requiredFieldsHaveValues = requiredFields?.every((field) => values[field] !== void 0 && values[field] !== "") ?? true;
|
|
552
469
|
return isValid && requiredFieldsHaveValues;
|
|
553
470
|
}, [isValid, requiredFields]);
|
|
@@ -558,6 +475,7 @@ function useForm(options) {
|
|
|
558
475
|
setFieldValue,
|
|
559
476
|
setFieldsValue,
|
|
560
477
|
getInputFieldProps,
|
|
478
|
+
getSwitchProps,
|
|
561
479
|
focusField,
|
|
562
480
|
inputFieldRefs: inputFieldRefs.current,
|
|
563
481
|
validate: validateForm,
|
|
@@ -581,39 +499,8 @@ function useEventEmitter() {
|
|
|
581
499
|
};
|
|
582
500
|
}
|
|
583
501
|
|
|
584
|
-
// src/utils/functions.ts
|
|
585
|
-
var getFormErrorObject = (formValues) => {
|
|
586
|
-
return {};
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
// src/utils/asyncStorage.ts
|
|
590
|
-
import NativeAsyncStorage from "@react-native-async-storage/async-storage";
|
|
591
|
-
function generateAsyncStorage() {
|
|
592
|
-
return {
|
|
593
|
-
setItem: async (name, value) => {
|
|
594
|
-
if (value) await NativeAsyncStorage.setItem(name.toString(), JSON.stringify(value));
|
|
595
|
-
else await NativeAsyncStorage.removeItem(name.toString());
|
|
596
|
-
},
|
|
597
|
-
getItem: async (name) => {
|
|
598
|
-
const item = await NativeAsyncStorage.getItem(name.toString());
|
|
599
|
-
if (item === null) return void 0;
|
|
600
|
-
try {
|
|
601
|
-
return JSON.parse(item);
|
|
602
|
-
} catch (error) {
|
|
603
|
-
return void 0;
|
|
604
|
-
}
|
|
605
|
-
},
|
|
606
|
-
removeItem: async (name) => {
|
|
607
|
-
await NativeAsyncStorage.removeItem(name.toString());
|
|
608
|
-
},
|
|
609
|
-
removeAllItems: () => {
|
|
610
|
-
NativeAsyncStorage.clear();
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
}
|
|
614
|
-
|
|
615
502
|
// src/components/View.tsx
|
|
616
|
-
import { memo
|
|
503
|
+
import { memo, useMemo as useMemo2 } from "react";
|
|
617
504
|
import {
|
|
618
505
|
View as NativeView,
|
|
619
506
|
Platform,
|
|
@@ -622,7 +509,7 @@ import {
|
|
|
622
509
|
TouchableOpacity
|
|
623
510
|
} from "react-native";
|
|
624
511
|
import { useTheme as useTheme2 } from "react-better-core";
|
|
625
|
-
import { Fragment
|
|
512
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
626
513
|
var touchableHighlightStyleMoveToContent = [
|
|
627
514
|
"width",
|
|
628
515
|
"backgroundColor",
|
|
@@ -675,7 +562,7 @@ var ViewComponent = function View({
|
|
|
675
562
|
...props
|
|
676
563
|
}) {
|
|
677
564
|
const theme2 = useTheme2();
|
|
678
|
-
const style =
|
|
565
|
+
const style = useMemo2(
|
|
679
566
|
() => ({
|
|
680
567
|
flexDirection: isRow ? "row" : "column",
|
|
681
568
|
...props,
|
|
@@ -688,7 +575,7 @@ var ViewComponent = function View({
|
|
|
688
575
|
}),
|
|
689
576
|
[isRow, props]
|
|
690
577
|
);
|
|
691
|
-
const touchableHighlightStyle =
|
|
578
|
+
const touchableHighlightStyle = useMemo2(
|
|
692
579
|
() => ({
|
|
693
580
|
...style,
|
|
694
581
|
...touchableHighlightStyleMoveToContent.reduce((previousValue, currentValue) => {
|
|
@@ -701,21 +588,21 @@ var ViewComponent = function View({
|
|
|
701
588
|
}),
|
|
702
589
|
[style]
|
|
703
590
|
);
|
|
704
|
-
const touchableHighlightContentProps =
|
|
591
|
+
const touchableHighlightContentProps = useMemo2(
|
|
705
592
|
() => touchableHighlightStyleMoveToContent.reduce((previousValue, currentValue) => {
|
|
706
593
|
previousValue[currentValue] = props[currentValue];
|
|
707
594
|
return previousValue;
|
|
708
595
|
}, {}),
|
|
709
596
|
[props]
|
|
710
597
|
);
|
|
711
|
-
const touchableNativeFeedbackHolderStyle =
|
|
598
|
+
const touchableNativeFeedbackHolderStyle = useMemo2(
|
|
712
599
|
() => touchableNativeFeedbackStyleMoveToHolder.reduce((previousValue, currentValue) => {
|
|
713
600
|
previousValue[currentValue] = props[currentValue];
|
|
714
601
|
return previousValue;
|
|
715
602
|
}, {}),
|
|
716
603
|
[props]
|
|
717
604
|
);
|
|
718
|
-
const touchableNativeFeedbackContentStyle =
|
|
605
|
+
const touchableNativeFeedbackContentStyle = useMemo2(
|
|
719
606
|
() => ({
|
|
720
607
|
...style,
|
|
721
608
|
...touchableNativeFeedbackStyleMoveToHolder.reduce(
|
|
@@ -730,7 +617,7 @@ var ViewComponent = function View({
|
|
|
730
617
|
}),
|
|
731
618
|
[style]
|
|
732
619
|
);
|
|
733
|
-
const pressEvents =
|
|
620
|
+
const pressEvents = useMemo2(
|
|
734
621
|
() => !disabled ? {
|
|
735
622
|
onPress: (event) => {
|
|
736
623
|
onPress?.(event);
|
|
@@ -744,7 +631,7 @@ var ViewComponent = function View({
|
|
|
744
631
|
);
|
|
745
632
|
const androidBoxShadow = 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;
|
|
746
633
|
const isPressable = onPress || onPressIn || onPressOut || onLongPress || onPressWithValue;
|
|
747
|
-
return isPressable ? pressType === "opacity" ? /* @__PURE__ */
|
|
634
|
+
return isPressable ? pressType === "opacity" ? /* @__PURE__ */ jsx(
|
|
748
635
|
TouchableOpacity,
|
|
749
636
|
{
|
|
750
637
|
style,
|
|
@@ -754,7 +641,7 @@ var ViewComponent = function View({
|
|
|
754
641
|
...props,
|
|
755
642
|
children
|
|
756
643
|
}
|
|
757
|
-
) : pressType === "highlight" ? Platform.OS === "ios" ? /* @__PURE__ */
|
|
644
|
+
) : pressType === "highlight" ? Platform.OS === "ios" ? /* @__PURE__ */ jsx(
|
|
758
645
|
TouchableHighlight,
|
|
759
646
|
{
|
|
760
647
|
activeOpacity: pressStrength2,
|
|
@@ -762,7 +649,7 @@ var ViewComponent = function View({
|
|
|
762
649
|
style: touchableHighlightStyle,
|
|
763
650
|
...pressEvents,
|
|
764
651
|
...props,
|
|
765
|
-
children: /* @__PURE__ */
|
|
652
|
+
children: /* @__PURE__ */ jsx(
|
|
766
653
|
ViewComponent,
|
|
767
654
|
{
|
|
768
655
|
width: "100%",
|
|
@@ -777,7 +664,7 @@ var ViewComponent = function View({
|
|
|
777
664
|
}
|
|
778
665
|
)
|
|
779
666
|
}
|
|
780
|
-
) : Platform.OS === "android" ? /* @__PURE__ */
|
|
667
|
+
) : Platform.OS === "android" ? /* @__PURE__ */ jsx(
|
|
781
668
|
ViewComponent,
|
|
782
669
|
{
|
|
783
670
|
...touchableNativeFeedbackHolderStyle,
|
|
@@ -789,7 +676,7 @@ var ViewComponent = function View({
|
|
|
789
676
|
boxShadow: androidBoxShadow,
|
|
790
677
|
overflow: "hidden",
|
|
791
678
|
pointerEvents: "box-none",
|
|
792
|
-
children: /* @__PURE__ */
|
|
679
|
+
children: /* @__PURE__ */ jsx(
|
|
793
680
|
TouchableNativeFeedback,
|
|
794
681
|
{
|
|
795
682
|
...pressEvents,
|
|
@@ -800,15 +687,15 @@ var ViewComponent = function View({
|
|
|
800
687
|
),
|
|
801
688
|
useForeground: true,
|
|
802
689
|
touchSoundDisabled: true,
|
|
803
|
-
children: /* @__PURE__ */
|
|
690
|
+
children: /* @__PURE__ */ jsx(ViewComponent, { flex: 1, ...touchableNativeFeedbackContentStyle, children })
|
|
804
691
|
}
|
|
805
692
|
)
|
|
806
693
|
}
|
|
807
|
-
) : /* @__PURE__ */
|
|
694
|
+
) : /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsx(NativeView, { boxShadow: androidBoxShadow, style, ...props, children });
|
|
808
695
|
};
|
|
809
696
|
ViewComponent.box = function Box({ withShadow, ...props }) {
|
|
810
697
|
const theme2 = useTheme2();
|
|
811
|
-
const shadowProps =
|
|
698
|
+
const shadowProps = useMemo2(
|
|
812
699
|
() => withShadow ? {
|
|
813
700
|
shadowOpacity: 0.2,
|
|
814
701
|
shadowOffsetHeight: 10,
|
|
@@ -817,7 +704,7 @@ ViewComponent.box = function Box({ withShadow, ...props }) {
|
|
|
817
704
|
} : {},
|
|
818
705
|
[]
|
|
819
706
|
);
|
|
820
|
-
return /* @__PURE__ */
|
|
707
|
+
return /* @__PURE__ */ jsx(
|
|
821
708
|
ViewComponent,
|
|
822
709
|
{
|
|
823
710
|
width: "100%",
|
|
@@ -832,18 +719,52 @@ ViewComponent.box = function Box({ withShadow, ...props }) {
|
|
|
832
719
|
}
|
|
833
720
|
);
|
|
834
721
|
};
|
|
835
|
-
var View2 =
|
|
722
|
+
var View2 = memo(ViewComponent);
|
|
836
723
|
View2.box = ViewComponent.box;
|
|
837
724
|
var View_default = View2;
|
|
838
725
|
|
|
726
|
+
// src/components/alerts/Alert.tsx
|
|
727
|
+
import { memo as memo8, useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo6, useRef as useRef2 } from "react";
|
|
728
|
+
import { useBooleanState as useBooleanState2, useTheme as useTheme8 } from "react-better-core";
|
|
729
|
+
|
|
730
|
+
// src/plugins/alerts.ts
|
|
731
|
+
var defaultAlertsPluginOptions = {
|
|
732
|
+
align: "right",
|
|
733
|
+
defaultDuration: "auto",
|
|
734
|
+
defaultDisplay: {},
|
|
735
|
+
withCloseButton: true
|
|
736
|
+
};
|
|
737
|
+
var alertsPlugin = (options) => ({
|
|
738
|
+
name: "alerts",
|
|
739
|
+
initialize: () => {
|
|
740
|
+
},
|
|
741
|
+
getConfig: () => ({
|
|
742
|
+
...defaultAlertsPluginOptions,
|
|
743
|
+
...options
|
|
744
|
+
})
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
// src/plugins/asyncStorage.ts
|
|
748
|
+
var defaultAsyncStoragePluginOptions = {};
|
|
749
|
+
var asyncStoragePlugin = (options) => ({
|
|
750
|
+
name: "asyncStorage",
|
|
751
|
+
initialize: () => {
|
|
752
|
+
console.log("asyncStorage plugin initialized");
|
|
753
|
+
},
|
|
754
|
+
getConfig: () => ({
|
|
755
|
+
...defaultAsyncStoragePluginOptions,
|
|
756
|
+
...options
|
|
757
|
+
})
|
|
758
|
+
});
|
|
759
|
+
|
|
839
760
|
// src/components/Text.tsx
|
|
840
|
-
import { memo as
|
|
761
|
+
import { memo as memo2, useMemo as useMemo3 } from "react";
|
|
841
762
|
import { Text as NativeText } from "react-native";
|
|
842
763
|
import { useTheme as useTheme3 } from "react-better-core";
|
|
843
|
-
import { jsx as
|
|
764
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
844
765
|
var TextComponent = function Text({ selectionColor, children, ...props }) {
|
|
845
766
|
const theme2 = useTheme3();
|
|
846
|
-
const style =
|
|
767
|
+
const style = useMemo3(
|
|
847
768
|
() => ({
|
|
848
769
|
fontSize: 16,
|
|
849
770
|
color: theme2.colors.textPrimary,
|
|
@@ -851,27 +772,27 @@ var TextComponent = function Text({ selectionColor, children, ...props }) {
|
|
|
851
772
|
}),
|
|
852
773
|
[theme2, props]
|
|
853
774
|
);
|
|
854
|
-
return /* @__PURE__ */
|
|
775
|
+
return /* @__PURE__ */ jsx2(NativeText, { selectionColor: selectionColor ?? theme2.colors.primary, style, ...props, children });
|
|
855
776
|
};
|
|
856
777
|
TextComponent.title = function Title(props) {
|
|
857
|
-
return /* @__PURE__ */
|
|
778
|
+
return /* @__PURE__ */ jsx2(TextComponent, { fontSize: 32, fontWeight: 700, ...props });
|
|
858
779
|
};
|
|
859
780
|
TextComponent.subtitle = function Subtitle(props) {
|
|
860
|
-
return /* @__PURE__ */
|
|
781
|
+
return /* @__PURE__ */ jsx2(TextComponent, { fontSize: 24, fontWeight: 700, ...props });
|
|
861
782
|
};
|
|
862
783
|
TextComponent.body = function Body(props) {
|
|
863
784
|
const theme2 = useTheme3();
|
|
864
|
-
return /* @__PURE__ */
|
|
785
|
+
return /* @__PURE__ */ jsx2(TextComponent, { color: theme2.colors.textSecondary, ...props });
|
|
865
786
|
};
|
|
866
787
|
TextComponent.caption = function Caption(props) {
|
|
867
788
|
const theme2 = useTheme3();
|
|
868
|
-
return /* @__PURE__ */
|
|
789
|
+
return /* @__PURE__ */ jsx2(TextComponent, { fontSize: 14, color: theme2.colors.textSecondary, ...props });
|
|
869
790
|
};
|
|
870
791
|
TextComponent.unknown = function Unknown(props) {
|
|
871
792
|
const theme2 = useTheme3();
|
|
872
|
-
return /* @__PURE__ */
|
|
793
|
+
return /* @__PURE__ */ jsx2(TextComponent, { fontStyle: "italic", textAlign: "center", color: theme2.colors.textSecondary, ...props });
|
|
873
794
|
};
|
|
874
|
-
var Text2 =
|
|
795
|
+
var Text2 = memo2(TextComponent);
|
|
875
796
|
Text2.title = TextComponent.title;
|
|
876
797
|
Text2.subtitle = TextComponent.subtitle;
|
|
877
798
|
Text2.body = TextComponent.body;
|
|
@@ -879,13 +800,116 @@ Text2.caption = TextComponent.caption;
|
|
|
879
800
|
Text2.unknown = TextComponent.unknown;
|
|
880
801
|
var Text_default = Text2;
|
|
881
802
|
|
|
882
|
-
// src/components/
|
|
883
|
-
import { memo as
|
|
803
|
+
// src/components/Icon.tsx
|
|
804
|
+
import { memo as memo3, useEffect as useEffect2 } from "react";
|
|
884
805
|
import { Platform as Platform2 } from "react-native";
|
|
885
|
-
import {
|
|
806
|
+
import { Path, Svg } from "react-native-svg";
|
|
807
|
+
import { useBetterCoreContext, useTheme as useTheme4 } from "react-better-core";
|
|
808
|
+
import { SymbolView } from "expo-symbols";
|
|
809
|
+
|
|
810
|
+
// src/utils/variableFunctions.ts
|
|
811
|
+
import { generateRandomString } from "react-better-core";
|
|
812
|
+
var checkBetterCoreContextValue = (value, functionsName) => {
|
|
813
|
+
if (value === void 0) {
|
|
814
|
+
throw new Error(
|
|
815
|
+
`\`${functionsName}()\` must be used within a \`<BetterCoreProvider>\`. Make sure to add one at the root of your component tree.`
|
|
816
|
+
);
|
|
817
|
+
}
|
|
818
|
+
return value !== void 0;
|
|
819
|
+
};
|
|
820
|
+
var checkBetterComponentsContextValue = (value, functionsName) => {
|
|
821
|
+
if (value === void 0) {
|
|
822
|
+
throw new Error(
|
|
823
|
+
`\`${functionsName}()\` must be used within a \`<BetterComponentsProvider>\`. Make sure to add one at the root of your component tree.`
|
|
824
|
+
);
|
|
825
|
+
}
|
|
826
|
+
return value !== void 0;
|
|
827
|
+
};
|
|
828
|
+
var alertControls = {
|
|
829
|
+
createAlert: (alert) => {
|
|
830
|
+
if (!checkBetterComponentsContextValue(externalBetterComponentsContextValue, "alertControls.createAlert"))
|
|
831
|
+
return void 0;
|
|
832
|
+
const readyAlert = {
|
|
833
|
+
id: generateRandomString(36),
|
|
834
|
+
...alert
|
|
835
|
+
};
|
|
836
|
+
externalBetterComponentsContextValue.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
837
|
+
return readyAlert;
|
|
838
|
+
},
|
|
839
|
+
removeAlert: (alertId) => {
|
|
840
|
+
if (!checkBetterComponentsContextValue(externalBetterComponentsContextValue, "alertControls.removeAlert"))
|
|
841
|
+
return;
|
|
842
|
+
externalBetterComponentsContextValue.setAlerts(
|
|
843
|
+
(oldValue) => oldValue.filter((alert) => alert.id !== alertId)
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
var pressStrength = () => {
|
|
848
|
+
if (!checkBetterCoreContextValue(externalBetterCoreContextValue, "pressStrength")) return void 0;
|
|
849
|
+
return {
|
|
850
|
+
p05: externalBetterCoreContextValue.colorTheme === "dark" ? 0.85 : 0.95,
|
|
851
|
+
p1: externalBetterCoreContextValue.colorTheme === "dark" ? 0.6 : 0.8,
|
|
852
|
+
p2: externalBetterCoreContextValue.colorTheme === "dark" ? 0.5 : 0.7,
|
|
853
|
+
p3: externalBetterCoreContextValue.colorTheme === "dark" ? 0.4 : 0.6
|
|
854
|
+
};
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
// src/components/Icon.tsx
|
|
858
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
859
|
+
import { createElement } from "react";
|
|
860
|
+
function Icon({ name, nameIOS, size = 16, color, ...props }) {
|
|
861
|
+
const theme2 = useTheme4();
|
|
862
|
+
const { icons: icons2 } = useBetterCoreContext();
|
|
863
|
+
const svgColor = color ?? theme2.colors.textPrimary;
|
|
864
|
+
useEffect2(() => {
|
|
865
|
+
if (!icons2[name.toString()])
|
|
866
|
+
console.warn(
|
|
867
|
+
`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.`
|
|
868
|
+
);
|
|
869
|
+
}, [icons2, name]);
|
|
870
|
+
return /* @__PURE__ */ jsx3(
|
|
871
|
+
View_default,
|
|
872
|
+
{
|
|
873
|
+
width: size + (parseFloat(props.padding?.toString() ?? "0") ?? 0) + (parseFloat(props.paddingHorizontal?.toString() ?? "0") ?? 0),
|
|
874
|
+
height: size + (parseFloat(props.padding?.toString() ?? "0") ?? 0) + (parseFloat(props.paddingVertical?.toString() ?? "0") ?? 0),
|
|
875
|
+
alignItems: "center",
|
|
876
|
+
justifyContent: "center",
|
|
877
|
+
pressType: "opacity",
|
|
878
|
+
pressStrength: pressStrength().p2,
|
|
879
|
+
...props,
|
|
880
|
+
children: Platform2.OS === "ios" && nameIOS ? /* @__PURE__ */ jsx3(SymbolView, { name: nameIOS, tintColor: svgColor, size: size * 1.12 }) : /* @__PURE__ */ jsx3(
|
|
881
|
+
Svg,
|
|
882
|
+
{
|
|
883
|
+
width: size,
|
|
884
|
+
height: size,
|
|
885
|
+
viewBox: `0 0 ${icons2[name.toString()]?.width ?? 0} ${icons2[name.toString()]?.height ?? 0}`,
|
|
886
|
+
fill: "none",
|
|
887
|
+
children: icons2[name.toString()]?.paths.map(({ type, ...path }) => /* @__PURE__ */ createElement(
|
|
888
|
+
Path,
|
|
889
|
+
{
|
|
890
|
+
...path,
|
|
891
|
+
fill: type === "fill" ? svgColor : void 0,
|
|
892
|
+
stroke: type === "stroke" ? svgColor : void 0,
|
|
893
|
+
key: path.d
|
|
894
|
+
}
|
|
895
|
+
))
|
|
896
|
+
}
|
|
897
|
+
)
|
|
898
|
+
}
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
var Icon_default = memo3(Icon);
|
|
902
|
+
|
|
903
|
+
// src/components/Button.tsx
|
|
904
|
+
import { memo as memo7, useCallback as useCallback2 } from "react";
|
|
905
|
+
import { Platform as Platform3 } from "react-native";
|
|
906
|
+
import {
|
|
907
|
+
useLoader,
|
|
908
|
+
useTheme as useTheme7
|
|
909
|
+
} from "react-better-core";
|
|
886
910
|
|
|
887
911
|
// src/components/Animate.tsx
|
|
888
|
-
import { memo as memo4, useMemo as
|
|
912
|
+
import { memo as memo4, useMemo as useMemo4 } from "react";
|
|
889
913
|
import { Motion } from "@legendapp/motion";
|
|
890
914
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
891
915
|
var defaultTransitionDuration = 0.15 * 1e3;
|
|
@@ -895,7 +919,7 @@ var Animate = {
|
|
|
895
919
|
const animateProps2 = useComponentPropsGrouper(props, "animate");
|
|
896
920
|
const whileTapProps = useComponentPropsGrouper(props, "whileTap");
|
|
897
921
|
const transitionProps = useComponentPropsGrouper(props, "transition");
|
|
898
|
-
const transition =
|
|
922
|
+
const transition = useMemo4(
|
|
899
923
|
() => ({
|
|
900
924
|
type: "timing",
|
|
901
925
|
duration: defaultTransitionDuration,
|
|
@@ -903,7 +927,7 @@ var Animate = {
|
|
|
903
927
|
}),
|
|
904
928
|
[transitionProps.withPrefixStyle]
|
|
905
929
|
);
|
|
906
|
-
const transformOrigin =
|
|
930
|
+
const transformOrigin = useMemo4(
|
|
907
931
|
() => transformOriginX !== void 0 || transformOriginY !== void 0 ? {
|
|
908
932
|
x: transformOriginX ?? 0,
|
|
909
933
|
y: transformOriginY ?? 0
|
|
@@ -929,7 +953,7 @@ var Animate = {
|
|
|
929
953
|
const animateProps2 = useComponentPropsGrouper(props, "animate");
|
|
930
954
|
const whileTapProps = useComponentPropsGrouper(props, "whileTap");
|
|
931
955
|
const transitionProps = useComponentPropsGrouper(props, "transition");
|
|
932
|
-
const transition =
|
|
956
|
+
const transition = useMemo4(
|
|
933
957
|
() => ({
|
|
934
958
|
type: "timing",
|
|
935
959
|
duration: defaultTransitionDuration,
|
|
@@ -937,7 +961,7 @@ var Animate = {
|
|
|
937
961
|
}),
|
|
938
962
|
[transitionProps.withPrefixStyle]
|
|
939
963
|
);
|
|
940
|
-
const transformOrigin =
|
|
964
|
+
const transformOrigin = useMemo4(
|
|
941
965
|
() => transformOriginX !== void 0 || transformOriginY !== void 0 ? {
|
|
942
966
|
x: transformOriginX ?? 0,
|
|
943
967
|
y: transformOriginY ?? 0
|
|
@@ -964,14 +988,14 @@ var Animate_default = Animate;
|
|
|
964
988
|
// src/components/Loader.tsx
|
|
965
989
|
import { memo as memo5 } from "react";
|
|
966
990
|
import { ActivityIndicator } from "react-native";
|
|
967
|
-
import { useTheme as
|
|
991
|
+
import { useTheme as useTheme5 } from "react-better-core";
|
|
968
992
|
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
969
993
|
var LoaderComponent = function Loader({ size = "small", color, ...props }) {
|
|
970
|
-
const theme2 =
|
|
994
|
+
const theme2 = useTheme5();
|
|
971
995
|
return /* @__PURE__ */ jsx5(View_default, { ...props, children: /* @__PURE__ */ jsx5(ActivityIndicator, { size, color: color ?? theme2.colors.textPrimary }) });
|
|
972
996
|
};
|
|
973
997
|
LoaderComponent.box = function Box2({ text = "Loading...", size = "large", color, ...props }) {
|
|
974
|
-
const theme2 =
|
|
998
|
+
const theme2 = useTheme5();
|
|
975
999
|
return /* @__PURE__ */ jsxs(
|
|
976
1000
|
View_default,
|
|
977
1001
|
{
|
|
@@ -988,7 +1012,7 @@ LoaderComponent.box = function Box2({ text = "Loading...", size = "large", color
|
|
|
988
1012
|
);
|
|
989
1013
|
};
|
|
990
1014
|
LoaderComponent.text = function LoaderText({ text = "Loading...", size, color, ...props }) {
|
|
991
|
-
const theme2 =
|
|
1015
|
+
const theme2 = useTheme5();
|
|
992
1016
|
return /* @__PURE__ */ jsxs(
|
|
993
1017
|
View_default,
|
|
994
1018
|
{
|
|
@@ -1010,21 +1034,92 @@ Loader2.box = LoaderComponent.box;
|
|
|
1010
1034
|
Loader2.text = LoaderComponent.text;
|
|
1011
1035
|
var Loader_default = Loader2;
|
|
1012
1036
|
|
|
1013
|
-
// src/components/
|
|
1014
|
-
import {
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1037
|
+
// src/components/Image.tsx
|
|
1038
|
+
import { memo as memo6, useEffect as useEffect3, useMemo as useMemo5 } from "react";
|
|
1039
|
+
import { useBetterCoreContext as useBetterCoreContext2, useTheme as useTheme6 } from "react-better-core";
|
|
1040
|
+
import {
|
|
1041
|
+
Image as NativeImage
|
|
1042
|
+
} from "react-native";
|
|
1043
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1044
|
+
var ImageComponent = function Image({ name, source, withDevFittingMode, ...props }) {
|
|
1045
|
+
const { assets: assets2 } = useBetterCoreContext2();
|
|
1046
|
+
const style = useMemo5(
|
|
1047
|
+
() => ({
|
|
1048
|
+
width: 100,
|
|
1049
|
+
height: 100,
|
|
1050
|
+
...withDevFittingMode ? {
|
|
1051
|
+
borderWidth: 1,
|
|
1052
|
+
borderColor: "#eb39f7"
|
|
1053
|
+
} : {},
|
|
1054
|
+
...props
|
|
1055
|
+
}),
|
|
1056
|
+
[withDevFittingMode, props]
|
|
1057
|
+
);
|
|
1058
|
+
useEffect3(() => {
|
|
1059
|
+
if (!name) return;
|
|
1060
|
+
if (!assets2[name.toString()])
|
|
1061
|
+
console.warn(
|
|
1062
|
+
`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.`
|
|
1063
|
+
);
|
|
1064
|
+
}, [assets2, name]);
|
|
1065
|
+
return /* @__PURE__ */ jsx6(NativeImage, { source: name ? assets2[name.toString()] : source, style, ...props });
|
|
1066
|
+
};
|
|
1067
|
+
ImageComponent.profileImage = function ProfileImage({
|
|
1068
|
+
size = 50,
|
|
1069
|
+
letters,
|
|
1070
|
+
color,
|
|
1071
|
+
backgroundColor,
|
|
1072
|
+
...props
|
|
1073
|
+
}) {
|
|
1074
|
+
const theme2 = useTheme6();
|
|
1075
|
+
return letters ? /* @__PURE__ */ jsx6(
|
|
1076
|
+
View_default,
|
|
1077
|
+
{
|
|
1078
|
+
width: size,
|
|
1079
|
+
height: size,
|
|
1080
|
+
backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
|
|
1081
|
+
borderWidth: 1,
|
|
1082
|
+
borderColor: theme2.colors.border,
|
|
1083
|
+
borderRadius: 999,
|
|
1084
|
+
alignItems: "center",
|
|
1085
|
+
justifyContent: "center",
|
|
1086
|
+
...props,
|
|
1087
|
+
children: /* @__PURE__ */ jsx6(Text_default, { fontSize: size / 2.5, fontWeight: 700, color: color ?? theme2.colors.textPrimary, marginTop: 1, children: letters.toUpperCase().slice(0, 2) })
|
|
1088
|
+
}
|
|
1089
|
+
) : /* @__PURE__ */ jsx6(
|
|
1090
|
+
ImageComponent,
|
|
1091
|
+
{
|
|
1092
|
+
width: size,
|
|
1093
|
+
height: size,
|
|
1094
|
+
borderWidth: 1,
|
|
1095
|
+
borderColor: theme2.colors.border,
|
|
1096
|
+
borderRadius: 999,
|
|
1097
|
+
objectFit: "cover",
|
|
1098
|
+
...props
|
|
1099
|
+
}
|
|
1100
|
+
);
|
|
1101
|
+
};
|
|
1102
|
+
var Image2 = memo6(ImageComponent);
|
|
1103
|
+
Image2.profileImage = ImageComponent.profileImage;
|
|
1104
|
+
var Image_default = Image2;
|
|
1105
|
+
|
|
1106
|
+
// src/components/Button.tsx
|
|
1107
|
+
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1108
|
+
var ButtonComponent = function Button({
|
|
1109
|
+
value,
|
|
1110
|
+
text,
|
|
1111
|
+
textFontSize = 16,
|
|
1112
|
+
textFontWeight = 700,
|
|
1113
|
+
textDecorationLine,
|
|
1114
|
+
textColor,
|
|
1115
|
+
icon,
|
|
1116
|
+
iconIOS,
|
|
1117
|
+
iconPosition = "left",
|
|
1118
|
+
iconColor,
|
|
1119
|
+
iconSize,
|
|
1120
|
+
image,
|
|
1121
|
+
imagePosition = "left",
|
|
1122
|
+
imageWidth,
|
|
1028
1123
|
imageHeight,
|
|
1029
1124
|
loaderName,
|
|
1030
1125
|
isLoading,
|
|
@@ -1033,9 +1128,11 @@ var ButtonComponent = function Button({
|
|
|
1033
1128
|
flex,
|
|
1034
1129
|
alignSelf,
|
|
1035
1130
|
disabled,
|
|
1131
|
+
onPress,
|
|
1132
|
+
onPressWithValue,
|
|
1036
1133
|
...props
|
|
1037
1134
|
}) {
|
|
1038
|
-
const theme2 =
|
|
1135
|
+
const theme2 = useTheme7();
|
|
1039
1136
|
const isLoadingLoader = useLoader(loaderName);
|
|
1040
1137
|
const isLoadingElement = isLoading || isLoadingLoader;
|
|
1041
1138
|
const isDisabled = disabled || isLoadingElement;
|
|
@@ -1044,7 +1141,24 @@ var ButtonComponent = function Button({
|
|
|
1044
1141
|
const paddingVertical = props.paddingVertical ? parseFloat(props.paddingVertical.toString()) : theme2.styles.space;
|
|
1045
1142
|
const paddingHorizontal = props.paddingHorizontal ? parseFloat(props.paddingHorizontal.toString()) : theme2.styles.space + theme2.styles.gap;
|
|
1046
1143
|
const buttonHeight = paddingVertical + lineHeight + paddingVertical;
|
|
1047
|
-
|
|
1144
|
+
const onPressElement = useCallback2(
|
|
1145
|
+
(event) => {
|
|
1146
|
+
onPress?.(event);
|
|
1147
|
+
onPressWithValue?.(value);
|
|
1148
|
+
},
|
|
1149
|
+
[onPress, onPressWithValue, value]
|
|
1150
|
+
);
|
|
1151
|
+
const iconComponent = icon ? /* @__PURE__ */ jsx7(View_default, { height: 20, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsx7(
|
|
1152
|
+
Icon_default,
|
|
1153
|
+
{
|
|
1154
|
+
name: icon,
|
|
1155
|
+
nameIOS: iconIOS,
|
|
1156
|
+
color: iconColor ?? textColor ?? theme2.colors.base,
|
|
1157
|
+
size: iconSize ?? textFontSize ?? 16
|
|
1158
|
+
}
|
|
1159
|
+
) }) : void 0;
|
|
1160
|
+
const imageComponent = image ? /* @__PURE__ */ jsx7(Image_default, { name: image, width: imageWidth ?? textFontSize ?? 16, height: imageHeight }) : void 0;
|
|
1161
|
+
return /* @__PURE__ */ jsx7(
|
|
1048
1162
|
Animate_default.View,
|
|
1049
1163
|
{
|
|
1050
1164
|
position: "relative",
|
|
@@ -1057,7 +1171,7 @@ var ButtonComponent = function Button({
|
|
|
1057
1171
|
{
|
|
1058
1172
|
position: "relative",
|
|
1059
1173
|
width: !isSmall ? "100%" : void 0,
|
|
1060
|
-
height:
|
|
1174
|
+
height: Platform3.OS === "android" ? buttonHeight : void 0,
|
|
1061
1175
|
alignItems: "center",
|
|
1062
1176
|
justifyContent: "center",
|
|
1063
1177
|
backgroundColor: theme2.colors.primary,
|
|
@@ -1065,22 +1179,29 @@ var ButtonComponent = function Button({
|
|
|
1065
1179
|
paddingVertical,
|
|
1066
1180
|
paddingHorizontal,
|
|
1067
1181
|
disabled: isDisabled,
|
|
1182
|
+
onPress: onPressElement,
|
|
1068
1183
|
...props,
|
|
1069
1184
|
children: [
|
|
1070
|
-
/* @__PURE__ */
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1185
|
+
/* @__PURE__ */ jsx7(Animate_default.View, { initialOpacity: 1, animateOpacity: isLoadingElement ? 0 : 1, children: /* @__PURE__ */ jsxs2(View_default, { isRow: true, alignItems: "center", justifyContent: "center", gap: theme2.styles.gap, children: [
|
|
1186
|
+
iconPosition === "left" && iconComponent,
|
|
1187
|
+
imagePosition === "left" && imageComponent,
|
|
1188
|
+
text && /* @__PURE__ */ jsx7(
|
|
1189
|
+
Text_default,
|
|
1190
|
+
{
|
|
1191
|
+
fontSize: textFontSize,
|
|
1192
|
+
fontWeight: textFontWeight,
|
|
1193
|
+
textDecorationLine,
|
|
1194
|
+
textDecorationColor: color,
|
|
1195
|
+
textAlign: "center",
|
|
1196
|
+
lineHeight,
|
|
1197
|
+
color,
|
|
1198
|
+
children: text
|
|
1199
|
+
}
|
|
1200
|
+
),
|
|
1201
|
+
iconPosition === "right" && iconComponent,
|
|
1202
|
+
imagePosition === "right" && imageComponent
|
|
1203
|
+
] }) }),
|
|
1204
|
+
/* @__PURE__ */ jsx7(
|
|
1084
1205
|
Animate_default.View,
|
|
1085
1206
|
{
|
|
1086
1207
|
position: "absolute",
|
|
@@ -1091,7 +1212,7 @@ var ButtonComponent = function Button({
|
|
|
1091
1212
|
justifyContent: "center",
|
|
1092
1213
|
initialOpacity: 0,
|
|
1093
1214
|
animateOpacity: isLoadingElement ? 1 : 0,
|
|
1094
|
-
children: /* @__PURE__ */
|
|
1215
|
+
children: /* @__PURE__ */ jsx7(Loader_default, { color })
|
|
1095
1216
|
}
|
|
1096
1217
|
)
|
|
1097
1218
|
]
|
|
@@ -1101,8 +1222,8 @@ var ButtonComponent = function Button({
|
|
|
1101
1222
|
);
|
|
1102
1223
|
};
|
|
1103
1224
|
ButtonComponent.secondary = function Secondary(props) {
|
|
1104
|
-
const theme2 =
|
|
1105
|
-
return /* @__PURE__ */
|
|
1225
|
+
const theme2 = useTheme7();
|
|
1226
|
+
return /* @__PURE__ */ jsx7(
|
|
1106
1227
|
ButtonComponent,
|
|
1107
1228
|
{
|
|
1108
1229
|
backgroundColor: theme2.colors.backgroundContent,
|
|
@@ -1116,15 +1237,16 @@ ButtonComponent.secondary = function Secondary(props) {
|
|
|
1116
1237
|
);
|
|
1117
1238
|
};
|
|
1118
1239
|
ButtonComponent.destructive = function Destructive(props) {
|
|
1119
|
-
const theme2 =
|
|
1120
|
-
return /* @__PURE__ */
|
|
1240
|
+
const theme2 = useTheme7();
|
|
1241
|
+
return /* @__PURE__ */ jsx7(ButtonComponent, { backgroundColor: theme2.colors.error, ...props });
|
|
1121
1242
|
};
|
|
1122
1243
|
ButtonComponent.text = function ButtonText(props) {
|
|
1123
|
-
const theme2 =
|
|
1124
|
-
return /* @__PURE__ */
|
|
1244
|
+
const theme2 = useTheme7();
|
|
1245
|
+
return /* @__PURE__ */ jsx7(
|
|
1125
1246
|
ButtonComponent,
|
|
1126
1247
|
{
|
|
1127
1248
|
width: "auto",
|
|
1249
|
+
textFontWeight: 400,
|
|
1128
1250
|
textColor: theme2.colors.textPrimary,
|
|
1129
1251
|
textDecorationLine: "underline",
|
|
1130
1252
|
backgroundColor: "transparent",
|
|
@@ -1136,17 +1258,323 @@ ButtonComponent.text = function ButtonText(props) {
|
|
|
1136
1258
|
}
|
|
1137
1259
|
);
|
|
1138
1260
|
};
|
|
1139
|
-
|
|
1261
|
+
ButtonComponent.icon = function ButtonIcon({ size = 16, ...props }) {
|
|
1262
|
+
const theme2 = useTheme7();
|
|
1263
|
+
const buttonSize = size + theme2.styles.space;
|
|
1264
|
+
return /* @__PURE__ */ jsx7(
|
|
1265
|
+
ButtonComponent,
|
|
1266
|
+
{
|
|
1267
|
+
width: buttonSize,
|
|
1268
|
+
height: buttonSize,
|
|
1269
|
+
textColor: theme2.colors.textPrimary,
|
|
1270
|
+
backgroundColor: "transparent",
|
|
1271
|
+
hitSlop: theme2.styles.gap / 2,
|
|
1272
|
+
borderRadius: 999,
|
|
1273
|
+
iconSize: size,
|
|
1274
|
+
paddingVertical: 0,
|
|
1275
|
+
paddingHorizontal: 0,
|
|
1276
|
+
pressType: "opacity",
|
|
1277
|
+
...props
|
|
1278
|
+
}
|
|
1279
|
+
);
|
|
1280
|
+
};
|
|
1281
|
+
var Button2 = memo7(ButtonComponent);
|
|
1140
1282
|
Button2.secondary = ButtonComponent.secondary;
|
|
1141
1283
|
Button2.destructive = ButtonComponent.destructive;
|
|
1142
1284
|
Button2.text = ButtonComponent.text;
|
|
1285
|
+
Button2.icon = ButtonComponent.icon;
|
|
1143
1286
|
var Button_default = Button2;
|
|
1144
1287
|
|
|
1288
|
+
// src/components/alerts/Alert.tsx
|
|
1289
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1290
|
+
var getAlertDurationFromAuto = (duration, alert) => {
|
|
1291
|
+
if (duration === "auto") {
|
|
1292
|
+
const titleLength = alert.title?.length ?? 0;
|
|
1293
|
+
const messageLength = alert.message?.length ?? 0;
|
|
1294
|
+
return Math.max(defaultAlertDuration, (titleLength + messageLength) * 30);
|
|
1295
|
+
}
|
|
1296
|
+
return duration;
|
|
1297
|
+
};
|
|
1298
|
+
function Alert({ alert }) {
|
|
1299
|
+
const theme2 = useTheme8();
|
|
1300
|
+
const alertControls2 = useAlertControls();
|
|
1301
|
+
const alertsPlugin2 = usePlugin("alerts");
|
|
1302
|
+
const pluginConfig = alertsPlugin2?.getConfig() ?? {};
|
|
1303
|
+
const defaultAlertDurationNumber = getAlertDurationFromAuto(
|
|
1304
|
+
alert.duration ?? pluginConfig.defaultDuration ?? defaultAlertsPluginOptions.defaultDuration,
|
|
1305
|
+
alert
|
|
1306
|
+
);
|
|
1307
|
+
const defaultAlertDisplay = alert.display ?? pluginConfig.defaultDisplay?.[alert.type] ?? defaultAlertsPluginOptions.defaultDisplay[alert.type] ?? "default";
|
|
1308
|
+
const calledOnCloseRef = useRef2(false);
|
|
1309
|
+
const [isRemoved, setIsRemoved] = useBooleanState2();
|
|
1310
|
+
const onPressCloseAlert = useCallback3(() => {
|
|
1311
|
+
setIsRemoved.setTrue();
|
|
1312
|
+
setTimeout(() => {
|
|
1313
|
+
alertControls2.removeAlert(alert.id);
|
|
1314
|
+
if (!calledOnCloseRef.current) {
|
|
1315
|
+
alert.onClose?.(alert);
|
|
1316
|
+
calledOnCloseRef.current = true;
|
|
1317
|
+
}
|
|
1318
|
+
}, defaultTransitionDuration);
|
|
1319
|
+
}, [alert]);
|
|
1320
|
+
const alertData = useMemo6(
|
|
1321
|
+
() => ({
|
|
1322
|
+
info: {
|
|
1323
|
+
icon: "infoI",
|
|
1324
|
+
iconIOS: "info",
|
|
1325
|
+
backgroundColor: theme2.colors.info,
|
|
1326
|
+
title: "Info"
|
|
1327
|
+
},
|
|
1328
|
+
success: {
|
|
1329
|
+
icon: "check",
|
|
1330
|
+
backgroundColor: theme2.colors.success,
|
|
1331
|
+
title: "Success"
|
|
1332
|
+
},
|
|
1333
|
+
warning: {
|
|
1334
|
+
icon: "warningTriangle",
|
|
1335
|
+
backgroundColor: theme2.colors.warn,
|
|
1336
|
+
title: "Warning"
|
|
1337
|
+
},
|
|
1338
|
+
error: {
|
|
1339
|
+
icon: "XMark",
|
|
1340
|
+
backgroundColor: theme2.colors.error,
|
|
1341
|
+
title: "Error"
|
|
1342
|
+
}
|
|
1343
|
+
}),
|
|
1344
|
+
[theme2]
|
|
1345
|
+
);
|
|
1346
|
+
useEffect4(() => {
|
|
1347
|
+
const timeout = setTimeout(onPressCloseAlert, defaultAlertDurationNumber);
|
|
1348
|
+
return () => {
|
|
1349
|
+
clearTimeout(timeout);
|
|
1350
|
+
};
|
|
1351
|
+
}, [onPressCloseAlert, defaultAlertDurationNumber]);
|
|
1352
|
+
return defaultAlertDisplay === "prominent" ? /* @__PURE__ */ jsx8(Fragment2, {}) : /* @__PURE__ */ jsx8(
|
|
1353
|
+
Animate_default.View,
|
|
1354
|
+
{
|
|
1355
|
+
initialOpacity: 0,
|
|
1356
|
+
animateOpacity: isRemoved ? 0 : 1,
|
|
1357
|
+
initialX: 40,
|
|
1358
|
+
animateX: isRemoved ? 40 : 0,
|
|
1359
|
+
children: /* @__PURE__ */ jsx8(View_default.box, { width: "auto", withShadow: true, children: /* @__PURE__ */ jsxs3(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.space, children: [
|
|
1360
|
+
/* @__PURE__ */ jsx8(
|
|
1361
|
+
View_default,
|
|
1362
|
+
{
|
|
1363
|
+
alignItems: "center",
|
|
1364
|
+
justifyContent: "center",
|
|
1365
|
+
backgroundColor: alertData[alert.type].backgroundColor,
|
|
1366
|
+
borderRadius: 999,
|
|
1367
|
+
padding: (theme2.styles.space + theme2.styles.gap) / 2,
|
|
1368
|
+
children: /* @__PURE__ */ jsx8(
|
|
1369
|
+
Icon_default,
|
|
1370
|
+
{
|
|
1371
|
+
name: alertData[alert.type].icon,
|
|
1372
|
+
color: alertData[alert.type].iconColor ?? theme2.colors.base
|
|
1373
|
+
}
|
|
1374
|
+
)
|
|
1375
|
+
}
|
|
1376
|
+
),
|
|
1377
|
+
/* @__PURE__ */ jsxs3(View_default, { children: [
|
|
1378
|
+
/* @__PURE__ */ jsx8(Text_default, { fontSize: 18, fontWeight: 700, children: alert.title ?? alertData[alert.type].title }),
|
|
1379
|
+
/* @__PURE__ */ jsx8(Text_default.body, { children: alert.message })
|
|
1380
|
+
] }),
|
|
1381
|
+
pluginConfig.withCloseButton && /* @__PURE__ */ jsx8(Button_default.icon, { icon: "XMark", onPress: onPressCloseAlert })
|
|
1382
|
+
] }) })
|
|
1383
|
+
}
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
var Alert_default = memo8(Alert);
|
|
1387
|
+
|
|
1388
|
+
// src/components/alerts/AlertsHolder.tsx
|
|
1389
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1390
|
+
function AlertsHolder() {
|
|
1391
|
+
const theme2 = useTheme9();
|
|
1392
|
+
const device = useDevice();
|
|
1393
|
+
const alertsPlugin2 = usePlugin("alerts");
|
|
1394
|
+
const { alerts } = useBetterComponentsContextInternal();
|
|
1395
|
+
const pluginConfig = alertsPlugin2?.getConfig() ?? {};
|
|
1396
|
+
return /* @__PURE__ */ jsx9(
|
|
1397
|
+
View_default,
|
|
1398
|
+
{
|
|
1399
|
+
position: "absolute",
|
|
1400
|
+
width: "100%",
|
|
1401
|
+
top: device.safeArea.afterCalculations.top + theme2.styles.gap / 2,
|
|
1402
|
+
left: 0,
|
|
1403
|
+
gap: theme2.styles.gap,
|
|
1404
|
+
alignItems: pluginConfig.align === "left" ? "flex-start" : pluginConfig.align === "center" ? "center" : pluginConfig.align === "right" ? "flex-end" : void 0,
|
|
1405
|
+
paddingHorizontal: theme2.styles.space,
|
|
1406
|
+
pointerEvents: "box-none",
|
|
1407
|
+
zIndex: 1e3,
|
|
1408
|
+
children: alerts.map((alert) => /* @__PURE__ */ jsx9(Alert_default, { alert }, alert.id))
|
|
1409
|
+
}
|
|
1410
|
+
);
|
|
1411
|
+
}
|
|
1412
|
+
var AlertsHolder_default = memo9(AlertsHolder);
|
|
1413
|
+
|
|
1414
|
+
// src/components/BetterComponentsProvider.tsx
|
|
1415
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1416
|
+
var betterComponentsContext = createContext(void 0);
|
|
1417
|
+
var externalBetterCoreContextValue;
|
|
1418
|
+
var externalBetterComponentsContextValue;
|
|
1419
|
+
var useBetterComponentsContext = () => {
|
|
1420
|
+
const coreContext = useBetterCoreContext3();
|
|
1421
|
+
const context = useContext(betterComponentsContext);
|
|
1422
|
+
if (context === void 0)
|
|
1423
|
+
throw new Error(
|
|
1424
|
+
"`useBetterComponentsContext()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1425
|
+
);
|
|
1426
|
+
const { plugins, componentsState, ...rest } = context;
|
|
1427
|
+
return {
|
|
1428
|
+
...coreContext,
|
|
1429
|
+
...rest
|
|
1430
|
+
};
|
|
1431
|
+
};
|
|
1432
|
+
var useBetterComponentsContextInternal = () => {
|
|
1433
|
+
const context = useContext(betterComponentsContext);
|
|
1434
|
+
if (context === void 0)
|
|
1435
|
+
throw new Error(
|
|
1436
|
+
"`useBetterComponentsContextInternal()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1437
|
+
);
|
|
1438
|
+
return context;
|
|
1439
|
+
};
|
|
1440
|
+
var useAlertControls = () => {
|
|
1441
|
+
const context = useContext(betterComponentsContext);
|
|
1442
|
+
if (context === void 0)
|
|
1443
|
+
throw new Error(
|
|
1444
|
+
"`useAlertControls()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1445
|
+
);
|
|
1446
|
+
const createAlert = useCallback4((alert) => {
|
|
1447
|
+
const readyAlert = {
|
|
1448
|
+
id: generateRandomString2(36),
|
|
1449
|
+
...alert
|
|
1450
|
+
};
|
|
1451
|
+
context.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
1452
|
+
return readyAlert;
|
|
1453
|
+
}, []);
|
|
1454
|
+
const removeAlert = useCallback4((alertId) => {
|
|
1455
|
+
context.setAlerts((oldValue) => oldValue.filter((alert) => alert.id !== alertId));
|
|
1456
|
+
}, []);
|
|
1457
|
+
return {
|
|
1458
|
+
createAlert,
|
|
1459
|
+
removeAlert
|
|
1460
|
+
};
|
|
1461
|
+
};
|
|
1462
|
+
var usePlugin = (pluginName) => {
|
|
1463
|
+
const context = useContext(betterComponentsContext);
|
|
1464
|
+
if (context === void 0) {
|
|
1465
|
+
throw new Error(
|
|
1466
|
+
"`usePlugin()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
return useMemo7(
|
|
1470
|
+
() => context.plugins.find((plugin) => plugin.name === pluginName),
|
|
1471
|
+
[context.plugins, pluginName]
|
|
1472
|
+
);
|
|
1473
|
+
};
|
|
1474
|
+
function BetterComponentsProviderInternalContent({ children }) {
|
|
1475
|
+
const alertsPlugin2 = usePlugin("alerts");
|
|
1476
|
+
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
1477
|
+
children,
|
|
1478
|
+
alertsPlugin2 && /* @__PURE__ */ jsx10(AlertsHolder_default, {})
|
|
1479
|
+
] });
|
|
1480
|
+
}
|
|
1481
|
+
function BetterComponentsProviderInternal({
|
|
1482
|
+
config,
|
|
1483
|
+
plugins,
|
|
1484
|
+
children
|
|
1485
|
+
}) {
|
|
1486
|
+
const betterCoreContext = useBetterCoreContext3();
|
|
1487
|
+
const [alerts, setAlerts] = useState2([]);
|
|
1488
|
+
const readyConfig = useMemo7(
|
|
1489
|
+
() => ({
|
|
1490
|
+
app: {
|
|
1491
|
+
...appConfig,
|
|
1492
|
+
...config?.app
|
|
1493
|
+
},
|
|
1494
|
+
alerts,
|
|
1495
|
+
setAlerts,
|
|
1496
|
+
plugins: plugins ?? [],
|
|
1497
|
+
componentsState: {}
|
|
1498
|
+
}),
|
|
1499
|
+
[config, alerts, plugins]
|
|
1500
|
+
);
|
|
1501
|
+
useEffect5(() => {
|
|
1502
|
+
if (!plugins) return;
|
|
1503
|
+
plugins.forEach((plugin) => {
|
|
1504
|
+
plugin.initialize?.();
|
|
1505
|
+
});
|
|
1506
|
+
}, []);
|
|
1507
|
+
externalBetterCoreContextValue = betterCoreContext;
|
|
1508
|
+
externalBetterComponentsContextValue = readyConfig;
|
|
1509
|
+
return /* @__PURE__ */ jsx10(betterComponentsContext.Provider, { value: readyConfig, children: /* @__PURE__ */ jsx10(BetterComponentsProviderInternalContent, { children }) });
|
|
1510
|
+
}
|
|
1511
|
+
function BetterComponentsProvider({ config, ...props }) {
|
|
1512
|
+
const coreConfig = useMemo7(
|
|
1513
|
+
() => ({
|
|
1514
|
+
theme: {
|
|
1515
|
+
...theme,
|
|
1516
|
+
...config?.theme
|
|
1517
|
+
},
|
|
1518
|
+
// colorTheme: config?.colorTheme ?? (localStorage.getItem("theme") === "dark" ? "dark" : "light"),
|
|
1519
|
+
colorTheme: config?.colorTheme ?? "light",
|
|
1520
|
+
icons: {
|
|
1521
|
+
...icons,
|
|
1522
|
+
...config?.icons
|
|
1523
|
+
},
|
|
1524
|
+
assets: {
|
|
1525
|
+
...assets,
|
|
1526
|
+
...config?.assets
|
|
1527
|
+
},
|
|
1528
|
+
loaders: config?.loaders
|
|
1529
|
+
}),
|
|
1530
|
+
[config]
|
|
1531
|
+
);
|
|
1532
|
+
const componentsConfig = useMemo7(
|
|
1533
|
+
() => ({
|
|
1534
|
+
app: config?.app
|
|
1535
|
+
}),
|
|
1536
|
+
[config]
|
|
1537
|
+
);
|
|
1538
|
+
return /* @__PURE__ */ jsx10(BetterCoreProvider, { config: coreConfig, children: /* @__PURE__ */ jsx10(BetterComponentsProviderInternal, { config: componentsConfig, ...props }) });
|
|
1539
|
+
}
|
|
1540
|
+
var BetterComponentsProvider_default = memo10(BetterComponentsProvider);
|
|
1541
|
+
|
|
1542
|
+
// src/utils/functions.ts
|
|
1543
|
+
var getFormErrorObject = (formValues) => {
|
|
1544
|
+
return {};
|
|
1545
|
+
};
|
|
1546
|
+
|
|
1547
|
+
// src/utils/asyncStorage.ts
|
|
1548
|
+
import NativeAsyncStorage from "@react-native-async-storage/async-storage";
|
|
1549
|
+
function generateAsyncStorage() {
|
|
1550
|
+
return {
|
|
1551
|
+
setItem: async (name, value) => {
|
|
1552
|
+
if (value) await NativeAsyncStorage.setItem(name.toString(), JSON.stringify(value));
|
|
1553
|
+
else await NativeAsyncStorage.removeItem(name.toString());
|
|
1554
|
+
},
|
|
1555
|
+
getItem: async (name) => {
|
|
1556
|
+
const item = await NativeAsyncStorage.getItem(name.toString());
|
|
1557
|
+
if (item === null) return void 0;
|
|
1558
|
+
try {
|
|
1559
|
+
return JSON.parse(item);
|
|
1560
|
+
} catch (error) {
|
|
1561
|
+
return void 0;
|
|
1562
|
+
}
|
|
1563
|
+
},
|
|
1564
|
+
removeItem: async (name) => {
|
|
1565
|
+
await NativeAsyncStorage.removeItem(name.toString());
|
|
1566
|
+
},
|
|
1567
|
+
removeAllItems: () => {
|
|
1568
|
+
NativeAsyncStorage.clear();
|
|
1569
|
+
}
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1145
1573
|
// src/components/ScreenHolder.tsx
|
|
1146
|
-
import { memo as
|
|
1147
|
-
import { KeyboardAvoidingView, Platform as
|
|
1148
|
-
import { useBooleanState as useBooleanState3, useTheme as
|
|
1149
|
-
import { jsx as
|
|
1574
|
+
import { memo as memo11, useCallback as useCallback5, useMemo as useMemo8 } from "react";
|
|
1575
|
+
import { KeyboardAvoidingView, Platform as Platform4, RefreshControl, ScrollView } from "react-native";
|
|
1576
|
+
import { useBooleanState as useBooleanState3, useTheme as useTheme10 } from "react-better-core";
|
|
1577
|
+
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1150
1578
|
var ScreenHolderComponent = ({
|
|
1151
1579
|
noScroll,
|
|
1152
1580
|
noSideSpace,
|
|
@@ -1163,17 +1591,17 @@ var ScreenHolderComponent = ({
|
|
|
1163
1591
|
withNoHeader,
|
|
1164
1592
|
children
|
|
1165
1593
|
}) => {
|
|
1166
|
-
const theme2 =
|
|
1594
|
+
const theme2 = useTheme10();
|
|
1167
1595
|
const device = useDevice();
|
|
1168
1596
|
const keyboard = useKeyboard();
|
|
1169
1597
|
const [isRefreshing, setIsRefreshing] = useBooleanState3();
|
|
1170
|
-
const keyboardAvoidingViewStyle =
|
|
1598
|
+
const keyboardAvoidingViewStyle = useMemo8(
|
|
1171
1599
|
() => ({
|
|
1172
1600
|
flex: 1
|
|
1173
1601
|
}),
|
|
1174
1602
|
[]
|
|
1175
1603
|
);
|
|
1176
|
-
const onRefreshElement =
|
|
1604
|
+
const onRefreshElement = useCallback5(() => {
|
|
1177
1605
|
setIsRefreshing.setTrue();
|
|
1178
1606
|
onRefresh?.();
|
|
1179
1607
|
setTimeout(() => {
|
|
@@ -1181,36 +1609,36 @@ var ScreenHolderComponent = ({
|
|
|
1181
1609
|
onRefreshEnd?.();
|
|
1182
1610
|
}, refreshTimeout * 1e3);
|
|
1183
1611
|
}, [onRefresh, onRefreshEnd, refreshTimeout]);
|
|
1184
|
-
const content = /* @__PURE__ */
|
|
1612
|
+
const content = /* @__PURE__ */ jsx11(
|
|
1185
1613
|
View_default,
|
|
1186
1614
|
{
|
|
1187
1615
|
flex: 1,
|
|
1188
1616
|
paddingHorizontal: !noSideSpace ? theme2.styles.space : void 0,
|
|
1189
1617
|
paddingTop: theme2.styles.gap + (insideTopSafeArea ? device.safeArea.afterCalculations.top : 0),
|
|
1190
|
-
paddingBottom:
|
|
1618
|
+
paddingBottom: Platform4.OS === "ios" && keyboard.isOpened ? device.safeArea.afterCalculations.top : bottomSpace + (insideBottomSafeArea ? device.safeArea.afterCalculations.bottom : 0),
|
|
1191
1619
|
children
|
|
1192
1620
|
}
|
|
1193
1621
|
);
|
|
1194
1622
|
const withRefresh = onRefresh || onRefreshEnd;
|
|
1195
|
-
return /* @__PURE__ */
|
|
1623
|
+
return /* @__PURE__ */ jsx11(View_default, { flex: 1, backgroundColor: backgroundColor ?? theme2.colors.backgroundBase, children: /* @__PURE__ */ jsxs5(
|
|
1196
1624
|
KeyboardAvoidingView,
|
|
1197
1625
|
{
|
|
1198
1626
|
style: keyboardAvoidingViewStyle,
|
|
1199
|
-
keyboardVerticalOffset: keyboardVerticalOffset ?? (withNoHeader ?
|
|
1200
|
-
behavior:
|
|
1627
|
+
keyboardVerticalOffset: keyboardVerticalOffset ?? (withNoHeader ? Platform4.OS === "ios" ? 0 : theme2.styles.gap : keepFooterOnKeyboardOpened ? Platform4.OS === "ios" ? device.safeArea.afterCalculations.bottom : theme2.styles.gap : void 0),
|
|
1628
|
+
behavior: Platform4.OS === "ios" ? "padding" : "height",
|
|
1201
1629
|
children: [
|
|
1202
|
-
/* @__PURE__ */
|
|
1630
|
+
/* @__PURE__ */ jsx11(View_default, { flex: 1, children: noScroll ? content : /* @__PURE__ */ jsx11(
|
|
1203
1631
|
ScrollView,
|
|
1204
1632
|
{
|
|
1205
|
-
refreshControl: withRefresh ? /* @__PURE__ */
|
|
1633
|
+
refreshControl: withRefresh ? /* @__PURE__ */ jsx11(RefreshControl, { refreshing: isRefreshing, onRefresh: onRefreshElement }) : void 0,
|
|
1206
1634
|
children: content
|
|
1207
1635
|
}
|
|
1208
1636
|
) }),
|
|
1209
|
-
keepFooterOnKeyboardOpened || (
|
|
1637
|
+
keepFooterOnKeyboardOpened || (Platform4.OS === "ios" ? !keyboard.willOpen : !keyboard.isOpened) ? footer && /* @__PURE__ */ jsx11(View_default, { children: footer }) : !withNoHeader && /* @__PURE__ */ jsx11(
|
|
1210
1638
|
View_default,
|
|
1211
1639
|
{
|
|
1212
1640
|
width: "100%",
|
|
1213
|
-
height: device.safeArea.afterCalculations.bottom + (
|
|
1641
|
+
height: device.safeArea.afterCalculations.bottom + (Platform4.OS === "android" ? theme2.styles.gap : 0)
|
|
1214
1642
|
}
|
|
1215
1643
|
)
|
|
1216
1644
|
]
|
|
@@ -1224,154 +1652,34 @@ ScreenHolderComponent.footer = function Footer({
|
|
|
1224
1652
|
withNoHeader,
|
|
1225
1653
|
children
|
|
1226
1654
|
}) {
|
|
1227
|
-
const theme2 =
|
|
1655
|
+
const theme2 = useTheme10();
|
|
1228
1656
|
const device = useDevice();
|
|
1229
1657
|
const keyboard = useKeyboard();
|
|
1230
|
-
return /* @__PURE__ */
|
|
1658
|
+
return /* @__PURE__ */ jsx11(
|
|
1231
1659
|
View_default,
|
|
1232
1660
|
{
|
|
1233
1661
|
backgroundColor: backgroundColor ?? theme2.colors.backgroundBase,
|
|
1234
1662
|
paddingHorizontal: !noSideSpace ? theme2.styles.space : void 0,
|
|
1235
1663
|
paddingTop: theme2.styles.gap,
|
|
1236
|
-
paddingBottom: (
|
|
1664
|
+
paddingBottom: (Platform4.OS === "ios" ? keyboard.willOpen : keyboard.isOpened) && withNoHeader ? theme2.styles.gap : insideBottomSafeArea ? device.safeArea.afterCalculations.bottom : void 0,
|
|
1237
1665
|
children
|
|
1238
1666
|
}
|
|
1239
1667
|
);
|
|
1240
1668
|
};
|
|
1241
|
-
var ScreenHolder =
|
|
1669
|
+
var ScreenHolder = memo11(ScreenHolderComponent);
|
|
1242
1670
|
ScreenHolder.footer = ScreenHolderComponent.footer;
|
|
1243
1671
|
var ScreenHolder_default = ScreenHolder;
|
|
1244
1672
|
|
|
1245
|
-
// src/components/Image.tsx
|
|
1246
|
-
import { memo as memo8, useEffect as useEffect3, useMemo as useMemo7 } from "react";
|
|
1247
|
-
import { useBetterCoreContext as useBetterCoreContext2, useTheme as useTheme7 } from "react-better-core";
|
|
1248
|
-
import {
|
|
1249
|
-
Image as NativeImage
|
|
1250
|
-
} from "react-native";
|
|
1251
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1252
|
-
var ImageComponent = function Image({ name, source, withDevFittingMode, ...props }) {
|
|
1253
|
-
const { assets: assets2 } = useBetterCoreContext2();
|
|
1254
|
-
const style = useMemo7(
|
|
1255
|
-
() => ({
|
|
1256
|
-
width: 100,
|
|
1257
|
-
height: 100,
|
|
1258
|
-
...withDevFittingMode ? {
|
|
1259
|
-
borderWidth: 1,
|
|
1260
|
-
borderColor: "#eb39f7"
|
|
1261
|
-
} : {},
|
|
1262
|
-
...props
|
|
1263
|
-
}),
|
|
1264
|
-
[withDevFittingMode, props]
|
|
1265
|
-
);
|
|
1266
|
-
useEffect3(() => {
|
|
1267
|
-
if (!name) return;
|
|
1268
|
-
if (!assets2[name.toString()])
|
|
1269
|
-
console.warn(
|
|
1270
|
-
`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.`
|
|
1271
|
-
);
|
|
1272
|
-
}, [assets2, name]);
|
|
1273
|
-
return /* @__PURE__ */ jsx8(NativeImage, { source: name ? assets2[name.toString()] : source, style, ...props });
|
|
1274
|
-
};
|
|
1275
|
-
ImageComponent.profileImage = function ProfileImage({
|
|
1276
|
-
size = 50,
|
|
1277
|
-
letters,
|
|
1278
|
-
color,
|
|
1279
|
-
backgroundColor,
|
|
1280
|
-
...props
|
|
1281
|
-
}) {
|
|
1282
|
-
const theme2 = useTheme7();
|
|
1283
|
-
return letters ? /* @__PURE__ */ jsx8(
|
|
1284
|
-
View_default,
|
|
1285
|
-
{
|
|
1286
|
-
width: size,
|
|
1287
|
-
height: size,
|
|
1288
|
-
backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
|
|
1289
|
-
borderWidth: 1,
|
|
1290
|
-
borderColor: theme2.colors.border,
|
|
1291
|
-
borderRadius: 999,
|
|
1292
|
-
alignItems: "center",
|
|
1293
|
-
justifyContent: "center",
|
|
1294
|
-
...props,
|
|
1295
|
-
children: /* @__PURE__ */ jsx8(Text_default, { fontSize: size / 2.5, fontWeight: 700, color: color ?? theme2.colors.textPrimary, marginTop: 1, children: letters.toUpperCase().slice(0, 2) })
|
|
1296
|
-
}
|
|
1297
|
-
) : /* @__PURE__ */ jsx8(
|
|
1298
|
-
ImageComponent,
|
|
1299
|
-
{
|
|
1300
|
-
width: size,
|
|
1301
|
-
height: size,
|
|
1302
|
-
borderWidth: 1,
|
|
1303
|
-
borderColor: theme2.colors.border,
|
|
1304
|
-
borderRadius: 999,
|
|
1305
|
-
objectFit: "cover",
|
|
1306
|
-
...props
|
|
1307
|
-
}
|
|
1308
|
-
);
|
|
1309
|
-
};
|
|
1310
|
-
var Image2 = memo8(ImageComponent);
|
|
1311
|
-
Image2.profileImage = ImageComponent.profileImage;
|
|
1312
|
-
var Image_default = Image2;
|
|
1313
|
-
|
|
1314
|
-
// src/components/Icon.tsx
|
|
1315
|
-
import { memo as memo9, useEffect as useEffect4 } from "react";
|
|
1316
|
-
import { Platform as Platform4 } from "react-native";
|
|
1317
|
-
import { Path, Svg } from "react-native-svg";
|
|
1318
|
-
import { useBetterCoreContext as useBetterCoreContext3, useTheme as useTheme8 } from "react-better-core";
|
|
1319
|
-
import { SymbolView } from "expo-symbols";
|
|
1320
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1321
|
-
import { createElement } from "react";
|
|
1322
|
-
function Icon({ name, nameIOS, size = 16, color, ...props }) {
|
|
1323
|
-
const theme2 = useTheme8();
|
|
1324
|
-
const { icons: icons2 } = useBetterCoreContext3();
|
|
1325
|
-
const svgColor = color ?? theme2.colors.textPrimary;
|
|
1326
|
-
useEffect4(() => {
|
|
1327
|
-
if (!icons2[name.toString()])
|
|
1328
|
-
console.warn(
|
|
1329
|
-
`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.`
|
|
1330
|
-
);
|
|
1331
|
-
}, [icons2, name]);
|
|
1332
|
-
return /* @__PURE__ */ jsx9(
|
|
1333
|
-
View_default,
|
|
1334
|
-
{
|
|
1335
|
-
width: size + (parseFloat(props.padding?.toString() ?? "0") ?? 0) + (parseFloat(props.paddingHorizontal?.toString() ?? "0") ?? 0),
|
|
1336
|
-
height: size + (parseFloat(props.padding?.toString() ?? "0") ?? 0) + (parseFloat(props.paddingVertical?.toString() ?? "0") ?? 0),
|
|
1337
|
-
alignItems: "center",
|
|
1338
|
-
justifyContent: "center",
|
|
1339
|
-
pressType: "opacity",
|
|
1340
|
-
pressStrength: pressStrength().p2,
|
|
1341
|
-
...props,
|
|
1342
|
-
children: Platform4.OS === "ios" && nameIOS ? /* @__PURE__ */ jsx9(SymbolView, { name: nameIOS, tintColor: svgColor, size }) : /* @__PURE__ */ jsx9(
|
|
1343
|
-
Svg,
|
|
1344
|
-
{
|
|
1345
|
-
width: size,
|
|
1346
|
-
height: size,
|
|
1347
|
-
viewBox: `0 0 ${icons2[name.toString()]?.width ?? 0} ${icons2[name.toString()]?.height ?? 0}`,
|
|
1348
|
-
fill: "none",
|
|
1349
|
-
children: icons2[name.toString()]?.paths.map(({ type, ...path }) => /* @__PURE__ */ createElement(
|
|
1350
|
-
Path,
|
|
1351
|
-
{
|
|
1352
|
-
...path,
|
|
1353
|
-
fill: type === "fill" ? svgColor : void 0,
|
|
1354
|
-
stroke: type === "stroke" ? svgColor : void 0,
|
|
1355
|
-
key: path.d
|
|
1356
|
-
}
|
|
1357
|
-
))
|
|
1358
|
-
}
|
|
1359
|
-
)
|
|
1360
|
-
}
|
|
1361
|
-
);
|
|
1362
|
-
}
|
|
1363
|
-
var Icon_default = memo9(Icon);
|
|
1364
|
-
|
|
1365
1673
|
// src/components/InputField.tsx
|
|
1366
1674
|
import {
|
|
1367
1675
|
forwardRef,
|
|
1368
|
-
memo as
|
|
1369
|
-
useCallback as
|
|
1370
|
-
useEffect as
|
|
1676
|
+
memo as memo12,
|
|
1677
|
+
useCallback as useCallback6,
|
|
1678
|
+
useEffect as useEffect6,
|
|
1371
1679
|
useImperativeHandle,
|
|
1372
|
-
useMemo as
|
|
1373
|
-
useRef as
|
|
1374
|
-
useState as
|
|
1680
|
+
useMemo as useMemo9,
|
|
1681
|
+
useRef as useRef3,
|
|
1682
|
+
useState as useState3
|
|
1375
1683
|
} from "react";
|
|
1376
1684
|
import {
|
|
1377
1685
|
Platform as Platform5,
|
|
@@ -1385,9 +1693,9 @@ import {
|
|
|
1385
1693
|
lightenColor,
|
|
1386
1694
|
useBetterCoreContext as useBetterCoreContext4,
|
|
1387
1695
|
useBooleanState as useBooleanState4,
|
|
1388
|
-
useTheme as
|
|
1696
|
+
useTheme as useTheme11
|
|
1389
1697
|
} from "react-better-core";
|
|
1390
|
-
import { Fragment as
|
|
1698
|
+
import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1391
1699
|
var InputFieldComponent = forwardRef(
|
|
1392
1700
|
({
|
|
1393
1701
|
flex,
|
|
@@ -1407,7 +1715,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1407
1715
|
autoCapitalize,
|
|
1408
1716
|
autoComplete,
|
|
1409
1717
|
autoCorrect,
|
|
1410
|
-
keyboardAppearance
|
|
1718
|
+
keyboardAppearance,
|
|
1411
1719
|
keyboardType,
|
|
1412
1720
|
secureTextEntry,
|
|
1413
1721
|
returnKeyLabel,
|
|
@@ -1439,11 +1747,11 @@ var InputFieldComponent = forwardRef(
|
|
|
1439
1747
|
onPressEnter,
|
|
1440
1748
|
...props
|
|
1441
1749
|
}, ref) => {
|
|
1442
|
-
const theme2 =
|
|
1750
|
+
const theme2 = useTheme11();
|
|
1443
1751
|
const { colorTheme } = useBetterCoreContext4();
|
|
1444
|
-
const textInputRef =
|
|
1445
|
-
const [internalValue, setInternalValue] =
|
|
1446
|
-
const [internalDateValue, setInternalDateValue] =
|
|
1752
|
+
const textInputRef = useRef3(null);
|
|
1753
|
+
const [internalValue, setInternalValue] = useState3(value?.toString() || defaultValue || "");
|
|
1754
|
+
const [internalDateValue, setInternalDateValue] = useState3();
|
|
1447
1755
|
const [isFocused, setIsFocused] = useBooleanState4();
|
|
1448
1756
|
const isIOSDateTime = Platform5.OS === "ios" && (type === "date" || type === "time");
|
|
1449
1757
|
const iconSize = 16;
|
|
@@ -1453,14 +1761,14 @@ var InputFieldComponent = forwardRef(
|
|
|
1453
1761
|
const readyPaddingHorizontal = paddingHorizontal ?? theme2.styles.space;
|
|
1454
1762
|
const readyPaddingVertical = paddingVertical ? parseFloat(paddingVertical.toString()) : (theme2.styles.space + theme2.styles.gap) / 2;
|
|
1455
1763
|
const readyHeight = height ?? isIOSDateTime ? void 0 : borderWidth + readyPaddingVertical + lineHeight + readyPaddingVertical + borderWidth + (Platform5.OS === "android" ? 2 : 0);
|
|
1456
|
-
const onChangeRNDateTimePicker =
|
|
1764
|
+
const onChangeRNDateTimePicker = useCallback6(
|
|
1457
1765
|
(event, data) => {
|
|
1458
1766
|
setInternalDateValue(data);
|
|
1459
1767
|
onChange?.(data?.toISOString() ?? "");
|
|
1460
1768
|
},
|
|
1461
1769
|
[onChange]
|
|
1462
1770
|
);
|
|
1463
|
-
const onPressInputField =
|
|
1771
|
+
const onPressInputField = useCallback6(
|
|
1464
1772
|
(event) => {
|
|
1465
1773
|
onPress?.(event);
|
|
1466
1774
|
if (type === "date" || type === "time") {
|
|
@@ -1488,22 +1796,22 @@ var InputFieldComponent = forwardRef(
|
|
|
1488
1796
|
},
|
|
1489
1797
|
[onPress, type, internalDateValue, onChangeRNDateTimePicker]
|
|
1490
1798
|
);
|
|
1491
|
-
const onFocusElement =
|
|
1799
|
+
const onFocusElement = useCallback6((event) => {
|
|
1492
1800
|
setIsFocused.setTrue();
|
|
1493
1801
|
onFocus?.(event);
|
|
1494
1802
|
}, []);
|
|
1495
|
-
const onBlurElement =
|
|
1803
|
+
const onBlurElement = useCallback6((event) => {
|
|
1496
1804
|
setIsFocused.setFalse();
|
|
1497
1805
|
onBlur?.(event);
|
|
1498
1806
|
}, []);
|
|
1499
|
-
const onChangeText =
|
|
1807
|
+
const onChangeText = useCallback6(
|
|
1500
1808
|
(text) => {
|
|
1501
1809
|
setInternalValue(text);
|
|
1502
1810
|
onChange?.(text);
|
|
1503
1811
|
},
|
|
1504
1812
|
[onChange]
|
|
1505
1813
|
);
|
|
1506
|
-
const textInputStyle =
|
|
1814
|
+
const textInputStyle = useMemo9(
|
|
1507
1815
|
() => ({
|
|
1508
1816
|
flex: 1,
|
|
1509
1817
|
fontSize,
|
|
@@ -1528,14 +1836,14 @@ var InputFieldComponent = forwardRef(
|
|
|
1528
1836
|
rightIcon
|
|
1529
1837
|
]
|
|
1530
1838
|
);
|
|
1531
|
-
const rnDateTimePickerStyle =
|
|
1839
|
+
const rnDateTimePickerStyle = useMemo9(
|
|
1532
1840
|
() => ({
|
|
1533
1841
|
flex: iOSDateTimeFullSize ? 1 : void 0,
|
|
1534
1842
|
marginLeft: -8 + (iOSDateTimeFullSize ? 0 : theme2.styles.space)
|
|
1535
1843
|
}),
|
|
1536
1844
|
[iOSDateTimeFullSize]
|
|
1537
1845
|
);
|
|
1538
|
-
|
|
1846
|
+
useEffect6(() => {
|
|
1539
1847
|
if (value === void 0) return;
|
|
1540
1848
|
setInternalValue(value.toString());
|
|
1541
1849
|
try {
|
|
@@ -1543,7 +1851,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1543
1851
|
} catch (error) {
|
|
1544
1852
|
}
|
|
1545
1853
|
}, [value]);
|
|
1546
|
-
|
|
1854
|
+
useEffect6(() => {
|
|
1547
1855
|
if (type !== "date" && type !== "time") return;
|
|
1548
1856
|
const date = internalDateValue?.toISOString().split("T")[0] ?? "";
|
|
1549
1857
|
const hours = internalDateValue ? internalDateValue.getHours().toString() : "00";
|
|
@@ -1561,11 +1869,11 @@ var InputFieldComponent = forwardRef(
|
|
|
1561
1869
|
);
|
|
1562
1870
|
const withPressInputField = !!onPress || type === "date" || type === "time";
|
|
1563
1871
|
const prefixSuffixBackgroundColor = colorTheme === "light" ? darkenColor(theme2.colors.backgroundContent, 0.03) : lightenColor(theme2.colors.backgroundContent, 0.1);
|
|
1564
|
-
const labelComponent = label && /* @__PURE__ */
|
|
1565
|
-
/* @__PURE__ */
|
|
1566
|
-
required && /* @__PURE__ */
|
|
1872
|
+
const labelComponent = label && /* @__PURE__ */ jsxs6(View_default, { isRow: true, alignItems: "center", gap: 2, children: [
|
|
1873
|
+
/* @__PURE__ */ jsx12(Text_default, { fontSize: 14, color: isError ? theme2.colors.error : theme2.colors.textSecondary, children: label }),
|
|
1874
|
+
required && /* @__PURE__ */ jsx12(Text_default, { color: theme2.colors.error, children: "*" })
|
|
1567
1875
|
] });
|
|
1568
|
-
return /* @__PURE__ */
|
|
1876
|
+
return /* @__PURE__ */ jsxs6(
|
|
1569
1877
|
Animate_default.View,
|
|
1570
1878
|
{
|
|
1571
1879
|
flex,
|
|
@@ -1575,8 +1883,8 @@ var InputFieldComponent = forwardRef(
|
|
|
1575
1883
|
...props,
|
|
1576
1884
|
children: [
|
|
1577
1885
|
isIOSDateTime && !iOSDateTimeFullSize ? void 0 : labelComponent,
|
|
1578
|
-
/* @__PURE__ */
|
|
1579
|
-
prefix && /* @__PURE__ */
|
|
1886
|
+
/* @__PURE__ */ jsxs6(View_default, { isRow: true, position: "relative", alignItems: "center", height: readyHeight, children: [
|
|
1887
|
+
prefix && /* @__PURE__ */ jsx12(
|
|
1580
1888
|
View_default,
|
|
1581
1889
|
{
|
|
1582
1890
|
isRow: true,
|
|
@@ -1591,7 +1899,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1591
1899
|
borderColor: theme2.colors.border,
|
|
1592
1900
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1593
1901
|
onPress: onPressPrefix,
|
|
1594
|
-
children: typeof prefix === "string" ? /* @__PURE__ */
|
|
1902
|
+
children: typeof prefix === "string" ? /* @__PURE__ */ jsx12(
|
|
1595
1903
|
Text_default,
|
|
1596
1904
|
{
|
|
1597
1905
|
fontWeight: 700,
|
|
@@ -1602,20 +1910,21 @@ var InputFieldComponent = forwardRef(
|
|
|
1602
1910
|
) : prefix
|
|
1603
1911
|
}
|
|
1604
1912
|
),
|
|
1605
|
-
isIOSDateTime ? /* @__PURE__ */
|
|
1913
|
+
isIOSDateTime ? /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
1606
1914
|
!iOSDateTimeFullSize ? labelComponent : void 0,
|
|
1607
|
-
/* @__PURE__ */
|
|
1915
|
+
/* @__PURE__ */ jsx12(
|
|
1608
1916
|
RNDateTimePicker,
|
|
1609
1917
|
{
|
|
1610
1918
|
value: internalDateValue ?? /* @__PURE__ */ new Date(),
|
|
1611
1919
|
mode: type,
|
|
1612
1920
|
display: iOSDateTimeFullSize ? type === "date" ? "inline" : "spinner" : "default",
|
|
1613
1921
|
accentColor: theme2.colors.primary,
|
|
1922
|
+
themeVariant: colorTheme === "dark" ? "dark" : "light",
|
|
1614
1923
|
style: rnDateTimePickerStyle,
|
|
1615
1924
|
onChange: onChangeRNDateTimePicker
|
|
1616
1925
|
}
|
|
1617
1926
|
)
|
|
1618
|
-
] }) : /* @__PURE__ */
|
|
1927
|
+
] }) : /* @__PURE__ */ jsx12(
|
|
1619
1928
|
View_default,
|
|
1620
1929
|
{
|
|
1621
1930
|
flex: 1,
|
|
@@ -1626,7 +1935,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1626
1935
|
borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1627
1936
|
pressStrength: 1,
|
|
1628
1937
|
onPress: Platform5.OS === "android" ? editable === false || withPressInputField ? onPressInputField : void 0 : void 0,
|
|
1629
|
-
children: /* @__PURE__ */
|
|
1938
|
+
children: /* @__PURE__ */ jsxs6(
|
|
1630
1939
|
Animate_default.View,
|
|
1631
1940
|
{
|
|
1632
1941
|
position: "relative",
|
|
@@ -1642,7 +1951,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1642
1951
|
animateBorderColor: isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border,
|
|
1643
1952
|
overflow: "hidden",
|
|
1644
1953
|
children: [
|
|
1645
|
-
leftIcon && /* @__PURE__ */
|
|
1954
|
+
leftIcon && /* @__PURE__ */ jsx12(
|
|
1646
1955
|
Icon_default,
|
|
1647
1956
|
{
|
|
1648
1957
|
position: "absolute",
|
|
@@ -1655,7 +1964,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1655
1964
|
onPress: onPressLeftIcon
|
|
1656
1965
|
}
|
|
1657
1966
|
),
|
|
1658
|
-
/* @__PURE__ */
|
|
1967
|
+
/* @__PURE__ */ jsx12(
|
|
1659
1968
|
TextInput2,
|
|
1660
1969
|
{
|
|
1661
1970
|
style: textInputStyle,
|
|
@@ -1673,7 +1982,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1673
1982
|
readOnly: !editable || disabled || type === "date" || type === "time",
|
|
1674
1983
|
textAlign,
|
|
1675
1984
|
editable: !disabled,
|
|
1676
|
-
keyboardAppearance,
|
|
1985
|
+
keyboardAppearance: keyboardAppearance ?? colorTheme === "dark" ? "dark" : "light",
|
|
1677
1986
|
keyboardType,
|
|
1678
1987
|
cursorColor: theme2.colors.primary,
|
|
1679
1988
|
selectionColor: theme2.colors.primary,
|
|
@@ -1688,7 +1997,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1688
1997
|
ref: textInputRef
|
|
1689
1998
|
}
|
|
1690
1999
|
),
|
|
1691
|
-
rightIcon && /* @__PURE__ */
|
|
2000
|
+
rightIcon && /* @__PURE__ */ jsx12(
|
|
1692
2001
|
Icon_default,
|
|
1693
2002
|
{
|
|
1694
2003
|
position: "absolute",
|
|
@@ -1706,7 +2015,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1706
2015
|
)
|
|
1707
2016
|
}
|
|
1708
2017
|
),
|
|
1709
|
-
suffix && /* @__PURE__ */
|
|
2018
|
+
suffix && /* @__PURE__ */ jsx12(
|
|
1710
2019
|
View_default,
|
|
1711
2020
|
{
|
|
1712
2021
|
isRow: true,
|
|
@@ -1720,7 +2029,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1720
2029
|
borderColor: theme2.colors.border,
|
|
1721
2030
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1722
2031
|
onPress: onPressSuffix,
|
|
1723
|
-
children: typeof suffix === "string" ? /* @__PURE__ */
|
|
2032
|
+
children: typeof suffix === "string" ? /* @__PURE__ */ jsx12(
|
|
1724
2033
|
Text_default,
|
|
1725
2034
|
{
|
|
1726
2035
|
fontWeight: 700,
|
|
@@ -1732,7 +2041,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1732
2041
|
}
|
|
1733
2042
|
)
|
|
1734
2043
|
] }),
|
|
1735
|
-
infoMessage && /* @__PURE__ */
|
|
2044
|
+
infoMessage && /* @__PURE__ */ jsx12(
|
|
1736
2045
|
Animate_default.Text,
|
|
1737
2046
|
{
|
|
1738
2047
|
fontSize: 14,
|
|
@@ -1744,7 +2053,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1744
2053
|
children: infoMessage
|
|
1745
2054
|
}
|
|
1746
2055
|
),
|
|
1747
|
-
errorMessage && /* @__PURE__ */
|
|
2056
|
+
errorMessage && /* @__PURE__ */ jsx12(
|
|
1748
2057
|
Animate_default.Text,
|
|
1749
2058
|
{
|
|
1750
2059
|
fontSize: 14,
|
|
@@ -1762,7 +2071,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1762
2071
|
}
|
|
1763
2072
|
);
|
|
1764
2073
|
InputFieldComponent.email = forwardRef(function Email(props, ref) {
|
|
1765
|
-
return /* @__PURE__ */
|
|
2074
|
+
return /* @__PURE__ */ jsx12(
|
|
1766
2075
|
InputFieldComponent,
|
|
1767
2076
|
{
|
|
1768
2077
|
placeholder: "your@email.here",
|
|
@@ -1776,9 +2085,9 @@ InputFieldComponent.email = forwardRef(function Email(props, ref) {
|
|
|
1776
2085
|
);
|
|
1777
2086
|
});
|
|
1778
2087
|
InputFieldComponent.password = forwardRef(function Password(props, ref) {
|
|
1779
|
-
const inputFieldRef =
|
|
2088
|
+
const inputFieldRef = useRef3(null);
|
|
1780
2089
|
const [showPassword, setShowPassword] = useBooleanState4();
|
|
1781
|
-
const onPressEye =
|
|
2090
|
+
const onPressEye = useCallback6(() => {
|
|
1782
2091
|
setShowPassword.toggle();
|
|
1783
2092
|
inputFieldRef.current?.focus();
|
|
1784
2093
|
}, []);
|
|
@@ -1789,7 +2098,7 @@ InputFieldComponent.password = forwardRef(function Password(props, ref) {
|
|
|
1789
2098
|
},
|
|
1790
2099
|
[]
|
|
1791
2100
|
);
|
|
1792
|
-
return /* @__PURE__ */
|
|
2101
|
+
return /* @__PURE__ */ jsx12(
|
|
1793
2102
|
InputFieldComponent,
|
|
1794
2103
|
{
|
|
1795
2104
|
secureTextEntry: !showPassword,
|
|
@@ -1805,11 +2114,11 @@ InputFieldComponent.password = forwardRef(function Password(props, ref) {
|
|
|
1805
2114
|
);
|
|
1806
2115
|
});
|
|
1807
2116
|
InputFieldComponent.search = forwardRef(function Search(props, ref) {
|
|
1808
|
-
return /* @__PURE__ */
|
|
2117
|
+
return /* @__PURE__ */ jsx12(InputFieldComponent, { placeholder: "Search...", leftIcon: "magnifyingGlass", ...props, ref });
|
|
1809
2118
|
});
|
|
1810
2119
|
InputFieldComponent.code = forwardRef(function Password2({ isSmall, ...props }, ref) {
|
|
1811
|
-
const theme2 =
|
|
1812
|
-
return /* @__PURE__ */
|
|
2120
|
+
const theme2 = useTheme11();
|
|
2121
|
+
return /* @__PURE__ */ jsx12(
|
|
1813
2122
|
InputFieldComponent,
|
|
1814
2123
|
{
|
|
1815
2124
|
flex: 1,
|
|
@@ -1824,43 +2133,157 @@ InputFieldComponent.code = forwardRef(function Password2({ isSmall, ...props },
|
|
|
1824
2133
|
}
|
|
1825
2134
|
);
|
|
1826
2135
|
});
|
|
1827
|
-
var InputField =
|
|
2136
|
+
var InputField = memo12(InputFieldComponent);
|
|
1828
2137
|
InputField.email = InputFieldComponent.email;
|
|
1829
2138
|
InputField.password = InputFieldComponent.password;
|
|
1830
2139
|
InputField.search = InputFieldComponent.search;
|
|
1831
2140
|
InputField.code = InputFieldComponent.code;
|
|
1832
2141
|
var InputField_default = InputField;
|
|
1833
2142
|
|
|
2143
|
+
// src/components/Switch.tsx
|
|
2144
|
+
import { memo as memo13, useCallback as useCallback7, useEffect as useEffect7, useMemo as useMemo10 } from "react";
|
|
2145
|
+
import { Switch as NativeSwitch, Platform as Platform6 } from "react-native";
|
|
2146
|
+
import { useBooleanState as useBooleanState5, useTheme as useTheme12 } from "react-better-core";
|
|
2147
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
2148
|
+
function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
2149
|
+
const theme2 = useTheme12();
|
|
2150
|
+
const [enabled, setEnabled] = useBooleanState5(isEnabled ?? defaultIsEnabled);
|
|
2151
|
+
const onPressElement = useCallback7(() => {
|
|
2152
|
+
onChange?.(!enabled);
|
|
2153
|
+
setEnabled.toggle();
|
|
2154
|
+
}, [onChange, enabled]);
|
|
2155
|
+
const trackColor = useMemo10(
|
|
2156
|
+
() => ({
|
|
2157
|
+
false: theme2.colors.border,
|
|
2158
|
+
true: theme2.colors.primary
|
|
2159
|
+
}),
|
|
2160
|
+
[theme2.colors]
|
|
2161
|
+
);
|
|
2162
|
+
useEffect7(() => {
|
|
2163
|
+
if (isEnabled === void 0) return;
|
|
2164
|
+
setEnabled.setState(isEnabled);
|
|
2165
|
+
}, [isEnabled]);
|
|
2166
|
+
const ballSize = 26;
|
|
2167
|
+
const ballGap = 3;
|
|
2168
|
+
const holderWidth = ballSize * 2.1;
|
|
2169
|
+
return Platform6.OS === "ios" ? /* @__PURE__ */ jsx13(
|
|
2170
|
+
NativeSwitch,
|
|
2171
|
+
{
|
|
2172
|
+
trackColor,
|
|
2173
|
+
ios_backgroundColor: theme2.colors.border,
|
|
2174
|
+
onValueChange: onPressElement,
|
|
2175
|
+
value: enabled,
|
|
2176
|
+
disabled
|
|
2177
|
+
}
|
|
2178
|
+
) : /* @__PURE__ */ jsx13(
|
|
2179
|
+
View_default,
|
|
2180
|
+
{
|
|
2181
|
+
width: holderWidth,
|
|
2182
|
+
borderRadius: 999,
|
|
2183
|
+
pressStrength: pressStrength().p05,
|
|
2184
|
+
disabled,
|
|
2185
|
+
onPress: !disabled ? onPressElement : void 0,
|
|
2186
|
+
children: /* @__PURE__ */ jsx13(
|
|
2187
|
+
Animate_default.View,
|
|
2188
|
+
{
|
|
2189
|
+
width: "100%",
|
|
2190
|
+
height: ballGap + ballSize + ballGap,
|
|
2191
|
+
borderRadius: 999,
|
|
2192
|
+
initialOpacity: 1,
|
|
2193
|
+
animateOpacity: disabled ? 0.6 : 1,
|
|
2194
|
+
initialBackgroundColor: theme2.colors.border,
|
|
2195
|
+
animateBackgroundColor: enabled ? theme2.colors.primary : theme2.colors.border,
|
|
2196
|
+
children: /* @__PURE__ */ jsx13(
|
|
2197
|
+
Animate_default.View,
|
|
2198
|
+
{
|
|
2199
|
+
width: ballSize,
|
|
2200
|
+
height: ballSize,
|
|
2201
|
+
top: ballGap,
|
|
2202
|
+
borderRadius: 999,
|
|
2203
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
2204
|
+
initialX: ballGap,
|
|
2205
|
+
animateX: enabled ? holderWidth - ballGap - ballSize : ballGap
|
|
2206
|
+
}
|
|
2207
|
+
)
|
|
2208
|
+
}
|
|
2209
|
+
)
|
|
2210
|
+
}
|
|
2211
|
+
);
|
|
2212
|
+
}
|
|
2213
|
+
var Switch_default = memo13(Switch);
|
|
2214
|
+
|
|
1834
2215
|
// src/components/StatusBar.tsx
|
|
1835
|
-
import { memo as
|
|
1836
|
-
import { useTheme as
|
|
1837
|
-
import { StatusBar as NativeStatusBar, Platform as
|
|
1838
|
-
import { jsx as
|
|
2216
|
+
import { memo as memo14 } from "react";
|
|
2217
|
+
import { useTheme as useTheme13 } from "react-better-core";
|
|
2218
|
+
import { StatusBar as NativeStatusBar, Platform as Platform7 } from "react-native";
|
|
2219
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1839
2220
|
function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarStyle }) {
|
|
1840
|
-
const theme2 =
|
|
1841
|
-
return /* @__PURE__ */
|
|
2221
|
+
const theme2 = useTheme13();
|
|
2222
|
+
return /* @__PURE__ */ jsx14(
|
|
1842
2223
|
NativeStatusBar,
|
|
1843
2224
|
{
|
|
1844
2225
|
backgroundColor: darkStatusBar ? theme2.colors.backgroundSecondary : void 0,
|
|
1845
|
-
barStyle: barStyle ?? (
|
|
2226
|
+
barStyle: barStyle ?? (Platform7.OS === "android" ? androidBarStyle : iOSBarStyle),
|
|
1846
2227
|
hidden
|
|
1847
2228
|
}
|
|
1848
2229
|
);
|
|
1849
2230
|
}
|
|
1850
|
-
var StatusBar_default =
|
|
2231
|
+
var StatusBar_default = memo14(StatusBar);
|
|
1851
2232
|
|
|
1852
|
-
// src/
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
2233
|
+
// src/components/ListItem.tsx
|
|
2234
|
+
import { memo as memo15 } from "react";
|
|
2235
|
+
import { useTheme as useTheme14 } from "react-better-core";
|
|
2236
|
+
import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2237
|
+
function ListItem({
|
|
2238
|
+
icon,
|
|
2239
|
+
iconIOS,
|
|
2240
|
+
title,
|
|
2241
|
+
description,
|
|
2242
|
+
descriptionSelectable,
|
|
2243
|
+
rightElement,
|
|
2244
|
+
backgroundColor,
|
|
2245
|
+
insideScreenHolder,
|
|
2246
|
+
onPress,
|
|
2247
|
+
rightValue,
|
|
2248
|
+
rightValueSelectable,
|
|
2249
|
+
switchIsEnabled,
|
|
2250
|
+
switchOnChange
|
|
2251
|
+
}) {
|
|
2252
|
+
const theme2 = useTheme14();
|
|
2253
|
+
const device = useDevice();
|
|
2254
|
+
const sideSpace = theme2.styles.space;
|
|
2255
|
+
return /* @__PURE__ */ jsx15(
|
|
2256
|
+
View_default,
|
|
2257
|
+
{
|
|
2258
|
+
width: insideScreenHolder ? device.windowDimensions.width : "100%",
|
|
2259
|
+
backgroundColor: backgroundColor ?? theme2.colors.backgroundBase,
|
|
2260
|
+
marginHorizontal: insideScreenHolder ? -sideSpace : void 0,
|
|
2261
|
+
paddingVertical: theme2.styles.gap,
|
|
2262
|
+
paddingHorizontal: sideSpace,
|
|
2263
|
+
pressStrength: pressStrength().p05,
|
|
2264
|
+
onPress,
|
|
2265
|
+
children: /* @__PURE__ */ jsxs7(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.space, children: [
|
|
2266
|
+
icon && /* @__PURE__ */ jsx15(Icon_default, { name: icon, nameIOS: iconIOS, size: 22, color: theme2.colors.primary }),
|
|
2267
|
+
/* @__PURE__ */ jsx15(View_default, { flex: 1, flexDirection: "row", alignItems: "center", gap: theme2.styles.gap, children: /* @__PURE__ */ jsxs7(View_default, { flex: 1, children: [
|
|
2268
|
+
title && /* @__PURE__ */ jsx15(Text_default, { fontSize: 20, fontWeight: 700, children: title }),
|
|
2269
|
+
description && /* @__PURE__ */ jsx15(Text_default.body, { selectable: descriptionSelectable, children: description })
|
|
2270
|
+
] }) }),
|
|
2271
|
+
rightElement ? /* @__PURE__ */ jsx15(Fragment5, { children: rightValue !== void 0 || rightElement === "arrow" ? /* @__PURE__ */ jsxs7(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.gap / 2, children: [
|
|
2272
|
+
rightValue !== void 0 && /* @__PURE__ */ jsx15(Text_default, { fontSize: 14, fontWeight: 700, selectable: rightValueSelectable, children: rightValue }),
|
|
2273
|
+
rightElement === "arrow" && /* @__PURE__ */ jsx15(
|
|
2274
|
+
Icon_default,
|
|
2275
|
+
{
|
|
2276
|
+
name: "chevronRight",
|
|
2277
|
+
nameIOS: "chevron.right",
|
|
2278
|
+
color: rightValue !== void 0 ? theme2.colors.textPrimary : theme2.colors.textSecondary
|
|
2279
|
+
}
|
|
2280
|
+
)
|
|
2281
|
+
] }) : rightElement === "switch" ? /* @__PURE__ */ jsx15(Switch_default, { isEnabled: switchIsEnabled, onChange: switchOnChange }) : void 0 }) : void 0
|
|
2282
|
+
] })
|
|
2283
|
+
}
|
|
2284
|
+
);
|
|
2285
|
+
}
|
|
2286
|
+
var ListItem_default = memo15(ListItem);
|
|
1864
2287
|
export {
|
|
1865
2288
|
Animate_default as Animate,
|
|
1866
2289
|
BetterComponentsProvider_default as BetterComponentsProvider,
|
|
@@ -1868,15 +2291,20 @@ export {
|
|
|
1868
2291
|
Icon_default as Icon,
|
|
1869
2292
|
Image_default as Image,
|
|
1870
2293
|
InputField_default as InputField,
|
|
2294
|
+
ListItem_default as ListItem,
|
|
1871
2295
|
Loader_default as Loader,
|
|
1872
2296
|
ScreenHolder_default as ScreenHolder,
|
|
1873
2297
|
StatusBar_default as StatusBar,
|
|
2298
|
+
Switch_default as Switch,
|
|
1874
2299
|
Text_default as Text,
|
|
1875
2300
|
View_default as View,
|
|
2301
|
+
alertControls,
|
|
2302
|
+
alertsPlugin,
|
|
1876
2303
|
asyncStoragePlugin,
|
|
1877
2304
|
colorThemeControls,
|
|
1878
2305
|
countries,
|
|
1879
2306
|
darkenColor2 as darkenColor,
|
|
2307
|
+
defaultAlertsPluginOptions,
|
|
1880
2308
|
defaultAsyncStoragePluginOptions,
|
|
1881
2309
|
desaturateColor,
|
|
1882
2310
|
eventPreventDefault,
|
|
@@ -1884,15 +2312,16 @@ export {
|
|
|
1884
2312
|
eventStopPropagation,
|
|
1885
2313
|
formatPhoneNumber,
|
|
1886
2314
|
generateAsyncStorage,
|
|
1887
|
-
generateRandomString,
|
|
2315
|
+
generateRandomString3 as generateRandomString,
|
|
1888
2316
|
getFormErrorObject,
|
|
1889
2317
|
getPluralWord,
|
|
1890
2318
|
lightenColor2 as lightenColor,
|
|
1891
2319
|
loaderControls,
|
|
1892
2320
|
pressStrength,
|
|
1893
2321
|
saturateColor,
|
|
2322
|
+
useAlertControls,
|
|
1894
2323
|
useBetterComponentsContext,
|
|
1895
|
-
|
|
2324
|
+
useBooleanState6 as useBooleanState,
|
|
1896
2325
|
useDebounceState,
|
|
1897
2326
|
useDevice,
|
|
1898
2327
|
useEventEmitter,
|
|
@@ -1900,6 +2329,6 @@ export {
|
|
|
1900
2329
|
useKeyboard,
|
|
1901
2330
|
useLoader2 as useLoader,
|
|
1902
2331
|
useLoaderControls,
|
|
1903
|
-
|
|
2332
|
+
useTheme15 as useTheme
|
|
1904
2333
|
};
|
|
1905
2334
|
//# sourceMappingURL=index.mjs.map
|