@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/src/Card/Card.jsx
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '../ThemeProvider'
|
|
10
10
|
import { getTokensPropType, variantProp, StyleSheet, createMediaQueryStyles } from '../utils'
|
|
11
11
|
import { useViewport } from '../ViewportProvider'
|
|
12
|
-
import { a11yProps, linkProps, selectSystemProps, viewProps } from '../utils/props'
|
|
12
|
+
import { a11yProps, linkProps, selectSystemProps, viewProps, responsiveProps } from '../utils/props'
|
|
13
13
|
import CardBase from './CardBase'
|
|
14
14
|
import PressableCardBase from './PressableCardBase'
|
|
15
15
|
import CheckboxButton from '../Checkbox/CheckboxButton'
|
|
@@ -100,7 +100,10 @@ const getInputProps = ({
|
|
|
100
100
|
* depending on what you are trying to achieve.
|
|
101
101
|
*/
|
|
102
102
|
const Card = React.forwardRef(
|
|
103
|
-
(
|
|
103
|
+
(
|
|
104
|
+
{ children, tokens, variant, dataSet, onPress, id, interactiveCard, backgroundImage, ...rest },
|
|
105
|
+
ref
|
|
106
|
+
) => {
|
|
104
107
|
const viewport = useViewport()
|
|
105
108
|
const { themeOptions } = useTheme()
|
|
106
109
|
|
|
@@ -213,6 +216,7 @@ const Card = React.forwardRef(
|
|
|
213
216
|
<CardBase
|
|
214
217
|
ref={ref}
|
|
215
218
|
tokens={interactiveCard?.body ? restOfTokens : cardStyles}
|
|
219
|
+
backgroundImage={backgroundImage}
|
|
216
220
|
dataSet={mediaIds && { media: mediaIds }}
|
|
217
221
|
{...selectProps(rest)}
|
|
218
222
|
>
|
|
@@ -310,6 +314,18 @@ Card.propTypes = {
|
|
|
310
314
|
tokens: getTokensPropType('Card'),
|
|
311
315
|
selectionType: PropTypes.oneOf(Object.values(SelectionType)),
|
|
312
316
|
variant: variantProp.propType
|
|
317
|
+
}),
|
|
318
|
+
/**
|
|
319
|
+
* Apply background image to the card.
|
|
320
|
+
*/
|
|
321
|
+
backgroundImage: PropTypes.shape({
|
|
322
|
+
// The image src is either a URI string or a number (when a local image src is bundled in IOS or Android app)
|
|
323
|
+
// src is an object when used responsively to provide different image sources for different screen sizes
|
|
324
|
+
src: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,
|
|
325
|
+
alt: PropTypes.string,
|
|
326
|
+
resizeMode: responsiveProps.getTypeOptionallyByViewport(
|
|
327
|
+
PropTypes.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center'])
|
|
328
|
+
)
|
|
313
329
|
})
|
|
314
330
|
}
|
|
315
331
|
|
package/src/Card/CardBase.jsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import { View, Platform } from 'react-native'
|
|
3
|
+
import { View, Platform, ImageBackground, StyleSheet } from 'react-native'
|
|
4
4
|
|
|
5
5
|
import { applyShadowToken } from '../ThemeProvider'
|
|
6
|
-
import { getTokensPropType } from '../utils'
|
|
6
|
+
import { getTokensPropType, responsiveProps, useResponsiveProp, formatImageSource } from '../utils'
|
|
7
7
|
import { a11yProps, viewProps, selectSystemProps } from '../utils/props'
|
|
8
8
|
|
|
9
9
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
@@ -50,21 +50,56 @@ const selectStyles = ({
|
|
|
50
50
|
* A themeless base component for Card which components can apply theme tokens to. Not
|
|
51
51
|
* intended to be used in apps or sites directly: build themed components on top of this.
|
|
52
52
|
*/
|
|
53
|
-
const CardBase = React.forwardRef(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
const CardBase = React.forwardRef(
|
|
54
|
+
({ children, tokens, dataSet, backgroundImage, ...rest }, ref) => {
|
|
55
|
+
const cardStyle = selectStyles(typeof tokens === 'function' ? tokens() : tokens)
|
|
56
|
+
const props = selectProps(rest)
|
|
57
|
+
|
|
58
|
+
const { src = '', alt = '', resizeMode = '' } = backgroundImage || {}
|
|
59
|
+
const backgroundImageResizeMode = useResponsiveProp(resizeMode, 'cover')
|
|
60
|
+
const imageSourceViewport = formatImageSource(useResponsiveProp(src))
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<View style={cardStyle} dataSet={dataSet} ref={ref} {...props}>
|
|
64
|
+
{src ? (
|
|
65
|
+
<ImageBackground
|
|
66
|
+
alt={alt}
|
|
67
|
+
source={imageSourceViewport}
|
|
68
|
+
imageStyle={{ borderRadius: cardStyle?.borderRadius - cardStyle?.borderWidth }}
|
|
69
|
+
resizeMode={backgroundImageResizeMode}
|
|
70
|
+
style={styles.imageBackground}
|
|
71
|
+
>
|
|
72
|
+
{children}
|
|
73
|
+
</ImageBackground>
|
|
74
|
+
) : (
|
|
75
|
+
children
|
|
76
|
+
)}
|
|
77
|
+
</View>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
)
|
|
62
81
|
CardBase.displayName = 'CardBase'
|
|
63
82
|
|
|
83
|
+
const styles = StyleSheet.create({
|
|
84
|
+
imageBackground: { width: '100%', height: '100%' }
|
|
85
|
+
})
|
|
86
|
+
|
|
64
87
|
CardBase.propTypes = {
|
|
65
88
|
...selectedSystemPropTypes,
|
|
66
89
|
children: PropTypes.node,
|
|
67
|
-
tokens: getTokensPropType('Card')
|
|
90
|
+
tokens: getTokensPropType('Card'),
|
|
91
|
+
/**
|
|
92
|
+
* Apply background image to the card.
|
|
93
|
+
*/
|
|
94
|
+
backgroundImage: PropTypes.shape({
|
|
95
|
+
// The image src is either a URI string or a number (when a local image src is bundled in IOS or Android app)
|
|
96
|
+
// src is an object when used responsively to provide different image sources for different screen sizes
|
|
97
|
+
src: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,
|
|
98
|
+
alt: PropTypes.string,
|
|
99
|
+
resizeMode: responsiveProps.getTypeOptionallyByViewport(
|
|
100
|
+
PropTypes.oneOf(['cover', 'contain', 'stretch', 'repeat', 'center'])
|
|
101
|
+
)
|
|
102
|
+
})
|
|
68
103
|
}
|
|
69
104
|
|
|
70
105
|
export default CardBase
|
|
@@ -55,9 +55,9 @@ const selectContainerStyles = (width) => ({
|
|
|
55
55
|
width
|
|
56
56
|
})
|
|
57
57
|
|
|
58
|
-
const selectSwipeAreaStyles = (count, width) => ({
|
|
58
|
+
const selectSwipeAreaStyles = (count, width, enablePeeking) => ({
|
|
59
59
|
width: width * count,
|
|
60
|
-
justifyContent: 'space-between',
|
|
60
|
+
justifyContent: enablePeeking ? 'flex-start' : 'space-between',
|
|
61
61
|
flexDirection: 'row'
|
|
62
62
|
})
|
|
63
63
|
|
|
@@ -68,7 +68,8 @@ const selectControlButtonPositionStyles = ({
|
|
|
68
68
|
positionVariant,
|
|
69
69
|
buttonWidth,
|
|
70
70
|
positionProperty = getDynamicPositionProperty(),
|
|
71
|
-
spaceBetweenSlideAndButton
|
|
71
|
+
spaceBetweenSlideAndButton,
|
|
72
|
+
enablePeeking
|
|
72
73
|
}) => {
|
|
73
74
|
const styles = {}
|
|
74
75
|
if (positionVariant === 'edge') {
|
|
@@ -76,7 +77,11 @@ const selectControlButtonPositionStyles = ({
|
|
|
76
77
|
} else if (positionVariant === 'inside') {
|
|
77
78
|
styles[positionProperty] = 0
|
|
78
79
|
} else if (positionVariant === 'outside') {
|
|
79
|
-
|
|
80
|
+
if (enablePeeking) {
|
|
81
|
+
styles[positionProperty] = 0
|
|
82
|
+
} else {
|
|
83
|
+
styles[positionProperty] = -1 * (spaceBetweenSlideAndButton + buttonWidth)
|
|
84
|
+
}
|
|
80
85
|
}
|
|
81
86
|
return styles
|
|
82
87
|
}
|
|
@@ -87,7 +92,8 @@ const selectPreviousNextNavigationButtonStyles = (
|
|
|
87
92
|
spaceBetweenSlideAndPreviousNextNavigation,
|
|
88
93
|
isFirstSlide,
|
|
89
94
|
isLastSlide,
|
|
90
|
-
areStylesAppliedOnPreviousButton
|
|
95
|
+
areStylesAppliedOnPreviousButton,
|
|
96
|
+
enablePeeking
|
|
91
97
|
) => {
|
|
92
98
|
const styles = {
|
|
93
99
|
zIndex: 1,
|
|
@@ -107,11 +113,33 @@ const selectPreviousNextNavigationButtonStyles = (
|
|
|
107
113
|
positionVariant: previousNextNavigationPosition,
|
|
108
114
|
buttonWidth: previousNextNavigationButtonWidth,
|
|
109
115
|
positionProperty: getDynamicPositionProperty(areStylesAppliedOnPreviousButton),
|
|
110
|
-
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation
|
|
116
|
+
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
|
|
117
|
+
enablePeeking
|
|
111
118
|
})
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
121
|
|
|
122
|
+
const getPeekingProps = (viewport) => {
|
|
123
|
+
if (viewport === 'xs' || viewport === 'sm') {
|
|
124
|
+
return {
|
|
125
|
+
peekingFirstSpace: 48,
|
|
126
|
+
peekingGap: 16,
|
|
127
|
+
peekingLastSpace: 48,
|
|
128
|
+
peekingMarginLeft: 24,
|
|
129
|
+
peekingMarginRight: 24,
|
|
130
|
+
peekingMiddleSpace: 28
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
peekingFirstSpace: 48,
|
|
135
|
+
peekingGap: 16,
|
|
136
|
+
peekingLastSpace: 48,
|
|
137
|
+
peekingMarginLeft: 16,
|
|
138
|
+
peekingMarginRight: 16,
|
|
139
|
+
peekingMiddleSpace: 24
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
115
143
|
const selectIconStyles = ({ iconBackgroundColor }) => ({ backgroundColor: iconBackgroundColor })
|
|
116
144
|
|
|
117
145
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
@@ -204,6 +232,7 @@ const Carousel = React.forwardRef(
|
|
|
204
232
|
slideDuration = 0,
|
|
205
233
|
transitionDuration = 0,
|
|
206
234
|
autoPlay = false,
|
|
235
|
+
enablePeeking = false,
|
|
207
236
|
...rest
|
|
208
237
|
},
|
|
209
238
|
ref
|
|
@@ -301,6 +330,13 @@ const Carousel = React.forwardRef(
|
|
|
301
330
|
useNativeDriver: false,
|
|
302
331
|
duration: transitionDuration * 1000
|
|
303
332
|
}).start(handleAnimationEndToIndex)
|
|
333
|
+
} else if (enablePeeking) {
|
|
334
|
+
Animated.timing(pan, {
|
|
335
|
+
...springConfig,
|
|
336
|
+
toValue,
|
|
337
|
+
useNativeDriver: false,
|
|
338
|
+
duration: transitionDuration ? transitionDuration * 1000 : 1000
|
|
339
|
+
}).start(handleAnimationEndToIndex)
|
|
304
340
|
} else {
|
|
305
341
|
Animated.spring(pan, {
|
|
306
342
|
...springConfig,
|
|
@@ -309,7 +345,7 @@ const Carousel = React.forwardRef(
|
|
|
309
345
|
}).start(handleAnimationEndToIndex)
|
|
310
346
|
}
|
|
311
347
|
},
|
|
312
|
-
[pan, springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled]
|
|
348
|
+
[pan, springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled, enablePeeking]
|
|
313
349
|
)
|
|
314
350
|
|
|
315
351
|
const stopAutoplay = React.useCallback(() => {
|
|
@@ -676,7 +712,8 @@ const Carousel = React.forwardRef(
|
|
|
676
712
|
positionVariant: previousNextNavigationPosition,
|
|
677
713
|
buttonWidth: previousNextNavigationButtonWidth,
|
|
678
714
|
positionProperty: getDynamicPositionProperty(),
|
|
679
|
-
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation
|
|
715
|
+
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
|
|
716
|
+
enablePeeking
|
|
680
717
|
})
|
|
681
718
|
]}
|
|
682
719
|
>
|
|
@@ -698,7 +735,8 @@ const Carousel = React.forwardRef(
|
|
|
698
735
|
spaceBetweenSlideAndPreviousNextNavigation,
|
|
699
736
|
isFirstSlide,
|
|
700
737
|
isLastSlide,
|
|
701
|
-
true
|
|
738
|
+
true,
|
|
739
|
+
enablePeeking
|
|
702
740
|
)}
|
|
703
741
|
testID="previous-button-container"
|
|
704
742
|
>
|
|
@@ -731,7 +769,7 @@ const Carousel = React.forwardRef(
|
|
|
731
769
|
<View style={selectContainerStyles(containerLayout.width)}>
|
|
732
770
|
<Animated.View
|
|
733
771
|
style={StyleSheet.flatten([
|
|
734
|
-
selectSwipeAreaStyles(childrenArray.length, containerLayout.width),
|
|
772
|
+
selectSwipeAreaStyles(childrenArray.length, containerLayout.width, enablePeeking),
|
|
735
773
|
{
|
|
736
774
|
transform: [{ translateX: pan.x }, { translateY: pan.y }]
|
|
737
775
|
}
|
|
@@ -746,7 +784,9 @@ const Carousel = React.forwardRef(
|
|
|
746
784
|
const hidden = !isAnimating && index !== activeIndex
|
|
747
785
|
const clonedElement = React.cloneElement(element, {
|
|
748
786
|
elementIndex: index,
|
|
749
|
-
hidden
|
|
787
|
+
hidden: enablePeeking ? false : hidden,
|
|
788
|
+
enablePeeking,
|
|
789
|
+
peekingProps: getPeekingProps(viewport)
|
|
750
790
|
})
|
|
751
791
|
return <React.Fragment key={index.toFixed(2)}>{clonedElement}</React.Fragment>
|
|
752
792
|
})}
|
|
@@ -760,7 +800,8 @@ const Carousel = React.forwardRef(
|
|
|
760
800
|
spaceBetweenSlideAndPreviousNextNavigation,
|
|
761
801
|
isFirstSlide,
|
|
762
802
|
isLastSlide,
|
|
763
|
-
false
|
|
803
|
+
false,
|
|
804
|
+
enablePeeking
|
|
764
805
|
)}
|
|
765
806
|
testID="next-button-container"
|
|
766
807
|
>
|
|
@@ -962,7 +1003,12 @@ Carousel.propTypes = {
|
|
|
962
1003
|
* - Default value is `0`
|
|
963
1004
|
* - `autoPlay` and `slideDuration` are required to be set for this to work
|
|
964
1005
|
*/
|
|
965
|
-
transitionDuration: PropTypes.number
|
|
1006
|
+
transitionDuration: PropTypes.number,
|
|
1007
|
+
/**
|
|
1008
|
+
* If set to `true`, the Carousel will show the previous and next slides
|
|
1009
|
+
* - Default value is `false`
|
|
1010
|
+
*/
|
|
1011
|
+
enablePeeking: PropTypes.bool
|
|
966
1012
|
}
|
|
967
1013
|
|
|
968
1014
|
Carousel.Item = CarouselItem
|
|
@@ -13,13 +13,73 @@ import { useCarousel } from '../CarouselContext'
|
|
|
13
13
|
|
|
14
14
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
15
15
|
|
|
16
|
+
const selectContainerStyle = ({
|
|
17
|
+
width,
|
|
18
|
+
activeIndex,
|
|
19
|
+
elementIndex,
|
|
20
|
+
totalItems,
|
|
21
|
+
enablePeeking,
|
|
22
|
+
peekingMarginLeft,
|
|
23
|
+
peekingMarginRight,
|
|
24
|
+
peekingFirstSpace,
|
|
25
|
+
peekingLastSpace,
|
|
26
|
+
peekingMiddleSpace,
|
|
27
|
+
peekingGap,
|
|
28
|
+
hidden
|
|
29
|
+
}) => {
|
|
30
|
+
const isFirst = elementIndex === 0
|
|
31
|
+
const isLast = elementIndex === totalItems - 1
|
|
32
|
+
const isMiddle = !isFirst && !isLast
|
|
33
|
+
const isActive = activeIndex === elementIndex
|
|
34
|
+
|
|
35
|
+
let adjustedWidth = width
|
|
36
|
+
let marginLeft = 0
|
|
37
|
+
let marginRight = 0
|
|
38
|
+
|
|
39
|
+
if (enablePeeking) {
|
|
40
|
+
if (isActive) {
|
|
41
|
+
adjustedWidth = width - (peekingMarginLeft + peekingGap + peekingFirstSpace)
|
|
42
|
+
} else if (isMiddle) {
|
|
43
|
+
adjustedWidth = width - peekingGap
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (isFirst) {
|
|
47
|
+
if (isActive) {
|
|
48
|
+
marginLeft = peekingMarginLeft
|
|
49
|
+
} else if (activeIndex === totalItems - 1) {
|
|
50
|
+
marginLeft = peekingLastSpace
|
|
51
|
+
} else {
|
|
52
|
+
marginLeft = peekingMiddleSpace
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (isLast && isActive) {
|
|
57
|
+
marginRight = peekingMarginRight
|
|
58
|
+
} else {
|
|
59
|
+
marginRight = peekingGap
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const style = {
|
|
64
|
+
width: adjustedWidth,
|
|
65
|
+
marginLeft,
|
|
66
|
+
marginRight
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (hidden && Platform.OS === 'web') {
|
|
70
|
+
style.visibility = 'hidden'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return style
|
|
74
|
+
}
|
|
75
|
+
|
|
16
76
|
/**
|
|
17
77
|
* `Carousel.Item` is used to wrap the content of an individual slide and is suppsoed to be the
|
|
18
78
|
* only top-level component passed to the `Carousel`
|
|
19
79
|
*/
|
|
20
80
|
const CarouselItem = React.forwardRef(
|
|
21
|
-
({ children, elementIndex, tag = 'li', hidden, ...rest }, ref) => {
|
|
22
|
-
const { width, activeIndex } = useCarousel()
|
|
81
|
+
({ children, elementIndex, tag = 'li', hidden, enablePeeking, peekingProps, ...rest }, ref) => {
|
|
82
|
+
const { width, activeIndex, totalItems, height } = useCarousel()
|
|
23
83
|
|
|
24
84
|
const selectedProps = selectProps({
|
|
25
85
|
...rest,
|
|
@@ -27,13 +87,23 @@ const CarouselItem = React.forwardRef(
|
|
|
27
87
|
})
|
|
28
88
|
|
|
29
89
|
const focusabilityProps = activeIndex === elementIndex ? {} : a11yProps.nonFocusableProps
|
|
30
|
-
|
|
31
|
-
if (hidden && Platform.OS === 'web') {
|
|
32
|
-
// On web, visibility: hidden makes all children non-focusable. It doesn't exist on native.
|
|
33
|
-
style.visibility = 'hidden'
|
|
34
|
-
}
|
|
90
|
+
|
|
35
91
|
return (
|
|
36
|
-
<View
|
|
92
|
+
<View
|
|
93
|
+
style={selectContainerStyle({
|
|
94
|
+
width,
|
|
95
|
+
activeIndex,
|
|
96
|
+
elementIndex,
|
|
97
|
+
totalItems,
|
|
98
|
+
hidden,
|
|
99
|
+
height,
|
|
100
|
+
enablePeeking,
|
|
101
|
+
...peekingProps
|
|
102
|
+
})}
|
|
103
|
+
{...selectedProps}
|
|
104
|
+
{...focusabilityProps}
|
|
105
|
+
ref={ref}
|
|
106
|
+
>
|
|
37
107
|
{children}
|
|
38
108
|
</View>
|
|
39
109
|
)
|
|
@@ -67,7 +137,22 @@ CarouselItem.propTypes = {
|
|
|
67
137
|
/**
|
|
68
138
|
* Function to set carousel content background color when slide is being display
|
|
69
139
|
*/
|
|
70
|
-
setContentBackgroundColor: PropTypes.func
|
|
140
|
+
setContentBackgroundColor: PropTypes.func,
|
|
141
|
+
/**
|
|
142
|
+
* Boolean to enable peeking effect on the first and last slide
|
|
143
|
+
*/
|
|
144
|
+
enablePeeking: PropTypes.bool,
|
|
145
|
+
/**
|
|
146
|
+
* Object to configure the peeking effect
|
|
147
|
+
*/
|
|
148
|
+
peekingProps: PropTypes.shape({
|
|
149
|
+
peekingMarginLeft: PropTypes.number,
|
|
150
|
+
peekingMarginRight: PropTypes.number,
|
|
151
|
+
peekingFirstSpace: PropTypes.number,
|
|
152
|
+
peekingLastSpace: PropTypes.number,
|
|
153
|
+
peekingMiddleSpace: PropTypes.number,
|
|
154
|
+
peekingGap: PropTypes.number
|
|
155
|
+
})
|
|
71
156
|
}
|
|
72
157
|
|
|
73
158
|
CarouselItem.displayName = 'Carousel.Item'
|
|
@@ -19,18 +19,18 @@ const FieldsetContainer = React.forwardRef(
|
|
|
19
19
|
name: fieldsetName,
|
|
20
20
|
showBorderStyle = false,
|
|
21
21
|
borderStyle,
|
|
22
|
+
style,
|
|
22
23
|
...rest
|
|
23
24
|
},
|
|
24
25
|
ref
|
|
25
26
|
) => {
|
|
26
27
|
// If needs border for error design or reset the component style
|
|
27
28
|
const styleContainer = showBorderStyle && borderStyle ? borderStyle : cssReset
|
|
28
|
-
|
|
29
29
|
return (
|
|
30
30
|
<fieldset
|
|
31
31
|
ref={ref}
|
|
32
32
|
disabled={inactive}
|
|
33
|
-
style={styleContainer}
|
|
33
|
+
style={{ ...styleContainer, ...style }}
|
|
34
34
|
role={accessibilityRole}
|
|
35
35
|
name={fieldsetName}
|
|
36
36
|
{...selectProps(rest)}
|
|
@@ -49,7 +49,8 @@ FieldsetContainer.propTypes = {
|
|
|
49
49
|
inactive: PropTypes.bool,
|
|
50
50
|
name: PropTypes.string,
|
|
51
51
|
showBorderStyle: PropTypes.bool,
|
|
52
|
-
borderStyle: PropTypes.object
|
|
52
|
+
borderStyle: PropTypes.object,
|
|
53
|
+
style: PropTypes.object
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
export default FieldsetContainer
|
|
@@ -8,17 +8,20 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
|
|
|
8
8
|
|
|
9
9
|
// No equivalent of `<fieldset>` on native, so just apply accessibility role to container.
|
|
10
10
|
// If a11y testing finds any additional handling is needed at the container level, add it here.
|
|
11
|
-
const FieldsetContainer = React.forwardRef(
|
|
12
|
-
|
|
13
|
-
{
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const FieldsetContainer = React.forwardRef(
|
|
12
|
+
({ children, accessibilityRole, style, ...rest }, ref) => (
|
|
13
|
+
<View ref={ref} accessibilityRole={accessibilityRole} {...selectProps(rest)} style={style}>
|
|
14
|
+
{children}
|
|
15
|
+
</View>
|
|
16
|
+
)
|
|
17
|
+
)
|
|
16
18
|
FieldsetContainer.displayName = 'FieldsetContainer'
|
|
17
19
|
|
|
18
20
|
FieldsetContainer.propTypes = {
|
|
19
21
|
...selectedSystemPropTypes,
|
|
20
22
|
children: PropTypes.node,
|
|
21
|
-
accessibilityRole: PropTypes.string
|
|
23
|
+
accessibilityRole: PropTypes.string,
|
|
24
|
+
style: PropTypes.object
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
export default FieldsetContainer
|