@carbon/react 1.51.0 → 1.52.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +776 -729
- package/es/components/ChatButton/ChatButton.js +9 -1
- package/es/components/ComposedModal/ComposedModal.js +5 -4
- package/es/components/DataTable/TableActionList.d.ts +8 -0
- package/es/components/DataTable/TableActionList.js +1 -2
- package/es/components/DataTable/TableHead.d.ts +2 -2
- package/es/components/DataTable/TableToolbarContent.d.ts +1 -12
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Link/Link.d.ts +5 -10
- package/es/components/Link/Link.js +1 -2
- package/es/components/Menu/Menu.d.ts +6 -6
- package/es/components/Menu/Menu.js +7 -3
- package/es/components/Menu/MenuContext.d.ts +14 -6
- package/es/components/Menu/MenuContext.js +3 -3
- package/es/components/Menu/MenuItem.d.ts +22 -31
- package/es/components/Menu/MenuItem.js +25 -13
- package/es/components/MenuButton/index.d.ts +43 -0
- package/es/components/MenuButton/index.js +15 -10
- package/es/components/Modal/Modal.js +2 -1
- package/es/components/Notification/Notification.d.ts +17 -1
- package/es/components/Notification/Notification.js +24 -9
- package/es/components/Toggletip/index.d.ts +1 -1
- package/es/components/Toggletip/index.js +4 -3
- package/es/components/TreeView/TreeNode.js +46 -24
- package/es/components/TreeView/TreeView.js +40 -13
- package/es/components/UIShell/Header.d.ts +24 -0
- package/es/components/UIShell/Header.js +1 -2
- package/es/components/UIShell/HeaderGlobalAction.d.ts +50 -0
- package/es/components/UIShell/HeaderGlobalAction.js +1 -2
- package/es/components/UIShell/HeaderGlobalBar.d.ts +11 -0
- package/es/components/UIShell/HeaderGlobalBar.js +2 -1
- package/es/components/UIShell/SideNavLink.d.ts +57 -0
- package/es/components/UIShell/SideNavLink.js +4 -4
- package/es/internal/useAttachedMenu.d.ts +45 -0
- package/es/internal/useAttachedMenu.js +1 -7
- package/es/tools/wrapComponent.d.ts +20 -0
- package/es/tools/wrapComponent.js +3 -4
- package/lib/components/ChatButton/ChatButton.js +9 -1
- package/lib/components/ComposedModal/ComposedModal.js +5 -4
- package/lib/components/DataTable/TableActionList.d.ts +8 -0
- package/lib/components/DataTable/TableActionList.js +1 -2
- package/lib/components/DataTable/TableHead.d.ts +2 -2
- package/lib/components/DataTable/TableToolbarContent.d.ts +1 -12
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Link/Link.d.ts +5 -10
- package/lib/components/Link/Link.js +1 -2
- package/lib/components/Menu/Menu.d.ts +6 -6
- package/lib/components/Menu/Menu.js +6 -2
- package/lib/components/Menu/MenuContext.d.ts +14 -6
- package/lib/components/Menu/MenuContext.js +2 -6
- package/lib/components/Menu/MenuItem.d.ts +22 -31
- package/lib/components/Menu/MenuItem.js +24 -12
- package/lib/components/MenuButton/index.d.ts +43 -0
- package/lib/components/MenuButton/index.js +14 -9
- package/lib/components/Modal/Modal.js +2 -1
- package/lib/components/Notification/Notification.d.ts +17 -1
- package/lib/components/Notification/Notification.js +24 -9
- package/lib/components/Toggletip/index.d.ts +1 -1
- package/lib/components/Toggletip/index.js +4 -3
- package/lib/components/TreeView/TreeNode.js +46 -24
- package/lib/components/TreeView/TreeView.js +40 -13
- package/lib/components/UIShell/Header.d.ts +24 -0
- package/lib/components/UIShell/Header.js +1 -2
- package/lib/components/UIShell/HeaderGlobalAction.d.ts +50 -0
- package/lib/components/UIShell/HeaderGlobalAction.js +1 -2
- package/lib/components/UIShell/HeaderGlobalBar.d.ts +11 -0
- package/lib/components/UIShell/HeaderGlobalBar.js +2 -1
- package/lib/components/UIShell/SideNavLink.d.ts +57 -0
- package/lib/components/UIShell/SideNavLink.js +3 -3
- package/lib/internal/useAttachedMenu.d.ts +45 -0
- package/lib/internal/useAttachedMenu.js +1 -7
- package/lib/tools/wrapComponent.d.ts +20 -0
- package/lib/tools/wrapComponent.js +5 -6
- package/package.json +8 -8
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
import { ComponentType, ElementType, ForwardedRef, ReactNode, WeakValidationMap } from 'react';
|
|
8
|
+
import { LinkProps } from './Link';
|
|
9
|
+
export type SideNavLinkProps<E extends ElementType> = LinkProps<E> & {
|
|
10
|
+
/**
|
|
11
|
+
* Required props for the accessibility label
|
|
12
|
+
*/
|
|
13
|
+
'aria-label'?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Required props for the accessibility label
|
|
16
|
+
*/
|
|
17
|
+
'aria-labelledby'?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Specify the text content for the link
|
|
20
|
+
*/
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Provide an optional class to be applied to the containing node
|
|
24
|
+
*/
|
|
25
|
+
className?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Specify whether the link is the current page
|
|
28
|
+
*/
|
|
29
|
+
isActive?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Property to indicate if the side nav container is open (or not). Use to
|
|
32
|
+
* keep local state and styling in step with the SideNav expansion state.
|
|
33
|
+
*/
|
|
34
|
+
isSideNavExpanded?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Specify if this is a large variation of the SideNavLink
|
|
37
|
+
*/
|
|
38
|
+
large?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Provide an icon to render in the side navigation link. Should be a React class.
|
|
41
|
+
*/
|
|
42
|
+
renderIcon?: ComponentType;
|
|
43
|
+
/**
|
|
44
|
+
* Optional prop to specify the tabIndex of the button. If undefined, it will be applied default validation
|
|
45
|
+
*/
|
|
46
|
+
tabIndex?: number;
|
|
47
|
+
};
|
|
48
|
+
export interface SideNavLinkComponent {
|
|
49
|
+
<E extends ElementType = 'a'>(props: SideNavLinkProps<E> & {
|
|
50
|
+
ref?: ForwardedRef<ElementType>;
|
|
51
|
+
}): JSX.Element | null;
|
|
52
|
+
displayName?: string;
|
|
53
|
+
propTypes?: WeakValidationMap<SideNavLinkProps<any>>;
|
|
54
|
+
}
|
|
55
|
+
declare const SideNavLink: SideNavLinkComponent;
|
|
56
|
+
export declare const createCustomSideNavLink: (element: any) => (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
export default SideNavLink;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import React__default, { useContext } from 'react';
|
|
11
|
+
import React__default, { forwardRef, useContext } from 'react';
|
|
12
12
|
import Link, { LinkPropTypes } from './Link.js';
|
|
13
13
|
import SideNavIcon from './SideNavIcon.js';
|
|
14
14
|
import SideNavItem from './SideNavItem.js';
|
|
@@ -16,7 +16,7 @@ import SideNavLinkText from './SideNavLinkText.js';
|
|
|
16
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
17
|
import { SideNavContext } from './SideNav.js';
|
|
18
18
|
|
|
19
|
-
const SideNavLink = /*#__PURE__*/
|
|
19
|
+
const SideNavLink = /*#__PURE__*/forwardRef(function SideNavLink(_ref, ref) {
|
|
20
20
|
let {
|
|
21
21
|
children,
|
|
22
22
|
className: customClassName,
|
|
@@ -71,12 +71,12 @@ SideNavLink.propTypes = {
|
|
|
71
71
|
/**
|
|
72
72
|
* Provide an icon to render in the side navigation link. Should be a React class.
|
|
73
73
|
*/
|
|
74
|
+
// @ts-expect-error - PropTypes are unable to cover this case.
|
|
74
75
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
75
76
|
/**
|
|
76
77
|
* Optional prop to specify the tabIndex of the button. If undefined, it will be applied default validation
|
|
77
78
|
*/
|
|
78
79
|
tabIndex: PropTypes.number
|
|
79
80
|
};
|
|
80
|
-
var SideNavLink$1 = SideNavLink;
|
|
81
81
|
|
|
82
|
-
export { SideNavLink
|
|
82
|
+
export { SideNavLink as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 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
|
+
import { MouseEventHandler } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* Array of two numbers either representing [left, right] or [top, bottom].
|
|
10
|
+
*/
|
|
11
|
+
type TwoCoordinates = [number, number];
|
|
12
|
+
export interface UseAttachedMenuReturn {
|
|
13
|
+
/**
|
|
14
|
+
* Whether the menu is open or not.
|
|
15
|
+
*/
|
|
16
|
+
open: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The x position of the menu.
|
|
19
|
+
*/
|
|
20
|
+
x: TwoCoordinates;
|
|
21
|
+
/**
|
|
22
|
+
* The y position of the menu.
|
|
23
|
+
*/
|
|
24
|
+
y: TwoCoordinates;
|
|
25
|
+
/**
|
|
26
|
+
* A function to be called when the trigger element receives a click event.
|
|
27
|
+
*/
|
|
28
|
+
handleClick: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* A function to be called when the trigger element receives a mousedown event.
|
|
31
|
+
*/
|
|
32
|
+
handleMousedown: MouseEventHandler;
|
|
33
|
+
/**
|
|
34
|
+
* A function to be called when the menu emits onClose.
|
|
35
|
+
*/
|
|
36
|
+
handleClose: () => void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* This hook contains common code to be used when a menu should be visually attached to an anchor based on a click event.
|
|
40
|
+
*
|
|
41
|
+
* @param {Element|object} anchor The element or ref the menu should visually be attached to.
|
|
42
|
+
* @returns {useAttachedMenuReturn}
|
|
43
|
+
*/
|
|
44
|
+
export declare function useAttachedMenu(anchor: any): UseAttachedMenuReturn;
|
|
45
|
+
export {};
|
|
@@ -8,13 +8,7 @@
|
|
|
8
8
|
import { useState } from 'react';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @property {boolean} open Whether the menu is open or not
|
|
13
|
-
* @property {[number, number]} x The x position of the menu
|
|
14
|
-
* @property {[number, number]} y The y position of the menu
|
|
15
|
-
* @property {Function} handleClick A function to be called when the trigger element receives a click event
|
|
16
|
-
* @property {Function} handleMousedown A function to be called when the trigger element recives a mousedown event
|
|
17
|
-
* @property {Function} handleClose A function to be called when the menu emits onClose
|
|
11
|
+
* Array of two numbers either representing [left, right] or [top, bottom].
|
|
18
12
|
*/
|
|
19
13
|
|
|
20
14
|
/**
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import { ReactAttr } from '../types/common';
|
|
9
|
+
type HTMLTagName = keyof HTMLElementTagNameMap;
|
|
10
|
+
type WrapComponentArgs<T extends HTMLTagName> = {
|
|
11
|
+
name: string;
|
|
12
|
+
type: T;
|
|
13
|
+
className?: string | ((prefix: string) => string);
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* @param {{ name: string, type: string, className?: string | (prefix: string) => string }} props
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
declare const wrapComponent: <T extends keyof HTMLElementTagNameMap>({ name, className: getClassName, type, }: WrapComponentArgs<T>) => (props: ReactAttr<T>) => React.ReactElement;
|
|
20
|
+
export default wrapComponent;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React__default from 'react';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
8
|
import cx from 'classnames';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import React__default from 'react';
|
|
11
11
|
import { usePrefix } from '../internal/usePrefix.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -46,6 +46,5 @@ const wrapComponent = _ref => {
|
|
|
46
46
|
};
|
|
47
47
|
return Component;
|
|
48
48
|
};
|
|
49
|
-
var wrapComponent$1 = wrapComponent;
|
|
50
49
|
|
|
51
|
-
export { wrapComponent
|
|
50
|
+
export { wrapComponent as default };
|
|
@@ -31,12 +31,14 @@ const ChatButton = /*#__PURE__*/React__default["default"].forwardRef(function Ch
|
|
|
31
31
|
isQuickAction,
|
|
32
32
|
isSelected,
|
|
33
33
|
kind,
|
|
34
|
+
renderIcon,
|
|
34
35
|
size,
|
|
35
36
|
...other
|
|
36
37
|
} = _ref;
|
|
37
38
|
const prefix = usePrefix.usePrefix();
|
|
38
39
|
const classNames = cx__default["default"](className, {
|
|
39
40
|
[`${prefix}--chat-btn`]: true,
|
|
41
|
+
[`${prefix}--chat-btn--with-icon`]: renderIcon,
|
|
40
42
|
[`${prefix}--chat-btn--quick-action`]: isQuickAction,
|
|
41
43
|
[`${prefix}--chat-btn--quick-action--selected`]: isSelected
|
|
42
44
|
});
|
|
@@ -53,7 +55,8 @@ const ChatButton = /*#__PURE__*/React__default["default"].forwardRef(function Ch
|
|
|
53
55
|
className: classNames,
|
|
54
56
|
kind: kind,
|
|
55
57
|
ref: ref,
|
|
56
|
-
size: size
|
|
58
|
+
size: size,
|
|
59
|
+
renderIcon: renderIcon
|
|
57
60
|
}, other), children);
|
|
58
61
|
});
|
|
59
62
|
ChatButton.propTypes = {
|
|
@@ -81,6 +84,11 @@ ChatButton.propTypes = {
|
|
|
81
84
|
* Specify the kind of `ChatButton` you want to create
|
|
82
85
|
*/
|
|
83
86
|
kind: PropTypes__default["default"].oneOf(['primary', 'secondary', 'danger', 'ghost', 'tertiary']),
|
|
87
|
+
/**
|
|
88
|
+
* Optional prop to specify an icon to be rendered.
|
|
89
|
+
* Can be a React component class
|
|
90
|
+
*/
|
|
91
|
+
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
84
92
|
/**
|
|
85
93
|
* Specify the size of the `ChatButton`, from the following list of sizes:
|
|
86
94
|
*/
|
|
@@ -47,9 +47,8 @@ const ModalBody = /*#__PURE__*/React__default["default"].forwardRef(function Mod
|
|
|
47
47
|
const contentClass = cx__default["default"]({
|
|
48
48
|
[`${prefix}--modal-content`]: true,
|
|
49
49
|
[`${prefix}--modal-content--with-form`]: hasForm,
|
|
50
|
-
[`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable
|
|
51
|
-
|
|
52
|
-
});
|
|
50
|
+
[`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable
|
|
51
|
+
}, customClassName);
|
|
53
52
|
useIsomorphicEffect["default"](() => {
|
|
54
53
|
if (contentRef.current) {
|
|
55
54
|
setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
|
|
@@ -127,7 +126,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
127
126
|
const startSentinel = React.useRef(null);
|
|
128
127
|
const endSentinel = React.useRef(null);
|
|
129
128
|
|
|
130
|
-
//
|
|
129
|
+
// Keep track of modal open/close state
|
|
131
130
|
// and propagate it to the document.body
|
|
132
131
|
React.useEffect(() => {
|
|
133
132
|
if (open !== wasOpen) {
|
|
@@ -144,12 +143,14 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
144
143
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
145
144
|
|
|
146
145
|
function handleKeyDown(evt) {
|
|
146
|
+
evt.stopPropagation();
|
|
147
147
|
if (match.match(evt, keys.Escape)) {
|
|
148
148
|
closeModal(evt);
|
|
149
149
|
}
|
|
150
150
|
onKeyDown?.(evt);
|
|
151
151
|
}
|
|
152
152
|
function handleMousedown(evt) {
|
|
153
|
+
evt.stopPropagation();
|
|
153
154
|
const isInside = innerModal.current?.contains(evt.target);
|
|
154
155
|
if (!isInside && !preventCloseOnClickOutside) {
|
|
155
156
|
closeModal(evt);
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
declare const TableActionList: (props: import("../../types/common").ReactAttr<"div">) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
8
|
+
export default TableActionList;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import { ThHTMLAttributes } from 'react';
|
|
8
8
|
export type TableHeadProps = ThHTMLAttributes<HTMLTableSectionElement>;
|
|
9
|
-
declare const TableHead:
|
|
9
|
+
declare const TableHead: (props: import("../../types/common").ReactAttr<"thead">) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
10
10
|
export default TableHead;
|
|
@@ -4,16 +4,5 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
declare const TableToolbarContent:
|
|
8
|
-
({ className: baseClassName, ...other }: {
|
|
9
|
-
[x: string]: any;
|
|
10
|
-
className?: string | undefined;
|
|
11
|
-
}): import("react").ReactElement<{
|
|
12
|
-
className: string | undefined;
|
|
13
|
-
}, string | import("react").JSXElementConstructor<any>>;
|
|
14
|
-
displayName: string;
|
|
15
|
-
propTypes: {
|
|
16
|
-
className: import("prop-types").Requireable<string>;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
7
|
+
declare const TableToolbarContent: (props: import("../../types/common").ReactAttr<"div">) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
19
8
|
export default TableToolbarContent;
|
|
@@ -102,7 +102,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
102
102
|
* An optional callback to render the currently selected item as a react element instead of only
|
|
103
103
|
* as a string.
|
|
104
104
|
*/
|
|
105
|
-
renderSelectedItem?(item: ItemType):
|
|
105
|
+
renderSelectedItem?(item: ItemType): ReactNode;
|
|
106
106
|
/**
|
|
107
107
|
* In the case you want to control the dropdown selection entirely.
|
|
108
108
|
*/
|
|
@@ -4,13 +4,9 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { AnchorHTMLAttributes, AriaAttributes, ComponentType, HTMLAttributeAnchorTarget } from 'react';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Provide a custom element or component to render the top-level node for the
|
|
11
|
-
* component.
|
|
12
|
-
*/
|
|
13
|
-
as?: string | undefined;
|
|
7
|
+
import React, { AnchorHTMLAttributes, AriaAttributes, ComponentType, ElementType, HTMLAttributeAnchorTarget } from 'react';
|
|
8
|
+
import { PolymorphicProps } from '../../types/common';
|
|
9
|
+
export interface LinkBaseProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
14
10
|
/**
|
|
15
11
|
* @description Indicates the element that represents the
|
|
16
12
|
* current item within a container or set of related
|
|
@@ -52,7 +48,6 @@ export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
|
52
48
|
*/
|
|
53
49
|
visited?: boolean;
|
|
54
50
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
} & React.RefAttributes<HTMLAnchorElement>>;
|
|
51
|
+
export type LinkProps<E extends ElementType> = PolymorphicProps<E, LinkBaseProps>;
|
|
52
|
+
declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps<React.ElementType<any>>, "ref"> & React.RefAttributes<unknown>>;
|
|
58
53
|
export default Link;
|
|
@@ -70,7 +70,7 @@ Link.propTypes = {
|
|
|
70
70
|
* Provide a custom element or component to render the top-level node for the
|
|
71
71
|
* component.
|
|
72
72
|
*/
|
|
73
|
-
as: PropTypes__default["default"].
|
|
73
|
+
as: PropTypes__default["default"].elementType,
|
|
74
74
|
/**
|
|
75
75
|
* Provide the content for the Link
|
|
76
76
|
*/
|
|
@@ -95,7 +95,6 @@ Link.propTypes = {
|
|
|
95
95
|
* Optional prop to render an icon next to the link.
|
|
96
96
|
* Can be a React component class
|
|
97
97
|
*/
|
|
98
|
-
// @ts-expect-error - PropTypes are unable to cover this case.
|
|
99
98
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
100
99
|
/**
|
|
101
100
|
* Specify the size of the Link. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { RefObject } from 'react';
|
|
7
|
+
import React, { ReactNode, RefObject } from 'react';
|
|
8
8
|
interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
9
9
|
/**
|
|
10
10
|
* The ref of the containing element, used for positioning and alignment of the menu
|
|
@@ -13,7 +13,7 @@ interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
|
13
13
|
/**
|
|
14
14
|
* A collection of MenuItems to be rendered within this Menu.
|
|
15
15
|
*/
|
|
16
|
-
children?:
|
|
16
|
+
children?: ReactNode;
|
|
17
17
|
/**
|
|
18
18
|
* Additional CSS class names.
|
|
19
19
|
*/
|
|
@@ -21,7 +21,7 @@ interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
|
21
21
|
/**
|
|
22
22
|
* A label describing the Menu.
|
|
23
23
|
*/
|
|
24
|
-
label
|
|
24
|
+
label: string;
|
|
25
25
|
/**
|
|
26
26
|
* Specify how the menu should align with the button element
|
|
27
27
|
*/
|
|
@@ -53,15 +53,15 @@ interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
|
53
53
|
/**
|
|
54
54
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
55
55
|
*/
|
|
56
|
-
target?:
|
|
56
|
+
target?: HTMLElement;
|
|
57
57
|
/**
|
|
58
58
|
* Specify the x position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([x1, x2])
|
|
59
59
|
*/
|
|
60
|
-
x?: number |
|
|
60
|
+
x?: number | [number, number];
|
|
61
61
|
/**
|
|
62
62
|
* Specify the y position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([y1, y2])
|
|
63
63
|
*/
|
|
64
|
-
y?: number |
|
|
64
|
+
y?: number | [number, number];
|
|
65
65
|
}
|
|
66
66
|
declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLUListElement>>;
|
|
67
67
|
export { Menu };
|
|
@@ -30,7 +30,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
30
30
|
|
|
31
31
|
const spacing = 8; // distance to keep to window edges, in px
|
|
32
32
|
|
|
33
|
-
const Menu = /*#__PURE__*/
|
|
33
|
+
const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
34
34
|
let {
|
|
35
35
|
children,
|
|
36
36
|
className,
|
|
@@ -82,7 +82,7 @@ const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_re
|
|
|
82
82
|
actionButtonWidth = w;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
// Set RTL based on document direction or `LayoutDirection`
|
|
85
|
+
// Set RTL based on the document direction or `LayoutDirection`
|
|
86
86
|
const {
|
|
87
87
|
direction
|
|
88
88
|
} = useLayoutDirection.useLayoutDirection();
|
|
@@ -313,6 +313,7 @@ Menu.propTypes = {
|
|
|
313
313
|
/**
|
|
314
314
|
* A label describing the Menu.
|
|
315
315
|
*/
|
|
316
|
+
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
316
317
|
label: PropTypes__default["default"].string,
|
|
317
318
|
/**
|
|
318
319
|
* Specify how the menu should align with the button element
|
|
@@ -345,14 +346,17 @@ Menu.propTypes = {
|
|
|
345
346
|
/**
|
|
346
347
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
347
348
|
*/
|
|
349
|
+
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
348
350
|
target: PropTypes__default["default"].object,
|
|
349
351
|
/**
|
|
350
352
|
* Specify the x position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([x1, x2])
|
|
351
353
|
*/
|
|
354
|
+
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
352
355
|
x: PropTypes__default["default"].oneOfType([PropTypes__default["default"].number, PropTypes__default["default"].arrayOf(PropTypes__default["default"].number)]),
|
|
353
356
|
/**
|
|
354
357
|
* Specify the y position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([y1, y2])
|
|
355
358
|
*/
|
|
359
|
+
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
356
360
|
y: PropTypes__default["default"].oneOfType([PropTypes__default["default"].number, PropTypes__default["default"].arrayOf(PropTypes__default["default"].number)])
|
|
357
361
|
};
|
|
358
362
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import { KeyboardEvent, RefObject } from 'react';
|
|
8
8
|
type ActionType = {
|
|
9
9
|
type: 'enableIcons' | 'registerItem';
|
|
10
10
|
payload: any;
|
|
@@ -15,7 +15,7 @@ type StateType = {
|
|
|
15
15
|
hasIcons: boolean;
|
|
16
16
|
size: 'xs' | 'sm' | 'md' | 'lg' | null;
|
|
17
17
|
items: any[];
|
|
18
|
-
requestCloseRoot: (e: Pick<
|
|
18
|
+
requestCloseRoot: (e: Pick<KeyboardEvent<HTMLUListElement>, 'type'>) => void;
|
|
19
19
|
};
|
|
20
20
|
declare function menuReducer(state: StateType, action: ActionType): {
|
|
21
21
|
hasIcons: boolean;
|
|
@@ -23,10 +23,18 @@ declare function menuReducer(state: StateType, action: ActionType): {
|
|
|
23
23
|
mode: "full" | "basic";
|
|
24
24
|
size: "sm" | "md" | "lg" | "xs" | null;
|
|
25
25
|
items: any[];
|
|
26
|
-
requestCloseRoot: (e: Pick<
|
|
26
|
+
requestCloseRoot: (e: Pick<KeyboardEvent<HTMLUListElement>, "type">) => void;
|
|
27
27
|
};
|
|
28
|
-
|
|
28
|
+
type DispatchFuncProps = {
|
|
29
|
+
type: 'registerItem' | 'enableIcons';
|
|
30
|
+
payload: {
|
|
31
|
+
ref: RefObject<HTMLLIElement>;
|
|
32
|
+
disabled: boolean;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
type MenuContextProps = {
|
|
29
36
|
state: StateType;
|
|
30
|
-
dispatch:
|
|
31
|
-
}
|
|
37
|
+
dispatch: (props: DispatchFuncProps) => void;
|
|
38
|
+
};
|
|
39
|
+
declare const MenuContext: import("react").Context<MenuContextProps>;
|
|
32
40
|
export { MenuContext, menuReducer };
|
|
@@ -11,10 +11,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
|
|
12
12
|
var React = require('react');
|
|
13
13
|
|
|
14
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
-
|
|
16
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
|
-
|
|
18
14
|
const menuDefaultState = {
|
|
19
15
|
isRoot: true,
|
|
20
16
|
mode: 'full',
|
|
@@ -37,10 +33,10 @@ function menuReducer(state, action) {
|
|
|
37
33
|
};
|
|
38
34
|
}
|
|
39
35
|
}
|
|
40
|
-
const MenuContext = /*#__PURE__*/
|
|
36
|
+
const MenuContext = /*#__PURE__*/React.createContext({
|
|
41
37
|
state: menuDefaultState,
|
|
42
38
|
// 'dispatch' is populated by the root menu
|
|
43
|
-
dispatch:
|
|
39
|
+
dispatch: _ => {}
|
|
44
40
|
});
|
|
45
41
|
|
|
46
42
|
exports.MenuContext = MenuContext;
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React from 'react';
|
|
8
|
-
interface MenuItemProps extends
|
|
7
|
+
import React, { ChangeEventHandler, ComponentProps, FC, KeyboardEvent, LiHTMLAttributes, MouseEvent, ReactNode } from 'react';
|
|
8
|
+
export interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {
|
|
9
9
|
/**
|
|
10
10
|
* Optionally provide another Menu to create a submenu. props.children can't be used to specify the content of the MenuItem itself. Use props.label instead.
|
|
11
11
|
*/
|
|
12
|
-
children?:
|
|
12
|
+
children?: ReactNode;
|
|
13
13
|
/**
|
|
14
14
|
* Additional CSS class names.
|
|
15
15
|
*/
|
|
@@ -29,45 +29,37 @@ interface MenuItemProps extends React.LiHTMLAttributes<HTMLLIElement> {
|
|
|
29
29
|
/**
|
|
30
30
|
* Provide an optional function to be called when the MenuItem is clicked.
|
|
31
31
|
*/
|
|
32
|
-
onClick?: (event:
|
|
32
|
+
onClick?: (event: KeyboardEvent<HTMLLIElement> | MouseEvent<HTMLLIElement>) => void;
|
|
33
33
|
/**
|
|
34
34
|
* Only applicable if the parent menu is in `basic` mode. Sets the menu item's icon.
|
|
35
35
|
*/
|
|
36
|
-
renderIcon?:
|
|
36
|
+
renderIcon?: FC;
|
|
37
37
|
/**
|
|
38
38
|
* Provide a shortcut for the action of this MenuItem. Note that the component will only render it as a hint but not actually register the shortcut.
|
|
39
39
|
*/
|
|
40
40
|
shortcut?: string;
|
|
41
41
|
}
|
|
42
|
-
declare const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
43
|
-
interface MenuItemSelectableProps {
|
|
44
|
-
/**
|
|
45
|
-
* Additional CSS class names.
|
|
46
|
-
*/
|
|
47
|
-
className?: string;
|
|
42
|
+
export declare const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
43
|
+
export interface MenuItemSelectableProps extends Omit<MenuItemProps, 'onChange'> {
|
|
48
44
|
/**
|
|
49
45
|
* Specify whether the option should be selected by default.
|
|
50
46
|
*/
|
|
51
47
|
defaultSelected?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* A required label titling this option.
|
|
54
|
-
*/
|
|
55
|
-
label: string;
|
|
56
48
|
/**
|
|
57
49
|
* Provide an optional function to be called when the selection state changes.
|
|
58
50
|
*/
|
|
59
|
-
onChange?:
|
|
51
|
+
onChange?: ChangeEventHandler<HTMLLIElement>;
|
|
60
52
|
/**
|
|
61
|
-
*
|
|
53
|
+
* Controls the state of this option.
|
|
62
54
|
*/
|
|
63
55
|
selected?: boolean;
|
|
64
56
|
}
|
|
65
|
-
declare const MenuItemSelectable: React.ForwardRefExoticComponent<MenuItemSelectableProps & React.RefAttributes<HTMLLIElement>>;
|
|
66
|
-
interface MenuItemGroupProps {
|
|
57
|
+
export declare const MenuItemSelectable: React.ForwardRefExoticComponent<MenuItemSelectableProps & React.RefAttributes<HTMLLIElement>>;
|
|
58
|
+
export interface MenuItemGroupProps extends ComponentProps<'ul'> {
|
|
67
59
|
/**
|
|
68
60
|
* A collection of MenuItems to be rendered within this group.
|
|
69
61
|
*/
|
|
70
|
-
children?:
|
|
62
|
+
children?: ReactNode;
|
|
71
63
|
/**
|
|
72
64
|
* Additional CSS class names.
|
|
73
65
|
*/
|
|
@@ -77,8 +69,8 @@ interface MenuItemGroupProps {
|
|
|
77
69
|
*/
|
|
78
70
|
label: string;
|
|
79
71
|
}
|
|
80
|
-
declare const MenuItemGroup: React.ForwardRefExoticComponent<MenuItemGroupProps & React.RefAttributes<HTMLLIElement>>;
|
|
81
|
-
interface MenuItemRadioGroupProps {
|
|
72
|
+
export declare const MenuItemGroup: React.ForwardRefExoticComponent<Omit<MenuItemGroupProps, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
73
|
+
export interface MenuItemRadioGroupProps<Item> extends Omit<ComponentProps<'ul'>, 'onChange'> {
|
|
82
74
|
/**
|
|
83
75
|
* Additional CSS class names.
|
|
84
76
|
*/
|
|
@@ -86,15 +78,15 @@ interface MenuItemRadioGroupProps {
|
|
|
86
78
|
/**
|
|
87
79
|
* Specify the default selected item. Must match the type of props.items.
|
|
88
80
|
*/
|
|
89
|
-
defaultSelectedItem?:
|
|
81
|
+
defaultSelectedItem?: Item;
|
|
90
82
|
/**
|
|
91
83
|
* Provide a function to convert an item to the string that will be rendered. Defaults to item.toString().
|
|
92
84
|
*/
|
|
93
|
-
itemToString?: (item:
|
|
85
|
+
itemToString?: (item: Item) => string;
|
|
94
86
|
/**
|
|
95
87
|
* Provide the options for this radio group. Can be of any type, as long as you provide an appropriate props.itemToString function.
|
|
96
88
|
*/
|
|
97
|
-
items
|
|
89
|
+
items: Item[];
|
|
98
90
|
/**
|
|
99
91
|
* A required label titling this radio group.
|
|
100
92
|
*/
|
|
@@ -102,18 +94,17 @@ interface MenuItemRadioGroupProps {
|
|
|
102
94
|
/**
|
|
103
95
|
* Provide an optional function to be called when the selection changes.
|
|
104
96
|
*/
|
|
105
|
-
onChange?:
|
|
97
|
+
onChange?: ChangeEventHandler<HTMLLIElement>;
|
|
106
98
|
/**
|
|
107
99
|
* Provide props.selectedItem to control the state of this radio group. Must match the type of props.items.
|
|
108
100
|
*/
|
|
109
|
-
selectedItem?:
|
|
101
|
+
selectedItem?: Item;
|
|
110
102
|
}
|
|
111
|
-
declare const MenuItemRadioGroup: React.ForwardRefExoticComponent<MenuItemRadioGroupProps & React.RefAttributes<HTMLLIElement>>;
|
|
112
|
-
interface MenuItemDividerProps {
|
|
103
|
+
export declare const MenuItemRadioGroup: React.ForwardRefExoticComponent<Omit<MenuItemRadioGroupProps<unknown>, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
104
|
+
export interface MenuItemDividerProps extends ComponentProps<'li'> {
|
|
113
105
|
/**
|
|
114
106
|
* Additional CSS class names.
|
|
115
107
|
*/
|
|
116
108
|
className?: string;
|
|
117
109
|
}
|
|
118
|
-
declare const MenuItemDivider: React.ForwardRefExoticComponent<MenuItemDividerProps & React.RefAttributes<HTMLLIElement>>;
|
|
119
|
-
export { MenuItem, MenuItemSelectable, MenuItemGroup, MenuItemRadioGroup, MenuItemDivider, };
|
|
110
|
+
export declare const MenuItemDivider: React.ForwardRefExoticComponent<Omit<MenuItemDividerProps, "ref"> & React.RefAttributes<HTMLLIElement>>;
|