react-native-better-html 1.0.18 → 1.0.20
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 +54 -7
- package/dist/index.d.ts +54 -7
- package/dist/index.js +888 -590
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +771 -474
- 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,7 +8,7 @@ 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,
|
|
@@ -21,15 +21,16 @@ import {
|
|
|
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) => {
|
|
@@ -555,15 +456,15 @@ function useForm(options) {
|
|
|
555
456
|
setValues(defaultValues);
|
|
556
457
|
setErrors({});
|
|
557
458
|
}, [defaultValues]);
|
|
558
|
-
const isDirty =
|
|
459
|
+
const isDirty = useMemo(
|
|
559
460
|
() => Object.keys(defaultValues).some((key) => defaultValues[key] !== values[key]),
|
|
560
461
|
[defaultValues, values]
|
|
561
462
|
);
|
|
562
|
-
const isValid =
|
|
463
|
+
const isValid = useMemo(() => {
|
|
563
464
|
const validationErrors = validate?.(values) || {};
|
|
564
465
|
return Object.keys(validationErrors).length === 0;
|
|
565
466
|
}, [validate, values]);
|
|
566
|
-
const canSubmit =
|
|
467
|
+
const canSubmit = useMemo(() => {
|
|
567
468
|
const requiredFieldsHaveValues = requiredFields?.every((field) => values[field] !== void 0 && values[field] !== "") ?? true;
|
|
568
469
|
return isValid && requiredFieldsHaveValues;
|
|
569
470
|
}, [isValid, requiredFields]);
|
|
@@ -598,39 +499,8 @@ function useEventEmitter() {
|
|
|
598
499
|
};
|
|
599
500
|
}
|
|
600
501
|
|
|
601
|
-
// src/utils/functions.ts
|
|
602
|
-
var getFormErrorObject = (formValues) => {
|
|
603
|
-
return {};
|
|
604
|
-
};
|
|
605
|
-
|
|
606
|
-
// src/utils/asyncStorage.ts
|
|
607
|
-
import NativeAsyncStorage from "@react-native-async-storage/async-storage";
|
|
608
|
-
function generateAsyncStorage() {
|
|
609
|
-
return {
|
|
610
|
-
setItem: async (name, value) => {
|
|
611
|
-
if (value) await NativeAsyncStorage.setItem(name.toString(), JSON.stringify(value));
|
|
612
|
-
else await NativeAsyncStorage.removeItem(name.toString());
|
|
613
|
-
},
|
|
614
|
-
getItem: async (name) => {
|
|
615
|
-
const item = await NativeAsyncStorage.getItem(name.toString());
|
|
616
|
-
if (item === null) return void 0;
|
|
617
|
-
try {
|
|
618
|
-
return JSON.parse(item);
|
|
619
|
-
} catch (error) {
|
|
620
|
-
return void 0;
|
|
621
|
-
}
|
|
622
|
-
},
|
|
623
|
-
removeItem: async (name) => {
|
|
624
|
-
await NativeAsyncStorage.removeItem(name.toString());
|
|
625
|
-
},
|
|
626
|
-
removeAllItems: () => {
|
|
627
|
-
NativeAsyncStorage.clear();
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
|
|
632
502
|
// src/components/View.tsx
|
|
633
|
-
import { memo
|
|
503
|
+
import { memo, useMemo as useMemo2 } from "react";
|
|
634
504
|
import {
|
|
635
505
|
View as NativeView,
|
|
636
506
|
Platform,
|
|
@@ -639,7 +509,7 @@ import {
|
|
|
639
509
|
TouchableOpacity
|
|
640
510
|
} from "react-native";
|
|
641
511
|
import { useTheme as useTheme2 } from "react-better-core";
|
|
642
|
-
import { Fragment
|
|
512
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
643
513
|
var touchableHighlightStyleMoveToContent = [
|
|
644
514
|
"width",
|
|
645
515
|
"backgroundColor",
|
|
@@ -692,7 +562,7 @@ var ViewComponent = function View({
|
|
|
692
562
|
...props
|
|
693
563
|
}) {
|
|
694
564
|
const theme2 = useTheme2();
|
|
695
|
-
const style =
|
|
565
|
+
const style = useMemo2(
|
|
696
566
|
() => ({
|
|
697
567
|
flexDirection: isRow ? "row" : "column",
|
|
698
568
|
...props,
|
|
@@ -705,7 +575,7 @@ var ViewComponent = function View({
|
|
|
705
575
|
}),
|
|
706
576
|
[isRow, props]
|
|
707
577
|
);
|
|
708
|
-
const touchableHighlightStyle =
|
|
578
|
+
const touchableHighlightStyle = useMemo2(
|
|
709
579
|
() => ({
|
|
710
580
|
...style,
|
|
711
581
|
...touchableHighlightStyleMoveToContent.reduce((previousValue, currentValue) => {
|
|
@@ -718,21 +588,21 @@ var ViewComponent = function View({
|
|
|
718
588
|
}),
|
|
719
589
|
[style]
|
|
720
590
|
);
|
|
721
|
-
const touchableHighlightContentProps =
|
|
591
|
+
const touchableHighlightContentProps = useMemo2(
|
|
722
592
|
() => touchableHighlightStyleMoveToContent.reduce((previousValue, currentValue) => {
|
|
723
593
|
previousValue[currentValue] = props[currentValue];
|
|
724
594
|
return previousValue;
|
|
725
595
|
}, {}),
|
|
726
596
|
[props]
|
|
727
597
|
);
|
|
728
|
-
const touchableNativeFeedbackHolderStyle =
|
|
598
|
+
const touchableNativeFeedbackHolderStyle = useMemo2(
|
|
729
599
|
() => touchableNativeFeedbackStyleMoveToHolder.reduce((previousValue, currentValue) => {
|
|
730
600
|
previousValue[currentValue] = props[currentValue];
|
|
731
601
|
return previousValue;
|
|
732
602
|
}, {}),
|
|
733
603
|
[props]
|
|
734
604
|
);
|
|
735
|
-
const touchableNativeFeedbackContentStyle =
|
|
605
|
+
const touchableNativeFeedbackContentStyle = useMemo2(
|
|
736
606
|
() => ({
|
|
737
607
|
...style,
|
|
738
608
|
...touchableNativeFeedbackStyleMoveToHolder.reduce(
|
|
@@ -747,7 +617,7 @@ var ViewComponent = function View({
|
|
|
747
617
|
}),
|
|
748
618
|
[style]
|
|
749
619
|
);
|
|
750
|
-
const pressEvents =
|
|
620
|
+
const pressEvents = useMemo2(
|
|
751
621
|
() => !disabled ? {
|
|
752
622
|
onPress: (event) => {
|
|
753
623
|
onPress?.(event);
|
|
@@ -761,7 +631,7 @@ var ViewComponent = function View({
|
|
|
761
631
|
);
|
|
762
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;
|
|
763
633
|
const isPressable = onPress || onPressIn || onPressOut || onLongPress || onPressWithValue;
|
|
764
|
-
return isPressable ? pressType === "opacity" ? /* @__PURE__ */
|
|
634
|
+
return isPressable ? pressType === "opacity" ? /* @__PURE__ */ jsx(
|
|
765
635
|
TouchableOpacity,
|
|
766
636
|
{
|
|
767
637
|
style,
|
|
@@ -771,7 +641,7 @@ var ViewComponent = function View({
|
|
|
771
641
|
...props,
|
|
772
642
|
children
|
|
773
643
|
}
|
|
774
|
-
) : pressType === "highlight" ? Platform.OS === "ios" ? /* @__PURE__ */
|
|
644
|
+
) : pressType === "highlight" ? Platform.OS === "ios" ? /* @__PURE__ */ jsx(
|
|
775
645
|
TouchableHighlight,
|
|
776
646
|
{
|
|
777
647
|
activeOpacity: pressStrength2,
|
|
@@ -779,7 +649,7 @@ var ViewComponent = function View({
|
|
|
779
649
|
style: touchableHighlightStyle,
|
|
780
650
|
...pressEvents,
|
|
781
651
|
...props,
|
|
782
|
-
children: /* @__PURE__ */
|
|
652
|
+
children: /* @__PURE__ */ jsx(
|
|
783
653
|
ViewComponent,
|
|
784
654
|
{
|
|
785
655
|
width: "100%",
|
|
@@ -794,7 +664,7 @@ var ViewComponent = function View({
|
|
|
794
664
|
}
|
|
795
665
|
)
|
|
796
666
|
}
|
|
797
|
-
) : Platform.OS === "android" ? /* @__PURE__ */
|
|
667
|
+
) : Platform.OS === "android" ? /* @__PURE__ */ jsx(
|
|
798
668
|
ViewComponent,
|
|
799
669
|
{
|
|
800
670
|
...touchableNativeFeedbackHolderStyle,
|
|
@@ -806,7 +676,7 @@ var ViewComponent = function View({
|
|
|
806
676
|
boxShadow: androidBoxShadow,
|
|
807
677
|
overflow: "hidden",
|
|
808
678
|
pointerEvents: "box-none",
|
|
809
|
-
children: /* @__PURE__ */
|
|
679
|
+
children: /* @__PURE__ */ jsx(
|
|
810
680
|
TouchableNativeFeedback,
|
|
811
681
|
{
|
|
812
682
|
...pressEvents,
|
|
@@ -817,15 +687,15 @@ var ViewComponent = function View({
|
|
|
817
687
|
),
|
|
818
688
|
useForeground: true,
|
|
819
689
|
touchSoundDisabled: true,
|
|
820
|
-
children: /* @__PURE__ */
|
|
690
|
+
children: /* @__PURE__ */ jsx(ViewComponent, { flex: 1, ...touchableNativeFeedbackContentStyle, children })
|
|
821
691
|
}
|
|
822
692
|
)
|
|
823
693
|
}
|
|
824
|
-
) : /* @__PURE__ */
|
|
694
|
+
) : /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsx(NativeView, { boxShadow: androidBoxShadow, style, ...props, children });
|
|
825
695
|
};
|
|
826
696
|
ViewComponent.box = function Box({ withShadow, ...props }) {
|
|
827
697
|
const theme2 = useTheme2();
|
|
828
|
-
const shadowProps =
|
|
698
|
+
const shadowProps = useMemo2(
|
|
829
699
|
() => withShadow ? {
|
|
830
700
|
shadowOpacity: 0.2,
|
|
831
701
|
shadowOffsetHeight: 10,
|
|
@@ -834,7 +704,7 @@ ViewComponent.box = function Box({ withShadow, ...props }) {
|
|
|
834
704
|
} : {},
|
|
835
705
|
[]
|
|
836
706
|
);
|
|
837
|
-
return /* @__PURE__ */
|
|
707
|
+
return /* @__PURE__ */ jsx(
|
|
838
708
|
ViewComponent,
|
|
839
709
|
{
|
|
840
710
|
width: "100%",
|
|
@@ -849,18 +719,52 @@ ViewComponent.box = function Box({ withShadow, ...props }) {
|
|
|
849
719
|
}
|
|
850
720
|
);
|
|
851
721
|
};
|
|
852
|
-
var View2 =
|
|
722
|
+
var View2 = memo(ViewComponent);
|
|
853
723
|
View2.box = ViewComponent.box;
|
|
854
724
|
var View_default = View2;
|
|
855
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
|
+
|
|
856
760
|
// src/components/Text.tsx
|
|
857
|
-
import { memo as
|
|
761
|
+
import { memo as memo2, useMemo as useMemo3 } from "react";
|
|
858
762
|
import { Text as NativeText } from "react-native";
|
|
859
763
|
import { useTheme as useTheme3 } from "react-better-core";
|
|
860
|
-
import { jsx as
|
|
764
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
861
765
|
var TextComponent = function Text({ selectionColor, children, ...props }) {
|
|
862
766
|
const theme2 = useTheme3();
|
|
863
|
-
const style =
|
|
767
|
+
const style = useMemo3(
|
|
864
768
|
() => ({
|
|
865
769
|
fontSize: 16,
|
|
866
770
|
color: theme2.colors.textPrimary,
|
|
@@ -868,27 +772,27 @@ var TextComponent = function Text({ selectionColor, children, ...props }) {
|
|
|
868
772
|
}),
|
|
869
773
|
[theme2, props]
|
|
870
774
|
);
|
|
871
|
-
return /* @__PURE__ */
|
|
775
|
+
return /* @__PURE__ */ jsx2(NativeText, { selectionColor: selectionColor ?? theme2.colors.primary, style, ...props, children });
|
|
872
776
|
};
|
|
873
777
|
TextComponent.title = function Title(props) {
|
|
874
|
-
return /* @__PURE__ */
|
|
778
|
+
return /* @__PURE__ */ jsx2(TextComponent, { fontSize: 32, fontWeight: 700, ...props });
|
|
875
779
|
};
|
|
876
780
|
TextComponent.subtitle = function Subtitle(props) {
|
|
877
|
-
return /* @__PURE__ */
|
|
781
|
+
return /* @__PURE__ */ jsx2(TextComponent, { fontSize: 24, fontWeight: 700, ...props });
|
|
878
782
|
};
|
|
879
783
|
TextComponent.body = function Body(props) {
|
|
880
784
|
const theme2 = useTheme3();
|
|
881
|
-
return /* @__PURE__ */
|
|
785
|
+
return /* @__PURE__ */ jsx2(TextComponent, { color: theme2.colors.textSecondary, ...props });
|
|
882
786
|
};
|
|
883
787
|
TextComponent.caption = function Caption(props) {
|
|
884
788
|
const theme2 = useTheme3();
|
|
885
|
-
return /* @__PURE__ */
|
|
789
|
+
return /* @__PURE__ */ jsx2(TextComponent, { fontSize: 14, color: theme2.colors.textSecondary, ...props });
|
|
886
790
|
};
|
|
887
791
|
TextComponent.unknown = function Unknown(props) {
|
|
888
792
|
const theme2 = useTheme3();
|
|
889
|
-
return /* @__PURE__ */
|
|
793
|
+
return /* @__PURE__ */ jsx2(TextComponent, { fontStyle: "italic", textAlign: "center", color: theme2.colors.textSecondary, ...props });
|
|
890
794
|
};
|
|
891
|
-
var Text2 =
|
|
795
|
+
var Text2 = memo2(TextComponent);
|
|
892
796
|
Text2.title = TextComponent.title;
|
|
893
797
|
Text2.subtitle = TextComponent.subtitle;
|
|
894
798
|
Text2.body = TextComponent.body;
|
|
@@ -896,13 +800,116 @@ Text2.caption = TextComponent.caption;
|
|
|
896
800
|
Text2.unknown = TextComponent.unknown;
|
|
897
801
|
var Text_default = Text2;
|
|
898
802
|
|
|
899
|
-
// src/components/
|
|
900
|
-
import { memo as
|
|
803
|
+
// src/components/Icon.tsx
|
|
804
|
+
import { memo as memo3, useEffect as useEffect2 } from "react";
|
|
901
805
|
import { Platform as Platform2 } from "react-native";
|
|
902
|
-
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";
|
|
903
910
|
|
|
904
911
|
// src/components/Animate.tsx
|
|
905
|
-
import { memo as memo4, useMemo as
|
|
912
|
+
import { memo as memo4, useMemo as useMemo4 } from "react";
|
|
906
913
|
import { Motion } from "@legendapp/motion";
|
|
907
914
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
908
915
|
var defaultTransitionDuration = 0.15 * 1e3;
|
|
@@ -912,7 +919,7 @@ var Animate = {
|
|
|
912
919
|
const animateProps2 = useComponentPropsGrouper(props, "animate");
|
|
913
920
|
const whileTapProps = useComponentPropsGrouper(props, "whileTap");
|
|
914
921
|
const transitionProps = useComponentPropsGrouper(props, "transition");
|
|
915
|
-
const transition =
|
|
922
|
+
const transition = useMemo4(
|
|
916
923
|
() => ({
|
|
917
924
|
type: "timing",
|
|
918
925
|
duration: defaultTransitionDuration,
|
|
@@ -920,7 +927,7 @@ var Animate = {
|
|
|
920
927
|
}),
|
|
921
928
|
[transitionProps.withPrefixStyle]
|
|
922
929
|
);
|
|
923
|
-
const transformOrigin =
|
|
930
|
+
const transformOrigin = useMemo4(
|
|
924
931
|
() => transformOriginX !== void 0 || transformOriginY !== void 0 ? {
|
|
925
932
|
x: transformOriginX ?? 0,
|
|
926
933
|
y: transformOriginY ?? 0
|
|
@@ -946,7 +953,7 @@ var Animate = {
|
|
|
946
953
|
const animateProps2 = useComponentPropsGrouper(props, "animate");
|
|
947
954
|
const whileTapProps = useComponentPropsGrouper(props, "whileTap");
|
|
948
955
|
const transitionProps = useComponentPropsGrouper(props, "transition");
|
|
949
|
-
const transition =
|
|
956
|
+
const transition = useMemo4(
|
|
950
957
|
() => ({
|
|
951
958
|
type: "timing",
|
|
952
959
|
duration: defaultTransitionDuration,
|
|
@@ -954,7 +961,7 @@ var Animate = {
|
|
|
954
961
|
}),
|
|
955
962
|
[transitionProps.withPrefixStyle]
|
|
956
963
|
);
|
|
957
|
-
const transformOrigin =
|
|
964
|
+
const transformOrigin = useMemo4(
|
|
958
965
|
() => transformOriginX !== void 0 || transformOriginY !== void 0 ? {
|
|
959
966
|
x: transformOriginX ?? 0,
|
|
960
967
|
y: transformOriginY ?? 0
|
|
@@ -981,14 +988,14 @@ var Animate_default = Animate;
|
|
|
981
988
|
// src/components/Loader.tsx
|
|
982
989
|
import { memo as memo5 } from "react";
|
|
983
990
|
import { ActivityIndicator } from "react-native";
|
|
984
|
-
import { useTheme as
|
|
991
|
+
import { useTheme as useTheme5 } from "react-better-core";
|
|
985
992
|
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
986
993
|
var LoaderComponent = function Loader({ size = "small", color, ...props }) {
|
|
987
|
-
const theme2 =
|
|
994
|
+
const theme2 = useTheme5();
|
|
988
995
|
return /* @__PURE__ */ jsx5(View_default, { ...props, children: /* @__PURE__ */ jsx5(ActivityIndicator, { size, color: color ?? theme2.colors.textPrimary }) });
|
|
989
996
|
};
|
|
990
997
|
LoaderComponent.box = function Box2({ text = "Loading...", size = "large", color, ...props }) {
|
|
991
|
-
const theme2 =
|
|
998
|
+
const theme2 = useTheme5();
|
|
992
999
|
return /* @__PURE__ */ jsxs(
|
|
993
1000
|
View_default,
|
|
994
1001
|
{
|
|
@@ -1005,7 +1012,7 @@ LoaderComponent.box = function Box2({ text = "Loading...", size = "large", color
|
|
|
1005
1012
|
);
|
|
1006
1013
|
};
|
|
1007
1014
|
LoaderComponent.text = function LoaderText({ text = "Loading...", size, color, ...props }) {
|
|
1008
|
-
const theme2 =
|
|
1015
|
+
const theme2 = useTheme5();
|
|
1009
1016
|
return /* @__PURE__ */ jsxs(
|
|
1010
1017
|
View_default,
|
|
1011
1018
|
{
|
|
@@ -1027,32 +1034,105 @@ Loader2.box = LoaderComponent.box;
|
|
|
1027
1034
|
Loader2.text = LoaderComponent.text;
|
|
1028
1035
|
var Loader_default = Loader2;
|
|
1029
1036
|
|
|
1030
|
-
// src/components/
|
|
1031
|
-
import {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
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,
|
|
1053
1072
|
...props
|
|
1054
1073
|
}) {
|
|
1055
|
-
const theme2 =
|
|
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,
|
|
1123
|
+
imageHeight,
|
|
1124
|
+
loaderName,
|
|
1125
|
+
isLoading,
|
|
1126
|
+
isSmall,
|
|
1127
|
+
animateOpacity,
|
|
1128
|
+
flex,
|
|
1129
|
+
alignSelf,
|
|
1130
|
+
disabled,
|
|
1131
|
+
onPress,
|
|
1132
|
+
onPressWithValue,
|
|
1133
|
+
...props
|
|
1134
|
+
}) {
|
|
1135
|
+
const theme2 = useTheme7();
|
|
1056
1136
|
const isLoadingLoader = useLoader(loaderName);
|
|
1057
1137
|
const isLoadingElement = isLoading || isLoadingLoader;
|
|
1058
1138
|
const isDisabled = disabled || isLoadingElement;
|
|
@@ -1061,7 +1141,24 @@ var ButtonComponent = function Button({
|
|
|
1061
1141
|
const paddingVertical = props.paddingVertical ? parseFloat(props.paddingVertical.toString()) : theme2.styles.space;
|
|
1062
1142
|
const paddingHorizontal = props.paddingHorizontal ? parseFloat(props.paddingHorizontal.toString()) : theme2.styles.space + theme2.styles.gap;
|
|
1063
1143
|
const buttonHeight = paddingVertical + lineHeight + paddingVertical;
|
|
1064
|
-
|
|
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(
|
|
1065
1162
|
Animate_default.View,
|
|
1066
1163
|
{
|
|
1067
1164
|
position: "relative",
|
|
@@ -1074,7 +1171,7 @@ var ButtonComponent = function Button({
|
|
|
1074
1171
|
{
|
|
1075
1172
|
position: "relative",
|
|
1076
1173
|
width: !isSmall ? "100%" : void 0,
|
|
1077
|
-
height:
|
|
1174
|
+
height: Platform3.OS === "android" ? buttonHeight : void 0,
|
|
1078
1175
|
alignItems: "center",
|
|
1079
1176
|
justifyContent: "center",
|
|
1080
1177
|
backgroundColor: theme2.colors.primary,
|
|
@@ -1082,22 +1179,29 @@ var ButtonComponent = function Button({
|
|
|
1082
1179
|
paddingVertical,
|
|
1083
1180
|
paddingHorizontal,
|
|
1084
1181
|
disabled: isDisabled,
|
|
1182
|
+
onPress: onPressElement,
|
|
1085
1183
|
...props,
|
|
1086
1184
|
children: [
|
|
1087
|
-
/* @__PURE__ */
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
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(
|
|
1101
1205
|
Animate_default.View,
|
|
1102
1206
|
{
|
|
1103
1207
|
position: "absolute",
|
|
@@ -1108,7 +1212,7 @@ var ButtonComponent = function Button({
|
|
|
1108
1212
|
justifyContent: "center",
|
|
1109
1213
|
initialOpacity: 0,
|
|
1110
1214
|
animateOpacity: isLoadingElement ? 1 : 0,
|
|
1111
|
-
children: /* @__PURE__ */
|
|
1215
|
+
children: /* @__PURE__ */ jsx7(Loader_default, { color })
|
|
1112
1216
|
}
|
|
1113
1217
|
)
|
|
1114
1218
|
]
|
|
@@ -1118,8 +1222,8 @@ var ButtonComponent = function Button({
|
|
|
1118
1222
|
);
|
|
1119
1223
|
};
|
|
1120
1224
|
ButtonComponent.secondary = function Secondary(props) {
|
|
1121
|
-
const theme2 =
|
|
1122
|
-
return /* @__PURE__ */
|
|
1225
|
+
const theme2 = useTheme7();
|
|
1226
|
+
return /* @__PURE__ */ jsx7(
|
|
1123
1227
|
ButtonComponent,
|
|
1124
1228
|
{
|
|
1125
1229
|
backgroundColor: theme2.colors.backgroundContent,
|
|
@@ -1133,15 +1237,16 @@ ButtonComponent.secondary = function Secondary(props) {
|
|
|
1133
1237
|
);
|
|
1134
1238
|
};
|
|
1135
1239
|
ButtonComponent.destructive = function Destructive(props) {
|
|
1136
|
-
const theme2 =
|
|
1137
|
-
return /* @__PURE__ */
|
|
1240
|
+
const theme2 = useTheme7();
|
|
1241
|
+
return /* @__PURE__ */ jsx7(ButtonComponent, { backgroundColor: theme2.colors.error, ...props });
|
|
1138
1242
|
};
|
|
1139
1243
|
ButtonComponent.text = function ButtonText(props) {
|
|
1140
|
-
const theme2 =
|
|
1141
|
-
return /* @__PURE__ */
|
|
1244
|
+
const theme2 = useTheme7();
|
|
1245
|
+
return /* @__PURE__ */ jsx7(
|
|
1142
1246
|
ButtonComponent,
|
|
1143
1247
|
{
|
|
1144
1248
|
width: "auto",
|
|
1249
|
+
textFontWeight: 400,
|
|
1145
1250
|
textColor: theme2.colors.textPrimary,
|
|
1146
1251
|
textDecorationLine: "underline",
|
|
1147
1252
|
backgroundColor: "transparent",
|
|
@@ -1153,17 +1258,336 @@ ButtonComponent.text = function ButtonText(props) {
|
|
|
1153
1258
|
}
|
|
1154
1259
|
);
|
|
1155
1260
|
};
|
|
1156
|
-
|
|
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);
|
|
1157
1282
|
Button2.secondary = ButtonComponent.secondary;
|
|
1158
1283
|
Button2.destructive = ButtonComponent.destructive;
|
|
1159
1284
|
Button2.text = ButtonComponent.text;
|
|
1285
|
+
Button2.icon = ButtonComponent.icon;
|
|
1160
1286
|
var Button_default = Button2;
|
|
1161
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 device = useDevice();
|
|
1301
|
+
const alertControls2 = useAlertControls();
|
|
1302
|
+
const alertsPlugin2 = usePlugin("alerts");
|
|
1303
|
+
const pluginConfig = alertsPlugin2?.getConfig() ?? {};
|
|
1304
|
+
const defaultAlertDurationNumber = getAlertDurationFromAuto(
|
|
1305
|
+
alert.duration ?? pluginConfig.defaultDuration ?? defaultAlertsPluginOptions.defaultDuration,
|
|
1306
|
+
alert
|
|
1307
|
+
);
|
|
1308
|
+
const defaultAlertDisplay = alert.display ?? pluginConfig.defaultDisplay?.[alert.type] ?? defaultAlertsPluginOptions.defaultDisplay[alert.type] ?? "default";
|
|
1309
|
+
const calledOnCloseRef = useRef2(false);
|
|
1310
|
+
const [isRemoved, setIsRemoved] = useBooleanState2();
|
|
1311
|
+
const onPressCloseAlert = useCallback3(() => {
|
|
1312
|
+
setIsRemoved.setTrue();
|
|
1313
|
+
setTimeout(() => {
|
|
1314
|
+
alertControls2.removeAlert(alert.id);
|
|
1315
|
+
if (!calledOnCloseRef.current) {
|
|
1316
|
+
alert.onClose?.(alert);
|
|
1317
|
+
calledOnCloseRef.current = true;
|
|
1318
|
+
}
|
|
1319
|
+
}, defaultTransitionDuration);
|
|
1320
|
+
}, [alert]);
|
|
1321
|
+
const alertData = useMemo6(
|
|
1322
|
+
() => ({
|
|
1323
|
+
info: {
|
|
1324
|
+
icon: "infoI",
|
|
1325
|
+
iconIOS: "info",
|
|
1326
|
+
backgroundColor: theme2.colors.info,
|
|
1327
|
+
title: "Info"
|
|
1328
|
+
},
|
|
1329
|
+
success: {
|
|
1330
|
+
icon: "check",
|
|
1331
|
+
backgroundColor: theme2.colors.success,
|
|
1332
|
+
title: "Success"
|
|
1333
|
+
},
|
|
1334
|
+
warning: {
|
|
1335
|
+
icon: "warningTriangle",
|
|
1336
|
+
backgroundColor: theme2.colors.warn,
|
|
1337
|
+
title: "Warning"
|
|
1338
|
+
},
|
|
1339
|
+
error: {
|
|
1340
|
+
icon: "XMark",
|
|
1341
|
+
backgroundColor: theme2.colors.error,
|
|
1342
|
+
title: "Error"
|
|
1343
|
+
}
|
|
1344
|
+
}),
|
|
1345
|
+
[theme2]
|
|
1346
|
+
);
|
|
1347
|
+
useEffect4(() => {
|
|
1348
|
+
const timeout = setTimeout(onPressCloseAlert, defaultAlertDurationNumber);
|
|
1349
|
+
return () => {
|
|
1350
|
+
clearTimeout(timeout);
|
|
1351
|
+
};
|
|
1352
|
+
}, [onPressCloseAlert, defaultAlertDurationNumber]);
|
|
1353
|
+
const iconSize = 16;
|
|
1354
|
+
const iconPadding = (theme2.styles.space + theme2.styles.gap) / 2;
|
|
1355
|
+
return defaultAlertDisplay === "prominent" ? /* @__PURE__ */ jsx8(Fragment2, {}) : /* @__PURE__ */ jsx8(
|
|
1356
|
+
Animate_default.View,
|
|
1357
|
+
{
|
|
1358
|
+
maxWidth: "100%",
|
|
1359
|
+
initialOpacity: 0,
|
|
1360
|
+
animateOpacity: isRemoved ? 0 : 1,
|
|
1361
|
+
initialX: 40,
|
|
1362
|
+
animateX: isRemoved ? 40 : 0,
|
|
1363
|
+
children: /* @__PURE__ */ jsx8(View_default.box, { width: "auto", withShadow: true, children: /* @__PURE__ */ jsxs3(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.space, children: [
|
|
1364
|
+
/* @__PURE__ */ jsx8(
|
|
1365
|
+
View_default,
|
|
1366
|
+
{
|
|
1367
|
+
alignItems: "center",
|
|
1368
|
+
justifyContent: "center",
|
|
1369
|
+
backgroundColor: alertData[alert.type].backgroundColor,
|
|
1370
|
+
borderRadius: 999,
|
|
1371
|
+
padding: iconPadding,
|
|
1372
|
+
children: /* @__PURE__ */ jsx8(
|
|
1373
|
+
Icon_default,
|
|
1374
|
+
{
|
|
1375
|
+
name: alertData[alert.type].icon,
|
|
1376
|
+
nameIOS: alertData[alert.type].iconIOS,
|
|
1377
|
+
size: iconSize,
|
|
1378
|
+
color: alertData[alert.type].iconColor ?? theme2.colors.base
|
|
1379
|
+
}
|
|
1380
|
+
)
|
|
1381
|
+
}
|
|
1382
|
+
),
|
|
1383
|
+
/* @__PURE__ */ jsxs3(
|
|
1384
|
+
View_default,
|
|
1385
|
+
{
|
|
1386
|
+
maxWidth: device.windowDimensions.width - theme2.styles.space - theme2.styles.space - (iconPadding + iconSize + iconPadding) - theme2.styles.space - 60 - theme2.styles.space - theme2.styles.space - theme2.styles.space,
|
|
1387
|
+
gap: theme2.styles.gap / 3,
|
|
1388
|
+
children: [
|
|
1389
|
+
/* @__PURE__ */ jsx8(Text_default, { fontSize: 18, fontWeight: 700, children: alert.title ?? alertData[alert.type].title }),
|
|
1390
|
+
/* @__PURE__ */ jsx8(Text_default.body, { children: alert.message })
|
|
1391
|
+
]
|
|
1392
|
+
}
|
|
1393
|
+
),
|
|
1394
|
+
pluginConfig.withCloseButton && /* @__PURE__ */ jsx8(Button_default.icon, { icon: "XMark", onPress: onPressCloseAlert })
|
|
1395
|
+
] }) })
|
|
1396
|
+
}
|
|
1397
|
+
);
|
|
1398
|
+
}
|
|
1399
|
+
var Alert_default = memo8(Alert);
|
|
1400
|
+
|
|
1401
|
+
// src/components/alerts/AlertsHolder.tsx
|
|
1402
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1403
|
+
function AlertsHolder() {
|
|
1404
|
+
const theme2 = useTheme9();
|
|
1405
|
+
const device = useDevice();
|
|
1406
|
+
const alertsPlugin2 = usePlugin("alerts");
|
|
1407
|
+
const { alerts } = useBetterComponentsContextInternal();
|
|
1408
|
+
const pluginConfig = alertsPlugin2?.getConfig() ?? {};
|
|
1409
|
+
return /* @__PURE__ */ jsx9(
|
|
1410
|
+
View_default,
|
|
1411
|
+
{
|
|
1412
|
+
position: "absolute",
|
|
1413
|
+
width: "100%",
|
|
1414
|
+
top: device.safeArea.afterCalculations.top + theme2.styles.gap / 2,
|
|
1415
|
+
left: 0,
|
|
1416
|
+
gap: theme2.styles.gap,
|
|
1417
|
+
alignItems: pluginConfig.align === "left" ? "flex-start" : pluginConfig.align === "center" ? "center" : pluginConfig.align === "right" ? "flex-end" : void 0,
|
|
1418
|
+
paddingHorizontal: theme2.styles.space,
|
|
1419
|
+
pointerEvents: "box-none",
|
|
1420
|
+
zIndex: 1e3,
|
|
1421
|
+
children: alerts.map((alert) => /* @__PURE__ */ jsx9(Alert_default, { alert }, alert.id))
|
|
1422
|
+
}
|
|
1423
|
+
);
|
|
1424
|
+
}
|
|
1425
|
+
var AlertsHolder_default = memo9(AlertsHolder);
|
|
1426
|
+
|
|
1427
|
+
// src/components/BetterComponentsProvider.tsx
|
|
1428
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1429
|
+
var betterComponentsContext = createContext(void 0);
|
|
1430
|
+
var externalBetterCoreContextValue;
|
|
1431
|
+
var externalBetterComponentsContextValue;
|
|
1432
|
+
var useBetterComponentsContext = () => {
|
|
1433
|
+
const coreContext = useBetterCoreContext3();
|
|
1434
|
+
const context = useContext(betterComponentsContext);
|
|
1435
|
+
if (context === void 0)
|
|
1436
|
+
throw new Error(
|
|
1437
|
+
"`useBetterComponentsContext()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1438
|
+
);
|
|
1439
|
+
const { plugins, componentsState, ...rest } = context;
|
|
1440
|
+
return {
|
|
1441
|
+
...coreContext,
|
|
1442
|
+
...rest
|
|
1443
|
+
};
|
|
1444
|
+
};
|
|
1445
|
+
var useBetterComponentsContextInternal = () => {
|
|
1446
|
+
const context = useContext(betterComponentsContext);
|
|
1447
|
+
if (context === void 0)
|
|
1448
|
+
throw new Error(
|
|
1449
|
+
"`useBetterComponentsContextInternal()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1450
|
+
);
|
|
1451
|
+
return context;
|
|
1452
|
+
};
|
|
1453
|
+
var useAlertControls = () => {
|
|
1454
|
+
const context = useContext(betterComponentsContext);
|
|
1455
|
+
if (context === void 0)
|
|
1456
|
+
throw new Error(
|
|
1457
|
+
"`useAlertControls()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1458
|
+
);
|
|
1459
|
+
const createAlert = useCallback4((alert) => {
|
|
1460
|
+
const readyAlert = {
|
|
1461
|
+
id: generateRandomString2(36),
|
|
1462
|
+
...alert
|
|
1463
|
+
};
|
|
1464
|
+
context.setAlerts((oldValue) => [...oldValue, readyAlert]);
|
|
1465
|
+
return readyAlert;
|
|
1466
|
+
}, []);
|
|
1467
|
+
const removeAlert = useCallback4((alertId) => {
|
|
1468
|
+
context.setAlerts((oldValue) => oldValue.filter((alert) => alert.id !== alertId));
|
|
1469
|
+
}, []);
|
|
1470
|
+
return {
|
|
1471
|
+
createAlert,
|
|
1472
|
+
removeAlert
|
|
1473
|
+
};
|
|
1474
|
+
};
|
|
1475
|
+
var usePlugin = (pluginName) => {
|
|
1476
|
+
const context = useContext(betterComponentsContext);
|
|
1477
|
+
if (context === void 0) {
|
|
1478
|
+
throw new Error(
|
|
1479
|
+
"`usePlugin()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
return useMemo7(
|
|
1483
|
+
() => context.plugins.find((plugin) => plugin.name === pluginName),
|
|
1484
|
+
[context.plugins, pluginName]
|
|
1485
|
+
);
|
|
1486
|
+
};
|
|
1487
|
+
function BetterComponentsProviderInternalContent({ children }) {
|
|
1488
|
+
const alertsPlugin2 = usePlugin("alerts");
|
|
1489
|
+
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
1490
|
+
children,
|
|
1491
|
+
alertsPlugin2 && /* @__PURE__ */ jsx10(AlertsHolder_default, {})
|
|
1492
|
+
] });
|
|
1493
|
+
}
|
|
1494
|
+
function BetterComponentsProviderInternal({
|
|
1495
|
+
config,
|
|
1496
|
+
plugins,
|
|
1497
|
+
children
|
|
1498
|
+
}) {
|
|
1499
|
+
const betterCoreContext = useBetterCoreContext3();
|
|
1500
|
+
const [alerts, setAlerts] = useState2([]);
|
|
1501
|
+
const readyConfig = useMemo7(
|
|
1502
|
+
() => ({
|
|
1503
|
+
app: {
|
|
1504
|
+
...appConfig,
|
|
1505
|
+
...config?.app
|
|
1506
|
+
},
|
|
1507
|
+
alerts,
|
|
1508
|
+
setAlerts,
|
|
1509
|
+
plugins: plugins ?? [],
|
|
1510
|
+
componentsState: {}
|
|
1511
|
+
}),
|
|
1512
|
+
[config, alerts, plugins]
|
|
1513
|
+
);
|
|
1514
|
+
useEffect5(() => {
|
|
1515
|
+
if (!plugins) return;
|
|
1516
|
+
plugins.forEach((plugin) => {
|
|
1517
|
+
plugin.initialize?.();
|
|
1518
|
+
});
|
|
1519
|
+
}, []);
|
|
1520
|
+
externalBetterCoreContextValue = betterCoreContext;
|
|
1521
|
+
externalBetterComponentsContextValue = readyConfig;
|
|
1522
|
+
return /* @__PURE__ */ jsx10(betterComponentsContext.Provider, { value: readyConfig, children: /* @__PURE__ */ jsx10(BetterComponentsProviderInternalContent, { children }) });
|
|
1523
|
+
}
|
|
1524
|
+
function BetterComponentsProvider({ config, ...props }) {
|
|
1525
|
+
const coreConfig = useMemo7(
|
|
1526
|
+
() => ({
|
|
1527
|
+
theme: {
|
|
1528
|
+
...theme,
|
|
1529
|
+
...config?.theme
|
|
1530
|
+
},
|
|
1531
|
+
// colorTheme: config?.colorTheme ?? (localStorage.getItem("theme") === "dark" ? "dark" : "light"),
|
|
1532
|
+
colorTheme: config?.colorTheme ?? "light",
|
|
1533
|
+
icons: {
|
|
1534
|
+
...icons,
|
|
1535
|
+
...config?.icons
|
|
1536
|
+
},
|
|
1537
|
+
assets: {
|
|
1538
|
+
...assets,
|
|
1539
|
+
...config?.assets
|
|
1540
|
+
},
|
|
1541
|
+
loaders: config?.loaders
|
|
1542
|
+
}),
|
|
1543
|
+
[config]
|
|
1544
|
+
);
|
|
1545
|
+
const componentsConfig = useMemo7(
|
|
1546
|
+
() => ({
|
|
1547
|
+
app: config?.app
|
|
1548
|
+
}),
|
|
1549
|
+
[config]
|
|
1550
|
+
);
|
|
1551
|
+
return /* @__PURE__ */ jsx10(BetterCoreProvider, { config: coreConfig, children: /* @__PURE__ */ jsx10(BetterComponentsProviderInternal, { config: componentsConfig, ...props }) });
|
|
1552
|
+
}
|
|
1553
|
+
var BetterComponentsProvider_default = memo10(BetterComponentsProvider);
|
|
1554
|
+
|
|
1555
|
+
// src/utils/functions.ts
|
|
1556
|
+
var getFormErrorObject = (formValues) => {
|
|
1557
|
+
return {};
|
|
1558
|
+
};
|
|
1559
|
+
|
|
1560
|
+
// src/utils/asyncStorage.ts
|
|
1561
|
+
import NativeAsyncStorage from "@react-native-async-storage/async-storage";
|
|
1562
|
+
function generateAsyncStorage() {
|
|
1563
|
+
return {
|
|
1564
|
+
setItem: async (name, value) => {
|
|
1565
|
+
if (value) await NativeAsyncStorage.setItem(name.toString(), JSON.stringify(value));
|
|
1566
|
+
else await NativeAsyncStorage.removeItem(name.toString());
|
|
1567
|
+
},
|
|
1568
|
+
getItem: async (name) => {
|
|
1569
|
+
const item = await NativeAsyncStorage.getItem(name.toString());
|
|
1570
|
+
if (item === null) return void 0;
|
|
1571
|
+
try {
|
|
1572
|
+
return JSON.parse(item);
|
|
1573
|
+
} catch (error) {
|
|
1574
|
+
return void 0;
|
|
1575
|
+
}
|
|
1576
|
+
},
|
|
1577
|
+
removeItem: async (name) => {
|
|
1578
|
+
await NativeAsyncStorage.removeItem(name.toString());
|
|
1579
|
+
},
|
|
1580
|
+
removeAllItems: () => {
|
|
1581
|
+
NativeAsyncStorage.clear();
|
|
1582
|
+
}
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1162
1586
|
// src/components/ScreenHolder.tsx
|
|
1163
|
-
import { memo as
|
|
1164
|
-
import { KeyboardAvoidingView, Platform as
|
|
1165
|
-
import { useBooleanState as useBooleanState3, useTheme as
|
|
1166
|
-
import { jsx as
|
|
1587
|
+
import { memo as memo11, useCallback as useCallback5, useMemo as useMemo8 } from "react";
|
|
1588
|
+
import { KeyboardAvoidingView, Platform as Platform4, RefreshControl, ScrollView } from "react-native";
|
|
1589
|
+
import { useBooleanState as useBooleanState3, useTheme as useTheme10 } from "react-better-core";
|
|
1590
|
+
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1167
1591
|
var ScreenHolderComponent = ({
|
|
1168
1592
|
noScroll,
|
|
1169
1593
|
noSideSpace,
|
|
@@ -1180,17 +1604,17 @@ var ScreenHolderComponent = ({
|
|
|
1180
1604
|
withNoHeader,
|
|
1181
1605
|
children
|
|
1182
1606
|
}) => {
|
|
1183
|
-
const theme2 =
|
|
1607
|
+
const theme2 = useTheme10();
|
|
1184
1608
|
const device = useDevice();
|
|
1185
1609
|
const keyboard = useKeyboard();
|
|
1186
1610
|
const [isRefreshing, setIsRefreshing] = useBooleanState3();
|
|
1187
|
-
const keyboardAvoidingViewStyle =
|
|
1611
|
+
const keyboardAvoidingViewStyle = useMemo8(
|
|
1188
1612
|
() => ({
|
|
1189
1613
|
flex: 1
|
|
1190
1614
|
}),
|
|
1191
1615
|
[]
|
|
1192
1616
|
);
|
|
1193
|
-
const onRefreshElement =
|
|
1617
|
+
const onRefreshElement = useCallback5(() => {
|
|
1194
1618
|
setIsRefreshing.setTrue();
|
|
1195
1619
|
onRefresh?.();
|
|
1196
1620
|
setTimeout(() => {
|
|
@@ -1198,36 +1622,36 @@ var ScreenHolderComponent = ({
|
|
|
1198
1622
|
onRefreshEnd?.();
|
|
1199
1623
|
}, refreshTimeout * 1e3);
|
|
1200
1624
|
}, [onRefresh, onRefreshEnd, refreshTimeout]);
|
|
1201
|
-
const content = /* @__PURE__ */
|
|
1625
|
+
const content = /* @__PURE__ */ jsx11(
|
|
1202
1626
|
View_default,
|
|
1203
1627
|
{
|
|
1204
1628
|
flex: 1,
|
|
1205
1629
|
paddingHorizontal: !noSideSpace ? theme2.styles.space : void 0,
|
|
1206
1630
|
paddingTop: theme2.styles.gap + (insideTopSafeArea ? device.safeArea.afterCalculations.top : 0),
|
|
1207
|
-
paddingBottom:
|
|
1631
|
+
paddingBottom: Platform4.OS === "ios" && keyboard.isOpened ? device.safeArea.afterCalculations.top : bottomSpace + (insideBottomSafeArea ? device.safeArea.afterCalculations.bottom : 0),
|
|
1208
1632
|
children
|
|
1209
1633
|
}
|
|
1210
1634
|
);
|
|
1211
1635
|
const withRefresh = onRefresh || onRefreshEnd;
|
|
1212
|
-
return /* @__PURE__ */
|
|
1636
|
+
return /* @__PURE__ */ jsx11(View_default, { flex: 1, backgroundColor: backgroundColor ?? theme2.colors.backgroundBase, children: /* @__PURE__ */ jsxs5(
|
|
1213
1637
|
KeyboardAvoidingView,
|
|
1214
1638
|
{
|
|
1215
1639
|
style: keyboardAvoidingViewStyle,
|
|
1216
|
-
keyboardVerticalOffset: keyboardVerticalOffset ?? (withNoHeader ?
|
|
1217
|
-
behavior:
|
|
1640
|
+
keyboardVerticalOffset: keyboardVerticalOffset ?? (withNoHeader ? Platform4.OS === "ios" ? 0 : theme2.styles.gap : keepFooterOnKeyboardOpened ? Platform4.OS === "ios" ? device.safeArea.afterCalculations.bottom : theme2.styles.gap : void 0),
|
|
1641
|
+
behavior: Platform4.OS === "ios" ? "padding" : "height",
|
|
1218
1642
|
children: [
|
|
1219
|
-
/* @__PURE__ */
|
|
1643
|
+
/* @__PURE__ */ jsx11(View_default, { flex: 1, children: noScroll ? content : /* @__PURE__ */ jsx11(
|
|
1220
1644
|
ScrollView,
|
|
1221
1645
|
{
|
|
1222
|
-
refreshControl: withRefresh ? /* @__PURE__ */
|
|
1646
|
+
refreshControl: withRefresh ? /* @__PURE__ */ jsx11(RefreshControl, { refreshing: isRefreshing, onRefresh: onRefreshElement }) : void 0,
|
|
1223
1647
|
children: content
|
|
1224
1648
|
}
|
|
1225
1649
|
) }),
|
|
1226
|
-
keepFooterOnKeyboardOpened || (
|
|
1650
|
+
keepFooterOnKeyboardOpened || (Platform4.OS === "ios" ? !keyboard.willOpen : !keyboard.isOpened) ? footer && /* @__PURE__ */ jsx11(View_default, { children: footer }) : !withNoHeader && /* @__PURE__ */ jsx11(
|
|
1227
1651
|
View_default,
|
|
1228
1652
|
{
|
|
1229
1653
|
width: "100%",
|
|
1230
|
-
height: device.safeArea.afterCalculations.bottom + (
|
|
1654
|
+
height: device.safeArea.afterCalculations.bottom + (Platform4.OS === "android" ? theme2.styles.gap : 0)
|
|
1231
1655
|
}
|
|
1232
1656
|
)
|
|
1233
1657
|
]
|
|
@@ -1241,154 +1665,34 @@ ScreenHolderComponent.footer = function Footer({
|
|
|
1241
1665
|
withNoHeader,
|
|
1242
1666
|
children
|
|
1243
1667
|
}) {
|
|
1244
|
-
const theme2 =
|
|
1668
|
+
const theme2 = useTheme10();
|
|
1245
1669
|
const device = useDevice();
|
|
1246
1670
|
const keyboard = useKeyboard();
|
|
1247
|
-
return /* @__PURE__ */
|
|
1671
|
+
return /* @__PURE__ */ jsx11(
|
|
1248
1672
|
View_default,
|
|
1249
1673
|
{
|
|
1250
1674
|
backgroundColor: backgroundColor ?? theme2.colors.backgroundBase,
|
|
1251
1675
|
paddingHorizontal: !noSideSpace ? theme2.styles.space : void 0,
|
|
1252
1676
|
paddingTop: theme2.styles.gap,
|
|
1253
|
-
paddingBottom: (
|
|
1677
|
+
paddingBottom: (Platform4.OS === "ios" ? keyboard.willOpen : keyboard.isOpened) && withNoHeader ? theme2.styles.gap : insideBottomSafeArea ? device.safeArea.afterCalculations.bottom : void 0,
|
|
1254
1678
|
children
|
|
1255
1679
|
}
|
|
1256
1680
|
);
|
|
1257
1681
|
};
|
|
1258
|
-
var ScreenHolder =
|
|
1682
|
+
var ScreenHolder = memo11(ScreenHolderComponent);
|
|
1259
1683
|
ScreenHolder.footer = ScreenHolderComponent.footer;
|
|
1260
1684
|
var ScreenHolder_default = ScreenHolder;
|
|
1261
1685
|
|
|
1262
|
-
// src/components/Image.tsx
|
|
1263
|
-
import { memo as memo8, useEffect as useEffect3, useMemo as useMemo7 } from "react";
|
|
1264
|
-
import { useBetterCoreContext as useBetterCoreContext2, useTheme as useTheme7 } from "react-better-core";
|
|
1265
|
-
import {
|
|
1266
|
-
Image as NativeImage
|
|
1267
|
-
} from "react-native";
|
|
1268
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1269
|
-
var ImageComponent = function Image({ name, source, withDevFittingMode, ...props }) {
|
|
1270
|
-
const { assets: assets2 } = useBetterCoreContext2();
|
|
1271
|
-
const style = useMemo7(
|
|
1272
|
-
() => ({
|
|
1273
|
-
width: 100,
|
|
1274
|
-
height: 100,
|
|
1275
|
-
...withDevFittingMode ? {
|
|
1276
|
-
borderWidth: 1,
|
|
1277
|
-
borderColor: "#eb39f7"
|
|
1278
|
-
} : {},
|
|
1279
|
-
...props
|
|
1280
|
-
}),
|
|
1281
|
-
[withDevFittingMode, props]
|
|
1282
|
-
);
|
|
1283
|
-
useEffect3(() => {
|
|
1284
|
-
if (!name) return;
|
|
1285
|
-
if (!assets2[name.toString()])
|
|
1286
|
-
console.warn(
|
|
1287
|
-
`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.`
|
|
1288
|
-
);
|
|
1289
|
-
}, [assets2, name]);
|
|
1290
|
-
return /* @__PURE__ */ jsx8(NativeImage, { source: name ? assets2[name.toString()] : source, style, ...props });
|
|
1291
|
-
};
|
|
1292
|
-
ImageComponent.profileImage = function ProfileImage({
|
|
1293
|
-
size = 50,
|
|
1294
|
-
letters,
|
|
1295
|
-
color,
|
|
1296
|
-
backgroundColor,
|
|
1297
|
-
...props
|
|
1298
|
-
}) {
|
|
1299
|
-
const theme2 = useTheme7();
|
|
1300
|
-
return letters ? /* @__PURE__ */ jsx8(
|
|
1301
|
-
View_default,
|
|
1302
|
-
{
|
|
1303
|
-
width: size,
|
|
1304
|
-
height: size,
|
|
1305
|
-
backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
|
|
1306
|
-
borderWidth: 1,
|
|
1307
|
-
borderColor: theme2.colors.border,
|
|
1308
|
-
borderRadius: 999,
|
|
1309
|
-
alignItems: "center",
|
|
1310
|
-
justifyContent: "center",
|
|
1311
|
-
...props,
|
|
1312
|
-
children: /* @__PURE__ */ jsx8(Text_default, { fontSize: size / 2.5, fontWeight: 700, color: color ?? theme2.colors.textPrimary, marginTop: 1, children: letters.toUpperCase().slice(0, 2) })
|
|
1313
|
-
}
|
|
1314
|
-
) : /* @__PURE__ */ jsx8(
|
|
1315
|
-
ImageComponent,
|
|
1316
|
-
{
|
|
1317
|
-
width: size,
|
|
1318
|
-
height: size,
|
|
1319
|
-
borderWidth: 1,
|
|
1320
|
-
borderColor: theme2.colors.border,
|
|
1321
|
-
borderRadius: 999,
|
|
1322
|
-
objectFit: "cover",
|
|
1323
|
-
...props
|
|
1324
|
-
}
|
|
1325
|
-
);
|
|
1326
|
-
};
|
|
1327
|
-
var Image2 = memo8(ImageComponent);
|
|
1328
|
-
Image2.profileImage = ImageComponent.profileImage;
|
|
1329
|
-
var Image_default = Image2;
|
|
1330
|
-
|
|
1331
|
-
// src/components/Icon.tsx
|
|
1332
|
-
import { memo as memo9, useEffect as useEffect4 } from "react";
|
|
1333
|
-
import { Platform as Platform4 } from "react-native";
|
|
1334
|
-
import { Path, Svg } from "react-native-svg";
|
|
1335
|
-
import { useBetterCoreContext as useBetterCoreContext3, useTheme as useTheme8 } from "react-better-core";
|
|
1336
|
-
import { SymbolView } from "expo-symbols";
|
|
1337
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1338
|
-
import { createElement } from "react";
|
|
1339
|
-
function Icon({ name, nameIOS, size = 16, color, ...props }) {
|
|
1340
|
-
const theme2 = useTheme8();
|
|
1341
|
-
const { icons: icons2 } = useBetterCoreContext3();
|
|
1342
|
-
const svgColor = color ?? theme2.colors.textPrimary;
|
|
1343
|
-
useEffect4(() => {
|
|
1344
|
-
if (!icons2[name.toString()])
|
|
1345
|
-
console.warn(
|
|
1346
|
-
`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.`
|
|
1347
|
-
);
|
|
1348
|
-
}, [icons2, name]);
|
|
1349
|
-
return /* @__PURE__ */ jsx9(
|
|
1350
|
-
View_default,
|
|
1351
|
-
{
|
|
1352
|
-
width: size + (parseFloat(props.padding?.toString() ?? "0") ?? 0) + (parseFloat(props.paddingHorizontal?.toString() ?? "0") ?? 0),
|
|
1353
|
-
height: size + (parseFloat(props.padding?.toString() ?? "0") ?? 0) + (parseFloat(props.paddingVertical?.toString() ?? "0") ?? 0),
|
|
1354
|
-
alignItems: "center",
|
|
1355
|
-
justifyContent: "center",
|
|
1356
|
-
pressType: "opacity",
|
|
1357
|
-
pressStrength: pressStrength().p2,
|
|
1358
|
-
...props,
|
|
1359
|
-
children: Platform4.OS === "ios" && nameIOS ? /* @__PURE__ */ jsx9(SymbolView, { name: nameIOS, tintColor: svgColor, size }) : /* @__PURE__ */ jsx9(
|
|
1360
|
-
Svg,
|
|
1361
|
-
{
|
|
1362
|
-
width: size,
|
|
1363
|
-
height: size,
|
|
1364
|
-
viewBox: `0 0 ${icons2[name.toString()]?.width ?? 0} ${icons2[name.toString()]?.height ?? 0}`,
|
|
1365
|
-
fill: "none",
|
|
1366
|
-
children: icons2[name.toString()]?.paths.map(({ type, ...path }) => /* @__PURE__ */ createElement(
|
|
1367
|
-
Path,
|
|
1368
|
-
{
|
|
1369
|
-
...path,
|
|
1370
|
-
fill: type === "fill" ? svgColor : void 0,
|
|
1371
|
-
stroke: type === "stroke" ? svgColor : void 0,
|
|
1372
|
-
key: path.d
|
|
1373
|
-
}
|
|
1374
|
-
))
|
|
1375
|
-
}
|
|
1376
|
-
)
|
|
1377
|
-
}
|
|
1378
|
-
);
|
|
1379
|
-
}
|
|
1380
|
-
var Icon_default = memo9(Icon);
|
|
1381
|
-
|
|
1382
1686
|
// src/components/InputField.tsx
|
|
1383
1687
|
import {
|
|
1384
1688
|
forwardRef,
|
|
1385
|
-
memo as
|
|
1386
|
-
useCallback as
|
|
1387
|
-
useEffect as
|
|
1689
|
+
memo as memo12,
|
|
1690
|
+
useCallback as useCallback6,
|
|
1691
|
+
useEffect as useEffect6,
|
|
1388
1692
|
useImperativeHandle,
|
|
1389
|
-
useMemo as
|
|
1390
|
-
useRef as
|
|
1391
|
-
useState as
|
|
1693
|
+
useMemo as useMemo9,
|
|
1694
|
+
useRef as useRef3,
|
|
1695
|
+
useState as useState3
|
|
1392
1696
|
} from "react";
|
|
1393
1697
|
import {
|
|
1394
1698
|
Platform as Platform5,
|
|
@@ -1402,9 +1706,9 @@ import {
|
|
|
1402
1706
|
lightenColor,
|
|
1403
1707
|
useBetterCoreContext as useBetterCoreContext4,
|
|
1404
1708
|
useBooleanState as useBooleanState4,
|
|
1405
|
-
useTheme as
|
|
1709
|
+
useTheme as useTheme11
|
|
1406
1710
|
} from "react-better-core";
|
|
1407
|
-
import { Fragment as
|
|
1711
|
+
import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1408
1712
|
var InputFieldComponent = forwardRef(
|
|
1409
1713
|
({
|
|
1410
1714
|
flex,
|
|
@@ -1456,11 +1760,11 @@ var InputFieldComponent = forwardRef(
|
|
|
1456
1760
|
onPressEnter,
|
|
1457
1761
|
...props
|
|
1458
1762
|
}, ref) => {
|
|
1459
|
-
const theme2 =
|
|
1763
|
+
const theme2 = useTheme11();
|
|
1460
1764
|
const { colorTheme } = useBetterCoreContext4();
|
|
1461
|
-
const textInputRef =
|
|
1462
|
-
const [internalValue, setInternalValue] =
|
|
1463
|
-
const [internalDateValue, setInternalDateValue] =
|
|
1765
|
+
const textInputRef = useRef3(null);
|
|
1766
|
+
const [internalValue, setInternalValue] = useState3(value?.toString() || defaultValue || "");
|
|
1767
|
+
const [internalDateValue, setInternalDateValue] = useState3();
|
|
1464
1768
|
const [isFocused, setIsFocused] = useBooleanState4();
|
|
1465
1769
|
const isIOSDateTime = Platform5.OS === "ios" && (type === "date" || type === "time");
|
|
1466
1770
|
const iconSize = 16;
|
|
@@ -1470,14 +1774,14 @@ var InputFieldComponent = forwardRef(
|
|
|
1470
1774
|
const readyPaddingHorizontal = paddingHorizontal ?? theme2.styles.space;
|
|
1471
1775
|
const readyPaddingVertical = paddingVertical ? parseFloat(paddingVertical.toString()) : (theme2.styles.space + theme2.styles.gap) / 2;
|
|
1472
1776
|
const readyHeight = height ?? isIOSDateTime ? void 0 : borderWidth + readyPaddingVertical + lineHeight + readyPaddingVertical + borderWidth + (Platform5.OS === "android" ? 2 : 0);
|
|
1473
|
-
const onChangeRNDateTimePicker =
|
|
1777
|
+
const onChangeRNDateTimePicker = useCallback6(
|
|
1474
1778
|
(event, data) => {
|
|
1475
1779
|
setInternalDateValue(data);
|
|
1476
1780
|
onChange?.(data?.toISOString() ?? "");
|
|
1477
1781
|
},
|
|
1478
1782
|
[onChange]
|
|
1479
1783
|
);
|
|
1480
|
-
const onPressInputField =
|
|
1784
|
+
const onPressInputField = useCallback6(
|
|
1481
1785
|
(event) => {
|
|
1482
1786
|
onPress?.(event);
|
|
1483
1787
|
if (type === "date" || type === "time") {
|
|
@@ -1505,22 +1809,22 @@ var InputFieldComponent = forwardRef(
|
|
|
1505
1809
|
},
|
|
1506
1810
|
[onPress, type, internalDateValue, onChangeRNDateTimePicker]
|
|
1507
1811
|
);
|
|
1508
|
-
const onFocusElement =
|
|
1812
|
+
const onFocusElement = useCallback6((event) => {
|
|
1509
1813
|
setIsFocused.setTrue();
|
|
1510
1814
|
onFocus?.(event);
|
|
1511
1815
|
}, []);
|
|
1512
|
-
const onBlurElement =
|
|
1816
|
+
const onBlurElement = useCallback6((event) => {
|
|
1513
1817
|
setIsFocused.setFalse();
|
|
1514
1818
|
onBlur?.(event);
|
|
1515
1819
|
}, []);
|
|
1516
|
-
const onChangeText =
|
|
1820
|
+
const onChangeText = useCallback6(
|
|
1517
1821
|
(text) => {
|
|
1518
1822
|
setInternalValue(text);
|
|
1519
1823
|
onChange?.(text);
|
|
1520
1824
|
},
|
|
1521
1825
|
[onChange]
|
|
1522
1826
|
);
|
|
1523
|
-
const textInputStyle =
|
|
1827
|
+
const textInputStyle = useMemo9(
|
|
1524
1828
|
() => ({
|
|
1525
1829
|
flex: 1,
|
|
1526
1830
|
fontSize,
|
|
@@ -1545,14 +1849,14 @@ var InputFieldComponent = forwardRef(
|
|
|
1545
1849
|
rightIcon
|
|
1546
1850
|
]
|
|
1547
1851
|
);
|
|
1548
|
-
const rnDateTimePickerStyle =
|
|
1852
|
+
const rnDateTimePickerStyle = useMemo9(
|
|
1549
1853
|
() => ({
|
|
1550
1854
|
flex: iOSDateTimeFullSize ? 1 : void 0,
|
|
1551
1855
|
marginLeft: -8 + (iOSDateTimeFullSize ? 0 : theme2.styles.space)
|
|
1552
1856
|
}),
|
|
1553
1857
|
[iOSDateTimeFullSize]
|
|
1554
1858
|
);
|
|
1555
|
-
|
|
1859
|
+
useEffect6(() => {
|
|
1556
1860
|
if (value === void 0) return;
|
|
1557
1861
|
setInternalValue(value.toString());
|
|
1558
1862
|
try {
|
|
@@ -1560,7 +1864,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1560
1864
|
} catch (error) {
|
|
1561
1865
|
}
|
|
1562
1866
|
}, [value]);
|
|
1563
|
-
|
|
1867
|
+
useEffect6(() => {
|
|
1564
1868
|
if (type !== "date" && type !== "time") return;
|
|
1565
1869
|
const date = internalDateValue?.toISOString().split("T")[0] ?? "";
|
|
1566
1870
|
const hours = internalDateValue ? internalDateValue.getHours().toString() : "00";
|
|
@@ -1578,11 +1882,11 @@ var InputFieldComponent = forwardRef(
|
|
|
1578
1882
|
);
|
|
1579
1883
|
const withPressInputField = !!onPress || type === "date" || type === "time";
|
|
1580
1884
|
const prefixSuffixBackgroundColor = colorTheme === "light" ? darkenColor(theme2.colors.backgroundContent, 0.03) : lightenColor(theme2.colors.backgroundContent, 0.1);
|
|
1581
|
-
const labelComponent = label && /* @__PURE__ */
|
|
1582
|
-
/* @__PURE__ */
|
|
1583
|
-
required && /* @__PURE__ */
|
|
1885
|
+
const labelComponent = label && /* @__PURE__ */ jsxs6(View_default, { isRow: true, alignItems: "center", gap: 2, children: [
|
|
1886
|
+
/* @__PURE__ */ jsx12(Text_default, { fontSize: 14, color: isError ? theme2.colors.error : theme2.colors.textSecondary, children: label }),
|
|
1887
|
+
required && /* @__PURE__ */ jsx12(Text_default, { color: theme2.colors.error, children: "*" })
|
|
1584
1888
|
] });
|
|
1585
|
-
return /* @__PURE__ */
|
|
1889
|
+
return /* @__PURE__ */ jsxs6(
|
|
1586
1890
|
Animate_default.View,
|
|
1587
1891
|
{
|
|
1588
1892
|
flex,
|
|
@@ -1592,8 +1896,8 @@ var InputFieldComponent = forwardRef(
|
|
|
1592
1896
|
...props,
|
|
1593
1897
|
children: [
|
|
1594
1898
|
isIOSDateTime && !iOSDateTimeFullSize ? void 0 : labelComponent,
|
|
1595
|
-
/* @__PURE__ */
|
|
1596
|
-
prefix && /* @__PURE__ */
|
|
1899
|
+
/* @__PURE__ */ jsxs6(View_default, { isRow: true, position: "relative", alignItems: "center", height: readyHeight, children: [
|
|
1900
|
+
prefix && /* @__PURE__ */ jsx12(
|
|
1597
1901
|
View_default,
|
|
1598
1902
|
{
|
|
1599
1903
|
isRow: true,
|
|
@@ -1608,7 +1912,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1608
1912
|
borderColor: theme2.colors.border,
|
|
1609
1913
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1610
1914
|
onPress: onPressPrefix,
|
|
1611
|
-
children: typeof prefix === "string" ? /* @__PURE__ */
|
|
1915
|
+
children: typeof prefix === "string" ? /* @__PURE__ */ jsx12(
|
|
1612
1916
|
Text_default,
|
|
1613
1917
|
{
|
|
1614
1918
|
fontWeight: 700,
|
|
@@ -1619,9 +1923,9 @@ var InputFieldComponent = forwardRef(
|
|
|
1619
1923
|
) : prefix
|
|
1620
1924
|
}
|
|
1621
1925
|
),
|
|
1622
|
-
isIOSDateTime ? /* @__PURE__ */
|
|
1926
|
+
isIOSDateTime ? /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
1623
1927
|
!iOSDateTimeFullSize ? labelComponent : void 0,
|
|
1624
|
-
/* @__PURE__ */
|
|
1928
|
+
/* @__PURE__ */ jsx12(
|
|
1625
1929
|
RNDateTimePicker,
|
|
1626
1930
|
{
|
|
1627
1931
|
value: internalDateValue ?? /* @__PURE__ */ new Date(),
|
|
@@ -1633,7 +1937,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1633
1937
|
onChange: onChangeRNDateTimePicker
|
|
1634
1938
|
}
|
|
1635
1939
|
)
|
|
1636
|
-
] }) : /* @__PURE__ */
|
|
1940
|
+
] }) : /* @__PURE__ */ jsx12(
|
|
1637
1941
|
View_default,
|
|
1638
1942
|
{
|
|
1639
1943
|
flex: 1,
|
|
@@ -1644,7 +1948,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1644
1948
|
borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1645
1949
|
pressStrength: 1,
|
|
1646
1950
|
onPress: Platform5.OS === "android" ? editable === false || withPressInputField ? onPressInputField : void 0 : void 0,
|
|
1647
|
-
children: /* @__PURE__ */
|
|
1951
|
+
children: /* @__PURE__ */ jsxs6(
|
|
1648
1952
|
Animate_default.View,
|
|
1649
1953
|
{
|
|
1650
1954
|
position: "relative",
|
|
@@ -1660,7 +1964,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1660
1964
|
animateBorderColor: isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border,
|
|
1661
1965
|
overflow: "hidden",
|
|
1662
1966
|
children: [
|
|
1663
|
-
leftIcon && /* @__PURE__ */
|
|
1967
|
+
leftIcon && /* @__PURE__ */ jsx12(
|
|
1664
1968
|
Icon_default,
|
|
1665
1969
|
{
|
|
1666
1970
|
position: "absolute",
|
|
@@ -1673,7 +1977,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1673
1977
|
onPress: onPressLeftIcon
|
|
1674
1978
|
}
|
|
1675
1979
|
),
|
|
1676
|
-
/* @__PURE__ */
|
|
1980
|
+
/* @__PURE__ */ jsx12(
|
|
1677
1981
|
TextInput2,
|
|
1678
1982
|
{
|
|
1679
1983
|
style: textInputStyle,
|
|
@@ -1706,7 +2010,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1706
2010
|
ref: textInputRef
|
|
1707
2011
|
}
|
|
1708
2012
|
),
|
|
1709
|
-
rightIcon && /* @__PURE__ */
|
|
2013
|
+
rightIcon && /* @__PURE__ */ jsx12(
|
|
1710
2014
|
Icon_default,
|
|
1711
2015
|
{
|
|
1712
2016
|
position: "absolute",
|
|
@@ -1724,7 +2028,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1724
2028
|
)
|
|
1725
2029
|
}
|
|
1726
2030
|
),
|
|
1727
|
-
suffix && /* @__PURE__ */
|
|
2031
|
+
suffix && /* @__PURE__ */ jsx12(
|
|
1728
2032
|
View_default,
|
|
1729
2033
|
{
|
|
1730
2034
|
isRow: true,
|
|
@@ -1738,7 +2042,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1738
2042
|
borderColor: theme2.colors.border,
|
|
1739
2043
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1740
2044
|
onPress: onPressSuffix,
|
|
1741
|
-
children: typeof suffix === "string" ? /* @__PURE__ */
|
|
2045
|
+
children: typeof suffix === "string" ? /* @__PURE__ */ jsx12(
|
|
1742
2046
|
Text_default,
|
|
1743
2047
|
{
|
|
1744
2048
|
fontWeight: 700,
|
|
@@ -1750,7 +2054,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1750
2054
|
}
|
|
1751
2055
|
)
|
|
1752
2056
|
] }),
|
|
1753
|
-
infoMessage && /* @__PURE__ */
|
|
2057
|
+
infoMessage && /* @__PURE__ */ jsx12(
|
|
1754
2058
|
Animate_default.Text,
|
|
1755
2059
|
{
|
|
1756
2060
|
fontSize: 14,
|
|
@@ -1762,7 +2066,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1762
2066
|
children: infoMessage
|
|
1763
2067
|
}
|
|
1764
2068
|
),
|
|
1765
|
-
errorMessage && /* @__PURE__ */
|
|
2069
|
+
errorMessage && /* @__PURE__ */ jsx12(
|
|
1766
2070
|
Animate_default.Text,
|
|
1767
2071
|
{
|
|
1768
2072
|
fontSize: 14,
|
|
@@ -1780,7 +2084,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1780
2084
|
}
|
|
1781
2085
|
);
|
|
1782
2086
|
InputFieldComponent.email = forwardRef(function Email(props, ref) {
|
|
1783
|
-
return /* @__PURE__ */
|
|
2087
|
+
return /* @__PURE__ */ jsx12(
|
|
1784
2088
|
InputFieldComponent,
|
|
1785
2089
|
{
|
|
1786
2090
|
placeholder: "your@email.here",
|
|
@@ -1794,9 +2098,9 @@ InputFieldComponent.email = forwardRef(function Email(props, ref) {
|
|
|
1794
2098
|
);
|
|
1795
2099
|
});
|
|
1796
2100
|
InputFieldComponent.password = forwardRef(function Password(props, ref) {
|
|
1797
|
-
const inputFieldRef =
|
|
2101
|
+
const inputFieldRef = useRef3(null);
|
|
1798
2102
|
const [showPassword, setShowPassword] = useBooleanState4();
|
|
1799
|
-
const onPressEye =
|
|
2103
|
+
const onPressEye = useCallback6(() => {
|
|
1800
2104
|
setShowPassword.toggle();
|
|
1801
2105
|
inputFieldRef.current?.focus();
|
|
1802
2106
|
}, []);
|
|
@@ -1807,7 +2111,7 @@ InputFieldComponent.password = forwardRef(function Password(props, ref) {
|
|
|
1807
2111
|
},
|
|
1808
2112
|
[]
|
|
1809
2113
|
);
|
|
1810
|
-
return /* @__PURE__ */
|
|
2114
|
+
return /* @__PURE__ */ jsx12(
|
|
1811
2115
|
InputFieldComponent,
|
|
1812
2116
|
{
|
|
1813
2117
|
secureTextEntry: !showPassword,
|
|
@@ -1823,11 +2127,11 @@ InputFieldComponent.password = forwardRef(function Password(props, ref) {
|
|
|
1823
2127
|
);
|
|
1824
2128
|
});
|
|
1825
2129
|
InputFieldComponent.search = forwardRef(function Search(props, ref) {
|
|
1826
|
-
return /* @__PURE__ */
|
|
2130
|
+
return /* @__PURE__ */ jsx12(InputFieldComponent, { placeholder: "Search...", leftIcon: "magnifyingGlass", ...props, ref });
|
|
1827
2131
|
});
|
|
1828
2132
|
InputFieldComponent.code = forwardRef(function Password2({ isSmall, ...props }, ref) {
|
|
1829
|
-
const theme2 =
|
|
1830
|
-
return /* @__PURE__ */
|
|
2133
|
+
const theme2 = useTheme11();
|
|
2134
|
+
return /* @__PURE__ */ jsx12(
|
|
1831
2135
|
InputFieldComponent,
|
|
1832
2136
|
{
|
|
1833
2137
|
flex: 1,
|
|
@@ -1842,7 +2146,7 @@ InputFieldComponent.code = forwardRef(function Password2({ isSmall, ...props },
|
|
|
1842
2146
|
}
|
|
1843
2147
|
);
|
|
1844
2148
|
});
|
|
1845
|
-
var InputField =
|
|
2149
|
+
var InputField = memo12(InputFieldComponent);
|
|
1846
2150
|
InputField.email = InputFieldComponent.email;
|
|
1847
2151
|
InputField.password = InputFieldComponent.password;
|
|
1848
2152
|
InputField.search = InputFieldComponent.search;
|
|
@@ -1850,32 +2154,32 @@ InputField.code = InputFieldComponent.code;
|
|
|
1850
2154
|
var InputField_default = InputField;
|
|
1851
2155
|
|
|
1852
2156
|
// src/components/Switch.tsx
|
|
1853
|
-
import { memo as
|
|
2157
|
+
import { memo as memo13, useCallback as useCallback7, useEffect as useEffect7, useMemo as useMemo10 } from "react";
|
|
1854
2158
|
import { Switch as NativeSwitch, Platform as Platform6 } from "react-native";
|
|
1855
|
-
import { useBooleanState as useBooleanState5, useTheme as
|
|
1856
|
-
import { jsx as
|
|
2159
|
+
import { useBooleanState as useBooleanState5, useTheme as useTheme12 } from "react-better-core";
|
|
2160
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1857
2161
|
function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
1858
|
-
const theme2 =
|
|
2162
|
+
const theme2 = useTheme12();
|
|
1859
2163
|
const [enabled, setEnabled] = useBooleanState5(isEnabled ?? defaultIsEnabled);
|
|
1860
|
-
const onPressElement =
|
|
2164
|
+
const onPressElement = useCallback7(() => {
|
|
1861
2165
|
onChange?.(!enabled);
|
|
1862
2166
|
setEnabled.toggle();
|
|
1863
2167
|
}, [onChange, enabled]);
|
|
1864
|
-
const trackColor =
|
|
2168
|
+
const trackColor = useMemo10(
|
|
1865
2169
|
() => ({
|
|
1866
2170
|
false: theme2.colors.border,
|
|
1867
2171
|
true: theme2.colors.primary
|
|
1868
2172
|
}),
|
|
1869
2173
|
[theme2.colors]
|
|
1870
2174
|
);
|
|
1871
|
-
|
|
2175
|
+
useEffect7(() => {
|
|
1872
2176
|
if (isEnabled === void 0) return;
|
|
1873
2177
|
setEnabled.setState(isEnabled);
|
|
1874
2178
|
}, [isEnabled]);
|
|
1875
2179
|
const ballSize = 26;
|
|
1876
2180
|
const ballGap = 3;
|
|
1877
2181
|
const holderWidth = ballSize * 2.1;
|
|
1878
|
-
return Platform6.OS === "ios" ? /* @__PURE__ */
|
|
2182
|
+
return Platform6.OS === "ios" ? /* @__PURE__ */ jsx13(
|
|
1879
2183
|
NativeSwitch,
|
|
1880
2184
|
{
|
|
1881
2185
|
trackColor,
|
|
@@ -1884,7 +2188,7 @@ function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
|
1884
2188
|
value: enabled,
|
|
1885
2189
|
disabled
|
|
1886
2190
|
}
|
|
1887
|
-
) : /* @__PURE__ */
|
|
2191
|
+
) : /* @__PURE__ */ jsx13(
|
|
1888
2192
|
View_default,
|
|
1889
2193
|
{
|
|
1890
2194
|
width: holderWidth,
|
|
@@ -1892,7 +2196,7 @@ function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
|
1892
2196
|
pressStrength: pressStrength().p05,
|
|
1893
2197
|
disabled,
|
|
1894
2198
|
onPress: !disabled ? onPressElement : void 0,
|
|
1895
|
-
children: /* @__PURE__ */
|
|
2199
|
+
children: /* @__PURE__ */ jsx13(
|
|
1896
2200
|
Animate_default.View,
|
|
1897
2201
|
{
|
|
1898
2202
|
width: "100%",
|
|
@@ -1902,7 +2206,7 @@ function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
|
1902
2206
|
animateOpacity: disabled ? 0.6 : 1,
|
|
1903
2207
|
initialBackgroundColor: theme2.colors.border,
|
|
1904
2208
|
animateBackgroundColor: enabled ? theme2.colors.primary : theme2.colors.border,
|
|
1905
|
-
children: /* @__PURE__ */
|
|
2209
|
+
children: /* @__PURE__ */ jsx13(
|
|
1906
2210
|
Animate_default.View,
|
|
1907
2211
|
{
|
|
1908
2212
|
width: ballSize,
|
|
@@ -1919,16 +2223,16 @@ function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
|
1919
2223
|
}
|
|
1920
2224
|
);
|
|
1921
2225
|
}
|
|
1922
|
-
var Switch_default =
|
|
2226
|
+
var Switch_default = memo13(Switch);
|
|
1923
2227
|
|
|
1924
2228
|
// src/components/StatusBar.tsx
|
|
1925
|
-
import { memo as
|
|
1926
|
-
import { useTheme as
|
|
2229
|
+
import { memo as memo14 } from "react";
|
|
2230
|
+
import { useTheme as useTheme13 } from "react-better-core";
|
|
1927
2231
|
import { StatusBar as NativeStatusBar, Platform as Platform7 } from "react-native";
|
|
1928
|
-
import { jsx as
|
|
2232
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1929
2233
|
function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarStyle }) {
|
|
1930
|
-
const theme2 =
|
|
1931
|
-
return /* @__PURE__ */
|
|
2234
|
+
const theme2 = useTheme13();
|
|
2235
|
+
return /* @__PURE__ */ jsx14(
|
|
1932
2236
|
NativeStatusBar,
|
|
1933
2237
|
{
|
|
1934
2238
|
backgroundColor: darkStatusBar ? theme2.colors.backgroundSecondary : void 0,
|
|
@@ -1937,29 +2241,31 @@ function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarSty
|
|
|
1937
2241
|
}
|
|
1938
2242
|
);
|
|
1939
2243
|
}
|
|
1940
|
-
var StatusBar_default =
|
|
2244
|
+
var StatusBar_default = memo14(StatusBar);
|
|
1941
2245
|
|
|
1942
2246
|
// src/components/ListItem.tsx
|
|
1943
|
-
import { memo as
|
|
1944
|
-
import { useTheme as
|
|
1945
|
-
import { Fragment as
|
|
2247
|
+
import { memo as memo15 } from "react";
|
|
2248
|
+
import { useTheme as useTheme14 } from "react-better-core";
|
|
2249
|
+
import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1946
2250
|
function ListItem({
|
|
1947
2251
|
icon,
|
|
1948
2252
|
iconIOS,
|
|
1949
2253
|
title,
|
|
1950
2254
|
description,
|
|
2255
|
+
descriptionSelectable,
|
|
1951
2256
|
rightElement,
|
|
1952
2257
|
backgroundColor,
|
|
1953
2258
|
insideScreenHolder,
|
|
1954
2259
|
onPress,
|
|
1955
|
-
|
|
2260
|
+
rightValue,
|
|
2261
|
+
rightValueSelectable,
|
|
1956
2262
|
switchIsEnabled,
|
|
1957
2263
|
switchOnChange
|
|
1958
2264
|
}) {
|
|
1959
|
-
const theme2 =
|
|
2265
|
+
const theme2 = useTheme14();
|
|
1960
2266
|
const device = useDevice();
|
|
1961
2267
|
const sideSpace = theme2.styles.space;
|
|
1962
|
-
return /* @__PURE__ */
|
|
2268
|
+
return /* @__PURE__ */ jsx15(
|
|
1963
2269
|
View_default,
|
|
1964
2270
|
{
|
|
1965
2271
|
width: insideScreenHolder ? device.windowDimensions.width : "100%",
|
|
@@ -1969,41 +2275,28 @@ function ListItem({
|
|
|
1969
2275
|
paddingHorizontal: sideSpace,
|
|
1970
2276
|
pressStrength: pressStrength().p05,
|
|
1971
2277
|
onPress,
|
|
1972
|
-
children: /* @__PURE__ */
|
|
1973
|
-
icon && /* @__PURE__ */
|
|
1974
|
-
/* @__PURE__ */
|
|
1975
|
-
title && /* @__PURE__ */
|
|
1976
|
-
description && /* @__PURE__ */
|
|
2278
|
+
children: /* @__PURE__ */ jsxs7(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.space, children: [
|
|
2279
|
+
icon && /* @__PURE__ */ jsx15(Icon_default, { name: icon, nameIOS: iconIOS, size: 22, color: theme2.colors.primary }),
|
|
2280
|
+
/* @__PURE__ */ jsx15(View_default, { flex: 1, flexDirection: "row", alignItems: "center", gap: theme2.styles.gap, children: /* @__PURE__ */ jsxs7(View_default, { flex: 1, children: [
|
|
2281
|
+
title && /* @__PURE__ */ jsx15(Text_default, { fontSize: 20, fontWeight: 700, children: title }),
|
|
2282
|
+
description && /* @__PURE__ */ jsx15(Text_default.body, { selectable: descriptionSelectable, children: description })
|
|
1977
2283
|
] }) }),
|
|
1978
|
-
rightElement ? /* @__PURE__ */
|
|
1979
|
-
|
|
1980
|
-
/* @__PURE__ */
|
|
2284
|
+
rightElement ? /* @__PURE__ */ jsx15(Fragment5, { children: rightValue !== void 0 || rightElement === "arrow" ? /* @__PURE__ */ jsxs7(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.gap / 2, children: [
|
|
2285
|
+
rightValue !== void 0 && /* @__PURE__ */ jsx15(Text_default, { fontSize: 14, fontWeight: 700, selectable: rightValueSelectable, children: rightValue }),
|
|
2286
|
+
rightElement === "arrow" && /* @__PURE__ */ jsx15(
|
|
1981
2287
|
Icon_default,
|
|
1982
2288
|
{
|
|
1983
2289
|
name: "chevronRight",
|
|
1984
2290
|
nameIOS: "chevron.right",
|
|
1985
|
-
color:
|
|
2291
|
+
color: rightValue !== void 0 ? theme2.colors.textPrimary : theme2.colors.textSecondary
|
|
1986
2292
|
}
|
|
1987
2293
|
)
|
|
1988
|
-
] }) : rightElement === "switch" ? /* @__PURE__ */
|
|
2294
|
+
] }) : rightElement === "switch" ? /* @__PURE__ */ jsx15(Switch_default, { isEnabled: switchIsEnabled, onChange: switchOnChange }) : void 0 }) : void 0
|
|
1989
2295
|
] })
|
|
1990
2296
|
}
|
|
1991
2297
|
);
|
|
1992
2298
|
}
|
|
1993
|
-
var ListItem_default =
|
|
1994
|
-
|
|
1995
|
-
// src/plugins/asyncStorage.ts
|
|
1996
|
-
var defaultAsyncStoragePluginOptions = {};
|
|
1997
|
-
var asyncStoragePlugin = (options) => ({
|
|
1998
|
-
name: "asyncStorage",
|
|
1999
|
-
initialize: () => {
|
|
2000
|
-
console.log("asyncStorage plugin initialized");
|
|
2001
|
-
},
|
|
2002
|
-
getConfig: () => ({
|
|
2003
|
-
...defaultAsyncStoragePluginOptions,
|
|
2004
|
-
...options
|
|
2005
|
-
})
|
|
2006
|
-
});
|
|
2299
|
+
var ListItem_default = memo15(ListItem);
|
|
2007
2300
|
export {
|
|
2008
2301
|
Animate_default as Animate,
|
|
2009
2302
|
BetterComponentsProvider_default as BetterComponentsProvider,
|
|
@@ -2018,10 +2311,13 @@ export {
|
|
|
2018
2311
|
Switch_default as Switch,
|
|
2019
2312
|
Text_default as Text,
|
|
2020
2313
|
View_default as View,
|
|
2314
|
+
alertControls,
|
|
2315
|
+
alertsPlugin,
|
|
2021
2316
|
asyncStoragePlugin,
|
|
2022
2317
|
colorThemeControls,
|
|
2023
2318
|
countries,
|
|
2024
2319
|
darkenColor2 as darkenColor,
|
|
2320
|
+
defaultAlertsPluginOptions,
|
|
2025
2321
|
defaultAsyncStoragePluginOptions,
|
|
2026
2322
|
desaturateColor,
|
|
2027
2323
|
eventPreventDefault,
|
|
@@ -2029,13 +2325,14 @@ export {
|
|
|
2029
2325
|
eventStopPropagation,
|
|
2030
2326
|
formatPhoneNumber,
|
|
2031
2327
|
generateAsyncStorage,
|
|
2032
|
-
generateRandomString,
|
|
2328
|
+
generateRandomString3 as generateRandomString,
|
|
2033
2329
|
getFormErrorObject,
|
|
2034
2330
|
getPluralWord,
|
|
2035
2331
|
lightenColor2 as lightenColor,
|
|
2036
2332
|
loaderControls,
|
|
2037
2333
|
pressStrength,
|
|
2038
2334
|
saturateColor,
|
|
2335
|
+
useAlertControls,
|
|
2039
2336
|
useBetterComponentsContext,
|
|
2040
2337
|
useBooleanState6 as useBooleanState,
|
|
2041
2338
|
useDebounceState,
|
|
@@ -2045,6 +2342,6 @@ export {
|
|
|
2045
2342
|
useKeyboard,
|
|
2046
2343
|
useLoader2 as useLoader,
|
|
2047
2344
|
useLoaderControls,
|
|
2048
|
-
|
|
2345
|
+
useTheme15 as useTheme
|
|
2049
2346
|
};
|
|
2050
2347
|
//# sourceMappingURL=index.mjs.map
|