@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.
- package/CHANGELOG.md +32 -3
- package/lib/Autocomplete/Autocomplete.js +2 -1
- 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/DownloadApp/DownloadApp.js +168 -0
- package/lib/DownloadApp/dictionary.js +17 -0
- package/lib/DownloadApp/index.js +10 -0
- 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/Icon/IconText.js +19 -2
- package/lib/Link/LinkBase.js +2 -2
- package/lib/Link/TextButton.js +7 -17
- package/lib/Modal/Modal.js +1 -1
- 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/TabBar/TabBar.js +133 -0
- package/lib/TabBar/TabBarItem.js +184 -0
- package/lib/TabBar/index.js +10 -0
- package/lib/TextInput/TextInputBase.js +2 -1
- package/lib/Tooltip/getTooltipPosition.js +8 -9
- package/lib/index.js +24 -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/Autocomplete/Autocomplete.js +2 -1
- 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/DownloadApp/DownloadApp.js +160 -0
- package/lib-module/DownloadApp/dictionary.js +10 -0
- package/lib-module/DownloadApp/index.js +2 -0
- 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/Icon/IconText.js +19 -2
- package/lib-module/Link/LinkBase.js +2 -2
- package/lib-module/Link/TextButton.js +7 -17
- package/lib-module/Modal/Modal.js +1 -1
- 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/TabBar/TabBar.js +125 -0
- package/lib-module/TabBar/TabBarItem.js +177 -0
- package/lib-module/TabBar/index.js +2 -0
- package/lib-module/TextInput/TextInputBase.js +2 -1
- package/lib-module/Tooltip/getTooltipPosition.js +8 -9
- package/lib-module/index.js +3 -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/Autocomplete/Autocomplete.jsx +2 -1
- 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/DownloadApp/DownloadApp.jsx +165 -0
- package/src/DownloadApp/dictionary.js +10 -0
- package/src/DownloadApp/index.js +3 -0
- 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/Icon/IconText.jsx +21 -4
- package/src/Link/LinkBase.jsx +2 -2
- package/src/Link/TextButton.jsx +10 -17
- package/src/Modal/Modal.jsx +1 -1
- 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/TabBar/TabBar.jsx +123 -0
- package/src/TabBar/TabBarItem.jsx +149 -0
- package/src/TabBar/index.js +3 -0
- package/src/TextInput/TextInputBase.jsx +1 -1
- package/src/Tooltip/getTooltipPosition.js +11 -12
- package/src/index.js +3 -0
- package/src/utils/convertFromMegaByteToByte.js +11 -0
- package/src/utils/formatImageSource.js +29 -0
- package/src/utils/index.js +2 -0
|
@@ -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'
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import { Pressable, Platform, StyleSheet } from 'react-native'
|
|
4
|
+
import {
|
|
5
|
+
a11yProps,
|
|
6
|
+
linkProps,
|
|
7
|
+
hrefAttrsProp,
|
|
8
|
+
viewProps,
|
|
9
|
+
getTokensPropType,
|
|
10
|
+
resolvePressableTokens,
|
|
11
|
+
variantProp,
|
|
12
|
+
copyPropTypes,
|
|
13
|
+
selectSystemProps,
|
|
14
|
+
useCopy
|
|
15
|
+
} from '../utils'
|
|
16
|
+
import { useThemeTokensCallback } from '../ThemeProvider'
|
|
17
|
+
import defaultDictionary from './dictionary'
|
|
18
|
+
|
|
19
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, linkProps, viewProps])
|
|
20
|
+
|
|
21
|
+
const selectOuterStyles = ({ borderColor, borderWidth, borderGap, borderRadius, padding }) => ({
|
|
22
|
+
outline: 'none',
|
|
23
|
+
borderColor,
|
|
24
|
+
borderWidth,
|
|
25
|
+
borderGap,
|
|
26
|
+
borderRadius,
|
|
27
|
+
padding
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const DownloadApp = React.forwardRef(
|
|
31
|
+
(
|
|
32
|
+
{
|
|
33
|
+
copy = 'en',
|
|
34
|
+
dictionary = defaultDictionary,
|
|
35
|
+
type = 'ios',
|
|
36
|
+
href,
|
|
37
|
+
onPress,
|
|
38
|
+
tokens = {},
|
|
39
|
+
variant = {},
|
|
40
|
+
...props
|
|
41
|
+
},
|
|
42
|
+
ref
|
|
43
|
+
) => {
|
|
44
|
+
const getCopy = useCopy({ dictionary, copy })
|
|
45
|
+
const { hrefAttrs, rest } = hrefAttrsProp.bundle(props)
|
|
46
|
+
|
|
47
|
+
const selectedProps = selectProps({
|
|
48
|
+
accessibilityRole: href ? 'link' : 'button',
|
|
49
|
+
href,
|
|
50
|
+
onPress: linkProps.handleHref({ href, onPress }),
|
|
51
|
+
hrefAttrs,
|
|
52
|
+
...rest
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const getDownloadAppTokens = useThemeTokensCallback('DownloadApp', tokens, variant)
|
|
56
|
+
const resolveDownloadAppTokens = (pressableState) => {
|
|
57
|
+
const themeTokens = resolvePressableTokens(getDownloadAppTokens, pressableState, {})
|
|
58
|
+
return selectOuterStyles(themeTokens)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const { androidENIcon, androidFRIcon, iosENIcon, iosFRIcon } = getDownloadAppTokens()
|
|
62
|
+
|
|
63
|
+
const imageResources = {
|
|
64
|
+
en: {
|
|
65
|
+
android: androidENIcon,
|
|
66
|
+
ios: iosENIcon
|
|
67
|
+
},
|
|
68
|
+
fr: {
|
|
69
|
+
android: androidFRIcon,
|
|
70
|
+
ios: iosFRIcon
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const IconComponent = imageResources[copy][type]
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Pressable
|
|
77
|
+
ref={ref}
|
|
78
|
+
style={(pressState) => [resolveDownloadAppTokens(pressState), staticStyles.row]}
|
|
79
|
+
{...selectedProps}
|
|
80
|
+
>
|
|
81
|
+
<IconComponent
|
|
82
|
+
style={staticImageSizes[type][copy]}
|
|
83
|
+
alt={type === 'ios' ? getCopy('altTextIos') : getCopy('altTextAndroid')}
|
|
84
|
+
/>
|
|
85
|
+
</Pressable>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
DownloadApp.displayName = 'DownloadApp'
|
|
90
|
+
|
|
91
|
+
const dictionaryContentShape = PropTypes.shape({
|
|
92
|
+
altTextAndroid: PropTypes.string.isRequired,
|
|
93
|
+
altTextIos: PropTypes.string.isRequired
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
DownloadApp.propTypes = {
|
|
97
|
+
...selectedSystemPropTypes,
|
|
98
|
+
copy: copyPropTypes,
|
|
99
|
+
/**
|
|
100
|
+
* Override the default dictionary, by passing the complete dictionary object for `en` and `fr`
|
|
101
|
+
*/
|
|
102
|
+
dictionary: PropTypes.shape({
|
|
103
|
+
en: dictionaryContentShape,
|
|
104
|
+
fr: dictionaryContentShape
|
|
105
|
+
}),
|
|
106
|
+
/**
|
|
107
|
+
* Select the type of image to show.
|
|
108
|
+
*/
|
|
109
|
+
type: PropTypes.oneOf(['android', 'ios']),
|
|
110
|
+
/**
|
|
111
|
+
* It's a simple link that opens the Download Button instead of the onPress function.
|
|
112
|
+
*/
|
|
113
|
+
href: PropTypes.string,
|
|
114
|
+
/**
|
|
115
|
+
* Function called when the button is pressed. Required unless the button has a href.
|
|
116
|
+
*/
|
|
117
|
+
onPress: PropTypes.func,
|
|
118
|
+
/**
|
|
119
|
+
* DownloadApp tokens.
|
|
120
|
+
*/
|
|
121
|
+
tokens: getTokensPropType('DownloadApp'),
|
|
122
|
+
/**
|
|
123
|
+
* DownloadApp variant.
|
|
124
|
+
*/
|
|
125
|
+
variant: variantProp.propType
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const staticStyles = StyleSheet.create({
|
|
129
|
+
row: {
|
|
130
|
+
...Platform.select({
|
|
131
|
+
web: {
|
|
132
|
+
display: 'inline-flex',
|
|
133
|
+
width: 'fit-content'
|
|
134
|
+
},
|
|
135
|
+
default: {
|
|
136
|
+
alignSelf: 'flex-start'
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
const staticImageSizes = {
|
|
143
|
+
android: {
|
|
144
|
+
en: {
|
|
145
|
+
width: 162,
|
|
146
|
+
height: 48
|
|
147
|
+
},
|
|
148
|
+
fr: {
|
|
149
|
+
width: 162,
|
|
150
|
+
height: 48
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
ios: {
|
|
154
|
+
en: {
|
|
155
|
+
width: 144,
|
|
156
|
+
height: 48
|
|
157
|
+
},
|
|
158
|
+
fr: {
|
|
159
|
+
width: 152,
|
|
160
|
+
height: 48
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export default DownloadApp
|
|
@@ -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
|