@adea-ai/ui 0.72.2 → 0.72.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/composites/update-dialog/update-dialog.d.ts +7 -3
- package/dist/components/composites/update-dialog/update-dialog.d.ts.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.js +48 -13
- package/dist/components/composites/update-dialog/update-dialog.js.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.d.ts +2 -2
- package/dist/components/ui/alert-dialog/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.js +2 -2
- package/dist/components/ui/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/ui/dialog/dialog.d.ts +5 -5
- package/dist/components/ui/dialog/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog/dialog.js +3 -3
- package/dist/components/ui/dialog/dialog.js.map +1 -1
- package/dist/components/ui/sheet/sheet.d.ts +2 -2
- package/dist/components/ui/sheet/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet/sheet.js +2 -2
- package/dist/components/ui/sheet/sheet.js.map +1 -1
- package/dist/r/src/components/composites/update-dialog/update-dialog.tsx +70 -16
- package/dist/r/src/components/ui/alert-dialog/alert-dialog.tsx +7 -3
- package/dist/r/src/components/ui/dialog/dialog.tsx +13 -8
- package/dist/r/src/components/ui/sheet/sheet.tsx +5 -4
- package/package.json +1 -1
- package/src/components/composites/update-dialog/update-dialog.tsx +70 -16
- package/src/components/ui/alert-dialog/alert-dialog.tsx +7 -3
- package/src/components/ui/dialog/dialog.tsx +13 -8
- package/src/components/ui/sheet/sheet.tsx +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","names":["Dialog","KobalteDialog","X","Accessor","ComponentProps","JSX","createRenderEffect","onCleanup","Show","splitProps","overlayMotion","overlayPositioner","overlayScrim","overlaySurface","cn","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","Content","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","Overlay","local","rest","_$mergeProps","class","DialogContentProps","closeButton","Element","DialogContent","children","_el$","_tmpl$","_$className","_$insert","_$memo","when","CloseButton","DialogHeader","_el$2","_tmpl$2","_$spread","DialogFooter","_el$3","_tmpl$3","DialogTitle","Title","DialogDescription","Description","DialogCloseButton","DialogClose","Dialog","_$createComponent","KobalteDialog","_$mergeProps","_$memo"],"sources":["../../../../src/components/ui/dialog/dialog.tsx"],"sourcesContent":["import { Dialog as KobalteDialog } from '@kobalte/core/dialog'\nimport { X } from 'lucide-solid'\nimport type { Accessor, ComponentProps, JSX } from 'solid-js'\nimport { createRenderEffect, onCleanup, Show, splitProps } from 'solid-js'\nimport { overlayMotion, overlayPositioner, overlayScrim, overlaySurface } from '#lib/overlay'\nimport { cn } from '#lib/utils'\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 KobalteDialog.Content>['onOpenAutoFocus']\n onCloseAutoFocus?: ComponentProps<typeof KobalteDialog.Content>['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 target === element ||\n element.contains(target) ||\n target === (opener instanceof HTMLElement ? opener : null)\n ) {\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 KobalteDialog.Overlay>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <KobalteDialog.Overlay\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 KobalteDialog.Content> & {\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\nexport function DialogContent(props: DialogContentProps) {\n const [local, rest] = splitProps(props, ['class', 'children', 'closeButton'])\n\n return (\n <KobalteDialog.Portal>\n <DialogOverlay />\n <div class={overlayPositioner}>\n <KobalteDialog.Content\n class={cn(\n overlaySurface,\n overlayMotion,\n 'relative grid w-full max-w-lg gap-4 p-5',\n local.class\n )}\n {...rest}\n >\n {local.children}\n <Show when={local.closeButton !== false}>\n <KobalteDialog.CloseButton\n aria-label=\"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 </KobalteDialog.CloseButton>\n </Show>\n </KobalteDialog.Content>\n </div>\n </KobalteDialog.Portal>\n )\n}\n\nexport function DialogHeader(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"dialog-header\"\n class={cn('flex flex-col gap-1.5 pe-6 text-start', 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 (\n <KobalteDialog.Title\n class={cn('text-base leading-none font-semibold tracking-tight', local.class)}\n {...rest}\n />\n )\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":";;;;;;;;;;AAoBA,SAAS8B,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,gBAAgBxB,SAAsBE,QAA8B;CAC3E,OAAO,CAAC,GAAGe,SAASQ,iBAA8B,2CAAuC,CAAC,CAAC,CAACC,MACzFC,YACCA,YAAY3B,WACZ,CAACA,QAAQ4B,SAASD,OAAO,KACzB,CAACA,QAAQC,SAAS1B,MAAM,KACxB,CAACyB,QAAQP,QAAQ,iCAA+B,KAChDO,QAAQL,eAAe,CAAC,CAACC,SAAS,CAC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AYpC,OAAyD;CACnF,MAAM,CAACQ,OAAOC,QAAQ3F,WAAWkF,OAAO,CAAC,OAAO,CAAC;CACjD,OAAAC,gBAAQ3F,OAAciH,aAAWb,WAAA,EAAA,KAAA,WAAA;EAAA,OAAQvF,GAAG,cAAcqF,MAAMG,KAAK;CAAC,EAAA,GAAMF,IAAI,CAAA;AAClF"}
|
|
1
|
+
{"version":3,"file":"dialog.js","names":["Dialog","KobalteDialog","Content","KobalteDialogContent","Overlay","KobalteDialogOverlay","X","Accessor","ComponentProps","JSX","createRenderEffect","onCleanup","Show","splitProps","overlayMotion","overlayPositioner","overlayScrim","overlaySurface","cn","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","DialogContent","children","_el$","_tmpl$","_$className","_$insert","_$memo","when","CloseButton","DialogHeader","_el$2","_tmpl$2","_$spread","DialogFooter","_el$3","_tmpl$3","DialogTitle","Title","DialogDescription","Description","DialogCloseButton","DialogClose","Dialog","_$createComponent","KobalteDialog","KobalteDialogOverlay","_$mergeProps","KobalteDialogContent","_$memo"],"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 { overlayMotion, overlayPositioner, overlayScrim, overlaySurface } from '#lib/overlay'\nimport { cn } from '#lib/utils'\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 target === element ||\n element.contains(target) ||\n target === (opener instanceof HTMLElement ? opener : null)\n ) {\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\nexport function DialogContent(props: DialogContentProps) {\n const [local, rest] = splitProps(props, ['class', 'children', 'closeButton'])\n\n return (\n <KobalteDialog.Portal>\n <DialogOverlay />\n <div class={overlayPositioner}>\n <KobalteDialogContent\n class={cn(\n overlaySurface,\n overlayMotion,\n 'relative grid w-full max-w-lg gap-4 p-5',\n local.class\n )}\n {...rest}\n >\n {local.children}\n <Show when={local.closeButton !== false}>\n <KobalteDialog.CloseButton\n aria-label=\"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 </KobalteDialog.CloseButton>\n </Show>\n </KobalteDialogContent>\n </div>\n </KobalteDialog.Portal>\n )\n}\n\nexport function DialogHeader(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"dialog-header\"\n class={cn('flex flex-col gap-1.5 pe-6 text-start', 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 (\n <KobalteDialog.Title\n class={cn('text-base leading-none font-semibold tracking-tight', local.class)}\n {...rest}\n />\n )\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 <Kobal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Gd;AAEA,SAAgBwB,kBAAkBhC,OAAyD;CACzF,MAAM,CAACO,OAAOC,QAAQzF,WAAWiF,OAAO,CAAC,OAAO,CAAC;CACjD,OAAAC,gBACG9F,OAAc8H,aAAWxB,WAAA,EAAA,KAAA,WAAA;EAAA,OAAQrF,GAAG,iCAAiCmF,MAAMG,KAAK;CAAC,EAAA,GAAMF,IAAI,CAAA;AAEhG;AAEA,SAAgB0B,kBAAkBlC,OAAyD;CACzF,MAAM,CAACO,OAAOC,QAAQzF,WAAWiF,OAAO,CAAC,OAAO,CAAC;CACjD,OAAAC,gBAAQ9F,OAAcmH,aAAWb,WAAA,EAAA,KAAA,WAAA;EAAA,OAAQrF,GAAG,cAAcmF,MAAMG,KAAK;CAAC,EAAA,GAAMF,IAAI,CAAA;AAClF;;;;;;;AAQA,SAAgB2B,YAAYnC,OAAyD;CACnF,MAAM,CAACO,OAAOC,QAAQzF,WAAWiF,OAAO,CAAC,OAAO,CAAC;CACjD,OAAAC,gBAAQ9F,OAAcmH,aAAWb,WAAA,EAAA,KAAA,WAAA;EAAA,OAAQrF,GAAG,cAAcmF,MAAMG,KAAK;CAAC,EAAA,GAAMF,IAAI,CAAA;AAClF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dialog as KobalteDialog } from '@kobalte/core/dialog';
|
|
1
|
+
import { Dialog as KobalteDialog, Content as KobalteDialogContent } from '@kobalte/core/dialog';
|
|
2
2
|
import type { ComponentProps, JSX } from 'solid-js';
|
|
3
3
|
import { type VariantProps } from '#lib/variants';
|
|
4
4
|
/**
|
|
@@ -16,7 +16,7 @@ import { type VariantProps } from '#lib/variants';
|
|
|
16
16
|
declare const sheetVariants: (props?: ({
|
|
17
17
|
side?: "bottom" | "end" | "start" | "top" | null | undefined;
|
|
18
18
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
19
|
-
export type SheetContentProps = ComponentProps<typeof
|
|
19
|
+
export type SheetContentProps = ComponentProps<typeof KobalteDialogContent> & VariantProps<typeof sheetVariants> & {
|
|
20
20
|
closeButton?: JSX.Element | false;
|
|
21
21
|
};
|
|
22
22
|
export declare function SheetContent(props: SheetContentProps): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/sheet/sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/sheet/sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAG/F,OAAO,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AAItD;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,aAAa;;8EAelB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,OAAO,oBAAoB,CAAC,GACzE,YAAY,CAAC,OAAO,aAAa,CAAC,GAAG;IACnC,WAAW,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,KAAK,CAAA;CAClC,CAAA;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eA2BpD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,eAEhE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,OAAO,CAAC,eAE/E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,WAAW,CAAC,eAGvF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,eASvD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,eASrD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,eASvD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,KAAK,CAAC,eAK3E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,WAAW,CAAC,eAKvF;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { DialogOverlay } from "../dialog/dialog.js";
|
|
|
4
4
|
import { createComponent, memo, mergeProps, spread, template } from "solid-js/web";
|
|
5
5
|
import { X } from "lucide-solid";
|
|
6
6
|
import { Show, splitProps } from "solid-js";
|
|
7
|
-
import { Dialog } from "@kobalte/core/dialog";
|
|
7
|
+
import { Content, Dialog } from "@kobalte/core/dialog";
|
|
8
8
|
//#region src/components/ui/sheet/sheet.tsx
|
|
9
9
|
var _tmpl$ = /*#__PURE__*/ template(`<div data-slot=sheet-header>`);
|
|
10
10
|
var _tmpl$2 = /*#__PURE__*/ template(`<div data-slot=sheet-body>`);
|
|
@@ -38,7 +38,7 @@ function SheetContent(props) {
|
|
|
38
38
|
"closeButton"
|
|
39
39
|
]);
|
|
40
40
|
return createComponent(Dialog.Portal, { get children() {
|
|
41
|
-
return [createComponent(DialogOverlay, {}), createComponent(
|
|
41
|
+
return [createComponent(DialogOverlay, {}), createComponent(Content, mergeProps({ get ["class"]() {
|
|
42
42
|
return cn(sheetVariants({ side: local.side }), "data-expanded:animate-in data-expanded:fade-in-0 data-expanded:duration-200", "data-closed:animate-out data-closed:fade-out-0 data-closed:duration-150", local.class);
|
|
43
43
|
} }, rest, { get children() {
|
|
44
44
|
return [memo(() => local.children), createComponent(Show, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet.js","names":["Dialog","KobalteDialog","X","ComponentProps","JSX","Show","splitProps","cva","VariantProps","cn","DialogOverlay","sheetVariants","variants","side","top","bottom","start","end","defaultVariants","SheetContentProps","
|
|
1
|
+
{"version":3,"file":"sheet.js","names":["Dialog","KobalteDialog","Content","KobalteDialogContent","X","ComponentProps","JSX","Show","splitProps","cva","VariantProps","cn","DialogOverlay","sheetVariants","variants","side","top","bottom","start","end","defaultVariants","SheetContentProps","closeButton","Element","SheetContent","props","local","rest","_$createComponent","Portal","children","_$mergeProps","class","_$memo","when","CloseButton","Sheet","SheetTrigger","Trigger","SheetCloseButton","SheetHeader","_el$","_tmpl$","_$spread","SheetBody","_el$2","_tmpl$2","SheetFooter","_el$3","_tmpl$3","SheetTitle","Title","SheetDescription","Description","_$createComponent","KobalteDialog","KobalteDialogContent","_$mergeProps","_$memo"],"sources":["../../../../src/components/ui/sheet/sheet.tsx"],"sourcesContent":["import { Dialog as KobalteDialog, Content as KobalteDialogContent } from '@kobalte/core/dialog'\n// AlertDialog shares DialogRoot.Content; Sheet uses the stable named primitive.\nimport { X } from 'lucide-solid'\nimport type { ComponentProps, JSX } from 'solid-js'\nimport { Show, splitProps } from 'solid-js'\nimport { cva, type VariantProps } from '#lib/variants'\nimport { cn } from '#lib/utils'\nimport { DialogOverlay } from '../dialog/dialog'\n\n/**\n * Sheet.\n *\n * A dialog anchored to an edge of the window rather than centred. Use it when\n * the content is a *panel beside* the work — a details inspector, a filter rail,\n * a settings flyout — so the user keeps the context it belongs to in view.\n * A centred dialog interrupts; a sheet is inspected.\n *\n * `side` decides which edge; the panel is a full-height column for `start` and\n * `end`, and a full-width row for `top` and `bottom`. The slide-in direction\n * follows from the side, so a caller never pairs them by hand.\n */\nconst sheetVariants = cva(\n 'bg-popover text-popover-foreground fixed z-(--z-dialog) flex flex-col gap-4 border-border shadow-lg',\n {\n variants: {\n side: {\n top: 'inset-x-0 top-0 h-auto max-h-[85vh] rounded-b-xl border-b data-expanded:slide-in-from-top data-closed:slide-out-to-top',\n bottom:\n 'inset-x-0 bottom-0 h-auto max-h-[85vh] rounded-t-xl border-t data-expanded:slide-in-from-bottom data-closed:slide-out-to-bottom',\n start:\n 'inset-y-0 start-0 h-full w-80 max-w-[85vw] rounded-e-xl border-e data-expanded:slide-in-from-left data-closed:slide-out-to-left',\n end: 'inset-y-0 end-0 h-full w-80 max-w-[85vw] rounded-s-xl border-s data-expanded:slide-in-from-right data-closed:slide-out-to-right',\n },\n },\n defaultVariants: { side: 'end' },\n }\n)\n\nexport type SheetContentProps = ComponentProps<typeof KobalteDialogContent> &\n VariantProps<typeof sheetVariants> & {\n closeButton?: JSX.Element | false\n }\n\nexport function SheetContent(props: SheetContentProps) {\n const [local, rest] = splitProps(props, ['class', 'side', 'children', 'closeButton'])\n\n return (\n <KobalteDialog.Portal>\n <DialogOverlay />\n <KobalteDialogContent\n class={cn(\n sheetVariants({ side: local.side }),\n 'data-expanded:animate-in data-expanded:fade-in-0 data-expanded:duration-200',\n 'data-closed:animate-out data-closed:fade-out-0 data-closed:duration-150',\n local.class\n )}\n {...rest}\n >\n {local.children}\n <Show when={local.closeButton !== false}>\n <KobalteDialog.CloseButton\n aria-label=\"Close\"\n class=\"absolute top-3.5 end-3.5 rounded-md p-1 text-muted-foreground transition-colors ease-out outline-none hover:bg-surface-hover hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle\"\n >\n {local.closeButton ?? <X class=\"size-4\" />}\n </KobalteDialog.CloseButton>\n </Show>\n </KobalteDialogContent>\n </KobalteDialog.Portal>\n )\n}\n\nexport function Sheet(props: ComponentProps<typeof KobalteDialog>) {\n return <KobalteDialog {...props} />\n}\n\nexport function SheetTrigger(props: ComponentProps<typeof KobalteDialog.Trigger>) {\n return <KobalteDialog.Trigger {...props} />\n}\n\nexport function SheetCloseButton(props: ComponentProps<typeof KobalteDialog.CloseButton>) {\n const [local, rest] = splitProps(props, ['class'])\n return <KobalteDialog.CloseButton class={cn(local.class)} {...rest} />\n}\n\nexport function SheetHeader(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"sheet-header\"\n class={cn('flex flex-col gap-1.5 border-b border-border p-4 pe-12 text-start', local.class)}\n {...rest}\n />\n )\n}\n\nexport function SheetBody(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"sheet-body\"\n class={cn('flex-1 overflow-y-auto px-4 pb-4', local.class)}\n {...rest}\n />\n )\n}\n\nexport function SheetFooter(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"sheet-footer\"\n class={cn('flex items-center justify-end gap-2 border-t border-border p-4', local.class)}\n {...rest}\n />\n )\n}\n\nexport function SheetTitle(props: ComponentProps<typeof KobalteDialog.Title>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <KobalteDialog.Title class={cn('text-sm leading-none font-semibold', local.class)} {...rest} />\n )\n}\n\nexport function SheetDescription(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 { sheetVariants }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAMa,gBAAgBJ,IACpB,uGACA;CACEK,UAAU,EACRC,MAAM;EACJC,KAAK;EACLC,QACE;EACFC,OACE;EACFC,KAAK;CACP,EACF;CACAC,iBAAiB,EAAEL,MAAM,MAAM;AACjC,CACF;AAOA,SAAgBS,aAAaC,OAA0B;CACrD,MAAM,CAACC,OAAOC,QAAQnB,WAAWiB,OAAO;EAAC;EAAS;EAAQ;EAAY;CAAa,CAAC;CAEpF,OAAAG,gBACG3B,OAAc4B,QAAM,EAAA,IAAAC,WAAA;EAAA,OAAA,CAAAF,gBAClBhB,eAAa,CAAA,CAAA,GAAAgB,gBACbzB,SAAoB4B,WAAA,EAAA,KAAA,WAAA;GAAA,OACZpB,GACLE,cAAc,EAAEE,MAAMW,MAAMX,KAAK,CA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OAAO,CAAC,OAAO,CAAC;CACjD,cAAA;EAAA,IAAAoB,QAAAC,QAAA;EAAAH,OAAAE,OAAAd,WAAA,EAAA,KAAA,WAAA;GAAA,OAGWpB,GAAG,oCAAoCe,MAAMM,KAAK;EAAC,EAAA,GACtDL,IAAI,GAAA,OAAA,KAAA;EAAA,OAAAkB;CAAA,EAAA,CAAA;AAGd;AAEA,SAAgBE,YAAYtB,OAA8B;CACxD,MAAM,CAACC,OAAOC,QAAQnB,WAAWiB,OAAO,CAAC,OAAO,CAAC;CACjD,cAAA;EAAA,IAAAuB,QAAAC,QAAA;EAAAN,OAAAK,OAAAjB,WAAA,EAAA,KAAA,WAAA;GAAA,OAGWpB,GAAG,kEAAkEe,MAAMM,KAAK;EAAC,EAAA,GACpFL,IAAI,GAAA,OAAA,KAAA;EAAA,OAAAqB;CAAA,EAAA,CAAA;AAGd;AAEA,SAAgBE,WAAWzB,OAAmD;CAC5E,MAAM,CAACC,OAAOC,QAAQnB,WAAWiB,OAAO,CAAC,OAAO,CAAC;CACjD,OAAAG,gBACG3B,OAAckD,OAAKpB,WAAA,EAAA,KAAA,WAAA;EAAA,OAAQpB,GAAG,sCAAsCe,MAAMM,KAAK;CAAC,EAAA,GAAML,IAAI,CAAA;AAE/F;AAEA,SAAgByB,iBAAiB3B,OAAyD;CACxF,MAAM,CAACC,OAAOC,QAAQnB,WAAWiB,OAAO,CAAC,OAAO,CAAC;CACjD,OAAAG,gBACG3B,OAAcoD,aAAWtB,WAAA,EAAA,KAAA,WAAA;EAAA,OAAQpB,GAAG,iCAAiCe,MAAMM,KAAK;CAAC,EAAA,GAAML,IAAI,CAAA;AAEhG"}
|
|
@@ -56,9 +56,13 @@ import { formatBytes, formatReleaseDate, plainTextFromMarkdown } from '../../../
|
|
|
56
56
|
* the other order leaves the dialog blank for as long as the check takes, on a
|
|
57
57
|
* dialog whose first question is always "what am I running?".
|
|
58
58
|
*
|
|
59
|
-
* **
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
* **A failed check is not a current result.** A cached `current` status can only
|
|
60
|
+
* be shown as up to date after the latest check succeeds; a failed check remains
|
|
61
|
+
* retryable and suppresses that claim.
|
|
62
|
+
*
|
|
63
|
+
* **Errors are not always `Error`s.** An adapter can reject with a string or a
|
|
64
|
+
* structured safe message. Unknown object fields are never serialized into the
|
|
65
|
+
* UI; a generic fallback is shown instead.
|
|
62
66
|
*
|
|
63
67
|
* The adapter's `isDesktopRuntime` gate exists because an update is a desktop
|
|
64
68
|
* concern: a browser build has no installer, and the honest thing to show is that
|
|
@@ -151,10 +155,22 @@ export type UpdateDialogProps = {
|
|
|
151
155
|
class?: string
|
|
152
156
|
}
|
|
153
157
|
|
|
158
|
+
function messageText(value: unknown): string | undefined {
|
|
159
|
+
if (typeof value !== 'string') return undefined
|
|
160
|
+
const message = value.trim()
|
|
161
|
+
return message && message !== '[object Object]' ? message : undefined
|
|
162
|
+
}
|
|
163
|
+
|
|
154
164
|
function errorMessage(caught: unknown, fallback: string): string {
|
|
155
|
-
if (caught instanceof Error
|
|
156
|
-
|
|
157
|
-
return
|
|
165
|
+
if (caught instanceof Error) return messageText(caught.message) ?? fallback
|
|
166
|
+
const plainMessage = messageText(caught)
|
|
167
|
+
if (plainMessage) return plainMessage
|
|
168
|
+
if (!caught || typeof caught !== 'object') return fallback
|
|
169
|
+
|
|
170
|
+
const record = caught as { error?: unknown; safe?: unknown }
|
|
171
|
+
const safe = record.safe as { message?: unknown } | null | undefined
|
|
172
|
+
const nestedError = record.error as { safe?: { message?: unknown } | null } | null | undefined
|
|
173
|
+
return messageText(safe?.message) ?? messageText(nestedError?.safe?.message) ?? fallback
|
|
158
174
|
}
|
|
159
175
|
|
|
160
176
|
/**
|
|
@@ -199,6 +215,7 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
199
215
|
const [state, setState] = createSignal<UpdateState | null>(null)
|
|
200
216
|
const [busy, setBusy] = createSignal(false)
|
|
201
217
|
const [error, setError] = createSignal('')
|
|
218
|
+
const [checkFailed, setCheckFailed] = createSignal(false)
|
|
202
219
|
let lifecycleEpoch = 0
|
|
203
220
|
let activeOpenEpoch: number | undefined
|
|
204
221
|
let disposed = false
|
|
@@ -213,7 +230,19 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
213
230
|
if (!desktop() || !isCurrent()) return
|
|
214
231
|
try {
|
|
215
232
|
const status = await local.adapter.getStatus()
|
|
216
|
-
|
|
233
|
+
const previous = state()
|
|
234
|
+
const hasActionableSnapshot = (candidate: UpdateState | null) =>
|
|
235
|
+
candidate?.phase === 'available' || isBusy(candidate)
|
|
236
|
+
const preservesSnapshot =
|
|
237
|
+
previous?.phase === 'available'
|
|
238
|
+
? status.phase === 'available' || isBusy(status)
|
|
239
|
+
: isBusy(previous) && isBusy(status)
|
|
240
|
+
if (
|
|
241
|
+
isCurrent() &&
|
|
242
|
+
!(checkFailed() && hasActionableSnapshot(previous) && !preservesSnapshot)
|
|
243
|
+
) {
|
|
244
|
+
setState(status)
|
|
245
|
+
}
|
|
217
246
|
} catch (caught) {
|
|
218
247
|
if (isCurrent()) setError(errorMessage(caught, 'Version status is unavailable'))
|
|
219
248
|
}
|
|
@@ -226,6 +255,24 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
226
255
|
}
|
|
227
256
|
})
|
|
228
257
|
|
|
258
|
+
const failCheck = (caught: unknown, fallback: string) => {
|
|
259
|
+
const message = errorMessage(caught, fallback)
|
|
260
|
+
setCheckFailed(true)
|
|
261
|
+
setError(message)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const applyCheckResult = (next: UpdateState) => {
|
|
265
|
+
if (next.phase === 'failed') {
|
|
266
|
+
const current = state()
|
|
267
|
+
if (!current) setState(next)
|
|
268
|
+
failCheck(next.error, 'Could not check for updates')
|
|
269
|
+
return
|
|
270
|
+
}
|
|
271
|
+
setState(next)
|
|
272
|
+
setCheckFailed(false)
|
|
273
|
+
setError('')
|
|
274
|
+
}
|
|
275
|
+
|
|
229
276
|
const check = async () => {
|
|
230
277
|
if (!desktop()) {
|
|
231
278
|
setError(local.desktopOnlyMessage ?? `Update checks are available from the desktop app.`)
|
|
@@ -241,13 +288,15 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
241
288
|
if (!isCurrent()) return
|
|
242
289
|
setBusy(true)
|
|
243
290
|
setError('')
|
|
291
|
+
setCheckFailed(false)
|
|
244
292
|
try {
|
|
245
293
|
const checked = await local.adapter.check()
|
|
246
|
-
if (isCurrent())
|
|
294
|
+
if (isCurrent()) applyCheckResult(checked)
|
|
247
295
|
} catch (caught) {
|
|
248
|
-
if (
|
|
249
|
-
|
|
250
|
-
|
|
296
|
+
if (isCurrent()) {
|
|
297
|
+
failCheck(caught, 'Could not check for updates')
|
|
298
|
+
await loadStatus(isCurrent)
|
|
299
|
+
}
|
|
251
300
|
} finally {
|
|
252
301
|
if (isCurrent()) setBusy(false)
|
|
253
302
|
}
|
|
@@ -279,6 +328,7 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
279
328
|
}
|
|
280
329
|
})
|
|
281
330
|
setError('')
|
|
331
|
+
setCheckFailed(false)
|
|
282
332
|
setBusy(true)
|
|
283
333
|
void (async () => {
|
|
284
334
|
try {
|
|
@@ -286,9 +336,9 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
286
336
|
if (!isCurrent()) return
|
|
287
337
|
setState(current)
|
|
288
338
|
const checked = await local.adapter.check()
|
|
289
|
-
if (isCurrent())
|
|
339
|
+
if (isCurrent()) applyCheckResult(checked)
|
|
290
340
|
} catch (caught) {
|
|
291
|
-
if (isCurrent())
|
|
341
|
+
if (isCurrent()) failCheck(caught, 'Could not check for updates')
|
|
292
342
|
} finally {
|
|
293
343
|
if (isCurrent()) setBusy(false)
|
|
294
344
|
}
|
|
@@ -315,6 +365,8 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
315
365
|
// Without this the click looked like nothing happened.
|
|
316
366
|
if (next.phase === 'failed') {
|
|
317
367
|
setError(errorMessage(next.error, 'Update installation failed'))
|
|
368
|
+
} else {
|
|
369
|
+
setCheckFailed(false)
|
|
318
370
|
}
|
|
319
371
|
} catch (caught) {
|
|
320
372
|
if (!isCurrent()) return
|
|
@@ -331,10 +383,12 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
331
383
|
return value ? plainTextFromMarkdown(value) : ''
|
|
332
384
|
}
|
|
333
385
|
const working = () => busy() || isBusy(state())
|
|
386
|
+
const isCurrent = () => state()?.phase === 'current' && !error() && !checkFailed() && !working()
|
|
334
387
|
|
|
335
388
|
const triggerLabel = () => {
|
|
336
389
|
const current = state()
|
|
337
390
|
const fallback = `v${local.fallbackVersion ?? '0.1.0'}`
|
|
391
|
+
if (checkFailed()) return `Version ${current?.currentVersion || fallback} · Retry`
|
|
338
392
|
if (!current) return `${appName()} ${fallback}`
|
|
339
393
|
switch (current.phase) {
|
|
340
394
|
case 'checking':
|
|
@@ -410,7 +464,7 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
410
464
|
</p>
|
|
411
465
|
<p class="text-sm text-muted-foreground">
|
|
412
466
|
<Show
|
|
413
|
-
when={
|
|
467
|
+
when={isCurrent()}
|
|
414
468
|
fallback={
|
|
415
469
|
<Show
|
|
416
470
|
when={state()?.phase === 'available' && state()?.availableVersion}
|
|
@@ -439,7 +493,7 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
439
493
|
<Show when={working()} fallback={<RefreshCw aria-hidden="true" />}>
|
|
440
494
|
<LoaderCircle class="animate-spin" aria-hidden="true" />
|
|
441
495
|
</Show>
|
|
442
|
-
Check latest version
|
|
496
|
+
{checkFailed() ? 'Retry update check' : 'Check latest version'}
|
|
443
497
|
</Button>
|
|
444
498
|
</div>
|
|
445
499
|
</section>
|
|
@@ -503,7 +557,7 @@ export function UpdateDialog(props: UpdateDialogProps) {
|
|
|
503
557
|
</section>
|
|
504
558
|
</Show>
|
|
505
559
|
|
|
506
|
-
<Show when={
|
|
560
|
+
<Show when={isCurrent()}>
|
|
507
561
|
<p class="text-foreground flex items-center gap-2 text-sm" role="status">
|
|
508
562
|
<Check class="size-4 text-success" aria-hidden="true" />
|
|
509
563
|
{appName()} is up to date.
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AlertDialog as KobalteAlertDialog,
|
|
3
|
+
Content as KobalteAlertDialogContent,
|
|
4
|
+
} from '@kobalte/core/alert-dialog'
|
|
5
|
+
// Use the alert-specific export rather than DialogRoot.Content, which other imports can replace.
|
|
2
6
|
import type { ComponentProps } from 'solid-js'
|
|
3
7
|
import { createEffect, createSignal, splitProps } from 'solid-js'
|
|
4
8
|
import { overlayMotion, overlayPositioner, overlayScrim, overlaySurface } from '../../../lib/overlay'
|
|
@@ -70,14 +74,14 @@ const blockDismissal = {
|
|
|
70
74
|
onInteractOutside: (event: Event) => event.preventDefault(),
|
|
71
75
|
} as const
|
|
72
76
|
|
|
73
|
-
export function AlertDialogContent(props: ComponentProps<typeof
|
|
77
|
+
export function AlertDialogContent(props: ComponentProps<typeof KobalteAlertDialogContent>) {
|
|
74
78
|
const [local, rest] = splitProps(props, ['class'])
|
|
75
79
|
|
|
76
80
|
return (
|
|
77
81
|
<KobalteAlertDialog.Portal>
|
|
78
82
|
<AlertDialogOverlay />
|
|
79
83
|
<div class={overlayPositioner}>
|
|
80
|
-
<
|
|
84
|
+
<KobalteAlertDialogContent
|
|
81
85
|
{...blockDismissal}
|
|
82
86
|
class={cn(overlaySurface, overlayMotion, 'grid w-full max-w-md gap-4 p-5', local.class)}
|
|
83
87
|
{...rest}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Dialog as KobalteDialog,
|
|
3
|
+
Content as KobalteDialogContent,
|
|
4
|
+
Overlay as KobalteDialogOverlay,
|
|
5
|
+
} from '@kobalte/core/dialog'
|
|
6
|
+
// AlertDialog assigns to the shared DialogRoot.Content object, so these named exports stay role-stable.
|
|
2
7
|
import { X } from 'lucide-solid'
|
|
3
8
|
import type { Accessor, ComponentProps, JSX } from 'solid-js'
|
|
4
9
|
import { createRenderEffect, onCleanup, Show, splitProps } from 'solid-js'
|
|
@@ -43,8 +48,8 @@ function hasOtherOverlay(content: HTMLElement, opener: HTMLElement): boolean {
|
|
|
43
48
|
type DialogFocusRestorationOptions = {
|
|
44
49
|
open: Accessor<boolean>
|
|
45
50
|
restoreFocusRef?: Accessor<HTMLElement | undefined>
|
|
46
|
-
onOpenAutoFocus?: ComponentProps<typeof
|
|
47
|
-
onCloseAutoFocus?: ComponentProps<typeof
|
|
51
|
+
onOpenAutoFocus?: ComponentProps<typeof KobalteDialogContent>['onOpenAutoFocus']
|
|
52
|
+
onCloseAutoFocus?: ComponentProps<typeof KobalteDialogContent>['onCloseAutoFocus']
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
/**
|
|
@@ -231,10 +236,10 @@ export function DialogPortal(props: ComponentProps<typeof KobalteDialog.Portal>)
|
|
|
231
236
|
return <KobalteDialog.Portal {...props} />
|
|
232
237
|
}
|
|
233
238
|
|
|
234
|
-
export function DialogOverlay(props: ComponentProps<typeof
|
|
239
|
+
export function DialogOverlay(props: ComponentProps<typeof KobalteDialogOverlay>) {
|
|
235
240
|
const [local, rest] = splitProps(props, ['class'])
|
|
236
241
|
return (
|
|
237
|
-
<
|
|
242
|
+
<KobalteDialogOverlay
|
|
238
243
|
class={cn(
|
|
239
244
|
overlayScrim,
|
|
240
245
|
'data-expanded:animate-in data-expanded:fade-in-0 data-closed:animate-out data-closed:fade-out-0',
|
|
@@ -245,7 +250,7 @@ export function DialogOverlay(props: ComponentProps<typeof KobalteDialog.Overlay
|
|
|
245
250
|
)
|
|
246
251
|
}
|
|
247
252
|
|
|
248
|
-
export type DialogContentProps = ComponentProps<typeof
|
|
253
|
+
export type DialogContentProps = ComponentProps<typeof KobalteDialogContent> & {
|
|
249
254
|
/**
|
|
250
255
|
* Replaces the default close button. Pass `false` to remove it — only for a
|
|
251
256
|
* dialog that cannot be dismissed (an update that must finish); anything the
|
|
@@ -261,7 +266,7 @@ export function DialogContent(props: DialogContentProps) {
|
|
|
261
266
|
<KobalteDialog.Portal>
|
|
262
267
|
<DialogOverlay />
|
|
263
268
|
<div class={overlayPositioner}>
|
|
264
|
-
<
|
|
269
|
+
<KobalteDialogContent
|
|
265
270
|
class={cn(
|
|
266
271
|
overlaySurface,
|
|
267
272
|
overlayMotion,
|
|
@@ -283,7 +288,7 @@ export function DialogContent(props: DialogContentProps) {
|
|
|
283
288
|
{local.closeButton ?? <X class="size-4" />}
|
|
284
289
|
</KobalteDialog.CloseButton>
|
|
285
290
|
</Show>
|
|
286
|
-
</
|
|
291
|
+
</KobalteDialogContent>
|
|
287
292
|
</div>
|
|
288
293
|
</KobalteDialog.Portal>
|
|
289
294
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Dialog as KobalteDialog } from '@kobalte/core/dialog'
|
|
1
|
+
import { Dialog as KobalteDialog, Content as KobalteDialogContent } from '@kobalte/core/dialog'
|
|
2
|
+
// AlertDialog shares DialogRoot.Content; Sheet uses the stable named primitive.
|
|
2
3
|
import { X } from 'lucide-solid'
|
|
3
4
|
import type { ComponentProps, JSX } from 'solid-js'
|
|
4
5
|
import { Show, splitProps } from 'solid-js'
|
|
@@ -35,7 +36,7 @@ const sheetVariants = cva(
|
|
|
35
36
|
}
|
|
36
37
|
)
|
|
37
38
|
|
|
38
|
-
export type SheetContentProps = ComponentProps<typeof
|
|
39
|
+
export type SheetContentProps = ComponentProps<typeof KobalteDialogContent> &
|
|
39
40
|
VariantProps<typeof sheetVariants> & {
|
|
40
41
|
closeButton?: JSX.Element | false
|
|
41
42
|
}
|
|
@@ -46,7 +47,7 @@ export function SheetContent(props: SheetContentProps) {
|
|
|
46
47
|
return (
|
|
47
48
|
<KobalteDialog.Portal>
|
|
48
49
|
<DialogOverlay />
|
|
49
|
-
<
|
|
50
|
+
<KobalteDialogContent
|
|
50
51
|
class={cn(
|
|
51
52
|
sheetVariants({ side: local.side }),
|
|
52
53
|
'data-expanded:animate-in data-expanded:fade-in-0 data-expanded:duration-200',
|
|
@@ -64,7 +65,7 @@ export function SheetContent(props: SheetContentProps) {
|
|
|
64
65
|
{local.closeButton ?? <X class="size-4" />}
|
|
65
66
|
</KobalteDialog.CloseButton>
|
|
66
67
|
</Show>
|
|
67
|
-
</
|
|
68
|
+
</KobalteDialogContent>
|
|
68
69
|
</KobalteDialog.Portal>
|
|
69
70
|
)
|
|
70
71
|
}
|
package/package.json
CHANGED