@telus-uds/components-base 3.7.0 → 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.
Files changed (51) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/lib/cjs/ActivityIndicator/FullScreenIndicator.js +89 -0
  3. package/lib/cjs/ActivityIndicator/InlineIndicator.js +64 -0
  4. package/lib/cjs/ActivityIndicator/OverlayIndicator.js +156 -0
  5. package/lib/cjs/ActivityIndicator/RenderActivityIndicator.js +88 -0
  6. package/lib/cjs/ActivityIndicator/index.js +91 -23
  7. package/lib/cjs/ActivityIndicator/shared.js +12 -1
  8. package/lib/cjs/ActivityIndicator/sharedProptypes.js +67 -0
  9. package/lib/cjs/Card/Card.js +38 -45
  10. package/lib/cjs/Card/PressableCardBase.js +4 -1
  11. package/lib/cjs/ExpandCollapseMini/ExpandCollapseMiniControl.js +1 -1
  12. package/lib/cjs/List/ListItemMark.js +13 -2
  13. package/lib/cjs/MultiSelectFilter/ModalOverlay.js +12 -3
  14. package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +9 -2
  15. package/lib/cjs/utils/index.js +9 -1
  16. package/lib/cjs/utils/useDetectOutsideClick.js +39 -0
  17. package/lib/cjs/utils/useVariants.js +46 -0
  18. package/lib/esm/ActivityIndicator/FullScreenIndicator.js +82 -0
  19. package/lib/esm/ActivityIndicator/InlineIndicator.js +57 -0
  20. package/lib/esm/ActivityIndicator/OverlayIndicator.js +149 -0
  21. package/lib/esm/ActivityIndicator/RenderActivityIndicator.js +83 -0
  22. package/lib/esm/ActivityIndicator/index.js +89 -23
  23. package/lib/esm/ActivityIndicator/shared.js +11 -0
  24. package/lib/esm/ActivityIndicator/sharedProptypes.js +61 -0
  25. package/lib/esm/Card/Card.js +38 -45
  26. package/lib/esm/Card/PressableCardBase.js +4 -1
  27. package/lib/esm/ExpandCollapseMini/ExpandCollapseMiniControl.js +1 -1
  28. package/lib/esm/List/ListItemMark.js +13 -2
  29. package/lib/esm/MultiSelectFilter/ModalOverlay.js +12 -3
  30. package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +9 -2
  31. package/lib/esm/utils/index.js +2 -1
  32. package/lib/esm/utils/useDetectOutsideClick.js +31 -0
  33. package/lib/esm/utils/useVariants.js +41 -0
  34. package/lib/package.json +2 -2
  35. package/package.json +2 -2
  36. package/src/ActivityIndicator/FullScreenIndicator.jsx +65 -0
  37. package/src/ActivityIndicator/InlineIndicator.jsx +47 -0
  38. package/src/ActivityIndicator/OverlayIndicator.jsx +140 -0
  39. package/src/ActivityIndicator/RenderActivityIndicator.jsx +82 -0
  40. package/src/ActivityIndicator/index.jsx +113 -32
  41. package/src/ActivityIndicator/shared.js +11 -0
  42. package/src/ActivityIndicator/sharedProptypes.js +62 -0
  43. package/src/Card/Card.jsx +51 -54
  44. package/src/Card/PressableCardBase.jsx +1 -1
  45. package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +1 -1
  46. package/src/List/ListItemMark.jsx +18 -2
  47. package/src/MultiSelectFilter/ModalOverlay.jsx +15 -3
  48. package/src/MultiSelectFilter/MultiSelectFilter.jsx +9 -2
  49. package/src/utils/index.js +1 -0
  50. package/src/utils/useDetectOutsideClick.js +35 -0
  51. package/src/utils/useVariants.js +44 -0
@@ -133,6 +133,7 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
133
133
  const selected = interactiveCard?.variant?.selected;
134
134
  const inactive = interactiveCard?.variant?.inactive;
135
135
  const selectionType = interactiveCard?.selectionType;
136
+ const isControl = interactiveCard?.variant?.isControl === true;
136
137
  const getThemeTokens = (0, _ThemeProvider.useThemeTokensCallback)('Card', interactiveCard?.tokens, {
137
138
  interactive: true,
138
139
  ...(interactiveCard?.variant || {})
@@ -200,6 +201,9 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
200
201
  cardStyles = themeTokens;
201
202
  }
202
203
  const renderInputPerSelectionType = props => {
204
+ if (!isControl) {
205
+ return null;
206
+ }
203
207
  switch (selectionType) {
204
208
  case SelectionType.Checkbox:
205
209
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
@@ -227,17 +231,8 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
227
231
  return null;
228
232
  }
229
233
  };
230
- const renderNoSelectionView = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
231
- style: {
232
- paddingTop,
233
- paddingBottom,
234
- paddingLeft,
235
- paddingRight
236
- },
237
- children: children
238
- });
239
234
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
240
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBase.default, {
235
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CardBase.default, {
241
236
  ref: ref,
242
237
  tokens: interactiveCard?.body ? restOfTokens : cardStyles,
243
238
  backgroundImage: backgroundImage,
@@ -245,41 +240,39 @@ const Card = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
245
240
  media: mediaIds
246
241
  },
247
242
  ...selectProps(rest),
248
- children: interactiveCard?.body ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
249
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PressableCardBase.default, {
250
- ref: ref,
251
- tokens: getThemeTokens,
252
- dataSet: dataSet,
253
- onPress: onPress,
254
- href: interactiveCard?.href,
255
- hrefAttrs: interactiveCard?.hrefAttrs,
256
- ...selectProps(rest),
257
- children: cardState => {
258
- const {
259
- iconColor: checkColor,
260
- inputBackgroundColor: boxBackgroundColor,
261
- iconBackgroundColor: checkBackgroundColor
262
- } = getThemeTokens({
263
- ...cardState,
264
- selected,
265
- interactive: true,
266
- isControl: true
267
- }, interactiveCard?.tokens);
268
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
269
- children: [renderInputPerSelectionType(getInputProps({
270
- id,
271
- checkColor,
272
- boxBackgroundColor,
273
- checkBackgroundColor,
274
- isControlled: true,
275
- isChecked: selected || cardState?.hover,
276
- isInactive: inactive,
277
- onPress
278
- })), typeof interactiveCard?.body === 'function' ? interactiveCard.body(cardState) : interactiveCard.body]
279
- });
280
- }
281
- }), children && selectionType !== SelectionType.None ? renderNoSelectionView() : null]
282
- }) : children
243
+ children: [interactiveCard?.body && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PressableCardBase.default, {
244
+ ref: ref,
245
+ tokens: getThemeTokens,
246
+ dataSet: dataSet,
247
+ onPress: onPress,
248
+ href: interactiveCard?.href,
249
+ hrefAttrs: interactiveCard?.hrefAttrs,
250
+ ...selectProps(rest),
251
+ children: cardState => {
252
+ const {
253
+ iconColor: checkColor,
254
+ inputBackgroundColor: boxBackgroundColor,
255
+ iconBackgroundColor: checkBackgroundColor
256
+ } = getThemeTokens({
257
+ ...cardState,
258
+ selected,
259
+ interactive: true,
260
+ isControl
261
+ }, interactiveCard?.tokens);
262
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
263
+ children: [renderInputPerSelectionType(getInputProps({
264
+ id,
265
+ checkColor,
266
+ boxBackgroundColor,
267
+ checkBackgroundColor,
268
+ isControlled: true,
269
+ isChecked: selected || cardState?.hover,
270
+ isInactive: inactive,
271
+ onPress
272
+ })), typeof interactiveCard?.body === 'function' ? interactiveCard.body(cardState) : interactiveCard.body]
273
+ });
274
+ }
275
+ }), children]
283
276
  })
284
277
  });
285
278
  });
@@ -133,7 +133,10 @@ const PressableCardBase = /*#__PURE__*/_react.default.forwardRef((_ref, ref) =>
133
133
  setFocused(false);
134
134
  setPressed(false);
135
135
  },
136
- style: staticStyles.container,
136
+ style: {
137
+ ...staticStyles.container,
138
+ textDecoration: 'none'
139
+ },
137
140
  ...(hrefAttrs || {}),
138
141
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBase.default, {
139
142
  tokens: getCardTokens({
@@ -45,7 +45,7 @@ const ExpandCollapseMiniControl = /*#__PURE__*/_react.default.forwardRef((_ref,
45
45
  const isFocusVisible = _Platform.default.OS === 'web' ? focus && !pressed && !hover : expanded;
46
46
  const linkTokens = (0, _ThemeProvider.useThemeTokens)('Link', {}, {
47
47
  ...variant,
48
- quiet: expanded ?? quiet
48
+ quiet
49
49
  }, {
50
50
  focus: isFocusVisible,
51
51
  hover,
@@ -9,6 +9,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
10
10
  var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
11
11
  var _Icon = _interopRequireDefault(require("../Icon"));
12
+ var _utils = require("../utils");
12
13
  var _jsxRuntime = require("react/jsx-runtime");
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  const tokenTypes = exports.tokenTypes = {
@@ -60,6 +61,7 @@ const selectBulletContainerStyles = _ref4 => {
60
61
  alignItems: itemBulletContainerAlign
61
62
  };
62
63
  };
64
+ const getIconColorVariants = iconVariants => iconVariants?.filter(variant => variant[0] === 'color').map(variant => variant[1]);
63
65
 
64
66
  /**
65
67
  * Subcomponent used within ListItem and similar components for rendering bullets or icons
@@ -78,6 +80,10 @@ const ListItemMark = /*#__PURE__*/_react.default.forwardRef((_ref5, ref) => {
78
80
  const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
79
81
  const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
80
82
  const bulletContainerStyles = selectBulletContainerStyles(themeTokens);
83
+
84
+ // TODO: Remove it when iconColor custom colors are deprecated.
85
+ const iconVariants = (0, _utils.useVariants)('Icon');
86
+ const iconColorVariants = getIconColorVariants(iconVariants);
81
87
  if (icon) {
82
88
  const iconTokens = selectItemIconTokens(themeTokens);
83
89
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
@@ -85,10 +91,15 @@ const ListItemMark = /*#__PURE__*/_react.default.forwardRef((_ref5, ref) => {
85
91
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
86
92
  icon: icon,
87
93
  tokens: {
88
- size: iconSize ?? iconTokens.size
94
+ size: iconSize ?? iconTokens.size,
95
+ ...((iconColor && !iconColorVariants?.includes(iconColor) || !iconColor) && {
96
+ color: iconColor && !iconColorVariants?.includes(iconColor) ? iconColor : iconTokens.color
97
+ })
89
98
  },
90
99
  variant: {
91
- color: iconColor ?? iconTokens.color
100
+ ...(iconColorVariants?.includes(iconColor) && {
101
+ color: iconColor
102
+ })
92
103
  }
93
104
  })
94
105
  });
@@ -16,6 +16,7 @@ var _ThemeProvider = require("../ThemeProvider");
16
16
  var _dictionary = _interopRequireDefault(require("./dictionary"));
17
17
  var _Card = _interopRequireDefault(require("../Card"));
18
18
  var _IconButton = _interopRequireDefault(require("../IconButton"));
19
+ var _useDetectOutsideClick = _interopRequireDefault(require("../utils/useDetectOutsideClick"));
19
20
  var _jsxRuntime = require("react/jsx-runtime");
20
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
22
  const staticStyles = _StyleSheet.default.create({
@@ -96,13 +97,16 @@ const ModalOverlay = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
96
97
  tokens,
97
98
  copy,
98
99
  onClose,
99
- enableFullscreen = false
100
+ enableFullscreen = false,
101
+ dismissWhenPressedOutside = false
100
102
  } = _ref2;
101
103
  const viewport = (0, _ViewportProvider.useViewport)();
102
104
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('Modal', tokens, variant, {
103
105
  viewport,
104
106
  maxWidth: false
105
107
  });
108
+ const containerRef = _react.default.useRef(ref || null);
109
+ (0, _useDetectOutsideClick.default)(containerRef, onClose, dismissWhenPressedOutside);
106
110
  const containerWidthHeight = {
107
111
  minWidth: tokens.maxWidth ? maxWidthSize : minWidth,
108
112
  minHeight: maxHeight ? maxHeightSize : minHeight,
@@ -119,7 +123,7 @@ const ModalOverlay = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
119
123
  const closeLabel = getCopy('closeButton');
120
124
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_portal.Portal, {
121
125
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
122
- ref: ref,
126
+ ref: containerRef,
123
127
  onLayout: onLayout,
124
128
  style: [overlaidPosition, containerWidthHeight, staticStyles.positioner, !isReady && staticStyles.hidden, selectContainerStyle(enableFullscreen, themeTokens)],
125
129
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Card.default, {
@@ -157,6 +161,11 @@ ModalOverlay.propTypes = {
157
161
  tokens: (0, _utils.getTokensPropType)('Modal'),
158
162
  copy: _utils.copyPropTypes,
159
163
  onClose: _propTypes.default.func,
160
- enableFullscreen: _propTypes.default.bool
164
+ enableFullscreen: _propTypes.default.bool,
165
+ /**
166
+ * If true, clicking outside the content will trigger the a close callback, dismissing the content.
167
+ * @deprecated This parameter will be removed in the next major release; detection will be always enabled by default.
168
+ */
169
+ dismissWhenPressedOutside: _propTypes.default.bool
161
170
  };
162
171
  var _default = exports.default = ModalOverlay;
@@ -92,6 +92,7 @@ const MultiSelectFilter = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) =>
92
92
  inactive = false,
93
93
  rowLimit = 12,
94
94
  dictionary = _dictionary.default,
95
+ dismissWhenPressedOutside = false,
95
96
  ...rest
96
97
  } = _ref3;
97
98
  const viewport = (0, _ViewportProvider.useViewport)();
@@ -403,8 +404,9 @@ const MultiSelectFilter = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) =>
403
404
  })]
404
405
  })
405
406
  }), isOpen && viewport !== 'xs' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ModalOverlay.default, {
406
- overlaidPosition: overlaidPosition,
407
+ dismissWhenPressedOutside: dismissWhenPressedOutside,
407
408
  onClose: onClose,
409
+ overlaidPosition: overlaidPosition,
408
410
  maxHeight: items.length > MAX_ITEMS_THRESHOLD ? true : maxHeight,
409
411
  maxHeightSize: maxHeightSize,
410
412
  maxWidthSize: maxWidthSize,
@@ -548,6 +550,11 @@ MultiSelectFilter.propTypes = {
548
550
  * Sets the maximum number of items in one column. If number of items are more
549
551
  * than the `rowLimit`, they will be rendered in 2 columns.
550
552
  */
551
- rowLimit: _propTypes.default.number
553
+ rowLimit: _propTypes.default.number,
554
+ /**
555
+ * If true, clicking outside the content will trigger the a close callback, dismissing the content.
556
+ * @deprecated This parameter will be removed in the next major release; detection will be always enabled by default.
557
+ */
558
+ dismissWhenPressedOutside: _propTypes.default.bool
552
559
  };
553
560
  var _default = exports.default = MultiSelectFilter;
@@ -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;