@telus-uds/components-base 1.1.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -0
- package/CHANGELOG.json +38 -0
- package/CHANGELOG.md +35 -2
- package/__fixtures__/Accessible.js +4 -2
- package/__fixtures__/Accessible.native.js +5 -2
- package/__fixtures__/testTheme.js +9 -0
- package/__tests__/ActivityIndicator/ActivityIndicator.test.jsx +35 -0
- package/__tests__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +287 -0
- package/__tests__/FlexGrid/Col.test.jsx +6 -10
- package/__tests__/HorizontalScroll/HorizontalScroll.test.jsx +1 -0
- package/__tests__/ToggleSwitch/ToggleSwitch.test.jsx +10 -0
- package/__tests__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
- package/__tests__/utils/props.test.js +36 -0
- package/__tests__/utils/semantics.test.jsx +1 -10
- package/babel.config.js +27 -5
- package/component-docs.json +638 -1145
- package/generate-component-docs.js +3 -0
- package/lib/A11yText/index.js +6 -5
- package/lib/ActivityIndicator/Spinner.js +46 -37
- package/lib/ActivityIndicator/Spinner.native.js +26 -15
- package/lib/ActivityIndicator/index.js +3 -3
- package/lib/Box/Box.js +8 -8
- package/lib/Button/Button.js +2 -2
- package/lib/Button/ButtonBase.js +25 -12
- package/lib/Button/ButtonGroup.js +10 -12
- package/lib/Button/ButtonLink.js +4 -4
- package/lib/Button/propTypes.js +4 -2
- package/lib/Card/Card.js +6 -5
- package/lib/Card/CardBase.js +6 -9
- package/lib/Card/PressableCardBase.js +15 -14
- package/lib/Checkbox/Checkbox.js +4 -8
- package/lib/Divider/Divider.js +14 -13
- package/lib/ExpandCollapse/Control.js +7 -7
- package/lib/ExpandCollapse/ExpandCollapse.js +6 -2
- package/lib/ExpandCollapse/Panel.js +6 -7
- package/lib/Feedback/Feedback.js +6 -5
- package/lib/Fieldset/Fieldset.js +1 -3
- package/lib/FlexGrid/FlexGrid.js +4 -4
- package/lib/FlexGrid/helpers/index.js +1 -4
- package/lib/HorizontalScroll/HorizontalScroll.js +5 -6
- package/lib/IconButton/IconButton.js +14 -9
- package/lib/InputLabel/InputLabel.js +7 -2
- package/lib/InputSupports/InputSupports.js +2 -2
- package/lib/Link/LinkBase.js +21 -15
- package/lib/List/List.js +4 -6
- package/lib/List/ListItem.js +6 -2
- package/lib/Modal/Modal.js +6 -2
- package/lib/Notification/Notification.js +7 -2
- package/lib/Pagination/PageButton.js +3 -1
- package/lib/Pagination/Pagination.js +22 -5
- package/lib/Pagination/SideButton.js +3 -1
- package/lib/Progress/Progress.js +5 -4
- package/lib/Progress/ProgressBar.js +8 -7
- package/lib/Radio/Radio.js +4 -8
- package/lib/Radio/RadioButton.js +6 -3
- package/lib/Radio/RadioGroup.js +7 -2
- package/lib/RadioCard/RadioCard.js +4 -4
- package/lib/RadioCard/RadioCardGroup.js +9 -6
- package/lib/Search/Search.js +7 -2
- package/lib/Select/Select.js +10 -9
- package/lib/SideNav/Item.js +7 -7
- package/lib/SideNav/SideNav.js +7 -3
- package/lib/Skeleton/Skeleton.js +6 -2
- package/lib/Spacer/Spacer.js +9 -20
- package/lib/StackView/StackView.js +7 -7
- package/lib/StackView/StackWrapBox.js +6 -7
- package/lib/StackView/StackWrapGap.js +6 -5
- package/lib/StackView/getStackedContent.js +1 -1
- package/lib/StepTracker/Step.js +7 -3
- package/lib/StepTracker/StepTracker.js +7 -7
- package/lib/Tabs/Tabs.js +16 -4
- package/lib/Tabs/TabsItem.js +18 -11
- package/lib/Tags/Tags.js +11 -12
- package/lib/TextInput/TextArea.js +13 -14
- package/lib/TextInput/TextInput.js +13 -14
- package/lib/TextInput/TextInputBase.js +5 -3
- package/lib/ThemeProvider/useThemeTokens.js +3 -3
- package/lib/ThemeProvider/utils/theme-tokens.js +3 -3
- package/lib/ToggleSwitch/ToggleSwitch.js +106 -43
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +228 -0
- package/lib/ToggleSwitch/index.js +14 -4
- package/lib/Tooltip/Tooltip.js +7 -2
- package/lib/TooltipButton/TooltipButton.js +7 -2
- package/lib/Typography/Typography.js +8 -6
- package/lib/index.js +20 -8
- package/lib/utils/a11y/semantics.js +4 -3
- package/lib/utils/children.js +5 -1
- package/lib/utils/index.js +28 -5
- package/lib/utils/pressability.js +2 -2
- package/lib/utils/props/a11yProps.js +153 -0
- package/lib/utils/props/clickProps.js +36 -0
- package/lib/utils/props/componentPropType.js +70 -0
- package/lib/utils/props/copyPropTypes.js +14 -0
- package/lib/utils/props/getPropSelector.js +13 -0
- package/lib/utils/props/hrefAttrsProp.js +41 -0
- package/lib/utils/props/index.js +158 -0
- package/lib/{InputSupports/propTypes.js → utils/props/inputSupportsProps.js} +2 -3
- package/lib/utils/props/linkProps.js +64 -0
- package/lib/utils/props/paddingProp.js +20 -0
- package/lib/utils/props/pressProps.js +57 -0
- package/lib/utils/props/rectProp.js +20 -0
- package/lib/utils/props/responsiveProps.js +40 -0
- package/lib/utils/props/selectSystemProps.js +31 -0
- package/lib/utils/props/spacingProps.js +71 -0
- package/lib/utils/props/tokens.js +145 -0
- package/lib/utils/props/variantProp.js +28 -0
- package/lib/utils/props/viewProps.js +34 -0
- package/lib/utils/ssr.js +51 -0
- package/lib/utils/useResponsiveProp.js +1 -1
- package/lib/utils/useSpacingScale.js +4 -4
- package/lib/utils/withLinkRouter.js +98 -0
- package/lib-module/A11yInfoProvider/index.js +62 -0
- package/lib-module/A11yText/index.js +55 -0
- package/lib-module/ActivityIndicator/Spinner.js +76 -0
- package/lib-module/ActivityIndicator/Spinner.native.js +143 -0
- package/lib-module/ActivityIndicator/index.js +40 -0
- package/lib-module/ActivityIndicator/shared.js +12 -0
- package/lib-module/BaseProvider/index.js +26 -0
- package/lib-module/Box/Box.js +243 -0
- package/lib-module/Box/index.js +2 -0
- package/lib-module/Button/Button.js +25 -0
- package/lib-module/Button/ButtonBase.js +254 -0
- package/lib-module/Button/ButtonGroup.js +164 -0
- package/lib-module/Button/ButtonLink.js +39 -0
- package/lib-module/Button/index.js +4 -0
- package/lib-module/Button/propTypes.js +36 -0
- package/lib-module/Card/Card.js +83 -0
- package/lib-module/Card/CardBase.js +62 -0
- package/lib-module/Card/PressableCardBase.js +113 -0
- package/lib-module/Card/index.js +4 -0
- package/lib-module/Checkbox/Checkbox.js +321 -0
- package/lib-module/Checkbox/CheckboxGroup.js +218 -0
- package/lib-module/Checkbox/CheckboxInput.js +58 -0
- package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
- package/lib-module/Checkbox/index.js +3 -0
- package/lib-module/Divider/Divider.js +123 -0
- package/lib-module/Divider/index.js +2 -0
- package/lib-module/ExpandCollapse/Accordion.js +15 -0
- package/lib-module/ExpandCollapse/Control.js +130 -0
- package/lib-module/ExpandCollapse/ExpandCollapse.js +94 -0
- package/lib-module/ExpandCollapse/Panel.js +158 -0
- package/lib-module/ExpandCollapse/index.js +7 -0
- package/lib-module/Feedback/Feedback.js +144 -0
- package/lib-module/Feedback/index.js +2 -0
- package/lib-module/Fieldset/Fieldset.js +145 -0
- package/lib-module/Fieldset/FieldsetContainer.js +29 -0
- package/lib-module/Fieldset/FieldsetContainer.native.js +20 -0
- package/lib-module/Fieldset/Legend.js +21 -0
- package/lib-module/Fieldset/Legend.native.js +28 -0
- package/lib-module/Fieldset/cssReset.js +14 -0
- package/lib-module/Fieldset/index.js +2 -0
- package/lib-module/FlexGrid/Col/Col.js +265 -0
- package/lib-module/FlexGrid/Col/index.js +2 -0
- package/lib-module/FlexGrid/FlexGrid.js +147 -0
- package/lib-module/FlexGrid/Row/Row.js +177 -0
- package/lib-module/FlexGrid/Row/index.js +2 -0
- package/lib-module/FlexGrid/helpers/index.js +18 -0
- package/lib-module/FlexGrid/index.js +2 -0
- package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
- package/lib-module/HorizontalScroll/HorizontalScroll.js +171 -0
- package/lib-module/HorizontalScroll/HorizontalScrollButton.js +102 -0
- package/lib-module/HorizontalScroll/ScrollViewEnd.js +47 -0
- package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +24 -0
- package/lib-module/HorizontalScroll/dictionary.js +11 -0
- package/lib-module/HorizontalScroll/index.js +11 -0
- package/lib-module/HorizontalScroll/itemPositions.js +106 -0
- package/lib-module/Icon/Icon.js +61 -0
- package/lib-module/Icon/IconText.js +81 -0
- package/lib-module/Icon/index.js +4 -0
- package/lib-module/IconButton/IconButton.js +115 -0
- package/lib-module/IconButton/index.js +2 -0
- package/lib-module/InputLabel/InputLabel.js +131 -0
- package/lib-module/InputLabel/LabelContent.js +24 -0
- package/lib-module/InputLabel/LabelContent.native.js +16 -0
- package/lib-module/InputLabel/index.js +2 -0
- package/lib-module/InputSupports/InputSupports.js +88 -0
- package/lib-module/InputSupports/index.js +2 -0
- package/lib-module/InputSupports/useInputSupports.js +31 -0
- package/lib-module/Link/ChevronLink.js +51 -0
- package/lib-module/Link/InlinePressable.js +37 -0
- package/lib-module/Link/InlinePressable.native.js +85 -0
- package/lib-module/Link/Link.js +27 -0
- package/lib-module/Link/LinkBase.js +210 -0
- package/lib-module/Link/TextButton.js +43 -0
- package/lib-module/Link/index.js +5 -0
- package/lib-module/List/List.js +55 -0
- package/lib-module/List/ListItem.js +213 -0
- package/lib-module/List/index.js +5 -0
- package/lib-module/Modal/Modal.js +208 -0
- package/lib-module/Modal/dictionary.js +9 -0
- package/lib-module/Modal/index.js +2 -0
- package/lib-module/Notification/Notification.js +196 -0
- package/lib-module/Notification/dictionary.js +8 -0
- package/lib-module/Notification/index.js +2 -0
- package/lib-module/Pagination/PageButton.js +65 -0
- package/lib-module/Pagination/Pagination.js +140 -0
- package/lib-module/Pagination/SideButton.js +103 -0
- package/lib-module/Pagination/dictionary.js +18 -0
- package/lib-module/Pagination/index.js +2 -0
- package/lib-module/Pagination/usePagination.js +72 -0
- package/lib-module/Progress/Progress.js +85 -0
- package/lib-module/Progress/ProgressBar.js +134 -0
- package/lib-module/Progress/ProgressBarBackground.js +41 -0
- package/lib-module/Progress/index.js +4 -0
- package/lib-module/Radio/Radio.js +263 -0
- package/lib-module/Radio/RadioButton.js +128 -0
- package/lib-module/Radio/RadioGroup.js +225 -0
- package/lib-module/Radio/RadioInput.js +60 -0
- package/lib-module/Radio/RadioInput.native.js +6 -0
- package/lib-module/Radio/index.js +3 -0
- package/lib-module/RadioCard/RadioCard.js +218 -0
- package/lib-module/RadioCard/RadioCardGroup.js +232 -0
- package/lib-module/RadioCard/index.js +3 -0
- package/lib-module/Search/Search.js +233 -0
- package/lib-module/Search/dictionary.js +12 -0
- package/lib-module/Search/index.js +2 -0
- package/lib-module/Select/Group.js +20 -0
- package/lib-module/Select/Group.native.js +14 -0
- package/lib-module/Select/Item.js +17 -0
- package/lib-module/Select/Item.native.js +9 -0
- package/lib-module/Select/Picker.js +67 -0
- package/lib-module/Select/Picker.native.js +110 -0
- package/lib-module/Select/Select.js +317 -0
- package/lib-module/Select/index.js +6 -0
- package/lib-module/SideNav/Item.js +139 -0
- package/lib-module/SideNav/ItemContent.js +45 -0
- package/lib-module/SideNav/ItemsGroup.js +115 -0
- package/lib-module/SideNav/SideNav.js +133 -0
- package/lib-module/SideNav/index.js +1 -0
- package/lib-module/Skeleton/Skeleton.js +117 -0
- package/lib-module/Skeleton/index.js +2 -0
- package/lib-module/Skeleton/skeleton.constant.js +3 -0
- package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
- package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
- package/lib-module/Spacer/Spacer.js +97 -0
- package/lib-module/Spacer/index.js +2 -0
- package/lib-module/StackView/StackView.js +124 -0
- package/lib-module/StackView/StackWrap.js +48 -0
- package/lib-module/StackView/StackWrap.native.js +3 -0
- package/lib-module/StackView/StackWrapBox.js +114 -0
- package/lib-module/StackView/StackWrapGap.js +58 -0
- package/lib-module/StackView/common.js +32 -0
- package/lib-module/StackView/getStackedContent.js +123 -0
- package/lib-module/StackView/index.js +5 -0
- package/lib-module/StepTracker/Step.js +229 -0
- package/lib-module/StepTracker/StepTracker.js +175 -0
- package/lib-module/StepTracker/dictionary.js +10 -0
- package/lib-module/StepTracker/index.js +2 -0
- package/lib-module/Tabs/Tabs.js +113 -0
- package/lib-module/Tabs/TabsItem.js +215 -0
- package/lib-module/Tabs/index.js +2 -0
- package/lib-module/Tags/Tags.js +238 -0
- package/lib-module/Tags/index.js +2 -0
- package/lib-module/TextInput/TextArea.js +88 -0
- package/lib-module/TextInput/TextInput.js +60 -0
- package/lib-module/TextInput/TextInputBase.js +233 -0
- package/lib-module/TextInput/index.js +3 -0
- package/lib-module/TextInput/propTypes.js +31 -0
- package/lib-module/ThemeProvider/ThemeProvider.js +35 -0
- package/lib-module/ThemeProvider/index.js +6 -0
- package/lib-module/ThemeProvider/useSetTheme.js +22 -0
- package/lib-module/ThemeProvider/useTheme.js +14 -0
- package/lib-module/ThemeProvider/useThemeTokens.js +105 -0
- package/lib-module/ThemeProvider/utils/index.js +2 -0
- package/lib-module/ThemeProvider/utils/styles.js +174 -0
- package/lib-module/ThemeProvider/utils/theme-tokens.js +151 -0
- package/lib-module/ToggleSwitch/ToggleSwitch.js +224 -0
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +202 -0
- package/lib-module/ToggleSwitch/index.js +3 -0
- package/lib-module/Tooltip/Backdrop.js +52 -0
- package/lib-module/Tooltip/Backdrop.native.js +43 -0
- package/lib-module/Tooltip/Tooltip.js +332 -0
- package/lib-module/Tooltip/dictionary.js +8 -0
- package/lib-module/Tooltip/getTooltipPosition.js +164 -0
- package/lib-module/Tooltip/index.js +2 -0
- package/lib-module/TooltipButton/TooltipButton.js +71 -0
- package/lib-module/TooltipButton/index.js +2 -0
- package/lib-module/Typography/Typography.js +118 -0
- package/lib-module/Typography/index.js +2 -0
- package/lib-module/ViewportProvider/ViewportProvider.js +28 -0
- package/lib-module/ViewportProvider/index.js +3 -0
- package/lib-module/ViewportProvider/useViewport.js +3 -0
- package/lib-module/ViewportProvider/useViewportListener.js +43 -0
- package/lib-module/index.js +48 -0
- package/lib-module/utils/a11y/index.js +2 -0
- package/lib-module/utils/a11y/semantics.js +154 -0
- package/lib-module/utils/a11y/textSize.js +34 -0
- package/lib-module/utils/animation/index.js +2 -0
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +49 -0
- package/lib-module/utils/children.js +118 -0
- package/lib-module/utils/index.js +15 -0
- package/lib-module/utils/info/index.js +7 -0
- package/lib-module/utils/info/platform/index.js +11 -0
- package/lib-module/utils/info/platform/platform.android.js +1 -0
- package/lib-module/utils/info/platform/platform.ios.js +1 -0
- package/lib-module/utils/info/platform/platform.js +1 -0
- package/lib-module/utils/info/platform/platform.native.js +4 -0
- package/lib-module/utils/info/versions.js +5 -0
- package/lib-module/utils/input.js +180 -0
- package/lib-module/utils/pressability.js +97 -0
- package/lib-module/utils/props/a11yProps.js +140 -0
- package/lib-module/utils/props/clickProps.js +25 -0
- package/lib-module/utils/props/componentPropType.js +63 -0
- package/lib-module/utils/props/copyPropTypes.js +2 -0
- package/lib-module/utils/props/getPropSelector.js +6 -0
- package/lib-module/utils/props/hrefAttrsProp.js +30 -0
- package/lib-module/utils/props/index.js +16 -0
- package/lib-module/utils/props/inputSupportsProps.js +54 -0
- package/lib-module/utils/props/linkProps.js +47 -0
- package/lib-module/utils/props/paddingProp.js +9 -0
- package/lib-module/utils/props/pressProps.js +42 -0
- package/lib-module/utils/props/rectProp.js +9 -0
- package/lib-module/utils/props/responsiveProps.js +30 -0
- package/lib-module/utils/props/selectSystemProps.js +24 -0
- package/lib-module/utils/props/spacingProps.js +56 -0
- package/lib-module/utils/props/tokens.js +120 -0
- package/lib-module/utils/props/variantProp.js +18 -0
- package/lib-module/utils/props/viewProps.js +22 -0
- package/lib-module/utils/ssr.js +35 -0
- package/lib-module/utils/useCopy.js +42 -0
- package/lib-module/utils/useHash.js +44 -0
- package/lib-module/utils/useHash.native.js +7 -0
- package/lib-module/utils/useResponsiveProp.js +47 -0
- package/lib-module/utils/useSpacingScale.js +123 -0
- package/lib-module/utils/useUniqueId.js +12 -0
- package/lib-module/utils/withLinkRouter.js +82 -0
- package/package.json +9 -5
- package/src/A11yText/index.jsx +7 -3
- package/src/ActivityIndicator/Spinner.jsx +56 -44
- package/src/ActivityIndicator/Spinner.native.jsx +20 -12
- package/src/ActivityIndicator/index.jsx +1 -1
- package/src/Box/Box.jsx +15 -13
- package/src/Button/Button.jsx +1 -1
- package/src/Button/ButtonBase.jsx +20 -12
- package/src/Button/ButtonGroup.jsx +17 -8
- package/src/Button/ButtonLink.jsx +1 -1
- package/src/Button/propTypes.js +2 -1
- package/src/Card/Card.jsx +7 -4
- package/src/Card/CardBase.jsx +6 -5
- package/src/Card/PressableCardBase.jsx +16 -14
- package/src/Checkbox/Checkbox.jsx +12 -7
- package/src/Divider/Divider.jsx +19 -12
- package/src/ExpandCollapse/Control.jsx +12 -7
- package/src/ExpandCollapse/ExpandCollapse.jsx +13 -3
- package/src/ExpandCollapse/Panel.jsx +15 -5
- package/src/Feedback/Feedback.jsx +13 -3
- package/src/Fieldset/Fieldset.jsx +1 -1
- package/src/FlexGrid/FlexGrid.jsx +11 -5
- package/src/FlexGrid/helpers/index.js +1 -3
- package/src/HorizontalScroll/HorizontalScroll.jsx +12 -5
- package/src/IconButton/IconButton.jsx +18 -12
- package/src/InputLabel/InputLabel.jsx +16 -2
- package/src/InputSupports/InputSupports.jsx +1 -1
- package/src/Link/LinkBase.jsx +15 -12
- package/src/List/List.jsx +12 -5
- package/src/List/ListItem.jsx +16 -2
- package/src/Modal/Modal.jsx +63 -50
- package/src/Notification/Notification.jsx +17 -3
- package/src/Pagination/PageButton.jsx +3 -2
- package/src/Pagination/Pagination.jsx +38 -4
- package/src/Pagination/SideButton.jsx +2 -2
- package/src/Progress/Progress.jsx +5 -3
- package/src/Progress/ProgressBar.jsx +8 -6
- package/src/Radio/Radio.jsx +13 -7
- package/src/Radio/RadioButton.jsx +13 -3
- package/src/Radio/RadioGroup.jsx +14 -2
- package/src/RadioCard/RadioCard.jsx +9 -6
- package/src/RadioCard/RadioCardGroup.jsx +16 -4
- package/src/Search/Search.jsx +15 -3
- package/src/Select/Select.jsx +21 -7
- package/src/SideNav/Item.jsx +15 -7
- package/src/SideNav/SideNav.jsx +13 -2
- package/src/Skeleton/Skeleton.jsx +55 -43
- package/src/Spacer/Spacer.jsx +10 -18
- package/src/StackView/StackView.jsx +13 -12
- package/src/StackView/StackWrapBox.jsx +12 -12
- package/src/StackView/StackWrapGap.jsx +9 -7
- package/src/StackView/getStackedContent.jsx +1 -1
- package/src/StepTracker/Step.jsx +7 -4
- package/src/StepTracker/StepTracker.jsx +8 -8
- package/src/Tabs/Tabs.jsx +63 -23
- package/src/Tabs/TabsItem.jsx +22 -14
- package/src/Tags/Tags.jsx +16 -7
- package/src/TextInput/TextArea.jsx +20 -8
- package/src/TextInput/TextInput.jsx +20 -8
- package/src/TextInput/TextInputBase.jsx +13 -3
- package/src/ThemeProvider/useThemeTokens.js +3 -3
- package/src/ThemeProvider/utils/theme-tokens.js +3 -3
- package/src/ToggleSwitch/ToggleSwitch.jsx +104 -41
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +211 -0
- package/src/ToggleSwitch/index.js +2 -1
- package/src/Tooltip/Tooltip.jsx +13 -3
- package/src/TooltipButton/TooltipButton.jsx +6 -4
- package/src/Typography/Typography.jsx +10 -6
- package/src/index.js +2 -2
- package/src/utils/a11y/semantics.js +3 -2
- package/src/utils/children.jsx +2 -1
- package/src/utils/index.js +3 -1
- package/src/utils/pressability.js +1 -1
- package/src/utils/props/a11yProps.js +151 -0
- package/src/utils/props/clickProps.js +31 -0
- package/src/utils/props/componentPropType.js +67 -0
- package/src/utils/props/copyPropTypes.js +3 -0
- package/src/utils/props/getPropSelector.js +14 -0
- package/src/utils/props/hrefAttrsProp.js +25 -0
- package/src/utils/props/index.js +16 -0
- package/src/{InputSupports/propTypes.js → utils/props/inputSupportsProps.js} +2 -4
- package/src/utils/props/linkProps.js +43 -0
- package/src/utils/props/paddingProp.js +10 -0
- package/src/utils/props/pressProps.js +45 -0
- package/src/utils/props/rectProp.js +10 -0
- package/src/utils/props/responsiveProps.js +30 -0
- package/src/utils/props/selectSystemProps.js +25 -0
- package/src/utils/props/spacingProps.js +58 -0
- package/src/utils/props/tokens.js +150 -0
- package/src/utils/props/variantProp.js +20 -0
- package/src/utils/props/viewProps.js +23 -0
- package/src/utils/ssr.js +35 -0
- package/src/utils/useResponsiveProp.js +1 -1
- package/src/utils/useSpacingScale.js +4 -4
- package/src/utils/withLinkRouter.jsx +68 -0
- package/stories/TextInput/TextArea.stories.jsx +1 -0
- package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +5 -1
- package/stories/ToggleSwitch/ToggleSwitchGroup.stories.jsx +81 -0
- package/.ultra.cache.json +0 -1
- package/lib/utils/a11y/propTypes.js +0 -61
- package/lib/utils/a11y/propTypes.native.js +0 -47
- package/lib/utils/propTypes.js +0 -541
- package/release-context.json +0 -7
- package/src/utils/a11y/propTypes.js +0 -61
- package/src/utils/a11y/propTypes.native.js +0 -39
- package/src/utils/propTypes.js +0 -531
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
6
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
7
|
+
import Spacer from '../Spacer';
|
|
8
|
+
import { a11yProps, getTokensPropType, selectSystemProps, spacingProps, variantProp, viewProps } from '../utils';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {import('../utils/props/spacingProps.js').SpacingIndex} SpacingIndex
|
|
15
|
+
* @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A basic divider component, horizontal by default. Color and thickness can be controlled by theme.
|
|
20
|
+
* Divider is based on the flexbox model and uses `alignSelf: flex` to span its flex parent.
|
|
21
|
+
*
|
|
22
|
+
* ## Vertical
|
|
23
|
+
*
|
|
24
|
+
* Vertical dividers can be created by passing a `vertical` boolean prop.
|
|
25
|
+
* Note that for a vertical divider the parent flex element **must** have flex direction set to row.
|
|
26
|
+
* This is the default for web but not for React Native.
|
|
27
|
+
*
|
|
28
|
+
* In a flexbox row, vertical dividers will automatically size to their parent height.
|
|
29
|
+
*
|
|
30
|
+
* ## Space
|
|
31
|
+
*
|
|
32
|
+
* Use this to create **space either side of the divider**. For simple cases, pass a number referring to
|
|
33
|
+
* a position on the theme's spacing scale; for example, this will put a Spacer of the smallest supported
|
|
34
|
+
* size either side of the divider:
|
|
35
|
+
*
|
|
36
|
+
* ```jsx
|
|
37
|
+
* <Divider space={1} />
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* `space` prop uses `useSpacingScale` and may accept a {@link SpacingObject} or a {@link SpacingIndex} number.
|
|
41
|
+
*
|
|
42
|
+
* To **reduce the length of a divider** as well as creating space between it and its neighbours, wrap it in
|
|
43
|
+
* a `Box` component. For example, this will have the second-smallest theme-supported spacing value between
|
|
44
|
+
* the dividing line and its neighbours, and will shorten the line at either end by the same amount:
|
|
45
|
+
*
|
|
46
|
+
* ```jsx
|
|
47
|
+
* <Box space={2}><Divider /></Box>
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* ## Accessibility
|
|
51
|
+
*
|
|
52
|
+
* For accessibility purposes a divider component will be described with ARIA attributes, i.e. `role="separator"` and `aria-orientation="vertical/horizontal"`.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
const Divider = /*#__PURE__*/forwardRef(({
|
|
56
|
+
variant,
|
|
57
|
+
vertical = false,
|
|
58
|
+
space,
|
|
59
|
+
tokens,
|
|
60
|
+
...rest
|
|
61
|
+
}, ref) => {
|
|
62
|
+
const {
|
|
63
|
+
color,
|
|
64
|
+
width
|
|
65
|
+
} = useThemeTokens('Divider', tokens, variant);
|
|
66
|
+
const borderStyles = vertical ? {
|
|
67
|
+
borderRightColor: color,
|
|
68
|
+
borderRightWidth: width
|
|
69
|
+
} : {
|
|
70
|
+
borderBottomColor: color,
|
|
71
|
+
borderBottomWidth: width
|
|
72
|
+
};
|
|
73
|
+
const a11y = Platform.OS === 'web' ? // There are aria attributes for dividers on web
|
|
74
|
+
{
|
|
75
|
+
'aria-orientation': vertical ? 'vertical' : 'horizontal',
|
|
76
|
+
accessibilityRole: 'separator'
|
|
77
|
+
} : // There are no such equivalent attributes for native
|
|
78
|
+
{};
|
|
79
|
+
const {
|
|
80
|
+
testID,
|
|
81
|
+
...selectedProps
|
|
82
|
+
} = selectProps({ ...a11y,
|
|
83
|
+
...rest
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const divider = /*#__PURE__*/_jsx(View, {
|
|
87
|
+
ref: ref,
|
|
88
|
+
style: [styles.divider, borderStyles],
|
|
89
|
+
testID: testID,
|
|
90
|
+
...selectedProps
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (!space) return divider;
|
|
94
|
+
const spacerProps = {
|
|
95
|
+
space,
|
|
96
|
+
direction: vertical ? 'row' : 'column'
|
|
97
|
+
};
|
|
98
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
99
|
+
children: [/*#__PURE__*/_jsx(Spacer, { ...spacerProps,
|
|
100
|
+
testID: testID ? `${testID}-Spacer-before` : undefined
|
|
101
|
+
}), divider, /*#__PURE__*/_jsx(Spacer, { ...spacerProps,
|
|
102
|
+
testID: testID ? `${testID}-Spacer-after` : undefined
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
Divider.displayName = 'Divider';
|
|
107
|
+
Divider.propTypes = { ...selectedSystemPropTypes,
|
|
108
|
+
tokens: getTokensPropType('Divider'),
|
|
109
|
+
space: spacingProps.types.spacingValue,
|
|
110
|
+
variant: variantProp.propType,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* By default, the divider is a horizontal line the full width of its parent.
|
|
114
|
+
* With `vertical` prop and when inside a container with { flexDirection: row }, draws a full height vertical line.
|
|
115
|
+
*/
|
|
116
|
+
vertical: PropTypes.bool
|
|
117
|
+
};
|
|
118
|
+
const styles = StyleSheet.create({
|
|
119
|
+
divider: {
|
|
120
|
+
alignSelf: 'stretch'
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
export default Divider;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import ExpandCollapse from './ExpandCollapse';
|
|
3
|
+
/**
|
|
4
|
+
* 'Accordion' is a shorthand for an ExpandCollapse where only one item may be open at a time
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const Accordion = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/_jsx(ExpandCollapse, {
|
|
9
|
+
ref: ref,
|
|
10
|
+
...props,
|
|
11
|
+
maxOpen: 1
|
|
12
|
+
}));
|
|
13
|
+
Accordion.displayName = 'Accordion';
|
|
14
|
+
Accordion.propTypes = ExpandCollapse.propTypes;
|
|
15
|
+
export default Accordion;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { useThemeTokensCallback, verticalAlignRow } from '../ThemeProvider';
|
|
6
|
+
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
11
|
+
|
|
12
|
+
function selectContainerStyles({
|
|
13
|
+
backgroundColor,
|
|
14
|
+
borderColor,
|
|
15
|
+
borderWidth,
|
|
16
|
+
borderStyle,
|
|
17
|
+
paddingLeft,
|
|
18
|
+
paddingRight,
|
|
19
|
+
paddingTop,
|
|
20
|
+
paddingBottom,
|
|
21
|
+
justifyContent,
|
|
22
|
+
verticalAlign,
|
|
23
|
+
iconPosition
|
|
24
|
+
}) {
|
|
25
|
+
return {
|
|
26
|
+
backgroundColor,
|
|
27
|
+
borderTopColor: borderColor,
|
|
28
|
+
borderTopWidth: borderWidth,
|
|
29
|
+
borderTopStyle: borderStyle,
|
|
30
|
+
paddingLeft,
|
|
31
|
+
paddingRight,
|
|
32
|
+
paddingTop,
|
|
33
|
+
paddingBottom,
|
|
34
|
+
justifyContent,
|
|
35
|
+
...verticalAlignRow(verticalAlign, iconPosition === 'right')
|
|
36
|
+
};
|
|
37
|
+
} // TODO: use stack / spacer when available
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function selectIconContainerStyles({
|
|
41
|
+
iconGap,
|
|
42
|
+
iconPosition
|
|
43
|
+
}) {
|
|
44
|
+
const paddingSide = iconPosition === 'right' ? 'paddingLeft' : 'paddingRight';
|
|
45
|
+
return {
|
|
46
|
+
[paddingSide]: iconGap
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function selectIconTokens(tokens) {
|
|
51
|
+
return {
|
|
52
|
+
color: tokens.iconColor,
|
|
53
|
+
size: tokens.iconSize
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const ExpandCollapseControl = /*#__PURE__*/forwardRef(({
|
|
58
|
+
onPress,
|
|
59
|
+
isExpanded,
|
|
60
|
+
children,
|
|
61
|
+
tokens,
|
|
62
|
+
accessibilityRole = 'button',
|
|
63
|
+
variant,
|
|
64
|
+
...rest
|
|
65
|
+
}, ref) => {
|
|
66
|
+
const getTokens = useThemeTokensCallback('ExpandCollapseControl', tokens, variant);
|
|
67
|
+
const selectedProps = selectProps({ ...rest,
|
|
68
|
+
accessibilityRole
|
|
69
|
+
});
|
|
70
|
+
selectedProps.accessibilityState = { ...(selectedProps.accessibilityState || {}),
|
|
71
|
+
expanded: isExpanded
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const getControlState = ({
|
|
75
|
+
pressed,
|
|
76
|
+
hovered,
|
|
77
|
+
focused
|
|
78
|
+
}) => ({
|
|
79
|
+
pressed,
|
|
80
|
+
hover: hovered,
|
|
81
|
+
focus: focused,
|
|
82
|
+
expanded: isExpanded
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const getControlTokens = pressableState => getTokens(getControlState(pressableState));
|
|
86
|
+
|
|
87
|
+
const getPressableStyle = pressableState => selectContainerStyles(getControlTokens(pressableState));
|
|
88
|
+
|
|
89
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
90
|
+
ref: ref,
|
|
91
|
+
...selectedProps,
|
|
92
|
+
onPress: onPress,
|
|
93
|
+
style: getPressableStyle,
|
|
94
|
+
children: pressableState => {
|
|
95
|
+
const {
|
|
96
|
+
icon: IconComponent,
|
|
97
|
+
...themeTokens
|
|
98
|
+
} = getControlTokens(pressableState);
|
|
99
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
100
|
+
children: [IconComponent && /*#__PURE__*/_jsx(View, {
|
|
101
|
+
style: selectIconContainerStyles(themeTokens),
|
|
102
|
+
children: /*#__PURE__*/_jsx(IconComponent, { ...selectIconTokens(themeTokens)
|
|
103
|
+
})
|
|
104
|
+
}), typeof children === 'function' ? children(getControlState(pressableState)) : children]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
ExpandCollapseControl.displayName = 'ExpandCollapseControl';
|
|
110
|
+
ExpandCollapseControl.propTypes = { ...selectedSystemPropTypes,
|
|
111
|
+
tokens: getTokensPropType('ExpandCollapseControl'),
|
|
112
|
+
variant: variantProp.propType,
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* ExpandCollapseControl's children are the content within the button that opens or closes this panel. May
|
|
116
|
+
* accept a render function that recieves the control state: { pressed, hover, focus, expanded }
|
|
117
|
+
*/
|
|
118
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Whether the linked ExpandCollapsePanel is opened or closed. Allows themes to set `expanded` styles.
|
|
122
|
+
*/
|
|
123
|
+
isExpanded: PropTypes.bool,
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Function called when the ExpandCollapse is pressed.
|
|
127
|
+
*/
|
|
128
|
+
onPress: PropTypes.func.isRequired
|
|
129
|
+
};
|
|
130
|
+
export default ExpandCollapseControl;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import View from "react-native-web/dist/exports/View";
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
5
|
+
import { a11yProps, getTokensPropType, selectSystemProps, useMultipleInputValues, variantProp, viewProps } from '../utils';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
8
|
+
|
|
9
|
+
function selectBorderStyles(tokens) {
|
|
10
|
+
return {
|
|
11
|
+
borderBottomWidth: tokens.borderWidth,
|
|
12
|
+
borderBottomStyle: tokens.borderStyle,
|
|
13
|
+
borderBottomColor: tokens.borderColor
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Flexible base component for lists where some or all items are collapsible headers.
|
|
18
|
+
*
|
|
19
|
+
* Pass a render function as `children` which takes and passes `openIds` and `onToggle` props to
|
|
20
|
+
* <ExpandCollapse.Panel> children, and assign the panels explicit `panelId` props. The panels may be
|
|
21
|
+
* nested (they do not need to be direct children), and non-interactive items may be included too.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const ExpandCollapse = /*#__PURE__*/forwardRef(({
|
|
26
|
+
children,
|
|
27
|
+
tokens,
|
|
28
|
+
variant,
|
|
29
|
+
maxOpen,
|
|
30
|
+
open,
|
|
31
|
+
initialOpen,
|
|
32
|
+
onChange,
|
|
33
|
+
...rest
|
|
34
|
+
}, ref) => {
|
|
35
|
+
const {
|
|
36
|
+
currentValues: openIds,
|
|
37
|
+
toggleOneValue: onToggle,
|
|
38
|
+
resetValues,
|
|
39
|
+
setValues,
|
|
40
|
+
unsetValues
|
|
41
|
+
} = useMultipleInputValues({
|
|
42
|
+
maxValues: maxOpen,
|
|
43
|
+
values: open,
|
|
44
|
+
initialValues: initialOpen,
|
|
45
|
+
onChange
|
|
46
|
+
});
|
|
47
|
+
const themeTokens = useThemeTokens('ExpandCollapse', tokens, variant);
|
|
48
|
+
return /*#__PURE__*/_jsx(View, {
|
|
49
|
+
ref: ref,
|
|
50
|
+
style: selectBorderStyles(themeTokens),
|
|
51
|
+
...selectProps(rest),
|
|
52
|
+
children: typeof children === 'function' ? children({
|
|
53
|
+
openIds,
|
|
54
|
+
onToggle,
|
|
55
|
+
resetValues,
|
|
56
|
+
setValues,
|
|
57
|
+
unsetValues
|
|
58
|
+
}) : children
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
ExpandCollapse.displayName = 'ExpandCollapse';
|
|
62
|
+
ExpandCollapse.propTypes = { ...selectedSystemPropTypes,
|
|
63
|
+
variant: variantProp.propType,
|
|
64
|
+
tokens: getTokensPropType('ExpandCollapse'),
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* ExpandCollapse usually takes a render function to which it passes an object with properties
|
|
68
|
+
* { openIds, onToggle, resetValues, setValues, unsetValues }. openIds (array of ids) and
|
|
69
|
+
* onToggle (function) will usually be passed to `<ExpandCollapse.Panel>`
|
|
70
|
+
*/
|
|
71
|
+
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* If set, enforces a specific maximum number of open items, closing already-open items when new
|
|
75
|
+
* items are opened. By default, any number of items may be open at once.
|
|
76
|
+
*/
|
|
77
|
+
maxOpen: PropTypes.number,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* If passed, the item or items that are expanded will be controlled by a parent component
|
|
81
|
+
*/
|
|
82
|
+
open: PropTypes.arrayOf(PropTypes.string),
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Function called when which panels are currently open changes. Necessary if `open` is passed.
|
|
86
|
+
*/
|
|
87
|
+
onChange: PropTypes.func,
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Allows items with specified ids to be open by default on first load. Should not be used with `open`.
|
|
91
|
+
*/
|
|
92
|
+
initialOpen: PropTypes.arrayOf(PropTypes.string)
|
|
93
|
+
};
|
|
94
|
+
export default ExpandCollapse;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React, { forwardRef, useState } from 'react';
|
|
2
|
+
import Animated from "react-native-web/dist/exports/Animated";
|
|
3
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
|
+
import View from "react-native-web/dist/exports/View";
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import ExpandCollapseControl from './Control';
|
|
8
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
9
|
+
import { a11yProps, getTokensPropType, selectSystemProps, useVerticalExpandAnimation, variantProp, viewProps } from '../utils';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]); // just void functions for now, since there are no style tokens for a panel or control at this point
|
|
13
|
+
|
|
14
|
+
const selectGroupStyles = () => {};
|
|
15
|
+
|
|
16
|
+
const selectContainerStyles = ({
|
|
17
|
+
contentPaddingLeft,
|
|
18
|
+
contentPaddingRight,
|
|
19
|
+
contentPaddingTop,
|
|
20
|
+
contentPaddingBottom
|
|
21
|
+
}) => ({
|
|
22
|
+
paddingLeft: contentPaddingLeft,
|
|
23
|
+
paddingRight: contentPaddingRight,
|
|
24
|
+
paddingTop: contentPaddingTop,
|
|
25
|
+
paddingBottom: contentPaddingBottom
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* An item in an `ExpandCollapse` which contains collapsible `children` and a `control` that opens
|
|
29
|
+
* and closes the collapsible children when pressed.
|
|
30
|
+
*
|
|
31
|
+
* Expects `openIds` and `onToggle` props from the `ExpandCollapse` render function and a unique
|
|
32
|
+
* `panelId` that matches the ids passed to the `<ExpandCollapse>`.
|
|
33
|
+
*
|
|
34
|
+
* The panel does not need to be a direct child of the `<ExpandCollapse>` (unless this is required
|
|
35
|
+
* by the chosen accessibility props for a particular accessibility tools).
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const ExpandCollapsePanel = /*#__PURE__*/forwardRef(({
|
|
40
|
+
openIds = [],
|
|
41
|
+
panelId,
|
|
42
|
+
onToggle,
|
|
43
|
+
onPress,
|
|
44
|
+
control,
|
|
45
|
+
controlTokens,
|
|
46
|
+
children,
|
|
47
|
+
tokens,
|
|
48
|
+
variant,
|
|
49
|
+
...rest
|
|
50
|
+
}, ref) => {
|
|
51
|
+
const [containerHeight, setContainerHeight] = useState(null);
|
|
52
|
+
const isExpanded = openIds.includes(panelId);
|
|
53
|
+
const selectedProps = selectProps(rest);
|
|
54
|
+
selectedProps.accessibilityState = { ...(selectedProps.accessibilityState || {}),
|
|
55
|
+
expanded: isExpanded
|
|
56
|
+
};
|
|
57
|
+
const themeTokens = useThemeTokens('ExpandCollapsePanel', tokens, variant, {
|
|
58
|
+
expanded: isExpanded
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const handleControlPress = event => {
|
|
62
|
+
onToggle(panelId, event);
|
|
63
|
+
if (onPress) onPress(panelId, event);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const onContainerLayout = event => {
|
|
67
|
+
if (containerHeight === null) {
|
|
68
|
+
const {
|
|
69
|
+
layout: {
|
|
70
|
+
height = 0
|
|
71
|
+
} = {}
|
|
72
|
+
} = event.nativeEvent;
|
|
73
|
+
setContainerHeight(height);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const animatedStyles = useVerticalExpandAnimation({
|
|
78
|
+
containerHeight,
|
|
79
|
+
isExpanded,
|
|
80
|
+
tokens: themeTokens
|
|
81
|
+
}); // on web we can hide the contents until we have the container measured and avoid occasional jitter
|
|
82
|
+
// this won't work on native platforms
|
|
83
|
+
|
|
84
|
+
const overflowContainerStyles = containerHeight === null && Platform.OS === 'web' ? {
|
|
85
|
+
height: 0,
|
|
86
|
+
visibility: 'hidden'
|
|
87
|
+
} : undefined;
|
|
88
|
+
const focusabilityProps = isExpanded ? {} : a11yProps.nonFocusableProps;
|
|
89
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
90
|
+
ref: ref,
|
|
91
|
+
style: selectGroupStyles(themeTokens),
|
|
92
|
+
children: [/*#__PURE__*/_jsx(ExpandCollapseControl, { ...selectedProps,
|
|
93
|
+
isExpanded: isExpanded,
|
|
94
|
+
tokens: controlTokens,
|
|
95
|
+
onPress: handleControlPress,
|
|
96
|
+
children: control
|
|
97
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
98
|
+
style: overflowContainerStyles,
|
|
99
|
+
...focusabilityProps,
|
|
100
|
+
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
101
|
+
onLayout: onContainerLayout,
|
|
102
|
+
style: [staticStyles.itemsContainer, animatedStyles],
|
|
103
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
104
|
+
style: selectContainerStyles(themeTokens),
|
|
105
|
+
children: children
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})]
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
ExpandCollapsePanel.displayName = 'ExpandCollapsePanel';
|
|
112
|
+
ExpandCollapsePanel.propTypes = { ...selectedSystemPropTypes,
|
|
113
|
+
variant: variantProp.propType,
|
|
114
|
+
tokens: getTokensPropType('ExpandCollapsePanel'),
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Array of the ids of currently open groups
|
|
118
|
+
*/
|
|
119
|
+
openIds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Unique name by which the ExpandCollapse controls this element.
|
|
123
|
+
*/
|
|
124
|
+
panelId: PropTypes.string.isRequired,
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Function to call on pressing the panel's control, which should open or close the panel.
|
|
128
|
+
* If Panel is a direct child of `ExpandCollapse`, this prop will be provided by the ExpandCollapse parent.
|
|
129
|
+
*/
|
|
130
|
+
onToggle: PropTypes.func.isRequired,
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Optional function to call on pressing the panel's control, in addition to opening or closing the panel.
|
|
134
|
+
*/
|
|
135
|
+
onPress: PropTypes.func,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* ExpandCollapsePanel's children are the content that is hidden or revealed on open or close, and may be any
|
|
139
|
+
* single React element or a render function which takes this group's isExpanded state, onToggle function and panelId
|
|
140
|
+
*/
|
|
141
|
+
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The content inside the always-visible control element that opens and closes the ExpandCollapse when pressed.
|
|
145
|
+
*/
|
|
146
|
+
control: ExpandCollapseControl.propTypes.children.isRequired,
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Optional theme token overrides that may be passed to the ExpandCollapseControl element.
|
|
150
|
+
*/
|
|
151
|
+
controlTokens: getTokensPropType('ExpandCollapseControl')
|
|
152
|
+
};
|
|
153
|
+
const staticStyles = StyleSheet.create({
|
|
154
|
+
itemsContainer: {
|
|
155
|
+
overflow: 'hidden'
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
export default ExpandCollapsePanel;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
3
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
4
|
+
import View from "react-native-web/dist/exports/View";
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { applyTextStyles, useThemeTokens } from '../ThemeProvider';
|
|
7
|
+
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps } from '../utils';
|
|
8
|
+
import StackView from '../StackView';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
12
|
+
|
|
13
|
+
const selectStyles = tokens => selectTokens('Feedback', tokens);
|
|
14
|
+
|
|
15
|
+
const selectTitleTextStyles = ({
|
|
16
|
+
titleFontSize,
|
|
17
|
+
...tokens
|
|
18
|
+
}) => applyTextStyles(selectTokens('Typography', { ...tokens,
|
|
19
|
+
fontSize: titleFontSize
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const selectContentTextStyles = ({
|
|
23
|
+
contentFontSize,
|
|
24
|
+
...tokens
|
|
25
|
+
}) => applyTextStyles(selectTokens('Typography', { ...tokens,
|
|
26
|
+
fontSize: contentFontSize
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
const selectIconTokens = ({
|
|
30
|
+
iconSize,
|
|
31
|
+
iconColor
|
|
32
|
+
}) => ({
|
|
33
|
+
size: iconSize,
|
|
34
|
+
color: iconColor
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const selectIconContainerStyles = ({
|
|
38
|
+
iconGap
|
|
39
|
+
}) => ({
|
|
40
|
+
paddingRight: iconGap
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* A feedback box commonly used with form fields.
|
|
44
|
+
*
|
|
45
|
+
* ### Standalone usage
|
|
46
|
+
* While its primary use is to facilitate feedback states for other form components such as `TextInput`,
|
|
47
|
+
* you may use it standalone.
|
|
48
|
+
*
|
|
49
|
+
* ### Complex content
|
|
50
|
+
* You may pass any React tree as the children of this component, bear in mind that a render function
|
|
51
|
+
* is better suited for styling children based on Feedback's variant.
|
|
52
|
+
*
|
|
53
|
+
* ### Using a render function
|
|
54
|
+
* When a function is passed for rendering content, it will receive the feedback text styles and
|
|
55
|
+
* variant as arguments.
|
|
56
|
+
*
|
|
57
|
+
* ### Accessibility
|
|
58
|
+
* All accessibility props set on this component will be applied to the outer container.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const Feedback = /*#__PURE__*/forwardRef(({
|
|
63
|
+
title,
|
|
64
|
+
children,
|
|
65
|
+
id,
|
|
66
|
+
validation,
|
|
67
|
+
tokens,
|
|
68
|
+
variant,
|
|
69
|
+
...rest
|
|
70
|
+
}, ref) => {
|
|
71
|
+
const themeTokens = useThemeTokens('Feedback', tokens, { ...variant,
|
|
72
|
+
validation
|
|
73
|
+
});
|
|
74
|
+
const {
|
|
75
|
+
space
|
|
76
|
+
} = themeTokens;
|
|
77
|
+
const {
|
|
78
|
+
icon: IconComponent
|
|
79
|
+
} = themeTokens;
|
|
80
|
+
const titleTextStyles = selectTitleTextStyles(themeTokens);
|
|
81
|
+
const contentTextStyles = selectContentTextStyles(themeTokens);
|
|
82
|
+
const content = typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
83
|
+
style: contentTextStyles,
|
|
84
|
+
children: children
|
|
85
|
+
}) : children;
|
|
86
|
+
const selectedProps = selectProps({
|
|
87
|
+
accessibilityRole: validation === 'error' ? 'alert' : undefined,
|
|
88
|
+
...rest
|
|
89
|
+
});
|
|
90
|
+
return /*#__PURE__*/_jsx(View, {
|
|
91
|
+
ref: ref,
|
|
92
|
+
style: selectStyles(themeTokens),
|
|
93
|
+
nativeID: id,
|
|
94
|
+
...selectedProps,
|
|
95
|
+
children: /*#__PURE__*/_jsxs(StackView, {
|
|
96
|
+
space: space,
|
|
97
|
+
children: [title !== undefined && /*#__PURE__*/_jsxs(View, {
|
|
98
|
+
style: staticStyles.title,
|
|
99
|
+
children: [IconComponent && /*#__PURE__*/_jsx(View, {
|
|
100
|
+
style: selectIconContainerStyles(themeTokens),
|
|
101
|
+
children: /*#__PURE__*/_jsx(IconComponent, { ...selectIconTokens(themeTokens)
|
|
102
|
+
})
|
|
103
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
104
|
+
style: titleTextStyles,
|
|
105
|
+
children: title
|
|
106
|
+
})]
|
|
107
|
+
}), content && typeof content === 'function' ? content({
|
|
108
|
+
textStyles: contentTextStyles,
|
|
109
|
+
variant
|
|
110
|
+
}) : content]
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
Feedback.displayName = 'Feedback';
|
|
115
|
+
Feedback.propTypes = { ...selectedSystemPropTypes,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Emphasized summary of the feedback. If an icon is set, it is rendered next to the title.
|
|
119
|
+
*/
|
|
120
|
+
title: PropTypes.string,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Feedback content rendered below the title. A render function `({textStyles, variant}) => {}` is supported.
|
|
124
|
+
*/
|
|
125
|
+
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.func]),
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Use to visually mark the Feedback as valid or invalid.
|
|
129
|
+
*/
|
|
130
|
+
validation: PropTypes.oneOf(['error', 'success']),
|
|
131
|
+
|
|
132
|
+
/** @ignore */
|
|
133
|
+
id: PropTypes.string,
|
|
134
|
+
tokens: getTokensPropType('Feedback'),
|
|
135
|
+
variant: variantProp.propType
|
|
136
|
+
};
|
|
137
|
+
export default Feedback;
|
|
138
|
+
const staticStyles = StyleSheet.create({
|
|
139
|
+
title: {
|
|
140
|
+
display: 'flex',
|
|
141
|
+
flexDirection: 'row',
|
|
142
|
+
alignItems: 'center'
|
|
143
|
+
}
|
|
144
|
+
});
|