@c9up/nebula 0.1.8 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/atoms/Avatar.d.ts +36 -9
  2. package/dist/atoms/Avatar.js +66 -27
  3. package/dist/atoms/index.d.ts +1 -1
  4. package/dist/atoms/index.js +1 -1
  5. package/dist/lib/children.d.ts +30 -0
  6. package/dist/lib/motion.d.ts +10 -0
  7. package/dist/lib/motion.js +10 -0
  8. package/dist/molecules/Accordion.d.ts +36 -15
  9. package/dist/molecules/Accordion.js +68 -45
  10. package/dist/molecules/Breadcrumb.d.ts +29 -11
  11. package/dist/molecules/Breadcrumb.js +52 -52
  12. package/dist/molecules/Collapsible.d.ts +18 -17
  13. package/dist/molecules/Collapsible.js +42 -34
  14. package/dist/molecules/Field.d.ts +66 -30
  15. package/dist/molecules/Field.js +106 -55
  16. package/dist/molecules/InputGroup.d.ts +39 -21
  17. package/dist/molecules/InputGroup.js +43 -27
  18. package/dist/molecules/InputOTP.d.ts +26 -3
  19. package/dist/molecules/InputOTP.js +109 -76
  20. package/dist/molecules/Message.js +5 -4
  21. package/dist/molecules/Pagination.d.ts +36 -11
  22. package/dist/molecules/Pagination.js +58 -74
  23. package/dist/molecules/RadioGroup.d.ts +25 -17
  24. package/dist/molecules/RadioGroup.js +47 -43
  25. package/dist/molecules/Resizable.d.ts +32 -7
  26. package/dist/molecules/Resizable.js +76 -49
  27. package/dist/molecules/Tabs.d.ts +49 -11
  28. package/dist/molecules/Tabs.js +107 -51
  29. package/dist/molecules/ToggleGroup.d.ts +16 -10
  30. package/dist/molecules/ToggleGroup.js +37 -21
  31. package/dist/molecules/index.d.ts +11 -11
  32. package/dist/molecules/index.js +11 -11
  33. package/dist/organisms/AlertDialog.d.ts +80 -28
  34. package/dist/organisms/AlertDialog.js +192 -67
  35. package/dist/organisms/Carousel.d.ts +25 -3
  36. package/dist/organisms/Carousel.js +75 -43
  37. package/dist/organisms/Combobox.d.ts +2 -1
  38. package/dist/organisms/Combobox.js +46 -16
  39. package/dist/organisms/Command.d.ts +73 -32
  40. package/dist/organisms/Command.js +209 -131
  41. package/dist/organisms/CommandDialog.js +5 -5
  42. package/dist/organisms/ContextMenu.d.ts +41 -19
  43. package/dist/organisms/ContextMenu.js +112 -71
  44. package/dist/organisms/DataTable.js +42 -8
  45. package/dist/organisms/Dialog.d.ts +97 -31
  46. package/dist/organisms/Dialog.js +193 -68
  47. package/dist/organisms/Drawer.d.ts +33 -10
  48. package/dist/organisms/Drawer.js +130 -52
  49. package/dist/organisms/DropdownMenu.d.ts +58 -11
  50. package/dist/organisms/DropdownMenu.js +137 -50
  51. package/dist/organisms/Form.js +9 -11
  52. package/dist/organisms/HoverCard.d.ts +39 -19
  53. package/dist/organisms/HoverCard.js +116 -40
  54. package/dist/organisms/Menubar.d.ts +55 -19
  55. package/dist/organisms/Menubar.js +166 -82
  56. package/dist/organisms/NavigationMenu.d.ts +77 -31
  57. package/dist/organisms/NavigationMenu.js +169 -98
  58. package/dist/organisms/Popover.d.ts +72 -12
  59. package/dist/organisms/Popover.js +132 -25
  60. package/dist/organisms/Questionnaire.js +5 -5
  61. package/dist/organisms/Select.d.ts +99 -18
  62. package/dist/organisms/Select.js +253 -111
  63. package/dist/organisms/Sheet.d.ts +57 -13
  64. package/dist/organisms/Sheet.js +141 -54
  65. package/dist/organisms/Sidebar.d.ts +146 -56
  66. package/dist/organisms/Sidebar.js +236 -128
  67. package/dist/organisms/Tooltip.d.ts +88 -14
  68. package/dist/organisms/Tooltip.js +210 -47
  69. package/dist/organisms/index.d.ts +15 -15
  70. package/dist/organisms/index.js +15 -15
  71. package/dist/primitives/floating.js +25 -0
  72. package/dist/primitives/floatingSurface.d.ts +11 -0
  73. package/dist/primitives/floatingSurface.js +8 -0
  74. package/dist/primitives/menu.d.ts +45 -1
  75. package/dist/primitives/menu.js +45 -14
  76. package/dist/primitives/menuParts.d.ts +113 -0
  77. package/dist/primitives/menuParts.js +207 -0
  78. package/nebula.css +1 -1
  79. package/package.json +5 -4
  80. package/registry.json +18 -6
  81. package/src/atoms/Avatar.ts +141 -37
  82. package/src/atoms/index.ts +13 -1
  83. package/src/lib/children.ts +31 -0
  84. package/src/lib/motion.ts +12 -0
  85. package/src/molecules/Accordion.ts +120 -60
  86. package/src/molecules/Breadcrumb.ts +77 -76
  87. package/src/molecules/Collapsible.ts +77 -41
  88. package/src/molecules/Field.ts +187 -72
  89. package/src/molecules/InputGroup.ts +88 -35
  90. package/src/molecules/InputOTP.ts +150 -86
  91. package/src/molecules/Message.ts +6 -4
  92. package/src/molecules/Pagination.ts +96 -101
  93. package/src/molecules/RadioGroup.ts +70 -59
  94. package/src/molecules/Resizable.ts +138 -75
  95. package/src/molecules/Tabs.ts +187 -74
  96. package/src/molecules/ToggleGroup.ts +77 -38
  97. package/src/molecules/index.ts +85 -8
  98. package/src/organisms/AlertDialog.ts +319 -82
  99. package/src/organisms/Carousel.ts +129 -52
  100. package/src/organisms/Combobox.ts +64 -19
  101. package/src/organisms/Command.ts +342 -159
  102. package/src/organisms/CommandDialog.ts +6 -6
  103. package/src/organisms/ContextMenu.ts +185 -83
  104. package/src/organisms/DataTable.ts +56 -10
  105. package/src/organisms/Dialog.ts +312 -102
  106. package/src/organisms/Drawer.ts +219 -71
  107. package/src/organisms/DropdownMenu.ts +219 -61
  108. package/src/organisms/Form.ts +48 -34
  109. package/src/organisms/HoverCard.ts +187 -53
  110. package/src/organisms/Menubar.ts +247 -87
  111. package/src/organisms/NavigationMenu.ts +306 -128
  112. package/src/organisms/Popover.ts +215 -39
  113. package/src/organisms/Questionnaire.ts +9 -6
  114. package/src/organisms/Select.ts +397 -130
  115. package/src/organisms/Sheet.ts +252 -83
  116. package/src/organisms/Sidebar.ts +438 -185
  117. package/src/organisms/Tooltip.ts +315 -65
  118. package/src/organisms/index.ts +284 -14
  119. package/src/primitives/floating.ts +33 -0
  120. package/src/primitives/floatingSurface.ts +19 -0
  121. package/src/primitives/menu.ts +79 -18
  122. package/src/primitives/menuParts.ts +371 -0
@@ -1,6 +1,23 @@
1
1
  /**
2
2
  * Tooltip — a label that appears on hover or focus.
3
3
  *
4
+ * Four parts, as upstream: a `TooltipProvider` that owns the timing for a
5
+ * group, a `Tooltip` that owns one tooltip's state, a `TooltipTrigger` and a
6
+ * `TooltipContent`. The state lives in the middle and both ends read it
7
+ * through context, which is why the trigger can describe content it never
8
+ * sees.
9
+ *
10
+ * TooltipProvider({ children: () => html`
11
+ * ${Tooltip({ children: () => html`
12
+ * ${TooltipTrigger({ children: () => Button({ children: "Save" }) })}
13
+ * ${TooltipContent({ children: "Saves and closes" })}
14
+ * ` })}
15
+ * ` })
16
+ *
17
+ * The `() =>` is not decoration. Aurora builds eagerly, so children handed
18
+ * over already built would have run before the provider existed and found no
19
+ * context — see `Parts`.
20
+ *
4
21
  * Three rules separate a usable tooltip from an irritating one, and all three
5
22
  * are about time rather than appearance:
6
23
  *
@@ -11,8 +28,9 @@
11
28
  * halfway.
12
29
  * - **No delay between neighbours.** Once one tooltip is showing, the next one
13
30
  * appears instantly; the user has clearly decided to browse the toolbar, and
14
- * re-serving the delay each time makes the interface feel stuck. That is why
15
- * `lastClosedAt` is module state and not per-component.
31
+ * re-serving the delay each time makes the interface feel stuck. That is
32
+ * what `skipDelayDuration` bounds, and why the window belongs to the
33
+ * provider rather than to either tooltip.
16
34
  *
17
35
  * Focus opens it with no delay at all. A keyboard user landing on a control
18
36
  * has already committed to it, and a delay just looks like lag.
@@ -21,74 +39,219 @@
21
39
  * tooltip supplements a control's name; it is not the name. A button labelled
22
40
  * only by its tooltip is unlabelled to anything that does not hover.
23
41
  */
24
- import { component, html, onUnmount, signal } from "@c9up/aurora";
42
+ import { component, createContext, html, inject, onUnmount, provide, signal, } from "@c9up/aurora";
25
43
  import { slot } from "../lib/children.js";
26
44
  import { cn } from "../lib/cn.js";
27
45
  import { uid } from "../lib/id.js";
28
- import { fadeInOut } from "../lib/motion.js";
46
+ import { slideInFromSide, zoomInOut } from "../lib/motion.js";
29
47
  import { read } from "../lib/props.js";
30
48
  import { floatingSurface } from "../primitives/floatingSurface.js";
31
- const OPEN_DELAY_MS = 500;
49
+ /** Upstream's default once shadcn has overridden Radix's 700ms. */
50
+ const DEFAULT_DELAY_MS = 0;
51
+ /** Radix's `skipDelayDuration`. */
52
+ const DEFAULT_SKIP_DELAY_MS = 300;
32
53
  const CLOSE_DELAY_MS = 150;
33
- /** How long after one closes that the next opens instantly. */
34
- const GRACE_MS = 300;
35
- /** Shared across every tooltip on the page — see the "no delay" rule above. */
36
- let lastClosedAt = 0;
54
+ /**
55
+ * NAMED DEVIATION — a default, where Radix throws without a `TooltipProvider`.
56
+ *
57
+ * Radix raises so the skip-delay grouping is always an explicit choice. Here
58
+ * the default IS a group: one page-wide window, which is what nebula did
59
+ * before the parts were split out and what a single tooltip on a page wants.
60
+ * Wrapping a toolbar in a provider still gives it a window of its own, so
61
+ * nothing is lost — only the raise.
62
+ */
63
+ const TooltipProviderContext = createContext("TooltipProvider", {
64
+ delayDuration: DEFAULT_DELAY_MS,
65
+ skipDelayDuration: DEFAULT_SKIP_DELAY_MS,
66
+ disableHoverableContent: false,
67
+ lastClosedAt: 0,
68
+ });
69
+ const TooltipContext = createContext("Tooltip");
70
+ /**
71
+ * Timing shared by every tooltip inside it.
72
+ *
73
+ * Renders no element of its own, exactly as upstream: it is a context holder,
74
+ * and giving it a wrapper would put a box into a layout that did not ask for
75
+ * one. `data-slot="tooltip-provider"` is inert upstream for the same reason.
76
+ */
77
+ export const TooltipProvider = component((props) => {
78
+ provide(TooltipProviderContext, {
79
+ delayDuration: props.delayDuration ?? DEFAULT_DELAY_MS,
80
+ skipDelayDuration: props.skipDelayDuration ?? DEFAULT_SKIP_DELAY_MS,
81
+ disableHoverableContent: props.disableHoverableContent ?? false,
82
+ lastClosedAt: 0,
83
+ });
84
+ return html `${props.children?.()}`;
85
+ });
86
+ /**
87
+ * One tooltip: the state its trigger and its content both read.
88
+ *
89
+ * Renders no element of its own — see `TooltipProvider`. The parts are built
90
+ * here, inside setup, which is what puts the context within their reach; the
91
+ * content registers itself during that call, so the floating surface can be
92
+ * wired straight afterwards.
93
+ */
37
94
  export const Tooltip = component((props) => {
95
+ const group = inject(TooltipProviderContext);
38
96
  const triggerId = uid("tooltip-trigger");
39
97
  const contentId = uid("tooltip-content");
40
- const open = signal(false);
98
+ const internal = signal(props.defaultOpen ?? false);
99
+ let content;
41
100
  let timer;
42
- function clear() {
101
+ /** Controlled when `open` reads as anything but `undefined`, on every read. */
102
+ function isOpen() {
103
+ const external = read(props.open);
104
+ return external === undefined ? internal() : external;
105
+ }
106
+ function setOpen(next) {
107
+ // Written even when controlled: the caller may ignore `onOpenChange` and
108
+ // leave its own state put, and the internal value has to stay in step for
109
+ // the moment it stops controlling.
110
+ internal(next);
111
+ props.onOpenChange?.(next);
112
+ }
113
+ function cancelPending() {
43
114
  if (timer !== undefined)
44
115
  clearTimeout(timer);
45
116
  timer = undefined;
46
117
  }
47
- function scheduleOpen(immediate) {
48
- clear();
49
- const withinGrace = Date.now() - lastClosedAt < GRACE_MS;
50
- const delay = immediate || withinGrace ? 0 : (props.openDelay ?? OPEN_DELAY_MS);
118
+ function requestOpen(immediate) {
119
+ cancelPending();
120
+ const withinSkipWindow = Date.now() - group.lastClosedAt < group.skipDelayDuration;
121
+ const delay = immediate || withinSkipWindow
122
+ ? 0
123
+ : (props.delayDuration ?? group.delayDuration);
51
124
  if (delay === 0) {
52
- open(true);
125
+ setOpen(true);
53
126
  return;
54
127
  }
55
- timer = setTimeout(() => open(true), delay);
128
+ timer = setTimeout(() => setOpen(true), delay);
56
129
  }
57
- function scheduleClose() {
58
- clear();
130
+ function requestClose() {
131
+ cancelPending();
59
132
  timer = setTimeout(() => {
60
- open(false);
61
- lastClosedAt = Date.now();
62
- }, props.closeDelay ?? CLOSE_DELAY_MS);
133
+ setOpen(false);
134
+ group.lastClosedAt = Date.now();
135
+ }, CLOSE_DELAY_MS);
63
136
  }
64
- onUnmount(clear);
65
- floatingSurface({
66
- anchor: () => document.getElementById(triggerId),
67
- open: () => open(),
68
- onClose: () => {
69
- clear();
70
- open(false);
137
+ onUnmount(cancelPending);
138
+ provide(TooltipContext, {
139
+ triggerId,
140
+ contentId,
141
+ open: isOpen,
142
+ requestOpen,
143
+ requestClose,
144
+ cancelPending,
145
+ register(registered) {
146
+ content = registered;
71
147
  },
72
- placement: props.placement ?? "top",
73
- offset: 6,
74
- outsidePointer: false,
75
- content: () => html `<div
76
- data-slot="tooltip-content"
77
- id="${contentId}"
78
- role="tooltip"
79
- class="${cn("bg-primary text-primary-foreground z-50 w-fit rounded-md px-3 py-1.5 text-xs text-balance", fadeInOut, read(props.contentClass))}"
80
- @pointerenter="${clear}"
81
- @pointerleave="${scheduleClose}"
82
- >${props.content}</div>`,
83
148
  });
149
+ // Built HERE so the parts see the context, and so the content has
150
+ // registered by the time the surface below needs it.
151
+ const parts = props.children?.();
152
+ if (content !== undefined) {
153
+ const registered = content;
154
+ const placement = registered.align === "center"
155
+ ? registered.side
156
+ : `${registered.side}-${registered.align}`;
157
+ floatingSurface({
158
+ anchor: () => document.getElementById(triggerId),
159
+ open: isOpen,
160
+ onClose: () => {
161
+ cancelPending();
162
+ setOpen(false);
163
+ },
164
+ placement,
165
+ offset: registered.sideOffset,
166
+ arrowSize: ARROW_SIZE_PX,
167
+ arrow: (element) => element.querySelector('[data-slot="tooltip-arrow"]'),
168
+ // A tooltip is not a layer the pointer dismisses: it closes because
169
+ // the pointer left, which the trigger's own handlers already say.
170
+ outsidePointer: false,
171
+ content: () => renderContent(registered, contentId, {
172
+ hoverable: !(props.disableHoverableContent ?? group.disableHoverableContent),
173
+ cancelPending,
174
+ requestClose,
175
+ }),
176
+ });
177
+ }
178
+ return html `${parts}`;
179
+ });
180
+ /**
181
+ * The control being described.
182
+ *
183
+ * NAMED DEVIATION — a wrapping `<span>`, where upstream is used as
184
+ * `<TooltipTrigger asChild>` and merges onto the control itself. `asChild`
185
+ * needs an element to merge INTO, and Aurora has no element until the template
186
+ * is rendered; a `<button>` wrapper would nest a button inside a button, which
187
+ * is invalid and unfocusable. `inline-flex` keeps the wrapper out of the
188
+ * layout. Focus still opens it because `focusin` bubbles out of the control.
189
+ */
190
+ export const TooltipTrigger = component((props) => {
191
+ const tooltip = inject(TooltipContext);
84
192
  return html `<span
85
193
  data-slot="tooltip-trigger"
86
- id="${triggerId}"
87
- aria-describedby="${() => (open() ? contentId : undefined)}"
194
+ id="${tooltip.triggerId}"
195
+ data-state="${() => (tooltip.open() ? "open" : "closed")}"
196
+ aria-describedby="${() => (tooltip.open() ? tooltip.contentId : undefined)}"
88
197
  class="${() => cn("inline-flex", read(props.class))}"
89
- @pointerenter="${() => scheduleOpen(false)}"
90
- @pointerleave="${scheduleClose}"
91
- @focusin="${() => scheduleOpen(true)}"
92
- @focusout="${scheduleClose}"
93
- >${slot(props.trigger)}</span>`;
198
+ @pointerenter="${() => tooltip.requestOpen(false)}"
199
+ @pointerleave="${() => tooltip.requestClose()}"
200
+ @focusin="${() => tooltip.requestOpen(true)}"
201
+ @focusout="${() => tooltip.requestClose()}"
202
+ >${slot(props.children)}</span>`;
94
203
  });
204
+ /**
205
+ * The label itself.
206
+ *
207
+ * Renders nothing where it is written: the tooltip portals its content out of
208
+ * the tree when it opens, so this registers what to build and returns an empty
209
+ * template. Writing it inside `Tooltip` — rather than passing content as a
210
+ * prop — is what keeps the call site shaped like the thing it describes.
211
+ */
212
+ export const TooltipContent = component((props) => {
213
+ const tooltip = inject(TooltipContext);
214
+ tooltip.register({
215
+ render: () => props.children,
216
+ side: props.side ?? "top",
217
+ align: props.align ?? "center",
218
+ sideOffset: props.sideOffset ?? 0,
219
+ class: props.class,
220
+ });
221
+ return html ``;
222
+ });
223
+ /** `size-2.5` in pixels — what the positioner centres on the anchor. */
224
+ const ARROW_SIZE_PX = 10;
225
+ const CONTENT_CLASSES = "bg-foreground text-background z-50 w-fit origin-(--nebula-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance";
226
+ /**
227
+ * NAMED DEVIATION — the arrow is placed per side here, where shadcn writes one
228
+ * `translate-y`. Radix wraps its arrow in a span the popper rotates to face the
229
+ * anchor, so upstream's single nudge is applied in an already-oriented frame.
230
+ * `autoPosition` positions the arrow along the CROSS axis only, by design, and
231
+ * leaves the facing edge to CSS — so the edge has to be named for each side.
232
+ * The look is upstream's: a 10px square, rotated, softly rounded.
233
+ */
234
+ const ARROW_CLASSES = [
235
+ "bg-foreground fill-foreground absolute z-50 size-2.5 rotate-45 rounded-[2px]",
236
+ "data-[side=top]:bottom-0 data-[side=top]:translate-y-[calc(50%_-_2px)]",
237
+ "data-[side=bottom]:top-0 data-[side=bottom]:translate-y-[calc(-50%_+_2px)]",
238
+ "data-[side=left]:right-0 data-[side=left]:translate-x-[calc(50%_-_2px)]",
239
+ "data-[side=right]:left-0 data-[side=right]:translate-x-[calc(-50%_+_2px)]",
240
+ ].join(" ");
241
+ function renderContent(registered, contentId, handlers) {
242
+ // Hoverable content keeps the tooltip open while the pointer is inside it,
243
+ // which is the only way to read a long one or click a link in it.
244
+ const enter = handlers.hoverable ? () => handlers.cancelPending() : undefined;
245
+ const leave = handlers.hoverable ? () => handlers.requestClose() : undefined;
246
+ return html `<div
247
+ data-slot="tooltip-content"
248
+ id="${contentId}"
249
+ role="tooltip"
250
+ class="${cn(CONTENT_CLASSES, zoomInOut, slideInFromSide, read(registered.class))}"
251
+ @pointerenter="${enter}"
252
+ @pointerleave="${leave}"
253
+ >${registered.render()}<span
254
+ data-slot="tooltip-arrow"
255
+ class="${ARROW_CLASSES}"
256
+ ></span></div>`;
257
+ }
@@ -12,29 +12,29 @@
12
12
  * ones — so the parts that are easy to get wrong (teardown order, focus
13
13
  * restoration, hiding the page from assistive technology) exist once.
14
14
  */
15
- export { AlertDialog, type AlertDialogProps } from "./AlertDialog.js";
15
+ export { AlertDialog, AlertDialogAction, type AlertDialogButtonProps, AlertDialogCancel, AlertDialogContent, type AlertDialogContentProps, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, type AlertDialogPortalProps, type AlertDialogProps, type AlertDialogSectionProps, AlertDialogTitle, AlertDialogTrigger, type AlertDialogTriggerProps, } from "./AlertDialog.js";
16
16
  export { addDays, addMonths, Calendar, type CalendarProps, type DateRange, isSameDay, monthGrid, startOfDay, } from "./Calendar.js";
17
- export { Carousel, type CarouselProps } from "./Carousel.js";
17
+ export { Carousel, type CarouselButtonProps, CarouselContent, type CarouselContentProps, CarouselItem, type CarouselItemProps, CarouselNext, CarouselPrevious, type CarouselProps, } from "./Carousel.js";
18
18
  export { Chart, type ChartDatum, type ChartProps, type ChartSeries, valueRange, } from "./Chart.js";
19
19
  export { Combobox, type ComboboxOption, type ComboboxProps, } from "./Combobox.js";
20
- export { Command, type CommandItem, type CommandProps, defaultFilter, } from "./Command.js";
20
+ export { Command, type CommandCandidate, CommandEmpty, type CommandEmptyProps, CommandGroup, type CommandGroupProps, CommandInput, type CommandInputProps, CommandItem, type CommandItemProps, CommandList, type CommandListProps, type CommandProps, CommandSeparator, type CommandSeparatorProps, CommandShortcut, type CommandShortcutProps, defaultFilter, } from "./Command.js";
21
21
  export { CommandDialog, type CommandDialogProps } from "./CommandDialog.js";
22
- export { ContextMenu, type ContextMenuProps } from "./ContextMenu.js";
22
+ export { ContextMenu, ContextMenuCheckboxItem, type ContextMenuCheckboxItemProps, ContextMenuContent, type ContextMenuContentProps, ContextMenuGroup, type ContextMenuGroupProps, ContextMenuItem, type ContextMenuItemProps, ContextMenuLabel, type ContextMenuLabelProps, ContextMenuPortal, type ContextMenuPortalProps, type ContextMenuProps, ContextMenuRadioGroup, type ContextMenuRadioGroupProps, ContextMenuRadioItem, type ContextMenuRadioItemProps, ContextMenuSeparator, type ContextMenuSeparatorProps, ContextMenuShortcut, type ContextMenuShortcutProps, ContextMenuSub, ContextMenuSubContent, type ContextMenuSubContentProps, type ContextMenuSubProps, ContextMenuSubTrigger, type ContextMenuSubTriggerProps, ContextMenuTrigger, type ContextMenuTriggerProps, } from "./ContextMenu.js";
23
23
  export { type Column, DataTable, type DataTableProps } from "./DataTable.js";
24
24
  export { DatePicker, type DatePickerProps, toISODate } from "./DatePicker.js";
25
25
  export { DateRangePicker, type DateRangePickerProps, } from "./DateRangePicker.js";
26
- export { Dialog, type DialogProps, dialogBackdropClasses, dialogPanelClasses, useDialog, } from "./Dialog.js";
27
- export { Drawer, type DrawerProps } from "./Drawer.js";
28
- export { DropdownMenu, type DropdownMenuProps } from "./DropdownMenu.js";
26
+ export { Dialog, DialogClose, type DialogCloseProps, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, type DialogFooterProps, DialogHeader, DialogOverlay, type DialogOverlayProps, DialogPortal, type DialogPortalProps, type DialogProps, type DialogSectionProps, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerProps, dialogBackdropClasses, dialogPanelClasses, useDialog, } from "./Dialog.js";
27
+ export { Drawer, DrawerClose, type DrawerCloseProps, DrawerContent, type DrawerContentProps, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, type DrawerOverlayProps, type DrawerProps, type DrawerSectionProps, DrawerTitle, DrawerTrigger, type DrawerTriggerProps, } from "./Drawer.js";
28
+ export { DropdownMenu, DropdownMenuCheckboxItem, type DropdownMenuCheckboxItemProps, DropdownMenuContent, type DropdownMenuContentProps, DropdownMenuGroup, type DropdownMenuGroupProps, DropdownMenuItem, type DropdownMenuItemProps, DropdownMenuLabel, type DropdownMenuLabelProps, DropdownMenuPortal, type DropdownMenuPortalProps, type DropdownMenuProps, DropdownMenuRadioGroup, type DropdownMenuRadioGroupProps, DropdownMenuRadioItem, type DropdownMenuRadioItemProps, DropdownMenuSeparator, type DropdownMenuSeparatorProps, DropdownMenuShortcut, type DropdownMenuShortcutProps, DropdownMenuSub, DropdownMenuSubContent, type DropdownMenuSubContentProps, type DropdownMenuSubProps, DropdownMenuSubTrigger, type DropdownMenuSubTriggerProps, DropdownMenuTrigger, type DropdownMenuTriggerProps, } from "./DropdownMenu.js";
29
29
  export { bind, type FieldBinding, Form, type FormProps, SubmitButton, type SubmitButtonProps, TextAreaField, type TextAreaFieldProps, TextField, type TextFieldProps, } from "./Form.js";
30
- export { HoverCard, type HoverCardProps } from "./HoverCard.js";
31
- export { Menubar, type MenubarMenu, type MenubarProps } from "./Menubar.js";
30
+ export { HoverCard, HoverCardContent, type HoverCardContentProps, type HoverCardProps, HoverCardTrigger, type HoverCardTriggerProps, } from "./HoverCard.js";
31
+ export { Menubar, MenubarCheckboxItem, type MenubarCheckboxItemProps, MenubarContent, type MenubarContentProps, MenubarGroup, type MenubarGroupProps, MenubarItem, type MenubarItemProps, MenubarLabel, type MenubarLabelProps, MenubarMenu, type MenubarMenuProps, MenubarPortal, type MenubarPortalProps, type MenubarProps, MenubarRadioGroup, type MenubarRadioGroupProps, MenubarRadioItem, type MenubarRadioItemProps, MenubarSeparator, type MenubarSeparatorProps, MenubarShortcut, type MenubarShortcutProps, MenubarSub, MenubarSubContent, type MenubarSubContentProps, type MenubarSubProps, MenubarSubTrigger, type MenubarSubTriggerProps, MenubarTrigger, type MenubarTriggerProps, } from "./Menubar.js";
32
32
  export { MessageScroller, type MessageScrollerProps, } from "./MessageScroller.js";
33
- export { type NavigationItem, type NavigationLink, NavigationMenu, type NavigationMenuProps, } from "./NavigationMenu.js";
34
- export { Popover, type PopoverProps, popoverContentClasses, } from "./Popover.js";
33
+ export { NavigationMenu, NavigationMenuContent, type NavigationMenuContentProps, NavigationMenuIndicator, type NavigationMenuIndicatorProps, NavigationMenuItem, type NavigationMenuItemProps, NavigationMenuLink, type NavigationMenuLinkProps, NavigationMenuList, type NavigationMenuListProps, type NavigationMenuProps, NavigationMenuTrigger, type NavigationMenuTriggerProps, NavigationMenuViewport, type NavigationMenuViewportProps, triggerClasses, } from "./NavigationMenu.js";
34
+ export { Popover, PopoverAnchor, type PopoverAnchorProps, PopoverContent, type PopoverContentProps, PopoverDescription, PopoverHeader, type PopoverProps, type PopoverSectionProps, PopoverTitle, PopoverTrigger, type PopoverTriggerProps, popoverContentClasses, } from "./Popover.js";
35
35
  export { type Answer, type Answers, type FreeformQuestion, isAnswered, type MultipleChoiceQuestion, type Question, Questionnaire, type QuestionnaireProps, type QuestionOption, type SingleChoiceQuestion, } from "./Questionnaire.js";
36
- export { Select, type SelectOption, type SelectProps, selectTriggerClasses, } from "./Select.js";
37
- export { Sheet, type SheetProps } from "./Sheet.js";
38
- export { Sidebar, SidebarGroup, SidebarGroupLabel, SidebarMenu, SidebarMenuAction, SidebarMenuItem, type SidebarMenuItemProps, SidebarMenuSub, SidebarMenuSubItem, type SidebarProps, SidebarTrigger, type SidebarTriggerProps, sidebarCollapsed, sidebarState, } from "./Sidebar.js";
36
+ export { Select, SelectContent, type SelectContentProps, SelectGroup, type SelectGroupProps, SelectItem, type SelectItemProps, SelectLabel, type SelectLabelProps, type SelectProps, type SelectScrollButtonProps, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, type SelectSeparatorProps, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, selectContentClasses, selectTriggerClasses, } from "./Select.js";
37
+ export { Sheet, SheetClose, type SheetCloseProps, SheetContent, type SheetContentProps, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, type SheetOverlayProps, type SheetProps, type SheetSectionProps, SheetTitle, type SheetTitleProps, SheetTrigger, type SheetTriggerProps, } from "./Sheet.js";
38
+ export { Sidebar, type SidebarActionProps, type SidebarApi, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, type SidebarInputProps, SidebarInset, type SidebarInsetProps, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonVariants, SidebarMenuItem, SidebarMenuSkeleton, type SidebarMenuSkeletonProps, SidebarMenuSub, SidebarMenuSubButton, type SidebarMenuSubButtonProps, SidebarMenuSubItem, type SidebarProps, SidebarProvider, type SidebarProviderProps, SidebarRail, type SidebarRailProps, SidebarSeparator, type SidebarSeparatorProps, SidebarTrigger, type SidebarTriggerProps, sidebarCollapsed, sidebarMenuButtonVariants, sidebarState, useSidebar, } from "./Sidebar.js";
39
39
  export { Toaster, type ToasterProps, type ToastOptions, type ToastVariant, toast, } from "./Toaster.js";
40
- export { Tooltip, type TooltipProps } from "./Tooltip.js";
40
+ export { Tooltip, TooltipContent, type TooltipContentProps, type TooltipProps, TooltipProvider, type TooltipProviderProps, TooltipTrigger, type TooltipTriggerProps, } from "./Tooltip.js";
@@ -12,29 +12,29 @@
12
12
  * ones — so the parts that are easy to get wrong (teardown order, focus
13
13
  * restoration, hiding the page from assistive technology) exist once.
14
14
  */
15
- export { AlertDialog } from "./AlertDialog.js";
15
+ export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, } from "./AlertDialog.js";
16
16
  export { addDays, addMonths, Calendar, isSameDay, monthGrid, startOfDay, } from "./Calendar.js";
17
- export { Carousel } from "./Carousel.js";
17
+ export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, } from "./Carousel.js";
18
18
  export { Chart, valueRange, } from "./Chart.js";
19
19
  export { Combobox, } from "./Combobox.js";
20
- export { Command, defaultFilter, } from "./Command.js";
20
+ export { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, defaultFilter, } from "./Command.js";
21
21
  export { CommandDialog } from "./CommandDialog.js";
22
- export { ContextMenu } from "./ContextMenu.js";
22
+ export { ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, } from "./ContextMenu.js";
23
23
  export { DataTable } from "./DataTable.js";
24
24
  export { DatePicker, toISODate } from "./DatePicker.js";
25
25
  export { DateRangePicker, } from "./DateRangePicker.js";
26
- export { Dialog, dialogBackdropClasses, dialogPanelClasses, useDialog, } from "./Dialog.js";
27
- export { Drawer } from "./Drawer.js";
28
- export { DropdownMenu } from "./DropdownMenu.js";
26
+ export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, dialogBackdropClasses, dialogPanelClasses, useDialog, } from "./Dialog.js";
27
+ export { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerTitle, DrawerTrigger, } from "./Drawer.js";
28
+ export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "./DropdownMenu.js";
29
29
  export { bind, Form, SubmitButton, TextAreaField, TextField, } from "./Form.js";
30
- export { HoverCard } from "./HoverCard.js";
31
- export { Menubar } from "./Menubar.js";
30
+ export { HoverCard, HoverCardContent, HoverCardTrigger, } from "./HoverCard.js";
31
+ export { Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, } from "./Menubar.js";
32
32
  export { MessageScroller, } from "./MessageScroller.js";
33
- export { NavigationMenu, } from "./NavigationMenu.js";
34
- export { Popover, popoverContentClasses, } from "./Popover.js";
33
+ export { NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, triggerClasses, } from "./NavigationMenu.js";
34
+ export { Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, popoverContentClasses, } from "./Popover.js";
35
35
  export { isAnswered, Questionnaire, } from "./Questionnaire.js";
36
- export { Select, selectTriggerClasses, } from "./Select.js";
37
- export { Sheet } from "./Sheet.js";
38
- export { Sidebar, SidebarGroup, SidebarGroupLabel, SidebarMenu, SidebarMenuAction, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubItem, SidebarTrigger, sidebarCollapsed, sidebarState, } from "./Sidebar.js";
36
+ export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, selectContentClasses, selectTriggerClasses, } from "./Select.js";
37
+ export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetTitle, SheetTrigger, } from "./Sheet.js";
38
+ export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, sidebarCollapsed, sidebarMenuButtonVariants, sidebarState, useSidebar, } from "./Sidebar.js";
39
39
  export { Toaster, toast, } from "./Toaster.js";
40
- export { Tooltip } from "./Tooltip.js";
40
+ export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "./Tooltip.js";
@@ -176,6 +176,25 @@ function bestSide(requested, anchor, floating, viewport, offset, padding) {
176
176
  return other;
177
177
  return there > here ? other : requested;
178
178
  }
179
+ /**
180
+ * `transform-origin` for a surface anchored on `side`.
181
+ *
182
+ * Along the main axis it is the edge facing the anchor: a surface placed above
183
+ * grows downward out of its own bottom edge. Along the cross axis it is the
184
+ * anchor's centre, clamped to the surface, which keeps the origin pointing at
185
+ * the control even after `shift` has slid a wide menu sideways — the same
186
+ * reason the arrow tracks the anchor rather than the surface.
187
+ */
188
+ function transformOrigin(position, anchor, floating) {
189
+ if (position.side === "top" || position.side === "bottom") {
190
+ const centre = anchor.x + anchor.width / 2 - position.x;
191
+ const x = Math.round(clamp(centre, 0, floating.width));
192
+ return `${x}px ${position.side === "bottom" ? 0 : Math.round(floating.height)}px`;
193
+ }
194
+ const centre = anchor.y + anchor.height / 2 - position.y;
195
+ const y = Math.round(clamp(centre, 0, floating.height));
196
+ return `${position.side === "right" ? 0 : Math.round(floating.width)}px ${y}px`;
197
+ }
179
198
  /**
180
199
  * Centre the arrow on the anchor, then pull it back off the corners.
181
200
  *
@@ -231,6 +250,12 @@ export function autoPosition(anchor, floating, options = {}) {
231
250
  // CSS rather than hardcoding a pixel max-height from script.
232
251
  floating.style.setProperty("--nebula-available-height", `${Math.round(position.availableHeight)}px`);
233
252
  floating.style.setProperty("--nebula-anchor-width", `${Math.round(anchorRect.width)}px`);
253
+ // The point the surface grows FROM, so `zoom-in-95` expands out of the
254
+ // control that opened it rather than out of its own middle. Radix
255
+ // publishes the same thing as `--radix-popper-transform-origin` and
256
+ // shadcn's surfaces read it through `origin-(…)`; ours are all anchored,
257
+ // so it is written here once instead of per component.
258
+ floating.style.setProperty("--nebula-transform-origin", transformOrigin(position, anchorRect, floatingRect));
234
259
  floating.setAttribute("data-side", position.side);
235
260
  floating.setAttribute("data-align", position.align);
236
261
  const arrowEl = options.arrow?.();
@@ -32,6 +32,17 @@ export interface FloatingSurfaceOptions {
32
32
  offset?: number;
33
33
  /** Size the surface to the anchor. Select and Combobox want this. */
34
34
  matchWidth?: boolean;
35
+ /**
36
+ * The arrow inside the surface, looked up once the content exists.
37
+ *
38
+ * Positioned along the CROSS axis only — centred on the anchor and pulled
39
+ * off the corners — so a surface that `shift` slid sideways still points at
40
+ * its trigger. Which edge it sits on is left to CSS, because that is where
41
+ * the surface's own padding and radius are known.
42
+ */
43
+ arrow?: (content: HTMLElement) => Element | null;
44
+ /** The arrow's width in pixels. Required for `arrow` to be positioned. */
45
+ arrowSize?: number;
35
46
  /** Keep keyboard focus inside while open. */
36
47
  trapFocus?: boolean;
37
48
  /** Move focus into the surface on open. Implied by `trapFocus`. */
@@ -64,6 +64,14 @@ export function floatingSurface(options) {
64
64
  placement: options.placement,
65
65
  offset: options.offset,
66
66
  matchWidth: options.matchWidth,
67
+ arrowSize: options.arrowSize,
68
+ arrow: () => {
69
+ // Narrowed rather than asserted: `querySelector` answers `Element`,
70
+ // and an arrow that turned out to be an SVG node has no `style` to
71
+ // position.
72
+ const found = options.arrow?.(element) ?? null;
73
+ return found instanceof HTMLElement ? found : null;
74
+ },
67
75
  });
68
76
  const layer = dismissable({
69
77
  element: () => element,
@@ -65,7 +65,28 @@ export interface MenuSubmenu {
65
65
  entries: readonly MenuEntry[];
66
66
  }
67
67
  export type MenuEntry = MenuAction | MenuCheckbox | MenuRadioGroup | MenuLabel | MenuSeparator | MenuSubmenu;
68
- export declare const menuPanelClasses = "bg-popover text-popover-foreground z-50 min-w-[8rem] max-h-(--nebula-available-height) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md outline-none";
68
+ /**
69
+ * Upstream's class strings, shared by the three menus built on this module.
70
+ *
71
+ * shadcn repeats them in `dropdown-menu.tsx`, `context-menu.tsx` and
72
+ * `menubar.tsx` because each file is copied on its own. Here all three already
73
+ * depend on this module, and the registry copies it with them, so repeating
74
+ * the strings would only be three places to update when one of them changes.
75
+ *
76
+ * `--nebula-available-height` and `--nebula-transform-origin` stand in for
77
+ * Radix's per-component custom properties; `autoPosition` writes both.
78
+ */
79
+ export declare const menuPanelClasses = "bg-popover text-popover-foreground z-50 max-h-(--nebula-available-height) min-w-[8rem] origin-(--nebula-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md outline-none";
80
+ /** A submenu panel: no height cap, a deeper shadow. */
81
+ export declare const menuSubPanelClasses = "bg-popover text-popover-foreground z-50 min-w-[8rem] origin-(--nebula-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg outline-none";
82
+ export declare const menuItemClasses = "relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!";
83
+ /** Checkbox and radio rows: the same, indented to leave room for the mark. */
84
+ export declare const menuCheckItemClasses = "relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4";
85
+ export declare const menuIndicatorClasses = "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center";
86
+ export declare const menuLabelClasses = "px-2 py-1.5 text-sm font-medium data-[inset]:pl-8";
87
+ export declare const menuSeparatorClasses = "bg-border -mx-1 my-1 h-px";
88
+ export declare const menuShortcutClasses = "text-muted-foreground ml-auto text-xs tracking-widest";
89
+ export declare const menuSubTriggerClasses = "flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground";
69
90
  export interface MenuPanelOptions {
70
91
  id: string;
71
92
  entries: readonly MenuEntry[];
@@ -76,6 +97,22 @@ export interface MenuPanelOptions {
76
97
  }
77
98
  /** The panel's markup. Behaviour is attached separately by `wireMenu`. */
78
99
  export declare function menuPanel(options: MenuPanelOptions): TemplateResult;
100
+ /**
101
+ * How a submenu's panel is produced when the row is opened.
102
+ *
103
+ * A factory rather than the panel itself, because a submenu is built fresh on
104
+ * each open: a panel kept from a previous open would carry the DOM state
105
+ * `wireMenu` left on it, and reusing a node that has already been torn down is
106
+ * how a menu ends up showing the previous row's entries.
107
+ *
108
+ * The entries-based API supplies one that calls `menuPanel`; the composed
109
+ * parts supply one that returns the markup they were given. `wireMenu` cannot
110
+ * tell the two apart, which is the point — the keyboard model works on the
111
+ * rendered DOM, never on the description that produced it.
112
+ */
113
+ export type SubmenuPanel = (options: {
114
+ id: string;
115
+ }) => TemplateResult;
79
116
  export interface WireMenuOptions {
80
117
  /** Close the whole stack, back to the original trigger. */
81
118
  onCloseAll: () => void;
@@ -100,3 +137,10 @@ export interface WireMenuOptions {
100
137
  * keeps a stack of three from leaving two behind when the root closes.
101
138
  */
102
139
  export declare function wireMenu(panel: HTMLElement, options: WireMenuOptions): () => void;
140
+ /**
141
+ * Register a composed submenu panel against a trigger id.
142
+ *
143
+ * The parts in `DropdownMenu` and friends build their own markup, so they hand
144
+ * the factory over directly instead of going through `MenuEntry`.
145
+ */
146
+ export declare function registerSubmenu(id: string, build: SubmenuPanel): void;