@kortix/ui 0.15.6 → 0.15.8

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 (226) hide show
  1. package/README.md +7 -7
  2. package/dist/_vendor/kortix-shared.js +36 -1
  3. package/dist/_vendor/shared/my-kortix-agent.d.ts +7 -0
  4. package/dist/_vendor/shared/pixel-mark.d.ts +18 -0
  5. package/dist/customize/connectors/catalog/connector-categories.d.ts +2 -2
  6. package/dist/customize/connectors/catalog/connector-categories.js +2 -2
  7. package/dist/customize/connectors/detail/connector-modal.js +1 -1
  8. package/dist/customize/providers/provider-accordion.js +3 -2
  9. package/dist/customize/providers/provider-connect.d.ts +7 -0
  10. package/dist/customize/providers/provider-connect.js +21 -2
  11. package/dist/customize/providers/provider-sheet.js +3 -2
  12. package/dist/customize/sections/gateway-view.d.ts +2 -2
  13. package/dist/customize/sections/gateway-view.js +30 -15
  14. package/dist/customize/sections/llm-provider/chatgpt-subscription-connect.d.ts +3 -1
  15. package/dist/customize/sections/llm-provider/chatgpt-subscription-connect.js +2 -2
  16. package/dist/customize/sections/view/account-secret-resources-panel.js +8 -5
  17. package/dist/customize/sections/view/agent-editor-basics-fields.js +1 -1
  18. package/dist/customize/sections/view/gateway/gateway-logs.d.ts +1 -1
  19. package/dist/customize/sections/view/git-view.js +1 -1
  20. package/dist/customize/sections/view/permission-editor.js +1 -1
  21. package/dist/customize/sections/view/review-center-connected.js +15 -3
  22. package/dist/customize/sections/view/subscription-usage.d.ts +269 -17
  23. package/dist/customize/sections/view/subscription-usage.js +197 -54
  24. package/dist/customize/shared/entity/entity-modal.js +8 -10
  25. package/dist/files/project/components/drive-toolbar.d.ts +1 -1
  26. package/dist/files/project/components/drive-toolbar.js +1 -1
  27. package/dist/files/project/store/version-store.d.ts +1 -1
  28. package/dist/files/renderers/shared/scroll-area-compat.d.ts +6 -6
  29. package/dist/files/renderers/shared/scroll-area-compat.js +7 -9
  30. package/dist/files/renderers/shared/select-compat.js +3 -7
  31. package/dist/files/viewer/file-preview-modal.d.ts +10 -11
  32. package/dist/files/viewer/file-preview-modal.js +17 -18
  33. package/dist/i18n/en.d.ts +40 -47
  34. package/dist/i18n/en.js +47 -54
  35. package/dist/i18n/ui-catalog/app-registry-translation-keys.generated.js +5 -0
  36. package/dist/index.js +1 -1
  37. package/dist/internal/account-hub/account-hub-location.js +2 -2
  38. package/dist/internal/account-hub/use-account-members.d.ts +28 -1
  39. package/dist/internal/account-hub/use-account-members.js +27 -10
  40. package/dist/internal/auth/auth-primitives.d.ts +27 -0
  41. package/dist/internal/auth/auth-primitives.js +21 -0
  42. package/dist/internal/billing/index.d.ts +1 -0
  43. package/dist/internal/billing/index.js +2 -0
  44. package/dist/internal/billing/use-free-grant-unspent.d.ts +10 -0
  45. package/dist/internal/billing/use-free-grant-unspent.js +20 -0
  46. package/dist/internal/components/agent-mark.d.ts +1 -8
  47. package/dist/internal/components/agent-mark.js +2 -19
  48. package/dist/internal/lib/billing/billing-gate-state.d.ts +20 -0
  49. package/dist/internal/lib/billing/billing-gate-state.js +22 -0
  50. package/dist/internal/lib/error-handler.js +0 -2
  51. package/dist/internal/lib/navigation/modified-click.js +2 -2
  52. package/dist/internal/lib/pixel-mark.d.ts +3 -20
  53. package/dist/internal/lib/pixel-mark.js +3 -34
  54. package/dist/internal/notifications/notification-inbox.js +1 -1
  55. package/dist/internal/stores/active-space-store.d.ts +1 -1
  56. package/dist/internal/stores/browser-recents-store.d.ts +1 -1
  57. package/dist/internal/stores/current-account-store.d.ts +1 -1
  58. package/dist/internal/stores/first-chat-store.d.ts +1 -1
  59. package/dist/internal/stores/mobile-app-promo-store.d.ts +1 -1
  60. package/dist/internal/stores/session-browser-store.d.ts +1 -1
  61. package/dist/internal/stores/session-expanded-store.d.ts +1 -1
  62. package/dist/internal/stores/session-filter-store.d.ts +1 -1
  63. package/dist/internal/stores/session-history-view-store.d.ts +1 -1
  64. package/dist/internal/stores/session-hover-store.d.ts +1 -1
  65. package/dist/internal/stores/session-hover-store.js +1 -1
  66. package/dist/internal/stores/session-panel-memory-store.d.ts +1 -1
  67. package/dist/internal/stores/sound-store.d.ts +1 -1
  68. package/dist/internal/stores/tab-store.d.ts +1 -1
  69. package/dist/internal/stores/upgrade-dialog-store.d.ts +0 -2
  70. package/dist/internal/stores/upgrade-dialog-store.js +0 -2
  71. package/dist/internal/stores/user-preferences-store.d.ts +1 -1
  72. package/dist/internal/stores/web-notification-store.d.ts +1 -1
  73. package/dist/lib/base-ui-compat.d.ts +149 -0
  74. package/dist/lib/base-ui-compat.js +339 -0
  75. package/dist/lib/portal-container.d.ts +3 -7
  76. package/dist/lib/portal-container.js +5 -3
  77. package/dist/lib/z-stack.d.ts +4 -4
  78. package/dist/lib/z-stack.js +5 -5
  79. package/dist/markdown/setup-links/approval-decision.d.ts +1 -1
  80. package/dist/markdown/setup-links/approval-decision.js +1 -1
  81. package/dist/primitives/accordion.d.ts +36 -5
  82. package/dist/primitives/accordion.js +41 -8
  83. package/dist/primitives/alert-dialog.d.ts +33 -11
  84. package/dist/primitives/alert-dialog.js +41 -19
  85. package/dist/primitives/avatar.d.ts +5 -2
  86. package/dist/primitives/avatar.js +3 -3
  87. package/dist/primitives/badge.js +1 -1
  88. package/dist/primitives/breadcrumb.js +1 -1
  89. package/dist/primitives/button-group.js +3 -3
  90. package/dist/primitives/button.js +1 -1
  91. package/dist/primitives/checkbox.d.ts +14 -5
  92. package/dist/primitives/checkbox.js +24 -9
  93. package/dist/primitives/collapsible.d.ts +16 -4
  94. package/dist/primitives/collapsible.js +18 -7
  95. package/dist/primitives/command-core.d.ts +121 -0
  96. package/dist/primitives/command-core.js +642 -0
  97. package/dist/primitives/command.d.ts +38 -4
  98. package/dist/primitives/command.js +22 -13
  99. package/dist/primitives/context-menu.d.ts +61 -31
  100. package/dist/primitives/context-menu.js +40 -53
  101. package/dist/primitives/dialog.d.ts +48 -10
  102. package/dist/primitives/dialog.js +48 -19
  103. package/dist/primitives/disclosure.d.ts +1 -1
  104. package/dist/primitives/disclosure.js +2 -2
  105. package/dist/primitives/drawer.d.ts +28 -9
  106. package/dist/primitives/drawer.js +42 -18
  107. package/dist/primitives/dropdown-menu.d.ts +55 -33
  108. package/dist/primitives/dropdown-menu.js +46 -82
  109. package/dist/primitives/faded-scroll-area.js +2 -1
  110. package/dist/primitives/hint.js +3 -3
  111. package/dist/primitives/hover-card.d.ts +17 -5
  112. package/dist/primitives/hover-card.js +45 -8
  113. package/dist/primitives/item.js +2 -2
  114. package/dist/primitives/label.d.ts +5 -2
  115. package/dist/primitives/label.js +10 -3
  116. package/dist/primitives/menu-base.d.ts +150 -0
  117. package/dist/primitives/menu-base.js +171 -0
  118. package/dist/primitives/menu-recipe.d.ts +1 -1
  119. package/dist/primitives/menu-recipe.js +2 -7
  120. package/dist/primitives/modal.d.ts +19 -52
  121. package/dist/primitives/modal.js +24 -28
  122. package/dist/primitives/navigation-menu.d.ts +36 -11
  123. package/dist/primitives/navigation-menu.js +31 -12
  124. package/dist/primitives/popover.d.ts +31 -6
  125. package/dist/primitives/popover.js +79 -12
  126. package/dist/primitives/preview-image.d.ts +18 -7
  127. package/dist/primitives/preview-image.js +14 -11
  128. package/dist/primitives/progress.d.ts +4 -2
  129. package/dist/primitives/progress.js +4 -3
  130. package/dist/primitives/project-icon-picker.js +2 -2
  131. package/dist/primitives/radio-group.d.ts +28 -5
  132. package/dist/primitives/radio-group.js +18 -10
  133. package/dist/primitives/scroll-area.d.ts +2 -2
  134. package/dist/primitives/scroll-area.js +8 -3
  135. package/dist/primitives/select.d.ts +55 -12
  136. package/dist/primitives/select.js +93 -36
  137. package/dist/primitives/separator.d.ts +6 -2
  138. package/dist/primitives/separator.js +10 -2
  139. package/dist/primitives/sheet.d.ts +17 -10
  140. package/dist/primitives/sheet.js +19 -22
  141. package/dist/primitives/sidebar-menu-primitives.js +8 -8
  142. package/dist/primitives/slider-native.d.ts +2 -2
  143. package/dist/primitives/slider-native.js +11 -9
  144. package/dist/primitives/slider.d.ts +24 -6
  145. package/dist/primitives/slider.js +26 -24
  146. package/dist/primitives/slot.d.ts +6 -0
  147. package/dist/primitives/slot.js +7 -0
  148. package/dist/primitives/split-sheet.js +1 -1
  149. package/dist/primitives/stepper.js +1 -1
  150. package/dist/primitives/switch.d.ts +16 -3
  151. package/dist/primitives/switch.js +7 -6
  152. package/dist/primitives/tabs.d.ts +36 -20
  153. package/dist/primitives/tabs.js +131 -102
  154. package/dist/primitives/toggle.d.ts +16 -3
  155. package/dist/primitives/toggle.js +8 -3
  156. package/dist/primitives/tooltip.d.ts +24 -5
  157. package/dist/primitives/tooltip.js +32 -10
  158. package/dist/primitives/type-to-confirm-dialog.d.ts +1 -1
  159. package/dist/primitives/type-to-confirm-dialog.js +1 -1
  160. package/dist/session/composer/animated-placeholder.js +1 -1
  161. package/dist/session/composer/chat-input/chat-input-control.js +3 -3
  162. package/dist/session/composer/editor/composer-editor.js +1 -1
  163. package/dist/session/composer/menus/menu-shell.d.ts +1 -1
  164. package/dist/session/composer/menus/menu-shell.js +1 -1
  165. package/dist/session/composer/menus/mount.js +1 -1
  166. package/dist/session/composer/reasoning-effort-selector.js +1 -1
  167. package/dist/session/header/session-site-header.js +2 -2
  168. package/dist/session/header/subagent-hover-card.js +2 -2
  169. package/dist/session/media/image-preview.js +1 -1
  170. package/dist/session/models/model-selector.d.ts +1 -1
  171. package/dist/session/models/model-selector.js +18 -12
  172. package/dist/session/models/subscription-switcher.d.ts +37 -0
  173. package/dist/session/models/subscription-switcher.js +97 -0
  174. package/dist/session/models/subscription-windows.d.ts +40 -0
  175. package/dist/session/models/subscription-windows.js +86 -0
  176. package/dist/session/overrides/session-overrides-control.js +3 -3
  177. package/dist/session/panel/diff-dialog.js +1 -1
  178. package/dist/session/panel/easy/detail-view.js +3 -3
  179. package/dist/session/panel/mobile-tool-drawer.js +2 -2
  180. package/dist/session/panel/panel-fallback.js +1 -1
  181. package/dist/session/panel/session-files-explorer.d.ts +1 -1
  182. package/dist/session/panel/session-files-explorer.js +1 -1
  183. package/dist/session/prompts/ask-deck.d.ts +14 -2
  184. package/dist/session/prompts/ask-deck.js +6 -2
  185. package/dist/session/thread/session-chat.js +2 -2
  186. package/dist/session/thread/session-context-message-explorer.js +1 -1
  187. package/dist/session/thread/turn-share.js +3 -4
  188. package/dist/session/tool/shared/show-helpers.js +1 -1
  189. package/dist/session/turn/message-time-label.js +1 -1
  190. package/dist/styles.css +1 -1
  191. package/dist/test-utils/intl.d.ts +40 -47
  192. package/dist/workspace/admin/settings-search.js +4 -12
  193. package/dist/workspace/inbox/workspace-inbox.js +11 -2
  194. package/dist/workspace/layout/new-session-create.d.ts +4 -2
  195. package/dist/workspace/layout/new-session-create.js +11 -0
  196. package/dist/workspace/projects/modal/project-icon-field.js +9 -23
  197. package/dist/workspace/review/approval-modal.d.ts +6 -6
  198. package/dist/workspace/review/approval-modal.js +10 -14
  199. package/dist/workspace/review/review-center.d.ts +9 -2
  200. package/dist/workspace/review/review-center.js +258 -126
  201. package/dist/workspace/review/review-detail.d.ts +20 -10
  202. package/dist/workspace/review/review-detail.js +39 -44
  203. package/dist/workspace/review/review-meta.d.ts +27 -6
  204. package/dist/workspace/review/review-meta.js +46 -34
  205. package/dist/workspace/sessions/session-row.js +1 -1
  206. package/dist/workspace/sidebar/footer/project-download-app-nav.d.ts +10 -0
  207. package/dist/workspace/sidebar/footer/project-download-app-nav.js +53 -0
  208. package/dist/workspace/sidebar/footer/promo-nav-row.d.ts +2 -1
  209. package/dist/workspace/sidebar/footer/promo-nav-row.js +1 -1
  210. package/dist/workspace/sidebar/project-session-list.js +2 -2
  211. package/dist/workspace/sidebar/project-sidebar.d.ts +6 -1
  212. package/dist/workspace/sidebar/project-sidebar.js +3 -2
  213. package/dist/workspace/sidebar/session-brief-hover-card.d.ts +1 -1
  214. package/dist/workspace/sidebar/session-brief-hover-card.js +3 -3
  215. package/dist/workspace/sidebar/session-title.d.ts +2 -2
  216. package/dist/workspace/sidebar/session-title.js +2 -2
  217. package/dist/workspace/sidebar/workspace-menu-model.d.ts +19 -13
  218. package/dist/workspace/sidebar/workspace-menu-model.js +7 -8
  219. package/dist/workspace/sidebar/workspace-menu-section.js +1 -1
  220. package/dist/workspace/spaces/space-links.js +1 -1
  221. package/dist/workspace/spaces/space-threads-tab.js +1 -1
  222. package/package.json +16 -35
  223. package/skills/kortix-ui/SKILL.md +1 -1
  224. package/skills/kortix-ui/references/custom-dashboard.md +1 -1
  225. package/dist/customize/sections/view/subscription-usage-tab.d.ts +0 -25
  226. package/dist/customize/sections/view/subscription-usage-tab.js +0 -121
@@ -0,0 +1,150 @@
1
+ /**
2
+ * The Base UI menu parts that `dropdown-menu.tsx` and `context-menu.tsx`
3
+ * share. A context menu's items, groups, submenus and separators are the
4
+ * same Base UI `Menu` parts as a dropdown's; only the root, the trigger and
5
+ * the positioner differ.
6
+ *
7
+ * Every part keeps the Radix contract callers use: `onSelect` with
8
+ * `event.preventDefault()` keeps the menu open, checkbox and radio rows close
9
+ * the menu on select, rows and sub triggers carry `data-state`, and content
10
+ * accepts `onCloseAutoFocus` and the dismiss handlers.
11
+ */
12
+ import { Menu as MenuPrimitive } from '@base-ui/react/menu';
13
+ import * as React from 'react';
14
+ import { type ChangeDetails, type DismissHandlers, type LegacyPositionProps } from '../lib/base-ui-compat.js';
15
+ import { type MenuRowSize } from './menu-recipe.js';
16
+ export interface MenuRootProps {
17
+ open?: boolean;
18
+ defaultOpen?: boolean;
19
+ onOpenChange?: (open: boolean) => void;
20
+ modal?: boolean;
21
+ /** Accepted for Radix parity; Base UI reads the direction from the document. */
22
+ dir?: 'ltr' | 'rtl';
23
+ children?: React.ReactNode;
24
+ }
25
+ /** Wraps a Base UI menu root's `onOpenChange` with keep-open and dismiss handling. */
26
+ export declare function useMenuRoot(onOpenChange?: (open: boolean) => void): {
27
+ onOpenChange: (open: boolean, details?: ChangeDetails) => void;
28
+ wrap: (children: React.ReactNode) => React.JSX.Element;
29
+ };
30
+ export type MenuContentProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'dir'> & LegacyPositionProps & DismissHandlers & {
31
+ asChild?: boolean;
32
+ forceMount?: true;
33
+ loop?: boolean;
34
+ container?: HTMLElement;
35
+ onCloseAutoFocus?: (event: Event) => void;
36
+ /** Radix menus never moved focus on open; accepted and ignored. */
37
+ onOpenAutoFocus?: (event: Event) => void;
38
+ };
39
+ type PositionerComponent = React.ComponentType<React.ComponentPropsWithoutRef<typeof MenuPrimitive.Positioner>>;
40
+ /**
41
+ * Portal → Positioner → Popup. `zIndex` sits on the positioner, the fixed
42
+ * element; the popup carries `data-state` and the caller's classes.
43
+ */
44
+ export declare const MenuContentImpl: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "dir"> & LegacyPositionProps & DismissHandlers & {
45
+ asChild?: boolean;
46
+ forceMount?: true;
47
+ loop?: boolean;
48
+ container?: HTMLElement;
49
+ onCloseAutoFocus?: (event: Event) => void;
50
+ /** Radix menus never moved focus on open; accepted and ignored. */
51
+ onOpenAutoFocus?: (event: Event) => void;
52
+ } & {
53
+ Positioner: PositionerComponent;
54
+ varName: string;
55
+ } & React.RefAttributes<HTMLDivElement>>;
56
+ type RowBaseProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'onSelect'> & {
57
+ asChild?: boolean;
58
+ disabled?: boolean;
59
+ /** Typeahead text when the children are not plain text. */
60
+ textValue?: string;
61
+ onSelect?: (event: Event) => void;
62
+ };
63
+ export type MenuItemProps = RowBaseProps & {
64
+ inset?: boolean;
65
+ variant?: 'default' | 'destructive';
66
+ size?: MenuRowSize;
67
+ };
68
+ export declare function makeMenuItem(slotName?: string): React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "onSelect"> & {
69
+ asChild?: boolean;
70
+ disabled?: boolean;
71
+ /** Typeahead text when the children are not plain text. */
72
+ textValue?: string;
73
+ onSelect?: (event: Event) => void;
74
+ } & {
75
+ inset?: boolean;
76
+ variant?: "default" | "destructive";
77
+ size?: MenuRowSize;
78
+ } & React.RefAttributes<HTMLDivElement>>;
79
+ export type MenuCheckboxItemProps = Omit<RowBaseProps, 'onChange'> & {
80
+ checked?: boolean | 'indeterminate';
81
+ defaultChecked?: boolean;
82
+ onCheckedChange?: (checked: boolean) => void;
83
+ reverse?: boolean;
84
+ size?: MenuRowSize;
85
+ };
86
+ export declare function makeMenuCheckboxItem(slotName?: string): React.ForwardRefExoticComponent<Omit<RowBaseProps, "onChange"> & {
87
+ checked?: boolean | "indeterminate";
88
+ defaultChecked?: boolean;
89
+ onCheckedChange?: (checked: boolean) => void;
90
+ reverse?: boolean;
91
+ size?: MenuRowSize;
92
+ } & React.RefAttributes<HTMLDivElement>>;
93
+ export type MenuRadioItemProps = RowBaseProps & {
94
+ value: string;
95
+ size?: MenuRowSize;
96
+ side?: 'left' | 'right';
97
+ };
98
+ export declare function makeMenuRadioItem(slotName?: string): React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "onSelect"> & {
99
+ asChild?: boolean;
100
+ disabled?: boolean;
101
+ /** Typeahead text when the children are not plain text. */
102
+ textValue?: string;
103
+ onSelect?: (event: Event) => void;
104
+ } & {
105
+ value: string;
106
+ size?: MenuRowSize;
107
+ side?: "left" | "right";
108
+ } & React.RefAttributes<HTMLDivElement>>;
109
+ export interface MenuRadioGroupProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'defaultValue'> {
110
+ value?: string;
111
+ defaultValue?: string;
112
+ onValueChange?: (value: string) => void;
113
+ }
114
+ export declare const MenuRadioGroup: React.ForwardRefExoticComponent<MenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
115
+ export declare const MenuGroup: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
116
+ export declare function makeMenuLabel(slotName?: string): React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
117
+ inset?: boolean;
118
+ } & React.RefAttributes<HTMLDivElement>>;
119
+ export declare function makeMenuSeparator(slotName?: string): React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
120
+ export interface MenuSubProps {
121
+ open?: boolean;
122
+ defaultOpen?: boolean;
123
+ onOpenChange?: (open: boolean) => void;
124
+ children?: React.ReactNode;
125
+ }
126
+ export declare function MenuSub({ onOpenChange, ...props }: MenuSubProps): React.JSX.Element;
127
+ export type MenuSubTriggerProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'onSelect'> & {
128
+ inset?: boolean;
129
+ size?: MenuRowSize;
130
+ disabled?: boolean;
131
+ textValue?: string;
132
+ };
133
+ /**
134
+ * Takes the same `size` and `inset` props as the item, because a submenu
135
+ * trigger is a row like any other and has to line up with its siblings. The
136
+ * caret is `size-3.5` and muted: an affordance, not content.
137
+ */
138
+ export declare function makeMenuSubTrigger(slotName?: string): React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "onSelect"> & {
139
+ inset?: boolean;
140
+ size?: MenuRowSize;
141
+ disabled?: boolean;
142
+ textValue?: string;
143
+ } & React.RefAttributes<HTMLDivElement>>;
144
+ /** A passthrough: every content part already portals itself. */
145
+ export declare function MenuPortalPassthrough({ children, }: {
146
+ children?: React.ReactNode;
147
+ container?: HTMLElement;
148
+ forceMount?: true;
149
+ }): React.JSX.Element;
150
+ export { MenuPrimitive };
@@ -0,0 +1,171 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ /**
4
+ * The Base UI menu parts that `dropdown-menu.tsx` and `context-menu.tsx`
5
+ * share. A context menu's items, groups, submenus and separators are the
6
+ * same Base UI `Menu` parts as a dropdown's; only the root, the trigger and
7
+ * the positioner differ.
8
+ *
9
+ * Every part keeps the Radix contract callers use: `onSelect` with
10
+ * `event.preventDefault()` keeps the menu open, checkbox and radio rows close
11
+ * the menu on select, rows and sub triggers carry `data-state`, and content
12
+ * accepts `onCloseAutoFocus` and the dismiss handlers.
13
+ */
14
+ import { Menu as MenuPrimitive } from '@base-ui/react/menu';
15
+ import { CheckIcon as Check, CaretRightIcon as ChevronRight } from '@phosphor-icons/react';
16
+ import * as React from 'react';
17
+ import { asChildRender, checkedState, composeRefs, DismissProvider, FLOATING_LAYER_ATTR, focusProps, openState, radixPositionVars, splitPosition, stateRender, useDismissContent, useDismissRoot, useNativeButton, } from '../lib/base-ui-compat.js';
18
+ import { usePortalContainer } from '../lib/portal-container.js';
19
+ import { cn } from '../lib/utils.js';
20
+ import { floatingZ, useDialogDepth } from '../lib/z-stack.js';
21
+ import { MENU_INDICATOR, MENU_INDICATOR_ICON, MENU_INSET, MENU_INSET_END, MENU_LABEL, MENU_SEPARATOR, menuRow, } from './menu-recipe.js';
22
+ /* ---------- root: keep-open on a prevented onSelect ---------- */
23
+ /**
24
+ * Set by a row whose `onSelect` called `preventDefault()`. The root (and every
25
+ * submenu root) cancels the `item-press` close while it is set. Each row click
26
+ * resets it first, so it never outlives the click that set it.
27
+ */
28
+ const KeepOpenContext = React.createContext(null);
29
+ /** Wraps a Base UI menu root's `onOpenChange` with keep-open and dismiss handling. */
30
+ export function useMenuRoot(onOpenChange) {
31
+ const keepOpen = React.useRef(false);
32
+ const dismiss = useDismissRoot(onOpenChange);
33
+ const handle = React.useCallback((open, details) => {
34
+ if (!open && details?.reason === 'item-press' && keepOpen.current) {
35
+ details.cancel();
36
+ return;
37
+ }
38
+ dismiss.onOpenChange(open, details);
39
+ }, [dismiss]);
40
+ const wrap = React.useCallback((children) => (_jsx(KeepOpenContext.Provider, { value: keepOpen, children: _jsx(DismissProvider, { kind: "menu", registry: dismiss.registry, children: children }) })), [dismiss.registry]);
41
+ return { onOpenChange: handle, wrap };
42
+ }
43
+ /** The Radix `onSelect` event: a cancelable `CustomEvent` dispatched on the row. */
44
+ function useSelectHandler(onSelect, onClick, disabled) {
45
+ const keepOpen = React.useContext(KeepOpenContext);
46
+ return (event) => {
47
+ if (keepOpen)
48
+ keepOpen.current = false;
49
+ onClick?.(event);
50
+ if (disabled || !onSelect)
51
+ return;
52
+ const selectEvent = new CustomEvent('menu.itemSelect', {
53
+ bubbles: true,
54
+ cancelable: true,
55
+ detail: { originalEvent: event.nativeEvent },
56
+ });
57
+ const target = event.currentTarget;
58
+ target.addEventListener('menu.itemSelect', onSelect, { once: true });
59
+ target.dispatchEvent(selectEvent);
60
+ if (selectEvent.defaultPrevented && keepOpen)
61
+ keepOpen.current = true;
62
+ };
63
+ }
64
+ /**
65
+ * Portal → Positioner → Popup. `zIndex` sits on the positioner, the fixed
66
+ * element; the popup carries `data-state` and the caller's classes.
67
+ */
68
+ export const MenuContentImpl = React.forwardRef(({ Positioner, varName, asChild, children, forceMount, loop: _loop, container, style, onCloseAutoFocus, onOpenAutoFocus: _onOpenAutoFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, ...rest }, ref) => {
69
+ const depth = useDialogDepth();
70
+ const scoped = usePortalContainer();
71
+ const popup = React.useRef(null);
72
+ useDismissContent('menu', {
73
+ onEscapeKeyDown,
74
+ onPointerDownOutside,
75
+ onFocusOutside,
76
+ onInteractOutside,
77
+ });
78
+ const { positioner, rest: props } = splitPosition(rest);
79
+ const slot = asChildRender(asChild, children);
80
+ return (_jsx(MenuPrimitive.Portal, { container: container ?? scoped, keepMounted: forceMount, children: _jsx(Positioner, { ...positioner, ...FLOATING_LAYER_ATTR, className: "outline-none", style: { zIndex: floatingZ(depth), ...radixPositionVars(varName) }, children: _jsx(MenuPrimitive.Popup, { ref: composeRefs(ref, popup), style: style, ...props, ...focusProps(() => popup.current, undefined, onCloseAutoFocus), render: stateRender('div', openState, slot.render), children: slot.children }) }) }));
81
+ });
82
+ MenuContentImpl.displayName = 'MenuContent';
83
+ export function makeMenuItem(slotName) {
84
+ const Item = React.forwardRef(({ className, inset, variant = 'default', size = 'sm', asChild, children, disabled, textValue, onSelect, onClick, ...props }, ref) => {
85
+ const slot = asChildRender(asChild, children);
86
+ const handleClick = useSelectHandler(onSelect, onClick, disabled);
87
+ // A row is a <div>; with `asChild` it is whatever the child renders.
88
+ const native = useNativeButton(asChild, children);
89
+ return (_jsx(MenuPrimitive.Item, { ref: composeRefs(ref, native.ref), nativeButton: asChild ? native.nativeButton : false, "data-slot": slotName, className: cn(menuRow(size, variant), inset && MENU_INSET, className), disabled: disabled, label: textValue, ...props, onClick: handleClick, render: slot.render, children: slot.children }));
90
+ });
91
+ Item.displayName = 'MenuItem';
92
+ return Item;
93
+ }
94
+ export function makeMenuCheckboxItem(slotName) {
95
+ const CheckboxItem = React.forwardRef(({ className, children, checked, defaultChecked, onCheckedChange, reverse, size = 'sm', disabled, textValue, onSelect, onClick, asChild: _asChild, ...props }, ref) => {
96
+ const handleClick = useSelectHandler(onSelect, onClick, disabled);
97
+ return (_jsxs(MenuPrimitive.CheckboxItem, { ref: ref, "data-slot": slotName,
98
+ // The check sits in the row's leading slot (absolute, so an unchecked row
99
+ // keeps the same label x as a checked one) and the label starts at
100
+ // `MENU_INSET` — the same x as an `inset` item or an icon row's label.
101
+ className: cn(menuRow(size, 'default'), reverse ? MENU_INSET_END : MENU_INSET, className), checked: checked === undefined ? undefined : checked === true, defaultChecked: defaultChecked, onCheckedChange: onCheckedChange ? (next) => onCheckedChange(next) : undefined, disabled: disabled, label: textValue,
102
+ // Radix closes the menu when a checkbox row is picked; Base UI keeps it open.
103
+ closeOnClick: true, ...props, onClick: handleClick, render: stateRender('div', (s) => checked === 'indeterminate' ? 'indeterminate' : checkedState(s)), children: [_jsx("span", { className: cn(MENU_INDICATOR, 'absolute', reverse ? 'right-2' : 'left-2'), children: _jsx(MenuPrimitive.CheckboxItemIndicator, { children: _jsx(Check, { className: MENU_INDICATOR_ICON }) }) }), children] }));
104
+ });
105
+ CheckboxItem.displayName = 'MenuCheckboxItem';
106
+ return CheckboxItem;
107
+ }
108
+ /**
109
+ * The label column of a radio row. `flex-1` pushes the check to the far
110
+ * edge; `flex` keeps a leading icon on the label's line (Preflight makes
111
+ * `svg` a block). `gap-2` matches `MENU_ROW_BASE`.
112
+ */
113
+ const RADIO_LABEL = 'flex min-w-0 flex-1 items-center gap-2';
114
+ export function makeMenuRadioItem(slotName) {
115
+ const RadioItem = React.forwardRef(({ className, children, size = 'sm', side = 'right', disabled, textValue, onSelect, onClick, asChild: _asChild, ...props }, ref) => {
116
+ const handleClick = useSelectHandler(onSelect, onClick, disabled);
117
+ // A check, not a dot, and the same check the checkbox row uses.
118
+ const indicator = (_jsx("span", { className: MENU_INDICATOR, children: _jsx(MenuPrimitive.RadioItemIndicator, { children: _jsx(Check, { className: MENU_INDICATOR_ICON }) }) }));
119
+ return (_jsx(MenuPrimitive.RadioItem, { ref: ref, "data-slot": slotName, className: cn(menuRow(size, 'default'), className), disabled: disabled, label: textValue,
120
+ // Radix closes the menu when a radio row is picked; Base UI keeps it open.
121
+ closeOnClick: true, ...props, onClick: handleClick, render: stateRender('div', checkedState), children: side === 'left' ? (_jsxs(_Fragment, { children: [indicator, _jsx("span", { className: RADIO_LABEL, children: children })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: RADIO_LABEL, children: children }), indicator] })) }));
122
+ });
123
+ RadioItem.displayName = 'MenuRadioItem';
124
+ return RadioItem;
125
+ }
126
+ export const MenuRadioGroup = React.forwardRef(({ onValueChange, ...props }, ref) => (_jsx(MenuPrimitive.RadioGroup, { ref: ref, ...props, onValueChange: onValueChange ? (next) => onValueChange(next) : undefined })));
127
+ MenuRadioGroup.displayName = 'MenuRadioGroup';
128
+ /* ---------- group, label, separator ---------- */
129
+ const GroupContext = React.createContext(false);
130
+ export const MenuGroup = React.forwardRef((props, ref) => (_jsx(GroupContext.Provider, { value: true, children: _jsx(MenuPrimitive.Group, { ref: ref, ...props }) })));
131
+ MenuGroup.displayName = 'MenuGroup';
132
+ export function makeMenuLabel(slotName) {
133
+ const Label = React.forwardRef(({ className, inset, ...props }, ref) => {
134
+ const inGroup = React.useContext(GroupContext);
135
+ const classes = cn(MENU_LABEL, inset && MENU_INSET, className);
136
+ // `GroupLabel` names its group; outside a group the label is plain text, as on Radix.
137
+ return inGroup ? (_jsx(MenuPrimitive.GroupLabel, { ref: ref, "data-slot": slotName, className: classes, ...props })) : (_jsx("div", { ref: ref, "data-slot": slotName, className: classes, ...props }));
138
+ });
139
+ Label.displayName = 'MenuLabel';
140
+ return Label;
141
+ }
142
+ export function makeMenuSeparator(slotName) {
143
+ const Separator = React.forwardRef(({ className, ...props }, ref) => (_jsx(MenuPrimitive.Separator, { ref: ref, "data-slot": slotName, className: cn(MENU_SEPARATOR, className), ...props })));
144
+ Separator.displayName = 'MenuSeparator';
145
+ return Separator;
146
+ }
147
+ export function MenuSub({ onOpenChange, ...props }) {
148
+ const keepOpen = React.useContext(KeepOpenContext);
149
+ return (_jsx(MenuPrimitive.SubmenuRoot, { ...props, onOpenChange: (open, details) => {
150
+ if (!open && details.reason === 'item-press' && keepOpen?.current) {
151
+ details.cancel();
152
+ return;
153
+ }
154
+ onOpenChange?.(open);
155
+ } }));
156
+ }
157
+ /**
158
+ * Takes the same `size` and `inset` props as the item, because a submenu
159
+ * trigger is a row like any other and has to line up with its siblings. The
160
+ * caret is `size-3.5` and muted: an affordance, not content.
161
+ */
162
+ export function makeMenuSubTrigger(slotName) {
163
+ const SubTrigger = React.forwardRef(({ className, inset, size = 'sm', children, textValue, ...props }, ref) => (_jsxs(MenuPrimitive.SubmenuTrigger, { ref: ref, "data-slot": slotName, className: cn('group', menuRow(size, 'default'), inset && MENU_INSET, className), label: textValue, ...props, render: stateRender('div', openState), children: [children, _jsx(ChevronRight, { className: "text-muted-foreground ml-auto size-3.5" })] })));
164
+ SubTrigger.displayName = 'MenuSubTrigger';
165
+ return SubTrigger;
166
+ }
167
+ /** A passthrough: every content part already portals itself. */
168
+ export function MenuPortalPassthrough({ children, }) {
169
+ return _jsx(_Fragment, { children: children });
170
+ }
171
+ export { MenuPrimitive };
@@ -67,7 +67,7 @@ export declare function menuRow(size: MenuRowSize, tone: MenuRowTone, className?
67
67
  * shared `overflow-hidden` would survive alongside a later `overflow-y-auto`
68
68
  * and the winner would come down to Tailwind's generated property order.
69
69
  * - **Transform origin.** Anchored panels scale out of their trigger, and the
70
- * Radix variable that carries it is named per primitive.
70
+ * `--radix-*-transform-origin` variable that carries it is named per primitive.
71
71
  *
72
72
  * No `hover:text-foreground` here either — select had it. On the panel it
73
73
  * recoloured every row at once whenever the pointer entered, fighting the
@@ -42,12 +42,7 @@ export const MENU_INSET_END = 'pr-8';
42
42
  const MENU_ROW_BASE = "relative flex w-full items-center gap-2 rounded-sm px-2 text-sm font-medium outline-none select-none transition-colors duration-normal ease-out data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4";
43
43
  /**
44
44
  * Keyboard focus and pointer hover resolve to the same treatment on purpose —
45
- * Radix marks the keyboard-focused row `data-highlighted`, and a row you
46
- * arrowed onto should look exactly like a row you hovered.
47
- */
48
- /**
49
- * Keyboard focus and pointer hover resolve to the same treatment on purpose —
50
- * Radix marks the keyboard-focused row `data-highlighted`, and a row you
45
+ * Base UI marks the keyboard-focused row `data-highlighted`, and a row you
51
46
  * arrowed onto should look exactly like a row you hovered.
52
47
  */
53
48
  const MENU_ROW_TONE = {
@@ -94,7 +89,7 @@ export function menuRow(size, tone, className) {
94
89
  * shared `overflow-hidden` would survive alongside a later `overflow-y-auto`
95
90
  * and the winner would come down to Tailwind's generated property order.
96
91
  * - **Transform origin.** Anchored panels scale out of their trigger, and the
97
- * Radix variable that carries it is named per primitive.
92
+ * `--radix-*-transform-origin` variable that carries it is named per primitive.
98
93
  *
99
94
  * No `hover:text-foreground` here either — select had it. On the panel it
100
95
  * recoloured every row at once whenever the pointer entered, fighting the
@@ -1,59 +1,22 @@
1
- /**
2
- * @example
3
- * ```tsx
4
- * import {
5
- * Modal,
6
- * ModalBody,
7
- * ModalContent,
8
- * ModalDescription,
9
- * ModalFooter,
10
- * ModalHeader,
11
- * ModalTitle,
12
- * ModalTrigger,
13
- * } from './modal.js';
14
- * import { Button } from './button.js';
15
- *
16
- * <Modal>
17
- * <ModalTrigger asChild>
18
- * <Button>Open</Button>
19
- * </ModalTrigger>
20
- * <ModalContent className="lg:max-w-md">
21
- * <ModalHeader>
22
- * <ModalTitle>Title</ModalTitle>
23
- * <ModalDescription>Description</ModalDescription>
24
- * </ModalHeader>
25
- * <ModalBody>{children}</ModalBody>
26
- * <ModalFooter>
27
- * <Button variant="outline-ghost">Cancel</Button>
28
- * <Button>Confirm</Button>
29
- * </ModalFooter>
30
- * </ModalContent>
31
- * </Modal>
32
- * ```
33
- *
34
- * Controlled:
35
- * ```tsx
36
- * <Modal open={open} onOpenChange={setOpen}>
37
- * <ModalContent>...</ModalContent>
38
- * </Modal>
39
- * ```
40
- */
41
- import * as DialogPrimitive from '@radix-ui/react-dialog';
42
1
  import { type VariantProps } from 'class-variance-authority';
43
2
  import * as React from 'react';
44
- import { type TriggerVariantProps } from './trigger-variants.js';
45
- declare const Modal: ({ open, defaultOpen, onOpenChange, ...props }: DialogPrimitive.DialogProps) => React.JSX.Element;
46
- declare const ModalTrigger: ({ className, variant, size, asChild, ...props }: Omit<React.ComponentProps<typeof DialogPrimitive.Trigger>, "size"> & TriggerVariantProps) => React.JSX.Element;
47
- declare const ModalClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
3
+ import { type DialogContentBaseProps } from './dialog.js';
4
+ declare const Modal: ({ open, defaultOpen, onOpenChange, modal, children }: import("./dialog.js").DialogProps) => React.JSX.Element;
5
+ declare const ModalTrigger: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "size"> & {
6
+ asChild?: boolean;
7
+ } & import("./trigger-variants.js").TriggerVariantProps & React.RefAttributes<HTMLButtonElement>>;
8
+ declare const ModalClose: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "size"> & {
9
+ asChild?: boolean;
10
+ } & React.RefAttributes<HTMLButtonElement>>;
48
11
  declare const ModalPortal: {
49
- (props: DialogPrimitive.DialogPortalProps): React.JSX.Element;
12
+ (props: Omit<import("@base-ui/react").AlertDialogPortalProps, "ref"> & React.RefAttributes<HTMLDivElement>): React.JSX.Element;
50
13
  displayName: string;
51
14
  };
52
15
  declare const overlayAnimationClasses: {
53
16
  readonly default: "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-moderate";
54
17
  readonly none: "";
55
18
  };
56
- declare const ModalOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
19
+ declare const ModalOverlay: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
57
20
  animation?: keyof typeof overlayAnimationClasses;
58
21
  } & React.RefAttributes<HTMLDivElement>>;
59
22
  declare const ModalVariants: (props?: ({
@@ -61,7 +24,7 @@ declare const ModalVariants: (props?: ({
61
24
  side?: "bottom" | "left" | "right" | "top" | "fullscreen" | null | undefined;
62
25
  animation?: "default" | "none" | null | undefined;
63
26
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
64
- interface ModalContentProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, VariantProps<typeof ModalVariants> {
27
+ interface ModalContentProps extends DialogContentBaseProps, VariantProps<typeof ModalVariants> {
65
28
  closeClassName?: string;
66
29
  closeLabel?: string;
67
30
  modalClassName?: string;
@@ -73,7 +36,7 @@ interface ModalContentProps extends React.ComponentPropsWithoutRef<typeof Dialog
73
36
  /**
74
37
  * Should an "outside" interaction actually dismiss the modal?
75
38
  *
76
- * Two cases both look like backdrop clicks to Radix and must NOT dismiss:
39
+ * Two cases both look like backdrop clicks to the dialog and must NOT dismiss:
77
40
  *
78
41
  * 1. The click lands on a portaled Select / DropdownMenu / tooltip panel.
79
42
  * Those portal to `document.body`, outside the modal's DOM subtree, so
@@ -81,7 +44,7 @@ interface ModalContentProps extends React.ComponentPropsWithoutRef<typeof Dialog
81
44
  *
82
45
  * 2. A *modal* DropdownMenu is open and the click lands anywhere else —
83
46
  * including visually on the modal body, or on the dark overlay. While the
84
- * menu is open Radix sets `pointer-events: none` on everything under it, so
47
+ * menu is open it sets `pointer-events: none` on everything under it, so
85
48
  * the event target is `body` / the overlay, not the menu. Checking the
86
49
  * target alone fails; Escape already uses `hasOpenFloatingLayer()` for the
87
50
  * same reason. The gesture owns the floating layer: dismiss that first, and
@@ -98,8 +61,12 @@ declare const ModalFooter: {
98
61
  ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
99
62
  displayName: string;
100
63
  };
101
- declare const ModalTitle: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
102
- declare const ModalDescription: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
64
+ declare const ModalTitle: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & {
65
+ asChild?: boolean;
66
+ } & React.RefAttributes<HTMLHeadingElement>>;
67
+ declare const ModalDescription: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & {
68
+ asChild?: boolean;
69
+ } & React.RefAttributes<HTMLParagraphElement>>;
103
70
  declare const ModalBody: {
104
71
  ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
105
72
  displayName: string;
@@ -40,35 +40,31 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
40
40
  * </Modal>
41
41
  * ```
42
42
  */
43
- import * as DialogPrimitive from '@radix-ui/react-dialog';
43
+ import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
44
44
  import { cva } from 'class-variance-authority';
45
45
  import * as React from 'react';
46
46
  import { Close } from '../icons/close.js';
47
- import { withPortalContainer } from '../lib/portal-container.js';
47
+ import { asChildRender, openState, stateRender, } from '../lib/base-ui-compat.js';
48
48
  import { cn } from '../lib/utils.js';
49
- import { DialogDepthProvider, dialogContentZ, dialogOverlayZ, hasOpenFloatingLayer, isFloatingLayerTarget, useDialogDepth, useDialogRootLayer, } from '../lib/z-stack.js';
49
+ import { dialogContentZ, dialogOverlayZ, hasOpenFloatingLayer, isFloatingLayerTarget, useDialogDepth, } from '../lib/z-stack.js';
50
50
  import { Button } from './button.js';
51
- import { triggerVariants } from './trigger-variants.js';
51
+ import { Dialog, DialogClose, DialogPopup, DialogPortal, DialogTrigger, } from './dialog.js';
52
52
  // Stacks by open order, not only by JSX nesting: a Modal opened while another
53
- // is open sits above it even when the two share no React ancestor.
54
- const Modal = ({ open, defaultOpen, onOpenChange, ...props }) => {
55
- const layer = useDialogRootLayer({ open, defaultOpen, onOpenChange });
56
- return (_jsx(DialogDepthProvider, { depth: layer.depth, children: _jsx(DialogPrimitive.Root, { ...props, open: layer.open, onOpenChange: layer.onOpenChange }) }));
57
- };
58
- const ModalTrigger = ({ className, variant, size, asChild, ...props }) => (_jsx(DialogPrimitive.Trigger, { asChild: asChild,
59
- // With `asChild` the child owns its styling — merging ours would double it.
60
- className: asChild ? className : cn(triggerVariants({ variant, size }), className), ...props }));
61
- const ModalClose = DialogPrimitive.Close;
62
- const ModalPortal = withPortalContainer(DialogPrimitive.Portal);
53
+ // is open sits above it even when the two share no React ancestor. `Dialog`
54
+ // owns that layer stack.
55
+ const Modal = Dialog;
56
+ const ModalTrigger = DialogTrigger;
57
+ const ModalClose = DialogClose;
58
+ const ModalPortal = DialogPortal;
63
59
  const overlayAnimationClasses = {
64
60
  default: 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-moderate',
65
61
  none: '',
66
62
  };
67
63
  const ModalOverlay = React.forwardRef(({ className, style, animation = 'default', ...props }, ref) => {
68
64
  const depth = useDialogDepth();
69
- return (_jsx(DialogPrimitive.Overlay, { className: cn('fixed inset-0 bg-black/65 backdrop-blur-xs', overlayAnimationClasses[animation], className), style: { zIndex: dialogOverlayZ(depth), ...style }, ...props, ref: ref }));
65
+ return (_jsx(DialogPrimitive.Backdrop, { render: stateRender('div', openState), className: cn('fixed inset-0 bg-black/65 backdrop-blur-xs', overlayAnimationClasses[animation], className), style: { zIndex: dialogOverlayZ(depth), ...style }, ...props, ref: ref }));
70
66
  });
71
- ModalOverlay.displayName = DialogPrimitive.Overlay.displayName;
67
+ ModalOverlay.displayName = 'ModalOverlay';
72
68
  const ModalVariants = cva(cn('fixed gap-0 border p-0 shadow-lg overflow-y-auto', 'lg:top-[50%] lg:left-[50%] lg:grid lg:w-full lg:max-w-lg lg:-translate-x-1/2 lg:-translate-y-1/2 lg:rounded-xl', 'lg:flex lg:h-full lg:flex-col space-y-4'), {
73
69
  variants: {
74
70
  variant: {
@@ -119,7 +115,7 @@ const ModalVariants = cva(cn('fixed gap-0 border p-0 shadow-lg overflow-y-auto',
119
115
  /**
120
116
  * Should an "outside" interaction actually dismiss the modal?
121
117
  *
122
- * Two cases both look like backdrop clicks to Radix and must NOT dismiss:
118
+ * Two cases both look like backdrop clicks to the dialog and must NOT dismiss:
123
119
  *
124
120
  * 1. The click lands on a portaled Select / DropdownMenu / tooltip panel.
125
121
  * Those portal to `document.body`, outside the modal's DOM subtree, so
@@ -127,7 +123,7 @@ const ModalVariants = cva(cn('fixed gap-0 border p-0 shadow-lg overflow-y-auto',
127
123
  *
128
124
  * 2. A *modal* DropdownMenu is open and the click lands anywhere else —
129
125
  * including visually on the modal body, or on the dark overlay. While the
130
- * menu is open Radix sets `pointer-events: none` on everything under it, so
126
+ * menu is open it sets `pointer-events: none` on everything under it, so
131
127
  * the event target is `body` / the overlay, not the menu. Checking the
132
128
  * target alone fails; Escape already uses `hasOpenFloatingLayer()` for the
133
129
  * same reason. The gesture owns the floating layer: dismiss that first, and
@@ -150,8 +146,8 @@ const ModalContentInner = React.forwardRef(({ side = 'bottom', animation = 'defa
150
146
  // Same asymmetry for the keyboard: Escape aimed at an open select or menu must
151
147
  // dismiss that panel, not the modal underneath it.
152
148
  //
153
- // Deliberately NOT guarded on `hasOpenNestedDialog()`. Radix runs this handler
154
- // on the top-most layer only, so a nested modal would see its own parent in
149
+ // Deliberately NOT guarded on `hasOpenNestedDialog()`. The dialog runs this
150
+ // handler on the top-most layer only, so a nested modal would see its own parent in
155
151
  // that count, prevent its own dismissal, and leave Escape dead. Callers that
156
152
  // need the nested-dialog guard pass their own `onEscapeKeyDown` — it lands in
157
153
  // `...props` below and replaces this one (see the legacy Customize panel).
@@ -160,22 +156,22 @@ const ModalContentInner = React.forwardRef(({ side = 'bottom', animation = 'defa
160
156
  event.preventDefault();
161
157
  }
162
158
  };
163
- return (_jsxs(DialogPrimitive.Content, { ref: ref, className: cn(ModalVariants({ side, animation, className: modalClassName, variant }), className, 'rounded-xl rounded-b-none lg:rounded-b-xl'), style: { zIndex: dialogContentZ(depth), ...style }, onInteractOutside: handleInteractOutside, onEscapeKeyDown: handleEscapeKeyDown, ...props, children: [children, _jsxs("div", { className: "absolute top-3 right-3 flex items-center justify-end gap-2", children: [closeButtonChildren, showCloseButton && (_jsx(ModalClose, { asChild: true, children: _jsxs(Button, { variant: "ghost", className: cn('size-8 p-0 text-xs font-semibold focus:outline-none', closeClassName), children: [_jsx(Close, { className: "text-primary size-4 stroke-1" }), _jsx("span", { className: "sr-only", children: closeLabel })] }) }))] })] }));
159
+ return (_jsxs(DialogPopup, { ref: ref, className: cn(ModalVariants({ side, animation, className: modalClassName, variant }), className, 'rounded-xl rounded-b-none lg:rounded-b-xl'), style: { zIndex: dialogContentZ(depth), ...style }, onInteractOutside: handleInteractOutside, onEscapeKeyDown: handleEscapeKeyDown, ...props, children: [children, _jsxs("div", { className: "absolute top-3 right-3 flex items-center justify-end gap-2", children: [closeButtonChildren, showCloseButton && (_jsx(ModalClose, { asChild: true, children: _jsxs(Button, { variant: "ghost", className: cn('size-8 p-0 text-xs font-semibold focus:outline-none', closeClassName), children: [_jsx(Close, { className: "text-primary size-4 stroke-1" }), _jsx("span", { className: "sr-only", children: closeLabel })] }) }))] })] }));
164
160
  });
165
161
  ModalContentInner.displayName = 'ModalContentInner';
166
- const ModalContent = React.forwardRef(({ animation = 'default', overlayClassName, ...props }, ref) => {
162
+ const ModalContent = React.forwardRef(({ animation = 'default', overlayClassName, forceMount, ...props }, ref) => {
167
163
  const resolvedAnimation = animation ?? 'default';
168
- return (_jsxs(ModalPortal, { children: [_jsx(ModalOverlay, { animation: resolvedAnimation, className: overlayClassName }), _jsx(ModalContentInner, { animation: resolvedAnimation, ...props, ref: ref })] }));
164
+ return (_jsxs(ModalPortal, { keepMounted: forceMount, children: [_jsx(ModalOverlay, { animation: resolvedAnimation, className: overlayClassName }), _jsx(ModalContentInner, { animation: resolvedAnimation, ...props, ref: ref })] }));
169
165
  });
170
- ModalContent.displayName = DialogPrimitive.Content.displayName;
166
+ ModalContent.displayName = 'ModalContent';
171
167
  const ModalHeader = ({ className, ...props }) => (_jsx("div", { className: cn('flex flex-col space-y-0 text-left', 'px-5 pt-5', className), ...props }));
172
168
  ModalHeader.displayName = 'ModalHeader';
173
169
  const ModalFooter = ({ className, ...props }) => (_jsx("div", { className: cn('flex flex-col-reverse items-center justify-end gap-y-2 rounded-b-none px-5 sm:flex-row sm:justify-end sm:space-x-2 sm:gap-y-0 md:rounded-b-xl md:px-5 lg:rounded-b-xl', className), ...props }));
174
170
  ModalFooter.displayName = 'ModalFooter';
175
- const ModalTitle = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Title, { ref: ref, className: cn('text-foreground text-base font-semibold', className), ...props })));
176
- ModalTitle.displayName = DialogPrimitive.Title.displayName;
177
- const ModalDescription = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Description, { ref: ref, className: cn('text-muted-foreground text-sm', className), ...props })));
178
- ModalDescription.displayName = DialogPrimitive.Description.displayName;
171
+ const ModalTitle = React.forwardRef(({ className, asChild, children, ...props }, ref) => (_jsx(DialogPrimitive.Title, { ...asChildRender(asChild, children), ref: ref, className: cn('text-foreground text-base font-semibold', className), ...props })));
172
+ ModalTitle.displayName = 'ModalTitle';
173
+ const ModalDescription = React.forwardRef(({ className, asChild, children, ...props }, ref) => (_jsx(DialogPrimitive.Description, { ...asChildRender(asChild, children), ref: ref, className: cn('text-muted-foreground text-sm', className), ...props })));
174
+ ModalDescription.displayName = 'ModalDescription';
179
175
  const ModalBody = ({ className, ...props }) => (_jsx("div", { className: cn('flex-1 space-y-4 p-5 pt-0', className), ...props }));
180
176
  ModalBody.displayName = 'ModalBody';
181
177
  export { Modal, ModalBody, ModalClose, ModalContent, ModalContentInner, ModalDescription, ModalFooter, ModalHeader, ModalOverlay, ModalPortal, ModalTitle, ModalTrigger, };
@@ -1,16 +1,41 @@
1
- import * as SeparatorPrimitive from '@radix-ui/react-separator';
2
- import { NavigationMenu as NavigationMenuPrimitive } from 'radix-ui';
3
1
  import * as React from 'react';
4
- declare function NavigationMenu({ className, children, viewport, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Root> & {
2
+ /**
3
+ * Base UI always renders the open item's content in one popup viewport, so
4
+ * `viewport={false}` (inline content under each trigger) is accepted and
5
+ * renders the same shared viewport.
6
+ */
7
+ declare function NavigationMenu({ className, children, viewport, value, defaultValue, onValueChange, delayDuration, ...props }: Omit<React.ComponentPropsWithoutRef<'nav'>, 'defaultValue' | 'dir'> & {
5
8
  viewport?: boolean;
9
+ value?: string;
10
+ defaultValue?: string;
11
+ onValueChange?: (value: string) => void;
12
+ /** Radix name for the open delay. */
13
+ delayDuration?: number;
14
+ orientation?: 'horizontal' | 'vertical';
15
+ dir?: 'ltr' | 'rtl';
16
+ }): React.JSX.Element;
17
+ declare function NavigationMenuList({ className, ...props }: React.ComponentPropsWithoutRef<'ul'>): React.JSX.Element;
18
+ declare function NavigationMenuItem({ className, ...props }: React.ComponentPropsWithoutRef<'li'> & {
19
+ value?: string;
6
20
  }): React.JSX.Element;
7
- declare function NavigationMenuList({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.List>): React.JSX.Element;
8
- declare function NavigationMenuItem({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Item>): React.JSX.Element;
9
21
  declare const navigationMenuTriggerStyle: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
10
- declare function NavigationMenuTrigger({ className, children, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>): React.JSX.Element;
11
- declare function NavigationMenuContent({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Content>): React.JSX.Element;
12
- declare function NavigationMenuViewport({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Viewport>): React.JSX.Element;
13
- declare function NavigationMenuLink({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Link>): React.JSX.Element;
14
- declare function NavigationMenuSeparator({ className, orientation, decorative, ...props }: React.ComponentProps<typeof SeparatorPrimitive.Root>): React.JSX.Element;
15
- declare function NavigationMenuIndicator({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Indicator>): React.JSX.Element;
22
+ declare function NavigationMenuTrigger({ className, children, ...props }: React.ComponentPropsWithoutRef<'button'>): React.JSX.Element;
23
+ declare function NavigationMenuContent({ className, children, ...props }: React.ComponentPropsWithoutRef<'div'> & {
24
+ forceMount?: true;
25
+ }): React.JSX.Element;
26
+ /**
27
+ * Portal → Positioner → Popup → Viewport. The popup keeps the Radix
28
+ * `--radix-navigation-menu-viewport-*` names for its size.
29
+ */
30
+ declare function NavigationMenuViewport({ className, ...props }: React.ComponentPropsWithoutRef<'div'>): React.JSX.Element;
31
+ declare function NavigationMenuLink({ className, asChild, children, active, ...props }: React.ComponentPropsWithoutRef<'a'> & {
32
+ asChild?: boolean;
33
+ active?: boolean;
34
+ }): React.JSX.Element;
35
+ declare function NavigationMenuSeparator({ className, orientation, decorative, ...props }: React.ComponentPropsWithoutRef<'div'> & {
36
+ orientation?: 'horizontal' | 'vertical';
37
+ decorative?: boolean;
38
+ }): React.JSX.Element;
39
+ /** The arrow that points at the open trigger. Renders inside the popup. */
40
+ declare function NavigationMenuIndicator({ className, ...props }: React.ComponentPropsWithoutRef<'div'>): React.JSX.Element;
16
41
  export { NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuSeparator, NavigationMenuTrigger, navigationMenuTriggerStyle, NavigationMenuViewport, };