@kolkrabbi/kol-component 0.264.0 → 0.266.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.
@@ -0,0 +1,397 @@
1
+ import { useEffect, useId, useRef, useState } from 'react'
2
+ import { Icon } from '@kolkrabbi/kol-icons'
3
+ import SearchInput from '../molecules/SearchInput.jsx'
4
+ import Tag from '../atoms/Tag.jsx'
5
+ import Kbd from '../atoms/Kbd.jsx'
6
+ import OptionRow from '../molecules/OptionRow.jsx'
7
+ import Button from '../atoms/Button.jsx'
8
+ import { Tooltip } from '../utilities/Popover.jsx'
9
+ import { shortcutInScope } from './ShortcutsOverlay.jsx'
10
+
11
+ /* ONE COLUMN (2026-09-30): rows, headings and footer sit on the field's own
12
+ * geometry — the p-2 inset, then the md control's 1px ring + 16px pad — so
13
+ * every glyph and word lines up under the field's icon and caret. */
14
+
15
+ /* Rows bucketed by `group` in first-seen order, rank kept inside a group —
16
+ * one heading per group; arrows rove this order, not the engine's. */
17
+ function groupRows(rows) {
18
+ const order = []
19
+ const byGroup = new Map()
20
+ rows.forEach((r) => {
21
+ const g = r.group ?? ''
22
+ if (!byGroup.has(g)) { byGroup.set(g, []); order.push(g) }
23
+ byGroup.get(g).push(r)
24
+ })
25
+ return order.flatMap((g) => byGroup.get(g))
26
+ }
27
+
28
+ /**
29
+ * HighlightMatch — default row renderer: underlines the first
30
+ * case-insensitive `query` slice inside `label` at full ink. Exported for
31
+ * consumers building their own rows; not in the package barrel.
32
+ *
33
+ * @param {string} label full row label
34
+ * @param {string} query current query (empty / no match → plain label)
35
+ */
36
+ export function HighlightMatch({ label, query, ranges }) {
37
+ /* An engine that already knows where it matched (kol-search's `highlights`)
38
+ * passes `ranges` — every hit, not just the first slice of the raw query. */
39
+ if (Array.isArray(ranges)) {
40
+ if (!ranges.length) return <span>{label}</span>
41
+ const out = []
42
+ let at = 0
43
+ ranges.forEach(([s, e], i) => {
44
+ if (s > at) out.push(<span key={`t${i}`}>{label.slice(at, s)}</span>)
45
+ out.push(<span key={`m${i}`} className="text-fg underline decoration-2 underline-offset-[3px]">{label.slice(s, e)}</span>)
46
+ at = e
47
+ })
48
+ if (at < label.length) out.push(<span key="rest">{label.slice(at)}</span>)
49
+ return <>{out}</>
50
+ }
51
+ const idx = query ? label.toLowerCase().indexOf(query.toLowerCase()) : -1
52
+ if (idx === -1) return <span>{label}</span>
53
+ return (
54
+ <>
55
+ <span>{label.slice(0, idx)}</span>
56
+ <span className="text-fg underline decoration-2 underline-offset-[3px]">
57
+ {label.slice(idx, idx + query.length)}
58
+ </span>
59
+ <span>{label.slice(idx + query.length)}</span>
60
+ </>
61
+ )
62
+ }
63
+
64
+ /* THE MODES (CommandOverlayModes, kol-monitor 2026-10-17 — user: *"can we make the modal more general then just
65
+ * search? … add module would be another, shortcuts could be a third"*). One field, one grouped list, one footer;
66
+ * the mode only sets the footer's words and, for `shortcuts`, where the rows come from. */
67
+ const MODE_LABEL = { search: 'Go to page', go: 'Go to page', add: 'Add', shortcuts: 'Run' }
68
+ const MODE_PLACEHOLDER = { search: 'Search…', go: 'Go to…', add: 'Add…', shortcuts: 'Search shortcuts…' }
69
+
70
+ /* the keymap as rows: every section visible at once, this page's first, the rest muted and never run */
71
+ function shortcutRows(shortcuts, path, query) {
72
+ const q = query.trim().toLowerCase()
73
+ const rows = (sec, here) => (sec.items ?? []).map((it) => ({
74
+ id: `${sec.section}:${it.id ?? it.label}`, label: it.label, hint: it.combo ?? it.keys,
75
+ group: here ? sec.section : `Elsewhere · ${sec.section}`, disabled: !here, run: it.run,
76
+ }))
77
+ const all = [...shortcuts.filter((s) => shortcutInScope(s, path)).flatMap((s) => rows(s, true)),
78
+ ...shortcuts.filter((s) => !shortcutInScope(s, path)).flatMap((s) => rows(s, false))]
79
+ return q ? all.filter((r) => r.label.toLowerCase().includes(q) || String(r.hint ?? '').toLowerCase().includes(q)) : all
80
+ }
81
+
82
+ /**
83
+ * CommandOverlay — The ⌘K overlay: search, add, go, shortcuts. Was `ShellSearchOverlay` (still exported, an
84
+ * alias). `mode` names what the overlay is for — `search` (default) · `go` · `add` · `shortcuts`. In
85
+ * `shortcuts` it draws `shortcuts` (the AppHub keymap) as rows: every section at once, the current page's
86
+ * first, the rest muted under "Elsewhere"; typing filters; Enter runs a row's `run`.
87
+ *
88
+ * ARROWS (2026-10-17 — user: *"arrows up down can focus category and arrows left right can enter and back,
89
+ * along with enter key"*): ↑↓ move through rows; → or Enter opens a category (a `keepOpen` row); ← goes back
90
+ * (`onBack`). ← and → only step in and out while the field is empty — typing, they move the caret.
91
+ *
92
+ * Former ShellSearchOverlay — The ⌘K search modal. the ⌘K search modal: fullscreen dim + centered
93
+ * panel, a bare SearchInput on top, result rows beneath (HighlightMatch
94
+ * label, dim hint line, right-aligned group label). Distinct from Modal
95
+ * (prompt/confirm only) — this is the search/command primitive.
96
+ *
97
+ * Content-agnostic: the consumer filters and passes `results`; selection
98
+ * emits `onSelect(item)` (no navigation here — ported off react-router).
99
+ * The ⌘K binding itself lives in the shell's key handler, not here.
100
+ *
101
+ * Keyboard: ArrowUp/ArrowDown rove the active row (mouse hover roves too),
102
+ * Enter opens it (the top row from the first keystroke), ⌘/Ctrl+Enter opens every hit,
103
+ * Escape closes. Focus trap: focus moves into the input on open, returns to
104
+ * the opener on close, and Tab is pinned — rows are combobox options driven
105
+ * via aria-activedescendant, never tab stops.
106
+ *
107
+ * @param {boolean} open mount/unmount the overlay
108
+ * @param {Function} onClose () => void — backdrop click, Escape, post-select
109
+ * @param {Array} results pre-filtered rows: { id, label, group?, hint?, icon?, disabled?, disabledHint? }
110
+ * @param {Array} [suggestions] rows shown while the query is empty (same shape) —
111
+ * the search modal opens on somewhere to go, not a blank box
112
+ * @param {string} query controlled query (drives the highlight slice)
113
+ * @param {Function} onQueryChange (string) => void — input change
114
+ * @param {Function} onSelect (item) => void — row click / Enter; consumer navigates. A row
115
+ * with `keepOpen` or `action` selects and the modal stays open
116
+ * @param {string} placeholder input placeholder
117
+ * @param {string} [enterLabel] what Enter does when no row is picked — shown as
118
+ * the panel's last line, so Enter is never a surprise
119
+ * (e.g. `All results for “q”`). Rows may carry
120
+ * `highlights` ([start, end] ranges) from the engine.
121
+ * @param {Function} [onOpenResults] (query) => void — ⌘/Ctrl+Enter: every hit, on the consumer's
122
+ * own results surface. Plain Enter keeps its meaning.
123
+ * @param {string} [resultsLabel] the footer's second line for ⌘Enter (e.g. `All results`)
124
+ * @param {Function} [onBack] a drill-in's way back (CommandOverlayModes, kol-monitor 2026-10-17): set, the
125
+ * field row leads with a back arrow, and Backspace on an empty field calls it —
126
+ * instead of a "← All" row that scrolls away with the list
127
+ * @param {string} [backLabel] the arrow's tooltip (default `Back`) — name where it goes ("All modules")
128
+ * @param {string} [selectLabel] the footer's Enter line while a row is highlighted (default
129
+ * `Go to page`) — a modal whose rows are not pages says what
130
+ * Enter does instead (the rack's module search: `Add module`)
131
+ */
132
+ export default function CommandOverlay({
133
+ open,
134
+ onClose,
135
+ results: rawResults = [],
136
+ suggestions = [],
137
+ /* EXPANDED — the search modal's second state (user ruling 2026-08-01). Enter
138
+ * commits the query and opens `children` as the results body; the search modal
139
+ * and the old tag overlay are one surface with two states, not two
140
+ * components. `chips` are the committed tag facets of the same query. */
141
+ expanded = false,
142
+ onExpand,
143
+ chips = [],
144
+ onRemoveChip,
145
+ children,
146
+ query = '',
147
+ onQueryChange,
148
+ onSelect,
149
+ placeholder: placeholderProp,
150
+ enterLabel,
151
+ onOpenResults,
152
+ resultsLabel = 'All results',
153
+ selectLabel: selectLabelProp,
154
+ onBack,
155
+ backLabel = 'Back',
156
+ mode = 'search',
157
+ shortcuts = [],
158
+ currentPath,
159
+ }) {
160
+ const panelRef = useRef(null)
161
+ const listRef = useRef(null)
162
+ const listId = useId()
163
+ const [activeIndex, setActiveIndex] = useState(0)
164
+ /* Has the user actually chosen a row? See the Enter branch — without this,
165
+ * index 0 counts as a selection and Enter navigates somewhere unasked. */
166
+ const [navigated, setNavigated] = useState(false)
167
+ const placeholder = placeholderProp ?? MODE_PLACEHOLDER[mode] ?? 'Search…'
168
+ const selectLabel = selectLabelProp ?? MODE_LABEL[mode] ?? 'Go to page'
169
+ const results = mode === 'shortcuts' ? shortcutRows(shortcuts, currentPath, query) : groupRows(query ? rawResults : suggestions)
170
+ /* a `disabled` row is drawn but never active: ↑↓ step over it, Enter and click never reach
171
+ * `onSelect` (ShellSearchDisabledRow, kol-monitor 2026-10-15 — a module with no room on the rack) */
172
+ const clamped = Math.min(activeIndex, results.length - 1)
173
+ const active = clamped >= 0 && !results[clamped].disabled ? clamped : -1
174
+ const step = (from, dir) => {
175
+ for (let i = from + dir; i >= 0 && i < results.length; i += dir) if (!results[i].disabled) return i
176
+ return from
177
+ }
178
+
179
+ /* Focus in on open, restore the opener on close. querySelector instead of
180
+ * a ref through SearchInput — ref-as-prop needs React 19 and the package
181
+ * peer range still allows 18. */
182
+ useEffect(() => {
183
+ if (!open) return undefined
184
+ const prev = document.activeElement
185
+ panelRef.current?.querySelector('input')?.focus()
186
+ return () => { if (prev instanceof HTMLElement) prev.focus() }
187
+ }, [open])
188
+
189
+ /* Roving row resets to the top on every query change / reopen — and when the ROWS change under an
190
+ * unchanged query (ShellSearchOverlayActionKeepsOpen, kol-fxr 2026-10-13: a drill-in swaps the
191
+ * suggestions for a category's presets). Keyed on the row ids, not the array's identity, so a
192
+ * consumer passing a fresh array every render does not snap the highlight back to the top. */
193
+ const rowsKey = results.map((r) => r.id).join('\u0000')
194
+ useEffect(() => { setActiveIndex(Math.max(0, results.findIndex((r) => !r.disabled))); setNavigated(false) }, [query, open, rowsKey]) // eslint-disable-line react-hooks/exhaustive-deps
195
+
196
+ /* Keep the active row visible inside the scrolling list. */
197
+ useEffect(() => {
198
+ if (active < 0) return
199
+ listRef.current?.querySelectorAll('[role="option"]')[active]?.scrollIntoView({ block: 'nearest' })
200
+ }, [active])
201
+
202
+ if (!open) return null
203
+
204
+ /* A row that KEEPS THE MODAL OPEN — `keepOpen`, or an `action` row (the contract below always said
205
+ * so; until 0.252.0 every pick closed — ShellSearchOverlayActionKeepsOpen, kol-fxr 2026-10-13). It
206
+ * still reaches `onSelect`, and the closure stays the consumer's to run there: the overlay running
207
+ * it too would fire it twice in every shell that already does (workshop's tag rows). */
208
+ const select = (item) => {
209
+ if (item?.disabled) return
210
+ if (mode === 'shortcuts') { onClose?.(); item?.run?.(); onSelect?.(item); return }
211
+ onSelect?.(item)
212
+ if (!(item?.keepOpen || typeof item?.action === 'function')) onClose?.()
213
+ }
214
+
215
+ const optionId = (item) => `${listId}-${item.id}`
216
+
217
+ const handleKeyDown = (e) => {
218
+ if (e.key === 'Backspace' && !query && onBack) {
219
+ e.preventDefault()
220
+ onBack()
221
+ } else if (e.key === 'ArrowLeft' && !query && onBack) {
222
+ e.preventDefault()
223
+ onBack()
224
+ } else if (e.key === 'ArrowRight' && !query && active >= 0 && results[active]?.keepOpen) {
225
+ e.preventDefault()
226
+ select(results[active])
227
+ } else if (e.key === 'Escape') {
228
+ e.preventDefault()
229
+ onClose?.()
230
+ } else if (e.key === 'ArrowDown') {
231
+ e.preventDefault()
232
+ setNavigated(true)
233
+ setActiveIndex((i) => step(Math.min(i, results.length - 1), 1))
234
+ } else if (e.key === 'ArrowUp') {
235
+ e.preventDefault()
236
+ setNavigated(true)
237
+ setActiveIndex((i) => step(Math.min(i, results.length - 1), -1))
238
+ } else if (e.key === 'Enter') {
239
+ e.preventDefault()
240
+ /* ⌘ENTER OPENS EVERY HIT (user 2026-09-30: *"enter would focus searched item, and maybe
241
+ * command enter would open the results page"*) — only where the consumer has a place for them. */
242
+ if ((e.metaKey || e.ctrlKey) && onOpenResults && query) { onOpenResults(query); onClose?.(); return }
243
+ /* ENTER OPENS THE HIGHLIGHTED ROW (user 2026-10-01: *"I think enter should also take you to
244
+ * the atom but something like command enter take you to the index"* — reverses the
245
+ * 2026-08-01 "Enter commits, it only selects once you have arrowed"). The top row is drawn
246
+ * highlighted from the first keystroke, so Enter goes where the highlight says. With no
247
+ * rows there is nothing to open and Enter commits the query. */
248
+ if (active >= 0) select(results[active])
249
+ else onExpand?.()
250
+ } else if (e.key === 'Tab') {
251
+ /* Focus trap — the input is the search modal's only tab stop. */
252
+ e.preventDefault()
253
+ }
254
+ }
255
+
256
+ return (
257
+ <div className="fixed inset-0 flex items-start justify-center pt-[20vh]" style={{ zIndex: 'var(--kol-z-modal, 100)' }}>
258
+ {/* A BUTTON, not a div (OverlayScrimTapDismiss, 2026-09-01): iOS Safari
259
+ * does not bubble tap-clicks from non-interactive elements, so the div's
260
+ * onClick never fired on a phone and the only way out was the close
261
+ * control. A button always fires — and it ends the other half of the
262
+ * defect, an interactive target carrying `aria-hidden`. */}
263
+ <button
264
+ type="button"
265
+ aria-label="Close search"
266
+ className="absolute inset-0 kol-overlay-scrim"
267
+ onClick={onClose}
268
+ />
269
+ <div
270
+ ref={panelRef}
271
+ role="dialog"
272
+ aria-modal="true"
273
+ aria-label="Search"
274
+ className={`kol-overlay-panel mx-4 ${expanded ? 'max-w-[var(--kol-content-panel)]' : 'max-w-lg'}`}
275
+ >
276
+ {/* THE MODE, said out loud (user 2026-08-01: "how do you set search
277
+ * mode? theres no helper, message or mode clearly readble"). Two
278
+ * modes exist — FILTER (tags narrow a set) and FIND (a keyword jumps
279
+ * to a destination) — and the only signal was whether chips happened
280
+ * to be present. The chips ARE the mode, so they get a label. */}
281
+ {chips.length > 0 && (
282
+ <div className="flex flex-wrap items-center gap-1.5 px-4 pt-3">
283
+ <span className="kol-helper-10 text-fg-48 shrink-0">FILTERING BY</span>
284
+ {chips.map((t) => (
285
+ <Tag key={t} onRemove={() => onRemoveChip?.(t)}>{t}</Tag>
286
+ ))}
287
+ </div>
288
+ )}
289
+ {/* A REAL FIELD, inset in the panel (2026-09-30, shadcn's search modal as
290
+ * the aim) — the flush `bare` strip read as a hole, not a control. */}
291
+ <div className="kol-tone-grey p-2 flex items-center gap-2">
292
+ {onBack && (
293
+ <Tooltip label={backLabel}>
294
+ {/* mousedown keeps focus in the field, as the rows do */}
295
+ <Button iconOnly="arrow-left" tone="ghost" size="md" aria-label={backLabel} onMouseDown={(e) => e.preventDefault()} onClick={onBack} />
296
+ </Tooltip>
297
+ )}
298
+ <SearchInput
299
+ className="w-full min-w-0 flex-1"
300
+ value={query}
301
+ onChange={(e) => onQueryChange?.(e.target.value)}
302
+ placeholder={chips.length > 0 ? 'Narrow these results…' : placeholder}
303
+ onKeyDown={handleKeyDown}
304
+ role="combobox"
305
+ aria-expanded={results.length > 0}
306
+ aria-controls={listId}
307
+ aria-activedescendant={active >= 0 ? optionId(results[active]) : undefined}
308
+ />
309
+ </div>
310
+
311
+ {/* WHY THIS IS NOT `molecules/Dropdown` (asked 2026-08-01). Dropdown is
312
+ * a SELECT: a trigger, a `value`, `onChange(value)`, and rows that are
313
+ * options. This is a COMBOBOX — a text query filtering a live list
314
+ * whose rows carry a `group`, a `hint`, and may fire an `action`
315
+ * instead of selecting a value. Same ARIA family, different control.
316
+ * Folding one into the other would mean giving Dropdown a query, a
317
+ * hint slot and an action escape hatch, i.e. building this inside it.
318
+ *
319
+ * THE ROW CONTRACT (was documented nowhere):
320
+ * label the row's text, match-highlighted against the query
321
+ * group section heading the row files under — 'Atoms', 'Documentation', 'Tags'
322
+ * icon optional leading glyph (kol-icons name)
323
+ * hint subtext shown when the LABEL was not what matched
324
+ * href a destination; dismisses the search modal
325
+ * action a closure, run by the consumer's `onSelect`; the search modal STAYS OPEN (tag rows)
326
+ * disabled drawn muted, skipped by ↑↓, never reaches `onSelect`; `disabledHint` replaces
327
+ * `hint` with the reason (a full rack: "no room")
328
+ * keepOpen the row selects and the search modal STAYS OPEN — a drill-in (category →
329
+ * its items, a "← All" row back); the consumer swaps `suggestions`/`results`
330
+ * Built by `buildShellSearchItems` (showcase/src/nav/shell-nav.js). */}
331
+ {expanded ? (
332
+ <div className="border-t border-fg-08 max-h-[70vh] overflow-y-auto">{children}</div>
333
+ ) : results.length > 0 && (
334
+ /* FIXED BODY HEIGHT — the panel holds still while the list narrows. */
335
+ <ul
336
+ ref={listRef}
337
+ id={listId}
338
+ role="listbox"
339
+ className="kol-tone-grey h-80 overflow-y-auto px-2 pb-2"
340
+ >
341
+ {results.map((item, i) => {
342
+ const heading = (item.group ?? '') !== (results[i - 1]?.group ?? '') || i === 0
343
+ return (
344
+ <li key={item.id} role="presentation">
345
+ {heading && item.group && (
346
+ <p className="kol-helper-12 text-fg-48 px-4 border-x border-transparent pt-3 pb-2">{item.group}</p>
347
+ )}
348
+ <OptionRow
349
+ id={optionId(item)}
350
+ role="option"
351
+ aria-selected={i === active}
352
+ aria-disabled={item.disabled || undefined}
353
+ active={i === active}
354
+ disabled={item.disabled}
355
+ icon={item.icon}
356
+ label={<HighlightMatch label={item.label} query={query} ranges={item.highlights} />}
357
+ hint={(item.disabled && item.disabledHint) || item.hint}
358
+ /* preventDefault keeps focus in the input through the click */
359
+ onMouseDown={(e) => e.preventDefault()}
360
+ onClick={() => select(item)}
361
+ onMouseEnter={() => { if (!item.disabled) { setActiveIndex(i); setNavigated(true) } }}
362
+ />
363
+ </li>
364
+ )
365
+ })}
366
+ </ul>
367
+ )}
368
+ {/* THE FOOTER SAYS WHAT ENTER DOES — always, not only once typing. */}
369
+ {!expanded && (results.length > 0 || (query && (enterLabel || onOpenResults))) && (
370
+ <div className="border-t border-fg-08 py-2">
371
+ {/* Enter's line names what Enter does NOW: a row is highlighted → it opens that row;
372
+ * no rows → it commits the query. */}
373
+ {(results.length > 0 || enterLabel) && (
374
+ <p className="flex items-center gap-2 kol-helper-12 text-fg-48 mx-2 px-4 border-x border-transparent">
375
+ <Kbd icon="corner-down-left" />
376
+ {results.length > 0 ? selectLabel : enterLabel}
377
+ </p>
378
+ )}
379
+ {/* THE RESULTS LINE IS A LINK (user 2026-10-01: *"make 'all results...' at the bottom
380
+ * also be a link to the results page"*) — the same door ⌘Enter opens. */}
381
+ {query && onOpenResults && (
382
+ <button
383
+ type="button"
384
+ className="flex items-center gap-2 kol-helper-12 text-fg-48 hover:text-fg-default transition-colors mx-2 px-4 border-x border-transparent pt-1"
385
+ onMouseDown={(e) => e.preventDefault()}
386
+ onClick={() => { onOpenResults(query); onClose?.() }}
387
+ >
388
+ <Kbd icon="command"><Icon name="corner-down-left" size={12} /></Kbd>
389
+ {resultsLabel}
390
+ </button>
391
+ )}
392
+ </div>
393
+ )}
394
+ </div>
395
+ </div>
396
+ )
397
+ }
@@ -0,0 +1,103 @@
1
+ import { useMemo, useState } from 'react'
2
+ import IconPlate from '../atoms/IconPlate.jsx'
3
+ import IconToggle from '../atoms/IconToggle.jsx'
4
+ import Pill from '../atoms/Pill.jsx'
5
+ import SegmentedToggle from '../atoms/SegmentedToggle.jsx'
6
+ import ViewToggle from '../atoms/ViewToggle.jsx'
7
+
8
+ /* taxonomy-ok: organism — a toolbar of atoms over a wall of IconPlate pairs */
9
+
10
+ const SIZES = [24, 48, 96, 128]
11
+ const GROUNDS = [
12
+ { value: 'dark', label: 'Dark ground', icon: 'mode-toggle-01' },
13
+ { value: 'light', label: 'Light ground', icon: 'brightness' },
14
+ ]
15
+ /* states are the consumer's words (monitor: same · redrawn · missing); shown capitalised, in the order
16
+ * they first appear */
17
+ const stateLabel = (s) => s.charAt(0).toUpperCase() + s.slice(1)
18
+ const ACTUAL = 16
19
+
20
+ /* a side is a node or a renderer `(ctx) => node`; ctx is `{ size, ground, guide }` */
21
+ const draw = (side, ctx) => (typeof side === 'function' ? side(ctx) : side)
22
+
23
+ function Side({ name, item, side, size, ground, guide, showActual }) {
24
+ const node = item[side]
25
+ const missing = node == null
26
+ return (
27
+ <span className="inline-flex flex-col items-center gap-2">
28
+ <IconPlate size={size} ground={ground} guide={guide && !missing}>
29
+ {missing ? <span className="kol-mono-10 opacity-60 px-1 text-center break-all">{item.candidate ?? item.label}</span> : draw(node, { size, ground, guide })}
30
+ </IconPlate>
31
+ <span className="flex items-center gap-2">
32
+ {showActual && !missing && <IconPlate size={ACTUAL} ground={ground}>{draw(node, { size: ACTUAL, ground, guide: false })}</IconPlate>}
33
+ <span className="kol-mono-12 text-meta">{name}</span>
34
+ </span>
35
+ </span>
36
+ )
37
+ }
38
+
39
+ /**
40
+ * CompareGrid — Two versions of many things, side by side. Each item is a pair of plates, A beside B, each
41
+ * side named in words, the item's name under the pair (CompareGridDevTab, kol-monitor 2026-10-17 — user:
42
+ * *"why are we inventing the wheel for this every time in multiple repos … the way you diff local vs DS is
43
+ * very confusing, its ill labeled, hard to read"*). The open-questions icon review was the readable one;
44
+ * this is it, for any two renderers.
45
+ *
46
+ * The toolbar is controls, not text: size (24 · 48 · 96 · 128), ground, guide, and a filter by state. A
47
+ * side draws at the chosen size on an `IconPlate`, with its real 16px size beside its name. A missing side
48
+ * is an empty plate carrying the item's name.
49
+ *
50
+ * @param {Array} items `[{ id, label, a, b, state?, candidate? }]` — `a` / `b` a node, or
51
+ * `({ size, ground, guide }) => node` (an Icon sized to `size`); `state` is the consumer's
52
+ * word ('same' · 'redrawn' · 'missing'), a chip and the filter; `candidate` names what an
53
+ * empty side would map to
54
+ * @param {Object} labels `{ a, b }` — what each side IS ("monitor" / "kol-icons", "old" / "new")
55
+ * @param {number} [defaultSize=96]
56
+ * @param {'light'|'dark'} [defaultGround='light']
57
+ * @param {boolean} [defaultGuide=true]
58
+ * @param {boolean} [showActual=true] the 16px real size beside each side's name
59
+ */
60
+ export default function CompareGrid({ items = [], labels = { a: 'A', b: 'B' }, defaultSize = 96, defaultGround = 'light', defaultGuide = true, showActual = true, className = '' }) {
61
+ const [size, setSize] = useState(defaultSize)
62
+ const [ground, setGround] = useState(defaultGround)
63
+ const [guide, setGuide] = useState(defaultGuide)
64
+ const [filter, setFilter] = useState('all')
65
+
66
+ const states = useMemo(() => [...new Set(items.map((i) => i.state).filter(Boolean))], [items])
67
+ const counts = useMemo(() => Object.fromEntries(states.map((s) => [s, items.filter((i) => i.state === s).length])), [items, states])
68
+ const hasStates = states.length > 0
69
+ const shown = filter === 'all' ? items : items.filter((i) => i.state === filter)
70
+
71
+ return (
72
+ <div className={`flex flex-col gap-6 ${className}`.trim()}>
73
+ <div className="flex flex-wrap items-center gap-4">
74
+ <SegmentedToggle ariaLabel="Size" value={size} onChange={setSize} options={SIZES.map((v) => ({ value: v, label: String(v) }))} size="sm" />
75
+ <ViewToggle variant="icon" options={GROUNDS} viewMode={ground} onViewChange={setGround} />
76
+ <IconToggle icon="grid" label="Guide" title="Keyline guide" pressed={guide} onChange={setGuide} size="sm" />
77
+ {hasStates && (
78
+ <SegmentedToggle
79
+ ariaLabel="Show"
80
+ value={filter}
81
+ onChange={setFilter}
82
+ size="sm"
83
+ options={[{ value: 'all', label: `All ${items.length}` }, ...states.map((s) => ({ value: s, label: `${stateLabel(s)} ${counts[s]}` }))]}
84
+ />
85
+ )}
86
+ </div>
87
+ <div className="grid gap-4" style={{ gridTemplateColumns: `repeat(auto-fill, minmax(min(100%, ${2 * size + 52}px), 1fr))` }}>
88
+ {shown.map((item) => (
89
+ <div key={item.id} className="flex flex-col items-center gap-3 rounded border border-fg-08 p-3">
90
+ <div className="flex items-start gap-3">
91
+ <Side name={labels.a} item={item} side="a" size={size} ground={ground} guide={guide} showActual={showActual} />
92
+ <Side name={labels.b} item={item} side="b" size={size} ground={ground} guide={guide} showActual={showActual} />
93
+ </div>
94
+ <span className="flex flex-wrap items-center justify-center gap-2">
95
+ <span className="kol-mono-12 text-emphasis">{item.label}</span>
96
+ {item.state && <Pill size="sm" variant={item.state === 'same' ? 'secondary' : 'primary'}>{stateLabel(item.state)}</Pill>}
97
+ </span>
98
+ </div>
99
+ ))}
100
+ </div>
101
+ </div>
102
+ )
103
+ }
@@ -20,7 +20,7 @@ import RowMenuButton from '../molecules/RowMenuButton.jsx'
20
20
  import ContentRow from '../molecules/ContentRow.jsx'
21
21
  import SortControls from '../molecules/SortControls.jsx'
22
22
  import SearchInput from '../molecules/SearchInput.jsx'
23
- import MobileTabBar, { TABBAR_H } from '../molecules/MobileTabBar.jsx'
23
+ import TabsRow, { TABBAR_H } from '../molecules/TabsRow.jsx'
24
24
  import { filterMedia, rankMedia } from '../utilities/mediaSearch.js'
25
25
  import { useMasthead, mastheadTitleClass } from '../utilities/masthead.js'
26
26
  import { MenuItem, MenuDropdownItem, MenuDropdownDivider } from '../molecules/MenuItem.jsx'
@@ -40,7 +40,7 @@ import ContentFilters from './ContentFilters.jsx'
40
40
  import DocumentEditor from './DocumentEditor.jsx'
41
41
  import { listDrafts, moveDrafts, DRAFTS_EVENT } from '../utilities/localDrafts.js'
42
42
  import { parseFrontmatter } from '@kolkrabbi/kol-markdown'
43
- import ShellSearchOverlay from './ShellSearchOverlay.jsx'
43
+ import CommandOverlay from './CommandOverlay.jsx'
44
44
  import ColumnBrowser, { isFileDrag, Preview as ColumnPreview, SelectionPreview } from './ColumnBrowser.jsx'
45
45
  import SettingsPanel, { SettingsSwitch, SettingsChoice, SettingsMulti, SettingsFooter } from './SettingsPanel.jsx'
46
46
  import SettingsSections from './SettingsSections.jsx'
@@ -2528,7 +2528,7 @@ export function MediaLibraryBrowse({
2528
2528
  </div>
2529
2529
 
2530
2530
  {searchOpen && (
2531
- <ShellSearchOverlay
2531
+ <CommandOverlay
2532
2532
  open
2533
2533
  onClose={() => { setSearchOpen(false); setSearchQuery('') }}
2534
2534
  query={searchQuery}
@@ -2775,7 +2775,7 @@ export function MediaLibraryBrowse({
2775
2775
  {tabs?.length > 0 && (
2776
2776
  <>
2777
2777
  <div className="md:hidden" aria-hidden="true" style={{ height: TABBAR_H }} />
2778
- <MobileTabBar tabs={tabs} value={activeTab} onChange={onTabChange} />
2778
+ <TabsRow look="stacked" placement="phone" tabs={tabs} value={activeTab} onChange={onTabChange} />
2779
2779
  </>
2780
2780
  )}
2781
2781
  </div>
@@ -3205,7 +3205,7 @@ export function MediaLibraryLibrary({
3205
3205
  {tabs?.length > 0 && (
3206
3206
  <>
3207
3207
  <div className="md:hidden" aria-hidden="true" style={{ height: TABBAR_H }} />
3208
- <MobileTabBar tabs={tabs} value={activeTab} onChange={onTabChange} />
3208
+ <TabsRow look="stacked" placement="phone" tabs={tabs} value={activeTab} onChange={onTabChange} />
3209
3209
  </>
3210
3210
  )}
3211
3211
  </div>
@@ -5,7 +5,7 @@ import Button from '../atoms/Button'
5
5
  import SearchInput from '../molecules/SearchInput'
6
6
  import ToggleCheckbox from '../atoms/ToggleCheckbox'
7
7
  import IconFrame from '../atoms/IconFrame'
8
- import ShellDrawer from '../molecules/ShellDrawer'
8
+ import Rail from '../molecules/Rail.jsx'
9
9
  import FieldRow, { StatusChip } from '../molecules/FieldRow'
10
10
  import { Tooltip } from '../utilities/Popover'
11
11
  import Table from './Table'
@@ -308,7 +308,7 @@ export default function RecordManager({
308
308
  {/* detail panel — ShellDrawer owns the slide-over chrome AND the close ×;
309
309
  * this header carries only the record actions (reference: … ▶ save-state
310
310
  * Publish). aria-label defaults follow ShellDrawer's own precedent. */}
311
- <ShellDrawer
311
+ <Rail
312
312
  open={!!active}
313
313
  onClose={() => setActive(null)}
314
314
  side="right"
@@ -357,7 +357,7 @@ export default function RecordManager({
357
357
  ))}
358
358
  </div>
359
359
  )}
360
- </ShellDrawer>
360
+ </Rail>
361
361
 
362
362
  {/* media picker — the EXISTING MediaLibrary organism, modal variant;
363
363
  * client injected, never imported (§3). accept comes from the field. */}
@@ -4,7 +4,7 @@ import Divider from '../atoms/Divider.jsx'
4
4
  import IconFrame from '../atoms/IconFrame.jsx'
5
5
  import LabeledControl from '../molecules/LabeledControl.jsx'
6
6
  import ToggleSwitch from '../atoms/ToggleSwitch.jsx'
7
- import ShellDrawer from '../molecules/ShellDrawer.jsx'
7
+ import Rail from '../molecules/Rail.jsx'
8
8
  import FullscreenOverlay from '../utilities/FullscreenOverlay.jsx'
9
9
  import { Tooltip } from '../utilities/Popover.jsx'
10
10
 
@@ -100,9 +100,9 @@ export default function SettingsPanel({
100
100
  paints `bg-surface-primary`, the same token as the page, so the scrim was
101
101
  the only thing separating them — with it off the panel was invisible and
102
102
  the controls floated in the right third of the screen. */
103
- <ShellDrawer open={open} onClose={onClose} side="right" width={width} header={header} className={className} edge={false} shadow={false}>
103
+ <Rail open={open} onClose={onClose} side="right" width={width} header={header} className={className} edge={false} shadow={false}>
104
104
  <div className="flex flex-col gap-4"><Divider />{body}</div>
105
- </ShellDrawer>
105
+ </Rail>
106
106
  )
107
107
  }
108
108