@hero-design/rn 8.128.1 → 8.128.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.
- package/CHANGELOG.md +6 -0
- package/es/index.js +135 -238
- package/lib/index.js +135 -238
- package/package.json +8 -1
- package/src/components/DatePicker/DatePicker.tsx +5 -24
- package/src/components/DatePicker/DatePickerAndroid.tsx +8 -17
- package/src/components/DatePicker/DatePickerCalendar.tsx +8 -17
- package/src/components/DatePicker/DatePickerIOS.tsx +8 -17
- package/src/components/DatePicker/StyledDatePicker.tsx +2 -19
- package/src/components/DatePicker/types.ts +0 -17
- package/src/components/Select/MultiSelect/index.tsx +9 -23
- package/src/components/Select/SingleSelect/index.tsx +9 -23
- package/src/components/Select/StyledSelect.tsx +2 -25
- package/src/components/Select/index.tsx +2 -8
- package/src/components/Select/types.ts +0 -4
- package/src/components/TimePicker/StyledTimePicker.tsx +2 -19
- package/src/components/TimePicker/TimePicker.tsx +2 -2
- package/src/components/TimePicker/TimePickerAndroid.tsx +6 -15
- package/src/components/TimePicker/TimePickerIOS.tsx +7 -18
- package/src/components/TimePicker/types.ts +0 -17
- package/types/components/Checkbox/StyledInlineCheckBox.d.ts +1 -1
- package/types/components/Checkbox/utils.d.ts +1 -1
- package/types/components/DatePicker/DatePicker.d.ts +2 -2
- package/types/components/DatePicker/DatePickerAndroid.d.ts +3 -3
- package/types/components/DatePicker/DatePickerCalendar.d.ts +2 -2
- package/types/components/DatePicker/DatePickerIOS.d.ts +3 -3
- package/types/components/DatePicker/StyledDatePicker.d.ts +1 -8
- package/types/components/DatePicker/types.d.ts +0 -15
- package/types/components/Select/MultiSelect/index.d.ts +1 -6
- package/types/components/Select/SingleSelect/index.d.ts +1 -6
- package/types/components/Select/StyledSelect.d.ts +1 -8
- package/types/components/Select/index.d.ts +2 -2
- package/types/components/Select/types.d.ts +0 -4
- package/types/components/TextInput/index.d.ts +1 -1
- package/types/components/TimePicker/StyledTimePicker.d.ts +1 -8
- package/types/components/TimePicker/TimePicker.d.ts +2 -2
- package/types/components/TimePicker/TimePickerAndroid.d.ts +2 -2
- package/types/components/TimePicker/TimePickerIOS.d.ts +2 -2
- package/types/components/TimePicker/types.d.ts +0 -15
- package/src/components/DatePicker/index.internal.tsx +0 -10
- package/src/components/Select/index.internal.tsx +0 -26
- package/src/components/TimePicker/index.internal.tsx +0 -9
- package/src/index.internal.ts +0 -26
- package/src/types.internal.ts +0 -28
- package/types/components/DatePicker/index.internal.d.ts +0 -7
- package/types/components/Select/index.internal.d.ts +0 -21
- package/types/components/TimePicker/index.internal.d.ts +0 -5
- package/types/index.internal.d.ts +0 -19
- package/types/types.internal.d.ts +0 -18
package/package.json
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.128.
|
|
3
|
+
"version": "8.128.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
"*": {
|
|
10
|
+
"locales/*": [
|
|
11
|
+
"types/locales/*"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
8
15
|
"react-native": "src/index.ts",
|
|
9
16
|
"scripts": {
|
|
10
17
|
"lint": "eslint src --quiet",
|
|
@@ -3,36 +3,17 @@ import { Platform } from 'react-native';
|
|
|
3
3
|
import DatePickerAndroid from './DatePickerAndroid';
|
|
4
4
|
import DatePickerCalendar from './DatePickerCalendar';
|
|
5
5
|
import DatePickerIOS from './DatePickerIOS';
|
|
6
|
-
import type {
|
|
7
|
-
import TextInput from '../TextInput';
|
|
6
|
+
import type { DatePickerProps } from './types';
|
|
8
7
|
|
|
9
|
-
const DatePicker = ({
|
|
10
|
-
variant = 'default',
|
|
11
|
-
TextInputComponent = TextInput,
|
|
12
|
-
...props
|
|
13
|
-
}: InternalDatePickerProps) => {
|
|
8
|
+
const DatePicker = ({ variant = 'default', ...props }: DatePickerProps) => {
|
|
14
9
|
if (variant === 'calendar') {
|
|
15
|
-
return
|
|
16
|
-
<DatePickerCalendar {...props} TextInputComponent={TextInputComponent} />
|
|
17
|
-
);
|
|
10
|
+
return <DatePickerCalendar {...props} />;
|
|
18
11
|
}
|
|
19
12
|
if (Platform.OS === 'ios') {
|
|
20
|
-
return
|
|
21
|
-
<DatePickerIOS
|
|
22
|
-
{...props}
|
|
23
|
-
variant={variant}
|
|
24
|
-
TextInputComponent={TextInputComponent}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
13
|
+
return <DatePickerIOS {...props} variant={variant} />;
|
|
27
14
|
}
|
|
28
15
|
|
|
29
|
-
return
|
|
30
|
-
<DatePickerAndroid
|
|
31
|
-
{...props}
|
|
32
|
-
variant={variant}
|
|
33
|
-
TextInputComponent={TextInputComponent}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
16
|
+
return <DatePickerAndroid {...props} variant={variant} />;
|
|
36
17
|
};
|
|
37
18
|
|
|
38
19
|
export default DatePicker;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import React, { useState, useCallback } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
2
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
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 {
|
|
9
|
-
import type { InternalDatePickerProps } from './types';
|
|
8
|
+
import type { DatePickerProps } from './types';
|
|
10
9
|
|
|
11
10
|
type DatePickerAndroidProps = Omit<
|
|
12
|
-
|
|
11
|
+
DatePickerProps,
|
|
13
12
|
'variant' | 'monthPickerConfirmLabel' | 'monthPickerCancelLabel'
|
|
14
13
|
> & {
|
|
15
14
|
variant?: 'default' | 'month-year';
|
|
@@ -31,9 +30,6 @@ const DatePickerAndroid = ({
|
|
|
31
30
|
variant = 'default',
|
|
32
31
|
renderSelectedValue,
|
|
33
32
|
locale,
|
|
34
|
-
TextInputComponent,
|
|
35
|
-
inputProps,
|
|
36
|
-
groupStyleEnabled = false,
|
|
37
33
|
}: DatePickerAndroidProps) => {
|
|
38
34
|
const [open, setOpen] = useState(false);
|
|
39
35
|
|
|
@@ -45,23 +41,18 @@ const DatePickerAndroid = ({
|
|
|
45
41
|
|
|
46
42
|
useCalculateDate({ minDate, maxDate, onChange, value });
|
|
47
43
|
|
|
48
|
-
const InputComponent = TextInputComponent || TextInput;
|
|
49
|
-
|
|
50
44
|
const onPress = useCallback(() => {
|
|
51
45
|
setOpen(true);
|
|
52
46
|
}, []);
|
|
53
47
|
|
|
54
48
|
return (
|
|
55
|
-
<
|
|
49
|
+
<TouchableOpacity
|
|
56
50
|
onPress={onPress}
|
|
57
51
|
disabled={disabled}
|
|
58
|
-
themeGroupStyleEnabled={groupStyleEnabled}
|
|
59
|
-
themeHasError={!!error}
|
|
60
52
|
testID="date-picker-android-touchable-opacity"
|
|
61
53
|
>
|
|
62
54
|
<View pointerEvents="none" testID="datePickerInputAndroid">
|
|
63
|
-
<
|
|
64
|
-
{...inputProps}
|
|
55
|
+
<TextInput
|
|
65
56
|
label={label}
|
|
66
57
|
value={displayValue}
|
|
67
58
|
suffix="calendar-dates-outlined"
|
|
@@ -74,13 +65,13 @@ const DatePickerAndroid = ({
|
|
|
74
65
|
testID={testID}
|
|
75
66
|
renderInputValue={
|
|
76
67
|
renderSelectedValue !== undefined && !!value
|
|
77
|
-
? (
|
|
68
|
+
? (inputProps) =>
|
|
78
69
|
renderSelectedValue(
|
|
79
70
|
{
|
|
80
71
|
date: value,
|
|
81
72
|
formattedDateString: displayValue,
|
|
82
73
|
},
|
|
83
|
-
|
|
74
|
+
inputProps
|
|
84
75
|
)
|
|
85
76
|
: undefined
|
|
86
77
|
}
|
|
@@ -95,7 +86,7 @@ const DatePickerAndroid = ({
|
|
|
95
86
|
onChange={onChange}
|
|
96
87
|
variant={variant}
|
|
97
88
|
/>
|
|
98
|
-
</
|
|
89
|
+
</TouchableOpacity>
|
|
99
90
|
);
|
|
100
91
|
};
|
|
101
92
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useCallback } from 'react';
|
|
2
|
-
import { Platform, ScrollView, View } from 'react-native';
|
|
2
|
+
import { Platform, ScrollView, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import BottomSheet from '../BottomSheet';
|
|
5
5
|
import Button from '../Button';
|
|
@@ -8,8 +8,7 @@ import type { CalendarProps } from '../Calendar/types';
|
|
|
8
8
|
import TextInput from '../TextInput';
|
|
9
9
|
import useCalculateDate from './hooks/useCalculateDate';
|
|
10
10
|
import useFormatDate from './hooks/useFormatDate';
|
|
11
|
-
import {
|
|
12
|
-
import type { InternalDatePickerProps } from './types';
|
|
11
|
+
import type { DatePickerProps } from './types';
|
|
13
12
|
|
|
14
13
|
const InternalCalendar = ({
|
|
15
14
|
minDate,
|
|
@@ -82,10 +81,7 @@ const DatePickerCalendar = ({
|
|
|
82
81
|
supportedOrientations = ['portrait'],
|
|
83
82
|
renderSelectedValue,
|
|
84
83
|
locale,
|
|
85
|
-
|
|
86
|
-
inputProps,
|
|
87
|
-
groupStyleEnabled = false,
|
|
88
|
-
}: Omit<InternalDatePickerProps, 'variant'>) => {
|
|
84
|
+
}: Omit<DatePickerProps, 'variant'>) => {
|
|
89
85
|
const [open, setOpen] = useState(false);
|
|
90
86
|
const [monthPickerVisible, setMonthPickerVisible] = useState(false);
|
|
91
87
|
const shouldHideToolbar = Platform.OS === 'ios' && monthPickerVisible;
|
|
@@ -100,23 +96,18 @@ const DatePickerCalendar = ({
|
|
|
100
96
|
|
|
101
97
|
useCalculateDate({ minDate, maxDate, onChange, value });
|
|
102
98
|
|
|
103
|
-
const InputComponent = TextInputComponent || TextInput;
|
|
104
|
-
|
|
105
99
|
const onPress = useCallback(() => {
|
|
106
100
|
setOpen(true);
|
|
107
101
|
}, []);
|
|
108
102
|
|
|
109
103
|
return (
|
|
110
|
-
<
|
|
104
|
+
<TouchableOpacity
|
|
111
105
|
onPress={onPress}
|
|
112
106
|
disabled={disabled}
|
|
113
|
-
themeGroupStyleEnabled={groupStyleEnabled}
|
|
114
|
-
themeHasError={!!error}
|
|
115
107
|
testID="date-picker-calendar-touchable-opacity"
|
|
116
108
|
>
|
|
117
109
|
<View pointerEvents="none" testID="datePickerCalendar">
|
|
118
|
-
<
|
|
119
|
-
{...inputProps}
|
|
110
|
+
<TextInput
|
|
120
111
|
label={label}
|
|
121
112
|
value={displayValue}
|
|
122
113
|
suffix="calendar-dates-outlined"
|
|
@@ -129,13 +120,13 @@ const DatePickerCalendar = ({
|
|
|
129
120
|
style={style}
|
|
130
121
|
renderInputValue={
|
|
131
122
|
renderSelectedValue !== undefined && !!value
|
|
132
|
-
? (
|
|
123
|
+
? (inputProps) =>
|
|
133
124
|
renderSelectedValue(
|
|
134
125
|
{
|
|
135
126
|
date: value,
|
|
136
127
|
formattedDateString: displayValue,
|
|
137
128
|
},
|
|
138
|
-
|
|
129
|
+
inputProps
|
|
139
130
|
)
|
|
140
131
|
: undefined
|
|
141
132
|
}
|
|
@@ -173,7 +164,7 @@ const DatePickerCalendar = ({
|
|
|
173
164
|
/>
|
|
174
165
|
</ScrollView>
|
|
175
166
|
</BottomSheet>
|
|
176
|
-
</
|
|
167
|
+
</TouchableOpacity>
|
|
177
168
|
);
|
|
178
169
|
};
|
|
179
170
|
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import React, { useState, useCallback } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
2
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { useLocale } from '../LocaleProvider/hooks';
|
|
5
5
|
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 {
|
|
10
|
-
import type { InternalDatePickerProps } from './types';
|
|
9
|
+
import type { DatePickerProps } from './types';
|
|
11
10
|
|
|
12
11
|
type DatePickerIOSProps = Omit<
|
|
13
|
-
|
|
12
|
+
DatePickerProps,
|
|
14
13
|
'variant' | 'monthPickerConfirmLabel' | 'monthPickerCancelLabel'
|
|
15
14
|
> & {
|
|
16
15
|
variant?: 'default' | 'month-year';
|
|
@@ -34,9 +33,6 @@ const DatePickerIOS = ({
|
|
|
34
33
|
variant = 'default',
|
|
35
34
|
locale,
|
|
36
35
|
renderSelectedValue,
|
|
37
|
-
TextInputComponent,
|
|
38
|
-
inputProps,
|
|
39
|
-
groupStyleEnabled = false,
|
|
40
36
|
}: DatePickerIOSProps) => {
|
|
41
37
|
const [open, setOpen] = useState(false);
|
|
42
38
|
const { lang: defaultLocale } = useLocale();
|
|
@@ -48,23 +44,18 @@ const DatePickerIOS = ({
|
|
|
48
44
|
|
|
49
45
|
useCalculateDate({ minDate, maxDate, onChange, value });
|
|
50
46
|
|
|
51
|
-
const InputComponent = TextInputComponent || TextInput;
|
|
52
|
-
|
|
53
47
|
const onPress = useCallback(() => {
|
|
54
48
|
setOpen(true);
|
|
55
49
|
}, []);
|
|
56
50
|
|
|
57
51
|
return (
|
|
58
|
-
<
|
|
52
|
+
<TouchableOpacity
|
|
59
53
|
onPress={onPress}
|
|
60
54
|
disabled={disabled}
|
|
61
|
-
themeGroupStyleEnabled={groupStyleEnabled}
|
|
62
|
-
themeHasError={!!error}
|
|
63
55
|
testID="date-picker-ios-touchable-opacity"
|
|
64
56
|
>
|
|
65
57
|
<View pointerEvents="none" testID="datePickerInputIOS">
|
|
66
|
-
<
|
|
67
|
-
{...inputProps}
|
|
58
|
+
<TextInput
|
|
68
59
|
label={label}
|
|
69
60
|
value={displayValue}
|
|
70
61
|
suffix="calendar-dates-outlined"
|
|
@@ -77,13 +68,13 @@ const DatePickerIOS = ({
|
|
|
77
68
|
style={style}
|
|
78
69
|
renderInputValue={
|
|
79
70
|
renderSelectedValue !== undefined && !!value
|
|
80
|
-
? (
|
|
71
|
+
? (inputProps) =>
|
|
81
72
|
renderSelectedValue(
|
|
82
73
|
{
|
|
83
74
|
date: value,
|
|
84
75
|
formattedDateString: displayValue,
|
|
85
76
|
},
|
|
86
|
-
|
|
77
|
+
inputProps
|
|
87
78
|
)
|
|
88
79
|
: undefined
|
|
89
80
|
}
|
|
@@ -102,7 +93,7 @@ const DatePickerIOS = ({
|
|
|
102
93
|
minDate={minDate}
|
|
103
94
|
maxDate={maxDate}
|
|
104
95
|
/>
|
|
105
|
-
</
|
|
96
|
+
</TouchableOpacity>
|
|
106
97
|
);
|
|
107
98
|
};
|
|
108
99
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled from '@emotion/native';
|
|
2
|
-
import { View
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
import type { ViewProps } from 'react-native';
|
|
4
4
|
|
|
5
5
|
const StyledPickerWrapper = styled(View)<ViewProps>(({ theme }) => ({
|
|
@@ -7,21 +7,4 @@ const StyledPickerWrapper = styled(View)<ViewProps>(({ theme }) => ({
|
|
|
7
7
|
alignItems: 'center',
|
|
8
8
|
}));
|
|
9
9
|
|
|
10
|
-
|
|
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 };
|
|
10
|
+
export { StyledPickerWrapper };
|
|
@@ -3,7 +3,6 @@ import type {
|
|
|
3
3
|
StyleProp,
|
|
4
4
|
ViewStyle,
|
|
5
5
|
} from 'react-native';
|
|
6
|
-
import type { TextInputProps } from '../TextInput';
|
|
7
6
|
|
|
8
7
|
export interface DatePickerProps {
|
|
9
8
|
/**
|
|
@@ -101,19 +100,3 @@ export interface DatePickerProps {
|
|
|
101
100
|
props?: NativeTextInputProps
|
|
102
101
|
) => React.ReactNode;
|
|
103
102
|
}
|
|
104
|
-
|
|
105
|
-
// Add an internal prop type for TextInputComponent, not exported
|
|
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
|
-
*/
|
|
118
|
-
TextInputComponent?: React.ComponentType<TextInputProps>;
|
|
119
|
-
}
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
TextInputProps as NativeTextInputProps,
|
|
4
4
|
SectionList,
|
|
5
5
|
} from 'react-native';
|
|
6
|
-
import { View } from 'react-native';
|
|
6
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
7
7
|
import { useKeyboard } from '../../../utils/helpers';
|
|
8
8
|
import BottomSheet from '../../BottomSheet';
|
|
9
9
|
import Box from '../../Box';
|
|
@@ -11,7 +11,7 @@ import type { TextInputProps } from '../../TextInput';
|
|
|
11
11
|
import TextInput from '../../TextInput';
|
|
12
12
|
import Footer from '../Footer';
|
|
13
13
|
import { getScrollParams, toFlatOptions, toSections } from '../helpers';
|
|
14
|
-
import { StyledSearchBar
|
|
14
|
+
import { StyledSearchBar } from '../StyledSelect';
|
|
15
15
|
import type { SectionType, SelectOptionType, SelectProps } from '../types';
|
|
16
16
|
import OptionList from './OptionList';
|
|
17
17
|
import { isOptionSelected } from './utils';
|
|
@@ -53,15 +53,6 @@ export interface MultiSelectProps<
|
|
|
53
53
|
supportedOrientations?: ('portrait' | 'landscape')[];
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// Add an internal prop type for TextInputComponent, not exported
|
|
57
|
-
export interface InternalMultiSelectProps<
|
|
58
|
-
V,
|
|
59
|
-
T extends SelectOptionType<V> = SelectOptionType<V>
|
|
60
|
-
> extends MultiSelectProps<V, T> {
|
|
61
|
-
TextInputComponent?: React.ComponentType<TextInputProps>;
|
|
62
|
-
groupStyleEnabled?: boolean;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
56
|
function MultiSelect<V, T extends SelectOptionType<V>>({
|
|
66
57
|
footerLabel,
|
|
67
58
|
label,
|
|
@@ -84,9 +75,7 @@ function MultiSelect<V, T extends SelectOptionType<V>>({
|
|
|
84
75
|
value,
|
|
85
76
|
supportedOrientations = ['portrait'],
|
|
86
77
|
bottomSheetConfig = {},
|
|
87
|
-
|
|
88
|
-
...rest
|
|
89
|
-
}: InternalMultiSelectProps<V, T>) {
|
|
78
|
+
}: MultiSelectProps<V, T>) {
|
|
90
79
|
const { isKeyboardVisible, keyboardHeight } = useKeyboard();
|
|
91
80
|
const [open, setOpen] = useState(false);
|
|
92
81
|
const [selectingValue, setSelectingValue] = useState(value);
|
|
@@ -101,8 +90,6 @@ function MultiSelect<V, T extends SelectOptionType<V>>({
|
|
|
101
90
|
const { variant: bottomSheetVariant, header: bottomSheetHeader } =
|
|
102
91
|
bottomSheetConfig;
|
|
103
92
|
|
|
104
|
-
const TextInputComponent = rest.TextInputComponent || TextInput;
|
|
105
|
-
|
|
106
93
|
const onPress = useCallback(() => {
|
|
107
94
|
setOpen(true);
|
|
108
95
|
}, []);
|
|
@@ -122,17 +109,15 @@ function MultiSelect<V, T extends SelectOptionType<V>>({
|
|
|
122
109
|
!editable || disabled || inputProps?.loading ? 'none' : 'auto'
|
|
123
110
|
}
|
|
124
111
|
>
|
|
125
|
-
<
|
|
112
|
+
<TouchableOpacity
|
|
126
113
|
onPress={onPress}
|
|
127
|
-
themeGroupStyleEnabled={groupStyleEnabled}
|
|
128
|
-
themeHasError={!!error}
|
|
129
114
|
testID="multi-select-touchable-opacity"
|
|
130
115
|
>
|
|
131
116
|
{
|
|
132
117
|
// prevent users from focusing TextInput
|
|
133
118
|
}
|
|
134
119
|
<View pointerEvents="none">
|
|
135
|
-
<
|
|
120
|
+
<TextInput
|
|
136
121
|
{...inputProps}
|
|
137
122
|
label={label}
|
|
138
123
|
value={renderSelectedValue ? rawValue : displayedValue}
|
|
@@ -147,12 +132,13 @@ function MultiSelect<V, T extends SelectOptionType<V>>({
|
|
|
147
132
|
testID={testID}
|
|
148
133
|
renderInputValue={
|
|
149
134
|
renderSelectedValue !== undefined && rawValue?.length > 0
|
|
150
|
-
? (
|
|
135
|
+
? (nativeInputProps) =>
|
|
136
|
+
renderSelectedValue(value, nativeInputProps)
|
|
151
137
|
: undefined
|
|
152
138
|
}
|
|
153
139
|
/>
|
|
154
140
|
</View>
|
|
155
|
-
</
|
|
141
|
+
</TouchableOpacity>
|
|
156
142
|
</View>
|
|
157
143
|
<BottomSheet
|
|
158
144
|
variant={bottomSheetVariant || 'fixed'}
|
|
@@ -193,7 +179,7 @@ function MultiSelect<V, T extends SelectOptionType<V>>({
|
|
|
193
179
|
>
|
|
194
180
|
{onQueryChange && (
|
|
195
181
|
<StyledSearchBar>
|
|
196
|
-
<
|
|
182
|
+
<TextInput
|
|
197
183
|
editable
|
|
198
184
|
placeholder="Search"
|
|
199
185
|
suffix="search-outlined"
|
|
@@ -3,13 +3,13 @@ import type {
|
|
|
3
3
|
TextInputProps as NativeTextInputProps,
|
|
4
4
|
SectionList,
|
|
5
5
|
} from 'react-native';
|
|
6
|
-
import { View } from 'react-native';
|
|
6
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
7
7
|
import { deepCompareValue, useKeyboard } from '../../../utils/helpers';
|
|
8
8
|
import BottomSheet from '../../BottomSheet';
|
|
9
9
|
import type { TextInputProps } from '../../TextInput';
|
|
10
10
|
import TextInput from '../../TextInput';
|
|
11
11
|
import { getScrollParams, toFlatOptions, toSections } from '../helpers';
|
|
12
|
-
import { StyledSearchBar
|
|
12
|
+
import { StyledSearchBar } from '../StyledSelect';
|
|
13
13
|
import type { SectionType, SelectOptionType, SelectProps } from '../types';
|
|
14
14
|
import OptionList from './OptionList';
|
|
15
15
|
|
|
@@ -38,15 +38,6 @@ export interface SingleSelectProps<
|
|
|
38
38
|
supportedOrientations?: ('portrait' | 'landscape')[];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// Add an internal prop type for TextInputComponent, not exported
|
|
42
|
-
export interface InternalSingleSelectProps<
|
|
43
|
-
V,
|
|
44
|
-
T extends SelectOptionType<V> = SelectOptionType<V>
|
|
45
|
-
> extends SingleSelectProps<V, T> {
|
|
46
|
-
TextInputComponent?: React.ComponentType<TextInputProps>;
|
|
47
|
-
groupStyleEnabled?: boolean;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
41
|
const SingleSelect = <V, T extends SelectOptionType<V>>({
|
|
51
42
|
label,
|
|
52
43
|
loading = false,
|
|
@@ -68,9 +59,7 @@ const SingleSelect = <V, T extends SelectOptionType<V>>({
|
|
|
68
59
|
value,
|
|
69
60
|
supportedOrientations = ['portrait'],
|
|
70
61
|
bottomSheetConfig = {},
|
|
71
|
-
|
|
72
|
-
...rest
|
|
73
|
-
}: InternalSingleSelectProps<V, T>) => {
|
|
62
|
+
}: SingleSelectProps<V, T>) => {
|
|
74
63
|
const { isKeyboardVisible, keyboardHeight } = useKeyboard();
|
|
75
64
|
const [open, setOpen] = useState(false);
|
|
76
65
|
const sectionListRef = useRef<SectionList<T, SectionType>>(null);
|
|
@@ -84,8 +73,6 @@ const SingleSelect = <V, T extends SelectOptionType<V>>({
|
|
|
84
73
|
const { variant: bottomSheetVariant, header: bottomSheetHeader } =
|
|
85
74
|
bottomSheetConfig;
|
|
86
75
|
|
|
87
|
-
const TextInputComponent = rest.TextInputComponent || TextInput;
|
|
88
|
-
|
|
89
76
|
const onPress = useCallback(() => {
|
|
90
77
|
setOpen(true);
|
|
91
78
|
}, []);
|
|
@@ -105,17 +92,15 @@ const SingleSelect = <V, T extends SelectOptionType<V>>({
|
|
|
105
92
|
!editable || disabled || inputProps?.loading ? 'none' : 'auto'
|
|
106
93
|
}
|
|
107
94
|
>
|
|
108
|
-
<
|
|
95
|
+
<TouchableOpacity
|
|
109
96
|
onPress={onPress}
|
|
110
|
-
themeGroupStyleEnabled={groupStyleEnabled}
|
|
111
|
-
themeHasError={!!error}
|
|
112
97
|
testID="single-select-touchable-opacity"
|
|
113
98
|
>
|
|
114
99
|
{
|
|
115
100
|
// prevent users from focusing TextInput
|
|
116
101
|
}
|
|
117
102
|
<View pointerEvents="none">
|
|
118
|
-
<
|
|
103
|
+
<TextInput
|
|
119
104
|
{...inputProps}
|
|
120
105
|
label={label}
|
|
121
106
|
value={renderSelectedValue ? rawValue : displayedValue}
|
|
@@ -130,12 +115,13 @@ const SingleSelect = <V, T extends SelectOptionType<V>>({
|
|
|
130
115
|
testID={testID}
|
|
131
116
|
renderInputValue={
|
|
132
117
|
renderSelectedValue !== undefined && !!rawValue
|
|
133
|
-
? (
|
|
118
|
+
? (nativeInputProps) =>
|
|
119
|
+
renderSelectedValue(value, nativeInputProps)
|
|
134
120
|
: undefined
|
|
135
121
|
}
|
|
136
122
|
/>
|
|
137
123
|
</View>
|
|
138
|
-
</
|
|
124
|
+
</TouchableOpacity>
|
|
139
125
|
</View>
|
|
140
126
|
<BottomSheet
|
|
141
127
|
variant={bottomSheetVariant || 'fixed'}
|
|
@@ -158,7 +144,7 @@ const SingleSelect = <V, T extends SelectOptionType<V>>({
|
|
|
158
144
|
>
|
|
159
145
|
{onQueryChange && (
|
|
160
146
|
<StyledSearchBar>
|
|
161
|
-
<
|
|
147
|
+
<TextInput
|
|
162
148
|
editable
|
|
163
149
|
placeholder="Search"
|
|
164
150
|
suffix="search-outlined"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SectionList,
|
|
1
|
+
import { SectionList, View } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
3
|
|
|
4
4
|
const SectionSpacer = styled(View)(({ theme }) => ({
|
|
@@ -19,27 +19,4 @@ const StyledSectionList = styled(SectionList)(({ theme }) => ({
|
|
|
19
19
|
paddingHorizontal: theme.__hd__.select.space.optionListHorizontalPadding,
|
|
20
20
|
})) as unknown as typeof SectionList;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
if (themeHasError) {
|
|
24
|
-
return 1;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return 0;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const StyledTouchableOpacity = styled(TouchableOpacity)<{
|
|
31
|
-
themeGroupStyleEnabled: boolean;
|
|
32
|
-
themeHasError: boolean;
|
|
33
|
-
}>(({ themeGroupStyleEnabled, themeHasError }) => ({
|
|
34
|
-
...(themeGroupStyleEnabled && {
|
|
35
|
-
zIndex: getZIndexByState({ themeHasError }),
|
|
36
|
-
}),
|
|
37
|
-
}));
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
SectionSpacer,
|
|
41
|
-
OptionSpacer,
|
|
42
|
-
StyledSearchBar,
|
|
43
|
-
StyledSectionList,
|
|
44
|
-
StyledTouchableOpacity,
|
|
45
|
-
};
|
|
22
|
+
export { SectionSpacer, OptionSpacer, StyledSearchBar, StyledSectionList };
|
|
@@ -10,17 +10,11 @@ type SingleSelectType = <
|
|
|
10
10
|
V,
|
|
11
11
|
T extends SelectOptionType<V> = SelectOptionType<V>
|
|
12
12
|
>(
|
|
13
|
-
props:
|
|
14
|
-
SingleSelectProps<V, T>,
|
|
15
|
-
'TextInputComponent' | 'groupStyleEnabled'
|
|
16
|
-
>
|
|
13
|
+
props: SingleSelectProps<V, T>
|
|
17
14
|
) => React.ReactElement;
|
|
18
15
|
|
|
19
16
|
type MultiSelectType = <V, T extends SelectOptionType<V> = SelectOptionType<V>>(
|
|
20
|
-
props:
|
|
21
|
-
MultiSelectProps<V, T>,
|
|
22
|
-
'TextInputComponent' | 'groupStyleEnabled'
|
|
23
|
-
>
|
|
17
|
+
props: MultiSelectProps<V, T>
|
|
24
18
|
) => React.ReactElement;
|
|
25
19
|
|
|
26
20
|
export default Object.assign(SingleSelect as SingleSelectType, {
|
|
@@ -102,8 +102,4 @@ export interface SelectProps<V, T extends SelectOptionType<V>>
|
|
|
102
102
|
variant?: BottomSheetProps['variant'];
|
|
103
103
|
header?: BottomSheetProps['header'];
|
|
104
104
|
};
|
|
105
|
-
/**
|
|
106
|
-
* Inject a custom TextInput component (e.g., from rn-work-uikit). Defaults to local TextInput.
|
|
107
|
-
*/
|
|
108
|
-
TextInputComponent?: React.ComponentType<TextInputProps>;
|
|
109
105
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled from '@emotion/native';
|
|
2
|
-
import { View
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
import type { ViewProps } from 'react-native';
|
|
4
4
|
|
|
5
5
|
const StyledPickerWrapper = styled(View)<ViewProps>(({ theme }) => ({
|
|
@@ -7,21 +7,4 @@ const StyledPickerWrapper = styled(View)<ViewProps>(({ theme }) => ({
|
|
|
7
7
|
alignItems: 'center',
|
|
8
8
|
}));
|
|
9
9
|
|
|
10
|
-
|
|
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 };
|
|
10
|
+
export { StyledPickerWrapper };
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
import TimePickerAndroid from './TimePickerAndroid';
|
|
4
4
|
import TimePickerIOS from './TimePickerIOS';
|
|
5
|
-
import type {
|
|
5
|
+
import type { TimePickerProps } from './types';
|
|
6
6
|
|
|
7
|
-
const TimePicker = (props:
|
|
7
|
+
const TimePicker = (props: TimePickerProps) => {
|
|
8
8
|
if (Platform.OS === 'ios') {
|
|
9
9
|
return <TimePickerIOS {...props} />;
|
|
10
10
|
}
|