@kerfjs/ui 5.0.0-beta.127 → 5.0.0-beta.129

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.
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ export { applySelection, isApplePlatform, selectionGesture } from './chunk-GXSX6
42
42
  export { Grid } from './chunk-FR5G77K5.js';
43
43
 
44
44
  export { ListActionRow } from './chunk-RHMY45DK.js';
45
- export { DialogSurface, PinnablePopoverSurface, PopoverDialogSurface, PopupSurface, isPopoverPinned, pinPopover, wirePinnablePopover } from './chunk-HD7ZLISK.js';
45
+ export { DialogSurface, PinnablePopoverSurface, PopoverDialogSurface, PopupSurface, isPopoverPinned, pinPopover, wirePinnablePopover } from './chunk-IMXLOMTF.js';
46
46
  export { closeDialog, openDialog } from './chunk-UQ4FRQ6M.js';
47
47
 
48
48
  export { EmptyState } from './chunk-FNJA4S6J.js';
@@ -1,5 +1,5 @@
1
1
  import { SplitView } from './chunk-E2MTHHLS.js';
2
- import { DialogSurface } from './chunk-HD7ZLISK.js';
2
+ import { DialogSurface } from './chunk-IMXLOMTF.js';
3
3
  export { closeDialog, openDialog } from './chunk-UQ4FRQ6M.js';
4
4
 
5
5
 
@@ -142,7 +142,7 @@ interface PinnablePopoverSurfaceProps {
142
142
  * `fill-last` stacks fixed rows above one filling last child.
143
143
  */
144
144
  bodyLayout?: DialogSurfaceBodyLayout;
145
- /** Add a bottom-edge handle that pins and resizes an overlay by drag or arrow key. */
145
+ /** Add a bottom-edge handle that resizes by drag or arrow key without changing pin state. */
146
146
  resizeFromBottom?: boolean;
147
147
  /** The Pin toggle's accessible name (default `Pin`). */
148
148
  pinLabel?: string;
@@ -197,7 +197,7 @@ type PinnablePopoverChangeReason = 'pin' | 'unpin' | 'move' | 'resize';
197
197
  /** What `wirePinnablePopover`'s `onChange` reports. */
198
198
  interface PinnablePopoverChange {
199
199
  readonly pinned: boolean;
200
- /** The pinned placement; `null` while transient. */
200
+ /** Placement and saved size; transient surfaces use only the size. */
201
201
  readonly placement: PinnablePopoverPlacement | null;
202
202
  readonly reason: PinnablePopoverChangeReason;
203
203
  }
@@ -210,7 +210,7 @@ interface PinnablePopoverOptions {
210
210
  anchor?: Element | (() => Element | null);
211
211
  /** Start pinned, as the application last stored it. */
212
212
  pinned?: boolean;
213
- /** The pinned placement to restore, as `onChange` last reported it. */
213
+ /** Placement and size to restore; transient surfaces ignore x and y. */
214
214
  placement?: PinnablePopoverPlacement;
215
215
  /** An arrow key's move, in px (default 8). */
216
216
  step?: number;
@@ -236,8 +236,8 @@ declare function pinPopover(surface: HTMLElement, pinned?: boolean): void;
236
236
  * Give an overlay PinnablePopoverSurface its behavior: placement below its
237
237
  * anchor while transient, a press outside or Escape closing it; the Pin
238
238
  * toggle; a drag by the header and the arrow keys on the focused title
239
- * (Shift for `largeStep`) moving it, which pins it; a pinned surface's
240
- * resize; and a clamp inside the viewport gutter, kept after a window
239
+ * (Shift for `largeStep`) moving it, which pins it; resizing without changing
240
+ * pin state; and a clamp inside the viewport gutter, kept after a window
241
241
  * resize. Pinned, it closes only by Escape (with focus inside it), its Close
242
242
  * button, or `hidePopover()`. The state survives application re-renders and
243
243
  * closing; `onChange` reports it for the application to store. An
@@ -1,4 +1,4 @@
1
- export { DialogSurface, PinnablePopoverSurface, PopoverDialogSurface, PopupSurface, isPopoverPinned, pinPopover, wirePinnablePopover } from './chunk-HD7ZLISK.js';
1
+ export { DialogSurface, PinnablePopoverSurface, PopoverDialogSurface, PopupSurface, isPopoverPinned, pinPopover, wirePinnablePopover } from './chunk-IMXLOMTF.js';
2
2
  export { closeDialog, openDialog, syncDialogStack, wireDialogStack } from './chunk-UQ4FRQ6M.js';
3
3
 
4
4
 
@@ -1,4 +1,4 @@
1
- import { DialogSurface } from './chunk-HD7ZLISK.js';
1
+ import { DialogSurface } from './chunk-IMXLOMTF.js';
2
2
  export { closeDialog, openDialog } from './chunk-UQ4FRQ6M.js';
3
3
 
4
4
 
@@ -575,7 +575,10 @@ hand-built draggable panel. It takes the same geometry props as
575
575
  Moving a transient surface pins it. It stays inside the viewport gutter,
576
576
  and after a window resize it is clamped again; when the window has room it
577
577
  returns to where the person put it.
578
- - **Resized** from its corner while pinned, within the viewport caps.
578
+ - **Resized** from its corner while pinned, or from the optional
579
+ `resizeFromBottom` handle by pointer or arrow keys in either state, within
580
+ the viewport caps. Bottom-edge resizing keeps the current pin state; the
581
+ chosen size survives closing, reopening, and unpinning.
579
582
 
580
583
  The surface is `popover="manual"`, so the controller provides its light
581
584
  dismiss; changing an `auto` popover into a pinned one is not possible while
@@ -586,8 +589,8 @@ popover; give its first control `autofocus` to move focus in on open.
586
589
 
587
590
  The application owns storage. `onChange` reports `{ pinned, placement, reason }`
588
591
  whenever the person or `pinPopover` pins, unpins, moves, or resizes it
589
- (`placement` is `{ x, y, width?, height? }` in viewport px, `null` while
590
- transient); a clamp after a window resize is not reported. Pass the stored
592
+ (`placement` is `{ x, y, width?, height? }` in viewport px, or `null` before
593
+ a placement or size is saved; transient surfaces restore only its size); a clamp after a window resize is not reported. Pass the stored
591
594
  values back as `pinned` and `placement` to restore it. `isPopoverPinned()`
592
595
  reads the current state.
593
596
 
package/llms.txt CHANGED
@@ -8,6 +8,8 @@
8
8
  Read the [consumer house grammar](./docs/interaction-conventions.md) before
9
9
  composing an application screen. It states the default interaction and layout
10
10
  decisions; a project records compelling deviations in its own conventions doc.
11
+ For pre-implementation screen concepts and rendered design review, use the
12
+ [design-mock skill](./ai/design-mock/SKILL.md) from this installed package.
11
13
 
12
14
  ```bash
13
15
  npm install kerfjs @kerfjs/ui # kerfjs is a peer; Web Awesome is an optional peer
@@ -1214,7 +1216,7 @@ Key conditional `StateBanner` siblings with `rootAttributes={{ "data-key": "…"
1214
1216
 
1215
1217
  Key sibling `DialogSurface`s that render conditionally with `rootAttributes={{ "data-key": "…" }}` so a re-render morphs each dialog into itself; never wrap one in a keyed app `div`. Modal `DialogSurface` bounds use typed `viewportGutter` and `maxHeight` (`CssLength` or `"viewport"`); explicit caps stay within the dynamic viewport minus both gutters. Omitted props keep the default caps (20px clear of each edge, 80% of the viewport height at 420px wide or narrower). Application render state chooses responsive values, and preview layout remains application-owned. `height` sets a definite bounded modal size and `bodyLayout="fill"` lets one child fill the body; `bodyLayout="fill-last"` keeps leading rows at their height above one filling last child, and `footerPresentation="floating"` (with a typed `footerOffset`) floats a chat composer over the body while the body reserves its measured height; give the transcript `scrollClearance="block-end"` (a `scrollable` `List` or a `Pane`) to let it scroll beneath the composer, with the last message still resting above it, through the published `--kui-scroll-clearance-block-end` context (overlaying chrome publishes `--kui-scroll-clearance-block-start` / `-end`; one scroller per covered edge opts in; a composed Pane opts in through `PaneConfig.scrollClearance` on a Workbench `mainPane` or panel `pane`, a `CollapsiblePanel` `pane`, or a `NavStack` view's `pane`). `headerPresentation="floating"` lays the title bar over the body on the translucent `--kui-chrome-material-raised` (opaque under reduced transparency, increased contrast, and forced colors); the register measures it and the body reserves it, and a `fill` body's only child with `scrollClearance="both"` scrolls beneath both the title bar and a floating composer through the published `--kui-scroll-clearance-block-start`. `presentation="bottom-sheet"` attaches the dialog to the bottom edge with square bottom corners, safe-area and virtual-keyboard clearance behind the panel, and a slide in/out (`enterMotion` / `exitMotion`); `resizable` adds a top grabber separator bounded by `minHeight` and `maxHeight`. `PopoverDialogSurface` is the non-modal, light-dismiss counterpart on the native Popover API, with the same size props and an `embedded` in-flow presentation; `describedBy` sets its `aria-describedby` (usually a title `ToolbarText`'s `descriptionId`).
1216
1218
  Render a non-modal dialog as `PopoverDialogSurface`; `dismiss="manual"` keeps a request open until it is answered, and `anchorName` docks it to an app region named with the same CSS `anchor-name`.
1217
- Render a panel the person can pin and move (a library, a palette) as `PinnablePopoverSurface` and call `wirePinnablePopover(surface, { pinned, placement, onChange })`: transient below its `popoverTarget` control with light dismiss; pinned (its Pin toggle or `pinPopover`, read with `isPopoverPinned`) it stays open, drags by its title, moves with the arrow keys, resizes, and stays in the viewport gutter; the app stores what `onChange` reports.
1219
+ Render a panel the person can pin and move (a library, a palette) as `PinnablePopoverSurface` and call `wirePinnablePopover(surface, { pinned, placement, onChange })`: transient below its `popoverTarget` control with light dismiss; pinned (its Pin toggle or `pinPopover`, read with `isPopoverPinned`) it stays open, drags by its title, moves with the arrow keys, resizes, and stays in the viewport gutter; the app stores what `onChange` reports. `resizeFromBottom` enables pointer/keyboard resizing in either state without pinning; saved dimensions survive reopening and unpinning.
1218
1220
 
1219
1221
  Render a modal dialog as `DialogSurface` itself, a native `<dialog>` (`alert` renders `role="alertdialog"` for a destructive confirmation; pair it with `describedBy` on the message): `label` (or `labelledBy` with a `heading`, such as an xl `ToolbarText` with a description) names it, `describedBy` (the heading ToolbarText's `descriptionId`, or app-owned summary copy) describes it as `aria-describedby`, `children` is its body, `footer` holds its buttons, and `headerActions` sit before its close button (`withoutHeader` drops the header for content that owns its heading and close control). Open it with `openDialog(dialog)` and close it with `closeDialog(dialog)` from `@kerfjs/ui/surface-scaffold`; never toggle its `open` attribute. The close button, any `data-dialog-close` element inside (a Cancel button), Escape, and, with `lightDismiss`, a backdrop press dispatch a cancelable `kui-request-close` (`detail.source`: `close-button`, `escape`, or `backdrop`); cancel it to keep the dialog open (the panel pulses). The native `close` event fires once it closes. `openDialog` installs the listeners and, while the dialog is open, measures its floating header/footer, follows a bottom sheet's keyboard and grabber, and keeps that state across re-renders; import `@kerfjs/ui/surface-scaffold/register` only when a dialog may open some other way. Do not write `wa-dialog` inside a `DialogSurface`.
1220
1222
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kerfjs/ui",
3
- "version": "5.0.0-beta.127",
3
+ "version": "5.0.0-beta.129",
4
4
  "description": "Accessible, composable UI primitives for kerf applications.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -808,7 +808,7 @@
808
808
  "ai:regressions:record-v3": "node scripts/record-ai-regression-run-v3.mjs",
809
809
  "ai:regressions:replay-v3": "node scripts/replay-ai-regression-run-v3.mjs",
810
810
  "ai:regressions:score": "node scripts/score-ai-regression.mjs",
811
- "check:guidance": "node scripts/check-decision-guidance.mjs",
811
+ "check:guidance": "node scripts/check-decision-guidance.mjs && node scripts/check-design-mock-skill.mjs",
812
812
  "lint:eslint": "eslint src tests ux-demo docs/examples scripts ai analyzer doctor evaluator view props catalog-projection.mjs catalog-projection-cli.mjs vite-editor.mjs vite-ux-review.mjs traversal-exclusions.mjs eslint.config.mjs --max-warnings 0",
813
813
  "lint": "npm run lint:eslint && npm run check:format",
814
814
  "typecheck": "node node_modules/typescript7/bin/tsc --noEmit",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/surfaces/surface-scaffold/internal/dialog-surface.tsx","../src/components/surfaces/surface-scaffold/internal/pinnable-popover-surface.tsx","../src/components/surfaces/surface-scaffold/internal/popover-dialog-surface.tsx","../src/components/surfaces/surface-scaffold/internal/popup-surface.tsx","../src/components/surfaces/surface-scaffold/wiring/wire-pinnable-popover.ts"],"names":["jsxs","jsx","X","box","distance","min"],"mappings":";;;;;;;AA2EA,IAAM,wBAAA,uBAA+B,GAAA,CAAI;AAAA,EACvC,gBAAA;AAAA,EACA,WAAA;AAAA,EACA,mBAAA;AAAA,EACA,sBAAA;AAAA,EACA,iBAAA;AAAA,EACA,mBAAA;AAAA,EACA,sBAAA;AAAA,EACA,iBAAA;AAAA,EACA,aAAA;AAAA,EACA,kBAAA;AAAA,EACA,0BAAA;AAAA,EACA,0BAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,kBAAA;AAAA,EACA,oBAAA;AAAA,EACA,iBAAA;AAAA,EACA,mBAAA;AAAA,EACA,qBAAA;AAAA,EACA;AACF,CAAC,CAAA;AAiKM,SAAS,aAAA,CAAc;AAAA,EAC5B,EAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,KAAA,GAAQ,KAAA;AAAA,EACR,OAAA;AAAA,EACA,aAAA;AAA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AAI,mBAAA,CAAoB,aAAA,EAAe,qBAAA,EAAuB,IAAI,CAAA;AAClE,IAAA,GAAA,CAAI,mBAAA,CAAoB,WAAW,iBAAiB,CAAA;AACpD,IAAA,IAAA,CAAK,mBAAA,CAAoB,UAAU,QAAQ,CAAA;AAC3C,IAAA,GAAA,CAAI,oBAAoB,QAAA,EAAU,QAAA,EAAU,EAAE,OAAA,EAAS,MAAM,CAAA;AAC7D,IAAA,KAAA,MAAW,YAAY,KAAA,CAAM,IAAA,IAAQ,OAAA,CAAQ,KAAA,CAAM,eAAe,QAAQ,CAAA;AAC1E,IAAA,KAAA,CAAM,KAAA,EAAM;AACZ,IAAA,OAAA,CAAQ,gBAAgB,aAAa,CAAA;AACrC,IAAA,OAAA,CAAQ,gBAAgB,eAAe,CAAA;AACvC,IAAA,IAAI,YAAY,GAAA,CAAI,OAAO,MAAM,UAAA,EAAY,WAAA,CAAY,OAAO,OAAO,CAAA;AAAA,EACzE,CAAA;AACF","file":"chunk-HD7ZLISK.js","sourcesContent":["// KF-0MY6JQ: DialogSurface, one of the four surfaces the\n// `@kerfjs/ui/surface-scaffold` facade re-exports.\nimport { X } from 'lucide';\n\nimport type { KerfUiContent } from '../../../../shared/content/semantic-content.js';\nimport { filterDataAttributes } from '../../../../shared/dom/extension-attributes.js';\nimport type { CssLength } from '../../../../shared/styles/css-values.js';\nimport { LucideIcon } from '../../../media/lucide-icon/lucide-icon.js';\n\nexport type DialogSurfaceSize = 'small' | 'medium' | 'large';\n/**\n * How the dialog is presented: `modal` (default) centered on the screen,\n * `side-sheet` against the inline end, `fullscreen`, or `bottom-sheet`\n * attached to the bottom edge (square bottom corners, safe-area and\n * virtual-keyboard clearance, optionally user-resizable).\n */\nexport type DialogSurfacePresentation =\n | 'modal'\n | 'side-sheet'\n | 'fullscreen'\n | 'bottom-sheet'\n /**\n * In flow, always shown: the same panel without the top layer or a\n * backdrop, never wider than its container. For a catalog, a design\n * canvas, or a document; `openDialog` / `closeDialog` leave it alone and\n * `data-dialog-close` does not hide it.\n */\n | 'embedded';\n/**\n * How a bottom sheet appears or leaves: `slide` (default) moves the panel in\n * from, or out to, the bottom edge; `standard` keeps the dialog's\n * scale-and-fade. Both honor `prefers-reduced-motion`.\n */\nexport type DialogSurfaceSheetMotion = 'slide' | 'standard';\nexport type SurfaceInset =\n | 'none'\n | 'default'\n | 'comfortable'\n | /** @deprecated Use default; this legacy compact value retains its 8px inset. */ 'compact';\nexport type DialogSurfaceMaxHeight = CssLength | 'viewport';\n/** A definite modal height: a length or the full viewport, minus both gutters. */\nexport type DialogSurfaceHeight = CssLength | 'viewport';\n/**\n * How the dialog body lays out its children: `flow` (default) scrolls ordinary\n * content in the body; `fill` gives one child the body's whole height and\n * lets it own scrolling (a SplitView, a Pane, an editor); `fill-last` stacks\n * the leading children at their natural height and gives the last child the\n * remaining height to own its scrolling (a heading and notices above a\n * scrolling transcript).\n */\nexport type DialogSurfaceBodyLayout = 'flow' | 'fill' | 'fill-last';\n/**\n * Where the dialog footer sits: `docked` (default) below the body, or\n * `floating` over the body's block end, inset from the panel's inline and\n * block-end edges on a transparent background (a chat composer).\n */\nexport type DialogSurfaceFooterPresentation = 'docked' | 'floating';\n/**\n * Where the dialog header sits: `docked` (default) above the body, or\n * `floating` over the body's block-start edge on the translucent chrome\n * material, so content scrolls visibly beneath the title bar.\n */\nexport type DialogSurfaceHeaderPresentation = 'docked' | 'floating';\n\n/** The built-in close control's visual weight; `normal` keeps the default. */\nexport type DialogSurfaceCloseEmphasis = 'normal' | 'quiet';\n\n/**\n * Application `data-*` identity on the DialogSurface root, such as\n * `data-key`; the surface's own configuration attributes stay protected.\n */\nexport type DialogSurfaceRootAttributes = Readonly<\n Record<`data-${string}`, string | undefined>\n>;\n\nconst DIALOG_SURFACE_PROTECTED = new Set([\n 'data-component',\n 'data-size',\n 'data-presentation',\n 'data-preferred-width',\n 'data-body-inset',\n 'data-footer-inset',\n 'data-viewport-gutter',\n 'data-max-height',\n 'data-height',\n 'data-body-layout',\n 'data-footer-presentation',\n 'data-header-presentation',\n 'data-min-height',\n 'data-resizable',\n 'data-enter-motion',\n 'data-exit-motion',\n 'data-light-dismiss',\n 'data-stack-open',\n 'data-stack-active',\n 'data-stack-position',\n 'data-stack-count',\n]);\n\n/**\n * The dialog's accessible name: its `label` text (also the default title), or\n * the id of an element that names it, such as a `heading` ToolbarText.\n */\nexport type DialogSurfaceName =\n { label: string; labelledBy?: never } | { label?: never; labelledBy: string };\n\nexport type DialogSurfaceProps = DialogSurfaceName & DialogSurfaceOptions;\n\n/** Controlled state of one native modal layer inside a `wireDialogStack` root. */\nexport interface DialogSurfaceStack {\n /** Whether this layer belongs in the native top layer. */\n open: boolean;\n /** The one frontmost open layer; it owns modal focus and accessibility. */\n active: boolean;\n /** One-based order from the back to the front. */\n position: number;\n /** Number of layers in the stack, including closed layers still rendered. */\n count: number;\n /** Optional vertical offset for an inactive layer; omitted on phones. */\n offset?: CssLength;\n}\n\nexport interface DialogSurfaceOptions {\n /** The dialog's id, for `openDialog(document.getElementById(id))`. */\n id?: string;\n /**\n * Id of the element whose text is the dialog's accessible description,\n * such as the `heading` ToolbarText's `descriptionId` or app-owned summary\n * copy in the body; rendered as `aria-describedby` on the `<dialog>`.\n */\n describedBy?: string;\n /**\n * An alert dialog: a confirmation that interrupts the person to report\n * something urgent or ask before a destructive action (\"Delete this\n * topic?\"). Renders `role=\"alertdialog\"` on the `<dialog>`; set\n * `describedBy` to the element holding the message, and leave\n * `lightDismiss` off so the person answers it.\n */\n alert?: boolean;\n /** The body content. */\n children: KerfUiContent;\n /** Controlled modal stack state; call `wireDialogStack` on the containing root. */\n stack?: DialogSurfaceStack;\n /**\n * Header title content in place of the `label` text, such as an xl\n * `ToolbarText` with a description. The dialog keeps its `label` (or\n * `labelledBy`) name.\n */\n heading?: KerfUiContent;\n /** Controls before the close button in the header. */\n headerActions?: KerfUiContent;\n /** The footer, below the body (or floating over it); usually its buttons. */\n footer?: KerfUiContent;\n /**\n * Render no header: no title and no close button. The content then owns its\n * heading and a way to close (an element with `data-dialog-close`).\n */\n withoutHeader?: boolean;\n /** Close on a press on the backdrop; otherwise the panel pulses. */\n lightDismiss?: boolean;\n /** The close button's accessible name (default `Close`). */\n closeLabel?: string;\n /** Soften the built-in close control without changing its 40px target. */\n closeEmphasis?: DialogSurfaceCloseEmphasis;\n size?: DialogSurfaceSize;\n presentation?: DialogSurfacePresentation;\n /** Modal preferred width. Takes precedence over size, within the viewport cap. */\n preferredWidth?: CssLength;\n bodyInset?: SurfaceInset;\n footerInset?: SurfaceInset;\n /** Modal edge clearance. Omit to retain Web Awesome's default viewport cap. */\n viewportGutter?: CssLength;\n /**\n * Modal height cap, bounded by the dynamic viewport minus both gutters. On a\n * bottom sheet, the cap (and the resize ceiling), bounded by the dynamic\n * viewport minus the top safe area and one gutter.\n */\n maxHeight?: DialogSurfaceMaxHeight;\n /**\n * Modal definite height, bounded the same way, so a filling child has a\n * height to fill. Takes precedence over `maxHeight`. On a bottom sheet, the\n * height it opens at (the visible height above the safe area or keyboard).\n */\n height?: DialogSurfaceHeight;\n /**\n * A resizable bottom sheet's resize floor (default 160px), the visible\n * height above the safe area or keyboard.\n */\n minHeight?: CssLength;\n /**\n * Let the person resize a bottom sheet by its top grabber (drag, or the\n * arrow, Page Up/Down, Home and End keys) between `minHeight` and the\n * sheet's cap. Needs the `/register` entry; each opening starts at `height`\n * (or the content height). Ignored by other presentations.\n */\n resizable?: boolean;\n /** How a bottom sheet appears (default `slide` up from the bottom edge). */\n enterMotion?: DialogSurfaceSheetMotion;\n /** How a bottom sheet is dismissed (default `slide` down off the bottom edge). */\n exitMotion?: DialogSurfaceSheetMotion;\n /**\n * Body layout (default `flow`); `fill` lets one child own the body and\n * `fill-last` stacks fixed rows above one filling last child.\n */\n bodyLayout?: DialogSurfaceBodyLayout;\n /**\n * Header placement (default `docked`); `floating` lays the dialog's header\n * (its title and close control) over the body's block-start edge on the\n * translucent chrome material (`--kui-chrome-material-raised`, opaque under\n * `prefers-reduced-transparency`, increased contrast, forced colors, or\n * without `backdrop-filter`). The `/register` entry measures the header;\n * the body reserves that height before its own inset, so its first content\n * rests below the title bar. A `fill`/`fill-last` child that is the body's\n * only child and opts into block-start `scrollClearance` (a `List` or\n * `Pane`) takes the clearance inside its own scroll area instead, published\n * as `--kui-scroll-clearance-block-start`, so its content scrolls visibly\n * beneath the header. Unmeasured (without the register), the header stays\n * docked. Keep header text in the normal text color: quiet text can fall\n * below AA over the content passing beneath it.\n */\n headerPresentation?: DialogSurfaceHeaderPresentation;\n /**\n * Footer placement (default `docked`); `floating` lays the footer over the\n * body's block end. The body reserves the footer's measured height so its\n * last content is never hidden beneath it. A `fill`/`fill-last` child that\n * opts into block-end `scrollClearance` (a `List` or `Pane`) takes that\n * clearance inside its own scroll area instead, published as\n * `--kui-scroll-clearance-block-end`, so its content scrolls visibly beneath\n * the transparent footer.\n */\n footerPresentation?: DialogSurfaceFooterPresentation;\n /**\n * A floating footer's clearance from the panel's inline and block-end edges\n * (default the 16px container inset). Choose a phone value such as\n * `remify(8)` from `deviceClass()`; the scaffold adds no breakpoint.\n */\n footerOffset?: CssLength;\n /**\n * Safe `data-*` identity on the root. Give sibling dialogs distinct\n * `data-key`s so a re-render morphs each surface into itself instead of\n * reusing one dialog's element for another (structurally identical roots\n * are otherwise matched by position).\n */\n rootAttributes?: DialogSurfaceRootAttributes;\n className?: string;\n /** Native named-slot assignment when composed inside a web component. */\n slot?: string;\n}\n\n/**\n * A modal dialog: a native `<dialog>` with Kerf's header, body, and footer\n * chrome, sized and presented by its props. Render it closed, then open it\n * with `openDialog()` and close it with `closeDialog()`, the close button, an\n * element with `data-dialog-close`, Escape, or (with `lightDismiss`) a press\n * on the backdrop. Import `@kerfjs/ui/surface-scaffold/register` for the\n * floating header and footer measurement, the bottom sheet's keyboard\n * clearance and grabber, and re-render resilience while open.\n */\nexport function DialogSurface({\n id,\n label,\n labelledBy,\n describedBy,\n alert = false,\n heading,\n headerActions,\n footer,\n withoutHeader = false,\n lightDismiss = false,\n closeLabel = 'Close',\n closeEmphasis = 'normal',\n children,\n stack,\n size = 'medium',\n presentation = 'modal',\n preferredWidth,\n bodyInset = 'default',\n footerInset = 'comfortable',\n viewportGutter,\n maxHeight,\n height,\n minHeight,\n resizable = false,\n enterMotion = 'slide',\n exitMotion = 'slide',\n bodyLayout = 'flow',\n headerPresentation = 'docked',\n footerPresentation = 'docked',\n footerOffset,\n rootAttributes = {},\n className = '',\n slot,\n}: DialogSurfaceProps) {\n if (\n stack &&\n (!Number.isInteger(stack.position) ||\n !Number.isInteger(stack.count) ||\n stack.count < 1 ||\n stack.position < 1 ||\n stack.position > stack.count ||\n (stack.active && !stack.open))\n )\n throw new RangeError(\n 'DialogSurface stack needs a valid frontmost active layer',\n );\n const style = [\n preferredWidth === undefined\n ? ''\n : `--_kui-dialog-surface-preferred-width:${preferredWidth}`,\n viewportGutter === undefined\n ? ''\n : `--_kui-dialog-surface-gutter:${viewportGutter}`,\n maxHeight === undefined || maxHeight === 'viewport'\n ? ''\n : `--_kui-dialog-surface-max-height:${maxHeight}`,\n height === undefined || height === 'viewport'\n ? ''\n : `--_kui-dialog-surface-height:${height}`,\n footerOffset === undefined\n ? ''\n : `--_kui-dialog-surface-footer-offset:${footerOffset}`,\n minHeight === undefined\n ? ''\n : `--_kui-dialog-surface-min-height:${minHeight}`,\n stack?.offset === undefined\n ? ''\n : `--_kui-dialog-surface-stack-offset:${stack.offset}`,\n ]\n .filter(Boolean)\n .join(';');\n return (\n <dialog\n {...filterDataAttributes(rootAttributes, DIALOG_SURFACE_PROTECTED)}\n id={id}\n class={`kui-dialog-surface ${className}`.trim()}\n open={presentation === 'embedded' ? true : undefined}\n role={alert ? 'alertdialog' : undefined}\n aria-label={label}\n aria-labelledby={labelledBy}\n aria-describedby={describedBy}\n aria-modal={\n stack ? (stack.open && stack.active ? 'true' : 'false') : undefined\n }\n aria-hidden={\n stack ? (stack.open && stack.active ? 'false' : 'true') : undefined\n }\n inert={stack && (!stack.open || !stack.active) ? true : undefined}\n tabindex={-1}\n data-light-dismiss={lightDismiss ? '' : undefined}\n data-component=\"dialog-surface\"\n data-stack-open={stack ? String(stack.open) : undefined}\n data-stack-active={stack ? String(stack.active) : undefined}\n data-stack-position={stack?.position}\n data-stack-count={stack?.count}\n data-size={size}\n data-presentation={presentation}\n data-preferred-width={preferredWidth === undefined ? undefined : ''}\n data-body-inset={bodyInset === 'compact' ? 'default' : bodyInset}\n data-footer-inset={footerInset === 'compact' ? 'default' : footerInset}\n data-viewport-gutter={\n viewportGutter === undefined && !stack ? undefined : ''\n }\n data-max-height={maxHeight === undefined ? undefined : ''}\n data-height={height === undefined ? undefined : ''}\n data-body-layout={bodyLayout === 'flow' ? undefined : bodyLayout}\n data-header-presentation={\n headerPresentation === 'floating' ? 'floating' : undefined\n }\n data-footer-presentation={\n footerPresentation === 'floating' ? 'floating' : undefined\n }\n data-min-height={minHeight === undefined ? undefined : ''}\n data-resizable={resizable ? '' : undefined}\n data-enter-motion={enterMotion === 'slide' ? undefined : enterMotion}\n data-exit-motion={exitMotion === 'slide' ? undefined : exitMotion}\n style={style || undefined}\n slot={slot}\n >\n {withoutHeader ? null : (\n <header class=\"kui-dialog-surface__header\">\n {heading === undefined ? (\n <h2 class=\"kui-dialog-surface__title\">{label}</h2>\n ) : (\n <div class=\"kui-dialog-surface__title\">{heading}</div>\n )}\n <div class=\"kui-dialog-surface__header-actions\">\n {headerActions}\n <button\n type=\"button\"\n class=\"kui-dialog-surface__close\"\n aria-label={closeLabel}\n data-emphasis={closeEmphasis === 'quiet' ? 'quiet' : undefined}\n data-dialog-close=\"\"\n >\n <LucideIcon\n icon={X}\n name=\"x\"\n size={closeEmphasis === 'quiet' ? 'm' : 'l'}\n />\n </button>\n </div>\n </header>\n )}\n {presentation === 'bottom-sheet' && resizable ? (\n <div\n class=\"kui-dialog-surface__sheet-handle\"\n role=\"separator\"\n aria-orientation=\"horizontal\"\n aria-label=\"Resize sheet\"\n tabindex={0}\n />\n ) : null}\n <div class=\"kui-dialog-surface__body\">{children}</div>\n {footer === undefined ? null : (\n <footer class=\"kui-dialog-surface__footer\">{footer}</footer>\n )}\n {/* Where kerfjs/overlay hosts a popover or tooltip opened inside the\n modal dialog, so it stays interactive above the inert page. */}\n <div data-kerf-overlay-host data-morph-skip style=\"display:contents\" />\n </dialog>\n );\n}\n","// KF-0MY6JQ: PinnablePopoverSurface, one of the four surfaces the\n// `@kerfjs/ui/surface-scaffold` facade re-exports.\nimport { Pin, X } from 'lucide';\n\nimport type { KerfUiContent } from '../../../../shared/content/semantic-content.js';\nimport { filterDataAttributes } from '../../../../shared/dom/extension-attributes.js';\nimport type { CssLength } from '../../../../shared/styles/css-values.js';\nimport { LucideIcon } from '../../../media/lucide-icon/lucide-icon.js';\nimport type {\n DialogSurfaceBodyLayout,\n DialogSurfaceHeight,\n DialogSurfaceMaxHeight,\n DialogSurfaceSize,\n} from './dialog-surface.js';\nimport type { PopoverDialogSurfaceDataAttributes } from './popover-dialog-surface.js';\nimport type { SurfacePresentation } from './surface-presentation.js';\n\n/**\n * Where a PinnablePopoverSurface appears: the top layer, or in flow. An alias\n * of the shared {@link SurfacePresentation}.\n */\nexport type PinnablePopoverSurfacePresentation = SurfacePresentation;\n\nexport interface PinnablePopoverSurfaceProps {\n /**\n * The root id: what an opening control's `popoverTarget` names. The title\n * and the move description derive their ids from it.\n */\n id: string;\n /** The title text: the surface's accessible name and its move handle's. */\n label: string;\n /**\n * Id of the element whose text describes the surface, rendered as\n * `aria-describedby` on the `role=\"dialog\"` root.\n */\n describedBy?: string;\n /** The body content, below the header. */\n children: KerfUiContent;\n /** Controls before the Pin and Close buttons in the header. */\n headerActions?: KerfUiContent;\n /**\n * `overlay` (default) is a native `popover=\"manual\"` in the top layer that\n * `wirePinnablePopover` places, dismisses, and moves; `embedded` renders\n * the same surface in flow for a catalog or a design canvas.\n */\n presentation?: PinnablePopoverSurfacePresentation;\n /**\n * Render it pinned: an `embedded` preview of the pinned state. An\n * overlay's pinned state belongs to `wirePinnablePopover`; pass `pinned`\n * there to restore it.\n */\n pinned?: boolean;\n /** Preferred width preset: 400px, 560px (default), or 800px. */\n size?: DialogSurfaceSize;\n /** Preferred width; takes precedence over `size`, within the viewport cap. */\n preferredWidth?: CssLength;\n /** Definite height, bounded by the dynamic viewport minus both gutters. */\n height?: DialogSurfaceHeight;\n /** Height cap, bounded the same way, for a surface that sizes to content. */\n maxHeight?: DialogSurfaceMaxHeight;\n /**\n * Edge clearance on each side of the viewport (default 16px): the surface\n * is placed, dragged, and moved inside it.\n */\n viewportGutter?: CssLength;\n /**\n * Body layout (default `flow`); `fill` lets one child own the body and\n * `fill-last` stacks fixed rows above one filling last child.\n */\n bodyLayout?: DialogSurfaceBodyLayout;\n /** Add a bottom-edge handle that pins and resizes an overlay by drag or arrow key. */\n resizeFromBottom?: boolean;\n /** The Pin toggle's accessible name (default `Pin`). */\n pinLabel?: string;\n /** The close button's accessible name (default `Close`). */\n closeLabel?: string;\n /** The move handle's accessible description of the pointer and keyboard move. */\n moveDescription?: string;\n rootAttributes?: PopoverDialogSurfaceDataAttributes;\n className?: string;\n /** Native named-slot assignment when composed inside a web component. */\n slot?: string;\n}\n\nconst PINNABLE_POPOVER_PROTECTED = new Set([\n 'data-component',\n 'data-presentation',\n 'data-size',\n 'data-height',\n 'data-max-height',\n 'data-body-layout',\n 'data-pinned',\n 'data-placed',\n 'data-scrolled',\n 'data-resize-from-bottom',\n]);\n\nconst DEFAULT_MOVE_DESCRIPTION =\n 'Drag the title or press the arrow keys to move it; hold Shift to move farther. Moving it pins it.';\n\n/**\n * A non-modal surface a person can pin and move. Transient by default: it\n * opens below the control that opened it and closes on Escape or a press\n * outside. Pinned (by its header Pin toggle or `pinPopover()`), it stays\n * open while the page is used, drags by its title, moves with the arrow\n * keys, resizes, and stays inside the viewport gutter. Open it with a\n * `popoverTarget` control or `showPopover()`, and call `wirePinnablePopover()`\n * once for its placement, dismissal, and movement; the application stores\n * what `onChange` reports. Use `PopoverDialogSurface` for a dialog that only\n * ever light-dismisses.\n */\nexport function PinnablePopoverSurface({\n id,\n label,\n describedBy,\n children,\n headerActions,\n presentation = 'overlay',\n pinned = false,\n size = 'medium',\n preferredWidth,\n height,\n maxHeight,\n viewportGutter,\n bodyLayout = 'flow',\n resizeFromBottom = false,\n pinLabel = 'Pin',\n closeLabel = 'Close',\n moveDescription = DEFAULT_MOVE_DESCRIPTION,\n rootAttributes = {},\n className = '',\n slot,\n}: PinnablePopoverSurfaceProps) {\n const style = [\n preferredWidth === undefined\n ? ''\n : `--_kui-pinnable-popover-surface-preferred-width:${preferredWidth}`,\n viewportGutter === undefined\n ? ''\n : `--_kui-pinnable-popover-surface-gutter:${viewportGutter}`,\n height === undefined || height === 'viewport'\n ? ''\n : `--_kui-pinnable-popover-surface-height:${height}`,\n maxHeight === undefined || maxHeight === 'viewport'\n ? ''\n : `--_kui-pinnable-popover-surface-max-height:${maxHeight}`,\n ]\n .filter(Boolean)\n .join(';');\n const overlay = presentation === 'overlay';\n return (\n <section\n {...filterDataAttributes(rootAttributes, PINNABLE_POPOVER_PROTECTED)}\n id={id}\n class={`kui-pinnable-popover-surface ${className}`.trim()}\n data-component=\"pinnable-popover-surface\"\n data-presentation={presentation}\n data-size={size}\n data-height={height === undefined ? undefined : ''}\n data-max-height={maxHeight === undefined ? undefined : ''}\n data-body-layout={bodyLayout === 'flow' ? undefined : bodyLayout}\n data-resize-from-bottom={resizeFromBottom ? '' : undefined}\n data-pinned={pinned ? '' : undefined}\n popover={overlay ? 'manual' : undefined}\n role=\"dialog\"\n aria-labelledby={`${id}-title`}\n aria-describedby={describedBy}\n style={style || undefined}\n slot={slot}\n >\n <header class=\"kui-pinnable-popover-surface__header\">\n <button\n type=\"button\"\n class=\"kui-pinnable-popover-surface__handle\"\n aria-describedby={`${id}-move-description`}\n >\n <span id={`${id}-title`} class=\"kui-pinnable-popover-surface__title\">\n {label}\n </span>\n </button>\n <span id={`${id}-move-description`} hidden>\n {moveDescription}\n </span>\n <div class=\"kui-pinnable-popover-surface__header-actions\">\n {headerActions}\n <button\n type=\"button\"\n class=\"kui-pinnable-popover-surface__control\"\n aria-label={pinLabel}\n aria-pressed={String(pinned)}\n data-pinnable-popover-pin=\"\"\n >\n <LucideIcon icon={Pin} name=\"pin\" size=\"m\" />\n </button>\n <button\n type=\"button\"\n class=\"kui-pinnable-popover-surface__control\"\n aria-label={closeLabel}\n popoverTarget={overlay ? id : undefined}\n popoverTargetAction={overlay ? 'hide' : undefined}\n >\n <LucideIcon icon={X} name=\"x\" size=\"l\" />\n </button>\n </div>\n </header>\n <div class=\"kui-pinnable-popover-surface__body\">{children}</div>\n {resizeFromBottom && overlay ? (\n <button\n type=\"button\"\n class=\"kui-pinnable-popover-surface__bottom-resize\"\n aria-label={`Resize ${label} vertically`}\n title={`Resize ${label} vertically`}\n />\n ) : undefined}\n </section>\n );\n}\n","// KF-0MY6JQ: PopoverDialogSurface, one of the four surfaces the\n// `@kerfjs/ui/surface-scaffold` facade re-exports.\nimport type { KerfUiContent } from '../../../../shared/content/semantic-content.js';\nimport { filterDataAttributes } from '../../../../shared/dom/extension-attributes.js';\nimport {\n type AnchorName,\n checkedAnchorName,\n} from '../../../../shared/styles/anchor-name.js';\nimport type { CssLength } from '../../../../shared/styles/css-values.js';\nimport type {\n DialogSurfaceBodyLayout,\n DialogSurfaceHeight,\n DialogSurfaceMaxHeight,\n DialogSurfaceSize,\n} from './dialog-surface.js';\nimport type { SurfacePresentation } from './surface-presentation.js';\n\n/**\n * Where a PopoverDialogSurface appears: the top layer, or in flow. An alias\n * of the shared {@link SurfacePresentation}.\n */\nexport type PopoverDialogSurfacePresentation = SurfacePresentation;\n\n/** How an overlay PopoverDialogSurface closes: light dismiss, or its own controls. */\nexport type PopoverDialogSurfaceDismiss = 'light' | 'manual';\n\n/** Application `data-*` metadata on the surface root. */\nexport type PopoverDialogSurfaceDataAttributes = Readonly<\n Record<`data-${string}`, string>\n>;\n\ntype PopoverDialogSurfaceName =\n { label: string; labelledBy?: never } | { label?: never; labelledBy: string };\n\nexport type PopoverDialogSurfaceProps = PopoverDialogSurfaceName & {\n /** The root id: what an opening control's `popovertarget` names. */\n id?: string;\n /**\n * Id of the element whose text is the dialog's accessible description,\n * such as a title `ToolbarText`'s `descriptionId`; rendered as\n * `aria-describedby` on the `role=\"dialog\"` root.\n */\n describedBy?: string;\n children: KerfUiContent;\n /**\n * `overlay` (default) is a native `popover=\"auto\"` in the top layer:\n * non-modal, light dismiss (Escape or a press outside), nothing inert.\n * `embedded` renders the same surface in flow for a catalog or inline use.\n */\n presentation?: PopoverDialogSurfacePresentation;\n /**\n * How an overlay closes. `light` (default) is `popover=\"auto\"`: Escape or a\n * press outside closes it. `manual` is `popover=\"manual\"`: only its own\n * controls (`popovertargetaction=\"hide\"`) or `hidePopover()` close it, for a\n * request the person must answer. Ignored when `embedded`.\n */\n dismiss?: PopoverDialogSurfaceDismiss;\n /**\n * KF-T1V86Q: a CSS anchor name (a dashed ident such as `--app-main`) the\n * open overlay docks to: centered on the bottom edge of the element whose\n * `anchor-name` it is, inset by `viewportGutter`. The application names\n * that element (its shell's main column). Engines without CSS anchor\n * positioning keep the centered top-layer placement. Ignored when\n * `embedded`.\n */\n anchorName?: AnchorName;\n /** Preferred width preset: 400px, 560px (default), or 800px. */\n size?: DialogSurfaceSize;\n /** Preferred width; takes precedence over `size`, within the viewport cap. */\n preferredWidth?: CssLength;\n /** Definite height, bounded by the dynamic viewport minus both gutters. */\n height?: DialogSurfaceHeight;\n /** Height cap, bounded the same way, for a surface that sizes to content. */\n maxHeight?: DialogSurfaceMaxHeight;\n /** Edge clearance on each side of the viewport (default 16px). */\n viewportGutter?: CssLength;\n /**\n * Body layout (default `flow`); `fill` lets one child own the surface and\n * `fill-last` stacks fixed rows above one filling last child.\n */\n bodyLayout?: DialogSurfaceBodyLayout;\n rootAttributes?: PopoverDialogSurfaceDataAttributes;\n className?: string;\n /** Native named-slot assignment when composed inside a web component. */\n slot?: string;\n};\n\nconst POPOVER_DIALOG_PROTECTED = new Set([\n 'data-anchored',\n 'data-component',\n 'data-presentation',\n 'data-size',\n 'data-height',\n 'data-max-height',\n 'data-body-layout',\n]);\n\n/**\n * A non-modal dialog surface on the native Popover API: Kerf's dialog chrome,\n * viewport-bounded size, and single-child fill without application CSS.\n * Open it with a `popovertarget` control or `showPopover()`; it light\n * dismisses and leaves the page interactive. Use `DialogSurface` when the\n * task must block the page.\n */\nexport function PopoverDialogSurface({\n id,\n children,\n label,\n labelledBy,\n describedBy,\n presentation = 'overlay',\n dismiss = 'light',\n anchorName,\n size = 'medium',\n preferredWidth,\n height,\n maxHeight,\n viewportGutter,\n bodyLayout = 'flow',\n rootAttributes = {},\n className = '',\n slot,\n}: PopoverDialogSurfaceProps) {\n if (anchorName !== undefined)\n checkedAnchorName(anchorName, 'PopoverDialogSurface anchorName');\n const anchored = anchorName !== undefined && presentation === 'overlay';\n const style = [\n anchored ? `position-anchor:${anchorName}` : '',\n preferredWidth === undefined\n ? ''\n : `--_kui-popover-dialog-surface-preferred-width:${preferredWidth}`,\n viewportGutter === undefined\n ? ''\n : `--_kui-popover-dialog-surface-gutter:${viewportGutter}`,\n height === undefined || height === 'viewport'\n ? ''\n : `--_kui-popover-dialog-surface-height:${height}`,\n maxHeight === undefined || maxHeight === 'viewport'\n ? ''\n : `--_kui-popover-dialog-surface-max-height:${maxHeight}`,\n ]\n .filter(Boolean)\n .join(';');\n return (\n <section\n {...filterDataAttributes(rootAttributes, POPOVER_DIALOG_PROTECTED)}\n id={id}\n class={`kui-popover-dialog-surface ${className}`.trim()}\n data-component=\"popover-dialog-surface\"\n data-presentation={presentation}\n data-size={size}\n data-height={height === undefined ? undefined : ''}\n data-max-height={maxHeight === undefined ? undefined : ''}\n data-body-layout={bodyLayout === 'flow' ? undefined : bodyLayout}\n data-anchored={anchored ? '' : undefined}\n popover={\n presentation !== 'overlay'\n ? undefined\n : dismiss === 'manual'\n ? 'manual'\n : 'auto'\n }\n role=\"dialog\"\n aria-label={label}\n aria-labelledby={labelledBy}\n aria-describedby={describedBy}\n style={style || undefined}\n slot={slot}\n >\n {children}\n </section>\n );\n}\n","// KF-0MY6JQ: PopupSurface, one of the four surfaces the\n// `@kerfjs/ui/surface-scaffold` facade re-exports.\nimport type { KerfUiContent } from '../../../../shared/content/semantic-content.js';\nimport {\n filterDataAttributes,\n type RootDataAttributes,\n} from '../../../../shared/dom/extension-attributes.js';\n\nexport type PopupSurfaceInset =\n | 'none'\n | 'compact'\n | 'default'\n | /** @deprecated Use default. */ 'standard'\n | /** @deprecated Use none. */ 'list-zero';\n\nexport interface PopupSurfaceProps {\n children: KerfUiContent;\n inset?: PopupSurfaceInset;\n className?: string;\n /** Native named-slot assignment when composed inside a web component. */\n slot?: string;\n /** Application `data-*` metadata on the root, such as a row key or an\n * editor node marker; the component's own markers stay protected. */\n rootAttributes?: RootDataAttributes;\n}\n\nconst POPUP_SURFACE_PROTECTED = new Set([\n 'data-body-inset',\n 'data-body-layout',\n 'data-component',\n 'data-dialog-close',\n 'data-emphasis',\n 'data-enter-motion',\n 'data-exit-motion',\n 'data-footer-inset',\n 'data-footer-presentation',\n 'data-header-presentation',\n 'data-height',\n 'data-inset',\n 'data-light-dismiss',\n 'data-max-height',\n 'data-min-height',\n 'data-preferred-width',\n 'data-presentation',\n 'data-resizable',\n 'data-size',\n 'data-stack-active',\n 'data-stack-count',\n 'data-stack-open',\n 'data-stack-position',\n 'data-viewport-gutter',\n]);\n\n/** Configure recurring Web Awesome dropdown-menu geometry without consumer ::part() CSS. */\nexport function PopupSurface({\n children,\n inset = 'default',\n className = '',\n slot,\n rootAttributes = {},\n}: PopupSurfaceProps) {\n return (\n <span\n {...filterDataAttributes(rootAttributes, POPUP_SURFACE_PROTECTED)}\n class={`kui-popup-surface ${className}`.trim()}\n data-component=\"popup-surface\"\n data-inset={\n inset === 'standard'\n ? 'default'\n : inset === 'list-zero'\n ? 'none'\n : inset\n }\n slot={slot}\n >\n {children}\n </span>\n );\n}\n","import { watchOwnedStyles } from '../../../../shared/dom/owned-styles.js';\n\n/**\n * Where a pinned PinnablePopoverSurface sits: its top-left corner in viewport\n * px, and the size the person resized it to (omitted until they do).\n */\nexport interface PinnablePopoverPlacement {\n readonly x: number;\n readonly y: number;\n readonly width?: number;\n readonly height?: number;\n}\n\n/** What changed a PinnablePopoverSurface's pinned state or placement. */\nexport type PinnablePopoverChangeReason = 'pin' | 'unpin' | 'move' | 'resize';\n\n/** What `wirePinnablePopover`'s `onChange` reports. */\nexport interface PinnablePopoverChange {\n readonly pinned: boolean;\n /** The pinned placement; `null` while transient. */\n readonly placement: PinnablePopoverPlacement | null;\n readonly reason: PinnablePopoverChangeReason;\n}\n\nexport interface PinnablePopoverOptions {\n /**\n * The element a transient surface opens below (or above, without room\n * below). Default: the first control whose `popovertarget` names the\n * surface. Without one, a transient surface opens centered.\n */\n anchor?: Element | (() => Element | null);\n /** Start pinned, as the application last stored it. */\n pinned?: boolean;\n /** The pinned placement to restore, as `onChange` last reported it. */\n placement?: PinnablePopoverPlacement;\n /** An arrow key's move, in px (default 8). */\n step?: number;\n /** A Shift+arrow move, in px (default 40). */\n largeStep?: number;\n /**\n * Called when the person (or `pinPopover`) pins, unpins, moves, or resizes\n * the surface. A clamp after a window resize is not reported: the surface\n * returns to the reported placement when the window has room again.\n */\n onChange?: (change: PinnablePopoverChange) => void;\n}\n\ninterface Controller {\n readonly pinned: boolean;\n setPinned(pinned: boolean): void;\n}\n\nconst controllers = new WeakMap<HTMLElement, Controller>();\n\n/** The surface variables that place it, and the registered resolved gutter. */\nconst X_PROPERTY = '--_kui-pinnable-popover-surface-x';\nconst Y_PROPERTY = '--_kui-pinnable-popover-surface-y';\nconst GUTTER_PROPERTY = '--_kui-pinnable-popover-surface-gutter-px';\nconst DEFAULT_GUTTER = 16;\n/** Space between the anchor and a transient surface. */\nconst ANCHOR_GAP = 4;\n/** Pointer travel, in px, before a press on the header becomes a drag. */\nconst DRAG_THRESHOLD = 3;\nconst MIN_RESIZE_HEIGHT = 160;\n\nconst ARROWS: Readonly<Record<string, readonly [number, number]>> = {\n ArrowLeft: [-1, 0],\n ArrowRight: [1, 0],\n ArrowUp: [0, -1],\n ArrowDown: [0, 1],\n};\n\n/** Whether `surface` is pinned (its rendered state when it is not wired). */\nexport function isPopoverPinned(surface: HTMLElement): boolean {\n return (\n controllers.get(surface)?.pinned ?? surface.hasAttribute('data-pinned')\n );\n}\n\n/**\n * Pin (or, with `false`, unpin) a wired PinnablePopoverSurface, as its\n * header Pin toggle does. Pinned, it no longer closes on a press outside\n * and keeps where it is; unpinned, it returns below its anchor. Reported\n * through `onChange`. Does nothing to a surface that is not wired.\n */\nexport function pinPopover(surface: HTMLElement, pinned = true): void {\n controllers.get(surface)?.setPinned(pinned);\n}\n\n/**\n * Give an overlay PinnablePopoverSurface its behavior: placement below its\n * anchor while transient, a press outside or Escape closing it; the Pin\n * toggle; a drag by the header and the arrow keys on the focused title\n * (Shift for `largeStep`) moving it, which pins it; a pinned surface's\n * resize; and a clamp inside the viewport gutter, kept after a window\n * resize. Pinned, it closes only by Escape (with focus inside it), its Close\n * button, or `hidePopover()`. The state survives application re-renders and\n * closing; `onChange` reports it for the application to store. An\n * `embedded` surface is left alone. Returns a disposer.\n */\nexport function wirePinnablePopover(\n surface: HTMLElement,\n options: PinnablePopoverOptions = {},\n): () => void {\n if (surface.dataset.presentation === 'embedded') return () => {};\n const doc = surface.ownerDocument;\n const view = doc.defaultView ?? globalThis;\n const step = options.step ?? 8;\n const largeStep = options.largeStep ?? 40;\n let pinned = options.pinned ?? false;\n let requested: PinnablePopoverPlacement | null =\n pinned && options.placement ? options.placement : null;\n /** Inline styles the controller owns, restored after a re-render. */\n const owned = new Map<string, string>();\n let frame = 0;\n\n const isOpen = () => surface.matches(':popover-open');\n const report = (reason: PinnablePopoverChangeReason) =>\n options.onChange?.({ pinned, placement: requested, reason });\n\n const own = (property: string, value: string | null) => {\n if (value === null) {\n owned.delete(property);\n surface.style.removeProperty(property);\n } else {\n owned.set(property, value);\n if (surface.style.getPropertyValue(property) !== value)\n surface.style.setProperty(property, value);\n }\n };\n const syncAttributes = () => {\n surface.toggleAttribute('data-pinned', pinned);\n surface.toggleAttribute('data-placed', owned.has(X_PROPERTY));\n const pin = surface.querySelector('[data-pinnable-popover-pin]');\n if (pin && pin.getAttribute('aria-pressed') !== String(pinned))\n pin.setAttribute('aria-pressed', String(pinned));\n };\n\n const gutter = () => {\n const value = parseFloat(\n view.getComputedStyle(surface).getPropertyValue(GUTTER_PROPERTY),\n );\n return Number.isFinite(value) ? value : DEFAULT_GUTTER;\n };\n const viewport = () => ({\n width: doc.documentElement.clientWidth || view.innerWidth,\n height: view.innerHeight,\n });\n /** Keep the box inside the viewport gutter; its leading edge wins. */\n const clamp = (x: number, y: number) => {\n const box = surface.getBoundingClientRect();\n const g = gutter();\n const { width, height } = viewport();\n return {\n x: Math.max(g, Math.min(x, width - g - box.width)),\n y: Math.max(g, Math.min(y, height - g - box.height)),\n };\n };\n const place = (x: number, y: number) => {\n const at = clamp(x, y);\n own(X_PROPERTY, `${at.x}px`);\n own(Y_PROPERTY, `${at.y}px`);\n syncAttributes();\n return at;\n };\n const applySize = () => {\n own(\n 'width',\n requested?.width === undefined ? null : `${requested.width}px`,\n );\n own(\n 'height',\n requested?.height === undefined ? null : `${requested.height}px`,\n );\n };\n\n const resolveAnchor = (): Element | null => {\n const anchor =\n typeof options.anchor === 'function' ? options.anchor() : options.anchor;\n if (anchor) return anchor;\n if (!surface.id) return null;\n // The opener outside the surface, not its own Close button.\n for (const invoker of doc.querySelectorAll(\n `[popovertarget=\"${CSS.escape(surface.id)}\"]`,\n ))\n if (!surface.contains(invoker)) return invoker;\n return null;\n };\n /** Below the anchor, start-aligned, or above it without room below. */\n const placeAtAnchor = () => {\n const anchor = resolveAnchor();\n if (!anchor) {\n own(X_PROPERTY, null);\n own(Y_PROPERTY, null);\n syncAttributes();\n return;\n }\n const target = anchor.getBoundingClientRect();\n const box = surface.getBoundingClientRect();\n const rtl = view.getComputedStyle(surface).direction === 'rtl';\n let y = target.bottom + ANCHOR_GAP;\n if (\n y + box.height > viewport().height - gutter() &&\n target.top - ANCHOR_GAP - box.height >= gutter()\n )\n y = target.top - ANCHOR_GAP - box.height;\n place(rtl ? target.right - box.width : target.left, y);\n };\n /** Where an open surface belongs now. */\n const layout = () => {\n if (!isOpen()) return;\n if (!pinned) placeAtAnchor();\n else if (requested) place(requested.x, requested.y);\n else if (owned.has(X_PROPERTY)) {\n const box = surface.getBoundingClientRect();\n place(box.left, box.top);\n }\n };\n /** The pinned placement after a move, keeping any resized size. */\n const settle = (at: { x: number; y: number }) => {\n requested = {\n ...(requested ?? {}),\n x: at.x,\n y: at.y,\n };\n };\n\n const setPinned = (next: boolean) => {\n if (next === pinned) return;\n pinned = next;\n if (pinned) {\n if (isOpen()) {\n const box = surface.getBoundingClientRect();\n settle(place(box.left, box.top));\n }\n } else {\n requested = null;\n applySize();\n layout();\n }\n syncAttributes();\n report(pinned ? 'pin' : 'unpin');\n };\n const controller: Controller = {\n get pinned() {\n return pinned;\n },\n setPinned,\n };\n controllers.set(surface, controller);\n\n const onBeforeToggle = (event: Event) => {\n if ((event as ToggleEvent).newState !== 'open') return;\n applySize();\n view.cancelAnimationFrame(frame);\n // Laid out by the next frame, placed before it paints.\n frame = view.requestAnimationFrame(layout);\n };\n const scrollOwner = () =>\n surface.querySelector<HTMLElement>(\n ':scope > .kui-pinnable-popover-surface__body > :last-child',\n );\n const syncScrollDivider = () => {\n surface.toggleAttribute(\n 'data-scrolled',\n surface.dataset.bodyLayout === 'fill-last' &&\n (scrollOwner()?.scrollTop ?? 0) > 1,\n );\n };\n const onToggle = (event: Event) => {\n if ((event as ToggleEvent).newState === 'open') {\n layout();\n syncScrollDivider();\n }\n };\n const onSurfaceScroll = (event: Event) => {\n if (event.target === scrollOwner()) syncScrollDivider();\n };\n\n const onClick = (event: MouseEvent) => {\n const pin = (event.target as Element).closest(\n '[data-pinnable-popover-pin]',\n );\n if (pin && surface.contains(pin)) setPinned(!pinned);\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n const resizeHandle = (event.target as Element).closest(\n '.kui-pinnable-popover-surface__bottom-resize',\n );\n if (\n resizeHandle?.parentElement === surface &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown') &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey\n ) {\n event.preventDefault();\n setPinned(true);\n const box = surface.getBoundingClientRect();\n const distance = event.shiftKey ? largeStep : step;\n const maxHeight = Math.max(0, viewport().height - gutter() - box.top);\n const height = Math.min(\n Math.max(\n MIN_RESIZE_HEIGHT,\n box.height + (event.key === 'ArrowDown' ? distance : -distance),\n ),\n maxHeight,\n );\n own('height', `${Math.round(height)}px`);\n requested = {\n ...(requested ?? { x: box.left, y: box.top }),\n height: Math.round(height),\n };\n report('resize');\n return;\n }\n const handle = (event.target as Element).closest(\n '.kui-pinnable-popover-surface__handle',\n );\n const delta = ARROWS[event.key];\n if (!handle || !delta || event.altKey || event.ctrlKey || event.metaKey)\n return;\n event.preventDefault();\n setPinned(true);\n const distance = event.shiftKey ? largeStep : step;\n const box = surface.getBoundingClientRect();\n settle(\n place(box.left + delta[0] * distance, box.top + delta[1] * distance),\n );\n report('move');\n };\n\n let drag:\n | {\n id: number;\n header: HTMLElement;\n startX: number;\n startY: number;\n left: number;\n top: number;\n moving: boolean;\n bounds?: { min: number; maxX: number; maxY: number };\n }\n | undefined;\n let resizeDrag:\n | { id: number; handle: HTMLElement; startY: number; height: number }\n | undefined;\n const onPointerDown = (event: PointerEvent) => {\n const target = event.target as Element;\n const resizeHandle = target.closest<HTMLElement>(\n '.kui-pinnable-popover-surface__bottom-resize',\n );\n if (resizeHandle?.parentElement === surface && event.button === 0) {\n const box = surface.getBoundingClientRect();\n setPinned(true);\n resizeDrag = {\n id: event.pointerId,\n handle: resizeHandle,\n startY: event.clientY,\n height: box.height,\n };\n resizeHandle.setPointerCapture?.(event.pointerId);\n event.preventDefault();\n return;\n }\n const header = target.closest<HTMLElement>(\n '.kui-pinnable-popover-surface__header',\n );\n if (\n !header ||\n header.parentElement !== surface ||\n event.button !== 0 ||\n target.closest('.kui-pinnable-popover-surface__header-actions')\n )\n return;\n const box = surface.getBoundingClientRect();\n drag = {\n id: event.pointerId,\n header,\n startX: event.clientX,\n startY: event.clientY,\n left: box.left,\n top: box.top,\n moving: false,\n };\n header.setPointerCapture?.(event.pointerId);\n };\n const onPointerMove = (event: PointerEvent) => {\n if (resizeDrag && event.pointerId === resizeDrag.id) {\n const box = surface.getBoundingClientRect();\n const maxHeight = Math.max(0, viewport().height - gutter() - box.top);\n const height = Math.min(\n Math.max(\n MIN_RESIZE_HEIGHT,\n resizeDrag.height + event.clientY - resizeDrag.startY,\n ),\n maxHeight,\n );\n own('height', `${Math.round(height)}px`);\n return;\n }\n if (!drag || event.pointerId !== drag.id) return;\n const dx = event.clientX - drag.startX;\n const dy = event.clientY - drag.startY;\n if (!drag.moving && Math.hypot(dx, dy) < DRAG_THRESHOLD) return;\n const firstMove = !drag.bounds;\n if (!drag.bounds) {\n drag.moving = true;\n setPinned(true);\n const box = surface.getBoundingClientRect();\n const min = gutter();\n const viewSize = viewport();\n drag.bounds = {\n min,\n maxX: viewSize.width - min - box.width,\n maxY: viewSize.height - min - box.height,\n };\n }\n const { min, maxX, maxY } = drag.bounds;\n own(X_PROPERTY, `${Math.max(min, Math.min(drag.left + dx, maxX))}px`);\n own(Y_PROPERTY, `${Math.max(min, Math.min(drag.top + dy, maxY))}px`);\n if (firstMove) syncAttributes();\n };\n const onPointerEnd = (event: PointerEvent) => {\n if (resizeDrag && event.pointerId === resizeDrag.id) {\n const { handle } = resizeDrag;\n resizeDrag = undefined;\n if (handle.hasPointerCapture?.(event.pointerId))\n handle.releasePointerCapture(event.pointerId);\n const box = surface.getBoundingClientRect();\n requested = {\n ...(requested ?? { x: box.left, y: box.top }),\n height: Math.round(box.height),\n };\n report('resize');\n return;\n }\n if (!drag || event.pointerId !== drag.id) return;\n const { header, moving } = drag;\n drag = undefined;\n if (header.hasPointerCapture?.(event.pointerId))\n header.releasePointerCapture(event.pointerId);\n if (!moving) return;\n const box = surface.getBoundingClientRect();\n settle(place(box.left, box.top));\n report('move');\n };\n\n // A transient surface closes on a press outside it and its openers.\n const onDocumentPointerDown = (event: PointerEvent) => {\n if (pinned || !isOpen()) return;\n const path = event.composedPath();\n if (path.includes(surface)) return;\n const anchor = resolveAnchor();\n if (anchor && path.includes(anchor)) return;\n if (\n path.some(\n (node) =>\n node instanceof Element &&\n node.getAttribute('popovertarget') === surface.id,\n )\n )\n return;\n surface.hidePopover();\n };\n // Escape closes it: always while transient, from inside it while pinned.\n // An open light-dismiss popover or modal dialog takes Escape first.\n const onDocumentKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape' || event.defaultPrevented || !isOpen()) return;\n if (pinned && !surface.contains(doc.activeElement)) return;\n if (\n doc.querySelector(\n ':is([popover=\"\"], [popover=\"auto\"]):popover-open, dialog:modal',\n )\n )\n return;\n event.preventDefault();\n surface.hidePopover();\n };\n\n const onResize = () => {\n if (drag?.moving) {\n drag.bounds = undefined;\n return;\n }\n layout();\n };\n const onScroll = () => {\n if (!pinned) layout();\n };\n\n // An application re-render morphs the surface back to its template: restore\n // what the controller owns. A person resizing a pinned surface writes its\n // inline width and height: take those as the pinned size.\n const adoptResize = () => {\n if (pinned) {\n const width = surface.style.width;\n const height = surface.style.height;\n const resized =\n (width !== '' && width !== owned.get('width')) ||\n (height !== '' && height !== owned.get('height'));\n if (resized) {\n const box = surface.getBoundingClientRect();\n requested = {\n ...(requested ?? { x: box.left, y: box.top }),\n width: Math.round(box.width),\n height: Math.round(box.height),\n };\n if (width !== '') owned.set('width', width);\n if (height !== '') owned.set('height', height);\n report('resize');\n }\n }\n };\n\n if (pinned) syncAttributes();\n syncScrollDivider();\n if (isOpen()) {\n applySize();\n layout();\n }\n const restore = watchOwnedStyles(surface, owned, {\n attributes: ['data-pinned', 'data-placed', 'data-scrolled', 'aria-pressed'],\n childList: true,\n subtree: true,\n beforeRestore: adoptResize,\n afterRestore: () => {\n syncAttributes();\n syncScrollDivider();\n },\n });\n surface.addEventListener('beforetoggle', onBeforeToggle);\n surface.addEventListener('toggle', onToggle);\n surface.addEventListener('scroll', onSurfaceScroll, {\n capture: true,\n passive: true,\n });\n surface.addEventListener('click', onClick);\n surface.addEventListener('keydown', onKeyDown);\n surface.addEventListener('pointerdown', onPointerDown);\n surface.addEventListener('pointermove', onPointerMove);\n surface.addEventListener('pointerup', onPointerEnd);\n surface.addEventListener('pointercancel', onPointerEnd);\n doc.addEventListener('pointerdown', onDocumentPointerDown, true);\n doc.addEventListener('keydown', onDocumentKeyDown);\n view.addEventListener('resize', onResize);\n doc.addEventListener('scroll', onScroll, { capture: true, passive: true });\n\n return () => {\n view.cancelAnimationFrame(frame);\n restore.disconnect();\n surface.removeEventListener('beforetoggle', onBeforeToggle);\n surface.removeEventListener('toggle', onToggle);\n surface.removeEventListener('scroll', onSurfaceScroll, { capture: true });\n surface.removeEventListener('click', onClick);\n surface.removeEventListener('keydown', onKeyDown);\n surface.removeEventListener('pointerdown', onPointerDown);\n surface.removeEventListener('pointermove', onPointerMove);\n surface.removeEventListener('pointerup', onPointerEnd);\n surface.removeEventListener('pointercancel', onPointerEnd);\n doc.removeEventListener('pointerdown', onDocumentPointerDown, true);\n doc.removeEventListener('keydown', onDocumentKeyDown);\n view.removeEventListener('resize', onResize);\n doc.removeEventListener('scroll', onScroll, { capture: true });\n for (const property of owned.keys()) surface.style.removeProperty(property);\n owned.clear();\n surface.removeAttribute('data-placed');\n surface.removeAttribute('data-scrolled');\n if (controllers.get(surface) === controller) controllers.delete(surface);\n };\n}\n"]}