@dxos/plugin-simple-layout 0.8.4-main.c85a9c8dae → 0.8.4-main.dfabb4ec29
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/neutral/SimpleLayoutPlugin.mjs +52 -0
- package/dist/lib/neutral/SimpleLayoutPlugin.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-EYQKLRRP.mjs +21 -0
- package/dist/lib/neutral/app-graph-builder-EYQKLRRP.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +21 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7UDV3JDT.mjs +22 -0
- package/dist/lib/neutral/chunk-7UDV3JDT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-AMTEDJHG.mjs +19 -0
- package/dist/lib/neutral/chunk-AMTEDJHG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FD2CAY4Q.mjs +26 -0
- package/dist/lib/neutral/chunk-FD2CAY4Q.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XVUAQHKU.mjs +8 -0
- package/dist/lib/neutral/chunk-XVUAQHKU.mjs.map +7 -0
- package/dist/lib/neutral/close-WKMURGUB.mjs +35 -0
- package/dist/lib/neutral/close-WKMURGUB.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +924 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +332 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +14 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/open-XI2T7D5O.mjs +49 -0
- package/dist/lib/neutral/open-XI2T7D5O.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-EAIE7KPR.mjs +13 -0
- package/dist/lib/neutral/operation-handler-EAIE7KPR.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/{browser/react-root-MMB575WY.mjs → neutral/react-root-VE265VX4.mjs} +5 -8
- package/dist/lib/neutral/react-root-VE265VX4.mjs.map +7 -0
- package/dist/lib/{node-esm/react-surface-ITVNQYLG.mjs → neutral/react-surface-REZMYKQV.mjs} +20 -16
- package/dist/lib/neutral/react-surface-REZMYKQV.mjs.map +7 -0
- package/dist/lib/neutral/revert-workspace-ST6NZUNG.mjs +22 -0
- package/dist/lib/neutral/revert-workspace-ST6NZUNG.mjs.map +7 -0
- package/dist/lib/neutral/set-6ZRLWPJS.mjs +22 -0
- package/dist/lib/neutral/set-6ZRLWPJS.mjs.map +7 -0
- package/dist/lib/neutral/set-layout-mode-L22HRCKS.mjs +13 -0
- package/dist/lib/neutral/set-layout-mode-L22HRCKS.mjs.map +7 -0
- package/dist/lib/{browser/spotlight-dismiss-67PHYS5B.mjs → neutral/spotlight-dismiss-EIYW5E7M.mjs} +7 -15
- package/dist/lib/{node-esm/spotlight-dismiss-RMLRZUVY.mjs.map → neutral/spotlight-dismiss-EIYW5E7M.mjs.map} +3 -3
- package/dist/lib/{browser/state-A3PGDWWZ.mjs → neutral/state-7NXKBLPY.mjs} +5 -6
- package/dist/lib/neutral/state-7NXKBLPY.mjs.map +7 -0
- package/dist/lib/neutral/switch-workspace-PYWPTMFO.mjs +25 -0
- package/dist/lib/neutral/switch-workspace-PYWPTMFO.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +36 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/neutral/update-complementary-HKWF5OXT.mjs +33 -0
- package/dist/lib/neutral/update-complementary-HKWF5OXT.mjs.map +7 -0
- package/dist/lib/neutral/update-dialog-P4ASXCE7.mjs +30 -0
- package/dist/lib/neutral/update-dialog-P4ASXCE7.mjs.map +7 -0
- package/dist/lib/neutral/update-popover-REAKC2GN.mjs +34 -0
- package/dist/lib/neutral/update-popover-REAKC2GN.mjs.map +7 -0
- package/dist/lib/neutral/update-sidebar-O5SQPR6Q.mjs +12 -0
- package/dist/lib/neutral/update-sidebar-O5SQPR6Q.mjs.map +7 -0
- package/dist/lib/neutral/url-handler-GZXUUAHD.mjs +129 -0
- package/dist/lib/neutral/url-handler-GZXUUAHD.mjs.map +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts +2 -1
- package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +21 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/{spotlight-dismiss/spotlight-dismiss.d.ts → spotlight-dismiss.d.ts} +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss.d.ts.map +1 -0
- package/dist/types/src/capabilities/{state/state.d.ts → state.d.ts} +3 -3
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/{url-handler/url-handler.d.ts → url-handler.d.ts} +3 -3
- package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
- package/dist/types/src/components/ContentError.stories.d.ts +26 -19
- package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
- package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts +19 -0
- package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts.map +1 -0
- package/dist/types/src/components/DebugOverlay/index.d.ts +2 -0
- package/dist/types/src/components/DebugOverlay/index.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Home/Home.d.ts.map +1 -1
- package/dist/types/src/components/Loading/Loading.d.ts +3 -0
- package/dist/types/src/components/Loading/Loading.d.ts.map +1 -0
- package/dist/types/src/components/{ContentLoading.stories.d.ts → Loading/Loading.stories.d.ts} +1 -1
- package/dist/types/src/components/Loading/Loading.stories.d.ts.map +1 -0
- package/dist/types/src/components/Loading/index.d.ts +2 -0
- package/dist/types/src/components/Loading/index.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts +2 -2
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -1
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavBranch/NavBranch.d.ts +11 -0
- package/dist/types/src/components/NavBranch/NavBranch.d.ts.map +1 -0
- package/dist/types/src/components/NavBranch/index.d.ts +2 -0
- package/dist/types/src/components/NavBranch/index.d.ts.map +1 -0
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts +5 -7
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +29 -22
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts +4 -7
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Main.d.ts +4 -7
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +5 -7
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +29 -23
- 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 +26 -25
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/hooks.d.ts +4 -2
- package/dist/types/src/components/hooks.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/actions.d.ts +5 -6
- package/dist/types/src/hooks/actions.d.ts.map +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts +2 -2
- package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -1
- package/dist/types/src/hooks/useCompanions.d.ts.map +1 -1
- package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts +3 -3
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/close.d.ts +5 -0
- package/dist/types/src/operations/close.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open.d.ts +5 -0
- package/dist/types/src/operations/open.d.ts.map +1 -0
- package/dist/types/src/operations/revert-workspace.d.ts +5 -0
- package/dist/types/src/operations/revert-workspace.d.ts.map +1 -0
- package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
- package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
- package/dist/types/src/operations/set.d.ts +5 -0
- package/dist/types/src/operations/set.d.ts.map +1 -0
- package/dist/types/src/operations/state-access.d.ts +8 -0
- package/dist/types/src/operations/state-access.d.ts.map +1 -0
- package/dist/types/src/operations/switch-workspace.d.ts +5 -0
- package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
- package/dist/types/src/operations/update-complementary.d.ts +5 -0
- package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
- package/dist/types/src/operations/update-dialog.d.ts +5 -0
- package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
- package/dist/types/src/operations/update-popover.d.ts +5 -0
- package/dist/types/src/operations/update-popover.d.ts.map +1 -0
- package/dist/types/src/operations/update-sidebar.d.ts +5 -0
- package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +26 -20
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/{capabilities.d.ts → SimpleLayoutCapabilities.d.ts} +12 -10
- package/dist/types/src/types/SimpleLayoutCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/SimpleLayoutEvents.d.ts +4 -0
- package/dist/types/src/types/SimpleLayoutEvents.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +87 -33
- package/src/SimpleLayoutPlugin.ts +18 -7
- package/src/capabilities/app-graph-builder.ts +21 -0
- package/src/capabilities/index.ts +13 -6
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/capabilities/{react-root/react-root.tsx → react-root.tsx} +2 -2
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +17 -8
- package/src/capabilities/{state/state.tsx → state.tsx} +5 -6
- package/src/capabilities/url-handler.ts +164 -0
- package/src/components/ContentError.stories.tsx +1 -1
- package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
- package/src/components/DebugOverlay/index.ts +5 -0
- package/src/components/Dialog/Dialog.tsx +14 -3
- package/src/components/Home/Home.tsx +32 -32
- package/src/components/{ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +4 -4
- package/src/components/{ContentLoading.tsx → Loading/Loading.tsx} +2 -2
- package/src/components/Loading/index.ts +5 -0
- package/src/components/MobileLayout/MobileLayout.stories.tsx +21 -17
- package/src/components/MobileLayout/MobileLayout.tsx +118 -51
- package/src/components/{Workspace/Workspace.tsx → NavBranch/NavBranch.tsx} +40 -41
- package/src/components/{Workspace → NavBranch}/index.ts +1 -1
- package/src/components/Popover/Popover.tsx +10 -16
- package/src/components/SimpleLayout/AppBar.stories.tsx +10 -10
- package/src/components/SimpleLayout/AppBar.tsx +60 -60
- package/src/components/SimpleLayout/Drawer.tsx +30 -31
- package/src/components/SimpleLayout/Main.tsx +21 -26
- package/src/components/SimpleLayout/NavBar.stories.tsx +2 -2
- package/src/components/SimpleLayout/NavBar.tsx +8 -9
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +46 -69
- package/src/components/SimpleLayout/SimpleLayout.tsx +33 -34
- package/src/components/hooks.ts +8 -8
- package/src/components/index.ts +3 -2
- package/src/hooks/actions.ts +18 -17
- package/src/hooks/useAppBarProps.ts +10 -31
- package/src/hooks/useDrawerActions.ts +14 -12
- package/src/hooks/useNavbarActions.ts +9 -8
- package/src/hooks/useSimpleLayoutState.ts +7 -5
- package/src/index.ts +2 -1
- package/src/meta.ts +2 -1
- package/src/operations/close.ts +34 -0
- package/src/operations/index.ts +16 -0
- package/src/operations/open.ts +63 -0
- package/src/operations/revert-workspace.ts +22 -0
- package/src/operations/set-layout-mode.ts +12 -0
- package/src/operations/set.ts +23 -0
- package/src/operations/state-access.ts +21 -0
- package/src/operations/switch-workspace.ts +26 -0
- package/src/operations/update-complementary.ts +35 -0
- package/src/operations/update-dialog.ts +28 -0
- package/src/operations/update-popover.ts +35 -0
- package/src/operations/update-sidebar.ts +12 -0
- package/src/plugin.ts +11 -0
- package/src/translations.ts +21 -19
- package/src/types/{capabilities.ts → SimpleLayoutCapabilities.ts} +6 -18
- package/src/types/SimpleLayoutEvents.ts +15 -0
- package/src/types/index.ts +2 -2
- package/dist/lib/browser/chunk-7VLT3S46.mjs +0 -29
- package/dist/lib/browser/chunk-7VLT3S46.mjs.map +0 -7
- package/dist/lib/browser/chunk-TMZNLVT2.mjs +0 -1170
- package/dist/lib/browser/chunk-TMZNLVT2.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -101
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs +0 -205
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs.map +0 -7
- package/dist/lib/browser/react-root-MMB575WY.mjs.map +0 -7
- package/dist/lib/browser/react-surface-M6CURANW.mjs +0 -41
- package/dist/lib/browser/react-surface-M6CURANW.mjs.map +0 -7
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs.map +0 -7
- package/dist/lib/browser/state-A3PGDWWZ.mjs.map +0 -7
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs +0 -152
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-FLOYBAHE.mjs +0 -1171
- package/dist/lib/node-esm/chunk-FLOYBAHE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs +0 -31
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -102
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs +0 -206
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-ENZKVSY4.mjs +0 -22
- package/dist/lib/node-esm/react-root-ENZKVSY4.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-ITVNQYLG.mjs.map +0 -7
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs +0 -68
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs +0 -49
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs +0 -153
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs.map +0 -7
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-root/index.d.ts +0 -6
- package/dist/types/src/capabilities/react-root/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-root/react-root.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +0 -3
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/index.d.ts +0 -13
- package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
- package/dist/types/src/capabilities/url-handler/index.d.ts +0 -3
- package/dist/types/src/capabilities/url-handler/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading.d.ts +0 -3
- package/dist/types/src/components/ContentLoading.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading.stories.d.ts.map +0 -1
- package/dist/types/src/components/Workspace/Workspace.d.ts +0 -11
- package/dist/types/src/components/Workspace/Workspace.d.ts.map +0 -1
- package/dist/types/src/components/Workspace/index.d.ts +0 -2
- package/dist/types/src/components/Workspace/index.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/dist/types/src/types/events.d.ts +0 -6
- package/dist/types/src/types/events.d.ts.map +0 -1
- package/src/capabilities/operation-resolver/index.ts +0 -10
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -217
- package/src/capabilities/react-root/index.ts +0 -7
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/spotlight-dismiss/index.ts +0 -7
- package/src/capabilities/state/index.ts +0 -9
- package/src/capabilities/url-handler/index.ts +0 -7
- package/src/capabilities/url-handler/url-handler.ts +0 -157
- package/src/types/events.ts +0 -15
- /package/dist/types/src/capabilities/{react-root/react-root.d.ts → react-root.d.ts} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
- /package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +0 -0
|
@@ -0,0 +1,924 @@
|
|
|
1
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/components/DebugOverlay/DebugOverlay.tsx
|
|
4
|
+
import { createContext } from "@radix-ui/react-context";
|
|
5
|
+
import React, { useCallback, useRef } from "react";
|
|
6
|
+
var DEBUG_OVERLAY_NAME = "DebugOverlay";
|
|
7
|
+
var [DebugOverlayProvider, useDebugLog] = createContext(DEBUG_OVERLAY_NAME, {
|
|
8
|
+
dbg: () => {
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var DebugOverlayRoot = ({ children, enabled = true, maxLines = 10 }) => {
|
|
12
|
+
const overlayRef = useRef(null);
|
|
13
|
+
const dbg = useCallback((msg) => {
|
|
14
|
+
if (!overlayRef.current) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const line = document.createElement("pre");
|
|
18
|
+
line.textContent = `${(performance.now() / 1e3).toFixed(2).padStart(8, " ")} ${msg}`;
|
|
19
|
+
overlayRef.current.prepend(line);
|
|
20
|
+
while (overlayRef.current.children.length > maxLines) {
|
|
21
|
+
overlayRef.current.lastChild?.remove();
|
|
22
|
+
}
|
|
23
|
+
}, []);
|
|
24
|
+
return /* @__PURE__ */ React.createElement(DebugOverlayProvider, {
|
|
25
|
+
dbg
|
|
26
|
+
}, children, enabled && /* @__PURE__ */ React.createElement("div", {
|
|
27
|
+
ref: overlayRef,
|
|
28
|
+
style: {
|
|
29
|
+
position: "fixed",
|
|
30
|
+
bottom: "calc(var(--kb-height, 0px) + 8px)",
|
|
31
|
+
left: 8,
|
|
32
|
+
right: 8,
|
|
33
|
+
background: "rgba(0,0,0,0.8)",
|
|
34
|
+
color: "#0f0",
|
|
35
|
+
fontSize: 10,
|
|
36
|
+
fontFamily: "monospace",
|
|
37
|
+
padding: 6,
|
|
38
|
+
borderRadius: 4,
|
|
39
|
+
zIndex: 9999,
|
|
40
|
+
pointerEvents: "none"
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
var DebugOverlay = {
|
|
45
|
+
Root: DebugOverlayRoot
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/components/Home/Home.tsx
|
|
49
|
+
import React2, { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef2 } from "react";
|
|
50
|
+
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
51
|
+
import { LayoutOperation } from "@dxos/app-toolkit";
|
|
52
|
+
import { useAppGraph as useAppGraph2 } from "@dxos/app-toolkit/ui";
|
|
53
|
+
import { Node, useConnections } from "@dxos/plugin-graph";
|
|
54
|
+
import { Avatar, Icon, ScrollArea, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
55
|
+
import { Card } from "@dxos/react-ui";
|
|
56
|
+
import { Mosaic } from "@dxos/react-ui-mosaic";
|
|
57
|
+
import { SearchPanel, useSearchListItem, useSearchListResults } from "@dxos/react-ui-search";
|
|
58
|
+
import { mx } from "@dxos/ui-theme";
|
|
59
|
+
import { byPosition, getHostPlatform, isTauri } from "@dxos/util";
|
|
60
|
+
import { meta } from "#meta";
|
|
61
|
+
|
|
62
|
+
// src/components/hooks.ts
|
|
63
|
+
import { useEffect } from "react";
|
|
64
|
+
import { useAppGraph } from "@dxos/app-toolkit/ui";
|
|
65
|
+
import { Graph } from "@dxos/plugin-graph";
|
|
66
|
+
import { expandAttendableId } from "@dxos/react-ui-attention";
|
|
67
|
+
var useExpandPath = (nodeId) => {
|
|
68
|
+
const { graph } = useAppGraph();
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (nodeId) {
|
|
71
|
+
for (const prefix of expandAttendableId(nodeId)) {
|
|
72
|
+
Graph.expand(graph, prefix, "child");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, [
|
|
76
|
+
nodeId,
|
|
77
|
+
graph
|
|
78
|
+
]);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/components/Home/Home.tsx
|
|
82
|
+
var Home = (_) => {
|
|
83
|
+
const { t } = useTranslation(meta.id);
|
|
84
|
+
const userAccountItem = useItemsByDisposition("user-account")[0];
|
|
85
|
+
const pinnedItems = useItemsByDisposition("pin-end", true);
|
|
86
|
+
const workspaceItems = useItemsByDisposition("workspace");
|
|
87
|
+
useExpandPath(Node.RootId);
|
|
88
|
+
const items = useMemo(() => [
|
|
89
|
+
...userAccountItem ? [
|
|
90
|
+
userAccountItem
|
|
91
|
+
] : [],
|
|
92
|
+
...pinnedItems,
|
|
93
|
+
...workspaceItems
|
|
94
|
+
], [
|
|
95
|
+
userAccountItem,
|
|
96
|
+
pinnedItems,
|
|
97
|
+
workspaceItems
|
|
98
|
+
]);
|
|
99
|
+
const { results, handleSearch } = useSearchListResults({
|
|
100
|
+
items,
|
|
101
|
+
extract: (node) => toLocalizedString(node.properties.label, t)
|
|
102
|
+
});
|
|
103
|
+
const autoFocus = !isTauri() || getHostPlatform() !== "ios";
|
|
104
|
+
return /* @__PURE__ */ React2.createElement(SearchPanel, {
|
|
105
|
+
onSearch: handleSearch
|
|
106
|
+
}, /* @__PURE__ */ React2.createElement(Mosaic.Container, {
|
|
107
|
+
asChild: true
|
|
108
|
+
}, /* @__PURE__ */ React2.createElement(ScrollArea.Root, {
|
|
109
|
+
centered: true,
|
|
110
|
+
padding: true,
|
|
111
|
+
thin: true
|
|
112
|
+
}, /* @__PURE__ */ React2.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React2.createElement(Mosaic.Stack, {
|
|
113
|
+
classNames: "gap-1",
|
|
114
|
+
draggable: false,
|
|
115
|
+
items: results,
|
|
116
|
+
getId: (item) => item.id,
|
|
117
|
+
Tile: WorkspaceTile
|
|
118
|
+
})))));
|
|
119
|
+
};
|
|
120
|
+
var WorkspaceTile = (props) => {
|
|
121
|
+
const data = props.data;
|
|
122
|
+
const { t } = useTranslation(meta.id);
|
|
123
|
+
const { invokePromise } = useOperationInvoker();
|
|
124
|
+
const { selectedValue, registerItem, unregisterItem } = useSearchListItem();
|
|
125
|
+
const name = toLocalizedString(data.properties.label, t);
|
|
126
|
+
const isSelected = selectedValue === data.id;
|
|
127
|
+
const cardRef = useRef2(null);
|
|
128
|
+
useExpandPath(data.id);
|
|
129
|
+
const handleSelect = useCallback2(() => invokePromise(LayoutOperation.SwitchWorkspace, {
|
|
130
|
+
subject: data.id
|
|
131
|
+
}), [
|
|
132
|
+
invokePromise,
|
|
133
|
+
data.id
|
|
134
|
+
]);
|
|
135
|
+
useEffect2(() => {
|
|
136
|
+
if (cardRef.current) {
|
|
137
|
+
registerItem(data.id, cardRef.current, handleSelect);
|
|
138
|
+
}
|
|
139
|
+
return () => unregisterItem(data.id);
|
|
140
|
+
}, [
|
|
141
|
+
data.id,
|
|
142
|
+
handleSelect,
|
|
143
|
+
registerItem,
|
|
144
|
+
unregisterItem
|
|
145
|
+
]);
|
|
146
|
+
useEffect2(() => {
|
|
147
|
+
if (isSelected && cardRef.current) {
|
|
148
|
+
cardRef.current.scrollIntoView({
|
|
149
|
+
block: "nearest",
|
|
150
|
+
behavior: "smooth"
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}, [
|
|
154
|
+
isSelected
|
|
155
|
+
]);
|
|
156
|
+
return /* @__PURE__ */ React2.createElement(Card.Root, {
|
|
157
|
+
role: "button",
|
|
158
|
+
fullWidth: true,
|
|
159
|
+
tabIndex: -1,
|
|
160
|
+
"data-selected": isSelected,
|
|
161
|
+
classNames: mx("dx-focus-ring", isSelected && "bg-hover-overlay"),
|
|
162
|
+
onClick: handleSelect,
|
|
163
|
+
ref: cardRef
|
|
164
|
+
}, /* @__PURE__ */ React2.createElement(Card.Toolbar, {
|
|
165
|
+
density: "fine"
|
|
166
|
+
}, /* @__PURE__ */ React2.createElement(Avatar.Root, null, /* @__PURE__ */ React2.createElement(Avatar.Content, {
|
|
167
|
+
icon: data.properties.icon,
|
|
168
|
+
hue: data.properties.hue,
|
|
169
|
+
hueVariant: "transparent",
|
|
170
|
+
variant: "square",
|
|
171
|
+
size: 8,
|
|
172
|
+
fallback: name
|
|
173
|
+
}), /* @__PURE__ */ React2.createElement(Avatar.Label, {
|
|
174
|
+
classNames: "cursor-pointer"
|
|
175
|
+
}, name), /* @__PURE__ */ React2.createElement(Icon, {
|
|
176
|
+
icon: "ph--caret-right--regular"
|
|
177
|
+
}))));
|
|
178
|
+
};
|
|
179
|
+
var filterItems = (node, disposition) => {
|
|
180
|
+
return node.properties.disposition === disposition;
|
|
181
|
+
};
|
|
182
|
+
var useItemsByDisposition = (disposition, sort = false) => {
|
|
183
|
+
const { graph } = useAppGraph2();
|
|
184
|
+
const connections = useConnections(graph, Node.RootId, "child");
|
|
185
|
+
return useMemo(() => {
|
|
186
|
+
const filtered = connections.filter((node) => filterItems(node, disposition));
|
|
187
|
+
return sort ? filtered.toSorted((a, b) => byPosition(a.properties, b.properties)) : filtered;
|
|
188
|
+
}, [
|
|
189
|
+
connections,
|
|
190
|
+
disposition,
|
|
191
|
+
sort
|
|
192
|
+
]);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// src/components/Loading/Loading.tsx
|
|
196
|
+
import React3 from "react";
|
|
197
|
+
var Loading = () => {
|
|
198
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
199
|
+
className: "grid place-items-center dx-attention-surface"
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// src/components/MobileLayout/MobileLayout.tsx
|
|
204
|
+
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
205
|
+
import React4, { forwardRef, useEffect as useEffect3, useLayoutEffect, useState } from "react";
|
|
206
|
+
import { addEventListener, combine } from "@dxos/async";
|
|
207
|
+
import { log } from "@dxos/log";
|
|
208
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
209
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-simple-layout/src/components/MobileLayout/MobileLayout.tsx";
|
|
210
|
+
var MOBILE_LAYOUT_NAME = "MobileLayout";
|
|
211
|
+
var MOBILE_LAYOUT_ROOT_NAME = "MobileLayout.Root";
|
|
212
|
+
var MOBILE_LAYOUT_PANEL_NAME = "MobileLayout.Panel";
|
|
213
|
+
var [MobileLayoutProvider, useMobileLayout] = createContext2(MOBILE_LAYOUT_NAME);
|
|
214
|
+
var MobileLayoutRoot = /* @__PURE__ */ forwardRef(({ classNames, children, transition = 500, onKeyboardOpenChange, ...props }, forwardedRef) => {
|
|
215
|
+
const { open: keyboardOpen } = useIOSKeyboard();
|
|
216
|
+
useLockBodyScroll(keyboardOpen);
|
|
217
|
+
useAutoScroll();
|
|
218
|
+
useLayoutEffect(() => onKeyboardOpenChange?.(keyboardOpen), [
|
|
219
|
+
keyboardOpen,
|
|
220
|
+
onKeyboardOpenChange
|
|
221
|
+
]);
|
|
222
|
+
return /* @__PURE__ */ React4.createElement(MobileLayoutProvider, {
|
|
223
|
+
keyboardOpen
|
|
224
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
225
|
+
...props,
|
|
226
|
+
style: {
|
|
227
|
+
height: "calc(100vh - var(--kb-height, 0px))",
|
|
228
|
+
transition: `height ${keyboardOpen ? 0 : transition}ms ease-out`
|
|
229
|
+
},
|
|
230
|
+
className: mx2("fixed top-0 left-0 right-0 grid overflow-hidden", classNames),
|
|
231
|
+
ref: forwardedRef
|
|
232
|
+
}, children));
|
|
233
|
+
});
|
|
234
|
+
MobileLayoutRoot.displayName = MOBILE_LAYOUT_ROOT_NAME;
|
|
235
|
+
var MobileLayoutPanel = /* @__PURE__ */ forwardRef(({ classNames, children, safe, ...props }, forwardedRef) => {
|
|
236
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
237
|
+
...props,
|
|
238
|
+
style: {
|
|
239
|
+
paddingTop: safe?.top ? "env(safe-area-inset-top)" : void 0,
|
|
240
|
+
paddingBottom: safe?.bottom ? `calc((1 - var(--kb-open, 0)) * env(safe-area-inset-bottom))` : void 0
|
|
241
|
+
},
|
|
242
|
+
className: mx2(classNames),
|
|
243
|
+
ref: forwardedRef
|
|
244
|
+
}, children);
|
|
245
|
+
});
|
|
246
|
+
MobileLayoutPanel.displayName = MOBILE_LAYOUT_PANEL_NAME;
|
|
247
|
+
var MobileLayout = {
|
|
248
|
+
Root: MobileLayoutRoot,
|
|
249
|
+
Panel: MobileLayoutPanel
|
|
250
|
+
};
|
|
251
|
+
var useAutoScroll = () => {
|
|
252
|
+
const { dbg } = useDebugLog("useAutoScroll");
|
|
253
|
+
useEffect3(() => {
|
|
254
|
+
const resetScroll = () => {
|
|
255
|
+
if (window.scrollX !== 0 || window.scrollY !== 0) {
|
|
256
|
+
window.scrollTo(0, 0);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const detectContainerScroll = (event) => {
|
|
260
|
+
const el = event.target;
|
|
261
|
+
if (el === document.documentElement || el === document.body) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
dbg(`scroll: ${el.tagName}.${Array.from(el.classList).slice(0, 2).join(".")} top=${el.scrollTop.toFixed(0)}`);
|
|
265
|
+
};
|
|
266
|
+
return combine(
|
|
267
|
+
addEventListener(window, "scroll", resetScroll),
|
|
268
|
+
window.visualViewport ? addEventListener(window.visualViewport, "scroll", resetScroll) : () => {
|
|
269
|
+
},
|
|
270
|
+
// TODO(burdon): Remove debug logging.
|
|
271
|
+
addEventListener(document, "scroll", detectContainerScroll, {
|
|
272
|
+
capture: true
|
|
273
|
+
}),
|
|
274
|
+
// Prevent focus-triggered scroll-into-view on inputs.
|
|
275
|
+
(() => {
|
|
276
|
+
let focusingWithPreventScroll = false;
|
|
277
|
+
return addEventListener(document, "focus", (event) => {
|
|
278
|
+
if (focusingWithPreventScroll) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const target = event.target;
|
|
282
|
+
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) {
|
|
283
|
+
focusingWithPreventScroll = true;
|
|
284
|
+
target.focus({
|
|
285
|
+
preventScroll: true
|
|
286
|
+
});
|
|
287
|
+
focusingWithPreventScroll = false;
|
|
288
|
+
}
|
|
289
|
+
}, {
|
|
290
|
+
capture: true
|
|
291
|
+
});
|
|
292
|
+
})()
|
|
293
|
+
);
|
|
294
|
+
}, [
|
|
295
|
+
dbg
|
|
296
|
+
]);
|
|
297
|
+
};
|
|
298
|
+
var useLockBodyScroll = (enabled) => {
|
|
299
|
+
useEffect3(() => {
|
|
300
|
+
if (!enabled) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const isScrollable = (el, axis) => {
|
|
304
|
+
while (el && el !== document.body) {
|
|
305
|
+
const style = getComputedStyle(el);
|
|
306
|
+
if (axis === "y") {
|
|
307
|
+
const overflow = style.overflowY;
|
|
308
|
+
if ((overflow === "auto" || overflow === "scroll") && el.scrollHeight > el.clientHeight) {
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
const overflow = style.overflowX;
|
|
313
|
+
if ((overflow === "auto" || overflow === "scroll") && el.scrollWidth > el.clientWidth) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
el = el.parentElement;
|
|
318
|
+
}
|
|
319
|
+
return false;
|
|
320
|
+
};
|
|
321
|
+
let touchStartX = 0;
|
|
322
|
+
let touchStartY = 0;
|
|
323
|
+
return combine(
|
|
324
|
+
// Record initial touch position.
|
|
325
|
+
addEventListener(document, "touchstart", (event) => {
|
|
326
|
+
const touch = event.touches[0];
|
|
327
|
+
touchStartX = touch.clientX;
|
|
328
|
+
touchStartY = touch.clientY;
|
|
329
|
+
}, {
|
|
330
|
+
passive: true
|
|
331
|
+
}),
|
|
332
|
+
// Prevent scrolling the viewport.
|
|
333
|
+
addEventListener(document, "touchmove", (event) => {
|
|
334
|
+
const touch = event.touches[0];
|
|
335
|
+
const dx = Math.abs(touch.clientX - touchStartX);
|
|
336
|
+
const dy = Math.abs(touch.clientY - touchStartY);
|
|
337
|
+
if (!isScrollable(event.target, dx > dy ? "x" : "y")) {
|
|
338
|
+
event.preventDefault();
|
|
339
|
+
}
|
|
340
|
+
}, {
|
|
341
|
+
passive: false
|
|
342
|
+
})
|
|
343
|
+
);
|
|
344
|
+
}, [
|
|
345
|
+
enabled
|
|
346
|
+
]);
|
|
347
|
+
};
|
|
348
|
+
var useIOSKeyboard = () => {
|
|
349
|
+
const { dbg } = useDebugLog("useIOSKeyboard");
|
|
350
|
+
const [open, setOpen] = useState(false);
|
|
351
|
+
const [height, setHeight] = useState(0);
|
|
352
|
+
const [duration, setDuration] = useState(void 0);
|
|
353
|
+
useEffect3(() => {
|
|
354
|
+
const viewport = window.visualViewport;
|
|
355
|
+
if (!viewport) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const initialHeight = viewport.height ?? window.innerHeight;
|
|
359
|
+
const updateState = (keyboardHeight, keyboardOpen, animationDuration) => {
|
|
360
|
+
setOpen(keyboardOpen);
|
|
361
|
+
setHeight(keyboardHeight);
|
|
362
|
+
setDuration(animationDuration);
|
|
363
|
+
const vvh = initialHeight - keyboardHeight;
|
|
364
|
+
document.documentElement.style.setProperty("--vvh", `${vvh}px`);
|
|
365
|
+
document.documentElement.style.setProperty("--kb-height", `${keyboardHeight}px`);
|
|
366
|
+
document.documentElement.style.setProperty("--kb-open", keyboardOpen ? "1" : "0");
|
|
367
|
+
log.info("viewport size", {
|
|
368
|
+
initialHeight,
|
|
369
|
+
vvh,
|
|
370
|
+
keyboardHeight,
|
|
371
|
+
keyboardOpen,
|
|
372
|
+
animationDuration
|
|
373
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 211, S: void 0 });
|
|
374
|
+
};
|
|
375
|
+
let rafId;
|
|
376
|
+
return combine(
|
|
377
|
+
// Handler for native iOS keyboard events (from KeyboardObserver.swift).
|
|
378
|
+
addEventListener(window, "keyboard", (event) => {
|
|
379
|
+
const { type, height: height2, duration: duration2 } = event.detail;
|
|
380
|
+
const durationMs = duration2 < 1 ? duration2 * 1e3 : duration2;
|
|
381
|
+
const vp = window.visualViewport;
|
|
382
|
+
dbg(`kb:${type} h=${height2} dur=${duration2} scrollY=${window.scrollY} vpOffset=${vp?.offsetTop?.toFixed(0) ?? "?"}`);
|
|
383
|
+
log.info("keyboard event", {
|
|
384
|
+
type,
|
|
385
|
+
height: height2,
|
|
386
|
+
duration: duration2
|
|
387
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 228, S: void 0 });
|
|
388
|
+
updateState(height2, type === "show", durationMs);
|
|
389
|
+
const end = performance.now() + durationMs + 300;
|
|
390
|
+
let prevOffsetTop = vp?.offsetTop ?? 0;
|
|
391
|
+
let prevScrollY = window.scrollY;
|
|
392
|
+
const monitorFrame = () => {
|
|
393
|
+
const offsetTop = vp?.offsetTop ?? 0;
|
|
394
|
+
const scrollY = window.scrollY;
|
|
395
|
+
if (offsetTop !== prevOffsetTop || scrollY !== prevScrollY) {
|
|
396
|
+
dbg(`\u0394 vpOffset=${offsetTop.toFixed(0)} scrollY=${scrollY.toFixed(0)}`);
|
|
397
|
+
prevOffsetTop = offsetTop;
|
|
398
|
+
prevScrollY = scrollY;
|
|
399
|
+
}
|
|
400
|
+
if (scrollY !== 0) {
|
|
401
|
+
window.scrollTo(0, 0);
|
|
402
|
+
}
|
|
403
|
+
if (performance.now() < end) {
|
|
404
|
+
rafId = requestAnimationFrame(monitorFrame);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
rafId = requestAnimationFrame(monitorFrame);
|
|
408
|
+
}),
|
|
409
|
+
() => {
|
|
410
|
+
if (rafId !== void 0) {
|
|
411
|
+
cancelAnimationFrame(rafId);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
}, [
|
|
416
|
+
dbg
|
|
417
|
+
]);
|
|
418
|
+
return {
|
|
419
|
+
open,
|
|
420
|
+
height,
|
|
421
|
+
duration
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
// src/components/Popover/Popover.tsx
|
|
426
|
+
import { createContext as createContext3 } from "@radix-ui/react-context";
|
|
427
|
+
import React5, { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef3, useState as useState2 } from "react";
|
|
428
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
429
|
+
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
430
|
+
import { Popover, toLocalizedString as toLocalizedString2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
431
|
+
import { Card as Card2 } from "@dxos/react-ui";
|
|
432
|
+
import { useSimpleLayoutState } from "#hooks";
|
|
433
|
+
import { meta as meta2 } from "#meta";
|
|
434
|
+
var DEBOUNCE_DELAY = 40;
|
|
435
|
+
var [LayoutPopoverProvider, useLayoutPopoverContext] = createContext3("LayoutPopover");
|
|
436
|
+
var PopoverRoot = ({ children }) => {
|
|
437
|
+
const { state } = useSimpleLayoutState();
|
|
438
|
+
const [open, setOpen] = useState2(false);
|
|
439
|
+
const virtualRef = useRef3(null);
|
|
440
|
+
const [virtualIter, setVirtualIter] = useState2(0);
|
|
441
|
+
const debounceRef = useRef3(null);
|
|
442
|
+
useEffect4(() => {
|
|
443
|
+
setOpen(false);
|
|
444
|
+
if (state.popoverOpen) {
|
|
445
|
+
if (debounceRef.current) {
|
|
446
|
+
clearTimeout(debounceRef.current);
|
|
447
|
+
}
|
|
448
|
+
if (state.popoverAnchor && virtualRef.current !== state.popoverAnchor) {
|
|
449
|
+
virtualRef.current = state.popoverAnchor ?? null;
|
|
450
|
+
setVirtualIter((iter) => iter + 1);
|
|
451
|
+
}
|
|
452
|
+
debounceRef.current = setTimeout(() => setOpen(true), DEBOUNCE_DELAY);
|
|
453
|
+
}
|
|
454
|
+
}, [
|
|
455
|
+
state.popoverOpen,
|
|
456
|
+
state.popoverAnchorId,
|
|
457
|
+
state.popoverAnchor,
|
|
458
|
+
state.popoverContent
|
|
459
|
+
]);
|
|
460
|
+
return /* @__PURE__ */ React5.createElement(LayoutPopoverProvider, {
|
|
461
|
+
setOpen
|
|
462
|
+
}, /* @__PURE__ */ React5.createElement(Popover.Root, {
|
|
463
|
+
modal: false,
|
|
464
|
+
open
|
|
465
|
+
}, state.popoverAnchor && /* @__PURE__ */ React5.createElement(Popover.VirtualTrigger, {
|
|
466
|
+
key: virtualIter,
|
|
467
|
+
virtualRef
|
|
468
|
+
}), children));
|
|
469
|
+
};
|
|
470
|
+
var PopoverContent = () => {
|
|
471
|
+
const { t } = useTranslation2(meta2.id);
|
|
472
|
+
const { state, updateState } = useSimpleLayoutState();
|
|
473
|
+
const { setOpen } = useLayoutPopoverContext("PopoverContent");
|
|
474
|
+
const handleClose = useCallback3(() => {
|
|
475
|
+
setOpen(false);
|
|
476
|
+
updateState((s) => ({
|
|
477
|
+
...s,
|
|
478
|
+
popoverOpen: false,
|
|
479
|
+
popoverAnchor: void 0,
|
|
480
|
+
popoverAnchorId: void 0,
|
|
481
|
+
popoverSide: void 0
|
|
482
|
+
}));
|
|
483
|
+
}, [
|
|
484
|
+
setOpen,
|
|
485
|
+
updateState
|
|
486
|
+
]);
|
|
487
|
+
const handleInteractOutside = useCallback3((event) => {
|
|
488
|
+
if (
|
|
489
|
+
// TODO(thure): CodeMirror should not focus itself when it updates.
|
|
490
|
+
event.type === "dismissableLayer.focusOutside" && event.currentTarget?.classList.contains("cm-content")
|
|
491
|
+
) {
|
|
492
|
+
event.preventDefault();
|
|
493
|
+
} else {
|
|
494
|
+
handleClose();
|
|
495
|
+
}
|
|
496
|
+
}, [
|
|
497
|
+
handleClose
|
|
498
|
+
]);
|
|
499
|
+
const collisionBoundaries = useMemo2(() => {
|
|
500
|
+
const closest = state.popoverAnchor?.closest("[data-popover-collision-boundary]");
|
|
501
|
+
return closest ? [
|
|
502
|
+
closest
|
|
503
|
+
] : [];
|
|
504
|
+
}, [
|
|
505
|
+
state.popoverAnchor
|
|
506
|
+
]);
|
|
507
|
+
return /* @__PURE__ */ React5.createElement(Popover.Portal, null, /* @__PURE__ */ React5.createElement(Popover.Content, {
|
|
508
|
+
side: state.popoverSide,
|
|
509
|
+
sticky: "always",
|
|
510
|
+
hideWhenDetached: true,
|
|
511
|
+
collisionBoundary: collisionBoundaries,
|
|
512
|
+
onInteractOutside: handleInteractOutside,
|
|
513
|
+
onEscapeKeyDown: handleInteractOutside
|
|
514
|
+
}, /* @__PURE__ */ React5.createElement(Popover.Viewport, null, state.popoverKind === "base" && state.popoverContent && "component" in state.popoverContent && /* @__PURE__ */ React5.createElement(Surface.Surface, {
|
|
515
|
+
type: AppSurface.Popover,
|
|
516
|
+
data: state.popoverContent,
|
|
517
|
+
limit: 1
|
|
518
|
+
}), state.popoverKind === "card" && /* @__PURE__ */ React5.createElement(Card2.Root, {
|
|
519
|
+
border: false,
|
|
520
|
+
classNames: "dx-card-popover"
|
|
521
|
+
}, /* @__PURE__ */ React5.createElement(Card2.Toolbar, null, /* @__PURE__ */ React5.createElement("span", null), state.popoverTitle ? /* @__PURE__ */ React5.createElement(Card2.Title, null, toLocalizedString2(state.popoverTitle, t)) : /* @__PURE__ */ React5.createElement("span", null), /* @__PURE__ */ React5.createElement(Card2.CloseIconButton, {
|
|
522
|
+
onClick: handleClose
|
|
523
|
+
})), state.popoverContent && "subject" in state.popoverContent && /* @__PURE__ */ React5.createElement(Surface.Surface, {
|
|
524
|
+
type: AppSurface.Card,
|
|
525
|
+
data: state.popoverContent,
|
|
526
|
+
limit: 1
|
|
527
|
+
}))), /* @__PURE__ */ React5.createElement(Popover.Arrow, null)));
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
// src/components/SimpleLayout/AppBar.tsx
|
|
531
|
+
import { useAtomValue } from "@effect-atom/atom-react";
|
|
532
|
+
import React6, { Fragment } from "react";
|
|
533
|
+
import { IconButton, Popover as Popover2, Toolbar, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
534
|
+
import { Menu, useMenuActions } from "@dxos/react-ui-menu";
|
|
535
|
+
import { composable, composableProps, osTranslations } from "@dxos/ui-theme";
|
|
536
|
+
import { meta as meta3 } from "#meta";
|
|
537
|
+
var APP_BAR_NAME = "SimpleLayout.AppBar";
|
|
538
|
+
var AppBar = composable(({ classNames, title, actions, showBackButton, popoverAnchorId, onAction, onBack, ...props }, forwardedRef) => {
|
|
539
|
+
const { t } = useTranslation3(meta3.id);
|
|
540
|
+
const menuActions = useMenuActions(actions);
|
|
541
|
+
const actionsValue = useAtomValue(actions);
|
|
542
|
+
const hasActions = actionsValue.nodes.length > 0;
|
|
543
|
+
const { keyboardOpen } = useMobileLayout(APP_BAR_NAME);
|
|
544
|
+
const displayTitle = title ?? t("current-app.name", {
|
|
545
|
+
ns: osTranslations
|
|
546
|
+
});
|
|
547
|
+
const AnchorRoot = popoverAnchorId ? Popover2.Anchor : Fragment;
|
|
548
|
+
return /* @__PURE__ */ React6.createElement(Toolbar.Root, {
|
|
549
|
+
...composableProps(props, {
|
|
550
|
+
role: "banner",
|
|
551
|
+
classNames: "grid grid-cols-[var(--dx-rail-size)_1fr_var(--dx-rail-size)] items-center dx-density-fine"
|
|
552
|
+
}),
|
|
553
|
+
ref: forwardedRef
|
|
554
|
+
}, keyboardOpen ? /* @__PURE__ */ React6.createElement(IconButton, {
|
|
555
|
+
variant: "ghost",
|
|
556
|
+
icon: "ph--x--regular",
|
|
557
|
+
iconOnly: true,
|
|
558
|
+
label: t("done.label")
|
|
559
|
+
}) : showBackButton ? /* @__PURE__ */ React6.createElement(IconButton, {
|
|
560
|
+
variant: "ghost",
|
|
561
|
+
icon: "ph--caret-left--regular",
|
|
562
|
+
iconOnly: true,
|
|
563
|
+
label: t("back.label"),
|
|
564
|
+
onClick: onBack
|
|
565
|
+
}) : /* @__PURE__ */ React6.createElement("div", null), /* @__PURE__ */ React6.createElement("h1", {
|
|
566
|
+
className: "text-center truncate font-thin uppercase"
|
|
567
|
+
}, displayTitle), hasActions ? /* @__PURE__ */ React6.createElement(AnchorRoot, null, /* @__PURE__ */ React6.createElement(Menu.Root, {
|
|
568
|
+
...menuActions,
|
|
569
|
+
caller: meta3.id,
|
|
570
|
+
onAction
|
|
571
|
+
}, /* @__PURE__ */ React6.createElement(Menu.Trigger, {
|
|
572
|
+
asChild: true
|
|
573
|
+
}, /* @__PURE__ */ React6.createElement(IconButton, {
|
|
574
|
+
variant: "ghost",
|
|
575
|
+
icon: "ph--dots-three-vertical--regular",
|
|
576
|
+
iconOnly: true,
|
|
577
|
+
label: t("actions-menu.label")
|
|
578
|
+
})), /* @__PURE__ */ React6.createElement(Menu.Content, null))) : /* @__PURE__ */ React6.createElement("span", null));
|
|
579
|
+
});
|
|
580
|
+
AppBar.displayName = APP_BAR_NAME;
|
|
581
|
+
|
|
582
|
+
// src/components/SimpleLayout/Main.tsx
|
|
583
|
+
import React8, { useMemo as useMemo3 } from "react";
|
|
584
|
+
import { Surface as Surface2 } from "@dxos/app-framework/ui";
|
|
585
|
+
import { AppSurface as AppSurface2, useAppGraph as useAppGraph3 } from "@dxos/app-toolkit/ui";
|
|
586
|
+
import { useNode } from "@dxos/plugin-graph";
|
|
587
|
+
import { ErrorFallback, Panel } from "@dxos/react-ui";
|
|
588
|
+
import { useAttentionAttributes } from "@dxos/react-ui-attention";
|
|
589
|
+
import { useAppBarProps, useNavbarActions, useSimpleLayoutState as useSimpleLayoutState2 } from "#hooks";
|
|
590
|
+
|
|
591
|
+
// src/components/SimpleLayout/NavBar.tsx
|
|
592
|
+
import React7 from "react";
|
|
593
|
+
import { Menu as Menu2, useMenuActions as useMenuActions2 } from "@dxos/react-ui-menu";
|
|
594
|
+
import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
|
|
595
|
+
var NAVBAR_NAME = "SimpleLayout.NavBar";
|
|
596
|
+
var NavBar = composable2(({ actions, onAction, ...props }, forwardedRef) => {
|
|
597
|
+
const menuActions = useMenuActions2(actions);
|
|
598
|
+
return /* @__PURE__ */ React7.createElement(Menu2.Root, {
|
|
599
|
+
...menuActions,
|
|
600
|
+
alwaysActive: true,
|
|
601
|
+
onAction
|
|
602
|
+
}, /* @__PURE__ */ React7.createElement(Menu2.Toolbar, {
|
|
603
|
+
...composableProps2(props),
|
|
604
|
+
ref: forwardedRef
|
|
605
|
+
}));
|
|
606
|
+
});
|
|
607
|
+
NavBar.displayName = NAVBAR_NAME;
|
|
608
|
+
|
|
609
|
+
// src/components/SimpleLayout/Main.tsx
|
|
610
|
+
var MAIN_NAME = "SimpleLayout.Main";
|
|
611
|
+
var Main = () => {
|
|
612
|
+
const { state } = useSimpleLayoutState2();
|
|
613
|
+
const id = state.active ?? state.workspace;
|
|
614
|
+
const attentionAttrs = useAttentionAttributes(id);
|
|
615
|
+
const { keyboardOpen } = useMobileLayout(MAIN_NAME);
|
|
616
|
+
const { actions, onAction } = useNavbarActions();
|
|
617
|
+
const appBarProps = useAppBarProps();
|
|
618
|
+
const placeholder = useMemo3(() => /* @__PURE__ */ React8.createElement(Loading, null), []);
|
|
619
|
+
const { graph } = useAppGraph3();
|
|
620
|
+
const node = useNode(graph, id);
|
|
621
|
+
const data = useMemo3(() => {
|
|
622
|
+
return node && {
|
|
623
|
+
attendableId: id,
|
|
624
|
+
subject: node.data,
|
|
625
|
+
properties: node.properties,
|
|
626
|
+
popoverAnchorId: state.popoverAnchorId
|
|
627
|
+
};
|
|
628
|
+
}, [
|
|
629
|
+
id,
|
|
630
|
+
node,
|
|
631
|
+
node?.data,
|
|
632
|
+
node?.properties,
|
|
633
|
+
state.popoverAnchorId
|
|
634
|
+
]);
|
|
635
|
+
useExpandPath(id);
|
|
636
|
+
const showNavBar = !keyboardOpen && !state.isPopover && state.drawerState === "closed";
|
|
637
|
+
return /* @__PURE__ */ React8.createElement(Panel.Root, {
|
|
638
|
+
...attentionAttrs,
|
|
639
|
+
className: "dx-document"
|
|
640
|
+
}, /* @__PURE__ */ React8.createElement(Panel.Toolbar, {
|
|
641
|
+
asChild: true
|
|
642
|
+
}, /* @__PURE__ */ React8.createElement(AppBar, appBarProps)), /* @__PURE__ */ React8.createElement(Panel.Content, {
|
|
643
|
+
role: "article",
|
|
644
|
+
className: "bg-base-surface"
|
|
645
|
+
}, /* @__PURE__ */ React8.createElement(Surface2.Surface, {
|
|
646
|
+
key: id,
|
|
647
|
+
type: AppSurface2.Article,
|
|
648
|
+
data,
|
|
649
|
+
limit: 1,
|
|
650
|
+
fallback: ErrorFallback,
|
|
651
|
+
placeholder
|
|
652
|
+
})), showNavBar && /* @__PURE__ */ React8.createElement(Panel.Statusbar, {
|
|
653
|
+
asChild: true
|
|
654
|
+
}, /* @__PURE__ */ React8.createElement(NavBar, {
|
|
655
|
+
actions,
|
|
656
|
+
onAction
|
|
657
|
+
})));
|
|
658
|
+
};
|
|
659
|
+
Main.displayName = MAIN_NAME;
|
|
660
|
+
|
|
661
|
+
// src/components/SimpleLayout/SimpleLayout.tsx
|
|
662
|
+
import React11, { useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState3 } from "react";
|
|
663
|
+
import { Splitter } from "@dxos/react-ui";
|
|
664
|
+
import { Mosaic as Mosaic2 } from "@dxos/react-ui-mosaic";
|
|
665
|
+
import { useSimpleLayoutState as useSimpleLayoutState5 } from "#hooks";
|
|
666
|
+
|
|
667
|
+
// src/components/Dialog/Dialog.tsx
|
|
668
|
+
import React9 from "react";
|
|
669
|
+
import { Surface as Surface3 } from "@dxos/app-framework/ui";
|
|
670
|
+
import { AppSurface as AppSurface3 } from "@dxos/app-toolkit/ui";
|
|
671
|
+
import { AlertDialog, Dialog as NaturalDialog } from "@dxos/react-ui";
|
|
672
|
+
import { ErrorFallback as ErrorFallback2 } from "@dxos/react-ui";
|
|
673
|
+
import { useSimpleLayoutState as useSimpleLayoutState3 } from "#hooks";
|
|
674
|
+
var Dialog = () => {
|
|
675
|
+
const { state, updateState } = useSimpleLayoutState3();
|
|
676
|
+
const DialogRoot = state.dialogType === "alert" ? AlertDialog.Root : NaturalDialog.Root;
|
|
677
|
+
const DialogOverlay = state.dialogType === "alert" ? AlertDialog.Overlay : NaturalDialog.Overlay;
|
|
678
|
+
return /* @__PURE__ */ React9.createElement(DialogRoot, {
|
|
679
|
+
modal: state.dialogBlockAlign !== "end",
|
|
680
|
+
open: state.dialogOpen,
|
|
681
|
+
onOpenChange: (nextOpen) => updateState((state2) => ({
|
|
682
|
+
...state2,
|
|
683
|
+
dialogOpen: nextOpen
|
|
684
|
+
}))
|
|
685
|
+
}, state.dialogBlockAlign === "end" ? /* @__PURE__ */ React9.createElement(Surface3.Surface, {
|
|
686
|
+
type: AppSurface3.Dialog,
|
|
687
|
+
data: state.dialogContent ?? void 0,
|
|
688
|
+
limit: 1,
|
|
689
|
+
fallback: ErrorFallback2
|
|
690
|
+
}) : /* @__PURE__ */ React9.createElement(DialogOverlay, {
|
|
691
|
+
blockAlign: state.dialogBlockAlign,
|
|
692
|
+
classNames: state.dialogOverlayClasses,
|
|
693
|
+
style: state.dialogOverlayStyle
|
|
694
|
+
}, /* @__PURE__ */ React9.createElement(Surface3.Surface, {
|
|
695
|
+
type: AppSurface3.Dialog,
|
|
696
|
+
data: state.dialogContent ?? void 0,
|
|
697
|
+
limit: 1,
|
|
698
|
+
fallback: ErrorFallback2
|
|
699
|
+
})));
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
// src/components/SimpleLayout/Drawer.tsx
|
|
703
|
+
import React10, { useMemo as useMemo4 } from "react";
|
|
704
|
+
import { Surface as Surface4 } from "@dxos/app-framework/ui";
|
|
705
|
+
import { AppSurface as AppSurface4, useAppGraph as useAppGraph4 } from "@dxos/app-toolkit/ui";
|
|
706
|
+
import { useNode as useNode2 } from "@dxos/plugin-graph";
|
|
707
|
+
import { ErrorFallback as ErrorFallback3, Panel as Panel2 } from "@dxos/react-ui";
|
|
708
|
+
import { getLinkedVariant } from "@dxos/react-ui-attention";
|
|
709
|
+
import { Menu as Menu3, useMenuActions as useMenuActions3 } from "@dxos/react-ui-menu";
|
|
710
|
+
import { useCompanions, useDrawerActions, useSimpleLayoutState as useSimpleLayoutState4 } from "#hooks";
|
|
711
|
+
var DRAWER_NAME = "SimpleLayout.Drawer";
|
|
712
|
+
var Drawer = () => {
|
|
713
|
+
const { graph } = useAppGraph4();
|
|
714
|
+
const { state: layoutState } = useSimpleLayoutState4();
|
|
715
|
+
const placeholder = useMemo4(() => /* @__PURE__ */ React10.createElement(Loading, null), []);
|
|
716
|
+
const activeId = layoutState.active ?? layoutState.workspace;
|
|
717
|
+
const companions = useCompanions(activeId);
|
|
718
|
+
const { companionId, variant } = useSelectedCompanion(companions, layoutState.companionVariant);
|
|
719
|
+
const node = useNode2(graph, companionId);
|
|
720
|
+
const parentNode = useNode2(graph, activeId);
|
|
721
|
+
const data = useMemo4(() => {
|
|
722
|
+
if (!node || !companionId) {
|
|
723
|
+
return void 0;
|
|
724
|
+
}
|
|
725
|
+
return {
|
|
726
|
+
attendableId: companionId,
|
|
727
|
+
subject: node.data,
|
|
728
|
+
companionTo: parentNode?.data,
|
|
729
|
+
properties: node.properties,
|
|
730
|
+
variant
|
|
731
|
+
};
|
|
732
|
+
}, [
|
|
733
|
+
companionId,
|
|
734
|
+
node,
|
|
735
|
+
parentNode,
|
|
736
|
+
variant
|
|
737
|
+
]);
|
|
738
|
+
const { actions, onAction } = useDrawerActions(DRAWER_NAME);
|
|
739
|
+
const menuActions = useMenuActions3(actions);
|
|
740
|
+
return /* @__PURE__ */ React10.createElement(Panel2.Root, null, /* @__PURE__ */ React10.createElement(Panel2.Toolbar, null, /* @__PURE__ */ React10.createElement(Menu3.Root, {
|
|
741
|
+
...menuActions,
|
|
742
|
+
alwaysActive: true,
|
|
743
|
+
onAction
|
|
744
|
+
}, /* @__PURE__ */ React10.createElement(Menu3.Toolbar, null))), /* @__PURE__ */ React10.createElement(Panel2.Content, null, /* @__PURE__ */ React10.createElement(Surface4.Surface, {
|
|
745
|
+
type: AppSurface4.Article,
|
|
746
|
+
data,
|
|
747
|
+
limit: 1,
|
|
748
|
+
fallback: ErrorFallback3,
|
|
749
|
+
placeholder
|
|
750
|
+
})));
|
|
751
|
+
};
|
|
752
|
+
Drawer.displayName = DRAWER_NAME;
|
|
753
|
+
var useSelectedCompanion = (companions, preferredVariant) => {
|
|
754
|
+
const selectedCompanion = useMemo4(() => {
|
|
755
|
+
if (companions.length === 0) {
|
|
756
|
+
return void 0;
|
|
757
|
+
}
|
|
758
|
+
if (preferredVariant) {
|
|
759
|
+
const preferred = companions.find((c) => getLinkedVariant(c.id) === preferredVariant);
|
|
760
|
+
if (preferred) {
|
|
761
|
+
return preferred;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return companions[0];
|
|
765
|
+
}, [
|
|
766
|
+
companions,
|
|
767
|
+
preferredVariant
|
|
768
|
+
]);
|
|
769
|
+
const companionId = selectedCompanion?.id;
|
|
770
|
+
const variant = companionId ? getLinkedVariant(companionId) : void 0;
|
|
771
|
+
return {
|
|
772
|
+
selectedCompanion,
|
|
773
|
+
companionId,
|
|
774
|
+
variant
|
|
775
|
+
};
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
// src/components/SimpleLayout/SimpleLayout.tsx
|
|
779
|
+
var SimpleLayout = () => {
|
|
780
|
+
const { state } = useSimpleLayoutState5();
|
|
781
|
+
const [keyboardOpen, setKeyboardOpen] = useState3(false);
|
|
782
|
+
const [splitterMode, setSplitterMode] = useState3("top");
|
|
783
|
+
const drawerRef = useRef4(null);
|
|
784
|
+
useLayoutEffect2(() => {
|
|
785
|
+
if (!keyboardOpen) {
|
|
786
|
+
setSplitterMode(state.drawerState === "closed" ? "top" : state.drawerState === "open" ? "split" : "bottom");
|
|
787
|
+
}
|
|
788
|
+
}, [
|
|
789
|
+
state.drawerState,
|
|
790
|
+
keyboardOpen
|
|
791
|
+
]);
|
|
792
|
+
return /* @__PURE__ */ React11.createElement(DebugOverlay.Root, {
|
|
793
|
+
enabled: false
|
|
794
|
+
}, /* @__PURE__ */ React11.createElement(PopoverRoot, null, /* @__PURE__ */ React11.createElement(Mosaic2.Root, null, /* @__PURE__ */ React11.createElement(MobileLayout.Root, {
|
|
795
|
+
classNames: "dx-container grid relative bg-toolbar-surface",
|
|
796
|
+
onKeyboardOpenChange: (nextKeyboardOpen) => setKeyboardOpen(nextKeyboardOpen)
|
|
797
|
+
}, /* @__PURE__ */ React11.createElement(MobileLayout.Panel, {
|
|
798
|
+
safe: {
|
|
799
|
+
top: true,
|
|
800
|
+
bottom: splitterMode === "top"
|
|
801
|
+
}
|
|
802
|
+
}, /* @__PURE__ */ React11.createElement(Splitter.Root, {
|
|
803
|
+
mode: splitterMode,
|
|
804
|
+
ratio: 0.55
|
|
805
|
+
}, /* @__PURE__ */ React11.createElement(Splitter.Panel, {
|
|
806
|
+
position: "top"
|
|
807
|
+
}, /* @__PURE__ */ React11.createElement(Main, null)), /* @__PURE__ */ React11.createElement(Splitter.Panel, {
|
|
808
|
+
position: "bottom",
|
|
809
|
+
ref: drawerRef
|
|
810
|
+
}, /* @__PURE__ */ React11.createElement(Drawer, null))), /* @__PURE__ */ React11.createElement(Dialog, null), /* @__PURE__ */ React11.createElement(PopoverContent, null))))));
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
// src/components/NavBranch/NavBranch.tsx
|
|
814
|
+
import React12, { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo5, useRef as useRef5 } from "react";
|
|
815
|
+
import { useOperationInvoker as useOperationInvoker2 } from "@dxos/app-framework/ui";
|
|
816
|
+
import { LayoutOperation as LayoutOperation2 } from "@dxos/app-toolkit";
|
|
817
|
+
import { useAppGraph as useAppGraph5 } from "@dxos/app-toolkit/ui";
|
|
818
|
+
import { useConnections as useConnections2 } from "@dxos/plugin-graph";
|
|
819
|
+
import { Avatar as Avatar2, Icon as Icon2, ScrollArea as ScrollArea2, toLocalizedString as toLocalizedString3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
820
|
+
import { Card as Card3 } from "@dxos/react-ui";
|
|
821
|
+
import { Mosaic as Mosaic3 } from "@dxos/react-ui-mosaic";
|
|
822
|
+
import { SearchPanel as SearchPanel2, useSearchListItem as useSearchListItem2, useSearchListResults as useSearchListResults2 } from "@dxos/react-ui-search";
|
|
823
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
824
|
+
import { meta as meta4 } from "#meta";
|
|
825
|
+
var NavBranch = ({ id }) => {
|
|
826
|
+
const { t } = useTranslation4(meta4.id);
|
|
827
|
+
const { graph } = useAppGraph5();
|
|
828
|
+
useExpandPath(id);
|
|
829
|
+
const children = useConnections2(graph, id, "child");
|
|
830
|
+
const visibleChildren = useMemo5(() => children.filter((node) => node.properties.disposition !== "hidden"), [
|
|
831
|
+
children
|
|
832
|
+
]);
|
|
833
|
+
const { results, handleSearch } = useSearchListResults2({
|
|
834
|
+
items: visibleChildren,
|
|
835
|
+
extract: (child) => toLocalizedString3(child.properties.label, t)
|
|
836
|
+
});
|
|
837
|
+
return /* @__PURE__ */ React12.createElement(SearchPanel2, {
|
|
838
|
+
onSearch: handleSearch
|
|
839
|
+
}, /* @__PURE__ */ React12.createElement(Mosaic3.Container, {
|
|
840
|
+
asChild: true
|
|
841
|
+
}, /* @__PURE__ */ React12.createElement(ScrollArea2.Root, {
|
|
842
|
+
centered: true,
|
|
843
|
+
padding: true,
|
|
844
|
+
thin: true
|
|
845
|
+
}, /* @__PURE__ */ React12.createElement(ScrollArea2.Viewport, null, /* @__PURE__ */ React12.createElement(Mosaic3.Stack, {
|
|
846
|
+
classNames: "gap-1",
|
|
847
|
+
draggable: false,
|
|
848
|
+
items: results,
|
|
849
|
+
getId: (item) => item.id,
|
|
850
|
+
Tile: NavBranchTile
|
|
851
|
+
})))));
|
|
852
|
+
};
|
|
853
|
+
var NavBranchTile = (props) => {
|
|
854
|
+
const data = props.data;
|
|
855
|
+
const { t } = useTranslation4(meta4.id);
|
|
856
|
+
const { invokePromise } = useOperationInvoker2();
|
|
857
|
+
const ref = useRef5(null);
|
|
858
|
+
const { selectedValue, registerItem, unregisterItem } = useSearchListItem2();
|
|
859
|
+
const isSelected = selectedValue === data.id;
|
|
860
|
+
const name = toLocalizedString3(data.properties.label, t);
|
|
861
|
+
const handleSelect = useCallback4(() => void invokePromise(LayoutOperation2.Open, {
|
|
862
|
+
subject: [
|
|
863
|
+
data.id
|
|
864
|
+
]
|
|
865
|
+
}), [
|
|
866
|
+
invokePromise,
|
|
867
|
+
data.id
|
|
868
|
+
]);
|
|
869
|
+
useEffect5(() => {
|
|
870
|
+
if (ref.current) {
|
|
871
|
+
registerItem(data.id, ref.current, handleSelect);
|
|
872
|
+
}
|
|
873
|
+
return () => unregisterItem(data.id);
|
|
874
|
+
}, [
|
|
875
|
+
data.id,
|
|
876
|
+
handleSelect,
|
|
877
|
+
registerItem,
|
|
878
|
+
unregisterItem
|
|
879
|
+
]);
|
|
880
|
+
useEffect5(() => {
|
|
881
|
+
if (isSelected && ref.current) {
|
|
882
|
+
ref.current.scrollIntoView({
|
|
883
|
+
block: "nearest",
|
|
884
|
+
behavior: "smooth"
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
}, [
|
|
888
|
+
isSelected
|
|
889
|
+
]);
|
|
890
|
+
return /* @__PURE__ */ React12.createElement(Card3.Root, {
|
|
891
|
+
ref,
|
|
892
|
+
role: "button",
|
|
893
|
+
fullWidth: true,
|
|
894
|
+
tabIndex: -1,
|
|
895
|
+
"data-selected": isSelected,
|
|
896
|
+
classNames: mx3("dx-focus-ring cursor-pointer", isSelected && "bg-hover-overlay"),
|
|
897
|
+
onClick: handleSelect
|
|
898
|
+
}, /* @__PURE__ */ React12.createElement(Card3.Toolbar, null, /* @__PURE__ */ React12.createElement(Avatar2.Root, null, /* @__PURE__ */ React12.createElement(Avatar2.Content, {
|
|
899
|
+
hue: data.properties.hue,
|
|
900
|
+
icon: data.properties.icon,
|
|
901
|
+
hueVariant: "transparent",
|
|
902
|
+
variant: "square",
|
|
903
|
+
size: 8,
|
|
904
|
+
fallback: name
|
|
905
|
+
}), /* @__PURE__ */ React12.createElement(Avatar2.Label, null, name), /* @__PURE__ */ React12.createElement(Icon2, {
|
|
906
|
+
icon: "ph--caret-right--regular"
|
|
907
|
+
}))));
|
|
908
|
+
};
|
|
909
|
+
export {
|
|
910
|
+
AppBar,
|
|
911
|
+
DebugOverlay,
|
|
912
|
+
Home,
|
|
913
|
+
Loading,
|
|
914
|
+
Main,
|
|
915
|
+
MobileLayout,
|
|
916
|
+
NavBar,
|
|
917
|
+
NavBranch,
|
|
918
|
+
PopoverContent,
|
|
919
|
+
PopoverRoot,
|
|
920
|
+
SimpleLayout,
|
|
921
|
+
useDebugLog,
|
|
922
|
+
useMobileLayout
|
|
923
|
+
};
|
|
924
|
+
//# sourceMappingURL=index.mjs.map
|