react-native-better-html 1.0.17 → 1.0.18
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 +35 -6
- package/dist/index.d.ts +35 -6
- package/dist/index.js +175 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -14
- 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 useTheme13,
|
|
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 useBooleanState6,
|
|
18
18
|
useDebounceState,
|
|
19
19
|
loaderControls,
|
|
20
20
|
colorThemeControls
|
|
@@ -535,6 +535,22 @@ function useForm(options) {
|
|
|
535
535
|
},
|
|
536
536
|
[values, setFieldValue, errors, requiredFields, additional, onSubmitFunction]
|
|
537
537
|
);
|
|
538
|
+
const getSwitchProps = useCallback(
|
|
539
|
+
(field, insideListItem) => {
|
|
540
|
+
return insideListItem ? {
|
|
541
|
+
switchIsEnabled: values[field],
|
|
542
|
+
switchOnChange: (value) => {
|
|
543
|
+
setFieldValue(field, value);
|
|
544
|
+
}
|
|
545
|
+
} : {
|
|
546
|
+
isEnabled: values[field],
|
|
547
|
+
onChange: (value) => {
|
|
548
|
+
setFieldValue(field, value);
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
},
|
|
552
|
+
[values, setFieldValue]
|
|
553
|
+
);
|
|
538
554
|
const reset = useCallback(() => {
|
|
539
555
|
setValues(defaultValues);
|
|
540
556
|
setErrors({});
|
|
@@ -558,6 +574,7 @@ function useForm(options) {
|
|
|
558
574
|
setFieldValue,
|
|
559
575
|
setFieldsValue,
|
|
560
576
|
getInputFieldProps,
|
|
577
|
+
getSwitchProps,
|
|
561
578
|
focusField,
|
|
562
579
|
inputFieldRefs: inputFieldRefs.current,
|
|
563
580
|
validate: validateForm,
|
|
@@ -1407,7 +1424,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1407
1424
|
autoCapitalize,
|
|
1408
1425
|
autoComplete,
|
|
1409
1426
|
autoCorrect,
|
|
1410
|
-
keyboardAppearance
|
|
1427
|
+
keyboardAppearance,
|
|
1411
1428
|
keyboardType,
|
|
1412
1429
|
secureTextEntry,
|
|
1413
1430
|
returnKeyLabel,
|
|
@@ -1611,6 +1628,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1611
1628
|
mode: type,
|
|
1612
1629
|
display: iOSDateTimeFullSize ? type === "date" ? "inline" : "spinner" : "default",
|
|
1613
1630
|
accentColor: theme2.colors.primary,
|
|
1631
|
+
themeVariant: colorTheme === "dark" ? "dark" : "light",
|
|
1614
1632
|
style: rnDateTimePickerStyle,
|
|
1615
1633
|
onChange: onChangeRNDateTimePicker
|
|
1616
1634
|
}
|
|
@@ -1673,7 +1691,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1673
1691
|
readOnly: !editable || disabled || type === "date" || type === "time",
|
|
1674
1692
|
textAlign,
|
|
1675
1693
|
editable: !disabled,
|
|
1676
|
-
keyboardAppearance,
|
|
1694
|
+
keyboardAppearance: keyboardAppearance ?? colorTheme === "dark" ? "dark" : "light",
|
|
1677
1695
|
keyboardType,
|
|
1678
1696
|
cursorColor: theme2.colors.primary,
|
|
1679
1697
|
selectionColor: theme2.colors.primary,
|
|
@@ -1831,23 +1849,148 @@ InputField.search = InputFieldComponent.search;
|
|
|
1831
1849
|
InputField.code = InputFieldComponent.code;
|
|
1832
1850
|
var InputField_default = InputField;
|
|
1833
1851
|
|
|
1834
|
-
// src/components/
|
|
1835
|
-
import { memo as memo11 } from "react";
|
|
1836
|
-
import {
|
|
1837
|
-
import {
|
|
1852
|
+
// src/components/Switch.tsx
|
|
1853
|
+
import { memo as memo11, useCallback as useCallback4, useEffect as useEffect6, useMemo as useMemo9 } from "react";
|
|
1854
|
+
import { Switch as NativeSwitch, Platform as Platform6 } from "react-native";
|
|
1855
|
+
import { useBooleanState as useBooleanState5, useTheme as useTheme10 } from "react-better-core";
|
|
1838
1856
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1839
|
-
function
|
|
1857
|
+
function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
|
|
1840
1858
|
const theme2 = useTheme10();
|
|
1841
|
-
|
|
1859
|
+
const [enabled, setEnabled] = useBooleanState5(isEnabled ?? defaultIsEnabled);
|
|
1860
|
+
const onPressElement = useCallback4(() => {
|
|
1861
|
+
onChange?.(!enabled);
|
|
1862
|
+
setEnabled.toggle();
|
|
1863
|
+
}, [onChange, enabled]);
|
|
1864
|
+
const trackColor = useMemo9(
|
|
1865
|
+
() => ({
|
|
1866
|
+
false: theme2.colors.border,
|
|
1867
|
+
true: theme2.colors.primary
|
|
1868
|
+
}),
|
|
1869
|
+
[theme2.colors]
|
|
1870
|
+
);
|
|
1871
|
+
useEffect6(() => {
|
|
1872
|
+
if (isEnabled === void 0) return;
|
|
1873
|
+
setEnabled.setState(isEnabled);
|
|
1874
|
+
}, [isEnabled]);
|
|
1875
|
+
const ballSize = 26;
|
|
1876
|
+
const ballGap = 3;
|
|
1877
|
+
const holderWidth = ballSize * 2.1;
|
|
1878
|
+
return Platform6.OS === "ios" ? /* @__PURE__ */ jsx11(
|
|
1879
|
+
NativeSwitch,
|
|
1880
|
+
{
|
|
1881
|
+
trackColor,
|
|
1882
|
+
ios_backgroundColor: theme2.colors.border,
|
|
1883
|
+
onValueChange: onPressElement,
|
|
1884
|
+
value: enabled,
|
|
1885
|
+
disabled
|
|
1886
|
+
}
|
|
1887
|
+
) : /* @__PURE__ */ jsx11(
|
|
1888
|
+
View_default,
|
|
1889
|
+
{
|
|
1890
|
+
width: holderWidth,
|
|
1891
|
+
borderRadius: 999,
|
|
1892
|
+
pressStrength: pressStrength().p05,
|
|
1893
|
+
disabled,
|
|
1894
|
+
onPress: !disabled ? onPressElement : void 0,
|
|
1895
|
+
children: /* @__PURE__ */ jsx11(
|
|
1896
|
+
Animate_default.View,
|
|
1897
|
+
{
|
|
1898
|
+
width: "100%",
|
|
1899
|
+
height: ballGap + ballSize + ballGap,
|
|
1900
|
+
borderRadius: 999,
|
|
1901
|
+
initialOpacity: 1,
|
|
1902
|
+
animateOpacity: disabled ? 0.6 : 1,
|
|
1903
|
+
initialBackgroundColor: theme2.colors.border,
|
|
1904
|
+
animateBackgroundColor: enabled ? theme2.colors.primary : theme2.colors.border,
|
|
1905
|
+
children: /* @__PURE__ */ jsx11(
|
|
1906
|
+
Animate_default.View,
|
|
1907
|
+
{
|
|
1908
|
+
width: ballSize,
|
|
1909
|
+
height: ballSize,
|
|
1910
|
+
top: ballGap,
|
|
1911
|
+
borderRadius: 999,
|
|
1912
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
1913
|
+
initialX: ballGap,
|
|
1914
|
+
animateX: enabled ? holderWidth - ballGap - ballSize : ballGap
|
|
1915
|
+
}
|
|
1916
|
+
)
|
|
1917
|
+
}
|
|
1918
|
+
)
|
|
1919
|
+
}
|
|
1920
|
+
);
|
|
1921
|
+
}
|
|
1922
|
+
var Switch_default = memo11(Switch);
|
|
1923
|
+
|
|
1924
|
+
// src/components/StatusBar.tsx
|
|
1925
|
+
import { memo as memo12 } from "react";
|
|
1926
|
+
import { useTheme as useTheme11 } from "react-better-core";
|
|
1927
|
+
import { StatusBar as NativeStatusBar, Platform as Platform7 } from "react-native";
|
|
1928
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1929
|
+
function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarStyle }) {
|
|
1930
|
+
const theme2 = useTheme11();
|
|
1931
|
+
return /* @__PURE__ */ jsx12(
|
|
1842
1932
|
NativeStatusBar,
|
|
1843
1933
|
{
|
|
1844
1934
|
backgroundColor: darkStatusBar ? theme2.colors.backgroundSecondary : void 0,
|
|
1845
|
-
barStyle: barStyle ?? (
|
|
1935
|
+
barStyle: barStyle ?? (Platform7.OS === "android" ? androidBarStyle : iOSBarStyle),
|
|
1846
1936
|
hidden
|
|
1847
1937
|
}
|
|
1848
1938
|
);
|
|
1849
1939
|
}
|
|
1850
|
-
var StatusBar_default =
|
|
1940
|
+
var StatusBar_default = memo12(StatusBar);
|
|
1941
|
+
|
|
1942
|
+
// src/components/ListItem.tsx
|
|
1943
|
+
import { memo as memo13 } from "react";
|
|
1944
|
+
import { useTheme as useTheme12 } from "react-better-core";
|
|
1945
|
+
import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1946
|
+
function ListItem({
|
|
1947
|
+
icon,
|
|
1948
|
+
iconIOS,
|
|
1949
|
+
title,
|
|
1950
|
+
description,
|
|
1951
|
+
rightElement,
|
|
1952
|
+
backgroundColor,
|
|
1953
|
+
insideScreenHolder,
|
|
1954
|
+
onPress,
|
|
1955
|
+
rightArrowValue,
|
|
1956
|
+
switchIsEnabled,
|
|
1957
|
+
switchOnChange
|
|
1958
|
+
}) {
|
|
1959
|
+
const theme2 = useTheme12();
|
|
1960
|
+
const device = useDevice();
|
|
1961
|
+
const sideSpace = theme2.styles.space;
|
|
1962
|
+
return /* @__PURE__ */ jsx13(
|
|
1963
|
+
View_default,
|
|
1964
|
+
{
|
|
1965
|
+
width: insideScreenHolder ? device.windowDimensions.width : "100%",
|
|
1966
|
+
backgroundColor: backgroundColor ?? theme2.colors.backgroundBase,
|
|
1967
|
+
marginHorizontal: insideScreenHolder ? -sideSpace : void 0,
|
|
1968
|
+
paddingVertical: theme2.styles.gap,
|
|
1969
|
+
paddingHorizontal: sideSpace,
|
|
1970
|
+
pressStrength: pressStrength().p05,
|
|
1971
|
+
onPress,
|
|
1972
|
+
children: /* @__PURE__ */ jsxs5(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.space, children: [
|
|
1973
|
+
icon && /* @__PURE__ */ jsx13(Icon_default, { name: icon, nameIOS: iconIOS, size: 22, color: theme2.colors.primary }),
|
|
1974
|
+
/* @__PURE__ */ jsx13(View_default, { flex: 1, flexDirection: "row", alignItems: "center", gap: theme2.styles.gap, children: /* @__PURE__ */ jsxs5(View_default, { flex: 1, children: [
|
|
1975
|
+
title && /* @__PURE__ */ jsx13(Text_default, { fontSize: 20, fontWeight: 700, children: title }),
|
|
1976
|
+
description && /* @__PURE__ */ jsx13(Text_default.body, { children: description })
|
|
1977
|
+
] }) }),
|
|
1978
|
+
rightElement ? /* @__PURE__ */ jsx13(Fragment4, { children: rightElement === "arrow" ? /* @__PURE__ */ jsxs5(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.gap / 2, children: [
|
|
1979
|
+
rightArrowValue !== void 0 && /* @__PURE__ */ jsx13(Text_default, { fontSize: 14, fontWeight: 700, children: rightArrowValue }),
|
|
1980
|
+
/* @__PURE__ */ jsx13(
|
|
1981
|
+
Icon_default,
|
|
1982
|
+
{
|
|
1983
|
+
name: "chevronRight",
|
|
1984
|
+
nameIOS: "chevron.right",
|
|
1985
|
+
color: rightArrowValue !== void 0 ? theme2.colors.textPrimary : theme2.colors.textSecondary
|
|
1986
|
+
}
|
|
1987
|
+
)
|
|
1988
|
+
] }) : rightElement === "switch" ? /* @__PURE__ */ jsx13(Switch_default, { isEnabled: switchIsEnabled, onChange: switchOnChange }) : void 0 }) : void 0
|
|
1989
|
+
] })
|
|
1990
|
+
}
|
|
1991
|
+
);
|
|
1992
|
+
}
|
|
1993
|
+
var ListItem_default = memo13(ListItem);
|
|
1851
1994
|
|
|
1852
1995
|
// src/plugins/asyncStorage.ts
|
|
1853
1996
|
var defaultAsyncStoragePluginOptions = {};
|
|
@@ -1868,9 +2011,11 @@ export {
|
|
|
1868
2011
|
Icon_default as Icon,
|
|
1869
2012
|
Image_default as Image,
|
|
1870
2013
|
InputField_default as InputField,
|
|
2014
|
+
ListItem_default as ListItem,
|
|
1871
2015
|
Loader_default as Loader,
|
|
1872
2016
|
ScreenHolder_default as ScreenHolder,
|
|
1873
2017
|
StatusBar_default as StatusBar,
|
|
2018
|
+
Switch_default as Switch,
|
|
1874
2019
|
Text_default as Text,
|
|
1875
2020
|
View_default as View,
|
|
1876
2021
|
asyncStoragePlugin,
|
|
@@ -1892,7 +2037,7 @@ export {
|
|
|
1892
2037
|
pressStrength,
|
|
1893
2038
|
saturateColor,
|
|
1894
2039
|
useBetterComponentsContext,
|
|
1895
|
-
|
|
2040
|
+
useBooleanState6 as useBooleanState,
|
|
1896
2041
|
useDebounceState,
|
|
1897
2042
|
useDevice,
|
|
1898
2043
|
useEventEmitter,
|
|
@@ -1900,6 +2045,6 @@ export {
|
|
|
1900
2045
|
useKeyboard,
|
|
1901
2046
|
useLoader2 as useLoader,
|
|
1902
2047
|
useLoaderControls,
|
|
1903
|
-
|
|
2048
|
+
useTheme13 as useTheme
|
|
1904
2049
|
};
|
|
1905
2050
|
//# sourceMappingURL=index.mjs.map
|