@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
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,45 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 05 Mar 2025 00:01:06 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.3.0
|
|
8
|
+
|
|
9
|
+
Wed, 05 Mar 2025 00:01:06 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `Carousel`: add animated background color to hero mode (guillermo.peitzner@telus.com)
|
|
14
|
+
- `ExpandCollapseMini`: add quiet variant (sergio.ramirez@telus.com)
|
|
15
|
+
|
|
16
|
+
### Patches
|
|
17
|
+
|
|
18
|
+
- `Card`: add `accessible` prop to have alt on custom image background (kristina.kirpichnikova@telus.com)
|
|
19
|
+
- `List`: remove textAlign parent value" (sergio.ramirez@telus.com)
|
|
20
|
+
- `Alignment`: fix Typography align issue when using `align` (sergio.ramirez@telus.com)
|
|
21
|
+
- `Carousel`: add progress-bar variants" (guillermo.peitzner@telus.com)
|
|
22
|
+
- `TextArea`: minLines issue when the size value changes dynamically fixed (35577399+JoshHC@users.noreply.github.com)
|
|
23
|
+
- `MultiSelectFilter`: Adding space between title and checkboxes when there isn't a subtitle (Mauricio.BatresMontejo@telus.com)
|
|
24
|
+
|
|
25
|
+
## 3.2.0
|
|
26
|
+
|
|
27
|
+
Fri, 14 Feb 2025 19:03:35 GMT
|
|
28
|
+
|
|
29
|
+
### Minor changes
|
|
30
|
+
|
|
31
|
+
- `Link`: refactoring component for koodo brand (Mauricio.BatresMontejo@telus.com)
|
|
32
|
+
- Bump @telus-uds/system-theme-tokens to v4.2.0
|
|
33
|
+
|
|
34
|
+
### Patches
|
|
35
|
+
|
|
36
|
+
- `Notification`: fix system variant (guillermo.peitzner@telus.com)
|
|
37
|
+
- `Typography`: add default value in text-align (sergio.ramirez@telus.com)
|
|
38
|
+
- `Modal`: Added space below the title when content is passed as a child. (Mauricio.BatresMontejo@telus.com)
|
|
39
|
+
|
|
7
40
|
## 3.1.0
|
|
8
41
|
|
|
9
|
-
Mon, 10 Feb 2025 17:
|
|
42
|
+
Mon, 10 Feb 2025 17:36:47 GMT
|
|
10
43
|
|
|
11
44
|
### Minor changes
|
|
12
45
|
|
package/lib/cjs/Card/CardBase.js
CHANGED
|
@@ -91,13 +91,14 @@ const CardBase = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
91
91
|
ref: ref,
|
|
92
92
|
...props,
|
|
93
93
|
children: src ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageBackground.default, {
|
|
94
|
-
alt: alt,
|
|
95
94
|
source: imageSourceViewport,
|
|
96
95
|
imageStyle: {
|
|
97
96
|
borderRadius: cardStyle?.borderRadius - cardStyle?.borderWidth
|
|
98
97
|
},
|
|
99
98
|
resizeMode: backgroundImageResizeMode,
|
|
100
99
|
style: styles.imageBackground,
|
|
100
|
+
accessible: true,
|
|
101
|
+
accessibilityLabel: alt,
|
|
101
102
|
children: children
|
|
102
103
|
}) : children
|
|
103
104
|
});
|
|
@@ -26,6 +26,7 @@ var _CarouselThumbnailNavigation = _interopRequireDefault(require("./CarouselThu
|
|
|
26
26
|
var _CarouselTabsPanel = _interopRequireDefault(require("./CarouselTabs/CarouselTabsPanel"));
|
|
27
27
|
var _CarouselTabsPanelItem = _interopRequireDefault(require("./CarouselTabs/CarouselTabsPanelItem"));
|
|
28
28
|
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
29
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
|
29
30
|
var _Constants = require("./Constants");
|
|
30
31
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
32
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -48,6 +49,24 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
48
49
|
zIndex: 1,
|
|
49
50
|
right: _Platform.default.OS === 'web' ? undefined : 40,
|
|
50
51
|
top: 40
|
|
52
|
+
},
|
|
53
|
+
heroMainContainer: {
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
top: 0,
|
|
56
|
+
left: 0,
|
|
57
|
+
right: 0,
|
|
58
|
+
bottom: 0,
|
|
59
|
+
overflow: 'hidden',
|
|
60
|
+
zIndex: -1
|
|
61
|
+
},
|
|
62
|
+
heroSwipeArea: {
|
|
63
|
+
position: 'absolute',
|
|
64
|
+
top: 0,
|
|
65
|
+
left: 0,
|
|
66
|
+
right: 0,
|
|
67
|
+
bottom: 0,
|
|
68
|
+
zIndex: -1,
|
|
69
|
+
flexDirection: 'row'
|
|
51
70
|
}
|
|
52
71
|
});
|
|
53
72
|
const selectContainerStyles = width => ({
|
|
@@ -60,6 +79,10 @@ const selectSwipeAreaStyles = (count, width, enablePeeking, enableDisplayMultipl
|
|
|
60
79
|
justifyContent: enablePeeking || enableDisplayMultipleItemsPerSlide ? 'flex-start' : 'space-between',
|
|
61
80
|
flexDirection: 'row'
|
|
62
81
|
});
|
|
82
|
+
const selectHeroContainerStyles = (width, hidden) => ({
|
|
83
|
+
width,
|
|
84
|
+
visibility: hidden ? 'hidden' : 'visible'
|
|
85
|
+
});
|
|
63
86
|
const getDynamicPositionProperty = areStylesAppliedOnPreviousButton => areStylesAppliedOnPreviousButton ? 'left' : 'right';
|
|
64
87
|
const selectControlButtonPositionStyles = _ref => {
|
|
65
88
|
let {
|
|
@@ -68,19 +91,13 @@ const selectControlButtonPositionStyles = _ref => {
|
|
|
68
91
|
positionProperty = getDynamicPositionProperty(),
|
|
69
92
|
spaceBetweenSlideAndButton,
|
|
70
93
|
enablePeeking,
|
|
71
|
-
enableDisplayMultipleItemsPerSlide
|
|
72
|
-
enableHero,
|
|
73
|
-
viewport
|
|
94
|
+
enableDisplayMultipleItemsPerSlide
|
|
74
95
|
} = _ref;
|
|
75
96
|
const styles = {};
|
|
76
97
|
if (positionVariant === 'edge') {
|
|
77
98
|
styles[positionProperty] = -1 * (buttonWidth / 2);
|
|
78
99
|
} else if (positionVariant === 'inside') {
|
|
79
|
-
|
|
80
|
-
styles[positionProperty] = _Constants.HERO_POSITION_OFFSET;
|
|
81
|
-
} else {
|
|
82
|
-
styles[positionProperty] = _Constants.DEFAULT_POSITION_OFFSET;
|
|
83
|
-
}
|
|
100
|
+
styles[positionProperty] = _Constants.DEFAULT_POSITION_OFFSET;
|
|
84
101
|
} else if (positionVariant === 'outside') {
|
|
85
102
|
if (enablePeeking || enableDisplayMultipleItemsPerSlide) {
|
|
86
103
|
styles[positionProperty] = 0;
|
|
@@ -90,7 +107,7 @@ const selectControlButtonPositionStyles = _ref => {
|
|
|
90
107
|
}
|
|
91
108
|
return styles;
|
|
92
109
|
};
|
|
93
|
-
const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, areStylesAppliedOnPreviousButton, enablePeeking, enableDisplayMultipleItemsPerSlide
|
|
110
|
+
const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, areStylesAppliedOnPreviousButton, enablePeeking, enableDisplayMultipleItemsPerSlide) => {
|
|
94
111
|
const styles = {
|
|
95
112
|
zIndex: 1,
|
|
96
113
|
position: 'absolute'
|
|
@@ -110,9 +127,7 @@ const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWi
|
|
|
110
127
|
positionProperty: getDynamicPositionProperty(areStylesAppliedOnPreviousButton),
|
|
111
128
|
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
|
|
112
129
|
enablePeeking,
|
|
113
|
-
enableDisplayMultipleItemsPerSlide
|
|
114
|
-
enableHero,
|
|
115
|
-
viewport
|
|
130
|
+
enableDisplayMultipleItemsPerSlide
|
|
116
131
|
})
|
|
117
132
|
};
|
|
118
133
|
};
|
|
@@ -170,15 +185,12 @@ const selectMainContainerStyles = (enableHero, viewport) => {
|
|
|
170
185
|
}
|
|
171
186
|
return {};
|
|
172
187
|
};
|
|
173
|
-
const selectNavigationStyles = (tabs,
|
|
174
|
-
let marginTop = 0;
|
|
188
|
+
const selectNavigationStyles = (tabs, enableHero, viewport) => {
|
|
175
189
|
let marginHorizontal = 0;
|
|
176
190
|
if (enableHero && tabs) {
|
|
177
|
-
marginTop = -tabsPanelHeight;
|
|
178
191
|
marginHorizontal = viewport === 'xl' ? _Constants.LARGE_VIEWPORT_MARGIN : _Constants.DEFAULT_VIEWPORT_MARGIN;
|
|
179
192
|
}
|
|
180
193
|
return {
|
|
181
|
-
marginTop,
|
|
182
194
|
marginHorizontal
|
|
183
195
|
};
|
|
184
196
|
};
|
|
@@ -310,6 +322,9 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
310
322
|
itemLabel = 'item',
|
|
311
323
|
previousNextNavigationPosition = 'inside',
|
|
312
324
|
stepTrackerVariant,
|
|
325
|
+
progressBarVariant = {
|
|
326
|
+
style: 'subtle'
|
|
327
|
+
},
|
|
313
328
|
previousNextIconSize = 'default',
|
|
314
329
|
minDistanceToCapture = 5,
|
|
315
330
|
minDistanceForAction = 0.2,
|
|
@@ -327,7 +342,8 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
327
342
|
panelNavigation = thumbnails ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_CarouselThumbnailNavigation.default, {
|
|
328
343
|
thumbnails: thumbnails
|
|
329
344
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CarouselStepTracker.default, {
|
|
330
|
-
|
|
345
|
+
stepTrackerVariant: stepTrackerVariant,
|
|
346
|
+
progressBarVariant: progressBarVariant,
|
|
331
347
|
enableDisplayMultipleItemsPerSlide: enableDisplayMultipleItemsPerSlide
|
|
332
348
|
}),
|
|
333
349
|
tag = 'ul',
|
|
@@ -379,11 +395,21 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
379
395
|
height: 0
|
|
380
396
|
});
|
|
381
397
|
const containerLayoutRef = _react.default.useRef(containerLayout);
|
|
398
|
+
const [heroContainerLayout, setHeroContainerLayout] = _react.default.useState({
|
|
399
|
+
x: 0,
|
|
400
|
+
y: 0,
|
|
401
|
+
width: 0,
|
|
402
|
+
height: 0
|
|
403
|
+
});
|
|
404
|
+
const heroContainerLayoutRef = _react.default.useRef(heroContainerLayout);
|
|
382
405
|
const [previousNextNavigationButtonWidth, setPreviousNextNavigationButtonWidth] = _react.default.useState(0);
|
|
383
406
|
const firstFocusRef = _react.default.useRef(null);
|
|
384
407
|
const pan = _react.default.useRef(new _Animated.default.ValueXY()).current;
|
|
385
408
|
const animatedX = _react.default.useRef(0);
|
|
386
409
|
const animatedY = _react.default.useRef(0);
|
|
410
|
+
const heroPan = _react.default.useRef(new _Animated.default.ValueXY()).current;
|
|
411
|
+
const heroAnimatedX = _react.default.useRef(0);
|
|
412
|
+
const heroAnimatedY = _react.default.useRef(0);
|
|
387
413
|
const [isAnimating, setIsAnimating] = _react.default.useState(false);
|
|
388
414
|
/**
|
|
389
415
|
* While having the same starting point, `isAutoPlayEnabled` and `isCarouselPlaying` are different states
|
|
@@ -416,8 +442,20 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
416
442
|
x: 0,
|
|
417
443
|
y: 0
|
|
418
444
|
});
|
|
419
|
-
|
|
420
|
-
|
|
445
|
+
if (enableHero) {
|
|
446
|
+
heroAnimatedX.current = heroContainerLayoutRef.current.width * activeIndexRef.current * -1;
|
|
447
|
+
heroAnimatedY.current = 0;
|
|
448
|
+
heroPan.setOffset({
|
|
449
|
+
x: heroAnimatedX.current,
|
|
450
|
+
y: heroAnimatedY.current
|
|
451
|
+
});
|
|
452
|
+
heroPan.setValue({
|
|
453
|
+
x: 0,
|
|
454
|
+
y: 0
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}, [pan, animatedX, heroPan, heroAnimatedX, enableHero]);
|
|
458
|
+
const animate = _react.default.useCallback((panToAnimate, toValue, toIndex) => {
|
|
421
459
|
const handleAnimationEndToIndex = function () {
|
|
422
460
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
423
461
|
args[_key] = arguments[_key];
|
|
@@ -425,33 +463,33 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
425
463
|
return handleAnimationEnd(toIndex, ...args);
|
|
426
464
|
};
|
|
427
465
|
if (reduceMotionRef.current || isSwiping.current) {
|
|
428
|
-
_Animated.default.timing(
|
|
466
|
+
_Animated.default.timing(panToAnimate, {
|
|
429
467
|
toValue,
|
|
430
468
|
duration: 1,
|
|
431
469
|
useNativeDriver: false
|
|
432
470
|
}).start(handleAnimationEndToIndex);
|
|
433
471
|
} else if (isAutoPlayEnabled) {
|
|
434
|
-
_Animated.default.timing(
|
|
472
|
+
_Animated.default.timing(panToAnimate, {
|
|
435
473
|
...springConfig,
|
|
436
474
|
toValue,
|
|
437
475
|
useNativeDriver: false,
|
|
438
476
|
duration: transitionDuration * 1000
|
|
439
477
|
}).start(handleAnimationEndToIndex);
|
|
440
478
|
} else if (enablePeeking || enableDisplayMultipleItemsPerSlide) {
|
|
441
|
-
_Animated.default.timing(
|
|
479
|
+
_Animated.default.timing(panToAnimate, {
|
|
442
480
|
...springConfig,
|
|
443
481
|
toValue,
|
|
444
482
|
useNativeDriver: false,
|
|
445
483
|
duration: transitionDuration ? transitionDuration * 1000 : 1000
|
|
446
484
|
}).start(handleAnimationEndToIndex);
|
|
447
485
|
} else {
|
|
448
|
-
_Animated.default.spring(
|
|
486
|
+
_Animated.default.spring(panToAnimate, {
|
|
449
487
|
...springConfig,
|
|
450
488
|
toValue,
|
|
451
489
|
useNativeDriver: false
|
|
452
490
|
}).start(handleAnimationEndToIndex);
|
|
453
491
|
}
|
|
454
|
-
}, [
|
|
492
|
+
}, [springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled, enablePeeking, enableDisplayMultipleItemsPerSlide]);
|
|
455
493
|
const stopAutoplay = _react.default.useCallback(() => {
|
|
456
494
|
if (autoPlayRef?.current) {
|
|
457
495
|
clearTimeout(autoPlayRef?.current);
|
|
@@ -483,14 +521,25 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
483
521
|
}
|
|
484
522
|
const index = activeIndexRef.current + calcDelta;
|
|
485
523
|
if (skipChanges) {
|
|
486
|
-
animate(toValue, index);
|
|
524
|
+
animate(pan, toValue, index);
|
|
525
|
+
if (enableHero) {
|
|
526
|
+
animate(heroPan, toValue, index);
|
|
527
|
+
}
|
|
487
528
|
return calcDelta;
|
|
488
529
|
}
|
|
489
530
|
stopAutoplay();
|
|
490
531
|
setActiveIndex(index);
|
|
491
532
|
const finalWidth = calculateFinalWidth(containerLayoutRef.current.width, enablePeeking, viewport, activeIndexRef, totalItems, calcDelta);
|
|
492
533
|
toValue.x = finalWidth * -1 * calcDelta;
|
|
493
|
-
|
|
534
|
+
const heroToValue = {
|
|
535
|
+
x: 0,
|
|
536
|
+
y: 0
|
|
537
|
+
};
|
|
538
|
+
heroToValue.x = heroContainerLayoutRef.current.width * -1 * calcDelta;
|
|
539
|
+
animate(pan, toValue, index);
|
|
540
|
+
if (enableHero) {
|
|
541
|
+
animate(heroPan, heroToValue, index);
|
|
542
|
+
}
|
|
494
543
|
if (isCarouselPlaying) {
|
|
495
544
|
stopAutoplay();
|
|
496
545
|
if (index === 0 && activeIndexRef.current + 1 === totalItems && transitionMode === TRANSITION_MODES.AUTOMATIC) {
|
|
@@ -506,7 +555,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
506
555
|
}
|
|
507
556
|
if (onIndexChanged) onIndexChanged(calcDelta, index);
|
|
508
557
|
return calcDelta;
|
|
509
|
-
}, [handleAnimationStart, triggerRefocus, slideDuration, updateOffset, animate, totalItems, onIndexChanged, isCarouselPlaying, stopAutoplay, isAutoPlayEnabled, viewport, enablePeeking]);
|
|
558
|
+
}, [handleAnimationStart, triggerRefocus, slideDuration, updateOffset, animate, totalItems, onIndexChanged, isCarouselPlaying, stopAutoplay, isAutoPlayEnabled, viewport, enablePeeking, pan, heroPan, enableHero]);
|
|
510
559
|
const startAutoplay = _react.default.useCallback(() => {
|
|
511
560
|
stopAutoplay();
|
|
512
561
|
if (isAutoPlayEnabled) {
|
|
@@ -529,7 +578,6 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
529
578
|
let transitionMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TRANSITION_MODES.MANUAL;
|
|
530
579
|
fixOffsetAndGo(toPrev ? -1 : 1, transitionMode);
|
|
531
580
|
}, [fixOffsetAndGo]);
|
|
532
|
-
const [tabsPanelHeight, setTabsPanelHeight] = _react.default.useState(0);
|
|
533
581
|
_react.default.useEffect(() => {
|
|
534
582
|
activeIndexRef.current = activeIndex;
|
|
535
583
|
}, [activeIndex]);
|
|
@@ -539,6 +587,9 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
539
587
|
_react.default.useEffect(() => {
|
|
540
588
|
containerLayoutRef.current = containerLayout;
|
|
541
589
|
}, [containerLayout]);
|
|
590
|
+
_react.default.useEffect(() => {
|
|
591
|
+
heroContainerLayoutRef.current = heroContainerLayout;
|
|
592
|
+
}, [heroContainerLayout]);
|
|
542
593
|
_react.default.useEffect(() => {
|
|
543
594
|
pan.x.addListener(_ref4 => {
|
|
544
595
|
let {
|
|
@@ -552,6 +603,20 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
552
603
|
} = _ref5;
|
|
553
604
|
animatedY.current = value;
|
|
554
605
|
});
|
|
606
|
+
if (enableHero) {
|
|
607
|
+
heroPan.x.addListener(_ref6 => {
|
|
608
|
+
let {
|
|
609
|
+
value
|
|
610
|
+
} = _ref6;
|
|
611
|
+
heroAnimatedX.current = value;
|
|
612
|
+
});
|
|
613
|
+
heroPan.y.addListener(_ref7 => {
|
|
614
|
+
let {
|
|
615
|
+
value
|
|
616
|
+
} = _ref7;
|
|
617
|
+
heroAnimatedY.current = value;
|
|
618
|
+
});
|
|
619
|
+
}
|
|
555
620
|
if (isCarouselPlaying) {
|
|
556
621
|
startAutoplay();
|
|
557
622
|
}
|
|
@@ -559,8 +624,12 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
559
624
|
stopAutoplay();
|
|
560
625
|
pan.x.removeAllListeners();
|
|
561
626
|
pan.y.removeAllListeners();
|
|
627
|
+
if (enableHero) {
|
|
628
|
+
heroPan.x.removeAllListeners();
|
|
629
|
+
heroPan.y.removeAllListeners();
|
|
630
|
+
}
|
|
562
631
|
};
|
|
563
|
-
}, [pan.x, pan.y, startAutoplay, stopAutoplay, isCarouselPlaying]);
|
|
632
|
+
}, [pan.x, pan.y, heroPan.x, heroPan.y, startAutoplay, stopAutoplay, isCarouselPlaying, enableHero]);
|
|
564
633
|
_react.default.useEffect(() => {
|
|
565
634
|
const subscription = _Dimensions.default.addEventListener('change', () => {
|
|
566
635
|
updateOffset();
|
|
@@ -581,10 +650,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
581
650
|
stopAutoplay();
|
|
582
651
|
};
|
|
583
652
|
}, [stopAutoplay]);
|
|
584
|
-
const
|
|
585
|
-
setTabsPanelHeight(event.nativeEvent.layout.height);
|
|
586
|
-
};
|
|
587
|
-
const onContainerLayout = _ref6 => {
|
|
653
|
+
const onContainerLayout = _ref8 => {
|
|
588
654
|
let {
|
|
589
655
|
nativeEvent: {
|
|
590
656
|
layout: {
|
|
@@ -594,7 +660,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
594
660
|
height
|
|
595
661
|
}
|
|
596
662
|
}
|
|
597
|
-
} =
|
|
663
|
+
} = _ref8;
|
|
598
664
|
return setContainerLayout(prevState => ({
|
|
599
665
|
...prevState,
|
|
600
666
|
x,
|
|
@@ -603,14 +669,33 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
603
669
|
height
|
|
604
670
|
}));
|
|
605
671
|
};
|
|
606
|
-
const
|
|
672
|
+
const onHeroContainerLayout = _ref9 => {
|
|
673
|
+
let {
|
|
674
|
+
nativeEvent: {
|
|
675
|
+
layout: {
|
|
676
|
+
x,
|
|
677
|
+
y,
|
|
678
|
+
width,
|
|
679
|
+
height
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
} = _ref9;
|
|
683
|
+
return setHeroContainerLayout(prevState => ({
|
|
684
|
+
...prevState,
|
|
685
|
+
x,
|
|
686
|
+
y,
|
|
687
|
+
width,
|
|
688
|
+
height
|
|
689
|
+
}));
|
|
690
|
+
};
|
|
691
|
+
const onPreviousNextNavigationButtonLayout = _ref10 => {
|
|
607
692
|
let {
|
|
608
693
|
nativeEvent: {
|
|
609
694
|
layout: {
|
|
610
695
|
width
|
|
611
696
|
}
|
|
612
697
|
}
|
|
613
|
-
} =
|
|
698
|
+
} = _ref10;
|
|
614
699
|
return setPreviousNextNavigationButtonWidth(width);
|
|
615
700
|
};
|
|
616
701
|
const isSwipeAllowed = _react.default.useCallback(() => {
|
|
@@ -651,7 +736,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
651
736
|
}
|
|
652
737
|
const correction = gesture.moveX - gesture.x0;
|
|
653
738
|
if (Math.abs(correction) < containerLayoutRef.current.width * minDistanceForAction) {
|
|
654
|
-
animate({
|
|
739
|
+
animate(pan, {
|
|
655
740
|
x: 0,
|
|
656
741
|
y: 0
|
|
657
742
|
}, 0);
|
|
@@ -661,7 +746,47 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
661
746
|
}
|
|
662
747
|
isSwiping.current = false;
|
|
663
748
|
}
|
|
664
|
-
}), [updateIndex, updateOffset, animate, isSwipeAllowed, minDistanceForAction, handleAnimationStart, minDistanceToCapture,
|
|
749
|
+
}), [pan, updateIndex, updateOffset, animate, isSwipeAllowed, minDistanceForAction, handleAnimationStart, minDistanceToCapture, startAutoplay, stopAutoplay, isCarouselPlaying]);
|
|
750
|
+
const heroPanResponder = _react.default.useMemo(() => _PanResponder.default.create({
|
|
751
|
+
onPanResponderTerminationRequest: () => false,
|
|
752
|
+
onMoveShouldSetResponderCapture: () => true,
|
|
753
|
+
onMoveShouldSetPanResponderCapture: (_, gestureState) => {
|
|
754
|
+
if (!isSwipeAllowed()) {
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
handleAnimationStart(activeIndexRef.current);
|
|
758
|
+
const allow = Math.abs(gestureState.dx) > minDistanceToCapture;
|
|
759
|
+
if (allow) {
|
|
760
|
+
isSwiping.current = true;
|
|
761
|
+
stopAutoplay();
|
|
762
|
+
}
|
|
763
|
+
return allow;
|
|
764
|
+
},
|
|
765
|
+
onPanResponderGrant: () => {
|
|
766
|
+
updateOffset();
|
|
767
|
+
},
|
|
768
|
+
onPanResponderMove: _Animated.default.event([null, {
|
|
769
|
+
dx: heroPan.x
|
|
770
|
+
}], {
|
|
771
|
+
useNativeDriver: false
|
|
772
|
+
}),
|
|
773
|
+
onPanResponderRelease: (_, gesture) => {
|
|
774
|
+
if (isCarouselPlaying) {
|
|
775
|
+
startAutoplay();
|
|
776
|
+
}
|
|
777
|
+
const correction = gesture.moveX - gesture.x0;
|
|
778
|
+
if (Math.abs(correction) < containerLayoutRef.current.width * minDistanceForAction) {
|
|
779
|
+
animate(heroPan, {
|
|
780
|
+
x: 0,
|
|
781
|
+
y: 0
|
|
782
|
+
}, 0);
|
|
783
|
+
} else {
|
|
784
|
+
const delta = correction > 0 ? -1 : 1;
|
|
785
|
+
updateIndex(delta, TRANSITION_MODES.SWIPE);
|
|
786
|
+
}
|
|
787
|
+
isSwiping.current = false;
|
|
788
|
+
}
|
|
789
|
+
}), [heroPan, updateIndex, updateOffset, animate, isSwipeAllowed, minDistanceForAction, handleAnimationStart, minDistanceToCapture, startAutoplay, stopAutoplay, isCarouselPlaying]);
|
|
665
790
|
const goToNext = _react.default.useCallback(() => {
|
|
666
791
|
goToNeighboring();
|
|
667
792
|
}, [goToNeighboring]);
|
|
@@ -732,9 +857,9 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
732
857
|
}
|
|
733
858
|
setisCarouselPlaying(prevState => !prevState);
|
|
734
859
|
}, [isCarouselPlaying, stopAutoplay, startAutoplay]);
|
|
735
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
860
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
736
861
|
style: selectRootContainerStyles(enableHero, viewport),
|
|
737
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
862
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
738
863
|
style: selectMainContainerStyles(enableHero, viewport),
|
|
739
864
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CarouselContext.CarouselProvider, {
|
|
740
865
|
activeIndex: activeIndex,
|
|
@@ -763,9 +888,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
763
888
|
positionProperty: getDynamicPositionProperty(),
|
|
764
889
|
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
|
|
765
890
|
enablePeeking,
|
|
766
|
-
enableDisplayMultipleItemsPerSlide
|
|
767
|
-
enableHero,
|
|
768
|
-
viewport
|
|
891
|
+
enableDisplayMultipleItemsPerSlide
|
|
769
892
|
})],
|
|
770
893
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
771
894
|
icon: isCarouselPlaying ? pauseIcon : playIcon,
|
|
@@ -774,7 +897,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
774
897
|
onPress: onAnimationControlButtonPress
|
|
775
898
|
})
|
|
776
899
|
}) : null, showPreviousNextNavigation && totalItems > 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
777
|
-
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true, enablePeeking, enableDisplayMultipleItemsPerSlide
|
|
900
|
+
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true, enablePeeking, enableDisplayMultipleItemsPerSlide),
|
|
778
901
|
testID: "previous-button-container",
|
|
779
902
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
780
903
|
onLayout: onPreviousNextNavigationButtonLayout,
|
|
@@ -818,9 +941,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
818
941
|
peekingProps: getPeekingProps(viewport),
|
|
819
942
|
enableDisplayMultipleItemsPerSlide,
|
|
820
943
|
viewport,
|
|
821
|
-
backgroundColor: element.props.backgroundColor
|
|
822
|
-
enableHero,
|
|
823
|
-
tabsPanelHeight
|
|
944
|
+
backgroundColor: element.props.backgroundColor
|
|
824
945
|
});
|
|
825
946
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
|
|
826
947
|
children: clonedElement
|
|
@@ -828,7 +949,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
828
949
|
})
|
|
829
950
|
})
|
|
830
951
|
}), showPreviousNextNavigation && totalItems > 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
831
|
-
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false, enablePeeking, enableDisplayMultipleItemsPerSlide
|
|
952
|
+
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false, enablePeeking, enableDisplayMultipleItemsPerSlide),
|
|
832
953
|
testID: "next-button-container",
|
|
833
954
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
834
955
|
onLayout: onPreviousNextNavigationButtonLayout,
|
|
@@ -840,12 +961,38 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
840
961
|
})
|
|
841
962
|
}) : null]
|
|
842
963
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
843
|
-
style: selectNavigationStyles(tabs,
|
|
844
|
-
onLayout: tabs && onTabsPanelLayout,
|
|
964
|
+
style: selectNavigationStyles(tabs, enableHero, viewport),
|
|
845
965
|
children: showPanelNavigation ? activePanelNavigation : null
|
|
846
966
|
})]
|
|
847
967
|
})
|
|
848
|
-
})
|
|
968
|
+
}), enableHero && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
969
|
+
style: staticStyles.heroMainContainer,
|
|
970
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Animated.default.View, {
|
|
971
|
+
style: _StyleSheet.default.flatten([staticStyles.heroSwipeArea, {
|
|
972
|
+
transform: [{
|
|
973
|
+
translateX: heroPan.x
|
|
974
|
+
}, {
|
|
975
|
+
translateY: heroPan.y
|
|
976
|
+
}]
|
|
977
|
+
}]),
|
|
978
|
+
onLayout: onHeroContainerLayout,
|
|
979
|
+
...heroPanResponder.panHandlers,
|
|
980
|
+
...(0, _utils.getA11yPropsFromHtmlTag)(tag),
|
|
981
|
+
accessibilityLiveRegion: accessibilityLiveRegion,
|
|
982
|
+
children: childrenArray.map((element, index) => {
|
|
983
|
+
const hidden = !isAnimating && index !== activeIndex;
|
|
984
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
985
|
+
style: selectHeroContainerStyles(heroContainerLayout.width, hidden),
|
|
986
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
987
|
+
flex: 1,
|
|
988
|
+
variant: {
|
|
989
|
+
background: element.props.backgroundColor
|
|
990
|
+
}
|
|
991
|
+
})
|
|
992
|
+
}, index.toFixed(2));
|
|
993
|
+
})
|
|
994
|
+
})
|
|
995
|
+
})]
|
|
849
996
|
});
|
|
850
997
|
});
|
|
851
998
|
Carousel.propTypes = {
|
|
@@ -856,6 +1003,10 @@ Carousel.propTypes = {
|
|
|
856
1003
|
* Prop related to StepTracker Variants
|
|
857
1004
|
*/
|
|
858
1005
|
stepTrackerVariant: _utils.variantProp.propType,
|
|
1006
|
+
/**
|
|
1007
|
+
* Prop related to ProgressBar Variants
|
|
1008
|
+
*/
|
|
1009
|
+
progressBarVariant: _utils.variantProp.propType,
|
|
859
1010
|
/**
|
|
860
1011
|
* Slides to render in Carousel. Wrap individual slides in `Carousel.Item`
|
|
861
1012
|
*/
|
|
@@ -11,7 +11,6 @@ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/export
|
|
|
11
11
|
var _utils = require("../../utils");
|
|
12
12
|
var _CarouselContext = require("../CarouselContext");
|
|
13
13
|
var _Constants = require("../Constants");
|
|
14
|
-
var _Box = _interopRequireDefault(require("../../Box"));
|
|
15
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
16
|
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
@@ -93,8 +92,6 @@ const CarouselItem = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
93
92
|
enableDisplayMultipleItemsPerSlide,
|
|
94
93
|
viewport,
|
|
95
94
|
backgroundColor,
|
|
96
|
-
enableHero,
|
|
97
|
-
tabsPanelHeight,
|
|
98
95
|
...rest
|
|
99
96
|
} = _ref2;
|
|
100
97
|
const {
|
|
@@ -119,18 +116,7 @@ const CarouselItem = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
119
116
|
...selectedProps,
|
|
120
117
|
...focusabilityProps,
|
|
121
118
|
ref: ref,
|
|
122
|
-
children:
|
|
123
|
-
variant: {
|
|
124
|
-
background: backgroundColor
|
|
125
|
-
},
|
|
126
|
-
space: 0,
|
|
127
|
-
flex: 1,
|
|
128
|
-
children: [children, enableHero && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
129
|
-
style: {
|
|
130
|
-
height: tabsPanelHeight
|
|
131
|
-
}
|
|
132
|
-
})]
|
|
133
|
-
})
|
|
119
|
+
children: children
|
|
134
120
|
});
|
|
135
121
|
});
|
|
136
122
|
CarouselItem.propTypes = {
|
|
@@ -18,7 +18,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
const CarouselStepTracker = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
20
20
|
let {
|
|
21
|
-
|
|
21
|
+
stepTrackerVariant,
|
|
22
|
+
progressBarVariant,
|
|
22
23
|
enableDisplayMultipleItemsPerSlide
|
|
23
24
|
} = _ref;
|
|
24
25
|
const {
|
|
@@ -62,9 +63,7 @@ const CarouselStepTracker = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =
|
|
|
62
63
|
items: totalItems,
|
|
63
64
|
current: activeIndex + 1
|
|
64
65
|
},
|
|
65
|
-
variant:
|
|
66
|
-
style: 'subtle'
|
|
67
|
-
},
|
|
66
|
+
variant: progressBarVariant,
|
|
68
67
|
accessibilityLabel: getCopyWithPlaceholders('stepTrackerLabel')
|
|
69
68
|
})
|
|
70
69
|
})
|
|
@@ -84,13 +83,14 @@ const CarouselStepTracker = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =
|
|
|
84
83
|
stepTrackerLabel: getCopyWithPlaceholders('stepTrackerLabel')
|
|
85
84
|
},
|
|
86
85
|
tokens: stepTrackerTokens,
|
|
87
|
-
variant:
|
|
86
|
+
variant: stepTrackerVariant
|
|
88
87
|
})
|
|
89
88
|
});
|
|
90
89
|
});
|
|
91
90
|
CarouselStepTracker.displayName = 'CarouselStepTracker';
|
|
92
91
|
CarouselStepTracker.propTypes = {
|
|
93
|
-
|
|
92
|
+
stepTrackerVariant: _utils.variantProp.propType,
|
|
93
|
+
progressBarVariant: _utils.variantProp.propType,
|
|
94
94
|
enableDisplayMultipleItemsPerSlide: _propTypes.default.bool
|
|
95
95
|
};
|
|
96
96
|
const staticStyles = _StyleSheet.default.create({
|
|
@@ -48,7 +48,9 @@ function selectContainerStyles(_ref) {
|
|
|
48
48
|
borderBottomRightRadius,
|
|
49
49
|
borderTopLeftRadius,
|
|
50
50
|
borderBottomLeftRadius,
|
|
51
|
-
...(0, _ThemeProvider.verticalAlignRow)(verticalAlign, iconPosition === 'right')
|
|
51
|
+
...(0, _ThemeProvider.verticalAlignRow)(verticalAlign, iconPosition === 'right'),
|
|
52
|
+
// Updated default alignment due to the change in Pressable's behavior from div to button on web.
|
|
53
|
+
textAlign: _Platform.default.OS === 'web' ? 'inherit' : undefined
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -41,7 +41,7 @@ const ExpandCollapseMini = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
41
41
|
// Remove unwanted look and feel from ExpandCollapse(background pressed, focus border and text underline)
|
|
42
42
|
icon: null,
|
|
43
43
|
borderColor: 'transparent',
|
|
44
|
-
textLine: 'none',
|
|
44
|
+
textLine: tokens.textLine ?? 'none',
|
|
45
45
|
backgroundColor: 'transparent'
|
|
46
46
|
}
|
|
47
47
|
// TODO refactor
|