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

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.
Files changed (46) hide show
  1. package/es/app.js +2 -1
  2. package/es/components/ui/alert-dialog.js +22 -10
  3. package/es/components/ui/alert-dialog.js.map +1 -1
  4. package/es/components/ui/context-menu.js +15 -8
  5. package/es/components/ui/context-menu.js.map +1 -1
  6. package/es/components/ui/dialog.js +39 -23
  7. package/es/components/ui/dialog.js.map +1 -1
  8. package/es/components/ui/dropdown-menu.js +17 -10
  9. package/es/components/ui/dropdown-menu.js.map +1 -1
  10. package/es/components/ui/hover-card.js +12 -8
  11. package/es/components/ui/hover-card.js.map +1 -1
  12. package/es/components/ui/popover.js +13 -9
  13. package/es/components/ui/popover.js.map +1 -1
  14. package/es/components/ui/select.js +22 -17
  15. package/es/components/ui/select.js.map +1 -1
  16. package/es/components/ui/sheet.js +29 -18
  17. package/es/components/ui/sheet.js.map +1 -1
  18. package/es/components/ui/tooltip.js +79 -31
  19. package/es/components/ui/tooltip.js.map +1 -1
  20. package/es/components.js +1 -1
  21. package/es/index.js +1 -1
  22. package/es/lib/app-overlay.js +151 -0
  23. package/es/lib/app-overlay.js.map +1 -0
  24. package/es/shade-app.js +6 -2
  25. package/es/shade-app.js.map +1 -1
  26. package/package.json +1 -1
  27. package/types/app.d.ts +2 -0
  28. package/types/app.d.ts.map +1 -1
  29. package/types/components/ui/alert-dialog.d.ts +1 -1
  30. package/types/components/ui/alert-dialog.d.ts.map +1 -1
  31. package/types/components/ui/context-menu.d.ts +1 -1
  32. package/types/components/ui/context-menu.d.ts.map +1 -1
  33. package/types/components/ui/dialog.d.ts +1 -1
  34. package/types/components/ui/dialog.d.ts.map +1 -1
  35. package/types/components/ui/dropdown-menu.d.ts +1 -1
  36. package/types/components/ui/dropdown-menu.d.ts.map +1 -1
  37. package/types/components/ui/hover-card.d.ts.map +1 -1
  38. package/types/components/ui/popover.d.ts.map +1 -1
  39. package/types/components/ui/select.d.ts.map +1 -1
  40. package/types/components/ui/sheet.d.ts +1 -1
  41. package/types/components/ui/sheet.d.ts.map +1 -1
  42. package/types/components/ui/tooltip.d.ts.map +1 -1
  43. package/types/lib/app-overlay.d.ts +58 -0
  44. package/types/lib/app-overlay.d.ts.map +1 -0
  45. package/types/shade-app.d.ts +3 -0
  46. package/types/shade-app.d.ts.map +1 -1
@@ -1,6 +1,7 @@
1
1
  import { cn } from "../../lib/ds-utils.js";
2
2
  import { ShadeScope } from "../../shade-scope.js";
3
3
  import { hasSafeArea, safeAreaCollision } from "../../lib/safe-area.js";
4
+ import { usePortalContainer } from "../../lib/app-overlay.js";
4
5
  import { consumeOverlayEscape } from "../../lib/overlay-escape.js";
5
6
  import { selectTriggerVariants } from "./select-variants.js";
6
7
  import { inputSurface, inputSurfaceClasses } from "./input-surface.js";
@@ -45,23 +46,27 @@ var SelectScrollDownButton = React$1.forwardRef(({ className, ...props }, ref) =
45
46
  }));
46
47
  SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
47
48
  var SelectContent = React$1.forwardRef(({ className, children, onEscapeKeyDown, position: requested = "popper", collisionBoundary, ...props }, ref) => {
48
- const position = hasSafeArea() ? "popper" : requested;
49
- return /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsx(ShadeScope, { children: /* @__PURE__ */ jsxs(SelectPrimitive.Content, {
50
- ref,
51
- className: cn("relative z-[9999] max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-menu border border-border/60 bg-surface-elevated-2 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 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 dark:border-border/30", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className),
52
- ...safeAreaCollision(collisionBoundary),
53
- position,
54
- onEscapeKeyDown: (event) => consumeOverlayEscape(event, onEscapeKeyDown),
55
- ...props,
56
- children: [
57
- /* @__PURE__ */ jsx(SelectScrollUpButton, {}),
58
- /* @__PURE__ */ jsx(SelectPrimitive.Viewport, {
59
- className: cn("p-1", position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),
60
- children
61
- }),
62
- /* @__PURE__ */ jsx(SelectScrollDownButton, {})
63
- ]
64
- }) }) });
49
+ const container = usePortalContainer();
50
+ const position = hasSafeArea(container) ? "popper" : requested;
51
+ return /* @__PURE__ */ jsx(SelectPrimitive.Portal, {
52
+ container,
53
+ children: /* @__PURE__ */ jsx(ShadeScope, { children: /* @__PURE__ */ jsxs(SelectPrimitive.Content, {
54
+ ref,
55
+ className: cn("relative z-[9999] max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-menu border border-border/60 bg-surface-elevated-2 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 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 dark:border-border/30", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className),
56
+ ...safeAreaCollision(collisionBoundary, container),
57
+ position,
58
+ onEscapeKeyDown: (event) => consumeOverlayEscape(event, onEscapeKeyDown),
59
+ ...props,
60
+ children: [
61
+ /* @__PURE__ */ jsx(SelectScrollUpButton, {}),
62
+ /* @__PURE__ */ jsx(SelectPrimitive.Viewport, {
63
+ className: cn("p-1", position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),
64
+ children
65
+ }),
66
+ /* @__PURE__ */ jsx(SelectScrollDownButton, {})
67
+ ]
68
+ }) })
69
+ });
65
70
  });
66
71
  SelectContent.displayName = SelectPrimitive.Content.displayName;
67
72
  var SelectLabel = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Label, {
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","names":[],"sources":["../../../src/components/ui/select.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { type VariantProps } from 'class-variance-authority';\nimport { Check, ChevronDown, ChevronUp } from 'lucide-react';\n\nimport { selectTriggerVariants } from '@/components/ui/select-variants';\nimport { cn } from '@/lib/utils';\nimport { ShadeScope } from '@/shade-scope';\nimport { inputSurface, inputSurfaceClasses } from '@/components/ui/input-surface';\nimport { consumeOverlayEscape } from '@/lib/overlay-escape';\nimport { hasSafeArea, safeAreaCollision } from '@/lib/safe-area';\nconst Select = SelectPrimitive.Root;\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\nexport interface SelectTriggerProps\n extends\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>,\n VariantProps<typeof selectTriggerVariants> {\n /** Show the dropdown chevron. Defaults to hidden for the secondary variant. */\n showChevron?: boolean;\n}\n\nconst SelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Trigger>,\n SelectTriggerProps\n>(\n (\n { className, children, shape, variant, showChevron = variant !== 'secondary', ...props },\n ref,\n ) => {\n const resolvedShape = shape ?? 'rounded';\n return (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n inputSurface('self'),\n inputSurfaceClasses.disabledFieldSelf,\n selectTriggerVariants({ shape: resolvedShape, variant }),\n showChevron && 'pr-2',\n className,\n )}\n data-control-shape={resolvedShape}\n data-variant={variant ?? 'default'}\n {...props}\n >\n {children}\n {showChevron && (\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"-mr-0.5 size-4 opacity-50\" />\n </SelectPrimitive.Icon>\n )}\n </SelectPrimitive.Trigger>\n );\n },\n);\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn('flex cursor-default items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronUp className=\"size-4\" />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn('flex cursor-default items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronDown className=\"size-4\" />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>\n>(\n (\n {\n className,\n children,\n onEscapeKeyDown,\n position: requested = 'popper',\n collisionBoundary,\n ...props\n },\n ref,\n ) => {\n // Radix fits an item-aligned select to the window, ignoring the safe area's boundary.\n const position = hasSafeArea() ? 'popper' : requested;\n return (\n <SelectPrimitive.Portal>\n <ShadeScope>\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n 'relative z-[9999] max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-menu border border-border/60 bg-surface-elevated-2 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 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 dark:border-border/30',\n position === 'popper' &&\n 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n className,\n )}\n {...safeAreaCollision(collisionBoundary)}\n position={position}\n onEscapeKeyDown={(event) => consumeOverlayEscape(event, onEscapeKeyDown)}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\n 'p-1',\n position === 'popper' &&\n 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]',\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </ShadeScope>\n </SelectPrimitive.Portal>\n );\n },\n);\nSelectContent.displayName = SelectPrimitive.Content.displayName;\n\nconst SelectLabel = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn('px-2 py-1.5 text-control font-semibold', className)}\n {...props}\n />\n));\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\n\nconst SelectItem = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex w-full cursor-default items-center rounded-menu-item py-1.5 pr-8 pl-2 text-control outline-hidden select-none focus:bg-interactive-hover focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n className,\n )}\n {...props}\n >\n <span className=\"absolute right-2 flex size-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"size-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n));\nSelectItem.displayName = SelectPrimitive.Item.displayName;\n\nconst SelectSeparator = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn('-mx-1 my-1 h-px bg-muted', className)}\n {...props}\n />\n));\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n};\n"],"mappings":";;;;;;;;;;;AAWA,IAAM,SAAS,gBAAgB;AAE/B,IAAM,cAAc,gBAAgB;AAEpC,IAAM,cAAc,gBAAgB;AAUpC,IAAM,gBAAgB,QAAM,YAKxB,EAAE,WAAW,UAAU,OAAO,SAAS,cAAc,YAAY,aAAa,GAAG,SACjF,QACG;CACH,MAAM,gBAAgB,SAAS;CAC/B,OACE,qBAAC,gBAAgB,SAAjB;EACO;EACL,WAAW,GACT,aAAa,MAAM,GACnB,oBAAoB,mBACpB,sBAAsB;GAAE,OAAO;GAAe;EAAQ,CAAC,GACvD,eAAe,QACf,SACF;EACA,sBAAoB;EACpB,gBAAc,WAAW;EACzB,GAAI;YAXN,CAaG,UACA,eACC,oBAAC,gBAAgB,MAAjB;GAAsB,SAAA;aACpB,oBAAC,aAAD,EAAa,WAAU,4BAA6B,CAAA;EAChC,CAAA,CAED;;AAE7B,CACF;AACA,cAAc,cAAc,gBAAgB,QAAQ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gBAAgB,MAAM;AAEhD,IAAM,aAAa,QAAM,YAGtB,EAAE,WAAW,UAAU,GAAG,SAAS,QACpC,qBAAC,gBAAgB,MAAjB;CACO;CACL,WAAW,GACT,sPACA,SACF;CACA,GAAI;WANN,CAQE,oBAAC,QAAD;EAAM,WAAU;YACd,oBAAC,gBAAgB,eAAjB,EAAA,UACE,oBAAC,OAAD,EAAO,WAAU,SAAU,CAAA,EACE,CAAA;CAC3B,CAAA,GACN,oBAAC,gBAAgB,UAAjB,EAA2B,SAAmC,CAAA,CAC1C;EACvB;AACD,WAAW,cAAc,gBAAgB,KAAK;AAE9C,IAAM,kBAAkB,QAAM,YAG3B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,WAAjB;CACO;CACL,WAAW,GAAG,4BAA4B,SAAS;CACnD,GAAI;AACL,CAAA,CACF;AACD,gBAAgB,cAAc,gBAAgB,UAAU"}
1
+ {"version":3,"file":"select.js","names":[],"sources":["../../../src/components/ui/select.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { type VariantProps } from 'class-variance-authority';\nimport { Check, ChevronDown, ChevronUp } from 'lucide-react';\n\nimport { selectTriggerVariants } from '@/components/ui/select-variants';\nimport { usePortalContainer } from '@/lib/app-overlay';\nimport { cn } from '@/lib/utils';\nimport { ShadeScope } from '@/shade-scope';\nimport { inputSurface, inputSurfaceClasses } from '@/components/ui/input-surface';\nimport { consumeOverlayEscape } from '@/lib/overlay-escape';\nimport { hasSafeArea, safeAreaCollision } from '@/lib/safe-area';\nconst Select = SelectPrimitive.Root;\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\nexport interface SelectTriggerProps\n extends\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>,\n VariantProps<typeof selectTriggerVariants> {\n /** Show the dropdown chevron. Defaults to hidden for the secondary variant. */\n showChevron?: boolean;\n}\n\nconst SelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Trigger>,\n SelectTriggerProps\n>(\n (\n { className, children, shape, variant, showChevron = variant !== 'secondary', ...props },\n ref,\n ) => {\n const resolvedShape = shape ?? 'rounded';\n return (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n inputSurface('self'),\n inputSurfaceClasses.disabledFieldSelf,\n selectTriggerVariants({ shape: resolvedShape, variant }),\n showChevron && 'pr-2',\n className,\n )}\n data-control-shape={resolvedShape}\n data-variant={variant ?? 'default'}\n {...props}\n >\n {children}\n {showChevron && (\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"-mr-0.5 size-4 opacity-50\" />\n </SelectPrimitive.Icon>\n )}\n </SelectPrimitive.Trigger>\n );\n },\n);\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn('flex cursor-default items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronUp className=\"size-4\" />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn('flex cursor-default items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronDown className=\"size-4\" />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>\n>(\n (\n {\n className,\n children,\n onEscapeKeyDown,\n position: requested = 'popper',\n collisionBoundary,\n ...props\n },\n ref,\n ) => {\n const container = usePortalContainer();\n // Radix fits an item-aligned select to the window, ignoring the safe area's boundary.\n const position = hasSafeArea(container) ? 'popper' : requested;\n return (\n <SelectPrimitive.Portal container={container}>\n <ShadeScope>\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n 'relative z-[9999] max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-menu border border-border/60 bg-surface-elevated-2 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 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 dark:border-border/30',\n position === 'popper' &&\n 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n className,\n )}\n {...safeAreaCollision(collisionBoundary, container)}\n position={position}\n onEscapeKeyDown={(event) => consumeOverlayEscape(event, onEscapeKeyDown)}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\n 'p-1',\n position === 'popper' &&\n 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]',\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </ShadeScope>\n </SelectPrimitive.Portal>\n );\n },\n);\nSelectContent.displayName = SelectPrimitive.Content.displayName;\n\nconst SelectLabel = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn('px-2 py-1.5 text-control font-semibold', className)}\n {...props}\n />\n));\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\n\nconst SelectItem = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex w-full cursor-default items-center rounded-menu-item py-1.5 pr-8 pl-2 text-control outline-hidden select-none focus:bg-interactive-hover focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n className,\n )}\n {...props}\n >\n <span className=\"absolute right-2 flex size-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"size-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n));\nSelectItem.displayName = SelectPrimitive.Item.displayName;\n\nconst SelectSeparator = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn('-mx-1 my-1 h-px bg-muted', className)}\n {...props}\n />\n));\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n};\n"],"mappings":";;;;;;;;;;;;AAYA,IAAM,SAAS,gBAAgB;AAE/B,IAAM,cAAc,gBAAgB;AAEpC,IAAM,cAAc,gBAAgB;AAUpC,IAAM,gBAAgB,QAAM,YAKxB,EAAE,WAAW,UAAU,OAAO,SAAS,cAAc,YAAY,aAAa,GAAG,SACjF,QACG;CACH,MAAM,gBAAgB,SAAS;CAC/B,OACE,qBAAC,gBAAgB,SAAjB;EACO;EACL,WAAW,GACT,aAAa,MAAM,GACnB,o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W,GACT,OACA,aAAa,YACX,yFACJ;KAEC;IACuB,CAAA;IAC1B,oBAAC,wBAAD,CAAyB,CAAA;GACF;KACf,CAAA;CACU,CAAA;AAE5B,CACF;AACA,cAAc,cAAc,gBAAgB,QAAQ;AAEpD,IAAM,cAAc,QAAM,YAGvB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,OAAjB;CACO;CACL,WAAW,GAAG,0CAA0C,SAAS;CACjE,GAAI;AACL,CAAA,CACF;AACD,YAAY,cAAc,gBAAgB,MAAM;AAEhD,IAAM,aAAa,QAAM,YAGtB,EAAE,WAAW,UAAU,GAAG,SAAS,QACpC,qBAAC,gBAAgB,MAAjB;CACO;CACL,WAAW,GACT,sPACA,SACF;CACA,GAAI;WANN,CAQE,oBAAC,QAAD;EAAM,WAAU;YACd,oBAAC,gBAAgB,eAAjB,EAAA,UACE,oBAAC,OAAD,EAAO,WAAU,SAAU,CAAA,EACE,CAAA;CAC3B,CAAA,GACN,oBAAC,gBAAgB,UAAjB,EAA2B,SAAmC,CAAA,CAC1C;EACvB;AACD,WAAW,cAAc,gBAAgB,KAAK;AAE9C,IAAM,kBAAkB,QAAM,YAG3B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,WAAjB;CACO;CACL,WAAW,GAAG,4BAA4B,SAAS;CACnD,GAAI;AACL,CAAA,CACF;AACD,gBAAgB,cAAc,gBAAgB,UAAU"}
@@ -1,43 +1,54 @@
1
1
  "use client";
2
2
  import { cn } from "../../lib/ds-utils.js";
3
3
  import { ShadeScope } from "../../shade-scope.js";
4
+ import { overlayTint, useHostedModal, useModalOpen } from "../../lib/app-overlay.js";
4
5
  import { X } from "lucide-react";
5
6
  import * as React$1 from "react";
6
7
  import { jsx, jsxs } from "react/jsx-runtime";
7
8
  import { cva } from "class-variance-authority";
8
9
  import * as SheetPrimitive from "@radix-ui/react-dialog";
9
10
  //#region src/components/ui/sheet.tsx
10
- var Sheet = SheetPrimitive.Root;
11
+ var Sheet = (props) => {
12
+ const [rootProps, provideOpen] = useModalOpen(props);
13
+ return provideOpen(/* @__PURE__ */ jsx(SheetPrimitive.Root, { ...rootProps }));
14
+ };
11
15
  var SheetTrigger = SheetPrimitive.Trigger;
12
16
  var SheetClose = SheetPrimitive.Close;
13
17
  var SheetPortal = SheetPrimitive.Portal;
14
18
  var SheetOverlay = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(SheetPrimitive.Overlay, {
15
- className: cn("fixed inset-0 z-50 bg-black/10 duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", className),
19
+ className: cn("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", overlayTint("sheet"), className),
16
20
  ...props,
17
21
  ref
18
22
  }));
19
23
  SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
20
24
  var sheetVariants = cva("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", {
21
25
  variants: { side: {
22
- top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
23
- bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
24
- left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
25
- right: "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"
26
+ 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",
27
+ bottom: "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",
28
+ 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",
29
+ right: "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"
26
30
  } },
27
31
  defaultVariants: { side: "right" }
28
32
  });
29
- var SheetContent = React$1.forwardRef(({ side = "right", className, children, ...props }, ref) => /* @__PURE__ */ jsx(SheetPortal, { children: /* @__PURE__ */ jsxs(ShadeScope, { children: [/* @__PURE__ */ jsx(SheetOverlay, {}), /* @__PURE__ */ jsxs(SheetPrimitive.Content, {
30
- ref,
31
- className: cn(sheetVariants({ side }), className),
32
- ...props,
33
- children: [/* @__PURE__ */ jsxs(SheetPrimitive.Close, {
34
- 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", side === "bottom" ? "absolute" : "fixed"),
35
- children: [/* @__PURE__ */ jsx(X, { className: "size-4" }), /* @__PURE__ */ jsx("span", {
36
- className: "sr-only",
37
- children: "Close"
38
- })]
39
- }), children]
40
- })] }) }));
33
+ var SheetContent = React$1.forwardRef(({ side = "right", className, children, ...props }, ref) => {
34
+ const { container, inApp, overlayStyle, ref: contentRef, wrap } = useHostedModal("sheet", ref);
35
+ return /* @__PURE__ */ jsx(SheetPortal, {
36
+ container,
37
+ children: /* @__PURE__ */ jsxs(ShadeScope, { children: [/* @__PURE__ */ jsx(SheetOverlay, { style: overlayStyle }), wrap(/* @__PURE__ */ jsxs(SheetPrimitive.Content, {
38
+ ref: contentRef,
39
+ 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
+ ...props,
41
+ children: [/* @__PURE__ */ jsxs(SheetPrimitive.Close, {
42
+ 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
+ onFocus: inApp ? (event) => event.currentTarget.scrollIntoView({ block: "nearest" }) : void 0,
44
+ children: [/* @__PURE__ */ jsx(X, { className: "size-4" }), /* @__PURE__ */ jsx("span", {
45
+ className: "sr-only",
46
+ children: "Close"
47
+ })]
48
+ }), children]
49
+ }))] })
50
+ });
51
+ });
41
52
  SheetContent.displayName = SheetPrimitive.Content.displayName;
42
53
  var SheetHeader = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
43
54
  className: cn("flex flex-col space-y-1 text-center sm:text-left", className),
@@ -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 { cn } from '@/lib/utils';\nimport { ShadeScope } from '@/shade-scope';\n\nconst Sheet = SheetPrimitive.Root;\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 bg-black/10 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 className,\n )}\n {...props}\n ref={ref}\n />\n));\nSheetOverlay.displayName = SheetPrimitive.Overlay.displayName;\n\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: 'inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',\n bottom:\n 'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',\n left: 'inset-y-0 left-0 h-full 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 'inset-y-0 right-0 h-full 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 <SheetPortal>\n <ShadeScope>\n <SheetOverlay />\n <SheetPrimitive.Content\n ref={ref}\n className={cn(sheetVariants({ side }), className)}\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 side === 'bottom' ? 'absolute' : 'fixed',\n )}\n >\n <X className=\"size-4\" />\n <span className=\"sr-only\">Close</span>\n </SheetPrimitive.Close>\n {children}\n </SheetPrimitive.Content>\n </ShadeScope>\n </SheetPortal>\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":";;;;;;;;;AAWA,IAAM,QAAQ,eAAe;AAE7B,IAAM,eAAe,eAAe;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WAAW,GACT,iFACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,WAAW,cAAc,eAAe,MAAM;AAE9C,IAAM,mBAAmB,QAAM,YAG5B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,eAAe,aAAhB;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 { 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,MAAM,EAAE,WAAW,OAAO,cAAc,KAAK,YAAY,SAAS,eAAe,SAAS,GAAG;CAC7F,OACE,oBAAC,aAAD;EAAwB;YACtB,qBAAC,YAAD,EAAA,UAAA,CACE,oBAAC,cAAD,EA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js";
2
2
  import { ShadeScope } from "../../shade-scope.js";
3
3
  import { safeAreaCollision } from "../../lib/safe-area.js";
4
+ import { usePortalContainer } from "../../lib/app-overlay.js";
4
5
  import * as React$1 from "react";
5
6
  import { jsx } from "react/jsx-runtime";
6
7
  import { cva } from "class-variance-authority";
7
8
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
8
9
  //#region src/components/ui/tooltip.tsx
9
10
  var TooltipInputContext = React$1.createContext(null);
11
+ var TooltipCloseContext = React$1.createContext(void 0);
10
12
  /**
11
13
  * Shared hover timing: `delayDuration` (ms) waits before the first tooltip;
12
14
  * `skipDelayDuration` (ms) lets nearby triggers open immediately after it.
@@ -17,14 +19,12 @@ function TooltipProvider({ children, ...props }) {
17
19
  suppressFocus: false,
18
20
  windowBlurred: false
19
21
  });
20
- React$1.useEffect(() => {
22
+ const watching = React$1.useRef(/* @__PURE__ */ new Map());
23
+ const watch = React$1.useCallback((target) => {
24
+ if (watching.current.has(target)) return;
21
25
  const suppressFocus = () => {
22
26
  inputState.current.suppressFocus = true;
23
27
  };
24
- const onWindowBlur = () => {
25
- suppressFocus();
26
- inputState.current.windowBlurred = true;
27
- };
28
28
  const onKeyDown = () => {
29
29
  inputState.current.suppressFocus = false;
30
30
  inputState.current.windowBlurred = false;
@@ -32,19 +32,35 @@ function TooltipProvider({ children, ...props }) {
32
32
  const onPointerMove = () => {
33
33
  inputState.current.windowBlurred = false;
34
34
  };
35
- document.addEventListener("pointerdown", suppressFocus, true);
36
- document.addEventListener("pointermove", onPointerMove, true);
35
+ target.addEventListener("pointerdown", suppressFocus, true);
36
+ target.addEventListener("pointermove", onPointerMove, true);
37
+ target.addEventListener("keydown", onKeyDown, true);
38
+ watching.current.set(target, () => {
39
+ target.removeEventListener("pointerdown", suppressFocus, true);
40
+ target.removeEventListener("pointermove", onPointerMove, true);
41
+ target.removeEventListener("keydown", onKeyDown, true);
42
+ });
43
+ }, []);
44
+ React$1.useEffect(() => {
45
+ const documents = watching.current;
46
+ watch(document);
47
+ const onWindowBlur = () => {
48
+ inputState.current.suppressFocus = true;
49
+ inputState.current.windowBlurred = true;
50
+ };
37
51
  window.addEventListener("blur", onWindowBlur);
38
- document.addEventListener("keydown", onKeyDown, true);
39
52
  return () => {
40
- document.removeEventListener("pointerdown", suppressFocus, true);
41
- document.removeEventListener("pointermove", onPointerMove, true);
42
53
  window.removeEventListener("blur", onWindowBlur);
43
- document.removeEventListener("keydown", onKeyDown, true);
54
+ for (const stop of documents.values()) stop();
55
+ documents.clear();
44
56
  };
45
- }, []);
57
+ }, [watch]);
58
+ const input = React$1.useMemo(() => ({
59
+ state: inputState,
60
+ watch
61
+ }), [watch]);
46
62
  return /* @__PURE__ */ jsx(TooltipInputContext.Provider, {
47
- value: inputState,
63
+ value: input,
48
64
  children: /* @__PURE__ */ jsx(TooltipPrimitive.Provider, {
49
65
  delayDuration: 1e3,
50
66
  ...props,
@@ -53,7 +69,7 @@ function TooltipProvider({ children, ...props }) {
53
69
  });
54
70
  }
55
71
  function Tooltip({ open: controlledOpen, defaultOpen = false, onOpenChange, ...props }) {
56
- const inputState = React$1.useContext(TooltipInputContext);
72
+ const inputState = React$1.useContext(TooltipInputContext)?.state;
57
73
  const [uncontrolledOpen, setUncontrolledOpen] = React$1.useState(defaultOpen);
58
74
  const open = controlledOpen ?? uncontrolledOpen;
59
75
  const handleOpenChange = React$1.useCallback((nextOpen) => {
@@ -61,23 +77,52 @@ function Tooltip({ open: controlledOpen, defaultOpen = false, onOpenChange, ...p
61
77
  setUncontrolledOpen(nextOpen);
62
78
  onOpenChange?.(nextOpen);
63
79
  }, [inputState, onOpenChange]);
80
+ const close = React$1.useCallback(() => handleOpenChange(false), [handleOpenChange]);
81
+ const view = usePortalContainer()?.ownerDocument.defaultView ?? window;
64
82
  React$1.useEffect(() => {
65
83
  if (!open) return;
66
- const close = () => handleOpenChange(false);
67
- window.addEventListener("blur", close);
68
- return () => window.removeEventListener("blur", close);
69
- }, [open, handleOpenChange]);
70
- return /* @__PURE__ */ jsx(TooltipPrimitive.Root, {
71
- ...props,
72
- defaultOpen,
84
+ view.addEventListener("blur", close);
85
+ return () => view.removeEventListener("blur", close);
86
+ }, [
73
87
  open,
74
- onOpenChange: handleOpenChange
88
+ close,
89
+ view
90
+ ]);
91
+ return /* @__PURE__ */ jsx(TooltipCloseContext.Provider, {
92
+ value: open ? close : void 0,
93
+ children: /* @__PURE__ */ jsx(TooltipPrimitive.Root, {
94
+ ...props,
95
+ defaultOpen,
96
+ open,
97
+ onOpenChange: handleOpenChange
98
+ })
75
99
  });
76
100
  }
77
101
  var TooltipTrigger = React$1.forwardRef(({ onFocus, ...props }, ref) => {
78
- const inputState = React$1.useContext(TooltipInputContext);
102
+ const input = React$1.useContext(TooltipInputContext);
103
+ const inputState = input?.state;
104
+ const container = usePortalContainer();
105
+ React$1.useEffect(() => {
106
+ if (container && container.ownerDocument !== document) input?.watch(container.ownerDocument);
107
+ }, [container, input]);
108
+ const close = React$1.useContext(TooltipCloseContext);
109
+ const trigger = React$1.useRef(null);
110
+ React$1.useEffect(() => {
111
+ const view = container?.ownerDocument.defaultView;
112
+ if (!close || !view || view === window) return;
113
+ const onScroll = (event) => {
114
+ if (event.target instanceof view.Node && event.target.contains(trigger.current)) close();
115
+ };
116
+ view.addEventListener("scroll", onScroll, true);
117
+ return () => view.removeEventListener("scroll", onScroll, true);
118
+ }, [close, container]);
119
+ const triggerRef = React$1.useCallback((element) => {
120
+ trigger.current = element;
121
+ if (typeof ref === "function") ref(element);
122
+ else if (ref) ref.current = element;
123
+ }, [ref]);
79
124
  return /* @__PURE__ */ jsx(TooltipPrimitive.Trigger, {
80
- ref,
125
+ ref: triggerRef,
81
126
  ...props,
82
127
  onFocus: (event) => {
83
128
  onFocus?.(event);
@@ -94,13 +139,16 @@ var tooltipContentVariants = cva("z-50 animate-in overflow-hidden rounded-menu p
94
139
  defaultVariants: { variant: "default" }
95
140
  });
96
141
  var TooltipContent = React$1.forwardRef(({ className, sideOffset = 4, variant, collisionBoundary, ...props }, ref) => {
97
- return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx(ShadeScope, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Content, {
98
- ref,
99
- className: cn(tooltipContentVariants({ variant: variant ?? "white" }), "data-[safe-area]:max-w-(--radix-tooltip-content-available-width)", className),
100
- ...safeAreaCollision(collisionBoundary),
101
- sideOffset,
102
- ...props
103
- }) }) });
142
+ return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, {
143
+ container: usePortalContainer(),
144
+ children: /* @__PURE__ */ jsx(ShadeScope, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Content, {
145
+ ref,
146
+ className: cn(tooltipContentVariants({ variant: variant ?? "white" }), "data-[safe-area]:max-w-(--radix-tooltip-content-available-width)", className),
147
+ ...safeAreaCollision(collisionBoundary, usePortalContainer()),
148
+ sideOffset,
149
+ ...props
150
+ }) })
151
+ });
104
152
  });
105
153
  TooltipContent.displayName = TooltipPrimitive.Content.displayName;
106
154
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","names":[],"sources":["../../../src/components/ui/tooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport { cn } from '@/lib/utils';\nimport { ShadeScope } from '@/shade-scope';\nimport { safeAreaCollision } from '@/lib/safe-area';\n\nconst TooltipInputContext = React.createContext<React.RefObject<{\n suppressFocus: boolean;\n windowBlurred: boolean;\n}> | null>(null);\n\n/**\n * Shared hover timing: `delayDuration` (ms) waits before the first tooltip;\n * `skipDelayDuration` (ms) lets nearby triggers open immediately after it.\n * Individual Tooltip roots can override delayDuration. Keyboard focus opens immediately.\n */\nfunction TooltipProvider({\n children,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n const inputState = React.useRef({ suppressFocus: false, windowBlurred: false });\n\n React.useEffect(() => {\n const suppressFocus = () => {\n inputState.current.suppressFocus = true;\n };\n const onWindowBlur = () => {\n suppressFocus();\n inputState.current.windowBlurred = true;\n };\n const onKeyDown = () => {\n inputState.current.suppressFocus = false;\n inputState.current.windowBlurred = false;\n };\n const onPointerMove = () => {\n inputState.current.windowBlurred = false;\n };\n document.addEventListener('pointerdown', suppressFocus, true);\n document.addEventListener('pointermove', onPointerMove, true);\n window.addEventListener('blur', onWindowBlur);\n document.addEventListener('keydown', onKeyDown, true);\n return () => {\n document.removeEventListener('pointerdown', suppressFocus, true);\n document.removeEventListener('pointermove', onPointerMove, true);\n window.removeEventListener('blur', onWindowBlur);\n document.removeEventListener('keydown', onKeyDown, true);\n };\n }, []);\n\n return (\n <TooltipInputContext.Provider value={inputState}>\n <TooltipPrimitive.Provider delayDuration={1000} {...props}>\n {children}\n </TooltipPrimitive.Provider>\n </TooltipInputContext.Provider>\n );\n}\n\nfunction Tooltip({\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n const inputState = React.useContext(TooltipInputContext);\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);\n const open = controlledOpen ?? uncontrolledOpen;\n const handleOpenChange = React.useCallback(\n (nextOpen: boolean) => {\n // Radix may finish a hover timer after window blur. Wait for fresh input.\n if (nextOpen && inputState?.current?.windowBlurred) {\n return;\n }\n setUncontrolledOpen(nextOpen);\n onOpenChange?.(nextOpen);\n },\n [inputState, onOpenChange],\n );\n\n React.useEffect(() => {\n if (!open) {\n return;\n }\n const close = () => handleOpenChange(false);\n window.addEventListener('blur', close);\n return () => window.removeEventListener('blur', close);\n }, [open, handleOpenChange]);\n\n return (\n <TooltipPrimitive.Root\n {...props}\n defaultOpen={defaultOpen}\n open={open}\n onOpenChange={handleOpenChange}\n />\n );\n}\n\nconst TooltipTrigger = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Trigger>\n>(({ onFocus, ...props }, ref) => {\n const inputState = React.useContext(TooltipInputContext);\n\n return (\n <TooltipPrimitive.Trigger\n ref={ref}\n {...props}\n onFocus={(event) => {\n onFocus?.(event);\n // Menus and browser windows restore focus without a new interaction.\n // Only deliberate keyboard focus or normal hover should show a tooltip.\n if (inputState?.current?.suppressFocus) {\n event.preventDefault();\n }\n }}\n />\n );\n});\nTooltipTrigger.displayName = TooltipPrimitive.Trigger.displayName;\n\nconst tooltipContentVariants = cva(\n 'z-50 animate-in overflow-hidden rounded-menu px-3 py-1.5 text-xs fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95',\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground dark:bg-popover dark:text-popover-foreground',\n white: 'bg-surface-elevated-2 text-foreground shadow-md',\n },\n },\n defaultVariants: { variant: 'default' },\n },\n);\n\nexport interface TooltipContentProps\n extends\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>,\n VariantProps<typeof tooltipContentVariants> {}\n\nconst TooltipContent = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Content>,\n TooltipContentProps\n>(({ className, sideOffset = 4, variant, collisionBoundary, ...props }, ref) => {\n return (\n <TooltipPrimitive.Portal>\n <ShadeScope>\n <TooltipPrimitive.Content\n ref={ref}\n className={cn(\n tooltipContentVariants({ variant: variant ?? 'white' }),\n 'data-[safe-area]:max-w-(--radix-tooltip-content-available-width)',\n className,\n )}\n {...safeAreaCollision(collisionBoundary)}\n sideOffset={sideOffset}\n {...props}\n />\n </ShadeScope>\n </TooltipPrimitive.Portal>\n );\n});\nTooltipContent.displayName = TooltipPrimitive.Content.displayName;\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };\n"],"mappings":";;;;;;;;AAQA,IAA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CAC3B;CAEA,QAAM,gBAAgB;EACpB,IAAI,CAAC,MACH;EAEF,MAAM,cAAc,iBAAiB,KAAK;EAC1C,OAAO,iBAAiB,QAAQ,KAAK;EACrC,aAAa,OAAO,oBAAoB,QAAQ,KAAK;CACvD,GAAG,CAAC,MAAM,gBAAgB,CAAC;CAE3B,OACE,oBAAC,iBAAiB,MAAlB;EACE,GAAI;EACS;EACP;EACN,cAAc;CACf,CAAA;AAEL;AAEA,IAAM,iBAAiB,QAAM,YAG1B,EAAE,SAAS,GAAG,SAAS,QAAQ;CAChC,MAAM,aAAa,QAAM,WAAW,mBAAmB;CAEvD,OACE,oBAAC,iBAAiB,SAAlB;EACO;EACL,GAAI;EACJ,UAAU,UAAU;GAClB,UAAU,KAAK;GAGf,IAAI,YAAY,SAAS,eACvB,MAAM,eAAe;EAEzB;CACD,CAAA;AAEL,CAAC;AACD,eAAe,cAAc,iBAAiB,QAAQ;AAEtD,IAAM,yBAAyB,IAC7B,oVACA;CACE,UAAU,EACR,SAAS;EACP,SAAS;EACT,OAAO;CACT,EACF;CACA,iBAAiB,EAAE,SAAS,UAAU;AACxC,CACF;AAOA,IAAM,iBAAiB,QAAM,YAG1B,EAAE,WAAW,aAAa,GAAG,SAAS,mBAAmB,GAAG,SAAS,QAAQ;CAC9E,OACE,oBAAC,iBAAiB,QAAlB,EAAA,UACE,oBAAC,YAAD,EAAA,UACE,oBAAC,iBAAiB,SAAlB;EACO;EACL,WAAW,GACT,uBAAuB,EAAE,SAAS,WAAW,QAAQ,CAAC,GACtD,oEACA,SACF;EACA,GAAI,kBAAkB,iBAAiB;EAC3B;EACZ,GAAI;CACL,CAAA,EACS,CAAA,EACW,CAAA;AAE7B,CAAC;AACD,eAAe,cAAc,iBAAiB,QAAQ"}
1
+ {"version":3,"file":"tooltip.js","names":[],"sources":["../../../src/components/ui/tooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport { usePortalContainer } from '@/lib/app-overlay';\nimport { cn } from '@/lib/utils';\nimport { ShadeScope } from '@/shade-scope';\nimport { safeAreaCollision } from '@/lib/safe-area';\n\ninterface TooltipInput {\n state: React.RefObject<{ suppressFocus: boolean; windowBlurred: boolean }>;\n watch: (target: Document) => void;\n}\n\nconst TooltipInputContext = React.createContext<TooltipInput | null>(null);\n\nconst TooltipCloseContext = React.createContext<(() => void) | undefined>(undefined);\n\n/**\n * Shared hover timing: `delayDuration` (ms) waits before the first tooltip;\n * `skipDelayDuration` (ms) lets nearby triggers open immediately after it.\n * Individual Tooltip roots can override delayDuration. Keyboard focus opens immediately.\n */\nfunction TooltipProvider({\n children,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n const inputState = React.useRef({ suppressFocus: false, windowBlurred: false });\n const watching = React.useRef(new Map<Document, () => void>());\n\n const watch = React.useCallback((target: Document) => {\n if (watching.current.has(target)) {\n return;\n }\n const suppressFocus = () => {\n inputState.current.suppressFocus = true;\n };\n const onKeyDown = () => {\n inputState.current.suppressFocus = false;\n inputState.current.windowBlurred = false;\n };\n const onPointerMove = () => {\n inputState.current.windowBlurred = false;\n };\n target.addEventListener('pointerdown', suppressFocus, true);\n target.addEventListener('pointermove', onPointerMove, true);\n target.addEventListener('keydown', onKeyDown, true);\n watching.current.set(target, () => {\n target.removeEventListener('pointerdown', suppressFocus, true);\n target.removeEventListener('pointermove', onPointerMove, true);\n target.removeEventListener('keydown', onKeyDown, true);\n });\n }, []);\n\n React.useEffect(() => {\n const documents = watching.current;\n watch(document);\n const onWindowBlur = () => {\n inputState.current.suppressFocus = true;\n inputState.current.windowBlurred = true;\n };\n window.addEventListener('blur', onWindowBlur);\n return () => {\n window.removeEventListener('blur', onWindowBlur);\n for (const stop of documents.values()) {\n stop();\n }\n documents.clear();\n };\n }, [watch]);\n\n const input = React.useMemo(() => ({ state: inputState, watch }), [watch]);\n\n return (\n <TooltipInputContext.Provider value={input}>\n <TooltipPrimitive.Provider delayDuration={1000} {...props}>\n {children}\n </TooltipPrimitive.Provider>\n </TooltipInputContext.Provider>\n );\n}\n\nfunction Tooltip({\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n const inputState = React.useContext(TooltipInputContext)?.state;\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);\n const open = controlledOpen ?? uncontrolledOpen;\n const handleOpenChange = React.useCallback(\n (nextOpen: boolean) => {\n // Radix may finish a hover timer after window blur. Wait for fresh input.\n if (nextOpen && inputState?.current?.windowBlurred) {\n return;\n }\n setUncontrolledOpen(nextOpen);\n onOpenChange?.(nextOpen);\n },\n [inputState, onOpenChange],\n );\n\n const close = React.useCallback(() => handleOpenChange(false), [handleOpenChange]);\n const view = usePortalContainer()?.ownerDocument.defaultView ?? window;\n React.useEffect(() => {\n if (!open) {\n return;\n }\n view.addEventListener('blur', close);\n return () => view.removeEventListener('blur', close);\n }, [open, close, view]);\n\n return (\n <TooltipCloseContext.Provider value={open ? close : undefined}>\n <TooltipPrimitive.Root\n {...props}\n defaultOpen={defaultOpen}\n open={open}\n onOpenChange={handleOpenChange}\n />\n </TooltipCloseContext.Provider>\n );\n}\n\nconst TooltipTrigger = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Trigger>\n>(({ onFocus, ...props }, ref) => {\n const input = React.useContext(TooltipInputContext);\n const inputState = input?.state;\n // In the overlay, input arrives in the overlay's document, and the page's window has lost focus.\n const container = usePortalContainer();\n React.useEffect(() => {\n if (container && container.ownerDocument !== document) {\n input?.watch(container.ownerDocument);\n }\n }, [container, input]);\n\n // Radix closes the tooltip as what its trigger is in scrolls, but only in the page's window.\n const close = React.useContext(TooltipCloseContext);\n const trigger = React.useRef<HTMLButtonElement | null>(null);\n React.useEffect(() => {\n const view = container?.ownerDocument.defaultView;\n if (!close || !view || view === window) {\n return;\n }\n const onScroll = (event: Event) => {\n if (event.target instanceof view.Node && event.target.contains(trigger.current)) {\n close();\n }\n };\n view.addEventListener('scroll', onScroll, true);\n return () => view.removeEventListener('scroll', onScroll, true);\n }, [close, container]);\n const triggerRef = React.useCallback(\n (element: HTMLButtonElement | null) => {\n trigger.current = element;\n if (typeof ref === 'function') {\n ref(element);\n } else if (ref) {\n ref.current = element;\n }\n },\n [ref],\n );\n\n return (\n <TooltipPrimitive.Trigger\n ref={triggerRef}\n {...props}\n onFocus={(event) => {\n onFocus?.(event);\n // Menus and browser windows restore focus without a new interaction.\n // Only deliberate keyboard focus or normal hover should show a tooltip.\n if (inputState?.current?.suppressFocus) {\n event.preventDefault();\n }\n }}\n />\n );\n});\nTooltipTrigger.displayName = TooltipPrimitive.Trigger.displayName;\n\nconst tooltipContentVariants = cva(\n 'z-50 animate-in overflow-hidden rounded-menu px-3 py-1.5 text-xs fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95',\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground dark:bg-popover dark:text-popover-foreground',\n white: 'bg-surface-elevated-2 text-foreground shadow-md',\n },\n },\n defaultVariants: { variant: 'default' },\n },\n);\n\nexport interface TooltipContentProps\n extends\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>,\n VariantProps<typeof tooltipContentVariants> {}\n\nconst TooltipContent = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Content>,\n TooltipContentProps\n>(({ className, sideOffset = 4, variant, collisionBoundary, ...props }, ref) => {\n return (\n <TooltipPrimitive.Portal container={usePortalContainer()}>\n <ShadeScope>\n <TooltipPrimitive.Content\n ref={ref}\n className={cn(\n tooltipContentVariants({ variant: variant ?? 'white' }),\n 'data-[safe-area]:max-w-(--radix-tooltip-content-available-width)',\n className,\n )}\n {...safeAreaCollision(collisionBoundary, usePortalContainer())}\n sideOffset={sideOffset}\n {...props}\n />\n </ShadeScope>\n </TooltipPrimitive.Portal>\n );\n});\nTooltipContent.displayName = TooltipPrimitive.Content.displayName;\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };\n"],"mappings":";;;;;;;;;AAcA,IAAM,sBAAsB,QAAM,cAAmC,IAAI;AAEzE,IAAM,sBAAsB,QAAM,cAAwC,KAAA,CAAS;;;;;;AAOnF,SAAS,gBAAgB,EACvB,UACA,GAAG,SACsD;CACzD,MAAM,aAAa,QAAM,OAAO;EAAE,eAAe;EAAO,eAAe;CAAM,CAAC;CAC9E,MAAM,WAAW,QAAM,uBAAO,IAAI,IAA0B,CAAC;CAE7D,MAAM,QAAQ,QAAM,aAAa,WAAqB;EACpD,IAAI,SAAS,QAAQ,IAAI,MAAM,GAC7B;EAEF,MAAM,sBAAsB;GAC1B,WAAW,QAAQ,gBAAgB;EACrC;EACA,MAAM,kBAAkB;GACtB,WAAW,QAAQ,gBAAgB;GACnC,WAAW,QAAQ,gBAAgB;EACrC;EACA,MAAM,sBAAsB;GAC1B,WAAW,QAAQ,gBAAgB;EACrC;EACA,OAAO,iBAAiB,eAAe,eAAe,IAAI;EAC1D,OAAO,iBAAiB,eAAe,eAAe,IAAI;EAC1D,OAAO,iBAAiB,WAAW,WAAW,IAAI;EAClD,SAAS,QAAQ,IAAI,cAAc;GACjC,OAAO,oBAAoB,eAAe,eAAe,IAAI;GAC7D,OAAO,oBAAoB,eAAe,eAAe,IAAI;GAC7D,OAAO,oBAAoB,WAAW,WAAW,IAAI;EACvD,CAAC;CACH,GAAG,CAAC,CAAC;CAEL,QAAM,gBAAgB;EACpB,MAAM,YAAY,SAAS;EAC3B,MAAM,QAAQ;EACd,MAAM,qBAAqB;GACzB,WAAW,QAAQ,gBAAgB;GACnC,WAAW,QAAQ,gBAAgB;EACrC;EACA,OAAO,iBAAiB,QAA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B;EAAyB,WAAW,mBAAmB;YACrD,oBAAC,YAAD,EAAA,UACE,oBAAC,iBAAiB,SAAlB;GACO;GACL,WAAW,GACT,uBAAuB,EAAE,SAAS,WAAW,QAAQ,CAAC,GACtD,oEACA,SACF;GACA,GAAI,kBAAkB,mBAAmB,mBAAmB,CAAC;GACjD;GACZ,GAAI;EACL,CAAA,EACS,CAAA;CACW,CAAA;AAE7B,CAAC;AACD,eAAe,cAAc,iBAAiB,QAAQ"}
package/es/components.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as IconComponents } from "./icon--CakqPdG.js";
2
- import { Toaster } from "./components/ui/sonner.js";
3
2
  import { FLOATING_SIDEBAR_BUMP, FLOATING_SIDEBAR_CLOSED_FOOTPRINT, FLOATING_SIDEBAR_CLOSED_SIZE, FLOATING_SIDEBAR_DURATION, FLOATING_SIDEBAR_EASE, FLOATING_SIDEBAR_EASE_DURATION, FLOATING_SIDEBAR_INSET, FLOATING_SIDEBAR_OPEN_WIDTH, FLOATING_SIDEBAR_SPRING, getFloatingSidebarGapWidth, getFloatingSidebarTiming } from "./components/ui/floating-sidebar-metrics.js";
3
+ import { Toaster } from "./components/ui/sonner.js";
4
4
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./components/ui/tooltip.js";
5
5
  import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "./components/ui/dropdown-menu.js";
6
6
  import { buttonVariants } from "./components/ui/button-variants.js";
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as IconComponents } from "./icon--CakqPdG.js";
2
2
  import { SHADE_TOKEN_NAMES, shadeToken } from "./tokens.js";
3
- import { Toaster } from "./components/ui/sonner.js";
4
3
  import { FLOATING_SIDEBAR_BUMP, FLOATING_SIDEBAR_CLOSED_FOOTPRINT, FLOATING_SIDEBAR_CLOSED_SIZE, FLOATING_SIDEBAR_DURATION, FLOATING_SIDEBAR_EASE, FLOATING_SIDEBAR_EASE_DURATION, FLOATING_SIDEBAR_INSET, FLOATING_SIDEBAR_OPEN_WIDTH, FLOATING_SIDEBAR_SPRING, getFloatingSidebarGapWidth, getFloatingSidebarTiming } from "./components/ui/floating-sidebar-metrics.js";
4
+ import { Toaster } from "./components/ui/sonner.js";
5
5
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./components/ui/tooltip.js";
6
6
  import { Box } from "./components/primitives/box.js";
7
7
  import { Container } from "./components/primitives/container.js";
@@ -0,0 +1,151 @@
1
+ import { hasSafeArea } from "./safe-area.js";
2
+ import * as React$1 from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/lib/app-overlay.tsx
5
+ var OVERLAY_TINTS = {
6
+ dialog: "bg-black/30 dark:bg-black/60",
7
+ sheet: "bg-black/10"
8
+ };
9
+ /** A modal's tint classes. Admin draws the same tint behind an app's dialogs and sheets. */
10
+ var overlayTint = (tint) => OVERLAY_TINTS[tint];
11
+ /**
12
+ * Centres a dialog on the window, moved only as far as it must to stay inside the safe area.
13
+ * One wider than the safe area is centred on it instead.
14
+ */
15
+ var SAFE_AREA_DIALOG_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
+ 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
+ var AppOverlayContext = React$1.createContext(void 0);
18
+ /** Content portalled from a hosted dialog renders in the overlay too, above the dialog. */
19
+ var PortalContainerContext = React$1.createContext(void 0);
20
+ var ModalStateContext = React$1.createContext(void 0);
21
+ /**
22
+ * Wraps a Radix dialog `Root`'s props so its content re-renders when it opens, even from its own
23
+ * trigger, and can then decide whether to render in the overlay. Radix re-renders only its
24
+ * portal, and doesn't expose `modal` to the content.
25
+ */
26
+ function useModalOpen(props) {
27
+ const { open, defaultOpen, onOpenChange, modal = true } = props;
28
+ const [uncontrolled, setUncontrolled] = React$1.useState(defaultOpen ?? false);
29
+ const isOpen = open ?? uncontrolled;
30
+ const handleOpenChange = React$1.useCallback((next) => {
31
+ setUncontrolled(next);
32
+ onOpenChange?.(next);
33
+ }, [onOpenChange]);
34
+ const state = React$1.useMemo(() => ({
35
+ open: isOpen,
36
+ modal
37
+ }), [isOpen, modal]);
38
+ const provide = React$1.useCallback((children) => /* @__PURE__ */ jsx(ModalStateContext.Provider, {
39
+ value: state,
40
+ children
41
+ }), [state]);
42
+ return [{
43
+ ...props,
44
+ onOpenChange: handleOpenChange
45
+ }, provide];
46
+ }
47
+ /** The container for a Radix `Portal`: the overlay inside a hosted dialog, else the default. */
48
+ var usePortalContainer = () => React$1.useContext(PortalContainerContext);
49
+ function setRef(ref, value) {
50
+ if (typeof ref === "function") ref(value);
51
+ else if (ref) ref.current = value;
52
+ }
53
+ /**
54
+ * Transparent so Admin's tint shows through, but still there so a press beside the dialog closes
55
+ * it. A style rather than a class, to override the overlay's colour in either theme.
56
+ */
57
+ var HOSTED_OVERLAY_STYLE = { background: "transparent" };
58
+ /**
59
+ * Renders a dialog, alert dialog or sheet in the app's overlay when there is one, holding the
60
+ * overlay while its content is mounted.
61
+ */
62
+ function useHostedModal(tint, forwardedRef) {
63
+ const overlay = React$1.useContext(AppOverlayContext);
64
+ const inherited = usePortalContainer();
65
+ const state = React$1.useContext(ModalStateContext);
66
+ const open = state?.open;
67
+ const modal = state?.modal ?? true;
68
+ const place = () => modal ? overlay?.container() : void 0;
69
+ const [placed, setPlaced] = React$1.useState(() => ({
70
+ open,
71
+ container: open === false ? void 0 : place()
72
+ }));
73
+ let placement = placed;
74
+ if (open === void 0) placement = {
75
+ ...placed,
76
+ container: place()
77
+ };
78
+ else if (open !== placed.open) {
79
+ placement = open && !placed.open ? {
80
+ open,
81
+ container: place()
82
+ } : {
83
+ ...placed,
84
+ open
85
+ };
86
+ setPlaced(placement);
87
+ }
88
+ const { container } = placement;
89
+ const hosted = modal && container !== void 0;
90
+ const latest = React$1.useRef({
91
+ overlay,
92
+ hosted,
93
+ tint
94
+ });
95
+ React$1.useInsertionEffect(() => {
96
+ latest.current = {
97
+ overlay,
98
+ hosted,
99
+ tint
100
+ };
101
+ });
102
+ const content = React$1.useRef(null);
103
+ const attached = React$1.useRef(forwardedRef);
104
+ React$1.useLayoutEffect(() => {
105
+ if (attached.current !== forwardedRef) {
106
+ if (content.current) {
107
+ setRef(attached.current, null);
108
+ setRef(forwardedRef, content.current);
109
+ }
110
+ attached.current = forwardedRef;
111
+ }
112
+ }, [forwardedRef]);
113
+ const cleanup = React$1.useRef(void 0);
114
+ const ref = React$1.useCallback((element) => {
115
+ const current = latest.current;
116
+ content.current = element;
117
+ setRef(attached.current, element);
118
+ cleanup.current?.();
119
+ cleanup.current = void 0;
120
+ if (!element || !current.overlay || !current.hosted) return;
121
+ const hold = current.overlay.hold(current.tint, element);
122
+ const sync = () => hold.setOpen(element.getAttribute("data-state") === "open");
123
+ sync();
124
+ const observer = new ((element.ownerDocument.defaultView?.MutationObserver) ?? MutationObserver)(sync);
125
+ observer.observe(element, {
126
+ attributes: true,
127
+ attributeFilter: ["data-state"]
128
+ });
129
+ cleanup.current = () => {
130
+ observer.disconnect();
131
+ hold.release();
132
+ };
133
+ }, []);
134
+ const wrap = React$1.useCallback((children) => hosted ? /* @__PURE__ */ jsx(PortalContainerContext.Provider, {
135
+ value: container,
136
+ children
137
+ }) : children, [hosted, container]);
138
+ const portal = modal ? container : inherited;
139
+ return {
140
+ container: portal,
141
+ inApp: hasSafeArea(portal),
142
+ modal,
143
+ overlayStyle: hosted ? HOSTED_OVERLAY_STYLE : void 0,
144
+ ref,
145
+ wrap
146
+ };
147
+ }
148
+ //#endregion
149
+ export { AppOverlayContext, SAFE_AREA_DIALOG_HEIGHT, SAFE_AREA_DIALOG_X, overlayTint, useHostedModal, useModalOpen, usePortalContainer };
150
+
151
+ //# sourceMappingURL=app-overlay.js.map