@telus-uds/components-base 1.16.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 +20 -2
- package/component-docs.json +708 -120
- package/lib/BaseProvider/index.js +5 -1
- package/lib/Button/ButtonBase.js +2 -1
- 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/Timeline/Timeline.js +193 -0
- package/lib/Timeline/index.js +13 -0
- package/lib/index.js +28 -1
- package/lib-module/BaseProvider/index.js +4 -1
- package/lib-module/Button/ButtonBase.js +2 -1
- 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/Timeline/Timeline.js +174 -0
- package/lib-module/Timeline/index.js +2 -0
- package/lib-module/index.js +4 -1
- package/package.json +6 -5
- package/src/BaseProvider/index.jsx +2 -1
- package/src/Button/ButtonBase.jsx +2 -2
- 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/Timeline/Timeline.jsx +148 -0
- package/src/Timeline/index.js +3 -0
- package/src/index.js +3 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import { useThemeTokens } from '../ThemeProvider'
|
|
5
|
+
import { useViewport } from '../ViewportProvider'
|
|
6
|
+
import { getTokensPropType, variantProp } from '../utils'
|
|
7
|
+
|
|
8
|
+
import List from '../List'
|
|
9
|
+
import StackWrap from '../StackView/StackWrap'
|
|
10
|
+
import QuickLinksCard from './QuickLinksCard'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* QuickLinks renders a list of interactive items. How it renders these items depends on theme options:
|
|
14
|
+
* - If the theme returns `list` token as true, it renders an ordered list based on List
|
|
15
|
+
* - If the theme returns `button` token as true and `list` as false, it renders a wrapping horizontal bar of buttons
|
|
16
|
+
* - If the theme returns `card` token as true, it wraps the above with a `Card`.
|
|
17
|
+
*/
|
|
18
|
+
const QuickLinks = forwardRef(
|
|
19
|
+
({ tokens, variant, listTokens, cardTokens, children, tag = 'ul', ...rest }, ref) => {
|
|
20
|
+
const viewport = useViewport()
|
|
21
|
+
const { dividers, list, card, stackSpace, stackGap, stackJustify } = useThemeTokens(
|
|
22
|
+
'QuickLinks',
|
|
23
|
+
tokens,
|
|
24
|
+
variant,
|
|
25
|
+
{
|
|
26
|
+
viewport
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
const content = (list && (
|
|
31
|
+
<List ref={ref} tokens={listTokens} showDivider={dividers} tag={tag} {...rest}>
|
|
32
|
+
{children}
|
|
33
|
+
</List>
|
|
34
|
+
)) || (
|
|
35
|
+
<StackWrap
|
|
36
|
+
space={stackSpace}
|
|
37
|
+
gap={stackGap}
|
|
38
|
+
tokens={{ justifyContent: stackJustify }}
|
|
39
|
+
tag={tag}
|
|
40
|
+
{...rest}
|
|
41
|
+
>
|
|
42
|
+
{children}
|
|
43
|
+
</StackWrap>
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
return card ? <QuickLinksCard tokens={cardTokens}>{content}</QuickLinksCard> : content
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
QuickLinks.displayName = 'QuickLinks'
|
|
51
|
+
|
|
52
|
+
QuickLinks.propTypes = {
|
|
53
|
+
tokens: getTokensPropType('QuickLinks'),
|
|
54
|
+
cardTokens: getTokensPropType('Card'),
|
|
55
|
+
listTokens: getTokensPropType('QuickLinksList'),
|
|
56
|
+
tag: PropTypes.string,
|
|
57
|
+
variant: variantProp.propType,
|
|
58
|
+
children: PropTypes.node
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default QuickLinks
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import { useThemeTokens } from '../ThemeProvider'
|
|
5
|
+
import { getTokensPropType, variantProp } from '../utils'
|
|
6
|
+
import CardBase from '../Card/CardBase'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Private subcomponent for use within QuickLinks.
|
|
10
|
+
*
|
|
11
|
+
* Restyled Card with identical behaviour to Card, but themed according to the
|
|
12
|
+
* QuickLinksCard theme rather than the Card theme.
|
|
13
|
+
*/
|
|
14
|
+
const QuickLinksList = ({ tokens, variant, children }) => {
|
|
15
|
+
const themeTokens = useThemeTokens('QuickLinksCard', tokens, variant)
|
|
16
|
+
|
|
17
|
+
return <CardBase tokens={themeTokens}>{children}</CardBase>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
QuickLinksList.propTypes = {
|
|
21
|
+
tokens: getTokensPropType('QuickLinksCard'),
|
|
22
|
+
variant: variantProp.propType,
|
|
23
|
+
children: PropTypes.node
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default QuickLinksList
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import { getTokensPropType, variantProp, withLinkRouter } from '../utils'
|
|
5
|
+
import { useViewport } from '../ViewportProvider'
|
|
6
|
+
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider'
|
|
7
|
+
|
|
8
|
+
import PressableListItemBase from '../List/PressableListItemBase'
|
|
9
|
+
import ButtonBase from '../Button/ButtonBase'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Public component exported as QuickLinks.Item, for use as children of QuickLinks.
|
|
13
|
+
*
|
|
14
|
+
* Receives props injected by QuickLinks and renders the appropriate child component.
|
|
15
|
+
*/
|
|
16
|
+
const QuickLinksItem = forwardRef(({ tokens, variant, children, ...rest }, ref) => {
|
|
17
|
+
const viewport = useViewport()
|
|
18
|
+
const { list } = useThemeTokens('QuickLinks', tokens, variant, { viewport })
|
|
19
|
+
|
|
20
|
+
const themeName = list ? 'QuickLinksList' : 'QuickLinksButton'
|
|
21
|
+
|
|
22
|
+
const getTokens = useThemeTokensCallback(themeName, tokens, variant)
|
|
23
|
+
|
|
24
|
+
return list ? (
|
|
25
|
+
<PressableListItemBase ref={ref} tokens={getTokens} {...rest}>
|
|
26
|
+
{children}
|
|
27
|
+
</PressableListItemBase>
|
|
28
|
+
) : (
|
|
29
|
+
<ButtonBase ref={ref} tokens={getTokens} {...rest}>
|
|
30
|
+
{children}
|
|
31
|
+
</ButtonBase>
|
|
32
|
+
)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
QuickLinksItem.displayName = 'QuickLinksItem'
|
|
36
|
+
|
|
37
|
+
QuickLinksItem.propTypes = {
|
|
38
|
+
...withLinkRouter.propTypes,
|
|
39
|
+
...PressableListItemBase.propTypes,
|
|
40
|
+
...ButtonBase.propTypes,
|
|
41
|
+
tokens: getTokensPropType('QuickLinksList', 'QuickLinksButton'),
|
|
42
|
+
variant: variantProp.propType,
|
|
43
|
+
children: PropTypes.node
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default withLinkRouter(QuickLinksItem)
|
|
@@ -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
|
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'
|