react-native-better-html 1.0.2 → 1.0.3

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.mjs ADDED
@@ -0,0 +1,1063 @@
1
+ // src/index.ts
2
+ import {
3
+ useTheme as useTheme7,
4
+ useLoader as useLoader2,
5
+ useLoaderControls,
6
+ countries,
7
+ lightenColor,
8
+ darkenColor,
9
+ saturateColor,
10
+ desaturateColor,
11
+ generateRandomString,
12
+ formatPhoneNumber,
13
+ eventPreventDefault,
14
+ eventStopPropagation,
15
+ eventPreventStop,
16
+ getPluralWord,
17
+ useBooleanState as useBooleanState3,
18
+ useDebounceState,
19
+ loaderControls,
20
+ colorThemeControls
21
+ } from "react-better-core";
22
+
23
+ // src/components/BetterComponentsProvider.tsx
24
+ import { createContext, memo, useContext, useEffect, useMemo } from "react";
25
+ import {
26
+ useBooleanState,
27
+ BetterCoreProvider,
28
+ useBetterCoreContext
29
+ } from "react-better-core";
30
+
31
+ // src/constants/app.ts
32
+ var appConfig = {};
33
+
34
+ // src/constants/theme.ts
35
+ var theme = {};
36
+
37
+ // src/constants/icons.ts
38
+ var icons = {};
39
+
40
+ // src/constants/assets.ts
41
+ var assets = {};
42
+
43
+ // src/components/BetterComponentsProvider.tsx
44
+ import { Fragment, jsx } from "react/jsx-runtime";
45
+ var betterComponentsContext = createContext(void 0);
46
+ var externalBetterCoreContextValue;
47
+ var externalBetterComponentsContextValue;
48
+ var useBetterComponentsContext = () => {
49
+ const coreContext = useBetterCoreContext();
50
+ const context = useContext(betterComponentsContext);
51
+ if (context === void 0)
52
+ throw new Error(
53
+ "`useBetterComponentsContext()` must be used within a `<BetterComponentsProvider>`. Make sure to add one at the root of your component tree."
54
+ );
55
+ const { plugins, componentsState, ...rest } = context;
56
+ return {
57
+ ...coreContext,
58
+ ...rest
59
+ };
60
+ };
61
+ function BetterComponentsProviderInternalContent({ children }) {
62
+ return /* @__PURE__ */ jsx(Fragment, { children });
63
+ }
64
+ function BetterComponentsProviderInternal({
65
+ config,
66
+ plugins,
67
+ children
68
+ }) {
69
+ const betterCoreContext = useBetterCoreContext();
70
+ const [sideMenuIsCollapsed, setSideMenuIsCollapsed] = useBooleanState();
71
+ const [sideMenuIsOpenMobile, setSideMenuIsOpenMobile] = useBooleanState();
72
+ const readyConfig = useMemo(
73
+ () => ({
74
+ app: {
75
+ ...appConfig,
76
+ ...config?.app
77
+ },
78
+ sideMenuIsCollapsed,
79
+ setSideMenuIsCollapsed,
80
+ sideMenuIsOpenMobile,
81
+ setSideMenuIsOpenMobile,
82
+ plugins: plugins ?? [],
83
+ componentsState: {}
84
+ }),
85
+ [config, sideMenuIsCollapsed, sideMenuIsOpenMobile, plugins]
86
+ );
87
+ useEffect(() => {
88
+ if (!plugins) return;
89
+ plugins.forEach((plugin) => {
90
+ plugin.initialize?.();
91
+ });
92
+ }, []);
93
+ externalBetterCoreContextValue = betterCoreContext;
94
+ externalBetterComponentsContextValue = readyConfig;
95
+ return /* @__PURE__ */ jsx(betterComponentsContext.Provider, { value: readyConfig, children: /* @__PURE__ */ jsx(BetterComponentsProviderInternalContent, { children }) });
96
+ }
97
+ function BetterComponentsProvider({ config, ...props }) {
98
+ const coreConfig = useMemo(
99
+ () => ({
100
+ theme: {
101
+ ...theme,
102
+ ...config?.theme
103
+ },
104
+ // colorTheme: config?.colorTheme ?? (localStorage.getItem("theme") === "dark" ? "dark" : "light"),
105
+ colorTheme: config?.colorTheme ?? "light",
106
+ icons: {
107
+ ...icons,
108
+ ...config?.icons
109
+ },
110
+ assets: {
111
+ ...assets,
112
+ ...config?.assets
113
+ },
114
+ loaders: config?.loaders
115
+ }),
116
+ [config]
117
+ );
118
+ const componentsConfig = useMemo(
119
+ () => ({
120
+ app: config?.app
121
+ }),
122
+ [config]
123
+ );
124
+ return /* @__PURE__ */ jsx(BetterCoreProvider, { config: coreConfig, children: /* @__PURE__ */ jsx(BetterComponentsProviderInternal, { config: componentsConfig, ...props }) });
125
+ }
126
+ var BetterComponentsProvider_default = memo(BetterComponentsProvider);
127
+
128
+ // src/utils/variableFunctions.ts
129
+ var checkBetterCoreContextValue = (value, functionsName) => {
130
+ if (value === void 0) {
131
+ throw new Error(
132
+ `\`${functionsName}()\` must be used within a \`<BetterCoreProvider>\`. Make sure to add one at the root of your component tree.`
133
+ );
134
+ }
135
+ return value !== void 0;
136
+ };
137
+ var pressStrength = () => {
138
+ if (!checkBetterCoreContextValue(externalBetterCoreContextValue, "pressStrength")) return void 0;
139
+ return {
140
+ z05: externalBetterCoreContextValue.colorTheme === "dark" ? 0.85 : 0.95,
141
+ z1: externalBetterCoreContextValue.colorTheme === "dark" ? 0.6 : 0.8,
142
+ z2: externalBetterCoreContextValue.colorTheme === "dark" ? 0.5 : 0.7,
143
+ z3: externalBetterCoreContextValue.colorTheme === "dark" ? 0.4 : 0.6
144
+ };
145
+ };
146
+
147
+ // src/utils/hooks.ts
148
+ import { useMemo as useMemo2 } from "react";
149
+ import { Dimensions } from "react-native";
150
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
151
+ import { useTheme } from "react-better-core";
152
+
153
+ // src/constants/css.ts
154
+ var cssProps = /* @__PURE__ */ new Set([
155
+ "aligncontent",
156
+ "alignitems",
157
+ "alignself",
158
+ "aspectratio",
159
+ "borderbottomwidth",
160
+ "borderendwidth",
161
+ "borderleftwidth",
162
+ "borderrightwidth",
163
+ "borderstartwidth",
164
+ "bordertopwidth",
165
+ "borderwidth",
166
+ "bottom",
167
+ "boxsizing",
168
+ "display",
169
+ "end",
170
+ "flex",
171
+ "flexbasis",
172
+ "flexdirection",
173
+ "rowgap",
174
+ "gap",
175
+ "columngap",
176
+ "flexgrow",
177
+ "flexshrink",
178
+ "flexwrap",
179
+ "height",
180
+ "justifycontent",
181
+ "left",
182
+ "margin",
183
+ "marginbottom",
184
+ "marginend",
185
+ "marginhorizontal",
186
+ "marginleft",
187
+ "marginright",
188
+ "marginstart",
189
+ "margintop",
190
+ "marginvertical",
191
+ "maxheight",
192
+ "maxwidth",
193
+ "minheight",
194
+ "minwidth",
195
+ "overflow",
196
+ "padding",
197
+ "paddingbottom",
198
+ "paddingend",
199
+ "paddinghorizontal",
200
+ "paddingleft",
201
+ "paddingright",
202
+ "paddingstart",
203
+ "paddingtop",
204
+ "paddingvertical",
205
+ "position",
206
+ "right",
207
+ "start",
208
+ "top",
209
+ "width",
210
+ "zindex",
211
+ "direction",
212
+ "inset",
213
+ "insetblock",
214
+ "insetblockend",
215
+ "insetblockstart",
216
+ "insetinline",
217
+ "insetinlineend",
218
+ "insetinlinestart",
219
+ "marginblock",
220
+ "marginblockend",
221
+ "marginblockstart",
222
+ "margininline",
223
+ "margininlineend",
224
+ "margininlinestart",
225
+ "paddingblock",
226
+ "paddingblockend",
227
+ "paddingblockstart",
228
+ "paddinginline",
229
+ "paddinginlineend",
230
+ "paddinginlinestart",
231
+ "shadowcolor",
232
+ "shadowoffset",
233
+ "shadowopacity",
234
+ "shadowradius",
235
+ "transform",
236
+ "transformorigin",
237
+ "transformmatrix",
238
+ "rotation",
239
+ "scalex",
240
+ "scaley",
241
+ "translatex",
242
+ "translatey",
243
+ "backfacevisibility",
244
+ "backgroundcolor",
245
+ "borderblockcolor",
246
+ "borderblockendcolor",
247
+ "borderblockstartcolor",
248
+ "borderbottomcolor",
249
+ "borderbottomendradius",
250
+ "borderbottomleftradius",
251
+ "borderbottomrightradius",
252
+ "borderbottomstartradius",
253
+ "bordercolor",
254
+ "bordercurve",
255
+ "borderendcolor",
256
+ "borderendendradius",
257
+ "borderendstartradius",
258
+ "borderleftcolor",
259
+ "borderradius",
260
+ "borderrightcolor",
261
+ "borderstartcolor",
262
+ "borderstartendradius",
263
+ "borderstartstartradius",
264
+ "borderstyle",
265
+ "bordertopcolor",
266
+ "bordertopendradius",
267
+ "bordertopleftradius",
268
+ "bordertoprightradius",
269
+ "bordertopstartradius",
270
+ "outlinecolor",
271
+ "outlineoffset",
272
+ "outlinestyle",
273
+ "outlinewidth",
274
+ "opacity",
275
+ "elevation",
276
+ "pointerevents",
277
+ "isolation",
278
+ "cursor",
279
+ "boxshadow",
280
+ "filter",
281
+ "mixblendmode",
282
+ "fontvariant",
283
+ "textdecorationcolor",
284
+ "textdecorationstyle",
285
+ "writingdirection",
286
+ "textalignvertical",
287
+ "verticalalign",
288
+ "includefontpadding",
289
+ "color",
290
+ "fontfamily",
291
+ "fontsize",
292
+ "fontstyle",
293
+ "fontweight",
294
+ "letterspacing",
295
+ "lineheight",
296
+ "textalign",
297
+ "textdecorationline",
298
+ "textdecorationstyle",
299
+ "textdecorationcolor",
300
+ "textshadowcolor",
301
+ "textshadowoffset",
302
+ "textshadowradius",
303
+ "texttransform",
304
+ "userselect"
305
+ ]);
306
+ var animateProps = /* @__PURE__ */ new Set([
307
+ "x",
308
+ "y",
309
+ "scale",
310
+ "scaleX",
311
+ "scaleY",
312
+ "skewX",
313
+ "skewY",
314
+ "perspective",
315
+ "rotate",
316
+ "rotateX",
317
+ "rotateY",
318
+ "rotateZ",
319
+ "matrix"
320
+ ]);
321
+ var animateTransitionProps = /* @__PURE__ */ new Set([
322
+ "type",
323
+ "ease",
324
+ "easing",
325
+ "duration",
326
+ "delay",
327
+ "type",
328
+ "friction",
329
+ "tension",
330
+ "speed",
331
+ "bounciness",
332
+ "stiffness",
333
+ "damping",
334
+ "mass",
335
+ "overshootClamping",
336
+ "restDisplacementThreshold",
337
+ "restSpeedThreshold",
338
+ "velocity",
339
+ "loop"
340
+ ]);
341
+
342
+ // src/utils/hooks.ts
343
+ function useDevice() {
344
+ const theme2 = useTheme();
345
+ const safeAreaInsets = useSafeAreaInsets();
346
+ const screenDimensions = Dimensions.get("screen");
347
+ const windowDimensions = Dimensions.get("window");
348
+ const isSmallDevice = windowDimensions.height <= 700;
349
+ return {
350
+ safeArea: {
351
+ ...safeAreaInsets,
352
+ /** @description The safe area insets after calculations. Recommended to use this instead of the raw insets. */
353
+ afterCalculations: {
354
+ top: safeAreaInsets.top < 25 ? 32 : safeAreaInsets.top < 40 ? 40 : safeAreaInsets.top,
355
+ bottom: (safeAreaInsets.bottom === 0 ? theme2.styles.space : safeAreaInsets.bottom) + (isSmallDevice ? 0 : theme2.styles.space * 2),
356
+ left: safeAreaInsets.left,
357
+ right: safeAreaInsets.right
358
+ }
359
+ },
360
+ /** @description The dimensions of the device screen. */
361
+ screenDimensions,
362
+ /** @description The dimensions of the app window. */
363
+ windowDimensions,
364
+ /** @description Whether the device is small. */
365
+ isSmallDevice
366
+ };
367
+ }
368
+ function useComponentPropsGrouper(props, prefix) {
369
+ return useMemo2(() => {
370
+ const style = {};
371
+ const withPrefixStyle = {};
372
+ const restProps = {};
373
+ for (const key in props) {
374
+ const keyName = key;
375
+ if (cssProps.has(keyName.toLowerCase())) {
376
+ style[keyName] = props[keyName];
377
+ } else if (keyName.startsWith(prefix) && (cssProps.has(keyName.slice(prefix.length).toLowerCase()) || animateProps.has(keyName.slice(prefix.length).toLowerCase()) || animateTransitionProps.has(keyName.slice(prefix.length).toLowerCase()))) {
378
+ const realKey = `${keyName.slice(prefix.length, prefix.length + 1).toLowerCase()}${keyName.slice(
379
+ prefix.length + 1
380
+ )}`;
381
+ withPrefixStyle[realKey] = props[keyName];
382
+ } else {
383
+ restProps[keyName] = props[keyName];
384
+ }
385
+ }
386
+ return {
387
+ style,
388
+ withPrefixStyle,
389
+ restProps
390
+ };
391
+ }, [props, prefix]);
392
+ }
393
+
394
+ // src/utils/asyncStorage.ts
395
+ import NativeAsyncStorage from "@react-native-async-storage/async-storage";
396
+ function generateAsyncStorage() {
397
+ return {
398
+ setItem: async (name, value) => {
399
+ if (value) await NativeAsyncStorage.setItem(name.toString(), JSON.stringify(value));
400
+ else await NativeAsyncStorage.removeItem(name.toString());
401
+ },
402
+ getItem: async (name) => {
403
+ const item = await NativeAsyncStorage.getItem(name.toString());
404
+ if (item === null) return void 0;
405
+ try {
406
+ return JSON.parse(item);
407
+ } catch (error) {
408
+ return void 0;
409
+ }
410
+ },
411
+ removeItem: async (name) => {
412
+ await NativeAsyncStorage.removeItem(name.toString());
413
+ },
414
+ removeAllItems: () => {
415
+ NativeAsyncStorage.clear();
416
+ }
417
+ };
418
+ }
419
+
420
+ // src/components/View.tsx
421
+ import { memo as memo2, useMemo as useMemo3 } from "react";
422
+ import {
423
+ View as NativeView,
424
+ Platform,
425
+ TouchableHighlight,
426
+ TouchableNativeFeedback,
427
+ TouchableOpacity
428
+ } from "react-native";
429
+ import { useTheme as useTheme2 } from "react-better-core";
430
+ import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
431
+ var touchableHighlightStyleMoveToContent = [
432
+ "backgroundColor",
433
+ "padding",
434
+ "paddingTop",
435
+ "paddingBottom",
436
+ "paddingLeft",
437
+ "paddingRight",
438
+ "paddingHorizontal",
439
+ "paddingVertical",
440
+ "borderWidth",
441
+ "borderTopWidth",
442
+ "borderBottomWidth",
443
+ "borderLeftWidth",
444
+ "borderRightWidth",
445
+ "borderColor",
446
+ "borderTopColor",
447
+ "borderBottomColor",
448
+ "borderLeftColor",
449
+ "borderRightColor"
450
+ ];
451
+ var touchableNativeFeedbackStyleMoveToHolder = [
452
+ "width",
453
+ "height",
454
+ "margin",
455
+ "marginTop",
456
+ "marginBottom",
457
+ "marginLeft",
458
+ "marginRight",
459
+ "marginHorizontal",
460
+ "marginVertical"
461
+ ];
462
+ function alphaToHex(alpha) {
463
+ const clamped = Math.min(1, Math.max(0, alpha));
464
+ const value = Math.round(clamped * 255);
465
+ return value.toString(16).padStart(2, "0");
466
+ }
467
+ var ViewComponent = function View({
468
+ isRow,
469
+ value,
470
+ disabled,
471
+ pressType = "highlight",
472
+ pressStrength: pressStrength2 = 0.8,
473
+ onPress,
474
+ onPressIn,
475
+ onPressOut,
476
+ onLongPress,
477
+ onPressWithValue,
478
+ children,
479
+ ...props
480
+ }) {
481
+ const theme2 = useTheme2();
482
+ const style = useMemo3(
483
+ () => ({
484
+ flexDirection: isRow ? "row" : "column",
485
+ ...props,
486
+ ...props.shadowOffsetWidth !== void 0 || props.shadowOffsetHeight !== void 0 ? {
487
+ shadowOffset: {
488
+ width: props.shadowOffsetWidth ?? 0,
489
+ height: props.shadowOffsetHeight ?? 0
490
+ }
491
+ } : {}
492
+ }),
493
+ [isRow, props]
494
+ );
495
+ const touchableHighlightStyle = useMemo3(
496
+ () => ({
497
+ ...style,
498
+ ...touchableHighlightStyleMoveToContent.reduce((previousValue, currentValue) => {
499
+ if (currentValue === "shadowOffsetWidth" || currentValue === "shadowOffsetHeight")
500
+ previousValue.shadowOffset = void 0;
501
+ else previousValue[currentValue] = void 0;
502
+ return previousValue;
503
+ }, {})
504
+ }),
505
+ [style]
506
+ );
507
+ const touchableHighlightContentProps = useMemo3(
508
+ () => touchableHighlightStyleMoveToContent.reduce((previousValue, currentValue) => {
509
+ previousValue[currentValue] = props[currentValue];
510
+ return previousValue;
511
+ }, {}),
512
+ [props]
513
+ );
514
+ const touchableNativeFeedbackHolderStyle = useMemo3(
515
+ () => touchableNativeFeedbackStyleMoveToHolder.reduce((previousValue, currentValue) => {
516
+ previousValue[currentValue] = props[currentValue];
517
+ return previousValue;
518
+ }, {}),
519
+ [props]
520
+ );
521
+ const touchableNativeFeedbackContentStyle = useMemo3(
522
+ () => ({
523
+ ...style,
524
+ ...touchableNativeFeedbackStyleMoveToHolder.reduce(
525
+ (previousValue, currentValue) => {
526
+ if (currentValue === "shadowOffsetWidth" || currentValue === "shadowOffsetHeight")
527
+ previousValue.shadowOffset = void 0;
528
+ else previousValue[currentValue] = void 0;
529
+ return previousValue;
530
+ },
531
+ {}
532
+ )
533
+ }),
534
+ [style]
535
+ );
536
+ const pressEvents = useMemo3(
537
+ () => !disabled ? {
538
+ onPress: (event) => {
539
+ onPress?.(event);
540
+ if (value !== void 0) onPressWithValue?.(value);
541
+ },
542
+ onPressIn,
543
+ onPressOut,
544
+ onLongPress
545
+ } : {},
546
+ [disabled, onPress, onPressIn, onPressOut, onLongPress, onPressWithValue, value]
547
+ );
548
+ 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;
549
+ const isPressable = onPress || onPressIn || onPressOut || onLongPress || onPressWithValue;
550
+ return isPressable ? pressType === "opacity" ? /* @__PURE__ */ jsx2(
551
+ TouchableOpacity,
552
+ {
553
+ style,
554
+ activeOpacity: pressStrength2,
555
+ boxShadow: androidBoxShadow,
556
+ ...pressEvents,
557
+ ...props,
558
+ children
559
+ }
560
+ ) : pressType === "highlight" ? Platform.OS === "ios" ? /* @__PURE__ */ jsx2(
561
+ TouchableHighlight,
562
+ {
563
+ activeOpacity: pressStrength2,
564
+ underlayColor: theme2.colors.textPrimary,
565
+ style: touchableHighlightStyle,
566
+ ...pressEvents,
567
+ ...props,
568
+ children: /* @__PURE__ */ jsx2(
569
+ ViewComponent,
570
+ {
571
+ width: "100%",
572
+ borderRadius: props.borderRadius,
573
+ borderTopLeftRadius: props.borderTopLeftRadius,
574
+ borderTopRightRadius: props.borderTopRightRadius,
575
+ borderBottomLeftRadius: props.borderBottomLeftRadius,
576
+ borderBottomRightRadius: props.borderBottomRightRadius,
577
+ ...touchableHighlightContentProps,
578
+ children
579
+ }
580
+ )
581
+ }
582
+ ) : Platform.OS === "android" ? /* @__PURE__ */ jsx2(
583
+ ViewComponent,
584
+ {
585
+ ...touchableNativeFeedbackHolderStyle,
586
+ borderRadius: props.borderRadius,
587
+ borderTopLeftRadius: props.borderTopLeftRadius,
588
+ borderTopRightRadius: props.borderTopRightRadius,
589
+ borderBottomLeftRadius: props.borderBottomLeftRadius,
590
+ borderBottomRightRadius: props.borderBottomRightRadius,
591
+ boxShadow: androidBoxShadow,
592
+ overflow: "hidden",
593
+ pointerEvents: "box-none",
594
+ children: /* @__PURE__ */ jsx2(
595
+ TouchableNativeFeedback,
596
+ {
597
+ ...pressEvents,
598
+ ...props,
599
+ background: TouchableNativeFeedback.Ripple(
600
+ `${theme2.colors.textPrimary}${alphaToHex(1 - pressStrength2)}`,
601
+ false
602
+ ),
603
+ useForeground: true,
604
+ touchSoundDisabled: true,
605
+ children: /* @__PURE__ */ jsx2(ViewComponent, { flex: 1, ...touchableNativeFeedbackContentStyle, children })
606
+ }
607
+ )
608
+ }
609
+ ) : /* @__PURE__ */ jsx2(Fragment2, {}) : /* @__PURE__ */ jsx2(Fragment2, {}) : /* @__PURE__ */ jsx2(NativeView, { boxShadow: androidBoxShadow, style, ...props, children });
610
+ };
611
+ ViewComponent.box = function Box({ withShadow, ...props }) {
612
+ const theme2 = useTheme2();
613
+ const shadowProps = useMemo3(
614
+ () => withShadow ? {
615
+ shadowOpacity: 0.2,
616
+ shadowOffsetHeight: 10,
617
+ shadowRadius: 10,
618
+ shadowColor: Platform.OS === "android" ? "#00000020" : void 0
619
+ } : {},
620
+ []
621
+ );
622
+ return /* @__PURE__ */ jsx2(
623
+ ViewComponent,
624
+ {
625
+ width: "100%",
626
+ backgroundColor: theme2.colors.backgroundContent,
627
+ borderWidth: 1,
628
+ borderColor: theme2.colors.border,
629
+ borderRadius: theme2.styles.borderRadius,
630
+ paddingHorizontal: theme2.styles.space,
631
+ paddingVertical: theme2.styles.gap,
632
+ ...shadowProps,
633
+ ...props
634
+ }
635
+ );
636
+ };
637
+ var View2 = memo2(ViewComponent);
638
+ View2.box = ViewComponent.box;
639
+ var View_default = View2;
640
+
641
+ // src/components/Text.tsx
642
+ import { memo as memo3, useMemo as useMemo4 } from "react";
643
+ import { Text as NativeText } from "react-native";
644
+ import { useTheme as useTheme3 } from "react-better-core";
645
+ import { jsx as jsx3 } from "react/jsx-runtime";
646
+ var TextComponent = function Text({ selectionColor, children, ...props }) {
647
+ const theme2 = useTheme3();
648
+ const style = useMemo4(
649
+ () => ({
650
+ fontSize: 16,
651
+ color: theme2.colors.textPrimary,
652
+ ...props
653
+ }),
654
+ [theme2, props]
655
+ );
656
+ return /* @__PURE__ */ jsx3(NativeText, { selectionColor: selectionColor ?? theme2.colors.primary, style, ...props, children });
657
+ };
658
+ TextComponent.title = function Title(props) {
659
+ return /* @__PURE__ */ jsx3(TextComponent, { fontSize: 32, fontWeight: 700, ...props });
660
+ };
661
+ TextComponent.subtitle = function Subtitle(props) {
662
+ return /* @__PURE__ */ jsx3(TextComponent, { fontSize: 24, fontWeight: 700, ...props });
663
+ };
664
+ TextComponent.body = function Body(props) {
665
+ const theme2 = useTheme3();
666
+ return /* @__PURE__ */ jsx3(TextComponent, { color: theme2.colors.textSecondary, ...props });
667
+ };
668
+ TextComponent.caption = function Caption(props) {
669
+ const theme2 = useTheme3();
670
+ return /* @__PURE__ */ jsx3(TextComponent, { fontSize: 14, color: theme2.colors.textSecondary, ...props });
671
+ };
672
+ TextComponent.unknown = function Unknown(props) {
673
+ const theme2 = useTheme3();
674
+ return /* @__PURE__ */ jsx3(TextComponent, { fontStyle: "italic", textAlign: "center", color: theme2.colors.textSecondary, ...props });
675
+ };
676
+ var Text2 = memo3(TextComponent);
677
+ Text2.title = TextComponent.title;
678
+ Text2.subtitle = TextComponent.subtitle;
679
+ Text2.body = TextComponent.body;
680
+ Text2.caption = TextComponent.caption;
681
+ Text2.unknown = TextComponent.unknown;
682
+ var Text_default = Text2;
683
+
684
+ // src/components/Button.tsx
685
+ import { memo as memo6 } from "react";
686
+ import { useLoader, useTheme as useTheme5 } from "react-better-core";
687
+
688
+ // src/components/Animate.tsx
689
+ import { memo as memo4, useMemo as useMemo5 } from "react";
690
+ import { Motion } from "@legendapp/motion";
691
+ import { jsx as jsx4 } from "react/jsx-runtime";
692
+ var defaultTransitionDuration = 0.15 * 1e3;
693
+ var Animate = {
694
+ View: memo4(function View3({ transformOriginX, transformOriginY, children, ...props }) {
695
+ const initialProps = useComponentPropsGrouper(props, "initial");
696
+ const animateProps2 = useComponentPropsGrouper(props, "animate");
697
+ const whileTapProps = useComponentPropsGrouper(props, "whileTap");
698
+ const transitionProps = useComponentPropsGrouper(props, "transition");
699
+ const transition = useMemo5(
700
+ () => ({
701
+ type: "timing",
702
+ duration: defaultTransitionDuration,
703
+ ...transitionProps.withPrefixStyle
704
+ }),
705
+ [transitionProps.withPrefixStyle]
706
+ );
707
+ const transformOrigin = useMemo5(
708
+ () => transformOriginX !== void 0 || transformOriginY !== void 0 ? {
709
+ x: transformOriginX ?? 0,
710
+ y: transformOriginY ?? 0
711
+ } : void 0,
712
+ [transformOriginX, transformOriginY]
713
+ );
714
+ const content = /* @__PURE__ */ jsx4(
715
+ Motion.View,
716
+ {
717
+ style: initialProps.style,
718
+ initial: initialProps.withPrefixStyle,
719
+ animate: animateProps2.withPrefixStyle,
720
+ transition,
721
+ whileTap: whileTapProps.withPrefixStyle,
722
+ transformOrigin,
723
+ children
724
+ }
725
+ );
726
+ return Object.keys(whileTapProps.withPrefixStyle).length > 0 ? /* @__PURE__ */ jsx4(Motion.Pressable, { children: content }) : content;
727
+ }),
728
+ Text: memo4(function Text3({ transformOriginX, transformOriginY, children, ...props }) {
729
+ const initialProps = useComponentPropsGrouper(props, "initial");
730
+ const animateProps2 = useComponentPropsGrouper(props, "animate");
731
+ const whileTapProps = useComponentPropsGrouper(props, "whileTap");
732
+ const transitionProps = useComponentPropsGrouper(props, "transition");
733
+ const transition = useMemo5(
734
+ () => ({
735
+ type: "timing",
736
+ duration: defaultTransitionDuration,
737
+ ...transitionProps.withPrefixStyle
738
+ }),
739
+ [transitionProps.withPrefixStyle]
740
+ );
741
+ const transformOrigin = useMemo5(
742
+ () => transformOriginX !== void 0 || transformOriginY !== void 0 ? {
743
+ x: transformOriginX ?? 0,
744
+ y: transformOriginY ?? 0
745
+ } : void 0,
746
+ [transformOriginX, transformOriginY]
747
+ );
748
+ const content = /* @__PURE__ */ jsx4(
749
+ Motion.Text,
750
+ {
751
+ style: initialProps.style,
752
+ initial: initialProps.withPrefixStyle,
753
+ animate: animateProps2.withPrefixStyle,
754
+ transition,
755
+ whileTap: whileTapProps.withPrefixStyle,
756
+ transformOrigin,
757
+ children
758
+ }
759
+ );
760
+ return Object.keys(whileTapProps.withPrefixStyle).length > 0 ? /* @__PURE__ */ jsx4(Motion.Pressable, { children: content }) : content;
761
+ })
762
+ };
763
+ var Animate_default = Animate;
764
+
765
+ // src/components/Loader.tsx
766
+ import { memo as memo5 } from "react";
767
+ import { ActivityIndicator } from "react-native";
768
+ import { useTheme as useTheme4 } from "react-better-core";
769
+ import { jsx as jsx5, jsxs } from "react/jsx-runtime";
770
+ var LoaderComponent = function Loader({ size = "small", color, ...props }) {
771
+ const theme2 = useTheme4();
772
+ return /* @__PURE__ */ jsx5(View_default, { ...props, children: /* @__PURE__ */ jsx5(ActivityIndicator, { size, color: color ?? theme2.colors.textPrimary }) });
773
+ };
774
+ LoaderComponent.box = function Box2({ text = "Loading...", size = "large", color, ...props }) {
775
+ const theme2 = useTheme4();
776
+ return /* @__PURE__ */ jsxs(
777
+ View_default,
778
+ {
779
+ width: "100%",
780
+ alignItems: "center",
781
+ gap: theme2.styles.gap,
782
+ marginVertical: theme2.styles.space,
783
+ ...props,
784
+ children: [
785
+ /* @__PURE__ */ jsx5(Loader2, { size, color }),
786
+ text && /* @__PURE__ */ jsx5(Text_default, { textAlign: "center", color: color ?? theme2.colors.textSecondary, children: text })
787
+ ]
788
+ }
789
+ );
790
+ };
791
+ LoaderComponent.text = function LoaderText({ text = "Loading...", size, color, ...props }) {
792
+ const theme2 = useTheme4();
793
+ return /* @__PURE__ */ jsxs(
794
+ View_default,
795
+ {
796
+ isRow: true,
797
+ alignItems: "center",
798
+ justifyContent: "center",
799
+ gap: theme2.styles.gap,
800
+ marginVertical: theme2.styles.space,
801
+ ...props,
802
+ children: [
803
+ /* @__PURE__ */ jsx5(Loader2, { size, color }),
804
+ text && /* @__PURE__ */ jsx5(Text_default, { textAlign: "center", color: color ?? theme2.colors.textSecondary, children: text })
805
+ ]
806
+ }
807
+ );
808
+ };
809
+ var Loader2 = memo5(LoaderComponent);
810
+ Loader2.box = LoaderComponent.box;
811
+ Loader2.text = LoaderComponent.text;
812
+ var Loader_default = Loader2;
813
+
814
+ // src/components/Button.tsx
815
+ import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
816
+ var ButtonComponent = function Button({
817
+ text,
818
+ textFontSize = 16,
819
+ textFontWeight = 700,
820
+ textDecorationLine,
821
+ textColor,
822
+ icon,
823
+ iconPosition = "left",
824
+ iconColor,
825
+ iconSize,
826
+ image,
827
+ imagePosition = "left",
828
+ imageWidth,
829
+ imageHeight,
830
+ loaderName,
831
+ isLoading,
832
+ isSmall,
833
+ animateOpacity,
834
+ flex,
835
+ alignSelf,
836
+ disabled,
837
+ ...props
838
+ }) {
839
+ const theme2 = useTheme5();
840
+ const isLoadingLoader = useLoader(loaderName);
841
+ const isLoadingElement = isLoading || isLoadingLoader;
842
+ const isDisabled = disabled || isLoadingElement;
843
+ const lineHeight = 20;
844
+ const color = textColor ?? theme2.colors.base;
845
+ const paddingVertical = props.paddingVertical ? parseFloat(props.paddingVertical.toString()) : theme2.styles.space;
846
+ const paddingHorizontal = props.paddingHorizontal ? parseFloat(props.paddingHorizontal.toString()) : theme2.styles.space + theme2.styles.gap;
847
+ return /* @__PURE__ */ jsx6(
848
+ Animate_default.View,
849
+ {
850
+ position: "relative",
851
+ flex,
852
+ alignSelf: alignSelf ?? (isSmall === "left" ? "flex-start" : isSmall === "right" ? "flex-end" : isSmall === "center" ? "center" : isSmall ? "baseline" : void 0),
853
+ initialOpacity: 1,
854
+ animateOpacity: animateOpacity ?? (disabled ? 0.6 : 1),
855
+ children: /* @__PURE__ */ jsxs2(
856
+ View_default,
857
+ {
858
+ position: "relative",
859
+ width: !isSmall ? "100%" : void 0,
860
+ alignItems: "center",
861
+ justifyContent: "center",
862
+ backgroundColor: theme2.colors.primary,
863
+ borderRadius: theme2.styles.borderRadius,
864
+ paddingVertical,
865
+ paddingHorizontal,
866
+ disabled: isDisabled,
867
+ ...props,
868
+ children: [
869
+ /* @__PURE__ */ jsx6(Animate_default.View, { initialOpacity: 1, animateOpacity: isLoadingElement ? 0 : 1, children: text && /* @__PURE__ */ jsx6(
870
+ Text_default,
871
+ {
872
+ fontSize: textFontSize,
873
+ fontWeight: textFontWeight,
874
+ textDecorationLine,
875
+ textDecorationColor: color,
876
+ textAlign: "center",
877
+ lineHeight,
878
+ color,
879
+ children: text
880
+ }
881
+ ) }),
882
+ /* @__PURE__ */ jsx6(
883
+ Animate_default.View,
884
+ {
885
+ position: "absolute",
886
+ width: "100%",
887
+ height: paddingVertical + lineHeight + paddingVertical,
888
+ left: paddingHorizontal,
889
+ alignItems: "center",
890
+ justifyContent: "center",
891
+ initialOpacity: 0,
892
+ animateOpacity: isLoadingElement ? 1 : 0,
893
+ children: /* @__PURE__ */ jsx6(Loader_default, { color })
894
+ }
895
+ )
896
+ ]
897
+ }
898
+ )
899
+ }
900
+ );
901
+ };
902
+ ButtonComponent.secondary = function Secondary(props) {
903
+ const theme2 = useTheme5();
904
+ return /* @__PURE__ */ jsx6(
905
+ ButtonComponent,
906
+ {
907
+ backgroundColor: theme2.colors.backgroundContent,
908
+ borderWidth: 1,
909
+ borderColor: theme2.colors.border,
910
+ textColor: theme2.colors.textPrimary,
911
+ pressStrength: pressStrength().z05,
912
+ animateOpacity: props.disabled ? 0.4 : 1,
913
+ ...props
914
+ }
915
+ );
916
+ };
917
+ ButtonComponent.destructive = function Destructive(props) {
918
+ const theme2 = useTheme5();
919
+ return /* @__PURE__ */ jsx6(ButtonComponent, { backgroundColor: theme2.colors.error, ...props });
920
+ };
921
+ ButtonComponent.text = function ButtonText(props) {
922
+ const theme2 = useTheme5();
923
+ return /* @__PURE__ */ jsx6(
924
+ ButtonComponent,
925
+ {
926
+ width: "auto",
927
+ textColor: theme2.colors.textPrimary,
928
+ textDecorationLine: "underline",
929
+ backgroundColor: "transparent",
930
+ paddingHorizontal: theme2.styles.space,
931
+ paddingVertical: theme2.styles.gap,
932
+ isSmall: true,
933
+ pressType: "opacity",
934
+ ...props
935
+ }
936
+ );
937
+ };
938
+ var Button2 = memo6(ButtonComponent);
939
+ Button2.secondary = ButtonComponent.secondary;
940
+ Button2.destructive = ButtonComponent.destructive;
941
+ Button2.text = ButtonComponent.text;
942
+ var Button_default = Button2;
943
+
944
+ // src/components/ScreenHolder.tsx
945
+ import { memo as memo7, useCallback } from "react";
946
+ import { RefreshControl, ScrollView } from "react-native";
947
+ import { useBooleanState as useBooleanState2, useTheme as useTheme6 } from "react-better-core";
948
+ import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
949
+ var ScreenHolderComponent = ({
950
+ noScroll,
951
+ noSideSpace,
952
+ refreshTimeout = 1,
953
+ onRefresh,
954
+ onRefreshEnd,
955
+ backgroundColor,
956
+ insideTopSafeArea,
957
+ insideBottomSafeArea,
958
+ bottomSpace = 0,
959
+ footer,
960
+ children
961
+ }) => {
962
+ const theme2 = useTheme6();
963
+ const device = useDevice();
964
+ const [isRefreshing, setIsRefreshing] = useBooleanState2();
965
+ const onRefreshElement = useCallback(() => {
966
+ setIsRefreshing.setTrue();
967
+ onRefresh?.();
968
+ setTimeout(() => {
969
+ setIsRefreshing.setFalse();
970
+ onRefreshEnd?.();
971
+ }, refreshTimeout * 1e3);
972
+ }, [onRefresh, onRefreshEnd, refreshTimeout]);
973
+ const content = /* @__PURE__ */ jsx7(
974
+ View_default,
975
+ {
976
+ flex: 1,
977
+ paddingHorizontal: !noSideSpace ? theme2.styles.space : void 0,
978
+ paddingTop: theme2.styles.gap + (insideTopSafeArea ? device.safeArea.afterCalculations.top : 0),
979
+ paddingBottom: bottomSpace + (insideBottomSafeArea ? device.safeArea.afterCalculations.bottom : 0),
980
+ children
981
+ }
982
+ );
983
+ const withRefresh = onRefresh || onRefreshEnd;
984
+ return /* @__PURE__ */ jsxs3(View_default, { flex: 1, backgroundColor: backgroundColor ?? theme2.colors.backgroundBase, children: [
985
+ /* @__PURE__ */ jsx7(View_default, { flex: 1, children: noScroll ? content : /* @__PURE__ */ jsx7(
986
+ ScrollView,
987
+ {
988
+ refreshControl: withRefresh ? /* @__PURE__ */ jsx7(RefreshControl, { refreshing: isRefreshing, onRefresh: onRefreshElement }) : void 0,
989
+ children: content
990
+ }
991
+ ) }),
992
+ footer && /* @__PURE__ */ jsx7(View_default, { children: footer })
993
+ ] });
994
+ };
995
+ ScreenHolderComponent.footer = function Footer({
996
+ noSideSpace,
997
+ backgroundColor,
998
+ insideBottomSafeArea,
999
+ children
1000
+ }) {
1001
+ const theme2 = useTheme6();
1002
+ const device = useDevice();
1003
+ return /* @__PURE__ */ jsx7(
1004
+ View_default,
1005
+ {
1006
+ backgroundColor: backgroundColor ?? theme2.colors.backgroundBase,
1007
+ paddingHorizontal: !noSideSpace ? theme2.styles.space : void 0,
1008
+ paddingTop: theme2.styles.gap,
1009
+ paddingBottom: insideBottomSafeArea ? device.safeArea.afterCalculations.bottom : void 0,
1010
+ children
1011
+ }
1012
+ );
1013
+ };
1014
+ var ScreenHolder = memo7(ScreenHolderComponent);
1015
+ ScreenHolder.footer = ScreenHolderComponent.footer;
1016
+ var ScreenHolder_default = ScreenHolder;
1017
+
1018
+ // src/plugins/asyncStorage.ts
1019
+ var defaultAsyncStoragePluginOptions = {};
1020
+ var asyncStoragePlugin = (options) => ({
1021
+ name: "asyncStorage",
1022
+ initialize: () => {
1023
+ console.log("asyncStorage plugin initialized");
1024
+ },
1025
+ getConfig: () => ({
1026
+ ...defaultAsyncStoragePluginOptions,
1027
+ ...options
1028
+ })
1029
+ });
1030
+ export {
1031
+ Animate_default as Animate,
1032
+ BetterComponentsProvider_default as BetterComponentsProvider,
1033
+ Button_default as Button,
1034
+ Loader_default as Loader,
1035
+ ScreenHolder_default as ScreenHolder,
1036
+ Text_default as Text,
1037
+ View_default as View,
1038
+ asyncStoragePlugin,
1039
+ colorThemeControls,
1040
+ countries,
1041
+ darkenColor,
1042
+ defaultAsyncStoragePluginOptions,
1043
+ desaturateColor,
1044
+ eventPreventDefault,
1045
+ eventPreventStop,
1046
+ eventStopPropagation,
1047
+ formatPhoneNumber,
1048
+ generateAsyncStorage,
1049
+ generateRandomString,
1050
+ getPluralWord,
1051
+ lightenColor,
1052
+ loaderControls,
1053
+ pressStrength,
1054
+ saturateColor,
1055
+ useBetterComponentsContext,
1056
+ useBooleanState3 as useBooleanState,
1057
+ useDebounceState,
1058
+ useDevice,
1059
+ useLoader2 as useLoader,
1060
+ useLoaderControls,
1061
+ useTheme7 as useTheme
1062
+ };
1063
+ //# sourceMappingURL=index.mjs.map