@hero-design/rn 8.3.1 → 8.3.2

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.
@@ -1,9 +1,9 @@
1
- @hero-design/rn:build: cache hit, replaying output 3ad2304a0e6682cc
2
- @hero-design/rn:build: $ yarn build:js && yarn build:types
3
- @hero-design/rn:build: $ rollup -c
4
- @hero-design/rn:build: 
5
- @hero-design/rn:build: src/index.ts → lib/index.js, es/index.js...
6
- @hero-design/rn:build: (!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
7
- @hero-design/rn:build: (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/root/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
8
- @hero-design/rn:build: created lib/index.js, es/index.js in 23.8s
9
- @hero-design/rn:build: $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
1
+ @hero-design/rn:build: cache hit, replaying output 5e986a2b883ef3bb
2
+ @hero-design/rn:build: $ yarn build:js && yarn build:types
3
+ @hero-design/rn:build: $ rollup -c
4
+ @hero-design/rn:build: 
5
+ @hero-design/rn:build: src/index.ts → lib/index.js, es/index.js...
6
+ @hero-design/rn:build: (!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
7
+ @hero-design/rn:build: (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/root/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
8
+ @hero-design/rn:build: created lib/index.js, es/index.js in 28.6s
9
+ @hero-design/rn:build: $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as reactNative from 'react-native';
2
- import { Platform, Dimensions, StyleSheet as StyleSheet$1, Animated, View, Easing, TouchableOpacity, Text as Text$1, Image as Image$1, TouchableWithoutFeedback, Pressable, SafeAreaView, KeyboardAvoidingView, ScrollView, Modal, useWindowDimensions, FlatList, TextInput as TextInput$2, PanResponder, TouchableHighlight, InteractionManager, Keyboard, SectionList, LayoutAnimation, RefreshControl as RefreshControl$1 } from 'react-native';
2
+ import { Platform, Dimensions, StyleSheet as StyleSheet$1, Animated, View, Easing, TouchableOpacity, Text as Text$1, Image as Image$1, TouchableWithoutFeedback, Pressable, SafeAreaView, KeyboardAvoidingView, ScrollView, Modal, useWindowDimensions, FlatList, TextInput as TextInput$1, PanResponder, TouchableHighlight, InteractionManager, Keyboard, SectionList, LayoutAnimation, RefreshControl as RefreshControl$1 } from 'react-native';
3
3
  import React, { useContext, createContext, createElement, useMemo, forwardRef, useEffect, useCallback, useRef, useState, useLayoutEffect, useImperativeHandle } from 'react';
4
4
  import { createIconSet } from 'react-native-vector-icons';
5
5
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -10958,7 +10958,7 @@ var StyledHelperText = index$a(Typography.Text)(function (_ref10) {
10958
10958
  fontSize: theme.__hd__.textInput.fontSizes.error
10959
10959
  };
10960
10960
  });
10961
- var StyledTextInput = index$a(TextInput$2)(function (_ref11) {
10961
+ var StyledTextInput = index$a(TextInput$1)(function (_ref11) {
10962
10962
  var theme = _ref11.theme;
10963
10963
  return {
10964
10964
  textAlignVertical: 'center',
@@ -11035,7 +11035,7 @@ var getVariant$1 = function getVariant(_ref) {
11035
11035
  // Fix issue: Placeholder is not shown on iOS when multiline is true
11036
11036
  // https://github.com/callstack/react-native-paper/pull/3331
11037
11037
  var EMPTY_PLACEHOLDER_VALUE = ' ';
11038
- var TextInput = function TextInput(_ref2, ref) {
11038
+ var TextInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
11039
11039
  var _ref3;
11040
11040
  var label = _ref2.label,
11041
11041
  prefix = _ref2.prefix,
@@ -11204,8 +11204,7 @@ var TextInput = function TextInput(_ref2, ref) {
11204
11204
  themeVariant: variant,
11205
11205
  fontSize: "small"
11206
11206
  }, displayText.length, "/", maxLength)), !!helpText && /*#__PURE__*/React.createElement(StyledHelperText, null, helpText)));
11207
- };
11208
- var TextInput$1 = /*#__PURE__*/React.forwardRef(TextInput);
11207
+ });
11209
11208
 
11210
11209
  var DatePickerAndroid = function DatePickerAndroid(_ref) {
11211
11210
  var value = _ref.value,
@@ -11237,7 +11236,7 @@ var DatePickerAndroid = function DatePickerAndroid(_ref) {
11237
11236
  }, /*#__PURE__*/React.createElement(View, {
11238
11237
  pointerEvents: "none",
11239
11238
  testID: "datePickerInputAndroid"
11240
- }, /*#__PURE__*/React.createElement(TextInput$1, {
11239
+ }, /*#__PURE__*/React.createElement(TextInput, {
11241
11240
  label: label,
11242
11241
  value: displayValue,
11243
11242
  suffix: "calendar-dates-outlined",
@@ -11305,7 +11304,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
11305
11304
  }, /*#__PURE__*/React.createElement(View, {
11306
11305
  pointerEvents: "none",
11307
11306
  testID: "datePickerInputIOS"
11308
- }, /*#__PURE__*/React.createElement(TextInput$1, {
11307
+ }, /*#__PURE__*/React.createElement(TextInput, {
11309
11308
  label: label,
11310
11309
  value: displayValue,
11311
11310
  suffix: "calendar-dates-outlined",
@@ -12238,7 +12237,7 @@ var StyledFilledMask = index$a(View)(function (_ref5) {
12238
12237
  backgroundColor: theme.__hd__.pinInput.colors[themeState]
12239
12238
  };
12240
12239
  });
12241
- var StyledHiddenInput = index$a(TextInput$2)(function (_ref6) {
12240
+ var StyledHiddenInput = index$a(TextInput$1)(function (_ref6) {
12242
12241
  var themePinLength = _ref6.themePinLength,
12243
12242
  theme = _ref6.theme;
12244
12243
  var cellWidth = theme.__hd__.pinInput.sizes.cellWidth;
@@ -13350,7 +13349,7 @@ function MultiSelect(_ref) {
13350
13349
  }
13351
13350
  }, /*#__PURE__*/React.createElement(View, {
13352
13351
  pointerEvents: "none"
13353
- }, /*#__PURE__*/React.createElement(TextInput$1, _extends$1({}, inputProps, {
13352
+ }, /*#__PURE__*/React.createElement(TextInput, _extends$1({}, inputProps, {
13354
13353
  label: label,
13355
13354
  value: displayedValue,
13356
13355
  suffix: "arrow-down",
@@ -13398,7 +13397,7 @@ function MultiSelect(_ref) {
13398
13397
  (_sectionListRef$curre = sectionListRef.current) === null || _sectionListRef$curre === void 0 ? void 0 : _sectionListRef$curre.scrollToLocation(scrollParams);
13399
13398
  }
13400
13399
  }
13401
- }, onQueryChange && /*#__PURE__*/React.createElement(StyledSearchBar, null, /*#__PURE__*/React.createElement(TextInput$1, {
13400
+ }, onQueryChange && /*#__PURE__*/React.createElement(StyledSearchBar, null, /*#__PURE__*/React.createElement(TextInput, {
13402
13401
  editable: true,
13403
13402
  placeholder: "Search",
13404
13403
  suffix: "search-outlined",
@@ -13526,7 +13525,7 @@ var SingleSelect = function SingleSelect(_ref) {
13526
13525
  }
13527
13526
  }, /*#__PURE__*/React.createElement(View, {
13528
13527
  pointerEvents: "none"
13529
- }, /*#__PURE__*/React.createElement(TextInput$1, _extends$1({}, inputProps, {
13528
+ }, /*#__PURE__*/React.createElement(TextInput, _extends$1({}, inputProps, {
13530
13529
  label: label,
13531
13530
  value: displayedValue,
13532
13531
  suffix: "arrow-down",
@@ -13558,7 +13557,7 @@ var SingleSelect = function SingleSelect(_ref) {
13558
13557
  (_sectionListRef$curre = sectionListRef.current) === null || _sectionListRef$curre === void 0 ? void 0 : _sectionListRef$curre.scrollToLocation(scrollParams);
13559
13558
  }
13560
13559
  }
13561
- }, onQueryChange && /*#__PURE__*/React.createElement(StyledSearchBar, null, /*#__PURE__*/React.createElement(TextInput$1, {
13560
+ }, onQueryChange && /*#__PURE__*/React.createElement(StyledSearchBar, null, /*#__PURE__*/React.createElement(TextInput, {
13562
13561
  editable: true,
13563
13562
  placeholder: "Search",
13564
13563
  suffix: "search-outlined",
@@ -14299,7 +14298,7 @@ var TimePickerAndroid = function TimePickerAndroid(_ref) {
14299
14298
  }, /*#__PURE__*/React.createElement(View, {
14300
14299
  pointerEvents: "none",
14301
14300
  testID: "timePickerInputAndroid"
14302
- }, /*#__PURE__*/React.createElement(TextInput$1, {
14301
+ }, /*#__PURE__*/React.createElement(TextInput, {
14303
14302
  label: label,
14304
14303
  value: displayValue,
14305
14304
  suffix: showSuffix ? 'clock-3' : undefined,
@@ -14367,7 +14366,7 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
14367
14366
  }, /*#__PURE__*/React.createElement(View, {
14368
14367
  pointerEvents: "none",
14369
14368
  testID: "timePickerInputIOS"
14370
- }, /*#__PURE__*/React.createElement(TextInput$1, {
14369
+ }, /*#__PURE__*/React.createElement(TextInput, {
14371
14370
  label: label,
14372
14371
  value: displayValue,
14373
14372
  suffix: showSuffix ? 'clock-3' : undefined,
@@ -31210,4 +31209,4 @@ var index = Object.assign(RichTextEditor$1, {
31210
31209
  Toolbar: EditorToolbar
31211
31210
  });
31212
31211
 
31213
- export { Accordion, Alert, Attachment, index$9 as Avatar, Badge$1 as Badge, BottomNavigation, BottomSheet$1 as BottomSheet, Box, CompoundButton as Button, Calendar, index$8 as Card, Carousel, Checkbox, Collapse, ContentNavigator, DatePicker, Divider, index$7 as Drawer, Empty, index$6 as FAB, Icon, Image, List, PinInput, Progress, CompoundRadio as Radio, RefreshControl, index as RichTextEditor, SectionHeading, index$4 as Select, Slider, Spinner, index$5 as Swipeable, index$3 as Switch, index$2 as Tabs, Tag, TextInput$1 as TextInput, ThemeProvider, ThemeSwitcher, TimePicker, Toast, index$1 as Toolbar, Typography, eBensSystemPalette, getTheme$1 as getTheme, jobsSystemPalette, scale, swagSystemPalette, defaultTheme as theme, useAvatarColors, useTheme, walletSystemPalette, workSystemPalette };
31212
+ export { Accordion, Alert, Attachment, index$9 as Avatar, Badge$1 as Badge, BottomNavigation, BottomSheet$1 as BottomSheet, Box, CompoundButton as Button, Calendar, index$8 as Card, Carousel, Checkbox, Collapse, ContentNavigator, DatePicker, Divider, index$7 as Drawer, Empty, index$6 as FAB, Icon, Image, List, PinInput, Progress, CompoundRadio as Radio, RefreshControl, index as RichTextEditor, SectionHeading, index$4 as Select, Slider, Spinner, index$5 as Swipeable, index$3 as Switch, index$2 as Tabs, Tag, TextInput, ThemeProvider, ThemeSwitcher, TimePicker, Toast, index$1 as Toolbar, Typography, eBensSystemPalette, getTheme$1 as getTheme, jobsSystemPalette, scale, swagSystemPalette, defaultTheme as theme, useAvatarColors, useTheme, walletSystemPalette, workSystemPalette };
package/lib/index.js CHANGED
@@ -11064,7 +11064,7 @@ var getVariant$1 = function getVariant(_ref) {
11064
11064
  // Fix issue: Placeholder is not shown on iOS when multiline is true
11065
11065
  // https://github.com/callstack/react-native-paper/pull/3331
11066
11066
  var EMPTY_PLACEHOLDER_VALUE = ' ';
11067
- var TextInput = function TextInput(_ref2, ref) {
11067
+ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
11068
11068
  var _ref3;
11069
11069
  var label = _ref2.label,
11070
11070
  prefix = _ref2.prefix,
@@ -11233,8 +11233,7 @@ var TextInput = function TextInput(_ref2, ref) {
11233
11233
  themeVariant: variant,
11234
11234
  fontSize: "small"
11235
11235
  }, displayText.length, "/", maxLength)), !!helpText && /*#__PURE__*/React__default["default"].createElement(StyledHelperText, null, helpText)));
11236
- };
11237
- var TextInput$1 = /*#__PURE__*/React__default["default"].forwardRef(TextInput);
11236
+ });
11238
11237
 
11239
11238
  var DatePickerAndroid = function DatePickerAndroid(_ref) {
11240
11239
  var value = _ref.value,
@@ -11266,7 +11265,7 @@ var DatePickerAndroid = function DatePickerAndroid(_ref) {
11266
11265
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
11267
11266
  pointerEvents: "none",
11268
11267
  testID: "datePickerInputAndroid"
11269
- }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
11268
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput, {
11270
11269
  label: label,
11271
11270
  value: displayValue,
11272
11271
  suffix: "calendar-dates-outlined",
@@ -11334,7 +11333,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
11334
11333
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
11335
11334
  pointerEvents: "none",
11336
11335
  testID: "datePickerInputIOS"
11337
- }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
11336
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput, {
11338
11337
  label: label,
11339
11338
  value: displayValue,
11340
11339
  suffix: "calendar-dates-outlined",
@@ -13379,7 +13378,7 @@ function MultiSelect(_ref) {
13379
13378
  }
13380
13379
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
13381
13380
  pointerEvents: "none"
13382
- }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, _extends$1({}, inputProps, {
13381
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput, _extends$1({}, inputProps, {
13383
13382
  label: label,
13384
13383
  value: displayedValue,
13385
13384
  suffix: "arrow-down",
@@ -13427,7 +13426,7 @@ function MultiSelect(_ref) {
13427
13426
  (_sectionListRef$curre = sectionListRef.current) === null || _sectionListRef$curre === void 0 ? void 0 : _sectionListRef$curre.scrollToLocation(scrollParams);
13428
13427
  }
13429
13428
  }
13430
- }, onQueryChange && /*#__PURE__*/React__default["default"].createElement(StyledSearchBar, null, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
13429
+ }, onQueryChange && /*#__PURE__*/React__default["default"].createElement(StyledSearchBar, null, /*#__PURE__*/React__default["default"].createElement(TextInput, {
13431
13430
  editable: true,
13432
13431
  placeholder: "Search",
13433
13432
  suffix: "search-outlined",
@@ -13555,7 +13554,7 @@ var SingleSelect = function SingleSelect(_ref) {
13555
13554
  }
13556
13555
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
13557
13556
  pointerEvents: "none"
13558
- }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, _extends$1({}, inputProps, {
13557
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput, _extends$1({}, inputProps, {
13559
13558
  label: label,
13560
13559
  value: displayedValue,
13561
13560
  suffix: "arrow-down",
@@ -13587,7 +13586,7 @@ var SingleSelect = function SingleSelect(_ref) {
13587
13586
  (_sectionListRef$curre = sectionListRef.current) === null || _sectionListRef$curre === void 0 ? void 0 : _sectionListRef$curre.scrollToLocation(scrollParams);
13588
13587
  }
13589
13588
  }
13590
- }, onQueryChange && /*#__PURE__*/React__default["default"].createElement(StyledSearchBar, null, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
13589
+ }, onQueryChange && /*#__PURE__*/React__default["default"].createElement(StyledSearchBar, null, /*#__PURE__*/React__default["default"].createElement(TextInput, {
13591
13590
  editable: true,
13592
13591
  placeholder: "Search",
13593
13592
  suffix: "search-outlined",
@@ -14328,7 +14327,7 @@ var TimePickerAndroid = function TimePickerAndroid(_ref) {
14328
14327
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
14329
14328
  pointerEvents: "none",
14330
14329
  testID: "timePickerInputAndroid"
14331
- }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
14330
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput, {
14332
14331
  label: label,
14333
14332
  value: displayValue,
14334
14333
  suffix: showSuffix ? 'clock-3' : undefined,
@@ -14396,7 +14395,7 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
14396
14395
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
14397
14396
  pointerEvents: "none",
14398
14397
  testID: "timePickerInputIOS"
14399
- }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
14398
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput, {
14400
14399
  label: label,
14401
14400
  value: displayValue,
14402
14401
  suffix: showSuffix ? 'clock-3' : undefined,
@@ -31275,7 +31274,7 @@ exports.Swipeable = index$5;
31275
31274
  exports.Switch = index$3;
31276
31275
  exports.Tabs = index$2;
31277
31276
  exports.Tag = Tag;
31278
- exports.TextInput = TextInput$1;
31277
+ exports.TextInput = TextInput;
31279
31278
  exports.ThemeProvider = ThemeProvider;
31280
31279
  exports.ThemeSwitcher = ThemeSwitcher;
31281
31280
  exports.TimePicker = TimePicker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.3.1",
3
+ "version": "8.3.2",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@emotion/native": "^11.9.3",
23
23
  "@emotion/react": "^11.9.3",
24
- "@hero-design/colors": "8.3.1",
24
+ "@hero-design/colors": "8.3.2",
25
25
  "date-fns": "^2.16.1",
26
26
  "events": "^3.2.0",
27
27
  "hero-editor": "^1.9.21"
@@ -44,7 +44,7 @@
44
44
  "@babel/preset-typescript": "^7.17.12",
45
45
  "@babel/runtime": "^7.18.9",
46
46
  "@emotion/jest": "^11.9.3",
47
- "@hero-design/eslint-plugin": "8.3.1",
47
+ "@hero-design/eslint-plugin": "8.3.2",
48
48
  "@react-native-community/datetimepicker": "^3.5.2",
49
49
  "@react-native-community/slider": "4.1.12",
50
50
  "@rollup/plugin-babel": "^5.3.1",
@@ -60,9 +60,9 @@
60
60
  "@types/react-native": "^0.67.7",
61
61
  "@types/react-native-vector-icons": "^6.4.10",
62
62
  "babel-plugin-inline-import": "^3.0.0",
63
- "eslint-config-hd": "8.3.1",
63
+ "eslint-config-hd": "8.3.2",
64
64
  "jest": "^27.3.1",
65
- "prettier-config-hd": "8.3.1",
65
+ "prettier-config-hd": "8.3.2",
66
66
  "react": "18.0.0",
67
67
  "react-native": "0.69.7",
68
68
  "react-native-gesture-handler": "~2.1.0",
@@ -1,4 +1,4 @@
1
- import React, { useMemo } from 'react';
1
+ import React, { useMemo, forwardRef } from 'react';
2
2
  import { StyleSheet, TextInput as RNTextInput } from 'react-native';
3
3
  import type {
4
4
  TextInputProps as NativeTextInputProps,
@@ -141,225 +141,227 @@ export const getVariant = ({
141
141
  // https://github.com/callstack/react-native-paper/pull/3331
142
142
  const EMPTY_PLACEHOLDER_VALUE = ' ';
143
143
 
144
- const TextInput = (
145
- {
146
- label,
147
- prefix,
148
- suffix,
149
- style,
150
- textStyle,
151
- testID,
152
- accessibilityLabelledBy,
153
- error,
154
- required,
155
- editable = true,
156
- disabled = false,
157
- loading = false,
158
- maxLength,
159
- helpText,
160
- value,
161
- defaultValue,
162
- renderInputValue,
163
- ...nativeProps
164
- }: TextInputProps,
165
- ref?: React.Ref<TextInputHandles>
166
- ) => {
167
- const displayText = (value !== undefined ? value : defaultValue) ?? '';
168
- const isEmptyValue = displayText.length === 0;
169
- const actualSuffix = loading ? 'loading' : suffix;
144
+ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
145
+ (
146
+ {
147
+ label,
148
+ prefix,
149
+ suffix,
150
+ style,
151
+ textStyle,
152
+ testID,
153
+ accessibilityLabelledBy,
154
+ error,
155
+ required,
156
+ editable = true,
157
+ disabled = false,
158
+ loading = false,
159
+ maxLength,
160
+ helpText,
161
+ value,
162
+ defaultValue,
163
+ renderInputValue,
164
+ ...nativeProps
165
+ }: TextInputProps,
166
+ ref?: React.Ref<TextInputHandles>
167
+ ) => {
168
+ const displayText = (value !== undefined ? value : defaultValue) ?? '';
169
+ const isEmptyValue = displayText.length === 0;
170
+ const actualSuffix = loading ? 'loading' : suffix;
170
171
 
171
- const [isFocused, setIsFocused] = React.useState(false);
172
+ const [isFocused, setIsFocused] = React.useState(false);
172
173
 
173
- const variant = getVariant({
174
- disabled,
175
- error,
176
- editable,
177
- loading,
178
- isFocused,
179
- isEmptyValue,
180
- });
174
+ const variant = getVariant({
175
+ disabled,
176
+ error,
177
+ editable,
178
+ loading,
179
+ isFocused,
180
+ isEmptyValue,
181
+ });
181
182
 
182
- const shouldShowMaxLength = maxLength !== undefined;
183
+ const shouldShowMaxLength = maxLength !== undefined;
183
184
 
184
- const theme = useTheme();
185
+ const theme = useTheme();
185
186
 
186
- const innerTextInput = React.useRef<RNTextInput | undefined | null>();
187
- React.useImperativeHandle(
188
- ref,
189
- () => ({
190
- // we don't expose this method, it's for testing https://medium.com/developer-rants/how-to-test-useref-without-mocking-useref-699165f4994e
191
- getNativeTextInputRef: () => innerTextInput.current,
192
- focus: () => {
193
- innerTextInput.current?.focus();
194
- },
195
- clear: () => innerTextInput.current?.clear(),
196
- setNativeProps: (args: NativeTextInputProps) =>
197
- innerTextInput.current?.setNativeProps(args),
198
- isFocused: () => innerTextInput.current?.isFocused() || false,
199
- blur: () => innerTextInput.current?.blur(),
200
- }),
201
- [innerTextInput]
202
- );
187
+ const innerTextInput = React.useRef<RNTextInput | undefined | null>();
188
+ React.useImperativeHandle(
189
+ ref,
190
+ () => ({
191
+ // we don't expose this method, it's for testing https://medium.com/developer-rants/how-to-test-useref-without-mocking-useref-699165f4994e
192
+ getNativeTextInputRef: () => innerTextInput.current,
193
+ focus: () => {
194
+ innerTextInput.current?.focus();
195
+ },
196
+ clear: () => innerTextInput.current?.clear(),
197
+ setNativeProps: (args: NativeTextInputProps) =>
198
+ innerTextInput.current?.setNativeProps(args),
199
+ isFocused: () => innerTextInput.current?.isFocused() || false,
200
+ blur: () => innerTextInput.current?.blur(),
201
+ }),
202
+ [innerTextInput]
203
+ );
203
204
 
204
- const { borderStyle, textStyleWithoutBorderStyle } = useMemo(() => {
205
- if (!textStyle) {
206
- return {};
207
- }
205
+ const { borderStyle, textStyleWithoutBorderStyle } = useMemo(() => {
206
+ if (!textStyle) {
207
+ return {};
208
+ }
208
209
 
209
- const flattenTextStyle = StyleSheet.flatten(textStyle);
210
- const borderKeys = Object.keys(flattenTextStyle).filter((key) => {
211
- return key.startsWith('border');
212
- }) as Array<keyof TextStyle>;
213
- return {
214
- borderStyle: pick(borderKeys, flattenTextStyle),
215
- textStyleWithoutBorderStyle: omit(borderKeys, flattenTextStyle),
216
- };
217
- }, [textStyle]);
210
+ const flattenTextStyle = StyleSheet.flatten(textStyle);
211
+ const borderKeys = Object.keys(flattenTextStyle).filter((key) => {
212
+ return key.startsWith('border');
213
+ }) as Array<keyof TextStyle>;
214
+ return {
215
+ borderStyle: pick(borderKeys, flattenTextStyle),
216
+ textStyleWithoutBorderStyle: omit(borderKeys, flattenTextStyle),
217
+ };
218
+ }, [textStyle]);
218
219
 
219
- const nativeInputProps: NativeTextInputProps = {
220
- style: StyleSheet.flatten([
221
- { color: theme.__hd__.textInput.colors.text },
222
- textStyleWithoutBorderStyle,
223
- ]),
224
- testID: 'text-input',
225
- accessibilityState: {
226
- disabled: variant === 'disabled' || variant === 'readonly',
227
- },
228
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
229
- // @ts-ignore
230
- accessibilityLabelledBy,
231
- ...nativeProps,
232
- onFocus: (event) => {
233
- setIsFocused(true);
234
- nativeProps.onFocus?.(event);
235
- },
236
- onBlur: (event) => {
237
- setIsFocused(false);
238
- nativeProps.onBlur?.(event);
239
- },
240
- editable,
241
- maxLength,
242
- value,
243
- onChangeText: (text) => {
244
- nativeProps.onChangeText?.(text);
245
- },
246
- defaultValue,
247
- placeholder:
248
- isFocused || label === undefined
249
- ? nativeProps.placeholder
250
- : EMPTY_PLACEHOLDER_VALUE,
251
- };
220
+ const nativeInputProps: NativeTextInputProps = {
221
+ style: StyleSheet.flatten([
222
+ { color: theme.__hd__.textInput.colors.text },
223
+ textStyleWithoutBorderStyle,
224
+ ]),
225
+ testID: 'text-input',
226
+ accessibilityState: {
227
+ disabled: variant === 'disabled' || variant === 'readonly',
228
+ },
229
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
230
+ // @ts-ignore
231
+ accessibilityLabelledBy,
232
+ ...nativeProps,
233
+ onFocus: (event) => {
234
+ setIsFocused(true);
235
+ nativeProps.onFocus?.(event);
236
+ },
237
+ onBlur: (event) => {
238
+ setIsFocused(false);
239
+ nativeProps.onBlur?.(event);
240
+ },
241
+ editable,
242
+ maxLength,
243
+ value,
244
+ onChangeText: (text) => {
245
+ nativeProps.onChangeText?.(text);
246
+ },
247
+ defaultValue,
248
+ placeholder:
249
+ isFocused || label === undefined
250
+ ? nativeProps.placeholder
251
+ : EMPTY_PLACEHOLDER_VALUE,
252
+ };
252
253
 
253
- return (
254
- <StyledContainer
255
- style={style}
256
- pointerEvents={
257
- variant === 'disabled' || variant === 'readonly' ? 'none' : 'auto'
258
- }
259
- testID={testID}
260
- >
261
- <StyledTextInputContainer>
262
- <StyledBorderBackDrop
263
- themeFocused={isFocused}
264
- themeVariant={variant}
265
- style={borderStyle}
266
- />
267
- {(isFocused || (label && !isEmptyValue)) && (
268
- <StyledLabelContainer pointerEvents="none">
269
- {required && (
270
- <StyledAsteriskLabel themeVariant={variant} fontSize="small">
271
- *
272
- </StyledAsteriskLabel>
273
- )}
274
- {!!label && (
275
- <StyledLabel
276
- nativeID={accessibilityLabelledBy}
277
- testID="input-label"
278
- fontSize="small"
279
- themeVariant={variant}
280
- >
281
- {label}
282
- </StyledLabel>
283
- )}
284
- </StyledLabelContainer>
285
- )}
286
- {typeof prefix === 'string' ? (
287
- <Icon
288
- intent={variant === 'disabled' ? 'disabled-text' : 'text'}
289
- testID="input-prefix"
290
- icon={prefix}
291
- size="xsmall"
254
+ return (
255
+ <StyledContainer
256
+ style={style}
257
+ pointerEvents={
258
+ variant === 'disabled' || variant === 'readonly' ? 'none' : 'auto'
259
+ }
260
+ testID={testID}
261
+ >
262
+ <StyledTextInputContainer>
263
+ <StyledBorderBackDrop
264
+ themeFocused={isFocused}
265
+ themeVariant={variant}
266
+ style={borderStyle}
292
267
  />
293
- ) : (
294
- prefix
295
- )}
296
- <StyledTextInputAndLabelContainer>
297
- {!isFocused && isEmptyValue && (
298
- <StyledLabelContainerInsideTextInput pointerEvents="none">
268
+ {(isFocused || (label && !isEmptyValue)) && (
269
+ <StyledLabelContainer pointerEvents="none">
299
270
  {required && (
300
- <StyledAsteriskLabelInsideTextInput themeVariant={variant}>
271
+ <StyledAsteriskLabel themeVariant={variant} fontSize="small">
301
272
  *
302
- </StyledAsteriskLabelInsideTextInput>
273
+ </StyledAsteriskLabel>
303
274
  )}
304
275
  {!!label && (
305
- <StyledLabelInsideTextInput
276
+ <StyledLabel
306
277
  nativeID={accessibilityLabelledBy}
307
278
  testID="input-label"
308
- fontSize="medium"
279
+ fontSize="small"
309
280
  themeVariant={variant}
310
281
  >
311
282
  {label}
312
- </StyledLabelInsideTextInput>
283
+ </StyledLabel>
313
284
  )}
314
- </StyledLabelContainerInsideTextInput>
285
+ </StyledLabelContainer>
315
286
  )}
316
- {renderInputValue ? (
317
- renderInputValue(nativeInputProps)
318
- ) : (
319
- <StyledTextInput
320
- {...nativeInputProps}
321
- ref={(reference) => {
322
- innerTextInput.current = reference;
323
- }}
287
+ {typeof prefix === 'string' ? (
288
+ <Icon
289
+ intent={variant === 'disabled' ? 'disabled-text' : 'text'}
290
+ testID="input-prefix"
291
+ icon={prefix}
292
+ size="xsmall"
324
293
  />
294
+ ) : (
295
+ prefix
325
296
  )}
326
- </StyledTextInputAndLabelContainer>
327
- {typeof actualSuffix === 'string' ? (
328
- <Icon
329
- intent={variant === 'disabled' ? 'disabled-text' : 'text'}
330
- testID="input-suffix"
331
- icon={actualSuffix}
332
- spin={actualSuffix === 'loading'}
333
- size="xsmall"
334
- />
335
- ) : (
336
- suffix
337
- )}
338
- </StyledTextInputContainer>
339
- <StyledErrorAndHelpTextContainer>
340
- <StyledErrorAndMaxLengthContainer>
341
- {!!error && (
342
- <StyledErrorContainer>
343
- <Icon
344
- testID="input-error-icon"
345
- icon="circle-info"
346
- size="xsmall"
347
- intent="danger"
297
+ <StyledTextInputAndLabelContainer>
298
+ {!isFocused && isEmptyValue && (
299
+ <StyledLabelContainerInsideTextInput pointerEvents="none">
300
+ {required && (
301
+ <StyledAsteriskLabelInsideTextInput themeVariant={variant}>
302
+ *
303
+ </StyledAsteriskLabelInsideTextInput>
304
+ )}
305
+ {!!label && (
306
+ <StyledLabelInsideTextInput
307
+ nativeID={accessibilityLabelledBy}
308
+ testID="input-label"
309
+ fontSize="medium"
310
+ themeVariant={variant}
311
+ >
312
+ {label}
313
+ </StyledLabelInsideTextInput>
314
+ )}
315
+ </StyledLabelContainerInsideTextInput>
316
+ )}
317
+ {renderInputValue ? (
318
+ renderInputValue(nativeInputProps)
319
+ ) : (
320
+ <StyledTextInput
321
+ {...nativeInputProps}
322
+ ref={(reference) => {
323
+ innerTextInput.current = reference;
324
+ }}
348
325
  />
349
-
350
- <StyledError testID="input-error-message">{error}</StyledError>
351
- </StyledErrorContainer>
352
- )}
353
- {shouldShowMaxLength && (
354
- <StyledMaxLengthMessage themeVariant={variant} fontSize="small">
355
- {displayText.length}/{maxLength}
356
- </StyledMaxLengthMessage>
326
+ )}
327
+ </StyledTextInputAndLabelContainer>
328
+ {typeof actualSuffix === 'string' ? (
329
+ <Icon
330
+ intent={variant === 'disabled' ? 'disabled-text' : 'text'}
331
+ testID="input-suffix"
332
+ icon={actualSuffix}
333
+ spin={actualSuffix === 'loading'}
334
+ size="xsmall"
335
+ />
336
+ ) : (
337
+ suffix
357
338
  )}
358
- </StyledErrorAndMaxLengthContainer>
359
- {!!helpText && <StyledHelperText>{helpText}</StyledHelperText>}
360
- </StyledErrorAndHelpTextContainer>
361
- </StyledContainer>
362
- );
363
- };
339
+ </StyledTextInputContainer>
340
+ <StyledErrorAndHelpTextContainer>
341
+ <StyledErrorAndMaxLengthContainer>
342
+ {!!error && (
343
+ <StyledErrorContainer>
344
+ <Icon
345
+ testID="input-error-icon"
346
+ icon="circle-info"
347
+ size="xsmall"
348
+ intent="danger"
349
+ />
350
+
351
+ <StyledError testID="input-error-message">{error}</StyledError>
352
+ </StyledErrorContainer>
353
+ )}
354
+ {shouldShowMaxLength && (
355
+ <StyledMaxLengthMessage themeVariant={variant} fontSize="small">
356
+ {displayText.length}/{maxLength}
357
+ </StyledMaxLengthMessage>
358
+ )}
359
+ </StyledErrorAndMaxLengthContainer>
360
+ {!!helpText && <StyledHelperText>{helpText}</StyledHelperText>}
361
+ </StyledErrorAndHelpTextContainer>
362
+ </StyledContainer>
363
+ );
364
+ }
365
+ );
364
366
 
365
- export default React.forwardRef<TextInputHandles, TextInputProps>(TextInput);
367
+ export default TextInput;
@@ -83,5 +83,5 @@ export declare const getVariant: ({ disabled, error, editable, loading, isEmptyV
83
83
  isFocused?: boolean | undefined;
84
84
  isEmptyValue?: boolean | undefined;
85
85
  }) => Variant;
86
- declare const _default: React.ForwardRefExoticComponent<Pick<TextInputProps, "children" | "label" | "style" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "disabled" | "value" | "onBlur" | "onFocus" | "onPressIn" | "onPressOut" | "allowFontScaling" | "numberOfLines" | "maxFontSizeMultiplier" | "selectionColor" | "textBreakStrategy" | "loading" | "textAlign" | "error" | "textAlignVertical" | "onContentSizeChange" | "onScroll" | "scrollEnabled" | "onChange" | "autoCapitalize" | "autoCorrect" | "autoFocus" | "blurOnSubmit" | "caretHidden" | "contextMenuHidden" | "defaultValue" | "editable" | "keyboardType" | "maxLength" | "multiline" | "onChangeText" | "onEndEditing" | "onSelectionChange" | "onSubmitEditing" | "onTextInput" | "onKeyPress" | "placeholder" | "placeholderTextColor" | "returnKeyType" | "secureTextEntry" | "selectTextOnFocus" | "selection" | "inputAccessoryViewID" | "clearButtonMode" | "clearTextOnFocus" | "dataDetectorTypes" | "enablesReturnKeyAutomatically" | "keyboardAppearance" | "passwordRules" | "rejectResponderTermination" | "selectionState" | "spellCheck" | "textContentType" | "autoComplete" | "importantForAutofill" | "disableFullscreenUI" | "inlineImageLeft" | "inlineImagePadding" | "returnKeyLabel" | "underlineColorAndroid" | "showSoftInputOnFocus" | "prefix" | "suffix" | "textStyle" | "accessibilityLabelledBy" | "required" | "helpText" | "renderInputValue"> & React.RefAttributes<TextInputHandles>>;
87
- export default _default;
86
+ declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputProps, "children" | "label" | "style" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "disabled" | "value" | "onBlur" | "onFocus" | "onPressIn" | "onPressOut" | "allowFontScaling" | "numberOfLines" | "maxFontSizeMultiplier" | "selectionColor" | "textBreakStrategy" | "loading" | "textAlign" | "error" | "textAlignVertical" | "onContentSizeChange" | "onScroll" | "scrollEnabled" | "onChange" | "autoCapitalize" | "autoCorrect" | "autoFocus" | "blurOnSubmit" | "caretHidden" | "contextMenuHidden" | "defaultValue" | "editable" | "keyboardType" | "maxLength" | "multiline" | "onChangeText" | "onEndEditing" | "onSelectionChange" | "onSubmitEditing" | "onTextInput" | "onKeyPress" | "placeholder" | "placeholderTextColor" | "returnKeyType" | "secureTextEntry" | "selectTextOnFocus" | "selection" | "inputAccessoryViewID" | "clearButtonMode" | "clearTextOnFocus" | "dataDetectorTypes" | "enablesReturnKeyAutomatically" | "keyboardAppearance" | "passwordRules" | "rejectResponderTermination" | "selectionState" | "spellCheck" | "textContentType" | "autoComplete" | "importantForAutofill" | "disableFullscreenUI" | "inlineImageLeft" | "inlineImagePadding" | "returnKeyLabel" | "underlineColorAndroid" | "showSoftInputOnFocus" | "prefix" | "suffix" | "textStyle" | "accessibilityLabelledBy" | "required" | "helpText" | "renderInputValue"> & React.RefAttributes<TextInputHandles>>;
87
+ export default TextInput;