@telus-uds/components-base 3.2.0 → 3.4.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 +29 -2
- package/lib/cjs/Button/ButtonBase.js +1 -1
- package/lib/cjs/Button/ButtonLink.js +1 -0
- 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/ExpandCollapse/ExpandCollapse.js +3 -1
- package/lib/cjs/ExpandCollapseMini/ExpandCollapseMini.js +11 -2
- package/lib/cjs/Link/Link.js +8 -1
- package/lib/cjs/Link/LinkBase.js +2 -0
- package/lib/cjs/List/ListItemBase.js +1 -2
- package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +2 -2
- package/lib/cjs/TextInput/TextArea.js +10 -1
- package/lib/cjs/Typography/Typography.js +8 -2
- package/lib/cjs/utils/useUniqueId.js +2 -6
- package/lib/esm/Button/ButtonBase.js +2 -2
- package/lib/esm/Button/ButtonLink.js +2 -1
- 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/ExpandCollapse/ExpandCollapse.js +4 -2
- package/lib/esm/ExpandCollapseMini/ExpandCollapseMini.js +12 -3
- package/lib/esm/Link/Link.js +8 -1
- package/lib/esm/Link/LinkBase.js +2 -0
- package/lib/esm/List/ListItemBase.js +1 -2
- package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +2 -2
- package/lib/esm/TextInput/TextArea.js +10 -1
- package/lib/esm/Typography/Typography.js +8 -2
- package/lib/esm/utils/useUniqueId.js +3 -7
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/src/Button/ButtonBase.jsx +4 -2
- package/src/Button/ButtonLink.jsx +3 -1
- 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/ExpandCollapse/ExpandCollapse.jsx +9 -4
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +16 -4
- package/src/Link/Link.jsx +8 -1
- package/src/Link/LinkBase.jsx +2 -0
- package/src/List/ListItemBase.jsx +1 -2
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +1 -1
- package/src/TextInput/TextArea.jsx +11 -1
- package/src/Typography/Typography.jsx +8 -2
- package/src/utils/useUniqueId.js +3 -8
package/lib/esm/Link/Link.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import { useThemeTokensCallback } from '../ThemeProvider';
|
|
3
4
|
import LinkBase from './LinkBase';
|
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -24,5 +25,11 @@ const Link = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
24
25
|
});
|
|
25
26
|
});
|
|
26
27
|
Link.displayName = 'Link';
|
|
27
|
-
Link.propTypes =
|
|
28
|
+
Link.propTypes = {
|
|
29
|
+
...LinkBase.propTypes,
|
|
30
|
+
/**
|
|
31
|
+
* The dataSet prop allows to pass data-* attributes element to the component.
|
|
32
|
+
*/
|
|
33
|
+
dataSet: PropTypes.object
|
|
34
|
+
};
|
|
28
35
|
export default Link;
|
package/lib/esm/Link/LinkBase.js
CHANGED
|
@@ -136,6 +136,7 @@ const LinkBase = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
|
136
136
|
variant,
|
|
137
137
|
tokens = {},
|
|
138
138
|
children,
|
|
139
|
+
dataSet,
|
|
139
140
|
accessibilityRole = 'link',
|
|
140
141
|
...rawRest
|
|
141
142
|
} = _ref6;
|
|
@@ -170,6 +171,7 @@ const LinkBase = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
|
170
171
|
} = useTheme();
|
|
171
172
|
return /*#__PURE__*/_jsx(InlinePressable, {
|
|
172
173
|
...selectedProps,
|
|
174
|
+
dataSet: dataSet,
|
|
173
175
|
inlineFlex: hasIcon
|
|
174
176
|
// assuming links without icons should be inline (even if they are long)
|
|
175
177
|
,
|
|
@@ -286,9 +286,9 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
286
286
|
},
|
|
287
287
|
children: subtitle
|
|
288
288
|
})
|
|
289
|
-
}), /*#__PURE__*/_jsx(Spacer, {
|
|
290
|
-
space: 4
|
|
291
289
|
})]
|
|
290
|
+
}), /*#__PURE__*/_jsx(Spacer, {
|
|
291
|
+
space: 4
|
|
292
292
|
}), /*#__PURE__*/_jsx(View, {
|
|
293
293
|
style: styles.options,
|
|
294
294
|
children: /*#__PURE__*/_jsx(ScrollView, {
|
|
@@ -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 {
|
|
@@ -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);
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
let id = 0;
|
|
1
|
+
import { useId } from 'react';
|
|
3
2
|
function useUniqueId() {
|
|
4
3
|
let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
return `${prefix}-${id}`;
|
|
8
|
-
});
|
|
9
|
-
return uniqueId;
|
|
4
|
+
const id = useId();
|
|
5
|
+
return `${prefix ? `${prefix}-` : ''}${id}`;
|
|
10
6
|
}
|
|
11
7
|
export default useUniqueId;
|
package/lib/package.json
CHANGED
package/package.json
CHANGED
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
selectSystemProps,
|
|
16
16
|
viewProps,
|
|
17
17
|
wrapStringsInText,
|
|
18
|
-
withLinkRouter
|
|
18
|
+
withLinkRouter,
|
|
19
|
+
contentfulProps
|
|
19
20
|
} from '../utils'
|
|
20
21
|
import { IconText } from '../Icon'
|
|
21
22
|
|
|
@@ -23,7 +24,8 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([
|
|
|
23
24
|
a11yProps,
|
|
24
25
|
focusHandlerProps,
|
|
25
26
|
linkProps,
|
|
26
|
-
viewProps
|
|
27
|
+
viewProps,
|
|
28
|
+
contentfulProps
|
|
27
29
|
])
|
|
28
30
|
|
|
29
31
|
const getOuterBorderOffset = ({ outerBorderGap = 0, outerBorderWidth = 0 }) =>
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import ButtonBase from './ButtonBase'
|
|
4
4
|
import buttonPropTypes, { textAndA11yText } from './propTypes'
|
|
5
|
-
import { a11yProps, hrefAttrsProp, linkProps } from '../utils/props'
|
|
5
|
+
import { a11yProps, hrefAttrsProp, linkProps, contentfulProps } from '../utils/props'
|
|
6
6
|
import { useThemeTokensCallback } from '../ThemeProvider'
|
|
7
7
|
import { useViewport } from '../ViewportProvider'
|
|
8
8
|
|
|
@@ -16,6 +16,7 @@ const ButtonLink = React.forwardRef(
|
|
|
16
16
|
const viewport = useViewport()
|
|
17
17
|
const buttonVariant = { viewport, ...variant }
|
|
18
18
|
const getTokens = useThemeTokensCallback('Button', tokens, buttonVariant)
|
|
19
|
+
|
|
19
20
|
return (
|
|
20
21
|
<ButtonBase
|
|
21
22
|
ref={ref}
|
|
@@ -34,6 +35,7 @@ ButtonLink.propTypes = {
|
|
|
34
35
|
...a11yProps.types,
|
|
35
36
|
...buttonPropTypes,
|
|
36
37
|
...linkProps.types,
|
|
38
|
+
...contentfulProps.types,
|
|
37
39
|
children: textAndA11yText,
|
|
38
40
|
dataSet: PropTypes.object,
|
|
39
41
|
accessibilityRole: PropTypes.string
|
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>
|