@telus-uds/components-web 2.17.2 → 2.19.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 (88) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/component-docs.json +854 -421
  3. package/lib/Badge/Badge.js +2 -2
  4. package/lib/BlockQuote/BlockQuote.js +9 -0
  5. package/lib/Callout/Callout.js +5 -0
  6. package/lib/DatePicker/DatePicker.js +24 -4
  7. package/lib/Disclaimer/Disclaimer.js +4 -0
  8. package/lib/ExpandCollapseMini/ExpandCollapseMini.js +7 -1
  9. package/lib/NavigationBar/NavigationBar.js +8 -2
  10. package/lib/NavigationBar/NavigationSubMenu.js +2 -4
  11. package/lib/OrderedList/OrderedList.js +4 -2
  12. package/lib/Ribbon/Ribbon.js +2 -1
  13. package/lib/Toast/Toast.js +2 -1
  14. package/lib/Video/Video.js +3 -1
  15. package/lib/WaffleGrid/WaffleGrid.js +20 -20
  16. package/lib/baseExports.js +12 -0
  17. package/lib/index.js +0 -18
  18. package/lib/utils/useOverlaidPosition.js +2 -2
  19. package/lib-module/Badge/Badge.js +1 -1
  20. package/lib-module/BlockQuote/BlockQuote.js +10 -1
  21. package/lib-module/Callout/Callout.js +6 -1
  22. package/lib-module/DatePicker/DatePicker.js +24 -4
  23. package/lib-module/Disclaimer/Disclaimer.js +4 -0
  24. package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +8 -2
  25. package/lib-module/NavigationBar/NavigationBar.js +8 -2
  26. package/lib-module/NavigationBar/NavigationSubMenu.js +1 -2
  27. package/lib-module/OrderedList/OrderedList.js +5 -3
  28. package/lib-module/Ribbon/Ribbon.js +3 -2
  29. package/lib-module/Toast/Toast.js +3 -2
  30. package/lib-module/Video/Video.js +4 -2
  31. package/lib-module/WaffleGrid/WaffleGrid.js +21 -21
  32. package/lib-module/baseExports.js +1 -1
  33. package/lib-module/index.js +0 -2
  34. package/lib-module/utils/useOverlaidPosition.js +2 -2
  35. package/package.json +3 -3
  36. package/src/Badge/Badge.jsx +1 -1
  37. package/src/BlockQuote/BlockQuote.jsx +10 -1
  38. package/src/Callout/Callout.jsx +11 -1
  39. package/src/DatePicker/DatePicker.jsx +20 -2
  40. package/src/Disclaimer/Disclaimer.jsx +3 -0
  41. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +7 -2
  42. package/src/NavigationBar/NavigationBar.jsx +7 -2
  43. package/src/NavigationBar/NavigationSubMenu.jsx +1 -2
  44. package/src/OrderedList/OrderedList.jsx +4 -3
  45. package/src/Ribbon/Ribbon.jsx +8 -2
  46. package/src/Toast/Toast.jsx +4 -2
  47. package/src/Video/Video.jsx +9 -2
  48. package/src/WaffleGrid/WaffleGrid.jsx +21 -15
  49. package/src/baseExports.js +2 -0
  50. package/src/index.js +0 -2
  51. package/src/utils/useOverlaidPosition.js +2 -2
  52. package/types/Callout.d.ts +1 -0
  53. package/lib/Autocomplete/Autocomplete.js +0 -407
  54. package/lib/Autocomplete/Loading.js +0 -46
  55. package/lib/Autocomplete/Suggestions.js +0 -81
  56. package/lib/Autocomplete/constants.js +0 -19
  57. package/lib/Autocomplete/dictionary.js +0 -19
  58. package/lib/Autocomplete/index.js +0 -13
  59. package/lib/Listbox/GroupControl.js +0 -110
  60. package/lib/Listbox/Listbox.js +0 -179
  61. package/lib/Listbox/ListboxGroup.js +0 -145
  62. package/lib/Listbox/ListboxItem.js +0 -101
  63. package/lib/Listbox/ListboxOverlay.js +0 -91
  64. package/lib/Listbox/index.js +0 -13
  65. package/lib-module/Autocomplete/Autocomplete.js +0 -383
  66. package/lib-module/Autocomplete/Loading.js +0 -32
  67. package/lib-module/Autocomplete/Suggestions.js +0 -64
  68. package/lib-module/Autocomplete/constants.js +0 -5
  69. package/lib-module/Autocomplete/dictionary.js +0 -12
  70. package/lib-module/Autocomplete/index.js +0 -2
  71. package/lib-module/Listbox/GroupControl.js +0 -96
  72. package/lib-module/Listbox/Listbox.js +0 -158
  73. package/lib-module/Listbox/ListboxGroup.js +0 -122
  74. package/lib-module/Listbox/ListboxItem.js +0 -77
  75. package/lib-module/Listbox/ListboxOverlay.js +0 -69
  76. package/lib-module/Listbox/index.js +0 -2
  77. package/src/Autocomplete/Autocomplete.jsx +0 -357
  78. package/src/Autocomplete/Loading.jsx +0 -15
  79. package/src/Autocomplete/Suggestions.jsx +0 -52
  80. package/src/Autocomplete/constants.js +0 -6
  81. package/src/Autocomplete/dictionary.js +0 -12
  82. package/src/Autocomplete/index.js +0 -3
  83. package/src/Listbox/GroupControl.jsx +0 -82
  84. package/src/Listbox/Listbox.jsx +0 -163
  85. package/src/Listbox/ListboxGroup.jsx +0 -125
  86. package/src/Listbox/ListboxItem.jsx +0 -80
  87. package/src/Listbox/ListboxOverlay.jsx +0 -72
  88. package/src/Listbox/index.js +0 -3
@@ -1,407 +0,0 @@
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 _lodash = require("lodash");
13
-
14
- var _componentsBase = require("@telus-uds/components-base");
15
-
16
- var _Listbox = _interopRequireDefault(require("../Listbox"));
17
-
18
- var _utils = require("../utils");
19
-
20
- var _Loading = _interopRequireDefault(require("./Loading"));
21
-
22
- var _Suggestions = _interopRequireDefault(require("./Suggestions"));
23
-
24
- var _constants = require("./constants");
25
-
26
- var _dictionary = _interopRequireDefault(require("./dictionary"));
27
-
28
- var _jsxRuntime = require("react/jsx-runtime");
29
-
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
- 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); }
33
-
34
- 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; }
35
-
36
- /* eslint-disable react/require-default-props */
37
- const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs, _componentsBase.inputSupportsProps, _componentsBase.textInputHandlerProps, _componentsBase.textInputProps]); // Returns JSX to display a bold string `str` with unbolded occurrences of the
38
- // `substring` based in the array of `matchIndexes` provided
39
-
40
- const highlightAllMatches = function (str) {
41
- let substring = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
42
- let matchIndexes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
43
- let resultsTextColor = arguments.length > 3 ? arguments[3] : undefined;
44
- return (
45
- /*#__PURE__*/
46
- // Wrapping all in bold
47
- (0, _jsxRuntime.jsx)(_componentsBase.Typography, {
48
- variant: {
49
- bold: false
50
- },
51
- tokens: {
52
- color: resultsTextColor
53
- },
54
- children: matchIndexes.reduce((acc, matchIndex, index) => [...acc, // Add a piece of the string up to the first occurrence of the substring
55
- index === 0 && (str.slice(0, matchIndex) ?? ''),
56
- /*#__PURE__*/
57
- // Unbold the occurrence of the substring (while keeping the original casing)
58
- (0, _jsxRuntime.jsx)(_componentsBase.Typography, {
59
- variant: {
60
- bold: true
61
- },
62
- tokens: {
63
- color: resultsTextColor
64
- },
65
- children: str.slice(matchIndex, matchIndex + substring.length)
66
- }, matchIndex), // Add the rest of the string until the next occurrence or the end of it
67
- str.slice(matchIndex + substring.length, matchIndexes[index + 1] ?? str.length)], [])
68
- })
69
- );
70
- };
71
-
72
- const highlight = function () {
73
- let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
74
- let text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
75
- let color = arguments.length > 2 ? arguments[2] : undefined;
76
- return items.reduce((acc, item) => {
77
- var _Array$from;
78
-
79
- const matches = (_Array$from = Array.from(item.label.toLowerCase().matchAll(text.toLowerCase()))) === null || _Array$from === void 0 ? void 0 : _Array$from.map(_ref => {
80
- let {
81
- index
82
- } = _ref;
83
- return index;
84
- });
85
-
86
- if (matches !== null && matches !== void 0 && matches.length) {
87
- return [...acc, { ...item,
88
- label: highlightAllMatches(item.label, text, matches, color)
89
- }];
90
- }
91
-
92
- return [...acc, item];
93
- }, []);
94
- };
95
-
96
- const Autocomplete = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
97
- var _ref3;
98
-
99
- let {
100
- children,
101
- copy = 'en',
102
- fullWidth = true,
103
- initialItems,
104
- initialValue,
105
- isLoading = false,
106
- items,
107
- maxSuggestions = _constants.DEFAULT_MAX_SUGGESTIONS,
108
- minToSuggestion = _constants.DEFAULT_MIN_TO_SUGGESTION,
109
- noResults,
110
- onChange,
111
- onClear,
112
- onSelect,
113
- readOnly,
114
- validation,
115
- value,
116
- ...rest
117
- } = _ref2;
118
- const {
119
- color: resultsTextColor
120
- } = (0, _componentsBase.useThemeTokens)('Search', {}, {
121
- focus: true
122
- }); // The wrapped input is mostly responsible for controlled vs uncontrolled handling,
123
- // but we also need to adjust suggestions based on the mode:
124
- // - in controlled mode we rely entirely on the suggestions passed via the `items` prop,
125
- // - in uncontrolled mode we filter the suggestions ourselves based on the `initialItems`
126
- // prop and the text entered
127
-
128
- const isControlled = value !== undefined; // We need to store current items for uncontrolled usage
129
-
130
- const [currentItems, setCurrentItems] = (0, _react.useState)(initialItems); // We need to store the current value as well to be able to highlight it
131
-
132
- const [currentValue, setCurrentValue] = (0, _react.useState)(value ?? initialValue);
133
- const inputTokens = {
134
- paddingLeft: _constants.INPUT_LEFT_PADDING
135
- }; // Setting up the overlay
136
-
137
- const openOverlayRef = (0, _react.useRef)();
138
- const [isExpanded, setIsExpanded] = (0, _react.useState)(((_ref3 = value ?? initialValue) === null || _ref3 === void 0 ? void 0 : _ref3.length) >= minToSuggestion);
139
- const {
140
- overlaidPosition,
141
- sourceRef: inputRef,
142
- targetRef,
143
- onTargetLayout,
144
- isReady
145
- } = (0, _utils.useOverlaidPosition)({
146
- isShown: isExpanded,
147
- offsets: {
148
- vertical: 4
149
- }
150
- }); // We limit the number of suggestions displayed to avoid huge lists
151
- // TODO: add a way to make the `Listbox` occupy fixed height and be scrollable
152
- // within that height, which will unlock similar behaviour for `AutoComplete` as well
153
-
154
- const itemsToSuggest = function () {
155
- let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
156
- return maxSuggestions ? data.slice(0, maxSuggestions) : [...data];
157
- };
158
-
159
- const getCopy = (0, _componentsBase.useCopy)({
160
- dictionary: _dictionary.default,
161
- copy
162
- }); // Tracking input width changes to resize the listbox overlay accordingly
163
-
164
- const [inputWidth, setInputWidth] = (0, _react.useState)();
165
- (0, _componentsBase.useSafeLayoutEffect)(() => {
166
- const updateInputWidth = () => {
167
- var _inputRef$current;
168
-
169
- setInputWidth((inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.clientWidth) + 4); // adding back all the input borders / outlines
170
-
171
- setIsExpanded(false); // close the suggestions while the input is changing
172
- };
173
-
174
- const throttledUpdateInputWidth = (0, _lodash.throttle)(updateInputWidth, 100, {
175
- leading: false
176
- });
177
- updateInputWidth();
178
- window.addEventListener('load', updateInputWidth);
179
- window.addEventListener('resize', throttledUpdateInputWidth);
180
- return () => {
181
- window.removeEventListener('load', updateInputWidth);
182
- window.removeEventListener('resize', throttledUpdateInputWidth);
183
- };
184
- }, [inputRef]);
185
-
186
- const handleChange = newValue => {
187
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
188
- setCurrentValue(newValue);
189
- setIsExpanded((newValue === null || newValue === void 0 ? void 0 : newValue.length) >= minToSuggestion);
190
-
191
- if (!isControlled && initialItems !== undefined) {
192
- setCurrentItems(initialItems.filter(_ref4 => {
193
- var _label$toLowerCase;
194
-
195
- let {
196
- label
197
- } = _ref4;
198
- return label === null || label === void 0 ? void 0 : (_label$toLowerCase = label.toLowerCase()) === null || _label$toLowerCase === void 0 ? void 0 : _label$toLowerCase.includes(newValue === null || newValue === void 0 ? void 0 : newValue.toLowerCase());
199
- }));
200
- }
201
- };
202
-
203
- const handleSelect = selectedId => {
204
- var _ref5;
205
-
206
- onSelect === null || onSelect === void 0 ? void 0 : onSelect(selectedId);
207
- const {
208
- label: newValue
209
- } = (_ref5 = isControlled ? items : currentItems) === null || _ref5 === void 0 ? void 0 : _ref5.find(_ref6 => {
210
- let {
211
- id
212
- } = _ref6;
213
- return id === selectedId;
214
- });
215
- onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
216
- setCurrentValue(newValue);
217
- if (!isControlled && inputRef !== null && inputRef !== void 0 && inputRef.current) inputRef.current.value = newValue;
218
- setIsExpanded(false);
219
- };
220
-
221
- const handleClose = event => {
222
- var _openOverlayRef$curre, _openOverlayRef$curre2;
223
-
224
- if (event.type === 'keydown') {
225
- if (event.key === 'Escape' || event.key === 27) {
226
- setIsExpanded(false);
227
- } else if (event.key === 'ArrowDown' && isExpanded && !isLoading && targetRef !== null && targetRef !== void 0 && targetRef.current) {
228
- targetRef.current.focus();
229
- }
230
- } else if (event.type === 'click' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre = openOverlayRef.current) !== null && _openOverlayRef$curre !== void 0 && _openOverlayRef$curre.contains(event.target))) {
231
- setIsExpanded(false);
232
- } else if (event.type === 'touchstart' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.touches[0].target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre2 = openOverlayRef.current) !== null && _openOverlayRef$curre2 !== void 0 && _openOverlayRef$curre2.contains(event.touches[0].target))) {
233
- setIsExpanded(false);
234
- }
235
- };
236
-
237
- const {
238
- supportsProps,
239
- ...selectedProps
240
- } = selectProps(rest);
241
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
242
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.InputSupports, { ...supportsProps,
243
- accessibilityAutoComplete: "list",
244
- accessibilityControls: "autocomplete",
245
- accessibilityExpanded: isExpanded,
246
- accessibilityRole: "combobox",
247
- ...selectedProps,
248
- validation: validation,
249
- ref: ref,
250
- children: _ref7 => {
251
- let {
252
- inputId,
253
- ...props
254
- } = _ref7;
255
- if (typeof children === 'function') return children({
256
- inputId,
257
- inputRef,
258
- onChange: handleChange,
259
- onKeyPress: handleClose,
260
- readOnly,
261
- tokens: inputTokens,
262
- ...selectedProps,
263
- ...props,
264
- ...(isControlled ? {
265
- value
266
- } : {
267
- initialValue
268
- })
269
- });
270
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.TextInput, {
271
- onChange: handleChange,
272
- onClear: onClear,
273
- onKeyPress: handleClose,
274
- readOnly: readOnly,
275
- ref: inputRef,
276
- tokens: inputTokens,
277
- validation: validation,
278
- ...selectedProps,
279
- ...props,
280
- ...(isControlled ? {
281
- value
282
- } : {
283
- initialValue
284
- })
285
- });
286
- }
287
- }), isExpanded && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
288
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Listbox.default.Overlay, {
289
- overlaidPosition: overlaidPosition,
290
- isReady: isReady,
291
- minWidth: fullWidth ? inputWidth : _constants.MIN_LISTBOX_WIDTH,
292
- maxWidth: inputWidth,
293
- onLayout: onTargetLayout,
294
- ref: openOverlayRef,
295
- children: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.default, {
296
- label: getCopy('loading')
297
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Suggestions.default, {
298
- hasResults: getCopy('hasResults'),
299
- id: "autocomplete",
300
- items: itemsToSuggest(highlight(isControlled ? items : currentItems, currentValue, resultsTextColor)),
301
- noResults: noResults ?? getCopy('noResults'),
302
- onClose: handleClose,
303
- onSelect: handleSelect,
304
- parentRef: inputRef,
305
- ref: targetRef
306
- })
307
- }), (targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
308
- // This catches and shifts focus to other interactive elements.
309
- onFocus: () => {
310
- var _targetRef$current;
311
-
312
- return targetRef === null || targetRef === void 0 ? void 0 : (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.focus();
313
- } // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
314
- ,
315
- tabIndex: 0
316
- })]
317
- })]
318
- });
319
- });
320
- Autocomplete.displayName = 'Autocomplete'; // If a language dictionary entry is provided, it must contain every key
321
-
322
- const dictionaryContentShape = _propTypes.default.shape({
323
- hasResults: _propTypes.default.string.isRequired,
324
- loading: _propTypes.default.string.isRequired,
325
- noResults: _propTypes.default.string.isRequired
326
- });
327
-
328
- Autocomplete.propTypes = { ...selectedSystemPropTypes,
329
-
330
- /**
331
- * Can be used to provide a function that renders a custom input:
332
- * <Autocomplete items={items} value={currentValue}>
333
- * {({ inputId, inputRef, onChange, onKeyPress, readOnly, tokens, value }) => (
334
- * <Search
335
- * nativeID={inputId}
336
- * ref={inputRef}
337
- * onChange={onChange}
338
- * onKeyPress={onKeyPress}
339
- * readOnly={readOnly}
340
- * tokens={tokens}
341
- * value={value}
342
- * />
343
- * )}
344
- * </Autocomplete>
345
- */
346
- children: _propTypes.default.func,
347
-
348
- /**
349
- * Copy language identifier
350
- */
351
- copy: _propTypes.default.oneOfType([_propTypes.default.oneOf(['en', 'fr']), dictionaryContentShape]),
352
-
353
- /**
354
- * Set to true in order to display the loading indicator instead of results
355
- */
356
- isLoading: _propTypes.default.bool,
357
-
358
- /**
359
- * List of items to display as suggestions
360
- */
361
- items: _propTypes.default.arrayOf(_propTypes.default.shape({
362
- id: _propTypes.default.string,
363
- label: _propTypes.default.string
364
- })),
365
-
366
- /**
367
- * Label to display alongside the spinner when in a loading state
368
- */
369
- loadingLabel: _propTypes.default.string,
370
-
371
- /**
372
- * Minimum number of characters typed for a list of suggestions to appear
373
- */
374
- minToSuggestion: _propTypes.default.number,
375
-
376
- /**
377
- * Maximum number of suggestions provided at the same time
378
- */
379
- maxSuggestions: _propTypes.default.number,
380
-
381
- /**
382
- * Text or JSX to render when no results are available
383
- */
384
- noResults: _propTypes.default.node,
385
-
386
- /**
387
- * Handler function to be called when the input value changes
388
- */
389
- onChange: _propTypes.default.func,
390
-
391
- /**
392
- * Handler function to be called when the clear button (appears if the handler is passed) is pressed
393
- */
394
- onClear: _propTypes.default.func,
395
-
396
- /**
397
- * Callback function to be called when an item is selected from the list
398
- */
399
- onSelect: _propTypes.default.func,
400
-
401
- /**
402
- * Input value for controlled usage
403
- */
404
- value: _propTypes.default.string
405
- };
406
- var _default = Autocomplete;
407
- exports.default = _default;
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _componentsBase = require("@telus-uds/components-base");
13
-
14
- var _Spinner = _interopRequireDefault(require("../Spinner"));
15
-
16
- var _jsxRuntime = require("react/jsx-runtime");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- const Loading = _ref => {
21
- let {
22
- label
23
- } = _ref;
24
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Box, {
25
- space: 3,
26
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.StackView, {
27
- direction: "row",
28
- space: 2,
29
- tokens: {
30
- alignItems: 'center'
31
- },
32
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.default, {
33
- inline: true,
34
- show: true,
35
- label: label,
36
- labelPosition: "right"
37
- })
38
- })
39
- });
40
- };
41
-
42
- Loading.propTypes = {
43
- label: _propTypes.default.string
44
- };
45
- var _default = Loading;
46
- exports.default = _default;
@@ -1,81 +0,0 @@
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 _componentsBase = require("@telus-uds/components-base");
13
-
14
- var _Listbox = _interopRequireDefault(require("../Listbox"));
15
-
16
- var _jsxRuntime = require("react/jsx-runtime");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- 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); }
21
-
22
- 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; }
23
-
24
- const Suggestions = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
25
- let {
26
- hasResults,
27
- items = [],
28
- noResults,
29
- onClose,
30
- onSelect,
31
- parentRef
32
- } = _ref;
33
- const pressableItems = items.map(_ref2 => {
34
- let {
35
- id,
36
- ...rest
37
- } = _ref2;
38
- return {
39
- id,
40
- onPress: () => onSelect(id),
41
- ...rest
42
- };
43
- });
44
- if (items !== null && items !== void 0 && items.length) return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
45
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.A11yText, {
46
- accessibilityLiveRegion: "polite",
47
- text: hasResults
48
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Listbox.default, {
49
- items: pressableItems,
50
- firstItemRef: ref,
51
- parentRef: parentRef,
52
- onClose: onClose
53
- })]
54
- });
55
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Box, {
56
- space: 3,
57
- children: typeof noResults === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
58
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
59
- accessibilityLiveRegion: "polite",
60
- variant: {
61
- size: 'small'
62
- },
63
- children: noResults
64
- })
65
- }) : noResults
66
- });
67
- });
68
- Suggestions.displayName = 'Suggestions';
69
- Suggestions.propTypes = {
70
- hasResults: _propTypes.default.string.isRequired,
71
- items: _propTypes.default.arrayOf(_propTypes.default.shape({
72
- id: _propTypes.default.string,
73
- label: _propTypes.default.node
74
- })).isRequired,
75
- noResults: _propTypes.default.node.isRequired,
76
- onClose: _propTypes.default.func.isRequired,
77
- onSelect: _propTypes.default.func.isRequired,
78
- parentRef: _propTypes.default.object.isRequired
79
- };
80
- var _default = Suggestions;
81
- exports.default = _default;
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MIN_LISTBOX_WIDTH = exports.INPUT_LEFT_PADDING = exports.DEFAULT_MIN_TO_SUGGESTION = exports.DEFAULT_MAX_SUGGESTIONS = void 0;
7
-
8
- var _palette = _interopRequireDefault(require("@telus-uds/palette-allium/build/web/palette"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- const DEFAULT_MIN_TO_SUGGESTION = 1;
13
- exports.DEFAULT_MIN_TO_SUGGESTION = DEFAULT_MIN_TO_SUGGESTION;
14
- const DEFAULT_MAX_SUGGESTIONS = 5;
15
- exports.DEFAULT_MAX_SUGGESTIONS = DEFAULT_MAX_SUGGESTIONS;
16
- const INPUT_LEFT_PADDING = _palette.default.size.size16;
17
- exports.INPUT_LEFT_PADDING = INPUT_LEFT_PADDING;
18
- const MIN_LISTBOX_WIDTH = _palette.default.size.size288;
19
- exports.MIN_LISTBOX_WIDTH = MIN_LISTBOX_WIDTH;
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {
8
- en: {
9
- hasResults: 'Some results are available',
10
- loading: 'Searching...',
11
- noResults: 'No results found'
12
- },
13
- fr: {
14
- hasResults: 'Quelques suggestions sont disponible',
15
- loading: 'Recherche...',
16
- noResults: 'Aucun résultat trouvé'
17
- }
18
- };
19
- exports.default = _default;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _Autocomplete = _interopRequireDefault(require("./Autocomplete"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- var _default = _Autocomplete.default;
13
- exports.default = _default;