draft-components 1.3.0 → 1.4.1
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.
|
@@ -4,18 +4,18 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
const react = require('react');
|
|
5
5
|
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
6
6
|
|
|
7
|
-
const MenuItem = react.forwardRef(function MenuItem({ role = 'menuitem', appearance = 'default',
|
|
7
|
+
const MenuItem = react.forwardRef(function MenuItem({ role = 'menuitem', appearance = 'default', leftIcon = null, rightIcon = null, className, children, ...props }, ref) {
|
|
8
8
|
let label = children;
|
|
9
|
-
if (
|
|
9
|
+
if (leftIcon || rightIcon) {
|
|
10
10
|
const className = reactHelpers.classNames('dc-menu-btn__label', {
|
|
11
|
-
'dc-menu-btn__label_gap_left':
|
|
12
|
-
'dc-menu-btn__label_gap_right':
|
|
11
|
+
'dc-menu-btn__label_gap_left': leftIcon,
|
|
12
|
+
'dc-menu-btn__label_gap_right': rightIcon,
|
|
13
13
|
});
|
|
14
14
|
label = jsxRuntime.jsx("span", { className: className, children: label });
|
|
15
15
|
}
|
|
16
16
|
return (jsxRuntime.jsx("li", { role: "presentation", children: jsxRuntime.jsxs("button", { ...props, ref: ref, className: reactHelpers.classNames(className, 'dc-menu-btn', {
|
|
17
17
|
[`dc-menu-btn_${appearance}`]: appearance,
|
|
18
|
-
}), type: "button", role: role, tabIndex: -1, children: [
|
|
18
|
+
}), type: "button", role: role, tabIndex: -1, children: [leftIcon, label, rightIcon] }) }));
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
exports.MenuItem = MenuItem;
|
package/css/draft-components.css
CHANGED
|
@@ -2,18 +2,18 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
4
4
|
|
|
5
|
-
const MenuItem = forwardRef(function MenuItem({ role = 'menuitem', appearance = 'default',
|
|
5
|
+
const MenuItem = forwardRef(function MenuItem({ role = 'menuitem', appearance = 'default', leftIcon = null, rightIcon = null, className, children, ...props }, ref) {
|
|
6
6
|
let label = children;
|
|
7
|
-
if (
|
|
7
|
+
if (leftIcon || rightIcon) {
|
|
8
8
|
const className = classNames('dc-menu-btn__label', {
|
|
9
|
-
'dc-menu-btn__label_gap_left':
|
|
10
|
-
'dc-menu-btn__label_gap_right':
|
|
9
|
+
'dc-menu-btn__label_gap_left': leftIcon,
|
|
10
|
+
'dc-menu-btn__label_gap_right': rightIcon,
|
|
11
11
|
});
|
|
12
12
|
label = jsx("span", { className: className, children: label });
|
|
13
13
|
}
|
|
14
14
|
return (jsx("li", { role: "presentation", children: jsxs("button", { ...props, ref: ref, className: classNames(className, 'dc-menu-btn', {
|
|
15
15
|
[`dc-menu-btn_${appearance}`]: appearance,
|
|
16
|
-
}), type: "button", role: role, tabIndex: -1, children: [
|
|
16
|
+
}), type: "button", role: role, tabIndex: -1, children: [leftIcon, label, rightIcon] }) }));
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
export { MenuItem };
|
package/package.json
CHANGED
|
@@ -6,8 +6,8 @@ export type MenuItemRole = 'menuitem' | 'menuitemradio';
|
|
|
6
6
|
export type MenuItemProps = {
|
|
7
7
|
role?: MenuItemRole;
|
|
8
8
|
appearance?: MenuItemAppearance;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
leftIcon?: ReactNode;
|
|
10
|
+
rightIcon?: ReactNode;
|
|
11
11
|
children: ReactNode;
|
|
12
12
|
} & MenuItemBaseProps;
|
|
13
13
|
export declare const MenuItem: import("react").ForwardRefExoticComponent<Omit<MenuItemProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|