react-native-better-html 1.0.23 → 1.0.25
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 +21 -6
- package/dist/index.d.ts +21 -6
- package/dist/index.js +181 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +165 -53
- 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 useTheme16,
|
|
4
4
|
useLoader as useLoader2,
|
|
5
5
|
useLoaderControls,
|
|
6
6
|
countries,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
eventStopPropagation,
|
|
15
15
|
eventPreventStop,
|
|
16
16
|
getPluralWord,
|
|
17
|
-
useBooleanState as
|
|
17
|
+
useBooleanState as useBooleanState7,
|
|
18
18
|
useDebounceState,
|
|
19
19
|
loaderControls,
|
|
20
20
|
colorThemeControls
|
|
@@ -452,6 +452,22 @@ function useForm(options) {
|
|
|
452
452
|
},
|
|
453
453
|
[values, setFieldValue]
|
|
454
454
|
);
|
|
455
|
+
const getCheckBoxProps = useCallback(
|
|
456
|
+
(field, insideListItem) => {
|
|
457
|
+
return insideListItem ? {
|
|
458
|
+
checkBoxIsChecked: values[field],
|
|
459
|
+
checkBoxOnChange: (value) => {
|
|
460
|
+
setFieldValue(field, value);
|
|
461
|
+
}
|
|
462
|
+
} : {
|
|
463
|
+
isChecked: values[field],
|
|
464
|
+
onChange: (value) => {
|
|
465
|
+
setFieldValue(field, value);
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
},
|
|
469
|
+
[values, setFieldValue]
|
|
470
|
+
);
|
|
455
471
|
const reset = useCallback(() => {
|
|
456
472
|
setValues(defaultValues);
|
|
457
473
|
setErrors({});
|
|
@@ -476,6 +492,7 @@ function useForm(options) {
|
|
|
476
492
|
setFieldsValue,
|
|
477
493
|
getInputFieldProps,
|
|
478
494
|
getSwitchProps,
|
|
495
|
+
getCheckBoxProps,
|
|
479
496
|
focusField,
|
|
480
497
|
inputFieldRefs: inputFieldRefs.current,
|
|
481
498
|
validate: validateForm,
|
|
@@ -512,6 +529,8 @@ import { useTheme as useTheme2 } from "react-better-core";
|
|
|
512
529
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
513
530
|
var touchableHighlightStyleMoveToContent = [
|
|
514
531
|
"width",
|
|
532
|
+
"alignItems",
|
|
533
|
+
"justifyContent",
|
|
515
534
|
"backgroundColor",
|
|
516
535
|
"padding",
|
|
517
536
|
"paddingTop",
|
|
@@ -1883,6 +1902,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1883
1902
|
/* @__PURE__ */ jsx12(Text_default, { fontSize: 14, color: isError ? theme2.colors.error : theme2.colors.textSecondary, children: label }),
|
|
1884
1903
|
required && /* @__PURE__ */ jsx12(Text_default, { color: theme2.colors.error, children: "*" })
|
|
1885
1904
|
] });
|
|
1905
|
+
const borderColor = isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border;
|
|
1886
1906
|
return /* @__PURE__ */ jsxs6(
|
|
1887
1907
|
Animate_default.View,
|
|
1888
1908
|
{
|
|
@@ -1894,10 +1914,11 @@ var InputFieldComponent = forwardRef(
|
|
|
1894
1914
|
children: [
|
|
1895
1915
|
isIOSDateTime && !iOSDateTimeFullSize ? void 0 : labelComponent,
|
|
1896
1916
|
/* @__PURE__ */ jsxs6(View_default, { isRow: true, position: "relative", alignItems: "center", height: readyHeight, children: [
|
|
1897
|
-
prefix && /* @__PURE__ */
|
|
1917
|
+
prefix && /* @__PURE__ */ jsxs6(
|
|
1898
1918
|
View_default,
|
|
1899
1919
|
{
|
|
1900
1920
|
isRow: true,
|
|
1921
|
+
position: "relative",
|
|
1901
1922
|
height: "100%",
|
|
1902
1923
|
backgroundColor: prefixSuffixBackgroundColor,
|
|
1903
1924
|
alignItems: "center",
|
|
@@ -1908,16 +1929,23 @@ var InputFieldComponent = forwardRef(
|
|
|
1908
1929
|
borderBottomLeftRadius: theme2.styles.borderRadius,
|
|
1909
1930
|
borderColor: theme2.colors.border,
|
|
1910
1931
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1932
|
+
zIndex: 1,
|
|
1911
1933
|
onPress: onPressPrefix,
|
|
1912
|
-
children:
|
|
1913
|
-
Text_default,
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1934
|
+
children: [
|
|
1935
|
+
typeof prefix === "string" ? /* @__PURE__ */ jsx12(Text_default, { fontWeight: 700, lineHeight, children: prefix }) : prefix,
|
|
1936
|
+
/* @__PURE__ */ jsx12(
|
|
1937
|
+
Animate_default.View,
|
|
1938
|
+
{
|
|
1939
|
+
position: "absolute",
|
|
1940
|
+
top: 0,
|
|
1941
|
+
right: -1,
|
|
1942
|
+
width: 1,
|
|
1943
|
+
height: "100%",
|
|
1944
|
+
initialBackgroundColor: theme2.colors.border,
|
|
1945
|
+
animateBackgroundColor: borderColor
|
|
1946
|
+
}
|
|
1947
|
+
)
|
|
1948
|
+
]
|
|
1921
1949
|
}
|
|
1922
1950
|
),
|
|
1923
1951
|
isIOSDateTime ? /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
@@ -1952,13 +1980,15 @@ var InputFieldComponent = forwardRef(
|
|
|
1952
1980
|
flex: 1,
|
|
1953
1981
|
justifyContent: "center",
|
|
1954
1982
|
backgroundColor: theme2.colors.backgroundContent,
|
|
1955
|
-
borderTopLeftRadius: prefix ?
|
|
1956
|
-
borderBottomLeftRadius: prefix ?
|
|
1957
|
-
borderTopRightRadius: suffix ?
|
|
1958
|
-
borderBottomRightRadius: suffix ?
|
|
1983
|
+
borderTopLeftRadius: prefix ? 2 : theme2.styles.borderRadius,
|
|
1984
|
+
borderBottomLeftRadius: prefix ? 2 : theme2.styles.borderRadius,
|
|
1985
|
+
borderTopRightRadius: suffix ? 2 : theme2.styles.borderRadius,
|
|
1986
|
+
borderBottomRightRadius: suffix ? 2 : theme2.styles.borderRadius,
|
|
1959
1987
|
borderWidth,
|
|
1988
|
+
marginLeft: prefix ? -2 : 0,
|
|
1989
|
+
marginRight: suffix ? -2 : 0,
|
|
1960
1990
|
initialBorderColor: theme2.colors.border,
|
|
1961
|
-
animateBorderColor:
|
|
1991
|
+
animateBorderColor: borderColor,
|
|
1962
1992
|
overflow: "hidden",
|
|
1963
1993
|
children: [
|
|
1964
1994
|
leftIcon && /* @__PURE__ */ jsx12(
|
|
@@ -2025,29 +2055,38 @@ var InputFieldComponent = forwardRef(
|
|
|
2025
2055
|
)
|
|
2026
2056
|
}
|
|
2027
2057
|
),
|
|
2028
|
-
suffix && /* @__PURE__ */
|
|
2058
|
+
suffix && /* @__PURE__ */ jsxs6(
|
|
2029
2059
|
View_default,
|
|
2030
2060
|
{
|
|
2031
2061
|
isRow: true,
|
|
2062
|
+
position: "relative",
|
|
2032
2063
|
height: "100%",
|
|
2033
2064
|
backgroundColor: prefixSuffixBackgroundColor,
|
|
2034
2065
|
alignItems: "center",
|
|
2066
|
+
justifyContent: "center",
|
|
2035
2067
|
borderWidth,
|
|
2036
2068
|
borderLeftWidth: 0,
|
|
2037
2069
|
borderTopRightRadius: theme2.styles.borderRadius,
|
|
2038
2070
|
borderBottomRightRadius: theme2.styles.borderRadius,
|
|
2039
2071
|
borderColor: theme2.colors.border,
|
|
2040
2072
|
paddingHorizontal: readyPaddingHorizontal,
|
|
2073
|
+
zIndex: 1,
|
|
2041
2074
|
onPress: onPressSuffix,
|
|
2042
|
-
children:
|
|
2043
|
-
Text_default,
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2075
|
+
children: [
|
|
2076
|
+
typeof suffix === "string" ? /* @__PURE__ */ jsx12(Text_default, { fontWeight: 700, lineHeight, children: suffix }) : suffix,
|
|
2077
|
+
/* @__PURE__ */ jsx12(
|
|
2078
|
+
Animate_default.View,
|
|
2079
|
+
{
|
|
2080
|
+
position: "absolute",
|
|
2081
|
+
top: 0,
|
|
2082
|
+
left: -1,
|
|
2083
|
+
width: 1,
|
|
2084
|
+
height: "100%",
|
|
2085
|
+
initialBackgroundColor: theme2.colors.border,
|
|
2086
|
+
animateBackgroundColor: borderColor
|
|
2087
|
+
}
|
|
2088
|
+
)
|
|
2089
|
+
]
|
|
2051
2090
|
}
|
|
2052
2091
|
)
|
|
2053
2092
|
] }),
|
|
@@ -2195,10 +2234,10 @@ function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
|
2195
2234
|
width: "100%",
|
|
2196
2235
|
height: ballGap + ballSize + ballGap,
|
|
2197
2236
|
borderRadius: 999,
|
|
2198
|
-
initialOpacity: 1,
|
|
2199
|
-
animateOpacity: disabled ? 0.6 : 1,
|
|
2200
2237
|
initialBackgroundColor: theme2.colors.border,
|
|
2201
2238
|
animateBackgroundColor: enabled ? theme2.colors.primary : theme2.colors.border,
|
|
2239
|
+
initialOpacity: 1,
|
|
2240
|
+
animateOpacity: disabled ? 0.6 : 1,
|
|
2202
2241
|
children: /* @__PURE__ */ jsx13(
|
|
2203
2242
|
Animate_default.View,
|
|
2204
2243
|
{
|
|
@@ -2206,6 +2245,9 @@ function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
|
2206
2245
|
height: ballSize,
|
|
2207
2246
|
top: ballGap,
|
|
2208
2247
|
borderRadius: 999,
|
|
2248
|
+
transitionType: "spring",
|
|
2249
|
+
transitionDamping: 20,
|
|
2250
|
+
transitionStiffness: 230,
|
|
2209
2251
|
backgroundColor: theme2.colors.backgroundContent,
|
|
2210
2252
|
initialX: ballGap,
|
|
2211
2253
|
animateX: enabled ? holderWidth - ballGap - ballSize : ballGap
|
|
@@ -2218,28 +2260,95 @@ function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
|
2218
2260
|
}
|
|
2219
2261
|
var Switch_default = memo13(Switch);
|
|
2220
2262
|
|
|
2221
|
-
// src/components/
|
|
2222
|
-
import { memo as memo14 } from "react";
|
|
2223
|
-
import {
|
|
2224
|
-
import {
|
|
2263
|
+
// src/components/CheckBox.tsx
|
|
2264
|
+
import { memo as memo14, useCallback as useCallback8, useEffect as useEffect8 } from "react";
|
|
2265
|
+
import { Platform as Platform7 } from "react-native";
|
|
2266
|
+
import { useBooleanState as useBooleanState6, useTheme as useTheme13 } from "react-better-core";
|
|
2225
2267
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
2226
|
-
function
|
|
2268
|
+
function CheckBox({ isChecked, defaultIsChecked, size = 36, disabled, onChange }) {
|
|
2227
2269
|
const theme2 = useTheme13();
|
|
2270
|
+
const [checked, setChecked] = useBooleanState6(isChecked ?? defaultIsChecked);
|
|
2271
|
+
const onPressElement = useCallback8(() => {
|
|
2272
|
+
onChange?.(!checked);
|
|
2273
|
+
setChecked.toggle();
|
|
2274
|
+
}, [onChange, checked]);
|
|
2275
|
+
useEffect8(() => {
|
|
2276
|
+
if (isChecked === void 0) return;
|
|
2277
|
+
setChecked.setState(isChecked);
|
|
2278
|
+
}, [isChecked]);
|
|
2228
2279
|
return /* @__PURE__ */ jsx14(
|
|
2280
|
+
View_default,
|
|
2281
|
+
{
|
|
2282
|
+
width: size,
|
|
2283
|
+
borderRadius: theme2.styles.borderRadius,
|
|
2284
|
+
pressStrength: pressStrength().p05,
|
|
2285
|
+
disabled,
|
|
2286
|
+
onPress: !disabled ? onPressElement : void 0,
|
|
2287
|
+
children: /* @__PURE__ */ jsx14(
|
|
2288
|
+
Animate_default.View,
|
|
2289
|
+
{
|
|
2290
|
+
width: "100%",
|
|
2291
|
+
height: size,
|
|
2292
|
+
borderWidth: 1,
|
|
2293
|
+
borderRadius: theme2.styles.borderRadius,
|
|
2294
|
+
initialBackgroundColor: theme2.colors.backgroundContent,
|
|
2295
|
+
animateBackgroundColor: checked ? theme2.colors.primary : theme2.colors.backgroundContent,
|
|
2296
|
+
initialBorderColor: theme2.colors.border,
|
|
2297
|
+
animateBorderColor: checked ? theme2.colors.primary : theme2.colors.border,
|
|
2298
|
+
initialOpacity: 1,
|
|
2299
|
+
animateOpacity: disabled ? 0.6 : 1,
|
|
2300
|
+
children: /* @__PURE__ */ jsx14(
|
|
2301
|
+
Animate_default.View,
|
|
2302
|
+
{
|
|
2303
|
+
width: "100%",
|
|
2304
|
+
height: "100%",
|
|
2305
|
+
alignItems: "center",
|
|
2306
|
+
justifyContent: "center",
|
|
2307
|
+
transitionType: "spring",
|
|
2308
|
+
transitionDamping: 20,
|
|
2309
|
+
transitionStiffness: 230,
|
|
2310
|
+
initialScale: 0,
|
|
2311
|
+
animateScale: checked ? 1 : 0,
|
|
2312
|
+
children: /* @__PURE__ */ jsx14(
|
|
2313
|
+
Icon_default,
|
|
2314
|
+
{
|
|
2315
|
+
name: "check",
|
|
2316
|
+
nameIOS: "checkmark",
|
|
2317
|
+
size: size * (Platform7.OS === "ios" ? 0.5 : 0.6),
|
|
2318
|
+
color: theme2.colors.base
|
|
2319
|
+
}
|
|
2320
|
+
)
|
|
2321
|
+
}
|
|
2322
|
+
)
|
|
2323
|
+
}
|
|
2324
|
+
)
|
|
2325
|
+
}
|
|
2326
|
+
);
|
|
2327
|
+
}
|
|
2328
|
+
var CheckBox_default = memo14(CheckBox);
|
|
2329
|
+
|
|
2330
|
+
// src/components/StatusBar.tsx
|
|
2331
|
+
import { memo as memo15 } from "react";
|
|
2332
|
+
import { useTheme as useTheme14 } from "react-better-core";
|
|
2333
|
+
import { StatusBar as NativeStatusBar, Platform as Platform8 } from "react-native";
|
|
2334
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
2335
|
+
function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarStyle }) {
|
|
2336
|
+
const theme2 = useTheme14();
|
|
2337
|
+
return /* @__PURE__ */ jsx15(
|
|
2229
2338
|
NativeStatusBar,
|
|
2230
2339
|
{
|
|
2231
2340
|
backgroundColor: darkStatusBar ? theme2.colors.backgroundSecondary : void 0,
|
|
2232
|
-
barStyle: barStyle ?? (
|
|
2341
|
+
barStyle: barStyle ?? (Platform8.OS === "android" ? androidBarStyle : iOSBarStyle),
|
|
2233
2342
|
hidden
|
|
2234
2343
|
}
|
|
2235
2344
|
);
|
|
2236
2345
|
}
|
|
2237
|
-
var StatusBar_default =
|
|
2346
|
+
var StatusBar_default = memo15(StatusBar);
|
|
2238
2347
|
|
|
2239
2348
|
// src/components/ListItem.tsx
|
|
2240
|
-
import { memo as
|
|
2241
|
-
import { useTheme as
|
|
2242
|
-
import { Fragment as Fragment5, jsx as
|
|
2349
|
+
import { memo as memo16 } from "react";
|
|
2350
|
+
import { useTheme as useTheme15 } from "react-better-core";
|
|
2351
|
+
import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2243
2352
|
function ListItem({
|
|
2244
2353
|
icon,
|
|
2245
2354
|
iconIOS,
|
|
@@ -2253,12 +2362,14 @@ function ListItem({
|
|
|
2253
2362
|
rightValue,
|
|
2254
2363
|
rightValueSelectable,
|
|
2255
2364
|
switchIsEnabled,
|
|
2256
|
-
switchOnChange
|
|
2365
|
+
switchOnChange,
|
|
2366
|
+
checkBoxIsChecked,
|
|
2367
|
+
checkBoxOnChange
|
|
2257
2368
|
}) {
|
|
2258
|
-
const theme2 =
|
|
2369
|
+
const theme2 = useTheme15();
|
|
2259
2370
|
const device = useDevice();
|
|
2260
2371
|
const sideSpace = theme2.styles.space;
|
|
2261
|
-
return /* @__PURE__ */
|
|
2372
|
+
return /* @__PURE__ */ jsx16(
|
|
2262
2373
|
View_default,
|
|
2263
2374
|
{
|
|
2264
2375
|
width: insideScreenHolder ? device.windowDimensions.width : "100%",
|
|
@@ -2269,14 +2380,14 @@ function ListItem({
|
|
|
2269
2380
|
pressStrength: pressStrength().p05,
|
|
2270
2381
|
onPress,
|
|
2271
2382
|
children: /* @__PURE__ */ jsxs7(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.space, children: [
|
|
2272
|
-
icon && /* @__PURE__ */
|
|
2273
|
-
/* @__PURE__ */
|
|
2274
|
-
title && /* @__PURE__ */
|
|
2275
|
-
description && /* @__PURE__ */
|
|
2383
|
+
icon && /* @__PURE__ */ jsx16(Icon_default, { name: icon, nameIOS: iconIOS, size: 22, color: theme2.colors.primary }),
|
|
2384
|
+
/* @__PURE__ */ jsx16(View_default, { flex: 1, flexDirection: "row", alignItems: "center", gap: theme2.styles.gap, children: /* @__PURE__ */ jsxs7(View_default, { flex: 1, children: [
|
|
2385
|
+
title && /* @__PURE__ */ jsx16(Text_default, { fontSize: 20, fontWeight: 700, children: title }),
|
|
2386
|
+
description && /* @__PURE__ */ jsx16(Text_default.body, { selectable: descriptionSelectable, children: description })
|
|
2276
2387
|
] }) }),
|
|
2277
|
-
rightElement ? /* @__PURE__ */
|
|
2278
|
-
rightValue !== void 0 && /* @__PURE__ */
|
|
2279
|
-
rightElement === "arrow" && /* @__PURE__ */
|
|
2388
|
+
rightElement ? /* @__PURE__ */ jsx16(Fragment5, { children: rightValue !== void 0 || rightElement === "arrow" ? /* @__PURE__ */ jsxs7(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.gap / 2, children: [
|
|
2389
|
+
rightValue !== void 0 && /* @__PURE__ */ jsx16(Text_default, { fontSize: 14, fontWeight: 700, selectable: rightValueSelectable, children: rightValue }),
|
|
2390
|
+
rightElement === "arrow" && /* @__PURE__ */ jsx16(
|
|
2280
2391
|
Icon_default,
|
|
2281
2392
|
{
|
|
2282
2393
|
name: "chevronRight",
|
|
@@ -2284,16 +2395,17 @@ function ListItem({
|
|
|
2284
2395
|
color: rightValue !== void 0 ? theme2.colors.textPrimary : theme2.colors.textSecondary
|
|
2285
2396
|
}
|
|
2286
2397
|
)
|
|
2287
|
-
] }) : rightElement === "switch" ? /* @__PURE__ */
|
|
2398
|
+
] }) : rightElement === "switch" ? /* @__PURE__ */ jsx16(Switch_default, { isEnabled: switchIsEnabled, onChange: switchOnChange }) : rightElement === "checkBox" ? /* @__PURE__ */ jsx16(CheckBox_default, { isChecked: checkBoxIsChecked, onChange: checkBoxOnChange }) : void 0 }) : void 0
|
|
2288
2399
|
] })
|
|
2289
2400
|
}
|
|
2290
2401
|
);
|
|
2291
2402
|
}
|
|
2292
|
-
var ListItem_default =
|
|
2403
|
+
var ListItem_default = memo16(ListItem);
|
|
2293
2404
|
export {
|
|
2294
2405
|
Animate_default as Animate,
|
|
2295
2406
|
BetterComponentsProvider_default as BetterComponentsProvider,
|
|
2296
2407
|
Button_default as Button,
|
|
2408
|
+
CheckBox_default as CheckBox,
|
|
2297
2409
|
Icon_default as Icon,
|
|
2298
2410
|
Image_default as Image,
|
|
2299
2411
|
InputField_default as InputField,
|
|
@@ -2327,7 +2439,7 @@ export {
|
|
|
2327
2439
|
saturateColor,
|
|
2328
2440
|
useAlertControls,
|
|
2329
2441
|
useBetterComponentsContext,
|
|
2330
|
-
|
|
2442
|
+
useBooleanState7 as useBooleanState,
|
|
2331
2443
|
useDebounceState,
|
|
2332
2444
|
useDevice,
|
|
2333
2445
|
useEventEmitter,
|
|
@@ -2335,6 +2447,6 @@ export {
|
|
|
2335
2447
|
useKeyboard,
|
|
2336
2448
|
useLoader2 as useLoader,
|
|
2337
2449
|
useLoaderControls,
|
|
2338
|
-
|
|
2450
|
+
useTheme16 as useTheme
|
|
2339
2451
|
};
|
|
2340
2452
|
//# sourceMappingURL=index.mjs.map
|