react-native-better-html 1.0.12 → 1.0.13
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 +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +155 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +161 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -487,6 +487,7 @@ function useForm(options) {
|
|
|
487
487
|
required: requiredFields?.includes(field),
|
|
488
488
|
value: values[field]?.toString() ?? "",
|
|
489
489
|
errorMessage: errors[field],
|
|
490
|
+
isError: !!errors[field],
|
|
490
491
|
returnKeyLabel: isLastInputField ? additional?.lastInputFieldReturnKeyLabel ?? "done" : "next",
|
|
491
492
|
onPressEnter: () => {
|
|
492
493
|
if (isLastInputField) onSubmitFunction();
|
|
@@ -581,6 +582,7 @@ import {
|
|
|
581
582
|
import { useTheme as useTheme2 } from "react-better-core";
|
|
582
583
|
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
583
584
|
var touchableHighlightStyleMoveToContent = [
|
|
585
|
+
"width",
|
|
584
586
|
"backgroundColor",
|
|
585
587
|
"padding",
|
|
586
588
|
"paddingTop",
|
|
@@ -721,6 +723,7 @@ var ViewComponent = function View({
|
|
|
721
723
|
ViewComponent,
|
|
722
724
|
{
|
|
723
725
|
width: "100%",
|
|
726
|
+
height: props.height,
|
|
724
727
|
borderRadius: props.borderRadius,
|
|
725
728
|
borderTopLeftRadius: props.borderTopLeftRadius,
|
|
726
729
|
borderTopRightRadius: props.borderTopRightRadius,
|
|
@@ -1271,8 +1274,12 @@ import {
|
|
|
1271
1274
|
useState as useState2
|
|
1272
1275
|
} from "react";
|
|
1273
1276
|
import {
|
|
1277
|
+
Platform as Platform4,
|
|
1274
1278
|
TextInput as TextInput2
|
|
1275
1279
|
} from "react-native";
|
|
1280
|
+
import RNDateTimePicker, {
|
|
1281
|
+
DateTimePickerAndroid
|
|
1282
|
+
} from "@react-native-community/datetimepicker";
|
|
1276
1283
|
import {
|
|
1277
1284
|
darkenColor,
|
|
1278
1285
|
lightenColor,
|
|
@@ -1280,10 +1287,12 @@ import {
|
|
|
1280
1287
|
useBooleanState as useBooleanState4,
|
|
1281
1288
|
useTheme as useTheme8
|
|
1282
1289
|
} from "react-better-core";
|
|
1283
|
-
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1290
|
+
import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1284
1291
|
var InputFieldComponent = forwardRef(
|
|
1285
1292
|
({
|
|
1286
1293
|
placeholder,
|
|
1294
|
+
type = "text",
|
|
1295
|
+
iOSDateTimeFullSize,
|
|
1287
1296
|
prefix,
|
|
1288
1297
|
suffix,
|
|
1289
1298
|
defaultValue,
|
|
@@ -1309,23 +1318,65 @@ var InputFieldComponent = forwardRef(
|
|
|
1309
1318
|
textAlign,
|
|
1310
1319
|
required,
|
|
1311
1320
|
disabled,
|
|
1321
|
+
maxLength,
|
|
1322
|
+
multiline,
|
|
1323
|
+
numberOfLines = 2,
|
|
1312
1324
|
paddingHorizontal,
|
|
1313
1325
|
paddingVertical,
|
|
1314
1326
|
onFocus,
|
|
1315
1327
|
onBlur,
|
|
1316
1328
|
onChange,
|
|
1317
1329
|
onPress,
|
|
1330
|
+
onPressPrefix,
|
|
1331
|
+
onPressSuffix,
|
|
1318
1332
|
onPressEnter
|
|
1319
1333
|
}, ref) => {
|
|
1320
1334
|
const theme2 = useTheme8();
|
|
1321
1335
|
const { colorTheme } = useBetterCoreContext3();
|
|
1322
1336
|
const textInputRef = useRef2(null);
|
|
1323
1337
|
const [internalValue, setInternalValue] = useState2(value?.toString() || defaultValue || "");
|
|
1338
|
+
const [internalDateValue, setInternalDateValue] = useState2();
|
|
1324
1339
|
const [isFocused, setIsFocused] = useBooleanState4();
|
|
1340
|
+
const isIOSDateTime = Platform4.OS === "ios" && (type === "date" || type === "time");
|
|
1325
1341
|
const borderWidth = 1;
|
|
1326
1342
|
const readyPaddingHorizontal = paddingHorizontal ?? theme2.styles.space;
|
|
1327
1343
|
const readyPaddingVertical = paddingVertical ? parseFloat(paddingVertical.toString()) : (theme2.styles.space + theme2.styles.gap) / 2;
|
|
1328
|
-
const readyHeight = height ?? borderWidth + readyPaddingVertical + lineHeight + readyPaddingVertical + borderWidth;
|
|
1344
|
+
const readyHeight = height ?? isIOSDateTime ? void 0 : borderWidth + readyPaddingVertical + lineHeight + readyPaddingVertical + borderWidth + (Platform4.OS === "android" ? 2 : 0);
|
|
1345
|
+
const onChangeRNDateTimePicker = useCallback3(
|
|
1346
|
+
(event, data) => {
|
|
1347
|
+
setInternalDateValue(data);
|
|
1348
|
+
onChange?.(data?.toISOString() ?? "");
|
|
1349
|
+
},
|
|
1350
|
+
[onChange]
|
|
1351
|
+
);
|
|
1352
|
+
const onPressInputField = useCallback3(
|
|
1353
|
+
(event) => {
|
|
1354
|
+
onPress?.(event);
|
|
1355
|
+
if (type === "date" || type === "time") {
|
|
1356
|
+
if (Platform4.OS === "android") {
|
|
1357
|
+
DateTimePickerAndroid.open({
|
|
1358
|
+
value: internalDateValue ?? /* @__PURE__ */ new Date(),
|
|
1359
|
+
is24Hour: true,
|
|
1360
|
+
mode: type,
|
|
1361
|
+
positiveButton: {
|
|
1362
|
+
label: "Done"
|
|
1363
|
+
},
|
|
1364
|
+
negativeButton: {
|
|
1365
|
+
label: "Clear",
|
|
1366
|
+
textColor: theme2.colors.textSecondary
|
|
1367
|
+
},
|
|
1368
|
+
neutralButton: {
|
|
1369
|
+
label: "Cancel",
|
|
1370
|
+
textColor: theme2.colors.textSecondary
|
|
1371
|
+
},
|
|
1372
|
+
onChange: onChangeRNDateTimePicker
|
|
1373
|
+
});
|
|
1374
|
+
} else if (Platform4.OS === "ios") {
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
},
|
|
1378
|
+
[onPress, type, internalDateValue, onChangeRNDateTimePicker]
|
|
1379
|
+
);
|
|
1329
1380
|
const onFocusElement = useCallback3((event) => {
|
|
1330
1381
|
setIsFocused.setTrue();
|
|
1331
1382
|
onFocus?.(event);
|
|
@@ -1353,10 +1404,27 @@ var InputFieldComponent = forwardRef(
|
|
|
1353
1404
|
}),
|
|
1354
1405
|
[theme2.colors, fontSize, fontWeight, lineHeight, readyPaddingHorizontal, readyPaddingVertical]
|
|
1355
1406
|
);
|
|
1407
|
+
const rnDateTimePickerStyle = useMemo8(
|
|
1408
|
+
() => ({
|
|
1409
|
+
flex: iOSDateTimeFullSize ? 1 : void 0,
|
|
1410
|
+
marginLeft: -8 + (iOSDateTimeFullSize ? 0 : theme2.styles.space)
|
|
1411
|
+
}),
|
|
1412
|
+
[iOSDateTimeFullSize]
|
|
1413
|
+
);
|
|
1356
1414
|
useEffect4(() => {
|
|
1357
1415
|
if (value === void 0) return;
|
|
1358
1416
|
setInternalValue(value.toString());
|
|
1417
|
+
setInternalDateValue(new Date(value));
|
|
1359
1418
|
}, [value]);
|
|
1419
|
+
useEffect4(() => {
|
|
1420
|
+
if (type !== "date" && type !== "time") return;
|
|
1421
|
+
const date = internalDateValue?.toISOString().split("T")[0] ?? "";
|
|
1422
|
+
const hours = internalDateValue ? internalDateValue.getHours().toString() : "00";
|
|
1423
|
+
const minutes = internalDateValue ? internalDateValue.getMinutes().toString() : "00";
|
|
1424
|
+
setInternalValue(
|
|
1425
|
+
type === "date" ? date : internalDateValue ? `${hours.length === 1 ? `0${hours}` : hours}:${minutes.length === 1 ? `0${minutes}` : minutes}` : ""
|
|
1426
|
+
);
|
|
1427
|
+
}, [internalDateValue]);
|
|
1360
1428
|
useImperativeHandle(
|
|
1361
1429
|
ref,
|
|
1362
1430
|
() => {
|
|
@@ -1364,7 +1432,12 @@ var InputFieldComponent = forwardRef(
|
|
|
1364
1432
|
},
|
|
1365
1433
|
[]
|
|
1366
1434
|
);
|
|
1435
|
+
const withPressInputField = !!onPress || type === "date" || type === "time";
|
|
1367
1436
|
const prefixSuffixBackgroundColor = colorTheme === "light" ? darkenColor(theme2.colors.backgroundContent, 0.03) : lightenColor(theme2.colors.backgroundContent, 0.1);
|
|
1437
|
+
const labelComponent = label && /* @__PURE__ */ jsxs4(View_default, { isRow: true, alignItems: "center", gap: 2, children: [
|
|
1438
|
+
/* @__PURE__ */ jsx9(Text_default, { fontSize: 14, color: isError ? theme2.colors.error : theme2.colors.textSecondary, children: label }),
|
|
1439
|
+
required && /* @__PURE__ */ jsx9(Text_default, { color: theme2.colors.error, children: "*" })
|
|
1440
|
+
] });
|
|
1368
1441
|
return /* @__PURE__ */ jsxs4(
|
|
1369
1442
|
Animate_default.View,
|
|
1370
1443
|
{
|
|
@@ -1373,10 +1446,7 @@ var InputFieldComponent = forwardRef(
|
|
|
1373
1446
|
initialOpacity: 1,
|
|
1374
1447
|
animateOpacity: disabled ? 0.6 : 1,
|
|
1375
1448
|
children: [
|
|
1376
|
-
|
|
1377
|
-
/* @__PURE__ */ jsx9(Text_default, { fontSize: 14, color: theme2.colors.textSecondary, children: label }),
|
|
1378
|
-
required && /* @__PURE__ */ jsx9(Text_default, { color: theme2.colors.error, children: "*" })
|
|
1379
|
-
] }),
|
|
1449
|
+
isIOSDateTime && !iOSDateTimeFullSize ? void 0 : labelComponent,
|
|
1380
1450
|
/* @__PURE__ */ jsxs4(View_default, { isRow: true, position: "relative", alignItems: "center", flex: 1, height: readyHeight, children: [
|
|
1381
1451
|
prefix && /* @__PURE__ */ jsx9(
|
|
1382
1452
|
View_default,
|
|
@@ -1385,56 +1455,95 @@ var InputFieldComponent = forwardRef(
|
|
|
1385
1455
|
height: "100%",
|
|
1386
1456
|
backgroundColor: prefixSuffixBackgroundColor,
|
|
1387
1457
|
alignItems: "center",
|
|
1458
|
+
justifyContent: "center",
|
|
1388
1459
|
borderWidth,
|
|
1389
1460
|
borderRightWidth: 0,
|
|
1390
1461
|
borderTopLeftRadius: theme2.styles.borderRadius,
|
|
1391
1462
|
borderBottomLeftRadius: theme2.styles.borderRadius,
|
|
1392
1463
|
borderColor: theme2.colors.border,
|
|
1393
1464
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1394
|
-
|
|
1465
|
+
onPress: onPressPrefix,
|
|
1466
|
+
children: typeof prefix === "string" ? /* @__PURE__ */ jsx9(
|
|
1467
|
+
Text_default,
|
|
1468
|
+
{
|
|
1469
|
+
fontWeight: 700,
|
|
1470
|
+
lineHeight,
|
|
1471
|
+
marginTop: Platform4.OS === "ios" ? readyPaddingVertical : void 0,
|
|
1472
|
+
children: prefix
|
|
1473
|
+
}
|
|
1474
|
+
) : prefix
|
|
1395
1475
|
}
|
|
1396
1476
|
),
|
|
1397
|
-
/* @__PURE__ */
|
|
1398
|
-
|
|
1477
|
+
isIOSDateTime ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
1478
|
+
!iOSDateTimeFullSize ? labelComponent : void 0,
|
|
1479
|
+
/* @__PURE__ */ jsx9(
|
|
1480
|
+
RNDateTimePicker,
|
|
1481
|
+
{
|
|
1482
|
+
value: internalDateValue ?? /* @__PURE__ */ new Date(),
|
|
1483
|
+
mode: type,
|
|
1484
|
+
display: iOSDateTimeFullSize ? type === "date" ? "inline" : "spinner" : "default",
|
|
1485
|
+
accentColor: theme2.colors.primary,
|
|
1486
|
+
style: rnDateTimePickerStyle,
|
|
1487
|
+
onChange: onChangeRNDateTimePicker
|
|
1488
|
+
}
|
|
1489
|
+
)
|
|
1490
|
+
] }) : /* @__PURE__ */ jsx9(
|
|
1491
|
+
View_default,
|
|
1399
1492
|
{
|
|
1400
1493
|
flex: 1,
|
|
1401
|
-
|
|
1494
|
+
width: "100%",
|
|
1402
1495
|
borderTopLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1403
1496
|
borderBottomLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1404
1497
|
borderTopRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1405
1498
|
borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
animateBorderColor: isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border,
|
|
1409
|
-
overflow: "hidden",
|
|
1499
|
+
pressStrength: 1,
|
|
1500
|
+
onPress: Platform4.OS === "android" ? editable === false || withPressInputField ? onPressInputField : void 0 : void 0,
|
|
1410
1501
|
children: /* @__PURE__ */ jsx9(
|
|
1411
|
-
|
|
1502
|
+
Animate_default.View,
|
|
1412
1503
|
{
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1504
|
+
flex: 1,
|
|
1505
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
1506
|
+
borderTopLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1507
|
+
borderBottomLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1508
|
+
borderTopRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1509
|
+
borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1510
|
+
borderWidth,
|
|
1511
|
+
initialBorderColor: theme2.colors.border,
|
|
1512
|
+
animateBorderColor: isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border,
|
|
1513
|
+
overflow: "hidden",
|
|
1514
|
+
children: /* @__PURE__ */ jsx9(
|
|
1515
|
+
TextInput2,
|
|
1516
|
+
{
|
|
1517
|
+
style: textInputStyle,
|
|
1518
|
+
value: internalValue,
|
|
1519
|
+
defaultValue,
|
|
1520
|
+
autoCapitalize,
|
|
1521
|
+
autoComplete,
|
|
1522
|
+
autoCorrect,
|
|
1523
|
+
autoFocus,
|
|
1524
|
+
placeholder: placeholder ?? label,
|
|
1525
|
+
placeholderTextColor: theme2.colors.textSecondary + "80",
|
|
1526
|
+
enterKeyHint: returnKeyLabel,
|
|
1527
|
+
returnKeyType,
|
|
1528
|
+
onSubmitEditing: onPressEnter,
|
|
1529
|
+
readOnly: !editable || disabled || type === "date" || type === "time",
|
|
1530
|
+
textAlign,
|
|
1531
|
+
editable: !disabled,
|
|
1532
|
+
keyboardAppearance,
|
|
1533
|
+
keyboardType,
|
|
1534
|
+
cursorColor: theme2.colors.primary,
|
|
1535
|
+
selectionColor: theme2.colors.primary,
|
|
1536
|
+
secureTextEntry,
|
|
1537
|
+
onFocus: onFocusElement,
|
|
1538
|
+
onBlur: onBlurElement,
|
|
1539
|
+
onChangeText,
|
|
1540
|
+
maxLength,
|
|
1541
|
+
multiline,
|
|
1542
|
+
numberOfLines,
|
|
1543
|
+
onPress: withPressInputField ? onPressInputField : void 0,
|
|
1544
|
+
ref: textInputRef
|
|
1545
|
+
}
|
|
1546
|
+
)
|
|
1438
1547
|
}
|
|
1439
1548
|
)
|
|
1440
1549
|
}
|
|
@@ -1452,7 +1561,16 @@ var InputFieldComponent = forwardRef(
|
|
|
1452
1561
|
borderBottomRightRadius: theme2.styles.borderRadius,
|
|
1453
1562
|
borderColor: theme2.colors.border,
|
|
1454
1563
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1455
|
-
|
|
1564
|
+
onPress: onPressSuffix,
|
|
1565
|
+
children: typeof suffix === "string" ? /* @__PURE__ */ jsx9(
|
|
1566
|
+
Text_default,
|
|
1567
|
+
{
|
|
1568
|
+
fontWeight: 700,
|
|
1569
|
+
lineHeight,
|
|
1570
|
+
marginTop: Platform4.OS === "ios" ? readyPaddingVertical : void 0,
|
|
1571
|
+
children: suffix
|
|
1572
|
+
}
|
|
1573
|
+
) : suffix
|
|
1456
1574
|
}
|
|
1457
1575
|
)
|
|
1458
1576
|
] }),
|
|
@@ -1538,7 +1656,7 @@ var InputField_default = InputField;
|
|
|
1538
1656
|
// src/components/StatusBar.tsx
|
|
1539
1657
|
import { memo as memo10 } from "react";
|
|
1540
1658
|
import { useTheme as useTheme9 } from "react-better-core";
|
|
1541
|
-
import { StatusBar as NativeStatusBar, Platform as
|
|
1659
|
+
import { StatusBar as NativeStatusBar, Platform as Platform5 } from "react-native";
|
|
1542
1660
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1543
1661
|
function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarStyle }) {
|
|
1544
1662
|
const theme2 = useTheme9();
|
|
@@ -1546,7 +1664,7 @@ function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarSty
|
|
|
1546
1664
|
NativeStatusBar,
|
|
1547
1665
|
{
|
|
1548
1666
|
backgroundColor: darkStatusBar ? theme2.colors.backgroundSecondary : void 0,
|
|
1549
|
-
barStyle: barStyle ?? (
|
|
1667
|
+
barStyle: barStyle ?? (Platform5.OS === "android" ? androidBarStyle : iOSBarStyle),
|
|
1550
1668
|
hidden
|
|
1551
1669
|
}
|
|
1552
1670
|
);
|