@telus-uds/components-base 3.7.1 → 3.9.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 +34 -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 +19 -5
- package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +22 -9
- package/lib/cjs/ToggleSwitch/ToggleSwitch.js +13 -2
- package/lib/cjs/Validator/Validator.js +135 -64
- 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 +19 -5
- package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +22 -9
- package/lib/esm/ToggleSwitch/ToggleSwitch.js +13 -2
- package/lib/esm/Validator/Validator.js +135 -64
- 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 +18 -5
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +21 -10
- package/src/ToggleSwitch/ToggleSwitch.jsx +17 -2
- package/src/Validator/Validator.jsx +172 -85
- package/src/utils/index.js +1 -0
- package/src/utils/useDetectOutsideClick.js +35 -0
- package/src/utils/useVariants.js +44 -0
package/lib/cjs/utils/index.js
CHANGED
|
@@ -20,7 +20,8 @@ var _exportNames = {
|
|
|
20
20
|
transformGradient: true,
|
|
21
21
|
convertFromMegaByteToByte: true,
|
|
22
22
|
formatImageSource: true,
|
|
23
|
-
getSpacingScale: true
|
|
23
|
+
getSpacingScale: true,
|
|
24
|
+
useVariants: true
|
|
24
25
|
};
|
|
25
26
|
Object.defineProperty(exports, "BaseView", {
|
|
26
27
|
enumerable: true,
|
|
@@ -118,6 +119,12 @@ Object.defineProperty(exports, "useUniqueId", {
|
|
|
118
119
|
return _useUniqueId.default;
|
|
119
120
|
}
|
|
120
121
|
});
|
|
122
|
+
Object.defineProperty(exports, "useVariants", {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
get: function () {
|
|
125
|
+
return _useVariants.default;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
121
128
|
Object.defineProperty(exports, "withLinkRouter", {
|
|
122
129
|
enumerable: true,
|
|
123
130
|
get: function () {
|
|
@@ -248,6 +255,7 @@ var _transformGradient = require("./transformGradient");
|
|
|
248
255
|
var _convertFromMegaByteToByte = _interopRequireDefault(require("./convertFromMegaByteToByte"));
|
|
249
256
|
var _formatImageSource = _interopRequireDefault(require("./formatImageSource"));
|
|
250
257
|
var _getSpacingScale = _interopRequireDefault(require("./getSpacingScale"));
|
|
258
|
+
var _useVariants = _interopRequireDefault(require("./useVariants"));
|
|
251
259
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
252
260
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
253
261
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
/**
|
|
11
|
+
* Hook to detect clicks outside of a ref, only on web.
|
|
12
|
+
*
|
|
13
|
+
* @param {React.RefObject<HTMLElement>} ref
|
|
14
|
+
* Reference to the element you want to “protect.”
|
|
15
|
+
* @param {() => void} onOutside
|
|
16
|
+
* Callback invoked when a click occurs outside that ref.
|
|
17
|
+
* @param {boolean} [enabled=true]
|
|
18
|
+
* Flag to enable or disable the outside-click detection at runtime.
|
|
19
|
+
* @deprecated Will be removed in next major release; detection will always be enabled.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function useDetectOutsideClick(ref, onOutside) {
|
|
23
|
+
let enabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
24
|
+
_react.default.useEffect(() => {
|
|
25
|
+
if (!enabled || _Platform.default.OS !== 'web') {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const handleClickOutside = e => {
|
|
29
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
30
|
+
onOutside();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
34
|
+
return () => {
|
|
35
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
36
|
+
};
|
|
37
|
+
}, [ref, onOutside, enabled]);
|
|
38
|
+
}
|
|
39
|
+
var _default = exports.default = useDetectOutsideClick;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
8
|
+
/**
|
|
9
|
+
* Generates a label string for a variant based on the provided key and value.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} key - The name of the variant.
|
|
12
|
+
* @param {*} value - The value of the variant. If it's a string, it will be appended to the key.
|
|
13
|
+
* @returns {string} The formatted variant label (e.g., "color: red" or "size").
|
|
14
|
+
*/
|
|
15
|
+
const getVariantLabel = (key, value) => `${key}${typeof value === 'string' ? `: ${value}` : ''}`;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the variant options for a given component from the theme.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} componentName - The name of the component to get variants for.
|
|
21
|
+
* @returns {Array<Array>} An array of variant tuples. Each tuple contains:
|
|
22
|
+
* - {string|undefined} The variant key (e.g., 'size', 'color', or undefined for default).
|
|
23
|
+
* - {string|undefined} The variant value (e.g., 'small', 'primary', or undefined for default).
|
|
24
|
+
* - {string} The human-readable label for the variant.
|
|
25
|
+
* Returns [['default', {}]] if no componentName is provided.
|
|
26
|
+
* @throws {Error} If the theme does not define appearances for the given component.
|
|
27
|
+
*/
|
|
28
|
+
const useVariants = componentName => {
|
|
29
|
+
const theme = (0, _ThemeProvider.useTheme)();
|
|
30
|
+
if (!componentName) return [['default', {}]];
|
|
31
|
+
const {
|
|
32
|
+
appearances
|
|
33
|
+
} = (0, _ThemeProvider.getComponentTheme)(theme, componentName);
|
|
34
|
+
if (!appearances) {
|
|
35
|
+
throw new Error(`Theme ${theme.metadata?.name} does not have any appearances set for ${componentName}`);
|
|
36
|
+
}
|
|
37
|
+
const variants = Object.entries(appearances).reduce((pairs, _ref) => {
|
|
38
|
+
let [key, {
|
|
39
|
+
values,
|
|
40
|
+
type
|
|
41
|
+
} = {}] = _ref;
|
|
42
|
+
return type === 'variant' ? [...pairs, ...values.map(value => [key, value, getVariantLabel(key, value)])] : pairs;
|
|
43
|
+
}, [[undefined, undefined, 'default style']]);
|
|
44
|
+
return variants;
|
|
45
|
+
};
|
|
46
|
+
var _default = exports.default = useVariants;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import View from "react-native-web/dist/exports/View";
|
|
3
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import StackView from '../StackView';
|
|
7
|
+
import Typography from '../Typography';
|
|
8
|
+
import RenderActivityIndicator from './RenderActivityIndicator';
|
|
9
|
+
import { BACKDROP_Z_INDEX, SPACE_WITH_LABEL, SPACE_WITHOUT_LABEL } from './shared';
|
|
10
|
+
import { activityIndicatorCommonProps } from './sharedProptypes';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const FullScreenIndicator = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
13
|
+
let {
|
|
14
|
+
variantProps,
|
|
15
|
+
label,
|
|
16
|
+
labelPosition,
|
|
17
|
+
labelMapping,
|
|
18
|
+
backgroundColor,
|
|
19
|
+
showLabel
|
|
20
|
+
} = _ref;
|
|
21
|
+
return /*#__PURE__*/_jsx(View, {
|
|
22
|
+
style: [staticStyles.fullScreenOverlay, {
|
|
23
|
+
backgroundColor
|
|
24
|
+
}],
|
|
25
|
+
children: /*#__PURE__*/_jsxs(StackView, {
|
|
26
|
+
space: showLabel ? SPACE_WITH_LABEL : SPACE_WITHOUT_LABEL,
|
|
27
|
+
tokens: {
|
|
28
|
+
alignItems: 'center'
|
|
29
|
+
},
|
|
30
|
+
direction: labelMapping[labelPosition],
|
|
31
|
+
children: [/*#__PURE__*/_jsx(RenderActivityIndicator, {
|
|
32
|
+
...variantProps,
|
|
33
|
+
ref: ref,
|
|
34
|
+
label: label
|
|
35
|
+
}), showLabel && /*#__PURE__*/_jsx(Typography, {
|
|
36
|
+
children: label
|
|
37
|
+
})]
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
FullScreenIndicator.displayName = 'FullScreenIndicator';
|
|
42
|
+
const staticStyles = StyleSheet.create({
|
|
43
|
+
fullScreenOverlay: {
|
|
44
|
+
...Platform.select({
|
|
45
|
+
web: {
|
|
46
|
+
position: 'fixed',
|
|
47
|
+
top: 0,
|
|
48
|
+
left: 0,
|
|
49
|
+
width: '100vw',
|
|
50
|
+
height: '100vh',
|
|
51
|
+
zIndex: BACKDROP_Z_INDEX,
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
alignItems: 'center'
|
|
54
|
+
},
|
|
55
|
+
default: {
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
top: 0,
|
|
58
|
+
left: 0,
|
|
59
|
+
right: 0,
|
|
60
|
+
bottom: 0,
|
|
61
|
+
justifyContent: 'center',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
...(Platform.OS === 'android' ? {
|
|
64
|
+
elevation: 5
|
|
65
|
+
} : {
|
|
66
|
+
zIndex: BACKDROP_Z_INDEX
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
FullScreenIndicator.propTypes = {
|
|
73
|
+
/**
|
|
74
|
+
* Shared props
|
|
75
|
+
* */
|
|
76
|
+
...activityIndicatorCommonProps,
|
|
77
|
+
/**
|
|
78
|
+
* Background color for overlay
|
|
79
|
+
* */
|
|
80
|
+
backgroundColor: PropTypes.string.isRequired
|
|
81
|
+
};
|
|
82
|
+
export default FullScreenIndicator;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import View from "react-native-web/dist/exports/View";
|
|
3
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
4
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import StackView from '../StackView';
|
|
7
|
+
import Typography from '../Typography';
|
|
8
|
+
import RenderActivityIndicator from './RenderActivityIndicator';
|
|
9
|
+
import { activityIndicatorCommonProps } from './sharedProptypes';
|
|
10
|
+
import { SPACE_WITH_LABEL, SPACE_WITHOUT_LABEL } from './shared';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const InlineIndicator = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
13
|
+
let {
|
|
14
|
+
variantProps,
|
|
15
|
+
label,
|
|
16
|
+
labelPosition,
|
|
17
|
+
labelMapping,
|
|
18
|
+
showLabel
|
|
19
|
+
} = _ref;
|
|
20
|
+
return /*#__PURE__*/_jsx(View, {
|
|
21
|
+
style: staticStyles.container,
|
|
22
|
+
children: /*#__PURE__*/_jsxs(StackView, {
|
|
23
|
+
space: showLabel ? SPACE_WITH_LABEL : SPACE_WITHOUT_LABEL,
|
|
24
|
+
direction: labelMapping[labelPosition],
|
|
25
|
+
tokens: {
|
|
26
|
+
alignItems: 'center'
|
|
27
|
+
},
|
|
28
|
+
children: [/*#__PURE__*/_jsx(RenderActivityIndicator, {
|
|
29
|
+
...variantProps,
|
|
30
|
+
ref: ref,
|
|
31
|
+
label: label
|
|
32
|
+
}), showLabel && /*#__PURE__*/_jsx(Typography, {
|
|
33
|
+
children: label
|
|
34
|
+
})]
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
InlineIndicator.displayName = 'InlineIndicator';
|
|
39
|
+
const staticStyles = StyleSheet.create({
|
|
40
|
+
container: {
|
|
41
|
+
flexDirection: 'column',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
display: Platform.OS === 'web' ? 'inline-flex' : 'flex',
|
|
44
|
+
alignSelf: 'flex-start'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
InlineIndicator.propTypes = {
|
|
48
|
+
/**
|
|
49
|
+
* Shared props
|
|
50
|
+
* */
|
|
51
|
+
...activityIndicatorCommonProps,
|
|
52
|
+
/**
|
|
53
|
+
* Whether the indicator sits inline with text/other elements
|
|
54
|
+
* */
|
|
55
|
+
inline: PropTypes.bool
|
|
56
|
+
};
|
|
57
|
+
export default InlineIndicator;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import View from "react-native-web/dist/exports/View";
|
|
3
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import StackView from '../StackView';
|
|
7
|
+
import Typography from '../Typography';
|
|
8
|
+
import RenderActivityIndicator from './RenderActivityIndicator';
|
|
9
|
+
import { BACKDROP_Z_INDEX, BACKDROP_OPACITY, SPACE_WITH_LABEL, SPACE_WITHOUT_LABEL } from './shared';
|
|
10
|
+
import { activityIndicatorCommonProps } from './sharedProptypes';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const recursiveMap = (nodeChildren, fn) => React.Children.map(nodeChildren, child => {
|
|
13
|
+
if (! /*#__PURE__*/React.isValidElement(child)) return child;
|
|
14
|
+
if (child.props?.children) {
|
|
15
|
+
return fn(/*#__PURE__*/React.cloneElement(child, {
|
|
16
|
+
children: recursiveMap(child.props.children, fn)
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
return fn(child);
|
|
20
|
+
});
|
|
21
|
+
const OverlayIndicator = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
22
|
+
let {
|
|
23
|
+
variantProps,
|
|
24
|
+
label,
|
|
25
|
+
labelPosition,
|
|
26
|
+
labelMapping,
|
|
27
|
+
children,
|
|
28
|
+
inline,
|
|
29
|
+
showLabel,
|
|
30
|
+
isActive = true
|
|
31
|
+
} = _ref;
|
|
32
|
+
const safeChildren = Platform.OS === 'web' && isActive ? recursiveMap(children, c => /*#__PURE__*/React.isValidElement(c) ? /*#__PURE__*/React.cloneElement(c, {
|
|
33
|
+
role: 'presentation'
|
|
34
|
+
}) : c) : children;
|
|
35
|
+
|
|
36
|
+
// inline + children
|
|
37
|
+
if (inline && children) {
|
|
38
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
39
|
+
style: [staticStyles.container, Platform.OS === 'web' && staticStyles.inlineContainer],
|
|
40
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
41
|
+
style: staticStyles.backdropContainer,
|
|
42
|
+
children: safeChildren
|
|
43
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
44
|
+
style: staticStyles.buttonOverlaySpinner,
|
|
45
|
+
children: /*#__PURE__*/_jsx(RenderActivityIndicator, {
|
|
46
|
+
...variantProps,
|
|
47
|
+
ref: ref,
|
|
48
|
+
label: label
|
|
49
|
+
})
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// overlay
|
|
55
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
56
|
+
style: staticStyles.container,
|
|
57
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
58
|
+
style: staticStyles.backdropContainer,
|
|
59
|
+
children: safeChildren
|
|
60
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
61
|
+
style: [staticStyles.overlayContainer, Platform.OS === 'web' && staticStyles.webOverlayContainer],
|
|
62
|
+
children: /*#__PURE__*/_jsxs(StackView, {
|
|
63
|
+
space: showLabel ? SPACE_WITH_LABEL : SPACE_WITHOUT_LABEL,
|
|
64
|
+
tokens: {
|
|
65
|
+
alignItems: 'center'
|
|
66
|
+
},
|
|
67
|
+
direction: labelMapping[labelPosition],
|
|
68
|
+
children: [/*#__PURE__*/_jsx(RenderActivityIndicator, {
|
|
69
|
+
...variantProps,
|
|
70
|
+
ref: ref,
|
|
71
|
+
label: label
|
|
72
|
+
}), showLabel && /*#__PURE__*/_jsx(Typography, {
|
|
73
|
+
children: label
|
|
74
|
+
})]
|
|
75
|
+
})
|
|
76
|
+
})]
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
OverlayIndicator.displayName = 'OverlayIndicator';
|
|
80
|
+
const staticStyles = StyleSheet.create({
|
|
81
|
+
container: {
|
|
82
|
+
position: 'relative'
|
|
83
|
+
},
|
|
84
|
+
inlineContainer: {
|
|
85
|
+
display: 'inline-flex'
|
|
86
|
+
},
|
|
87
|
+
backdropContainer: {
|
|
88
|
+
opacity: BACKDROP_OPACITY
|
|
89
|
+
},
|
|
90
|
+
overlayContainer: {
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
top: '50%',
|
|
93
|
+
left: '50%',
|
|
94
|
+
...Platform.select({
|
|
95
|
+
ios: {
|
|
96
|
+
zIndex: BACKDROP_Z_INDEX
|
|
97
|
+
},
|
|
98
|
+
android: {
|
|
99
|
+
elevation: 5
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
},
|
|
103
|
+
webOverlayContainer: {
|
|
104
|
+
transform: [{
|
|
105
|
+
translateX: '-50%'
|
|
106
|
+
}, {
|
|
107
|
+
translateY: '-50%'
|
|
108
|
+
}],
|
|
109
|
+
zIndex: BACKDROP_Z_INDEX
|
|
110
|
+
},
|
|
111
|
+
buttonOverlaySpinner: {
|
|
112
|
+
position: 'absolute',
|
|
113
|
+
top: '50%',
|
|
114
|
+
left: '50%',
|
|
115
|
+
...Platform.select({
|
|
116
|
+
web: {
|
|
117
|
+
transform: 'translate(-50%, -50%)',
|
|
118
|
+
zIndex: BACKDROP_Z_INDEX
|
|
119
|
+
},
|
|
120
|
+
default: {
|
|
121
|
+
transform: [{
|
|
122
|
+
translateX: -0.5
|
|
123
|
+
}, {
|
|
124
|
+
translateY: -0.5
|
|
125
|
+
}],
|
|
126
|
+
zIndex: BACKDROP_Z_INDEX
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
OverlayIndicator.propTypes = {
|
|
132
|
+
/**
|
|
133
|
+
* Shared props
|
|
134
|
+
* */
|
|
135
|
+
...activityIndicatorCommonProps,
|
|
136
|
+
/**
|
|
137
|
+
* Background color for overlay
|
|
138
|
+
* */
|
|
139
|
+
inline: PropTypes.bool,
|
|
140
|
+
/**
|
|
141
|
+
* Children on which the overlay is drawn
|
|
142
|
+
* */
|
|
143
|
+
children: PropTypes.node,
|
|
144
|
+
/**
|
|
145
|
+
* Controls whether the overlay is active and should apply the presentation role
|
|
146
|
+
* */
|
|
147
|
+
isActive: PropTypes.bool
|
|
148
|
+
};
|
|
149
|
+
export default OverlayIndicator;
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const RenderActivityIndicator = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
13
|
+
let {
|
|
14
|
+
variant = {},
|
|
15
|
+
dotSize,
|
|
16
|
+
size,
|
|
17
|
+
color,
|
|
18
|
+
indicatorBackgroundColor,
|
|
19
|
+
thickness,
|
|
20
|
+
label,
|
|
21
|
+
isStatic
|
|
22
|
+
} = _ref;
|
|
23
|
+
const {
|
|
24
|
+
dots,
|
|
25
|
+
style
|
|
26
|
+
} = variant || {};
|
|
27
|
+
const isDots = dots === true || style === DOTS_STYLE;
|
|
28
|
+
return isDots ? /*#__PURE__*/_jsx(Dots, {
|
|
29
|
+
ref: ref,
|
|
30
|
+
size: dotSize,
|
|
31
|
+
color: color,
|
|
32
|
+
indicatorBackgroundColor: indicatorBackgroundColor,
|
|
33
|
+
label: label,
|
|
34
|
+
isStatic: isStatic
|
|
35
|
+
}) : /*#__PURE__*/_jsx(Spinner, {
|
|
36
|
+
ref: ref,
|
|
37
|
+
size: size,
|
|
38
|
+
color: color,
|
|
39
|
+
indicatorBackgroundColor: indicatorBackgroundColor,
|
|
40
|
+
thickness: thickness,
|
|
41
|
+
label: label,
|
|
42
|
+
isStatic: isStatic
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
RenderActivityIndicator.displayName = 'RenderActivityIndicator';
|
|
46
|
+
RenderActivityIndicator.propTypes = {
|
|
47
|
+
/**
|
|
48
|
+
* ActivityIndicator variants
|
|
49
|
+
* */
|
|
50
|
+
variant: PropTypes.shape({
|
|
51
|
+
dots: PropTypes.bool,
|
|
52
|
+
style: PropTypes.oneOf([DOTS_STYLE])
|
|
53
|
+
}),
|
|
54
|
+
/**
|
|
55
|
+
* Size of the dots
|
|
56
|
+
* */
|
|
57
|
+
dotSize: PropTypes.number,
|
|
58
|
+
/**
|
|
59
|
+
* Size of the spinner
|
|
60
|
+
* */
|
|
61
|
+
size: PropTypes.number,
|
|
62
|
+
/**
|
|
63
|
+
* Primary color
|
|
64
|
+
* */
|
|
65
|
+
color: PropTypes.string,
|
|
66
|
+
/**
|
|
67
|
+
* Secondary color (background) of the indicator
|
|
68
|
+
* */
|
|
69
|
+
indicatorBackgroundColor: PropTypes.string,
|
|
70
|
+
/**
|
|
71
|
+
* Thickness of the indicator
|
|
72
|
+
* */
|
|
73
|
+
thickness: PropTypes.number,
|
|
74
|
+
/**
|
|
75
|
+
* Label for the ActivityIndicator
|
|
76
|
+
* */
|
|
77
|
+
label: PropTypes.string,
|
|
78
|
+
/**
|
|
79
|
+
* if true, there's no animation for ActivityIndicator
|
|
80
|
+
* */
|
|
81
|
+
isStatic: PropTypes.bool
|
|
82
|
+
};
|
|
83
|
+
export default RenderActivityIndicator;
|
|
@@ -1,45 +1,83 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
|
+
import { useScrollBlocking } from '../utils';
|
|
3
5
|
import { useThemeTokens } from '../ThemeProvider';
|
|
4
6
|
import { getTokensPropType, variantProp } from '../utils/props';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
+
import FullScreenIndicator from './FullScreenIndicator';
|
|
8
|
+
import OverlayIndicator from './OverlayIndicator';
|
|
9
|
+
import InlineIndicator from './InlineIndicator';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const labelMapping = {
|
|
12
|
+
top: 'column-reverse',
|
|
13
|
+
bottom: 'column',
|
|
14
|
+
left: 'row-reverse',
|
|
15
|
+
right: 'row'
|
|
16
|
+
};
|
|
7
17
|
|
|
8
18
|
/**
|
|
9
19
|
* `ActivityIndicator` renders a visual loading state.
|
|
10
20
|
* It does not handle positioning or layout of that visual loader.
|
|
11
21
|
*/
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
22
|
const ActivityIndicator = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
14
23
|
let {
|
|
15
24
|
variant,
|
|
16
25
|
tokens,
|
|
17
26
|
label,
|
|
18
|
-
|
|
27
|
+
labelPosition = 'bottom',
|
|
28
|
+
showLabel = true,
|
|
29
|
+
inline = false,
|
|
30
|
+
fullScreen = false,
|
|
31
|
+
overlay = false,
|
|
32
|
+
isStatic = false,
|
|
33
|
+
children,
|
|
34
|
+
fullScreenBackgroundColor
|
|
19
35
|
} = _ref;
|
|
20
36
|
const {
|
|
21
37
|
size,
|
|
22
38
|
dotSize,
|
|
23
39
|
color,
|
|
24
40
|
indicatorBackgroundColor,
|
|
41
|
+
fullScreenOverlayBackground,
|
|
25
42
|
thickness
|
|
26
43
|
} = useThemeTokens('ActivityIndicator', tokens, variant);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
useScrollBlocking([Platform.OS === 'web' && fullScreen]);
|
|
45
|
+
const variantProps = {
|
|
46
|
+
variant,
|
|
47
|
+
dotSize,
|
|
48
|
+
size,
|
|
49
|
+
color,
|
|
50
|
+
indicatorBackgroundColor,
|
|
51
|
+
thickness,
|
|
52
|
+
isStatic
|
|
53
|
+
};
|
|
54
|
+
const visibleLabel = showLabel && !!label;
|
|
55
|
+
const commonProps = {
|
|
56
|
+
ref,
|
|
57
|
+
variantProps,
|
|
58
|
+
label,
|
|
59
|
+
labelPosition,
|
|
60
|
+
labelMapping,
|
|
61
|
+
showLabel: visibleLabel
|
|
62
|
+
};
|
|
63
|
+
switch (true) {
|
|
64
|
+
case fullScreen:
|
|
65
|
+
return /*#__PURE__*/_jsx(FullScreenIndicator, {
|
|
66
|
+
...commonProps,
|
|
67
|
+
backgroundColor: fullScreenBackgroundColor || fullScreenOverlayBackground
|
|
68
|
+
});
|
|
69
|
+
case overlay:
|
|
70
|
+
return /*#__PURE__*/_jsx(OverlayIndicator, {
|
|
71
|
+
...commonProps,
|
|
72
|
+
inline: inline,
|
|
73
|
+
isActive: overlay,
|
|
74
|
+
children: children
|
|
75
|
+
});
|
|
76
|
+
default:
|
|
77
|
+
return /*#__PURE__*/_jsx(InlineIndicator, {
|
|
78
|
+
...commonProps
|
|
79
|
+
});
|
|
80
|
+
}
|
|
43
81
|
});
|
|
44
82
|
ActivityIndicator.displayName = 'ActivityIndicator';
|
|
45
83
|
ActivityIndicator.propTypes = {
|
|
@@ -48,10 +86,38 @@ ActivityIndicator.propTypes = {
|
|
|
48
86
|
/**
|
|
49
87
|
* A visually hidden accessible label describing the action taking place
|
|
50
88
|
*/
|
|
51
|
-
label: PropTypes.string
|
|
89
|
+
label: PropTypes.string,
|
|
90
|
+
/**
|
|
91
|
+
* If true, it should render a static ActivityIndicator
|
|
92
|
+
*/
|
|
93
|
+
isStatic: PropTypes.bool,
|
|
94
|
+
/**
|
|
95
|
+
* Position of the label relative to ActivityIndicator
|
|
96
|
+
*/
|
|
97
|
+
labelPosition: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
|
98
|
+
/**
|
|
99
|
+
* show or hide the label
|
|
100
|
+
*/
|
|
101
|
+
showLabel: PropTypes.bool,
|
|
102
|
+
/**
|
|
103
|
+
* If true, the ActivityIndicator will be displayed in full screen mode
|
|
104
|
+
*/
|
|
105
|
+
fullScreen: PropTypes.bool,
|
|
106
|
+
/**
|
|
107
|
+
* If true, the ActivityIndicator will be displayed inline
|
|
108
|
+
*/
|
|
109
|
+
inline: PropTypes.bool,
|
|
110
|
+
/**
|
|
111
|
+
* If true, the ActivityIndicator will be displayed in overlay mode
|
|
112
|
+
*/
|
|
113
|
+
overlay: PropTypes.bool,
|
|
114
|
+
/**
|
|
115
|
+
* Children to be rendered inside ActivityIndicator
|
|
116
|
+
*/
|
|
117
|
+
children: PropTypes.node,
|
|
52
118
|
/**
|
|
53
|
-
*
|
|
119
|
+
* Background color of the full screen overlay
|
|
54
120
|
*/
|
|
55
|
-
|
|
121
|
+
fullScreenBackgroundColor: PropTypes.string
|
|
56
122
|
};
|
|
57
123
|
export default ActivityIndicator;
|
|
@@ -50,6 +50,17 @@ export const DOT_FADEOUT_OUTPUT_RANGE = [1, 1, 0, 0];
|
|
|
50
50
|
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
|
+
|
|
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';
|
|
53
64
|
export const propTypes = {
|
|
54
65
|
color: PropTypes.string.isRequired,
|
|
55
66
|
baseColor: PropTypes.string,
|