@hero-design/rn 8.64.8 → 8.65.0-alpha.0

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/es/index.js +17548 -17421
  3. package/lib/index.js +18085 -17961
  4. package/package.json +12 -13
  5. package/{rollup.config.js → rollup.config.mjs} +5 -3
  6. package/src/components/BottomNavigation/index.tsx +0 -4
  7. package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +30 -5
  8. package/src/components/PinInput/__tests__/index.spec.tsx +23 -11
  9. package/src/components/PinInput/index.tsx +26 -9
  10. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +1 -1
  11. package/src/theme/components/pinInput.ts +1 -1
  12. package/stats/8.64.8/rn-stats.html +2 -0
  13. package/stats/8.65.0/rn-stats.html +4842 -0
  14. package/tsconfig.json +2 -3
  15. package/tsconfig.rollup.json +27 -0
  16. package/types/components/Accordion/StyledAccordion.d.ts +5 -5
  17. package/types/components/Alert/StyledAlert.d.ts +5 -5
  18. package/types/components/Attachment/StyledAttachment.d.ts +4 -4
  19. package/types/components/Avatar/AvatarStack/StyledAvatarStack.d.ts +3 -3
  20. package/types/components/Avatar/StyledAvatar.d.ts +4 -4
  21. package/types/components/Badge/StyledBadge.d.ts +3 -3
  22. package/types/components/Badge/types.d.ts +53 -0
  23. package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +7 -7
  24. package/types/components/BottomSheet/StyledBottomSheet.d.ts +8 -8
  25. package/types/components/Box/StyledBox.d.ts +1 -1
  26. package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +2 -3
  27. package/types/components/Button/StyledButton.d.ts +5 -6
  28. package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +3 -3
  29. package/types/components/Calendar/StyledCalendar.d.ts +8 -8
  30. package/types/components/Card/DataCard/StyledDataCard.d.ts +2 -2
  31. package/types/components/Card/StyledCard.d.ts +1 -1
  32. package/types/components/Carousel/StyledCardCarousel.d.ts +4 -4
  33. package/types/components/Carousel/StyledCarousel.d.ts +9 -9
  34. package/types/components/Checkbox/StyledCheckbox.d.ts +5 -5
  35. package/types/components/Chip/StyledChip.d.ts +4 -4
  36. package/types/components/Collapse/StyledCollapse.d.ts +3 -3
  37. package/types/components/CompoundSearch/CompoundSearchHandler.d.ts +31 -0
  38. package/types/components/CompoundSearch/CompoundSearchTextInput.d.ts +60 -0
  39. package/types/components/CompoundSearch/StyledCompoundSearch.d.ts +40 -0
  40. package/types/components/CompoundSearch/index.d.ts +8 -0
  41. package/types/components/CompoundSearch/utils.d.ts +8 -0
  42. package/types/components/ContentNavigator/StyledContentNavigator.d.ts +1 -1
  43. package/types/components/DatePicker/StyledDatePicker.d.ts +1 -1
  44. package/types/components/Divider/StyledDivider.d.ts +1 -1
  45. package/types/components/Drawer/StyledDrawer.d.ts +7 -7
  46. package/types/components/Empty/StyledEmpty.d.ts +3 -3
  47. package/types/components/Error/StyledError.d.ts +10 -10
  48. package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +5 -5
  49. package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +3 -3
  50. package/types/components/FAB/Pair/StyledFAB.d.ts +12 -0
  51. package/types/components/FAB/Pair/index.d.ts +16 -0
  52. package/types/components/FAB/StyledFAB.d.ts +4 -4
  53. package/types/components/Icon/HeroIcon/index.d.ts +1 -1
  54. package/types/components/List/StyledBasicListItem.d.ts +4 -4
  55. package/types/components/List/StyledListItem.d.ts +7 -7
  56. package/types/components/MapPin/Focussed.d.ts +13 -0
  57. package/types/components/MapPin/StyledMapPin.d.ts +32 -0
  58. package/types/components/MapPin/index.d.ts +5 -0
  59. package/types/components/MapPin/types.d.ts +38 -0
  60. package/types/components/PageControl/StyledPageControl.d.ts +2 -2
  61. package/types/components/PinInput/StyledPinInput.d.ts +10 -10
  62. package/types/components/Progress/ProgressStep.d.ts +20 -0
  63. package/types/components/Progress/StyledProgressBar.d.ts +2 -2
  64. package/types/components/Progress/StyledProgressCircle.d.ts +6 -6
  65. package/types/components/Progress/StyledStep.d.ts +23 -0
  66. package/types/components/Radio/StyledRadio.d.ts +4 -4
  67. package/types/components/Rate/StyledRate.d.ts +2 -2
  68. package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +2 -2
  69. package/types/components/RichTextEditor/StyledToolbar.d.ts +3 -3
  70. package/types/components/Search/SearchOneLine.d.ts +65 -0
  71. package/types/components/Search/SearchSuffixIcon.d.ts +24 -0
  72. package/types/components/Search/SearchTwoLine.d.ts +36 -0
  73. package/types/components/Search/StyledSearch.d.ts +49 -0
  74. package/types/components/Search/index.d.ts +10 -0
  75. package/types/components/Search/utils.d.ts +8 -0
  76. package/types/components/SectionHeading/StyledHeading.d.ts +3 -3
  77. package/types/components/Select/StyledSelect.d.ts +3 -3
  78. package/types/components/Skeleton/StyledSkeleton.d.ts +2 -2
  79. package/types/components/Spinner/StyledSpinner.d.ts +4 -4
  80. package/types/components/Success/StyledSuccess.d.ts +9 -9
  81. package/types/components/Swipeable/StyledSwipeable.d.ts +1 -1
  82. package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +4 -4
  83. package/types/components/Switch/StyledSwitch.d.ts +2 -2
  84. package/types/components/Tabs/StyledScrollableTabs.d.ts +8 -8
  85. package/types/components/Tabs/StyledTabs.d.ts +7 -7
  86. package/types/components/Tag/StyledTag.d.ts +2 -2
  87. package/types/components/TextInput/StyledTextInput.d.ts +13 -13
  88. package/types/components/TimePicker/StyledTimePicker.d.ts +1 -1
  89. package/types/components/Toast/StyledToast.d.ts +6 -6
  90. package/types/components/Toolbar/StyledToolbar.d.ts +5 -5
  91. package/types/components/Typography/Body/StyledBody.d.ts +1 -1
  92. package/types/components/Typography/Caption/StyledCaption.d.ts +1 -1
  93. package/types/components/Typography/Label/StyledLabel.d.ts +1 -1
  94. package/types/components/Typography/Text/StyledText.d.ts +1 -1
  95. package/types/components/Typography/Title/StyledTitle.d.ts +1 -1
  96. package/types/theme/components/compoundSearch.d.ts +36 -0
  97. package/types/theme/components/mapPin.d.ts +40 -0
  98. package/types/theme/components/search.d.ts +64 -0
  99. package/types/theme/global/colors/swagLight.d.ts +3 -0
  100. package/types/theme/global/colors/swagLightGlobal.d.ts +3 -0
  101. package/types/theme/global/colors/swagLightJobs.d.ts +47 -0
  102. package/.turbo/turbo-build.log +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.64.8",
3
+ "version": "8.65.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -32,7 +32,7 @@
32
32
  "@react-native-community/datetimepicker": "^3.5.2 || ^7.6.1",
33
33
  "@react-native-community/slider": "^4.5.1",
34
34
  "react": "18.2.0",
35
- "react-native": "^0.73.8",
35
+ "react-native": "^0.74.5",
36
36
  "react-native-gesture-handler": "^2.15.0",
37
37
  "react-native-linear-gradient": "^2.8.3",
38
38
  "react-native-pager-view": "^6.2.1",
@@ -41,7 +41,7 @@
41
41
  "react-native-webview": "^13.10.2"
42
42
  },
43
43
  "devDependencies": {
44
- "@babel/core": "^7.20.0",
44
+ "@babel/core": "^7.24.0",
45
45
  "@babel/preset-env": "^7.20.0",
46
46
  "@babel/preset-react": "^7.20.0",
47
47
  "@babel/preset-typescript": "^7.20.0",
@@ -54,12 +54,12 @@
54
54
  "@hero-design/react-native-month-year-picker": "^8.42.10",
55
55
  "@react-native-community/datetimepicker": "7.6.1",
56
56
  "@react-native-community/slider": "^4.5.1",
57
- "@rollup/plugin-babel": "^5.3.1",
58
- "@rollup/plugin-commonjs": "^21.0.1",
59
- "@rollup/plugin-json": "^4.1.0",
60
- "@rollup/plugin-node-resolve": "^13.1.3",
61
- "@rollup/plugin-replace": "^4.0.0",
62
- "@rollup/plugin-typescript": "^8.3.0",
57
+ "@rollup/plugin-babel": "^6.0.4",
58
+ "@rollup/plugin-commonjs": "^28.0.1",
59
+ "@rollup/plugin-json": "^6.1.0",
60
+ "@rollup/plugin-node-resolve": "^15.3.0",
61
+ "@rollup/plugin-replace": "^6.0.1",
62
+ "@rollup/plugin-typescript": "^12.1.1",
63
63
  "@testing-library/jest-native": "^5.4.2",
64
64
  "@testing-library/react-native": "^9.1.0",
65
65
  "@types/events": "^3.0.3",
@@ -67,7 +67,7 @@
67
67
  "@types/react": "^18.2.0",
68
68
  "@types/react-native-vector-icons": "^6.4.10",
69
69
  "babel-plugin-inline-import": "^3.0.0",
70
- "babel-preset-expo": "9.5.2",
70
+ "babel-preset-expo": "^11.0.15",
71
71
  "core-js": "^3.33.0",
72
72
  "eslint": "^8.56.0",
73
73
  "eslint-config-hd": "8.42.4",
@@ -78,7 +78,6 @@
78
78
  "prettier-config-hd": "8.42.4",
79
79
  "react": "18.2.0",
80
80
  "react-dom": "^18.2.0",
81
- "react-native": "0.73.8",
82
81
  "react-native-gesture-handler": "^2.15.0",
83
82
  "react-native-linear-gradient": "2.8.3",
84
83
  "react-native-pager-view": "^6.2.1",
@@ -86,8 +85,8 @@
86
85
  "react-native-vector-icons": "^9.1.0",
87
86
  "react-native-webview": "13.10.3",
88
87
  "react-test-renderer": "18.2.0",
89
- "rollup": "^2.70.1",
90
- "rollup-plugin-copy": "^3.4.0",
88
+ "rollup": "^4.24.3",
89
+ "rollup-plugin-copy": "^3.5.0",
91
90
  "rollup-plugin-flow": "^1.1.1",
92
91
  "rollup-plugin-visualizer": "^5.12.0",
93
92
  "ts-jest": "^29.1.1",
@@ -8,7 +8,7 @@ import copy from 'rollup-plugin-copy';
8
8
  import flow from 'rollup-plugin-flow';
9
9
  import { visualizer } from 'rollup-plugin-visualizer';
10
10
 
11
- import pkg from './package.json';
11
+ import pkg from './package.json' assert { type: 'json' };
12
12
 
13
13
  const extensions = ['.js', '.jsx', '.ts', '.tsx'];
14
14
 
@@ -22,10 +22,12 @@ export default {
22
22
  {
23
23
  file: pkg.main,
24
24
  format: 'cjs',
25
+ interop: 'compat',
25
26
  },
26
27
  {
27
28
  file: pkg.module,
28
- format: 'esm',
29
+ format: 'es',
30
+ interop: 'compat',
29
31
  },
30
32
  ],
31
33
  external: [
@@ -49,7 +51,7 @@ export default {
49
51
  flow(),
50
52
  commonjs(),
51
53
  json(),
52
- typescript(),
54
+ typescript({ tsconfig: './tsconfig.rollup.json' }),
53
55
  babel({ extensions, babelHelpers: 'bundled' }),
54
56
  copy({
55
57
  targets: [
@@ -16,7 +16,6 @@ import {
16
16
  } from './StyledBottomNavigation';
17
17
  import { isIOS } from '../../utils/helpers';
18
18
  import type { IconName } from '../Icon';
19
- import { useDeprecation } from '../../utils/hooks';
20
19
 
21
20
  export type BottomNavigationTabType = {
22
21
  key: string;
@@ -72,9 +71,6 @@ const BottomNavigation = ({
72
71
  tabs,
73
72
  ...nativeProps
74
73
  }: BottomNavigationProps): JSX.Element => {
75
- useDeprecation(
76
- 'BottomNavigation is deprecated and will be removed in the next major release. Please remove it.'
77
- );
78
74
  const insets = useSafeAreaInsets();
79
75
 
80
76
  /**
@@ -211,13 +211,18 @@ exports[`rendering renders correctly 1`] = `
211
211
  pointerEvents="box-none"
212
212
  secureTextEntry={true}
213
213
  selectTextOnFocus={false}
214
+ selection={
215
+ {
216
+ "start": 2,
217
+ }
218
+ }
214
219
  style={
215
220
  [
216
221
  {
217
222
  "fontSize": 42,
218
223
  "height": "100%",
219
224
  "left": 0,
220
- "letterSpacing": 32,
225
+ "letterSpacing": 4,
221
226
  "opacity": 0,
222
227
  "paddingHorizontal": 8,
223
228
  "position": "absolute",
@@ -467,13 +472,18 @@ exports[`rendering renders correctly when disabled 1`] = `
467
472
  pointerEvents="box-none"
468
473
  secureTextEntry={true}
469
474
  selectTextOnFocus={false}
475
+ selection={
476
+ {
477
+ "start": 2,
478
+ }
479
+ }
470
480
  style={
471
481
  [
472
482
  {
473
483
  "fontSize": 42,
474
484
  "height": "100%",
475
485
  "left": 0,
476
- "letterSpacing": 32,
486
+ "letterSpacing": 4,
477
487
  "opacity": 0,
478
488
  "paddingHorizontal": 8,
479
489
  "position": "absolute",
@@ -841,13 +851,18 @@ exports[`rendering renders correctly when length is 6 and secure is false 1`] =
841
851
  pointerEvents="box-none"
842
852
  secureTextEntry={false}
843
853
  selectTextOnFocus={false}
854
+ selection={
855
+ {
856
+ "start": 3,
857
+ }
858
+ }
844
859
  style={
845
860
  [
846
861
  {
847
862
  "fontSize": 42,
848
863
  "height": "100%",
849
864
  "left": 0,
850
- "letterSpacing": 32,
865
+ "letterSpacing": 4,
851
866
  "opacity": 0,
852
867
  "paddingHorizontal": 8,
853
868
  "position": "absolute",
@@ -1150,13 +1165,18 @@ exports[`rendering renders correctly when there is error 1`] = `
1150
1165
  pointerEvents="box-none"
1151
1166
  secureTextEntry={true}
1152
1167
  selectTextOnFocus={false}
1168
+ selection={
1169
+ {
1170
+ "start": 2,
1171
+ }
1172
+ }
1153
1173
  style={
1154
1174
  [
1155
1175
  {
1156
1176
  "fontSize": 42,
1157
1177
  "height": "100%",
1158
1178
  "left": 0,
1159
- "letterSpacing": 32,
1179
+ "letterSpacing": 4,
1160
1180
  "opacity": 0,
1161
1181
  "paddingHorizontal": 8,
1162
1182
  "position": "absolute",
@@ -1407,13 +1427,18 @@ exports[`rendering renders correctly with textContentType and autoComplete 1`] =
1407
1427
  pointerEvents="box-none"
1408
1428
  secureTextEntry={true}
1409
1429
  selectTextOnFocus={false}
1430
+ selection={
1431
+ {
1432
+ "start": 2,
1433
+ }
1434
+ }
1410
1435
  style={
1411
1436
  [
1412
1437
  {
1413
1438
  "fontSize": 42,
1414
1439
  "height": "100%",
1415
1440
  "left": 0,
1416
- "letterSpacing": 32,
1441
+ "letterSpacing": 4,
1417
1442
  "opacity": 0,
1418
1443
  "paddingHorizontal": 8,
1419
1444
  "position": "absolute",
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { fireEvent } from '@testing-library/react-native';
3
- import { Platform } from 'react-native';
4
3
  import renderWithTheme from '../../../testHelpers/renderWithTheme';
5
4
  import PinInput, { getState, normalizeValue } from '..';
6
5
 
@@ -68,16 +67,6 @@ describe('rendering', () => {
68
67
 
69
68
  expect(wrapper.toJSON()).toMatchSnapshot();
70
69
  });
71
-
72
- it('renders a placeholder if the value is empty on android', () => {
73
- Platform.OS = 'android';
74
-
75
- const wrapper = renderWithTheme(
76
- <PinInput value="" onChangeText={jest.fn()} />
77
- );
78
-
79
- expect(wrapper.getByDisplayValue('*')).toBeTruthy();
80
- });
81
70
  });
82
71
 
83
72
  describe('behaviors', () => {
@@ -150,6 +139,29 @@ describe('behaviors', () => {
150
139
  }
151
140
  }
152
141
  );
142
+
143
+ it('slice text when the text is already at the length', () => {
144
+ const onFulfill = jest.fn();
145
+ const SamplePinInput = () => {
146
+ const [pin, setPin] = React.useState('1234');
147
+
148
+ return (
149
+ <PinInput value={pin} onChangeText={setPin} onFulfill={onFulfill} />
150
+ );
151
+ };
152
+ const { getByTestId, getByDisplayValue, queryByDisplayValue } =
153
+ renderWithTheme(<SamplePinInput />);
154
+
155
+ // Fill with full length
156
+ const pinInput = getByTestId('pin-hidden-input');
157
+ fireEvent.changeText(pinInput, '12349');
158
+ expect(getByDisplayValue('9')).toBeTruthy();
159
+
160
+ // Add more text
161
+ fireEvent.changeText(pinInput, '581');
162
+ expect(queryByDisplayValue('4567')).toBeNull();
163
+ expect(getByDisplayValue('581')).toBeTruthy();
164
+ });
153
165
  });
154
166
 
155
167
  describe('getState', () => {
@@ -4,10 +4,11 @@ import React, {
4
4
  useCallback,
5
5
  useEffect,
6
6
  useImperativeHandle,
7
+ useMemo,
7
8
  useRef,
8
9
  useState,
9
10
  } from 'react';
10
- import { InteractionManager, Platform, TextInput } from 'react-native';
11
+ import { InteractionManager, TextInput } from 'react-native';
11
12
  import type { StyleProp, ViewStyle } from 'react-native';
12
13
  import Icon from '../Icon';
13
14
  import PinCell from './PinCell';
@@ -127,9 +128,6 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
127
128
  const state = getState({ disabled, error });
128
129
  const trimmedValue = normalizeValue(value, length);
129
130
 
130
- const maskedValueWithExtraSpace =
131
- Platform.OS === 'android' && !trimmedValue ? '*' : trimmedValue;
132
-
133
131
  const focus = useCallback(() => {
134
132
  if (inputRef?.current) {
135
133
  inputRef.current.focus();
@@ -143,19 +141,30 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
143
141
  setFocused(false);
144
142
  }
145
143
  }, []);
146
-
147
144
  const changeText = useCallback(
148
145
  (text: string) => {
149
- // Prevent user from entering more than the length
150
146
  const trimmedPin = normalizeValue(text, length);
151
147
 
152
- onChangeText?.(trimmedPin);
148
+ // If current value is already the length, and user is not deleting,
149
+ // replace it with the new text, starting from the length
150
+ if (
151
+ trimmedValue.length === length &&
152
+ trimmedValue.length <= text.length
153
+ ) {
154
+ // Slice the text, starting from the length position
155
+ const slicedText = text.slice(length);
156
+
157
+ onChangeText?.(normalizeValue(slicedText, length));
158
+ } else {
159
+ // Prevent user from entering more than the length
160
+ onChangeText?.(trimmedPin);
161
+ }
153
162
 
154
163
  if (trimmedPin.length === length) {
155
164
  onFulfill?.(trimmedPin);
156
165
  }
157
166
  },
158
- [length, onChangeText, onFulfill]
167
+ [length, onChangeText, onFulfill, trimmedValue.length]
159
168
  );
160
169
 
161
170
  useEffect(() => {
@@ -170,6 +179,13 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
170
179
  blur,
171
180
  }));
172
181
 
182
+ const selection = useMemo(
183
+ () => ({
184
+ start: trimmedValue.length,
185
+ }),
186
+ [trimmedValue]
187
+ );
188
+
173
189
  return (
174
190
  <StyledWrapper style={style} testID={testID}>
175
191
  <StyledPinWrapper>
@@ -199,7 +215,7 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
199
215
  <StyledHiddenInput
200
216
  themePinLength={length}
201
217
  ref={inputRef}
202
- value={maskedValueWithExtraSpace}
218
+ value={trimmedValue}
203
219
  onChangeText={changeText}
204
220
  secureTextEntry={secure}
205
221
  editable={!disabled}
@@ -212,6 +228,7 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
212
228
  textContentType={textContentType}
213
229
  autoComplete={autoComplete}
214
230
  selectTextOnFocus={false}
231
+ selection={selection}
215
232
  />
216
233
  </StyledWrapper>
217
234
  );
@@ -667,7 +667,7 @@ exports[`theme returns correct theme object 1`] = `
667
667
  "space": {
668
668
  "errorMessagePadding": 4,
669
669
  "hiddenInputHorrizontalPadding": 8,
670
- "hiddenInputText": 32,
670
+ "hiddenInputText": 4,
671
671
  "spacer": 16,
672
672
  },
673
673
  },
@@ -37,7 +37,7 @@ const getPinInputTheme = (theme: GlobalTheme) => {
37
37
  const space = {
38
38
  spacer: theme.space.medium,
39
39
  errorMessagePadding: theme.space.xsmall,
40
- hiddenInputText: theme.space.xlarge,
40
+ hiddenInputText: theme.space.xsmall,
41
41
  hiddenInputHorrizontalPadding: theme.space.small,
42
42
  };
43
43
 
@@ -4840,3 +4840,5 @@ var drawChart = (function (exports) {
4840
4840
  </body>
4841
4841
  </html>
4842
4842
 
4843
+ >
4844
+