@stll/ui 0.89.1 → 0.90.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 (57) hide show
  1. package/dist/calendar/day-calendar.d.ts +11 -0
  2. package/dist/calendar/day-calendar.js +9 -3
  3. package/dist/components/composer-frame.d.ts +22 -0
  4. package/dist/components/composer-frame.js +139 -0
  5. package/dist/components/composer-frame.native.d.ts +29 -0
  6. package/dist/components/composer-frame.native.js +105 -0
  7. package/dist/components/composer-frame.shared.d.ts +50 -0
  8. package/dist/components/composer-frame.shared.js +0 -0
  9. package/dist/components/composer-layout.d.ts +35 -0
  10. package/dist/components/composer-layout.js +52 -0
  11. package/dist/components/composer-tokens.d.ts +24 -44
  12. package/dist/components/composer-tokens.js +25 -45
  13. package/dist/components/composer.d.ts +2 -15
  14. package/dist/components/composer.js +2 -17
  15. package/dist/components/control-face.js +1 -1
  16. package/dist/components/details-grid.js +7 -3
  17. package/dist/components/dialog-form-state.js +4 -3
  18. package/dist/components/entity-actions.d.ts +33 -1
  19. package/dist/components/entity-actions.js +47 -23
  20. package/dist/components/hex-color-picker.js +1 -1
  21. package/dist/components/landing-shell.d.ts +3 -3
  22. package/dist/components/landing-shell.js +20 -27
  23. package/dist/components/menu.d.ts +7 -1
  24. package/dist/components/menu.js +8 -3
  25. package/dist/components/outcome-screen.js +1 -1
  26. package/dist/components/outline-rail.js +13 -12
  27. package/dist/components/select.js +1 -1
  28. package/dist/components/settings.d.ts +6 -0
  29. package/dist/components/settings.js +14 -3
  30. package/dist/components/sheet.native.js +3 -3
  31. package/dist/components/sidebar.js +15 -7
  32. package/dist/components/switch.js +2 -2
  33. package/dist/components/switch.native.d.ts +2 -1
  34. package/dist/components/switch.native.js +6 -5
  35. package/dist/components/textarea.d.ts +5 -1
  36. package/dist/components/textarea.js +2 -2
  37. package/dist/components/textarea.native.d.ts +6 -3
  38. package/dist/components/textarea.native.js +27 -8
  39. package/dist/components/textarea.shared.d.ts +8 -1
  40. package/dist/components/toggle-classes.d.ts +9 -2
  41. package/dist/components/toggle-classes.js +10 -3
  42. package/dist/data-table/schema.js +1 -5
  43. package/dist/effects/dom.d.ts +53 -0
  44. package/dist/effects/dom.js +177 -0
  45. package/dist/effects/effects.d.ts +88 -0
  46. package/dist/effects/effects.js +196 -0
  47. package/dist/hooks/use-inline-overflow.d.ts +2 -2
  48. package/dist/hooks/use-inline-overflow.js +12 -15
  49. package/dist/hooks/use-latest.d.ts +2 -19
  50. package/dist/hooks/use-latest.js +1 -27
  51. package/dist/icons.d.ts +2 -2
  52. package/dist/icons.js +2 -2
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.js +2 -2
  55. package/dist/lib/slot.js +7 -3
  56. package/dist/styles/theme.css +29 -0
  57. package/package.json +17 -1
@@ -1,12 +1,11 @@
1
1
  // src/components/composer-tokens.ts
2
2
  /**
3
- * The tokens every composer box shares: the chat hero, the chat follow-up
4
- * bar, the docked bar over documents (inspector chat, file overlay,
5
- * Template Studio) and the law home's entry box all render one shell from
6
- * these, so they restyle together. A surface that needs the look imports
7
- * these rather than copying the classes; a copy is how the boxes drifted
8
- * apart the first time (44px / `rounded-lg` / 14px in the chat, 38px /
9
- * `rounded-2xl` / 13px in the inspector).
3
+ * The tokens a composer's paint shares: the box, its text, its round
4
+ * controls, its text region's cap and the rows beside it. The box's layout
5
+ * (where the text sits, where the controls sit, when it switches between
6
+ * the two) is not a token: it belongs to `ComposerFrame` (./composer-frame.tsx
7
+ * and its React Native twin ./composer-frame.native.tsx), and every composer
8
+ * renders through it, so no surface can lay text and controls out by hand.
10
9
  */
11
10
  /** Shared responsive size for the two round controls flanking a composer. */
12
11
  const COMPOSER_CONTROL_BUTTON_SIZE = "icon-sm";
@@ -15,51 +14,32 @@ const COMPOSER_CONTROL_BUTTON_SIZE = "icon-sm";
15
14
  * stature it reads as a soft pill, which is the shape the composers were
16
15
  * meant to unify on. */
17
16
  const COMPOSER_BOX_CLASS = "bg-background rounded-2xl border";
18
- /** The box's focus ring in its default (non-anonymized) treatment. */
19
- const COMPOSER_BOX_FOCUS_CLASS = "focus-within:border-ring";
20
17
  /**
21
- * The box's "shield active" treatment when the next send is anonymized: a
22
- * blue ring replaces the default focus border (both together read as a
23
- * double ring on click).
18
+ * Background for chrome floating over a document page (the docked composer,
19
+ * the suggestion stepper, preset chips). In light mode the rendered page
20
+ * reads as white paper in every accent palette, while `--popover` follows
21
+ * the palette (Flexoki `#fffcf0`, Nord `#eceff4`): solid but visibly
22
+ * hue-tinted against the document. These surfaces are anchored to the
23
+ * document instead: white in light; in dark the page follows the theme, so
24
+ * the popover token stays correct.
24
25
  */
25
- const COMPOSER_BOX_ANONYMIZED_CLASS = "ring-info/40 border-info/40 focus-within:border-info/60 shadow-[0_0_0_4px_rgb(from_var(--color-info)_r_g_b_/_0.08)] ring-1";
26
+ const DOC_FLOAT_SURFACE_CLASS = "[--doc-float-surface:var(--color-white)] dark:[--doc-float-surface:var(--popover)] bg-(--doc-float-surface)";
26
27
  /**
27
- * The compact (one-line) bar row: its stature, end alignment, control gap
28
- * and inset. The surface supplies the layout (`grid` for the chat bar's
29
- * three fixed columns, `flex` for the docked bar's variable leading
30
- * controls); the row grows with the editor.
28
+ * The most a composer's text region grows to before it scrolls: 16 lines of
29
+ * the web's `leading-5`, 320 points on a phone. Both `ComposerFrame`
30
+ * renderers cap their text region with it; the controls and the attachments
31
+ * sit outside the region, so they stay put while the text scrolls.
31
32
  */
32
- const COMPOSER_COMPACT_ROW_CLASS = "min-h-11 items-end gap-1 px-1.5 py-px";
33
- /**
34
- * The compact text cell: one `text-sm` line at `leading-5` plus the
35
- * vertical inset that makes a single line exactly as tall as the row's
36
- * inner height (44px row, 1px inset each side ⇒ 42px), so text and controls
37
- * share one centre. The editable element itself takes `min-h-0` so an empty
38
- * composer collapses to this one line and grows from there.
39
- */
40
- const COMPOSER_COMPACT_TEXT_CELL_CLASS = "relative min-w-0 py-[11px]";
33
+ const COMPOSER_TEXT_REGION_MAX_HEIGHT_CLASS = "max-h-80";
41
34
  /** Text stature of the editor and every placeholder painted over it. */
42
35
  const COMPOSER_TEXT_CLASS = "text-sm leading-5";
43
36
  /**
44
- * The `large` (hero) text well: the padding around the editor. The editor's
45
- * own stature is `COMPOSER_LARGE_EDITOR_CLASS` (~3 lines of `text-sm` at
46
- * `leading-5`), applied on the editable element by each surface because the
47
- * chat editor targets its `.ProseMirror` node while a plain textarea takes
48
- * it directly.
49
- */
50
- const COMPOSER_LARGE_TEXT_WELL_CLASS = "ps-3 pe-3 pt-2 pb-1";
51
- /** The `large` editable element's stature: three lines before it grows. */
52
- const COMPOSER_LARGE_EDITOR_CLASS = "min-h-15";
53
- /**
54
- * The placeholder painted over an empty editor, in either stature.
55
- * `ComposerPlaceholder` cuts its text through TruncatedText; a row that wears
56
- * this class around other content cuts its own text the same way.
37
+ * One line of a phone composer's text, in points: the line of the native
38
+ * field's `text-base`, which a thumb-sized composer uses where the web's
39
+ * reads `text-sm`. The native `Textarea` sets it and the native
40
+ * `ComposerFrame` measures the text against it.
57
41
  */
58
- const COMPOSER_PLACEHOLDER_CLASS = "text-foreground-placeholder pointer-events-none absolute text-sm";
59
- /** The `large` action row under the text well: leading controls, trailing send. */
60
- const COMPOSER_LARGE_ACTION_ROW_CLASS = "flex items-center justify-end gap-0.5 px-1.5 pb-1.5";
61
- /** The leading group of the action row (the (+) menu, or a scope control). */
62
- const COMPOSER_LEADING_GROUP_CLASS = "flex min-w-0 items-center gap-0.5";
42
+ const COMPOSER_NATIVE_LINE_HEIGHT = 24;
63
43
  /**
64
44
  * The round, foreground-filled primary control at the action row's end:
65
45
  * the chat's send/stop/retry button and the law home's submit. `size-7`
@@ -81,4 +61,4 @@ const COMPOSER_PICKER_TRIGGER_CLASS = "text-muted-foreground hover:text-foregrou
81
61
  const COMPOSER_STATUS_ROW_CENTERED_CLASS = "text-muted-foreground @container mt-1.5 grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 px-1 text-xs";
82
62
  /** The status row without a middle slot: a start cluster and an end slot. */
83
63
  const COMPOSER_STATUS_ROW_CLASS = "text-muted-foreground mt-1.5 flex items-center justify-between gap-2 px-1 text-xs";
84
- export { COMPOSER_BOX_ANONYMIZED_CLASS, COMPOSER_BOX_CLASS, COMPOSER_BOX_FOCUS_CLASS, COMPOSER_COMPACT_ROW_CLASS, COMPOSER_COMPACT_TEXT_CELL_CLASS, COMPOSER_CONTROL_BUTTON_SIZE, COMPOSER_LARGE_ACTION_ROW_CLASS, COMPOSER_LARGE_EDITOR_CLASS, COMPOSER_LARGE_TEXT_WELL_CLASS, COMPOSER_LEADING_GROUP_CLASS, COMPOSER_PICKER_TRIGGER_CLASS, COMPOSER_PLACEHOLDER_CLASS, COMPOSER_SEND_BUTTON_CLASS, COMPOSER_STATUS_ROW_CENTERED_CLASS, COMPOSER_STATUS_ROW_CLASS, COMPOSER_TEXT_CLASS };
64
+ export { COMPOSER_BOX_CLASS, COMPOSER_CONTROL_BUTTON_SIZE, COMPOSER_NATIVE_LINE_HEIGHT, COMPOSER_PICKER_TRIGGER_CLASS, COMPOSER_SEND_BUTTON_CLASS, COMPOSER_STATUS_ROW_CENTERED_CLASS, COMPOSER_STATUS_ROW_CLASS, COMPOSER_TEXT_CLASS, COMPOSER_TEXT_REGION_MAX_HEIGHT_CLASS, DOC_FLOAT_SURFACE_CLASS };
@@ -1,18 +1,5 @@
1
- import { COMPOSER_BOX_ANONYMIZED_CLASS, COMPOSER_BOX_CLASS, COMPOSER_BOX_FOCUS_CLASS, COMPOSER_COMPACT_ROW_CLASS, COMPOSER_COMPACT_TEXT_CELL_CLASS, COMPOSER_CONTROL_BUTTON_SIZE, COMPOSER_LARGE_ACTION_ROW_CLASS, COMPOSER_LARGE_EDITOR_CLASS, COMPOSER_LARGE_TEXT_WELL_CLASS, COMPOSER_LEADING_GROUP_CLASS, COMPOSER_PICKER_TRIGGER_CLASS, COMPOSER_PLACEHOLDER_CLASS, COMPOSER_SEND_BUTTON_CLASS, COMPOSER_STATUS_ROW_CENTERED_CLASS, COMPOSER_STATUS_ROW_CLASS, COMPOSER_TEXT_CLASS } from "./composer-tokens.js";
1
+ import { COMPOSER_CONTROL_BUTTON_SIZE, COMPOSER_PICKER_TRIGGER_CLASS, COMPOSER_SEND_BUTTON_CLASS, COMPOSER_STATUS_ROW_CENTERED_CLASS, COMPOSER_STATUS_ROW_CLASS, COMPOSER_TEXT_CLASS } from "./composer-tokens.js";
2
2
  import { ReactNode } from "react";
3
- /** Where the placeholder sits over the editor, in each stature. */
4
- declare const COMPOSER_PLACEHOLDER_POSITION_CLASS: {
5
- readonly compact: "start-0 end-0 top-1/2 -translate-y-1/2";
6
- readonly large: "start-3 end-3 top-2";
7
- };
8
- /**
9
- * The placeholder painted over an empty editor, cut to one line. It takes no
10
- * pointer and is hidden from assistive tech, so it shows no hint.
11
- */
12
- export declare const ComposerPlaceholder: ({ children, stature }: {
13
- children: ReactNode;
14
- stature: keyof typeof COMPOSER_PLACEHOLDER_POSITION_CLASS;
15
- }) => import("react").JSX.Element;
16
3
  type ComposerStatusRowProps = {
17
4
  /** Left cluster: matter picker, web-search / anonymize toggles, ... */
18
5
  start?: ReactNode | undefined;
@@ -55,4 +42,4 @@ type ComposerPickerProps<Value extends string> = {
55
42
  * kind of control.
56
43
  */
57
44
  export declare const ComposerPicker: <Value extends string>({ ariaLabel, icon, onChange, options, value }: ComposerPickerProps<Value>) => import("react").JSX.Element;
58
- export { COMPOSER_BOX_ANONYMIZED_CLASS, COMPOSER_BOX_CLASS, COMPOSER_BOX_FOCUS_CLASS, COMPOSER_COMPACT_ROW_CLASS, COMPOSER_COMPACT_TEXT_CELL_CLASS, COMPOSER_CONTROL_BUTTON_SIZE, COMPOSER_LARGE_ACTION_ROW_CLASS, COMPOSER_LARGE_EDITOR_CLASS, COMPOSER_LARGE_TEXT_WELL_CLASS, COMPOSER_LEADING_GROUP_CLASS, COMPOSER_PICKER_TRIGGER_CLASS, COMPOSER_PLACEHOLDER_CLASS, COMPOSER_SEND_BUTTON_CLASS, COMPOSER_STATUS_ROW_CENTERED_CLASS, COMPOSER_STATUS_ROW_CLASS, COMPOSER_TEXT_CLASS };
45
+ export { COMPOSER_CONTROL_BUTTON_SIZE, COMPOSER_PICKER_TRIGGER_CLASS, COMPOSER_SEND_BUTTON_CLASS, COMPOSER_STATUS_ROW_CENTERED_CLASS, COMPOSER_STATUS_ROW_CLASS, COMPOSER_TEXT_CLASS };
@@ -1,26 +1,11 @@
1
1
  "use client";
2
2
  import { ChevronDownIcon } from "../icons.js";
3
3
  import { cn } from "../lib/utils.js";
4
- import { COMPOSER_BOX_ANONYMIZED_CLASS, COMPOSER_BOX_CLASS, COMPOSER_BOX_FOCUS_CLASS, COMPOSER_COMPACT_ROW_CLASS, COMPOSER_COMPACT_TEXT_CELL_CLASS, COMPOSER_CONTROL_BUTTON_SIZE, COMPOSER_LARGE_ACTION_ROW_CLASS, COMPOSER_LARGE_EDITOR_CLASS, COMPOSER_LARGE_TEXT_WELL_CLASS, COMPOSER_LEADING_GROUP_CLASS, COMPOSER_PICKER_TRIGGER_CLASS, COMPOSER_PLACEHOLDER_CLASS, COMPOSER_SEND_BUTTON_CLASS, COMPOSER_STATUS_ROW_CENTERED_CLASS, COMPOSER_STATUS_ROW_CLASS, COMPOSER_TEXT_CLASS } from "./composer-tokens.js";
4
+ import { COMPOSER_CONTROL_BUTTON_SIZE, COMPOSER_PICKER_TRIGGER_CLASS, COMPOSER_SEND_BUTTON_CLASS, COMPOSER_STATUS_ROW_CENTERED_CLASS, COMPOSER_STATUS_ROW_CLASS, COMPOSER_TEXT_CLASS } from "./composer-tokens.js";
5
5
  import { DropdownMenu as Menu, DropdownMenuContent as MenuPopup, DropdownMenuRadioGroup as MenuRadioGroup, DropdownMenuRadioItem as MenuRadioItem, DropdownMenuTrigger as MenuTrigger } from "./menu.js";
6
6
  import { TruncatedText } from "./truncated-text.js";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  // src/components/composer.tsx
9
- /** Where the placeholder sits over the editor, in each stature. */
10
- const COMPOSER_PLACEHOLDER_POSITION_CLASS = {
11
- compact: "start-0 end-0 top-1/2 -translate-y-1/2",
12
- large: "start-3 end-3 top-2"
13
- };
14
- /**
15
- * The placeholder painted over an empty editor, cut to one line. It takes no
16
- * pointer and is hidden from assistive tech, so it shows no hint.
17
- */
18
- const ComposerPlaceholder = ({ children, stature }) => /* @__PURE__ */ jsx(TruncatedText, {
19
- "aria-hidden": "true",
20
- className: cn(COMPOSER_PLACEHOLDER_CLASS, COMPOSER_PLACEHOLDER_POSITION_CLASS[stature]),
21
- hint: false,
22
- children
23
- });
24
9
  /**
25
10
  * The rendered status row is the `composer-status` container: the same row
26
11
  * renders under the wide main chat and in a narrow side pane, so a control
@@ -99,4 +84,4 @@ const ComposerPicker = ({ ariaLabel, icon, onChange, options, value }) => {
99
84
  })
100
85
  })] });
101
86
  };
102
- export { COMPOSER_BOX_ANONYMIZED_CLASS, COMPOSER_BOX_CLASS, COMPOSER_BOX_FOCUS_CLASS, COMPOSER_COMPACT_ROW_CLASS, COMPOSER_COMPACT_TEXT_CELL_CLASS, COMPOSER_CONTROL_BUTTON_SIZE, COMPOSER_LARGE_ACTION_ROW_CLASS, COMPOSER_LARGE_EDITOR_CLASS, COMPOSER_LARGE_TEXT_WELL_CLASS, COMPOSER_LEADING_GROUP_CLASS, COMPOSER_PICKER_TRIGGER_CLASS, COMPOSER_PLACEHOLDER_CLASS, COMPOSER_SEND_BUTTON_CLASS, COMPOSER_STATUS_ROW_CENTERED_CLASS, COMPOSER_STATUS_ROW_CLASS, COMPOSER_TEXT_CLASS, ComposerPicker, ComposerPlaceholder, ComposerStatusRow };
87
+ export { COMPOSER_CONTROL_BUTTON_SIZE, COMPOSER_PICKER_TRIGGER_CLASS, COMPOSER_SEND_BUTTON_CLASS, COMPOSER_STATUS_ROW_CENTERED_CLASS, COMPOSER_STATUS_ROW_CLASS, COMPOSER_TEXT_CLASS, ComposerPicker, ComposerStatusRow };
@@ -105,7 +105,7 @@ const CheckboxFace = ({ className }) => /* @__PURE__ */ jsx("span", {
105
105
  /** A switch's face: its track, off (the value waits on data). */
106
106
  const SwitchFace = ({ className, size = "default" }) => /* @__PURE__ */ jsx("span", {
107
107
  "aria-hidden": "true",
108
- className: cn(SWITCH_ROOT_CLASS_NAME, SWITCH_ROOT_SIZE_CLASS_NAME[size], "bg-input", FACE_UNAVAILABLE_CLASS, className),
108
+ className: cn(SWITCH_ROOT_CLASS_NAME, SWITCH_ROOT_SIZE_CLASS_NAME[size], "bg-switch-track", FACE_UNAVAILABLE_CLASS, className),
109
109
  "data-slot": "switch-face"
110
110
  });
111
111
  /**
@@ -2,7 +2,7 @@ import { rendersNothing } from "../lib/renders-nothing.js";
2
2
  import { cn } from "../lib/utils.js";
3
3
  import { DetailsListFace, DetailsListItemFace } from "./details-list-face.js";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
- import { createContext, useContext } from "react";
5
+ import { createContext, useContext, useMemo } from "react";
6
6
  // src/components/details-grid.tsx
7
7
  const DetailsShapeContext = createContext({
8
8
  labelWidth: "md",
@@ -66,11 +66,15 @@ const VALUE_CLASS_NAME = {
66
66
  sheet: "text-foreground-strong-muted min-w-0 wrap-anywhere"
67
67
  };
68
68
  const DetailsGrid = ({ className, density, labelWidth, orientation = "horizontal", variant = "sheet", ...props }) => {
69
- const shape = {
69
+ const shape = useMemo(() => ({
70
70
  labelWidth: labelWidth ?? (variant === "list" ? "auto" : "md"),
71
71
  orientation,
72
72
  variant
73
- };
73
+ }), [
74
+ labelWidth,
75
+ orientation,
76
+ variant
77
+ ]);
74
78
  if (variant === "list") {
75
79
  if (orientation === "horizontal") return /* @__PURE__ */ jsx(DetailsShapeContext.Provider, {
76
80
  value: shape,
@@ -1,12 +1,13 @@
1
1
  "use client";
2
- import { createContext, useContext, useId, useLayoutEffect } from "react";
2
+ import { useLayoutSyncEffect } from "../effects/effects.js";
3
+ import { createContext, useContext, useId } from "react";
3
4
  // src/components/dialog-form-state.tsx
4
5
  const DialogFormContext = createContext(null);
5
6
  /** Forms report semantic changes, including edits made by custom controls. */
6
7
  const DialogFormState = ({ dirty, onDiscard }) => {
7
8
  const registry = useContext(DialogFormContext);
8
9
  const id = useId();
9
- useLayoutEffect(() => {
10
+ useLayoutSyncEffect(() => {
10
11
  if (registry === null) return;
11
12
  if (registry.sources.get(id)?.dirty !== dirty) registry.clearConfirmation();
12
13
  registry.sources.set(id, {
@@ -19,7 +20,7 @@ const DialogFormState = ({ dirty, onDiscard }) => {
19
20
  onDiscard,
20
21
  registry
21
22
  ]);
22
- useLayoutEffect(() => () => {
23
+ useLayoutSyncEffect(() => () => {
23
24
  registry?.sources.delete(id);
24
25
  }, [id, registry]);
25
26
  return null;
@@ -1,5 +1,5 @@
1
1
  import { ContextMenuAction } from "./context-menu.js";
2
- import { ReactNode, Ref } from "react";
2
+ import { KeyboardEvent, MouseEvent, ReactNode, Ref } from "react";
3
3
  import { useRender } from "@base-ui/react/use-render";
4
4
  /** One action of an object: the same shape `ContextMenu` renders. */
5
5
  export type EntityAction = ContextMenuAction;
@@ -22,10 +22,42 @@ export type EntityActionsProps = {
22
22
  */
23
23
  render?: useRender.RenderProp;
24
24
  };
25
+ export type CursorAnchor = {
26
+ getBoundingClientRect: () => DOMRect;
27
+ };
28
+ export type ContextMenuSurfaceOpenEvent = {
29
+ /** Virtual anchor at pointer coordinates (or focused control for keyboard). */
30
+ anchor: CursorAnchor;
31
+ /** The focusable control inside the surface to return focus to on close. */
32
+ returnFocus: HTMLElement | null;
33
+ /** The triggering mouse or keyboard event. */
34
+ event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>;
35
+ };
36
+ export type ContextMenuSurfaceProps = {
37
+ children?: ReactNode;
38
+ /** When true, right-click is still claimed so parents do not open, but the
39
+ * native browser menu stays. */
40
+ disabled?: boolean;
41
+ /** Called when a non-native right-click or context-menu key activates this
42
+ * surface. */
43
+ onOpenContextMenu: (details: ContextMenuSurfaceOpenEvent) => void;
44
+ /** Keep native browser context menu on Shift+click, editable text, links, and
45
+ * selected text. Defaults to true. */
46
+ preserveNativeTargets?: boolean;
47
+ /** Optional host element to attach the listener to directly. */
48
+ render?: useRender.RenderProp | undefined;
49
+ };
25
50
  /**
26
51
  * An object's actions: the right-click menu over `children`, and the list
27
52
  * an `EntityActionsButton` inside them opens.
28
53
  */
54
+ /**
55
+ * Sanctioned right-click and context-menu-key surface for objects whose popup
56
+ * is custom (rich menus, popovers, or inline rename triggers). Shares the same
57
+ * event-claiming, native-menu preservation, keyboard support, and focus-return
58
+ * contract as `EntityActions`.
59
+ */
60
+ export declare const ContextMenuSurface: ({ children, disabled, onOpenContextMenu, preserveNativeTargets, render }: ContextMenuSurfaceProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
29
61
  export declare const EntityActions: ({ actions, children, heading, label, render }: EntityActionsProps) => import("react").JSX.Element;
30
62
  export type EntityActionsButtonProps = {
31
63
  /** Popup alignment against the button. */
@@ -5,7 +5,7 @@ import { Button } from "./button.js";
5
5
  import { ContextMenuActionItems } from "./context-menu.js";
6
6
  import { DropdownMenu as Menu, DropdownMenuContent as MenuPopup, DropdownMenuGroup as MenuGroup, DropdownMenuLabel as MenuGroupLabel, DropdownMenuSeparator as MenuSeparator, DropdownMenuTrigger as MenuTrigger, MenuAnchor } from "./menu.js";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
- import { createContext, use, useRef, useState } from "react";
8
+ import { createContext, use, useMemo, useRef, useState } from "react";
9
9
  import { useRender } from "@base-ui/react/use-render";
10
10
  import { panic } from "better-result";
11
11
  import { createPortal } from "react-dom";
@@ -41,41 +41,38 @@ const EntityActionItems = ({ actions, heading }) => /* @__PURE__ */ jsxs(Fragmen
41
41
  * An object's actions: the right-click menu over `children`, and the list
42
42
  * an `EntityActionsButton` inside them opens.
43
43
  */
44
- const EntityActions = ({ actions, children, heading, label, render }) => {
45
- const [open, setOpen] = useState(false);
46
- const [hasOpened, setHasOpened] = useState(false);
47
- const [anchor, setAnchor] = useState(null);
48
- const returnFocus = useRef(null);
49
- const context = {
50
- actions,
51
- heading,
52
- label
53
- };
54
- const hasActions = actions.length > 0;
55
- const openAt = (event, anchorRect) => {
44
+ /**
45
+ * Sanctioned right-click and context-menu-key surface for objects whose popup
46
+ * is custom (rich menus, popovers, or inline rename triggers). Shares the same
47
+ * event-claiming, native-menu preservation, keyboard support, and focus-return
48
+ * contract as `EntityActions`.
49
+ */
50
+ const ContextMenuSurface = ({ children, disabled = false, onOpenContextMenu, preserveNativeTargets = true, render }) => {
51
+ const activate = (event, anchorRect) => {
56
52
  event.preventDefault();
57
53
  event.stopPropagation();
58
- returnFocus.current = focusReturnTarget(event.currentTarget, event.target);
59
- setHasOpened(true);
60
- setAnchor(anchorRect);
61
- setOpen(true);
54
+ onOpenContextMenu({
55
+ anchor: anchorRect,
56
+ returnFocus: focusReturnTarget(event.currentTarget, event.target),
57
+ event
58
+ });
62
59
  };
63
60
  const handleContextMenu = (event) => {
64
61
  if (event.defaultPrevented || !(event.target instanceof Node) || !event.currentTarget.contains(event.target) || !claimEvent(event.nativeEvent)) return;
65
- if (!hasActions || nativeContextMenuReason(event) !== null) return;
62
+ if (disabled || preserveNativeTargets && nativeContextMenuReason(event) !== null) return;
66
63
  const { clientX: x, clientY: y } = event;
67
- openAt(event, { getBoundingClientRect: () => new DOMRect(x, y, 0, 0) });
64
+ activate(event, { getBoundingClientRect: () => new DOMRect(x, y, 0, 0) });
68
65
  };
69
66
  const handleKeyDown = (event) => {
70
67
  const target = event.target;
71
68
  if (event.defaultPrevented || !isContextMenuKey(event) || !(target instanceof Element) || !event.currentTarget.contains(target) || !claimEvent(event.nativeEvent)) return;
72
- if (!hasActions || nativeContextMenuReason({
69
+ if (disabled || preserveNativeTargets && nativeContextMenuReason({
73
70
  shiftKey: false,
74
71
  target
75
72
  }) !== null) return;
76
- openAt(event, { getBoundingClientRect: () => target.getBoundingClientRect() });
73
+ activate(event, { getBoundingClientRect: () => target.getBoundingClientRect() });
77
74
  };
78
- const target = useRender({
75
+ return useRender({
79
76
  defaultTagName: "div",
80
77
  render,
81
78
  props: {
@@ -90,6 +87,33 @@ const EntityActions = ({ actions, children, heading, label, render }) => {
90
87
  children
91
88
  }
92
89
  });
90
+ };
91
+ const EntityActions = ({ actions, children, heading, label, render }) => {
92
+ const [open, setOpen] = useState(false);
93
+ const [hasOpened, setHasOpened] = useState(false);
94
+ const [anchor, setAnchor] = useState(null);
95
+ const returnFocus = useRef(null);
96
+ const context = useMemo(() => ({
97
+ actions,
98
+ heading,
99
+ label
100
+ }), [
101
+ actions,
102
+ heading,
103
+ label
104
+ ]);
105
+ const hasActions = actions.length > 0;
106
+ const target = /* @__PURE__ */ jsx(ContextMenuSurface, {
107
+ disabled: !hasActions,
108
+ onOpenContextMenu: ({ anchor: nextAnchor, returnFocus: nextFocus }) => {
109
+ returnFocus.current = nextFocus;
110
+ setHasOpened(true);
111
+ setAnchor(nextAnchor);
112
+ setOpen(true);
113
+ },
114
+ render,
115
+ children
116
+ });
93
117
  const contextMenu = hasActions && hasOpened ? /* @__PURE__ */ jsxs(Menu, {
94
118
  onOpenChange: (nextOpen) => {
95
119
  setOpen(nextOpen);
@@ -141,4 +165,4 @@ const EntityActionsButton = ({ align = "end", ref, side = "bottom" }) => {
141
165
  })
142
166
  })] });
143
167
  };
144
- export { EntityActions, EntityActionsButton };
168
+ export { ContextMenuSurface, EntityActions, EntityActionsButton };
@@ -1,6 +1,6 @@
1
1
  "use client";
2
+ import { useLatest } from "../effects/effects.js";
2
3
  import { containedHandler } from "../hooks/use-contained-handler.js";
3
- import { useLatest } from "../hooks/use-latest.js";
4
4
  import { cn } from "../lib/utils.js";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import { useCallback, useEffect, useRef, useState } from "react";
@@ -46,9 +46,9 @@ export declare const LandingSectionHeadingPending: ({ icon }: {
46
46
  export type LandingBox = "composer" | "search";
47
47
  /**
48
48
  * The hero's box before it mounts (the chat composer, the law entry box),
49
- * from the composer tokens both are built on: the bordered box, the
50
- * three-line text well, the action row with its round ends, and the status
51
- * row's line beneath.
49
+ * drawn by the frame both render through: the bordered box, the three-line
50
+ * text, the action row with its round ends, and the status row's line
51
+ * beneath.
52
52
  */
53
53
  export declare const LandingBoxPending: ({ box }: {
54
54
  box: LandingBox;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { cn } from "../lib/utils.js";
3
- import { COMPOSER_BOX_CLASS, COMPOSER_LARGE_ACTION_ROW_CLASS, COMPOSER_LARGE_EDITOR_CLASS, COMPOSER_LARGE_TEXT_WELL_CLASS } from "./composer-tokens.js";
3
+ import { ComposerFrame } from "./composer-frame.js";
4
4
  import { ScrollArea } from "./scroll-area.js";
5
5
  import { Skeleton } from "./skeleton.js";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -35,16 +35,12 @@ const LandingLayout = ({ actions, placeholder = false, hero, children, footer })
35
35
  children: /* @__PURE__ */ jsxs("div", {
36
36
  className: "flex min-h-full w-full flex-col items-center px-4 @2xl:h-full",
37
37
  children: [
38
- /* @__PURE__ */ jsx(LandingScroll, {
39
- className: "min-h-72 w-full max-w-2xl shrink-0 basis-[22rem] @2xl:shrink",
40
- scrollFade: true,
41
- children: /* @__PURE__ */ jsx("div", {
42
- className: "flex min-h-full w-full flex-col items-center justify-center gap-8 px-1",
43
- children: hero
44
- })
38
+ /* @__PURE__ */ jsx("div", {
39
+ className: "flex w-full max-w-2xl shrink-0 basis-[22rem] flex-col items-center justify-center gap-8 px-1 @2xl:shrink",
40
+ children: hero
45
41
  }),
46
42
  /* @__PURE__ */ jsx("div", {
47
- className: "grid w-full shrink-0 gap-8 pb-6 @2xl:min-h-0 @2xl:flex-1 @2xl:auto-rows-fr @2xl:grid-cols-3",
43
+ className: "grid w-full shrink-0 gap-8 pb-6 @2xl:min-h-48 @2xl:flex-1 @2xl:auto-rows-fr @2xl:grid-cols-3",
48
44
  children
49
45
  }),
50
46
  footer !== void 0 && /* @__PURE__ */ jsx(LandingScroll, {
@@ -142,28 +138,25 @@ const BOX_TRAILING_CONTROLS_CLASS = {
142
138
  };
143
139
  /**
144
140
  * The hero's box before it mounts (the chat composer, the law entry box),
145
- * from the composer tokens both are built on: the bordered box, the
146
- * three-line text well, the action row with its round ends, and the status
147
- * row's line beneath.
141
+ * drawn by the frame both render through: the bordered box, the three-line
142
+ * text, the action row with its round ends, and the status row's line
143
+ * beneath.
148
144
  */
149
145
  const LandingBoxPending = ({ box }) => /* @__PURE__ */ jsxs("div", {
150
146
  "aria-hidden": "true",
151
147
  className: "flex w-full flex-col",
152
- children: [/* @__PURE__ */ jsxs("div", {
153
- className: COMPOSER_BOX_CLASS,
154
- children: [/* @__PURE__ */ jsx("div", {
155
- className: COMPOSER_LARGE_TEXT_WELL_CLASS,
156
- children: /* @__PURE__ */ jsx("div", {
157
- className: cn(COMPOSER_LARGE_EDITOR_CLASS, "py-0.5"),
158
- children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" })
159
- })
160
- }), /* @__PURE__ */ jsxs("div", {
161
- className: COMPOSER_LARGE_ACTION_ROW_CLASS,
162
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "me-auto size-7 rounded-full" }), /* @__PURE__ */ jsx("span", {
163
- className: cn("flex items-center", BOX_TRAILING_CONTROLS_CLASS[box]),
164
- children: /* @__PURE__ */ jsx(Skeleton, { className: "size-7 rounded-full" })
165
- })]
166
- })]
148
+ children: [/* @__PURE__ */ jsx(ComposerFrame, {
149
+ leading: /* @__PURE__ */ jsx(Skeleton, { className: "size-7 rounded-full" }),
150
+ ring: "none",
151
+ stature: "large",
152
+ text: /* @__PURE__ */ jsx("div", {
153
+ className: "py-0.5",
154
+ children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" })
155
+ }),
156
+ trailing: /* @__PURE__ */ jsx("span", {
157
+ className: cn("flex items-center", BOX_TRAILING_CONTROLS_CLASS[box]),
158
+ children: /* @__PURE__ */ jsx(Skeleton, { className: "size-7 rounded-full" })
159
+ })
167
160
  }), /* @__PURE__ */ jsxs("div", {
168
161
  className: "mt-1.5 flex h-6 items-center justify-between gap-2 px-1",
169
162
  children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-32" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" })]
@@ -42,8 +42,14 @@ declare const MenuCheckboxItem: ({ className, children, checked, variant, ...pro
42
42
  variant?: "default" | "switch";
43
43
  }) => React.JSX.Element;
44
44
  declare const MenuRadioGroup: (props: Menu$1.RadioGroup.Props) => React.JSX.Element;
45
- declare const MenuRadioItem: ({ className, children, indicator, ...props }: Menu$1.RadioItem.Props & {
45
+ /**
46
+ * A radio choice in a menu. `segment` lays the choices of a group out as one
47
+ * segmented control: the parent places them side by side, the chosen one is
48
+ * raised, and no check mark is drawn.
49
+ */
50
+ declare const MenuRadioItem: ({ className, children, indicator, appearance, ...props }: Menu$1.RadioItem.Props & {
46
51
  indicator?: "check" | "none";
52
+ appearance?: "row" | "segment";
47
53
  }) => React.JSX.Element;
48
54
  declare const MenuGroupLabel: ({ className, inset, ...props }: Menu$1.GroupLabel.Props & {
49
55
  inset?: boolean;
@@ -110,11 +110,16 @@ const MenuRadioGroup = (props) => /* @__PURE__ */ jsx(Menu$1.RadioGroup, {
110
110
  "data-slot": "menu-radio-group",
111
111
  ...props
112
112
  });
113
- const MenuRadioItem = ({ className, children, indicator = "check", ...props }) => /* @__PURE__ */ jsx(Menu$1.RadioItem, {
114
- className: cn("text-foreground data-highlighted:bg-accent data-highlighted:text-accent-foreground min-h-8 cursor-pointer items-center gap-2 rounded-sm py-1 text-base outline-none in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] data-disabled:pointer-events-none data-disabled:opacity-64 sm:min-h-7 sm:text-sm pointer-coarse:min-h-11 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4", indicator === "check" ? "grid grid-cols-[1rem_minmax(0,1fr)] ps-2 pe-4" : "flex px-2", className),
113
+ /**
114
+ * A radio choice in a menu. `segment` lays the choices of a group out as one
115
+ * segmented control: the parent places them side by side, the chosen one is
116
+ * raised, and no check mark is drawn.
117
+ */
118
+ const MenuRadioItem = ({ className, children, indicator = "check", appearance = "row", ...props }) => /* @__PURE__ */ jsx(Menu$1.RadioItem, {
119
+ className: cn(appearance === "segment" ? "text-muted-foreground aria-checked:bg-background aria-checked:text-foreground justify-center aria-checked:shadow-xs" : "text-foreground", "data-highlighted:bg-accent data-highlighted:text-accent-foreground min-h-8 cursor-pointer items-center gap-2 rounded-sm py-1 text-base outline-none in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] data-disabled:pointer-events-none data-disabled:opacity-64 sm:min-h-7 sm:text-sm pointer-coarse:min-h-11 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4", indicator === "check" && appearance === "row" ? "grid grid-cols-[1rem_minmax(0,1fr)] ps-2 pe-4" : "flex px-2", className),
115
120
  "data-slot": "menu-radio-item",
116
121
  ...props,
117
- children: indicator === "check" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Menu$1.RadioItemIndicator, {
122
+ children: indicator === "check" && appearance === "row" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Menu$1.RadioItemIndicator, {
118
123
  className: "col-start-1",
119
124
  children: /* @__PURE__ */ jsxs("svg", {
120
125
  fill: "none",
@@ -1,4 +1,4 @@
1
- import { useLatest } from "../hooks/use-latest.js";
1
+ import { useLatest } from "../effects/effects.js";
2
2
  import { OutcomeScreenView } from "./outcome-screen-view.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { useEffect, useRef } from "react";
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { useLatest, useLayoutSyncEffect } from "../effects/effects.js";
2
3
  import { ChevronRightIcon } from "../icons.js";
3
4
  import "../lib/panel-inset.js";
4
5
  import { cn } from "../lib/utils.js";
@@ -9,7 +10,7 @@ import { ScrollArea } from "./scroll-area.js";
9
10
  import { Tooltip, TooltipContent as TooltipPopup, TooltipTrigger } from "./tooltip.js";
10
11
  import { TruncatedText } from "./truncated-text.js";
11
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
- import { memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
13
+ import { memo, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
13
14
  import { Temporal } from "temporal-polyfill/full";
14
15
  // src/components/outline-rail.tsx
15
16
  /**
@@ -245,8 +246,8 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
245
246
  const panelRef = useRef(null);
246
247
  const railRef = useRef(null);
247
248
  const focusedTickRef = useRef(null);
248
- const resolvePctRef = useRef(resolvePct);
249
- const onJumpRef = useRef(onJump);
249
+ const resolvePctRef = useLatest(resolvePct);
250
+ const onJumpRef = useLatest(onJump);
250
251
  const tree = useMemo(() => buildTree(items), [items]);
251
252
  const [seededItems, setSeededItems] = useState([]);
252
253
  if (seededItems !== items) {
@@ -299,12 +300,7 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
299
300
  scrollContainerRef,
300
301
  resolvePct
301
302
  ]);
302
- const recalcRef = useRef(recalc);
303
- useLayoutEffect(() => {
304
- resolvePctRef.current = resolvePct;
305
- onJumpRef.current = onJump;
306
- recalcRef.current = recalc;
307
- });
303
+ const recalcRef = useLatest(recalc);
308
304
  useEffect(() => {
309
305
  recalc();
310
306
  }, [recalc]);
@@ -314,7 +310,7 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
314
310
  const observer = new ResizeObserver(() => recalcRef.current());
315
311
  observer.observe(container);
316
312
  return () => observer.disconnect();
317
- }, [scrollContainerRef]);
313
+ }, [recalcRef, scrollContainerRef]);
318
314
  useEffect(() => {
319
315
  if (activeId !== void 0) return;
320
316
  const container = scrollContainerRef.current;
@@ -343,6 +339,7 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
343
339
  }, [
344
340
  activeId,
345
341
  items,
342
+ resolvePctRef,
346
343
  scrollContainerRef
347
344
  ]);
348
345
  const active = activeId === void 0 ? derivedActive : activeId;
@@ -369,7 +366,11 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
369
366
  manualLockUntil.current = Temporal.Now.instant().epochMilliseconds + 900;
370
367
  }
371
368
  onJumpRef.current(id, container);
372
- }, [activeControlled, scrollContainerRef]);
369
+ }, [
370
+ activeControlled,
371
+ onJumpRef,
372
+ scrollContainerRef
373
+ ]);
373
374
  const toggleCollapse = useCallback((id, rowEl) => {
374
375
  const rowTop = rowEl?.getBoundingClientRect().top;
375
376
  setToggled((prev) => new Set(prev).add(id));
@@ -386,7 +387,7 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
386
387
  });
387
388
  }, []);
388
389
  const activeIndex = items.findIndex((item) => item.id === activeId);
389
- useLayoutEffect(() => {
390
+ useLayoutSyncEffect(() => {
390
391
  if (activeIndex === -1 || !panelOpen) return;
391
392
  const panel = panelRef.current;
392
393
  const row = panel?.querySelector(`[${ACTIVE_ROW_ATTRIBUTE}]`);
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { useLatest } from "../hooks/use-latest.js";
2
+ import { useLatest } from "../effects/effects.js";
3
3
  import { ChevronDownIcon, ChevronUpIcon, ChevronsUpDownIcon } from "../icons.js";
4
4
  import { CONTROL_SIZE } from "../lib/control-size.js";
5
5
  import { FIELD_TRIGGER_CLASS_NAME } from "../lib/field-trigger.js";
@@ -54,6 +54,12 @@ type SettingsRowProps = SettingsRowInteraction & {
54
54
  depth?: SettingsRowDepth | undefined;
55
55
  /** Shown dimmed: its control is disabled until something else allows it. */
56
56
  disabled?: boolean | undefined;
57
+ /**
58
+ * The name a settings link uses to bring this row into view: set as
59
+ * `data-settings-target`, the row can take focus from script, and it is
60
+ * marked while `data-highlighted` is set on it.
61
+ */
62
+ target?: string | undefined;
57
63
  };
58
64
  /** One option: media, title and secondary line, then its control. */
59
65
  declare const SettingsRow: (props: SettingsRowProps) => React.JSX.Element;