@adea-ai/ui 0.160.3 → 0.160.4
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/r/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +23 -0
- package/package.json +1 -1
- package/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +23 -0
|
@@ -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;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I,CAAA;IACnD,iEAAiE;IACjE,MAAM,CAAC,CAAC,OAAO,EAAE,8BAA8B,GAAG,GAAG,CAAC,OAAO,CAAA;IAC7D,0EAA0E;IAC1E,OAAO,CAAC,OAAO,EAAE,8BAA8B,GAAG,GAAG,CAAC,OAAO,CAAA;IAC7D,oEAAoE;IACpE,MAAM,CAAC,CAAC,OAAO,EAAE,8BAA8B,GAAG,GAAG,CAAC,OAAO,CAAA;IAC7D,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eA6Q9D"}
|
|
@@ -3,7 +3,7 @@ import { cn } from "../../../lib/utils.js";
|
|
|
3
3
|
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,WAAW;CACf,gBAAgB;EACd,WAAW;EACX,wBAAwB;CAC1B,CAAC;CAQD,IAAI,OAAO;EACT,MAAM;EACN,oBAAoB,KAAA;EACpB,eAAe,UAAmB,CAAC;EACnC,4BAA4B,KAAA;CAG9B;CACA,oBACS;EACL,MAAM,MAAM;EACZ,oBAAoB,MAAM;EAC1B,cAAc,MAAM;EACpB,4BAA4B,MAAM;CACpC,KACC,SAAS;EACR,OAAO;CACT,CACF;CAOA,MAAM,cAAc,MAAe,gBAAyB,eAAe,UAAU;EAGnF,IAAI,gBAAgB,MAAM;EAC1B,MAAM,WAAW;EACjB,MAAM,UAAU,6BAA6B,aAAa;EAC1D,MAAM,aACJ,WAAW,gBAAgB,KAAA,IAAY,EAAE,uBAAuB;EAClE,cAAc;EACd,MAAM,QAAQ;GACZ,MAAM,WAAY,WAAsB;GACxC,IAAI,OAAQ,WAAsB;GAClC;EACF;EACA,IAAI;GAGF,IAAI,SAAS,KAAK,6BAA6B;IAAE,GAAG;IAAO,OAAO;GAAS,CAAC;GAC5E,IAAI,WAAW,cAAc,MAAM;GACnC,IAAI,YAAY,eAAe,sBAA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S,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,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,WAAW;CACf,gBAAgB;EACd,WAAW;EACX,wBAAwB;CAC1B,CAAC;CAQD,IAAI,OAAO;EACT,MAAM;EACN,oBAAoB,KAAA;EACpB,eAAe,UAAmB,CAAC;EACnC,4BAA4B,KAAA;CAG9B;CACA,oBACS;EACL,MAAM,MAAM;EACZ,oBAAoB,MAAM;EAC1B,cAAc,MAAM;EACpB,4BAA4B,MAAM;CACpC,KACC,SAAS;EACR,OAAO;CACT,CACF;CAOA,MAAM,cAAc,MAAe,gBAAyB,eAAe,UAAU;EAGnF,IAAI,gBAAgB,MAAM;EAC1B,MAAM,WAAW;EACjB,MAAM,UAAU,6BAA6B,aAAa;EAC1D,MAAM,aACJ,WAAW,gBAAgB,K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AA;GAqCW;;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;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"}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
createUniqueId,
|
|
9
9
|
flush,
|
|
10
10
|
onCleanup,
|
|
11
|
+
onSettled,
|
|
11
12
|
} from 'solid-js'
|
|
12
13
|
import { MD_BREAKPOINT } from '../../../lib/breakpoints'
|
|
13
14
|
import { cn } from '../../../lib/utils'
|
|
@@ -350,6 +351,7 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
|
|
|
350
351
|
{props.footer ? (
|
|
351
352
|
<SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>
|
|
352
353
|
) : null}
|
|
354
|
+
{mobile ? <FocusNavigationOnMount aside={() => element} /> : null}
|
|
353
355
|
</Show>
|
|
354
356
|
</SidebarNav>
|
|
355
357
|
)
|
|
@@ -376,3 +378,24 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
|
|
|
376
378
|
</>
|
|
377
379
|
)
|
|
378
380
|
}
|
|
381
|
+
|
|
382
|
+
const FIRST_CONTROL =
|
|
383
|
+
'button:not(:disabled), [href], input:not(:disabled):not([type="hidden"]), ' +
|
|
384
|
+
'select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])'
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* The mobile navigation renders once its aside is connected, a tick after the Sheet placed its
|
|
388
|
+
* initial focus on what it held then: its own Close, or the panel. Hand that focus to the
|
|
389
|
+
* navigation's first control, as a keyboard opener expects; focus already inside the
|
|
390
|
+
* navigation, or outside the Sheet, stays where it is.
|
|
391
|
+
*/
|
|
392
|
+
function FocusNavigationOnMount(props: { aside: () => HTMLElement | undefined }) {
|
|
393
|
+
onSettled(() => {
|
|
394
|
+
const aside = props.aside()
|
|
395
|
+
const sheet = aside?.closest<HTMLElement>('[role="dialog"]')
|
|
396
|
+
const active = document.activeElement
|
|
397
|
+
if (!aside || !sheet || !active || !sheet.contains(active) || aside.contains(active)) return
|
|
398
|
+
aside.querySelector<HTMLElement>(FIRST_CONTROL)?.focus()
|
|
399
|
+
})
|
|
400
|
+
return null
|
|
401
|
+
}
|
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
createUniqueId,
|
|
9
9
|
flush,
|
|
10
10
|
onCleanup,
|
|
11
|
+
onSettled,
|
|
11
12
|
} from 'solid-js'
|
|
12
13
|
import { MD_BREAKPOINT } from '#lib/breakpoints'
|
|
13
14
|
import { cn } from '#lib/utils'
|
|
@@ -350,6 +351,7 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
|
|
|
350
351
|
{props.footer ? (
|
|
351
352
|
<SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>
|
|
352
353
|
) : null}
|
|
354
|
+
{mobile ? <FocusNavigationOnMount aside={() => element} /> : null}
|
|
353
355
|
</Show>
|
|
354
356
|
</SidebarNav>
|
|
355
357
|
)
|
|
@@ -376,3 +378,24 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
|
|
|
376
378
|
</>
|
|
377
379
|
)
|
|
378
380
|
}
|
|
381
|
+
|
|
382
|
+
const FIRST_CONTROL =
|
|
383
|
+
'button:not(:disabled), [href], input:not(:disabled):not([type="hidden"]), ' +
|
|
384
|
+
'select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])'
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* The mobile navigation renders once its aside is connected, a tick after the Sheet placed its
|
|
388
|
+
* initial focus on what it held then: its own Close, or the panel. Hand that focus to the
|
|
389
|
+
* navigation's first control, as a keyboard opener expects; focus already inside the
|
|
390
|
+
* navigation, or outside the Sheet, stays where it is.
|
|
391
|
+
*/
|
|
392
|
+
function FocusNavigationOnMount(props: { aside: () => HTMLElement | undefined }) {
|
|
393
|
+
onSettled(() => {
|
|
394
|
+
const aside = props.aside()
|
|
395
|
+
const sheet = aside?.closest<HTMLElement>('[role="dialog"]')
|
|
396
|
+
const active = document.activeElement
|
|
397
|
+
if (!aside || !sheet || !active || !sheet.contains(active) || aside.contains(active)) return
|
|
398
|
+
aside.querySelector<HTMLElement>(FIRST_CONTROL)?.focus()
|
|
399
|
+
})
|
|
400
|
+
return null
|
|
401
|
+
}
|