@kolkrabbi/kol-component 0.378.0 → 0.380.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.
- package/package.json +5 -4
- package/src/atoms/Badge.jsx +1 -5
- package/src/atoms/BezierPathEditor.jsx +1 -1
- package/src/atoms/Button.jsx +88 -12
- package/src/atoms/Figure.jsx +19 -1
- package/src/atoms/FunctionPlot.jsx +1 -1
- package/src/atoms/Input.jsx +107 -7
- package/src/atoms/Kbd.jsx +42 -2
- package/src/atoms/Link.jsx +20 -0
- package/src/atoms/OriginPicker.jsx +9 -5
- package/src/atoms/Pill.jsx +1 -3
- package/src/atoms/ProgressBar.jsx +3 -6
- package/src/atoms/SectionFooter.jsx +22 -0
- package/src/atoms/SectionHeader.jsx +24 -0
- package/src/atoms/SectionLabel.jsx +0 -22
- package/src/atoms/SizeOrDownload.jsx +1 -1
- package/src/atoms/Tag.jsx +4 -7
- package/src/atoms/Textarea.jsx +12 -7
- package/src/atoms/ToggleCheckbox.jsx +25 -5
- package/src/atoms/ToggleSwitch.jsx +41 -7
- package/src/atoms/ViewToggle.jsx +2 -29
- package/src/atoms/XYPad.jsx +25 -0
- package/src/hooks/useDragResize.js +1 -1
- package/src/index.js +26 -4
- package/src/molecules/AccountMenu.jsx +16 -3
- package/src/molecules/AlignmentGrid.jsx +13 -1
- package/src/molecules/ButtonGroup.jsx +78 -15
- package/src/molecules/ButtonSplit.jsx +75 -28
- package/src/molecules/Chip.jsx +26 -0
- package/src/molecules/CodeBlock.jsx +39 -2
- package/src/molecules/ColorInputRow.jsx +125 -4
- package/src/molecules/ColorSwatch.jsx +43 -2
- package/src/molecules/ContentCard.jsx +104 -3
- package/src/molecules/ContentMedia.jsx +1 -1
- package/src/molecules/ContentRow.jsx +4 -32
- package/src/molecules/ContextMenu.jsx +0 -1
- package/src/molecules/DividerLabel.jsx +19 -0
- package/src/molecules/DocsToc.jsx +1 -16
- package/src/molecules/Dropdown.jsx +115 -18
- package/src/molecules/DropdownStepper.jsx +29 -0
- package/src/molecules/EmptyState.jsx +1 -15
- package/src/molecules/FieldPair.jsx +41 -2
- package/src/molecules/Header.jsx +4 -4
- package/src/molecules/IndexRow.jsx +1 -1
- package/src/molecules/InlineAddRow.jsx +2 -2
- package/src/molecules/LabeledControl.jsx +56 -11
- package/src/molecules/LayerRow.jsx +1 -1
- package/src/molecules/LinkAddRow.jsx +5 -7
- package/src/molecules/Menu.jsx +250 -33
- package/src/molecules/MenuFloat.jsx +6 -12
- package/src/molecules/MenuList.jsx +5 -11
- package/src/molecules/Modal.jsx +228 -55
- package/src/molecules/ModalHeader.jsx +12 -20
- package/src/molecules/ModalShell.jsx +20 -10
- package/src/molecules/NoticeBanner.jsx +1 -1
- package/src/molecules/OptionRow.jsx +1 -1
- package/src/molecules/PanelsMenu.jsx +2 -2
- package/src/molecules/ParamBindDot.jsx +29 -2
- package/src/molecules/PasswordInput.jsx +1 -1
- package/src/molecules/QuantityInput.jsx +45 -13
- package/src/molecules/QuickLookFrame.jsx +2 -31
- package/src/molecules/RailHeader.jsx +37 -16
- package/src/molecules/ReadingActions.jsx +2 -2
- package/src/molecules/ReadingNotes.jsx +3 -3
- package/src/molecules/ReadingSettings.jsx +8 -8
- package/src/molecules/SearchInput.jsx +4 -5
- package/src/molecules/SectionText.jsx +56 -10
- package/src/molecules/SettingsControls.jsx +23 -23
- package/src/molecules/Slider.jsx +103 -55
- package/src/molecules/SpecList.jsx +1 -21
- package/src/molecules/SplitToolButton.jsx +4 -6
- package/src/molecules/SwatchControls.jsx +28 -0
- package/src/molecules/SwatchGrid.jsx +39 -0
- package/src/molecules/TabsDocument.jsx +131 -0
- package/src/molecules/TabsRow.jsx +40 -50
- package/src/molecules/TaskRow.jsx +2 -2
- package/src/molecules/Toast.jsx +55 -0
- package/src/molecules/TocRow.jsx +1 -1
- package/src/molecules/TreeRow.jsx +87 -1
- package/src/molecules/WorkspaceSwitcher.jsx +3 -6
- package/src/organisms/AppItemMenuProvider.jsx +2 -2
- package/src/organisms/ColorPickerPopover.jsx +133 -4
- package/src/organisms/ColumnBrowser.jsx +1 -1
- package/src/organisms/CommandOverlay.jsx +362 -87
- package/src/organisms/ContentFilters.jsx +4 -12
- package/src/organisms/FindBar.jsx +70 -0
- package/src/organisms/FramedMediaBand.jsx +2 -2
- package/src/organisms/GalleryCarousel.jsx +1 -1
- package/src/organisms/LogoSystem.jsx +38 -0
- package/src/organisms/LogoTuner.jsx +32 -0
- package/src/organisms/MediaLibrary.jsx +1 -56
- package/src/organisms/MediaLibraryPages.jsx +1 -1
- package/src/organisms/NavRail.jsx +1 -4
- package/src/organisms/Rail.jsx +33 -1
- package/src/organisms/RailSwitcher.jsx +62 -0
- package/src/organisms/ReadingContents.jsx +65 -3
- package/src/organisms/ReadingOverview.jsx +5 -5
- package/src/organisms/ReadingPanel.jsx +1 -1
- package/src/organisms/SectionSplit.jsx +1 -1
- package/src/organisms/SettingsPanel.jsx +64 -41
- package/src/organisms/ShortcutsOverlay.jsx +46 -2
- package/src/organisms/SpectrumControls.jsx +112 -19
- package/src/organisms/StatusBar.jsx +30 -0
- package/src/organisms/Table.jsx +136 -45
- package/src/organisms/TimelineDock.jsx +281 -1
- package/src/organisms/logoBoard.jsx +61 -0
- package/src/utilities/AssetPlaceholder.jsx +1 -1
- package/src/utilities/EditorShell.jsx +42 -1
- package/src/utilities/OverlayGlassPanel.jsx +1 -1
- package/src/utilities/Popover.jsx +299 -5
- package/src/utilities/SelectionOverlay.jsx +60 -31
- package/src/utilities/kolboxGlyph.jsx +10 -0
- package/src/molecules/FloatModuleHeader.jsx +0 -11
- package/src/organisms/NavRailFloat.jsx +0 -139
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { useEffect, useId, useRef, useState } from 'react'
|
|
1
|
+
import { Fragment, useEffect, useId, useRef, useState } from 'react'
|
|
2
|
+
import Input from '../atoms/Input.jsx'
|
|
3
|
+
import Kbd, { KbdKeys } from '../atoms/Kbd.jsx'
|
|
4
|
+
import TreeRow from '../molecules/TreeRow.jsx'
|
|
5
|
+
import OptionRow from '../molecules/OptionRow.jsx'
|
|
6
|
+
import { PopoverLayer } from '../utilities/Popover.jsx'
|
|
2
7
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
8
|
import SearchInput from '../molecules/SearchInput.jsx'
|
|
9
|
+
import ModalShell from '../molecules/ModalShell.jsx'
|
|
4
10
|
import Tag from '../atoms/Tag.jsx'
|
|
5
11
|
import TabsRow from '../molecules/TabsRow.jsx'
|
|
6
|
-
import Button from '../atoms/Button.jsx'
|
|
7
|
-
import { floatSurfaceClass } from '../utilities/tone.js'
|
|
8
|
-
import { floatMotion } from '../utilities/motion.js'
|
|
9
|
-
import useFloatPresence from '../hooks/useFloatPresence.js'
|
|
10
12
|
import { shortcutInScope } from './ShortcutsOverlay.jsx'
|
|
11
13
|
|
|
12
14
|
/* ONE COLUMN (2026-09-30): rows, headings and footer sit on the field's own
|
|
13
15
|
* geometry — the p-2 inset, then the md control's 1px ring + 16px pad — so
|
|
14
16
|
* every glyph and word lines up under the field's icon and caret. */
|
|
15
17
|
|
|
16
|
-
/* the foot's rule runs the card's full width: out through the card's inset, the hints 12 in from the rows' edge */
|
|
17
|
-
const RULE = { margin: '6px calc(-1 * var(--kol-float-inset)) calc(-1 * var(--kol-float-inset))', paddingInline: 'calc(var(--kol-float-inset) + 12px)' }
|
|
18
|
-
|
|
19
18
|
/* Rows bucketed by `group` in first-seen order, rank kept inside a group —
|
|
20
19
|
* one heading per group; arrows rove this order, not the engine's. */
|
|
21
20
|
function groupRows(rows) {
|
|
@@ -154,22 +153,12 @@ function unfold(rows, opened) {
|
|
|
154
153
|
* @param {string} [selectLabel] the footer's Enter line while a row is highlighted (default
|
|
155
154
|
* `Go to page`) — a modal whose rows are not pages says what
|
|
156
155
|
* Enter does instead (the rack's module search: `Add module`)
|
|
157
|
-
* @param {'
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* rows (Inter, `--kol-float-row`, the lit row fg-16, the hint right), eyebrow groups, and
|
|
162
|
-
* the key-hint foot under a full-width rule. `surface` only picks what the card is made of
|
|
163
|
-
* @param {Array} [tabs] `[{ id, label }]` — his All · Actions · Tools · Pages: the first shows every row, the
|
|
164
|
-
* rest the rows whose `tab` is their id. Tab / ⇧Tab step through them from the field
|
|
165
|
-
* @param {Object|Element} [anchor] a ref (or element) the card ANCHORS ABOVE — the dock's ⌘K: the card takes the anchor's
|
|
166
|
-
* left and width, 16 over its top, the page undimmed. Unset, the card is centred
|
|
167
|
-
* @param {string} [shortcutHint] the field's key cap while it is empty (his `⌘K`)
|
|
168
|
-
* @param {boolean|Object} [motion=true] with `surface`, the card fades and scales in and out over a fading scrim, held in
|
|
169
|
-
* the tree while it leaves (FloatActionStatesAndMotion, 2026-11-04): `true` the
|
|
170
|
-
* `--kol-float-*` tokens · `false` none · `{ duration, ease }` per app
|
|
156
|
+
* @param {'default'|'kolbox'|'folio'} [variant='default'] the look. `folio`: Folio's search modal and command list (`mode`
|
|
157
|
+
* search, commands), see `CommandOverlayFolio`. `default` is the KOL search modal (the overlay
|
|
158
|
+
* panel on oq-04, the field in a grey tone, OptionRow rows, the Kbd footer), as it was
|
|
159
|
+
* drawn up to 0.341.1.
|
|
171
160
|
*/
|
|
172
|
-
|
|
161
|
+
function CommandOverlayDefault({
|
|
173
162
|
open,
|
|
174
163
|
onClose,
|
|
175
164
|
results: rawResults = [],
|
|
@@ -196,16 +185,11 @@ export default function CommandOverlay({
|
|
|
196
185
|
mode = 'search',
|
|
197
186
|
shortcuts = [],
|
|
198
187
|
currentPath,
|
|
199
|
-
|
|
188
|
+
variant = 'default',
|
|
200
189
|
tabs,
|
|
201
190
|
anchor,
|
|
202
191
|
shortcutHint,
|
|
203
|
-
motion = true,
|
|
204
192
|
}) {
|
|
205
|
-
const float = true
|
|
206
|
-
const fm = floatMotion(motion)
|
|
207
|
-
const presence = useFloatPresence(open, float ? fm.ms : 0)
|
|
208
|
-
const exit = float && presence.exiting ? '' : undefined
|
|
209
193
|
const panelRef = useRef(null)
|
|
210
194
|
const listRef = useRef(null)
|
|
211
195
|
const listId = useId()
|
|
@@ -234,7 +218,7 @@ export default function CommandOverlay({
|
|
|
234
218
|
window.addEventListener('resize', on)
|
|
235
219
|
return () => window.removeEventListener('resize', on)
|
|
236
220
|
}, [open, anchor])
|
|
237
|
-
const anchorRect =
|
|
221
|
+
const anchorRect = open && anchor ? (anchor.current ?? anchor)?.getBoundingClientRect?.() : null
|
|
238
222
|
const place = anchorRect ? { left: anchorRect.left, width: anchorRect.width, bottom: window.innerHeight - anchorRect.top + 16 } : null
|
|
239
223
|
const results = unfold(base, opened)
|
|
240
224
|
/* a `disabled` row is drawn but never active: ↑↓ step over it, Enter and click never reach
|
|
@@ -271,7 +255,7 @@ export default function CommandOverlay({
|
|
|
271
255
|
listRef.current?.querySelectorAll('[role="option"]')[active]?.scrollIntoView({ block: 'nearest' })
|
|
272
256
|
}, [active])
|
|
273
257
|
|
|
274
|
-
if (!
|
|
258
|
+
if (!open) return null
|
|
275
259
|
|
|
276
260
|
/* A row that KEEPS THE MODAL OPEN — `keepOpen`, or an `action` row (the contract below always said
|
|
277
261
|
* so; until 0.252.0 every pick closed — ShellSearchOverlayActionKeepsOpen, kol-fxr 2026-10-13). It
|
|
@@ -352,11 +336,9 @@ export default function CommandOverlay({
|
|
|
352
336
|
const enterWord = results.length > 0
|
|
353
337
|
? (results[active]?.fold ? (opened.has(results[active].id) ? 'Collapse' : 'Expand') : noField ? 'Collapse' : selectLabel)
|
|
354
338
|
: enterLabel
|
|
355
|
-
const hint = 'flex items-center gap-1.5 text-oq-64'
|
|
356
|
-
const hintBtn = `${hint} hover:text-fg-emphasis transition-colors cursor-pointer`
|
|
357
339
|
|
|
358
340
|
return (
|
|
359
|
-
<div className={`fixed inset-0 ${place ? '' : 'flex items-start justify-center pt-[20vh]'}`} style={{ zIndex: 'var(--kol-z-modal, 100)'
|
|
341
|
+
<div className={`fixed inset-0 ${place ? '' : 'flex items-start justify-center pt-[20vh]'}`} style={{ zIndex: 'var(--kol-z-modal, 100)' }}>
|
|
360
342
|
{/* A BUTTON, not a div (OverlayScrimTapDismiss, 2026-09-01): iOS Safari
|
|
361
343
|
* does not bubble tap-clicks from non-interactive elements, so the div's
|
|
362
344
|
* onClick never fired on a phone and the only way out was the close
|
|
@@ -365,8 +347,7 @@ export default function CommandOverlay({
|
|
|
365
347
|
<button
|
|
366
348
|
type="button"
|
|
367
349
|
aria-label="Close search"
|
|
368
|
-
className={`absolute inset-0 ${place ? 'cursor-default' : 'kol-overlay-scrim
|
|
369
|
-
data-exit={exit}
|
|
350
|
+
className={`absolute inset-0 ${place ? 'cursor-default' : 'kol-overlay-scrim'}`}
|
|
370
351
|
onClick={onClose}
|
|
371
352
|
/>
|
|
372
353
|
<div
|
|
@@ -377,10 +358,9 @@ export default function CommandOverlay({
|
|
|
377
358
|
role="dialog"
|
|
378
359
|
aria-modal="true"
|
|
379
360
|
aria-label="Search"
|
|
380
|
-
data-exit={exit}
|
|
381
361
|
data-side={place ? 'top' : undefined}
|
|
382
362
|
style={place ? { position: 'fixed', left: place.left, width: place.width, bottom: place.bottom } : undefined}
|
|
383
|
-
className={`kol-
|
|
363
|
+
className={`kol-overlay-panel ${place ? '' : 'mx-4 '}${noField ? 'outline-none ' : ''}${expanded ? 'max-w-[var(--kol-content-panel)]' : 'max-w-lg'}`}
|
|
384
364
|
>
|
|
385
365
|
{/* THE MODE, said out loud (user 2026-08-01: "how do you set search
|
|
386
366
|
* mode? theres no helper, message or mode clearly readble"). Two
|
|
@@ -388,8 +368,8 @@ export default function CommandOverlay({
|
|
|
388
368
|
* to a destination) — and the only signal was whether chips happened
|
|
389
369
|
* to be present. The chips ARE the mode, so they get a label. */}
|
|
390
370
|
{chips.length > 0 && (
|
|
391
|
-
<div className="flex flex-wrap items-center gap-1.5 px-
|
|
392
|
-
<span className="kol-
|
|
371
|
+
<div className="flex flex-wrap items-center gap-1.5 px-4 pt-3">
|
|
372
|
+
<span className="kol-helper-10 text-fg-48 shrink-0">FILTERING BY</span>
|
|
393
373
|
{chips.map((t) => (
|
|
394
374
|
<Tag key={t} onRemove={() => onRemoveChip?.(t)}>{t}</Tag>
|
|
395
375
|
))}
|
|
@@ -398,26 +378,27 @@ export default function CommandOverlay({
|
|
|
398
378
|
{/* THE BACK ARROW TAKES THE SEARCH GLYPH'S SLOT (user 2026-10-18: *"why would the back move the input?!"*) —
|
|
399
379
|
* a button beside the field shrank it and shifted the caret on every drill-in */}
|
|
400
380
|
{!noField && (
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
381
|
+
/* A REAL FIELD, inset in the panel (2026-09-30, shadcn's search modal as the aim) */
|
|
382
|
+
<div className="kol-tone-grey p-2 flex items-center gap-2">
|
|
383
|
+
<SearchInput
|
|
384
|
+
className="w-full min-w-0 flex-1"
|
|
385
|
+
value={query}
|
|
386
|
+
onChange={(e) => onQueryChange?.(e.target.value)}
|
|
387
|
+
placeholder={chips.length > 0 ? 'Narrow these results…' : placeholder}
|
|
388
|
+
onKeyDown={handleKeyDown}
|
|
389
|
+
onBack={back}
|
|
390
|
+
backLabel={backLabel}
|
|
391
|
+
shortcutHint={shortcutHint}
|
|
392
|
+
role="combobox"
|
|
393
|
+
aria-expanded={results.length > 0}
|
|
394
|
+
aria-controls={listId}
|
|
395
|
+
aria-activedescendant={active >= 0 ? optionId(results[active]) : undefined}
|
|
396
|
+
/>
|
|
397
|
+
</div>
|
|
417
398
|
)}
|
|
418
|
-
{/* his tabs — All · Actions · Tools · Pages
|
|
399
|
+
{/* his tabs — All · Actions · Tools · Pages */}
|
|
419
400
|
{tabs?.length > 0 && !expanded && (
|
|
420
|
-
<TabsRow
|
|
401
|
+
<TabsRow size="md" tabs={tabs} value={tabNow} onChange={setTab} className="px-2 pt-2" />
|
|
421
402
|
)}
|
|
422
403
|
|
|
423
404
|
{/* WHY THIS IS NOT `molecules/Dropdown` (asked 2026-08-01). Dropdown is
|
|
@@ -441,39 +422,35 @@ export default function CommandOverlay({
|
|
|
441
422
|
* its items, a "← All" row back); the consumer swaps `suggestions`/`results`
|
|
442
423
|
* Built by `buildShellSearchItems` (showcase/src/nav/shell-nav.js). */}
|
|
443
424
|
{expanded ? (
|
|
444
|
-
<div className="border-t border-fg-08 max-h-[70vh] overflow-y-auto"
|
|
425
|
+
<div className="border-t border-fg-08 max-h-[70vh] overflow-y-auto">{children}</div>
|
|
445
426
|
) : results.length > 0 && (
|
|
446
427
|
/* FIXED BODY HEIGHT — the panel holds still while the list narrows. */
|
|
447
|
-
<ul ref={listRef} id={listId} role="listbox" className=
|
|
428
|
+
<ul ref={listRef} id={listId} role="listbox" className={`kol-tone-grey h-80 overflow-y-auto px-2 pb-2${noField ? ' pt-2' : ''}`}>
|
|
448
429
|
{results.map((item, i) => {
|
|
449
430
|
const heading = (item.group ?? '') !== (results[i - 1]?.group ?? '') || i === 0
|
|
450
431
|
return (
|
|
451
432
|
<li key={item.id} role="presentation">
|
|
452
433
|
{heading && item.group && (
|
|
453
434
|
/* the rail's eyebrow (user 2026-10-18: *"sections shoudl be uppercase eyebrow like in siderail"*) */
|
|
454
|
-
<p className="kol-eyebrow text-
|
|
435
|
+
<p className="kol-eyebrow text-fg-80 px-4 border-x border-transparent pt-3 pb-2">{item.group}</p>
|
|
455
436
|
)}
|
|
456
|
-
|
|
457
|
-
<Button
|
|
437
|
+
<OptionRow
|
|
458
438
|
id={optionId(item)}
|
|
459
439
|
role="option"
|
|
460
440
|
aria-selected={i === active}
|
|
461
441
|
aria-disabled={item.disabled || undefined}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
442
|
+
active={i === active}
|
|
443
|
+
disabled={item.disabled}
|
|
444
|
+
icon={typeof item.icon === 'string' ? item.icon : undefined}
|
|
445
|
+
/* a fold's key row sits under its category's label, past the chevron */
|
|
446
|
+
leading={item.indent ? <span className="inline-block w-4" /> : typeof item.icon === 'string' ? undefined : item.icon}
|
|
447
|
+
label={<HighlightMatch label={item.label} query={query} ranges={item.highlights} />}
|
|
448
|
+
hint={(item.disabled && item.disabledHint) || item.hint}
|
|
449
|
+
/* preventDefault keeps focus in the input through the click */
|
|
466
450
|
onMouseDown={(e) => e.preventDefault()}
|
|
467
451
|
onClick={() => select(item)}
|
|
468
452
|
onMouseEnter={() => { if (!item.disabled) { setActiveIndex(i); setNavigated(true) } }}
|
|
469
|
-
|
|
470
|
-
{/* the glyph drawn here, not as `iconLeft` — Button would wrap it and the label in a span that does not take the row */}
|
|
471
|
-
<span className="flex min-w-0 flex-1 items-center" style={{ gap: 'var(--kol-float-gap-ic)' }}>
|
|
472
|
-
{item.indent ? <span className="inline-block w-4 shrink-0" /> : item.icon && (typeof item.icon === 'string' ? <IconLoader name={item.icon} size="var(--kol-float-ic)" className="shrink-0 text-oq-88" /> : item.icon)}
|
|
473
|
-
<span className="truncate text-left"><HighlightMatch label={item.label} query={query} ranges={item.highlights} /></span>
|
|
474
|
-
{((item.disabled && item.disabledHint) || item.hint) && <span className="kol-float-hint ml-auto truncate pl-3 text-oq-64">{(item.disabled && item.disabledHint) || item.hint}</span>}
|
|
475
|
-
</span>
|
|
476
|
-
</Button>
|
|
453
|
+
/>
|
|
477
454
|
</li>
|
|
478
455
|
)
|
|
479
456
|
})}
|
|
@@ -481,20 +458,37 @@ export default function CommandOverlay({
|
|
|
481
458
|
)}
|
|
482
459
|
{/* THE FOOT — his key hints under a rule that runs the card's full width; it always says what Enter does. */}
|
|
483
460
|
{!expanded && (results.length > 0 || (query && (enterLabel || onOpenResults))) && (
|
|
484
|
-
<div className="
|
|
485
|
-
{
|
|
486
|
-
{enterWord &&
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
461
|
+
<div className="border-t border-fg-08 py-2">
|
|
462
|
+
{/* Enter's line names what Enter does NOW: a row is highlighted → it opens that row; no rows → it commits the query */}
|
|
463
|
+
{enterWord && (
|
|
464
|
+
/* 44px on touch — a finger-sized line */
|
|
465
|
+
<p className="flex items-center gap-2 kol-helper-12 text-fg-48 mx-2 px-4 border-x border-transparent pointer-coarse:min-h-11">
|
|
466
|
+
<Kbd icon="corner-down-left" />
|
|
467
|
+
{enterWord}
|
|
468
|
+
{/* the second action on the same line, right — ⌘↵, the footer's idiom for "the other one" */}
|
|
469
|
+
{folds.length > 0 && !query && (
|
|
470
|
+
<button
|
|
471
|
+
type="button"
|
|
472
|
+
className="ml-auto flex items-center gap-2 text-fg-48 hover:text-fg-default transition-colors cursor-pointer"
|
|
473
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
474
|
+
onClick={toggleAll}
|
|
475
|
+
>
|
|
476
|
+
<Kbd icon="command"><IconLoader name="corner-down-left" size={12} /></Kbd>
|
|
477
|
+
{allOpen ? 'Collapse all' : 'Expand all'}
|
|
478
|
+
</button>
|
|
479
|
+
)}
|
|
480
|
+
</p>
|
|
494
481
|
)}
|
|
482
|
+
{/* THE RESULTS LINE IS A LINK (user 2026-10-01) — the same door ⌘Enter opens */}
|
|
495
483
|
{query && onOpenResults && (
|
|
496
|
-
<button
|
|
497
|
-
|
|
484
|
+
<button
|
|
485
|
+
type="button"
|
|
486
|
+
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"
|
|
487
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
488
|
+
onClick={() => { onOpenResults(query); onClose?.() }}
|
|
489
|
+
>
|
|
490
|
+
<Kbd icon="command"><IconLoader name="corner-down-left" size={12} /></Kbd>
|
|
491
|
+
{resultsLabel}
|
|
498
492
|
</button>
|
|
499
493
|
)}
|
|
500
494
|
</div>
|
|
@@ -503,3 +497,284 @@ export default function CommandOverlay({
|
|
|
503
497
|
</div>
|
|
504
498
|
)
|
|
505
499
|
}
|
|
500
|
+
|
|
501
|
+
/* ── kolbox (plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18) ─────────────────────────────────────────────────
|
|
502
|
+
* kolbox's ModalSearch (round 3, 9.1; round 4, 14.1), carried from apps/kolbox/src/ui/ModalSearch.jsx: the panel 576 wide
|
|
503
|
+
* (`--kol-kolbox-search-w`), radius 16, on the one floating surface, in PopoverLayer's body on the dim, 20% down. The
|
|
504
|
+
* field (Input kolbox lg, the lens, the ⌘K mark while empty), the tabs, then the groups: a title and its rows (TreeRow
|
|
505
|
+
* kolbox lg, touching, the active one lit, the hint at the right), then a rule and the foot (↑↓ Navigate, ↵ Run, Esc
|
|
506
|
+
* Close). Presentational: the host passes the rows and keeps the state. CommandOverlay's words: `open`, `onClose`,
|
|
507
|
+
* `query`, `onQueryChange`, `placeholder`, `tabs` [{ value, label }], `onSelect(row)` (kolbox's onRun), `mode` ('search',
|
|
508
|
+
* or 'shortcuts': the real S sheet, the same panel with no field and no tabs, Enter folds a key's section back up and
|
|
509
|
+
* never runs it). kolbox's own: `tab`, `onTab`, `groups` [{ title, rows: [{ id, icon, label, body, hint, kbd, disabled,
|
|
510
|
+
* disabledHint, items, open }] }] (a row with `items` is a fold), `active` (an index into the rows in group order),
|
|
511
|
+
* `onActive(index)`, `empty` (what can be searched, said when nothing is found:
|
|
512
|
+
* plan-2026-11-19 C5.1b). Keys in the field: ↑↓ move the lit row over disabled rows,
|
|
513
|
+
* Enter runs it, Tab and ⇧Tab step the tabs, → and ← open and close a fold while the field is empty, ⌘↵ all folds;
|
|
514
|
+
* Escape is the layer's. */
|
|
515
|
+
function MatchKolbox({ label, query }) {
|
|
516
|
+
/* a label the host has marked itself (a node) is drawn as it is */
|
|
517
|
+
if (typeof label !== 'string') return label
|
|
518
|
+
const at = query ? label.toLowerCase().indexOf(query.toLowerCase()) : -1
|
|
519
|
+
if (at < 0) return label
|
|
520
|
+
return <>{label.slice(0, at)}<span className="underline decoration-2 underline-offset-[3px]">{label.slice(at, at + query.length)}</span>{label.slice(at + query.length)}</>
|
|
521
|
+
}
|
|
522
|
+
const KeyKolbox = ({ k, children }) => <span className="flex items-center gap-1"><KbdKeys variant="kolbox" size="sm" keys={k} />{children}</span>
|
|
523
|
+
/* a fold's rows indented to its label: the row's 12 inset, the 20 icon and its 12 gap */
|
|
524
|
+
const INDENT_KOLBOX = { paddingLeft: 'calc(var(--kol-spacing-3) * 2 + 20px)' }
|
|
525
|
+
|
|
526
|
+
function CommandOverlayKolbox({ open, onClose, mode = 'search', query = '', onQueryChange, placeholder = 'Search tools, actions, pages…', tabs = [], tab, onTab, groups = [], active = -1, onActive, onSelect, empty, mark = '⌘K', 'aria-label': ariaLabel }) {
|
|
527
|
+
const field = mode !== 'shortcuts'
|
|
528
|
+
const input = useRef(null)
|
|
529
|
+
const panel = useRef(null)
|
|
530
|
+
const list = useRef(null)
|
|
531
|
+
const listId = useId()
|
|
532
|
+
const folds = groups.flatMap((g) => g.rows).filter((r) => Array.isArray(r.items))
|
|
533
|
+
const [opened, setOpened] = useState(() => new Set())
|
|
534
|
+
const toggle = (id, on) => setOpened((o) => { const n = new Set(o); (on ?? !n.has(id)) ? n.add(id) : n.delete(id); return n })
|
|
535
|
+
const allOpen = folds.length > 0 && folds.every((r) => opened.has(r.id))
|
|
536
|
+
const toggleAll = () => setOpened(allOpen ? new Set() : new Set(folds.map((r) => r.id)))
|
|
537
|
+
const shown = groups.map((g) => ({
|
|
538
|
+
...g,
|
|
539
|
+
rows: g.rows.flatMap((r) => (Array.isArray(r.items)
|
|
540
|
+
? [{ ...r, icon: opened.has(r.id) ? 'arrow-down' : 'arrow-right', fold: true }, ...(opened.has(r.id) ? r.items.map((c) => ({ ...c, id: `${r.id}/${c.id}`, of: r.id })) : [])]
|
|
541
|
+
: [r])),
|
|
542
|
+
}))
|
|
543
|
+
const rows = shown.flatMap((g) => g.rows)
|
|
544
|
+
|
|
545
|
+
useEffect(() => {
|
|
546
|
+
if (!open) return
|
|
547
|
+
const back = document.activeElement
|
|
548
|
+
;(field ? input.current : panel.current)?.focus({ preventScroll: true })
|
|
549
|
+
setOpened(new Set(folds.filter((r) => r.open).map((r) => r.id)))
|
|
550
|
+
return () => back?.focus?.({ preventScroll: true })
|
|
551
|
+
}, [open]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
552
|
+
useEffect(() => { list.current?.querySelector(`[data-search-row="${active}"]`)?.scrollIntoView({ block: 'nearest' }) }, [active])
|
|
553
|
+
|
|
554
|
+
const step = (dir) => {
|
|
555
|
+
for (let i = active + dir; i >= 0 && i < rows.length; i += dir) if (!rows[i].disabled) return i
|
|
556
|
+
return active
|
|
557
|
+
}
|
|
558
|
+
const at = (id) => rows.findIndex((r) => r.id === id)
|
|
559
|
+
const pick = (r) => {
|
|
560
|
+
if (!r || r.disabled) return
|
|
561
|
+
if (r.fold) return toggle(r.id)
|
|
562
|
+
if (!field) { if (r.of) { toggle(r.of, false); onActive?.(at(r.of)) } return }
|
|
563
|
+
onSelect?.(r)
|
|
564
|
+
}
|
|
565
|
+
const key = (e) => {
|
|
566
|
+
if (e.key === 'Escape') return
|
|
567
|
+
if (field || /^(Arrow|Enter$|Tab$)/.test(e.key)) e.stopPropagation()
|
|
568
|
+
const r = rows[active]
|
|
569
|
+
if (!query && (e.key === 'ArrowRight' || e.key === 'ArrowLeft') && r && (r.fold || r.of)) {
|
|
570
|
+
e.preventDefault()
|
|
571
|
+
if (e.key === 'ArrowRight' && r.fold) toggle(r.id, true)
|
|
572
|
+
if (e.key === 'ArrowLeft') { toggle(r.fold ? r.id : r.of, false); if (!r.fold) onActive?.(at(r.of)) }
|
|
573
|
+
}
|
|
574
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); onActive?.(step(1)) }
|
|
575
|
+
if (e.key === 'ArrowUp') { e.preventDefault(); onActive?.(step(-1)) }
|
|
576
|
+
if (e.key === 'Enter') {
|
|
577
|
+
e.preventDefault()
|
|
578
|
+
if ((e.metaKey || e.ctrlKey) && folds.length && !query) toggleAll()
|
|
579
|
+
else pick(r)
|
|
580
|
+
}
|
|
581
|
+
if (e.key === 'Tab') {
|
|
582
|
+
e.preventDefault()
|
|
583
|
+
const now = tabs.findIndex((t) => t.value === tab)
|
|
584
|
+
if (field && tabs.length) onTab?.(tabs[(now + (e.shiftKey ? -1 : 1) + tabs.length) % tabs.length].value)
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
const enter = rows[active]?.fold ? (opened.has(rows[active].id) ? 'Collapse' : 'Expand') : field ? 'Run' : 'Collapse'
|
|
588
|
+
|
|
589
|
+
let n = -1
|
|
590
|
+
return (
|
|
591
|
+
<PopoverLayer open={open} onClose={onClose} placement="center" kind="modal">
|
|
592
|
+
<section
|
|
593
|
+
ref={panel}
|
|
594
|
+
role="dialog"
|
|
595
|
+
aria-modal="true"
|
|
596
|
+
aria-label={ariaLabel ?? (field ? 'Search' : 'Shortcuts')}
|
|
597
|
+
data-kolbox-search=""
|
|
598
|
+
tabIndex={field ? undefined : -1}
|
|
599
|
+
onKeyDown={field ? undefined : key}
|
|
600
|
+
className="kol-command--kolbox kol-kolbox-surface mt-[20vh] flex max-w-[calc(100vw-var(--kol-spacing-8))] flex-col self-start overflow-hidden outline-none"
|
|
601
|
+
>
|
|
602
|
+
{field && (
|
|
603
|
+
<div className="flex flex-col gap-2 p-2">
|
|
604
|
+
<Input variant="kolbox"
|
|
605
|
+
ref={input}
|
|
606
|
+
size="lg"
|
|
607
|
+
iconLeft="search"
|
|
608
|
+
placeholder={placeholder}
|
|
609
|
+
aria-label="Search"
|
|
610
|
+
role="combobox"
|
|
611
|
+
aria-expanded={rows.length > 0}
|
|
612
|
+
aria-controls={listId}
|
|
613
|
+
aria-activedescendant={active >= 0 && rows[active] ? `${listId}-${active}` : undefined}
|
|
614
|
+
value={query}
|
|
615
|
+
onChange={(e) => onQueryChange?.(e.target.value)}
|
|
616
|
+
onKeyDown={key}
|
|
617
|
+
slotRight={!query && mark && <KbdKeys variant="kolbox" size="sm" keys={mark} />} />
|
|
618
|
+
{tabs.length > 0 && <TabsRow variant="kolbox" tabs={tabs} value={tab} onChange={onTab} className="h-10! w-full [&>button]:flex-1 [&>button]:px-4" />}
|
|
619
|
+
</div>
|
|
620
|
+
)}
|
|
621
|
+
{(rows.length > 0 || field) && (
|
|
622
|
+
<>
|
|
623
|
+
{rows.length === 0 && (
|
|
624
|
+
<div className="flex h-80 flex-col items-center justify-center gap-2 px-8 text-center" data-search-empty="">
|
|
625
|
+
<span className="kol-command-group">{query ? `Nothing found for “${query}”` : 'Nothing to show'}</span>
|
|
626
|
+
{empty && <span className="kol-command-group">{empty}</span>}
|
|
627
|
+
</div>
|
|
628
|
+
)}
|
|
629
|
+
{rows.length > 0 && <div ref={list} id={listId} role="listbox" className={`flex h-80 flex-col gap-0.5 overflow-y-auto px-2 ${field ? '' : 'pt-2'}`}>
|
|
630
|
+
{shown.map((g, gi) => (
|
|
631
|
+
<Fragment key={gi}>
|
|
632
|
+
{g.title && g.rows.length > 0 && <div className="kol-command-group shrink-0 px-3 pt-3 pb-2 tracking-wider uppercase">{g.title}</div>}
|
|
633
|
+
{g.rows.map((r) => {
|
|
634
|
+
const i = ++n
|
|
635
|
+
const hint = (r.disabled && r.disabledHint) || r.hint
|
|
636
|
+
return (
|
|
637
|
+
<TreeRow
|
|
638
|
+
key={r.id}
|
|
639
|
+
variant="kolbox"
|
|
640
|
+
size="lg"
|
|
641
|
+
id={`${listId}-${i}`}
|
|
642
|
+
role="option"
|
|
643
|
+
aria-selected={i === active}
|
|
644
|
+
aria-expanded={r.fold ? opened.has(r.id) : undefined}
|
|
645
|
+
tabIndex={-1}
|
|
646
|
+
data-search-row={i}
|
|
647
|
+
data-fold={r.fold ? '' : undefined}
|
|
648
|
+
icon={r.of ? undefined : r.icon}
|
|
649
|
+
label={r.body
|
|
650
|
+
/* `body`, an optional second line (Folio's word): the row grows to hold it; a row without one is as before */
|
|
651
|
+
? <span className="flex min-w-0 flex-col"><span className="truncate"><MatchKolbox label={r.label} query={query} /></span><span className="kol-command-body truncate">{r.body}</span></span>
|
|
652
|
+
: <MatchKolbox label={r.label} query={query} />}
|
|
653
|
+
className={r.body ? 'h-auto! min-h-10 py-1.5' : undefined}
|
|
654
|
+
active={i === active}
|
|
655
|
+
disabled={r.disabled}
|
|
656
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
657
|
+
onMouseEnter={() => !r.disabled && onActive?.(i)}
|
|
658
|
+
onClick={() => pick(r)}
|
|
659
|
+
trailing={hint && (r.kbd && hint === r.hint ? <KbdKeys variant="kolbox" keys={hint} size="md" className="pl-3" /> : <span className="kol-command-hint max-w-1/2 shrink-0 truncate pl-3">{hint}</span>)}
|
|
660
|
+
{...(r.of ? { style: INDENT_KOLBOX } : {})}
|
|
661
|
+
/>
|
|
662
|
+
)
|
|
663
|
+
})}
|
|
664
|
+
</Fragment>
|
|
665
|
+
))}
|
|
666
|
+
</div>}
|
|
667
|
+
<div role="separator" className="kol-command-rule mt-2 h-px shrink-0" />
|
|
668
|
+
<footer className="kol-command-foot flex h-10 shrink-0 items-center gap-4 px-4">
|
|
669
|
+
{rows.length > 1 && <KeyKolbox k="↑↓">Navigate</KeyKolbox>}
|
|
670
|
+
{rows.length > 0 && <KeyKolbox k="↵">{enter}</KeyKolbox>}
|
|
671
|
+
<button type="button" onMouseDown={(e) => e.preventDefault()} onClick={onClose} className="outline-none">
|
|
672
|
+
<KeyKolbox k="Esc">Close</KeyKolbox>
|
|
673
|
+
</button>
|
|
674
|
+
{folds.length > 0 && !query && (
|
|
675
|
+
<button type="button" onMouseDown={(e) => e.preventDefault()} onClick={toggleAll} className="ml-auto outline-none" data-fold-all>
|
|
676
|
+
<KeyKolbox k="⌘↵">{allOpen ? 'Collapse all' : 'Expand all'}</KeyKolbox>
|
|
677
|
+
</button>
|
|
678
|
+
)}
|
|
679
|
+
</footer>
|
|
680
|
+
</>
|
|
681
|
+
)}
|
|
682
|
+
</section>
|
|
683
|
+
</PopoverLayer>
|
|
684
|
+
)
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/* ── folio (Folio migration batch B, 2026-11-22) ──────────────────────────────────────────────────────────────────────────
|
|
688
|
+
* Folio's two search windows carried class for class, the chrome in kol-theme `.kol-command--folio`, on `ModalShell
|
|
689
|
+
* variant="folio"`, 12% down, drawn in place (never portalled, so they keep the frame's `data-folio-*`); a press outside
|
|
690
|
+
* closes. Presentational, as kolbox's: the host keeps the query, the rows and the lit row.
|
|
691
|
+
* mode 'search' the search modal (Folio's SearchOverlay): 720 wide on the Folio dim, the field (the lens, `esc`),
|
|
692
|
+
* then each row: `label` (a node, the matches marked by the host) with `group` at the right, `hint`
|
|
693
|
+
* under it, `body` (Folio's word: a line of the text) under that
|
|
694
|
+
* mode 'commands' the command list (Folio's CommandPalette, ⇧⌘P): 640 wide, no dim, the field, then rows of `label`
|
|
695
|
+
* with `hint` (the keys) at the right
|
|
696
|
+
* CommandOverlay's words: `open`, `onClose`, `query`, `onQueryChange`, `placeholder`, `results` `[{ id, label, group,
|
|
697
|
+
* hint, body }]`, `onSelect(row)` (also on Enter with no row in `commands`, so Enter there always closes), `aria-label`.
|
|
698
|
+
* kolbox's: `active`, `onActive`, `empty` (said under the field when it is set). Keys in the field: ↑↓ move the lit
|
|
699
|
+
* row, Enter picks, Escape closes. */
|
|
700
|
+
function CommandOverlayFolio({ open, onClose, mode = 'search', query = '', onQueryChange, placeholder, results = [], active = 0, onActive, onSelect, empty, 'aria-label': label }) {
|
|
701
|
+
const commands = mode === 'commands'
|
|
702
|
+
const input = useRef(null)
|
|
703
|
+
useEffect(() => { if (open && !commands) setTimeout(() => input.current?.focus(), 0) }, [open]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
704
|
+
if (!open) return null
|
|
705
|
+
const onKey = (e) => {
|
|
706
|
+
if (e.key === 'Escape') onClose?.()
|
|
707
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); onActive?.(Math.min(active + 1, results.length - 1)) }
|
|
708
|
+
if (e.key === 'ArrowUp') { e.preventDefault(); onActive?.(Math.max(active - 1, 0)) }
|
|
709
|
+
if (e.key === 'Enter') {
|
|
710
|
+
if (commands) { e.preventDefault(); onSelect?.(results[active]) }
|
|
711
|
+
else if (results[active]) onSelect?.(results[active])
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
if (commands) {
|
|
715
|
+
return (
|
|
716
|
+
<div className="fixed inset-0 z-50 flex items-start justify-center px-[16px] pt-[12vh]" onMouseDown={onClose}>
|
|
717
|
+
<ModalShell variant="folio" role="dialog" aria-label={label} onMouseDown={(e) => e.stopPropagation()} className="kol-command--folio kol-command--folio-commands max-h-[60vh] w-[640px] max-w-full overflow-hidden">
|
|
718
|
+
<input autoFocus aria-label="Command" placeholder={placeholder} value={query} onChange={(e) => onQueryChange?.(e.target.value)} onKeyDown={onKey}
|
|
719
|
+
className="kol-command-field--folio h-[48px] shrink-0 border-b bg-transparent px-[16px] outline-none" />
|
|
720
|
+
<div role="listbox" aria-label={label} className="min-h-0 overflow-y-auto py-[6px]">
|
|
721
|
+
{results.map((r, i) => (
|
|
722
|
+
<button key={r.id ?? r.label} type="button" role="option" aria-selected={i === active} onMouseEnter={() => onActive?.(i)} onClick={() => onSelect?.(r)} className={`kol-command-row--folio${i === active ? ' is-active' : ''} flex h-[32px] w-full items-center px-[16px] text-left`}>
|
|
723
|
+
{r.label}<span className="kol-command-hint--folio ml-auto">{r.hint ?? ''}</span>
|
|
724
|
+
</button>
|
|
725
|
+
))}
|
|
726
|
+
{empty && <p className="kol-folio-meta kol-command-empty--folio px-[16px] py-[8px]">{empty}</p>}
|
|
727
|
+
</div>
|
|
728
|
+
</ModalShell>
|
|
729
|
+
</div>
|
|
730
|
+
)
|
|
731
|
+
}
|
|
732
|
+
return (
|
|
733
|
+
<div className="kol-modal-dim--folio fixed inset-0 z-50 flex items-start justify-center px-[16px] pt-[12vh]" onMouseDown={onClose}>
|
|
734
|
+
<ModalShell variant="folio" role="dialog" aria-label={label} className="kol-command--folio kol-command--folio-search max-h-[70vh] w-full max-w-[720px] overflow-hidden" onMouseDown={(e) => e.stopPropagation()}>
|
|
735
|
+
<label className="kol-command-head--folio flex h-[56px] shrink-0 items-center gap-[12px] border-b px-[18px]">
|
|
736
|
+
<IconLoader name="search" size={18} />
|
|
737
|
+
<input ref={input} value={query} onChange={(e) => onQueryChange?.(e.target.value)} onKeyDown={onKey} placeholder={placeholder} className="kol-command-search--folio min-w-0 flex-1 bg-transparent outline-none" />
|
|
738
|
+
<span className="kol-folio-meta kol-command-hint--folio">esc</span>
|
|
739
|
+
</label>
|
|
740
|
+
<div className="overflow-y-auto">
|
|
741
|
+
{empty && <p className="kol-folio-body kol-command-empty--folio px-[18px] py-[20px]">{empty}</p>}
|
|
742
|
+
{results.map((r, i) => (
|
|
743
|
+
<button key={r.id} type="button" onMouseEnter={() => onActive?.(i)} onClick={() => onSelect?.(r)} className={`kol-command-result--folio${i === active ? ' is-active' : ''} flex w-full flex-col gap-[6px] border-b px-[18px] py-[14px] text-left`}>
|
|
744
|
+
<span className="flex items-baseline justify-between gap-[16px]">
|
|
745
|
+
<span className="kol-folio-shelf">{r.label}</span>
|
|
746
|
+
<span className="kol-folio-label kol-command-hint--folio shrink-0">{r.group}</span>
|
|
747
|
+
</span>
|
|
748
|
+
{r.hint && <span className="kol-folio-meta kol-command-hint--folio">{r.hint}</span>}
|
|
749
|
+
{r.body && <span className="kol-folio-body kol-command-hint--folio">{r.body}</span>}
|
|
750
|
+
</button>
|
|
751
|
+
))}
|
|
752
|
+
</div>
|
|
753
|
+
</ModalShell>
|
|
754
|
+
</div>
|
|
755
|
+
)
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/* ── kolbox, from `results` (Folio on kolbox, 2026-11-22) ──
|
|
759
|
+
* The folio branch's words under the kolbox look, so a host switches by the variant alone: `results` `[{ id, label, group,
|
|
760
|
+
* hint, body }]` become kolbox's groups (each `group` a titled group, in the order they first come; `hint` at the row's
|
|
761
|
+
* right, as key caps when it is one combo); `body`, when a row has one, is a second line under its label. `mode`
|
|
762
|
+
* 'commands' is the same panel with no group titles: the command list. The row handed to `onSelect` is the host's own. */
|
|
763
|
+
export const isKeyCombo = (s) => typeof s === 'string' && /^[⌘⇧⌥⌃]*[^\s⌘⇧⌥⌃]+$/.test(s)
|
|
764
|
+
function CommandOverlayKolboxResults({ results, mode, ...props }) {
|
|
765
|
+
const groups = []
|
|
766
|
+
results.forEach((r, i) => {
|
|
767
|
+
const title = mode === 'commands' ? undefined : r.group
|
|
768
|
+
let g = groups.find((x) => x.title === title)
|
|
769
|
+
if (!g) groups.push((g = { title, rows: [] }))
|
|
770
|
+
g.rows.push({ ...r, id: r.id ?? `${i}:${typeof r.label === 'string' ? r.label : ''}`, hint: r.hint || undefined, kbd: isKeyCombo(r.hint) })
|
|
771
|
+
})
|
|
772
|
+
/* the field's ⌘K mark is the search modal's own key; the command list does not open on it */
|
|
773
|
+
return <CommandOverlayKolbox {...props} mode="search" groups={groups} mark={mode === 'commands' ? null : undefined} />
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
export default function CommandOverlay(props) {
|
|
777
|
+
if (props.variant === 'folio') return <CommandOverlayFolio {...props} />
|
|
778
|
+
if (props.variant === 'kolbox') return props.results ? <CommandOverlayKolboxResults {...props} /> : <CommandOverlayKolbox {...props} />
|
|
779
|
+
return <CommandOverlayDefault {...props} />
|
|
780
|
+
}
|
|
@@ -70,13 +70,9 @@ import { filterItems } from '../utilities/searchItems.js'
|
|
|
70
70
|
* @param {string} props.countClassName — the "N of N" type/ink
|
|
71
71
|
* @param {string} props.tone — 'default' | 'inverse' — forwarded to the search field (ControlToneInverse,
|
|
72
72
|
* 2026-08-27): a page on a wash sets its header row's tone in one place
|
|
73
|
-
* @param {'float'} props.variant — the float filter bar (float-everything W4 row 56, 2026-11-04): each group's
|
|
74
|
-
* chips are `Tag variant="float" size="md"` capsules with the count of items
|
|
75
|
-
* each would show, in a capsule track 5 in. Everything else stays.
|
|
76
73
|
*/
|
|
77
74
|
const ContentFilters = ({
|
|
78
75
|
tone = 'default',
|
|
79
|
-
variant,
|
|
80
76
|
items,
|
|
81
77
|
title,
|
|
82
78
|
totalCount,
|
|
@@ -324,9 +320,6 @@ const ContentFilters = ({
|
|
|
324
320
|
* rule sits in the components layer. */
|
|
325
321
|
const stacked = group.stack ?? index === 0
|
|
326
322
|
const first = index === 0 && stacked
|
|
327
|
-
const float = variant === 'float'
|
|
328
|
-
/* the float chip carries the count of items it would show (row 56) */
|
|
329
|
-
const countOf = (value) => items.filter((item) => { const v = item[group.key]; return Array.isArray(v) ? v.includes(value) : v === value }).length
|
|
330
323
|
return (
|
|
331
324
|
<div key={group.key} className={`flex flex-col gap-3 ${first ? 'kol-filters-first' : stacked ? 'shrink-0' : 'min-w-0 flex-1'} ${group.className ?? ''}`.trim()}>
|
|
332
325
|
{/* THE CATEGORY LABEL IS THE ACTIVE INK — `kol-helper-12` at `text-fg-96`,
|
|
@@ -344,17 +337,16 @@ const ContentFilters = ({
|
|
|
344
337
|
</h4>
|
|
345
338
|
{/* the fluid group keeps 48px of room on its right (it ran flush to the
|
|
346
339
|
* panel's edge); `group.wrapClassName` is the per-group seam */}
|
|
347
|
-
<div className={`${
|
|
340
|
+
<div className={`${stacked ? 'flex flex-col items-start gap-2' : 'flex flex-wrap gap-2 pr-12'} ${group.wrapClassName ?? ''}`.trim()}>
|
|
348
341
|
{group.values.map((value) => (
|
|
349
342
|
<Tag
|
|
350
343
|
key={value}
|
|
351
|
-
size={
|
|
352
|
-
variant={
|
|
344
|
+
size={tagSize}
|
|
345
|
+
variant={tagVariant}
|
|
353
346
|
hash={false}
|
|
354
|
-
count={float ? countOf(value) : undefined}
|
|
355
347
|
active={activeFilters.has(`${group.key}:${value}`)}
|
|
356
348
|
onClick={() => toggleFilter(group.key, value)}
|
|
357
|
-
className={
|
|
349
|
+
className={activeFilters.has(`${group.key}:${value}`) ? tagActiveClassName : tagRestClassName}
|
|
358
350
|
>
|
|
359
351
|
{value}
|
|
360
352
|
</Tag>
|