@adea-ai/ui 0.150.0 → 0.151.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/composites/inline-citation/inline-citation.d.ts +2 -1
- package/dist/components/composites/inline-citation/inline-citation.d.ts.map +1 -1
- package/dist/components/composites/inline-citation/inline-citation.js +36 -3
- package/dist/components/composites/inline-citation/inline-citation.js.map +1 -1
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts +5 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts.map +1 -1
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js +54 -23
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.js +9 -4
- package/dist/components/ui/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/ui/dialog/dialog.js +1 -1
- package/dist/components/ui/dialog/dialog.js.map +1 -1
- package/dist/components/ui/modal-dialog/modal-dialog.d.ts +18 -3
- package/dist/components/ui/modal-dialog/modal-dialog.d.ts.map +1 -1
- package/dist/components/ui/modal-dialog/modal-dialog.js +29 -3
- package/dist/components/ui/modal-dialog/modal-dialog.js.map +1 -1
- package/dist/r/src/components/composites/inline-citation/inline-citation.tsx +53 -4
- package/dist/r/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +76 -28
- package/dist/r/src/components/ui/alert-dialog/alert-dialog.tsx +11 -2
- package/dist/r/src/components/ui/dialog/dialog.tsx +1 -1
- package/dist/r/src/components/ui/modal-dialog/modal-dialog.tsx +33 -4
- package/package.json +1 -1
- package/src/components/composites/inline-citation/inline-citation.tsx +53 -4
- package/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +76 -28
- package/src/components/ui/alert-dialog/alert-dialog.tsx +11 -2
- package/src/components/ui/dialog/dialog.tsx +1 -1
- package/src/components/ui/modal-dialog/modal-dialog.tsx +33 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","names":["Dialog","KobalteDialog","Content","KobalteDialogContent","Overlay","KobalteDialogOverlay","X","Accessor","ComponentProps","JSX","createRenderEffect","onCleanup","Show","splitProps","dialogSurface","overlayMotion","overlayPositioner","overlayScrim","overlayTitle","cn","Tooltip","TooltipContent","TooltipTrigger","FocusCycle","content","HTMLElement","opener","openerEligible","closed","focusMovedOutside","closeAutoFocusScheduled","frame","fallbackTimer","observer","MutationObserver","onFocusIn","event","FocusEvent","canRestoreFocus","target","isConnected","document","body","documentElement","closest","matches","getClientRects","length","hasOtherOverlay","querySelectorAll","some","overlay","contains","DialogFocusRestorationOptions","open","restoreFocusRef","onOpenAutoFocus","onCloseAutoFocus","createDialogFocusRestoration","callerOnOpenAutoFocus","callerOnCloseAutoFocus","focusCycles","WeakMap","activeFocusCycle","pendingOpener","pendingOpenerEligible","active","activeElement","finishFocusCycle","cycle","undefined","window","cancelAnimationFrame","clearTimeout","disconnect","removeEventListener","scheduleFocusRestore","requestAnimationFrame","focusIsAvailable","Node","focus","preventScroll","Event","element","currentTarget","openerWasCaptured","focusEvent","set","addEventListener","get","defaultPrevented","observe","attributes","attributeFilter","childList","subtree","queueMicrotask","setTimeout","props","_$createComponent","DialogTrigger","Trigger","DialogPortal","Portal","DialogOverlay","local","rest","_$mergeProps","class","DialogContentProps","closeButton","Element","closeLabel","positioner","size","DialogContentSize","dialogContentSizes","sm","md","lg","xl","const","DialogContent","children","_el$","_tmpl$","_$insert","_$memo","when","as","CloseButton","aria-label","_$effect","_$className","DialogHeader","band","_el$2","_tmpl$2","_$spread","DialogFooter","_el$3","_tmpl$3","DialogTitle","Title","DialogDescription","Description","DialogCloseButton","DialogClose","Dialog","_$createComponent","KobalteDialog","KobalteDialogOverlay","_$mergeProps","KobalteDialogContent","_$memo","_$className"],"sources":["../../../../src/components/ui/dialog/dialog.tsx"],"sourcesContent":["import {\n Dialog as KobalteDialog,\n Content as KobalteDialogContent,\n Overlay as KobalteDialogOverlay,\n} from '@kobalte/core/dialog'\n// AlertDialog assigns to the shared DialogRoot.Content object, so these named exports stay role-stable.\nimport { X } from 'lucide-solid'\nimport type { Accessor, ComponentProps, JSX } from 'solid-js'\nimport { createRenderEffect, onCleanup, Show, splitProps } from 'solid-js'\nimport {\n dialogSurface,\n overlayMotion,\n overlayPositioner,\n overlayScrim,\n overlayTitle,\n} from '#lib/overlay'\nimport { cn } from '#lib/utils'\nimport { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip'\n\ntype FocusCycle = {\n content: HTMLElement\n opener: HTMLElement | null\n openerEligible: boolean\n closed: boolean\n focusMovedOutside: boolean\n closeAutoFocusScheduled: boolean\n frame?: number\n fallbackTimer?: number\n observer?: MutationObserver\n onFocusIn: (event: FocusEvent) => void\n}\n\nfunction canRestoreFocus(target: HTMLElement): boolean {\n return (\n target.isConnected &&\n target !== document.body &&\n target !== document.documentElement &&\n !target.closest('[inert], [aria-hidden=\"true\"]') &&\n !target.matches(':disabled') &&\n target.getClientRects().length > 0\n )\n}\n\nfunction hasOtherOverlay(content: HTMLElement, opener: HTMLElement): boolean {\n return [...document.querySelectorAll<HTMLElement>('[role=\"dialog\"], [role=\"alertdialog\"]')].some(\n (overlay) =>\n overlay !== content &&\n !content.contains(overlay) &&\n !overlay.contains(opener) &&\n !overlay.closest('[aria-hidden=\"true\"], [inert]') &&\n overlay.getClientRects().length > 0\n )\n}\n\ntype DialogFocusRestorationOptions = {\n open: Accessor<boolean>\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n onOpenAutoFocus?: ComponentProps<typeof KobalteDialogContent>['onOpenAutoFocus']\n onCloseAutoFocus?: ComponentProps<typeof KobalteDialogContent>['onCloseAutoFocus']\n}\n\n/**\n * Adds guarded opener capture and restoration to a Kobalte dialog content.\n * Composed surfaces use this internal helper; it is omitted from the public\n * dialog barrel so the restoration policy stays with the dialog components.\n */\nexport function createDialogFocusRestoration({\n open,\n restoreFocusRef,\n onOpenAutoFocus: callerOnOpenAutoFocus,\n onCloseAutoFocus: callerOnCloseAutoFocus,\n}: DialogFocusRestorationOptions) {\n const focusCycles = new WeakMap<HTMLElement, FocusCycle>()\n let activeFocusCycle: FocusCycle | undefined\n let pendingOpener: HTMLElement | null = null\n let pendingOpenerEligible = false\n\n createRenderEffect(() => {\n if (!open() || typeof document === 'undefined') {\n pendingOpener = null\n pendingOpenerEligible = false\n return\n }\n const active = restoreFocusRef?.() ?? document.activeElement\n pendingOpener = active instanceof HTMLElement ? active : null\n pendingOpenerEligible = active instanceof HTMLElement && canRestoreFocus(active)\n })\n\n const finishFocusCycle = (cycle: FocusCycle) => {\n if (cycle.frame !== undefined) window.cancelAnimationFrame(cycle.frame)\n if (cycle.fallbackTimer !== undefined) window.clearTimeout(cycle.fallbackTimer)\n cycle.observer?.disconnect()\n document.removeEventListener('focusin', cycle.onFocusIn)\n if (activeFocusCycle === cycle) activeFocusCycle = undefined\n }\n\n const scheduleFocusRestore = (cycle: FocusCycle) => {\n if (cycle.frame !== undefined) return\n cycle.frame = window.requestAnimationFrame(() => {\n cycle.frame = undefined\n const opener = cycle.opener\n const active = document.activeElement\n const focusIsAvailable =\n active === document.body ||\n active === document.documentElement ||\n active === cycle.content ||\n (active instanceof Node && cycle.content.contains(active))\n if (\n activeFocusCycle !== cycle ||\n !cycle.closed ||\n cycle.focusMovedOutside ||\n !opener ||\n !opener.isConnected ||\n opener.matches(':disabled') ||\n opener.getClientRects().length === 0 ||\n !focusIsAvailable ||\n hasOtherOverlay(cycle.content, opener)\n ) {\n finishFocusCycle(cycle)\n return\n }\n\n // Inert and aria-hidden are removed by the dialog's containment cleanup.\n // Wait for that cleanup before returning focus to the original control.\n if (opener.closest('[inert], [aria-hidden=\"true\"]')) return\n if (cycle.openerEligible && canRestoreFocus(opener)) {\n opener.focus({ preventScroll: true })\n }\n finishFocusCycle(cycle)\n })\n }\n\n const onOpenAutoFocus = (event: Event) => {\n const element = event.currentTarget\n if (element instanceof HTMLElement) {\n if (activeFocusCycle) finishFocusCycle(activeFocusCycle)\n\n const openerWasCaptured = pendingOpener !== null\n const opener = pendingOpener ?? document.activeElement\n const openerEligible = openerWasCaptured\n ? pendingOpenerEligible\n : opener instanceof HTMLElement && canRestoreFocus(opener)\n pendingOpener = null\n pendingOpenerEligible = false\n const cycle: FocusCycle = {\n content: element,\n opener: opener instanceof HTMLElement ? opener : null,\n openerEligible,\n closed: false,\n focusMovedOutside: false,\n closeAutoFocusScheduled: false,\n onFocusIn: (focusEvent) => {\n const target = focusEvent.target\n if (\n !(target instanceof HTMLElement) ||\n target === document.body ||\n target === document.documentElement\n ) {\n return\n }\n if (\n target === element ||\n element.contains(target) ||\n target === (opener instanceof HTMLElement ? opener : null)\n ) {\n if (!cycle.closed) cycle.focusMovedOutside = false\n return\n }\n cycle.focusMovedOutside = true\n },\n }\n focusCycles.set(element, cycle)\n activeFocusCycle = cycle\n document.addEventListener('focusin', cycle.onFocusIn)\n }\n callerOnOpenAutoFocus?.(event)\n }\n\n const onCloseAutoFocus = (event: Event) => {\n const element = event.currentTarget\n const cycle = element instanceof HTMLElement ? focusCycles.get(element) : undefined\n callerOnCloseAutoFocus?.(event)\n\n if (!cycle) return\n cycle.closed = true\n\n // A caller that prevents Kobalte's close autofocus owns the focus decision.\n if (event.defaultPrevented) {\n finishFocusCycle(cycle)\n return\n }\n\n if (cycle.fallbackTimer !== undefined) {\n window.clearTimeout(cycle.fallbackTimer)\n cycle.fallbackTimer = undefined\n }\n cycle.closeAutoFocusScheduled = true\n cycle.observer = new MutationObserver(() => scheduleFocusRestore(cycle))\n cycle.observer.observe(document.body, {\n attributes: true,\n attributeFilter: ['aria-hidden', 'inert'],\n childList: true,\n subtree: true,\n })\n scheduleFocusRestore(cycle)\n }\n\n onCleanup(() => {\n const cycle = activeFocusCycle\n if (!cycle) return\n cycle.closed = true\n\n // Kobalte dispatches unmount autofocus from a timer. This fallback only\n // releases the scoped focus listener if the content did not dispatch it.\n queueMicrotask(() => {\n if (cycle.closeAutoFocusScheduled) return\n cycle.fallbackTimer = window.setTimeout(() => {\n cycle.fallbackTimer = undefined\n if (!cycle.closeAutoFocusScheduled) finishFocusCycle(cycle)\n }, 0)\n })\n })\n\n return { onOpenAutoFocus, onCloseAutoFocus }\n}\n\n/**\n * Dialog.\n *\n * A modal surface for a decision or a short task. `Dialog.Portal` keeps the\n * panel out of the app's stacking and overflow contexts, `Dialog.Overlay`\n * dims what is behind it, and Kobalte handles the focus trap, the escape key,\n * scroll locking and returning focus to the trigger on close.\n *\n * The close button is part of the content rather than optional, because every\n * modal needs a way out that is not the keyboard. A dialog whose only exit is\n * Escape is a trap for anyone using a pointer.\n */\nexport function Dialog(props: ComponentProps<typeof KobalteDialog>) {\n return <KobalteDialog {...props} />\n}\n\nexport function DialogTrigger(props: ComponentProps<typeof KobalteDialog.Trigger>) {\n return <KobalteDialog.Trigger {...props} />\n}\n\nexport function DialogPortal(props: ComponentProps<typeof KobalteDialog.Portal>) {\n return <KobalteDialog.Portal {...props} />\n}\n\nexport function DialogOverlay(props: ComponentProps<typeof KobalteDialogOverlay>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <KobalteDialogOverlay\n class={cn(\n overlayScrim,\n 'data-expanded:animate-in data-expanded:fade-in-0 data-closed:animate-out data-closed:fade-out-0',\n local.class\n )}\n {...rest}\n />\n )\n}\n\nexport type DialogContentProps = ComponentProps<typeof KobalteDialogContent> & {\n /**\n * Replaces the default close button. Pass `false` to remove it — only for a\n * dialog that cannot be dismissed (an update that must finish); anything the\n * user can escape from needs the button.\n */\n closeButton?: JSX.Element | false\n /**\n * The corner close's accessible name. Defaults to \"Close\". Name it for the\n * dialog (\"Close version and updates\") when the footer also has a text\n * \"Close\", so the two controls do not share one name.\n */\n closeLabel?: string\n /** Use a 1rem inset as the positioner bounds for tall, viewport-filling surfaces. */\n positioner?: 'default' | 'inset'\n /**\n * The panel's maximum width. `md` (32rem) is the default and right for a\n * confirmation or a short form; `sm` (28rem) for a single question; `lg`\n * (42rem) for a picker or a form with two columns; `xl` (48rem) for a\n * multi-step flow that needs a table or a preview beside its fields.\n */\n size?: DialogContentSize\n}\n\n/** The dialog width ladder, so a caller picks a rung instead of a `max-w-*`. */\nexport const dialogContentSizes = {\n sm: 'max-w-md',\n md: 'max-w-lg',\n lg: 'max-w-2xl',\n xl: 'max-w-3xl',\n} as const\n\nexport type DialogContentSize = keyof typeof dialogContentSizes\n\nexport function DialogContent(props: DialogContentProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'children',\n 'closeButton',\n 'closeLabel',\n 'positioner',\n 'size',\n ])\n\n return (\n <KobalteDialog.Portal>\n <DialogOverlay />\n <div class={cn(overlayPositioner, local.positioner === 'inset' && 'inset-4 grid-rows-1 p-0')}>\n <KobalteDialogContent\n class={cn(\n dialogSurface,\n overlayMotion,\n 'relative grid w-full gap-4 p-5',\n dialogContentSizes[local.size ?? 'md'],\n local.class\n )}\n {...rest}\n >\n {local.children}\n <Show when={local.closeButton !== false}>\n {/* The corner close is icon-only, so it carries the shared tooltip\n treatment. Its accessible name is \"Close\" unless the caller names it. */}\n <Tooltip>\n <TooltipTrigger\n as={KobalteDialog.CloseButton}\n data-slot=\"dialog-corner-close\"\n aria-label={local.closeLabel ?? 'Close'}\n class={cn(\n 'absolute top-3.5 end-3.5 rounded-md p-1 text-muted-foreground',\n 'transition-colors ease-out hover:bg-surface-hover hover:text-foreground',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle outline-none'\n )}\n >\n {local.closeButton ?? <X class=\"size-4\" />}\n </TooltipTrigger>\n <TooltipContent>\n {local.closeLabel ? `${local.closeLabel}.` : 'Close dialog.'}\n </TooltipContent>\n </Tooltip>\n </Show>\n </KobalteDialogContent>\n </div>\n </KobalteDialog.Portal>\n )\n}\n\n/**\n * The dialog's title block. `band` steps it onto the elevation ladder's\n * subtle-fill rung (`--muted`), the same treatment as the sheet parts' band —\n * for the dialog family whose panel anatomy matches a sheet's (a title band\n * over a full-bleed shell, such as a settings dialog) rather than the centred\n * modal's documented flat surface. See `SheetFooter` for the rung's rationale.\n */\nexport function DialogHeader(props: ComponentProps<'div'> & { band?: boolean }) {\n const [local, rest] = splitProps(props, ['class', 'band'])\n return (\n <div\n data-slot=\"dialog-header\"\n class={cn('flex flex-col gap-1.5 pe-6 text-start', { 'bg-muted': local.band }, local.class)}\n {...rest}\n />\n )\n}\n\nexport function DialogFooter(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"dialog-footer\"\n class={cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', local.class)}\n {...rest}\n />\n )\n}\n\nexport function DialogTitle(props: ComponentProps<typeof KobalteDialog.Title>) {\n const [local, rest] = splitProps(props, ['class'])\n return <KobalteDialog.Title class={cn(overlayTitle, local.class)} {...rest} />\n}\n\nexport function DialogDescription(props: ComponentProps<typeof KobalteDialog.Description>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <KobalteDialog.Description class={cn('text-muted-foreground text-sm', local.class)} {...rest} />\n )\n}\n\nexport function DialogCloseButton(props: ComponentProps<typeof KobalteDialog.CloseButton>) {\n const [local, rest] = splitProps(props, ['class'])\n return <KobalteDialog.CloseButton class={cn('focus-ring', local.class)} {...rest} />\n}\n\n/**\n * The close control, unstyled and polymorphic — for a footer's text \"Cancel\" or\n * \"Close\", which is a different control from the corner icon `DialogCloseButton`\n * draws. Take it as `as={Button}` so it carries the button's variants rather than\n * a copied class string.\n */\nexport function DialogClose(props: ComponentProps<typeof KobalteDialog.CloseButton>) {\n const [local, rest] = splitProps(props, ['class'])\n return <KobalteDialog.CloseButton class={cn('focus-ring', local.class)} {...rest} />\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAASsC,gBAAgBC,QAA8B;CACrD,OACEA,OAAOC,eACPD,WAAWE,SAASC,QACpBH,WAAWE,SAASE,mBACpB,CAACJ,OAAOK,QAAQ,iCAA+B,KAC/C,CAACL,OAAOM,QAA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alteDialogContent","Overlay","KobalteDialogOverlay","X","Accessor","ComponentProps","JSX","createRenderEffect","onCleanup","Show","splitProps","dialogSurface","overlayMotion","overlayPositioner","overlayScrim","overlayTitle","cn","Tooltip","TooltipContent","TooltipTrigger","FocusCycle","content","HTMLElement","opener","openerEligible","closed","focusMovedOutside","closeAutoFocusScheduled","frame","fallbackTimer","observer","MutationObserver","onFocusIn","event","FocusEvent","canRestoreFocus","target","isConnected","document","body","documentElement","closest","matches","getClientRects","length","hasOtherOverlay","querySelectorAll","some","overlay","contains","DialogFocusRestorationOptions","open","restoreFocusRef","onOpenAutoFocus","onCloseAutoFocus","createDialogFocusRestoration","callerOnOpenAutoFocus","callerOnCloseAutoFocus","focusCycles","WeakMap","activeFocusCycle","pendingOpener","pendingOpenerEligible","active","activeElement","finishFocusCycle","cycle","undefined","window","cancelAnimationFrame","clearTimeout","disconnect","removeEventListener","scheduleFocusRestore","requestAnimationFrame","focusIsAvailable","Node","focus","preventScroll","Event","element","currentTarget","openerWasCaptured","focusEvent","set","addEventListener","get","defaultPrevented","observe","attributes","attributeFilter","childList","subtree","queueMicrotask","setTimeout","props","_$createComponent","DialogTrigger","Trigger","DialogPortal","Portal","DialogOverlay","local","rest","_$mergeProps","class","DialogContentProps","closeButton","Element","closeLabel","positioner","size","DialogContentSize","dialogContentSizes","sm","md","lg","xl","const","DialogContent","children","_el$","_tmpl$","_$insert","_$memo","when","as","CloseButton","aria-label","_$effect","_$className","DialogHeader","band","_el$2","_tmpl$2","_$spread","DialogFooter","_el$3","_tmpl$3","DialogTitle","Title","DialogDescription","Description","DialogCloseButton","DialogClose","Dialog","_$createComponent","KobalteDialog","KobalteDialogOverlay","_$mergeProps","KobalteDialogContent","_$memo","_$className"],"sources":["../../../../src/components/ui/dialog/dialog.tsx"],"sourcesContent":["import {\n Dialog as KobalteDialog,\n Content as KobalteDialogContent,\n Overlay as KobalteDialogOverlay,\n} from '@kobalte/core/dialog'\n// AlertDialog assigns to the shared DialogRoot.Content object, so these named exports stay role-stable.\nimport { X } from 'lucide-solid'\nimport type { Accessor, ComponentProps, JSX } from 'solid-js'\nimport { createRenderEffect, onCleanup, Show, splitProps } from 'solid-js'\nimport {\n dialogSurface,\n overlayMotion,\n overlayPositioner,\n overlayScrim,\n overlayTitle,\n} from '#lib/overlay'\nimport { cn } from '#lib/utils'\nimport { Tooltip, TooltipContent, TooltipTrigger } from '../tooltip'\n\ntype FocusCycle = {\n content: HTMLElement\n opener: HTMLElement | null\n openerEligible: boolean\n closed: boolean\n focusMovedOutside: boolean\n closeAutoFocusScheduled: boolean\n frame?: number\n fallbackTimer?: number\n observer?: MutationObserver\n onFocusIn: (event: FocusEvent) => void\n}\n\nfunction canRestoreFocus(target: HTMLElement): boolean {\n return (\n target.isConnected &&\n target !== document.body &&\n target !== document.documentElement &&\n !target.closest('[inert], [aria-hidden=\"true\"]') &&\n !target.matches(':disabled') &&\n target.getClientRects().length > 0\n )\n}\n\nfunction hasOtherOverlay(content: HTMLElement, opener: HTMLElement): boolean {\n return [...document.querySelectorAll<HTMLElement>('[role=\"dialog\"], [role=\"alertdialog\"]')].some(\n (overlay) =>\n overlay !== content &&\n !content.contains(overlay) &&\n !overlay.contains(opener) &&\n !overlay.closest('[aria-hidden=\"true\"], [inert]') &&\n overlay.getClientRects().length > 0\n )\n}\n\ntype DialogFocusRestorationOptions = {\n open: Accessor<boolean>\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n onOpenAutoFocus?: ComponentProps<typeof KobalteDialogContent>['onOpenAutoFocus']\n onCloseAutoFocus?: ComponentProps<typeof KobalteDialogContent>['onCloseAutoFocus']\n}\n\n/**\n * Adds guarded opener capture and restoration to a Kobalte dialog content.\n * Composed surfaces use this internal helper; it is omitted from the public\n * dialog barrel so the restoration policy stays with the dialog components.\n */\nexport function createDialogFocusRestoration({\n open,\n restoreFocusRef,\n onOpenAutoFocus: callerOnOpenAutoFocus,\n onCloseAutoFocus: callerOnCloseAutoFocus,\n}: DialogFocusRestorationOptions) {\n const focusCycles = new WeakMap<HTMLElement, FocusCycle>()\n let activeFocusCycle: FocusCycle | undefined\n let pendingOpener: HTMLElement | null = null\n let pendingOpenerEligible = false\n\n createRenderEffect(() => {\n if (!open() || typeof document === 'undefined') {\n pendingOpener = null\n pendingOpenerEligible = false\n return\n }\n const active = restoreFocusRef?.() ?? document.activeElement\n pendingOpener = active instanceof HTMLElement ? active : null\n pendingOpenerEligible = active instanceof HTMLElement && canRestoreFocus(active)\n })\n\n const finishFocusCycle = (cycle: FocusCycle) => {\n if (cycle.frame !== undefined) window.cancelAnimationFrame(cycle.frame)\n if (cycle.fallbackTimer !== undefined) window.clearTimeout(cycle.fallbackTimer)\n cycle.observer?.disconnect()\n document.removeEventListener('focusin', cycle.onFocusIn)\n if (activeFocusCycle === cycle) activeFocusCycle = undefined\n }\n\n const scheduleFocusRestore = (cycle: FocusCycle) => {\n if (cycle.frame !== undefined) return\n cycle.frame = window.requestAnimationFrame(() => {\n cycle.frame = undefined\n const opener = cycle.opener\n const active = document.activeElement\n const focusIsAvailable =\n active === document.body ||\n active === document.documentElement ||\n active === cycle.content ||\n (active instanceof Node && cycle.content.contains(active))\n if (\n activeFocusCycle !== cycle ||\n !cycle.closed ||\n cycle.focusMovedOutside ||\n !opener ||\n !opener.isConnected ||\n opener.matches(':disabled') ||\n opener.getClientRects().length === 0 ||\n !focusIsAvailable ||\n hasOtherOverlay(cycle.content, opener)\n ) {\n finishFocusCycle(cycle)\n return\n }\n\n // Inert and aria-hidden are removed by the dialog's containment cleanup.\n // Wait for that cleanup before returning focus to the original control.\n if (opener.closest('[inert], [aria-hidden=\"true\"]')) return\n if (cycle.openerEligible && canRestoreFocus(opener)) {\n opener.focus({ preventScroll: true })\n }\n finishFocusCycle(cycle)\n })\n }\n\n const onOpenAutoFocus = (event: Event) => {\n const element = event.currentTarget\n if (element instanceof HTMLElement) {\n if (activeFocusCycle) finishFocusCycle(activeFocusCycle)\n\n const openerWasCaptured = pendingOpener !== null\n const opener = pendingOpener ?? document.activeElement\n const openerEligible = openerWasCaptured\n ? pendingOpenerEligible\n : opener instanceof HTMLElement && canRestoreFocus(opener)\n pendingOpener = null\n pendingOpenerEligible = false\n const cycle: FocusCycle = {\n content: element,\n opener: opener instanceof HTMLElement ? opener : null,\n openerEligible,\n closed: false,\n focusMovedOutside: false,\n closeAutoFocusScheduled: false,\n onFocusIn: (focusEvent) => {\n const target = focusEvent.target\n if (\n !(target instanceof HTMLElement) ||\n target === document.body ||\n target === document.documentElement\n ) {\n return\n }\n if (\n target === element ||\n element.contains(target) ||\n target === (opener instanceof HTMLElement ? opener : null)\n ) {\n if (!cycle.closed) cycle.focusMovedOutside = false\n return\n }\n cycle.focusMovedOutside = true\n },\n }\n focusCycles.set(element, cycle)\n activeFocusCycle = cycle\n document.addEventListener('focusin', cycle.onFocusIn)\n }\n callerOnOpenAutoFocus?.(event)\n }\n\n const onCloseAutoFocus = (event: Event) => {\n const element = event.currentTarget\n const cycle = element instanceof HTMLElement ? focusCycles.get(element) : undefined\n callerOnCloseAutoFocus?.(event)\n\n if (!cycle) return\n cycle.closed = true\n\n // A caller that prevents Kobalte's close autofocus owns the focus decision.\n if (event.defaultPrevented) {\n finishFocusCycle(cycle)\n return\n }\n\n if (cycle.fallbackTimer !== undefined) {\n window.clearTimeout(cycle.fallbackTimer)\n cycle.fallbackTimer = undefined\n }\n cycle.closeAutoFocusScheduled = true\n cycle.observer = new MutationObserver(() => scheduleFocusRestore(cycle))\n cycle.observer.observe(document.body, {\n attributes: true,\n attributeFilter: ['aria-hidden', 'inert'],\n childList: true,\n subtree: true,\n })\n scheduleFocusRestore(cycle)\n }\n\n onCleanup(() => {\n const cycle = activeFocusCycle\n if (!cycle) return\n cycle.closed = true\n\n // Kobalte dispatches unmount autofocus from a timer. This fallback only\n // releases the scoped focus listener if the content did not dispatch it.\n queueMicrotask(() => {\n if (cycle.closeAutoFocusScheduled) return\n cycle.fallbackTimer = window.setTimeout(() => {\n cycle.fallbackTimer = undefined\n if (!cycle.closeAutoFocusScheduled) finishFocusCycle(cycle)\n }, 0)\n })\n })\n\n return { onOpenAutoFocus, onCloseAutoFocus }\n}\n\n/**\n * Dialog.\n *\n * A modal surface for a decision or a short task. `Dialog.Portal` keeps the\n * panel out of the app's stacking and overflow contexts, `Dialog.Overlay`\n * dims what is behind it, and Kobalte handles the focus trap, the escape key,\n * scroll locking and returning focus to the trigger on close.\n *\n * The close button is part of the content rather than optional, because every\n * modal needs a way out that is not the keyboard. A dialog whose only exit is\n * Escape is a trap for anyone using a pointer.\n */\nexport function Dialog(props: ComponentProps<typeof KobalteDialog>) {\n return <KobalteDialog {...props} />\n}\n\nexport function DialogTrigger(props: ComponentProps<typeof KobalteDialog.Trigger>) {\n return <KobalteDialog.Trigger {...props} />\n}\n\nexport function DialogPortal(props: ComponentProps<typeof KobalteDialog.Portal>) {\n return <KobalteDialog.Portal {...props} />\n}\n\nexport function DialogOverlay(props: ComponentProps<typeof KobalteDialogOverlay>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <KobalteDialogOverlay\n class={cn(\n overlayScrim,\n 'data-expanded:animate-in data-expanded:fade-in-0 data-closed:animate-out data-closed:fade-out-0',\n local.class\n )}\n {...rest}\n />\n )\n}\n\nexport type DialogContentProps = ComponentProps<typeof KobalteDialogContent> & {\n /**\n * Replaces the default close button. Pass `false` to remove it — only for a\n * dialog that cannot be dismissed (an update that must finish); anything the\n * user can escape from needs the button.\n */\n closeButton?: JSX.Element | false\n /**\n * The corner close's accessible name. Defaults to \"Close\". Name it for the\n * dialog (\"Close version and updates\") when the footer also has a text\n * \"Close\", so the two controls do not share one name.\n */\n closeLabel?: string\n /** Use a 1rem inset as the positioner bounds for tall, viewport-filling surfaces. */\n positioner?: 'default' | 'inset'\n /**\n * The panel's maximum width. `md` (32rem) is the default and right for a\n * confirmation or a short form; `sm` (28rem) for a single question; `lg`\n * (42rem) for a picker or a form with two columns; `xl` (48rem) for a\n * multi-step flow that needs a table or a preview beside its fields.\n */\n size?: DialogContentSize\n}\n\n/** The dialog width ladder, so a caller picks a rung instead of a `max-w-*`. */\nexport const dialogContentSizes = {\n sm: 'max-w-md',\n md: 'max-w-lg',\n lg: 'max-w-2xl',\n xl: 'max-w-3xl',\n} as const\n\nexport type DialogContentSize = keyof typeof dialogContentSizes\n\nexport function DialogContent(props: DialogContentProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'children',\n 'closeButton',\n 'closeLabel',\n 'positioner',\n 'size',\n ])\n\n return (\n <KobalteDialog.Portal>\n <DialogOverlay />\n <div class={cn(overlayPositioner, local.positioner === 'inset' && 'inset-4 grid-rows-1 p-0')}>\n <KobalteDialogContent\n class={cn(\n dialogSurface,\n overlayMotion,\n 'relative grid max-h-full w-full gap-4 overflow-y-auto p-5',\n dialogContentSizes[local.size ?? 'md'],\n local.class\n )}\n {...rest}\n >\n {local.children}\n <Show when={local.closeButton !== false}>\n {/* The corner close is icon-only, so it carries the shared tooltip\n treatment. Its accessible name is \"Close\" unless the caller names it. */}\n <Tooltip>\n <TooltipTrigger\n as={KobalteDialog.CloseButton}\n data-slot=\"dialog-corner-close\"\n aria-label={local.closeLabel ?? 'Close'}\n class={cn(\n 'absolute top-3.5 end-3.5 rounded-md p-1 text-muted-foreground',\n 'transition-colors ease-out hover:bg-surface-hover hover:text-foreground',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle outline-none'\n )}\n >\n {local.closeButton ?? <X class=\"size-4\" />}\n </TooltipTrigger>\n <TooltipContent>\n {local.closeLabel ? `${local.closeLabel}.` : 'Close dialog.'}\n </TooltipContent>\n </Tooltip>\n </Show>\n </KobalteDialogContent>\n </div>\n </KobalteDialog.Portal>\n )\n}\n\n/**\n * The dialog's title block. `band` steps it onto the elevation ladder's\n * subtle-fill rung (`--muted`), the same treatment as the sheet parts' band —\n * for the dialog family whose panel anatomy matches a sheet's (a title band\n * over a full-bleed shell, such as a settings dialog) rather than the centred\n * modal's documented flat surface. See `SheetFooter` for the rung's rationale.\n */\nexport function DialogHeader(props: ComponentProps<'div'> & { band?: boolean }) {\n const [local, rest] = splitProps(props, ['class', 'band'])\n return (\n <div\n data-slot=\"dialog-header\"\n class={cn('flex flex-col gap-1.5 pe-6 text-start', { 'bg-muted': local.band }, local.class)}\n {...rest}\n />\n )\n}\n\nexport function DialogFooter(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"dialog-footer\"\n class={cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', local.class)}\n {...rest}\n />\n )\n}\n\nexport function DialogTitle(props: ComponentProps<typeof KobalteDialog.Title>) {\n const [local, rest] = splitProps(props, ['class'])\n return <KobalteDialog.Title class={cn(overlayTitle, local.class)} {...rest} />\n}\n\nexport function DialogDescription(props: ComponentProps<typeof KobalteDialog.Description>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <KobalteDialog.Description class={cn('text-muted-foreground text-sm', local.class)} {...rest} />\n )\n}\n\nexport function DialogCloseButton(props: ComponentProps<typeof KobalteDialog.CloseButton>) {\n const [local, rest] = splitProps(props, ['class'])\n return <KobalteDialog.CloseButton class={cn('focus-ring', local.class)} {...rest} />\n}\n\n/**\n * The close control, unstyled and polymorphic — for a footer's text \"Cancel\" or\n * \"Close\", which is a different control from the corner icon `DialogCloseButton`\n * draws. Take it as `as={Button}` so it carries the button's variants rather than\n * a copied class string.\n */\nexport function DialogClose(props: ComponentProps<typeof KobalteDialog.CloseButton>) {\n const [local, rest] = splitProps(props, ['class'])\n return <KobalteDialog.CloseButton class={cn('focus-ring', local.class)} {...rest} />\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAASsC,gBAAgBC,QAA8B;CACrD,OACEA,OAAOC,eACPD,WAAWE,SAASC,QACpBH,WAAWE,SAASE,mBACpB,CAACJ,OAAOK,QAAQ,iCAA+B,KAC/C,CAACL,OAAOM,QAAQ,WAAW,KAC3BN,OAAOO,eAAe,CAAC,CAACC,SAAS;AAErC;AAEA,SAASC,g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,OAGWxF,GAAG,0DAA0DsF,MAAMG,KAAK;EAAC,EAAA,GAC5EF,IAAI,GAAA,OAAA,KAAA;EAAA,OAAAkC;CAAA,EAAA,CAAA;AAGd;AAEA,SAAgBE,YAAY5C,OAAmD;CAC7E,MAAM,CAACO,OAAOC,QAAQ7F,WAAWqF,OAAO,CAAC,OAAO,CAAC;CACjD,OAAAC,gBAAQlG,OAAc8I,OAAKpC,WAAA,EAAA,KAAA,WAAA;EAAA,OAAQxF,GAAGD,cAAcuF,MAAMG,KAAK;CAAC,EAAA,GAAMF,IAAI,CAAA;AAC5E;AAEA,SAAgBsC,kBAAkB9C,OAAyD;CACzF,MAAM,CAACO,OAAOC,QAAQ7F,WAAWqF,OAAO,CAAC,OAAO,CAAC;CACjD,OAAAC,gBACGlG,OAAcgJ,aAAWtC,WAAA,EAAA,KAAA,WAAA;EAAA,OAAQxF,GAAG,iCAAiCsF,MAAMG,KAAK;CAAC,EAAA,GAAMF,IAAI,CAAA;AAEhG;AAEA,SAAgBwC,kBAAkBhD,OAAyD;CACzF,MAAM,CAACO,OAAOC,QAAQ7F,WAAWqF,OAAO,CAAC,OAAO,CAAC;CACjD,OAAAC,gBAAQlG,OAAciI,aAAWvB,WAAA,EAAA,KAAA,WAAA;EAAA,OAAQxF,GAAG,cAAcsF,MAAMG,KAAK;CAAC,EAAA,GAAMF,IAAI,CAAA;AAClF;;;;;;;AAQA,SAAgByC,YAAYjD,OAAyD;CACnF,MAAM,CAACO,OAAOC,QAAQ7F,WAAWqF,OAAO,CAAC,OAAO,CAAC;CACjD,OAAAC,gBAAQlG,OAAciI,aAAWvB,WAAA,EAAA,KAAA,WAAA;EAAA,OAAQxF,GAAG,cAAcsF,MAAMG,KAAK;CAAC,EAAA,GAAMF,IAAI,CAAA;AAClF"}
|
|
@@ -33,11 +33,26 @@ import { DialogContent } from '../dialog/dialog';
|
|
|
33
33
|
* Use `Dialog` directly when you need its composition; use this when you want a
|
|
34
34
|
* dialog that is correct by default. `size="settings"` supplies a wide, bounded
|
|
35
35
|
* shell for a shared settings layout, titled by a banded header like a sheet's;
|
|
36
|
-
* ordinary dialogs keep their compact default.
|
|
36
|
+
* ordinary dialogs keep their compact default. Every centred dialog stays inside
|
|
37
|
+
* the window: past the window's height it scrolls rather than running off its
|
|
38
|
+
* edges. `size="fit"` is for a dialog whose body can grow (a scan result, a long
|
|
39
|
+
* plan) and whose actions must stay in view: the title and `footer` stay put and
|
|
40
|
+
* the children scroll between them.
|
|
37
41
|
*/
|
|
38
42
|
export type ModalDialogProps = Omit<ComponentProps<typeof DialogContent>, 'children' | 'aria-label' | 'aria-labelledby' | 'positioner'> & {
|
|
39
|
-
/**
|
|
40
|
-
|
|
43
|
+
/**
|
|
44
|
+
* `settings` selects the bounded, scrollable shell used for grouped workspace
|
|
45
|
+
* settings. `fit` keeps the compact default width but lets the dialog's content
|
|
46
|
+
* decide its height up to the window: the title band stays put, the children
|
|
47
|
+
* scroll, and `footer` stays in view beneath them.
|
|
48
|
+
*/
|
|
49
|
+
size?: 'default' | 'settings' | 'fit';
|
|
50
|
+
/**
|
|
51
|
+
* Actions that must stay reachable however long the content is (Cancel and a
|
|
52
|
+
* primary button). Rendered under the scrolling children, outside the scroll
|
|
53
|
+
* area, and only by the `fit` size.
|
|
54
|
+
*/
|
|
55
|
+
footer?: JSX.Element;
|
|
41
56
|
open: boolean;
|
|
42
57
|
onClose: () => void;
|
|
43
58
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-dialog.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/modal-dialog/modal-dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAG7D,OAAO,EAGL,aAAa,EAId,MAAM,kBAAkB,CAAA;AAEzB
|
|
1
|
+
{"version":3,"file":"modal-dialog.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/modal-dialog/modal-dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAG7D,OAAO,EAGL,aAAa,EAId,MAAM,kBAAkB,CAAA;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,cAAc,CAAC,OAAO,aAAa,CAAC,EACpC,UAAU,GAAG,YAAY,GAAG,iBAAiB,GAAG,YAAY,CAC7D,GAAG;IACF;;;;;OAKG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,KAAK,CAAA;IACrC;;;;OAIG;IACH,MAAM,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACpB,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IAC3B,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,2FAA2F;IAC3F,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,QAAQ,CAAC,WAAW,GAAG,SAAS,CAAC,CAAA;IACnD,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;CACvB,CAAA;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,eAmHlD"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { cn } from "../../../lib/utils.js";
|
|
2
2
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, createDialogFocusRestoration } from "../dialog/dialog.js";
|
|
3
|
-
import { createComponent, memo, mergeProps } from "solid-js/web";
|
|
3
|
+
import { createComponent, insert, memo, mergeProps, template } from "solid-js/web";
|
|
4
4
|
import { Show, createEffect, createSignal, onCleanup, splitProps } from "solid-js";
|
|
5
5
|
// src/components/ui/modal-dialog/modal-dialog.tsx
|
|
6
|
+
var _tmpl$ = /*#__PURE__*/ template(`<div class="-mx-1 flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-1">`);
|
|
7
|
+
var _tmpl$2 = /*#__PURE__*/ template(`<div class="flex shrink-0 flex-wrap justify-end gap-2 border-t border-border pt-3">`);
|
|
6
8
|
function ModalDialog(props) {
|
|
7
9
|
const [local, rest] = splitProps(props, [
|
|
8
10
|
"open",
|
|
@@ -10,6 +12,7 @@ function ModalDialog(props) {
|
|
|
10
12
|
"title",
|
|
11
13
|
"modal",
|
|
12
14
|
"size",
|
|
15
|
+
"footer",
|
|
13
16
|
"description",
|
|
14
17
|
"headerLeading",
|
|
15
18
|
"class",
|
|
@@ -62,7 +65,7 @@ function ModalDialog(props) {
|
|
|
62
65
|
return local.size === "settings" ? "inset" : "default";
|
|
63
66
|
},
|
|
64
67
|
get ["class"]() {
|
|
65
|
-
return cn("gap-4", local.size === "settings" && "flex h-208 max-h-full min-h-0 max-w-6xl flex-col gap-0 overflow-hidden p-0", local.class);
|
|
68
|
+
return cn("gap-4", local.size === "settings" && "flex h-208 max-h-full min-h-0 max-w-6xl flex-col gap-0 overflow-hidden p-0", local.size === "fit" && "flex flex-col overflow-hidden", local.class);
|
|
66
69
|
},
|
|
67
70
|
get ["aria-label"]() {
|
|
68
71
|
return local["aria-label"] ?? local.title;
|
|
@@ -109,7 +112,30 @@ function ModalDialog(props) {
|
|
|
109
112
|
}
|
|
110
113
|
})];
|
|
111
114
|
}
|
|
112
|
-
}),
|
|
115
|
+
}), createComponent(Show, {
|
|
116
|
+
get when() {
|
|
117
|
+
return local.size === "fit";
|
|
118
|
+
},
|
|
119
|
+
get fallback() {
|
|
120
|
+
return local.children;
|
|
121
|
+
},
|
|
122
|
+
get children() {
|
|
123
|
+
return [(() => {
|
|
124
|
+
var _el$ = _tmpl$();
|
|
125
|
+
insert(_el$, () => local.children);
|
|
126
|
+
return _el$;
|
|
127
|
+
})(), createComponent(Show, {
|
|
128
|
+
get when() {
|
|
129
|
+
return local.footer;
|
|
130
|
+
},
|
|
131
|
+
get children() {
|
|
132
|
+
var _el$2 = _tmpl$2();
|
|
133
|
+
insert(_el$2, () => local.footer);
|
|
134
|
+
return _el$2;
|
|
135
|
+
}
|
|
136
|
+
})];
|
|
137
|
+
}
|
|
138
|
+
})];
|
|
113
139
|
}
|
|
114
140
|
}));
|
|
115
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-dialog.js","names":["Accessor","ComponentProps","JSX","Show","createEffect","createSignal","onCleanup","splitProps","cn","createDialogFocusRestoration","Dialog","DialogContent","DialogDescription","DialogHeader","DialogTitle","ModalDialogProps","Omit","size","open","onClose","title","modal","description","headerLeading","Element","restoreFocusRef","HTMLElement","children","ModalDialog","props","local","rest","content","setContent","focusRestoration","onOpenAutoFocus","onCloseAutoFocus","element","background","document","body","filter","child","contains","wasInert","map","node","hasAttribute","setAttribute","forEach","index","removeAttribute","portal","parentElement","_$createComponent","when","onOpenChange","next","_$mergeProps","ref","positioner","class","aria-label","aria-labelledby","undefined","band","_$memo","_$createComponent","_$mergeProps","_$memo"],"sources":["../../../../src/components/ui/modal-dialog/modal-dialog.tsx"],"sourcesContent":["import type { Accessor, ComponentProps, JSX } from 'solid-js'\nimport { Show, createEffect, createSignal, onCleanup, splitProps } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport {\n createDialogFocusRestoration,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from '../dialog/dialog'\n\n/**\n * ModalDialog.\n *\n * A dialog that owns four things `Dialog` leaves to its caller, each of which is a\n * real defect when it is missed:\n *\n * 1. **It unmounts while closed.** An always-mounted dialog that closes as a side\n * effect of an async action can leave Kobalte's `aria-hidden` bookkeeping behind,\n * which hides the rest of the application from assistive technology. Unmounting\n * the whole owner makes cleanup the only way the layer can end.\n * 2. **It marks the background `inert`.** `inert` keeps the background out of the\n * tab order and the accessibility tree without depending on that bookkeeping, and\n * it restores exactly the elements that did not already have it — so a nested\n * dialog does not un-inert its parent.\n * 3. **It sets an explicit accessible name.** The content receives `aria-label`\n * from `title`, so its name does not depend on the title id registration effect.\n * Pass `aria-label` to use a different name while keeping the visible title;\n * pass `aria-labelledby` when another visible label should take precedence.\n * 4. **It returns focus to the opener.** The opener is captured before the dialog\n * autofocuses and restored after the owner closes, unless a close-autofocus\n * handler takes control or focus has moved to another layer. For controlled\n * dialogs without a composed trigger, pass `restoreFocusRef` when the opener\n * cannot be inferred from the focused element.\n * 5. **It keeps its own portal out of an enclosing layer's `aria-hidden`\n * bookkeeping.** A non-modal dialog opened while a modal `Sheet` is alive would\n * otherwise be aria-hidden one frame after it mounts — the enclosing layer's\n * hide-outside observer walks late-arriving body children as background. The\n * portal carries the marker that observer exempts; a modal layer opened above\n * still hides it, because that path matches a different attribute.\n *\n * Use `Dialog` directly when you need its composition; use this when you want a\n * dialog that is correct by default. `size=\"settings\"` supplies a wide, bounded\n * shell for a shared settings layout, titled by a banded header like a sheet's;\n * ordinary dialogs keep their compact default.\n */\nexport type ModalDialogProps = Omit<\n ComponentProps<typeof DialogContent>,\n 'children' | 'aria-label' | 'aria-labelledby' | 'positioner'\n> & {\n /** Selects the bounded, scrollable shell used for grouped workspace settings. */\n size?: 'default' | 'settings'\n open: boolean\n onClose: () => void\n title: string\n /**\n * Controls Kobalte's focus, scroll and accessibility modality. Defaults to `true`;\n * background body children remain inert in either mode.\n */\n modal?: boolean\n description?: string\n /** A mark or icon drawn before the title. */\n headerLeading?: JSX.Element\n /** Replaces `title` as the accessible name while keeping the visible title. */\n 'aria-label'?: string\n /** Names the dialog from a visible element; ARIA gives it precedence over `aria-label`. */\n 'aria-labelledby'?: string\n /**\n * Supplies the external control to focus when this controlled dialog closes.\n * Defaults to the element focused immediately before the dialog opens.\n */\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n children?: JSX.Element\n}\n\nexport function ModalDialog(props: ModalDialogProps) {\n const [local, rest] = splitProps(props, [\n 'open',\n 'onClose',\n 'title',\n 'modal',\n 'size',\n 'description',\n 'headerLeading',\n 'class',\n 'children',\n 'aria-label',\n 'aria-labelledby',\n 'restoreFocusRef',\n 'onOpenAutoFocus',\n 'onCloseAutoFocus',\n ])\n\n const [content, setContent] = createSignal<HTMLElement>()\n const focusRestoration = createDialogFocusRestoration({\n open: () => local.open,\n restoreFocusRef: local.restoreFocusRef,\n onOpenAutoFocus: local.onOpenAutoFocus,\n onCloseAutoFocus: local.onCloseAutoFocus,\n })\n\n createEffect(() => {\n if (!local.open) return\n const element = content()\n if (!element) return\n\n const background = [...document.body.children].filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.contains(element)\n )\n const wasInert = background.map((node) => node.hasAttribute('inert'))\n for (const node of background) node.setAttribute('inert', '')\n\n onCleanup(() => {\n background.forEach((node, index) => {\n // Only the elements that were not already inert are restored, so a nested\n // dialog closing does not undo its parent's containment.\n if (!wasInert[index]) node.removeAttribute('inert')\n })\n })\n\n // Kobalte's hide-outside observer walks body children added after its layer\n // opened and aria-hides them one frame later, so a non-modal dialog portaled\n // in during that window would land outside the accessibility tree — role\n // queries never resolve it again while the enclosing layer stays open. The\n // observer exempts added nodes carrying its top-layer marker (it checks the\n // React Aria spelling it ported; `data-kb-top-layer` is only matched by a\n // newer layer's initial walk, which must still hide this dialog).\n let portal = element\n while (portal.parentElement !== null && portal.parentElement !== document.body) {\n portal = portal.parentElement\n }\n portal.setAttribute('data-react-aria-top-layer', 'true')\n onCleanup(() => portal.removeAttribute('data-react-aria-top-layer'))\n })\n\n return (\n <Show when={local.open}>\n <Dialog open modal={local.modal ?? true} onOpenChange={(next) => !next && local.onClose()}>\n <DialogContent\n ref={setContent}\n positioner={local.size === 'settings' ? 'inset' : 'default'}\n class={cn(\n 'gap-4',\n local.size === 'settings' &&\n 'flex h-208 max-h-full min-h-0 max-w-6xl flex-col gap-0 overflow-hidden p-0',\n local.class\n )}\n aria-label={local['aria-label'] ?? local.title}\n aria-labelledby={\n local['aria-labelledby'] ?? (local['aria-label'] !== undefined ? '' : undefined)\n }\n {...rest}\n onOpenAutoFocus={focusRestoration.onOpenAutoFocus}\n onCloseAutoFocus={focusRestoration.onCloseAutoFocus}\n >\n <DialogHeader\n band={local.size === 'settings'}\n class={\n local.size === 'settings'\n ? 'shrink-0 gap-1 border-b border-border px-5 pt-4 pb-3 pe-14'\n : undefined\n }\n >\n <DialogTitle class=\"flex items-center gap-2\">\n <Show when={local.headerLeading}>{local.headerLeading}</Show>\n {local.title}\n </DialogTitle>\n <Show when={local.description}>\n <DialogDescription>{local.description}</DialogDescription>\n </Show>\n </DialogHeader>\n {local.children}\n </DialogContent>\n </Dialog>\n </Show>\n )\n}\n"],"mappings":";;;;;AA4EA,SAAgB4B,YAAYC,OAAyB;CACnD,MAAM,CAACC,OAAOC,QAAQxB,WAAWsB,OAAO;EACtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAAkB,CACnB;CAED,MAAM,CAACG,SAASC,cAAc5B,aAA0B;CACxD,MAAM6B,mBAAmBzB,6BAA6B;EACpDS,YAAYY,MAAMZ;EAClBO,iBAAiBK,MAAML;EACvBU,iBAAiBL,MAAMK;EACvBC,kBAAkBN,MAAMM;CAC1B,CAAC;CAEDhC,mBAAmB;EACjB,IAAI,CAAC0B,MAAMZ,MAAM;EACjB,MAAMmB,UAAUL,QAAQ;EACxB,IAAI,CAACK,SAAS;EAEd,MAAMC,aAAa,CAAC,GAAGC,SAASC,KAAKb,QAAQ,CAAC,CAACc,QAC5CC,UAAgCA,iBAAiBhB,eAAe,CAACgB,MAAMC,SAASN,OAAO,CAC1F;EACA,MAAMO,WAAWN,WAAWO,KAAKC,SAASA,KAAKC,aAAa,OAAO,CAAC;EACpE,KAAK,MAAM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,WAAA;SAAA,OAE7Ba,MAAMb,SAAS,aACX,+DACA+C,KAAAA;QAAS;QAAA,IAAArC,WAAA;SAAA,OAAA,CAAA2B,gBAGdxC,aAAW;UAAA,SAAA;UAAA,IAAAa,WAAA;WAAA,OAAA,CAAA2B,gBACTnD,MAAI;YAAA,IAACoD,OAAI;aAAA,OAAEzB,MAAMP;YAAa;YAAA,IAAAI,WAAA;aAAA,OAAGG,MAAMP;YAAa;WAAA,CAAA,GAAA2C,WACpDpC,MAAMV,KAAK,CAAA;UAAA;SAAA,CAAA,GAAAkC,gBAEbnD,MAAI;UAAA,IAACoD,OAAI;WAAA,OAAEzB,MAAMR;UAAW;UAAA,IAAAK,WAAA;WAAA,OAAA2B,gBAC1B1C,mBAAiB,EAAA,IAAAe,WAAA;YAAA,OAAEG,MAAMR;WAAW,EAAA,CAAA;UAAA;SAAA,CAAA,CAAA;QAAA;OAAA,CAAA,GAAA4C,WAGxCpC,MAAMH,QAAQ,CAAA;MAAA;KAAA,CAAA,CAAA;IAAA;GAAA,CAAA;EAAA;CAAA,CAAA;AAKzB"}
|
|
1
|
+
{"version":3,"file":"modal-dialog.js","names":["Accessor","ComponentProps","JSX","Show","createEffect","createSignal","onCleanup","splitProps","cn","createDialogFocusRestoration","Dialog","DialogContent","DialogDescription","DialogHeader","DialogTitle","ModalDialogProps","Omit","size","footer","Element","open","onClose","title","modal","description","headerLeading","restoreFocusRef","HTMLElement","children","ModalDialog","props","local","rest","content","setContent","focusRestoration","onOpenAutoFocus","onCloseAutoFocus","element","background","document","body","filter","child","contains","wasInert","map","node","hasAttribute","setAttribute","forEach","index","removeAttribute","portal","parentElement","_$createComponent","when","onOpenChange","next","_$mergeProps","ref","positioner","class","aria-label","aria-labelledby","undefined","band","_$memo","fallback","_el$","_tmpl$","_$insert","_el$2","_tmpl$2","_$createComponent","_$mergeProps","_$memo"],"sources":["../../../../src/components/ui/modal-dialog/modal-dialog.tsx"],"sourcesContent":["import type { Accessor, ComponentProps, JSX } from 'solid-js'\nimport { Show, createEffect, createSignal, onCleanup, splitProps } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport {\n createDialogFocusRestoration,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from '../dialog/dialog'\n\n/**\n * ModalDialog.\n *\n * A dialog that owns four things `Dialog` leaves to its caller, each of which is a\n * real defect when it is missed:\n *\n * 1. **It unmounts while closed.** An always-mounted dialog that closes as a side\n * effect of an async action can leave Kobalte's `aria-hidden` bookkeeping behind,\n * which hides the rest of the application from assistive technology. Unmounting\n * the whole owner makes cleanup the only way the layer can end.\n * 2. **It marks the background `inert`.** `inert` keeps the background out of the\n * tab order and the accessibility tree without depending on that bookkeeping, and\n * it restores exactly the elements that did not already have it — so a nested\n * dialog does not un-inert its parent.\n * 3. **It sets an explicit accessible name.** The content receives `aria-label`\n * from `title`, so its name does not depend on the title id registration effect.\n * Pass `aria-label` to use a different name while keeping the visible title;\n * pass `aria-labelledby` when another visible label should take precedence.\n * 4. **It returns focus to the opener.** The opener is captured before the dialog\n * autofocuses and restored after the owner closes, unless a close-autofocus\n * handler takes control or focus has moved to another layer. For controlled\n * dialogs without a composed trigger, pass `restoreFocusRef` when the opener\n * cannot be inferred from the focused element.\n * 5. **It keeps its own portal out of an enclosing layer's `aria-hidden`\n * bookkeeping.** A non-modal dialog opened while a modal `Sheet` is alive would\n * otherwise be aria-hidden one frame after it mounts — the enclosing layer's\n * hide-outside observer walks late-arriving body children as background. The\n * portal carries the marker that observer exempts; a modal layer opened above\n * still hides it, because that path matches a different attribute.\n *\n * Use `Dialog` directly when you need its composition; use this when you want a\n * dialog that is correct by default. `size=\"settings\"` supplies a wide, bounded\n * shell for a shared settings layout, titled by a banded header like a sheet's;\n * ordinary dialogs keep their compact default. Every centred dialog stays inside\n * the window: past the window's height it scrolls rather than running off its\n * edges. `size=\"fit\"` is for a dialog whose body can grow (a scan result, a long\n * plan) and whose actions must stay in view: the title and `footer` stay put and\n * the children scroll between them.\n */\nexport type ModalDialogProps = Omit<\n ComponentProps<typeof DialogContent>,\n 'children' | 'aria-label' | 'aria-labelledby' | 'positioner'\n> & {\n /**\n * `settings` selects the bounded, scrollable shell used for grouped workspace\n * settings. `fit` keeps the compact default width but lets the dialog's content\n * decide its height up to the window: the title band stays put, the children\n * scroll, and `footer` stays in view beneath them.\n */\n size?: 'default' | 'settings' | 'fit'\n /**\n * Actions that must stay reachable however long the content is (Cancel and a\n * primary button). Rendered under the scrolling children, outside the scroll\n * area, and only by the `fit` size.\n */\n footer?: JSX.Element\n open: boolean\n onClose: () => void\n title: string\n /**\n * Controls Kobalte's focus, scroll and accessibility modality. Defaults to `true`;\n * background body children remain inert in either mode.\n */\n modal?: boolean\n description?: string\n /** A mark or icon drawn before the title. */\n headerLeading?: JSX.Element\n /** Replaces `title` as the accessible name while keeping the visible title. */\n 'aria-label'?: string\n /** Names the dialog from a visible element; ARIA gives it precedence over `aria-label`. */\n 'aria-labelledby'?: string\n /**\n * Supplies the external control to focus when this controlled dialog closes.\n * Defaults to the element focused immediately before the dialog opens.\n */\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n children?: JSX.Element\n}\n\nexport function ModalDialog(props: ModalDialogProps) {\n const [local, rest] = splitProps(props, [\n 'open',\n 'onClose',\n 'title',\n 'modal',\n 'size',\n 'footer',\n 'description',\n 'headerLeading',\n 'class',\n 'children',\n 'aria-label',\n 'aria-labelledby',\n 'restoreFocusRef',\n 'onOpenAutoFocus',\n 'onCloseAutoFocus',\n ])\n\n const [content, setContent] = createSignal<HTMLElement>()\n const focusRestoration = createDialogFocusRestoration({\n open: () => local.open,\n restoreFocusRef: local.restoreFocusRef,\n onOpenAutoFocus: local.onOpenAutoFocus,\n onCloseAutoFocus: local.onCloseAutoFocus,\n })\n\n createEffect(() => {\n if (!local.open) return\n const element = content()\n if (!element) return\n\n const background = [...document.body.children].filter(\n (child): child is HTMLElement => child instanceof HTMLElement && !child.contains(element)\n )\n const wasInert = background.map((node) => node.hasAttribute('inert'))\n for (const node of background) node.setAttribute('inert', '')\n\n onCleanup(() => {\n background.forEach((node, index) => {\n // Only the elements that were not already inert are restored, so a nested\n // dialog closing does not undo its parent's containment.\n if (!wasInert[index]) node.removeAttribute('inert')\n })\n })\n\n // Kobalte's hide-outside observer walks body children added after its layer\n // opened and aria-hides them one frame later, so a non-modal dialog portaled\n // in during that window would land outside the accessibility tree — role\n // queries never resolve it again while the enclosing layer stays open. The\n // observer exempts added nodes carrying its top-layer marker (it checks the\n // React Aria spelling it ported; `data-kb-top-layer` is only matched by a\n // newer layer's initial walk, which must still hide this dialog).\n let portal = element\n while (portal.parentElement !== null && portal.parentElement !== document.body) {\n portal = portal.parentElement\n }\n portal.setAttribute('data-react-aria-top-layer', 'true')\n onCleanup(() => portal.removeAttribute('data-react-aria-top-layer'))\n })\n\n return (\n <Show when={local.open}>\n <Dialog open modal={local.modal ?? true} onOpenChange={(next) => !next && local.onClose()}>\n <DialogContent\n ref={setContent}\n positioner={local.size === 'settings' ? 'inset' : 'default'}\n class={cn(\n 'gap-4',\n local.size === 'settings' &&\n 'flex h-208 max-h-full min-h-0 max-w-6xl flex-col gap-0 overflow-hidden p-0',\n local.size === 'fit' && 'flex flex-col overflow-hidden',\n local.class\n )}\n aria-label={local['aria-label'] ?? local.title}\n aria-labelledby={\n local['aria-labelledby'] ?? (local['aria-label'] !== undefined ? '' : undefined)\n }\n {...rest}\n onOpenAutoFocus={focusRestoration.onOpenAutoFocus}\n onCloseAutoFocus={focusRestoration.onCloseAutoFocus}\n >\n <DialogHeader\n band={local.size === 'settings'}\n class={\n local.size === 'settings'\n ? 'shrink-0 gap-1 border-b border-border px-5 pt-4 pb-3 pe-14'\n : undefined\n }\n >\n <DialogTitle class=\"flex items-center gap-2\">\n <Show when={local.headerLeading}>{local.headerLeading}</Show>\n {local.title}\n </DialogTitle>\n <Show when={local.description}>\n <DialogDescription>{local.description}</DialogDescription>\n </Show>\n </DialogHeader>\n <Show when={local.size === 'fit'} fallback={local.children}>\n {/* The scrollport takes the room the title band and footer leave. The\n padding and matching negative margin keep a focused control's ring\n from being clipped at the scrollport's edge. */}\n <div class=\"-mx-1 flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-1\">\n {local.children}\n </div>\n <Show when={local.footer}>\n <div class=\"flex shrink-0 flex-wrap justify-end gap-2 border-t border-border pt-3\">\n {local.footer}\n </div>\n </Show>\n </Show>\n </DialogContent>\n </Dialog>\n </Show>\n )\n}\n"],"mappings":";;;;;;;AA2FA,SAAgB6B,YAAYC,OAAyB;CACnD,MAAM,CAACC,OAAOC,QAAQzB,WAAWuB,OAAO;EACtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAAkB,CACnB;CAED,MAAM,CAACG,SAASC,cAAc7B,aAA0B;CACxD,MAAM8B,mBAAmB1B,6BAA6B;EACpDW,YAAYW,MAAMX;EAClBM,iBAAiBK,MAAML;EACvBU,iBAAiBL,MAAMK;EACvBC,kBAAkBN,MAAMM;CAC1B,CAAC;CAEDjC,mBAAmB;EACjB,IAAI,CAAC2B,MAAMX,MAAM;EACjB,MAAMkB,UAAUL,QAAQ;EACxB,IAAI,CAACK,SAAS;EAEd,MAAMC,aAAa,CAAC,GAAGC,SAASC,KAAKb,QAAQ,CAAC,CAACc,QAC5CC,UAAgCA,iBAAiBhB,eAAe,CAACgB,MAAMC,SAASN,OAAO,CAC1F;EACA,MAAMO,WAAWN,WAAWO,KAAKC,SAASA,KAAKC,aAAa,OAAO,CAAC;EACpE,KAAK,MAAMD,QAAQR,YAAYQ,KAAKE,aAAa,SAAS,EAAE;EAE5D3C,gBAAgB;GACdiC,WAAWW,SAASH,MAAMI,UAAU;IAGlC,IAAI,CAACN,SAASM,QAAQJ,KAAKK,gBAAgB,OAAO;GACpD,CAAC;EACH,CAAC;EASD,IAAIC,SAASf;EACb,OAAOe,OAAOC,kBAAkB,QAAQD,OAAOC,kBAAkBd,SAASC,MACxEY,SAASA,OAA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AAG,WAAA;aAAA,OAAGG,MAAMN;YAAa;WAAA,CAAA,GAAA0C,WACpDpC,MAAMT,KAAK,CAAA;UAAA;SAAA,CAAA,GAAAiC,gBAEbpD,MAAI;UAAA,IAACqD,OAAI;WAAA,OAAEzB,MAAMP;UAAW;UAAA,IAAAI,WAAA;WAAA,OAAA2B,gBAC1B3C,mBAAiB,EAAA,IAAAgB,WAAA;YAAA,OAAEG,MAAMP;WAAW,EAAA,CAAA;UAAA;SAAA,CAAA,CAAA;QAAA;OAAA,CAAA,GAAA+B,gBAGxCpD,MAAI;QAAA,IAACqD,OAAI;SAAA,OAAEzB,MAAMd,SAAS;QAAK;QAAA,IAAEmD,WAAQ;SAAA,OAAErC,MAAMH;QAAQ;QAAA,IAAAA,WAAA;SAAA,OAAA,QAAA;UAAA,IAAAyC,OAAAC,OAAA;UAAAC,OAAAF,YAKrDtC,MAAMH,QAAQ;UAAA,OAAAyC;SAAA,EAAA,CAAA,GAAAd,gBAEhBpD,MAAI;UAAA,IAACqD,OAAI;WAAA,OAAEzB,MAAMb;UAAM;UAAA,IAAAU,WAAA;WAAA,IAAA4C,QAAAC,QAAA;WAAAF,OAAAC,aAEnBzC,MAAMb,MAAM;WAAA,OAAAsD;UAAA;SAAA,CAAA,CAAA;QAAA;OAAA,CAAA,CAAA;MAAA;KAAA,CAAA,CAAA;IAAA;GAAA,CAAA;EAAA;CAAA,CAAA;AAQ7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChevronLeft, ChevronRight } from 'lucide-solid'
|
|
2
|
-
import { createSignal, onCleanup, Show, splitProps } from 'solid-js'
|
|
2
|
+
import { createEffect, createSignal, onCleanup, Show, splitProps } from 'solid-js'
|
|
3
3
|
import { cn } from '../../../lib/utils'
|
|
4
4
|
import { ActionButton } from '../action-button'
|
|
5
5
|
import { Button } from '../../ui/button'
|
|
@@ -40,7 +40,8 @@ import {
|
|
|
40
40
|
*
|
|
41
41
|
* - **Hover or keyboard focus peeks.** The popover opens without taking focus
|
|
42
42
|
* and closes when the pointer or focus leaves. Touch has no hover, so a touch
|
|
43
|
-
* never peeks.
|
|
43
|
+
* never peeks. A keyboard peek's card is inert, so Tab moves on from the badge
|
|
44
|
+
* to the next control on the page instead of into a card that is closing.
|
|
44
45
|
* - **Click, tap, Enter or Space pins.** Focus moves into the popover so its
|
|
45
46
|
* link and Previous/Next are reachable; it stays until Escape, an outside press,
|
|
46
47
|
* or the badge is pressed again, and focus returns to the badge. Pressing a badge
|
|
@@ -85,6 +86,34 @@ export function InlineCitation(props: InlineCitationProps) {
|
|
|
85
86
|
// Focus handed back to the badge as the popover closes is not a request to
|
|
86
87
|
// peek again; without this, Escape from a pinned card reopens it as a preview.
|
|
87
88
|
let restoringFocus = false
|
|
89
|
+
// A keyboard peek is a preview of the badge the reader is already on. Its card
|
|
90
|
+
// sits in a portal at the end of the document, so if it stayed tabbable, Tab
|
|
91
|
+
// from the badge would walk into the card, the card would close behind the
|
|
92
|
+
// focus as the badge blurred, and focus would fall to <body> and be pulled
|
|
93
|
+
// back to the badge: a keyboard trap. The card is inert until Enter or Space
|
|
94
|
+
// pins it, and while it closes. A pointer peek stays interactive.
|
|
95
|
+
const [keyboardPeek, setKeyboardPeek] = createSignal(false)
|
|
96
|
+
// Focus goes back to the badge only when it was in the card. A peek never
|
|
97
|
+
// held focus, and its close (finishing after its exit animation) must not
|
|
98
|
+
// pull the reader back from wherever Tab has taken them since.
|
|
99
|
+
let focusInCard = false
|
|
100
|
+
// Escape closes the innermost layer first: an open Previous/Next tooltip, then
|
|
101
|
+
// the card. Kobalte only lets the top-most layer take Escape, and a tooltip
|
|
102
|
+
// that just closed stays the top layer while it animates out, so a second
|
|
103
|
+
// Escape pressed during that exit used to vanish and leave the card open.
|
|
104
|
+
// Whether a tooltip was open is read before any handler runs (window,
|
|
105
|
+
// capture); an Escape that closed nothing else closes the card itself.
|
|
106
|
+
let escapeClosedTooltip = false
|
|
107
|
+
const onWindowKeyDown = (event: KeyboardEvent) => {
|
|
108
|
+
if (event.key !== 'Escape') return
|
|
109
|
+
escapeClosedTooltip =
|
|
110
|
+
content?.ownerDocument.querySelector('[data-slot="tooltip-content"][data-expanded]') != null
|
|
111
|
+
}
|
|
112
|
+
createEffect(() => {
|
|
113
|
+
if (mode() !== 'pinned' || typeof window === 'undefined') return
|
|
114
|
+
window.addEventListener('keydown', onWindowKeyDown, true)
|
|
115
|
+
onCleanup(() => window.removeEventListener('keydown', onWindowKeyDown, true))
|
|
116
|
+
})
|
|
88
117
|
|
|
89
118
|
const count = () => local.sources.length
|
|
90
119
|
const active = () => local.sources[wrapIndex(position(), count())]
|
|
@@ -94,7 +123,13 @@ export function InlineCitation(props: InlineCitationProps) {
|
|
|
94
123
|
}
|
|
95
124
|
onCleanup(clear)
|
|
96
125
|
|
|
97
|
-
const dispatch = (event: CitationEvent) =>
|
|
126
|
+
const dispatch = (event: CitationEvent) =>
|
|
127
|
+
setMode((current) => {
|
|
128
|
+
const next = nextCitationMode(current, event)
|
|
129
|
+
if (next !== 'peek') setKeyboardPeek(false)
|
|
130
|
+
else if (current === 'closed') setKeyboardPeek(event === 'focus')
|
|
131
|
+
return next
|
|
132
|
+
})
|
|
98
133
|
const schedule = (event: CitationEvent, delay: number) => {
|
|
99
134
|
clear()
|
|
100
135
|
timer = setTimeout(() => dispatch(event), delay)
|
|
@@ -159,11 +194,25 @@ export function InlineCitation(props: InlineCitationProps) {
|
|
|
159
194
|
</PopoverTrigger>
|
|
160
195
|
<PopoverContent
|
|
161
196
|
ref={(element: HTMLElement) => (content = element)}
|
|
197
|
+
inert={keyboardPeek() || mode() === 'closed' || undefined}
|
|
162
198
|
class="w-72 max-w-full"
|
|
163
199
|
onOpenAutoFocus={(event: Event) => {
|
|
164
200
|
if (mode() === 'peek') event.preventDefault()
|
|
165
201
|
}}
|
|
166
|
-
|
|
202
|
+
onFocusIn={() => {
|
|
203
|
+
focusInCard = true
|
|
204
|
+
}}
|
|
205
|
+
onKeyDown={(event: KeyboardEvent) => {
|
|
206
|
+
if (event.key !== 'Escape' || escapeClosedTooltip || mode() !== 'pinned') return
|
|
207
|
+
dispatch('dismiss')
|
|
208
|
+
}}
|
|
209
|
+
onCloseAutoFocus={(event: Event) => {
|
|
210
|
+
const returnFocus = focusInCard
|
|
211
|
+
focusInCard = false
|
|
212
|
+
if (!returnFocus) {
|
|
213
|
+
event.preventDefault()
|
|
214
|
+
return
|
|
215
|
+
}
|
|
167
216
|
// The focus move that follows is synchronous; the microtask ends the window.
|
|
168
217
|
restoringFocus = true
|
|
169
218
|
queueMicrotask(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Accessor, JSX } from 'solid-js'
|
|
2
|
-
import { Show, createSignal, createUniqueId, onCleanup,
|
|
2
|
+
import { Show, createEffect, createSignal, createUniqueId, onCleanup, untrack } from 'solid-js'
|
|
3
3
|
import { cn } from '../../../lib/utils'
|
|
4
4
|
import {
|
|
5
5
|
SidebarNav,
|
|
@@ -37,6 +37,11 @@ export type ContextualSidebarProps = {
|
|
|
37
37
|
/** Host-controlled expanded state for the desktop panel and mobile dialog. */
|
|
38
38
|
open: boolean
|
|
39
39
|
onOpenChange(open: boolean): void
|
|
40
|
+
/**
|
|
41
|
+
* Presentation mode. `auto` (default) uses the built-in viewport breakpoint;
|
|
42
|
+
* hosts can select `desktop` or the shared mobile `Sheet` themselves.
|
|
43
|
+
*/
|
|
44
|
+
responsiveMode?: 'auto' | 'desktop' | 'mobile'
|
|
40
45
|
/** Current host-owned pixel width, reflected by the resize handle. */
|
|
41
46
|
width: number
|
|
42
47
|
minimum: number
|
|
@@ -80,20 +85,32 @@ export type ContextualSidebarProps = {
|
|
|
80
85
|
* persisted preference, open state, and view-specific navigation content.
|
|
81
86
|
*/
|
|
82
87
|
export function ContextualSidebar(props: ContextualSidebarProps) {
|
|
83
|
-
const [
|
|
88
|
+
const [isMobile, setIsMobile] = createSignal(false)
|
|
84
89
|
const [mobileLoad, setMobileLoad] = createSignal<MobileLoad>()
|
|
85
|
-
let
|
|
90
|
+
let mobileLoadGeneration = 0
|
|
91
|
+
let mobileLoadPending = false
|
|
92
|
+
let mobileLoadSettled = false
|
|
93
|
+
let responsiveModeInitialized = false
|
|
86
94
|
// Keep the resolved component mounted across viewport changes for Sheet cleanup.
|
|
87
95
|
const loadMobile = () => {
|
|
88
|
-
if (
|
|
89
|
-
|
|
96
|
+
if (mobileLoadPending || mobileLoadSettled) return
|
|
97
|
+
mobileLoadPending = true
|
|
98
|
+
const generation = ++mobileLoadGeneration
|
|
90
99
|
// Native module caching shares successful loads without keeping a rejected promise.
|
|
91
100
|
void import('./mobile-contextual-sidebar').then(
|
|
92
101
|
(module) => {
|
|
93
|
-
if (
|
|
102
|
+
if (generation === mobileLoadGeneration) {
|
|
103
|
+
mobileLoadPending = false
|
|
104
|
+
mobileLoadSettled = true
|
|
105
|
+
setMobileLoad(module)
|
|
106
|
+
}
|
|
94
107
|
},
|
|
95
108
|
(error: unknown) => {
|
|
96
|
-
if (
|
|
109
|
+
if (generation === mobileLoadGeneration) {
|
|
110
|
+
mobileLoadPending = false
|
|
111
|
+
mobileLoadSettled = true
|
|
112
|
+
setMobileLoad({ error })
|
|
113
|
+
}
|
|
97
114
|
}
|
|
98
115
|
)
|
|
99
116
|
}
|
|
@@ -107,28 +124,59 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
|
|
|
107
124
|
return mount?.connected && mount.element.isConnected ? mount.element : undefined
|
|
108
125
|
}
|
|
109
126
|
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// Close before mounting a modal. A desktop-expanded host state is not
|
|
116
|
-
// mobile intent, and opening the Sheet for one frame can steal focus.
|
|
117
|
-
if (media.matches && !wasNarrow) props.onOpenChange(false)
|
|
118
|
-
setIsNarrowViewport(media.matches)
|
|
119
|
-
}
|
|
127
|
+
createEffect(() => {
|
|
128
|
+
const mode = props.responsiveMode ?? 'auto'
|
|
129
|
+
const wasMobile = untrack(isMobile)
|
|
130
|
+
let media: MediaQueryList | undefined
|
|
131
|
+
let viewportListener: (() => void) | undefined
|
|
120
132
|
|
|
121
|
-
// A route can mount after a wide-loaded host crosses into mobile. Clear
|
|
122
|
-
// that stale seed, but preserve a sidebar intentionally opened at a
|
|
123
|
-
// narrow boot viewport.
|
|
124
|
-
if (media.matches) loadMobile()
|
|
125
|
-
if (media.matches && props.wideViewportAtLoad && props.open) props.onOpenChange(false)
|
|
126
|
-
setIsNarrowViewport(media.matches)
|
|
127
|
-
media.addEventListener('change', updateViewport)
|
|
128
133
|
onCleanup(() => {
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
mobileLoadGeneration += 1
|
|
135
|
+
mobileLoadPending = false
|
|
136
|
+
if (media && viewportListener) media.removeEventListener('change', viewportListener)
|
|
131
137
|
})
|
|
138
|
+
|
|
139
|
+
if (mode === 'desktop') {
|
|
140
|
+
setIsMobile(false)
|
|
141
|
+
} else if (mode === 'mobile') {
|
|
142
|
+
// An explicit host transition into mobile must not briefly open a Sheet
|
|
143
|
+
// with stale desktop-expanded state. An initial wide-loaded seed still
|
|
144
|
+
// marks an open value as stale, including in host-selected mobile mode.
|
|
145
|
+
const shouldCloseStaleOpen = responsiveModeInitialized
|
|
146
|
+
? !wasMobile && untrack(() => props.open)
|
|
147
|
+
: untrack(() => props.wideViewportAtLoad && props.open)
|
|
148
|
+
if (shouldCloseStaleOpen) untrack(() => props.onOpenChange(false))
|
|
149
|
+
loadMobile()
|
|
150
|
+
setIsMobile(true)
|
|
151
|
+
} else {
|
|
152
|
+
const mediaQuery = window.matchMedia('(max-width: 48rem)')
|
|
153
|
+
media = mediaQuery
|
|
154
|
+
const updateViewport = () => {
|
|
155
|
+
const nextIsMobile = mediaQuery.matches
|
|
156
|
+
const wasNarrow = untrack(isMobile)
|
|
157
|
+
if (nextIsMobile) loadMobile()
|
|
158
|
+
// Close before mounting a modal. A desktop-expanded host state is not
|
|
159
|
+
// mobile intent, and opening the Sheet for one frame can steal focus.
|
|
160
|
+
if (nextIsMobile && !wasNarrow) props.onOpenChange(false)
|
|
161
|
+
setIsMobile(nextIsMobile)
|
|
162
|
+
}
|
|
163
|
+
viewportListener = updateViewport
|
|
164
|
+
|
|
165
|
+
// Preserve a narrow-boot open intent. Initial auto and mobile modes use
|
|
166
|
+
// the viewport seed to clear stale state; runtime transitions close it.
|
|
167
|
+
if (media.matches) {
|
|
168
|
+
if (!responsiveModeInitialized && untrack(() => props.wideViewportAtLoad && props.open)) {
|
|
169
|
+
untrack(() => props.onOpenChange(false))
|
|
170
|
+
} else if (responsiveModeInitialized && !wasMobile) {
|
|
171
|
+
untrack(() => props.onOpenChange(false))
|
|
172
|
+
}
|
|
173
|
+
loadMobile()
|
|
174
|
+
}
|
|
175
|
+
setIsMobile(mediaQuery.matches)
|
|
176
|
+
mediaQuery.addEventListener('change', updateViewport)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
responsiveModeInitialized = true
|
|
132
180
|
})
|
|
133
181
|
|
|
134
182
|
const renderSidebar = (mobile: boolean) => {
|
|
@@ -209,13 +257,13 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
|
|
|
209
257
|
|
|
210
258
|
return (
|
|
211
259
|
<>
|
|
212
|
-
<Show when={!
|
|
260
|
+
<Show when={!isMobile()}>{(_wide) => renderSidebar(false)}</Show>
|
|
213
261
|
<Show when={mobileLoad()} keyed>
|
|
214
262
|
{(loaded) => {
|
|
215
263
|
if ('error' in loaded) throw loaded.error
|
|
216
264
|
return (
|
|
217
265
|
<loaded.MobileSidebar
|
|
218
|
-
open={
|
|
266
|
+
open={isMobile() && props.open}
|
|
219
267
|
onOpenChange={props.onOpenChange}
|
|
220
268
|
label={props.label}
|
|
221
269
|
sheetClass={props.sheetClass}
|
|
@@ -94,7 +94,12 @@ export function AlertDialogContent(props: ComponentProps<typeof KobalteAlertDial
|
|
|
94
94
|
<div class={overlayPositioner}>
|
|
95
95
|
<KobalteAlertDialogContent
|
|
96
96
|
{...blockDismissal}
|
|
97
|
-
class={cn(
|
|
97
|
+
class={cn(
|
|
98
|
+
dialogSurface,
|
|
99
|
+
overlayMotion,
|
|
100
|
+
'grid max-h-full w-full max-w-md gap-4 overflow-y-auto p-5',
|
|
101
|
+
local.class
|
|
102
|
+
)}
|
|
98
103
|
{...rest}
|
|
99
104
|
/>
|
|
100
105
|
</div>
|
|
@@ -172,7 +177,11 @@ function AlertDialogChoice(props: ComponentProps<typeof KobalteAlertDialog.Close
|
|
|
172
177
|
|
|
173
178
|
return (
|
|
174
179
|
<span ref={setWrapper} class="contents">
|
|
175
|
-
<KobalteAlertDialog.CloseButton
|
|
180
|
+
<KobalteAlertDialog.CloseButton
|
|
181
|
+
class={cn(local.class)}
|
|
182
|
+
aria-label={local['aria-label']}
|
|
183
|
+
{...rest}
|
|
184
|
+
/>
|
|
176
185
|
</span>
|
|
177
186
|
)
|
|
178
187
|
}
|
|
@@ -314,7 +314,7 @@ export function DialogContent(props: DialogContentProps) {
|
|
|
314
314
|
class={cn(
|
|
315
315
|
dialogSurface,
|
|
316
316
|
overlayMotion,
|
|
317
|
-
'relative grid w-full gap-4 p-5',
|
|
317
|
+
'relative grid max-h-full w-full gap-4 overflow-y-auto p-5',
|
|
318
318
|
dialogContentSizes[local.size ?? 'md'],
|
|
319
319
|
local.class
|
|
320
320
|
)}
|