@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.
- package/README.md +22 -7
- package/es/components/ComboBox/ComboBox.js +43 -10
- package/es/components/ContentSwitcher/ContentSwitcher.js +5 -5
- package/es/components/DataTable/DataTable.js +110 -130
- package/es/components/DataTable/Table.js +1 -1
- package/es/components/DatePicker/DatePicker.d.ts +14 -13
- package/es/components/DatePicker/DatePicker.js +3 -0
- package/es/components/DatePickerInput/DatePickerInput.d.ts +2 -2
- package/es/components/Dropdown/Dropdown.js +31 -6
- package/es/components/FileUploader/FileUploader.Skeleton.d.ts +29 -0
- package/es/components/FileUploader/FileUploader.d.ts +175 -0
- package/es/components/FileUploader/FileUploader.js +3 -3
- package/es/components/FileUploader/FileUploaderButton.d.ts +140 -0
- package/es/components/FileUploader/FileUploaderButton.js +11 -7
- package/es/components/FileUploader/FileUploaderDropContainer.d.ts +139 -0
- package/es/components/FileUploader/FileUploaderDropContainer.js +3 -3
- package/es/components/FileUploader/FileUploaderItem.d.ts +110 -0
- package/es/components/FileUploader/Filename.d.ts +71 -0
- package/es/components/FileUploader/Filename.js +6 -4
- package/es/components/InlineCheckbox/InlineCheckbox.js +3 -1
- package/es/components/Loading/Loading.d.ts +65 -0
- package/es/components/Notification/Notification.d.ts +4 -4
- package/es/components/Notification/Notification.js +3 -3
- package/es/components/OverflowMenu/OverflowMenu.js +36 -41
- package/es/components/Slider/Slider.js +59 -68
- package/es/components/Toggle/Toggle.d.ts +129 -0
- package/es/components/Toggle/Toggle.js +2 -2
- package/es/components/Toggle/index.d.ts +11 -0
- package/es/components/UIShell/HeaderMenu.js +29 -36
- package/es/components/UIShell/HeaderName.d.ts +39 -0
- package/es/components/UIShell/HeaderName.js +2 -7
- package/es/components/UIShell/HeaderPanel.js +1 -1
- package/es/components/UIShell/Link.js +2 -1
- package/es/index.js +1 -1
- package/es/internal/FloatingMenu.js +47 -51
- package/es/internal/useControllableState.js +1 -1
- package/es/internal/useId.js +10 -1
- package/lib/components/ComboBox/ComboBox.js +43 -10
- package/lib/components/ContentSwitcher/ContentSwitcher.js +5 -5
- package/lib/components/DataTable/DataTable.js +110 -130
- package/lib/components/DataTable/Table.js +1 -1
- package/lib/components/DatePicker/DatePicker.d.ts +14 -13
- package/lib/components/DatePicker/DatePicker.js +3 -0
- package/lib/components/DatePickerInput/DatePickerInput.d.ts +2 -2
- package/lib/components/Dropdown/Dropdown.js +30 -5
- package/lib/components/FileUploader/FileUploader.Skeleton.d.ts +29 -0
- package/lib/components/FileUploader/FileUploader.d.ts +175 -0
- package/lib/components/FileUploader/FileUploader.js +3 -3
- package/lib/components/FileUploader/FileUploaderButton.d.ts +140 -0
- package/lib/components/FileUploader/FileUploaderButton.js +11 -7
- package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +139 -0
- package/lib/components/FileUploader/FileUploaderDropContainer.js +3 -3
- package/lib/components/FileUploader/FileUploaderItem.d.ts +110 -0
- package/lib/components/FileUploader/Filename.d.ts +71 -0
- package/lib/components/FileUploader/Filename.js +6 -4
- package/lib/components/InlineCheckbox/InlineCheckbox.js +3 -1
- package/lib/components/Loading/Loading.d.ts +65 -0
- package/lib/components/Notification/Notification.d.ts +4 -4
- package/lib/components/Notification/Notification.js +3 -3
- package/lib/components/OverflowMenu/OverflowMenu.js +36 -41
- package/lib/components/Slider/Slider.js +59 -68
- package/lib/components/Toggle/Toggle.d.ts +129 -0
- package/lib/components/Toggle/Toggle.js +2 -2
- package/lib/components/Toggle/index.d.ts +11 -0
- package/lib/components/UIShell/HeaderMenu.js +29 -36
- package/lib/components/UIShell/HeaderName.d.ts +39 -0
- package/lib/components/UIShell/HeaderName.js +2 -7
- package/lib/components/UIShell/HeaderPanel.js +1 -1
- package/lib/components/UIShell/Link.js +2 -1
- package/lib/index.js +2 -2
- package/lib/internal/FloatingMenu.js +47 -51
- package/lib/internal/useControllableState.js +1 -1
- package/lib/internal/useId.js +9 -0
- 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;
|
|
@@ -19,7 +19,7 @@ function Filename(_ref) {
|
|
|
19
19
|
status,
|
|
20
20
|
invalid,
|
|
21
21
|
name,
|
|
22
|
-
['aria-
|
|
22
|
+
['aria-describedby']: ariaDescribedBy,
|
|
23
23
|
...rest
|
|
24
24
|
} = _ref;
|
|
25
25
|
const prefix = usePrefix();
|
|
@@ -35,10 +35,12 @@ function Filename(_ref) {
|
|
|
35
35
|
className: `${prefix}--file-invalid`
|
|
36
36
|
}), /*#__PURE__*/React__default.createElement("button", _extends({
|
|
37
37
|
"aria-label": `${iconDescription} - ${name}`,
|
|
38
|
-
"aria-describedby": invalid ? ariaDescribedBy : null,
|
|
39
38
|
className: `${prefix}--file-close`,
|
|
40
39
|
type: "button"
|
|
41
|
-
}, rest
|
|
40
|
+
}, rest, {
|
|
41
|
+
tabIndex: rest.tabIndex !== undefined ? parseInt(rest.tabIndex, 10) : undefined,
|
|
42
|
+
"aria-describedby": invalid ? ariaDescribedBy : undefined
|
|
43
|
+
}), _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null))));
|
|
42
44
|
case 'complete':
|
|
43
45
|
return /*#__PURE__*/React__default.createElement(CheckmarkFilled, _extends({
|
|
44
46
|
"aria-label": iconDescription,
|
|
@@ -74,7 +76,7 @@ Filename.propTypes = {
|
|
|
74
76
|
/**
|
|
75
77
|
* Provide a custom tabIndex value for the `<Filename>`
|
|
76
78
|
*/
|
|
77
|
-
tabIndex: PropTypes.string
|
|
79
|
+
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
78
80
|
};
|
|
79
81
|
Filename.defaultProps = {
|
|
80
82
|
iconDescription: 'Uploading file',
|
|
@@ -47,7 +47,9 @@ const InlineCheckbox = /*#__PURE__*/React__default.forwardRef(function InlineChe
|
|
|
47
47
|
inputProps.checked = false;
|
|
48
48
|
}
|
|
49
49
|
useEffect(() => {
|
|
50
|
-
inputRef
|
|
50
|
+
if (inputRef?.current) {
|
|
51
|
+
inputRef.current.indeterminate = indeterminate;
|
|
52
|
+
}
|
|
51
53
|
}, [indeterminate]);
|
|
52
54
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
53
55
|
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
|
|
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?:
|
|
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.
|
|
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<
|
|
516
|
+
subtitle: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
517
517
|
/**
|
|
518
518
|
* Specify the title
|
|
519
519
|
*/
|
|
@@ -556,7 +556,7 @@ function ActionableNotification(_ref6) {
|
|
|
556
556
|
id: id
|
|
557
557
|
}, title), subtitle && /*#__PURE__*/React__default.createElement("div", {
|
|
558
558
|
className: `${prefix}--actionable-notification__subtitle`
|
|
559
|
-
}, subtitle), children))), /*#__PURE__*/React__default.createElement(NotificationActionButton, {
|
|
559
|
+
}, subtitle), children))), actionButtonLabel && /*#__PURE__*/React__default.createElement(NotificationActionButton, {
|
|
560
560
|
onClick: onActionButtonClick,
|
|
561
561
|
inline: inline
|
|
562
562
|
}, actionButtonLabel), !hideCloseButton && /*#__PURE__*/React__default.createElement(NotificationButton, {
|
|
@@ -569,7 +569,7 @@ ActionableNotification.propTypes = {
|
|
|
569
569
|
/**
|
|
570
570
|
* Pass in the action button label that will be rendered within the ActionableNotification.
|
|
571
571
|
*/
|
|
572
|
-
actionButtonLabel: PropTypes.string
|
|
572
|
+
actionButtonLabel: PropTypes.string,
|
|
573
573
|
/**
|
|
574
574
|
* Provide a description for "close" icon button that can be read by screen readers
|
|
575
575
|
*/
|
|
@@ -635,7 +635,7 @@ ActionableNotification.propTypes = {
|
|
|
635
635
|
/**
|
|
636
636
|
* Specify the subtitle
|
|
637
637
|
*/
|
|
638
|
-
subtitle: PropTypes.
|
|
638
|
+
subtitle: PropTypes.node,
|
|
639
639
|
/**
|
|
640
640
|
* Specify the title
|
|
641
641
|
*/
|
|
@@ -97,8 +97,21 @@ class OverflowMenu extends Component {
|
|
|
97
97
|
super(...arguments);
|
|
98
98
|
_defineProperty(this, "state", {});
|
|
99
99
|
_defineProperty(this, "instanceId", getInstanceId());
|
|
100
|
+
/**
|
|
101
|
+
* The handle of `onfocusin` or `focus` event handler.
|
|
102
|
+
* @private
|
|
103
|
+
*/
|
|
100
104
|
_defineProperty(this, "_hFocusIn", null);
|
|
105
|
+
/**
|
|
106
|
+
* The timeout handle for handling `blur` event.
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
101
109
|
_defineProperty(this, "_hBlurTimeout", void 0);
|
|
110
|
+
/**
|
|
111
|
+
* The element ref of the tooltip's trigger button.
|
|
112
|
+
* @type {React.RefObject<Element>}
|
|
113
|
+
* @private
|
|
114
|
+
*/
|
|
102
115
|
_defineProperty(this, "_triggerRef", /*#__PURE__*/React__default.createRef());
|
|
103
116
|
_defineProperty(this, "handleClick", evt => {
|
|
104
117
|
evt.stopPropagation();
|
|
@@ -154,6 +167,15 @@ class OverflowMenu extends Component {
|
|
|
154
167
|
triggerEl.focus();
|
|
155
168
|
}
|
|
156
169
|
});
|
|
170
|
+
/**
|
|
171
|
+
* Focuses the next enabled overflow menu item given the currently focused
|
|
172
|
+
* item index and direction to move
|
|
173
|
+
* @param {object} params
|
|
174
|
+
* @param {number} params.currentIndex - the index of the currently focused
|
|
175
|
+
* overflow menu item in the list of overflow menu items
|
|
176
|
+
* @param {number} params.direction - number denoting the direction to move
|
|
177
|
+
* focus (1 for forwards, -1 for backwards)
|
|
178
|
+
*/
|
|
157
179
|
_defineProperty(this, "handleOverflowMenuItemFocus", _ref => {
|
|
158
180
|
let {
|
|
159
181
|
currentIndex,
|
|
@@ -179,6 +201,12 @@ class OverflowMenu extends Component {
|
|
|
179
201
|
const overflowMenuItem = this[`overflowMenuItem${enabledIndices[nextValidIndex]}`];
|
|
180
202
|
overflowMenuItem?.focus();
|
|
181
203
|
});
|
|
204
|
+
/**
|
|
205
|
+
* Handles the floating menu being unmounted or non-floating menu being
|
|
206
|
+
* mounted or unmounted.
|
|
207
|
+
* @param {Element} menuBody The DOM element of the menu body.
|
|
208
|
+
* @private
|
|
209
|
+
*/
|
|
182
210
|
_defineProperty(this, "_bindMenuBody", menuBody => {
|
|
183
211
|
if (!menuBody) {
|
|
184
212
|
this._menuBody = menuBody;
|
|
@@ -187,6 +215,11 @@ class OverflowMenu extends Component {
|
|
|
187
215
|
this._hFocusIn = this._hFocusIn.release();
|
|
188
216
|
}
|
|
189
217
|
});
|
|
218
|
+
/**
|
|
219
|
+
* Handles the floating menu being placed.
|
|
220
|
+
* @param {Element} menuBody The DOM element of the menu body.
|
|
221
|
+
* @private
|
|
222
|
+
*/
|
|
190
223
|
_defineProperty(this, "_handlePlace", menuBody => {
|
|
191
224
|
if (menuBody) {
|
|
192
225
|
this._menuBody = menuBody;
|
|
@@ -206,6 +239,9 @@ class OverflowMenu extends Component {
|
|
|
206
239
|
this.props.onOpen();
|
|
207
240
|
}
|
|
208
241
|
});
|
|
242
|
+
/**
|
|
243
|
+
* @returns {Element} The DOM element where the floating menu is placed in.
|
|
244
|
+
*/
|
|
209
245
|
_defineProperty(this, "_getTarget", () => {
|
|
210
246
|
const {
|
|
211
247
|
current: triggerEl
|
|
@@ -213,19 +249,6 @@ class OverflowMenu extends Component {
|
|
|
213
249
|
return triggerEl && triggerEl.closest('[data-floating-menu-container]') || document.body;
|
|
214
250
|
});
|
|
215
251
|
}
|
|
216
|
-
/**
|
|
217
|
-
* The handle of `onfocusin` or `focus` event handler.
|
|
218
|
-
* @private
|
|
219
|
-
*/
|
|
220
|
-
/**
|
|
221
|
-
* The timeout handle for handling `blur` event.
|
|
222
|
-
* @private
|
|
223
|
-
*/
|
|
224
|
-
/**
|
|
225
|
-
* The element ref of the tooltip's trigger button.
|
|
226
|
-
* @type {React.RefObject<Element>}
|
|
227
|
-
* @private
|
|
228
|
-
*/
|
|
229
252
|
componentDidUpdate(_, prevState) {
|
|
230
253
|
const {
|
|
231
254
|
onClose
|
|
@@ -261,34 +284,6 @@ class OverflowMenu extends Component {
|
|
|
261
284
|
this._hBlurTimeout = undefined;
|
|
262
285
|
}
|
|
263
286
|
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Focuses the next enabled overflow menu item given the currently focused
|
|
267
|
-
* item index and direction to move
|
|
268
|
-
* @param {object} params
|
|
269
|
-
* @param {number} params.currentIndex - the index of the currently focused
|
|
270
|
-
* overflow menu item in the list of overflow menu items
|
|
271
|
-
* @param {number} params.direction - number denoting the direction to move
|
|
272
|
-
* focus (1 for forwards, -1 for backwards)
|
|
273
|
-
*/
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Handles the floating menu being unmounted or non-floating menu being
|
|
277
|
-
* mounted or unmounted.
|
|
278
|
-
* @param {Element} menuBody The DOM element of the menu body.
|
|
279
|
-
* @private
|
|
280
|
-
*/
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Handles the floating menu being placed.
|
|
284
|
-
* @param {Element} menuBody The DOM element of the menu body.
|
|
285
|
-
* @private
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @returns {Element} The DOM element where the floating menu is placed in.
|
|
290
|
-
*/
|
|
291
|
-
|
|
292
287
|
render() {
|
|
293
288
|
const prefix = this.context;
|
|
294
289
|
const {
|
|
@@ -49,6 +49,13 @@ class Slider extends PureComponent {
|
|
|
49
49
|
_defineProperty(this, "element", null);
|
|
50
50
|
_defineProperty(this, "inputId", '');
|
|
51
51
|
_defineProperty(this, "track", void 0);
|
|
52
|
+
/**
|
|
53
|
+
* Sets up "drag" event handlers and calls `this.onDrag` in case dragging
|
|
54
|
+
* started on somewhere other than the thumb without a corresponding "move"
|
|
55
|
+
* event.
|
|
56
|
+
*
|
|
57
|
+
* @param {Event} evt The event.
|
|
58
|
+
*/
|
|
52
59
|
_defineProperty(this, "onDragStart", evt => {
|
|
53
60
|
// Do nothing if component is disabled
|
|
54
61
|
if (this.props.disabled || this.props.readOnly) {
|
|
@@ -69,6 +76,10 @@ class Slider extends PureComponent {
|
|
|
69
76
|
// middle of the thumb
|
|
70
77
|
this.onDrag(evt);
|
|
71
78
|
});
|
|
79
|
+
/**
|
|
80
|
+
* Unregisters "drag" and "drag stop" event handlers and calls sets the flag
|
|
81
|
+
* indicating that the `onRelease` callback should be called.
|
|
82
|
+
*/
|
|
72
83
|
_defineProperty(this, "onDragStop", () => {
|
|
73
84
|
// Do nothing if component is disabled
|
|
74
85
|
if (this.props.disabled || this.props.readOnly) {
|
|
@@ -91,6 +102,12 @@ class Slider extends PureComponent {
|
|
|
91
102
|
isValid: true
|
|
92
103
|
});
|
|
93
104
|
});
|
|
105
|
+
/**
|
|
106
|
+
* Handles a "drag" event by recalculating the value/thumb and setting state
|
|
107
|
+
* accordingly.
|
|
108
|
+
*
|
|
109
|
+
* @param {Event} evt The event.
|
|
110
|
+
*/
|
|
94
111
|
_defineProperty(this, "_onDrag", evt => {
|
|
95
112
|
// Do nothing if component is disabled or we have no event
|
|
96
113
|
if (this.props.disabled || this.props.readOnly || !evt) {
|
|
@@ -117,10 +134,20 @@ class Slider extends PureComponent {
|
|
|
117
134
|
isValid: true
|
|
118
135
|
});
|
|
119
136
|
});
|
|
137
|
+
/**
|
|
138
|
+
* Throttles calls to `this._onDrag` by limiting events to being processed at
|
|
139
|
+
* most once every `EVENT_THROTTLE` milliseconds.
|
|
140
|
+
*/
|
|
120
141
|
_defineProperty(this, "onDrag", throttle(this._onDrag, EVENT_THROTTLE, {
|
|
121
142
|
leading: true,
|
|
122
143
|
trailing: false
|
|
123
144
|
}));
|
|
145
|
+
/**
|
|
146
|
+
* Handles a `keydown` event by recalculating the value/thumb and setting
|
|
147
|
+
* state accordingly.
|
|
148
|
+
*
|
|
149
|
+
* @param {Event} evt The event.
|
|
150
|
+
*/
|
|
124
151
|
_defineProperty(this, "onKeyDown", evt => {
|
|
125
152
|
// Do nothing if component is disabled or we don't have a valid event
|
|
126
153
|
if (this.props.disabled || this.props.readOnly || !('which' in evt)) {
|
|
@@ -156,6 +183,13 @@ class Slider extends PureComponent {
|
|
|
156
183
|
isValid: true
|
|
157
184
|
});
|
|
158
185
|
});
|
|
186
|
+
/**
|
|
187
|
+
* Provides the two-way binding for the input field of the Slider. It also
|
|
188
|
+
* Handles a change to the input field by recalculating the value/thumb and
|
|
189
|
+
* setting state accordingly.
|
|
190
|
+
*
|
|
191
|
+
* @param {Event} evt The event.
|
|
192
|
+
*/
|
|
159
193
|
_defineProperty(this, "onChange", evt => {
|
|
160
194
|
// Do nothing if component is disabled
|
|
161
195
|
if (this.props.disabled || this.props.readOnly) {
|
|
@@ -187,6 +221,12 @@ class Slider extends PureComponent {
|
|
|
187
221
|
});
|
|
188
222
|
}
|
|
189
223
|
});
|
|
224
|
+
/**
|
|
225
|
+
* Checks for validity of input value after clicking out of the input. It also
|
|
226
|
+
* Handles state change to isValid state.
|
|
227
|
+
*
|
|
228
|
+
* @param {Event} evt The event.
|
|
229
|
+
*/
|
|
190
230
|
_defineProperty(this, "onBlur", evt => {
|
|
191
231
|
// Do nothing if we have no valid event, target, or value
|
|
192
232
|
if (!evt || !('target' in evt) || typeof evt.target.value !== 'string') {
|
|
@@ -205,6 +245,25 @@ class Slider extends PureComponent {
|
|
|
205
245
|
value
|
|
206
246
|
});
|
|
207
247
|
});
|
|
248
|
+
/**
|
|
249
|
+
* Calculates a new Slider `value` and `left` (thumb offset) given a `clientX`,
|
|
250
|
+
* `value`, or neither of those.
|
|
251
|
+
* - If `clientX` is specified, it will be used in
|
|
252
|
+
* conjunction with the Slider's bounding rectangle to calculate the new
|
|
253
|
+
* values.
|
|
254
|
+
* - If `clientX` is not specified and `value` is, it will be used to
|
|
255
|
+
* calculate new values as though it were the current value of the Slider.
|
|
256
|
+
* - If neither `clientX` nor `value` are specified, `this.props.value` will
|
|
257
|
+
* be used to calculate the new values as though it were the current value
|
|
258
|
+
* of the Slider.
|
|
259
|
+
*
|
|
260
|
+
* @param {object} params
|
|
261
|
+
* @param {number} [params.clientX] Optional clientX value expected to be from
|
|
262
|
+
* an event fired by one of the Slider's `DRAG_EVENT_TYPES` events.
|
|
263
|
+
* @param {number} [params.value] Optional value use during calculations if
|
|
264
|
+
* clientX is not provided.
|
|
265
|
+
* @param {boolean} [params.useRawValue=false] `true` to use the given value as-is.
|
|
266
|
+
*/
|
|
208
267
|
_defineProperty(this, "calcValue", _ref => {
|
|
209
268
|
let {
|
|
210
269
|
clientX,
|
|
@@ -329,74 +388,6 @@ class Slider extends PureComponent {
|
|
|
329
388
|
clamp(val, min, max) {
|
|
330
389
|
return Math.max(min, Math.min(val, max));
|
|
331
390
|
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Sets up "drag" event handlers and calls `this.onDrag` in case dragging
|
|
335
|
-
* started on somewhere other than the thumb without a corresponding "move"
|
|
336
|
-
* event.
|
|
337
|
-
*
|
|
338
|
-
* @param {Event} evt The event.
|
|
339
|
-
*/
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Unregisters "drag" and "drag stop" event handlers and calls sets the flag
|
|
343
|
-
* indicating that the `onRelease` callback should be called.
|
|
344
|
-
*/
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Handles a "drag" event by recalculating the value/thumb and setting state
|
|
348
|
-
* accordingly.
|
|
349
|
-
*
|
|
350
|
-
* @param {Event} evt The event.
|
|
351
|
-
*/
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Throttles calls to `this._onDrag` by limiting events to being processed at
|
|
355
|
-
* most once every `EVENT_THROTTLE` milliseconds.
|
|
356
|
-
*/
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Handles a `keydown` event by recalculating the value/thumb and setting
|
|
360
|
-
* state accordingly.
|
|
361
|
-
*
|
|
362
|
-
* @param {Event} evt The event.
|
|
363
|
-
*/
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Provides the two-way binding for the input field of the Slider. It also
|
|
367
|
-
* Handles a change to the input field by recalculating the value/thumb and
|
|
368
|
-
* setting state accordingly.
|
|
369
|
-
*
|
|
370
|
-
* @param {Event} evt The event.
|
|
371
|
-
*/
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Checks for validity of input value after clicking out of the input. It also
|
|
375
|
-
* Handles state change to isValid state.
|
|
376
|
-
*
|
|
377
|
-
* @param {Event} evt The event.
|
|
378
|
-
*/
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Calculates a new Slider `value` and `left` (thumb offset) given a `clientX`,
|
|
382
|
-
* `value`, or neither of those.
|
|
383
|
-
* - If `clientX` is specified, it will be used in
|
|
384
|
-
* conjunction with the Slider's bounding rectangle to calculate the new
|
|
385
|
-
* values.
|
|
386
|
-
* - If `clientX` is not specified and `value` is, it will be used to
|
|
387
|
-
* calculate new values as though it were the current value of the Slider.
|
|
388
|
-
* - If neither `clientX` nor `value` are specified, `this.props.value` will
|
|
389
|
-
* be used to calculate the new values as though it were the current value
|
|
390
|
-
* of the Slider.
|
|
391
|
-
*
|
|
392
|
-
* @param {object} params
|
|
393
|
-
* @param {number} [params.clientX] Optional clientX value expected to be from
|
|
394
|
-
* an event fired by one of the Slider's `DRAG_EVENT_TYPES` events.
|
|
395
|
-
* @param {number} [params.value] Optional value use during calculations if
|
|
396
|
-
* clientX is not provided.
|
|
397
|
-
* @param {boolean} [params.useRawValue=false] `true` to use the given value as-is.
|
|
398
|
-
*/
|
|
399
|
-
|
|
400
391
|
// syncs invalid state and prop
|
|
401
392
|
static getDerivedStateFromProps(props, state) {
|
|
402
393
|
const {
|