@hero-design/rn 8.44.0-alpha.0 → 8.44.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/CHANGELOG.md +30 -0
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +2773 -2662
- package/jest-setup.ts +2 -0
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +2776 -2666
- package/package.json +23 -24
- package/rollup.config.js +0 -1
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +564 -384
- package/src/components/Accordion/__tests__/__snapshots__/StyledAccordion.spec.tsx.snap +76 -20
- package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +791 -605
- package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +848 -567
- package/src/components/Attachment/__tests__/__snapshots__/index.spec.tsx.snap +172 -110
- package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/StyledAvatarStack.spec.tsx.snap +138 -70
- package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/index.spec.tsx.snap +745 -581
- package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +158 -57
- package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +273 -153
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +391 -223
- package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +119 -63
- package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +306 -242
- package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +317 -183
- package/src/components/Box/__tests__/__snapshots__/index.spec.tsx.snap +1042 -454
- package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +6 -10
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +400 -140
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +1090 -880
- package/src/components/Button/StyledButton.tsx +4 -0
- package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +196 -106
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +1675 -1125
- package/src/components/Button/__tests__/__snapshots__/IconButton.spec.tsx.snap +71 -26
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +1651 -665
- package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +555 -330
- package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +265 -69
- package/src/components/Card/DataCard/__tests__/__snapshots__/index.spec.tsx.snap +205 -65
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +36 -8
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +292 -124
- package/src/components/Carousel/CardCarousel.tsx +10 -7
- package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +486 -406
- package/src/components/Carousel/__tests__/__snapshots__/StyledCardCarousel.spec.tsx.snap +197 -70
- package/src/components/Carousel/__tests__/__snapshots__/StyledCarousel.spec.tsx.snap +41 -13
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +1742 -1526
- package/src/components/Carousel/__tests__/index.spec.tsx +50 -3
- package/src/components/Carousel/index.tsx +16 -22
- package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +404 -112
- package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +574 -334
- package/src/components/Chip/StyledChip.tsx +121 -0
- package/src/components/Chip/__tests__/__snapshots__/index.spec.tsx.snap +1483 -0
- package/src/components/Chip/__tests__/index.spec.tsx +136 -0
- package/src/components/Chip/index.tsx +82 -0
- package/src/components/Collapse/__tests__/__snapshots__/StyledCollapse.spec.tsx.snap +73 -17
- package/src/components/Collapse/__tests__/__snapshots__/index.spec.tsx.snap +94 -38
- package/src/components/Collapse/index.tsx +1 -1
- package/src/components/ContentNavigator/__tests__/__snapshots__/StyledContentNavigator.spec.tsx.snap +37 -9
- package/src/components/ContentNavigator/__tests__/__snapshots__/index.spec.tsx.snap +424 -268
- package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +586 -466
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +200 -160
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +192 -152
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +471 -389
- package/src/components/Divider/__tests__/__snapshots__/StyledDivider.spec.tsx.snap +464 -128
- package/src/components/Drawer/DragableDrawer/__tests__/__snapshots__/index.spec.tsx.snap +97 -69
- package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +327 -192
- package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +169 -113
- package/src/components/Error/StyledError.tsx +2 -1
- package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +390 -262
- package/src/components/Error/__tests__/index.spec.tsx +9 -6
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +860 -723
- package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +98 -42
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +199 -99
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +293 -185
- package/src/components/HeroDesignProvider/__tests__/__snapshots__/index.spec.tsx.snap +45 -17
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +3 -0
- package/src/components/Icon/__tests__/__snapshots__/index.spec.tsx.snap +158 -46
- package/src/components/Image/__tests__/__snapshots__/index.spec.tsx.snap +164 -52
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +242 -170
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +760 -588
- package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +272 -128
- package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +477 -193
- package/src/components/Modal/__tests__/__snapshots__/index.spec.tsx.snap +169 -0
- package/src/components/Modal/__tests__/index.spec.tsx +99 -0
- package/src/components/Modal/index.tsx +178 -82
- package/src/components/PageControl/__tests__/__snapshots__/index.spec.tsx.snap +84 -41
- package/src/components/PageControl/index.tsx +1 -0
- package/src/components/PinInput/__tests__/StyledPinInput.spec.tsx +9 -4
- package/src/components/PinInput/__tests__/__snapshots__/PinCell.spec.tsx.snap +293 -153
- package/src/components/PinInput/__tests__/__snapshots__/StyledPinInput.spec.tsx.snap +15 -48
- package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +809 -697
- package/src/components/Portal/__tests__/PortalHost.spec.tsx +12 -14
- package/src/components/Portal/__tests__/__snapshots__/index.spec.tsx.snap +43 -15
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +743 -603
- package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +188 -116
- package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +257 -205
- package/src/components/Rate/__tests__/__snapshots__/index.spec.tsx.snap +864 -600
- package/src/components/RefreshControl/__tests__/__snapshots__/index.spec.tsx.snap +128 -44
- package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +5 -2
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +3 -3
- package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +413 -266
- package/src/components/RichTextEditor/__tests__/__snapshots__/MentionList.spec.tsx.snap +64 -35
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +371 -297
- package/src/components/SectionHeading/__tests__/__snapshots__/StyledHeading.spec.tsx.snap +158 -46
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +394 -226
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +93 -57
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +2387 -2151
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +621 -28
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +7 -6
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +73 -37
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +2321 -2085
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +473 -23
- package/src/components/Skeleton/__tests__/__snapshots__/index.spec.tsx.snap +490 -294
- package/src/components/Slider/__tests__/__snapshots__/index.spec.tsx.snap +117 -33
- package/src/components/Spinner/__tests__/__snapshots__/AnimatedSpinner.spec.tsx.snap +105 -77
- package/src/components/Spinner/__tests__/__snapshots__/StyledSpinner.spec.tsx.snap +1308 -636
- package/src/components/Spinner/__tests__/__snapshots__/index.spec.tsx.snap +121 -93
- package/src/components/Success/StyledSuccess.tsx +2 -1
- package/src/components/Success/__tests__/__snapshots__/index.spec.tsx.snap +388 -258
- package/src/components/Success/__tests__/index.spec.tsx +9 -6
- package/src/components/Swipeable/__tests__/__snapshots__/SwipeableAction.spec.tsx.snap +210 -75
- package/src/components/Swipeable/__tests__/__snapshots__/index.spec.tsx.snap +58 -30
- package/src/components/Swipeable/index.tsx +3 -3
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +226 -114
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +146 -109
- package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +202 -62
- package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +132 -68
- package/src/components/Tabs/__tests__/SceneView.spec.tsx +7 -7
- package/src/components/Tabs/__tests__/__snapshots__/SceneView.spec.tsx.snap +206 -94
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +2217 -1962
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +523 -455
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +121 -65
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +1641 -1398
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +554 -274
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1542 -646
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +3177 -2701
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +390 -310
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +662 -540
- package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +871 -573
- package/src/components/Toast/__tests__/__snapshots__/ToastContainer.spec.tsx.snap +180 -68
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +582 -426
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +683 -363
- package/src/components/Typography/Body/__tests__/__snapshots__/StyledBody.tsx.snap +704 -256
- package/src/components/Typography/Body/__tests__/__snapshots__/index.spec.tsx.snap +855 -323
- package/src/components/Typography/Caption/__tests__/__snapshots__/StyledCaption.spec.tsx.snap +430 -150
- package/src/components/Typography/Caption/__tests__/__snapshots__/index.spec.tsx.snap +572 -208
- package/src/components/Typography/Label/__tests__/__snapshots__/StyledLabel.tsx.snap +328 -104
- package/src/components/Typography/Label/__tests__/__snapshots__/index.spec.tsx.snap +462 -154
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +900 -340
- package/src/components/Typography/Title/__tests__/__snapshots__/StyledTitle.tsx.snap +880 -320
- package/src/components/Typography/Title/__tests__/__snapshots__/index.spec.tsx.snap +1035 -391
- package/src/index.ts +2 -2
- package/src/testHelpers/renderWithTheme.tsx +2 -2
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +38 -1
- package/src/theme/components/button.ts +0 -1
- package/src/theme/components/chip.ts +47 -0
- package/src/theme/getTheme.ts +3 -0
- package/testUtils/setup.tsx +0 -18
- package/tsconfig.json +4 -1
- package/types/components/Accordion/AccordionItem.d.ts +2 -1
- package/types/components/Accordion/index.d.ts +1 -1
- package/types/components/Attachment/index.d.ts +2 -1
- package/types/components/Avatar/Avatar.d.ts +2 -1
- package/types/components/Avatar/AvatarStack/index.d.ts +2 -2
- package/types/components/Avatar/index.d.ts +3 -2
- package/types/components/Badge/StyledBadge.d.ts +0 -4
- package/types/components/BottomSheet/Footer.d.ts +2 -1
- package/types/components/BottomSheet/Header.d.ts +2 -1
- package/types/components/BottomSheet/ScrollView.d.ts +1 -0
- package/types/components/BottomSheet/StyledBottomSheet.d.ts +0 -4
- package/types/components/Box/index.d.ts +2 -1
- package/types/components/Button/IconButton.d.ts +2 -1
- package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +3 -3
- package/types/components/Button/LoadingIndicator/index.d.ts +2 -1
- package/types/components/Button/UtilityButton/index.d.ts +2 -1
- package/types/components/Calendar/CalendarRowItem.d.ts +2 -1
- package/types/components/Calendar/StyledCalendar.d.ts +1 -1
- package/types/components/Calendar/index.d.ts +2 -1
- package/types/components/Carousel/CardCarousel.d.ts +1 -1
- package/types/components/Carousel/CarouselItem.d.ts +2 -1
- package/types/components/Carousel/index.d.ts +2 -2
- package/types/components/Checkbox/index.d.ts +2 -1
- package/types/components/Chip/StyledChip.d.ts +31 -0
- package/types/components/Chip/index.d.ts +27 -0
- package/types/components/Collapse/StyledCollapse.d.ts +0 -2
- package/types/components/Collapse/index.d.ts +2 -1
- package/types/components/ContentNavigator/index.d.ts +2 -1
- package/types/components/DatePicker/DatePickerAndroid.d.ts +2 -1
- package/types/components/DatePicker/DatePickerCalendar.d.ts +2 -1
- package/types/components/DatePicker/DatePickerIOS.d.ts +2 -1
- package/types/components/DatePicker/index.d.ts +2 -1
- package/types/components/Divider/index.d.ts +2 -1
- package/types/components/Drawer/StyledDrawer.d.ts +0 -6
- package/types/components/Error/StyledError.d.ts +3 -9
- package/types/components/FAB/ActionGroup/ActionItem.d.ts +2 -1
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -4
- package/types/components/FAB/AnimatedFABIcon.d.ts +2 -1
- package/types/components/HeroDesignProvider/index.d.ts +2 -1
- package/types/components/Icon/AnimatedIcon.d.ts +2 -1
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +3 -2
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/Image/index.d.ts +1 -0
- package/types/components/Modal/index.d.ts +12 -8
- package/types/components/PageControl/StyledPageControl.d.ts +0 -2
- package/types/components/PageControl/index.d.ts +2 -1
- package/types/components/PinInput/PinCell.d.ts +2 -1
- package/types/components/Portal/PortalHost.d.ts +1 -1
- package/types/components/Portal/PortalProvider.d.ts +1 -1
- package/types/components/Portal/index.d.ts +2 -2
- package/types/components/Progress/ProgressBar.d.ts +1 -0
- package/types/components/Progress/StyledProgressBar.d.ts +0 -2
- package/types/components/Progress/index.d.ts +1 -0
- package/types/components/Rate/StyledRate.d.ts +0 -2
- package/types/components/Rate/index.d.ts +2 -1
- package/types/components/RefreshControl/index.d.ts +2 -1
- package/types/components/RichTextEditor/EditorToolbar.d.ts +2 -1
- package/types/components/RichTextEditor/MentionList.d.ts +2 -1
- package/types/components/RichTextEditor/index.d.ts +2 -2
- package/types/components/Select/BaseOptionList.d.ts +1 -1
- package/types/components/Select/Footer.d.ts +2 -1
- package/types/components/Select/MultiSelect/Option.d.ts +2 -1
- package/types/components/Select/MultiSelect/OptionList.d.ts +2 -1
- package/types/components/Select/MultiSelect/index.d.ts +1 -1
- package/types/components/Select/SingleSelect/Option.d.ts +2 -1
- package/types/components/Select/SingleSelect/OptionList.d.ts +1 -1
- package/types/components/Select/SingleSelect/StyledSingleSelect.d.ts +2 -1
- package/types/components/Select/SingleSelect/index.d.ts +1 -1
- package/types/components/Select/helpers.d.ts +1 -2
- package/types/components/Select/index.d.ts +2 -1
- package/types/components/Skeleton/index.d.ts +2 -1
- package/types/components/Slider/index.d.ts +2 -1
- package/types/components/Spinner/AnimatedSpinner.d.ts +2 -1
- package/types/components/Success/StyledSuccess.d.ts +3 -7
- package/types/components/Swipeable/SwipeableAction.d.ts +2 -2
- package/types/components/Swipeable/index.d.ts +3 -3
- package/types/components/Switch/SelectorSwitch/Option.d.ts +2 -1
- package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +0 -6
- package/types/components/Switch/StyledSwitch.d.ts +0 -2
- package/types/components/Tabs/ActiveTabIndicator.d.ts +2 -1
- package/types/components/Tabs/SceneView.d.ts +1 -1
- package/types/components/Tabs/ScrollableTabs.d.ts +2 -1
- package/types/components/Tabs/ScrollableTabsHeader.d.ts +2 -1
- package/types/components/Tabs/StyledScrollableTabs.d.ts +0 -4
- package/types/components/Tabs/StyledTabs.d.ts +0 -4
- package/types/components/Tabs/TabWithBadge.d.ts +2 -2
- package/types/components/Tabs/index.d.ts +2 -1
- package/types/components/TextInput/StyledTextInput.d.ts +1 -1
- package/types/components/TextInput/index.d.ts +1 -1
- package/types/components/TimePicker/TimePickerAndroid.d.ts +2 -1
- package/types/components/TimePicker/TimePickerIOS.d.ts +2 -1
- package/types/components/TimePicker/index.d.ts +2 -1
- package/types/components/Toast/StyledToast.d.ts +0 -2
- package/types/components/Toast/Toast.d.ts +1 -0
- package/types/components/Toast/ToastProvider.d.ts +2 -1
- package/types/components/Toast/index.d.ts +1 -1
- package/types/components/Toolbar/ToolbarGroup.d.ts +2 -1
- package/types/components/Toolbar/ToolbarItem.d.ts +2 -1
- package/types/components/Toolbar/index.d.ts +3 -2
- package/types/components/Typography/Body/index.d.ts +2 -1
- package/types/components/Typography/Caption/index.d.ts +2 -1
- package/types/components/Typography/Label/index.d.ts +2 -1
- package/types/components/Typography/Text/index.d.ts +2 -1
- package/types/components/Typography/Title/index.d.ts +2 -1
- package/types/index.d.ts +2 -2
- package/types/testHelpers/renderWithTheme.d.ts +1 -0
- package/types/theme/ThemeSwitcher.d.ts +2 -2
- package/types/theme/components/button.d.ts +0 -1
- package/types/theme/components/chip.d.ts +40 -0
- package/types/theme/getTheme.d.ts +2 -0
- package/.turbo/turbo-publish:npm.log +0 -0
- package/src/components/Modal/ModalContentWrapper.tsx +0 -112
- package/src/components/Modal/ModalPresenter/ModalPresenter.tsx +0 -135
- package/src/components/Modal/ModalPresenter/index.tsx +0 -9
- package/src/components/Modal/ModalProvider.tsx +0 -8
- package/types/components/Modal/ModalContentWrapper.d.ts +0 -16
- package/types/components/Modal/ModalPresenter/ModalPresenter.d.ts +0 -34
- package/types/components/Modal/ModalPresenter/index.d.ts +0 -3
- package/types/components/Modal/ModalProvider.d.ts +0 -5
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent } from '@testing-library/react-native';
|
|
3
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
|
+
import Chip from '..';
|
|
5
|
+
|
|
6
|
+
describe('Chip', () => {
|
|
7
|
+
it.each`
|
|
8
|
+
selected
|
|
9
|
+
${true}
|
|
10
|
+
${false}
|
|
11
|
+
`('renders correctly when selected is $selected', ({ selected }) => {
|
|
12
|
+
const { getByText, toJSON } = renderWithTheme(
|
|
13
|
+
<Chip label="Cover my bills" selected={selected} />
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expect(getByText('Cover my bills')).toBeTruthy();
|
|
17
|
+
expect(toJSON()).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('renders correctly with default icon', () => {
|
|
21
|
+
const ChipWithoutIcon = () => {
|
|
22
|
+
const [selected, setSelected] = React.useState(false);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Chip
|
|
26
|
+
label="Cover my bills"
|
|
27
|
+
testID="chip"
|
|
28
|
+
selected={selected}
|
|
29
|
+
onPress={() => setSelected(!selected)}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { getByTestId, queryByTestId, toJSON } = renderWithTheme(
|
|
35
|
+
<ChipWithoutIcon />
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expect(queryByTestId('chip-icon-checkmark')).toBeFalsy();
|
|
39
|
+
expect(toJSON()).toMatchSnapshot();
|
|
40
|
+
|
|
41
|
+
fireEvent.press(getByTestId('chip'));
|
|
42
|
+
|
|
43
|
+
expect(getByTestId('chip-icon-checkmark')).toBeTruthy();
|
|
44
|
+
expect(toJSON()).toMatchSnapshot();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('does not render icon when variant is outlined', () => {
|
|
48
|
+
const ChipWithIcon = () => {
|
|
49
|
+
const [selected, setSelected] = React.useState(false);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Chip
|
|
53
|
+
label="Cover my bills"
|
|
54
|
+
testID="chip"
|
|
55
|
+
icon="charging-station-outlined"
|
|
56
|
+
selected={selected}
|
|
57
|
+
variant="outlined"
|
|
58
|
+
onPress={() => setSelected(!selected)}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const { getByTestId, toJSON, queryByTestId } = renderWithTheme(
|
|
64
|
+
<ChipWithIcon />
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
expect(queryByTestId('chip-icon-charging-station-outlined')).toBeFalsy();
|
|
68
|
+
expect(toJSON()).toMatchSnapshot();
|
|
69
|
+
|
|
70
|
+
fireEvent.press(getByTestId('chip'));
|
|
71
|
+
|
|
72
|
+
expect(queryByTestId('chip-icon-charging-station-outlined')).toBeFalsy();
|
|
73
|
+
expect(toJSON()).toMatchSnapshot();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('renders correctly with custom icon', () => {
|
|
77
|
+
const ChipWithIcon = () => {
|
|
78
|
+
const [selected, setSelected] = React.useState(false);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Chip
|
|
82
|
+
label="Cover my bills"
|
|
83
|
+
testID="chip"
|
|
84
|
+
icon="charging-station-outlined"
|
|
85
|
+
selected={selected}
|
|
86
|
+
variant="filled"
|
|
87
|
+
onPress={() => setSelected(!selected)}
|
|
88
|
+
/>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const { getByTestId, toJSON } = renderWithTheme(<ChipWithIcon />);
|
|
93
|
+
|
|
94
|
+
expect(getByTestId('chip-icon-charging-station-outlined')).toBeTruthy();
|
|
95
|
+
expect(toJSON()).toMatchSnapshot();
|
|
96
|
+
|
|
97
|
+
fireEvent.press(getByTestId('chip'));
|
|
98
|
+
|
|
99
|
+
expect(getByTestId('chip-icon-charging-station-outlined')).toBeTruthy();
|
|
100
|
+
expect(toJSON()).toMatchSnapshot();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it.each`
|
|
104
|
+
variant | selected
|
|
105
|
+
${'filled'} | ${true}
|
|
106
|
+
${'filled'} | ${false}
|
|
107
|
+
${'outlined'} | ${true}
|
|
108
|
+
${'outlined'} | ${false}
|
|
109
|
+
`(
|
|
110
|
+
'renders correctly with variant $variant and selected $selected',
|
|
111
|
+
({ variant, selected }) => {
|
|
112
|
+
const { toJSON } = renderWithTheme(
|
|
113
|
+
<Chip
|
|
114
|
+
label="Cover my bills"
|
|
115
|
+
testID="chip"
|
|
116
|
+
variant={variant}
|
|
117
|
+
selected={selected}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
expect(toJSON()).toMatchSnapshot();
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
it('calls onPress when pressed', () => {
|
|
126
|
+
const onPress = jest.fn();
|
|
127
|
+
|
|
128
|
+
const { getByTestId } = renderWithTheme(
|
|
129
|
+
<Chip label="Cover my bills" testID="chip" onPress={onPress} />
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
fireEvent.press(getByTestId('chip'));
|
|
133
|
+
|
|
134
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
import { IconName } from '../Icon';
|
|
4
|
+
import {
|
|
5
|
+
StyledChipWrapper,
|
|
6
|
+
StyledIcon,
|
|
7
|
+
StyledIconWrapper,
|
|
8
|
+
StyledLabel,
|
|
9
|
+
} from './StyledChip';
|
|
10
|
+
|
|
11
|
+
export interface ChipProps extends ViewProps {
|
|
12
|
+
/**
|
|
13
|
+
* The label of the chip.
|
|
14
|
+
*/
|
|
15
|
+
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* Variant of the chip.
|
|
18
|
+
*/
|
|
19
|
+
variant?: 'outlined' | 'filled';
|
|
20
|
+
/**
|
|
21
|
+
* Whether the chip is selected.
|
|
22
|
+
*/
|
|
23
|
+
selected?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Icon of the chip. Usable only with `variant="filled"`.
|
|
26
|
+
*/
|
|
27
|
+
icon?: IconName;
|
|
28
|
+
/**
|
|
29
|
+
* Callback when the chip is pressed.
|
|
30
|
+
*/
|
|
31
|
+
onPress?: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const Chip = ({
|
|
35
|
+
label,
|
|
36
|
+
variant = 'outlined',
|
|
37
|
+
selected = false,
|
|
38
|
+
icon,
|
|
39
|
+
onPress,
|
|
40
|
+
...otherProps
|
|
41
|
+
}: ChipProps) => {
|
|
42
|
+
const internalIcon = React.useMemo(() => {
|
|
43
|
+
if (icon && variant === 'filled') {
|
|
44
|
+
return icon;
|
|
45
|
+
}
|
|
46
|
+
if (selected) {
|
|
47
|
+
return 'checkmark';
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}, [icon, selected, variant]);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<StyledChipWrapper
|
|
54
|
+
onPress={onPress}
|
|
55
|
+
themeVariant={variant}
|
|
56
|
+
themeSelected={selected}
|
|
57
|
+
{...otherProps}
|
|
58
|
+
>
|
|
59
|
+
{internalIcon && (
|
|
60
|
+
<StyledIconWrapper>
|
|
61
|
+
<StyledIcon
|
|
62
|
+
size="xsmall"
|
|
63
|
+
icon={internalIcon}
|
|
64
|
+
themeSelected={selected}
|
|
65
|
+
themeVariant={variant}
|
|
66
|
+
testID={`chip-icon-${internalIcon}`}
|
|
67
|
+
/>
|
|
68
|
+
</StyledIconWrapper>
|
|
69
|
+
)}
|
|
70
|
+
|
|
71
|
+
<StyledLabel
|
|
72
|
+
variant="small"
|
|
73
|
+
themeVariant={variant}
|
|
74
|
+
themeSelected={selected}
|
|
75
|
+
>
|
|
76
|
+
{label}
|
|
77
|
+
</StyledLabel>
|
|
78
|
+
</StyledChipWrapper>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default Chip;
|
|
@@ -3,34 +3,90 @@
|
|
|
3
3
|
exports[`StyledChildWrapper renders correct style 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
style={
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"padding": 0,
|
|
10
|
-
},
|
|
11
|
-
undefined,
|
|
12
|
-
]
|
|
6
|
+
{
|
|
7
|
+
"flex": 1,
|
|
8
|
+
}
|
|
13
9
|
}
|
|
14
10
|
>
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
<View
|
|
12
|
+
style={
|
|
13
|
+
[
|
|
14
|
+
{
|
|
15
|
+
"margin": 0,
|
|
16
|
+
"padding": 0,
|
|
17
|
+
},
|
|
18
|
+
undefined,
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
>
|
|
22
|
+
<Text>
|
|
23
|
+
Sample Child
|
|
24
|
+
</Text>
|
|
25
|
+
</View>
|
|
26
|
+
<View
|
|
27
|
+
pointerEvents="box-none"
|
|
28
|
+
position="bottom"
|
|
29
|
+
style={
|
|
30
|
+
[
|
|
31
|
+
{
|
|
32
|
+
"bottom": 0,
|
|
33
|
+
"elevation": 9999,
|
|
34
|
+
"flexDirection": "column-reverse",
|
|
35
|
+
"left": 0,
|
|
36
|
+
"paddingHorizontal": 24,
|
|
37
|
+
"paddingVertical": 16,
|
|
38
|
+
"position": "absolute",
|
|
39
|
+
"right": 0,
|
|
40
|
+
"top": 0,
|
|
41
|
+
},
|
|
42
|
+
undefined,
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
/>
|
|
18
46
|
</View>
|
|
19
47
|
`;
|
|
20
48
|
|
|
21
49
|
exports[`StyledWrapper renders correct style 1`] = `
|
|
22
50
|
<View
|
|
23
|
-
collapsable={false}
|
|
24
51
|
style={
|
|
25
52
|
{
|
|
26
|
-
"
|
|
27
|
-
"overflow": "hidden",
|
|
28
|
-
"padding": 0,
|
|
53
|
+
"flex": 1,
|
|
29
54
|
}
|
|
30
55
|
}
|
|
31
56
|
>
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
57
|
+
<View
|
|
58
|
+
collapsable={false}
|
|
59
|
+
style={
|
|
60
|
+
{
|
|
61
|
+
"margin": 0,
|
|
62
|
+
"overflow": "hidden",
|
|
63
|
+
"padding": 0,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
>
|
|
67
|
+
<Text>
|
|
68
|
+
Sample Child
|
|
69
|
+
</Text>
|
|
70
|
+
</View>
|
|
71
|
+
<View
|
|
72
|
+
pointerEvents="box-none"
|
|
73
|
+
position="bottom"
|
|
74
|
+
style={
|
|
75
|
+
[
|
|
76
|
+
{
|
|
77
|
+
"bottom": 0,
|
|
78
|
+
"elevation": 9999,
|
|
79
|
+
"flexDirection": "column-reverse",
|
|
80
|
+
"left": 0,
|
|
81
|
+
"paddingHorizontal": 24,
|
|
82
|
+
"paddingVertical": 16,
|
|
83
|
+
"position": "absolute",
|
|
84
|
+
"right": 0,
|
|
85
|
+
"top": 0,
|
|
86
|
+
},
|
|
87
|
+
undefined,
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
/>
|
|
35
91
|
</View>
|
|
36
92
|
`;
|
|
@@ -2,88 +2,144 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Collapse renders correctly 1`] = `
|
|
4
4
|
<View
|
|
5
|
-
collapsable={false}
|
|
6
|
-
onLayout={[Function]}
|
|
7
5
|
style={
|
|
8
6
|
{
|
|
9
|
-
"
|
|
10
|
-
"margin": 0,
|
|
11
|
-
"overflow": "hidden",
|
|
12
|
-
"padding": 0,
|
|
7
|
+
"flex": 1,
|
|
13
8
|
}
|
|
14
9
|
}
|
|
15
|
-
testID="collapse"
|
|
16
10
|
>
|
|
17
11
|
<View
|
|
12
|
+
collapsable={false}
|
|
13
|
+
onLayout={[Function]}
|
|
18
14
|
style={
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
{
|
|
16
|
+
"height": 0,
|
|
17
|
+
"margin": 0,
|
|
18
|
+
"overflow": "hidden",
|
|
19
|
+
"padding": 0,
|
|
20
|
+
}
|
|
25
21
|
}
|
|
22
|
+
testID="collapse"
|
|
26
23
|
>
|
|
27
24
|
<View
|
|
28
|
-
onLayout={[Function]}
|
|
29
25
|
style={
|
|
30
26
|
[
|
|
31
27
|
{
|
|
32
|
-
"
|
|
33
|
-
"padding": 0,
|
|
28
|
+
"height": 1334,
|
|
34
29
|
},
|
|
35
30
|
undefined,
|
|
36
31
|
]
|
|
37
32
|
}
|
|
38
33
|
>
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
<View
|
|
35
|
+
onLayout={[Function]}
|
|
36
|
+
style={
|
|
37
|
+
[
|
|
38
|
+
{
|
|
39
|
+
"margin": 0,
|
|
40
|
+
"padding": 0,
|
|
41
|
+
},
|
|
42
|
+
undefined,
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
<Text>
|
|
47
|
+
Sample Text
|
|
48
|
+
</Text>
|
|
49
|
+
</View>
|
|
42
50
|
</View>
|
|
43
51
|
</View>
|
|
52
|
+
<View
|
|
53
|
+
pointerEvents="box-none"
|
|
54
|
+
position="bottom"
|
|
55
|
+
style={
|
|
56
|
+
[
|
|
57
|
+
{
|
|
58
|
+
"bottom": 0,
|
|
59
|
+
"elevation": 9999,
|
|
60
|
+
"flexDirection": "column-reverse",
|
|
61
|
+
"left": 0,
|
|
62
|
+
"paddingHorizontal": 24,
|
|
63
|
+
"paddingVertical": 16,
|
|
64
|
+
"position": "absolute",
|
|
65
|
+
"right": 0,
|
|
66
|
+
"top": 0,
|
|
67
|
+
},
|
|
68
|
+
undefined,
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
/>
|
|
44
72
|
</View>
|
|
45
73
|
`;
|
|
46
74
|
|
|
47
75
|
exports[`Collapse should render Sample Text but not visible 1`] = `
|
|
48
76
|
<View
|
|
49
|
-
collapsable={false}
|
|
50
|
-
onLayout={[Function]}
|
|
51
77
|
style={
|
|
52
78
|
{
|
|
53
|
-
"
|
|
54
|
-
"margin": 0,
|
|
55
|
-
"overflow": "hidden",
|
|
56
|
-
"padding": 0,
|
|
79
|
+
"flex": 1,
|
|
57
80
|
}
|
|
58
81
|
}
|
|
59
|
-
testID="collapse"
|
|
60
82
|
>
|
|
61
83
|
<View
|
|
84
|
+
collapsable={false}
|
|
85
|
+
onLayout={[Function]}
|
|
62
86
|
style={
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
87
|
+
{
|
|
88
|
+
"height": 0,
|
|
89
|
+
"margin": 0,
|
|
90
|
+
"overflow": "hidden",
|
|
91
|
+
"padding": 0,
|
|
92
|
+
}
|
|
69
93
|
}
|
|
94
|
+
testID="collapse"
|
|
70
95
|
>
|
|
71
96
|
<View
|
|
72
|
-
onLayout={[Function]}
|
|
73
97
|
style={
|
|
74
98
|
[
|
|
75
99
|
{
|
|
76
|
-
"
|
|
77
|
-
"padding": 0,
|
|
100
|
+
"height": 1334,
|
|
78
101
|
},
|
|
79
102
|
undefined,
|
|
80
103
|
]
|
|
81
104
|
}
|
|
82
105
|
>
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
<View
|
|
107
|
+
onLayout={[Function]}
|
|
108
|
+
style={
|
|
109
|
+
[
|
|
110
|
+
{
|
|
111
|
+
"margin": 0,
|
|
112
|
+
"padding": 0,
|
|
113
|
+
},
|
|
114
|
+
undefined,
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
>
|
|
118
|
+
<Text>
|
|
119
|
+
Sample Text
|
|
120
|
+
</Text>
|
|
121
|
+
</View>
|
|
86
122
|
</View>
|
|
87
123
|
</View>
|
|
124
|
+
<View
|
|
125
|
+
pointerEvents="box-none"
|
|
126
|
+
position="bottom"
|
|
127
|
+
style={
|
|
128
|
+
[
|
|
129
|
+
{
|
|
130
|
+
"bottom": 0,
|
|
131
|
+
"elevation": 9999,
|
|
132
|
+
"flexDirection": "column-reverse",
|
|
133
|
+
"left": 0,
|
|
134
|
+
"paddingHorizontal": 24,
|
|
135
|
+
"paddingVertical": 16,
|
|
136
|
+
"position": "absolute",
|
|
137
|
+
"right": 0,
|
|
138
|
+
"top": 0,
|
|
139
|
+
},
|
|
140
|
+
undefined,
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
/>
|
|
88
144
|
</View>
|
|
89
145
|
`;
|
package/src/components/ContentNavigator/__tests__/__snapshots__/StyledContentNavigator.spec.tsx.snap
CHANGED
|
@@ -3,14 +3,42 @@
|
|
|
3
3
|
exports[`Wrapper has correct style 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
style={
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"flexDirection": "row",
|
|
10
|
-
"justifyContent": "space-between",
|
|
11
|
-
},
|
|
12
|
-
undefined,
|
|
13
|
-
]
|
|
6
|
+
{
|
|
7
|
+
"flex": 1,
|
|
8
|
+
}
|
|
14
9
|
}
|
|
15
|
-
|
|
10
|
+
>
|
|
11
|
+
<View
|
|
12
|
+
style={
|
|
13
|
+
[
|
|
14
|
+
{
|
|
15
|
+
"flex": 1,
|
|
16
|
+
"flexDirection": "row",
|
|
17
|
+
"justifyContent": "space-between",
|
|
18
|
+
},
|
|
19
|
+
undefined,
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
/>
|
|
23
|
+
<View
|
|
24
|
+
pointerEvents="box-none"
|
|
25
|
+
position="bottom"
|
|
26
|
+
style={
|
|
27
|
+
[
|
|
28
|
+
{
|
|
29
|
+
"bottom": 0,
|
|
30
|
+
"elevation": 9999,
|
|
31
|
+
"flexDirection": "column-reverse",
|
|
32
|
+
"left": 0,
|
|
33
|
+
"paddingHorizontal": 24,
|
|
34
|
+
"paddingVertical": 16,
|
|
35
|
+
"position": "absolute",
|
|
36
|
+
"right": 0,
|
|
37
|
+
"top": 0,
|
|
38
|
+
},
|
|
39
|
+
undefined,
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
/>
|
|
43
|
+
</View>
|
|
16
44
|
`;
|