react-native-better-html 1.0.12 → 1.0.14
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 +158 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +164 -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,30 @@ 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
|
+
try {
|
|
1437
|
+
setInternalDateValue(value ? new Date(value) : void 0);
|
|
1438
|
+
} catch (error) {
|
|
1439
|
+
}
|
|
1381
1440
|
}, [value]);
|
|
1441
|
+
(0, import_react10.useEffect)(() => {
|
|
1442
|
+
if (type !== "date" && type !== "time") return;
|
|
1443
|
+
const date = internalDateValue?.toISOString().split("T")[0] ?? "";
|
|
1444
|
+
const hours = internalDateValue ? internalDateValue.getHours().toString() : "00";
|
|
1445
|
+
const minutes = internalDateValue ? internalDateValue.getMinutes().toString() : "00";
|
|
1446
|
+
setInternalValue(
|
|
1447
|
+
type === "date" ? date : internalDateValue ? `${hours.length === 1 ? `0${hours}` : hours}:${minutes.length === 1 ? `0${minutes}` : minutes}` : ""
|
|
1448
|
+
);
|
|
1449
|
+
}, [internalDateValue]);
|
|
1382
1450
|
(0, import_react10.useImperativeHandle)(
|
|
1383
1451
|
ref,
|
|
1384
1452
|
() => {
|
|
@@ -1386,7 +1454,12 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
|
1386
1454
|
},
|
|
1387
1455
|
[]
|
|
1388
1456
|
);
|
|
1457
|
+
const withPressInputField = !!onPress || type === "date" || type === "time";
|
|
1389
1458
|
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);
|
|
1459
|
+
const labelComponent = label && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(View_default, { isRow: true, alignItems: "center", gap: 2, children: [
|
|
1460
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text_default, { fontSize: 14, color: isError ? theme2.colors.error : theme2.colors.textSecondary, children: label }),
|
|
1461
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text_default, { color: theme2.colors.error, children: "*" })
|
|
1462
|
+
] });
|
|
1390
1463
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1391
1464
|
Animate_default.View,
|
|
1392
1465
|
{
|
|
@@ -1395,10 +1468,7 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
|
1395
1468
|
initialOpacity: 1,
|
|
1396
1469
|
animateOpacity: disabled ? 0.6 : 1,
|
|
1397
1470
|
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
|
-
] }),
|
|
1471
|
+
isIOSDateTime && !iOSDateTimeFullSize ? void 0 : labelComponent,
|
|
1402
1472
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(View_default, { isRow: true, position: "relative", alignItems: "center", flex: 1, height: readyHeight, children: [
|
|
1403
1473
|
prefix && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1404
1474
|
View_default,
|
|
@@ -1407,56 +1477,95 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
|
1407
1477
|
height: "100%",
|
|
1408
1478
|
backgroundColor: prefixSuffixBackgroundColor,
|
|
1409
1479
|
alignItems: "center",
|
|
1480
|
+
justifyContent: "center",
|
|
1410
1481
|
borderWidth,
|
|
1411
1482
|
borderRightWidth: 0,
|
|
1412
1483
|
borderTopLeftRadius: theme2.styles.borderRadius,
|
|
1413
1484
|
borderBottomLeftRadius: theme2.styles.borderRadius,
|
|
1414
1485
|
borderColor: theme2.colors.border,
|
|
1415
1486
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1416
|
-
|
|
1487
|
+
onPress: onPressPrefix,
|
|
1488
|
+
children: typeof prefix === "string" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1489
|
+
Text_default,
|
|
1490
|
+
{
|
|
1491
|
+
fontWeight: 700,
|
|
1492
|
+
lineHeight,
|
|
1493
|
+
marginTop: import_react_native8.Platform.OS === "ios" && onPressPrefix ? readyPaddingVertical : void 0,
|
|
1494
|
+
children: prefix
|
|
1495
|
+
}
|
|
1496
|
+
) : prefix
|
|
1417
1497
|
}
|
|
1418
1498
|
),
|
|
1419
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.
|
|
1420
|
-
|
|
1499
|
+
isIOSDateTime ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1500
|
+
!iOSDateTimeFullSize ? labelComponent : void 0,
|
|
1501
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1502
|
+
import_datetimepicker.default,
|
|
1503
|
+
{
|
|
1504
|
+
value: internalDateValue ?? /* @__PURE__ */ new Date(),
|
|
1505
|
+
mode: type,
|
|
1506
|
+
display: iOSDateTimeFullSize ? type === "date" ? "inline" : "spinner" : "default",
|
|
1507
|
+
accentColor: theme2.colors.primary,
|
|
1508
|
+
style: rnDateTimePickerStyle,
|
|
1509
|
+
onChange: onChangeRNDateTimePicker
|
|
1510
|
+
}
|
|
1511
|
+
)
|
|
1512
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1513
|
+
View_default,
|
|
1421
1514
|
{
|
|
1422
1515
|
flex: 1,
|
|
1423
|
-
|
|
1516
|
+
width: "100%",
|
|
1424
1517
|
borderTopLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1425
1518
|
borderBottomLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1426
1519
|
borderTopRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1427
1520
|
borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
animateBorderColor: isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border,
|
|
1431
|
-
overflow: "hidden",
|
|
1521
|
+
pressStrength: 1,
|
|
1522
|
+
onPress: import_react_native8.Platform.OS === "android" ? editable === false || withPressInputField ? onPressInputField : void 0 : void 0,
|
|
1432
1523
|
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1433
|
-
|
|
1524
|
+
Animate_default.View,
|
|
1434
1525
|
{
|
|
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
|
-
|
|
1526
|
+
flex: 1,
|
|
1527
|
+
backgroundColor: theme2.colors.backgroundContent,
|
|
1528
|
+
borderTopLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1529
|
+
borderBottomLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
|
|
1530
|
+
borderTopRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1531
|
+
borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
|
|
1532
|
+
borderWidth,
|
|
1533
|
+
initialBorderColor: theme2.colors.border,
|
|
1534
|
+
animateBorderColor: isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border,
|
|
1535
|
+
overflow: "hidden",
|
|
1536
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1537
|
+
import_react_native8.TextInput,
|
|
1538
|
+
{
|
|
1539
|
+
style: textInputStyle,
|
|
1540
|
+
value: internalValue,
|
|
1541
|
+
defaultValue,
|
|
1542
|
+
autoCapitalize,
|
|
1543
|
+
autoComplete,
|
|
1544
|
+
autoCorrect,
|
|
1545
|
+
autoFocus,
|
|
1546
|
+
placeholder: placeholder ?? label,
|
|
1547
|
+
placeholderTextColor: theme2.colors.textSecondary + "80",
|
|
1548
|
+
enterKeyHint: returnKeyLabel,
|
|
1549
|
+
returnKeyType,
|
|
1550
|
+
onSubmitEditing: onPressEnter,
|
|
1551
|
+
readOnly: !editable || disabled || type === "date" || type === "time",
|
|
1552
|
+
textAlign,
|
|
1553
|
+
editable: !disabled,
|
|
1554
|
+
keyboardAppearance,
|
|
1555
|
+
keyboardType,
|
|
1556
|
+
cursorColor: theme2.colors.primary,
|
|
1557
|
+
selectionColor: theme2.colors.primary,
|
|
1558
|
+
secureTextEntry,
|
|
1559
|
+
onFocus: onFocusElement,
|
|
1560
|
+
onBlur: onBlurElement,
|
|
1561
|
+
onChangeText,
|
|
1562
|
+
maxLength,
|
|
1563
|
+
multiline,
|
|
1564
|
+
numberOfLines,
|
|
1565
|
+
onPress: withPressInputField ? onPressInputField : void 0,
|
|
1566
|
+
ref: textInputRef
|
|
1567
|
+
}
|
|
1568
|
+
)
|
|
1460
1569
|
}
|
|
1461
1570
|
)
|
|
1462
1571
|
}
|
|
@@ -1474,7 +1583,16 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
|
|
|
1474
1583
|
borderBottomRightRadius: theme2.styles.borderRadius,
|
|
1475
1584
|
borderColor: theme2.colors.border,
|
|
1476
1585
|
paddingHorizontal: readyPaddingHorizontal,
|
|
1477
|
-
|
|
1586
|
+
onPress: onPressSuffix,
|
|
1587
|
+
children: typeof suffix === "string" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1588
|
+
Text_default,
|
|
1589
|
+
{
|
|
1590
|
+
fontWeight: 700,
|
|
1591
|
+
lineHeight,
|
|
1592
|
+
marginTop: import_react_native8.Platform.OS === "ios" && onPressSuffix ? readyPaddingVertical : void 0,
|
|
1593
|
+
children: suffix
|
|
1594
|
+
}
|
|
1595
|
+
) : suffix
|
|
1478
1596
|
}
|
|
1479
1597
|
)
|
|
1480
1598
|
] }),
|