@dxos/react-ui-menu 0.8.4-main.ead640a → 0.8.4-main.effb148878

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 (64) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/index.mjs +542 -420
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/translations.mjs +14 -0
  6. package/dist/lib/browser/translations.mjs.map +7 -0
  7. package/dist/lib/node-esm/index.mjs +542 -420
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/lib/node-esm/translations.mjs +16 -0
  11. package/dist/lib/node-esm/translations.mjs.map +7 -0
  12. package/dist/types/src/builder.d.ts +27 -2
  13. package/dist/types/src/builder.d.ts.map +1 -1
  14. package/dist/types/src/builder.test.d.ts +2 -0
  15. package/dist/types/src/builder.test.d.ts.map +1 -0
  16. package/dist/types/src/components/ActionLabel.d.ts +3 -3
  17. package/dist/types/src/components/ActionLabel.d.ts.map +1 -1
  18. package/dist/types/src/components/DropdownMenu.d.ts +4 -2
  19. package/dist/types/src/components/DropdownMenu.d.ts.map +1 -1
  20. package/dist/types/src/components/Menu.d.ts +50 -0
  21. package/dist/types/src/components/Menu.d.ts.map +1 -0
  22. package/dist/types/src/components/Menu.stories.d.ts +21 -0
  23. package/dist/types/src/components/Menu.stories.d.ts.map +1 -0
  24. package/dist/types/src/components/Menu.test.d.ts +2 -0
  25. package/dist/types/src/components/Menu.test.d.ts.map +1 -0
  26. package/dist/types/src/components/ToolbarMenu.d.ts +7 -6
  27. package/dist/types/src/components/ToolbarMenu.d.ts.map +1 -1
  28. package/dist/types/src/components/ToolbarMenu.stories.d.ts +16 -2
  29. package/dist/types/src/components/ToolbarMenu.stories.d.ts.map +1 -1
  30. package/dist/types/src/components/index.d.ts +1 -3
  31. package/dist/types/src/components/index.d.ts.map +1 -1
  32. package/dist/types/src/hooks/useMenuActions.d.ts +15 -7
  33. package/dist/types/src/hooks/useMenuActions.d.ts.map +1 -1
  34. package/dist/types/src/index.d.ts +1 -2
  35. package/dist/types/src/index.d.ts.map +1 -1
  36. package/dist/types/src/testing/generator.d.ts +20 -14
  37. package/dist/types/src/testing/generator.d.ts.map +1 -1
  38. package/dist/types/src/translations.d.ts +2 -2
  39. package/dist/types/src/translations.d.ts.map +1 -1
  40. package/dist/types/src/types.d.ts +38 -27
  41. package/dist/types/src/types.d.ts.map +1 -1
  42. package/dist/types/src/util.d.ts +15 -6
  43. package/dist/types/src/util.d.ts.map +1 -1
  44. package/dist/types/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +45 -33
  46. package/src/builder.test.ts +224 -0
  47. package/src/builder.ts +69 -19
  48. package/src/components/ActionLabel.tsx +7 -6
  49. package/src/components/DropdownMenu.tsx +12 -6
  50. package/src/components/Menu.stories.tsx +266 -0
  51. package/src/components/Menu.test.tsx +447 -0
  52. package/src/components/Menu.tsx +348 -0
  53. package/src/components/ToolbarMenu.stories.tsx +50 -28
  54. package/src/components/ToolbarMenu.tsx +148 -90
  55. package/src/components/index.ts +1 -3
  56. package/src/hooks/useMenuActions.ts +39 -55
  57. package/src/index.ts +1 -3
  58. package/src/testing/generator.ts +74 -64
  59. package/src/translations.ts +1 -1
  60. package/src/types.ts +39 -27
  61. package/src/util.ts +35 -16
  62. package/dist/types/src/components/MenuContext.d.ts +0 -13
  63. package/dist/types/src/components/MenuContext.d.ts.map +0 -1
  64. package/src/components/MenuContext.tsx +0 -50
@@ -2,12 +2,14 @@ import { type StoryObj } from '@storybook/react-vite';
2
2
  import React from 'react';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: ({ __menuScope, classNames, textBlockWidth: wrapContents, ...props }: import("./MenuContext").MenuScopedProps<import("./ToolbarMenu").ToolbarMenuProps>) => React.JSX.Element;
5
+ component: React.ForwardRefExoticComponent<Omit<import("./Menu").MenuScopedProps<import("@dxos/react-ui").ToolbarRootProps>, "className"> & {
6
+ classNames?: import("@dxos/ui-types").ClassNameValue;
7
+ } & Pick<React.HTMLAttributes<Element>, "children" | "className" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
6
8
  decorators: import("@storybook/react").Decorator[];
7
9
  parameters: {
8
10
  translations: [{
9
11
  readonly 'en-US': {
10
- readonly "react-ui-menu": {};
12
+ readonly "@dxos/react-ui-menu": {};
11
13
  };
12
14
  }];
13
15
  };
@@ -16,5 +18,17 @@ export default meta;
16
18
  type Story = StoryObj<typeof meta>;
17
19
  export declare const DropdownMenu: Story;
18
20
  export declare const Toolbar: Story;
21
+ /**
22
+ * Reactive toolbar driven by an atom-backed actions hook.
23
+ *
24
+ * Defining actions inside a hook lets them subscribe to reactive state
25
+ * (echo, atoms, settings) without re-rendering the toolbar shell.
26
+ * The menu structure is data, not JSX.
27
+ *
28
+ * @idiom org.dxos.react-ui-menu.toolbarMenu
29
+ * applies: Toolbars whose entries depend on reactive state
30
+ * instead-of: Hand-wired children inside a bespoke `Toolbar.Root`
31
+ * uses: {@link useMenuActions}, {@link Menu.Root}, {@link Menu.Toolbar}
32
+ */
19
33
  export declare const UseMenuActionsToolbar: Story;
20
34
  //# sourceMappingURL=ToolbarMenu.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarMenu.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/ToolbarMenu.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAA+B,MAAM,OAAO,CAAC;AAcpD,QAAA,MAAM,IAAI;;;;;;;;;;;CAO0B,CAAC;AAErC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,YAAY,EAAE,KAgB1B,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAUrB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAUnC,CAAC"}
1
+ {"version":3,"file":"ToolbarMenu.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/ToolbarMenu.stories.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAA8B,MAAM,OAAO,CAAC;AAenD,QAAA,MAAM,IAAI;;;;;;;;;;;;;CAO2B,CAAC;eAEvB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,YAAY,EAAE,KAsB1B,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAWrB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAWnC,CAAC"}
@@ -1,4 +1,2 @@
1
- export * from './DropdownMenu';
2
- export * from './ToolbarMenu';
3
- export * from './MenuContext';
1
+ export * from './Menu';
4
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC"}
@@ -1,14 +1,22 @@
1
- import { type Rx } from '@effect-rx/rx-react';
2
- import { type Edge, type NodeArg } from '@dxos/app-graph';
3
- import { type MenuItem, type MenuItemGroup } from '../types';
4
- export type ActionGraphNodes = NodeArg<any>[];
5
- export type ActionGraphEdges = Edge[];
1
+ import { Atom } from '@effect-atom/atom-react';
2
+ import { type DependencyList } from 'react';
3
+ import { Graph, Node } from '@dxos/app-graph';
4
+ import { type MenuItemsAccessor } from '../types';
5
+ export type ActionGraphNodes = Node.NodeArg<any>[];
6
+ export type ActionGraphEdges = Graph.Edge[];
6
7
  export type ActionGraphProps = {
7
8
  nodes: ActionGraphNodes;
8
9
  edges: ActionGraphEdges;
9
10
  };
10
11
  export type MenuActions = {
11
- useGroupItems: (sourceNode?: MenuItemGroup) => MenuItem[];
12
+ items: MenuItemsAccessor;
12
13
  };
13
- export declare const useMenuActions: (props: Rx.Rx<ActionGraphProps>) => MenuActions;
14
+ export declare const useMenuActions: (props: Atom.Atom<ActionGraphProps>) => MenuActions;
15
+ /**
16
+ * Convenience wrapper around `useMenuActions` that creates the backing atom inline.
17
+ * Pass a builder thunk and a dependency list — the hook memoizes `Atom.make(build)` and threads
18
+ * it through `useMenuActions`. Saves the `useMemo(() => Atom.make(...), deps)` boilerplate when
19
+ * the action graph is composed from local state (e.g. a toolbar driven by component state).
20
+ */
21
+ export declare const useMenuBuilder: (build: (get: Atom.Context) => ActionGraphProps, deps: DependencyList) => MenuActions;
14
22
  //# sourceMappingURL=useMenuActions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMenuActions.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useMenuActions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,KAAK,EAAE,EAAc,MAAM,qBAAqB,CAAC;AAG3E,OAAO,EAAE,KAAK,IAAI,EAAgC,KAAK,OAAO,EAAW,MAAM,iBAAiB,CAAC;AAEjG,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AA6B7D,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AAC9C,MAAM,MAAM,gBAAgB,GAAG,IAAI,EAAE,CAAC;AACtC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IAAE,aAAa,EAAE,CAAC,UAAU,CAAC,EAAE,aAAa,KAAK,QAAQ,EAAE,CAAA;CAAE,CAAC;AAExF,eAAO,MAAM,cAAc,GAAI,OAAO,EAAE,CAAC,EAAE,CAAC,gBAAgB,CAAC,KAAG,WA0B/D,CAAC"}
1
+ {"version":3,"file":"useMenuActions.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useMenuActions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAiC,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,KAAK,cAAc,EAAoC,MAAM,OAAO,CAAC;AAE9E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAqC,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAErF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AACnD,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;AAC5C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,iBAAiB,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAG,WAuBnE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,UAAW,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,KAAK,gBAAgB,QAAQ,cAAc,KAAG,WAIrG,CAAC"}
@@ -1,7 +1,6 @@
1
- export { rxFromSignal } from '@dxos/app-graph';
2
1
  export * from './components';
3
2
  export * from './hooks';
4
3
  export * from './types';
5
4
  export { createMenuAction, createMenuItemGroup, createLineSeparator, createGapSeparator } from './util';
6
- export { MenuBuilder } from './builder';
5
+ export { type ActionGroupBuilder, type ActionGroupBuilderFn, MenuBuilder } from './builder';
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACxG,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
@@ -1,27 +1,33 @@
1
- import { Rx } from '@effect-rx/rx-react';
2
- import { ACTION_GROUP_TYPE, ACTION_TYPE, type Action } from '@dxos/app-graph';
1
+ import { Atom, Registry } from '@effect-atom/atom-react';
2
+ import { Node } from '@dxos/app-graph';
3
3
  import { type ActionGraphProps } from '../hooks/useMenuActions';
4
- import { type MenuAction, type MenuItem, type MenuItemGroup } from '../types';
5
- export type CreateActionsParams = Partial<{
6
- type?: typeof ACTION_TYPE | typeof ACTION_GROUP_TYPE;
4
+ import { type MenuItemsAccessor } from '../types';
5
+ export type CreateActionsProps = Partial<{
6
+ type?: typeof Node.ActionType | typeof Node.ActionGroupType;
7
7
  callback: () => void;
8
8
  count: number;
9
9
  }>;
10
- export declare const createActions: (params?: CreateActionsParams) => import("@dxos/live-object").Live<{
10
+ export declare const createActions: (params?: CreateActionsProps) => {
11
11
  id: string;
12
- type: "dxos.org/type/GraphActionGroup" | "dxos.org/type/GraphAction";
12
+ type: "org.dxos.type.graphAction" | "org.dxos.type.graphActionGroup";
13
13
  data: symbol | (() => void);
14
14
  properties: {
15
- variant?: string | undefined;
16
15
  label: string;
17
16
  icon: string;
18
17
  disabled: boolean;
18
+ variant?: string | undefined;
19
19
  };
20
- }>[];
21
- export declare const createNestedActions: Rx.Rx<ActionGraphProps>;
22
- export declare const createNestedActionsResolver: (groupParams?: CreateActionsParams, params?: CreateActionsParams) => {
23
- resolveGroupItems: (groupNode?: MenuItemGroup) => MenuItem[] | null;
20
+ }[];
21
+ export declare const createNestedActions: Atom.Writable<ActionGraphProps, ActionGraphProps>;
22
+ export declare const createNestedActionsResolver: (props?: {
23
+ groupParams?: CreateActionsProps;
24
+ params?: CreateActionsProps;
25
+ registry?: Registry.Registry;
26
+ }) => {
27
+ items: MenuItemsAccessor;
24
28
  };
25
- export declare const mutateActionsOnInterval: (actions: Action[]) => NodeJS.Timeout;
26
- export declare const useMutateActions: (actions: MenuAction[]) => void;
29
+ /**
30
+ * Hook to mutate actions in an atom on an interval for testing reactivity.
31
+ */
32
+ export declare const useMutateActions: (actionsAtom: Atom.Writable<ActionGraphProps>) => void;
27
33
  //# sourceMappingURL=generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../src/testing/generator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAGzC,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,KAAK,MAAM,EAKZ,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9E,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC;IACxC,IAAI,CAAC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C,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC;CAC9B;;CAkBA,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,gBAAiB,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SA0B5E,CAAC"}
@@ -1,7 +1,7 @@
1
- export declare const translationKey = "react-ui-menu";
1
+ export declare const translationKey = "@dxos/react-ui-menu";
2
2
  export declare const translations: [{
3
3
  readonly 'en-US': {
4
- readonly "react-ui-menu": {};
4
+ readonly "@dxos/react-ui-menu": {};
5
5
  };
6
6
  }];
7
7
  //# sourceMappingURL=translations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAE9C,eAAO,MAAM,YAAY;;;;EAMM,CAAC"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,eAAO,MAAM,YAAY;;;;EAMM,CAAC"}
@@ -1,28 +1,13 @@
1
- import { type Action, type ActionGroup, type Node } from '@dxos/app-graph';
2
- import { type ClassNameValue, type IconButtonProps, type Label, type ToolbarSeparatorProps } from '@dxos/react-ui';
3
- export type MenuActionProperties = {
4
- label: Label;
5
- icon?: string;
6
- value?: string;
7
- disabled?: boolean;
8
- hidden?: boolean;
9
- iconOnly?: boolean;
10
- testId?: string;
11
- variant?: 'action' | 'toggle';
12
- checked?: boolean;
13
- classNames?: ClassNameValue;
14
- };
15
- export type MenuItemGroupProperties = {
16
- label: Label;
17
- icon?: string;
18
- iconOnly?: boolean;
19
- };
20
- export type MenuAction<P extends {} = {}> = Action<P & MenuActionProperties>;
21
- export declare const MenuSeparatorType: "@dxos/react-ui-toolbar/separator";
22
- export type MenuSeparator = Node<never, Pick<ToolbarSeparatorProps, 'variant'>> & {
1
+ import { type Atom } from '@effect-atom/atom-react';
2
+ import { Node } from '@dxos/app-graph';
3
+ import { type IconButtonProps, type ToolbarSeparatorProps } from '@dxos/react-ui';
4
+ import { type MenuActionProperties } from '@dxos/ui-types';
5
+ export type MenuAction<P extends {} = {}> = Node.Action<P & MenuActionProperties>;
6
+ export declare const MenuSeparatorType: '@dxos/react-ui-toolbar/separator';
7
+ export type MenuSeparator = Node.Node<never, Pick<ToolbarSeparatorProps, 'variant'>> & {
23
8
  type: typeof MenuSeparatorType;
24
9
  };
25
- export declare const isSeparator: (node: Node) => node is MenuSeparator;
10
+ export declare const isSeparator: (node: Node.Node) => node is MenuSeparator;
26
11
  export type MenuSingleSelectActionGroup = {
27
12
  selectCardinality: 'single';
28
13
  value: string;
@@ -31,13 +16,39 @@ export type MenuMultipleSelectActionGroup = {
31
16
  selectCardinality: 'multiple';
32
17
  value: string[];
33
18
  };
34
- export type MenuItemGroup<P extends Record<string, any> = Record<string, any>> = ActionGroup<P>;
35
- export declare const isMenuGroup: (node: Node) => node is MenuItemGroup;
19
+ export type MenuItemGroup<P extends Record<string, any> = Record<string, any>> = Node.ActionGroup<P>;
20
+ export declare const isMenuGroup: (node: Node.Node) => node is MenuItemGroup;
36
21
  export type MenuItem = MenuSeparator | MenuAction | MenuItemGroup;
37
- export type MenuItemsResolver = (group?: MenuItemGroup) => MenuItem[] | null;
22
+ /** Atom-family-style accessor: returns an atom of items for a given group (or root when undefined). */
23
+ export type MenuItemsAccessor = (group?: MenuItemGroup) => Atom.Atom<MenuItem[] | null>;
24
+ export type ActionExecutor = (action: MenuAction, params: Node.InvokeProps) => void;
25
+ export type MenuItemsMode = 'additive' | 'replacement';
26
+ export type AddMenuItemsProps = {
27
+ id: string;
28
+ mode: MenuItemsMode;
29
+ priority?: number;
30
+ items: MenuItem[];
31
+ groupFilter?: (group?: MenuItemGroup) => boolean;
32
+ };
33
+ export type MenuItems = Omit<AddMenuItemsProps, 'priority'> & {
34
+ priority: number;
35
+ };
36
+ export type MenuItemsMap = Map<string, MenuItems>;
38
37
  export type MenuContextValue = {
39
- useGroupItems: MenuItemsResolver;
38
+ /** Atom-family accessor for base menu items, keyed by group (similar to Tree model). */
39
+ items: MenuItemsAccessor;
40
40
  iconSize: IconButtonProps['size'];
41
41
  attendableId?: string;
42
+ /** TODO(burdon): Remove and assume always active if attendableId is undefined. */
43
+ /** If true, the menu is always active regardless of attention state. */
44
+ alwaysActive?: boolean;
45
+ /** Atom holding the current set of imperatively added menu items. */
46
+ menuItemsAtom: Atom.Atom<MenuItemsMap>;
47
+ /** Imperatively add menu items to the nearest MenuProvider. */
48
+ addMenuItems: (props: AddMenuItemsProps) => void;
49
+ /** Remove previously added menu items by id. */
50
+ removeMenuItems: (id: string) => void;
51
+ /** Optional action executor. If provided, will be used instead of default execution. */
52
+ onAction?: ActionExecutor;
42
53
  };
43
54
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqB,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,KAAK,KAAK,EAAE,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEnH,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC9B,OAAO,CAAC,EAA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AAY,CAAC,CAAC;IACvC,+DAA+D;IAC/D,YAAY,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACjD,gDAAgD;IAChD,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,wFAAwF;IACxF,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC"}
@@ -1,18 +1,25 @@
1
- import { type ActionLike, actionGroupSymbol } from '@dxos/app-graph';
2
- import { type MenuActionProperties, type MenuItemGroupProperties } from './types';
3
- export declare const getShortcut: (action: ActionLike) => any;
4
- export declare const fallbackIcon = "ph--placeholder--regular";
1
+ import * as Effect from 'effect/Effect';
2
+ import { Node } from '@dxos/app-graph';
3
+ import { type MenuActionProperties, type MenuItemGroupProperties } from '@dxos/ui-types';
4
+ import { type MenuAction } from './types';
5
+ /**
6
+ * Execute a menu action's Effect with its captured context.
7
+ * This provides the `_actionContext` layer if available.
8
+ */
9
+ export declare const executeMenuAction: (action: MenuAction, params?: Node.InvokeProps) => Promise<void>;
10
+ export declare const getShortcut: (action: Node.ActionLike) => any;
11
+ export declare const fallbackIcon = "ph--circle-dashed--regular";
5
12
  export declare const createMenuAction: <P extends {} = {}>(id: string, invoke: () => void, properties: P & MenuActionProperties) => {
6
13
  id: string;
7
14
  type: string;
8
15
  properties: P & MenuActionProperties;
9
- data: () => void;
16
+ data: () => Effect.Effect<void, never, never>;
10
17
  };
11
18
  export declare const createMenuItemGroup: <P extends MenuItemGroupProperties = MenuItemGroupProperties & Partial<MenuActionProperties>>(id: string, properties: P) => {
12
19
  id: string;
13
20
  type: string;
14
21
  properties: P;
15
- data: typeof actionGroupSymbol;
22
+ data: typeof Node.actionGroupSymbol;
16
23
  };
17
24
  export declare const createGapSeparator: (id?: string, source?: string) => {
18
25
  nodes: {
@@ -26,6 +33,7 @@ export declare const createGapSeparator: (id?: string, source?: string) => {
26
33
  edges: {
27
34
  source: string;
28
35
  target: string;
36
+ relation: 'child';
29
37
  }[];
30
38
  };
31
39
  export declare const createLineSeparator: (id?: string, source?: string) => {
@@ -40,6 +48,7 @@ export declare const createLineSeparator: (id?: string, source?: string) => {
40
48
  edges: {
41
49
  source: string;
42
50
  target: string;
51
+ relation: 'child';
43
52
  }[];
44
53
  };
45
54
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkC,KAAK,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGrG,OAAO,EAEL,KAAK,oBAAoB,EAEzB,KAAK,uBAAuB,EAE7B,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,WAAW,GAAI,QAAQ,UAAU,QAI7C,CAAC;AAEF,eAAO,MAAM,YAAY,6BAA6B,CAAC;AAEvD,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,EAAE,GAAG,EAAE,EAChD,IAAI,MAAM,EACV,QAAQ,MAAM,IAAI,EAClB,YAAY,CAAC,GAAG,oBAAoB;;;;gBADtB,IAAI;CAQK,CAAC;AAE1B,eAAO,MAAM,mBAAmB,GAC9B,CAAC,SAAS,uBAAuB,GAAG,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC,EAE3F,IAAI,MAAM,EACV,YAAY,CAAC;;;;;CAOa,CAAC;AAE7B,eAAO,MAAM,kBAAkB,GAAI,KAAI,MAAc,EAAE,SAAQ,MAAe;;;;;;;cAMrD,KAAK;;;;;;CAI5B,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAAI,KAAI,MAAe,EAAE,SAAQ,MAAe;;;;;;;cAMvD,KAAK;;;;;;CAI5B,CAAC"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC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