@dxos/plugin-simple-layout 0.8.4-main.69d29f4 → 0.8.4-main.7996785055
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-J5FQ32AV.mjs +1256 -0
- package/dist/lib/browser/chunk-J5FQ32AV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CLPGTNWJ.mjs → chunk-MRR7PXSM.mjs} +5 -5
- package/dist/lib/browser/chunk-MRR7PXSM.mjs.map +7 -0
- package/dist/lib/browser/chunk-XJVW3PRY.mjs +22 -0
- package/dist/lib/browser/chunk-XJVW3PRY.mjs.map +7 -0
- package/dist/lib/browser/close-OT5JOGVY.mjs +34 -0
- package/dist/lib/browser/close-OT5JOGVY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +40 -32
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/open-4FQ44Z5G.mjs +31 -0
- package/dist/lib/browser/open-4FQ44Z5G.mjs.map +7 -0
- package/dist/lib/browser/operation-handler-OAD7LISD.mjs +16 -0
- package/dist/lib/browser/operation-handler-OAD7LISD.mjs.map +7 -0
- package/dist/lib/browser/{react-root-6ARAPH3O.mjs → react-root-6KIGPLUT.mjs} +5 -5
- package/dist/lib/browser/react-root-6KIGPLUT.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-SO7B23GS.mjs → react-surface-JLIEQGOL.mjs} +18 -13
- package/dist/lib/browser/react-surface-JLIEQGOL.mjs.map +7 -0
- package/dist/lib/browser/revert-workspace-DLE265AN.mjs +21 -0
- package/dist/lib/browser/revert-workspace-DLE265AN.mjs.map +7 -0
- package/dist/lib/browser/set-52HGTSH4.mjs +21 -0
- package/dist/lib/browser/set-52HGTSH4.mjs.map +7 -0
- package/dist/lib/browser/set-layout-mode-T6QI3DGU.mjs +11 -0
- package/dist/lib/browser/set-layout-mode-T6QI3DGU.mjs.map +7 -0
- package/dist/lib/browser/{spotlight-dismiss-VSNOPETH.mjs → spotlight-dismiss-67PHYS5B.mjs} +3 -3
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs.map +7 -0
- package/dist/lib/browser/{state-H4IGICBB.mjs → state-TXSMUWYI.mjs} +8 -5
- package/dist/lib/browser/state-TXSMUWYI.mjs.map +7 -0
- package/dist/lib/browser/switch-workspace-5Y6T4BWJ.mjs +24 -0
- package/dist/lib/browser/switch-workspace-5Y6T4BWJ.mjs.map +7 -0
- package/dist/lib/browser/update-complementary-MX3TTVAB.mjs +31 -0
- package/dist/lib/browser/update-complementary-MX3TTVAB.mjs.map +7 -0
- package/dist/lib/browser/update-dialog-FPAPZXKO.mjs +29 -0
- package/dist/lib/browser/update-dialog-FPAPZXKO.mjs.map +7 -0
- package/dist/lib/browser/update-popover-6V5ZTIYN.mjs +33 -0
- package/dist/lib/browser/update-popover-6V5ZTIYN.mjs.map +7 -0
- package/dist/lib/browser/update-sidebar-WHDKYMV7.mjs +10 -0
- package/dist/lib/browser/update-sidebar-WHDKYMV7.mjs.map +7 -0
- package/dist/lib/browser/url-handler-GUJ3L7Y3.mjs +163 -0
- package/dist/lib/browser/url-handler-GUJ3L7Y3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-27K22G6S.mjs +23 -0
- package/dist/lib/node-esm/chunk-27K22G6S.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-EXNDYZTP.mjs +1257 -0
- package/dist/lib/node-esm/chunk-EXNDYZTP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MUVVYBUE.mjs → chunk-WMNTJ2MK.mjs} +5 -5
- package/dist/lib/node-esm/chunk-WMNTJ2MK.mjs.map +7 -0
- package/dist/lib/node-esm/close-PEVHREL2.mjs +35 -0
- package/dist/lib/node-esm/close-PEVHREL2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +40 -32
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/open-LMJY7JCJ.mjs +32 -0
- package/dist/lib/node-esm/open-LMJY7JCJ.mjs.map +7 -0
- package/dist/lib/node-esm/operation-handler-A2DC4WHC.mjs +18 -0
- package/dist/lib/node-esm/operation-handler-A2DC4WHC.mjs.map +7 -0
- package/dist/lib/node-esm/{react-root-2CPA2ZUS.mjs → react-root-5SCW2KTH.mjs} +5 -5
- package/dist/lib/node-esm/react-root-5SCW2KTH.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-FKAV56MO.mjs → react-surface-WLKB6AET.mjs} +18 -13
- package/dist/lib/node-esm/react-surface-WLKB6AET.mjs.map +7 -0
- package/dist/lib/node-esm/revert-workspace-XZXT64YA.mjs +22 -0
- package/dist/lib/node-esm/revert-workspace-XZXT64YA.mjs.map +7 -0
- package/dist/lib/node-esm/set-5I6LFH5L.mjs +22 -0
- package/dist/lib/node-esm/set-5I6LFH5L.mjs.map +7 -0
- package/dist/lib/node-esm/set-layout-mode-F5B6QLZM.mjs +13 -0
- package/dist/lib/node-esm/set-layout-mode-F5B6QLZM.mjs.map +7 -0
- package/dist/lib/node-esm/{spotlight-dismiss-L5PCWIJG.mjs → spotlight-dismiss-RMLRZUVY.mjs} +3 -3
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs.map +7 -0
- package/dist/lib/node-esm/{state-QIU2LMLT.mjs → state-JMX6FAG4.mjs} +8 -5
- package/dist/lib/node-esm/state-JMX6FAG4.mjs.map +7 -0
- package/dist/lib/node-esm/switch-workspace-PB6T2SGY.mjs +25 -0
- package/dist/lib/node-esm/switch-workspace-PB6T2SGY.mjs.map +7 -0
- package/dist/lib/node-esm/update-complementary-FTW423IY.mjs +32 -0
- package/dist/lib/node-esm/update-complementary-FTW423IY.mjs.map +7 -0
- package/dist/lib/node-esm/update-dialog-ID267DCL.mjs +30 -0
- package/dist/lib/node-esm/update-dialog-ID267DCL.mjs.map +7 -0
- package/dist/lib/node-esm/update-popover-RLHU2HF4.mjs +34 -0
- package/dist/lib/node-esm/update-popover-RLHU2HF4.mjs.map +7 -0
- package/dist/lib/node-esm/update-sidebar-BJ7HTNZ4.mjs +12 -0
- package/dist/lib/node-esm/update-sidebar-BJ7HTNZ4.mjs.map +7 -0
- package/dist/lib/node-esm/url-handler-WMONO2T6.mjs +164 -0
- package/dist/lib/node-esm/url-handler-WMONO2T6.mjs.map +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts +1 -1
- package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler/index.d.ts +4 -0
- package/dist/types/src/capabilities/operation-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root/react-root.d.ts +1 -1
- package/dist/types/src/capabilities/react-root/react-root.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +1 -1
- package/dist/types/src/capabilities/state/index.d.ts +1 -1
- package/dist/types/src/capabilities/state/state.d.ts +1 -1
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -1
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts +5 -3
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +1 -1
- package/dist/types/src/components/ContentError.stories.d.ts +13 -4
- 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/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 +35 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts +7 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/index.d.ts +2 -0
- package/dist/types/src/components/MobileLayout/index.d.ts.map +1 -0
- 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 +28 -0
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +52 -0
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -0
- 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 +18 -6
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +22 -10
- 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 +16 -7
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/index.d.ts +3 -0
- package/dist/types/src/components/SimpleLayout/index.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 +4 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/actions.d.ts +19 -0
- package/dist/types/src/hooks/actions.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts +7 -0
- package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -0
- package/dist/types/src/hooks/useCompanions.d.ts +12 -0
- package/dist/types/src/hooks/useCompanions.d.ts.map +1 -0
- package/dist/types/src/hooks/useDrawerActions.d.ts +13 -0
- package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavbarActions.d.ts +14 -0
- package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -0
- 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/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/translations.d.ts +12 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +8 -3
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/events.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +36 -30
- package/src/SimpleLayoutPlugin.ts +12 -11
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/operation-handler/index.ts +9 -0
- package/src/capabilities/operation-handler/operation-handler.ts +14 -0
- package/src/capabilities/react-root/react-root.tsx +2 -2
- package/src/capabilities/react-surface/react-surface.tsx +14 -11
- package/src/capabilities/spotlight-dismiss/spotlight-dismiss.ts +2 -2
- package/src/capabilities/state/state.tsx +6 -3
- package/src/capabilities/url-handler/url-handler.ts +110 -45
- package/src/components/ContentError.stories.tsx +8 -7
- package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
- package/src/components/DebugOverlay/index.ts +5 -0
- package/src/components/Dialog/Dialog.tsx +5 -5
- package/src/components/Home/Home.tsx +49 -42
- package/src/components/{ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +5 -5
- 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 +133 -0
- package/src/components/MobileLayout/MobileLayout.tsx +374 -0
- package/src/components/MobileLayout/index.ts +5 -0
- package/src/components/NavBranch/NavBranch.tsx +127 -0
- package/src/components/{Workspace → NavBranch}/index.ts +1 -1
- package/src/components/Popover/Popover.tsx +7 -7
- package/src/components/SimpleLayout/AppBar.stories.tsx +144 -0
- package/src/components/SimpleLayout/AppBar.tsx +93 -0
- package/src/components/SimpleLayout/Drawer.tsx +96 -0
- package/src/components/SimpleLayout/Main.tsx +45 -48
- package/src/components/SimpleLayout/NavBar.stories.tsx +131 -26
- package/src/components/SimpleLayout/NavBar.tsx +21 -62
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +43 -53
- package/src/components/SimpleLayout/SimpleLayout.tsx +44 -6
- package/src/components/SimpleLayout/index.ts +3 -0
- package/src/components/hooks.ts +10 -14
- package/src/components/index.ts +4 -2
- package/src/hooks/actions.ts +83 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useAppBarProps.ts +115 -0
- package/src/hooks/useCompanions.ts +22 -0
- package/src/hooks/useDrawerActions.ts +100 -0
- package/src/hooks/useNavbarActions.ts +87 -0
- package/src/hooks/useSimpleLayoutState.ts +5 -5
- package/src/meta.ts +1 -1
- package/src/operations/close.ts +34 -0
- package/src/operations/index.ts +16 -0
- package/src/operations/open.ts +32 -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 +19 -0
- package/src/operations/switch-workspace.ts +26 -0
- package/src/operations/update-complementary.ts +34 -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/translations.ts +8 -1
- package/src/types/capabilities.ts +13 -4
- package/src/types/events.ts +3 -2
- package/dist/lib/browser/chunk-CLPGTNWJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FK4M7GJV.mjs +0 -613
- package/dist/lib/browser/chunk-FK4M7GJV.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-LTB63NKP.mjs +0 -168
- package/dist/lib/browser/operation-resolver-LTB63NKP.mjs.map +0 -7
- package/dist/lib/browser/react-root-6ARAPH3O.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SO7B23GS.mjs.map +0 -7
- package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs.map +0 -7
- package/dist/lib/browser/state-H4IGICBB.mjs.map +0 -7
- package/dist/lib/browser/url-handler-7CFGTLNG.mjs +0 -54
- package/dist/lib/browser/url-handler-7CFGTLNG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EGFZAVBD.mjs +0 -614
- 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 +0 -169
- package/dist/lib/node-esm/operation-resolver-7O6O7T4Q.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-2CPA2ZUS.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-FKAV56MO.mjs.map +0 -7
- package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs.map +0 -7
- package/dist/lib/node-esm/state-QIU2LMLT.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-4LYP3JM7.mjs +0 -55
- package/dist/lib/node-esm/url-handler-4LYP3JM7.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/components/ContentError.d.ts +0 -5
- package/dist/types/src/components/ContentError.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/SimpleLayout/Banner.d.ts +0 -8
- package/dist/types/src/components/SimpleLayout/Banner.d.ts.map +0 -1
- package/dist/types/src/components/Workspace/Workspace.d.ts +0 -9
- 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/src/capabilities/operation-resolver/index.ts +0 -10
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -178
- package/src/components/ContentError.tsx +0 -23
- package/src/components/SimpleLayout/Banner.tsx +0 -82
- package/src/components/Workspace/Workspace.tsx +0 -115
|
@@ -5,81 +5,71 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { ActivationEvents, Capability, Plugin } from '@dxos/app-framework';
|
|
9
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
-
import {
|
|
10
|
+
import { AppActivationEvents } from '@dxos/app-toolkit';
|
|
11
|
+
import { Collection } from '@dxos/echo';
|
|
12
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
11
13
|
import { SearchPlugin } from '@dxos/plugin-search';
|
|
12
14
|
import { SpacePlugin } from '@dxos/plugin-space';
|
|
13
|
-
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
14
15
|
import { corePlugins } from '@dxos/plugin-testing';
|
|
15
|
-
import {
|
|
16
|
-
import { translations as searchTranslation } from '@dxos/react-ui-
|
|
17
|
-
import { Collection } from '@dxos/schema';
|
|
16
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
17
|
+
import { translations as searchTranslation } from '@dxos/react-ui-search';
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { ReactRoot, ReactSurface, State } from '../../capabilities';
|
|
20
20
|
import { meta as pluginMeta } from '../../meta';
|
|
21
21
|
import { type SimpleLayoutPluginOptions } from '../../SimpleLayoutPlugin';
|
|
22
22
|
import { translations } from '../../translations';
|
|
23
|
+
import { SimpleLayoutEvents } from '../../types';
|
|
23
24
|
|
|
24
25
|
import { SimpleLayout } from './SimpleLayout';
|
|
25
26
|
|
|
26
|
-
const
|
|
27
|
-
Plugin.addModule(({ isPopover = false }) => ({
|
|
28
|
-
id: Capability.getModuleTag(State),
|
|
29
|
-
activatesOn: Common.ActivationEvent.Startup,
|
|
30
|
-
activatesAfter: [Common.ActivationEvent.LayoutReady],
|
|
31
|
-
activate: () => State({ initialState: { isPopover } } satisfies SimpleLayoutStateOptions),
|
|
32
|
-
})),
|
|
33
|
-
Common.Plugin.addOperationResolverModule({ activate: OperationResolver }),
|
|
34
|
-
Plugin.addModule({
|
|
35
|
-
id: 'setup',
|
|
36
|
-
activatesOn: Common.ActivationEvent.OperationInvokerReady,
|
|
37
|
-
activate: Effect.fnUntraced(function* () {
|
|
38
|
-
const { invoke } = yield* Capability.get(Common.Capability.OperationInvoker);
|
|
39
|
-
yield* invoke(ClientOperation.CreateIdentity, {});
|
|
40
|
-
const { space: work } = yield* invoke(SpaceOperation.Create, { name: 'Work Space' });
|
|
41
|
-
const { space: sharedProject } = yield* invoke(SpaceOperation.Create, { name: 'Shared Project' });
|
|
42
|
-
|
|
43
|
-
// Add collections to Work Space.
|
|
44
|
-
yield* invoke(SpaceOperation.AddObject, {
|
|
45
|
-
target: work.db,
|
|
46
|
-
object: Collection.make({ name: 'Projects', objects: [] }),
|
|
47
|
-
});
|
|
48
|
-
yield* invoke(SpaceOperation.AddObject, {
|
|
49
|
-
target: work.db,
|
|
50
|
-
object: Collection.make({ name: 'Documents', objects: [] }),
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Add collections to Shared Project.
|
|
54
|
-
yield* invoke(SpaceOperation.AddObject, {
|
|
55
|
-
target: sharedProject.db,
|
|
56
|
-
object: Collection.make({ name: 'Tasks', objects: [] }),
|
|
57
|
-
});
|
|
58
|
-
yield* invoke(SpaceOperation.AddObject, {
|
|
59
|
-
target: sharedProject.db,
|
|
60
|
-
object: Collection.make({ name: 'Notes', objects: [] }),
|
|
61
|
-
});
|
|
62
|
-
}),
|
|
63
|
-
}),
|
|
64
|
-
Plugin.make,
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const createPluginManager = ({ isPopover }: { isPopover: boolean }) => {
|
|
27
|
+
const createPluginManager = ({ isPopover }: { isPopover?: boolean }) => {
|
|
68
28
|
return withPluginManager({
|
|
29
|
+
setupEvents: [AppActivationEvents.SetupSettings],
|
|
69
30
|
plugins: [
|
|
70
31
|
...corePlugins(),
|
|
71
32
|
ClientPlugin({
|
|
72
33
|
types: [Collection.Collection],
|
|
34
|
+
onClientInitialized: ({ client }) =>
|
|
35
|
+
Effect.gen(function* () {
|
|
36
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
37
|
+
}),
|
|
73
38
|
}),
|
|
39
|
+
|
|
74
40
|
SearchPlugin(),
|
|
75
41
|
SpacePlugin({}),
|
|
76
|
-
|
|
42
|
+
|
|
43
|
+
// TODO(burdon): This should be factored ouf from SimpleLayoutPlugin.
|
|
44
|
+
Plugin.define<SimpleLayoutPluginOptions>(pluginMeta).pipe(
|
|
45
|
+
Plugin.addModule(({ isPopover = false }) => ({
|
|
46
|
+
id: Capability.getModuleTag(State),
|
|
47
|
+
activatesOn: ActivationEvents.Startup,
|
|
48
|
+
activatesAfter: [SimpleLayoutEvents.StateReady, AppActivationEvents.LayoutReady],
|
|
49
|
+
activate: () => State({ initialState: { isPopover } }),
|
|
50
|
+
})),
|
|
51
|
+
Plugin.addModule({
|
|
52
|
+
id: Capability.getModuleTag(ReactRoot),
|
|
53
|
+
activatesOn: ActivationEvents.Startup,
|
|
54
|
+
activate: ReactRoot,
|
|
55
|
+
}),
|
|
56
|
+
Plugin.addModule({
|
|
57
|
+
id: Capability.getModuleTag(ReactSurface),
|
|
58
|
+
activatesOn: ActivationEvents.Startup,
|
|
59
|
+
activate: ReactSurface,
|
|
60
|
+
}),
|
|
61
|
+
Plugin.make,
|
|
62
|
+
)({ isPopover }),
|
|
77
63
|
],
|
|
78
64
|
});
|
|
79
65
|
};
|
|
80
66
|
|
|
67
|
+
/**
|
|
68
|
+
* NOTE: To expose to iphone on network:
|
|
69
|
+
* `moon run storybook-react:serve dev -H 0.0.0.0`
|
|
70
|
+
*/
|
|
81
71
|
const meta = {
|
|
82
|
-
title: 'plugins/plugin-simple-layout/SimpleLayout',
|
|
72
|
+
title: 'plugins/plugin-simple-layout/components/SimpleLayout',
|
|
83
73
|
component: SimpleLayout,
|
|
84
74
|
parameters: {
|
|
85
75
|
layout: 'fullscreen',
|
|
@@ -92,9 +82,9 @@ export default meta;
|
|
|
92
82
|
type Story = StoryObj<typeof meta>;
|
|
93
83
|
|
|
94
84
|
export const Default: Story = {
|
|
95
|
-
decorators: [
|
|
85
|
+
decorators: [withLayout({ layout: 'column', classNames: 'relative' }), createPluginManager({})],
|
|
96
86
|
};
|
|
97
87
|
|
|
98
88
|
export const Popover: Story = {
|
|
99
|
-
decorators: [
|
|
89
|
+
decorators: [withLayout({ layout: 'column', classNames: 'relative' }), createPluginManager({ isPopover: true })],
|
|
100
90
|
};
|
|
@@ -2,19 +2,57 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useLayoutEffect, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
+
import { Splitter, type SplitterMode } from '@dxos/react-ui';
|
|
8
|
+
import { Mosaic } from '@dxos/react-ui-mosaic';
|
|
9
|
+
|
|
10
|
+
import { useSimpleLayoutState } from '../../hooks';
|
|
11
|
+
import { DebugOverlay } from '../DebugOverlay';
|
|
7
12
|
import { Dialog } from '../Dialog';
|
|
13
|
+
import { MobileLayout } from '../MobileLayout';
|
|
8
14
|
import { PopoverContent, PopoverRoot } from '../Popover';
|
|
9
15
|
|
|
16
|
+
import { Drawer } from './Drawer';
|
|
10
17
|
import { Main } from './Main';
|
|
11
18
|
|
|
12
19
|
export const SimpleLayout = () => {
|
|
20
|
+
const { state } = useSimpleLayoutState();
|
|
21
|
+
const [keyboardOpen, setKeyboardOpen] = useState(false);
|
|
22
|
+
const [splitterMode, setSplitterMode] = useState<SplitterMode>('upper');
|
|
23
|
+
|
|
24
|
+
const drawerRef = useRef<HTMLDivElement>(null);
|
|
25
|
+
|
|
26
|
+
// Restore Splitter mode when keyboard closes.
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
if (!keyboardOpen) {
|
|
29
|
+
setSplitterMode(state.drawerState === 'closed' ? 'upper' : state.drawerState === 'open' ? 'both' : 'lower');
|
|
30
|
+
}
|
|
31
|
+
}, [state.drawerState, keyboardOpen]);
|
|
32
|
+
|
|
13
33
|
return (
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
34
|
+
<DebugOverlay.Root enabled={false}>
|
|
35
|
+
<PopoverRoot>
|
|
36
|
+
<Mosaic.Root classNames='dx-container grid relative'>
|
|
37
|
+
<MobileLayout.Root
|
|
38
|
+
classNames='bg-toolbar-surface'
|
|
39
|
+
onKeyboardOpenChange={(nextKeyboardOpen) => setKeyboardOpen(nextKeyboardOpen)}
|
|
40
|
+
>
|
|
41
|
+
<MobileLayout.Panel safe={{ top: true, bottom: splitterMode === 'upper' }}>
|
|
42
|
+
<Splitter.Root mode={splitterMode} ratio={0.55}>
|
|
43
|
+
<Splitter.Panel position='upper'>
|
|
44
|
+
<Main />
|
|
45
|
+
</Splitter.Panel>
|
|
46
|
+
<Splitter.Panel position='lower' ref={drawerRef}>
|
|
47
|
+
<Drawer />
|
|
48
|
+
</Splitter.Panel>
|
|
49
|
+
</Splitter.Root>
|
|
50
|
+
<Dialog />
|
|
51
|
+
<PopoverContent />
|
|
52
|
+
</MobileLayout.Panel>
|
|
53
|
+
</MobileLayout.Root>
|
|
54
|
+
</Mosaic.Root>
|
|
55
|
+
</PopoverRoot>
|
|
56
|
+
</DebugOverlay.Root>
|
|
19
57
|
);
|
|
20
58
|
};
|
package/src/components/hooks.ts
CHANGED
|
@@ -4,27 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { expandAttendableId } from '@dxos/react-ui-attention';
|
|
8
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
9
|
import { Graph } from '@dxos/plugin-graph';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* Expand graph nodes along the full path from root to the given node ID.
|
|
13
|
+
* Walks each progressive prefix, ensuring ancestor nodes are materialized
|
|
14
|
+
* before attempting to access their children.
|
|
12
15
|
*/
|
|
13
|
-
export const
|
|
16
|
+
export const useExpandPath = (nodeId?: string) => {
|
|
14
17
|
const { graph } = useAppGraph();
|
|
15
18
|
|
|
16
19
|
useEffect(() => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Graph.expand(graph, nodeId, 'outbound');
|
|
21
|
-
// Second level: expand each child.
|
|
22
|
-
Graph.getConnections(graph, nodeId, 'outbound').forEach((child) => {
|
|
23
|
-
Graph.expand(graph, child.id, 'outbound');
|
|
24
|
-
});
|
|
20
|
+
if (nodeId) {
|
|
21
|
+
for (const prefix of expandAttendableId(nodeId)) {
|
|
22
|
+
Graph.expand(graph, prefix, 'child');
|
|
25
23
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return () => cancelAnimationFrame(frame);
|
|
24
|
+
}
|
|
29
25
|
}, [nodeId, graph]);
|
|
30
26
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './DebugOverlay';
|
|
6
6
|
export * from './Home';
|
|
7
|
+
export * from './Loading';
|
|
8
|
+
export * from './MobileLayout';
|
|
7
9
|
export * from './Popover';
|
|
8
10
|
export * from './SimpleLayout';
|
|
9
|
-
export * from './
|
|
11
|
+
export * from './NavBranch';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { type AppCapabilities, getCompanionVariant } from '@dxos/app-toolkit';
|
|
9
|
+
import { Node } from '@dxos/plugin-graph';
|
|
10
|
+
import { type ActionGraphProps } from '@dxos/react-ui-menu';
|
|
11
|
+
import { byPosition } from '@dxos/util';
|
|
12
|
+
|
|
13
|
+
import { type SimpleLayoutState } from '../types';
|
|
14
|
+
|
|
15
|
+
// TODO(wittjosiah): Factor out to shared location with plugin-deck.
|
|
16
|
+
export const PLANK_COMPANION_TYPE = 'org.dxos.plugin.deck.plank-companion';
|
|
17
|
+
|
|
18
|
+
export type CompanionActionsConfig = {
|
|
19
|
+
/** Prefix for companion action IDs (e.g. 'navbar' or 'drawer') */
|
|
20
|
+
idPrefix: string;
|
|
21
|
+
/** Optional: highlight companion with this variant */
|
|
22
|
+
selectedVariant?: string;
|
|
23
|
+
/** State updater for toggling the drawer. */
|
|
24
|
+
updateState: (fn: (state: SimpleLayoutState) => SimpleLayoutState) => void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates action graph nodes and edges for companion actions.
|
|
29
|
+
* Shared logic between useNavbarActions and useDrawerActions.
|
|
30
|
+
*/
|
|
31
|
+
// TODO(burdon): Use builder pattern.
|
|
32
|
+
export const createCompanionActions = (
|
|
33
|
+
graph: AppCapabilities.AppGraph['graph'],
|
|
34
|
+
stateAtom: Atom.Atom<SimpleLayoutState>,
|
|
35
|
+
get: (atom: Atom.Atom<any>) => any,
|
|
36
|
+
config: CompanionActionsConfig,
|
|
37
|
+
): Pick<ActionGraphProps, 'nodes' | 'edges'> => {
|
|
38
|
+
const { idPrefix, selectedVariant, updateState } = config;
|
|
39
|
+
|
|
40
|
+
// Derive activeId from state atom.
|
|
41
|
+
const state = get(stateAtom);
|
|
42
|
+
const activeId = state.active ?? state.workspace;
|
|
43
|
+
|
|
44
|
+
// Get companions from graph connections for activeId.
|
|
45
|
+
const activeConnections = activeId ? get(graph.connections(activeId, 'child')) : [];
|
|
46
|
+
const companions = activeConnections
|
|
47
|
+
.filter((node: Node.Node) => node.type === PLANK_COMPANION_TYPE)
|
|
48
|
+
.toSorted((a: Node.Node, b: Node.Node) => byPosition(a.properties, b.properties));
|
|
49
|
+
|
|
50
|
+
const nodes: ActionGraphProps['nodes'] = [];
|
|
51
|
+
const edges: ActionGraphProps['edges'] = [];
|
|
52
|
+
|
|
53
|
+
companions.forEach((companion: Node.Node) => {
|
|
54
|
+
const companionVariant = getCompanionVariant(companion.id);
|
|
55
|
+
const companionAction = {
|
|
56
|
+
id: `${idPrefix}-companion-${companion.id}`,
|
|
57
|
+
type: Node.ActionType,
|
|
58
|
+
properties: {
|
|
59
|
+
icon: companion.properties.icon ?? 'ph--placeholder--regular',
|
|
60
|
+
label: companion.properties.label,
|
|
61
|
+
iconOnly: true,
|
|
62
|
+
...(selectedVariant !== undefined && {
|
|
63
|
+
variant: selectedVariant === companionVariant ? 'primary' : 'ghost',
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
data: () =>
|
|
67
|
+
Effect.sync(() =>
|
|
68
|
+
updateState((current) => {
|
|
69
|
+
const closing = current.companionVariant === companionVariant && current.drawerState !== 'closed';
|
|
70
|
+
return {
|
|
71
|
+
...current,
|
|
72
|
+
companionVariant: closing ? undefined : companionVariant,
|
|
73
|
+
drawerState: closing ? 'closed' : 'open',
|
|
74
|
+
};
|
|
75
|
+
}),
|
|
76
|
+
),
|
|
77
|
+
};
|
|
78
|
+
nodes.push(companionAction);
|
|
79
|
+
edges.push({ source: 'root', target: companionAction.id, relation: 'child' });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return { nodes, edges };
|
|
83
|
+
};
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Atom, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Option from 'effect/Option';
|
|
8
|
+
import { useCallback, useMemo } from 'react';
|
|
9
|
+
|
|
10
|
+
import { useCapability, useOperationInvoker } from '@dxos/app-framework/ui';
|
|
11
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
12
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
13
|
+
import { Graph, Node, useActionRunner, useNode } from '@dxos/plugin-graph';
|
|
14
|
+
import { toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
15
|
+
import { type ActionGraphProps } from '@dxos/react-ui-menu';
|
|
16
|
+
|
|
17
|
+
import { type AppBarProps } from '../components';
|
|
18
|
+
import { meta } from '../meta';
|
|
19
|
+
import { SimpleLayoutState as SimpleLayoutStateCapability } from '../types';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Hook that computes all AppBar props from the app graph.
|
|
23
|
+
* Derives activeId from state atom. Returns props ready to spread into the AppBar component.
|
|
24
|
+
*/
|
|
25
|
+
export const useAppBarProps = (): Omit<AppBarProps, 'classNames'> => {
|
|
26
|
+
const { t } = useTranslation(meta.id);
|
|
27
|
+
const stateAtom = useCapability(SimpleLayoutStateCapability);
|
|
28
|
+
const state = useAtomValue(stateAtom);
|
|
29
|
+
const { graph } = useAppGraph();
|
|
30
|
+
const { invokePromise } = useOperationInvoker();
|
|
31
|
+
const runAction = useActionRunner();
|
|
32
|
+
|
|
33
|
+
// Derive activeId from state.
|
|
34
|
+
const activeId = state.active ?? state.workspace;
|
|
35
|
+
const node = useNode(graph, activeId);
|
|
36
|
+
|
|
37
|
+
// Compute title from node label.
|
|
38
|
+
const title = node ? toLocalizedString(node.properties.label, t) : undefined;
|
|
39
|
+
|
|
40
|
+
// Build actions atom filtering by disposition.
|
|
41
|
+
// Derive activeId from state atom so we don't need to recreate this atom when it changes.
|
|
42
|
+
const actionsAtom = useMemo(
|
|
43
|
+
() =>
|
|
44
|
+
Atom.make((get): ActionGraphProps => {
|
|
45
|
+
const state = get(stateAtom);
|
|
46
|
+
const activeId = state.active ?? state.workspace;
|
|
47
|
+
const allActions = activeId ? get(graph.actions(activeId)) : [];
|
|
48
|
+
const filtered = allActions.filter((action) =>
|
|
49
|
+
['list-item', 'list-item-primary', 'heading-list-item'].includes(action.properties.disposition),
|
|
50
|
+
);
|
|
51
|
+
const nodes: ActionGraphProps['nodes'] = filtered as ActionGraphProps['nodes'];
|
|
52
|
+
const edges: ActionGraphProps['edges'] = filtered.map((action) => ({
|
|
53
|
+
source: 'root',
|
|
54
|
+
target: action.id,
|
|
55
|
+
relation: 'child',
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
// Add alternate-tree action (e.g. Settings) from the workspace node.
|
|
59
|
+
const workspaceConnections = state.workspace ? get(graph.connections(state.workspace, 'child')) : [];
|
|
60
|
+
const alternateTreeNode = workspaceConnections.find(
|
|
61
|
+
(node: Node.Node) => node.properties.disposition === 'alternate-tree',
|
|
62
|
+
);
|
|
63
|
+
if (alternateTreeNode && activeId !== alternateTreeNode.id) {
|
|
64
|
+
const settingsAction = {
|
|
65
|
+
id: `appbar-settings-${alternateTreeNode.id}`,
|
|
66
|
+
type: Node.ActionType,
|
|
67
|
+
data: () => Effect.promise(() => invokePromise(LayoutOperation.Open, { subject: [alternateTreeNode.id] })),
|
|
68
|
+
properties: {
|
|
69
|
+
label: alternateTreeNode.properties.label ?? alternateTreeNode.id,
|
|
70
|
+
icon: alternateTreeNode.properties.icon ?? 'ph--placeholder--regular',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
nodes.push(settingsAction);
|
|
74
|
+
edges.push({ source: 'root', target: settingsAction.id, relation: 'child' });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { nodes, edges };
|
|
78
|
+
}),
|
|
79
|
+
[graph, stateAtom],
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// Back button logic.
|
|
83
|
+
const showBackButton = activeId !== undefined && activeId !== Node.RootId;
|
|
84
|
+
|
|
85
|
+
const onBack = useCallback(() => {
|
|
86
|
+
if (state.active) {
|
|
87
|
+
const isWorkspace = Graph.getNode(graph, state.active).pipe(
|
|
88
|
+
Option.map((node) => node.properties.disposition === 'workspace'),
|
|
89
|
+
Option.getOrElse(() => false),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// If history is empty and this is a workspace, go to home.
|
|
93
|
+
if (state.history.length === 0 && isWorkspace) {
|
|
94
|
+
void invokePromise(LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
|
|
95
|
+
} else {
|
|
96
|
+
// Otherwise, close (which will pop from history or clear active).
|
|
97
|
+
void invokePromise(LayoutOperation.Close, { subject: [state.active] });
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
void invokePromise(LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
|
|
101
|
+
}
|
|
102
|
+
}, [graph, invokePromise, state.active, state.history.length]);
|
|
103
|
+
|
|
104
|
+
// Compute popover anchor ID.
|
|
105
|
+
const popoverAnchorId = node && state.popoverAnchorId === `${meta.id}:${node.id}` ? state.popoverAnchorId : undefined;
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
title,
|
|
109
|
+
actions: actionsAtom,
|
|
110
|
+
showBackButton,
|
|
111
|
+
popoverAnchorId,
|
|
112
|
+
onBack: onBack,
|
|
113
|
+
onAction: runAction,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { useConnections } from '@dxos/plugin-graph';
|
|
9
|
+
import { byPosition } from '@dxos/util';
|
|
10
|
+
|
|
11
|
+
import { PLANK_COMPANION_TYPE } from './actions';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Adopt the pattern from useNavbarActions (deriving from graph atoms)
|
|
15
|
+
* or merge the Drawer companion display into the NavBar component.
|
|
16
|
+
*/
|
|
17
|
+
export const useCompanions = (nodeId?: string) => {
|
|
18
|
+
const { graph } = useAppGraph();
|
|
19
|
+
const nodes = useConnections(graph, nodeId, 'child');
|
|
20
|
+
const companions = nodes.filter((node) => node.type === PLANK_COMPANION_TYPE);
|
|
21
|
+
return useMemo(() => companions.toSorted((a, b) => byPosition(a.properties, b.properties)), [companions]);
|
|
22
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
10
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
11
|
+
import { Node, useActionRunner } from '@dxos/plugin-graph';
|
|
12
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
13
|
+
import { type ActionExecutor, type ActionGraphProps, createGapSeparator } from '@dxos/react-ui-menu';
|
|
14
|
+
|
|
15
|
+
import { useMobileLayout } from '../components';
|
|
16
|
+
import { meta } from '../meta';
|
|
17
|
+
import { SimpleLayoutState as SimpleLayoutStateCapability } from '../types';
|
|
18
|
+
|
|
19
|
+
import { createCompanionActions } from './actions';
|
|
20
|
+
import { useSimpleLayoutState } from './useSimpleLayoutState';
|
|
21
|
+
|
|
22
|
+
export type DrawerActions = {
|
|
23
|
+
/** Action graph atom for the drawer. */
|
|
24
|
+
actions: Atom.Atom<ActionGraphProps>;
|
|
25
|
+
/** Action executor callback. */
|
|
26
|
+
onAction: ActionExecutor;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Builds the drawer actions including companion tabs and toolbar buttons.
|
|
31
|
+
*/
|
|
32
|
+
export const useDrawerActions = (consumerName: string): DrawerActions => {
|
|
33
|
+
const { t } = useTranslation(meta.id);
|
|
34
|
+
const stateAtom = useCapability(SimpleLayoutStateCapability);
|
|
35
|
+
const { graph } = useAppGraph();
|
|
36
|
+
const runAction = useActionRunner();
|
|
37
|
+
const { updateState } = useSimpleLayoutState();
|
|
38
|
+
const { keyboardOpen } = useMobileLayout(consumerName);
|
|
39
|
+
|
|
40
|
+
// Create a computed atom that derives everything from graph connections and state.
|
|
41
|
+
const actionsAtom = useMemo(
|
|
42
|
+
() =>
|
|
43
|
+
Atom.make((get): ActionGraphProps => {
|
|
44
|
+
// Derive drawer state from state atom.
|
|
45
|
+
const state = get(stateAtom);
|
|
46
|
+
|
|
47
|
+
// Add companion tab actions.
|
|
48
|
+
const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
|
|
49
|
+
idPrefix: 'drawer',
|
|
50
|
+
selectedVariant: state.drawerState !== 'closed' ? state.companionVariant : undefined,
|
|
51
|
+
updateState,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Add gap separator before toolbar buttons.
|
|
55
|
+
const gapSeparator = createGapSeparator('drawer-gap');
|
|
56
|
+
nodes.push(...gapSeparator.nodes);
|
|
57
|
+
edges.push(...gapSeparator.edges);
|
|
58
|
+
|
|
59
|
+
// Add expand/collapse toggle button (hidden when keyboard is open).
|
|
60
|
+
if (!keyboardOpen) {
|
|
61
|
+
const isExpanded = state.drawerState === 'expanded';
|
|
62
|
+
const toggleExpandAction = {
|
|
63
|
+
id: 'drawer-toggle-expand',
|
|
64
|
+
type: Node.ActionType,
|
|
65
|
+
properties: {
|
|
66
|
+
icon: isExpanded ? 'ph--arrow-down--regular' : 'ph--arrow-up--regular',
|
|
67
|
+
label: isExpanded ? t('collapse drawer label') : t('expand drawer label'),
|
|
68
|
+
iconOnly: true,
|
|
69
|
+
},
|
|
70
|
+
data: () =>
|
|
71
|
+
Effect.sync(() => updateState((state) => ({ ...state, drawerState: isExpanded ? 'open' : 'expanded' }))),
|
|
72
|
+
};
|
|
73
|
+
nodes.push(toggleExpandAction);
|
|
74
|
+
edges.push({ source: 'root', target: toggleExpandAction.id, relation: 'child' });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Add close button.
|
|
78
|
+
const closeAction = {
|
|
79
|
+
id: 'drawer-close',
|
|
80
|
+
type: Node.ActionType,
|
|
81
|
+
properties: {
|
|
82
|
+
icon: 'ph--x--regular',
|
|
83
|
+
label: t('close drawer label'),
|
|
84
|
+
iconOnly: true,
|
|
85
|
+
},
|
|
86
|
+
data: () =>
|
|
87
|
+
Effect.sync(() =>
|
|
88
|
+
updateState((state) => ({ ...state, drawerState: 'closed', companionVariant: undefined })),
|
|
89
|
+
),
|
|
90
|
+
};
|
|
91
|
+
nodes.push(closeAction);
|
|
92
|
+
edges.push({ source: 'root', target: closeAction.id, relation: 'child' });
|
|
93
|
+
|
|
94
|
+
return { nodes, edges };
|
|
95
|
+
}),
|
|
96
|
+
[graph, stateAtom, updateState, keyboardOpen, t],
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return { actions: actionsAtom, onAction: runAction };
|
|
100
|
+
};
|