@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,145 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Feedback from '../Feedback';
|
|
4
|
+
import { spacingProps } from '../utils';
|
|
5
|
+
import FieldsetContainer from './FieldsetContainer';
|
|
6
|
+
import { getStackedContent } from '../StackView';
|
|
7
|
+
import InputLabel from '../InputLabel';
|
|
8
|
+
import useInputSupports from '../InputSupports/useInputSupports';
|
|
9
|
+
import Legend from './Legend';
|
|
10
|
+
/**
|
|
11
|
+
* An alternative to InputSupports for groups of input elements that, on web, are to be
|
|
12
|
+
* wrapped in a `<fieldset>` tag, with label content displated in a `<legend>` tag.
|
|
13
|
+
*
|
|
14
|
+
* Follows the same theming and most of the same props as InputSupports.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
+
const Fieldset = /*#__PURE__*/forwardRef(({
|
|
20
|
+
space,
|
|
21
|
+
feedback,
|
|
22
|
+
feedbackPosition = 'top',
|
|
23
|
+
validation,
|
|
24
|
+
legend,
|
|
25
|
+
hint,
|
|
26
|
+
hintPosition,
|
|
27
|
+
tooltip,
|
|
28
|
+
inactive,
|
|
29
|
+
accessibilityRole,
|
|
30
|
+
name: fieldsetName,
|
|
31
|
+
children
|
|
32
|
+
}, ref) => {
|
|
33
|
+
// Skips `inputId` because a fieldset' legend describes multiple inputs
|
|
34
|
+
const {
|
|
35
|
+
hintId,
|
|
36
|
+
feedbackId,
|
|
37
|
+
a11yProps
|
|
38
|
+
} = useInputSupports({
|
|
39
|
+
feedback,
|
|
40
|
+
hint,
|
|
41
|
+
label: legend,
|
|
42
|
+
validation
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const legendContent = legend && /*#__PURE__*/_jsx(Legend, {
|
|
46
|
+
children: /*#__PURE__*/_jsx(InputLabel, {
|
|
47
|
+
label: legend,
|
|
48
|
+
hint: hint,
|
|
49
|
+
hintPosition: hintPosition,
|
|
50
|
+
hintId: hintId,
|
|
51
|
+
tooltip: tooltip
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const feedbackContent = feedback && /*#__PURE__*/_jsx(Feedback, {
|
|
56
|
+
id: feedbackId,
|
|
57
|
+
title: feedback,
|
|
58
|
+
validation: validation
|
|
59
|
+
}); // Some accessibility patterns depend on elements being direct children, e.g. fieldset -> legend,
|
|
60
|
+
// and on MacOS voiceover, radiogroup -> radio. To allow elements to be direct children of the
|
|
61
|
+
// fieldset as much as possible, but also allow different spacing within content and between
|
|
62
|
+
// fieldset / feedback / etc, wrap resolved children in a fragment, and stack with `preserveFragments`.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
const childContent = /*#__PURE__*/_jsx(_Fragment, {
|
|
66
|
+
children: typeof children === 'function' ? children(a11yProps) : children
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const orderedContent = feedbackPosition === 'bottom' ? [legendContent, feedbackContent, childContent] : [legendContent, childContent, feedbackContent];
|
|
70
|
+
const stackedContent = getStackedContent(orderedContent, {
|
|
71
|
+
space,
|
|
72
|
+
preserveFragments: true
|
|
73
|
+
});
|
|
74
|
+
return /*#__PURE__*/_jsx(FieldsetContainer, {
|
|
75
|
+
ref: ref,
|
|
76
|
+
inactive: inactive,
|
|
77
|
+
accessibilityRole: accessibilityRole,
|
|
78
|
+
name: fieldsetName,
|
|
79
|
+
children: stackedContent
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
Fieldset.displayName = 'Fieldset';
|
|
83
|
+
Fieldset.propTypes = {
|
|
84
|
+
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The accessibility role of the `<fieldset>` element itself. Other React Native accessibility
|
|
88
|
+
* props are not supported because there is not an appropriate counterpart for Fieldsets.
|
|
89
|
+
*/
|
|
90
|
+
accessibilityRole: PropTypes.string,
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The amout of space between legend, feedback and content; according to the theme's spacing scale.
|
|
94
|
+
* Either a number corresponding to a position on the theme's spacing scale (1 is smallest, 2 is second smallest, etc),
|
|
95
|
+
* or, a SpacingObject with viewport keys and options (see `useSpacingScale` for details).
|
|
96
|
+
*/
|
|
97
|
+
space: spacingProps.types.spacingValue,
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The text for the fieldset's legend, describing the fieldset content.
|
|
101
|
+
*/
|
|
102
|
+
legend: PropTypes.string,
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A short description of the expected input.
|
|
106
|
+
*/
|
|
107
|
+
hint: PropTypes.string,
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Position of the hint relative to label.
|
|
111
|
+
*/
|
|
112
|
+
hintPosition: PropTypes.oneOf(['inline', 'below']),
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A detailed description of validation error/success or additional instructions.
|
|
116
|
+
* Visual variant is determined based on the `validation` prop.
|
|
117
|
+
*/
|
|
118
|
+
feedback: PropTypes.string,
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Position of the feedback block relative to the fieldset's content.
|
|
122
|
+
*/
|
|
123
|
+
feedbackPosition: PropTypes.oneOf(['above', 'below']),
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* If true, the fieldset is treated as inactive (setting `disabled` attribute on web).
|
|
127
|
+
*/
|
|
128
|
+
inactive: PropTypes.bool,
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
|
|
132
|
+
*/
|
|
133
|
+
tooltip: PropTypes.string,
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* On web, this is passed to the `<fieldset>`'s `name` attribute.
|
|
137
|
+
*/
|
|
138
|
+
name: PropTypes.string,
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Use to visually mark an input as valid or invalid.
|
|
142
|
+
*/
|
|
143
|
+
validation: PropTypes.oneOf(['error', 'success'])
|
|
144
|
+
};
|
|
145
|
+
export default Fieldset;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cssReset from './cssReset';
|
|
4
|
+
/**
|
|
5
|
+
* On Web, wraps children with a HTML `<fieldset>` and sets its attributes as necessary.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const FieldsetContainer = /*#__PURE__*/forwardRef(({
|
|
10
|
+
children,
|
|
11
|
+
inactive,
|
|
12
|
+
accessibilityRole,
|
|
13
|
+
name: fieldsetName
|
|
14
|
+
}, ref) => /*#__PURE__*/_jsx("fieldset", {
|
|
15
|
+
ref: ref,
|
|
16
|
+
disabled: inactive,
|
|
17
|
+
style: cssReset,
|
|
18
|
+
role: accessibilityRole,
|
|
19
|
+
name: fieldsetName,
|
|
20
|
+
children: children
|
|
21
|
+
}));
|
|
22
|
+
FieldsetContainer.displayName = 'FieldsetContainer';
|
|
23
|
+
FieldsetContainer.propTypes = {
|
|
24
|
+
accessibilityRole: PropTypes.string,
|
|
25
|
+
children: PropTypes.node,
|
|
26
|
+
inactive: PropTypes.bool,
|
|
27
|
+
name: PropTypes.string
|
|
28
|
+
};
|
|
29
|
+
export default FieldsetContainer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import View from "react-native-web/dist/exports/View"; // No equivalent of `<fieldset>` on native, so just apply accessibility role to container.
|
|
4
|
+
// If a11y testing finds any additional handling is needed at the container level, add it here.
|
|
5
|
+
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const FieldsetContainer = /*#__PURE__*/forwardRef(({
|
|
8
|
+
children,
|
|
9
|
+
accessibilityRole
|
|
10
|
+
}, ref) => /*#__PURE__*/_jsx(View, {
|
|
11
|
+
ref: ref,
|
|
12
|
+
accessibilityRole: accessibilityRole,
|
|
13
|
+
children: children
|
|
14
|
+
}));
|
|
15
|
+
FieldsetContainer.displayName = 'FieldsetContainer';
|
|
16
|
+
FieldsetContainer.propTypes = {
|
|
17
|
+
children: PropTypes.node,
|
|
18
|
+
accessibilityRole: PropTypes.string
|
|
19
|
+
};
|
|
20
|
+
export default FieldsetContainer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cssReset from './cssReset';
|
|
4
|
+
/**
|
|
5
|
+
* On Web, wraps children in HTML `<legend>` tag.
|
|
6
|
+
* On Native, `<legend>` does not exist, wraps in a width 100% block to follow <legend>'s behaviour in a flex.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const Legend = /*#__PURE__*/forwardRef(({
|
|
11
|
+
children
|
|
12
|
+
}, ref) => /*#__PURE__*/_jsx("legend", {
|
|
13
|
+
ref: ref,
|
|
14
|
+
style: cssReset,
|
|
15
|
+
children: children
|
|
16
|
+
}));
|
|
17
|
+
Legend.displayName = 'Legend';
|
|
18
|
+
Legend.propTypes = {
|
|
19
|
+
children: PropTypes.node
|
|
20
|
+
};
|
|
21
|
+
export default Legend;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import View from "react-native-web/dist/exports/View";
|
|
3
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
/**
|
|
6
|
+
* On Web, wraps children in HTML `<legend>` tag.
|
|
7
|
+
* On Native, `<legend>` does not exist, wraps in a width 100% block to follow <legend>'s behaviour in a flex.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const Legend = /*#__PURE__*/forwardRef(({
|
|
12
|
+
children
|
|
13
|
+
}, ref) => /*#__PURE__*/_jsx(View, {
|
|
14
|
+
ref: ref,
|
|
15
|
+
style: staticStyles.stretch,
|
|
16
|
+
children: children
|
|
17
|
+
}));
|
|
18
|
+
Legend.displayName = 'Legend';
|
|
19
|
+
Legend.propTypes = {
|
|
20
|
+
children: PropTypes.node
|
|
21
|
+
};
|
|
22
|
+
const staticStyles = StyleSheet.create({
|
|
23
|
+
stretch: {
|
|
24
|
+
width: '100%',
|
|
25
|
+
flexGrow: 1
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
export default Legend;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// React Native Web has no built-in `fieldset` or `legend` support.
|
|
2
|
+
// This reset makes them consistent with other RNW views.
|
|
3
|
+
// Can't use RN stylesheets because it's not an RN element (RNW's createElement tooling is unstable).
|
|
4
|
+
// Using CSS `all` doesn't work well as an inline style.
|
|
5
|
+
// https://github.com/necolas/react-native-web/issues/1385
|
|
6
|
+
export default {
|
|
7
|
+
margin: 'unset',
|
|
8
|
+
padding: 'unset',
|
|
9
|
+
float: 'unset',
|
|
10
|
+
border: 'unset',
|
|
11
|
+
width: 'unset',
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flexDirection: 'column'
|
|
14
|
+
};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import React, { forwardRef, useContext } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
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 { viewports } from '@telus-uds/system-constants';
|
|
7
|
+
import GutterContext from '../providers/GutterContext';
|
|
8
|
+
import { useViewport } from '../../ViewportProvider';
|
|
9
|
+
import applyInheritance from '../helpers';
|
|
10
|
+
import { responsiveProps } from '../../utils';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const Col = /*#__PURE__*/forwardRef(({
|
|
13
|
+
horizontalAlign,
|
|
14
|
+
children,
|
|
15
|
+
xs,
|
|
16
|
+
sm,
|
|
17
|
+
md,
|
|
18
|
+
lg,
|
|
19
|
+
xl,
|
|
20
|
+
xsOffset,
|
|
21
|
+
smOffset,
|
|
22
|
+
mdOffset,
|
|
23
|
+
lgOffset,
|
|
24
|
+
xlOffset,
|
|
25
|
+
...viewProps
|
|
26
|
+
}, ref) => {
|
|
27
|
+
const gutter = useContext(GutterContext);
|
|
28
|
+
const viewPort = useViewport();
|
|
29
|
+
const hiddenLevels = applyInheritance([xs, sm, md, lg, xl]);
|
|
30
|
+
|
|
31
|
+
const getHorizontalAlignLevel = () => {
|
|
32
|
+
if (typeof horizontalAlign === 'object') {
|
|
33
|
+
return applyInheritance([horizontalAlign.xs, horizontalAlign.sm, horizontalAlign.md, horizontalAlign.lg, horizontalAlign.xl]);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (typeof horizontalAlign === 'string') {
|
|
37
|
+
return [horizontalAlign, horizontalAlign, horizontalAlign, horizontalAlign, horizontalAlign];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return ['inherit', 'inherit', 'inherit', 'inherit', 'inherit'];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const horizontalAlignLevel = getHorizontalAlignLevel();
|
|
44
|
+
|
|
45
|
+
const toPercent = num => {
|
|
46
|
+
return `${num / 12 * 100}%`;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const calculateWidth = value => {
|
|
50
|
+
if (typeof value === 'undefined') {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (typeof value === 'number') {
|
|
55
|
+
const percent = toPercent(value);
|
|
56
|
+
return {
|
|
57
|
+
maxWidth: percent,
|
|
58
|
+
flexBasis: percent
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
flexGrow: 1,
|
|
64
|
+
flexBasis: 0,
|
|
65
|
+
maxWidth: '100%'
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const calculateOffset = value => {
|
|
70
|
+
if (typeof value === 'number') {
|
|
71
|
+
const percent = toPercent(value);
|
|
72
|
+
return {
|
|
73
|
+
marginLeft: percent
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const sizeStyles = sizes => {
|
|
81
|
+
const currViewport = Object.keys(sizes).find(key => key.startsWith(viewPort));
|
|
82
|
+
const currSize = sizes[currViewport];
|
|
83
|
+
return { ...calculateWidth(currSize)
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const offsetStyles = offsets => {
|
|
88
|
+
const currViewport = Object.keys(offsets).find(key => key.startsWith(viewPort));
|
|
89
|
+
const currOffset = offsets[currViewport];
|
|
90
|
+
return { ...calculateOffset(currOffset)
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const gutterPadding = {
|
|
95
|
+
paddingLeft: gutter ? 16 : 0,
|
|
96
|
+
paddingRight: gutter ? 16 : 0
|
|
97
|
+
};
|
|
98
|
+
let hidingStyles = {};
|
|
99
|
+
const shown = Platform.OS === 'web' ? 'block' : 'flex';
|
|
100
|
+
|
|
101
|
+
if (viewPort === viewports.xs) {
|
|
102
|
+
hidingStyles = {
|
|
103
|
+
display: hiddenLevels[0] === 0 ? 'none' : shown,
|
|
104
|
+
textAlign: horizontalAlignLevel[0]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (viewPort === viewports.sm) {
|
|
109
|
+
hidingStyles = {
|
|
110
|
+
display: hiddenLevels[1] === 0 ? 'none' : shown,
|
|
111
|
+
textAlign: horizontalAlignLevel[1]
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (viewPort === viewports.md) {
|
|
116
|
+
hidingStyles = {
|
|
117
|
+
display: hiddenLevels[2] === 0 ? 'none' : shown,
|
|
118
|
+
textAlign: horizontalAlignLevel[2]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (viewPort === viewports.lg) {
|
|
123
|
+
hidingStyles = {
|
|
124
|
+
display: hiddenLevels[3] === 0 ? 'none' : shown,
|
|
125
|
+
textAlign: horizontalAlignLevel[3]
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (viewPort === viewports.xl) {
|
|
130
|
+
hidingStyles = {
|
|
131
|
+
display: hiddenLevels[4] === 0 ? 'none' : shown,
|
|
132
|
+
textAlign: horizontalAlignLevel[4]
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const sizesArray = [xs, sm, md, lg, xl];
|
|
137
|
+
const offSetsArray = [xsOffset, smOffset, mdOffset, lgOffset, xlOffset];
|
|
138
|
+
const sizesWithIheritance = applyInheritance(sizesArray);
|
|
139
|
+
const offsetsWithIheritance = applyInheritance(offSetsArray);
|
|
140
|
+
const sizes = {
|
|
141
|
+
xs: sizesWithIheritance[0],
|
|
142
|
+
sm: sizesWithIheritance[1],
|
|
143
|
+
md: sizesWithIheritance[2],
|
|
144
|
+
lg: sizesWithIheritance[3],
|
|
145
|
+
xl: sizesWithIheritance[4]
|
|
146
|
+
};
|
|
147
|
+
const offsets = {
|
|
148
|
+
xs: offsetsWithIheritance[0],
|
|
149
|
+
sm: offsetsWithIheritance[1],
|
|
150
|
+
md: offsetsWithIheritance[2],
|
|
151
|
+
lg: offsetsWithIheritance[3],
|
|
152
|
+
xl: offsetsWithIheritance[4]
|
|
153
|
+
};
|
|
154
|
+
return /*#__PURE__*/_jsx(View, {
|
|
155
|
+
ref: ref,
|
|
156
|
+
...viewProps,
|
|
157
|
+
style: [styles.col, gutterPadding, offsetStyles(offsets), sizeStyles(sizes), { ...hidingStyles
|
|
158
|
+
}],
|
|
159
|
+
children: children
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
Col.displayName = 'Col';
|
|
163
|
+
const styles = StyleSheet.create({
|
|
164
|
+
col: {
|
|
165
|
+
flexGrow: 1,
|
|
166
|
+
flexShrink: 0,
|
|
167
|
+
flexBasis: 'auto',
|
|
168
|
+
maxWidth: '100%'
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
/*
|
|
172
|
+
* We're disabling default props since passing undefined props to
|
|
173
|
+
* the react-flexbox-grid component sets up blank classes that may cause
|
|
174
|
+
* styling issues.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
Col.propTypes = {
|
|
178
|
+
/**
|
|
179
|
+
* Specify number of columns within the 'xs' breakpoint range. `0` hides the column.
|
|
180
|
+
*
|
|
181
|
+
* `true` sets the column width automatically;
|
|
182
|
+
* `false` disables the prop
|
|
183
|
+
*
|
|
184
|
+
*/
|
|
185
|
+
xs: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, true, false]),
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Specify number of columns within the 'sm' breakpoint range. `0` hides the column.
|
|
189
|
+
*
|
|
190
|
+
* `true` sets the column width automatically;
|
|
191
|
+
* `false` disables the prop
|
|
192
|
+
*
|
|
193
|
+
*/
|
|
194
|
+
sm: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, true, false]),
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Specify number of columns within the 'md' breakpoint range. `0` hides the column.
|
|
198
|
+
*
|
|
199
|
+
* `true` sets the column width automatically;
|
|
200
|
+
* `false` disables the prop
|
|
201
|
+
*
|
|
202
|
+
*/
|
|
203
|
+
md: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, true, false]),
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Specify number of columns within the 'lg' breakpoint range. `0` hides the column.
|
|
207
|
+
*
|
|
208
|
+
* `true` sets the column width automatically;
|
|
209
|
+
* `false` disables the prop
|
|
210
|
+
*
|
|
211
|
+
*/
|
|
212
|
+
lg: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, true, false]),
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Specify number of columns after the 'xl' breakpoint. `0` hides the column.
|
|
216
|
+
*
|
|
217
|
+
* `true` sets the column width automatically;
|
|
218
|
+
* `false` disables the prop
|
|
219
|
+
*
|
|
220
|
+
*/
|
|
221
|
+
xl: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, true, false]),
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Offset the specified number of columns within the 'xs' breakpoint range. `0` hides the column.
|
|
225
|
+
*
|
|
226
|
+
*/
|
|
227
|
+
xsOffset: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Offset the specified number of columns within the 'sm' breakpoint range.
|
|
231
|
+
*
|
|
232
|
+
*/
|
|
233
|
+
smOffset: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Offset the specified number of columns within the 'md' breakpoint range.
|
|
237
|
+
*
|
|
238
|
+
*/
|
|
239
|
+
mdOffset: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Offset the specified number of columns within the 'lg' breakpoint range.
|
|
243
|
+
*
|
|
244
|
+
*/
|
|
245
|
+
lgOffset: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Offset the specified number of columns within the 'xl' breakpoint range.
|
|
249
|
+
*/
|
|
250
|
+
xlOffset: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The columns of the Grid. Will typically be `FlexGrid.Col` components.
|
|
254
|
+
*/
|
|
255
|
+
children: PropTypes.node.isRequired,
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
*
|
|
259
|
+
* Align content horizontally within the column.
|
|
260
|
+
*
|
|
261
|
+
* Accepts a `PropType.string` following the [responsive prop](#/Layout?id=responsive) structure.
|
|
262
|
+
*/
|
|
263
|
+
horizontalAlign: responsiveProps.getTypeOptionallyByViewport(PropTypes.oneOf(['left', 'center', 'right']))
|
|
264
|
+
};
|
|
265
|
+
export default Col;
|
|
@@ -0,0 +1,147 @@
|
|
|
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 { viewports } from '@telus-uds/system-constants';
|
|
6
|
+
import Row from './Row';
|
|
7
|
+
import Col from './Col';
|
|
8
|
+
import { useViewport } from '../ViewportProvider';
|
|
9
|
+
import GutterContext from './providers/GutterContext';
|
|
10
|
+
import applyInheritance from './helpers';
|
|
11
|
+
import { a11yProps, viewProps, getA11yPropsFromHtmlTag, layoutTags, selectSystemProps } from '../utils';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
14
|
+
/**
|
|
15
|
+
* A mobile-first flexbox grid.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const FlexGrid = /*#__PURE__*/forwardRef(({
|
|
19
|
+
limitWidth = true,
|
|
20
|
+
gutter = true,
|
|
21
|
+
outsideGutter = true,
|
|
22
|
+
xsReverse,
|
|
23
|
+
smReverse,
|
|
24
|
+
mdReverse,
|
|
25
|
+
lgReverse,
|
|
26
|
+
xlReverse,
|
|
27
|
+
tag,
|
|
28
|
+
accessibilityRole,
|
|
29
|
+
children,
|
|
30
|
+
...rest
|
|
31
|
+
}, ref) => {
|
|
32
|
+
const viewPort = useViewport();
|
|
33
|
+
const reverseLevel = applyInheritance([xsReverse, smReverse, mdReverse, lgReverse, xlReverse]);
|
|
34
|
+
const marginVertical = 0;
|
|
35
|
+
const marginHorizontal = outsideGutter ? 'auto' : -16;
|
|
36
|
+
const width = outsideGutter ? '100%' : 'auto';
|
|
37
|
+
let flexDirection;
|
|
38
|
+
let maxWidth;
|
|
39
|
+
|
|
40
|
+
if (viewPort === viewports.xs) {
|
|
41
|
+
// no maxWidth for xs
|
|
42
|
+
flexDirection = reverseLevel[0] ? 'column-reverse' : 'column';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (viewPort === viewports.sm) {
|
|
46
|
+
maxWidth = limitWidth && viewports.map.get(viewports.sm);
|
|
47
|
+
flexDirection = reverseLevel[1] ? 'column-reverse' : 'column';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (viewPort === viewports.md) {
|
|
51
|
+
maxWidth = limitWidth && viewports.map.get(viewports.md);
|
|
52
|
+
flexDirection = reverseLevel[2] ? 'column-reverse' : 'column';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (viewPort === viewports.lg) {
|
|
56
|
+
maxWidth = limitWidth && viewports.map.get(viewports.lg);
|
|
57
|
+
flexDirection = reverseLevel[3] ? 'column-reverse' : 'column';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (viewPort === viewports.xl) {
|
|
61
|
+
maxWidth = limitWidth && viewports.map.get(viewports.xl);
|
|
62
|
+
flexDirection = reverseLevel[4] ? 'column-reverse' : 'column';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const props = { ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
|
|
66
|
+
...selectProps(rest)
|
|
67
|
+
};
|
|
68
|
+
return /*#__PURE__*/_jsx(GutterContext.Provider, {
|
|
69
|
+
value: gutter,
|
|
70
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
71
|
+
ref: ref,
|
|
72
|
+
...props,
|
|
73
|
+
style: [styles.grid, {
|
|
74
|
+
marginHorizontal,
|
|
75
|
+
marginVertical,
|
|
76
|
+
width,
|
|
77
|
+
flexDirection,
|
|
78
|
+
maxWidth
|
|
79
|
+
}],
|
|
80
|
+
children: children
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
FlexGrid.displayName = 'FlexGrid';
|
|
85
|
+
const styles = StyleSheet.create({
|
|
86
|
+
grid: {
|
|
87
|
+
flexWrap: 'wrap'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
FlexGrid.propTypes = { ...selectedSystemPropTypes,
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Whether or not to give the grid a fixed width. This also centres the grid horizontally.
|
|
94
|
+
*/
|
|
95
|
+
limitWidth: PropTypes.bool,
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Whether or not to include gutters in between columns.
|
|
99
|
+
*/
|
|
100
|
+
gutter: PropTypes.bool,
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Whether or not to include gutter at the ends to the left and right of the FlexGrid
|
|
104
|
+
*/
|
|
105
|
+
outsideGutter: PropTypes.bool,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Choose if the item order should be reversed from the 'xs' breakpoint. When you pass in false, the order will be normal from the xs breakpoint. By default, it inherits the behaviour set by the preceding prop.
|
|
109
|
+
*/
|
|
110
|
+
xsReverse: PropTypes.bool,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Choose if the item order should be reversed from the 'sm' breakpoint. When you pass in false, the order will be normal from the sm breakpoint. By default, it inherits the behaviour set by the preceding prop.
|
|
114
|
+
*/
|
|
115
|
+
smReverse: PropTypes.bool,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Choose if the item order should be reversed from the 'md' breakpoint. When you pass in false, the order will be normal from the md breakpoint. By default, it inherits the behaviour set by the preceding prop.
|
|
119
|
+
*/
|
|
120
|
+
mdReverse: PropTypes.bool,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Choose if the item order should be reversed from the 'lg' breakpoint. When you pass in false, the order will be normal from the lg breakpoint. By default, it inherits the behaviour set by the preceding prop.
|
|
124
|
+
*/
|
|
125
|
+
lgReverse: PropTypes.bool,
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Choose if the item order should be reversed from the 'xl' breakpoint. When you pass in false, the order will be normal from the xl breakpoint. By default, it inherits the behaviour set by the preceding prop.
|
|
129
|
+
*/
|
|
130
|
+
xlReverse: PropTypes.bool,
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Optional semantic HTML tag, to apply to the container on web. Does not change styling.
|
|
134
|
+
*
|
|
135
|
+
* In native apps, if a header tag is provided ("h1", "h2" etc) and accessibilityRole prop
|
|
136
|
+
* is not defined, the accessibilityRole will default to "heading".
|
|
137
|
+
*/
|
|
138
|
+
tag: PropTypes.oneOf(layoutTags),
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The rows and columns of the Grid. Will typically be `FlexGrid.Row` and `FlexGrid.Col` components.
|
|
142
|
+
*/
|
|
143
|
+
children: PropTypes.node.isRequired
|
|
144
|
+
};
|
|
145
|
+
FlexGrid.Row = Row;
|
|
146
|
+
FlexGrid.Col = Col;
|
|
147
|
+
export default FlexGrid;
|