@telus-uds/components-web 4.17.0 → 4.18.1
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 -3
- package/lib/cjs/Card/Card.js +295 -118
- package/lib/cjs/Card/CardContent.js +36 -7
- package/lib/cjs/NavigationBar/NavigationBar.js +59 -17
- package/lib/cjs/NavigationBar/collapseItems.js +1 -1
- package/lib/cjs/QuantitySelector/QuantitySelector.js +34 -14
- package/lib/cjs/Testimonial/Testimonial.js +2 -1
- package/lib/cjs/shared/FullBleedContent/FullBleedContent.js +46 -8
- package/lib/esm/Card/Card.js +295 -118
- package/lib/esm/Card/CardContent.js +36 -7
- package/lib/esm/NavigationBar/NavigationBar.js +60 -18
- package/lib/esm/NavigationBar/collapseItems.js +1 -1
- package/lib/esm/QuantitySelector/QuantitySelector.js +35 -15
- package/lib/esm/Testimonial/Testimonial.js +1 -0
- package/lib/esm/shared/FullBleedContent/FullBleedContent.js +48 -9
- package/package.json +3 -3
- package/src/Card/Card.jsx +313 -116
- package/src/Card/CardContent.jsx +40 -8
- package/src/NavigationBar/NavigationBar.jsx +39 -4
- package/src/NavigationBar/collapseItems.js +1 -1
- package/src/QuantitySelector/QuantitySelector.jsx +36 -18
- package/src/Testimonial/Testimonial.jsx +1 -0
- package/src/shared/FullBleedContent/FullBleedContent.jsx +34 -4
|
@@ -28,12 +28,28 @@ const Heading = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
|
28
28
|
letterSpacing: 0
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
+
const ContentWrapper = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
32
|
+
displayName: "NavigationBar__ContentWrapper",
|
|
33
|
+
componentId: "components-web__sc-1vis1gt-1"
|
|
34
|
+
})(_ref => {
|
|
35
|
+
let {
|
|
36
|
+
maxWidth
|
|
37
|
+
} = _ref;
|
|
38
|
+
return {
|
|
39
|
+
width: '100%',
|
|
40
|
+
...(maxWidth && {
|
|
41
|
+
maxWidth,
|
|
42
|
+
marginLeft: 'auto',
|
|
43
|
+
marginRight: 'auto'
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
});
|
|
31
47
|
|
|
32
48
|
/**
|
|
33
49
|
* NavigationBar can be used to allow customers to consistently navigate across
|
|
34
50
|
* key pages within a specific product line
|
|
35
51
|
*/
|
|
36
|
-
const NavigationBar = /*#__PURE__*/_react.default.forwardRef((
|
|
52
|
+
const NavigationBar = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
37
53
|
let {
|
|
38
54
|
accessibilityRole = 'navigation',
|
|
39
55
|
heading,
|
|
@@ -46,8 +62,9 @@ const NavigationBar = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
46
62
|
linkRouterProps,
|
|
47
63
|
tokens,
|
|
48
64
|
variant,
|
|
65
|
+
contentMaxWidth,
|
|
49
66
|
...rest
|
|
50
|
-
} =
|
|
67
|
+
} = _ref2;
|
|
51
68
|
const {
|
|
52
69
|
currentValue,
|
|
53
70
|
setValue
|
|
@@ -56,29 +73,35 @@ const NavigationBar = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
56
73
|
initialValue: selectedId,
|
|
57
74
|
onChange
|
|
58
75
|
});
|
|
76
|
+
const {
|
|
77
|
+
themeOptions
|
|
78
|
+
} = (0, _componentsBase.useTheme)();
|
|
79
|
+
const contentWidthValue = (0, _componentsBase.useResponsiveProp)(contentMaxWidth);
|
|
80
|
+
const responsiveWidth = (0, _componentsBase.useResponsiveProp)(themeOptions?.contentMaxWidth);
|
|
81
|
+
const maxWidth = (0, _componentsBase.resolveContentMaxWidth)(contentWidthValue, responsiveWidth);
|
|
59
82
|
(0, _componentsBase.useHash)((hash, event) => {
|
|
60
|
-
let hashItem = hash && items.find(
|
|
83
|
+
let hashItem = hash && items.find(_ref3 => {
|
|
61
84
|
let {
|
|
62
85
|
href
|
|
63
|
-
} =
|
|
86
|
+
} = _ref3;
|
|
64
87
|
return hash === href;
|
|
65
88
|
});
|
|
66
89
|
if (!hashItem) {
|
|
67
|
-
const parentItem = items.find(
|
|
90
|
+
const parentItem = items.find(_ref4 => {
|
|
68
91
|
let {
|
|
69
92
|
items: parentItems
|
|
70
|
-
} =
|
|
71
|
-
return parentItems?.some(
|
|
93
|
+
} = _ref4;
|
|
94
|
+
return parentItems?.some(_ref5 => {
|
|
72
95
|
let {
|
|
73
96
|
href
|
|
74
|
-
} =
|
|
97
|
+
} = _ref5;
|
|
75
98
|
return hash === href;
|
|
76
99
|
});
|
|
77
100
|
});
|
|
78
|
-
hashItem = parentItem?.items.find(
|
|
101
|
+
hashItem = parentItem?.items.find(_ref6 => {
|
|
79
102
|
let {
|
|
80
103
|
href
|
|
81
|
-
} =
|
|
104
|
+
} = _ref6;
|
|
82
105
|
return hash === href;
|
|
83
106
|
});
|
|
84
107
|
}
|
|
@@ -145,7 +168,7 @@ const NavigationBar = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
145
168
|
}
|
|
146
169
|
};
|
|
147
170
|
}, [openSubMenuId, handleMouseDown]);
|
|
148
|
-
|
|
171
|
+
const stackView = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.StackView, {
|
|
149
172
|
accessibilityRole: accessibilityRole,
|
|
150
173
|
direction: direction,
|
|
151
174
|
ref: navRef,
|
|
@@ -163,7 +186,7 @@ const NavigationBar = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
163
186
|
heading: headingLevel,
|
|
164
187
|
children: heading
|
|
165
188
|
})
|
|
166
|
-
}), itemsForViewport?.map((
|
|
189
|
+
}), itemsForViewport?.map((_ref7, index) => {
|
|
167
190
|
let {
|
|
168
191
|
href,
|
|
169
192
|
label,
|
|
@@ -174,7 +197,7 @@ const NavigationBar = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
174
197
|
linkRouterProps: itemLinkRouterProps,
|
|
175
198
|
items: nestedItems,
|
|
176
199
|
...itemRest
|
|
177
|
-
} =
|
|
200
|
+
} = _ref7;
|
|
178
201
|
const itemId = id ?? label;
|
|
179
202
|
const handleClick = event => {
|
|
180
203
|
if (nestedItems) {
|
|
@@ -200,9 +223,7 @@ const NavigationBar = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
200
223
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ItemComponent, {
|
|
201
224
|
ref: itemRef,
|
|
202
225
|
href: href,
|
|
203
|
-
onClick: handleClick
|
|
204
|
-
// TODO: refactor to pass selected ID via context
|
|
205
|
-
,
|
|
226
|
+
onClick: handleClick,
|
|
206
227
|
selectedId: currentValue,
|
|
207
228
|
index: index,
|
|
208
229
|
LinkRouter: ItemLinkRouter,
|
|
@@ -226,6 +247,10 @@ const NavigationBar = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
226
247
|
}, itemId);
|
|
227
248
|
})]
|
|
228
249
|
});
|
|
250
|
+
return maxWidth ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ContentWrapper, {
|
|
251
|
+
maxWidth: maxWidth,
|
|
252
|
+
children: stackView
|
|
253
|
+
}) : stackView;
|
|
229
254
|
});
|
|
230
255
|
NavigationBar.displayName = 'NavigationBar';
|
|
231
256
|
NavigationBar.propTypes = {
|
|
@@ -285,6 +310,23 @@ NavigationBar.propTypes = {
|
|
|
285
310
|
/**
|
|
286
311
|
* Variant configuration
|
|
287
312
|
*/
|
|
288
|
-
variant: _componentsBase.variantProp.propType
|
|
313
|
+
variant: _componentsBase.variantProp.propType,
|
|
314
|
+
/**
|
|
315
|
+
* The maximum width of the content in the NavigationBar.
|
|
316
|
+
* This prop accepts responsive values for different viewports. If a number is provided,
|
|
317
|
+
* it will be the max content width for the desired viewport.
|
|
318
|
+
* - `xs`: 'max' | 'full' | <number>
|
|
319
|
+
* - `sm`: 'max' | 'full' | <number>
|
|
320
|
+
* - `md`: 'max' | 'full' | <number>
|
|
321
|
+
* - `lg`: 'max' | 'full' | <number>
|
|
322
|
+
* - `xl`: 'max' | 'full' | <number>
|
|
323
|
+
*/
|
|
324
|
+
contentMaxWidth: _propTypes.default.shape({
|
|
325
|
+
xl: _propTypes.default.oneOfType([_propTypes.default.oneOf(['max', 'full']), _propTypes.default.number]),
|
|
326
|
+
lg: _propTypes.default.oneOfType([_propTypes.default.oneOf(['max', 'full']), _propTypes.default.number]),
|
|
327
|
+
md: _propTypes.default.oneOfType([_propTypes.default.oneOf(['max', 'full']), _propTypes.default.number]),
|
|
328
|
+
sm: _propTypes.default.oneOfType([_propTypes.default.oneOf(['max', 'full']), _propTypes.default.number]),
|
|
329
|
+
xs: _propTypes.default.oneOfType([_propTypes.default.oneOf(['max', 'full']), _propTypes.default.number])
|
|
330
|
+
})
|
|
289
331
|
};
|
|
290
332
|
var _default = exports.default = NavigationBar;
|
|
@@ -40,6 +40,7 @@ const QuantitySelector = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
40
40
|
},
|
|
41
41
|
tokens,
|
|
42
42
|
testID = 'quantity-selector-testid',
|
|
43
|
+
inactive = false,
|
|
43
44
|
...rest
|
|
44
45
|
} = _ref;
|
|
45
46
|
const {
|
|
@@ -64,8 +65,8 @@ const QuantitySelector = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
64
65
|
initialValue: getValidatedNumber(defaultValue),
|
|
65
66
|
onChange
|
|
66
67
|
});
|
|
67
|
-
const isDecreaseEnabled = !disabled && !isNumber(minNumber) || number > minNumber;
|
|
68
|
-
const isIncreaseEnabled = !disabled && !isNumber(maxNumber) || number < maxNumber;
|
|
68
|
+
const isDecreaseEnabled = (!disabled && !isNumber(minNumber) || number > minNumber) && !inactive;
|
|
69
|
+
const isIncreaseEnabled = (!disabled && !isNumber(maxNumber) || number < maxNumber) && !inactive;
|
|
69
70
|
const inputValue = isNumber(number) ? number.toString() : '';
|
|
70
71
|
const updateNumber = (newNumber, originalInputEvent) => {
|
|
71
72
|
try {
|
|
@@ -85,15 +86,30 @@ const QuantitySelector = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
85
86
|
setError(getCopy('errors').invalidCharacters);
|
|
86
87
|
}
|
|
87
88
|
};
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
const getTokens = (0, _componentsBase.useThemeTokensCallback)('QuantitySelector', tokens, {
|
|
90
|
+
inactive,
|
|
91
|
+
...variant
|
|
92
|
+
});
|
|
93
|
+
const renderLabelAndSpacer = () => {
|
|
94
|
+
const {
|
|
95
|
+
showTopSpace
|
|
96
|
+
} = getTokens();
|
|
97
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
98
|
+
children: [(label || hint) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.InputLabel, {
|
|
99
|
+
forId: id,
|
|
100
|
+
label: label,
|
|
101
|
+
hint: hint,
|
|
102
|
+
hintPosition: hintPosition,
|
|
103
|
+
tooltip: tooltip
|
|
104
|
+
}), label || hint ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Spacer, {
|
|
105
|
+
space: 2
|
|
106
|
+
}) : showTopSpace && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Spacer, {
|
|
107
|
+
space: 2
|
|
108
|
+
})]
|
|
109
|
+
});
|
|
110
|
+
};
|
|
96
111
|
const renderTextInput = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.TextInput, {
|
|
112
|
+
inactive: inactive,
|
|
97
113
|
nativeID: id,
|
|
98
114
|
value: inputValue,
|
|
99
115
|
defaultValue: defaultValue,
|
|
@@ -138,9 +154,7 @@ const QuantitySelector = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
138
154
|
testID: testID,
|
|
139
155
|
ref: ref,
|
|
140
156
|
...selectProps(rest),
|
|
141
|
-
children: [
|
|
142
|
-
space: 2
|
|
143
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.InputWrapper, {
|
|
157
|
+
children: [renderLabelAndSpacer(), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.InputWrapper, {
|
|
144
158
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.InputField, {
|
|
145
159
|
children: renderTextInput()
|
|
146
160
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -152,6 +166,7 @@ const QuantitySelector = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
152
166
|
tokens: tokens,
|
|
153
167
|
variant: {
|
|
154
168
|
decrease: true,
|
|
169
|
+
inactive,
|
|
155
170
|
...variant
|
|
156
171
|
},
|
|
157
172
|
accessibilityLabel: getCopy('accessibility').decreaseButton,
|
|
@@ -168,6 +183,7 @@ const QuantitySelector = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
168
183
|
tokens: tokens,
|
|
169
184
|
variant: {
|
|
170
185
|
increase: true,
|
|
186
|
+
inactive,
|
|
171
187
|
...variant
|
|
172
188
|
}
|
|
173
189
|
})
|
|
@@ -262,6 +278,10 @@ QuantitySelector.propTypes = {
|
|
|
262
278
|
/**
|
|
263
279
|
* Sets `data-testid` attribute on the input field for testing purposes.
|
|
264
280
|
*/
|
|
265
|
-
testID: _propTypes.default.string
|
|
281
|
+
testID: _propTypes.default.string,
|
|
282
|
+
/**
|
|
283
|
+
* If true, the quantity selector will be disabled
|
|
284
|
+
*/
|
|
285
|
+
inactive: _propTypes.default.bool
|
|
266
286
|
};
|
|
267
287
|
var _default = exports.default = QuantitySelector;
|
|
@@ -226,7 +226,8 @@ Testimonial.propTypes = {
|
|
|
226
226
|
testimonialStyle: _propTypes.default.oneOf(['large', 'heading']),
|
|
227
227
|
/**
|
|
228
228
|
* Whether to show or not dividers at the top and the bottom of the testimonial
|
|
229
|
-
|
|
229
|
+
*/
|
|
230
|
+
showDivider: _propTypes.default.bool,
|
|
230
231
|
/**
|
|
231
232
|
* The src attribute for the Image component or custom JSX content to render instead
|
|
232
233
|
*/
|
|
@@ -10,6 +10,10 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
10
10
|
var _ResponsiveImage = _interopRequireDefault(require("../../ResponsiveImage"));
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
// Interactive overlay opacity constants
|
|
14
|
+
const OVERLAY_OPACITY_PRESSED = 0.2;
|
|
15
|
+
const OVERLAY_OPACITY_HOVER = 0.1;
|
|
16
|
+
const OVERLAY_OPACITY_DEFAULT = 0;
|
|
13
17
|
const selectFullBleedContentProps = _ref => {
|
|
14
18
|
let {
|
|
15
19
|
alt,
|
|
@@ -48,9 +52,11 @@ const FullBleedContentContainer = /*#__PURE__*/_styledComponents.default.div.wit
|
|
|
48
52
|
borderTopLeftRadius,
|
|
49
53
|
borderTopRightRadius,
|
|
50
54
|
opacity,
|
|
51
|
-
transform
|
|
55
|
+
transform,
|
|
56
|
+
hasCardState
|
|
52
57
|
} = _ref2;
|
|
53
58
|
return {
|
|
59
|
+
position: hasCardState ? 'relative' : 'static',
|
|
54
60
|
overflow: 'hidden',
|
|
55
61
|
borderBottomLeftRadius,
|
|
56
62
|
borderBottomRightRadius,
|
|
@@ -61,24 +67,56 @@ const FullBleedContentContainer = /*#__PURE__*/_styledComponents.default.div.wit
|
|
|
61
67
|
transition: 'opacity 0.2s ease, transform 0.2s ease'
|
|
62
68
|
};
|
|
63
69
|
});
|
|
70
|
+
const InteractiveOverlay = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
71
|
+
displayName: "FullBleedContent__InteractiveOverlay",
|
|
72
|
+
componentId: "components-web__sc-1130ea5-1"
|
|
73
|
+
})(_ref3 => {
|
|
74
|
+
let {
|
|
75
|
+
overlayOpacity,
|
|
76
|
+
overlayBackgroundColor
|
|
77
|
+
} = _ref3;
|
|
78
|
+
return {
|
|
79
|
+
position: 'absolute',
|
|
80
|
+
top: 0,
|
|
81
|
+
left: 0,
|
|
82
|
+
right: 0,
|
|
83
|
+
bottom: 0,
|
|
84
|
+
backgroundColor: overlayBackgroundColor || 'rgba(0, 0, 0, 0.1)',
|
|
85
|
+
opacity: overlayOpacity || 0,
|
|
86
|
+
pointerEvents: 'none',
|
|
87
|
+
transition: 'opacity 0.2s ease',
|
|
88
|
+
zIndex: 1
|
|
89
|
+
};
|
|
90
|
+
});
|
|
64
91
|
|
|
65
92
|
/**
|
|
66
93
|
* Full bleed content component can accept either a single source,
|
|
67
94
|
* a number of sources corresponding to the `ResponsiveImage` component API,
|
|
68
95
|
* or a custom component.
|
|
69
96
|
*/
|
|
70
|
-
const FullBleedContent =
|
|
97
|
+
const FullBleedContent = _ref4 => {
|
|
71
98
|
let {
|
|
72
99
|
borderRadius,
|
|
73
100
|
content,
|
|
74
101
|
cardState,
|
|
75
102
|
...rest
|
|
76
|
-
} =
|
|
77
|
-
|
|
103
|
+
} = _ref4;
|
|
104
|
+
let overlayOpacity = OVERLAY_OPACITY_DEFAULT;
|
|
105
|
+
if (cardState) {
|
|
106
|
+
if (cardState.pressed) {
|
|
107
|
+
overlayOpacity = OVERLAY_OPACITY_PRESSED;
|
|
108
|
+
} else if (cardState.hover) {
|
|
109
|
+
overlayOpacity = OVERLAY_OPACITY_HOVER;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(FullBleedContentContainer, {
|
|
78
113
|
...borderRadius,
|
|
79
|
-
|
|
114
|
+
hasCardState: !!cardState,
|
|
115
|
+
children: [content ?? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResponsiveImage.default, {
|
|
80
116
|
...selectFullBleedContentProps(rest)
|
|
81
|
-
})
|
|
117
|
+
}), cardState && /*#__PURE__*/(0, _jsxRuntime.jsx)(InteractiveOverlay, {
|
|
118
|
+
overlayOpacity: overlayOpacity
|
|
119
|
+
})]
|
|
82
120
|
});
|
|
83
121
|
};
|
|
84
122
|
FullBleedContent.propTypes = {
|
|
@@ -96,10 +134,10 @@ FullBleedContent.propTypes = {
|
|
|
96
134
|
*/
|
|
97
135
|
content: _propTypes.default.node,
|
|
98
136
|
/**
|
|
99
|
-
* Card state object containing interactive states (
|
|
137
|
+
* Card state object containing interactive states (hover, pressed, focused).
|
|
100
138
|
*/
|
|
101
139
|
cardState: _propTypes.default.shape({
|
|
102
|
-
|
|
140
|
+
hover: _propTypes.default.bool,
|
|
103
141
|
pressed: _propTypes.default.bool,
|
|
104
142
|
focused: _propTypes.default.bool
|
|
105
143
|
}),
|