@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
|
@@ -20,7 +20,8 @@ import CarouselThumbnailNavigation from './CarouselThumbnailNavigation';
|
|
|
20
20
|
import CarouselTabsPanel from './CarouselTabs/CarouselTabsPanel';
|
|
21
21
|
import CarouselTabsPanelItem from './CarouselTabs/CarouselTabsPanelItem';
|
|
22
22
|
import dictionary from './dictionary';
|
|
23
|
-
import
|
|
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
25
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
26
|
const TRANSITION_MODES = {
|
|
26
27
|
MANUAL: 'manual',
|
|
@@ -41,6 +42,24 @@ const staticStyles = StyleSheet.create({
|
|
|
41
42
|
zIndex: 1,
|
|
42
43
|
right: Platform.OS === 'web' ? undefined : 40,
|
|
43
44
|
top: 40
|
|
45
|
+
},
|
|
46
|
+
heroMainContainer: {
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
top: 0,
|
|
49
|
+
left: 0,
|
|
50
|
+
right: 0,
|
|
51
|
+
bottom: 0,
|
|
52
|
+
overflow: 'hidden',
|
|
53
|
+
zIndex: -1
|
|
54
|
+
},
|
|
55
|
+
heroSwipeArea: {
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
top: 0,
|
|
58
|
+
left: 0,
|
|
59
|
+
right: 0,
|
|
60
|
+
bottom: 0,
|
|
61
|
+
zIndex: -1,
|
|
62
|
+
flexDirection: 'row'
|
|
44
63
|
}
|
|
45
64
|
});
|
|
46
65
|
const selectContainerStyles = width => ({
|
|
@@ -53,6 +72,10 @@ const selectSwipeAreaStyles = (count, width, enablePeeking, enableDisplayMultipl
|
|
|
53
72
|
justifyContent: enablePeeking || enableDisplayMultipleItemsPerSlide ? 'flex-start' : 'space-between',
|
|
54
73
|
flexDirection: 'row'
|
|
55
74
|
});
|
|
75
|
+
const selectHeroContainerStyles = (width, hidden) => ({
|
|
76
|
+
width,
|
|
77
|
+
visibility: hidden ? 'hidden' : 'visible'
|
|
78
|
+
});
|
|
56
79
|
const getDynamicPositionProperty = areStylesAppliedOnPreviousButton => areStylesAppliedOnPreviousButton ? 'left' : 'right';
|
|
57
80
|
const selectControlButtonPositionStyles = _ref => {
|
|
58
81
|
let {
|
|
@@ -61,19 +84,13 @@ const selectControlButtonPositionStyles = _ref => {
|
|
|
61
84
|
positionProperty = getDynamicPositionProperty(),
|
|
62
85
|
spaceBetweenSlideAndButton,
|
|
63
86
|
enablePeeking,
|
|
64
|
-
enableDisplayMultipleItemsPerSlide
|
|
65
|
-
enableHero,
|
|
66
|
-
viewport
|
|
87
|
+
enableDisplayMultipleItemsPerSlide
|
|
67
88
|
} = _ref;
|
|
68
89
|
const styles = {};
|
|
69
90
|
if (positionVariant === 'edge') {
|
|
70
91
|
styles[positionProperty] = -1 * (buttonWidth / 2);
|
|
71
92
|
} else if (positionVariant === 'inside') {
|
|
72
|
-
|
|
73
|
-
styles[positionProperty] = HERO_POSITION_OFFSET;
|
|
74
|
-
} else {
|
|
75
|
-
styles[positionProperty] = DEFAULT_POSITION_OFFSET;
|
|
76
|
-
}
|
|
93
|
+
styles[positionProperty] = DEFAULT_POSITION_OFFSET;
|
|
77
94
|
} else if (positionVariant === 'outside') {
|
|
78
95
|
if (enablePeeking || enableDisplayMultipleItemsPerSlide) {
|
|
79
96
|
styles[positionProperty] = 0;
|
|
@@ -83,7 +100,7 @@ const selectControlButtonPositionStyles = _ref => {
|
|
|
83
100
|
}
|
|
84
101
|
return styles;
|
|
85
102
|
};
|
|
86
|
-
const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, areStylesAppliedOnPreviousButton, enablePeeking, enableDisplayMultipleItemsPerSlide
|
|
103
|
+
const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, areStylesAppliedOnPreviousButton, enablePeeking, enableDisplayMultipleItemsPerSlide) => {
|
|
87
104
|
const styles = {
|
|
88
105
|
zIndex: 1,
|
|
89
106
|
position: 'absolute'
|
|
@@ -103,9 +120,7 @@ const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWi
|
|
|
103
120
|
positionProperty: getDynamicPositionProperty(areStylesAppliedOnPreviousButton),
|
|
104
121
|
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
|
|
105
122
|
enablePeeking,
|
|
106
|
-
enableDisplayMultipleItemsPerSlide
|
|
107
|
-
enableHero,
|
|
108
|
-
viewport
|
|
123
|
+
enableDisplayMultipleItemsPerSlide
|
|
109
124
|
})
|
|
110
125
|
};
|
|
111
126
|
};
|
|
@@ -163,15 +178,12 @@ const selectMainContainerStyles = (enableHero, viewport) => {
|
|
|
163
178
|
}
|
|
164
179
|
return {};
|
|
165
180
|
};
|
|
166
|
-
const selectNavigationStyles = (tabs,
|
|
167
|
-
let marginTop = 0;
|
|
181
|
+
const selectNavigationStyles = (tabs, enableHero, viewport) => {
|
|
168
182
|
let marginHorizontal = 0;
|
|
169
183
|
if (enableHero && tabs) {
|
|
170
|
-
marginTop = -tabsPanelHeight;
|
|
171
184
|
marginHorizontal = viewport === 'xl' ? LARGE_VIEWPORT_MARGIN : DEFAULT_VIEWPORT_MARGIN;
|
|
172
185
|
}
|
|
173
186
|
return {
|
|
174
|
-
marginTop,
|
|
175
187
|
marginHorizontal
|
|
176
188
|
};
|
|
177
189
|
};
|
|
@@ -303,6 +315,9 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
303
315
|
itemLabel = 'item',
|
|
304
316
|
previousNextNavigationPosition = 'inside',
|
|
305
317
|
stepTrackerVariant,
|
|
318
|
+
progressBarVariant = {
|
|
319
|
+
style: 'subtle'
|
|
320
|
+
},
|
|
306
321
|
previousNextIconSize = 'default',
|
|
307
322
|
minDistanceToCapture = 5,
|
|
308
323
|
minDistanceForAction = 0.2,
|
|
@@ -320,7 +335,8 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
320
335
|
panelNavigation = thumbnails ? /*#__PURE__*/_jsx(CarouselThumbnailNavigation, {
|
|
321
336
|
thumbnails: thumbnails
|
|
322
337
|
}) : /*#__PURE__*/_jsx(CarouselStepTracker, {
|
|
323
|
-
|
|
338
|
+
stepTrackerVariant: stepTrackerVariant,
|
|
339
|
+
progressBarVariant: progressBarVariant,
|
|
324
340
|
enableDisplayMultipleItemsPerSlide: enableDisplayMultipleItemsPerSlide
|
|
325
341
|
}),
|
|
326
342
|
tag = 'ul',
|
|
@@ -372,11 +388,21 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
372
388
|
height: 0
|
|
373
389
|
});
|
|
374
390
|
const containerLayoutRef = React.useRef(containerLayout);
|
|
391
|
+
const [heroContainerLayout, setHeroContainerLayout] = React.useState({
|
|
392
|
+
x: 0,
|
|
393
|
+
y: 0,
|
|
394
|
+
width: 0,
|
|
395
|
+
height: 0
|
|
396
|
+
});
|
|
397
|
+
const heroContainerLayoutRef = React.useRef(heroContainerLayout);
|
|
375
398
|
const [previousNextNavigationButtonWidth, setPreviousNextNavigationButtonWidth] = React.useState(0);
|
|
376
399
|
const firstFocusRef = React.useRef(null);
|
|
377
400
|
const pan = React.useRef(new Animated.ValueXY()).current;
|
|
378
401
|
const animatedX = React.useRef(0);
|
|
379
402
|
const animatedY = React.useRef(0);
|
|
403
|
+
const heroPan = React.useRef(new Animated.ValueXY()).current;
|
|
404
|
+
const heroAnimatedX = React.useRef(0);
|
|
405
|
+
const heroAnimatedY = React.useRef(0);
|
|
380
406
|
const [isAnimating, setIsAnimating] = React.useState(false);
|
|
381
407
|
/**
|
|
382
408
|
* While having the same starting point, `isAutoPlayEnabled` and `isCarouselPlaying` are different states
|
|
@@ -409,8 +435,20 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
409
435
|
x: 0,
|
|
410
436
|
y: 0
|
|
411
437
|
});
|
|
412
|
-
|
|
413
|
-
|
|
438
|
+
if (enableHero) {
|
|
439
|
+
heroAnimatedX.current = heroContainerLayoutRef.current.width * activeIndexRef.current * -1;
|
|
440
|
+
heroAnimatedY.current = 0;
|
|
441
|
+
heroPan.setOffset({
|
|
442
|
+
x: heroAnimatedX.current,
|
|
443
|
+
y: heroAnimatedY.current
|
|
444
|
+
});
|
|
445
|
+
heroPan.setValue({
|
|
446
|
+
x: 0,
|
|
447
|
+
y: 0
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}, [pan, animatedX, heroPan, heroAnimatedX, enableHero]);
|
|
451
|
+
const animate = React.useCallback((panToAnimate, toValue, toIndex) => {
|
|
414
452
|
const handleAnimationEndToIndex = function () {
|
|
415
453
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
416
454
|
args[_key] = arguments[_key];
|
|
@@ -418,33 +456,33 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
418
456
|
return handleAnimationEnd(toIndex, ...args);
|
|
419
457
|
};
|
|
420
458
|
if (reduceMotionRef.current || isSwiping.current) {
|
|
421
|
-
Animated.timing(
|
|
459
|
+
Animated.timing(panToAnimate, {
|
|
422
460
|
toValue,
|
|
423
461
|
duration: 1,
|
|
424
462
|
useNativeDriver: false
|
|
425
463
|
}).start(handleAnimationEndToIndex);
|
|
426
464
|
} else if (isAutoPlayEnabled) {
|
|
427
|
-
Animated.timing(
|
|
465
|
+
Animated.timing(panToAnimate, {
|
|
428
466
|
...springConfig,
|
|
429
467
|
toValue,
|
|
430
468
|
useNativeDriver: false,
|
|
431
469
|
duration: transitionDuration * 1000
|
|
432
470
|
}).start(handleAnimationEndToIndex);
|
|
433
471
|
} else if (enablePeeking || enableDisplayMultipleItemsPerSlide) {
|
|
434
|
-
Animated.timing(
|
|
472
|
+
Animated.timing(panToAnimate, {
|
|
435
473
|
...springConfig,
|
|
436
474
|
toValue,
|
|
437
475
|
useNativeDriver: false,
|
|
438
476
|
duration: transitionDuration ? transitionDuration * 1000 : 1000
|
|
439
477
|
}).start(handleAnimationEndToIndex);
|
|
440
478
|
} else {
|
|
441
|
-
Animated.spring(
|
|
479
|
+
Animated.spring(panToAnimate, {
|
|
442
480
|
...springConfig,
|
|
443
481
|
toValue,
|
|
444
482
|
useNativeDriver: false
|
|
445
483
|
}).start(handleAnimationEndToIndex);
|
|
446
484
|
}
|
|
447
|
-
}, [
|
|
485
|
+
}, [springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled, enablePeeking, enableDisplayMultipleItemsPerSlide]);
|
|
448
486
|
const stopAutoplay = React.useCallback(() => {
|
|
449
487
|
if (autoPlayRef?.current) {
|
|
450
488
|
clearTimeout(autoPlayRef?.current);
|
|
@@ -476,14 +514,25 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
476
514
|
}
|
|
477
515
|
const index = activeIndexRef.current + calcDelta;
|
|
478
516
|
if (skipChanges) {
|
|
479
|
-
animate(toValue, index);
|
|
517
|
+
animate(pan, toValue, index);
|
|
518
|
+
if (enableHero) {
|
|
519
|
+
animate(heroPan, toValue, index);
|
|
520
|
+
}
|
|
480
521
|
return calcDelta;
|
|
481
522
|
}
|
|
482
523
|
stopAutoplay();
|
|
483
524
|
setActiveIndex(index);
|
|
484
525
|
const finalWidth = calculateFinalWidth(containerLayoutRef.current.width, enablePeeking, viewport, activeIndexRef, totalItems, calcDelta);
|
|
485
526
|
toValue.x = finalWidth * -1 * calcDelta;
|
|
486
|
-
|
|
527
|
+
const heroToValue = {
|
|
528
|
+
x: 0,
|
|
529
|
+
y: 0
|
|
530
|
+
};
|
|
531
|
+
heroToValue.x = heroContainerLayoutRef.current.width * -1 * calcDelta;
|
|
532
|
+
animate(pan, toValue, index);
|
|
533
|
+
if (enableHero) {
|
|
534
|
+
animate(heroPan, heroToValue, index);
|
|
535
|
+
}
|
|
487
536
|
if (isCarouselPlaying) {
|
|
488
537
|
stopAutoplay();
|
|
489
538
|
if (index === 0 && activeIndexRef.current + 1 === totalItems && transitionMode === TRANSITION_MODES.AUTOMATIC) {
|
|
@@ -499,7 +548,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
499
548
|
}
|
|
500
549
|
if (onIndexChanged) onIndexChanged(calcDelta, index);
|
|
501
550
|
return calcDelta;
|
|
502
|
-
}, [handleAnimationStart, triggerRefocus, slideDuration, updateOffset, animate, totalItems, onIndexChanged, isCarouselPlaying, stopAutoplay, isAutoPlayEnabled, viewport, enablePeeking]);
|
|
551
|
+
}, [handleAnimationStart, triggerRefocus, slideDuration, updateOffset, animate, totalItems, onIndexChanged, isCarouselPlaying, stopAutoplay, isAutoPlayEnabled, viewport, enablePeeking, pan, heroPan, enableHero]);
|
|
503
552
|
const startAutoplay = React.useCallback(() => {
|
|
504
553
|
stopAutoplay();
|
|
505
554
|
if (isAutoPlayEnabled) {
|
|
@@ -522,7 +571,6 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
522
571
|
let transitionMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TRANSITION_MODES.MANUAL;
|
|
523
572
|
fixOffsetAndGo(toPrev ? -1 : 1, transitionMode);
|
|
524
573
|
}, [fixOffsetAndGo]);
|
|
525
|
-
const [tabsPanelHeight, setTabsPanelHeight] = React.useState(0);
|
|
526
574
|
React.useEffect(() => {
|
|
527
575
|
activeIndexRef.current = activeIndex;
|
|
528
576
|
}, [activeIndex]);
|
|
@@ -532,6 +580,9 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
532
580
|
React.useEffect(() => {
|
|
533
581
|
containerLayoutRef.current = containerLayout;
|
|
534
582
|
}, [containerLayout]);
|
|
583
|
+
React.useEffect(() => {
|
|
584
|
+
heroContainerLayoutRef.current = heroContainerLayout;
|
|
585
|
+
}, [heroContainerLayout]);
|
|
535
586
|
React.useEffect(() => {
|
|
536
587
|
pan.x.addListener(_ref4 => {
|
|
537
588
|
let {
|
|
@@ -545,6 +596,20 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
545
596
|
} = _ref5;
|
|
546
597
|
animatedY.current = value;
|
|
547
598
|
});
|
|
599
|
+
if (enableHero) {
|
|
600
|
+
heroPan.x.addListener(_ref6 => {
|
|
601
|
+
let {
|
|
602
|
+
value
|
|
603
|
+
} = _ref6;
|
|
604
|
+
heroAnimatedX.current = value;
|
|
605
|
+
});
|
|
606
|
+
heroPan.y.addListener(_ref7 => {
|
|
607
|
+
let {
|
|
608
|
+
value
|
|
609
|
+
} = _ref7;
|
|
610
|
+
heroAnimatedY.current = value;
|
|
611
|
+
});
|
|
612
|
+
}
|
|
548
613
|
if (isCarouselPlaying) {
|
|
549
614
|
startAutoplay();
|
|
550
615
|
}
|
|
@@ -552,8 +617,12 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
552
617
|
stopAutoplay();
|
|
553
618
|
pan.x.removeAllListeners();
|
|
554
619
|
pan.y.removeAllListeners();
|
|
620
|
+
if (enableHero) {
|
|
621
|
+
heroPan.x.removeAllListeners();
|
|
622
|
+
heroPan.y.removeAllListeners();
|
|
623
|
+
}
|
|
555
624
|
};
|
|
556
|
-
}, [pan.x, pan.y, startAutoplay, stopAutoplay, isCarouselPlaying]);
|
|
625
|
+
}, [pan.x, pan.y, heroPan.x, heroPan.y, startAutoplay, stopAutoplay, isCarouselPlaying, enableHero]);
|
|
557
626
|
React.useEffect(() => {
|
|
558
627
|
const subscription = Dimensions.addEventListener('change', () => {
|
|
559
628
|
updateOffset();
|
|
@@ -574,10 +643,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
574
643
|
stopAutoplay();
|
|
575
644
|
};
|
|
576
645
|
}, [stopAutoplay]);
|
|
577
|
-
const
|
|
578
|
-
setTabsPanelHeight(event.nativeEvent.layout.height);
|
|
579
|
-
};
|
|
580
|
-
const onContainerLayout = _ref6 => {
|
|
646
|
+
const onContainerLayout = _ref8 => {
|
|
581
647
|
let {
|
|
582
648
|
nativeEvent: {
|
|
583
649
|
layout: {
|
|
@@ -587,7 +653,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
587
653
|
height
|
|
588
654
|
}
|
|
589
655
|
}
|
|
590
|
-
} =
|
|
656
|
+
} = _ref8;
|
|
591
657
|
return setContainerLayout(prevState => ({
|
|
592
658
|
...prevState,
|
|
593
659
|
x,
|
|
@@ -596,14 +662,33 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
596
662
|
height
|
|
597
663
|
}));
|
|
598
664
|
};
|
|
599
|
-
const
|
|
665
|
+
const onHeroContainerLayout = _ref9 => {
|
|
666
|
+
let {
|
|
667
|
+
nativeEvent: {
|
|
668
|
+
layout: {
|
|
669
|
+
x,
|
|
670
|
+
y,
|
|
671
|
+
width,
|
|
672
|
+
height
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
} = _ref9;
|
|
676
|
+
return setHeroContainerLayout(prevState => ({
|
|
677
|
+
...prevState,
|
|
678
|
+
x,
|
|
679
|
+
y,
|
|
680
|
+
width,
|
|
681
|
+
height
|
|
682
|
+
}));
|
|
683
|
+
};
|
|
684
|
+
const onPreviousNextNavigationButtonLayout = _ref10 => {
|
|
600
685
|
let {
|
|
601
686
|
nativeEvent: {
|
|
602
687
|
layout: {
|
|
603
688
|
width
|
|
604
689
|
}
|
|
605
690
|
}
|
|
606
|
-
} =
|
|
691
|
+
} = _ref10;
|
|
607
692
|
return setPreviousNextNavigationButtonWidth(width);
|
|
608
693
|
};
|
|
609
694
|
const isSwipeAllowed = React.useCallback(() => {
|
|
@@ -644,7 +729,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
644
729
|
}
|
|
645
730
|
const correction = gesture.moveX - gesture.x0;
|
|
646
731
|
if (Math.abs(correction) < containerLayoutRef.current.width * minDistanceForAction) {
|
|
647
|
-
animate({
|
|
732
|
+
animate(pan, {
|
|
648
733
|
x: 0,
|
|
649
734
|
y: 0
|
|
650
735
|
}, 0);
|
|
@@ -654,7 +739,47 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
654
739
|
}
|
|
655
740
|
isSwiping.current = false;
|
|
656
741
|
}
|
|
657
|
-
}), [updateIndex, updateOffset, animate, isSwipeAllowed, minDistanceForAction, handleAnimationStart, minDistanceToCapture,
|
|
742
|
+
}), [pan, updateIndex, updateOffset, animate, isSwipeAllowed, minDistanceForAction, handleAnimationStart, minDistanceToCapture, startAutoplay, stopAutoplay, isCarouselPlaying]);
|
|
743
|
+
const heroPanResponder = React.useMemo(() => PanResponder.create({
|
|
744
|
+
onPanResponderTerminationRequest: () => false,
|
|
745
|
+
onMoveShouldSetResponderCapture: () => true,
|
|
746
|
+
onMoveShouldSetPanResponderCapture: (_, gestureState) => {
|
|
747
|
+
if (!isSwipeAllowed()) {
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
handleAnimationStart(activeIndexRef.current);
|
|
751
|
+
const allow = Math.abs(gestureState.dx) > minDistanceToCapture;
|
|
752
|
+
if (allow) {
|
|
753
|
+
isSwiping.current = true;
|
|
754
|
+
stopAutoplay();
|
|
755
|
+
}
|
|
756
|
+
return allow;
|
|
757
|
+
},
|
|
758
|
+
onPanResponderGrant: () => {
|
|
759
|
+
updateOffset();
|
|
760
|
+
},
|
|
761
|
+
onPanResponderMove: Animated.event([null, {
|
|
762
|
+
dx: heroPan.x
|
|
763
|
+
}], {
|
|
764
|
+
useNativeDriver: false
|
|
765
|
+
}),
|
|
766
|
+
onPanResponderRelease: (_, gesture) => {
|
|
767
|
+
if (isCarouselPlaying) {
|
|
768
|
+
startAutoplay();
|
|
769
|
+
}
|
|
770
|
+
const correction = gesture.moveX - gesture.x0;
|
|
771
|
+
if (Math.abs(correction) < containerLayoutRef.current.width * minDistanceForAction) {
|
|
772
|
+
animate(heroPan, {
|
|
773
|
+
x: 0,
|
|
774
|
+
y: 0
|
|
775
|
+
}, 0);
|
|
776
|
+
} else {
|
|
777
|
+
const delta = correction > 0 ? -1 : 1;
|
|
778
|
+
updateIndex(delta, TRANSITION_MODES.SWIPE);
|
|
779
|
+
}
|
|
780
|
+
isSwiping.current = false;
|
|
781
|
+
}
|
|
782
|
+
}), [heroPan, updateIndex, updateOffset, animate, isSwipeAllowed, minDistanceForAction, handleAnimationStart, minDistanceToCapture, startAutoplay, stopAutoplay, isCarouselPlaying]);
|
|
658
783
|
const goToNext = React.useCallback(() => {
|
|
659
784
|
goToNeighboring();
|
|
660
785
|
}, [goToNeighboring]);
|
|
@@ -725,9 +850,9 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
725
850
|
}
|
|
726
851
|
setisCarouselPlaying(prevState => !prevState);
|
|
727
852
|
}, [isCarouselPlaying, stopAutoplay, startAutoplay]);
|
|
728
|
-
return /*#__PURE__*/
|
|
853
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
729
854
|
style: selectRootContainerStyles(enableHero, viewport),
|
|
730
|
-
children: /*#__PURE__*/_jsx(View, {
|
|
855
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
731
856
|
style: selectMainContainerStyles(enableHero, viewport),
|
|
732
857
|
children: /*#__PURE__*/_jsxs(CarouselProvider, {
|
|
733
858
|
activeIndex: activeIndex,
|
|
@@ -756,9 +881,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
756
881
|
positionProperty: getDynamicPositionProperty(),
|
|
757
882
|
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
|
|
758
883
|
enablePeeking,
|
|
759
|
-
enableDisplayMultipleItemsPerSlide
|
|
760
|
-
enableHero,
|
|
761
|
-
viewport
|
|
884
|
+
enableDisplayMultipleItemsPerSlide
|
|
762
885
|
})],
|
|
763
886
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
764
887
|
icon: isCarouselPlaying ? pauseIcon : playIcon,
|
|
@@ -767,7 +890,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
767
890
|
onPress: onAnimationControlButtonPress
|
|
768
891
|
})
|
|
769
892
|
}) : null, showPreviousNextNavigation && totalItems > 1 ? /*#__PURE__*/_jsx(View, {
|
|
770
|
-
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true, enablePeeking, enableDisplayMultipleItemsPerSlide
|
|
893
|
+
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true, enablePeeking, enableDisplayMultipleItemsPerSlide),
|
|
771
894
|
testID: "previous-button-container",
|
|
772
895
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
773
896
|
onLayout: onPreviousNextNavigationButtonLayout,
|
|
@@ -811,9 +934,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
811
934
|
peekingProps: getPeekingProps(viewport),
|
|
812
935
|
enableDisplayMultipleItemsPerSlide,
|
|
813
936
|
viewport,
|
|
814
|
-
backgroundColor: element.props.backgroundColor
|
|
815
|
-
enableHero,
|
|
816
|
-
tabsPanelHeight
|
|
937
|
+
backgroundColor: element.props.backgroundColor
|
|
817
938
|
});
|
|
818
939
|
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
819
940
|
children: clonedElement
|
|
@@ -821,7 +942,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
821
942
|
})
|
|
822
943
|
})
|
|
823
944
|
}), showPreviousNextNavigation && totalItems > 1 ? /*#__PURE__*/_jsx(View, {
|
|
824
|
-
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false, enablePeeking, enableDisplayMultipleItemsPerSlide
|
|
945
|
+
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false, enablePeeking, enableDisplayMultipleItemsPerSlide),
|
|
825
946
|
testID: "next-button-container",
|
|
826
947
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
827
948
|
onLayout: onPreviousNextNavigationButtonLayout,
|
|
@@ -833,12 +954,38 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
833
954
|
})
|
|
834
955
|
}) : null]
|
|
835
956
|
}), /*#__PURE__*/_jsx(View, {
|
|
836
|
-
style: selectNavigationStyles(tabs,
|
|
837
|
-
onLayout: tabs && onTabsPanelLayout,
|
|
957
|
+
style: selectNavigationStyles(tabs, enableHero, viewport),
|
|
838
958
|
children: showPanelNavigation ? activePanelNavigation : null
|
|
839
959
|
})]
|
|
840
960
|
})
|
|
841
|
-
})
|
|
961
|
+
}), enableHero && /*#__PURE__*/_jsx(View, {
|
|
962
|
+
style: staticStyles.heroMainContainer,
|
|
963
|
+
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
964
|
+
style: StyleSheet.flatten([staticStyles.heroSwipeArea, {
|
|
965
|
+
transform: [{
|
|
966
|
+
translateX: heroPan.x
|
|
967
|
+
}, {
|
|
968
|
+
translateY: heroPan.y
|
|
969
|
+
}]
|
|
970
|
+
}]),
|
|
971
|
+
onLayout: onHeroContainerLayout,
|
|
972
|
+
...heroPanResponder.panHandlers,
|
|
973
|
+
...getA11yPropsFromHtmlTag(tag),
|
|
974
|
+
accessibilityLiveRegion: accessibilityLiveRegion,
|
|
975
|
+
children: childrenArray.map((element, index) => {
|
|
976
|
+
const hidden = !isAnimating && index !== activeIndex;
|
|
977
|
+
return /*#__PURE__*/_jsx(View, {
|
|
978
|
+
style: selectHeroContainerStyles(heroContainerLayout.width, hidden),
|
|
979
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
980
|
+
flex: 1,
|
|
981
|
+
variant: {
|
|
982
|
+
background: element.props.backgroundColor
|
|
983
|
+
}
|
|
984
|
+
})
|
|
985
|
+
}, index.toFixed(2));
|
|
986
|
+
})
|
|
987
|
+
})
|
|
988
|
+
})]
|
|
842
989
|
});
|
|
843
990
|
});
|
|
844
991
|
Carousel.propTypes = {
|
|
@@ -849,6 +996,10 @@ Carousel.propTypes = {
|
|
|
849
996
|
* Prop related to StepTracker Variants
|
|
850
997
|
*/
|
|
851
998
|
stepTrackerVariant: variantProp.propType,
|
|
999
|
+
/**
|
|
1000
|
+
* Prop related to ProgressBar Variants
|
|
1001
|
+
*/
|
|
1002
|
+
progressBarVariant: variantProp.propType,
|
|
852
1003
|
/**
|
|
853
1004
|
* Slides to render in Carousel. Wrap individual slides in `Carousel.Item`
|
|
854
1005
|
*/
|
|
@@ -5,8 +5,7 @@ import Platform from "react-native-web/dist/exports/Platform";
|
|
|
5
5
|
import { layoutTags, getA11yPropsFromHtmlTag, selectSystemProps, a11yProps, viewProps, variantProp } from '../../utils';
|
|
6
6
|
import { useCarousel } from '../CarouselContext';
|
|
7
7
|
import { ITEMS_PER_VIEWPORT_MD, ITEMS_PER_VIEWPORT_LG_XL, GAP_BETWEEN_ITEMS } from '../Constants';
|
|
8
|
-
import
|
|
9
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
9
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
11
10
|
const selectContainerStyle = _ref => {
|
|
12
11
|
let {
|
|
@@ -86,8 +85,6 @@ const CarouselItem = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
86
85
|
enableDisplayMultipleItemsPerSlide,
|
|
87
86
|
viewport,
|
|
88
87
|
backgroundColor,
|
|
89
|
-
enableHero,
|
|
90
|
-
tabsPanelHeight,
|
|
91
88
|
...rest
|
|
92
89
|
} = _ref2;
|
|
93
90
|
const {
|
|
@@ -112,18 +109,7 @@ const CarouselItem = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
112
109
|
...selectedProps,
|
|
113
110
|
...focusabilityProps,
|
|
114
111
|
ref: ref,
|
|
115
|
-
children:
|
|
116
|
-
variant: {
|
|
117
|
-
background: backgroundColor
|
|
118
|
-
},
|
|
119
|
-
space: 0,
|
|
120
|
-
flex: 1,
|
|
121
|
-
children: [children, enableHero && /*#__PURE__*/_jsx(View, {
|
|
122
|
-
style: {
|
|
123
|
-
height: tabsPanelHeight
|
|
124
|
-
}
|
|
125
|
-
})]
|
|
126
|
-
})
|
|
112
|
+
children: children
|
|
127
113
|
});
|
|
128
114
|
});
|
|
129
115
|
CarouselItem.propTypes = {
|
|
@@ -11,7 +11,8 @@ import { variantProp } from '../../utils';
|
|
|
11
11
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
const CarouselStepTracker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
13
13
|
let {
|
|
14
|
-
|
|
14
|
+
stepTrackerVariant,
|
|
15
|
+
progressBarVariant,
|
|
15
16
|
enableDisplayMultipleItemsPerSlide
|
|
16
17
|
} = _ref;
|
|
17
18
|
const {
|
|
@@ -55,9 +56,7 @@ const CarouselStepTracker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
55
56
|
items: totalItems,
|
|
56
57
|
current: activeIndex + 1
|
|
57
58
|
},
|
|
58
|
-
variant:
|
|
59
|
-
style: 'subtle'
|
|
60
|
-
},
|
|
59
|
+
variant: progressBarVariant,
|
|
61
60
|
accessibilityLabel: getCopyWithPlaceholders('stepTrackerLabel')
|
|
62
61
|
})
|
|
63
62
|
})
|
|
@@ -77,13 +76,14 @@ const CarouselStepTracker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
77
76
|
stepTrackerLabel: getCopyWithPlaceholders('stepTrackerLabel')
|
|
78
77
|
},
|
|
79
78
|
tokens: stepTrackerTokens,
|
|
80
|
-
variant:
|
|
79
|
+
variant: stepTrackerVariant
|
|
81
80
|
})
|
|
82
81
|
});
|
|
83
82
|
});
|
|
84
83
|
CarouselStepTracker.displayName = 'CarouselStepTracker';
|
|
85
84
|
CarouselStepTracker.propTypes = {
|
|
86
|
-
|
|
85
|
+
stepTrackerVariant: variantProp.propType,
|
|
86
|
+
progressBarVariant: variantProp.propType,
|
|
87
87
|
enableDisplayMultipleItemsPerSlide: PropTypes.bool
|
|
88
88
|
};
|
|
89
89
|
const staticStyles = StyleSheet.create({
|
|
@@ -41,7 +41,9 @@ function selectContainerStyles(_ref) {
|
|
|
41
41
|
borderBottomRightRadius,
|
|
42
42
|
borderTopLeftRadius,
|
|
43
43
|
borderBottomLeftRadius,
|
|
44
|
-
...verticalAlignRow(verticalAlign, iconPosition === 'right')
|
|
44
|
+
...verticalAlignRow(verticalAlign, iconPosition === 'right'),
|
|
45
|
+
// Updated default alignment due to the change in Pressable's behavior from div to button on web.
|
|
46
|
+
textAlign: Platform.OS === 'web' ? 'inherit' : undefined
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -34,7 +34,7 @@ const ExpandCollapseMini = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
34
34
|
// Remove unwanted look and feel from ExpandCollapse(background pressed, focus border and text underline)
|
|
35
35
|
icon: null,
|
|
36
36
|
borderColor: 'transparent',
|
|
37
|
-
textLine: 'none',
|
|
37
|
+
textLine: tokens.textLine ?? 'none',
|
|
38
38
|
backgroundColor: 'transparent'
|
|
39
39
|
}
|
|
40
40
|
// TODO refactor
|
|
@@ -44,10 +44,12 @@ const selectBulletPositioningStyles = _ref3 => {
|
|
|
44
44
|
const selectBulletContainerStyles = _ref4 => {
|
|
45
45
|
let {
|
|
46
46
|
itemBulletContainerWidth,
|
|
47
|
+
itemBulletContainerHeight,
|
|
47
48
|
itemBulletContainerAlign
|
|
48
49
|
} = _ref4;
|
|
49
50
|
return {
|
|
50
51
|
width: itemBulletContainerWidth,
|
|
52
|
+
height: itemBulletContainerHeight,
|
|
51
53
|
alignItems: itemBulletContainerAlign
|
|
52
54
|
};
|
|
53
55
|
};
|
|
@@ -69,10 +71,11 @@ const ListItemMark = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
69
71
|
const IconComponent = icon || /*#__PURE__*/_jsx(_Fragment, {});
|
|
70
72
|
const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
|
|
71
73
|
const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
|
|
74
|
+
const bulletContainerStyles = selectBulletContainerStyles(themeTokens);
|
|
72
75
|
if (icon) {
|
|
73
76
|
const iconTokens = selectItemIconTokens(themeTokens);
|
|
74
77
|
return /*#__PURE__*/_jsx(View, {
|
|
75
|
-
style: sideItemContainerStyles,
|
|
78
|
+
style: [sideItemContainerStyles, bulletContainerStyles],
|
|
76
79
|
children: /*#__PURE__*/_jsx(IconComponent, {
|
|
77
80
|
size: iconSize || iconTokens.size,
|
|
78
81
|
color: iconColor || iconTokens.color
|
|
@@ -94,7 +97,8 @@ const ListItemMark = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
94
97
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
95
98
|
icon: bulletIcon,
|
|
96
99
|
tokens: {
|
|
97
|
-
color: bulletColor
|
|
100
|
+
color: bulletColor,
|
|
101
|
+
size: themeTokens.itemIconSize
|
|
98
102
|
}
|
|
99
103
|
})
|
|
100
104
|
})
|
|
@@ -128,7 +128,7 @@ const ModalContent = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
128
128
|
},
|
|
129
129
|
children: subHeading
|
|
130
130
|
})
|
|
131
|
-
}), Boolean(bodyText && hasHeadingSection) && /*#__PURE__*/_jsx(Spacer, {
|
|
131
|
+
}), Boolean((bodyText || children) && hasHeadingSection) && /*#__PURE__*/_jsx(Spacer, {
|
|
132
132
|
space: 3
|
|
133
133
|
})]
|
|
134
134
|
}), bodyText && /*#__PURE__*/_jsx(Box, {
|
|
@@ -286,9 +286,9 @@ const MultiSelectFilter = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
286
286
|
},
|
|
287
287
|
children: subtitle
|
|
288
288
|
})
|
|
289
|
-
}), /*#__PURE__*/_jsx(Spacer, {
|
|
290
|
-
space: 4
|
|
291
289
|
})]
|
|
290
|
+
}), /*#__PURE__*/_jsx(Spacer, {
|
|
291
|
+
space: 4
|
|
292
292
|
}), /*#__PURE__*/_jsx(View, {
|
|
293
293
|
style: styles.options,
|
|
294
294
|
children: /*#__PURE__*/_jsx(ScrollView, {
|