@utilitywarehouse/hearth-react-native 0.1.0 → 0.3.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/.storybook/preview.tsx +5 -0
- package/.storybook/prism-setup.ts +104 -0
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +42 -0
- package/build/components/Accordion/Accordion.d.ts +1 -1
- package/build/components/Accordion/Accordion.js +7 -7
- package/build/components/Accordion/Accordion.props.d.ts +2 -2
- package/build/components/Accordion/AccordionIcon.js +2 -2
- package/build/components/Accordion/AccordionItemRoot.js +2 -2
- package/build/components/Accordion/AccordionTrigger.js +4 -4
- package/build/components/Accordion/index.d.ts +1 -2
- package/build/components/Accordion/index.js +1 -2
- package/build/components/Alert/Alert.js +21 -21
- package/build/components/Alert/Alert.props.d.ts +3 -3
- package/build/components/Alert/AlertCloseButton.js +2 -2
- package/build/components/Alert/AlertIcon.js +5 -5
- package/build/components/Badge/Badge.context.d.ts +4 -0
- package/build/components/Badge/Badge.js +179 -33
- package/build/components/Badge/Badge.props.d.ts +3 -2
- package/build/components/Badge/BadgeIcon.js +29 -19
- package/build/components/Badge/BadgeText.js +30 -19
- package/build/components/BodyText/BodyText.js +2 -2
- package/build/components/BottomSheet/BottomSheet.d.ts +1 -1
- package/build/components/BottomSheet/BottomSheet.js +3 -3
- package/build/components/BottomSheet/BottomSheetHandle.js +1 -1
- package/build/components/BottomSheet/BottomSheetModal.js +1 -1
- package/build/components/BottomSheet/BottomSheetScrollView.js +3 -1
- package/build/components/BottomSheet/BottomSheetView.js +1 -1
- package/build/components/Button/Button.d.ts +2 -2
- package/build/components/Button/Button.props.d.ts +7 -7
- package/build/components/Button/ButtonGroupRoot.d.ts +3 -2
- package/build/components/Button/ButtonGroupRoot.js +9 -0
- package/build/components/Button/ButtonIcon.js +29 -29
- package/build/components/Button/ButtonRoot.js +79 -88
- package/build/components/Button/ButtonSpinner.js +28 -31
- package/build/components/Button/ButtonText.js +40 -26
- package/build/components/Card/Card.props.d.ts +3 -3
- package/build/components/Card/CardRoot.js +56 -56
- package/build/components/Checkbox/CheckboxIcon.js +3 -3
- package/build/components/Checkbox/CheckboxIndicator.js +3 -3
- package/build/components/Checkbox/CheckboxTileRoot.js +3 -3
- package/build/components/CurrencyInput/CurrencyInput.d.ts +6 -0
- package/build/components/CurrencyInput/CurrencyInput.js +47 -0
- package/build/components/CurrencyInput/CurrencyInput.props.d.ts +14 -0
- package/build/components/CurrencyInput/index.d.ts +1 -0
- package/build/components/CurrencyInput/index.js +1 -0
- package/build/components/DescriptionList/DescriptionList.context.d.ts +6 -0
- package/build/components/DescriptionList/DescriptionList.context.js +9 -0
- package/build/components/DescriptionList/DescriptionList.d.ts +6 -0
- package/build/components/DescriptionList/DescriptionList.js +25 -0
- package/build/components/DescriptionList/DescriptionList.props.d.ts +18 -0
- package/build/components/DescriptionList/DescriptionListItem.d.ts +6 -0
- package/build/components/DescriptionList/DescriptionListItem.js +49 -0
- package/build/components/DescriptionList/DescriptionListItem.props.d.ts +17 -0
- package/build/components/DescriptionList/DescriptionListItem.props.js +1 -0
- package/build/components/DescriptionList/index.d.ts +4 -0
- package/build/components/DescriptionList/index.js +2 -0
- package/build/components/DetailText/DetailText.js +2 -2
- package/build/components/Divider/Divider.js +47 -1
- package/build/components/Divider/Divider.props.d.ts +2 -2
- package/build/components/Flex/Flex.props.d.ts +3 -2
- package/build/components/Grid/Grid.props.d.ts +2 -2
- package/build/components/Heading/Heading.js +2 -2
- package/build/components/Heading/Heading.props.d.ts +3 -1
- package/build/components/Helper/HelperIcon.js +3 -3
- package/build/components/Helper/HelperText.js +4 -4
- package/build/components/IconButton/IconButtonIcon.js +29 -29
- package/build/components/IconButton/IconButtonRoot.js +94 -88
- package/build/components/IconButton/IconButtonSpinner.js +27 -30
- package/build/components/IconContainer/IconContainer.d.ts +5 -0
- package/build/components/IconContainer/IconContainer.js +161 -0
- package/build/components/IconContainer/IconContainer.props.d.ts +15 -0
- package/build/components/IconContainer/IconContainer.props.js +1 -0
- package/build/components/IconContainer/index.d.ts +2 -0
- package/build/components/IconContainer/index.js +1 -0
- package/build/components/Icons/CircleIcon.js +3 -3
- package/build/components/InlineLink/InlineLinkRoot.js +2 -2
- package/build/components/Input/Input.d.ts +9 -3
- package/build/components/Input/Input.js +11 -43
- package/build/components/Input/Input.props.d.ts +2 -17
- package/build/components/Input/InputField.d.ts +3 -1
- package/build/components/Input/InputField.js +9 -46
- package/build/components/Input/InputIcon.js +1 -1
- package/build/components/Input/InputRoot.js +9 -9
- package/build/components/Label/Label.js +1 -1
- package/build/components/Link/LinkRoot.js +2 -2
- package/build/components/List/List.d.ts +1 -1
- package/build/components/List/List.js +6 -4
- package/build/components/List/List.props.d.ts +9 -10
- package/build/components/List/ListItem/ListItemHelperText.js +1 -1
- package/build/components/List/ListItem/ListItemIcon.js +1 -1
- package/build/components/List/ListItem/ListItemRoot.js +15 -6
- package/build/components/List/ListItem/ListItemTrailingIcon.js +1 -1
- package/build/components/List/index.d.ts +0 -1
- package/build/components/List/index.js +0 -1
- package/build/components/Modal/Modal.d.ts +7 -0
- package/build/components/Modal/Modal.js +180 -0
- package/build/components/Modal/Modal.props.d.ts +24 -0
- package/build/components/Modal/Modal.props.js +1 -0
- package/build/components/Modal/Modal.web.d.ts +7 -0
- package/build/components/Modal/Modal.web.js +164 -0
- package/build/components/Modal/index.d.ts +2 -0
- package/build/components/Modal/index.js +1 -0
- package/build/components/Radio/RadioIndicator.js +2 -2
- package/build/components/Radio/RadioTileRoot.js +3 -3
- package/build/components/RadioCard/RadioCardIndicator.js +2 -2
- package/build/components/RadioCard/RadioCardRoot.js +3 -3
- package/build/components/SectionHeader/SectionHeader.d.ts +6 -0
- package/build/components/SectionHeader/SectionHeader.js +20 -0
- package/build/components/{List/ListHeading/ListHeading.props.d.ts → SectionHeader/SectionHeader.props.d.ts} +7 -9
- package/build/components/SectionHeader/SectionHeader.props.js +1 -0
- package/build/components/SectionHeader/SectionHeaderHeading.d.ts +6 -0
- package/build/components/SectionHeader/SectionHeaderHeading.js +7 -0
- package/build/components/SectionHeader/SectionHeaderHelperText.d.ts +6 -0
- package/build/components/{List/ListHeading/ListHeadingHelperText.js → SectionHeader/SectionHeaderHelperText.js} +5 -5
- package/build/components/{List/ListHeading/ListHeadingTextContent.d.ts → SectionHeader/SectionHeaderTextContent.d.ts} +2 -2
- package/build/components/{List/ListHeading/ListHeadingTextContent.js → SectionHeader/SectionHeaderTextContent.js} +4 -4
- package/build/components/SectionHeader/index.d.ts +4 -0
- package/build/components/SectionHeader/index.js +4 -0
- package/build/components/Select/Select.js +10 -10
- package/build/components/Select/SelectOption.js +6 -6
- package/build/components/Spinner/Spinner.web.js +3 -3
- package/build/components/Switch/Switch.js +10 -7
- package/build/components/Switch/Switch.web.js +10 -8
- package/build/components/Tabs/Tab.d.ts +18 -0
- package/build/components/Tabs/Tab.js +74 -0
- package/build/components/Tabs/Tab.props.d.ts +14 -0
- package/build/components/Tabs/Tab.props.js +1 -0
- package/build/components/Tabs/TabPanel.d.ts +3 -0
- package/build/components/Tabs/TabPanel.js +34 -0
- package/build/components/Tabs/TabPanel.props.d.ts +8 -0
- package/build/components/Tabs/TabPanel.props.js +1 -0
- package/build/components/Tabs/Tabs.context.d.ts +23 -0
- package/build/components/Tabs/Tabs.context.js +8 -0
- package/build/components/Tabs/Tabs.d.ts +6 -0
- package/build/components/Tabs/Tabs.js +114 -0
- package/build/components/Tabs/Tabs.props.d.ts +19 -0
- package/build/components/Tabs/Tabs.props.js +1 -0
- package/build/components/Tabs/TabsList.d.ts +6 -0
- package/build/components/Tabs/TabsList.js +112 -0
- package/build/components/Tabs/TabsList.props.d.ts +6 -0
- package/build/components/Tabs/TabsList.props.js +1 -0
- package/build/components/Tabs/index.d.ts +8 -0
- package/build/components/Tabs/index.js +4 -0
- package/build/components/Textarea/TextareaField.js +5 -5
- package/build/components/Textarea/TextareaRoot.js +9 -9
- package/build/components/ToggleButton/ToggleButtonIcon.js +3 -3
- package/build/components/ToggleButton/ToggleButtonRoot.js +9 -9
- package/build/components/ToggleButton/ToggleButtonText.js +2 -2
- package/build/components/ToggleButtonCard/ToggleButtonCardRoot.js +3 -3
- package/build/components/index.d.ts +9 -3
- package/build/components/index.js +9 -3
- package/build/core/themes.d.ts +1442 -258
- package/build/core/themes.js +59 -3
- package/build/tokens/color.d.ts +1010 -86
- package/build/tokens/color.js +505 -43
- package/build/tokens/components/dark/accordion.d.ts +0 -2
- package/build/tokens/components/dark/accordion.js +0 -2
- package/build/tokens/components/dark/alert.d.ts +0 -16
- package/build/tokens/components/dark/alert.js +0 -16
- package/build/tokens/components/dark/avatar.d.ts +19 -0
- package/build/tokens/components/dark/avatar.js +18 -0
- package/build/tokens/components/dark/badge.d.ts +7 -34
- package/build/tokens/components/dark/badge.js +7 -34
- package/build/tokens/components/dark/banner.d.ts +1 -10
- package/build/tokens/components/dark/banner.js +1 -10
- package/build/tokens/components/dark/bottom-navigation.d.ts +2 -7
- package/build/tokens/components/dark/bottom-navigation.js +2 -7
- package/build/tokens/components/dark/bottom-sheet.d.ts +1 -2
- package/build/tokens/components/dark/bottom-sheet.js +1 -2
- package/build/tokens/components/dark/breadcrumb.d.ts +0 -1
- package/build/tokens/components/dark/breadcrumb.js +0 -1
- package/build/tokens/components/dark/button.d.ts +1 -86
- package/build/tokens/components/dark/button.js +1 -86
- package/build/tokens/components/dark/card.d.ts +0 -28
- package/build/tokens/components/dark/card.js +0 -28
- package/build/tokens/components/dark/carousel-control.d.ts +0 -8
- package/build/tokens/components/dark/carousel-control.js +0 -8
- package/build/tokens/components/dark/checkbox.d.ts +2 -11
- package/build/tokens/components/dark/checkbox.js +2 -11
- package/build/tokens/components/dark/date-picker.d.ts +0 -12
- package/build/tokens/components/dark/date-picker.js +0 -12
- package/build/tokens/components/dark/description-list.d.ts +20 -0
- package/build/tokens/components/dark/description-list.js +19 -0
- package/build/tokens/components/dark/dialog.d.ts +0 -1
- package/build/tokens/components/dark/dialog.js +0 -1
- package/build/tokens/components/dark/divider.d.ts +4 -1
- package/build/tokens/components/dark/divider.js +4 -1
- package/build/tokens/components/dark/expandable-card.d.ts +11 -0
- package/build/tokens/components/dark/expandable-card.js +10 -0
- package/build/tokens/components/dark/icon-button.d.ts +5 -5
- package/build/tokens/components/dark/icon-button.js +5 -5
- package/build/tokens/components/dark/icon-container.d.ts +0 -17
- package/build/tokens/components/dark/icon-container.js +0 -17
- package/build/tokens/components/dark/index.d.ts +10 -4
- package/build/tokens/components/dark/index.js +10 -4
- package/build/tokens/components/dark/indicator-icon-button.d.ts +11 -0
- package/build/tokens/components/dark/indicator-icon-button.js +10 -0
- package/build/tokens/components/dark/inline-link.d.ts +1 -1
- package/build/tokens/components/dark/inline-link.js +1 -1
- package/build/tokens/components/dark/input.d.ts +1 -9
- package/build/tokens/components/dark/input.js +1 -9
- package/build/tokens/components/dark/link.d.ts +2 -2
- package/build/tokens/components/dark/link.js +2 -2
- package/build/tokens/components/dark/list.d.ts +20 -20
- package/build/tokens/components/dark/list.js +20 -20
- package/build/tokens/components/dark/menu.d.ts +0 -12
- package/build/tokens/components/dark/menu.js +0 -12
- package/build/tokens/components/dark/modal.d.ts +0 -1
- package/build/tokens/components/dark/modal.js +0 -1
- package/build/tokens/components/dark/navigation.d.ts +1 -6
- package/build/tokens/components/dark/navigation.js +1 -6
- package/build/tokens/components/dark/pagination.d.ts +12 -0
- package/build/tokens/components/dark/pagination.js +11 -0
- package/build/tokens/components/dark/parts.d.ts +14 -4
- package/build/tokens/components/dark/parts.js +14 -4
- package/build/tokens/components/dark/pill.d.ts +0 -10
- package/build/tokens/components/dark/pill.js +0 -10
- package/build/tokens/components/dark/progress-stepper.d.ts +0 -8
- package/build/tokens/components/dark/progress-stepper.js +0 -8
- package/build/tokens/components/dark/radio.d.ts +2 -9
- package/build/tokens/components/dark/radio.js +2 -9
- package/build/tokens/components/dark/{focus.d.ts → section-header.d.ts} +4 -2
- package/build/tokens/components/dark/{focus.js → section-header.js} +4 -2
- package/build/tokens/components/dark/segmented-control.d.ts +0 -8
- package/build/tokens/components/dark/segmented-control.js +0 -8
- package/build/tokens/components/dark/select.d.ts +0 -10
- package/build/tokens/components/dark/select.js +0 -10
- package/build/tokens/components/dark/spinner.d.ts +1 -1
- package/build/tokens/components/dark/spinner.js +1 -1
- package/build/tokens/components/dark/switch.d.ts +1 -11
- package/build/tokens/components/dark/switch.js +1 -11
- package/build/tokens/components/dark/table.d.ts +23 -0
- package/build/tokens/components/dark/table.js +22 -0
- package/build/tokens/components/dark/tabs.d.ts +26 -0
- package/build/tokens/components/dark/tabs.js +25 -0
- package/build/tokens/components/dark/toast.d.ts +10 -0
- package/build/tokens/components/dark/toast.js +9 -0
- package/build/tokens/components/dark/toggle-button.d.ts +0 -11
- package/build/tokens/components/dark/toggle-button.js +0 -11
- package/build/tokens/components/dark/tooltip.d.ts +12 -0
- package/build/tokens/components/dark/tooltip.js +11 -0
- package/build/tokens/components/dark/top-navigation.d.ts +0 -8
- package/build/tokens/components/dark/top-navigation.js +0 -8
- package/build/tokens/components/light/accordion.d.ts +0 -2
- package/build/tokens/components/light/accordion.js +0 -2
- package/build/tokens/components/light/alert.d.ts +0 -16
- package/build/tokens/components/light/alert.js +0 -16
- package/build/tokens/components/light/avatar.d.ts +19 -0
- package/build/tokens/components/light/avatar.js +18 -0
- package/build/tokens/components/light/badge.d.ts +7 -34
- package/build/tokens/components/light/badge.js +7 -34
- package/build/tokens/components/light/banner.d.ts +2 -11
- package/build/tokens/components/light/banner.js +2 -11
- package/build/tokens/components/light/bottom-navigation.d.ts +0 -5
- package/build/tokens/components/light/bottom-navigation.js +0 -5
- package/build/tokens/components/light/bottom-sheet.d.ts +1 -2
- package/build/tokens/components/light/bottom-sheet.js +1 -2
- package/build/tokens/components/light/breadcrumb.d.ts +0 -1
- package/build/tokens/components/light/breadcrumb.js +0 -1
- package/build/tokens/components/light/button.d.ts +1 -86
- package/build/tokens/components/light/button.js +1 -86
- package/build/tokens/components/light/card.d.ts +0 -28
- package/build/tokens/components/light/card.js +0 -28
- package/build/tokens/components/light/carousel-control.d.ts +0 -8
- package/build/tokens/components/light/carousel-control.js +0 -8
- package/build/tokens/components/light/checkbox.d.ts +3 -12
- package/build/tokens/components/light/checkbox.js +3 -12
- package/build/tokens/components/light/date-picker.d.ts +0 -12
- package/build/tokens/components/light/date-picker.js +0 -12
- package/build/tokens/components/light/description-list.d.ts +20 -0
- package/build/tokens/components/light/description-list.js +19 -0
- package/build/tokens/components/light/dialog.d.ts +0 -1
- package/build/tokens/components/light/dialog.js +0 -1
- package/build/tokens/components/light/divider.d.ts +4 -1
- package/build/tokens/components/light/divider.js +4 -1
- package/build/tokens/components/light/expandable-card.d.ts +11 -0
- package/build/tokens/components/light/expandable-card.js +10 -0
- package/build/tokens/components/light/icon-button.d.ts +5 -5
- package/build/tokens/components/light/icon-button.js +5 -5
- package/build/tokens/components/light/icon-container.d.ts +0 -17
- package/build/tokens/components/light/icon-container.js +0 -17
- package/build/tokens/components/light/index.d.ts +10 -4
- package/build/tokens/components/light/index.js +10 -4
- package/build/tokens/components/light/indicator-icon-button.d.ts +11 -0
- package/build/tokens/components/light/indicator-icon-button.js +10 -0
- package/build/tokens/components/light/input.d.ts +1 -9
- package/build/tokens/components/light/input.js +1 -9
- package/build/tokens/components/light/link.d.ts +2 -2
- package/build/tokens/components/light/link.js +2 -2
- package/build/tokens/components/light/list.d.ts +20 -20
- package/build/tokens/components/light/list.js +20 -20
- package/build/tokens/components/light/menu.d.ts +0 -12
- package/build/tokens/components/light/menu.js +0 -12
- package/build/tokens/components/light/modal.d.ts +0 -1
- package/build/tokens/components/light/modal.js +0 -1
- package/build/tokens/components/light/navigation.d.ts +1 -6
- package/build/tokens/components/light/navigation.js +1 -6
- package/build/tokens/components/light/pagination.d.ts +12 -0
- package/build/tokens/components/light/pagination.js +11 -0
- package/build/tokens/components/light/parts.d.ts +11 -1
- package/build/tokens/components/light/parts.js +11 -1
- package/build/tokens/components/light/pill.d.ts +0 -10
- package/build/tokens/components/light/pill.js +0 -10
- package/build/tokens/components/light/progress-stepper.d.ts +0 -8
- package/build/tokens/components/light/progress-stepper.js +0 -8
- package/build/tokens/components/light/radio.d.ts +3 -10
- package/build/tokens/components/light/radio.js +3 -10
- package/build/tokens/components/light/section-header.d.ts +10 -0
- package/build/tokens/components/light/section-header.js +9 -0
- package/build/tokens/components/light/segmented-control.d.ts +0 -8
- package/build/tokens/components/light/segmented-control.js +0 -8
- package/build/tokens/components/light/select.d.ts +0 -10
- package/build/tokens/components/light/select.js +0 -10
- package/build/tokens/components/light/switch.d.ts +1 -11
- package/build/tokens/components/light/switch.js +1 -11
- package/build/tokens/components/light/table.d.ts +23 -0
- package/build/tokens/components/light/table.js +22 -0
- package/build/tokens/components/light/tabs.d.ts +26 -0
- package/build/tokens/components/light/tabs.js +25 -0
- package/build/tokens/components/light/toast.d.ts +10 -0
- package/build/tokens/components/light/toast.js +9 -0
- package/build/tokens/components/light/toggle-button.d.ts +0 -11
- package/build/tokens/components/light/toggle-button.js +0 -11
- package/build/tokens/components/light/tooltip.d.ts +12 -0
- package/build/tokens/components/light/tooltip.js +11 -0
- package/build/tokens/components/light/top-navigation.d.ts +0 -8
- package/build/tokens/components/light/top-navigation.js +0 -8
- package/build/tokens/index.d.ts +1 -0
- package/build/tokens/index.js +1 -0
- package/build/tokens/layout.d.ts +48 -30
- package/build/tokens/layout.js +24 -15
- package/build/tokens/semantic-dark.d.ts +242 -13
- package/build/tokens/semantic-dark.js +242 -13
- package/build/tokens/semantic-light.d.ts +242 -13
- package/build/tokens/semantic-light.js +242 -13
- package/build/tokens/{components/light/focus.d.ts → semantic.d.ts} +3 -2
- package/build/tokens/{components/light/focus.js → semantic.js} +3 -2
- package/build/types/values.d.ts +12 -7
- package/build/utils/coloursAsArray.d.ts +8 -0
- package/build/utils/coloursAsArray.js +37 -2
- package/build/utils/formatThousands.d.ts +2 -0
- package/build/utils/formatThousands.js +16 -0
- package/build/utils/getFlattenedColorValue.d.ts +3 -1
- package/build/utils/hexWithOpacity.d.ts +2 -0
- package/build/utils/hexWithOpacity.js +15 -0
- package/build/utils/index.d.ts +3 -1
- package/build/utils/index.js +3 -1
- package/build/utils/styleUtils.js +33 -1
- package/docs/assets/modal-android.mp4 +0 -0
- package/docs/assets/modal-ios.mp4 +0 -0
- package/docs/assets/pigs.png +0 -0
- package/docs/components/AllComponents.web.tsx +135 -9
- package/docs/components/BadgeList.tsx +8 -8
- package/docs/components/NextPrevPage.tsx +11 -3
- package/docs/components/UsageWrap.tsx +2 -2
- package/docs/components/ViewFigmaButton.tsx +3 -3
- package/docs/heplers/addReactNativePrefix.ts +8 -0
- package/docs/heplers/index.ts +1 -0
- package/docs/introduction.mdx +2 -2
- package/docs/llm-docs/unistyles-llms-full.txt +1 -1
- package/docs/theme-tokens.mdx +91 -26
- package/package.json +21 -19
- package/src/components/Accordion/Accordion.docs.mdx +25 -39
- package/src/components/Accordion/Accordion.props.ts +2 -2
- package/src/components/Accordion/Accordion.stories.tsx +10 -10
- package/src/components/Accordion/Accordion.tsx +14 -14
- package/src/components/Accordion/AccordionIcon.tsx +2 -2
- package/src/components/Accordion/AccordionItemRoot.tsx +3 -3
- package/src/components/Accordion/AccordionTrigger.tsx +4 -4
- package/src/components/Accordion/index.ts +3 -4
- package/src/components/Alert/Alert.docs.mdx +25 -25
- package/src/components/Alert/Alert.props.ts +3 -3
- package/src/components/Alert/Alert.stories.tsx +11 -11
- package/src/components/Alert/Alert.tsx +22 -22
- package/src/components/Alert/AlertCloseButton.tsx +3 -3
- package/src/components/Alert/AlertIcon.tsx +7 -7
- package/src/components/Badge/Badge.context.ts +2 -0
- package/src/components/Badge/Badge.docs.mdx +16 -15
- package/src/components/Badge/Badge.props.ts +15 -2
- package/src/components/Badge/Badge.stories.tsx +101 -54
- package/src/components/Badge/Badge.tsx +189 -35
- package/src/components/Badge/BadgeIcon.tsx +29 -19
- package/src/components/Badge/BadgeText.tsx +30 -19
- package/src/components/BodyText/BodyText.tsx +4 -4
- package/src/components/BottomSheet/BottomSheet.docs.mdx +23 -5
- package/src/components/BottomSheet/BottomSheet.stories.tsx +9 -9
- package/src/components/BottomSheet/BottomSheet.tsx +5 -5
- package/src/components/BottomSheet/BottomSheetHandle.tsx +1 -1
- package/src/components/BottomSheet/BottomSheetModal.tsx +1 -1
- package/src/components/BottomSheet/BottomSheetScrollView.tsx +4 -2
- package/src/components/BottomSheet/BottomSheetView.tsx +1 -1
- package/src/components/Box/Box.stories.tsx +3 -3
- package/src/components/Button/Button.docs.mdx +35 -35
- package/src/components/Button/Button.props.tsx +7 -7
- package/src/components/Button/Button.stories.tsx +16 -16
- package/src/components/Button/ButtonGroupRoot.tsx +12 -2
- package/src/components/Button/ButtonIcon.tsx +29 -29
- package/src/components/Button/ButtonRoot.tsx +79 -89
- package/src/components/Button/ButtonSpinner.tsx +30 -33
- package/src/components/Button/ButtonText.tsx +40 -26
- package/src/components/Card/Card.docs.mdx +22 -22
- package/src/components/Card/Card.props.ts +11 -11
- package/src/components/Card/Card.stories.tsx +34 -34
- package/src/components/Card/CardRoot.tsx +56 -56
- package/src/components/Checkbox/CheckboxIcon.tsx +4 -4
- package/src/components/Checkbox/CheckboxIndicator.tsx +3 -3
- package/src/components/Checkbox/CheckboxTileRoot.tsx +3 -3
- package/src/components/CurrencyInput/CurrencyInput.docs.mdx +120 -0
- package/src/components/CurrencyInput/CurrencyInput.props.ts +19 -0
- package/src/components/CurrencyInput/CurrencyInput.stories.tsx +116 -0
- package/src/components/CurrencyInput/CurrencyInput.tsx +91 -0
- package/src/components/CurrencyInput/index.ts +1 -0
- package/src/components/DescriptionList/DescriptionList.context.ts +18 -0
- package/src/components/DescriptionList/DescriptionList.docs.mdx +98 -0
- package/src/components/DescriptionList/DescriptionList.props.ts +20 -0
- package/src/components/DescriptionList/DescriptionList.stories.tsx +154 -0
- package/src/components/DescriptionList/DescriptionList.tsx +64 -0
- package/src/components/DescriptionList/DescriptionListItem.props.ts +19 -0
- package/src/components/DescriptionList/DescriptionListItem.tsx +101 -0
- package/src/components/DescriptionList/index.ts +4 -0
- package/src/components/DetailText/DetailText.tsx +3 -3
- package/src/components/Divider/Divider.props.ts +2 -2
- package/src/components/Divider/Divider.stories.tsx +3 -3
- package/src/components/Divider/Divider.tsx +47 -1
- package/src/components/Flex/Flex.docs.mdx +4 -4
- package/src/components/Flex/Flex.props.ts +3 -2
- package/src/components/Flex/Flex.stories.tsx +1 -1
- package/src/components/Grid/Grid.docs.mdx +12 -12
- package/src/components/Grid/Grid.props.ts +2 -2
- package/src/components/Grid/Grid.stories.tsx +2 -2
- package/src/components/Heading/Heading.props.ts +3 -1
- package/src/components/Heading/Heading.tsx +2 -2
- package/src/components/Helper/HelperIcon.tsx +3 -3
- package/src/components/Helper/HelperText.tsx +4 -4
- package/src/components/Icon/Icon.stories.tsx +2 -2
- package/src/components/IconButton/IconButton.docs.mdx +21 -16
- package/src/components/IconButton/IconButton.figma.tsx +1 -1
- package/src/components/IconButton/IconButton.stories.tsx +14 -14
- package/src/components/IconButton/IconButtonIcon.tsx +29 -29
- package/src/components/IconButton/IconButtonRoot.tsx +94 -88
- package/src/components/IconButton/IconButtonSpinner.tsx +27 -30
- package/src/components/IconContainer/IconContainer.docs.mdx +90 -0
- package/src/components/IconContainer/IconContainer.props.ts +17 -0
- package/src/components/IconContainer/IconContainer.stories.tsx +130 -0
- package/src/components/IconContainer/IconContainer.tsx +180 -0
- package/src/components/IconContainer/index.tsx +2 -0
- package/src/components/Icons/CircleIcon.tsx +9 -11
- package/src/components/InlineLink/InlineLinkRoot.tsx +2 -2
- package/src/components/Input/Input.docs.mdx +19 -17
- package/src/components/Input/Input.props.ts +1 -20
- package/src/components/Input/Input.stories.tsx +5 -10
- package/src/components/Input/Input.tsx +16 -61
- package/src/components/Input/InputField.tsx +25 -59
- package/src/components/Input/InputIcon.tsx +1 -1
- package/src/components/Input/InputRoot.tsx +10 -10
- package/src/components/Label/Label.tsx +2 -2
- package/src/components/Link/LinkRoot.tsx +2 -2
- package/src/components/List/List.docs.mdx +35 -56
- package/src/components/List/List.props.ts +9 -10
- package/src/components/List/List.stories.tsx +8 -8
- package/src/components/List/List.tsx +25 -25
- package/src/components/List/ListItem/ListItemHelperText.tsx +1 -1
- package/src/components/List/ListItem/ListItemIcon.tsx +1 -1
- package/src/components/List/ListItem/ListItemRoot.tsx +15 -6
- package/src/components/List/ListItem/ListItemTrailingIcon.tsx +1 -1
- package/src/components/List/index.ts +0 -1
- package/src/components/Modal/Modal.docs.mdx +547 -0
- package/src/components/Modal/Modal.props.ts +26 -0
- package/src/components/Modal/Modal.stories.tsx +222 -0
- package/src/components/Modal/Modal.tsx +351 -0
- package/src/components/Modal/Modal.web.tsx +333 -0
- package/src/components/Modal/index.ts +2 -0
- package/src/components/Radio/RadioIndicator.tsx +2 -2
- package/src/components/Radio/RadioTileRoot.tsx +3 -3
- package/src/components/RadioCard/RadioCardIndicator.tsx +2 -2
- package/src/components/RadioCard/RadioCardRoot.tsx +3 -3
- package/src/components/{List/ListHeading/ListHeading.figma.tsx → SectionHeader/SectionHeader.figma.tsx} +3 -3
- package/src/components/{List/ListHeading/ListHeading.props.ts → SectionHeader/SectionHeader.props.ts} +7 -9
- package/src/components/SectionHeader/SectionHeader.stories.tsx +76 -0
- package/src/components/{List/ListHeading/ListHeading.tsx → SectionHeader/SectionHeader.tsx} +17 -19
- package/src/components/SectionHeader/SectionHeaderHeading.tsx +14 -0
- package/src/components/SectionHeader/SectionHeaderHelperText.tsx +21 -0
- package/src/components/{List/ListHeading/ListHeadingTextContent.tsx → SectionHeader/SectionHeaderTextContent.tsx} +4 -4
- package/src/components/SectionHeader/Sectionheader.docs.mdx +83 -0
- package/src/components/SectionHeader/index.ts +4 -0
- package/src/components/Select/Select.tsx +10 -10
- package/src/components/Select/SelectOption.tsx +7 -7
- package/src/components/Spinner/Spinner.tsx +3 -3
- package/src/components/Spinner/Spinner.web.tsx +12 -12
- package/src/components/Switch/Switch.tsx +10 -7
- package/src/components/Switch/Switch.web.tsx +10 -12
- package/src/components/Tabs/Tab.props.ts +16 -0
- package/src/components/Tabs/Tab.tsx +113 -0
- package/src/components/Tabs/TabPanel.props.ts +10 -0
- package/src/components/Tabs/TabPanel.tsx +46 -0
- package/src/components/Tabs/Tabs.context.ts +26 -0
- package/src/components/Tabs/Tabs.docs.mdx +214 -0
- package/src/components/Tabs/Tabs.props.ts +21 -0
- package/src/components/Tabs/Tabs.stories.tsx +270 -0
- package/src/components/Tabs/Tabs.tsx +139 -0
- package/src/components/Tabs/TabsList.props.ts +8 -0
- package/src/components/Tabs/TabsList.tsx +194 -0
- package/src/components/Tabs/index.ts +8 -0
- package/src/components/Textarea/TextareaField.tsx +5 -5
- package/src/components/Textarea/TextareaRoot.tsx +10 -10
- package/src/components/ToggleButton/ToggleButtonIcon.tsx +3 -3
- package/src/components/ToggleButton/ToggleButtonRoot.tsx +11 -11
- package/src/components/ToggleButton/ToggleButtonText.tsx +2 -2
- package/src/components/ToggleButtonCard/ToggleButtonCardRoot.tsx +3 -3
- package/src/components/index.ts +11 -5
- package/src/core/themes.ts +59 -3
- package/src/tokens/color.ts +505 -43
- package/src/tokens/components/dark/accordion.ts +0 -2
- package/src/tokens/components/dark/alert.ts +0 -16
- package/src/tokens/components/dark/avatar.ts +19 -0
- package/src/tokens/components/dark/badge.ts +7 -34
- package/src/tokens/components/dark/banner.ts +1 -10
- package/src/tokens/components/dark/bottom-navigation.ts +2 -7
- package/src/tokens/components/dark/bottom-sheet.ts +1 -2
- package/src/tokens/components/dark/breadcrumb.ts +0 -1
- package/src/tokens/components/dark/button.ts +1 -86
- package/src/tokens/components/dark/card.ts +0 -28
- package/src/tokens/components/dark/carousel-control.ts +0 -8
- package/src/tokens/components/dark/checkbox.ts +2 -11
- package/src/tokens/components/dark/date-picker.ts +0 -12
- package/src/tokens/components/dark/description-list.ts +20 -0
- package/src/tokens/components/dark/dialog.ts +0 -1
- package/src/tokens/components/dark/divider.ts +4 -1
- package/src/tokens/components/{light/footer.ts → dark/expandable-card.ts} +4 -5
- package/src/tokens/components/dark/icon-button.ts +5 -5
- package/src/tokens/components/dark/icon-container.ts +0 -17
- package/src/tokens/components/dark/index.ts +10 -4
- package/src/tokens/components/dark/{footer.ts → indicator-icon-button.ts} +4 -5
- package/src/tokens/components/dark/inline-link.ts +1 -1
- package/src/tokens/components/dark/input.ts +1 -9
- package/src/tokens/components/dark/link.ts +2 -2
- package/src/tokens/components/dark/list.ts +20 -20
- package/src/tokens/components/dark/menu.ts +0 -12
- package/src/tokens/components/dark/modal.ts +0 -1
- package/src/tokens/components/dark/navigation.ts +1 -6
- package/src/tokens/components/dark/pagination.ts +12 -0
- package/src/tokens/components/dark/parts.ts +14 -4
- package/src/tokens/components/dark/pill.ts +0 -10
- package/src/tokens/components/dark/progress-stepper.ts +0 -8
- package/src/tokens/components/dark/radio.ts +2 -9
- package/src/tokens/components/dark/{focus.ts → section-header.ts} +4 -2
- package/src/tokens/components/dark/segmented-control.ts +0 -8
- package/src/tokens/components/dark/select.ts +0 -10
- package/src/tokens/components/dark/spinner.ts +1 -1
- package/src/tokens/components/dark/switch.ts +1 -11
- package/src/tokens/components/dark/table.ts +23 -0
- package/src/tokens/components/dark/tabs.ts +26 -0
- package/src/tokens/components/dark/toast.ts +10 -0
- package/src/tokens/components/dark/toggle-button.ts +0 -11
- package/src/tokens/components/dark/tooltip.ts +12 -0
- package/src/tokens/components/dark/top-navigation.ts +0 -8
- package/src/tokens/components/light/accordion.ts +0 -2
- package/src/tokens/components/light/alert.ts +0 -16
- package/src/tokens/components/light/avatar.ts +19 -0
- package/src/tokens/components/light/badge.ts +7 -34
- package/src/tokens/components/light/banner.ts +2 -11
- package/src/tokens/components/light/bottom-navigation.ts +0 -5
- package/src/tokens/components/light/bottom-sheet.ts +1 -2
- package/src/tokens/components/light/breadcrumb.ts +0 -1
- package/src/tokens/components/light/button.ts +1 -86
- package/src/tokens/components/light/card.ts +0 -28
- package/src/tokens/components/light/carousel-control.ts +0 -8
- package/src/tokens/components/light/checkbox.ts +3 -12
- package/src/tokens/components/light/date-picker.ts +0 -12
- package/src/tokens/components/light/description-list.ts +20 -0
- package/src/tokens/components/light/dialog.ts +0 -1
- package/src/tokens/components/light/divider.ts +4 -1
- package/src/tokens/components/light/expandable-card.ts +11 -0
- package/src/tokens/components/light/icon-button.ts +5 -5
- package/src/tokens/components/light/icon-container.ts +0 -17
- package/src/tokens/components/light/index.ts +10 -4
- package/src/tokens/components/light/indicator-icon-button.ts +11 -0
- package/src/tokens/components/light/input.ts +1 -9
- package/src/tokens/components/light/link.ts +2 -2
- package/src/tokens/components/light/list.ts +20 -20
- package/src/tokens/components/light/menu.ts +0 -12
- package/src/tokens/components/light/modal.ts +0 -1
- package/src/tokens/components/light/navigation.ts +1 -6
- package/src/tokens/components/light/pagination.ts +12 -0
- package/src/tokens/components/light/parts.ts +11 -1
- package/src/tokens/components/light/pill.ts +0 -10
- package/src/tokens/components/light/progress-stepper.ts +0 -8
- package/src/tokens/components/light/radio.ts +3 -10
- package/src/tokens/components/light/{focus.ts → section-header.ts} +4 -2
- package/src/tokens/components/light/segmented-control.ts +0 -8
- package/src/tokens/components/light/select.ts +0 -10
- package/src/tokens/components/light/switch.ts +1 -11
- package/src/tokens/components/light/table.ts +23 -0
- package/src/tokens/components/light/tabs.ts +26 -0
- package/src/tokens/components/light/toast.ts +10 -0
- package/src/tokens/components/light/toggle-button.ts +0 -11
- package/src/tokens/components/light/tooltip.ts +12 -0
- package/src/tokens/components/light/top-navigation.ts +0 -8
- package/src/tokens/index.ts +1 -0
- package/src/tokens/layout.ts +24 -15
- package/src/tokens/semantic-dark.ts +242 -13
- package/src/tokens/semantic-light.ts +242 -13
- package/src/tokens/semantic.ts +9 -0
- package/src/types/values.ts +31 -7
- package/src/utils/coloursAsArray.ts +44 -2
- package/src/utils/formatThousands.ts +14 -0
- package/src/utils/getFlattenedColorValue.ts +1 -1
- package/src/utils/hexWithOpacity.ts +19 -0
- package/src/utils/index.ts +3 -1
- package/src/utils/styleUtils.ts +39 -1
- package/src/vite-env.d.ts +5 -0
- package/build/components/Accordion/AccordionHeading/AccordionHeading.d.ts +0 -6
- package/build/components/Accordion/AccordionHeading/AccordionHeading.js +0 -16
- package/build/components/Accordion/AccordionHeading/AccordionHeading.props.d.ts +0 -14
- package/build/components/Accordion/AccordionHeading/AccordionHeadingHelperText.d.ts +0 -6
- package/build/components/Accordion/AccordionHeading/AccordionHeadingHelperText.js +0 -13
- package/build/components/Accordion/AccordionHeading/AccordionHeadingTextContent.d.ts +0 -6
- package/build/components/Accordion/AccordionHeading/AccordionHeadingTextContent.js +0 -14
- package/build/components/Accordion/AccordionHeading/AccordionHeadingTitle.d.ts +0 -6
- package/build/components/Accordion/AccordionHeading/AccordionHeadingTitle.js +0 -7
- package/build/components/Accordion/AccordionHeading/index.d.ts +0 -4
- package/build/components/Accordion/AccordionHeading/index.js +0 -4
- package/build/components/List/ListHeading/ListHeading.d.ts +0 -6
- package/build/components/List/ListHeading/ListHeading.js +0 -20
- package/build/components/List/ListHeading/ListHeadingHelperText.d.ts +0 -6
- package/build/components/List/ListHeading/ListHeadingTitle.d.ts +0 -6
- package/build/components/List/ListHeading/ListHeadingTitle.js +0 -7
- package/build/components/List/ListHeading/index.d.ts +0 -4
- package/build/components/List/ListHeading/index.js +0 -4
- package/build/tokens/components/dark/footer.d.ts +0 -12
- package/build/tokens/components/dark/footer.js +0 -11
- package/build/tokens/components/dark/icon.d.ts +0 -15
- package/build/tokens/components/dark/icon.js +0 -14
- package/build/tokens/components/dark/text.d.ts +0 -11
- package/build/tokens/components/dark/text.js +0 -10
- package/build/tokens/components/light/footer.d.ts +0 -12
- package/build/tokens/components/light/footer.js +0 -11
- package/build/tokens/components/light/icon.d.ts +0 -15
- package/build/tokens/components/light/icon.js +0 -14
- package/build/tokens/components/light/text.d.ts +0 -11
- package/build/tokens/components/light/text.js +0 -10
- package/src/components/Accordion/AccordionHeading/AccordionHeading.props.ts +0 -19
- package/src/components/Accordion/AccordionHeading/AccordionHeading.tsx +0 -38
- package/src/components/Accordion/AccordionHeading/AccordionHeadingHelperText.tsx +0 -22
- package/src/components/Accordion/AccordionHeading/AccordionHeadingTextContent.tsx +0 -21
- package/src/components/Accordion/AccordionHeading/AccordionHeadingTitle.tsx +0 -14
- package/src/components/Accordion/AccordionHeading/index.ts +0 -4
- package/src/components/List/ListHeading/ListHeadingHelperText.tsx +0 -21
- package/src/components/List/ListHeading/ListHeadingTitle.tsx +0 -14
- package/src/components/List/ListHeading/index.ts +0 -4
- package/src/tokens/components/dark/icon.ts +0 -15
- package/src/tokens/components/dark/text.ts +0 -11
- package/src/tokens/components/light/icon.ts +0 -15
- package/src/tokens/components/light/text.ts +0 -11
- /package/build/components/{Accordion/AccordionHeading/AccordionHeading.props.js → CurrencyInput/CurrencyInput.props.js} +0 -0
- /package/build/components/{List/ListHeading/ListHeading.props.js → DescriptionList/DescriptionList.props.js} +0 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import { Badge, BodyText, Tab, TabPanel, Tabs, TabsList } from '../../';
|
|
3
|
+
import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
4
|
+
import * as Stories from './Tabs.stories';
|
|
5
|
+
|
|
6
|
+
<BackToTopButton />
|
|
7
|
+
|
|
8
|
+
<ViewFigmaButton url="https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=6463-1113" />
|
|
9
|
+
|
|
10
|
+
<Meta title="Components / Tabs" />
|
|
11
|
+
|
|
12
|
+
# Tabs
|
|
13
|
+
|
|
14
|
+
Tabs are a navigational component that allows users to move easily between groups of related content.
|
|
15
|
+
|
|
16
|
+
- [Playground](#playground)
|
|
17
|
+
- [Usage](#usage)
|
|
18
|
+
- [Examples](#examples)
|
|
19
|
+
- [Controlled](#controlled)
|
|
20
|
+
- [Overflow & Scrolling](#overflow--scrolling)
|
|
21
|
+
- [With Icons](#with-icons)
|
|
22
|
+
- [Props](#props)
|
|
23
|
+
- [Size Variants](#size-variants)
|
|
24
|
+
- [Accessibility](#accessibility)
|
|
25
|
+
|
|
26
|
+
## Playground
|
|
27
|
+
|
|
28
|
+
<Canvas of={Stories.Playground} />
|
|
29
|
+
<Controls of={Stories.Playground} />
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
<UsageWrap>
|
|
34
|
+
<Tabs defaultValue="account">
|
|
35
|
+
<TabsList>
|
|
36
|
+
<Tab value="account">Account</Tab>
|
|
37
|
+
<Tab value="billing">Billing</Tab>
|
|
38
|
+
<Tab value="usage">Usage</Tab>
|
|
39
|
+
</TabsList>
|
|
40
|
+
<TabPanel value="account">
|
|
41
|
+
<BodyText>Account content</BodyText>
|
|
42
|
+
</TabPanel>
|
|
43
|
+
<TabPanel value="billing">
|
|
44
|
+
<BodyText>Billing content</BodyText>
|
|
45
|
+
</TabPanel>
|
|
46
|
+
<TabPanel value="usage">
|
|
47
|
+
<BodyText>Usage metrics content</BodyText>
|
|
48
|
+
</TabPanel>
|
|
49
|
+
</Tabs>
|
|
50
|
+
</UsageWrap>
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { Tabs, TabsList, Tab, TabPanel } from '@utilitywarehouse/hearth-react-native';
|
|
54
|
+
|
|
55
|
+
<Tabs defaultValue="account">
|
|
56
|
+
<TabsList>
|
|
57
|
+
<Tab value="account">Account</Tab>
|
|
58
|
+
<Tab value="billing">Billing</Tab>
|
|
59
|
+
<Tab value="usage">Usage</Tab>
|
|
60
|
+
</TabsList>
|
|
61
|
+
<TabPanel value="account">
|
|
62
|
+
<BodyText>Account content</BodyText>
|
|
63
|
+
</TabPanel>
|
|
64
|
+
<TabPanel value="billing">
|
|
65
|
+
<BodyText>Billing content</BodyText>
|
|
66
|
+
</TabPanel>
|
|
67
|
+
<TabPanel value="usage">
|
|
68
|
+
<BodyText>Usage metrics content</BodyText>
|
|
69
|
+
</TabPanel>
|
|
70
|
+
</Tabs>;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Examples
|
|
74
|
+
|
|
75
|
+
### Controlled
|
|
76
|
+
|
|
77
|
+
Tabs can be controlled by passing `value` and `onValueChange` props to the `Tabs` component.
|
|
78
|
+
This allows you to manage the active tab state externally.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
const [tab, setTab] = useState('account');
|
|
82
|
+
<Tabs value={tab} onValueChange={setTab}>
|
|
83
|
+
<TabsList>
|
|
84
|
+
<Tab value="account">Account</Tab>
|
|
85
|
+
<Tab value="billing">Billing</Tab>
|
|
86
|
+
<Tab value="usage">Usage</Tab>
|
|
87
|
+
</TabsList>
|
|
88
|
+
<TabPanel value="account">
|
|
89
|
+
<BodyText>Account content</BodyText>
|
|
90
|
+
</TabPanel>
|
|
91
|
+
<TabPanel value="billing">
|
|
92
|
+
<BodyText>Billing content</BodyText>
|
|
93
|
+
</TabPanel>
|
|
94
|
+
<TabPanel value="usage">
|
|
95
|
+
<BodyText>Usage metrics content</BodyText>
|
|
96
|
+
</TabPanel>
|
|
97
|
+
</Tabs>;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Overflow & Scrolling
|
|
101
|
+
|
|
102
|
+
<Canvas of={Stories.WithScrolling} />
|
|
103
|
+
|
|
104
|
+
When the combined tab labels exceed the horizontal space, the list becomes horizontally scrollable.
|
|
105
|
+
Contextual navigation buttons (previous / next) appear just outside the scrollable area. They:
|
|
106
|
+
|
|
107
|
+
- Scroll by ~60% of the visible width per press (for efficient paging)
|
|
108
|
+
- Are hidden from assistive technology (screen readers) - users rely on the tab structure itself
|
|
109
|
+
- Only render when further scrolling in that direction is possible
|
|
110
|
+
- Honor reduced motion: only the indicator animation is affected (system reduced motion will minimise excessive transitions)
|
|
111
|
+
|
|
112
|
+
### With Icons
|
|
113
|
+
|
|
114
|
+
You can add icons to each `Tab` by passing an icon component to the `icon` prop. The icon will be placed to the left of the tab label.
|
|
115
|
+
|
|
116
|
+
<Canvas of={Stories.WithIcons} />
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { Tabs, TabsList, Tab, TabPanel } from '@utilitywarehouse/hearth-react-native';
|
|
120
|
+
import {
|
|
121
|
+
ElectricityMediumIcon,
|
|
122
|
+
MobileMediumIcon,
|
|
123
|
+
InsuranceMediumIcon,
|
|
124
|
+
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
125
|
+
|
|
126
|
+
const MyComponent = () => (
|
|
127
|
+
<Tabs defaultValue="one">
|
|
128
|
+
<TabsList>
|
|
129
|
+
<Tab value="one" icon={ElectricityMediumIcon}>
|
|
130
|
+
Energy
|
|
131
|
+
</Tab>
|
|
132
|
+
<Tab value="two" icon={BroadbandMediumIcon}>
|
|
133
|
+
Broadband
|
|
134
|
+
</Tab>
|
|
135
|
+
<Tab value="three" icon={MobileMediumIcon}>
|
|
136
|
+
Mobile
|
|
137
|
+
</Tab>
|
|
138
|
+
<Tab value="four" icon={InsuranceMediumIcon}>
|
|
139
|
+
Insurance
|
|
140
|
+
</Tab>
|
|
141
|
+
</TabsList>
|
|
142
|
+
<TabPanel value="one">
|
|
143
|
+
<BodyText>One panel</BodyText>
|
|
144
|
+
</TabPanel>
|
|
145
|
+
<TabPanel value="two">
|
|
146
|
+
<BodyText>Two panel</BodyText>
|
|
147
|
+
</TabPanel>
|
|
148
|
+
<TabPanel value="three">
|
|
149
|
+
<BodyText>Three panel</BodyText>
|
|
150
|
+
</TabPanel>
|
|
151
|
+
<TabPanel value="four">
|
|
152
|
+
<BodyText>Four panel</BodyText>
|
|
153
|
+
</TabPanel>
|
|
154
|
+
</Tabs>
|
|
155
|
+
);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Props
|
|
159
|
+
|
|
160
|
+
### Tabs
|
|
161
|
+
|
|
162
|
+
| Prop | Type | Description | Default |
|
|
163
|
+
| --------------- | ------------------------- | ------------------------------------------------------------------- | ---------- |
|
|
164
|
+
| `value` | `string` | Controlled active tab value | - |
|
|
165
|
+
| `defaultValue` | `string` | Uncontrolled initial tab value | first Tab |
|
|
166
|
+
| `onValueChange` | `(value: string) => void` | Change handler | - |
|
|
167
|
+
| `size` | `'md' \| 'lg'` | Size variant (affects tab height & list padding) | `md` |
|
|
168
|
+
| `disabled` | `boolean` | Disables all interaction | `false` |
|
|
169
|
+
| `withPanels` | `boolean` | If true, expects sibling `TabPanel` elements and wires ARIA linkage | `true`\* |
|
|
170
|
+
| `children` | `ReactNode` | Composition (typically `TabsList` + `TabPanel` children) | (required) |
|
|
171
|
+
|
|
172
|
+
\*If omitted you can still compose panels manually, but accessibility linkage (`aria-controls` / `id`) is provided when `withPanels` is true.
|
|
173
|
+
|
|
174
|
+
### TabsList / Tab / TabPanel
|
|
175
|
+
|
|
176
|
+
#### TabsList
|
|
177
|
+
|
|
178
|
+
| Prop | Type | Description | Default |
|
|
179
|
+
| ---------- | ----------- | -------------------------- | ---------- |
|
|
180
|
+
| `children` | `ReactNode` | One or more `Tab` elements | (required) |
|
|
181
|
+
|
|
182
|
+
#### Tab
|
|
183
|
+
|
|
184
|
+
| Prop | Type | Description | Default |
|
|
185
|
+
| ---------- | --------------- | --------------------------------- | ---------- |
|
|
186
|
+
| `value` | `string` | Unique tab value | (required) |
|
|
187
|
+
| `children` | `ReactNode` | Label content (can include badge) | (required) |
|
|
188
|
+
| `icon` | `ComponentType` | Optional leading icon | - |
|
|
189
|
+
| `disabled` | `boolean` | Disabled state | `false` |
|
|
190
|
+
|
|
191
|
+
#### TabPanel
|
|
192
|
+
|
|
193
|
+
| Prop | Type | Description | Default |
|
|
194
|
+
| ------------- | ----------- | ------------------------------------------- | ---------- |
|
|
195
|
+
| `value` | `string` | Matches a `Tab` value | (required) |
|
|
196
|
+
| `children` | `ReactNode` | Panel content | (required) |
|
|
197
|
+
| `keepMounted` | `boolean` | Keep hidden panels in tree (preserve state) | `false` |
|
|
198
|
+
|
|
199
|
+
## Size Variants
|
|
200
|
+
|
|
201
|
+
<Canvas of={Stories.Sizes} />
|
|
202
|
+
|
|
203
|
+
## Accessibility
|
|
204
|
+
|
|
205
|
+
| Element | Role | Notes |
|
|
206
|
+
| ----------- | --------------------------------------- | ----------------------------------------------- |
|
|
207
|
+
| `Tabs` root | `tablist` | Container for related `tab` elements |
|
|
208
|
+
| `Tab` | `tab` | Uses `accessibilityState.selected` & `disabled` |
|
|
209
|
+
| `TabPanel` | `tabpanel` (web) / hidden view (native) | Inactive panels removed from a11y tree |
|
|
210
|
+
|
|
211
|
+
Selection state is communicated through `accessibilityState`. Provide concise labels (children text) for best screen reader clarity.
|
|
212
|
+
Any extra content you compose is read in order unless you explicitly hide it. The animated indicator reflects the active tab;
|
|
213
|
+
reduced motion preferences are respected. Hidden panels are removed from the accessibility tree.
|
|
214
|
+
Overflow scroll buttons are hidden from assistive tech and only appear visually when scrolling is possible.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface TabsProps extends ViewProps {
|
|
5
|
+
/** Controlled active tab value */
|
|
6
|
+
value?: string;
|
|
7
|
+
/** Uncontrolled initial value */
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
/** Callback when active tab changes */
|
|
10
|
+
onValueChange?: (value: string) => void;
|
|
11
|
+
/** Size variant */
|
|
12
|
+
size?: 'md' | 'lg';
|
|
13
|
+
/** Tabs (Tab components) */
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
/** Disable all tabs */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** If true, expect sibling TabPanel components and manage their rendering/ARIA linkage */
|
|
18
|
+
withPanels?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default TabsProps;
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import {
|
|
3
|
+
BroadbandMediumIcon,
|
|
4
|
+
ElectricityMediumIcon,
|
|
5
|
+
InsuranceMediumIcon,
|
|
6
|
+
MobileMediumIcon,
|
|
7
|
+
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { Platform } from 'react-native';
|
|
10
|
+
import { BodyText, Button, Flex, Tab, TabPanel, Tabs, TabsList } from '../';
|
|
11
|
+
|
|
12
|
+
const meta = {
|
|
13
|
+
title: 'Stories / Tabs',
|
|
14
|
+
component: Tabs,
|
|
15
|
+
args: {
|
|
16
|
+
size: 'md',
|
|
17
|
+
children: undefined,
|
|
18
|
+
},
|
|
19
|
+
argTypes: {
|
|
20
|
+
size: { control: 'radio', options: ['md', 'lg'] },
|
|
21
|
+
},
|
|
22
|
+
} satisfies Meta<typeof Tabs>;
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
type Story = StoryObj<typeof meta>;
|
|
26
|
+
|
|
27
|
+
export const Playground: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
children: (
|
|
30
|
+
<>
|
|
31
|
+
<Tab value="account">Account</Tab>
|
|
32
|
+
<Tab value="billing">Billing</Tab>
|
|
33
|
+
<Tab value="usage">Usage</Tab>
|
|
34
|
+
<Tab value="settings">Settings</Tab>
|
|
35
|
+
</>
|
|
36
|
+
),
|
|
37
|
+
},
|
|
38
|
+
render: ({ children, ...args }) => (
|
|
39
|
+
<Tabs {...args} defaultValue="account">
|
|
40
|
+
<TabsList>{children}</TabsList>
|
|
41
|
+
<TabPanel value="account">
|
|
42
|
+
<BodyText>Account content</BodyText>
|
|
43
|
+
</TabPanel>
|
|
44
|
+
<TabPanel value="billing">
|
|
45
|
+
<BodyText>Billing content</BodyText>
|
|
46
|
+
</TabPanel>
|
|
47
|
+
<TabPanel value="usage">
|
|
48
|
+
<BodyText>Usage metrics</BodyText>
|
|
49
|
+
</TabPanel>
|
|
50
|
+
<TabPanel value="settings">
|
|
51
|
+
<BodyText>Settings content</BodyText>
|
|
52
|
+
</TabPanel>
|
|
53
|
+
</Tabs>
|
|
54
|
+
),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Sizes: Story = {
|
|
58
|
+
args: { children: null },
|
|
59
|
+
render: () => (
|
|
60
|
+
<>
|
|
61
|
+
<Tabs size="md" defaultValue="a">
|
|
62
|
+
<TabsList>
|
|
63
|
+
<Tab value="a">Medium A</Tab>
|
|
64
|
+
<Tab value="b">Medium B</Tab>
|
|
65
|
+
<Tab value="c">Medium C</Tab>
|
|
66
|
+
</TabsList>
|
|
67
|
+
<TabPanel value="a">
|
|
68
|
+
<BodyText>Medium A panel</BodyText>
|
|
69
|
+
</TabPanel>
|
|
70
|
+
<TabPanel value="b">
|
|
71
|
+
<BodyText>Medium B panel</BodyText>
|
|
72
|
+
</TabPanel>
|
|
73
|
+
<TabPanel value="c">
|
|
74
|
+
<BodyText>Medium C panel</BodyText>
|
|
75
|
+
</TabPanel>
|
|
76
|
+
</Tabs>
|
|
77
|
+
<Tabs size="lg" defaultValue="a" style={{ marginTop: 24 }}>
|
|
78
|
+
<TabsList>
|
|
79
|
+
<Tab value="a">Large A</Tab>
|
|
80
|
+
<Tab value="b">Large B</Tab>
|
|
81
|
+
<Tab value="c">Large C</Tab>
|
|
82
|
+
</TabsList>
|
|
83
|
+
<TabPanel value="a">
|
|
84
|
+
<BodyText>Large A panel</BodyText>
|
|
85
|
+
</TabPanel>
|
|
86
|
+
<TabPanel value="b">
|
|
87
|
+
<BodyText>Large B panel</BodyText>
|
|
88
|
+
</TabPanel>
|
|
89
|
+
<TabPanel value="c">
|
|
90
|
+
<BodyText>Large C panel</BodyText>
|
|
91
|
+
</TabPanel>
|
|
92
|
+
</Tabs>
|
|
93
|
+
</>
|
|
94
|
+
),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const WithScrolling: Story = {
|
|
98
|
+
args: { children: null },
|
|
99
|
+
render: () => (
|
|
100
|
+
<Tabs defaultValue="one">
|
|
101
|
+
<TabsList>
|
|
102
|
+
<Tab value="one">One</Tab>
|
|
103
|
+
<Tab value="two">Two</Tab>
|
|
104
|
+
<Tab value="three">Three</Tab>
|
|
105
|
+
<Tab value="four">Four</Tab>
|
|
106
|
+
<Tab value="five">Five</Tab>
|
|
107
|
+
<Tab value="six">Six</Tab>
|
|
108
|
+
<Tab value="seven">Seven</Tab>
|
|
109
|
+
<Tab value="eight">Eight</Tab>
|
|
110
|
+
<Tab value="nine">Nine</Tab>
|
|
111
|
+
<Tab value="ten">Ten</Tab>
|
|
112
|
+
<Tab value="eleven">Eleven</Tab>
|
|
113
|
+
<Tab value="twelve">Twelve</Tab>
|
|
114
|
+
<Tab value="thirteen">Thirteen</Tab>
|
|
115
|
+
<Tab value="fourteen">Fourteen</Tab>
|
|
116
|
+
<Tab value="fifteen">Fifteen</Tab>
|
|
117
|
+
<Tab value="sixteen">Sixteen</Tab>
|
|
118
|
+
<Tab value="seventeen">Seventeen</Tab>
|
|
119
|
+
<Tab value="eighteen">Eighteen</Tab>
|
|
120
|
+
<Tab value="nineteen">Nineteen</Tab>
|
|
121
|
+
<Tab value="twenty">Twenty</Tab>
|
|
122
|
+
</TabsList>
|
|
123
|
+
<TabPanel value="one">
|
|
124
|
+
<BodyText>One panel</BodyText>
|
|
125
|
+
</TabPanel>
|
|
126
|
+
<TabPanel value="two">
|
|
127
|
+
<BodyText>Two panel</BodyText>
|
|
128
|
+
</TabPanel>
|
|
129
|
+
<TabPanel value="three">
|
|
130
|
+
<BodyText>Three panel</BodyText>
|
|
131
|
+
</TabPanel>
|
|
132
|
+
<TabPanel value="four">
|
|
133
|
+
<BodyText>Four panel</BodyText>
|
|
134
|
+
</TabPanel>
|
|
135
|
+
<TabPanel value="five">
|
|
136
|
+
<BodyText>Five panel</BodyText>
|
|
137
|
+
</TabPanel>
|
|
138
|
+
<TabPanel value="six">
|
|
139
|
+
<BodyText>Six panel</BodyText>
|
|
140
|
+
</TabPanel>
|
|
141
|
+
<TabPanel value="seven">
|
|
142
|
+
<BodyText>Seven panel</BodyText>
|
|
143
|
+
</TabPanel>
|
|
144
|
+
<TabPanel value="eight">
|
|
145
|
+
<BodyText>Eight panel</BodyText>
|
|
146
|
+
</TabPanel>
|
|
147
|
+
<TabPanel value="nine">
|
|
148
|
+
<BodyText>Nine panel</BodyText>
|
|
149
|
+
</TabPanel>
|
|
150
|
+
<TabPanel value="ten">
|
|
151
|
+
<BodyText>Ten panel</BodyText>
|
|
152
|
+
</TabPanel>
|
|
153
|
+
<TabPanel value="eleven">
|
|
154
|
+
<BodyText>Eleven panel</BodyText>
|
|
155
|
+
</TabPanel>
|
|
156
|
+
<TabPanel value="twelve">
|
|
157
|
+
<BodyText>Twelve panel</BodyText>
|
|
158
|
+
</TabPanel>
|
|
159
|
+
<TabPanel value="thirteen">
|
|
160
|
+
<BodyText>Thirteen panel</BodyText>
|
|
161
|
+
</TabPanel>
|
|
162
|
+
<TabPanel value="fourteen">
|
|
163
|
+
<BodyText>Fourteen panel</BodyText>
|
|
164
|
+
</TabPanel>
|
|
165
|
+
<TabPanel value="fifteen">
|
|
166
|
+
<BodyText>Fifteen panel</BodyText>
|
|
167
|
+
</TabPanel>
|
|
168
|
+
<TabPanel value="sixteen">
|
|
169
|
+
<BodyText>Sixteen panel</BodyText>
|
|
170
|
+
</TabPanel>
|
|
171
|
+
<TabPanel value="seventeen">
|
|
172
|
+
<BodyText>Seventeen panel</BodyText>
|
|
173
|
+
</TabPanel>
|
|
174
|
+
<TabPanel value="eighteen">
|
|
175
|
+
<BodyText>Eighteen panel</BodyText>
|
|
176
|
+
</TabPanel>
|
|
177
|
+
<TabPanel value="nineteen">
|
|
178
|
+
<BodyText>Nineteen panel</BodyText>
|
|
179
|
+
</TabPanel>
|
|
180
|
+
<TabPanel value="twenty">
|
|
181
|
+
<BodyText>Twenty panel</BodyText>
|
|
182
|
+
</TabPanel>
|
|
183
|
+
</Tabs>
|
|
184
|
+
),
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const WithIcons: Story = {
|
|
188
|
+
args: { children: null },
|
|
189
|
+
render: () => (
|
|
190
|
+
<Tabs defaultValue="one">
|
|
191
|
+
<TabsList>
|
|
192
|
+
<Tab value="one" icon={ElectricityMediumIcon}>
|
|
193
|
+
Energy
|
|
194
|
+
</Tab>
|
|
195
|
+
<Tab value="two" icon={BroadbandMediumIcon}>
|
|
196
|
+
Broadband
|
|
197
|
+
</Tab>
|
|
198
|
+
<Tab value="three" icon={MobileMediumIcon}>
|
|
199
|
+
Mobile
|
|
200
|
+
</Tab>
|
|
201
|
+
<Tab value="four" icon={InsuranceMediumIcon}>
|
|
202
|
+
Insurance
|
|
203
|
+
</Tab>
|
|
204
|
+
</TabsList>
|
|
205
|
+
<TabPanel value="one">
|
|
206
|
+
<BodyText>One panel</BodyText>
|
|
207
|
+
</TabPanel>
|
|
208
|
+
<TabPanel value="two">
|
|
209
|
+
<BodyText>Two panel</BodyText>
|
|
210
|
+
</TabPanel>
|
|
211
|
+
<TabPanel value="three">
|
|
212
|
+
<BodyText>Three panel</BodyText>
|
|
213
|
+
</TabPanel>
|
|
214
|
+
<TabPanel value="four">
|
|
215
|
+
<BodyText>Four panel</BodyText>
|
|
216
|
+
</TabPanel>
|
|
217
|
+
</Tabs>
|
|
218
|
+
),
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export const Disabled: Story = {
|
|
222
|
+
args: { children: null },
|
|
223
|
+
render: () => (
|
|
224
|
+
<Tabs defaultValue="one" disabled>
|
|
225
|
+
<TabsList>
|
|
226
|
+
<Tab value="one">One</Tab>
|
|
227
|
+
<Tab value="two">Two</Tab>
|
|
228
|
+
<Tab value="three">Three</Tab>
|
|
229
|
+
</TabsList>
|
|
230
|
+
<TabPanel value="one">One panel</TabPanel>
|
|
231
|
+
<TabPanel value="two">Two panel</TabPanel>
|
|
232
|
+
<TabPanel value="three">Three panel</TabPanel>
|
|
233
|
+
</Tabs>
|
|
234
|
+
),
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export const Controlled: Story = {
|
|
238
|
+
args: { children: null },
|
|
239
|
+
render: () => {
|
|
240
|
+
const [value, setValue] = useState('account');
|
|
241
|
+
const nextTab = () => {
|
|
242
|
+
const tabs = ['account', 'billing', 'usage'];
|
|
243
|
+
const currentIndex = tabs.indexOf(value);
|
|
244
|
+
const nextIndex = (currentIndex + 1) % tabs.length;
|
|
245
|
+
setValue(tabs[nextIndex]);
|
|
246
|
+
};
|
|
247
|
+
return (
|
|
248
|
+
<Flex align={Platform.OS === 'web' ? 'flex-start' : 'stretch'} space="lg">
|
|
249
|
+
<Tabs value={value}>
|
|
250
|
+
<TabsList>
|
|
251
|
+
<Tab value="account">Account</Tab>
|
|
252
|
+
<Tab value="billing">Billing</Tab>
|
|
253
|
+
<Tab value="usage">Usage</Tab>
|
|
254
|
+
</TabsList>
|
|
255
|
+
<TabPanel value="account">
|
|
256
|
+
<BodyText>Account content</BodyText>
|
|
257
|
+
</TabPanel>
|
|
258
|
+
<TabPanel value="billing">
|
|
259
|
+
<BodyText>Billing content</BodyText>
|
|
260
|
+
</TabPanel>
|
|
261
|
+
<TabPanel value="usage">
|
|
262
|
+
<BodyText>Usage metrics content</BodyText>
|
|
263
|
+
</TabPanel>
|
|
264
|
+
</Tabs>
|
|
265
|
+
|
|
266
|
+
<Button onPress={nextTab}>Next Tab</Button>
|
|
267
|
+
</Flex>
|
|
268
|
+
);
|
|
269
|
+
},
|
|
270
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Children, isValidElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Easing, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
4
|
+
import { TabsContext } from './Tabs.context';
|
|
5
|
+
import type TabsProps from './Tabs.props';
|
|
6
|
+
|
|
7
|
+
const Tabs = ({
|
|
8
|
+
value: controlledValue,
|
|
9
|
+
defaultValue,
|
|
10
|
+
onValueChange,
|
|
11
|
+
size = 'md',
|
|
12
|
+
disabled,
|
|
13
|
+
children,
|
|
14
|
+
withPanels,
|
|
15
|
+
...props
|
|
16
|
+
}: TabsProps) => {
|
|
17
|
+
// Collect child tab values
|
|
18
|
+
const tabValues = useMemo(() => {
|
|
19
|
+
const vals: string[] = [];
|
|
20
|
+
const walk = (node: any) => {
|
|
21
|
+
Children.forEach(node, child => {
|
|
22
|
+
if (!isValidElement(child)) return;
|
|
23
|
+
const props: any = child.props;
|
|
24
|
+
const type: any = child.type;
|
|
25
|
+
if (type?.displayName === 'Tab' && typeof props?.value === 'string') {
|
|
26
|
+
vals.push(props.value);
|
|
27
|
+
}
|
|
28
|
+
if (props?.children) walk(props.children);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
walk(children);
|
|
32
|
+
return vals;
|
|
33
|
+
}, [children]);
|
|
34
|
+
|
|
35
|
+
const getInitial = () => {
|
|
36
|
+
if (controlledValue !== undefined) return controlledValue;
|
|
37
|
+
if (defaultValue) return defaultValue;
|
|
38
|
+
return tabValues[0];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const [uncontrolled, setUncontrolled] = useState<string | undefined>(getInitial);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (controlledValue !== undefined) setUncontrolled(controlledValue);
|
|
45
|
+
}, [controlledValue]);
|
|
46
|
+
|
|
47
|
+
// Ensure value remains valid if tabs change
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
setUncontrolled(prev => {
|
|
50
|
+
if (!prev) return tabValues[0];
|
|
51
|
+
if (!tabValues.includes(prev)) return tabValues[0];
|
|
52
|
+
return prev;
|
|
53
|
+
});
|
|
54
|
+
}, [tabValues.join('|')]);
|
|
55
|
+
|
|
56
|
+
const currentValue = controlledValue !== undefined ? controlledValue : uncontrolled;
|
|
57
|
+
|
|
58
|
+
const select = useCallback(
|
|
59
|
+
(val: string) => {
|
|
60
|
+
if (disabled) return;
|
|
61
|
+
if (controlledValue === undefined) setUncontrolled(val);
|
|
62
|
+
onValueChange?.(val);
|
|
63
|
+
},
|
|
64
|
+
[controlledValue, disabled, onValueChange]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// Indicator shared values (declared early so registerTabLayout can reference)
|
|
68
|
+
const indicatorX = useSharedValue(0);
|
|
69
|
+
const indicatorSize = useSharedValue(0);
|
|
70
|
+
|
|
71
|
+
// Layout registry for animated indicator
|
|
72
|
+
const layoutsRef = useRef<Map<string, { x: number; y: number; width: number; height: number }>>(
|
|
73
|
+
new Map()
|
|
74
|
+
);
|
|
75
|
+
const prevValueRef = useRef<string | undefined>(undefined);
|
|
76
|
+
const initialisedRef = useRef(false);
|
|
77
|
+
const registerTabLayout = useCallback(
|
|
78
|
+
(value: string, layout: { x: number; y: number; width: number; height: number }) => {
|
|
79
|
+
layoutsRef.current.set(value, layout);
|
|
80
|
+
const active = controlledValue !== undefined ? controlledValue : uncontrolled;
|
|
81
|
+
if (!active) return;
|
|
82
|
+
// Initial active tab: seed indicator & prevValue so first change animates
|
|
83
|
+
if (!initialisedRef.current && value === active) {
|
|
84
|
+
indicatorX.value = layout.x;
|
|
85
|
+
indicatorSize.value = layout.width;
|
|
86
|
+
prevValueRef.current = active;
|
|
87
|
+
initialisedRef.current = true;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
[controlledValue, uncontrolled, indicatorX, indicatorSize]
|
|
91
|
+
);
|
|
92
|
+
const getTabLayout = useCallback((v: string) => layoutsRef.current.get(v), []);
|
|
93
|
+
|
|
94
|
+
const contextValue = useMemo(
|
|
95
|
+
() => ({
|
|
96
|
+
value: currentValue,
|
|
97
|
+
size,
|
|
98
|
+
select,
|
|
99
|
+
disabled,
|
|
100
|
+
registerTabLayout,
|
|
101
|
+
getTabLayout,
|
|
102
|
+
indicatorXSV: indicatorX,
|
|
103
|
+
indicatorSizeSV: indicatorSize,
|
|
104
|
+
}),
|
|
105
|
+
[
|
|
106
|
+
currentValue,
|
|
107
|
+
size,
|
|
108
|
+
select,
|
|
109
|
+
disabled,
|
|
110
|
+
registerTabLayout,
|
|
111
|
+
getTabLayout,
|
|
112
|
+
tabValues,
|
|
113
|
+
indicatorX,
|
|
114
|
+
indicatorSize,
|
|
115
|
+
]
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// Animate indicator only on value changes after initialisation
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (!currentValue || !initialisedRef.current) return;
|
|
121
|
+
if (prevValueRef.current === undefined || prevValueRef.current === currentValue) return;
|
|
122
|
+
const layout = getTabLayout(currentValue);
|
|
123
|
+
if (!layout) return;
|
|
124
|
+
const cfg = { duration: 250, easing: Easing.out(Easing.ease) } as const;
|
|
125
|
+
indicatorX.value = withTiming(layout.x, cfg);
|
|
126
|
+
indicatorSize.value = withTiming(layout.width, cfg);
|
|
127
|
+
prevValueRef.current = currentValue;
|
|
128
|
+
}, [currentValue, getTabLayout, indicatorX, indicatorSize, tabValues.join('|')]);
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<TabsContext.Provider value={contextValue}>
|
|
132
|
+
<View {...props}>{children}</View>
|
|
133
|
+
</TabsContext.Provider>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
Tabs.displayName = 'Tabs';
|
|
138
|
+
|
|
139
|
+
export default Tabs;
|