@telus-uds/components-base 1.93.0 → 1.95.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 (101) hide show
  1. package/CHANGELOG.md +32 -3
  2. package/lib/Autocomplete/Autocomplete.js +2 -1
  3. package/lib/Button/ButtonGroup.js +17 -1
  4. package/lib/Card/Card.js +12 -0
  5. package/lib/Card/CardBase.js +37 -2
  6. package/lib/Carousel/Carousel.js +55 -13
  7. package/lib/Carousel/CarouselItem/CarouselItem.js +86 -12
  8. package/lib/DownloadApp/DownloadApp.js +168 -0
  9. package/lib/DownloadApp/dictionary.js +17 -0
  10. package/lib/DownloadApp/index.js +10 -0
  11. package/lib/Fieldset/FieldsetContainer.js +7 -2
  12. package/lib/Fieldset/FieldsetContainer.native.js +4 -1
  13. package/lib/FileUpload/FileUpload.js +336 -0
  14. package/lib/FileUpload/NotificationContent.js +60 -0
  15. package/lib/FileUpload/dictionary.js +47 -0
  16. package/lib/FileUpload/index.js +10 -0
  17. package/lib/Icon/IconText.js +19 -2
  18. package/lib/Link/LinkBase.js +2 -2
  19. package/lib/Link/TextButton.js +7 -17
  20. package/lib/Modal/Modal.js +1 -1
  21. package/lib/Modal/ModalContent.js +12 -6
  22. package/lib/MultiSelectFilter/ModalOverlay.js +49 -30
  23. package/lib/MultiSelectFilter/MultiSelectFilter.js +170 -131
  24. package/lib/Notification/Notification.js +11 -2
  25. package/lib/Status/Status.js +9 -4
  26. package/lib/TabBar/TabBar.js +133 -0
  27. package/lib/TabBar/TabBarItem.js +184 -0
  28. package/lib/TabBar/index.js +10 -0
  29. package/lib/TextInput/TextInputBase.js +2 -1
  30. package/lib/Tooltip/getTooltipPosition.js +8 -9
  31. package/lib/index.js +24 -0
  32. package/lib/utils/convertFromMegaByteToByte.js +16 -0
  33. package/lib/utils/formatImageSource.js +34 -0
  34. package/lib/utils/index.js +17 -1
  35. package/lib-module/Autocomplete/Autocomplete.js +2 -1
  36. package/lib-module/Button/ButtonGroup.js +17 -1
  37. package/lib-module/Card/Card.js +13 -1
  38. package/lib-module/Card/CardBase.js +38 -3
  39. package/lib-module/Carousel/Carousel.js +55 -13
  40. package/lib-module/Carousel/CarouselItem/CarouselItem.js +86 -12
  41. package/lib-module/DownloadApp/DownloadApp.js +160 -0
  42. package/lib-module/DownloadApp/dictionary.js +10 -0
  43. package/lib-module/DownloadApp/index.js +2 -0
  44. package/lib-module/Fieldset/FieldsetContainer.js +7 -2
  45. package/lib-module/Fieldset/FieldsetContainer.native.js +4 -1
  46. package/lib-module/FileUpload/FileUpload.js +329 -0
  47. package/lib-module/FileUpload/NotificationContent.js +55 -0
  48. package/lib-module/FileUpload/dictionary.js +40 -0
  49. package/lib-module/FileUpload/index.js +2 -0
  50. package/lib-module/Icon/IconText.js +19 -2
  51. package/lib-module/Link/LinkBase.js +2 -2
  52. package/lib-module/Link/TextButton.js +7 -17
  53. package/lib-module/Modal/Modal.js +1 -1
  54. package/lib-module/Modal/ModalContent.js +12 -6
  55. package/lib-module/MultiSelectFilter/ModalOverlay.js +49 -30
  56. package/lib-module/MultiSelectFilter/MultiSelectFilter.js +171 -132
  57. package/lib-module/Notification/Notification.js +11 -2
  58. package/lib-module/Status/Status.js +9 -4
  59. package/lib-module/TabBar/TabBar.js +125 -0
  60. package/lib-module/TabBar/TabBarItem.js +177 -0
  61. package/lib-module/TabBar/index.js +2 -0
  62. package/lib-module/TextInput/TextInputBase.js +2 -1
  63. package/lib-module/Tooltip/getTooltipPosition.js +8 -9
  64. package/lib-module/index.js +3 -0
  65. package/lib-module/utils/convertFromMegaByteToByte.js +10 -0
  66. package/lib-module/utils/formatImageSource.js +27 -0
  67. package/lib-module/utils/index.js +3 -1
  68. package/package.json +4 -3
  69. package/src/Autocomplete/Autocomplete.jsx +2 -1
  70. package/src/Button/ButtonGroup.jsx +9 -1
  71. package/src/Card/Card.jsx +18 -2
  72. package/src/Card/CardBase.jsx +47 -12
  73. package/src/Carousel/Carousel.jsx +59 -13
  74. package/src/Carousel/CarouselItem/CarouselItem.jsx +94 -9
  75. package/src/DownloadApp/DownloadApp.jsx +165 -0
  76. package/src/DownloadApp/dictionary.js +10 -0
  77. package/src/DownloadApp/index.js +3 -0
  78. package/src/Fieldset/FieldsetContainer.jsx +4 -3
  79. package/src/Fieldset/FieldsetContainer.native.jsx +9 -6
  80. package/src/FileUpload/FileUpload.jsx +396 -0
  81. package/src/FileUpload/NotificationContent.jsx +44 -0
  82. package/src/FileUpload/dictionary.js +40 -0
  83. package/src/FileUpload/index.js +3 -0
  84. package/src/Icon/IconText.jsx +21 -4
  85. package/src/Link/LinkBase.jsx +2 -2
  86. package/src/Link/TextButton.jsx +10 -17
  87. package/src/Modal/Modal.jsx +1 -1
  88. package/src/Modal/ModalContent.jsx +8 -3
  89. package/src/MultiSelectFilter/ModalOverlay.jsx +44 -18
  90. package/src/MultiSelectFilter/MultiSelectFilter.jsx +188 -126
  91. package/src/Notification/Notification.jsx +12 -4
  92. package/src/Status/Status.jsx +15 -4
  93. package/src/TabBar/TabBar.jsx +123 -0
  94. package/src/TabBar/TabBarItem.jsx +149 -0
  95. package/src/TabBar/index.js +3 -0
  96. package/src/TextInput/TextInputBase.jsx +1 -1
  97. package/src/Tooltip/getTooltipPosition.js +11 -12
  98. package/src/index.js +3 -0
  99. package/src/utils/convertFromMegaByteToByte.js +11 -0
  100. package/src/utils/formatImageSource.js +29 -0
  101. package/src/utils/index.js +2 -0
package/CHANGELOG.md CHANGED
@@ -1,16 +1,45 @@
1
1
  # Change Log - @telus-uds/components-base
2
2
 
3
- This log was last generated on Mon, 26 Aug 2024 16:19:45 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 25 Sep 2024 16:57:49 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 1.93.0
7
+ ## 1.95.0
8
8
 
9
- Mon, 26 Aug 2024 16:19:45 GMT
9
+ Wed, 25 Sep 2024 16:57:49 GMT
10
10
 
11
11
  ### Minor changes
12
12
 
13
+ - `DownloadApp`: add component (Mauricio.BatresMontejo@telus.com)
14
+ - `TabBar`: new component added (35577399+JoshHC@users.noreply.github.com)
15
+ - `Link`: add `inline` variant to `iconPosition` (evander.owusu@telus.com)
16
+ - Bump @telus-uds/system-theme-tokens to v2.64.0
17
+
18
+ ### Patches
19
+
20
+ - `Modal`: fix focusing on undefined ref for close button (kristina.kirpichnikova@telus.com)
21
+ - `TextInput`: masked characters issue in password fixed (35577399+JoshHC@users.noreply.github.com)
22
+ - `Tooltip`: fix positioning (guillermo.peitzner@telus.com)
23
+ - `Autocomplete`: add missing loading-label functionality (guillermo.peitzner@telus.com)
24
+
25
+ ## 1.94.0
26
+
27
+ Mon, 16 Sep 2024 12:35:38 GMT
28
+
29
+ ### Minor changes
30
+
31
+ - `FileUpload`: add component and add an on-dismiss function to the notification component (guillermo.peitzner@telus.com)
32
+ - `Carousel`: add peeking functionality (guillermo.peitzner@telus.com)
33
+ - `Card`: Add `backgroundImage` prop (<tony.eng@telus.com>)
34
+ - `ButtonGroup`: add `contained` variant, and new, `backgroundColor`, `borderRadius`, `padding`, and `gap` tokens (jaime.tuyuc@telus.com)
13
35
  - `A11yText`: add role prop (guillermo.peitzner@telus.com)
36
+ - Bump @telus-uds/system-theme-tokens to v2.63.0
37
+
38
+ ### Patches
39
+
40
+ - `MultiSelectFilter:` align with design intention (guillermo.peitzner@telus.com)
41
+ - `TextButton`: remove flex behavior (guillermo.peitzner@telus.com)
42
+ - Status: enable conditional rendering of `icon`. (Mauricio.BatresMontejo@telus.com)
14
43
 
15
44
  ## 1.92.0
16
45
 
@@ -111,6 +111,7 @@ const Autocomplete = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
111
111
  validation,
112
112
  value,
113
113
  helpText = '',
114
+ loadingLabel,
114
115
  ...rest
115
116
  } = _ref2;
116
117
  const {
@@ -346,7 +347,7 @@ const Autocomplete = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
346
347
  onLayout: handleMeasure,
347
348
  ref: openOverlayRef,
348
349
  children: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.default, {
349
- label: getCopy('loading')
350
+ label: loadingLabel ?? getCopy('loading')
350
351
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Suggestions.default, {
351
352
  hasResults: getCopy('hasResults'),
352
353
  id: "autocomplete",
@@ -55,7 +55,11 @@ const ButtonGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
55
55
  const {
56
56
  direction,
57
57
  space,
58
- fieldSpace
58
+ fieldSpace,
59
+ borderRadius,
60
+ backgroundColor,
61
+ padding,
62
+ gap
59
63
  } = themeTokens;
60
64
  const getButtonTokens = (0, _ThemeProvider.useThemeTokensCallback)('ButtonGroupItem', tokens, variant);
61
65
  const {
@@ -94,12 +98,24 @@ const ButtonGroup = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
94
98
  inactive: inactive,
95
99
  validation: validation,
96
100
  accessibilityRole: accessibilityRole,
101
+ style: {
102
+ borderRadius,
103
+ backgroundColor,
104
+ padding,
105
+ ...(_Platform.default.OS === 'web' ? {
106
+ gap,
107
+ width: 'fit-content'
108
+ } : {
109
+ alignSelf: 'flex-start'
110
+ })
111
+ },
97
112
  ...selectProps(rest),
98
113
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.StackWrap, {
99
114
  accessibilityRole: innerRole,
100
115
  space: space,
101
116
  direction: direction,
102
117
  tokens: stackTokens,
118
+ gap: gap,
103
119
  ref: ref,
104
120
  children: items.map((_ref2, index) => {
105
121
  let {
package/lib/Card/Card.js CHANGED
@@ -117,6 +117,7 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
117
117
  onPress,
118
118
  id,
119
119
  interactiveCard,
120
+ backgroundImage,
120
121
  ...rest
121
122
  } = _ref3;
122
123
  const viewport = (0, _ViewportProvider.useViewport)();
@@ -240,6 +241,7 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
240
241
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBase.default, {
241
242
  ref: ref,
242
243
  tokens: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? restOfTokens : cardStyles,
244
+ backgroundImage: backgroundImage,
243
245
  dataSet: mediaIds && {
244
246
  media: mediaIds
245
247
  },
@@ -318,6 +320,16 @@ Card.propTypes = {
318
320
  tokens: (0, _utils.getTokensPropType)('Card'),
319
321
  selectionType: _propTypes.default.oneOf(Object.values(SelectionType)),
320
322
  variant: _utils.variantProp.propType
323
+ }),
324
+ /**
325
+ * Apply background image to the card.
326
+ */
327
+ backgroundImage: _propTypes.default.shape({
328
+ // The image src is either a URI string or a number (when a local image src is bundled in IOS or Android app)
329
+ // src is an object when used responsively to provide different image sources for different screen sizes
330
+ src: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.object]).isRequired,
331
+ alt: _propTypes.default.string,
332
+ resizeMode: _props.responsiveProps.getTypeOptionallyByViewport(_propTypes.default.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center']))
321
333
  })
322
334
  };
323
335
  var _default = Card;
@@ -8,6 +8,8 @@ var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
10
10
  var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
11
+ var _ImageBackground = _interopRequireDefault(require("react-native-web/dist/cjs/exports/ImageBackground"));
12
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
11
13
  var _ThemeProvider = require("../ThemeProvider");
12
14
  var _utils = require("../utils");
13
15
  var _props = require("../utils/props");
@@ -61,23 +63,56 @@ const CardBase = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
61
63
  children,
62
64
  tokens,
63
65
  dataSet,
66
+ backgroundImage,
64
67
  ...rest
65
68
  } = _ref2;
66
69
  const cardStyle = selectStyles(typeof tokens === 'function' ? tokens() : tokens);
67
70
  const props = selectProps(rest);
71
+ const {
72
+ src = '',
73
+ alt = '',
74
+ resizeMode = ''
75
+ } = backgroundImage || {};
76
+ const backgroundImageResizeMode = (0, _utils.useResponsiveProp)(resizeMode, 'cover');
77
+ const imageSourceViewport = (0, _utils.formatImageSource)((0, _utils.useResponsiveProp)(src));
68
78
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
69
79
  style: cardStyle,
70
80
  dataSet: dataSet,
71
81
  ref: ref,
72
82
  ...props,
73
- children: children
83
+ children: src ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageBackground.default, {
84
+ alt: alt,
85
+ source: imageSourceViewport,
86
+ imageStyle: {
87
+ borderRadius: (cardStyle === null || cardStyle === void 0 ? void 0 : cardStyle.borderRadius) - (cardStyle === null || cardStyle === void 0 ? void 0 : cardStyle.borderWidth)
88
+ },
89
+ resizeMode: backgroundImageResizeMode,
90
+ style: styles.imageBackground,
91
+ children: children
92
+ }) : children
74
93
  });
75
94
  });
76
95
  CardBase.displayName = 'CardBase';
96
+ const styles = _StyleSheet.default.create({
97
+ imageBackground: {
98
+ width: '100%',
99
+ height: '100%'
100
+ }
101
+ });
77
102
  CardBase.propTypes = {
78
103
  ...selectedSystemPropTypes,
79
104
  children: _propTypes.default.node,
80
- tokens: (0, _utils.getTokensPropType)('Card')
105
+ tokens: (0, _utils.getTokensPropType)('Card'),
106
+ /**
107
+ * Apply background image to the card.
108
+ */
109
+ backgroundImage: _propTypes.default.shape({
110
+ // The image src is either a URI string or a number (when a local image src is bundled in IOS or Android app)
111
+ // src is an object when used responsively to provide different image sources for different screen sizes
112
+ src: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.object]).isRequired,
113
+ alt: _propTypes.default.string,
114
+ resizeMode: _utils.responsiveProps.getTypeOptionallyByViewport(_propTypes.default.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center']))
115
+ })
81
116
  };
82
117
  var _default = CardBase;
83
118
  exports.default = _default;
@@ -54,9 +54,9 @@ const selectContainerStyles = width => ({
54
54
  overflow: 'hidden',
55
55
  width
56
56
  });
57
- const selectSwipeAreaStyles = (count, width) => ({
57
+ const selectSwipeAreaStyles = (count, width, enablePeeking) => ({
58
58
  width: width * count,
59
- justifyContent: 'space-between',
59
+ justifyContent: enablePeeking ? 'flex-start' : 'space-between',
60
60
  flexDirection: 'row'
61
61
  });
62
62
  const getDynamicPositionProperty = areStylesAppliedOnPreviousButton => areStylesAppliedOnPreviousButton ? 'left' : 'right';
@@ -65,7 +65,8 @@ const selectControlButtonPositionStyles = _ref => {
65
65
  positionVariant,
66
66
  buttonWidth,
67
67
  positionProperty = getDynamicPositionProperty(),
68
- spaceBetweenSlideAndButton
68
+ spaceBetweenSlideAndButton,
69
+ enablePeeking
69
70
  } = _ref;
70
71
  const styles = {};
71
72
  if (positionVariant === 'edge') {
@@ -73,11 +74,15 @@ const selectControlButtonPositionStyles = _ref => {
73
74
  } else if (positionVariant === 'inside') {
74
75
  styles[positionProperty] = 0;
75
76
  } else if (positionVariant === 'outside') {
76
- styles[positionProperty] = -1 * (spaceBetweenSlideAndButton + buttonWidth);
77
+ if (enablePeeking) {
78
+ styles[positionProperty] = 0;
79
+ } else {
80
+ styles[positionProperty] = -1 * (spaceBetweenSlideAndButton + buttonWidth);
81
+ }
77
82
  }
78
83
  return styles;
79
84
  };
80
- const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, areStylesAppliedOnPreviousButton) => {
85
+ const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, areStylesAppliedOnPreviousButton, enablePeeking) => {
81
86
  const styles = {
82
87
  zIndex: 1,
83
88
  position: 'absolute'
@@ -95,10 +100,31 @@ const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWi
95
100
  positionVariant: previousNextNavigationPosition,
96
101
  buttonWidth: previousNextNavigationButtonWidth,
97
102
  positionProperty: getDynamicPositionProperty(areStylesAppliedOnPreviousButton),
98
- spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation
103
+ spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
104
+ enablePeeking
99
105
  })
100
106
  };
101
107
  };
108
+ const getPeekingProps = viewport => {
109
+ if (viewport === 'xs' || viewport === 'sm') {
110
+ return {
111
+ peekingFirstSpace: 48,
112
+ peekingGap: 16,
113
+ peekingLastSpace: 48,
114
+ peekingMarginLeft: 24,
115
+ peekingMarginRight: 24,
116
+ peekingMiddleSpace: 28
117
+ };
118
+ }
119
+ return {
120
+ peekingFirstSpace: 48,
121
+ peekingGap: 16,
122
+ peekingLastSpace: 48,
123
+ peekingMarginLeft: 16,
124
+ peekingMarginRight: 16,
125
+ peekingMiddleSpace: 24
126
+ };
127
+ };
102
128
  const selectIconStyles = _ref2 => {
103
129
  let {
104
130
  iconBackgroundColor
@@ -196,6 +222,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
196
222
  slideDuration = 0,
197
223
  transitionDuration = 0,
198
224
  autoPlay = false,
225
+ enablePeeking = false,
199
226
  ...rest
200
227
  } = _ref3;
201
228
  let childrenArray = (0, _utils.unpackFragment)(children);
@@ -292,6 +319,13 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
292
319
  useNativeDriver: false,
293
320
  duration: transitionDuration * 1000
294
321
  }).start(handleAnimationEndToIndex);
322
+ } else if (enablePeeking) {
323
+ _Animated.default.timing(pan, {
324
+ ...springConfig,
325
+ toValue,
326
+ useNativeDriver: false,
327
+ duration: transitionDuration ? transitionDuration * 1000 : 1000
328
+ }).start(handleAnimationEndToIndex);
295
329
  } else {
296
330
  _Animated.default.spring(pan, {
297
331
  ...springConfig,
@@ -299,7 +333,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
299
333
  useNativeDriver: false
300
334
  }).start(handleAnimationEndToIndex);
301
335
  }
302
- }, [pan, springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled]);
336
+ }, [pan, springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled, enablePeeking]);
303
337
  const stopAutoplay = _react.default.useCallback(() => {
304
338
  if (autoPlayRef !== null && autoPlayRef !== void 0 && autoPlayRef.current) {
305
339
  clearTimeout(autoPlayRef === null || autoPlayRef === void 0 ? void 0 : autoPlayRef.current);
@@ -601,7 +635,8 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
601
635
  positionVariant: previousNextNavigationPosition,
602
636
  buttonWidth: previousNextNavigationButtonWidth,
603
637
  positionProperty: getDynamicPositionProperty(),
604
- spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation
638
+ spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
639
+ enablePeeking
605
640
  })],
606
641
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
607
642
  icon: isCarouselPlaying ? pauseIcon : playIcon,
@@ -610,7 +645,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
610
645
  onPress: onAnimationControlButtonPress
611
646
  })
612
647
  }) : null, showPreviousNextNavigation && childrenArray.length > 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
613
- style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true),
648
+ style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true, enablePeeking),
614
649
  testID: "previous-button-container",
615
650
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
616
651
  onLayout: onPreviousNextNavigationButtonLayout,
@@ -633,7 +668,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
633
668
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
634
669
  style: selectContainerStyles(containerLayout.width),
635
670
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Animated.default.View, {
636
- style: _StyleSheet.default.flatten([selectSwipeAreaStyles(childrenArray.length, containerLayout.width), {
671
+ style: _StyleSheet.default.flatten([selectSwipeAreaStyles(childrenArray.length, containerLayout.width, enablePeeking), {
637
672
  transform: [{
638
673
  translateX: pan.x
639
674
  }, {
@@ -649,7 +684,9 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
649
684
  const hidden = !isAnimating && index !== activeIndex;
650
685
  const clonedElement = /*#__PURE__*/_react.default.cloneElement(element, {
651
686
  elementIndex: index,
652
- hidden
687
+ hidden: enablePeeking ? false : hidden,
688
+ enablePeeking,
689
+ peekingProps: getPeekingProps(viewport)
653
690
  });
654
691
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
655
692
  children: clonedElement
@@ -657,7 +694,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
657
694
  })
658
695
  })
659
696
  }), showPreviousNextNavigation && childrenArray.length > 1 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
660
- style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false),
697
+ style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false, enablePeeking),
661
698
  testID: "next-button-container",
662
699
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
663
700
  onLayout: onPreviousNextNavigationButtonLayout,
@@ -851,7 +888,12 @@ Carousel.propTypes = {
851
888
  * - Default value is `0`
852
889
  * - `autoPlay` and `slideDuration` are required to be set for this to work
853
890
  */
854
- transitionDuration: _propTypes.default.number
891
+ transitionDuration: _propTypes.default.number,
892
+ /**
893
+ * If set to `true`, the Carousel will show the previous and next slides
894
+ * - Default value is `false`
895
+ */
896
+ enablePeeking: _propTypes.default.bool
855
897
  };
856
898
  Carousel.Item = _CarouselItem.default;
857
899
  Carousel.displayName = 'Carousel';
@@ -13,37 +13,96 @@ var _CarouselContext = require("../CarouselContext");
13
13
  var _jsxRuntime = require("react/jsx-runtime");
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
  const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
16
+ const selectContainerStyle = _ref => {
17
+ let {
18
+ width,
19
+ activeIndex,
20
+ elementIndex,
21
+ totalItems,
22
+ enablePeeking,
23
+ peekingMarginLeft,
24
+ peekingMarginRight,
25
+ peekingFirstSpace,
26
+ peekingLastSpace,
27
+ peekingMiddleSpace,
28
+ peekingGap,
29
+ hidden
30
+ } = _ref;
31
+ const isFirst = elementIndex === 0;
32
+ const isLast = elementIndex === totalItems - 1;
33
+ const isMiddle = !isFirst && !isLast;
34
+ const isActive = activeIndex === elementIndex;
35
+ let adjustedWidth = width;
36
+ let marginLeft = 0;
37
+ let marginRight = 0;
38
+ if (enablePeeking) {
39
+ if (isActive) {
40
+ adjustedWidth = width - (peekingMarginLeft + peekingGap + peekingFirstSpace);
41
+ } else if (isMiddle) {
42
+ adjustedWidth = width - peekingGap;
43
+ }
44
+ if (isFirst) {
45
+ if (isActive) {
46
+ marginLeft = peekingMarginLeft;
47
+ } else if (activeIndex === totalItems - 1) {
48
+ marginLeft = peekingLastSpace;
49
+ } else {
50
+ marginLeft = peekingMiddleSpace;
51
+ }
52
+ }
53
+ if (isLast && isActive) {
54
+ marginRight = peekingMarginRight;
55
+ } else {
56
+ marginRight = peekingGap;
57
+ }
58
+ }
59
+ const style = {
60
+ width: adjustedWidth,
61
+ marginLeft,
62
+ marginRight
63
+ };
64
+ if (hidden && _Platform.default.OS === 'web') {
65
+ style.visibility = 'hidden';
66
+ }
67
+ return style;
68
+ };
16
69
 
17
70
  /**
18
71
  * `Carousel.Item` is used to wrap the content of an individual slide and is suppsoed to be the
19
72
  * only top-level component passed to the `Carousel`
20
73
  */
21
- const CarouselItem = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
74
+ const CarouselItem = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
22
75
  let {
23
76
  children,
24
77
  elementIndex,
25
78
  tag = 'li',
26
79
  hidden,
80
+ enablePeeking,
81
+ peekingProps,
27
82
  ...rest
28
- } = _ref;
83
+ } = _ref2;
29
84
  const {
30
85
  width,
31
- activeIndex
86
+ activeIndex,
87
+ totalItems,
88
+ height
32
89
  } = (0, _CarouselContext.useCarousel)();
33
90
  const selectedProps = selectProps({
34
91
  ...rest,
35
92
  ...(0, _utils.getA11yPropsFromHtmlTag)(tag, rest.accessibilityRole)
36
93
  });
37
94
  const focusabilityProps = activeIndex === elementIndex ? {} : _utils.a11yProps.nonFocusableProps;
38
- const style = {
39
- width
40
- };
41
- if (hidden && _Platform.default.OS === 'web') {
42
- // On web, visibility: hidden makes all children non-focusable. It doesn't exist on native.
43
- style.visibility = 'hidden';
44
- }
45
95
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
46
- style: style,
96
+ style: selectContainerStyle({
97
+ width,
98
+ activeIndex,
99
+ elementIndex,
100
+ totalItems,
101
+ hidden,
102
+ height,
103
+ enablePeeking,
104
+ ...peekingProps
105
+ }),
47
106
  ...selectedProps,
48
107
  ...focusabilityProps,
49
108
  ref: ref,
@@ -77,7 +136,22 @@ CarouselItem.propTypes = {
77
136
  /**
78
137
  * Function to set carousel content background color when slide is being display
79
138
  */
80
- setContentBackgroundColor: _propTypes.default.func
139
+ setContentBackgroundColor: _propTypes.default.func,
140
+ /**
141
+ * Boolean to enable peeking effect on the first and last slide
142
+ */
143
+ enablePeeking: _propTypes.default.bool,
144
+ /**
145
+ * Object to configure the peeking effect
146
+ */
147
+ peekingProps: _propTypes.default.shape({
148
+ peekingMarginLeft: _propTypes.default.number,
149
+ peekingMarginRight: _propTypes.default.number,
150
+ peekingFirstSpace: _propTypes.default.number,
151
+ peekingLastSpace: _propTypes.default.number,
152
+ peekingMiddleSpace: _propTypes.default.number,
153
+ peekingGap: _propTypes.default.number
154
+ })
81
155
  };
82
156
  CarouselItem.displayName = 'Carousel.Item';
83
157
  var _default = CarouselItem;
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
10
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
11
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
12
+ var _utils = require("../utils");
13
+ var _ThemeProvider = require("../ThemeProvider");
14
+ var _dictionary = _interopRequireDefault(require("./dictionary"));
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.linkProps, _utils.viewProps]);
18
+ const selectOuterStyles = _ref => {
19
+ let {
20
+ borderColor,
21
+ borderWidth,
22
+ borderGap,
23
+ borderRadius,
24
+ padding
25
+ } = _ref;
26
+ return {
27
+ outline: 'none',
28
+ borderColor,
29
+ borderWidth,
30
+ borderGap,
31
+ borderRadius,
32
+ padding
33
+ };
34
+ };
35
+ const DownloadApp = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
36
+ let {
37
+ copy = 'en',
38
+ dictionary = _dictionary.default,
39
+ type = 'ios',
40
+ href,
41
+ onPress,
42
+ tokens = {},
43
+ variant = {},
44
+ ...props
45
+ } = _ref2;
46
+ const getCopy = (0, _utils.useCopy)({
47
+ dictionary,
48
+ copy
49
+ });
50
+ const {
51
+ hrefAttrs,
52
+ rest
53
+ } = _utils.hrefAttrsProp.bundle(props);
54
+ const selectedProps = selectProps({
55
+ accessibilityRole: href ? 'link' : 'button',
56
+ href,
57
+ onPress: _utils.linkProps.handleHref({
58
+ href,
59
+ onPress
60
+ }),
61
+ hrefAttrs,
62
+ ...rest
63
+ });
64
+ const getDownloadAppTokens = (0, _ThemeProvider.useThemeTokensCallback)('DownloadApp', tokens, variant);
65
+ const resolveDownloadAppTokens = pressableState => {
66
+ const themeTokens = (0, _utils.resolvePressableTokens)(getDownloadAppTokens, pressableState, {});
67
+ return selectOuterStyles(themeTokens);
68
+ };
69
+ const {
70
+ androidENIcon,
71
+ androidFRIcon,
72
+ iosENIcon,
73
+ iosFRIcon
74
+ } = getDownloadAppTokens();
75
+ const imageResources = {
76
+ en: {
77
+ android: androidENIcon,
78
+ ios: iosENIcon
79
+ },
80
+ fr: {
81
+ android: androidFRIcon,
82
+ ios: iosFRIcon
83
+ }
84
+ };
85
+ const IconComponent = imageResources[copy][type];
86
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
87
+ ref: ref,
88
+ style: pressState => [resolveDownloadAppTokens(pressState), staticStyles.row],
89
+ ...selectedProps,
90
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, {
91
+ style: staticImageSizes[type][copy],
92
+ alt: type === 'ios' ? getCopy('altTextIos') : getCopy('altTextAndroid')
93
+ })
94
+ });
95
+ });
96
+ DownloadApp.displayName = 'DownloadApp';
97
+ const dictionaryContentShape = _propTypes.default.shape({
98
+ altTextAndroid: _propTypes.default.string.isRequired,
99
+ altTextIos: _propTypes.default.string.isRequired
100
+ });
101
+ DownloadApp.propTypes = {
102
+ ...selectedSystemPropTypes,
103
+ copy: _utils.copyPropTypes,
104
+ /**
105
+ * Override the default dictionary, by passing the complete dictionary object for `en` and `fr`
106
+ */
107
+ dictionary: _propTypes.default.shape({
108
+ en: dictionaryContentShape,
109
+ fr: dictionaryContentShape
110
+ }),
111
+ /**
112
+ * Select the type of image to show.
113
+ */
114
+ type: _propTypes.default.oneOf(['android', 'ios']),
115
+ /**
116
+ * It's a simple link that opens the Download Button instead of the onPress function.
117
+ */
118
+ href: _propTypes.default.string,
119
+ /**
120
+ * Function called when the button is pressed. Required unless the button has a href.
121
+ */
122
+ onPress: _propTypes.default.func,
123
+ /**
124
+ * DownloadApp tokens.
125
+ */
126
+ tokens: (0, _utils.getTokensPropType)('DownloadApp'),
127
+ /**
128
+ * DownloadApp variant.
129
+ */
130
+ variant: _utils.variantProp.propType
131
+ };
132
+ const staticStyles = _StyleSheet.default.create({
133
+ row: {
134
+ ..._Platform.default.select({
135
+ web: {
136
+ display: 'inline-flex',
137
+ width: 'fit-content'
138
+ },
139
+ default: {
140
+ alignSelf: 'flex-start'
141
+ }
142
+ })
143
+ }
144
+ });
145
+ const staticImageSizes = {
146
+ android: {
147
+ en: {
148
+ width: 162,
149
+ height: 48
150
+ },
151
+ fr: {
152
+ width: 162,
153
+ height: 48
154
+ }
155
+ },
156
+ ios: {
157
+ en: {
158
+ width: 144,
159
+ height: 48
160
+ },
161
+ fr: {
162
+ width: 152,
163
+ height: 48
164
+ }
165
+ }
166
+ };
167
+ var _default = DownloadApp;
168
+ exports.default = _default;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ en: {
9
+ altTextAndroid: 'Get it on Google Play',
10
+ altTextIos: 'Download on the App Store'
11
+ },
12
+ fr: {
13
+ altTextAndroid: 'Disponible sur Google Play',
14
+ altTextIos: 'Télécharger dans l’App Store'
15
+ }
16
+ };
17
+ exports.default = _default;