@telus-uds/components-base 3.7.1 → 3.8.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 +19 -2
- package/lib/cjs/ActivityIndicator/FullScreenIndicator.js +89 -0
- package/lib/cjs/ActivityIndicator/InlineIndicator.js +64 -0
- package/lib/cjs/ActivityIndicator/OverlayIndicator.js +156 -0
- package/lib/cjs/ActivityIndicator/RenderActivityIndicator.js +88 -0
- package/lib/cjs/ActivityIndicator/index.js +91 -23
- package/lib/cjs/ActivityIndicator/shared.js +12 -1
- package/lib/cjs/ActivityIndicator/sharedProptypes.js +67 -0
- package/lib/cjs/Card/Card.js +38 -45
- package/lib/cjs/ExpandCollapseMini/ExpandCollapseMiniControl.js +1 -1
- package/lib/cjs/List/ListItemMark.js +13 -2
- package/lib/cjs/MultiSelectFilter/ModalOverlay.js +12 -3
- package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +9 -2
- package/lib/cjs/utils/index.js +9 -1
- package/lib/cjs/utils/useDetectOutsideClick.js +39 -0
- package/lib/cjs/utils/useVariants.js +46 -0
- package/lib/esm/ActivityIndicator/FullScreenIndicator.js +82 -0
- package/lib/esm/ActivityIndicator/InlineIndicator.js +57 -0
- package/lib/esm/ActivityIndicator/OverlayIndicator.js +149 -0
- package/lib/esm/ActivityIndicator/RenderActivityIndicator.js +83 -0
- package/lib/esm/ActivityIndicator/index.js +89 -23
- package/lib/esm/ActivityIndicator/shared.js +11 -0
- package/lib/esm/ActivityIndicator/sharedProptypes.js +61 -0
- package/lib/esm/Card/Card.js +38 -45
- package/lib/esm/ExpandCollapseMini/ExpandCollapseMiniControl.js +1 -1
- package/lib/esm/List/ListItemMark.js +13 -2
- package/lib/esm/MultiSelectFilter/ModalOverlay.js +12 -3
- package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +9 -2
- package/lib/esm/utils/index.js +2 -1
- package/lib/esm/utils/useDetectOutsideClick.js +31 -0
- package/lib/esm/utils/useVariants.js +41 -0
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/ActivityIndicator/FullScreenIndicator.jsx +65 -0
- package/src/ActivityIndicator/InlineIndicator.jsx +47 -0
- package/src/ActivityIndicator/OverlayIndicator.jsx +140 -0
- package/src/ActivityIndicator/RenderActivityIndicator.jsx +82 -0
- package/src/ActivityIndicator/index.jsx +113 -32
- package/src/ActivityIndicator/shared.js +11 -0
- package/src/ActivityIndicator/sharedProptypes.js +62 -0
- package/src/Card/Card.jsx +51 -54
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +1 -1
- package/src/List/ListItemMark.jsx +18 -2
- package/src/MultiSelectFilter/ModalOverlay.jsx +15 -3
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +9 -2
- package/src/utils/index.js +1 -0
- package/src/utils/useDetectOutsideClick.js +35 -0
- package/src/utils/useVariants.js +44 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, StyleSheet, Platform } from 'react-native'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import StackView from '../StackView'
|
|
5
|
+
import Typography from '../Typography'
|
|
6
|
+
import RenderActivityIndicator from './RenderActivityIndicator'
|
|
7
|
+
import { BACKDROP_Z_INDEX, SPACE_WITH_LABEL, SPACE_WITHOUT_LABEL } from './shared'
|
|
8
|
+
import { activityIndicatorCommonProps } from './sharedProptypes'
|
|
9
|
+
|
|
10
|
+
const FullScreenIndicator = React.forwardRef(
|
|
11
|
+
({ variantProps, label, labelPosition, labelMapping, backgroundColor, showLabel }, ref) => (
|
|
12
|
+
<View style={[staticStyles.fullScreenOverlay, { backgroundColor }]}>
|
|
13
|
+
<StackView
|
|
14
|
+
space={showLabel ? SPACE_WITH_LABEL : SPACE_WITHOUT_LABEL}
|
|
15
|
+
tokens={{ alignItems: 'center' }}
|
|
16
|
+
direction={labelMapping[labelPosition]}
|
|
17
|
+
>
|
|
18
|
+
<RenderActivityIndicator {...variantProps} ref={ref} label={label} />
|
|
19
|
+
{showLabel && <Typography>{label}</Typography>}
|
|
20
|
+
</StackView>
|
|
21
|
+
</View>
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
FullScreenIndicator.displayName = 'FullScreenIndicator'
|
|
26
|
+
|
|
27
|
+
const staticStyles = StyleSheet.create({
|
|
28
|
+
fullScreenOverlay: {
|
|
29
|
+
...Platform.select({
|
|
30
|
+
web: {
|
|
31
|
+
position: 'fixed',
|
|
32
|
+
top: 0,
|
|
33
|
+
left: 0,
|
|
34
|
+
width: '100vw',
|
|
35
|
+
height: '100vh',
|
|
36
|
+
zIndex: BACKDROP_Z_INDEX,
|
|
37
|
+
justifyContent: 'center',
|
|
38
|
+
alignItems: 'center'
|
|
39
|
+
},
|
|
40
|
+
default: {
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: 0,
|
|
43
|
+
left: 0,
|
|
44
|
+
right: 0,
|
|
45
|
+
bottom: 0,
|
|
46
|
+
justifyContent: 'center',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
...(Platform.OS === 'android' ? { elevation: 5 } : { zIndex: BACKDROP_Z_INDEX })
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
FullScreenIndicator.propTypes = {
|
|
55
|
+
/**
|
|
56
|
+
* Shared props
|
|
57
|
+
* */
|
|
58
|
+
...activityIndicatorCommonProps,
|
|
59
|
+
/**
|
|
60
|
+
* Background color for overlay
|
|
61
|
+
* */
|
|
62
|
+
backgroundColor: PropTypes.string.isRequired
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default FullScreenIndicator
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, StyleSheet, Platform } from 'react-native'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import StackView from '../StackView'
|
|
5
|
+
import Typography from '../Typography'
|
|
6
|
+
import RenderActivityIndicator from './RenderActivityIndicator'
|
|
7
|
+
import { activityIndicatorCommonProps } from './sharedProptypes'
|
|
8
|
+
import { SPACE_WITH_LABEL, SPACE_WITHOUT_LABEL } from './shared'
|
|
9
|
+
|
|
10
|
+
const InlineIndicator = React.forwardRef(
|
|
11
|
+
({ variantProps, label, labelPosition, labelMapping, showLabel }, ref) => (
|
|
12
|
+
<View style={staticStyles.container}>
|
|
13
|
+
<StackView
|
|
14
|
+
space={showLabel ? SPACE_WITH_LABEL : SPACE_WITHOUT_LABEL}
|
|
15
|
+
direction={labelMapping[labelPosition]}
|
|
16
|
+
tokens={{ alignItems: 'center' }}
|
|
17
|
+
>
|
|
18
|
+
<RenderActivityIndicator {...variantProps} ref={ref} label={label} />
|
|
19
|
+
{showLabel && <Typography>{label}</Typography>}
|
|
20
|
+
</StackView>
|
|
21
|
+
</View>
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
InlineIndicator.displayName = 'InlineIndicator'
|
|
26
|
+
|
|
27
|
+
const staticStyles = StyleSheet.create({
|
|
28
|
+
container: {
|
|
29
|
+
flexDirection: 'column',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
display: Platform.OS === 'web' ? 'inline-flex' : 'flex',
|
|
32
|
+
alignSelf: 'flex-start'
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
InlineIndicator.propTypes = {
|
|
37
|
+
/**
|
|
38
|
+
* Shared props
|
|
39
|
+
* */
|
|
40
|
+
...activityIndicatorCommonProps,
|
|
41
|
+
/**
|
|
42
|
+
* Whether the indicator sits inline with text/other elements
|
|
43
|
+
* */
|
|
44
|
+
inline: PropTypes.bool
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default InlineIndicator
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, Platform, StyleSheet } from 'react-native'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import StackView from '../StackView'
|
|
5
|
+
import Typography from '../Typography'
|
|
6
|
+
import RenderActivityIndicator from './RenderActivityIndicator'
|
|
7
|
+
import { BACKDROP_Z_INDEX, BACKDROP_OPACITY, SPACE_WITH_LABEL, SPACE_WITHOUT_LABEL } from './shared'
|
|
8
|
+
import { activityIndicatorCommonProps } from './sharedProptypes'
|
|
9
|
+
|
|
10
|
+
const recursiveMap = (nodeChildren, fn) =>
|
|
11
|
+
React.Children.map(nodeChildren, (child) => {
|
|
12
|
+
if (!React.isValidElement(child)) return child
|
|
13
|
+
if (child.props?.children) {
|
|
14
|
+
return fn(
|
|
15
|
+
React.cloneElement(child, {
|
|
16
|
+
children: recursiveMap(child.props.children, fn)
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
return fn(child)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const OverlayIndicator = React.forwardRef(
|
|
24
|
+
(
|
|
25
|
+
{
|
|
26
|
+
variantProps,
|
|
27
|
+
label,
|
|
28
|
+
labelPosition,
|
|
29
|
+
labelMapping,
|
|
30
|
+
children,
|
|
31
|
+
inline,
|
|
32
|
+
showLabel,
|
|
33
|
+
isActive = true
|
|
34
|
+
},
|
|
35
|
+
ref
|
|
36
|
+
) => {
|
|
37
|
+
const safeChildren =
|
|
38
|
+
Platform.OS === 'web' && isActive
|
|
39
|
+
? recursiveMap(children, (c) =>
|
|
40
|
+
React.isValidElement(c) ? React.cloneElement(c, { role: 'presentation' }) : c
|
|
41
|
+
)
|
|
42
|
+
: children
|
|
43
|
+
|
|
44
|
+
// inline + children
|
|
45
|
+
if (inline && children) {
|
|
46
|
+
return (
|
|
47
|
+
<View
|
|
48
|
+
style={[staticStyles.container, Platform.OS === 'web' && staticStyles.inlineContainer]}
|
|
49
|
+
>
|
|
50
|
+
<View style={staticStyles.backdropContainer}>{safeChildren}</View>
|
|
51
|
+
<View style={staticStyles.buttonOverlaySpinner}>
|
|
52
|
+
<RenderActivityIndicator {...variantProps} ref={ref} label={label} />
|
|
53
|
+
</View>
|
|
54
|
+
</View>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// overlay
|
|
59
|
+
return (
|
|
60
|
+
<View style={staticStyles.container}>
|
|
61
|
+
<View style={staticStyles.backdropContainer}>{safeChildren}</View>
|
|
62
|
+
|
|
63
|
+
<View
|
|
64
|
+
style={[
|
|
65
|
+
staticStyles.overlayContainer,
|
|
66
|
+
Platform.OS === 'web' && staticStyles.webOverlayContainer
|
|
67
|
+
]}
|
|
68
|
+
>
|
|
69
|
+
<StackView
|
|
70
|
+
space={showLabel ? SPACE_WITH_LABEL : SPACE_WITHOUT_LABEL}
|
|
71
|
+
tokens={{ alignItems: 'center' }}
|
|
72
|
+
direction={labelMapping[labelPosition]}
|
|
73
|
+
>
|
|
74
|
+
<RenderActivityIndicator {...variantProps} ref={ref} label={label} />
|
|
75
|
+
{showLabel && <Typography>{label}</Typography>}
|
|
76
|
+
</StackView>
|
|
77
|
+
</View>
|
|
78
|
+
</View>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
OverlayIndicator.displayName = 'OverlayIndicator'
|
|
84
|
+
|
|
85
|
+
const staticStyles = StyleSheet.create({
|
|
86
|
+
container: { position: 'relative' },
|
|
87
|
+
inlineContainer: { display: 'inline-flex' },
|
|
88
|
+
backdropContainer: { opacity: BACKDROP_OPACITY },
|
|
89
|
+
overlayContainer: {
|
|
90
|
+
position: 'absolute',
|
|
91
|
+
top: '50%',
|
|
92
|
+
left: '50%',
|
|
93
|
+
...Platform.select({
|
|
94
|
+
ios: { zIndex: BACKDROP_Z_INDEX },
|
|
95
|
+
android: { elevation: 5 }
|
|
96
|
+
})
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
webOverlayContainer: {
|
|
100
|
+
transform: [{ translateX: '-50%' }, { translateY: '-50%' }],
|
|
101
|
+
zIndex: BACKDROP_Z_INDEX
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
buttonOverlaySpinner: {
|
|
105
|
+
position: 'absolute',
|
|
106
|
+
top: '50%',
|
|
107
|
+
left: '50%',
|
|
108
|
+
...Platform.select({
|
|
109
|
+
web: {
|
|
110
|
+
transform: 'translate(-50%, -50%)',
|
|
111
|
+
zIndex: BACKDROP_Z_INDEX
|
|
112
|
+
},
|
|
113
|
+
default: {
|
|
114
|
+
transform: [{ translateX: -0.5 }, { translateY: -0.5 }],
|
|
115
|
+
zIndex: BACKDROP_Z_INDEX
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
OverlayIndicator.propTypes = {
|
|
122
|
+
/**
|
|
123
|
+
* Shared props
|
|
124
|
+
* */
|
|
125
|
+
...activityIndicatorCommonProps,
|
|
126
|
+
/**
|
|
127
|
+
* Background color for overlay
|
|
128
|
+
* */
|
|
129
|
+
inline: PropTypes.bool,
|
|
130
|
+
/**
|
|
131
|
+
* Children on which the overlay is drawn
|
|
132
|
+
* */
|
|
133
|
+
children: PropTypes.node,
|
|
134
|
+
/**
|
|
135
|
+
* Controls whether the overlay is active and should apply the presentation role
|
|
136
|
+
* */
|
|
137
|
+
isActive: PropTypes.bool
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default OverlayIndicator
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import Spinner from './Spinner'
|
|
4
|
+
import Dots from './Dots'
|
|
5
|
+
import { DOTS_STYLE } from './shared'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Return <Dots/> or <Spinner/> based on `variant?.dots`.
|
|
9
|
+
* Reused in all the variants of the component.
|
|
10
|
+
*/
|
|
11
|
+
const RenderActivityIndicator = React.forwardRef(
|
|
12
|
+
(
|
|
13
|
+
{ variant = {}, dotSize, size, color, indicatorBackgroundColor, thickness, label, isStatic },
|
|
14
|
+
ref
|
|
15
|
+
) => {
|
|
16
|
+
const { dots, style } = variant || {}
|
|
17
|
+
const isDots = dots === true || style === DOTS_STYLE
|
|
18
|
+
|
|
19
|
+
return isDots ? (
|
|
20
|
+
<Dots
|
|
21
|
+
ref={ref}
|
|
22
|
+
size={dotSize}
|
|
23
|
+
color={color}
|
|
24
|
+
indicatorBackgroundColor={indicatorBackgroundColor}
|
|
25
|
+
label={label}
|
|
26
|
+
isStatic={isStatic}
|
|
27
|
+
/>
|
|
28
|
+
) : (
|
|
29
|
+
<Spinner
|
|
30
|
+
ref={ref}
|
|
31
|
+
size={size}
|
|
32
|
+
color={color}
|
|
33
|
+
indicatorBackgroundColor={indicatorBackgroundColor}
|
|
34
|
+
thickness={thickness}
|
|
35
|
+
label={label}
|
|
36
|
+
isStatic={isStatic}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
RenderActivityIndicator.displayName = 'RenderActivityIndicator'
|
|
43
|
+
|
|
44
|
+
RenderActivityIndicator.propTypes = {
|
|
45
|
+
/**
|
|
46
|
+
* ActivityIndicator variants
|
|
47
|
+
* */
|
|
48
|
+
variant: PropTypes.shape({
|
|
49
|
+
dots: PropTypes.bool,
|
|
50
|
+
style: PropTypes.oneOf([DOTS_STYLE])
|
|
51
|
+
}),
|
|
52
|
+
/**
|
|
53
|
+
* Size of the dots
|
|
54
|
+
* */
|
|
55
|
+
dotSize: PropTypes.number,
|
|
56
|
+
/**
|
|
57
|
+
* Size of the spinner
|
|
58
|
+
* */
|
|
59
|
+
size: PropTypes.number,
|
|
60
|
+
/**
|
|
61
|
+
* Primary color
|
|
62
|
+
* */
|
|
63
|
+
color: PropTypes.string,
|
|
64
|
+
/**
|
|
65
|
+
* Secondary color (background) of the indicator
|
|
66
|
+
* */
|
|
67
|
+
indicatorBackgroundColor: PropTypes.string,
|
|
68
|
+
/**
|
|
69
|
+
* Thickness of the indicator
|
|
70
|
+
* */
|
|
71
|
+
thickness: PropTypes.number,
|
|
72
|
+
/**
|
|
73
|
+
* Label for the ActivityIndicator
|
|
74
|
+
* */
|
|
75
|
+
label: PropTypes.string,
|
|
76
|
+
/**
|
|
77
|
+
* if true, there's no animation for ActivityIndicator
|
|
78
|
+
* */
|
|
79
|
+
isStatic: PropTypes.bool
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default RenderActivityIndicator
|
|
@@ -1,42 +1,95 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
+
import { Platform } from 'react-native'
|
|
4
|
+
import { useScrollBlocking } from '../utils'
|
|
3
5
|
import { useThemeTokens } from '../ThemeProvider'
|
|
4
6
|
import { getTokensPropType, variantProp } from '../utils/props'
|
|
5
7
|
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
+
import FullScreenIndicator from './FullScreenIndicator'
|
|
9
|
+
import OverlayIndicator from './OverlayIndicator'
|
|
10
|
+
import InlineIndicator from './InlineIndicator'
|
|
11
|
+
|
|
12
|
+
const labelMapping = {
|
|
13
|
+
top: 'column-reverse',
|
|
14
|
+
bottom: 'column',
|
|
15
|
+
left: 'row-reverse',
|
|
16
|
+
right: 'row'
|
|
17
|
+
}
|
|
8
18
|
|
|
9
19
|
/**
|
|
10
20
|
* `ActivityIndicator` renders a visual loading state.
|
|
11
21
|
* It does not handle positioning or layout of that visual loader.
|
|
12
22
|
*/
|
|
13
|
-
const ActivityIndicator = React.forwardRef(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
size
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
const ActivityIndicator = React.forwardRef(
|
|
24
|
+
(
|
|
25
|
+
{
|
|
26
|
+
variant,
|
|
27
|
+
tokens,
|
|
28
|
+
label,
|
|
29
|
+
labelPosition = 'bottom',
|
|
30
|
+
showLabel = true,
|
|
31
|
+
inline = false,
|
|
32
|
+
fullScreen = false,
|
|
33
|
+
overlay = false,
|
|
34
|
+
isStatic = false,
|
|
35
|
+
children,
|
|
36
|
+
fullScreenBackgroundColor
|
|
37
|
+
},
|
|
38
|
+
ref
|
|
39
|
+
) => {
|
|
40
|
+
const {
|
|
41
|
+
size,
|
|
42
|
+
dotSize,
|
|
43
|
+
color,
|
|
44
|
+
indicatorBackgroundColor,
|
|
45
|
+
fullScreenOverlayBackground,
|
|
46
|
+
thickness
|
|
47
|
+
} = useThemeTokens('ActivityIndicator', tokens, variant)
|
|
48
|
+
|
|
49
|
+
useScrollBlocking([Platform.OS === 'web' && fullScreen])
|
|
50
|
+
|
|
51
|
+
const variantProps = {
|
|
52
|
+
variant,
|
|
53
|
+
dotSize,
|
|
54
|
+
size,
|
|
55
|
+
color,
|
|
56
|
+
indicatorBackgroundColor,
|
|
57
|
+
thickness,
|
|
58
|
+
isStatic
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const visibleLabel = showLabel && !!label
|
|
62
|
+
|
|
63
|
+
const commonProps = {
|
|
64
|
+
ref,
|
|
65
|
+
variantProps,
|
|
66
|
+
label,
|
|
67
|
+
labelPosition,
|
|
68
|
+
labelMapping,
|
|
69
|
+
showLabel: visibleLabel
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
switch (true) {
|
|
73
|
+
case fullScreen:
|
|
74
|
+
return (
|
|
75
|
+
<FullScreenIndicator
|
|
76
|
+
{...commonProps}
|
|
77
|
+
backgroundColor={fullScreenBackgroundColor || fullScreenOverlayBackground}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
case overlay:
|
|
82
|
+
return (
|
|
83
|
+
<OverlayIndicator {...commonProps} inline={inline} isActive={overlay}>
|
|
84
|
+
{children}
|
|
85
|
+
</OverlayIndicator>
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
default:
|
|
89
|
+
return <InlineIndicator {...commonProps} />
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
)
|
|
40
93
|
|
|
41
94
|
ActivityIndicator.displayName = 'ActivityIndicator'
|
|
42
95
|
|
|
@@ -46,11 +99,39 @@ ActivityIndicator.propTypes = {
|
|
|
46
99
|
/**
|
|
47
100
|
* A visually hidden accessible label describing the action taking place
|
|
48
101
|
*/
|
|
49
|
-
label: PropTypes.string
|
|
102
|
+
label: PropTypes.string,
|
|
103
|
+
/**
|
|
104
|
+
* If true, it should render a static ActivityIndicator
|
|
105
|
+
*/
|
|
106
|
+
isStatic: PropTypes.bool,
|
|
107
|
+
/**
|
|
108
|
+
* Position of the label relative to ActivityIndicator
|
|
109
|
+
*/
|
|
110
|
+
labelPosition: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
|
111
|
+
/**
|
|
112
|
+
* show or hide the label
|
|
113
|
+
*/
|
|
114
|
+
showLabel: PropTypes.bool,
|
|
115
|
+
/**
|
|
116
|
+
* If true, the ActivityIndicator will be displayed in full screen mode
|
|
117
|
+
*/
|
|
118
|
+
fullScreen: PropTypes.bool,
|
|
119
|
+
/**
|
|
120
|
+
* If true, the ActivityIndicator will be displayed inline
|
|
121
|
+
*/
|
|
122
|
+
inline: PropTypes.bool,
|
|
123
|
+
/**
|
|
124
|
+
* If true, the ActivityIndicator will be displayed in overlay mode
|
|
125
|
+
*/
|
|
126
|
+
overlay: PropTypes.bool,
|
|
127
|
+
/**
|
|
128
|
+
* Children to be rendered inside ActivityIndicator
|
|
129
|
+
*/
|
|
130
|
+
children: PropTypes.node,
|
|
50
131
|
/**
|
|
51
|
-
*
|
|
132
|
+
* Background color of the full screen overlay
|
|
52
133
|
*/
|
|
53
|
-
|
|
134
|
+
fullScreenBackgroundColor: PropTypes.string
|
|
54
135
|
}
|
|
55
136
|
|
|
56
137
|
export default ActivityIndicator
|
|
@@ -51,6 +51,17 @@ export const DOT1_ANIMATION_INPUT_RANGE = [0, 0.1, 0.2, 1]
|
|
|
51
51
|
export const DOT2_ANIMATION_INPUT_RANGE = [0, 0.3, 0.4, 0.5, 1]
|
|
52
52
|
export const DOT3_ANIMATION_INPUT_RANGE = [0, 0.6, 0.7, 0.8, 1]
|
|
53
53
|
|
|
54
|
+
// Backdrop
|
|
55
|
+
export const BACKDROP_OPACITY = 0.06
|
|
56
|
+
export const BACKDROP_Z_INDEX = 1400
|
|
57
|
+
|
|
58
|
+
// Space
|
|
59
|
+
export const SPACE_WITH_LABEL = 3
|
|
60
|
+
export const SPACE_WITHOUT_LABEL = 0
|
|
61
|
+
|
|
62
|
+
// Style
|
|
63
|
+
export const DOTS_STYLE = 'dots'
|
|
64
|
+
|
|
54
65
|
export const propTypes = {
|
|
55
66
|
color: PropTypes.string.isRequired,
|
|
56
67
|
baseColor: PropTypes.string,
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* PropTypes for the 3 variants of the ActivityIndicator:
|
|
5
|
+
* - InlineIndicator
|
|
6
|
+
* - OverlayIndicator
|
|
7
|
+
* - FullScreenIndicator
|
|
8
|
+
*/
|
|
9
|
+
export const activityIndicatorVariantProps = PropTypes.shape({
|
|
10
|
+
/**
|
|
11
|
+
* Indicates the variant style for the ActivityIndicator
|
|
12
|
+
* */
|
|
13
|
+
variant: PropTypes.object,
|
|
14
|
+
/**
|
|
15
|
+
* Size of the dots
|
|
16
|
+
* */
|
|
17
|
+
dotSize: PropTypes.number,
|
|
18
|
+
/**
|
|
19
|
+
* Size of the ActivityIndicator Spinner
|
|
20
|
+
* */
|
|
21
|
+
size: PropTypes.number,
|
|
22
|
+
/**
|
|
23
|
+
* Primary color (Spinner)
|
|
24
|
+
* */
|
|
25
|
+
color: PropTypes.string,
|
|
26
|
+
/**
|
|
27
|
+
* Secondary color (background) of the indicator
|
|
28
|
+
* */
|
|
29
|
+
indicatorBackgroundColor: PropTypes.string,
|
|
30
|
+
/**
|
|
31
|
+
* Thickness of the ActivityIndicator Spinner
|
|
32
|
+
* */
|
|
33
|
+
thickness: PropTypes.number,
|
|
34
|
+
/**
|
|
35
|
+
* Indicates if the ActivityIndicator is static
|
|
36
|
+
* (not animated)
|
|
37
|
+
* */
|
|
38
|
+
isStatic: PropTypes.bool
|
|
39
|
+
}).isRequired
|
|
40
|
+
|
|
41
|
+
export const activityIndicatorCommonProps = {
|
|
42
|
+
/**
|
|
43
|
+
* Props used by RenderActivityIndicator
|
|
44
|
+
* */
|
|
45
|
+
variantProps: activityIndicatorVariantProps,
|
|
46
|
+
/**
|
|
47
|
+
* Shows or hide the label
|
|
48
|
+
* */
|
|
49
|
+
showLabel: PropTypes.bool,
|
|
50
|
+
/**
|
|
51
|
+
* A visually hidden accessible label describing the action taking place
|
|
52
|
+
*/
|
|
53
|
+
label: PropTypes.string,
|
|
54
|
+
/**
|
|
55
|
+
* Position of the label relative to ActivityIndicator
|
|
56
|
+
*/
|
|
57
|
+
labelPosition: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
|
58
|
+
/**
|
|
59
|
+
* Map of flex-direction position for label
|
|
60
|
+
* */
|
|
61
|
+
labelMapping: PropTypes.object.isRequired
|
|
62
|
+
}
|