@hero-design/rn 8.103.3 → 8.103.5

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 (48) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +17 -0
  3. package/es/index.js +45 -23
  4. package/lib/index.js +45 -23
  5. package/package.json +3 -3
  6. package/src/components/DatePicker/DatePicker.tsx +38 -0
  7. package/src/components/DatePicker/DatePickerAndroid.tsx +6 -3
  8. package/src/components/DatePicker/DatePickerCalendar.tsx +6 -3
  9. package/src/components/DatePicker/DatePickerIOS.tsx +6 -3
  10. package/src/components/DatePicker/Dialog/IOSDialog.tsx +6 -1
  11. package/src/components/DatePicker/Dialog.tsx +15 -0
  12. package/src/components/DatePicker/index.internal.tsx +10 -0
  13. package/src/components/DatePicker/index.tsx +6 -29
  14. package/src/components/DatePicker/types.ts +6 -0
  15. package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +5 -5
  16. package/src/components/PinInput/index.tsx +1 -1
  17. package/src/components/TextInput/index.tsx +29 -4
  18. package/src/components/TimePicker/TimePicker.tsx +15 -0
  19. package/src/components/TimePicker/TimePickerAndroid.tsx +6 -3
  20. package/src/components/TimePicker/TimePickerIOS.tsx +6 -3
  21. package/src/components/TimePicker/index.internal.tsx +9 -0
  22. package/src/components/TimePicker/index.tsx +4 -13
  23. package/src/components/TimePicker/types.ts +6 -0
  24. package/src/index.internal.ts +9 -2
  25. package/src/types.internal.ts +8 -1
  26. package/src/types.ts +4 -0
  27. package/stats/8.103.3/rn-stats.html +0 -2
  28. package/stats/8.103.4/rn-stats.html +4842 -0
  29. package/stats/8.103.5/rn-stats.html +4844 -0
  30. package/types/components/Calendar/CalendarRowItem.d.ts +1 -1
  31. package/types/components/DatePicker/DatePicker.d.ts +4 -0
  32. package/types/components/DatePicker/DatePickerAndroid.d.ts +3 -3
  33. package/types/components/DatePicker/DatePickerCalendar.d.ts +2 -2
  34. package/types/components/DatePicker/DatePickerIOS.d.ts +3 -3
  35. package/types/components/DatePicker/Dialog.d.ts +4 -0
  36. package/types/components/DatePicker/index.d.ts +4 -5
  37. package/types/components/DatePicker/index.internal.d.ts +7 -0
  38. package/types/components/DatePicker/types.d.ts +4 -0
  39. package/types/components/TextInput/index.d.ts +14 -3
  40. package/types/components/TimePicker/TimePicker.d.ts +4 -0
  41. package/types/components/TimePicker/TimePickerAndroid.d.ts +2 -2
  42. package/types/components/TimePicker/TimePickerIOS.d.ts +2 -2
  43. package/types/components/TimePicker/index.d.ts +3 -3
  44. package/types/components/TimePicker/index.internal.d.ts +5 -0
  45. package/types/components/TimePicker/types.d.ts +4 -0
  46. package/types/index.internal.d.ts +4 -2
  47. package/types/types.d.ts +3 -1
  48. package/types/types.internal.d.ts +3 -1
@@ -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;
@@ -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
+ }
@@ -258,7 +258,7 @@ exports[`rendering renders correctly 1`] = `
258
258
  <TextInput
259
259
  autoFocus={false}
260
260
  editable={true}
261
- keyboardType="numeric"
261
+ inputMode="numeric"
262
262
  onBlur={[Function]}
263
263
  onChangeText={[Function]}
264
264
  onFocus={[Function]}
@@ -573,7 +573,7 @@ exports[`rendering renders correctly when disabled 1`] = `
573
573
  <TextInput
574
574
  autoFocus={false}
575
575
  editable={false}
576
- keyboardType="numeric"
576
+ inputMode="numeric"
577
577
  onBlur={[Function]}
578
578
  onChangeText={[Function]}
579
579
  onFocus={[Function]}
@@ -1018,7 +1018,7 @@ exports[`rendering renders correctly when length is 6 and secure is false 1`] =
1018
1018
  <TextInput
1019
1019
  autoFocus={false}
1020
1020
  editable={true}
1021
- keyboardType="numeric"
1021
+ inputMode="numeric"
1022
1022
  onBlur={[Function]}
1023
1023
  onChangeText={[Function]}
1024
1024
  onFocus={[Function]}
@@ -1386,7 +1386,7 @@ exports[`rendering renders correctly when there is error 1`] = `
1386
1386
  <TextInput
1387
1387
  autoFocus={false}
1388
1388
  editable={true}
1389
- keyboardType="numeric"
1389
+ inputMode="numeric"
1390
1390
  onBlur={[Function]}
1391
1391
  onChangeText={[Function]}
1392
1392
  onFocus={[Function]}
@@ -1702,7 +1702,7 @@ exports[`rendering renders correctly with textContentType and autoComplete 1`] =
1702
1702
  autoComplete="one-time-code"
1703
1703
  autoFocus={false}
1704
1704
  editable={true}
1705
- keyboardType="numeric"
1705
+ inputMode="numeric"
1706
1706
  onBlur={[Function]}
1707
1707
  onChangeText={[Function]}
1708
1708
  onFocus={[Function]}
@@ -231,7 +231,7 @@ const PinInput = forwardRef<PinInputHandler, PinInputProps>(
231
231
  onFocus={focus}
232
232
  onBlur={blur}
233
233
  pointerEvents="none"
234
- keyboardType="numeric"
234
+ inputMode="numeric"
235
235
  testID="pin-hidden-input"
236
236
  textContentType={textContentType}
237
237
  autoComplete={autoComplete}
@@ -13,11 +13,13 @@ import {
13
13
  View,
14
14
  } from 'react-native';
15
15
  import type {
16
- TextInputProps as NativeTextInputProps,
16
+ TextInputProps as RNTextInputProps,
17
17
  StyleProp,
18
18
  ViewStyle,
19
19
  TextStyle,
20
20
  LayoutChangeEvent,
21
+ NativeSyntheticEvent,
22
+ TextInputFocusEventData,
21
23
  } from 'react-native';
22
24
  import {
23
25
  StyledTextInputContainer,
@@ -49,6 +51,23 @@ export type TextInputHandles = Pick<
49
51
 
50
52
  export type TextInputVariant = 'text' | 'textarea';
51
53
 
54
+ type NativeTextInputProps = Omit<RNTextInputProps, 'onFocus' | 'onBlur'> & {
55
+ onFocus?: (
56
+ event?: NativeSyntheticEvent<TextInputFocusEventData>
57
+ ) => void | undefined;
58
+ onBlur?: (
59
+ event?: NativeSyntheticEvent<TextInputFocusEventData>
60
+ ) => void | undefined;
61
+ };
62
+
63
+ export interface TextInputRef {
64
+ focus: () => void;
65
+ blur: () => void;
66
+ clear: () => void;
67
+ isFocused: () => boolean;
68
+ setNativeProps?: (props: RNTextInputProps) => void;
69
+ }
70
+
52
71
  export interface TextInputProps extends NativeTextInputProps {
53
72
  /**
54
73
  * Field label.
@@ -118,7 +137,10 @@ export interface TextInputProps extends NativeTextInputProps {
118
137
  /**
119
138
  * Customise input value renderer
120
139
  */
121
- renderInputValue?: (inputProps: NativeTextInputProps) => React.ReactNode;
140
+ renderInputValue?: (
141
+ inputProps: NativeTextInputProps,
142
+ ref?: React.ForwardedRef<TextInputRef>
143
+ ) => React.ReactNode;
122
144
  /**
123
145
  * Component ref.
124
146
  */
@@ -197,12 +219,15 @@ export const renderInput = ({
197
219
  variant: TextInputVariant;
198
220
  nativeInputProps: NativeTextInputProps;
199
221
  multiline?: boolean;
200
- renderInputValue?: (inputProps: NativeTextInputProps) => React.ReactNode;
222
+ renderInputValue?: (
223
+ inputProps: NativeTextInputProps,
224
+ ref?: React.Ref<TextInputRef>
225
+ ) => React.ReactNode;
201
226
  ref?: React.Ref<RNTextInput>;
202
227
  theme: Theme;
203
228
  }) => {
204
229
  return renderInputValue ? (
205
- renderInputValue(nativeInputProps)
230
+ renderInputValue(nativeInputProps, ref)
206
231
  ) : (
207
232
  <StyledTextInput
208
233
  {...nativeInputProps}
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { Platform } from 'react-native';
3
+ import TimePickerAndroid from './TimePickerAndroid';
4
+ import TimePickerIOS from './TimePickerIOS';
5
+ import type { InternalTimePickerProps } from './types';
6
+
7
+ const TimePicker = (props: InternalTimePickerProps) => {
8
+ if (Platform.OS === 'ios') {
9
+ return <TimePickerIOS {...props} />;
10
+ }
11
+
12
+ return <TimePickerAndroid {...props} />;
13
+ };
14
+
15
+ export default TimePicker;
@@ -4,7 +4,7 @@ import { TouchableOpacity, View } from 'react-native';
4
4
  import formatTime from 'date-fns/fp/format';
5
5
 
6
6
  import TextInput from '../TextInput';
7
- import type { TimePickerProps } from './types';
7
+ import type { InternalTimePickerProps } from './types';
8
8
 
9
9
  const TimePickerAndroid = ({
10
10
  value,
@@ -19,17 +19,20 @@ const TimePickerAndroid = ({
19
19
  style,
20
20
  testID,
21
21
  showSuffix = true,
22
- }: TimePickerProps) => {
22
+ TextInputComponent,
23
+ }: InternalTimePickerProps) => {
23
24
  const [open, setOpen] = useState(false);
24
25
 
25
26
  const is12Hour = displayFormat.includes('hh');
26
27
  const displayValue = value ? formatTime(displayFormat, value) : '';
27
28
  const pickerInitValue = value || new Date();
28
29
 
30
+ const InputComponent = TextInputComponent || TextInput;
31
+
29
32
  return (
30
33
  <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
31
34
  <View pointerEvents="none" testID="timePickerInputAndroid">
32
- <TextInput
35
+ <InputComponent
33
36
  label={label}
34
37
  value={displayValue}
35
38
  suffix={showSuffix ? 'clock-3' : undefined}
@@ -7,7 +7,7 @@ import BottomSheet from '../BottomSheet';
7
7
  import TextInput from '../TextInput';
8
8
  import Button from '../Button';
9
9
  import { StyledPickerWrapper } from './StyledTimePicker';
10
- import type { TimePickerProps } from './types';
10
+ import type { InternalTimePickerProps } from './types';
11
11
  import { useTheme } from '../../theme';
12
12
 
13
13
  const TimePickerIOS = ({
@@ -25,7 +25,8 @@ const TimePickerIOS = ({
25
25
  testID,
26
26
  showSuffix = true,
27
27
  supportedOrientations = ['portrait'],
28
- }: TimePickerProps) => {
28
+ TextInputComponent,
29
+ }: InternalTimePickerProps) => {
29
30
  const [selectingDate, setSelectingDate] = useState<Date>(value || new Date());
30
31
  const [open, setOpen] = useState(false);
31
32
 
@@ -33,6 +34,8 @@ const TimePickerIOS = ({
33
34
  const displayValue = value ? formatTime(displayFormat, value) : '';
34
35
  const theme = useTheme();
35
36
 
37
+ const InputComponent = TextInputComponent || TextInput;
38
+
36
39
  useEffect(() => {
37
40
  setSelectingDate(value || new Date());
38
41
  }, [value]);
@@ -40,7 +43,7 @@ const TimePickerIOS = ({
40
43
  return (
41
44
  <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
42
45
  <View pointerEvents="none" testID="timePickerInputIOS">
43
- <TextInput
46
+ <InputComponent
44
47
  label={label}
45
48
  value={displayValue}
46
49
  suffix={showSuffix ? 'clock-3' : undefined}
@@ -0,0 +1,9 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { InternalTimePickerProps } from './types';
3
+ import TimePicker from './TimePicker';
4
+
5
+ const InternalTimePicker =
6
+ TimePicker as FunctionComponent<InternalTimePickerProps>;
7
+
8
+ export type { InternalTimePickerProps as TimePickerProps };
9
+ export default InternalTimePicker;
@@ -1,15 +1,6 @@
1
- import React from 'react';
2
- import { Platform } from 'react-native';
3
- import TimePickerAndroid from './TimePickerAndroid';
4
- import TimePickerIOS from './TimePickerIOS';
1
+ import { FunctionComponent } from 'react';
5
2
  import type { TimePickerProps } from './types';
3
+ import TimePicker from './TimePicker';
6
4
 
7
- const TimePicker = (props: TimePickerProps) => {
8
- if (Platform.OS === 'ios') {
9
- return <TimePickerIOS {...props} />;
10
- }
11
-
12
- return <TimePickerAndroid {...props} />;
13
- };
14
-
15
- export default TimePicker;
5
+ const PublicTimePicker = TimePicker as FunctionComponent<TimePickerProps>;
6
+ export default PublicTimePicker;
@@ -1,4 +1,5 @@
1
1
  import type { StyleProp, ViewStyle } from 'react-native';
2
+ import { TextInputProps } from '../TextInput';
2
3
 
3
4
  export interface TimePickerProps {
4
5
  /**
@@ -61,3 +62,8 @@ export interface TimePickerProps {
61
62
  */
62
63
  supportedOrientations?: ('portrait' | 'landscape')[];
63
64
  }
65
+
66
+ // Add an internal prop type for TextInputComponent, not exported
67
+ export interface InternalTimePickerProps extends TimePickerProps {
68
+ TextInputComponent?: React.ComponentType<TextInputProps>;
69
+ }
@@ -1,5 +1,12 @@
1
1
  import Select from './components/Select/index.internal';
2
+ import DatePicker from './components/DatePicker/index.internal';
3
+ import TimePicker from './components/TimePicker/index.internal';
2
4
 
3
5
  export * from '.';
4
- export { Select };
5
- export type { MultiSelectProps, SingleSelectProps } from './types.internal';
6
+ export type {
7
+ MultiSelectProps,
8
+ SingleSelectProps,
9
+ DatePickerProps,
10
+ TimePickerProps,
11
+ } from './types.internal';
12
+ export { Select, DatePicker, TimePicker };
@@ -1,8 +1,15 @@
1
+ import { DatePickerProps } from './components/DatePicker/index.internal';
1
2
  import type {
2
3
  SingleSelectProps,
3
4
  MultiSelectProps,
4
5
  } from './components/Select/index.internal';
6
+ import { TimePickerProps } from './components/TimePicker/index.internal';
5
7
 
6
8
  export * from './types';
7
9
 
8
- export { SingleSelectProps, MultiSelectProps };
10
+ export {
11
+ SingleSelectProps,
12
+ MultiSelectProps,
13
+ DatePickerProps,
14
+ TimePickerProps,
15
+ };
package/src/types.ts CHANGED
@@ -49,6 +49,8 @@ import { TitleProps } from './components/Typography/Title';
49
49
  import { CarouselData, CarouselImageProps } from './components/Carousel/types';
50
50
  import { PinInputHandler } from './components/PinInput';
51
51
  import { ThemeScale } from './components/Box/types';
52
+ import { TimePickerProps } from './components/TimePicker/types';
53
+ import { DatePickerProps } from './components/DatePicker/types';
52
54
 
53
55
  export type {
54
56
  Space,
@@ -101,4 +103,6 @@ export type {
101
103
  ListItemProps,
102
104
  IconButtonProps,
103
105
  BadgeProps,
106
+ TimePickerProps,
107
+ DatePickerProps,
104
108
  };
@@ -4840,5 +4840,3 @@ var drawChart = (function (exports) {
4840
4840
  </body>
4841
4841
  </html>
4842
4842
 
4843
- l>
4844
-