@ai-matrx/context-menu 0.0.0 → 0.1.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/CHANGELOG.md +16 -0
- package/README.md +14 -1
- package/dist/builder.cjs +1665 -0
- package/dist/builder.cjs.map +1 -0
- package/dist/builder.d.cts +22 -0
- package/dist/builder.d.ts +22 -0
- package/dist/builder.js +1650 -0
- package/dist/builder.js.map +1 -0
- package/dist/design-store.cjs +195 -0
- package/dist/design-store.cjs.map +1 -0
- package/dist/design-store.d.cts +42 -0
- package/dist/design-store.d.ts +42 -0
- package/dist/design-store.js +175 -0
- package/dist/design-store.js.map +1 -0
- package/dist/engine.cjs +3069 -0
- package/dist/engine.cjs.map +1 -0
- package/dist/engine.d.cts +731 -0
- package/dist/engine.d.ts +731 -0
- package/dist/engine.js +3250 -0
- package/dist/engine.js.map +1 -0
- package/dist/grouping-CB3zlD1T.d.ts +623 -0
- package/dist/grouping-CGcWsltu.d.cts +623 -0
- package/dist/host-types-AOiEYwR8.d.cts +9 -0
- package/dist/host-types-AOiEYwR8.d.ts +9 -0
- package/dist/index.cjs +486 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +464 -0
- package/dist/index.js.map +1 -0
- package/dist/menu-content.cjs +3146 -0
- package/dist/menu-content.cjs.map +1 -0
- package/dist/menu-content.d.cts +30 -0
- package/dist/menu-content.d.ts +30 -0
- package/dist/menu-content.js +3197 -0
- package/dist/menu-content.js.map +1 -0
- package/dist/model-BdF0TqZ3.d.cts +107 -0
- package/dist/model-BdF0TqZ3.d.ts +107 -0
- package/dist/react.cjs +3322 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +133 -0
- package/dist/react.d.ts +133 -0
- package/dist/react.js +3345 -0
- package/dist/react.js.map +1 -0
- package/package.json +170 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
type MenuNodeKind = "item" | "section" | "submenu" | "divider";
|
|
2
|
+
interface NodeBase {
|
|
3
|
+
/** Stable within the design. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** The catalog option this was dragged from, when it came from one. */
|
|
6
|
+
catalogId?: string;
|
|
7
|
+
/** A designer's note on this one entry ("only on a table row", "merge with Copy"). */
|
|
8
|
+
note?: string;
|
|
9
|
+
}
|
|
10
|
+
interface MenuItemNode extends NodeBase {
|
|
11
|
+
kind: "item";
|
|
12
|
+
label: string;
|
|
13
|
+
/** A lucide icon name (`Sparkles`, `Copy`). */
|
|
14
|
+
icon?: string;
|
|
15
|
+
/** Shown right-aligned (`⌘C`). */
|
|
16
|
+
shortcut?: string;
|
|
17
|
+
/** One short line under the label. */
|
|
18
|
+
hint?: string;
|
|
19
|
+
/** Shown greyed out — the design says "this exists here but is unavailable now". */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Red, for actions that remove or discard. */
|
|
22
|
+
danger?: boolean;
|
|
23
|
+
/** A checkbox-style toggle item. */
|
|
24
|
+
toggle?: boolean;
|
|
25
|
+
/** Drawn as a highlighted, AI-flavoured item. */
|
|
26
|
+
ai?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface MenuSectionNode extends NodeBase {
|
|
29
|
+
kind: "section";
|
|
30
|
+
/** The small heading. Empty = an unlabelled group. */
|
|
31
|
+
label: string;
|
|
32
|
+
children: MenuNode[];
|
|
33
|
+
/** Starts folded; a click on the heading opens it. */
|
|
34
|
+
collapsible?: boolean;
|
|
35
|
+
/** How the section's items are laid out. */
|
|
36
|
+
layout?: "list" | "grid" | "row";
|
|
37
|
+
}
|
|
38
|
+
interface MenuSubmenuNode extends NodeBase {
|
|
39
|
+
kind: "submenu";
|
|
40
|
+
label: string;
|
|
41
|
+
icon?: string;
|
|
42
|
+
hint?: string;
|
|
43
|
+
children: MenuNode[];
|
|
44
|
+
}
|
|
45
|
+
interface MenuDividerNode extends NodeBase {
|
|
46
|
+
kind: "divider";
|
|
47
|
+
}
|
|
48
|
+
type MenuNode = MenuItemNode | MenuSectionNode | MenuSubmenuNode | MenuDividerNode;
|
|
49
|
+
type MenuContainerNode = MenuSectionNode | MenuSubmenuNode;
|
|
50
|
+
/** Where the menu opens; the builder previews each the way it appears there. */
|
|
51
|
+
declare const MENU_SURFACES: readonly ["text-selection", "editable-field", "table-row", "page", "chat-message", "file", "anywhere"];
|
|
52
|
+
type MenuSurface = (typeof MENU_SURFACES)[number];
|
|
53
|
+
interface MenuLook {
|
|
54
|
+
density: "compact" | "comfortable";
|
|
55
|
+
width: number;
|
|
56
|
+
showIcons: boolean;
|
|
57
|
+
showShortcuts: boolean;
|
|
58
|
+
showHints: boolean;
|
|
59
|
+
/** A search box at the top of the menu. */
|
|
60
|
+
search: boolean;
|
|
61
|
+
}
|
|
62
|
+
declare const DEFAULT_LOOK: MenuLook;
|
|
63
|
+
interface MenuDesign {
|
|
64
|
+
/** The design's identity; every version shares it. */
|
|
65
|
+
designId: string;
|
|
66
|
+
name: string;
|
|
67
|
+
surface: MenuSurface;
|
|
68
|
+
look: MenuLook;
|
|
69
|
+
nodes: MenuNode[];
|
|
70
|
+
/** Free notes for whoever builds it. */
|
|
71
|
+
notes: string;
|
|
72
|
+
}
|
|
73
|
+
declare const DESIGN_FORMAT = 1;
|
|
74
|
+
declare function newId(prefix?: string): string;
|
|
75
|
+
declare function emptyDesign(name?: string): MenuDesign;
|
|
76
|
+
declare function isContainer(node: MenuNode): node is MenuContainerNode;
|
|
77
|
+
/** A deep copy with every id renewed — what a duplicate or a second drop of a template gets. */
|
|
78
|
+
declare function cloneNode<N extends MenuNode>(node: N): N;
|
|
79
|
+
interface Located {
|
|
80
|
+
node: MenuNode;
|
|
81
|
+
/** The container's id, or null at the top. */
|
|
82
|
+
parentId: string | null;
|
|
83
|
+
index: number;
|
|
84
|
+
depth: number;
|
|
85
|
+
}
|
|
86
|
+
declare function locate(nodes: readonly MenuNode[], id: string, parentId?: string | null, depth?: number): Located | null;
|
|
87
|
+
declare function contains(node: MenuNode, id: string): boolean;
|
|
88
|
+
declare function countItems(nodes: readonly MenuNode[]): number;
|
|
89
|
+
declare function insertNode(nodes: readonly MenuNode[], parentId: string | null, index: number, node: MenuNode): MenuNode[];
|
|
90
|
+
declare function removeNode(nodes: readonly MenuNode[], id: string): MenuNode[];
|
|
91
|
+
declare function updateNode(nodes: readonly MenuNode[], id: string, patch: Partial<MenuNode>): MenuNode[];
|
|
92
|
+
/**
|
|
93
|
+
* Move `id` to `index` inside `parentId`. Refuses (returns the tree unchanged) a move into itself
|
|
94
|
+
* or its own descendant. `index` is in the destination list as it reads BEFORE the move.
|
|
95
|
+
*/
|
|
96
|
+
declare function canMove(nodes: readonly MenuNode[], id: string, parentId: string | null): boolean;
|
|
97
|
+
declare function moveNode(nodes: readonly MenuNode[], id: string, parentId: string | null, index: number): MenuNode[];
|
|
98
|
+
declare function duplicateNode(nodes: readonly MenuNode[], id: string): MenuNode[];
|
|
99
|
+
/** Wrap a node into a new section (or submenu) in its place. */
|
|
100
|
+
declare function wrapNode(nodes: readonly MenuNode[], id: string, kind: "section" | "submenu"): MenuNode[];
|
|
101
|
+
/** Replace a container by its children. */
|
|
102
|
+
declare function unwrapNode(nodes: readonly MenuNode[], id: string): MenuNode[];
|
|
103
|
+
/** A saved document back into a design; anything unreadable becomes an empty design, never a throw. */
|
|
104
|
+
declare function parseDesign(raw: unknown): MenuDesign;
|
|
105
|
+
declare function serializeDesign(design: MenuDesign): string;
|
|
106
|
+
|
|
107
|
+
export { updateNode as A, wrapNode as B, DEFAULT_LOOK as D, type Located as L, type MenuDesign as M, type MenuNode as a, type MenuItemNode as b, DESIGN_FORMAT as c, MENU_SURFACES as d, type MenuContainerNode as e, type MenuDividerNode as f, type MenuLook as g, type MenuNodeKind as h, type MenuSectionNode as i, type MenuSubmenuNode as j, type MenuSurface as k, canMove as l, cloneNode as m, contains as n, countItems as o, duplicateNode as p, emptyDesign as q, insertNode as r, isContainer as s, locate as t, moveNode as u, newId as v, parseDesign as w, removeNode as x, serializeDesign as y, unwrapNode as z };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
type MenuNodeKind = "item" | "section" | "submenu" | "divider";
|
|
2
|
+
interface NodeBase {
|
|
3
|
+
/** Stable within the design. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** The catalog option this was dragged from, when it came from one. */
|
|
6
|
+
catalogId?: string;
|
|
7
|
+
/** A designer's note on this one entry ("only on a table row", "merge with Copy"). */
|
|
8
|
+
note?: string;
|
|
9
|
+
}
|
|
10
|
+
interface MenuItemNode extends NodeBase {
|
|
11
|
+
kind: "item";
|
|
12
|
+
label: string;
|
|
13
|
+
/** A lucide icon name (`Sparkles`, `Copy`). */
|
|
14
|
+
icon?: string;
|
|
15
|
+
/** Shown right-aligned (`⌘C`). */
|
|
16
|
+
shortcut?: string;
|
|
17
|
+
/** One short line under the label. */
|
|
18
|
+
hint?: string;
|
|
19
|
+
/** Shown greyed out — the design says "this exists here but is unavailable now". */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Red, for actions that remove or discard. */
|
|
22
|
+
danger?: boolean;
|
|
23
|
+
/** A checkbox-style toggle item. */
|
|
24
|
+
toggle?: boolean;
|
|
25
|
+
/** Drawn as a highlighted, AI-flavoured item. */
|
|
26
|
+
ai?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface MenuSectionNode extends NodeBase {
|
|
29
|
+
kind: "section";
|
|
30
|
+
/** The small heading. Empty = an unlabelled group. */
|
|
31
|
+
label: string;
|
|
32
|
+
children: MenuNode[];
|
|
33
|
+
/** Starts folded; a click on the heading opens it. */
|
|
34
|
+
collapsible?: boolean;
|
|
35
|
+
/** How the section's items are laid out. */
|
|
36
|
+
layout?: "list" | "grid" | "row";
|
|
37
|
+
}
|
|
38
|
+
interface MenuSubmenuNode extends NodeBase {
|
|
39
|
+
kind: "submenu";
|
|
40
|
+
label: string;
|
|
41
|
+
icon?: string;
|
|
42
|
+
hint?: string;
|
|
43
|
+
children: MenuNode[];
|
|
44
|
+
}
|
|
45
|
+
interface MenuDividerNode extends NodeBase {
|
|
46
|
+
kind: "divider";
|
|
47
|
+
}
|
|
48
|
+
type MenuNode = MenuItemNode | MenuSectionNode | MenuSubmenuNode | MenuDividerNode;
|
|
49
|
+
type MenuContainerNode = MenuSectionNode | MenuSubmenuNode;
|
|
50
|
+
/** Where the menu opens; the builder previews each the way it appears there. */
|
|
51
|
+
declare const MENU_SURFACES: readonly ["text-selection", "editable-field", "table-row", "page", "chat-message", "file", "anywhere"];
|
|
52
|
+
type MenuSurface = (typeof MENU_SURFACES)[number];
|
|
53
|
+
interface MenuLook {
|
|
54
|
+
density: "compact" | "comfortable";
|
|
55
|
+
width: number;
|
|
56
|
+
showIcons: boolean;
|
|
57
|
+
showShortcuts: boolean;
|
|
58
|
+
showHints: boolean;
|
|
59
|
+
/** A search box at the top of the menu. */
|
|
60
|
+
search: boolean;
|
|
61
|
+
}
|
|
62
|
+
declare const DEFAULT_LOOK: MenuLook;
|
|
63
|
+
interface MenuDesign {
|
|
64
|
+
/** The design's identity; every version shares it. */
|
|
65
|
+
designId: string;
|
|
66
|
+
name: string;
|
|
67
|
+
surface: MenuSurface;
|
|
68
|
+
look: MenuLook;
|
|
69
|
+
nodes: MenuNode[];
|
|
70
|
+
/** Free notes for whoever builds it. */
|
|
71
|
+
notes: string;
|
|
72
|
+
}
|
|
73
|
+
declare const DESIGN_FORMAT = 1;
|
|
74
|
+
declare function newId(prefix?: string): string;
|
|
75
|
+
declare function emptyDesign(name?: string): MenuDesign;
|
|
76
|
+
declare function isContainer(node: MenuNode): node is MenuContainerNode;
|
|
77
|
+
/** A deep copy with every id renewed — what a duplicate or a second drop of a template gets. */
|
|
78
|
+
declare function cloneNode<N extends MenuNode>(node: N): N;
|
|
79
|
+
interface Located {
|
|
80
|
+
node: MenuNode;
|
|
81
|
+
/** The container's id, or null at the top. */
|
|
82
|
+
parentId: string | null;
|
|
83
|
+
index: number;
|
|
84
|
+
depth: number;
|
|
85
|
+
}
|
|
86
|
+
declare function locate(nodes: readonly MenuNode[], id: string, parentId?: string | null, depth?: number): Located | null;
|
|
87
|
+
declare function contains(node: MenuNode, id: string): boolean;
|
|
88
|
+
declare function countItems(nodes: readonly MenuNode[]): number;
|
|
89
|
+
declare function insertNode(nodes: readonly MenuNode[], parentId: string | null, index: number, node: MenuNode): MenuNode[];
|
|
90
|
+
declare function removeNode(nodes: readonly MenuNode[], id: string): MenuNode[];
|
|
91
|
+
declare function updateNode(nodes: readonly MenuNode[], id: string, patch: Partial<MenuNode>): MenuNode[];
|
|
92
|
+
/**
|
|
93
|
+
* Move `id` to `index` inside `parentId`. Refuses (returns the tree unchanged) a move into itself
|
|
94
|
+
* or its own descendant. `index` is in the destination list as it reads BEFORE the move.
|
|
95
|
+
*/
|
|
96
|
+
declare function canMove(nodes: readonly MenuNode[], id: string, parentId: string | null): boolean;
|
|
97
|
+
declare function moveNode(nodes: readonly MenuNode[], id: string, parentId: string | null, index: number): MenuNode[];
|
|
98
|
+
declare function duplicateNode(nodes: readonly MenuNode[], id: string): MenuNode[];
|
|
99
|
+
/** Wrap a node into a new section (or submenu) in its place. */
|
|
100
|
+
declare function wrapNode(nodes: readonly MenuNode[], id: string, kind: "section" | "submenu"): MenuNode[];
|
|
101
|
+
/** Replace a container by its children. */
|
|
102
|
+
declare function unwrapNode(nodes: readonly MenuNode[], id: string): MenuNode[];
|
|
103
|
+
/** A saved document back into a design; anything unreadable becomes an empty design, never a throw. */
|
|
104
|
+
declare function parseDesign(raw: unknown): MenuDesign;
|
|
105
|
+
declare function serializeDesign(design: MenuDesign): string;
|
|
106
|
+
|
|
107
|
+
export { updateNode as A, wrapNode as B, DEFAULT_LOOK as D, type Located as L, type MenuDesign as M, type MenuNode as a, type MenuItemNode as b, DESIGN_FORMAT as c, MENU_SURFACES as d, type MenuContainerNode as e, type MenuDividerNode as f, type MenuLook as g, type MenuNodeKind as h, type MenuSectionNode as i, type MenuSubmenuNode as j, type MenuSurface as k, canMove as l, cloneNode as m, contains as n, countItems as o, duplicateNode as p, emptyDesign as q, insertNode as r, isContainer as s, locate as t, moveNode as u, newId as v, parseDesign as w, removeNode as x, serializeDesign as y, unwrapNode as z };
|