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