@kolkrabbi/kol-component 0.342.0 → 0.344.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 +4 -4
- package/src/index.js +5 -0
- package/src/molecules/Modal.jsx +71 -2
- package/src/molecules/SettingsControls.jsx +227 -0
- package/src/organisms/CommandOverlay.jsx +113 -118
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.344.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"pdfjs-dist": "^6.3.289",
|
|
31
31
|
"react-syntax-highlighter": "^16.1.1",
|
|
32
32
|
"@kolkrabbi/kol-search": "^0.3.0",
|
|
33
|
-
"@kolkrabbi/kol-
|
|
34
|
-
"@kolkrabbi/kol-
|
|
33
|
+
"@kolkrabbi/kol-growth": "^0.5.0",
|
|
34
|
+
"@kolkrabbi/kol-markdown": "^0.2.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@kolkrabbi/kol-icons": ">=0.61.1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-dom": "^18.3.0 || ^19.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@kolkrabbi/kol-icons": "^0.
|
|
45
|
+
"@kolkrabbi/kol-icons": "^0.66.0"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"src",
|
package/src/index.js
CHANGED
|
@@ -176,6 +176,11 @@ export { MenuItem, MenuRow, MenuDivider, MenuFlyout, MenuDropdownItem, MenuDropd
|
|
|
176
176
|
export { Menu, MenuTrigger, MenuPanel, MenuLabel, MenuFilter, MenuDatePicker, MenuMore } from './molecules/Menu.jsx'
|
|
177
177
|
export { MenuPopover } from './molecules/MenuPopover.jsx'
|
|
178
178
|
export { ModalProvider, useModal, Dialog } from './molecules/Modal.jsx'
|
|
179
|
+
/* the generator settings window's controls (plan-2026-11-05-float-editor W7.2) — `Dialog variant="settings"`'s rows */
|
|
180
|
+
export {
|
|
181
|
+
SettingsGroup, SettingsGrid, SettingsCell, SettingsSlider, SettingsRange, SettingsSelect, SettingsSegmented, SettingsToggle,
|
|
182
|
+
SettingsText, SettingsPoint, SettingsRamp, SettingsRampHead, SettingsLights, SettingsFieldMap, SettingsDisclosure,
|
|
183
|
+
} from './molecules/SettingsControls.jsx'
|
|
179
184
|
export { default as Combobox } from './molecules/Combobox.jsx'
|
|
180
185
|
export { default as PaletteHarmonyWheel } from './molecules/PaletteHarmonyWheel.jsx'
|
|
181
186
|
export { default as PropertyInput } from './molecules/PropertyInput.jsx'
|
package/src/molecules/Modal.jsx
CHANGED
|
@@ -347,16 +347,85 @@ export function useModal() {
|
|
|
347
347
|
* @param {Element} [container] the portal target instead of `<body>` (float-operational W2, 2026-11-04): the layer turns
|
|
348
348
|
* `absolute` and fills it — a specimen box (`position: relative`, a height) shows the window open in place. Unset, unchanged.
|
|
349
349
|
*/
|
|
350
|
-
|
|
350
|
+
/*
|
|
351
|
+
* `variant="settings"` (plan-2026-11-05-float-editor W7.1 — his "Stripe Array settings modal", Figma 7K5v68l4tblHPFuiLdokRu
|
|
352
|
+
* 12:2282, 880 × 656): the generator's settings window. A 60 header (the `title` in Inter 14 semibold, `kind` beside it in
|
|
353
|
+
* the hint ink, `headerEnd` — the preset select — and the ×), a 156 section list on the primary surface (`sections`
|
|
354
|
+
* `[{ key, label, state }]` — the name and a one-line state, the lit one on oq-12 with a 2px marker; `section` /
|
|
355
|
+
* `onSection`), the body (`children`, 24 in, scrolling), an `aside` column 248 wide (the preview), and a 60 `footer`. The
|
|
356
|
+
* secondary surface, a 16 round, oq-16 rules between the parts — his frame draws them. `height` (default 656) and
|
|
357
|
+
* `width` (default 880) are its size; both shrink to the viewport.
|
|
358
|
+
* @param {string} [kind] settings: the line beside the title ("Generate")
|
|
359
|
+
* @param {ReactNode} [headerEnd] settings: the header's right side, before the × (the preset select)
|
|
360
|
+
* @param {Array} [sections] settings: `[{ key, label, state }]`
|
|
361
|
+
* @param {string} [section] · @param {Function} [onSection]
|
|
362
|
+
* @param {ReactNode} [aside] · @param {ReactNode} [footer] · @param {number} [height=656]
|
|
363
|
+
*/
|
|
364
|
+
export function Dialog({ open, onClose, title, width = 560, variant = 'lift', icon, onMinimise, blocking = true, container, kind, headerEnd, sections, section, onSection, aside, footer, height = 656, children }) {
|
|
351
365
|
const look = modalVariant(variant, 'lift')
|
|
352
366
|
const float = variant === 'float'
|
|
353
367
|
useEffect(() => {
|
|
354
368
|
if (!open) return undefined
|
|
355
|
-
const onKey = (e) => { if (e.key === 'Escape' && !document.querySelector('.kol-popover-float')) onClose() }
|
|
369
|
+
const onKey = (e) => { if (e.key === 'Escape' && !document.querySelector('.kol-popover-float, [data-state="open"].kol-dd-trigger')) onClose() }
|
|
356
370
|
window.addEventListener('keydown', onKey)
|
|
357
371
|
return () => window.removeEventListener('keydown', onKey)
|
|
358
372
|
}, [open, onClose])
|
|
359
373
|
if (!open || typeof document === 'undefined') return null
|
|
374
|
+
if (variant === 'settings') {
|
|
375
|
+
const within = container ? '100%' : '100vw'
|
|
376
|
+
const withinH = container ? '100%' : '100dvh'
|
|
377
|
+
return createPortal(
|
|
378
|
+
<div onMouseDown={blocking ? onClose : undefined} className={blocking ? 'kol-overlay-scrim' : 'pointer-events-none'}
|
|
379
|
+
style={{ position: container ? 'absolute' : 'fixed', inset: 0, zIndex: 150, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
380
|
+
<div role="dialog" aria-modal={blocking ? 'true' : undefined} aria-label={title} data-dialog onMouseDown={(e) => e.stopPropagation()}
|
|
381
|
+
className="kol-modal kol-settings-window pointer-events-auto flex flex-col overflow-hidden rounded-2xl border border-oq-16 bg-surface-secondary text-fg-96 font-(family-name:--kol-font-family-float) shadow-[var(--kol-shadow-float)]"
|
|
382
|
+
style={{ width: `min(${width}px, calc(${within} - 32px))`, height: `min(${height}px, calc(${withinH} - 32px))` }}>
|
|
383
|
+
<header className="flex items-center gap-4 h-[60px] shrink-0 pl-6 pr-[22px] border-b border-oq-16">
|
|
384
|
+
<h2 className="text-[14px] font-semibold leading-none">{title}</h2>
|
|
385
|
+
{kind && <span className="text-[11px] text-oq-64 leading-none mt-px">{kind}</span>}
|
|
386
|
+
<span className="flex-1" />
|
|
387
|
+
{headerEnd}
|
|
388
|
+
<button type="button" aria-label="Close" onClick={onClose}
|
|
389
|
+
className="ml-3 size-7 -mr-[7px] inline-flex items-center justify-center rounded-md text-[20px] leading-none text-oq-64 hover:text-(--kol-fg-96) hover:bg-(--kol-oq-08) focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">×</button>
|
|
390
|
+
</header>
|
|
391
|
+
<div className="flex flex-1 min-h-0">
|
|
392
|
+
{sections?.length > 0 && (
|
|
393
|
+
<nav aria-label="Settings" className="w-[156px] shrink-0 overflow-y-auto bg-surface-primary border-r border-oq-16 px-2 pt-[21px] pb-4">
|
|
394
|
+
<p className="pl-[10px] pb-[14px] text-[9px] font-medium leading-[11px] uppercase text-oq-64">Settings</p>
|
|
395
|
+
<div role="tablist" aria-orientation="vertical" className="flex flex-col gap-1.5"
|
|
396
|
+
onKeyDown={(e) => {
|
|
397
|
+
const dir = { ArrowDown: 1, ArrowUp: -1 }[e.key]
|
|
398
|
+
if (!dir) return
|
|
399
|
+
e.preventDefault()
|
|
400
|
+
const at = sections.findIndex((s) => s.key === section)
|
|
401
|
+
const next = sections[(at + dir + sections.length) % sections.length]
|
|
402
|
+
onSection?.(next.key)
|
|
403
|
+
e.currentTarget.querySelector(`[data-section="${next.key}"]`)?.focus()
|
|
404
|
+
}}>
|
|
405
|
+
{sections.map((s) => {
|
|
406
|
+
const lit = s.key === section
|
|
407
|
+
return (
|
|
408
|
+
<button key={s.key} type="button" role="tab" aria-selected={lit} data-section={s.key} tabIndex={lit ? 0 : -1}
|
|
409
|
+
onClick={() => onSection?.(s.key)}
|
|
410
|
+
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-oq-12' : 'hover:bg-(--kol-oq-08)'}`}>
|
|
411
|
+
{lit && <span aria-hidden="true" className="absolute left-0 top-[13px] h-[18px] w-0.5 rounded-[1px] bg-fg-96" />}
|
|
412
|
+
<span className={`text-[11px] leading-[13px] text-fg-96 ${lit ? 'font-medium' : ''}`}>{s.label}</span>
|
|
413
|
+
{s.state != null && <span className="text-[10px] leading-[12px] text-oq-64">{s.state}</span>}
|
|
414
|
+
</button>
|
|
415
|
+
)
|
|
416
|
+
})}
|
|
417
|
+
</div>
|
|
418
|
+
</nav>
|
|
419
|
+
)}
|
|
420
|
+
<div className="flex-1 min-w-0 overflow-y-auto pl-6 pr-5 pt-6 pb-6">{children}</div>
|
|
421
|
+
{aside && <aside className="w-[248px] shrink-0 mr-6 pt-6 pb-6 overflow-y-auto">{aside}</aside>}
|
|
422
|
+
</div>
|
|
423
|
+
{footer && <footer className="flex items-center gap-3 h-[60px] shrink-0 px-6 border-t border-oq-16">{footer}</footer>}
|
|
424
|
+
</div>
|
|
425
|
+
</div>,
|
|
426
|
+
container ?? document.body,
|
|
427
|
+
)
|
|
428
|
+
}
|
|
360
429
|
return createPortal(
|
|
361
430
|
<div
|
|
362
431
|
onMouseDown={blocking ? onClose : undefined}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import Input from '../atoms/Input.jsx'
|
|
2
|
+
import Button from '../atoms/Button.jsx'
|
|
3
|
+
import SegmentedToggle from '../atoms/SegmentedToggle.jsx'
|
|
4
|
+
import ToggleSwitch from '../atoms/ToggleSwitch.jsx'
|
|
5
|
+
import Dropdown from './Dropdown.jsx'
|
|
6
|
+
import Slider from './Slider.jsx'
|
|
7
|
+
|
|
8
|
+
/* taxonomy-ok: molecule — the settings window's controls, each a shipped atom in the window's dense look */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The SETTINGS controls — the generator settings window's rows (plan-2026-11-05-float-editor W7.2; his frame 12:2282,
|
|
12
|
+
* `Dialog variant="settings"`). His look, one rung: a 28 field on the primary surface behind an oq-16 rule, a 5 round,
|
|
13
|
+
* Inter 11 (readouts JetBrains Mono 10); a label above in Inter 10 at oq-64. Every part is a shipped control dressed for
|
|
14
|
+
* the window — Slider, the dual Slider, Dropdown, SegmentedToggle, ToggleSwitch, Input — not a second set.
|
|
15
|
+
*
|
|
16
|
+
* SettingsGroup a titled block (Inter 12 semibold) with a note at its right; `children` its rows; groups are
|
|
17
|
+
* ruled apart (`ruled`, default true)
|
|
18
|
+
* SettingsCell a labelled cell (`label` over the control) — a group lays them two-up (`SettingsGrid`)
|
|
19
|
+
* SettingsSlider the boxed slider: the float track and a mono readout (`format`)
|
|
20
|
+
* SettingsRange two handles on one track (From / To) — the dual Slider, boxed, both readouts
|
|
21
|
+
* SettingsSelect the boxed Dropdown (`options` `[{ value, label }]`)
|
|
22
|
+
* SettingsSegmented the boxed SegmentedToggle (Rows / Columns), the lit cell on oq-16
|
|
23
|
+
* SettingsToggle ToggleSwitch with its words
|
|
24
|
+
* SettingsText the boxed Input (text or number)
|
|
25
|
+
* SettingsPoint an X / Y pair of number fields
|
|
26
|
+
* SettingsRamp an A→B row: label · value A · curve · value B (`SettingsRampHead` the VALUE A · CURVE · VALUE B row)
|
|
27
|
+
* SettingsLights a list of points — X · Y · radius · intensity · delete — and Add light
|
|
28
|
+
* SettingsFieldMap the field's gradient strip: FIELD MAP over a 26 strip (`background`) and two captions
|
|
29
|
+
* SettingsDisclosure a group that starts closed (› More geometry … its note)
|
|
30
|
+
*
|
|
31
|
+
* `disabled` on any of them dims it to 40% and takes it out of the tab order (a control whose engine param does not
|
|
32
|
+
* exist yet). Keyboard is each shipped part's own: ← / → on a slider and on the segmented, Enter / Space on a select.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
const FIELD = 'h-7 w-full min-w-0 rounded-[5px] border border-oq-16 bg-surface-primary'
|
|
36
|
+
const INK = 'text-[11px] leading-[13px] text-fg-96 font-(family-name:--kol-font-family-float)'
|
|
37
|
+
const LABEL = 'text-[10px] leading-[12px] text-oq-64 font-(family-name:--kol-font-family-float)'
|
|
38
|
+
const MONO = 'font-(family-name:--kol-font-family-mono) text-[10px] leading-[12px] text-fg-96'
|
|
39
|
+
|
|
40
|
+
/* a disabled control: a fieldset disables every input and button inside it natively */
|
|
41
|
+
const Dim = ({ disabled, className = '', children, ...rest }) => (
|
|
42
|
+
<fieldset disabled={disabled || undefined} aria-disabled={disabled || undefined} {...rest}
|
|
43
|
+
className={`min-w-0 m-0 p-0 ${className.includes('border-oq-16') ? '' : 'border-0'} ${disabled ? 'opacity-40' : ''} ${className}`.trim()}>{children}</fieldset>
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
export function SettingsGroup({ title, note, ruled = true, className = '', children }) {
|
|
47
|
+
return (
|
|
48
|
+
<section className={`flex flex-col ${ruled ? 'pb-[22px] mb-[18px] border-b border-oq-16 last:border-b-0 last:mb-0' : ''} ${className}`.trim()}>
|
|
49
|
+
{(title || note) && (
|
|
50
|
+
<header className="flex items-baseline justify-between gap-4 pr-3 pb-[15px]">
|
|
51
|
+
{title && <h3 className="text-[12px] leading-[15px] font-semibold text-fg-96 font-(family-name:--kol-font-family-float)">{title}</h3>}
|
|
52
|
+
{note && <span className={LABEL}>{note}</span>}
|
|
53
|
+
</header>
|
|
54
|
+
)}
|
|
55
|
+
{children}
|
|
56
|
+
</section>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const SettingsGrid = ({ className = '', children }) => <div className={`grid grid-cols-2 gap-x-3 gap-y-[7px] ${className}`.trim()}>{children}</div>
|
|
61
|
+
|
|
62
|
+
export function SettingsCell({ label, span = 1, disabled, className = '', children, ...rest }) {
|
|
63
|
+
return (
|
|
64
|
+
<Dim disabled={disabled} className={`flex flex-col gap-1.5 ${span === 2 ? 'col-span-2' : ''} ${className}`.trim()} {...rest}>
|
|
65
|
+
{label && <span className={LABEL}>{label}</span>}
|
|
66
|
+
{children}
|
|
67
|
+
</Dim>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function SettingsSlider({ value, onChange, min = 0, max = 1, step = 0.01, format = (v) => String(v), disabled, 'aria-label': ariaLabel }) {
|
|
72
|
+
return (
|
|
73
|
+
<Dim disabled={disabled} className={`${FIELD} flex items-center gap-3 pl-[9px] pr-2`}>
|
|
74
|
+
<Slider variant="float" readout="none" value={value} onChange={onChange} min={min} max={max} step={step} disabled={disabled}
|
|
75
|
+
aria-label={ariaLabel} className="flex-1 min-w-0 [&_.kol-slider-float]:h-4" />
|
|
76
|
+
<span className={`${MONO} w-[52px] shrink-0 tabular-nums`}>{format(value)}</span>
|
|
77
|
+
</Dim>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function SettingsRange({ value = [0, 1], onChange, min = 0, max = 1, step = 0.01, format = (v) => String(v), disabled, 'aria-label': ariaLabel }) {
|
|
82
|
+
const [a, b] = value
|
|
83
|
+
return (
|
|
84
|
+
<Dim disabled={disabled} className={`${FIELD} flex items-center gap-2 px-2`}>
|
|
85
|
+
<span className={`${MONO} shrink-0 tabular-nums`}>{format(a)}</span>
|
|
86
|
+
<Slider variant="dual" value={a} value2={b} min={min} max={max} step={step} aria-label={ariaLabel}
|
|
87
|
+
onChange={(v) => onChange?.([Math.min(v, b), b])} onChange2={(v) => onChange?.([a, Math.max(v, a)])}
|
|
88
|
+
label1="" label2="" className="flex-1 min-w-0" />
|
|
89
|
+
<span className={`${MONO} shrink-0 tabular-nums`}>{format(b)}</span>
|
|
90
|
+
</Dim>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function SettingsSelect({ value, onChange, options = [], disabled, ariaLabel, className = '' }) {
|
|
95
|
+
return (
|
|
96
|
+
<Dim disabled={disabled} className="w-full">
|
|
97
|
+
<Dropdown value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} size="sm"
|
|
98
|
+
className={`w-full [&_.kol-dd-trigger]:w-full [&_.kol-dd-trigger]:!h-7 [&_.kol-dd-trigger]:!rounded-[5px] [&_.kol-dd-trigger]:!border [&_.kol-dd-trigger]:!border-(--kol-oq-16) [&_.kol-dd-trigger]:!bg-(--kol-surface-primary) [&_.kol-dd-trigger]:!px-2 [&_.kol-dd-trigger]:!text-[11px] [&_.kol-dd-trigger]:!font-normal [&_.kol-dd-trigger]:!text-(--kol-fg-96) [&_.kol-dd-trigger]:font-(family-name:--kol-font-family-float) [&_.kol-dd-trigger]:justify-between [&_.kol-dd-caret]:text-(--kol-oq-64) ${className}`.trim()} />
|
|
99
|
+
</Dim>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function SettingsSegmented({ value, onChange, options = [], disabled, ariaLabel }) {
|
|
104
|
+
return (
|
|
105
|
+
<Dim disabled={disabled} className={`${FIELD} p-0.5`}>
|
|
106
|
+
<SegmentedToggle value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} size="sm"
|
|
107
|
+
className="!flex w-full h-full !border-0 !bg-transparent !p-0 gap-0 [&_.kol-seg-cell]:flex-1 [&_.kol-seg-cell]:h-full [&_.kol-seg-cell]:!rounded-[3px] [&_.kol-seg-cell]:!border-0 [&_.kol-seg-cell]:!bg-transparent [&_.kol-seg-cell]:!text-[10px] [&_.kol-seg-cell]:!text-(--kol-oq-64) [&_.kol-seg-cell]:font-(family-name:--kol-font-family-float) [&_.kol-seg-cell.is-active]:!bg-(--kol-oq-16) [&_.kol-seg-cell.is-active]:!text-(--kol-fg-96) [&_.kol-seg-cell.is-active]:font-medium" />
|
|
108
|
+
</Dim>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function SettingsToggle({ label, checked, onChange, disabled }) {
|
|
113
|
+
return (
|
|
114
|
+
<Dim disabled={disabled} className="flex items-center gap-2 h-7">
|
|
115
|
+
<ToggleSwitch checked={!!checked} onChange={onChange} aria-label={label} disabled={disabled} />
|
|
116
|
+
{label && <span className={INK}>{label}</span>}
|
|
117
|
+
</Dim>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function SettingsText({ value, onChange, onCommit, type = 'text', placeholder, disabled, 'aria-label': ariaLabel, className = '' }) {
|
|
122
|
+
return (
|
|
123
|
+
<Dim disabled={disabled} className="w-full">
|
|
124
|
+
<Input variant="outline" size="sm" type={type} value={value ?? ''} placeholder={placeholder} aria-label={ariaLabel}
|
|
125
|
+
onChange={onChange ? (e) => onChange(type === 'number' ? Number(e.target.value) : e.target.value) : undefined}
|
|
126
|
+
onCommit={onCommit} disabled={disabled}
|
|
127
|
+
className={`${FIELD} !px-2 !py-0 [&_input]:text-[11px] [&_input]:text-(--kol-fg-96) [&_input]:font-(family-name:--kol-font-family-float) ${className}`.trim()} />
|
|
128
|
+
</Dim>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function SettingsPoint({ value = [0.5, 0.5], onChange, min, max, step = 0.01, disabled, 'aria-label': ariaLabel }) {
|
|
133
|
+
const [x, y] = value
|
|
134
|
+
const clamp = (n) => Math.min(max ?? Infinity, Math.max(min ?? -Infinity, n))
|
|
135
|
+
const field = (axis, v, set) => (
|
|
136
|
+
<label className={`${FIELD} flex items-center gap-1.5 px-2`}>
|
|
137
|
+
<span className={LABEL} aria-hidden="true">{axis}</span>
|
|
138
|
+
<input type="number" value={v} min={min} max={max} step={step} disabled={disabled} aria-label={`${ariaLabel ?? 'Point'} ${axis}`}
|
|
139
|
+
onChange={(e) => { const n = Number(e.target.value); if (Number.isFinite(n)) set(clamp(n)) }}
|
|
140
|
+
className={`${INK} w-full min-w-0 bg-transparent border-0 p-0 focus:outline-none tabular-nums`} />
|
|
141
|
+
</label>
|
|
142
|
+
)
|
|
143
|
+
return (
|
|
144
|
+
<Dim disabled={disabled} className="grid grid-cols-2 gap-2">
|
|
145
|
+
{field('X', x, (n) => onChange?.([n, y]))}
|
|
146
|
+
{field('Y', y, (n) => onChange?.([x, n]))}
|
|
147
|
+
</Dim>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export const SettingsRampHead = () => (
|
|
152
|
+
<div className="grid grid-cols-[88px_minmax(0,87fr)_minmax(0,122fr)_minmax(0,87fr)] gap-x-2 pb-0.5" aria-hidden="true">
|
|
153
|
+
<span />
|
|
154
|
+
{['Value A', 'Curve', 'Value B'].map((t) => <span key={t} className={`${LABEL} uppercase text-center`}>{t}</span>)}
|
|
155
|
+
</div>
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
export function SettingsRamp({ label, value = { a: 0, b: 1, curve: 'linear' }, onChange, curves = [], disabled, partial, ...rest }) {
|
|
159
|
+
const set = (k) => (v) => onChange?.({ ...value, [k]: v })
|
|
160
|
+
const num = (k) => (
|
|
161
|
+
<input type="number" value={value[k]} aria-label={`${label} value ${k.toUpperCase()}`} disabled={disabled || partial?.[k]}
|
|
162
|
+
onChange={(e) => { const n = Number(e.target.value); if (Number.isFinite(n)) set(k)(n) }}
|
|
163
|
+
className={`${FIELD} ${INK} px-2 focus:outline-none focus-visible:shadow-[var(--kol-float-focus)] tabular-nums ${partial?.[k] ? 'opacity-40' : ''}`} />
|
|
164
|
+
)
|
|
165
|
+
return (
|
|
166
|
+
<Dim disabled={disabled} className="grid grid-cols-[88px_minmax(0,87fr)_minmax(0,122fr)_minmax(0,87fr)] gap-x-2 items-center" {...rest}>
|
|
167
|
+
<span className={`${INK} !text-(--kol-oq-64)`}>{label}</span>
|
|
168
|
+
{num('a')}
|
|
169
|
+
<div className={partial?.curve ? 'opacity-40' : ''}>
|
|
170
|
+
<SettingsSelect value={value.curve} onChange={set('curve')} options={curves} ariaLabel={`${label} curve`} disabled={disabled || partial?.curve} />
|
|
171
|
+
</div>
|
|
172
|
+
{num('b')}
|
|
173
|
+
</Dim>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function SettingsLights({ value = [], onChange, disabled }) {
|
|
178
|
+
const set = (i, k, n) => onChange?.(value.map((l, j) => (j === i ? { ...l, [k]: n } : l)))
|
|
179
|
+
const cell = (i, k, v, label, step = 0.01) => (
|
|
180
|
+
<input type="number" value={v} step={step} aria-label={`Light ${i + 1} ${label}`}
|
|
181
|
+
onChange={(e) => { const n = Number(e.target.value); if (Number.isFinite(n)) set(i, k, n) }}
|
|
182
|
+
className={`${FIELD} ${INK} px-2 focus:outline-none focus-visible:shadow-[var(--kol-float-focus)] tabular-nums`} />
|
|
183
|
+
)
|
|
184
|
+
return (
|
|
185
|
+
<Dim disabled={disabled} className="flex flex-col gap-1">
|
|
186
|
+
<div className="grid grid-cols-[1fr_1fr_1fr_1fr_28px] gap-x-2 pb-0.5" aria-hidden="true">
|
|
187
|
+
{['X', 'Y', 'Radius', 'Intensity'].map((t) => <span key={t} className={`${LABEL} uppercase`}>{t}</span>)}
|
|
188
|
+
<span />
|
|
189
|
+
</div>
|
|
190
|
+
{value.map((l, i) => (
|
|
191
|
+
<div key={i} className="grid grid-cols-[1fr_1fr_1fr_1fr_28px] gap-x-2 items-center">
|
|
192
|
+
{cell(i, 'x', l.x, 'X')}{cell(i, 'y', l.y, 'Y')}{cell(i, 'radius', l.radius, 'radius')}{cell(i, 'intensity', l.intensity, 'intensity')}
|
|
193
|
+
<Button tone="ghost" quiet size="xs" iconOnly="trash" aria-label={`Delete light ${i + 1}`} onClick={() => onChange?.(value.filter((_, j) => j !== i))} />
|
|
194
|
+
</div>
|
|
195
|
+
))}
|
|
196
|
+
<button type="button" onClick={() => onChange?.([...value, { x: 0.5, y: 0.5, radius: 0.3, intensity: 1 }])}
|
|
197
|
+
className={`${INK} self-start h-7 px-2 rounded-[5px] hover:bg-(--kol-oq-08) focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]`}>+ Add light</button>
|
|
198
|
+
</Dim>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function SettingsFieldMap({ background, left, right, label = 'Field map' }) {
|
|
203
|
+
return (
|
|
204
|
+
<div className="flex flex-col">
|
|
205
|
+
<span className={`${LABEL} uppercase pb-[9px]`}>{label}</span>
|
|
206
|
+
<div className="h-[26px] rounded-[4px] bg-surface-primary" style={{ background }} role="img" aria-label={`${label}: ${left ?? ''}`} />
|
|
207
|
+
<div className="flex justify-between gap-2 pt-2.5 pr-6">
|
|
208
|
+
<span className={INK}>{left}</span>
|
|
209
|
+
<span className={`${LABEL} !text-(--kol-fg-64)`}>{right}</span>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function SettingsDisclosure({ label, note, open, onToggle, children }) {
|
|
216
|
+
return (
|
|
217
|
+
<section className="flex flex-col">
|
|
218
|
+
<button type="button" aria-expanded={!!open} onClick={() => onToggle?.(!open)}
|
|
219
|
+
className="flex items-center gap-[11px] h-[19px] pr-3 text-left rounded focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
|
|
220
|
+
<span aria-hidden="true" className={`text-[16px] leading-[19px] text-oq-64 transition-transform ${open ? 'rotate-90' : ''}`}>›</span>
|
|
221
|
+
<span className={`${INK} font-medium`}>{label}</span>
|
|
222
|
+
{note && <span className={`${LABEL} ml-auto`}>{note}</span>}
|
|
223
|
+
</button>
|
|
224
|
+
{open && <div className="pt-4 flex flex-col gap-[7px]">{children}</div>}
|
|
225
|
+
</section>
|
|
226
|
+
)
|
|
227
|
+
}
|
|
@@ -2,8 +2,7 @@ import { useEffect, useId, useRef, useState } from 'react'
|
|
|
2
2
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
3
3
|
import SearchInput from '../molecules/SearchInput.jsx'
|
|
4
4
|
import Tag from '../atoms/Tag.jsx'
|
|
5
|
-
import
|
|
6
|
-
import OptionRow from '../molecules/OptionRow.jsx'
|
|
5
|
+
import TabsRow from '../molecules/TabsRow.jsx'
|
|
7
6
|
import Button from '../atoms/Button.jsx'
|
|
8
7
|
import { floatSurfaceClass } from '../utilities/tone.js'
|
|
9
8
|
import { floatMotion } from '../utilities/motion.js'
|
|
@@ -14,6 +13,9 @@ import { shortcutInScope } from './ShortcutsOverlay.jsx'
|
|
|
14
13
|
* geometry — the p-2 inset, then the md control's 1px ring + 16px pad — so
|
|
15
14
|
* every glyph and word lines up under the field's icon and caret. */
|
|
16
15
|
|
|
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
|
+
|
|
17
19
|
/* Rows bucketed by `group` in first-seen order, rank kept inside a group —
|
|
18
20
|
* one heading per group; arrows rove this order, not the engine's. */
|
|
19
21
|
function groupRows(rows) {
|
|
@@ -152,10 +154,17 @@ function unfold(rows, opened) {
|
|
|
152
154
|
* @param {string} [selectLabel] the footer's Enter line while a row is highlighted (default
|
|
153
155
|
* `Go to page`) — a modal whose rows are not pages says what
|
|
154
156
|
* Enter does instead (the rack's module search: `Add module`)
|
|
155
|
-
* @param {'solid'|'glass-dark'|'glass-light'} [surface]
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* the
|
|
157
|
+
* @param {'solid'|'glass-dark'|'glass-light'} [surface='solid'] ONE SEARCH STYLE (plan-2026-11-05-float-editor 7.7, his
|
|
158
|
+
* frame float-more 30:914 — *"anchored search (along with same style regular search)"*):
|
|
159
|
+
* every search modal is the float card — RailTrigger's (`kol-more-sheet-float` on
|
|
160
|
+
* `--kol-float-menu-r`, the float surface and shadow), the float SearchInput, the float
|
|
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`)
|
|
159
168
|
* @param {boolean|Object} [motion=true] with `surface`, the card fades and scales in and out over a fading scrim, held in
|
|
160
169
|
* the tree while it leaves (FloatActionStatesAndMotion, 2026-11-04): `true` the
|
|
161
170
|
* `--kol-float-*` tokens · `false` none · `{ duration, ease }` per app
|
|
@@ -187,10 +196,13 @@ export default function CommandOverlay({
|
|
|
187
196
|
mode = 'search',
|
|
188
197
|
shortcuts = [],
|
|
189
198
|
currentPath,
|
|
190
|
-
surface,
|
|
199
|
+
surface = 'solid',
|
|
200
|
+
tabs,
|
|
201
|
+
anchor,
|
|
202
|
+
shortcutHint,
|
|
191
203
|
motion = true,
|
|
192
204
|
}) {
|
|
193
|
-
const float =
|
|
205
|
+
const float = true
|
|
194
206
|
const fm = floatMotion(motion)
|
|
195
207
|
const presence = useFloatPresence(open, float ? fm.ms : 0)
|
|
196
208
|
const exit = float && presence.exiting ? '' : undefined
|
|
@@ -209,7 +221,21 @@ export default function CommandOverlay({
|
|
|
209
221
|
if (mode === 'go') mode = 'search'
|
|
210
222
|
const placeholder = placeholderProp ?? MODE_PLACEHOLDER[mode] ?? 'Search…'
|
|
211
223
|
const selectLabel = selectLabelProp ?? MODE_LABEL[mode] ?? 'Go to page'
|
|
212
|
-
const
|
|
224
|
+
const [tab, setTab] = useState(null)
|
|
225
|
+
const tabNow = tabs?.some((t) => t.id === tab) ? tab : tabs?.[0]?.id
|
|
226
|
+
const inTab = (r) => !tabs || (tabNow === tabs[0].id ? !r.tabOnly : r.tab === tabNow)
|
|
227
|
+
const base = mode === 'shortcuts' ? shortcutFolds(shortcuts, currentPath) : groupRows((query ? rawResults : suggestions).filter(inTab))
|
|
228
|
+
/* the anchored card: the anchor's left and width, 16 over its top — read as it draws (a hidden first frame could not
|
|
229
|
+
* take the focus), and again on resize */
|
|
230
|
+
const [, reflow] = useState(0)
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
if (!open || !anchor) return undefined
|
|
233
|
+
const on = () => reflow((n) => n + 1)
|
|
234
|
+
window.addEventListener('resize', on)
|
|
235
|
+
return () => window.removeEventListener('resize', on)
|
|
236
|
+
}, [open, anchor])
|
|
237
|
+
const anchorRect = presence.mounted && anchor ? (anchor.current ?? anchor)?.getBoundingClientRect?.() : null
|
|
238
|
+
const place = anchorRect ? { left: anchorRect.left, width: anchorRect.width, bottom: window.innerHeight - anchorRect.top + 16 } : null
|
|
213
239
|
const results = unfold(base, opened)
|
|
214
240
|
/* a `disabled` row is drawn but never active: ↑↓ step over it, Enter and click never reach
|
|
215
241
|
* `onSelect` (ShellSearchDisabledRow, kol-monitor 2026-10-15 — a module with no room on the rack) */
|
|
@@ -228,7 +254,7 @@ export default function CommandOverlay({
|
|
|
228
254
|
const prev = document.activeElement
|
|
229
255
|
;(panelRef.current?.querySelector('input') ?? panelRef.current)?.focus()
|
|
230
256
|
setOpened(new Set(base.filter((r) => r.items && r.open).map((r) => r.id)))
|
|
231
|
-
return () => { setOpened(new Set()); if (prev instanceof HTMLElement) prev.focus() }
|
|
257
|
+
return () => { setOpened(new Set()); setTab(null); if (prev instanceof HTMLElement) prev.focus() }
|
|
232
258
|
}, [open])
|
|
233
259
|
|
|
234
260
|
/* Roving row resets to the top on every query change / reopen — and when the ROWS change under an
|
|
@@ -237,7 +263,7 @@ export default function CommandOverlay({
|
|
|
237
263
|
* consumer passing a fresh array every render does not snap the highlight back to the top. */
|
|
238
264
|
/* the BASE rows, not the unfolded ones: opening a category must not throw the highlight back to the top */
|
|
239
265
|
const rowsKey = base.map((r) => r.id).join('\u0000')
|
|
240
|
-
useEffect(() => { setActiveIndex(Math.max(0, results.findIndex((r) => !r.disabled))); setNavigated(false) }, [query, open, rowsKey]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
266
|
+
useEffect(() => { setActiveIndex(Math.max(0, results.findIndex((r) => !r.disabled))); setNavigated(false) }, [query, open, rowsKey, tabNow]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
241
267
|
|
|
242
268
|
/* Keep the active row visible inside the scrolling list. */
|
|
243
269
|
useEffect(() => {
|
|
@@ -313,22 +339,33 @@ export default function CommandOverlay({
|
|
|
313
339
|
if (active >= 0) select(results[active])
|
|
314
340
|
else onExpand?.()
|
|
315
341
|
} else if (e.key === 'Tab') {
|
|
316
|
-
/* Focus trap — the input is the search modal's only tab stop
|
|
342
|
+
/* Focus trap — the input is the search modal's only tab stop; with `tabs`, Tab / ⇧Tab step through them */
|
|
317
343
|
e.preventDefault()
|
|
344
|
+
if (tabs?.length) {
|
|
345
|
+
const at = tabs.findIndex((t) => t.id === tabNow)
|
|
346
|
+
setTab(tabs[(at + (e.shiftKey ? -1 : 1) + tabs.length) % tabs.length].id)
|
|
347
|
+
}
|
|
318
348
|
}
|
|
319
349
|
}
|
|
320
350
|
|
|
351
|
+
/* the foot's hints — his "↑↓ Navigate · ↵ Run · Esc Close"; Enter's word names what Enter does NOW */
|
|
352
|
+
const enterWord = results.length > 0
|
|
353
|
+
? (results[active]?.fold ? (opened.has(results[active].id) ? 'Collapse' : 'Expand') : noField ? 'Collapse' : selectLabel)
|
|
354
|
+
: 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
|
+
|
|
321
358
|
return (
|
|
322
|
-
<div className=
|
|
359
|
+
<div className={`fixed inset-0 ${place ? '' : 'flex items-start justify-center pt-[20vh]'}`} style={{ zIndex: 'var(--kol-z-modal, 100)', ...fm.style }}>
|
|
323
360
|
{/* A BUTTON, not a div (OverlayScrimTapDismiss, 2026-09-01): iOS Safari
|
|
324
361
|
* does not bubble tap-clicks from non-interactive elements, so the div's
|
|
325
362
|
* onClick never fired on a phone and the only way out was the close
|
|
326
363
|
* control. A button always fires — and it ends the other half of the
|
|
327
|
-
* defect, an interactive target carrying `aria-hidden`. */}
|
|
364
|
+
* defect, an interactive target carrying `aria-hidden`. Anchored, the page stays undimmed. */}
|
|
328
365
|
<button
|
|
329
366
|
type="button"
|
|
330
367
|
aria-label="Close search"
|
|
331
|
-
className={`absolute inset-0
|
|
368
|
+
className={`absolute inset-0 ${place ? 'cursor-default' : 'kol-overlay-scrim kol-float-fade'}`}
|
|
332
369
|
data-exit={exit}
|
|
333
370
|
onClick={onClose}
|
|
334
371
|
/>
|
|
@@ -341,7 +378,9 @@ export default function CommandOverlay({
|
|
|
341
378
|
aria-modal="true"
|
|
342
379
|
aria-label="Search"
|
|
343
380
|
data-exit={exit}
|
|
344
|
-
|
|
381
|
+
data-side={place ? 'top' : undefined}
|
|
382
|
+
style={place ? { position: 'fixed', left: place.left, width: place.width, bottom: place.bottom } : undefined}
|
|
383
|
+
className={`kol-command kol-more-sheet kol-more-sheet-float kol-float-chrome kol-float-motion ${floatSurfaceClass(surface, true)} overflow-hidden ${place ? '' : `relative w-full mx-4 ${expanded ? 'max-w-[var(--kol-content-panel)]' : 'max-w-xl'}`} ${noField ? 'outline-none' : ''}`.replace(/\s+/g, ' ').trim()}
|
|
345
384
|
>
|
|
346
385
|
{/* THE MODE, said out loud (user 2026-08-01: "how do you set search
|
|
347
386
|
* mode? theres no helper, message or mode clearly readble"). Two
|
|
@@ -349,34 +388,36 @@ export default function CommandOverlay({
|
|
|
349
388
|
* to a destination) — and the only signal was whether chips happened
|
|
350
389
|
* to be present. The chips ARE the mode, so they get a label. */}
|
|
351
390
|
{chips.length > 0 && (
|
|
352
|
-
<div className="flex flex-wrap items-center gap-1.5 px-
|
|
353
|
-
<span className="kol-
|
|
391
|
+
<div className="flex flex-wrap items-center gap-1.5 px-3 pt-2 pb-1">
|
|
392
|
+
<span className="kol-float-label text-oq-64 shrink-0">Filtering by</span>
|
|
354
393
|
{chips.map((t) => (
|
|
355
394
|
<Tag key={t} onRemove={() => onRemoveChip?.(t)}>{t}</Tag>
|
|
356
395
|
))}
|
|
357
396
|
</div>
|
|
358
397
|
)}
|
|
359
|
-
{/* A REAL FIELD, inset in the panel (2026-09-30, shadcn's search modal as
|
|
360
|
-
* the aim) — the flush `bare` strip read as a hole, not a control. */}
|
|
361
|
-
{!noField && (
|
|
362
|
-
<div className={`${float ? '' : 'kol-tone-grey '}p-2 flex items-center gap-2`}>
|
|
363
398
|
{/* THE BACK ARROW TAKES THE SEARCH GLYPH'S SLOT (user 2026-10-18: *"why would the back move the input?!"*) —
|
|
364
399
|
* a button beside the field shrank it and shifted the caret on every drill-in */}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
400
|
+
{!noField && (
|
|
401
|
+
<SearchInput
|
|
402
|
+
className="w-full min-w-0"
|
|
403
|
+
value={query}
|
|
404
|
+
onChange={(e) => onQueryChange?.(e.target.value)}
|
|
405
|
+
placeholder={chips.length > 0 ? 'Narrow these results…' : placeholder}
|
|
406
|
+
onKeyDown={handleKeyDown}
|
|
407
|
+
onBack={back}
|
|
408
|
+
backLabel={backLabel}
|
|
409
|
+
shortcutHint={shortcutHint}
|
|
410
|
+
variant="float"
|
|
411
|
+
size="lg"
|
|
412
|
+
role="combobox"
|
|
413
|
+
aria-expanded={results.length > 0}
|
|
414
|
+
aria-controls={listId}
|
|
415
|
+
aria-activedescendant={active >= 0 ? optionId(results[active]) : undefined}
|
|
416
|
+
/>
|
|
417
|
+
)}
|
|
418
|
+
{/* his tabs — All · Actions · Tools · Pages — the float TabsRow under the field */}
|
|
419
|
+
{tabs?.length > 0 && !expanded && (
|
|
420
|
+
<TabsRow variant="float" size="md" tabs={tabs} value={tabNow} onChange={setTab} className="pt-2" />
|
|
380
421
|
)}
|
|
381
422
|
|
|
382
423
|
{/* WHY THIS IS NOT `molecules/Dropdown` (asked 2026-08-01). Dropdown is
|
|
@@ -384,14 +425,14 @@ export default function CommandOverlay({
|
|
|
384
425
|
* options. This is a COMBOBOX — a text query filtering a live list
|
|
385
426
|
* whose rows carry a `group`, a `hint`, and may fire an `action`
|
|
386
427
|
* instead of selecting a value. Same ARIA family, different control.
|
|
387
|
-
* Folding one into the other would mean giving Dropdown a query, a
|
|
388
|
-
* hint slot and an action escape hatch, i.e. building this inside it.
|
|
389
428
|
*
|
|
390
|
-
* THE ROW CONTRACT
|
|
429
|
+
* THE ROW CONTRACT:
|
|
391
430
|
* label the row's text, match-highlighted against the query
|
|
392
|
-
* group section heading the row files under — 'Atoms', '
|
|
431
|
+
* group section heading the row files under — 'Atoms', 'Recent', 'Pages'
|
|
432
|
+
* tab the `tabs` id it shows under (every row shows under the first); `tabOnly` — only under its own
|
|
433
|
+
* (an empty Actions tab lists every action, which All leaves to Recent)
|
|
393
434
|
* icon optional leading glyph (kol-icons name)
|
|
394
|
-
* hint
|
|
435
|
+
* hint the right-hand line — a key, a page, what matched when the LABEL did not
|
|
395
436
|
* href a destination; dismisses the search modal
|
|
396
437
|
* action a closure, run by the consumer's `onSelect`; the search modal STAYS OPEN (tag rows)
|
|
397
438
|
* disabled drawn muted, skipped by ↑↓, never reaches `onSelect`; `disabledHint` replaces
|
|
@@ -400,106 +441,60 @@ export default function CommandOverlay({
|
|
|
400
441
|
* its items, a "← All" row back); the consumer swaps `suggestions`/`results`
|
|
401
442
|
* Built by `buildShellSearchItems` (showcase/src/nav/shell-nav.js). */}
|
|
402
443
|
{expanded ? (
|
|
403
|
-
<div className="border-t border-fg-08 max-h-[70vh] overflow-y-auto">{children}</div>
|
|
444
|
+
<div className="border-t border-fg-08 max-h-[70vh] overflow-y-auto" style={RULE}>{children}</div>
|
|
404
445
|
) : results.length > 0 && (
|
|
405
446
|
/* FIXED BODY HEIGHT — the panel holds still while the list narrows. */
|
|
406
|
-
<ul
|
|
407
|
-
ref={listRef}
|
|
408
|
-
id={listId}
|
|
409
|
-
role="listbox"
|
|
410
|
-
className={float ? 'h-80 overflow-y-auto' : `kol-tone-grey h-80 overflow-y-auto px-2 pb-2${noField ? ' pt-2' : ''}`}
|
|
411
|
-
>
|
|
447
|
+
<ul ref={listRef} id={listId} role="listbox" className="h-80 overflow-y-auto">
|
|
412
448
|
{results.map((item, i) => {
|
|
413
449
|
const heading = (item.group ?? '') !== (results[i - 1]?.group ?? '') || i === 0
|
|
414
450
|
return (
|
|
415
451
|
<li key={item.id} role="presentation">
|
|
416
452
|
{heading && item.group && (
|
|
417
453
|
/* the rail's eyebrow (user 2026-10-18: *"sections shoudl be uppercase eyebrow like in siderail"*) */
|
|
418
|
-
<p className=
|
|
454
|
+
<p className="kol-eyebrow text-oq-64 px-3 pt-3 pb-2">{item.group}</p>
|
|
419
455
|
)}
|
|
420
|
-
{float
|
|
421
|
-
|
|
422
|
-
<Button
|
|
423
|
-
id={optionId(item)}
|
|
424
|
-
role="option"
|
|
425
|
-
aria-selected={i === active}
|
|
426
|
-
aria-disabled={item.disabled || undefined}
|
|
427
|
-
tabIndex={-1}
|
|
428
|
-
variant="nav"
|
|
429
|
-
size="lg"
|
|
430
|
-
className={`kol-btn-float w-full justify-start${i === active ? ' kol-btn-pressed' : ''}`}
|
|
431
|
-
onMouseDown={(e) => e.preventDefault()}
|
|
432
|
-
onClick={() => select(item)}
|
|
433
|
-
onMouseEnter={() => { if (!item.disabled) { setActiveIndex(i); setNavigated(true) } }}
|
|
434
|
-
>
|
|
435
|
-
{/* the glyph drawn here, not as `iconLeft` — Button would wrap it and the label in a span that does not take the row */}
|
|
436
|
-
<span className="flex min-w-0 flex-1 items-center" style={{ gap: 'var(--kol-float-gap-ic)' }}>
|
|
437
|
-
{item.indent ? <span className="inline-block w-4 shrink-0" /> : item.icon && <Icon name={item.icon} size="var(--kol-float-ic)" className="shrink-0" />}
|
|
438
|
-
<span className="truncate text-left"><HighlightMatch label={item.label} query={query} ranges={item.highlights} /></span>
|
|
439
|
-
{((item.disabled && item.disabledHint) || item.hint) && <span className="kol-float-hint ml-auto truncate text-oq-64">{(item.disabled && item.disabledHint) || item.hint}</span>}
|
|
440
|
-
</span>
|
|
441
|
-
</Button>
|
|
442
|
-
) : (
|
|
443
|
-
<OptionRow
|
|
456
|
+
{/* the float row: RailTrigger's card row, lit on the float selection while it is the cursor */}
|
|
457
|
+
<Button
|
|
444
458
|
id={optionId(item)}
|
|
445
459
|
role="option"
|
|
446
460
|
aria-selected={i === active}
|
|
447
461
|
aria-disabled={item.disabled || undefined}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
leading={item.indent ? <span className="inline-block w-4" /> : undefined}
|
|
453
|
-
label={<HighlightMatch label={item.label} query={query} ranges={item.highlights} />}
|
|
454
|
-
hint={(item.disabled && item.disabledHint) || item.hint}
|
|
455
|
-
/* preventDefault keeps focus in the input through the click */
|
|
462
|
+
tabIndex={-1}
|
|
463
|
+
variant="nav"
|
|
464
|
+
size="lg"
|
|
465
|
+
className={`kol-btn-float w-full justify-start${i === active ? ' kol-btn-pressed' : ''}${item.disabled ? ' opacity-40' : ''}`}
|
|
456
466
|
onMouseDown={(e) => e.preventDefault()}
|
|
457
467
|
onClick={() => select(item)}
|
|
458
468
|
onMouseEnter={() => { if (!item.disabled) { setActiveIndex(i); setNavigated(true) } }}
|
|
459
|
-
|
|
460
|
-
|
|
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' ? <Icon 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>
|
|
461
477
|
</li>
|
|
462
478
|
)
|
|
463
479
|
})}
|
|
464
480
|
</ul>
|
|
465
481
|
)}
|
|
466
|
-
{/* THE
|
|
482
|
+
{/* THE FOOT — his key hints under a rule that runs the card's full width; it always says what Enter does. */}
|
|
467
483
|
{!expanded && (results.length > 0 || (query && (enterLabel || onOpenResults))) && (
|
|
468
|
-
<div className="border-t border-fg-08 py-
|
|
469
|
-
{
|
|
470
|
-
|
|
471
|
-
{(
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
{/* the second action on the same line, right — ⌘↵, the footer's idiom for "the other one" */}
|
|
479
|
-
{folds.length > 0 && !query && (
|
|
480
|
-
<button
|
|
481
|
-
type="button"
|
|
482
|
-
className="ml-auto flex items-center gap-2 text-fg-48 hover:text-fg-default transition-colors cursor-pointer"
|
|
483
|
-
onMouseDown={(e) => e.preventDefault()}
|
|
484
|
-
onClick={toggleAll}
|
|
485
|
-
>
|
|
486
|
-
<Kbd icon="command"><Icon name="corner-down-left" size={12} /></Kbd>
|
|
487
|
-
{allOpen ? 'Collapse all' : 'Expand all'}
|
|
488
|
-
</button>
|
|
489
|
-
)}
|
|
490
|
-
</p>
|
|
484
|
+
<div className="kol-float-hint flex flex-wrap items-center gap-x-5 gap-y-1 border-t border-fg-08 py-3 pointer-coarse:min-h-11" style={RULE}>
|
|
485
|
+
{results.length > 1 && <span className={hint}><span aria-hidden>↑↓</span>Navigate</span>}
|
|
486
|
+
{enterWord && <span className={hint}><span aria-hidden>↵</span>{enterWord}</span>}
|
|
487
|
+
<button type="button" className={hintBtn} onMouseDown={(e) => e.preventDefault()} onClick={onClose}><span aria-hidden>Esc</span>Close</button>
|
|
488
|
+
{/* ⌘↵ — the other one: every fold open or shut, or THE RESULTS LINK (user 2026-10-01: *"make 'all
|
|
489
|
+
* results...' at the bottom also be a link to the results page"*) — the door ⌘Enter opens */}
|
|
490
|
+
{folds.length > 0 && !query && (
|
|
491
|
+
<button type="button" className={`${hintBtn} ml-auto`} onMouseDown={(e) => e.preventDefault()} onClick={toggleAll}>
|
|
492
|
+
<span aria-hidden>⌘↵</span>{allOpen ? 'Collapse all' : 'Expand all'}
|
|
493
|
+
</button>
|
|
491
494
|
)}
|
|
492
|
-
{/* THE RESULTS LINE IS A LINK (user 2026-10-01: *"make 'all results...' at the bottom
|
|
493
|
-
* also be a link to the results page"*) — the same door ⌘Enter opens. */}
|
|
494
495
|
{query && onOpenResults && (
|
|
495
|
-
<button
|
|
496
|
-
|
|
497
|
-
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"
|
|
498
|
-
onMouseDown={(e) => e.preventDefault()}
|
|
499
|
-
onClick={() => { onOpenResults(query); onClose?.() }}
|
|
500
|
-
>
|
|
501
|
-
<Kbd icon="command"><Icon name="corner-down-left" size={12} /></Kbd>
|
|
502
|
-
{resultsLabel}
|
|
496
|
+
<button type="button" className={`${hintBtn} ml-auto min-w-0`} onMouseDown={(e) => e.preventDefault()} onClick={() => { onOpenResults(query); onClose?.() }}>
|
|
497
|
+
<span aria-hidden>⌘↵</span><span className="truncate">{resultsLabel}</span>
|
|
503
498
|
</button>
|
|
504
499
|
)}
|
|
505
500
|
</div>
|