@flamingo-stack/openframe-frontend-core 0.0.389 → 0.0.390-snapshot.20260709094308
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/{chunk-VXJBE5NX.cjs → chunk-2LHLX7GH.cjs} +59 -59
- package/dist/{chunk-VXJBE5NX.cjs.map → chunk-2LHLX7GH.cjs.map} +1 -1
- package/dist/{chunk-WIMXB5EU.js → chunk-3ML4WLFP.js} +4 -4
- package/dist/{chunk-7MKU2EB4.cjs → chunk-5SBJ77M7.cjs} +26 -26
- package/dist/{chunk-7MKU2EB4.cjs.map → chunk-5SBJ77M7.cjs.map} +1 -1
- package/dist/{chunk-BJPQJNSC.js → chunk-7W3B6ZGK.js} +4 -4
- package/dist/{chunk-2JCSORCJ.cjs → chunk-BIWPZS54.cjs} +26 -26
- package/dist/{chunk-2JCSORCJ.cjs.map → chunk-BIWPZS54.cjs.map} +1 -1
- package/dist/{chunk-ZFZAHLI4.cjs → chunk-C5BJFGOU.cjs} +7 -7
- package/dist/{chunk-ZFZAHLI4.cjs.map → chunk-C5BJFGOU.cjs.map} +1 -1
- package/dist/{chunk-3JQUNKWY.cjs → chunk-CLXHPRN2.cjs} +15 -15
- package/dist/{chunk-3JQUNKWY.cjs.map → chunk-CLXHPRN2.cjs.map} +1 -1
- package/dist/{chunk-KA4WXCN3.js → chunk-DRWFCYDM.js} +4 -4
- package/dist/{chunk-CQXHHVMR.js → chunk-DV5O2VU7.js} +2 -2
- package/dist/{chunk-TQZLC3BQ.cjs → chunk-DVDB5FJ7.cjs} +5 -5
- package/dist/{chunk-TQZLC3BQ.cjs.map → chunk-DVDB5FJ7.cjs.map} +1 -1
- package/dist/{chunk-EHTE3CTT.cjs → chunk-EI45U7WT.cjs} +37 -37
- package/dist/{chunk-EHTE3CTT.cjs.map → chunk-EI45U7WT.cjs.map} +1 -1
- package/dist/{chunk-LFLFQ422.js → chunk-HATQB5CS.js} +2 -2
- package/dist/{chunk-Q4YGG3CL.cjs → chunk-KC5MY4HW.cjs} +31 -31
- package/dist/{chunk-Q4YGG3CL.cjs.map → chunk-KC5MY4HW.cjs.map} +1 -1
- package/dist/{chunk-4OLIDOLO.js → chunk-LC3W676Z.js} +2 -2
- package/dist/{chunk-M6ODI2F5.js → chunk-N6LX6CYY.js} +2 -2
- package/dist/{chunk-JSFHTIKA.js → chunk-OKUDGO3Q.js} +2 -2
- package/dist/{chunk-OBKCQ7LA.cjs → chunk-RBFGCUWO.cjs} +62 -62
- package/dist/{chunk-OBKCQ7LA.cjs.map → chunk-RBFGCUWO.cjs.map} +1 -1
- package/dist/{chunk-XGOX5UQ2.js → chunk-SI6DI5HC.js} +4 -4
- package/dist/{chunk-MIEODAAV.cjs → chunk-TIJP7OPH.cjs} +9 -9
- package/dist/{chunk-MIEODAAV.cjs.map → chunk-TIJP7OPH.cjs.map} +1 -1
- package/dist/{chunk-GNB5ERZP.cjs → chunk-VFK5CZNU.cjs} +1025 -974
- package/dist/chunk-VFK5CZNU.cjs.map +1 -0
- package/dist/{chunk-IDWKP5H5.js → chunk-VIKH44M7.js} +1492 -1441
- package/dist/chunk-VIKH44M7.js.map +1 -0
- package/dist/{chunk-NULFIYK2.js → chunk-WL4YNYJN.js} +2 -2
- package/dist/{chunk-44Q3IXZM.js → chunk-Y6SVPXGD.js} +2 -2
- package/dist/{chunk-MPOP47ME.cjs → chunk-ZLMIJ3EN.cjs} +12 -12
- package/dist/{chunk-MPOP47ME.cjs.map → chunk-ZLMIJ3EN.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +8 -8
- package/dist/components/case-studies/index.js +2 -2
- package/dist/components/chat/index.cjs +2 -2
- package/dist/components/chat/index.js +1 -1
- package/dist/components/contact/index.cjs +3 -3
- package/dist/components/contact/index.js +2 -2
- package/dist/components/docs/index.cjs +5 -5
- package/dist/components/docs/index.js +4 -4
- package/dist/components/embeds/index.cjs +3 -3
- package/dist/components/embeds/index.js +2 -2
- package/dist/components/faq/index.cjs +3 -3
- package/dist/components/faq/index.js +2 -2
- package/dist/components/features/auth/accept-invitation-form.d.ts +2 -2
- package/dist/components/features/auth/accept-invitation-form.d.ts.map +1 -1
- package/dist/components/features/index.cjs +2 -2
- package/dist/components/features/index.js +1 -1
- package/dist/components/features/notifications/notification-drawer.d.ts.map +1 -1
- package/dist/components/features/time-tracker/time-tracker-header-button.d.ts +5 -2
- package/dist/components/features/time-tracker/time-tracker-header-button.d.ts.map +1 -1
- package/dist/components/help-center-pages/index.cjs +20 -20
- package/dist/components/help-center-pages/index.js +11 -11
- package/dist/components/index.cjs +120 -120
- package/dist/components/index.js +9 -9
- package/dist/components/navigation/app-header.d.ts.map +1 -1
- package/dist/components/navigation/app-layout-context.d.ts +34 -0
- package/dist/components/navigation/app-layout-context.d.ts.map +1 -0
- package/dist/components/navigation/app-layout-drawer.d.ts.map +1 -1
- package/dist/components/navigation/app-layout.d.ts +2 -21
- package/dist/components/navigation/app-layout.d.ts.map +1 -1
- package/dist/components/navigation/index.cjs +2 -2
- package/dist/components/navigation/index.js +1 -1
- package/dist/components/onboarding-guides/index.cjs +5 -5
- package/dist/components/onboarding-guides/index.js +4 -4
- package/dist/components/related-content/index.cjs +3 -3
- package/dist/components/related-content/index.js +2 -2
- package/dist/components/tickets/index.cjs +5 -5
- package/dist/components/tickets/index.js +4 -4
- package/dist/components/ui/index.cjs +2 -2
- package/dist/components/ui/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/features/auth/accept-invitation-form.tsx +4 -4
- package/src/components/features/notifications/notification-drawer.tsx +72 -43
- package/src/components/features/time-tracker/time-tracker-header-button.tsx +46 -6
- package/src/components/navigation/app-header.tsx +13 -9
- package/src/components/navigation/app-layout-context.ts +46 -0
- package/src/components/navigation/app-layout-drawer.tsx +21 -11
- package/src/components/navigation/app-layout.tsx +17 -39
- package/dist/chunk-GNB5ERZP.cjs.map +0 -1
- package/dist/chunk-IDWKP5H5.js.map +0 -1
- /package/dist/{chunk-WIMXB5EU.js.map → chunk-3ML4WLFP.js.map} +0 -0
- /package/dist/{chunk-BJPQJNSC.js.map → chunk-7W3B6ZGK.js.map} +0 -0
- /package/dist/{chunk-KA4WXCN3.js.map → chunk-DRWFCYDM.js.map} +0 -0
- /package/dist/{chunk-CQXHHVMR.js.map → chunk-DV5O2VU7.js.map} +0 -0
- /package/dist/{chunk-LFLFQ422.js.map → chunk-HATQB5CS.js.map} +0 -0
- /package/dist/{chunk-4OLIDOLO.js.map → chunk-LC3W676Z.js.map} +0 -0
- /package/dist/{chunk-M6ODI2F5.js.map → chunk-N6LX6CYY.js.map} +0 -0
- /package/dist/{chunk-JSFHTIKA.js.map → chunk-OKUDGO3Q.js.map} +0 -0
- /package/dist/{chunk-XGOX5UQ2.js.map → chunk-SI6DI5HC.js.map} +0 -0
- /package/dist/{chunk-NULFIYK2.js.map → chunk-WL4YNYJN.js.map} +0 -0
- /package/dist/{chunk-44Q3IXZM.js.map → chunk-Y6SVPXGD.js.map} +0 -0
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import * as PopoverPrimitive from '@radix-ui/react-popover'
|
|
4
|
+
import { useEffect, useRef } from 'react'
|
|
4
5
|
import { cn } from '../../../utils/cn'
|
|
5
6
|
import { ClockHistoryIcon } from '../../icons-v2-generated/date-and-time/clock-history-icon'
|
|
7
|
+
import {
|
|
8
|
+
type AppLayoutDrawerHandle,
|
|
9
|
+
useAppLayoutDrawerContainer,
|
|
10
|
+
useAppLayoutDrawerCoordination,
|
|
11
|
+
} from '../../navigation/app-layout-context'
|
|
6
12
|
import { HeaderButton } from '../../navigation/header-button'
|
|
7
13
|
import { OVERLAY_BACKDROP_CLASS } from '../../ui/drawer'
|
|
8
14
|
import { TimeTrackerPanel } from './time-tracker-panel'
|
|
@@ -19,8 +25,11 @@ export interface TimeTrackerHeaderButtonProps {
|
|
|
19
25
|
* Header affordance for the time tracker. Renders nothing unless wrapped in a
|
|
20
26
|
* `<TimeTrackerProvider>`. The trigger is the standard `HeaderButton`; when a
|
|
21
27
|
* session is active it also shows the live elapsed time. The popup is a Radix
|
|
22
|
-
* Popover anchored under the button (not a modal/drawer)
|
|
23
|
-
* dim
|
|
28
|
+
* Popover anchored under the button (not a modal/drawer). Inside AppLayout the
|
|
29
|
+
* dim backdrop covers only the main content area (header and sidebar stay
|
|
30
|
+
* interactive) and the popup joins the layout's panel coordination — opening
|
|
31
|
+
* it closes any open in-layout drawer and vice versa. Outside AppLayout it
|
|
32
|
+
* falls back to a viewport-wide backdrop.
|
|
24
33
|
*/
|
|
25
34
|
export function TimeTrackerHeaderButton({ className, disabled }: TimeTrackerHeaderButtonProps) {
|
|
26
35
|
const ctx = useOptionalTimeTracker()
|
|
@@ -29,10 +38,38 @@ export function TimeTrackerHeaderButton({ className, disabled }: TimeTrackerHead
|
|
|
29
38
|
runningSince: ctx?.runningSince,
|
|
30
39
|
accumulatedMs: ctx?.accumulatedMs,
|
|
31
40
|
})
|
|
41
|
+
const layoutContainer = useAppLayoutDrawerContainer()
|
|
42
|
+
const coordination = useAppLayoutDrawerCoordination()
|
|
43
|
+
|
|
44
|
+
const isOpen = ctx?.isOpen ?? false
|
|
45
|
+
const isOpenRef = useRef(isOpen)
|
|
46
|
+
isOpenRef.current = isOpen
|
|
47
|
+
const closeRef = useRef(ctx?.close)
|
|
48
|
+
closeRef.current = ctx?.close
|
|
49
|
+
// Stable handle: the same object must be registered AND passed as `self`
|
|
50
|
+
// to notifyDrawerDidOpen so the coordinator can skip it when closing the
|
|
51
|
+
// other panels.
|
|
52
|
+
const selfHandleRef = useRef<AppLayoutDrawerHandle | null>(null)
|
|
53
|
+
if (!selfHandleRef.current) {
|
|
54
|
+
selfHandleRef.current = {
|
|
55
|
+
close: () => {
|
|
56
|
+
if (isOpenRef.current) closeRef.current?.()
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (isOpen) coordination?.notifyDrawerDidOpen(selfHandleRef.current ?? undefined)
|
|
63
|
+
}, [isOpen, coordination])
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!selfHandleRef.current) return
|
|
67
|
+
return coordination?.registerDrawer(selfHandleRef.current)
|
|
68
|
+
}, [coordination])
|
|
32
69
|
|
|
33
70
|
if (!ctx) return null
|
|
34
71
|
|
|
35
|
-
const {
|
|
72
|
+
const { open, close, status } = ctx
|
|
36
73
|
const isPaused = status === 'paused'
|
|
37
74
|
const isActive = status === 'tracking' || isPaused
|
|
38
75
|
|
|
@@ -72,13 +109,16 @@ export function TimeTrackerHeaderButton({ className, disabled }: TimeTrackerHead
|
|
|
72
109
|
</PopoverPrimitive.Trigger>
|
|
73
110
|
{/* Popovers have no built-in overlay — portal a dim backdrop behind the
|
|
74
111
|
panel. Clicks land on it (outside Content), so Radix still closes the
|
|
75
|
-
popover. Own Portal: Radix's Portal slots a single child.
|
|
76
|
-
|
|
112
|
+
popover. Own Portal: Radix's Portal slots a single child. Inside
|
|
113
|
+
AppLayout the backdrop portals into the main-area container (absolute,
|
|
114
|
+
AppLayoutDrawer-overlay tier) so header/sidebar stay undimmed and
|
|
115
|
+
interactive; standalone it dims the whole viewport. */}
|
|
116
|
+
<PopoverPrimitive.Portal container={layoutContainer ?? undefined}>
|
|
77
117
|
<div
|
|
78
118
|
aria-hidden="true"
|
|
79
119
|
data-state={isOpen ? 'open' : 'closed'}
|
|
80
120
|
className={cn(
|
|
81
|
-
'fixed inset-0 z-[1299]',
|
|
121
|
+
layoutContainer ? 'absolute inset-0 z-[102]' : 'fixed inset-0 z-[1299]',
|
|
82
122
|
OVERLAY_BACKDROP_CLASS,
|
|
83
123
|
'data-[state=open]:animate-in data-[state=open]:fade-in-0',
|
|
84
124
|
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0',
|
|
@@ -251,16 +251,20 @@ function NotificationsHeaderButton({
|
|
|
251
251
|
return (
|
|
252
252
|
<HeaderButton
|
|
253
253
|
icon={
|
|
254
|
-
|
|
255
|
-
<
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
254
|
+
isActive ? (
|
|
255
|
+
<XmarkIcon className="w-4 h-4 md:w-6 md:h-6" />
|
|
256
|
+
) : (
|
|
257
|
+
<div className="relative w-4 h-4 md:w-6 md:h-6">
|
|
258
|
+
<BellIcon className="w-full h-full" />
|
|
259
|
+
{hasUnread && (
|
|
260
|
+
<span
|
|
261
|
+
className="absolute top-0 right-0 bg-ods-warning rounded-full w-1.5 h-1.5 md:w-2 md:h-2"
|
|
262
|
+
/>
|
|
263
|
+
)}
|
|
264
|
+
</div>
|
|
265
|
+
)
|
|
262
266
|
}
|
|
263
|
-
aria-label=
|
|
267
|
+
aria-label={isActive ? 'Close notifications' : 'Notifications'}
|
|
264
268
|
onClick={onClick}
|
|
265
269
|
isActive={isActive}
|
|
266
270
|
disabled={disabled || !onClick}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext } from 'react'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Container element that wraps `<main>` and serves as the portal target for
|
|
7
|
+
* `AppLayoutDrawer`. Drawers rendered into this container sit on top of the
|
|
8
|
+
* main content area only — the sidebar and header remain visible and
|
|
9
|
+
* interactive. Null when AppLayout hasn't mounted (or when used outside of it).
|
|
10
|
+
*
|
|
11
|
+
* Lives in its own module (not app-layout.tsx) so in-layout panels
|
|
12
|
+
* (AppLayoutDrawer, NotificationDrawer, TimeTrackerHeaderButton) can consume
|
|
13
|
+
* these contexts without importing AppLayout itself — AppLayout renders those
|
|
14
|
+
* panels, so importing it back would create a module cycle.
|
|
15
|
+
*/
|
|
16
|
+
export const AppLayoutDrawerContainerContext = createContext<HTMLElement | null>(null)
|
|
17
|
+
|
|
18
|
+
export function useAppLayoutDrawerContainer(): HTMLElement | null {
|
|
19
|
+
return useContext(AppLayoutDrawerContainerContext)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Coordination between AppLayout's in-layout panels (`AppLayoutDrawer`, the
|
|
24
|
+
* time-tracker popup) and the mobile burger menu. At most ONE of them may be
|
|
25
|
+
* open at a time — each dims the main area, so stacking them reads as broken:
|
|
26
|
+
* - a panel that opens calls `notifyDrawerDidOpen(self)` so the layout
|
|
27
|
+
* closes the burger menu AND every other registered panel;
|
|
28
|
+
* - each panel registers a close handle so opening the menu via the burger
|
|
29
|
+
* button (or another panel) closes it. Null outside of AppLayout.
|
|
30
|
+
*/
|
|
31
|
+
export interface AppLayoutDrawerHandle {
|
|
32
|
+
close: () => void
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface AppLayoutDrawerCoordination {
|
|
36
|
+
/** `self` is skipped when closing the other registered panels. */
|
|
37
|
+
notifyDrawerDidOpen: (self?: AppLayoutDrawerHandle) => void
|
|
38
|
+
/** Returns an unregister cleanup. */
|
|
39
|
+
registerDrawer: (handle: AppLayoutDrawerHandle) => () => void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const AppLayoutDrawerCoordinationContext = createContext<AppLayoutDrawerCoordination | null>(null)
|
|
43
|
+
|
|
44
|
+
export function useAppLayoutDrawerCoordination(): AppLayoutDrawerCoordination | null {
|
|
45
|
+
return useContext(AppLayoutDrawerCoordinationContext)
|
|
46
|
+
}
|
|
@@ -14,7 +14,11 @@ import {
|
|
|
14
14
|
OVERLAY_BACKDROP_CLASS,
|
|
15
15
|
type DrawerSide,
|
|
16
16
|
} from "../ui/drawer"
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
type AppLayoutDrawerHandle,
|
|
19
|
+
useAppLayoutDrawerContainer,
|
|
20
|
+
useAppLayoutDrawerCoordination,
|
|
21
|
+
} from "./app-layout-context"
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* AppLayoutDrawer is a Drawer variant that renders **inside** AppLayout's main
|
|
@@ -68,26 +72,32 @@ const AppLayoutDrawerRoot = ({
|
|
|
68
72
|
[isControlled, onOpenChange],
|
|
69
73
|
)
|
|
70
74
|
|
|
71
|
-
// Coordinate with AppLayout's
|
|
72
|
-
// opening
|
|
73
|
-
// drawer via the registered close handle. Refs keep the
|
|
74
|
-
//
|
|
75
|
+
// Coordinate with AppLayout's other in-layout panels and the mobile burger
|
|
76
|
+
// menu: opening this drawer closes them, and opening any of them closes
|
|
77
|
+
// this drawer via the registered close handle. Refs keep the handle
|
|
78
|
+
// identity stable across renders — the same object must be registered AND
|
|
79
|
+
// passed as `self` so the coordinator can skip it when closing the rest.
|
|
75
80
|
const coordination = useAppLayoutDrawerCoordination()
|
|
76
81
|
const openRef = React.useRef(open)
|
|
77
82
|
openRef.current = open
|
|
78
83
|
const handleOpenChangeRef = React.useRef(handleOpenChange)
|
|
79
84
|
handleOpenChangeRef.current = handleOpenChange
|
|
85
|
+
const selfHandleRef = React.useRef<AppLayoutDrawerHandle | null>(null)
|
|
86
|
+
if (!selfHandleRef.current) {
|
|
87
|
+
selfHandleRef.current = {
|
|
88
|
+
close: () => {
|
|
89
|
+
if (openRef.current) handleOpenChangeRef.current(false)
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
}
|
|
80
93
|
|
|
81
94
|
React.useEffect(() => {
|
|
82
|
-
if (open) coordination?.notifyDrawerDidOpen()
|
|
95
|
+
if (open) coordination?.notifyDrawerDidOpen(selfHandleRef.current ?? undefined)
|
|
83
96
|
}, [open, coordination])
|
|
84
97
|
|
|
85
98
|
React.useEffect(() => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (openRef.current) handleOpenChangeRef.current(false)
|
|
89
|
-
},
|
|
90
|
-
})
|
|
99
|
+
if (!selfHandleRef.current) return
|
|
100
|
+
return coordination?.registerDrawer(selfHandleRef.current)
|
|
91
101
|
}, [coordination])
|
|
92
102
|
|
|
93
103
|
return (
|
|
@@ -1,50 +1,21 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Suspense, useCallback, useMemo, useRef, useState } from 'react'
|
|
4
4
|
import { NavigationSidebarConfig } from '../../types/navigation'
|
|
5
5
|
import { cn } from '../../utils'
|
|
6
6
|
import { NotificationDrawer } from '../features/notifications/notification-drawer'
|
|
7
7
|
import { AppHeader, AppHeaderProps } from './app-header'
|
|
8
|
+
import {
|
|
9
|
+
AppLayoutDrawerContainerContext,
|
|
10
|
+
type AppLayoutDrawerCoordination,
|
|
11
|
+
AppLayoutDrawerCoordinationContext,
|
|
12
|
+
type AppLayoutDrawerHandle,
|
|
13
|
+
} from './app-layout-context'
|
|
8
14
|
import { MobileBurgerMenu, MobileBurgerMenuProps } from './mobile-burger-menu'
|
|
9
15
|
import { NavigationSidebar } from './navigation-sidebar'
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* `AppLayoutDrawer`. Drawers rendered into this container sit on top of the
|
|
14
|
-
* main content area only — the sidebar and header remain visible and
|
|
15
|
-
* interactive. Null when AppLayout hasn't mounted (or when used outside of it).
|
|
16
|
-
*/
|
|
17
|
-
const AppLayoutDrawerContainerContext = createContext<HTMLElement | null>(null)
|
|
18
|
-
|
|
19
|
-
export function useAppLayoutDrawerContainer(): HTMLElement | null {
|
|
20
|
-
return useContext(AppLayoutDrawerContainerContext)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Two-way coordination between AppLayout's mobile burger menu and in-layout
|
|
25
|
-
* drawers (`AppLayoutDrawer`), which render above the menu (z-[103] vs
|
|
26
|
-
* z-[101]) — the two must never be open at the same time:
|
|
27
|
-
* - a drawer that opens calls `notifyDrawerDidOpen` so the layout closes
|
|
28
|
-
* the menu (otherwise it would resurface once the drawer closes);
|
|
29
|
-
* - each drawer registers a close handle so opening the menu via the
|
|
30
|
-
* burger button closes any open drawer instead of hiding the menu
|
|
31
|
-
* underneath it. Null outside of AppLayout.
|
|
32
|
-
*/
|
|
33
|
-
export interface AppLayoutDrawerHandle {
|
|
34
|
-
close: () => void
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface AppLayoutDrawerCoordination {
|
|
38
|
-
notifyDrawerDidOpen: () => void
|
|
39
|
-
/** Returns an unregister cleanup. */
|
|
40
|
-
registerDrawer: (handle: AppLayoutDrawerHandle) => () => void
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const AppLayoutDrawerCoordinationContext = createContext<AppLayoutDrawerCoordination | null>(null)
|
|
44
|
-
|
|
45
|
-
export function useAppLayoutDrawerCoordination(): AppLayoutDrawerCoordination | null {
|
|
46
|
-
return useContext(AppLayoutDrawerCoordinationContext)
|
|
47
|
-
}
|
|
17
|
+
export { useAppLayoutDrawerContainer, useAppLayoutDrawerCoordination } from './app-layout-context'
|
|
18
|
+
export type { AppLayoutDrawerHandle } from './app-layout-context'
|
|
48
19
|
|
|
49
20
|
export interface AppLayoutProps {
|
|
50
21
|
children: React.ReactNode
|
|
@@ -113,7 +84,14 @@ export function AppLayout({
|
|
|
113
84
|
}, [])
|
|
114
85
|
|
|
115
86
|
const drawerCoordination = useMemo<AppLayoutDrawerCoordination>(() => ({
|
|
116
|
-
notifyDrawerDidOpen: () =>
|
|
87
|
+
notifyDrawerDidOpen: (self) => {
|
|
88
|
+
setMobileMenuOpen(false)
|
|
89
|
+
// Only one in-layout panel may be open at a time — each dims the main
|
|
90
|
+
// area, so stacking them reads as broken.
|
|
91
|
+
for (const handle of drawerHandlesRef.current) {
|
|
92
|
+
if (handle !== self) handle.close()
|
|
93
|
+
}
|
|
94
|
+
},
|
|
117
95
|
registerDrawer: (handle) => {
|
|
118
96
|
drawerHandlesRef.current.add(handle)
|
|
119
97
|
return () => drawerHandlesRef.current.delete(handle)
|