@pingux/astro 2.71.0-alpha.0 → 2.71.0-alpha.2

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 (25) hide show
  1. package/lib/cjs/components/ListBox/ListBox.js +4 -2
  2. package/lib/cjs/components/ListBox/ListBox.styles.js +20 -0
  3. package/lib/cjs/components/ListBox/Option.js +47 -8
  4. package/lib/cjs/components/MultivaluesField/CondensedMultivaluesField.js +508 -0
  5. package/lib/cjs/components/MultivaluesField/DefaultMultivaluesField.js +616 -0
  6. package/lib/cjs/components/MultivaluesField/MultivaluesField.js +18 -481
  7. package/lib/cjs/components/MultivaluesField/MultivaluesField.stories.js +114 -2
  8. package/lib/cjs/components/MultivaluesField/MultivaluesField.test.js +251 -2
  9. package/lib/cjs/components/SelectFieldBase/SelectFieldBase.js +3 -1
  10. package/lib/cjs/recipes/DateTimeRangePicker.stories.js +182 -0
  11. package/lib/cjs/types/listBox.d.ts +6 -0
  12. package/lib/cjs/utils/designUtils/figmaLinks.d.ts +3 -0
  13. package/lib/cjs/utils/designUtils/figmaLinks.js +3 -0
  14. package/lib/components/ListBox/ListBox.js +4 -2
  15. package/lib/components/ListBox/ListBox.styles.js +20 -0
  16. package/lib/components/ListBox/Option.js +47 -8
  17. package/lib/components/MultivaluesField/CondensedMultivaluesField.js +495 -0
  18. package/lib/components/MultivaluesField/DefaultMultivaluesField.js +603 -0
  19. package/lib/components/MultivaluesField/MultivaluesField.js +18 -480
  20. package/lib/components/MultivaluesField/MultivaluesField.stories.js +111 -1
  21. package/lib/components/MultivaluesField/MultivaluesField.test.js +250 -2
  22. package/lib/components/SelectFieldBase/SelectFieldBase.js +3 -1
  23. package/lib/recipes/DateTimeRangePicker.stories.js +167 -0
  24. package/lib/utils/designUtils/figmaLinks.js +3 -0
  25. package/package.json +1 -1
@@ -0,0 +1,603 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
4
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
5
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
6
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
7
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
8
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
9
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
10
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
11
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
12
+ var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onOpenChange", "onSelectionChange", "placeholder", "readOnlyKeys", "selectedKeys", "scrollBoxProps", "status"];
13
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context11, _context12; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context11 = ownKeys(Object(source), !0)).call(_context11, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context12 = ownKeys(Object(source))).call(_context12, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
15
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
16
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
17
+ import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
18
+ import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/trim";
19
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
20
+ import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
21
+ import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
22
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
23
+ import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
24
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
25
+ import { DismissButton, FocusScope, useOverlayPosition } from 'react-aria';
26
+ import Clear from '@pingux/mdi-react/CloseIcon';
27
+ import { useFilter } from '@react-aria/i18n';
28
+ import { useLayoutEffect, useResizeObserver } from '@react-aria/utils';
29
+ import { VisuallyHidden } from '@react-aria/visually-hidden';
30
+ import { useListState } from '@react-stately/list';
31
+ import PropTypes from 'prop-types';
32
+ import { Badge, Box, Icon, IconButton, PopoverContainer, ScrollBox, Text, TextField } from '../..';
33
+ import { MultivaluesContext } from '../../context/MultivaluesContext';
34
+ import { usePropWarning } from '../../hooks';
35
+ import { getPendoID } from '../../utils/devUtils/constants/pendoID';
36
+ import { isIterableProp } from '../../utils/devUtils/props/isIterable';
37
+ import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
38
+ import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
39
+ import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusProp';
40
+ import ListBox from '../ListBox';
41
+ import { jsx as ___EmotionJSX } from "@emotion/react";
42
+ var DefaultMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
43
+ var _context8, _listBoxRef$current;
44
+ var defaultSelectedKeys = props.defaultSelectedKeys,
45
+ direction = props.direction,
46
+ _props$disabledKeys = props.disabledKeys,
47
+ disabledKeys = _props$disabledKeys === void 0 ? [] : _props$disabledKeys,
48
+ containerProps = props.containerProps,
49
+ hasAutoFocus = props.hasAutoFocus,
50
+ hasNoStatusIndicator = props.hasNoStatusIndicator,
51
+ helperText = props.helperText,
52
+ customInputProps = props.inputProps,
53
+ isDisabled = props.isDisabled,
54
+ isNotFlippable = props.isNotFlippable,
55
+ isReadOnly = props.isReadOnly,
56
+ isRequired = props.isRequired,
57
+ initialItems = props.items,
58
+ label = props.label,
59
+ mode = props.mode,
60
+ _onBlur = props.onBlur,
61
+ _onFocus = props.onFocus,
62
+ onInputChange = props.onInputChange,
63
+ onKeyDown = props.onKeyDown,
64
+ _onKeyUp = props.onKeyUp,
65
+ onOpenChange = props.onOpenChange,
66
+ onSelectionChange = props.onSelectionChange,
67
+ placeholder = props.placeholder,
68
+ _props$readOnlyKeys = props.readOnlyKeys,
69
+ readOnlyKeys = _props$readOnlyKeys === void 0 ? [] : _props$readOnlyKeys,
70
+ selectedKeys = props.selectedKeys,
71
+ scrollBoxProps = props.scrollBoxProps,
72
+ status = props.status,
73
+ others = _objectWithoutProperties(props, _excluded);
74
+ var hasCustomValue = mode === 'non-restrictive';
75
+ usePropWarning(props, 'disabled', 'isDisabled');
76
+ var _useState = useState([]),
77
+ _useState2 = _slicedToArray(_useState, 2),
78
+ customItems = _useState2[0],
79
+ setCustomItems = _useState2[1];
80
+ var _useState3 = useState(''),
81
+ _useState4 = _slicedToArray(_useState3, 2),
82
+ filterString = _useState4[0],
83
+ setFilterString = _useState4[1];
84
+ var _useState5 = useState(false),
85
+ _useState6 = _slicedToArray(_useState5, 2),
86
+ isOpen = _useState6[0],
87
+ setIsOpen = _useState6[1];
88
+ var _useState7 = useState(initialItems),
89
+ _useState8 = _slicedToArray(_useState7, 2),
90
+ items = _useState8[0],
91
+ setItems = _useState8[1];
92
+ var _useState9 = useState(''),
93
+ _useState10 = _slicedToArray(_useState9, 2),
94
+ activeDescendant = _useState10[0],
95
+ setActiveDescendant = _useState10[1];
96
+ var toggleItems = function toggleItems(keys) {
97
+ setItems(_filterInstanceProperty(initialItems).call(initialItems, function (item) {
98
+ var _context;
99
+ return !_includesInstanceProperty(_context = _Array$from(keys)).call(_context, item.key);
100
+ }));
101
+ setFilterString('');
102
+ if (onSelectionChange) onSelectionChange(keys);
103
+ };
104
+ var _useFilter = useFilter({
105
+ sensitivity: 'base'
106
+ }),
107
+ contains = _useFilter.contains;
108
+ var state = useListState(_objectSpread(_objectSpread({}, props), {}, {
109
+ filter: function filter(nodes) {
110
+ var _context2;
111
+ return _filterInstanceProperty(_context2 = _Array$from(nodes)).call(_context2, function (item) {
112
+ return contains(item.textValue, filterString);
113
+ });
114
+ },
115
+ items: _filterInstanceProperty(items).call(items, function (_ref) {
116
+ var key = _ref.key;
117
+ return !_includesInstanceProperty(readOnlyKeys).call(readOnlyKeys, key);
118
+ }),
119
+ onSelectionChange: toggleItems,
120
+ selectionMode: 'multiple'
121
+ }));
122
+ var selectionManager = state.selectionManager;
123
+ var filteredItems = useMemo(function () {
124
+ return _Array$from(state.collection);
125
+ }, [state.collection, filterString]);
126
+ var close = function close() {
127
+ return setIsOpen(false);
128
+ };
129
+ var closeBadgeRefs = useRef([]);
130
+ var inputWrapperRef = useRef();
131
+ var inputRef = useRef();
132
+ /* istanbul ignore next */
133
+ useImperativeHandle(ref, function () {
134
+ return inputWrapperRef.current;
135
+ });
136
+ useImperativeHandle(ref, function () {
137
+ return inputRef.current;
138
+ });
139
+ var listBoxRef = useRef();
140
+ var popoverRef = useRef();
141
+ var _useOverlayPosition = useOverlayPosition({
142
+ isOpen: isOpen,
143
+ onClose: close,
144
+ offset: 1,
145
+ overlayRef: popoverRef,
146
+ placement: "".concat(direction, " end"),
147
+ scrollRef: listBoxRef,
148
+ shouldFlip: !isNotFlippable,
149
+ targetRef: inputWrapperRef
150
+ }),
151
+ overlayProps = _useOverlayPosition.overlayProps,
152
+ placement = _useOverlayPosition.placement,
153
+ updatePosition = _useOverlayPosition.updatePosition;
154
+
155
+ // Update position once the ListBox has rendered. This ensures that
156
+ // it flips properly when it doesn't fit in the available space.
157
+ /* istanbul ignore next */
158
+ useLayoutEffect(function () {
159
+ if (isOpen) {
160
+ requestAnimationFrame(function () {
161
+ updatePosition();
162
+ });
163
+ }
164
+ }, [isOpen, selectionManager.selectedKeys, updatePosition]);
165
+
166
+ // Measure the width of the input to inform the width of the menu (below).
167
+ var _useState11 = useState(null),
168
+ _useState12 = _slicedToArray(_useState11, 2),
169
+ menuWidth = _useState12[0],
170
+ setMenuWidth = _useState12[1];
171
+ var onResize = useCallback(function () {
172
+ /* istanbul ignore next */
173
+ if (inputWrapperRef.current) {
174
+ setMenuWidth("".concat(inputWrapperRef.current.offsetWidth + 2, "px"));
175
+ }
176
+ }, [inputWrapperRef, isOpen, setMenuWidth]);
177
+ useResizeObserver({
178
+ ref: inputWrapperRef,
179
+ onResize: onResize
180
+ });
181
+ useLayoutEffect(onResize, [onResize]);
182
+ var style = _objectSpread(_objectSpread({}, overlayProps.style), {}, {
183
+ width: menuWidth,
184
+ minWidth: menuWidth
185
+ });
186
+ useEffect(function () {
187
+ if (defaultSelectedKeys) selectionManager.setSelectedKeys(defaultSelectedKeys);
188
+ }, []);
189
+ useEffect(function () {
190
+ if (selectedKeys) selectionManager.setSelectedKeys(selectedKeys);
191
+ }, []);
192
+ useEffect(function () {
193
+ if (onOpenChange) onOpenChange(isOpen);
194
+ if (!isOpen) setActiveDescendant('');
195
+ }, [isOpen]);
196
+ var addNewBadgeFromInput = function addNewBadgeFromInput(inputValue) {
197
+ var _context3, _context4;
198
+ var key = _trimInstanceProperty(inputValue).call(inputValue);
199
+ if (key === '') {
200
+ return;
201
+ }
202
+ if (state.selectionManager.isSelected(key)) {
203
+ return;
204
+ }
205
+ selectionManager.setSelectedKeys(_concatInstanceProperty(_context3 = []).call(_context3, _Array$from(selectionManager.state.selectedKeys), [key]));
206
+ setCustomItems(_concatInstanceProperty(_context4 = []).call(_context4, customItems, [{
207
+ id: key,
208
+ key: key,
209
+ name: key
210
+ }]));
211
+ setFilterString('');
212
+ };
213
+
214
+ // there actually is a test for this, but coverage is not picking it up.
215
+ /* istanbul ignore next */
216
+ var selectTheOnlyFilteredItem = function selectTheOnlyFilteredItem() {
217
+ var key = filteredItems[0].key;
218
+ if (!_includesInstanceProperty(disabledKeys).call(disabledKeys, key)) {
219
+ selectionManager.toggleSelection(filteredItems[0].key);
220
+ setFilterString('');
221
+ }
222
+ };
223
+
224
+ // there actually is a test for this, but coverage is not picking it up.
225
+ /* istanbul ignore next */
226
+ var onBlurTextField = function onBlurTextField() {
227
+ if (hasCustomValue && filteredItems.length === 1) {
228
+ selectTheOnlyFilteredItem();
229
+ } else if (hasCustomValue) {
230
+ addNewBadgeFromInput(filterString);
231
+ }
232
+ };
233
+
234
+ /* istanbul ignore next */
235
+ var keyDown = function keyDown(e) {
236
+ switch (e.key) {
237
+ case 'Enter':
238
+ {
239
+ e.preventDefault();
240
+ if (selectionManager.focusedKey) {
241
+ var key = selectionManager.focusedKey;
242
+ if (!_includesInstanceProperty(disabledKeys).call(disabledKeys, key)) {
243
+ selectionManager.toggleSelection(selectionManager.focusedKey);
244
+ setFilterString('');
245
+ }
246
+ } else if (hasCustomValue && !selectionManager.focusedKey) {
247
+ var _key = e.target.value;
248
+ if (_key === '') {
249
+ return;
250
+ }
251
+ addNewBadgeFromInput(e.target.value);
252
+ } else if (hasCustomValue && filteredItems.length === 1) {
253
+ selectTheOnlyFilteredItem();
254
+ } else if (!hasCustomValue) {
255
+ setFilterString('');
256
+ close();
257
+ }
258
+ break;
259
+ }
260
+ case 'ArrowDown':
261
+ {
262
+ var nextKey = state.collection.getKeyAfter(selectionManager.focusedKey) || state.collection.getFirstKey();
263
+ if (nextKey) selectionManager.setFocusedKey(nextKey);
264
+ break;
265
+ }
266
+ case 'ArrowUp':
267
+ {
268
+ var prevKey = state.collection.getKeyBefore(selectionManager.focusedKey) || state.collection.getLastKey();
269
+ if (prevKey) selectionManager.setFocusedKey(prevKey);
270
+ break;
271
+ }
272
+ case 'Escape':
273
+ {
274
+ setFilterString('');
275
+ close();
276
+ break;
277
+ }
278
+ default:
279
+ break;
280
+ }
281
+ if (onKeyDown) onKeyDown(e.nativeEvent);
282
+ };
283
+ var deleteItem = function deleteItem(key, e) {
284
+ var _context5;
285
+ var activeBadgesKeys = _reduceInstanceProperty(_context5 = closeBadgeRefs.current).call(_context5, function (result, item) {
286
+ if (item) {
287
+ result.push(item.dataset.item);
288
+ }
289
+ return result;
290
+ }, []);
291
+ selectionManager.toggleSelection(key);
292
+ if (e.pointerType !== 'keyboard') return;
293
+ if (activeBadgesKeys.length > 1) {
294
+ var badgeIndex = _findIndexInstanceProperty(activeBadgesKeys).call(activeBadgesKeys, function (item) {
295
+ return item === key;
296
+ });
297
+ var nextFocusBadgeIndex = badgeIndex === activeBadgesKeys.length - 1 ? badgeIndex - 1 : badgeIndex;
298
+ closeBadgeRefs.current[nextFocusBadgeIndex].focus();
299
+ } else {
300
+ inputRef.current.focus();
301
+ }
302
+ };
303
+ var readOnlyTextItem = function readOnlyTextItem(key, name) {
304
+ return ___EmotionJSX(Text, {
305
+ key: key,
306
+ role: "presentation",
307
+ label: name,
308
+ variant: "bodyStrong",
309
+ sx: {
310
+ bg: 'accent.95',
311
+ fontSize: 'sm',
312
+ alignSelf: 'center',
313
+ ':not(:last-of-type):after': {
314
+ content: "\",\xA0\""
315
+ }
316
+ }
317
+ }, name);
318
+ };
319
+ var readOnlyInputEntry = isReadOnly && (readOnlyKeys.length ? _mapInstanceProperty(readOnlyKeys).call(readOnlyKeys, function (key) {
320
+ var _context6, _context7;
321
+ var item = _findInstanceProperty(_context6 = _concatInstanceProperty(_context7 = []).call(_context7, initialItems, customItems)).call(_context6, function (el) {
322
+ return el.key === key;
323
+ });
324
+ if (item) {
325
+ return readOnlyTextItem(item.key, item.name);
326
+ }
327
+ return null;
328
+ }) : _mapInstanceProperty(initialItems).call(initialItems, function (item) {
329
+ return readOnlyTextItem(item.key, item.name);
330
+ }));
331
+ var readOnlyItems = !isReadOnly && _mapInstanceProperty(readOnlyKeys).call(readOnlyKeys, function (key) {
332
+ var item = _findInstanceProperty(initialItems).call(initialItems, function (el) {
333
+ return el.key === key;
334
+ });
335
+ if (item) {
336
+ return ___EmotionJSX(Badge, {
337
+ key: item.key,
338
+ label: item.name,
339
+ variant: "readOnlyBadge",
340
+ bg: "white",
341
+ textProps: {
342
+ sx: {
343
+ color: 'text.primary',
344
+ tabIndex: '-1'
345
+ }
346
+ },
347
+ as: "li",
348
+ tabIndex: 0
349
+ });
350
+ }
351
+ return null;
352
+ });
353
+ var multivaluesFieldBadge = function multivaluesFieldBadge(item, index) {
354
+ return ___EmotionJSX(Box, {
355
+ as: "li",
356
+ key: "li ".concat(item.key)
357
+ }, ___EmotionJSX(Badge, _extends({
358
+ key: item.key,
359
+ role: "presentation",
360
+ variant: "selectedItemBadge",
361
+ bg: "active",
362
+ label: item.name,
363
+ slots: item.slots
364
+ }, item.badgeProps), ___EmotionJSX(IconButton, _extends({
365
+ "aria-label": "delete ".concat(item.name),
366
+ "data-item": item.name,
367
+ onPress: function onPress(e) {
368
+ return deleteItem(item.key, e);
369
+ },
370
+ ref: function ref(el) {
371
+ return closeBadgeRefs.current[index] = el;
372
+ } // eslint-disable-line
373
+ ,
374
+ variant: "badge.deleteButton",
375
+ "aria-describedby": "selectedKeysState"
376
+ }, item.buttonProps), ___EmotionJSX(Icon, {
377
+ icon: Clear,
378
+ color: "white",
379
+ size: 14,
380
+ title: {
381
+ name: 'Clear Icon'
382
+ }
383
+ }))));
384
+ };
385
+ var selectedItems = ___EmotionJSX(React.Fragment, null, _mapInstanceProperty(_context8 = _Array$from(selectionManager.selectedKeys)).call(_context8, function (key, i) {
386
+ var _context9, _context10;
387
+ var item = _findInstanceProperty(_context9 = _concatInstanceProperty(_context10 = []).call(_context10, initialItems, customItems)).call(_context9, function (el) {
388
+ return el.key === key;
389
+ });
390
+ if (item) {
391
+ return multivaluesFieldBadge(item, i);
392
+ }
393
+ return null;
394
+ }));
395
+ var listbox = ___EmotionJSX(FocusScope, null, ___EmotionJSX(DismissButton, {
396
+ onDismiss: close
397
+ }), ___EmotionJSX(ScrollBox, scrollBoxProps, ___EmotionJSX(ListBox, {
398
+ ref: listBoxRef,
399
+ hasAutoFocus: hasAutoFocus,
400
+ hasVirtualFocus: true,
401
+ hasNoEmptySelection: true,
402
+ state: state,
403
+ "aria-label": "List of options"
404
+ })), ___EmotionJSX(DismissButton, {
405
+ onDismiss: close
406
+ }));
407
+ var visuallyHidden = ___EmotionJSX(VisuallyHidden, {
408
+ id: "selectedKeysState"
409
+ }, "Selected options:", _Array$from(selectionManager.selectedKeys).join(' '));
410
+
411
+ // the reason we are using two different visually hiddens, rather than one that updates it's value
412
+ // is because there are tests that break if an empty visually hidden is rendered in the TextField
413
+ var EmptyVisuallyHidden = function EmptyVisuallyHidden() {
414
+ return ___EmotionJSX(VisuallyHidden, {
415
+ id: "emptyKeysState"
416
+ }, "Nothing Selected");
417
+ };
418
+ var inputProps = _objectSpread(_objectSpread({}, customInputProps), {}, {
419
+ controlProps: {
420
+ 'aria-activedescendant': activeDescendant,
421
+ 'aria-controls': (_listBoxRef$current = listBoxRef.current) === null || _listBoxRef$current === void 0 ? void 0 : _listBoxRef$current.id,
422
+ 'aria-expanded': isOpen,
423
+ role: 'combobox',
424
+ ref: inputRef
425
+ },
426
+ hasAutoFocus: hasAutoFocus,
427
+ hasNoStatusIndicator: hasNoStatusIndicator,
428
+ isDisabled: isDisabled,
429
+ isReadOnly: isReadOnly,
430
+ isRequired: isRequired,
431
+ label: label,
432
+ placeholder: placeholder,
433
+ wrapperProps: {
434
+ ref: inputWrapperRef,
435
+ variant: 'forms.input.multivaluesWrapper',
436
+ sx: isReadOnly && {
437
+ boxShadow: 'inset 0 0 0 100px #e5e9f8',
438
+ border: 'none'
439
+ }
440
+ },
441
+ status: status
442
+ });
443
+ return ___EmotionJSX(MultivaluesContext.Provider, {
444
+ value: setActiveDescendant
445
+ }, ___EmotionJSX(Box, containerProps, ___EmotionJSX(TextField, _extends({
446
+ onBlur: function onBlur(e) {
447
+ setIsOpen(false);
448
+ if (filterString !== '') onBlurTextField();
449
+ if (_onBlur) _onBlur(e.nativeEvent);
450
+ if (!hasCustomValue) setFilterString('');
451
+ },
452
+ onChange: function onChange(e) {
453
+ if (!isOpen) setIsOpen(true);
454
+ setFilterString(e.target.value);
455
+ if (onInputChange) onInputChange(e.target.value);
456
+ },
457
+ onFocus: function onFocus(e) {
458
+ if (!isReadOnly) {
459
+ setIsOpen(true);
460
+ }
461
+ if (_onFocus) _onFocus(e.nativeEvent);
462
+ },
463
+ onKeyDown: keyDown,
464
+ onKeyUp: function onKeyUp(e) {
465
+ return _onKeyUp && _onKeyUp(e.nativeEvent);
466
+ },
467
+ "aria-describedby": selectionManager.selectedKeys.size > 0 ? 'selectedKeysState' : 'emptyKeysState',
468
+ slots: {
469
+ beforeInput: ___EmotionJSX(React.Fragment, null, readOnlyItems && ___EmotionJSX(Box, {
470
+ as: "ul",
471
+ isRow: true,
472
+ sx: {
473
+ p: 0,
474
+ flexWrap: 'wrap'
475
+ }
476
+ }, readOnlyItems), ' ', selectedItems && ___EmotionJSX(Box, {
477
+ as: "ul",
478
+ isRow: true,
479
+ sx: {
480
+ p: 0,
481
+ flexWrap: 'wrap'
482
+ }
483
+ }, selectedItems), readOnlyInputEntry, selectionManager.selectedKeys.size > 0 && visuallyHidden)
484
+ } // eslint-disable-line
485
+ ,
486
+ value: filterString,
487
+ helperText: helperText,
488
+ "aria-invalid": status === 'error' && true
489
+ }, getPendoID('MultivaluesField'), others, inputProps)), ___EmotionJSX(PopoverContainer, {
490
+ hasNoArrow: true,
491
+ isNonModal: true,
492
+ isOpen: !state.collection.size ? false : isOpen,
493
+ onClose: close,
494
+ placement: placement,
495
+ ref: popoverRef,
496
+ style: style
497
+ }, listbox), ___EmotionJSX(EmptyVisuallyHidden, null)));
498
+ });
499
+ DefaultMultivaluesField.propTypes = _objectSpread(_objectSpread(_objectSpread({
500
+ /** The initial selected keys in the collection (uncontrolled). */
501
+ defaultSelectedKeys: isIterableProp,
502
+ /** Where the menu opens relative to its trigger. */
503
+ direction: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
504
+ /**
505
+ * The item keys that are disabled. These items cannot be selected.
506
+ */
507
+ disabledKeys: isIterableProp,
508
+ /** Whether the element should receive focus on render. */
509
+ hasAutoFocus: PropTypes.bool,
510
+ /** Whether the field has a status indicator. */
511
+ hasNoStatusIndicator: PropTypes.bool,
512
+ /** Text rendered below the input. */
513
+ helperText: PropTypes.node,
514
+ /**
515
+ * Props that get passed as-is to the underlying TextField element
516
+ */
517
+ inputProps: PropTypes.shape({}),
518
+ /** Whether the input is disabled. */
519
+ isDisabled: PropTypes.bool,
520
+ /**
521
+ * Whether the menu is prevented from flipping directions when insufficient space is
522
+ * available for the given `direction` placement.
523
+ */
524
+ isNotFlippable: PropTypes.bool,
525
+ /** Whether the input can be selected but not changed by the user. */
526
+ isReadOnly: PropTypes.bool,
527
+ /** Whether user input is required on the input before form submission. */
528
+ isRequired: PropTypes.bool,
529
+ /** The list of items.
530
+ *
531
+ * **Note:** Every item needs to have key and name properties.
532
+ *
533
+ * `Array<{key: string, name: string}>`
534
+ */
535
+ items: isIterableProp,
536
+ /** The rendered label for the field. */
537
+ label: PropTypes.string,
538
+ /** Whether the component allows to create new values or only choose from the selection list */
539
+ mode: PropTypes.oneOf(['restrictive', 'non-restrictive']),
540
+ /**
541
+ * Handler that is called when the element loses focus.
542
+ *
543
+ * `(e: FocusEvent) => void`
544
+ */
545
+ onBlur: PropTypes.func,
546
+ /**
547
+ * Handler that is called when the element receives focus.
548
+ *
549
+ * `(e: FocusEvent) => void`
550
+ */
551
+ onFocus: PropTypes.func,
552
+ /**
553
+ * Handler that is called when the input value changes.
554
+ *
555
+ * `(value: string) => void`
556
+ */
557
+ onInputChange: PropTypes.func,
558
+ /**
559
+ * Handler that is called when a key is pressed.
560
+ *
561
+ * `(e: KeyboardEvent) => void`
562
+ */
563
+ onKeyDown: PropTypes.func,
564
+ /**
565
+ * Handler that is called when a key is released.
566
+ *
567
+ * `(e: KeyboardEvent) => void`
568
+ */
569
+ onKeyUp: PropTypes.func,
570
+ /**
571
+ * Method that is called when the open state of the menu changes.
572
+ *
573
+ * `(isOpen: boolean) => void`
574
+ */
575
+ onOpenChange: PropTypes.func,
576
+ /**
577
+ * Handler that is called when the selection changes.
578
+ *
579
+ * `(keys: Iterable<Key>) => any`
580
+ */
581
+ onSelectionChange: PropTypes.func,
582
+ /** Temporary text that occupies the text input when it is empty. */
583
+ placeholder: PropTypes.string,
584
+ /**
585
+ * The item keys that are readonly. These items cannot be changed or selected.
586
+ */
587
+ readOnlyKeys: PropTypes.arrayOf(PropTypes.string),
588
+ /** The currently selected keys in the collection (controlled). */
589
+ selectedKeys: isIterableProp,
590
+ // /** Props object that is spread directly into the ScrollBox element. */
591
+ /** @ignore */
592
+ scrollBoxProps: PropTypes.shape({
593
+ maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.number])
594
+ })
595
+ }, statusPropTypes), ariaAttributesBasePropTypes), inputFieldAttributesBasePropTypes);
596
+ DefaultMultivaluesField.defaultProps = _objectSpread({
597
+ direction: 'bottom',
598
+ isReadOnly: false,
599
+ scrollBoxProps: {
600
+ maxHeight: 300
601
+ }
602
+ }, statusDefaultProp);
603
+ export default DefaultMultivaluesField;