@carbon/react 1.32.0 → 1.33.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 (86) 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/DataTableSkeleton/DataTableSkeleton.d.ts +17 -16
  7. package/es/components/DatePicker/DatePicker.d.ts +14 -13
  8. package/es/components/DatePicker/DatePicker.js +3 -0
  9. package/es/components/DatePickerInput/DatePickerInput.d.ts +2 -2
  10. package/es/components/Dropdown/Dropdown.js +31 -6
  11. package/es/components/FileUploader/FileUploader.Skeleton.d.ts +29 -0
  12. package/es/components/FileUploader/FileUploader.d.ts +175 -0
  13. package/es/components/FileUploader/FileUploader.js +3 -3
  14. package/es/components/FileUploader/FileUploaderButton.d.ts +140 -0
  15. package/es/components/FileUploader/FileUploaderButton.js +11 -7
  16. package/es/components/FileUploader/FileUploaderDropContainer.d.ts +139 -0
  17. package/es/components/FileUploader/FileUploaderDropContainer.js +3 -3
  18. package/es/components/FileUploader/FileUploaderItem.d.ts +110 -0
  19. package/es/components/FileUploader/Filename.d.ts +71 -0
  20. package/es/components/FileUploader/Filename.js +6 -4
  21. package/es/components/InlineCheckbox/InlineCheckbox.js +3 -1
  22. package/es/components/Loading/Loading.d.ts +65 -0
  23. package/es/components/Notification/Notification.d.ts +4 -4
  24. package/es/components/Notification/Notification.js +3 -3
  25. package/es/components/OverflowMenu/OverflowMenu.js +36 -41
  26. package/es/components/Slider/Slider.js +59 -68
  27. package/es/components/Tag/Tag.js +9 -2
  28. package/es/components/TextArea/TextArea.js +1 -1
  29. package/es/components/Toggle/Toggle.d.ts +129 -0
  30. package/es/components/Toggle/Toggle.js +2 -2
  31. package/es/components/Toggle/index.d.ts +11 -0
  32. package/es/components/UIShell/HeaderMenu.js +29 -36
  33. package/es/components/UIShell/HeaderMenuButton.d.ts +4 -0
  34. package/es/components/UIShell/HeaderMenuButton.js +4 -0
  35. package/es/components/UIShell/HeaderName.d.ts +39 -0
  36. package/es/components/UIShell/HeaderName.js +2 -7
  37. package/es/components/UIShell/HeaderPanel.js +2 -2
  38. package/es/components/UIShell/Link.js +2 -1
  39. package/es/components/UIShell/Switcher.js +17 -6
  40. package/es/index.js +1 -1
  41. package/es/internal/FloatingMenu.js +47 -51
  42. package/es/internal/useControllableState.js +1 -1
  43. package/es/internal/useId.js +10 -1
  44. package/lib/components/ComboBox/ComboBox.js +43 -10
  45. package/lib/components/ContentSwitcher/ContentSwitcher.js +5 -5
  46. package/lib/components/DataTable/DataTable.js +110 -130
  47. package/lib/components/DataTable/Table.js +1 -1
  48. package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +17 -16
  49. package/lib/components/DatePicker/DatePicker.d.ts +14 -13
  50. package/lib/components/DatePicker/DatePicker.js +3 -0
  51. package/lib/components/DatePickerInput/DatePickerInput.d.ts +2 -2
  52. package/lib/components/Dropdown/Dropdown.js +30 -5
  53. package/lib/components/FileUploader/FileUploader.Skeleton.d.ts +29 -0
  54. package/lib/components/FileUploader/FileUploader.d.ts +175 -0
  55. package/lib/components/FileUploader/FileUploader.js +3 -3
  56. package/lib/components/FileUploader/FileUploaderButton.d.ts +140 -0
  57. package/lib/components/FileUploader/FileUploaderButton.js +11 -7
  58. package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +139 -0
  59. package/lib/components/FileUploader/FileUploaderDropContainer.js +3 -3
  60. package/lib/components/FileUploader/FileUploaderItem.d.ts +110 -0
  61. package/lib/components/FileUploader/Filename.d.ts +71 -0
  62. package/lib/components/FileUploader/Filename.js +6 -4
  63. package/lib/components/InlineCheckbox/InlineCheckbox.js +3 -1
  64. package/lib/components/Loading/Loading.d.ts +65 -0
  65. package/lib/components/Notification/Notification.d.ts +4 -4
  66. package/lib/components/Notification/Notification.js +3 -3
  67. package/lib/components/OverflowMenu/OverflowMenu.js +36 -41
  68. package/lib/components/Slider/Slider.js +59 -68
  69. package/lib/components/Tag/Tag.js +9 -2
  70. package/lib/components/TextArea/TextArea.js +1 -1
  71. package/lib/components/Toggle/Toggle.d.ts +129 -0
  72. package/lib/components/Toggle/Toggle.js +2 -2
  73. package/lib/components/Toggle/index.d.ts +11 -0
  74. package/lib/components/UIShell/HeaderMenu.js +29 -36
  75. package/lib/components/UIShell/HeaderMenuButton.d.ts +4 -0
  76. package/lib/components/UIShell/HeaderMenuButton.js +4 -0
  77. package/lib/components/UIShell/HeaderName.d.ts +39 -0
  78. package/lib/components/UIShell/HeaderName.js +2 -7
  79. package/lib/components/UIShell/HeaderPanel.js +2 -2
  80. package/lib/components/UIShell/Link.js +2 -1
  81. package/lib/components/UIShell/Switcher.js +17 -6
  82. package/lib/index.js +2 -2
  83. package/lib/internal/FloatingMenu.js +47 -51
  84. package/lib/internal/useControllableState.js +1 -1
  85. package/lib/internal/useId.js +9 -0
  86. package/package.json +22 -19
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { useLayoutEffect, useEffect, useState } from 'react';
8
+ import { useLayoutEffect, useEffect, useState, useId as useId$1 } from 'react';
9
9
  import setupGetInstanceId from '../tools/setupGetInstanceId.js';
10
10
  import { canUseDOM } from './environment.js';
11
11
  import { useIdPrefix } from './useIdPrefix.js';
@@ -39,6 +39,15 @@ function useId() {
39
39
  serverHandoffCompleted = true;
40
40
  }
41
41
  }, []);
42
+ if (useId$1) {
43
+ const id = nativeReactUseId(_prefix, prefix);
44
+ return id;
45
+ }
46
+ return id;
47
+ }
48
+ function nativeReactUseId(_prefix, prefix) {
49
+ const getId = useId$1();
50
+ const id = `${_prefix ? `${_prefix}-` : ``}${prefix}-${getId}`;
42
51
  return id;
43
52
  }
44
53
 
@@ -37,6 +37,14 @@ var Downshift__default = /*#__PURE__*/_interopDefaultLegacy(Downshift);
37
37
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
38
38
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
39
39
 
40
+ const {
41
+ keyDownArrowDown,
42
+ keyDownArrowUp,
43
+ keyDownEscape,
44
+ clickButton,
45
+ blurButton,
46
+ changeInput
47
+ } = Downshift__default["default"].stateChangeTypes;
40
48
  const defaultItemToString = item => {
41
49
  if (typeof item === 'string') {
42
50
  return item;
@@ -126,6 +134,7 @@ const ComboBox = /*#__PURE__*/React__default["default"].forwardRef((props, ref)
126
134
  const [isFocused, setIsFocused] = React.useState(false);
127
135
  const [prevSelectedItem, setPrevSelectedItem] = React.useState();
128
136
  const [doneInitialSelectedItem, setDoneInitialSelectedItem] = React.useState(false);
137
+ const [highlightedIndex, setHighlightedIndex] = React.useState();
129
138
  const savedOnInputChange = React.useRef(onInputChange);
130
139
  if (!doneInitialSelectedItem || prevSelectedItem !== selectedItem) {
131
140
  setDoneInitialSelectedItem(true);
@@ -165,19 +174,43 @@ const ComboBox = /*#__PURE__*/React__default["default"].forwardRef((props, ref)
165
174
  textInput.current.focus();
166
175
  }
167
176
  };
168
- const handleOnStateChange = (newState, _ref3) => {
169
- let {
170
- setHighlightedIndex
171
- } = _ref3;
172
- if (Object.prototype.hasOwnProperty.call(newState, 'inputValue')) {
177
+ const getHighlightedIndex = changes => {
178
+ if (Object.prototype.hasOwnProperty.call(changes, 'inputValue')) {
173
179
  const {
174
180
  inputValue
175
- } = newState;
181
+ } = changes;
176
182
  const filteredItems = filterItems(items, itemToString, inputValue);
177
- setHighlightedIndex(findHighlightedIndex({
183
+ const indexToHighlight = findHighlightedIndex({
178
184
  ...props,
179
185
  items: filteredItems
180
- }, inputValue));
186
+ }, inputValue);
187
+ setHighlightedIndex(indexToHighlight);
188
+ return indexToHighlight;
189
+ }
190
+ return highlightedIndex;
191
+ };
192
+ const handleOnStateChange = (changes, _ref3) => {
193
+ let {
194
+ setHighlightedIndex: updateHighlightedIndex
195
+ } = _ref3;
196
+ const {
197
+ type
198
+ } = changes;
199
+ switch (type) {
200
+ case keyDownArrowDown:
201
+ case keyDownArrowUp:
202
+ setHighlightedIndex(changes.highlightedIndex);
203
+ break;
204
+ case blurButton:
205
+ case keyDownEscape:
206
+ setHighlightedIndex(changes.highlightedIndex);
207
+ break;
208
+ case clickButton:
209
+ setHighlightedIndex(changes.highlightedIndex);
210
+ break;
211
+ case changeInput:
212
+ updateHighlightedIndex(getHighlightedIndex(changes));
213
+ break;
181
214
  }
182
215
  };
183
216
  const handleToggleClick = isOpen => event => {
@@ -239,7 +272,6 @@ const ComboBox = /*#__PURE__*/React__default["default"].forwardRef((props, ref)
239
272
  isOpen,
240
273
  inputValue,
241
274
  selectedItem,
242
- highlightedIndex,
243
275
  clearSelection,
244
276
  toggleMenu
245
277
  } = _ref4;
@@ -337,6 +369,7 @@ const ComboBox = /*#__PURE__*/React__default["default"].forwardRef((props, ref)
337
369
  "aria-expanded": rootProps['aria-expanded'],
338
370
  "aria-haspopup": "listbox",
339
371
  "aria-controls": inputProps['aria-controls'],
372
+ "aria-owns": getMenuProps().id,
340
373
  title: textInput?.current?.value
341
374
  }, inputProps, rest, readOnlyEventHandlers, {
342
375
  readOnly: readOnly,
@@ -368,7 +401,7 @@ const ComboBox = /*#__PURE__*/React__default["default"].forwardRef((props, ref)
368
401
  return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
369
402
  key: itemProps.id,
370
403
  isActive: selectedItem === item,
371
- isHighlighted: highlightedIndex === index$1 || selectedItem?.id && selectedItem?.id === item.id || false,
404
+ isHighlighted: highlightedIndex === index$1,
372
405
  title: itemToElement ? item.text : itemToString ? itemToString(item) : undefined
373
406
  }, itemProps), itemToElement ?
374
407
  /*#__PURE__*/
@@ -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,46 +5,47 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
- export interface DataTableSkeletonProps {
8
+ import { TableHTMLAttributes } from 'react';
9
+ export interface DataTableSkeletonHeader {
9
10
  /**
10
- * Specify an optional className to add.
11
+ * Optionally specify header label
11
12
  */
12
- className?: string;
13
+ header?: string;
14
+ /**
15
+ * Optionally specify header key
16
+ */
17
+ key?: string;
18
+ }
19
+ export interface DataTableSkeletonProps extends TableHTMLAttributes<HTMLTableElement> {
13
20
  /**
14
21
  * Specify the number of columns that you want to render in the skeleton state
15
22
  */
16
- columnCount: number;
23
+ columnCount?: number;
17
24
  /**
18
25
  * Optionally specify whether you want the Skeleton to be rendered as a
19
26
  * compact DataTable
20
27
  */
21
- compact: boolean;
28
+ compact?: boolean;
22
29
  /**
23
30
  * Optionally specify the displayed headers
24
31
  */
25
- headers?: [{
26
- header: string;
27
- key: string;
28
- }] | {
29
- header: string;
30
- key: string;
31
- };
32
+ headers?: DataTableSkeletonHeader[];
32
33
  /**
33
34
  * Specify the number of rows that you want to render in the skeleton state
34
35
  */
35
- rowCount: number;
36
+ rowCount?: number;
36
37
  /**
37
38
  * Specify if the table header should be rendered as part of the skeleton.
38
39
  */
39
- showHeader: boolean;
40
+ showHeader?: boolean;
40
41
  /**
41
42
  * Specify if the table toolbar should be rendered as part of the skeleton.
42
43
  */
43
- showToolbar: boolean;
44
+ showToolbar?: boolean;
44
45
  /**
45
46
  * Optionally specify whether you want the DataTable to be zebra striped
46
47
  */
47
- zebra: boolean;
48
+ zebra?: boolean;
48
49
  }
49
50
  declare const DataTableSkeleton: {
50
51
  ({ headers, rowCount, columnCount, zebra, compact, className, showHeader, showToolbar, ...rest }: {
@@ -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
  /**