@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
@@ -0,0 +1,110 @@
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 FileUploaderItemProps extends ReactAttr<HTMLSpanElement> {
11
+ /**
12
+ * Error message body for an invalid file upload
13
+ */
14
+ errorBody?: string;
15
+ /**
16
+ * Error message subject for an invalid file upload
17
+ */
18
+ errorSubject?: string;
19
+ /**
20
+ * Description of status icon (displayed in native tooltip)
21
+ */
22
+ iconDescription?: string;
23
+ /**
24
+ * Specify if the currently uploaded file is invalid
25
+ */
26
+ invalid?: boolean;
27
+ /**
28
+ * Name of the uploaded file
29
+ */
30
+ name?: string;
31
+ /**
32
+ * Event handler that is called after removing a file from the file uploader
33
+ * The event handler signature looks like `onDelete(evt, { uuid })`
34
+ */
35
+ onDelete?: (event: any, opts: {
36
+ uuid: string;
37
+ }) => void;
38
+ /**
39
+ * Specify the size of the FileUploaderButton, from a list of available
40
+ * sizes.
41
+ */
42
+ size?: 'sm' | 'md' | 'lg';
43
+ /**
44
+ * Status of the file upload
45
+ */
46
+ status?: 'uploading' | 'edit' | 'complete';
47
+ /**
48
+ * Unique identifier for the file object
49
+ */
50
+ uuid?: string;
51
+ }
52
+ declare function FileUploaderItem({ uuid, name, status, iconDescription, onDelete, invalid, errorSubject, errorBody, size, ...other }: {
53
+ [x: string]: any;
54
+ uuid: any;
55
+ name: any;
56
+ status: any;
57
+ iconDescription: any;
58
+ onDelete: any;
59
+ invalid: any;
60
+ errorSubject: any;
61
+ errorBody: any;
62
+ size: any;
63
+ }): JSX.Element;
64
+ declare namespace FileUploaderItem {
65
+ var propTypes: {
66
+ /**
67
+ * Error message body for an invalid file upload
68
+ */
69
+ errorBody: PropTypes.Requireable<string>;
70
+ /**
71
+ * Error message subject for an invalid file upload
72
+ */
73
+ errorSubject: PropTypes.Requireable<string>;
74
+ /**
75
+ * Description of status icon (displayed in native tooltip)
76
+ */
77
+ iconDescription: PropTypes.Requireable<string>;
78
+ /**
79
+ * Specify if the currently uploaded file is invalid
80
+ */
81
+ invalid: PropTypes.Requireable<boolean>;
82
+ /**
83
+ * Name of the uploaded file
84
+ */
85
+ name: PropTypes.Requireable<string>;
86
+ /**
87
+ * Event handler that is called after removing a file from the file uploader
88
+ * The event handler signature looks like `onDelete(evt, { uuid })`
89
+ */
90
+ onDelete: PropTypes.Requireable<(...args: any[]) => any>;
91
+ /**
92
+ * Specify the size of the FileUploaderButton, from a list of available
93
+ * sizes.
94
+ */
95
+ size: PropTypes.Requireable<string>;
96
+ /**
97
+ * Status of the file upload
98
+ */
99
+ status: PropTypes.Requireable<string>;
100
+ /**
101
+ * Unique identifier for the file object
102
+ */
103
+ uuid: PropTypes.Requireable<string>;
104
+ };
105
+ var defaultProps: {
106
+ status: string;
107
+ onDelete: () => void;
108
+ };
109
+ }
110
+ export default FileUploaderItem;
@@ -0,0 +1,71 @@
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 type FilenameStatus = 'edit' | 'complete' | 'uploading';
11
+ export interface FilenameProps extends Omit<ReactAttr<HTMLElement>, 'tabIndex'> {
12
+ /**
13
+ * Specify an id that describes the error to be read by screen readers when the filename is invalid
14
+ */
15
+ ['aria-describedby']?: string;
16
+ /**
17
+ * Provide a description of the SVG icon to denote file upload status
18
+ */
19
+ iconDescription?: string;
20
+ /**
21
+ * Specify if the file is invalid
22
+ */
23
+ invalid?: boolean;
24
+ /**
25
+ * Name of the uploaded file
26
+ */
27
+ name?: string;
28
+ /**
29
+ * Status of the file upload
30
+ */
31
+ status?: FilenameStatus;
32
+ /**
33
+ * Provide a custom tabIndex value for the `<Filename>`
34
+ */
35
+ tabIndex?: number | string;
36
+ }
37
+ declare function Filename({ iconDescription, status, invalid, name, ['aria-describedby']: ariaDescribedBy, ...rest }: FilenameProps): JSX.Element | null;
38
+ declare namespace Filename {
39
+ var propTypes: {
40
+ /**
41
+ * Specify an id that describes the error to be read by screen readers when the filename is invalid
42
+ */
43
+ "aria-describedby": PropTypes.Requireable<string>;
44
+ /**
45
+ * Provide a description of the SVG icon to denote file upload status
46
+ */
47
+ iconDescription: PropTypes.Requireable<string>;
48
+ /**
49
+ * Specify if the file is invalid
50
+ */
51
+ invalid: PropTypes.Requireable<boolean>;
52
+ /**
53
+ * Name of the uploaded file
54
+ */
55
+ name: PropTypes.Requireable<string>;
56
+ /**
57
+ * Status of the file upload
58
+ */
59
+ status: PropTypes.Requireable<string>;
60
+ /**
61
+ * Provide a custom tabIndex value for the `<Filename>`
62
+ */
63
+ tabIndex: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
64
+ };
65
+ var defaultProps: {
66
+ iconDescription: string;
67
+ status: string;
68
+ tabIndex: string;
69
+ };
70
+ }
71
+ export default Filename;
@@ -28,7 +28,7 @@ function Filename(_ref) {
28
28
  status,
29
29
  invalid,
30
30
  name,
31
- ['aria-describedBy']: ariaDescribedBy,
31
+ ['aria-describedby']: ariaDescribedBy,
32
32
  ...rest
33
33
  } = _ref;
34
34
  const prefix = usePrefix.usePrefix();
@@ -44,10 +44,12 @@ function Filename(_ref) {
44
44
  className: `${prefix}--file-invalid`
45
45
  }), /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({
46
46
  "aria-label": `${iconDescription} - ${name}`,
47
- "aria-describedby": invalid ? ariaDescribedBy : null,
48
47
  className: `${prefix}--file-close`,
49
48
  type: "button"
50
- }, rest), _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null))));
49
+ }, rest, {
50
+ tabIndex: rest.tabIndex !== undefined ? parseInt(rest.tabIndex, 10) : undefined,
51
+ "aria-describedby": invalid ? ariaDescribedBy : undefined
52
+ }), _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null))));
51
53
  case 'complete':
52
54
  return /*#__PURE__*/React__default["default"].createElement(iconsReact.CheckmarkFilled, _rollupPluginBabelHelpers["extends"]({
53
55
  "aria-label": iconDescription,
@@ -83,7 +85,7 @@ Filename.propTypes = {
83
85
  /**
84
86
  * Provide a custom tabIndex value for the `<Filename>`
85
87
  */
86
- tabIndex: PropTypes__default["default"].string
88
+ tabIndex: PropTypes__default["default"].oneOfType([PropTypes__default["default"].number, PropTypes__default["default"].string])
87
89
  };
88
90
  Filename.defaultProps = {
89
91
  iconDescription: 'Uploading file',
@@ -56,7 +56,9 @@ const InlineCheckbox = /*#__PURE__*/React__default["default"].forwardRef(functio
56
56
  inputProps.checked = false;
57
57
  }
58
58
  React.useEffect(() => {
59
- inputRef.current.indeterminate = indeterminate;
59
+ if (inputRef?.current) {
60
+ inputRef.current.indeterminate = indeterminate;
61
+ }
60
62
  }, [indeterminate]);
61
63
  return /*#__PURE__*/React__default["default"].createElement("div", {
62
64
  className: `${prefix}--checkbox--inline`
@@ -0,0 +1,65 @@
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 LoadingProps extends ReactAttr<HTMLDivElement> {
11
+ /**
12
+ * Specify whether you want the loading indicator to be spinning or not
13
+ */
14
+ active?: boolean;
15
+ /**
16
+ * Provide an optional className to be applied to the containing node
17
+ */
18
+ className?: string;
19
+ /**
20
+ * Specify a description that would be used to best describe the loading state
21
+ */
22
+ description?: string;
23
+ /**
24
+ * @deprecated The prop `id` is no longer needed
25
+ */
26
+ id?: string;
27
+ /**
28
+ * Specify whether you would like the small variant of <Loading>
29
+ */
30
+ small?: boolean;
31
+ /**
32
+ * Specify whether you want the loader to be applied with an overlay
33
+ */
34
+ withOverlay: boolean;
35
+ }
36
+ declare function Loading({ active, className: customClassName, withOverlay, small, description, ...rest }: LoadingProps): JSX.Element;
37
+ declare namespace Loading {
38
+ var propTypes: {
39
+ /**
40
+ * Specify whether you want the loading indicator to be spinning or not
41
+ */
42
+ active: PropTypes.Requireable<boolean>;
43
+ /**
44
+ * Provide an optional className to be applied to the containing node
45
+ */
46
+ className: PropTypes.Requireable<string>;
47
+ /**
48
+ * Specify a description that would be used to best describe the loading state
49
+ */
50
+ description: PropTypes.Requireable<string>;
51
+ /**
52
+ * Provide an `id` to uniquely identify the label
53
+ */
54
+ id: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
55
+ /**
56
+ * Specify whether you would like the small variant of <Loading>
57
+ */
58
+ small: PropTypes.Requireable<boolean>;
59
+ /**
60
+ * Specify whether you want the loader to be applied with an overlay
61
+ */
62
+ withOverlay: PropTypes.Requireable<boolean>;
63
+ };
64
+ }
65
+ export default Loading;
@@ -379,7 +379,7 @@ export interface ActionableNotificationProps extends HTMLAttributes<HTMLDivEleme
379
379
  /**
380
380
  * Pass in the action button label that will be rendered within the ActionableNotification.
381
381
  */
382
- actionButtonLabel: string;
382
+ actionButtonLabel?: string;
383
383
  /**
384
384
  * Provide a description for "close" icon button that can be read by screen readers
385
385
  */
@@ -438,7 +438,7 @@ export interface ActionableNotificationProps extends HTMLAttributes<HTMLDivEleme
438
438
  /**
439
439
  * Specify the subtitle
440
440
  */
441
- subtitle?: string;
441
+ subtitle?: ReactNode;
442
442
  /**
443
443
  * Specify the title
444
444
  */
@@ -450,7 +450,7 @@ export declare namespace ActionableNotification {
450
450
  /**
451
451
  * Pass in the action button label that will be rendered within the ActionableNotification.
452
452
  */
453
- actionButtonLabel: PropTypes.Validator<string>;
453
+ actionButtonLabel: PropTypes.Requireable<string>;
454
454
  /**
455
455
  * Provide a description for "close" icon button that can be read by screen readers
456
456
  */
@@ -513,7 +513,7 @@ export declare namespace ActionableNotification {
513
513
  /**
514
514
  * Specify the subtitle
515
515
  */
516
- subtitle: PropTypes.Requireable<string>;
516
+ subtitle: PropTypes.Requireable<PropTypes.ReactNodeLike>;
517
517
  /**
518
518
  * Specify the title
519
519
  */
@@ -566,7 +566,7 @@ function ActionableNotification(_ref6) {
566
566
  id: id
567
567
  }, title), subtitle && /*#__PURE__*/React__default["default"].createElement("div", {
568
568
  className: `${prefix}--actionable-notification__subtitle`
569
- }, subtitle), children))), /*#__PURE__*/React__default["default"].createElement(NotificationActionButton, {
569
+ }, subtitle), children))), actionButtonLabel && /*#__PURE__*/React__default["default"].createElement(NotificationActionButton, {
570
570
  onClick: onActionButtonClick,
571
571
  inline: inline
572
572
  }, actionButtonLabel), !hideCloseButton && /*#__PURE__*/React__default["default"].createElement(NotificationButton, {
@@ -579,7 +579,7 @@ ActionableNotification.propTypes = {
579
579
  /**
580
580
  * Pass in the action button label that will be rendered within the ActionableNotification.
581
581
  */
582
- actionButtonLabel: PropTypes__default["default"].string.isRequired,
582
+ actionButtonLabel: PropTypes__default["default"].string,
583
583
  /**
584
584
  * Provide a description for "close" icon button that can be read by screen readers
585
585
  */
@@ -645,7 +645,7 @@ ActionableNotification.propTypes = {
645
645
  /**
646
646
  * Specify the subtitle
647
647
  */
648
- subtitle: PropTypes__default["default"].string,
648
+ subtitle: PropTypes__default["default"].node,
649
649
  /**
650
650
  * Specify the title
651
651
  */
@@ -108,8 +108,21 @@ class OverflowMenu extends React.Component {
108
108
  super(...arguments);
109
109
  _rollupPluginBabelHelpers.defineProperty(this, "state", {});
110
110
  _rollupPluginBabelHelpers.defineProperty(this, "instanceId", getInstanceId());
111
+ /**
112
+ * The handle of `onfocusin` or `focus` event handler.
113
+ * @private
114
+ */
111
115
  _rollupPluginBabelHelpers.defineProperty(this, "_hFocusIn", null);
116
+ /**
117
+ * The timeout handle for handling `blur` event.
118
+ * @private
119
+ */
112
120
  _rollupPluginBabelHelpers.defineProperty(this, "_hBlurTimeout", void 0);
121
+ /**
122
+ * The element ref of the tooltip's trigger button.
123
+ * @type {React.RefObject<Element>}
124
+ * @private
125
+ */
113
126
  _rollupPluginBabelHelpers.defineProperty(this, "_triggerRef", /*#__PURE__*/React__default["default"].createRef());
114
127
  _rollupPluginBabelHelpers.defineProperty(this, "handleClick", evt => {
115
128
  evt.stopPropagation();
@@ -165,6 +178,15 @@ class OverflowMenu extends React.Component {
165
178
  triggerEl.focus();
166
179
  }
167
180
  });
181
+ /**
182
+ * Focuses the next enabled overflow menu item given the currently focused
183
+ * item index and direction to move
184
+ * @param {object} params
185
+ * @param {number} params.currentIndex - the index of the currently focused
186
+ * overflow menu item in the list of overflow menu items
187
+ * @param {number} params.direction - number denoting the direction to move
188
+ * focus (1 for forwards, -1 for backwards)
189
+ */
168
190
  _rollupPluginBabelHelpers.defineProperty(this, "handleOverflowMenuItemFocus", _ref => {
169
191
  let {
170
192
  currentIndex,
@@ -190,6 +212,12 @@ class OverflowMenu extends React.Component {
190
212
  const overflowMenuItem = this[`overflowMenuItem${enabledIndices[nextValidIndex]}`];
191
213
  overflowMenuItem?.focus();
192
214
  });
215
+ /**
216
+ * Handles the floating menu being unmounted or non-floating menu being
217
+ * mounted or unmounted.
218
+ * @param {Element} menuBody The DOM element of the menu body.
219
+ * @private
220
+ */
193
221
  _rollupPluginBabelHelpers.defineProperty(this, "_bindMenuBody", menuBody => {
194
222
  if (!menuBody) {
195
223
  this._menuBody = menuBody;
@@ -198,6 +226,11 @@ class OverflowMenu extends React.Component {
198
226
  this._hFocusIn = this._hFocusIn.release();
199
227
  }
200
228
  });
229
+ /**
230
+ * Handles the floating menu being placed.
231
+ * @param {Element} menuBody The DOM element of the menu body.
232
+ * @private
233
+ */
201
234
  _rollupPluginBabelHelpers.defineProperty(this, "_handlePlace", menuBody => {
202
235
  if (menuBody) {
203
236
  this._menuBody = menuBody;
@@ -217,6 +250,9 @@ class OverflowMenu extends React.Component {
217
250
  this.props.onOpen();
218
251
  }
219
252
  });
253
+ /**
254
+ * @returns {Element} The DOM element where the floating menu is placed in.
255
+ */
220
256
  _rollupPluginBabelHelpers.defineProperty(this, "_getTarget", () => {
221
257
  const {
222
258
  current: triggerEl
@@ -224,19 +260,6 @@ class OverflowMenu extends React.Component {
224
260
  return triggerEl && triggerEl.closest('[data-floating-menu-container]') || document.body;
225
261
  });
226
262
  }
227
- /**
228
- * The handle of `onfocusin` or `focus` event handler.
229
- * @private
230
- */
231
- /**
232
- * The timeout handle for handling `blur` event.
233
- * @private
234
- */
235
- /**
236
- * The element ref of the tooltip's trigger button.
237
- * @type {React.RefObject<Element>}
238
- * @private
239
- */
240
263
  componentDidUpdate(_, prevState) {
241
264
  const {
242
265
  onClose
@@ -272,34 +295,6 @@ class OverflowMenu extends React.Component {
272
295
  this._hBlurTimeout = undefined;
273
296
  }
274
297
  }
275
-
276
- /**
277
- * Focuses the next enabled overflow menu item given the currently focused
278
- * item index and direction to move
279
- * @param {object} params
280
- * @param {number} params.currentIndex - the index of the currently focused
281
- * overflow menu item in the list of overflow menu items
282
- * @param {number} params.direction - number denoting the direction to move
283
- * focus (1 for forwards, -1 for backwards)
284
- */
285
-
286
- /**
287
- * Handles the floating menu being unmounted or non-floating menu being
288
- * mounted or unmounted.
289
- * @param {Element} menuBody The DOM element of the menu body.
290
- * @private
291
- */
292
-
293
- /**
294
- * Handles the floating menu being placed.
295
- * @param {Element} menuBody The DOM element of the menu body.
296
- * @private
297
- */
298
-
299
- /**
300
- * @returns {Element} The DOM element where the floating menu is placed in.
301
- */
302
-
303
298
  render() {
304
299
  const prefix = this.context;
305
300
  const {
@@ -60,6 +60,13 @@ class Slider extends React.PureComponent {
60
60
  _rollupPluginBabelHelpers.defineProperty(this, "element", null);
61
61
  _rollupPluginBabelHelpers.defineProperty(this, "inputId", '');
62
62
  _rollupPluginBabelHelpers.defineProperty(this, "track", void 0);
63
+ /**
64
+ * Sets up "drag" event handlers and calls `this.onDrag` in case dragging
65
+ * started on somewhere other than the thumb without a corresponding "move"
66
+ * event.
67
+ *
68
+ * @param {Event} evt The event.
69
+ */
63
70
  _rollupPluginBabelHelpers.defineProperty(this, "onDragStart", evt => {
64
71
  // Do nothing if component is disabled
65
72
  if (this.props.disabled || this.props.readOnly) {
@@ -80,6 +87,10 @@ class Slider extends React.PureComponent {
80
87
  // middle of the thumb
81
88
  this.onDrag(evt);
82
89
  });
90
+ /**
91
+ * Unregisters "drag" and "drag stop" event handlers and calls sets the flag
92
+ * indicating that the `onRelease` callback should be called.
93
+ */
83
94
  _rollupPluginBabelHelpers.defineProperty(this, "onDragStop", () => {
84
95
  // Do nothing if component is disabled
85
96
  if (this.props.disabled || this.props.readOnly) {
@@ -102,6 +113,12 @@ class Slider extends React.PureComponent {
102
113
  isValid: true
103
114
  });
104
115
  });
116
+ /**
117
+ * Handles a "drag" event by recalculating the value/thumb and setting state
118
+ * accordingly.
119
+ *
120
+ * @param {Event} evt The event.
121
+ */
105
122
  _rollupPluginBabelHelpers.defineProperty(this, "_onDrag", evt => {
106
123
  // Do nothing if component is disabled or we have no event
107
124
  if (this.props.disabled || this.props.readOnly || !evt) {
@@ -128,10 +145,20 @@ class Slider extends React.PureComponent {
128
145
  isValid: true
129
146
  });
130
147
  });
148
+ /**
149
+ * Throttles calls to `this._onDrag` by limiting events to being processed at
150
+ * most once every `EVENT_THROTTLE` milliseconds.
151
+ */
131
152
  _rollupPluginBabelHelpers.defineProperty(this, "onDrag", throttle__default["default"](this._onDrag, EVENT_THROTTLE, {
132
153
  leading: true,
133
154
  trailing: false
134
155
  }));
156
+ /**
157
+ * Handles a `keydown` event by recalculating the value/thumb and setting
158
+ * state accordingly.
159
+ *
160
+ * @param {Event} evt The event.
161
+ */
135
162
  _rollupPluginBabelHelpers.defineProperty(this, "onKeyDown", evt => {
136
163
  // Do nothing if component is disabled or we don't have a valid event
137
164
  if (this.props.disabled || this.props.readOnly || !('which' in evt)) {
@@ -167,6 +194,13 @@ class Slider extends React.PureComponent {
167
194
  isValid: true
168
195
  });
169
196
  });
197
+ /**
198
+ * Provides the two-way binding for the input field of the Slider. It also
199
+ * Handles a change to the input field by recalculating the value/thumb and
200
+ * setting state accordingly.
201
+ *
202
+ * @param {Event} evt The event.
203
+ */
170
204
  _rollupPluginBabelHelpers.defineProperty(this, "onChange", evt => {
171
205
  // Do nothing if component is disabled
172
206
  if (this.props.disabled || this.props.readOnly) {
@@ -198,6 +232,12 @@ class Slider extends React.PureComponent {
198
232
  });
199
233
  }
200
234
  });
235
+ /**
236
+ * Checks for validity of input value after clicking out of the input. It also
237
+ * Handles state change to isValid state.
238
+ *
239
+ * @param {Event} evt The event.
240
+ */
201
241
  _rollupPluginBabelHelpers.defineProperty(this, "onBlur", evt => {
202
242
  // Do nothing if we have no valid event, target, or value
203
243
  if (!evt || !('target' in evt) || typeof evt.target.value !== 'string') {
@@ -216,6 +256,25 @@ class Slider extends React.PureComponent {
216
256
  value
217
257
  });
218
258
  });
259
+ /**
260
+ * Calculates a new Slider `value` and `left` (thumb offset) given a `clientX`,
261
+ * `value`, or neither of those.
262
+ * - If `clientX` is specified, it will be used in
263
+ * conjunction with the Slider's bounding rectangle to calculate the new
264
+ * values.
265
+ * - If `clientX` is not specified and `value` is, it will be used to
266
+ * calculate new values as though it were the current value of the Slider.
267
+ * - If neither `clientX` nor `value` are specified, `this.props.value` will
268
+ * be used to calculate the new values as though it were the current value
269
+ * of the Slider.
270
+ *
271
+ * @param {object} params
272
+ * @param {number} [params.clientX] Optional clientX value expected to be from
273
+ * an event fired by one of the Slider's `DRAG_EVENT_TYPES` events.
274
+ * @param {number} [params.value] Optional value use during calculations if
275
+ * clientX is not provided.
276
+ * @param {boolean} [params.useRawValue=false] `true` to use the given value as-is.
277
+ */
219
278
  _rollupPluginBabelHelpers.defineProperty(this, "calcValue", _ref => {
220
279
  let {
221
280
  clientX,
@@ -340,74 +399,6 @@ class Slider extends React.PureComponent {
340
399
  clamp(val, min, max) {
341
400
  return Math.max(min, Math.min(val, max));
342
401
  }
343
-
344
- /**
345
- * Sets up "drag" event handlers and calls `this.onDrag` in case dragging
346
- * started on somewhere other than the thumb without a corresponding "move"
347
- * event.
348
- *
349
- * @param {Event} evt The event.
350
- */
351
-
352
- /**
353
- * Unregisters "drag" and "drag stop" event handlers and calls sets the flag
354
- * indicating that the `onRelease` callback should be called.
355
- */
356
-
357
- /**
358
- * Handles a "drag" event by recalculating the value/thumb and setting state
359
- * accordingly.
360
- *
361
- * @param {Event} evt The event.
362
- */
363
-
364
- /**
365
- * Throttles calls to `this._onDrag` by limiting events to being processed at
366
- * most once every `EVENT_THROTTLE` milliseconds.
367
- */
368
-
369
- /**
370
- * Handles a `keydown` event by recalculating the value/thumb and setting
371
- * state accordingly.
372
- *
373
- * @param {Event} evt The event.
374
- */
375
-
376
- /**
377
- * Provides the two-way binding for the input field of the Slider. It also
378
- * Handles a change to the input field by recalculating the value/thumb and
379
- * setting state accordingly.
380
- *
381
- * @param {Event} evt The event.
382
- */
383
-
384
- /**
385
- * Checks for validity of input value after clicking out of the input. It also
386
- * Handles state change to isValid state.
387
- *
388
- * @param {Event} evt The event.
389
- */
390
-
391
- /**
392
- * Calculates a new Slider `value` and `left` (thumb offset) given a `clientX`,
393
- * `value`, or neither of those.
394
- * - If `clientX` is specified, it will be used in
395
- * conjunction with the Slider's bounding rectangle to calculate the new
396
- * values.
397
- * - If `clientX` is not specified and `value` is, it will be used to
398
- * calculate new values as though it were the current value of the Slider.
399
- * - If neither `clientX` nor `value` are specified, `this.props.value` will
400
- * be used to calculate the new values as though it were the current value
401
- * of the Slider.
402
- *
403
- * @param {object} params
404
- * @param {number} [params.clientX] Optional clientX value expected to be from
405
- * an event fired by one of the Slider's `DRAG_EVENT_TYPES` events.
406
- * @param {number} [params.value] Optional value use during calculations if
407
- * clientX is not provided.
408
- * @param {boolean} [params.useRawValue=false] `true` to use the given value as-is.
409
- */
410
-
411
402
  // syncs invalid state and prop
412
403
  static getDerivedStateFromProps(props, state) {
413
404
  const {