@tryghost/shade 0.1.0-alpha.49 → 0.1.0-alpha.50

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.
@@ -1,6 +1,7 @@
1
1
  import { cn } from "../../lib/ds-utils.js";
2
2
  import { ShadeScope } from "../../shade-scope.js";
3
3
  import { SAFE_AREA_DIALOG_HEIGHT, SAFE_AREA_DIALOG_X, overlayTint, useHostedModal, useModalOpen } from "../../lib/app-overlay.js";
4
+ import { keepOpenOnToast } from "../../lib/toast-press.js";
4
5
  import * as React$1 from "react";
5
6
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
7
  import * as DialogPrimitive from "@radix-ui/react-dialog";
@@ -32,6 +33,7 @@ var DialogContent = React$1.forwardRef(({ className, children, scroll = "fixed",
32
33
  ref: contentRef,
33
34
  className: cn(dialogPanelClassName, scroll === "overlay" ? scrollingDialogClassName : fixedDialogClassName, inApp && (scroll === "overlay" ? inAppScrollingDialogClassName : inAppFixedDialogClassName), className),
34
35
  ...props,
36
+ onInteractOutside: (event) => keepOpenOnToast(event, props.onInteractOutside),
35
37
  children
36
38
  }));
37
39
  const scrollingPanel = /* @__PURE__ */ jsx("div", {
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.js","names":[],"sources":["../../../src/components/ui/dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\n\nimport {\n overlayTint,\n SAFE_AREA_DIALOG_HEIGHT,\n SAFE_AREA_DIALOG_X,\n useHostedModal,\n useModalOpen,\n} from '@/lib/app-overlay';\nimport { cn } from '@/lib/utils';\nimport { ShadeScope } from '@/shade-scope';\n\nconst Dialog = (props: React.ComponentProps<typeof DialogPrimitive.Root>) => {\n const [rootProps, provideOpen] = useModalOpen(props);\n return provideOpen(<DialogPrimitive.Root {...rootProps} />);\n};\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = DialogPrimitive.Portal;\n\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-50 transform-gpu data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0',\n overlayTint('dialog'),\n className,\n )}\n data-slot=\"dialog-overlay\"\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst fixedDialogClassName = cn(\n 'fixed top-[max(8vmin,var(--ghost-safe-area-inset-top,0px))] left-[50%] sm:rounded-lg',\n SAFE_AREA_DIALOG_X,\n);\n\n// Moves up only as far as it must to stay between the safe area's top and bottom.\nconst inAppFixedDialogClassName = cn(\n SAFE_AREA_DIALOG_HEIGHT,\n 'translate-y-[clamp(var(--ghost-safe-area-inset-top,0px)_-_max(8vmin,var(--ghost-safe-area-inset-top,0px)),0px,100dvh_-_var(--ghost-safe-area-inset-bottom,0px)_-_1rem_-_max(8vmin,var(--ghost-safe-area-inset-top,0px))_-_100%)]',\n);\n\nconst scrollingDialogClassName = 'pointer-events-auto relative rounded-lg';\n\n// The dialog keeps as near the window's centre as the safe area allows. It measures against its\n// wrapper, a size container, so the wrapper's padding and the scrollbar are allowed for.\nconst inAppScrollerClassName =\n 'top-[var(--ghost-safe-area-inset-top,0px)] right-[var(--ghost-safe-area-inset-right,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] left-[var(--ghost-safe-area-inset-left,0px)]';\nconst inAppScrollingWrapperClassName =\n '@container pt-[max(0px,calc(8vmin_-_var(--ghost-safe-area-inset-top,0px)))] pb-[max(1rem,calc(8vmin_-_var(--ghost-safe-area-inset-bottom,0px)))]';\nconst inAppScrollingDialogClassName =\n 'translate-x-[clamp((100%_-_100cqw)/2,(var(--ghost-safe-area-inset-right,0px)_-_var(--ghost-safe-area-inset-left,0px))/2,(100cqw_-_100%)/2)]';\n\n// The panel itself, shared by both ways a dialog can sit on the page.\nconst dialogPanelClassName =\n 'z-50 grid w-full max-w-lg transform-gpu gap-6 bg-surface-elevated-2 p-6 shadow-lg [--sticky-footer-background:var(--surface-elevated-2)] outline-hidden duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95';\n\nexport interface DialogContentProps extends React.ComponentPropsWithoutRef<\n typeof DialogPrimitive.Content\n> {\n /**\n * How a dialog taller than the window scrolls. `fixed` (the default) pins the dialog near\n * the top of the window, so it needs its own height limit and inner scroll. `overlay` makes\n * the backdrop the scroll container instead: the whole dialog scrolls as one piece, the way\n * a page does.\n */\n scroll?: 'fixed' | 'overlay';\n}\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(({ className, children, scroll = 'fixed', ...props }, ref) => {\n const {\n container,\n inApp,\n modal,\n overlayStyle,\n ref: contentRef,\n wrap,\n } = useHostedModal('dialog', ref);\n\n // Wrapped outside the content, so an `asChild` content's element still gets Radix's props.\n const panel = wrap(\n <DialogPrimitive.Content\n ref={contentRef}\n className={cn(\n dialogPanelClassName,\n scroll === 'overlay' ? scrollingDialogClassName : fixedDialogClassName,\n inApp && (scroll === 'overlay' ? inAppScrollingDialogClassName : inAppFixedDialogClassName),\n className,\n )}\n {...props}\n >\n {children}\n </DialogPrimitive.Content>,\n );\n\n // The space around the dialog is padding on this wrapper, not on the scroll container:\n // browsers leave a scroll container's own bottom padding out of what it scrolls, which\n // would leave the dialog flush with the bottom of the window.\n const scrollingPanel = (\n <div\n className={cn(\n 'flex min-h-full items-start justify-center px-4 py-[8vmin]',\n inApp && inAppScrollingWrapperClassName,\n )}\n >\n {panel}\n </div>\n );\n const scroller = cn('overflow-y-auto', inApp && inAppScrollerClassName);\n\n return (\n <DialogPortal container={container}>\n <ShadeScope>\n {scroll === 'overlay' ? (\n modal ? (\n // The dialog sits inside the backdrop here, so the backdrop animates as long as the\n // dialog does; otherwise closing unmounts the dialog part-way through its animation.\n inApp ? (\n <DialogOverlay className=\"duration-200\" style={overlayStyle}>\n <div className={cn('fixed z-50', scroller)} data-slot=\"dialog-scroller\">\n {scrollingPanel}\n </div>\n </DialogOverlay>\n ) : (\n <DialogOverlay className={cn(scroller, 'duration-200')} style={overlayStyle}>\n {scrollingPanel}\n </DialogOverlay>\n )\n ) : (\n // Radix renders no backdrop for a non-modal dialog, and the page behind stays\n // usable, so this scroll container lets presses beside the dialog through.\n <div\n className={cn('pointer-events-none fixed inset-0 z-50', scroller)}\n data-slot=\"dialog-scroller\"\n >\n {scrollingPanel}\n </div>\n )\n ) : (\n <>\n <DialogOverlay style={overlayStyle} />\n {panel}\n </>\n )}\n </ShadeScope>\n </DialogPortal>\n );\n});\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn('flex flex-col gap-y-1.5 text-center sm:text-left', className)} {...props} />\n);\nDialogHeader.displayName = 'DialogHeader';\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n 'flex flex-col-reverse sm:flex-row sm:items-end sm:justify-end sm:gap-2',\n className,\n )}\n {...props}\n />\n);\nDialogFooter.displayName = 'DialogFooter';\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\n 'text-xl leading-none font-semibold tracking-tight in-data-[admin7-design=true]:font-title',\n className,\n )}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-muted-foreground', className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogTrigger,\n DialogClose,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n};\n"],"mappings":";;;;;;;AAaA,IAAM,UAAU,UAA6D;CAC3E,MAAM,CAAC,WAAW,eAAe,aAAa,KAAK;CACnD,OAAO,YAAY,oBAAC,gBAAgB,MAAjB,EAAsB,GAAI,UAAY,CAAA,CAAC;AAC5D;AAEA,IAAM,gBAAgB,gBAAgB;AAEtC,IAAM,eAAe,gBAAgB;AAErC,IAAM,cAAc,gBAAgB;AAEpC,IAAM,gBAAgB,QAAM,YAGzB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,SAAjB;CACO;CACL,WAAW,GACT,4JACA,YAAY,QAAQ,GACpB,SACF;CACA,aAAU;CACV,GAAI;AACL,CAAA,CACF;AACD,cAAc,cAAc,gBAAgB,QAAQ;AAEpD,IAAM,uBAAuB,GAC3B,wFACA,kBACF;AAGA,IAAM,4BAA4B,GAChC,yBACA,kOACF;AAEA,IAAM,2BAA2B;AAIjC,IAAM,yBACJ;AACF,IAAM,iCACJ;AACF,IAAM,gCACJ;AAGF,IAAM,uBACJ;AAcF,IAAM,gBAAgB,QAAM,YAGzB,EAAE,WAAW,UAAU,SAAS,SAAS,GAAG,SAAS,QAAQ;CAC9D,MAAM,EACJ,WACA,OACA,OACA,cACA,KAAK,YACL,SACE,eAAe,UAAU,GAAG;CAGhC,MAAM,QAAQ,KACZ,oBAAC,gBAAgB,SAAjB;EACE,KAAK;EACL,WAAW,GACT,sBACA,WAAW,YAAY,2BAA2B,sBAClD,UAAU,WAAW,YAAY,gCAAgC,4BACjE,SACF;EACA,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L,WAAW,GAAG,yBAAyB,SAAS;CAChD,GAAI;AACL,CAAA,CACF;AACD,kBAAkB,cAAc,gBAAgB,YAAY"}
1
+ {"version":3,"file":"dialog.js","names":[],"sources":["../../../src/components/ui/dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\n\nimport {\n overlayTint,\n SAFE_AREA_DIALOG_HEIGHT,\n SAFE_AREA_DIALOG_X,\n useHostedModal,\n useModalOpen,\n} from '@/lib/app-overlay';\nimport { cn } from '@/lib/utils';\nimport { keepOpenOnToast } from '@/lib/toast-press';\nimport { ShadeScope } from '@/shade-scope';\n\nconst Dialog = (props: React.ComponentProps<typeof DialogPrimitive.Root>) => {\n const [rootProps, provideOpen] = useModalOpen(props);\n return provideOpen(<DialogPrimitive.Root {...rootProps} />);\n};\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = DialogPrimitive.Portal;\n\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-50 transform-gpu data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0',\n overlayTint('dialog'),\n className,\n )}\n data-slot=\"dialog-overlay\"\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst fixedDialogClassName = cn(\n 'fixed top-[max(8vmin,var(--ghost-safe-area-inset-top,0px))] left-[50%] sm:rounded-lg',\n SAFE_AREA_DIALOG_X,\n);\n\n// Moves up only as far as it must to stay between the safe area's top and bottom.\nconst inAppFixedDialogClassName = cn(\n SAFE_AREA_DIALOG_HEIGHT,\n 'translate-y-[clamp(var(--ghost-safe-area-inset-top,0px)_-_max(8vmin,var(--ghost-safe-area-inset-top,0px)),0px,100dvh_-_var(--ghost-safe-area-inset-bottom,0px)_-_1rem_-_max(8vmin,var(--ghost-safe-area-inset-top,0px))_-_100%)]',\n);\n\nconst scrollingDialogClassName = 'pointer-events-auto relative rounded-lg';\n\n// The dialog keeps as near the window's centre as the safe area allows. It measures against its\n// wrapper, a size container, so the wrapper's padding and the scrollbar are allowed for.\nconst inAppScrollerClassName =\n 'top-[var(--ghost-safe-area-inset-top,0px)] right-[var(--ghost-safe-area-inset-right,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] left-[var(--ghost-safe-area-inset-left,0px)]';\nconst inAppScrollingWrapperClassName =\n '@container pt-[max(0px,calc(8vmin_-_var(--ghost-safe-area-inset-top,0px)))] pb-[max(1rem,calc(8vmin_-_var(--ghost-safe-area-inset-bottom,0px)))]';\nconst inAppScrollingDialogClassName =\n 'translate-x-[clamp((100%_-_100cqw)/2,(var(--ghost-safe-area-inset-right,0px)_-_var(--ghost-safe-area-inset-left,0px))/2,(100cqw_-_100%)/2)]';\n\n// The panel itself, shared by both ways a dialog can sit on the page.\nconst dialogPanelClassName =\n 'z-50 grid w-full max-w-lg transform-gpu gap-6 bg-surface-elevated-2 p-6 shadow-lg [--sticky-footer-background:var(--surface-elevated-2)] outline-hidden duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95';\n\nexport interface DialogContentProps extends React.ComponentPropsWithoutRef<\n typeof DialogPrimitive.Content\n> {\n /**\n * How a dialog taller than the window scrolls. `fixed` (the default) pins the dialog near\n * the top of the window, so it needs its own height limit and inner scroll. `overlay` makes\n * the backdrop the scroll container instead: the whole dialog scrolls as one piece, the way\n * a page does.\n */\n scroll?: 'fixed' | 'overlay';\n}\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(({ className, children, scroll = 'fixed', ...props }, ref) => {\n const {\n container,\n inApp,\n modal,\n overlayStyle,\n ref: contentRef,\n wrap,\n } = useHostedModal('dialog', ref);\n\n // Wrapped outside the content, so an `asChild` content's element still gets Radix's props.\n const panel = wrap(\n <DialogPrimitive.Content\n ref={contentRef}\n className={cn(\n dialogPanelClassName,\n scroll === 'overlay' ? scrollingDialogClassName : fixedDialogClassName,\n inApp && (scroll === 'overlay' ? inAppScrollingDialogClassName : inAppFixedDialogClassName),\n className,\n )}\n {...props}\n onInteractOutside={(event) => keepOpenOnToast(event, props.onInteractOutside)}\n >\n {children}\n </DialogPrimitive.Content>,\n );\n\n // The space around the dialog is padding on this wrapper, not on the scroll container:\n // browsers leave a scroll container's own bottom padding out of what it scrolls, which\n // would leave the dialog flush with the bottom of the window.\n const scrollingPanel = (\n <div\n className={cn(\n 'flex min-h-full items-start justify-center px-4 py-[8vmin]',\n inApp && inAppScrollingWrapperClassName,\n )}\n >\n {panel}\n </div>\n );\n const scroller = cn('overflow-y-auto', inApp && inAppScrollerClassName);\n\n return (\n <DialogPortal container={container}>\n <ShadeScope>\n {scroll === 'overlay' ? (\n modal ? (\n // The dialog sits inside the backdrop here, so the backdrop animates as long as the\n // dialog does; otherwise closing unmounts the dialog part-way through its animation.\n inApp ? (\n <DialogOverlay className=\"duration-200\" style={overlayStyle}>\n <div className={cn('fixed z-50', scroller)} data-slot=\"dialog-scroller\">\n {scrollingPanel}\n </div>\n </DialogOverlay>\n ) : (\n <DialogOverlay className={cn(scroller, 'duration-200')} style={overlayStyle}>\n {scrollingPanel}\n </DialogOverlay>\n )\n ) : (\n // Radix renders no backdrop for a non-modal dialog, and the page behind stays\n // usable, so this scroll container lets presses beside the dialog through.\n <div\n className={cn('pointer-events-none fixed inset-0 z-50', scroller)}\n data-slot=\"dialog-scroller\"\n >\n {scrollingPanel}\n </div>\n )\n ) : (\n <>\n <DialogOverlay style={overlayStyle} />\n {panel}\n </>\n )}\n </ShadeScope>\n </DialogPortal>\n );\n});\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn('flex flex-col gap-y-1.5 text-center sm:text-left', className)} {...props} />\n);\nDialogHeader.displayName = 'DialogHeader';\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n 'flex flex-col-reverse sm:flex-row sm:items-end sm:justify-end sm:gap-2',\n className,\n )}\n {...props}\n />\n);\nDialogFooter.displayName = 'DialogFooter';\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\n 'text-xl leading-none font-semibold tracking-tight in-data-[admin7-design=true]:font-title',\n className,\n )}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-muted-foreground', className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogTrigger,\n DialogClose,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n};\n"],"mappings":";;;;;;;;AAcA,IAAM,UAAU,UAA6D;CAC3E,MAAM,CAAC,WAAW,eAAe,aAAa,KAAK;CACnD,OAAO,YAAY,oBAAC,gBAAgB,MAAjB,EAAsB,GAAI,UAAY,CAAA,CAAC;AAC5D;AAEA,IAAM,gBAAgB,gBAAgB;AAEtC,IAAM,eAAe,gBAAgB;AAErC,IAAM,cAAc,gBAAgB;AAEpC,IAAM,gBAAgB,QAAM,YAGzB,EAAE,WAAW,GAAG,SAAS,QAC1B,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EAAA,UAAA,CACE,oBAAC,eAAD,EAAe,OAAO,aAAe,CAAA,GACpC,KACD,EAAA,CAAA,EAEM,CAAA;CACA,CAAA;AAElB,CAAC;AACD,cAAc,cAAc,gBAAgB,QAAQ;AAEpD,IAAM,gBAAgB,EAAE,WAAW,GAAG,YACpC,oBAAC,OAAD;CAAK,WAAW,GAAG,oDAAoD,SAAS;CAAG,GAAI;AAAQ,CAAA;AAEjG,aAAa,cAAc;AAE3B,IAAM,gBAAgB,EAAE,WAAW,GAAG,YACpC,oBAAC,OAAD;CACE,WAAW,GACT,0EACA,SACF;CACA,GAAI;AACL,CAAA;AAEH,aAAa,cAAc;AAE3B,IAAM,cAAc,QAAM,YAGvB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,OAAjB;CACO;CACL,WAAW,GACT,6FACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,YAAY,cAAc,gBAAgB,MAAM;AAEhD,IAAM,oBAAoB,QAAM,YAG7B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,aAAjB;CACO;CACL,WAAW,GAAG,yBAAyB,SAAS;CAChD,GAAI;AACL,CAAA,CACF;AACD,kBAAkB,cAAc,gBAAgB,YAAY"}
@@ -2,6 +2,7 @@
2
2
  import { cn } from "../../lib/ds-utils.js";
3
3
  import { ShadeScope } from "../../shade-scope.js";
4
4
  import { overlayTint, useHostedModal, useModalOpen } from "../../lib/app-overlay.js";
5
+ import { keepOpenOnToast } from "../../lib/toast-press.js";
5
6
  import { X } from "lucide-react";
6
7
  import * as React$1 from "react";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -38,6 +39,7 @@ var SheetContent = React$1.forwardRef(({ side = "right", className, children, ..
38
39
  ref: contentRef,
39
40
  className: cn(sheetVariants({ side }), inApp && "overflow-y-auto", inApp && (side === "top" || side === "bottom") && "max-h-[calc(100dvh_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))]", inApp && (side === "left" || side === "right") && "w-[min(75%,calc(100vw_-_var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px)))]", className),
40
41
  ...props,
42
+ onInteractOutside: (event) => keepOpenOnToast(event, props.onInteractOutside),
41
43
  children: [/* @__PURE__ */ jsxs(SheetPrimitive.Close, {
42
44
  className: cn("top-4 right-4 z-50 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 disabled:pointer-events-none data-[state=open]:bg-secondary", inApp || side === "bottom" ? "absolute" : "fixed"),
43
45
  onFocus: inApp ? (event) => event.currentTarget.scrollIntoView({ block: "nearest" }) : void 0,
@@ -1 +1 @@
1
- {"version":3,"file":"sheet.js","names":[],"sources":["../../../src/components/ui/sheet.tsx"],"sourcesContent":["'use client';\n\n// Disable sourcemap for this file due to source map resolution errors\nimport * as React from 'react';\nimport * as SheetPrimitive from '@radix-ui/react-dialog';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { X } from 'lucide-react';\n\nimport { overlayTint, useHostedModal, useModalOpen } from '@/lib/app-overlay';\nimport { cn } from '@/lib/utils';\nimport { ShadeScope } from '@/shade-scope';\n\nconst Sheet = (props: React.ComponentProps<typeof SheetPrimitive.Root>) => {\n const [rootProps, provideOpen] = useModalOpen(props);\n return provideOpen(<SheetPrimitive.Root {...rootProps} />);\n};\n\nconst SheetTrigger = SheetPrimitive.Trigger;\n\nconst SheetClose = SheetPrimitive.Close;\n\nconst SheetPortal = SheetPrimitive.Portal;\n\nconst SheetOverlay = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Overlay\n className={cn(\n 'fixed inset-0 z-50 duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0',\n overlayTint('sheet'),\n className,\n )}\n {...props}\n ref={ref}\n />\n));\nSheetOverlay.displayName = SheetPrimitive.Overlay.displayName;\n\n// A side sheet sets a height as well as its top and bottom, so a caller's `top-*`, `bottom-*`\n// or `h-*` still works.\nconst sheetVariants = cva(\n 'fixed z-50 gap-4 bg-surface-elevated p-8 shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:animate-in data-[state=open]:duration-500',\n {\n variants: {\n side: {\n top: 'top-[var(--ghost-safe-area-inset-top,0px)] right-[var(--ghost-safe-area-inset-right,0px)] left-[var(--ghost-safe-area-inset-left,0px)] border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',\n bottom:\n 'right-[var(--ghost-safe-area-inset-right,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] left-[var(--ghost-safe-area-inset-left,0px)] border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',\n left: 'top-[var(--ghost-safe-area-inset-top,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] left-[var(--ghost-safe-area-inset-left,0px)] h-[calc(100%_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))] w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',\n right:\n 'top-[var(--ghost-safe-area-inset-top,0px)] right-[var(--ghost-safe-area-inset-right,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] h-[calc(100%_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))] w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',\n },\n },\n defaultVariants: {\n side: 'right',\n },\n },\n);\n\ninterface SheetContentProps\n extends\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,\n VariantProps<typeof sheetVariants> {}\n\nconst SheetContent = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Content>,\n SheetContentProps\n>(({ side = 'right', className, children, ...props }, ref) => {\n const { container, inApp, overlayStyle, ref: contentRef, wrap } = useHostedModal('sheet', ref);\n return (\n <SheetPortal container={container}>\n <ShadeScope>\n <SheetOverlay style={overlayStyle} />\n {wrap(\n <SheetPrimitive.Content\n ref={contentRef}\n className={cn(\n sheetVariants({ side }),\n inApp && 'overflow-y-auto',\n inApp &&\n (side === 'top' || side === 'bottom') &&\n 'max-h-[calc(100dvh_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))]',\n // On the width, not max-width, so a caller's `max-w-*` only narrows it.\n inApp &&\n (side === 'left' || side === 'right') &&\n 'w-[min(75%,calc(100vw_-_var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px)))]',\n className,\n )}\n {...props}\n >\n <SheetPrimitive.Close\n className={cn(\n 'top-4 right-4 z-50 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 disabled:pointer-events-none data-[state=open]:bg-secondary',\n // In an app, the window's corner is under Admin's chrome, so use the sheet's.\n inApp || side === 'bottom' ? 'absolute' : 'fixed',\n )}\n // Radix's focus loop focuses this without scrolling, which can leave it out of sight\n // in a scrolled sheet.\n onFocus={\n inApp\n ? (event) => event.currentTarget.scrollIntoView({ block: 'nearest' })\n : undefined\n }\n >\n <X className=\"size-4\" />\n <span className=\"sr-only\">Close</span>\n </SheetPrimitive.Close>\n {children}\n </SheetPrimitive.Content>,\n )}\n </ShadeScope>\n </SheetPortal>\n );\n});\nSheetContent.displayName = SheetPrimitive.Content.displayName;\n\nconst SheetHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn('flex flex-col space-y-1 text-center sm:text-left', className)} {...props} />\n);\nSheetHeader.displayName = 'SheetHeader';\n\nconst SheetFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-2', className)}\n {...props}\n />\n);\nSheetFooter.displayName = 'SheetFooter';\n\nconst SheetTitle = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Title\n ref={ref}\n className={cn(\n 'text-xl font-semibold text-foreground in-data-[admin7-design=true]:font-title',\n className,\n )}\n {...props}\n />\n));\nSheetTitle.displayName = SheetPrimitive.Title.displayName;\n\nconst SheetDescription = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Description\n ref={ref}\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n));\nSheetDescription.displayName = SheetPrimitive.Description.displayName;\n\nexport {\n Sheet,\n SheetPortal,\n SheetOverlay,\n SheetTrigger,\n SheetClose,\n SheetContent,\n SheetHeader,\n SheetFooter,\n SheetTitle,\n SheetDescription,\n};\n"],"mappings":";;;;;;;;;;AAYA,IAAM,SAAS,UAA4D;CACzE,MAAM,CAAC,WAAW,eAAe,aAAa,KAAK;CACnD,OAAO,YAAY,oBAAC,eAAe,MAAhB,EAAqB,GAAI,UAAY,CAAA,CAAC;AAC3D;AAEA,IAAM,eAAe,eAAe;AAEpC,IAAM,aAAa,eAAe;AAElC,IAAM,cAAc,eAAe;AAEnC,IAAM,eAAe,QAAM,YAGxB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,eAAe,SAAhB;CACE,WAAW,GACT,2JACA,YAAY,OAAO,GACnB,SACF;CACA,GAAI;CACC;AACN,CAAA,CACF;AACD,aAAa,cAAc,eAAe,QAAQ;AAIlD,IAAM,gBAAgB,IACpB,0MACA;CACE,UAAU,EACR,MAAM;EACJ,KAAK;EACL,QACE;EACF,MAAM;EACN,OACE;CACJ,EACF;CACA,iBAAiB,EACf,MAAM,QACR;AACF,CACF;AAOA,IAAM,eAAe,QAAM,YAGxB,EAAE,OAAO,SAAS,WAAW,UAAU,GAAG,SAAS,QAAQ;CAC5D,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AAhB;CACO;CACL,WAAW,GAAG,iCAAiC,SAAS;CACxD,GAAI;AACL,CAAA,CACF;AACD,iBAAiB,cAAc,eAAe,YAAY"}
1
+ {"version":3,"file":"sheet.js","names":[],"sources":["../../../src/components/ui/sheet.tsx"],"sourcesContent":["'use client';\n\n// Disable sourcemap for this file due to source map resolution errors\nimport * as React from 'react';\nimport * as SheetPrimitive from '@radix-ui/react-dialog';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { X } from 'lucide-react';\n\nimport { overlayTint, useHostedModal, useModalOpen } from '@/lib/app-overlay';\nimport { cn } from '@/lib/utils';\nimport { keepOpenOnToast } from '@/lib/toast-press';\nimport { ShadeScope } from '@/shade-scope';\n\nconst Sheet = (props: React.ComponentProps<typeof SheetPrimitive.Root>) => {\n const [rootProps, provideOpen] = useModalOpen(props);\n return provideOpen(<SheetPrimitive.Root {...rootProps} />);\n};\n\nconst SheetTrigger = SheetPrimitive.Trigger;\n\nconst SheetClose = SheetPrimitive.Close;\n\nconst SheetPortal = SheetPrimitive.Portal;\n\nconst SheetOverlay = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Overlay\n className={cn(\n 'fixed inset-0 z-50 duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0',\n overlayTint('sheet'),\n className,\n )}\n {...props}\n ref={ref}\n />\n));\nSheetOverlay.displayName = SheetPrimitive.Overlay.displayName;\n\n// A side sheet sets a height as well as its top and bottom, so a caller's `top-*`, `bottom-*`\n// or `h-*` still works.\nconst sheetVariants = cva(\n 'fixed z-50 gap-4 bg-surface-elevated p-8 shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:animate-in data-[state=open]:duration-500',\n {\n variants: {\n side: {\n top: 'top-[var(--ghost-safe-area-inset-top,0px)] right-[var(--ghost-safe-area-inset-right,0px)] left-[var(--ghost-safe-area-inset-left,0px)] border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',\n bottom:\n 'right-[var(--ghost-safe-area-inset-right,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] left-[var(--ghost-safe-area-inset-left,0px)] border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',\n left: 'top-[var(--ghost-safe-area-inset-top,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] left-[var(--ghost-safe-area-inset-left,0px)] h-[calc(100%_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))] w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',\n right:\n 'top-[var(--ghost-safe-area-inset-top,0px)] right-[var(--ghost-safe-area-inset-right,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] h-[calc(100%_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))] w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',\n },\n },\n defaultVariants: {\n side: 'right',\n },\n },\n);\n\ninterface SheetContentProps\n extends\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,\n VariantProps<typeof sheetVariants> {}\n\nconst SheetContent = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Content>,\n SheetContentProps\n>(({ side = 'right', className, children, ...props }, ref) => {\n const { container, inApp, overlayStyle, ref: contentRef, wrap } = useHostedModal('sheet', ref);\n return (\n <SheetPortal container={container}>\n <ShadeScope>\n <SheetOverlay style={overlayStyle} />\n {wrap(\n <SheetPrimitive.Content\n ref={contentRef}\n className={cn(\n sheetVariants({ side }),\n inApp && 'overflow-y-auto',\n inApp &&\n (side === 'top' || side === 'bottom') &&\n 'max-h-[calc(100dvh_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))]',\n // On the width, not max-width, so a caller's `max-w-*` only narrows it.\n inApp &&\n (side === 'left' || side === 'right') &&\n 'w-[min(75%,calc(100vw_-_var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px)))]',\n className,\n )}\n {...props}\n onInteractOutside={(event) => keepOpenOnToast(event, props.onInteractOutside)}\n >\n <SheetPrimitive.Close\n className={cn(\n 'top-4 right-4 z-50 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 disabled:pointer-events-none data-[state=open]:bg-secondary',\n // In an app, the window's corner is under Admin's chrome, so use the sheet's.\n inApp || side === 'bottom' ? 'absolute' : 'fixed',\n )}\n // Radix's focus loop focuses this without scrolling, which can leave it out of sight\n // in a scrolled sheet.\n onFocus={\n inApp\n ? (event) => event.currentTarget.scrollIntoView({ block: 'nearest' })\n : undefined\n }\n >\n <X className=\"size-4\" />\n <span className=\"sr-only\">Close</span>\n </SheetPrimitive.Close>\n {children}\n </SheetPrimitive.Content>,\n )}\n </ShadeScope>\n </SheetPortal>\n );\n});\nSheetContent.displayName = SheetPrimitive.Content.displayName;\n\nconst SheetHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn('flex flex-col space-y-1 text-center sm:text-left', className)} {...props} />\n);\nSheetHeader.displayName = 'SheetHeader';\n\nconst SheetFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-2', className)}\n {...props}\n />\n);\nSheetFooter.displayName = 'SheetFooter';\n\nconst SheetTitle = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Title\n ref={ref}\n className={cn(\n 'text-xl font-semibold text-foreground in-data-[admin7-design=true]:font-title',\n className,\n )}\n {...props}\n />\n));\nSheetTitle.displayName = SheetPrimitive.Title.displayName;\n\nconst SheetDescription = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Description\n ref={ref}\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n));\nSheetDescription.displayName = SheetPrimitive.Description.displayName;\n\nexport {\n Sheet,\n SheetPortal,\n SheetOverlay,\n SheetTrigger,\n SheetClose,\n SheetContent,\n SheetHeader,\n SheetFooter,\n SheetTitle,\n SheetDescription,\n};\n"],"mappings":";;;;;;;;;;;AAaA,IAAM,SAAS,UAA4D;CACzE,MAAM,CAAC,WAAW,eAAe,aAAa,KAAK;CACnD,OAAO,YAAY,oBAAC,eAAe,MAAhB,EAAqB,GAAI,UAAY,CAAA,CAAC;AAC3D;AAEA,IAAM,eAAe,eAAe;AAEpC,IAAM,aAAa,eAAe;AAElC,IAAM,cAAc,eAAe;AAEnC,IAAM,eAAe,QAAM,YAGxB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,eAAe,SAAhB;CACE,WAAW,GACT,2JACA,YAAY,OAAO,GACnB,SACF;CACA,GAAI;CACC;AACN,CAAA,CACF;AACD,aAAa,cAAc,eAAe,QAAQ;AAIlD,IAAM,gBAAgB,IACpB,0MACA;CACE,UAAU,EACR,MAAM;EACJ,KAAK;EACL,QACE;EACF,MAAM;EACN,OACE;CACJ,EACF;CACA,iBAAiB,EACf,MAAM,QACR;AACF,CACF;AAOA,IAAM,eAAe,QAAM,YAGxB,EAAE,OAAO,SAAS,WAAW,UAAU,GAAG,SAAS,QAAQ;CAC5D,MAAM,EAAE,WAAW,OAAO,cAAc,KAAK,YAAY,SAAS,eAAe,SAAS,GAAG;CAC7F,OACE,oBAAC,aAAD;EAAwB;YACtB,qBAAC,YAAD,EAAA,UAAA,CACE,oBAAC,cAAD,EAAc,OAAO,aAAe,CAAA,GACnC,KACC,qBAAC,eAAe,SAAhB;GACE,KAAK;GACL,WAAW,GACT,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G_X = "w-[calc(100%_-_var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px))] translate-x-[calc(-50%_+_clamp(min(var(--ghost-safe-area-inset-left,0px)_-_50vw_+_50%,(var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px))/2),0px,max(50vw_-_var(--ghost-safe-area-inset-right,0px)_-_50%,(var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px))/2)))]";
16
16
  var SAFE_AREA_DIALOG_HEIGHT = "max-h-[calc(100dvh_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px)_-_1rem)] overflow-y-auto";
17
17
  var AppOverlayContext = React$1.createContext(void 0);
18
+ /**
19
+ * Tracks the dialogs open in the overlay so toasts can show above them. Returns the overlay to
20
+ * give the dialogs, and the toasts' container: the overlay's while a dialog is open there.
21
+ */
22
+ function useOverlayToasts(overlay) {
23
+ const [container, setContainer] = React$1.useState();
24
+ return [React$1.useMemo(() => {
25
+ if (!overlay) return;
26
+ const open = /* @__PURE__ */ new Map();
27
+ const update = () => setContainer([...open.values()].at(-1));
28
+ return {
29
+ container: () => overlay.container(),
30
+ hold(tint, element) {
31
+ const key = {};
32
+ const hold = overlay.hold(tint, element);
33
+ return {
34
+ setOpen(next) {
35
+ hold.setOpen(next);
36
+ open.delete(key);
37
+ const root = next ? overlay.container() : void 0;
38
+ if (root?.contains(element)) open.set(key, root);
39
+ update();
40
+ },
41
+ release() {
42
+ open.delete(key);
43
+ update();
44
+ hold.release();
45
+ }
46
+ };
47
+ }
48
+ };
49
+ }, [overlay]), overlay ? container : void 0];
50
+ }
18
51
  /** Content portalled from a hosted dialog renders in the overlay too, above the dialog. */
19
52
  var PortalContainerContext = React$1.createContext(void 0);
20
53
  var ModalStateContext = React$1.createContext(void 0);
@@ -146,6 +179,6 @@ function useHostedModal(tint, forwardedRef) {
146
179
  };
147
180
  }
148
181
  //#endregion
149
- export { AppOverlayContext, SAFE_AREA_DIALOG_HEIGHT, SAFE_AREA_DIALOG_X, overlayTint, useHostedModal, useModalOpen, usePortalContainer };
182
+ export { AppOverlayContext, SAFE_AREA_DIALOG_HEIGHT, SAFE_AREA_DIALOG_X, overlayTint, useHostedModal, useModalOpen, useOverlayToasts, usePortalContainer };
150
183
 
151
184
  //# sourceMappingURL=app-overlay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-overlay.js","names":[],"sources":["../../src/lib/app-overlay.tsx"],"sourcesContent":["import * as React from 'react';\nimport { hasSafeArea } from '@/lib/safe-area';\n\nexport type AppOverlayTint = 'dialog' | 'sheet';\n\nconst OVERLAY_TINTS: Record<AppOverlayTint, string> = {\n dialog: 'bg-black/30 dark:bg-black/60',\n sheet: 'bg-black/10',\n};\n\n/** A modal's tint classes. Admin draws the same tint behind an app's dialogs and sheets. */\nexport const overlayTint = (tint: AppOverlayTint) => OVERLAY_TINTS[tint];\n\n/**\n * Centres a dialog on the window, moved only as far as it must to stay inside the safe area.\n * One wider than the safe area is centred on it instead.\n */\nexport const SAFE_AREA_DIALOG_X =\n 'w-[calc(100%_-_var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px))] translate-x-[calc(-50%_+_clamp(min(var(--ghost-safe-area-inset-left,0px)_-_50vw_+_50%,(var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px))/2),0px,max(50vw_-_var(--ghost-safe-area-inset-right,0px)_-_50%,(var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px))/2)))]';\n\nexport const SAFE_AREA_DIALOG_HEIGHT =\n 'max-h-[calc(100dvh_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px)_-_1rem)] overflow-y-auto';\n\n/** A dialog or sheet's hold on the overlay, from when it mounts until it unmounts. */\nexport interface AppOverlayHold {\n /** True once the dialog opens, false as soon as it starts to close. */\n setOpen(open: boolean): void;\n /** Called after the dialog's closing animation, once it has unmounted. */\n release(): void;\n}\n\n/**\n * Where an app's dialogs and sheets render, so they cover all of Admin rather than only the\n * app's frame. Pass the app SDK's `ghost.overlay` to `ShadeApp` as `overlay`.\n */\nexport interface AppOverlay {\n /** The element to render into, or undefined to render in the page. */\n container(): HTMLElement | undefined;\n /** Called with the dialog's content element as it mounts. */\n hold(tint: AppOverlayTint, element: HTMLElement): AppOverlayHold;\n}\n\nexport const AppOverlayContext = React.createContext<AppOverlay | undefined>(undefined);\n\n/** Content portalled from a hosted dialog renders in the overlay too, above the dialog. */\nconst PortalContainerContext = React.createContext<HTMLElement | undefined>(undefined);\n\nconst ModalStateContext = React.createContext<{ open: boolean; modal: boolean } | undefined>(\n undefined,\n);\n\ninterface OpenProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n modal?: boolean;\n}\n\n/**\n * Wraps a Radix dialog `Root`'s props so its content re-renders when it opens, even from its own\n * trigger, and can then decide whether to render in the overlay. Radix re-renders only its\n * portal, and doesn't expose `modal` to the content.\n */\nexport function useModalOpen<P extends OpenProps>(\n props: P,\n): [P, (children: React.ReactNode) => React.ReactNode] {\n const { open, defaultOpen, onOpenChange, modal = true } = props;\n const [uncontrolled, setUncontrolled] = React.useState(defaultOpen ?? false);\n const isOpen = open ?? uncontrolled;\n const handleOpenChange = React.useCallback(\n (next: boolean) => {\n setUncontrolled(next);\n onOpenChange?.(next);\n },\n [onOpenChange],\n );\n const state = React.useMemo(() => ({ open: isOpen, modal }), [isOpen, modal]);\n const provide = React.useCallback(\n (children: React.ReactNode) => (\n <ModalStateContext.Provider value={state}>{children}</ModalStateContext.Provider>\n ),\n [state],\n );\n return [{ ...props, onOpenChange: handleOpenChange }, provide];\n}\n\n/** The container for a Radix `Portal`: the overlay inside a hosted dialog, else the default. */\nexport const usePortalContainer = () => React.useContext(PortalContainerContext);\n\nfunction setRef<T>(ref: React.Ref<T> | undefined, value: T | null) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n}\n\n/**\n * Transparent so Admin's tint shows through, but still there so a press beside the dialog closes\n * it. A style rather than a class, to override the overlay's colour in either theme.\n */\nconst HOSTED_OVERLAY_STYLE: React.CSSProperties = { background: 'transparent' };\n\ninterface Placement {\n open: boolean | undefined;\n container: HTMLElement | undefined;\n}\n\ninterface HostedModal<T extends HTMLElement> {\n /** The overlay when the dialog renders there, or a non-modal one opens from a dialog there. */\n container: HTMLElement | undefined;\n inApp: boolean;\n modal: boolean;\n overlayStyle: React.CSSProperties | undefined;\n ref: React.RefCallback<T>;\n wrap: (children: React.ReactNode) => React.ReactNode;\n}\n\n/**\n * Renders a dialog, alert dialog or sheet in the app's overlay when there is one, holding the\n * overlay while its content is mounted.\n */\nexport function useHostedModal<T extends HTMLElement>(\n tint: AppOverlayTint,\n forwardedRef: React.Ref<T>,\n): HostedModal<T> {\n const overlay = React.useContext(AppOverlayContext);\n const inherited = usePortalContainer();\n const state = React.useContext(ModalStateContext);\n const open = state?.open;\n const modal = state?.modal ?? true;\n // Decided as the dialog opens and kept while it closes: moving it would remount the content.\n // Outside Shade's dialog roots `open` is undefined, so it decides on each render.\n const place = () => (modal ? overlay?.container() : undefined);\n const [placed, setPlaced] = React.useState<Placement>(() => ({\n open,\n container: open === false ? undefined : place(),\n }));\n let placement = placed;\n if (open === undefined) {\n placement = { ...placed, container: place() };\n } else if (open !== placed.open) {\n placement = open && !placed.open ? { open, container: place() } : { ...placed, open };\n setPlaced(placement);\n }\n const { container } = placement;\n const hosted = modal && container !== undefined;\n\n // The ref must stay stable: a new one makes React reattach the content, releasing the hold.\n // The insertion effect stores this render's decision before React attaches the content.\n const latest = React.useRef({ overlay, hosted, tint });\n React.useInsertionEffect(() => {\n latest.current = { overlay, hosted, tint };\n });\n // Hands the element over when the caller's ref changes, as React would.\n const content = React.useRef<T | null>(null);\n const attached = React.useRef(forwardedRef);\n React.useLayoutEffect(() => {\n if (attached.current !== forwardedRef) {\n if (content.current) {\n setRef(attached.current, null);\n setRef(forwardedRef, content.current);\n }\n attached.current = forwardedRef;\n }\n }, [forwardedRef]);\n const cleanup = React.useRef<() => void>(undefined);\n const ref = React.useCallback((element: T | null) => {\n const current = latest.current;\n content.current = element;\n setRef(attached.current, element);\n cleanup.current?.();\n cleanup.current = undefined;\n if (!element || !current.overlay || !current.hosted) {\n return;\n }\n const hold = current.overlay.hold(current.tint, element);\n const sync = () => hold.setOpen(element.getAttribute('data-state') === 'open');\n sync();\n // The element lives in the overlay's document, so use that window's constructor.\n const Observer = element.ownerDocument.defaultView?.MutationObserver ?? MutationObserver;\n const observer = new Observer(sync);\n observer.observe(element, { attributes: true, attributeFilter: ['data-state'] });\n cleanup.current = () => {\n observer.disconnect();\n hold.release();\n };\n }, []);\n\n const wrap = React.useCallback(\n (children: React.ReactNode) =>\n hosted ? (\n <PortalContainerContext.Provider value={container}>\n {children}\n </PortalContainerContext.Provider>\n ) : (\n children\n ),\n [hosted, container],\n );\n\n const portal = modal ? container : inherited;\n return {\n container: portal,\n inApp: hasSafeArea(portal),\n modal,\n overlayStyle: hosted ? HOSTED_OVERLAY_STYLE : undefined,\n ref,\n wrap,\n };\n}\n"],"mappings":";;;;AAKA,IAAM,gBAAgD;CACpD,QAAQ;CACR,OAAO;AACT;;AAGA,IAAa,eAAe,SAAyB,cAAc;;;;;AAMnE,IAAa,qBACX;AAEF,IAAa,0BACX;AAqBF,IAAa,oBAAoB,QAAM,cAAsC,KAAA,CAAS;;AAGtF,IAAM,yBAAyB,QAAM,cAAuC,KAAA,CAAS;AAErF,IAAM,oBAAoB,QAAM,cAC9B,KAAA,CACF;;;;;;AAcA,SAAgB,aACd,OACqD;CACrD,MAAM,EAAE,MAAM,aAAa,cAAc,QAAQ,SAAS;CAC1D,MAAM,CAAC,cAAc,mBAAmB,QAAM,SAAS,eAAe,KAAK;CAC3E,MAAM,SAAS,QAAQ;CACvB,MAAM,mBAAmB,QAAM,aAC5B,SAAkB;EACjB,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AAA;EAC9C;EACA;CACF;AACF"}
1
+ {"version":3,"file":"app-overlay.js","names":[],"sources":["../../src/lib/app-overlay.tsx"],"sourcesContent":["import * as React from 'react';\nimport { hasSafeArea } from '@/lib/safe-area';\n\nexport type AppOverlayTint = 'dialog' | 'sheet';\n\nconst OVERLAY_TINTS: Record<AppOverlayTint, string> = {\n dialog: 'bg-black/30 dark:bg-black/60',\n sheet: 'bg-black/10',\n};\n\n/** A modal's tint classes. Admin draws the same tint behind an app's dialogs and sheets. */\nexport const overlayTint = (tint: AppOverlayTint) => OVERLAY_TINTS[tint];\n\n/**\n * Centres a dialog on the window, moved only as far as it must to stay inside the safe area.\n * One wider than the safe area is centred on it instead.\n */\nexport const SAFE_AREA_DIALOG_X =\n 'w-[calc(100%_-_var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px))] translate-x-[calc(-50%_+_clamp(min(var(--ghost-safe-area-inset-left,0px)_-_50vw_+_50%,(var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px))/2),0px,max(50vw_-_var(--ghost-safe-area-inset-right,0px)_-_50%,(var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px))/2)))]';\n\nexport const SAFE_AREA_DIALOG_HEIGHT =\n 'max-h-[calc(100dvh_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px)_-_1rem)] overflow-y-auto';\n\n/** A dialog or sheet's hold on the overlay, from when it mounts until it unmounts. */\nexport interface AppOverlayHold {\n /** True once the dialog opens, false as soon as it starts to close. */\n setOpen(open: boolean): void;\n /** Called after the dialog's closing animation, once it has unmounted. */\n release(): void;\n}\n\n/**\n * Where an app's dialogs and sheets render, so they cover all of Admin rather than only the\n * app's frame. Pass the app SDK's `ghost.overlay` to `ShadeApp` as `overlay`.\n */\nexport interface AppOverlay {\n /** The element to render into, or undefined to render in the page. */\n container(): HTMLElement | undefined;\n /** Called with the dialog's content element as it mounts. */\n hold(tint: AppOverlayTint, element: HTMLElement): AppOverlayHold;\n}\n\nexport const AppOverlayContext = React.createContext<AppOverlay | undefined>(undefined);\n\n/**\n * Tracks the dialogs open in the overlay so toasts can show above them. Returns the overlay to\n * give the dialogs, and the toasts' container: the overlay's while a dialog is open there.\n */\nexport function useOverlayToasts(\n overlay: AppOverlay | undefined,\n): [AppOverlay | undefined, HTMLElement | undefined] {\n const [container, setContainer] = React.useState<HTMLElement>();\n const tracked = React.useMemo((): AppOverlay | undefined => {\n if (!overlay) {\n return undefined;\n }\n const open = new Map<object, HTMLElement>();\n const update = () => setContainer([...open.values()].at(-1));\n return {\n container: () => overlay.container(),\n hold(tint, element) {\n const key = {};\n const hold = overlay.hold(tint, element);\n return {\n setOpen(next) {\n hold.setOpen(next);\n open.delete(key);\n // A dialog that fell back to the page keeps its toasts there too.\n const root = next ? overlay.container() : undefined;\n if (root?.contains(element)) {\n open.set(key, root);\n }\n update();\n },\n release() {\n open.delete(key);\n update();\n hold.release();\n },\n };\n },\n };\n }, [overlay]);\n return [tracked, overlay ? container : undefined];\n}\n\n/** Content portalled from a hosted dialog renders in the overlay too, above the dialog. */\nconst PortalContainerContext = React.createContext<HTMLElement | undefined>(undefined);\n\nconst ModalStateContext = React.createContext<{ open: boolean; modal: boolean } | undefined>(\n undefined,\n);\n\ninterface OpenProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n modal?: boolean;\n}\n\n/**\n * Wraps a Radix dialog `Root`'s props so its content re-renders when it opens, even from its own\n * trigger, and can then decide whether to render in the overlay. Radix re-renders only its\n * portal, and doesn't expose `modal` to the content.\n */\nexport function useModalOpen<P extends OpenProps>(\n props: P,\n): [P, (children: React.ReactNode) => React.ReactNode] {\n const { open, defaultOpen, onOpenChange, modal = true } = props;\n const [uncontrolled, setUncontrolled] = React.useState(defaultOpen ?? false);\n const isOpen = open ?? uncontrolled;\n const handleOpenChange = React.useCallback(\n (next: boolean) => {\n setUncontrolled(next);\n onOpenChange?.(next);\n },\n [onOpenChange],\n );\n const state = React.useMemo(() => ({ open: isOpen, modal }), [isOpen, modal]);\n const provide = React.useCallback(\n (children: React.ReactNode) => (\n <ModalStateContext.Provider value={state}>{children}</ModalStateContext.Provider>\n ),\n [state],\n );\n return [{ ...props, onOpenChange: handleOpenChange }, provide];\n}\n\n/** The container for a Radix `Portal`: the overlay inside a hosted dialog, else the default. */\nexport const usePortalContainer = () => React.useContext(PortalContainerContext);\n\nfunction setRef<T>(ref: React.Ref<T> | undefined, value: T | null) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n}\n\n/**\n * Transparent so Admin's tint shows through, but still there so a press beside the dialog closes\n * it. A style rather than a class, to override the overlay's colour in either theme.\n */\nconst HOSTED_OVERLAY_STYLE: React.CSSProperties = { background: 'transparent' };\n\ninterface Placement {\n open: boolean | undefined;\n container: HTMLElement | undefined;\n}\n\ninterface HostedModal<T extends HTMLElement> {\n /** The overlay when the dialog renders there, or a non-modal one opens from a dialog there. */\n container: HTMLElement | undefined;\n inApp: boolean;\n modal: boolean;\n overlayStyle: React.CSSProperties | undefined;\n ref: React.RefCallback<T>;\n wrap: (children: React.ReactNode) => React.ReactNode;\n}\n\n/**\n * Renders a dialog, alert dialog or sheet in the app's overlay when there is one, holding the\n * overlay while its content is mounted.\n */\nexport function useHostedModal<T extends HTMLElement>(\n tint: AppOverlayTint,\n forwardedRef: React.Ref<T>,\n): HostedModal<T> {\n const overlay = React.useContext(AppOverlayContext);\n const inherited = usePortalContainer();\n const state = React.useContext(ModalStateContext);\n const open = state?.open;\n const modal = state?.modal ?? true;\n // Decided as the dialog opens and kept while it closes: moving it would remount the content.\n // Outside Shade's dialog roots `open` is undefined, so it decides on each render.\n const place = () => (modal ? overlay?.container() : undefined);\n const [placed, setPlaced] = React.useState<Placement>(() => ({\n open,\n container: open === false ? undefined : place(),\n }));\n let placement = placed;\n if (open === undefined) {\n placement = { ...placed, container: place() };\n } else if (open !== placed.open) {\n placement = open && !placed.open ? { open, container: place() } : { ...placed, open };\n setPlaced(placement);\n }\n const { container } = placement;\n const hosted = modal && container !== undefined;\n\n // The ref must stay stable: a new one makes React reattach the content, releasing the hold.\n // The insertion effect stores this render's decision before React attaches the content.\n const latest = React.useRef({ overlay, hosted, tint });\n React.useInsertionEffect(() => {\n latest.current = { overlay, hosted, tint };\n });\n // Hands the element over when the caller's ref changes, as React would.\n const content = React.useRef<T | null>(null);\n const attached = React.useRef(forwardedRef);\n React.useLayoutEffect(() => {\n if (attached.current !== forwardedRef) {\n if (content.current) {\n setRef(attached.current, null);\n setRef(forwardedRef, content.current);\n }\n attached.current = forwardedRef;\n }\n }, [forwardedRef]);\n const cleanup = React.useRef<() => void>(undefined);\n const ref = React.useCallback((element: T | null) => {\n const current = latest.current;\n content.current = element;\n setRef(attached.current, element);\n cleanup.current?.();\n cleanup.current = undefined;\n if (!element || !current.overlay || !current.hosted) {\n return;\n }\n const hold = current.overlay.hold(current.tint, element);\n const sync = () => hold.setOpen(element.getAttribute('data-state') === 'open');\n sync();\n // The element lives in the overlay's document, so use that window's constructor.\n const Observer = element.ownerDocument.defaultView?.MutationObserver ?? MutationObserver;\n const observer = new Observer(sync);\n observer.observe(element, { attributes: true, attributeFilter: ['data-state'] });\n cleanup.current = () => {\n observer.disconnect();\n hold.release();\n };\n }, []);\n\n const wrap = React.useCallback(\n (children: React.ReactNode) =>\n hosted ? (\n <PortalContainerContext.Provider value={container}>\n {children}\n </PortalContainerContext.Provider>\n ) : (\n children\n ),\n [hosted, container],\n );\n\n const portal = modal ? container : inherited;\n return {\n container: portal,\n inApp: hasSafeArea(portal),\n modal,\n overlayStyle: hosted ? HOSTED_OVERLAY_STYLE : undefined,\n ref,\n wrap,\n };\n}\n"],"mappings":";;;;AAKA,IAAM,gBAAgD;CACpD,QAAQ;CACR,OAAO;AACT;;AAGA,IAAa,eAAe,SAAyB,cAAc;;;;;AAMnE,IAAa,qBACX;AAEF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penOnToast = (event, onInteractOutside) => {
4
+ const { target } = event;
5
+ if (target && "closest" in target && target.closest("[data-sonner-toaster]")) event.preventDefault();
6
+ onInteractOutside?.(event);
7
+ };
8
+ //#endregion
9
+ export { keepOpenOnToast };
10
+
11
+ //# sourceMappingURL=toast-press.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast-press.js","names":[],"sources":["../../src/lib/toast-press.ts"],"sourcesContent":["/** Keeps a dialog or sheet open when a toast above it is pressed, which Radix counts as outside. */\nconst keepOpenOnToast = <E extends Event>(event: E, onInteractOutside?: (event: E) => void) => {\n const { target } = event;\n if (target && 'closest' in target && (target as Element).closest('[data-sonner-toaster]')) {\n event.preventDefault();\n }\n onInteractOutside?.(event);\n};\n\nexport { keepOpenOnToast };\n"],"mappings":";;AACA,IAAM,mBAAoC,OAAU,sBAA2C;CAC7F,MAAM,EAAE,WAAW;CACnB,IAAI,UAAU,aAAa,UAAW,OAAmB,QAAQ,uBAAuB,GACtF,MAAM,eAAe;CAEvB,oBAAoB,KAAK;AAC3B"}
@@ -4,7 +4,7 @@ import { ShadeScope } from "../shade-scope.js";
4
4
  import { Toaster } from "../components/ui/sonner.js";
5
5
  import { GlobalDirtyStateProvider } from "./global-dirty-state-provider.js";
6
6
  import { TooltipProvider } from "../components/ui/tooltip.js";
7
- import { useEffect, useState } from "react";
7
+ import { useEffect, useLayoutEffect, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import { createPortal } from "react-dom";
10
10
  //#region src/providers/shade-provider.tsx
@@ -14,18 +14,24 @@ var safeAreaOffset = (offset) => ({
14
14
  bottom: `calc(${offset}px + var(--ghost-safe-area-inset-bottom, 0px))`,
15
15
  left: `calc(${offset}px + var(--ghost-safe-area-inset-left, 0px))`
16
16
  });
17
- var ToasterPortal = () => {
18
- const [mounted, setMounted] = useState(false);
17
+ var ToasterPortal = ({ container }) => {
18
+ const [host, setHost] = useState();
19
19
  useEffect(() => {
20
- setMounted(true);
21
- return () => setMounted(false);
20
+ const element = document.createElement("div");
21
+ setHost(element);
22
+ return () => element.remove();
22
23
  }, []);
23
- return mounted ? createPortal(/* @__PURE__ */ jsx(ShadeScope, {
24
+ useLayoutEffect(() => {
25
+ if (!host) return;
26
+ (container?.isConnected && container.ownerDocument.defaultView !== null ? container : document.body).append(host);
27
+ }, [host, container]);
28
+ return host ? createPortal(/* @__PURE__ */ jsx(ShadeScope, {
24
29
  style: {
25
30
  width: "unset",
26
31
  height: "unset"
27
32
  },
28
33
  children: /* @__PURE__ */ jsx(Toaster, {
34
+ className: "pointer-events-auto",
29
35
  duration: 5e3,
30
36
  icons: {
31
37
  error: /* @__PURE__ */ jsx(Icon.ErrorFill, { className: "text-red" }),
@@ -48,9 +54,9 @@ var ToasterPortal = () => {
48
54
  },
49
55
  closeButton: true
50
56
  })
51
- }), document.body) : null;
57
+ }), host) : null;
52
58
  };
53
- var ShadeProvider = ({ darkMode, admin7Design = true, admin7Mobile = false, controlShape, children }) => {
59
+ var ShadeProvider = ({ darkMode, admin7Design = true, admin7Mobile = false, controlShape, toasterContainer, children }) => {
54
60
  const [isAnyTextFieldFocused, setIsAnyTextFieldFocused] = useState(false);
55
61
  const setFocusState = (value) => {
56
62
  setIsAnyTextFieldFocused(value);
@@ -64,7 +70,7 @@ var ShadeProvider = ({ darkMode, admin7Design = true, admin7Mobile = false, cont
64
70
  admin7Mobile,
65
71
  controlShape: controlShape ?? "pill"
66
72
  },
67
- children: /* @__PURE__ */ jsx(GlobalDirtyStateProvider, { children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [children, /* @__PURE__ */ jsx(ToasterPortal, {})] }) })
73
+ children: /* @__PURE__ */ jsx(GlobalDirtyStateProvider, { children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [children, /* @__PURE__ */ jsx(ToasterPortal, { container: toasterContainer })] }) })
68
74
  });
69
75
  };
70
76
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"shade-provider.js","names":[],"sources":["../../src/providers/shade-provider.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { Toaster } from '../components/ui/sonner';\nimport { createPortal } from 'react-dom';\nimport { GlobalDirtyStateProvider } from '@/providers/global-dirty-state-provider';\nimport Icon from '../components/ui/icon';\nimport { TooltipProvider } from '@/components/ui/tooltip';\nimport { ShadeScope } from '@/shade-scope';\nimport { ShadeContext, type ControlShape } from '@/providers/shade-context';\n\nconst safeAreaOffset = (offset: number) => ({\n top: `calc(${offset}px + var(--ghost-safe-area-inset-top, 0px))`,\n right: `calc(${offset}px + var(--ghost-safe-area-inset-right, 0px))`,\n bottom: `calc(${offset}px + var(--ghost-safe-area-inset-bottom, 0px))`,\n left: `calc(${offset}px + var(--ghost-safe-area-inset-left, 0px))`,\n});\n\nconst ToasterPortal = () => {\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n setMounted(true);\n return () => setMounted(false);\n }, []);\n\n return mounted\n ? createPortal(\n <ShadeScope style={{ width: 'unset', height: 'unset' }}>\n <Toaster\n duration={5000}\n icons={{\n error: <Icon.ErrorFill className=\"text-red\" />,\n success: <Icon.SuccessFill className=\"text-green\" />,\n info: <Icon.InfoFill className=\"text-text-tertiary\" />,\n }}\n mobileOffset={safeAreaOffset(16)}\n offset={safeAreaOffset(24)}\n position=\"bottom-left\"\n toastOptions={{\n classNames: {\n title: 'mt-[-1px]! text-md! font-semibold! leading-tighter! tracking-[0.1px]!',\n description: 'text-text-primary! text-sm! mt-px!',\n icon: 'ml-0!',\n },\n style: {\n alignItems: 'flex-start',\n maxWidth:\n 'min(290px, calc(100vw - 32px - var(--ghost-safe-area-inset-left, 0px) - var(--ghost-safe-area-inset-right, 0px)))',\n },\n }}\n closeButton\n />\n </ShadeScope>,\n document.body,\n )\n : null;\n};\n\ninterface ShadeProviderProps {\n darkMode: boolean;\n admin7Design?: boolean;\n admin7Mobile?: boolean;\n controlShape?: ControlShape;\n children: React.ReactNode;\n}\n\nconst ShadeProvider: React.FC<ShadeProviderProps> = ({\n darkMode,\n admin7Design = true,\n admin7Mobile = false,\n controlShape,\n children,\n}) => {\n const [isAnyTextFieldFocused, setIsAnyTextFieldFocused] = useState(false);\n\n const setFocusState = (value: boolean) => {\n setIsAnyTextFieldFocused(value);\n };\n\n return (\n <ShadeContext.Provider\n value={{\n isAnyTextFieldFocused,\n setFocusState,\n darkMode,\n admin7Design,\n admin7Mobile,\n controlShape: controlShape ?? 'pill',\n }}\n >\n <GlobalDirtyStateProvider>\n {/* Default Radix tooltip timing for any Tooltip without a nearer\n provider; inner providers still win via nearest-provider scoping. */}\n <TooltipProvider>\n {children}\n <ToasterPortal />\n </TooltipProvider>\n </GlobalDirtyStateProvider>\n </ShadeContext.Provider>\n );\n};\n\nexport default ShadeProvider;\n"],"mappings":";;;;;;;;;;AASA,IAAM,kBAAkB,YAAoB;CAC1C,KAAK,QAAQ,OAAO;CACpB,OAAO,QAAQ,OAAO;CACtB,QAAQ,QAAQ,OAAO;CACvB,MAAM,QAAQ,OAAO;AACvB;AAEA,IAAM,sBAAsB;CAC1B,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAE5C,gBAAgB;EACd,WAAW,IAAI;EACf,aAAa,WAAW,KAAK;CAC/B,GAAG,CAAC,CAAC;CAEL,OAAO,UACH,aACE,oBAAC,YAAD;EAAY,OAAO;GAAE,OAAO;GAAS,QAAQ;EAAQ;YACnD,oBAAC,SAAD;GACE,UAAU;GACV,OAAO;IACL,OAAO,oBAAC,KAAK,WAAN,EAAgB,WAAU,WAAY,CAAA;IAC7C,SAAS,oBAAC,KAAK,aAAN,EAAkB,WAAU,aAAc,CAAA;IACnD,MAAM,oBAAC,KAAK,UAAN,EAAe,WAAU,qBAAsB,CAAA;GACvD;GACA,cAAc,eAAe,EAAE;GAC/B,QAAQ,eAAe,EAAE;GACzB,UAAS;GACT,cAAc;IACZ,YAAY;KACV,OAAO;KACP,aAAa;KACb,MAAM;IACR;IACA,OAAO;KACL,YAAY;KACZ,UACE;IACJ;GACF;GACA,aAAA;EACD,CAAA;CACS,CAAA,GACZ,SAAS,IACX,IACA;AACN;AAUA,IAAM,iBAA+C,EACnD,UACA,eAAe,MACf,eAAe,OACf,cACA,eACI;CACJ,MAAM,CAAC,uBAAuB,4BAA4B,SAAS,KAAK;CAExE,MAAM,iBAAiB,UAAmB;EACxC,yBAAyB,KAAK;CAChC;CAEA,OACE,oBAAC,aAAa,UAAd;EACE,OAAO;GACL;GACA;GACA;GACA;GACA;GACA,cAAc,gBAAgB;EAChC;YAEA,oBAAC,0BAAD,EAAA,UAGE,qBAAC,iBAAD,EAAA,UAAA,CACG,UACD,oBAAC,eAAD,CAAgB,CAAA,CACD,EAAA,CAAA,EACO,CAAA;CACL,CAAA;AAE3B"}
1
+ {"version":3,"file":"shade-provider.js","names":[],"sources":["../../src/providers/shade-provider.tsx"],"sourcesContent":["import React, { useEffect, useLayoutEffect, useState } from 'react';\nimport { Toaster } from '../components/ui/sonner';\nimport { createPortal } from 'react-dom';\nimport { GlobalDirtyStateProvider } from '@/providers/global-dirty-state-provider';\nimport Icon from '../components/ui/icon';\nimport { TooltipProvider } from '@/components/ui/tooltip';\nimport { ShadeScope } from '@/shade-scope';\nimport { ShadeContext, type ControlShape } from '@/providers/shade-context';\n\nconst safeAreaOffset = (offset: number) => ({\n top: `calc(${offset}px + var(--ghost-safe-area-inset-top, 0px))`,\n right: `calc(${offset}px + var(--ghost-safe-area-inset-right, 0px))`,\n bottom: `calc(${offset}px + var(--ghost-safe-area-inset-bottom, 0px))`,\n left: `calc(${offset}px + var(--ghost-safe-area-inset-left, 0px))`,\n});\n\nconst ToasterPortal = ({ container }: { container: HTMLElement | undefined }) => {\n // One host for the Toaster's whole life, moved to where toasts show: portalling into another\n // element would remount the Toaster and restart its toasts.\n const [host, setHost] = useState<HTMLElement>();\n\n useEffect(() => {\n const element = document.createElement('div');\n setHost(element);\n return () => element.remove();\n }, []);\n\n useLayoutEffect(() => {\n if (!host) {\n return;\n }\n // An app's overlay document can go while a dialog is open in it.\n const live = container?.isConnected && container.ownerDocument.defaultView !== null;\n (live ? container : document.body).append(host);\n }, [host, container]);\n\n return host\n ? createPortal(\n <ShadeScope style={{ width: 'unset', height: 'unset' }}>\n <Toaster\n // Radix turns off pointer events on the body under a modal dialog or sheet.\n className=\"pointer-events-auto\"\n duration={5000}\n icons={{\n error: <Icon.ErrorFill className=\"text-red\" />,\n success: <Icon.SuccessFill className=\"text-green\" />,\n info: <Icon.InfoFill className=\"text-text-tertiary\" />,\n }}\n mobileOffset={safeAreaOffset(16)}\n offset={safeAreaOffset(24)}\n position=\"bottom-left\"\n toastOptions={{\n classNames: {\n title: 'mt-[-1px]! text-md! font-semibold! leading-tighter! tracking-[0.1px]!',\n description: 'text-text-primary! text-sm! mt-px!',\n icon: 'ml-0!',\n },\n style: {\n alignItems: 'flex-start',\n maxWidth:\n 'min(290px, calc(100vw - 32px - var(--ghost-safe-area-inset-left, 0px) - var(--ghost-safe-area-inset-right, 0px)))',\n },\n }}\n closeButton\n />\n </ShadeScope>,\n host,\n )\n : null;\n};\n\ninterface ShadeProviderProps {\n darkMode: boolean;\n admin7Design?: boolean;\n admin7Mobile?: boolean;\n controlShape?: ControlShape;\n /** Where toasts render instead of the page: an app's overlay, while a dialog is open there. */\n toasterContainer?: HTMLElement;\n children: React.ReactNode;\n}\n\nconst ShadeProvider: React.FC<ShadeProviderProps> = ({\n darkMode,\n admin7Design = true,\n admin7Mobile = false,\n controlShape,\n toasterContainer,\n children,\n}) => {\n const [isAnyTextFieldFocused, setIsAnyTextFieldFocused] = useState(false);\n\n const setFocusState = (value: boolean) => {\n setIsAnyTextFieldFocused(value);\n };\n\n return (\n <ShadeContext.Provider\n value={{\n isAnyTextFieldFocused,\n setFocusState,\n darkMode,\n admin7Design,\n admin7Mobile,\n controlShape: controlShape ?? 'pill',\n }}\n >\n <GlobalDirtyStateProvider>\n {/* Default Radix tooltip timing for any Tooltip without a nearer\n provider; inner providers still win via nearest-provider scoping. */}\n <TooltipProvider>\n {children}\n <ToasterPortal container={toasterContainer} />\n </TooltipProvider>\n </GlobalDirtyStateProvider>\n </ShadeContext.Provider>\n );\n};\n\nexport default ShadeProvider;\n"],"mappings":";;;;;;;;;;AASA,IAAM,kBAAkB,YAAoB;CAC1C,KAAK,QAAQ,OAAO;CACpB,OAAO,QAAQ,OAAO;CACtB,QAAQ,QAAQ,OAAO;CACvB,MAAM,QAAQ,OAAO;AACvB;AAEA,IAAM,iBAAiB,EAAE,gBAAwD;CAG/E,MAAM,CAAC,MAAM,WAAW,SAAsB;CAE9C,gBAAgB;EACd,MAAM,UAAU,SAAS,cAAc,KAAK;EAC5C,QAAQ,OAAO;EACf,aAAa,QAAQ,OAAO;CAC9B,GAAG,CAAC,CAAC;CAEL,sBAAsB;EACpB,IAAI,CAAC,MACH;EAIF,CADa,WAAW,eAAe,UAAU,cAAc,gBAAgB,OACvE,YAAY,SAAS,KAAA,CAAM,OAAO,IAAI;CAChD,GAAG,CAAC,MAAM,SAAS,CAAC;CAEpB,OAAO,OACH,aACE,oBAAC,YAAD;EAAY,OAAO;GAAE,OAAO;GAAS,QAAQ;EAAQ;YACnD,oBAAC,SAAD;GAEE,WAAU;GACV,UAAU;GACV,OAAO;IACL,OAAO,oBAAC,KAAK,WAAN,EAAgB,WAAU,WAAY,CAAA;IAC7C,SAAS,oBAAC,KAAK,aAAN,EAAkB,WAAU,aAAc,CAAA;IACnD,MAAM,oBAAC,KAAK,UAAN,EAAe,WAAU,qBAAsB,CAAA;GACvD;GACA,cAAc,eAAe,EAAE;GAC/B,QAAQ,eAAe,EAAE;GACzB,UAAS;GACT,cAAc;IACZ,YAAY;KACV,OAAO;KACP,aAAa;KACb,MAAM;IACR;IACA,OAAO;KACL,YAAY;KACZ,UACE;IACJ;GACF;GACA,aAAA;EACD,CAAA;CACS,CAAA,GACZ,IACF,IACA;AACN;AAYA,IAAM,iBAA+C,EACnD,UACA,eAAe,MACf,eAAe,OACf,cACA,kBACA,eACI;CACJ,MAAM,CAAC,uBAAuB,4BAA4B,SAAS,KAAK;CAExE,MAAM,iBAAiB,UAAmB;EACxC,yBAAyB,KAAK;CAChC;CAEA,OACE,oBAAC,aAAa,UAAd;EACE,OAAO;GACL;GACA;GACA;GACA;GACA;GACA,cAAc,gBAAgB;EAChC;YAEA,oBAAC,0BAAD,EAAA,UAGE,qBAAC,iBAAD,EAAA,UAAA,CACG,UACD,oBAAC,eAAD,EAAe,WAAW,iBAAmB,CAAA,CAC9B,EAAA,CAAA,EACO,CAAA;CACL,CAAA;AAE3B"}
package/es/shade-app.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { cn } from "./lib/ds-utils.js";
2
2
  import { useHasSafeArea, useSafeAreaSlide } from "./lib/safe-area.js";
3
- import { AppOverlayContext } from "./lib/app-overlay.js";
3
+ import { AppOverlayContext, useOverlayToasts } from "./lib/app-overlay.js";
4
4
  import ShadeProvider from "./providers/shade-provider.js";
5
5
  import React from "react";
6
6
  import clsx$1 from "clsx";
@@ -18,6 +18,7 @@ var ShadeApp = ({ darkMode, controlShape, admin7Design = true, admin7Mobile = fa
18
18
  const inApp = useHasSafeArea();
19
19
  useSafeAreaSlide(root);
20
20
  const appClassName = cn("shade", SAFE_AREA_PADDING, className);
21
+ const [hostedOverlay, toasterContainer] = useOverlayToasts(overlay);
21
22
  return /* @__PURE__ */ jsx("div", {
22
23
  ref: root,
23
24
  className: inApp ? appClassName : clsx$1("shade", className),
@@ -29,8 +30,9 @@ var ShadeApp = ({ darkMode, controlShape, admin7Design = true, admin7Mobile = fa
29
30
  admin7Mobile,
30
31
  controlShape,
31
32
  darkMode,
33
+ toasterContainer,
32
34
  children: /* @__PURE__ */ jsx(AppOverlayContext.Provider, {
33
- value: overlay,
35
+ value: hostedOverlay,
34
36
  children
35
37
  })
36
38
  })
@@ -1 +1 @@
1
- {"version":3,"file":"shade-app.js","names":[],"sources":["../src/shade-app.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React from 'react';\nimport { type AppOverlay, AppOverlayContext } from '@/lib/app-overlay';\nimport ShadeProvider from '@/providers/shade-provider';\nimport type { ControlShape } from '@/providers/shade-context';\nimport { useHasSafeArea, useSafeAreaSlide } from '@/lib/safe-area';\nimport { cn } from '@/lib/utils';\n\n/**\n * The className is used to scope the styles of the app to the app's namespace.\n * Some components in radixUI/ShadCN need to be wrapped in a div with the className\n * in order to work correctly.\n */\nexport const SHADE_APP_NAMESPACES = 'shade shade-admin shade-activitypub';\n\nconst SAFE_AREA_PADDING = cn(\n 'pt-[var(--ghost-safe-area-inset-top,0px)] pr-[var(--ghost-safe-area-inset-right,0px)]',\n 'pb-[var(--ghost-safe-area-inset-bottom,0px)] pl-[var(--ghost-safe-area-inset-left,0px)]',\n);\n\nexport interface ShadeAppProps extends React.HTMLProps<HTMLDivElement> {\n darkMode: boolean;\n controlShape?: ControlShape;\n /**\n * Admin's `admin7Design` Labs flag. Admin passes the flag's value; isolated Shade\n * previews and standalone apps default to the Admin 7 design. Removed with the flag.\n */\n admin7Design?: boolean;\n /** Temporary Admin mobile-hardening flag. Standalone surfaces stay off by default. */\n admin7Mobile?: boolean;\n /** In a Ghost app, where dialogs and sheets render. Pass the app SDK's `ghost.overlay`. */\n overlay?: AppOverlay;\n}\n\nconst ShadeApp: React.FC<ShadeAppProps> = ({\n darkMode,\n controlShape,\n admin7Design = true,\n admin7Mobile = false,\n overlay,\n className,\n children,\n ...props\n}) => {\n const root = React.useRef<HTMLDivElement>(null);\n const inApp = useHasSafeArea();\n useSafeAreaSlide(root);\n // Last, so a className's own padding wins.\n const appClassName = cn('shade', SAFE_AREA_PADDING, className);\n\n return (\n <div\n ref={root}\n className={inApp ? appClassName : clsx('shade', className)}\n {...props}\n data-admin7-design={admin7Design}\n data-admin7-mobile={admin7Mobile}\n >\n <ShadeProvider\n admin7Design={admin7Design}\n admin7Mobile={admin7Mobile}\n controlShape={controlShape}\n darkMode={darkMode}\n >\n <AppOverlayContext.Provider value={overlay}>{children}</AppOverlayContext.Provider>\n </ShadeProvider>\n </div>\n );\n};\n\nexport default ShadeApp;\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,uBAAuB;AAEpC,IAAM,oBAAoB,GACxB,yFACA,yFACF;AAgBA,IAAM,YAAqC,EACzC,UACA,cACA,eAAe,MACf,eAAe,OACf,SACA,WACA,UACA,GAAG,YACC;CACJ,MAAM,OAAO,MAAM,OAAuB,IAAI;CAC9C,MAAM,QAAQ,eAAe;CAC7B,iBAAiB,IAAI;CAErB,MAAM,eAAe,GAAG,SAAS,mBAAmB,SAAS;CAE7D,OACE,oBAAC,OAAD;EACE,KAAK;EACL,WAAW,QAAQ,eAAe,OAAK,SAAS,SAAS;EACzD,GAAI;EACJ,sBAAoB;EACpB,sBAAoB;YAEpB,oBAAC,eAAD;GACgB;GACA;GACA;GACJ;aAEV,oBAAC,kBAAkB,UAAnB;IAA4B,OAAO;IAAU;GAAqC,CAAA;EACrE,CAAA;CACZ,CAAA;AAET"}
1
+ {"version":3,"file":"shade-app.js","names":[],"sources":["../src/shade-app.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React from 'react';\nimport { type AppOverlay, AppOverlayContext, useOverlayToasts } from '@/lib/app-overlay';\nimport ShadeProvider from '@/providers/shade-provider';\nimport type { ControlShape } from '@/providers/shade-context';\nimport { useHasSafeArea, useSafeAreaSlide } from '@/lib/safe-area';\nimport { cn } from '@/lib/utils';\n\n/**\n * The className is used to scope the styles of the app to the app's namespace.\n * Some components in radixUI/ShadCN need to be wrapped in a div with the className\n * in order to work correctly.\n */\nexport const SHADE_APP_NAMESPACES = 'shade shade-admin shade-activitypub';\n\nconst SAFE_AREA_PADDING = cn(\n 'pt-[var(--ghost-safe-area-inset-top,0px)] pr-[var(--ghost-safe-area-inset-right,0px)]',\n 'pb-[var(--ghost-safe-area-inset-bottom,0px)] pl-[var(--ghost-safe-area-inset-left,0px)]',\n);\n\nexport interface ShadeAppProps extends React.HTMLProps<HTMLDivElement> {\n darkMode: boolean;\n controlShape?: ControlShape;\n /**\n * Admin's `admin7Design` Labs flag. Admin passes the flag's value; isolated Shade\n * previews and standalone apps default to the Admin 7 design. Removed with the flag.\n */\n admin7Design?: boolean;\n /** Temporary Admin mobile-hardening flag. Standalone surfaces stay off by default. */\n admin7Mobile?: boolean;\n /** In a Ghost app, where dialogs and sheets render. Pass the app SDK's `ghost.overlay`. */\n overlay?: AppOverlay;\n}\n\nconst ShadeApp: React.FC<ShadeAppProps> = ({\n darkMode,\n controlShape,\n admin7Design = true,\n admin7Mobile = false,\n overlay,\n className,\n children,\n ...props\n}) => {\n const root = React.useRef<HTMLDivElement>(null);\n const inApp = useHasSafeArea();\n useSafeAreaSlide(root);\n // Last, so a className's own padding wins.\n const appClassName = cn('shade', SAFE_AREA_PADDING, className);\n const [hostedOverlay, toasterContainer] = useOverlayToasts(overlay);\n\n return (\n <div\n ref={root}\n className={inApp ? appClassName : clsx('shade', className)}\n {...props}\n data-admin7-design={admin7Design}\n data-admin7-mobile={admin7Mobile}\n >\n <ShadeProvider\n admin7Design={admin7Design}\n admin7Mobile={admin7Mobile}\n controlShape={controlShape}\n darkMode={darkMode}\n toasterContainer={toasterContainer}\n >\n <AppOverlayContext.Provider value={hostedOverlay}>{children}</AppOverlayContext.Provider>\n </ShadeProvider>\n </div>\n );\n};\n\nexport default ShadeApp;\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,uBAAuB;AAEpC,IAAM,oBAAoB,GACxB,yFACA,yFACF;AAgBA,IAAM,YAAqC,EACzC,UACA,cACA,eAAe,MACf,eAAe,OACf,SACA,WACA,UACA,GAAG,YACC;CACJ,MAAM,OAAO,MAAM,OAAuB,IAAI;CAC9C,MAAM,QAAQ,eAAe;CAC7B,iBAAiB,IAAI;CAErB,MAAM,eAAe,GAAG,SAAS,mBAAmB,SAAS;CAC7D,MAAM,CAAC,eAAe,oBAAoB,iBAAiB,OAAO;CAElE,OACE,oBAAC,OAAD;EACE,KAAK;EACL,WAAW,QAAQ,eAAe,OAAK,SAAS,SAAS;EACzD,GAAI;EACJ,sBAAoB;EACpB,sBAAoB;YAEpB,oBAAC,eAAD;GACgB;GACA;GACA;GACJ;GACQ;aAElB,oBAAC,kBAAkB,UAAnB;IAA4B,OAAO;IAAgB;GAAqC,CAAA;EAC3E,CAAA;CACZ,CAAA;AAET"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/shade",
3
- "version": "0.1.0-alpha.49",
3
+ "version": "0.1.0-alpha.50",
4
4
  "description": "Ghost design system for React apps",
5
5
  "license": "MIT",
6
6
  "author": "Ghost Foundation",
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../../src/components/ui/dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAY1D,QAAA,MAAM,MAAM,UAAW,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,oBAGvE,CAAC;AAEF,QAAA,MAAM,aAAa,8GAA0B,CAAC;AAE9C,QAAA,MAAM,YAAY,6CAAyB,CAAC;AAE5C,QAAA,MAAM,WAAW,4GAAwB,CAAC;AAE1C,QAAA,MAAM,aAAa,8JAcjB,CAAC;AA6BH,MAAM,WAAW,kBAAmB,SAAQ,KAAK,CAAC,wBAAwB,CACxE,OAAO,eAAe,CAAC,OAAO,CAC/B;IACC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC9B;AAED,QAAA,MAAM,aAAa,2FAiFjB,CAAC;8BAGmB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;;;;8BAK7D,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;;;;AAWnF,QAAA,MAAM,WAAW,oKAYf,CAAC;AAGH,QAAA,MAAM,iBAAiB,8KASrB,CAAC;AAGH,OAAO,EACL,MAAM,EACN,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,iBAAiB,GAClB,CAAC"}
1
+ {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../../src/components/ui/dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAa1D,QAAA,MAAM,MAAM,UAAW,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,oBAGvE,CAAC;AAEF,QAAA,MAAM,aAAa,8GAA0B,CAAC;AAE9C,QAAA,MAAM,YAAY,6CAAyB,CAAC;AAE5C,QAAA,MAAM,WAAW,4GAAwB,CAAC;AAE1C,QAAA,MAAM,aAAa,8JAcjB,CAAC;AA6BH,MAAM,WAAW,kBAAmB,SAAQ,KAAK,CAAC,wBAAwB,CACxE,OAAO,eAAe,CAAC,OAAO,CAC/B;IACC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC9B;AAED,QAAA,MAAM,aAAa,2FAkFjB,CAAC;8BAGmB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;;;;8BAK7D,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;;;;AAWnF,QAAA,MAAM,WAAW,oKAYf,CAAC;AAGH,QAAA,MAAM,iBAAiB,8KASrB,CAAC;AAGH,OAAO,EACL,MAAM,EACN,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,iBAAiB,GAClB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../../src/components/ui/sheet.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAOlE,QAAA,MAAM,KAAK,UAAW,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,oBAGrE,CAAC;AAEF,QAAA,MAAM,YAAY,6GAAyB,CAAC;AAE5C,QAAA,MAAM,UAAU,2GAAuB,CAAC;AAExC,QAAA,MAAM,WAAW,4CAAwB,CAAC;AAE1C,QAAA,MAAM,YAAY,6JAahB,CAAC;AAKH,QAAA,MAAM,aAAa;;8EAiBlB,CAAC;AAEF,UAAU,iBACR,SACE,KAAK,CAAC,wBAAwB,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,EAC7D,YAAY,CAAC,OAAO,aAAa,CAAC;CAAG;AAEzC,QAAA,MAAM,YAAY,0FAiDhB,CAAC;6BAGkB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;;;;6BAK7D,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;;;;AAQlF,QAAA,MAAM,UAAU,mKAYd,CAAC;AAGH,QAAA,MAAM,gBAAgB,6KASpB,CAAC;AAGH,OAAO,EACL,KAAK,EACL,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,GACjB,CAAC"}
1
+ {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../../src/components/ui/sheet.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAQlE,QAAA,MAAM,KAAK,UAAW,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,oBAGrE,CAAC;AAEF,QAAA,MAAM,YAAY,6GAAyB,CAAC;AAE5C,QAAA,MAAM,UAAU,2GAAuB,CAAC;AAExC,QAAA,MAAM,WAAW,4CAAwB,CAAC;AAE1C,QAAA,MAAM,YAAY,6JAahB,CAAC;AAKH,QAAA,MAAM,aAAa;;8EAiBlB,CAAC;AAEF,UAAU,iBACR,SACE,KAAK,CAAC,wBAAwB,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,EAC7D,YAAY,CAAC,OAAO,aAAa,CAAC;CAAG;AAEzC,QAAA,MAAM,YAAY,0FAkDhB,CAAC;6BAGkB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;;;;6BAK7D,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;;;;AAQlF,QAAA,MAAM,UAAU,mKAYd,CAAC;AAGH,QAAA,MAAM,gBAAgB,6KASpB,CAAC;AAGH,OAAO,EACL,KAAK,EACL,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,GACjB,CAAC"}
@@ -26,6 +26,11 @@ export interface AppOverlay {
26
26
  hold(tint: AppOverlayTint, element: HTMLElement): AppOverlayHold;
27
27
  }
28
28
  export declare const AppOverlayContext: React.Context<AppOverlay | undefined>;
29
+ /**
30
+ * Tracks the dialogs open in the overlay so toasts can show above them. Returns the overlay to
31
+ * give the dialogs, and the toasts' container: the overlay's while a dialog is open there.
32
+ */
33
+ export declare function useOverlayToasts(overlay: AppOverlay | undefined): [AppOverlay | undefined, HTMLElement | undefined];
29
34
  interface OpenProps {
30
35
  open?: boolean;
31
36
  default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D,CAAC;AAExF;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,UAAU,GAAG,SAAS,GAC9B,CAAC,UAAU,GAAG,SAAS,EAAE,WAAW,GAAG,SAAS,CAAC,CAkCnD;AASD,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,SAAS,EAC9C,KAAK,EAAE,CAAC,GACP,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC,CAmBrD;AAED,gGAAgG;AAChG,eAAO,MAAM,kBAAkB,+BAAiD,CAAC;AAqBjF,UAAU,WAAW,CAAC,CAAC,SAAS,WAAW;IACzC,+FAA+F;IAC/F,SAAS,EAAE,WAAW,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC;IAC9C,GAAG,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC;CACtD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,WAAW,EAClD,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GACzB,WAAW,CAAC,CAAC,CAAC,CAqFhB"}
@@ -0,0 +1,4 @@
1
+ /** Keeps a dialog or sheet open when a toast above it is pressed, which Radix counts as outside. */
2
+ declare const keepOpenOnToast: <E extends Event>(event: E, onInteractOutside?: (event: E) => void) => void;
3
+ export { keepOpenOnToast };
4
+ //# sourceMappingURL=toast-press.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast-press.d.ts","sourceRoot":"","sources":["../../src/lib/toast-press.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,QAAA,MAAM,eAAe,GAAI,CAAC,SAAS,KAAK,SAAS,CAAC,sBAAsB,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,SAMzF,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -5,6 +5,8 @@ interface ShadeProviderProps {
5
5
  admin7Design?: boolean;
6
6
  admin7Mobile?: boolean;
7
7
  controlShape?: ControlShape;
8
+ /** Where toasts render instead of the page: an app's overlay, while a dialog is open there. */
9
+ toasterContainer?: HTMLElement;
8
10
  children: React.ReactNode;
9
11
  }
10
12
  declare const ShadeProvider: React.FC<ShadeProviderProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"shade-provider.d.ts","sourceRoot":"","sources":["../../src/providers/shade-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAOnD,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAkD5E,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAkC/C,CAAC;eAEa,aAAa"}
1
+ {"version":3,"file":"shade-provider.d.ts","sourceRoot":"","sources":["../../src/providers/shade-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAOpE,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAgE5E,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,+FAA+F;IAC/F,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAmC/C,CAAC;eAEa,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"shade-app.d.ts","sourceRoot":"","sources":["../src/shade-app.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,UAAU,EAAqB,MAAM,mBAAmB,CAAC;AAEvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,wCAAwC,CAAC;AAO1E,MAAM,WAAW,aAAc,SAAQ,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;IACpE,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sFAAsF;IACtF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAkCrC,CAAC;eAEa,QAAQ"}
1
+ {"version":3,"file":"shade-app.d.ts","sourceRoot":"","sources":["../src/shade-app.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,UAAU,EAAuC,MAAM,mBAAmB,CAAC;AAEzF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