@telus-uds/components-base 3.1.0 → 3.3.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 +35 -2
- package/lib/cjs/Card/CardBase.js +2 -1
- package/lib/cjs/Carousel/Carousel.js +202 -51
- package/lib/cjs/Carousel/CarouselItem/CarouselItem.js +1 -15
- package/lib/cjs/Carousel/CarouselStepTracker/CarouselStepTracker.js +6 -6
- package/lib/cjs/ExpandCollapse/Control.js +3 -1
- package/lib/cjs/ExpandCollapseMini/ExpandCollapseMini.js +1 -1
- package/lib/cjs/List/ListItemBase.js +1 -2
- package/lib/cjs/List/ListItemMark.js +6 -2
- package/lib/cjs/Modal/ModalContent.js +1 -1
- package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +2 -2
- package/lib/cjs/Notification/Notification.js +15 -25
- package/lib/cjs/TextInput/TextArea.js +10 -1
- package/lib/cjs/Typography/Typography.js +9 -3
- package/lib/esm/Card/CardBase.js +2 -1
- package/lib/esm/Carousel/Carousel.js +203 -52
- package/lib/esm/Carousel/CarouselItem/CarouselItem.js +2 -16
- package/lib/esm/Carousel/CarouselStepTracker/CarouselStepTracker.js +6 -6
- package/lib/esm/ExpandCollapse/Control.js +3 -1
- package/lib/esm/ExpandCollapseMini/ExpandCollapseMini.js +1 -1
- package/lib/esm/List/ListItemBase.js +1 -2
- package/lib/esm/List/ListItemMark.js +6 -2
- package/lib/esm/Modal/ModalContent.js +1 -1
- package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +2 -2
- package/lib/esm/Notification/Notification.js +16 -26
- package/lib/esm/TextInput/TextArea.js +10 -1
- package/lib/esm/Typography/Typography.js +9 -3
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Card/CardBase.jsx +2 -1
- package/src/Carousel/Carousel.jsx +200 -55
- package/src/Carousel/CarouselItem/CarouselItem.jsx +1 -7
- package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +5 -4
- package/src/ExpandCollapse/Control.jsx +3 -1
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +1 -1
- package/src/List/ListItemBase.jsx +1 -2
- package/src/List/ListItemMark.jsx +9 -3
- package/src/Modal/ModalContent.jsx +1 -1
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +1 -1
- package/src/Notification/Notification.jsx +14 -17
- package/src/TextInput/TextArea.jsx +11 -1
- package/src/Typography/Typography.jsx +9 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import View from "react-native-web/dist/exports/View";
|
|
3
|
-
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import { viewports } from '@telus-uds/system-constants';
|
|
5
5
|
import { applyTextStyles, useTheme, useThemeTokens, useResponsiveThemeTokens } from '../ThemeProvider';
|
|
6
|
-
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps, wrapStringsInText,
|
|
6
|
+
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps, wrapStringsInText, createMediaQueryStyles, StyleSheet } from '../utils';
|
|
7
7
|
import IconButton from '../IconButton';
|
|
8
8
|
import useCopy from '../utils/useCopy';
|
|
9
9
|
import dictionary from './dictionary';
|
|
@@ -64,12 +64,12 @@ const selectDismissButtonContainerStyles = _ref4 => {
|
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
66
|
const selectContentContainerStyle = (themeTokens, maxWidth, viewport, system) => ({
|
|
67
|
-
maxWidth: viewport === 'xl' && system === true ? maxWidth : '
|
|
68
|
-
|
|
67
|
+
maxWidth: viewport === 'xl' && system === true ? maxWidth : '100%',
|
|
68
|
+
width: '100%',
|
|
69
69
|
paddingRight: themeTokens?.containerPaddingRight,
|
|
70
70
|
paddingLeft: themeTokens?.containerPaddingLeft
|
|
71
71
|
});
|
|
72
|
-
const getMediaQueryStyles = (themeTokens, themeOptions, mediaIdsRef, dismissible, viewport, system) => {
|
|
72
|
+
const getMediaQueryStyles = (themeTokens, themeOptions, maxWidth, mediaIdsRef, dismissible, viewport, system) => {
|
|
73
73
|
const transformedSelectContainerStyles = Object.entries(themeTokens).reduce((acc, _ref5) => {
|
|
74
74
|
let [vp, viewportTokens] = _ref5;
|
|
75
75
|
acc[vp] = selectContainerStyles({
|
|
@@ -83,7 +83,7 @@ const getMediaQueryStyles = (themeTokens, themeOptions, mediaIdsRef, dismissible
|
|
|
83
83
|
styles: containerStyles
|
|
84
84
|
} = StyleSheet.create({
|
|
85
85
|
container: {
|
|
86
|
-
flexDirection:
|
|
86
|
+
flexDirection: 'column',
|
|
87
87
|
...selectContainerMediaQueryStyles
|
|
88
88
|
}
|
|
89
89
|
});
|
|
@@ -95,22 +95,9 @@ const getMediaQueryStyles = (themeTokens, themeOptions, mediaIdsRef, dismissible
|
|
|
95
95
|
flexDirection: 'row',
|
|
96
96
|
flexShrink: 1,
|
|
97
97
|
justifyContent: 'space-between',
|
|
98
|
-
...
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
md: {
|
|
103
|
-
maxWidth: themeOptions?.contentMaxWidth?.md || '100%'
|
|
104
|
-
},
|
|
105
|
-
lg: {
|
|
106
|
-
maxWidth: themeOptions?.contentMaxWidth?.lg || '100%'
|
|
107
|
-
},
|
|
108
|
-
sm: {
|
|
109
|
-
maxWidth: themeOptions?.contentMaxWidth?.sm || '100%'
|
|
110
|
-
},
|
|
111
|
-
xl: {
|
|
112
|
-
maxWidth: themeOptions?.contentMaxWidth?.xl || '100%'
|
|
113
|
-
}
|
|
98
|
+
...selectContentContainerStyle(themeTokens, maxWidth, viewport, system),
|
|
99
|
+
...(system && {
|
|
100
|
+
alignSelf: 'center'
|
|
114
101
|
})
|
|
115
102
|
}
|
|
116
103
|
});
|
|
@@ -175,7 +162,7 @@ const getMediaQueryStyles = (themeTokens, themeOptions, mediaIdsRef, dismissible
|
|
|
175
162
|
const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible, viewport, system) => ({
|
|
176
163
|
containerStyles: {
|
|
177
164
|
container: {
|
|
178
|
-
flexDirection:
|
|
165
|
+
flexDirection: 'column',
|
|
179
166
|
...selectContainerStyles(themeTokens)
|
|
180
167
|
}
|
|
181
168
|
},
|
|
@@ -184,7 +171,10 @@ const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible, view
|
|
|
184
171
|
flexDirection: 'row',
|
|
185
172
|
flexShrink: 1,
|
|
186
173
|
justifyContent: 'space-between',
|
|
187
|
-
...selectContentContainerStyle(themeTokens, maxWidth, viewport, system)
|
|
174
|
+
...selectContentContainerStyle(themeTokens, maxWidth, viewport, system),
|
|
175
|
+
...(system && {
|
|
176
|
+
alignSelf: 'center'
|
|
177
|
+
})
|
|
188
178
|
}
|
|
189
179
|
},
|
|
190
180
|
staticContentContainerStyles: {
|
|
@@ -302,7 +292,7 @@ const Notification = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
|
302
292
|
system: isSystemEnabled,
|
|
303
293
|
viewport
|
|
304
294
|
});
|
|
305
|
-
const maxWidth =
|
|
295
|
+
const maxWidth = viewports.map.get(viewports.xl);
|
|
306
296
|
const notificationComponentRef = React.useRef({
|
|
307
297
|
containerStyles: {},
|
|
308
298
|
contentContainerStyles: {},
|
|
@@ -324,7 +314,7 @@ const Notification = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
|
324
314
|
selectDismissIconPropsIds: {}
|
|
325
315
|
});
|
|
326
316
|
if (enableMediaQueryStyleSheet) {
|
|
327
|
-
notificationComponentRef.current = getMediaQueryStyles(themeTokens, themeOptions, mediaIdsRef, dismissible, viewport, isSystemEnabled);
|
|
317
|
+
notificationComponentRef.current = getMediaQueryStyles(themeTokens, themeOptions, maxWidth, mediaIdsRef, dismissible, viewport, isSystemEnabled);
|
|
328
318
|
} else {
|
|
329
319
|
notificationComponentRef.current = getDefaultStyles(themeTokens, themeOptions, maxWidth, dismissible, viewport, isSystemEnabled);
|
|
330
320
|
}
|
|
@@ -40,6 +40,7 @@ const TextArea = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
40
40
|
} = _ref;
|
|
41
41
|
const themeTokens = useThemeTokens('TextArea', tokens, variant);
|
|
42
42
|
const [inputHeight, setInputHeight] = React.useState();
|
|
43
|
+
const isUpdatingHeight = React.useRef(false);
|
|
43
44
|
|
|
44
45
|
// adjust the text area's height as new lines are added to the content
|
|
45
46
|
const onHeightChange = _ref2 => {
|
|
@@ -51,8 +52,16 @@ const TextArea = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
51
52
|
}
|
|
52
53
|
} = _ref2;
|
|
53
54
|
// on native this is happens out of the box
|
|
54
|
-
if (Platform.OS === 'web') {
|
|
55
|
+
if (Platform.OS === 'web' && !isUpdatingHeight.current) {
|
|
56
|
+
isUpdatingHeight.current = true;
|
|
55
57
|
setInputHeight(height);
|
|
58
|
+
// setTimeout is used to “wait” for the next update cycle before allowing a new height adjustment,
|
|
59
|
+
// avoiding multiple updates in the same render and preventing a possible infinite loop or constant re-renders.
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
isUpdatingHeight.current = false;
|
|
62
|
+
}, 0);
|
|
63
|
+
} else {
|
|
64
|
+
setInputHeight(null);
|
|
56
65
|
}
|
|
57
66
|
};
|
|
58
67
|
const {
|
|
@@ -63,7 +63,7 @@ const Typography = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
63
63
|
tag = typeof heading === 'string' ? heading : undefined,
|
|
64
64
|
accessibilityRole = heading === true ? 'header' : undefined,
|
|
65
65
|
block = false,
|
|
66
|
-
align = undefined,
|
|
66
|
+
align = Platform.OS === 'web' ? 'inherit' : undefined,
|
|
67
67
|
tokens,
|
|
68
68
|
dataSet,
|
|
69
69
|
strikeThrough = false,
|
|
@@ -112,13 +112,19 @@ const Typography = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
112
112
|
backgroundClip: 'text'
|
|
113
113
|
} : styles;
|
|
114
114
|
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Added to maintain previous behavior, as the 'auto' value for the 'align' prop now defaults to 'inherit' on the web,
|
|
118
|
+
* maintaining the previous behavior that was changed in the Text component of react-native.
|
|
119
|
+
*/
|
|
120
|
+
const resolvedAlign = Platform.OS === 'web' && align === 'auto' ? 'inherit' : align;
|
|
115
121
|
let textStyles;
|
|
116
122
|
let mediaIds;
|
|
117
123
|
if (enableMediaQueryStyleSheet) {
|
|
118
124
|
const transformedThemeTokens = Object.entries(themeTokens).reduce((acc, _ref4) => {
|
|
119
125
|
let [vp, viewportTokens] = _ref4;
|
|
120
126
|
acc[vp] = selectTextStyles({
|
|
121
|
-
textAlign:
|
|
127
|
+
textAlign: resolvedAlign,
|
|
122
128
|
textDecorationLine,
|
|
123
129
|
...viewportTokens
|
|
124
130
|
}, themeOptions);
|
|
@@ -147,7 +153,7 @@ const Typography = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
147
153
|
mediaIds = ids.text;
|
|
148
154
|
} else {
|
|
149
155
|
textStyles = selectTextStyles({
|
|
150
|
-
textAlign:
|
|
156
|
+
textAlign: resolvedAlign,
|
|
151
157
|
textDecorationLine,
|
|
152
158
|
...themeTokens
|
|
153
159
|
}, themeOptions);
|
package/lib/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@gorhom/portal": "^1.0.14",
|
|
13
13
|
"@react-native-picker/picker": "^2.9.0",
|
|
14
14
|
"@telus-uds/system-constants": "^3.0.0",
|
|
15
|
-
"@telus-uds/system-theme-tokens": "^4.
|
|
15
|
+
"@telus-uds/system-theme-tokens": "^4.2.0",
|
|
16
16
|
"airbnb-prop-types": "^2.16.0",
|
|
17
17
|
"css-mediaquery": "^0.1.2",
|
|
18
18
|
"expo-document-picker": "^13.0.1",
|
|
@@ -83,6 +83,6 @@
|
|
|
83
83
|
"standard-engine": {
|
|
84
84
|
"skip": true
|
|
85
85
|
},
|
|
86
|
-
"version": "3.
|
|
86
|
+
"version": "3.3.0",
|
|
87
87
|
"types": "types/index.d.ts"
|
|
88
88
|
}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@gorhom/portal": "^1.0.14",
|
|
13
13
|
"@react-native-picker/picker": "^2.9.0",
|
|
14
14
|
"@telus-uds/system-constants": "^3.0.0",
|
|
15
|
-
"@telus-uds/system-theme-tokens": "^4.
|
|
15
|
+
"@telus-uds/system-theme-tokens": "^4.2.0",
|
|
16
16
|
"airbnb-prop-types": "^2.16.0",
|
|
17
17
|
"css-mediaquery": "^0.1.2",
|
|
18
18
|
"expo-document-picker": "^13.0.1",
|
|
@@ -83,6 +83,6 @@
|
|
|
83
83
|
"standard-engine": {
|
|
84
84
|
"skip": true
|
|
85
85
|
},
|
|
86
|
-
"version": "3.
|
|
86
|
+
"version": "3.3.0",
|
|
87
87
|
"types": "types/index.d.ts"
|
|
88
88
|
}
|
package/src/Card/CardBase.jsx
CHANGED
|
@@ -72,11 +72,12 @@ const CardBase = React.forwardRef(
|
|
|
72
72
|
<View style={cardStyle} dataSet={dataSet} ref={ref} {...props}>
|
|
73
73
|
{src ? (
|
|
74
74
|
<ImageBackground
|
|
75
|
-
alt={alt}
|
|
76
75
|
source={imageSourceViewport}
|
|
77
76
|
imageStyle={{ borderRadius: cardStyle?.borderRadius - cardStyle?.borderWidth }}
|
|
78
77
|
resizeMode={backgroundImageResizeMode}
|
|
79
78
|
style={styles.imageBackground}
|
|
79
|
+
accessible={true}
|
|
80
|
+
accessibilityLabel={alt}
|
|
80
81
|
>
|
|
81
82
|
{children}
|
|
82
83
|
</ImageBackground>
|