@hero-design/rn 8.103.6 → 8.103.7

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 (33) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +6 -0
  3. package/es/index.js +128 -61
  4. package/lib/index.js +128 -61
  5. package/package.json +1 -1
  6. package/src/components/DatePicker/DatePickerAndroid.tsx +18 -4
  7. package/src/components/DatePicker/DatePickerCalendar.tsx +18 -4
  8. package/src/components/DatePicker/DatePickerIOS.tsx +18 -4
  9. package/src/components/DatePicker/StyledDatePicker.tsx +19 -2
  10. package/src/components/DatePicker/__tests__/DatePicker.spec.tsx +102 -1
  11. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +3 -0
  12. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +1 -0
  13. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +1 -0
  14. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +2 -0
  15. package/src/components/DatePicker/types.ts +11 -0
  16. package/src/components/TimePicker/StyledTimePicker.tsx +19 -2
  17. package/src/components/TimePicker/TimePickerAndroid.tsx +18 -4
  18. package/src/components/TimePicker/TimePickerIOS.tsx +21 -5
  19. package/src/components/TimePicker/__tests__/TimePicker.spec.tsx +72 -1
  20. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +2 -0
  21. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +2 -0
  22. package/src/components/TimePicker/types.ts +11 -0
  23. package/stats/8.103.6/rn-stats.html +0 -2
  24. package/stats/8.103.7/rn-stats.html +4844 -0
  25. package/types/components/DatePicker/DatePickerAndroid.d.ts +1 -1
  26. package/types/components/DatePicker/DatePickerCalendar.d.ts +1 -1
  27. package/types/components/DatePicker/DatePickerIOS.d.ts +1 -1
  28. package/types/components/DatePicker/StyledDatePicker.d.ts +8 -1
  29. package/types/components/DatePicker/types.d.ts +11 -0
  30. package/types/components/TimePicker/StyledTimePicker.d.ts +8 -1
  31. package/types/components/TimePicker/TimePickerAndroid.d.ts +1 -1
  32. package/types/components/TimePicker/TimePickerIOS.d.ts +1 -1
  33. package/types/components/TimePicker/types.d.ts +11 -0
@@ -41,6 +41,7 @@ exports[`DatePicker renders DatePickerAndroid when OS is android 1`] = `
41
41
  "opacity": 1,
42
42
  }
43
43
  }
44
+ testID="date-picker-android-touchable-opacity"
44
45
  >
45
46
  <View
46
47
  pointerEvents="none"
@@ -328,6 +329,7 @@ exports[`DatePicker renders DatePickerIOS when OS is iOS 1`] = `
328
329
  "opacity": 1,
329
330
  }
330
331
  }
332
+ testID="date-picker-ios-touchable-opacity"
331
333
  >
332
334
  <View
333
335
  pointerEvents="none"
@@ -615,6 +617,7 @@ exports[`DatePicker renders variant Calendar 1`] = `
615
617
  "opacity": 1,
616
618
  }
617
619
  }
620
+ testID="date-picker-calendar-touchable-opacity"
618
621
  >
619
622
  <View
620
623
  pointerEvents="none"
@@ -41,6 +41,7 @@ exports[`DatePickerAndroid renders correctly 1`] = `
41
41
  "opacity": 1,
42
42
  }
43
43
  }
44
+ testID="date-picker-android-touchable-opacity"
44
45
  >
45
46
  <View
46
47
  pointerEvents="none"
@@ -41,6 +41,7 @@ exports[`DatePickerCalendar renders correctly 1`] = `
41
41
  "opacity": 1,
42
42
  }
43
43
  }
44
+ testID="date-picker-calendar-touchable-opacity"
44
45
  >
45
46
  <View
46
47
  pointerEvents="none"
@@ -41,6 +41,7 @@ exports[`DatePickerIOS renders correctly 1`] = `
41
41
  "opacity": 1,
42
42
  }
43
43
  }
44
+ testID="date-picker-ios-touchable-opacity"
44
45
  >
45
46
  <View
46
47
  pointerEvents="none"
@@ -711,6 +712,7 @@ exports[`DatePickerIOS renders correctly with custom locale 1`] = `
711
712
  "opacity": 1,
712
713
  }
713
714
  }
715
+ testID="date-picker-ios-touchable-opacity"
714
716
  >
715
717
  <View
716
718
  pointerEvents="none"
@@ -104,5 +104,16 @@ export interface DatePickerProps {
104
104
 
105
105
  // Add an internal prop type for TextInputComponent, not exported
106
106
  export interface InternalDatePickerProps extends DatePickerProps {
107
+ /**
108
+ * Props that are passed to TextInput.
109
+ */
110
+ inputProps?: Pick<TextInputProps, 'loading' | 'numberOfLines'>;
111
+ /**
112
+ * Whether the component is used within a FormGroup for styling purposes.
113
+ */
114
+ groupStyleEnabled?: boolean;
115
+ /**
116
+ * Input component to use instead of the default TextInput.
117
+ */
107
118
  TextInputComponent?: React.ComponentType<TextInputProps>;
108
119
  }
@@ -1,5 +1,5 @@
1
1
  import styled from '@emotion/native';
2
- import { View } from 'react-native';
2
+ import { View, TouchableOpacity } from 'react-native';
3
3
  import type { ViewProps } from 'react-native';
4
4
 
5
5
  const StyledPickerWrapper = styled(View)<ViewProps>(({ theme }) => ({
@@ -7,4 +7,21 @@ const StyledPickerWrapper = styled(View)<ViewProps>(({ theme }) => ({
7
7
  alignItems: 'center',
8
8
  }));
9
9
 
10
- export { StyledPickerWrapper };
10
+ const getZIndexByState = ({ themeHasError }: { themeHasError: boolean }) => {
11
+ if (themeHasError) {
12
+ return 1;
13
+ }
14
+
15
+ return 0;
16
+ };
17
+
18
+ const StyledTouchableOpacity = styled(TouchableOpacity)<{
19
+ themeGroupStyleEnabled: boolean;
20
+ themeHasError: boolean;
21
+ }>(({ themeGroupStyleEnabled, themeHasError }) => ({
22
+ ...(themeGroupStyleEnabled && {
23
+ zIndex: getZIndexByState({ themeHasError }),
24
+ }),
25
+ }));
26
+
27
+ export { StyledPickerWrapper, StyledTouchableOpacity };
@@ -1,9 +1,10 @@
1
1
  import DateTimePicker from '@react-native-community/datetimepicker';
2
- import React, { useState } from 'react';
3
- import { TouchableOpacity, View } from 'react-native';
2
+ import React, { useState, useCallback } from 'react';
3
+ import { View } from 'react-native';
4
4
  import formatTime from 'date-fns/fp/format';
5
5
 
6
6
  import TextInput from '../TextInput';
7
+ import { StyledTouchableOpacity } from './StyledTimePicker';
7
8
  import type { InternalTimePickerProps } from './types';
8
9
 
9
10
  const TimePickerAndroid = ({
@@ -20,6 +21,8 @@ const TimePickerAndroid = ({
20
21
  testID,
21
22
  showSuffix = true,
22
23
  TextInputComponent,
24
+ inputProps,
25
+ groupStyleEnabled = false,
23
26
  }: InternalTimePickerProps) => {
24
27
  const [open, setOpen] = useState(false);
25
28
 
@@ -29,10 +32,21 @@ const TimePickerAndroid = ({
29
32
 
30
33
  const InputComponent = TextInputComponent || TextInput;
31
34
 
35
+ const onPress = useCallback(() => {
36
+ setOpen(true);
37
+ }, []);
38
+
32
39
  return (
33
- <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
40
+ <StyledTouchableOpacity
41
+ onPress={onPress}
42
+ disabled={disabled}
43
+ themeGroupStyleEnabled={groupStyleEnabled}
44
+ themeHasError={!!error}
45
+ testID="time-picker-android-touchable-opacity"
46
+ >
34
47
  <View pointerEvents="none" testID="timePickerInputAndroid">
35
48
  <InputComponent
49
+ {...inputProps}
36
50
  label={label}
37
51
  value={displayValue}
38
52
  suffix={showSuffix ? 'clock-3' : undefined}
@@ -60,7 +74,7 @@ const TimePickerAndroid = ({
60
74
  is24Hour={!is12Hour}
61
75
  />
62
76
  ) : null}
63
- </TouchableOpacity>
77
+ </StyledTouchableOpacity>
64
78
  );
65
79
  };
66
80
 
@@ -1,12 +1,15 @@
1
1
  import DateTimePicker from '@react-native-community/datetimepicker';
2
- import React, { useEffect, useState } from 'react';
3
- import { TouchableOpacity, View } from 'react-native';
2
+ import React, { useEffect, useState, useCallback } from 'react';
3
+ import { View } from 'react-native';
4
4
  import formatTime from 'date-fns/fp/format';
5
5
 
6
6
  import BottomSheet from '../BottomSheet';
7
7
  import TextInput from '../TextInput';
8
8
  import Button from '../Button';
9
- import { StyledPickerWrapper } from './StyledTimePicker';
9
+ import {
10
+ StyledPickerWrapper,
11
+ StyledTouchableOpacity,
12
+ } from './StyledTimePicker';
10
13
  import type { InternalTimePickerProps } from './types';
11
14
  import { useTheme } from '../../theme';
12
15
 
@@ -26,6 +29,8 @@ const TimePickerIOS = ({
26
29
  showSuffix = true,
27
30
  supportedOrientations = ['portrait'],
28
31
  TextInputComponent,
32
+ inputProps,
33
+ groupStyleEnabled = false,
29
34
  }: InternalTimePickerProps) => {
30
35
  const [selectingDate, setSelectingDate] = useState<Date>(value || new Date());
31
36
  const [open, setOpen] = useState(false);
@@ -40,10 +45,21 @@ const TimePickerIOS = ({
40
45
  setSelectingDate(value || new Date());
41
46
  }, [value]);
42
47
 
48
+ const onPress = useCallback(() => {
49
+ setOpen(true);
50
+ }, []);
51
+
43
52
  return (
44
- <TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
53
+ <StyledTouchableOpacity
54
+ onPress={onPress}
55
+ disabled={disabled}
56
+ themeGroupStyleEnabled={groupStyleEnabled}
57
+ themeHasError={!!error}
58
+ testID="time-picker-ios-touchable-opacity"
59
+ >
45
60
  <View pointerEvents="none" testID="timePickerInputIOS">
46
61
  <InputComponent
62
+ {...inputProps}
47
63
  label={label}
48
64
  value={displayValue}
49
65
  suffix={showSuffix ? 'clock-3' : undefined}
@@ -93,7 +109,7 @@ const TimePickerIOS = ({
93
109
  />
94
110
  </StyledPickerWrapper>
95
111
  </BottomSheet>
96
- </TouchableOpacity>
112
+ </StyledTouchableOpacity>
97
113
  );
98
114
  };
99
115
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Platform } from 'react-native';
3
- import TimePicker from '..';
3
+ // Use internal import for full prop support
4
+ import TimePicker from '../index.internal';
4
5
  import renderWithTheme from '../../../testHelpers/renderWithTheme';
5
6
 
6
7
  describe('TimePicker', () => {
@@ -31,4 +32,74 @@ describe('TimePicker', () => {
31
32
 
32
33
  expect(getByTestId('timePickerInputAndroid')).toBeDefined();
33
34
  });
35
+
36
+ it('renders correctly when inputProps loading is true', () => {
37
+ Platform.OS = 'ios';
38
+ const { getByTestId } = renderWithTheme(
39
+ <TimePicker
40
+ label="Start time"
41
+ value={new Date('December 17, 1995 03:24:00')}
42
+ confirmLabel="Confirm"
43
+ inputProps={{ loading: true }}
44
+ onChange={jest.fn()}
45
+ />
46
+ );
47
+
48
+ expect(getByTestId('input-suffix')).toHaveProp('name', 'loading');
49
+ });
50
+
51
+ it('renders correctly when groupStyleEnabled is true and no error', () => {
52
+ Platform.OS = 'ios';
53
+ const { getByTestId } = renderWithTheme(
54
+ <TimePicker
55
+ label="Start time"
56
+ value={new Date('December 17, 1995 03:24:00')}
57
+ confirmLabel="Confirm"
58
+ groupStyleEnabled
59
+ onChange={jest.fn()}
60
+ />
61
+ );
62
+
63
+ const touchableOpacity = getByTestId('time-picker-ios-touchable-opacity');
64
+ expect(touchableOpacity).toBeTruthy();
65
+ expect(touchableOpacity.props.style).toHaveProperty('zIndex', 0);
66
+ });
67
+
68
+ it('renders correctly when groupStyleEnabled is true and has error', () => {
69
+ Platform.OS = 'ios';
70
+ const { getByTestId } = renderWithTheme(
71
+ <TimePicker
72
+ label="Start time"
73
+ value={new Date('December 17, 1995 03:24:00')}
74
+ confirmLabel="Confirm"
75
+ groupStyleEnabled
76
+ error="This field is required"
77
+ onChange={jest.fn()}
78
+ />
79
+ );
80
+
81
+ const touchableOpacity = getByTestId('time-picker-ios-touchable-opacity');
82
+ expect(touchableOpacity).toBeTruthy();
83
+ expect(touchableOpacity.props.style).toHaveProperty('zIndex', 1);
84
+ });
85
+
86
+ it('renders correctly when groupStyleEnabled is true and has error for Android', () => {
87
+ Platform.OS = 'android';
88
+ const { getByTestId } = renderWithTheme(
89
+ <TimePicker
90
+ label="Start time"
91
+ value={new Date('December 17, 1995 03:24:00')}
92
+ confirmLabel="Confirm"
93
+ groupStyleEnabled
94
+ error="This field is required"
95
+ onChange={jest.fn()}
96
+ />
97
+ );
98
+
99
+ const touchableOpacity = getByTestId(
100
+ 'time-picker-android-touchable-opacity'
101
+ );
102
+ expect(touchableOpacity).toBeTruthy();
103
+ expect(touchableOpacity.props.style).toHaveProperty('zIndex', 1);
104
+ });
34
105
  });
@@ -41,6 +41,7 @@ exports[`TimePickerAndroid renders correct with hide suffix 1`] = `
41
41
  "opacity": 1,
42
42
  }
43
43
  }
44
+ testID="time-picker-android-touchable-opacity"
44
45
  >
45
46
  <View
46
47
  pointerEvents="none"
@@ -333,6 +334,7 @@ exports[`TimePickerAndroid renders correctly 1`] = `
333
334
  "opacity": 1,
334
335
  }
335
336
  }
337
+ testID="time-picker-android-touchable-opacity"
336
338
  >
337
339
  <View
338
340
  pointerEvents="none"
@@ -41,6 +41,7 @@ exports[`TimePickerIOS renders correct with hide suffix 1`] = `
41
41
  "opacity": 1,
42
42
  }
43
43
  }
44
+ testID="time-picker-ios-touchable-opacity"
44
45
  >
45
46
  <View
46
47
  pointerEvents="none"
@@ -333,6 +334,7 @@ exports[`TimePickerIOS renders correctly 1`] = `
333
334
  "opacity": 1,
334
335
  }
335
336
  }
337
+ testID="time-picker-ios-touchable-opacity"
336
338
  >
337
339
  <View
338
340
  pointerEvents="none"
@@ -65,5 +65,16 @@ export interface TimePickerProps {
65
65
 
66
66
  // Add an internal prop type for TextInputComponent, not exported
67
67
  export interface InternalTimePickerProps extends TimePickerProps {
68
+ /**
69
+ * Props that are passed to TextInput.
70
+ */
71
+ inputProps?: Pick<TextInputProps, 'loading' | 'numberOfLines'>;
72
+ /**
73
+ * Whether the component is used within a FormGroup for styling purposes.
74
+ */
75
+ groupStyleEnabled?: boolean;
76
+ /**
77
+ * Input component to use instead of the default TextInput.
78
+ */
68
79
  TextInputComponent?: React.ComponentType<TextInputProps>;
69
80
  }
@@ -4840,5 +4840,3 @@ var drawChart = (function (exports) {
4840
4840
  </body>
4841
4841
  </html>
4842
4842
 
4843
- ml>
4844
-