@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/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 16 Sep 2024 12:26:18 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.94.0
|
|
8
|
+
|
|
9
|
+
Mon, 16 Sep 2024 12:26:18 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `FileUpload`: add component and add an on-dismiss function to the notification component (guillermo.peitzner@telus.com)
|
|
14
|
+
- `Carousel`: add peeking functionality (guillermo.peitzner@telus.com)
|
|
15
|
+
- `Card`: Add `backgroundImage` prop (<tony.eng@telus.com>)
|
|
16
|
+
- `ButtonGroup`: add `contained` variant, and new, `backgroundColor`, `borderRadius`, `padding`, and `gap` tokens (jaime.tuyuc@telus.com)
|
|
17
|
+
- `A11yText`: add role prop (guillermo.peitzner@telus.com)
|
|
18
|
+
- Bump @telus-uds/system-theme-tokens to v2.63.0
|
|
19
|
+
|
|
20
|
+
### Patches
|
|
21
|
+
|
|
22
|
+
- `MultiSelectFilter:` align with design intention (guillermo.peitzner@telus.com)
|
|
23
|
+
- `TextButton`: remove flex behavior (guillermo.peitzner@telus.com)
|
|
24
|
+
- Status: enable conditional rendering of `icon`. (Mauricio.BatresMontejo@telus.com)
|
|
25
|
+
|
|
7
26
|
## 1.92.0
|
|
8
27
|
|
|
9
|
-
Thu, 22 Aug 2024 18:
|
|
28
|
+
Thu, 22 Aug 2024 18:25:10 GMT
|
|
10
29
|
|
|
11
30
|
### Minor changes
|
|
12
31
|
|
package/lib/A11yText/index.js
CHANGED
|
@@ -24,6 +24,7 @@ const A11yText = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
24
24
|
let {
|
|
25
25
|
text,
|
|
26
26
|
heading,
|
|
27
|
+
role = 'text',
|
|
27
28
|
...rest
|
|
28
29
|
} = _ref;
|
|
29
30
|
const selectedProps = selectProps({
|
|
@@ -33,7 +34,7 @@ const A11yText = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
33
34
|
// see https://github.com/facebook/react-native/issues/30851#issuecomment-790165489
|
|
34
35
|
accessible: _Platform.default.OS === 'ios',
|
|
35
36
|
accessibilityLabel: text,
|
|
36
|
-
accessibilityRole: heading ? 'header' :
|
|
37
|
+
accessibilityRole: heading ? 'header' : role,
|
|
37
38
|
...rest
|
|
38
39
|
});
|
|
39
40
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
@@ -52,7 +53,11 @@ A11yText.propTypes = {
|
|
|
52
53
|
/**
|
|
53
54
|
* Whether text should be rendered as a heading
|
|
54
55
|
*/
|
|
55
|
-
heading: _propTypes.default.bool
|
|
56
|
+
heading: _propTypes.default.bool,
|
|
57
|
+
/**
|
|
58
|
+
* Role of the element
|
|
59
|
+
*/
|
|
60
|
+
role: _propTypes.default.string
|
|
56
61
|
};
|
|
57
62
|
const styles = _StyleSheet.default.create({
|
|
58
63
|
invisible: {
|
|
@@ -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;
|
package/lib/Card/CardBase.js
CHANGED
|
@@ -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:
|
|
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;
|
package/lib/Carousel/Carousel.js
CHANGED
|
@@ -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
|
-
|
|
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((
|
|
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
|
-
} =
|
|
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:
|
|
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;
|
|
@@ -23,6 +23,7 @@ const FieldsetContainer = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
23
23
|
name: fieldsetName,
|
|
24
24
|
showBorderStyle = false,
|
|
25
25
|
borderStyle,
|
|
26
|
+
style,
|
|
26
27
|
...rest
|
|
27
28
|
} = _ref;
|
|
28
29
|
// If needs border for error design or reset the component style
|
|
@@ -30,7 +31,10 @@ const FieldsetContainer = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
30
31
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("fieldset", {
|
|
31
32
|
ref: ref,
|
|
32
33
|
disabled: inactive,
|
|
33
|
-
style:
|
|
34
|
+
style: {
|
|
35
|
+
...styleContainer,
|
|
36
|
+
...style
|
|
37
|
+
},
|
|
34
38
|
role: accessibilityRole,
|
|
35
39
|
name: fieldsetName,
|
|
36
40
|
...selectProps(rest),
|
|
@@ -45,7 +49,8 @@ FieldsetContainer.propTypes = {
|
|
|
45
49
|
inactive: _propTypes.default.bool,
|
|
46
50
|
name: _propTypes.default.string,
|
|
47
51
|
showBorderStyle: _propTypes.default.bool,
|
|
48
|
-
borderStyle: _propTypes.default.object
|
|
52
|
+
borderStyle: _propTypes.default.object,
|
|
53
|
+
style: _propTypes.default.object
|
|
49
54
|
};
|
|
50
55
|
var _default = FieldsetContainer;
|
|
51
56
|
exports.default = _default;
|
|
@@ -18,12 +18,14 @@ const FieldsetContainer = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
|
|
|
18
18
|
let {
|
|
19
19
|
children,
|
|
20
20
|
accessibilityRole,
|
|
21
|
+
style,
|
|
21
22
|
...rest
|
|
22
23
|
} = _ref;
|
|
23
24
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
24
25
|
ref: ref,
|
|
25
26
|
accessibilityRole: accessibilityRole,
|
|
26
27
|
...selectProps(rest),
|
|
28
|
+
style: style,
|
|
27
29
|
children: children
|
|
28
30
|
});
|
|
29
31
|
});
|
|
@@ -31,7 +33,8 @@ FieldsetContainer.displayName = 'FieldsetContainer';
|
|
|
31
33
|
FieldsetContainer.propTypes = {
|
|
32
34
|
...selectedSystemPropTypes,
|
|
33
35
|
children: _propTypes.default.node,
|
|
34
|
-
accessibilityRole: _propTypes.default.string
|
|
36
|
+
accessibilityRole: _propTypes.default.string,
|
|
37
|
+
style: _propTypes.default.object
|
|
35
38
|
};
|
|
36
39
|
var _default = FieldsetContainer;
|
|
37
40
|
exports.default = _default;
|