@telus-uds/components-base 3.5.1 → 3.5.2
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 +12 -2
- package/lib/cjs/Carousel/Carousel.js +34 -47
- package/lib/cjs/Carousel/CarouselItem/CarouselItem.js +4 -6
- package/lib/cjs/Carousel/Constants.js +5 -2
- package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +1 -1
- package/lib/cjs/Notification/Notification.js +26 -16
- package/lib/cjs/utils/useResponsiveProp.js +1 -1
- package/lib/esm/Carousel/Carousel.js +35 -48
- package/lib/esm/Carousel/CarouselItem/CarouselItem.js +4 -6
- package/lib/esm/Carousel/Constants.js +4 -1
- package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +1 -1
- package/lib/esm/Notification/Notification.js +27 -17
- package/lib/esm/utils/useResponsiveProp.js +1 -1
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/src/Carousel/Carousel.jsx +47 -58
- package/src/Carousel/CarouselItem/CarouselItem.jsx +4 -6
- package/src/Carousel/Constants.js +3 -0
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +1 -1
- package/src/Notification/Notification.jsx +29 -12
- package/src/utils/useResponsiveProp.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 08 Apr 2025 19:33:55 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.5.2
|
|
8
|
+
|
|
9
|
+
Tue, 08 Apr 2025 19:33:55 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- `Carousel`: peeking mode optimizations (guillermo.peitzner@telus.com)
|
|
14
|
+
- `Notification`: fix system alignment variant when using RNMQ (guillermo.peitzner@telus.com)
|
|
15
|
+
- `MultiSelectFilter`: allow scrolling to viewport beyond xs (Mauricio.BatresMontejo@telus.com)
|
|
16
|
+
|
|
7
17
|
## 3.5.1
|
|
8
18
|
|
|
9
|
-
Fri, 28 Mar 2025 01:
|
|
19
|
+
Fri, 28 Mar 2025 01:02:45 GMT
|
|
10
20
|
|
|
11
21
|
### Patches
|
|
12
22
|
|
|
@@ -205,56 +205,27 @@ const selectNavigationStyles = (tabs, enableHero, viewport) => {
|
|
|
205
205
|
};
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
|
-
* Calculates the final width of
|
|
208
|
+
* Calculates the final width of a carousel container based on the provided parameters.
|
|
209
209
|
*
|
|
210
|
-
* @param {number} containerWidth - The
|
|
211
|
-
* @param {boolean} enablePeeking - Flag indicating
|
|
212
|
-
* @param {
|
|
213
|
-
* @param {
|
|
214
|
-
* @
|
|
215
|
-
* @param {number} calcDelta - The delta value used for calculations.
|
|
216
|
-
* @returns {number} - The final calculated width of the container.
|
|
217
|
-
*
|
|
218
|
-
* The function adjusts the container width for displacement purposes based on the peeking properties and the position
|
|
219
|
-
* of the active item (first, middle, or last). It considers different peeking spaces and gaps
|
|
220
|
-
* to ensure the correct width is calculated for the carousel to display properly.
|
|
210
|
+
* @param {number} containerWidth - The width of the carousel container.
|
|
211
|
+
* @param {boolean} enablePeeking - Flag indicating whether peeking is enabled.
|
|
212
|
+
* @param {Object} viewport - The viewport configuration object used to determine peeking properties.
|
|
213
|
+
* @param {React.MutableRefObject<number>} activeIndexRef - A ref object holding the current active index of the carousel.
|
|
214
|
+
* @returns {number} The calculated final width of the carousel container.
|
|
221
215
|
*/
|
|
222
|
-
const calculateFinalWidth = (containerWidth, enablePeeking, viewport, activeIndexRef
|
|
216
|
+
const calculateFinalWidth = (containerWidth, enablePeeking, viewport, activeIndexRef) => {
|
|
223
217
|
let finalWidth = containerWidth;
|
|
224
218
|
if (enablePeeking) {
|
|
225
219
|
const {
|
|
226
|
-
peekingFirstSpace,
|
|
227
220
|
peekingGap,
|
|
228
|
-
|
|
229
|
-
|
|
221
|
+
peekingMiddleSpace,
|
|
222
|
+
peekingMarginLeft
|
|
230
223
|
} = getPeekingProps(viewport);
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (isFirst) {
|
|
237
|
-
finalWidth -= basePeekingSpace;
|
|
238
|
-
if (activeIndexRef.current + 1 === totalItems - 1) {
|
|
239
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace;
|
|
240
|
-
}
|
|
241
|
-
} else if (isMiddle) {
|
|
242
|
-
if (calcDelta > 0) {
|
|
243
|
-
finalWidth -= basePeekingSpace + middlePeekingSpace * activeIndexRef.current;
|
|
244
|
-
if (activeIndexRef.current + 1 === totalItems - 1) {
|
|
245
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace;
|
|
246
|
-
}
|
|
247
|
-
} else {
|
|
248
|
-
finalWidth += basePeekingSpace + middlePeekingSpace * (activeIndexRef.current - 2);
|
|
249
|
-
if (activeIndexRef.current - 1 === 0) {
|
|
250
|
-
finalWidth -= peekingFirstSpace - peekingMiddleSpace;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
} else if (isLast) {
|
|
254
|
-
finalWidth += basePeekingSpace + middlePeekingSpace * (activeIndexRef.current - 2);
|
|
255
|
-
if (activeIndexRef.current - 1 === 0) {
|
|
256
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace;
|
|
257
|
-
}
|
|
224
|
+
const slideWide = containerWidth - (peekingMiddleSpace * _Constants.PEEKING_MULTIPLIER + peekingGap * _Constants.PEEKING_MULTIPLIER);
|
|
225
|
+
if (activeIndexRef.current === 0) {
|
|
226
|
+
finalWidth = slideWide + peekingMarginLeft - peekingMiddleSpace;
|
|
227
|
+
} else {
|
|
228
|
+
finalWidth = slideWide + peekingGap;
|
|
258
229
|
}
|
|
259
230
|
}
|
|
260
231
|
return finalWidth;
|
|
@@ -441,7 +412,23 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
441
412
|
setIsAnimating(false);
|
|
442
413
|
}, [onAnimationEnd]);
|
|
443
414
|
const updateOffset = _react.default.useCallback(() => {
|
|
444
|
-
|
|
415
|
+
if (enablePeeking) {
|
|
416
|
+
const {
|
|
417
|
+
peekingGap,
|
|
418
|
+
peekingMiddleSpace,
|
|
419
|
+
peekingMarginLeft
|
|
420
|
+
} = getPeekingProps(viewport);
|
|
421
|
+
let finalWidth;
|
|
422
|
+
const slideWide = containerLayoutRef.current.width - (peekingMiddleSpace * _Constants.PEEKING_MULTIPLIER + peekingGap * _Constants.PEEKING_MULTIPLIER);
|
|
423
|
+
if (activeIndexRef.current === 0) {
|
|
424
|
+
finalWidth = 0;
|
|
425
|
+
} else {
|
|
426
|
+
finalWidth = slideWide + peekingMarginLeft - peekingMiddleSpace + (slideWide + peekingGap) * (activeIndexRef.current - _Constants.ACTIVE_INDEX_OFFSET_MULTIPLIER);
|
|
427
|
+
}
|
|
428
|
+
animatedX.current = finalWidth * _Constants.NEGATIVE_MULTIPLIER;
|
|
429
|
+
} else {
|
|
430
|
+
animatedX.current = containerLayoutRef.current.width * activeIndexRef.current * _Constants.NEGATIVE_MULTIPLIER;
|
|
431
|
+
}
|
|
445
432
|
animatedY.current = 0;
|
|
446
433
|
pan.setOffset({
|
|
447
434
|
x: animatedX.current,
|
|
@@ -452,7 +439,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
452
439
|
y: 0
|
|
453
440
|
});
|
|
454
441
|
if (enableHero) {
|
|
455
|
-
heroAnimatedX.current = heroContainerLayoutRef.current.width * activeIndexRef.current *
|
|
442
|
+
heroAnimatedX.current = heroContainerLayoutRef.current.width * activeIndexRef.current * _Constants.NEGATIVE_MULTIPLIER;
|
|
456
443
|
heroAnimatedY.current = 0;
|
|
457
444
|
heroPan.setOffset({
|
|
458
445
|
x: heroAnimatedX.current,
|
|
@@ -463,7 +450,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
463
450
|
y: 0
|
|
464
451
|
});
|
|
465
452
|
}
|
|
466
|
-
}, [pan, animatedX, heroPan, heroAnimatedX, enableHero]);
|
|
453
|
+
}, [pan, animatedX, heroPan, heroAnimatedX, enableHero, viewport, enablePeeking]);
|
|
467
454
|
const animate = _react.default.useCallback((panToAnimate, toValue, toIndex) => {
|
|
468
455
|
const handleAnimationEndToIndex = function () {
|
|
469
456
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -538,7 +525,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
538
525
|
}
|
|
539
526
|
stopAutoplay();
|
|
540
527
|
setActiveIndex(index);
|
|
541
|
-
const finalWidth = calculateFinalWidth(containerLayoutRef.current.width, enablePeeking, viewport, activeIndexRef
|
|
528
|
+
const finalWidth = calculateFinalWidth(containerLayoutRef.current.width, enablePeeking, viewport, activeIndexRef);
|
|
542
529
|
toValue.x = finalWidth * -1 * calcDelta;
|
|
543
530
|
const heroToValue = {
|
|
544
531
|
x: 0,
|
|
@@ -20,18 +20,17 @@ const selectContainerStyle = _ref => {
|
|
|
20
20
|
elementIndex,
|
|
21
21
|
enablePeeking,
|
|
22
22
|
peekingMarginLeft,
|
|
23
|
-
peekingFirstSpace,
|
|
24
23
|
peekingGap,
|
|
25
24
|
hidden,
|
|
26
25
|
enableDisplayMultipleItemsPerSlide,
|
|
27
|
-
viewport
|
|
26
|
+
viewport,
|
|
27
|
+
peekingMiddleSpace
|
|
28
28
|
} = _ref;
|
|
29
29
|
let adjustedWidth = width;
|
|
30
30
|
let marginLeft = 0;
|
|
31
|
-
const marginRight = 0;
|
|
32
31
|
if (enablePeeking) {
|
|
33
32
|
const isFirst = elementIndex === 0;
|
|
34
|
-
adjustedWidth = width - (
|
|
33
|
+
adjustedWidth = width - (peekingMiddleSpace * 2 + peekingGap * 2);
|
|
35
34
|
if (isFirst) {
|
|
36
35
|
marginLeft = peekingMarginLeft;
|
|
37
36
|
} else {
|
|
@@ -68,8 +67,7 @@ const selectContainerStyle = _ref => {
|
|
|
68
67
|
}
|
|
69
68
|
const style = {
|
|
70
69
|
width: adjustedWidth,
|
|
71
|
-
marginLeft
|
|
72
|
-
marginRight
|
|
70
|
+
marginLeft
|
|
73
71
|
};
|
|
74
72
|
if (hidden && _Platform.default.OS === 'web') {
|
|
75
73
|
style.visibility = 'hidden';
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.LARGE_VIEWPORT_MARGIN = exports.ITEMS_PER_VIEWPORT_MD = exports.ITEMS_PER_VIEWPORT_LG_XL = exports.HERO_POSITION_OFFSET = exports.GAP_BETWEEN_ITEMS = exports.DEFAULT_VIEWPORT_MARGIN = exports.DEFAULT_POSITION_OFFSET = void 0;
|
|
6
|
+
exports.PEEKING_MULTIPLIER = exports.NEGATIVE_MULTIPLIER = exports.LARGE_VIEWPORT_MARGIN = exports.ITEMS_PER_VIEWPORT_MD = exports.ITEMS_PER_VIEWPORT_LG_XL = exports.HERO_POSITION_OFFSET = exports.GAP_BETWEEN_ITEMS = exports.DEFAULT_VIEWPORT_MARGIN = exports.DEFAULT_POSITION_OFFSET = exports.ACTIVE_INDEX_OFFSET_MULTIPLIER = void 0;
|
|
7
7
|
const ITEMS_PER_VIEWPORT_MD = exports.ITEMS_PER_VIEWPORT_MD = 2;
|
|
8
8
|
const ITEMS_PER_VIEWPORT_LG_XL = exports.ITEMS_PER_VIEWPORT_LG_XL = 3;
|
|
9
9
|
const GAP_BETWEEN_ITEMS = exports.GAP_BETWEEN_ITEMS = 16;
|
|
10
10
|
const HERO_POSITION_OFFSET = exports.HERO_POSITION_OFFSET = 20;
|
|
11
11
|
const DEFAULT_POSITION_OFFSET = exports.DEFAULT_POSITION_OFFSET = 0;
|
|
12
12
|
const LARGE_VIEWPORT_MARGIN = exports.LARGE_VIEWPORT_MARGIN = 40;
|
|
13
|
-
const DEFAULT_VIEWPORT_MARGIN = exports.DEFAULT_VIEWPORT_MARGIN = 10;
|
|
13
|
+
const DEFAULT_VIEWPORT_MARGIN = exports.DEFAULT_VIEWPORT_MARGIN = 10;
|
|
14
|
+
const PEEKING_MULTIPLIER = exports.PEEKING_MULTIPLIER = 2;
|
|
15
|
+
const ACTIVE_INDEX_OFFSET_MULTIPLIER = exports.ACTIVE_INDEX_OFFSET_MULTIPLIER = 1;
|
|
16
|
+
const NEGATIVE_MULTIPLIER = exports.NEGATIVE_MULTIPLIER = -1;
|
|
@@ -249,7 +249,7 @@ const MultiSelectFilter = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) =>
|
|
|
249
249
|
const [isScrolling, setIsScrolling] = _react.default.useState(false);
|
|
250
250
|
const [scrollViewHeight, setScrollViewHeight] = _react.default.useState(0);
|
|
251
251
|
const [rowHeight, setRowHeight] = _react.default.useState(0);
|
|
252
|
-
const modalRef = (0, _utils.useScrollBlocking)(isOpen);
|
|
252
|
+
const modalRef = (0, _utils.useScrollBlocking)(isOpen && viewport === 'xs');
|
|
253
253
|
const windowWidth = _Dimensions.default.get('window').width;
|
|
254
254
|
const windowHeight = _Dimensions.default.get('window').height;
|
|
255
255
|
_react.default.useEffect(() => {
|
|
@@ -70,8 +70,8 @@ const selectDismissButtonContainerStyles = _ref4 => {
|
|
|
70
70
|
placeContent: 'start'
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
|
-
const selectContentContainerStyle = (themeTokens, maxWidth,
|
|
74
|
-
maxWidth: viewport === 'xl'
|
|
73
|
+
const selectContentContainerStyle = (themeTokens, maxWidth, system, viewport) => ({
|
|
74
|
+
maxWidth: system && viewport === 'xl' ? maxWidth : '100%',
|
|
75
75
|
width: '100%',
|
|
76
76
|
paddingRight: themeTokens?.containerPaddingRight,
|
|
77
77
|
paddingLeft: themeTokens?.containerPaddingLeft
|
|
@@ -79,9 +79,12 @@ const selectContentContainerStyle = (themeTokens, maxWidth, viewport, system) =>
|
|
|
79
79
|
const getMediaQueryStyles = (themeTokens, themeOptions, maxWidth, mediaIdsRef, dismissible, viewport, system) => {
|
|
80
80
|
const transformedSelectContainerStyles = Object.entries(themeTokens).reduce((acc, _ref5) => {
|
|
81
81
|
let [vp, viewportTokens] = _ref5;
|
|
82
|
-
acc[vp] =
|
|
83
|
-
...
|
|
84
|
-
|
|
82
|
+
acc[vp] = {
|
|
83
|
+
...selectContainerStyles({
|
|
84
|
+
...viewportTokens
|
|
85
|
+
}),
|
|
86
|
+
flexDirection: 'column'
|
|
87
|
+
};
|
|
85
88
|
return acc;
|
|
86
89
|
}, {});
|
|
87
90
|
const selectContainerMediaQueryStyles = (0, _utils.createMediaQueryStyles)(transformedSelectContainerStyles);
|
|
@@ -90,22 +93,29 @@ const getMediaQueryStyles = (themeTokens, themeOptions, maxWidth, mediaIdsRef, d
|
|
|
90
93
|
styles: containerStyles
|
|
91
94
|
} = _utils.StyleSheet.create({
|
|
92
95
|
container: {
|
|
93
|
-
flexDirection: 'column',
|
|
94
96
|
...selectContainerMediaQueryStyles
|
|
95
97
|
}
|
|
96
98
|
});
|
|
97
|
-
const {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
contentContainer: {
|
|
99
|
+
const transformedSelectContentContainerStyles = Object.entries(themeTokens).reduce((acc, _ref6) => {
|
|
100
|
+
let [vp, viewportTokens] = _ref6;
|
|
101
|
+
acc[vp] = {
|
|
102
|
+
...selectContentContainerStyle(viewportTokens, maxWidth, system, vp),
|
|
102
103
|
flexDirection: 'row',
|
|
103
104
|
flexShrink: 1,
|
|
104
105
|
justifyContent: 'space-between',
|
|
105
|
-
...selectContentContainerStyle(themeTokens, maxWidth, viewport, system),
|
|
106
106
|
...(system && {
|
|
107
107
|
alignSelf: 'center'
|
|
108
108
|
})
|
|
109
|
+
};
|
|
110
|
+
return acc;
|
|
111
|
+
}, {});
|
|
112
|
+
const selectContentContainerMediaQueryStyles = (0, _utils.createMediaQueryStyles)(transformedSelectContentContainerStyles);
|
|
113
|
+
const {
|
|
114
|
+
ids: contentContainerIds,
|
|
115
|
+
styles: contentContainerStyles
|
|
116
|
+
} = _utils.StyleSheet.create({
|
|
117
|
+
contentContainer: {
|
|
118
|
+
...selectContentContainerMediaQueryStyles
|
|
109
119
|
}
|
|
110
120
|
});
|
|
111
121
|
const {
|
|
@@ -178,7 +188,7 @@ const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible, view
|
|
|
178
188
|
flexDirection: 'row',
|
|
179
189
|
flexShrink: 1,
|
|
180
190
|
justifyContent: 'space-between',
|
|
181
|
-
...selectContentContainerStyle(themeTokens, maxWidth,
|
|
191
|
+
...selectContentContainerStyle(themeTokens, maxWidth, system, viewport),
|
|
182
192
|
...(system && {
|
|
183
193
|
alignSelf: 'center'
|
|
184
194
|
})
|
|
@@ -268,7 +278,7 @@ const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible, view
|
|
|
268
278
|
* Use full-width `Notifications` to show system-based messages coming from the application, not in response to user action.
|
|
269
279
|
* Show system notifications at the top of the page, below the navigation, and expands the full-width of the viewport
|
|
270
280
|
*/
|
|
271
|
-
const Notification = /*#__PURE__*/_react.default.forwardRef((
|
|
281
|
+
const Notification = /*#__PURE__*/_react.default.forwardRef((_ref7, ref) => {
|
|
272
282
|
let {
|
|
273
283
|
children,
|
|
274
284
|
system,
|
|
@@ -278,7 +288,7 @@ const Notification = /*#__PURE__*/_react.default.forwardRef((_ref6, ref) => {
|
|
|
278
288
|
variant,
|
|
279
289
|
onDismiss,
|
|
280
290
|
...rest
|
|
281
|
-
} =
|
|
291
|
+
} = _ref7;
|
|
282
292
|
const [isDismissed, setIsDismissed] = _react.default.useState(false);
|
|
283
293
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
284
294
|
const getCopy = (0, _useCopy.default)({
|
|
@@ -299,7 +309,7 @@ const Notification = /*#__PURE__*/_react.default.forwardRef((_ref6, ref) => {
|
|
|
299
309
|
system: isSystemEnabled,
|
|
300
310
|
viewport
|
|
301
311
|
});
|
|
302
|
-
const maxWidth = _systemConstants.viewports.map.get(_systemConstants.viewports.xl);
|
|
312
|
+
const maxWidth = (0, _utils.useResponsiveProp)(themeOptions?.contentMaxWidth, _systemConstants.viewports.map.get(_systemConstants.viewports.xl));
|
|
303
313
|
const notificationComponentRef = _react.default.useRef({
|
|
304
314
|
containerStyles: {},
|
|
305
315
|
contentContainerStyles: {},
|
|
@@ -28,7 +28,7 @@ const resolveResponsiveProp = (prop, viewport, defaultValue) => {
|
|
|
28
28
|
_systemConstants.viewports.inherit(prop)[viewport] :
|
|
29
29
|
// If no current viewport is available, default to smallest viewport
|
|
30
30
|
prop[_systemConstants.viewports.keys.find(key => (0, _hasOwnProperty.default)(prop, key))];
|
|
31
|
-
return value === undefined ? defaultValue : value;
|
|
31
|
+
return value === undefined || value === null ? defaultValue : value;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -21,7 +21,7 @@ import CarouselTabsPanel from './CarouselTabs/CarouselTabsPanel';
|
|
|
21
21
|
import CarouselTabsPanelItem from './CarouselTabs/CarouselTabsPanelItem';
|
|
22
22
|
import dictionary from './dictionary';
|
|
23
23
|
import Box from '../Box';
|
|
24
|
-
import { ITEMS_PER_VIEWPORT_MD, ITEMS_PER_VIEWPORT_LG_XL, DEFAULT_POSITION_OFFSET, LARGE_VIEWPORT_MARGIN, DEFAULT_VIEWPORT_MARGIN } from './Constants';
|
|
24
|
+
import { ITEMS_PER_VIEWPORT_MD, ITEMS_PER_VIEWPORT_LG_XL, DEFAULT_POSITION_OFFSET, LARGE_VIEWPORT_MARGIN, DEFAULT_VIEWPORT_MARGIN, PEEKING_MULTIPLIER, ACTIVE_INDEX_OFFSET_MULTIPLIER, NEGATIVE_MULTIPLIER } from './Constants';
|
|
25
25
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
26
|
const TRANSITION_MODES = {
|
|
27
27
|
MANUAL: 'manual',
|
|
@@ -198,56 +198,27 @@ const selectNavigationStyles = (tabs, enableHero, viewport) => {
|
|
|
198
198
|
};
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
|
-
* Calculates the final width of
|
|
201
|
+
* Calculates the final width of a carousel container based on the provided parameters.
|
|
202
202
|
*
|
|
203
|
-
* @param {number} containerWidth - The
|
|
204
|
-
* @param {boolean} enablePeeking - Flag indicating
|
|
205
|
-
* @param {
|
|
206
|
-
* @param {
|
|
207
|
-
* @
|
|
208
|
-
* @param {number} calcDelta - The delta value used for calculations.
|
|
209
|
-
* @returns {number} - The final calculated width of the container.
|
|
210
|
-
*
|
|
211
|
-
* The function adjusts the container width for displacement purposes based on the peeking properties and the position
|
|
212
|
-
* of the active item (first, middle, or last). It considers different peeking spaces and gaps
|
|
213
|
-
* to ensure the correct width is calculated for the carousel to display properly.
|
|
203
|
+
* @param {number} containerWidth - The width of the carousel container.
|
|
204
|
+
* @param {boolean} enablePeeking - Flag indicating whether peeking is enabled.
|
|
205
|
+
* @param {Object} viewport - The viewport configuration object used to determine peeking properties.
|
|
206
|
+
* @param {React.MutableRefObject<number>} activeIndexRef - A ref object holding the current active index of the carousel.
|
|
207
|
+
* @returns {number} The calculated final width of the carousel container.
|
|
214
208
|
*/
|
|
215
|
-
const calculateFinalWidth = (containerWidth, enablePeeking, viewport, activeIndexRef
|
|
209
|
+
const calculateFinalWidth = (containerWidth, enablePeeking, viewport, activeIndexRef) => {
|
|
216
210
|
let finalWidth = containerWidth;
|
|
217
211
|
if (enablePeeking) {
|
|
218
212
|
const {
|
|
219
|
-
peekingFirstSpace,
|
|
220
213
|
peekingGap,
|
|
221
|
-
|
|
222
|
-
|
|
214
|
+
peekingMiddleSpace,
|
|
215
|
+
peekingMarginLeft
|
|
223
216
|
} = getPeekingProps(viewport);
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (isFirst) {
|
|
230
|
-
finalWidth -= basePeekingSpace;
|
|
231
|
-
if (activeIndexRef.current + 1 === totalItems - 1) {
|
|
232
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace;
|
|
233
|
-
}
|
|
234
|
-
} else if (isMiddle) {
|
|
235
|
-
if (calcDelta > 0) {
|
|
236
|
-
finalWidth -= basePeekingSpace + middlePeekingSpace * activeIndexRef.current;
|
|
237
|
-
if (activeIndexRef.current + 1 === totalItems - 1) {
|
|
238
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace;
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
finalWidth += basePeekingSpace + middlePeekingSpace * (activeIndexRef.current - 2);
|
|
242
|
-
if (activeIndexRef.current - 1 === 0) {
|
|
243
|
-
finalWidth -= peekingFirstSpace - peekingMiddleSpace;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
} else if (isLast) {
|
|
247
|
-
finalWidth += basePeekingSpace + middlePeekingSpace * (activeIndexRef.current - 2);
|
|
248
|
-
if (activeIndexRef.current - 1 === 0) {
|
|
249
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace;
|
|
250
|
-
}
|
|
217
|
+
const slideWide = containerWidth - (peekingMiddleSpace * PEEKING_MULTIPLIER + peekingGap * PEEKING_MULTIPLIER);
|
|
218
|
+
if (activeIndexRef.current === 0) {
|
|
219
|
+
finalWidth = slideWide + peekingMarginLeft - peekingMiddleSpace;
|
|
220
|
+
} else {
|
|
221
|
+
finalWidth = slideWide + peekingGap;
|
|
251
222
|
}
|
|
252
223
|
}
|
|
253
224
|
return finalWidth;
|
|
@@ -434,7 +405,23 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
434
405
|
setIsAnimating(false);
|
|
435
406
|
}, [onAnimationEnd]);
|
|
436
407
|
const updateOffset = React.useCallback(() => {
|
|
437
|
-
|
|
408
|
+
if (enablePeeking) {
|
|
409
|
+
const {
|
|
410
|
+
peekingGap,
|
|
411
|
+
peekingMiddleSpace,
|
|
412
|
+
peekingMarginLeft
|
|
413
|
+
} = getPeekingProps(viewport);
|
|
414
|
+
let finalWidth;
|
|
415
|
+
const slideWide = containerLayoutRef.current.width - (peekingMiddleSpace * PEEKING_MULTIPLIER + peekingGap * PEEKING_MULTIPLIER);
|
|
416
|
+
if (activeIndexRef.current === 0) {
|
|
417
|
+
finalWidth = 0;
|
|
418
|
+
} else {
|
|
419
|
+
finalWidth = slideWide + peekingMarginLeft - peekingMiddleSpace + (slideWide + peekingGap) * (activeIndexRef.current - ACTIVE_INDEX_OFFSET_MULTIPLIER);
|
|
420
|
+
}
|
|
421
|
+
animatedX.current = finalWidth * NEGATIVE_MULTIPLIER;
|
|
422
|
+
} else {
|
|
423
|
+
animatedX.current = containerLayoutRef.current.width * activeIndexRef.current * NEGATIVE_MULTIPLIER;
|
|
424
|
+
}
|
|
438
425
|
animatedY.current = 0;
|
|
439
426
|
pan.setOffset({
|
|
440
427
|
x: animatedX.current,
|
|
@@ -445,7 +432,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
445
432
|
y: 0
|
|
446
433
|
});
|
|
447
434
|
if (enableHero) {
|
|
448
|
-
heroAnimatedX.current = heroContainerLayoutRef.current.width * activeIndexRef.current *
|
|
435
|
+
heroAnimatedX.current = heroContainerLayoutRef.current.width * activeIndexRef.current * NEGATIVE_MULTIPLIER;
|
|
449
436
|
heroAnimatedY.current = 0;
|
|
450
437
|
heroPan.setOffset({
|
|
451
438
|
x: heroAnimatedX.current,
|
|
@@ -456,7 +443,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
456
443
|
y: 0
|
|
457
444
|
});
|
|
458
445
|
}
|
|
459
|
-
}, [pan, animatedX, heroPan, heroAnimatedX, enableHero]);
|
|
446
|
+
}, [pan, animatedX, heroPan, heroAnimatedX, enableHero, viewport, enablePeeking]);
|
|
460
447
|
const animate = React.useCallback((panToAnimate, toValue, toIndex) => {
|
|
461
448
|
const handleAnimationEndToIndex = function () {
|
|
462
449
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -531,7 +518,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
531
518
|
}
|
|
532
519
|
stopAutoplay();
|
|
533
520
|
setActiveIndex(index);
|
|
534
|
-
const finalWidth = calculateFinalWidth(containerLayoutRef.current.width, enablePeeking, viewport, activeIndexRef
|
|
521
|
+
const finalWidth = calculateFinalWidth(containerLayoutRef.current.width, enablePeeking, viewport, activeIndexRef);
|
|
535
522
|
toValue.x = finalWidth * -1 * calcDelta;
|
|
536
523
|
const heroToValue = {
|
|
537
524
|
x: 0,
|
|
@@ -13,18 +13,17 @@ const selectContainerStyle = _ref => {
|
|
|
13
13
|
elementIndex,
|
|
14
14
|
enablePeeking,
|
|
15
15
|
peekingMarginLeft,
|
|
16
|
-
peekingFirstSpace,
|
|
17
16
|
peekingGap,
|
|
18
17
|
hidden,
|
|
19
18
|
enableDisplayMultipleItemsPerSlide,
|
|
20
|
-
viewport
|
|
19
|
+
viewport,
|
|
20
|
+
peekingMiddleSpace
|
|
21
21
|
} = _ref;
|
|
22
22
|
let adjustedWidth = width;
|
|
23
23
|
let marginLeft = 0;
|
|
24
|
-
const marginRight = 0;
|
|
25
24
|
if (enablePeeking) {
|
|
26
25
|
const isFirst = elementIndex === 0;
|
|
27
|
-
adjustedWidth = width - (
|
|
26
|
+
adjustedWidth = width - (peekingMiddleSpace * 2 + peekingGap * 2);
|
|
28
27
|
if (isFirst) {
|
|
29
28
|
marginLeft = peekingMarginLeft;
|
|
30
29
|
} else {
|
|
@@ -61,8 +60,7 @@ const selectContainerStyle = _ref => {
|
|
|
61
60
|
}
|
|
62
61
|
const style = {
|
|
63
62
|
width: adjustedWidth,
|
|
64
|
-
marginLeft
|
|
65
|
-
marginRight
|
|
63
|
+
marginLeft
|
|
66
64
|
};
|
|
67
65
|
if (hidden && Platform.OS === 'web') {
|
|
68
66
|
style.visibility = 'hidden';
|
|
@@ -4,4 +4,7 @@ export const GAP_BETWEEN_ITEMS = 16;
|
|
|
4
4
|
export const HERO_POSITION_OFFSET = 20;
|
|
5
5
|
export const DEFAULT_POSITION_OFFSET = 0;
|
|
6
6
|
export const LARGE_VIEWPORT_MARGIN = 40;
|
|
7
|
-
export const DEFAULT_VIEWPORT_MARGIN = 10;
|
|
7
|
+
export const DEFAULT_VIEWPORT_MARGIN = 10;
|
|
8
|
+
export const PEEKING_MULTIPLIER = 2;
|
|
9
|
+
export const ACTIVE_INDEX_OFFSET_MULTIPLIER = 1;
|
|
10
|
+
export const NEGATIVE_MULTIPLIER = -1;
|
|
@@ -242,7 +242,7 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
242
242
|
const [isScrolling, setIsScrolling] = React.useState(false);
|
|
243
243
|
const [scrollViewHeight, setScrollViewHeight] = React.useState(0);
|
|
244
244
|
const [rowHeight, setRowHeight] = React.useState(0);
|
|
245
|
-
const modalRef = useScrollBlocking(isOpen);
|
|
245
|
+
const modalRef = useScrollBlocking(isOpen && viewport === 'xs');
|
|
246
246
|
const windowWidth = Dimensions.get('window').width;
|
|
247
247
|
const windowHeight = Dimensions.get('window').height;
|
|
248
248
|
React.useEffect(() => {
|
|
@@ -3,7 +3,7 @@ import View from "react-native-web/dist/exports/View";
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
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, createMediaQueryStyles, StyleSheet } from '../utils';
|
|
6
|
+
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps, wrapStringsInText, createMediaQueryStyles, StyleSheet, useResponsiveProp } from '../utils';
|
|
7
7
|
import IconButton from '../IconButton';
|
|
8
8
|
import useCopy from '../utils/useCopy';
|
|
9
9
|
import dictionary from './dictionary';
|
|
@@ -63,8 +63,8 @@ const selectDismissButtonContainerStyles = _ref4 => {
|
|
|
63
63
|
placeContent: 'start'
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
|
-
const selectContentContainerStyle = (themeTokens, maxWidth,
|
|
67
|
-
maxWidth: viewport === 'xl'
|
|
66
|
+
const selectContentContainerStyle = (themeTokens, maxWidth, system, viewport) => ({
|
|
67
|
+
maxWidth: system && viewport === 'xl' ? maxWidth : '100%',
|
|
68
68
|
width: '100%',
|
|
69
69
|
paddingRight: themeTokens?.containerPaddingRight,
|
|
70
70
|
paddingLeft: themeTokens?.containerPaddingLeft
|
|
@@ -72,9 +72,12 @@ const selectContentContainerStyle = (themeTokens, maxWidth, viewport, system) =>
|
|
|
72
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
|
-
acc[vp] =
|
|
76
|
-
...
|
|
77
|
-
|
|
75
|
+
acc[vp] = {
|
|
76
|
+
...selectContainerStyles({
|
|
77
|
+
...viewportTokens
|
|
78
|
+
}),
|
|
79
|
+
flexDirection: 'column'
|
|
80
|
+
};
|
|
78
81
|
return acc;
|
|
79
82
|
}, {});
|
|
80
83
|
const selectContainerMediaQueryStyles = createMediaQueryStyles(transformedSelectContainerStyles);
|
|
@@ -83,22 +86,29 @@ const getMediaQueryStyles = (themeTokens, themeOptions, maxWidth, mediaIdsRef, d
|
|
|
83
86
|
styles: containerStyles
|
|
84
87
|
} = StyleSheet.create({
|
|
85
88
|
container: {
|
|
86
|
-
flexDirection: 'column',
|
|
87
89
|
...selectContainerMediaQueryStyles
|
|
88
90
|
}
|
|
89
91
|
});
|
|
90
|
-
const {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
contentContainer: {
|
|
92
|
+
const transformedSelectContentContainerStyles = Object.entries(themeTokens).reduce((acc, _ref6) => {
|
|
93
|
+
let [vp, viewportTokens] = _ref6;
|
|
94
|
+
acc[vp] = {
|
|
95
|
+
...selectContentContainerStyle(viewportTokens, maxWidth, system, vp),
|
|
95
96
|
flexDirection: 'row',
|
|
96
97
|
flexShrink: 1,
|
|
97
98
|
justifyContent: 'space-between',
|
|
98
|
-
...selectContentContainerStyle(themeTokens, maxWidth, viewport, system),
|
|
99
99
|
...(system && {
|
|
100
100
|
alignSelf: 'center'
|
|
101
101
|
})
|
|
102
|
+
};
|
|
103
|
+
return acc;
|
|
104
|
+
}, {});
|
|
105
|
+
const selectContentContainerMediaQueryStyles = createMediaQueryStyles(transformedSelectContentContainerStyles);
|
|
106
|
+
const {
|
|
107
|
+
ids: contentContainerIds,
|
|
108
|
+
styles: contentContainerStyles
|
|
109
|
+
} = StyleSheet.create({
|
|
110
|
+
contentContainer: {
|
|
111
|
+
...selectContentContainerMediaQueryStyles
|
|
102
112
|
}
|
|
103
113
|
});
|
|
104
114
|
const {
|
|
@@ -171,7 +181,7 @@ const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible, view
|
|
|
171
181
|
flexDirection: 'row',
|
|
172
182
|
flexShrink: 1,
|
|
173
183
|
justifyContent: 'space-between',
|
|
174
|
-
...selectContentContainerStyle(themeTokens, maxWidth,
|
|
184
|
+
...selectContentContainerStyle(themeTokens, maxWidth, system, viewport),
|
|
175
185
|
...(system && {
|
|
176
186
|
alignSelf: 'center'
|
|
177
187
|
})
|
|
@@ -261,7 +271,7 @@ const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible, view
|
|
|
261
271
|
* Use full-width `Notifications` to show system-based messages coming from the application, not in response to user action.
|
|
262
272
|
* Show system notifications at the top of the page, below the navigation, and expands the full-width of the viewport
|
|
263
273
|
*/
|
|
264
|
-
const Notification = /*#__PURE__*/React.forwardRef((
|
|
274
|
+
const Notification = /*#__PURE__*/React.forwardRef((_ref7, ref) => {
|
|
265
275
|
let {
|
|
266
276
|
children,
|
|
267
277
|
system,
|
|
@@ -271,7 +281,7 @@ const Notification = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
|
271
281
|
variant,
|
|
272
282
|
onDismiss,
|
|
273
283
|
...rest
|
|
274
|
-
} =
|
|
284
|
+
} = _ref7;
|
|
275
285
|
const [isDismissed, setIsDismissed] = React.useState(false);
|
|
276
286
|
const viewport = useViewport();
|
|
277
287
|
const getCopy = useCopy({
|
|
@@ -292,7 +302,7 @@ const Notification = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
|
292
302
|
system: isSystemEnabled,
|
|
293
303
|
viewport
|
|
294
304
|
});
|
|
295
|
-
const maxWidth = viewports.map.get(viewports.xl);
|
|
305
|
+
const maxWidth = useResponsiveProp(themeOptions?.contentMaxWidth, viewports.map.get(viewports.xl));
|
|
296
306
|
const notificationComponentRef = React.useRef({
|
|
297
307
|
containerStyles: {},
|
|
298
308
|
contentContainerStyles: {},
|
|
@@ -21,7 +21,7 @@ export const resolveResponsiveProp = (prop, viewport, defaultValue) => {
|
|
|
21
21
|
viewports.inherit(prop)[viewport] :
|
|
22
22
|
// If no current viewport is available, default to smallest viewport
|
|
23
23
|
prop[viewports.keys.find(key => hasOwnProperty(prop, key))];
|
|
24
|
-
return value === undefined ? defaultValue : value;
|
|
24
|
+
return value === undefined || value === null ? defaultValue : value;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
/**
|
package/lib/package.json
CHANGED
package/package.json
CHANGED
|
@@ -31,7 +31,10 @@ import {
|
|
|
31
31
|
ITEMS_PER_VIEWPORT_LG_XL,
|
|
32
32
|
DEFAULT_POSITION_OFFSET,
|
|
33
33
|
LARGE_VIEWPORT_MARGIN,
|
|
34
|
-
DEFAULT_VIEWPORT_MARGIN
|
|
34
|
+
DEFAULT_VIEWPORT_MARGIN,
|
|
35
|
+
PEEKING_MULTIPLIER,
|
|
36
|
+
ACTIVE_INDEX_OFFSET_MULTIPLIER,
|
|
37
|
+
NEGATIVE_MULTIPLIER
|
|
35
38
|
} from './Constants'
|
|
36
39
|
|
|
37
40
|
const TRANSITION_MODES = {
|
|
@@ -245,63 +248,26 @@ const selectNavigationStyles = (tabs, enableHero, viewport) => {
|
|
|
245
248
|
}
|
|
246
249
|
|
|
247
250
|
/**
|
|
248
|
-
* Calculates the final width of
|
|
251
|
+
* Calculates the final width of a carousel container based on the provided parameters.
|
|
249
252
|
*
|
|
250
|
-
* @param {number} containerWidth - The
|
|
251
|
-
* @param {boolean} enablePeeking - Flag indicating
|
|
252
|
-
* @param {
|
|
253
|
-
* @param {
|
|
254
|
-
* @
|
|
255
|
-
* @param {number} calcDelta - The delta value used for calculations.
|
|
256
|
-
* @returns {number} - The final calculated width of the container.
|
|
257
|
-
*
|
|
258
|
-
* The function adjusts the container width for displacement purposes based on the peeking properties and the position
|
|
259
|
-
* of the active item (first, middle, or last). It considers different peeking spaces and gaps
|
|
260
|
-
* to ensure the correct width is calculated for the carousel to display properly.
|
|
253
|
+
* @param {number} containerWidth - The width of the carousel container.
|
|
254
|
+
* @param {boolean} enablePeeking - Flag indicating whether peeking is enabled.
|
|
255
|
+
* @param {Object} viewport - The viewport configuration object used to determine peeking properties.
|
|
256
|
+
* @param {React.MutableRefObject<number>} activeIndexRef - A ref object holding the current active index of the carousel.
|
|
257
|
+
* @returns {number} The calculated final width of the carousel container.
|
|
261
258
|
*/
|
|
262
|
-
const calculateFinalWidth = (
|
|
263
|
-
containerWidth,
|
|
264
|
-
enablePeeking,
|
|
265
|
-
viewport,
|
|
266
|
-
activeIndexRef,
|
|
267
|
-
totalItems,
|
|
268
|
-
calcDelta
|
|
269
|
-
) => {
|
|
259
|
+
const calculateFinalWidth = (containerWidth, enablePeeking, viewport, activeIndexRef) => {
|
|
270
260
|
let finalWidth = containerWidth
|
|
271
261
|
|
|
272
262
|
if (enablePeeking) {
|
|
273
|
-
const {
|
|
274
|
-
|
|
263
|
+
const { peekingGap, peekingMiddleSpace, peekingMarginLeft } = getPeekingProps(viewport)
|
|
264
|
+
const slideWide =
|
|
265
|
+
containerWidth - (peekingMiddleSpace * PEEKING_MULTIPLIER + peekingGap * PEEKING_MULTIPLIER)
|
|
275
266
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const basePeekingSpace = peekingFirstSpace + peekingGap + peekingMiddleSpace
|
|
281
|
-
const middlePeekingSpace = peekingMiddleSpace * 2 + peekingGap
|
|
282
|
-
|
|
283
|
-
if (isFirst) {
|
|
284
|
-
finalWidth -= basePeekingSpace
|
|
285
|
-
if (activeIndexRef.current + 1 === totalItems - 1) {
|
|
286
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace
|
|
287
|
-
}
|
|
288
|
-
} else if (isMiddle) {
|
|
289
|
-
if (calcDelta > 0) {
|
|
290
|
-
finalWidth -= basePeekingSpace + middlePeekingSpace * activeIndexRef.current
|
|
291
|
-
if (activeIndexRef.current + 1 === totalItems - 1) {
|
|
292
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace
|
|
293
|
-
}
|
|
294
|
-
} else {
|
|
295
|
-
finalWidth += basePeekingSpace + middlePeekingSpace * (activeIndexRef.current - 2)
|
|
296
|
-
if (activeIndexRef.current - 1 === 0) {
|
|
297
|
-
finalWidth -= peekingFirstSpace - peekingMiddleSpace
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
} else if (isLast) {
|
|
301
|
-
finalWidth += basePeekingSpace + middlePeekingSpace * (activeIndexRef.current - 2)
|
|
302
|
-
if (activeIndexRef.current - 1 === 0) {
|
|
303
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace
|
|
304
|
-
}
|
|
267
|
+
if (activeIndexRef.current === 0) {
|
|
268
|
+
finalWidth = slideWide + peekingMarginLeft - peekingMiddleSpace
|
|
269
|
+
} else {
|
|
270
|
+
finalWidth = slideWide + peekingGap
|
|
305
271
|
}
|
|
306
272
|
}
|
|
307
273
|
|
|
@@ -495,15 +461,40 @@ const Carousel = React.forwardRef(
|
|
|
495
461
|
)
|
|
496
462
|
|
|
497
463
|
const updateOffset = React.useCallback(() => {
|
|
498
|
-
|
|
464
|
+
if (enablePeeking) {
|
|
465
|
+
const { peekingGap, peekingMiddleSpace, peekingMarginLeft } = getPeekingProps(viewport)
|
|
466
|
+
|
|
467
|
+
let finalWidth
|
|
468
|
+
const slideWide =
|
|
469
|
+
containerLayoutRef.current.width -
|
|
470
|
+
(peekingMiddleSpace * PEEKING_MULTIPLIER + peekingGap * PEEKING_MULTIPLIER)
|
|
471
|
+
|
|
472
|
+
if (activeIndexRef.current === 0) {
|
|
473
|
+
finalWidth = 0
|
|
474
|
+
} else {
|
|
475
|
+
finalWidth =
|
|
476
|
+
slideWide +
|
|
477
|
+
peekingMarginLeft -
|
|
478
|
+
peekingMiddleSpace +
|
|
479
|
+
(slideWide + peekingGap) * (activeIndexRef.current - ACTIVE_INDEX_OFFSET_MULTIPLIER)
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
animatedX.current = finalWidth * NEGATIVE_MULTIPLIER
|
|
483
|
+
} else {
|
|
484
|
+
animatedX.current =
|
|
485
|
+
containerLayoutRef.current.width * activeIndexRef.current * NEGATIVE_MULTIPLIER
|
|
486
|
+
}
|
|
487
|
+
|
|
499
488
|
animatedY.current = 0
|
|
500
489
|
pan.setOffset({
|
|
501
490
|
x: animatedX.current,
|
|
502
491
|
y: animatedY.current
|
|
503
492
|
})
|
|
504
493
|
pan.setValue({ x: 0, y: 0 })
|
|
494
|
+
|
|
505
495
|
if (enableHero) {
|
|
506
|
-
heroAnimatedX.current =
|
|
496
|
+
heroAnimatedX.current =
|
|
497
|
+
heroContainerLayoutRef.current.width * activeIndexRef.current * NEGATIVE_MULTIPLIER
|
|
507
498
|
heroAnimatedY.current = 0
|
|
508
499
|
heroPan.setOffset({
|
|
509
500
|
x: heroAnimatedX.current,
|
|
@@ -511,7 +502,7 @@ const Carousel = React.forwardRef(
|
|
|
511
502
|
})
|
|
512
503
|
heroPan.setValue({ x: 0, y: 0 })
|
|
513
504
|
}
|
|
514
|
-
}, [pan, animatedX, heroPan, heroAnimatedX, enableHero])
|
|
505
|
+
}, [pan, animatedX, heroPan, heroAnimatedX, enableHero, viewport, enablePeeking])
|
|
515
506
|
|
|
516
507
|
const animate = React.useCallback(
|
|
517
508
|
(panToAnimate, toValue, toIndex) => {
|
|
@@ -593,9 +584,7 @@ const Carousel = React.forwardRef(
|
|
|
593
584
|
containerLayoutRef.current.width,
|
|
594
585
|
enablePeeking,
|
|
595
586
|
viewport,
|
|
596
|
-
activeIndexRef
|
|
597
|
-
totalItems,
|
|
598
|
-
calcDelta
|
|
587
|
+
activeIndexRef
|
|
599
588
|
)
|
|
600
589
|
|
|
601
590
|
toValue.x = finalWidth * -1 * calcDelta
|
|
@@ -19,19 +19,18 @@ const selectContainerStyle = ({
|
|
|
19
19
|
elementIndex,
|
|
20
20
|
enablePeeking,
|
|
21
21
|
peekingMarginLeft,
|
|
22
|
-
peekingFirstSpace,
|
|
23
22
|
peekingGap,
|
|
24
23
|
hidden,
|
|
25
24
|
enableDisplayMultipleItemsPerSlide,
|
|
26
|
-
viewport
|
|
25
|
+
viewport,
|
|
26
|
+
peekingMiddleSpace
|
|
27
27
|
}) => {
|
|
28
28
|
let adjustedWidth = width
|
|
29
29
|
let marginLeft = 0
|
|
30
|
-
const marginRight = 0
|
|
31
30
|
|
|
32
31
|
if (enablePeeking) {
|
|
33
32
|
const isFirst = elementIndex === 0
|
|
34
|
-
adjustedWidth = width - (
|
|
33
|
+
adjustedWidth = width - (peekingMiddleSpace * 2 + peekingGap * 2)
|
|
35
34
|
if (isFirst) {
|
|
36
35
|
marginLeft = peekingMarginLeft
|
|
37
36
|
} else {
|
|
@@ -73,8 +72,7 @@ const selectContainerStyle = ({
|
|
|
73
72
|
|
|
74
73
|
const style = {
|
|
75
74
|
width: adjustedWidth,
|
|
76
|
-
marginLeft
|
|
77
|
-
marginRight
|
|
75
|
+
marginLeft
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
if (hidden && Platform.OS === 'web') {
|
|
@@ -5,3 +5,6 @@ export const HERO_POSITION_OFFSET = 20
|
|
|
5
5
|
export const DEFAULT_POSITION_OFFSET = 0
|
|
6
6
|
export const LARGE_VIEWPORT_MARGIN = 40
|
|
7
7
|
export const DEFAULT_VIEWPORT_MARGIN = 10
|
|
8
|
+
export const PEEKING_MULTIPLIER = 2
|
|
9
|
+
export const ACTIVE_INDEX_OFFSET_MULTIPLIER = 1
|
|
10
|
+
export const NEGATIVE_MULTIPLIER = -1
|
|
@@ -236,7 +236,7 @@ const MultiSelectFilter = React.forwardRef(
|
|
|
236
236
|
const [isScrolling, setIsScrolling] = React.useState(false)
|
|
237
237
|
const [scrollViewHeight, setScrollViewHeight] = React.useState(0)
|
|
238
238
|
const [rowHeight, setRowHeight] = React.useState(0)
|
|
239
|
-
const modalRef = useScrollBlocking(isOpen)
|
|
239
|
+
const modalRef = useScrollBlocking(isOpen && viewport === 'xs')
|
|
240
240
|
const windowWidth = Dimensions.get('window').width
|
|
241
241
|
const windowHeight = Dimensions.get('window').height
|
|
242
242
|
|
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
viewProps,
|
|
19
19
|
wrapStringsInText,
|
|
20
20
|
createMediaQueryStyles,
|
|
21
|
-
StyleSheet
|
|
21
|
+
StyleSheet,
|
|
22
|
+
useResponsiveProp
|
|
22
23
|
} from '../utils'
|
|
23
24
|
import IconButton from '../IconButton'
|
|
24
25
|
import useCopy from '../utils/useCopy'
|
|
@@ -64,8 +65,8 @@ const selectDismissButtonContainerStyles = ({ dismissButtonGap }) => ({
|
|
|
64
65
|
placeContent: 'start'
|
|
65
66
|
})
|
|
66
67
|
|
|
67
|
-
const selectContentContainerStyle = (themeTokens, maxWidth,
|
|
68
|
-
maxWidth: viewport === 'xl'
|
|
68
|
+
const selectContentContainerStyle = (themeTokens, maxWidth, system, viewport) => ({
|
|
69
|
+
maxWidth: system && viewport === 'xl' ? maxWidth : '100%',
|
|
69
70
|
width: '100%',
|
|
70
71
|
paddingRight: themeTokens?.containerPaddingRight,
|
|
71
72
|
paddingLeft: themeTokens?.containerPaddingLeft
|
|
@@ -82,7 +83,7 @@ const getMediaQueryStyles = (
|
|
|
82
83
|
) => {
|
|
83
84
|
const transformedSelectContainerStyles = Object.entries(themeTokens).reduce(
|
|
84
85
|
(acc, [vp, viewportTokens]) => {
|
|
85
|
-
acc[vp] = selectContainerStyles({ ...viewportTokens })
|
|
86
|
+
acc[vp] = { ...selectContainerStyles({ ...viewportTokens }), flexDirection: 'column' }
|
|
86
87
|
return acc
|
|
87
88
|
},
|
|
88
89
|
{}
|
|
@@ -92,18 +93,31 @@ const getMediaQueryStyles = (
|
|
|
92
93
|
|
|
93
94
|
const { ids: containerIds, styles: containerStyles } = StyleSheet.create({
|
|
94
95
|
container: {
|
|
95
|
-
flexDirection: 'column',
|
|
96
96
|
...selectContainerMediaQueryStyles
|
|
97
97
|
}
|
|
98
98
|
})
|
|
99
99
|
|
|
100
|
+
const transformedSelectContentContainerStyles = Object.entries(themeTokens).reduce(
|
|
101
|
+
(acc, [vp, viewportTokens]) => {
|
|
102
|
+
acc[vp] = {
|
|
103
|
+
...selectContentContainerStyle(viewportTokens, maxWidth, system, vp),
|
|
104
|
+
flexDirection: 'row',
|
|
105
|
+
flexShrink: 1,
|
|
106
|
+
justifyContent: 'space-between',
|
|
107
|
+
...(system && { alignSelf: 'center' })
|
|
108
|
+
}
|
|
109
|
+
return acc
|
|
110
|
+
},
|
|
111
|
+
{}
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
const selectContentContainerMediaQueryStyles = createMediaQueryStyles(
|
|
115
|
+
transformedSelectContentContainerStyles
|
|
116
|
+
)
|
|
117
|
+
|
|
100
118
|
const { ids: contentContainerIds, styles: contentContainerStyles } = StyleSheet.create({
|
|
101
119
|
contentContainer: {
|
|
102
|
-
|
|
103
|
-
flexShrink: 1,
|
|
104
|
-
justifyContent: 'space-between',
|
|
105
|
-
...selectContentContainerStyle(themeTokens, maxWidth, viewport, system),
|
|
106
|
-
...(system && { alignSelf: 'center' })
|
|
120
|
+
...selectContentContainerMediaQueryStyles
|
|
107
121
|
}
|
|
108
122
|
})
|
|
109
123
|
|
|
@@ -167,7 +181,7 @@ const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible, view
|
|
|
167
181
|
flexDirection: 'row',
|
|
168
182
|
flexShrink: 1,
|
|
169
183
|
justifyContent: 'space-between',
|
|
170
|
-
...selectContentContainerStyle(themeTokens, maxWidth,
|
|
184
|
+
...selectContentContainerStyle(themeTokens, maxWidth, system, viewport),
|
|
171
185
|
...(system && { alignSelf: 'center' })
|
|
172
186
|
}
|
|
173
187
|
},
|
|
@@ -252,7 +266,10 @@ const Notification = React.forwardRef(
|
|
|
252
266
|
system: isSystemEnabled,
|
|
253
267
|
viewport
|
|
254
268
|
})
|
|
255
|
-
const maxWidth =
|
|
269
|
+
const maxWidth = useResponsiveProp(
|
|
270
|
+
themeOptions?.contentMaxWidth,
|
|
271
|
+
viewports.map.get(viewports.xl)
|
|
272
|
+
)
|
|
256
273
|
|
|
257
274
|
const notificationComponentRef = React.useRef({
|
|
258
275
|
containerStyles: {},
|
|
@@ -25,7 +25,7 @@ export const resolveResponsiveProp = (prop, viewport, defaultValue) => {
|
|
|
25
25
|
: // If no current viewport is available, default to smallest viewport
|
|
26
26
|
prop[viewports.keys.find((key) => hasOwnProperty(prop, key))]
|
|
27
27
|
|
|
28
|
-
return value === undefined ? defaultValue : value
|
|
28
|
+
return value === undefined || value === null ? defaultValue : value
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|