@telus-uds/components-base 1.15.0 → 1.17.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 +36 -2
- package/component-docs.json +1322 -346
- package/lib/BaseProvider/index.js +5 -1
- package/lib/Button/ButtonBase.js +2 -1
- package/lib/Carousel/Carousel.js +18 -2
- package/lib/Carousel/CarouselTabs/CarouselTabs.js +6 -7
- package/lib/List/List.js +11 -8
- package/lib/List/PressableListItemBase.js +5 -9
- package/lib/QuickLinks/QuickLinks.js +91 -0
- package/lib/QuickLinks/QuickLinksCard.js +47 -0
- package/lib/QuickLinks/QuickLinksItem.js +73 -0
- package/lib/QuickLinks/index.js +16 -0
- package/lib/Skeleton/Skeleton.js +18 -13
- package/lib/Skeleton/useSkeletonNativeAnimation.js +4 -2
- package/lib/Timeline/Timeline.js +193 -0
- package/lib/Timeline/index.js +13 -0
- package/lib/ToggleSwitch/ToggleSwitch.js +24 -19
- package/lib/index.js +28 -1
- package/lib/utils/props/a11yProps.js +50 -47
- package/lib-module/BaseProvider/index.js +4 -1
- package/lib-module/Button/ButtonBase.js +2 -1
- package/lib-module/Carousel/Carousel.js +16 -2
- package/lib-module/Carousel/CarouselTabs/CarouselTabs.js +7 -6
- package/lib-module/List/List.js +12 -8
- package/lib-module/List/PressableListItemBase.js +6 -10
- package/lib-module/QuickLinks/QuickLinks.js +71 -0
- package/lib-module/QuickLinks/QuickLinksCard.js +33 -0
- package/lib-module/QuickLinks/QuickLinksItem.js +50 -0
- package/lib-module/QuickLinks/index.js +4 -0
- package/lib-module/Skeleton/Skeleton.js +15 -13
- package/lib-module/Skeleton/useSkeletonNativeAnimation.js +3 -2
- package/lib-module/Timeline/Timeline.js +174 -0
- package/lib-module/Timeline/index.js +2 -0
- package/lib-module/ToggleSwitch/ToggleSwitch.js +24 -19
- package/lib-module/index.js +4 -1
- package/lib-module/utils/props/a11yProps.js +50 -47
- package/package.json +8 -7
- package/src/BaseProvider/index.jsx +2 -1
- package/src/Button/ButtonBase.jsx +2 -2
- package/src/Carousel/Carousel.jsx +15 -2
- package/src/Carousel/CarouselTabs/CarouselTabs.jsx +5 -3
- package/src/List/List.jsx +9 -13
- package/src/List/PressableListItemBase.jsx +7 -9
- package/src/QuickLinks/QuickLinks.jsx +61 -0
- package/src/QuickLinks/QuickLinksCard.jsx +26 -0
- package/src/QuickLinks/QuickLinksItem.jsx +46 -0
- package/src/QuickLinks/index.js +6 -0
- package/src/Skeleton/Skeleton.jsx +25 -19
- package/src/Skeleton/useSkeletonNativeAnimation.js +3 -3
- package/src/Timeline/Timeline.jsx +148 -0
- package/src/Timeline/index.js +3 -0
- package/src/ToggleSwitch/ToggleSwitch.jsx +3 -3
- package/src/index.js +3 -0
- package/src/utils/props/a11yProps.js +61 -68
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
import { View } from 'react-native'
|
|
4
|
+
|
|
5
|
+
import { useThemeTokens } from '../ThemeProvider'
|
|
6
|
+
import {
|
|
7
|
+
getTokensPropType,
|
|
8
|
+
variantProp,
|
|
9
|
+
a11yProps,
|
|
10
|
+
viewProps,
|
|
11
|
+
selectSystemProps,
|
|
12
|
+
getA11yPropsFromHtmlTag,
|
|
13
|
+
layoutTags
|
|
14
|
+
} from '../utils'
|
|
15
|
+
import { useViewport } from '../ViewportProvider'
|
|
16
|
+
|
|
17
|
+
const selectDotStyles = ({ dotWidth, timelineColor, dotBorderWidth, dotColor }) => ({
|
|
18
|
+
width: dotWidth,
|
|
19
|
+
height: dotWidth,
|
|
20
|
+
borderRadius: dotWidth / 2,
|
|
21
|
+
backgroundColor: dotColor,
|
|
22
|
+
borderWidth: dotBorderWidth,
|
|
23
|
+
borderColor: timelineColor
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const selectConnectorStyles = ({ timelineColor, connectorHeight, connectorWidth }) => ({
|
|
27
|
+
width: connectorWidth,
|
|
28
|
+
height: connectorHeight,
|
|
29
|
+
backgroundColor: timelineColor
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const selectTimelineContainerStyle = ({ timelineContainerDirection }) => ({
|
|
33
|
+
flexDirection: timelineContainerDirection
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const selectLineItemStyles = ({
|
|
37
|
+
lineItemAlign,
|
|
38
|
+
lineItemDirection,
|
|
39
|
+
lineItemMarginBottom,
|
|
40
|
+
lineItemMarginRight
|
|
41
|
+
}) => ({
|
|
42
|
+
alignItems: lineItemAlign,
|
|
43
|
+
flexDirection: lineItemDirection,
|
|
44
|
+
marginBottom: lineItemMarginBottom,
|
|
45
|
+
marginRight: lineItemMarginRight,
|
|
46
|
+
overflow: 'hidden'
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const selectLineItemContainer = ({ lineItemContainerDirection, lineContainerFlexSize }) => ({
|
|
50
|
+
flexDirection: lineItemContainerDirection,
|
|
51
|
+
flex: lineContainerFlexSize
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const selectItemContentStyles = (
|
|
55
|
+
{ itemContentFlexSize, itemContentMarginBottom, itemContentMarginRight },
|
|
56
|
+
isLastChild
|
|
57
|
+
) => {
|
|
58
|
+
return {
|
|
59
|
+
flex: itemContentFlexSize,
|
|
60
|
+
marginBottom: !isLastChild && itemContentMarginBottom,
|
|
61
|
+
marginRight: !isLastChild && itemContentMarginRight
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Timeline is a component that displays either a horizontal or vertical list of the
|
|
69
|
+
* children components passed by props
|
|
70
|
+
*
|
|
71
|
+
* ## Component API
|
|
72
|
+
*
|
|
73
|
+
* - `horizontal` In order to display the Component list horizontally
|
|
74
|
+
*
|
|
75
|
+
*
|
|
76
|
+
* ## A11y guidelines
|
|
77
|
+
* Timeline link supports all the common a11y props.
|
|
78
|
+
*/
|
|
79
|
+
const Timeline = forwardRef(
|
|
80
|
+
(
|
|
81
|
+
{ tokens, variant = {}, children, accessibilityLabel, tag = 'ul', childrenTag = 'li', ...rest },
|
|
82
|
+
ref
|
|
83
|
+
) => {
|
|
84
|
+
const viewport = useViewport()
|
|
85
|
+
const themeTokens = useThemeTokens('Timeline', tokens, variant, { viewport })
|
|
86
|
+
|
|
87
|
+
const containerProps = {
|
|
88
|
+
...selectProps(rest),
|
|
89
|
+
...getA11yPropsFromHtmlTag(tag, rest.accessibilityRole || 'list'),
|
|
90
|
+
accessibilityLabel
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<View {...containerProps} ref={ref} style={selectTimelineContainerStyle(themeTokens)}>
|
|
95
|
+
{children.map((child, index) => {
|
|
96
|
+
const childrenProps = {
|
|
97
|
+
...getA11yPropsFromHtmlTag(childrenTag, child?.props?.accessibilityRole || 'listitem')
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<View
|
|
102
|
+
style={selectLineItemContainer(themeTokens)}
|
|
103
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
104
|
+
key={`timeline-${index}-${child.displayName}`}
|
|
105
|
+
{...childrenProps}
|
|
106
|
+
>
|
|
107
|
+
<View style={selectLineItemStyles(themeTokens)}>
|
|
108
|
+
<View style={selectDotStyles(themeTokens)} />
|
|
109
|
+
<View style={selectConnectorStyles(themeTokens)} />
|
|
110
|
+
</View>
|
|
111
|
+
<View style={selectItemContentStyles(themeTokens, index + 1 === children.length)}>
|
|
112
|
+
{child}
|
|
113
|
+
</View>
|
|
114
|
+
</View>
|
|
115
|
+
)
|
|
116
|
+
})}
|
|
117
|
+
</View>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
Timeline.displayName = 'Timeline'
|
|
123
|
+
|
|
124
|
+
Timeline.propTypes = {
|
|
125
|
+
...selectedSystemPropTypes,
|
|
126
|
+
tokens: getTokensPropType('Timeline'),
|
|
127
|
+
variant: variantProp.propType,
|
|
128
|
+
/**
|
|
129
|
+
* A list of components that will be rendered either horizontally or vertically
|
|
130
|
+
*/
|
|
131
|
+
children: PropTypes.arrayOf(PropTypes.node).isRequired,
|
|
132
|
+
/**
|
|
133
|
+
* A required accessibility label that needs to be passed to be used on List
|
|
134
|
+
* which is applied as normal for a React Native accessibilityLabel prop.
|
|
135
|
+
*/
|
|
136
|
+
accessibilityLabel: PropTypes.string.isRequired,
|
|
137
|
+
/**
|
|
138
|
+
* Sets the HTML tag of the outer container and the children. By default `'li'` for the children
|
|
139
|
+
* and `'ul'` for the container
|
|
140
|
+
*
|
|
141
|
+
* If either `tag` or `childrenTag` is overridden, the other should be too, to avoid producing invalid HTML.
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
tag: PropTypes.oneOf(layoutTags),
|
|
145
|
+
childrenTag: PropTypes.oneOf(layoutTags)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default Timeline
|
|
@@ -26,7 +26,9 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([
|
|
|
26
26
|
viewProps
|
|
27
27
|
])
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
// We need to drop the icon before passing it to the `ButtonBase`, because it's
|
|
30
|
+
// being handled separately in this case
|
|
31
|
+
const selectButtonTokens = ({ icon: _, ...tokens }) =>
|
|
30
32
|
selectTokens('Button', {
|
|
31
33
|
...tokens,
|
|
32
34
|
// Width tokens are applied to our inner track. Disable Button width token so it wraps our track width.
|
|
@@ -215,8 +217,6 @@ ToggleSwitch.propTypes = {
|
|
|
215
217
|
|
|
216
218
|
const staticStyles = StyleSheet.create({
|
|
217
219
|
track: {
|
|
218
|
-
flexGrow: 1,
|
|
219
|
-
alignSelf: 'stretch',
|
|
220
220
|
flexDirection: 'row'
|
|
221
221
|
},
|
|
222
222
|
switch: {
|
package/src/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export { default as Modal } from './Modal'
|
|
|
24
24
|
export { default as Notification } from './Notification'
|
|
25
25
|
export { default as Pagination } from './Pagination'
|
|
26
26
|
export { default as Progress } from './Progress'
|
|
27
|
+
export { default as QuickLinks } from './QuickLinks'
|
|
27
28
|
export { default as Radio } from './Radio'
|
|
28
29
|
export * from './Radio'
|
|
29
30
|
export { default as RadioCard } from './RadioCard'
|
|
@@ -40,6 +41,7 @@ export { default as StepTracker } from './StepTracker'
|
|
|
40
41
|
export { default as Tabs } from './Tabs'
|
|
41
42
|
export { default as Tags } from './Tags'
|
|
42
43
|
export * from './TextInput'
|
|
44
|
+
export { default as Timeline } from './Timeline'
|
|
43
45
|
export * from './ToggleSwitch'
|
|
44
46
|
export { default as Tooltip } from './Tooltip'
|
|
45
47
|
export { default as TooltipButton } from './TooltipButton'
|
|
@@ -60,3 +62,4 @@ export {
|
|
|
60
62
|
} from './ThemeProvider'
|
|
61
63
|
|
|
62
64
|
export * from './utils'
|
|
65
|
+
export { Portal } from '@gorhom/portal'
|
|
@@ -40,75 +40,68 @@ const nativeA11yPropTypes = {
|
|
|
40
40
|
onAccessibilityTap: PropTypes.func
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const a11yPropTypes =
|
|
43
|
+
const a11yPropTypes = {
|
|
44
|
+
...nativeA11yPropTypes,
|
|
44
45
|
// React Native Web adds many a11y props that alias aria-* attributes
|
|
45
46
|
// Types based on https://necolas.github.io/react-native-web/docs/accessibility/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
accessibilitySelected: PropTypes.bool,
|
|
105
|
-
accessibilitySetSize: PropTypes.number,
|
|
106
|
-
accessibilitySort: PropTypes.oneOf(['ascending', 'descending', 'none', 'other']),
|
|
107
|
-
accessibilityValueMax: PropTypes.number,
|
|
108
|
-
accessibilityValueMin: PropTypes.number,
|
|
109
|
-
accessibilityValueNow: PropTypes.number,
|
|
110
|
-
accessibilityValueText: PropTypes.string
|
|
111
|
-
},
|
|
47
|
+
accessibilityActiveDescendant: PropTypes.string,
|
|
48
|
+
accessibilityAtomic: PropTypes.bool,
|
|
49
|
+
accessibilityAutoComplete: PropTypes.string,
|
|
50
|
+
accessibilityBusy: PropTypes.bool,
|
|
51
|
+
accessibilityChecked: PropTypes.oneOf([true, false, 'mixed']),
|
|
52
|
+
accessibilityColumnCount: PropTypes.number,
|
|
53
|
+
accessibilityColumnIndex: PropTypes.number,
|
|
54
|
+
accessibilityColumnSpan: PropTypes.number,
|
|
55
|
+
accessibilityControls: PropTypes.oneOfType([
|
|
56
|
+
PropTypes.string,
|
|
57
|
+
PropTypes.arrayOf(PropTypes.string)
|
|
58
|
+
]),
|
|
59
|
+
accessibilityCurrent: PropTypes.oneOf([true, false, 'page', 'step', 'location', 'date', 'time']),
|
|
60
|
+
accessibilityDescribedBy: PropTypes.oneOfType([
|
|
61
|
+
PropTypes.string,
|
|
62
|
+
PropTypes.arrayOf(PropTypes.string)
|
|
63
|
+
]),
|
|
64
|
+
accessibilityDetails: PropTypes.string,
|
|
65
|
+
accessibilityDisabled: PropTypes.bool,
|
|
66
|
+
accessibilityErrorMessage: PropTypes.string,
|
|
67
|
+
accessibilityExpanded: PropTypes.bool,
|
|
68
|
+
accessibilityFlowTo: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
|
69
|
+
accessibilityHasPopup: PropTypes.string,
|
|
70
|
+
accessibilityHidden: PropTypes.bool,
|
|
71
|
+
accessibilityInvalid: PropTypes.bool,
|
|
72
|
+
accessibilityKeyShortcuts: PropTypes.string,
|
|
73
|
+
accessibilityLabelledBy: PropTypes.oneOfType([
|
|
74
|
+
PropTypes.string,
|
|
75
|
+
PropTypes.arrayOf(PropTypes.string)
|
|
76
|
+
]),
|
|
77
|
+
accessibilityLevel: PropTypes.number,
|
|
78
|
+
accessibilityModal: PropTypes.bool,
|
|
79
|
+
accessibilityMultiline: PropTypes.bool,
|
|
80
|
+
accessibilityMultiSelectable: PropTypes.bool,
|
|
81
|
+
accessibilityOrientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
82
|
+
accessibilityOwns: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
|
83
|
+
accessibilityPlaceholder: PropTypes.string,
|
|
84
|
+
accessibilityPosInSet: PropTypes.number,
|
|
85
|
+
accessibilityPressed: PropTypes.bool,
|
|
86
|
+
accessibilityReadOnly: PropTypes.bool,
|
|
87
|
+
accessibilityRequired: PropTypes.bool,
|
|
88
|
+
accessibilityRoleDescription: PropTypes.string,
|
|
89
|
+
accessibilityRowCount: PropTypes.number,
|
|
90
|
+
accessibilityRowIndex: PropTypes.number,
|
|
91
|
+
accessibilityRowSpan: PropTypes.number,
|
|
92
|
+
accessibilitySelected: PropTypes.bool,
|
|
93
|
+
accessibilitySetSize: PropTypes.number,
|
|
94
|
+
accessibilitySort: PropTypes.oneOf(['ascending', 'descending', 'none', 'other']),
|
|
95
|
+
accessibilityValueMax: PropTypes.number,
|
|
96
|
+
accessibilityValueMin: PropTypes.number,
|
|
97
|
+
accessibilityValueNow: PropTypes.number,
|
|
98
|
+
accessibilityValueText: PropTypes.string
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const a11yPropTypesByPlatform = Platform.select({
|
|
102
|
+
// React Native Web adds many a11y props that alias aria-* attributes
|
|
103
|
+
// Types based on https://necolas.github.io/react-native-web/docs/accessibility/
|
|
104
|
+
web: a11yPropTypes,
|
|
112
105
|
// Ignore web-only props in native builds
|
|
113
106
|
default: nativeA11yPropTypes
|
|
114
107
|
})
|
|
@@ -214,7 +207,7 @@ export default {
|
|
|
214
207
|
*/
|
|
215
208
|
select: getPropSelector(
|
|
216
209
|
// Allow all React Native accessibility props
|
|
217
|
-
|
|
210
|
+
a11yPropTypesByPlatform,
|
|
218
211
|
// Allow any `aria-*` attribute on web; ignore them on native
|
|
219
212
|
Platform.OS === 'web' && /^aria-/,
|
|
220
213
|
// For the props added and deprecated in React Native Web 0.18, convert them to
|