@telus-uds/components-base 3.26.0 → 3.27.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +19 -2
  2. package/lib/cjs/Card/Card.js +34 -13
  3. package/lib/cjs/Card/CardBase.js +78 -11
  4. package/lib/cjs/Card/PressableCardBase.js +147 -8
  5. package/lib/cjs/Carousel/Carousel.js +105 -50
  6. package/lib/cjs/Carousel/CarouselContext.js +10 -4
  7. package/lib/cjs/Carousel/CarouselItem/CarouselItem.js +11 -7
  8. package/lib/cjs/Carousel/Constants.js +11 -2
  9. package/lib/cjs/Checkbox/Checkbox.js +43 -13
  10. package/lib/cjs/List/List.js +24 -9
  11. package/lib/cjs/List/ListItem.js +18 -1
  12. package/lib/cjs/List/ListItemBase.js +27 -8
  13. package/lib/cjs/List/ListItemMark.js +33 -62
  14. package/lib/cjs/List/PressableListItemBase.js +1 -0
  15. package/lib/esm/Card/Card.js +34 -13
  16. package/lib/esm/Card/CardBase.js +78 -11
  17. package/lib/esm/Card/PressableCardBase.js +148 -9
  18. package/lib/esm/Carousel/Carousel.js +106 -51
  19. package/lib/esm/Carousel/CarouselContext.js +10 -4
  20. package/lib/esm/Carousel/CarouselItem/CarouselItem.js +11 -7
  21. package/lib/esm/Carousel/Constants.js +10 -1
  22. package/lib/esm/Checkbox/Checkbox.js +43 -13
  23. package/lib/esm/List/List.js +24 -9
  24. package/lib/esm/List/ListItem.js +19 -2
  25. package/lib/esm/List/ListItemBase.js +27 -8
  26. package/lib/esm/List/ListItemMark.js +33 -62
  27. package/lib/esm/List/PressableListItemBase.js +1 -0
  28. package/lib/package.json +2 -2
  29. package/package.json +2 -2
  30. package/src/Card/Card.jsx +29 -7
  31. package/src/Card/CardBase.jsx +88 -8
  32. package/src/Card/PressableCardBase.jsx +135 -9
  33. package/src/Carousel/Carousel.jsx +119 -64
  34. package/src/Carousel/CarouselContext.jsx +12 -4
  35. package/src/Carousel/CarouselItem/CarouselItem.jsx +10 -6
  36. package/src/Carousel/Constants.js +10 -0
  37. package/src/Checkbox/Checkbox.jsx +29 -7
  38. package/src/List/List.jsx +33 -9
  39. package/src/List/ListItem.jsx +33 -11
  40. package/src/List/ListItemBase.jsx +33 -9
  41. package/src/List/ListItemMark.jsx +32 -53
  42. package/src/List/PressableListItemBase.jsx +1 -0
@@ -79,7 +79,7 @@ const selectHeroContainerStyles = (width, hidden) => ({
79
79
  width,
80
80
  visibility: hidden ? 'hidden' : 'visible'
81
81
  });
82
- const getDynamicPositionProperty = areStylesAppliedOnPreviousButton => areStylesAppliedOnPreviousButton ? 'left' : 'right';
82
+ const getDynamicPositionProperty = areStylesAppliedOnPreviousButton => areStylesAppliedOnPreviousButton ? _Constants.POSITION_PROPERTIES.LEFT : _Constants.POSITION_PROPERTIES.RIGHT;
83
83
  const selectControlButtonPositionStyles = _ref => {
84
84
  let {
85
85
  positionVariant,
@@ -89,23 +89,36 @@ const selectControlButtonPositionStyles = _ref => {
89
89
  enablePeeking,
90
90
  enableDisplayMultipleItemsPerSlide,
91
91
  isAutoPlayEnabled,
92
- viewport
92
+ viewport,
93
+ maxWidth,
94
+ viewportWidth
93
95
  } = _ref;
94
96
  const styles = {};
95
- if (positionVariant === 'edge') {
96
- styles[positionProperty] = -1 * (buttonWidth / 2);
97
- } else if (positionVariant === 'inside') {
98
- styles[positionProperty] = _Constants.DEFAULT_POSITION_OFFSET;
99
- } else if (positionVariant === 'outside') {
97
+ let positionOffset = 0;
98
+ if (positionVariant === _Constants.POSITION_VARIANTS.EDGE) {
99
+ positionOffset = -1 * (buttonWidth / 2);
100
+ } else if (positionVariant === _Constants.POSITION_VARIANTS.INSIDE) {
101
+ positionOffset = _Constants.DEFAULT_POSITION_OFFSET;
102
+ } else if (positionVariant === _Constants.POSITION_VARIANTS.OUTSIDE) {
100
103
  if (enablePeeking || enableDisplayMultipleItemsPerSlide || isAutoPlayEnabled && viewport === 'xs') {
101
- styles[positionProperty] = 0;
104
+ positionOffset = 0;
102
105
  } else {
103
- styles[positionProperty] = -1 * (spaceBetweenSlideAndButton + buttonWidth);
106
+ positionOffset = -1 * (spaceBetweenSlideAndButton + buttonWidth);
107
+ }
108
+ }
109
+ if (enablePeeking) {
110
+ if (positionProperty === _Constants.POSITION_PROPERTIES.RIGHT) {
111
+ const rightMargin = (viewportWidth - maxWidth) / 2;
112
+ positionOffset += rightMargin;
113
+ } else if (positionProperty === _Constants.POSITION_PROPERTIES.LEFT) {
114
+ const leftMargin = (viewportWidth - maxWidth) / 2;
115
+ positionOffset += leftMargin;
104
116
  }
105
117
  }
118
+ styles[positionProperty] = positionOffset;
106
119
  return styles;
107
120
  };
108
- const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, areStylesAppliedOnPreviousButton, enablePeeking, enableDisplayMultipleItemsPerSlide, isAutoPlayEnabled, viewport) => {
121
+ const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, areStylesAppliedOnPreviousButton, enablePeeking, enableDisplayMultipleItemsPerSlide, isAutoPlayEnabled, viewport, maxWidth, viewportWidth) => {
109
122
  const styles = {
110
123
  zIndex: 1,
111
124
  position: 'absolute'
@@ -127,7 +140,9 @@ const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWi
127
140
  enablePeeking,
128
141
  enableDisplayMultipleItemsPerSlide,
129
142
  isAutoPlayEnabled,
130
- viewport
143
+ viewport,
144
+ maxWidth,
145
+ viewportWidth
131
146
  })
132
147
  };
133
148
  };
@@ -193,7 +208,7 @@ const getMaximumItemsForSlide = (enableDisplayMultipleItemsPerSlide, viewport) =
193
208
  }
194
209
  return _Constants.ITEMS_PER_VIEWPORT_XS_SM;
195
210
  };
196
- const selectRootContainerStyles = (enableHero, viewport) => {
211
+ const selectRootContainerStyles = (enableHero, viewport, enablePeeking) => {
197
212
  if (enableHero && viewport === 'xl' && _Platform.default.OS === 'web') {
198
213
  return {
199
214
  alignItems: 'center'
@@ -204,15 +219,25 @@ const selectRootContainerStyles = (enableHero, viewport) => {
204
219
  paddingHorizontal: 16
205
220
  };
206
221
  }
222
+ if (enablePeeking) {
223
+ return {
224
+ width: '100%'
225
+ };
226
+ }
207
227
  return {};
208
228
  };
209
- const selectMainContainerStyles = (enableHero, viewport, maxWidth) => {
210
- if (enableHero && viewport === 'xl' && _Platform.default.OS === 'web') {
229
+ const selectMainContainerStyles = (enableHero, viewport, maxWidth, enablePeeking) => {
230
+ if (enableHero && viewport === 'xl' && _Platform.default.OS === 'web' && !enablePeeking) {
211
231
  return {
212
232
  width: '100%',
213
233
  maxWidth: maxWidth || 1200
214
234
  };
215
235
  }
236
+ if (enablePeeking) {
237
+ return {
238
+ width: '100%'
239
+ };
240
+ }
216
241
  if (maxWidth !== null && maxWidth !== undefined) {
217
242
  return {
218
243
  maxWidth,
@@ -222,14 +247,20 @@ const selectMainContainerStyles = (enableHero, viewport, maxWidth) => {
222
247
  }
223
248
  return {};
224
249
  };
225
- const selectNavigationStyles = (tabs, enableHero, viewport) => {
250
+ const selectNavigationStyles = (tabs, enableHero, viewport, enablePeeking, maxWidth) => {
226
251
  let marginHorizontal = 0;
227
252
  if (enableHero && tabs) {
228
253
  marginHorizontal = viewport === 'xl' ? _Constants.LARGE_VIEWPORT_MARGIN : _Constants.DEFAULT_VIEWPORT_MARGIN;
229
254
  }
230
- return {
255
+ const styles = {
231
256
  marginHorizontal
232
257
  };
258
+ if (enablePeeking && maxWidth) {
259
+ styles.maxWidth = maxWidth;
260
+ styles.alignSelf = 'center';
261
+ styles.width = '100%';
262
+ }
263
+ return styles;
233
264
  };
234
265
 
235
266
  /**
@@ -238,23 +269,18 @@ const selectNavigationStyles = (tabs, enableHero, viewport) => {
238
269
  * @param {number} containerWidth - The width of the carousel container.
239
270
  * @param {boolean} enablePeeking - Flag indicating whether peeking is enabled.
240
271
  * @param {Object} viewport - The viewport configuration object used to determine peeking properties.
241
- * @param {React.MutableRefObject<number>} activeIndexRef - A ref object holding the current active index of the carousel.
272
+ * @param {number} maxWidth - The maximum width constraint for the carousel content.
242
273
  * @returns {number} The calculated final width of the carousel container.
243
274
  */
244
- const calculateFinalWidth = (containerWidth, enablePeeking, viewport, activeIndexRef) => {
275
+ const calculateFinalWidth = (containerWidth, enablePeeking, viewport, maxWidth) => {
245
276
  let finalWidth = containerWidth;
246
277
  if (enablePeeking) {
247
278
  const {
248
279
  peekingGap,
249
- peekingMiddleSpace,
250
- peekingMarginLeft
280
+ peekingMiddleSpace
251
281
  } = getPeekingProps(viewport);
252
- const slideWide = containerWidth - (peekingMiddleSpace * _Constants.PEEKING_MULTIPLIER + peekingGap * _Constants.PEEKING_MULTIPLIER);
253
- if (activeIndexRef.current === 0) {
254
- finalWidth = slideWide + peekingMarginLeft - peekingMiddleSpace;
255
- } else {
256
- finalWidth = slideWide + peekingGap;
257
- }
282
+ const baseWidth = maxWidth || containerWidth;
283
+ finalWidth = baseWidth - peekingMiddleSpace * _Constants.PEEKING_MULTIPLIER + peekingGap;
258
284
  }
259
285
  return finalWidth;
260
286
  };
@@ -377,7 +403,10 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
377
403
  } = (0, _ThemeProvider.useTheme)();
378
404
  const contentMaxWidthValue = (0, _utils.useResponsiveProp)(contentMaxWidth);
379
405
  const responsiveWidth = (0, _utils.useResponsiveProp)(themeOptions?.contentMaxWidth);
380
- const maxWidth = (0, _utils.resolveContentMaxWidth)(contentMaxWidthValue, responsiveWidth);
406
+ let maxWidth = null;
407
+ if (enablePeeking || contentMaxWidth !== undefined) {
408
+ maxWidth = contentMaxWidthValue === undefined ? responsiveWidth : (0, _utils.resolveContentMaxWidth)(contentMaxWidthValue, responsiveWidth);
409
+ }
381
410
  const totalItems = getTotalItems(enableDisplayMultipleItemsPerSlide, childrenArray, viewport);
382
411
  const autoPlayFeatureEnabled = autoPlay && slideDuration > 0 && transitionDuration > 0 && totalItems > 1;
383
412
  // if `Carousel` only has one `Carousel.Item`, convert this to a single-item array
@@ -440,8 +469,16 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
440
469
  const [isCarouselPlaying, setisCarouselPlaying] = _react.default.useState(autoPlayFeatureEnabled);
441
470
  const isSwiping = _react.default.useRef(false);
442
471
  const autoPlayRef = _react.default.useRef(null);
472
+ const [rootContainerLayout, setRootContainerLayout] = _react.default.useState({
473
+ x: 0,
474
+ y: 0,
475
+ width: 0,
476
+ height: 0
477
+ });
478
+ const rootContainerLayoutRef = _react.default.useRef(rootContainerLayout);
443
479
  const isFirstSlide = !activeIndex;
444
480
  const isLastSlide = activeIndex + 1 >= totalItems;
481
+ const currentViewportWidth = rootContainerLayout.width;
445
482
  const handleAnimationStart = _react.default.useCallback(function () {
446
483
  if (typeof onAnimationStart === 'function') onAnimationStart(...arguments);
447
484
  setIsAnimating(true);
@@ -459,15 +496,15 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
459
496
  if (enablePeeking) {
460
497
  const {
461
498
  peekingGap,
462
- peekingMiddleSpace,
463
- peekingMarginLeft
499
+ peekingMiddleSpace
464
500
  } = getPeekingProps(viewport);
465
501
  let finalWidth;
466
- const slideWide = containerLayoutRef.current.width - (peekingMiddleSpace * _Constants.PEEKING_MULTIPLIER + peekingGap * _Constants.PEEKING_MULTIPLIER);
502
+ const baseWidth = maxWidth || containerLayoutRef.current.width;
503
+ const slideWide = baseWidth - peekingMiddleSpace * _Constants.PEEKING_MULTIPLIER;
467
504
  if (activeIndexRef.current === 0) {
468
505
  finalWidth = 0;
469
506
  } else {
470
- finalWidth = slideWide + peekingMarginLeft - peekingMiddleSpace + (slideWide + peekingGap) * (activeIndexRef.current - _Constants.ACTIVE_INDEX_OFFSET_MULTIPLIER);
507
+ finalWidth = (slideWide + peekingGap) * activeIndexRef.current;
471
508
  }
472
509
  animatedX.current = finalWidth * _Constants.NEGATIVE_MULTIPLIER;
473
510
  } else {
@@ -494,7 +531,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
494
531
  y: 0
495
532
  });
496
533
  }
497
- }, [pan, animatedX, heroPan, heroAnimatedX, enableHero, viewport, enablePeeking]);
534
+ }, [pan, animatedX, heroPan, heroAnimatedX, enableHero, viewport, enablePeeking, maxWidth]);
498
535
  const animate = _react.default.useCallback(function (panToAnimate, toValue, toIndex) {
499
536
  let isSwipeRelease = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
500
537
  const applicableTransitionDuration = isLastSlide && toIndex === 0 ? loopDuration : transitionDuration;
@@ -586,7 +623,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
586
623
  }
587
624
  stopAutoplay();
588
625
  setActiveIndex(index);
589
- const finalWidth = calculateFinalWidth(containerLayoutRef.current.width, enablePeeking, viewport, activeIndexRef);
626
+ const finalWidth = calculateFinalWidth(containerLayoutRef.current.width, enablePeeking, viewport, maxWidth);
590
627
  toValue.x = finalWidth * -1 * calcDelta;
591
628
  const heroToValue = {
592
629
  x: 0,
@@ -613,7 +650,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
613
650
  }
614
651
  if (onIndexChanged) onIndexChanged(calcDelta, index);
615
652
  return calcDelta;
616
- }, [handleAnimationStart, triggerRefocus, slideDuration, updateOffset, animate, totalItems, onIndexChanged, isCarouselPlaying, stopAutoplay, isAutoPlayEnabled, viewport, enablePeeking, pan, heroPan, enableHero]);
653
+ }, [handleAnimationStart, triggerRefocus, slideDuration, updateOffset, animate, totalItems, onIndexChanged, isCarouselPlaying, stopAutoplay, isAutoPlayEnabled, viewport, enablePeeking, pan, heroPan, enableHero, maxWidth]);
617
654
  const startAutoplay = _react.default.useCallback(() => {
618
655
  stopAutoplay();
619
656
  if (isAutoPlayEnabled) {
@@ -648,6 +685,9 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
648
685
  _react.default.useEffect(() => {
649
686
  heroContainerLayoutRef.current = heroContainerLayout;
650
687
  }, [heroContainerLayout]);
688
+ _react.default.useEffect(() => {
689
+ rootContainerLayoutRef.current = rootContainerLayout;
690
+ }, [rootContainerLayout]);
651
691
  _react.default.useEffect(() => {
652
692
  pan.x.addListener(_ref5 => {
653
693
  let {
@@ -756,6 +796,25 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
756
796
  } = _ref11;
757
797
  return setPreviousNextNavigationButtonWidth(width);
758
798
  };
799
+ const onRootContainerLayout = _ref12 => {
800
+ let {
801
+ nativeEvent: {
802
+ layout: {
803
+ x,
804
+ y,
805
+ width,
806
+ height
807
+ }
808
+ }
809
+ } = _ref12;
810
+ return setRootContainerLayout(prevState => ({
811
+ ...prevState,
812
+ x,
813
+ y,
814
+ width,
815
+ height
816
+ }));
817
+ };
759
818
  const isSwipeAllowed = _react.default.useCallback(() => {
760
819
  if (totalItems === 1) {
761
820
  return false;
@@ -921,9 +980,10 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
921
980
  }
922
981
  }, [isTransitioningRef]);
923
982
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
924
- style: selectRootContainerStyles(enableHero, viewport),
983
+ style: selectRootContainerStyles(enableHero, viewport, enablePeeking),
984
+ onLayout: onRootContainerLayout,
925
985
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
926
- style: selectMainContainerStyles(enableHero, viewport, maxWidth),
986
+ style: selectMainContainerStyles(enableHero, viewport, maxWidth, enablePeeking),
927
987
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CarouselContext.CarouselProvider, {
928
988
  activeIndex: activeIndex,
929
989
  goTo: goTo,
@@ -935,6 +995,8 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
935
995
  refocus: refocus,
936
996
  width: containerLayout.width,
937
997
  maximumItemsForSlide: getMaximumItemsForSlide(enableDisplayMultipleItemsPerSlide, viewport),
998
+ maxWidth: maxWidth,
999
+ viewportWidth: currentViewportWidth,
938
1000
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
939
1001
  style: [staticStyles.root, {
940
1002
  ...(_Platform.default.OS === 'web' ? {
@@ -957,7 +1019,9 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
957
1019
  enablePeeking,
958
1020
  enableDisplayMultipleItemsPerSlide,
959
1021
  isAutoPlayEnabled,
960
- viewport
1022
+ viewport,
1023
+ maxWidth,
1024
+ viewportWidth: currentViewportWidth
961
1025
  })],
962
1026
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
963
1027
  icon: isCarouselPlaying ? pauseIcon : playIcon,
@@ -966,7 +1030,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
966
1030
  onPress: onAnimationControlButtonPress
967
1031
  })
968
1032
  }) : null, showPreviousNextNavigation && totalItems > 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
969
- style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true, enablePeeking, enableDisplayMultipleItemsPerSlide, isAutoPlayEnabled, viewport),
1033
+ style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true, enablePeeking, enableDisplayMultipleItemsPerSlide, isAutoPlayEnabled, viewport, maxWidth, currentViewportWidth),
970
1034
  testID: "previous-button-container",
971
1035
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
972
1036
  onLayout: onPreviousNextNavigationButtonLayout,
@@ -1004,16 +1068,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
1004
1068
  children: childrenArray.map((element, index) => {
1005
1069
  let hidden = !isAnimating && index !== activeIndex;
1006
1070
  if (enablePeeking && !isAnimating) {
1007
- if (enableDisplayMultipleItemsPerSlide) {
1008
- const maxItemsForSlide = getMaximumItemsForSlide(enableDisplayMultipleItemsPerSlide, viewport);
1009
- if (index >= activeIndex * maxItemsForSlide - 1 && index < activeIndex * maxItemsForSlide + maxItemsForSlide + 1) {
1010
- hidden = false;
1011
- } else {
1012
- hidden = true;
1013
- }
1014
- } else if (index >= activeIndex - 1 && index <= activeIndex + 1) {
1015
- hidden = false;
1016
- }
1071
+ hidden = false;
1017
1072
  } else if (!enablePeeking && enableDisplayMultipleItemsPerSlide && !isAnimating) {
1018
1073
  const maxItemsForSlide = getMaximumItemsForSlide(enableDisplayMultipleItemsPerSlide, viewport);
1019
1074
  if (index >= activeIndex * maxItemsForSlide && index < activeIndex * maxItemsForSlide + maxItemsForSlide) {
@@ -1035,7 +1090,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
1035
1090
  })
1036
1091
  })
1037
1092
  }), showPreviousNextNavigation && totalItems > 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
1038
- style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false, enablePeeking, enableDisplayMultipleItemsPerSlide, isAutoPlayEnabled, viewport),
1093
+ style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false, enablePeeking, enableDisplayMultipleItemsPerSlide, isAutoPlayEnabled, viewport, maxWidth, currentViewportWidth),
1039
1094
  testID: "next-button-container",
1040
1095
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
1041
1096
  onLayout: onPreviousNextNavigationButtonLayout,
@@ -1047,7 +1102,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
1047
1102
  })
1048
1103
  }) : null]
1049
1104
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
1050
- style: selectNavigationStyles(tabs, enableHero, viewport),
1105
+ style: selectNavigationStyles(tabs, enableHero, viewport, enablePeeking, maxWidth),
1051
1106
  children: showPanelNavigation ? activePanelNavigation : null
1052
1107
  })]
1053
1108
  })
@@ -22,7 +22,9 @@ const CarouselProvider = _ref => {
22
22
  themeTokens,
23
23
  totalItems,
24
24
  width,
25
- maximumItemsForSlide
25
+ maximumItemsForSlide,
26
+ maxWidth,
27
+ viewportWidth
26
28
  } = _ref;
27
29
  const value = _react.default.useMemo(() => ({
28
30
  activeIndex,
@@ -33,8 +35,10 @@ const CarouselProvider = _ref => {
33
35
  themeTokens,
34
36
  totalItems,
35
37
  width,
36
- maximumItemsForSlide
37
- }), [activeIndex, goTo, getCopyWithPlaceholders, itemLabel, refocus, totalItems, themeTokens, width, maximumItemsForSlide]);
38
+ maximumItemsForSlide,
39
+ maxWidth,
40
+ viewportWidth
41
+ }), [activeIndex, goTo, getCopyWithPlaceholders, itemLabel, refocus, totalItems, themeTokens, width, maximumItemsForSlide, maxWidth, viewportWidth]);
38
42
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(CarouselContext.Provider, {
39
43
  value: value,
40
44
  children: children
@@ -58,5 +62,7 @@ CarouselProvider.propTypes = {
58
62
  themeTokens: (0, _utils.getTokensPropType)('Carousel'),
59
63
  totalItems: _propTypes.default.number.isRequired,
60
64
  width: _propTypes.default.number.isRequired,
61
- maximumItemsForSlide: _propTypes.default.number
65
+ maximumItemsForSlide: _propTypes.default.number,
66
+ maxWidth: _propTypes.default.number,
67
+ viewportWidth: _propTypes.default.number
62
68
  };
@@ -19,26 +19,26 @@ const selectContainerStyle = _ref => {
19
19
  width,
20
20
  elementIndex,
21
21
  enablePeeking,
22
- peekingMarginLeft,
23
22
  peekingGap,
24
23
  hidden,
25
24
  enableDisplayMultipleItemsPerSlide,
26
25
  viewport,
27
- peekingMiddleSpace
26
+ peekingMiddleSpace,
27
+ maxWidth,
28
+ viewportWidth
28
29
  } = _ref;
29
30
  let adjustedWidth = width;
30
31
  let marginLeft = 0;
31
32
  if (enablePeeking) {
32
33
  const isFirst = elementIndex === 0;
33
- adjustedWidth = width - (peekingMiddleSpace * 2 + peekingGap * 2);
34
+ const baseWidth = maxWidth || width;
35
+ adjustedWidth = baseWidth - peekingMiddleSpace * 2;
34
36
  if (isFirst) {
35
- marginLeft = peekingMarginLeft;
37
+ marginLeft = peekingMiddleSpace + (viewportWidth - maxWidth) / 2;
36
38
  } else {
37
39
  marginLeft = peekingGap;
38
40
  }
39
41
  }
40
-
41
- // Adjust width and margins for multiple items per slide.
42
42
  if (enableDisplayMultipleItemsPerSlide) {
43
43
  switch (viewport) {
44
44
  case 'xs':
@@ -96,7 +96,9 @@ const CarouselItem = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
96
96
  width,
97
97
  activeIndex,
98
98
  goTo,
99
- maximumItemsForSlide
99
+ maximumItemsForSlide,
100
+ maxWidth,
101
+ viewportWidth
100
102
  } = (0, _CarouselContext.useCarousel)();
101
103
  const selectedProps = selectProps({
102
104
  ...rest,
@@ -139,6 +141,8 @@ const CarouselItem = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
139
141
  enablePeeking,
140
142
  enableDisplayMultipleItemsPerSlide,
141
143
  viewport,
144
+ maxWidth,
145
+ viewportWidth,
142
146
  ...peekingProps
143
147
  }),
144
148
  ...selectedProps,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TRANSITION_MODES = exports.SWIPE_RELEASE_STYLES = exports.PEEKING_MULTIPLIER = exports.NEGATIVE_MULTIPLIER = exports.LARGE_VIEWPORT_MARGIN = exports.ITEMS_PER_VIEWPORT_XS_SM = exports.ITEMS_PER_VIEWPORT_MD = exports.ITEMS_PER_VIEWPORT_LG_XL = exports.INSTANT_ANIMATION_DURATION = exports.HERO_POSITION_OFFSET = exports.GAP_BETWEEN_ITEMS = exports.DEFAULT_VIEWPORT_MARGIN = exports.DEFAULT_SWIPE_RELEASE_DURATION = exports.DEFAULT_POSITION_OFFSET = exports.ACTIVE_INDEX_OFFSET_MULTIPLIER = void 0;
6
+ exports.TRANSITION_MODES = exports.SWIPE_RELEASE_STYLES = exports.POSITION_VARIANTS = exports.POSITION_PROPERTIES = exports.PEEKING_MULTIPLIER = exports.NEGATIVE_MULTIPLIER = exports.LARGE_VIEWPORT_MARGIN = exports.ITEMS_PER_VIEWPORT_XS_SM = exports.ITEMS_PER_VIEWPORT_MD = exports.ITEMS_PER_VIEWPORT_LG_XL = exports.INSTANT_ANIMATION_DURATION = exports.HERO_POSITION_OFFSET = exports.GAP_BETWEEN_ITEMS = exports.DEFAULT_VIEWPORT_MARGIN = exports.DEFAULT_SWIPE_RELEASE_DURATION = exports.DEFAULT_POSITION_OFFSET = exports.ACTIVE_INDEX_OFFSET_MULTIPLIER = void 0;
7
7
  const ITEMS_PER_VIEWPORT_XS_SM = exports.ITEMS_PER_VIEWPORT_XS_SM = 1;
8
8
  const ITEMS_PER_VIEWPORT_MD = exports.ITEMS_PER_VIEWPORT_MD = 2;
9
9
  const ITEMS_PER_VIEWPORT_LG_XL = exports.ITEMS_PER_VIEWPORT_LG_XL = 3;
@@ -25,4 +25,13 @@ const SWIPE_RELEASE_STYLES = exports.SWIPE_RELEASE_STYLES = {
25
25
  EASE_OUT: 'ease-out'
26
26
  };
27
27
  const INSTANT_ANIMATION_DURATION = exports.INSTANT_ANIMATION_DURATION = 1;
28
- const DEFAULT_SWIPE_RELEASE_DURATION = exports.DEFAULT_SWIPE_RELEASE_DURATION = 500;
28
+ const DEFAULT_SWIPE_RELEASE_DURATION = exports.DEFAULT_SWIPE_RELEASE_DURATION = 500;
29
+ const POSITION_VARIANTS = exports.POSITION_VARIANTS = {
30
+ EDGE: 'edge',
31
+ INSIDE: 'inside',
32
+ OUTSIDE: 'outside'
33
+ };
34
+ const POSITION_PROPERTIES = exports.POSITION_PROPERTIES = {
35
+ LEFT: 'left',
36
+ RIGHT: 'right'
37
+ };
@@ -121,6 +121,32 @@ const selectFeedbackTokens = _ref5 => {
121
121
  feedbackMarginTop
122
122
  };
123
123
  };
124
+ const selectPressableStyles = _ref6 => {
125
+ let {
126
+ padding,
127
+ paddingLeft,
128
+ paddingRight,
129
+ paddingTop,
130
+ paddingBottom
131
+ } = _ref6;
132
+ return {
133
+ padding,
134
+ paddingLeft,
135
+ paddingRight,
136
+ paddingTop,
137
+ paddingBottom
138
+ };
139
+ };
140
+ const selectContainerStyles = _ref7 => {
141
+ let {
142
+ iconContainerHeight,
143
+ iconContainerWidth
144
+ } = _ref7;
145
+ return {
146
+ height: iconContainerHeight,
147
+ width: iconContainerWidth
148
+ };
149
+ };
124
150
 
125
151
  /**
126
152
  * Basic Checkbox component.
@@ -157,7 +183,7 @@ const selectFeedbackTokens = _ref5 => {
157
183
  * or the internal state in case of uncontrolled checkbox.
158
184
  *
159
185
  */
160
- const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref6, ref) => {
186
+ const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref8, ref) => {
161
187
  let {
162
188
  checked,
163
189
  defaultChecked,
@@ -172,8 +198,9 @@ const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref6, ref) => {
172
198
  tokens,
173
199
  value,
174
200
  variant,
201
+ testID,
175
202
  ...rest
176
- } = _ref6;
203
+ } = _ref8;
177
204
  const {
178
205
  currentValue: isChecked,
179
206
  setValue: setIsChecked,
@@ -230,17 +257,18 @@ const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref6, ref) => {
230
257
  direction: feedbackPosition === 'top' ? 'column-reverse' : 'column',
231
258
  space: 0,
232
259
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
260
+ testID: testID && `${testID}-pressable`,
233
261
  disabled: inactive,
234
262
  onKeyDown: handleKeyDown,
235
263
  onPress: handleChange,
236
264
  ...selectedProps,
237
- style: staticStyles.removeOutline,
238
- children: _ref7 => {
265
+ style: [staticStyles.removeOutline, selectPressableStyles(defaultTokens)],
266
+ children: _ref9 => {
239
267
  let {
240
268
  focused: focus,
241
269
  hovered: hover,
242
270
  pressed
243
- } = _ref7;
271
+ } = _ref9;
244
272
  const {
245
273
  icon: IconComponent,
246
274
  ...stateTokens
@@ -251,15 +279,12 @@ const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref6, ref) => {
251
279
  });
252
280
  const iconTokens = selectIconTokens(stateTokens);
253
281
  const labelStyles = selectLabelStyles(stateTokens, themeOptions);
254
- const alignWithLabel = label ? [staticStyles.alignWithLabel, {
255
- height: labelStyles.lineHeight
256
- }] : null;
257
282
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
258
283
  space: 0,
259
284
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
260
285
  style: staticStyles.container,
261
286
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
262
- style: alignWithLabel,
287
+ style: [staticStyles.iconContainer, selectContainerStyles(stateTokens)],
263
288
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
264
289
  style: [staticStyles.defaultInputStyles, selectInputStyles(stateTokens, isChecked)],
265
290
  testID: "Checkbox-Input",
@@ -358,7 +383,11 @@ Checkbox.propTypes = {
358
383
  /**
359
384
  * An optional Checkbox description.
360
385
  */
361
- description: _propTypes.default.string
386
+ description: _propTypes.default.string,
387
+ /**
388
+ * A identifier for testing purposes.
389
+ */
390
+ testID: _propTypes.default.string
362
391
  };
363
392
  var _default = exports.default = Checkbox;
364
393
  const staticStyles = _StyleSheet.default.create({
@@ -373,9 +402,10 @@ const staticStyles = _StyleSheet.default.create({
373
402
  alignItems: 'center',
374
403
  justifyContent: 'center'
375
404
  },
376
- alignWithLabel: {
377
- alignSelf: 'flex-start',
378
- justifyContent: 'center'
405
+ iconContainer: {
406
+ display: 'flex',
407
+ justifyContent: 'center',
408
+ alignItems: 'center'
379
409
  },
380
410
  removeOutline: {
381
411
  outlineStyle: 'none'
@@ -13,10 +13,15 @@ var _utils = require("../utils");
13
13
  var _jsxRuntime = require("react/jsx-runtime");
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
15
  const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
16
+ const LIST_ITEM_TYPE = 'ListItem';
17
+ const LINKS_ITEM_TYPE = 'LinksItem';
16
18
  const isListItem = element => {
17
- const elementName = element?.type?.displayName || element?.type?.name;
18
- // Match our own ListItem, and also, custom list items
19
- return Boolean(elementName.match(/Item/));
19
+ if (!element?.type) return false;
20
+ if (element.type.__UDS_COMPONENT_TYPE__ === LIST_ITEM_TYPE) {
21
+ return true;
22
+ }
23
+ const elementName = element.type.displayName || element.type.name || '';
24
+ return elementName === LIST_ITEM_TYPE || elementName.includes(LIST_ITEM_TYPE) || elementName.includes(LINKS_ITEM_TYPE);
20
25
  };
21
26
 
22
27
  /**
@@ -29,6 +34,7 @@ const List = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
29
34
  showDivider,
30
35
  tokens,
31
36
  variant,
37
+ iconVerticalAlign,
32
38
  accessibilityRole = _Platform.default.select({
33
39
  web: 'list',
34
40
  default: undefined
@@ -38,13 +44,17 @@ const List = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
38
44
  const items = _react.default.Children.map(children, (child, index) => {
39
45
  // Pass ListItem-specific props to children (by name so teams can add their own ListItems)
40
46
  if (isListItem(child)) {
41
- return /*#__PURE__*/_react.default.cloneElement(child, {
42
- showDivider,
43
- isLastItem: index + 1 === _react.default.Children.count(children),
47
+ const childProps = {
44
48
  tokens,
45
49
  variant,
46
- ...child.props
47
- });
50
+ ...child.props,
51
+ showDivider,
52
+ isLastItem: index + 1 === _react.default.Children.count(children)
53
+ };
54
+ if (!child.props.iconVerticalAlign && iconVerticalAlign) {
55
+ childProps.iconVerticalAlign = iconVerticalAlign;
56
+ }
57
+ return /*#__PURE__*/_react.default.cloneElement(child, childProps);
48
58
  }
49
59
  return child;
50
60
  });
@@ -78,6 +88,11 @@ List.propTypes = {
78
88
  /**
79
89
  * In case it is not the last item allow display divider
80
90
  */
81
- showDivider: _propTypes.default.bool
91
+ showDivider: _propTypes.default.bool,
92
+ /**
93
+ * The vertical alignment of the icon in ListItems.
94
+ * This prop is passed down to ListItem components and can be overridden in individual List.Item components.
95
+ */
96
+ iconVerticalAlign: _propTypes.default.oneOf(['top', 'center', 'bottom'])
82
97
  };
83
98
  var _default = exports.default = List;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
9
  var _ListItemBase = _interopRequireDefault(require("./ListItemBase"));
9
10
  var _ThemeProvider = require("../ThemeProvider");
10
11
  var _utils = require("../utils");
@@ -18,6 +19,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
18
19
  variant,
19
20
  children,
20
21
  title,
22
+ iconVerticalAlign = 'top',
21
23
  ...listItemProps
22
24
  } = _ref;
23
25
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('List', tokens, variant);
@@ -26,12 +28,27 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
26
28
  ref: ref,
27
29
  ...listItemProps,
28
30
  title: title,
31
+ iconVerticalAlign: iconVerticalAlign,
29
32
  children: children
30
33
  });
31
34
  });
32
35
  ListItem.displayName = 'ListItem';
33
36
  ListItem.propTypes = {
37
+ /** Theme tokens for styling */
38
+ tokens: (0, _utils.getTokensPropType)('List'),
39
+ /** Variant configuration for the component */
34
40
  variant: _utils.variantProp.propType,
35
- ..._ListItemBase.default.propTypes
41
+ /** Content to be rendered within the list item */
42
+ children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
43
+ /** Title of the list item */
44
+ title: _propTypes.default.node,
45
+ /** Controls the vertical alignment of the icon */
46
+ iconVerticalAlign: _propTypes.default.oneOf(['top', 'center', 'bottom']),
47
+ /** Icon to be displayed */
48
+ icon: _propTypes.default.elementType,
49
+ /** Color of the icon */
50
+ iconColor: _propTypes.default.string,
51
+ /** Size of the icon */
52
+ iconSize: _propTypes.default.number
36
53
  };
37
54
  var _default = exports.default = ListItem;