@telus-uds/components-base 1.18.1 → 1.19.1

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 (160) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/component-docs.json +111 -16
  3. package/jest.config-android.js +17 -0
  4. package/jest.config-ios.js +18 -0
  5. package/jest.config-web.js +31 -0
  6. package/lib/ActivityIndicator/Spinner.js +7 -7
  7. package/lib/ActivityIndicator/Spinner.native.js +2 -2
  8. package/lib/BaseProvider/HydrationContext.js +1 -1
  9. package/lib/BaseProvider/TamaguiProvider.js +30 -0
  10. package/lib/Button/ButtonBase.js +8 -4
  11. package/lib/Button/ButtonDropdown.js +207 -0
  12. package/lib/Button/ButtonGroup.js +1 -1
  13. package/lib/Carousel/Carousel.js +31 -5
  14. package/lib/Carousel/CarouselContext.js +1 -1
  15. package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +1 -1
  16. package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +1 -10
  17. package/lib/Carousel/CarouselThumbnail.js +2 -2
  18. package/lib/Checkbox/Checkbox.js +1 -1
  19. package/lib/Checkbox/CheckboxGroup.js +2 -2
  20. package/lib/Divider/Divider.js +2 -2
  21. package/lib/FlexGrid/Col/Col.js +1 -1
  22. package/lib/Icon/Icon.js +1 -1
  23. package/lib/MultiSelectFilter/ModalOverlay.js +136 -0
  24. package/lib/MultiSelectFilter/MultiSelectFilter.js +314 -0
  25. package/lib/MultiSelectFilter/dictionary.js +19 -0
  26. package/lib/MultiSelectFilter/index.js +13 -0
  27. package/lib/Pagination/PageButton.js +2 -2
  28. package/lib/Pagination/Pagination.js +3 -5
  29. package/lib/Pagination/SideButton.js +6 -4
  30. package/lib/Pagination/usePagination.js +2 -2
  31. package/lib/Progress/ProgressBar.js +3 -3
  32. package/lib/Progress/ProgressBarBackground.js +3 -3
  33. package/lib/QuickLinksFeature/QuickLinksFeature.js +91 -0
  34. package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +157 -0
  35. package/lib/QuickLinksFeature/index.js +16 -0
  36. package/lib/Radio/Radio.js +2 -2
  37. package/lib/Radio/RadioGroup.js +2 -2
  38. package/lib/RadioCard/RadioCard.js +1 -1
  39. package/lib/RadioCard/RadioCardGroup.js +2 -2
  40. package/lib/Responsive/Responsive.js +58 -0
  41. package/lib/Responsive/index.js +13 -0
  42. package/lib/Search/Search.js +30 -63
  43. package/lib/Select/constants.js +15 -0
  44. package/lib/SideNav/SideNav.js +2 -2
  45. package/lib/Skeleton/Skeleton.js +1 -1
  46. package/lib/Skeleton/skeletonWebAnimation.js +1 -1
  47. package/lib/StackView/StackWrap.js +1 -3
  48. package/lib/StackView/getStackedContent.js +2 -2
  49. package/lib/Tabs/Tabs.js +2 -4
  50. package/lib/Tags/Tags.js +11 -5
  51. package/lib/TextInput/TextInputBase.js +53 -19
  52. package/lib/TextInput/dictionary.js +19 -0
  53. package/lib/ThemeProvider/utils/styles.js +3 -3
  54. package/lib/ThemeProvider/utils/theme-tokens.js +9 -7
  55. package/lib/Timeline/Timeline.js +1 -1
  56. package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
  57. package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
  58. package/lib/Tooltip/Backdrop.js +10 -2
  59. package/lib/Tooltip/Tooltip.native.js +357 -0
  60. package/lib/Tooltip/shared.js +39 -0
  61. package/lib/Validator/Validator.js +271 -0
  62. package/lib/Validator/index.js +13 -0
  63. package/lib/index.js +9 -0
  64. package/lib/utils/BaseView/BaseView.js +64 -0
  65. package/lib/utils/BaseView/BaseView.native.js +16 -0
  66. package/lib/utils/BaseView/index.js +13 -0
  67. package/lib/utils/animation/useVerticalExpandAnimation.js +1 -1
  68. package/lib/utils/children.js +2 -2
  69. package/lib/utils/floating-ui/index.js +43 -0
  70. package/lib/utils/floating-ui/index.native.js +43 -0
  71. package/lib/utils/input.js +12 -6
  72. package/lib/utils/props/componentPropType.js +3 -3
  73. package/lib/utils/props/selectSystemProps.js +2 -2
  74. package/lib/utils/props/tokens.js +2 -2
  75. package/lib/utils/useOverlaidPosition.js +243 -0
  76. package/lib/utils/useSpacingScale.js +1 -3
  77. package/lib/utils/useUniqueId.js +1 -1
  78. package/lib-module/ActivityIndicator/Spinner.js +7 -7
  79. package/lib-module/ActivityIndicator/Spinner.native.js +2 -2
  80. package/lib-module/BaseProvider/HydrationContext.js +1 -1
  81. package/lib-module/BaseProvider/TamaguiProvider.js +22 -0
  82. package/lib-module/Button/ButtonBase.js +8 -4
  83. package/lib-module/Button/ButtonDropdown.js +181 -0
  84. package/lib-module/Button/ButtonGroup.js +1 -1
  85. package/lib-module/Carousel/Carousel.js +31 -5
  86. package/lib-module/Carousel/CarouselContext.js +1 -1
  87. package/lib-module/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +1 -1
  88. package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +1 -10
  89. package/lib-module/Carousel/CarouselThumbnail.js +2 -2
  90. package/lib-module/Checkbox/Checkbox.js +1 -1
  91. package/lib-module/Checkbox/CheckboxGroup.js +2 -2
  92. package/lib-module/Divider/Divider.js +2 -2
  93. package/lib-module/FlexGrid/Col/Col.js +1 -1
  94. package/lib-module/Icon/Icon.js +1 -1
  95. package/lib-module/MultiSelectFilter/ModalOverlay.js +112 -0
  96. package/lib-module/MultiSelectFilter/MultiSelectFilter.js +286 -0
  97. package/lib-module/MultiSelectFilter/dictionary.js +12 -0
  98. package/lib-module/MultiSelectFilter/index.js +2 -0
  99. package/lib-module/Pagination/PageButton.js +2 -2
  100. package/lib-module/Pagination/Pagination.js +3 -5
  101. package/lib-module/Pagination/SideButton.js +6 -4
  102. package/lib-module/Pagination/usePagination.js +2 -2
  103. package/lib-module/Progress/ProgressBar.js +3 -3
  104. package/lib-module/Progress/ProgressBarBackground.js +3 -3
  105. package/lib-module/QuickLinksFeature/QuickLinksFeature.js +69 -0
  106. package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +130 -0
  107. package/lib-module/QuickLinksFeature/index.js +4 -0
  108. package/lib-module/Radio/Radio.js +2 -2
  109. package/lib-module/Radio/RadioGroup.js +2 -2
  110. package/lib-module/RadioCard/RadioCard.js +1 -1
  111. package/lib-module/RadioCard/RadioCardGroup.js +2 -2
  112. package/lib-module/Responsive/Responsive.js +45 -0
  113. package/lib-module/Responsive/index.js +2 -0
  114. package/lib-module/Search/Search.js +30 -61
  115. package/lib-module/Select/constants.js +5 -0
  116. package/lib-module/SideNav/SideNav.js +2 -2
  117. package/lib-module/Skeleton/Skeleton.js +1 -1
  118. package/lib-module/Skeleton/skeletonWebAnimation.js +1 -1
  119. package/lib-module/StackView/StackWrap.js +1 -3
  120. package/lib-module/StackView/getStackedContent.js +2 -2
  121. package/lib-module/Tabs/Tabs.js +2 -4
  122. package/lib-module/Tags/Tags.js +11 -5
  123. package/lib-module/TextInput/TextInputBase.js +52 -19
  124. package/lib-module/TextInput/dictionary.js +12 -0
  125. package/lib-module/ThemeProvider/utils/styles.js +3 -3
  126. package/lib-module/ThemeProvider/utils/theme-tokens.js +9 -7
  127. package/lib-module/Timeline/Timeline.js +1 -1
  128. package/lib-module/ToggleSwitch/ToggleSwitch.js +1 -1
  129. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +1 -1
  130. package/lib-module/Tooltip/Backdrop.js +10 -2
  131. package/lib-module/Tooltip/Tooltip.native.js +326 -0
  132. package/lib-module/Tooltip/shared.js +27 -0
  133. package/lib-module/Validator/Validator.js +245 -0
  134. package/lib-module/Validator/index.js +2 -0
  135. package/lib-module/index.js +1 -0
  136. package/lib-module/utils/BaseView/BaseView.js +43 -0
  137. package/lib-module/utils/BaseView/BaseView.native.js +6 -0
  138. package/lib-module/utils/BaseView/index.js +2 -0
  139. package/lib-module/utils/animation/useVerticalExpandAnimation.js +1 -1
  140. package/lib-module/utils/children.js +2 -2
  141. package/lib-module/utils/floating-ui/index.js +1 -0
  142. package/lib-module/utils/floating-ui/index.native.js +1 -0
  143. package/lib-module/utils/input.js +12 -6
  144. package/lib-module/utils/props/componentPropType.js +3 -3
  145. package/lib-module/utils/props/selectSystemProps.js +2 -2
  146. package/lib-module/utils/props/tokens.js +2 -2
  147. package/lib-module/utils/useOverlaidPosition.js +232 -0
  148. package/lib-module/utils/useSpacingScale.js +1 -3
  149. package/lib-module/utils/useUniqueId.js +1 -1
  150. package/package.json +7 -4
  151. package/src/Button/ButtonBase.jsx +4 -2
  152. package/src/Carousel/Carousel.jsx +42 -10
  153. package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +0 -10
  154. package/src/Pagination/SideButton.jsx +5 -5
  155. package/src/Responsive/Responsive.jsx +33 -0
  156. package/src/Responsive/index.js +3 -0
  157. package/src/Search/Search.jsx +17 -32
  158. package/src/Tags/Tags.jsx +46 -33
  159. package/src/TextInput/TextInputBase.jsx +46 -16
  160. package/src/index.js +1 -0
package/lib/index.js CHANGED
@@ -31,6 +31,7 @@ var _exportNames = {
31
31
  QuickLinks: true,
32
32
  Radio: true,
33
33
  RadioCard: true,
34
+ Responsive: true,
34
35
  Search: true,
35
36
  Select: true,
36
37
  SideNav: true,
@@ -241,6 +242,12 @@ Object.defineProperty(exports, "RadioCard", {
241
242
  return _RadioCard.default;
242
243
  }
243
244
  });
245
+ Object.defineProperty(exports, "Responsive", {
246
+ enumerable: true,
247
+ get: function () {
248
+ return _Responsive.default;
249
+ }
250
+ });
244
251
  Object.defineProperty(exports, "Search", {
245
252
  enumerable: true,
246
253
  get: function () {
@@ -546,6 +553,8 @@ Object.keys(_RadioCard).forEach(function (key) {
546
553
  });
547
554
  });
548
555
 
556
+ var _Responsive = _interopRequireDefault(require("./Responsive"));
557
+
549
558
  var _Search = _interopRequireDefault(require("./Search"));
550
559
 
551
560
  var _Select = _interopRequireDefault(require("./Select"));
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
11
+
12
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
13
+
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+
16
+ var _ThemeProvider = require("../../ThemeProvider");
17
+
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ /**
27
+ * Identical to React Native's View and supporting all the same props, but with:
28
+ * - a zIndex: 'auto' style added to prevent unexpectedly causing children to overlap other elements from other stacking contexts
29
+ */
30
+ const BaseView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
31
+ let {
32
+ children,
33
+ style,
34
+ ...rest
35
+ } = _ref;
36
+ const {
37
+ themeOptions
38
+ } = (0, _ThemeProvider.useTheme)();
39
+ const styleProp = Array.isArray(style) ? [...style] : [style];
40
+
41
+ if (!themeOptions.forceZIndex) {
42
+ styleProp.unshift(styles.resetZIndex);
43
+ }
44
+
45
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, { ...rest,
46
+ style: styleProp,
47
+ ref: ref,
48
+ children: children
49
+ });
50
+ });
51
+ BaseView.displayName = 'BaseView';
52
+
53
+ const styles = _StyleSheet.default.create({
54
+ resetZIndex: {
55
+ zIndex: 'auto'
56
+ }
57
+ });
58
+
59
+ BaseView.propTypes = {
60
+ children: _propTypes.default.node,
61
+ style: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array])
62
+ };
63
+ var _default = BaseView;
64
+ exports.default = _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ /**
13
+ * Android crashes on non-standard style properties like `zIndex` so adding a `BaseView` for native platforms
14
+ */
15
+ var _default = _View.default;
16
+ exports.default = _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _BaseView = _interopRequireDefault(require("./BaseView"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ var _default = _BaseView.default;
13
+ exports.default = _default;
@@ -88,7 +88,7 @@ function useVerticalExpandAnimation(_ref) {
88
88
  }
89
89
  } else if (_Platform.default.OS === 'web') {
90
90
  const transitionDuration = isExpanded ? expandDuration : collapseDuration;
91
- containerStyles.transition = "height ".concat(transitionDuration, "ms ease-in-out");
91
+ containerStyles.transition = `height ${transitionDuration}ms ease-in-out`;
92
92
  containerStyles.height = isExpanded ? containerHeight : 0;
93
93
  } else if (_Platform.default.OS === 'ios' && isExpanded && !isAnimating && !expandStateChanged && typeof containerHeight === 'number') {
94
94
  // iOS reflows text while the height animation is in progress. Sometimes, it hits a timing bug where
@@ -73,7 +73,7 @@ const isWrapable = child => {
73
73
  return isStringOrNumber(child) || child.type === _A11yText.default || ((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.name) === 'FootnoteLink';
74
74
  };
75
75
 
76
- const combineKeys = childrenArray => childrenArray.reduce((newKey, child) => "".concat(newKey).concat(child.key || ''), ''); // Group wrappable children for one `<Text>` parent, merging adjacent text nodes
76
+ const combineKeys = childrenArray => childrenArray.reduce((newKey, child) => `${newKey}${child.key || ''}`, ''); // Group wrappable children for one `<Text>` parent, merging adjacent text nodes
77
77
 
78
78
 
79
79
  const wrapChild = (child, wrappedText) => {
@@ -82,7 +82,7 @@ const wrapChild = (child, wrappedText) => {
82
82
 
83
83
  if (lastIndex >= 0 && isStringOrNumber(child) && isStringOrNumber(wrappedText[lastIndex])) {
84
84
  /* eslint-disable-next-line no-param-reassign */
85
- wrappedText[lastIndex] = "".concat(wrappedText[lastIndex]).concat(child);
85
+ wrappedText[lastIndex] = `${wrappedText[lastIndex]}${child}`;
86
86
  } else {
87
87
  wrappedText.push(child);
88
88
  }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "arrow", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _reactDom.arrow;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "autoPlacement", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _reactDom.autoPlacement;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "flip", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _reactDom.flip;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "offset", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _reactDom.offset;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "shift", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _reactDom.shift;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "useFloating", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _reactDom.useFloating;
40
+ }
41
+ });
42
+
43
+ var _reactDom = require("@floating-ui/react-dom");
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "arrow", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _reactNative.arrow;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "autoPlacement", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _reactNative.autoPlacement;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "flip", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _reactNative.flip;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "offset", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _reactNative.offset;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "shift", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _reactNative.shift;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "useFloating", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _reactNative.useFloating;
40
+ }
41
+ });
42
+
43
+ var _reactNative = require("@floating-ui/react-native");
@@ -28,23 +28,29 @@ const validateProps = (_ref, _ref2, hookName) => {
28
28
  const usageError = error => {
29
29
  // Errors inside hooks in React Native get incomplete stack traces pointing at parent component only.
30
30
  // Help devs out by telling them exactly which hook threw the error as well as why.
31
- throw new Error("".concat(hookName, " ").concat(error, ".\n\nConsumers of this hook must be one of:\n1. An \"uncontrolled\" component responding directly to user actions, with an optional `initialValue").concat(s, "` but no `value").concat(s, "` prop,\n2. A \"controlled\" component where an always-defined `value").concat(s, "` prop is managed by an `onChange` handler, with no `initialValue").concat(s, "`,\n3. A \"read-only\" component, with `readOnly` prop set as `true`.\n"));
31
+ throw new Error(`${hookName} ${error}.
32
+
33
+ Consumers of this hook must be one of:
34
+ 1. An "uncontrolled" component responding directly to user actions, with an optional \`initialValue${s}\` but no \`value${s}\` prop,
35
+ 2. A "controlled" component where an always-defined \`value${s}\` prop is managed by an \`onChange\` handler, with no \`initialValue${s}\`,
36
+ 3. A "read-only" component, with \`readOnly\` prop set as \`true\`.
37
+ `);
32
38
  };
33
39
 
34
40
  if (value && !onChange && !readOnly) {
35
- usageError("has `value".concat(s, "` prop without `onChange` or `readOnly`"));
41
+ usageError(`has \`value${s}\` prop without \`onChange\` or \`readOnly\``);
36
42
  }
37
43
 
38
44
  if (initialValue && value) {
39
- usageError("has both `initialValue".concat(s, "` and `value").concat(s, "`"));
45
+ usageError(`has both \`initialValue${s}\` and \`value${s}\``);
40
46
  }
41
47
 
42
48
  if (isControlled && !isCurrentlyControlled) {
43
- usageError("stopped receiving `value".concat(s, "` from parent after delegating state management"));
49
+ usageError(`stopped receiving \`value${s}\` from parent after delegating state management`);
44
50
  }
45
51
 
46
52
  if (!isControlled && isCurrentlyControlled) {
47
- usageError("started receiving `value".concat(s, "` from parent after starting managing own state"));
53
+ usageError(`started receiving \`value${s}\` from parent after starting managing own state`);
48
54
  }
49
55
  };
50
56
  /**
@@ -158,7 +164,7 @@ const useMultipleInputValues = function () {
158
164
  onChange,
159
165
  value: values,
160
166
  // if we're controlling our own state, always start with an array
161
- initialValue: initialValues !== null && initialValues !== void 0 ? initialValues : values === undefined ? [] : undefined
167
+ initialValue: initialValues ?? (values === undefined ? [] : undefined)
162
168
  }, 'useMultipleInputValues');
163
169
  const enforceMaxValues = (0, _react.useCallback)(newValues => {
164
170
  if (!maxValues) return newValues;
@@ -33,8 +33,8 @@ function componentPropType(passedName) {
33
33
  const nameInProp = ((_props$propName$type = props[propName].type) === null || _props$propName$type === void 0 ? void 0 : _props$propName$type.displayName) || ((_props$propName$type2 = props[propName].type) === null || _props$propName$type2 === void 0 ? void 0 : _props$propName$type2.name);
34
34
 
35
35
  if (!nameInProp || !passedNames.includes(nameInProp)) {
36
- const propDescription = nameInProp ? "Component ".concat(nameInProp) : typeof props[propName];
37
- return new Error("".concat(componentName, ": ").concat(propDescription, " was passed to `").concat(propName, "` prop; should be ").concat(passedNames.join(' or ')));
36
+ const propDescription = nameInProp ? `Component ${nameInProp}` : typeof props[propName];
37
+ return new Error(`${componentName}: ${propDescription} was passed to \`${propName}\` prop; should be ${passedNames.join(' or ')}`);
38
38
  }
39
39
 
40
40
  return undefined;
@@ -42,7 +42,7 @@ function componentPropType(passedName) {
42
42
 
43
43
  const checkRequired = (props, propName, componentName) => {
44
44
  if (props[propName] === undefined) {
45
- return new Error("The prop `".concat(propName, "` is marked as required in `").concat(componentName, "`, but its value is ").concat(props[propName], "."));
45
+ return new Error(`The prop \`${propName}\` is marked as required in \`${componentName}\`, but its value is ${props[propName]}.`);
46
46
  }
47
47
 
48
48
  return undefined;
@@ -10,7 +10,7 @@ exports.default = selectSystemProps;
10
10
  function selectSystemProps(systemPropHelpers) {
11
11
  const selectProps = props => systemPropHelpers.reduce((acc, propHelper) => {
12
12
  if (typeof (propHelper === null || propHelper === void 0 ? void 0 : propHelper.select) !== 'function') {
13
- throw new Error("An invalid system prop helper has been passed to 'selectSystemProps': prop selector ('.select') is missing in ".concat(propHelper));
13
+ throw new Error(`An invalid system prop helper has been passed to 'selectSystemProps': prop selector ('.select') is missing in ${propHelper}`);
14
14
  }
15
15
 
16
16
  return { ...acc,
@@ -20,7 +20,7 @@ function selectSystemProps(systemPropHelpers) {
20
20
 
21
21
  const selectedPropTypes = systemPropHelpers.reduce((acc, propHelper) => {
22
22
  if (!(propHelper !== null && propHelper !== void 0 && propHelper.types)) {
23
- throw new Error("An invalid system prop helper has been passed to 'selectSystemProps': types selector ('.types') is missing in ".concat(propHelper));
23
+ throw new Error(`An invalid system prop helper has been passed to 'selectSystemProps': types selector ('.types') is missing in ${propHelper}`);
24
24
  }
25
25
 
26
26
  return { ...acc,
@@ -22,7 +22,7 @@ const getTokenNames = componentName => {
22
22
  const componentTokenSchema = _systemThemeTokens.components[componentName];
23
23
 
24
24
  if (!componentTokenSchema) {
25
- throw new Error("No \"".concat(componentName, "\" tokenKeys in @telus-uds/system-theme-tokens"));
25
+ throw new Error(`No "${componentName}" tokenKeys in @telus-uds/system-theme-tokens`);
26
26
  }
27
27
 
28
28
  return Object.keys(componentTokenSchema);
@@ -63,7 +63,7 @@ exports.getTokenNames = getTokenNames;
63
63
  const selectTokens = (specifier, tokens, prefix) => {
64
64
  const tokenNames = typeof specifier === 'string' ? getTokenNames(specifier) : specifier;
65
65
  const filteredTokens = tokenNames.reduce((validTokens, key) => {
66
- const prefixedKey = prefix ? "".concat(prefix).concat(key[0].toUpperCase()).concat(key.slice(1)) : key;
66
+ const prefixedKey = prefix ? `${prefix}${key[0].toUpperCase()}${key.slice(1)}` : key;
67
67
  const token = tokens[prefixedKey];
68
68
  return token !== undefined ? { ...validTokens,
69
69
  [key]: token
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _Dimensions = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Dimensions"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const adjustHorizontalToFit = (initialOffset, windowWidth, sourceWidth) => {
15
+ const offset = Math.max(0, initialOffset);
16
+ const otherEdgeOverflow = Math.max(0, offset + sourceWidth - windowWidth);
17
+ const tooWideBy = Math.max(0, otherEdgeOverflow - offset);
18
+ const adjusted = {
19
+ offset: Math.max(0, offset - otherEdgeOverflow)
20
+ };
21
+ if (tooWideBy) adjusted.width = Math.max(0, sourceWidth - tooWideBy);
22
+ return adjusted;
23
+ };
24
+
25
+ const getPosition = _ref => {
26
+ let {
27
+ edge,
28
+ fromEdge,
29
+ sourceSize
30
+ } = _ref;
31
+
32
+ switch (edge) {
33
+ case 'near':
34
+ return fromEdge;
35
+
36
+ case 'mid':
37
+ return fromEdge + sourceSize / 2;
38
+
39
+ case 'far':
40
+ return fromEdge + sourceSize;
41
+
42
+ default:
43
+ return 0;
44
+ }
45
+ };
46
+
47
+ const getEdgeType = (align, alignSide) => {
48
+ const alignTo = align[alignSide];
49
+ const edge = ['center', 'middle'].includes(alignTo) && 'mid' || (alignSide === alignTo ? 'near' : 'far');
50
+ return edge;
51
+ };
52
+ /**
53
+ * Based on UDS's private getTooltipPosition but generalised.
54
+ *
55
+ * Used for absolute positioning of the tooltip. Since the tooltip is always centered relatively
56
+ * to the source (button) and we have a limited set of positions, an easy and consistent way
57
+ * of positioning it is to check all of the possible positions and pick one that will be rendered
58
+ * within the window bounds. This way we can also rely on the tooltip being actually rendered
59
+ * before it is shown, which makes it account for the width being limiting in styles, custom font
60
+ * rendering, etc.
61
+ */
62
+
63
+
64
+ function getOverlaidPosition(_ref2) {
65
+ let {
66
+ sourceLayout,
67
+ targetDimensions,
68
+ windowDimensions,
69
+ offsets = {},
70
+ align
71
+ } = _ref2;
72
+ // Web-only: this will be difficult to mimic on native because there's no global scroll position.
73
+ // TODO: wire something in e.g. a scroll ref accessible from a provider included in Allium provider
74
+ // that can be passed to the appropriate ScrollView?
75
+ const {
76
+ scrollX = 0,
77
+ scrollY = 0
78
+ } = typeof window === 'object' ? window : {}; // Will have top, bottom, left and/or right offsets depending on `align`
79
+
80
+ const positioning = {};
81
+ if (align.top) positioning.top = getPosition({
82
+ edge: getEdgeType(align, 'top'),
83
+ fromEdge: sourceLayout.y + scrollY + (offsets.vertical ?? 0),
84
+ sourceSize: sourceLayout.height
85
+ });
86
+ if (align.middle) positioning.top = getPosition({
87
+ edge: getEdgeType(align, 'middle'),
88
+ fromEdge: sourceLayout.y + scrollY + (offsets.vertical ?? 0) - targetDimensions.height / 2,
89
+ sourceSize: sourceLayout.height
90
+ });
91
+ if (align.bottom) positioning.bottom = getPosition({
92
+ edge: getEdgeType(align, 'bottom'),
93
+ fromEdge: windowDimensions.height - (sourceLayout.y + scrollY + sourceLayout.height - (offsets.vertical ?? 0)),
94
+ sourceSize: sourceLayout.height
95
+ });
96
+ if (align.left) positioning.left = getPosition({
97
+ edge: getEdgeType(align, 'left'),
98
+ fromEdge: sourceLayout.x + scrollX + (offsets.horizontal ?? 0),
99
+ sourceSize: sourceLayout.width
100
+ });
101
+ if (align.center) positioning.left = getPosition({
102
+ edge: getEdgeType(align, 'center'),
103
+ fromEdge: sourceLayout.x + scrollX + (offsets.horizontal ?? 0) - targetDimensions.width / 2,
104
+ sourceSize: sourceLayout.width
105
+ });
106
+ if (align.right) positioning.right = getPosition({
107
+ edge: getEdgeType(align, 'right'),
108
+ fromEdge: windowDimensions.width - (sourceLayout.x + scrollX + sourceLayout.width - (offsets.horizontal ?? 0)),
109
+ sourceSize: sourceLayout.width
110
+ });
111
+
112
+ if (!(align.left && align.right)) {
113
+ // Check if the position and/or width need adjusting to fit on the screen
114
+ const side = align.right ? 'right' : 'left';
115
+ const adjusted = adjustHorizontalToFit(positioning[side], windowDimensions.width, sourceLayout.width);
116
+ if (typeof adjusted.width === 'number') positioning.width = adjusted.width;
117
+
118
+ if (typeof adjusted.offset === 'number') {
119
+ positioning[side] = adjusted.offset;
120
+ }
121
+ }
122
+
123
+ return positioning;
124
+ }
125
+ /**
126
+ * Positions an element in a modal or portal so that it appears tooltip-like below the
127
+ * target element.
128
+ *
129
+ * @TODO - add support for positioning other than 'below' like UDS's tooltip (this is not
130
+ * a small task because UDS's tooltip logic only really works for short text - it might be
131
+ * better to use a third-party library).
132
+ */
133
+
134
+
135
+ const useOverlaidPosition = _ref3 => {
136
+ let {
137
+ isShown = false,
138
+ offsets,
139
+ // By default, align the overlaid target's `top` to the bottom of the source, and center horizontally.
140
+ align = {
141
+ center: 'center',
142
+ top: 'bottom'
143
+ }
144
+ } = _ref3;
145
+ // Element in main document flow that the targetRef element is positioned around
146
+ const sourceRef = (0, _react.useRef)(null);
147
+ const [sourceLayout, setSourceLayout] = (0, _react.useState)(null); // Element in a modal or portal overlay positioned to appear adjacent to sourceRef
148
+
149
+ const targetRef = (0, _react.useRef)(null);
150
+ const [targetDimensions, setTargetDimensions] = (0, _react.useState)(null);
151
+ const [windowDimensions, setWindowDimensions] = (0, _react.useState)(null);
152
+ const onTargetLayout = (0, _react.useCallback)(_ref4 => {
153
+ let {
154
+ nativeEvent: {
155
+ layout: {
156
+ width,
157
+ height
158
+ }
159
+ }
160
+ } = _ref4;
161
+ // NOTE: UDS's Tooltip logic injects some additional width to allow for antialiasing etc of text,
162
+ // avoiding adding unnecessary line breaks to text that is slightly wider than it thinks it is.
163
+ // That is probably something specific to text tooltips that doesn't belong in a generic hook.
164
+ setTargetDimensions(previousDimensions => {
165
+ // Re-render on first non-zero width / height: avoid infinite loops on changes, or mispositioning
166
+ // if user scrolls while a slidedown animation is changing the height and recalculating position.
167
+ if (!previousDimensions && width && height) {
168
+ return {
169
+ width,
170
+ height
171
+ };
172
+ }
173
+
174
+ return previousDimensions;
175
+ });
176
+ }, []);
177
+ const readyToShow = Boolean(isShown && sourceRef.current);
178
+ (0, _react.useEffect)(() => {
179
+ const handleDimensionsChange = _ref5 => {
180
+ var _sourceRef$current;
181
+
182
+ let {
183
+ window
184
+ } = _ref5;
185
+ (_sourceRef$current = sourceRef.current) === null || _sourceRef$current === void 0 ? void 0 : _sourceRef$current.measureInWindow((x, y, width, height) => {
186
+ // Could add a debouncer here if there's too many rerenders during gradual resizes
187
+ setWindowDimensions(window);
188
+ setSourceLayout({
189
+ x,
190
+ y,
191
+ width,
192
+ height
193
+ });
194
+ });
195
+ };
196
+
197
+ let subscription;
198
+
199
+ const unsubscribe = () => {
200
+ var _subscription;
201
+
202
+ if (typeof ((_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.remove) === 'function') {
203
+ // React Native >=0.65.0
204
+ subscription.remove();
205
+ } else if (typeof _Dimensions.default.removeEventListener === 'function') {
206
+ // React Native <0.65.0
207
+ _Dimensions.default.removeEventListener('change', handleDimensionsChange);
208
+ }
209
+
210
+ setSourceLayout(null);
211
+ setTargetDimensions(null);
212
+ };
213
+
214
+ if (readyToShow) {
215
+ subscription = _Dimensions.default.addEventListener('change', handleDimensionsChange);
216
+ handleDimensionsChange({
217
+ window: _Dimensions.default.get('window')
218
+ });
219
+ } else {
220
+ unsubscribe();
221
+ }
222
+
223
+ return unsubscribe;
224
+ }, [readyToShow]);
225
+ const isReady = Boolean(isShown && sourceLayout && windowDimensions && targetDimensions);
226
+ const overlaidPosition = isReady ? getOverlaidPosition({
227
+ sourceLayout,
228
+ targetDimensions,
229
+ windowDimensions,
230
+ offsets,
231
+ align
232
+ }) : {};
233
+ return {
234
+ overlaidPosition,
235
+ sourceRef,
236
+ targetRef,
237
+ onTargetLayout,
238
+ isReady
239
+ };
240
+ };
241
+
242
+ var _default = useOverlaidPosition;
243
+ exports.default = _default;
@@ -110,8 +110,6 @@ const resolveSpacingOptions = space => {
110
110
 
111
111
 
112
112
  const useSpacingScale = spaceValue => {
113
- var _spaceValue$space;
114
-
115
113
  // In future, may need to consider window height as well as width, particularly for native apps,
116
114
  // e.g. to ensure designs don't look lost on large, tall, not-so-wide portrait screens.
117
115
  const viewport = (0, _ViewportProvider.useViewport)();
@@ -121,7 +119,7 @@ const useSpacingScale = spaceValue => {
121
119
  overridden,
122
120
  subtract = 0
123
121
  } = resolveSpacingOptions(spaceValue);
124
- const space = !overridden && ((_spaceValue$space = spaceValue === null || spaceValue === void 0 ? void 0 : spaceValue.space) !== null && _spaceValue$space !== void 0 ? _spaceValue$space : (0, _useResponsiveProp.resolveResponsiveProp)(spaceValue, viewport, 0));
122
+ const space = !overridden && ((spaceValue === null || spaceValue === void 0 ? void 0 : spaceValue.space) ?? (0, _useResponsiveProp.resolveResponsiveProp)(spaceValue, viewport, 0));
125
123
  const {
126
124
  size
127
125
  } = (0, _ThemeProvider.useThemeTokens)('spacingScale', tokens, variant, {
@@ -13,7 +13,7 @@ function useUniqueId() {
13
13
  let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
14
14
  const [uniqueId] = (0, _react.useState)(() => {
15
15
  id += 1;
16
- return "".concat(prefix, "-").concat(id);
16
+ return `${prefix}-${id}`;
17
17
  });
18
18
  return uniqueId;
19
19
  }
@@ -10,14 +10,14 @@ const MIN_SVG_LENGTH = MIN_STROKE_ANGLE / 360 * SVG_CIRCUMFERENCE;
10
10
  const MAX_SVG_LENGTH = (1 - MIN_EMPTY_ANGLE / 360) * SVG_CIRCUMFERENCE;
11
11
  const animationProps = {
12
12
  begin: '0s',
13
- dur: "".concat(DURATION, "ms"),
13
+ dur: `${DURATION}ms`,
14
14
  fill: 'freeze',
15
15
  repeatCount: 'indefinite'
16
16
  };
17
17
  const bezierProps = {
18
18
  calcMode: 'spline',
19
19
  keyTimes: '0; 0.5; 1',
20
- keySplines: "".concat(BEZIER.join(', '), " ; ").concat(BEZIER.join(', '))
20
+ keySplines: `${BEZIER.join(', ')} ; ${BEZIER.join(', ')}`
21
21
  }; // We're using svg rather than css here to define the animation to avoid needing to introduce css injection mechanism
22
22
  // It's possible to replicate this functionality with RNW animations, but it snags on chrome at least, see https://github.com/telus/universal-design-system/pull/477 for details.
23
23
 
@@ -33,8 +33,8 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
33
33
  } = useA11yInfo();
34
34
  return /*#__PURE__*/_jsx("svg", {
35
35
  ref: ref,
36
- width: "".concat(size, "px"),
37
- height: "".concat(size, "px"),
36
+ width: `${size}px`,
37
+ height: `${size}px`,
38
38
  viewBox: "0 0 48 48",
39
39
  "aria-valuetext": label,
40
40
  role: "progressbar",
@@ -43,7 +43,7 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
43
43
  children: [reduceMotionEnabled ? null : /*#__PURE__*/_jsx("animateTransform", {
44
44
  attributeName: "transform",
45
45
  type: "rotate",
46
- values: "-180 24 24;".concat(360 + MIN_STROKE_ANGLE - 180, " 24 24"),
46
+ values: `-180 24 24;${360 + MIN_STROKE_ANGLE - 180} 24 24`,
47
47
  ...animationProps
48
48
  }), /*#__PURE__*/_jsx("circle", {
49
49
  fill: "none",
@@ -58,12 +58,12 @@ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
58
58
  children: reduceMotionEnabled ? null : /*#__PURE__*/_jsxs(_Fragment, {
59
59
  children: [/*#__PURE__*/_jsx("animate", {
60
60
  attributeName: "stroke-dashoffset",
61
- values: "0;-10;".concat(MIN_SVG_LENGTH - SVG_CIRCUMFERENCE),
61
+ values: `0;-10;${MIN_SVG_LENGTH - SVG_CIRCUMFERENCE}`,
62
62
  ...animationProps,
63
63
  ...bezierProps
64
64
  }), /*#__PURE__*/_jsx("animate", {
65
65
  attributeName: "stroke-dasharray",
66
- values: "".concat(MIN_SVG_LENGTH, ", 200;").concat(MAX_SVG_LENGTH, ", 200;").concat(MIN_SVG_LENGTH, ", 200"),
66
+ values: `${MIN_SVG_LENGTH}, 200;${MAX_SVG_LENGTH}, 200;${MIN_SVG_LENGTH}, 200`,
67
67
  ...animationProps,
68
68
  ...bezierProps
69
69
  })]