@kolkrabbi/kol-component 0.343.0 → 0.345.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 +1 -1
- package/src/index.js +1 -1
- package/src/molecules/AlignmentGrid.jsx +2 -2
- package/src/molecules/ButtonGroup.jsx +153 -13
- package/src/molecules/PageControls.jsx +2 -2
- package/src/molecules/SegmentedToggle.jsx +16 -0
- package/src/molecules/SettingsControls.jsx +2 -2
- package/src/molecules/VariantsControl.jsx +2 -2
- package/src/organisms/CommandOverlay.jsx +113 -118
- package/src/organisms/CompareGrid.jsx +3 -3
- package/src/organisms/MediaGalleryModes.jsx +2 -2
- package/src/organisms/RailKit.jsx +2 -2
- package/src/atoms/SegmentedToggle.jsx +0 -132
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -68,7 +68,7 @@ export { default as SearchInput } from './molecules/SearchInput.jsx'
|
|
|
68
68
|
export { default as InspectorSection, default as Section } from './molecules/InspectorSection.jsx'
|
|
69
69
|
export { default as SectionText, SECTION_TEXT_LEVELS } from './molecules/SectionText.jsx'
|
|
70
70
|
export { default as SectionLabel } from './atoms/SectionLabel.jsx'
|
|
71
|
-
export { default as SegmentedToggle } from './
|
|
71
|
+
export { default as SegmentedToggle } from './molecules/SegmentedToggle.jsx'
|
|
72
72
|
/* a page's variants — the pinned slider button and its panel of segmented rows (OneVariantsControl, 2026-10-29; catalog's) */
|
|
73
73
|
export { default as VariantsControl } from './molecules/VariantsControl.jsx'
|
|
74
74
|
export { default as Stepper } from './molecules/Stepper.jsx'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
2
|
-
import
|
|
2
|
+
import ButtonGroup from './ButtonGroup.jsx'
|
|
3
3
|
import { glyphSize } from '../hooks/glyphLadders.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -42,7 +42,7 @@ export default function AlignmentGrid({ onAlign, items = ALIGN_BUTTONS, size = '
|
|
|
42
42
|
const cells = strip(axis)
|
|
43
43
|
if (!cells.length) return null
|
|
44
44
|
return (
|
|
45
|
-
<
|
|
45
|
+
<ButtonGroup layout="joined"
|
|
46
46
|
key={axis}
|
|
47
47
|
variant="filled"
|
|
48
48
|
size={size}
|
|
@@ -1,20 +1,95 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ButtonGroup —
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* (nothing is cloned, no props injected); all button behavior lives on each
|
|
6
|
-
* Button. `center` (default) hugs its content and self-centers; `left` /
|
|
7
|
-
* `right` stay full-width block. Alignment classes come from static lookup
|
|
8
|
-
* maps of complete literals — never interpolated — so Tailwind's scanner
|
|
9
|
-
* sees them.
|
|
2
|
+
* ButtonGroup — the one component for a group of buttons (plan-2026-11-06-buttons-page 2.7; the user,
|
|
3
|
+
* 2026-11-06: *"button group CAN be segmented toggle … just by the fact it wraps multiple buttons"*).
|
|
4
|
+
* Three layouts:
|
|
10
5
|
*
|
|
6
|
+
* layout="row" (default) — a responsive layout wrapper for a group of Buttons: stacked full-width on
|
|
7
|
+
* mobile, a horizontal row from `sm` up, aligned left / center / right. Pure layout —
|
|
8
|
+
* children compose at the call site and render as-is (nothing is cloned, no props
|
|
9
|
+
* injected); all button behavior lives on each Button. `center` (default) hugs its
|
|
10
|
+
* content and self-centers; `left` / `right` stay full-width block. Alignment classes
|
|
11
|
+
* come from static lookup maps of complete literals — never interpolated — so
|
|
12
|
+
* Tailwind's scanner sees them.
|
|
13
|
+
* layout="stack" — the same wrapper, stacked at every width (the row's 8 stacked gap).
|
|
14
|
+
* layout="joined" — the segmented control (was `SegmentedToggle`, kept as its alias on the retirement
|
|
15
|
+
* ledger): joined cells, no gap, built from `options` instead of children. See below.
|
|
16
|
+
*
|
|
17
|
+
* row / stack props:
|
|
11
18
|
* @param {'left'|'center'|'right'} align horizontal alignment + container layout mode (default 'center')
|
|
12
19
|
* @param {string} title optional heading rendered above the group, authored at the call site
|
|
13
20
|
* @param {string} className extra container classes (appended) — note this lands on the OUTER
|
|
14
21
|
* container, not the flex row that carries the gap; the gap is responsive by default (8 stacked,
|
|
15
22
|
* 16 as a row) rather than reachable, so there is nothing to reach for.
|
|
16
23
|
* @param {ReactNode} children the Buttons
|
|
24
|
+
*
|
|
25
|
+
* layout="joined" — N-way segmented control. Joined cells sharing one outer stroke; thin dividers
|
|
26
|
+
* between cells; no gap. Active cell fills with surface-secondary + text-emphasis, inactive is
|
|
27
|
+
* text-meta with hover lifting. Chrome comes from .kol-seg* in kol-theme (NOT Tailwind utilities —
|
|
28
|
+
* those never generate from package sources).
|
|
29
|
+
*
|
|
30
|
+
* <ButtonGroup layout="joined"
|
|
31
|
+
* value={current}
|
|
32
|
+
* onChange={setCurrent}
|
|
33
|
+
* options={[{ value, label }]}
|
|
34
|
+
* />
|
|
35
|
+
*
|
|
36
|
+
* Companion to `ViewToggle`:
|
|
37
|
+
* - ViewToggle (text) — bare segmented buttons separated by gap; no shared shell.
|
|
38
|
+
* - ViewToggle (icon) — inset-well row of square icon buttons.
|
|
39
|
+
* - ButtonGroup joined — flat segmented strip with shared border + dividers.
|
|
40
|
+
*
|
|
41
|
+
* Labels accept any node — pass strings or inline SVG previews. Optional `ariaLabel` per option for
|
|
42
|
+
* non-text labels.
|
|
43
|
+
*
|
|
44
|
+
* A11y: radiogroup/radio semantics with a roving tabindex — Tab enters the group on the active cell,
|
|
45
|
+
* ←/→ (or ↑/↓) move selection + focus.
|
|
46
|
+
*
|
|
47
|
+
* Props (joined):
|
|
48
|
+
* value — current option value. `null`/`undefined` = STATELESS mode
|
|
49
|
+
* (the segmented state law, 2026-08-12): role `group`, no
|
|
50
|
+
* aria-checked, no selected styling — a pure one-shot ACTION
|
|
51
|
+
* strip (canvas alignment, transform cluster); onChange is the
|
|
52
|
+
* action dispatch.
|
|
53
|
+
* onChange — handler (newValue) => void
|
|
54
|
+
* options — [{ value, label, ariaLabel?, tooltip?, disabled?, count? }] — a cell whose label is not a string
|
|
55
|
+
* (a glyph) shows its `ariaLabel` as a KOL Tooltip; `tooltip` overrides it.
|
|
56
|
+
* `count` (float-everything W2 row 26, 2026-11-04): a number after the label, mono one step down,
|
|
57
|
+
* 12 off the label — `Open 5`; drawn on `variant="float"` (`.kol-seg-count`), ignored elsewhere.
|
|
58
|
+
* `disabled` (kol-fxr 2026-10-09): the cell draws the family's disabled ink
|
|
59
|
+
* (`aria-disabled`, not the attribute — the tooltip still gives the reason),
|
|
60
|
+
* refuses the press, and ←/→ step over it. It may still be the current `value`
|
|
61
|
+
* (the ground changed under it): selected + disabled, no throw.
|
|
62
|
+
* variant — 'default' — BORDERLESS (2026-10-29, the user: *"WE DONT USE BORDER, almost NEVER … DONT USE FUCKING
|
|
63
|
+
* BORDER unless I APPROVE it"*): the `sunken` tone, no outer stroke, the selected cell on the sunken
|
|
64
|
+
* ground. A choice is a Dropdown or text tabs first; a toggle that stays is this one |
|
|
65
|
+
* 'outlined' (the old default: shared outer stroke + dividers, filled active cell — only where he has
|
|
66
|
+
* approved a border) | 'filled' (the state law's tiles: every
|
|
67
|
+
* cell a surface-secondary tile with 1px transparent gaps, NO
|
|
68
|
+
* outline shell; the inset ring marks ONLY the selected cell) |
|
|
69
|
+
* 'tonal' (filled tiles, but the clicked cell marks itself by
|
|
70
|
+
* TONE — surface-tertiary fill, no ring; 2026-08-12).
|
|
71
|
+
* 'float' (W16, round 3 — 2026-10-31): a capsule track 6 in on its `surface`, pills 4 apart at the
|
|
72
|
+
* float heights (28/36/44, touch 36/44/52), the selected pill filled with the ink.
|
|
73
|
+
* Every other variant renders at the SAME pinned button-ladder
|
|
74
|
+
* height (22/26/32/40) — icon or text, the box never moves.
|
|
75
|
+
* size — mirrors Button exactly: 'sm' (26px, mono-12, 4/12 pad) |
|
|
76
|
+
* 'md' (default, 32px, mono-14, 6/16 pad) | 'lg' (40px,
|
|
77
|
+
* mono-16, 8/20 pad). Same cell padding + mono type as the
|
|
78
|
+
* matching `.kol-btn-{sm,md,lg}`, so a segmented strip lines
|
|
79
|
+
* up with a Button of the same size.
|
|
80
|
+
* tone — the ground (segmented-toggle-sunken-tone, kol-client-olina 2026-09-03: the one
|
|
81
|
+
* control ControlToneSunken skipped; kol-fxr and olina carried the same three CSS
|
|
82
|
+
* lines to fake it). `sunken` (alias `inverse`): shell border transparent, the
|
|
83
|
+
* selected cell on `--kol-surface-sunken` / `fg-96`, rest cells as the default paints
|
|
84
|
+
* them; `filled` and `tonal` keep their own selected law. Through `toneClass`, so a
|
|
85
|
+
* `kol-tone-sunken` wrapper reaches it too. Unset = inherit.
|
|
86
|
+
* surface — `variant="float"` only: 'solid' (default) | 'glass-dark' | 'glass-light' — the track's material
|
|
87
|
+
* (`floatSurfaceClass`, kol-theme `.kol-float-*`)
|
|
88
|
+
* ariaLabel — accessible name for the group
|
|
89
|
+
* className — additional classes on the outer shell
|
|
17
90
|
*/
|
|
91
|
+
import { toneClass, floatSurfaceClass } from '../utilities/tone.js'
|
|
92
|
+
import { Tooltip } from '../utilities/Popover.jsx'
|
|
18
93
|
|
|
19
94
|
const CONTAINER = {
|
|
20
95
|
left: 'flex flex-col w-full',
|
|
@@ -28,7 +103,8 @@ const JUSTIFY = {
|
|
|
28
103
|
right: 'sm:justify-end',
|
|
29
104
|
}
|
|
30
105
|
|
|
31
|
-
export default function ButtonGroup({ align = 'center', title, className = '', children }) {
|
|
106
|
+
export default function ButtonGroup({ layout = 'row', align = 'center', title, className = '', children, ...joined }) {
|
|
107
|
+
if (layout === 'joined') return <Joined className={className} {...joined} />
|
|
32
108
|
return (
|
|
33
109
|
<div className={[CONTAINER[align] || CONTAINER.center, className].filter(Boolean).join(' ')}>
|
|
34
110
|
{title && <h3 className="kol-sans-heading-05 text-emphasis mb-6">{title}</h3>}
|
|
@@ -42,13 +118,77 @@ export default function ButtonGroup({ align = 'center', title, className = '', c
|
|
|
42
118
|
* big, at least lets see 8 or 12"), and 8 is what looks right on device.
|
|
43
119
|
* A responsive default rather than a prop — the stacked case IS the
|
|
44
120
|
* narrow viewport, so the value is pickable once instead of per
|
|
45
|
-
* consumer. The row keeps today's 16 and nothing moves at `sm` and up.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
121
|
+
* consumer. The row keeps today's 16 and nothing moves at `sm` and up.
|
|
122
|
+
* `stack` keeps the stacked half at every width. */
|
|
123
|
+
layout === 'stack' ? 'flex flex-col gap-2' : 'flex flex-col gap-2 sm:flex-row sm:gap-4 sm:items-center',
|
|
124
|
+
layout === 'stack' ? '' : JUSTIFY[align] || JUSTIFY.center,
|
|
125
|
+
].filter(Boolean).join(' ')}
|
|
49
126
|
>
|
|
50
127
|
{children}
|
|
51
128
|
</div>
|
|
52
129
|
</div>
|
|
53
130
|
)
|
|
54
131
|
}
|
|
132
|
+
|
|
133
|
+
/* layout="joined" — the segmented control (SegmentedToggle's implementation, moved here 2026-11-06) */
|
|
134
|
+
function Joined({ value, onChange, options = [], variant = 'default', size = 'md', tone = 'default', surface = 'solid', ariaLabel, className = '' }) {
|
|
135
|
+
const float = variant === 'float'
|
|
136
|
+
const cellType = { xs: 'kol-mono-8', sm: 'kol-mono-12', md: 'kol-mono-14', lg: 'kol-mono-16' }[size]
|
|
137
|
+
const stateless = value == null
|
|
138
|
+
const focusIdx = Math.max(0, options.findIndex((opt) => opt.value === value))
|
|
139
|
+
|
|
140
|
+
const handleKeyDown = (e) => {
|
|
141
|
+
if (stateless) return // plain button row — Tab moves focus, arrows do nothing
|
|
142
|
+
const dir = { ArrowLeft: -1, ArrowUp: -1, ArrowRight: 1, ArrowDown: 1 }[e.key]
|
|
143
|
+
if (!dir || !options.length) return
|
|
144
|
+
e.preventDefault()
|
|
145
|
+
let next = focusIdx
|
|
146
|
+
for (let step = 0; step < options.length; step++) {
|
|
147
|
+
next = (next + dir + options.length) % options.length
|
|
148
|
+
if (!options[next].disabled) break
|
|
149
|
+
}
|
|
150
|
+
if (options[next].disabled) return
|
|
151
|
+
onChange?.(options[next].value)
|
|
152
|
+
e.currentTarget.children[next]?.focus()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* the default draws borderless — the sunken tone — unless a tone is asked for; `outlined` keeps the stroke */
|
|
156
|
+
const resolvedTone = variant === 'default' && tone === 'default' ? 'sunken' : tone
|
|
157
|
+
return (
|
|
158
|
+
<div
|
|
159
|
+
role={stateless ? 'group' : 'radiogroup'}
|
|
160
|
+
aria-label={ariaLabel}
|
|
161
|
+
onKeyDown={handleKeyDown}
|
|
162
|
+
className={[
|
|
163
|
+
'kol-seg',
|
|
164
|
+
(variant === 'filled' || variant === 'tonal') && 'kol-seg--filled',
|
|
165
|
+
variant === 'tonal' && 'kol-seg--tonal',
|
|
166
|
+
size !== 'md' && `kol-seg--${size}`,
|
|
167
|
+
float && `kol-seg--float ${floatSurfaceClass(surface)}`,
|
|
168
|
+
toneClass(resolvedTone),
|
|
169
|
+
className,
|
|
170
|
+
].filter(Boolean).join(' ')}
|
|
171
|
+
>
|
|
172
|
+
{options.map((opt, i) => {
|
|
173
|
+
const isActive = !stateless && opt.value === value
|
|
174
|
+
return (
|
|
175
|
+
<Tooltip key={opt.value} asChild label={opt.tooltip ?? (typeof opt.label === 'string' ? null : opt.ariaLabel)}>
|
|
176
|
+
<button
|
|
177
|
+
type="button"
|
|
178
|
+
role={stateless ? undefined : 'radio'}
|
|
179
|
+
aria-checked={stateless ? undefined : isActive}
|
|
180
|
+
aria-label={opt.ariaLabel}
|
|
181
|
+
aria-disabled={opt.disabled || undefined}
|
|
182
|
+
tabIndex={stateless ? 0 : (i === focusIdx ? 0 : -1)}
|
|
183
|
+
onClick={opt.disabled ? undefined : () => onChange?.(opt.value)}
|
|
184
|
+
className={['kol-seg-cell', cellType, isActive && 'is-active'].filter(Boolean).join(' ')}
|
|
185
|
+
>
|
|
186
|
+
{opt.label}
|
|
187
|
+
{float && opt.count != null && <span className="kol-seg-count">{opt.count}</span>}
|
|
188
|
+
</button>
|
|
189
|
+
</Tooltip>
|
|
190
|
+
)
|
|
191
|
+
})}
|
|
192
|
+
</div>
|
|
193
|
+
)
|
|
194
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Tag from '../atoms/Tag.jsx'
|
|
2
|
-
import
|
|
2
|
+
import ButtonGroup from './ButtonGroup.jsx'
|
|
3
3
|
import TabsRow from './TabsRow.jsx'
|
|
4
4
|
|
|
5
5
|
/* taxonomy-ok: molecule — composes Tag, SegmentedToggle (atoms) and TabsRow (a molecule of chips) into one strip */
|
|
@@ -44,7 +44,7 @@ export default function PageControls({ toggles, views = [], count, jump, legend,
|
|
|
44
44
|
</div>
|
|
45
45
|
)}
|
|
46
46
|
{views.map((v) => (
|
|
47
|
-
<
|
|
47
|
+
<ButtonGroup layout="joined" key={v.label} ariaLabel={v.label} size="sm" value={v.value} onChange={v.onChange} options={v.options} />
|
|
48
48
|
))}
|
|
49
49
|
{count != null && <span className="kol-mono-12 text-fg-48 ml-auto">{count}</span>}
|
|
50
50
|
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated 2026-11-06 — alias of `<ButtonGroup layout="joined">` (plan-2026-11-06-buttons-page 2.7). Drops when nobody imports it (04-retirements.md).
|
|
3
|
+
* SegmentedToggle — Old name for the joined ButtonGroup. Same props, same DOM: the implementation lives
|
|
4
|
+
* in ButtonGroup's `joined` layout; this alias is kept so a consumer's next bump does not break.
|
|
5
|
+
*/
|
|
6
|
+
import ButtonGroup from './ButtonGroup.jsx'
|
|
7
|
+
|
|
8
|
+
let warned = false
|
|
9
|
+
|
|
10
|
+
export default function SegmentedToggle(props) {
|
|
11
|
+
if (import.meta.env?.DEV && !warned) {
|
|
12
|
+
warned = true
|
|
13
|
+
console.warn('SegmentedToggle is deprecated — use <ButtonGroup layout="joined">')
|
|
14
|
+
}
|
|
15
|
+
return <ButtonGroup layout="joined" {...props} />
|
|
16
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Input from '../atoms/Input.jsx'
|
|
2
2
|
import Button from '../atoms/Button.jsx'
|
|
3
|
-
import
|
|
3
|
+
import ButtonGroup from './ButtonGroup.jsx'
|
|
4
4
|
import ToggleSwitch from '../atoms/ToggleSwitch.jsx'
|
|
5
5
|
import Dropdown from './Dropdown.jsx'
|
|
6
6
|
import Slider from './Slider.jsx'
|
|
@@ -103,7 +103,7 @@ export function SettingsSelect({ value, onChange, options = [], disabled, ariaLa
|
|
|
103
103
|
export function SettingsSegmented({ value, onChange, options = [], disabled, ariaLabel }) {
|
|
104
104
|
return (
|
|
105
105
|
<Dim disabled={disabled} className={`${FIELD} p-0.5`}>
|
|
106
|
-
<
|
|
106
|
+
<ButtonGroup layout="joined" value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} size="sm"
|
|
107
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
108
|
</Dim>
|
|
109
109
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
|
2
2
|
import Button from '../atoms/Button.jsx'
|
|
3
|
-
import
|
|
3
|
+
import ButtonGroup from './ButtonGroup.jsx'
|
|
4
4
|
import { usePopover, PopoverPanel } from '../utilities/Popover.jsx'
|
|
5
5
|
|
|
6
6
|
const cap = (v) => String(v).charAt(0).toUpperCase() + String(v).slice(1)
|
|
@@ -80,7 +80,7 @@ export default function VariantsControl({ axes = [], value = {}, onChange, child
|
|
|
80
80
|
<span key={`${a.key}-l`} className="kol-mono-12 text-fg-64">{a.label}</span>,
|
|
81
81
|
/* a row wider than the panel (a phone, a long axis) scrolls sideways in its cell — every option still one tap away */
|
|
82
82
|
<div key={a.key} className="min-w-0 overflow-x-auto">
|
|
83
|
-
<
|
|
83
|
+
<ButtonGroup layout="joined" size="sm" className="w-max min-w-full" ariaLabel={a.label} value={value[a.key]} onChange={(v) => onChange?.(a.key, v)}
|
|
84
84
|
options={a.options ?? (a.values ?? []).map((v) => ({ value: v, label: cap(v) }))} />
|
|
85
85
|
</div>,
|
|
86
86
|
])}
|
|
@@ -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>
|
|
@@ -2,7 +2,7 @@ import { useMemo, useState } from 'react'
|
|
|
2
2
|
import IconPlate from '../atoms/IconPlate.jsx'
|
|
3
3
|
import IconToggle from '../atoms/IconToggle.jsx'
|
|
4
4
|
import Pill from '../atoms/Pill.jsx'
|
|
5
|
-
import
|
|
5
|
+
import ButtonGroup from '../molecules/ButtonGroup.jsx'
|
|
6
6
|
import ViewToggle from '../atoms/ViewToggle.jsx'
|
|
7
7
|
|
|
8
8
|
/* taxonomy-ok: organism — a toolbar of atoms over a wall of IconPlate pairs */
|
|
@@ -71,11 +71,11 @@ export default function CompareGrid({ items = [], labels = { a: 'A', b: 'B' }, d
|
|
|
71
71
|
return (
|
|
72
72
|
<div className={`flex flex-col gap-6 ${className}`.trim()}>
|
|
73
73
|
<div className="flex flex-wrap items-center gap-4">
|
|
74
|
-
<
|
|
74
|
+
<ButtonGroup layout="joined" ariaLabel="Size" value={size} onChange={setSize} options={SIZES.map((v) => ({ value: v, label: String(v) }))} size="sm" />
|
|
75
75
|
<ViewToggle variant="icon" options={GROUNDS} viewMode={ground} onViewChange={setGround} />
|
|
76
76
|
<IconToggle icon="grid" label="Guide" title="Keyline guide" pressed={guide} onChange={setGuide} size="sm" />
|
|
77
77
|
{hasStates && (
|
|
78
|
-
<
|
|
78
|
+
<ButtonGroup layout="joined"
|
|
79
79
|
ariaLabel="Show"
|
|
80
80
|
value={filter}
|
|
81
81
|
onChange={setFilter}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
|
-
import
|
|
2
|
+
import ButtonGroup from '../molecules/ButtonGroup.jsx'
|
|
3
3
|
import GalleryCarousel from './GalleryCarousel.jsx'
|
|
4
4
|
import MediaTileGallery from './MediaTileGallery.jsx'
|
|
5
5
|
import MediaViewer from './MediaViewer.jsx'
|
|
@@ -38,7 +38,7 @@ export default function MediaGalleryModes({
|
|
|
38
38
|
<div className="flex items-center justify-between gap-4">
|
|
39
39
|
{title ? <span className="kol-helper-12 text-meta">{title}</span> : <span />}
|
|
40
40
|
{modes.length > 1 && (
|
|
41
|
-
<
|
|
41
|
+
<ButtonGroup layout="joined" size="sm" ariaLabel="View" value={mode} onChange={setMode}
|
|
42
42
|
options={modes.map((m) => ({ value: m, label: LABELS[m] }))} />
|
|
43
43
|
)}
|
|
44
44
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ButtonGroup from '../molecules/ButtonGroup.jsx'
|
|
2
2
|
import Button from '../atoms/Button.jsx'
|
|
3
3
|
import { Tooltip } from '../utilities/Popover.jsx'
|
|
4
4
|
import { RAIL_ROW } from '../hooks/railRow.js'
|
|
@@ -50,7 +50,7 @@ export function RailHeader({ title, subtitle, actions }) {
|
|
|
50
50
|
|
|
51
51
|
/** RailTabs — segmented tabs across the rail: `tabs` `[{ value, label }]`, controlled by `value` / `onChange`. */
|
|
52
52
|
export function RailTabs({ tabs = [], value, onChange, ariaLabel = 'Tabs', className = '' }) {
|
|
53
|
-
return <
|
|
53
|
+
return <ButtonGroup layout="joined" size="sm" className={`w-full ${className}`.trim()} options={tabs} value={value} onChange={onChange} ariaLabel={ariaLabel} />
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/** RailHint — one quiet line of guidance under a row or a group; a sentence, never a label. */
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SegmentedToggle — N-way segmented control. Joined cells sharing one
|
|
3
|
-
* outer stroke; thin dividers between cells; no gap. Active cell fills
|
|
4
|
-
* with surface-secondary + text-emphasis, inactive is text-meta with
|
|
5
|
-
* hover lifting. Chrome comes from .kol-seg* in kol-theme (NOT Tailwind
|
|
6
|
-
* utilities — those never generate from package sources).
|
|
7
|
-
*
|
|
8
|
-
* <SegmentedToggle
|
|
9
|
-
* value={current}
|
|
10
|
-
* onChange={setCurrent}
|
|
11
|
-
* options={[{ value, label }]}
|
|
12
|
-
* />
|
|
13
|
-
*
|
|
14
|
-
* Companion to `ViewToggle`:
|
|
15
|
-
* - ViewToggle (text) — bare segmented buttons separated by gap; no shared shell.
|
|
16
|
-
* - ViewToggle (icon) — inset-well row of square icon buttons.
|
|
17
|
-
* - SegmentedToggle — flat segmented strip with shared border + dividers.
|
|
18
|
-
*
|
|
19
|
-
* Labels accept any node — pass strings or inline SVG previews. Optional
|
|
20
|
-
* `ariaLabel` per option for non-text labels.
|
|
21
|
-
*
|
|
22
|
-
* A11y: radiogroup/radio semantics with a roving tabindex — Tab enters
|
|
23
|
-
* the group on the active cell, ←/→ (or ↑/↓) move selection + focus.
|
|
24
|
-
*
|
|
25
|
-
* Props:
|
|
26
|
-
* value — current option value. `null`/`undefined` = STATELESS mode
|
|
27
|
-
* (the segmented state law, 2026-08-12): role `group`, no
|
|
28
|
-
* aria-checked, no selected styling — a pure one-shot ACTION
|
|
29
|
-
* strip (canvas alignment, transform cluster); onChange is the
|
|
30
|
-
* action dispatch.
|
|
31
|
-
* onChange — handler (newValue) => void
|
|
32
|
-
* options — [{ value, label, ariaLabel?, tooltip?, disabled?, count? }] — a cell whose label is not a string
|
|
33
|
-
* (a glyph) shows its `ariaLabel` as a KOL Tooltip; `tooltip` overrides it.
|
|
34
|
-
* `count` (float-everything W2 row 26, 2026-11-04): a number after the label, mono one step down,
|
|
35
|
-
* 12 off the label — `Open 5`; drawn on `variant="float"` (`.kol-seg-count`), ignored elsewhere.
|
|
36
|
-
* `disabled` (kol-fxr 2026-10-09): the cell draws the family's disabled ink
|
|
37
|
-
* (`aria-disabled`, not the attribute — the tooltip still gives the reason),
|
|
38
|
-
* refuses the press, and ←/→ step over it. It may still be the current `value`
|
|
39
|
-
* (the ground changed under it): selected + disabled, no throw.
|
|
40
|
-
* variant — 'default' — BORDERLESS (2026-10-29, the user: *"WE DONT USE BORDER, almost NEVER … DONT USE FUCKING
|
|
41
|
-
* BORDER unless I APPROVE it"*): the `sunken` tone, no outer stroke, the selected cell on the sunken
|
|
42
|
-
* ground. A choice is a Dropdown or text tabs first; a toggle that stays is this one |
|
|
43
|
-
* 'outlined' (the old default: shared outer stroke + dividers, filled active cell — only where he has
|
|
44
|
-
* approved a border) | 'filled' (the state law's tiles: every
|
|
45
|
-
* cell a surface-secondary tile with 1px transparent gaps, NO
|
|
46
|
-
* outline shell; the inset ring marks ONLY the selected cell) |
|
|
47
|
-
* 'tonal' (filled tiles, but the clicked cell marks itself by
|
|
48
|
-
* TONE — surface-tertiary fill, no ring; 2026-08-12).
|
|
49
|
-
* 'float' (W16, round 3 — 2026-10-31): a capsule track 6 in on its `surface`, pills 4 apart at the
|
|
50
|
-
* float heights (28/36/44, touch 36/44/52), the selected pill filled with the ink.
|
|
51
|
-
* Every other variant renders at the SAME pinned button-ladder
|
|
52
|
-
* height (22/26/32/40) — icon or text, the box never moves.
|
|
53
|
-
* size — mirrors Button exactly: 'sm' (26px, mono-12, 4/12 pad) |
|
|
54
|
-
* 'md' (default, 32px, mono-14, 6/16 pad) | 'lg' (40px,
|
|
55
|
-
* mono-16, 8/20 pad). Same cell padding + mono type as the
|
|
56
|
-
* matching `.kol-btn-{sm,md,lg}`, so a segmented strip lines
|
|
57
|
-
* up with a Button of the same size.
|
|
58
|
-
* tone — the ground (segmented-toggle-sunken-tone, kol-client-olina 2026-09-03: the one
|
|
59
|
-
* control ControlToneSunken skipped; kol-fxr and olina carried the same three CSS
|
|
60
|
-
* lines to fake it). `sunken` (alias `inverse`): shell border transparent, the
|
|
61
|
-
* selected cell on `--kol-surface-sunken` / `fg-96`, rest cells as the default paints
|
|
62
|
-
* them; `filled` and `tonal` keep their own selected law. Through `toneClass`, so a
|
|
63
|
-
* `kol-tone-sunken` wrapper reaches it too. Unset = inherit.
|
|
64
|
-
* surface — `variant="float"` only: 'solid' (default) | 'glass-dark' | 'glass-light' — the track's material
|
|
65
|
-
* (`floatSurfaceClass`, kol-theme `.kol-float-*`)
|
|
66
|
-
* ariaLabel — accessible name for the group
|
|
67
|
-
* className — additional classes on the outer shell
|
|
68
|
-
*/
|
|
69
|
-
import { toneClass, floatSurfaceClass } from '../utilities/tone.js'
|
|
70
|
-
import { Tooltip } from '../utilities/Popover.jsx'
|
|
71
|
-
|
|
72
|
-
export default function SegmentedToggle({ value, onChange, options = [], variant = 'default', size = 'md', tone = 'default', surface = 'solid', ariaLabel, className = '' }) {
|
|
73
|
-
const float = variant === 'float'
|
|
74
|
-
const cellType = { xs: 'kol-mono-8', sm: 'kol-mono-12', md: 'kol-mono-14', lg: 'kol-mono-16' }[size]
|
|
75
|
-
const stateless = value == null
|
|
76
|
-
const focusIdx = Math.max(0, options.findIndex((opt) => opt.value === value))
|
|
77
|
-
|
|
78
|
-
const handleKeyDown = (e) => {
|
|
79
|
-
if (stateless) return // plain button row — Tab moves focus, arrows do nothing
|
|
80
|
-
const dir = { ArrowLeft: -1, ArrowUp: -1, ArrowRight: 1, ArrowDown: 1 }[e.key]
|
|
81
|
-
if (!dir || !options.length) return
|
|
82
|
-
e.preventDefault()
|
|
83
|
-
let next = focusIdx
|
|
84
|
-
for (let step = 0; step < options.length; step++) {
|
|
85
|
-
next = (next + dir + options.length) % options.length
|
|
86
|
-
if (!options[next].disabled) break
|
|
87
|
-
}
|
|
88
|
-
if (options[next].disabled) return
|
|
89
|
-
onChange?.(options[next].value)
|
|
90
|
-
e.currentTarget.children[next]?.focus()
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/* the default draws borderless — the sunken tone — unless a tone is asked for; `outlined` keeps the stroke */
|
|
94
|
-
const resolvedTone = variant === 'default' && tone === 'default' ? 'sunken' : tone
|
|
95
|
-
return (
|
|
96
|
-
<div
|
|
97
|
-
role={stateless ? 'group' : 'radiogroup'}
|
|
98
|
-
aria-label={ariaLabel}
|
|
99
|
-
onKeyDown={handleKeyDown}
|
|
100
|
-
className={[
|
|
101
|
-
'kol-seg',
|
|
102
|
-
(variant === 'filled' || variant === 'tonal') && 'kol-seg--filled',
|
|
103
|
-
variant === 'tonal' && 'kol-seg--tonal',
|
|
104
|
-
size !== 'md' && `kol-seg--${size}`,
|
|
105
|
-
float && `kol-seg--float ${floatSurfaceClass(surface)}`,
|
|
106
|
-
toneClass(resolvedTone),
|
|
107
|
-
className,
|
|
108
|
-
].filter(Boolean).join(' ')}
|
|
109
|
-
>
|
|
110
|
-
{options.map((opt, i) => {
|
|
111
|
-
const isActive = !stateless && opt.value === value
|
|
112
|
-
return (
|
|
113
|
-
<Tooltip key={opt.value} asChild label={opt.tooltip ?? (typeof opt.label === 'string' ? null : opt.ariaLabel)}>
|
|
114
|
-
<button
|
|
115
|
-
type="button"
|
|
116
|
-
role={stateless ? undefined : 'radio'}
|
|
117
|
-
aria-checked={stateless ? undefined : isActive}
|
|
118
|
-
aria-label={opt.ariaLabel}
|
|
119
|
-
aria-disabled={opt.disabled || undefined}
|
|
120
|
-
tabIndex={stateless ? 0 : (i === focusIdx ? 0 : -1)}
|
|
121
|
-
onClick={opt.disabled ? undefined : () => onChange?.(opt.value)}
|
|
122
|
-
className={['kol-seg-cell', cellType, isActive && 'is-active'].filter(Boolean).join(' ')}
|
|
123
|
-
>
|
|
124
|
-
{opt.label}
|
|
125
|
-
{float && opt.count != null && <span className="kol-seg-count">{opt.count}</span>}
|
|
126
|
-
</button>
|
|
127
|
-
</Tooltip>
|
|
128
|
-
)
|
|
129
|
-
})}
|
|
130
|
-
</div>
|
|
131
|
-
)
|
|
132
|
-
}
|