@hero-design/rn 7.6.1-alpha.0 → 7.8.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/.expo/README.md +15 -0
- package/.expo/packager-info.json +10 -0
- package/.expo/prebuild/cached-packages.json +4 -0
- package/.expo/settings.json +10 -0
- package/.expo/xcodebuild-error.log +2 -0
- package/.expo/xcodebuild.log +11199 -0
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-publish:npm.log +0 -0
- package/es/index.js +4528 -432
- package/lib/index.js +4616 -516
- package/package.json +6 -8
- package/rollup.config.js +1 -7
- package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/Avatar/index.tsx +1 -1
- package/src/components/Button/Button.tsx +4 -2
- package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +7 -2
- package/src/components/Button/LoadingIndicator/__tests__/StyledLoadingIndicator.spec.tsx +2 -0
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +40 -0
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +242 -0
- package/src/components/Button/LoadingIndicator/__tests__/index.spec.tsx +2 -0
- package/src/components/Button/LoadingIndicator/index.tsx +3 -1
- package/src/components/Button/StyledButton.tsx +15 -2
- package/src/components/Button/__tests__/Button.spec.tsx +2 -0
- package/src/components/Button/__tests__/StyledButton.spec.tsx +12 -0
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +314 -0
- package/src/components/Card/DataCard/StyledDataCard.tsx +20 -0
- package/src/components/Card/DataCard/__tests__/StyledDataCard.spec.tsx +24 -0
- package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +97 -0
- package/src/components/Card/DataCard/__tests__/__snapshots__/index.spec.tsx.snap +156 -0
- package/src/components/Card/DataCard/__tests__/index.spec.tsx +30 -0
- package/src/components/Card/DataCard/index.tsx +35 -0
- package/src/components/Card/index.tsx +7 -2
- package/src/components/Checkbox/StyledCheckbox.tsx +18 -0
- package/src/components/Checkbox/__tests__/StyledCheckbox.spec.tsx +10 -0
- package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +31 -0
- package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +63 -0
- package/src/components/Checkbox/__tests__/index.spec.tsx +24 -0
- package/src/components/Checkbox/index.tsx +58 -0
- package/src/components/Collapse/index.tsx +1 -1
- package/src/components/Icon/index.tsx +1 -1
- package/src/components/List/BasicListItem.tsx +98 -0
- package/src/components/List/ListItem.tsx +142 -0
- package/src/components/List/StyledBasicListItem.tsx +34 -0
- package/src/components/List/StyledListItem.tsx +82 -0
- package/src/components/List/__tests__/BasicListItem.spec.tsx +37 -0
- package/src/components/List/__tests__/ListItem.spec.tsx +110 -0
- package/src/components/List/__tests__/StyledBasicListItem.spec.tsx +24 -0
- package/src/components/List/__tests__/StyledListItem.spec.tsx +48 -0
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +103 -0
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +760 -0
- package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +105 -0
- package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +200 -0
- package/src/components/List/index.tsx +14 -0
- package/src/components/SectionHeading/index.tsx +1 -1
- package/src/components/Select/Footer.tsx +13 -0
- package/src/components/Select/MultiSelect/Option.tsx +25 -0
- package/src/components/Select/MultiSelect/OptionList.tsx +30 -63
- package/src/components/Select/MultiSelect/__tests__/Option.spec.tsx +16 -0
- package/src/components/Select/MultiSelect/__tests__/OptionList.spec.tsx +42 -0
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +70 -0
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +627 -0
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +6 -6
- package/src/components/Select/MultiSelect/index.tsx +8 -7
- package/src/components/Select/SingleSelect/Option.tsx +23 -0
- package/src/components/Select/SingleSelect/OptionList.tsx +43 -0
- package/src/components/Select/SingleSelect/__tests__/Option.spec.tsx +16 -0
- package/src/components/Select/SingleSelect/__tests__/OptionList.spec.tsx +42 -0
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +56 -0
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +571 -0
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +1430 -0
- package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +89 -0
- package/src/components/Select/SingleSelect/index.tsx +89 -0
- package/src/components/Select/{MultiSelect/StyledMultiSelect.tsx → StyledSelect.tsx} +1 -1
- package/src/components/Select/{MultiSelect/__tests__/StyledMultiSelect.spec.tsx → __tests__/StyledSelect.spec.tsx} +2 -2
- package/src/components/Select/{MultiSelect/__tests__/__snapshots__/StyledMultiSelect.spec.tsx.snap → __tests__/__snapshots__/StyledSelect.spec.tsx.snap} +0 -0
- package/src/components/Select/helpers.tsx +18 -0
- package/src/components/Select/index.tsx +4 -3
- package/src/components/Select/{MultiSelect/types.ts → types.ts} +0 -0
- package/src/components/Switch/index.tsx +1 -1
- package/src/components/Toast/StyledToast.tsx +65 -0
- package/src/components/Toast/Toast.tsx +123 -0
- package/src/components/Toast/ToastContainer.tsx +88 -0
- package/src/components/Toast/ToastContext.ts +25 -0
- package/src/components/Toast/ToastProvider.tsx +53 -0
- package/src/components/Toast/__tests__/Toast.spec.tsx +125 -0
- package/src/components/Toast/__tests__/ToastContainer.spec.tsx +107 -0
- package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +655 -0
- package/src/components/Toast/__tests__/__snapshots__/ToastContainer.spec.tsx.snap +93 -0
- package/src/components/Toast/index.tsx +11 -0
- package/src/components/Toast/types.ts +70 -0
- package/src/components/Toolbar/StyledToolbar.tsx +42 -0
- package/src/components/Toolbar/ToolbarGroup.tsx +31 -0
- package/src/components/Toolbar/ToolbarItem.tsx +57 -0
- package/src/components/Toolbar/__tests__/ToolbarGroup.spec.tsx +32 -0
- package/src/components/Toolbar/__tests__/ToolbarItem.spec.tsx +57 -0
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +391 -0
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +355 -0
- package/src/components/Toolbar/index.tsx +18 -0
- package/src/components/Typography/Text/StyledText.tsx +8 -1
- package/src/components/Typography/Text/__tests__/StyledText.spec.tsx +5 -0
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +110 -0
- package/src/components/Typography/Text/index.tsx +9 -2
- package/src/index.ts +8 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +119 -2
- package/src/theme/components/button.ts +2 -0
- package/src/theme/components/card.ts +8 -1
- package/src/theme/components/checkbox.ts +37 -0
- package/src/theme/components/list.ts +46 -0
- package/src/theme/components/toast.ts +33 -0
- package/src/theme/components/toolbar.ts +27 -0
- package/src/theme/components/typography.ts +4 -0
- package/src/theme/global/colors.ts +9 -2
- package/src/theme/global/space.ts +2 -0
- package/src/theme/index.ts +12 -0
- package/tsconfig.json +1 -2
- package/types/components/Alert/StyledAlert.d.ts +0 -0
- package/types/components/Alert/__tests__/index.spec.d.ts +0 -0
- package/types/components/Alert/index.d.ts +0 -0
- package/types/components/Avatar/index.d.ts +1 -1
- package/types/components/Button/Button.d.ts +2 -2
- package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +1 -1
- package/types/components/Button/LoadingIndicator/index.d.ts +1 -1
- package/types/components/Button/StyledButton.d.ts +2 -2
- package/{es/components/Card/StyledCard.d.ts → types/components/Card/DataCard/StyledDataCard.d.ts} +5 -6
- package/{es/components/Avatar/__tests__/StyledAvatar.spec.d.ts → types/components/Card/DataCard/__tests__/StyledDataCard.spec.d.ts} +0 -0
- package/{es/components/Avatar → types/components/Card/DataCard}/__tests__/index.spec.d.ts +0 -0
- package/types/components/Card/DataCard/index.d.ts +22 -0
- package/types/components/Card/index.d.ts +7 -3
- package/types/components/Checkbox/StyledCheckbox.d.ts +0 -0
- package/types/components/Checkbox/__tests__/StyledCheckbox.spec.d.ts +0 -0
- package/types/components/Checkbox/__tests__/index.spec.d.ts +0 -0
- package/types/components/Checkbox/index.d.ts +1 -1
- package/types/components/Collapse/index.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/List/BasicListItem.d.ts +43 -0
- package/types/components/List/ListItem.d.ts +51 -0
- package/types/components/List/StyledBasicListItem.d.ts +29 -0
- package/types/components/List/StyledListItem.d.ts +51 -0
- package/{es/components/Badge/__tests__/Badge.spec.d.ts → types/components/List/__tests__/BasicListItem.spec.d.ts} +0 -0
- package/{es/components/Badge/__tests__/Status.spec.d.ts → types/components/List/__tests__/ListItem.spec.d.ts} +0 -0
- package/{es/components/BottomNavigation/__tests__/index.spec.d.ts → types/components/List/__tests__/StyledBasicListItem.spec.d.ts} +0 -0
- package/{es/components/Button/__tests__/index.spec.d.ts → types/components/List/__tests__/StyledListItem.spec.d.ts} +0 -0
- package/types/components/List/index.d.ts +8 -0
- package/types/components/Radio/types.d.ts +0 -0
- package/types/components/SectionHeading/__tests__/StyledHeading.spec.d.ts +0 -0
- package/types/components/SectionHeading/index.d.ts +1 -1
- package/types/components/Select/Footer.d.ts +5 -0
- package/types/components/Select/MultiSelect/Footer.d.ts +0 -0
- package/types/components/Select/MultiSelect/Option.d.ts +6 -0
- package/types/components/Select/MultiSelect/OptionList.d.ts +7 -1
- package/types/components/Select/MultiSelect/StyledMultiSelect.d.ts +0 -0
- package/{es/components/Card/__tests__/StyledCard.spec.d.ts → types/components/Select/MultiSelect/__tests__/Option.spec.d.ts} +0 -0
- package/{es/components/Card/__tests__/index.spec.d.ts → types/components/Select/MultiSelect/__tests__/OptionList.spec.d.ts} +0 -0
- package/types/components/Select/MultiSelect/__tests__/StyledMultiSelect.spec.d.ts +0 -0
- package/types/components/Select/MultiSelect/__tests__/index.spec.d.ts +0 -0
- package/types/components/Select/MultiSelect/index.d.ts +4 -4
- package/types/components/Select/MultiSelect/types.d.ts +0 -0
- package/types/components/Select/SingleSelect/Option.d.ts +6 -0
- package/types/components/Select/SingleSelect/OptionList.d.ts +9 -0
- package/{es/components/Collapse/__tests__/StyledCollapse.spec.d.ts → types/components/Select/SingleSelect/__tests__/Option.spec.d.ts} +0 -0
- package/{es/components/Collapse/__tests__/index.spec.d.ts → types/components/Select/SingleSelect/__tests__/OptionList.spec.d.ts} +0 -0
- package/{es/components/Drawer → types/components/Select/SingleSelect}/__tests__/index.spec.d.ts +0 -0
- package/types/components/Select/SingleSelect/index.d.ts +35 -0
- package/types/components/Select/StyledSelect.d.ts +26 -0
- package/{es/components/Divider/__tests__/StyledDivider.spec.d.ts → types/components/Select/__tests__/StyledSelect.spec.d.ts} +0 -0
- package/types/components/Select/helpers.d.ts +2 -0
- package/types/components/Select/index.d.ts +3 -3
- package/types/components/Select/types.d.ts +5 -0
- package/types/components/Switch/StyledSwitch.d.ts +0 -0
- package/types/components/Switch/__tests__/StyledHeading.spec.d.ts +0 -0
- package/types/components/Switch/__tests__/index.spec.d.ts +0 -0
- package/types/components/Switch/index.d.ts +1 -1
- package/types/components/Toast/StyledToast.d.ts +45 -0
- package/types/components/Toast/Toast.d.ts +3 -0
- package/types/components/Toast/ToastContainer.d.ts +5 -0
- package/types/components/Toast/ToastContext.d.ts +11 -0
- package/types/components/Toast/ToastProvider.d.ts +10 -0
- package/{es/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts → types/components/Toast/__tests__/Toast.spec.d.ts} +0 -0
- package/{es/components/FAB/__tests__/StyledFAB.spec.d.ts → types/components/Toast/__tests__/ToastContainer.spec.d.ts} +0 -0
- package/types/components/Toast/index.d.ts +8 -0
- package/types/components/Toast/types.d.ts +67 -0
- package/types/components/Toolbar/StyledToolbar.d.ts +22 -0
- package/types/components/Toolbar/ToolbarGroup.d.ts +13 -0
- package/types/components/Toolbar/ToolbarItem.d.ts +25 -0
- package/{es/components/FAB/__tests__/index.spec.d.ts → types/components/Toolbar/__tests__/ToolbarGroup.spec.d.ts} +0 -0
- package/{es/components/Icon/__tests__/index.spec.d.ts → types/components/Toolbar/__tests__/ToolbarItem.spec.d.ts} +0 -0
- package/types/components/Toolbar/index.d.ts +11 -0
- package/types/components/Typography/Text/StyledText.d.ts +1 -1
- package/types/components/Typography/Text/index.d.ts +2 -2
- package/types/index.d.ts +5 -1
- package/types/theme/components/alert.d.ts +0 -0
- package/types/theme/components/button.d.ts +2 -0
- package/types/theme/components/card.d.ts +7 -0
- package/types/theme/components/checkbox.d.ts +0 -0
- package/types/theme/components/list.d.ts +40 -0
- package/types/theme/components/sectionHeading.d.ts +0 -0
- package/types/theme/components/select.d.ts +0 -0
- package/types/theme/components/switch.d.ts +0 -0
- package/types/theme/components/toast.d.ts +24 -0
- package/types/theme/components/toolbar.d.ts +21 -0
- package/types/theme/components/typography.d.ts +4 -0
- package/types/theme/global/colors.d.ts +5 -0
- package/types/theme/global/index.d.ts +5 -0
- package/types/theme/global/space.d.ts +1 -0
- package/types/theme/index.d.ts +8 -0
- package/.turbo/turbo-build:types.log +0 -2
- package/.turbo/turbo-build:watch.log +0 -1
- package/.turbo/turbo-lint.log +0 -2
- package/.turbo/turbo-type-check.log +0 -2
- package/es/components/Avatar/StyledAvatar.d.ts +0 -46
- package/es/components/Avatar/index.d.ts +0 -25
- package/es/components/Badge/Status.d.ts +0 -24
- package/es/components/Badge/StyledBadge.d.ts +0 -28
- package/es/components/Badge/index.d.ts +0 -32
- package/es/components/BottomNavigation/StyledBottomNavigation.d.ts +0 -52
- package/es/components/BottomNavigation/index.d.ts +0 -45
- package/es/components/Button/IconButton.d.ts +0 -34
- package/es/components/Button/index.d.ts +0 -4
- package/es/components/Card/index.d.ts +0 -22
- package/es/components/Collapse/StyledCollapse.d.ts +0 -15
- package/es/components/Collapse/index.d.ts +0 -23
- package/es/components/Divider/StyledDivider.d.ts +0 -13
- package/es/components/Divider/index.d.ts +0 -21
- package/es/components/Drawer/StyledDrawer.d.ts +0 -25
- package/es/components/Drawer/index.d.ts +0 -25
- package/es/components/FAB/ActionGroup/ActionItem.d.ts +0 -12
- package/es/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -30
- package/es/components/FAB/ActionGroup/StyledActionItem.d.ts +0 -13
- package/es/components/FAB/ActionGroup/__tests__/index.spec.d.ts +0 -1
- package/es/components/FAB/ActionGroup/index.d.ts +0 -34
- package/es/components/FAB/AnimatedFABIcon.d.ts +0 -6
- package/es/components/FAB/FAB.d.ts +0 -34
- package/es/components/FAB/StyledFAB.d.ts +0 -20
- package/es/components/FAB/index.d.ts +0 -4
- package/es/components/Icon/HeroIcon/index.d.ts +0 -13
- package/es/components/Icon/IconList.d.ts +0 -2
- package/es/components/Icon/index.d.ts +0 -27
- package/es/components/Icon/utils.d.ts +0 -2
- package/es/components/Progress/ProgressBar.d.ts +0 -18
- package/es/components/Progress/ProgressCircle.d.ts +0 -18
- package/es/components/Progress/StyledProgressBar.d.ts +0 -18
- package/es/components/Progress/StyledProgressCircle.d.ts +0 -38
- package/es/components/Progress/index.d.ts +0 -5
- package/es/components/Progress/types.d.ts +0 -1
- package/es/components/Tabs/ActiveTabIndicator.d.ts +0 -8
- package/es/components/Tabs/ScrollableTabs.d.ts +0 -3
- package/es/components/Tabs/StyledScrollableTabs.d.ts +0 -61
- package/es/components/Tabs/StyledTabs.d.ts +0 -55
- package/es/components/Tabs/__tests__/ScrollableTabs.spec.d.ts +0 -1
- package/es/components/Tabs/__tests__/index.spec.d.ts +0 -1
- package/es/components/Tabs/index.d.ts +0 -54
- package/es/components/Tabs/utils.d.ts +0 -2
- package/es/components/Tag/StyledTag.d.ts +0 -20
- package/es/components/Tag/__tests__/Tag.spec.d.ts +0 -1
- package/es/components/Tag/index.d.ts +0 -21
- package/es/components/Typography/Text/StyledText.d.ts +0 -13
- package/es/components/Typography/Text/__tests__/StyledText.spec.d.ts +0 -1
- package/es/components/Typography/Text/__tests__/index.spec.d.ts +0 -1
- package/es/components/Typography/Text/index.d.ts +0 -30
- package/es/components/Typography/index.d.ts +0 -6
- package/es/index.d.ts +0 -19
- package/es/theme/__tests__/index.spec.d.ts +0 -1
- package/es/theme/components/avatar.d.ts +0 -32
- package/es/theme/components/badge.d.ts +0 -29
- package/es/theme/components/bottomNavigation.d.ts +0 -23
- package/es/theme/components/card.d.ts +0 -10
- package/es/theme/components/divider.d.ts +0 -17
- package/es/theme/components/drawer.d.ts +0 -21
- package/es/theme/components/fab.d.ts +0 -51
- package/es/theme/components/icon.d.ts +0 -19
- package/es/theme/components/progress.d.ts +0 -21
- package/es/theme/components/tabs.d.ts +0 -27
- package/es/theme/components/tag.d.ts +0 -30
- package/es/theme/components/typography.d.ts +0 -26
- package/es/theme/global/borders.d.ts +0 -11
- package/es/theme/global/colors.d.ts +0 -29
- package/es/theme/global/index.d.ts +0 -39
- package/es/theme/global/scale.d.ts +0 -9
- package/es/theme/global/space.d.ts +0 -13
- package/es/theme/global/typography.d.ts +0 -21
- package/es/theme/index.d.ts +0 -33
- package/es/types.d.ts +0 -5
- package/es/utils/__tests__/scale.spec.d.ts +0 -1
- package/es/utils/helpers.d.ts +0 -2
- package/es/utils/hooks.d.ts +0 -1
- package/es/utils/scale.d.ts +0 -3
- package/lib/components/Avatar/StyledAvatar.d.ts +0 -46
- package/lib/components/Avatar/__tests__/StyledAvatar.spec.d.ts +0 -1
- package/lib/components/Avatar/__tests__/index.spec.d.ts +0 -1
- package/lib/components/Avatar/index.d.ts +0 -25
- package/lib/components/Badge/Status.d.ts +0 -24
- package/lib/components/Badge/StyledBadge.d.ts +0 -28
- package/lib/components/Badge/__tests__/Badge.spec.d.ts +0 -1
- package/lib/components/Badge/__tests__/Status.spec.d.ts +0 -1
- package/lib/components/Badge/index.d.ts +0 -32
- package/lib/components/BottomNavigation/StyledBottomNavigation.d.ts +0 -52
- package/lib/components/BottomNavigation/__tests__/index.spec.d.ts +0 -1
- package/lib/components/BottomNavigation/index.d.ts +0 -45
- package/lib/components/Button/IconButton.d.ts +0 -34
- package/lib/components/Button/__tests__/index.spec.d.ts +0 -1
- package/lib/components/Button/index.d.ts +0 -4
- package/lib/components/Card/StyledCard.d.ts +0 -17
- package/lib/components/Card/__tests__/StyledCard.spec.d.ts +0 -1
- package/lib/components/Card/__tests__/index.spec.d.ts +0 -1
- package/lib/components/Card/index.d.ts +0 -22
- package/lib/components/Collapse/StyledCollapse.d.ts +0 -15
- package/lib/components/Collapse/__tests__/StyledCollapse.spec.d.ts +0 -1
- package/lib/components/Collapse/__tests__/index.spec.d.ts +0 -1
- package/lib/components/Collapse/index.d.ts +0 -23
- package/lib/components/Divider/StyledDivider.d.ts +0 -13
- package/lib/components/Divider/__tests__/StyledDivider.spec.d.ts +0 -1
- package/lib/components/Divider/index.d.ts +0 -21
- package/lib/components/Drawer/StyledDrawer.d.ts +0 -25
- package/lib/components/Drawer/__tests__/index.spec.d.ts +0 -1
- package/lib/components/Drawer/index.d.ts +0 -25
- package/lib/components/FAB/ActionGroup/ActionItem.d.ts +0 -12
- package/lib/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -30
- package/lib/components/FAB/ActionGroup/StyledActionItem.d.ts +0 -13
- package/lib/components/FAB/ActionGroup/__tests__/index.spec.d.ts +0 -1
- package/lib/components/FAB/ActionGroup/index.d.ts +0 -34
- package/lib/components/FAB/AnimatedFABIcon.d.ts +0 -6
- package/lib/components/FAB/FAB.d.ts +0 -34
- package/lib/components/FAB/StyledFAB.d.ts +0 -20
- package/lib/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts +0 -1
- package/lib/components/FAB/__tests__/StyledFAB.spec.d.ts +0 -1
- package/lib/components/FAB/__tests__/index.spec.d.ts +0 -1
- package/lib/components/FAB/index.d.ts +0 -4
- package/lib/components/Icon/HeroIcon/index.d.ts +0 -13
- package/lib/components/Icon/IconList.d.ts +0 -2
- package/lib/components/Icon/__tests__/index.spec.d.ts +0 -1
- package/lib/components/Icon/index.d.ts +0 -27
- package/lib/components/Icon/utils.d.ts +0 -2
- package/lib/components/Progress/ProgressBar.d.ts +0 -18
- package/lib/components/Progress/ProgressCircle.d.ts +0 -18
- package/lib/components/Progress/StyledProgressBar.d.ts +0 -18
- package/lib/components/Progress/StyledProgressCircle.d.ts +0 -38
- package/lib/components/Progress/index.d.ts +0 -5
- package/lib/components/Progress/types.d.ts +0 -1
- package/lib/components/Tabs/ActiveTabIndicator.d.ts +0 -8
- package/lib/components/Tabs/ScrollableTabs.d.ts +0 -3
- package/lib/components/Tabs/StyledScrollableTabs.d.ts +0 -61
- package/lib/components/Tabs/StyledTabs.d.ts +0 -55
- package/lib/components/Tabs/__tests__/ScrollableTabs.spec.d.ts +0 -1
- package/lib/components/Tabs/__tests__/index.spec.d.ts +0 -1
- package/lib/components/Tabs/index.d.ts +0 -54
- package/lib/components/Tabs/utils.d.ts +0 -2
- package/lib/components/Tag/StyledTag.d.ts +0 -20
- package/lib/components/Tag/__tests__/Tag.spec.d.ts +0 -1
- package/lib/components/Tag/index.d.ts +0 -21
- package/lib/components/Typography/Text/StyledText.d.ts +0 -13
- package/lib/components/Typography/Text/__tests__/StyledText.spec.d.ts +0 -1
- package/lib/components/Typography/Text/__tests__/index.spec.d.ts +0 -1
- package/lib/components/Typography/Text/index.d.ts +0 -30
- package/lib/components/Typography/index.d.ts +0 -6
- package/lib/index.d.ts +0 -19
- package/lib/theme/__tests__/index.spec.d.ts +0 -1
- package/lib/theme/components/avatar.d.ts +0 -32
- package/lib/theme/components/badge.d.ts +0 -29
- package/lib/theme/components/bottomNavigation.d.ts +0 -23
- package/lib/theme/components/card.d.ts +0 -10
- package/lib/theme/components/divider.d.ts +0 -17
- package/lib/theme/components/drawer.d.ts +0 -21
- package/lib/theme/components/fab.d.ts +0 -51
- package/lib/theme/components/icon.d.ts +0 -19
- package/lib/theme/components/progress.d.ts +0 -21
- package/lib/theme/components/tabs.d.ts +0 -27
- package/lib/theme/components/tag.d.ts +0 -30
- package/lib/theme/components/typography.d.ts +0 -26
- package/lib/theme/global/borders.d.ts +0 -11
- package/lib/theme/global/colors.d.ts +0 -29
- package/lib/theme/global/index.d.ts +0 -39
- package/lib/theme/global/scale.d.ts +0 -9
- package/lib/theme/global/space.d.ts +0 -13
- package/lib/theme/global/typography.d.ts +0 -21
- package/lib/theme/index.d.ts +0 -33
- package/lib/types.d.ts +0 -5
- package/lib/utils/__tests__/scale.spec.d.ts +0 -1
- package/lib/utils/helpers.d.ts +0 -2
- package/lib/utils/hooks.d.ts +0 -1
- package/lib/utils/scale.d.ts +0 -3
- package/playground/.detoxrc.json +0 -49
- package/playground/.prettierrc.json +0 -8
- package/playground/app.json +0 -9
- package/playground/babel.config.js +0 -63
- package/playground/e2e/config.json +0 -9
- package/playground/e2e/environment.js +0 -23
- package/playground/e2e/firstTest.e2e.js +0 -16
- package/playground/expoEntry.js +0 -5
- package/playground/fonts/be-vietnam-pro-light.ttf +0 -0
- package/playground/fonts/be-vietnam-pro-regular.ttf +0 -0
- package/playground/fonts/be-vietnam-pro-semibold.ttf +0 -0
- package/playground/fonts/hero-icons.ttf +0 -0
- package/playground/index.js +0 -7
- package/playground/ios/MobileHeroDesignPlayground/AppDelegate.h +0 -9
- package/playground/ios/MobileHeroDesignPlayground/AppDelegate.m +0 -75
- package/playground/ios/MobileHeroDesignPlayground/Images.xcassets/AppIcon.appiconset/Contents.json +0 -38
- package/playground/ios/MobileHeroDesignPlayground/Images.xcassets/Contents.json +0 -6
- package/playground/ios/MobileHeroDesignPlayground/Images.xcassets/SplashScreenBackground.imageset/Contents.json +0 -21
- package/playground/ios/MobileHeroDesignPlayground/Images.xcassets/SplashScreenBackground.imageset/image.png +0 -0
- package/playground/ios/MobileHeroDesignPlayground/Info.plist +0 -85
- package/playground/ios/MobileHeroDesignPlayground/MobileHeroDesignPlayground-Bridging-Header.h +0 -3
- package/playground/ios/MobileHeroDesignPlayground/MobileHeroDesignPlayground.entitlements +0 -8
- package/playground/ios/MobileHeroDesignPlayground/SplashScreen.storyboard +0 -40
- package/playground/ios/MobileHeroDesignPlayground/Supporting/Expo.plist +0 -16
- package/playground/ios/MobileHeroDesignPlayground/main.m +0 -10
- package/playground/ios/MobileHeroDesignPlayground/noop-file.swift +0 -4
- package/playground/ios/MobileHeroDesignPlayground.xcodeproj/project.pbxproj +0 -515
- package/playground/ios/MobileHeroDesignPlayground.xcodeproj/xcshareddata/xcschemes/MobileHeroDesignPlayground.xcscheme +0 -88
- package/playground/ios/MobileHeroDesignPlayground.xcworkspace/contents.xcworkspacedata +0 -10
- package/playground/ios/MobileHeroDesignPlayground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/playground/ios/Podfile +0 -49
- package/playground/ios/Podfile.lock +0 -478
- package/playground/ios/Podfile.properties.json +0 -3
- package/playground/metro.config.js +0 -24
- package/playground/package.json +0 -63
- package/playground/src/Alert.tsx +0 -80
- package/playground/src/App.tsx +0 -202
- package/playground/src/Avatar.tsx +0 -102
- package/playground/src/Badge.tsx +0 -187
- package/playground/src/BottomNavigation.tsx +0 -72
- package/playground/src/BottomSheet.tsx +0 -43
- package/playground/src/Button.tsx +0 -170
- package/playground/src/Card.tsx +0 -342
- package/playground/src/Collapse.tsx +0 -99
- package/playground/src/ContentNavigator.tsx +0 -58
- package/playground/src/Divider.tsx +0 -13
- package/playground/src/Drawer.tsx +0 -32
- package/playground/src/FAB.tsx +0 -66
- package/playground/src/Icon.tsx +0 -144
- package/playground/src/IconButton.tsx +0 -78
- package/playground/src/MultipleThemes.tsx +0 -34
- package/playground/src/Progress.tsx +0 -95
- package/playground/src/Radio.tsx +0 -25
- package/playground/src/SectionHeading.tsx +0 -68
- package/playground/src/Select.tsx +0 -32
- package/playground/src/Spinner.tsx +0 -19
- package/playground/src/Switch.tsx +0 -80
- package/playground/src/Tabs.tsx +0 -136
- package/playground/src/Tag.tsx +0 -45
- package/playground/src/TextInput.tsx +0 -14
- package/playground/src/Typography.tsx +0 -23
- package/playground/tsconfig.json +0 -21
- package/src/components/Select/MultiSelect/Footer.tsx +0 -15
- package/types/components/SectionHeading/__tests__/StyledHeading.d.ts +0 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { fireEvent } from '@testing-library/react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import renderWithTheme from '../../../../testHelpers/renderWithTheme';
|
|
4
|
+
import SingleSelect from '..';
|
|
5
|
+
|
|
6
|
+
const options = [
|
|
7
|
+
{ text: 'Monday', value: 'mon' },
|
|
8
|
+
{ text: 'Tuesday', value: 'tue' },
|
|
9
|
+
{ text: 'Wednesday', value: 'wed' },
|
|
10
|
+
{ text: 'Thursday', value: 'thu' },
|
|
11
|
+
{ text: 'Friday', value: 'fri' },
|
|
12
|
+
{ text: 'Saturday', value: 'sat' },
|
|
13
|
+
{ text: 'Sunday', value: 'sun' },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
describe('rendering', () => {
|
|
17
|
+
it('renders correctly when bottom sheet is NOT visible', () => {
|
|
18
|
+
const { queryAllByText, toJSON, getByTestId } = renderWithTheme(
|
|
19
|
+
<SingleSelect
|
|
20
|
+
label="Allow notifications"
|
|
21
|
+
options={options}
|
|
22
|
+
value="mon"
|
|
23
|
+
onConfirm={jest.fn()}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
expect(toJSON()).toMatchSnapshot();
|
|
28
|
+
expect(queryAllByText('Allow notifications')).toHaveLength(2);
|
|
29
|
+
expect(getByTestId('text-input').props.value).toBe('Monday');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('renders correctly when bottom sheet is visible', () => {
|
|
33
|
+
const { queryAllByText, getByText, toJSON, getByTestId } = renderWithTheme(
|
|
34
|
+
<SingleSelect
|
|
35
|
+
label="Allow notifications"
|
|
36
|
+
options={options}
|
|
37
|
+
value="mon"
|
|
38
|
+
onConfirm={jest.fn()}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
fireEvent.press(getByTestId('text-input'));
|
|
42
|
+
|
|
43
|
+
expect(toJSON()).toMatchSnapshot();
|
|
44
|
+
expect(queryAllByText('Allow notifications')).toHaveLength(2);
|
|
45
|
+
expect(getByText('Monday')).toBeDefined();
|
|
46
|
+
expect(getByText('Tuesday')).toBeDefined();
|
|
47
|
+
expect(getByText('Wednesday')).toBeDefined();
|
|
48
|
+
expect(getByText('Thursday')).toBeDefined();
|
|
49
|
+
expect(getByText('Friday')).toBeDefined();
|
|
50
|
+
expect(getByText('Saturday')).toBeDefined();
|
|
51
|
+
expect(getByText('Sunday')).toBeDefined();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('behavior', () => {
|
|
56
|
+
it('calls onConfirm when pressing footer of bottom sheet', () => {
|
|
57
|
+
const onPress = jest.fn();
|
|
58
|
+
const { getByText, getByTestId } = renderWithTheme(
|
|
59
|
+
<SingleSelect
|
|
60
|
+
label="Allow notifications"
|
|
61
|
+
options={options}
|
|
62
|
+
value="mon"
|
|
63
|
+
onConfirm={onPress}
|
|
64
|
+
testID="single-select"
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
fireEvent.press(getByTestId('single-select'));
|
|
68
|
+
fireEvent.press(getByText('Monday'));
|
|
69
|
+
|
|
70
|
+
expect(onPress).toBeCalledTimes(1);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('does NOT call onConfirm when pressing closing button of bottom sheet', () => {
|
|
74
|
+
const onPress = jest.fn();
|
|
75
|
+
const { getByTestId } = renderWithTheme(
|
|
76
|
+
<SingleSelect
|
|
77
|
+
label="Allow notifications"
|
|
78
|
+
options={options}
|
|
79
|
+
value="mon"
|
|
80
|
+
onConfirm={onPress}
|
|
81
|
+
testID="single-select"
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
fireEvent.press(getByTestId('single-select'));
|
|
85
|
+
fireEvent.press(getByTestId('bottom-sheet-close-icon'));
|
|
86
|
+
|
|
87
|
+
expect(onPress).toBeCalledTimes(0);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useTheme } from '@emotion/react';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { StyleProp, ViewStyle, TouchableOpacity } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { OptionType } from '../types';
|
|
6
|
+
import BottomSheet from '../../BottomSheet';
|
|
7
|
+
import OptionList from './OptionList';
|
|
8
|
+
import TextInput from '../../TextInput';
|
|
9
|
+
|
|
10
|
+
export interface SingleSelectProps<T> {
|
|
11
|
+
/**
|
|
12
|
+
* An array of options to be selected.
|
|
13
|
+
*/
|
|
14
|
+
options: OptionType<T>[];
|
|
15
|
+
/**
|
|
16
|
+
* Current selected value.
|
|
17
|
+
*/
|
|
18
|
+
value: T | null;
|
|
19
|
+
/**
|
|
20
|
+
* event handler for confirm button
|
|
21
|
+
*/
|
|
22
|
+
onConfirm: (value: T | null) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Field label.
|
|
25
|
+
*/
|
|
26
|
+
label: string;
|
|
27
|
+
/**
|
|
28
|
+
* Used to extract a unique key for a given option at the specified index. Key is used for caching and as the react key to track item re-ordering.
|
|
29
|
+
* The default extractor checks option.key, and then falls back to using the index, like React does.
|
|
30
|
+
*/
|
|
31
|
+
keyExtractor?: (option: OptionType<T>, index?: number) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Additional style.
|
|
34
|
+
*/
|
|
35
|
+
style?: StyleProp<ViewStyle>;
|
|
36
|
+
/**
|
|
37
|
+
* Testing id of the component.
|
|
38
|
+
*/
|
|
39
|
+
testID?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const SingleSelect = <T,>({
|
|
43
|
+
options,
|
|
44
|
+
value,
|
|
45
|
+
testID,
|
|
46
|
+
style,
|
|
47
|
+
label,
|
|
48
|
+
onConfirm,
|
|
49
|
+
}: SingleSelectProps<T>) => {
|
|
50
|
+
const theme = useTheme();
|
|
51
|
+
const [open, setOpen] = useState(false);
|
|
52
|
+
const [selectingValue, setSelectingValue] = useState<T | null>(value);
|
|
53
|
+
const displayedValue = options.find(opt => value === opt.value)?.text;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<TouchableOpacity onPress={() => setOpen(true)}>
|
|
57
|
+
<TextInput
|
|
58
|
+
label={label}
|
|
59
|
+
value={displayedValue}
|
|
60
|
+
onPressIn={() => setOpen(true)}
|
|
61
|
+
editable={false}
|
|
62
|
+
// when input is not editable on Android, the text color is gray
|
|
63
|
+
// hence, adding this to make the text color the same as iOS
|
|
64
|
+
textStyle={{ color: theme.colors.text }}
|
|
65
|
+
suffix="arrow-down"
|
|
66
|
+
multiline
|
|
67
|
+
style={style}
|
|
68
|
+
testID={testID}
|
|
69
|
+
/>
|
|
70
|
+
<BottomSheet
|
|
71
|
+
open={open}
|
|
72
|
+
onRequestClose={() => setOpen(false)}
|
|
73
|
+
onDismiss={() => setSelectingValue(value)}
|
|
74
|
+
header={label}
|
|
75
|
+
>
|
|
76
|
+
<OptionList
|
|
77
|
+
options={options}
|
|
78
|
+
value={selectingValue}
|
|
79
|
+
onPress={selectedValue => {
|
|
80
|
+
setOpen(false);
|
|
81
|
+
onConfirm(selectedValue);
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
</BottomSheet>
|
|
85
|
+
</TouchableOpacity>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default SingleSelect;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { View, TouchableOpacity } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
|
-
import Typography from '
|
|
3
|
+
import Typography from '../Typography';
|
|
4
4
|
|
|
5
5
|
const OptionWrapper = styled(TouchableOpacity)<{ themeSelected: boolean }>(
|
|
6
6
|
({ theme, themeSelected }) => ({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import renderWithTheme from '
|
|
2
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
3
|
import {
|
|
4
4
|
OptionWrapper,
|
|
5
5
|
OptionListWrapper,
|
|
6
6
|
Spacer,
|
|
7
7
|
FooterText,
|
|
8
|
-
} from '../
|
|
8
|
+
} from '../StyledSelect';
|
|
9
9
|
|
|
10
10
|
describe('OptionWrapper', () => {
|
|
11
11
|
it.each`
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OptionType } from './types';
|
|
2
|
+
|
|
3
|
+
export const getKey = <T,>(
|
|
4
|
+
option: OptionType<T>,
|
|
5
|
+
index: number,
|
|
6
|
+
keyExtractor?: (opt: OptionType<T>, i?: number) => string
|
|
7
|
+
) => {
|
|
8
|
+
let key: React.Key = '';
|
|
9
|
+
if (keyExtractor !== undefined) {
|
|
10
|
+
key = keyExtractor(option, index);
|
|
11
|
+
} else if (option.key !== undefined) {
|
|
12
|
+
key = option.key;
|
|
13
|
+
} else {
|
|
14
|
+
key = index;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return key;
|
|
18
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import styled from '@emotion/native';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Animated,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
ViewProps,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
|
|
11
|
+
const ToastContainerWrapper = styled(View)<{ position: 'top' | 'bottom' }>(
|
|
12
|
+
({ theme, position }) => ({
|
|
13
|
+
...StyleSheet.absoluteFillObject,
|
|
14
|
+
paddingHorizontal: theme.__hd__.toast.space.largePadding,
|
|
15
|
+
paddingVertical: theme.__hd__.toast.space.mediumPadding,
|
|
16
|
+
flexDirection: position === 'bottom' ? 'column-reverse' : 'column',
|
|
17
|
+
elevation: 9999,
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const Container = styled(Animated.View)<{
|
|
22
|
+
themeVariant: 'default' | 'round';
|
|
23
|
+
themeIntent: 'success' | 'info' | 'warning' | 'error';
|
|
24
|
+
}>(({ theme, themeVariant, themeIntent }) => ({
|
|
25
|
+
borderRadius: themeVariant === 'round' ? theme.__hd__.toast.radii.default : 0,
|
|
26
|
+
backgroundColor: theme.__hd__.toast.colors[themeIntent],
|
|
27
|
+
minHeight: theme.__hd__.toast.sizes.height,
|
|
28
|
+
flexDirection: 'row',
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const IconContainer = styled(View)<ViewProps>(({ theme }) => ({
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
paddingLeft: theme.__hd__.toast.space.mediumPadding,
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
const TextContainer = styled(View)<ViewProps>(({ theme }) => ({
|
|
37
|
+
paddingHorizontal: theme.__hd__.toast.space.mediumPadding,
|
|
38
|
+
flex: 1,
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
const ContentContainer = styled(View)<{ showDivider: boolean }>(
|
|
42
|
+
({ theme, showDivider }) => ({
|
|
43
|
+
paddingVertical: theme.__hd__.toast.space.mediumPadding,
|
|
44
|
+
flex: 1,
|
|
45
|
+
borderRightWidth: showDivider ? theme.__hd__.toast.borderWidths.base : 0,
|
|
46
|
+
borderColor: theme.__hd__.toast.colors.divider,
|
|
47
|
+
flexDirection: 'row',
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const CTAWrapper = styled(TouchableOpacity)<
|
|
52
|
+
ComponentProps<typeof TouchableOpacity>
|
|
53
|
+
>(({ theme }) => ({
|
|
54
|
+
paddingHorizontal: theme.__hd__.alert.space.padding,
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
ToastContainerWrapper,
|
|
60
|
+
Container,
|
|
61
|
+
ContentContainer,
|
|
62
|
+
TextContainer,
|
|
63
|
+
IconContainer,
|
|
64
|
+
CTAWrapper,
|
|
65
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React, { useEffect, useLayoutEffect, useRef } from 'react';
|
|
2
|
+
import { Animated, LayoutAnimation } from 'react-native';
|
|
3
|
+
import Icon, { IconName } from '../Icon';
|
|
4
|
+
import Typography from '../Typography';
|
|
5
|
+
import {
|
|
6
|
+
Container,
|
|
7
|
+
ContentContainer,
|
|
8
|
+
IconContainer,
|
|
9
|
+
CTAWrapper,
|
|
10
|
+
TextContainer,
|
|
11
|
+
} from './StyledToast';
|
|
12
|
+
import { useToastConfig } from './ToastContext';
|
|
13
|
+
import { ToastProps } from './types';
|
|
14
|
+
|
|
15
|
+
const getIntentIcon = (
|
|
16
|
+
intent: 'success' | 'info' | 'warning' | 'error'
|
|
17
|
+
): IconName => {
|
|
18
|
+
switch (intent) {
|
|
19
|
+
case 'success':
|
|
20
|
+
return 'circle-ok';
|
|
21
|
+
case 'warning':
|
|
22
|
+
return 'warning';
|
|
23
|
+
case 'info':
|
|
24
|
+
return 'circle-info';
|
|
25
|
+
case 'error':
|
|
26
|
+
return 'circle-warning';
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const Toast = ({
|
|
31
|
+
content,
|
|
32
|
+
icon,
|
|
33
|
+
variant = 'default',
|
|
34
|
+
intent = 'info',
|
|
35
|
+
style,
|
|
36
|
+
duration = 2000,
|
|
37
|
+
autoDismiss = true,
|
|
38
|
+
onAction,
|
|
39
|
+
actionLabel,
|
|
40
|
+
onDismiss,
|
|
41
|
+
}: ToastProps): JSX.Element => {
|
|
42
|
+
const animatedValue = useRef(new Animated.Value(0)).current;
|
|
43
|
+
const toastConfig = useToastConfig();
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (autoDismiss && duration >= 0) {
|
|
47
|
+
const id = setTimeout(() => onDismiss?.(), duration);
|
|
48
|
+
|
|
49
|
+
return () => clearTimeout(id);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Consistent return
|
|
53
|
+
return () => {};
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const animation = Animated.timing(animatedValue, {
|
|
58
|
+
toValue: 1,
|
|
59
|
+
useNativeDriver: true,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
animation.start();
|
|
63
|
+
|
|
64
|
+
return () => animation.stop();
|
|
65
|
+
}, []);
|
|
66
|
+
|
|
67
|
+
useLayoutEffect(() => {
|
|
68
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const interpolateY = animatedValue.interpolate({
|
|
72
|
+
inputRange: [0, 1],
|
|
73
|
+
outputRange: [toastConfig.position === 'top' ? -20 : 20, 0],
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Container
|
|
78
|
+
themeVariant={variant}
|
|
79
|
+
themeIntent={intent}
|
|
80
|
+
style={[
|
|
81
|
+
style,
|
|
82
|
+
{
|
|
83
|
+
opacity: animatedValue,
|
|
84
|
+
transform: [{ translateY: interpolateY }],
|
|
85
|
+
},
|
|
86
|
+
]}
|
|
87
|
+
>
|
|
88
|
+
<ContentContainer showDivider={!!actionLabel}>
|
|
89
|
+
{icon !== null ? (
|
|
90
|
+
<IconContainer testID="toast-left-icon">
|
|
91
|
+
<Icon icon={icon || getIntentIcon(intent)} size="small" />
|
|
92
|
+
</IconContainer>
|
|
93
|
+
) : null}
|
|
94
|
+
<TextContainer>
|
|
95
|
+
{typeof content === 'string' ? (
|
|
96
|
+
<Typography.Text>{content}</Typography.Text>
|
|
97
|
+
) : (
|
|
98
|
+
content
|
|
99
|
+
)}
|
|
100
|
+
</TextContainer>
|
|
101
|
+
</ContentContainer>
|
|
102
|
+
{actionLabel ? (
|
|
103
|
+
<CTAWrapper
|
|
104
|
+
testID="toast-action-button"
|
|
105
|
+
onPress={() => {
|
|
106
|
+
onAction?.();
|
|
107
|
+
onDismiss?.();
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
{typeof actionLabel === 'string' ? (
|
|
111
|
+
<Typography.Text fontWeight="semi-bold">
|
|
112
|
+
{actionLabel}
|
|
113
|
+
</Typography.Text>
|
|
114
|
+
) : (
|
|
115
|
+
actionLabel
|
|
116
|
+
)}
|
|
117
|
+
</CTAWrapper>
|
|
118
|
+
) : null}
|
|
119
|
+
</Container>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export default Toast;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useImperativeHandle, useState } from 'react';
|
|
2
|
+
import { useTheme } from '@emotion/react';
|
|
3
|
+
|
|
4
|
+
import Toast from './Toast';
|
|
5
|
+
import { ToastContainerWrapper } from './StyledToast';
|
|
6
|
+
import { ToastContainerProps, ToastItemProps } from './types';
|
|
7
|
+
import { ToastControllerContextType } from './ToastContext';
|
|
8
|
+
|
|
9
|
+
const generateID = () =>
|
|
10
|
+
(performance.now().toString(36) + Math.random().toString(36)).replace(
|
|
11
|
+
/\./g,
|
|
12
|
+
''
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const SingleToastDisplay = ({
|
|
16
|
+
toastList,
|
|
17
|
+
setToastList,
|
|
18
|
+
}: {
|
|
19
|
+
toastList: ToastItemProps[];
|
|
20
|
+
setToastList: React.Dispatch<React.SetStateAction<ToastItemProps[]>>;
|
|
21
|
+
}) => {
|
|
22
|
+
const theme = useTheme();
|
|
23
|
+
const toast = toastList[toastList.length - 1];
|
|
24
|
+
|
|
25
|
+
return toast ? (
|
|
26
|
+
<Toast
|
|
27
|
+
{...toast.props}
|
|
28
|
+
key={toast.id}
|
|
29
|
+
style={{ marginBottom: theme.space.small }}
|
|
30
|
+
onDismiss={() => {
|
|
31
|
+
setToastList(state => state.filter(item => item.id !== toast.id));
|
|
32
|
+
toast.props.onDismiss?.();
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
) : null;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const ToastContainer = React.forwardRef<
|
|
39
|
+
ToastControllerContextType,
|
|
40
|
+
ToastContainerProps
|
|
41
|
+
>(({ displayType = 'single', position = 'top', style }, ref) => {
|
|
42
|
+
const theme = useTheme();
|
|
43
|
+
const [toastList, setToastList] = useState<ToastItemProps[]>([]);
|
|
44
|
+
|
|
45
|
+
useImperativeHandle(ref, () => ({
|
|
46
|
+
show: props => {
|
|
47
|
+
const item = {
|
|
48
|
+
id: generateID(),
|
|
49
|
+
props,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
setToastList(state => [item, ...state]);
|
|
53
|
+
return item.id;
|
|
54
|
+
},
|
|
55
|
+
hide: id => {
|
|
56
|
+
setToastList(state => state.filter(item => item.id !== id));
|
|
57
|
+
},
|
|
58
|
+
clearAll: () => {
|
|
59
|
+
setToastList([]);
|
|
60
|
+
},
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<ToastContainerWrapper
|
|
65
|
+
pointerEvents="box-none"
|
|
66
|
+
position={position}
|
|
67
|
+
style={style}
|
|
68
|
+
>
|
|
69
|
+
{displayType === 'single' ? (
|
|
70
|
+
<SingleToastDisplay toastList={toastList} setToastList={setToastList} />
|
|
71
|
+
) : (
|
|
72
|
+
toastList.map(({ id, props }: ToastItemProps) => (
|
|
73
|
+
<Toast
|
|
74
|
+
{...props}
|
|
75
|
+
key={id}
|
|
76
|
+
style={{ marginBottom: theme.space.small }}
|
|
77
|
+
onDismiss={() => {
|
|
78
|
+
setToastList(state => state.filter(item => item.id !== id));
|
|
79
|
+
props.onDismiss?.();
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
))
|
|
83
|
+
)}
|
|
84
|
+
</ToastContainerWrapper>
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export default ToastContainer;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import { ToastContainerProps, ToastProps } from './types';
|
|
3
|
+
|
|
4
|
+
export type ToastControllerContextType = {
|
|
5
|
+
show: (props: Omit<ToastProps, 'position'>) => string;
|
|
6
|
+
hide: (id: string) => void;
|
|
7
|
+
clearAll: () => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const ToastContext = createContext<ToastControllerContextType>(
|
|
11
|
+
{} as ToastControllerContextType
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export type ToastConfigContextType = Pick<
|
|
15
|
+
ToastContainerProps,
|
|
16
|
+
'position' | 'displayType'
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
export const ToastConfigContext = createContext<ToastConfigContextType>(
|
|
20
|
+
{} as ToastConfigContextType
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const useToastConfig = () => useContext(ToastConfigContext);
|
|
24
|
+
|
|
25
|
+
export const useToast = () => useContext(ToastContext);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { ReactNode, useEffect, useRef, useState, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import ToastContainer from './ToastContainer';
|
|
4
|
+
import {
|
|
5
|
+
ToastConfigContext,
|
|
6
|
+
ToastContext,
|
|
7
|
+
ToastControllerContextType,
|
|
8
|
+
} from './ToastContext';
|
|
9
|
+
import { ToastContainerProps } from './types';
|
|
10
|
+
|
|
11
|
+
type ToastProviderProps = {
|
|
12
|
+
/**
|
|
13
|
+
* Content to be wrapped.
|
|
14
|
+
*/
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
} & ToastContainerProps;
|
|
17
|
+
|
|
18
|
+
const ToastProvider = ({
|
|
19
|
+
children,
|
|
20
|
+
displayType = 'single',
|
|
21
|
+
position = 'top',
|
|
22
|
+
}: ToastProviderProps) => {
|
|
23
|
+
const toastRef = useRef<ToastControllerContextType>(null);
|
|
24
|
+
const [refState, setRefState] = useState<ToastControllerContextType>(
|
|
25
|
+
{} as ToastControllerContextType
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (toastRef.current) {
|
|
30
|
+
setRefState(toastRef.current);
|
|
31
|
+
}
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
34
|
+
const config = useMemo(() => ({ displayType, position }), [
|
|
35
|
+
displayType,
|
|
36
|
+
position,
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<ToastContext.Provider value={refState}>
|
|
41
|
+
{children}
|
|
42
|
+
<ToastConfigContext.Provider value={config}>
|
|
43
|
+
<ToastContainer
|
|
44
|
+
ref={toastRef}
|
|
45
|
+
displayType={displayType}
|
|
46
|
+
position={position}
|
|
47
|
+
/>
|
|
48
|
+
</ToastConfigContext.Provider>
|
|
49
|
+
</ToastContext.Provider>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default ToastProvider;
|