@telus-uds/components-base 1.60.0 → 1.62.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 (66) hide show
  1. package/CHANGELOG.md +19 -2
  2. package/component-docs.json +306 -116
  3. package/lib/Autocomplete/Autocomplete.js +483 -0
  4. package/lib/Autocomplete/Loading.js +51 -0
  5. package/lib/Autocomplete/Suggestions.js +85 -0
  6. package/lib/Autocomplete/constants.js +14 -0
  7. package/lib/Autocomplete/dictionary.js +19 -0
  8. package/lib/Autocomplete/index.js +13 -0
  9. package/lib/IconButton/IconButton.js +28 -9
  10. package/lib/Listbox/GroupControl.js +121 -0
  11. package/lib/Listbox/Listbox.js +198 -0
  12. package/lib/Listbox/ListboxGroup.js +142 -0
  13. package/lib/Listbox/ListboxItem.js +97 -0
  14. package/lib/Listbox/ListboxOverlay.js +106 -0
  15. package/lib/Listbox/PressableItem.js +0 -2
  16. package/lib/Listbox/index.js +5 -24
  17. package/lib/SideNav/Item.js +7 -15
  18. package/lib/TextInput/TextInputBase.js +8 -1
  19. package/lib/Tooltip/Tooltip.js +5 -1
  20. package/lib/Tooltip/Tooltip.native.js +5 -1
  21. package/lib/Tooltip/shared.js +5 -0
  22. package/lib/index.js +17 -13
  23. package/lib/utils/useOverlaidPosition.js +6 -4
  24. package/lib-module/Autocomplete/Autocomplete.js +448 -0
  25. package/lib-module/Autocomplete/Loading.js +36 -0
  26. package/lib-module/Autocomplete/Suggestions.js +66 -0
  27. package/lib-module/Autocomplete/constants.js +4 -0
  28. package/lib-module/Autocomplete/dictionary.js +12 -0
  29. package/lib-module/Autocomplete/index.js +2 -0
  30. package/lib-module/IconButton/IconButton.js +30 -10
  31. package/lib-module/Listbox/GroupControl.js +102 -0
  32. package/lib-module/Listbox/Listbox.js +172 -0
  33. package/lib-module/Listbox/ListboxGroup.js +117 -0
  34. package/lib-module/Listbox/ListboxItem.js +71 -0
  35. package/lib-module/Listbox/ListboxOverlay.js +80 -0
  36. package/lib-module/Listbox/PressableItem.js +0 -2
  37. package/lib-module/Listbox/index.js +2 -2
  38. package/lib-module/SideNav/Item.js +7 -15
  39. package/lib-module/TextInput/TextInputBase.js +8 -1
  40. package/lib-module/Tooltip/Tooltip.js +5 -1
  41. package/lib-module/Tooltip/Tooltip.native.js +5 -1
  42. package/lib-module/Tooltip/shared.js +5 -0
  43. package/lib-module/index.js +2 -1
  44. package/lib-module/utils/useOverlaidPosition.js +5 -4
  45. package/package.json +4 -2
  46. package/src/Autocomplete/Autocomplete.jsx +411 -0
  47. package/src/Autocomplete/Loading.jsx +18 -0
  48. package/src/Autocomplete/Suggestions.jsx +54 -0
  49. package/src/Autocomplete/constants.js +4 -0
  50. package/src/Autocomplete/dictionary.js +12 -0
  51. package/src/Autocomplete/index.js +3 -0
  52. package/src/IconButton/IconButton.jsx +62 -35
  53. package/src/Listbox/GroupControl.jsx +93 -0
  54. package/src/Listbox/Listbox.jsx +165 -0
  55. package/src/Listbox/ListboxGroup.jsx +120 -0
  56. package/src/Listbox/ListboxItem.jsx +76 -0
  57. package/src/Listbox/ListboxOverlay.jsx +82 -0
  58. package/src/Listbox/PressableItem.jsx +0 -2
  59. package/src/Listbox/index.js +3 -2
  60. package/src/SideNav/Item.jsx +7 -13
  61. package/src/TextInput/TextInputBase.jsx +4 -1
  62. package/src/Tooltip/Tooltip.jsx +15 -2
  63. package/src/Tooltip/Tooltip.native.jsx +15 -2
  64. package/src/Tooltip/shared.js +4 -0
  65. package/src/index.js +2 -1
  66. package/src/utils/useOverlaidPosition.js +6 -5
@@ -0,0 +1,106 @@
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 _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
13
+
14
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
15
+
16
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
17
+
18
+ var _portal = require("@gorhom/portal");
19
+
20
+ var _ThemeProvider = require("../ThemeProvider");
21
+
22
+ var _Card = _interopRequireDefault(require("../Card"));
23
+
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+
28
+ 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); }
29
+
30
+ 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; }
31
+
32
+ /* eslint-disable react/require-default-props */
33
+ const staticStyles = _StyleSheet.default.create({
34
+ positioner: {
35
+ flex: 1,
36
+ // Grow to maxWidth when possible, shrink when not possible
37
+ position: 'absolute',
38
+ zIndex: 1000000000000000 // Position on top of all the other overlays, including backdrops and modals
39
+
40
+ },
41
+ hidden: {
42
+ // Use opacity not visibility to hide the dropdown during positioning
43
+ // so on web, children may be focused from the first render
44
+ opacity: 0
45
+ }
46
+ });
47
+
48
+ const paddingVertical = 0;
49
+ const paddingHorizontal = 0;
50
+ const DropdownOverlay = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
51
+ let {
52
+ children,
53
+ isReady = false,
54
+ overlaidPosition,
55
+ maxWidth,
56
+ minWidth,
57
+ onLayout
58
+ } = _ref;
59
+ const systemTokens = (0, _ThemeProvider.useThemeTokens)('Listbox', {}, {});
60
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
61
+ ref: ref,
62
+ onLayout: onLayout,
63
+ style: [overlaidPosition, {
64
+ maxWidth,
65
+ minWidth
66
+ }, staticStyles.positioner, !isReady && staticStyles.hidden],
67
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Card.default, {
68
+ tokens: {
69
+ shadow: systemTokens.shadow,
70
+ paddingBottom: paddingVertical,
71
+ paddingTop: paddingVertical,
72
+ paddingLeft: paddingHorizontal,
73
+ paddingRight: paddingHorizontal
74
+ },
75
+ children: children
76
+ })
77
+ });
78
+ });
79
+
80
+ const withPortal = Overlay => {
81
+ // eslint-disable-next-line react/display-name, react/no-multi-comp
82
+ return props => {
83
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_portal.Portal, {
84
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Overlay, { ...props
85
+ })
86
+ });
87
+ };
88
+ };
89
+
90
+ DropdownOverlay.displayName = 'DropdownOverlay';
91
+ DropdownOverlay.propTypes = {
92
+ children: _propTypes.default.node.isRequired,
93
+ isReady: _propTypes.default.bool,
94
+ overlaidPosition: _propTypes.default.shape({
95
+ top: _propTypes.default.number,
96
+ left: _propTypes.default.number,
97
+ width: _propTypes.default.number
98
+ }),
99
+ maxWidth: _propTypes.default.number,
100
+ minWidth: _propTypes.default.number,
101
+ onLayout: _propTypes.default.func
102
+ };
103
+
104
+ var _default = _Platform.default.OS === 'web' ? withPortal(DropdownOverlay) : DropdownOverlay;
105
+
106
+ exports.default = _default;
@@ -40,7 +40,6 @@ const getItemStyles = _ref => {
40
40
  itemPaddingRight,
41
41
  itemBackgroundColor,
42
42
  itemColor,
43
- itemDisplay,
44
43
  itemOutline,
45
44
  itemTextDecoration,
46
45
  itemBorderLeftColor,
@@ -62,7 +61,6 @@ const getItemStyles = _ref => {
62
61
  width: '100%',
63
62
  backgroundColor: itemBackgroundColor,
64
63
  color: itemColor,
65
- display: itemDisplay,
66
64
  outline: itemOutline,
67
65
  textDecoration: itemTextDecoration,
68
66
  borderLeft: `${itemBorderLeftWidth}px solid ${itemBorderLeftColor}`,
@@ -3,30 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _exportNames = {
7
- PressableItem: true
8
- };
9
- Object.defineProperty(exports, "PressableItem", {
10
- enumerable: true,
11
- get: function () {
12
- return _PressableItem.default;
13
- }
14
- });
15
-
16
- var _ListboxContext = require("./ListboxContext");
6
+ exports.default = void 0;
17
7
 
18
- Object.keys(_ListboxContext).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
21
- if (key in exports && exports[key] === _ListboxContext[key]) return;
22
- Object.defineProperty(exports, key, {
23
- enumerable: true,
24
- get: function () {
25
- return _ListboxContext[key];
26
- }
27
- });
28
- });
8
+ var _Listbox = _interopRequireDefault(require("./Listbox"));
29
9
 
30
- var _PressableItem = _interopRequireDefault(require("./PressableItem"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
11
 
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ var _default = _Listbox.default;
13
+ exports.default = _default;
@@ -138,13 +138,13 @@ Item.propTypes = { ...selectedSystemPropTypes,
138
138
  children: _propTypes.default.node.isRequired,
139
139
 
140
140
  /**
141
- *
141
+ * @ignore
142
142
  * Set internally in `SideNav` render function - used to keep track of active item.
143
143
  */
144
144
  itemId: _propTypes.default.string,
145
145
 
146
146
  /**
147
- *
147
+ * @ignore
148
148
  * Set internally in `SideNav` render function - used to keep track of expanded items groups.
149
149
  */
150
150
  groupId: _propTypes.default.string,
@@ -158,28 +158,20 @@ Item.propTypes = { ...selectedSystemPropTypes,
158
158
  hrefAttrs: _propTypes.default.shape(_utils.hrefAttrsProp.types),
159
159
 
160
160
  /**
161
- *
161
+ * @ignore
162
162
  * Set internally in `SideNav` render function.
163
163
  */
164
164
  isActive: _propTypes.default.bool,
165
165
 
166
166
  /**
167
- *
167
+ * @ignore
168
168
  * Set internally in `SideNav.ItemsGroup` render function. Used to mark expanded `ItemsGroup` parent.
169
169
  */
170
170
  isExpanded: _propTypes.default.bool,
171
- tokens: (0, _utils.getTokensPropType)('SideNavItem'),
172
- variant: _utils.variantProp.propType,
173
-
174
- /**
175
- * Accesibility Role
176
- */
177
171
  accessibilityRole: _propTypes.default.string,
178
-
179
- /**
180
- * test ID
181
- */
182
- testID: _propTypes.default.number
172
+ testID: _propTypes.default.number,
173
+ tokens: (0, _utils.getTokensPropType)('SideNavItem'),
174
+ variant: _utils.variantProp.propType
183
175
  };
184
176
  var _default = Item;
185
177
  exports.default = _default;
@@ -295,7 +295,12 @@ const TextInputBase = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
295
295
  variant: {
296
296
  compact: true,
297
297
  password: true,
298
- inactive: !!variant.inactive
298
+ inactive: variant.inactive,
299
+ size: 'large'
300
+ },
301
+ tokens: {
302
+ width: 40,
303
+ height: 40
299
304
  }
300
305
  }, !showPassword ? 'hide' : 'show'));
301
306
  }
@@ -375,6 +380,8 @@ exports.default = _default;
375
380
  const staticStyles = _StyleSheet.default.create({
376
381
  buttonsContainer: {
377
382
  position: 'absolute',
383
+ flexDirection: 'row',
384
+ alignItems: 'center',
378
385
  right: 0,
379
386
  top: 0,
380
387
  bottom: 0,
@@ -149,6 +149,7 @@ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
149
149
  content,
150
150
  position = 'auto',
151
151
  copy = 'en',
152
+ onPress = () => {},
152
153
  tokens,
153
154
  variant,
154
155
  inline = false,
@@ -189,7 +190,10 @@ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
189
190
  });
190
191
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('Tooltip', tokens, variant);
191
192
 
192
- const toggleIsOpen = () => setIsOpen(!isOpen);
193
+ const toggleIsOpen = () => {
194
+ onPress();
195
+ setIsOpen(!isOpen);
196
+ };
193
197
 
194
198
  const close = () => setIsOpen(false);
195
199
 
@@ -178,6 +178,7 @@ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
178
178
  content,
179
179
  position = 'auto',
180
180
  copy = 'en',
181
+ onPress = () => {},
181
182
  tokens,
182
183
  variant,
183
184
  inline = false,
@@ -209,7 +210,10 @@ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
209
210
  return () => subscription === null || subscription === void 0 ? void 0 : subscription.remove();
210
211
  });
211
212
 
212
- const toggleIsOpen = () => setIsOpen(!isOpen);
213
+ const toggleIsOpen = () => {
214
+ onPress();
215
+ setIsOpen(!isOpen);
216
+ };
213
217
 
214
218
  const close = () => setIsOpen(false);
215
219
 
@@ -37,6 +37,11 @@ const propTypes = {
37
37
  * Display tooltip icon button as an inline element.
38
38
  */
39
39
  inline: _propTypes.default.bool,
40
+
41
+ /**
42
+ * Callback function triggered when the tooltip is pressed.
43
+ */
44
+ onPress: _propTypes.default.func,
40
45
  tokens: (0, _utils.getTokensPropType)('Tooltip'),
41
46
  variant: _utils.variantProp.propType
42
47
  };
package/lib/index.js CHANGED
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _exportNames = {
7
7
  A11yText: true,
8
8
  ActivityIndicator: true,
9
+ Autocomplete: true,
9
10
  Box: true,
10
11
  Card: true,
11
12
  PressableCardBase: true,
13
+ Listbox: true,
12
14
  Checkbox: true,
13
15
  Divider: true,
14
16
  ExpandCollapse: true,
@@ -91,6 +93,12 @@ Object.defineProperty(exports, "ActivityIndicator", {
91
93
  return _ActivityIndicator.default;
92
94
  }
93
95
  });
96
+ Object.defineProperty(exports, "Autocomplete", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _Autocomplete.default;
100
+ }
101
+ });
94
102
  Object.defineProperty(exports, "BaseProvider", {
95
103
  enumerable: true,
96
104
  get: function () {
@@ -193,6 +201,12 @@ Object.defineProperty(exports, "ListItem", {
193
201
  return _List.ListItem;
194
202
  }
195
203
  });
204
+ Object.defineProperty(exports, "Listbox", {
205
+ enumerable: true,
206
+ get: function () {
207
+ return _Listbox.default;
208
+ }
209
+ });
196
210
  Object.defineProperty(exports, "Modal", {
197
211
  enumerable: true,
198
212
  get: function () {
@@ -444,6 +458,8 @@ var _A11yText = _interopRequireDefault(require("./A11yText"));
444
458
 
445
459
  var _ActivityIndicator = _interopRequireDefault(require("./ActivityIndicator"));
446
460
 
461
+ var _Autocomplete = _interopRequireDefault(require("./Autocomplete"));
462
+
447
463
  var _Box = _interopRequireDefault(require("./Box"));
448
464
 
449
465
  var _Button = require("./Button");
@@ -476,19 +492,7 @@ Object.keys(_Carousel).forEach(function (key) {
476
492
  });
477
493
  });
478
494
 
479
- var _Listbox = require("./Listbox");
480
-
481
- Object.keys(_Listbox).forEach(function (key) {
482
- if (key === "default" || key === "__esModule") return;
483
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
484
- if (key in exports && exports[key] === _Listbox[key]) return;
485
- Object.defineProperty(exports, key, {
486
- enumerable: true,
487
- get: function () {
488
- return _Listbox[key];
489
- }
490
- });
491
- });
495
+ var _Listbox = _interopRequireDefault(require("./Listbox"));
492
496
 
493
497
  var _Checkbox = _interopRequireWildcard(require("./Checkbox"));
494
498
 
@@ -9,6 +9,8 @@ var _react = require("react");
9
9
 
10
10
  var _Dimensions = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Dimensions"));
11
11
 
12
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
13
+
12
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
15
 
14
16
  const adjustHorizontalToFit = (initialOffset, windowWidth, sourceWidth) => {
@@ -182,8 +184,8 @@ const useOverlaidPosition = _ref3 => {
182
184
  let {
183
185
  window
184
186
  } = _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
+ const measurementFunction = _Platform.default.OS === 'web' ? 'measureInWindow' : 'measure';
188
+ (_sourceRef$current = sourceRef.current) === null || _sourceRef$current === void 0 ? void 0 : _sourceRef$current[measurementFunction]((x, y, width, height) => {
187
189
  setWindowDimensions(window);
188
190
  setSourceLayout({
189
191
  x,
@@ -202,9 +204,9 @@ const useOverlaidPosition = _ref3 => {
202
204
  if (typeof ((_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.remove) === 'function') {
203
205
  // React Native >=0.65.0
204
206
  subscription.remove();
205
- } else if (typeof _Dimensions.default.removeEventListener === 'function') {
207
+ } else if (typeof _Dimensions.default.remove === 'function') {
206
208
  // React Native <0.65.0
207
- _Dimensions.default.removeEventListener('change', handleDimensionsChange);
209
+ _Dimensions.default.remove('change', handleDimensionsChange);
208
210
  }
209
211
 
210
212
  setSourceLayout(null);