draft-components 2.6.0 → 2.8.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/css/draft-components.css
CHANGED
|
@@ -3,6 +3,7 @@ type MenuItemHTMLProps = ComponentPropsWithRef<'button'>;
|
|
|
3
3
|
type MenuItemBaseProps = Omit<MenuItemHTMLProps, 'children' | 'role'>;
|
|
4
4
|
export type MenuItemProps = {
|
|
5
5
|
role?: 'menuitem' | 'menuitemradio';
|
|
6
|
+
disabled?: boolean;
|
|
6
7
|
destructive?: boolean;
|
|
7
8
|
iconLeft?: ReactNode;
|
|
8
9
|
iconRight?: ReactNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
4
|
-
export const MenuItem = forwardRef(function MenuItem({ role = 'menuitem', destructive, iconLeft, iconRight, children, className, ...props }, ref) {
|
|
4
|
+
export const MenuItem = forwardRef(function MenuItem({ role = 'menuitem', disabled, destructive, iconLeft, iconRight, children, className, ...props }, ref) {
|
|
5
5
|
let label = children;
|
|
6
6
|
if (iconLeft || iconRight) {
|
|
7
7
|
const className = classNames('dc-menu-btn__label', {
|
|
@@ -12,5 +12,5 @@ export const MenuItem = forwardRef(function MenuItem({ role = 'menuitem', destru
|
|
|
12
12
|
}
|
|
13
13
|
return (_jsx("li", { role: "presentation", children: _jsxs("button", { ...props, ref: ref, className: classNames(className, 'dc-menu-btn', {
|
|
14
14
|
'dc-menu-btn_destructive': destructive,
|
|
15
|
-
}), type: "button", role: role, tabIndex: -1, children: [iconLeft, label, iconRight] }) }));
|
|
15
|
+
}), type: "button", disabled: disabled, role: role, tabIndex: -1, children: [iconLeft, label, iconRight] }) }));
|
|
16
16
|
});
|
|
@@ -183,6 +183,6 @@ function getMenuItems(menuId) {
|
|
|
183
183
|
if (!menuEl) {
|
|
184
184
|
return [];
|
|
185
185
|
}
|
|
186
|
-
const nodes = menuEl.querySelectorAll('button[role="menuitem"], button[role="menuitemradio"]');
|
|
186
|
+
const nodes = menuEl.querySelectorAll('button[role="menuitem"]:not(:disabled), button[role="menuitemradio"]:not(:disabled)');
|
|
187
187
|
return Array.from(nodes);
|
|
188
188
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
import { TabName, TabSetter } from './types.js';
|
|
3
|
+
import { TabList } from './tab-list.js';
|
|
4
|
+
import { TabPanel } from './tab-panel.js';
|
|
3
5
|
export interface TabsProps extends ComponentPropsWithoutRef<'div'> {
|
|
4
6
|
selectedTab: TabName;
|
|
5
7
|
onSelectTab: TabSetter;
|
|
6
8
|
}
|
|
7
9
|
export declare function Tabs({ className, children, selectedTab, onSelectTab, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare namespace Tabs {
|
|
11
|
+
var List: typeof TabList;
|
|
12
|
+
var Tab: typeof import("./tab.js").Tab;
|
|
13
|
+
var Panel: typeof TabPanel;
|
|
14
|
+
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { classNames } from '../../lib/react-helpers.js';
|
|
3
3
|
import { TabsContextProvider } from './tabs-context.js';
|
|
4
|
+
import { TabList } from './tab-list.js';
|
|
5
|
+
import { Tab } from './tab.js';
|
|
6
|
+
import { TabPanel } from './tab-panel.js';
|
|
4
7
|
export function Tabs({ className, children, selectedTab, onSelectTab, ...props }) {
|
|
5
8
|
return (_jsx(TabsContextProvider, { selectedTab: selectedTab, setSelectedTab: onSelectTab, children: _jsx("div", { ...props, className: classNames('dc-tabs', className), children: children }) }));
|
|
6
9
|
}
|
|
10
|
+
Tabs.List = TabList;
|
|
11
|
+
Tabs.Tab = Tab;
|
|
12
|
+
Tabs.Panel = TabPanel;
|