@dxos/plugin-simple-layout 0.8.4-main.937b3ca → 0.8.4-main.bc674ce
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/{chunk-FK4M7GJV.mjs → chunk-LR3EE3VB.mjs} +298 -122
- package/dist/lib/browser/chunk-LR3EE3VB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CLPGTNWJ.mjs → chunk-P77G4YTR.mjs} +1 -1
- package/dist/lib/browser/chunk-P77G4YTR.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +13 -7
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-LTB63NKP.mjs → operation-resolver-775UYAC2.mjs} +50 -15
- package/dist/lib/browser/operation-resolver-775UYAC2.mjs.map +7 -0
- package/dist/lib/browser/{react-root-6ARAPH3O.mjs → react-root-KM55OMGJ.mjs} +3 -3
- package/dist/lib/browser/{react-surface-SO7B23GS.mjs → react-surface-BABGAWGY.mjs} +3 -3
- package/dist/lib/browser/{state-H4IGICBB.mjs → state-OUFTC2KV.mjs} +5 -3
- package/dist/lib/browser/state-OUFTC2KV.mjs.map +7 -0
- package/dist/lib/browser/{url-handler-7CFGTLNG.mjs → url-handler-DOUFQIAC.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-MUVVYBUE.mjs → chunk-F5TEKVJG.mjs} +1 -1
- package/dist/lib/node-esm/chunk-F5TEKVJG.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-EGFZAVBD.mjs → chunk-HB2B3LLG.mjs} +298 -122
- package/dist/lib/node-esm/chunk-HB2B3LLG.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +13 -7
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{operation-resolver-7O6O7T4Q.mjs → operation-resolver-LDNYS3DI.mjs} +50 -15
- package/dist/lib/node-esm/operation-resolver-LDNYS3DI.mjs.map +7 -0
- package/dist/lib/node-esm/{react-root-2CPA2ZUS.mjs → react-root-36UYFEEB.mjs} +3 -3
- package/dist/lib/node-esm/{react-surface-FKAV56MO.mjs → react-surface-CGHFVWU3.mjs} +3 -3
- package/dist/lib/node-esm/{state-QIU2LMLT.mjs → state-Q2ZA26W5.mjs} +5 -3
- package/dist/lib/node-esm/state-Q2ZA26W5.mjs.map +7 -0
- package/dist/lib/node-esm/{url-handler-4LYP3JM7.mjs → url-handler-DVAZZEUO.mjs} +2 -2
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -1
- package/dist/types/src/components/ContentError.stories.d.ts +6 -0
- package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Banner.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts +9 -0
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/Main.d.ts +1 -1
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +5 -2
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +10 -6
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +10 -0
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/hooks.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useCompanions.d.ts +8 -0
- package/dist/types/src/hooks/useCompanions.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +6 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +5 -1
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -23
- package/src/capabilities/operation-resolver/operation-resolver.ts +50 -13
- package/src/capabilities/state/state.tsx +2 -0
- package/src/components/SimpleLayout/Banner.tsx +35 -4
- package/src/components/SimpleLayout/Drawer.tsx +151 -0
- package/src/components/SimpleLayout/Main.tsx +31 -40
- package/src/components/SimpleLayout/NavBar.stories.tsx +0 -3
- package/src/components/SimpleLayout/NavBar.tsx +29 -37
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +4 -0
- package/src/components/SimpleLayout/SimpleLayout.tsx +26 -6
- package/src/components/hooks.ts +8 -12
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useCompanions.ts +19 -0
- package/src/translations.ts +6 -0
- package/src/types/capabilities.ts +6 -1
- package/dist/lib/browser/chunk-CLPGTNWJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FK4M7GJV.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-LTB63NKP.mjs.map +0 -7
- package/dist/lib/browser/state-H4IGICBB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EGFZAVBD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MUVVYBUE.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-7O6O7T4Q.mjs.map +0 -7
- package/dist/lib/node-esm/state-QIU2LMLT.mjs.map +0 -7
- /package/dist/lib/browser/{react-root-6ARAPH3O.mjs.map → react-root-KM55OMGJ.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-SO7B23GS.mjs.map → react-surface-BABGAWGY.mjs.map} +0 -0
- /package/dist/lib/browser/{url-handler-7CFGTLNG.mjs.map → url-handler-DOUFQIAC.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-root-2CPA2ZUS.mjs.map → react-root-36UYFEEB.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-FKAV56MO.mjs.map → react-surface-CGHFVWU3.mjs.map} +0 -0
- /package/dist/lib/node-esm/{url-handler-4LYP3JM7.mjs.map → url-handler-DVAZZEUO.mjs.map} +0 -0
|
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
2
2
|
import {
|
|
3
3
|
SimpleLayoutState,
|
|
4
4
|
meta
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-F5TEKVJG.mjs";
|
|
6
6
|
|
|
7
7
|
// src/components/Home/Home.tsx
|
|
8
8
|
import React, { useCallback, useEffect as useEffect2, useMemo, useRef } from "react";
|
|
@@ -22,15 +22,12 @@ import { Graph } from "@dxos/plugin-graph";
|
|
|
22
22
|
var useLoadDescendents = (nodeId) => {
|
|
23
23
|
const { graph } = useAppGraph();
|
|
24
24
|
useEffect(() => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Graph.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return () => cancelAnimationFrame(frame);
|
|
25
|
+
if (nodeId) {
|
|
26
|
+
Graph.expand(graph, nodeId, "outbound");
|
|
27
|
+
Graph.getConnections(graph, nodeId, "outbound").forEach((child) => {
|
|
28
|
+
Graph.expand(graph, child.id, "outbound");
|
|
29
|
+
});
|
|
30
|
+
}
|
|
34
31
|
}, [
|
|
35
32
|
nodeId,
|
|
36
33
|
graph
|
|
@@ -143,12 +140,24 @@ var useItemsByDisposition = (disposition, sort = false) => {
|
|
|
143
140
|
};
|
|
144
141
|
|
|
145
142
|
// src/components/SimpleLayout/SimpleLayout.tsx
|
|
146
|
-
import
|
|
143
|
+
import React10, { useCallback as useCallback6 } from "react";
|
|
144
|
+
import { Main as NaturalMain3 } from "@dxos/react-ui";
|
|
145
|
+
import { Mosaic as Mosaic2 } from "@dxos/react-ui-mosaic";
|
|
147
146
|
|
|
148
|
-
// src/
|
|
149
|
-
import
|
|
150
|
-
import {
|
|
151
|
-
import {
|
|
147
|
+
// src/hooks/useCompanions.ts
|
|
148
|
+
import { useMemo as useMemo2 } from "react";
|
|
149
|
+
import { useAppGraph as useAppGraph3 } from "@dxos/app-framework/react";
|
|
150
|
+
import { useConnections as useConnections2 } from "@dxos/plugin-graph";
|
|
151
|
+
import { byPosition as byPosition2 } from "@dxos/util";
|
|
152
|
+
var PLANK_COMPANION_TYPE = "dxos.org/plugin/deck/plank-companion";
|
|
153
|
+
var useCompanions = (id) => {
|
|
154
|
+
const { graph } = useAppGraph3();
|
|
155
|
+
const nodes = useConnections2(graph, id);
|
|
156
|
+
const companions = nodes.filter((node) => node.type === PLANK_COMPANION_TYPE);
|
|
157
|
+
return useMemo2(() => companions.toSorted((a, b) => byPosition2(a.properties, b.properties)), [
|
|
158
|
+
companions
|
|
159
|
+
]);
|
|
160
|
+
};
|
|
152
161
|
|
|
153
162
|
// src/hooks/useSimpleLayoutState.ts
|
|
154
163
|
import { RegistryContext, useAtomValue } from "@effect-atom/atom-react";
|
|
@@ -170,6 +179,11 @@ var useSimpleLayoutState = () => {
|
|
|
170
179
|
};
|
|
171
180
|
};
|
|
172
181
|
|
|
182
|
+
// src/components/Dialog/Dialog.tsx
|
|
183
|
+
import React3 from "react";
|
|
184
|
+
import { Surface } from "@dxos/app-framework/react";
|
|
185
|
+
import { AlertDialog, Dialog as NaturalDialog } from "@dxos/react-ui";
|
|
186
|
+
|
|
173
187
|
// src/components/ContentError.tsx
|
|
174
188
|
import React2 from "react";
|
|
175
189
|
import { useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
@@ -217,7 +231,7 @@ var Dialog = () => {
|
|
|
217
231
|
|
|
218
232
|
// src/components/Popover/Popover.tsx
|
|
219
233
|
import { createContext } from "@radix-ui/react-context";
|
|
220
|
-
import React4, { useCallback as useCallback3, useEffect as useEffect3, useMemo as
|
|
234
|
+
import React4, { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo3, useRef as useRef2, useState } from "react";
|
|
221
235
|
import { Surface as Surface2 } from "@dxos/app-framework/react";
|
|
222
236
|
import { Popover, toLocalizedString as toLocalizedString2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
223
237
|
import { Card as Card2 } from "@dxos/react-ui-mosaic";
|
|
@@ -286,7 +300,7 @@ var PopoverContent = () => {
|
|
|
286
300
|
}, [
|
|
287
301
|
handleClose
|
|
288
302
|
]);
|
|
289
|
-
const collisionBoundaries =
|
|
303
|
+
const collisionBoundaries = useMemo3(() => {
|
|
290
304
|
const closest = state.popoverAnchor?.closest("[data-popover-collision-boundary]");
|
|
291
305
|
return closest ? [
|
|
292
306
|
closest
|
|
@@ -314,15 +328,12 @@ var PopoverContent = () => {
|
|
|
314
328
|
})), /* @__PURE__ */ React4.createElement(Popover.Arrow, null)));
|
|
315
329
|
};
|
|
316
330
|
|
|
317
|
-
// src/components/SimpleLayout/
|
|
318
|
-
import
|
|
319
|
-
import { Surface as Surface3, useAppGraph as
|
|
320
|
-
import { log } from "@dxos/log";
|
|
331
|
+
// src/components/SimpleLayout/Drawer.tsx
|
|
332
|
+
import React6, { useCallback as useCallback4, useMemo as useMemo4 } from "react";
|
|
333
|
+
import { Surface as Surface3, useAppGraph as useAppGraph4 } from "@dxos/app-framework/react";
|
|
321
334
|
import { useNode } from "@dxos/plugin-graph";
|
|
322
|
-
import { Main as NaturalMain } from "@dxos/react-ui";
|
|
335
|
+
import { IconButton, Main as NaturalMain, Toolbar as Toolbar2, toLocalizedString as toLocalizedString3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
323
336
|
import { ATTENDABLE_PATH_SEPARATOR } from "@dxos/react-ui-attention";
|
|
324
|
-
import { Mosaic as Mosaic2 } from "@dxos/react-ui-mosaic";
|
|
325
|
-
import { mx as mx5 } from "@dxos/ui-theme";
|
|
326
337
|
|
|
327
338
|
// src/components/ContentLoading.tsx
|
|
328
339
|
import React5 from "react";
|
|
@@ -333,26 +344,171 @@ var ContentLoading = () => {
|
|
|
333
344
|
});
|
|
334
345
|
};
|
|
335
346
|
|
|
347
|
+
// src/components/SimpleLayout/Drawer.tsx
|
|
348
|
+
var DRAWER_NAME = "SimpleLayout.Drawer";
|
|
349
|
+
var Drawer = () => {
|
|
350
|
+
const { t } = useTranslation4(meta.id);
|
|
351
|
+
const { state, updateState } = useSimpleLayoutState();
|
|
352
|
+
const { graph } = useAppGraph4();
|
|
353
|
+
const placeholder = useMemo4(() => /* @__PURE__ */ React6.createElement(ContentLoading, null), []);
|
|
354
|
+
const activeId = state.active ?? state.workspace;
|
|
355
|
+
const companions = useCompanions(activeId);
|
|
356
|
+
const { companionId, variant } = useSelectedCompanion(companions, state.companionVariant);
|
|
357
|
+
const node = useNode(graph, companionId);
|
|
358
|
+
const parentNode = useNode(graph, activeId);
|
|
359
|
+
const data = useMemo4(() => {
|
|
360
|
+
return node && {
|
|
361
|
+
attendableId: companionId,
|
|
362
|
+
subject: node.data,
|
|
363
|
+
companionTo: parentNode?.data,
|
|
364
|
+
properties: node.properties,
|
|
365
|
+
variant
|
|
366
|
+
};
|
|
367
|
+
}, [
|
|
368
|
+
companionId,
|
|
369
|
+
node,
|
|
370
|
+
parentNode,
|
|
371
|
+
variant
|
|
372
|
+
]);
|
|
373
|
+
const handleTabClick = useCallback4((companion) => {
|
|
374
|
+
const [, companionVariant] = companion.id.split(ATTENDABLE_PATH_SEPARATOR);
|
|
375
|
+
updateState((s) => ({
|
|
376
|
+
...s,
|
|
377
|
+
companionVariant
|
|
378
|
+
}));
|
|
379
|
+
}, [
|
|
380
|
+
updateState
|
|
381
|
+
]);
|
|
382
|
+
const handleToggleExpand = useCallback4(() => {
|
|
383
|
+
updateState((s) => ({
|
|
384
|
+
...s,
|
|
385
|
+
drawerState: s.drawerState === "full" ? "expanded" : "full"
|
|
386
|
+
}));
|
|
387
|
+
}, [
|
|
388
|
+
updateState
|
|
389
|
+
]);
|
|
390
|
+
const handleClose = useCallback4(() => {
|
|
391
|
+
updateState((s) => ({
|
|
392
|
+
...s,
|
|
393
|
+
drawerState: "closed"
|
|
394
|
+
}));
|
|
395
|
+
}, [
|
|
396
|
+
updateState
|
|
397
|
+
]);
|
|
398
|
+
const drawerState = state.drawerState ?? "closed";
|
|
399
|
+
if (drawerState === "closed") {
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
const isFullyExpanded = drawerState === "full";
|
|
403
|
+
return /* @__PURE__ */ React6.createElement(NaturalMain.Drawer, {
|
|
404
|
+
label: t("drawer label")
|
|
405
|
+
}, /* @__PURE__ */ React6.createElement(Toolbar2.Root, null, /* @__PURE__ */ React6.createElement("div", {
|
|
406
|
+
role: "tablist",
|
|
407
|
+
className: "flex-1 min-is-0 overflow-x-auto scrollbar-none flex gap-1"
|
|
408
|
+
}, companions.map((companion) => /* @__PURE__ */ React6.createElement(IconButton, {
|
|
409
|
+
key: companion.id,
|
|
410
|
+
role: "tab",
|
|
411
|
+
"aria-selected": companionId === companion.id,
|
|
412
|
+
icon: companion.properties.icon,
|
|
413
|
+
iconOnly: true,
|
|
414
|
+
label: toLocalizedString3(companion.properties.label, t),
|
|
415
|
+
variant: companionId === companion.id ? "primary" : "ghost",
|
|
416
|
+
onClick: () => handleTabClick(companion)
|
|
417
|
+
}))), /* @__PURE__ */ React6.createElement(Toolbar2.Separator, {
|
|
418
|
+
variant: "gap"
|
|
419
|
+
}), /* @__PURE__ */ React6.createElement(Toolbar2.IconButton, {
|
|
420
|
+
icon: isFullyExpanded ? "ph--arrow-down--regular" : "ph--arrow-up--regular",
|
|
421
|
+
iconOnly: true,
|
|
422
|
+
label: isFullyExpanded ? t("collapse drawer label") : t("expand drawer label"),
|
|
423
|
+
onClick: handleToggleExpand
|
|
424
|
+
}), /* @__PURE__ */ React6.createElement(Toolbar2.IconButton, {
|
|
425
|
+
icon: "ph--x--regular",
|
|
426
|
+
iconOnly: true,
|
|
427
|
+
label: t("close drawer label"),
|
|
428
|
+
onClick: handleClose
|
|
429
|
+
})), /* @__PURE__ */ React6.createElement(Surface3, {
|
|
430
|
+
role: "article",
|
|
431
|
+
data,
|
|
432
|
+
limit: 1,
|
|
433
|
+
fallback: ContentError,
|
|
434
|
+
placeholder
|
|
435
|
+
}));
|
|
436
|
+
};
|
|
437
|
+
Drawer.displayName = DRAWER_NAME;
|
|
438
|
+
var parseEntryId = (entryId) => {
|
|
439
|
+
const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR);
|
|
440
|
+
return {
|
|
441
|
+
id,
|
|
442
|
+
variant
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
var useSelectedCompanion = (companions, preferredVariant) => {
|
|
446
|
+
const selectedCompanion = useMemo4(() => {
|
|
447
|
+
if (companions.length === 0) {
|
|
448
|
+
return void 0;
|
|
449
|
+
}
|
|
450
|
+
if (preferredVariant) {
|
|
451
|
+
const preferred = companions.find((c) => {
|
|
452
|
+
const { variant: variant2 } = parseEntryId(c.id);
|
|
453
|
+
return variant2 === preferredVariant;
|
|
454
|
+
});
|
|
455
|
+
if (preferred) {
|
|
456
|
+
return preferred;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return companions[0];
|
|
460
|
+
}, [
|
|
461
|
+
companions,
|
|
462
|
+
preferredVariant
|
|
463
|
+
]);
|
|
464
|
+
const companionId = selectedCompanion?.id;
|
|
465
|
+
const { variant } = parseEntryId(companionId ?? "");
|
|
466
|
+
return {
|
|
467
|
+
selectedCompanion,
|
|
468
|
+
companionId,
|
|
469
|
+
variant
|
|
470
|
+
};
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
// src/components/SimpleLayout/Main.tsx
|
|
474
|
+
import React9, { useMemo as useMemo6 } from "react";
|
|
475
|
+
import { Surface as Surface4, useAppGraph as useAppGraph7 } from "@dxos/app-framework/react";
|
|
476
|
+
import { useNode as useNode2 } from "@dxos/plugin-graph";
|
|
477
|
+
import { Main as NaturalMain2, useSidebars } from "@dxos/react-ui";
|
|
478
|
+
import { mx as mx5 } from "@dxos/ui-theme";
|
|
479
|
+
|
|
336
480
|
// src/components/SimpleLayout/Banner.tsx
|
|
337
|
-
import
|
|
481
|
+
import React7, { Fragment, useCallback as useCallback5, useMemo as useMemo5 } from "react";
|
|
338
482
|
import { Common as Common2 } from "@dxos/app-framework";
|
|
339
|
-
import { useAppGraph as
|
|
340
|
-
import { Graph as Graph2, Node as Node2 } from "@dxos/plugin-graph";
|
|
341
|
-
import { IconButton, Toolbar as
|
|
483
|
+
import { useAppGraph as useAppGraph5, useOperationInvoker as useOperationInvoker2 } from "@dxos/app-framework/react";
|
|
484
|
+
import { Graph as Graph2, Node as Node2, useActionRunner, useActions } from "@dxos/plugin-graph";
|
|
485
|
+
import { IconButton as IconButton2, Popover as Popover2, Toolbar as Toolbar3, toLocalizedString as toLocalizedString4, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
486
|
+
import { DropdownMenu, MenuProvider } from "@dxos/react-ui-menu";
|
|
342
487
|
import { mx as mx3, osTranslations } from "@dxos/ui-theme";
|
|
343
488
|
var isWorkspaceOrCollectionChild = (graph, itemId) => {
|
|
344
489
|
const parents = Graph2.getConnections(graph, itemId, "inbound");
|
|
345
490
|
return parents.some((node) => node.properties.disposition === "workspace" || node.properties.disposition === "collection");
|
|
346
491
|
};
|
|
347
492
|
var Banner = ({ node, classNames }) => {
|
|
348
|
-
const { t } =
|
|
493
|
+
const { t } = useTranslation5(meta.id);
|
|
349
494
|
const { state } = useSimpleLayoutState();
|
|
350
495
|
const { invokePromise } = useOperationInvoker2();
|
|
351
|
-
const { graph } =
|
|
352
|
-
const
|
|
496
|
+
const { graph } = useAppGraph5();
|
|
497
|
+
const runAction = useActionRunner();
|
|
498
|
+
const label = (node && toLocalizedString4(node.properties.label, t)) ?? t("current app name", {
|
|
353
499
|
ns: osTranslations
|
|
354
500
|
});
|
|
355
|
-
const
|
|
501
|
+
const allActions = useActions(graph, node?.id);
|
|
502
|
+
const actions = useMemo5(() => {
|
|
503
|
+
return allActions.filter((a) => [
|
|
504
|
+
"list-item",
|
|
505
|
+
"list-item-primary",
|
|
506
|
+
"heading-list-item"
|
|
507
|
+
].includes(a.properties.disposition));
|
|
508
|
+
}, [
|
|
509
|
+
allActions
|
|
510
|
+
]);
|
|
511
|
+
const isTopLevelItem = useMemo5(() => {
|
|
356
512
|
if (!state.active) {
|
|
357
513
|
return false;
|
|
358
514
|
}
|
|
@@ -361,7 +517,7 @@ var Banner = ({ node, classNames }) => {
|
|
|
361
517
|
graph,
|
|
362
518
|
state.active
|
|
363
519
|
]);
|
|
364
|
-
const handleClick =
|
|
520
|
+
const handleClick = useCallback5(async () => {
|
|
365
521
|
if (state.active) {
|
|
366
522
|
if (state.history.length === 0 && isTopLevelItem) {
|
|
367
523
|
await invokePromise(Common2.LayoutOperation.SwitchWorkspace, {
|
|
@@ -385,78 +541,102 @@ var Banner = ({ node, classNames }) => {
|
|
|
385
541
|
state.history.length,
|
|
386
542
|
isTopLevelItem
|
|
387
543
|
]);
|
|
544
|
+
const AnchorRoot = node && state.popoverAnchorId === `dxos.org/ui/${meta.id}/${node.id}` ? Popover2.Anchor : Fragment;
|
|
388
545
|
if (!node) {
|
|
389
546
|
return null;
|
|
390
547
|
}
|
|
391
|
-
return /* @__PURE__ */
|
|
548
|
+
return /* @__PURE__ */ React7.createElement(Toolbar3.Root, {
|
|
392
549
|
role: "banner",
|
|
393
550
|
classNames: mx3("grid grid-cols-[var(--rail-size)_1fr_var(--rail-size)]", classNames)
|
|
394
|
-
}, node.id !== Node2.RootId ? /* @__PURE__ */
|
|
551
|
+
}, node.id !== Node2.RootId ? /* @__PURE__ */ React7.createElement(IconButton2, {
|
|
395
552
|
iconOnly: true,
|
|
396
553
|
variant: "ghost",
|
|
397
554
|
icon: "ph--caret-left--regular",
|
|
398
555
|
label: t("back label"),
|
|
399
556
|
onClick: handleClick
|
|
400
|
-
}) : /* @__PURE__ */
|
|
557
|
+
}) : /* @__PURE__ */ React7.createElement("div", null), /* @__PURE__ */ React7.createElement("h1", {
|
|
401
558
|
className: "grow text-center truncate font-medium"
|
|
402
|
-
}, label), /* @__PURE__ */
|
|
559
|
+
}, label), actions.length > 0 ? /* @__PURE__ */ React7.createElement(AnchorRoot, null, /* @__PURE__ */ React7.createElement(MenuProvider, {
|
|
560
|
+
onAction: runAction
|
|
561
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
|
|
562
|
+
items: actions,
|
|
563
|
+
caller: meta.id
|
|
564
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
565
|
+
asChild: true
|
|
566
|
+
}, /* @__PURE__ */ React7.createElement(IconButton2, {
|
|
403
567
|
iconOnly: true,
|
|
404
568
|
variant: "ghost",
|
|
405
569
|
icon: "ph--dots-three-vertical--regular",
|
|
406
|
-
label: t("menu label")
|
|
407
|
-
}));
|
|
570
|
+
label: t("actions menu label")
|
|
571
|
+
}))))) : /* @__PURE__ */ React7.createElement("span", null));
|
|
408
572
|
};
|
|
409
573
|
|
|
410
574
|
// src/components/SimpleLayout/NavBar.tsx
|
|
411
|
-
import
|
|
412
|
-
import {
|
|
413
|
-
import {
|
|
414
|
-
import {
|
|
415
|
-
import {
|
|
575
|
+
import React8 from "react";
|
|
576
|
+
import { Common as Common3 } from "@dxos/app-framework";
|
|
577
|
+
import { useAppGraph as useAppGraph6, useOperationInvoker as useOperationInvoker3 } from "@dxos/app-framework/react";
|
|
578
|
+
import { Node as Node3, useActionRunner as useActionRunner2, useConnections as useConnections3 } from "@dxos/plugin-graph";
|
|
579
|
+
import { IconButton as IconButton3, Toolbar as Toolbar4, Tooltip, toLocalizedString as toLocalizedString5, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
580
|
+
import { DropdownMenu as DropdownMenu2, MenuProvider as MenuProvider2 } from "@dxos/react-ui-menu";
|
|
416
581
|
import { mx as mx4 } from "@dxos/ui-theme";
|
|
417
|
-
var
|
|
418
|
-
|
|
419
|
-
const {
|
|
420
|
-
const
|
|
421
|
-
const
|
|
582
|
+
var NAVBAR_NAME = "SimpleLayout.NavBar";
|
|
583
|
+
var NavBar = ({ classNames, activeId }) => {
|
|
584
|
+
const { t } = useTranslation6(meta.id);
|
|
585
|
+
const { graph } = useAppGraph6();
|
|
586
|
+
const runAction = useActionRunner2();
|
|
587
|
+
const { invokePromise } = useOperationInvoker3();
|
|
588
|
+
const connections = useConnections3(graph, Node3.RootId);
|
|
422
589
|
const menuActions = connections.filter((node) => node.properties.disposition === "menu");
|
|
423
|
-
const
|
|
424
|
-
return /* @__PURE__ */
|
|
590
|
+
const companions = useCompanions(activeId);
|
|
591
|
+
return /* @__PURE__ */ React8.createElement(Toolbar4.Root, {
|
|
425
592
|
classNames: mx4("justify-center", classNames)
|
|
426
|
-
}, /* @__PURE__ */
|
|
593
|
+
}, companions.map((companion) => /* @__PURE__ */ React8.createElement(Toolbar4.IconButton, {
|
|
594
|
+
key: companion.id,
|
|
595
|
+
icon: companion.properties.icon ?? "ph--placeholder--regular",
|
|
596
|
+
iconOnly: true,
|
|
597
|
+
label: toLocalizedString5(companion.properties.label, t),
|
|
598
|
+
onClick: () => {
|
|
599
|
+
void invokePromise(Common3.LayoutOperation.Open, {
|
|
600
|
+
subject: [
|
|
601
|
+
companion.id
|
|
602
|
+
]
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
})), /* @__PURE__ */ React8.createElement(Toolbar4.Separator, {
|
|
606
|
+
variant: "gap"
|
|
607
|
+
}), /* @__PURE__ */ React8.createElement(MenuProvider2, {
|
|
427
608
|
onAction: runAction
|
|
428
|
-
}, /* @__PURE__ */
|
|
609
|
+
}, /* @__PURE__ */ React8.createElement(DropdownMenu2.Root, {
|
|
429
610
|
items: menuActions
|
|
430
|
-
}, /* @__PURE__ */
|
|
611
|
+
}, /* @__PURE__ */ React8.createElement(Tooltip.Trigger, {
|
|
431
612
|
asChild: true,
|
|
432
613
|
content: t("app menu label")
|
|
433
|
-
}, /* @__PURE__ */
|
|
614
|
+
}, /* @__PURE__ */ React8.createElement(DropdownMenu2.Trigger, {
|
|
434
615
|
asChild: true,
|
|
435
|
-
"data-testid": "
|
|
436
|
-
}, /* @__PURE__ */
|
|
616
|
+
"data-testid": "simpleLayoutPlugin.addSpace"
|
|
617
|
+
}, /* @__PURE__ */ React8.createElement(IconButton3, {
|
|
437
618
|
icon: "ph--plus--regular",
|
|
438
619
|
iconOnly: true,
|
|
439
620
|
label: t("main menu label")
|
|
440
621
|
}))))));
|
|
441
622
|
};
|
|
623
|
+
NavBar.displayName = NAVBAR_NAME;
|
|
442
624
|
|
|
443
625
|
// src/components/SimpleLayout/Main.tsx
|
|
444
|
-
var
|
|
626
|
+
var MAIN_NAME = "SimpleLayout.Main";
|
|
445
627
|
var Main = () => {
|
|
446
628
|
const { state } = useSimpleLayoutState();
|
|
629
|
+
const { graph } = useAppGraph7();
|
|
447
630
|
const id = state.active ?? state.workspace;
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
-
const data = useMemo4(() => {
|
|
453
|
-
const { variant } = parseEntryId(id);
|
|
631
|
+
const node = useNode2(graph, id);
|
|
632
|
+
useLoadDescendents(id);
|
|
633
|
+
const placeholder = useMemo6(() => /* @__PURE__ */ React9.createElement(ContentLoading, null), []);
|
|
634
|
+
const data = useMemo6(() => {
|
|
454
635
|
return node && {
|
|
455
636
|
attendableId: id,
|
|
456
637
|
subject: node.data,
|
|
457
638
|
properties: node.properties,
|
|
458
|
-
popoverAnchorId: state.popoverAnchorId
|
|
459
|
-
variant
|
|
639
|
+
popoverAnchorId: state.popoverAnchorId
|
|
460
640
|
};
|
|
461
641
|
}, [
|
|
462
642
|
id,
|
|
@@ -465,97 +645,93 @@ var Main = () => {
|
|
|
465
645
|
node?.properties,
|
|
466
646
|
state.popoverAnchorId
|
|
467
647
|
]);
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}, {
|
|
472
|
-
F: __dxlog_file,
|
|
473
|
-
L: 48,
|
|
474
|
-
S: void 0,
|
|
475
|
-
C: (f, a) => f(...a)
|
|
476
|
-
});
|
|
477
|
-
}, []);
|
|
478
|
-
return /* @__PURE__ */ React8.createElement(Mosaic2.Root, null, /* @__PURE__ */ React8.createElement(NaturalMain.Root, {
|
|
479
|
-
complementarySidebarState: "closed",
|
|
480
|
-
navigationSidebarState: "closed"
|
|
481
|
-
}, /* @__PURE__ */ React8.createElement(NaturalMain.Content, {
|
|
648
|
+
const { drawerState } = useSidebars(MAIN_NAME);
|
|
649
|
+
const showNavBar = !state.isPopover && drawerState === "closed";
|
|
650
|
+
return /* @__PURE__ */ React9.createElement(NaturalMain2.Content, {
|
|
482
651
|
bounce: true,
|
|
483
|
-
classNames: mx5("
|
|
484
|
-
}, /* @__PURE__ */
|
|
652
|
+
classNames: mx5("bs-full", "pbs-[env(safe-area-inset-top)] pbe-[env(safe-area-inset-bottom)]")
|
|
653
|
+
}, /* @__PURE__ */ React9.createElement("div", {
|
|
654
|
+
role: "none",
|
|
655
|
+
className: mx5("grid bs-full overflow-hidden", showNavBar ? "grid-rows-[min-content_1fr_min-content]" : "grid-rows-[min-content_1fr]")
|
|
656
|
+
}, /* @__PURE__ */ React9.createElement(Banner, {
|
|
485
657
|
classNames: "border-be border-separator",
|
|
486
658
|
node
|
|
487
|
-
}), /* @__PURE__ */
|
|
488
|
-
className: "
|
|
489
|
-
}, /* @__PURE__ */
|
|
659
|
+
}), /* @__PURE__ */ React9.createElement("article", {
|
|
660
|
+
className: "bs-full overflow-hidden"
|
|
661
|
+
}, /* @__PURE__ */ React9.createElement(Surface4, {
|
|
490
662
|
key: id,
|
|
491
663
|
role: "article",
|
|
492
664
|
data,
|
|
493
665
|
limit: 1,
|
|
494
666
|
fallback: ContentError,
|
|
495
667
|
placeholder
|
|
496
|
-
})), showNavBar && /* @__PURE__ */
|
|
668
|
+
})), showNavBar && /* @__PURE__ */ React9.createElement(NavBar, {
|
|
497
669
|
classNames: "border-bs border-separator",
|
|
498
|
-
activeId: id
|
|
499
|
-
|
|
500
|
-
}))));
|
|
501
|
-
};
|
|
502
|
-
var parseEntryId = (entryId) => {
|
|
503
|
-
const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR);
|
|
504
|
-
return {
|
|
505
|
-
id,
|
|
506
|
-
variant
|
|
507
|
-
};
|
|
670
|
+
activeId: id
|
|
671
|
+
})));
|
|
508
672
|
};
|
|
509
|
-
Main.displayName =
|
|
673
|
+
Main.displayName = MAIN_NAME;
|
|
510
674
|
|
|
511
675
|
// src/components/SimpleLayout/SimpleLayout.tsx
|
|
512
676
|
var SimpleLayout = () => {
|
|
513
|
-
|
|
677
|
+
const { state, updateState } = useSimpleLayoutState();
|
|
678
|
+
const handleDrawerStateChange = useCallback6((nextState) => {
|
|
679
|
+
updateState((s) => ({
|
|
680
|
+
...s,
|
|
681
|
+
drawerState: nextState
|
|
682
|
+
}));
|
|
683
|
+
}, [
|
|
684
|
+
updateState
|
|
685
|
+
]);
|
|
686
|
+
return /* @__PURE__ */ React10.createElement(Mosaic2.Root, null, /* @__PURE__ */ React10.createElement(NaturalMain3.Root, {
|
|
687
|
+
drawerState: state.drawerState ?? "closed",
|
|
688
|
+
onDrawerStateChange: handleDrawerStateChange
|
|
689
|
+
}, /* @__PURE__ */ React10.createElement(PopoverRoot, null, /* @__PURE__ */ React10.createElement(Main, null), /* @__PURE__ */ React10.createElement(Drawer, null), /* @__PURE__ */ React10.createElement(Dialog, null), /* @__PURE__ */ React10.createElement(PopoverContent, null))));
|
|
514
690
|
};
|
|
515
691
|
|
|
516
692
|
// src/components/Workspace/Workspace.tsx
|
|
517
|
-
import
|
|
518
|
-
import { Common as
|
|
519
|
-
import { useAppGraph as
|
|
520
|
-
import { useConnections as
|
|
521
|
-
import { Avatar as Avatar2, Icon as Icon2, Toolbar as
|
|
693
|
+
import React11, { useCallback as useCallback7, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
694
|
+
import { Common as Common4 } from "@dxos/app-framework";
|
|
695
|
+
import { useAppGraph as useAppGraph8, useOperationInvoker as useOperationInvoker4 } from "@dxos/app-framework/react";
|
|
696
|
+
import { useConnections as useConnections4 } from "@dxos/plugin-graph";
|
|
697
|
+
import { Avatar as Avatar2, Icon as Icon2, Toolbar as Toolbar5, toLocalizedString as toLocalizedString6, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
522
698
|
import { Card as Card3, Layout as Layout2, Mosaic as Mosaic3 } from "@dxos/react-ui-mosaic";
|
|
523
699
|
import { SearchList as SearchList2, useSearchListItem as useSearchListItem2, useSearchListResults as useSearchListResults2 } from "@dxos/react-ui-searchlist";
|
|
524
700
|
import { mx as mx6 } from "@dxos/ui-theme";
|
|
525
701
|
var Workspace = ({ id }) => {
|
|
526
|
-
const { t } =
|
|
527
|
-
const { graph } =
|
|
702
|
+
const { t } = useTranslation7(meta.id);
|
|
703
|
+
const { graph } = useAppGraph8();
|
|
528
704
|
useLoadDescendents(id);
|
|
529
|
-
const children =
|
|
705
|
+
const children = useConnections4(graph, id, "outbound");
|
|
530
706
|
const { results, handleSearch } = useSearchListResults2({
|
|
531
707
|
items: children,
|
|
532
|
-
extract: (child) =>
|
|
708
|
+
extract: (child) => toLocalizedString6(child.properties.label, t)
|
|
533
709
|
});
|
|
534
|
-
return /* @__PURE__ */
|
|
710
|
+
return /* @__PURE__ */ React11.createElement(Layout2.Main, {
|
|
535
711
|
toolbar: true
|
|
536
|
-
}, /* @__PURE__ */
|
|
712
|
+
}, /* @__PURE__ */ React11.createElement(SearchList2.Root, {
|
|
537
713
|
onSearch: handleSearch
|
|
538
|
-
}, /* @__PURE__ */
|
|
714
|
+
}, /* @__PURE__ */ React11.createElement(Toolbar5.Root, null, /* @__PURE__ */ React11.createElement(SearchList2.Input, {
|
|
539
715
|
placeholder: t("search placeholder"),
|
|
540
716
|
autoFocus: true
|
|
541
|
-
})), /* @__PURE__ */
|
|
717
|
+
})), /* @__PURE__ */ React11.createElement(SearchList2.Content, null, /* @__PURE__ */ React11.createElement(Mosaic3.Container, {
|
|
542
718
|
asChild: true
|
|
543
|
-
}, /* @__PURE__ */
|
|
719
|
+
}, /* @__PURE__ */ React11.createElement(Mosaic3.Viewport, {
|
|
544
720
|
padding: true
|
|
545
|
-
}, /* @__PURE__ */
|
|
721
|
+
}, /* @__PURE__ */ React11.createElement(Mosaic3.Stack, {
|
|
546
722
|
items: results,
|
|
547
723
|
getId: (child) => child.id,
|
|
548
724
|
Tile: WorkspaceChildTile
|
|
549
725
|
}))))));
|
|
550
726
|
};
|
|
551
727
|
var WorkspaceChildTile = ({ data }) => {
|
|
552
|
-
const { t } =
|
|
553
|
-
const { invokeSync } =
|
|
728
|
+
const { t } = useTranslation7(meta.id);
|
|
729
|
+
const { invokeSync } = useOperationInvoker4();
|
|
554
730
|
const ref = useRef3(null);
|
|
555
731
|
const { selectedValue, registerItem, unregisterItem } = useSearchListItem2();
|
|
556
732
|
const isSelected = selectedValue === data.id;
|
|
557
|
-
const name =
|
|
558
|
-
const handleSelect =
|
|
733
|
+
const name = toLocalizedString6(data.properties.label, t);
|
|
734
|
+
const handleSelect = useCallback7(() => invokeSync(Common4.LayoutOperation.Open, {
|
|
559
735
|
subject: [
|
|
560
736
|
data.id
|
|
561
737
|
]
|
|
@@ -584,7 +760,7 @@ var WorkspaceChildTile = ({ data }) => {
|
|
|
584
760
|
}, [
|
|
585
761
|
isSelected
|
|
586
762
|
]);
|
|
587
|
-
return /* @__PURE__ */
|
|
763
|
+
return /* @__PURE__ */ React11.createElement(Card3.Root, {
|
|
588
764
|
ref,
|
|
589
765
|
role: "button",
|
|
590
766
|
fullWidth: true,
|
|
@@ -592,16 +768,16 @@ var WorkspaceChildTile = ({ data }) => {
|
|
|
592
768
|
"data-selected": isSelected,
|
|
593
769
|
classNames: mx6("dx-focus-ring", isSelected && "bg-hoverOverlay"),
|
|
594
770
|
onClick: handleSelect
|
|
595
|
-
}, /* @__PURE__ */
|
|
771
|
+
}, /* @__PURE__ */ React11.createElement(Card3.Toolbar, {
|
|
596
772
|
density: "coarse"
|
|
597
|
-
}, /* @__PURE__ */
|
|
773
|
+
}, /* @__PURE__ */ React11.createElement(Avatar2.Root, null, /* @__PURE__ */ React11.createElement(Avatar2.Content, {
|
|
598
774
|
hue: data.properties.hue,
|
|
599
775
|
icon: data.properties.icon,
|
|
600
776
|
hueVariant: "transparent",
|
|
601
777
|
variant: "square",
|
|
602
778
|
size: 12,
|
|
603
779
|
fallback: name
|
|
604
|
-
}), /* @__PURE__ */
|
|
780
|
+
}), /* @__PURE__ */ React11.createElement(Avatar2.Label, null, name), /* @__PURE__ */ React11.createElement(Icon2, {
|
|
605
781
|
icon: "ph--caret-right--regular"
|
|
606
782
|
}))));
|
|
607
783
|
};
|
|
@@ -611,4 +787,4 @@ export {
|
|
|
611
787
|
SimpleLayout,
|
|
612
788
|
Workspace
|
|
613
789
|
};
|
|
614
|
-
//# sourceMappingURL=chunk-
|
|
790
|
+
//# sourceMappingURL=chunk-HB2B3LLG.mjs.map
|