@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
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);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import Animated from "react-native-web/dist/exports/Animated";
|
|
3
3
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
6
|
import propTypes from 'prop-types';
|
|
5
7
|
import StackView from '../StackView';
|
|
6
8
|
import { useThemeTokens } from '../ThemeProvider';
|
|
@@ -13,14 +15,12 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
|
|
|
13
15
|
const selectSkeletonStyles = _ref => {
|
|
14
16
|
let {
|
|
15
17
|
color,
|
|
16
|
-
radius
|
|
17
|
-
fadeAnimation
|
|
18
|
+
radius
|
|
18
19
|
} = _ref;
|
|
19
20
|
return {
|
|
20
21
|
backgroundColor: color,
|
|
21
22
|
borderRadius: radius,
|
|
22
|
-
maxWidth: '100%'
|
|
23
|
-
...fadeAnimation
|
|
23
|
+
maxWidth: '100%'
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -78,12 +78,14 @@ const Skeleton = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
78
78
|
const skeletonHeight = useSpacingScale(spacingScaleValue);
|
|
79
79
|
const nativeAnimation = useSkeletonNativeAnimation();
|
|
80
80
|
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
81
|
+
const getAnimationBasedOnPlatform = () => {
|
|
82
|
+
const animation = Platform.OS === 'web' ? skeletonWebAnimation : nativeAnimation; // We must pass the animation styles through `StyleSheet.create`
|
|
83
|
+
// @see https://github.com/necolas/react-native-web/issues/2387
|
|
85
84
|
|
|
86
|
-
|
|
85
|
+
const styles = StyleSheet.create({
|
|
86
|
+
animation
|
|
87
|
+
});
|
|
88
|
+
return styles.animation;
|
|
87
89
|
};
|
|
88
90
|
|
|
89
91
|
const getLineWidth = () => {
|
|
@@ -117,11 +119,11 @@ const Skeleton = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
117
119
|
|
|
118
120
|
const renderSkeleton = function () {
|
|
119
121
|
let index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
120
|
-
|
|
122
|
+
// @see https://github.com/necolas/react-native-web/issues/2387
|
|
123
|
+
const Component = Platform.OS === 'web' ? View : Animated.View;
|
|
124
|
+
return /*#__PURE__*/_jsx(Component, {
|
|
121
125
|
testID: "skeleton",
|
|
122
|
-
style: [selectSkeletonStyles(
|
|
123
|
-
fadeAnimation: getAnimationBaseOnPlatform()
|
|
124
|
-
}), getStyledBasedOnShape()]
|
|
126
|
+
style: [selectSkeletonStyles(themeTokens), getAnimationBasedOnPlatform(), getStyledBasedOnShape()]
|
|
125
127
|
}, "skeleton-".concat(index + 1));
|
|
126
128
|
};
|
|
127
129
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import Animated from "react-native-web/dist/exports/Animated";
|
|
3
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
3
4
|
import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant';
|
|
4
5
|
|
|
5
6
|
const useSkeletonNativeAnimation = () => {
|
|
@@ -8,11 +9,11 @@ const useSkeletonNativeAnimation = () => {
|
|
|
8
9
|
const fade = Animated.sequence([Animated.timing(fadeAnimation, {
|
|
9
10
|
toValue: OPACITY_STOP,
|
|
10
11
|
duration: ANIMATION_DURATION,
|
|
11
|
-
useNativeDriver:
|
|
12
|
+
useNativeDriver: Platform.OS !== 'web'
|
|
12
13
|
}), Animated.timing(fadeAnimation, {
|
|
13
14
|
toValue: DEFAULT_OPACITY,
|
|
14
15
|
duration: ANIMATION_DURATION,
|
|
15
|
-
useNativeDriver:
|
|
16
|
+
useNativeDriver: Platform.OS !== 'web'
|
|
16
17
|
})]);
|
|
17
18
|
Animated.loop(fade).start();
|
|
18
19
|
}, [fadeAnimation]);
|
|
@@ -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;
|
|
@@ -11,32 +11,39 @@ import { a11yProps, focusHandlerProps, getTokensPropType, selectTokens, pressPro
|
|
|
11
11
|
import { useInputValue } from '../utils/input';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, pressProps, viewProps]);
|
|
14
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, pressProps, viewProps]); // We need to drop the icon before passing it to the `ButtonBase`, because it's
|
|
15
|
+
// being handled separately in this case
|
|
15
16
|
|
|
16
|
-
const selectButtonTokens =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const selectButtonTokens = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
icon: _,
|
|
20
|
+
...tokens
|
|
21
|
+
} = _ref;
|
|
22
|
+
return selectTokens('Button', { ...tokens,
|
|
23
|
+
// Width tokens are applied to our inner track. Disable Button width token so it wraps our track width.
|
|
24
|
+
width: null
|
|
25
|
+
});
|
|
26
|
+
}; // Map and rename icon-specific tokens to name used within Icon
|
|
20
27
|
|
|
21
28
|
|
|
22
|
-
const selectIconTokens =
|
|
29
|
+
const selectIconTokens = _ref2 => {
|
|
23
30
|
let {
|
|
24
31
|
iconSize,
|
|
25
32
|
iconColor
|
|
26
|
-
} =
|
|
33
|
+
} = _ref2;
|
|
27
34
|
return {
|
|
28
35
|
size: iconSize,
|
|
29
36
|
color: iconColor
|
|
30
37
|
};
|
|
31
38
|
};
|
|
32
39
|
|
|
33
|
-
const selectTrackStyles =
|
|
40
|
+
const selectTrackStyles = _ref3 => {
|
|
34
41
|
let {
|
|
35
42
|
trackBorderWidth,
|
|
36
43
|
trackBorderColor,
|
|
37
44
|
trackBorderRadius,
|
|
38
45
|
width
|
|
39
|
-
} =
|
|
46
|
+
} = _ref3;
|
|
40
47
|
return {
|
|
41
48
|
borderWidth: trackBorderWidth,
|
|
42
49
|
borderColor: trackBorderColor,
|
|
@@ -45,7 +52,7 @@ const selectTrackStyles = _ref2 => {
|
|
|
45
52
|
};
|
|
46
53
|
};
|
|
47
54
|
|
|
48
|
-
const selectSwitchStyles =
|
|
55
|
+
const selectSwitchStyles = _ref4 => {
|
|
49
56
|
let {
|
|
50
57
|
switchSize,
|
|
51
58
|
switchColor,
|
|
@@ -53,7 +60,7 @@ const selectSwitchStyles = _ref3 => {
|
|
|
53
60
|
switchBorderColor,
|
|
54
61
|
switchBorderRadius,
|
|
55
62
|
switchShadow
|
|
56
|
-
} =
|
|
63
|
+
} = _ref4;
|
|
57
64
|
return {
|
|
58
65
|
width: switchSize,
|
|
59
66
|
height: switchSize,
|
|
@@ -71,23 +78,23 @@ const selectSwitchStyles = _ref3 => {
|
|
|
71
78
|
};
|
|
72
79
|
};
|
|
73
80
|
|
|
74
|
-
const selectLabelStyles =
|
|
81
|
+
const selectLabelStyles = _ref5 => {
|
|
75
82
|
let {
|
|
76
83
|
labelMarginLeft
|
|
77
|
-
} =
|
|
84
|
+
} = _ref5;
|
|
78
85
|
return {
|
|
79
86
|
marginLeft: labelMarginLeft
|
|
80
87
|
};
|
|
81
88
|
};
|
|
82
89
|
|
|
83
|
-
const selectLabelTokens =
|
|
90
|
+
const selectLabelTokens = _ref6 => {
|
|
84
91
|
let {
|
|
85
92
|
labelColor,
|
|
86
93
|
labelFontName,
|
|
87
94
|
labelFontSize,
|
|
88
95
|
labelFontWeight,
|
|
89
96
|
labelLineHeight
|
|
90
|
-
} =
|
|
97
|
+
} = _ref6;
|
|
91
98
|
return {
|
|
92
99
|
color: labelColor,
|
|
93
100
|
fontName: labelFontName,
|
|
@@ -97,7 +104,7 @@ const selectLabelTokens = _ref5 => {
|
|
|
97
104
|
};
|
|
98
105
|
};
|
|
99
106
|
|
|
100
|
-
const ToggleSwitch = /*#__PURE__*/forwardRef((
|
|
107
|
+
const ToggleSwitch = /*#__PURE__*/forwardRef((_ref7, ref) => {
|
|
101
108
|
let {
|
|
102
109
|
copy = 'en',
|
|
103
110
|
value,
|
|
@@ -112,7 +119,7 @@ const ToggleSwitch = /*#__PURE__*/forwardRef((_ref6, ref) => {
|
|
|
112
119
|
accessibilityRole = 'switch',
|
|
113
120
|
accessibilityLabel = label,
|
|
114
121
|
...rest
|
|
115
|
-
} =
|
|
122
|
+
} = _ref7;
|
|
116
123
|
const getTokens = useThemeTokensCallback('ToggleSwitch', tokens, variant);
|
|
117
124
|
const themeTokens = getTokens();
|
|
118
125
|
const {
|
|
@@ -235,8 +242,6 @@ ToggleSwitch.propTypes = { ...selectedSystemPropTypes,
|
|
|
235
242
|
};
|
|
236
243
|
const staticStyles = StyleSheet.create({
|
|
237
244
|
track: {
|
|
238
|
-
flexGrow: 1,
|
|
239
|
-
alignSelf: 'stretch',
|
|
240
245
|
flexDirection: 'row'
|
|
241
246
|
},
|
|
242
247
|
switch: {
|
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';
|