@carbon/react 1.32.0 → 1.33.0-rc.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 (74) hide show
  1. package/README.md +22 -7
  2. package/es/components/ComboBox/ComboBox.js +43 -10
  3. package/es/components/ContentSwitcher/ContentSwitcher.js +5 -5
  4. package/es/components/DataTable/DataTable.js +110 -130
  5. package/es/components/DataTable/Table.js +1 -1
  6. package/es/components/DatePicker/DatePicker.d.ts +14 -13
  7. package/es/components/DatePicker/DatePicker.js +3 -0
  8. package/es/components/DatePickerInput/DatePickerInput.d.ts +2 -2
  9. package/es/components/Dropdown/Dropdown.js +31 -6
  10. package/es/components/FileUploader/FileUploader.Skeleton.d.ts +29 -0
  11. package/es/components/FileUploader/FileUploader.d.ts +175 -0
  12. package/es/components/FileUploader/FileUploader.js +3 -3
  13. package/es/components/FileUploader/FileUploaderButton.d.ts +140 -0
  14. package/es/components/FileUploader/FileUploaderButton.js +11 -7
  15. package/es/components/FileUploader/FileUploaderDropContainer.d.ts +139 -0
  16. package/es/components/FileUploader/FileUploaderDropContainer.js +3 -3
  17. package/es/components/FileUploader/FileUploaderItem.d.ts +110 -0
  18. package/es/components/FileUploader/Filename.d.ts +71 -0
  19. package/es/components/FileUploader/Filename.js +6 -4
  20. package/es/components/InlineCheckbox/InlineCheckbox.js +3 -1
  21. package/es/components/Loading/Loading.d.ts +65 -0
  22. package/es/components/Notification/Notification.d.ts +4 -4
  23. package/es/components/Notification/Notification.js +3 -3
  24. package/es/components/OverflowMenu/OverflowMenu.js +36 -41
  25. package/es/components/Slider/Slider.js +59 -68
  26. package/es/components/Toggle/Toggle.d.ts +129 -0
  27. package/es/components/Toggle/Toggle.js +2 -2
  28. package/es/components/Toggle/index.d.ts +11 -0
  29. package/es/components/UIShell/HeaderMenu.js +29 -36
  30. package/es/components/UIShell/HeaderName.d.ts +39 -0
  31. package/es/components/UIShell/HeaderName.js +2 -7
  32. package/es/components/UIShell/HeaderPanel.js +1 -1
  33. package/es/components/UIShell/Link.js +2 -1
  34. package/es/index.js +1 -1
  35. package/es/internal/FloatingMenu.js +47 -51
  36. package/es/internal/useControllableState.js +1 -1
  37. package/es/internal/useId.js +10 -1
  38. package/lib/components/ComboBox/ComboBox.js +43 -10
  39. package/lib/components/ContentSwitcher/ContentSwitcher.js +5 -5
  40. package/lib/components/DataTable/DataTable.js +110 -130
  41. package/lib/components/DataTable/Table.js +1 -1
  42. package/lib/components/DatePicker/DatePicker.d.ts +14 -13
  43. package/lib/components/DatePicker/DatePicker.js +3 -0
  44. package/lib/components/DatePickerInput/DatePickerInput.d.ts +2 -2
  45. package/lib/components/Dropdown/Dropdown.js +30 -5
  46. package/lib/components/FileUploader/FileUploader.Skeleton.d.ts +29 -0
  47. package/lib/components/FileUploader/FileUploader.d.ts +175 -0
  48. package/lib/components/FileUploader/FileUploader.js +3 -3
  49. package/lib/components/FileUploader/FileUploaderButton.d.ts +140 -0
  50. package/lib/components/FileUploader/FileUploaderButton.js +11 -7
  51. package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +139 -0
  52. package/lib/components/FileUploader/FileUploaderDropContainer.js +3 -3
  53. package/lib/components/FileUploader/FileUploaderItem.d.ts +110 -0
  54. package/lib/components/FileUploader/Filename.d.ts +71 -0
  55. package/lib/components/FileUploader/Filename.js +6 -4
  56. package/lib/components/InlineCheckbox/InlineCheckbox.js +3 -1
  57. package/lib/components/Loading/Loading.d.ts +65 -0
  58. package/lib/components/Notification/Notification.d.ts +4 -4
  59. package/lib/components/Notification/Notification.js +3 -3
  60. package/lib/components/OverflowMenu/OverflowMenu.js +36 -41
  61. package/lib/components/Slider/Slider.js +59 -68
  62. package/lib/components/Toggle/Toggle.d.ts +129 -0
  63. package/lib/components/Toggle/Toggle.js +2 -2
  64. package/lib/components/Toggle/index.d.ts +11 -0
  65. package/lib/components/UIShell/HeaderMenu.js +29 -36
  66. package/lib/components/UIShell/HeaderName.d.ts +39 -0
  67. package/lib/components/UIShell/HeaderName.js +2 -7
  68. package/lib/components/UIShell/HeaderPanel.js +1 -1
  69. package/lib/components/UIShell/Link.js +2 -1
  70. package/lib/index.js +2 -2
  71. package/lib/internal/FloatingMenu.js +47 -51
  72. package/lib/internal/useControllableState.js +1 -1
  73. package/lib/internal/useId.js +9 -0
  74. package/package.json +22 -19
@@ -30,6 +30,11 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
30
30
  class ContentSwitcher extends React__default["default"].Component {
31
31
  constructor() {
32
32
  super(...arguments);
33
+ /**
34
+ * The DOM references of child `<Switch>`.
35
+ * @type {Array<Element>}
36
+ * @private
37
+ */
33
38
  _rollupPluginBabelHelpers.defineProperty(this, "_switchRefs", []);
34
39
  _rollupPluginBabelHelpers.defineProperty(this, "state", {
35
40
  selectedIndex: undefined
@@ -87,11 +92,6 @@ class ContentSwitcher extends React__default["default"].Component {
87
92
  }
88
93
  });
89
94
  }
90
- /**
91
- * The DOM references of child `<Switch>`.
92
- * @type {Array<Element>}
93
- * @private
94
- */
95
95
  static getDerivedStateFromProps(_ref, state) {
96
96
  let {
97
97
  selectedIndex
@@ -86,6 +86,16 @@ class DataTable extends React__default["default"].Component {
86
86
  var _this;
87
87
  super(_props);
88
88
  _this = this;
89
+ /**
90
+ * Get the props associated with the given header. Mostly used for adding in
91
+ * sorting behavior.
92
+ *
93
+ * @param {object} config
94
+ * @param {string} config.header the header we want the props for
95
+ * @param {Function} config.onClick a custom click handler for the header
96
+ * @param {boolean} config.isSortable
97
+ * @returns {object}
98
+ */
89
99
  _rollupPluginBabelHelpers.defineProperty(this, "getHeaderProps", _ref => {
90
100
  let {
91
101
  header,
@@ -116,6 +126,14 @@ class DataTable extends React__default["default"].Component {
116
126
  }
117
127
  };
118
128
  });
129
+ /**
130
+ * Get the props associated with the given expand header.
131
+ *
132
+ * @param {object} config
133
+ * @param {Function} config.onClick a custom click handler for the expand header
134
+ * @param {Function} config.onExpand a custom click handler called when header is expanded
135
+ * @returns {object}
136
+ */
119
137
  _rollupPluginBabelHelpers.defineProperty(this, "getExpandHeaderProps", function () {
120
138
  let {
121
139
  onClick,
@@ -143,12 +161,34 @@ class DataTable extends React__default["default"].Component {
143
161
  }) : null])
144
162
  };
145
163
  });
164
+ /**
165
+ * Decorate consumer's `onClick` event handler with sort parameters
166
+ *
167
+ * @param {Function} onClick
168
+ * @param {object} sortParams
169
+ * @returns {Function}
170
+ */
146
171
  _rollupPluginBabelHelpers.defineProperty(this, "handleOnHeaderClick", (onClick, sortParams) => {
147
172
  return e => onClick(e, sortParams);
148
173
  });
174
+ /**
175
+ * Decorate consumer's `onClick` event handler with sort parameters
176
+ *
177
+ * @param {Function} onClick
178
+ * @param {object} expandParams
179
+ * @returns {Function}
180
+ */
149
181
  _rollupPluginBabelHelpers.defineProperty(this, "handleOnExpandHeaderClick", (onClick, expandParams) => {
150
182
  return e => onClick(e, expandParams);
151
183
  });
184
+ /**
185
+ * Get the props associated with the given row. Mostly used for expansion.
186
+ *
187
+ * @param {object} config
188
+ * @param {object} config.row the row we want the props for
189
+ * @param {Function} config.onClick a custom click handler for the header
190
+ * @returns {object}
191
+ */
152
192
  _rollupPluginBabelHelpers.defineProperty(this, "getRowProps", _ref2 => {
153
193
  let {
154
194
  row,
@@ -171,6 +211,16 @@ class DataTable extends React__default["default"].Component {
171
211
  disabled: row.disabled
172
212
  };
173
213
  });
214
+ /**
215
+ * Gets the props associated with selection for a header or a row, where
216
+ * applicable. Most often used to indicate selection status of the table or
217
+ * for a specific row.
218
+ *
219
+ * @param {object} [row] an optional row that we want to access the props for
220
+ * @param {Function} row.onClick
221
+ * @param {object} row.row
222
+ * @returns {object}
223
+ */
174
224
  _rollupPluginBabelHelpers.defineProperty(this, "getSelectionProps", function () {
175
225
  let {
176
226
  onClick,
@@ -237,6 +287,9 @@ class DataTable extends React__default["default"].Component {
237
287
  onCancel: _this.handleOnCancel
238
288
  };
239
289
  });
290
+ /**
291
+ * Helper utility to get the Table Props.
292
+ */
240
293
  _rollupPluginBabelHelpers.defineProperty(this, "getTableProps", () => {
241
294
  const {
242
295
  useZebraStyles,
@@ -257,6 +310,9 @@ class DataTable extends React__default["default"].Component {
257
310
  experimentalAutoAlign
258
311
  };
259
312
  });
313
+ /**
314
+ * Helper utility to get the TableContainer Props.
315
+ */
260
316
  _rollupPluginBabelHelpers.defineProperty(this, "getTableContainerProps", () => {
261
317
  const {
262
318
  stickyHeader,
@@ -267,10 +323,18 @@ class DataTable extends React__default["default"].Component {
267
323
  useStaticWidth
268
324
  };
269
325
  });
326
+ /**
327
+ * Helper utility to get all the currently selected rows
328
+ * @returns {Array<string>} the array of rowIds that are currently selected
329
+ */
270
330
  _rollupPluginBabelHelpers.defineProperty(this, "getSelectedRows", () => this.state.rowIds.filter(id => {
271
331
  const row = this.state.rowsById[id];
272
332
  return row.isSelected && !row.disabled;
273
333
  }));
334
+ /**
335
+ * Helper utility to get all of the available rows after applying the filter
336
+ * @returns {Array<string>} the array of rowIds that are currently included through the filter
337
+ * */
274
338
  _rollupPluginBabelHelpers.defineProperty(this, "getFilteredRowIds", () => {
275
339
  const filteredRowIds = typeof this.state.filterInputValue === 'string' ? this.props.filterRows({
276
340
  rowIds: this.state.rowIds,
@@ -284,7 +348,19 @@ class DataTable extends React__default["default"].Component {
284
348
  }
285
349
  return filteredRowIds;
286
350
  });
351
+ /**
352
+ * Helper for getting the table prefix for elements that require an
353
+ * `id` attribute that is unique.
354
+ *
355
+ * @returns {string}
356
+ */
287
357
  _rollupPluginBabelHelpers.defineProperty(this, "getTablePrefix", () => `data-table-${this.instanceId}`);
358
+ /**
359
+ * Helper for toggling all selected items in a state. Does not call
360
+ * setState, so use it when setting state.
361
+ * @param {object} initialState
362
+ * @returns {object} object to put into this.setState (use spread operator)
363
+ */
288
364
  _rollupPluginBabelHelpers.defineProperty(this, "setAllSelectedState", (initialState, isSelected, filteredRowIds) => {
289
365
  const {
290
366
  rowIds
@@ -303,6 +379,10 @@ class DataTable extends React__default["default"].Component {
303
379
  }, {})
304
380
  };
305
381
  });
382
+ /**
383
+ * Handler for the `onCancel` event to hide the batch action bar and
384
+ * deselect all selected rows
385
+ */
306
386
  _rollupPluginBabelHelpers.defineProperty(this, "handleOnCancel", () => {
307
387
  this.setState(state => {
308
388
  return {
@@ -311,6 +391,9 @@ class DataTable extends React__default["default"].Component {
311
391
  };
312
392
  });
313
393
  });
394
+ /**
395
+ * Handler for toggling the selection state of all rows in the database
396
+ */
314
397
  _rollupPluginBabelHelpers.defineProperty(this, "handleSelectAll", () => {
315
398
  this.setState(state => {
316
399
  const filteredRowIds = this.getFilteredRowIds();
@@ -324,6 +407,12 @@ class DataTable extends React__default["default"].Component {
324
407
  };
325
408
  });
326
409
  });
410
+ /**
411
+ * Handler for toggling the selection state of a given row.
412
+ *
413
+ * @param {string} rowId
414
+ * @returns {Function}
415
+ */
327
416
  _rollupPluginBabelHelpers.defineProperty(this, "handleOnSelectRow", rowId => () => {
328
417
  this.setState(state => {
329
418
  const row = state.rowsById[rowId];
@@ -365,6 +454,12 @@ class DataTable extends React__default["default"].Component {
365
454
  };
366
455
  });
367
456
  });
457
+ /**
458
+ * Handler for toggling the expansion state of a given row.
459
+ *
460
+ * @param {string} rowId
461
+ * @returns {Function}
462
+ */
368
463
  _rollupPluginBabelHelpers.defineProperty(this, "handleOnExpandRow", rowId => () => {
369
464
  this.setState(state => {
370
465
  const row = state.rowsById[rowId];
@@ -383,6 +478,9 @@ class DataTable extends React__default["default"].Component {
383
478
  };
384
479
  });
385
480
  });
481
+ /**
482
+ * Handler for changing the expansion state of all rows.
483
+ */
386
484
  _rollupPluginBabelHelpers.defineProperty(this, "handleOnExpandAll", () => {
387
485
  this.setState(state => {
388
486
  const {
@@ -401,11 +499,23 @@ class DataTable extends React__default["default"].Component {
401
499
  };
402
500
  });
403
501
  });
502
+ /**
503
+ * Handler for transitioning to the next sort state of the table
504
+ *
505
+ * @param {string} headerKey the field for the header that we are sorting by
506
+ * @returns {Function}
507
+ */
404
508
  _rollupPluginBabelHelpers.defineProperty(this, "handleSortBy", headerKey => () => {
405
509
  this.setState(state => sorting.getNextSortState(this.props, state, {
406
510
  key: headerKey
407
511
  }));
408
512
  });
513
+ /**
514
+ * Event handler for transitioning input value state changes for the table
515
+ * filter component.
516
+ *
517
+ * @param {Event} event
518
+ */
409
519
  _rollupPluginBabelHelpers.defineProperty(this, "handleOnInputValueChange", (event, defaultValue) => {
410
520
  if (event.target) {
411
521
  this.setState({
@@ -448,136 +558,6 @@ class DataTable extends React__default["default"].Component {
448
558
  }
449
559
  return true;
450
560
  }
451
-
452
- /**
453
- * Get the props associated with the given header. Mostly used for adding in
454
- * sorting behavior.
455
- *
456
- * @param {object} config
457
- * @param {string} config.header the header we want the props for
458
- * @param {Function} config.onClick a custom click handler for the header
459
- * @param {boolean} config.isSortable
460
- * @returns {object}
461
- */
462
-
463
- /**
464
- * Get the props associated with the given expand header.
465
- *
466
- * @param {object} config
467
- * @param {Function} config.onClick a custom click handler for the expand header
468
- * @param {Function} config.onExpand a custom click handler called when header is expanded
469
- * @returns {object}
470
- */
471
-
472
- /**
473
- * Decorate consumer's `onClick` event handler with sort parameters
474
- *
475
- * @param {Function} onClick
476
- * @param {object} sortParams
477
- * @returns {Function}
478
- */
479
-
480
- /**
481
- * Decorate consumer's `onClick` event handler with sort parameters
482
- *
483
- * @param {Function} onClick
484
- * @param {object} expandParams
485
- * @returns {Function}
486
- */
487
-
488
- /**
489
- * Get the props associated with the given row. Mostly used for expansion.
490
- *
491
- * @param {object} config
492
- * @param {object} config.row the row we want the props for
493
- * @param {Function} config.onClick a custom click handler for the header
494
- * @returns {object}
495
- */
496
-
497
- /**
498
- * Gets the props associated with selection for a header or a row, where
499
- * applicable. Most often used to indicate selection status of the table or
500
- * for a specific row.
501
- *
502
- * @param {object} [row] an optional row that we want to access the props for
503
- * @param {Function} row.onClick
504
- * @param {object} row.row
505
- * @returns {object}
506
- */
507
-
508
- /**
509
- * Helper utility to get the Table Props.
510
- */
511
-
512
- /**
513
- * Helper utility to get the TableContainer Props.
514
- */
515
-
516
- /**
517
- * Helper utility to get all the currently selected rows
518
- * @returns {Array<string>} the array of rowIds that are currently selected
519
- */
520
-
521
- /**
522
- * Helper utility to get all of the available rows after applying the filter
523
- * @returns {Array<string>} the array of rowIds that are currently included through the filter
524
- * */
525
-
526
- /**
527
- * Helper for getting the table prefix for elements that require an
528
- * `id` attribute that is unique.
529
- *
530
- * @returns {string}
531
- */
532
-
533
- /**
534
- * Helper for toggling all selected items in a state. Does not call
535
- * setState, so use it when setting state.
536
- * @param {object} initialState
537
- * @returns {object} object to put into this.setState (use spread operator)
538
- */
539
-
540
- /**
541
- * Handler for the `onCancel` event to hide the batch action bar and
542
- * deselect all selected rows
543
- */
544
-
545
- /**
546
- * Handler for toggling the selection state of all rows in the database
547
- */
548
-
549
- /**
550
- * Handler for toggling the selection state of a given row.
551
- *
552
- * @param {string} rowId
553
- * @returns {Function}
554
- */
555
-
556
- /**
557
- * Handler for toggling the expansion state of a given row.
558
- *
559
- * @param {string} rowId
560
- * @returns {Function}
561
- */
562
-
563
- /**
564
- * Handler for changing the expansion state of all rows.
565
- */
566
-
567
- /**
568
- * Handler for transitioning to the next sort state of the table
569
- *
570
- * @param {string} headerKey the field for the header that we are sorting by
571
- * @returns {Function}
572
- */
573
-
574
- /**
575
- * Event handler for transitioning input value state changes for the table
576
- * filter component.
577
- *
578
- * @param {Event} event
579
- */
580
-
581
561
  render() {
582
562
  // eslint-disable-next-line react/prop-types
583
563
  const {
@@ -110,7 +110,7 @@ const Table = _ref => {
110
110
  useEvent.useWindowEvent('resize', debouncedSetTableAlignment);
111
111
 
112
112
  // recalculate table alignment once fonts have loaded
113
- if (document?.fonts?.status && document.fonts.status !== 'loaded') {
113
+ if (typeof document !== 'undefined' && document?.fonts?.status && document.fonts.status !== 'loaded') {
114
114
  document.fonts.ready.then(() => {
115
115
  setTableAlignment();
116
116
  });
@@ -5,7 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { ReactNodeLike } from 'prop-types';
8
- import React, { ChangeEventHandler } from 'react';
8
+ import React from 'react';
9
+ import flatpickr from 'flatpickr';
9
10
  import { ReactAttr } from '../../types/common';
10
11
  type ExcludedAttributes = 'value' | 'onChange' | 'locale';
11
12
  export type DatePickerTypes = 'simple' | 'single' | 'range';
@@ -26,11 +27,11 @@ interface DatePickerProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttrib
26
27
  * flatpickr prop passthrough. Allows the user to enter a date directly
27
28
  * into the input field
28
29
  */
29
- allowInput: boolean | undefined;
30
+ allowInput?: boolean;
30
31
  /**
31
32
  * The DOM element the flatpickr should be inserted into `<body>` by default.
32
33
  */
33
- appendTo: object | undefined;
34
+ appendTo?: object;
34
35
  /**
35
36
  * The child nodes.
36
37
  */
@@ -38,11 +39,11 @@ interface DatePickerProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttrib
38
39
  /**
39
40
  * The CSS class names.
40
41
  */
41
- className: string | undefined;
42
+ className?: string;
42
43
  /**
43
44
  * flatpickr prop passthrough. Controls whether the calendar dropdown closes upon selection.
44
45
  */
45
- closeOnSelect: boolean | undefined;
46
+ closeOnSelect?: boolean;
46
47
  /**
47
48
  * The date format.
48
49
  */
@@ -66,19 +67,19 @@ interface DatePickerProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttrib
66
67
  /**
67
68
  * The flatpickr `inline` option.
68
69
  */
69
- inline: boolean | undefined;
70
+ inline?: boolean;
70
71
  /**
71
72
  * Specify whether or not the control is invalid (Fluid only)
72
73
  */
73
- invalid: boolean | undefined;
74
+ invalid?: boolean;
74
75
  /**
75
76
  * Provide the text that is displayed when the control is in error state (Fluid Only)
76
77
  */
77
- invalidText: ReactNodeLike;
78
+ invalidText?: ReactNodeLike;
78
79
  /**
79
80
  * `true` to use the light version.
80
81
  */
81
- light: boolean;
82
+ light?: boolean;
82
83
  /**
83
84
  * The language locale used to format the days of the week, months, and numbers. The full list of supported locales can be found here https://github.com/flatpickr/flatpickr/tree/master/src/l10n
84
85
  */
@@ -94,15 +95,15 @@ interface DatePickerProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttrib
94
95
  /**
95
96
  * The `change` event handler.
96
97
  */
97
- onChange?: ChangeEventHandler<HTMLSelectElement>;
98
+ onChange?: flatpickr.Options.Hook;
98
99
  /**
99
100
  * The `close` event handler.
100
101
  */
101
- onClose?: any;
102
+ onClose?: flatpickr.Options.Hook;
102
103
  /**
103
104
  * The `open` event handler.
104
105
  */
105
- onOpen?: ChangeEventHandler<HTMLSelectElement>;
106
+ onOpen?: flatpickr.Options.Hook;
106
107
  /**
107
108
  * whether the DatePicker is to be readOnly
108
109
  * if boolean applies to all inputs
@@ -125,7 +126,7 @@ interface DatePickerProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttrib
125
126
  /**
126
127
  * Provide the text that is displayed when the control is in warning state (Fluid only)
127
128
  */
128
- warnText: ReactNodeLike;
129
+ warnText?: ReactNodeLike;
129
130
  }
130
131
  declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<HTMLDivElement>>;
131
132
  export default DatePicker;
@@ -688,14 +688,17 @@ DatePicker.propTypes = {
688
688
  minDate: PropTypes__default["default"].string,
689
689
  /**
690
690
  * The `change` event handler.
691
+ * `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
691
692
  */
692
693
  onChange: PropTypes__default["default"].func,
693
694
  /**
694
695
  * The `close` event handler.
696
+ * `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
695
697
  */
696
698
  onClose: PropTypes__default["default"].func,
697
699
  /**
698
700
  * The `open` event handler.
701
+ * `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
699
702
  */
700
703
  onOpen: PropTypes__default["default"].func,
701
704
  /**
@@ -42,7 +42,7 @@ interface DatePickerInputProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedA
42
42
  /**
43
43
  * Specify the text to be rendered when the input is invalid
44
44
  */
45
- invalidText: ReactNodeLike;
45
+ invalidText?: ReactNodeLike;
46
46
  /**
47
47
  * Provide the text that will be read by a screen reader when visiting this
48
48
  * control
@@ -61,7 +61,7 @@ interface DatePickerInputProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedA
61
61
  * Provide a regular expression that the input value must match
62
62
  * TODO:need to be rewritten
63
63
  */
64
- pattern: (props: {
64
+ pattern?: (props: {
65
65
  [key: string]: any;
66
66
  }, propName: string, componentName: string) => null | any | Error;
67
67
  /**
@@ -31,6 +31,13 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
31
31
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
32
32
 
33
33
  const getInstanceId = setupGetInstanceId["default"]();
34
+ const {
35
+ MenuBlur,
36
+ MenuKeyDownArrowDown,
37
+ MenuKeyDownArrowUp,
38
+ MenuKeyDownEscape,
39
+ ToggleButtonClick
40
+ } = Downshift.useSelect.stateChangeTypes;
34
41
  const defaultItemToString = item => {
35
42
  if (typeof item === 'string') {
36
43
  return item;
@@ -75,6 +82,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
75
82
  ...other
76
83
  } = _ref;
77
84
  const prefix = usePrefix.usePrefix();
85
+ const [highlightedIndex, setHighlightedIndex] = React.useState();
78
86
  const {
79
87
  isFluid
80
88
  } = React.useContext(FormContext.FormContext);
@@ -82,12 +90,32 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
82
90
  ...downshiftProps,
83
91
  items,
84
92
  itemToString,
93
+ highlightedIndex,
85
94
  initialSelectedItem,
86
- onSelectedItemChange
95
+ onSelectedItemChange,
96
+ onStateChange
87
97
  };
88
98
  const {
89
99
  current: dropdownInstanceId
90
100
  } = React.useRef(getInstanceId());
101
+ function onStateChange(changes) {
102
+ const {
103
+ type
104
+ } = changes;
105
+ switch (type) {
106
+ case MenuKeyDownArrowDown:
107
+ case MenuKeyDownArrowUp:
108
+ setHighlightedIndex(changes.highlightedIndex);
109
+ break;
110
+ case MenuBlur:
111
+ case MenuKeyDownEscape:
112
+ setHighlightedIndex(changes.highlightedIndex);
113
+ break;
114
+ case ToggleButtonClick:
115
+ setHighlightedIndex(changes.highlightedIndex);
116
+ break;
117
+ }
118
+ }
91
119
 
92
120
  // only set selectedItem if the prop is defined. Setting if it is undefined
93
121
  // will overwrite default selected items from useSelect
@@ -100,7 +128,6 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
100
128
  getLabelProps,
101
129
  getMenuProps,
102
130
  getItemProps,
103
- highlightedIndex,
104
131
  selectedItem
105
132
  } = Downshift.useSelect(selectProps);
106
133
  const inline = type === 'inline';
@@ -179,12 +206,10 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
179
206
  }
180
207
  } : {
181
208
  onKeyDown: evt => {
182
- console.log('typing should be false', isTyping);
183
209
  if (evt.code !== 'Space' || !['ArrowDown', 'ArrowUp', ' ', 'Enter'].includes(evt.key)) {
184
210
  setIsTyping(true);
185
211
  }
186
212
  if (isTyping && evt.code === 'Space' || !['ArrowDown', 'ArrowUp', ' ', 'Enter'].includes(evt.key)) {
187
- console.log(evt.key);
188
213
  if (evt.code === 'Space') {
189
214
  evt.preventDefault();
190
215
  return;
@@ -254,7 +279,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
254
279
  return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
255
280
  key: itemProps.id,
256
281
  isActive: selectedItem === item,
257
- isHighlighted: highlightedIndex === index$1 || selectedItem === item,
282
+ isHighlighted: highlightedIndex === index$1,
258
283
  title: title,
259
284
  ref: {
260
285
  menuItemOptionRef: menuItemOptionRefs.current[index$1]
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /// <reference types="react" />
8
+ import PropTypes from 'prop-types';
9
+ import { ReactAttr } from '../../types/common';
10
+ export interface FileUploaderSkeletonProps extends ReactAttr<HTMLDivElement> {
11
+ /**
12
+ * Specify an optional className to add.
13
+ */
14
+ className?: string;
15
+ }
16
+ declare function FileUploaderSkeleton({ className, ...rest }: {
17
+ [x: string]: any;
18
+ className: any;
19
+ }): JSX.Element;
20
+ declare namespace FileUploaderSkeleton {
21
+ var propTypes: {
22
+ /**
23
+ * Specify an optional className to add.
24
+ */
25
+ className: PropTypes.Requireable<string>;
26
+ };
27
+ }
28
+ export default FileUploaderSkeleton;
29
+ export { FileUploaderSkeleton };