@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
package/README.md CHANGED
@@ -21,20 +21,35 @@ yarn add @carbon/react
21
21
  This package requires [Dart Sass](http://npmjs.com/package/sass) in order to
22
22
  compile styles.
23
23
 
24
- If you're new to Sass, or are wondering how to configure Sass for your project,
25
- we recommend checking out the following resources and links:
24
+ If you're new to Sass, we recommend checking out the following resources and
25
+ links:
26
26
 
27
27
  - [Sass Basics](https://sass-lang.com/guide)
28
- - [Webpack with Sass](https://webpack.js.org/loaders/sass-loader/)
28
+ - [The Sass `@use` documentation for Sass modules](https://sass-lang.com/documentation/at-rules/use/)
29
+ - [The Carbon Design System FAQ on Sass](https://carbondesignsystem.com/migrating/faq/#sass-and-package-management)
30
+
31
+ For info on how to configure Sass for your project, here are some common
32
+ framework's documentation worth reviewing:
33
+
29
34
  - [Next.js with Sass](https://nextjs.org/docs/basic-features/built-in-css-support#sass-support)
30
- - [Create React App with Sass](https://create-react-app.dev/docs/adding-a-sass-stylesheet/)
35
+ - [Remix with Sass](https://remix.run/docs/en/1.18.0/guides/styling#css-preprocessors)
36
+ - [Gatsby with Sass](https://www.gatsbyjs.com/docs/how-to/styling/sass/)
37
+
38
+ Or if you're just using a bundler:
39
+
31
40
  - [Parcel with Sass](https://v2.parceljs.org/languages/sass/)
32
41
  - [Vite with Sass](https://vitejs.dev/guide/features.html#css-pre-processors)
42
+
43
+ Or anything else not listed above:
44
+
45
+ - [Webpack with Sass](https://webpack.js.org/loaders/sass-loader/)
46
+ - [Create React App with Sass](https://create-react-app.dev/docs/adding-a-sass-stylesheet/)
33
47
  - [Snowpack with Sass](https://www.snowpack.dev/guides/sass/)
34
48
 
35
- Once you get Sass up and running in your project, configure Sass to include
36
- `node_modules` in its `includePaths` option. For more information, checkout the
37
- [configuration](../styles/docs/sass.md#configuration) section in our Sass docs.
49
+ Once you get Sass up and running in your project, you may need to configure Sass
50
+ to include `node_modules` in its `includePaths` option. For more information,
51
+ checkout the [configuration](../styles/docs/sass.md#configuration) section in
52
+ our Sass docs.
38
53
 
39
54
  ## Usage
40
55
 
@@ -26,6 +26,14 @@ import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
26
26
  import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
27
27
  import { Space, Enter, Escape, Home, End } from '../../internal/keyboard/keys.js';
28
28
 
29
+ const {
30
+ keyDownArrowDown,
31
+ keyDownArrowUp,
32
+ keyDownEscape,
33
+ clickButton,
34
+ blurButton,
35
+ changeInput
36
+ } = Downshift.stateChangeTypes;
29
37
  const defaultItemToString = item => {
30
38
  if (typeof item === 'string') {
31
39
  return item;
@@ -115,6 +123,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
115
123
  const [isFocused, setIsFocused] = useState(false);
116
124
  const [prevSelectedItem, setPrevSelectedItem] = useState();
117
125
  const [doneInitialSelectedItem, setDoneInitialSelectedItem] = useState(false);
126
+ const [highlightedIndex, setHighlightedIndex] = useState();
118
127
  const savedOnInputChange = useRef(onInputChange);
119
128
  if (!doneInitialSelectedItem || prevSelectedItem !== selectedItem) {
120
129
  setDoneInitialSelectedItem(true);
@@ -154,19 +163,43 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
154
163
  textInput.current.focus();
155
164
  }
156
165
  };
157
- const handleOnStateChange = (newState, _ref3) => {
158
- let {
159
- setHighlightedIndex
160
- } = _ref3;
161
- if (Object.prototype.hasOwnProperty.call(newState, 'inputValue')) {
166
+ const getHighlightedIndex = changes => {
167
+ if (Object.prototype.hasOwnProperty.call(changes, 'inputValue')) {
162
168
  const {
163
169
  inputValue
164
- } = newState;
170
+ } = changes;
165
171
  const filteredItems = filterItems(items, itemToString, inputValue);
166
- setHighlightedIndex(findHighlightedIndex({
172
+ const indexToHighlight = findHighlightedIndex({
167
173
  ...props,
168
174
  items: filteredItems
169
- }, inputValue));
175
+ }, inputValue);
176
+ setHighlightedIndex(indexToHighlight);
177
+ return indexToHighlight;
178
+ }
179
+ return highlightedIndex;
180
+ };
181
+ const handleOnStateChange = (changes, _ref3) => {
182
+ let {
183
+ setHighlightedIndex: updateHighlightedIndex
184
+ } = _ref3;
185
+ const {
186
+ type
187
+ } = changes;
188
+ switch (type) {
189
+ case keyDownArrowDown:
190
+ case keyDownArrowUp:
191
+ setHighlightedIndex(changes.highlightedIndex);
192
+ break;
193
+ case blurButton:
194
+ case keyDownEscape:
195
+ setHighlightedIndex(changes.highlightedIndex);
196
+ break;
197
+ case clickButton:
198
+ setHighlightedIndex(changes.highlightedIndex);
199
+ break;
200
+ case changeInput:
201
+ updateHighlightedIndex(getHighlightedIndex(changes));
202
+ break;
170
203
  }
171
204
  };
172
205
  const handleToggleClick = isOpen => event => {
@@ -228,7 +261,6 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
228
261
  isOpen,
229
262
  inputValue,
230
263
  selectedItem,
231
- highlightedIndex,
232
264
  clearSelection,
233
265
  toggleMenu
234
266
  } = _ref4;
@@ -326,6 +358,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
326
358
  "aria-expanded": rootProps['aria-expanded'],
327
359
  "aria-haspopup": "listbox",
328
360
  "aria-controls": inputProps['aria-controls'],
361
+ "aria-owns": getMenuProps().id,
329
362
  title: textInput?.current?.value
330
363
  }, inputProps, rest, readOnlyEventHandlers, {
331
364
  readOnly: readOnly,
@@ -357,7 +390,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
357
390
  return /*#__PURE__*/React__default.createElement(ListBox.MenuItem, _extends({
358
391
  key: itemProps.id,
359
392
  isActive: selectedItem === item,
360
- isHighlighted: highlightedIndex === index || selectedItem?.id && selectedItem?.id === item.id || false,
393
+ isHighlighted: highlightedIndex === index,
361
394
  title: itemToElement ? item.text : itemToString ? itemToString(item) : undefined
362
395
  }, itemProps), itemToElement ?
363
396
  /*#__PURE__*/
@@ -20,6 +20,11 @@ import { ArrowRight, ArrowLeft } from '../../internal/keyboard/keys.js';
20
20
  class ContentSwitcher extends React__default.Component {
21
21
  constructor() {
22
22
  super(...arguments);
23
+ /**
24
+ * The DOM references of child `<Switch>`.
25
+ * @type {Array<Element>}
26
+ * @private
27
+ */
23
28
  _defineProperty(this, "_switchRefs", []);
24
29
  _defineProperty(this, "state", {
25
30
  selectedIndex: undefined
@@ -77,11 +82,6 @@ class ContentSwitcher extends React__default.Component {
77
82
  }
78
83
  });
79
84
  }
80
- /**
81
- * The DOM references of child `<Switch>`.
82
- * @type {Array<Element>}
83
- * @private
84
- */
85
85
  static getDerivedStateFromProps(_ref, state) {
86
86
  let {
87
87
  selectedIndex
@@ -76,6 +76,16 @@ class DataTable extends React__default.Component {
76
76
  var _this;
77
77
  super(_props);
78
78
  _this = this;
79
+ /**
80
+ * Get the props associated with the given header. Mostly used for adding in
81
+ * sorting behavior.
82
+ *
83
+ * @param {object} config
84
+ * @param {string} config.header the header we want the props for
85
+ * @param {Function} config.onClick a custom click handler for the header
86
+ * @param {boolean} config.isSortable
87
+ * @returns {object}
88
+ */
79
89
  _defineProperty(this, "getHeaderProps", _ref => {
80
90
  let {
81
91
  header,
@@ -106,6 +116,14 @@ class DataTable extends React__default.Component {
106
116
  }
107
117
  };
108
118
  });
119
+ /**
120
+ * Get the props associated with the given expand header.
121
+ *
122
+ * @param {object} config
123
+ * @param {Function} config.onClick a custom click handler for the expand header
124
+ * @param {Function} config.onExpand a custom click handler called when header is expanded
125
+ * @returns {object}
126
+ */
109
127
  _defineProperty(this, "getExpandHeaderProps", function () {
110
128
  let {
111
129
  onClick,
@@ -133,12 +151,34 @@ class DataTable extends React__default.Component {
133
151
  }) : null])
134
152
  };
135
153
  });
154
+ /**
155
+ * Decorate consumer's `onClick` event handler with sort parameters
156
+ *
157
+ * @param {Function} onClick
158
+ * @param {object} sortParams
159
+ * @returns {Function}
160
+ */
136
161
  _defineProperty(this, "handleOnHeaderClick", (onClick, sortParams) => {
137
162
  return e => onClick(e, sortParams);
138
163
  });
164
+ /**
165
+ * Decorate consumer's `onClick` event handler with sort parameters
166
+ *
167
+ * @param {Function} onClick
168
+ * @param {object} expandParams
169
+ * @returns {Function}
170
+ */
139
171
  _defineProperty(this, "handleOnExpandHeaderClick", (onClick, expandParams) => {
140
172
  return e => onClick(e, expandParams);
141
173
  });
174
+ /**
175
+ * Get the props associated with the given row. Mostly used for expansion.
176
+ *
177
+ * @param {object} config
178
+ * @param {object} config.row the row we want the props for
179
+ * @param {Function} config.onClick a custom click handler for the header
180
+ * @returns {object}
181
+ */
142
182
  _defineProperty(this, "getRowProps", _ref2 => {
143
183
  let {
144
184
  row,
@@ -161,6 +201,16 @@ class DataTable extends React__default.Component {
161
201
  disabled: row.disabled
162
202
  };
163
203
  });
204
+ /**
205
+ * Gets the props associated with selection for a header or a row, where
206
+ * applicable. Most often used to indicate selection status of the table or
207
+ * for a specific row.
208
+ *
209
+ * @param {object} [row] an optional row that we want to access the props for
210
+ * @param {Function} row.onClick
211
+ * @param {object} row.row
212
+ * @returns {object}
213
+ */
164
214
  _defineProperty(this, "getSelectionProps", function () {
165
215
  let {
166
216
  onClick,
@@ -227,6 +277,9 @@ class DataTable extends React__default.Component {
227
277
  onCancel: _this.handleOnCancel
228
278
  };
229
279
  });
280
+ /**
281
+ * Helper utility to get the Table Props.
282
+ */
230
283
  _defineProperty(this, "getTableProps", () => {
231
284
  const {
232
285
  useZebraStyles,
@@ -247,6 +300,9 @@ class DataTable extends React__default.Component {
247
300
  experimentalAutoAlign
248
301
  };
249
302
  });
303
+ /**
304
+ * Helper utility to get the TableContainer Props.
305
+ */
250
306
  _defineProperty(this, "getTableContainerProps", () => {
251
307
  const {
252
308
  stickyHeader,
@@ -257,10 +313,18 @@ class DataTable extends React__default.Component {
257
313
  useStaticWidth
258
314
  };
259
315
  });
316
+ /**
317
+ * Helper utility to get all the currently selected rows
318
+ * @returns {Array<string>} the array of rowIds that are currently selected
319
+ */
260
320
  _defineProperty(this, "getSelectedRows", () => this.state.rowIds.filter(id => {
261
321
  const row = this.state.rowsById[id];
262
322
  return row.isSelected && !row.disabled;
263
323
  }));
324
+ /**
325
+ * Helper utility to get all of the available rows after applying the filter
326
+ * @returns {Array<string>} the array of rowIds that are currently included through the filter
327
+ * */
264
328
  _defineProperty(this, "getFilteredRowIds", () => {
265
329
  const filteredRowIds = typeof this.state.filterInputValue === 'string' ? this.props.filterRows({
266
330
  rowIds: this.state.rowIds,
@@ -274,7 +338,19 @@ class DataTable extends React__default.Component {
274
338
  }
275
339
  return filteredRowIds;
276
340
  });
341
+ /**
342
+ * Helper for getting the table prefix for elements that require an
343
+ * `id` attribute that is unique.
344
+ *
345
+ * @returns {string}
346
+ */
277
347
  _defineProperty(this, "getTablePrefix", () => `data-table-${this.instanceId}`);
348
+ /**
349
+ * Helper for toggling all selected items in a state. Does not call
350
+ * setState, so use it when setting state.
351
+ * @param {object} initialState
352
+ * @returns {object} object to put into this.setState (use spread operator)
353
+ */
278
354
  _defineProperty(this, "setAllSelectedState", (initialState, isSelected, filteredRowIds) => {
279
355
  const {
280
356
  rowIds
@@ -293,6 +369,10 @@ class DataTable extends React__default.Component {
293
369
  }, {})
294
370
  };
295
371
  });
372
+ /**
373
+ * Handler for the `onCancel` event to hide the batch action bar and
374
+ * deselect all selected rows
375
+ */
296
376
  _defineProperty(this, "handleOnCancel", () => {
297
377
  this.setState(state => {
298
378
  return {
@@ -301,6 +381,9 @@ class DataTable extends React__default.Component {
301
381
  };
302
382
  });
303
383
  });
384
+ /**
385
+ * Handler for toggling the selection state of all rows in the database
386
+ */
304
387
  _defineProperty(this, "handleSelectAll", () => {
305
388
  this.setState(state => {
306
389
  const filteredRowIds = this.getFilteredRowIds();
@@ -314,6 +397,12 @@ class DataTable extends React__default.Component {
314
397
  };
315
398
  });
316
399
  });
400
+ /**
401
+ * Handler for toggling the selection state of a given row.
402
+ *
403
+ * @param {string} rowId
404
+ * @returns {Function}
405
+ */
317
406
  _defineProperty(this, "handleOnSelectRow", rowId => () => {
318
407
  this.setState(state => {
319
408
  const row = state.rowsById[rowId];
@@ -355,6 +444,12 @@ class DataTable extends React__default.Component {
355
444
  };
356
445
  });
357
446
  });
447
+ /**
448
+ * Handler for toggling the expansion state of a given row.
449
+ *
450
+ * @param {string} rowId
451
+ * @returns {Function}
452
+ */
358
453
  _defineProperty(this, "handleOnExpandRow", rowId => () => {
359
454
  this.setState(state => {
360
455
  const row = state.rowsById[rowId];
@@ -373,6 +468,9 @@ class DataTable extends React__default.Component {
373
468
  };
374
469
  });
375
470
  });
471
+ /**
472
+ * Handler for changing the expansion state of all rows.
473
+ */
376
474
  _defineProperty(this, "handleOnExpandAll", () => {
377
475
  this.setState(state => {
378
476
  const {
@@ -391,11 +489,23 @@ class DataTable extends React__default.Component {
391
489
  };
392
490
  });
393
491
  });
492
+ /**
493
+ * Handler for transitioning to the next sort state of the table
494
+ *
495
+ * @param {string} headerKey the field for the header that we are sorting by
496
+ * @returns {Function}
497
+ */
394
498
  _defineProperty(this, "handleSortBy", headerKey => () => {
395
499
  this.setState(state => getNextSortState(this.props, state, {
396
500
  key: headerKey
397
501
  }));
398
502
  });
503
+ /**
504
+ * Event handler for transitioning input value state changes for the table
505
+ * filter component.
506
+ *
507
+ * @param {Event} event
508
+ */
399
509
  _defineProperty(this, "handleOnInputValueChange", (event, defaultValue) => {
400
510
  if (event.target) {
401
511
  this.setState({
@@ -438,136 +548,6 @@ class DataTable extends React__default.Component {
438
548
  }
439
549
  return true;
440
550
  }
441
-
442
- /**
443
- * Get the props associated with the given header. Mostly used for adding in
444
- * sorting behavior.
445
- *
446
- * @param {object} config
447
- * @param {string} config.header the header we want the props for
448
- * @param {Function} config.onClick a custom click handler for the header
449
- * @param {boolean} config.isSortable
450
- * @returns {object}
451
- */
452
-
453
- /**
454
- * Get the props associated with the given expand header.
455
- *
456
- * @param {object} config
457
- * @param {Function} config.onClick a custom click handler for the expand header
458
- * @param {Function} config.onExpand a custom click handler called when header is expanded
459
- * @returns {object}
460
- */
461
-
462
- /**
463
- * Decorate consumer's `onClick` event handler with sort parameters
464
- *
465
- * @param {Function} onClick
466
- * @param {object} sortParams
467
- * @returns {Function}
468
- */
469
-
470
- /**
471
- * Decorate consumer's `onClick` event handler with sort parameters
472
- *
473
- * @param {Function} onClick
474
- * @param {object} expandParams
475
- * @returns {Function}
476
- */
477
-
478
- /**
479
- * Get the props associated with the given row. Mostly used for expansion.
480
- *
481
- * @param {object} config
482
- * @param {object} config.row the row we want the props for
483
- * @param {Function} config.onClick a custom click handler for the header
484
- * @returns {object}
485
- */
486
-
487
- /**
488
- * Gets the props associated with selection for a header or a row, where
489
- * applicable. Most often used to indicate selection status of the table or
490
- * for a specific row.
491
- *
492
- * @param {object} [row] an optional row that we want to access the props for
493
- * @param {Function} row.onClick
494
- * @param {object} row.row
495
- * @returns {object}
496
- */
497
-
498
- /**
499
- * Helper utility to get the Table Props.
500
- */
501
-
502
- /**
503
- * Helper utility to get the TableContainer Props.
504
- */
505
-
506
- /**
507
- * Helper utility to get all the currently selected rows
508
- * @returns {Array<string>} the array of rowIds that are currently selected
509
- */
510
-
511
- /**
512
- * Helper utility to get all of the available rows after applying the filter
513
- * @returns {Array<string>} the array of rowIds that are currently included through the filter
514
- * */
515
-
516
- /**
517
- * Helper for getting the table prefix for elements that require an
518
- * `id` attribute that is unique.
519
- *
520
- * @returns {string}
521
- */
522
-
523
- /**
524
- * Helper for toggling all selected items in a state. Does not call
525
- * setState, so use it when setting state.
526
- * @param {object} initialState
527
- * @returns {object} object to put into this.setState (use spread operator)
528
- */
529
-
530
- /**
531
- * Handler for the `onCancel` event to hide the batch action bar and
532
- * deselect all selected rows
533
- */
534
-
535
- /**
536
- * Handler for toggling the selection state of all rows in the database
537
- */
538
-
539
- /**
540
- * Handler for toggling the selection state of a given row.
541
- *
542
- * @param {string} rowId
543
- * @returns {Function}
544
- */
545
-
546
- /**
547
- * Handler for toggling the expansion state of a given row.
548
- *
549
- * @param {string} rowId
550
- * @returns {Function}
551
- */
552
-
553
- /**
554
- * Handler for changing the expansion state of all rows.
555
- */
556
-
557
- /**
558
- * Handler for transitioning to the next sort state of the table
559
- *
560
- * @param {string} headerKey the field for the header that we are sorting by
561
- * @returns {Function}
562
- */
563
-
564
- /**
565
- * Event handler for transitioning input value state changes for the table
566
- * filter component.
567
- *
568
- * @param {Event} event
569
- */
570
-
571
551
  render() {
572
552
  // eslint-disable-next-line react/prop-types
573
553
  const {
@@ -99,7 +99,7 @@ const Table = _ref => {
99
99
  useWindowEvent('resize', debouncedSetTableAlignment);
100
100
 
101
101
  // recalculate table alignment once fonts have loaded
102
- if (document?.fonts?.status && document.fonts.status !== 'loaded') {
102
+ if (typeof document !== 'undefined' && document?.fonts?.status && document.fonts.status !== 'loaded') {
103
103
  document.fonts.ready.then(() => {
104
104
  setTableAlignment();
105
105
  });
@@ -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;
@@ -676,14 +676,17 @@ DatePicker.propTypes = {
676
676
  minDate: PropTypes.string,
677
677
  /**
678
678
  * The `change` event handler.
679
+ * `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
679
680
  */
680
681
  onChange: PropTypes.func,
681
682
  /**
682
683
  * The `close` event handler.
684
+ * `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
683
685
  */
684
686
  onClose: PropTypes.func,
685
687
  /**
686
688
  * The `open` event handler.
689
+ * `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
687
690
  */
688
691
  onOpen: PropTypes.func,
689
692
  /**
@@ -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
  /**