@dxos/react-ui-menu 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

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.
@@ -1,11 +1,16 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
+ // packages/ui/react-ui-menu/src/index.ts
4
+ import { rxFromSignal } from "@dxos/app-graph";
5
+
3
6
  // packages/ui/react-ui-menu/src/components/DropdownMenu.tsx
7
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
4
8
  import { useControllableState } from "@radix-ui/react-use-controllable-state";
5
9
  import React3, { useCallback } from "react";
6
10
  import { DropdownMenu as NaturalDropdownMenu, Icon } from "@dxos/react-ui";
7
11
 
8
12
  // packages/ui/react-ui-menu/src/components/ActionLabel.tsx
13
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
9
14
  import React from "react";
10
15
  import { keySymbols } from "@dxos/keyboard";
11
16
  import { toLocalizedString, useTranslation } from "@dxos/react-ui";
@@ -78,13 +83,18 @@ var createLineSeparator = (id = "line", source = "root") => ({
78
83
 
79
84
  // packages/ui/react-ui-menu/src/components/ActionLabel.tsx
80
85
  var ActionLabel = ({ action }) => {
81
- const shortcut = getShortcut(action);
82
- const { t } = useTranslation(translationKey);
83
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
84
- className: "grow truncate"
85
- }, toLocalizedString(action.properties.label, t)), shortcut && /* @__PURE__ */ React.createElement("span", {
86
- className: mx("shrink-0", descriptionText)
87
- }, keySymbols(shortcut).join("")));
86
+ var _effect = _useSignals();
87
+ try {
88
+ const shortcut = getShortcut(action);
89
+ const { t } = useTranslation(translationKey);
90
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
91
+ className: "grow truncate"
92
+ }, toLocalizedString(action.properties.label, t)), shortcut && /* @__PURE__ */ React.createElement("span", {
93
+ className: mx("shrink-0", descriptionText)
94
+ }, keySymbols(shortcut).join("")));
95
+ } finally {
96
+ _effect.f();
97
+ }
88
98
  };
89
99
  var actionLabel = (action, t) => {
90
100
  const shortcut = getShortcut(action);
@@ -92,6 +102,7 @@ var actionLabel = (action, t) => {
92
102
  };
93
103
 
94
104
  // packages/ui/react-ui-menu/src/components/MenuContext.tsx
105
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
95
106
  import { createContextScope } from "@radix-ui/react-context";
96
107
  import React2, { useMemo } from "react";
97
108
  var MENU_NAME = "GraphMenu";
@@ -103,13 +114,18 @@ var menuContextDefaults = {
103
114
  };
104
115
  var useMenuScope = createMenuScope();
105
116
  var MenuProvider = ({ children, useGroupItems = menuContextDefaults.useGroupItems, iconSize = menuContextDefaults.iconSize, attendableId }) => {
106
- const { scope } = useMenuScope(void 0);
107
- return /* @__PURE__ */ React2.createElement(MenuContextProvider, {
108
- useGroupItems,
109
- iconSize,
110
- attendableId,
111
- scope
112
- }, children);
117
+ var _effect = _useSignals2();
118
+ try {
119
+ const { scope } = useMenuScope(void 0);
120
+ return /* @__PURE__ */ React2.createElement(MenuContextProvider, {
121
+ useGroupItems,
122
+ iconSize,
123
+ attendableId,
124
+ scope
125
+ }, children);
126
+ } finally {
127
+ _effect.f();
128
+ }
113
129
  };
114
130
  var useMenuItems = (group, propsItems, consumerName = "useMenuItemConsumer", __menuScope) => {
115
131
  const { useGroupItems } = useMenu(consumerName, __menuScope);
@@ -122,65 +138,66 @@ var useMenuItems = (group, propsItems, consumerName = "useMenuItemConsumer", __m
122
138
 
123
139
  // packages/ui/react-ui-menu/src/components/DropdownMenu.tsx
124
140
  var DropdownMenuItem = ({ item, onClick, __menuScope }) => {
125
- const action = item;
126
- const handleClick = useCallback((event) => onClick(action, event), [
127
- action,
128
- onClick
129
- ]);
130
- const { iconSize } = useMenu("DropdownMenuItem", __menuScope);
131
- return /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Item, {
132
- onClick: handleClick,
133
- classNames: "gap-2",
134
- disabled: action.properties?.disabled,
135
- ...action.properties?.testId && {
136
- "data-testid": action.properties.testId
137
- }
138
- }, action.properties?.icon && /* @__PURE__ */ React3.createElement(Icon, {
139
- icon: action.properties.icon,
140
- size: iconSize
141
- }), /* @__PURE__ */ React3.createElement(ActionLabel, {
142
- action
143
- }));
141
+ var _effect = _useSignals3();
142
+ try {
143
+ const action = item;
144
+ const handleClick = useCallback((event) => onClick(action, event), [
145
+ action,
146
+ onClick
147
+ ]);
148
+ const { iconSize } = useMenu("DropdownMenuItem", __menuScope);
149
+ return /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Item, {
150
+ onClick: handleClick,
151
+ classNames: "gap-2",
152
+ disabled: action.properties?.disabled,
153
+ ...action.properties?.testId && {
154
+ "data-testid": action.properties.testId
155
+ }
156
+ }, action.properties?.icon && /* @__PURE__ */ React3.createElement(Icon, {
157
+ icon: action.properties.icon,
158
+ size: iconSize
159
+ }), /* @__PURE__ */ React3.createElement(ActionLabel, {
160
+ action
161
+ }));
162
+ } finally {
163
+ _effect.f();
164
+ }
144
165
  };
145
- var DropdownMenuRoot = ({ items: propsItems, group, open, defaultOpen, onOpenChange, suppressNextTooltip, caller, children, __menuScope, ...naturalProps }) => {
146
- const [optionsMenuOpen, setOptionsMenuOpen] = useControllableState({
147
- prop: open,
148
- defaultProp: defaultOpen,
149
- onChange: onOpenChange
150
- });
151
- const handleActionClick = useCallback((action, event) => {
152
- if (action.properties?.disabled) {
153
- return;
154
- }
155
- event.stopPropagation();
156
- if (suppressNextTooltip) {
157
- suppressNextTooltip.current = true;
158
- }
159
- setOptionsMenuOpen(false);
160
- void action.data?.({
161
- parent: group,
162
- caller
166
+ var DropdownMenuRoot = ({ items: propsItems, group, open, defaultOpen, onOpenChange, caller, children, __menuScope, ...naturalProps }) => {
167
+ var _effect = _useSignals3();
168
+ try {
169
+ const [optionsMenuOpen, setOptionsMenuOpen] = useControllableState({
170
+ prop: open,
171
+ defaultProp: defaultOpen,
172
+ onChange: onOpenChange
163
173
  });
164
- }, [
165
- suppressNextTooltip,
166
- group,
167
- caller
168
- ]);
169
- const items = useMenuItems(group, propsItems);
170
- return /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Root, {
171
- open: optionsMenuOpen,
172
- onOpenChange: (nextOpen) => {
173
- if (!nextOpen && suppressNextTooltip) {
174
- suppressNextTooltip.current = true;
174
+ const handleActionClick = useCallback((action, event) => {
175
+ if (action.properties?.disabled) {
176
+ return;
175
177
  }
176
- return setOptionsMenuOpen(nextOpen);
177
- },
178
- ...naturalProps
179
- }, children, /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Portal, null, /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Content, null, /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Viewport, null, items?.map((item) => /* @__PURE__ */ React3.createElement(DropdownMenuItem, {
180
- key: item.id,
181
- item,
182
- onClick: handleActionClick
183
- }))), /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Arrow, null))));
178
+ event.stopPropagation();
179
+ setOptionsMenuOpen(false);
180
+ void action.data?.({
181
+ parent: group,
182
+ caller
183
+ });
184
+ }, [
185
+ group,
186
+ caller
187
+ ]);
188
+ const items = useMenuItems(group, propsItems);
189
+ return /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Root, {
190
+ open: optionsMenuOpen,
191
+ onOpenChange: setOptionsMenuOpen,
192
+ ...naturalProps
193
+ }, children, /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Portal, null, /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Content, null, /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Viewport, null, items?.map((item) => /* @__PURE__ */ React3.createElement(DropdownMenuItem, {
194
+ key: item.id,
195
+ item,
196
+ onClick: handleActionClick
197
+ }))), /* @__PURE__ */ React3.createElement(NaturalDropdownMenu.Arrow, null))));
198
+ } finally {
199
+ _effect.f();
200
+ }
184
201
  };
185
202
  var DropdownMenu = {
186
203
  Root: DropdownMenuRoot,
@@ -189,7 +206,8 @@ var DropdownMenu = {
189
206
  };
190
207
 
191
208
  // packages/ui/react-ui-menu/src/components/ToolbarMenu.tsx
192
- import React4, { useCallback as useCallback2, useRef } from "react";
209
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
210
+ import React4, { useCallback as useCallback2 } from "react";
193
211
  import { Icon as Icon2, Toolbar as NaturalToolbar, useTranslation as useTranslation2 } from "@dxos/react-ui";
194
212
  import { useAttention } from "@dxos/react-ui-attention";
195
213
 
@@ -201,171 +219,192 @@ var isMenuGroup = (node) => node.type === ACTION_GROUP_TYPE2;
201
219
 
202
220
  // packages/ui/react-ui-menu/src/components/ToolbarMenu.tsx
203
221
  var ActionToolbarItem = ({ action, __menuScope }) => {
204
- const { iconSize } = useMenu("ActionToolbarItem", __menuScope);
205
- const { t } = useTranslation2(translationKey);
206
- const handleClick = useCallback2(() => action.data?.(), [
207
- action
208
- ]);
209
- const { icon, iconOnly = true, disabled, testId, hidden, classNames } = action.properties;
210
- const Root = icon ? NaturalToolbar.IconButton : NaturalToolbar.Button;
211
- const rootProps = icon ? {
212
- icon,
213
- size: iconSize,
214
- iconOnly,
215
- label: actionLabel(action, t)
216
- } : {
217
- children: /* @__PURE__ */ React4.createElement(ActionLabel, {
222
+ var _effect = _useSignals4();
223
+ try {
224
+ const { iconSize } = useMenu("ActionToolbarItem", __menuScope);
225
+ const { t } = useTranslation2(translationKey);
226
+ const handleClick = useCallback2(() => action.data?.(), [
218
227
  action
219
- })
220
- };
221
- return hidden ? null : /* @__PURE__ */ React4.createElement(Root, {
222
- key: action.id,
223
- disabled,
224
- onClick: handleClick,
225
- variant: "ghost",
226
- ...testId && {
227
- "data-testid": testId
228
- },
229
- ...rootProps,
230
- classNames
231
- });
228
+ ]);
229
+ const { icon, iconOnly = true, disabled, testId, hidden, classNames } = action.properties;
230
+ const Root = icon ? NaturalToolbar.IconButton : NaturalToolbar.Button;
231
+ const rootProps = icon ? {
232
+ icon,
233
+ size: iconSize,
234
+ iconOnly,
235
+ label: actionLabel(action, t)
236
+ } : {
237
+ children: /* @__PURE__ */ React4.createElement(ActionLabel, {
238
+ action
239
+ })
240
+ };
241
+ return hidden ? null : /* @__PURE__ */ React4.createElement(Root, {
242
+ key: action.id,
243
+ disabled,
244
+ onClick: handleClick,
245
+ variant: "ghost",
246
+ ...testId && {
247
+ "data-testid": testId
248
+ },
249
+ ...rootProps,
250
+ classNames
251
+ });
252
+ } finally {
253
+ _effect.f();
254
+ }
232
255
  };
233
256
  var DropdownMenuToolbarItem = ({ group, items: propsItems, __menuScope }) => {
234
- const { iconOnly, disabled, testId } = group.properties;
235
- const suppressNextTooltip = useRef(false);
236
- const { t } = useTranslation2(translationKey);
237
- const { iconSize } = useMenu("DropdownMenuToolbarItem", __menuScope);
238
- const items = useMenuItems(group, propsItems, "DropdownMenuToolbarItem", __menuScope);
239
- const activeItem = items?.find((item) => !!item.properties.checked);
240
- const icon = group.properties.applyActive && // TODO(thure): Handle other menu item types.
241
- activeItem?.properties.icon || group.properties.icon;
242
- const Root = icon ? NaturalToolbar.IconButton : NaturalToolbar.Button;
243
- const labelAction = group.properties.applyActive && activeItem ? activeItem : group;
244
- const rootProps = icon ? {
245
- icon,
246
- size: iconSize,
247
- iconOnly,
248
- label: actionLabel(labelAction, t),
249
- caretDown: true,
250
- suppressNextTooltip
251
- } : {
252
- children: /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(ActionLabel, {
253
- action: labelAction
254
- }), /* @__PURE__ */ React4.createElement(Icon2, {
255
- size: 3,
256
- icon: "ph--caret-down--bold",
257
- classNames: "mis-1"
258
- }))
259
- };
260
- return /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
261
- group,
262
- items,
263
- suppressNextTooltip
264
- }, /* @__PURE__ */ React4.createElement(DropdownMenu.Trigger, {
265
- asChild: true
266
- }, /* @__PURE__ */ React4.createElement(Root, {
267
- variant: "ghost",
268
- disabled,
269
- ...rootProps,
270
- ...testId && {
271
- "data-testid": testId
272
- }
273
- })));
257
+ var _effect = _useSignals4();
258
+ try {
259
+ const { iconOnly, disabled, testId } = group.properties;
260
+ const { t } = useTranslation2(translationKey);
261
+ const { iconSize } = useMenu("DropdownMenuToolbarItem", __menuScope);
262
+ const items = useMenuItems(group, propsItems, "DropdownMenuToolbarItem", __menuScope);
263
+ const activeItem = items?.find((item) => !!item.properties.checked);
264
+ const icon = group.properties.applyActive && // TODO(thure): Handle other menu item types.
265
+ activeItem?.properties.icon || group.properties.icon;
266
+ const Root = icon ? NaturalToolbar.IconButton : NaturalToolbar.Button;
267
+ const labelAction = group.properties.applyActive && activeItem ? activeItem : group;
268
+ const rootProps = icon ? {
269
+ icon,
270
+ size: iconSize,
271
+ iconOnly,
272
+ label: actionLabel(labelAction, t),
273
+ caretDown: true
274
+ } : {
275
+ children: /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(ActionLabel, {
276
+ action: labelAction
277
+ }), /* @__PURE__ */ React4.createElement(Icon2, {
278
+ size: 3,
279
+ icon: "ph--caret-down--bold",
280
+ classNames: "mis-1"
281
+ }))
282
+ };
283
+ return /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
284
+ group,
285
+ items
286
+ }, /* @__PURE__ */ React4.createElement(DropdownMenu.Trigger, {
287
+ asChild: true
288
+ }, /* @__PURE__ */ React4.createElement(Root, {
289
+ variant: "ghost",
290
+ disabled,
291
+ ...rootProps,
292
+ ...testId && {
293
+ "data-testid": testId
294
+ }
295
+ })));
296
+ } finally {
297
+ _effect.f();
298
+ }
274
299
  };
275
300
  var ToggleGroupItem = ({ group, action, __menuScope }) => {
276
- const { iconSize } = useMenu("ToggleGroupItem", __menuScope);
277
- const { t } = useTranslation2(translationKey);
278
- const { icon, iconOnly = true, disabled, testId, hidden, classNames } = action.properties;
279
- const handleClick = useCallback2(() => action.data?.({
280
- parent: group
281
- }), [
282
- action,
283
- group
284
- ]);
285
- const Root = icon ? NaturalToolbar.ToggleGroupIconItem : NaturalToolbar.ToggleGroupItem;
286
- const rootProps = icon ? {
287
- icon,
288
- size: iconSize,
289
- iconOnly,
290
- label: actionLabel(action, t)
291
- } : {
292
- children: /* @__PURE__ */ React4.createElement(ActionLabel, {
293
- action
294
- })
295
- };
296
- return hidden ? null : /* @__PURE__ */ React4.createElement(Root, {
297
- key: action.id,
298
- value: action.id,
299
- disabled,
300
- onClick: handleClick,
301
- variant: "ghost",
302
- ...testId && {
303
- "data-testid": testId
304
- },
305
- ...rootProps,
306
- classNames
307
- });
301
+ var _effect = _useSignals4();
302
+ try {
303
+ const { iconSize } = useMenu("ToggleGroupItem", __menuScope);
304
+ const { t } = useTranslation2(translationKey);
305
+ const { icon, iconOnly = true, disabled, testId, hidden, classNames } = action.properties;
306
+ const handleClick = useCallback2(() => action.data?.({
307
+ parent: group
308
+ }), [
309
+ action,
310
+ group
311
+ ]);
312
+ const Root = icon ? NaturalToolbar.ToggleGroupIconItem : NaturalToolbar.ToggleGroupItem;
313
+ const rootProps = icon ? {
314
+ icon,
315
+ size: iconSize,
316
+ iconOnly,
317
+ label: actionLabel(action, t)
318
+ } : {
319
+ children: /* @__PURE__ */ React4.createElement(ActionLabel, {
320
+ action
321
+ })
322
+ };
323
+ return hidden ? null : /* @__PURE__ */ React4.createElement(Root, {
324
+ key: action.id,
325
+ value: action.id,
326
+ disabled,
327
+ onClick: handleClick,
328
+ variant: "ghost",
329
+ ...testId && {
330
+ "data-testid": testId
331
+ },
332
+ ...rootProps,
333
+ classNames
334
+ });
335
+ } finally {
336
+ _effect.f();
337
+ }
308
338
  };
309
339
  var ToggleGroupToolbarItem = ({ group, items: propsItems, __menuScope }) => {
310
- const items = useMenuItems(group, propsItems, "ToggleGroupToolbarItem", __menuScope);
311
- const { selectCardinality, value } = group.properties;
312
- return (
313
- // TODO(thure): The type here is difficult to manage, what do?
314
- // @ts-ignore
315
- /* @__PURE__ */ React4.createElement(
316
- NaturalToolbar.ToggleGroup,
317
- {
318
- type: selectCardinality,
319
- value
320
- },
321
- // TODO(thure): Handle other menu item types.
322
- items.map((action) => /* @__PURE__ */ React4.createElement(ToggleGroupItem, {
323
- key: action.id,
324
- group,
325
- action
326
- }))
327
- )
328
- );
340
+ var _effect = _useSignals4();
341
+ try {
342
+ const items = useMenuItems(group, propsItems, "ToggleGroupToolbarItem", __menuScope);
343
+ const { selectCardinality, value } = group.properties;
344
+ return (
345
+ // TODO(thure): The type here is difficult to manage, what do?
346
+ // @ts-ignore
347
+ /* @__PURE__ */ React4.createElement(
348
+ NaturalToolbar.ToggleGroup,
349
+ {
350
+ type: selectCardinality,
351
+ value
352
+ },
353
+ // TODO(thure): Handle other menu item types.
354
+ items.map((action) => /* @__PURE__ */ React4.createElement(ToggleGroupItem, {
355
+ key: action.id,
356
+ group,
357
+ action
358
+ }))
359
+ )
360
+ );
361
+ } finally {
362
+ _effect.f();
363
+ }
329
364
  };
330
365
  var ToolbarMenu = ({ __menuScope, classNames, ...props }) => {
331
- const items = useMenuItems(void 0, void 0, "ToolbarMenu", __menuScope);
332
- const { attendableId } = useMenu("ToolbarMenu", __menuScope);
333
- const { hasAttention } = useAttention(attendableId);
334
- return /* @__PURE__ */ React4.createElement(NaturalToolbar.Root, {
335
- ...props,
336
- classNames: [
337
- "p-1",
338
- !hasAttention && "[&>*]:opacity-20 !bg-transparent",
339
- classNames
340
- ]
341
- }, items?.map((item, i) => isSeparator(item) ? /* @__PURE__ */ React4.createElement(NaturalToolbar.Separator, {
342
- key: i,
343
- variant: item.properties.variant
344
- }) : isMenuGroup(item) ? item.properties.variant === "dropdownMenu" ? (
345
- // TODO(thure): Figure out type narrowing that doesn’t require so much use of `as`.
346
- /* @__PURE__ */ React4.createElement(DropdownMenuToolbarItem, {
347
- key: item.id,
348
- group: item
349
- })
350
- ) : (
351
- // TODO(thure): Figure out type narrowing that doesn’t require so much use of `as`.
352
- /* @__PURE__ */ React4.createElement(ToggleGroupToolbarItem, {
353
- key: item.id,
354
- group: item
355
- })
356
- ) : (
357
- // TODO(thure): Figure out type narrowing that doesn’t require so much use of `as`.
358
- /* @__PURE__ */ React4.createElement(ActionToolbarItem, {
359
- key: item.id,
360
- action: item
361
- })
362
- )));
366
+ var _effect = _useSignals4();
367
+ try {
368
+ const items = useMenuItems(void 0, void 0, "ToolbarMenu", __menuScope);
369
+ const { attendableId } = useMenu("ToolbarMenu", __menuScope);
370
+ const { hasAttention } = useAttention(attendableId);
371
+ return /* @__PURE__ */ React4.createElement(NaturalToolbar.Root, {
372
+ ...props,
373
+ classNames: [
374
+ "p-1",
375
+ attendableId && !hasAttention && "[&>*]:opacity-20 !bg-transparent",
376
+ classNames
377
+ ]
378
+ }, items?.map((item, i) => isSeparator(item) ? /* @__PURE__ */ React4.createElement(NaturalToolbar.Separator, {
379
+ key: i,
380
+ variant: item.properties.variant
381
+ }) : isMenuGroup(item) ? item.properties.variant === "dropdownMenu" ? (
382
+ // TODO(thure): Figure out type narrowing that doesn’t require so much use of `as`.
383
+ /* @__PURE__ */ React4.createElement(DropdownMenuToolbarItem, {
384
+ key: item.id,
385
+ group: item
386
+ })
387
+ ) : (
388
+ // TODO(thure): Figure out type narrowing that doesn’t require so much use of `as`.
389
+ /* @__PURE__ */ React4.createElement(ToggleGroupToolbarItem, {
390
+ key: item.id,
391
+ group: item
392
+ })
393
+ ) : (
394
+ // TODO(thure): Figure out type narrowing that doesn’t require so much use of `as`.
395
+ /* @__PURE__ */ React4.createElement(ActionToolbarItem, {
396
+ key: item.id,
397
+ action: item
398
+ })
399
+ )));
400
+ } finally {
401
+ _effect.f();
402
+ }
363
403
  };
364
404
 
365
405
  // packages/ui/react-ui-menu/src/hooks/useMenuActions.ts
366
406
  import { RegistryContext, useRxValue } from "@effect-rx/rx-react";
367
- import { useSignalEffect } from "@preact/signals-react";
368
- import { useCallback as useCallback3, useContext, useState } from "react";
407
+ import { useCallback as useCallback3, useContext, useEffect, useState } from "react";
369
408
  import { Graph, ROOT_ID } from "@dxos/app-graph";
370
409
  var edgesArrayToRecord = (edges) => {
371
410
  return Object.fromEntries(Object.entries(edges.reduce((acc, { source, target }) => {
@@ -392,19 +431,20 @@ var edgesArrayToRecord = (edges) => {
392
431
  return acc;
393
432
  }, {})));
394
433
  };
395
- var useMenuActions = (actionCreator) => {
434
+ var useMenuActions = (props) => {
396
435
  const registry = useContext(RegistryContext);
397
- const initialMenuGraphProps = actionCreator();
436
+ const menuGraphProps = useRxValue(props);
398
437
  const [graph] = useState(new Graph({
399
438
  registry,
400
- nodes: initialMenuGraphProps.nodes,
401
- edges: edgesArrayToRecord(initialMenuGraphProps.edges)
439
+ nodes: menuGraphProps.nodes,
440
+ edges: edgesArrayToRecord(menuGraphProps.edges)
402
441
  }));
403
- useSignalEffect(() => {
404
- const menuGraphProps = actionCreator();
442
+ useEffect(() => {
405
443
  graph.addNodes(menuGraphProps.nodes);
406
444
  graph.addEdges(menuGraphProps.edges);
407
- });
445
+ }, [
446
+ menuGraphProps
447
+ ]);
408
448
  const useGroupItems = useCallback3((sourceNode) => {
409
449
  const items = useRxValue(graph.connections(sourceNode?.id || ROOT_ID));
410
450
  return items;
@@ -428,6 +468,7 @@ export {
428
468
  isMenuGroup,
429
469
  isSeparator,
430
470
  menuContextDefaults,
471
+ rxFromSignal,
431
472
  useMenu,
432
473
  useMenuActions,
433
474
  useMenuItems