@dxos/react-ui-menu 0.8.3-staging.0fa589b → 0.8.4-main.1da679c
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/browser/index.mjs +123 -41
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +123 -41
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/builder.d.ts +14 -0
- package/dist/types/src/builder.d.ts.map +1 -0
- package/dist/types/src/components/ActionLabel.d.ts +1 -1
- package/dist/types/src/components/ActionLabel.d.ts.map +1 -1
- package/dist/types/src/components/DropdownMenu.d.ts +1 -1
- package/dist/types/src/components/DropdownMenu.d.ts.map +1 -1
- package/dist/types/src/components/MenuContext.d.ts.map +1 -1
- package/dist/types/src/components/ToolbarMenu.d.ts +1 -1
- package/dist/types/src/components/ToolbarMenu.d.ts.map +1 -1
- package/dist/types/src/components/{Menus.stories.d.ts → ToolbarMenu.stories.d.ts} +10 -14
- package/dist/types/src/components/ToolbarMenu.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/useMenuActions.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts +2 -2
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -4
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +2 -2
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -17
- package/src/builder.ts +62 -0
- package/src/components/ActionLabel.tsx +4 -5
- package/src/components/DropdownMenu.tsx +6 -3
- package/src/components/MenuContext.tsx +1 -1
- package/src/components/{Menus.stories.tsx → ToolbarMenu.stories.tsx} +19 -11
- package/src/components/ToolbarMenu.tsx +34 -24
- package/src/hooks/useMenuActions.ts +1 -1
- package/src/index.ts +1 -0
- package/src/testing/generator.ts +4 -4
- package/src/translations.ts +5 -3
- package/src/types.ts +2 -2
- package/src/util.ts +1 -1
- package/dist/lib/node/index.cjs +0 -506
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/types/src/components/Menus.stories.d.ts.map +0 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// src/index.ts
|
|
4
4
|
import { rxFromSignal } from "@dxos/app-graph";
|
|
5
5
|
|
|
6
|
-
//
|
|
6
|
+
// src/components/DropdownMenu.tsx
|
|
7
7
|
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
8
8
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
9
9
|
import React3, { useCallback } from "react";
|
|
10
|
-
import { DropdownMenu as NaturalDropdownMenu
|
|
10
|
+
import { Icon, DropdownMenu as NaturalDropdownMenu } from "@dxos/react-ui";
|
|
11
11
|
|
|
12
|
-
//
|
|
12
|
+
// src/components/ActionLabel.tsx
|
|
13
13
|
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
14
14
|
import React from "react";
|
|
15
15
|
import { keySymbols } from "@dxos/keyboard";
|
|
16
16
|
import { toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
17
|
-
import {
|
|
17
|
+
import { descriptionText, mx } from "@dxos/react-ui-theme";
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
var translationKey = "
|
|
21
|
-
var
|
|
19
|
+
// src/translations.ts
|
|
20
|
+
var translationKey = "react-ui-menu";
|
|
21
|
+
var translations = [
|
|
22
22
|
{
|
|
23
23
|
"en-US": {
|
|
24
24
|
[translationKey]: {}
|
|
@@ -26,7 +26,7 @@ var translations_default = [
|
|
|
26
26
|
}
|
|
27
27
|
];
|
|
28
28
|
|
|
29
|
-
//
|
|
29
|
+
// src/util.ts
|
|
30
30
|
import { ACTION_GROUP_TYPE, ACTION_TYPE, actionGroupSymbol } from "@dxos/app-graph";
|
|
31
31
|
import { getHostPlatform } from "@dxos/util";
|
|
32
32
|
var getShortcut = (action) => {
|
|
@@ -81,12 +81,12 @@ var createLineSeparator = (id = "line", source = "root") => ({
|
|
|
81
81
|
]
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
//
|
|
84
|
+
// src/components/ActionLabel.tsx
|
|
85
85
|
var ActionLabel = ({ action }) => {
|
|
86
86
|
var _effect = _useSignals();
|
|
87
87
|
try {
|
|
88
|
-
const shortcut = getShortcut(action);
|
|
89
88
|
const { t } = useTranslation(translationKey);
|
|
89
|
+
const shortcut = getShortcut(action);
|
|
90
90
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
|
|
91
91
|
className: "grow truncate"
|
|
92
92
|
}, toLocalizedString(action.properties.label, t)), shortcut && /* @__PURE__ */ React.createElement("span", {
|
|
@@ -101,7 +101,7 @@ var actionLabel = (action, t) => {
|
|
|
101
101
|
return `${toLocalizedString(action.properties.label, t)}${shortcut ? ` (${keySymbols(shortcut).join("")})` : ""}`;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
//
|
|
104
|
+
// src/components/MenuContext.tsx
|
|
105
105
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
106
106
|
import { createContextScope } from "@radix-ui/react-context";
|
|
107
107
|
import React2, { useMemo } from "react";
|
|
@@ -136,7 +136,7 @@ var useMenuItems = (group, propsItems, consumerName = "useMenuItemConsumer", __m
|
|
|
136
136
|
]);
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
//
|
|
139
|
+
// src/components/DropdownMenu.tsx
|
|
140
140
|
var DropdownMenuItem = ({ item, onClick, __menuScope }) => {
|
|
141
141
|
var _effect = _useSignals3();
|
|
142
142
|
try {
|
|
@@ -205,20 +205,20 @@ var DropdownMenu = {
|
|
|
205
205
|
VirtualTrigger: NaturalDropdownMenu.VirtualTrigger
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
-
//
|
|
208
|
+
// src/components/ToolbarMenu.tsx
|
|
209
209
|
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
210
210
|
import React4, { Fragment, useCallback as useCallback2 } from "react";
|
|
211
211
|
import { Icon as Icon2, Toolbar as NaturalToolbar, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
212
212
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
213
213
|
import { mx as mx2, textBlockWidth, toolbarLayout } from "@dxos/react-ui-theme";
|
|
214
214
|
|
|
215
|
-
//
|
|
215
|
+
// src/types.ts
|
|
216
216
|
import { ACTION_GROUP_TYPE as ACTION_GROUP_TYPE2 } from "@dxos/app-graph";
|
|
217
217
|
var MenuSeparatorType = "@dxos/react-ui-toolbar/separator";
|
|
218
218
|
var isSeparator = (node) => node.type === MenuSeparatorType;
|
|
219
219
|
var isMenuGroup = (node) => node.type === ACTION_GROUP_TYPE2;
|
|
220
220
|
|
|
221
|
-
//
|
|
221
|
+
// src/components/ToolbarMenu.tsx
|
|
222
222
|
var ActionToolbarItem = ({ action, __menuScope }) => {
|
|
223
223
|
var _effect = _useSignals4();
|
|
224
224
|
try {
|
|
@@ -343,7 +343,7 @@ var ToggleGroupToolbarItem = ({ group, items: propsItems, __menuScope }) => {
|
|
|
343
343
|
const items = useMenuItems(group, propsItems, "ToggleGroupToolbarItem", __menuScope);
|
|
344
344
|
const { selectCardinality, value } = group.properties;
|
|
345
345
|
return (
|
|
346
|
-
// TODO(thure):
|
|
346
|
+
// TODO(thure): Fix.
|
|
347
347
|
// @ts-ignore
|
|
348
348
|
/* @__PURE__ */ React4.createElement(
|
|
349
349
|
NaturalToolbar.ToggleGroup,
|
|
@@ -372,7 +372,7 @@ var ToolbarMenu = ({ __menuScope, classNames, textBlockWidth: wrapContents, ...p
|
|
|
372
372
|
const InnerRoot = wrapContents ? "div" : Fragment;
|
|
373
373
|
const innerRootProps = wrapContents ? {
|
|
374
374
|
role: "none",
|
|
375
|
-
className: mx2(textBlockWidth, toolbarLayout)
|
|
375
|
+
className: mx2(textBlockWidth, toolbarLayout, "bs-full")
|
|
376
376
|
} : {};
|
|
377
377
|
return /* @__PURE__ */ React4.createElement(NaturalToolbar.Root, {
|
|
378
378
|
...props,
|
|
@@ -381,34 +381,42 @@ var ToolbarMenu = ({ __menuScope, classNames, textBlockWidth: wrapContents, ...p
|
|
|
381
381
|
attendableId && !hasAttention && "*:opacity-20 !bg-transparent",
|
|
382
382
|
classNames
|
|
383
383
|
]
|
|
384
|
-
}, /* @__PURE__ */ React4.createElement(InnerRoot, innerRootProps, items?.map((item, i) =>
|
|
385
|
-
key: i,
|
|
386
|
-
|
|
387
|
-
})
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
})
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
384
|
+
}, /* @__PURE__ */ React4.createElement(InnerRoot, innerRootProps, items?.map((item, i) => /* @__PURE__ */ React4.createElement(ToolbarMenuItem, {
|
|
385
|
+
key: item.id ?? i,
|
|
386
|
+
item
|
|
387
|
+
}))));
|
|
388
|
+
} finally {
|
|
389
|
+
_effect.f();
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
var ToolbarMenuItem = ({ item }) => {
|
|
393
|
+
var _effect = _useSignals4();
|
|
394
|
+
try {
|
|
395
|
+
if (isSeparator(item)) {
|
|
396
|
+
return /* @__PURE__ */ React4.createElement(NaturalToolbar.Separator, {
|
|
397
|
+
variant: item.properties.variant
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
if (isMenuGroup(item)) {
|
|
401
|
+
if (item.properties.variant === "dropdownMenu") {
|
|
402
|
+
return /* @__PURE__ */ React4.createElement(DropdownMenuToolbarItem, {
|
|
403
|
+
group: item
|
|
404
|
+
});
|
|
405
|
+
} else {
|
|
406
|
+
return /* @__PURE__ */ React4.createElement(ToggleGroupToolbarItem, {
|
|
407
|
+
group: item
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return /* @__PURE__ */ React4.createElement(ActionToolbarItem, {
|
|
412
|
+
action: item
|
|
413
|
+
});
|
|
406
414
|
} finally {
|
|
407
415
|
_effect.f();
|
|
408
416
|
}
|
|
409
417
|
};
|
|
410
418
|
|
|
411
|
-
//
|
|
419
|
+
// src/hooks/useMenuActions.ts
|
|
412
420
|
import { RegistryContext, useRxValue } from "@effect-rx/rx-react";
|
|
413
421
|
import { useCallback as useCallback3, useContext, useEffect, useState } from "react";
|
|
414
422
|
import { Graph, ROOT_ID } from "@dxos/app-graph";
|
|
@@ -461,8 +469,82 @@ var useMenuActions = (props) => {
|
|
|
461
469
|
useGroupItems
|
|
462
470
|
};
|
|
463
471
|
};
|
|
472
|
+
|
|
473
|
+
// src/builder.ts
|
|
474
|
+
import { invariant } from "@dxos/invariant";
|
|
475
|
+
function _define_property(obj, key, value) {
|
|
476
|
+
if (key in obj) {
|
|
477
|
+
Object.defineProperty(obj, key, {
|
|
478
|
+
value,
|
|
479
|
+
enumerable: true,
|
|
480
|
+
configurable: true,
|
|
481
|
+
writable: true
|
|
482
|
+
});
|
|
483
|
+
} else {
|
|
484
|
+
obj[key] = value;
|
|
485
|
+
}
|
|
486
|
+
return obj;
|
|
487
|
+
}
|
|
488
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-menu/src/builder.ts";
|
|
489
|
+
var MenuBuilder = Object.freeze({
|
|
490
|
+
make: () => new MenuBuilderImpl({
|
|
491
|
+
nodes: [],
|
|
492
|
+
edges: []
|
|
493
|
+
}, "root")
|
|
494
|
+
});
|
|
495
|
+
var MenuBuilderImpl = class _MenuBuilderImpl {
|
|
496
|
+
root(props) {
|
|
497
|
+
invariant(this._rootId === "root", "Root group can only be at the top level", {
|
|
498
|
+
F: __dxlog_file,
|
|
499
|
+
L: 36,
|
|
500
|
+
S: this,
|
|
501
|
+
A: [
|
|
502
|
+
"this._rootId === 'root'",
|
|
503
|
+
"'Root group can only be at the top level'"
|
|
504
|
+
]
|
|
505
|
+
});
|
|
506
|
+
invariant(this._data.nodes.find((node) => node.id === "root") === void 0, "Root group can only be created once", {
|
|
507
|
+
F: __dxlog_file,
|
|
508
|
+
L: 37,
|
|
509
|
+
S: this,
|
|
510
|
+
A: [
|
|
511
|
+
"this._data.nodes.find((node) => node.id === 'root') === undefined",
|
|
512
|
+
"'Root group can only be created once'"
|
|
513
|
+
]
|
|
514
|
+
});
|
|
515
|
+
this._data.nodes.push(createMenuItemGroup("root", props));
|
|
516
|
+
return this;
|
|
517
|
+
}
|
|
518
|
+
action(id, props, invoke) {
|
|
519
|
+
this._data.nodes.push(createMenuAction(id, invoke, props));
|
|
520
|
+
this._data.edges.push({
|
|
521
|
+
source: this._rootId,
|
|
522
|
+
target: id
|
|
523
|
+
});
|
|
524
|
+
return this;
|
|
525
|
+
}
|
|
526
|
+
group(id, props, cb) {
|
|
527
|
+
this._data.nodes.push(createMenuItemGroup(id, props));
|
|
528
|
+
this._data.edges.push({
|
|
529
|
+
source: this._rootId,
|
|
530
|
+
target: id
|
|
531
|
+
});
|
|
532
|
+
cb(new _MenuBuilderImpl(this._data, id));
|
|
533
|
+
return this;
|
|
534
|
+
}
|
|
535
|
+
build() {
|
|
536
|
+
return this._data;
|
|
537
|
+
}
|
|
538
|
+
constructor(_data, _rootId) {
|
|
539
|
+
_define_property(this, "_data", void 0);
|
|
540
|
+
_define_property(this, "_rootId", void 0);
|
|
541
|
+
this._data = _data;
|
|
542
|
+
this._rootId = _rootId;
|
|
543
|
+
}
|
|
544
|
+
};
|
|
464
545
|
export {
|
|
465
546
|
DropdownMenu,
|
|
547
|
+
MenuBuilder,
|
|
466
548
|
MenuProvider,
|
|
467
549
|
MenuSeparatorType,
|
|
468
550
|
ToolbarMenu,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/index.ts", "../../../src/components/DropdownMenu.tsx", "../../../src/components/ActionLabel.tsx", "../../../src/translations.ts", "../../../src/util.ts", "../../../src/components/MenuContext.tsx", "../../../src/components/ToolbarMenu.tsx", "../../../src/types.ts", "../../../src/hooks/useMenuActions.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nexport { rxFromSignal } from '@dxos/app-graph';\n\nexport * from './components';\nexport * from './hooks';\nexport * from './types';\nexport { createMenuAction, createMenuItemGroup, createLineSeparator, createGapSeparator } from './util';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, { type MouseEvent, useCallback } from 'react';\n\nimport { DropdownMenu as NaturalDropdownMenu, Icon, type DropdownMenuRootProps } from '@dxos/react-ui';\n\nimport { ActionLabel } from './ActionLabel';\nimport { type MenuScopedProps, useMenu, useMenuItems } from './MenuContext';\nimport { type MenuAction, type MenuItem, type MenuItemGroup } from '../types';\n\nexport type DropdownMenuProps = DropdownMenuRootProps & {\n group?: MenuItemGroup;\n items?: MenuItem[];\n caller?: string;\n};\n\nconst DropdownMenuItem = ({\n item,\n onClick,\n __menuScope,\n}: MenuScopedProps<{\n item: MenuItem;\n onClick: (action: MenuAction, event: MouseEvent) => void;\n}>) => {\n // TODO(thure): handle other items.\n const action = item as MenuAction;\n const handleClick = useCallback((event: MouseEvent) => onClick(action, event), [action, onClick]);\n const { iconSize } = useMenu('DropdownMenuItem', __menuScope);\n return (\n <NaturalDropdownMenu.Item\n onClick={handleClick}\n classNames='gap-2'\n disabled={action.properties?.disabled}\n {...(action.properties?.testId && { 'data-testid': action.properties.testId })}\n >\n {action.properties?.icon && <Icon icon={action.properties!.icon} size={iconSize} />}\n <ActionLabel action={action} />\n </NaturalDropdownMenu.Item>\n );\n};\n\nconst DropdownMenuRoot = ({\n items: propsItems,\n group,\n open,\n defaultOpen,\n onOpenChange,\n caller,\n children,\n __menuScope,\n ...naturalProps\n}: MenuScopedProps<DropdownMenuProps>) => {\n const [optionsMenuOpen, setOptionsMenuOpen] = useControllableState({\n prop: open,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n const handleActionClick = useCallback(\n (action: MenuAction, event: MouseEvent) => {\n if (action.properties?.disabled) {\n return;\n }\n event.stopPropagation();\n // TODO(thure): Why does Dialog’s modal-ness cause issues if we don’t explicitly close the menu here?\n setOptionsMenuOpen(false);\n void action.data?.({ parent: group, caller });\n },\n [group, caller],\n );\n\n const items = useMenuItems(group, propsItems);\n\n return (\n <NaturalDropdownMenu.Root open={optionsMenuOpen} onOpenChange={setOptionsMenuOpen} {...naturalProps}>\n {children}\n <NaturalDropdownMenu.Portal>\n <NaturalDropdownMenu.Content>\n <NaturalDropdownMenu.Viewport>\n {items?.map((item) => <DropdownMenuItem key={item.id} item={item} onClick={handleActionClick} />)}\n </NaturalDropdownMenu.Viewport>\n <NaturalDropdownMenu.Arrow />\n </NaturalDropdownMenu.Content>\n </NaturalDropdownMenu.Portal>\n </NaturalDropdownMenu.Root>\n );\n};\n\nexport const DropdownMenu = {\n Root: DropdownMenuRoot,\n Trigger: NaturalDropdownMenu.Trigger,\n VirtualTrigger: NaturalDropdownMenu.VirtualTrigger,\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Action as GraphAction, type ActionGroup } from '@dxos/app-graph';\nimport { keySymbols } from '@dxos/keyboard';\nimport { toLocalizedString, useTranslation, type TFunction } from '@dxos/react-ui';\nimport { mx, descriptionText } from '@dxos/react-ui-theme';\n\nimport { translationKey } from '../translations';\nimport { type MenuActionProperties } from '../types';\nimport { getShortcut } from '../util';\n\ntype Action = GraphAction<MenuActionProperties> | ActionGroup<Omit<MenuActionProperties, 'variant'>>;\n\nexport const ActionLabel = ({ action }: { action: Action }) => {\n const shortcut = getShortcut(action);\n const { t } = useTranslation(translationKey);\n\n return (\n <>\n <span className='grow truncate'>{toLocalizedString(action.properties!.label, t)}</span>\n {shortcut && <span className={mx('shrink-0', descriptionText)}>{keySymbols(shortcut).join('')}</span>}\n </>\n );\n};\n\nexport const actionLabel = (action: Action, t: TFunction) => {\n const shortcut = getShortcut(action);\n return `${toLocalizedString(action.properties!.label, t)}${shortcut ? ` (${keySymbols(shortcut).join('')})` : ''}`;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const translationKey = 'menus';\n\nexport default [\n {\n 'en-US': {\n [translationKey]: {},\n },\n },\n] as const;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { ACTION_GROUP_TYPE, ACTION_TYPE, actionGroupSymbol, type ActionLike } from '@dxos/app-graph';\nimport { getHostPlatform } from '@dxos/util';\n\nimport {\n type MenuAction,\n type MenuActionProperties,\n type MenuItemGroup,\n type MenuItemGroupProperties,\n type MenuSeparator,\n} from './types';\n\nexport const getShortcut = (action: ActionLike) => {\n return typeof action.properties?.keyBinding === 'string'\n ? action.properties.keyBinding\n : action.properties?.keyBinding?.[getHostPlatform()];\n};\n\nexport const fallbackIcon = 'ph--placeholder--regular';\n\nexport const createMenuAction = <P extends {} = {}>(\n id: string,\n invoke: () => void,\n properties: P & MenuActionProperties,\n) =>\n ({\n id,\n type: ACTION_TYPE,\n properties,\n data: invoke,\n }) satisfies MenuAction;\n\nexport const createMenuItemGroup = <\n P extends MenuItemGroupProperties = MenuItemGroupProperties & Partial<MenuActionProperties>,\n>(\n id: string,\n properties: P,\n) =>\n ({\n id,\n type: ACTION_GROUP_TYPE,\n properties,\n data: 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: [{ source, target: id }],\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 }],\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContextScope, type Scope } from '@radix-ui/react-context';\nimport React, { type PropsWithChildren, useMemo } from 'react';\n\nimport { type MenuContextValue, type MenuItem, type MenuItemGroup } from '../types';\n\nexport type MenuScopedProps<P> = P & { __menuScope?: Scope };\n\nconst MENU_NAME = 'GraphMenu';\n\nconst [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, []);\n\nconst [MenuContextProvider, useMenu] = createMenuContext<MenuContextValue>(MENU_NAME);\n\nexport const menuContextDefaults: MenuContextValue = {\n iconSize: 5,\n useGroupItems: () => null,\n};\n\nconst useMenuScope = createMenuScope();\n\nconst MenuProvider = ({\n children,\n useGroupItems = menuContextDefaults.useGroupItems,\n iconSize = menuContextDefaults.iconSize,\n attendableId,\n}: PropsWithChildren<Partial<MenuContextValue>>) => {\n const { scope } = useMenuScope(undefined);\n return (\n <MenuContextProvider useGroupItems={useGroupItems} iconSize={iconSize} attendableId={attendableId} scope={scope}>\n {children}\n </MenuContextProvider>\n );\n};\n\nexport const useMenuItems = (\n group?: MenuItemGroup,\n propsItems?: MenuItem[],\n consumerName: string = 'useMenuItemConsumer',\n __menuScope?: Scope,\n) => {\n const { useGroupItems } = useMenu(consumerName, __menuScope);\n const groupItems = useGroupItems(group);\n return useMemo(() => propsItems ?? groupItems ?? undefined, [propsItems, groupItems]);\n};\n\nexport { useMenu, createMenuScope, MenuProvider };\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { Fragment, useCallback } from 'react';\n\nimport { Icon, Toolbar as NaturalToolbar, type ToolbarRootProps, useTranslation } from '@dxos/react-ui';\nimport { useAttention } from '@dxos/react-ui-attention';\nimport { mx, textBlockWidth, toolbarLayout } from '@dxos/react-ui-theme';\n\nimport { actionLabel, ActionLabel } from './ActionLabel';\nimport { DropdownMenu } from './DropdownMenu';\nimport { type MenuScopedProps, useMenu, useMenuItems } from './MenuContext';\nimport { translationKey } from '../translations';\nimport {\n type MenuAction,\n type MenuItem,\n isMenuGroup,\n isSeparator,\n type MenuItemGroup,\n type MenuActionProperties,\n type MenuMultipleSelectActionGroup,\n type MenuSingleSelectActionGroup,\n} from '../types';\n\nexport type ToolbarMenuDropdownMenuActionGroup = Omit<MenuActionProperties, 'variant' | 'icon'> & {\n variant: 'dropdownMenu';\n icon: string;\n applyActive?: boolean;\n};\n\nexport type ToolbarMenuToggleGroupActionGroup = Omit<MenuActionProperties, 'variant'> & {\n variant: 'toggleGroup';\n};\n\nexport type ToolbarMenuActionGroupProperties = (\n | ToolbarMenuDropdownMenuActionGroup\n | ToolbarMenuToggleGroupActionGroup\n) &\n (MenuSingleSelectActionGroup | MenuMultipleSelectActionGroup);\n\nexport type ToolbarMenuProps = ToolbarRootProps & { textBlockWidth?: boolean };\n\nexport type ToolbarMenuActionGroupProps = {\n group: MenuItemGroup<ToolbarMenuActionGroupProperties>;\n items?: MenuItem[];\n};\n\nexport type ToolbarMenuActionProps = {\n group: MenuItemGroup<ToolbarMenuActionGroupProperties>;\n action: MenuAction;\n};\n\nconst ActionToolbarItem = ({ action, __menuScope }: MenuScopedProps<{ action: MenuAction }>) => {\n const { iconSize } = useMenu('ActionToolbarItem', __menuScope);\n const { t } = useTranslation(translationKey);\n const handleClick = useCallback(() => action.data?.(), [action]);\n const { icon, iconOnly = true, disabled, testId, hidden, classNames } = action.properties;\n const Root = icon ? NaturalToolbar.IconButton : NaturalToolbar.Button;\n const rootProps = icon\n ? { icon, size: iconSize, iconOnly, label: actionLabel(action, t) }\n : { children: <ActionLabel action={action} /> };\n return hidden ? null : (\n <Root\n key={action.id}\n disabled={disabled}\n onClick={handleClick}\n variant='ghost'\n {...(testId && { 'data-testid': testId })}\n {...(rootProps as any)}\n classNames={classNames}\n />\n );\n};\n\nconst DropdownMenuToolbarItem = ({\n group,\n items: propsItems,\n __menuScope,\n}: MenuScopedProps<ToolbarMenuActionGroupProps>) => {\n const { iconOnly, disabled, testId } = group.properties;\n const { t } = useTranslation(translationKey);\n const { iconSize } = useMenu('DropdownMenuToolbarItem', __menuScope);\n const items = useMenuItems(group, propsItems, 'DropdownMenuToolbarItem', __menuScope);\n const activeItem = items?.find((item) => !!(item as MenuAction).properties.checked);\n const icon =\n ((group.properties as any).applyActive &&\n // TODO(thure): Handle other menu item types.\n (activeItem as MenuAction)?.properties.icon) ||\n group.properties.icon;\n const Root = icon ? NaturalToolbar.IconButton : NaturalToolbar.Button;\n const labelAction = (group.properties as any).applyActive && activeItem ? (activeItem as MenuAction) : group;\n const rootProps = icon\n ? { icon, size: iconSize, iconOnly, label: actionLabel(labelAction, t), caretDown: true }\n : {\n children: (\n <>\n <ActionLabel action={labelAction} />\n <Icon size={3} icon='ph--caret-down--bold' classNames='mis-1' />\n </>\n ),\n };\n return (\n <DropdownMenu.Root group={group} items={items}>\n <DropdownMenu.Trigger asChild>\n <Root variant='ghost' disabled={disabled} {...(rootProps as any)} {...(testId && { 'data-testid': testId })} />\n </DropdownMenu.Trigger>\n </DropdownMenu.Root>\n );\n};\n\nconst ToggleGroupItem = ({ group, action, __menuScope }: MenuScopedProps<ToolbarMenuActionProps>) => {\n const { iconSize } = useMenu('ToggleGroupItem', __menuScope);\n const { t } = useTranslation(translationKey);\n const { icon, iconOnly = true, disabled, testId, hidden, classNames } = action.properties;\n const handleClick = useCallback(() => action.data?.({ parent: group }), [action, group]);\n const Root = icon ? NaturalToolbar.ToggleGroupIconItem : NaturalToolbar.ToggleGroupItem;\n const rootProps = icon\n ? { icon, size: iconSize, iconOnly, label: actionLabel(action, t) }\n : { children: <ActionLabel action={action} /> };\n return hidden ? null : (\n <Root\n key={action.id}\n value={action.id as any}\n disabled={disabled}\n onClick={handleClick}\n variant='ghost'\n {...(testId && { 'data-testid': testId })}\n {...(rootProps as any)}\n classNames={classNames}\n />\n );\n};\n\nconst ToggleGroupToolbarItem = ({\n group,\n items: propsItems,\n __menuScope,\n}: MenuScopedProps<ToolbarMenuActionGroupProps>) => {\n const items = useMenuItems(group, propsItems, 'ToggleGroupToolbarItem', __menuScope);\n const { selectCardinality, value } = group.properties;\n return (\n // TODO(thure): The type here is difficult to manage, what do?\n // @ts-ignore\n <NaturalToolbar.ToggleGroup type={selectCardinality} value={value}>\n {\n // TODO(thure): Handle other menu item types.\n (items as MenuAction[]).map((action) => (\n <ToggleGroupItem key={action.id} group={group} action={action} />\n ))\n }\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nexport const ToolbarMenu = ({\n __menuScope,\n classNames,\n textBlockWidth: wrapContents,\n ...props\n}: MenuScopedProps<ToolbarMenuProps>) => {\n const items = useMenuItems(undefined, undefined, 'ToolbarMenu', __menuScope);\n const { attendableId } = useMenu('ToolbarMenu', __menuScope);\n const { hasAttention } = useAttention(attendableId);\n const InnerRoot = wrapContents ? 'div' : Fragment;\n const innerRootProps = wrapContents ? { role: 'none', className: mx(textBlockWidth, toolbarLayout) } : {};\n return (\n <NaturalToolbar.Root\n {...props}\n layoutManaged={wrapContents}\n classNames={[attendableId && !hasAttention && '*:opacity-20 !bg-transparent', classNames]}\n >\n <InnerRoot {...innerRootProps}>\n {items?.map((item: MenuItem, i: number) =>\n isSeparator(item) ? (\n <NaturalToolbar.Separator key={i} variant={item.properties.variant} />\n ) : isMenuGroup(item) ? (\n item.properties.variant === 'dropdownMenu' ? (\n // TODO(thure): Figure out type narrowing that doesn’t require so much use of `as`.\n <DropdownMenuToolbarItem key={item.id} group={item as MenuItemGroup<ToolbarMenuActionGroupProperties>} />\n ) : (\n // TODO(thure): Figure out type narrowing that doesn’t require so much use of `as`.\n <ToggleGroupToolbarItem key={item.id} group={item as MenuItemGroup<ToolbarMenuActionGroupProperties>} />\n )\n ) : (\n // TODO(thure): Figure out type narrowing that doesn’t require so much use of `as`.\n <ActionToolbarItem key={item.id} action={item as MenuAction} />\n ),\n )}\n </InnerRoot>\n </NaturalToolbar.Root>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Node, type Action, type ActionGroup, ACTION_GROUP_TYPE } from '@dxos/app-graph';\nimport { type ToolbarSeparatorProps, type Label, type IconButtonProps, type ClassNameValue } from '@dxos/react-ui';\n\nexport type MenuActionProperties = {\n label: Label;\n icon?: string;\n value?: string;\n disabled?: boolean;\n hidden?: boolean;\n iconOnly?: boolean;\n testId?: string;\n variant?: 'action' | 'toggle';\n checked?: boolean;\n classNames?: ClassNameValue;\n};\n\nexport type MenuItemGroupProperties = {\n label: Label;\n icon?: string;\n iconOnly?: boolean;\n};\n\nexport type MenuAction<P extends {} = {}> = Action<P & MenuActionProperties>;\n\nexport const MenuSeparatorType = '@dxos/react-ui-toolbar/separator' as const;\n\nexport type MenuSeparator = Node<never, Pick<ToolbarSeparatorProps, 'variant'>> & {\n type: typeof MenuSeparatorType;\n};\n\nexport const isSeparator = (node: Node): node is MenuSeparator => node.type === MenuSeparatorType;\n\nexport type MenuSingleSelectActionGroup = { selectCardinality: 'single'; value: string };\nexport type MenuMultipleSelectActionGroup = { selectCardinality: 'multiple'; value: string[] };\n\nexport type MenuItemGroup<P extends Record<string, any> = Record<string, any>> = ActionGroup<P>;\n\nexport const isMenuGroup = (node: Node): node is MenuItemGroup => node.type === ACTION_GROUP_TYPE;\n\nexport type MenuItem = MenuSeparator | MenuAction | MenuItemGroup;\n\nexport type MenuItemsResolver = (group?: MenuItemGroup) => MenuItem[] | null;\n\nexport type MenuContextValue = {\n useGroupItems: MenuItemsResolver;\n iconSize: IconButtonProps['size'];\n attendableId?: string;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RegistryContext, type Rx, useRxValue } from '@effect-rx/rx-react';\nimport { useCallback, useContext, useEffect, useState } from 'react';\n\nimport { type Edge, type Edges, Graph, type NodeArg, type Node, ROOT_ID } from '@dxos/app-graph';\n\nimport { type MenuItem, type MenuItemGroup } from '../types';\n\nconst edgesArrayToRecord = (edges: Edge[]): Record<string, Edges> => {\n return Object.fromEntries(\n Object.entries(\n edges.reduce((acc: Record<string, { inbound: string[]; outbound: string[] }>, { source, target }) => {\n if (!acc[source]) {\n acc[source] = { inbound: [], outbound: [] };\n }\n if (!acc[target]) {\n acc[target] = { inbound: [], outbound: [] };\n }\n\n const sourceEdges = acc[source];\n if (!sourceEdges.outbound.includes(target)) {\n sourceEdges.outbound.push(target);\n }\n\n const targetEdges = acc[target];\n if (!targetEdges.inbound.includes(source)) {\n targetEdges.inbound.push(source);\n }\n\n return acc;\n }, {}),\n ),\n );\n};\n\nexport type ActionGraphNodes = NodeArg<any>[];\nexport type ActionGraphEdges = Edge[];\nexport type ActionGraphProps = { nodes: ActionGraphNodes; edges: ActionGraphEdges };\n\nexport const useMenuActions = (props: Rx.Rx<ActionGraphProps>) => {\n const registry = useContext(RegistryContext);\n const menuGraphProps = useRxValue(props);\n\n const [graph] = useState(\n new Graph({\n registry,\n nodes: menuGraphProps.nodes as Node[],\n edges: edgesArrayToRecord(menuGraphProps.edges),\n }),\n );\n\n useEffect(() => {\n graph.addNodes(menuGraphProps.nodes);\n graph.addEdges(menuGraphProps.edges);\n }, [menuGraphProps]);\n\n const useGroupItems = useCallback(\n (sourceNode?: MenuItemGroup) => {\n const items = useRxValue(graph.connections(sourceNode?.id || ROOT_ID)) as MenuItem[];\n return items;\n },\n [graph],\n );\n\n return { useGroupItems };\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,oBAAoB;;;;ACA7B,SAASC,4BAA4B;AACrC,OAAOC,UAA0BC,mBAAmB;AAEpD,
|
|
6
|
-
"names": ["rxFromSignal", "useControllableState", "React", "useCallback", "
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/components/DropdownMenu.tsx", "../../../src/components/ActionLabel.tsx", "../../../src/translations.ts", "../../../src/util.ts", "../../../src/components/MenuContext.tsx", "../../../src/components/ToolbarMenu.tsx", "../../../src/types.ts", "../../../src/hooks/useMenuActions.ts", "../../../src/builder.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nexport { rxFromSignal } from '@dxos/app-graph';\n\nexport * from './components';\nexport * from './hooks';\nexport * from './types';\nexport { createMenuAction, createMenuItemGroup, createLineSeparator, createGapSeparator } from './util';\nexport { MenuBuilder } from './builder';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, { type MouseEvent, useCallback } from 'react';\n\nimport { type DropdownMenuRootProps, Icon, DropdownMenu as NaturalDropdownMenu } from '@dxos/react-ui';\n\nimport { type MenuAction, type MenuItem, type MenuItemGroup } from '../types';\n\nimport { ActionLabel } from './ActionLabel';\nimport { type MenuScopedProps, useMenu, useMenuItems } from './MenuContext';\n\nexport type DropdownMenuProps = DropdownMenuRootProps & {\n group?: MenuItemGroup;\n items?: MenuItem[];\n caller?: string;\n};\n\nconst DropdownMenuItem = ({\n item,\n onClick,\n __menuScope,\n}: MenuScopedProps<{\n item: MenuItem;\n onClick: (action: MenuAction, event: MouseEvent) => void;\n}>) => {\n // TODO(thure): handle other items.\n const action = item as MenuAction;\n const handleClick = useCallback((event: MouseEvent) => onClick(action, event), [action, onClick]);\n const { iconSize } = useMenu('DropdownMenuItem', __menuScope);\n return (\n <NaturalDropdownMenu.Item\n onClick={handleClick}\n classNames='gap-2'\n disabled={action.properties?.disabled}\n {...(action.properties?.testId && { 'data-testid': action.properties.testId })}\n >\n {action.properties?.icon && <Icon icon={action.properties!.icon} size={iconSize} />}\n <ActionLabel action={action} />\n </NaturalDropdownMenu.Item>\n );\n};\n\nconst DropdownMenuRoot = ({\n items: propsItems,\n group,\n open,\n defaultOpen,\n onOpenChange,\n caller,\n children,\n __menuScope,\n ...naturalProps\n}: MenuScopedProps<DropdownMenuProps>) => {\n const [optionsMenuOpen, setOptionsMenuOpen] = useControllableState({\n prop: open,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n const handleActionClick = useCallback(\n (action: MenuAction, event: MouseEvent) => {\n if (action.properties?.disabled) {\n return;\n }\n event.stopPropagation();\n // TODO(thure): Why does Dialog’s modal-ness cause issues if we don’t explicitly close the menu here?\n setOptionsMenuOpen(false);\n void action.data?.({ parent: group, caller });\n },\n [group, caller],\n );\n\n const items = useMenuItems(group, propsItems);\n\n return (\n <NaturalDropdownMenu.Root open={optionsMenuOpen} onOpenChange={setOptionsMenuOpen} {...naturalProps}>\n {children}\n <NaturalDropdownMenu.Portal>\n <NaturalDropdownMenu.Content>\n <NaturalDropdownMenu.Viewport>\n {items?.map((item) => (\n <DropdownMenuItem key={item.id} item={item} onClick={handleActionClick} />\n ))}\n </NaturalDropdownMenu.Viewport>\n <NaturalDropdownMenu.Arrow />\n </NaturalDropdownMenu.Content>\n </NaturalDropdownMenu.Portal>\n </NaturalDropdownMenu.Root>\n );\n};\n\nexport const DropdownMenu = {\n Root: DropdownMenuRoot,\n Trigger: NaturalDropdownMenu.Trigger,\n VirtualTrigger: NaturalDropdownMenu.VirtualTrigger,\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type ActionGroup, type Action as GraphAction } from '@dxos/app-graph';\nimport { keySymbols } from '@dxos/keyboard';\nimport { type TFunction, toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { descriptionText, mx } from '@dxos/react-ui-theme';\n\nimport { translationKey } from '../translations';\nimport { type MenuActionProperties } from '../types';\nimport { getShortcut } from '../util';\n\ntype Action = GraphAction<MenuActionProperties> | ActionGroup<Omit<MenuActionProperties, 'variant'>>;\n\nexport const ActionLabel = ({ action }: { action: Action }) => {\n const { t } = useTranslation(translationKey);\n const shortcut = getShortcut(action);\n return (\n <>\n <span className='grow truncate'>{toLocalizedString(action.properties!.label, t)}</span>\n {shortcut && <span className={mx('shrink-0', descriptionText)}>{keySymbols(shortcut).join('')}</span>}\n </>\n );\n};\n\nexport const actionLabel = (action: Action, t: TFunction) => {\n const shortcut = getShortcut(action);\n return `${toLocalizedString(action.properties!.label, t)}${shortcut ? ` (${keySymbols(shortcut).join('')})` : ''}`;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nexport const translationKey = 'react-ui-menu';\n\nexport const translations = [\n {\n 'en-US': {\n [translationKey]: {},\n },\n },\n] as const satisfies Resource[];\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { ACTION_GROUP_TYPE, ACTION_TYPE, type ActionLike, actionGroupSymbol } from '@dxos/app-graph';\nimport { getHostPlatform } from '@dxos/util';\n\nimport {\n type MenuAction,\n type MenuActionProperties,\n type MenuItemGroup,\n type MenuItemGroupProperties,\n type MenuSeparator,\n} from './types';\n\nexport const getShortcut = (action: ActionLike) => {\n return typeof action.properties?.keyBinding === 'string'\n ? action.properties.keyBinding\n : action.properties?.keyBinding?.[getHostPlatform()];\n};\n\nexport const fallbackIcon = 'ph--placeholder--regular';\n\nexport const createMenuAction = <P extends {} = {}>(\n id: string,\n invoke: () => void,\n properties: P & MenuActionProperties,\n) =>\n ({\n id,\n type: ACTION_TYPE,\n properties,\n data: invoke,\n }) satisfies MenuAction;\n\nexport const createMenuItemGroup = <\n P extends MenuItemGroupProperties = MenuItemGroupProperties & Partial<MenuActionProperties>,\n>(\n id: string,\n properties: P,\n) =>\n ({\n id,\n type: ACTION_GROUP_TYPE,\n properties,\n data: 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: [{ source, target: id }],\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 }],\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport React, { type PropsWithChildren, useMemo } from 'react';\n\nimport { type MenuContextValue, type MenuItem, type MenuItemGroup } from '../types';\n\nexport type MenuScopedProps<P> = P & { __menuScope?: Scope };\n\nconst MENU_NAME = 'GraphMenu';\n\nconst [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, []);\n\nconst [MenuContextProvider, useMenu] = createMenuContext<MenuContextValue>(MENU_NAME);\n\nexport const menuContextDefaults: MenuContextValue = {\n iconSize: 5,\n useGroupItems: () => null,\n};\n\nconst useMenuScope = createMenuScope();\n\nconst MenuProvider = ({\n children,\n useGroupItems = menuContextDefaults.useGroupItems,\n iconSize = menuContextDefaults.iconSize,\n attendableId,\n}: PropsWithChildren<Partial<MenuContextValue>>) => {\n const { scope } = useMenuScope(undefined);\n return (\n <MenuContextProvider useGroupItems={useGroupItems} iconSize={iconSize} attendableId={attendableId} scope={scope}>\n {children}\n </MenuContextProvider>\n );\n};\n\nexport const useMenuItems = (\n group?: MenuItemGroup,\n propsItems?: MenuItem[],\n consumerName: string = 'useMenuItemConsumer',\n __menuScope?: Scope,\n) => {\n const { useGroupItems } = useMenu(consumerName, __menuScope);\n const groupItems = useGroupItems(group);\n return useMemo(() => propsItems ?? groupItems ?? undefined, [propsItems, groupItems]);\n};\n\nexport { useMenu, createMenuScope, MenuProvider };\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { Fragment, useCallback } from 'react';\n\nimport { Icon, Toolbar as NaturalToolbar, type ToolbarRootProps, useTranslation } from '@dxos/react-ui';\nimport { useAttention } from '@dxos/react-ui-attention';\nimport { mx, textBlockWidth, toolbarLayout } from '@dxos/react-ui-theme';\n\nimport { translationKey } from '../translations';\nimport {\n type MenuAction,\n type MenuActionProperties,\n type MenuItem,\n type MenuItemGroup,\n type MenuMultipleSelectActionGroup,\n type MenuSingleSelectActionGroup,\n isMenuGroup,\n isSeparator,\n} from '../types';\n\nimport { ActionLabel, actionLabel } from './ActionLabel';\nimport { DropdownMenu } from './DropdownMenu';\nimport { type MenuScopedProps, useMenu, useMenuItems } from './MenuContext';\n\nexport type ToolbarMenuDropdownMenuActionGroup = Omit<MenuActionProperties, 'variant' | 'icon'> & {\n variant: 'dropdownMenu';\n icon: string;\n applyActive?: boolean;\n};\n\nexport type ToolbarMenuToggleGroupActionGroup = Omit<MenuActionProperties, 'variant'> & {\n variant: 'toggleGroup';\n};\n\nexport type ToolbarMenuActionGroupProperties = (\n | ToolbarMenuDropdownMenuActionGroup\n | ToolbarMenuToggleGroupActionGroup\n) &\n (MenuSingleSelectActionGroup | MenuMultipleSelectActionGroup);\n\nexport type ToolbarMenuProps = ToolbarRootProps & { textBlockWidth?: boolean };\n\nexport type ToolbarMenuActionGroupProps = {\n group: MenuItemGroup<ToolbarMenuActionGroupProperties>;\n items?: MenuItem[];\n};\n\nexport type ToolbarMenuActionProps = {\n group: MenuItemGroup<ToolbarMenuActionGroupProperties>;\n action: MenuAction;\n};\n\nconst ActionToolbarItem = ({ action, __menuScope }: MenuScopedProps<{ action: MenuAction }>) => {\n const { iconSize } = useMenu('ActionToolbarItem', __menuScope);\n const { t } = useTranslation(translationKey);\n const handleClick = useCallback(() => action.data?.(), [action]);\n const { icon, iconOnly = true, disabled, testId, hidden, classNames } = action.properties;\n const Root = icon ? NaturalToolbar.IconButton : NaturalToolbar.Button;\n const rootProps = icon\n ? { icon, size: iconSize, iconOnly, label: actionLabel(action, t) }\n : { children: <ActionLabel action={action} /> };\n\n return hidden ? null : (\n <Root\n key={action.id}\n disabled={disabled}\n onClick={handleClick}\n variant='ghost'\n {...(testId && { 'data-testid': testId })}\n {...(rootProps as any)}\n classNames={classNames}\n />\n );\n};\n\nconst DropdownMenuToolbarItem = ({\n group,\n items: propsItems,\n __menuScope,\n}: MenuScopedProps<ToolbarMenuActionGroupProps>) => {\n const { iconOnly, disabled, testId } = group.properties;\n const { t } = useTranslation(translationKey);\n const { iconSize } = useMenu('DropdownMenuToolbarItem', __menuScope);\n const items = useMenuItems(group, propsItems, 'DropdownMenuToolbarItem', __menuScope);\n const activeItem = items?.find((item) => !!(item as MenuAction).properties.checked);\n const icon =\n ((group.properties as any).applyActive &&\n // TODO(thure): Handle other menu item types.\n (activeItem as MenuAction)?.properties.icon) ||\n group.properties.icon;\n const Root = icon ? NaturalToolbar.IconButton : NaturalToolbar.Button;\n const labelAction = (group.properties as any).applyActive && activeItem ? (activeItem as MenuAction) : group;\n const rootProps = icon\n ? { icon, size: iconSize, iconOnly, label: actionLabel(labelAction, t), caretDown: true }\n : {\n children: (\n <>\n <ActionLabel action={labelAction} />\n <Icon size={3} icon='ph--caret-down--bold' classNames='mis-1' />\n </>\n ),\n };\n\n return (\n <DropdownMenu.Root group={group} items={items}>\n <DropdownMenu.Trigger asChild>\n <Root variant='ghost' disabled={disabled} {...(rootProps as any)} {...(testId && { 'data-testid': testId })} />\n </DropdownMenu.Trigger>\n </DropdownMenu.Root>\n );\n};\n\nconst ToggleGroupItem = ({ group, action, __menuScope }: MenuScopedProps<ToolbarMenuActionProps>) => {\n const { iconSize } = useMenu('ToggleGroupItem', __menuScope);\n const { t } = useTranslation(translationKey);\n const { icon, iconOnly = true, disabled, testId, hidden, classNames } = action.properties;\n const handleClick = useCallback(() => action.data?.({ parent: group }), [action, group]);\n const Root = icon ? NaturalToolbar.ToggleGroupIconItem : NaturalToolbar.ToggleGroupItem;\n const rootProps = icon\n ? { icon, size: iconSize, iconOnly, label: actionLabel(action, t) }\n : { children: <ActionLabel action={action} /> };\n\n return hidden ? null : (\n <Root\n key={action.id}\n value={action.id as any}\n disabled={disabled}\n onClick={handleClick}\n variant='ghost'\n {...(testId && { 'data-testid': testId })}\n {...(rootProps as any)}\n classNames={classNames}\n />\n );\n};\n\nconst ToggleGroupToolbarItem = ({\n group,\n items: propsItems,\n __menuScope,\n}: MenuScopedProps<ToolbarMenuActionGroupProps>) => {\n const items = useMenuItems(group, propsItems, 'ToggleGroupToolbarItem', __menuScope);\n const { selectCardinality, value } = group.properties;\n\n return (\n // TODO(thure): Fix.\n // @ts-ignore\n <NaturalToolbar.ToggleGroup type={selectCardinality} value={value}>\n {\n // TODO(thure): Handle other menu item types.\n (items as MenuAction[]).map((action) => (\n <ToggleGroupItem key={action.id} group={group} action={action} />\n ))\n }\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nexport const ToolbarMenu = ({\n __menuScope,\n classNames,\n textBlockWidth: wrapContents,\n ...props\n}: MenuScopedProps<ToolbarMenuProps>) => {\n const items = useMenuItems(undefined, undefined, 'ToolbarMenu', __menuScope);\n const { attendableId } = useMenu('ToolbarMenu', __menuScope);\n const { hasAttention } = useAttention(attendableId);\n const InnerRoot = wrapContents ? 'div' : Fragment;\n const innerRootProps = wrapContents ? { role: 'none', className: mx(textBlockWidth, toolbarLayout, 'bs-full') } : {};\n\n return (\n <NaturalToolbar.Root\n {...props}\n layoutManaged={wrapContents}\n classNames={[attendableId && !hasAttention && '*:opacity-20 !bg-transparent', classNames]}\n >\n <InnerRoot {...innerRootProps}>\n {items?.map((item: MenuItem, i: number) => (\n <ToolbarMenuItem key={item.id ?? i} item={item} />\n ))}\n </InnerRoot>\n </NaturalToolbar.Root>\n );\n};\n\nconst ToolbarMenuItem = ({ item }: { item: MenuItem }) => {\n if (isSeparator(item)) {\n return <NaturalToolbar.Separator variant={item.properties.variant} />;\n }\n\n // TODO(thure): Figure out type narrowing that doesn’t require so much use of `as`.\n if (isMenuGroup(item)) {\n if (item.properties.variant === 'dropdownMenu') {\n return <DropdownMenuToolbarItem group={item as MenuItemGroup<ToolbarMenuActionGroupProperties>} />;\n } else {\n return <ToggleGroupToolbarItem group={item as MenuItemGroup<ToolbarMenuActionGroupProperties>} />;\n }\n }\n\n return <ActionToolbarItem action={item as MenuAction} />;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { ACTION_GROUP_TYPE, type Action, type ActionGroup, type Node } from '@dxos/app-graph';\nimport { type ClassNameValue, type IconButtonProps, type Label, type ToolbarSeparatorProps } from '@dxos/react-ui';\n\nexport type MenuActionProperties = {\n label: Label;\n icon?: string;\n value?: string;\n disabled?: boolean;\n hidden?: boolean;\n iconOnly?: boolean;\n testId?: string;\n variant?: 'action' | 'toggle';\n checked?: boolean;\n classNames?: ClassNameValue;\n};\n\nexport type MenuItemGroupProperties = {\n label: Label;\n icon?: string;\n iconOnly?: boolean;\n};\n\nexport type MenuAction<P extends {} = {}> = Action<P & MenuActionProperties>;\n\nexport const MenuSeparatorType = '@dxos/react-ui-toolbar/separator' as const;\n\nexport type MenuSeparator = Node<never, Pick<ToolbarSeparatorProps, 'variant'>> & {\n type: typeof MenuSeparatorType;\n};\n\nexport const isSeparator = (node: Node): node is MenuSeparator => node.type === MenuSeparatorType;\n\nexport type MenuSingleSelectActionGroup = { selectCardinality: 'single'; value: string };\nexport type MenuMultipleSelectActionGroup = { selectCardinality: 'multiple'; value: string[] };\n\nexport type MenuItemGroup<P extends Record<string, any> = Record<string, any>> = ActionGroup<P>;\n\nexport const isMenuGroup = (node: Node): node is MenuItemGroup => node.type === ACTION_GROUP_TYPE;\n\nexport type MenuItem = MenuSeparator | MenuAction | MenuItemGroup;\n\nexport type MenuItemsResolver = (group?: MenuItemGroup) => MenuItem[] | null;\n\nexport type MenuContextValue = {\n useGroupItems: MenuItemsResolver;\n iconSize: IconButtonProps['size'];\n attendableId?: string;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RegistryContext, type Rx, useRxValue } from '@effect-rx/rx-react';\nimport { useCallback, useContext, useEffect, useState } from 'react';\n\nimport { type Edge, type Edges, Graph, type Node, type NodeArg, ROOT_ID } from '@dxos/app-graph';\n\nimport { type MenuItem, type MenuItemGroup } from '../types';\n\nconst edgesArrayToRecord = (edges: Edge[]): Record<string, Edges> => {\n return Object.fromEntries(\n Object.entries(\n edges.reduce((acc: Record<string, { inbound: string[]; outbound: string[] }>, { source, target }) => {\n if (!acc[source]) {\n acc[source] = { inbound: [], outbound: [] };\n }\n if (!acc[target]) {\n acc[target] = { inbound: [], outbound: [] };\n }\n\n const sourceEdges = acc[source];\n if (!sourceEdges.outbound.includes(target)) {\n sourceEdges.outbound.push(target);\n }\n\n const targetEdges = acc[target];\n if (!targetEdges.inbound.includes(source)) {\n targetEdges.inbound.push(source);\n }\n\n return acc;\n }, {}),\n ),\n );\n};\n\nexport type ActionGraphNodes = NodeArg<any>[];\nexport type ActionGraphEdges = Edge[];\nexport type ActionGraphProps = { nodes: ActionGraphNodes; edges: ActionGraphEdges };\n\nexport const useMenuActions = (props: Rx.Rx<ActionGraphProps>) => {\n const registry = useContext(RegistryContext);\n const menuGraphProps = useRxValue(props);\n\n const [graph] = useState(\n new Graph({\n registry,\n nodes: menuGraphProps.nodes as Node[],\n edges: edgesArrayToRecord(menuGraphProps.edges),\n }),\n );\n\n useEffect(() => {\n graph.addNodes(menuGraphProps.nodes);\n graph.addEdges(menuGraphProps.edges);\n }, [menuGraphProps]);\n\n const useGroupItems = useCallback(\n (sourceNode?: MenuItemGroup) => {\n const items = useRxValue(graph.connections(sourceNode?.id || ROOT_ID)) as MenuItem[];\n return items;\n },\n [graph],\n );\n\n return { useGroupItems };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\n\nimport type { ActionGraphProps } from './hooks';\nimport type { MenuActionProperties, MenuItemGroupProperties } from './types';\nimport { createMenuAction, createMenuItemGroup } from './util';\n\nexport interface ActionGroupBuilder {\n action<P extends {} = {}>(id: string, props: P & MenuActionProperties, invoke: () => void): this;\n group<P extends {} = {}>(\n id: string,\n props: P & MenuItemGroupProperties,\n cb: (builder: ActionGroupBuilder) => void,\n ): this;\n}\n\nexport interface MenuBuilder extends ActionGroupBuilder {\n root(props: MenuItemGroupProperties): this;\n build(): ActionGraphProps;\n}\n\nexport const MenuBuilder = Object.freeze({\n make: (): MenuBuilder => new MenuBuilderImpl({ nodes: [], edges: [] }, 'root'),\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 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 });\n return this;\n }\n\n group<P extends {} = {}>(\n id: string,\n props: P & MenuItemGroupProperties,\n cb: (builder: ActionGroupBuilder) => void,\n ): this {\n this._data.nodes.push(createMenuItemGroup(id, props));\n this._data.edges.push({ source: this._rootId, target: id });\n cb(new MenuBuilderImpl(this._data, id));\n return this;\n }\n\n build(): ActionGraphProps {\n return this._data;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,oBAAoB;;;;ACA7B,SAASC,4BAA4B;AACrC,OAAOC,UAA0BC,mBAAmB;AAEpD,SAAqCC,MAAMC,gBAAgBC,2BAA2B;;;;ACHtF,OAAOC,WAAW;AAGlB,SAASC,kBAAkB;AAC3B,SAAyBC,mBAAmBC,sBAAsB;AAClE,SAASC,iBAAiBC,UAAU;;;ACH7B,IAAMC,iBAAiB;AAEvB,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACD,cAAAA,GAAiB,CAAC;IACrB;EACF;;;;ACTF,SAASE,mBAAmBC,aAA8BC,yBAAyB;AACnF,SAASC,uBAAuB;AAUzB,IAAMC,cAAc,CAACC,WAAAA;AAC1B,SAAO,OAAOA,OAAOC,YAAYC,eAAe,WAC5CF,OAAOC,WAAWC,aAClBF,OAAOC,YAAYC,aAAaC,gBAAAA,CAAAA;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B,QAAQT,KAAAA,CAAAA;AAClD,WAAO;EACT;EAEAU,OAA0BJ,IAAYN,OAAiCW,QAA0B;AAC/F,SAAKR,MAAMN,MAAMW,KAAKI,iBAAiBN,IAAIK,QAAQX,KAAAA,CAAAA;AACnD,SAAKG,MAAML,MAAMU,KAAK;MAAEK,QAAQ,KAAKX;MAASY,QAAQR;IAAG,CAAA;AACzD,WAAO;EACT;EAEAS,MACET,IACAN,OACAgB,IACM;AACN,SAAKb,MAAMN,MAAMW,KAAKC,oBAAoBH,IAAIN,KAAAA,CAAAA;AAC9C,SAAKG,MAAML,MAAMU,KAAK;MAAEK,QAAQ,KAAKX;MAASY,QAAQR;IAAG,CAAA;AACzDU,OAAG,IAAIpB,iBAAgB,KAAKO,OAAOG,EAAAA,CAAAA;AACnC,WAAO;EACT;EAEAW,QAA0B;AACxB,WAAO,KAAKd;EACd;EA/BA,YACmBA,OACAD,SACjB;;;SAFiBC,QAAAA;SACAD,UAAAA;EAChB;AA6BL;",
|
|
6
|
+
"names": ["rxFromSignal", "useControllableState", "React", "useCallback", "Icon", "DropdownMenu", "NaturalDropdownMenu", "React", "keySymbols", "toLocalizedString", "useTranslation", "descriptionText", "mx", "translationKey", "translations", "ACTION_GROUP_TYPE", "ACTION_TYPE", "actionGroupSymbol", "getHostPlatform", "getShortcut", "action", "properties", "keyBinding", "getHostPlatform", "createMenuAction", "id", "invoke", "properties", "type", "ACTION_TYPE", "data", "createMenuItemGroup", "ACTION_GROUP_TYPE", "actionGroupSymbol", "createGapSeparator", "source", "nodes", "variant", "undefined", "edges", "target", "createLineSeparator", "ActionLabel", "action", "t", "useTranslation", "translationKey", "shortcut", "getShortcut", "span", "className", "toLocalizedString", "properties", "label", "mx", "descriptionText", "keySymbols", "join", "actionLabel", "createContextScope", "React", "useMemo", "MENU_NAME", "createMenuContext", "createMenuScope", "createContextScope", "MenuContextProvider", "useMenu", "menuContextDefaults", "iconSize", "useGroupItems", "useMenuScope", "MenuProvider", "children", "attendableId", "scope", "undefined", "React", "useMenuItems", "group", "propsItems", "consumerName", "__menuScope", "groupItems", "useMemo", "DropdownMenuItem", "item", "onClick", "__menuScope", "action", "handleClick", "useCallback", "event", "iconSize", "useMenu", "React", "NaturalDropdownMenu", "Item", "classNames", "disabled", "properties", "testId", "icon", "Icon", "size", "ActionLabel", "DropdownMenuRoot", "items", "propsItems", "group", "open", "defaultOpen", "onOpenChange", "caller", "children", "naturalProps", "optionsMenuOpen", "setOptionsMenuOpen", "useControllableState", "prop", "defaultProp", "onChange", "handleActionClick", "stopPropagation", "data", "parent", "useMenuItems", "Root", "Portal", "Content", "Viewport", "map", "key", "id", "Arrow", "DropdownMenu", "Trigger", "VirtualTrigger", "React", "Fragment", "useCallback", "Icon", "Toolbar", "NaturalToolbar", "useTranslation", "useAttention", "mx", "textBlockWidth", "toolbarLayout", "ACTION_GROUP_TYPE", "MenuSeparatorType", "isSeparator", "node", "type", "isMenuGroup", "ACTION_GROUP_TYPE", "ActionToolbarItem", "action", "__menuScope", "iconSize", "useMenu", "t", "useTranslation", "translationKey", "handleClick", "useCallback", "data", "icon", "iconOnly", "disabled", "testId", "hidden", "classNames", "properties", "Root", "NaturalToolbar", "IconButton", "Button", "rootProps", "size", "label", "actionLabel", "children", "React", "ActionLabel", "key", "id", "onClick", "variant", "DropdownMenuToolbarItem", "group", "items", "propsItems", "useMenuItems", "activeItem", "find", "item", "checked", "applyActive", "labelAction", "caretDown", "Icon", "DropdownMenu", "Trigger", "asChild", "ToggleGroupItem", "parent", "ToggleGroupIconItem", "value", "ToggleGroupToolbarItem", "selectCardinality", "ToggleGroup", "type", "map", "ToolbarMenu", "textBlockWidth", "wrapContents", "props", "undefined", "attendableId", "hasAttention", "useAttention", "InnerRoot", "Fragment", "innerRootProps", "role", "className", "mx", "toolbarLayout", "layoutManaged", "i", "ToolbarMenuItem", "isSeparator", "Separator", "isMenuGroup", "RegistryContext", "useRxValue", "useCallback", "useContext", "useEffect", "useState", "Graph", "ROOT_ID", "edgesArrayToRecord", "edges", "Object", "fromEntries", "entries", "reduce", "acc", "source", "target", "inbound", "outbound", "sourceEdges", "includes", "push", "targetEdges", "useMenuActions", "props", "registry", "useContext", "RegistryContext", "menuGraphProps", "useRxValue", "graph", "useState", "Graph", "nodes", "useEffect", "addNodes", "addEdges", "useGroupItems", "useCallback", "sourceNode", "items", "connections", "id", "ROOT_ID", "invariant", "MenuBuilder", "Object", "freeze", "make", "MenuBuilderImpl", "nodes", "edges", "root", "props", "invariant", "_rootId", "_data", "find", "node", "id", "undefined", "push", "createMenuItemGroup", "action", "invoke", "createMenuAction", "source", "target", "group", "cb", "build"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"
|
|
1
|
+
{"inputs":{"src/translations.ts":{"bytes":1041,"imports":[],"format":"esm"},"src/util.ts":{"bytes":5883,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/components/ActionLabel.tsx":{"bytes":4313,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/keyboard","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"src/translations.ts","kind":"import-statement","original":"../translations"},{"path":"src/util.ts","kind":"import-statement","original":"../util"}],"format":"esm"},"src/components/MenuContext.tsx":{"bytes":5209,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/components/DropdownMenu.tsx":{"bytes":10534,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"src/components/ActionLabel.tsx","kind":"import-statement","original":"./ActionLabel"},{"path":"src/components/MenuContext.tsx","kind":"import-statement","original":"./MenuContext"}],"format":"esm"},"src/types.ts":{"bytes":3194,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"format":"esm"},"src/components/ToolbarMenu.tsx":{"bytes":24514,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-attention","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"src/translations.ts","kind":"import-statement","original":"../translations"},{"path":"src/types.ts","kind":"import-statement","original":"../types"},{"path":"src/components/ActionLabel.tsx","kind":"import-statement","original":"./ActionLabel"},{"path":"src/components/DropdownMenu.tsx","kind":"import-statement","original":"./DropdownMenu"},{"path":"src/components/MenuContext.tsx","kind":"import-statement","original":"./MenuContext"}],"format":"esm"},"src/components/index.ts":{"bytes":673,"imports":[{"path":"src/components/DropdownMenu.tsx","kind":"import-statement","original":"./DropdownMenu"},{"path":"src/components/ToolbarMenu.tsx","kind":"import-statement","original":"./ToolbarMenu"},{"path":"src/components/MenuContext.tsx","kind":"import-statement","original":"./MenuContext"}],"format":"esm"},"src/hooks/useMenuActions.ts":{"bytes":6878,"imports":[{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"format":"esm"},"src/hooks/index.ts":{"bytes":476,"imports":[{"path":"src/hooks/useMenuActions.ts","kind":"import-statement","original":"./useMenuActions"}],"format":"esm"},"src/builder.ts":{"bytes":6944,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/index.ts":{"bytes":1394,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"src/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"path":"src/types.ts","kind":"import-statement","original":"./types"},{"path":"src/util.ts","kind":"import-statement","original":"./util"},{"path":"src/builder.ts","kind":"import-statement","original":"./builder"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":35259},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/keyboard","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-attention","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"exports":["DropdownMenu","MenuBuilder","MenuProvider","MenuSeparatorType","ToolbarMenu","createGapSeparator","createLineSeparator","createMenuAction","createMenuItemGroup","createMenuScope","isMenuGroup","isSeparator","menuContextDefaults","rxFromSignal","useMenu","useMenuActions","useMenuItems"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":48},"src/components/DropdownMenu.tsx":{"bytesInOutput":2621},"src/components/ActionLabel.tsx":{"bytesInOutput":1031},"src/translations.ts":{"bytesInOutput":118},"src/util.ts":{"bytesInOutput":1113},"src/components/MenuContext.tsx":{"bytesInOutput":1199},"src/components/index.ts":{"bytesInOutput":0},"src/components/ToolbarMenu.tsx":{"bytesInOutput":6599},"src/types.ts":{"bytesInOutput":258},"src/hooks/useMenuActions.ts":{"bytesInOutput":1447},"src/hooks/index.ts":{"bytesInOutput":0},"src/builder.ts":{"bytesInOutput":1855}},"bytes":17103}}}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ActionGraphProps } from './hooks';
|
|
2
|
+
import type { MenuActionProperties, MenuItemGroupProperties } from './types';
|
|
3
|
+
export interface ActionGroupBuilder {
|
|
4
|
+
action<P extends {} = {}>(id: string, props: P & MenuActionProperties, invoke: () => void): this;
|
|
5
|
+
group<P extends {} = {}>(id: string, props: P & MenuItemGroupProperties, cb: (builder: ActionGroupBuilder) => void): this;
|
|
6
|
+
}
|
|
7
|
+
export interface MenuBuilder extends ActionGroupBuilder {
|
|
8
|
+
root(props: MenuItemGroupProperties): this;
|
|
9
|
+
build(): ActionGraphProps;
|
|
10
|
+
}
|
|
11
|
+
export declare const MenuBuilder: Readonly<{
|
|
12
|
+
make: () => MenuBuilder;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../src/builder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAG7E,MAAM,WAAW,kBAAkB;IACjC,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;IACjG,KAAK,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,EACrB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,CAAC,GAAG,uBAAuB,EAClC,EAAE,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,GACxC,IAAI,CAAC;CACT;AAED,MAAM,WAAW,WAAY,SAAQ,kBAAkB;IACrD,IAAI,CAAC,KAAK,EAAE,uBAAuB,GAAG,IAAI,CAAC;IAC3C,KAAK,IAAI,gBAAgB,CAAC;CAC3B;AAED,eAAO,MAAM,WAAW;gBACZ,WAAW;EACrB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type Action as GraphAction
|
|
2
|
+
import { type ActionGroup, type Action as GraphAction } from '@dxos/app-graph';
|
|
3
3
|
import { type TFunction } from '@dxos/react-ui';
|
|
4
4
|
import { type MenuActionProperties } from '../types';
|
|
5
5
|
type Action = GraphAction<MenuActionProperties> | ActionGroup<Omit<MenuActionProperties, 'variant'>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionLabel.d.ts","sourceRoot":"","sources":["../../../../src/components/ActionLabel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"ActionLabel.d.ts","sourceRoot":"","sources":["../../../../src/components/ActionLabel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE/E,OAAO,EAAE,KAAK,SAAS,EAAqC,MAAM,gBAAgB,CAAC;AAInF,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,KAAK,MAAM,GAAG,WAAW,CAAC,oBAAoB,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC;AAErG,eAAO,MAAM,WAAW,GAAI,YAAY;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,sBASzD,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,GAAG,SAAS,WAGvD,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type DropdownMenuRootProps } from '@dxos/react-ui';
|
|
3
|
-
import { type MenuScopedProps } from './MenuContext';
|
|
4
3
|
import { type MenuItem, type MenuItemGroup } from '../types';
|
|
4
|
+
import { type MenuScopedProps } from './MenuContext';
|
|
5
5
|
export type DropdownMenuProps = DropdownMenuRootProps & {
|
|
6
6
|
group?: MenuItemGroup;
|
|
7
7
|
items?: MenuItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/DropdownMenu.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAO,
|
|
1
|
+
{"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/DropdownMenu.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,KAAK,qBAAqB,EAA6C,MAAM,gBAAgB,CAAC;AAEvG,OAAO,EAAmB,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9E,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,eAAe,CAAC;AAE5E,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GAAG;IACtD,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AA4EF,eAAO,MAAM,YAAY;0HAvCtB,eAAe,CAAC,iBAAiB,CAAC;;;;;;;;CA2CpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuContext.d.ts","sourceRoot":"","sources":["../../../../src/components/MenuContext.tsx"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"MenuContext.d.ts","sourceRoot":"","sources":["../../../../src/components/MenuContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAsB,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpF,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAI7D,QAAA,MAA0B,eAAe,+CAAqC,CAAC;AAE/E,QAAA,MAA4B,OAAO,wFAAkD,CAAC;AAEtF,eAAO,MAAM,mBAAmB,EAAE,gBAGjC,CAAC;AAIF,QAAA,MAAM,YAAY,GAAI,sDAKnB,iBAAiB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,sBAO9C,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,QAAQ,aAAa,EACrB,aAAa,QAAQ,EAAE,EACvB,eAAc,MAA8B,EAC5C,cAAc,KAAK,2BAKpB,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ToolbarRootProps } from '@dxos/react-ui';
|
|
3
|
+
import { type MenuAction, type MenuActionProperties, type MenuItem, type MenuItemGroup, type MenuMultipleSelectActionGroup, type MenuSingleSelectActionGroup } from '../types';
|
|
3
4
|
import { type MenuScopedProps } from './MenuContext';
|
|
4
|
-
import { type MenuAction, type MenuItem, type MenuItemGroup, type MenuActionProperties, type MenuMultipleSelectActionGroup, type MenuSingleSelectActionGroup } from '../types';
|
|
5
5
|
export type ToolbarMenuDropdownMenuActionGroup = Omit<MenuActionProperties, 'variant' | 'icon'> & {
|
|
6
6
|
variant: 'dropdownMenu';
|
|
7
7
|
icon: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/ToolbarMenu.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAErD,OAAO,EAAmC,KAAK,gBAAgB,EAAkB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ToolbarMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/ToolbarMenu.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAErD,OAAO,EAAmC,KAAK,gBAAgB,EAAkB,MAAM,gBAAgB,CAAC;AAKxG,OAAO,EACL,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAGjC,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,eAAe,CAAC;AAE5E,MAAM,MAAM,kCAAkC,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,MAAM,CAAC,GAAG;IAChG,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,GAAG;IACt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