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