@telus-uds/components-base 1.47.0 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -2
- package/component-docs.json +32 -35
- package/lib/Button/ButtonBase.js +6 -3
- package/lib/ExpandCollapse/Control.js +40 -13
- package/lib/ExpandCollapse/Panel.js +1 -3
- package/lib/List/ListItemBase.js +22 -3
- package/lib/SideNav/Item.js +11 -3
- package/lib/SideNav/ItemContent.js +2 -1
- package/lib/SideNav/ItemsGroup.js +11 -1
- package/lib/Skeleton/Skeleton.js +10 -3
- package/lib/Skeleton/skeleton.constant.js +2 -4
- package/lib/Skeleton/skeletonWebAnimation.js +13 -17
- package/lib/Skeleton/useSkeletonNativeAnimation.js +8 -3
- package/lib-module/Button/ButtonBase.js +6 -3
- package/lib-module/ExpandCollapse/Control.js +39 -13
- package/lib-module/ExpandCollapse/Panel.js +1 -3
- package/lib-module/List/ListItemBase.js +21 -3
- package/lib-module/SideNav/Item.js +10 -3
- package/lib-module/SideNav/ItemContent.js +2 -1
- package/lib-module/SideNav/ItemsGroup.js +11 -1
- package/lib-module/Skeleton/Skeleton.js +10 -3
- package/lib-module/Skeleton/skeleton.constant.js +1 -2
- package/lib-module/Skeleton/skeletonWebAnimation.js +14 -17
- package/lib-module/Skeleton/useSkeletonNativeAnimation.js +9 -4
- package/package.json +2 -2
- package/src/Button/ButtonBase.jsx +6 -2
- package/src/ExpandCollapse/Control.jsx +33 -27
- package/src/ExpandCollapse/Panel.jsx +3 -10
- package/src/Link/LinkBase.jsx +1 -0
- package/src/List/ListItemBase.jsx +18 -4
- package/src/SideNav/Item.jsx +8 -5
- package/src/SideNav/ItemContent.jsx +10 -6
- package/src/SideNav/ItemsGroup.jsx +10 -2
- package/src/SideNav/SideNav.jsx +2 -0
- package/src/Skeleton/Skeleton.jsx +9 -2
- package/src/Skeleton/skeleton.constant.js +0 -1
- package/src/Skeleton/skeletonWebAnimation.js +11 -11
- package/src/Skeleton/useSkeletonNativeAnimation.js +5 -4
- package/src/utils/a11y/semantics.js +7 -7
|
@@ -37,8 +37,15 @@ const ItemsGroup = forwardRef(
|
|
|
37
37
|
const getItemAppearance = (appearance) => ({ ...getAppearance(appearance), type: 'parent' })
|
|
38
38
|
|
|
39
39
|
const getGroupTokens = useThemeTokensCallback('SideNavItemsGroup', tokens, variant)
|
|
40
|
-
const getPanelTokens = (appearance) =>
|
|
41
|
-
|
|
40
|
+
const getPanelTokens = (appearance) => {
|
|
41
|
+
const { panelBorderColor, ...itemsGroupTokens } = getGroupTokens(getAppearance(appearance))
|
|
42
|
+
const groupTokens = {
|
|
43
|
+
...itemsGroupTokens,
|
|
44
|
+
borderWidth: 0,
|
|
45
|
+
marginBottom: 0
|
|
46
|
+
}
|
|
47
|
+
return selectTokens('ExpandCollapsePanel', groupTokens)
|
|
48
|
+
}
|
|
42
49
|
|
|
43
50
|
const getItemTokens = useThemeTokensCallback('SideNavItem', itemTokens, variant)
|
|
44
51
|
const getControlTokens = (appearance) =>
|
|
@@ -49,6 +56,7 @@ const ItemsGroup = forwardRef(
|
|
|
49
56
|
|
|
50
57
|
const controlContent = (controlState) => {
|
|
51
58
|
const currentItemTokens = getItemTokens(getItemAppearance(controlState))
|
|
59
|
+
|
|
52
60
|
return <ItemContent tokens={currentItemTokens}>{label}</ItemContent>
|
|
53
61
|
}
|
|
54
62
|
|
package/src/SideNav/SideNav.jsx
CHANGED
|
@@ -56,6 +56,7 @@ const SideNav = forwardRef(
|
|
|
56
56
|
onItemPress(...args)
|
|
57
57
|
if (onPress) onPress(...args)
|
|
58
58
|
}
|
|
59
|
+
|
|
59
60
|
return (
|
|
60
61
|
<Item
|
|
61
62
|
{...item.props}
|
|
@@ -78,6 +79,7 @@ const SideNav = forwardRef(
|
|
|
78
79
|
const { groupId = `group-${index}` } = child.props
|
|
79
80
|
const isGroupActive = active.itemId !== undefined && active.groupId === groupId
|
|
80
81
|
const handleToggle = (event) => onToggle(groupId, event)
|
|
82
|
+
|
|
81
83
|
return (
|
|
82
84
|
<ItemsGroup
|
|
83
85
|
{...child.props}
|
|
@@ -63,10 +63,17 @@ const Skeleton = forwardRef(
|
|
|
63
63
|
: // Size by an index on the spacing scale (getting default index from theme if none provided)
|
|
64
64
|
sizeIndex || themeTokens.size
|
|
65
65
|
const skeletonHeight = useSpacingScale(spacingScaleValue)
|
|
66
|
-
|
|
66
|
+
|
|
67
|
+
// Animation color and animation duration
|
|
68
|
+
const { secondColor, animationDuration } = themeTokens
|
|
69
|
+
|
|
70
|
+
const nativeAnimation = useSkeletonNativeAnimation({ animationDuration })
|
|
67
71
|
|
|
68
72
|
const getAnimationBasedOnPlatform = () => {
|
|
69
|
-
const animation =
|
|
73
|
+
const animation =
|
|
74
|
+
Platform.OS === 'web'
|
|
75
|
+
? skeletonWebAnimation(secondColor, animationDuration)
|
|
76
|
+
: nativeAnimation
|
|
70
77
|
// We must pass the animation styles through `StyleSheet.create`
|
|
71
78
|
// @see https://github.com/necolas/react-native-web/issues/2387
|
|
72
79
|
const styles = StyleSheet.create({ animation })
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'50%': { opacity: OPACITY_STOP },
|
|
11
|
-
'100%': { opacity: DEFAULT_OPACITY }
|
|
1
|
+
const skeletonWebAnimation = (secondColor, animationTime) => {
|
|
2
|
+
return {
|
|
3
|
+
animationDuration: `${animationTime}ms`,
|
|
4
|
+
animationTimingFunction: 'ease-in-out',
|
|
5
|
+
animationDelay: '0.5s',
|
|
6
|
+
animationIterationCount: 'infinite',
|
|
7
|
+
animationKeyframes: {
|
|
8
|
+
'50%': { backgroundColor: secondColor }
|
|
9
|
+
}
|
|
12
10
|
}
|
|
13
11
|
}
|
|
12
|
+
|
|
13
|
+
export default skeletonWebAnimation
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react'
|
|
2
2
|
import { Animated, Platform } from 'react-native'
|
|
3
|
-
import {
|
|
3
|
+
import { DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant'
|
|
4
4
|
|
|
5
|
-
const useSkeletonNativeAnimation = () => {
|
|
5
|
+
const useSkeletonNativeAnimation = ({ animationDuration }) => {
|
|
6
6
|
const fadeAnimation = useRef(new Animated.Value(DEFAULT_OPACITY)).current
|
|
7
7
|
|
|
8
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
8
9
|
useEffect(() => {
|
|
9
10
|
const fade = Animated.sequence([
|
|
10
11
|
Animated.timing(fadeAnimation, {
|
|
11
12
|
toValue: OPACITY_STOP,
|
|
12
|
-
duration:
|
|
13
|
+
duration: animationDuration,
|
|
13
14
|
useNativeDriver: Platform.OS !== 'web'
|
|
14
15
|
}),
|
|
15
16
|
Animated.timing(fadeAnimation, {
|
|
16
17
|
toValue: DEFAULT_OPACITY,
|
|
17
|
-
duration:
|
|
18
|
+
duration: animationDuration,
|
|
18
19
|
useNativeDriver: Platform.OS !== 'web'
|
|
19
20
|
})
|
|
20
21
|
])
|
|
@@ -23,7 +23,7 @@ import { Platform } from 'react-native'
|
|
|
23
23
|
*/
|
|
24
24
|
// Adding `/** @type {const} */ ({...})` denotes object content as `readonly` in many IDEs
|
|
25
25
|
// eslint-disable-next-line prettier/prettier
|
|
26
|
-
const rolesToTags = /** @type {const} */
|
|
26
|
+
const rolesToTags = /** @type {const} */ {
|
|
27
27
|
article: 'article',
|
|
28
28
|
banner: 'header',
|
|
29
29
|
blockquote: 'blockquote',
|
|
@@ -45,7 +45,7 @@ const rolesToTags = /** @type {const} */ ({
|
|
|
45
45
|
// Add special cases that are in RNW's function logic but not in its mapping object
|
|
46
46
|
label: 'label'
|
|
47
47
|
// eslint-disable-next-line prettier/prettier
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
|
|
50
50
|
// Invert React Native Web's mapping, so a tag gets the role that gets that tag
|
|
51
51
|
export const tagsToRoles = Object.fromEntries(
|
|
@@ -57,7 +57,7 @@ export const tagsToRoles = Object.fromEntries(
|
|
|
57
57
|
* to headings on web but without the expectation of a hierarchy of headings within one screen.
|
|
58
58
|
*/
|
|
59
59
|
// eslint-disable-next-line prettier/prettier
|
|
60
|
-
export const headingTags = /** @type {const} */
|
|
60
|
+
export const headingTags = /** @type {const} */ ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
|
|
61
61
|
/**
|
|
62
62
|
* @typedef {typeof headingTags[number]} HeadingTag
|
|
63
63
|
*/
|
|
@@ -81,7 +81,7 @@ export const supportedTags = [...Object.keys(tagsToRoles), ...headingTags]
|
|
|
81
81
|
* Of these, only headers (h1, h2, ...h5, h6) set a corresponding accessibilityRole in native apps ("heading").
|
|
82
82
|
*/
|
|
83
83
|
// eslint-disable-next-line prettier/prettier
|
|
84
|
-
export const layoutTags = /** @type {const} */
|
|
84
|
+
export const layoutTags = /** @type {const} */ [
|
|
85
85
|
...headingTags,
|
|
86
86
|
'article',
|
|
87
87
|
'aside',
|
|
@@ -97,7 +97,7 @@ export const layoutTags = /** @type {const} */ ([
|
|
|
97
97
|
'section',
|
|
98
98
|
'label'
|
|
99
99
|
// eslint-disable-next-line prettier/prettier
|
|
100
|
-
]
|
|
100
|
+
]
|
|
101
101
|
/**
|
|
102
102
|
* @typedef {typeof layoutTags[number]} LayoutTag
|
|
103
103
|
*/
|
|
@@ -108,7 +108,7 @@ export const layoutTags = /** @type {const} */ ([
|
|
|
108
108
|
* Of these, only headers (h1, h2, ...h5, h6) set a corresponding accessibilityRole in native apps ("heading").
|
|
109
109
|
*/
|
|
110
110
|
// eslint-disable-next-line prettier/prettier
|
|
111
|
-
export const textTags = /** @type {const} */
|
|
111
|
+
export const textTags = /** @type {const} */ [
|
|
112
112
|
...headingTags,
|
|
113
113
|
'blockquote',
|
|
114
114
|
'code',
|
|
@@ -119,7 +119,7 @@ export const textTags = /** @type {const} */ ([
|
|
|
119
119
|
'strong',
|
|
120
120
|
'label'
|
|
121
121
|
// eslint-disable-next-line prettier/prettier
|
|
122
|
-
]
|
|
122
|
+
]
|
|
123
123
|
/**
|
|
124
124
|
* @typedef {typeof layoutTags[number]} TextTag
|
|
125
125
|
*/
|