@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
|
@@ -171,11 +171,12 @@ const selectWebOnlyStyles = (inactive, themeTokens, _ref7) => {
|
|
|
171
171
|
const selectItemIconTokens = _ref8 => {
|
|
172
172
|
let {
|
|
173
173
|
color,
|
|
174
|
+
iconColor,
|
|
174
175
|
iconSize
|
|
175
176
|
} = _ref8;
|
|
176
177
|
return {
|
|
177
178
|
size: iconSize,
|
|
178
|
-
color
|
|
179
|
+
color: iconColor || color
|
|
179
180
|
};
|
|
180
181
|
};
|
|
181
182
|
|
package/lib-module/List/List.js
CHANGED
|
@@ -2,15 +2,23 @@ import React, { cloneElement, forwardRef, Children } from 'react';
|
|
|
2
2
|
import View from "react-native-web/dist/exports/View";
|
|
3
3
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { a11yProps,
|
|
6
|
-
import ListItem from './ListItem';
|
|
5
|
+
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
|
|
7
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
7
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
8
|
+
|
|
9
|
+
const isListItem = element => {
|
|
10
|
+
var _element$type, _element$type2;
|
|
11
|
+
|
|
12
|
+
const elementName = (element === null || element === void 0 ? void 0 : (_element$type = element.type) === null || _element$type === void 0 ? void 0 : _element$type.displayName) || (element === null || element === void 0 ? void 0 : (_element$type2 = element.type) === null || _element$type2 === void 0 ? void 0 : _element$type2.name); // Match our own ListItem, and also, custom list items
|
|
13
|
+
|
|
14
|
+
return Boolean(elementName.match(/Item/));
|
|
15
|
+
};
|
|
9
16
|
/**
|
|
10
17
|
* An unordered List component has a child a ListItem that
|
|
11
18
|
* allows icon, dividers and customized typography
|
|
12
19
|
*/
|
|
13
20
|
|
|
21
|
+
|
|
14
22
|
const List = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
15
23
|
let {
|
|
16
24
|
children,
|
|
@@ -24,12 +32,8 @@ const List = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
24
32
|
...rest
|
|
25
33
|
} = _ref;
|
|
26
34
|
const items = Children.map(children, (child, index) => {
|
|
27
|
-
var _child$type, _child$type2;
|
|
28
|
-
|
|
29
35
|
// Pass ListItem-specific props to children (by name so teams can add their own ListItems)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (isListItem(child === null || child === void 0 ? void 0 : (_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) || isListItem(child === null || child === void 0 ? void 0 : (_child$type2 = child.type) === null || _child$type2 === void 0 ? void 0 : _child$type2.name)) {
|
|
36
|
+
if (isListItem(child)) {
|
|
33
37
|
return /*#__PURE__*/cloneElement(child, {
|
|
34
38
|
showDivider,
|
|
35
39
|
isLastItem: index + 1 === Children.count(children),
|
|
@@ -52,7 +56,7 @@ List.displayName = 'List';
|
|
|
52
56
|
List.propTypes = { ...selectedSystemPropTypes,
|
|
53
57
|
tokens: getTokensPropType('List'),
|
|
54
58
|
variant: variantProp.propType,
|
|
55
|
-
children:
|
|
59
|
+
children: PropTypes.node,
|
|
56
60
|
|
|
57
61
|
/**
|
|
58
62
|
* In case it is not the last item allow display divider
|
|
@@ -4,10 +4,10 @@ import ABBPropTypes from 'airbnb-prop-types';
|
|
|
4
4
|
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
5
5
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
6
6
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
7
|
-
import { resolvePressableTokens, clickProps, linkProps, hrefAttrsProp, withLinkRouter } from '../utils';
|
|
7
|
+
import { resolvePressableTokens, clickProps, linkProps, hrefAttrsProp, selectTokens, withLinkRouter } from '../utils';
|
|
8
8
|
import ListItemBase from './ListItemBase';
|
|
9
|
-
import ListItemContent
|
|
10
|
-
import ListItemMark
|
|
9
|
+
import ListItemContent from './ListItemContent';
|
|
10
|
+
import ListItemMark from './ListItemMark';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -57,9 +57,10 @@ const PressableListItemBase = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
57
57
|
href,
|
|
58
58
|
onPress
|
|
59
59
|
});
|
|
60
|
+
const listItemTokens = selectTokens('List', typeof tokens === 'function' ? tokens() : tokens);
|
|
60
61
|
return /*#__PURE__*/_jsx(ListItemBase, {
|
|
61
62
|
ref: listItemRef,
|
|
62
|
-
tokens:
|
|
63
|
+
tokens: listItemTokens,
|
|
63
64
|
...listItemProps,
|
|
64
65
|
children: _ref3 => {
|
|
65
66
|
let {
|
|
@@ -99,16 +100,11 @@ const staticStyles = StyleSheet.create({
|
|
|
99
100
|
itemContainer: {
|
|
100
101
|
flexDirection: 'row',
|
|
101
102
|
flex: 1
|
|
102
|
-
},
|
|
103
|
-
tokens: { ...contentTokenTypes,
|
|
104
|
-
...markTokenTypes
|
|
105
103
|
}
|
|
106
104
|
});
|
|
107
|
-
PressableListItemBase.propTypes = {
|
|
105
|
+
PressableListItemBase.propTypes = { ...withLinkRouter.propTypes,
|
|
108
106
|
href: PropTypes.string,
|
|
109
107
|
onPress: PropTypes.func,
|
|
110
|
-
// TODO - type this better, maybe import the subcomponent token types and run it through util
|
|
111
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
112
108
|
tokens: PropTypes.any,
|
|
113
109
|
icon: PropTypes.elementType,
|
|
114
110
|
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
4
|
+
import { useViewport } from '../ViewportProvider';
|
|
5
|
+
import { getTokensPropType, variantProp } from '../utils';
|
|
6
|
+
import List from '../List';
|
|
7
|
+
import StackWrap from '../StackView/StackWrap';
|
|
8
|
+
import QuickLinksCard from './QuickLinksCard';
|
|
9
|
+
/**
|
|
10
|
+
* QuickLinks renders a list of interactive items. How it renders these items depends on theme options:
|
|
11
|
+
* - If the theme returns `list` token as true, it renders an ordered list based on List
|
|
12
|
+
* - If the theme returns `button` token as true and `list` as false, it renders a wrapping horizontal bar of buttons
|
|
13
|
+
* - If the theme returns `card` token as true, it wraps the above with a `Card`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
const QuickLinks = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
18
|
+
let {
|
|
19
|
+
tokens,
|
|
20
|
+
variant,
|
|
21
|
+
listTokens,
|
|
22
|
+
cardTokens,
|
|
23
|
+
children,
|
|
24
|
+
tag = 'ul',
|
|
25
|
+
...rest
|
|
26
|
+
} = _ref;
|
|
27
|
+
const viewport = useViewport();
|
|
28
|
+
const {
|
|
29
|
+
dividers,
|
|
30
|
+
list,
|
|
31
|
+
card,
|
|
32
|
+
stackSpace,
|
|
33
|
+
stackGap,
|
|
34
|
+
stackJustify
|
|
35
|
+
} = useThemeTokens('QuickLinks', tokens, variant, {
|
|
36
|
+
viewport
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const content = list && /*#__PURE__*/_jsx(List, {
|
|
40
|
+
ref: ref,
|
|
41
|
+
tokens: listTokens,
|
|
42
|
+
showDivider: dividers,
|
|
43
|
+
tag: tag,
|
|
44
|
+
...rest,
|
|
45
|
+
children: children
|
|
46
|
+
}) || /*#__PURE__*/_jsx(StackWrap, {
|
|
47
|
+
space: stackSpace,
|
|
48
|
+
gap: stackGap,
|
|
49
|
+
tokens: {
|
|
50
|
+
justifyContent: stackJustify
|
|
51
|
+
},
|
|
52
|
+
tag: tag,
|
|
53
|
+
...rest,
|
|
54
|
+
children: children
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return card ? /*#__PURE__*/_jsx(QuickLinksCard, {
|
|
58
|
+
tokens: cardTokens,
|
|
59
|
+
children: content
|
|
60
|
+
}) : content;
|
|
61
|
+
});
|
|
62
|
+
QuickLinks.displayName = 'QuickLinks';
|
|
63
|
+
QuickLinks.propTypes = {
|
|
64
|
+
tokens: getTokensPropType('QuickLinks'),
|
|
65
|
+
cardTokens: getTokensPropType('Card'),
|
|
66
|
+
listTokens: getTokensPropType('QuickLinksList'),
|
|
67
|
+
tag: PropTypes.string,
|
|
68
|
+
variant: variantProp.propType,
|
|
69
|
+
children: PropTypes.node
|
|
70
|
+
};
|
|
71
|
+
export default QuickLinks;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
4
|
+
import { getTokensPropType, variantProp } from '../utils';
|
|
5
|
+
import CardBase from '../Card/CardBase';
|
|
6
|
+
/**
|
|
7
|
+
* Private subcomponent for use within QuickLinks.
|
|
8
|
+
*
|
|
9
|
+
* Restyled Card with identical behaviour to Card, but themed according to the
|
|
10
|
+
* QuickLinksCard theme rather than the Card theme.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
|
|
15
|
+
const QuickLinksList = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
tokens,
|
|
18
|
+
variant,
|
|
19
|
+
children
|
|
20
|
+
} = _ref;
|
|
21
|
+
const themeTokens = useThemeTokens('QuickLinksCard', tokens, variant);
|
|
22
|
+
return /*#__PURE__*/_jsx(CardBase, {
|
|
23
|
+
tokens: themeTokens,
|
|
24
|
+
children: children
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
QuickLinksList.propTypes = {
|
|
29
|
+
tokens: getTokensPropType('QuickLinksCard'),
|
|
30
|
+
variant: variantProp.propType,
|
|
31
|
+
children: PropTypes.node
|
|
32
|
+
};
|
|
33
|
+
export default QuickLinksList;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { getTokensPropType, variantProp, withLinkRouter } from '../utils';
|
|
4
|
+
import { useViewport } from '../ViewportProvider';
|
|
5
|
+
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
|
|
6
|
+
import PressableListItemBase from '../List/PressableListItemBase';
|
|
7
|
+
import ButtonBase from '../Button/ButtonBase';
|
|
8
|
+
/**
|
|
9
|
+
* Public component exported as QuickLinks.Item, for use as children of QuickLinks.
|
|
10
|
+
*
|
|
11
|
+
* Receives props injected by QuickLinks and renders the appropriate child component.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const QuickLinksItem = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
16
|
+
let {
|
|
17
|
+
tokens,
|
|
18
|
+
variant,
|
|
19
|
+
children,
|
|
20
|
+
...rest
|
|
21
|
+
} = _ref;
|
|
22
|
+
const viewport = useViewport();
|
|
23
|
+
const {
|
|
24
|
+
list
|
|
25
|
+
} = useThemeTokens('QuickLinks', tokens, variant, {
|
|
26
|
+
viewport
|
|
27
|
+
});
|
|
28
|
+
const themeName = list ? 'QuickLinksList' : 'QuickLinksButton';
|
|
29
|
+
const getTokens = useThemeTokensCallback(themeName, tokens, variant);
|
|
30
|
+
return list ? /*#__PURE__*/_jsx(PressableListItemBase, {
|
|
31
|
+
ref: ref,
|
|
32
|
+
tokens: getTokens,
|
|
33
|
+
...rest,
|
|
34
|
+
children: children
|
|
35
|
+
}) : /*#__PURE__*/_jsx(ButtonBase, {
|
|
36
|
+
ref: ref,
|
|
37
|
+
tokens: getTokens,
|
|
38
|
+
...rest,
|
|
39
|
+
children: children
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
QuickLinksItem.displayName = 'QuickLinksItem';
|
|
43
|
+
QuickLinksItem.propTypes = { ...withLinkRouter.propTypes,
|
|
44
|
+
...PressableListItemBase.propTypes,
|
|
45
|
+
...ButtonBase.propTypes,
|
|
46
|
+
tokens: getTokensPropType('QuickLinksList', 'QuickLinksButton'),
|
|
47
|
+
variant: variantProp.propType,
|
|
48
|
+
children: PropTypes.node
|
|
49
|
+
};
|
|
50
|
+
export default withLinkRouter(QuickLinksItem);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
5
|
+
import { getTokensPropType, variantProp, a11yProps, viewProps, selectSystemProps, getA11yPropsFromHtmlTag, layoutTags } from '../utils';
|
|
6
|
+
import { useViewport } from '../ViewportProvider';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
const selectDotStyles = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
dotWidth,
|
|
13
|
+
timelineColor,
|
|
14
|
+
dotBorderWidth,
|
|
15
|
+
dotColor
|
|
16
|
+
} = _ref;
|
|
17
|
+
return {
|
|
18
|
+
width: dotWidth,
|
|
19
|
+
height: dotWidth,
|
|
20
|
+
borderRadius: dotWidth / 2,
|
|
21
|
+
backgroundColor: dotColor,
|
|
22
|
+
borderWidth: dotBorderWidth,
|
|
23
|
+
borderColor: timelineColor
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const selectConnectorStyles = _ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
timelineColor,
|
|
30
|
+
connectorHeight,
|
|
31
|
+
connectorWidth
|
|
32
|
+
} = _ref2;
|
|
33
|
+
return {
|
|
34
|
+
width: connectorWidth,
|
|
35
|
+
height: connectorHeight,
|
|
36
|
+
backgroundColor: timelineColor
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const selectTimelineContainerStyle = _ref3 => {
|
|
41
|
+
let {
|
|
42
|
+
timelineContainerDirection
|
|
43
|
+
} = _ref3;
|
|
44
|
+
return {
|
|
45
|
+
flexDirection: timelineContainerDirection
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const selectLineItemStyles = _ref4 => {
|
|
50
|
+
let {
|
|
51
|
+
lineItemAlign,
|
|
52
|
+
lineItemDirection,
|
|
53
|
+
lineItemMarginBottom,
|
|
54
|
+
lineItemMarginRight
|
|
55
|
+
} = _ref4;
|
|
56
|
+
return {
|
|
57
|
+
alignItems: lineItemAlign,
|
|
58
|
+
flexDirection: lineItemDirection,
|
|
59
|
+
marginBottom: lineItemMarginBottom,
|
|
60
|
+
marginRight: lineItemMarginRight,
|
|
61
|
+
overflow: 'hidden'
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const selectLineItemContainer = _ref5 => {
|
|
66
|
+
let {
|
|
67
|
+
lineItemContainerDirection,
|
|
68
|
+
lineContainerFlexSize
|
|
69
|
+
} = _ref5;
|
|
70
|
+
return {
|
|
71
|
+
flexDirection: lineItemContainerDirection,
|
|
72
|
+
flex: lineContainerFlexSize
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const selectItemContentStyles = (_ref6, isLastChild) => {
|
|
77
|
+
let {
|
|
78
|
+
itemContentFlexSize,
|
|
79
|
+
itemContentMarginBottom,
|
|
80
|
+
itemContentMarginRight
|
|
81
|
+
} = _ref6;
|
|
82
|
+
return {
|
|
83
|
+
flex: itemContentFlexSize,
|
|
84
|
+
marginBottom: !isLastChild && itemContentMarginBottom,
|
|
85
|
+
marginRight: !isLastChild && itemContentMarginRight
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
90
|
+
/**
|
|
91
|
+
* Timeline is a component that displays either a horizontal or vertical list of the
|
|
92
|
+
* children components passed by props
|
|
93
|
+
*
|
|
94
|
+
* ## Component API
|
|
95
|
+
*
|
|
96
|
+
* - `horizontal` In order to display the Component list horizontally
|
|
97
|
+
*
|
|
98
|
+
*
|
|
99
|
+
* ## A11y guidelines
|
|
100
|
+
* Timeline link supports all the common a11y props.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
const Timeline = /*#__PURE__*/forwardRef((_ref7, ref) => {
|
|
104
|
+
let {
|
|
105
|
+
tokens,
|
|
106
|
+
variant = {},
|
|
107
|
+
children,
|
|
108
|
+
accessibilityLabel,
|
|
109
|
+
tag = 'ul',
|
|
110
|
+
childrenTag = 'li',
|
|
111
|
+
...rest
|
|
112
|
+
} = _ref7;
|
|
113
|
+
const viewport = useViewport();
|
|
114
|
+
const themeTokens = useThemeTokens('Timeline', tokens, variant, {
|
|
115
|
+
viewport
|
|
116
|
+
});
|
|
117
|
+
const containerProps = { ...selectProps(rest),
|
|
118
|
+
...getA11yPropsFromHtmlTag(tag, rest.accessibilityRole || 'list'),
|
|
119
|
+
accessibilityLabel
|
|
120
|
+
};
|
|
121
|
+
return /*#__PURE__*/_jsx(View, { ...containerProps,
|
|
122
|
+
ref: ref,
|
|
123
|
+
style: selectTimelineContainerStyle(themeTokens),
|
|
124
|
+
children: children.map((child, index) => {
|
|
125
|
+
var _child$props;
|
|
126
|
+
|
|
127
|
+
const childrenProps = { ...getA11yPropsFromHtmlTag(childrenTag, (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.accessibilityRole) || 'listitem')
|
|
128
|
+
};
|
|
129
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
130
|
+
style: selectLineItemContainer(themeTokens) // eslint-disable-next-line react/no-array-index-key
|
|
131
|
+
,
|
|
132
|
+
...childrenProps,
|
|
133
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
134
|
+
style: selectLineItemStyles(themeTokens),
|
|
135
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
136
|
+
style: selectDotStyles(themeTokens)
|
|
137
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
138
|
+
style: selectConnectorStyles(themeTokens)
|
|
139
|
+
})]
|
|
140
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
141
|
+
style: selectItemContentStyles(themeTokens, index + 1 === children.length),
|
|
142
|
+
children: child
|
|
143
|
+
})]
|
|
144
|
+
}, "timeline-".concat(index, "-").concat(child.displayName));
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
Timeline.displayName = 'Timeline';
|
|
149
|
+
Timeline.propTypes = { ...selectedSystemPropTypes,
|
|
150
|
+
tokens: getTokensPropType('Timeline'),
|
|
151
|
+
variant: variantProp.propType,
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* A list of components that will be rendered either horizontally or vertically
|
|
155
|
+
*/
|
|
156
|
+
children: PropTypes.arrayOf(PropTypes.node).isRequired,
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* A required accessibility label that needs to be passed to be used on List
|
|
160
|
+
* which is applied as normal for a React Native accessibilityLabel prop.
|
|
161
|
+
*/
|
|
162
|
+
accessibilityLabel: PropTypes.string.isRequired,
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Sets the HTML tag of the outer container and the children. By default `'li'` for the children
|
|
166
|
+
* and `'ul'` for the container
|
|
167
|
+
*
|
|
168
|
+
* If either `tag` or `childrenTag` is overridden, the other should be too, to avoid producing invalid HTML.
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
tag: PropTypes.oneOf(layoutTags),
|
|
172
|
+
childrenTag: PropTypes.oneOf(layoutTags)
|
|
173
|
+
};
|
|
174
|
+
export default Timeline;
|
package/lib-module/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';
|
|
@@ -48,4 +50,5 @@ export { default as A11yInfoProvider, useA11yInfo } from './A11yInfoProvider';
|
|
|
48
50
|
export { default as BaseProvider } from './BaseProvider';
|
|
49
51
|
export { default as ViewportProvider, useViewport, ViewportContext } from './ViewportProvider';
|
|
50
52
|
export { default as ThemeProvider, useTheme, useSetTheme, useThemeTokens, getThemeTokens, applyOuterBorder, applyTextStyles, applyShadowToken } from './ThemeProvider';
|
|
51
|
-
export * from './utils';
|
|
53
|
+
export * from './utils';
|
|
54
|
+
export { Portal } from '@gorhom/portal';
|
package/package.json
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
"url": "https://github.com/telus/universal-design-system/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"
|
|
10
|
+
"@gorhom/portal": "^1.0.14",
|
|
11
11
|
"@telus-uds/system-constants": "^1.0.4",
|
|
12
|
-
"@telus-uds/system-theme-tokens": "^2.
|
|
12
|
+
"@telus-uds/system-theme-tokens": "^2.6.0",
|
|
13
|
+
"airbnb-prop-types": "^2.16.0",
|
|
13
14
|
"lodash.debounce": "^4.0.8",
|
|
14
15
|
"lodash.merge": "^4.6.2",
|
|
15
16
|
"prop-types": "^15.7.2",
|
|
@@ -21,10 +22,10 @@
|
|
|
21
22
|
"@telus-uds/browserslist-config": "^1.0.4",
|
|
22
23
|
"@testing-library/jest-native": "^4.0.1",
|
|
23
24
|
"@testing-library/react": "^13.3.0",
|
|
24
|
-
"@testing-library/react-native": "11.0.0",
|
|
25
|
-
"react-test-renderer": "~18.0.0",
|
|
26
25
|
"@testing-library/react-hooks": "~7.0.1",
|
|
26
|
+
"@testing-library/react-native": "11.0.0",
|
|
27
27
|
"@testing-library/react-native-17": "npm:@testing-library/react-native@7.2.0",
|
|
28
|
+
"react-test-renderer": "~18.0.0",
|
|
28
29
|
"react-test-renderer-17": "npm:react-test-renderer@17.0.2",
|
|
29
30
|
"webpack": "5.x"
|
|
30
31
|
},
|
|
@@ -66,5 +67,5 @@
|
|
|
66
67
|
"standard-engine": {
|
|
67
68
|
"skip": true
|
|
68
69
|
},
|
|
69
|
-
"version": "1.
|
|
70
|
+
"version": "1.17.0"
|
|
70
71
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
+
import { PortalProvider } from '@gorhom/portal'
|
|
3
4
|
import A11yInfoProvider from '../A11yInfoProvider'
|
|
4
5
|
import ViewportProvider from '../ViewportProvider'
|
|
5
6
|
import ThemeProvider from '../ThemeProvider'
|
|
@@ -8,7 +9,7 @@ const BaseProvider = ({ defaultTheme, children, themeOptions }) => (
|
|
|
8
9
|
<A11yInfoProvider>
|
|
9
10
|
<ViewportProvider>
|
|
10
11
|
<ThemeProvider defaultTheme={defaultTheme} themeOptions={themeOptions}>
|
|
11
|
-
{children}
|
|
12
|
+
<PortalProvider>{children}</PortalProvider>
|
|
12
13
|
</ThemeProvider>
|
|
13
14
|
</ViewportProvider>
|
|
14
15
|
</A11yInfoProvider>
|
|
@@ -148,9 +148,9 @@ const selectWebOnlyStyles = (inactive, themeTokens, { accessibilityRole }) => {
|
|
|
148
148
|
})
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
const selectItemIconTokens = ({ color, iconSize }) => ({
|
|
151
|
+
const selectItemIconTokens = ({ color, iconColor, iconSize }) => ({
|
|
152
152
|
size: iconSize,
|
|
153
|
-
color
|
|
153
|
+
color: iconColor || color
|
|
154
154
|
})
|
|
155
155
|
|
|
156
156
|
const ButtonBase = forwardRef(
|
package/src/List/List.jsx
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import React, { cloneElement, forwardRef, Children } from 'react'
|
|
2
2
|
import { View, Platform } from 'react-native'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
|
-
import {
|
|
5
|
-
a11yProps,
|
|
6
|
-
componentPropType,
|
|
7
|
-
getTokensPropType,
|
|
8
|
-
selectSystemProps,
|
|
9
|
-
variantProp,
|
|
10
|
-
viewProps
|
|
11
|
-
} from '../utils'
|
|
12
|
-
import ListItem from './ListItem'
|
|
4
|
+
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils'
|
|
13
5
|
|
|
14
6
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
15
7
|
|
|
8
|
+
const isListItem = (element) => {
|
|
9
|
+
const elementName = element?.type?.displayName || element?.type?.name
|
|
10
|
+
// Match our own ListItem, and also, custom list items
|
|
11
|
+
return Boolean(elementName.match(/Item/))
|
|
12
|
+
}
|
|
13
|
+
|
|
16
14
|
/**
|
|
17
15
|
* An unordered List component has a child a ListItem that
|
|
18
16
|
* allows icon, dividers and customized typography
|
|
@@ -31,9 +29,7 @@ const List = forwardRef(
|
|
|
31
29
|
) => {
|
|
32
30
|
const items = Children.map(children, (child, index) => {
|
|
33
31
|
// Pass ListItem-specific props to children (by name so teams can add their own ListItems)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (isListItem(child?.type?.displayName) || isListItem(child?.type?.name)) {
|
|
32
|
+
if (isListItem(child)) {
|
|
37
33
|
return cloneElement(child, {
|
|
38
34
|
showDivider,
|
|
39
35
|
isLastItem: index + 1 === Children.count(children),
|
|
@@ -58,7 +54,7 @@ List.propTypes = {
|
|
|
58
54
|
...selectedSystemPropTypes,
|
|
59
55
|
tokens: getTokensPropType('List'),
|
|
60
56
|
variant: variantProp.propType,
|
|
61
|
-
children:
|
|
57
|
+
children: PropTypes.node,
|
|
62
58
|
/**
|
|
63
59
|
* In case it is not the last item allow display divider
|
|
64
60
|
*/
|
|
@@ -9,12 +9,13 @@ import {
|
|
|
9
9
|
clickProps,
|
|
10
10
|
linkProps,
|
|
11
11
|
hrefAttrsProp,
|
|
12
|
+
selectTokens,
|
|
12
13
|
withLinkRouter
|
|
13
14
|
} from '../utils'
|
|
14
15
|
|
|
15
16
|
import ListItemBase from './ListItemBase'
|
|
16
|
-
import ListItemContent
|
|
17
|
-
import ListItemMark
|
|
17
|
+
import ListItemContent from './ListItemContent'
|
|
18
|
+
import ListItemMark from './ListItemMark'
|
|
18
19
|
|
|
19
20
|
const selectPressableStyles = ({
|
|
20
21
|
backgroundColor,
|
|
@@ -39,8 +40,10 @@ const PressableListItemBase = forwardRef(
|
|
|
39
40
|
const { hrefAttrs, rest: listItemProps } = hrefAttrsProp.bundle(props)
|
|
40
41
|
const handlePress = linkProps.handleHref({ href, onPress })
|
|
41
42
|
|
|
43
|
+
const listItemTokens = selectTokens('List', typeof tokens === 'function' ? tokens() : tokens)
|
|
44
|
+
|
|
42
45
|
return (
|
|
43
|
-
<ListItemBase ref={listItemRef} tokens={
|
|
46
|
+
<ListItemBase ref={listItemRef} tokens={listItemTokens} {...listItemProps}>
|
|
44
47
|
{({ isLastItem }) => {
|
|
45
48
|
const getTokens = (pressableState) =>
|
|
46
49
|
resolvePressableTokens(tokens, pressableState, { last: isLastItem })
|
|
@@ -81,18 +84,13 @@ const staticStyles = StyleSheet.create({
|
|
|
81
84
|
itemContainer: {
|
|
82
85
|
flexDirection: 'row',
|
|
83
86
|
flex: 1
|
|
84
|
-
},
|
|
85
|
-
tokens: {
|
|
86
|
-
...contentTokenTypes,
|
|
87
|
-
...markTokenTypes
|
|
88
87
|
}
|
|
89
88
|
})
|
|
90
89
|
|
|
91
90
|
PressableListItemBase.propTypes = {
|
|
91
|
+
...withLinkRouter.propTypes,
|
|
92
92
|
href: PropTypes.string,
|
|
93
93
|
onPress: PropTypes.func,
|
|
94
|
-
// TODO - type this better, maybe import the subcomponent token types and run it through util
|
|
95
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
96
94
|
tokens: PropTypes.any,
|
|
97
95
|
icon: PropTypes.elementType,
|
|
98
96
|
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|