@hero-design/rn 8.103.2 → 8.103.4

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 (68) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +15 -0
  3. package/es/index.js +144 -106
  4. package/eslint.config.js +1 -0
  5. package/lib/index.js +144 -106
  6. package/package.json +3 -3
  7. package/src/components/DatePicker/DatePicker.tsx +38 -0
  8. package/src/components/DatePicker/DatePickerAndroid.tsx +6 -3
  9. package/src/components/DatePicker/DatePickerCalendar.tsx +6 -3
  10. package/src/components/DatePicker/DatePickerIOS.tsx +6 -3
  11. package/src/components/DatePicker/Dialog/IOSDialog.tsx +6 -1
  12. package/src/components/DatePicker/Dialog.tsx +15 -0
  13. package/src/components/DatePicker/StyledDatePicker.tsx +1 -0
  14. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +2 -0
  15. package/src/components/DatePicker/index.internal.tsx +10 -0
  16. package/src/components/DatePicker/index.tsx +6 -29
  17. package/src/components/DatePicker/types.ts +6 -0
  18. package/src/components/PinInput/PinCell.tsx +6 -1
  19. package/src/components/PinInput/StyledPinInput.tsx +2 -2
  20. package/src/components/PinInput/__tests__/__snapshots__/PinCell.spec.tsx.snap +30 -0
  21. package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +287 -5
  22. package/src/components/PinInput/__tests__/index.spec.tsx +33 -0
  23. package/src/components/PinInput/index.tsx +6 -2
  24. package/src/components/Select/MultiSelect/index.tsx +15 -4
  25. package/src/components/Select/SingleSelect/index.tsx +15 -4
  26. package/src/components/Select/index.internal.tsx +13 -0
  27. package/src/components/Select/index.tsx +14 -2
  28. package/src/components/Select/types.ts +4 -0
  29. package/src/components/TimePicker/StyledTimePicker.tsx +1 -0
  30. package/src/components/TimePicker/TimePicker.tsx +15 -0
  31. package/src/components/TimePicker/TimePickerAndroid.tsx +6 -3
  32. package/src/components/TimePicker/TimePickerIOS.tsx +6 -3
  33. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +1 -0
  34. package/src/components/TimePicker/index.internal.tsx +9 -0
  35. package/src/components/TimePicker/index.tsx +4 -13
  36. package/src/components/TimePicker/types.ts +6 -0
  37. package/src/index.internal.ts +7 -0
  38. package/src/types.internal.ts +16 -0
  39. package/src/types.ts +4 -0
  40. package/stats/8.103.2/rn-stats.html +3 -1
  41. package/stats/8.103.3/rn-stats.html +4842 -0
  42. package/stats/8.103.4/rn-stats.html +4844 -0
  43. package/types/components/Calendar/CalendarRowItem.d.ts +1 -1
  44. package/types/components/Checkbox/index.d.ts +1 -1
  45. package/types/components/DatePicker/DatePicker.d.ts +4 -0
  46. package/types/components/DatePicker/DatePickerAndroid.d.ts +3 -3
  47. package/types/components/DatePicker/DatePickerCalendar.d.ts +2 -2
  48. package/types/components/DatePicker/DatePickerIOS.d.ts +3 -3
  49. package/types/components/DatePicker/Dialog.d.ts +4 -0
  50. package/types/components/DatePicker/index.d.ts +4 -5
  51. package/types/components/DatePicker/index.internal.d.ts +7 -0
  52. package/types/components/DatePicker/types.d.ts +4 -0
  53. package/types/components/PinInput/StyledPinInput.d.ts +2 -4
  54. package/types/components/Select/MultiSelect/index.d.ts +5 -1
  55. package/types/components/Select/SingleSelect/index.d.ts +5 -1
  56. package/types/components/Select/index.d.ts +5 -3
  57. package/types/components/Select/index.internal.d.ts +8 -0
  58. package/types/components/Select/types.d.ts +4 -0
  59. package/types/components/TextInput/index.d.ts +1 -1
  60. package/types/components/TimePicker/TimePicker.d.ts +4 -0
  61. package/types/components/TimePicker/TimePickerAndroid.d.ts +2 -2
  62. package/types/components/TimePicker/TimePickerIOS.d.ts +2 -2
  63. package/types/components/TimePicker/index.d.ts +3 -3
  64. package/types/components/TimePicker/index.internal.d.ts +5 -0
  65. package/types/components/TimePicker/types.d.ts +4 -0
  66. package/types/index.internal.d.ts +6 -0
  67. package/types/types.d.ts +3 -1
  68. package/types/types.internal.d.ts +5 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.103.2",
3
+ "version": "8.103.4",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -92,10 +92,10 @@
92
92
  "eslint-config-hd": "8.42.5",
93
93
  "eslint-config-prettier": "^8.5.0",
94
94
  "eslint-import-resolver-typescript": "^3.5.2",
95
- "eslint-plugin-import": "^2.26.0",
95
+ "eslint-plugin-import": "^2.32.0",
96
96
  "eslint-plugin-jsx-a11y": "^6.5.1",
97
97
  "eslint-plugin-prettier": "^4.0.0",
98
- "eslint-plugin-react": "^7.37.3",
98
+ "eslint-plugin-react": "^7.37.5",
99
99
  "eslint-plugin-react-hooks": "^4.3.0",
100
100
  "jest": "^29.2.1",
101
101
  "jest-environment-jsdom": "^29.2.1",
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { Platform } from 'react-native';
3
+ import DatePickerAndroid from './DatePickerAndroid';
4
+ import DatePickerCalendar from './DatePickerCalendar';
5
+ import DatePickerIOS from './DatePickerIOS';
6
+ import type { InternalDatePickerProps } from './types';
7
+ import TextInput from '../TextInput';
8
+
9
+ const DatePicker = ({
10
+ variant = 'default',
11
+ TextInputComponent = TextInput,
12
+ ...props
13
+ }: InternalDatePickerProps) => {
14
+ if (variant === 'calendar') {
15
+ return (
16
+ <DatePickerCalendar {...props} TextInputComponent={TextInputComponent} />
17
+ );
18
+ }
19
+ if (Platform.OS === 'ios') {
20
+ return (
21
+ <DatePickerIOS
22
+ {...props}
23
+ variant={variant}
24
+ TextInputComponent={TextInputComponent}
25
+ />
26
+ );
27
+ }
28
+
29
+ return (
30
+ <DatePickerAndroid
31
+ {...props}
32
+ variant={variant}
33
+ TextInputComponent={TextInputComponent}
34
+ />
35
+ );
36
+ };
37
+
38
+ export default DatePicker;
@@ -5,10 +5,10 @@ import TextInput from '../TextInput';
5
5
  import AndroidDatePickerDialog from './Dialog/AndroidDialog';
6
6
  import useCalculateDate from './hooks/useCalculateDate';
7
7
  import useFormatDate from './hooks/useFormatDate';
8
- import type { DatePickerProps } from './types';
8
+ import type { InternalDatePickerProps } from './types';
9
9
 
10
10
  type DatePickerAndroidProps = Omit<
11
- DatePickerProps,
11
+ InternalDatePickerProps,
12
12
  'variant' | 'monthPickerConfirmLabel' | 'monthPickerCancelLabel'
13
13
  > & {
14
14
  variant?: 'default' | 'month-year';
@@ -30,6 +30,7 @@ const DatePickerAndroid = ({
30
30
  variant = 'default',
31
31
  renderSelectedValue,
32
32
  locale,
33
+ TextInputComponent,
33
34
  }: DatePickerAndroidProps) => {
34
35
  const [open, setOpen] = useState(false);
35
36
 
@@ -41,10 +42,12 @@ const DatePickerAndroid = ({
41
42
 
42
43
  useCalculateDate({ minDate, maxDate, onChange, value });
43
44
 
45
+ const InputComponent = TextInputComponent || TextInput;
46
+
44
47
  return (
45
48
  <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
46
49
  <View pointerEvents="none" testID="datePickerInputAndroid">
47
- <TextInput
50
+ <InputComponent
48
51
  label={label}
49
52
  value={displayValue}
50
53
  suffix="calendar-dates-outlined"
@@ -7,7 +7,7 @@ import Calendar, { CalendarProps } from '../Calendar';
7
7
  import TextInput from '../TextInput';
8
8
  import useCalculateDate from './hooks/useCalculateDate';
9
9
  import useFormatDate from './hooks/useFormatDate';
10
- import type { DatePickerProps } from './types';
10
+ import type { InternalDatePickerProps } from './types';
11
11
 
12
12
  const InternalCalendar = ({
13
13
  minDate,
@@ -80,7 +80,8 @@ const DatePickerCalendar = ({
80
80
  supportedOrientations = ['portrait'],
81
81
  renderSelectedValue,
82
82
  locale,
83
- }: Omit<DatePickerProps, 'variant'>) => {
83
+ TextInputComponent,
84
+ }: Omit<InternalDatePickerProps, 'variant'>) => {
84
85
  const [open, setOpen] = useState(false);
85
86
  const [monthPickerVisible, setMonthPickerVisible] = useState(false);
86
87
  const shouldHideToolbar = Platform.OS === 'ios' && monthPickerVisible;
@@ -95,10 +96,12 @@ const DatePickerCalendar = ({
95
96
 
96
97
  useCalculateDate({ minDate, maxDate, onChange, value });
97
98
 
99
+ const InputComponent = TextInputComponent || TextInput;
100
+
98
101
  return (
99
102
  <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
100
103
  <View pointerEvents="none" testID="datePickerCalendar">
101
- <TextInput
104
+ <InputComponent
102
105
  label={label}
103
106
  value={displayValue}
104
107
  suffix="calendar-dates-outlined"
@@ -6,10 +6,10 @@ import TextInput from '../TextInput';
6
6
  import IOSDatePickerDialog from './Dialog/IOSDialog';
7
7
  import useCalculateDate from './hooks/useCalculateDate';
8
8
  import useFormatDate from './hooks/useFormatDate';
9
- import type { DatePickerProps } from './types';
9
+ import type { InternalDatePickerProps } from './types';
10
10
 
11
11
  type DatePickerIOSProps = Omit<
12
- DatePickerProps,
12
+ InternalDatePickerProps,
13
13
  'variant' | 'monthPickerConfirmLabel' | 'monthPickerCancelLabel'
14
14
  > & {
15
15
  variant?: 'default' | 'month-year';
@@ -33,6 +33,7 @@ const DatePickerIOS = ({
33
33
  variant = 'default',
34
34
  locale,
35
35
  renderSelectedValue,
36
+ TextInputComponent,
36
37
  }: DatePickerIOSProps) => {
37
38
  const [open, setOpen] = useState(false);
38
39
  const { lang: defaultLocale } = useLocale();
@@ -44,10 +45,12 @@ const DatePickerIOS = ({
44
45
 
45
46
  useCalculateDate({ minDate, maxDate, onChange, value });
46
47
 
48
+ const InputComponent = TextInputComponent || TextInput;
49
+
47
50
  return (
48
51
  <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
49
52
  <View pointerEvents="none" testID="datePickerInputIOS">
50
- <TextInput
53
+ <InputComponent
51
54
  label={label}
52
55
  value={displayValue}
53
56
  suffix="calendar-dates-outlined"
@@ -50,6 +50,11 @@ const IOSDatePickerDialog = ({
50
50
  supportedOrientations={supportedOrientations}
51
51
  >
52
52
  <StyledPickerWrapper>
53
+ {/*
54
+ For native pickers like MonthYearPickerViewIOS, using style={{ height: '100%', width: '100%' }} ensures the picker fills the parent container.
55
+ This is because many native views (especially iOS pickers) do not always respect flexbox properties like flex: 1,
56
+ and may render as empty or collapsed if not given explicit width/height. Using '100%' makes the picker reliably fill the available space.
57
+ */}
53
58
  {variant === 'month-year' ? (
54
59
  <MonthYearPickerViewIOS
55
60
  value={selectingDate}
@@ -57,12 +62,12 @@ const IOSDatePickerDialog = ({
57
62
  minimumDate={minDate}
58
63
  textColor={theme.colors.onDefaultGlobalSurface}
59
64
  maximumDate={maxDate}
65
+ style={{ height: '100%', width: '100%' }}
60
66
  onChange={(date: Date | undefined) => {
61
67
  if (date) {
62
68
  setSelectingDate(date);
63
69
  }
64
70
  }}
65
- style={{ flex: 1 }}
66
71
  />
67
72
  ) : null}
68
73
  {variant === 'default' ? (
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { Platform } from 'react-native';
3
+ import IOSDatePickerDialog from './Dialog/IOSDialog';
4
+ import AndroidDatePickerDialog from './Dialog/AndroidDialog';
5
+ import { DatePickerDialogProps } from './Dialog/type';
6
+
7
+ const Dialog = ({ ...props }: DatePickerDialogProps) => {
8
+ if (Platform.OS === 'ios') {
9
+ return <IOSDatePickerDialog {...props} />;
10
+ }
11
+
12
+ return <AndroidDatePickerDialog {...props} />;
13
+ };
14
+
15
+ export default Dialog;
@@ -4,6 +4,7 @@ import type { ViewProps } from 'react-native';
4
4
 
5
5
  const StyledPickerWrapper = styled(View)<ViewProps>(({ theme }) => ({
6
6
  height: theme.__hd__.datePicker.sizes.height,
7
+ alignItems: 'center',
7
8
  }));
8
9
 
9
10
  export { StyledPickerWrapper };
@@ -524,6 +524,7 @@ exports[`DatePickerIOS renders correctly 1`] = `
524
524
  style={
525
525
  [
526
526
  {
527
+ "alignItems": "center",
527
528
  "height": 176,
528
529
  },
529
530
  undefined,
@@ -1192,6 +1193,7 @@ exports[`DatePickerIOS renders correctly with custom locale 1`] = `
1192
1193
  style={
1193
1194
  [
1194
1195
  {
1196
+ "alignItems": "center",
1195
1197
  "height": 176,
1196
1198
  },
1197
1199
  undefined,
@@ -0,0 +1,10 @@
1
+ import { FunctionComponent } from 'react';
2
+ import DatePicker from './DatePicker';
3
+ import { InternalDatePickerProps } from './types';
4
+ import Dialog from './Dialog';
5
+
6
+ export type { InternalDatePickerProps as DatePickerProps };
7
+
8
+ const InternalDatePicker =
9
+ DatePicker as FunctionComponent<InternalDatePickerProps>;
10
+ export default Object.assign(InternalDatePicker, { Dialog });
@@ -1,30 +1,7 @@
1
- import React from 'react';
2
- import { Platform } from 'react-native';
3
- import DatePickerAndroid from './DatePickerAndroid';
4
- import DatePickerCalendar from './DatePickerCalendar';
5
- import DatePickerIOS from './DatePickerIOS';
6
- import type { DatePickerProps } from './types';
7
- import IOSDatePickerDialog from './Dialog/IOSDialog';
8
- import AndroidDatePickerDialog from './Dialog/AndroidDialog';
9
- import { DatePickerDialogProps } from './Dialog/type';
1
+ import { FunctionComponent } from 'react';
2
+ import DatePicker from './DatePicker';
3
+ import { DatePickerProps } from './types';
4
+ import Dialog from './Dialog';
10
5
 
11
- const DatePicker = ({ variant = 'default', ...props }: DatePickerProps) => {
12
- if (variant === 'calendar') {
13
- return <DatePickerCalendar {...props} />;
14
- }
15
- if (Platform.OS === 'ios') {
16
- return <DatePickerIOS {...props} variant={variant} />;
17
- }
18
-
19
- return <DatePickerAndroid {...props} variant={variant} />;
20
- };
21
-
22
- const Dialog = ({ ...props }: DatePickerDialogProps) => {
23
- if (Platform.OS === 'ios') {
24
- return <IOSDatePickerDialog {...props} />;
25
- }
26
-
27
- return <AndroidDatePickerDialog {...props} />;
28
- };
29
-
30
- export default Object.assign(DatePicker, { Dialog });
6
+ const PublicDatePicker = DatePicker as FunctionComponent<DatePickerProps>;
7
+ export default Object.assign(PublicDatePicker, { Dialog });
@@ -3,6 +3,7 @@ import type {
3
3
  StyleProp,
4
4
  ViewStyle,
5
5
  } from 'react-native';
6
+ import { TextInputProps } from '../TextInput';
6
7
 
7
8
  export interface DatePickerProps {
8
9
  /**
@@ -100,3 +101,8 @@ export interface DatePickerProps {
100
101
  props?: NativeTextInputProps
101
102
  ) => React.ReactNode;
102
103
  }
104
+
105
+ // Add an internal prop type for TextInputComponent, not exported
106
+ export interface InternalDatePickerProps extends DatePickerProps {
107
+ TextInputComponent?: React.ComponentType<TextInputProps>;
108
+ }
@@ -19,7 +19,12 @@ function PinCell({
19
19
  state?: State;
20
20
  }) {
21
21
  return (
22
- <StyledCell themeFocused={focused} themeState={state}>
22
+ <StyledCell
23
+ themeFocused={focused}
24
+ themeState={state}
25
+ accessibilityState={{ selected: focused }}
26
+ testID="pin-cell"
27
+ >
23
28
  {value === '' && <StyledMask themeState={state} testID="pin-cell-mask" />}
24
29
  {value !== '' && secure && (
25
30
  <StyledFilledMask themeState={state} testID="pin-cell-filled-mask" />
@@ -1,12 +1,12 @@
1
1
  import styled from '@emotion/native';
2
- import { TextInput, View } from 'react-native';
2
+ import { Pressable, TextInput, View } from 'react-native';
3
3
  import Typography from '../Typography';
4
4
 
5
5
  export const StyledWrapper = styled(View)(() => ({
6
6
  alignContent: 'flex-start',
7
7
  }));
8
8
 
9
- export const StyledPinWrapper = styled(View)(() => ({
9
+ export const StyledPinWrapper = styled(Pressable)(() => ({
10
10
  flexDirection: 'row',
11
11
  }));
12
12
 
@@ -9,6 +9,11 @@ exports[`PinCell renders correctly when focused is false, state is default 1`] =
9
9
  }
10
10
  >
11
11
  <View
12
+ accessibilityState={
13
+ {
14
+ "selected": false,
15
+ }
16
+ }
12
17
  style={
13
18
  [
14
19
  {
@@ -23,6 +28,7 @@ exports[`PinCell renders correctly when focused is false, state is default 1`] =
23
28
  undefined,
24
29
  ]
25
30
  }
31
+ testID="pin-cell"
26
32
  themeFocused={false}
27
33
  themeState="default"
28
34
  >
@@ -85,6 +91,11 @@ exports[`PinCell renders correctly when focused is false, state is disabled 1`]
85
91
  }
86
92
  >
87
93
  <View
94
+ accessibilityState={
95
+ {
96
+ "selected": false,
97
+ }
98
+ }
88
99
  style={
89
100
  [
90
101
  {
@@ -99,6 +110,7 @@ exports[`PinCell renders correctly when focused is false, state is disabled 1`]
99
110
  undefined,
100
111
  ]
101
112
  }
113
+ testID="pin-cell"
102
114
  themeFocused={false}
103
115
  themeState="disabled"
104
116
  >
@@ -161,6 +173,11 @@ exports[`PinCell renders correctly when focused is false, state is error 1`] = `
161
173
  }
162
174
  >
163
175
  <View
176
+ accessibilityState={
177
+ {
178
+ "selected": false,
179
+ }
180
+ }
164
181
  style={
165
182
  [
166
183
  {
@@ -175,6 +192,7 @@ exports[`PinCell renders correctly when focused is false, state is error 1`] = `
175
192
  undefined,
176
193
  ]
177
194
  }
195
+ testID="pin-cell"
178
196
  themeFocused={false}
179
197
  themeState="error"
180
198
  >
@@ -237,6 +255,11 @@ exports[`PinCell renders correctly when focused is true, state is default 1`] =
237
255
  }
238
256
  >
239
257
  <View
258
+ accessibilityState={
259
+ {
260
+ "selected": true,
261
+ }
262
+ }
240
263
  style={
241
264
  [
242
265
  {
@@ -251,6 +274,7 @@ exports[`PinCell renders correctly when focused is true, state is default 1`] =
251
274
  undefined,
252
275
  ]
253
276
  }
277
+ testID="pin-cell"
254
278
  themeFocused={true}
255
279
  themeState="default"
256
280
  >
@@ -313,6 +337,11 @@ exports[`PinCell renders correctly when focused is true, state is error 1`] = `
313
337
  }
314
338
  >
315
339
  <View
340
+ accessibilityState={
341
+ {
342
+ "selected": true,
343
+ }
344
+ }
316
345
  style={
317
346
  [
318
347
  {
@@ -327,6 +356,7 @@ exports[`PinCell renders correctly when focused is true, state is error 1`] = `
327
356
  undefined,
328
357
  ]
329
358
  }
359
+ testID="pin-cell"
330
360
  themeFocused={true}
331
361
  themeState="error"
332
362
  >