react-native-better-html 1.0.9 → 1.0.10

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 CHANGED
@@ -3,7 +3,7 @@ export { AnyOtherString, AssetName, AssetsConfig, Color, ColorName, ColorTheme,
3
3
  import * as react from 'react';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import * as react_native from 'react-native';
6
- import { ViewStyle, GestureResponderEvent, ViewProps as ViewProps$1, TextProps as TextProps$1, TextStyle, ColorValue, ImageSourcePropType, ImageProps as ImageProps$1, ImageStyle, TextInput, FocusEvent } from 'react-native';
6
+ import { ViewStyle, GestureResponderEvent, ViewProps as ViewProps$1, TextProps as TextProps$1, TextStyle, ColorValue, ImageSourcePropType, ImageProps as ImageProps$1, ImageStyle, TextInput, FocusEvent, NativeSyntheticEvent, NativeTouchEvent, TextInputSubmitEditingEvent } from 'react-native';
7
7
  import { EaseFunction, PropsTransforms } from '@legendapp/motion';
8
8
 
9
9
  type AppConfig = {};
@@ -332,20 +332,34 @@ type InputFieldProps = {
332
332
  keyboardType?: React.ComponentProps<typeof TextInput>["keyboardType"];
333
333
  /** @default false */
334
334
  secureTextEntry?: boolean;
335
+ returnKeyLabel?: React.ComponentProps<typeof TextInput>["enterKeyHint"];
336
+ returnKeyType?: React.ComponentProps<typeof TextInput>["returnKeyType"];
337
+ height?: number;
338
+ /** @default 16 */
339
+ fontSize?: number;
340
+ /** @default 400 */
341
+ fontWeight?: TextStyle["fontWeight"];
342
+ /** @default 20 */
343
+ lineHeight?: number;
344
+ textAlign?: React.ComponentProps<typeof TextInput>["textAlign"];
335
345
  onFocus?: (event: FocusEvent) => void;
336
346
  onBlur?: (event: FocusEvent) => void;
337
347
  onChange?: (text: string) => void;
338
- };
339
- type InputFieldRef = {};
348
+ onPress?: (event: NativeSyntheticEvent<NativeTouchEvent>) => void;
349
+ onPressEnter?: (event: TextInputSubmitEditingEvent) => void;
350
+ } & Pick<ComponentPaddingProps, "paddingHorizontal" | "paddingVertical">;
351
+ type InputFieldRef = TextInput;
340
352
  type InputFieldComponentType = {
341
- (props: ComponentPropWithRef<InputFieldRef, InputFieldProps>): React.ReactElement;
342
- email: (props: ComponentPropWithRef<InputFieldRef, InputFieldProps>) => React.ReactElement;
343
- password: (props: ComponentPropWithRef<InputFieldRef, InputFieldProps>) => React.ReactElement;
353
+ (props: ComponentPropWithRef<TextInput, InputFieldProps>): React.ReactElement;
354
+ email: (props: ComponentPropWithRef<TextInput, InputFieldProps>) => React.ReactElement;
355
+ password: (props: ComponentPropWithRef<TextInput, InputFieldProps>) => React.ReactElement;
356
+ code: (props: ComponentPropWithRef<TextInput, InputFieldProps>) => React.ReactElement;
344
357
  };
345
358
  declare const InputFieldComponent: InputFieldComponentType;
346
359
  declare const InputField: typeof InputFieldComponent & {
347
360
  email: typeof InputFieldComponent.email;
348
361
  password: typeof InputFieldComponent.password;
362
+ code: typeof InputFieldComponent.code;
349
363
  };
350
364
 
351
365
  type StatusBarProps = {
@@ -360,4 +374,4 @@ type AsyncStoragePluginOptions = {};
360
374
  declare const defaultAsyncStoragePluginOptions: Required<AsyncStoragePluginOptions>;
361
375
  declare const asyncStoragePlugin: BetterComponentsPluginConstructor<AsyncStoragePluginOptions>;
362
376
 
363
- export { Animate, type AnimateTextProps, type AnimateViewProps, type AppConfig, type AsyncStoragePluginOptions, type BetterComponentsConfig, type BetterComponentsPlugin, _default$1 as BetterComponentsProvider, type BetterComponentsProviderConfig, Button, type ButtonProps, type ComponentMarginProps, type ComponentPaddingProps, type FooterProps, Image, type ImageProps, InputField, type InputFieldProps, Loader, type LoaderProps, type LoaderSize, type PluginName, ScreenHolder, type ScreenHolderProps, _default as StatusBar, type StatusBarProps, Text, type TextProps, View, type ViewProps, asyncStoragePlugin, defaultAsyncStoragePluginOptions, generateAsyncStorage, pressStrength, useBetterComponentsContext, useDevice, useKeyboard };
377
+ export { Animate, type AnimateTextProps, type AnimateViewProps, type AppConfig, type AsyncStoragePluginOptions, type BetterComponentsConfig, type BetterComponentsPlugin, _default$1 as BetterComponentsProvider, type BetterComponentsProviderConfig, Button, type ButtonProps, type ComponentMarginProps, type ComponentPaddingProps, type FooterProps, Image, type ImageProps, InputField, type InputFieldProps, type InputFieldRef, Loader, type LoaderProps, type LoaderSize, type PluginName, ScreenHolder, type ScreenHolderProps, _default as StatusBar, type StatusBarProps, Text, type TextProps, View, type ViewProps, asyncStoragePlugin, defaultAsyncStoragePluginOptions, generateAsyncStorage, pressStrength, useBetterComponentsContext, useDevice, useKeyboard };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { AnyOtherString, AssetName, AssetsConfig, Color, ColorName, ColorTheme,
3
3
  import * as react from 'react';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import * as react_native from 'react-native';
6
- import { ViewStyle, GestureResponderEvent, ViewProps as ViewProps$1, TextProps as TextProps$1, TextStyle, ColorValue, ImageSourcePropType, ImageProps as ImageProps$1, ImageStyle, TextInput, FocusEvent } from 'react-native';
6
+ import { ViewStyle, GestureResponderEvent, ViewProps as ViewProps$1, TextProps as TextProps$1, TextStyle, ColorValue, ImageSourcePropType, ImageProps as ImageProps$1, ImageStyle, TextInput, FocusEvent, NativeSyntheticEvent, NativeTouchEvent, TextInputSubmitEditingEvent } from 'react-native';
7
7
  import { EaseFunction, PropsTransforms } from '@legendapp/motion';
8
8
 
9
9
  type AppConfig = {};
@@ -332,20 +332,34 @@ type InputFieldProps = {
332
332
  keyboardType?: React.ComponentProps<typeof TextInput>["keyboardType"];
333
333
  /** @default false */
334
334
  secureTextEntry?: boolean;
335
+ returnKeyLabel?: React.ComponentProps<typeof TextInput>["enterKeyHint"];
336
+ returnKeyType?: React.ComponentProps<typeof TextInput>["returnKeyType"];
337
+ height?: number;
338
+ /** @default 16 */
339
+ fontSize?: number;
340
+ /** @default 400 */
341
+ fontWeight?: TextStyle["fontWeight"];
342
+ /** @default 20 */
343
+ lineHeight?: number;
344
+ textAlign?: React.ComponentProps<typeof TextInput>["textAlign"];
335
345
  onFocus?: (event: FocusEvent) => void;
336
346
  onBlur?: (event: FocusEvent) => void;
337
347
  onChange?: (text: string) => void;
338
- };
339
- type InputFieldRef = {};
348
+ onPress?: (event: NativeSyntheticEvent<NativeTouchEvent>) => void;
349
+ onPressEnter?: (event: TextInputSubmitEditingEvent) => void;
350
+ } & Pick<ComponentPaddingProps, "paddingHorizontal" | "paddingVertical">;
351
+ type InputFieldRef = TextInput;
340
352
  type InputFieldComponentType = {
341
- (props: ComponentPropWithRef<InputFieldRef, InputFieldProps>): React.ReactElement;
342
- email: (props: ComponentPropWithRef<InputFieldRef, InputFieldProps>) => React.ReactElement;
343
- password: (props: ComponentPropWithRef<InputFieldRef, InputFieldProps>) => React.ReactElement;
353
+ (props: ComponentPropWithRef<TextInput, InputFieldProps>): React.ReactElement;
354
+ email: (props: ComponentPropWithRef<TextInput, InputFieldProps>) => React.ReactElement;
355
+ password: (props: ComponentPropWithRef<TextInput, InputFieldProps>) => React.ReactElement;
356
+ code: (props: ComponentPropWithRef<TextInput, InputFieldProps>) => React.ReactElement;
344
357
  };
345
358
  declare const InputFieldComponent: InputFieldComponentType;
346
359
  declare const InputField: typeof InputFieldComponent & {
347
360
  email: typeof InputFieldComponent.email;
348
361
  password: typeof InputFieldComponent.password;
362
+ code: typeof InputFieldComponent.code;
349
363
  };
350
364
 
351
365
  type StatusBarProps = {
@@ -360,4 +374,4 @@ type AsyncStoragePluginOptions = {};
360
374
  declare const defaultAsyncStoragePluginOptions: Required<AsyncStoragePluginOptions>;
361
375
  declare const asyncStoragePlugin: BetterComponentsPluginConstructor<AsyncStoragePluginOptions>;
362
376
 
363
- export { Animate, type AnimateTextProps, type AnimateViewProps, type AppConfig, type AsyncStoragePluginOptions, type BetterComponentsConfig, type BetterComponentsPlugin, _default$1 as BetterComponentsProvider, type BetterComponentsProviderConfig, Button, type ButtonProps, type ComponentMarginProps, type ComponentPaddingProps, type FooterProps, Image, type ImageProps, InputField, type InputFieldProps, Loader, type LoaderProps, type LoaderSize, type PluginName, ScreenHolder, type ScreenHolderProps, _default as StatusBar, type StatusBarProps, Text, type TextProps, View, type ViewProps, asyncStoragePlugin, defaultAsyncStoragePluginOptions, generateAsyncStorage, pressStrength, useBetterComponentsContext, useDevice, useKeyboard };
377
+ export { Animate, type AnimateTextProps, type AnimateViewProps, type AppConfig, type AsyncStoragePluginOptions, type BetterComponentsConfig, type BetterComponentsPlugin, _default$1 as BetterComponentsProvider, type BetterComponentsProviderConfig, Button, type ButtonProps, type ComponentMarginProps, type ComponentPaddingProps, type FooterProps, Image, type ImageProps, InputField, type InputFieldProps, type InputFieldRef, Loader, type LoaderProps, type LoaderSize, type PluginName, ScreenHolder, type ScreenHolderProps, _default as StatusBar, type StatusBarProps, Text, type TextProps, View, type ViewProps, asyncStoragePlugin, defaultAsyncStoragePluginOptions, generateAsyncStorage, pressStrength, useBetterComponentsContext, useDevice, useKeyboard };
package/dist/index.js CHANGED
@@ -1194,19 +1194,30 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
1194
1194
  keyboardAppearance = "default",
1195
1195
  keyboardType,
1196
1196
  secureTextEntry,
1197
+ returnKeyLabel,
1198
+ returnKeyType,
1199
+ height,
1200
+ fontSize = 16,
1201
+ fontWeight = 400,
1202
+ lineHeight = 20,
1203
+ textAlign,
1204
+ paddingHorizontal,
1205
+ paddingVertical,
1197
1206
  onFocus,
1198
1207
  onBlur,
1199
- onChange
1208
+ onChange,
1209
+ onPress,
1210
+ onPressEnter
1200
1211
  }, ref) => {
1201
1212
  const theme2 = (0, import_react_better_core9.useTheme)();
1202
1213
  const { colorTheme } = (0, import_react_better_core9.useBetterCoreContext)();
1214
+ const textInputRef = (0, import_react10.useRef)(null);
1203
1215
  const [internalValue, setInternalValue] = (0, import_react10.useState)(value?.toString() || defaultValue || "");
1204
1216
  const [isFocused, setIsFocused] = (0, import_react_better_core9.useBooleanState)();
1205
1217
  const borderWidth = 1;
1206
- const lineHeight = 20;
1207
- const paddingHorizontal = theme2.styles.space;
1208
- const paddingVertical = (theme2.styles.space + theme2.styles.gap) / 2;
1209
- const height = borderWidth + paddingVertical + lineHeight + paddingVertical + borderWidth;
1218
+ const readyPaddingHorizontal = paddingHorizontal ?? theme2.styles.space;
1219
+ const readyPaddingVertical = paddingVertical ? parseFloat(paddingVertical.toString()) : (theme2.styles.space + theme2.styles.gap) / 2;
1220
+ const readyHeight = height ?? borderWidth + readyPaddingVertical + lineHeight + readyPaddingVertical + borderWidth;
1210
1221
  const onFocusElement = (0, import_react10.useCallback)((event) => {
1211
1222
  setIsFocused.setTrue();
1212
1223
  onFocus?.(event);
@@ -1225,13 +1236,14 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
1225
1236
  const textInputStyle = (0, import_react10.useMemo)(
1226
1237
  () => ({
1227
1238
  flex: 1,
1228
- fontSize: 16,
1239
+ fontSize,
1240
+ fontWeight,
1229
1241
  lineHeight,
1230
1242
  color: theme2.colors.textPrimary,
1231
- paddingHorizontal,
1232
- paddingVertical
1243
+ paddingHorizontal: readyPaddingHorizontal,
1244
+ paddingVertical: readyPaddingVertical
1233
1245
  }),
1234
- [theme2.colors, lineHeight, paddingHorizontal, paddingVertical]
1246
+ [theme2.colors, fontSize, fontWeight, lineHeight, readyPaddingHorizontal, readyPaddingVertical]
1235
1247
  );
1236
1248
  (0, import_react10.useEffect)(() => {
1237
1249
  if (value === void 0) return;
@@ -1240,12 +1252,12 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
1240
1252
  (0, import_react10.useImperativeHandle)(
1241
1253
  ref,
1242
1254
  () => {
1243
- return {};
1255
+ return textInputRef.current;
1244
1256
  },
1245
1257
  []
1246
1258
  );
1247
1259
  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);
1248
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(View_default, { isRow: true, position: "relative", alignItems: "center", height, children: [
1260
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(View_default, { isRow: true, position: "relative", alignItems: "center", flex: 1, height: readyHeight, children: [
1249
1261
  prefix && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1250
1262
  View_default,
1251
1263
  {
@@ -1258,7 +1270,7 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
1258
1270
  borderTopLeftRadius: theme2.styles.borderRadius,
1259
1271
  borderBottomLeftRadius: theme2.styles.borderRadius,
1260
1272
  borderColor: theme2.colors.border,
1261
- paddingHorizontal,
1273
+ paddingHorizontal: readyPaddingHorizontal,
1262
1274
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text_default, { fontWeight: 700, children: prefix })
1263
1275
  }
1264
1276
  ),
@@ -1287,7 +1299,11 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
1287
1299
  autoFocus,
1288
1300
  placeholder,
1289
1301
  placeholderTextColor: theme2.colors.textSecondary + "80",
1302
+ enterKeyHint: returnKeyLabel,
1303
+ returnKeyType,
1304
+ onSubmitEditing: onPressEnter,
1290
1305
  readOnly: !editable,
1306
+ textAlign,
1291
1307
  keyboardAppearance,
1292
1308
  keyboardType,
1293
1309
  cursorColor: theme2.colors.primary,
@@ -1295,7 +1311,9 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
1295
1311
  secureTextEntry,
1296
1312
  onFocus: onFocusElement,
1297
1313
  onBlur: onBlurElement,
1298
- onChangeText
1314
+ onChangeText,
1315
+ onPress,
1316
+ ref: textInputRef
1299
1317
  }
1300
1318
  )
1301
1319
  }
@@ -1312,7 +1330,7 @@ var InputFieldComponent = (0, import_react10.forwardRef)(
1312
1330
  borderTopRightRadius: theme2.styles.borderRadius,
1313
1331
  borderBottomRightRadius: theme2.styles.borderRadius,
1314
1332
  borderColor: theme2.colors.border,
1315
- paddingHorizontal,
1333
+ paddingHorizontal: readyPaddingHorizontal,
1316
1334
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text_default, { fontWeight: 700, children: suffix })
1317
1335
  }
1318
1336
  )
@@ -1347,9 +1365,25 @@ InputFieldComponent.password = (0, import_react10.forwardRef)(function Password(
1347
1365
  }
1348
1366
  );
1349
1367
  });
1368
+ InputFieldComponent.code = (0, import_react10.forwardRef)(function Password2(props, ref) {
1369
+ const theme2 = (0, import_react_better_core9.useTheme)();
1370
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1371
+ InputFieldComponent,
1372
+ {
1373
+ fontSize: 42,
1374
+ fontWeight: 900,
1375
+ lineHeight: 50,
1376
+ paddingVertical: theme2.styles.space * 2,
1377
+ textAlign: "center",
1378
+ ...props,
1379
+ ref
1380
+ }
1381
+ );
1382
+ });
1350
1383
  var InputField = (0, import_react10.memo)(InputFieldComponent);
1351
1384
  InputField.email = InputFieldComponent.email;
1352
1385
  InputField.password = InputFieldComponent.password;
1386
+ InputField.code = InputFieldComponent.code;
1353
1387
  var InputField_default = InputField;
1354
1388
 
1355
1389
  // src/components/StatusBar.tsx