react-native-better-html 1.0.9 → 1.0.11

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.mjs CHANGED
@@ -1138,8 +1138,19 @@ Image2.profileImage = ImageComponent.profileImage;
1138
1138
  var Image_default = Image2;
1139
1139
 
1140
1140
  // src/components/InputField.tsx
1141
- import { forwardRef, memo as memo9, useCallback as useCallback2, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo8, useState as useState2 } from "react";
1142
- import { TextInput } from "react-native";
1141
+ import {
1142
+ forwardRef,
1143
+ memo as memo9,
1144
+ useCallback as useCallback2,
1145
+ useEffect as useEffect4,
1146
+ useImperativeHandle,
1147
+ useMemo as useMemo8,
1148
+ useRef,
1149
+ useState as useState2
1150
+ } from "react";
1151
+ import {
1152
+ TextInput
1153
+ } from "react-native";
1143
1154
  import {
1144
1155
  darkenColor,
1145
1156
  lightenColor,
@@ -1156,6 +1167,10 @@ var InputFieldComponent = forwardRef(
1156
1167
  defaultValue,
1157
1168
  value,
1158
1169
  editable = true,
1170
+ label,
1171
+ isError,
1172
+ infoMessage,
1173
+ errorMessage,
1159
1174
  autoFocus,
1160
1175
  autoCapitalize,
1161
1176
  autoComplete,
@@ -1163,19 +1178,30 @@ var InputFieldComponent = forwardRef(
1163
1178
  keyboardAppearance = "default",
1164
1179
  keyboardType,
1165
1180
  secureTextEntry,
1181
+ returnKeyLabel,
1182
+ returnKeyType,
1183
+ height,
1184
+ fontSize = 16,
1185
+ fontWeight = 400,
1186
+ lineHeight = 20,
1187
+ textAlign,
1188
+ paddingHorizontal,
1189
+ paddingVertical,
1166
1190
  onFocus,
1167
1191
  onBlur,
1168
- onChange
1192
+ onChange,
1193
+ onPress,
1194
+ onPressEnter
1169
1195
  }, ref) => {
1170
1196
  const theme2 = useTheme8();
1171
1197
  const { colorTheme } = useBetterCoreContext3();
1198
+ const textInputRef = useRef(null);
1172
1199
  const [internalValue, setInternalValue] = useState2(value?.toString() || defaultValue || "");
1173
1200
  const [isFocused, setIsFocused] = useBooleanState4();
1174
1201
  const borderWidth = 1;
1175
- const lineHeight = 20;
1176
- const paddingHorizontal = theme2.styles.space;
1177
- const paddingVertical = (theme2.styles.space + theme2.styles.gap) / 2;
1178
- const height = borderWidth + paddingVertical + lineHeight + paddingVertical + borderWidth;
1202
+ const readyPaddingHorizontal = paddingHorizontal ?? theme2.styles.space;
1203
+ const readyPaddingVertical = paddingVertical ? parseFloat(paddingVertical.toString()) : (theme2.styles.space + theme2.styles.gap) / 2;
1204
+ const readyHeight = height ?? borderWidth + readyPaddingVertical + lineHeight + readyPaddingVertical + borderWidth;
1179
1205
  const onFocusElement = useCallback2((event) => {
1180
1206
  setIsFocused.setTrue();
1181
1207
  onFocus?.(event);
@@ -1194,13 +1220,14 @@ var InputFieldComponent = forwardRef(
1194
1220
  const textInputStyle = useMemo8(
1195
1221
  () => ({
1196
1222
  flex: 1,
1197
- fontSize: 16,
1223
+ fontSize,
1224
+ fontWeight,
1198
1225
  lineHeight,
1199
1226
  color: theme2.colors.textPrimary,
1200
- paddingHorizontal,
1201
- paddingVertical
1227
+ paddingHorizontal: readyPaddingHorizontal,
1228
+ paddingVertical: readyPaddingVertical
1202
1229
  }),
1203
- [theme2.colors, lineHeight, paddingHorizontal, paddingVertical]
1230
+ [theme2.colors, fontSize, fontWeight, lineHeight, readyPaddingHorizontal, readyPaddingVertical]
1204
1231
  );
1205
1232
  useEffect4(() => {
1206
1233
  if (value === void 0) return;
@@ -1209,80 +1236,113 @@ var InputFieldComponent = forwardRef(
1209
1236
  useImperativeHandle(
1210
1237
  ref,
1211
1238
  () => {
1212
- return {};
1239
+ return textInputRef.current;
1213
1240
  },
1214
1241
  []
1215
1242
  );
1216
1243
  const prefixSuffixBackgroundColor = colorTheme === "light" ? darkenColor(theme2.colors.backgroundContent, 0.03) : lightenColor(theme2.colors.backgroundContent, 0.1);
1217
- return /* @__PURE__ */ jsxs4(View_default, { isRow: true, position: "relative", alignItems: "center", height, children: [
1218
- prefix && /* @__PURE__ */ jsx9(
1219
- View_default,
1220
- {
1221
- isRow: true,
1222
- height: "100%",
1223
- backgroundColor: prefixSuffixBackgroundColor,
1224
- alignItems: "center",
1225
- borderWidth,
1226
- borderRightWidth: 0,
1227
- borderTopLeftRadius: theme2.styles.borderRadius,
1228
- borderBottomLeftRadius: theme2.styles.borderRadius,
1229
- borderColor: theme2.colors.border,
1230
- paddingHorizontal,
1231
- children: /* @__PURE__ */ jsx9(Text_default, { fontWeight: 700, children: prefix })
1232
- }
1233
- ),
1234
- /* @__PURE__ */ jsx9(
1235
- Animate_default.View,
1244
+ return /* @__PURE__ */ jsxs4(View_default, { flex: 1, gap: theme2.styles.gap / 3, children: [
1245
+ label && /* @__PURE__ */ jsx9(Text_default, { fontSize: 14, color: theme2.colors.textSecondary, children: label }),
1246
+ /* @__PURE__ */ jsxs4(View_default, { isRow: true, position: "relative", alignItems: "center", flex: 1, height: readyHeight, children: [
1247
+ prefix && /* @__PURE__ */ jsx9(
1248
+ View_default,
1249
+ {
1250
+ isRow: true,
1251
+ height: "100%",
1252
+ backgroundColor: prefixSuffixBackgroundColor,
1253
+ alignItems: "center",
1254
+ borderWidth,
1255
+ borderRightWidth: 0,
1256
+ borderTopLeftRadius: theme2.styles.borderRadius,
1257
+ borderBottomLeftRadius: theme2.styles.borderRadius,
1258
+ borderColor: theme2.colors.border,
1259
+ paddingHorizontal: readyPaddingHorizontal,
1260
+ children: typeof prefix === "string" ? /* @__PURE__ */ jsx9(Text_default, { fontWeight: 700, children: prefix }) : prefix
1261
+ }
1262
+ ),
1263
+ /* @__PURE__ */ jsx9(
1264
+ Animate_default.View,
1265
+ {
1266
+ flex: 1,
1267
+ backgroundColor: theme2.colors.backgroundContent,
1268
+ borderTopLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
1269
+ borderBottomLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
1270
+ borderTopRightRadius: suffix ? 0 : theme2.styles.borderRadius,
1271
+ borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
1272
+ borderWidth,
1273
+ initialBorderColor: theme2.colors.border,
1274
+ animateBorderColor: isFocused ? theme2.colors.primary : isError ? theme2.colors.error : theme2.colors.border,
1275
+ overflow: "hidden",
1276
+ children: /* @__PURE__ */ jsx9(
1277
+ TextInput,
1278
+ {
1279
+ style: textInputStyle,
1280
+ value: internalValue,
1281
+ defaultValue,
1282
+ autoCapitalize,
1283
+ autoComplete,
1284
+ autoCorrect,
1285
+ autoFocus,
1286
+ placeholder,
1287
+ placeholderTextColor: theme2.colors.textSecondary + "80",
1288
+ enterKeyHint: returnKeyLabel,
1289
+ returnKeyType,
1290
+ onSubmitEditing: onPressEnter,
1291
+ readOnly: !editable,
1292
+ textAlign,
1293
+ keyboardAppearance,
1294
+ keyboardType,
1295
+ cursorColor: theme2.colors.primary,
1296
+ selectionColor: theme2.colors.primary,
1297
+ secureTextEntry,
1298
+ onFocus: onFocusElement,
1299
+ onBlur: onBlurElement,
1300
+ onChangeText,
1301
+ onPress,
1302
+ ref: textInputRef
1303
+ }
1304
+ )
1305
+ }
1306
+ ),
1307
+ suffix && /* @__PURE__ */ jsx9(
1308
+ View_default,
1309
+ {
1310
+ isRow: true,
1311
+ height: "100%",
1312
+ backgroundColor: prefixSuffixBackgroundColor,
1313
+ alignItems: "center",
1314
+ borderWidth,
1315
+ borderLeftWidth: 0,
1316
+ borderTopRightRadius: theme2.styles.borderRadius,
1317
+ borderBottomRightRadius: theme2.styles.borderRadius,
1318
+ borderColor: theme2.colors.border,
1319
+ paddingHorizontal: readyPaddingHorizontal,
1320
+ children: typeof suffix === "string" ? /* @__PURE__ */ jsx9(Text_default, { fontWeight: 700, children: suffix }) : suffix
1321
+ }
1322
+ )
1323
+ ] }),
1324
+ infoMessage && /* @__PURE__ */ jsx9(
1325
+ Animate_default.Text,
1236
1326
  {
1237
- flex: 1,
1238
- backgroundColor: theme2.colors.backgroundContent,
1239
- borderTopLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
1240
- borderBottomLeftRadius: prefix ? 0 : theme2.styles.borderRadius,
1241
- borderTopRightRadius: suffix ? 0 : theme2.styles.borderRadius,
1242
- borderBottomRightRadius: suffix ? 0 : theme2.styles.borderRadius,
1243
- borderWidth,
1244
- initialBorderColor: theme2.colors.border,
1245
- animateBorderColor: isFocused ? theme2.colors.primary : theme2.colors.border,
1246
- overflow: "hidden",
1247
- children: /* @__PURE__ */ jsx9(
1248
- TextInput,
1249
- {
1250
- style: textInputStyle,
1251
- value: internalValue,
1252
- defaultValue,
1253
- autoCapitalize,
1254
- autoComplete,
1255
- autoCorrect,
1256
- autoFocus,
1257
- placeholder,
1258
- placeholderTextColor: theme2.colors.textSecondary + "80",
1259
- readOnly: !editable,
1260
- keyboardAppearance,
1261
- keyboardType,
1262
- cursorColor: theme2.colors.primary,
1263
- selectionColor: theme2.colors.primary,
1264
- secureTextEntry,
1265
- onFocus: onFocusElement,
1266
- onBlur: onBlurElement,
1267
- onChangeText
1268
- }
1269
- )
1327
+ fontSize: 14,
1328
+ color: theme2.colors.textSecondary,
1329
+ initialHeight: 0,
1330
+ initialOpacity: 0,
1331
+ animateHeight: 17,
1332
+ animateOpacity: 1,
1333
+ children: infoMessage
1270
1334
  }
1271
1335
  ),
1272
- suffix && /* @__PURE__ */ jsx9(
1273
- View_default,
1336
+ errorMessage && /* @__PURE__ */ jsx9(
1337
+ Animate_default.Text,
1274
1338
  {
1275
- isRow: true,
1276
- height: "100%",
1277
- backgroundColor: prefixSuffixBackgroundColor,
1278
- alignItems: "center",
1279
- borderWidth,
1280
- borderLeftWidth: 0,
1281
- borderTopRightRadius: theme2.styles.borderRadius,
1282
- borderBottomRightRadius: theme2.styles.borderRadius,
1283
- borderColor: theme2.colors.border,
1284
- paddingHorizontal,
1285
- children: /* @__PURE__ */ jsx9(Text_default, { fontWeight: 700, children: suffix })
1339
+ fontSize: 14,
1340
+ color: theme2.colors.error,
1341
+ initialHeight: 0,
1342
+ initialOpacity: 0,
1343
+ animateHeight: 17,
1344
+ animateOpacity: 1,
1345
+ children: errorMessage
1286
1346
  }
1287
1347
  )
1288
1348
  ] });
@@ -1316,22 +1376,40 @@ InputFieldComponent.password = forwardRef(function Password(props, ref) {
1316
1376
  }
1317
1377
  );
1318
1378
  });
1379
+ InputFieldComponent.code = forwardRef(function Password2({ isSmall, ...props }, ref) {
1380
+ const theme2 = useTheme8();
1381
+ return /* @__PURE__ */ jsx9(
1382
+ InputFieldComponent,
1383
+ {
1384
+ fontSize: isSmall ? 36 : 42,
1385
+ fontWeight: 900,
1386
+ lineHeight: isSmall ? 42 : 50,
1387
+ paddingVertical: isSmall ? theme2.styles.space : theme2.styles.space * 2,
1388
+ paddingHorizontal: isSmall ? theme2.styles.gap : void 0,
1389
+ textAlign: "center",
1390
+ ...props,
1391
+ ref
1392
+ }
1393
+ );
1394
+ });
1319
1395
  var InputField = memo9(InputFieldComponent);
1320
1396
  InputField.email = InputFieldComponent.email;
1321
1397
  InputField.password = InputFieldComponent.password;
1398
+ InputField.code = InputFieldComponent.code;
1322
1399
  var InputField_default = InputField;
1323
1400
 
1324
1401
  // src/components/StatusBar.tsx
1325
1402
  import { memo as memo10 } from "react";
1326
1403
  import { useTheme as useTheme9 } from "react-better-core";
1327
- import { StatusBar as NativeStatusBar } from "react-native";
1404
+ import { StatusBar as NativeStatusBar, Platform as Platform4 } from "react-native";
1328
1405
  import { jsx as jsx10 } from "react/jsx-runtime";
1329
- function StatusBar({ darkStatusBar, hidden }) {
1406
+ function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarStyle }) {
1330
1407
  const theme2 = useTheme9();
1331
1408
  return /* @__PURE__ */ jsx10(
1332
1409
  NativeStatusBar,
1333
1410
  {
1334
1411
  backgroundColor: darkStatusBar ? theme2.colors.backgroundSecondary : void 0,
1412
+ barStyle: barStyle ?? (Platform4.OS === "android" ? androidBarStyle : iOSBarStyle),
1335
1413
  hidden
1336
1414
  }
1337
1415
  );