UNPKG

2.16 kBTypeScriptView Raw
1import { GemElement, TemplateResult } from '@mantou/gem/lib/element';
2import './compartment';
3import './button';
4import './options';
5export declare type Menu = MenuItem[] | TemplateResult;
6export interface MenuItem {
7 /**`---` is separator */
8 text: string | TemplateResult;
9 description?: string | TemplateResult;
10 tag?: string | TemplateResult;
11 tagIcon?: string | DocumentFragment | Element;
12 disabled?: boolean;
13 danger?: boolean;
14 selected?: boolean;
15 handle?: () => void | Promise<void>;
16 menu?: Menu;
17}
18declare type MenuStore = {
19 width?: string;
20 maxHeight?: string;
21 activeElement?: HTMLElement | null;
22 openLeft?: boolean;
23 maskClosable?: boolean;
24 menuStack: {
25 searchable?: boolean;
26 openTop?: boolean;
27 menu: Menu;
28 x: number;
29 y: number;
30 header?: TemplateResult;
31 }[];
32};
33declare type OpenMenuOptions = {
34 /**auto calc `x`/`y` via `activeElement` */
35 activeElement?: HTMLElement | null;
36 /**only work `activeElement`, only support first menu */
37 openLeft?: boolean;
38 maskClosable?: boolean;
39 /**only work nothing `activeElement` */
40 x?: number;
41 /**only work nothing `activeElement` */
42 y?: number;
43 /**work on all menu */
44 width?: string;
45 /**only support first menu */
46 maxHeight?: string;
47 /**only support first menu */
48 searchable?: boolean;
49 /**only support first menu */
50 header?: TemplateResult;
51};
52export declare const menuStore: import("@mantou/gem/lib/store").Store<MenuStore>;
53/**
54 * @customElement dy-menu
55 */
56export declare class DuoyunMenuElement extends GemElement {
57 #private;
58 static instance?: DuoyunMenuElement;
59 static open(menu: Menu, options?: OpenMenuOptions): Promise<void>;
60 static confirm(text: string | TemplateResult, options: OpenMenuOptions & {
61 danger?: boolean;
62 okText?: string | TemplateResult;
63 }): Promise<unknown>;
64 static close(): void;
65 constructor();
66 mounted: () => () => void;
67 render: () => TemplateResult;
68}
69export declare const ContextMenu: typeof DuoyunMenuElement;
70export {};
71//# sourceMappingURL=menu.d.ts.map
\No newline at end of file