@telus-uds/components-base 1.8.2 → 1.8.5
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/CHANGELOG.md +33 -2
- package/component-docs.json +36 -1
- package/lib/ActivityIndicator/Spinner.js +7 -7
- package/lib/ActivityIndicator/Spinner.native.js +2 -2
- package/lib/Button/ButtonBase.js +2 -2
- package/lib/Button/ButtonGroup.js +1 -1
- package/lib/Checkbox/Checkbox.js +5 -3
- package/lib/Checkbox/CheckboxGroup.js +2 -2
- package/lib/Divider/Divider.js +2 -2
- package/lib/ExpandCollapse/Panel.js +2 -17
- package/lib/FlexGrid/Col/Col.js +1 -1
- package/lib/Icon/Icon.js +1 -1
- package/lib/Link/InlinePressable.js +5 -1
- package/lib/Link/LinkBase.js +5 -2
- package/lib/List/List.js +12 -7
- package/lib/List/ListItem.js +4 -5
- package/lib/Modal/Modal.js +2 -1
- package/lib/Pagination/PageButton.js +2 -2
- package/lib/Pagination/Pagination.js +5 -3
- package/lib/Pagination/usePagination.js +2 -2
- package/lib/Progress/ProgressBar.js +3 -3
- package/lib/Progress/ProgressBarBackground.js +3 -3
- package/lib/Radio/Radio.js +2 -2
- package/lib/Radio/RadioGroup.js +2 -2
- package/lib/RadioCard/RadioCard.js +1 -1
- package/lib/RadioCard/RadioCardGroup.js +2 -2
- package/lib/Search/Search.js +1 -1
- package/lib/SideNav/SideNav.js +2 -2
- package/lib/Skeleton/Skeleton.js +1 -1
- package/lib/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib/StackView/StackWrap.js +3 -1
- package/lib/StackView/getStackedContent.js +2 -2
- package/lib/Tabs/Tabs.js +28 -3
- package/lib/Tabs/TabsItem.js +5 -6
- package/lib/Tags/Tags.js +1 -1
- package/lib/ThemeProvider/utils/styles.js +2 -2
- package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
- package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib/Tooltip/Backdrop.js +2 -10
- package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
- package/lib/utils/children.js +2 -2
- package/lib/utils/input.js +6 -12
- package/lib/utils/props/componentPropType.js +3 -3
- package/lib/utils/props/selectSystemProps.js +2 -2
- package/lib/utils/props/tokens.js +2 -2
- package/lib/utils/useSpacingScale.js +3 -1
- package/lib/utils/useUniqueId.js +1 -1
- package/lib-module/A11yInfoProvider/index.js +63 -0
- package/lib-module/A11yText/index.js +56 -0
- package/lib-module/ActivityIndicator/Spinner.js +77 -0
- package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
- package/lib-module/ActivityIndicator/index.js +41 -0
- package/lib-module/ActivityIndicator/shared.js +12 -0
- package/lib-module/BaseProvider/index.js +29 -0
- package/lib-module/Box/Box.js +244 -0
- package/lib-module/Box/index.js +2 -0
- package/lib-module/Button/Button.js +26 -0
- package/lib-module/Button/ButtonBase.js +271 -0
- package/lib-module/Button/ButtonGroup.js +247 -0
- package/lib-module/Button/ButtonLink.js +40 -0
- package/lib-module/Button/index.js +4 -0
- package/lib-module/Button/propTypes.js +36 -0
- package/lib-module/Card/Card.js +84 -0
- package/lib-module/Card/CardBase.js +66 -0
- package/lib-module/Card/PressableCardBase.js +114 -0
- package/lib-module/Card/index.js +4 -0
- package/lib-module/Checkbox/Checkbox.js +348 -0
- package/lib-module/Checkbox/CheckboxGroup.js +233 -0
- package/lib-module/Checkbox/CheckboxInput.js +60 -0
- package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
- package/lib-module/Checkbox/index.js +3 -0
- package/lib-module/Divider/Divider.js +124 -0
- package/lib-module/Divider/index.js +2 -0
- package/lib-module/ExpandCollapse/Accordion.js +15 -0
- package/lib-module/ExpandCollapse/Control.js +136 -0
- package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
- package/lib-module/ExpandCollapse/Panel.js +151 -0
- package/lib-module/ExpandCollapse/index.js +7 -0
- package/lib-module/Feedback/Feedback.js +157 -0
- package/lib-module/Feedback/index.js +2 -0
- package/lib-module/Fieldset/Fieldset.js +153 -0
- package/lib-module/Fieldset/FieldsetContainer.js +32 -0
- package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
- package/lib-module/Fieldset/Legend.js +24 -0
- package/lib-module/Fieldset/Legend.native.js +31 -0
- package/lib-module/Fieldset/cssReset.js +14 -0
- package/lib-module/Fieldset/index.js +2 -0
- package/lib-module/FlexGrid/Col/Col.js +276 -0
- package/lib-module/FlexGrid/Col/index.js +2 -0
- package/lib-module/FlexGrid/FlexGrid.js +148 -0
- package/lib-module/FlexGrid/Row/Row.js +184 -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 +175 -0
- package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
- package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
- package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
- package/lib-module/HorizontalScroll/dictionary.js +11 -0
- package/lib-module/HorizontalScroll/index.js +11 -0
- package/lib-module/HorizontalScroll/itemPositions.js +112 -0
- package/lib-module/Icon/Icon.js +62 -0
- package/lib-module/Icon/IconText.js +83 -0
- package/lib-module/Icon/index.js +4 -0
- package/lib-module/IconButton/IconButton.js +122 -0
- package/lib-module/IconButton/index.js +2 -0
- package/lib-module/InputLabel/InputLabel.js +148 -0
- package/lib-module/InputLabel/LabelContent.js +27 -0
- package/lib-module/InputLabel/LabelContent.native.js +19 -0
- package/lib-module/InputLabel/index.js +2 -0
- package/lib-module/InputSupports/InputSupports.js +96 -0
- package/lib-module/InputSupports/index.js +2 -0
- package/lib-module/InputSupports/useInputSupports.js +32 -0
- package/lib-module/Link/ChevronLink.js +52 -0
- package/lib-module/Link/InlinePressable.js +44 -0
- package/lib-module/Link/InlinePressable.native.js +89 -0
- package/lib-module/Link/Link.js +28 -0
- package/lib-module/Link/LinkBase.js +243 -0
- package/lib-module/Link/TextButton.js +35 -0
- package/lib-module/Link/index.js +5 -0
- package/lib-module/List/List.js +62 -0
- package/lib-module/List/ListItem.js +248 -0
- package/lib-module/List/index.js +5 -0
- package/lib-module/Modal/Modal.js +222 -0
- package/lib-module/Modal/dictionary.js +9 -0
- package/lib-module/Modal/index.js +2 -0
- package/lib-module/Notification/Notification.js +209 -0
- package/lib-module/Notification/dictionary.js +8 -0
- package/lib-module/Notification/index.js +2 -0
- package/lib-module/Pagination/PageButton.js +66 -0
- package/lib-module/Pagination/Pagination.js +153 -0
- package/lib-module/Pagination/SideButton.js +106 -0
- package/lib-module/Pagination/dictionary.js +18 -0
- package/lib-module/Pagination/index.js +2 -0
- package/lib-module/Pagination/usePagination.js +73 -0
- package/lib-module/Progress/Progress.js +89 -0
- package/lib-module/Progress/ProgressBar.js +138 -0
- package/lib-module/Progress/ProgressBarBackground.js +42 -0
- package/lib-module/Progress/index.js +4 -0
- package/lib-module/Radio/Radio.js +285 -0
- package/lib-module/Radio/RadioButton.js +138 -0
- package/lib-module/Radio/RadioGroup.js +243 -0
- package/lib-module/Radio/RadioInput.js +62 -0
- package/lib-module/Radio/RadioInput.native.js +6 -0
- package/lib-module/Radio/index.js +3 -0
- package/lib-module/RadioCard/RadioCard.js +219 -0
- package/lib-module/RadioCard/RadioCardGroup.js +250 -0
- package/lib-module/RadioCard/index.js +3 -0
- package/lib-module/Search/Search.js +261 -0
- package/lib-module/Search/dictionary.js +12 -0
- package/lib-module/Search/index.js +2 -0
- package/lib-module/Select/Group.js +21 -0
- package/lib-module/Select/Group.native.js +15 -0
- package/lib-module/Select/Item.js +20 -0
- package/lib-module/Select/Item.native.js +3 -0
- package/lib-module/Select/Picker.js +68 -0
- package/lib-module/Select/Picker.native.js +120 -0
- package/lib-module/Select/Select.js +337 -0
- package/lib-module/Select/index.js +6 -0
- package/lib-module/SideNav/Item.js +145 -0
- package/lib-module/SideNav/ItemContent.js +48 -0
- package/lib-module/SideNav/ItemsGroup.js +117 -0
- package/lib-module/SideNav/SideNav.js +136 -0
- package/lib-module/SideNav/index.js +1 -0
- package/lib-module/Skeleton/Skeleton.js +179 -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 +98 -0
- package/lib-module/Spacer/index.js +2 -0
- package/lib-module/StackView/StackView.js +125 -0
- package/lib-module/StackView/StackWrap.js +50 -0
- package/lib-module/StackView/StackWrap.native.js +3 -0
- package/lib-module/StackView/StackWrapBox.js +115 -0
- package/lib-module/StackView/StackWrapGap.js +59 -0
- package/lib-module/StackView/common.js +35 -0
- package/lib-module/StackView/getStackedContent.js +124 -0
- package/lib-module/StackView/index.js +5 -0
- package/lib-module/StepTracker/Step.js +248 -0
- package/lib-module/StepTracker/StepTracker.js +185 -0
- package/lib-module/StepTracker/dictionary.js +10 -0
- package/lib-module/StepTracker/index.js +2 -0
- package/lib-module/Tabs/Tabs.js +143 -0
- package/lib-module/Tabs/TabsItem.js +224 -0
- package/lib-module/Tabs/index.js +2 -0
- package/lib-module/Tags/Tags.js +251 -0
- package/lib-module/Tags/index.js +2 -0
- package/lib-module/TextInput/TextArea.js +94 -0
- package/lib-module/TextInput/TextInput.js +72 -0
- package/lib-module/TextInput/TextInputBase.js +245 -0
- package/lib-module/TextInput/index.js +3 -0
- package/lib-module/TextInput/propTypes.js +37 -0
- package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
- package/lib-module/ThemeProvider/index.js +6 -0
- package/lib-module/ThemeProvider/useSetTheme.js +25 -0
- package/lib-module/ThemeProvider/useTheme.js +14 -0
- package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
- package/lib-module/ThemeProvider/utils/index.js +2 -0
- package/lib-module/ThemeProvider/utils/styles.js +181 -0
- package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
- package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
- package/lib-module/ToggleSwitch/index.js +3 -0
- package/lib-module/Tooltip/Backdrop.js +45 -0
- package/lib-module/Tooltip/Backdrop.native.js +44 -0
- package/lib-module/Tooltip/Tooltip.js +348 -0
- package/lib-module/Tooltip/dictionary.js +8 -0
- package/lib-module/Tooltip/getTooltipPosition.js +175 -0
- package/lib-module/Tooltip/index.js +2 -0
- package/lib-module/TooltipButton/TooltipButton.js +78 -0
- package/lib-module/TooltipButton/index.js +2 -0
- package/lib-module/Typography/Typography.js +124 -0
- package/lib-module/Typography/index.js +2 -0
- package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
- package/lib-module/ViewportProvider/index.js +3 -0
- package/lib-module/ViewportProvider/useViewport.js +3 -0
- package/lib-module/ViewportProvider/useViewportListener.js +46 -0
- package/lib-module/index.js +48 -0
- package/lib-module/utils/a11y/index.js +2 -0
- package/lib-module/utils/a11y/semantics.js +157 -0
- package/lib-module/utils/a11y/textSize.js +36 -0
- package/lib-module/utils/animation/index.js +2 -0
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
- package/lib-module/utils/children.js +119 -0
- package/lib-module/utils/containUniqueFields.js +26 -0
- package/lib-module/utils/index.js +16 -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 +179 -0
- package/lib-module/utils/pressability.js +111 -0
- package/lib-module/utils/props/a11yProps.js +140 -0
- package/lib-module/utils/props/clickProps.js +26 -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 +9 -0
- package/lib-module/utils/props/handlerProps.js +65 -0
- package/lib-module/utils/props/hrefAttrsProp.js +33 -0
- package/lib-module/utils/props/index.js +19 -0
- package/lib-module/utils/props/inputSupportsProps.js +62 -0
- package/lib-module/utils/props/linkProps.js +44 -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/textInputProps.js +194 -0
- package/lib-module/utils/props/textProps.js +59 -0
- package/lib-module/utils/props/tokens.js +133 -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 +38 -0
- package/lib-module/utils/useCopy.js +44 -0
- package/lib-module/utils/useHash.js +45 -0
- package/lib-module/utils/useHash.native.js +7 -0
- package/lib-module/utils/useResponsiveProp.js +47 -0
- package/lib-module/utils/useSpacingScale.js +125 -0
- package/lib-module/utils/useUniqueId.js +13 -0
- package/lib-module/utils/withLinkRouter.js +83 -0
- package/package.json +3 -2
- package/src/Checkbox/Checkbox.jsx +3 -1
- package/src/ExpandCollapse/Panel.jsx +2 -19
- package/src/Link/InlinePressable.jsx +5 -2
- package/src/Link/LinkBase.jsx +4 -1
- package/src/List/List.jsx +34 -19
- package/src/List/ListItem.jsx +12 -2
- package/src/Modal/Modal.jsx +2 -1
- package/src/Tabs/Tabs.jsx +24 -2
- package/src/Tabs/TabsItem.jsx +6 -5
- package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
|
@@ -15,11 +15,11 @@ import { Pressable, StyleSheet } from 'react-native'
|
|
|
15
15
|
*/
|
|
16
16
|
// React Native exports prop Types but not propTypes, use JSDoc types here rather than duplicate RN
|
|
17
17
|
// eslint-disable-next-line react/prop-types
|
|
18
|
-
const InlinePressable = forwardRef(({ children, style, ...props }, ref) => (
|
|
18
|
+
const InlinePressable = forwardRef(({ children, style, inline = false, ...props }, ref) => (
|
|
19
19
|
<Pressable
|
|
20
20
|
ref={ref}
|
|
21
21
|
style={(pressState) => [
|
|
22
|
-
staticStyles
|
|
22
|
+
staticStyles[inline ? 'inline' : 'inlineFlex'],
|
|
23
23
|
typeof style === 'function' ? style(pressState) : style
|
|
24
24
|
]}
|
|
25
25
|
{...props}
|
|
@@ -32,6 +32,9 @@ InlinePressable.displayName = 'InlinePressable'
|
|
|
32
32
|
const staticStyles = StyleSheet.create({
|
|
33
33
|
inline: {
|
|
34
34
|
// Stop Pressable defaulting to (block) flex
|
|
35
|
+
display: 'inline'
|
|
36
|
+
},
|
|
37
|
+
inlineFlex: {
|
|
35
38
|
display: 'inline-flex'
|
|
36
39
|
}
|
|
37
40
|
})
|
package/src/Link/LinkBase.jsx
CHANGED
|
@@ -132,18 +132,21 @@ const LinkBase = forwardRef(
|
|
|
132
132
|
const resolveLinkTokens = (pressState) =>
|
|
133
133
|
resolvePressableTokens(tokens, pressState, { iconPosition })
|
|
134
134
|
|
|
135
|
+
const defaultThemeTokens = resolveLinkTokens({})
|
|
136
|
+
const hasIcon = Boolean(icon || defaultThemeTokens.icon)
|
|
137
|
+
|
|
135
138
|
// On web, this makes focus rings wrap only the link, not the entire block
|
|
136
139
|
const blockLeftStyle = Platform.OS === 'web' && staticStyles.blockLeft
|
|
137
140
|
|
|
138
141
|
return (
|
|
139
142
|
<InlinePressable
|
|
140
143
|
{...selectedProps}
|
|
144
|
+
inline={hasIcon} // assuming links without icons should be inline (even if they are long)
|
|
141
145
|
ref={ref}
|
|
142
146
|
style={(linkState) => {
|
|
143
147
|
const themeTokens = resolveLinkTokens(linkState)
|
|
144
148
|
const outerBorderStyles = selectOuterBorderStyles(themeTokens)
|
|
145
149
|
const decorationStyles = selectDecorationStyles(themeTokens)
|
|
146
|
-
const hasIcon = Boolean(icon || themeTokens.icon)
|
|
147
150
|
return [
|
|
148
151
|
outerBorderStyles,
|
|
149
152
|
blockLeftStyle,
|
package/src/List/List.jsx
CHANGED
|
@@ -17,26 +17,41 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
|
|
|
17
17
|
* An unordered List component has a child a ListItem that
|
|
18
18
|
* allows icon, dividers and customized typography
|
|
19
19
|
*/
|
|
20
|
-
const List = forwardRef(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
const List = forwardRef(
|
|
21
|
+
(
|
|
22
|
+
{
|
|
23
|
+
children,
|
|
24
|
+
showDivider,
|
|
25
|
+
tokens,
|
|
26
|
+
variant,
|
|
27
|
+
accessibilityRole = Platform.select({ web: 'list', default: undefined }),
|
|
28
|
+
...rest
|
|
29
|
+
},
|
|
30
|
+
ref
|
|
31
|
+
) => {
|
|
32
|
+
const items = Children.map(children, (child, index) => {
|
|
33
|
+
// Pass ListItem-specific props to children (by name so teams can add their own ListItems)
|
|
34
|
+
const isListItem = (componentName) => Boolean(componentName === ListItem.displayName)
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
if (isListItem(child?.type?.displayName) || isListItem(child?.type?.name)) {
|
|
37
|
+
return cloneElement(child, {
|
|
38
|
+
showDivider,
|
|
39
|
+
isLastItem: index + 1 === Children.count(children),
|
|
40
|
+
tokens,
|
|
41
|
+
variant,
|
|
42
|
+
...child.props
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
return child
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<View ref={ref} accessibilityRole={accessibilityRole} {...selectProps(rest)}>
|
|
50
|
+
{items}
|
|
51
|
+
</View>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
)
|
|
40
55
|
List.displayName = 'List'
|
|
41
56
|
|
|
42
57
|
List.propTypes = {
|
package/src/List/ListItem.jsx
CHANGED
|
@@ -65,7 +65,18 @@ const selectDividerStyles = ({ dividerColor, dividerSize, interItemMarginWithDiv
|
|
|
65
65
|
*/
|
|
66
66
|
const ListItem = forwardRef(
|
|
67
67
|
(
|
|
68
|
-
{
|
|
68
|
+
{
|
|
69
|
+
tokens,
|
|
70
|
+
variant,
|
|
71
|
+
icon,
|
|
72
|
+
iconColor,
|
|
73
|
+
iconSize,
|
|
74
|
+
showDivider,
|
|
75
|
+
children,
|
|
76
|
+
isLastItem,
|
|
77
|
+
accessibilityRole = Platform.select({ web: 'listitem', default: undefined }),
|
|
78
|
+
...rest
|
|
79
|
+
},
|
|
69
80
|
ref
|
|
70
81
|
) => {
|
|
71
82
|
const themeTokens = useThemeTokens('List', tokens, variant)
|
|
@@ -78,7 +89,6 @@ const ListItem = forwardRef(
|
|
|
78
89
|
const itemBulletPositioningStyles = selectBulletPositioningStyles(themeTokens)
|
|
79
90
|
const iconTokens = selectItemIconTokens(themeTokens)
|
|
80
91
|
const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens)
|
|
81
|
-
const accessibilityRole = Platform.select({ web: 'listitem', default: 'item' })
|
|
82
92
|
|
|
83
93
|
const renderItem = () => (
|
|
84
94
|
<View style={staticStyles.wrap}>{wrapStringsInText(children, { style: itemStyles })}</View>
|
package/src/Modal/Modal.jsx
CHANGED
package/src/Tabs/Tabs.jsx
CHANGED
|
@@ -23,9 +23,24 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
|
|
|
23
23
|
|
|
24
24
|
const { selectHorizontalScrollTokens, useItemPositions } = horizontalScrollUtils
|
|
25
25
|
|
|
26
|
+
const getDefaultTabItemAccessibilityRole = (parentRole) => {
|
|
27
|
+
switch (parentRole) {
|
|
28
|
+
case 'tablist':
|
|
29
|
+
return 'tab'
|
|
30
|
+
case 'navigation':
|
|
31
|
+
return 'link'
|
|
32
|
+
default:
|
|
33
|
+
return undefined
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
/**
|
|
27
38
|
* Tabs renders a horizontally-scrolling menu of selectable buttons which may link
|
|
28
39
|
* to a page or control what content is displayed on this page.
|
|
40
|
+
*
|
|
41
|
+
* If you are using Tabs to navigate to a new page (web-only) you should pass
|
|
42
|
+
* `navigation`as the `accessibilityRole` to te Tabs component, this will cause
|
|
43
|
+
* TabItems to default to a role of link and obtain aria-current behaviour.
|
|
29
44
|
*/
|
|
30
45
|
const Tabs = forwardRef(
|
|
31
46
|
(
|
|
@@ -61,6 +76,11 @@ const Tabs = forwardRef(
|
|
|
61
76
|
isPositioningReady
|
|
62
77
|
)
|
|
63
78
|
|
|
79
|
+
const restProps = selectProps(rest)
|
|
80
|
+
const parentAccessibilityRole = restProps.accessibilityRole ?? 'tablist'
|
|
81
|
+
const defaultTabItemAccessibiltyRole =
|
|
82
|
+
getDefaultTabItemAccessibilityRole(parentAccessibilityRole)
|
|
83
|
+
|
|
64
84
|
return (
|
|
65
85
|
<HorizontalScroll
|
|
66
86
|
ref={ref}
|
|
@@ -68,8 +88,8 @@ const Tabs = forwardRef(
|
|
|
68
88
|
itemPositions={itemPositions}
|
|
69
89
|
tokens={selectHorizontalScrollTokens(themeTokens)}
|
|
70
90
|
scrollButtonTokens={scrollButtonTokens}
|
|
71
|
-
accessibilityRole=
|
|
72
|
-
{...
|
|
91
|
+
accessibilityRole={parentAccessibilityRole}
|
|
92
|
+
{...restProps}
|
|
73
93
|
>
|
|
74
94
|
<StackView space={space} direction="row">
|
|
75
95
|
{items.map(
|
|
@@ -78,6 +98,7 @@ const Tabs = forwardRef(
|
|
|
78
98
|
href,
|
|
79
99
|
label,
|
|
80
100
|
id,
|
|
101
|
+
accessibilityRole = defaultTabItemAccessibiltyRole,
|
|
81
102
|
ref: itemRef,
|
|
82
103
|
LinkRouter: ItemLinkRouter = LinkRouter,
|
|
83
104
|
linkRouterProps: itemLinkRouterProps
|
|
@@ -98,6 +119,7 @@ const Tabs = forwardRef(
|
|
|
98
119
|
selected={isSelected}
|
|
99
120
|
itemPositions={itemPositions}
|
|
100
121
|
index={index}
|
|
122
|
+
accessibilityRole={accessibilityRole}
|
|
101
123
|
LinkRouter={ItemLinkRouter}
|
|
102
124
|
linkRouterProps={{ ...linkRouterProps, ...itemLinkRouterProps }}
|
|
103
125
|
>
|
package/src/Tabs/TabsItem.jsx
CHANGED
|
@@ -86,11 +86,11 @@ const TabsItem = forwardRef(
|
|
|
86
86
|
itemPositions,
|
|
87
87
|
index,
|
|
88
88
|
children,
|
|
89
|
-
accessibilityRole
|
|
90
|
-
|
|
91
|
-
?
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
accessibilityRole,
|
|
90
|
+
accessibilityCurrent = Platform.OS === 'web' && accessibilityRole === 'link' && selected
|
|
91
|
+
? 'page'
|
|
92
|
+
: undefined,
|
|
93
|
+
accessibilityState = accessibilityRole === 'tab' ? { selected } : undefined,
|
|
94
94
|
...rawRest
|
|
95
95
|
},
|
|
96
96
|
ref
|
|
@@ -121,6 +121,7 @@ const TabsItem = forwardRef(
|
|
|
121
121
|
|
|
122
122
|
const selectedProps = selectProps({
|
|
123
123
|
accessibilityRole,
|
|
124
|
+
accessibilityCurrent,
|
|
124
125
|
accessibilityState,
|
|
125
126
|
...rest
|
|
126
127
|
})
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react'
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
|
2
2
|
import { Animated, Easing, Platform } from 'react-native'
|
|
3
3
|
|
|
4
4
|
// TODO: systematise animations
|
|
5
5
|
// https://github.com/telus/universal-design-system/issues/487
|
|
6
6
|
function useVerticalExpandAnimation({ containerHeight, isExpanded, tokens }) {
|
|
7
7
|
const [isAnimating, setIsAnimating] = useState(false)
|
|
8
|
+
const [wasExpanded, setWasExpanded] = useState(isExpanded)
|
|
9
|
+
const expandStateChanged = isExpanded !== wasExpanded
|
|
8
10
|
|
|
9
11
|
const expandAnimatedValue = useRef(new Animated.Value(0)).current
|
|
10
12
|
const elementRef = useRef(null)
|
|
11
13
|
|
|
12
14
|
const { expandDuration, collapseDuration } = tokens
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
if (expandStateChanged) {
|
|
18
|
+
setIsAnimating(true)
|
|
19
|
+
setWasExpanded(isExpanded)
|
|
20
|
+
}
|
|
21
|
+
}, [expandStateChanged, isExpanded])
|
|
16
22
|
|
|
17
23
|
useEffect(() => {
|
|
18
|
-
const onComplete = () =>
|
|
24
|
+
const onComplete = () => setIsAnimating(false)
|
|
19
25
|
|
|
20
26
|
if (Platform.OS === 'web') {
|
|
21
27
|
if (!elementRef.current) return () => {}
|
|
@@ -39,19 +45,47 @@ function useVerticalExpandAnimation({ containerHeight, isExpanded, tokens }) {
|
|
|
39
45
|
return () => animation.stop()
|
|
40
46
|
}, [isExpanded, expandAnimatedValue, containerHeight, expandDuration, collapseDuration])
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
const containerStyles = !isExpanded && !isAnimating ? { visibility: 'hidden' } : {}
|
|
48
|
+
const containerStyles = {}
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
if (containerHeight !== null) {
|
|
47
|
-
if (Platform.OS === 'web') {
|
|
48
|
-
const transitionDuration = isExpanded ? expandDuration : collapseDuration
|
|
49
|
-
containerStyles.transition = `height ${transitionDuration}ms ease-in-out`
|
|
50
|
+
if (isAnimating || expandStateChanged) containerStyles.overflow = 'hidden'
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
if (!isExpanded && !isAnimating && !expandStateChanged) {
|
|
53
|
+
if (Platform.OS === 'web') {
|
|
54
|
+
// Without `visibility: 'hidden', descendents are focusable on web even when collapsed.
|
|
55
|
+
containerStyles.visibility = 'hidden'
|
|
52
56
|
} else {
|
|
53
|
-
|
|
57
|
+
// There's no `visibility: hidden` in React Native, and display: none causes a flicker on expand.
|
|
58
|
+
// Without some form of hiding, some children leak through even when closed e.g. `List.Item` bullets.
|
|
59
|
+
containerStyles.opacity = 0
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// don't visually collapse the container until we have it measured
|
|
64
|
+
if (containerHeight === null) {
|
|
65
|
+
if (Platform.OS === 'web') {
|
|
66
|
+
// on web we can hide the contents until we have the container measured and avoid occasional jitter
|
|
67
|
+
// this won't work on native platforms
|
|
68
|
+
containerStyles.height = 0
|
|
69
|
+
containerStyles.visibility = 'hidden'
|
|
54
70
|
}
|
|
71
|
+
} else if (Platform.OS === 'web') {
|
|
72
|
+
const transitionDuration = isExpanded ? expandDuration : collapseDuration
|
|
73
|
+
containerStyles.transition = `height ${transitionDuration}ms ease-in-out`
|
|
74
|
+
|
|
75
|
+
containerStyles.height = isExpanded ? containerHeight : 0
|
|
76
|
+
} else if (
|
|
77
|
+
Platform.OS === 'ios' &&
|
|
78
|
+
isExpanded &&
|
|
79
|
+
!isAnimating &&
|
|
80
|
+
!expandStateChanged &&
|
|
81
|
+
typeof containerHeight === 'number'
|
|
82
|
+
) {
|
|
83
|
+
// iOS reflows text while the height animation is in progress. Sometimes, it hits a timing bug where
|
|
84
|
+
// it fails to reflow properly after the last animation frame, leaving the last line of text not visible.
|
|
85
|
+
// Force reflow after animation completes with a static height non-identical to the last animated height.
|
|
86
|
+
containerStyles.height = containerHeight + 1
|
|
87
|
+
} else {
|
|
88
|
+
containerStyles.height = expandAnimatedValue
|
|
55
89
|
}
|
|
56
90
|
|
|
57
91
|
return [containerStyles, elementRef]
|