@adea-ai/ui 0.160.3 → 0.161.0
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/components/layout/contextual-sidebar/contextual-sidebar.d.ts.map +1 -1
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js +21 -1
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js.map +1 -1
- package/dist/components/layout/split-layout/index.d.ts +1 -0
- package/dist/components/layout/split-layout/index.d.ts.map +1 -1
- package/dist/components/layout/split-layout/index.js +2 -1
- package/dist/components/layout/split-layout/pane-focus.d.ts +29 -0
- package/dist/components/layout/split-layout/pane-focus.d.ts.map +1 -0
- package/dist/components/layout/split-layout/pane-focus.js +77 -0
- package/dist/components/layout/split-layout/pane-focus.js.map +1 -0
- package/dist/components/layout/split-layout/split-layout.d.ts +6 -0
- package/dist/components/layout/split-layout/split-layout.d.ts.map +1 -1
- package/dist/components/layout/split-layout/split-layout.js +25 -9
- package/dist/components/layout/split-layout/split-layout.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/r/registry.json +5 -0
- package/dist/r/split-layout.json +5 -0
- package/dist/r/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +23 -0
- package/dist/r/src/components/layout/split-layout/index.ts +1 -0
- package/dist/r/src/components/layout/split-layout/pane-focus.ts +111 -0
- package/dist/r/src/components/layout/split-layout/split-layout.tsx +27 -1
- package/package.json +7 -1
- package/registry.json +5 -0
- package/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +23 -0
- package/src/components/layout/split-layout/index.ts +1 -0
- package/src/components/layout/split-layout/pane-focus.ts +111 -0
- package/src/components/layout/split-layout/split-layout.tsx +27 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextual-sidebar.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/contextual-sidebar/contextual-sidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"contextual-sidebar.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/contextual-sidebar/contextual-sidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAyBvC,MAAM,MAAM,8BAA8B,GAAG;IAC3C,wEAAwE;IACxE,MAAM,EAAE,OAAO,CAAA;IACf,qFAAqF;IACrF,WAAW,IAAI,WAAW,GAAG,SAAS,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAA;IACzB,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC1B,EAAE,EAAE,SAAS,GAAG,QAAQ,CAAA;IACxB,cAAc,EAAE,WAAW,GAAG,SAAS,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,qDAAqD;IACrD,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAA;IACb,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,eAAe,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IACrC,8EAA8E;IAC9E,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;IACjC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAA;IAC9C;;;;OAIG;IACH,0BAA0B,CAAC,CAAC,KAAK,EAAE,+BAA+B,GAAG,IAAI,CAAA;IACzE,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM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|
import { SidebarNav, SidebarNavContent, SidebarNavFooter, SidebarNavHeader, SidebarNavTitle } from "../sidebar-nav/sidebar-nav.js";
|
|
4
4
|
import { PixelResizeHandle } from "../pixel-resize-handle/pixel-resize-handle.js";
|
|
5
5
|
import { createComponent, memo } from "@solidjs/web";
|
|
6
|
-
import { Show, createEffect, createMemo, createSignal, createUniqueId, flush, onCleanup } from "solid-js";
|
|
6
|
+
import { Show, createEffect, createMemo, createSignal, createUniqueId, flush, onCleanup, onSettled } from "solid-js";
|
|
7
7
|
// src/components/layout/contextual-sidebar/contextual-sidebar.tsx
|
|
8
8
|
/**
|
|
9
9
|
* ContextualSidebar.
|
|
@@ -280,6 +280,9 @@ function ContextualSidebar(props) {
|
|
|
280
280
|
return props.footer(context);
|
|
281
281
|
}
|
|
282
282
|
}) : null;
|
|
283
|
+
}),
|
|
284
|
+
memo(() => {
|
|
285
|
+
return mobile ? createComponent(FocusNavigationOnMount, { aside: () => element }) : null;
|
|
283
286
|
})
|
|
284
287
|
];
|
|
285
288
|
}
|
|
@@ -322,6 +325,23 @@ function ContextualSidebar(props) {
|
|
|
322
325
|
}
|
|
323
326
|
})];
|
|
324
327
|
}
|
|
328
|
+
var FIRST_CONTROL = "button:not(:disabled), [href], input:not(:disabled):not([type=\"hidden\"]), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
|
|
329
|
+
/**
|
|
330
|
+
* The mobile navigation renders once its aside is connected, a tick after the Sheet placed its
|
|
331
|
+
* initial focus on what it held then: its own Close, or the panel. Hand that focus to the
|
|
332
|
+
* navigation's first control, as a keyboard opener expects; focus already inside the
|
|
333
|
+
* navigation, or outside the Sheet, stays where it is.
|
|
334
|
+
*/
|
|
335
|
+
function FocusNavigationOnMount(props) {
|
|
336
|
+
onSettled(() => {
|
|
337
|
+
const aside = props.aside();
|
|
338
|
+
const sheet = aside?.closest("[role=\"dialog\"]");
|
|
339
|
+
const active = document.activeElement;
|
|
340
|
+
if (!aside || !sheet || !active || !sheet.contains(active) || aside.contains(active)) return;
|
|
341
|
+
aside.querySelector(FIRST_CONTROL)?.focus();
|
|
342
|
+
});
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
325
345
|
export { ContextualSidebar };
|
|
326
346
|
|
|
327
347
|
//# sourceMappingURL=contextual-sidebar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextual-sidebar.js","names":["<SidebarNav\n as=\"aside\"\n id={navigationId()}\n aria-label={props.label}\n aria-hidden={!mobile && !props.open ? 'true' : undefined}\n inert={!mobile && !props.open}\n data-contextual-sidebar={mobile ? 'mobile' : 'desktop'}\n data-open={mobile ? undefined : String(props.open)}\n ref={(node: HTMLElement) => {\n element = node\n if (!mobile) desktopSidebar = node\n if (mobile) {\n setMobileMount({ element: node, connected: node.isConnected })\n queueMicrotask(() => {\n if (node.isConnected && mobileMount()?.element === node)\n setMobileMount({ element: node, connected: true })\n })\n }\n props.onSidebarElement?.(node, mobile)\n }}\n class={cn('relative h-full w-full max-w-full', props.sidebarClass)}\n >\n <Show when={!mobile && props.open}>\n <PixelResizeHandle\n // The ruler spans the sidebar as a pointer-events-none overlay; lift\n // it above the neighbouring pane so the edge stays grabbable.\n class=\"z-(--z-docked)\"\n side=\"left\"\n value={props.width}\n minimum={props.minimum}\n maximum={props.maximum}\n step={props.step}\n label={resizeLabel()}\n grip={props.resizeGrip ?? 'rung'}\n controls={navigationId()}\n onChange={props.onWidthChange}\n onCommit={props.onWidthCommit}\n />\n </Show>\n <Show when={!mobile || mobileMount()?.connected}>\n <Show\n when={mobile || props.titleVisibility !== 'mobile' || props.header}\n fallback={\n <SidebarNavTitle as={props.headingAs ?? 'h2'} class=\"sr-only\">\n {props.title}\n </SidebarNavTitle>\n }\n >\n <SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>\n </Show>\n <SidebarNavContent class={props.contentClass}>{props.content(context)}</SidebarNavContent>\n {props.footer ? (\n <SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>\n ) : null}\n </Show>\n </SidebarNav>","as=\"aside\"","ref={(node: HTMLElement) => {\n element = node\n if (!mobile) desktopSidebar = node\n if (mobile) {\n setMobileMount({ element: node, connected: node.isConnected })\n queueMicrotask(() => {\n if (node.isConnected && mobileMount()?.element === node)\n setMobileMount({ element: node, connected: true })\n })\n }\n props.onSidebarElement?.(node, mobile)\n }}","<Show when={!mobile && props.open}>\n <PixelResizeHandle\n // The ruler spans the sidebar as a pointer-events-none overlay; lift\n // it above the neighbouring pane so the edge stays grabbable.\n class=\"z-(--z-docked)\"\n side=\"left\"\n value={props.width}\n minimum={props.minimum}\n maximum={props.maximum}\n step={props.step}\n label={resizeLabel()}\n grip={props.resizeGrip ?? 'rung'}\n controls={navigationId()}\n onChange={props.onWidthChange}\n onCommit={props.onWidthCommit}\n />\n </Show>","<PixelResizeHandle\n // The ruler spans the sidebar as a pointer-events-none overlay; lift\n // it above the neighbouring pane so the edge stays grabbable.\n class=\"z-(--z-docked)\"\n side=\"left\"\n value={props.width}\n minimum={props.minimum}\n maximum={props.maximum}\n step={props.step}\n label={resizeLabel()}\n grip={props.resizeGrip ?? 'rung'}\n controls={navigationId()}\n onChange={props.onWidthChange}\n onCommit={props.onWidthCommit}\n />","class=\"z-(--z-docked)\"","side=\"left\"","<Show when={!mobile || mobileMount()?.connected}>\n <Show\n when={mobile || props.titleVisibility !== 'mobile' || props.header}\n fallback={\n <SidebarNavTitle as={props.headingAs ?? 'h2'} class=\"sr-only\">\n {props.title}\n </SidebarNavTitle>\n }\n >\n <SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>\n </Show>\n <SidebarNavContent class={props.contentClass}>{props.content(context)}</SidebarNavContent>\n {props.footer ? (\n <SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>\n ) : null}\n </Show>","<Show\n when={mobile || props.titleVisibility !== 'mobile' || props.header}\n fallback={\n <SidebarNavTitle as={props.headingAs ?? 'h2'} class=\"sr-only\">\n {props.title}\n </SidebarNavTitle>\n }\n >\n <SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>\n </Show>","<SidebarNavTitle as={props.headingAs ?? 'h2'} class=\"sr-only\">\n {props.title}\n </SidebarNavTitle>","class=\"sr-only\"","<SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>","<SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>","props.header?.(context)","<SidebarNavContent class={props.contentClass}>{props.content(context)}</SidebarNavContent>","{props.footer ? (\n <SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>\n ) : null}","<SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>","<Show when={!isMobile()}>{(_wide) => renderSidebar(false)}</Show>","<Show when={mobileLoad()} keyed>\n {(loaded) => {\n if ('error' in loaded) throw loaded.error\n return (\n <loaded.MobileSidebar\n open={isMobile() && props.open}\n onOpenChange={props.onOpenChange}\n label={props.label}\n sheetClass={props.sheetClass}\n restoreFocusRef={props.restoreFocusRef}\n renderSidebar={() => renderSidebar(true)}\n />\n )\n }}\n </Show>","<loaded.MobileSidebar\n open={isMobile() && props.open}\n onOpenChange={props.onOpenChange}\n label={props.label}\n sheetClass={props.sheetClass}\n restoreFocusRef={props.restoreFocusRef}\n renderSidebar={() => renderSidebar(true)}\n />","loaded.MobileSidebar","isMobile() && props.open","renderSidebar={() => renderSidebar(true)}","wasNarrow"],"sources":["../../../../src/components/layout/contextual-sidebar/contextual-sidebar.tsx"],"sourcesContent":["import type { Accessor } from 'solid-js'\nimport type { JSX } from '@solidjs/web'\nimport {\n Show,\n createEffect,\n createMemo,\n createSignal,\n createUniqueId,\n flush,\n onCleanup,\n} from 'solid-js'\nimport { MD_BREAKPOINT } from '#lib/breakpoints'\nimport { cn } from '#lib/utils'\nimport {\n SidebarNav,\n SidebarNavContent,\n SidebarNavFooter,\n SidebarNavHeader,\n SidebarNavTitle,\n} from '../sidebar-nav'\nimport { PixelResizeHandle } from '../pixel-resize-handle'\n\ntype MobileModule = typeof import('./mobile-contextual-sidebar')\ntype MobileLoad = MobileModule | { error: unknown }\n\nexport type ContextualSidebarRenderContext = {\n /** Whether the slot is being rendered inside the modal mobile sheet. */\n mobile: boolean\n /** Mount nested popovers and menus inside the mobile dialog's accessibility tree. */\n portalMount(): HTMLElement | undefined\n}\n\nexport type ContextualSidebarModeTransition = {\n phase: 'before' | 'after'\n from: 'desktop' | 'mobile'\n to: 'desktop' | 'mobile'\n desktopSidebar: HTMLElement | undefined\n}\n\nexport type ContextualSidebarProps = {\n /** Stable host id prefix; generated when omitted. */\n id?: string\n /** Landmark name shared by the desktop and mobile navigation. */\n label: string\n /** Visible navigation title and mobile dialog title. */\n title: string\n /**\n * Where the title row shows. `always` (default) draws it on desktop and in\n * the mobile sheet; `mobile` keeps the desktop title for assistive\n * technology only and drops the desktop row, for hosts whose top bar\n * already names the context. A `header` slot keeps the row visible.\n */\n titleVisibility?: 'always' | 'mobile'\n /** Host-controlled expanded state for the desktop panel and mobile dialog. */\n open: boolean\n onOpenChange(open: boolean): void\n /**\n * Presentation mode. `auto` (default) uses the built-in viewport breakpoint;\n * hosts can select `desktop` or the shared mobile `Sheet` themselves.\n */\n responsiveMode?: 'auto' | 'desktop' | 'mobile'\n /**\n * Coordinate host layout before a runtime mode change and after its DOM settles.\n * A superseded transition or unmounted sidebar does not emit an after phase.\n * Initial mode resolution does not emit either phase.\n */\n onResponsiveModeTransition?(event: ContextualSidebarModeTransition): void\n /** Current host-owned pixel width, reflected by the resize handle. */\n width: number\n minimum: number\n maximum: number\n step?: number\n /** Pass the host's initial viewport seed to distinguish stale desktop state. */\n wideViewportAtLoad?: boolean\n resizeLabel?: string\n /**\n * The resize edge's grip: the quieter rung by default, or the bordered chip\n * for hosts that want the heavier affordance.\n */\n resizeGrip?: 'chip' | 'rung'\n /** Stable external opener used when the modal mobile sheet closes. */\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n /** Called with the nav node so a host can project width onto its layout root. */\n onSidebarElement?: (element: HTMLElement | undefined, mobile: boolean) => void\n /** Host-owned layout classes applied to both nav instances. */\n sidebarClass?: string\n /** Host-owned responsive constraints for the modal sheet. */\n sheetClass?: string\n headerClass?: string\n contentClass?: string\n footerClass?: string\n headingAs?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'\n /** Optional action/content slot alongside the shared heading. */\n header?(context: ContextualSidebarRenderContext): JSX.Element\n /** View-specific navigation rows, projects, rooms, files, or sessions. */\n content(context: ContextualSidebarRenderContext): JSX.Element\n /** Optional view-specific footer, such as an archive affordance. */\n footer?(context: ContextualSidebarRenderContext): JSX.Element\n onWidthChange(width: number): void\n onWidthCommit?(width: number): void\n}\n\n/**\n * ContextualSidebar.\n *\n * Shared navigation geometry and interaction policy for an application's\n * contextual sidebar. The host keeps ownership of the actual grid width,\n * persisted preference, open state, and view-specific navigation content.\n */\nexport function ContextualSidebar(props: ContextualSidebarProps) {\n const [isMobile, setIsMobile] = createSignal(false)\n // Signal reads lag writes until the next flush, and a host can re-enter\n // `transition` from its callbacks within the same tick. This mirror holds\n // the committed mode so those re-entrant reads see the latest value.\n let mobileNow = false\n const [mobileLoad, setMobileLoad] = createSignal<MobileLoad>()\n let mobileLoadGeneration = 0\n let mobileLoadPending = false\n let mobileLoadSettled = false\n let responsiveModeInitialized = false\n let desktopSidebar: HTMLElement | undefined\n let transitionGeneration = 0\n let pendingMode: boolean | undefined\n let disposed = false\n onCleanup(() => {\n disposed = true\n transitionGeneration += 1\n })\n\n // What the mode resolution samples from the host: its open state, viewport\n // seed and callbacks. They are read here, in an effect's compute, and the mode\n // effect and `transition` read this snapshot, so a change to `open` never\n // re-runs the mode resolution and the apply phase reads no props. Created\n // before the mode effect, so its first apply has run by the time that one's\n // does.\n let host = {\n open: false,\n wideViewportAtLoad: undefined as boolean | undefined,\n onOpenChange: (_open: boolean) => {},\n onResponsiveModeTransition: undefined as\n | ContextualSidebarProps['onResponsiveModeTransition']\n | undefined,\n }\n createEffect(\n () => ({\n open: props.open,\n wideViewportAtLoad: props.wideViewportAtLoad,\n onOpenChange: props.onOpenChange,\n onResponsiveModeTransition: props.onResponsiveModeTransition,\n }),\n (next) => {\n host = next\n }\n )\n\n // `fromListener` marks a call from the media listener, outside any flush. A\n // host that answers a callback by changing `responsiveMode` (or disposing)\n // has that write applied by `flush()` right away, so the generation check\n // below sees it, as Solid 1's synchronous updates did. Inside the mode\n // effect, flush() is a no-op and the same flush re-runs the effect next.\n const transition = (next: boolean, closeStaleOpen: boolean, fromListener = false) => {\n // The host may synchronously update its props from either callback, which\n // re-enters the responsive effect before this transition has finished.\n if (pendingMode === next) return\n const previous = mobileNow\n const changed = responsiveModeInitialized && previous !== next\n const generation =\n changed || pendingMode !== undefined ? ++transitionGeneration : transitionGeneration\n pendingMode = next\n const event = {\n from: previous ? ('mobile' as const) : ('desktop' as const),\n to: next ? ('mobile' as const) : ('desktop' as const),\n desktopSidebar,\n }\n try {\n // Callers are the effect apply phase and a media listener, neither of\n // which tracks, so the host callbacks below never subscribe.\n if (changed) host.onResponsiveModeTransition?.({ ...event, phase: 'before' })\n if (changed && fromListener) flush()\n if (disposed || generation !== transitionGeneration) return\n if (closeStaleOpen) host.onOpenChange(false)\n if (closeStaleOpen && fromListener) flush()\n if (disposed || generation !== transitionGeneration) return\n if (next) loadMobile()\n mobileNow = next\n setIsMobile(next)\n if (changed) {\n queueMicrotask(() => {\n if (!disposed && generation === transitionGeneration && mobileNow === next)\n host.onResponsiveModeTransition?.({ ...event, phase: 'after' })\n })\n }\n } finally {\n if (generation === transitionGeneration) pendingMode = undefined\n }\n }\n // Keep the resolved component mounted across viewport changes for Sheet cleanup.\n const loadMobile = () => {\n if (mobileLoadPending || mobileLoadSettled) return\n mobileLoadPending = true\n const generation = ++mobileLoadGeneration\n // Native module caching shares successful loads without keeping a rejected promise.\n void import('./mobile-contextual-sidebar').then(\n (module) => {\n if (generation === mobileLoadGeneration) {\n mobileLoadPending = false\n mobileLoadSettled = true\n setMobileLoad(module)\n }\n },\n (error: unknown) => {\n if (generation === mobileLoadGeneration) {\n mobileLoadPending = false\n mobileLoadSettled = true\n setMobileLoad({ error })\n }\n }\n )\n }\n const [mobileMount, setMobileMount] = createSignal<\n { element: HTMLElement; connected: boolean } | undefined\n >()\n const generatedId = `contextual-sidebar-${createUniqueId()}`\n const id = () => props.id ?? generatedId\n const resizeLabel = () => props.resizeLabel ?? `Resize ${props.label}`\n const portalMount = () => {\n const mount = mobileMount()\n return mount?.connected && mount.element.isConnected ? mount.element : undefined\n }\n\n const responsiveMode = createMemo(() => props.responsiveMode ?? 'auto')\n // Only the mode is tracked; the open state and viewport seed come from the\n // `host` snapshot, so toggling `open` never re-runs the mode resolution.\n createEffect(responsiveMode, (mode) => {\n const wasMobile = mobileNow\n let media: MediaQueryList | undefined\n let viewportListener: (() => void) | undefined\n\n const cleanup = () => {\n mobileLoadGeneration += 1\n mobileLoadPending = false\n if (media && viewportListener) media.removeEventListener('change', viewportListener)\n }\n\n if (mode === 'desktop') {\n transition(false, false)\n } else if (mode === 'mobile') {\n // An explicit host transition into mobile must not briefly open a Sheet\n // with stale desktop-expanded state. An initial wide-loaded seed still\n // marks an open value as stale, including in host-selected mobile mode.\n const shouldCloseStaleOpen = responsiveModeInitialized\n ? !wasMobile && host.open\n : host.wideViewportAtLoad && host.open\n transition(true, Boolean(shouldCloseStaleOpen))\n } else {\n const mediaQuery = window.matchMedia(`(max-width: ${MD_BREAKPOINT})`)\n media = mediaQuery\n const updateViewport = () => {\n const nextIsMobile = mediaQuery.matches\n const wasNarrow = mobileNow\n // Close before mounting a modal. A desktop-expanded host state is not\n // mobile intent, and opening the Sheet for one frame can steal focus.\n transition(nextIsMobile, nextIsMobile && !wasNarrow, true)\n }\n viewportListener = updateViewport\n\n // Preserve a narrow-boot open intent. Initial auto and mobile modes use\n // the viewport seed to clear stale state; runtime transitions close it.\n const shouldCloseStaleOpen =\n media.matches &&\n (!responsiveModeInitialized ? host.wideViewportAtLoad && host.open : !wasMobile)\n transition(media.matches, Boolean(shouldCloseStaleOpen))\n if (!disposed) mediaQuery.addEventListener('change', updateViewport)\n }\n\n responsiveModeInitialized = true\n return cleanup\n })\n\n const renderSidebar = (mobile: boolean) => {\n let element: HTMLElement | undefined\n const context: ContextualSidebarRenderContext = {\n mobile,\n portalMount: () => (mobile ? portalMount() : undefined),\n }\n const navigationId = () => `${id()}-${mobile ? 'mobile' : 'desktop'}`\n\n onCleanup(() => {\n if (mobile && mobileMount()?.element === element) setMobileMount(undefined)\n if (!mobile && desktopSidebar === element) desktopSidebar = undefined\n element = undefined\n props.onSidebarElement?.(undefined, mobile)\n })\n\n return (\n <SidebarNav\n as=\"aside\"\n id={navigationId()}\n aria-label={props.label}\n aria-hidden={!mobile && !props.open ? 'true' : undefined}\n inert={!mobile && !props.open}\n data-contextual-sidebar={mobile ? 'mobile' : 'desktop'}\n data-open={mobile ? undefined : String(props.open)}\n ref={(node: HTMLElement) => {\n element = node\n if (!mobile) desktopSidebar = node\n if (mobile) {\n setMobileMount({ element: node, connected: node.isConnected })\n queueMicrotask(() => {\n if (node.isConnected && mobileMount()?.element === node)\n setMobileMount({ element: node, connected: true })\n })\n }\n props.onSidebarElement?.(node, mobile)\n }}\n class={cn('relative h-full w-full max-w-full', props.sidebarClass)}\n >\n <Show when={!mobile && props.open}>\n <PixelResizeHandle\n // The ruler spans the sidebar as a pointer-events-none overlay; lift\n // it above the neighbouring pane so the edge stays grabbable.\n class=\"z-(--z-docked)\"\n side=\"left\"\n value={props.width}\n minimum={props.minimum}\n maximum={props.maximum}\n step={props.step}\n label={resizeLabel()}\n grip={props.resizeGrip ?? 'rung'}\n controls={navigationId()}\n onChange={props.onWidthChange}\n onCommit={props.onWidthCommit}\n />\n </Show>\n <Show when={!mobile || mobileMount()?.connected}>\n <Show\n when={mobile || props.titleVisibility !== 'mobile' || props.header}\n fallback={\n <SidebarNavTitle as={props.headingAs ?? 'h2'} class=\"sr-only\">\n {props.title}\n </SidebarNavTitle>\n }\n >\n <SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>\n </Show>\n <SidebarNavContent class={props.contentClass}>{props.content(context)}</SidebarNavContent>\n {props.footer ? (\n <SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>\n ) : null}\n </Show>\n </SidebarNav>\n )\n }\n\n return (\n <>\n <Show when={!isMobile()}>{(_wide) => renderSidebar(false)}</Show>\n <Show when={mobileLoad()} keyed>\n {(loaded) => {\n if ('error' in loaded) throw loaded.error\n return (\n <loaded.MobileSidebar\n open={isMobile() && props.open}\n onOpenChange={props.onOpenChange}\n label={props.label}\n sheetClass={props.sheetClass}\n restoreFocusRef={props.restoreFocusRef}\n renderSidebar={() => renderSidebar(true)}\n />\n )\n }}\n </Show>\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AA6GA,SAAgB,kBAAkB,OAA+B;CAC/D,MAAM,CAAC,UAAU,eAAe,aAAa,KAAK;CAIlD,IAAI,YAAY;CAChB,MAAM,CAAC,YAAY,iBAAiB,aAAyB;CAC7D,IAAI,uBAAuB;CAC3B,IAAI,oBAAoB;CACxB,IAAI,oBAAoB;CACxB,IAAI,4BAA4B;CAChC,IAAI;CACJ,IAAI,uBAAuB;CAC3B,IAAI;CACJ,IAAI,WAA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AA;SAAO,OAAA,MAAM;QAAY;QAA5C,IAAA,WAAA;SAA+C,OAAA,MAAM,QAAQ,OAAO;QAAqB;;OACzFC,WAAAA;;SAAC,OAAA,CAAA,CAAA,MAAM;QAEC,CAAA,CAAC,CAAD,IADNC,gBAAAA,kBAAAA;SAAkB,IAAA,UAAA;UAAO,OAAA,MAAM;SAAW;SAA1C,IAAA,WAAA;UAA6C,OAAA,MAAM,OAAO,OAAO;SAAoB;QACnF,CAAA,IAAA;OAAI,CAAA;MAhBT;KAiBK;IAnCP,CAAA,CAAA;GAoCW;;CAEhB;CAEA,OACI,CACAC,gBAAAA,MAAAA;EAAM,IAAA,OAAA;GAAM,OAAA,CAAC,SAAS;EAAC;EAAvBA,WAA2B,UAAU,cAAc,KAAK;CAAQ,CAAA,GAChEC,gBAAAA,MAAAA;EAAM,IAAA,OAAA;GAAM,OAAA,WAAW;EAAC;EAAE,OAAA;EAA1BA,WACI,WAAW;GACX,IAAI,WAAW,QAAQ,MAAM,OAAO;GACpC,OACEC,gBAAAA,OAACC,eAAD;IACE,IAAA,OAAA;KAAMC,OAAAA,WAAAA;MAAS,OAAA,CAAA,CAAA,SAAA;KAAc,CAAA,CAAC,CAAD,IAAT,MAAM,OAApB,SAAS;IAAe;IAC9B,IAAA,eAAA;KAAc,OAAA,MAAM;IAAY;IAChC,IAAA,QAAA;KAAO,OAAA,MAAM;IAAK;IAClB,IAAA,aAAA;KAAY,OAAA,MAAM;IAAU;IAC5B,IAAA,kBAAA;KAAiB,OAAA,MAAM;IAAe;IACtCC,qBAAqB,cAAc,IAAI;GACxC,CAAA;EAEL;CACI,CAAA,CAfP;AAkBL"}
|
|
1
|
+
{"version":3,"file":"contextual-sidebar.js","names":["<SidebarNav\n as=\"aside\"\n id={navigationId()}\n aria-label={props.label}\n aria-hidden={!mobile && !props.open ? 'true' : undefined}\n inert={!mobile && !props.open}\n data-contextual-sidebar={mobile ? 'mobile' : 'desktop'}\n data-open={mobile ? undefined : String(props.open)}\n ref={(node: HTMLElement) => {\n element = node\n if (!mobile) desktopSidebar = node\n if (mobile) {\n setMobileMount({ element: node, connected: node.isConnected })\n queueMicrotask(() => {\n if (node.isConnected && mobileMount()?.element === node)\n setMobileMount({ element: node, connected: true })\n })\n }\n props.onSidebarElement?.(node, mobile)\n }}\n class={cn('relative h-full w-full max-w-full', props.sidebarClass)}\n >\n <Show when={!mobile && props.open}>\n <PixelResizeHandle\n // The ruler spans the sidebar as a pointer-events-none overlay; lift\n // it above the neighbouring pane so the edge stays grabbable.\n class=\"z-(--z-docked)\"\n side=\"left\"\n value={props.width}\n minimum={props.minimum}\n maximum={props.maximum}\n step={props.step}\n label={resizeLabel()}\n grip={props.resizeGrip ?? 'rung'}\n controls={navigationId()}\n onChange={props.onWidthChange}\n onCommit={props.onWidthCommit}\n />\n </Show>\n <Show when={!mobile || mobileMount()?.connected}>\n <Show\n when={mobile || props.titleVisibility !== 'mobile' || props.header}\n fallback={\n <SidebarNavTitle as={props.headingAs ?? 'h2'} class=\"sr-only\">\n {props.title}\n </SidebarNavTitle>\n }\n >\n <SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>\n </Show>\n <SidebarNavContent class={props.contentClass}>{props.content(context)}</SidebarNavContent>\n {props.footer ? (\n <SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>\n ) : null}\n {mobile ? <FocusNavigationOnMount aside={() => element} /> : null}\n </Show>\n </SidebarNav>","as=\"aside\"","ref={(node: HTMLElement) => {\n element = node\n if (!mobile) desktopSidebar = node\n if (mobile) {\n setMobileMount({ element: node, connected: node.isConnected })\n queueMicrotask(() => {\n if (node.isConnected && mobileMount()?.element === node)\n setMobileMount({ element: node, connected: true })\n })\n }\n props.onSidebarElement?.(node, mobile)\n }}","<Show when={!mobile && props.open}>\n <PixelResizeHandle\n // The ruler spans the sidebar as a pointer-events-none overlay; lift\n // it above the neighbouring pane so the edge stays grabbable.\n class=\"z-(--z-docked)\"\n side=\"left\"\n value={props.width}\n minimum={props.minimum}\n maximum={props.maximum}\n step={props.step}\n label={resizeLabel()}\n grip={props.resizeGrip ?? 'rung'}\n controls={navigationId()}\n onChange={props.onWidthChange}\n onCommit={props.onWidthCommit}\n />\n </Show>","<PixelResizeHandle\n // The ruler spans the sidebar as a pointer-events-none overlay; lift\n // it above the neighbouring pane so the edge stays grabbable.\n class=\"z-(--z-docked)\"\n side=\"left\"\n value={props.width}\n minimum={props.minimum}\n maximum={props.maximum}\n step={props.step}\n label={resizeLabel()}\n grip={props.resizeGrip ?? 'rung'}\n controls={navigationId()}\n onChange={props.onWidthChange}\n onCommit={props.onWidthCommit}\n />","class=\"z-(--z-docked)\"","side=\"left\"","<Show when={!mobile || mobileMount()?.connected}>\n <Show\n when={mobile || props.titleVisibility !== 'mobile' || props.header}\n fallback={\n <SidebarNavTitle as={props.headingAs ?? 'h2'} class=\"sr-only\">\n {props.title}\n </SidebarNavTitle>\n }\n >\n <SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>\n </Show>\n <SidebarNavContent class={props.contentClass}>{props.content(context)}</SidebarNavContent>\n {props.footer ? (\n <SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>\n ) : null}\n {mobile ? <FocusNavigationOnMount aside={() => element} /> : null}\n </Show>","<Show\n when={mobile || props.titleVisibility !== 'mobile' || props.header}\n fallback={\n <SidebarNavTitle as={props.headingAs ?? 'h2'} class=\"sr-only\">\n {props.title}\n </SidebarNavTitle>\n }\n >\n <SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>\n </Show>","<SidebarNavTitle as={props.headingAs ?? 'h2'} class=\"sr-only\">\n {props.title}\n </SidebarNavTitle>","class=\"sr-only\"","<SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>","<SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>","props.header?.(context)","<SidebarNavContent class={props.contentClass}>{props.content(context)}</SidebarNavContent>","{props.footer ? (\n <SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>\n ) : null}","<SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>","mobile ? <FocusNavigationOnMount aside={() => element} /> : null","<FocusNavigationOnMount aside={() => element} />","aside={() => element}","<Show when={!isMobile()}>{(_wide) => renderSidebar(false)}</Show>","<Show when={mobileLoad()} keyed>\n {(loaded) => {\n if ('error' in loaded) throw loaded.error\n return (\n <loaded.MobileSidebar\n open={isMobile() && props.open}\n onOpenChange={props.onOpenChange}\n label={props.label}\n sheetClass={props.sheetClass}\n restoreFocusRef={props.restoreFocusRef}\n renderSidebar={() => renderSidebar(true)}\n />\n )\n }}\n </Show>","<loaded.MobileSidebar\n open={isMobile() && props.open}\n onOpenChange={props.onOpenChange}\n label={props.label}\n sheetClass={props.sheetClass}\n restoreFocusRef={props.restoreFocusRef}\n renderSidebar={() => renderSidebar(true)}\n />","loaded.MobileSidebar","isMobile() && props.open","renderSidebar={() => renderSidebar(true)}","wasNarrow"],"sources":["../../../../src/components/layout/contextual-sidebar/contextual-sidebar.tsx"],"sourcesContent":["import type { Accessor } from 'solid-js'\nimport type { JSX } from '@solidjs/web'\nimport {\n Show,\n createEffect,\n createMemo,\n createSignal,\n createUniqueId,\n flush,\n onCleanup,\n onSettled,\n} from 'solid-js'\nimport { MD_BREAKPOINT } from '#lib/breakpoints'\nimport { cn } from '#lib/utils'\nimport {\n SidebarNav,\n SidebarNavContent,\n SidebarNavFooter,\n SidebarNavHeader,\n SidebarNavTitle,\n} from '../sidebar-nav'\nimport { PixelResizeHandle } from '../pixel-resize-handle'\n\ntype MobileModule = typeof import('./mobile-contextual-sidebar')\ntype MobileLoad = MobileModule | { error: unknown }\n\nexport type ContextualSidebarRenderContext = {\n /** Whether the slot is being rendered inside the modal mobile sheet. */\n mobile: boolean\n /** Mount nested popovers and menus inside the mobile dialog's accessibility tree. */\n portalMount(): HTMLElement | undefined\n}\n\nexport type ContextualSidebarModeTransition = {\n phase: 'before' | 'after'\n from: 'desktop' | 'mobile'\n to: 'desktop' | 'mobile'\n desktopSidebar: HTMLElement | undefined\n}\n\nexport type ContextualSidebarProps = {\n /** Stable host id prefix; generated when omitted. */\n id?: string\n /** Landmark name shared by the desktop and mobile navigation. */\n label: string\n /** Visible navigation title and mobile dialog title. */\n title: string\n /**\n * Where the title row shows. `always` (default) draws it on desktop and in\n * the mobile sheet; `mobile` keeps the desktop title for assistive\n * technology only and drops the desktop row, for hosts whose top bar\n * already names the context. A `header` slot keeps the row visible.\n */\n titleVisibility?: 'always' | 'mobile'\n /** Host-controlled expanded state for the desktop panel and mobile dialog. */\n open: boolean\n onOpenChange(open: boolean): void\n /**\n * Presentation mode. `auto` (default) uses the built-in viewport breakpoint;\n * hosts can select `desktop` or the shared mobile `Sheet` themselves.\n */\n responsiveMode?: 'auto' | 'desktop' | 'mobile'\n /**\n * Coordinate host layout before a runtime mode change and after its DOM settles.\n * A superseded transition or unmounted sidebar does not emit an after phase.\n * Initial mode resolution does not emit either phase.\n */\n onResponsiveModeTransition?(event: ContextualSidebarModeTransition): void\n /** Current host-owned pixel width, reflected by the resize handle. */\n width: number\n minimum: number\n maximum: number\n step?: number\n /** Pass the host's initial viewport seed to distinguish stale desktop state. */\n wideViewportAtLoad?: boolean\n resizeLabel?: string\n /**\n * The resize edge's grip: the quieter rung by default, or the bordered chip\n * for hosts that want the heavier affordance.\n */\n resizeGrip?: 'chip' | 'rung'\n /** Stable external opener used when the modal mobile sheet closes. */\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n /** Called with the nav node so a host can project width onto its layout root. */\n onSidebarElement?: (element: HTMLElement | undefined, mobile: boolean) => void\n /** Host-owned layout classes applied to both nav instances. */\n sidebarClass?: string\n /** Host-owned responsive constraints for the modal sheet. */\n sheetClass?: string\n headerClass?: string\n contentClass?: string\n footerClass?: string\n headingAs?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'\n /** Optional action/content slot alongside the shared heading. */\n header?(context: ContextualSidebarRenderContext): JSX.Element\n /** View-specific navigation rows, projects, rooms, files, or sessions. */\n content(context: ContextualSidebarRenderContext): JSX.Element\n /** Optional view-specific footer, such as an archive affordance. */\n footer?(context: ContextualSidebarRenderContext): JSX.Element\n onWidthChange(width: number): void\n onWidthCommit?(width: number): void\n}\n\n/**\n * ContextualSidebar.\n *\n * Shared navigation geometry and interaction policy for an application's\n * contextual sidebar. The host keeps ownership of the actual grid width,\n * persisted preference, open state, and view-specific navigation content.\n */\nexport function ContextualSidebar(props: ContextualSidebarProps) {\n const [isMobile, setIsMobile] = createSignal(false)\n // Signal reads lag writes until the next flush, and a host can re-enter\n // `transition` from its callbacks within the same tick. This mirror holds\n // the committed mode so those re-entrant reads see the latest value.\n let mobileNow = false\n const [mobileLoad, setMobileLoad] = createSignal<MobileLoad>()\n let mobileLoadGeneration = 0\n let mobileLoadPending = false\n let mobileLoadSettled = false\n let responsiveModeInitialized = false\n let desktopSidebar: HTMLElement | undefined\n let transitionGeneration = 0\n let pendingMode: boolean | undefined\n let disposed = false\n onCleanup(() => {\n disposed = true\n transitionGeneration += 1\n })\n\n // What the mode resolution samples from the host: its open state, viewport\n // seed and callbacks. They are read here, in an effect's compute, and the mode\n // effect and `transition` read this snapshot, so a change to `open` never\n // re-runs the mode resolution and the apply phase reads no props. Created\n // before the mode effect, so its first apply has run by the time that one's\n // does.\n let host = {\n open: false,\n wideViewportAtLoad: undefined as boolean | undefined,\n onOpenChange: (_open: boolean) => {},\n onResponsiveModeTransition: undefined as\n | ContextualSidebarProps['onResponsiveModeTransition']\n | undefined,\n }\n createEffect(\n () => ({\n open: props.open,\n wideViewportAtLoad: props.wideViewportAtLoad,\n onOpenChange: props.onOpenChange,\n onResponsiveModeTransition: props.onResponsiveModeTransition,\n }),\n (next) => {\n host = next\n }\n )\n\n // `fromListener` marks a call from the media listener, outside any flush. A\n // host that answers a callback by changing `responsiveMode` (or disposing)\n // has that write applied by `flush()` right away, so the generation check\n // below sees it, as Solid 1's synchronous updates did. Inside the mode\n // effect, flush() is a no-op and the same flush re-runs the effect next.\n const transition = (next: boolean, closeStaleOpen: boolean, fromListener = false) => {\n // The host may synchronously update its props from either callback, which\n // re-enters the responsive effect before this transition has finished.\n if (pendingMode === next) return\n const previous = mobileNow\n const changed = responsiveModeInitialized && previous !== next\n const generation =\n changed || pendingMode !== undefined ? ++transitionGeneration : transitionGeneration\n pendingMode = next\n const event = {\n from: previous ? ('mobile' as const) : ('desktop' as const),\n to: next ? ('mobile' as const) : ('desktop' as const),\n desktopSidebar,\n }\n try {\n // Callers are the effect apply phase and a media listener, neither of\n // which tracks, so the host callbacks below never subscribe.\n if (changed) host.onResponsiveModeTransition?.({ ...event, phase: 'before' })\n if (changed && fromListener) flush()\n if (disposed || generation !== transitionGeneration) return\n if (closeStaleOpen) host.onOpenChange(false)\n if (closeStaleOpen && fromListener) flush()\n if (disposed || generation !== transitionGeneration) return\n if (next) loadMobile()\n mobileNow = next\n setIsMobile(next)\n if (changed) {\n queueMicrotask(() => {\n if (!disposed && generation === transitionGeneration && mobileNow === next)\n host.onResponsiveModeTransition?.({ ...event, phase: 'after' })\n })\n }\n } finally {\n if (generation === transitionGeneration) pendingMode = undefined\n }\n }\n // Keep the resolved component mounted across viewport changes for Sheet cleanup.\n const loadMobile = () => {\n if (mobileLoadPending || mobileLoadSettled) return\n mobileLoadPending = true\n const generation = ++mobileLoadGeneration\n // Native module caching shares successful loads without keeping a rejected promise.\n void import('./mobile-contextual-sidebar').then(\n (module) => {\n if (generation === mobileLoadGeneration) {\n mobileLoadPending = false\n mobileLoadSettled = true\n setMobileLoad(module)\n }\n },\n (error: unknown) => {\n if (generation === mobileLoadGeneration) {\n mobileLoadPending = false\n mobileLoadSettled = true\n setMobileLoad({ error })\n }\n }\n )\n }\n const [mobileMount, setMobileMount] = createSignal<\n { element: HTMLElement; connected: boolean } | undefined\n >()\n const generatedId = `contextual-sidebar-${createUniqueId()}`\n const id = () => props.id ?? generatedId\n const resizeLabel = () => props.resizeLabel ?? `Resize ${props.label}`\n const portalMount = () => {\n const mount = mobileMount()\n return mount?.connected && mount.element.isConnected ? mount.element : undefined\n }\n\n const responsiveMode = createMemo(() => props.responsiveMode ?? 'auto')\n // Only the mode is tracked; the open state and viewport seed come from the\n // `host` snapshot, so toggling `open` never re-runs the mode resolution.\n createEffect(responsiveMode, (mode) => {\n const wasMobile = mobileNow\n let media: MediaQueryList | undefined\n let viewportListener: (() => void) | undefined\n\n const cleanup = () => {\n mobileLoadGeneration += 1\n mobileLoadPending = false\n if (media && viewportListener) media.removeEventListener('change', viewportListener)\n }\n\n if (mode === 'desktop') {\n transition(false, false)\n } else if (mode === 'mobile') {\n // An explicit host transition into mobile must not briefly open a Sheet\n // with stale desktop-expanded state. An initial wide-loaded seed still\n // marks an open value as stale, including in host-selected mobile mode.\n const shouldCloseStaleOpen = responsiveModeInitialized\n ? !wasMobile && host.open\n : host.wideViewportAtLoad && host.open\n transition(true, Boolean(shouldCloseStaleOpen))\n } else {\n const mediaQuery = window.matchMedia(`(max-width: ${MD_BREAKPOINT})`)\n media = mediaQuery\n const updateViewport = () => {\n const nextIsMobile = mediaQuery.matches\n const wasNarrow = mobileNow\n // Close before mounting a modal. A desktop-expanded host state is not\n // mobile intent, and opening the Sheet for one frame can steal focus.\n transition(nextIsMobile, nextIsMobile && !wasNarrow, true)\n }\n viewportListener = updateViewport\n\n // Preserve a narrow-boot open intent. Initial auto and mobile modes use\n // the viewport seed to clear stale state; runtime transitions close it.\n const shouldCloseStaleOpen =\n media.matches &&\n (!responsiveModeInitialized ? host.wideViewportAtLoad && host.open : !wasMobile)\n transition(media.matches, Boolean(shouldCloseStaleOpen))\n if (!disposed) mediaQuery.addEventListener('change', updateViewport)\n }\n\n responsiveModeInitialized = true\n return cleanup\n })\n\n const renderSidebar = (mobile: boolean) => {\n let element: HTMLElement | undefined\n const context: ContextualSidebarRenderContext = {\n mobile,\n portalMount: () => (mobile ? portalMount() : undefined),\n }\n const navigationId = () => `${id()}-${mobile ? 'mobile' : 'desktop'}`\n\n onCleanup(() => {\n if (mobile && mobileMount()?.element === element) setMobileMount(undefined)\n if (!mobile && desktopSidebar === element) desktopSidebar = undefined\n element = undefined\n props.onSidebarElement?.(undefined, mobile)\n })\n\n return (\n <SidebarNav\n as=\"aside\"\n id={navigationId()}\n aria-label={props.label}\n aria-hidden={!mobile && !props.open ? 'true' : undefined}\n inert={!mobile && !props.open}\n data-contextual-sidebar={mobile ? 'mobile' : 'desktop'}\n data-open={mobile ? undefined : String(props.open)}\n ref={(node: HTMLElement) => {\n element = node\n if (!mobile) desktopSidebar = node\n if (mobile) {\n setMobileMount({ element: node, connected: node.isConnected })\n queueMicrotask(() => {\n if (node.isConnected && mobileMount()?.element === node)\n setMobileMount({ element: node, connected: true })\n })\n }\n props.onSidebarElement?.(node, mobile)\n }}\n class={cn('relative h-full w-full max-w-full', props.sidebarClass)}\n >\n <Show when={!mobile && props.open}>\n <PixelResizeHandle\n // The ruler spans the sidebar as a pointer-events-none overlay; lift\n // it above the neighbouring pane so the edge stays grabbable.\n class=\"z-(--z-docked)\"\n side=\"left\"\n value={props.width}\n minimum={props.minimum}\n maximum={props.maximum}\n step={props.step}\n label={resizeLabel()}\n grip={props.resizeGrip ?? 'rung'}\n controls={navigationId()}\n onChange={props.onWidthChange}\n onCommit={props.onWidthCommit}\n />\n </Show>\n <Show when={!mobile || mobileMount()?.connected}>\n <Show\n when={mobile || props.titleVisibility !== 'mobile' || props.header}\n fallback={\n <SidebarNavTitle as={props.headingAs ?? 'h2'} class=\"sr-only\">\n {props.title}\n </SidebarNavTitle>\n }\n >\n <SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>\n <SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>\n {props.header?.(context)}\n </SidebarNavHeader>\n </Show>\n <SidebarNavContent class={props.contentClass}>{props.content(context)}</SidebarNavContent>\n {props.footer ? (\n <SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>\n ) : null}\n {mobile ? <FocusNavigationOnMount aside={() => element} /> : null}\n </Show>\n </SidebarNav>\n )\n }\n\n return (\n <>\n <Show when={!isMobile()}>{(_wide) => renderSidebar(false)}</Show>\n <Show when={mobileLoad()} keyed>\n {(loaded) => {\n if ('error' in loaded) throw loaded.error\n return (\n <loaded.MobileSidebar\n open={isMobile() && props.open}\n onOpenChange={props.onOpenChange}\n label={props.label}\n sheetClass={props.sheetClass}\n restoreFocusRef={props.restoreFocusRef}\n renderSidebar={() => renderSidebar(true)}\n />\n )\n }}\n </Show>\n </>\n )\n}\n\nconst FIRST_CONTROL =\n 'button:not(:disabled), [href], input:not(:disabled):not([type=\"hidden\"]), ' +\n 'select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])'\n\n/**\n * The mobile navigation renders once its aside is connected, a tick after the Sheet placed its\n * initial focus on what it held then: its own Close, or the panel. Hand that focus to the\n * navigation's first control, as a keyboard opener expects; focus already inside the\n * navigation, or outside the Sheet, stays where it is.\n */\nfunction FocusNavigationOnMount(props: { aside: () => HTMLElement | undefined }) {\n onSettled(() => {\n const aside = props.aside()\n const sheet = aside?.closest<HTMLElement>('[role=\"dialog\"]')\n const active = document.activeElement\n if (!aside || !sheet || !active || !sheet.contains(active) || aside.contains(active)) return\n aside.querySelector<HTMLElement>(FIRST_CONTROL)?.focus()\n })\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;AA8GA,SAAgB,kBAAk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;KAAY,OAAA,MAAM;IAAU;IAC5B,IAAA,kBAAA;KAAiB,OAAA,MAAM;IAAe;IACtCC,qBAAqB,cAAc,IAAI;GACxC,CAAA;EAEL;CACI,CAAA,CAfP;AAkBL;AAEA,IAAM,gBACJ;;;;;;;AASF,SAAS,uBAAuB,OAAiD;CAC/E,gBAAgB;EACd,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,QAAQ,OAAO,QAAqB,mBAAiB;EAC3D,MAAM,SAAS,SAAS;EACxB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,SAAS,MAAM,KAAK,MAAM,SAAS,MAAM,GAAG;EACtF,MAAM,cAA2B,aAAa,CAAC,EAAE,MAAM;CACzD,CAAC;CACD,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/split-layout/index.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/split-layout/index.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA"}
|
|
@@ -2,4 +2,5 @@ import { MAX_LAYOUT_DEPTH, MAX_LAYOUT_LEAVES, MAX_SPLIT_RATIO, MIN_SPLIT_RATIO,
|
|
|
2
2
|
import { closePane, createLayoutState, focusPane, movePane, neighborLeaf, normalizeLayout, resizeSplit, splitPane, splitPaneBalanced, swapPanes, undoClosePane } from "./model.js";
|
|
3
3
|
import { computeLayoutFrames } from "./geometry.js";
|
|
4
4
|
import { SplitLayout } from "./split-layout.js";
|
|
5
|
-
|
|
5
|
+
import { PANE_FOCUS_TARGET, focusPaneOnHover, hoverTakesFocus, paneFocusMode, rememberPaneFocus, setPaneFocusMode, subscribePaneFocusMode } from "./pane-focus.js";
|
|
6
|
+
export { MAX_LAYOUT_DEPTH, MAX_LAYOUT_LEAVES, MAX_SPLIT_RATIO, MIN_SPLIT_RATIO, PANE_FOCUS_TARGET, SplitLayout, clampSplitRatio, closePane, computeLayoutFrames, countLeaves, createLayoutState, focusPane, focusPaneOnHover, hoverTakesFocus, layoutDepth, listLeaves, movePane, neighborLeaf, normalizeLayout, paneFocusMode, rememberPaneFocus, resizeSplit, setPaneFocusMode, splitPane, splitPaneBalanced, subscribePaneFocusMode, swapPanes, undoClosePane };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type PaneFocusMode = 'hover' | 'click';
|
|
2
|
+
/** How panes take focus: on hover unless the person chose click. */
|
|
3
|
+
export declare function paneFocusMode(): PaneFocusMode;
|
|
4
|
+
export declare function setPaneFocusMode(value: PaneFocusMode): void;
|
|
5
|
+
/** Calls `listener` after the choice changes; returns the way to stop. */
|
|
6
|
+
export declare function subscribePaneFocusMode(listener: () => void): () => void;
|
|
7
|
+
/** A pane's own element that takes the keys when hover activates it (a terminal's input, say). */
|
|
8
|
+
export declare const PANE_FOCUS_TARGET = "[data-pane-focus-target]";
|
|
9
|
+
/** Remembers where focus is inside `pane`; call from the pane's `focusin`. */
|
|
10
|
+
export declare function rememberPaneFocus(pane: HTMLElement, target: EventTarget | null): void;
|
|
11
|
+
type PointerLike = Pick<PointerEvent, 'pointerType' | 'buttons' | 'movementX' | 'movementY'>;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the pointer moving over `pane` should activate it. Only a real mouse move with no button
|
|
14
|
+
* held counts: a touch, a pen tap, a drag, a selection or content shifting under a still pointer
|
|
15
|
+
* does not. Focus already inside the pane, inside an open overlay, or in a text field that is in
|
|
16
|
+
* no pane (no `[data-pane-id]` ancestor) and outside `scope` stays where it is.
|
|
17
|
+
*/
|
|
18
|
+
export declare function hoverTakesFocus(event: PointerLike, pane: HTMLElement, scope?: Element): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Moves focus into `pane` as a hover activation: back to the element it last had focus in, else
|
|
21
|
+
* its `data-pane-focus-target`, else the pane itself. The pane's `focusin` then marks it active.
|
|
22
|
+
* Returns whether focus moved.
|
|
23
|
+
*/
|
|
24
|
+
export declare function focusPaneOnHover(event: PointerLike, pane: HTMLElement, options?: {
|
|
25
|
+
scope?: Element;
|
|
26
|
+
mode?: PaneFocusMode;
|
|
27
|
+
}): boolean;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=pane-focus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pane-focus.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/split-layout/pane-focus.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,CAAA;AAoB7C,oEAAoE;AACpE,wBAAgB,aAAa,IAAI,aAAa,CAW7C;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAS3D;AAED,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAGvE;AAED,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,6BAA6B,CAAA;AAS3D,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAGrF;AAED,KAAK,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC,CAAA;AAE5F;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAS/F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,WAAW,EACjB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,aAAa,CAAA;CAAO,GACtD,OAAO,CAUT"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/components/layout/split-layout/pane-focus.ts
|
|
2
|
+
var STORAGE_KEY = "adea:pane-focus-mode:v1";
|
|
3
|
+
var STATE_KEY = Symbol.for("adea.ui.pane-focus-mode");
|
|
4
|
+
var state = globalThis[STATE_KEY] ??= {
|
|
5
|
+
value: void 0,
|
|
6
|
+
listeners: /* @__PURE__ */ new Set()
|
|
7
|
+
};
|
|
8
|
+
function storage() {
|
|
9
|
+
try {
|
|
10
|
+
return typeof localStorage === "undefined" ? void 0 : localStorage;
|
|
11
|
+
} catch {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** How panes take focus: on hover unless the person chose click. */
|
|
16
|
+
function paneFocusMode() {
|
|
17
|
+
if (state.value === void 0) {
|
|
18
|
+
let saved = null;
|
|
19
|
+
try {
|
|
20
|
+
saved = storage()?.getItem(STORAGE_KEY) ?? null;
|
|
21
|
+
} catch {}
|
|
22
|
+
state.value = saved === "click" ? "click" : "hover";
|
|
23
|
+
}
|
|
24
|
+
return state.value;
|
|
25
|
+
}
|
|
26
|
+
function setPaneFocusMode(value) {
|
|
27
|
+
state.value = value;
|
|
28
|
+
try {
|
|
29
|
+
if (value === "hover") storage()?.removeItem(STORAGE_KEY);
|
|
30
|
+
else storage()?.setItem(STORAGE_KEY, value);
|
|
31
|
+
} catch {}
|
|
32
|
+
for (const listener of state.listeners) listener();
|
|
33
|
+
}
|
|
34
|
+
/** Calls `listener` after the choice changes; returns the way to stop. */
|
|
35
|
+
function subscribePaneFocusMode(listener) {
|
|
36
|
+
state.listeners.add(listener);
|
|
37
|
+
return () => state.listeners.delete(listener);
|
|
38
|
+
}
|
|
39
|
+
/** A pane's own element that takes the keys when hover activates it (a terminal's input, say). */
|
|
40
|
+
var PANE_FOCUS_TARGET = "[data-pane-focus-target]";
|
|
41
|
+
var OVERLAY = "[role=\"dialog\"], [role=\"alertdialog\"], [role=\"menu\"], [role=\"listbox\"]";
|
|
42
|
+
var EDITABLE = "input, textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]";
|
|
43
|
+
var lastFocused = /* @__PURE__ */ new WeakMap();
|
|
44
|
+
/** Remembers where focus is inside `pane`; call from the pane's `focusin`. */
|
|
45
|
+
function rememberPaneFocus(pane, target) {
|
|
46
|
+
if (target instanceof HTMLElement && target !== pane && pane.contains(target)) lastFocused.set(pane, target);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether the pointer moving over `pane` should activate it. Only a real mouse move with no button
|
|
50
|
+
* held counts: a touch, a pen tap, a drag, a selection or content shifting under a still pointer
|
|
51
|
+
* does not. Focus already inside the pane, inside an open overlay, or in a text field that is in
|
|
52
|
+
* no pane (no `[data-pane-id]` ancestor) and outside `scope` stays where it is.
|
|
53
|
+
*/
|
|
54
|
+
function hoverTakesFocus(event, pane, scope) {
|
|
55
|
+
if (event.pointerType !== "mouse" || event.buttons !== 0) return false;
|
|
56
|
+
if (event.movementX === 0 && event.movementY === 0) return false;
|
|
57
|
+
const active = pane.ownerDocument.activeElement;
|
|
58
|
+
if (!active || active === pane.ownerDocument.body) return true;
|
|
59
|
+
if (pane.contains(active)) return false;
|
|
60
|
+
if (active.closest(OVERLAY)) return false;
|
|
61
|
+
return active.closest("[data-pane-id]") !== null || (scope?.contains(active) ?? false) || !active.matches(EDITABLE);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Moves focus into `pane` as a hover activation: back to the element it last had focus in, else
|
|
65
|
+
* its `data-pane-focus-target`, else the pane itself. The pane's `focusin` then marks it active.
|
|
66
|
+
* Returns whether focus moved.
|
|
67
|
+
*/
|
|
68
|
+
function focusPaneOnHover(event, pane, options = {}) {
|
|
69
|
+
if ((options.mode ?? paneFocusMode()) !== "hover") return false;
|
|
70
|
+
if (!hoverTakesFocus(event, pane, options.scope)) return false;
|
|
71
|
+
const remembered = lastFocused.get(pane);
|
|
72
|
+
((remembered?.isConnected && pane.contains(remembered) ? remembered : void 0) ?? pane.querySelector("[data-pane-focus-target]") ?? pane).focus({ preventScroll: true });
|
|
73
|
+
return pane.contains(pane.ownerDocument.activeElement);
|
|
74
|
+
}
|
|
75
|
+
export { PANE_FOCUS_TARGET, focusPaneOnHover, hoverTakesFocus, paneFocusMode, rememberPaneFocus, setPaneFocusMode, subscribePaneFocusMode };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=pane-focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pane-focus.js","names":[],"sources":["../../../../src/components/layout/split-layout/pane-focus.ts"],"sourcesContent":["// How a pane takes focus: on hover (the pointer moving onto it activates it, so the keys typed\n// next go to it) or on click. The choice is a device preference kept in `localStorage`, shared by\n// every pane surface: SplitLayout reads it by default, and a host's own pane (a floating window,\n// for instance) calls `focusPaneOnHover` from its `pointermove` to behave the same way.\n\nexport type PaneFocusMode = 'hover' | 'click'\n\nconst STORAGE_KEY = 'adea:pane-focus-mode:v1'\n\n// One shared copy, because the preference reaches the page from more than one bundle.\ntype PaneFocusState = { value: PaneFocusMode | undefined; listeners: Set<() => void> }\nconst STATE_KEY = Symbol.for('adea.ui.pane-focus-mode')\nconst state: PaneFocusState = ((globalThis as Record<symbol, unknown>)[STATE_KEY] ??= {\n value: undefined,\n listeners: new Set<() => void>(),\n}) as PaneFocusState\n\nfunction storage(): Pick<Storage, 'getItem' | 'setItem' | 'removeItem'> | undefined {\n try {\n return typeof localStorage === 'undefined' ? undefined : localStorage\n } catch {\n return undefined\n }\n}\n\n/** How panes take focus: on hover unless the person chose click. */\nexport function paneFocusMode(): PaneFocusMode {\n if (state.value === undefined) {\n let saved: string | null = null\n try {\n saved = storage()?.getItem(STORAGE_KEY) ?? null\n } catch {\n // Unreadable storage means the default.\n }\n state.value = saved === 'click' ? 'click' : 'hover'\n }\n return state.value\n}\n\nexport function setPaneFocusMode(value: PaneFocusMode): void {\n state.value = value\n try {\n if (value === 'hover') storage()?.removeItem(STORAGE_KEY)\n else storage()?.setItem(STORAGE_KEY, value)\n } catch {\n // The choice still applies for this session.\n }\n for (const listener of state.listeners) listener()\n}\n\n/** Calls `listener` after the choice changes; returns the way to stop. */\nexport function subscribePaneFocusMode(listener: () => void): () => void {\n state.listeners.add(listener)\n return () => state.listeners.delete(listener)\n}\n\n/** A pane's own element that takes the keys when hover activates it (a terminal's input, say). */\nexport const PANE_FOCUS_TARGET = '[data-pane-focus-target]'\n\n// Focus inside an open overlay is never taken by a pane the pointer passes over.\nconst OVERLAY = '[role=\"dialog\"], [role=\"alertdialog\"], [role=\"menu\"], [role=\"listbox\"]'\nconst EDITABLE = 'input, textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]'\n\n// The element each pane last had focus in, so hovering back returns the keys to it.\nconst lastFocused = new WeakMap<HTMLElement, HTMLElement>()\n\n/** Remembers where focus is inside `pane`; call from the pane's `focusin`. */\nexport function rememberPaneFocus(pane: HTMLElement, target: EventTarget | null): void {\n if (target instanceof HTMLElement && target !== pane && pane.contains(target))\n lastFocused.set(pane, target)\n}\n\ntype PointerLike = Pick<PointerEvent, 'pointerType' | 'buttons' | 'movementX' | 'movementY'>\n\n/**\n * Whether the pointer moving over `pane` should activate it. Only a real mouse move with no button\n * held counts: a touch, a pen tap, a drag, a selection or content shifting under a still pointer\n * does not. Focus already inside the pane, inside an open overlay, or in a text field that is in\n * no pane (no `[data-pane-id]` ancestor) and outside `scope` stays where it is.\n */\nexport function hoverTakesFocus(event: PointerLike, pane: HTMLElement, scope?: Element): boolean {\n if (event.pointerType !== 'mouse' || event.buttons !== 0) return false\n if (event.movementX === 0 && event.movementY === 0) return false\n const active = pane.ownerDocument.activeElement\n if (!active || active === pane.ownerDocument.body) return true\n if (pane.contains(active)) return false\n if (active.closest(OVERLAY)) return false\n const inPane = active.closest('[data-pane-id]') !== null || (scope?.contains(active) ?? false)\n return inPane || !active.matches(EDITABLE)\n}\n\n/**\n * Moves focus into `pane` as a hover activation: back to the element it last had focus in, else\n * its `data-pane-focus-target`, else the pane itself. The pane's `focusin` then marks it active.\n * Returns whether focus moved.\n */\nexport function focusPaneOnHover(\n event: PointerLike,\n pane: HTMLElement,\n options: { scope?: Element; mode?: PaneFocusMode } = {}\n): boolean {\n if ((options.mode ?? paneFocusMode()) !== 'hover') return false\n if (!hoverTakesFocus(event, pane, options.scope)) return false\n const remembered = lastFocused.get(pane)\n const target =\n (remembered?.isConnected && pane.contains(remembered) ? remembered : undefined) ??\n pane.querySelector<HTMLElement>(PANE_FOCUS_TARGET) ??\n pane\n target.focus({ preventScroll: true })\n return pane.contains(pane.ownerDocument.activeElement)\n}\n"],"mappings":";AAOA,IAAM,cAAc;AAIpB,IAAM,YAAY,OAAO,IAAI,yBAAyB;AACtD,IAAM,QAAyB,WAAwC,eAAe;CACpF,OAAO,KAAA;CACP,2BAAW,IAAI,IAAgB;AACjC;AAEA,SAAS,UAA2E;CAClF,IAAI;EACF,OAAO,OAAO,iBAAiB,cAAc,KAAA,IAAY;CAC3D,QAAQ;EACN;CACF;AACF;;AAGA,SAAgB,gBAA+B;CAC7C,IAAI,MAAM,UAAU,KAAA,GAAW;EAC7B,IAAI,QAAuB;EAC3B,IAAI;GACF,QAAQ,QAAQ,CAAC,EAAE,QAAQ,WAAW,KAAK;EAC7C,QAAQ,CAER;EACA,MAAM,QAAQ,UAAU,UAAU,UAAU;CAC9C;CACA,OAAO,MAAM;AACf;AAEA,SAAgB,iBAAiB,OAA4B;CAC3D,MAAM,QAAQ;CACd,IAAI;EACF,IAAI,UAAU,SAAS,QAAQ,CAAC,EAAE,WAAW,WAAW;OACnD,QAAQ,CAAC,EAAE,QAAQ,aAAa,KAAK;CAC5C,QAAQ,CAER;CACA,KAAK,MAAM,YAAY,MAAM,WAAW,SAAS;AAC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
|
2
2
|
import { type JSX } from '@solidjs/web';
|
|
3
3
|
import { type PaneDropIntent } from './drop';
|
|
4
|
+
import { type PaneFocusMode } from './pane-focus';
|
|
4
5
|
export type { PaneDropIntent } from './drop';
|
|
5
6
|
import { type SplitLayoutBranch, type SplitLayoutLeaf, type SplitLayoutState } from './model';
|
|
6
7
|
export type SplitLayoutProps<L extends SplitLayoutLeaf> = {
|
|
@@ -18,6 +19,11 @@ export type SplitLayoutProps<L extends SplitLayoutLeaf> = {
|
|
|
18
19
|
labelForSeparator?: (branch: SplitLayoutBranch<L>) => string;
|
|
19
20
|
onResize: (splitId: string, ratio: number) => void;
|
|
20
21
|
onFocus?: (leafId: string) => void;
|
|
22
|
+
/**
|
|
23
|
+
* How a pane takes focus. `hover` activates the pane the mouse moves onto (keys typed next go to
|
|
24
|
+
* it); `click` waits for a click. Defaults to the device preference (`paneFocusMode`).
|
|
25
|
+
*/
|
|
26
|
+
focusMode?: PaneFocusMode;
|
|
21
27
|
/** Host performs the model transition and returns the surviving focus destination. */
|
|
22
28
|
onClose?: (leafId: string) => string | undefined;
|
|
23
29
|
/** Pointer placement only; the host supplies keyboard commands and performs the model transition. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split-layout.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/split-layout/split-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,QAAQ,EACd,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,cAAc,CAAA;AAQvC,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"split-layout.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/split-layout/split-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,QAAQ,EACd,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,cAAc,CAAA;AAQvC,OAAO,EAA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,EAAE,MAAM,EAAE,cAAc,KAAK,IAAI,CAAA;IAC3E,qFAAqF;IACrF,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CAAA;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA+HD,wHAAwH;AACxH,wBAAgB,WAAW,CAAC,CAAC,SAAS,eAAe,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,eA0fhF"}
|
|
@@ -4,6 +4,7 @@ import { resizeSeparatorClass } from "../../../lib/resize-separator.js";
|
|
|
4
4
|
import { cn } from "../../../lib/utils.js";
|
|
5
5
|
import { computeLayoutFrames } from "./geometry.js";
|
|
6
6
|
import { paneDropIntent } from "./drop.js";
|
|
7
|
+
import { focusPaneOnHover, paneFocusMode, rememberPaneFocus, subscribePaneFocusMode } from "./pane-focus.js";
|
|
7
8
|
import { fastIcon } from "../../../lib/fast-icon.js";
|
|
8
9
|
import { MAX_SPLIT_RATIO, MIN_SPLIT_RATIO, listLeaves } from "./tree.js";
|
|
9
10
|
import { Dynamic, className, createComponent, delegateEvents, effect, insert, memo, readShallow, ref, setAttribute, style, template } from "@solidjs/web";
|
|
@@ -158,6 +159,9 @@ function SplitLayout(props) {
|
|
|
158
159
|
const [drag, setDrag] = createSignal();
|
|
159
160
|
const [drop, setDrop] = createSignal();
|
|
160
161
|
const [resizeController, setResizeController] = createSignal();
|
|
162
|
+
const [preferredFocusMode, setPreferredFocusMode] = createSignal(paneFocusMode());
|
|
163
|
+
onCleanup(subscribePaneFocusMode(() => setPreferredFocusMode(paneFocusMode())));
|
|
164
|
+
const focusMode = () => props.focusMode ?? preferredFocusMode();
|
|
161
165
|
const reloadRequired = () => resizeControllerEntry >= resizeControllerEntries.length;
|
|
162
166
|
const cancelPendingFocusRestore = () => {
|
|
163
167
|
if (pendingFocusFrame !== void 0) cancelAnimationFrame(pendingFocusFrame);
|
|
@@ -362,7 +366,17 @@ function SplitLayout(props) {
|
|
|
362
366
|
var _el$9 = _el$7.nextSibling;
|
|
363
367
|
var _el$10 = _el$9.nextSibling;
|
|
364
368
|
var _el$11 = _el$6.nextSibling;
|
|
365
|
-
_el$5._$$
|
|
369
|
+
_el$5._$$pointermove = (event) => {
|
|
370
|
+
if (drag()) return;
|
|
371
|
+
focusPaneOnHover(event, event.currentTarget, {
|
|
372
|
+
mode: focusMode(),
|
|
373
|
+
...root ? { scope: root } : {}
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
_el$5._$$focusin = (event) => {
|
|
377
|
+
rememberPaneFocus(event.currentTarget, event.target);
|
|
378
|
+
props.onFocus?.(id);
|
|
379
|
+
};
|
|
366
380
|
_el$5.addEventListener("drop", (event) => {
|
|
367
381
|
const current = allowedTarget(id, event.dataTransfer);
|
|
368
382
|
const next = paneDropIntent(event.clientX, event.clientY, event.currentTarget.getBoundingClientRect());
|
|
@@ -499,14 +513,15 @@ function SplitLayout(props) {
|
|
|
499
513
|
width: 0,
|
|
500
514
|
height: 0
|
|
501
515
|
})),
|
|
502
|
-
r:
|
|
503
|
-
d:
|
|
516
|
+
r: focusMode(),
|
|
517
|
+
d: props.onMove ? "true" : "false",
|
|
518
|
+
l: readShallow(cn("flex min-w-0 flex-1 items-center gap-2 truncate text-sm", {
|
|
504
519
|
"cursor-grab": Boolean(props.onMove),
|
|
505
520
|
"cursor-grabbing": drag()?.id === id
|
|
506
521
|
})),
|
|
507
|
-
|
|
522
|
+
u: props.onMove ? `Drag ${props.labelForLeaf(leaf())} to move` : void 0
|
|
508
523
|
};
|
|
509
|
-
}, ({ e, t, a, o, i, n, s, h, r, d, l }, _p$) => {
|
|
524
|
+
}, ({ e, t, a, o, i, n, s, h, r, d, l, u }, _p$) => {
|
|
510
525
|
e !== _p$?.e && setAttribute(_el$5, "id", e);
|
|
511
526
|
t !== _p$?.t && setAttribute(_el$5, "aria-label", t);
|
|
512
527
|
a !== _p$?.a && setAttribute(_el$5, "tabindex", a);
|
|
@@ -515,9 +530,10 @@ function SplitLayout(props) {
|
|
|
515
530
|
n !== _p$?.n && setAttribute(_el$5, "data-drop-direction", n);
|
|
516
531
|
s !== _p$?.s && setAttribute(_el$5, "data-drop-placement", s);
|
|
517
532
|
style(_el$5, h, _p$?.h);
|
|
518
|
-
r !== _p$?.r && setAttribute(_el$
|
|
519
|
-
|
|
520
|
-
|
|
533
|
+
r !== _p$?.r && setAttribute(_el$5, "data-focus-mode", r);
|
|
534
|
+
d !== _p$?.d && setAttribute(_el$7, "draggable", d);
|
|
535
|
+
className(_el$7, l, _p$?.l);
|
|
536
|
+
u !== _p$?.u && setAttribute(_el$7, "title", u);
|
|
521
537
|
});
|
|
522
538
|
return _el$5;
|
|
523
539
|
}
|
|
@@ -642,7 +658,7 @@ function SplitLayout(props) {
|
|
|
642
658
|
});
|
|
643
659
|
return _el$;
|
|
644
660
|
}
|
|
645
|
-
delegateEvents(["focusin"]);
|
|
661
|
+
delegateEvents(["focusin", "pointermove"]);
|
|
646
662
|
export { SplitLayout };
|
|
647
663
|
|
|
648
664
|
//# sourceMappingURL=split-layout.js.map
|