@hero-design/rn 8.33.1 → 8.34.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 +1 -1
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +868 -655
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +871 -656
- package/package.json +8 -7
- package/rollup.config.js +1 -0
- package/src/components/Accordion/AccordionItem.tsx +1 -3
- package/src/components/Accordion/__tests__/AccordionItem.spec.tsx +5 -5
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +26 -34
- package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +36 -48
- package/src/components/Accordion/__tests__/index.spec.tsx +2 -2
- package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +26 -39
- package/src/components/Alert/__tests__/index.spec.tsx +8 -2
- package/src/components/Alert/index.tsx +2 -2
- package/src/components/Attachment/__tests__/__snapshots__/index.spec.tsx.snap +2 -3
- package/src/components/Attachment/index.tsx +3 -1
- package/src/components/Badge/StyledBadge.tsx +1 -4
- package/src/components/Badge/__tests__/Status.spec.tsx +1 -1
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +18 -48
- package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +2 -3
- package/src/components/BottomNavigation/StyledBottomNavigation.tsx +1 -1
- package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +4 -12
- package/src/components/BottomNavigation/index.tsx +0 -1
- package/src/components/BottomSheet/Header.tsx +1 -3
- package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +2 -3
- package/src/components/Button/Button.tsx +34 -11
- package/src/components/Button/StyledButton.tsx +45 -38
- package/src/components/Button/UtilityButton/StyledUtilityButton.tsx +2 -4
- package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +8 -14
- package/src/components/Button/__tests__/StyledButton.spec.tsx +12 -6
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +66 -90
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +56 -86
- package/src/components/Calendar/CalendarRowItem.tsx +5 -2
- package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +10 -15
- package/src/components/Calendar/index.tsx +1 -1
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +12 -18
- package/src/components/Card/__tests__/index.spec.tsx +1 -1
- package/src/components/Carousel/CardCarousel.tsx +2 -0
- package/src/components/Carousel/CarouselItem.tsx +4 -4
- package/src/components/Carousel/StyledCarousel.tsx +1 -4
- package/src/components/Carousel/__tests__/CardCarousel.spec.tsx +18 -18
- package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +24 -20
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +99 -165
- package/src/components/Checkbox/StyledCheckbox.tsx +1 -1
- package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +8 -12
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/ContentNavigator/StyledContentNavigator.tsx +1 -6
- package/src/components/ContentNavigator/__tests__/StyledContentNavigator.spec.tsx +1 -9
- package/src/components/ContentNavigator/__tests__/__snapshots__/StyledContentNavigator.spec.tsx.snap +0 -29
- package/src/components/ContentNavigator/__tests__/__snapshots__/index.spec.tsx.snap +124 -17
- package/src/components/ContentNavigator/__tests__/index.spec.tsx +16 -0
- package/src/components/ContentNavigator/index.tsx +30 -9
- package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +12 -18
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +4 -6
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +4 -6
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +13 -18
- package/src/components/Empty/StyledEmpty.tsx +2 -6
- package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +22 -36
- package/src/components/Empty/index.tsx +4 -2
- package/src/components/Error/StyledError.tsx +2 -8
- package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +44 -76
- package/src/components/Error/index.tsx +6 -2
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +1 -4
- package/src/components/FAB/ActionGroup/StyledActionItem.tsx +1 -5
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +54 -116
- package/src/components/FAB/ActionGroup/index.tsx +1 -1
- package/src/components/FAB/StyledFAB.tsx +1 -4
- package/src/components/FAB/__tests__/StyledFAB.spec.tsx +1 -1
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +2 -3
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +4 -8
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +2 -0
- package/src/components/List/BasicListItem.tsx +2 -6
- package/src/components/List/ListItem.tsx +3 -5
- package/src/components/List/__tests__/ListItem.spec.tsx +4 -4
- package/src/components/List/__tests__/StyledBasicListItem.spec.tsx +3 -1
- package/src/components/List/__tests__/StyledListItem.spec.tsx +3 -1
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +4 -10
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +23 -37
- package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +8 -12
- package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +8 -12
- package/src/components/Modal/ModalContentWrapper.tsx +112 -0
- package/src/components/Modal/ModalPresenter/ModalPresenter.tsx +135 -0
- package/src/components/Modal/ModalPresenter/index.tsx +9 -0
- package/src/components/Modal/ModalProvider.tsx +8 -0
- package/src/components/Modal/__tests__/ModalContentWrapper.spec.tsx +25 -0
- package/src/components/Modal/__tests__/ModalPresenter.spec.tsx +57 -0
- package/src/components/Modal/__tests__/__snapshots__/ModalContentWrapper.spec.tsx.snap +35 -0
- package/src/components/Modal/__tests__/__snapshots__/ModalPresenter.spec.tsx.snap +55 -0
- package/src/components/Modal/__tests__/index.spec.tsx +50 -0
- package/src/components/Modal/index.tsx +121 -0
- package/src/components/PageControl/index.tsx +0 -1
- package/src/components/PinInput/PinCell.tsx +3 -1
- package/src/components/PinInput/StyledPinInput.tsx +2 -7
- package/src/components/PinInput/__tests__/__snapshots__/PinCell.spec.tsx.snap +25 -45
- package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +18 -34
- package/src/components/PinInput/index.tsx +2 -0
- package/src/components/Progress/ProgressCircle.tsx +1 -3
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +3 -6
- package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +2 -4
- package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +3 -6
- package/src/components/RichTextEditor/RichTextEditor.tsx +7 -11
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +16 -24
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +2 -3
- package/src/components/SectionHeading/__tests__/index.spec.tsx +3 -1
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -2
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +12 -24
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +86 -130
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +6 -10
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -2
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +12 -24
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +49 -79
- package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +5 -9
- package/src/components/Success/StyledSuccess.tsx +2 -6
- package/src/components/Success/__tests__/__snapshots__/index.spec.tsx.snap +40 -64
- package/src/components/Success/index.tsx +3 -1
- package/src/components/Swipeable/__tests__/SwipeableAction.spec.tsx +2 -2
- package/src/components/Swipeable/__tests__/__snapshots__/SwipeableAction.spec.tsx.snap +6 -9
- package/src/components/Swipeable/__tests__/__snapshots__/index.spec.tsx.snap +2 -3
- package/src/components/Swipeable/__tests__/index.spec.tsx +6 -4
- package/src/components/Switch/SelectorSwitch/Option.tsx +1 -1
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +1 -2
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +1 -2
- package/src/components/Tabs/ScrollableTabsHeader.tsx +3 -3
- package/src/components/Tabs/__tests__/SceneView.spec.tsx +4 -4
- package/src/components/Tabs/__tests__/__snapshots__/SceneView.spec.tsx.snap +6 -9
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +33 -60
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +7 -13
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +3 -8
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +45 -81
- package/src/components/Tabs/index.tsx +3 -3
- package/src/components/Tag/StyledTag.tsx +1 -4
- package/src/components/Tag/__tests__/Tag.spec.tsx +5 -1
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +47 -93
- package/src/components/Tag/index.tsx +5 -1
- package/src/components/TextInput/StyledTextInput.tsx +8 -16
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +72 -134
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +145 -257
- package/src/components/TextInput/index.tsx +2 -3
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +12 -23
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +21 -35
- package/src/components/Toast/Toast.tsx +6 -5
- package/src/components/Toast/ToastContainer.tsx +2 -0
- package/src/components/Toast/__tests__/Toast.spec.tsx +5 -1
- package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +26 -39
- package/src/components/Toolbar/StyledToolbar.tsx +1 -1
- package/src/components/Toolbar/ToolbarItem.tsx +4 -6
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +12 -18
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +14 -21
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +4 -0
- package/src/theme/components/badge.ts +15 -0
- package/src/theme/components/button.ts +16 -0
- package/src/theme/components/carousel.ts +15 -0
- package/src/theme/components/empty.ts +12 -0
- package/src/theme/components/error.ts +16 -0
- package/src/theme/components/fab.ts +11 -0
- package/src/theme/components/pinInput.ts +15 -0
- package/src/theme/components/success.ts +12 -0
- package/src/theme/components/tag.ts +16 -0
- package/src/theme/components/textInput.ts +1 -0
- package/src/theme/getTheme.ts +18 -18
- package/testUtils/setup.tsx +24 -0
- package/types/components/Badge/StyledBadge.d.ts +1 -1
- package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +1 -1
- package/types/components/Button/StyledButton.d.ts +12 -5
- package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +1 -1
- package/types/components/Carousel/StyledCarousel.d.ts +1 -1
- package/types/components/Checkbox/StyledCheckbox.d.ts +1 -1
- package/types/components/ContentNavigator/StyledContentNavigator.d.ts +1 -5
- package/types/components/Empty/StyledEmpty.d.ts +2 -2
- package/types/components/Error/StyledError.d.ts +2 -2
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +2 -2
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +1 -1
- package/types/components/FAB/StyledFAB.d.ts +1 -1
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/Modal/ModalContentWrapper.d.ts +16 -0
- package/types/components/Modal/ModalPresenter/ModalPresenter.d.ts +34 -0
- package/types/components/Modal/ModalPresenter/index.d.ts +3 -0
- package/types/components/Modal/ModalProvider.d.ts +5 -0
- package/types/components/Modal/index.d.ts +33 -0
- package/types/components/PinInput/StyledPinInput.d.ts +2 -2
- package/types/components/RichTextEditor/RichTextEditor.d.ts +2 -2
- package/types/components/Success/StyledSuccess.d.ts +2 -2
- package/types/components/Tag/StyledTag.d.ts +1 -1
- package/types/components/TextInput/StyledTextInput.d.ts +7 -10
- package/types/components/Toolbar/StyledToolbar.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/theme/components/badge.d.ts +15 -0
- package/types/theme/components/button.d.ts +14 -0
- package/types/theme/components/carousel.d.ts +15 -0
- package/types/theme/components/empty.d.ts +11 -0
- package/types/theme/components/error.d.ts +15 -0
- package/types/theme/components/fab.d.ts +11 -0
- package/types/theme/components/pinInput.d.ts +15 -0
- package/types/theme/components/success.d.ts +11 -0
- package/types/theme/components/tag.d.ts +15 -0
- package/types/theme/components/textInput.d.ts +1 -0
- package/types/theme/getTheme.d.ts +18 -18
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
+
import ModalPresenter, {
|
|
4
|
+
ModalPresenterHandles,
|
|
5
|
+
} from '../ModalPresenter/ModalPresenter';
|
|
6
|
+
import Typography from '../../Typography';
|
|
7
|
+
|
|
8
|
+
jest.mock('react-native', () => {
|
|
9
|
+
const RN = jest.requireActual('react-native');
|
|
10
|
+
|
|
11
|
+
const mockedAnimatedFunctions = {
|
|
12
|
+
start: (callback: () => void) => {
|
|
13
|
+
if (callback) {
|
|
14
|
+
callback();
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
_isUsingNativeDriver: () => jest.fn(),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
RN.Animated.spring = () => mockedAnimatedFunctions;
|
|
21
|
+
|
|
22
|
+
return RN;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('ModalPresenter', () => {
|
|
26
|
+
it('should render correctly', () => {
|
|
27
|
+
const wrapper = renderWithTheme(
|
|
28
|
+
<ModalPresenter
|
|
29
|
+
testID="modal-presenter"
|
|
30
|
+
style={{ backgroundColor: 'blue' }}
|
|
31
|
+
>
|
|
32
|
+
<Typography.Text>Modal content</Typography.Text>
|
|
33
|
+
</ModalPresenter>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
37
|
+
expect(wrapper.getByText('Modal content')).toBeTruthy();
|
|
38
|
+
expect(wrapper.getByTestId('modal-presenter')).toBeTruthy();
|
|
39
|
+
expect(wrapper.getByTestId('modal-presenter')).toHaveStyle({
|
|
40
|
+
backgroundColor: 'blue',
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('allow using ref', () => {
|
|
45
|
+
const ref = React.createRef<ModalPresenterHandles>();
|
|
46
|
+
const completion = jest.fn();
|
|
47
|
+
|
|
48
|
+
renderWithTheme(
|
|
49
|
+
<ModalPresenter ref={ref}>
|
|
50
|
+
<Typography.Text>Modal content</Typography.Text>
|
|
51
|
+
</ModalPresenter>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
ref.current?.animatedOut(completion);
|
|
55
|
+
expect(completion).toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ModalContentWrapper should render correctly 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
collapsable={false}
|
|
6
|
+
style={
|
|
7
|
+
Object {
|
|
8
|
+
"backgroundColor": "blue",
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
testID="modal-content-wrapper"
|
|
12
|
+
>
|
|
13
|
+
<Text
|
|
14
|
+
allowFontScaling={false}
|
|
15
|
+
style={
|
|
16
|
+
Array [
|
|
17
|
+
Object {
|
|
18
|
+
"color": "#001f23",
|
|
19
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
20
|
+
"fontSize": 14,
|
|
21
|
+
"letterSpacing": 0.42,
|
|
22
|
+
"lineHeight": 22,
|
|
23
|
+
},
|
|
24
|
+
undefined,
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
themeFontSize="medium"
|
|
28
|
+
themeFontWeight="regular"
|
|
29
|
+
themeIntent="body"
|
|
30
|
+
themeTypeface="neutral"
|
|
31
|
+
>
|
|
32
|
+
Modal content
|
|
33
|
+
</Text>
|
|
34
|
+
</View>
|
|
35
|
+
`;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ModalPresenter should render correctly 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
Array [
|
|
7
|
+
Object {},
|
|
8
|
+
Object {
|
|
9
|
+
"bottom": 0,
|
|
10
|
+
"left": 0,
|
|
11
|
+
"position": "absolute",
|
|
12
|
+
"right": 0,
|
|
13
|
+
"top": 0,
|
|
14
|
+
},
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
<View
|
|
19
|
+
collapsable={false}
|
|
20
|
+
style={
|
|
21
|
+
Object {
|
|
22
|
+
"alignItems": "center",
|
|
23
|
+
"backgroundColor": "blue",
|
|
24
|
+
"height": "100%",
|
|
25
|
+
"justifyContent": "center",
|
|
26
|
+
"opacity": 0,
|
|
27
|
+
"width": "100%",
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
testID="modal-presenter"
|
|
31
|
+
>
|
|
32
|
+
<Text
|
|
33
|
+
allowFontScaling={false}
|
|
34
|
+
style={
|
|
35
|
+
Array [
|
|
36
|
+
Object {
|
|
37
|
+
"color": "#001f23",
|
|
38
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
39
|
+
"fontSize": 14,
|
|
40
|
+
"letterSpacing": 0.42,
|
|
41
|
+
"lineHeight": 22,
|
|
42
|
+
},
|
|
43
|
+
undefined,
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
themeFontSize="medium"
|
|
47
|
+
themeFontWeight="regular"
|
|
48
|
+
themeIntent="body"
|
|
49
|
+
themeTypeface="neutral"
|
|
50
|
+
>
|
|
51
|
+
Modal content
|
|
52
|
+
</Text>
|
|
53
|
+
</View>
|
|
54
|
+
</View>
|
|
55
|
+
`;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BackHandler } from 'react-native';
|
|
3
|
+
import Modal from '..';
|
|
4
|
+
import Typography from '../../Typography';
|
|
5
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
6
|
+
|
|
7
|
+
jest.mock('react-native', () => {
|
|
8
|
+
const RN = jest.requireActual('react-native');
|
|
9
|
+
|
|
10
|
+
const mockedAnimatedFunctions = {
|
|
11
|
+
start: (callback: () => void) => {
|
|
12
|
+
if (callback) {
|
|
13
|
+
callback();
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
_isUsingNativeDriver: () => jest.fn(),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
RN.Animated.timing = () => mockedAnimatedFunctions;
|
|
20
|
+
|
|
21
|
+
return RN;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('Modal', () => {
|
|
25
|
+
it('onShow should be called correctly', () => {
|
|
26
|
+
const onShow = jest.fn();
|
|
27
|
+
|
|
28
|
+
renderWithTheme(
|
|
29
|
+
<Modal onShow={onShow} visible>
|
|
30
|
+
<Typography.Text>Modal content</Typography.Text>
|
|
31
|
+
</Modal>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
expect(onShow).toHaveBeenCalled();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('onRequestClose should be called correctly', () => {
|
|
38
|
+
const onRequestClose = jest.fn();
|
|
39
|
+
|
|
40
|
+
renderWithTheme(
|
|
41
|
+
<Modal onRequestClose={onRequestClose} visible>
|
|
42
|
+
<Typography.Text>Modal content</Typography.Text>
|
|
43
|
+
</Modal>
|
|
44
|
+
);
|
|
45
|
+
// @ts-expect-error: BackHandler mock
|
|
46
|
+
BackHandler.mockPressBack();
|
|
47
|
+
|
|
48
|
+
expect(onRequestClose).toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BackHandler, Dimensions, View, ViewStyle } from 'react-native';
|
|
3
|
+
import ModalContentWrapper, {
|
|
4
|
+
ModalContentWrapperHandler,
|
|
5
|
+
} from './ModalContentWrapper';
|
|
6
|
+
import ModalProvider from './ModalProvider';
|
|
7
|
+
import { ModalHandler, showModal } from './ModalPresenter';
|
|
8
|
+
|
|
9
|
+
const wrapperStyle: ViewStyle = {
|
|
10
|
+
width: Dimensions.get('window').width,
|
|
11
|
+
height: Dimensions.get('window').height,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export interface ModalProps {
|
|
15
|
+
/**
|
|
16
|
+
* Content of the modal.
|
|
17
|
+
*/
|
|
18
|
+
children: React.ReactElement;
|
|
19
|
+
/**
|
|
20
|
+
* Visibility of the modal
|
|
21
|
+
*/
|
|
22
|
+
visible?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Callback when the modal is shown.
|
|
25
|
+
*/
|
|
26
|
+
onShow?: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Callback when the user taps the hardware back button.
|
|
29
|
+
*/
|
|
30
|
+
onRequestClose?: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* TestID of the modal.
|
|
33
|
+
*/
|
|
34
|
+
testID?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Animation type of the modal content.
|
|
37
|
+
*/
|
|
38
|
+
animationType?: 'none' | 'slide' | 'fade';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const Modal = ({
|
|
42
|
+
children,
|
|
43
|
+
onShow,
|
|
44
|
+
onRequestClose,
|
|
45
|
+
testID,
|
|
46
|
+
visible = true,
|
|
47
|
+
animationType = 'none',
|
|
48
|
+
}: ModalProps) => {
|
|
49
|
+
const [modalHandler, setModalHandler] = React.useState<ModalHandler>();
|
|
50
|
+
const modalContentWrapperRef = React.useRef<ModalContentWrapperHandler>(null);
|
|
51
|
+
|
|
52
|
+
const getModalContent = React.useCallback(
|
|
53
|
+
(isUpdate = false) => {
|
|
54
|
+
return animationType === 'none' ? (
|
|
55
|
+
<View style={wrapperStyle} testID={testID}>
|
|
56
|
+
{children}
|
|
57
|
+
</View>
|
|
58
|
+
) : (
|
|
59
|
+
<ModalContentWrapper
|
|
60
|
+
visible={visible}
|
|
61
|
+
style={wrapperStyle}
|
|
62
|
+
animationType={animationType}
|
|
63
|
+
testID={testID}
|
|
64
|
+
onShow={onShow}
|
|
65
|
+
ref={modalContentWrapperRef}
|
|
66
|
+
animated={!isUpdate}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
</ModalContentWrapper>
|
|
70
|
+
);
|
|
71
|
+
},
|
|
72
|
+
[visible, children, onShow, testID, animationType]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
if (visible) {
|
|
77
|
+
// Modal does not exist, create a new one
|
|
78
|
+
if (!modalHandler) {
|
|
79
|
+
const newModalHandler = showModal(getModalContent(false));
|
|
80
|
+
setModalHandler(newModalHandler);
|
|
81
|
+
|
|
82
|
+
// If animationType is slide for fade, onShow would be run after animation on ModalContentWrapper,
|
|
83
|
+
// else run on this component.
|
|
84
|
+
if (animationType === 'none') {
|
|
85
|
+
onShow?.();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Modal already exists, update it
|
|
89
|
+
else {
|
|
90
|
+
modalHandler.update(getModalContent(true));
|
|
91
|
+
}
|
|
92
|
+
} else if (animationType === 'none') {
|
|
93
|
+
modalHandler?.dismiss();
|
|
94
|
+
setModalHandler(undefined);
|
|
95
|
+
} else {
|
|
96
|
+
// Wait to finish animation before dismissing
|
|
97
|
+
modalContentWrapperRef.current?.hide(() => {
|
|
98
|
+
modalHandler?.dismiss();
|
|
99
|
+
setModalHandler(undefined);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}, [getModalContent]);
|
|
103
|
+
|
|
104
|
+
React.useEffect(() => {
|
|
105
|
+
const backHandler = BackHandler.addEventListener(
|
|
106
|
+
'hardwareBackPress',
|
|
107
|
+
() => {
|
|
108
|
+
onRequestClose?.();
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
return () => backHandler.remove();
|
|
114
|
+
}, [onRequestClose]);
|
|
115
|
+
|
|
116
|
+
return null;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export default Object.assign(Modal, {
|
|
120
|
+
Provider: ModalProvider,
|
|
121
|
+
});
|
|
@@ -25,7 +25,9 @@ function PinCell({
|
|
|
25
25
|
<StyledFilledMask themeState={state} testID="pin-cell-filled-mask" />
|
|
26
26
|
)}
|
|
27
27
|
{value !== '' && !secure && (
|
|
28
|
-
<StyledCellText themeState={state}>
|
|
28
|
+
<StyledCellText themeState={state} level="h3">
|
|
29
|
+
{value}
|
|
30
|
+
</StyledCellText>
|
|
29
31
|
)}
|
|
30
32
|
</StyledCell>
|
|
31
33
|
);
|
|
@@ -27,12 +27,9 @@ export const StyledCell = styled(View)<{
|
|
|
27
27
|
borderColor: theme.__hd__.pinInput.colors[themeState],
|
|
28
28
|
}));
|
|
29
29
|
|
|
30
|
-
export const StyledCellText = styled(Typography.
|
|
30
|
+
export const StyledCellText = styled(Typography.Title)<{
|
|
31
31
|
themeState: State;
|
|
32
32
|
}>(({ theme, themeState }) => ({
|
|
33
|
-
fontFamily: theme.__hd__.pinInput.fonts.cellText,
|
|
34
|
-
fontSize: theme.__hd__.pinInput.fontSizes.cellText,
|
|
35
|
-
lineHeight: theme.__hd__.pinInput.lineHeights.cellText,
|
|
36
33
|
color: theme.__hd__.pinInput.colors[themeState],
|
|
37
34
|
}));
|
|
38
35
|
|
|
@@ -83,9 +80,7 @@ export const StyledErrorContainer = styled(View)(({ theme }) => ({
|
|
|
83
80
|
alignItems: 'center',
|
|
84
81
|
}));
|
|
85
82
|
|
|
86
|
-
export const StyledErrorMessage = styled(Typography.
|
|
87
|
-
fontFamily: theme.__hd__.pinInput.fonts.errorMessage,
|
|
88
|
-
fontSize: theme.__hd__.pinInput.fontSizes.errorMessage,
|
|
83
|
+
export const StyledErrorMessage = styled(Typography.Caption)(({ theme }) => ({
|
|
89
84
|
color: theme.__hd__.pinInput.colors.error,
|
|
90
85
|
paddingLeft: theme.__hd__.pinInput.space.errorMessagePadding,
|
|
91
86
|
}));
|
|
@@ -25,25 +25,21 @@ exports[`PinCell renders correctly when focused is false, state is default 1`] =
|
|
|
25
25
|
Array [
|
|
26
26
|
Object {
|
|
27
27
|
"color": "#001f23",
|
|
28
|
-
"fontFamily": "BeVietnamPro-
|
|
29
|
-
"fontSize":
|
|
30
|
-
"letterSpacing": 0.
|
|
31
|
-
"lineHeight":
|
|
28
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
29
|
+
"fontSize": 28,
|
|
30
|
+
"letterSpacing": 0.24,
|
|
31
|
+
"lineHeight": 36,
|
|
32
32
|
},
|
|
33
33
|
Array [
|
|
34
34
|
Object {
|
|
35
35
|
"color": "#001f23",
|
|
36
|
-
"fontFamily": "BeVietnamPro-SemiBold",
|
|
37
|
-
"fontSize": 28,
|
|
38
|
-
"lineHeight": 36,
|
|
39
36
|
},
|
|
40
37
|
undefined,
|
|
41
38
|
],
|
|
42
39
|
]
|
|
43
40
|
}
|
|
44
|
-
themeFontSize="medium"
|
|
45
|
-
themeFontWeight="regular"
|
|
46
41
|
themeIntent="body"
|
|
42
|
+
themeLevel="h3"
|
|
47
43
|
themeState="default"
|
|
48
44
|
themeTypeface="neutral"
|
|
49
45
|
>
|
|
@@ -77,25 +73,21 @@ exports[`PinCell renders correctly when focused is false, state is disabled 1`]
|
|
|
77
73
|
Array [
|
|
78
74
|
Object {
|
|
79
75
|
"color": "#001f23",
|
|
80
|
-
"fontFamily": "BeVietnamPro-
|
|
81
|
-
"fontSize":
|
|
82
|
-
"letterSpacing": 0.
|
|
83
|
-
"lineHeight":
|
|
76
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
77
|
+
"fontSize": 28,
|
|
78
|
+
"letterSpacing": 0.24,
|
|
79
|
+
"lineHeight": 36,
|
|
84
80
|
},
|
|
85
81
|
Array [
|
|
86
82
|
Object {
|
|
87
83
|
"color": "#bfc1c5",
|
|
88
|
-
"fontFamily": "BeVietnamPro-SemiBold",
|
|
89
|
-
"fontSize": 28,
|
|
90
|
-
"lineHeight": 36,
|
|
91
84
|
},
|
|
92
85
|
undefined,
|
|
93
86
|
],
|
|
94
87
|
]
|
|
95
88
|
}
|
|
96
|
-
themeFontSize="medium"
|
|
97
|
-
themeFontWeight="regular"
|
|
98
89
|
themeIntent="body"
|
|
90
|
+
themeLevel="h3"
|
|
99
91
|
themeState="disabled"
|
|
100
92
|
themeTypeface="neutral"
|
|
101
93
|
>
|
|
@@ -129,25 +121,21 @@ exports[`PinCell renders correctly when focused is false, state is error 1`] = `
|
|
|
129
121
|
Array [
|
|
130
122
|
Object {
|
|
131
123
|
"color": "#001f23",
|
|
132
|
-
"fontFamily": "BeVietnamPro-
|
|
133
|
-
"fontSize":
|
|
134
|
-
"letterSpacing": 0.
|
|
135
|
-
"lineHeight":
|
|
124
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
125
|
+
"fontSize": 28,
|
|
126
|
+
"letterSpacing": 0.24,
|
|
127
|
+
"lineHeight": 36,
|
|
136
128
|
},
|
|
137
129
|
Array [
|
|
138
130
|
Object {
|
|
139
131
|
"color": "#de350b",
|
|
140
|
-
"fontFamily": "BeVietnamPro-SemiBold",
|
|
141
|
-
"fontSize": 28,
|
|
142
|
-
"lineHeight": 36,
|
|
143
132
|
},
|
|
144
133
|
undefined,
|
|
145
134
|
],
|
|
146
135
|
]
|
|
147
136
|
}
|
|
148
|
-
themeFontSize="medium"
|
|
149
|
-
themeFontWeight="regular"
|
|
150
137
|
themeIntent="body"
|
|
138
|
+
themeLevel="h3"
|
|
151
139
|
themeState="error"
|
|
152
140
|
themeTypeface="neutral"
|
|
153
141
|
>
|
|
@@ -181,25 +169,21 @@ exports[`PinCell renders correctly when focused is true, state is default 1`] =
|
|
|
181
169
|
Array [
|
|
182
170
|
Object {
|
|
183
171
|
"color": "#001f23",
|
|
184
|
-
"fontFamily": "BeVietnamPro-
|
|
185
|
-
"fontSize":
|
|
186
|
-
"letterSpacing": 0.
|
|
187
|
-
"lineHeight":
|
|
172
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
173
|
+
"fontSize": 28,
|
|
174
|
+
"letterSpacing": 0.24,
|
|
175
|
+
"lineHeight": 36,
|
|
188
176
|
},
|
|
189
177
|
Array [
|
|
190
178
|
Object {
|
|
191
179
|
"color": "#001f23",
|
|
192
|
-
"fontFamily": "BeVietnamPro-SemiBold",
|
|
193
|
-
"fontSize": 28,
|
|
194
|
-
"lineHeight": 36,
|
|
195
180
|
},
|
|
196
181
|
undefined,
|
|
197
182
|
],
|
|
198
183
|
]
|
|
199
184
|
}
|
|
200
|
-
themeFontSize="medium"
|
|
201
|
-
themeFontWeight="regular"
|
|
202
185
|
themeIntent="body"
|
|
186
|
+
themeLevel="h3"
|
|
203
187
|
themeState="default"
|
|
204
188
|
themeTypeface="neutral"
|
|
205
189
|
>
|
|
@@ -233,25 +217,21 @@ exports[`PinCell renders correctly when focused is true, state is error 1`] = `
|
|
|
233
217
|
Array [
|
|
234
218
|
Object {
|
|
235
219
|
"color": "#001f23",
|
|
236
|
-
"fontFamily": "BeVietnamPro-
|
|
237
|
-
"fontSize":
|
|
238
|
-
"letterSpacing": 0.
|
|
239
|
-
"lineHeight":
|
|
220
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
221
|
+
"fontSize": 28,
|
|
222
|
+
"letterSpacing": 0.24,
|
|
223
|
+
"lineHeight": 36,
|
|
240
224
|
},
|
|
241
225
|
Array [
|
|
242
226
|
Object {
|
|
243
227
|
"color": "#de350b",
|
|
244
|
-
"fontFamily": "BeVietnamPro-SemiBold",
|
|
245
|
-
"fontSize": 28,
|
|
246
|
-
"lineHeight": 36,
|
|
247
228
|
},
|
|
248
229
|
undefined,
|
|
249
230
|
],
|
|
250
231
|
]
|
|
251
232
|
}
|
|
252
|
-
themeFontSize="medium"
|
|
253
|
-
themeFontWeight="regular"
|
|
254
233
|
themeIntent="body"
|
|
234
|
+
themeLevel="h3"
|
|
255
235
|
themeState="error"
|
|
256
236
|
themeTypeface="neutral"
|
|
257
237
|
>
|
|
@@ -497,25 +497,21 @@ exports[`rendering renders correctly when length is 6 and secure is false 1`] =
|
|
|
497
497
|
Array [
|
|
498
498
|
Object {
|
|
499
499
|
"color": "#001f23",
|
|
500
|
-
"fontFamily": "BeVietnamPro-
|
|
501
|
-
"fontSize":
|
|
502
|
-
"letterSpacing": 0.
|
|
503
|
-
"lineHeight":
|
|
500
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
501
|
+
"fontSize": 28,
|
|
502
|
+
"letterSpacing": 0.24,
|
|
503
|
+
"lineHeight": 36,
|
|
504
504
|
},
|
|
505
505
|
Array [
|
|
506
506
|
Object {
|
|
507
507
|
"color": "#001f23",
|
|
508
|
-
"fontFamily": "BeVietnamPro-SemiBold",
|
|
509
|
-
"fontSize": 28,
|
|
510
|
-
"lineHeight": 36,
|
|
511
508
|
},
|
|
512
509
|
undefined,
|
|
513
510
|
],
|
|
514
511
|
]
|
|
515
512
|
}
|
|
516
|
-
themeFontSize="medium"
|
|
517
|
-
themeFontWeight="regular"
|
|
518
513
|
themeIntent="body"
|
|
514
|
+
themeLevel="h3"
|
|
519
515
|
themeState="default"
|
|
520
516
|
themeTypeface="neutral"
|
|
521
517
|
>
|
|
@@ -556,25 +552,21 @@ exports[`rendering renders correctly when length is 6 and secure is false 1`] =
|
|
|
556
552
|
Array [
|
|
557
553
|
Object {
|
|
558
554
|
"color": "#001f23",
|
|
559
|
-
"fontFamily": "BeVietnamPro-
|
|
560
|
-
"fontSize":
|
|
561
|
-
"letterSpacing": 0.
|
|
562
|
-
"lineHeight":
|
|
555
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
556
|
+
"fontSize": 28,
|
|
557
|
+
"letterSpacing": 0.24,
|
|
558
|
+
"lineHeight": 36,
|
|
563
559
|
},
|
|
564
560
|
Array [
|
|
565
561
|
Object {
|
|
566
562
|
"color": "#001f23",
|
|
567
|
-
"fontFamily": "BeVietnamPro-SemiBold",
|
|
568
|
-
"fontSize": 28,
|
|
569
|
-
"lineHeight": 36,
|
|
570
563
|
},
|
|
571
564
|
undefined,
|
|
572
565
|
],
|
|
573
566
|
]
|
|
574
567
|
}
|
|
575
|
-
themeFontSize="medium"
|
|
576
|
-
themeFontWeight="regular"
|
|
577
568
|
themeIntent="body"
|
|
569
|
+
themeLevel="h3"
|
|
578
570
|
themeState="default"
|
|
579
571
|
themeTypeface="neutral"
|
|
580
572
|
>
|
|
@@ -615,25 +607,21 @@ exports[`rendering renders correctly when length is 6 and secure is false 1`] =
|
|
|
615
607
|
Array [
|
|
616
608
|
Object {
|
|
617
609
|
"color": "#001f23",
|
|
618
|
-
"fontFamily": "BeVietnamPro-
|
|
619
|
-
"fontSize":
|
|
620
|
-
"letterSpacing": 0.
|
|
621
|
-
"lineHeight":
|
|
610
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
611
|
+
"fontSize": 28,
|
|
612
|
+
"letterSpacing": 0.24,
|
|
613
|
+
"lineHeight": 36,
|
|
622
614
|
},
|
|
623
615
|
Array [
|
|
624
616
|
Object {
|
|
625
617
|
"color": "#001f23",
|
|
626
|
-
"fontFamily": "BeVietnamPro-SemiBold",
|
|
627
|
-
"fontSize": 28,
|
|
628
|
-
"lineHeight": 36,
|
|
629
618
|
},
|
|
630
619
|
undefined,
|
|
631
620
|
],
|
|
632
621
|
]
|
|
633
622
|
}
|
|
634
|
-
themeFontSize="medium"
|
|
635
|
-
themeFontWeight="regular"
|
|
636
623
|
themeIntent="body"
|
|
624
|
+
themeLevel="h3"
|
|
637
625
|
themeState="default"
|
|
638
626
|
themeTypeface="neutral"
|
|
639
627
|
>
|
|
@@ -1036,25 +1024,21 @@ exports[`rendering renders correctly when there is error 1`] = `
|
|
|
1036
1024
|
Object {
|
|
1037
1025
|
"color": "#001f23",
|
|
1038
1026
|
"fontFamily": "BeVietnamPro-Regular",
|
|
1039
|
-
"fontSize":
|
|
1040
|
-
"letterSpacing": 0.
|
|
1041
|
-
"lineHeight":
|
|
1027
|
+
"fontSize": 12,
|
|
1028
|
+
"letterSpacing": 0.48,
|
|
1029
|
+
"lineHeight": 16,
|
|
1042
1030
|
},
|
|
1043
1031
|
Array [
|
|
1044
1032
|
Object {
|
|
1045
1033
|
"color": "#de350b",
|
|
1046
|
-
"fontFamily": "BeVietnamPro-Regular",
|
|
1047
|
-
"fontSize": 12,
|
|
1048
1034
|
"paddingLeft": 4,
|
|
1049
1035
|
},
|
|
1050
1036
|
undefined,
|
|
1051
1037
|
],
|
|
1052
1038
|
]
|
|
1053
1039
|
}
|
|
1054
|
-
themeFontSize="medium"
|
|
1055
1040
|
themeFontWeight="regular"
|
|
1056
1041
|
themeIntent="body"
|
|
1057
|
-
themeTypeface="neutral"
|
|
1058
1042
|
>
|
|
1059
1043
|
PIN is not correct
|
|
1060
1044
|
</Text>
|
|
@@ -171,9 +171,7 @@ const ProgressCircle = ({
|
|
|
171
171
|
<StyledStrokeEnd themeIntent={intent} />
|
|
172
172
|
</Animated.View>
|
|
173
173
|
<StyledDonutCircle>
|
|
174
|
-
<Typography.
|
|
175
|
-
{renderValue(value)}
|
|
176
|
-
</Typography.Text>
|
|
174
|
+
<Typography.Body>{renderValue(value)}</Typography.Body>
|
|
177
175
|
</StyledDonutCircle>
|
|
178
176
|
</StyledContainer>
|
|
179
177
|
</View>
|