@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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Atom, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import React, { Fragment } from 'react';
|
|
7
|
+
|
|
8
|
+
import { IconButton, Popover, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { type ActionExecutor, type ActionGraphProps, Menu, useMenuActions } from '@dxos/react-ui-menu';
|
|
10
|
+
import { composable, composableProps, osTranslations } from '@dxos/ui-theme';
|
|
11
|
+
|
|
12
|
+
import { meta } from '../../meta';
|
|
13
|
+
import { useMobileLayout } from '../MobileLayout';
|
|
14
|
+
|
|
15
|
+
const APP_BAR_NAME = 'SimpleLayout.AppBar';
|
|
16
|
+
|
|
17
|
+
export type AppBarProps = {
|
|
18
|
+
/** Title/label to display in the banner. */
|
|
19
|
+
title?: string;
|
|
20
|
+
/** Action graph atom for the dropdown menu. */
|
|
21
|
+
actions: Atom.Atom<ActionGraphProps>;
|
|
22
|
+
/** Whether to show the back button. */
|
|
23
|
+
showBackButton?: boolean;
|
|
24
|
+
/** Popover anchor ID for the dropdown trigger. */
|
|
25
|
+
popoverAnchorId?: string;
|
|
26
|
+
/** Action executor callback. */
|
|
27
|
+
onAction?: ActionExecutor;
|
|
28
|
+
/** Callback when back button is clicked. */
|
|
29
|
+
onBack?: () => void;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* AppBar component that renders a title, optional back button, and actions dropdown.
|
|
34
|
+
*/
|
|
35
|
+
export const AppBar = composable<HTMLDivElement, AppBarProps>(
|
|
36
|
+
({ classNames, title, actions, showBackButton, popoverAnchorId, onAction, onBack, ...props }, forwardedRef) => {
|
|
37
|
+
const { t } = useTranslation(meta.id);
|
|
38
|
+
const menuActions = useMenuActions(actions);
|
|
39
|
+
const actionsValue = useAtomValue(actions);
|
|
40
|
+
const hasActions = actionsValue.nodes.length > 0;
|
|
41
|
+
const { keyboardOpen } = useMobileLayout(APP_BAR_NAME);
|
|
42
|
+
|
|
43
|
+
// Fall back to app name if no title provided.
|
|
44
|
+
const displayTitle = title ?? t('current app name', { ns: osTranslations });
|
|
45
|
+
|
|
46
|
+
// Wrap the menu trigger with Popover.Anchor when the popoverAnchorId is set.
|
|
47
|
+
const AnchorRoot = popoverAnchorId ? Popover.Anchor : Fragment;
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Toolbar.Root
|
|
51
|
+
{...composableProps(props, {
|
|
52
|
+
role: 'banner',
|
|
53
|
+
classNames: 'grid grid-cols-[var(--dx-rail-size)_1fr_var(--dx-rail-size)] items-center dx-density-fine',
|
|
54
|
+
})}
|
|
55
|
+
ref={forwardedRef}
|
|
56
|
+
>
|
|
57
|
+
{keyboardOpen ? (
|
|
58
|
+
<IconButton variant='ghost' icon='ph--x--regular' iconOnly label={t('done label')} />
|
|
59
|
+
) : showBackButton ? (
|
|
60
|
+
<IconButton
|
|
61
|
+
variant='ghost'
|
|
62
|
+
icon='ph--caret-left--regular'
|
|
63
|
+
iconOnly
|
|
64
|
+
label={t('back label')}
|
|
65
|
+
onClick={onBack}
|
|
66
|
+
/>
|
|
67
|
+
) : (
|
|
68
|
+
<div />
|
|
69
|
+
)}
|
|
70
|
+
<h1 className='text-center truncate font-thin uppercase'>{displayTitle}</h1>
|
|
71
|
+
{hasActions ? (
|
|
72
|
+
<AnchorRoot>
|
|
73
|
+
<Menu.Root {...menuActions} caller={meta.id} onAction={onAction}>
|
|
74
|
+
<Menu.Trigger asChild>
|
|
75
|
+
<IconButton
|
|
76
|
+
variant='ghost'
|
|
77
|
+
icon='ph--dots-three-vertical--regular'
|
|
78
|
+
iconOnly
|
|
79
|
+
label={t('actions menu label')}
|
|
80
|
+
/>
|
|
81
|
+
</Menu.Trigger>
|
|
82
|
+
<Menu.Content />
|
|
83
|
+
</Menu.Root>
|
|
84
|
+
</AnchorRoot>
|
|
85
|
+
) : (
|
|
86
|
+
<span />
|
|
87
|
+
)}
|
|
88
|
+
</Toolbar.Root>
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
AppBar.displayName = APP_BAR_NAME;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
+
import { getCompanionVariant } from '@dxos/app-toolkit';
|
|
9
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
10
|
+
import { type Node, useNode } from '@dxos/plugin-graph';
|
|
11
|
+
import { ErrorFallback, Panel } from '@dxos/react-ui';
|
|
12
|
+
import { Menu, useMenuActions } from '@dxos/react-ui-menu';
|
|
13
|
+
|
|
14
|
+
import { useCompanions, useDrawerActions, useSimpleLayoutState } from '../../hooks';
|
|
15
|
+
import { Loading } from '../Loading';
|
|
16
|
+
|
|
17
|
+
const DRAWER_NAME = 'SimpleLayout.Drawer';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Companion drawer component.
|
|
21
|
+
*/
|
|
22
|
+
export const Drawer = () => {
|
|
23
|
+
const { graph } = useAppGraph();
|
|
24
|
+
const { state: layoutState } = useSimpleLayoutState();
|
|
25
|
+
|
|
26
|
+
const placeholder = useMemo(() => <Loading />, []);
|
|
27
|
+
|
|
28
|
+
// Get all companions for the current active (primary) item.
|
|
29
|
+
const activeId = layoutState.active ?? layoutState.workspace;
|
|
30
|
+
const companions = useCompanions(activeId);
|
|
31
|
+
const { companionId, variant } = useSelectedCompanion(companions, layoutState.companionVariant);
|
|
32
|
+
|
|
33
|
+
// Get node for the selected companion.
|
|
34
|
+
const node = useNode(graph, companionId);
|
|
35
|
+
const parentNode = useNode(graph, activeId);
|
|
36
|
+
|
|
37
|
+
// Build Surface data for the companion content.
|
|
38
|
+
const data = useMemo(() => {
|
|
39
|
+
return (
|
|
40
|
+
node && {
|
|
41
|
+
attendableId: companionId,
|
|
42
|
+
subject: node.data,
|
|
43
|
+
companionTo: parentNode?.data,
|
|
44
|
+
properties: node.properties,
|
|
45
|
+
variant,
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}, [companionId, node, parentNode, variant]);
|
|
49
|
+
|
|
50
|
+
// Get drawer actions (tabs + toolbar buttons).
|
|
51
|
+
const { actions, onAction } = useDrawerActions(DRAWER_NAME);
|
|
52
|
+
const menuActions = useMenuActions(actions);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Panel.Root>
|
|
56
|
+
<Panel.Toolbar>
|
|
57
|
+
<Menu.Root {...menuActions} alwaysActive onAction={onAction}>
|
|
58
|
+
<Menu.Toolbar />
|
|
59
|
+
</Menu.Root>
|
|
60
|
+
</Panel.Toolbar>
|
|
61
|
+
<Panel.Content>
|
|
62
|
+
<Surface.Surface role='article' data={data} limit={1} fallback={ErrorFallback} placeholder={placeholder} />
|
|
63
|
+
</Panel.Content>
|
|
64
|
+
</Panel.Root>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
Drawer.displayName = DRAWER_NAME;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Resolves which companion to show based on variant preference.
|
|
72
|
+
* Falls back to first available if preferred variant not available.
|
|
73
|
+
*/
|
|
74
|
+
const useSelectedCompanion = (companions: Node.Node[], preferredVariant?: string) => {
|
|
75
|
+
const selectedCompanion = useMemo(() => {
|
|
76
|
+
if (companions.length === 0) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Try to find companion matching the preferred variant.
|
|
81
|
+
if (preferredVariant) {
|
|
82
|
+
const preferred = companions.find((c) => getCompanionVariant(c.id) === preferredVariant);
|
|
83
|
+
if (preferred) {
|
|
84
|
+
return preferred;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Fallback to first companion.
|
|
89
|
+
return companions[0];
|
|
90
|
+
}, [companions, preferredVariant]);
|
|
91
|
+
|
|
92
|
+
const companionId = selectedCompanion?.id;
|
|
93
|
+
const variant = companionId ? getCompanionVariant(companionId) : undefined;
|
|
94
|
+
|
|
95
|
+
return { selectedCompanion, companionId, variant };
|
|
96
|
+
};
|
|
@@ -2,80 +2,77 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Surface
|
|
8
|
-
import {
|
|
7
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
9
|
import { useNode } from '@dxos/plugin-graph';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { Mosaic } from '@dxos/react-ui-mosaic';
|
|
13
|
-
import { mx } from '@dxos/ui-theme';
|
|
10
|
+
import { ErrorFallback, Panel } from '@dxos/react-ui';
|
|
11
|
+
import { useAttentionAttributes } from '@dxos/react-ui-attention';
|
|
14
12
|
|
|
15
|
-
import { useSimpleLayoutState } from '../../hooks';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
13
|
+
import { useAppBarProps, useNavbarActions, useSimpleLayoutState } from '../../hooks';
|
|
14
|
+
import { Loading } from '../Loading';
|
|
15
|
+
import { useExpandPath } from '../hooks';
|
|
16
|
+
import { useMobileLayout } from '../MobileLayout';
|
|
18
17
|
|
|
19
|
-
import {
|
|
18
|
+
import { AppBar } from './AppBar';
|
|
20
19
|
import { NavBar } from './NavBar';
|
|
21
20
|
|
|
21
|
+
const MAIN_NAME = 'SimpleLayout.Main';
|
|
22
|
+
|
|
22
23
|
/**
|
|
23
|
-
* Main
|
|
24
|
+
* Main content component.
|
|
24
25
|
*/
|
|
25
26
|
export const Main = () => {
|
|
26
27
|
const { state } = useSimpleLayoutState();
|
|
27
28
|
const id = state.active ?? state.workspace;
|
|
28
|
-
const
|
|
29
|
-
const {
|
|
30
|
-
const
|
|
29
|
+
const attentionAttrs = useAttentionAttributes(id);
|
|
30
|
+
const { keyboardOpen } = useMobileLayout(MAIN_NAME);
|
|
31
|
+
const { actions, onAction } = useNavbarActions();
|
|
32
|
+
const appBarProps = useAppBarProps();
|
|
31
33
|
|
|
32
|
-
const placeholder = useMemo(() => <
|
|
34
|
+
const placeholder = useMemo(() => <Loading />, []);
|
|
33
35
|
|
|
36
|
+
const { graph } = useAppGraph();
|
|
37
|
+
const node = useNode(graph, id);
|
|
34
38
|
const data = useMemo(() => {
|
|
35
|
-
const { variant } = parseEntryId(id);
|
|
36
39
|
return (
|
|
37
40
|
node && {
|
|
38
41
|
attendableId: id,
|
|
39
42
|
subject: node.data,
|
|
40
43
|
properties: node.properties,
|
|
41
44
|
popoverAnchorId: state.popoverAnchorId,
|
|
42
|
-
variant,
|
|
43
45
|
}
|
|
44
46
|
);
|
|
45
47
|
}, [id, node, node?.data, node?.properties, state.popoverAnchorId]);
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
useExpandPath(id);
|
|
50
|
+
|
|
51
|
+
// TODO(burdon): BUG: When showing ANY statusbar the size progressively shrinks when the keyboard opens/closes.
|
|
52
|
+
const showNavBar = !keyboardOpen && !state.isPopover && state.drawerState === 'closed';
|
|
50
53
|
|
|
51
54
|
return (
|
|
52
|
-
<
|
|
53
|
-
<
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
</
|
|
70
|
-
|
|
71
|
-
</
|
|
55
|
+
<Panel.Root {...attentionAttrs} className='dx-document'>
|
|
56
|
+
<Panel.Toolbar asChild>
|
|
57
|
+
<AppBar {...appBarProps} />
|
|
58
|
+
</Panel.Toolbar>
|
|
59
|
+
<Panel.Content role='article' className='bg-base-surface'>
|
|
60
|
+
<Surface.Surface
|
|
61
|
+
key={id}
|
|
62
|
+
role='article'
|
|
63
|
+
data={data}
|
|
64
|
+
limit={1}
|
|
65
|
+
fallback={ErrorFallback}
|
|
66
|
+
placeholder={placeholder}
|
|
67
|
+
/>
|
|
68
|
+
</Panel.Content>
|
|
69
|
+
{showNavBar && (
|
|
70
|
+
<Panel.Statusbar asChild>
|
|
71
|
+
<NavBar actions={actions} onAction={onAction} />
|
|
72
|
+
</Panel.Statusbar>
|
|
73
|
+
)}
|
|
74
|
+
</Panel.Root>
|
|
72
75
|
);
|
|
73
76
|
};
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
const parseEntryId = (entryId: string) => {
|
|
77
|
-
const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR);
|
|
78
|
-
return { id, variant };
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
Main.displayName = 'SimpleLayout.Main';
|
|
78
|
+
Main.displayName = MAIN_NAME;
|
|
@@ -2,58 +2,163 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
5
6
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
8
|
+
import { type Mock, expect, fn, screen, userEvent, within } from 'storybook/test';
|
|
6
9
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
import { type ActionGraphProps, createGapSeparator, createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
|
|
12
|
+
import { withRegistry } from '@dxos/storybook-utils';
|
|
10
13
|
|
|
11
14
|
import { translations } from '../../translations';
|
|
12
15
|
|
|
13
16
|
import { NavBar } from './NavBar';
|
|
14
17
|
|
|
18
|
+
const MAIN_MENU_GROUP_ID = 'navbar-main-menu';
|
|
19
|
+
|
|
20
|
+
const buildEmptyActions = (): ActionGraphProps => ({ nodes: [], edges: [] });
|
|
21
|
+
|
|
22
|
+
const buildCompanionOnlyActions = (): ActionGraphProps => {
|
|
23
|
+
const result: ActionGraphProps = { nodes: [], edges: [] };
|
|
24
|
+
const companions = [
|
|
25
|
+
createMenuAction('companion-browse', () => console.log('Browse'), {
|
|
26
|
+
icon: 'ph--house--regular',
|
|
27
|
+
label: 'Browse',
|
|
28
|
+
iconOnly: true,
|
|
29
|
+
}),
|
|
30
|
+
createMenuAction('companion-notifications', () => console.log('Notifications'), {
|
|
31
|
+
icon: 'ph--bell--regular',
|
|
32
|
+
label: 'Notifications',
|
|
33
|
+
iconOnly: true,
|
|
34
|
+
}),
|
|
35
|
+
createMenuAction('companion-profile', () => console.log('Profile'), {
|
|
36
|
+
icon: 'ph--user--regular',
|
|
37
|
+
label: 'Profile',
|
|
38
|
+
iconOnly: true,
|
|
39
|
+
}),
|
|
40
|
+
];
|
|
41
|
+
result.nodes.push(...companions);
|
|
42
|
+
result.edges.push(...companions.map((c) => ({ source: 'root', target: c.id, relation: 'child' })));
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const buildDefaultActions = (): ActionGraphProps => {
|
|
47
|
+
const result: ActionGraphProps = { nodes: [], edges: [] };
|
|
48
|
+
const gapSeparator = createGapSeparator('navbar-gap');
|
|
49
|
+
const mainMenuGroup = createMenuItemGroup(MAIN_MENU_GROUP_ID, {
|
|
50
|
+
variant: 'dropdownMenu',
|
|
51
|
+
icon: 'ph--plus--regular',
|
|
52
|
+
iconOnly: true,
|
|
53
|
+
label: 'Main menu',
|
|
54
|
+
testId: 'simpleLayoutPlugin.addSpace',
|
|
55
|
+
});
|
|
56
|
+
const companions = [
|
|
57
|
+
createMenuAction('companion-browse', () => console.log('Browse'), {
|
|
58
|
+
icon: 'ph--house--regular',
|
|
59
|
+
label: 'Browse',
|
|
60
|
+
iconOnly: true,
|
|
61
|
+
}),
|
|
62
|
+
createMenuAction('companion-notifications', () => console.log('Notifications'), {
|
|
63
|
+
icon: 'ph--bell--regular',
|
|
64
|
+
label: 'Notifications',
|
|
65
|
+
iconOnly: true,
|
|
66
|
+
}),
|
|
67
|
+
];
|
|
68
|
+
const menuActions = [
|
|
69
|
+
createMenuAction('action-create-space', () => console.log('Create space'), {
|
|
70
|
+
icon: 'ph--planet--regular',
|
|
71
|
+
label: 'Create space',
|
|
72
|
+
}),
|
|
73
|
+
createMenuAction('action-join-space', () => console.log('Join space'), {
|
|
74
|
+
icon: 'ph--sign-in--regular',
|
|
75
|
+
label: 'Join space',
|
|
76
|
+
}),
|
|
77
|
+
createMenuAction('action-settings', () => console.log('Settings'), {
|
|
78
|
+
icon: 'ph--gear--regular',
|
|
79
|
+
label: 'Settings',
|
|
80
|
+
}),
|
|
81
|
+
];
|
|
82
|
+
result.nodes.push(...companions, ...gapSeparator.nodes, mainMenuGroup, ...menuActions);
|
|
83
|
+
result.edges.push(
|
|
84
|
+
...companions.map((c) => ({ source: 'root', target: c.id, relation: 'child' })),
|
|
85
|
+
...gapSeparator.edges,
|
|
86
|
+
{ source: 'root', target: mainMenuGroup.id, relation: 'child' },
|
|
87
|
+
...menuActions.map((action) => ({ source: MAIN_MENU_GROUP_ID, target: action.id, relation: 'child' })),
|
|
88
|
+
);
|
|
89
|
+
return result;
|
|
90
|
+
};
|
|
91
|
+
|
|
15
92
|
const meta = {
|
|
16
|
-
title: 'plugins/plugin-simple-layout/NavBar',
|
|
93
|
+
title: 'plugins/plugin-simple-layout/components/NavBar',
|
|
17
94
|
component: NavBar,
|
|
18
|
-
decorators: [
|
|
19
|
-
withTheme,
|
|
20
|
-
withPluginManager({
|
|
21
|
-
plugins: [...corePlugins()],
|
|
22
|
-
}),
|
|
23
|
-
],
|
|
95
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withRegistry],
|
|
24
96
|
parameters: {
|
|
25
97
|
layout: 'fullscreen',
|
|
26
98
|
translations,
|
|
27
99
|
},
|
|
28
|
-
argTypes: {
|
|
29
|
-
onActiveIdChange: { action: 'activeIdChanged' },
|
|
30
|
-
},
|
|
31
100
|
} satisfies Meta<typeof NavBar>;
|
|
32
101
|
|
|
33
102
|
export default meta;
|
|
34
103
|
|
|
35
104
|
type Story = StoryObj<typeof meta>;
|
|
36
105
|
|
|
106
|
+
const DefaultStory = ({ onAction }: { onAction: (action: { id: string }) => void }) => {
|
|
107
|
+
const actions = useMemo(() => Atom.make(buildDefaultActions()).pipe(Atom.keepAlive), []);
|
|
108
|
+
|
|
109
|
+
return <NavBar classNames='border-y border-separator' actions={actions} onAction={onAction} />;
|
|
110
|
+
};
|
|
111
|
+
|
|
37
112
|
export const Default: Story = {
|
|
113
|
+
tags: ['test'],
|
|
38
114
|
args: {
|
|
39
|
-
|
|
115
|
+
onAction: fn(),
|
|
116
|
+
} as any,
|
|
117
|
+
render: (args: any) => <DefaultStory onAction={args.onAction} />,
|
|
118
|
+
play: async ({ args, canvasElement }) => {
|
|
119
|
+
const canvas = within(canvasElement);
|
|
120
|
+
|
|
121
|
+
// Verify the navbar renders with the toolbar.
|
|
122
|
+
await expect(canvas.getByRole('toolbar')).toBeInTheDocument();
|
|
123
|
+
|
|
124
|
+
// Test companion action click (Browse button).
|
|
125
|
+
const browseButton = canvas.getByRole('button', { name: /browse/i });
|
|
126
|
+
await expect(browseButton).toBeInTheDocument();
|
|
127
|
+
await userEvent.click(browseButton);
|
|
128
|
+
await expect(args.onAction).toHaveBeenCalledTimes(1);
|
|
129
|
+
await expect((args.onAction as Mock).mock.calls[0][0]).toHaveProperty('id', 'companion-browse');
|
|
130
|
+
|
|
131
|
+
// Test dropdown menu opens and action fires.
|
|
132
|
+
const menuTrigger = canvas.getByRole('button', { name: /main menu/i });
|
|
133
|
+
await expect(menuTrigger).toBeInTheDocument();
|
|
134
|
+
await userEvent.click(menuTrigger);
|
|
135
|
+
|
|
136
|
+
// Wait for menu to open and click an action (menu items render in a portal).
|
|
137
|
+
const createSpaceAction = await screen.findByRole('menuitem', { name: /create space/i });
|
|
138
|
+
await userEvent.click(createSpaceAction);
|
|
139
|
+
await expect(args.onAction).toHaveBeenCalledTimes(2);
|
|
140
|
+
await expect((args.onAction as Mock).mock.calls[1][0]).toHaveProperty('id', 'action-create-space');
|
|
40
141
|
},
|
|
41
142
|
};
|
|
42
143
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
144
|
+
const CompanionsOnlyStory = () => {
|
|
145
|
+
const actions = useMemo(() => Atom.make(buildCompanionOnlyActions()).pipe(Atom.keepAlive), []);
|
|
146
|
+
|
|
147
|
+
return <NavBar actions={actions} onAction={(action) => console.log('Action:', action.id)} />;
|
|
47
148
|
};
|
|
48
149
|
|
|
49
|
-
export const
|
|
50
|
-
args: {
|
|
51
|
-
|
|
52
|
-
},
|
|
150
|
+
export const CompanionsOnly: Story = {
|
|
151
|
+
args: {} as any,
|
|
152
|
+
render: () => <CompanionsOnlyStory />,
|
|
53
153
|
};
|
|
54
154
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
155
|
+
const EmptyStory = () => {
|
|
156
|
+
const actions = useMemo(() => Atom.make(buildEmptyActions()).pipe(Atom.keepAlive), []);
|
|
157
|
+
|
|
158
|
+
return <NavBar actions={actions} onAction={(action) => console.log('Action:', action.id)} />;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const Empty: Story = {
|
|
162
|
+
args: {} as any,
|
|
163
|
+
render: () => <EmptyStory />,
|
|
59
164
|
};
|
|
@@ -2,73 +2,32 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type Atom } from '@effect-atom/atom-react';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { IconButton, type ThemedClassName, Toolbar, Tooltip, useTranslation } from '@dxos/react-ui';
|
|
10
|
-
import { DropdownMenu, MenuProvider } from '@dxos/react-ui-menu';
|
|
11
|
-
import { mx } from '@dxos/ui-theme';
|
|
8
|
+
import { type ActionExecutor, type ActionGraphProps, Menu, useMenuActions } from '@dxos/react-ui-menu';
|
|
9
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
const NAVBAR_NAME = 'SimpleLayout.NavBar';
|
|
14
12
|
|
|
15
|
-
export type NavBarProps =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const { t } = useTranslation(meta.id);
|
|
22
|
-
const { graph } = useAppGraph();
|
|
23
|
-
const runAction = useActionRunner();
|
|
24
|
-
|
|
25
|
-
const connections = useConnections(graph, Node.RootId);
|
|
26
|
-
const menuActions = connections.filter((node) => node.properties.disposition === 'menu');
|
|
13
|
+
export type NavBarProps = {
|
|
14
|
+
/** Action graph atom for the toolbar. */
|
|
15
|
+
actions: Atom.Atom<ActionGraphProps>;
|
|
16
|
+
/** Action executor callback. */
|
|
17
|
+
onAction?: ActionExecutor;
|
|
18
|
+
};
|
|
27
19
|
|
|
28
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Presentational navbar component that renders a toolbar from an action graph.
|
|
22
|
+
*/
|
|
23
|
+
export const NavBar = composable<HTMLDivElement, NavBarProps>(({ actions, onAction, ...props }, forwardedRef) => {
|
|
24
|
+
const menuActions = useMenuActions(actions);
|
|
29
25
|
|
|
30
26
|
return (
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
<Tooltip.Trigger asChild content={t('app menu label')}>
|
|
35
|
-
<DropdownMenu.Trigger asChild data-testid='spacePlugin.addSpace'>
|
|
36
|
-
<IconButton icon='ph--plus--regular' iconOnly label={t('main menu label')} />
|
|
37
|
-
</DropdownMenu.Trigger>
|
|
38
|
-
</Tooltip.Trigger>
|
|
39
|
-
</DropdownMenu.Root>
|
|
40
|
-
</MenuProvider>
|
|
41
|
-
{/*
|
|
42
|
-
<ButtonGroup>
|
|
43
|
-
<IconButton
|
|
44
|
-
{...buttonProps}
|
|
45
|
-
label={t('browse label')}
|
|
46
|
-
icon='ph--squares-four--regular'
|
|
47
|
-
onClick={() => onActiveIdChange?.(null)}
|
|
48
|
-
variant={isBrowseActive ? 'primary' : 'default'}
|
|
49
|
-
{...(isBrowseActive && { 'aria-current': 'location' })}
|
|
50
|
-
/>
|
|
51
|
-
<IconButton
|
|
52
|
-
{...buttonProps}
|
|
53
|
-
label={t('notifications label')}
|
|
54
|
-
icon='ph--bell-simple--regular'
|
|
55
|
-
onClick={() => onActiveIdChange?.('notifications')}
|
|
56
|
-
variant={activeId === 'notifications' ? 'primary' : 'default'}
|
|
57
|
-
{...(activeId === 'notifications' && { 'aria-current': 'location' })}
|
|
58
|
-
/>
|
|
59
|
-
<Button
|
|
60
|
-
variant={activeId === 'profile' ? 'primary' : 'default'}
|
|
61
|
-
onClick={() => onActiveIdChange?.('profile')}
|
|
62
|
-
classNames={buttonProps.classNames}
|
|
63
|
-
>
|
|
64
|
-
<span className='sr-only'>{t('profile label')}</span>
|
|
65
|
-
<Avatar.Root>
|
|
66
|
-
<Avatar.Label classNames='sr-only'>Profile display name</Avatar.Label>
|
|
67
|
-
<Avatar.Content size={8} status='active' hue='cyan' fallback='🗿' />
|
|
68
|
-
</Avatar.Root>
|
|
69
|
-
</Button>
|
|
70
|
-
</ButtonGroup>
|
|
71
|
-
*/}
|
|
72
|
-
</Toolbar.Root>
|
|
27
|
+
<Menu.Root {...menuActions} alwaysActive onAction={onAction}>
|
|
28
|
+
<Menu.Toolbar {...composableProps(props)} ref={forwardedRef} />
|
|
29
|
+
</Menu.Root>
|
|
73
30
|
);
|
|
74
|
-
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
NavBar.displayName = NAVBAR_NAME;
|