@dxos/plugin-simple-layout 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b
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-GPTKI5H2.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-TCUSDIN2.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/react-root.d.ts → react-root.d.ts} +1 -1
- package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -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.d.ts +19 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler.d.ts +12 -0
- package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
- package/dist/types/src/components/ContentError.stories.d.ts +27 -22
- 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 -32
- 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 +8 -7
- package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
- package/src/components/DebugOverlay/index.ts +5 -0
- package/src/components/Dialog/Dialog.tsx +15 -4
- package/src/components/Home/Home.tsx +38 -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 +38 -30
- package/src/components/MobileLayout/MobileLayout.tsx +118 -51
- package/src/components/{Workspace/Workspace.tsx → NavBranch/NavBranch.tsx} +44 -39
- package/src/components/{Workspace → NavBranch}/index.ts +1 -1
- package/src/components/Popover/Popover.tsx +12 -8
- package/src/components/SimpleLayout/AppBar.stories.tsx +12 -12
- package/src/components/SimpleLayout/AppBar.tsx +56 -63
- package/src/components/SimpleLayout/Drawer.tsx +38 -36
- package/src/components/SimpleLayout/Main.tsx +22 -25
- package/src/components/SimpleLayout/NavBar.stories.tsx +9 -9
- package/src/components/SimpleLayout/NavBar.tsx +10 -17
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +48 -71
- 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 +20 -19
- package/src/hooks/useAppBarProps.ts +15 -32
- package/src/hooks/useCompanions.ts +1 -1
- package/src/hooks/useDrawerActions.ts +16 -14
- package/src/hooks/useNavbarActions.ts +14 -13
- 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-O3BQBYMW.mjs +0 -1165
- package/dist/lib/browser/chunk-O3BQBYMW.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-GPTKI5H2.mjs.map +0 -7
- package/dist/lib/browser/react-surface-LT5JJTPR.mjs +0 -41
- package/dist/lib/browser/react-surface-LT5JJTPR.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-UAWM4B2S.mjs +0 -1166
- package/dist/lib/node-esm/chunk-UAWM4B2S.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-GRG2OAI2.mjs +0 -22
- package/dist/lib/node-esm/react-root-GRG2OAI2.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-TCUSDIN2.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 +0 -5
- 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 +0 -19
- 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 +0 -12
- package/dist/types/src/capabilities/url-handler/url-handler.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/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/components/ContentError.tsx +0 -23
- package/src/types/events.ts +0 -15
- /package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +0 -0
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
9
|
import { AlertDialog, Dialog as NaturalDialog } from '@dxos/react-ui';
|
|
10
|
+
import { ErrorFallback } from '@dxos/react-ui';
|
|
9
11
|
|
|
10
|
-
import { useSimpleLayoutState } from '
|
|
11
|
-
import { ContentError } from '../ContentError';
|
|
12
|
+
import { useSimpleLayoutState } from '#hooks';
|
|
12
13
|
|
|
13
14
|
export const Dialog = () => {
|
|
14
15
|
const { state, updateState } = useSimpleLayoutState();
|
|
@@ -23,14 +24,24 @@ export const Dialog = () => {
|
|
|
23
24
|
onOpenChange={(nextOpen) => updateState((state) => ({ ...state, dialogOpen: nextOpen }))}
|
|
24
25
|
>
|
|
25
26
|
{state.dialogBlockAlign === 'end' ? (
|
|
26
|
-
<Surface.Surface
|
|
27
|
+
<Surface.Surface
|
|
28
|
+
type={AppSurface.Dialog}
|
|
29
|
+
data={state.dialogContent ?? undefined}
|
|
30
|
+
limit={1}
|
|
31
|
+
fallback={ErrorFallback}
|
|
32
|
+
/>
|
|
27
33
|
) : (
|
|
28
34
|
<DialogOverlay
|
|
29
35
|
blockAlign={state.dialogBlockAlign}
|
|
30
36
|
classNames={state.dialogOverlayClasses}
|
|
31
37
|
style={state.dialogOverlayStyle}
|
|
32
38
|
>
|
|
33
|
-
<Surface.Surface
|
|
39
|
+
<Surface.Surface
|
|
40
|
+
type={AppSurface.Dialog}
|
|
41
|
+
data={state.dialogContent ?? undefined}
|
|
42
|
+
limit={1}
|
|
43
|
+
fallback={ErrorFallback}
|
|
44
|
+
/>
|
|
34
45
|
</DialogOverlay>
|
|
35
46
|
)}
|
|
36
47
|
</DialogRoot>
|
|
@@ -8,14 +8,16 @@ import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
|
8
8
|
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
9
9
|
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
10
10
|
import { Node, useConnections } from '@dxos/plugin-graph';
|
|
11
|
-
import { Avatar, Icon,
|
|
12
|
-
import { Card
|
|
13
|
-
import {
|
|
11
|
+
import { Avatar, Icon, ScrollArea, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { Card } from '@dxos/react-ui';
|
|
13
|
+
import { Mosaic, type MosaicStackTileComponent } from '@dxos/react-ui-mosaic';
|
|
14
|
+
import { SearchPanel, useSearchListItem, useSearchListResults } from '@dxos/react-ui-search';
|
|
14
15
|
import { mx } from '@dxos/ui-theme';
|
|
15
|
-
import { byPosition } from '@dxos/util';
|
|
16
|
+
import { byPosition, getHostPlatform, isTauri } from '@dxos/util';
|
|
16
17
|
|
|
17
|
-
import { meta } from '
|
|
18
|
-
|
|
18
|
+
import { meta } from '#meta';
|
|
19
|
+
|
|
20
|
+
import { useExpandPath } from '../hooks';
|
|
19
21
|
|
|
20
22
|
export type HomeProps = {};
|
|
21
23
|
|
|
@@ -27,7 +29,7 @@ export const Home = (_: HomeProps) => {
|
|
|
27
29
|
const userAccountItem = useItemsByDisposition('user-account')[0];
|
|
28
30
|
const pinnedItems = useItemsByDisposition('pin-end', true);
|
|
29
31
|
const workspaceItems = useItemsByDisposition('workspace');
|
|
30
|
-
|
|
32
|
+
useExpandPath(Node.RootId);
|
|
31
33
|
|
|
32
34
|
const items = useMemo(
|
|
33
35
|
() => [...(userAccountItem ? [userAccountItem] : []), ...pinnedItems, ...workspaceItems],
|
|
@@ -39,27 +41,29 @@ export const Home = (_: HomeProps) => {
|
|
|
39
41
|
extract: (node) => toLocalizedString(node.properties.label, t),
|
|
40
42
|
});
|
|
41
43
|
|
|
44
|
+
const autoFocus = !isTauri() || getHostPlatform() !== 'ios';
|
|
45
|
+
|
|
42
46
|
return (
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
</Layout.Main>
|
|
47
|
+
<SearchPanel onSearch={handleSearch}>
|
|
48
|
+
<Mosaic.Container asChild>
|
|
49
|
+
<ScrollArea.Root centered padding thin>
|
|
50
|
+
<ScrollArea.Viewport>
|
|
51
|
+
<Mosaic.Stack
|
|
52
|
+
classNames='gap-1'
|
|
53
|
+
draggable={false}
|
|
54
|
+
items={results}
|
|
55
|
+
getId={(item) => item.id}
|
|
56
|
+
Tile={WorkspaceTile}
|
|
57
|
+
/>
|
|
58
|
+
</ScrollArea.Viewport>
|
|
59
|
+
</ScrollArea.Root>
|
|
60
|
+
</Mosaic.Container>
|
|
61
|
+
</SearchPanel>
|
|
59
62
|
);
|
|
60
63
|
};
|
|
61
64
|
|
|
62
|
-
const WorkspaceTile:
|
|
65
|
+
const WorkspaceTile: MosaicStackTileComponent<Node.Node> = (props) => {
|
|
66
|
+
const data = props.data;
|
|
63
67
|
const { t } = useTranslation(meta.id);
|
|
64
68
|
const { invokePromise } = useOperationInvoker();
|
|
65
69
|
const { selectedValue, registerItem, unregisterItem } = useSearchListItem();
|
|
@@ -67,7 +71,7 @@ const WorkspaceTile: StackTileComponent<Node.Node> = ({ data }) => {
|
|
|
67
71
|
const isSelected = selectedValue === data.id;
|
|
68
72
|
const cardRef = useRef<HTMLDivElement>(null);
|
|
69
73
|
|
|
70
|
-
|
|
74
|
+
useExpandPath(data.id);
|
|
71
75
|
|
|
72
76
|
const handleSelect = useCallback(
|
|
73
77
|
() => invokePromise(LayoutOperation.SwitchWorkspace, { subject: data.id }),
|
|
@@ -96,21 +100,21 @@ const WorkspaceTile: StackTileComponent<Node.Node> = ({ data }) => {
|
|
|
96
100
|
fullWidth
|
|
97
101
|
tabIndex={-1} // TODO(burdon): Use Mosaic.Focus.
|
|
98
102
|
data-selected={isSelected}
|
|
99
|
-
classNames={mx('dx-focus-ring', isSelected && 'bg-
|
|
103
|
+
classNames={mx('dx-focus-ring', isSelected && 'bg-hover-overlay')}
|
|
100
104
|
onClick={handleSelect}
|
|
101
105
|
ref={cardRef}
|
|
102
106
|
>
|
|
103
|
-
<Card.Toolbar density='
|
|
107
|
+
<Card.Toolbar density='fine'>
|
|
104
108
|
<Avatar.Root>
|
|
105
109
|
<Avatar.Content
|
|
106
110
|
icon={data.properties.icon}
|
|
107
111
|
hue={data.properties.hue}
|
|
108
112
|
hueVariant='transparent'
|
|
109
113
|
variant='square'
|
|
110
|
-
size={
|
|
114
|
+
size={8}
|
|
111
115
|
fallback={name}
|
|
112
116
|
/>
|
|
113
|
-
<Avatar.Label>{name}</Avatar.Label>
|
|
117
|
+
<Avatar.Label classNames='cursor-pointer'>{name}</Avatar.Label>
|
|
114
118
|
<Icon icon='ph--caret-right--regular' />
|
|
115
119
|
</Avatar.Root>
|
|
116
120
|
</Card.Toolbar>
|
|
@@ -126,7 +130,9 @@ const filterItems = (node: Node.Node, disposition: string) => {
|
|
|
126
130
|
/** Returns root-level items filtered by disposition. */
|
|
127
131
|
const useItemsByDisposition = (disposition: string, sort = false) => {
|
|
128
132
|
const { graph } = useAppGraph();
|
|
129
|
-
const connections = useConnections(graph, Node.RootId);
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
const connections = useConnections(graph, Node.RootId, 'child');
|
|
134
|
+
return useMemo(() => {
|
|
135
|
+
const filtered = connections.filter((node) => filterItems(node, disposition));
|
|
136
|
+
return sort ? filtered.toSorted((a, b) => byPosition(a.properties, b.properties)) : filtered;
|
|
137
|
+
}, [connections, disposition, sort]);
|
|
132
138
|
};
|
|
@@ -6,16 +6,16 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
|
|
7
7
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { Loading } from './Loading';
|
|
10
10
|
|
|
11
11
|
const meta = {
|
|
12
|
-
title: 'plugins/plugin-simple-layout/
|
|
13
|
-
component:
|
|
12
|
+
title: 'plugins/plugin-simple-layout/components/Loading',
|
|
13
|
+
component: Loading,
|
|
14
14
|
decorators: [withTheme()],
|
|
15
15
|
parameters: {
|
|
16
16
|
layout: 'centered',
|
|
17
17
|
},
|
|
18
|
-
} satisfies Meta<typeof
|
|
18
|
+
} satisfies Meta<typeof Loading>;
|
|
19
19
|
|
|
20
20
|
export default meta;
|
|
21
21
|
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
// TODO(burdon): Show skeleton: https://github.com/dxos/dxos/issues/8259
|
|
8
|
-
export const
|
|
9
|
-
return <div
|
|
8
|
+
export const Loading = () => {
|
|
9
|
+
return <div className='grid place-items-center dx-attention-surface' />;
|
|
10
10
|
};
|
|
@@ -6,7 +6,7 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import React, { type PropsWithChildren, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { addEventListener, combine } from '@dxos/async';
|
|
9
|
-
import { Flex, Input,
|
|
9
|
+
import { Column, Flex, Input, Panel, Splitter, type SplitterMode, Toolbar } from '@dxos/react-ui';
|
|
10
10
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
11
|
|
|
12
12
|
import { MobileLayout, type MobileLayoutRootProps } from './MobileLayout';
|
|
@@ -54,52 +54,60 @@ const WithKeyboard = ({ children }: PropsWithChildren) => {
|
|
|
54
54
|
return <div className='h-screen relative'>{children}</div>;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
const
|
|
57
|
+
const StoryPanel = ({ children, label }: PropsWithChildren<{ label: string }>) => {
|
|
58
58
|
return (
|
|
59
|
-
<
|
|
60
|
-
<Toolbar
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
<Panel.Root>
|
|
60
|
+
<Panel.Toolbar asChild>
|
|
61
|
+
<Toolbar.Root>
|
|
62
|
+
{label}
|
|
63
|
+
<Toolbar.Separator />
|
|
64
|
+
{children}
|
|
65
|
+
</Toolbar.Root>
|
|
66
|
+
</Panel.Toolbar>
|
|
67
|
+
<Panel.Content asChild>
|
|
68
|
+
<Column.Root gutter='xs' classNames='py-form-chrome'>
|
|
69
|
+
<Column.Center>
|
|
70
|
+
<Flex column>
|
|
71
|
+
<Input.Root>
|
|
72
|
+
<Input.TextInput placeholder={label} />
|
|
73
|
+
</Input.Root>
|
|
74
|
+
</Flex>
|
|
75
|
+
</Column.Center>
|
|
76
|
+
</Column.Root>
|
|
77
|
+
</Panel.Content>
|
|
78
|
+
</Panel.Root>
|
|
71
79
|
);
|
|
72
80
|
};
|
|
73
81
|
|
|
74
82
|
const DefaultStory = () => {
|
|
75
|
-
const [splitterMode, setSplitterMode] = useState<SplitterMode>('
|
|
83
|
+
const [splitterMode, setSplitterMode] = useState<SplitterMode>('top');
|
|
76
84
|
const [keyboardOpen, setKeyboardOpen] = useState(false);
|
|
77
85
|
|
|
78
86
|
useEffect(() => {
|
|
79
|
-
setSplitterMode(splitterMode === '
|
|
87
|
+
setSplitterMode(splitterMode === 'split' ? 'bottom' : splitterMode);
|
|
80
88
|
}, [keyboardOpen]);
|
|
81
89
|
|
|
82
90
|
return (
|
|
83
91
|
<WithKeyboard>
|
|
84
92
|
<MobileLayout.Root onKeyboardOpenChange={setKeyboardOpen}>
|
|
85
|
-
<MobileLayout.Panel safe={{ top: true, bottom: splitterMode === '
|
|
93
|
+
<MobileLayout.Panel safe={{ top: true, bottom: splitterMode === 'top' }}>
|
|
86
94
|
<Splitter.Root mode={splitterMode} ratio={0.5}>
|
|
87
|
-
<Splitter.Panel position='
|
|
88
|
-
<
|
|
89
|
-
{splitterMode === '
|
|
90
|
-
<Toolbar.IconButton icon='ph--plus--regular' label='Open' onClick={() => setSplitterMode('
|
|
95
|
+
<Splitter.Panel position='top'>
|
|
96
|
+
<StoryPanel label='Main'>
|
|
97
|
+
{splitterMode === 'top' && (
|
|
98
|
+
<Toolbar.IconButton icon='ph--plus--regular' label='Open' onClick={() => setSplitterMode('split')} />
|
|
91
99
|
)}
|
|
92
|
-
</
|
|
100
|
+
</StoryPanel>
|
|
93
101
|
</Splitter.Panel>
|
|
94
|
-
<Splitter.Panel position='
|
|
95
|
-
<
|
|
102
|
+
<Splitter.Panel position='bottom'>
|
|
103
|
+
<StoryPanel label='Drawer'>
|
|
96
104
|
<Toolbar.IconButton
|
|
97
|
-
icon={splitterMode === '
|
|
98
|
-
label={splitterMode === '
|
|
99
|
-
onClick={() => setSplitterMode((splitterMode) => (splitterMode === '
|
|
105
|
+
icon={splitterMode === 'bottom' ? 'ph--arrow-down--regular' : 'ph--arrow-up--regular'}
|
|
106
|
+
label={splitterMode === 'bottom' ? 'Collapse' : 'Expand'}
|
|
107
|
+
onClick={() => setSplitterMode((splitterMode) => (splitterMode === 'split' ? 'bottom' : 'split'))}
|
|
100
108
|
/>
|
|
101
|
-
<Toolbar.IconButton icon='ph--x--regular' label='Close' onClick={() => setSplitterMode('
|
|
102
|
-
</
|
|
109
|
+
<Toolbar.IconButton icon='ph--x--regular' label='Close' onClick={() => setSplitterMode('top')} />
|
|
110
|
+
</StoryPanel>
|
|
103
111
|
</Splitter.Panel>
|
|
104
112
|
</Splitter.Root>
|
|
105
113
|
</MobileLayout.Panel>
|
|
@@ -109,7 +117,7 @@ const DefaultStory = () => {
|
|
|
109
117
|
};
|
|
110
118
|
|
|
111
119
|
const meta: Meta<MobileLayoutRootProps> = {
|
|
112
|
-
title: 'plugins/plugin-simple-layout/MobileLayout',
|
|
120
|
+
title: 'plugins/plugin-simple-layout/components/MobileLayout',
|
|
113
121
|
component: MobileLayout.Root,
|
|
114
122
|
render: DefaultStory,
|
|
115
123
|
decorators: [withTheme(), withLayout({ layout: 'column', classNames: 'relative' })],
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { createContext } from '@radix-ui/react-context';
|
|
6
|
-
import React, { type PropsWithChildren, forwardRef, useEffect, useState } from 'react';
|
|
6
|
+
import React, { type PropsWithChildren, forwardRef, useEffect, useLayoutEffect, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { addEventListener, combine } from '@dxos/async';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
11
|
import { mx } from '@dxos/ui-theme';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
import { useDebugLog } from '../DebugOverlay';
|
|
14
14
|
|
|
15
15
|
const MOBILE_LAYOUT_NAME = 'MobileLayout';
|
|
16
16
|
const MOBILE_LAYOUT_ROOT_NAME = 'MobileLayout.Root';
|
|
@@ -42,22 +42,26 @@ type MobileLayoutRootProps = ThemedClassName<
|
|
|
42
42
|
*/
|
|
43
43
|
// TODO(burdon): Should this be ios-only?
|
|
44
44
|
const MobileLayoutRoot = forwardRef<HTMLDivElement, MobileLayoutRootProps>(
|
|
45
|
-
({ classNames, children, transition =
|
|
45
|
+
({ classNames, children, transition = 500, onKeyboardOpenChange, ...props }, forwardedRef) => {
|
|
46
46
|
const { open: keyboardOpen } = useIOSKeyboard();
|
|
47
|
-
useAutoScroll();
|
|
48
|
-
useEffect(() => onKeyboardOpenChange?.(keyboardOpen), [onKeyboardOpenChange, keyboardOpen]);
|
|
49
47
|
useLockBodyScroll(keyboardOpen);
|
|
48
|
+
useAutoScroll();
|
|
49
|
+
|
|
50
|
+
// Fire synchronously after DOM mutation (before paint) so SimpleLayout's Splitter mode
|
|
51
|
+
// change is batched into the same paint as the keyboard open state change, preventing
|
|
52
|
+
// intermediate render frames from showing an un-adjusted layout.
|
|
53
|
+
useLayoutEffect(() => onKeyboardOpenChange?.(keyboardOpen), [keyboardOpen, onKeyboardOpenChange]);
|
|
50
54
|
|
|
51
55
|
return (
|
|
52
56
|
<MobileLayoutProvider keyboardOpen={keyboardOpen}>
|
|
53
57
|
<div
|
|
54
58
|
{...props}
|
|
55
|
-
role='none'
|
|
56
59
|
style={{
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
height: 'calc(100vh - var(--kb-height, 0px))',
|
|
61
|
+
transition: `height ${keyboardOpen ? 0 : transition}ms ease-out`,
|
|
62
|
+
// transition: `height ${animationDuration}ms ease-out`,
|
|
59
63
|
}}
|
|
60
|
-
className={mx('
|
|
64
|
+
className={mx('fixed top-0 left-0 right-0 grid overflow-hidden', classNames)}
|
|
61
65
|
ref={forwardedRef}
|
|
62
66
|
>
|
|
63
67
|
{children}
|
|
@@ -90,12 +94,11 @@ const MobileLayoutPanel = forwardRef<HTMLDivElement, MobileLayoutPanelProps>(
|
|
|
90
94
|
return (
|
|
91
95
|
<div
|
|
92
96
|
{...props}
|
|
93
|
-
role='none'
|
|
94
97
|
style={{
|
|
95
98
|
paddingTop: safe?.top ? 'env(safe-area-inset-top)' : undefined,
|
|
96
99
|
paddingBottom: safe?.bottom ? `calc((1 - var(--kb-open, 0)) * env(safe-area-inset-bottom))` : undefined,
|
|
97
100
|
}}
|
|
98
|
-
className={mx(
|
|
101
|
+
className={mx(classNames)}
|
|
99
102
|
ref={forwardedRef}
|
|
100
103
|
>
|
|
101
104
|
{children}
|
|
@@ -120,42 +123,62 @@ export { useMobileLayout };
|
|
|
120
123
|
export type { MobileLayoutRootProps, MobileLayoutPanelProps };
|
|
121
124
|
|
|
122
125
|
/**
|
|
123
|
-
*
|
|
126
|
+
* Prevents iOS (WKWebView) from shifting the layout when the keyboard appears.
|
|
127
|
+
*
|
|
128
|
+
* Scroll events and window.scrollY stay at 0 in this WKWebView setup — the shift is
|
|
129
|
+
* caused by the browser's scroll-into-view for the focused input. We keep a window
|
|
130
|
+
* scroll reset as belt-and-suspenders, and also monitor container scroll events.
|
|
124
131
|
*/
|
|
125
132
|
const useAutoScroll = () => {
|
|
133
|
+
// TODO(burdon): Remove debug logging.
|
|
134
|
+
const { dbg } = useDebugLog('useAutoScroll');
|
|
135
|
+
|
|
126
136
|
useEffect(() => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
137
|
+
const resetScroll = () => {
|
|
138
|
+
if (window.scrollX !== 0 || window.scrollY !== 0) {
|
|
139
|
+
window.scrollTo(0, 0);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const detectContainerScroll = (event: Event) => {
|
|
144
|
+
const el = event.target as HTMLElement;
|
|
145
|
+
if (el === document.documentElement || el === document.body) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
dbg(`scroll: ${el.tagName}.${Array.from(el.classList).slice(0, 2).join('.')} top=${el.scrollTop.toFixed(0)}`);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
return combine(
|
|
153
|
+
addEventListener(window, 'scroll', resetScroll),
|
|
154
|
+
window.visualViewport ? addEventListener(window.visualViewport, 'scroll' as any, resetScroll) : () => {},
|
|
155
|
+
|
|
156
|
+
// TODO(burdon): Remove debug logging.
|
|
157
|
+
addEventListener(document, 'scroll', detectContainerScroll as EventListener, { capture: true } as any),
|
|
158
|
+
|
|
159
|
+
// Prevent focus-triggered scroll-into-view on inputs.
|
|
160
|
+
(() => {
|
|
161
|
+
let focusingWithPreventScroll = false;
|
|
162
|
+
return addEventListener(
|
|
163
|
+
document,
|
|
164
|
+
'focus',
|
|
165
|
+
(event: FocusEvent) => {
|
|
166
|
+
if (focusingWithPreventScroll) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const target = event.target as HTMLElement;
|
|
171
|
+
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {
|
|
172
|
+
focusingWithPreventScroll = true;
|
|
173
|
+
target.focus({ preventScroll: true });
|
|
174
|
+
focusingWithPreventScroll = false;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
{ capture: true },
|
|
178
|
+
);
|
|
179
|
+
})(),
|
|
157
180
|
);
|
|
158
|
-
}, []);
|
|
181
|
+
}, [dbg]);
|
|
159
182
|
};
|
|
160
183
|
|
|
161
184
|
/**
|
|
@@ -231,6 +254,8 @@ const useLockBodyScroll = (enabled: boolean) => {
|
|
|
231
254
|
type IOSKeyboard = {
|
|
232
255
|
open: boolean;
|
|
233
256
|
height: number;
|
|
257
|
+
/** Native keyboard animation duration in ms, from the iOS keyboard event. */
|
|
258
|
+
duration: number | undefined;
|
|
234
259
|
};
|
|
235
260
|
|
|
236
261
|
/**
|
|
@@ -263,10 +288,13 @@ type IOSKeyboard = {
|
|
|
263
288
|
* Falls back to VisualViewport API on other platforms.
|
|
264
289
|
*/
|
|
265
290
|
const useIOSKeyboard = (): IOSKeyboard => {
|
|
291
|
+
const { dbg } = useDebugLog('useIOSKeyboard');
|
|
292
|
+
|
|
266
293
|
const [open, setOpen] = useState(false);
|
|
267
294
|
const [height, setHeight] = useState(0);
|
|
295
|
+
const [duration, setDuration] = useState<number | undefined>(undefined);
|
|
268
296
|
|
|
269
|
-
// Detect
|
|
297
|
+
// Detect keyboard state.
|
|
270
298
|
useEffect(() => {
|
|
271
299
|
const viewport = window.visualViewport;
|
|
272
300
|
if (!viewport) {
|
|
@@ -276,30 +304,69 @@ const useIOSKeyboard = (): IOSKeyboard => {
|
|
|
276
304
|
// Handler for VisualViewport resize (fallback for non-iOS).
|
|
277
305
|
const initialHeight = viewport.height ?? window.innerHeight;
|
|
278
306
|
|
|
279
|
-
const updateState = (keyboardHeight: number, keyboardOpen: boolean) => {
|
|
307
|
+
const updateState = (keyboardHeight: number, keyboardOpen: boolean, animationDuration?: number) => {
|
|
280
308
|
setOpen(keyboardOpen);
|
|
281
309
|
setHeight(keyboardHeight);
|
|
310
|
+
setDuration(animationDuration);
|
|
282
311
|
|
|
283
312
|
const vvh = initialHeight - keyboardHeight;
|
|
284
313
|
document.documentElement.style.setProperty('--vvh', `${vvh}px`);
|
|
285
314
|
document.documentElement.style.setProperty('--kb-height', `${keyboardHeight}px`);
|
|
286
315
|
document.documentElement.style.setProperty('--kb-open', keyboardOpen ? '1' : '0');
|
|
287
|
-
log.info('viewport size', { initialHeight, vvh, keyboardHeight, keyboardOpen });
|
|
316
|
+
log.info('viewport size', { initialHeight, vvh, keyboardHeight, keyboardOpen, animationDuration });
|
|
288
317
|
};
|
|
289
318
|
|
|
319
|
+
let rafId: number | undefined;
|
|
320
|
+
|
|
290
321
|
return combine(
|
|
291
322
|
// Handler for native iOS keyboard events (from KeyboardObserver.swift).
|
|
292
323
|
addEventListener(
|
|
293
324
|
window,
|
|
294
325
|
'keyboard' as any,
|
|
295
326
|
(event: CustomEvent<{ type: 'show' | 'hide'; height: number; duration: number }>) => {
|
|
296
|
-
const { type, height } = event.detail;
|
|
297
|
-
|
|
298
|
-
|
|
327
|
+
const { type, height, duration } = event.detail;
|
|
328
|
+
// iOS KeyboardObserver.swift sends duration in seconds (e.g., 0.25). Convert to ms.
|
|
329
|
+
const durationMs = duration < 1 ? duration * 1000 : duration;
|
|
330
|
+
|
|
331
|
+
// TODO(burdon): Remove debug logging.
|
|
332
|
+
const vp = window.visualViewport;
|
|
333
|
+
dbg(
|
|
334
|
+
`kb:${type} h=${height} dur=${duration} scrollY=${window.scrollY} vpOffset=${vp?.offsetTop?.toFixed(0) ?? '?'}`,
|
|
335
|
+
);
|
|
336
|
+
log.info('keyboard event', { type, height, duration });
|
|
337
|
+
|
|
338
|
+
updateState(height, type === 'show', durationMs);
|
|
339
|
+
|
|
340
|
+
// RAF loop: monitor visualViewport.offsetTop and window.scrollY every frame.
|
|
341
|
+
// TODO(burdon): Remove debug logging.
|
|
342
|
+
const end = performance.now() + durationMs + 300;
|
|
343
|
+
let prevOffsetTop = vp?.offsetTop ?? 0;
|
|
344
|
+
let prevScrollY = window.scrollY;
|
|
345
|
+
const monitorFrame = () => {
|
|
346
|
+
const offsetTop = vp?.offsetTop ?? 0;
|
|
347
|
+
const scrollY = window.scrollY;
|
|
348
|
+
if (offsetTop !== prevOffsetTop || scrollY !== prevScrollY) {
|
|
349
|
+
dbg(`Δ vpOffset=${offsetTop.toFixed(0)} scrollY=${scrollY.toFixed(0)}`);
|
|
350
|
+
prevOffsetTop = offsetTop;
|
|
351
|
+
prevScrollY = scrollY;
|
|
352
|
+
}
|
|
353
|
+
if (scrollY !== 0) {
|
|
354
|
+
window.scrollTo(0, 0);
|
|
355
|
+
}
|
|
356
|
+
if (performance.now() < end) {
|
|
357
|
+
rafId = requestAnimationFrame(monitorFrame);
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
rafId = requestAnimationFrame(monitorFrame);
|
|
299
361
|
},
|
|
300
362
|
),
|
|
363
|
+
() => {
|
|
364
|
+
if (rafId !== undefined) {
|
|
365
|
+
cancelAnimationFrame(rafId);
|
|
366
|
+
}
|
|
367
|
+
},
|
|
301
368
|
);
|
|
302
|
-
}, []);
|
|
369
|
+
}, [dbg]);
|
|
303
370
|
|
|
304
|
-
return { open, height };
|
|
371
|
+
return { open, height, duration };
|
|
305
372
|
};
|