@telus-uds/components-base 1.92.0 → 1.94.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 +21 -2
- package/lib/A11yText/index.js +7 -2
- package/lib/Button/ButtonGroup.js +17 -1
- package/lib/Card/Card.js +12 -0
- package/lib/Card/CardBase.js +37 -2
- package/lib/Carousel/Carousel.js +55 -13
- package/lib/Carousel/CarouselItem/CarouselItem.js +86 -12
- package/lib/Fieldset/FieldsetContainer.js +7 -2
- package/lib/Fieldset/FieldsetContainer.native.js +4 -1
- package/lib/FileUpload/FileUpload.js +336 -0
- package/lib/FileUpload/NotificationContent.js +60 -0
- package/lib/FileUpload/dictionary.js +47 -0
- package/lib/FileUpload/index.js +10 -0
- package/lib/Link/TextButton.js +7 -17
- package/lib/Modal/ModalContent.js +12 -6
- package/lib/MultiSelectFilter/ModalOverlay.js +49 -30
- package/lib/MultiSelectFilter/MultiSelectFilter.js +170 -131
- package/lib/Notification/Notification.js +11 -2
- package/lib/Status/Status.js +9 -4
- package/lib/index.js +8 -0
- package/lib/utils/convertFromMegaByteToByte.js +16 -0
- package/lib/utils/formatImageSource.js +34 -0
- package/lib/utils/index.js +17 -1
- package/lib-module/A11yText/index.js +7 -2
- package/lib-module/Button/ButtonGroup.js +17 -1
- package/lib-module/Card/Card.js +13 -1
- package/lib-module/Card/CardBase.js +38 -3
- package/lib-module/Carousel/Carousel.js +55 -13
- package/lib-module/Carousel/CarouselItem/CarouselItem.js +86 -12
- package/lib-module/Fieldset/FieldsetContainer.js +7 -2
- package/lib-module/Fieldset/FieldsetContainer.native.js +4 -1
- package/lib-module/FileUpload/FileUpload.js +329 -0
- package/lib-module/FileUpload/NotificationContent.js +55 -0
- package/lib-module/FileUpload/dictionary.js +40 -0
- package/lib-module/FileUpload/index.js +2 -0
- package/lib-module/Link/TextButton.js +7 -17
- package/lib-module/Modal/ModalContent.js +12 -6
- package/lib-module/MultiSelectFilter/ModalOverlay.js +49 -30
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +171 -132
- package/lib-module/Notification/Notification.js +11 -2
- package/lib-module/Status/Status.js +9 -4
- package/lib-module/index.js +1 -0
- package/lib-module/utils/convertFromMegaByteToByte.js +10 -0
- package/lib-module/utils/formatImageSource.js +27 -0
- package/lib-module/utils/index.js +3 -1
- package/package.json +4 -3
- package/src/A11yText/index.jsx +7 -3
- package/src/Button/ButtonGroup.jsx +9 -1
- package/src/Card/Card.jsx +18 -2
- package/src/Card/CardBase.jsx +47 -12
- package/src/Carousel/Carousel.jsx +59 -13
- package/src/Carousel/CarouselItem/CarouselItem.jsx +94 -9
- package/src/Fieldset/FieldsetContainer.jsx +4 -3
- package/src/Fieldset/FieldsetContainer.native.jsx +9 -6
- package/src/FileUpload/FileUpload.jsx +396 -0
- package/src/FileUpload/NotificationContent.jsx +44 -0
- package/src/FileUpload/dictionary.js +40 -0
- package/src/FileUpload/index.js +3 -0
- package/src/Link/TextButton.jsx +10 -17
- package/src/Modal/ModalContent.jsx +8 -3
- package/src/MultiSelectFilter/ModalOverlay.jsx +44 -18
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +188 -126
- package/src/Notification/Notification.jsx +12 -4
- package/src/Status/Status.jsx +15 -4
- package/src/index.js +1 -0
- package/src/utils/convertFromMegaByteToByte.js +11 -0
- package/src/utils/formatImageSource.js +29 -0
- package/src/utils/index.js +2 -0
package/lib-module/Card/Card.js
CHANGED
|
@@ -4,7 +4,7 @@ import View from "react-native-web/dist/exports/View";
|
|
|
4
4
|
import { useThemeTokens, useThemeTokensCallback, useResponsiveThemeTokens, useTheme } from '../ThemeProvider';
|
|
5
5
|
import { getTokensPropType, variantProp, StyleSheet, createMediaQueryStyles } from '../utils';
|
|
6
6
|
import { useViewport } from '../ViewportProvider';
|
|
7
|
-
import { a11yProps, linkProps, selectSystemProps, viewProps } from '../utils/props';
|
|
7
|
+
import { a11yProps, linkProps, selectSystemProps, viewProps, responsiveProps } from '../utils/props';
|
|
8
8
|
import CardBase from './CardBase';
|
|
9
9
|
import PressableCardBase from './PressableCardBase';
|
|
10
10
|
import CheckboxButton from '../Checkbox/CheckboxButton';
|
|
@@ -112,6 +112,7 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
112
112
|
onPress,
|
|
113
113
|
id,
|
|
114
114
|
interactiveCard,
|
|
115
|
+
backgroundImage,
|
|
115
116
|
...rest
|
|
116
117
|
} = _ref3;
|
|
117
118
|
const viewport = useViewport();
|
|
@@ -235,6 +236,7 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
235
236
|
children: /*#__PURE__*/_jsx(CardBase, {
|
|
236
237
|
ref: ref,
|
|
237
238
|
tokens: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? restOfTokens : cardStyles,
|
|
239
|
+
backgroundImage: backgroundImage,
|
|
238
240
|
dataSet: mediaIds && {
|
|
239
241
|
media: mediaIds
|
|
240
242
|
},
|
|
@@ -313,6 +315,16 @@ Card.propTypes = {
|
|
|
313
315
|
tokens: getTokensPropType('Card'),
|
|
314
316
|
selectionType: PropTypes.oneOf(Object.values(SelectionType)),
|
|
315
317
|
variant: variantProp.propType
|
|
318
|
+
}),
|
|
319
|
+
/**
|
|
320
|
+
* Apply background image to the card.
|
|
321
|
+
*/
|
|
322
|
+
backgroundImage: PropTypes.shape({
|
|
323
|
+
// The image src is either a URI string or a number (when a local image src is bundled in IOS or Android app)
|
|
324
|
+
// src is an object when used responsively to provide different image sources for different screen sizes
|
|
325
|
+
src: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,
|
|
326
|
+
alt: PropTypes.string,
|
|
327
|
+
resizeMode: responsiveProps.getTypeOptionallyByViewport(PropTypes.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center']))
|
|
316
328
|
})
|
|
317
329
|
};
|
|
318
330
|
export default Card;
|
|
@@ -2,8 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import View from "react-native-web/dist/exports/View";
|
|
4
4
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
|
+
import ImageBackground from "react-native-web/dist/exports/ImageBackground";
|
|
6
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
7
|
import { applyShadowToken } from '../ThemeProvider';
|
|
6
|
-
import { getTokensPropType } from '../utils';
|
|
8
|
+
import { getTokensPropType, responsiveProps, useResponsiveProp, formatImageSource } from '../utils';
|
|
7
9
|
import { a11yProps, viewProps, selectSystemProps } from '../utils/props';
|
|
8
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
11
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
@@ -54,22 +56,55 @@ const CardBase = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
54
56
|
children,
|
|
55
57
|
tokens,
|
|
56
58
|
dataSet,
|
|
59
|
+
backgroundImage,
|
|
57
60
|
...rest
|
|
58
61
|
} = _ref2;
|
|
59
62
|
const cardStyle = selectStyles(typeof tokens === 'function' ? tokens() : tokens);
|
|
60
63
|
const props = selectProps(rest);
|
|
64
|
+
const {
|
|
65
|
+
src = '',
|
|
66
|
+
alt = '',
|
|
67
|
+
resizeMode = ''
|
|
68
|
+
} = backgroundImage || {};
|
|
69
|
+
const backgroundImageResizeMode = useResponsiveProp(resizeMode, 'cover');
|
|
70
|
+
const imageSourceViewport = formatImageSource(useResponsiveProp(src));
|
|
61
71
|
return /*#__PURE__*/_jsx(View, {
|
|
62
72
|
style: cardStyle,
|
|
63
73
|
dataSet: dataSet,
|
|
64
74
|
ref: ref,
|
|
65
75
|
...props,
|
|
66
|
-
children:
|
|
76
|
+
children: src ? /*#__PURE__*/_jsx(ImageBackground, {
|
|
77
|
+
alt: alt,
|
|
78
|
+
source: imageSourceViewport,
|
|
79
|
+
imageStyle: {
|
|
80
|
+
borderRadius: (cardStyle === null || cardStyle === void 0 ? void 0 : cardStyle.borderRadius) - (cardStyle === null || cardStyle === void 0 ? void 0 : cardStyle.borderWidth)
|
|
81
|
+
},
|
|
82
|
+
resizeMode: backgroundImageResizeMode,
|
|
83
|
+
style: styles.imageBackground,
|
|
84
|
+
children: children
|
|
85
|
+
}) : children
|
|
67
86
|
});
|
|
68
87
|
});
|
|
69
88
|
CardBase.displayName = 'CardBase';
|
|
89
|
+
const styles = StyleSheet.create({
|
|
90
|
+
imageBackground: {
|
|
91
|
+
width: '100%',
|
|
92
|
+
height: '100%'
|
|
93
|
+
}
|
|
94
|
+
});
|
|
70
95
|
CardBase.propTypes = {
|
|
71
96
|
...selectedSystemPropTypes,
|
|
72
97
|
children: PropTypes.node,
|
|
73
|
-
tokens: getTokensPropType('Card')
|
|
98
|
+
tokens: getTokensPropType('Card'),
|
|
99
|
+
/**
|
|
100
|
+
* Apply background image to the card.
|
|
101
|
+
*/
|
|
102
|
+
backgroundImage: PropTypes.shape({
|
|
103
|
+
// The image src is either a URI string or a number (when a local image src is bundled in IOS or Android app)
|
|
104
|
+
// src is an object when used responsively to provide different image sources for different screen sizes
|
|
105
|
+
src: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,
|
|
106
|
+
alt: PropTypes.string,
|
|
107
|
+
resizeMode: responsiveProps.getTypeOptionallyByViewport(PropTypes.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center']))
|
|
108
|
+
})
|
|
74
109
|
};
|
|
75
110
|
export default CardBase;
|
|
@@ -48,9 +48,9 @@ const selectContainerStyles = width => ({
|
|
|
48
48
|
overflow: 'hidden',
|
|
49
49
|
width
|
|
50
50
|
});
|
|
51
|
-
const selectSwipeAreaStyles = (count, width) => ({
|
|
51
|
+
const selectSwipeAreaStyles = (count, width, enablePeeking) => ({
|
|
52
52
|
width: width * count,
|
|
53
|
-
justifyContent: 'space-between',
|
|
53
|
+
justifyContent: enablePeeking ? 'flex-start' : 'space-between',
|
|
54
54
|
flexDirection: 'row'
|
|
55
55
|
});
|
|
56
56
|
const getDynamicPositionProperty = areStylesAppliedOnPreviousButton => areStylesAppliedOnPreviousButton ? 'left' : 'right';
|
|
@@ -59,7 +59,8 @@ const selectControlButtonPositionStyles = _ref => {
|
|
|
59
59
|
positionVariant,
|
|
60
60
|
buttonWidth,
|
|
61
61
|
positionProperty = getDynamicPositionProperty(),
|
|
62
|
-
spaceBetweenSlideAndButton
|
|
62
|
+
spaceBetweenSlideAndButton,
|
|
63
|
+
enablePeeking
|
|
63
64
|
} = _ref;
|
|
64
65
|
const styles = {};
|
|
65
66
|
if (positionVariant === 'edge') {
|
|
@@ -67,11 +68,15 @@ const selectControlButtonPositionStyles = _ref => {
|
|
|
67
68
|
} else if (positionVariant === 'inside') {
|
|
68
69
|
styles[positionProperty] = 0;
|
|
69
70
|
} else if (positionVariant === 'outside') {
|
|
70
|
-
|
|
71
|
+
if (enablePeeking) {
|
|
72
|
+
styles[positionProperty] = 0;
|
|
73
|
+
} else {
|
|
74
|
+
styles[positionProperty] = -1 * (spaceBetweenSlideAndButton + buttonWidth);
|
|
75
|
+
}
|
|
71
76
|
}
|
|
72
77
|
return styles;
|
|
73
78
|
};
|
|
74
|
-
const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, areStylesAppliedOnPreviousButton) => {
|
|
79
|
+
const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, areStylesAppliedOnPreviousButton, enablePeeking) => {
|
|
75
80
|
const styles = {
|
|
76
81
|
zIndex: 1,
|
|
77
82
|
position: 'absolute'
|
|
@@ -89,10 +94,31 @@ const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWi
|
|
|
89
94
|
positionVariant: previousNextNavigationPosition,
|
|
90
95
|
buttonWidth: previousNextNavigationButtonWidth,
|
|
91
96
|
positionProperty: getDynamicPositionProperty(areStylesAppliedOnPreviousButton),
|
|
92
|
-
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation
|
|
97
|
+
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
|
|
98
|
+
enablePeeking
|
|
93
99
|
})
|
|
94
100
|
};
|
|
95
101
|
};
|
|
102
|
+
const getPeekingProps = viewport => {
|
|
103
|
+
if (viewport === 'xs' || viewport === 'sm') {
|
|
104
|
+
return {
|
|
105
|
+
peekingFirstSpace: 48,
|
|
106
|
+
peekingGap: 16,
|
|
107
|
+
peekingLastSpace: 48,
|
|
108
|
+
peekingMarginLeft: 24,
|
|
109
|
+
peekingMarginRight: 24,
|
|
110
|
+
peekingMiddleSpace: 28
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
peekingFirstSpace: 48,
|
|
115
|
+
peekingGap: 16,
|
|
116
|
+
peekingLastSpace: 48,
|
|
117
|
+
peekingMarginLeft: 16,
|
|
118
|
+
peekingMarginRight: 16,
|
|
119
|
+
peekingMiddleSpace: 24
|
|
120
|
+
};
|
|
121
|
+
};
|
|
96
122
|
const selectIconStyles = _ref2 => {
|
|
97
123
|
let {
|
|
98
124
|
iconBackgroundColor
|
|
@@ -190,6 +216,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
190
216
|
slideDuration = 0,
|
|
191
217
|
transitionDuration = 0,
|
|
192
218
|
autoPlay = false,
|
|
219
|
+
enablePeeking = false,
|
|
193
220
|
...rest
|
|
194
221
|
} = _ref3;
|
|
195
222
|
let childrenArray = unpackFragment(children);
|
|
@@ -286,6 +313,13 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
286
313
|
useNativeDriver: false,
|
|
287
314
|
duration: transitionDuration * 1000
|
|
288
315
|
}).start(handleAnimationEndToIndex);
|
|
316
|
+
} else if (enablePeeking) {
|
|
317
|
+
Animated.timing(pan, {
|
|
318
|
+
...springConfig,
|
|
319
|
+
toValue,
|
|
320
|
+
useNativeDriver: false,
|
|
321
|
+
duration: transitionDuration ? transitionDuration * 1000 : 1000
|
|
322
|
+
}).start(handleAnimationEndToIndex);
|
|
289
323
|
} else {
|
|
290
324
|
Animated.spring(pan, {
|
|
291
325
|
...springConfig,
|
|
@@ -293,7 +327,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
293
327
|
useNativeDriver: false
|
|
294
328
|
}).start(handleAnimationEndToIndex);
|
|
295
329
|
}
|
|
296
|
-
}, [pan, springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled]);
|
|
330
|
+
}, [pan, springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled, enablePeeking]);
|
|
297
331
|
const stopAutoplay = React.useCallback(() => {
|
|
298
332
|
if (autoPlayRef !== null && autoPlayRef !== void 0 && autoPlayRef.current) {
|
|
299
333
|
clearTimeout(autoPlayRef === null || autoPlayRef === void 0 ? void 0 : autoPlayRef.current);
|
|
@@ -595,7 +629,8 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
595
629
|
positionVariant: previousNextNavigationPosition,
|
|
596
630
|
buttonWidth: previousNextNavigationButtonWidth,
|
|
597
631
|
positionProperty: getDynamicPositionProperty(),
|
|
598
|
-
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation
|
|
632
|
+
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
|
|
633
|
+
enablePeeking
|
|
599
634
|
})],
|
|
600
635
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
601
636
|
icon: isCarouselPlaying ? pauseIcon : playIcon,
|
|
@@ -604,7 +639,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
604
639
|
onPress: onAnimationControlButtonPress
|
|
605
640
|
})
|
|
606
641
|
}) : null, showPreviousNextNavigation && childrenArray.length > 1 ? /*#__PURE__*/_jsx(View, {
|
|
607
|
-
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true),
|
|
642
|
+
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true, enablePeeking),
|
|
608
643
|
testID: "previous-button-container",
|
|
609
644
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
610
645
|
onLayout: onPreviousNextNavigationButtonLayout,
|
|
@@ -627,7 +662,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
627
662
|
}), /*#__PURE__*/_jsx(View, {
|
|
628
663
|
style: selectContainerStyles(containerLayout.width),
|
|
629
664
|
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
630
|
-
style: StyleSheet.flatten([selectSwipeAreaStyles(childrenArray.length, containerLayout.width), {
|
|
665
|
+
style: StyleSheet.flatten([selectSwipeAreaStyles(childrenArray.length, containerLayout.width, enablePeeking), {
|
|
631
666
|
transform: [{
|
|
632
667
|
translateX: pan.x
|
|
633
668
|
}, {
|
|
@@ -643,7 +678,9 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
643
678
|
const hidden = !isAnimating && index !== activeIndex;
|
|
644
679
|
const clonedElement = /*#__PURE__*/React.cloneElement(element, {
|
|
645
680
|
elementIndex: index,
|
|
646
|
-
hidden
|
|
681
|
+
hidden: enablePeeking ? false : hidden,
|
|
682
|
+
enablePeeking,
|
|
683
|
+
peekingProps: getPeekingProps(viewport)
|
|
647
684
|
});
|
|
648
685
|
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
649
686
|
children: clonedElement
|
|
@@ -651,7 +688,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
651
688
|
})
|
|
652
689
|
})
|
|
653
690
|
}), showPreviousNextNavigation && childrenArray.length > 1 ? /*#__PURE__*/_jsx(View, {
|
|
654
|
-
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false),
|
|
691
|
+
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, false, enablePeeking),
|
|
655
692
|
testID: "next-button-container",
|
|
656
693
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
657
694
|
onLayout: onPreviousNextNavigationButtonLayout,
|
|
@@ -845,7 +882,12 @@ Carousel.propTypes = {
|
|
|
845
882
|
* - Default value is `0`
|
|
846
883
|
* - `autoPlay` and `slideDuration` are required to be set for this to work
|
|
847
884
|
*/
|
|
848
|
-
transitionDuration: PropTypes.number
|
|
885
|
+
transitionDuration: PropTypes.number,
|
|
886
|
+
/**
|
|
887
|
+
* If set to `true`, the Carousel will show the previous and next slides
|
|
888
|
+
* - Default value is `false`
|
|
889
|
+
*/
|
|
890
|
+
enablePeeking: PropTypes.bool
|
|
849
891
|
};
|
|
850
892
|
Carousel.Item = CarouselItem;
|
|
851
893
|
Carousel.displayName = 'Carousel';
|
|
@@ -6,37 +6,96 @@ import { layoutTags, getA11yPropsFromHtmlTag, selectSystemProps, a11yProps, view
|
|
|
6
6
|
import { useCarousel } from '../CarouselContext';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
9
|
+
const selectContainerStyle = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
width,
|
|
12
|
+
activeIndex,
|
|
13
|
+
elementIndex,
|
|
14
|
+
totalItems,
|
|
15
|
+
enablePeeking,
|
|
16
|
+
peekingMarginLeft,
|
|
17
|
+
peekingMarginRight,
|
|
18
|
+
peekingFirstSpace,
|
|
19
|
+
peekingLastSpace,
|
|
20
|
+
peekingMiddleSpace,
|
|
21
|
+
peekingGap,
|
|
22
|
+
hidden
|
|
23
|
+
} = _ref;
|
|
24
|
+
const isFirst = elementIndex === 0;
|
|
25
|
+
const isLast = elementIndex === totalItems - 1;
|
|
26
|
+
const isMiddle = !isFirst && !isLast;
|
|
27
|
+
const isActive = activeIndex === elementIndex;
|
|
28
|
+
let adjustedWidth = width;
|
|
29
|
+
let marginLeft = 0;
|
|
30
|
+
let marginRight = 0;
|
|
31
|
+
if (enablePeeking) {
|
|
32
|
+
if (isActive) {
|
|
33
|
+
adjustedWidth = width - (peekingMarginLeft + peekingGap + peekingFirstSpace);
|
|
34
|
+
} else if (isMiddle) {
|
|
35
|
+
adjustedWidth = width - peekingGap;
|
|
36
|
+
}
|
|
37
|
+
if (isFirst) {
|
|
38
|
+
if (isActive) {
|
|
39
|
+
marginLeft = peekingMarginLeft;
|
|
40
|
+
} else if (activeIndex === totalItems - 1) {
|
|
41
|
+
marginLeft = peekingLastSpace;
|
|
42
|
+
} else {
|
|
43
|
+
marginLeft = peekingMiddleSpace;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (isLast && isActive) {
|
|
47
|
+
marginRight = peekingMarginRight;
|
|
48
|
+
} else {
|
|
49
|
+
marginRight = peekingGap;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const style = {
|
|
53
|
+
width: adjustedWidth,
|
|
54
|
+
marginLeft,
|
|
55
|
+
marginRight
|
|
56
|
+
};
|
|
57
|
+
if (hidden && Platform.OS === 'web') {
|
|
58
|
+
style.visibility = 'hidden';
|
|
59
|
+
}
|
|
60
|
+
return style;
|
|
61
|
+
};
|
|
9
62
|
|
|
10
63
|
/**
|
|
11
64
|
* `Carousel.Item` is used to wrap the content of an individual slide and is suppsoed to be the
|
|
12
65
|
* only top-level component passed to the `Carousel`
|
|
13
66
|
*/
|
|
14
|
-
const CarouselItem = /*#__PURE__*/React.forwardRef((
|
|
67
|
+
const CarouselItem = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
15
68
|
let {
|
|
16
69
|
children,
|
|
17
70
|
elementIndex,
|
|
18
71
|
tag = 'li',
|
|
19
72
|
hidden,
|
|
73
|
+
enablePeeking,
|
|
74
|
+
peekingProps,
|
|
20
75
|
...rest
|
|
21
|
-
} =
|
|
76
|
+
} = _ref2;
|
|
22
77
|
const {
|
|
23
78
|
width,
|
|
24
|
-
activeIndex
|
|
79
|
+
activeIndex,
|
|
80
|
+
totalItems,
|
|
81
|
+
height
|
|
25
82
|
} = useCarousel();
|
|
26
83
|
const selectedProps = selectProps({
|
|
27
84
|
...rest,
|
|
28
85
|
...getA11yPropsFromHtmlTag(tag, rest.accessibilityRole)
|
|
29
86
|
});
|
|
30
87
|
const focusabilityProps = activeIndex === elementIndex ? {} : a11yProps.nonFocusableProps;
|
|
31
|
-
const style = {
|
|
32
|
-
width
|
|
33
|
-
};
|
|
34
|
-
if (hidden && Platform.OS === 'web') {
|
|
35
|
-
// On web, visibility: hidden makes all children non-focusable. It doesn't exist on native.
|
|
36
|
-
style.visibility = 'hidden';
|
|
37
|
-
}
|
|
38
88
|
return /*#__PURE__*/_jsx(View, {
|
|
39
|
-
style:
|
|
89
|
+
style: selectContainerStyle({
|
|
90
|
+
width,
|
|
91
|
+
activeIndex,
|
|
92
|
+
elementIndex,
|
|
93
|
+
totalItems,
|
|
94
|
+
hidden,
|
|
95
|
+
height,
|
|
96
|
+
enablePeeking,
|
|
97
|
+
...peekingProps
|
|
98
|
+
}),
|
|
40
99
|
...selectedProps,
|
|
41
100
|
...focusabilityProps,
|
|
42
101
|
ref: ref,
|
|
@@ -70,7 +129,22 @@ CarouselItem.propTypes = {
|
|
|
70
129
|
/**
|
|
71
130
|
* Function to set carousel content background color when slide is being display
|
|
72
131
|
*/
|
|
73
|
-
setContentBackgroundColor: PropTypes.func
|
|
132
|
+
setContentBackgroundColor: PropTypes.func,
|
|
133
|
+
/**
|
|
134
|
+
* Boolean to enable peeking effect on the first and last slide
|
|
135
|
+
*/
|
|
136
|
+
enablePeeking: PropTypes.bool,
|
|
137
|
+
/**
|
|
138
|
+
* Object to configure the peeking effect
|
|
139
|
+
*/
|
|
140
|
+
peekingProps: PropTypes.shape({
|
|
141
|
+
peekingMarginLeft: PropTypes.number,
|
|
142
|
+
peekingMarginRight: PropTypes.number,
|
|
143
|
+
peekingFirstSpace: PropTypes.number,
|
|
144
|
+
peekingLastSpace: PropTypes.number,
|
|
145
|
+
peekingMiddleSpace: PropTypes.number,
|
|
146
|
+
peekingGap: PropTypes.number
|
|
147
|
+
})
|
|
74
148
|
};
|
|
75
149
|
CarouselItem.displayName = 'Carousel.Item';
|
|
76
150
|
export default CarouselItem;
|
|
@@ -16,6 +16,7 @@ const FieldsetContainer = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
16
16
|
name: fieldsetName,
|
|
17
17
|
showBorderStyle = false,
|
|
18
18
|
borderStyle,
|
|
19
|
+
style,
|
|
19
20
|
...rest
|
|
20
21
|
} = _ref;
|
|
21
22
|
// If needs border for error design or reset the component style
|
|
@@ -23,7 +24,10 @@ const FieldsetContainer = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
23
24
|
return /*#__PURE__*/_jsx("fieldset", {
|
|
24
25
|
ref: ref,
|
|
25
26
|
disabled: inactive,
|
|
26
|
-
style:
|
|
27
|
+
style: {
|
|
28
|
+
...styleContainer,
|
|
29
|
+
...style
|
|
30
|
+
},
|
|
27
31
|
role: accessibilityRole,
|
|
28
32
|
name: fieldsetName,
|
|
29
33
|
...selectProps(rest),
|
|
@@ -38,6 +42,7 @@ FieldsetContainer.propTypes = {
|
|
|
38
42
|
inactive: PropTypes.bool,
|
|
39
43
|
name: PropTypes.string,
|
|
40
44
|
showBorderStyle: PropTypes.bool,
|
|
41
|
-
borderStyle: PropTypes.object
|
|
45
|
+
borderStyle: PropTypes.object,
|
|
46
|
+
style: PropTypes.object
|
|
42
47
|
};
|
|
43
48
|
export default FieldsetContainer;
|
|
@@ -11,12 +11,14 @@ const FieldsetContainer = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
11
11
|
let {
|
|
12
12
|
children,
|
|
13
13
|
accessibilityRole,
|
|
14
|
+
style,
|
|
14
15
|
...rest
|
|
15
16
|
} = _ref;
|
|
16
17
|
return /*#__PURE__*/_jsx(View, {
|
|
17
18
|
ref: ref,
|
|
18
19
|
accessibilityRole: accessibilityRole,
|
|
19
20
|
...selectProps(rest),
|
|
21
|
+
style: style,
|
|
20
22
|
children: children
|
|
21
23
|
});
|
|
22
24
|
});
|
|
@@ -24,6 +26,7 @@ FieldsetContainer.displayName = 'FieldsetContainer';
|
|
|
24
26
|
FieldsetContainer.propTypes = {
|
|
25
27
|
...selectedSystemPropTypes,
|
|
26
28
|
children: PropTypes.node,
|
|
27
|
-
accessibilityRole: PropTypes.string
|
|
29
|
+
accessibilityRole: PropTypes.string,
|
|
30
|
+
style: PropTypes.object
|
|
28
31
|
};
|
|
29
32
|
export default FieldsetContainer;
|