@kolkrabbi/kol-component 0.382.0 → 0.384.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.
@@ -1,12 +1,11 @@
1
1
  import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react'
2
2
  import { createPortal } from 'react-dom'
3
- import { IconLoader } from '@kolkrabbi/kol-icons'
4
3
  import Button from '../atoms/Button.jsx'
5
4
  import Input from '../atoms/Input.jsx'
6
5
  import ToggleCheckbox from '../atoms/ToggleCheckbox.jsx'
7
6
  import Header from './Header.jsx'
8
7
  import ModalShell from './ModalShell.jsx'
9
- import { KolboxShell, PopoverLayer } from '../utilities/Popover.jsx'
8
+ import { PanelShell, PopoverLayer } from '../utilities/Popover.jsx'
10
9
 
11
10
  /**
12
11
  * Modal — promise-based prompt + confirm + alert dialogs.
@@ -77,13 +76,12 @@ import { KolboxShell, PopoverLayer } from '../utilities/Popover.jsx'
77
76
 
78
77
  const ModalCtx = (globalThis[Symbol.for('@kolkrabbi/kol-component/ModalCtx')] ??= createContext(null))
79
78
 
80
- /* THE MODAL VARIANTS (user 2026-10-31: *"do we not use variants for different styles?"*) live on ModalShell (W2.1,
81
- * 2026-11-08) — the one panel: `lift`, `bordered`. Each modal keeps its own default (prompts bordered, Dialog
82
- * lift) until he picks one; an unknown name falls back to that default. */
83
- const KNOWN = new Set(['lift', 'bordered'])
84
- const modalVariant = (v, fallback) => (KNOWN.has(v) ? v : fallback)
85
-
86
- export function ModalProvider({ children, variant = 'bordered', container }) {
79
+ /* ONE VIEW, ONE SHELL (plan-2026-11-29-one-set-fold 1.3): every prompt, confirm, alert and form is drawn in PanelShell,
80
+ * kolbox's confirm and prompt for everyone — the title in the shell's header (a title of several lines, an alert's
81
+ * failure list, stays in the body, where it can wrap), `body` under it, the fields, the toggles, then Cancel (ghost) and
82
+ * the action (primary). The look is the theme's. `variant` on the provider or on a call ("bordered", "lift", "kolbox")
83
+ * is accepted and does nothing; the kolbox view (ModalViewKolbox) went to `_tmp/2026-11-29-one-set-fold/`. */
84
+ export function ModalProvider({ children, variant, container }) { // eslint-disable-line no-unused-vars
87
85
  const [state, setState] = useState(null)
88
86
 
89
87
  const closeWith = useCallback((value) => {
@@ -112,16 +110,15 @@ export function ModalProvider({ children, variant = 'bordered', container }) {
112
110
  return (
113
111
  <ModalCtx.Provider value={{ prompt, confirm, alert, form }}>
114
112
  {children}
115
- {variant === 'kolbox' ? <ModalViewKolbox state={state} closeWith={closeWith} /> : state && typeof document !== 'undefined' && createPortal(
116
- <ModalView state={state} closeWith={closeWith} variant={state.variant ?? variant} contained={!!container} />,
113
+ {state && typeof document !== 'undefined' && createPortal(
114
+ <ModalView state={state} closeWith={closeWith} contained={!!container} />,
117
115
  container ?? document.body,
118
116
  )}
119
117
  </ModalCtx.Provider>
120
118
  )
121
119
  }
122
120
 
123
- function ModalView({ state, closeWith, variant, contained }) {
124
- const look = modalVariant(variant, 'bordered')
121
+ function ModalView({ state, closeWith, contained }) {
125
122
  const [val, setVal] = useState(state.defaultValue ?? '')
126
123
  const [values, setValues] = useState(() => Object.fromEntries((state.options ?? []).map((o) => [o.id, !!o.defaultValue])))
127
124
  const [fieldVals, setFieldVals] = useState(() => Object.fromEntries((state.fields ?? []).map((f) => [f.id, f.defaultValue ?? ''])))
@@ -129,6 +126,8 @@ function ModalView({ state, closeWith, variant, contained }) {
129
126
  const dialogRef = useRef(null)
130
127
  const overlayRef = useRef(null)
131
128
  const typing = state.kind === 'prompt' || state.kind === 'form'
129
+ /* a title of several lines (an alert's failure list) stays in the body, where it wraps; one line heads the shell */
130
+ const long = typeof state.title === 'string' && state.title.includes('\n')
132
131
 
133
132
  /* the visual viewport (PromptHoldsWithKeyboard): the scrim is sized to it, so the dialog centres above the keyboard
134
133
  * instead of the browser scrolling the page to clear it; the scroll the page had is restored when the keyboard goes
@@ -162,10 +161,13 @@ function ModalView({ state, closeWith, variant, contained }) {
162
161
  const submit = () => closeWith(state.kind === 'prompt' ? val : state.kind === 'form' ? fieldVals : state.kind === 'alert' ? undefined : answer(true))
163
162
  const cancel = () => closeWith(typing ? null : state.kind === 'alert' ? undefined : answer(false))
164
163
 
165
- /* focus once on open — the key effect below re-runs per keystroke and would steal it back */
164
+ /* focus once on open — the key effect below re-runs per keystroke and would steal it back; a prompt's value is
165
+ * selected (kolbox's prompt). The focus goes back to whatever held it when the dialog closes. */
166
166
  useEffect(() => {
167
- if (typing) inputRef.current?.focus({ preventScroll: true })
167
+ const back = document.activeElement
168
+ if (typing) { inputRef.current?.focus({ preventScroll: true }); if (state.kind === 'prompt') inputRef.current?.select?.() }
168
169
  else dialogRef.current?.querySelector('[data-modal-ok]')?.focus(contained ? { preventScroll: true } : undefined)
170
+ return () => back?.focus?.({ preventScroll: true })
169
171
  }, [state.kind])
170
172
 
171
173
  /* Enter acts on its KEY UP (PromptEnterReopensItsOpener, kol-fxr 2026-11-28): acting on the key down handed the focus
@@ -197,70 +199,65 @@ function ModalView({ state, closeWith, variant, contained }) {
197
199
  <div
198
200
  ref={overlayRef}
199
201
  onMouseDown={cancel}
200
- /* THE scrim (overlay-scrim-outliers sweep, 2026-09-03): the docs said Modal
201
- wore `.kol-overlay-scrim`; the source drew a raw `rgba(0,0,0,0.5)`. The
202
- z stays above the drawers it can open from. */
203
- className="kol-overlay-scrim"
202
+ /* the theme's dim (`--kol-modal-dim`); the z stays above the drawers it can open from */
203
+ className="kol-popover-layer-dim"
204
204
  style={{
205
205
  position: contained ? 'absolute' : 'fixed', inset: 0, zIndex: 1000,
206
206
  display: 'flex', alignItems: 'center', justifyContent: 'center',
207
207
  }}
208
208
  >
209
- <ModalShell
209
+ <PanelShell
210
210
  ref={dialogRef}
211
- variant={look}
212
211
  role={typing ? 'dialog' : 'alertdialog'}
213
212
  aria-modal="true"
214
- aria-labelledby="kol-modal-title"
213
+ aria-label={typeof state.title === 'string' ? state.title : undefined}
214
+ title={long ? undefined : state.title}
215
+ onClose={cancel}
215
216
  onMouseDown={(e) => e.stopPropagation()}
216
- className="gap-4 p-5"
217
- style={{
218
- minWidth: 320,
219
- maxWidth: contained ? '90%' : '90vw',
220
- }}
221
- footer={
222
- <div className="flex gap-2 justify-end">
223
- {state.kind !== 'alert' && <Button size="sm" onClick={cancel}>{state.cancelLabel ?? 'Cancel'}</Button>}
224
- {/* inverted, not primary: since tone-is-the-ground-axis (2026-09-03) primary is the
225
- * dark ground, so OK drew the same as Cancel and nothing showed what Enter does */}
226
- <Button tone="inverted" size="sm" onClick={submit} data-modal-ok>{state.okLabel ?? 'OK'}</Button>
227
- </div>
228
- }
217
+ style={{ width: 'var(--kol-modal-prompt-w)', minWidth: 320, maxWidth: contained ? '90%' : '90vw' }}
218
+ footer={(
219
+ <>
220
+ {state.kind !== 'alert' && <Button tone="ghost" size="sm" onClick={cancel}>{state.cancelLabel ?? 'Cancel'}</Button>}
221
+ <Button tone="inverted" size="sm" onClick={submit} data-modal-ok>{state.okLabel ?? 'OK'}</Button>
222
+ </>
223
+ )}
229
224
  >
230
- {/* kol-mono-12, not helper: dialog copy WRAPS, and helper's
231
- * line-height 1 is single-line chrome only (type protocol). */}
232
225
  {/* pre-line: an alert can carry a failure list, one per line */}
233
- <p id="kol-modal-title" className="kol-mono-12 text-emphasis whitespace-pre-line">{state.title}</p>
226
+ {long && <p className="kol-panel-shell-title whitespace-pre-line px-4 pb-2">{state.title}</p>}
227
+ {state.body && <p className="kol-panel-shell-body whitespace-pre-line px-4 pb-4" data-modal-confirm>{state.body}</p>}
234
228
  {state.kind === 'prompt' && (
235
- <Input
236
- ref={inputRef}
237
- type={state.type}
238
- autoComplete={state.type === 'password' ? 'current-password' : undefined}
239
- placeholder={state.placeholder}
240
- variant="outline"
241
- size="sm"
242
- value={val}
243
- onChange={(e) => setVal(e.target.value)}
244
- className="w-full"
245
- />
229
+ <div className="px-4 pb-4" data-modal-prompt>
230
+ <Input
231
+ variant="kolbox"
232
+ ref={inputRef}
233
+ type={state.type}
234
+ autoComplete={state.type === 'password' ? 'current-password' : undefined}
235
+ aria-label={typeof state.title === 'string' ? state.title : undefined}
236
+ placeholder={state.placeholder}
237
+ value={val}
238
+ onChange={(e) => setVal(e.target.value)}
239
+ />
240
+ </div>
241
+ )}
242
+ {state.kind === 'form' && (
243
+ <div className="flex flex-col gap-2 px-4 pb-4" data-modal-prompt>
244
+ {state.fields.map((f, i) => (
245
+ <Input
246
+ key={f.id}
247
+ variant="kolbox"
248
+ ref={i === 0 ? inputRef : undefined}
249
+ type={f.type ?? 'text'}
250
+ autoComplete={f.autoComplete}
251
+ placeholder={f.placeholder}
252
+ aria-label={f.placeholder ?? f.id}
253
+ value={fieldVals[f.id]}
254
+ onChange={(e) => setFieldVals((v) => ({ ...v, [f.id]: e.target.value }))}
255
+ />
256
+ ))}
257
+ </div>
246
258
  )}
247
- {state.kind === 'form' && state.fields.map((f, i) => (
248
- <Input
249
- key={f.id}
250
- ref={i === 0 ? inputRef : undefined}
251
- type={f.type ?? 'text'}
252
- autoComplete={f.autoComplete}
253
- placeholder={f.placeholder}
254
- aria-label={f.placeholder ?? f.id}
255
- variant="outline"
256
- size="sm"
257
- value={fieldVals[f.id]}
258
- onChange={(e) => setFieldVals((v) => ({ ...v, [f.id]: e.target.value }))}
259
- className="w-full"
260
- />
261
- ))}
262
259
  {state.options && (
263
- <div className="flex flex-col gap-3">
260
+ <div className="flex flex-col gap-3 px-4 pb-4">
264
261
  {state.options.map((o) => (
265
262
  <ToggleCheckbox
266
263
  key={o.id}
@@ -272,96 +269,11 @@ function ModalView({ state, closeWith, variant, contained }) {
272
269
  ))}
273
270
  </div>
274
271
  )}
275
- </ModalShell>
272
+ </PanelShell>
276
273
  </div>
277
274
  )
278
275
  }
279
276
 
280
-
281
- /* ── the kolbox look (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18) ──
282
- * `ModalProvider variant="kolbox"`: every prompt, confirm and alert is kolbox's ModalPrompt or ModalConfirm, carried line
283
- * for line, in `ModalDialog variant="kolbox"`. The calls are useModal's, KOL's words: `confirm(title, { okLabel,
284
- * cancelLabel, body })`, `alert(title, { okLabel, body })` (the action alone), `prompt(title, defaultValue, { okLabel,
285
- * cancelLabel, placeholder })`. The confirm: the title as its heading, `body` under it, the cancel (ghost) and the action
286
- * (primary); Enter confirms unless a button has the focus (it answers for itself); Escape and the dim cancel. The prompt:
287
- * one Input with the value selected; Enter submits. The provider draws its two dialogs in place (they portal
288
- * themselves); `container` and a per-call `variant` are not read in this look. */
289
- function ModalConfirmKolbox({ open, title, message, action = 'OK', cancel = 'Cancel', onConfirm, onCancel }) {
290
- const ok = useRef(onConfirm); ok.current = onConfirm
291
- /* Enter arms on its key down and confirms on its key up (PromptEnterReopensItsOpener), so the opener that takes the
292
- focus back never hears the press */
293
- useEffect(() => {
294
- if (!open) return
295
- let armed = false
296
- const onKey = (e) => {
297
- if (e.key !== 'Enter' || e.target?.closest?.('button')) return
298
- e.preventDefault()
299
- if (!e.repeat) armed = true
300
- }
301
- const onUp = (e) => { if (e.key === 'Enter' && armed) { armed = false; ok.current?.() } }
302
- document.addEventListener('keydown', onKey)
303
- document.addEventListener('keyup', onUp)
304
- return () => { document.removeEventListener('keydown', onKey); document.removeEventListener('keyup', onUp) }
305
- }, [open])
306
- return (
307
- <ModalDialogKolbox
308
- open={open}
309
- onClose={onCancel}
310
- title={title}
311
- footer={(
312
- <>
313
- {cancel != null && <Button variant="kolbox" tone="ghost" onClick={onCancel}>{cancel}</Button>}
314
- <Button variant="kolbox" tone="primary" onClick={onConfirm} data-modal-ok>{action}</Button>
315
- </>
316
- )}
317
- >
318
- {message && <p className="kol-modal-body--kolbox px-4 pb-4" data-modal-confirm>{message}</p>}
319
- </ModalDialogKolbox>
320
- )
321
- }
322
-
323
- function ModalPromptKolbox({ open, title, label, value = '', placeholder, action = 'OK', cancel = 'Cancel', onSubmit, onCancel }) {
324
- const [draft, setDraft] = useState(value)
325
- const field = useRef(null)
326
- /* Enter arms on its key down in the field and submits on its key up (PromptEnterReopensItsOpener) */
327
- const armed = useRef(false)
328
- /* after the dialog has moved the focus into its shell, the field takes it with the value selected */
329
- useEffect(() => { if (open) { setDraft(value ?? ''); setTimeout(() => field.current?.select(), 0) } }, [open]) // eslint-disable-line react-hooks/exhaustive-deps
330
- return (
331
- <ModalDialogKolbox
332
- open={open}
333
- onClose={onCancel}
334
- title={title}
335
- footer={(
336
- <>
337
- <Button variant="kolbox" tone="ghost" onClick={onCancel}>{cancel}</Button>
338
- <Button variant="kolbox" tone="primary" onClick={() => onSubmit?.(draft)} data-modal-ok>{action}</Button>
339
- </>
340
- )}
341
- >
342
- <div className="px-4 pb-4" data-modal-prompt>
343
- <Input variant="kolbox" ref={field} aria-label={label ?? title} placeholder={placeholder} value={draft} onChange={(e) => setDraft(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); if (!e.repeat) armed.current = true } }} onKeyUp={(e) => { if (e.key === 'Enter' && armed.current) { armed.current = false; onSubmit?.(draft) } }} />
344
- </div>
345
- </ModalDialogKolbox>
346
- )
347
- }
348
-
349
- function ModalViewKolbox({ state, closeWith }) {
350
- const s = state ?? {}
351
- const confirming = s.kind === 'confirm' || s.kind === 'alert'
352
- const answer = (ok) => (s.options ? { ok, values: Object.fromEntries(s.options.map((o) => [o.id, !!o.defaultValue])) } : ok)
353
- return (
354
- <>
355
- <ModalPromptKolbox open={s.kind === 'prompt'} title={s.title} value={s.defaultValue} placeholder={s.placeholder}
356
- action={s.okLabel} cancel={s.cancelLabel} onSubmit={(v) => closeWith(v)} onCancel={() => closeWith(null)} />
357
- <ModalConfirmKolbox open={confirming} title={s.title} message={s.body} action={s.okLabel}
358
- cancel={s.kind === 'alert' ? null : s.cancelLabel}
359
- onConfirm={() => closeWith(s.kind === 'alert' ? undefined : answer(true))}
360
- onCancel={() => closeWith(s.kind === 'alert' ? undefined : answer(false))} />
361
- </>
362
- )
363
- }
364
-
365
277
  /* Warn once, not per call — the fallback swallowing a missing ModalProvider
366
278
  * silently is how kol-fxr ran months on native window.confirm without
367
279
  * noticing (ModalConfirmLabels, 2026-08-12). */
@@ -395,17 +307,21 @@ export function useModal() {
395
307
 
396
308
  /**
397
309
  * ModalDialog (was `Dialog`, renamed 2026-11-12; `Dialog` stays a deprecated alias) — Modal's shell holding any content (MetricDashboardUpstream, kol-website 2026-10-31 — metric's filter and
398
- * segment dialogs). The same `.kol-overlay-scrim` + `.kol-modal` surface as the prompts above, with `children` in place
399
- * of a prompt — both draw their panel through `ModalShell` (W2.1, 2026-11-08). **z 150, not Modal's 1000**, so KOL's portalled floats (z 210+) open ABOVE it — a Dropdown or Combobox
400
- * inside a dialog has to show its list (a native `<dialog>` cannot: `showModal()` puts it in the top layer, over every
401
- * portal). Esc and a press on the scrim close it; Esc is left to an open float inside first.
310
+ * segment dialogs). ONE WINDOW (plan-2026-11-29-one-set-fold 1.3): kolbox's Modal for everyone — `PanelShell` centred
311
+ * in `PopoverLayer` on the theme's dim: its header holds the `title` and the close, then `children`, then `footer` (a
312
+ * row of buttons). `width` any CSS length or a number of px (unset: the theme's `--kol-modal-w`). The stacking is the
313
+ * theme's (`--kol-modal-z`, 150 by default so KOL's portalled floats, z 300+, open ABOVE it — a Dropdown or Combobox
314
+ * inside a dialog has to show its list; a native `<dialog>` cannot). Escape (the last layer's, left to an open float
315
+ * first) and a click on the dim close it. Focus moves into the dialog on open and back to whatever held it on close. The
316
+ * shell's `title`, `leading`, `actions`, `footer` and `aria-label` pass through; `className` reaches the dialog.
402
317
  *
403
318
  * <ModalDialog open={open} onClose={() => setOpen(false)} title="Filter by page" width={560}>…</ModalDialog>
404
319
  *
405
- * `blocking` (default true) keeps the scrim: a blocking task dims the scene, a utility window does not —
406
- * `blocking={false}` drops the scrim and the press-outside close and leaves the scene live.
407
- * @param {'lift'|'bordered'|'kolbox'|'folio'} [variant='lift'] `kolbox` (W31.2 batch 4): kolbox's Modal, see `ModalDialogKolbox`;
408
- * `folio` (Folio migration batch B): Folio's dialog, `title`, `width` (720), `children`, see `ModalDialogFolio`
320
+ * `blocking` (default true) keeps the dim: a blocking task dims the scene, a utility window does not —
321
+ * `blocking={false}`: no dim, a press, scroll or pinch outside reaches what is under it and never closes it.
322
+ * @param {'settings'} [variant] `settings` is the generator's settings window, below. `lift`, `bordered`, `kolbox` and
323
+ * `folio` are accepted and do nothing (2026-11-29): the look is the theme's; the folio dialog and its own dim went to
324
+ * `_tmp/2026-11-29-one-set-fold/`.
409
325
  * @param {boolean} [blocking=true]
410
326
  * @param {Element} [container] the portal target instead of `<body>` (float-operational W2, 2026-11-04): the layer turns
411
327
  * `absolute` and fills it — a specimen box (`position: relative`, a height) shows the window open in place. Unset, unchanged.
@@ -426,22 +342,16 @@ export function useModal() {
426
342
  * @param {string} [section] · @param {Function} [onSection]
427
343
  * @param {ReactNode} [aside] · @param {ReactNode} [footer] · @param {number} [height=656]
428
344
  * @param {string} [sectionsLabel='Settings'] settings: the section list's title (the generator calls its list Steps, W23.3)
429
- * @param {string} [movable] settings · kolbox: a key; the window drags by its header (see `useMovable`)
430
- * @param {{x?: number, right?: number, y: number}} [place] kolbox: where the window opens until it is moved, in place of centred: its top at `y`, its left at `x` or its right edge at `right`; kept whole on screen
345
+ * @param {string} [movable] a key; the window drags by its header (see `useMovable`)
346
+ * @param {{x?: number, right?: number, y: number}} [place] where the window opens until it is moved, in place of centred: its top at `y`, its left at `x` or its right edge at `right`; kept whole on screen
431
347
  */
432
- /* `variant="kolbox"` (W31.2 batch 4): kolbox's Modal carried line for line: the kolbox panel shell (`ModalShell
433
- * variant="kolbox"`) centred on the dim (fg-ab-24), 480 wide (`--kol-kolbox-modal-w`) unless `width` (any CSS length)
434
- * says otherwise. Escape (the last layer's) and a click on the dim close it. `blocking={false}`: a window over a live
435
- * scene, no dim; a press, scroll or pinch outside it reaches what is under it and never closes it. Focus moves into the dialog on open and back
436
- * to whatever held it on close. The shell's `title`, `leading`, `actions`, `footer` and `aria-label` pass through;
437
- * `className` reaches the dialog beside its own. */
438
348
  /* A WINDOW THAT MOVES (plan-2026-11-18-kolbox-system W23.1, 2026-11-18; his "still cant grab this modal to move it out
439
349
  * of the way"): `movable` (a key, e.g. "generator") lets a press on the window's header, outside its controls, drag it.
440
350
  * It can be moved out of the way, never lost: its header stays on screen top to bottom, its left edge (the title,
441
351
  * where it is grabbed) stays on screen, and it may hang off the right edge until 160 px of it are left, so it can
442
352
  * always be grabbed back. Once moved it is fixed at its own left and top, so a
443
- * change of content never re-centres it, and its place is kept per key while the app is open. Only the kolbox and
444
- * settings variants take it; unset, nothing changes. */
353
+ * change of content never re-centres it, and its place is kept per key while the app is open. The window and the
354
+ * settings variant take it; unset, nothing changes. */
445
355
  const SPOTS = new Map()
446
356
  const NO_DRAG = 'button, input, select, textarea, a, [role="button"], [role="combobox"], [role="tab"], [role="switch"], [contenteditable="true"], [data-no-drag]'
447
357
  const KEEP = 160
@@ -498,9 +408,9 @@ function useMovable(key, ref, place) {
498
408
  }
499
409
  }
500
410
 
501
- function ModalDialogKolbox({ open, onClose, width = 'var(--kol-kolbox-modal-w)', className = '', variant, movable, blocking = true, place, ...shell }) {
411
+ function ModalWindow({ open, onClose, width = 'var(--kol-modal-w)', className = '', variant, movable, blocking = true, place, container, ...shell }) { // eslint-disable-line no-unused-vars
502
412
  const ref = useRef(null)
503
- const mv = useMovable(movable, ref, place)
413
+ const mv = useMovable(container ? undefined : movable, ref, place)
504
414
  useEffect(() => {
505
415
  if (!open) return
506
416
  const back = document.activeElement
@@ -509,48 +419,21 @@ function ModalDialogKolbox({ open, onClose, width = 'var(--kol-kolbox-modal-w)',
509
419
  }, [open])
510
420
  const close = () => { if (!mv.dragged()) onClose?.() }
511
421
  return (
512
- <PopoverLayer open={open} onClose={close} placement="center" kind="modal" blocking={blocking}>
513
- <KolboxShell ref={ref} tabIndex={-1} aria-modal={blocking ? 'true' : undefined} onClose={onClose} width={width} className={`outline-none ${mv.handle} ${className}`}
422
+ <PopoverLayer open={open} onClose={close} placement="center" kind="modal" blocking={blocking} container={container}>
423
+ <PanelShell ref={ref} tabIndex={-1} aria-modal={blocking ? 'true' : undefined} onClose={onClose} width={width} className={`outline-none ${mv.handle} ${className}`}
514
424
  {...shell} style={mv.style ? { width, ...mv.style } : { width }} onPointerDown={mv.onPointerDown} />
515
425
  </PopoverLayer>
516
426
  )
517
427
  }
518
428
 
519
- /* `variant="folio"` (Folio migration batch B, 2026-11-22): Folio's New overlay carried class for class (kol-theme
520
- * `.kol-modal-dialog--folio`): `ModalShell variant="folio"` 14% down on the Folio dim, `width` wide (720) and never wider
521
- * than the window, a 64 header (the title, the 32 ×) over a rule, then `children`. Drawn in place, never portalled, so
522
- * it keeps the frame's `data-folio-*`. Escape and a press on the dim close it. */
523
- function ModalDialogFolio({ open, onClose, title, width = 720, children }) {
524
- useEffect(() => {
525
- if (!open) return undefined
526
- const esc = (e) => e.key === 'Escape' && onClose?.()
527
- addEventListener('keydown', esc)
528
- return () => removeEventListener('keydown', esc)
529
- }, [open, onClose])
530
- if (!open) return null
531
- return (
532
- <div className="kol-modal-dim--folio fixed inset-0 z-50 flex items-start justify-center px-[16px] pt-[14vh]" onMouseDown={onClose}>
533
- <ModalShell variant="folio" role="dialog" aria-label={title} onMouseDown={(e) => e.stopPropagation()} className="kol-modal-dialog--folio max-w-full" style={{ width }}>
534
- <div className="kol-modal-head--folio flex h-[64px] items-center justify-between border-b pl-[24px] pr-[16px]">
535
- <p className="kol-modal-title--folio">{title}</p>
536
- <button type="button" aria-label="Close" onClick={onClose} className="kol-modal-close--folio flex size-[32px] items-center justify-center rounded-[3px]"><IconLoader name="x" size={14} /></button>
537
- </div>
538
- {children}
539
- </ModalShell>
540
- </div>
541
- )
542
- }
543
-
544
429
  export function ModalDialog(props) {
545
- if (props.variant === 'kolbox') return <ModalDialogKolbox {...props} />
546
- if (props.variant === 'folio') return <ModalDialogFolio {...props} />
547
- return <ModalDialogOn {...props} />
430
+ if (props.variant === 'settings') return <ModalDialogSettings {...props} />
431
+ return <ModalWindow {...props} />
548
432
  }
549
433
 
550
- function ModalDialogOn({ open, onClose, title, width, variant = 'lift', blocking = true, container, kind, headerEnd, sections, section, onSection, aside, footer, height = 656, movable, sectionsLabel = 'Settings', children }) {
551
- const look = variant === 'settings' ? 'settings' : modalVariant(variant, 'lift')
434
+ function ModalDialogSettings({ open, onClose, title, width, blocking = true, container, kind, headerEnd, sections, section, onSection, aside, footer, height = 656, movable, sectionsLabel = 'Settings', children }) {
552
435
  const shellRef = useRef(null)
553
- const mv = useMovable(variant === 'settings' && !container ? movable : undefined, shellRef)
436
+ const mv = useMovable(container ? undefined : movable, shellRef)
554
437
  useEffect(() => {
555
438
  if (!open) return undefined
556
439
  const onKey = (e) => { if (e.key === 'Escape' && !document.querySelector('.kol-popover-float, [data-state="open"].kol-dd-trigger')) onClose() }
@@ -558,75 +441,49 @@ function ModalDialogOn({ open, onClose, title, width, variant = 'lift', blocking
558
441
  return () => window.removeEventListener('keydown', onKey)
559
442
  }, [open, onClose])
560
443
  if (!open || typeof document === 'undefined') return null
561
- if (variant === 'settings') {
562
- const within = container ? '100%' : '100vw'
563
- const withinH = container ? '100%' : '100dvh'
564
- return createPortal(
565
- <div onMouseDown={blocking ? onClose : undefined} className={blocking ? 'kol-overlay-scrim' : 'pointer-events-none'}
566
- style={{ position: container ? 'absolute' : 'fixed', inset: 0, zIndex: 150, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
567
- <ModalShell ref={shellRef} variant="settings" role="dialog" aria-modal={blocking ? 'true' : undefined} aria-label={title} data-dialog onMouseDown={(e) => e.stopPropagation()}
568
- onPointerDown={mv.onPointerDown}
569
- className={`kol-settings-window pointer-events-auto overflow-hidden ${mv.handle}`.trim()}
570
- style={{ width: `min(${width ?? 880}px, calc(${within} - 32px))`, height: `min(${height}px, calc(${withinH} - 32px))`, ...mv.style }}
571
- header={<Header variant="settings" title={title} kind={kind} end={headerEnd} onClose={onClose} />}
572
- footer={footer && <footer className="flex items-center gap-3 h-[60px] shrink-0 px-6 border-t border-oq-16">{footer}</footer>}>
573
- <div className="flex flex-1 min-h-0">
574
- {sections?.length > 0 && (
575
- <nav aria-label={sectionsLabel} className="w-[156px] shrink-0 overflow-y-auto bg-surface-primary border-r border-oq-16 px-2 pt-[21px] pb-4">
576
- <p className="pl-[10px] pb-[14px] text-[9px] font-medium leading-[11px] uppercase text-oq-64">{sectionsLabel}</p>
577
- <div role="tablist" aria-orientation="vertical" className="flex flex-col gap-1.5"
578
- onKeyDown={(e) => {
579
- const dir = { ArrowDown: 1, ArrowUp: -1 }[e.key]
580
- if (!dir) return
581
- e.preventDefault()
582
- const at = sections.findIndex((s) => s.key === section)
583
- const next = sections[(at + dir + sections.length) % sections.length]
584
- onSection?.(next.key)
585
- e.currentTarget.querySelector(`[data-section="${next.key}"]`)?.focus()
586
- }}>
587
- {sections.map((s) => {
588
- const lit = s.key === section
589
- return (
590
- <button key={s.key} type="button" role="tab" aria-selected={lit} data-section={s.key} tabIndex={lit ? 0 : -1}
591
- onClick={() => onSection?.(s.key)}
592
- className={`relative h-[45px] shrink-0 flex flex-col items-start justify-center gap-[5px] px-3 rounded-md text-left focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)] ${lit ? 'bg-fg-12' : 'hover:bg-fg-04'}`}>
593
- {lit && <span aria-hidden="true" className="absolute left-0 top-[13px] h-[18px] w-0.5 rounded-[1px] bg-fg-96" />}
594
- <span className={`text-[11px] leading-[13px] text-fg-96 ${lit ? 'font-medium' : ''}`}>{s.label}</span>
595
- {s.state != null && <span className="text-[10px] leading-[12px] text-oq-64">{s.state}</span>}
596
- </button>
597
- )
598
- })}
599
- </div>
600
- </nav>
601
- )}
602
- <div className="flex-1 min-w-0 overflow-y-auto pl-6 pr-5 pt-6 pb-6">{children}</div>
603
- {aside && <aside className="w-[248px] shrink-0 mr-6 pt-6 pb-6 overflow-y-auto">{aside}</aside>}
604
- </div>
605
- </ModalShell>
606
- </div>,
607
- container ?? document.body,
608
- )
609
- }
444
+ const within = container ? '100%' : '100vw'
445
+ const withinH = container ? '100%' : '100dvh'
610
446
  return createPortal(
611
- <div
612
- onMouseDown={blocking ? onClose : undefined}
613
- className={blocking ? 'kol-overlay-scrim' : 'pointer-events-none'}
614
- style={{ position: container ? 'absolute' : 'fixed', inset: 0, zIndex: 150, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
615
- >
616
- <ModalShell
617
- variant={look}
618
- role="dialog"
619
- aria-modal={blocking ? 'true' : undefined}
620
- aria-label={title}
621
- data-dialog
622
- onMouseDown={(e) => e.stopPropagation()}
623
- /* THE OVERLAY PANEL (MetricRebuild, 2026-10-31 — user: the filter dialog read as "a borderless box floating
624
- * mid-page"): it painted the page's own surface behind an fg-08 hairline, so on a dark page it was the page.
625
- * `.kol-overlay-panel` is the lift every KOL overlay wears (oq-04, no border — the scrim is the edge). */
626
- className={`${container ? 'max-h-[85%]' : 'max-h-[85vh]'}${blocking ? '' : ' pointer-events-auto'}`}
627
- style={{ width: `min(${width != null ? `${width}px` : '560px'}, calc(${container ? '100%' : '100vw'} - 32px))` }}
628
- >
629
- {children}
447
+ <div onMouseDown={blocking ? onClose : undefined} className={blocking ? 'kol-overlay-scrim' : 'pointer-events-none'}
448
+ style={{ position: container ? 'absolute' : 'fixed', inset: 0, zIndex: 150, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
449
+ <ModalShell ref={shellRef} variant="settings" role="dialog" aria-modal={blocking ? 'true' : undefined} aria-label={title} data-dialog onMouseDown={(e) => e.stopPropagation()}
450
+ onPointerDown={mv.onPointerDown}
451
+ className={`kol-settings-window pointer-events-auto overflow-hidden ${mv.handle}`.trim()}
452
+ style={{ width: `min(${width ?? 880}px, calc(${within} - 32px))`, height: `min(${height}px, calc(${withinH} - 32px))`, ...mv.style }}
453
+ header={<Header variant="settings" title={title} kind={kind} end={headerEnd} onClose={onClose} />}
454
+ footer={footer && <footer className="flex items-center gap-3 h-[60px] shrink-0 px-6 border-t border-oq-16">{footer}</footer>}>
455
+ <div className="flex flex-1 min-h-0">
456
+ {sections?.length > 0 && (
457
+ <nav aria-label={sectionsLabel} className="w-[156px] shrink-0 overflow-y-auto bg-surface-primary border-r border-oq-16 px-2 pt-[21px] pb-4">
458
+ <p className="pl-[10px] pb-[14px] text-[9px] font-medium leading-[11px] uppercase text-oq-64">{sectionsLabel}</p>
459
+ <div role="tablist" aria-orientation="vertical" className="flex flex-col gap-1.5"
460
+ onKeyDown={(e) => {
461
+ const dir = { ArrowDown: 1, ArrowUp: -1 }[e.key]
462
+ if (!dir) return
463
+ e.preventDefault()
464
+ const at = sections.findIndex((s) => s.key === section)
465
+ const next = sections[(at + dir + sections.length) % sections.length]
466
+ onSection?.(next.key)
467
+ e.currentTarget.querySelector(`[data-section="${next.key}"]`)?.focus()
468
+ }}>
469
+ {sections.map((s) => {
470
+ const lit = s.key === section
471
+ return (
472
+ <button key={s.key} type="button" role="tab" aria-selected={lit} data-section={s.key} tabIndex={lit ? 0 : -1}
473
+ onClick={() => onSection?.(s.key)}
474
+ className={`relative h-[45px] shrink-0 flex flex-col items-start justify-center gap-[5px] px-3 rounded-md text-left focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)] ${lit ? 'bg-fg-12' : 'hover:bg-fg-04'}`}>
475
+ {lit && <span aria-hidden="true" className="absolute left-0 top-[13px] h-[18px] w-0.5 rounded-[1px] bg-fg-96" />}
476
+ <span className={`text-[11px] leading-[13px] text-fg-96 ${lit ? 'font-medium' : ''}`}>{s.label}</span>
477
+ {s.state != null && <span className="text-[10px] leading-[12px] text-oq-64">{s.state}</span>}
478
+ </button>
479
+ )
480
+ })}
481
+ </div>
482
+ </nav>
483
+ )}
484
+ <div className="flex-1 min-w-0 overflow-y-auto pl-6 pr-5 pt-6 pb-6">{children}</div>
485
+ {aside && <aside className="w-[248px] shrink-0 mr-6 pt-6 pb-6 overflow-y-auto">{aside}</aside>}
486
+ </div>
630
487
  </ModalShell>
631
488
  </div>,
632
489
  container ?? document.body,
@@ -1,5 +1,5 @@
1
1
  import { forwardRef } from 'react'
2
- import { KolboxShell } from '../utilities/Popover.jsx'
2
+ import { PanelShell } from '../utilities/Popover.jsx'
3
3
 
4
4
  /* taxonomy-ok: molecule — the modal family's panel: the surface every modal, dialog and sheet window draws its parts on */
5
5
 
@@ -17,15 +17,14 @@ import { KolboxShell } from '../utilities/Popover.jsx'
17
17
  * ONE RADIUS: `--kol-radius-4` (4px) — the radius Modal's prompts and Dialog wore. The generator settings window keeps
18
18
  * its 20 (`settings`, no outer border — his mock 143:35343, plan-2026-11-12-one-header W8.1).
19
19
  *
20
- * @param {'lift'|'bordered'|'settings'|'kolbox'|'folio'} [variant='lift']
20
+ * THE WINDOW (plan-2026-11-29-one-set-fold 1.3): given the shell's own parts — `title`, `leading`, `actions`, `onClose`
21
+ * or `width` — it is `PanelShell`, the one panel shell (its header, a scrolling body, `footer` as a row of buttons), its
22
+ * look the theme's. Was `variant="kolbox"`.
23
+ *
24
+ * @param {'lift'|'bordered'|'settings'} [variant='lift']
21
25
  * `lift` — the overlay panel every KOL overlay wears (`.kol-overlay-panel`: oq-04, no border, the scrim is the edge);
22
26
  * `bordered` — the page surface behind an fg-08 hairline (Modal's prompts); `settings` — the generator settings window (the secondary surface, radius 20, the float shadow, no border).
23
- * `kolbox` (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18) — kolbox's panel shell (its PopoverShell, carried
24
- * line for line): radius 16, the secondary surface on the one floating surface, 240 wide (`--kol-kolbox-popover-w`)
25
- * unless `width` says; it draws its own header from `leading`, `title`, `actions` and the close (`onClose`), the body,
26
- * and `footer` as a row of buttons; `aria-label` defaults to the title. The panel every kolbox popover and window is.
27
- * `folio` (Folio migration batch B, 2026-11-22) — Folio's overlay panel: `bordered`'s hairline and radius 4 on Folio's
28
- * paper and rule (`.kol-modal--folio`); its ink and shadow are the caller's (the search modal's, the dialog's).
27
+ * `kolbox` and `folio` are accepted and do nothing (2026-11-29): the look is the theme's.
29
28
  * @param {ReactNode} [header] drawn first
30
29
  * @param {ReactNode} [footer] drawn last
31
30
  * @param {string} [className] the caller's layout: padding, gap, size
@@ -35,14 +34,13 @@ import { KolboxShell } from '../utilities/Popover.jsx'
35
34
  const VARIANTS = {
36
35
  lift: { className: 'kol-overlay-panel rounded-[var(--kol-radius-4)]', style: {} },
37
36
  bordered: { className: 'border border-fg-08 rounded-[var(--kol-radius-4)]', style: { background: 'var(--kol-surface-primary)', color: 'var(--kol-surface-on-primary)' } },
38
- folio: { className: 'kol-modal--folio border rounded-[var(--kol-radius-4)]', style: {} },
39
37
  settings: { className: 'rounded-[20px] bg-surface-secondary text-fg-96 font-(family-name:--kol-font-family-float) shadow-[var(--kol-shadow-float)]', style: {} },
40
38
  }
41
39
 
42
40
  const ModalShell = forwardRef(function ModalShell(props, ref) {
43
- if (props.variant === 'kolbox') {
44
- const { variant, ...shell } = props
45
- return <KolboxShell ref={ref} {...shell} />
41
+ if (props.title != null || props.leading || props.actions || props.onClose || props.width != null) {
42
+ const { variant, ...shell } = props // eslint-disable-line no-unused-vars
43
+ return <PanelShell ref={ref} {...shell} />
46
44
  }
47
45
  const { variant = 'lift', header, footer, className = '', style, children, ...rest } = props
48
46
  const look = VARIANTS[variant] ?? VARIANTS.lift
@@ -45,9 +45,9 @@ export default function FindBar({ variant = 'kolbox', query, onQueryChange, repl
45
45
  <button type="button" aria-pressed={matchCase} onClick={() => onMatchCase(!matchCase)} className={`kol-find-bar-case${matchCase ? ' is-on' : ''} h-[28px] rounded-[3px] px-[8px]`}>Aa</button>
46
46
  <span className="kol-find-bar-rule mx-[8px] h-[20px] w-px" />
47
47
  <Input variant="folio" aria-label="Replace with" placeholder="Replace with" value={replacement} onChange={(e) => onReplacementChange(e.target.value)} className="w-[220px]" />
48
- <Button variant="folio" onClick={onReplace}>Replace</Button>
49
- <Button variant="folio" onClick={onReplaceAll}>Replace all</Button>
50
- <Button variant="folio" iconOnly="x" aria-label="Close find" onClick={onClose} className="kol-find-bar-close ml-auto" />
48
+ <Button variant="folio" keepFocus onClick={onReplace}>Replace</Button>
49
+ <Button variant="folio" keepFocus onClick={onReplaceAll}>Replace all</Button>
50
+ <Button variant="folio" keepFocus iconOnly="x" aria-label="Close find" onClick={onClose} className="kol-find-bar-close ml-auto" />
51
51
  </div>
52
52
  )
53
53