@hero-design/rn 7.20.1 → 7.21.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/.eslintrc.json +1 -0
- package/.turbo/turbo-build.log +2 -2
- package/es/index.js +370 -237
- package/lib/index.js +370 -234
- package/package.json +4 -2
- package/rollup.config.js +1 -0
- package/src/components/BottomSheet/index.tsx +6 -1
- package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +4 -4
- package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +13 -13
- package/src/components/Empty/StyledEmpty.tsx +1 -9
- package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +58 -5
- package/src/components/Empty/__tests__/index.spec.tsx +13 -0
- package/src/components/Empty/index.tsx +38 -18
- package/src/components/Image/__tests__/__snapshots__/index.spec.tsx.snap +81 -0
- package/src/components/Image/__tests__/index.spec.tsx +29 -0
- package/src/components/Image/index.tsx +46 -0
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +5 -5
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +60 -60
- package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +2 -2
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -2
- package/src/components/Select/MultiSelect/OptionList.tsx +4 -6
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +21 -0
- package/src/components/Select/MultiSelect/index.tsx +33 -3
- package/src/components/Select/SingleSelect/OptionList.tsx +4 -5
- package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +16 -0
- package/src/components/Select/SingleSelect/index.tsx +34 -4
- package/src/components/Select/StyledOptionList.tsx +3 -9
- package/src/components/Slider/__tests__/__snapshots__/index.spec.tsx.snap +43 -0
- package/src/components/Slider/__tests__/index.spec.tsx +33 -0
- package/src/components/Slider/index.tsx +89 -0
- package/src/components/Switch/StyledSwitch.tsx +4 -4
- package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +10 -10
- package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +8 -8
- package/src/components/Switch/index.tsx +5 -4
- package/src/components/TextInput/index.tsx +43 -37
- package/src/index.ts +4 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +56 -11
- package/src/theme/components/alert.ts +1 -2
- package/src/theme/components/avatar.ts +8 -8
- package/src/theme/components/badge.ts +4 -4
- package/src/theme/components/bottomNavigation.ts +1 -1
- package/src/theme/components/bottomSheet.ts +2 -3
- package/src/theme/components/calendar.ts +9 -7
- package/src/theme/components/card.ts +1 -1
- package/src/theme/components/checkbox.ts +2 -5
- package/src/theme/components/datePicker.ts +3 -3
- package/src/theme/components/drawer.ts +2 -3
- package/src/theme/components/empty.ts +3 -8
- package/src/theme/components/fab.ts +2 -2
- package/src/theme/components/image.ts +12 -0
- package/src/theme/components/pinInput.ts +3 -3
- package/src/theme/components/progress.ts +2 -3
- package/src/theme/components/radio.ts +7 -3
- package/src/theme/components/richTextEditor.ts +4 -4
- package/src/theme/components/slider.ts +13 -0
- package/src/theme/components/switch.ts +16 -1
- package/src/theme/components/tabs.ts +1 -1
- package/src/theme/components/timePicker.ts +3 -3
- package/src/theme/components/toast.ts +1 -2
- package/src/theme/getTheme.ts +9 -2
- package/src/theme/global/colors/swag.ts +2 -0
- package/src/theme/global/colors/types.ts +2 -0
- package/src/theme/global/index.ts +3 -0
- package/src/theme/global/scale.ts +3 -0
- package/src/theme/global/sizes.ts +29 -0
- package/testUtils/setup.tsx +14 -0
- package/types/components/BottomSheet/index.d.ts +5 -1
- package/types/components/Empty/StyledEmpty.d.ts +1 -7
- package/types/components/Empty/index.d.ts +8 -2
- package/types/components/Image/__tests__/index.spec.d.ts +1 -0
- package/types/components/Image/index.d.ts +17 -0
- package/types/components/Select/MultiSelect/OptionList.d.ts +5 -2
- package/types/components/Select/MultiSelect/index.d.ts +7 -1
- package/types/components/Select/SingleSelect/OptionList.d.ts +5 -2
- package/types/components/Select/SingleSelect/index.d.ts +8 -2
- package/types/components/Select/StyledOptionList.d.ts +4 -3
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/Slider/__tests__/index.spec.d.ts +1 -0
- package/types/components/Slider/index.d.ts +52 -0
- package/types/components/TextInput/index.d.ts +2 -1
- package/types/index.d.ts +3 -1
- package/types/theme/components/datePicker.d.ts +2 -1
- package/types/theme/components/empty.d.ts +2 -5
- package/types/theme/components/image.d.ts +8 -0
- package/types/theme/components/slider.d.ts +9 -0
- package/types/theme/components/switch.d.ts +14 -1
- package/types/theme/components/timePicker.d.ts +2 -1
- package/types/theme/getTheme.d.ts +4 -0
- package/types/theme/global/colors/types.d.ts +2 -0
- package/types/theme/global/index.d.ts +3 -0
- package/types/theme/global/scale.d.ts +1 -0
- package/types/theme/global/sizes.d.ts +14 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { useTheme } from '@emotion/react';
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
3
|
import { Dimensions, SectionList, View } from 'react-native';
|
|
4
4
|
import type { ReactElement } from 'react';
|
|
5
5
|
import type { SectionListRenderItemInfo } from 'react-native';
|
|
6
6
|
import SectionHeading from '../SectionHeading';
|
|
7
7
|
import Spinner from '../Spinner';
|
|
8
8
|
import { OptionSpacer, SectionSpacer } from './StyledSelect';
|
|
9
|
-
import type { ScrollParams } from './helpers';
|
|
10
9
|
import type {
|
|
11
10
|
SectionData,
|
|
12
11
|
OptionType,
|
|
@@ -18,9 +17,9 @@ export type StyledOptionListProps<V, T extends OptionType<V>> = Pick<
|
|
|
18
17
|
SelectProps<V, T>,
|
|
19
18
|
'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange'
|
|
20
19
|
> & {
|
|
21
|
-
scrollParams: ScrollParams;
|
|
22
20
|
sections: SectionData<V, T>[];
|
|
23
21
|
renderItem: (info: SectionListRenderItemInfo<T, SectionType>) => ReactElement;
|
|
22
|
+
sectionListRef?: React.RefObject<SectionList<T, SectionType>>;
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
const StyledOptionList = <V, T extends OptionType<V>>({
|
|
@@ -30,10 +29,9 @@ const StyledOptionList = <V, T extends OptionType<V>>({
|
|
|
30
29
|
onQueryChange,
|
|
31
30
|
sections,
|
|
32
31
|
renderItem,
|
|
33
|
-
|
|
32
|
+
sectionListRef,
|
|
34
33
|
}: StyledOptionListProps<V, T>) => {
|
|
35
34
|
const theme = useTheme();
|
|
36
|
-
const sectionListRef = useRef<SectionList<T, SectionType>>(null);
|
|
37
35
|
|
|
38
36
|
const [onEndReachedCalled, setOnEndReachedCalled] = useState(false);
|
|
39
37
|
|
|
@@ -48,10 +46,6 @@ const StyledOptionList = <V, T extends OptionType<V>>({
|
|
|
48
46
|
onEndReachedThreshold={0.1}
|
|
49
47
|
onEndReached={() => setOnEndReachedCalled(true)}
|
|
50
48
|
onScrollToIndexFailed={() => {}}
|
|
51
|
-
onContentSizeChange={() =>
|
|
52
|
-
sections.length &&
|
|
53
|
-
sectionListRef.current?.scrollToLocation(scrollParams)
|
|
54
|
-
}
|
|
55
49
|
onMomentumScrollBegin={() => {
|
|
56
50
|
if (onEndReached && onEndReachedCalled && !loading) onEndReached();
|
|
57
51
|
setOnEndReachedCalled(false);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Slider renders correctly by default 1`] = `
|
|
4
|
+
<Slider
|
|
5
|
+
disabled={false}
|
|
6
|
+
maximumTrackTintColor="#ece8ef"
|
|
7
|
+
maximumValue={1}
|
|
8
|
+
minimumTrackTintColor="#401960"
|
|
9
|
+
minimumValue={0}
|
|
10
|
+
step={0}
|
|
11
|
+
thumbTintColor="#e6e9e9"
|
|
12
|
+
value={0}
|
|
13
|
+
/>
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
exports[`Slider renders correctly when disabled 1`] = `
|
|
17
|
+
<Slider
|
|
18
|
+
disabled={true}
|
|
19
|
+
maximumTrackTintColor="#ece8ef"
|
|
20
|
+
maximumValue={1}
|
|
21
|
+
minimumTrackTintColor="#401960"
|
|
22
|
+
minimumValue={0}
|
|
23
|
+
step={0}
|
|
24
|
+
thumbTintColor="#e6e9e9"
|
|
25
|
+
value={0}
|
|
26
|
+
/>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`Slider renders correctly with props 1`] = `
|
|
30
|
+
<Slider
|
|
31
|
+
disabled={false}
|
|
32
|
+
maximumTrackTintColor="#ece8ef"
|
|
33
|
+
maximumValue={2}
|
|
34
|
+
minimumTrackTintColor="#401960"
|
|
35
|
+
minimumValue={-1}
|
|
36
|
+
onSlidingComplete={[MockFunction]}
|
|
37
|
+
onSlidingStart={[MockFunction]}
|
|
38
|
+
onValueChange={[MockFunction]}
|
|
39
|
+
step={0.25}
|
|
40
|
+
thumbTintColor="#e6e9e9"
|
|
41
|
+
value={0.5}
|
|
42
|
+
/>
|
|
43
|
+
`;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
+
import Slider from '..';
|
|
4
|
+
|
|
5
|
+
describe('Slider', () => {
|
|
6
|
+
it('renders correctly by default', () => {
|
|
7
|
+
const { toJSON } = renderWithTheme(<Slider />);
|
|
8
|
+
|
|
9
|
+
expect(toJSON()).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('renders correctly when disabled', () => {
|
|
13
|
+
const { toJSON } = renderWithTheme(<Slider disabled />);
|
|
14
|
+
|
|
15
|
+
expect(toJSON()).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders correctly with props', () => {
|
|
19
|
+
const { toJSON } = renderWithTheme(
|
|
20
|
+
<Slider
|
|
21
|
+
value={0.5}
|
|
22
|
+
minimumValue={-1}
|
|
23
|
+
maximumValue={2}
|
|
24
|
+
step={0.25}
|
|
25
|
+
onValueChange={jest.fn()}
|
|
26
|
+
onSlidingStart={jest.fn()}
|
|
27
|
+
onSlidingComplete={jest.fn()}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
expect(toJSON()).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import RnSlider from '@react-native-community/slider';
|
|
3
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import { useTheme } from '../../theme';
|
|
5
|
+
|
|
6
|
+
export interface SliderProps {
|
|
7
|
+
/**
|
|
8
|
+
* Minimum value of the slider.
|
|
9
|
+
* Defaults to 0.
|
|
10
|
+
*/
|
|
11
|
+
minimumValue?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Maximum value of the slider.
|
|
14
|
+
* Defaults to 1.
|
|
15
|
+
*/
|
|
16
|
+
maximumValue?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Step value of the slider.
|
|
19
|
+
* The value should be between 0 and (maximumValue - minimumValue).
|
|
20
|
+
* Defaults to 0.
|
|
21
|
+
*/
|
|
22
|
+
step?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Value of the slider.
|
|
25
|
+
* Defaults to 0.
|
|
26
|
+
*/
|
|
27
|
+
value?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Callback continuously called while the user is dragging the slider.
|
|
30
|
+
*/
|
|
31
|
+
onValueChange?: (value: number) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Callback that is called when the user picks up the slider.
|
|
34
|
+
* The initial value is passed as an argument to the callback handler.
|
|
35
|
+
*/
|
|
36
|
+
onSlidingStart?: (value: number) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Callback that is called when the user releases the slider, regardless if the value has changed.
|
|
39
|
+
* The current value is passed as an argument to the callback handler.
|
|
40
|
+
*/
|
|
41
|
+
onSlidingComplete?: (value: number) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the slider is disabled.
|
|
44
|
+
*/
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Additional style.
|
|
48
|
+
*/
|
|
49
|
+
style?: StyleProp<ViewStyle>;
|
|
50
|
+
/**
|
|
51
|
+
* Testing id of the component.
|
|
52
|
+
*/
|
|
53
|
+
testID?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const Slider = ({
|
|
57
|
+
minimumValue = 0,
|
|
58
|
+
maximumValue = 1,
|
|
59
|
+
step = 0,
|
|
60
|
+
value = 0,
|
|
61
|
+
onValueChange,
|
|
62
|
+
onSlidingStart,
|
|
63
|
+
onSlidingComplete,
|
|
64
|
+
disabled = false,
|
|
65
|
+
style,
|
|
66
|
+
testID,
|
|
67
|
+
}: SliderProps) => {
|
|
68
|
+
const theme = useTheme();
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<RnSlider
|
|
72
|
+
minimumValue={minimumValue}
|
|
73
|
+
maximumValue={maximumValue}
|
|
74
|
+
step={step}
|
|
75
|
+
value={value}
|
|
76
|
+
onValueChange={onValueChange}
|
|
77
|
+
onSlidingStart={onSlidingStart}
|
|
78
|
+
onSlidingComplete={onSlidingComplete}
|
|
79
|
+
disabled={disabled}
|
|
80
|
+
minimumTrackTintColor={theme.__hd__.slider.colors.minimumTrackTint}
|
|
81
|
+
thumbTintColor={theme.__hd__.slider.colors.thumbTint}
|
|
82
|
+
maximumTrackTintColor={theme.__hd__.slider.colors.maximumTrackTint}
|
|
83
|
+
style={style}
|
|
84
|
+
testID={testID}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default Slider;
|
|
@@ -13,8 +13,8 @@ const StyledWrapper = styled(View)<{
|
|
|
13
13
|
themeVariant: Variant;
|
|
14
14
|
themeSize: ThemeSize;
|
|
15
15
|
}>(({ theme, themeVariant, themeSize }) => ({
|
|
16
|
-
height: theme.__hd__.switch.heights[themeSize],
|
|
17
|
-
width: theme.__hd__.switch.widths[themeSize],
|
|
16
|
+
height: theme.__hd__.switch.sizes.heights[themeSize],
|
|
17
|
+
width: theme.__hd__.switch.sizes.widths[themeSize],
|
|
18
18
|
paddingHorizontal: theme.__hd__.switch.spaces[themeSize],
|
|
19
19
|
borderRadius: theme.__hd__.switch.radii.rounded,
|
|
20
20
|
backgroundColor: theme.__hd__.switch.colors.backgroundColors[themeVariant],
|
|
@@ -25,8 +25,8 @@ const StyledWrapper = styled(View)<{
|
|
|
25
25
|
const StyledKnot = styled(Animated.View)<{
|
|
26
26
|
themeSize: ThemeSize;
|
|
27
27
|
}>(({ theme, themeSize }) => ({
|
|
28
|
-
width: theme.__hd__.switch.
|
|
29
|
-
height: theme.__hd__.switch.
|
|
28
|
+
width: theme.__hd__.switch.sizes.thumbs[themeSize],
|
|
29
|
+
height: theme.__hd__.switch.sizes.thumbs[themeSize],
|
|
30
30
|
backgroundColor: theme.__hd__.switch.colors.thumb,
|
|
31
31
|
borderRadius: theme.__hd__.switch.radii.rounded,
|
|
32
32
|
}));
|
|
@@ -8,8 +8,8 @@ exports[`StyledKnot renders correct style 1`] = `
|
|
|
8
8
|
Object {
|
|
9
9
|
"backgroundColor": "#ffffff",
|
|
10
10
|
"borderRadius": 999,
|
|
11
|
-
"height":
|
|
12
|
-
"width":
|
|
11
|
+
"height": 24,
|
|
12
|
+
"width": 24,
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
themeSize="medium"
|
|
@@ -24,10 +24,10 @@ exports[`StyledWrapper renders correct style with variant checked 1`] = `
|
|
|
24
24
|
"backgroundColor": "#8505a2",
|
|
25
25
|
"borderRadius": 999,
|
|
26
26
|
"display": "flex",
|
|
27
|
-
"height":
|
|
27
|
+
"height": 32,
|
|
28
28
|
"justifyContent": "center",
|
|
29
29
|
"paddingHorizontal": 4,
|
|
30
|
-
"width":
|
|
30
|
+
"width": 64,
|
|
31
31
|
},
|
|
32
32
|
undefined,
|
|
33
33
|
]
|
|
@@ -45,10 +45,10 @@ exports[`StyledWrapper renders correct style with variant disabled-checked 1`] =
|
|
|
45
45
|
"backgroundColor": "#c282d1",
|
|
46
46
|
"borderRadius": 999,
|
|
47
47
|
"display": "flex",
|
|
48
|
-
"height":
|
|
48
|
+
"height": 32,
|
|
49
49
|
"justifyContent": "center",
|
|
50
50
|
"paddingHorizontal": 4,
|
|
51
|
-
"width":
|
|
51
|
+
"width": 64,
|
|
52
52
|
},
|
|
53
53
|
undefined,
|
|
54
54
|
]
|
|
@@ -66,10 +66,10 @@ exports[`StyledWrapper renders correct style with variant disabled-unchecked 1`]
|
|
|
66
66
|
"backgroundColor": "#ccced1",
|
|
67
67
|
"borderRadius": 999,
|
|
68
68
|
"display": "flex",
|
|
69
|
-
"height":
|
|
69
|
+
"height": 32,
|
|
70
70
|
"justifyContent": "center",
|
|
71
71
|
"paddingHorizontal": 4,
|
|
72
|
-
"width":
|
|
72
|
+
"width": 64,
|
|
73
73
|
},
|
|
74
74
|
undefined,
|
|
75
75
|
]
|
|
@@ -87,10 +87,10 @@ exports[`StyledWrapper renders correct style with variant unchecked 1`] = `
|
|
|
87
87
|
"backgroundColor": "#808f91",
|
|
88
88
|
"borderRadius": 999,
|
|
89
89
|
"display": "flex",
|
|
90
|
-
"height":
|
|
90
|
+
"height": 32,
|
|
91
91
|
"justifyContent": "center",
|
|
92
92
|
"paddingHorizontal": 4,
|
|
93
|
-
"width":
|
|
93
|
+
"width": 64,
|
|
94
94
|
},
|
|
95
95
|
undefined,
|
|
96
96
|
]
|
|
@@ -22,10 +22,10 @@ exports[`Switch renders correctly 1`] = `
|
|
|
22
22
|
"backgroundColor": "#808f91",
|
|
23
23
|
"borderRadius": 999,
|
|
24
24
|
"display": "flex",
|
|
25
|
-
"height":
|
|
25
|
+
"height": 32,
|
|
26
26
|
"justifyContent": "center",
|
|
27
27
|
"paddingHorizontal": 4,
|
|
28
|
-
"width":
|
|
28
|
+
"width": 64,
|
|
29
29
|
},
|
|
30
30
|
undefined,
|
|
31
31
|
]
|
|
@@ -41,9 +41,9 @@ exports[`Switch renders correctly 1`] = `
|
|
|
41
41
|
Object {
|
|
42
42
|
"backgroundColor": "#ffffff",
|
|
43
43
|
"borderRadius": 999,
|
|
44
|
-
"height":
|
|
44
|
+
"height": 24,
|
|
45
45
|
"left": 0,
|
|
46
|
-
"width":
|
|
46
|
+
"width": 24,
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
themeSize="medium"
|
|
@@ -73,10 +73,10 @@ exports[`Switch trigger press function correctly 1`] = `
|
|
|
73
73
|
"backgroundColor": "#808f91",
|
|
74
74
|
"borderRadius": 999,
|
|
75
75
|
"display": "flex",
|
|
76
|
-
"height":
|
|
76
|
+
"height": 32,
|
|
77
77
|
"justifyContent": "center",
|
|
78
78
|
"paddingHorizontal": 4,
|
|
79
|
-
"width":
|
|
79
|
+
"width": 64,
|
|
80
80
|
},
|
|
81
81
|
undefined,
|
|
82
82
|
]
|
|
@@ -92,9 +92,9 @@ exports[`Switch trigger press function correctly 1`] = `
|
|
|
92
92
|
Object {
|
|
93
93
|
"backgroundColor": "#ffffff",
|
|
94
94
|
"borderRadius": 999,
|
|
95
|
-
"height":
|
|
95
|
+
"height": 24,
|
|
96
96
|
"left": 0,
|
|
97
|
-
"width":
|
|
97
|
+
"width": 24,
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
themeSize="medium"
|
|
@@ -60,10 +60,11 @@ const Switch = ({
|
|
|
60
60
|
const variant = getVariant({ disabled, checked });
|
|
61
61
|
|
|
62
62
|
const offset = checked
|
|
63
|
-
? theme.__hd__.switch.widths[size] -
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
? (theme.__hd__.switch.sizes.widths[size] -
|
|
64
|
+
theme.__hd__.switch.sizes.thumbs[size]) /
|
|
65
|
+
2 +
|
|
66
|
+
theme.__hd__.switch.sizes.thumbs[size] / 2
|
|
67
|
+
: 0;
|
|
67
68
|
|
|
68
69
|
const [animatedOffset] = useState(() => new Animated.Value(offset));
|
|
69
70
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
3
|
import type {
|
|
4
4
|
TextInputProps as NativeTextInputProps,
|
|
5
5
|
StyleProp,
|
|
@@ -92,6 +92,10 @@ export interface TextInputProps extends NativeTextInputProps {
|
|
|
92
92
|
* The helper text to display.
|
|
93
93
|
*/
|
|
94
94
|
helpText?: string;
|
|
95
|
+
/*
|
|
96
|
+
* Customise input value renderer
|
|
97
|
+
*/
|
|
98
|
+
renderInputValue?: (inputProps: NativeTextInputProps) => React.ReactNode;
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
export const getVariant = ({
|
|
@@ -144,9 +148,9 @@ const TextInput = ({
|
|
|
144
148
|
helpText,
|
|
145
149
|
value,
|
|
146
150
|
defaultValue,
|
|
151
|
+
renderInputValue,
|
|
147
152
|
...nativeProps
|
|
148
153
|
}: TextInputProps): JSX.Element => {
|
|
149
|
-
const textInputReference = useRef<RNTextInput | null>(null);
|
|
150
154
|
const displayText = (value !== undefined ? value : defaultValue) ?? '';
|
|
151
155
|
const isEmptyValue = displayText.length === 0;
|
|
152
156
|
const actualSuffix = loading ? 'loading' : suffix;
|
|
@@ -165,6 +169,37 @@ const TextInput = ({
|
|
|
165
169
|
const shouldShowMaxLength = maxLength !== undefined;
|
|
166
170
|
|
|
167
171
|
const theme = useTheme();
|
|
172
|
+
|
|
173
|
+
const nativeInputProps: NativeTextInputProps = {
|
|
174
|
+
style: StyleSheet.flatten([
|
|
175
|
+
{ color: theme.__hd__.textInput.colors.text },
|
|
176
|
+
textStyle,
|
|
177
|
+
]),
|
|
178
|
+
testID: 'text-input',
|
|
179
|
+
accessibilityState: {
|
|
180
|
+
disabled: variant === 'disabled' || variant === 'readonly',
|
|
181
|
+
},
|
|
182
|
+
// @ts-ignore
|
|
183
|
+
accessibilityLabelledBy,
|
|
184
|
+
...nativeProps,
|
|
185
|
+
onFocus: event => {
|
|
186
|
+
setIsFocused(true);
|
|
187
|
+
nativeProps.onFocus?.(event);
|
|
188
|
+
},
|
|
189
|
+
onBlur: event => {
|
|
190
|
+
setIsFocused(false);
|
|
191
|
+
nativeProps.onBlur?.(event);
|
|
192
|
+
},
|
|
193
|
+
editable,
|
|
194
|
+
maxLength,
|
|
195
|
+
value,
|
|
196
|
+
onChangeText: text => {
|
|
197
|
+
nativeProps.onChangeText?.(text);
|
|
198
|
+
},
|
|
199
|
+
defaultValue,
|
|
200
|
+
placeholder: variant === 'focused' ? nativeProps.placeholder : undefined,
|
|
201
|
+
};
|
|
202
|
+
|
|
168
203
|
return (
|
|
169
204
|
<StyledContainer
|
|
170
205
|
style={style}
|
|
@@ -224,40 +259,11 @@ const TextInput = ({
|
|
|
224
259
|
)}
|
|
225
260
|
</StyledLabelContainerInsideTextInput>
|
|
226
261
|
)}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
textStyle,
|
|
233
|
-
])}
|
|
234
|
-
testID="text-input"
|
|
235
|
-
accessibilityState={{
|
|
236
|
-
disabled: variant === 'disabled' || variant === 'readonly',
|
|
237
|
-
}}
|
|
238
|
-
// @ts-ignore
|
|
239
|
-
accessibilityLabelledBy={accessibilityLabelledBy}
|
|
240
|
-
{...nativeProps}
|
|
241
|
-
onFocus={event => {
|
|
242
|
-
setIsFocused(true);
|
|
243
|
-
nativeProps.onFocus?.(event);
|
|
244
|
-
}}
|
|
245
|
-
onBlur={event => {
|
|
246
|
-
setIsFocused(false);
|
|
247
|
-
nativeProps.onBlur?.(event);
|
|
248
|
-
}}
|
|
249
|
-
ref={textInputReference}
|
|
250
|
-
editable={editable}
|
|
251
|
-
maxLength={maxLength}
|
|
252
|
-
value={value}
|
|
253
|
-
onChangeText={text => {
|
|
254
|
-
nativeProps.onChangeText?.(text);
|
|
255
|
-
}}
|
|
256
|
-
defaultValue={defaultValue}
|
|
257
|
-
placeholder={
|
|
258
|
-
variant === 'focused' ? nativeProps.placeholder : undefined
|
|
259
|
-
}
|
|
260
|
-
/>
|
|
262
|
+
{renderInputValue ? (
|
|
263
|
+
renderInputValue(nativeInputProps)
|
|
264
|
+
) : (
|
|
265
|
+
<StyledTextInput {...nativeInputProps} />
|
|
266
|
+
)}
|
|
261
267
|
</StyledTextInputAndLabelContainer>
|
|
262
268
|
{typeof actualSuffix === 'string' ? (
|
|
263
269
|
<Icon
|
package/src/index.ts
CHANGED
|
@@ -26,9 +26,11 @@ import Drawer from './components/Drawer';
|
|
|
26
26
|
import Empty from './components/Empty';
|
|
27
27
|
import FAB from './components/FAB';
|
|
28
28
|
import Icon from './components/Icon';
|
|
29
|
+
import Image from './components/Image';
|
|
29
30
|
import List from './components/List';
|
|
30
31
|
import PinInput from './components/PinInput';
|
|
31
32
|
import Progress from './components/Progress';
|
|
33
|
+
import Slider from './components/Slider';
|
|
32
34
|
import Spinner from './components/Spinner';
|
|
33
35
|
import Radio from './components/Radio';
|
|
34
36
|
import SectionHeading from './components/SectionHeading';
|
|
@@ -70,9 +72,11 @@ export {
|
|
|
70
72
|
Empty,
|
|
71
73
|
FAB,
|
|
72
74
|
Icon,
|
|
75
|
+
Image,
|
|
73
76
|
List,
|
|
74
77
|
PinInput,
|
|
75
78
|
Progress,
|
|
79
|
+
Slider,
|
|
76
80
|
Spinner,
|
|
77
81
|
Radio,
|
|
78
82
|
SectionHeading,
|
|
@@ -262,11 +262,11 @@ Object {
|
|
|
262
262
|
"wrapper": 8,
|
|
263
263
|
},
|
|
264
264
|
"sizes": Object {
|
|
265
|
-
"icon":
|
|
265
|
+
"icon": 24,
|
|
266
266
|
},
|
|
267
267
|
"space": Object {
|
|
268
268
|
"iconDescriptionPadding": 12,
|
|
269
|
-
"iconTop":
|
|
269
|
+
"iconTop": 0,
|
|
270
270
|
"wrapperPadding": 16,
|
|
271
271
|
},
|
|
272
272
|
},
|
|
@@ -338,14 +338,11 @@ Object {
|
|
|
338
338
|
"description": "BeVietnamPro-Light",
|
|
339
339
|
"title": "BeVietnamPro-SemiBold",
|
|
340
340
|
},
|
|
341
|
-
"radii": Object {
|
|
342
|
-
"illustration": 999,
|
|
343
|
-
},
|
|
344
341
|
"sizes": Object {
|
|
345
|
-
"
|
|
342
|
+
"image": 168,
|
|
346
343
|
},
|
|
347
344
|
"space": Object {
|
|
348
|
-
"
|
|
345
|
+
"imageMargin": 24,
|
|
349
346
|
"titleMargin": 16,
|
|
350
347
|
"wrapperPadding": 16,
|
|
351
348
|
},
|
|
@@ -419,6 +416,12 @@ Object {
|
|
|
419
416
|
"xsmall": 16,
|
|
420
417
|
},
|
|
421
418
|
},
|
|
419
|
+
"image": Object {
|
|
420
|
+
"sizes": Object {
|
|
421
|
+
"15xlarge": 144,
|
|
422
|
+
"6xlarge": 72,
|
|
423
|
+
},
|
|
424
|
+
},
|
|
422
425
|
"list": Object {
|
|
423
426
|
"colors": Object {
|
|
424
427
|
"checkedListItemContainerBackground": "#f3e6f6",
|
|
@@ -507,7 +510,7 @@ Object {
|
|
|
507
510
|
},
|
|
508
511
|
"sizes": Object {
|
|
509
512
|
"barHeight": 4,
|
|
510
|
-
"circleWidth":
|
|
513
|
+
"circleWidth": 72,
|
|
511
514
|
},
|
|
512
515
|
},
|
|
513
516
|
"radio": Object {
|
|
@@ -539,10 +542,10 @@ Object {
|
|
|
539
542
|
"editor": 14,
|
|
540
543
|
},
|
|
541
544
|
"sizes": Object {
|
|
542
|
-
"editorMinHeight":
|
|
545
|
+
"editorMinHeight": 24,
|
|
543
546
|
"toolbarButtonSize": 48,
|
|
544
547
|
"toolbarSeparatorHeight": 16,
|
|
545
|
-
"toolbarSeparatorWidth":
|
|
548
|
+
"toolbarSeparatorWidth": 2,
|
|
546
549
|
},
|
|
547
550
|
"space": Object {
|
|
548
551
|
"editorPadding": 16,
|
|
@@ -578,6 +581,13 @@ Object {
|
|
|
578
581
|
"sectionSpacing": 12,
|
|
579
582
|
},
|
|
580
583
|
},
|
|
584
|
+
"slider": Object {
|
|
585
|
+
"colors": Object {
|
|
586
|
+
"maximumTrackTint": "#ece8ef",
|
|
587
|
+
"minimumTrackTint": "#401960",
|
|
588
|
+
"thumbTint": "#e6e9e9",
|
|
589
|
+
},
|
|
590
|
+
},
|
|
581
591
|
"spinner": Object {
|
|
582
592
|
"colors": Object {
|
|
583
593
|
"dot1": "#795e90",
|
|
@@ -620,8 +630,21 @@ Object {
|
|
|
620
630
|
"radii": Object {
|
|
621
631
|
"rounded": 999,
|
|
622
632
|
},
|
|
633
|
+
"sizes": Object {
|
|
634
|
+
"heights": Object {
|
|
635
|
+
"medium": 32,
|
|
636
|
+
"small": 24,
|
|
637
|
+
},
|
|
638
|
+
"thumbs": Object {
|
|
639
|
+
"medium": 24,
|
|
640
|
+
"small": 16,
|
|
641
|
+
},
|
|
642
|
+
"widths": Object {
|
|
643
|
+
"medium": 64,
|
|
644
|
+
"small": 48,
|
|
645
|
+
},
|
|
646
|
+
},
|
|
623
647
|
"spaces": Object {
|
|
624
|
-
"inactive": 0,
|
|
625
648
|
"medium": 4,
|
|
626
649
|
"small": 4,
|
|
627
650
|
},
|
|
@@ -888,6 +911,8 @@ Object {
|
|
|
888
911
|
"__alpha__globalNeutral3": "#f6f6f7",
|
|
889
912
|
"__alpha__globalPrimary": "#001f23",
|
|
890
913
|
"__alpha__globalSecondary1": "#4d6265",
|
|
914
|
+
"__alpha__globalSecondary4": "#e6e9e9",
|
|
915
|
+
"__alpha__primary1": "#401960",
|
|
891
916
|
"__alpha__primary2": "#c38cee",
|
|
892
917
|
"__alpha__secondary1": "#795e90",
|
|
893
918
|
"__alpha__secondary2": "#a08cb0",
|
|
@@ -971,6 +996,26 @@ Object {
|
|
|
971
996
|
"rounded": 999,
|
|
972
997
|
"xlarge": 16,
|
|
973
998
|
},
|
|
999
|
+
"sizes": Object {
|
|
1000
|
+
"14xlarge": 136,
|
|
1001
|
+
"15xlarge": 144,
|
|
1002
|
+
"18xlarge": 168,
|
|
1003
|
+
"19xlarge": 176,
|
|
1004
|
+
"6xlarge": 72,
|
|
1005
|
+
"7xlarge": 80,
|
|
1006
|
+
"9xlarge": 96,
|
|
1007
|
+
"large": 24,
|
|
1008
|
+
"medium": 16,
|
|
1009
|
+
"small": 8,
|
|
1010
|
+
"smallMedium": 12,
|
|
1011
|
+
"xlarge": 32,
|
|
1012
|
+
"xsmall": 4,
|
|
1013
|
+
"xxlarge": 40,
|
|
1014
|
+
"xxsmall": 2,
|
|
1015
|
+
"xxxlarge": 48,
|
|
1016
|
+
"xxxxlarge": 56,
|
|
1017
|
+
"xxxxxlarge": 64,
|
|
1018
|
+
},
|
|
974
1019
|
"space": Object {
|
|
975
1020
|
"large": 24,
|
|
976
1021
|
"medium": 16,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { scale } from '../../utils/scale';
|
|
2
1
|
import type { GlobalTheme } from '../global';
|
|
3
2
|
|
|
4
3
|
const getAlertTheme = (theme: GlobalTheme) => {
|
|
@@ -12,7 +11,7 @@ const getAlertTheme = (theme: GlobalTheme) => {
|
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
const sizes = {
|
|
15
|
-
height:
|
|
14
|
+
height: theme.sizes.xxxlarge,
|
|
16
15
|
};
|
|
17
16
|
|
|
18
17
|
const space = {
|
|
@@ -10,14 +10,14 @@ const getAvatarTheme = (theme: GlobalTheme) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const sizes = {
|
|
13
|
-
small: theme.
|
|
14
|
-
medium: theme.
|
|
15
|
-
large: theme.
|
|
16
|
-
xlarge: theme.
|
|
17
|
-
xxlarge: theme.
|
|
18
|
-
xxxlarge: theme.
|
|
19
|
-
xxxxlarge: theme.
|
|
20
|
-
xxxxxlarge: theme.
|
|
13
|
+
small: theme.sizes.xlarge,
|
|
14
|
+
medium: theme.sizes.xxlarge,
|
|
15
|
+
large: theme.sizes.xxxlarge,
|
|
16
|
+
xlarge: theme.sizes.xxxxlarge,
|
|
17
|
+
xxlarge: theme.sizes.xxxxxlarge,
|
|
18
|
+
xxxlarge: theme.sizes['7xlarge'],
|
|
19
|
+
xxxxlarge: theme.sizes['9xlarge'],
|
|
20
|
+
xxxxxlarge: theme.sizes['14xlarge'],
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const fontSizes = {
|