torch-glare 2.5.3 → 2.5.5

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 (56) hide show
  1. package/apps/lib/components/ActionButton.tsx +39 -6
  2. package/apps/lib/components/Badge.tsx +5 -2
  3. package/apps/lib/components/BadgeField.tsx +71 -67
  4. package/apps/lib/components/Button.tsx +4 -4
  5. package/apps/lib/components/Calendar.tsx +7 -17
  6. package/apps/lib/components/Card.tsx +2 -1
  7. package/apps/lib/components/ColorPicker.tsx +1 -1
  8. package/apps/lib/components/ContextMenu.tsx +65 -22
  9. package/apps/lib/components/DataViews/context.ts +2 -2
  10. package/apps/lib/components/DataViews/data-views.tsx +3 -3
  11. package/apps/lib/components/DataViews/filters/filters.tsx +0 -2
  12. package/apps/lib/components/DataViews/views/table-view.tsx +190 -153
  13. package/apps/lib/components/Drawer.tsx +18 -1
  14. package/apps/lib/components/DropdownMenu.tsx +65 -22
  15. package/apps/lib/components/FormBuilder/fields/FieldShell.tsx +19 -5
  16. package/apps/lib/components/FormBuilder/types.ts +16 -0
  17. package/apps/lib/components/FormRenderer/form-renderer.tsx +16 -5
  18. package/apps/lib/components/FormRenderer/stepper.tsx +22 -16
  19. package/apps/lib/components/HeaderBar.tsx +51 -53
  20. package/apps/lib/components/Input.tsx +19 -4
  21. package/apps/lib/components/InputField.tsx +46 -47
  22. package/apps/lib/components/Popover.tsx +108 -56
  23. package/apps/lib/components/SearchableSelect.tsx +22 -17
  24. package/apps/lib/components/SearchableTree.tsx +33 -17
  25. package/apps/lib/components/SearchableTreeDialog.tsx +21 -12
  26. package/apps/lib/components/SectionBlock.tsx +3 -1
  27. package/apps/lib/components/Select.tsx +86 -54
  28. package/apps/lib/components/SimpleSelect.tsx +2 -2
  29. package/apps/lib/components/SlideDatePicker.tsx +15 -4
  30. package/apps/lib/components/Stepper.tsx +329 -180
  31. package/apps/lib/components/Switch.tsx +2 -2
  32. package/apps/lib/components/TabSwitch.tsx +18 -12
  33. package/apps/lib/components/Table.tsx +1 -1
  34. package/apps/lib/components/Textarea.tsx +29 -4
  35. package/apps/lib/components/TreeDropDown.tsx +18 -6
  36. package/apps/lib/layouts/FieldSection.tsx +28 -2
  37. package/apps/lib/registry.json +7 -17
  38. package/apps/lib/tsconfig.tsbuildinfo +1 -1
  39. package/docs/components/action-button.md +3 -1
  40. package/docs/components/badge-field.md +4 -4
  41. package/docs/components/context-menu.md +3 -1
  42. package/docs/components/data-views/examples/filters.md +0 -1
  43. package/docs/components/data-views/index.md +1 -17
  44. package/docs/components/dropdown-menu.md +3 -0
  45. package/docs/components/form-builder.md +27 -1
  46. package/docs/components/header-bar.md +3 -2
  47. package/docs/components/input-field.md +3 -3
  48. package/docs/components/select.md +1 -1
  49. package/docs/components/stepper.md +119 -24
  50. package/docs/migration/changelog.md +13 -0
  51. package/docs/reference/tailwind-plugins.md +42 -0
  52. package/docs/tutorials/getting-started.md +32 -11
  53. package/package.json +1 -1
  54. package/apps/lib/components/DataViews/filters/summary.tsx +0 -65
  55. package/apps/lib/components/FormStepper.tsx +0 -272
  56. package/docs/components/form-stepper.md +0 -250
@@ -125,162 +125,194 @@ function TableViewImpl({
125
125
  )}
126
126
  >
127
127
  <div className="flex flex-1 flex-col gap-4 overflow-hidden">
128
- <div
129
- ref={scrollRef}
130
- // `min-w-0` so the scroller can be narrower than the table inside it. Without it a flex
131
- // item refuses to shrink below its content, so pinning the table to its natural width
132
- // pushes the whole component wide instead of scrolling within it.
133
- className="min-w-0 flex-1 overflow-auto rounded-lg"
134
- >
135
- <Table ref={tableRef} className="w-full">
136
- {/* The header sticks to the scroller above by default that lives on `TableHeader`
137
- in the primitive. Two things this view adds:
128
+ {/* The scroller and the end action are stacked here with NO gap, so the bar sits flush
129
+ under the table the way it does on the card. `min-h-0` lets the scroller actually
130
+ shrink a flex item will not go below its content without it. */}
131
+ <div className="flex min-h-0 flex-1 flex-col">
132
+ <div
133
+ ref={scrollRef}
134
+ // `min-w-0` so the scroller can be narrower than the table inside it. Without it a flex
135
+ // item refuses to shrink below its content, so pinning the table to its natural width
136
+ // pushes the whole component wide instead of scrolling within it.
137
+ className="min-w-0 flex-1 overflow-auto rounded-lg"
138
+ >
139
+ {/* Sizes the table, not the footer — the end action now lives outside this scroller.
140
+ Inside an `overflow-auto` scroller a child's `w-full` resolves against the *visible*
141
+ width, so the table needs `w-max` to reach its natural width and scroll; `min-w-full`
142
+ keeps it filling the scroller when the table is narrower. */}
143
+ <div className="w-max min-w-full">
144
+ {/* `overflow-visible` opts out of the primitive's `overflow-hidden` (tailwind-merge
145
+ lets ours win). It has to: a clipping table is its own scrollport, and the sticky
146
+ header would then resolve against a box that never scrolls. Safe here because the
147
+ scroller above is `min-w-0 overflow-auto`, so a wide table scrolls inside it rather
148
+ than pushing the layout. */}
149
+ <Table ref={tableRef} className="w-full overflow-visible">
150
+ {/* The header sticks to the scroller above by default — that lives on `TableHeader`
151
+ in the primitive. Two things this view adds:
138
152
 
139
- Opacity. The primitive's header token is translucent, so scrolling rows read
140
- straight through it; the primitive can't fix that without naming a surface colour
141
- it doesn't know. Here the surface *is* known — the view root above sets
142
- `form-base` — so paint that as the background-color (tailwind-merge drops the
143
- primitive's translucent one, same `bg-color` group) and re-apply the tint as a
144
- background-image, which stacks above background-color. Composited that is the
145
- exact colour the header already had, just no longer see-through.
153
+ Opacity. The primitive's header token is translucent, so scrolling rows read
154
+ straight through it; the primitive can't fix that without naming a surface colour
155
+ it doesn't know. Here the surface *is* known — the view root above sets
156
+ `form-base` — so paint that as the background-color (tailwind-merge drops the
157
+ primitive's translucent one, same `bg-color` group) and re-apply the tint as a
158
+ background-image, which stacks above background-color. Composited that is the
159
+ exact colour the header already had, just no longer see-through.
146
160
 
147
- And `shadow-none`, because the drop shadow reads as a seam now that the view
148
- carries its own border. */}
149
- <TableHeader className="bg-background-presentation-form-base bg-[image:linear-gradient(var(--background-presentation-form-header),var(--background-presentation-form-header))] shadow-none">
150
- <TableRow>
151
- {onRowMove && <TableHead isDummy className="w-8" />}
152
- {selectable && (
153
- <TableHead isDummy className="w-12">
154
- {/* Size is stated on both this and the per-row checkbox rather than left to
155
- `Checkbox`'s default — they have to agree, and relying on the default on
156
- one side only is what previously made the select-all bigger than the
157
- column it heads. */}
158
- <Checkbox
159
- size="M"
160
- checked={allSelected ? true : someSelected ? "indeterminate" : false}
161
- onCheckedChange={toggleAll}
162
- aria-label="Select all rows"
163
- />
164
- </TableHead>
165
- )}
166
- {/* Keyed by position: two fields may share a `path` — the same value shown two
167
- ways — and keying on it would collide. */}
168
- {visibleFields.map((field, i) => (
169
- <TableHead
170
- key={`${field.path}-${i}`}
171
- size="M"
172
- sortType={sort?.path === field.path ? sort.direction : undefined}
173
- onSort={() => setSort(cycle(field.path))}
174
- // Without this every sort control announces itself as a bare "Sort ascending",
175
- // so a screen reader hears one identical button per column.
176
- sortLabel={field.label ?? formatPathLabel(field.path)}
177
- >
178
- {/* Wrapped rather than handed to `Table` as bare text: `truncate` needs a box
179
- to clip, and the label's parent in the primitive is already `flex min-w-0`
180
- so this span shrinks and ellipsises instead of wrapping the header row
181
- onto a second line. */}
182
- <span className="truncate">{field.label ?? field.path}</span>
183
- </TableHead>
184
- ))}
185
- </TableRow>
186
- </TableHeader>
161
+ And `shadow-none`, because the drop shadow reads as a seam now that the view
162
+ carries its own border. */}
163
+ <TableHeader className="bg-background-presentation-form-base bg-[image:linear-gradient(var(--background-presentation-form-header),var(--background-presentation-form-header))] shadow-none">
164
+ <TableRow>
165
+ {onRowMove && <TableHead isDummy className="w-8" />}
166
+ {selectable && (
167
+ <TableHead isDummy className="w-12">
168
+ {/* Size is stated on both this and the per-row checkbox rather than left to
169
+ `Checkbox`'s default — they have to agree, and relying on the default on
170
+ one side only is what previously made the select-all bigger than the
171
+ column it heads. */}
172
+ <Checkbox
173
+ size="M"
174
+ checked={allSelected ? true : someSelected ? "indeterminate" : false}
175
+ onCheckedChange={toggleAll}
176
+ aria-label="Select all rows"
177
+ />
178
+ </TableHead>
179
+ )}
180
+ {/* Keyed by position: two fields may share a `path` — the same value shown two
181
+ ways — and keying on it would collide. */}
182
+ {visibleFields.map((field, i) => (
183
+ <TableHead
184
+ key={`${field.path}-${i}`}
185
+ size="M"
186
+ sortType={sort?.path === field.path ? sort.direction : undefined}
187
+ onSort={() => setSort(cycle(field.path))}
188
+ // Without this every sort control announces itself as a bare "Sort ascending",
189
+ // so a screen reader hears one identical button per column.
190
+ sortLabel={field.label ?? formatPathLabel(field.path)}
191
+ >
192
+ {/* Wrapped rather than handed to `Table` as bare text: `truncate` needs a box
193
+ to clip, and the label's parent in the primitive is already `flex min-w-0`
194
+ so this span shrinks and ellipsises instead of wrapping the header row
195
+ onto a second line. */}
196
+ <span className="truncate">{field.label ?? field.path}</span>
197
+ </TableHead>
198
+ ))}
199
+ </TableRow>
200
+ </TableHeader>
187
201
 
188
- <TableBody>
189
- {loading && <SkeletonRows fields={visibleFields} grip={Boolean(onRowMove)} selectable={selectable} />}
190
- {virtualize && padTop > 0 && (
191
- <tr aria-hidden style={{ height: padTop }} />
192
- )}
193
- <DragList ids={ids}>
194
- {renderIndexes.map((index) => {
195
- const row = rows[index];
196
- const id = ids[index];
197
- const selected = selection.includes(id);
198
- return (
199
- <DraggableRow
200
- key={id}
201
- id={id}
202
- draggable={Boolean(onRowMove)}
203
- state={selected ? "selected" : undefined}
204
- onClick={onRowClick ? () => onRowClick(row, id) : undefined}
205
- // A clickable row has to be reachable without a mouse. `<tr>` carries no
206
- // implicit role, so a bare `onClick` is invisible to the keyboard and to a
207
- // screen reader; these only appear when the row is actually interactive.
208
- tabIndex={onRowClick ? 0 : undefined}
209
- role={onRowClick ? "button" : undefined}
210
- onKeyDown={
211
- onRowClick
212
- ? (e) => {
213
- if (e.key !== "Enter" && e.key !== " ") return;
214
- if (e.target !== e.currentTarget) return;
215
- e.preventDefault();
216
- onRowClick(row, id);
202
+ <TableBody>
203
+ {loading && <SkeletonRows fields={visibleFields} grip={Boolean(onRowMove)} selectable={selectable} />}
204
+ {virtualize && padTop > 0 && (
205
+ <tr aria-hidden style={{ height: padTop }} />
206
+ )}
207
+ <DragList ids={ids}>
208
+ {renderIndexes.map((index) => {
209
+ const row = rows[index];
210
+ const id = ids[index];
211
+ const selected = selection.includes(id);
212
+ return (
213
+ <DraggableRow
214
+ key={id}
215
+ id={id}
216
+ draggable={Boolean(onRowMove)}
217
+ state={selected ? "selected" : undefined}
218
+ onClick={onRowClick ? () => onRowClick(row, id) : undefined}
219
+ // A clickable row has to be reachable without a mouse. `<tr>` carries no
220
+ // implicit role, so a bare `onClick` is invisible to the keyboard and to a
221
+ // screen reader; these only appear when the row is actually interactive.
222
+ tabIndex={onRowClick ? 0 : undefined}
223
+ role={onRowClick ? "button" : undefined}
224
+ onKeyDown={
225
+ onRowClick
226
+ ? (e) => {
227
+ if (e.key !== "Enter" && e.key !== " ") return;
228
+ if (e.target !== e.currentTarget) return;
229
+ e.preventDefault();
230
+ onRowClick(row, id);
231
+ }
232
+ : undefined
217
233
  }
218
- : undefined
219
- }
220
- className={cn(
221
- // 40px per Figma's `Table-RowBackgroand-1.1`. `Table`'s body cells default
222
- // to 50, and the two live on different elements, so the cells below must be
223
- // told as well or CSS keeps the larger.
224
- "h-[40px]",
225
- "focus-visible:ring-border-presentation-state-focus outline-none focus-visible:ring-2",
226
- onRowClick && "cursor-pointer",
227
- )}
228
- >
229
- {onRowMove && <GripCell />}
230
- {selectable && (
231
- <TableCell isDummy className="h-[40px] w-12" onClick={(e) => e.stopPropagation()}>
232
- {/* What `TableCheckbox` renders, inlined: its props are typed as button
233
- attributes, so it cannot express a controlled checkbox. */}
234
- <div className="flex items-center justify-center">
235
- <Checkbox
236
- size="M"
237
- checked={selected}
238
- onCheckedChange={() => toggleRow(id)}
239
- aria-label="Select row"
240
- />
241
- </div>
242
- </TableCell>
243
- )}
244
- {visibleFields.map((field, i) => {
245
- // `undefined` means "you paint it" distinct from `null`, which is a
246
- // deliberate blank.
247
- const custom = renderCell?.({ field, row, id, index, fields: visibleFields });
248
- return (
249
- <TableCell key={`${field.path}-${i}`} className="h-[40px]">
250
- {/* `isolate` confines the Badge's mix-blend-luminosity to a local
251
- stacking context and `transform-gpu` promotes it to its own layer, so
252
- the table's post-mount column reflow repaints cleanly instead of
253
- leaving a ghosted badge frame. */}
254
- <span className="isolate inline-flex transform-gpu">
255
- {custom === undefined ? <Cell field={field} row={row} /> : custom}
256
- </span>
257
- </TableCell>
258
- );
259
- })}
260
- </DraggableRow>
261
- );
262
- })}
263
- </DragList>
264
- {virtualize && padBottom > 0 && (
265
- <tr aria-hidden style={{ height: padBottom }} />
266
- )}
267
- {/* The trigger. A row of its own rather than an element after the table, so it sits
268
- inside the same scroller the rows do. */}
269
- {hasMore && !loading && (
270
- <tr ref={sentinelRef as React.Ref<HTMLTableRowElement>} aria-hidden>
271
- <td style={{ height: 1, padding: 0, border: 0 }} colSpan={100} />
272
- </tr>
273
- )}
274
- {loadingMore && (
275
- <SkeletonRows
276
- rows={2}
277
- fields={visibleFields}
278
- grip={Boolean(onRowMove)}
279
- selectable={selectable}
280
- />
281
- )}
282
- </TableBody>
283
- </Table>
234
+ className={cn(
235
+ // 40px per Figma's `Table-RowBackgroand-1.1`. `Table`'s body cells default
236
+ // to 50, and the two live on different elements, so the cells below must be
237
+ // told as well or CSS keeps the larger.
238
+ "h-[40px]",
239
+ "focus-visible:ring-border-presentation-state-focus outline-none focus-visible:ring-2",
240
+ onRowClick && "cursor-pointer",
241
+ )}
242
+ >
243
+ {onRowMove && <GripCell />}
244
+ {selectable && (
245
+ <TableCell isDummy className="min-h-[40px] w-12" onClick={(e) => e.stopPropagation()}>
246
+ {/* What `TableCheckbox` renders, inlined: its props are typed as button
247
+ attributes, so it cannot express a controlled checkbox. */}
248
+ <div className="flex items-center justify-center">
249
+ <Checkbox
250
+ size="M"
251
+ checked={selected}
252
+ onCheckedChange={() => toggleRow(id)}
253
+ aria-label="Select row"
254
+ />
255
+ </div>
256
+ </TableCell>
257
+ )}
258
+ {visibleFields.map((field, i) => {
259
+ // `undefined` means "you paint it" — distinct from `null`, which is a
260
+ // deliberate blank.
261
+ const custom = renderCell?.({ field, row, id, index, fields: visibleFields });
262
+ // `fade={false}` and clip instead. The fade is a `mask-image` on every
263
+ // cell, close to free on its own but very expensive once a sticky header
264
+ // repaints the region each scroll frame: measured on this page,
265
+ // mask+sticky costs ~61ms/frame against ~29ms with the mask off and
266
+ // ~17ms with neither. `overflow-hidden` is passed back because
267
+ // `fade={false}` otherwise switches the cell to `overflow-visible`, and
268
+ // the text would spill into the next column.
269
+ return (
270
+ <TableCell
271
+ key={`${field.path}-${i}`}
272
+ className="min-h-[40px]"
273
+ fade={false}
274
+ childrenClassName="overflow-hidden"
275
+ >
276
+ {/* `isolate` confines the Badge's mix-blend-luminosity to a local
277
+ stacking context and `transform-gpu` promotes it to its own layer, so
278
+ the table's post-mount column reflow repaints cleanly instead of
279
+ leaving a ghosted badge frame. */}
280
+ <span className="isolate inline-flex transform-gpu">
281
+ {custom === undefined ? <Cell field={field} row={row} /> : custom}
282
+ </span>
283
+ </TableCell>
284
+ );
285
+ })}
286
+ </DraggableRow>
287
+ );
288
+ })}
289
+ </DragList>
290
+ {virtualize && padBottom > 0 && (
291
+ <tr aria-hidden style={{ height: padBottom }} />
292
+ )}
293
+ {/* The trigger. A row of its own rather than an element after the table, so it sits
294
+ inside the same scroller the rows do. */}
295
+ {hasMore && !loading && (
296
+ <tr ref={sentinelRef as React.Ref<HTMLTableRowElement>} aria-hidden>
297
+ <td style={{ height: 1, padding: 0, border: 0 }} colSpan={100} />
298
+ </tr>
299
+ )}
300
+ {loadingMore && (
301
+ <SkeletonRows
302
+ rows={2}
303
+ fields={visibleFields}
304
+ grip={Boolean(onRowMove)}
305
+ selectable={selectable}
306
+ />
307
+ )}
308
+ </TableBody>
309
+ </Table>
310
+ </div>
311
+ </div>
312
+ {/* Outside the scroller, deliberately: as a sibling its width is the component's visible
313
+ width, so it spans the full outer container and stays put while the columns scroll
314
+ sideways under it — instead of stretching to the table's scrollable width and sliding
315
+ away like a normal row. Same placement the form Table field uses. */}
284
316
  {onAddRow && (
285
317
  <TableEndAction onClick={onAddRow}>
286
318
  <Plus className="h-4 w-4" aria-hidden />
@@ -419,7 +451,12 @@ function SkeletonRows({
419
451
  {grip && <TableCell isDummy className="h-[40px] w-8" />}
420
452
  {selectable && <TableCell isDummy className="h-[40px] w-12" />}
421
453
  {fields.map((field, i) => (
422
- <TableCell key={`${field.path}-${i}`} className="h-[40px]">
454
+ <TableCell
455
+ key={`${field.path}-${i}`}
456
+ className="min-h-[40px]"
457
+ fade={false}
458
+ childrenClassName="overflow-hidden"
459
+ >
423
460
  {/* Widths cycle rather than repeat, so a column of bars reads as text that has not
424
461
  arrived instead of as a grid. */}
425
462
  <SkeletonBar className={["w-[70%]", "w-[45%]", "w-[85%]", "w-[60%]"][(row + i) % 4]} />
@@ -37,6 +37,7 @@ DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
37
37
  interface DrawerContentProps extends React.ComponentPropsWithoutRef<
38
38
  typeof DrawerPrimitive.Content
39
39
  > {
40
+ /** @deprecated No effect here — the drag handle is `DrawerPanel`'s `showHandle`. */
40
41
  showHandle?: boolean;
41
42
  notch?: React.ReactNode;
42
43
  notchSide?: "left" | "right";
@@ -87,7 +88,17 @@ const DrawerPanel = React.forwardRef<HTMLDivElement, DrawerPanelProps>(
87
88
  // would render white-on-light = invisible).
88
89
  data-theme="light"
89
90
  className={cn(
90
- "flex flex-1 gap-2 rounded-t-[16px] p-1 bg-[#F0F0F0] min-h-0",
91
+ // `flex-col` is load-bearing: this panel stacks header / body / footer, and its own
92
+ // `showHandle` centres the drag handle with `mx-auto`, which only centres in a column.
93
+ // It was dropped in 37fddd5 alongside the tray's — on the tray that was deliberate (FormDrawer
94
+ // puts the panel and its summary side by side), here it was not, and every consumer that puts
95
+ // a header/body/footer straight into a panel rendered them in a row.
96
+ //
97
+ // `min-w-0` for the same reason, one axis over: the tray is a row now, so width is its
98
+ // main axis, and a flex item's default `min-width: auto` pins it to its content — a wide
99
+ // form pushed the panel straight out past the tray. `min-h-0` alone covered the old
100
+ // column tray; the row needs both.
101
+ "flex flex-1 flex-col gap-2 rounded-t-[16px] p-1 bg-[#F0F0F0] min-h-0 min-w-0",
91
102
  framed && "border border-[#D4D4D4] shadow-[inset_0_-4px_16px_rgba(0,0,0,0.1)]",
92
103
  className,
93
104
  )}
@@ -113,6 +124,12 @@ const DrawerContent = React.forwardRef<
113
124
  framed: framedProp,
114
125
  wrapperClassName,
115
126
  trayClassName,
127
+ // Destructured only to keep it out of `...props`. The handle belongs to `DrawerPanel` now, so
128
+ // this does nothing here — but it was never pulled out either, so it was being spread onto the
129
+ // DOM node and React warned "does not recognize the `showHandle` prop on a DOM element" every
130
+ // time a drawer opened. Kept in the props type rather than removed: consumers still pass it.
131
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
132
+ showHandle,
116
133
  ...props
117
134
  },
118
135
  ref,
@@ -70,16 +70,27 @@ const DropdownMenuContent = React.forwardRef<
70
70
  ref={ref}
71
71
  sideOffset={sideOffset}
72
72
  collisionPadding={collisionPadding}
73
- // Cap at maxHeight, but never exceed the space Radix has after collision
74
- // handling. The menu scrolls (overflow on the surface) past this height.
73
+ // Cap at maxHeight, but never exceed the space Radix has after collision handling. The
74
+ // `100vh` fallback is load-bearing: an undefined var invalidates the whole `min()`, so
75
+ // `max-height` would resolve to `none` and the panel — which no longer scrolls itself —
76
+ // would grow unbounded with its rows clipped and unreachable.
75
77
  style={{
76
- maxHeight: `min(${maxHeight}px, var(--radix-dropdown-menu-content-available-height))`,
78
+ maxHeight: `min(${maxHeight}px, var(--radix-dropdown-menu-content-available-height, 100vh))`,
77
79
  ...style,
78
80
  }}
79
81
  className={cn(menuContentStyles({ variant }), className)}
80
82
  {...props}
81
83
  >
82
- {autoGroup ? autoGroupChildren(children) : children}
84
+ {/* Dedicated scroll viewport, matching Select's: the cap lives on the panel above, this
85
+ fills what is left and scrolls. `min-h-0` is what makes it work — a flex item will not
86
+ shrink below its content, so without it the list grows past the panel and the panel's
87
+ `overflow-hidden` just clips the rows with no scrollbar.
88
+
89
+ `gap-1` is re-declared here because `autoGroupChildren` emits several siblings (a group,
90
+ a label, a separator…) and this is now the element they are siblings within. */}
91
+ <div className="flex flex-col gap-1 flex-1 min-h-0 overflow-y-auto overflow-x-hidden rounded-[10px] scrollbar-hide">
92
+ {autoGroup ? autoGroupChildren(children) : children}
93
+ </div>
83
94
  </DropdownMenuPrimitive.Content>
84
95
  </DropdownMenuPrimitive.Portal>
85
96
  ),
@@ -123,18 +134,45 @@ const DropdownMenuSubContent = React.forwardRef<
123
134
  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent> & {
124
135
  variant?: "PresentationStyle";
125
136
  autoGroup?: boolean;
137
+ maxHeight?: number;
126
138
  }
127
- >(({ className, variant = "PresentationStyle", autoGroup = true, children, ...props }, ref) => (
128
- <DropdownMenuPrimitive.Portal>
129
- <DropdownMenuPrimitive.SubContent
130
- ref={ref}
131
- className={cn(menuContentStyles({ variant }), className)}
132
- {...props}
133
- >
134
- {autoGroup ? autoGroupChildren(children) : children}
135
- </DropdownMenuPrimitive.SubContent>
136
- </DropdownMenuPrimitive.Portal>
137
- ));
139
+ >(
140
+ (
141
+ {
142
+ className,
143
+ variant = "PresentationStyle",
144
+ autoGroup = true,
145
+ collisionPadding = 8,
146
+ maxHeight = 320,
147
+ // Destructured out of `{...props}` so the spread below cannot clobber the cap. Radix
148
+ // re-publishes the namespaced available-height var on SubContent, so the same expression
149
+ // Content uses works here unchanged.
150
+ style,
151
+ children,
152
+ ...props
153
+ },
154
+ ref,
155
+ ) => (
156
+ <DropdownMenuPrimitive.Portal>
157
+ <DropdownMenuPrimitive.SubContent
158
+ ref={ref}
159
+ collisionPadding={collisionPadding}
160
+ style={{
161
+ maxHeight: `min(${maxHeight}px, var(--radix-dropdown-menu-content-available-height, 100vh))`,
162
+ ...style,
163
+ }}
164
+ className={cn(menuContentStyles({ variant }), className)}
165
+ {...props}
166
+ >
167
+ {/* Same panel-clips / viewport-scrolls split as Content. A submenu is a peer surface, so it
168
+ shares the 320px default rather than getting a smaller one of its own. */}
169
+ <div className="flex flex-col gap-1 flex-1 min-h-0 overflow-y-auto overflow-x-hidden rounded-[10px] scrollbar-hide">
170
+ {autoGroup ? autoGroupChildren(children) : children}
171
+ </div>
172
+ </DropdownMenuPrimitive.SubContent>
173
+ </DropdownMenuPrimitive.Portal>
174
+ ),
175
+ );
138
176
  DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
139
177
 
140
178
  const DropdownMenuItem = React.forwardRef<
@@ -456,16 +494,19 @@ export const menuContentStyles = cva(
456
494
  "rounded-[14px]",
457
495
  "min-w-[240px]",
458
496
  "outline-none",
459
- "overflow-y-auto",
460
- "overflow-x-hidden",
497
+ // The panel clips; the inner viewport below owns scrolling. Height is capped inline on the
498
+ // Content element from `min(maxHeight, available-height)` — no `max-h-*` class here on
499
+ // purpose, so the inline value governs.
500
+ "overflow-hidden",
461
501
  // Only animate the OPEN (enter) state. An exit animation on [data-state=closed]
462
502
  // holds the old DOM node during close, which breaks the context menu's
463
503
  // close/reposition on a second right-click (Radix issue #2572).
464
504
  "data-[state=open]:animate-in",
465
505
  "data-[state=open]:fade-in-0",
466
- "scrollbar-hide",
467
506
  "backdrop-blur-[21px]",
468
- "flex gap-1 flex-col",
507
+ // No `gap` here: the panel has exactly one child (the scroll viewport), so a gap between
508
+ // siblings has nothing to act on. The 4px between groups/labels lives on that viewport.
509
+ "flex flex-col",
469
510
  ],
470
511
  {
471
512
  variants: {
@@ -475,9 +516,11 @@ export const menuContentStyles = cva(
475
516
  "shadow-[0_0_32px_2px_rgba(0,0,0,0.20),0_0_48px_2px_rgba(0,0,0,0.05)]",
476
517
  ],
477
518
  },
478
- defaultVariants: {
479
- variant: "PresentationStyle",
480
- },
519
+ },
520
+ // Was nested inside `variants`, where cva reads it as a variant group named
521
+ // "defaultVariants" and no default is ever applied. `menuGroupStyles` below has it right.
522
+ defaultVariants: {
523
+ variant: "PresentationStyle",
481
524
  },
482
525
  },
483
526
  );
@@ -16,6 +16,7 @@ import { FormField, FormItem, FormControl } from "../../Form";
16
16
  import { FieldHint } from "../../FieldHint";
17
17
  import { Tooltip } from "../../Tooltip";
18
18
  import { useDirection, useStepRegistry, useBare } from "../context";
19
+ import type { FieldHintSpec } from "../types";
19
20
 
20
21
  export interface FieldShellProps {
21
22
  name: string;
@@ -26,6 +27,8 @@ export interface FieldShellProps {
26
27
  hidden?: boolean;
27
28
  /** Force the field's layout direction, overriding the form's `useDirection()` context. */
28
29
  direction?: "horizontal" | "vertical" | "flexible";
30
+ /** Alerts stacked under the validation error. See `FieldHintSpec`. */
31
+ hints?: FieldHintSpec[];
29
32
  /** The input, wired to the react-hook-form field. */
30
33
  children: (
31
34
  field: ControllerRenderProps<FieldValues, string>,
@@ -47,6 +50,7 @@ export function FieldShell({
47
50
  fullWidth,
48
51
  hidden,
49
52
  direction: directionProp,
53
+ hints,
50
54
  children,
51
55
  }: FieldShellProps) {
52
56
  const form = useFormContext();
@@ -108,7 +112,7 @@ export function FieldShell({
108
112
  secondaryLabel={description}
109
113
  direction={direction}
110
114
  className={fullWidth ? "max-w-full" : undefined}
111
- childrenUnderLabel={<FieldError message={fieldError} />}
115
+ childrenUnderLabel={<FieldMessages message={fieldError} hints={hints} />}
112
116
  >
113
117
  <FormField
114
118
  control={form.control}
@@ -125,10 +129,20 @@ export function FieldShell({
125
129
  );
126
130
  }
127
131
 
128
- /** Validation error, shown as a `FieldHint` alert (no tooltip); null when there's none. */
129
- function FieldError({ message }: { message?: string }) {
130
- if (!message) return null;
131
- return <FieldHint state="error" label={message} />;
132
+ /**
133
+ * The stack under a field: the validation error first (it is the actionable one), then any author
134
+ * `hints` in order. Renders nothing when there is neither, so a field without hints is unchanged.
135
+ */
136
+ function FieldMessages({ message, hints }: { message?: string; hints?: FieldHintSpec[] }) {
137
+ if (!message && !hints?.length) return null;
138
+ return (
139
+ <div className="flex flex-col items-start gap-[4px]">
140
+ {message && <FieldHint state="error" label={message} />}
141
+ {hints?.map((hint, i) => (
142
+ <FieldHint key={i} state={hint.state ?? "info"} label={hint.label} icon={hint.icon} />
143
+ ))}
144
+ </div>
145
+ );
132
146
  }
133
147
 
134
148
  /**
@@ -41,6 +41,16 @@ export type FieldKind =
41
41
  | "custom";
42
42
 
43
43
  /** Props shared by every `FormBuilder.*` field. `name` is the RHF path. */
44
+ /**
45
+ * One alert under a field. Mirrors `FieldHint`'s own props so the design system stays the single
46
+ * source of truth for how each state looks.
47
+ */
48
+ export interface FieldHintSpec {
49
+ label: ReactNode;
50
+ state?: "info" | "warning" | "error" | "success";
51
+ icon?: ReactNode;
52
+ }
53
+
44
54
  export interface BaseFieldProps {
45
55
  name: string;
46
56
  label?: ReactNode;
@@ -51,6 +61,12 @@ export interface BaseFieldProps {
51
61
  hidden?: boolean;
52
62
  /** Span the full section width. */
53
63
  fullWidth?: boolean;
64
+ /**
65
+ * Alerts stacked under the field. The validation error, when there is one, always renders first —
66
+ * it is the actionable message — and these follow in order. Ignored in `bare` mode (a
67
+ * `FormBuilder.Table` cell), where errors surface as a tooltip to keep the row one line tall.
68
+ */
69
+ hints?: FieldHintSpec[];
54
70
  }
55
71
 
56
72
  export interface OptionItem {