@telus-uds/components-web 4.16.0 → 4.18.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 +34 -1
- package/lib/cjs/Card/Card.js +267 -107
- package/lib/cjs/NavigationBar/NavigationBar.js +59 -17
- package/lib/cjs/NavigationBar/NavigationSubMenu.js +51 -34
- package/lib/cjs/NavigationBar/collapseItems.js +1 -1
- package/lib/cjs/QuantitySelector/QuantitySelector.js +34 -14
- package/lib/cjs/shared/FullBleedContent/FullBleedContent.js +46 -8
- package/lib/cjs/utils/useOverlaidPosition.js +11 -1
- package/lib/esm/Card/Card.js +267 -107
- package/lib/esm/NavigationBar/NavigationBar.js +60 -18
- package/lib/esm/NavigationBar/NavigationSubMenu.js +49 -34
- package/lib/esm/NavigationBar/collapseItems.js +1 -1
- package/lib/esm/QuantitySelector/QuantitySelector.js +35 -15
- package/lib/esm/shared/FullBleedContent/FullBleedContent.js +48 -9
- package/lib/esm/utils/useOverlaidPosition.js +11 -1
- package/package.json +3 -3
- package/src/Card/Card.jsx +276 -110
- package/src/NavigationBar/NavigationBar.jsx +39 -4
- package/src/NavigationBar/NavigationSubMenu.jsx +38 -11
- package/src/NavigationBar/collapseItems.js +1 -1
- package/src/QuantitySelector/QuantitySelector.jsx +36 -18
- package/src/shared/FullBleedContent/FullBleedContent.jsx +34 -4
- package/src/utils/useOverlaidPosition.js +9 -1
|
@@ -12,11 +12,52 @@ var _useOverlaidPosition = _interopRequireDefault(require("../utils/useOverlaidP
|
|
|
12
12
|
var _resolveItemSelection = _interopRequireDefault(require("./resolveItemSelection"));
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const MIN_WIDTH = 192;
|
|
16
|
+
const MAX_WIDTH = 289;
|
|
17
|
+
const DEFAULT_OFFSETS = {
|
|
18
|
+
offsets: {
|
|
19
|
+
vertical: 4
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const XS_ALIGN = {
|
|
23
|
+
top: 'bottom',
|
|
24
|
+
left: 'left'
|
|
25
|
+
};
|
|
26
|
+
const SM_ALIGN = {
|
|
27
|
+
top: 'bottom',
|
|
28
|
+
right: 'right'
|
|
29
|
+
};
|
|
30
|
+
const LG_ALIGN = {
|
|
31
|
+
top: 'bottom',
|
|
32
|
+
center: 'center'
|
|
33
|
+
};
|
|
34
|
+
const getResponsiveBreakpoints = sourceWidth => ({
|
|
35
|
+
xs: {
|
|
36
|
+
...DEFAULT_OFFSETS,
|
|
37
|
+
align: XS_ALIGN,
|
|
38
|
+
minWidth: sourceWidth,
|
|
39
|
+
maxWidth: sourceWidth
|
|
40
|
+
},
|
|
41
|
+
sm: {
|
|
42
|
+
...DEFAULT_OFFSETS,
|
|
43
|
+
align: SM_ALIGN,
|
|
44
|
+
minWidth: sourceWidth,
|
|
45
|
+
maxWidth: sourceWidth
|
|
46
|
+
},
|
|
47
|
+
lg: {
|
|
48
|
+
...DEFAULT_OFFSETS,
|
|
49
|
+
align: LG_ALIGN,
|
|
50
|
+
minWidth: MIN_WIDTH,
|
|
51
|
+
maxWidth: MAX_WIDTH
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
15
55
|
/**
|
|
16
56
|
* A NavigationItem that opens or closes a Listbox of other NavigationItems.
|
|
17
57
|
*
|
|
18
58
|
* This is rendered automatically by `NavigationBar` and isn't intended be used directly.
|
|
19
|
-
*/
|
|
59
|
+
*/
|
|
60
|
+
const NavigationSubMenu = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
20
61
|
let {
|
|
21
62
|
children,
|
|
22
63
|
id,
|
|
@@ -33,42 +74,13 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
33
74
|
itemsContainerRef
|
|
34
75
|
} = _ref;
|
|
35
76
|
const focusTrapRef = _react.default.useRef();
|
|
36
|
-
const
|
|
37
|
-
const defaultOffsets = {
|
|
38
|
-
offsets: {
|
|
39
|
-
vertical: 4
|
|
40
|
-
}
|
|
41
|
-
};
|
|
77
|
+
const [sourceWidth, setSourceWidth] = _react.default.useState(0);
|
|
42
78
|
const {
|
|
43
79
|
align,
|
|
44
80
|
offsets,
|
|
45
|
-
minWidth
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
...defaultOffsets,
|
|
49
|
-
align: {
|
|
50
|
-
top: 'bottom',
|
|
51
|
-
left: 'left'
|
|
52
|
-
},
|
|
53
|
-
minWidth: maxWidth
|
|
54
|
-
},
|
|
55
|
-
sm: {
|
|
56
|
-
...defaultOffsets,
|
|
57
|
-
align: {
|
|
58
|
-
top: 'bottom',
|
|
59
|
-
right: 'right'
|
|
60
|
-
},
|
|
61
|
-
minWidth: maxWidth
|
|
62
|
-
},
|
|
63
|
-
lg: {
|
|
64
|
-
...defaultOffsets,
|
|
65
|
-
align: {
|
|
66
|
-
top: 'bottom',
|
|
67
|
-
center: 'center'
|
|
68
|
-
},
|
|
69
|
-
minWidth: 192
|
|
70
|
-
}
|
|
71
|
-
});
|
|
81
|
+
minWidth,
|
|
82
|
+
maxWidth
|
|
83
|
+
} = (0, _componentsBase.useResponsiveProp)(getResponsiveBreakpoints(sourceWidth));
|
|
72
84
|
const {
|
|
73
85
|
overlaidPosition,
|
|
74
86
|
sourceRef,
|
|
@@ -95,6 +107,11 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
95
107
|
} = (0, _componentsBase.useThemeTokens)('NavigationBar', tokens, {}, {
|
|
96
108
|
expanded: isOpen
|
|
97
109
|
});
|
|
110
|
+
_react.default.useEffect(() => {
|
|
111
|
+
sourceRef.current?.measureInWindow((_, __, width) => {
|
|
112
|
+
setSourceWidth(width);
|
|
113
|
+
});
|
|
114
|
+
}, [isOpen, sourceRef]);
|
|
98
115
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
99
116
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_NavigationItem.default, {
|
|
100
117
|
ref: sourceRef,
|
|
@@ -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;
|
|
@@ -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
|
}),
|
|
@@ -111,6 +111,13 @@ function getOverlaidPosition(_ref2) {
|
|
|
111
111
|
positioning[side] = adjusted.offset;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
if (positioning.left) {
|
|
115
|
+
const overflowAmount = positioning.left + targetDimensions.width - windowDimensions.width;
|
|
116
|
+
if (overflowAmount > 0) {
|
|
117
|
+
const spaceToRightEdge = windowDimensions.width - (sourceLayout.x + sourceLayout.width);
|
|
118
|
+
positioning.left = positioning.left - overflowAmount - spaceToRightEdge;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
114
121
|
return positioning;
|
|
115
122
|
}
|
|
116
123
|
|
|
@@ -210,7 +217,10 @@ const useOverlaidPosition = _ref3 => {
|
|
|
210
217
|
windowDimensions,
|
|
211
218
|
offsets,
|
|
212
219
|
align
|
|
213
|
-
}) : {
|
|
220
|
+
}) : {
|
|
221
|
+
top: 0,
|
|
222
|
+
left: 0
|
|
223
|
+
};
|
|
214
224
|
return {
|
|
215
225
|
overlaidPosition,
|
|
216
226
|
sourceRef,
|