@dxos/react-ui-menu 0.16.0 → 0.17.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/dist/lib/index.mjs +592 -209
- package/dist/lib/index.mjs.map +1 -1
- package/dist/types/src/builder.d.ts +20 -1
- package/dist/types/src/builder.d.ts.map +1 -1
- package/dist/types/src/components/ActionMenu.d.ts.map +1 -1
- package/dist/types/src/components/ActionMenu.stories.d.ts +2 -0
- package/dist/types/src/components/ActionMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/ActionToolbar.d.ts +32 -8
- package/dist/types/src/components/ActionToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ActionToolbar.stories.d.ts +32 -3
- package/dist/types/src/components/ActionToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +3 -2
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -22
- package/src/builder.test.ts +28 -0
- package/src/builder.ts +71 -6
- package/src/components/ActionMenu.stories.tsx +38 -1
- package/src/components/ActionMenu.tsx +67 -7
- package/src/components/ActionToolbar.stories.tsx +533 -22
- package/src/components/ActionToolbar.tsx +440 -35
- package/src/hooks/useMenuActions.browser.test.tsx +6 -0
- package/src/index.ts +1 -1
package/dist/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["__dxlog_file","_Fragment","_Fragment","_Fragment"],"sources":["../../src/presentation.ts","../../src/hooks/useMenuActions.ts","../../src/hooks/useGraphMenuActions.ts","../../src/types.ts","../../src/util.ts","../../src/components/ActionMenu.tsx","../../src/components/action-label.ts","../../src/components/ActionLabel.tsx","../../src/components/ActionToolbar.tsx","../../src/components/ViewOptionsMenu.tsx","../../src/builder.ts","../../src/toolbar.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport { type MenuActionProperties } from '@dxos/ui-types';\n\n/**\n * Merges an action's `presentation[surface]` chrome override (if any) into its properties, letting a\n * single action declare multiple dispositions yet render appropriately in each surface — e.g. a\n * primary toolbar button and a plain nav-tree row from the same definition.\n */\nexport const applyPresentation = <A extends AppGraphNode.ActionLike>(action: A, surface: string): A => {\n const presentation = (action.properties as MenuActionProperties).presentation?.[surface];\n if (!presentation) {\n return action;\n }\n return { ...action, properties: { ...action.properties, ...presentation } };\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { useAtomValue } from '@effect/atom-react/Hooks';\nimport { RegistryContext } from '@effect/atom-react/RegistryContext';\nimport * as Atom from 'effect/reactivity/Atom';\nimport { type DependencyList, useCallback, useContext, useEffect, useLayoutEffect, useMemo } from 'react';\n\nimport * as AppGraph from '@dxos/app-graph/AppGraph';\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport * as GraphNode from '@dxos/graph/GraphNode';\nimport { log } from '@dxos/log';\n\nimport {\n type AddMenuItemsProps,\n type MenuActions,\n type MenuActionsOptions,\n type MenuGroupContext,\n type MenuItem,\n type MenuItemGroup,\n type MenuItems,\n type MenuItemsAccessor,\n type MenuItemsMap,\n} from '../types.ts';\n\nexport type ActionGraphNodes = AppGraphNode.NodeArg<any>[];\nexport type ActionGraphEdges = AppGraph.Edge[];\nexport type ActionGraphProps = {\n nodes: ActionGraphNodes;\n edges: ActionGraphEdges;\n};\n\nconst DEFAULT_PRIORITY = 100;\n\nconst EMPTY_GRAPH = Atom.make<ActionGraphProps>({ nodes: [], edges: [] });\n\n/**\n * The graph behind a menu, rebuilt when `deps` change. Its nodes stay pinned while the menu is mounted,\n * taken on commit so a render React discards leaves nothing behind.\n */\nexport const useMenuGraph = <G extends AppGraph.BaseGraph | undefined>(build: () => G, deps: DependencyList): G => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const graph = useMemo(build, deps);\n useLayoutEffect(() => (graph ? AppGraph.retain(graph) : undefined), [graph]);\n return graph;\n};\n\n/** A `MenuActions` over a given accessor, for sources that are not an action graph (tests, fixtures). */\nexport const makeMenuActions = ({\n items,\n ...options\n}: { items: MenuItemsAccessor } & MenuActionsOptions): MenuActions => ({\n items,\n contributions: Atom.make<MenuItemsMap>(new Map()),\n ...options,\n});\n\n/**\n * The menu over an action graph. Omit `props` for a menu with no items of its own, filled entirely by\n * contributions (a card whose actions its children register).\n */\nexport const useMenuActions = (\n props: Atom.Atom<ActionGraphProps> = EMPTY_GRAPH,\n options: MenuActionsOptions = {},\n): MenuActions => {\n const registry = useContext(RegistryContext);\n const menuGraphProps = useAtomValue(props);\n\n // Create a new graph whenever props change to preserve correct order.\n // (AppGraph.addEdges appends rather than replaces, which breaks ordering on updates.)\n // NOTE: Using useMemo rather than a ref-mutation pattern to avoid calling registry.set during render,\n // which would trigger atom state updates in other components (setState-in-render React warning).\n const graph = useMenuGraph(() => {\n const newGraph = AppGraph.make({ registry });\n AppGraph.addNodes(newGraph, menuGraphProps.nodes as AppGraphNode.NodeArg<any>[]);\n AppGraph.addEdges(newGraph, menuGraphProps.edges);\n return newGraph;\n }, [registry, menuGraphProps]);\n\n const items: MenuItemsAccessor = useCallback(\n (group?: MenuItemGroup) => {\n // TODO(wittjosiah): Migrate to using action relation instead of child.\n return graph.connections(group?.id || GraphNode.RootId, 'child') as Atom.Atom<MenuItem[] | null>;\n },\n [graph],\n );\n\n const contributions = useMemo(() => Atom.make<MenuItemsMap>(new Map()), []);\n // A layout effect, so it is mounted before any contributor's effect writes to it.\n useLayoutEffect(() => registry.mount(contributions), [registry, contributions]);\n\n const { onAction, caller, iconSize } = options;\n return useMemo(\n () => ({ items, contributions, onAction, caller, iconSize }),\n [items, contributions, onAction, caller, iconSize],\n );\n};\n\n/**\n * Convenience wrapper around `useMenuActions` that creates the backing atom inline.\n * Pass a builder thunk and a dependency list — the hook memoizes `Atom.make(build)` and threads\n * it through `useMenuActions`. Saves the `useMemo(() => Atom.make(...), deps)` boilerplate when\n * the action graph is composed from local state (e.g. a toolbar driven by component state).\n *\n * Read reactive state via `get` inside the builder; `deps` should hold only stable references.\n */\nexport const useMenuBuilder = (\n build: (get: Atom.AtomContext) => ActionGraphProps,\n deps: DependencyList,\n options?: MenuActionsOptions,\n): MenuActions => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const atom = useMemo(() => Atom.make(build), deps);\n return useMenuActions(atom, options);\n};\n\n//\n// Contributions\n//\n\n/**\n * Registers items with a menu another component owns, for as long as the caller is mounted. The\n * owner hands its `MenuActions` down (props or its own context); there is no menu provider.\n */\nexport const useMenuContribution = (menu: MenuActions | undefined, props: AddMenuItemsProps): void => {\n const registry = useContext(RegistryContext);\n const { id, mode, priority = DEFAULT_PRIORITY, items, groupFilter } = props;\n\n useEffect(() => {\n if (!menu) {\n return;\n }\n const update = (change: (previous: MenuItemsMap) => MenuItemsMap) =>\n registry.set(menu.contributions, change(registry.get(menu.contributions)));\n update((previous) => new Map(previous).set(id, { id, mode, priority, items, groupFilter }));\n return () =>\n update((previous) => {\n const next = new Map(previous);\n next.delete(id);\n return next;\n });\n }, [registry, menu, id, mode, priority, items, groupFilter]);\n};\n\n//\n// Item resolution\n//\n\nconst sortMenuItems = (items: MenuItems[]) =>\n [...items].sort((a, b) => (a.priority !== b.priority ? a.priority - b.priority : a.id.localeCompare(b.id)));\n\nexport const resolveItems = (\n baseItems: MenuItem[] | null,\n group: MenuGroupContext | undefined,\n entries: ReadonlyMap<string, MenuItems>,\n): MenuItem[] | null => {\n const applicable = [...entries.values()].filter((entry) => !entry.groupFilter || entry.groupFilter(group));\n if (applicable.length === 0) {\n return baseItems;\n }\n\n const sorted = sortMenuItems(applicable);\n\n const replacements = sorted.filter((entry) => entry.mode === 'replacement');\n if (replacements.length > 0) {\n if (replacements.length > 1) {\n log.warn('multiple replacement entries found', {\n ids: replacements.map((r) => r.id).join(', '),\n using: replacements[0].id,\n });\n }\n return replacements[0].items;\n }\n\n const additive = sorted.filter((entry) => entry.mode === 'additive');\n const additiveItems = additive.flatMap((entry) => entry.items);\n\n if (!baseItems || baseItems.length === 0) {\n return additiveItems.length > 0 ? additiveItems : null;\n }\n\n return [...baseItems, ...additiveItems];\n};\n\n/**\n * A group's items (the root's when `group` is undefined), with the menu's contributions applied;\n * `propsItems` stands in for the group's own items when given.\n */\nexport const useMenuItems = (\n menu: MenuActions,\n group?: MenuGroupContext,\n propsItems?: MenuItem[],\n): MenuItem[] | undefined => {\n const groupItems = useAtomValue(menu.items(group));\n const entries = useAtomValue(menu.contributions);\n const baseItems = useMemo(() => propsItems ?? groupItems ?? null, [propsItems, groupItems]);\n const resolved = useMemo(() => resolveItems(baseItems, group, entries), [baseItems, group, entries]);\n return resolved ?? undefined;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Atom from 'effect/reactivity/Atom';\nimport { useMemo } from 'react';\n\nimport type * as AppGraph from '@dxos/app-graph/AppGraph';\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport * as GraphNode from '@dxos/graph/GraphNode';\n\nimport { applyPresentation } from '../presentation.ts';\nimport { type MenuActions, type MenuActionsOptions } from '../types.ts';\nimport {\n type ActionGraphEdges,\n type ActionGraphNodes,\n type ActionGraphProps,\n useMenuActions,\n} from './useMenuActions.ts';\n\nexport type GraphMenuOptions = {\n /** Group the actions descend from. Defaults to the menu root (top-level toolbar items). */\n rootId?: string;\n /** Keep only the actions the predicate accepts (e.g. by `disposition`). */\n filter?: (action: AppGraphNode.ActionLike) => boolean;\n /**\n * Disposition key this surface renders — when set, each action's `presentation[surface]` chrome\n * override (if any) is merged into its properties, letting one action multi-target dispositions\n * (e.g. `['toolbar', 'list-item']`) with per-surface chrome.\n */\n surface?: string;\n};\n\n/**\n * Flatten a node's contributed actions (and nested {@link AppGraphNode.ActionGroup}s) into the\n * `{ nodes, edges }` an {@link useMenuActions} / `Menu` consumes. The action nodes are spliced\n * verbatim, so their Effect `data` (and captured `_actionContext`) execute via `executeMenuAction`\n * without any `onAction` wiring.\n *\n * Pure over a `resolve` function so it is testable without a live graph; `resolve(id)` returns the\n * direct actions for `id` (a node id at the top level, a group id when expanding a group).\n */\nexport const buildGraphMenu = (\n resolve: (id: string) => AppGraphNode.ActionLike[],\n nodeId: string,\n options: GraphMenuOptions = {},\n): ActionGraphProps => {\n const { rootId = GraphNode.RootId, filter, surface } = options;\n const nodes: ActionGraphNodes = [];\n const edges: ActionGraphEdges = [];\n const seen = new Set<string>();\n\n const visit = (parentId: string, sourceId: string) => {\n for (const action of resolve(sourceId)) {\n if (filter && !filter(action)) {\n continue;\n }\n // Always record the parent→child edge (a shared action may sit under multiple groups).\n edges.push({ source: parentId, target: action.id, relation: 'child' });\n if (seen.has(action.id)) {\n continue;\n }\n seen.add(action.id);\n nodes.push((surface ? applyPresentation(action, surface) : action) as ActionGraphNodes[number]);\n // A group's children are the actions contributed for the group's own id.\n if (AppGraphNode.isActionGroup(action)) {\n visit(action.id, action.id);\n }\n }\n };\n\n visit(rootId, nodeId);\n return { nodes, edges };\n};\n\n/**\n * Read a node's contributed actions from the app-graph as menu `ActionGraphProps`, for splicing into a\n * hand-built toolbar via `MenuBuilder.subgraph(graphActions(graph, get, nodeId))`. Reactive: reads the\n * graph's action atoms through `get`, so contributed actions appear/disappear as extensions update.\n *\n * @idiom org.dxos.react-ui-menu.graphActionsToolbar\n * applies: Splicing a node's app-graph-contributed toolbar actions into a hand-built object toolbar\n * instead-of: Reading `graph.actions(nodeId)` and filtering/wiring `nodes`/`edges` by hand in every toolbar\n * uses: {@link graphActions}, {@link MenuBuilder}, {@link useMenuBuilder}\n * related: org.dxos.react-ui-menu.toolbarMenu\n */\nexport const graphActions = (\n graph: AppGraph.ReadableGraph | undefined,\n get: Atom.AtomContext,\n nodeId: string | undefined,\n options?: GraphMenuOptions,\n): ActionGraphProps =>\n graph && nodeId ? buildGraphMenu((id) => get(graph.actions(id)), nodeId, options) : { nodes: [], edges: [] };\n\n/**\n * Menu actions sourced entirely from a node's app-graph contributions — the common \"show every action\n * the graph offers for this object\" toolbar/menu. Compose with hand-built items via {@link graphActions}.\n */\nexport const useGraphMenuActions = (\n graph: AppGraph.ReadableGraph | undefined,\n nodeId: string | undefined,\n options?: GraphMenuOptions & MenuActionsOptions,\n): MenuActions => {\n const atom = useMemo(\n () => Atom.make((get) => graphActions(graph, get, nodeId, options)),\n // `options` is expected to be stable; `rootId` participates since it reshapes the graph.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [graph, nodeId, options?.rootId],\n );\n return useMenuActions(atom, options);\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Atom from 'effect/reactivity/Atom';\n\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport type * as Toolbar from '@dxos/react-ui/Toolbar';\nimport type * as Util from '@dxos/react-ui/Util';\nimport {\n type DropdownMenuItemGroupProperties,\n type MenuActionProperties,\n type ToggleGroupMenuItemGroupProperties,\n} from '@dxos/ui-types';\n\nexport type MenuAction<P extends {} = {}> = AppGraphNode.Action<P & MenuActionProperties>;\n\nexport const MenuSeparatorType = '@dxos/react-ui-toolbar/separator' as const;\n\nexport type MenuSeparator = AppGraphNode.Node<never, Pick<Toolbar.SeparatorProps, 'variant'>> & {\n type: typeof MenuSeparatorType;\n};\n\nexport const isSeparator = (node: AppGraphNode.Node): node is MenuSeparator => node.type === MenuSeparatorType;\n\nexport type MenuItemGroup<P extends Record<string, any> = Record<string, any>> = AppGraphNode.ActionGroup<P>;\n\nexport const isMenuGroup = (node: AppGraphNode.Node): node is MenuItemGroup =>\n node.type === AppGraphNode.ActionGroupType;\n\n/** Graph-sourced menu nodes carry plugin-specific properties validated at runtime. */\nexport type GraphMenuItem = AppGraphNode.Action | AppGraphNode.ActionGroup;\n\nexport type MenuItem = MenuSeparator | MenuAction | MenuItemGroup | GraphMenuItem;\n\n/** Group context for graph-backed dropdown menus (any graph node, not only action groups). */\nexport type MenuGroupContext = MenuItemGroup | AppGraphNode.Node;\n\n/** Atom-family-style accessor: returns an atom of items for a given group (or root when undefined). */\nexport type MenuItemsAccessor = (group?: MenuGroupContext) => Atom.Atom<MenuItem[] | null>;\n\nexport type ActionExecutor = (action: MenuAction, params: AppGraphNode.InvokeProps) => void;\n\nexport type MenuItemsMode = 'additive' | 'replacement';\n\nexport type AddMenuItemsProps = {\n id: string;\n mode: MenuItemsMode;\n priority?: number;\n items: MenuItem[];\n groupFilter?: (group?: MenuGroupContext) => boolean;\n};\n\nexport type MenuItems = Omit<AddMenuItemsProps, 'priority'> & { priority: number };\nexport type MenuItemsMap = Map<string, MenuItems>;\n\n/** How an action runs when a builder invokes it; overrides the node's own Effect. */\nexport type MenuActionsOptions = {\n onAction?: ActionExecutor;\n /** Identifies the component that owns the menu (passed to action handlers). */\n caller?: string;\n iconSize?: Util.Size;\n};\n\n/**\n * Everything a builder needs to render a menu: where its items come from, how they run, and the\n * registry other components contribute to. Produced by `useMenuActions` and its wrappers, spread\n * onto `ActionToolbar` / `ActionMenu`.\n */\nexport type MenuActions = MenuActionsOptions & {\n /** Atom-family accessor for base menu items, keyed by group (similar to Tree model). */\n items: MenuItemsAccessor;\n /** The set of imperatively contributed items (see `useMenuContribution`). */\n contributions: Atom.Writable<MenuItemsMap>;\n};\n\n/** The group variants a toolbar renders: a dropdown trigger or a toggle group. */\nexport type ToolbarMenuActionGroupProperties = DropdownMenuItemGroupProperties | ToggleGroupMenuItemGroupProperties;\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport * as EffectEx from '@dxos/effect/EffectEx';\nimport { type MenuActionProperties, type MenuItemGroupProperties } from '@dxos/ui-types';\nimport { resolveKeyBinding } from '@dxos/util';\n\nimport { type MenuAction, type MenuItemGroup, type MenuSeparator } from './types.ts';\n\n/**\n * Execute a menu action's Effect with its captured context.\n * This provides the `_actionContext` layer if available.\n */\nexport const executeMenuAction = async (action: MenuAction, params: AppGraphNode.InvokeProps = {}): Promise<void> => {\n let effect = action.data(params);\n\n // Provide captured action context if available.\n if (action._actionContext) {\n effect = effect.pipe(Effect.provide(action._actionContext));\n }\n\n await EffectEx.runAndForwardErrors(effect);\n};\n\nexport const getShortcut = (action: AppGraphNode.ActionLike) => {\n return resolveKeyBinding(action.properties?.keyBinding);\n};\n\nexport const fallbackIcon = 'ph--circle-dashed--regular';\n\nexport const createMenuAction = <P extends {} = {}>(\n id: string,\n invoke: (params?: AppGraphNode.InvokeProps) => void,\n properties: P & MenuActionProperties,\n) =>\n ({\n id,\n type: AppGraphNode.ActionType,\n properties,\n data: (params?: AppGraphNode.InvokeProps) => Effect.sync(() => invoke(params)),\n }) satisfies MenuAction;\n\nexport const createMenuItemGroup = <P extends MenuItemGroupProperties>(id: string, properties: P) =>\n ({\n id,\n type: AppGraphNode.ActionGroupType,\n properties,\n data: AppGraphNode.actionGroupSymbol,\n }) satisfies MenuItemGroup;\n\nexport const createGapSeparator = (id: string = 'gap', source: string = 'root') => ({\n nodes: [\n {\n id,\n type: '@dxos/react-ui-toolbar/separator',\n properties: { variant: 'gap' },\n data: undefined as never,\n } satisfies MenuSeparator,\n ],\n edges: [\n {\n source,\n target: id,\n relation: 'child' as const,\n },\n ],\n});\n\nexport const createLineSeparator = (id: string = 'line', source: string = 'root') => ({\n nodes: [\n {\n id,\n type: '@dxos/react-ui-toolbar/separator',\n properties: { variant: 'line' },\n data: undefined as never,\n } satisfies MenuSeparator,\n ],\n edges: [{ source, target: id, relation: 'child' as const }],\n});\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React, {\n type MouseEvent,\n type ReactNode,\n type RefObject,\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n useState,\n} from 'react';\n\nimport { keySymbols } from '@dxos/react-focus';\nimport * as Hooks from '@dxos/react-ui/Hooks';\nimport * as Icon from '@dxos/react-ui/Icon';\nimport * as Menu from '@dxos/react-ui/Menu';\nimport * as Theme from '@dxos/react-ui/Theme';\nimport * as VirtualAnchor from '@dxos/react-ui/VirtualAnchor';\nimport { type MenuItemChrome } from '@dxos/ui-types';\nimport { resolveKeyBinding } from '@dxos/util';\n\nimport { translationKey } from '#translations';\n\nimport { useMenuActions, useMenuItems } from '../hooks/index.ts';\nimport {\n type MenuAction,\n type MenuActions,\n type MenuGroupContext,\n type MenuItem,\n type MenuItemGroup,\n isMenuGroup,\n isSeparator,\n} from '../types.ts';\nimport { executeMenuAction } from '../util.ts';\n\n//\n// Items (private): the graph's items as `Menu` parts.\n//\n\nconst isMultiSelect = (group?: MenuGroupContext): boolean => group?.properties?.selectCardinality === 'multiple';\n\n/** An action that declares `checked` is a select-group member (radio, or checkbox in a multi-select group). */\nconst isCheckable = (item: MenuItem): item is MenuAction =>\n !isSeparator(item) && !isMenuGroup(item) && typeof item.properties?.checked === 'boolean';\n\n/** The row data Next's item parts render: the localized label and the platform's shortcut glyphs. */\nconst useItemData = (\n id: string,\n properties: Pick<MenuItemChrome, 'label' | 'icon' | 'disabled' | 'keyBinding'>,\n): Menu.Option => {\n const { t } = Hooks.useTranslation(translationKey);\n const shortcut = resolveKeyBinding(properties.keyBinding);\n return {\n value: id,\n label: Theme.toLocalizedString(properties.label, t),\n icon: properties.icon,\n shortcut: shortcut ? keySymbols(shortcut).join('') : undefined,\n disabled: properties.disabled,\n };\n};\n\n/** Runs the action on click, which zag also dispatches for Enter, so keyboard and pointer share one path. */\nconst useInvoke = (menu: MenuActions, action: MenuAction, group?: MenuGroupContext) => {\n const { onAction, caller } = menu;\n return useCallback(\n (event: MouseEvent) => {\n if (action.properties?.disabled) {\n return;\n }\n event.stopPropagation();\n const params = { parent: group, caller, modifiers: { shift: event.shiftKey } };\n if (onAction) {\n onAction(action, params);\n } else {\n void executeMenuAction(action, params);\n }\n },\n [action, group, caller, onAction],\n );\n};\n\ntype ActionItemProps = {\n menu: MenuActions;\n action: MenuAction;\n group?: MenuGroupContext;\n};\n\nconst ItemIcon = ({ menu, action }: { menu: MenuActions; action: MenuAction | MenuItemGroup<MenuItemChrome> }) =>\n action.properties?.icon ? (\n <Menu.ItemIcon spin={action.properties.spin} size={menu.iconSize} classNames={action.properties.iconClassNames} />\n ) : null;\n\nconst ActionMenuItem = ({ menu, action, group }: ActionItemProps) => {\n const item = useItemData(action.id, action.properties);\n const handleClick = useInvoke(menu, action, group);\n return (\n <Menu.Item\n item={item}\n onClick={handleClick}\n // Picking several values from a multi-select group should not close the menu after the first.\n closeOnSelect={!isMultiSelect(group)}\n {...(action.properties?.testId && { 'data-testid': action.properties.testId })}\n >\n <ItemIcon menu={menu} action={action} />\n <Menu.ItemText />\n {item.shortcut && <Menu.ItemShortcut />}\n </Menu.Item>\n );\n};\n\nconst ActionCheckboxItem = ({ menu, action, group }: ActionItemProps) => {\n const item = useItemData(action.id, action.properties);\n const handleClick = useInvoke(menu, action, group);\n return (\n <Menu.CheckboxItem\n item={item}\n // The graph owns the state: the action flips it and the item re-renders from `checked`.\n checked={!!action.properties.checked}\n onClick={handleClick}\n closeOnSelect={false}\n {...(action.properties?.testId && { 'data-testid': action.properties.testId })}\n >\n <ItemIcon menu={menu} action={action} />\n <Menu.ItemText />\n <Menu.ItemIndicator />\n </Menu.CheckboxItem>\n );\n};\n\nconst ActionRadioItem = ({ menu, action, group }: ActionItemProps) => {\n const item = useItemData(action.id, action.properties);\n const handleClick = useInvoke(menu, action, group);\n return (\n <Menu.RadioItem\n item={item}\n onClick={handleClick}\n {...(action.properties?.testId && { 'data-testid': action.properties.testId })}\n >\n {/* Composed rather than the default row, so the icon takes the action's classes (a priority's hue). */}\n <ItemIcon menu={menu} action={action} />\n <Menu.ItemText />\n <Menu.ItemIndicator />\n </Menu.RadioItem>\n );\n};\n\n/** A group inside a menu is a submenu; its items resolve when it opens. */\nconst ActionSubMenu = ({ menu, group }: { menu: MenuActions; group: MenuItemGroup<MenuItemChrome> }) => {\n const item = useItemData(group.id, group.properties);\n return (\n <Menu.Sub>\n <Menu.TriggerItem\n item={item}\n disabled={group.properties.disabled}\n {...(group.properties.testId && { 'data-testid': group.properties.testId })}\n >\n <ItemIcon menu={menu} action={group} />\n <Menu.ItemText />\n <Icon.Icon icon='ph--caret-right--regular' />\n </Menu.TriggerItem>\n <Menu.Content>\n <ActionMenuItems menu={menu} group={group} />\n </Menu.Content>\n </Menu.Sub>\n );\n};\n\ntype Segment = { kind: 'item'; item: MenuItem } | { kind: 'radio'; id: string; actions: MenuAction[] };\n\n/**\n * Runs of checkable items in a single-select group become one radio group (Ark's radio items need one), whose value is\n * the member marked `checked`.\n */\nconst segment = (items: MenuItem[], multiple: boolean): Segment[] =>\n items.reduce<Segment[]>((segments, item) => {\n const last = segments.at(-1);\n if (multiple || !isCheckable(item)) {\n segments.push({ kind: 'item', item });\n } else if (last?.kind === 'radio') {\n last.actions.push(item);\n } else {\n segments.push({ kind: 'radio', id: item.id, actions: [item] });\n }\n return segments;\n }, []);\n\nconst ActionMenuEntry = ({ menu, item, group }: { menu: MenuActions; item: MenuItem; group?: MenuGroupContext }) => {\n if (isSeparator(item)) {\n return <Menu.Separator />;\n }\n if (isMenuGroup(item)) {\n // A graph group's properties are an open record, validated by the plugin that contributed them.\n return <ActionSubMenu menu={menu} group={item as MenuItemGroup<MenuItemChrome>} />;\n }\n const action = item as MenuAction;\n if (action.properties?.hidden) {\n return null;\n }\n return isCheckable(action) ? (\n <ActionCheckboxItem menu={menu} action={action} group={group} />\n ) : (\n <ActionMenuItem menu={menu} action={action} group={group} />\n );\n};\n\nconst ActionMenuItems = ({\n menu,\n group,\n actions,\n}: {\n menu: MenuActions;\n group?: MenuGroupContext;\n actions?: MenuItem[];\n}) => {\n const items = useMenuItems(menu, group, actions);\n const segments = useMemo(() => segment(items ?? [], isMultiSelect(group)), [items, group]);\n return (\n <>\n {segments.map((entry) =>\n entry.kind === 'radio' ? (\n <Menu.RadioItemGroup\n key={entry.id}\n value={entry.actions.find((action) => action.properties.checked)?.id ?? ''}\n >\n {entry.actions\n .filter((action) => !action.properties.hidden)\n .map((action) => (\n <ActionRadioItem key={action.id} menu={menu} action={action} group={group} />\n ))}\n </Menu.RadioItemGroup>\n ) : (\n <ActionMenuEntry key={entry.item.id} menu={menu} item={entry.item} group={group} />\n ),\n )}\n </>\n );\n};\n\n//\n// ActionMenu\n//\n\nexport type ActionMenuProps = Partial<MenuActions> & {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** The group whose items the menu shows; the root's when omitted. */\n group?: MenuGroupContext;\n /**\n * Explicit items in place of the group's own; contributions still apply. A thunk is called once the menu exists, so\n * a deferred menu does not build its items until it is opened.\n */\n actions?: MenuItem[] | (() => MenuItem[]);\n /**\n * Builds the menu on the trigger's first click rather than with the trigger, since each menu carries a state machine\n * and a list renders one per row. Ignored for a controlled or virtually-anchored menu, which may be opened from\n * anywhere and so cannot wait for its own trigger.\n */\n deferUntilOpen?: boolean;\n /** Anchors the content at an element that is not the trigger (open it under control); the child is then optional. */\n virtualRef?: RefObject<Element | null>;\n disabled?: boolean;\n /** Specify a container element to portal the content into. */\n container?: HTMLElement | null;\n /** The trigger. */\n children?: ReactNode;\n};\n\n/**\n * A whole `Menu.Root` driven from a `MenuActions`: the child is the trigger (`asChild`), the items come from the\n * graph; groups become `Sub` menus, `checked` members radio or checkbox items. Without a `MenuActions` it is a menu of\n * the explicit `actions` alone.\n */\nexport const ActionMenu = (props: ActionMenuProps) => {\n const { virtualRef, open, defaultOpen, onOpenChange, deferUntilOpen, children } = props;\n const [built, setBuilt] = useState(false);\n // Only a menu that owns its open state and renders its own trigger can wait for a click.\n const deferred = !!deferUntilOpen && !virtualRef && open === undefined && defaultOpen === undefined;\n const trigger = isValidElement<{\n 'onClick'?: (event: MouseEvent) => void;\n 'aria-haspopup'?: 'menu';\n 'aria-expanded'?: boolean;\n }>(children)\n ? children\n : undefined;\n\n const handleTriggerClick = useCallback(\n (event: MouseEvent) => {\n trigger?.props.onClick?.(event);\n setBuilt(true);\n onOpenChange?.(true);\n },\n [trigger, onOpenChange],\n );\n\n // Returned before the menu's hooks run, not just before its JSX: the menu's action graph and state machine are what\n // a list of rows cannot afford per row, and a deferred menu builds neither until its trigger is first clicked.\n if (deferred && !built && trigger) {\n return cloneElement(trigger, {\n 'onClick': handleTriggerClick,\n // The trigger announces itself as a menu button before the `Menu.Trigger` that would say so exists.\n 'aria-haspopup': 'menu',\n 'aria-expanded': false,\n });\n }\n\n return <ActionMenuRoot {...props} deferred={deferred} />;\n};\n\nconst ActionMenuRoot = ({\n items,\n contributions,\n onAction,\n caller,\n iconSize,\n group,\n actions,\n virtualRef,\n disabled,\n container,\n open,\n defaultOpen,\n onOpenChange,\n deferred,\n children,\n}: ActionMenuProps & { deferred: boolean }) => {\n // Called unconditionally (hooks), used only when no source was spread in.\n const standalone = useMenuActions();\n const menu = useMemo<MenuActions>(\n () => ({\n items: items ?? standalone.items,\n contributions: contributions ?? standalone.contributions,\n onAction,\n caller,\n iconSize,\n }),\n [items, contributions, onAction, caller, iconSize, standalone],\n );\n\n // Next's Content portals into a ref.\n const containerRef = useMemo(() => (container ? { current: container } : undefined), [container]);\n\n const positioning = VirtualAnchor.useVirtualAnchor(virtualRef);\n\n return (\n <Menu.Root\n // A deferred menu mounts on its first click, so it mounts open and owns its state from then on: a controlled\n // close always refocuses the trigger, which would pull focus back from whatever an outside click focused.\n open={deferred ? undefined : open}\n defaultOpen={deferred ? true : defaultOpen}\n onOpenChange={({ open }) => onOpenChange?.(open)}\n positioning={positioning}\n >\n {children && (\n <Menu.Trigger asChild disabled={disabled}>\n {children}\n </Menu.Trigger>\n )}\n <Menu.Content container={containerRef}>\n <ActionMenuItems menu={menu} group={group} actions={typeof actions === 'function' ? actions() : actions} />\n </Menu.Content>\n </Menu.Root>\n );\n};\n\nActionMenu.displayName = 'ActionMenu';\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport { keySymbols } from '@dxos/react-focus';\nimport * as Theme from '@dxos/react-ui/Theme';\nimport { type MenuActionProperties, type MenuItemChrome } from '@dxos/ui-types';\n\nimport { getShortcut } from '../util.ts';\n\ntype Action = AppGraphNode.Action<MenuActionProperties> | AppGraphNode.ActionGroup<MenuItemChrome>;\n\n// Kept out of `ActionLabel.tsx`: react-refresh only fast-refreshes a module whose exports are all\n// components, so a value exported beside them forces a full page reload on every edit.\n\nexport const actionLabel = (action: Action, t: Theme.TFunction) => {\n const shortcut = getShortcut(action);\n return `${Theme.toLocalizedString(action.properties!.label, t)}${shortcut ? ` (${keySymbols(shortcut).join('')})` : ''}`;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport { keySymbols } from '@dxos/react-focus';\nimport * as Hooks from '@dxos/react-ui/Hooks';\nimport * as Theme from '@dxos/react-ui/Theme';\nimport { mx } from '@dxos/ui-theme';\nimport { type MenuActionProperties, type MenuItemChrome } from '@dxos/ui-types';\n\nimport { translationKey } from '#translations';\n\nimport { getShortcut } from '../util.ts';\n\ntype Action = AppGraphNode.Action<MenuActionProperties> | AppGraphNode.ActionGroup<MenuItemChrome>;\n\nexport const ActionLabel = ({ action }: { action: Action }) => {\n const { t } = Hooks.useTranslation(translationKey);\n const shortcut = getShortcut(action);\n return (\n <>\n <span className='grow truncate'>{Theme.toLocalizedString(action.properties!.label, t)}</span>\n {shortcut && <span className={mx('shrink-0', 'text-fg-muted')}>{keySymbols(shortcut).join('')}</span>}\n </>\n );\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React, {\n type ButtonHTMLAttributes,\n type ReactNode,\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useAttention } from '@dxos/react-ui-attention';\nimport * as Button from '@dxos/react-ui/Button';\nimport * as Hooks from '@dxos/react-ui/Hooks';\nimport * as Input from '@dxos/react-ui/Input';\nimport * as Theme from '@dxos/react-ui/Theme';\nimport * as ToggleGroup from '@dxos/react-ui/ToggleGroup';\nimport * as Toolbar from '@dxos/react-ui/Toolbar';\nimport * as Tooltip from '@dxos/react-ui/Tooltip';\nimport * as Util from '@dxos/react-ui/Util';\nimport {\n type ClassNameValue,\n type DropdownMenuItemGroupProperties,\n type ToggleGroupMenuItemGroupProperties,\n} from '@dxos/ui-types';\n\nimport { translationKey } from '#translations';\n\nimport { useMenuActions, useMenuItems } from '../hooks/index.ts';\nimport {\n type MenuAction,\n type MenuActions,\n type MenuItem,\n type MenuItemGroup,\n isMenuGroup,\n isSeparator,\n} from '../types.ts';\nimport { executeMenuAction } from '../util.ts';\nimport { actionLabel } from './action-label.ts';\nimport { ActionLabel } from './ActionLabel.tsx';\nimport { ActionMenu } from './ActionMenu.tsx';\n\n//\n// Items (private): the graph's root items as `Toolbar` parts.\n//\n\ntype ItemProps<T> = { menu: MenuActions } & T;\n\ntype ActionButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'aria-label' | 'title'> & {\n action: MenuAction | MenuItemGroup<DropdownMenuItemGroupProperties>;\n variant: Button.Variant;\n iconSize?: Util.Size;\n caretDown?: boolean;\n classNames?: ClassNameValue;\n testId?: string;\n};\n\n/**\n * An action as a Next Button: icon-only with its label (and shortcut) in a tooltip, or text with a trailing shortcut.\n * Forwards its ref and remaining props, since a `Menu.Trigger asChild` merges the trigger's onto it.\n */\nconst ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(\n ({ action, classNames, testId, ...props }, forwardedRef) => {\n const { t } = Hooks.useTranslation(translationKey);\n const { icon, iconOnly = true, spin } = action.properties;\n const common = {\n ...props,\n spin,\n classNames,\n ...(testId && { 'data-testid': testId }),\n ref: forwardedRef,\n };\n return icon && iconOnly ? (\n <Button.Root {...common} icon={icon} label={actionLabel(action, t)} iconOnly />\n ) : (\n <Button.Root {...common} icon={icon}>\n <ActionLabel action={action} />\n </Button.Root>\n );\n },\n);\n\nconst ActionToolbarItem = ({ menu, action }: ItemProps<{ action: MenuAction }>) => {\n const { onAction, caller, iconSize } = menu;\n const [pending, setPending] = useState(false);\n const pendingRef = useRef(false);\n const { disabled, testId, hidden, classNames } = action.properties;\n\n // One invocation at a time: the button is disabled until the last one settles.\n const handleClick = useCallback(() => {\n if (pendingRef.current) {\n return;\n }\n pendingRef.current = true;\n setPending(true);\n const done = () => {\n pendingRef.current = false;\n setPending(false);\n };\n if (onAction) {\n Promise.resolve(onAction(action, { caller })).then(done, done);\n } else {\n executeMenuAction(action, { caller }).then(done, done);\n }\n }, [action, caller, onAction]);\n\n if (hidden) {\n return null;\n }\n\n return (\n <ActionButton\n action={action}\n variant={action.properties.variant === 'primary' ? 'primary' : 'ghost'}\n disabled={disabled || pending}\n iconSize={iconSize}\n classNames={classNames}\n onClick={handleClick}\n testId={testId}\n />\n );\n};\n\n/** A `toggle` action is a pressed button whose state is the action's `checked`. */\nconst ToggleToolbarItem = ({ menu, action }: ItemProps<{ action: MenuAction }>) => {\n const { onAction, caller, iconSize } = menu;\n const { t } = Hooks.useTranslation(translationKey);\n const { icon, iconOnly = true, disabled, testId, hidden, checked, classNames, spin } = action.properties;\n\n const handlePressedChange = useCallback(() => {\n if (onAction) {\n onAction(action, { caller });\n } else {\n void executeMenuAction(action, { caller });\n }\n }, [action, caller, onAction]);\n\n if (hidden) {\n return null;\n }\n\n const common = {\n variant: 'ghost' as const,\n pressed: !!checked,\n disabled,\n spin,\n iconSize: iconSize,\n classNames,\n onPressedChange: handlePressedChange,\n ...(testId && { 'data-testid': testId }),\n };\n\n return icon && iconOnly ? (\n <Button.Toggle {...common} icon={icon} label={actionLabel(action, t)} iconOnly />\n ) : (\n <Button.Toggle {...common} icon={icon}>\n <ActionLabel action={action} />\n </Button.Toggle>\n );\n};\n\nconst SwitchToolbarItem = ({ menu, action }: ItemProps<{ action: MenuAction }>) => {\n const { onAction, caller } = menu;\n const { t } = Hooks.useTranslation(translationKey);\n const { label, iconOnly, disabled, testId, hidden, checked } = action.properties;\n const labelStr = Theme.toLocalizedString(label, t);\n\n const handleCheckedChange = useCallback(() => {\n if (onAction) {\n onAction(action, { caller });\n } else {\n void executeMenuAction(action, { caller });\n }\n }, [action, caller, onAction]);\n\n if (hidden) {\n return null;\n }\n\n const control = (\n <Input.Switch\n checked={checked}\n disabled={disabled}\n onCheckedChange={handleCheckedChange}\n {...(iconOnly ? { 'aria-label': labelStr } : { label: labelStr })}\n {...(testId && { 'data-testid': testId })}\n />\n );\n\n return iconOnly ? (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>{control}</Tooltip.Trigger>\n <Tooltip.Content>{labelStr}</Tooltip.Content>\n </Tooltip.Root>\n ) : (\n control\n );\n};\n\nconst DropdownToolbarItem = ({ menu, group }: ItemProps<{ group: MenuItemGroup<DropdownMenuItemGroupProperties> }>) => {\n const items = useMenuItems(menu, group);\n const { disabled, testId, applyActive, caretDown = true } = group.properties;\n const activeItem = items?.find((item) => !!(item as MenuAction).properties.checked) as MenuAction | undefined;\n\n // With `applyActive` the trigger shows the active child's icon, accent and label in place of the group's.\n const display = useMemo<MenuItemGroup<DropdownMenuItemGroupProperties>>(() => {\n if (!applyActive || !activeItem) {\n return group;\n }\n const { icon, iconClassNames, spin, label, keyBinding } = activeItem.properties;\n return {\n ...group,\n properties: {\n ...group.properties,\n icon: icon || group.properties.icon,\n iconClassNames: iconClassNames || group.properties.iconClassNames,\n spin: spin || group.properties.spin,\n label,\n keyBinding,\n },\n };\n }, [group, applyActive, activeItem]);\n\n const trigger = (\n <ActionButton\n action={display}\n variant='ghost'\n disabled={disabled}\n iconSize={menu.iconSize}\n caretDown={caretDown && !disabled}\n testId={testId}\n />\n );\n\n // No menu behind a disabled trigger, since `disabled` alone does not gate the machine's open handler.\n if (disabled) {\n return trigger;\n }\n\n return (\n <ActionMenu {...menu} group={group} actions={items}>\n {trigger}\n </ActionMenu>\n );\n};\n\nconst ToggleGroupItem = ({\n menu,\n group,\n action,\n}: ItemProps<{ group: MenuItemGroup<ToggleGroupMenuItemGroupProperties>; action: MenuAction }>) => {\n const { onAction, caller, iconSize } = menu;\n const { t } = Hooks.useTranslation(translationKey);\n const { icon, iconOnly = true, disabled, testId, hidden, classNames, spin } = action.properties;\n\n const handleClick = useCallback(() => {\n if (onAction) {\n onAction(action, { parent: group, caller });\n } else {\n void executeMenuAction(action, { parent: group, caller });\n }\n }, [action, group, caller, onAction]);\n\n if (hidden) {\n return null;\n }\n\n const common = {\n value: action.id,\n disabled,\n variant: 'ghost' as const,\n spin,\n iconSize: iconSize,\n classNames,\n onClick: handleClick,\n ...(testId && { 'data-testid': testId }),\n };\n\n return icon && iconOnly ? (\n <ToggleGroup.Item {...common} icon={icon} label={actionLabel(action, t)} iconOnly />\n ) : (\n <ToggleGroup.Item {...common} icon={icon}>\n <ActionLabel action={action} />\n </ToggleGroup.Item>\n );\n};\n\nconst ToggleGroupToolbarItem = ({\n menu,\n group,\n}: ItemProps<{ group: MenuItemGroup<ToggleGroupMenuItemGroupProperties> }>) => {\n const { t } = Hooks.useTranslation(translationKey);\n const items = useMenuItems(menu, group);\n const label = Theme.toLocalizedString(group.properties.label, t);\n\n // Only actions render as toggle group items.\n const children = items\n ?.filter((item) => !isSeparator(item) && !isMenuGroup(item))\n .map((item) => <ToggleGroupItem key={item.id} menu={menu} group={group} action={item as MenuAction} />);\n\n // The group is controlled by the graph: an item's action updates `value`, which flows back in.\n return group.properties.selectCardinality === 'multiple' ? (\n <Toolbar.ToggleGroup type='multiple' value={group.properties.value} aria-label={label}>\n {children}\n </Toolbar.ToggleGroup>\n ) : (\n <Toolbar.ToggleGroup type='single' value={group.properties.value} aria-label={label}>\n {children}\n </Toolbar.ToggleGroup>\n );\n};\n\nconst ToolbarItem = ({ menu, item }: ItemProps<{ item: MenuItem }>) => {\n if (isSeparator(item)) {\n return <Toolbar.Separator variant={item.properties.variant === 'line' ? 'line' : 'gap'} />;\n }\n\n if (isMenuGroup(item)) {\n return item.properties.variant === 'dropdownMenu' ? (\n <DropdownToolbarItem menu={menu} group={item as MenuItemGroup<DropdownMenuItemGroupProperties>} />\n ) : (\n <ToggleGroupToolbarItem menu={menu} group={item as MenuItemGroup<ToggleGroupMenuItemGroupProperties>} />\n );\n }\n\n const action = item as MenuAction;\n switch (action.properties?.variant) {\n case 'switch':\n return <SwitchToolbarItem menu={menu} action={action} />;\n case 'toggle':\n return <ToggleToolbarItem menu={menu} action={action} />;\n case 'custom':\n // The contributor owns the rendered element (interactions the action model cannot express).\n return action.properties.render ? <>{action.properties.render()}</> : null;\n default:\n return <ActionToolbarItem menu={menu} action={action} />;\n }\n};\n\nconst ActionToolbarItems = ({ menu }: { menu: MenuActions }) => {\n const items = useMenuItems(menu);\n return (\n <>\n {items?.map((item) => (\n <ToolbarItem key={item.id} menu={menu} item={item} />\n ))}\n </>\n );\n};\n\n//\n// ActionToolbar\n//\n\nexport type ActionToolbarProps = Partial<MenuActions> &\n Omit<Toolbar.RootProps, 'disabled'> & {\n /** The toolbar is dimmed (still operable) while this attendable lacks attention, unless `alwaysActive`. */\n attendableId?: string;\n alwaysActive?: boolean;\n /** Hand-written controls before the graph's items (the children follow them). */\n start?: ReactNode;\n };\n\n/**\n * A whole `Toolbar.Root` driven from a `MenuActions`: the graph's root items render first, then the toolbar's own\n * children. Mix graph and hand-written controls the other way round by dropping an `ActionMenu` into a plain\n * `Toolbar.Root`. Without a `MenuActions` it is an empty toolbar until one arrives.\n */\nexport const ActionToolbar = Util.composable<HTMLDivElement, ActionToolbarProps>(\n (\n { items, contributions, onAction, caller, iconSize, attendableId, alwaysActive, start, children, ...props },\n forwardedRef,\n ) => {\n // Called unconditionally (hooks), used only when no source was spread in.\n const standalone = useMenuActions();\n const menu = useMemo<MenuActions>(\n () => ({\n items: items ?? standalone.items,\n contributions: contributions ?? standalone.contributions,\n onAction,\n caller,\n iconSize,\n }),\n [items, contributions, onAction, caller, iconSize, standalone],\n );\n const { hasAttention } = useAttention(attendableId);\n\n return (\n <Toolbar.Root\n {...Util.composableProps(props, { classNames: attendableId })}\n inactive={!alwaysActive && !hasAttention}\n ref={forwardedRef}\n >\n {start}\n <ActionToolbarItems menu={menu} />\n {children}\n </Toolbar.Root>\n );\n },\n);\n\nActionToolbar.displayName = 'ActionToolbar';\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport * as Button from '@dxos/react-ui/Button';\n\nimport { createLineSeparator, createMenuAction, createMenuItemGroup } from '../util.ts';\nimport { ActionMenu } from './ActionMenu.tsx';\n\n/** One choice of a {@link SortMenu} or {@link GroupMenu}, labelled by the host so each list keeps its own wording. */\nexport type ViewOption<T extends string> = {\n id: T;\n label: string;\n icon: string;\n};\n\nexport type SortDirection = 'asc' | 'desc';\n\nexport type SortValue<T extends string> = {\n field: T;\n direction: SortDirection;\n};\n\nexport type SortMenuProps<T extends string> = {\n fields: readonly ViewOption<T>[];\n value: SortValue<T>;\n onChange: (value: SortValue<T>) => void;\n /** Trigger label while the list is in its own order, and the menu's heading. */\n label: string;\n directionLabels: Record<SortDirection, string>;\n /** A field that is the list's own order (e.g. a hand-arranged one), so it has no direction to pick. */\n unsorted?: T;\n /** Prefix of the trigger's and items' test ids (`<testId>.<field>`, `<testId>.<direction>`). */\n testId?: string;\n};\n\n/**\n * The order-by field and its direction, as one menu beside a list's filter. The value is the host's to\n * persist — typically in a `ViewState` aspect beside the filter query.\n */\nexport const SortMenu = <T extends string>({\n fields,\n value,\n onChange,\n label,\n directionLabels,\n unsorted,\n testId = 'sort',\n}: SortMenuProps<T>) => {\n const sorted = value.field !== unsorted;\n const current = fields.find((field) => field.id === value.field);\n\n const group = useMemo(\n () =>\n createMenuItemGroup(testId, {\n label,\n icon: 'ph--sort-ascending--regular',\n variant: 'dropdownMenu',\n selectCardinality: 'single',\n value: value.field,\n }),\n [testId, label, value.field],\n );\n\n const actions = useCallback(\n () => [\n ...fields.map((field) =>\n createMenuAction(`sort-${field.id}`, () => onChange({ ...value, field: field.id }), {\n label: field.label,\n icon: field.icon,\n checked: value.field === field.id,\n testId: `${testId}.${field.id}`,\n }),\n ),\n createLineSeparator(`${testId}Separator`).nodes[0],\n ...(['asc', 'desc'] as const).map((direction) =>\n createMenuAction(`sort-${direction}`, () => onChange({ ...value, direction }), {\n label: directionLabels[direction],\n icon: direction === 'asc' ? 'ph--sort-ascending--regular' : 'ph--sort-descending--regular',\n checked: sorted && value.direction === direction,\n disabled: !sorted,\n testId: `${testId}.${direction}`,\n }),\n ),\n ],\n [fields, value, sorted, onChange, directionLabels, testId],\n );\n\n return (\n <ActionMenu deferUntilOpen group={group} actions={actions}>\n <Button.Root\n // The trigger names the order while it is not the list's own, so a reader can tell why rows moved.\n icon={\n !sorted\n ? 'ph--arrows-down-up--regular'\n : value.direction === 'asc'\n ? 'ph--sort-ascending--regular'\n : 'ph--sort-descending--regular'\n }\n iconOnly={!sorted}\n label={sorted && current ? current.label : label}\n data-testid={testId}\n />\n </ActionMenu>\n );\n};\n\nSortMenu.displayName = 'SortMenu';\n\nexport type GroupMenuProps<T extends string> = {\n fields: readonly ViewOption<T>[];\n value: T;\n onChange: (value: T) => void;\n /** Trigger label while the list is ungrouped, and the menu's heading. */\n label: string;\n /** The field that means one ungrouped list. */\n none?: T;\n /** Prefix of the trigger's and items' test ids (`<testId>.<field>`). */\n testId?: string;\n};\n\n/** What a list is grouped by, as a single-select menu beside its sort. */\nexport const GroupMenu = <T extends string>({\n fields,\n value,\n onChange,\n label,\n none,\n testId = 'group',\n}: GroupMenuProps<T>) => {\n const current = value !== none ? fields.find((field) => field.id === value) : undefined;\n\n const group = useMemo(\n () =>\n createMenuItemGroup(testId, {\n label,\n icon: 'ph--rows--regular',\n variant: 'dropdownMenu',\n selectCardinality: 'single',\n value,\n }),\n [testId, label, value],\n );\n\n const actions = useCallback(\n () =>\n fields.map((field) =>\n createMenuAction(`group-${field.id}`, () => onChange(field.id), {\n label: field.label,\n icon: field.icon,\n checked: value === field.id,\n testId: `${testId}.${field.id}`,\n }),\n ),\n [fields, value, onChange, testId],\n );\n\n return (\n <ActionMenu deferUntilOpen group={group} actions={actions}>\n <Button.Root\n icon={current ? current.icon : 'ph--rows--regular'}\n iconOnly={!current}\n label={current ? current.label : label}\n data-testid={testId}\n />\n </ActionMenu>\n );\n};\n\nGroupMenu.displayName = 'GroupMenu';\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\nimport type { DropdownMenuItemGroupProperties, MenuActionProperties, MenuItemGroupProperties } from '@dxos/ui-types';\n\nimport { translationKey } from '#translations';\n\nimport type { ActionGraphProps } from './hooks/index.ts';\nimport { MenuSeparatorType } from './types.ts';\nimport { createMenuAction, createMenuItemGroup } from './util.ts';\n\n/** Default trigger for toolbar overflow (⋮) dropdown menus. */\nconst overflowMenuProperties = {\n label: ['toolbar-overflow.menu', { ns: translationKey }],\n icon: 'ph--dots-three-vertical--regular',\n iconOnly: true,\n caretDown: false,\n variant: 'dropdownMenu',\n} as const satisfies DropdownMenuItemGroupProperties;\n\n/** Callback that populates an action group builder. */\nexport type ActionGroupBuilderFn = (builder: ActionGroupBuilder) => void;\n\n/**\n * Fluent builder for composing menu action graphs.\n * Subgraph functions return a callback that receives the builder, enabling composition via partial application:\n * ```ts\n * const addHeadings = (state): ActionGroupBuilderFn => (builder) => {\n * builder.group('headings', { ... }, (group) => { ... });\n * };\n *\n * MenuBuilder.make()\n * .subgraph(showHeadings && addHeadings(state))\n * .subgraph(showFormatting && addFormatting(state))\n * .build();\n * ```\n */\nexport interface ActionGroupBuilder {\n /** Add an action node as a child of the current group. */\n action<P extends {} = {}>(id: string, props: P & MenuActionProperties, invoke: () => void): this;\n\n /** Add a switch action rendered as a labeled Field.Switch. */\n switch(id: string, props: Omit<MenuActionProperties, 'variant'> & { checked: boolean }, invoke: () => void): this;\n\n /** Add a nested action group. */\n group(id: string, props: MenuItemGroupProperties, cb: ActionGroupBuilderFn): this;\n\n /** Merge pre-built nodes and edges, or build a subgraph via callback scoped to the current group. Falsy values are ignored. */\n subgraph(subgraphOrCb: ActionGraphProps | ActionGroupBuilderFn | false | null | undefined): this;\n\n /** Add a separator. */\n separator(variant?: 'gap' | 'line'): this;\n}\n\n/** Top-level builder that creates the root group and produces the final action graph. */\nexport interface MenuBuilder extends ActionGroupBuilder {\n /**\n * Set properties on the root menu group. May only be called once.\n */\n root(props: MenuItemGroupProperties): this;\n\n /**\n * Add a root-level toolbar overflow dropdown (⋮) with built-in trigger styling.\n */\n menu(id: string, cb: ActionGroupBuilderFn, testId?: string): this;\n\n /**\n * Return the assembled action graph.\n */\n build(): ActionGraphProps;\n}\n\nclass MenuBuilderImpl implements MenuBuilder {\n private _separatorCount = 0;\n\n constructor(\n private readonly _data: ActionGraphProps,\n private readonly _rootId: string,\n ) {}\n\n root(props: MenuItemGroupProperties): this {\n invariant(this._rootId === 'root', 'Root group can only be at the top level');\n invariant(this._data.nodes.find((node) => node.id === 'root') === undefined, 'Root group can only be created once');\n this._data.nodes.push(createMenuItemGroup('root', props));\n return this;\n }\n\n build(): ActionGraphProps {\n return this._data;\n }\n\n action<P extends {} = {}>(id: string, props: P & MenuActionProperties, invoke: () => void): this {\n this._data.nodes.push(createMenuAction(id, invoke, props));\n this._data.edges.push({ source: this._rootId, target: id, relation: 'child' });\n return this;\n }\n\n switch(id: string, props: Omit<MenuActionProperties, 'variant'> & { checked: boolean }, invoke: () => void): this {\n return this.action(id, { ...props, variant: 'switch' }, invoke);\n }\n\n group(id: string, props: MenuItemGroupProperties, cb: ActionGroupBuilderFn): this {\n this._data.nodes.push(createMenuItemGroup(id, props));\n this._data.edges.push({ source: this._rootId, target: id, relation: 'child' });\n cb(new MenuBuilderImpl(this._data, id));\n return this;\n }\n\n menu(id: string, cb: ActionGroupBuilderFn, testId?: string): this {\n return this.group(id, testId === undefined ? overflowMenuProperties : { ...overflowMenuProperties, testId }, cb);\n }\n\n subgraph(subgraphOrCb: ActionGraphProps | ActionGroupBuilderFn | false | null | undefined): this {\n if (!subgraphOrCb) {\n return this;\n }\n if (typeof subgraphOrCb === 'function') {\n subgraphOrCb(new MenuBuilderImpl(this._data, this._rootId));\n } else {\n this._data.nodes.push(...subgraphOrCb.nodes);\n this._data.edges.push(...subgraphOrCb.edges);\n }\n return this;\n }\n\n separator(variant: 'gap' | 'line' = 'gap'): this {\n const id = `separator-${++this._separatorCount}`;\n this._data.nodes.push({\n id,\n type: MenuSeparatorType,\n properties: { variant },\n data: undefined as never,\n });\n this._data.edges.push({ source: this._rootId, target: id, relation: 'child' });\n return this;\n }\n}\n\nexport const MenuBuilder = Object.freeze({\n make: (): MenuBuilder => new MenuBuilderImpl({ nodes: [], edges: [] }, 'root'),\n});\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\n\n/** `disposition` value an action opts into to appear in an object toolbar (vs context-menu-only). */\nexport const TOOLBAR_DISPOSITION = 'toolbar';\n\n/** Filter for {@link graphActions}: keeps only actions a producer opted into the toolbar. */\nexport const isToolbarAction = (action: AppGraphNode.ActionLike): boolean =>\n AppGraphNode.hasDisposition(action, TOOLBAR_DISPOSITION);\n\n/**\n * `disposition` value an action opts into to appear in the row beside a text input — a chat prompt\n * today.\n *\n * Separate from {@link TOOLBAR_DISPOSITION} because the two surfaces act on different things: an\n * object toolbar acts on the object, a prompt row acts on the text being composed. Commenting on a\n * document belongs in the first and means nothing in the second; dictation belongs in both, and says\n * so by listing both (`disposition` takes an array).\n */\nexport const PROMPT_DISPOSITION = 'prompt';\n\n/** Filter for {@link graphActions}: keeps only actions a producer opted into a prompt row. */\nexport const isPromptAction = (action: AppGraphNode.ActionLike): boolean =>\n AppGraphNode.hasDisposition(action, PROMPT_DISPOSITION);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAa,qBAAwD,QAAW,YAAuB;CACrG,MAAM,eAAgB,OAAO,WAAoC,eAAe;CAChF,IAAI,CAAC,cACH,OAAO;CAET,OAAO;EAAE,GAAG;EAAQ,YAAY;GAAE,GAAG,OAAO;GAAY,GAAG;EAAa;CAAE;AAC5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,aAAa,KAAK;GAC3C,KAAK,MAAM,MAAM,KAAK,GAAG,aAAa,KAAK;EAC7C;EACA,OAAO;CACT;CAEA,UAAU,UAA0B,OAAa;EAC/C,MAAM,KAAK,aAAa,EAAE,KAAK;EAC/B,KAAK,MAAM,MAAM,KAAK;GACpB;GACA,MAAM;GACN,YAAY,EAAE,QAAQ;GACtB,MAAM,KAAA;EACR,CAAC;EACD,KAAK,MAAM,MAAM,KAAK;GAAE,QAAQ,KAAK;GAAS,QAAQ;GAAI,UAAU;EAAQ,CAAC;EAC7E,OAAO;CACT;AACF;AAEA,IAAa,cAAc,OAAO,OAAO,EACvC,YAAyB,IAAI,gBAAgB;CAAE,OAAO,CAAC;CAAG,OAAO,CAAC;AAAE,GAAG,MAAM,EAC/E,CAAC;;;;ACvID,IAAa,sBAAsB;;AAGnC,IAAa,mBAAmB,WAC9B,aAAa,eAAe,QAAQ,mBAAmB;;;;;;;;;;AAWzD,IAAa,qBAAqB;;AAGlC,IAAa,kBAAkB,WAC7B,aAAa,eAAe,QAAQ,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["__dxlog_file","_Fragment","_Fragment","_Fragment"],"sources":["../../src/types.ts","../../src/util.ts","../../src/builder.ts","../../src/presentation.ts","../../src/hooks/useMenuActions.ts","../../src/hooks/useGraphMenuActions.ts","../../src/components/ActionMenu.tsx","../../src/components/action-label.ts","../../src/components/ActionLabel.tsx","../../src/components/ActionToolbar.tsx","../../src/components/ViewOptionsMenu.tsx","../../src/toolbar.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Atom from 'effect/reactivity/Atom';\n\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport type * as Toolbar from '@dxos/react-ui/Toolbar';\nimport type * as Util from '@dxos/react-ui/Util';\nimport {\n type DropdownMenuItemGroupProperties,\n type MenuActionProperties,\n type ToggleGroupMenuItemGroupProperties,\n} from '@dxos/ui-types';\n\nexport type MenuAction<P extends {} = {}> = AppGraphNode.Action<P & MenuActionProperties>;\n\nexport const MenuSeparatorType = '@dxos/react-ui-toolbar/separator' as const;\n\nexport type MenuSeparator = AppGraphNode.Node<never, Pick<Toolbar.SeparatorProps, 'variant'>> & {\n type: typeof MenuSeparatorType;\n};\n\nexport const isSeparator = (node: AppGraphNode.Node): node is MenuSeparator => node.type === MenuSeparatorType;\n\nexport type MenuItemGroup<P extends Record<string, any> = Record<string, any>> = AppGraphNode.ActionGroup<P>;\n\nexport const isMenuGroup = (node: AppGraphNode.Node): node is MenuItemGroup =>\n node.type === AppGraphNode.ActionGroupType;\n\n/** Graph-sourced menu nodes carry plugin-specific properties validated at runtime. */\nexport type GraphMenuItem = AppGraphNode.Action | AppGraphNode.ActionGroup;\n\nexport type MenuItem = MenuSeparator | MenuAction | MenuItemGroup | GraphMenuItem;\n\n/** Group context for graph-backed dropdown menus (any graph node, not only action groups). */\nexport type MenuGroupContext = MenuItemGroup | AppGraphNode.Node;\n\n/** Atom-family-style accessor: returns an atom of items for a given group (or root when undefined). */\nexport type MenuItemsAccessor = (group?: MenuGroupContext) => Atom.Atom<MenuItem[] | null>;\n\nexport type ActionExecutor = (action: MenuAction, params: AppGraphNode.InvokeProps) => void;\n\nexport type MenuItemsMode = 'additive' | 'replacement';\n\nexport type AddMenuItemsProps = {\n id: string;\n mode: MenuItemsMode;\n priority?: number;\n items: MenuItem[];\n groupFilter?: (group?: MenuGroupContext) => boolean;\n};\n\nexport type MenuItems = Omit<AddMenuItemsProps, 'priority'> & { priority: number };\nexport type MenuItemsMap = Map<string, MenuItems>;\n\n/** How an action runs when a builder invokes it; overrides the node's own Effect. */\nexport type MenuActionsOptions = {\n onAction?: ActionExecutor;\n /** Identifies the component that owns the menu (passed to action handlers). */\n caller?: string;\n iconSize?: Util.Size;\n};\n\n/**\n * Everything a builder needs to render a menu: where its items come from, how they run, and the\n * registry other components contribute to. Produced by `useMenuActions` and its wrappers, spread\n * onto `ActionToolbar` / `ActionMenu`.\n */\nexport type MenuActions = MenuActionsOptions & {\n /** Atom-family accessor for base menu items, keyed by group (similar to Tree model). */\n items: MenuItemsAccessor;\n /** The set of imperatively contributed items (see `useMenuContribution`). */\n contributions: Atom.Writable<MenuItemsMap>;\n};\n\n/** The group variants a toolbar renders: a dropdown trigger or a toggle group. */\nexport type ToolbarMenuActionGroupProperties = DropdownMenuItemGroupProperties | ToggleGroupMenuItemGroupProperties;\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport * as EffectEx from '@dxos/effect/EffectEx';\nimport { type MenuActionProperties, type MenuItemGroupProperties } from '@dxos/ui-types';\nimport { resolveKeyBinding } from '@dxos/util';\n\nimport { type MenuAction, type MenuItemGroup, type MenuSeparator } from './types.ts';\n\n/**\n * Execute a menu action's Effect with its captured context.\n * This provides the `_actionContext` layer if available.\n */\nexport const executeMenuAction = async (action: MenuAction, params: AppGraphNode.InvokeProps = {}): Promise<void> => {\n let effect = action.data(params);\n\n // Provide captured action context if available.\n if (action._actionContext) {\n effect = effect.pipe(Effect.provide(action._actionContext));\n }\n\n await EffectEx.runAndForwardErrors(effect);\n};\n\nexport const getShortcut = (action: AppGraphNode.ActionLike) => {\n return resolveKeyBinding(action.properties?.keyBinding);\n};\n\nexport const fallbackIcon = 'ph--circle-dashed--regular';\n\nexport const createMenuAction = <P extends {} = {}>(\n id: string,\n invoke: (params?: AppGraphNode.InvokeProps) => void,\n properties: P & MenuActionProperties,\n) =>\n ({\n id,\n type: AppGraphNode.ActionType,\n properties,\n data: (params?: AppGraphNode.InvokeProps) => Effect.sync(() => invoke(params)),\n }) satisfies MenuAction;\n\nexport const createMenuItemGroup = <P extends MenuItemGroupProperties>(id: string, properties: P) =>\n ({\n id,\n type: AppGraphNode.ActionGroupType,\n properties,\n data: AppGraphNode.actionGroupSymbol,\n }) satisfies MenuItemGroup;\n\nexport const createGapSeparator = (id: string = 'gap', source: string = 'root') => ({\n nodes: [\n {\n id,\n type: '@dxos/react-ui-toolbar/separator',\n properties: { variant: 'gap' },\n data: undefined as never,\n } satisfies MenuSeparator,\n ],\n edges: [\n {\n source,\n target: id,\n relation: 'child' as const,\n },\n ],\n});\n\nexport const createLineSeparator = (id: string = 'line', source: string = 'root') => ({\n nodes: [\n {\n id,\n type: '@dxos/react-ui-toolbar/separator',\n properties: { variant: 'line' },\n data: undefined as never,\n } satisfies MenuSeparator,\n ],\n edges: [{ source, target: id, relation: 'child' as const }],\n});\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ReactNode } from 'react';\n\nimport { invariant } from '@dxos/invariant';\nimport type {\n CustomRenderProps,\n DropdownMenuItemGroupProperties,\n MenuActionProperties,\n MenuItemGroupProperties,\n} from '@dxos/ui-types';\n\nimport { translationKey } from '#translations';\n\nimport type { ActionGraphProps } from './hooks/index.ts';\nimport { MenuSeparatorType } from './types.ts';\nimport { createMenuAction, createMenuItemGroup } from './util.ts';\n\n/** Default trigger for toolbar overflow (⋮) dropdown menus. */\nconst overflowMenuProperties = {\n label: ['toolbar-overflow.menu', { ns: translationKey }],\n icon: 'ph--dots-three-vertical--regular',\n iconOnly: true,\n caretDown: false,\n variant: 'dropdownMenu',\n} as const satisfies DropdownMenuItemGroupProperties;\n\n/** Callback that populates an action group builder. */\nexport type ActionGroupBuilderFn = (builder: ActionGroupBuilder) => void;\n\n/**\n * Fluent builder for composing menu action graphs.\n * Subgraph functions return a callback that receives the builder, enabling composition via partial application:\n * ```ts\n * const addHeadings = (state): ActionGroupBuilderFn => (builder) => {\n * builder.group('headings', { ... }, (group) => { ... });\n * };\n *\n * MenuBuilder.make()\n * .subgraph(showHeadings && addHeadings(state))\n * .subgraph(showFormatting && addFormatting(state))\n * .build();\n * ```\n */\nexport interface ActionGroupBuilder {\n /** Add an action node as a child of the current group. */\n action<P extends {} = {}>(id: string, props: P & MenuActionProperties, invoke: () => void): this;\n\n /** Add a switch action rendered as a labeled Field.Switch. */\n switch(id: string, props: Omit<MenuActionProperties, 'variant'> & { checked: boolean }, invoke: () => void): this;\n\n /** Add a control the caller renders itself (a picker, a field); it stays in the toolbar and never collapses. */\n custom(\n id: string,\n props: Omit<MenuActionProperties, 'variant' | 'render'>,\n render: (props: CustomRenderProps) => ReactNode,\n ): this;\n\n /** Add a plain label (e.g. a panel's name) that takes the toolbar's free space. */\n text(id: string, props: Omit<MenuActionProperties, 'variant' | 'render'>): this;\n\n /** Add a nested action group. */\n group(id: string, props: MenuItemGroupProperties, cb: ActionGroupBuilderFn): this;\n\n /** Merge pre-built nodes and edges, or build a subgraph via callback scoped to the current group. Falsy values are ignored. */\n subgraph(subgraphOrCb: ActionGraphProps | ActionGroupBuilderFn | false | null | undefined): this;\n\n /** Add a separator. */\n separator(variant?: 'gap' | 'line'): this;\n}\n\n/** Top-level builder that creates the root group and produces the final action graph. */\nexport interface MenuBuilder extends ActionGroupBuilder {\n /**\n * Set properties on the root menu group. May only be called once.\n */\n root(props: MenuItemGroupProperties): this;\n\n /**\n * Add a root-level toolbar overflow dropdown (⋮) with built-in trigger styling.\n */\n menu(id: string, cb: ActionGroupBuilderFn, testId?: string): this;\n\n /**\n * Return the assembled action graph.\n */\n build(): ActionGraphProps;\n}\n\nclass MenuBuilderImpl implements MenuBuilder {\n constructor(\n private readonly _data: ActionGraphProps,\n private readonly _rootId: string,\n ) {}\n\n root(props: MenuItemGroupProperties): this {\n invariant(this._rootId === 'root', 'Root group can only be at the top level');\n invariant(this._data.nodes.find((node) => node.id === 'root') === undefined, 'Root group can only be created once');\n this._data.nodes.push(createMenuItemGroup('root', props));\n return this;\n }\n\n build(): ActionGraphProps {\n return this._data;\n }\n\n action<P extends {} = {}>(id: string, props: P & MenuActionProperties, invoke: () => void): this {\n this._data.nodes.push(createMenuAction(id, invoke, props));\n this._data.edges.push({ source: this._rootId, target: id, relation: 'child' });\n return this;\n }\n\n switch(id: string, props: Omit<MenuActionProperties, 'variant'> & { checked: boolean }, invoke: () => void): this {\n return this.action(id, { ...props, variant: 'switch' }, invoke);\n }\n\n custom(\n id: string,\n props: Omit<MenuActionProperties, 'variant' | 'render'>,\n render: (props: CustomRenderProps) => ReactNode,\n ): this {\n return this.action(id, { ...props, variant: 'custom', render }, () => {});\n }\n\n text(id: string, props: Omit<MenuActionProperties, 'variant' | 'render'>): this {\n return this.action(id, { ...props, variant: 'text' }, () => {});\n }\n\n group(id: string, props: MenuItemGroupProperties, cb: ActionGroupBuilderFn): this {\n this._data.nodes.push(createMenuItemGroup(id, props));\n this._data.edges.push({ source: this._rootId, target: id, relation: 'child' });\n cb(new MenuBuilderImpl(this._data, id));\n return this;\n }\n\n menu(id: string, cb: ActionGroupBuilderFn, testId?: string): this {\n return this.group(id, testId === undefined ? overflowMenuProperties : { ...overflowMenuProperties, testId }, cb);\n }\n\n subgraph(subgraphOrCb: ActionGraphProps | ActionGroupBuilderFn | false | null | undefined): this {\n if (!subgraphOrCb) {\n return this;\n }\n if (typeof subgraphOrCb === 'function') {\n subgraphOrCb(new MenuBuilderImpl(this._data, this._rootId));\n } else {\n // A graph built on its own numbers its separators from one, so they are renumbered into this one.\n const ids = new Map<string, string>();\n for (const node of subgraphOrCb.nodes) {\n if (node.type === MenuSeparatorType) {\n const id = this._nextSeparatorId();\n ids.set(node.id, id);\n this._data.nodes.push({ ...node, id });\n } else {\n this._data.nodes.push(node);\n }\n }\n this._data.edges.push(\n ...subgraphOrCb.edges.map((edge) => ({\n ...edge,\n source: ids.get(edge.source) ?? edge.source,\n target: ids.get(edge.target) ?? edge.target,\n })),\n );\n }\n return this;\n }\n\n separator(variant: 'gap' | 'line' = 'gap'): this {\n const id = this._nextSeparatorId();\n this._data.nodes.push({\n id,\n type: MenuSeparatorType,\n properties: { variant },\n data: undefined as never,\n });\n this._data.edges.push({ source: this._rootId, target: id, relation: 'child' });\n return this;\n }\n\n // Numbered across the whole graph: a nested group or subgraph builds into the same nodes, so a count of its own\n // would reuse an id and the later separator would replace the earlier one.\n private _nextSeparatorId(): string {\n return `separator-${this._data.nodes.filter((node) => node.type === MenuSeparatorType).length + 1}`;\n }\n}\n\n/** Id of the overflow menu (⋮) every toolbar ends with; contributors add to it with {@link MenuBuilder.extend}. */\nexport const TOOLBAR_OVERFLOW_ID = 'toolbar-overflow';\n\n/** The overflow group a toolbar uses when its owner declares none, so contributors can still add to it. */\nexport const defaultOverflowGroup = createMenuItemGroup(TOOLBAR_OVERFLOW_ID, overflowMenuProperties);\n\nexport const MenuBuilder = Object.freeze({\n make: (): MenuBuilder => new MenuBuilderImpl({ nodes: [], edges: [] }, 'root'),\n\n /**\n * Builds items into a named group another component declared, so a plugin extends a toolbar or menu it does not own.\n * The result is merged into the owner's graph (e.g. with `subgraph`); its edges hang off `groupId`.\n */\n extend: (groupId: string, cb: ActionGroupBuilderFn): ActionGraphProps => {\n const data: ActionGraphProps = { nodes: [], edges: [] };\n cb(new MenuBuilderImpl(data, groupId));\n return data;\n },\n});\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport { type MenuActionProperties } from '@dxos/ui-types';\n\n/**\n * Merges an action's `presentation[surface]` chrome override (if any) into its properties, letting a\n * single action declare multiple dispositions yet render appropriately in each surface — e.g. a\n * primary toolbar button and a plain nav-tree row from the same definition.\n */\nexport const applyPresentation = <A extends AppGraphNode.ActionLike>(action: A, surface: string): A => {\n const presentation = (action.properties as MenuActionProperties).presentation?.[surface];\n if (!presentation) {\n return action;\n }\n return { ...action, properties: { ...action.properties, ...presentation } };\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { useAtomValue } from '@effect/atom-react/Hooks';\nimport { RegistryContext } from '@effect/atom-react/RegistryContext';\nimport * as Atom from 'effect/reactivity/Atom';\nimport { type DependencyList, useCallback, useContext, useEffect, useLayoutEffect, useMemo } from 'react';\n\nimport * as AppGraph from '@dxos/app-graph/AppGraph';\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport * as GraphNode from '@dxos/graph/GraphNode';\nimport { log } from '@dxos/log';\n\nimport {\n type AddMenuItemsProps,\n type MenuActions,\n type MenuActionsOptions,\n type MenuGroupContext,\n type MenuItem,\n type MenuItemGroup,\n type MenuItems,\n type MenuItemsAccessor,\n type MenuItemsMap,\n} from '../types.ts';\n\nexport type ActionGraphNodes = AppGraphNode.NodeArg<any>[];\nexport type ActionGraphEdges = AppGraph.Edge[];\nexport type ActionGraphProps = {\n nodes: ActionGraphNodes;\n edges: ActionGraphEdges;\n};\n\nconst DEFAULT_PRIORITY = 100;\n\nconst EMPTY_GRAPH = Atom.make<ActionGraphProps>({ nodes: [], edges: [] });\n\n/**\n * The graph behind a menu, rebuilt when `deps` change. Its nodes stay pinned while the menu is mounted,\n * taken on commit so a render React discards leaves nothing behind.\n */\nexport const useMenuGraph = <G extends AppGraph.BaseGraph | undefined>(build: () => G, deps: DependencyList): G => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const graph = useMemo(build, deps);\n useLayoutEffect(() => (graph ? AppGraph.retain(graph) : undefined), [graph]);\n return graph;\n};\n\n/** A `MenuActions` over a given accessor, for sources that are not an action graph (tests, fixtures). */\nexport const makeMenuActions = ({\n items,\n ...options\n}: { items: MenuItemsAccessor } & MenuActionsOptions): MenuActions => ({\n items,\n contributions: Atom.make<MenuItemsMap>(new Map()),\n ...options,\n});\n\n/**\n * The menu over an action graph. Omit `props` for a menu with no items of its own, filled entirely by\n * contributions (a card whose actions its children register).\n */\nexport const useMenuActions = (\n props: Atom.Atom<ActionGraphProps> = EMPTY_GRAPH,\n options: MenuActionsOptions = {},\n): MenuActions => {\n const registry = useContext(RegistryContext);\n const menuGraphProps = useAtomValue(props);\n\n // Create a new graph whenever props change to preserve correct order.\n // (AppGraph.addEdges appends rather than replaces, which breaks ordering on updates.)\n // NOTE: Using useMemo rather than a ref-mutation pattern to avoid calling registry.set during render,\n // which would trigger atom state updates in other components (setState-in-render React warning).\n const graph = useMenuGraph(() => {\n const newGraph = AppGraph.make({ registry });\n AppGraph.addNodes(newGraph, menuGraphProps.nodes as AppGraphNode.NodeArg<any>[]);\n AppGraph.addEdges(newGraph, menuGraphProps.edges);\n return newGraph;\n }, [registry, menuGraphProps]);\n\n const items: MenuItemsAccessor = useCallback(\n (group?: MenuItemGroup) => {\n // TODO(wittjosiah): Migrate to using action relation instead of child.\n return graph.connections(group?.id || GraphNode.RootId, 'child') as Atom.Atom<MenuItem[] | null>;\n },\n [graph],\n );\n\n const contributions = useMemo(() => Atom.make<MenuItemsMap>(new Map()), []);\n // A layout effect, so it is mounted before any contributor's effect writes to it.\n useLayoutEffect(() => registry.mount(contributions), [registry, contributions]);\n\n const { onAction, caller, iconSize } = options;\n return useMemo(\n () => ({ items, contributions, onAction, caller, iconSize }),\n [items, contributions, onAction, caller, iconSize],\n );\n};\n\n/**\n * Convenience wrapper around `useMenuActions` that creates the backing atom inline.\n * Pass a builder thunk and a dependency list — the hook memoizes `Atom.make(build)` and threads\n * it through `useMenuActions`. Saves the `useMemo(() => Atom.make(...), deps)` boilerplate when\n * the action graph is composed from local state (e.g. a toolbar driven by component state).\n *\n * Read reactive state via `get` inside the builder; `deps` should hold only stable references.\n */\nexport const useMenuBuilder = (\n build: (get: Atom.AtomContext) => ActionGraphProps,\n deps: DependencyList,\n options?: MenuActionsOptions,\n): MenuActions => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const atom = useMemo(() => Atom.make(build), deps);\n return useMenuActions(atom, options);\n};\n\n//\n// Contributions\n//\n\n/**\n * Registers items with a menu another component owns, for as long as the caller is mounted. The\n * owner hands its `MenuActions` down (props or its own context); there is no menu provider.\n */\nexport const useMenuContribution = (menu: MenuActions | undefined, props: AddMenuItemsProps): void => {\n const registry = useContext(RegistryContext);\n const { id, mode, priority = DEFAULT_PRIORITY, items, groupFilter } = props;\n\n useEffect(() => {\n if (!menu) {\n return;\n }\n const update = (change: (previous: MenuItemsMap) => MenuItemsMap) =>\n registry.set(menu.contributions, change(registry.get(menu.contributions)));\n update((previous) => new Map(previous).set(id, { id, mode, priority, items, groupFilter }));\n return () =>\n update((previous) => {\n const next = new Map(previous);\n next.delete(id);\n return next;\n });\n }, [registry, menu, id, mode, priority, items, groupFilter]);\n};\n\n//\n// Item resolution\n//\n\nconst sortMenuItems = (items: MenuItems[]) =>\n [...items].sort((a, b) => (a.priority !== b.priority ? a.priority - b.priority : a.id.localeCompare(b.id)));\n\nexport const resolveItems = (\n baseItems: MenuItem[] | null,\n group: MenuGroupContext | undefined,\n entries: ReadonlyMap<string, MenuItems>,\n): MenuItem[] | null => {\n const applicable = [...entries.values()].filter((entry) => !entry.groupFilter || entry.groupFilter(group));\n if (applicable.length === 0) {\n return baseItems;\n }\n\n const sorted = sortMenuItems(applicable);\n\n const replacements = sorted.filter((entry) => entry.mode === 'replacement');\n if (replacements.length > 0) {\n if (replacements.length > 1) {\n log.warn('multiple replacement entries found', {\n ids: replacements.map((r) => r.id).join(', '),\n using: replacements[0].id,\n });\n }\n return replacements[0].items;\n }\n\n const additive = sorted.filter((entry) => entry.mode === 'additive');\n const additiveItems = additive.flatMap((entry) => entry.items);\n\n if (!baseItems || baseItems.length === 0) {\n return additiveItems.length > 0 ? additiveItems : null;\n }\n\n return [...baseItems, ...additiveItems];\n};\n\n/**\n * A group's items (the root's when `group` is undefined), with the menu's contributions applied;\n * `propsItems` stands in for the group's own items when given.\n */\nexport const useMenuItems = (\n menu: MenuActions,\n group?: MenuGroupContext,\n propsItems?: MenuItem[],\n): MenuItem[] | undefined => {\n const groupItems = useAtomValue(menu.items(group));\n const entries = useAtomValue(menu.contributions);\n const baseItems = useMemo(() => propsItems ?? groupItems ?? null, [propsItems, groupItems]);\n const resolved = useMemo(() => resolveItems(baseItems, group, entries), [baseItems, group, entries]);\n return resolved ?? undefined;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Atom from 'effect/reactivity/Atom';\nimport { useMemo } from 'react';\n\nimport type * as AppGraph from '@dxos/app-graph/AppGraph';\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport * as GraphNode from '@dxos/graph/GraphNode';\n\nimport { applyPresentation } from '../presentation.ts';\nimport { type MenuActions, type MenuActionsOptions } from '../types.ts';\nimport {\n type ActionGraphEdges,\n type ActionGraphNodes,\n type ActionGraphProps,\n useMenuActions,\n} from './useMenuActions.ts';\n\nexport type GraphMenuOptions = {\n /** Group the actions descend from. Defaults to the menu root (top-level toolbar items). */\n rootId?: string;\n /** Keep only the actions the predicate accepts (e.g. by `disposition`). */\n filter?: (action: AppGraphNode.ActionLike) => boolean;\n /**\n * Disposition key this surface renders — when set, each action's `presentation[surface]` chrome\n * override (if any) is merged into its properties, letting one action multi-target dispositions\n * (e.g. `['toolbar', 'list-item']`) with per-surface chrome.\n */\n surface?: string;\n};\n\n/**\n * Flatten a node's contributed actions (and nested {@link AppGraphNode.ActionGroup}s) into the\n * `{ nodes, edges }` an {@link useMenuActions} / `Menu` consumes. The action nodes are spliced\n * verbatim, so their Effect `data` (and captured `_actionContext`) execute via `executeMenuAction`\n * without any `onAction` wiring.\n *\n * Pure over a `resolve` function so it is testable without a live graph; `resolve(id)` returns the\n * direct actions for `id` (a node id at the top level, a group id when expanding a group).\n */\nexport const buildGraphMenu = (\n resolve: (id: string) => AppGraphNode.ActionLike[],\n nodeId: string,\n options: GraphMenuOptions = {},\n): ActionGraphProps => {\n const { rootId = GraphNode.RootId, filter, surface } = options;\n const nodes: ActionGraphNodes = [];\n const edges: ActionGraphEdges = [];\n const seen = new Set<string>();\n\n const visit = (parentId: string, sourceId: string) => {\n for (const action of resolve(sourceId)) {\n if (filter && !filter(action)) {\n continue;\n }\n // Always record the parent→child edge (a shared action may sit under multiple groups).\n edges.push({ source: parentId, target: action.id, relation: 'child' });\n if (seen.has(action.id)) {\n continue;\n }\n seen.add(action.id);\n nodes.push((surface ? applyPresentation(action, surface) : action) as ActionGraphNodes[number]);\n // A group's children are the actions contributed for the group's own id.\n if (AppGraphNode.isActionGroup(action)) {\n visit(action.id, action.id);\n }\n }\n };\n\n visit(rootId, nodeId);\n return { nodes, edges };\n};\n\n/**\n * Read a node's contributed actions from the app-graph as menu `ActionGraphProps`, for splicing into a\n * hand-built toolbar via `MenuBuilder.subgraph(graphActions(graph, get, nodeId))`. Reactive: reads the\n * graph's action atoms through `get`, so contributed actions appear/disappear as extensions update.\n *\n * @idiom org.dxos.react-ui-menu.graphActionsToolbar\n * applies: Splicing a node's app-graph-contributed toolbar actions into a hand-built object toolbar\n * instead-of: Reading `graph.actions(nodeId)` and filtering/wiring `nodes`/`edges` by hand in every toolbar\n * uses: {@link graphActions}, {@link MenuBuilder}, {@link useMenuBuilder}\n * related: org.dxos.react-ui-menu.toolbarMenu\n */\nexport const graphActions = (\n graph: AppGraph.ReadableGraph | undefined,\n get: Atom.AtomContext,\n nodeId: string | undefined,\n options?: GraphMenuOptions,\n): ActionGraphProps =>\n graph && nodeId ? buildGraphMenu((id) => get(graph.actions(id)), nodeId, options) : { nodes: [], edges: [] };\n\n/**\n * Menu actions sourced entirely from a node's app-graph contributions — the common \"show every action\n * the graph offers for this object\" toolbar/menu. Compose with hand-built items via {@link graphActions}.\n */\nexport const useGraphMenuActions = (\n graph: AppGraph.ReadableGraph | undefined,\n nodeId: string | undefined,\n options?: GraphMenuOptions & MenuActionsOptions,\n): MenuActions => {\n const atom = useMemo(\n () => Atom.make((get) => graphActions(graph, get, nodeId, options)),\n // `options` is expected to be stable; `rootId` participates since it reshapes the graph.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [graph, nodeId, options?.rootId],\n );\n return useMenuActions(atom, options);\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React, {\n type CSSProperties,\n Fragment,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n useState,\n} from 'react';\n\nimport { keySymbols } from '@dxos/react-focus';\nimport * as Hooks from '@dxos/react-ui/Hooks';\nimport * as Icon from '@dxos/react-ui/Icon';\nimport * as Menu from '@dxos/react-ui/Menu';\nimport * as Theme from '@dxos/react-ui/Theme';\nimport * as VirtualAnchor from '@dxos/react-ui/VirtualAnchor';\nimport { type MenuItemChrome } from '@dxos/ui-types';\nimport { resolveKeyBinding } from '@dxos/util';\n\nimport { translationKey } from '#translations';\n\nimport { TOOLBAR_OVERFLOW_ID } from '../builder.ts';\nimport { useMenuActions, useMenuItems } from '../hooks/index.ts';\nimport {\n type MenuAction,\n type MenuActions,\n type MenuGroupContext,\n type MenuItem,\n type MenuItemGroup,\n isMenuGroup,\n isSeparator,\n} from '../types.ts';\nimport { executeMenuAction } from '../util.ts';\n\n//\n// Items (private): the graph's items as `Menu` parts.\n//\n\nconst isMultiSelect = (group?: MenuGroupContext): boolean => group?.properties?.selectCardinality === 'multiple';\n\n/** An action that declares `checked` is a select-group member (radio, or checkbox in a multi-select group). */\nconst isCheckable = (item: MenuItem): item is MenuAction =>\n !isSeparator(item) && !isMenuGroup(item) && typeof item.properties?.checked === 'boolean';\n\n/** The row data Next's item parts render: the localized label and the platform's shortcut glyphs. */\nconst useItemData = (\n id: string,\n properties: Pick<MenuItemChrome, 'label' | 'icon' | 'disabled' | 'keyBinding'>,\n): Menu.Option => {\n const { t } = Hooks.useTranslation(translationKey);\n const shortcut = resolveKeyBinding(properties.keyBinding);\n return {\n value: id,\n label: Theme.toLocalizedString(properties.label, t),\n icon: properties.icon,\n shortcut: shortcut ? keySymbols(shortcut).join('') : undefined,\n disabled: properties.disabled,\n };\n};\n\n/** Runs the action on click, which zag also dispatches for Enter, so keyboard and pointer share one path. */\nconst useInvoke = (menu: MenuActions, action: MenuAction, group?: MenuGroupContext) => {\n const { onAction, caller } = menu;\n return useCallback(\n (event: MouseEvent) => {\n if (action.properties?.disabled) {\n return;\n }\n event.stopPropagation();\n const params = { parent: group, caller, modifiers: { shift: event.shiftKey } };\n if (onAction) {\n onAction(action, params);\n } else {\n void executeMenuAction(action, params);\n }\n },\n [action, group, caller, onAction],\n );\n};\n\ntype ActionItemProps = {\n menu: MenuActions;\n action: MenuAction;\n group?: MenuGroupContext;\n};\n\nconst ItemIcon = ({ menu, action }: { menu: MenuActions; action: MenuAction | MenuItemGroup<MenuItemChrome> }) =>\n action.properties?.icon ? (\n <Menu.ItemIcon spin={action.properties.spin} size={menu.iconSize} classNames={action.properties.iconClassNames} />\n ) : null;\n\n/** A row's indent within a menu listing a tree, added to the row's own inset. */\nconst indentStyle = ({ indent }: MenuAction['properties']): CSSProperties | undefined =>\n indent ? { paddingInlineStart: `calc(var(--dx-gap-size) * 1.5 + ${indent}rem)` } : undefined;\n\nconst ActionMenuItem = ({ menu, action, group }: ActionItemProps) => {\n const item = useItemData(action.id, action.properties);\n const handleClick = useInvoke(menu, action, group);\n return (\n <Menu.Item\n item={item}\n style={indentStyle(action.properties)}\n onClick={handleClick}\n // Picking several values from a multi-select group should not close the menu after the first.\n closeOnSelect={!isMultiSelect(group)}\n {...(action.properties?.testId && { 'data-testid': action.properties.testId })}\n >\n <ItemIcon menu={menu} action={action} />\n <Menu.ItemText />\n {item.shortcut && <Menu.ItemShortcut />}\n </Menu.Item>\n );\n};\n\nconst ActionCheckboxItem = ({ menu, action, group }: ActionItemProps) => {\n const item = useItemData(action.id, action.properties);\n const handleClick = useInvoke(menu, action, group);\n return (\n <Menu.CheckboxItem\n item={item}\n style={indentStyle(action.properties)}\n // The graph owns the state: the action flips it and the item re-renders from `checked`.\n checked={!!action.properties.checked}\n onClick={handleClick}\n closeOnSelect={false}\n {...(action.properties?.testId && { 'data-testid': action.properties.testId })}\n >\n <ItemIcon menu={menu} action={action} />\n <Menu.ItemText />\n <Menu.ItemIndicator />\n </Menu.CheckboxItem>\n );\n};\n\nconst ActionRadioItem = ({ menu, action, group }: ActionItemProps) => {\n const item = useItemData(action.id, action.properties);\n const handleClick = useInvoke(menu, action, group);\n return (\n <Menu.RadioItem\n item={item}\n style={indentStyle(action.properties)}\n onClick={handleClick}\n {...(action.properties?.testId && { 'data-testid': action.properties.testId })}\n >\n {/* Composed rather than the default row, so the icon takes the action's classes (a priority's hue). */}\n <ItemIcon menu={menu} action={action} />\n <Menu.ItemText />\n <Menu.ItemIndicator />\n </Menu.RadioItem>\n );\n};\n\n/** A group inside a menu is a submenu; its items resolve when it opens. */\nconst ActionSubMenu = ({ menu, group }: { menu: MenuActions; group: MenuItemGroup<MenuItemChrome> }) => {\n const item = useItemData(group.id, group.properties);\n return (\n <Menu.Sub>\n <Menu.TriggerItem\n item={item}\n disabled={group.properties.disabled}\n {...(group.properties.testId && { 'data-testid': group.properties.testId })}\n >\n <ItemIcon menu={menu} action={group} />\n <Menu.ItemText />\n <Icon.Icon icon='ph--caret-right--regular' />\n </Menu.TriggerItem>\n <Menu.Content>\n <ActionMenuItems menu={menu} group={group} />\n </Menu.Content>\n </Menu.Sub>\n );\n};\n\n/** A toolbar's named group may be declared for others to extend and left empty; a menu then omits it. */\nconst NamedGroupSubMenu = ({ menu, group }: { menu: MenuActions; group: MenuItemGroup<MenuItemChrome> }) => {\n const items = useMenuItems(menu, group);\n return items?.some(isMenuRow) ? <ActionSubMenu menu={menu} group={group} /> : null;\n};\n\n/**\n * Whether an item renders as a menu row: a label belongs to a toolbar row (a menu has its own title), and a menu cannot\n * host a control its contributor renders itself.\n */\nconst isMenuRow = (item: MenuItem): boolean =>\n isMenuGroup(item) ||\n (!isSeparator(item) &&\n !item.properties?.hidden &&\n item.properties?.variant !== 'text' &&\n item.properties?.variant !== 'custom');\n\n/** A toggle group is a set of options, which a menu lists in place, ruled off from its neighbours. */\nconst isOptionSet = (item: MenuItem): boolean => isMenuGroup(item) && item.properties.variant === 'toggleGroup';\n\ntype Segment = { kind: 'item'; item: MenuItem } | { kind: 'radio'; id: string; actions: MenuAction[] };\n\n/**\n * Runs of checkable items in a single-select group become one radio group (Ark's radio items need one), whose value is\n * the member marked `checked`; a `toggle` is pressed on its own (a toolbar's, collapsed into ⋮), so it stays a checkbox.\n */\nconst segment = (items: MenuItem[], multiple: boolean): Segment[] =>\n items.reduce<Segment[]>((segments, item) => {\n const last = segments.at(-1);\n if (multiple || !isCheckable(item) || item.properties.variant === 'toggle') {\n segments.push({ kind: 'item', item });\n } else if (last?.kind === 'radio') {\n last.actions.push(item);\n } else {\n segments.push({ kind: 'radio', id: item.id, actions: [item] });\n }\n return segments;\n }, []);\n\nconst isOptionSetSegment = (segment: Segment): boolean => segment.kind === 'item' && isOptionSet(segment.item);\n\nconst ActionMenuEntry = ({ menu, item, group }: { menu: MenuActions; item: MenuItem; group?: MenuGroupContext }) => {\n if (isSeparator(item)) {\n return <Menu.Separator />;\n }\n if (isMenuGroup(item)) {\n // A toolbar's overflow items are already \"more\" in a menu, so they follow the other items rather than nest.\n if (item.id === TOOLBAR_OVERFLOW_ID) {\n return <OverflowSection menu={menu} group={item} />;\n }\n if (isOptionSet(item)) {\n return <ActionMenuItems menu={menu} group={item} />;\n }\n // A graph group's properties are an open record, validated by the plugin that contributed them.\n return item.properties.variant ? (\n <ActionSubMenu menu={menu} group={item as MenuItemGroup<MenuItemChrome>} />\n ) : (\n <NamedGroupSubMenu menu={menu} group={item as MenuItemGroup<MenuItemChrome>} />\n );\n }\n const action = item as MenuAction;\n if (!isMenuRow(action)) {\n return null;\n }\n return isCheckable(action) ? (\n <ActionCheckboxItem menu={menu} action={action} group={group} />\n ) : (\n <ActionMenuItem menu={menu} action={action} group={group} />\n );\n};\n\nconst OverflowSection = ({ menu, group }: { menu: MenuActions; group: MenuItemGroup }) => {\n const items = useMenuItems(menu, group);\n if (!items?.some(isMenuRow)) {\n return null;\n }\n return (\n <>\n <Menu.Separator />\n <ActionMenuItems menu={menu} group={group} />\n </>\n );\n};\n\nconst ActionMenuItems = ({\n menu,\n group,\n actions,\n}: {\n menu: MenuActions;\n group?: MenuGroupContext;\n actions?: MenuItem[];\n}) => {\n const items = useMenuItems(menu, group, actions);\n const segments = useMemo(() => segment(items ?? [], isMultiSelect(group)), [items, group]);\n return (\n <>\n {segments.map((entry, index) =>\n entry.kind === 'radio' ? (\n <Menu.RadioItemGroup\n key={entry.id}\n value={entry.actions.find((action) => action.properties.checked)?.id ?? ''}\n >\n {entry.actions\n .filter((action) => !action.properties.hidden)\n .map((action) => (\n <ActionRadioItem key={action.id} menu={menu} action={action} group={group} />\n ))}\n </Menu.RadioItemGroup>\n ) : (\n <Fragment key={entry.item.id}>\n {index > 0 && (isOptionSet(entry.item) || isOptionSetSegment(segments[index - 1])) && <Menu.Separator />}\n <ActionMenuEntry menu={menu} item={entry.item} group={group} />\n </Fragment>\n ),\n )}\n </>\n );\n};\n\n//\n// ActionMenu\n//\n\nexport type ActionMenuProps = Partial<MenuActions> & {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** The group whose items the menu shows; the root's when omitted. */\n group?: MenuGroupContext;\n /**\n * Explicit items in place of the group's own; contributions still apply. A thunk is called once the menu exists, so\n * a deferred menu does not build its items until it is opened.\n */\n actions?: MenuItem[] | (() => MenuItem[]);\n /**\n * Builds the menu on the trigger's first click rather than with the trigger, since each menu carries a state machine\n * and a list renders one per row. Ignored for a controlled or virtually-anchored menu, which may be opened from\n * anywhere and so cannot wait for its own trigger.\n */\n deferUntilOpen?: boolean;\n /** Anchors the content at an element that is not the trigger (open it under control); the child is then optional. */\n virtualRef?: RefObject<Element | null>;\n disabled?: boolean;\n /** Specify a container element to portal the content into. */\n container?: HTMLElement | null;\n /** The trigger. */\n children?: ReactNode;\n};\n\n/**\n * A whole `Menu.Root` driven from a `MenuActions`: the child is the trigger (`asChild`), the items come from the\n * graph; groups become `Sub` menus, `checked` members radio or checkbox items. Without a `MenuActions` it is a menu of\n * the explicit `actions` alone.\n */\nexport const ActionMenu = (props: ActionMenuProps) => {\n const { virtualRef, open, defaultOpen, onOpenChange, deferUntilOpen, children } = props;\n const [built, setBuilt] = useState(false);\n // Only a menu that owns its open state and renders its own trigger can wait for a click.\n const deferred = !!deferUntilOpen && !virtualRef && open === undefined && defaultOpen === undefined;\n const trigger = isValidElement<{\n 'onClick'?: (event: MouseEvent) => void;\n 'aria-haspopup'?: 'menu';\n 'aria-expanded'?: boolean;\n }>(children)\n ? children\n : undefined;\n\n const handleTriggerClick = useCallback(\n (event: MouseEvent) => {\n trigger?.props.onClick?.(event);\n setBuilt(true);\n onOpenChange?.(true);\n },\n [trigger, onOpenChange],\n );\n\n // Returned before the menu's hooks run, not just before its JSX: the menu's action graph and state machine are what\n // a list of rows cannot afford per row, and a deferred menu builds neither until its trigger is first clicked.\n if (deferred && !built && trigger) {\n return cloneElement(trigger, {\n 'onClick': handleTriggerClick,\n // The trigger announces itself as a menu button before the `Menu.Trigger` that would say so exists.\n 'aria-haspopup': 'menu',\n 'aria-expanded': false,\n });\n }\n\n return <ActionMenuRoot {...props} deferred={deferred} />;\n};\n\nconst ActionMenuRoot = ({\n items,\n contributions,\n onAction,\n caller,\n iconSize,\n group,\n actions,\n virtualRef,\n disabled,\n container,\n open,\n defaultOpen,\n onOpenChange,\n deferred,\n children,\n}: ActionMenuProps & { deferred: boolean }) => {\n // Called unconditionally (hooks), used only when no source was spread in.\n const standalone = useMenuActions();\n const menu = useMemo<MenuActions>(\n () => ({\n items: items ?? standalone.items,\n contributions: contributions ?? standalone.contributions,\n onAction,\n caller,\n iconSize,\n }),\n [items, contributions, onAction, caller, iconSize, standalone],\n );\n\n // Next's Content portals into a ref.\n const containerRef = useMemo(() => (container ? { current: container } : undefined), [container]);\n\n const positioning = VirtualAnchor.useVirtualAnchor(virtualRef);\n\n return (\n <Menu.Root\n // A deferred menu mounts on its first click, so it mounts open and owns its state from then on: a controlled\n // close always refocuses the trigger, which would pull focus back from whatever an outside click focused.\n open={deferred ? undefined : open}\n defaultOpen={deferred ? true : defaultOpen}\n onOpenChange={({ open }) => onOpenChange?.(open)}\n positioning={positioning}\n >\n {children && (\n <Menu.Trigger asChild disabled={disabled}>\n {children}\n </Menu.Trigger>\n )}\n {/* A menu opened at a point (a right-click) has no trigger for an arrow to point at. */}\n <Menu.Content container={containerRef} arrow={virtualRef ? false : undefined}>\n <ActionMenuItems menu={menu} group={group} actions={typeof actions === 'function' ? actions() : actions} />\n </Menu.Content>\n </Menu.Root>\n );\n};\n\nActionMenu.displayName = 'ActionMenu';\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport { keySymbols } from '@dxos/react-focus';\nimport * as Theme from '@dxos/react-ui/Theme';\nimport { type MenuActionProperties, type MenuItemChrome } from '@dxos/ui-types';\n\nimport { getShortcut } from '../util.ts';\n\ntype Action = AppGraphNode.Action<MenuActionProperties> | AppGraphNode.ActionGroup<MenuItemChrome>;\n\n// Kept out of `ActionLabel.tsx`: react-refresh only fast-refreshes a module whose exports are all\n// components, so a value exported beside them forces a full page reload on every edit.\n\nexport const actionLabel = (action: Action, t: Theme.TFunction) => {\n const shortcut = getShortcut(action);\n return `${Theme.toLocalizedString(action.properties!.label, t)}${shortcut ? ` (${keySymbols(shortcut).join('')})` : ''}`;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport type * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\nimport { keySymbols } from '@dxos/react-focus';\nimport * as Hooks from '@dxos/react-ui/Hooks';\nimport * as Theme from '@dxos/react-ui/Theme';\nimport { mx } from '@dxos/ui-theme';\nimport { type MenuActionProperties, type MenuItemChrome } from '@dxos/ui-types';\n\nimport { translationKey } from '#translations';\n\nimport { getShortcut } from '../util.ts';\n\ntype Action = AppGraphNode.Action<MenuActionProperties> | AppGraphNode.ActionGroup<MenuItemChrome>;\n\nexport const ActionLabel = ({ action }: { action: Action }) => {\n const { t } = Hooks.useTranslation(translationKey);\n const shortcut = getShortcut(action);\n return (\n <>\n <span className='grow truncate'>{Theme.toLocalizedString(action.properties!.label, t)}</span>\n {shortcut && <span className={mx('shrink-0', 'text-fg-muted')}>{keySymbols(shortcut).join('')}</span>}\n </>\n );\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { RegistryContext } from '@effect/atom-react/RegistryContext';\nimport * as Atom from 'effect/reactivity/Atom';\nimport type * as Registry from 'effect/reactivity/AtomRegistry';\nimport React, {\n type ButtonHTMLAttributes,\n type ForwardedRef,\n Fragment,\n type RefObject,\n forwardRef,\n useCallback,\n useContext,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useAttention } from '@dxos/react-ui-attention';\nimport * as Button from '@dxos/react-ui/Button';\nimport * as Hooks from '@dxos/react-ui/Hooks';\nimport * as Input from '@dxos/react-ui/Input';\nimport * as Theme from '@dxos/react-ui/Theme';\nimport * as ToggleGroup from '@dxos/react-ui/ToggleGroup';\nimport * as Toolbar from '@dxos/react-ui/Toolbar';\nimport * as Tooltip from '@dxos/react-ui/Tooltip';\nimport * as Util from '@dxos/react-ui/Util';\nimport {\n type ClassNameValue,\n type DropdownMenuItemGroupProperties,\n type ToggleGroupMenuItemGroupProperties,\n TOOLBAR_HOLDS_ATTRIBUTE,\n TOOLBAR_OVERFLOW_TESTID,\n type ToolbarPlacement,\n type ToolbarZone,\n} from '@dxos/ui-types';\n\nimport { translationKey } from '#translations';\n\nimport { TOOLBAR_OVERFLOW_ID, defaultOverflowGroup } from '../builder.ts';\nimport { type ActionGraphProps, useMenuActions, useMenuItems } from '../hooks/index.ts';\nimport {\n type MenuAction,\n type MenuActions,\n type MenuItem,\n type MenuItemGroup,\n type MenuItemsAccessor,\n type MenuSeparator,\n MenuSeparatorType,\n isMenuGroup,\n isSeparator,\n} from '../types.ts';\nimport { executeMenuAction } from '../util.ts';\nimport { actionLabel } from './action-label.ts';\nimport { ActionLabel } from './ActionLabel.tsx';\nimport { ActionMenu } from './ActionMenu.tsx';\n\n//\n// Items (private): the graph's root items as `Toolbar` parts.\n//\n\ntype ItemProps<T> = { menu: MenuActions } & T;\n\ntype ActionButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'aria-label' | 'title'> & {\n action: MenuAction | MenuItemGroup<DropdownMenuItemGroupProperties>;\n variant: Button.Variant;\n iconSize?: Util.Size;\n caretDown?: boolean;\n classNames?: ClassNameValue;\n testId?: string;\n /** Shows the icon alone, as the toolbar does for a labelled action it has collapsed. */\n compact?: boolean;\n};\n\n/**\n * An action as a Next Button: icon-only with its label (and shortcut) in a tooltip, or text with a trailing shortcut.\n * Forwards its ref and remaining props, since a `Menu.Trigger asChild` merges the trigger's onto it.\n */\nconst ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(\n ({ action, classNames, testId, compact, ...props }, forwardedRef) => {\n const { t } = Hooks.useTranslation(translationKey);\n const { icon, iconOnly = true, spin } = action.properties;\n const common = {\n ...props,\n spin,\n classNames,\n ...(testId && { 'data-testid': testId }),\n ref: forwardedRef,\n };\n return icon && (iconOnly || compact) ? (\n <Button.Root {...common} icon={icon} label={actionLabel(action, t)} iconOnly />\n ) : (\n <Button.Root {...common} icon={icon}>\n <ActionLabel action={action} />\n </Button.Root>\n );\n },\n);\n\nconst ActionToolbarItem = ({ menu, action, compact }: ItemProps<{ action: MenuAction; compact?: boolean }>) => {\n const { onAction, caller, iconSize } = menu;\n const [pending, setPending] = useState(false);\n const pendingRef = useRef(false);\n const { disabled, testId, hidden, classNames } = action.properties;\n\n // One invocation at a time: the button is disabled until the last one settles.\n const handleClick = useCallback(() => {\n if (pendingRef.current) {\n return;\n }\n pendingRef.current = true;\n setPending(true);\n const done = () => {\n pendingRef.current = false;\n setPending(false);\n };\n if (onAction) {\n Promise.resolve(onAction(action, { caller })).then(done, done);\n } else {\n executeMenuAction(action, { caller }).then(done, done);\n }\n }, [action, caller, onAction]);\n\n if (hidden) {\n return null;\n }\n\n return (\n <ActionButton\n action={action}\n variant={action.properties.variant === 'primary' ? 'primary' : 'ghost'}\n disabled={disabled || pending}\n iconSize={iconSize}\n classNames={classNames}\n onClick={handleClick}\n testId={testId}\n compact={compact}\n />\n );\n};\n\n/** A `toggle` action is a pressed button whose state is the action's `checked`. */\nconst ToggleToolbarItem = ({ menu, action, compact }: ItemProps<{ action: MenuAction; compact?: boolean }>) => {\n const { onAction, caller, iconSize } = menu;\n const { t } = Hooks.useTranslation(translationKey);\n const { icon, iconOnly = true, disabled, testId, hidden, checked, classNames, spin } = action.properties;\n\n const handlePressedChange = useCallback(() => {\n if (onAction) {\n onAction(action, { caller });\n } else {\n void executeMenuAction(action, { caller });\n }\n }, [action, caller, onAction]);\n\n if (hidden) {\n return null;\n }\n\n const common = {\n variant: 'ghost' as const,\n pressed: !!checked,\n disabled,\n spin,\n iconSize: iconSize,\n classNames,\n onPressedChange: handlePressedChange,\n ...(testId && { 'data-testid': testId }),\n };\n\n return icon && (iconOnly || compact) ? (\n <Button.Toggle {...common} icon={icon} label={actionLabel(action, t)} iconOnly />\n ) : (\n <Button.Toggle {...common} icon={icon}>\n <ActionLabel action={action} />\n </Button.Toggle>\n );\n};\n\nconst SwitchToolbarItem = ({ menu, action }: ItemProps<{ action: MenuAction }>) => {\n const { onAction, caller } = menu;\n const { t } = Hooks.useTranslation(translationKey);\n const { label, iconOnly, disabled, testId, hidden, checked } = action.properties;\n const labelStr = Theme.toLocalizedString(label, t);\n\n const handleCheckedChange = useCallback(() => {\n if (onAction) {\n onAction(action, { caller });\n } else {\n void executeMenuAction(action, { caller });\n }\n }, [action, caller, onAction]);\n\n if (hidden) {\n return null;\n }\n\n const control = (\n <Input.Switch\n checked={checked}\n disabled={disabled}\n onCheckedChange={handleCheckedChange}\n {...(iconOnly ? { 'aria-label': labelStr } : { label: labelStr })}\n {...(testId && { 'data-testid': testId })}\n />\n );\n\n return iconOnly ? (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>{control}</Tooltip.Trigger>\n <Tooltip.Content>{labelStr}</Tooltip.Content>\n </Tooltip.Root>\n ) : (\n control\n );\n};\n\nconst DropdownToolbarItem = ({\n menu,\n group,\n holds,\n}: ItemProps<{ group: MenuItemGroup<DropdownMenuItemGroupProperties>; holds?: string }>) => {\n const items = useMenuItems(menu, group);\n const { disabled, testId, applyActive, caretDown = true } = group.properties;\n const activeItem = items?.find((item) => !!(item as MenuAction).properties.checked) as MenuAction | undefined;\n\n // With `applyActive` the trigger shows the active child's icon, accent and label in place of the group's.\n const display = useMemo<MenuItemGroup<DropdownMenuItemGroupProperties>>(() => {\n if (!applyActive || !activeItem) {\n return group;\n }\n const { icon, iconClassNames, spin, label, keyBinding } = activeItem.properties;\n return {\n ...group,\n properties: {\n ...group.properties,\n icon: icon || group.properties.icon,\n iconClassNames: iconClassNames || group.properties.iconClassNames,\n spin: spin || group.properties.spin,\n label,\n keyBinding,\n },\n };\n }, [group, applyActive, activeItem]);\n\n const trigger = (\n <ActionButton\n action={display}\n variant='ghost'\n disabled={disabled}\n iconSize={menu.iconSize}\n caretDown={caretDown && !disabled}\n testId={testId}\n {...(holds && { [TOOLBAR_HOLDS_ATTRIBUTE]: holds })}\n />\n );\n\n // No menu behind a disabled trigger, since `disabled` alone does not gate the machine's open handler.\n if (disabled) {\n return trigger;\n }\n\n return (\n <ActionMenu {...menu} group={group} actions={items}>\n {trigger}\n </ActionMenu>\n );\n};\n\nconst ToggleGroupItem = ({\n menu,\n group,\n action,\n}: ItemProps<{ group: MenuItemGroup<ToggleGroupMenuItemGroupProperties>; action: MenuAction }>) => {\n const { onAction, caller, iconSize } = menu;\n const { t } = Hooks.useTranslation(translationKey);\n const { icon, iconOnly = true, disabled, testId, hidden, classNames, spin } = action.properties;\n\n const handleClick = useCallback(() => {\n if (onAction) {\n onAction(action, { parent: group, caller });\n } else {\n void executeMenuAction(action, { parent: group, caller });\n }\n }, [action, group, caller, onAction]);\n\n if (hidden) {\n return null;\n }\n\n const common = {\n value: action.id,\n disabled,\n variant: 'ghost' as const,\n spin,\n iconSize: iconSize,\n classNames,\n onClick: handleClick,\n ...(testId && { 'data-testid': testId }),\n };\n\n return icon && iconOnly ? (\n <ToggleGroup.Item {...common} icon={icon} label={actionLabel(action, t)} iconOnly />\n ) : (\n <ToggleGroup.Item {...common} icon={icon}>\n <ActionLabel action={action} />\n </ToggleGroup.Item>\n );\n};\n\nconst ToggleGroupToolbarItem = ({\n menu,\n group,\n}: ItemProps<{ group: MenuItemGroup<ToggleGroupMenuItemGroupProperties> }>) => {\n const { t } = Hooks.useTranslation(translationKey);\n const items = useMenuItems(menu, group);\n const label = Theme.toLocalizedString(group.properties.label, t);\n\n // Only actions render as toggle group items.\n const children = items\n ?.filter((item) => !isSeparator(item) && !isMenuGroup(item))\n .map((item) => <ToggleGroupItem key={item.id} menu={menu} group={group} action={item as MenuAction} />);\n\n // The group is controlled by the graph: an item's action updates `value`, which flows back in.\n return group.properties.selectCardinality === 'multiple' ? (\n <Toolbar.ToggleGroup type='multiple' value={group.properties.value} aria-label={label}>\n {children}\n </Toolbar.ToggleGroup>\n ) : (\n <Toolbar.ToggleGroup type='single' value={group.properties.value} aria-label={label}>\n {children}\n </Toolbar.ToggleGroup>\n );\n};\n\nconst TextToolbarItem = ({ action }: { action: MenuAction }) => {\n const { t } = Hooks.useTranslation(translationKey);\n const { label, hidden, testId, classNames } = action.properties;\n if (hidden) {\n return null;\n }\n return (\n <Toolbar.Text classNames={classNames} {...(testId && { 'data-testid': testId })}>\n {Theme.toLocalizedString(label, t)}\n </Toolbar.Text>\n );\n};\n\n/**\n * One menu item rendered as its toolbar control (button, toggle, switch, dropdown, toggle group or custom); `collapsed`\n * renders its compact form.\n */\nexport const MenuToolbarItem = ({\n menu,\n item,\n collapsed = false,\n}: ItemProps<{ item: MenuItem; collapsed?: boolean }>) => {\n if (isSeparator(item)) {\n return <Toolbar.Separator variant={item.properties.variant === 'line' ? 'line' : 'gap'} />;\n }\n\n if (isMenuGroup(item)) {\n return item.properties.variant === 'dropdownMenu' ? (\n <DropdownToolbarItem menu={menu} group={item as MenuItemGroup<DropdownMenuItemGroupProperties>} />\n ) : (\n <ToggleGroupToolbarItem menu={menu} group={item as MenuItemGroup<ToggleGroupMenuItemGroupProperties>} />\n );\n }\n\n const action = item as MenuAction;\n switch (action.properties?.variant) {\n case 'switch':\n return <SwitchToolbarItem menu={menu} action={action} />;\n case 'toggle':\n return <ToggleToolbarItem menu={menu} action={action} compact={collapsed} />;\n case 'custom':\n // The contributor owns the rendered element (interactions the action model cannot express).\n return action.properties.render ? <>{action.properties.render({ collapsed })}</> : null;\n case 'text':\n return <TextToolbarItem action={action} />;\n default:\n return <ActionToolbarItem menu={menu} action={action} compact={collapsed} />;\n }\n};\n\n//\n// Layout (private): zones, rows and the overflow menu.\n//\n\nconst ZONES: readonly ToolbarZone[] = ['start', 'end'];\n\nconst placementOf = (item: MenuItem): ToolbarPlacement => (isSeparator(item) ? {} : (item.properties.placement ?? {}));\n\n/** A named group without a render variant: inline in a toolbar, a submenu in a menu. */\nconst isPlainGroup = (item: MenuItem): item is MenuItemGroup => isMenuGroup(item) && !item.properties.variant;\n\n/** Sorts by `placement.order`, an item without one keeping its insertion index. */\nconst byOrder = (items: readonly MenuItem[]): MenuItem[] =>\n items\n .map((item, index) => ({ item, order: placementOf(item).order ?? index }))\n .sort((a, b) => a.order - b.order)\n .map(({ item }) => item);\n\n/**\n * Drops separators left leading, trailing or doubled once items are placed elsewhere: of a run between two items, a gap\n * stays if there is one, as it lays the row out, else the last.\n */\nconst trimSeparators = (items: readonly MenuItem[]): MenuItem[] =>\n items.filter((item, index) => {\n if (!isSeparator(item)) {\n return true;\n }\n const before = items.findLastIndex((other, at) => at < index && !isSeparator(other));\n const after = items.findIndex((other, at) => at > index && !isSeparator(other));\n if (before < 0 || after < 0) {\n return false;\n }\n const run = items.slice(before + 1, after);\n const gap = run.findLastIndex((separator) => isSeparator(separator) && separator.properties.variant === 'gap');\n return index === before + 1 + (gap >= 0 ? gap : run.length - 1);\n });\n\n/** A named group laid out inline, its own and contributed items in order; ruled off from what precedes it. */\nconst InlineGroup = ({ menu, group, separated }: ItemProps<{ group: MenuItemGroup; separated: boolean }>) => {\n const items = useMenuItems(menu, group);\n const ordered = useMemo(() => byOrder(items ?? []), [items]);\n if (ordered.length === 0) {\n return null;\n }\n return (\n <>\n {separated && <Toolbar.Separator variant='line' />}\n {ordered.map((item) => (\n <MenuToolbarItem key={item.id} menu={menu} item={item} />\n ))}\n </>\n );\n};\n\n/** A rule in the ⋮ menu where the rows' items it lists change zone or row, or give way to its own. */\nconst menuBreak = (id: string): MenuSeparator => ({\n id: `toolbar-break-${id}`,\n type: MenuSeparatorType,\n properties: { variant: 'gap' },\n data: undefined as never,\n});\n\n/**\n * The ⋮ menu: what collapsed out of the rows, in the rows' order and ruled where they are (named groups as submenus),\n * then the overflow group's own and contributed items.\n */\nconst OverflowMenu = ({ menu, group, collapsed }: ItemProps<{ group: MenuItemGroup; collapsed: MenuItem[] }>) => {\n const items = useMenuItems(menu, group);\n const actions = useMemo(\n () => trimSeparators([...collapsed, menuBreak('overflow'), ...byOrder(items ?? [])]),\n [collapsed, items],\n );\n return <OverflowMenuTrigger menu={menu} actions={actions} testId={group.properties.testId} />;\n};\n\nconst OverflowMenuTrigger = ({ menu, actions, testId }: ItemProps<{ actions: MenuItem[]; testId?: string }>) => {\n const { t } = Hooks.useTranslation(translationKey);\n if (actions.length === 0) {\n return null;\n }\n return (\n <ActionMenu {...menu} actions={actions}>\n <Button.Root\n data-testid={testId ?? TOOLBAR_OVERFLOW_TESTID}\n icon='ph--dots-three-vertical--regular'\n iconOnly\n variant='ghost'\n label={t('toolbar-overflow.menu')}\n />\n </ActionMenu>\n );\n};\n\n/** The element a row lays out in: the `Toolbar.Root` scroll frame around it, else the row itself. */\nconst frameOf = (row: HTMLElement): HTMLElement =>\n row.parentElement?.classList.contains('dx-toolbar-scroll') ? row.parentElement : row;\n\n/** A menu cannot show a control the contributor renders itself, or a label, so such items never leave the row. */\nconst isMenuable = (item: MenuItem): boolean =>\n !isSeparator(item) && item.properties.variant !== 'custom' && item.properties.variant !== 'text';\n\n/**\n * Steps the toolbar takes while a row is too narrow, in order: an item taking its compact form, a group folding in\n * place, or an item moving to ⋮.\n */\ntype CollapseStep = { kind: 'compact' | 'fold' | 'move'; item: MenuItem };\n\n/** What the collapse has done so far: the items moved into ⋮, the groups folded and the items compacted, by id. */\ntype Collapsed = { moved: MenuItem[]; folded: ReadonlySet<string>; compacted: ReadonlySet<string> };\n\n/**\n * A ranked item that has a compact form collapses in place to it: a `custom` item renders with `collapsed`, and an\n * action shown with its label and an icon shows the icon alone.\n */\nconst isCompactable = (item: MenuItem): boolean => {\n if (isSeparator(item) || isMenuGroup(item) || placementOf(item).collapse === undefined) {\n return false;\n }\n const { variant, icon, iconOnly } = item.properties;\n return variant === 'custom' || (!!icon && iconOnly === false && variant !== 'text' && variant !== 'switch');\n};\n\n/**\n * Collapses items while any row is too narrow, so the toolbar fills its container without overflowing it. First each\n * ranked item with a compact form takes it (highest rank first); then groups marked `fold` fold; then ranked items move\n * into the overflow menu, then the rest, last first. Each step is undone once the toolbar is wider than when it was\n * taken, or tried again once an item's content changes, so hidden items are never measured.\n */\nconst useCollapse = (\n menu: MenuActions,\n units: MenuItem[],\n rows: RefObject<(HTMLElement | null)[]>,\n bounds: HTMLElement | null | undefined,\n): Collapsed => {\n const registry = useContext(RegistryContext);\n const steps = useMemo<CollapseStep[]>(() => {\n // A named group collapses as a submenu, which can only hold what a menu shows; an empty one takes no room to free.\n const canCollapse = (item: MenuItem) => {\n if (!isMenuable(item)) {\n return false;\n }\n if (!isPlainGroup(item)) {\n return true;\n }\n // A separator rules a menu as it does a row.\n const children = (registry.get(menu.items(item)) ?? []).filter((child) => !isSeparator(child));\n return children.length > 0 && children.every(isMenuable);\n };\n const ranked = units\n .map((item, index) => ({ item, rank: placementOf(item).collapse, index }))\n .filter(({ rank }) => rank !== undefined)\n .sort((a, b) => (b.rank ?? 0) - (a.rank ?? 0) || b.index - a.index)\n .map(({ item }) => item);\n const rest = units.filter((item) => placementOf(item).collapse === undefined && canCollapse(item)).reverse();\n const order = [...ranked.filter(canCollapse), ...rest];\n return [\n ...ranked.filter(isCompactable).map((item) => ({ kind: 'compact' as const, item })),\n ...order\n .filter((item) => isPlainGroup(item) && placementOf(item).fold)\n .map((item) => ({ kind: 'fold' as const, item })),\n ...order.map((item) => ({ kind: 'move' as const, item })),\n ];\n }, [registry, menu, units]);\n\n const [count, setCount] = useState(0);\n const thresholds = useRef<number[]>([]);\n const [width, setWidth] = useState(0);\n // Bumped when an item's own content (a custom item's children) changes.\n const [contentChanges, setContentChanges] = useState(0);\n const measuredChanges = useRef(contentChanges);\n // Ids rather than the items: `steps` is rebuilt whenever a caller passes a fresh `onAction`.\n const stepsKey = steps.map(({ kind, item }) => `${kind}:${item.id}`).join('\\n');\n\n // Each read forces a layout, so measure only when the items (a new label or icon-only flag yields new items), the\n // steps, the step count, the frame width or an item's content moved.\n useLayoutEffect(() => {\n if (steps.length === 0 && count === 0) {\n return;\n }\n const elements = rows.current.filter((row): row is HTMLElement => !!row);\n if (elements.length === 0) {\n return;\n }\n const width = (bounds ?? frameOf(elements[0])).clientWidth;\n // A toolbar not laid out yet (a closed drawer, a hidden panel) has no width to fit; it is measured once it has one.\n if (width === 0) {\n return;\n }\n // Content that shrank may make room at this width for a step taken, so each step is tried again.\n if (measuredChanges.current !== contentChanges) {\n measuredChanges.current = contentChanges;\n thresholds.current.fill(0);\n }\n const overflowing = elements.some((row) => row.scrollWidth > row.clientWidth + 1);\n if (overflowing && count < steps.length) {\n thresholds.current[count] = width;\n setCount(count + 1);\n } else if (!overflowing && count > 0 && width > (thresholds.current[count - 1] ?? Infinity)) {\n setCount(count - 1);\n }\n }, [units, stepsKey, count, width, bounds, contentChanges]);\n\n // Re-render on resize only when something can collapse.\n const observed = steps.length > 0;\n useLayoutEffect(() => {\n const element = rows.current[0];\n if (!observed || !element) {\n return;\n }\n const observer = new ResizeObserver(([entry]) => setWidth(entry.contentRect.width));\n observer.observe(bounds ?? frameOf(element));\n return () => observer.disconnect();\n }, [observed, rows, bounds]);\n\n // Content that changes inside an item leaves the items and the frame as they were, so neither observer above sees it.\n useLayoutEffect(() => {\n const elements = rows.current.filter((row): row is HTMLElement => !!row);\n if (!observed || elements.length === 0) {\n return;\n }\n // A step's own render changes the rows too; this observer is replaced then, which drops those records.\n const observer = new MutationObserver(() => setContentChanges((changes) => changes + 1));\n elements.forEach((row) => observer.observe(row, { childList: true, subtree: true, characterData: true }));\n return () => observer.disconnect();\n }, [observed, rows, units, count]);\n\n return useMemo(() => {\n const taken = steps.slice(0, count);\n return {\n moved: taken.filter(({ kind }) => kind === 'move').map(({ item }) => item),\n folded: new Set(taken.filter(({ kind }) => kind === 'fold').map(({ item }) => item.id)),\n compacted: new Set(taken.filter(({ kind }) => kind === 'compact').map(({ item }) => item.id)),\n };\n }, [steps, count]);\n};\n\n/** A folded group: its items in a dropdown, under the group's own label and icon. */\nconst FoldedGroup = ({ menu, group }: ItemProps<{ group: MenuItemGroup }>) => {\n const registry = useContext(RegistryContext);\n const dropdown = useMemo<MenuItemGroup<DropdownMenuItemGroupProperties>>(() => {\n const { label, icon, ...properties } = group.properties;\n return { ...group, properties: { ...properties, label, icon, variant: 'dropdownMenu' } };\n }, [group]);\n const holds = useMemo(() => heldTestIds(registry, menu, group).join(' '), [registry, menu, group]);\n return <DropdownToolbarItem menu={menu} group={dropdown} holds={holds} />;\n};\n\n/** The test ids of a group's items at any depth. */\nconst heldTestIds = (registry: Registry.AtomRegistry, menu: MenuActions, group: MenuItemGroup): string[] =>\n (registry.get(menu.items(group)) ?? []).flatMap((item) =>\n isSeparator(item)\n ? []\n : [\n ...(item.properties.testId ? [item.properties.testId as string] : []),\n ...(isMenuGroup(item) ? heldTestIds(registry, menu, item) : []),\n ],\n );\n\nconst setRef = <T,>(ref: ForwardedRef<T>, value: T | null) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\n//\n// ActionToolbar\n//\n\n/** Each group's items from `base`, then from `extra`, so a second graph extends the first group by group. */\nconst mergeItems = (base: MenuItemsAccessor, extra: MenuItemsAccessor): MenuItemsAccessor => {\n const atoms = new Map<string, Atom.Atom<MenuItem[] | null>>();\n return (group) => {\n const key = group?.id ?? '';\n let atom = atoms.get(key);\n if (!atom) {\n atom = Atom.make((get) => {\n const own = get(base(group));\n const added = get(extra(group));\n return own || added ? [...(own ?? []), ...(added ?? [])] : null;\n });\n atoms.set(key, atom);\n }\n return atom;\n };\n};\n\nexport type ActionToolbarProps = Partial<MenuActions> &\n Omit<Toolbar.RootProps, 'disabled' | 'children'> & {\n /** The toolbar is dimmed (still operable) while this attendable lacks attention, unless `alwaysActive`. */\n attendableId?: string;\n alwaysActive?: boolean;\n /**\n * Items another component adds to this toolbar, merged with its own group by group: root items follow the owner's,\n * and `MenuBuilder.extend(groupId, …)` adds to a named group.\n */\n customActions?: Atom.Atom<ActionGraphProps>;\n /**\n * The box whose width the toolbar may fill, measured to decide when collapsed items fit again; by default the\n * toolbar's own frame. A toolbar as wide as its content passes the box it sits in, or it never grows back.\n */\n bounds?: HTMLElement | null;\n };\n\n/**\n * A toolbar driven from a `MenuActions`. Each item's `placement` puts it in the start or end zone of a row; a\n * plain named group renders inline and others extend it (`MenuBuilder.extend`); the overflow menu (⋮,\n * `TOOLBAR_OVERFLOW_ID`) ends the first row and takes collapsible items while a row is too narrow. One row renders as a\n * single `Toolbar.Root` (which takes the props and ref); more stack one per row. Hand-written controls join the graph as\n * `custom` items (`MenuBuilder.custom`), labels as `text` items.\n */\nexport const ActionToolbar = Util.composable<HTMLDivElement, ActionToolbarProps>(\n (\n // Controls join the graph as `custom` items, so `children` are dropped rather than rendered.\n {\n items,\n contributions,\n onAction,\n caller,\n iconSize,\n attendableId,\n alwaysActive,\n customActions,\n bounds,\n children: _,\n ...props\n },\n forwardedRef,\n ) => {\n // Called unconditionally (hooks), used only when no source was spread in.\n const standalone = useMenuActions();\n const custom = useMenuActions(customActions);\n const menu = useMemo<MenuActions>(\n () => ({\n items: customActions ? mergeItems(items ?? standalone.items, custom.items) : (items ?? standalone.items),\n contributions: contributions ?? standalone.contributions,\n onAction,\n caller,\n iconSize,\n }),\n [items, contributions, onAction, caller, iconSize, standalone, customActions, custom],\n );\n const { hasAttention } = useAttention(attendableId);\n\n const rootItems = useMenuItems(menu);\n const overflow =\n rootItems?.find((item): item is MenuItemGroup => isMenuGroup(item) && item.id === TOOLBAR_OVERFLOW_ID) ??\n defaultOverflowGroup;\n const units = useMemo(() => (rootItems ?? []).filter((item) => item.id !== TOOLBAR_OVERFLOW_ID), [rootItems]);\n const rows = useRef<(HTMLElement | null)[]>([]);\n const { moved: collapsed, folded, compacted } = useCollapse(menu, units, rows, bounds);\n\n const rowCount = Math.max(1, ...units.map((item) => (placementOf(item).row ?? 0) + 1));\n // Sorted before `keep` filters, so an item's fallback order is its index in the whole zone.\n const inZone = (row: number, zone: ToolbarZone, keep: (item: MenuItem) => boolean) =>\n byOrder(\n units.filter((item) => {\n const placement = placementOf(item);\n return (placement.row ?? 0) === row && (placement.zone ?? 'start') === zone;\n }),\n ).filter(keep);\n const zone = (row: number, zone: ToolbarZone) =>\n trimSeparators(inZone(row, zone, (item) => !collapsed.includes(item)));\n const moved = Array.from({ length: rowCount }, (_, row) =>\n ZONES.flatMap((name) => [\n menuBreak(`${row}-${name}`),\n ...inZone(row, name, (item) => isSeparator(item) || collapsed.includes(item)),\n ]),\n ).flat();\n\n const renderRow = (row: number) => {\n const zones = ZONES.map((name) => ({ name, items: zone(row, name) }));\n const first = row === 0;\n return (\n <Toolbar.Root\n key={row}\n {...(first ? Util.composableProps(props, { classNames: attendableId }) : { classNames: props.classNames })}\n data-row={rowCount > 1 ? row : undefined}\n inactive={!alwaysActive && !hasAttention}\n ref={(element: HTMLDivElement | null) => {\n rows.current[row] = element;\n first && setRef(forwardedRef, element);\n }}\n >\n {zones.map(({ name, items }, index) => (\n <Fragment key={name}>\n {/* A gap pushes the end zone to the far right. */}\n {index > 0 && items.length > 0 && <Toolbar.Separator variant='gap' />}\n {items.map((item, index) =>\n isPlainGroup(item) && folded.has(item.id) ? (\n <FoldedGroup key={item.id} menu={menu} group={item} />\n ) : isPlainGroup(item) ? (\n // A folding group holds the toolbar's own controls, so it is spaced like them rather than ruled off.\n <InlineGroup\n key={item.id}\n menu={menu}\n group={item}\n separated={index > 0 && !placementOf(item).fold}\n />\n ) : (\n <MenuToolbarItem key={item.id} menu={menu} item={item} collapsed={compacted.has(item.id)} />\n ),\n )}\n </Fragment>\n ))}\n {first && <OverflowMenu menu={menu} group={overflow} collapsed={moved} />}\n </Toolbar.Root>\n );\n };\n\n return rowCount === 1 ? (\n renderRow(0)\n ) : (\n <div role='none' className='flex flex-col w-full min-w-0 min-h-fit'>\n {Array.from({ length: rowCount }, (_, row) => renderRow(row))}\n </div>\n );\n },\n);\n\nActionToolbar.displayName = 'ActionToolbar';\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport * as Button from '@dxos/react-ui/Button';\n\nimport { createLineSeparator, createMenuAction, createMenuItemGroup } from '../util.ts';\nimport { ActionMenu } from './ActionMenu.tsx';\n\n/** One choice of a {@link SortMenu} or {@link GroupMenu}, labelled by the host so each list keeps its own wording. */\nexport type ViewOption<T extends string> = {\n id: T;\n label: string;\n icon: string;\n};\n\nexport type SortDirection = 'asc' | 'desc';\n\nexport type SortValue<T extends string> = {\n field: T;\n direction: SortDirection;\n};\n\nexport type SortMenuProps<T extends string> = {\n fields: readonly ViewOption<T>[];\n value: SortValue<T>;\n onChange: (value: SortValue<T>) => void;\n /** Trigger label while the list is in its own order, and the menu's heading. */\n label: string;\n directionLabels: Record<SortDirection, string>;\n /** A field that is the list's own order (e.g. a hand-arranged one), so it has no direction to pick. */\n unsorted?: T;\n /** Prefix of the trigger's and items' test ids (`<testId>.<field>`, `<testId>.<direction>`). */\n testId?: string;\n};\n\n/**\n * The order-by field and its direction, as one menu beside a list's filter. The value is the host's to\n * persist — typically in a `ViewState` aspect beside the filter query.\n */\nexport const SortMenu = <T extends string>({\n fields,\n value,\n onChange,\n label,\n directionLabels,\n unsorted,\n testId = 'sort',\n}: SortMenuProps<T>) => {\n const sorted = value.field !== unsorted;\n const current = fields.find((field) => field.id === value.field);\n\n const group = useMemo(\n () =>\n createMenuItemGroup(testId, {\n label,\n icon: 'ph--sort-ascending--regular',\n variant: 'dropdownMenu',\n selectCardinality: 'single',\n value: value.field,\n }),\n [testId, label, value.field],\n );\n\n const actions = useCallback(\n () => [\n ...fields.map((field) =>\n createMenuAction(`sort-${field.id}`, () => onChange({ ...value, field: field.id }), {\n label: field.label,\n icon: field.icon,\n checked: value.field === field.id,\n testId: `${testId}.${field.id}`,\n }),\n ),\n createLineSeparator(`${testId}Separator`).nodes[0],\n ...(['asc', 'desc'] as const).map((direction) =>\n createMenuAction(`sort-${direction}`, () => onChange({ ...value, direction }), {\n label: directionLabels[direction],\n icon: direction === 'asc' ? 'ph--sort-ascending--regular' : 'ph--sort-descending--regular',\n checked: sorted && value.direction === direction,\n disabled: !sorted,\n testId: `${testId}.${direction}`,\n }),\n ),\n ],\n [fields, value, sorted, onChange, directionLabels, testId],\n );\n\n return (\n <ActionMenu deferUntilOpen group={group} actions={actions}>\n <Button.Root\n // The trigger names the order while it is not the list's own, so a reader can tell why rows moved.\n icon={\n !sorted\n ? 'ph--arrows-down-up--regular'\n : value.direction === 'asc'\n ? 'ph--sort-ascending--regular'\n : 'ph--sort-descending--regular'\n }\n iconOnly={!sorted}\n label={sorted && current ? current.label : label}\n data-testid={testId}\n />\n </ActionMenu>\n );\n};\n\nSortMenu.displayName = 'SortMenu';\n\nexport type GroupMenuProps<T extends string> = {\n fields: readonly ViewOption<T>[];\n value: T;\n onChange: (value: T) => void;\n /** Trigger label while the list is ungrouped, and the menu's heading. */\n label: string;\n /** The field that means one ungrouped list. */\n none?: T;\n /** Prefix of the trigger's and items' test ids (`<testId>.<field>`). */\n testId?: string;\n};\n\n/** What a list is grouped by, as a single-select menu beside its sort. */\nexport const GroupMenu = <T extends string>({\n fields,\n value,\n onChange,\n label,\n none,\n testId = 'group',\n}: GroupMenuProps<T>) => {\n const current = value !== none ? fields.find((field) => field.id === value) : undefined;\n\n const group = useMemo(\n () =>\n createMenuItemGroup(testId, {\n label,\n icon: 'ph--rows--regular',\n variant: 'dropdownMenu',\n selectCardinality: 'single',\n value,\n }),\n [testId, label, value],\n );\n\n const actions = useCallback(\n () =>\n fields.map((field) =>\n createMenuAction(`group-${field.id}`, () => onChange(field.id), {\n label: field.label,\n icon: field.icon,\n checked: value === field.id,\n testId: `${testId}.${field.id}`,\n }),\n ),\n [fields, value, onChange, testId],\n );\n\n return (\n <ActionMenu deferUntilOpen group={group} actions={actions}>\n <Button.Root\n icon={current ? current.icon : 'ph--rows--regular'}\n iconOnly={!current}\n label={current ? current.label : label}\n data-testid={testId}\n />\n </ActionMenu>\n );\n};\n\nGroupMenu.displayName = 'GroupMenu';\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as AppGraphNode from '@dxos/app-graph/AppGraphNode';\n\n/** `disposition` value an action opts into to appear in an object toolbar (vs context-menu-only). */\nexport const TOOLBAR_DISPOSITION = 'toolbar';\n\n/** Filter for {@link graphActions}: keeps only actions a producer opted into the toolbar. */\nexport const isToolbarAction = (action: AppGraphNode.ActionLike): boolean =>\n AppGraphNode.hasDisposition(action, TOOLBAR_DISPOSITION);\n\n/**\n * `disposition` value an action opts into to appear in the row beside a text input — a chat prompt\n * today.\n *\n * Separate from {@link TOOLBAR_DISPOSITION} because the two surfaces act on different things: an\n * object toolbar acts on the object, a prompt row acts on the text being composed. Commenting on a\n * document belongs in the first and means nothing in the second; dictation belongs in both, and says\n * so by listing both (`disposition` takes an array).\n */\nexport const PROMPT_DISPOSITION = 'prompt';\n\n/** Filter for {@link graphActions}: keeps only actions a producer opted into a prompt row. */\nexport const isPromptAction = (action: AppGraphNode.ActionLike): boolean =>\n AppGraphNode.hasDisposition(action, PROMPT_DISPOSITION);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAa,oBAAoB;AAMjC,IAAa,eAAe,SAAmD,KAAK,SAAS;AAI7F,IAAa,eAAe,SAC1B,KAAK,SAAS,aAAa;;;;;;;ACX7B,IAAa,oBAAoB,OAAO,QAAoB,SAA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
import
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { CustomRenderProps, MenuActionProperties, MenuItemGroupProperties } from '@dxos/ui-types';
|
|
2
3
|
import type { ActionGraphProps } from './hooks/index.ts';
|
|
3
4
|
/** Callback that populates an action group builder. */
|
|
4
5
|
export type ActionGroupBuilderFn = (builder: ActionGroupBuilder) => void;
|
|
@@ -23,6 +24,10 @@ export interface ActionGroupBuilder {
|
|
|
23
24
|
switch(id: string, props: Omit<MenuActionProperties, 'variant'> & {
|
|
24
25
|
checked: boolean;
|
|
25
26
|
}, invoke: () => void): this;
|
|
27
|
+
/** Add a control the caller renders itself (a picker, a field); it stays in the toolbar and never collapses. */
|
|
28
|
+
custom(id: string, props: Omit<MenuActionProperties, 'variant' | 'render'>, render: (props: CustomRenderProps) => ReactNode): this;
|
|
29
|
+
/** Add a plain label (e.g. a panel's name) that takes the toolbar's free space. */
|
|
30
|
+
text(id: string, props: Omit<MenuActionProperties, 'variant' | 'render'>): this;
|
|
26
31
|
/** Add a nested action group. */
|
|
27
32
|
group(id: string, props: MenuItemGroupProperties, cb: ActionGroupBuilderFn): this;
|
|
28
33
|
/** Merge pre-built nodes and edges, or build a subgraph via callback scoped to the current group. Falsy values are ignored. */
|
|
@@ -45,7 +50,21 @@ export interface MenuBuilder extends ActionGroupBuilder {
|
|
|
45
50
|
*/
|
|
46
51
|
build(): ActionGraphProps;
|
|
47
52
|
}
|
|
53
|
+
/** Id of the overflow menu (⋮) every toolbar ends with; contributors add to it with {@link MenuBuilder.extend}. */
|
|
54
|
+
export declare const TOOLBAR_OVERFLOW_ID = "toolbar-overflow";
|
|
55
|
+
/** The overflow group a toolbar uses when its owner declares none, so contributors can still add to it. */
|
|
56
|
+
export declare const defaultOverflowGroup: {
|
|
57
|
+
id: string;
|
|
58
|
+
type: string;
|
|
59
|
+
properties: MenuItemGroupProperties;
|
|
60
|
+
data: typeof import("@dxos/app-graph/AppGraphNode").actionGroupSymbol;
|
|
61
|
+
};
|
|
48
62
|
export declare const MenuBuilder: Readonly<{
|
|
49
63
|
make: () => MenuBuilder;
|
|
64
|
+
/**
|
|
65
|
+
* Builds items into a named group another component declared, so a plugin extends a toolbar or menu it does not own.
|
|
66
|
+
* The result is merged into the owner's graph (e.g. with `subgraph`); its edges hang off `groupId`.
|
|
67
|
+
*/
|
|
68
|
+
extend: (groupId: string, cb: ActionGroupBuilderFn) => ActionGraphProps;
|
|
50
69
|
}>;
|
|
51
70
|
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../src/builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../src/builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EACV,iBAAiB,EAEjB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAazD,uDAAuD;AACvD,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAEzE;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,MAAM,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,oBAAoB,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAEjG,8DAA8D;IAC9D,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAElH,gHAAgH;IAChH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d.ts","sourceRoot":"","sources":["../../../../src/components/ActionMenu.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ActionMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/ActionMenu.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAIZ,KAAK,SAAS,EACd,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAef,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EAId,MAAM,aAAa,CAAC;AA0QrB,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG;IACnD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,qEAAqE;IACrE,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,QAAQ,EAAE,CAAC,CAAC;IAC1C;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qHAAqH;IACrH,UAAU,CAAC,EAAE,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/B,mBAAmB;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;mCAOyB,KAAK,EAAE,eAAe"}
|
|
@@ -19,6 +19,8 @@ export declare const StaticItems: Story;
|
|
|
19
19
|
export declare const ReactiveItems: Story;
|
|
20
20
|
export declare const ReplacementMode: Story;
|
|
21
21
|
export declare const PriorityOrdering: Story;
|
|
22
|
+
/** Toggles are checkboxes, each pressed on its own; other checked actions in a run are one radio group. */
|
|
23
|
+
export declare const Toggles: Story;
|
|
22
24
|
/** A menu that builds its machine on the trigger's first click; the click both builds and opens it. */
|
|
23
25
|
export declare const DeferUntilOpen: Story;
|
|
24
26
|
//# sourceMappingURL=ActionMenu.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionMenu.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/ActionMenu.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKjE,OAAO,0BAA0B,CAAC;AAalC,QAAA,MAAM,IAAI;;;;;;;;;;;;CAMM,CAAC;eAEF,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionMenu.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/ActionMenu.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKjE,OAAO,0BAA0B,CAAC;AAalC,QAAA,MAAM,IAAI;;;;;;;;;;;;CAMM,CAAC;eAEF,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC;AA2CtB,eAAO,MAAM,WAAW,EAAE,KAwBzB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KA2C3B,CAAC;AAMF,eAAO,MAAM,eAAe,EAAE,KAoB7B,CAAC;AAUF,eAAO,MAAM,gBAAgB,EAAE,KAsB9B,CAAC;AAEF,2GAA2G;AAC3G,eAAO,MAAM,OAAO,EAAE,KA8BrB,CAAC;AAEF,uGAAuG;AACvG,eAAO,MAAM,cAAc,EAAE,KAmB5B,CAAC"}
|