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.d.mts
CHANGED
|
@@ -48,6 +48,10 @@ declare const pressStrength: () => Record<"z05" | "z1" | "z2" | "z3", number>;
|
|
|
48
48
|
|
|
49
49
|
type InputFieldProps = {
|
|
50
50
|
placeholder?: string;
|
|
51
|
+
/** @default "text" */
|
|
52
|
+
type?: "text" | "date" | "time";
|
|
53
|
+
/** @default false */
|
|
54
|
+
iOSDateTimeFullSize?: boolean;
|
|
51
55
|
prefix?: string | React.ReactNode;
|
|
52
56
|
suffix?: string | React.ReactNode;
|
|
53
57
|
defaultValue?: string;
|
|
@@ -82,10 +86,17 @@ type InputFieldProps = {
|
|
|
82
86
|
required?: boolean;
|
|
83
87
|
/** @default false */
|
|
84
88
|
disabled?: boolean;
|
|
89
|
+
maxLength?: number;
|
|
90
|
+
/** @default false */
|
|
91
|
+
multiline?: boolean;
|
|
92
|
+
/** @default 2 */
|
|
93
|
+
numberOfLines?: number;
|
|
85
94
|
onFocus?: (event: FocusEvent) => void;
|
|
86
95
|
onBlur?: (event: FocusEvent) => void;
|
|
87
96
|
onChange?: (text: string) => void;
|
|
88
97
|
onPress?: (event: NativeSyntheticEvent<NativeTouchEvent>) => void;
|
|
98
|
+
onPressPrefix?: (event: NativeSyntheticEvent<NativeTouchEvent>) => void;
|
|
99
|
+
onPressSuffix?: (event: NativeSyntheticEvent<NativeTouchEvent>) => void;
|
|
89
100
|
onPressEnter?: (event: TextInputSubmitEditingEvent) => void;
|
|
90
101
|
} & Pick<ComponentPaddingProps, "paddingHorizontal" | "paddingVertical">;
|
|
91
102
|
type InputFieldRef = TextInput;
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,10 @@ declare const pressStrength: () => Record<"z05" | "z1" | "z2" | "z3", number>;
|
|
|
48
48
|
|
|
49
49
|
type InputFieldProps = {
|
|
50
50
|
placeholder?: string;
|
|
51
|
+
/** @default "text" */
|
|
52
|
+
type?: "text" | "date" | "time";
|
|
53
|
+
/** @default false */
|
|
54
|
+
iOSDateTimeFullSize?: boolean;
|
|
51
55
|
prefix?: string | React.ReactNode;
|
|
52
56
|
suffix?: string | React.ReactNode;
|
|
53
57
|
defaultValue?: string;
|
|
@@ -82,10 +86,17 @@ type InputFieldProps = {
|
|
|
82
86
|
required?: boolean;
|
|
83
87
|
/** @default false */
|
|
84
88
|
disabled?: boolean;
|
|
89
|
+
maxLength?: number;
|
|
90
|
+
/** @default false */
|
|
91
|
+
multiline?: boolean;
|
|
92
|
+
/** @default 2 */
|
|
93
|
+
numberOfLines?: number;
|
|
85
94
|
onFocus?: (event: FocusEvent) => void;
|
|
86
95
|
onBlur?: (event: FocusEvent) => void;
|
|
87
96
|
onChange?: (text: string) => void;
|
|
88
97
|
onPress?: (event: NativeSyntheticEvent<NativeTouchEvent>) => void;
|
|
98
|
+
onPressPrefix?: (event: NativeSyntheticEvent<NativeTouchEvent>) => void;
|
|
99
|
+
onPressSuffix?: (event: NativeSyntheticEvent<NativeTouchEvent>) => void;
|
|
89
100
|
onPressEnter?: (event: TextInputSubmitEditingEvent) => void;
|
|
90
101
|
} & Pick<ComponentPaddingProps, "paddingHorizontal" | "paddingVertical">;
|
|
91
102
|
type InputFieldRef = TextInput;
|
package/dist/index.js
CHANGED
|
@@ -534,6 +534,7 @@ function useForm(options) {
|
|
|
534
534
|
required: requiredFields?.includes(field),
|
|
535
535
|
value: values[field]?.toString() ?? "",
|
|
536
536
|
errorMessage: errors[field],
|
|
537
|
+
isError: !!errors[field],
|
|
537
538
|
returnKeyLabel: isLastInputField ? additional?.lastInputFieldReturnKeyLabel ?? "done" : "next",
|
|
538
539
|
onPressEnter: () => {
|
|
539
540
|
if (isLastInputField) onSubmitFunction();
|
|
@@ -622,6 +623,7 @@ var import_react_native2 = require("react-native");
|
|
|
622
623
|
var import_react_better_core3 = require("react-better-core");
|
|
623
624
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
624
625
|
var touchableHighlightStyleMoveToContent = [
|
|
626
|
+
"width",
|
|
625
627
|
"backgroundColor",
|
|
626
628
|
"padding",
|
|
627
629
|
"paddingTop",
|
|
@@ -762,6 +764,7 @@ var ViewComponent = function View({
|
|
|
762
764
|
ViewComponent,
|
|
763
765
|
{
|
|
764
766
|
width: "100%",
|
|
767
|
+
height: props.height,
|
|
765
768
|
borderRadius: props.borderRadius,
|
|
766
769
|
borderTopLeftRadius: props.borderTopLeftRadius,
|
|
767
770
|
borderTopRightRadius: props.borderTopRightRadius,
|
|
@@ -1301,11 +1304,14 @@ var Image_default = Image2;
|
|
|
1301
1304
|
// src/components/InputField.tsx
|
|
1302
1305
|
var import_react10 = require("react");
|
|
1303
1306
|
var import_react_native8 = require("react-native");
|
|
1307
|
+
var import_datetimepicker = __toESM(require("@react-native-community/datetimepicker"));
|
|
1304
1308
|
var import_react_better_core9 = require("react-better-core");
|
|
1305
1309
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1306
1310
|
var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
1307
1311
|
({
|
|
1308
1312
|
placeholder,
|
|
1313
|
+
type = "text",
|
|
1314
|
+
iOSDateTimeFullSize,
|
|
1309
1315
|
prefix,
|
|
1310
1316
|
suffix,
|
|
1311
1317
|
defaultValue,
|
|
@@ -1331,23 +1337,65 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
|
1331
1337
|
textAlign,
|
|
1332
1338
|
required,
|
|
1333
1339
|
disabled,
|
|
1340
|
+
maxLength,
|
|
1341
|
+
multiline,
|
|
1342
|
+
numberOfLines = 2,
|
|
1334
1343
|
paddingHorizontal,
|
|
1335
1344
|
paddingVertical,
|
|
1336
1345
|
onFocus,
|
|
1337
1346
|
onBlur,
|
|
1338
1347
|
onChange,
|
|
1339
1348
|
onPress,
|
|
1349
|
+
onPressPrefix,
|
|
1350
|
+
onPressSuffix,
|
|
1340
1351
|
onPressEnter
|
|
1341
1352
|
}, ref) => {
|
|
1342
1353
|
const theme2 = (0, import_react_better_core9.useTheme)();
|
|
1343
1354
|
const { colorTheme } = (0, import_react_better_core9.useBetterCoreContext)();
|
|
1344
1355
|
const textInputRef = (0, import_react10.useRef)(null);
|
|
1345
1356
|
const [internalValue, setInternalValue] = (0, import_react10.useState)(value?.toString() || defaultValue || "");
|
|
1357
|
+
const [internalDateValue, setInternalDateValue] = (0, import_react10.useState)();
|
|
1346
1358
|
const [isFocused, setIsFocused] = (0, import_react_better_core9.useBooleanState)();
|
|
1359
|
+
const isIOSDateTime = import_react_native8.Platform.OS === "ios" && (type === "date" || type === "time");
|
|
1347
1360
|
const borderWidth = 1;
|
|
1348
1361
|
const readyPaddingHorizontal = paddingHorizontal ?? theme2.styles.space;
|
|
1349
1362
|
const readyPaddingVertical = paddingVertical ? parseFloat(paddingVertical.toString()) : (theme2.styles.space + theme2.styles.gap) / 2;
|
|
1350
|
-
const readyHeight = height ?? borderWidth + readyPaddingVertical + lineHeight + readyPaddingVertical + borderWidth;
|
|
1363
|
+
const readyHeight = height ?? isIOSDateTime ? void 0 : borderWidth + readyPaddingVertical + lineHeight + readyPaddingVertical + borderWidth + (import_react_native8.Platform.OS === "android" ? 2 : 0);
|
|
1364
|
+
const onChangeRNDateTimePicker = (0, import_react10.useCallback)(
|
|
1365
|
+
(event, data) => {
|
|
1366
|
+
setInternalDateValue(data);
|
|
1367
|
+
onChange?.(data?.toISOString() ?? "");
|
|
1368
|
+
},
|
|
1369
|
+
[onChange]
|
|
1370
|
+
);
|
|
1371
|
+
const onPressInputField = (0, import_react10.useCallback)(
|
|
1372
|
+
(event) => {
|
|
1373
|
+
onPress?.(event);
|
|
1374
|
+
if (type === "date" || type === "time") {
|
|
1375
|
+
if (import_react_native8.Platform.OS === "android") {
|
|
1376
|
+
import_datetimepicker.DateTimePickerAndroid.open({
|
|
1377
|
+
value: internalDateValue ?? /* @__PURE__ */ new Date(),
|
|
1378
|
+
is24Hour: true,
|
|
1379
|
+
mode: type,
|
|
1380
|
+
positiveButton: {
|
|
1381
|
+
label: "Done"
|
|
1382
|
+
},
|
|
1383
|
+
negativeButton: {
|
|
1384
|
+
label: "Clear",
|
|
1385
|
+
textColor: theme2.colors.textSecondary
|
|
1386
|
+
},
|
|
1387
|
+
neutralButton: {
|
|
1388
|
+
label: "Cancel",
|
|
1389
|
+
textColor: theme2.colors.textSecondary
|
|
1390
|
+
},
|
|
1391
|
+
onChange: onChangeRNDateTimePicker
|
|
1392
|
+
});
|
|
1393
|
+
} else if (import_react_native8.Platform.OS === "ios") {
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
},
|
|
1397
|
+
[onPress, type, internalDateValue, onChangeRNDateTimePicker]
|
|
1398
|
+
);
|
|
1351
1399
|
const onFocusElement = (0, import_react10.useCallback)((event) => {
|
|
1352
1400
|
setIsFocused.setTrue();
|
|
1353
1401
|
onFocus?.(event);
|
|
@@ -1375,10 +1423,27 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
|
1375
1423
|
}),
|
|
1376
1424
|
[theme2.colors, fontSize, fontWeight, lineHeight, readyPaddingHorizontal, readyPaddingVertical]
|
|
1377
1425
|
);
|
|
1426
|
+
const rnDateTimePickerStyle = (0, import_react10.useMemo)(
|
|
1427
|
+
() => ({
|
|
1428
|
+
flex: iOSDateTimeFullSize ? 1 : void 0,
|
|
1429
|
+
marginLeft: -8 + (iOSDateTimeFullSize ? 0 : theme2.styles.space)
|
|
1430
|
+
}),
|
|
1431
|
+
[iOSDateTimeFullSize]
|
|
1432
|
+
);
|
|
1378
1433
|
(0, import_react10.useEffect)(() => {
|
|
1379
1434
|
if (value === void 0) return;
|
|
1380
1435
|
setInternalValue(value.toString());
|
|
1436
|
+
setInternalDateValue(new Date(value));
|
|
1381
1437
|
}, [value]);
|
|
1438
|
+
(0, import_react10.useEffect)(() => {
|
|
1439
|
+
if (type !== "date" && type !== "time") return;
|
|
1440
|
+
const date = internalDateValue?.toISOString().split("T")[0] ?? "";
|
|
1441
|
+
const hours = internalDateValue ? internalDateValue.getHours().toString() : "00";
|
|
1442
|
+
const minutes = internalDateValue ? internalDateValue.getMinutes().toString() : "00";
|
|
1443
|
+
setInternalValue(
|
|
1444
|
+
type === "date" ? date : internalDateValue ? `${hours.length === 1 ? `0${hours}` : hours}:${minutes.length === 1 ? `0${minutes}` : minutes}` : ""
|
|
1445
|
+
);
|
|
1446
|
+
}, [internalDateValue]);
|
|
1382
1447
|
(0, import_react10.useImperativeHandle)(
|
|
1383
1448
|
ref,
|
|
1384
1449
|
() => {
|
|
@@ -1386,7 +1451,12 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
|
1386
1451
|
},
|
|
1387
1452
|
[]
|
|
1388
1453
|
);
|
|
1454
|
+
const withPressInputField = !!onPress || type === "date" || type === "time";
|
|
1389
1455
|
const prefixSuffixBackgroundColor = colorTheme === "light" ? (0, import_react_better_core9.darkenColor)(theme2.colors.backgroundContent, 0.03) : (0, import_react_better_core9.lightenColor)(theme2.colors.backgroundContent, 0.1);
|
|
1456
|
+
const labelComponent = label && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(View_default, { isRow: true, alignItems: "center", gap: 2, children: [
|
|
1457
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text_default, { fontSize: 14, color: isError ? theme2.colors.error : theme2.colors.textSecondary, children: label }),
|
|
1458
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text_default, { color: theme2.colors.error, children: "*" })
|
|
1459
|
+
] });
|
|
1390
1460
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1391
1461
|
Animate_default.View,
|
|
1392
1462
|
{
|
|
@@ -1395,10 +1465,7 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
|
1395
1465
|
initialOpacity: 1,
|
|
1396
1466
|
animateOpacity: disabled ? 0.6 : 1,
|
|
1397
1467
|
children: [
|
|
1398
|
-
|
|
1399
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text_default, { fontSize: 14, color: theme2.colors.textSecondary, children: label }),
|
|
1400
|
-
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text_default, { color: theme2.colors.error, children: "*" })
|
|
1401
|
-
] }),
|
|
1468
|
+
isIOSDateTime && !iOSDateTimeFullSize ? void 0 : labelComponent,
|
|
1402
1469
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(View_default, { isRow: true, position: "relative", alignItems: "center", flex: 1, height: readyHeight, children: [
|
|
1403
1470
|
prefix && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1404
1471
|
View_default,
|
|
@@ -1407,56 +1474,95 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
|
1407
1474
|
height: "100%",
|
|
1408
1475
|
backgroundColor: prefixSuffixBackgroundColor,
|
|
1409
1476
|
alignItems: "center",
|
|
1477
|
+
justifyContent: "center",
|
|
1410
1478
|
borderWidth,
|
|
1411
1479
|
borderRightWidth: 0,
|
|
1412
1480
|
borderTopLeftRadius: theme2.styles.borderRadius,
|
|
1413
1481
|
borderBottomLeftRadius: theme2.styles.borderRadius,
|
|
1414
1482
|
borderColor: theme2.colors.border,
|
|
1415
1483
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1416
|
-
|
|
1484
|
+
onPress: onPressPrefix,
|
|
1485
|
+
children: typeof prefix === "string" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1486
|
+
Text_default,
|
|
1487
|
+
{
|
|
1488
|
+
fontWeight: 700,
|
|
1489
|
+
lineHeight,
|
|
1490
|
+
marginTop: import_react_native8.Platform.OS === "ios" ? readyPaddingVertical : void 0,
|
|
1491
|
+
children: prefix
|
|
1492
|
+
}
|
|
1493
|
+
) : prefix
|
|
1417
1494
|
}
|
|
1418
1495
|
),
|
|
1419
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.
|
|
1420
|
-
|
|
1496
|
+
isIOSDateTime ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1497
|
+
!iOSDateTimeFullSize ? labelComponent : void 0,
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1499
|
+
import_datetimepicker.default,
|
|
1500
|
+
{
|
|
1501
|
+
value: internalDateValue ?? /* @__PURE__ */ new Date(),
|
|
1502
|
+
mode: type,
|
|
1503
|
+
display: iOSDateTimeFullSize ? type === "date" ? "inline" : "spinner" : "default",
|
|
1504
|
+
accentColor: theme2.colors.primary,
|
|
1505
|
+
style: rnDateTimePickerStyle,
|
|
1506
|
+
onChange: onChangeRNDateTimePicker
|
|
1507
|
+
}
|
|
1508
|
+
)
|
|
1509
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1510
|
+
View_default,
|
|
1421
1511
|
{
|
|
1422
1512
|
flex: 1,
|
|
1423
|
-
|
|
1513
|
+
width: "100%",
|
|
1424
1514
|
borderTopLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1425
1515
|
borderBottomLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1426
1516
|
borderTopRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1427
1517
|
borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
animateBorderColor: isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border,
|
|
1431
|
-
overflow: "hidden",
|
|
1518
|
+
pressStrength: 1,
|
|
1519
|
+
onPress: import_react_native8.Platform.OS === "android" ? editable === false || withPressInputField ? onPressInputField : void 0 : void 0,
|
|
1432
1520
|
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1433
|
-
|
|
1521
|
+
Animate_default.View,
|
|
1434
1522
|
{
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1523
|
+
flex: 1,
|
|
1524
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
1525
|
+
borderTopLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1526
|
+
borderBottomLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1527
|
+
borderTopRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1528
|
+
borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1529
|
+
borderWidth,
|
|
1530
|
+
initialBorderColor: theme2.colors.border,
|
|
1531
|
+
animateBorderColor: isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border,
|
|
1532
|
+
overflow: "hidden",
|
|
1533
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1534
|
+
import_react_native8.TextInput,
|
|
1535
|
+
{
|
|
1536
|
+
style: textInputStyle,
|
|
1537
|
+
value: internalValue,
|
|
1538
|
+
defaultValue,
|
|
1539
|
+
autoCapitalize,
|
|
1540
|
+
autoComplete,
|
|
1541
|
+
autoCorrect,
|
|
1542
|
+
autoFocus,
|
|
1543
|
+
placeholder: placeholder ?? label,
|
|
1544
|
+
placeholderTextColor: theme2.colors.textSecondary + "80",
|
|
1545
|
+
enterKeyHint: returnKeyLabel,
|
|
1546
|
+
returnKeyType,
|
|
1547
|
+
onSubmitEditing: onPressEnter,
|
|
1548
|
+
readOnly: !editable || disabled || type === "date" || type === "time",
|
|
1549
|
+
textAlign,
|
|
1550
|
+
editable: !disabled,
|
|
1551
|
+
keyboardAppearance,
|
|
1552
|
+
keyboardType,
|
|
1553
|
+
cursorColor: theme2.colors.primary,
|
|
1554
|
+
selectionColor: theme2.colors.primary,
|
|
1555
|
+
secureTextEntry,
|
|
1556
|
+
onFocus: onFocusElement,
|
|
1557
|
+
onBlur: onBlurElement,
|
|
1558
|
+
onChangeText,
|
|
1559
|
+
maxLength,
|
|
1560
|
+
multiline,
|
|
1561
|
+
numberOfLines,
|
|
1562
|
+
onPress: withPressInputField ? onPressInputField : void 0,
|
|
1563
|
+
ref: textInputRef
|
|
1564
|
+
}
|
|
1565
|
+
)
|
|
1460
1566
|
}
|
|
1461
1567
|
)
|
|
1462
1568
|
}
|
|
@@ -1474,7 +1580,16 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
|
1474
1580
|
borderBottomRightRadius: theme2.styles.borderRadius,
|
|
1475
1581
|
borderColor: theme2.colors.border,
|
|
1476
1582
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1477
|
-
|
|
1583
|
+
onPress: onPressSuffix,
|
|
1584
|
+
children: typeof suffix === "string" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1585
|
+
Text_default,
|
|
1586
|
+
{
|
|
1587
|
+
fontWeight: 700,
|
|
1588
|
+
lineHeight,
|
|
1589
|
+
marginTop: import_react_native8.Platform.OS === "ios" ? readyPaddingVertical : void 0,
|
|
1590
|
+
children: suffix
|
|
1591
|
+
}
|
|
1592
|
+
) : suffix
|
|
1478
1593
|
}
|
|
1479
1594
|
)
|
|
1480
1595
|
] }),
|