@ai-matrx/context-menu 0.0.0 → 0.1.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +14 -1
  3. package/dist/builder.cjs +1810 -0
  4. package/dist/builder.cjs.map +1 -0
  5. package/dist/builder.d.cts +22 -0
  6. package/dist/builder.d.ts +22 -0
  7. package/dist/builder.js +1795 -0
  8. package/dist/builder.js.map +1 -0
  9. package/dist/design-store.cjs +195 -0
  10. package/dist/design-store.cjs.map +1 -0
  11. package/dist/design-store.d.cts +42 -0
  12. package/dist/design-store.d.ts +42 -0
  13. package/dist/design-store.js +175 -0
  14. package/dist/design-store.js.map +1 -0
  15. package/dist/engine.cjs +3069 -0
  16. package/dist/engine.cjs.map +1 -0
  17. package/dist/engine.d.cts +731 -0
  18. package/dist/engine.d.ts +731 -0
  19. package/dist/engine.js +3250 -0
  20. package/dist/engine.js.map +1 -0
  21. package/dist/grouping-CB3zlD1T.d.ts +623 -0
  22. package/dist/grouping-CGcWsltu.d.cts +623 -0
  23. package/dist/host-types-AOiEYwR8.d.cts +9 -0
  24. package/dist/host-types-AOiEYwR8.d.ts +9 -0
  25. package/dist/index.cjs +583 -0
  26. package/dist/index.cjs.map +1 -0
  27. package/dist/index.d.cts +60 -0
  28. package/dist/index.d.ts +60 -0
  29. package/dist/index.js +561 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/menu-content.cjs +3146 -0
  32. package/dist/menu-content.cjs.map +1 -0
  33. package/dist/menu-content.d.cts +30 -0
  34. package/dist/menu-content.d.ts +30 -0
  35. package/dist/menu-content.js +3197 -0
  36. package/dist/menu-content.js.map +1 -0
  37. package/dist/model-CkLCR6WY.d.cts +123 -0
  38. package/dist/model-CkLCR6WY.d.ts +123 -0
  39. package/dist/react.cjs +3322 -0
  40. package/dist/react.cjs.map +1 -0
  41. package/dist/react.d.cts +133 -0
  42. package/dist/react.d.ts +133 -0
  43. package/dist/react.js +3345 -0
  44. package/dist/react.js.map +1 -0
  45. package/package.json +170 -1
@@ -0,0 +1,133 @@
1
+ import * as React from 'react';
2
+ import React__default, { ReactNode } from 'react';
3
+ import './host-types-AOiEYwR8.cjs';
4
+ import { ContextMenuV3Props, EditableContextMenuProps, NonEditableContextMenuProps, ContextMenuLayout } from '@ai-matrx/chat/context-menu/types';
5
+ import { ContentSource } from '@ai-matrx/rich-content/rich-document/types';
6
+ import { ClickTarget, ResolvedAction } from '@ai-matrx/alchemy/actions';
7
+ import { M as MenuGrouping } from './grouping-CGcWsltu.cjs';
8
+ export { a1 as ALL_DB_PLACEMENTS, a2 as AgentMenuCategoryGroup, a3 as AgentMenuEntry, a4 as BuildCategoryGroupsArgs, C as ContextMenuActions, a5 as DEFAULT_PLACEMENT_MODE, a6 as PLACEMENT_COLOR, a7 as PLACEMENT_LABEL_OVERRIDE, a8 as UseUnifiedAgentContextMenuArgs, a9 as UseUnifiedAgentContextMenuResult, aa as buildCategoryGroups, ab as getPlacementIcon, ac as getPlacementLabel, ad as groupsByPlacement, ae as hasItemsRecursive, af as resolveIcon, ag as resolveRichActionView, ah as useContextMenuActions, ai as useUnifiedAgentContextMenu } from './grouping-CGcWsltu.cjs';
9
+ import { ItemContextMenuProps } from '@ai-matrx/chat/ui/item-types';
10
+ import '@ai-matrx/icons';
11
+ import 'lucide-react';
12
+ import '@ai-matrx/chat/surfaces/types';
13
+ import '@ai-matrx/chat/agents/redux/agent-shortcuts/skl-types';
14
+ import '@ai-matrx/kit/confirm-opener';
15
+ import '@ai-matrx/chat/agents/types/scope.types';
16
+ import '@ai-matrx/chat/agents/redux/agent-shortcuts/types';
17
+ import '@ai-matrx/chat/agents/redux/agent-shortcut-categories/types';
18
+ import '@ai-matrx/chat/agents/redux/shared/scope';
19
+ import '@ai-matrx/chat/surfaces/services/surface-bound-agents.service';
20
+ import '@ai-matrx/chat/context-menu/utils/selection-tracking';
21
+ import '@ai-matrx/kit/json-format';
22
+ import '@ai-matrx/alchemy/menu';
23
+
24
+ /**
25
+ * A gesture that reached this shell only through a React PORTAL: its target is
26
+ * not in the shell's DOM subtree (an open menu, a dialog or popover rendered by
27
+ * something inside the region). React bubbles portal events to every React
28
+ * ancestor, so a right-click — or a Mac two-finger tap mid-scroll — on an OPEN
29
+ * message menu reached the transcript's shell around it, which opened the page
30
+ * menu over it with both engines mounted: 18 `DuplicateActionError`s and "the
31
+ * menu swapped" (blind run PB-06, /chat, 2026-10-01). A portal surface that
32
+ * wants a menu mounts its own.
33
+ */
34
+ declare function reachedThroughPortal(e: {
35
+ target: EventTarget | null;
36
+ currentTarget: EventTarget | null;
37
+ }): boolean;
38
+ /**
39
+ * Warm THAT SAME chunk once per tab, when the browser is idle after the first
40
+ * menu shell mounts — so the first right-click draws at once instead of
41
+ * fetching (and, in dev, compiling) the engine under the pointer (G11A review,
42
+ * 2026-10-07: the first open after a page load took 1–2 s). It is the same
43
+ * specifier as the `dynamic()` above, so it adds no chunk and no boundary
44
+ * (code-splitting rule 3); it only moves WHEN the browser fetches it. The
45
+ * menu still renders only on open.
46
+ */
47
+ declare function warmMenuContent(): Promise<unknown>;
48
+ declare function ContextMenuV3({ children, sourceFeature, surfaceName, menuVersion, getApplicationScope, contextData, resolveContextOnOpen, contentSource, entity, excludedRichActions, recordActionsOnly, subjectFold, extraRichActions, richDocCtxExtras, placementMode, extraSections, resolveExtraSectionsOnOpen, onUndo, onRedo, canUndo, canRedo, undoHint, redoHint, onViewHistory, hasHistory, scope, scopeId, className, menuLayout, menuDensity, suppressed, onMenuOpenChange, onCloseAutoFocus, isEditable, editorId, getTextarea, insertAtCaret, onContentInserted, onTextReplace, onTextInsertBefore, onTextInsertAfter, onSave, onDelete, }: ContextMenuV3Props): React__default.JSX.Element;
49
+
50
+ declare function EditableContextMenu(props: EditableContextMenuProps): React.JSX.Element;
51
+
52
+ declare function NonEditableContextMenu(props: NonEditableContextMenuProps): React.JSX.Element;
53
+
54
+ type MenuProps = Parameters<typeof NonEditableContextMenu>[0];
55
+ declare function PageSurfaceMenu({ sourceFeature, children, }: {
56
+ sourceFeature: MenuProps["sourceFeature"];
57
+ children: ReactNode;
58
+ }): React.JSX.Element;
59
+
60
+ declare const MenuPresenceProvider: React.Provider<boolean>;
61
+ /**
62
+ * `true` when some ancestor already mounts a v3 menu.
63
+ *
64
+ * A shared primitive uses this to decide whether to provide its own floor:
65
+ *
66
+ * ```tsx
67
+ * const insideMenu = useIsInsideContextMenu();
68
+ * return insideMenu ? field : <EditableContextMenu …>{field}</EditableContextMenu>;
69
+ * ```
70
+ *
71
+ * Do NOT use it to change what a menu CONTAINS — only whether a primitive
72
+ * mounts one at all. Content decisions belong to the surface.
73
+ */
74
+ declare function useIsInsideContextMenu(): boolean;
75
+ declare const RegistryMenuSourceProvider: React.Provider<ContentSource | null>;
76
+ declare function useRegistryMenuSource(): ContentSource | null;
77
+ /** Two sources name the same content (type + every identifying id). */
78
+ declare function sameContentSource(a: ContentSource | null | undefined, b: ContentSource | null | undefined): boolean;
79
+ /**
80
+ * A content source's identity as one string (every identifying field, the
81
+ * read-only flag excluded). The shell stamps it on its trigger
82
+ * (`data-content-source`) so a ⋯ button can open the ONE menu that carries its
83
+ * content even when the button renders beside that content, not inside it.
84
+ */
85
+ declare function contentSourceKey(s: ContentSource): string;
86
+
87
+ interface MenuResolutionReport {
88
+ target: ClickTarget;
89
+ /** Exactly what the registry resolved for this open — before any grouping. */
90
+ resolved: readonly ResolvedAction[];
91
+ arrangement: ContextMenuLayout;
92
+ }
93
+ interface MenuRegroupValue {
94
+ /** null = draw the menu as it is today (report only). */
95
+ grouping: MenuGrouping | null;
96
+ mergeSameName: boolean;
97
+ /**
98
+ * Arrange the resolved rows with a function instead of a grouping (the proposed menu,
99
+ * `../proposed/proposed-arrangement.ts`). Wins over `grouping`.
100
+ */
101
+ transform?: ((target: ClickTarget, resolved: readonly ResolvedAction[]) => ResolvedAction[]) | undefined;
102
+ /** The menu's size and whether it draws its header line (the proposed menu: large, none). */
103
+ size?: "standard" | "large" | undefined;
104
+ hideHeader?: boolean | undefined;
105
+ /** Called on every resolve of this menu; `close` shuts the open menu. */
106
+ onResolved?: ((report: MenuResolutionReport, close: () => void) => void) | undefined;
107
+ }
108
+ declare const MenuRegroupContext: React.Context<MenuRegroupValue | null>;
109
+ declare function MenuRegroupProvider({ value, children }: {
110
+ value: MenuRegroupValue;
111
+ children: React.ReactNode;
112
+ }): React.JSX.Element;
113
+ /** Wraps the menu renderer; a pass-through unless a MenuRegroupContext is above it. */
114
+ declare function RegroupBoundary({ arrangement, close, children, }: {
115
+ arrangement: ContextMenuLayout;
116
+ close: () => void;
117
+ children: React.ReactElement;
118
+ }): React.ReactElement;
119
+
120
+ declare function ItemMenuHostBinding({ children }: {
121
+ children: ReactNode;
122
+ }): React.JSX.Element;
123
+
124
+ declare function ItemContextMenuV3({ config, children, sourceFeature, surfaceName, entity, getApplicationScope, resolveItemOnOpen, onOpenChange, onCloseAutoFocus, }: ItemContextMenuProps): React.JSX.Element;
125
+
126
+ declare function OpenSurfaceMenuButton({ getSurface, label, className, }: {
127
+ /** The element the surface's context-menu shell wraps. */
128
+ getSurface: () => HTMLElement | null;
129
+ label?: string | undefined;
130
+ className?: string | undefined;
131
+ }): React.ReactElement;
132
+
133
+ export { ContextMenuV3, EditableContextMenu, ItemContextMenuV3, ItemMenuHostBinding, MenuPresenceProvider, MenuRegroupContext, MenuRegroupProvider, type MenuRegroupValue, type MenuResolutionReport, NonEditableContextMenu, OpenSurfaceMenuButton, PageSurfaceMenu, RegistryMenuSourceProvider, RegroupBoundary, contentSourceKey, reachedThroughPortal, sameContentSource, useIsInsideContextMenu, useRegistryMenuSource, warmMenuContent };
@@ -0,0 +1,133 @@
1
+ import * as React from 'react';
2
+ import React__default, { ReactNode } from 'react';
3
+ import './host-types-AOiEYwR8.js';
4
+ import { ContextMenuV3Props, EditableContextMenuProps, NonEditableContextMenuProps, ContextMenuLayout } from '@ai-matrx/chat/context-menu/types';
5
+ import { ContentSource } from '@ai-matrx/rich-content/rich-document/types';
6
+ import { ClickTarget, ResolvedAction } from '@ai-matrx/alchemy/actions';
7
+ import { M as MenuGrouping } from './grouping-CB3zlD1T.js';
8
+ export { a1 as ALL_DB_PLACEMENTS, a2 as AgentMenuCategoryGroup, a3 as AgentMenuEntry, a4 as BuildCategoryGroupsArgs, C as ContextMenuActions, a5 as DEFAULT_PLACEMENT_MODE, a6 as PLACEMENT_COLOR, a7 as PLACEMENT_LABEL_OVERRIDE, a8 as UseUnifiedAgentContextMenuArgs, a9 as UseUnifiedAgentContextMenuResult, aa as buildCategoryGroups, ab as getPlacementIcon, ac as getPlacementLabel, ad as groupsByPlacement, ae as hasItemsRecursive, af as resolveIcon, ag as resolveRichActionView, ah as useContextMenuActions, ai as useUnifiedAgentContextMenu } from './grouping-CB3zlD1T.js';
9
+ import { ItemContextMenuProps } from '@ai-matrx/chat/ui/item-types';
10
+ import '@ai-matrx/icons';
11
+ import 'lucide-react';
12
+ import '@ai-matrx/chat/surfaces/types';
13
+ import '@ai-matrx/chat/agents/redux/agent-shortcuts/skl-types';
14
+ import '@ai-matrx/kit/confirm-opener';
15
+ import '@ai-matrx/chat/agents/types/scope.types';
16
+ import '@ai-matrx/chat/agents/redux/agent-shortcuts/types';
17
+ import '@ai-matrx/chat/agents/redux/agent-shortcut-categories/types';
18
+ import '@ai-matrx/chat/agents/redux/shared/scope';
19
+ import '@ai-matrx/chat/surfaces/services/surface-bound-agents.service';
20
+ import '@ai-matrx/chat/context-menu/utils/selection-tracking';
21
+ import '@ai-matrx/kit/json-format';
22
+ import '@ai-matrx/alchemy/menu';
23
+
24
+ /**
25
+ * A gesture that reached this shell only through a React PORTAL: its target is
26
+ * not in the shell's DOM subtree (an open menu, a dialog or popover rendered by
27
+ * something inside the region). React bubbles portal events to every React
28
+ * ancestor, so a right-click — or a Mac two-finger tap mid-scroll — on an OPEN
29
+ * message menu reached the transcript's shell around it, which opened the page
30
+ * menu over it with both engines mounted: 18 `DuplicateActionError`s and "the
31
+ * menu swapped" (blind run PB-06, /chat, 2026-10-01). A portal surface that
32
+ * wants a menu mounts its own.
33
+ */
34
+ declare function reachedThroughPortal(e: {
35
+ target: EventTarget | null;
36
+ currentTarget: EventTarget | null;
37
+ }): boolean;
38
+ /**
39
+ * Warm THAT SAME chunk once per tab, when the browser is idle after the first
40
+ * menu shell mounts — so the first right-click draws at once instead of
41
+ * fetching (and, in dev, compiling) the engine under the pointer (G11A review,
42
+ * 2026-10-07: the first open after a page load took 1–2 s). It is the same
43
+ * specifier as the `dynamic()` above, so it adds no chunk and no boundary
44
+ * (code-splitting rule 3); it only moves WHEN the browser fetches it. The
45
+ * menu still renders only on open.
46
+ */
47
+ declare function warmMenuContent(): Promise<unknown>;
48
+ declare function ContextMenuV3({ children, sourceFeature, surfaceName, menuVersion, getApplicationScope, contextData, resolveContextOnOpen, contentSource, entity, excludedRichActions, recordActionsOnly, subjectFold, extraRichActions, richDocCtxExtras, placementMode, extraSections, resolveExtraSectionsOnOpen, onUndo, onRedo, canUndo, canRedo, undoHint, redoHint, onViewHistory, hasHistory, scope, scopeId, className, menuLayout, menuDensity, suppressed, onMenuOpenChange, onCloseAutoFocus, isEditable, editorId, getTextarea, insertAtCaret, onContentInserted, onTextReplace, onTextInsertBefore, onTextInsertAfter, onSave, onDelete, }: ContextMenuV3Props): React__default.JSX.Element;
49
+
50
+ declare function EditableContextMenu(props: EditableContextMenuProps): React.JSX.Element;
51
+
52
+ declare function NonEditableContextMenu(props: NonEditableContextMenuProps): React.JSX.Element;
53
+
54
+ type MenuProps = Parameters<typeof NonEditableContextMenu>[0];
55
+ declare function PageSurfaceMenu({ sourceFeature, children, }: {
56
+ sourceFeature: MenuProps["sourceFeature"];
57
+ children: ReactNode;
58
+ }): React.JSX.Element;
59
+
60
+ declare const MenuPresenceProvider: React.Provider<boolean>;
61
+ /**
62
+ * `true` when some ancestor already mounts a v3 menu.
63
+ *
64
+ * A shared primitive uses this to decide whether to provide its own floor:
65
+ *
66
+ * ```tsx
67
+ * const insideMenu = useIsInsideContextMenu();
68
+ * return insideMenu ? field : <EditableContextMenu …>{field}</EditableContextMenu>;
69
+ * ```
70
+ *
71
+ * Do NOT use it to change what a menu CONTAINS — only whether a primitive
72
+ * mounts one at all. Content decisions belong to the surface.
73
+ */
74
+ declare function useIsInsideContextMenu(): boolean;
75
+ declare const RegistryMenuSourceProvider: React.Provider<ContentSource | null>;
76
+ declare function useRegistryMenuSource(): ContentSource | null;
77
+ /** Two sources name the same content (type + every identifying id). */
78
+ declare function sameContentSource(a: ContentSource | null | undefined, b: ContentSource | null | undefined): boolean;
79
+ /**
80
+ * A content source's identity as one string (every identifying field, the
81
+ * read-only flag excluded). The shell stamps it on its trigger
82
+ * (`data-content-source`) so a ⋯ button can open the ONE menu that carries its
83
+ * content even when the button renders beside that content, not inside it.
84
+ */
85
+ declare function contentSourceKey(s: ContentSource): string;
86
+
87
+ interface MenuResolutionReport {
88
+ target: ClickTarget;
89
+ /** Exactly what the registry resolved for this open — before any grouping. */
90
+ resolved: readonly ResolvedAction[];
91
+ arrangement: ContextMenuLayout;
92
+ }
93
+ interface MenuRegroupValue {
94
+ /** null = draw the menu as it is today (report only). */
95
+ grouping: MenuGrouping | null;
96
+ mergeSameName: boolean;
97
+ /**
98
+ * Arrange the resolved rows with a function instead of a grouping (the proposed menu,
99
+ * `../proposed/proposed-arrangement.ts`). Wins over `grouping`.
100
+ */
101
+ transform?: ((target: ClickTarget, resolved: readonly ResolvedAction[]) => ResolvedAction[]) | undefined;
102
+ /** The menu's size and whether it draws its header line (the proposed menu: large, none). */
103
+ size?: "standard" | "large" | undefined;
104
+ hideHeader?: boolean | undefined;
105
+ /** Called on every resolve of this menu; `close` shuts the open menu. */
106
+ onResolved?: ((report: MenuResolutionReport, close: () => void) => void) | undefined;
107
+ }
108
+ declare const MenuRegroupContext: React.Context<MenuRegroupValue | null>;
109
+ declare function MenuRegroupProvider({ value, children }: {
110
+ value: MenuRegroupValue;
111
+ children: React.ReactNode;
112
+ }): React.JSX.Element;
113
+ /** Wraps the menu renderer; a pass-through unless a MenuRegroupContext is above it. */
114
+ declare function RegroupBoundary({ arrangement, close, children, }: {
115
+ arrangement: ContextMenuLayout;
116
+ close: () => void;
117
+ children: React.ReactElement;
118
+ }): React.ReactElement;
119
+
120
+ declare function ItemMenuHostBinding({ children }: {
121
+ children: ReactNode;
122
+ }): React.JSX.Element;
123
+
124
+ declare function ItemContextMenuV3({ config, children, sourceFeature, surfaceName, entity, getApplicationScope, resolveItemOnOpen, onOpenChange, onCloseAutoFocus, }: ItemContextMenuProps): React.JSX.Element;
125
+
126
+ declare function OpenSurfaceMenuButton({ getSurface, label, className, }: {
127
+ /** The element the surface's context-menu shell wraps. */
128
+ getSurface: () => HTMLElement | null;
129
+ label?: string | undefined;
130
+ className?: string | undefined;
131
+ }): React.ReactElement;
132
+
133
+ export { ContextMenuV3, EditableContextMenu, ItemContextMenuV3, ItemMenuHostBinding, MenuPresenceProvider, MenuRegroupContext, MenuRegroupProvider, type MenuRegroupValue, type MenuResolutionReport, NonEditableContextMenu, OpenSurfaceMenuButton, PageSurfaceMenu, RegistryMenuSourceProvider, RegroupBoundary, contentSourceKey, reachedThroughPortal, sameContentSource, useIsInsideContextMenu, useRegistryMenuSource, warmMenuContent };