@hero-design/rn 7.16.1 → 7.17.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.
- package/.turbo/turbo-build.log +2 -2
- package/es/index.js +228 -187
- package/lib/index.js +227 -186
- package/package.json +2 -2
- package/src/components/DatePicker/DatePickerIOS.tsx +2 -2
- package/src/components/List/BasicListItem.tsx +8 -4
- package/src/components/List/StyledBasicListItem.tsx +2 -2
- package/src/components/Select/MultiSelect/Option.tsx +21 -15
- package/src/components/Select/MultiSelect/OptionList.tsx +47 -41
- package/src/components/Select/MultiSelect/__tests__/OptionList.spec.tsx +25 -14
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +41 -21
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1995 -352
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5611 -523
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +122 -1
- package/src/components/Select/MultiSelect/index.tsx +26 -36
- package/src/components/Select/SingleSelect/Option.tsx +20 -13
- package/src/components/Select/SingleSelect/OptionList.tsx +47 -39
- package/src/components/Select/SingleSelect/__tests__/OptionList.spec.tsx +23 -12
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +23 -14
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1846 -258
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +5140 -412
- package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +117 -1
- package/src/components/Select/SingleSelect/index.tsx +26 -37
- package/src/components/Select/StyledOptionList.tsx +43 -44
- package/src/components/Select/StyledSelect.tsx +6 -15
- package/src/components/Select/__tests__/StyledSelect.spec.tsx +1 -23
- package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +0 -67
- package/src/components/Select/__tests__/helpers.spec.tsx +74 -0
- package/src/components/Select/helpers.tsx +87 -4
- package/src/components/Select/types.ts +99 -0
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +157 -1
- package/src/components/TextInput/__tests__/index.spec.tsx +29 -8
- package/src/components/TextInput/index.tsx +18 -7
- package/src/components/TimePicker/TimePickerIOS.tsx +2 -2
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +3 -5
- package/src/theme/components/select.ts +3 -5
- package/src/types.ts +7 -1
- package/types/components/List/BasicListItem.d.ts +1 -1
- package/types/components/Select/MultiSelect/Option.d.ts +4 -2
- package/types/components/Select/MultiSelect/OptionList.d.ts +6 -7
- package/types/components/Select/MultiSelect/index.d.ts +5 -5
- package/types/components/Select/SingleSelect/Option.d.ts +4 -2
- package/types/components/Select/SingleSelect/OptionList.d.ts +6 -7
- package/types/components/Select/SingleSelect/index.d.ts +5 -5
- package/types/components/Select/StyledOptionList.d.ts +10 -16
- package/types/components/Select/StyledSelect.d.ts +5 -7
- package/types/components/Select/__tests__/helpers.spec.d.ts +1 -0
- package/types/components/Select/helpers.d.ts +14 -2
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/Select/types.d.ts +32 -7
- package/types/components/TextInput/index.d.ts +4 -2
- package/types/theme/components/select.d.ts +3 -5
- package/types/types.d.ts +2 -1
- package/src/components/Select/types.tsx +0 -52
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ListRenderItemInfo,
|
|
4
|
+
SectionListData,
|
|
5
|
+
SectionListRenderItemInfo,
|
|
6
|
+
StyleProp,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import { TextInputProps } from '../TextInput';
|
|
10
|
+
|
|
11
|
+
export type OptionType<V> = {
|
|
12
|
+
value: V;
|
|
13
|
+
text: string;
|
|
14
|
+
key?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type SectionType = { category: string };
|
|
19
|
+
export type SectionData<V, T extends OptionType<V>> = SectionListData<
|
|
20
|
+
T,
|
|
21
|
+
SectionType
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export type CombinedOptionsType<V, T extends OptionType<V>> =
|
|
25
|
+
| T[]
|
|
26
|
+
| SectionData<V, T>[];
|
|
27
|
+
|
|
28
|
+
export type ListRenderOptionInfo<
|
|
29
|
+
V,
|
|
30
|
+
T extends OptionType<V>
|
|
31
|
+
> = ListRenderItemInfo<T> & { selected: boolean; onPress: () => void };
|
|
32
|
+
|
|
33
|
+
export type SectionListRenderOptionInfo<
|
|
34
|
+
V,
|
|
35
|
+
T extends OptionType<V>
|
|
36
|
+
> = SectionListRenderItemInfo<T, SectionType> & {
|
|
37
|
+
selected: boolean;
|
|
38
|
+
onPress: () => void;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export interface SelectProps<V, T extends OptionType<V>>
|
|
42
|
+
extends Pick<
|
|
43
|
+
TextInputProps,
|
|
44
|
+
'editable' | 'disabled' | 'numberOfLines' | 'error'
|
|
45
|
+
> {
|
|
46
|
+
/**
|
|
47
|
+
* An array of options to be selected.
|
|
48
|
+
*/
|
|
49
|
+
options: CombinedOptionsType<V, T>;
|
|
50
|
+
/**
|
|
51
|
+
* Customize option renderer.
|
|
52
|
+
*/
|
|
53
|
+
renderOption?:
|
|
54
|
+
| ((info: ListRenderOptionInfo<V, T>) => ReactElement)
|
|
55
|
+
| ((info: SectionListRenderOptionInfo<V, T>) => ReactElement);
|
|
56
|
+
/**
|
|
57
|
+
* Used to extract a unique key for a given option at the specified index. Key is used for caching and as the react key to track item re-ordering.
|
|
58
|
+
* The default extractor checks option.key, and then falls back to using the index, like React does.
|
|
59
|
+
*/
|
|
60
|
+
keyExtractor?: (option: T, index?: number) => string;
|
|
61
|
+
/**
|
|
62
|
+
* Current search value.
|
|
63
|
+
*/
|
|
64
|
+
query?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Search bar onChangeText event handler
|
|
67
|
+
*/
|
|
68
|
+
onQueryChange?: (value: string) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Event handler when selection dismiss
|
|
71
|
+
*/
|
|
72
|
+
onDimiss?: () => void;
|
|
73
|
+
/**
|
|
74
|
+
* Event handler when end of the list reached
|
|
75
|
+
*/
|
|
76
|
+
onEndReached?: () => void;
|
|
77
|
+
/**
|
|
78
|
+
* Show loading indicator at bottom of option list
|
|
79
|
+
*/
|
|
80
|
+
loading?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Props that are passed to TextInput.
|
|
83
|
+
*/
|
|
84
|
+
inputProps?: {
|
|
85
|
+
loading?: boolean;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Field label.
|
|
89
|
+
*/
|
|
90
|
+
label: string;
|
|
91
|
+
/**
|
|
92
|
+
* Additional style.
|
|
93
|
+
*/
|
|
94
|
+
style?: StyleProp<ViewStyle>;
|
|
95
|
+
/**
|
|
96
|
+
* Testing id of the component.
|
|
97
|
+
*/
|
|
98
|
+
testID?: string;
|
|
99
|
+
}
|
|
@@ -1754,6 +1754,162 @@ exports[`TextInput idle with suffix and prefix are React Element renders correct
|
|
|
1754
1754
|
</View>
|
|
1755
1755
|
`;
|
|
1756
1756
|
|
|
1757
|
+
exports[`TextInput loading renders correctly 1`] = `
|
|
1758
|
+
<View
|
|
1759
|
+
pointerEvents="none"
|
|
1760
|
+
style={
|
|
1761
|
+
Array [
|
|
1762
|
+
Object {
|
|
1763
|
+
"marginVertical": 8,
|
|
1764
|
+
"width": "100%",
|
|
1765
|
+
},
|
|
1766
|
+
undefined,
|
|
1767
|
+
]
|
|
1768
|
+
}
|
|
1769
|
+
>
|
|
1770
|
+
<View
|
|
1771
|
+
style={
|
|
1772
|
+
Array [
|
|
1773
|
+
Object {
|
|
1774
|
+
"alignItems": "center",
|
|
1775
|
+
"flexDirection": "row",
|
|
1776
|
+
"padding": 16,
|
|
1777
|
+
},
|
|
1778
|
+
undefined,
|
|
1779
|
+
]
|
|
1780
|
+
}
|
|
1781
|
+
>
|
|
1782
|
+
<View
|
|
1783
|
+
style={
|
|
1784
|
+
Array [
|
|
1785
|
+
Object {
|
|
1786
|
+
"borderColor": "#8b8d92",
|
|
1787
|
+
"borderRadius": 8,
|
|
1788
|
+
"borderWidth": 1,
|
|
1789
|
+
"bottom": 0,
|
|
1790
|
+
"left": 0,
|
|
1791
|
+
"position": "absolute",
|
|
1792
|
+
"right": 0,
|
|
1793
|
+
"top": 0,
|
|
1794
|
+
},
|
|
1795
|
+
undefined,
|
|
1796
|
+
]
|
|
1797
|
+
}
|
|
1798
|
+
themeVariant="readonly"
|
|
1799
|
+
/>
|
|
1800
|
+
<View
|
|
1801
|
+
style={
|
|
1802
|
+
Array [
|
|
1803
|
+
Object {
|
|
1804
|
+
"alignItems": "center",
|
|
1805
|
+
"alignSelf": "stretch",
|
|
1806
|
+
"flexDirection": "row",
|
|
1807
|
+
"flexGrow": 2,
|
|
1808
|
+
},
|
|
1809
|
+
undefined,
|
|
1810
|
+
]
|
|
1811
|
+
}
|
|
1812
|
+
>
|
|
1813
|
+
<View
|
|
1814
|
+
pointerEvents="none"
|
|
1815
|
+
style={
|
|
1816
|
+
Array [
|
|
1817
|
+
Object {
|
|
1818
|
+
"alignItems": "center",
|
|
1819
|
+
"bottom": 0,
|
|
1820
|
+
"flexDirection": "row",
|
|
1821
|
+
"left": 0,
|
|
1822
|
+
"position": "absolute",
|
|
1823
|
+
"right": 0,
|
|
1824
|
+
"top": 0,
|
|
1825
|
+
"zIndex": 9999,
|
|
1826
|
+
},
|
|
1827
|
+
undefined,
|
|
1828
|
+
]
|
|
1829
|
+
}
|
|
1830
|
+
/>
|
|
1831
|
+
<TextInput
|
|
1832
|
+
accessibilityState={
|
|
1833
|
+
Object {
|
|
1834
|
+
"disabled": true,
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
editable={true}
|
|
1838
|
+
onBlur={[Function]}
|
|
1839
|
+
onChangeText={[Function]}
|
|
1840
|
+
onFocus={[Function]}
|
|
1841
|
+
style={
|
|
1842
|
+
Array [
|
|
1843
|
+
Object {
|
|
1844
|
+
"alignSelf": "stretch",
|
|
1845
|
+
"flexGrow": 2,
|
|
1846
|
+
"fontSize": 14,
|
|
1847
|
+
"marginHorizontal": 8,
|
|
1848
|
+
"textAlignVertical": "center",
|
|
1849
|
+
},
|
|
1850
|
+
Object {
|
|
1851
|
+
"color": "#292a2b",
|
|
1852
|
+
},
|
|
1853
|
+
]
|
|
1854
|
+
}
|
|
1855
|
+
testID="text-input"
|
|
1856
|
+
/>
|
|
1857
|
+
</View>
|
|
1858
|
+
<View
|
|
1859
|
+
collapsable={false}
|
|
1860
|
+
nativeID="animatedComponent"
|
|
1861
|
+
style={
|
|
1862
|
+
Object {
|
|
1863
|
+
"transform": Array [
|
|
1864
|
+
Object {
|
|
1865
|
+
"rotate": "0deg",
|
|
1866
|
+
},
|
|
1867
|
+
],
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
>
|
|
1871
|
+
<HeroIcon
|
|
1872
|
+
name="loading"
|
|
1873
|
+
style={
|
|
1874
|
+
Array [
|
|
1875
|
+
Object {
|
|
1876
|
+
"color": "#292a2b",
|
|
1877
|
+
"fontSize": 16,
|
|
1878
|
+
},
|
|
1879
|
+
undefined,
|
|
1880
|
+
]
|
|
1881
|
+
}
|
|
1882
|
+
testID="input-suffix"
|
|
1883
|
+
themeIntent="text"
|
|
1884
|
+
themeSize="xsmall"
|
|
1885
|
+
/>
|
|
1886
|
+
</View>
|
|
1887
|
+
</View>
|
|
1888
|
+
<View
|
|
1889
|
+
style={
|
|
1890
|
+
Array [
|
|
1891
|
+
Object {
|
|
1892
|
+
"paddingLeft": 16,
|
|
1893
|
+
},
|
|
1894
|
+
undefined,
|
|
1895
|
+
]
|
|
1896
|
+
}
|
|
1897
|
+
>
|
|
1898
|
+
<View
|
|
1899
|
+
style={
|
|
1900
|
+
Array [
|
|
1901
|
+
Object {
|
|
1902
|
+
"flexDirection": "row",
|
|
1903
|
+
"justifyContent": "space-between",
|
|
1904
|
+
},
|
|
1905
|
+
undefined,
|
|
1906
|
+
]
|
|
1907
|
+
}
|
|
1908
|
+
/>
|
|
1909
|
+
</View>
|
|
1910
|
+
</View>
|
|
1911
|
+
`;
|
|
1912
|
+
|
|
1757
1913
|
exports[`TextInput max length renders correctly 1`] = `
|
|
1758
1914
|
<View
|
|
1759
1915
|
pointerEvents="auto"
|
|
@@ -2392,7 +2548,7 @@ exports[`TextInput readonly renders correctly 1`] = `
|
|
|
2392
2548
|
<TextInput
|
|
2393
2549
|
accessibilityState={
|
|
2394
2550
|
Object {
|
|
2395
|
-
"disabled":
|
|
2551
|
+
"disabled": true,
|
|
2396
2552
|
}
|
|
2397
2553
|
}
|
|
2398
2554
|
editable={false}
|
|
@@ -6,21 +6,30 @@ import TextInput, { getVariant } from '../index';
|
|
|
6
6
|
|
|
7
7
|
describe('getVariant', () => {
|
|
8
8
|
it.each`
|
|
9
|
-
disabled | error | editable | isFocused | isEmptyValue | expected
|
|
10
|
-
${false} | ${undefined} | ${true} | ${false} | ${true} | ${'default'}
|
|
11
|
-
${false} | ${undefined} | ${true} | ${false} | ${false} | ${'filled'}
|
|
12
|
-
${false} | ${undefined} | ${true} | ${true} | ${true} | ${'focused'}
|
|
13
|
-
${false} | ${undefined} | ${false} | ${true} | ${true} | ${'readonly'}
|
|
14
|
-
${false} | ${'This field is required'} | ${false} | ${true} | ${true} | ${'error'}
|
|
15
|
-
${true} | ${'This field is required'} | ${false} | ${true} | ${true} | ${'disabled'}
|
|
9
|
+
disabled | error | editable | loading | isFocused | isEmptyValue | expected
|
|
10
|
+
${false} | ${undefined} | ${true} | ${false} | ${false} | ${true} | ${'default'}
|
|
11
|
+
${false} | ${undefined} | ${true} | ${false} | ${false} | ${false} | ${'filled'}
|
|
12
|
+
${false} | ${undefined} | ${true} | ${false} | ${true} | ${true} | ${'focused'}
|
|
13
|
+
${false} | ${undefined} | ${false} | ${true} | ${true} | ${true} | ${'readonly'}
|
|
14
|
+
${false} | ${'This field is required'} | ${false} | ${false} | ${true} | ${true} | ${'error'}
|
|
15
|
+
${true} | ${'This field is required'} | ${false} | ${false} | ${true} | ${true} | ${'disabled'}
|
|
16
16
|
`(
|
|
17
17
|
'should return the correct variant when disabled $disabled, errorMessage $errorMessage, editable $false, isFocused $isFocused, isEmptyValue $isEmptyValue',
|
|
18
|
-
({
|
|
18
|
+
({
|
|
19
|
+
disabled,
|
|
20
|
+
error,
|
|
21
|
+
editable,
|
|
22
|
+
loading,
|
|
23
|
+
isFocused,
|
|
24
|
+
isEmptyValue,
|
|
25
|
+
expected,
|
|
26
|
+
}) => {
|
|
19
27
|
expect(
|
|
20
28
|
getVariant({
|
|
21
29
|
disabled,
|
|
22
30
|
error,
|
|
23
31
|
editable,
|
|
32
|
+
loading,
|
|
24
33
|
isFocused,
|
|
25
34
|
isEmptyValue,
|
|
26
35
|
})
|
|
@@ -206,6 +215,18 @@ describe('TextInput', () => {
|
|
|
206
215
|
});
|
|
207
216
|
});
|
|
208
217
|
|
|
218
|
+
describe('loading', () => {
|
|
219
|
+
it('renders correctly', () => {
|
|
220
|
+
const { toJSON, queryAllByTestId, getByTestId } = renderWithTheme(
|
|
221
|
+
<TextInput suffix="arrow-down" loading />
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
expect(toJSON()).toMatchSnapshot();
|
|
225
|
+
expect(queryAllByTestId('text-input')).toHaveLength(1);
|
|
226
|
+
expect(getByTestId('input-suffix')).toHaveProp('name', 'loading');
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
209
230
|
describe('max length', () => {
|
|
210
231
|
it('renders correctly', () => {
|
|
211
232
|
const {
|
|
@@ -79,6 +79,10 @@ export interface TextInputProps extends NativeTextInputProps {
|
|
|
79
79
|
* Whether the input is disabled.
|
|
80
80
|
*/
|
|
81
81
|
disabled?: boolean;
|
|
82
|
+
/*
|
|
83
|
+
* Whether the input is loading.
|
|
84
|
+
*/
|
|
85
|
+
loading?: boolean;
|
|
82
86
|
/*
|
|
83
87
|
* The max length of the input.
|
|
84
88
|
* If the max length is set, the input will display the current length and the max length.
|
|
@@ -94,12 +98,14 @@ export const getVariant = ({
|
|
|
94
98
|
disabled,
|
|
95
99
|
error,
|
|
96
100
|
editable,
|
|
101
|
+
loading,
|
|
97
102
|
isFocused,
|
|
98
103
|
isEmptyValue,
|
|
99
104
|
}: {
|
|
100
105
|
disabled?: boolean;
|
|
101
106
|
error?: string;
|
|
102
107
|
editable?: boolean;
|
|
108
|
+
loading: boolean;
|
|
103
109
|
isFocused?: boolean;
|
|
104
110
|
isEmptyValue?: boolean;
|
|
105
111
|
}): Variant => {
|
|
@@ -109,7 +115,7 @@ export const getVariant = ({
|
|
|
109
115
|
if (error) {
|
|
110
116
|
return 'error';
|
|
111
117
|
}
|
|
112
|
-
if (!editable) {
|
|
118
|
+
if (!editable || loading) {
|
|
113
119
|
return 'readonly';
|
|
114
120
|
}
|
|
115
121
|
if (isFocused) {
|
|
@@ -133,6 +139,7 @@ const TextInput = ({
|
|
|
133
139
|
required,
|
|
134
140
|
editable = true,
|
|
135
141
|
disabled = false,
|
|
142
|
+
loading = false,
|
|
136
143
|
maxLength,
|
|
137
144
|
helpText,
|
|
138
145
|
value,
|
|
@@ -142,6 +149,7 @@ const TextInput = ({
|
|
|
142
149
|
const textInputReference = useRef<RNTextInput | null>(null);
|
|
143
150
|
const displayText = (value !== undefined ? value : defaultValue) ?? '';
|
|
144
151
|
const isEmptyValue = displayText.length === 0;
|
|
152
|
+
const actualSuffix = loading ? 'loading' : suffix;
|
|
145
153
|
|
|
146
154
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
147
155
|
|
|
@@ -149,6 +157,7 @@ const TextInput = ({
|
|
|
149
157
|
disabled,
|
|
150
158
|
error,
|
|
151
159
|
editable,
|
|
160
|
+
loading,
|
|
152
161
|
isFocused,
|
|
153
162
|
isEmptyValue,
|
|
154
163
|
});
|
|
@@ -187,7 +196,7 @@ const TextInput = ({
|
|
|
187
196
|
)}
|
|
188
197
|
{typeof prefix === 'string' ? (
|
|
189
198
|
<Icon
|
|
190
|
-
intent={disabled ? 'disabled-text' : 'text'}
|
|
199
|
+
intent={variant === 'disabled' ? 'disabled-text' : 'text'}
|
|
191
200
|
testID="input-prefix"
|
|
192
201
|
icon={prefix}
|
|
193
202
|
size="xsmall"
|
|
@@ -195,7 +204,6 @@ const TextInput = ({
|
|
|
195
204
|
) : (
|
|
196
205
|
prefix
|
|
197
206
|
)}
|
|
198
|
-
|
|
199
207
|
<StyledTextInputAndLabelContainer>
|
|
200
208
|
{!isFocused && isEmptyValue && (
|
|
201
209
|
<StyledLabelContainerInsideTextInput pointerEvents="none">
|
|
@@ -224,7 +232,9 @@ const TextInput = ({
|
|
|
224
232
|
textStyle,
|
|
225
233
|
])}
|
|
226
234
|
testID="text-input"
|
|
227
|
-
accessibilityState={{
|
|
235
|
+
accessibilityState={{
|
|
236
|
+
disabled: variant === 'disabled' || variant === 'readonly',
|
|
237
|
+
}}
|
|
228
238
|
// @ts-ignore
|
|
229
239
|
accessibilityLabelledBy={accessibilityLabelledBy}
|
|
230
240
|
{...nativeProps}
|
|
@@ -249,11 +259,12 @@ const TextInput = ({
|
|
|
249
259
|
}
|
|
250
260
|
/>
|
|
251
261
|
</StyledTextInputAndLabelContainer>
|
|
252
|
-
{typeof
|
|
262
|
+
{typeof actualSuffix === 'string' ? (
|
|
253
263
|
<Icon
|
|
254
|
-
intent={disabled ? 'disabled-text' : 'text'}
|
|
264
|
+
intent={variant === 'disabled' ? 'disabled-text' : 'text'}
|
|
255
265
|
testID="input-suffix"
|
|
256
|
-
icon={
|
|
266
|
+
icon={actualSuffix}
|
|
267
|
+
spin={actualSuffix === 'loading'}
|
|
257
268
|
size="xsmall"
|
|
258
269
|
/>
|
|
259
270
|
) : (
|
|
@@ -23,7 +23,7 @@ const TimePickerIOS = ({
|
|
|
23
23
|
style,
|
|
24
24
|
testID,
|
|
25
25
|
}: TimePickerProps) => {
|
|
26
|
-
const [selectingDate, setSelectingDate] = useState<Date
|
|
26
|
+
const [selectingDate, setSelectingDate] = useState<Date>(value || new Date());
|
|
27
27
|
const [open, setOpen] = useState(false);
|
|
28
28
|
|
|
29
29
|
const is12Hour = displayFormat.includes('hh');
|
|
@@ -71,7 +71,7 @@ const TimePickerIOS = ({
|
|
|
71
71
|
<StyledPickerWrapper>
|
|
72
72
|
<DateTimePicker
|
|
73
73
|
testID="timePickerIOS"
|
|
74
|
-
value={selectingDate
|
|
74
|
+
value={selectingDate}
|
|
75
75
|
mode="time"
|
|
76
76
|
// Current prop is24Hour config only available for Android.
|
|
77
77
|
// This is a work around to get the picker to display 24 hour format for iOS.
|
|
@@ -552,21 +552,19 @@ Object {
|
|
|
552
552
|
},
|
|
553
553
|
"select": Object {
|
|
554
554
|
"colors": Object {
|
|
555
|
-
"checkedOption": "#f1e9fb",
|
|
556
555
|
"footerText": "#7622d7",
|
|
557
|
-
"option": "#ffffff",
|
|
558
556
|
},
|
|
559
557
|
"radii": Object {
|
|
560
558
|
"option": 4,
|
|
561
559
|
},
|
|
562
560
|
"space": Object {
|
|
563
561
|
"minimumOptionListHeight": 280,
|
|
564
|
-
"
|
|
565
|
-
"
|
|
566
|
-
"optionPadding": 16,
|
|
562
|
+
"optionHorizontalMargin": 12,
|
|
563
|
+
"optionSpacing": 4,
|
|
567
564
|
"searchBarBottomSpacing": 8,
|
|
568
565
|
"searchBarHorizontalSpacing": 16,
|
|
569
566
|
"searchBarMarginTopSpacing": 8,
|
|
567
|
+
"sectionSpacing": 12,
|
|
570
568
|
},
|
|
571
569
|
},
|
|
572
570
|
"spinner": Object {
|
|
@@ -2,16 +2,14 @@ import { GlobalTheme } from '../global';
|
|
|
2
2
|
|
|
3
3
|
const getSelectTheme = (theme: GlobalTheme) => {
|
|
4
4
|
const colors = {
|
|
5
|
-
option: theme.colors.platformBackground,
|
|
6
|
-
checkedOption: theme.colors.primaryBackground,
|
|
7
5
|
footerText: theme.colors.primary,
|
|
8
6
|
};
|
|
9
7
|
|
|
10
8
|
const space = {
|
|
11
9
|
minimumOptionListHeight: theme.space.xxxxlarge * 5,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
sectionSpacing: theme.space.smallMedium,
|
|
11
|
+
optionSpacing: theme.space.xsmall,
|
|
12
|
+
optionHorizontalMargin: theme.space.smallMedium,
|
|
15
13
|
searchBarMarginTopSpacing: theme.space.small,
|
|
16
14
|
searchBarHorizontalSpacing: theme.space.medium,
|
|
17
15
|
searchBarBottomSpacing: theme.space.small,
|
package/src/types.ts
CHANGED
|
@@ -10,14 +10,20 @@ import {
|
|
|
10
10
|
} from './components/RichTextEditor';
|
|
11
11
|
|
|
12
12
|
import { Theme } from './theme';
|
|
13
|
+
import {
|
|
14
|
+
ListRenderOptionInfo,
|
|
15
|
+
SectionListRenderOptionInfo,
|
|
16
|
+
} from './components/Select/types';
|
|
13
17
|
|
|
14
18
|
export type {
|
|
15
19
|
BottomNavigationTabType,
|
|
16
20
|
IconName,
|
|
21
|
+
SingleSelectProps,
|
|
17
22
|
MultiSelectProps,
|
|
23
|
+
ListRenderOptionInfo,
|
|
24
|
+
SectionListRenderOptionInfo,
|
|
18
25
|
RichTextEditorProps,
|
|
19
26
|
RichTextEditorRef,
|
|
20
|
-
SingleSelectProps,
|
|
21
27
|
TabType,
|
|
22
28
|
TextInputProps,
|
|
23
29
|
Theme,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
declare const Option: ({ text, disabled, selected, onPress, }: {
|
|
3
|
+
text: string | ReactElement;
|
|
4
|
+
disabled?: boolean | undefined;
|
|
3
5
|
selected: boolean;
|
|
4
6
|
onPress: () => void;
|
|
5
7
|
}) => JSX.Element;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { MultiSelectProps } from '.';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
declare const OptionList: <T>({ keyExtractor, loading, onEndReached, onPress, onQueryChange, options, value, }: Pick<OptionListProps<T>, "value" | "onPress" | "loading" | "options" | "keyExtractor" | "onQueryChange" | "onEndReached">) => JSX.Element;
|
|
2
|
+
import { OptionType, SectionData } from '../types';
|
|
3
|
+
declare type OptionListProps<V, T extends OptionType<V>> = Pick<MultiSelectProps<V, T>, 'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange' | 'value' | 'renderOption'> & {
|
|
4
|
+
onPress: (value: V[]) => void;
|
|
5
|
+
sections: SectionData<V, T>[];
|
|
6
|
+
};
|
|
7
|
+
declare const OptionList: <V, T extends OptionType<V>>({ keyExtractor, loading, onEndReached, onPress, onQueryChange, sections, renderOption, value, }: OptionListProps<V, T>) => JSX.Element;
|
|
9
8
|
export default OptionList;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { SelectProps } from '../types';
|
|
2
|
-
export interface MultiSelectProps<T> extends SelectProps<T> {
|
|
1
|
+
import { OptionType, SelectProps } from '../types';
|
|
2
|
+
export interface MultiSelectProps<V, T extends OptionType<V> = OptionType<V>> extends SelectProps<V, T> {
|
|
3
3
|
/**
|
|
4
4
|
* Current selected value.
|
|
5
5
|
*/
|
|
6
|
-
value:
|
|
6
|
+
value: V[];
|
|
7
7
|
/**
|
|
8
8
|
* event handler for footer button.
|
|
9
9
|
*/
|
|
10
|
-
onConfirm: (value:
|
|
10
|
+
onConfirm: (value: V[]) => void;
|
|
11
11
|
/**
|
|
12
12
|
* Footer label.
|
|
13
13
|
*/
|
|
14
14
|
footerLabel: string;
|
|
15
15
|
}
|
|
16
|
-
declare function MultiSelect<T
|
|
16
|
+
declare function MultiSelect<V, T extends OptionType<V>>({ footerLabel, label, loading, inputProps, onConfirm, onDimiss, onEndReached, onQueryChange, options, renderOption, query, error, editable, disabled, numberOfLines, style, testID, value, }: MultiSelectProps<V, T>): JSX.Element;
|
|
17
17
|
export default MultiSelect;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
declare const Option: ({ text, disabled, selected, onPress, }: {
|
|
3
|
+
text: string | ReactElement;
|
|
4
|
+
disabled?: boolean | undefined;
|
|
3
5
|
selected: boolean;
|
|
4
6
|
onPress: () => void;
|
|
5
7
|
}) => JSX.Element;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SingleSelectProps } from '.';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
declare const OptionList: <T>({ keyExtractor, loading, onEndReached, onPress, onQueryChange, options, value, }: Pick<OptionListProps<T>, "value" | "onPress" | "loading" | "options" | "keyExtractor" | "onQueryChange" | "onEndReached">) => JSX.Element;
|
|
2
|
+
import { OptionType, SectionData } from '../types';
|
|
3
|
+
declare type OptionListProps<V, T extends OptionType<V>> = Pick<SingleSelectProps<V, T>, 'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange' | 'value' | 'renderOption'> & {
|
|
4
|
+
onPress: (value: V | null) => void;
|
|
5
|
+
sections: SectionData<V, T>[];
|
|
6
|
+
};
|
|
7
|
+
declare const OptionList: <V, T extends OptionType<V>>({ keyExtractor, loading, onEndReached, onPress, onQueryChange, sections, renderOption, value, }: OptionListProps<V, T>) => JSX.Element;
|
|
9
8
|
export default OptionList;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { SelectProps } from '../types';
|
|
2
|
-
export interface SingleSelectProps<T> extends SelectProps<T> {
|
|
1
|
+
import { OptionType, SelectProps } from '../types';
|
|
2
|
+
export interface SingleSelectProps<V, T extends OptionType<V> = OptionType<V>> extends SelectProps<V, T> {
|
|
3
3
|
/**
|
|
4
4
|
* Current selected value.
|
|
5
5
|
*/
|
|
6
|
-
value:
|
|
6
|
+
value: V | null;
|
|
7
7
|
/**
|
|
8
8
|
* on select event handler
|
|
9
9
|
*/
|
|
10
|
-
onConfirm: (value:
|
|
10
|
+
onConfirm: (value: V | null) => void;
|
|
11
11
|
}
|
|
12
|
-
declare const SingleSelect: <T
|
|
12
|
+
declare const SingleSelect: <V, T extends OptionType<V>>({ label, loading, inputProps, onConfirm, onDimiss, onEndReached, onQueryChange, options, renderOption, query, error, editable, disabled, numberOfLines, style, testID, value, }: SingleSelectProps<V, T>) => JSX.Element;
|
|
13
13
|
export default SingleSelect;
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Selected scroll index
|
|
13
|
-
*/
|
|
14
|
-
scrollIndex?: number;
|
|
15
|
-
}
|
|
16
|
-
declare const StyledOptionList: <T>({ keyExtractor, loading, onEndReached, onQueryChange, options, RenderItem, scrollIndex, }: Pick<OptionListProps<T>, "loading" | "options" | "keyExtractor" | "onQueryChange" | "onEndReached" | "scrollIndex" | "RenderItem">) => JSX.Element;
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { SectionListRenderItemInfo } from 'react-native';
|
|
3
|
+
import { ScrollParams } from './helpers';
|
|
4
|
+
import { SectionData, OptionType, SelectProps, SectionType } from './types';
|
|
5
|
+
export declare type StyledOptionListProps<V, T extends OptionType<V>> = Pick<SelectProps<V, T>, 'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange'> & {
|
|
6
|
+
scrollParams: ScrollParams;
|
|
7
|
+
sections: SectionData<V, T>[];
|
|
8
|
+
renderItem: (info: SectionListRenderItemInfo<T, SectionType>) => ReactElement;
|
|
9
|
+
};
|
|
10
|
+
declare const StyledOptionList: <V, T extends OptionType<V>>({ keyExtractor, loading, onEndReached, onQueryChange, sections, renderItem, scrollParams, }: StyledOptionListProps<V, T>) => JSX.Element;
|
|
17
11
|
export default StyledOptionList;
|