@telus-uds/components-base 1.77.1 → 1.78.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 +18 -2
- package/lib/Card/Card.js +27 -3
- package/lib/Link/ChevronLink.js +0 -2
- package/lib/Link/InlinePressable.js +2 -16
- package/lib/Link/LinkBase.js +0 -1
- package/lib/Typography/Typography.js +11 -8
- package/lib-module/Card/Card.js +29 -5
- package/lib-module/Link/ChevronLink.js +0 -2
- package/lib-module/Link/InlinePressable.js +2 -17
- package/lib-module/Link/LinkBase.js +0 -1
- package/lib-module/Typography/Typography.js +11 -8
- package/package.json +2 -2
- package/src/Card/Card.jsx +37 -5
- package/src/Link/ChevronLink.jsx +1 -5
- package/src/Link/InlinePressable.jsx +15 -37
- package/src/Link/LinkBase.jsx +0 -1
- package/src/Typography/Typography.jsx +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 23 Feb 2024 19:32:18 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.78.0
|
|
8
|
+
|
|
9
|
+
Fri, 23 Feb 2024 19:32:18 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- refactoring Card component to add media queries as an option to prevent layout shifts (hoss.agina@telus.com)
|
|
14
|
+
- Bump @telus-uds/system-theme-tokens to v2.52.0
|
|
15
|
+
|
|
16
|
+
### Patches
|
|
17
|
+
|
|
18
|
+
- Onpress function reverted due to several bugs (35577399+JoshHC@users.noreply.github.com)
|
|
19
|
+
- fix Link component keyboard interaction (guillermo.peitzner@telus.com)
|
|
20
|
+
- prevent typography dataset property to be overruled (guillermo.peitzner@telus.com)
|
|
21
|
+
- New changes of notification component merged with old changes to support the users in the migraiton to the new ones (35577399+JoshHC@users.noreply.github.com)
|
|
22
|
+
|
|
7
23
|
## 1.77.1
|
|
8
24
|
|
|
9
|
-
Tue, 20 Feb 2024 23:
|
|
25
|
+
Tue, 20 Feb 2024 23:14:38 GMT
|
|
10
26
|
|
|
11
27
|
### Patches
|
|
12
28
|
|
package/lib/Card/Card.js
CHANGED
|
@@ -78,7 +78,14 @@ const Card = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
78
78
|
...rest
|
|
79
79
|
} = _ref;
|
|
80
80
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
81
|
-
const
|
|
81
|
+
const {
|
|
82
|
+
themeOptions
|
|
83
|
+
} = (0, _ThemeProvider.useTheme)();
|
|
84
|
+
const {
|
|
85
|
+
enableMediaQueryStyleSheet
|
|
86
|
+
} = themeOptions;
|
|
87
|
+
const useTokens = enableMediaQueryStyleSheet ? _ThemeProvider.useResponsiveThemeTokens : _ThemeProvider.useThemeTokens;
|
|
88
|
+
const themeTokens = useTokens('Card', tokens, variant, !enableMediaQueryStyleSheet && {
|
|
82
89
|
viewport
|
|
83
90
|
});
|
|
84
91
|
const getThemeTokens = (0, _ThemeProvider.useThemeTokensCallback)('Card', interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.tokens, {
|
|
@@ -94,11 +101,28 @@ const Card = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
94
101
|
paddingRight,
|
|
95
102
|
...restOfTokens
|
|
96
103
|
} = themeTokens;
|
|
104
|
+
let cardStyles;
|
|
105
|
+
let mediaIds;
|
|
106
|
+
if (enableMediaQueryStyleSheet) {
|
|
107
|
+
const mediaQueryStyleSheet = (0, _utils.createMediaQueryStyles)(themeTokens);
|
|
108
|
+
const {
|
|
109
|
+
ids,
|
|
110
|
+
styles
|
|
111
|
+
} = _utils.StyleSheet.create({
|
|
112
|
+
card: mediaQueryStyleSheet
|
|
113
|
+
});
|
|
114
|
+
cardStyles = styles.card;
|
|
115
|
+
mediaIds = ids.card;
|
|
116
|
+
} else {
|
|
117
|
+
cardStyles = themeTokens;
|
|
118
|
+
}
|
|
97
119
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
98
120
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBase.default, {
|
|
99
121
|
ref: ref,
|
|
100
|
-
tokens: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? restOfTokens :
|
|
101
|
-
dataSet:
|
|
122
|
+
tokens: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? restOfTokens : cardStyles,
|
|
123
|
+
dataSet: mediaIds && {
|
|
124
|
+
media: mediaIds
|
|
125
|
+
},
|
|
102
126
|
...selectProps(rest),
|
|
103
127
|
children: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
104
128
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PressableCardBase.default, {
|
package/lib/Link/ChevronLink.js
CHANGED
|
@@ -25,7 +25,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
25
25
|
tokens = {},
|
|
26
26
|
variant,
|
|
27
27
|
dataSet,
|
|
28
|
-
onPress,
|
|
29
28
|
...otherlinkProps
|
|
30
29
|
} = _ref;
|
|
31
30
|
const getChevronTokens = (0, _ThemeProvider.useThemeTokensCallback)('ChevronLink', tokens, variant);
|
|
@@ -54,7 +53,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
54
53
|
tokens: getTokens,
|
|
55
54
|
dataSet: dataSet,
|
|
56
55
|
ref: ref,
|
|
57
|
-
onPress: onPress,
|
|
58
56
|
children: children
|
|
59
57
|
});
|
|
60
58
|
});
|
|
@@ -7,7 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
9
9
|
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
10
|
-
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -25,30 +24,17 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
25
24
|
* @param {PressableProps} PressableProps
|
|
26
25
|
*/
|
|
27
26
|
// React Native exports prop Types but not propTypes, use JSDoc types here rather than duplicate RN
|
|
28
|
-
|
|
27
|
+
// eslint-disable-next-line react/prop-types
|
|
28
|
+
const InlinePressable = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
29
29
|
let {
|
|
30
30
|
children,
|
|
31
31
|
inlineFlex = true,
|
|
32
32
|
style,
|
|
33
|
-
onPress,
|
|
34
33
|
...props
|
|
35
34
|
} = _ref;
|
|
36
|
-
const handlePress = (0, _react.useCallback)(() => {
|
|
37
|
-
if (onPress) {
|
|
38
|
-
onPress();
|
|
39
|
-
}
|
|
40
|
-
}, [onPress]);
|
|
41
|
-
const handleKeyPress = (0, _react.useCallback)(e => {
|
|
42
|
-
e.preventDefault();
|
|
43
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
44
|
-
handlePress();
|
|
45
|
-
}
|
|
46
|
-
}, [handlePress]);
|
|
47
35
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
48
36
|
ref: ref,
|
|
49
37
|
style: pressState => [typeof style === 'function' ? style(pressState) : style, staticStyles[inlineFlex ? 'inlineFlex' : 'inline']],
|
|
50
|
-
onPress: handlePress,
|
|
51
|
-
onKeyDown: _Platform.default.OS === 'web' ? handleKeyPress : undefined,
|
|
52
38
|
...props,
|
|
53
39
|
children: pressState => typeof children === 'function' ? children(pressState) : children
|
|
54
40
|
});
|
package/lib/Link/LinkBase.js
CHANGED
|
@@ -187,7 +187,6 @@ const LinkBase = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
|
|
|
187
187
|
// assuming links without icons should be inline (even if they are long)
|
|
188
188
|
,
|
|
189
189
|
ref: ref,
|
|
190
|
-
keyboardShouldPersistTaps: "handled",
|
|
191
190
|
style: linkState => {
|
|
192
191
|
const themeTokens = resolveLinkTokens(linkState);
|
|
193
192
|
const outerBorderStyles = selectOuterBorderStyles(themeTokens);
|
|
@@ -104,7 +104,6 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
104
104
|
}
|
|
105
105
|
const resolvedTextProps = {
|
|
106
106
|
...selectTextProps(rest),
|
|
107
|
-
dataSet,
|
|
108
107
|
maxFontSizeMultiplier
|
|
109
108
|
};
|
|
110
109
|
const containerProps = {
|
|
@@ -136,15 +135,17 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
136
135
|
}
|
|
137
136
|
return resetTagStyling(children);
|
|
138
137
|
};
|
|
138
|
+
const dataSetValue = mediaIds ? {
|
|
139
|
+
media: mediaIds,
|
|
140
|
+
...dataSet
|
|
141
|
+
} : dataSet;
|
|
139
142
|
return block ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
140
143
|
ref: ref,
|
|
141
144
|
...containerProps,
|
|
142
145
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
143
146
|
...resolvedTextProps,
|
|
144
147
|
style: textStyles,
|
|
145
|
-
dataSet:
|
|
146
|
-
media: mediaIds
|
|
147
|
-
},
|
|
148
|
+
dataSet: dataSetValue,
|
|
148
149
|
children: sanitizeChildren(children)
|
|
149
150
|
})
|
|
150
151
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
@@ -152,9 +153,7 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
152
153
|
...containerProps,
|
|
153
154
|
...resolvedTextProps,
|
|
154
155
|
style: textStyles,
|
|
155
|
-
dataSet:
|
|
156
|
-
media: mediaIds
|
|
157
|
-
},
|
|
156
|
+
dataSet: dataSetValue,
|
|
158
157
|
children: sanitizeChildren(children)
|
|
159
158
|
});
|
|
160
159
|
});
|
|
@@ -199,7 +198,11 @@ Typography.propTypes = {
|
|
|
199
198
|
/**
|
|
200
199
|
* Same children allowed as a React Native <Text> node
|
|
201
200
|
*/
|
|
202
|
-
children: _propTypes.default.node
|
|
201
|
+
children: _propTypes.default.node,
|
|
202
|
+
/**
|
|
203
|
+
* Data attributes to be added to the element
|
|
204
|
+
*/
|
|
205
|
+
dataSet: _propTypes.default.object
|
|
203
206
|
};
|
|
204
207
|
var _default = Typography;
|
|
205
208
|
exports.default = _default;
|
package/lib-module/Card/Card.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import View from "react-native-web/dist/exports/View";
|
|
4
|
-
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
|
|
5
|
-
import { getTokensPropType, variantProp } from '../utils';
|
|
4
|
+
import { useThemeTokens, useThemeTokensCallback, useResponsiveThemeTokens, useTheme } from '../ThemeProvider';
|
|
5
|
+
import { getTokensPropType, variantProp, StyleSheet, createMediaQueryStyles } from '../utils';
|
|
6
6
|
import { useViewport } from '../ViewportProvider';
|
|
7
7
|
import { a11yProps, selectSystemProps, viewProps } from '../utils/props';
|
|
8
8
|
import CardBase from './CardBase';
|
|
@@ -71,7 +71,14 @@ const Card = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
71
71
|
...rest
|
|
72
72
|
} = _ref;
|
|
73
73
|
const viewport = useViewport();
|
|
74
|
-
const
|
|
74
|
+
const {
|
|
75
|
+
themeOptions
|
|
76
|
+
} = useTheme();
|
|
77
|
+
const {
|
|
78
|
+
enableMediaQueryStyleSheet
|
|
79
|
+
} = themeOptions;
|
|
80
|
+
const useTokens = enableMediaQueryStyleSheet ? useResponsiveThemeTokens : useThemeTokens;
|
|
81
|
+
const themeTokens = useTokens('Card', tokens, variant, !enableMediaQueryStyleSheet && {
|
|
75
82
|
viewport
|
|
76
83
|
});
|
|
77
84
|
const getThemeTokens = useThemeTokensCallback('Card', interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.tokens, {
|
|
@@ -87,11 +94,28 @@ const Card = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
87
94
|
paddingRight,
|
|
88
95
|
...restOfTokens
|
|
89
96
|
} = themeTokens;
|
|
97
|
+
let cardStyles;
|
|
98
|
+
let mediaIds;
|
|
99
|
+
if (enableMediaQueryStyleSheet) {
|
|
100
|
+
const mediaQueryStyleSheet = createMediaQueryStyles(themeTokens);
|
|
101
|
+
const {
|
|
102
|
+
ids,
|
|
103
|
+
styles
|
|
104
|
+
} = StyleSheet.create({
|
|
105
|
+
card: mediaQueryStyleSheet
|
|
106
|
+
});
|
|
107
|
+
cardStyles = styles.card;
|
|
108
|
+
mediaIds = ids.card;
|
|
109
|
+
} else {
|
|
110
|
+
cardStyles = themeTokens;
|
|
111
|
+
}
|
|
90
112
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
91
113
|
children: /*#__PURE__*/_jsx(CardBase, {
|
|
92
114
|
ref: ref,
|
|
93
|
-
tokens: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? restOfTokens :
|
|
94
|
-
dataSet:
|
|
115
|
+
tokens: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? restOfTokens : cardStyles,
|
|
116
|
+
dataSet: mediaIds && {
|
|
117
|
+
media: mediaIds
|
|
118
|
+
},
|
|
95
119
|
...selectProps(rest),
|
|
96
120
|
children: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
97
121
|
children: [/*#__PURE__*/_jsx(PressableCardBase, {
|
|
@@ -18,7 +18,6 @@ const ChevronLink = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
18
18
|
tokens = {},
|
|
19
19
|
variant,
|
|
20
20
|
dataSet,
|
|
21
|
-
onPress,
|
|
22
21
|
...otherlinkProps
|
|
23
22
|
} = _ref;
|
|
24
23
|
const getChevronTokens = useThemeTokensCallback('ChevronLink', tokens, variant);
|
|
@@ -47,7 +46,6 @@ const ChevronLink = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
47
46
|
tokens: getTokens,
|
|
48
47
|
dataSet: dataSet,
|
|
49
48
|
ref: ref,
|
|
50
|
-
onPress: onPress,
|
|
51
49
|
children: children
|
|
52
50
|
});
|
|
53
51
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
3
3
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
|
-
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
4
|
/**
|
|
6
5
|
* @typedef {import('react-native').PressableProps} PressableProps
|
|
7
6
|
*/
|
|
@@ -14,32 +13,18 @@ import Platform from "react-native-web/dist/exports/Platform";
|
|
|
14
13
|
* @param {PressableProps} PressableProps
|
|
15
14
|
*/
|
|
16
15
|
// React Native exports prop Types but not propTypes, use JSDoc types here rather than duplicate RN
|
|
17
|
-
|
|
16
|
+
// eslint-disable-next-line react/prop-types
|
|
18
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
18
|
const InlinePressable = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
20
19
|
let {
|
|
21
20
|
children,
|
|
22
21
|
inlineFlex = true,
|
|
23
22
|
style,
|
|
24
|
-
onPress,
|
|
25
23
|
...props
|
|
26
24
|
} = _ref;
|
|
27
|
-
const handlePress = useCallback(() => {
|
|
28
|
-
if (onPress) {
|
|
29
|
-
onPress();
|
|
30
|
-
}
|
|
31
|
-
}, [onPress]);
|
|
32
|
-
const handleKeyPress = useCallback(e => {
|
|
33
|
-
e.preventDefault();
|
|
34
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
35
|
-
handlePress();
|
|
36
|
-
}
|
|
37
|
-
}, [handlePress]);
|
|
38
25
|
return /*#__PURE__*/_jsx(Pressable, {
|
|
39
26
|
ref: ref,
|
|
40
27
|
style: pressState => [typeof style === 'function' ? style(pressState) : style, staticStyles[inlineFlex ? 'inlineFlex' : 'inline']],
|
|
41
|
-
onPress: handlePress,
|
|
42
|
-
onKeyDown: Platform.OS === 'web' ? handleKeyPress : undefined,
|
|
43
28
|
...props,
|
|
44
29
|
children: pressState => typeof children === 'function' ? children(pressState) : children
|
|
45
30
|
});
|
|
@@ -178,7 +178,6 @@ const LinkBase = /*#__PURE__*/forwardRef((_ref6, ref) => {
|
|
|
178
178
|
// assuming links without icons should be inline (even if they are long)
|
|
179
179
|
,
|
|
180
180
|
ref: ref,
|
|
181
|
-
keyboardShouldPersistTaps: "handled",
|
|
182
181
|
style: linkState => {
|
|
183
182
|
const themeTokens = resolveLinkTokens(linkState);
|
|
184
183
|
const outerBorderStyles = selectOuterBorderStyles(themeTokens);
|
|
@@ -96,7 +96,6 @@ const Typography = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
96
96
|
}
|
|
97
97
|
const resolvedTextProps = {
|
|
98
98
|
...selectTextProps(rest),
|
|
99
|
-
dataSet,
|
|
100
99
|
maxFontSizeMultiplier
|
|
101
100
|
};
|
|
102
101
|
const containerProps = {
|
|
@@ -128,15 +127,17 @@ const Typography = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
128
127
|
}
|
|
129
128
|
return resetTagStyling(children);
|
|
130
129
|
};
|
|
130
|
+
const dataSetValue = mediaIds ? {
|
|
131
|
+
media: mediaIds,
|
|
132
|
+
...dataSet
|
|
133
|
+
} : dataSet;
|
|
131
134
|
return block ? /*#__PURE__*/_jsx(View, {
|
|
132
135
|
ref: ref,
|
|
133
136
|
...containerProps,
|
|
134
137
|
children: /*#__PURE__*/_jsx(Text, {
|
|
135
138
|
...resolvedTextProps,
|
|
136
139
|
style: textStyles,
|
|
137
|
-
dataSet:
|
|
138
|
-
media: mediaIds
|
|
139
|
-
},
|
|
140
|
+
dataSet: dataSetValue,
|
|
140
141
|
children: sanitizeChildren(children)
|
|
141
142
|
})
|
|
142
143
|
}) : /*#__PURE__*/_jsx(Text, {
|
|
@@ -144,9 +145,7 @@ const Typography = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
144
145
|
...containerProps,
|
|
145
146
|
...resolvedTextProps,
|
|
146
147
|
style: textStyles,
|
|
147
|
-
dataSet:
|
|
148
|
-
media: mediaIds
|
|
149
|
-
},
|
|
148
|
+
dataSet: dataSetValue,
|
|
150
149
|
children: sanitizeChildren(children)
|
|
151
150
|
});
|
|
152
151
|
});
|
|
@@ -191,6 +190,10 @@ Typography.propTypes = {
|
|
|
191
190
|
/**
|
|
192
191
|
* Same children allowed as a React Native <Text> node
|
|
193
192
|
*/
|
|
194
|
-
children: PropTypes.node
|
|
193
|
+
children: PropTypes.node,
|
|
194
|
+
/**
|
|
195
|
+
* Data attributes to be added to the element
|
|
196
|
+
*/
|
|
197
|
+
dataSet: PropTypes.object
|
|
195
198
|
};
|
|
196
199
|
export default Typography;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@floating-ui/react-native": "^0.8.1",
|
|
12
12
|
"@gorhom/portal": "^1.0.14",
|
|
13
13
|
"@telus-uds/system-constants": "^1.3.0",
|
|
14
|
-
"@telus-uds/system-theme-tokens": "^2.
|
|
14
|
+
"@telus-uds/system-theme-tokens": "^2.52.0",
|
|
15
15
|
"airbnb-prop-types": "^2.16.0",
|
|
16
16
|
"css-mediaquery": "^0.1.2",
|
|
17
17
|
"expo-linear-gradient": "^12.5.0",
|
|
@@ -85,6 +85,6 @@
|
|
|
85
85
|
"standard-engine": {
|
|
86
86
|
"skip": true
|
|
87
87
|
},
|
|
88
|
-
"version": "1.
|
|
88
|
+
"version": "1.78.0",
|
|
89
89
|
"types": "types/index.d.ts"
|
|
90
90
|
}
|
package/src/Card/Card.jsx
CHANGED
|
@@ -2,8 +2,13 @@ import React, { forwardRef } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { View } from 'react-native'
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
useThemeTokens,
|
|
7
|
+
useThemeTokensCallback,
|
|
8
|
+
useResponsiveThemeTokens,
|
|
9
|
+
useTheme
|
|
10
|
+
} from '../ThemeProvider'
|
|
11
|
+
import { getTokensPropType, variantProp, StyleSheet, createMediaQueryStyles } from '../utils'
|
|
7
12
|
import { useViewport } from '../ViewportProvider'
|
|
8
13
|
import { a11yProps, selectSystemProps, viewProps } from '../utils/props'
|
|
9
14
|
import CardBase from './CardBase'
|
|
@@ -62,7 +67,19 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
|
|
|
62
67
|
const Card = forwardRef(
|
|
63
68
|
({ children, tokens, variant, dataSet, onPress, interactiveCard, ...rest }, ref) => {
|
|
64
69
|
const viewport = useViewport()
|
|
65
|
-
const
|
|
70
|
+
const { themeOptions } = useTheme()
|
|
71
|
+
|
|
72
|
+
const { enableMediaQueryStyleSheet } = themeOptions
|
|
73
|
+
|
|
74
|
+
const useTokens = enableMediaQueryStyleSheet ? useResponsiveThemeTokens : useThemeTokens
|
|
75
|
+
|
|
76
|
+
const themeTokens = useTokens(
|
|
77
|
+
'Card',
|
|
78
|
+
tokens,
|
|
79
|
+
variant,
|
|
80
|
+
!enableMediaQueryStyleSheet && { viewport }
|
|
81
|
+
)
|
|
82
|
+
|
|
66
83
|
const getThemeTokens = useThemeTokensCallback('Card', interactiveCard?.tokens, {
|
|
67
84
|
interactive: true,
|
|
68
85
|
...(interactiveCard?.variant || {})
|
|
@@ -71,12 +88,27 @@ const Card = forwardRef(
|
|
|
71
88
|
// to individual Card sections, not Card as a whole
|
|
72
89
|
const { paddingTop, paddingBottom, paddingLeft, paddingRight, ...restOfTokens } = themeTokens
|
|
73
90
|
|
|
91
|
+
let cardStyles
|
|
92
|
+
let mediaIds
|
|
93
|
+
|
|
94
|
+
if (enableMediaQueryStyleSheet) {
|
|
95
|
+
const mediaQueryStyleSheet = createMediaQueryStyles(themeTokens)
|
|
96
|
+
|
|
97
|
+
const { ids, styles } = StyleSheet.create({
|
|
98
|
+
card: mediaQueryStyleSheet
|
|
99
|
+
})
|
|
100
|
+
cardStyles = styles.card
|
|
101
|
+
mediaIds = ids.card
|
|
102
|
+
} else {
|
|
103
|
+
cardStyles = themeTokens
|
|
104
|
+
}
|
|
105
|
+
|
|
74
106
|
return (
|
|
75
107
|
<>
|
|
76
108
|
<CardBase
|
|
77
109
|
ref={ref}
|
|
78
|
-
tokens={interactiveCard?.body ? restOfTokens :
|
|
79
|
-
dataSet={
|
|
110
|
+
tokens={interactiveCard?.body ? restOfTokens : cardStyles}
|
|
111
|
+
dataSet={mediaIds && { media: mediaIds }}
|
|
80
112
|
{...selectProps(rest)}
|
|
81
113
|
>
|
|
82
114
|
{interactiveCard?.body ? (
|
package/src/Link/ChevronLink.jsx
CHANGED
|
@@ -12,10 +12,7 @@ import LinkBase from './LinkBase'
|
|
|
12
12
|
* ChevronLink is not intended to be deeply themable; variants passed to ChevronLink are forwarded to Link.
|
|
13
13
|
*/
|
|
14
14
|
const ChevronLink = forwardRef(
|
|
15
|
-
(
|
|
16
|
-
{ direction = 'right', children, tokens = {}, variant, dataSet, onPress, ...otherlinkProps },
|
|
17
|
-
ref
|
|
18
|
-
) => {
|
|
15
|
+
({ direction = 'right', children, tokens = {}, variant, dataSet, ...otherlinkProps }, ref) => {
|
|
19
16
|
const getChevronTokens = useThemeTokensCallback('ChevronLink', tokens, variant)
|
|
20
17
|
const applyChevronTokens = (linkState) => {
|
|
21
18
|
const { leftIcon, rightIcon, iconDisplace, height, fontSize, ...otherTokens } =
|
|
@@ -41,7 +38,6 @@ const ChevronLink = forwardRef(
|
|
|
41
38
|
tokens={getTokens}
|
|
42
39
|
dataSet={dataSet}
|
|
43
40
|
ref={ref}
|
|
44
|
-
onPress={onPress}
|
|
45
41
|
>
|
|
46
42
|
{children}
|
|
47
43
|
</LinkBase>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
2
|
-
import { Pressable, StyleSheet
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import { Pressable, StyleSheet } from 'react-native'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {import('react-native').PressableProps} PressableProps
|
|
@@ -14,42 +14,20 @@ import { Pressable, StyleSheet, Platform } from 'react-native'
|
|
|
14
14
|
* @param {PressableProps} PressableProps
|
|
15
15
|
*/
|
|
16
16
|
// React Native exports prop Types but not propTypes, use JSDoc types here rather than duplicate RN
|
|
17
|
-
|
|
18
|
-
const InlinePressable = forwardRef(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
17
|
+
// eslint-disable-next-line react/prop-types
|
|
18
|
+
const InlinePressable = forwardRef(({ children, inlineFlex = true, style, ...props }, ref) => (
|
|
19
|
+
<Pressable
|
|
20
|
+
ref={ref}
|
|
21
|
+
style={(pressState) => [
|
|
22
|
+
typeof style === 'function' ? style(pressState) : style,
|
|
23
|
+
staticStyles[inlineFlex ? 'inlineFlex' : 'inline']
|
|
24
|
+
]}
|
|
25
|
+
{...props}
|
|
26
|
+
>
|
|
27
|
+
{(pressState) => (typeof children === 'function' ? children(pressState) : children)}
|
|
28
|
+
</Pressable>
|
|
29
|
+
))
|
|
25
30
|
|
|
26
|
-
const handleKeyPress = useCallback(
|
|
27
|
-
(e) => {
|
|
28
|
-
e.preventDefault()
|
|
29
|
-
|
|
30
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
31
|
-
handlePress()
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
[handlePress]
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Pressable
|
|
39
|
-
ref={ref}
|
|
40
|
-
style={(pressState) => [
|
|
41
|
-
typeof style === 'function' ? style(pressState) : style,
|
|
42
|
-
staticStyles[inlineFlex ? 'inlineFlex' : 'inline']
|
|
43
|
-
]}
|
|
44
|
-
onPress={handlePress}
|
|
45
|
-
onKeyDown={Platform.OS === 'web' ? handleKeyPress : undefined}
|
|
46
|
-
{...props}
|
|
47
|
-
>
|
|
48
|
-
{(pressState) => (typeof children === 'function' ? children(pressState) : children)}
|
|
49
|
-
</Pressable>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
31
|
InlinePressable.displayName = 'InlinePressable'
|
|
54
32
|
|
|
55
33
|
const staticStyles = StyleSheet.create({
|
package/src/Link/LinkBase.jsx
CHANGED
|
@@ -162,7 +162,6 @@ const LinkBase = forwardRef(
|
|
|
162
162
|
inlineFlex={hasIcon}
|
|
163
163
|
// assuming links without icons should be inline (even if they are long)
|
|
164
164
|
ref={ref}
|
|
165
|
-
keyboardShouldPersistTaps="handled"
|
|
166
165
|
style={(linkState) => {
|
|
167
166
|
const themeTokens = resolveLinkTokens(linkState)
|
|
168
167
|
const outerBorderStyles = selectOuterBorderStyles(themeTokens)
|
|
@@ -124,7 +124,6 @@ const Typography = forwardRef(
|
|
|
124
124
|
|
|
125
125
|
const resolvedTextProps = {
|
|
126
126
|
...selectTextProps(rest),
|
|
127
|
-
dataSet,
|
|
128
127
|
maxFontSizeMultiplier
|
|
129
128
|
}
|
|
130
129
|
|
|
@@ -158,9 +157,11 @@ const Typography = forwardRef(
|
|
|
158
157
|
return resetTagStyling(children)
|
|
159
158
|
}
|
|
160
159
|
|
|
160
|
+
const dataSetValue = mediaIds ? { media: mediaIds, ...dataSet } : dataSet
|
|
161
|
+
|
|
161
162
|
return block ? (
|
|
162
163
|
<View ref={ref} {...containerProps}>
|
|
163
|
-
<Text {...resolvedTextProps} style={textStyles} dataSet={
|
|
164
|
+
<Text {...resolvedTextProps} style={textStyles} dataSet={dataSetValue}>
|
|
164
165
|
{sanitizeChildren(children)}
|
|
165
166
|
</Text>
|
|
166
167
|
</View>
|
|
@@ -170,7 +171,7 @@ const Typography = forwardRef(
|
|
|
170
171
|
{...containerProps}
|
|
171
172
|
{...resolvedTextProps}
|
|
172
173
|
style={textStyles}
|
|
173
|
-
dataSet={
|
|
174
|
+
dataSet={dataSetValue}
|
|
174
175
|
>
|
|
175
176
|
{sanitizeChildren(children)}
|
|
176
177
|
</Text>
|
|
@@ -219,7 +220,11 @@ Typography.propTypes = {
|
|
|
219
220
|
/**
|
|
220
221
|
* Same children allowed as a React Native <Text> node
|
|
221
222
|
*/
|
|
222
|
-
children: PropTypes.node
|
|
223
|
+
children: PropTypes.node,
|
|
224
|
+
/**
|
|
225
|
+
* Data attributes to be added to the element
|
|
226
|
+
*/
|
|
227
|
+
dataSet: PropTypes.object
|
|
223
228
|
}
|
|
224
229
|
|
|
225
230
|
export default Typography
|