@pingux/astro 2.242.0-alpha.0 → 2.243.0-alpha.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 (35) hide show
  1. package/lib/cjs/components/CodeView/CodeView.js +8 -4
  2. package/lib/cjs/components/CopyText/CopyButton.js +2 -7
  3. package/lib/cjs/components/CopyText/CopyText.js +10 -3
  4. package/lib/cjs/components/MultivaluesField/BadgeLabelTooltip.d.ts +3 -0
  5. package/lib/cjs/components/MultivaluesField/BadgeLabelTooltip.js +3 -3
  6. package/lib/cjs/components/MultivaluesField/CondensedMultivaluesField.d.ts +4 -0
  7. package/lib/cjs/components/MultivaluesField/CondensedMultivaluesField.js +24 -132
  8. package/lib/cjs/components/MultivaluesField/DefaultMultivaluesField.d.ts +4 -0
  9. package/lib/cjs/components/MultivaluesField/DefaultMultivaluesField.js +33 -139
  10. package/lib/cjs/components/MultivaluesField/MultivaluesField.d.ts +4 -0
  11. package/lib/cjs/components/MultivaluesField/MultivaluesField.js +6 -104
  12. package/lib/cjs/components/MultivaluesField/index.d.ts +1 -0
  13. package/lib/cjs/components/RadioGroupField/RadioGroupField.js +1 -1
  14. package/lib/cjs/styles/themes/next-gen/codeView/codeView.d.ts +6 -42
  15. package/lib/cjs/styles/themes/next-gen/codeView/codeView.js +2 -14
  16. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +10 -70
  17. package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +2 -14
  18. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +4 -28
  19. package/lib/cjs/types/MultivaluesField.d.ts +212 -0
  20. package/lib/cjs/types/MultivaluesField.js +5 -0
  21. package/lib/cjs/types/copyText.d.ts +1 -0
  22. package/lib/cjs/types/index.d.ts +1 -0
  23. package/lib/cjs/types/index.js +11 -0
  24. package/lib/components/CodeView/CodeView.js +8 -4
  25. package/lib/components/CopyText/CopyButton.js +2 -7
  26. package/lib/components/CopyText/CopyText.js +10 -3
  27. package/lib/components/MultivaluesField/BadgeLabelTooltip.js +3 -3
  28. package/lib/components/MultivaluesField/CondensedMultivaluesField.js +24 -132
  29. package/lib/components/MultivaluesField/DefaultMultivaluesField.js +33 -139
  30. package/lib/components/MultivaluesField/MultivaluesField.js +7 -105
  31. package/lib/components/RadioGroupField/RadioGroupField.js +1 -1
  32. package/lib/styles/themes/next-gen/codeView/codeView.js +2 -14
  33. package/lib/types/MultivaluesField.js +1 -0
  34. package/lib/types/index.js +1 -0
  35. package/package.json +1 -1
@@ -6,23 +6,19 @@ import { useFocusWithin } from '@react-aria/interactions';
6
6
  import { useLayoutEffect, useResizeObserver } from '@react-aria/utils';
7
7
  import { VisuallyHidden } from '@react-aria/visually-hidden';
8
8
  import { useListState } from '@react-stately/list';
9
- import PropTypes from 'prop-types';
10
9
  import { Box, Button, Icon, Loader, ScrollBox, Text, TextField } from '../..';
11
10
  import { MultivaluesContext } from '../../context/MultivaluesContext';
12
11
  import { useGetTheme, useInputLoader, usePropWarning } from '../../hooks';
13
12
  import loadingStates from '../../utils/devUtils/constants/loadingStates';
14
13
  import { getPendoID } from '../../utils/devUtils/constants/pendoID';
15
- import { isIterableProp } from '../../utils/devUtils/props/isIterable';
16
- import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
17
- import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
18
- import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusProp';
14
+ import statuses from '../../utils/devUtils/constants/statuses';
19
15
  import ListBox from '../ListBox';
20
16
  import Popover from '../Popover/Popover';
21
17
  import { jsx as ___EmotionJSX } from "@emotion/react";
22
18
  const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
23
19
  const {
24
20
  defaultSelectedKeys,
25
- direction,
21
+ direction = 'bottom',
26
22
  disabledKeys = [],
27
23
  containerProps,
28
24
  filter,
@@ -34,7 +30,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
34
30
  isDisabled,
35
31
  isFilteringDisabled,
36
32
  isNotFlippable,
37
- isReadOnly,
33
+ isReadOnly = false,
38
34
  isRequired,
39
35
  items,
40
36
  label,
@@ -52,8 +48,10 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
52
48
  placeholder,
53
49
  selectedKeys,
54
50
  selectedOptionText: selectedOptionTextProp,
55
- scrollBoxProps,
56
- status,
51
+ scrollBoxProps = {
52
+ maxHeight: 300
53
+ },
54
+ status = statuses.DEFAULT,
57
55
  ...others
58
56
  } = props;
59
57
  usePropWarning(props, 'disabled', 'isDisabled');
@@ -61,9 +59,9 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
61
59
  const [isOpen, setIsOpen] = useState(false);
62
60
  const [hasFocusWithin, setFocusWithin] = useState(false);
63
61
  const [activeDescendant, setActiveDescendant] = useState('');
64
- const inputWrapperRef = useRef();
65
- const inputRef = useRef();
66
- const buttonRef = useRef();
62
+ const inputWrapperRef = useRef(null);
63
+ const inputRef = useRef(null);
64
+ const buttonRef = useRef(null);
67
65
  const {
68
66
  icons,
69
67
  themeState: {
@@ -133,8 +131,8 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
133
131
  useImperativeHandle(ref, () => inputWrapperRef.current);
134
132
  /* istanbul ignore next */
135
133
  useImperativeHandle(ref, () => inputRef.current);
136
- const listBoxRef = useRef();
137
- const popoverRef = useRef();
134
+ const listBoxRef = useRef(null);
135
+ const popoverRef = useRef(null);
138
136
 
139
137
  // Measure the width of the input to inform the width of the menu (below).
140
138
  const [menuWidth, setMenuWidth] = useState(null);
@@ -214,11 +212,15 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
214
212
  setIsOpen(false);
215
213
  };
216
214
  const [selectionState, setSelectionState] = useState('Select All');
217
- const arrayItems = Array.from(items);
215
+ const arrayItems = items || [];
218
216
  const itemCount = arrayItems.reduce((count, obj) => count + (obj.children ? obj.children.length : 1), 0);
219
217
  const selectedKeysSize = selectionManager.selectedKeys.size;
220
- const selectedOptionText = selectedOptionTextProp || `${itemCount === selectedKeysSize ? 'All' : selectionManager.state.selectedKeys?.size} Selected`;
221
- const checkboxSelected = selectionManager.state.selectedKeys?.size !== 0 && ___EmotionJSX(Text, {
218
+
219
+ // `selectionManager.state` is private in the react-stately typings but is
220
+ // read throughout this component; the access is kept via a cast.
221
+ const selectionManagerState = selectionManager.state;
222
+ const selectedOptionText = selectedOptionTextProp || `${itemCount === selectedKeysSize ? 'All' : selectionManagerState.selectedKeys?.size} Selected`;
223
+ const checkboxSelected = selectionManagerState.selectedKeys?.size !== 0 && ___EmotionJSX(Text, {
222
224
  color: "text.secondary"
223
225
  }, selectedOptionText);
224
226
  useEffect(() => {
@@ -228,7 +230,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
228
230
  }, [itemCount, selectedKeysSize]);
229
231
  const handleSelection = () => {
230
232
  if (selectedKeysSize < itemCount) {
231
- const allItemNames = arrayItems.flatMap(obj => obj.children ? obj.children.map(child => child.key) : obj.key);
233
+ const allItemNames = arrayItems.flatMap(obj => obj.children ? obj.children.map(child => child.key) : obj.key).filter(key => key !== undefined);
232
234
  selectionManager.setSelectedKeys(allItemNames);
233
235
  setSelectionState('Deselect All');
234
236
  } else if (selectionState === 'Deselect All') {
@@ -274,7 +276,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
274
276
  id: "emptyKeysState"
275
277
  }, "Nothing Selected");
276
278
  };
277
- const placeholderText = selectionManager.state.selectedKeys?.size === 0 ? placeholder || 'Select' : '';
279
+ const placeholderText = selectionManagerState.selectedKeys?.size === 0 ? placeholder || 'Select' : '';
278
280
  const inputProps = {
279
281
  ...customInputProps,
280
282
  controlProps: {
@@ -292,7 +294,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
292
294
  isDisabled,
293
295
  isReadOnly,
294
296
  isRequired,
295
- label,
297
+ label: label,
296
298
  placeholder: placeholderText,
297
299
  wrapperProps: {
298
300
  ref: inputWrapperRef,
@@ -307,7 +309,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
307
309
  const handleButtonPress = () => {
308
310
  if (!isOpen) {
309
311
  setIsOpen(true);
310
- inputRef.current.focus();
312
+ inputRef.current?.focus();
311
313
  } else {
312
314
  setIsOpen(false);
313
315
  }
@@ -367,7 +369,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
367
369
  beforeInput: ___EmotionJSX(React.Fragment, null, checkboxSelected, selectionManager.selectedKeys.size > 0 && visuallyHidden)
368
370
  },
369
371
  value: filterString,
370
- helperText: helperText,
372
+ helperText,
371
373
  "aria-invalid": status === 'error' && true
372
374
  }, getPendoID('MultivaluesField'), others, inputProps)), ___EmotionJSX(Popover, {
373
375
  hasNoArrow: true,
@@ -382,114 +384,4 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
382
384
  onBlur: e => handleBlur(e)
383
385
  }, listbox), ___EmotionJSX(EmptyVisuallyHidden, null)));
384
386
  });
385
- CondensedMultivaluesField.propTypes = {
386
- /** The initial selected keys in the collection (uncontrolled). */
387
- defaultSelectedKeys: isIterableProp,
388
- /** Where the menu opens relative to its trigger. */
389
- direction: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
390
- /**
391
- * The item keys that are disabled. These items cannot be selected.
392
- */
393
- disabledKeys: isIterableProp,
394
- /** Whether the element should receive focus on render. */
395
- hasAutoFocus: PropTypes.bool,
396
- /** Whether the field has the select all button. */
397
- hasNoSelectAll: PropTypes.bool,
398
- /** Whether the field has a status indicator. */
399
- hasNoStatusIndicator: PropTypes.bool,
400
- /** Text rendered below the input. */
401
- helperText: PropTypes.node,
402
- /**
403
- * Props that get passed as-is to the underlying TextField element
404
- */
405
- inputProps: PropTypes.shape({}),
406
- /** Whether the input is disabled. */
407
- isDisabled: PropTypes.bool,
408
- /**
409
- * Whether the menu is prevented from flipping directions when insufficient space is
410
- * available for the given `direction` placement.
411
- */
412
- isNotFlippable: PropTypes.bool,
413
- /** Whether the input can be selected but not changed by the user. */
414
- isReadOnly: PropTypes.bool,
415
- /** Whether user input is required on the input before form submission. */
416
- isRequired: PropTypes.bool,
417
- /** The list of items.
418
- *
419
- * **Note:** Every item needs to have key and name properties.
420
- *
421
- * `Array<{key: string, name: string}>`
422
- */
423
- items: isIterableProp,
424
- /** The rendered label for the field. */
425
- label: PropTypes.string,
426
- /** Whether the component allows to create new values or only choose from the selection list */
427
- mode: PropTypes.oneOf(['restrictive', 'non-restrictive', 'condensed']),
428
- /**
429
- * Handler that is called when the element loses focus.
430
- *
431
- * `(e: FocusEvent) => void`
432
- */
433
- onBlur: PropTypes.func,
434
- /**
435
- * Handler that is called when the element receives focus.
436
- *
437
- * `(e: FocusEvent) => void`
438
- */
439
- onFocus: PropTypes.func,
440
- /**
441
- * Handler that is called when the input value changes.
442
- *
443
- * `(value: string) => void`
444
- */
445
- onInputChange: PropTypes.func,
446
- /**
447
- * Handler that is called when a key is pressed.
448
- *
449
- * `(e: KeyboardEvent) => void`
450
- */
451
- onKeyDown: PropTypes.func,
452
- /**
453
- * Handler that is called when a key is released.
454
- *
455
- * `(e: KeyboardEvent) => void`
456
- */
457
- onKeyUp: PropTypes.func,
458
- /**
459
- * Method that is called when the open state of the menu changes.
460
- *
461
- * `(isOpen: boolean) => void`
462
- */
463
- onOpenChange: PropTypes.func,
464
- /**
465
- * Handler that is called when the selection changes.
466
- *
467
- * `(keys: Iterable<Key>) => any`
468
- */
469
- onSelectionChange: PropTypes.func,
470
- /** Temporary text that occupies the text input when it is empty. */
471
- placeholder: PropTypes.string,
472
- /**
473
- * The item keys that are readonly. These items cannot be changed or selected.
474
- */
475
- readOnlyKeys: PropTypes.arrayOf(PropTypes.string),
476
- /** The currently selected keys in the collection (controlled). */
477
- selectedKeys: isIterableProp,
478
- // /** Props object that is spread directly into the ScrollBox element. */
479
- /** @ignore */
480
- scrollBoxProps: PropTypes.shape({
481
- maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.number])
482
- }),
483
- ...statusPropTypes,
484
- ...ariaAttributesBasePropTypes,
485
- ...inputFieldAttributesBasePropTypes
486
- };
487
- CondensedMultivaluesField.defaultProps = {
488
- direction: 'bottom',
489
- isReadOnly: false,
490
- scrollBoxProps: {
491
- maxHeight: 300
492
- },
493
- ...statusDefaultProp
494
- };
495
387
  export default CondensedMultivaluesField;
@@ -5,16 +5,12 @@ import { useFilter } from '@react-aria/i18n';
5
5
  import { useLayoutEffect, useResizeObserver } from '@react-aria/utils';
6
6
  import { VisuallyHidden } from '@react-aria/visually-hidden';
7
7
  import { useListState } from '@react-stately/list';
8
- import PropTypes from 'prop-types';
9
8
  import { Badge, Box, Loader, ScrollBox, Text, TextField } from '../..';
10
9
  import { MultivaluesContext } from '../../context/MultivaluesContext';
11
10
  import { useGetTheme, useInputLoader, usePropWarning } from '../../hooks';
12
11
  import loadingStates from '../../utils/devUtils/constants/loadingStates';
13
12
  import { getPendoID } from '../../utils/devUtils/constants/pendoID';
14
- import { isIterableProp } from '../../utils/devUtils/props/isIterable';
15
- import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
16
- import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
17
- import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusProp';
13
+ import statuses from '../../utils/devUtils/constants/statuses';
18
14
  import ListBox from '../ListBox';
19
15
  import Popover from '../Popover/Popover';
20
16
  import BadgeLabelTooltip from './BadgeLabelTooltip';
@@ -26,7 +22,7 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
26
22
  } = props;
27
23
  const {
28
24
  defaultSelectedKeys,
29
- direction,
25
+ direction = 'bottom',
30
26
  disabledKeys = [],
31
27
  containerProps,
32
28
  hasAutoFocus,
@@ -36,7 +32,7 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
36
32
  isDisabled,
37
33
  isFilteringDisabled,
38
34
  isNotFlippable,
39
- isReadOnly,
35
+ isReadOnly = false,
40
36
  isRequired,
41
37
  label,
42
38
  loadingState,
@@ -54,8 +50,10 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
54
50
  placeholder,
55
51
  readOnlyKeys = [],
56
52
  selectedKeys,
57
- scrollBoxProps,
58
- status,
53
+ scrollBoxProps = {
54
+ maxHeight: 300
55
+ },
56
+ status = statuses.DEFAULT,
59
57
  ...others
60
58
  } = otherProps;
61
59
  const hasCustomValue = mode === 'non-restrictive';
@@ -77,7 +75,7 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
77
75
  }
78
76
  }, [initialItems, mode]);
79
77
  const toggleItems = keys => {
80
- setItems(initialItems.filter(item => !Array.from(keys).includes(item.key)));
78
+ setItems((initialItems || []).filter(item => !Array.from(keys).includes(item.key)));
81
79
  if (onSelectionChange) onSelectionChange(keys);
82
80
  // Selecting an option removes it from the list, unmounting its row while
83
81
  // focusedKey still points at it — the virtualizer then holds DOM focus on
@@ -98,7 +96,7 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
98
96
  };
99
97
  const state = useListState({
100
98
  ...otherProps,
101
- items: items.filter(({
99
+ items: (items || []).filter(({
102
100
  key
103
101
  }) => !readOnlyKeys.includes(key)),
104
102
  onSelectionChange: toggleItems,
@@ -110,6 +108,10 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
110
108
  const {
111
109
  selectionManager
112
110
  } = state;
111
+
112
+ // `selectionManager.state` is private in the react-stately typings but is
113
+ // read throughout this component; the access is kept via a cast.
114
+ const selectionManagerState = selectionManager.state;
113
115
  const filteredItems = useMemo(() => Array.from(state.collection), [state.collection, filterString]);
114
116
  const close = () => setIsOpen(false);
115
117
  const {
@@ -119,13 +121,13 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
119
121
  inputValue: filterString
120
122
  });
121
123
  const closeBadgeRefs = useRef([]);
122
- const inputWrapperRef = useRef();
123
- const inputRef = useRef();
124
+ const inputWrapperRef = useRef(null);
125
+ const inputRef = useRef(null);
124
126
  /* istanbul ignore next */
125
127
  useImperativeHandle(ref, () => inputWrapperRef.current);
126
128
  useImperativeHandle(ref, () => inputRef.current);
127
- const listBoxRef = useRef();
128
- const popoverRef = useRef();
129
+ const listBoxRef = useRef(null);
130
+ const popoverRef = useRef(null);
129
131
 
130
132
  // Measure the width of the input to inform the width of the menu (below).
131
133
  const [menuWidth, setMenuWidth] = useState(null);
@@ -151,13 +153,13 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
151
153
  useEffect(() => {
152
154
  if (defaultSelectedKeys) {
153
155
  selectionManager.setSelectedKeys(defaultSelectedKeys);
154
- setItems(prevItems => prevItems.filter(item => !Array.from(defaultSelectedKeys).includes(item.key)));
156
+ setItems(prevItems => (prevItems || []).filter(item => !Array.from(defaultSelectedKeys).includes(item.key)));
155
157
  }
156
158
  }, []);
157
159
  useEffect(() => {
158
160
  if (selectedKeys) {
159
161
  selectionManager.setSelectedKeys(selectedKeys);
160
- setItems(prevItems => prevItems.filter(item => !Array.from(selectedKeys).includes(item.key)));
162
+ setItems(prevItems => (prevItems || []).filter(item => !Array.from(selectedKeys).includes(item.key)));
161
163
  }
162
164
  }, []);
163
165
  useEffect(() => {
@@ -172,7 +174,7 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
172
174
  if (state.selectionManager.isSelected(key)) {
173
175
  return;
174
176
  }
175
- selectionManager.setSelectedKeys([].concat(Array.from(selectionManager.state.selectedKeys), [key]));
177
+ selectionManager.setSelectedKeys([].concat(Array.from(selectionManagerState.selectedKeys), [key]));
176
178
  setCustomItems([].concat(customItems, [{
177
179
  id: key,
178
180
  key,
@@ -261,9 +263,9 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
261
263
  if (activeBadgesKeys.length > 1) {
262
264
  const badgeIndex = activeBadgesKeys.findIndex(item => item === key);
263
265
  const nextFocusBadgeIndex = badgeIndex === activeBadgesKeys.length - 1 ? badgeIndex - 1 : badgeIndex;
264
- closeBadgeRefs.current[nextFocusBadgeIndex].focus();
266
+ closeBadgeRefs.current[nextFocusBadgeIndex]?.focus();
265
267
  } else {
266
- inputRef.current.focus();
268
+ inputRef.current?.focus();
267
269
  }
268
270
  };
269
271
  const readOnlyFieldBadge = (key, name) => {
@@ -292,28 +294,28 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
292
294
  }, name);
293
295
  };
294
296
  const readOnlyInputEntry = isReadOnly && (readOnlyKeys.length ? readOnlyKeys.map(key => {
295
- const item = [].concat(initialItems, customItems).find(el => el.key === key);
297
+ const item = [].concat(initialItems || [], customItems).find(el => el.key === key);
296
298
  if (item) {
297
- return readOnlyTextItem(item.key, item.name);
299
+ return item.key !== undefined && readOnlyTextItem(item.key, item.name);
298
300
  }
299
301
  return null;
300
- }) : initialItems.map(item => {
301
- return readOnlyTextItem(item.key, item.name);
302
+ }) : (initialItems || []).map(item => {
303
+ return item.key !== undefined && readOnlyTextItem(item.key, item.name);
302
304
  }));
303
305
  const onyxReadOnlyInputEntry = isReadOnly && ___EmotionJSX(Box, {
304
306
  isRow: true,
305
307
  gap: "xs"
306
- }, initialItems.map(item => {
307
- return readOnlyFieldBadge(item.key, item.name);
308
+ }, (initialItems || []).map(item => {
309
+ return item.key !== undefined && readOnlyFieldBadge(item.key, item.name || '');
308
310
  }));
309
311
  const readOnlyItems = !isReadOnly && readOnlyKeys.map(key => {
310
- const item = initialItems.find(el => el.key === key);
312
+ const item = (initialItems || []).find(el => el.key === key);
311
313
  if (item) {
312
314
  return ___EmotionJSX(Badge, {
313
315
  key: item.key,
314
316
  label: item.name,
315
317
  variant: "readOnlyBadge",
316
- as: "li",
318
+ as: 'li',
317
319
  tabIndex: 0
318
320
  });
319
321
  }
@@ -327,7 +329,7 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
327
329
  closeBadgeRefs: closeBadgeRefs
328
330
  });
329
331
  const selectedItems = ___EmotionJSX(React.Fragment, null, Array.from(selectionManager.selectedKeys).map((key, i) => {
330
- const item = [].concat(initialItems, customItems).find(el => el.key === key);
332
+ const item = [].concat(initialItems || [], customItems).find(el => el.key === key);
331
333
  if (item) {
332
334
  return multivaluesFieldBadge(item, i);
333
335
  }
@@ -391,7 +393,7 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
391
393
  isDisabled,
392
394
  isReadOnly,
393
395
  isRequired,
394
- label,
396
+ label: label,
395
397
  placeholder,
396
398
  wrapperProps: {
397
399
  ref: inputWrapperRef,
@@ -448,7 +450,7 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
448
450
  }, selectedItems), isOnyx ? onyxReadOnlyInputEntry : readOnlyInputEntry, selectionManager.selectedKeys.size > 0 && visuallyHidden)
449
451
  },
450
452
  value: filterString,
451
- helperText: helperText,
453
+ helperText,
452
454
  "aria-invalid": status === 'error' && true
453
455
  }, getPendoID('MultivaluesField'), others, inputProps)), ___EmotionJSX(Popover, {
454
456
  hasNoArrow: true,
@@ -462,112 +464,4 @@ const DefaultMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
462
464
  sx: menuWidthSx
463
465
  }, listbox), ___EmotionJSX(EmptyVisuallyHidden, null)));
464
466
  });
465
- DefaultMultivaluesField.propTypes = {
466
- /** The initial selected keys in the collection (uncontrolled). */
467
- defaultSelectedKeys: isIterableProp,
468
- /** Where the menu opens relative to its trigger. */
469
- direction: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
470
- /**
471
- * The item keys that are disabled. These items cannot be selected.
472
- */
473
- disabledKeys: isIterableProp,
474
- /** Whether the element should receive focus on render. */
475
- hasAutoFocus: PropTypes.bool,
476
- /** Whether the field has a status indicator. */
477
- hasNoStatusIndicator: PropTypes.bool,
478
- /** Text rendered below the input. */
479
- helperText: PropTypes.node,
480
- /**
481
- * Props that get passed as-is to the underlying TextField element
482
- */
483
- inputProps: PropTypes.shape({}),
484
- /** Whether the input is disabled. */
485
- isDisabled: PropTypes.bool,
486
- /**
487
- * Whether the menu is prevented from flipping directions when insufficient space is
488
- * available for the given `direction` placement.
489
- */
490
- isNotFlippable: PropTypes.bool,
491
- /** Whether the input can be selected but not changed by the user. */
492
- isReadOnly: PropTypes.bool,
493
- /** Whether user input is required on the input before form submission. */
494
- isRequired: PropTypes.bool,
495
- /** The list of items.
496
- *
497
- * **Note:** Every item needs to have key and name properties.
498
- *
499
- * `Array<{key: string, name: string}>`
500
- */
501
- items: isIterableProp,
502
- /** The rendered label for the field. */
503
- label: PropTypes.string,
504
- /** Whether the component allows to create new values or only choose from the selection list */
505
- mode: PropTypes.oneOf(['restrictive', 'non-restrictive']),
506
- /**
507
- * Handler that is called when the element loses focus.
508
- *
509
- * `(e: FocusEvent) => void`
510
- */
511
- onBlur: PropTypes.func,
512
- /**
513
- * Handler that is called when the element receives focus.
514
- *
515
- * `(e: FocusEvent) => void`
516
- */
517
- onFocus: PropTypes.func,
518
- /**
519
- * Handler that is called when the input value changes.
520
- *
521
- * `(value: string) => void`
522
- */
523
- onInputChange: PropTypes.func,
524
- /**
525
- * Handler that is called when a key is pressed.
526
- *
527
- * `(e: KeyboardEvent) => void`
528
- */
529
- onKeyDown: PropTypes.func,
530
- /**
531
- * Handler that is called when a key is released.
532
- *
533
- * `(e: KeyboardEvent) => void`
534
- */
535
- onKeyUp: PropTypes.func,
536
- /**
537
- * Method that is called when the open state of the menu changes.
538
- *
539
- * `(isOpen: boolean) => void`
540
- */
541
- onOpenChange: PropTypes.func,
542
- /**
543
- * Handler that is called when the selection changes.
544
- *
545
- * `(keys: Iterable<Key>) => any`
546
- */
547
- onSelectionChange: PropTypes.func,
548
- /** Temporary text that occupies the text input when it is empty. */
549
- placeholder: PropTypes.string,
550
- /**
551
- * The item keys that are readonly. These items cannot be changed or selected.
552
- */
553
- readOnlyKeys: PropTypes.arrayOf(PropTypes.string),
554
- /** The currently selected keys in the collection (controlled). */
555
- selectedKeys: isIterableProp,
556
- // /** Props object that is spread directly into the ScrollBox element. */
557
- /** @ignore */
558
- scrollBoxProps: PropTypes.shape({
559
- maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.number])
560
- }),
561
- ...statusPropTypes,
562
- ...ariaAttributesBasePropTypes,
563
- ...inputFieldAttributesBasePropTypes
564
- };
565
- DefaultMultivaluesField.defaultProps = {
566
- direction: 'bottom',
567
- isReadOnly: false,
568
- scrollBoxProps: {
569
- maxHeight: 300
570
- },
571
- ...statusDefaultProp
572
- };
573
467
  export default DefaultMultivaluesField;
@@ -1,119 +1,20 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import React, { forwardRef } from 'react';
3
- import PropTypes from 'prop-types';
4
- import { isIterableProp } from '../../utils/devUtils/props/isIterable';
5
- import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
6
- import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
7
- import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusProp';
3
+ import { statusDefaultProp } from '../../utils/docUtils/statusProp';
8
4
  import CondensedMultivaluesField from './CondensedMultivaluesField';
9
5
  import DefaultMultivaluesField from './DefaultMultivaluesField';
10
6
  import { jsx as ___EmotionJSX } from "@emotion/react";
7
+ const displayName = 'MultivaluesField';
8
+
9
+ // No cast on the forwardRef result: a type assertion makes the react-docgen
10
+ // analyzer fail to extract the props table, which breaks the Storybook docs
11
+ // controls (argTypes lose their types and options).
11
12
  const MultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
12
13
  const Component = props.mode === 'condensed' ? CondensedMultivaluesField : DefaultMultivaluesField;
13
14
  return ___EmotionJSX(Component, _extends({
14
15
  ref: ref
15
16
  }, props));
16
17
  });
17
- MultivaluesField.propTypes = {
18
- /** The initial selected keys in the collection (uncontrolled). */
19
- defaultSelectedKeys: isIterableProp,
20
- /** Where the menu opens relative to its trigger. */
21
- direction: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
22
- /**
23
- * The item keys that are disabled. These items cannot be selected.
24
- */
25
- disabledKeys: isIterableProp,
26
- /** Whether the element should receive focus on render. */
27
- hasAutoFocus: PropTypes.bool,
28
- /** Whether the field has a status indicator. */
29
- hasNoStatusIndicator: PropTypes.bool,
30
- /** Text rendered below the input. */
31
- helperText: PropTypes.node,
32
- /**
33
- * Props that get passed as-is to the underlying TextField element
34
- */
35
- inputProps: PropTypes.shape({}),
36
- /** Whether the input is disabled. */
37
- isDisabled: PropTypes.bool,
38
- /**
39
- * Whether the menu is prevented from flipping directions when insufficient space is
40
- * available for the given `direction` placement.
41
- */
42
- isNotFlippable: PropTypes.bool,
43
- /** Whether the input can be selected but not changed by the user. */
44
- isReadOnly: PropTypes.bool,
45
- /** Whether user input is required on the input before form submission. */
46
- isRequired: PropTypes.bool,
47
- /** The list of items.
48
- *
49
- * **Note:** Every item needs to have key and name properties.
50
- *
51
- * `Array<{key: string, name: string}>`
52
- */
53
- items: isIterableProp,
54
- /** The rendered label for the field. */
55
- label: PropTypes.string,
56
- /** Whether the component allows to create new values or only choose from the selection list */
57
- mode: PropTypes.oneOf(['restrictive', 'non-restrictive', 'condensed']),
58
- /**
59
- * Handler that is called when the element loses focus.
60
- *
61
- * `(e: FocusEvent) => void`
62
- */
63
- onBlur: PropTypes.func,
64
- /**
65
- * Handler that is called when the element receives focus.
66
- *
67
- * `(e: FocusEvent) => void`
68
- */
69
- onFocus: PropTypes.func,
70
- /**
71
- * Handler that is called when the input value changes.
72
- *
73
- * `(value: string) => void`
74
- */
75
- onInputChange: PropTypes.func,
76
- /**
77
- * Handler that is called when a key is pressed.
78
- *
79
- * `(e: KeyboardEvent) => void`
80
- */
81
- onKeyDown: PropTypes.func,
82
- /**
83
- * Handler that is called when a key is released.
84
- *
85
- * `(e: KeyboardEvent) => void`
86
- */
87
- onKeyUp: PropTypes.func,
88
- /**
89
- * Method that is called when the open state of the menu changes.
90
- *
91
- * `(isOpen: boolean) => void`
92
- */
93
- onOpenChange: PropTypes.func,
94
- /**
95
- * Handler that is called when the selection changes.
96
- *
97
- * `(keys: Iterable<Key>) => any`
98
- */
99
- onSelectionChange: PropTypes.func,
100
- /** Temporary text that occupies the text input when it is empty. */
101
- placeholder: PropTypes.string,
102
- /**
103
- * The item keys that are readonly. These items cannot be changed or selected.
104
- */
105
- readOnlyKeys: PropTypes.arrayOf(PropTypes.string),
106
- /** The currently selected keys in the collection (controlled). */
107
- selectedKeys: isIterableProp,
108
- // /** Props object that is spread directly into the ScrollBox element. */
109
- /** @ignore */
110
- scrollBoxProps: PropTypes.shape({
111
- maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.number])
112
- }),
113
- ...statusPropTypes,
114
- ...ariaAttributesBasePropTypes,
115
- ...inputFieldAttributesBasePropTypes
116
- };
117
18
  MultivaluesField.defaultProps = {
118
19
  direction: 'bottom',
119
20
  isReadOnly: false,
@@ -122,4 +23,5 @@ MultivaluesField.defaultProps = {
122
23
  },
123
24
  ...statusDefaultProp
124
25
  };
26
+ MultivaluesField.displayName = displayName;
125
27
  export default MultivaluesField;