@kolkrabbi/kol-component 0.388.0 → 0.389.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/molecules/AccountMenu.jsx +11 -6
- package/src/molecules/AlignmentGrid.jsx +5 -5
- package/src/molecules/ButtonGroup.jsx +30 -48
- package/src/molecules/ButtonSplit.jsx +66 -66
- package/src/molecules/TabsDocument.jsx +42 -66
- package/src/molecules/TabsRow.jsx +19 -12
- package/src/organisms/FindBar.jsx +18 -32
package/package.json
CHANGED
|
@@ -16,16 +16,21 @@ import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
|
16
16
|
* @param {'start'|'end'} [align] default `end`
|
|
17
17
|
* @param {'sm'|'md'|'lg'} [size] the circle (default md)
|
|
18
18
|
* @param {string} [className]
|
|
19
|
-
* @param {
|
|
20
|
-
* trigger only: the xs Avatar (20) on
|
|
21
|
-
* (
|
|
19
|
+
* @param {boolean} [compact] the chip (kolbox's AccountChip, W31.2 batch 4, 2026-11-18; a plain prop since
|
|
20
|
+
* plan-2026-11-29-one-set-fold W3 run 2), the trigger only: the xs Avatar (20) on the chip's fill then the 12 chevron in
|
|
21
|
+
* oq-64, 4 apart, the accent's focus line. No menu (its host has none to open); `items` and `align` are not read. Other
|
|
22
|
+
* props land on the button. Chrome in kol-theme `.kol-account-chip`, the fill `--kol-account-chip-fill` (kolbox the field)
|
|
23
|
+
* @param {'kolbox'|'folio'} [variant] accepted (on the retirement ledger): `kolbox` draws `compact`
|
|
22
24
|
*/
|
|
23
|
-
|
|
25
|
+
/* the old theme word: `kolbox` draws the chip (W3 run 2, on the retirement ledger) */
|
|
26
|
+
const THEME_WORDS = ['kolbox']
|
|
27
|
+
|
|
28
|
+
export default function AccountMenu({ initial, src, name = 'Account', items = [], align = 'end', size = 'md', className = '', variant, compact, accent, ...rest }) {
|
|
24
29
|
if (accent === 'secondary') rest['data-accent'] = accent
|
|
25
|
-
if (
|
|
30
|
+
if (compact ?? THEME_WORDS.includes(variant)) {
|
|
26
31
|
return (
|
|
27
32
|
<button type="button" aria-label={name} aria-haspopup="menu" data-account-chip
|
|
28
|
-
className={`kol-account-chip
|
|
33
|
+
className={`kol-account-chip inline-flex shrink-0 items-center gap-1 rounded-full outline-none focus-visible:outline-solid focus-visible:outline-1 focus-visible:outline-offset-1 ${className}`.trim()} {...rest}>
|
|
29
34
|
<Avatar initial={initial} src={src} size="xs" />
|
|
30
35
|
<KolboxGlyph name="chevron-down" size={12} className="kol-account-chip-caret" />
|
|
31
36
|
</button>
|
|
@@ -27,8 +27,8 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
27
27
|
* @param {'stacked'|'strips'} [layout='stacked'] - `stacked`: the X strip over the Y strip. `strips` (kolbox's align row,
|
|
28
28
|
* plan-2026-11-18-kolbox-system W31.2 batch 3; a layout of its own since plan-2026-11-29-one-set-fold W2 run 4): the X
|
|
29
29
|
* and Y strips side by side, each filling its cell of a slot `FieldPair` (two cells 8 apart), each cell its own action;
|
|
30
|
-
* `items` carry the set's glyph names. The strips are ButtonGroup's icon group
|
|
31
|
-
*
|
|
30
|
+
* `items` carry the set's glyph names. The strips are ButtonGroup's icon group (`variant="icons"`, W3 run 2).
|
|
31
|
+
* `variant="kolbox"` and `"folio"` are accepted and draw `strips`; the old branch is in
|
|
32
32
|
* `_tmp/2026-11-29-one-set-fold/AlignmentGrid.pre-fields3.jsx`.
|
|
33
33
|
*/
|
|
34
34
|
const THEME_WORDS = ['kolbox', 'folio']
|
|
@@ -44,11 +44,11 @@ const ALIGN_BUTTONS = [
|
|
|
44
44
|
export default function AlignmentGrid({ onAlign, items = ALIGN_BUTTONS, size = 'sm', className = '', layout: layoutProp, variant }) {
|
|
45
45
|
const strip = (axis) => items.filter((b) => b.axis === axis)
|
|
46
46
|
const layout = layoutProp ?? (THEME_WORDS.includes(variant) ? 'strips' : 'stacked')
|
|
47
|
-
/* layout="strips" (kolbox's AlignmentRow carried): the two strips as icon groups, each filling its cell of
|
|
48
|
-
* FieldPair (two cells 8 apart)
|
|
47
|
+
/* layout="strips" (kolbox's AlignmentRow carried): the two strips as ButtonGroup's icon groups, each filling its cell of
|
|
48
|
+
* a slot FieldPair (two cells 8 apart) */
|
|
49
49
|
if (layout === 'strips') {
|
|
50
50
|
const group = (axis) => (
|
|
51
|
-
<ButtonGroup layout="joined" variant="
|
|
51
|
+
<ButtonGroup layout="joined" variant="icons" className="w-full"
|
|
52
52
|
options={strip(axis).map((b) => ({ icon: b.icon, ariaLabel: b.title, onPress: () => onAlign?.(b.axis, b.mode) }))} />
|
|
53
53
|
)
|
|
54
54
|
return <FieldPair className={className} first={group('h')} second={group('v')} />
|
|
@@ -87,12 +87,13 @@
|
|
|
87
87
|
* `kol-tone-sunken` wrapper reaches it too. Unset = inherit.
|
|
88
88
|
* ariaLabel — accessible name for the group
|
|
89
89
|
* className — additional classes on the outer shell
|
|
90
|
-
* variant="
|
|
91
|
-
* own action; `tone` unset (cells) or `sunken`
|
|
92
|
-
*
|
|
93
|
-
* variant="
|
|
94
|
-
* `[{ value, label }]`, the picked cell lit
|
|
95
|
-
*
|
|
90
|
+
* variant="icons" — the icon group (kolbox's IconGroup, a plain variant since plan-2026-11-29-one-set-fold W3 run 2):
|
|
91
|
+
* `options` `[{ icon, ariaLabel, pressed, onPress }]`, each its own action; `tone` unset (cells) or `sunken`
|
|
92
|
+
* (the track). Chrome in kol-theme `.kol-btn-group--icons`, its look `--kol-btn-group-*`
|
|
93
|
+
* variant="track" — a choice that stays, drawn on the tab track (TabsRow `variant="track"`'s sm track and cells):
|
|
94
|
+
* `options` `[{ value, label, disabled? }]`, the picked cell lit and aria-pressed, `ariaLabel` names it
|
|
95
|
+
* variant="kolbox" | "folio" — accepted (on the retirement ledger): without `value` they draw `icons`, with one `track`.
|
|
96
|
+
* Folio's own segmented row and frameless tool row went to `_tmp/2026-11-29-one-set-fold/ButtonGroup.pre-w3b.jsx`
|
|
96
97
|
*/
|
|
97
98
|
import { toneClass } from '../utilities/tone.js'
|
|
98
99
|
import { Tooltip } from '../utilities/Popover.jsx'
|
|
@@ -142,53 +143,31 @@ export default function ButtonGroup({ layout = 'row', align = 'center', title, c
|
|
|
142
143
|
)
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
/* layout="joined" variant="
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
function
|
|
146
|
+
/* layout="joined" variant="icons" (kolbox's IconGroup, W31.2 batch 3, 2026-11-18; a plain variant since plan-2026-11-29-one-set-fold
|
|
147
|
+
* W3 run 2). Each option is its own action, an icon Button (`{ icon, ariaLabel, pressed, onPress }`): no `value`, every
|
|
148
|
+
* option lights by its own `pressed`. Unset tone: each glyph in its own cell on the group's fill, 1px apart so the ground
|
|
149
|
+
* shows between them, radius 4 on the group's outer corners only. `tone="sunken"`: square cells the group's height side
|
|
150
|
+
* by side on the fill, the pressed cell (aria-pressed only) the ground inside the group's line, the others bare. Chrome
|
|
151
|
+
* in kol-theme `.kol-btn-group--icons`, its look `--kol-btn-group-*` (kolbox: the field fill, the one edge, the control
|
|
152
|
+
* height). */
|
|
153
|
+
function JoinedIcons({ options, tone, className }) {
|
|
153
154
|
const sunken = tone === 'sunken'
|
|
154
155
|
return (
|
|
155
|
-
<div className={`kol-btn-group--
|
|
156
|
+
<div className={`kol-btn-group--icons${sunken ? ' kol-btn-group--icons-sunken' : ' gap-px overflow-hidden'} inline-flex shrink-0 ${className}`}>
|
|
156
157
|
{options.map(({ icon, ariaLabel, pressed, onPress }) => (sunken
|
|
157
|
-
? <Button key={ariaLabel}
|
|
158
|
-
: <Button key={ariaLabel}
|
|
158
|
+
? <Button key={ariaLabel} iconOnly={icon} aria-label={ariaLabel} aria-pressed={!!pressed} onClick={onPress} className="aspect-square h-full! w-auto!" />
|
|
159
|
+
: <Button key={ariaLabel} iconOnly={icon} aria-label={ariaLabel} pressed={pressed} onClick={onPress} className="flex-1 rounded-none" />))}
|
|
159
160
|
</div>
|
|
160
161
|
)
|
|
161
162
|
}
|
|
162
163
|
|
|
163
|
-
/* layout="joined" variant="
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
|
|
168
|
-
* `.kol-btn-group--folio`. */
|
|
169
|
-
function JoinedFolio({ value, onChange, options, ariaLabel, className }) {
|
|
170
|
-
if (value == null) {
|
|
171
|
-
return (
|
|
172
|
-
<span role="group" aria-label={ariaLabel} className={`flex shrink-0 items-center ${className}`.trim()}>
|
|
173
|
-
{options.map(({ icon, ariaLabel: name, pressed, onPress }) => <Button key={name} variant="folio" keepFocus iconOnly={icon} aria-label={name} pressed={pressed} onClick={onPress} />)}
|
|
174
|
-
</span>
|
|
175
|
-
)
|
|
176
|
-
}
|
|
177
|
-
return (
|
|
178
|
-
<div role="group" aria-label={ariaLabel} className={`kol-btn-group--folio flex h-[32px] overflow-hidden rounded-[4px] border ${className}`.trim()}>
|
|
179
|
-
{options.map((opt) => (
|
|
180
|
-
<button key={opt.value} type="button" aria-pressed={value === opt.value} onClick={() => onChange?.(opt.value)} className="kol-btn-group-cell flex-1 whitespace-nowrap px-[16px]">{opt.label}</button>
|
|
181
|
-
))}
|
|
182
|
-
</div>
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
/* layout="joined" variant="kolbox" with a `value` (Folio on kolbox, 2026-11-22): kolbox's choice that stays (Off and On,
|
|
186
|
-
* Miter, Round and Bevel) is its tab track, so this draws TabsRow kolbox sm's track and cells (its chrome,
|
|
187
|
-
* `.kol-tabs--kolbox-sm`, kol-components-molecules.css) as a group: `options` `[{ value, label }]`, the picked cell lit and
|
|
188
|
-
* aria-pressed, `ariaLabel` names it. */
|
|
189
|
-
function JoinedKolboxChoice({ value, onChange, options, ariaLabel, className }) {
|
|
164
|
+
/* layout="joined" variant="track" (Folio on kolbox, 2026-11-22; a plain variant since W3 run 2): a choice that stays (Off
|
|
165
|
+
* and On, Miter, Round and Bevel) on the tab track, TabsRow `variant="track"` sm's track and cells (`.kol-tabs-track`,
|
|
166
|
+
* kol-components-molecules.css) as a group: `options` `[{ value, label }]`, the picked cell lit and aria-pressed,
|
|
167
|
+
* `ariaLabel` names it. `kol-tabs--kolbox-sm` stays on the box as a hook for kol-fxr's touch height (retirement ledger). */
|
|
168
|
+
function JoinedTrack({ value, onChange, options, ariaLabel, className }) {
|
|
190
169
|
return (
|
|
191
|
-
<div role="group" aria-label={ariaLabel} className={`kol-tabs--
|
|
170
|
+
<div role="group" aria-label={ariaLabel} className={`kol-tabs-track kol-tabs-track--sm kol-tabs--kolbox-sm inline-flex items-center gap-px p-0.5 ${className}`.trim()}>
|
|
192
171
|
{options.map((opt) => (
|
|
193
172
|
<button key={opt.value} type="button" aria-pressed={opt.value === value} disabled={opt.disabled} onClick={() => onChange?.(opt.value)}
|
|
194
173
|
className={`kol-tabs-tab${opt.value === value ? ' is-active' : ''} flex h-full min-w-0 flex-1 items-center justify-center px-3 whitespace-nowrap outline-none focus-visible:outline-solid focus-visible:outline-1 disabled:opacity-40`}>{opt.label}</button>
|
|
@@ -197,11 +176,14 @@ function JoinedKolboxChoice({ value, onChange, options, ariaLabel, className })
|
|
|
197
176
|
)
|
|
198
177
|
}
|
|
199
178
|
|
|
179
|
+
/* the old theme words: accepted, `icons` without a value, `track` with one (W3 run 2, on the retirement ledger) */
|
|
180
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
200
181
|
|
|
201
182
|
/* layout="joined" — the segmented control (SegmentedToggle's implementation, moved here 2026-11-06) */
|
|
202
|
-
function Joined({ value, onChange, options = [], variant = 'default', size = 'md', tone = 'default', ariaLabel, className = '' }) {
|
|
203
|
-
|
|
204
|
-
if (variant === '
|
|
183
|
+
function Joined({ value, onChange, options = [], variant: variantProp = 'default', size = 'md', tone = 'default', ariaLabel, className = '' }) {
|
|
184
|
+
const variant = THEME_WORDS.includes(variantProp) ? (value == null ? 'icons' : 'track') : variantProp
|
|
185
|
+
if (variant === 'icons') return <JoinedIcons options={options} tone={tone} className={className} />
|
|
186
|
+
if (variant === 'track') return <JoinedTrack value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} className={className} />
|
|
205
187
|
const cellType = { xs: 'kol-mono-8', sm: 'kol-mono-12', md: 'kol-mono-14', lg: 'kol-mono-16' }[size]
|
|
206
188
|
const stateless = value == null
|
|
207
189
|
const focusIdx = Math.max(0, options.findIndex((opt) => opt.value === value))
|
|
@@ -3,7 +3,6 @@ import Button from '../atoms/Button.jsx'
|
|
|
3
3
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
4
4
|
import { PopoverPanel, Tooltip, usePopover } from '../utilities/Popover.jsx'
|
|
5
5
|
import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
6
|
-
import { Menu } from './Menu.jsx'
|
|
7
6
|
|
|
8
7
|
/* taxonomy-ok: molecule — two Buttons (atoms) and a divider, the ⌄ opening a PopoverPanel (utility) of rows */
|
|
9
8
|
|
|
@@ -18,94 +17,95 @@ import { Menu } from './Menu.jsx'
|
|
|
18
17
|
* @param {Function} onClick the main action
|
|
19
18
|
* @param {Array} [items] `[{ label, icon?, onPress, disabled? }]` — the menu's rows
|
|
20
19
|
* @param {Function} [menu] `(close) => ReactNode` — the menu's content instead of `items`
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
20
|
+
* ONE SPLIT, THREE SHAPES (plan-2026-11-29-one-set-fold W3 run 2), picked by what the caller passes, never by a theme:
|
|
21
|
+
* - the menu its own (the default): `items` (or `menu`) open under the ⌄ in a PopoverPanel at `placement`
|
|
22
|
+
* (`bottom-end`, the list's right edge under the split's right edge)
|
|
23
|
+
* - `onMenu` (kolbox's SplitButton): the host opens its own menu, the ⌄'s press is `onMenu`; the action and a narrow ⌄
|
|
24
|
+
* are two Buttons of one tone 1px apart, square where they meet, the hovered half the fg-04 hover over its fill, the
|
|
25
|
+
* ghost tone filling both halves on hover or `is-open` (kol-theme `.kol-btn-split--narrow`, its fill
|
|
26
|
+
* `--kol-btn-split-fill`)
|
|
27
|
+
* - `iconOnly` (a glyph name, the tool dock's slot): a 32 tile and a 16 by 32 ⌄, 1 apart; `pressed` the armed look,
|
|
28
|
+
* `tooltip` the main half's tooltip label, `aria-label` the main half's name, `menuOpen` the ⌄'s menu is open (its
|
|
29
|
+
* quiet fill); the ⌄ is `onMenu`, else it opens `items` as above (`.kol-btn-split--icon`)
|
|
30
|
+
* @param {Function} [onMenu] the ⌄'s press when the host opens its menu
|
|
31
|
+
* @param {'kolbox'|'folio'} [variant] accepted (on the retirement ledger): `kolbox` draws the `onMenu` shape, `folio` the
|
|
32
|
+
* default. Folio's own split (its line, its green) is in `_tmp/2026-11-29-one-set-fold/`
|
|
27
33
|
* @param {string} [tone] · {'xs'|'sm'|'md'|'lg'} [size='md']
|
|
28
34
|
* @param {boolean} [disabled] the main action off; the menu still opens
|
|
29
35
|
* @param {string} [menuLabel='More actions'] the ⌄'s aria-label
|
|
30
36
|
* @param {string} [placement='bottom-end'] · {string} [className]
|
|
31
37
|
* @param {'primary'|'secondary'} [accent='primary'] the theme's accent the split draws (data-accent, kol-color.css)
|
|
32
38
|
*/
|
|
33
|
-
|
|
39
|
+
/* the old theme words: `kolbox` the host-menu shape, `folio` the default (W3 run 2, on the retirement ledger) */
|
|
40
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
41
|
+
|
|
42
|
+
export default function ButtonSplit({ children, icon, onClick, items = [], menu, variant, tone, size = 'md', disabled = false, menuLabel = 'More actions', placement = 'bottom-end', className = '', accent, onMenu, menuOpen, iconOnly, pressed, tooltip, 'aria-label': ariaLabel }) {
|
|
34
43
|
const [open, setOpen] = useState(false)
|
|
35
44
|
const popover = usePopover({ open, onOpenChange: setOpen, placement, offset: 6, role: 'menu' })
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
const dataAccent = accent === 'secondary' ? accent : undefined
|
|
46
|
+
const close = () => setOpen(false)
|
|
47
|
+
const pick = (it) => () => { if (it.disabled) return; it.onPress?.(); close() }
|
|
48
|
+
/* the menu its own: the rows of `items` (or `menu`) in a PopoverPanel under the ⌄ */
|
|
49
|
+
const panel = (
|
|
50
|
+
<PopoverPanel popover={popover} panel={false} focus={false}
|
|
51
|
+
className="w-max bg-surface-secondary border border-oq-08 rounded shadow-lg">
|
|
52
|
+
{menu ? menu(close) : items.map((it) => (
|
|
53
|
+
<button key={it.label} type="button" disabled={it.disabled} onClick={pick(it)}
|
|
54
|
+
className="w-full kol-helper-12 px-3 h-8 flex items-center gap-2 text-body hover:text-emphasis disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-body text-left">
|
|
55
|
+
<span className="flex-1 truncate">{it.label}</span>
|
|
56
|
+
</button>
|
|
57
|
+
))}
|
|
58
|
+
</PopoverPanel>
|
|
59
|
+
)
|
|
60
|
+
/* the icon-only form (the tool dock's slot with a fold), Figma's dock as measured 2026-11-20 (W16.3): two boxes 1
|
|
61
|
+
* apart, no divider and no joined half. The tool a 32 tile with the 22 glyph (Figma's draw 16 to 18, W2), rounded on all
|
|
62
|
+
* four corners, solid accent while `pressed`; the ⌄ its own 16 by 32 button, no fill at rest (pressed or not), the quiet
|
|
63
|
+
* fill on hover and while its menu is open (`menuOpen`); `tooltip` names the main half */
|
|
64
|
+
if (iconOnly) {
|
|
65
|
+
const main = (
|
|
66
|
+
<button type="button" aria-label={ariaLabel} aria-pressed={!!pressed} disabled={disabled} onClick={onClick}
|
|
67
|
+
className="kol-btn-split-main inline-flex size-8 shrink-0 items-center justify-center outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
68
|
+
<IconLoader name={iconOnly} size={22} className="kol-kolbox-icon shrink-0" />
|
|
69
|
+
</button>
|
|
70
|
+
)
|
|
71
|
+
const lit = menuOpen ?? (!onMenu && open)
|
|
72
|
+
const chevron = (
|
|
73
|
+
<button type="button" aria-label={menuLabel} aria-expanded={!!lit} onClick={onMenu}
|
|
74
|
+
className={`kol-btn-split-menu${lit ? ' is-open' : ''} inline-flex h-8 w-4 shrink-0 items-center justify-center outline-none focus-visible:outline-solid focus-visible:outline-1`}>
|
|
75
|
+
<KolboxGlyph name="chevron-down" />
|
|
76
|
+
</button>
|
|
77
|
+
)
|
|
64
78
|
return (
|
|
65
|
-
<div data-accent={
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
<div data-accent={dataAccent} className={`kol-btn-split--narrow kol-btn-split--icon${pressed ? ' is-pressed' : ''} inline-flex shrink-0 gap-px ${className}`.trim()}>
|
|
80
|
+
{tooltip ? <Tooltip label={tooltip}>{main}</Tooltip> : main}
|
|
81
|
+
{onMenu
|
|
82
|
+
? <Tooltip asChild label={menuLabel}>{chevron}</Tooltip>
|
|
83
|
+
: <span ref={popover.refs.setReference} {...popover.getReferenceProps()} className="inline-flex"><Tooltip asChild label={menuLabel}>{chevron}</Tooltip></span>}
|
|
84
|
+
{!onMenu && panel}
|
|
68
85
|
</div>
|
|
69
86
|
)
|
|
70
87
|
}
|
|
71
|
-
/*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
if (variant === 'folio') {
|
|
88
|
+
/* the host opens its menu (kolbox's SplitButton, W31.2 batch 3, 2026-11-18): the action and its ⌄ as two Buttons of one
|
|
89
|
+
* tone, 1px apart, square where they meet; the hovered half takes the fg-04 hover over its own fill (kol-theme
|
|
90
|
+
* `.kol-btn-split--narrow`). `onMenu` is the ⌄'s press. */
|
|
91
|
+
if (onMenu || variant === THEME_WORDS[0]) {
|
|
76
92
|
return (
|
|
77
|
-
<
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<button type="button" aria-label={menuLabel} aria-haspopup="menu" aria-expanded={open} onClick={() => setOpen(!open)} className="flex w-[32px] items-center justify-center"><IconLoader name="chevron-down" size={16} /></button>
|
|
82
|
-
</span>
|
|
83
|
-
<Menu variant="folio" open={open} onClose={() => setOpen(false)} aria-label={menuLabel} minWidth={160}
|
|
84
|
-
panelClassName="absolute right-0 top-[calc(100%+4px)] whitespace-nowrap"
|
|
85
|
-
items={items.map((it) => ({ label: it.label, onClick: it.onPress, disabled: it.disabled }))} />
|
|
86
|
-
</span>
|
|
93
|
+
<div data-accent={dataAccent} className={`kol-btn-split--narrow inline-flex shrink-0 gap-px ${className}`}>
|
|
94
|
+
<Button tone={tone} iconLeft={icon} onClick={onClick} className="rounded-r-none">{children}</Button>
|
|
95
|
+
<Tooltip asChild label={menuLabel}><Button tone={tone} iconLeft="chevron-down" onClick={onMenu} aria-label={menuLabel} className="rounded-l-none px-1" /></Tooltip>
|
|
96
|
+
</div>
|
|
87
97
|
)
|
|
88
98
|
}
|
|
89
|
-
const close = () => setOpen(false)
|
|
90
99
|
const shared = { tone, size }
|
|
91
|
-
const pick = (it) => () => { if (it.disabled) return; it.onPress?.(); close() }
|
|
92
100
|
return (
|
|
93
|
-
<div data-accent={
|
|
101
|
+
<div data-accent={dataAccent} className={`kol-btn-split inline-flex items-stretch ${className}`.trim()}>
|
|
94
102
|
<Button {...shared} iconLeft={icon} iconSize={12} disabled={disabled} onClick={onClick} className="flex-1 min-w-0 rounded-r-none">{children}</Button>
|
|
95
103
|
<span aria-hidden="true" className="w-px shrink-0 bg-oq-16" />
|
|
96
104
|
<span ref={popover.refs.setReference} {...popover.getReferenceProps()} className="inline-flex">
|
|
97
105
|
<Button {...shared} iconOnly="chevron-down" iconSize={12} pressed={open} aria-label={menuLabel}
|
|
98
106
|
className="rounded-l-none" />
|
|
99
107
|
</span>
|
|
100
|
-
|
|
101
|
-
className="w-max bg-surface-secondary border border-oq-08 rounded shadow-lg">
|
|
102
|
-
{menu ? menu(close) : items.map((it) => (
|
|
103
|
-
<button key={it.label} type="button" disabled={it.disabled} onClick={pick(it)}
|
|
104
|
-
className="w-full kol-helper-12 px-3 h-8 flex items-center gap-2 text-body hover:text-emphasis disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-body text-left">
|
|
105
|
-
<span className="flex-1 truncate">{it.label}</span>
|
|
106
|
-
</button>
|
|
107
|
-
))}
|
|
108
|
-
</PopoverPanel>
|
|
108
|
+
{panel}
|
|
109
109
|
</div>
|
|
110
110
|
)
|
|
111
111
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
2
1
|
import Button from '../atoms/Button.jsx'
|
|
3
2
|
import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
4
3
|
|
|
@@ -12,23 +11,24 @@ import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
|
12
11
|
* A tablist of tabs: arrow keys, Home and End move between the tabs (Enter or Space opens one); each tab's close button
|
|
13
12
|
* is in the Tab order, named "Close <name>".
|
|
14
13
|
*
|
|
15
|
-
* <TabsDocument
|
|
14
|
+
* <TabsDocument tabs={[{ value: '/a', label: 'notes.md', icon: 'file-md', dirty: true }]}
|
|
16
15
|
* value="/a" onChange={open} onClose={close} onNew={create} />
|
|
17
16
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
17
|
+
* ONE STRIP (plan-2026-11-29-one-set-fold W3 run 2): a 40 strip on the strip's ground with its line under it, tabs in the UI
|
|
18
|
+
* text, the current one on the active wash, the others flat in oq-64; the glyph 16, the close an icon Button; an unsaved
|
|
19
|
+
* tab shows a dot in the close's place until hovered. Its look is `--kol-doctabs-*` (kol-theme `.kol-tabs-document`): the
|
|
20
|
+
* default theme draws the secondary surface, kolbox the panel ground, the field line and wash (light: the top rail's track
|
|
21
|
+
* pair, canvas strip and ground tab).
|
|
22
|
+
* @param {'kolbox'|'folio'} [variant] - accepted and nothing (on the retirement ledger). Folio's own strip (44 high, 56 in,
|
|
23
|
+
* a text "New", the green chain line) went to `_tmp/2026-11-29-one-set-fold/TabsDocument.pre-w3b.jsx`
|
|
23
24
|
* @param {Array<{ value: string, label: string, icon?: string, dirty?: boolean }>} tabs - The open documents, in order.
|
|
24
|
-
* `icon` is the document kind's glyph by your icons' name (
|
|
25
|
+
* `icon` is the document kind's glyph by your icons' name (`file` when unset); `dirty` shows the unsaved dot
|
|
25
26
|
* @param {string} [value] - The current tab's value
|
|
26
27
|
* @param {(value: string) => void} [onChange] - A tab pressed (the current one included, as Folio's tab button is)
|
|
27
28
|
* @param {(value: string) => void} [onClose] - A tab's close pressed; no close button without it
|
|
28
29
|
* @param {() => void} [onNew] - The plus after the last tab; none without it
|
|
29
|
-
* @param {string} [newLabel='New'] - The plus's name
|
|
30
|
-
* @param {string} [paired] - The tab open beside the current one (a split): drawn on the current ground
|
|
31
|
-
* with its green line
|
|
30
|
+
* @param {string} [newLabel='New'] - The plus's name
|
|
31
|
+
* @param {string} [paired] - The tab open beside the current one (a split): drawn on the current ground
|
|
32
32
|
* @param {(value: string) => void} [onOpenBeside] - A tab's "Open beside" button (shown on hover, not on the current or the
|
|
33
33
|
* paired tab); none without it
|
|
34
34
|
* @param {() => void} [onCloseSplit] - With `paired`, a "Close split" button after the tabs
|
|
@@ -39,10 +39,10 @@ import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
|
39
39
|
* @param {string} [className] - Extra classes on the strip
|
|
40
40
|
*/
|
|
41
41
|
export default function TabsDocument({
|
|
42
|
-
variant
|
|
42
|
+
variant, // eslint-disable-line no-unused-vars
|
|
43
|
+
tabs = [], value, onChange, onClose, onNew, newLabel = 'New', paired,
|
|
43
44
|
onOpenBeside, onCloseSplit, onTabContextMenu, onTabDragStart, ariaLabel = 'Open documents', className = '', accent,
|
|
44
45
|
}) {
|
|
45
|
-
const kolbox = variant === 'kolbox'
|
|
46
46
|
const focusable = tabs.some((t) => t.value === value) ? value : tabs[0]?.value
|
|
47
47
|
/* arrows, Home and End move the focus between the tabs; the host opens one on Enter or Space (the tab is a button) */
|
|
48
48
|
const onKeyDown = (e) => {
|
|
@@ -64,68 +64,44 @@ export default function TabsDocument({
|
|
|
64
64
|
onClick: () => onChange?.(t.value),
|
|
65
65
|
})
|
|
66
66
|
|
|
67
|
-
if (kolbox) {
|
|
68
|
-
return (
|
|
69
|
-
<div data-accent={accent === 'secondary' ? accent : undefined} role="tablist" aria-label={ariaLabel} onKeyDown={onKeyDown}
|
|
70
|
-
className={`kol-tabs-document--kolbox relative flex h-10 shrink-0 items-stretch overflow-x-auto [scrollbar-width:none] after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:h-px after:content-[''] ${className}`.trim()}>
|
|
71
|
-
{tabs.map((t) => {
|
|
72
|
-
const on = t.value === value
|
|
73
|
-
const lit = on || t.value === paired
|
|
74
|
-
const closeShown = on && !t.dirty
|
|
75
|
-
return (
|
|
76
|
-
<div key={t.value} role="presentation" {...cell(t)}
|
|
77
|
-
className={`kol-tabs-document-tab${lit ? ' is-active' : ''} group relative flex shrink-0 items-center gap-1 pr-2 pl-3`}>
|
|
78
|
-
<button {...tabProps(t)} className="kol-tabs-document-label flex min-w-0 items-center gap-2 self-stretch outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
79
|
-
<KolboxGlyph name={t.icon || 'file'} className="kol-tabs-document-glyph" />
|
|
80
|
-
<span className="max-w-[220px] truncate">{t.label}</span>
|
|
81
|
-
</button>
|
|
82
|
-
{onOpenBeside && !lit && (
|
|
83
|
-
<Button variant="kolbox" iconOnly="panel-right" aria-label={`Open ${t.label} beside`} onClick={() => onOpenBeside(t.value)}
|
|
84
|
-
className="opacity-0 group-hover:opacity-100 focus-visible:opacity-100" />
|
|
85
|
-
)}
|
|
86
|
-
{onClose && (
|
|
87
|
-
<span className="relative flex size-(--kol-kolbox-ctl) items-center justify-center">
|
|
88
|
-
{t.dirty && <span aria-label="Unsaved changes" role="img" className="kol-tabs-document-dot pointer-events-none absolute size-1.5 rounded-full group-hover:opacity-0 group-focus-within:opacity-0" />}
|
|
89
|
-
<Button variant="kolbox" iconOnly="x" aria-label={`Close ${t.label}`} onClick={() => onClose(t.value)}
|
|
90
|
-
className={closeShown ? '' : 'opacity-0 group-hover:opacity-100 group-focus-within:opacity-100'} />
|
|
91
|
-
</span>
|
|
92
|
-
)}
|
|
93
|
-
</div>
|
|
94
|
-
)
|
|
95
|
-
})}
|
|
96
|
-
{paired && onCloseSplit && (
|
|
97
|
-
<span className="flex shrink-0 items-center px-2">
|
|
98
|
-
<Button variant="kolbox" tone="ghost" iconLeft="panel-right" onClick={onCloseSplit}>Close split</Button>
|
|
99
|
-
</span>
|
|
100
|
-
)}
|
|
101
|
-
{onNew && (
|
|
102
|
-
<span className="flex shrink-0 items-center px-2">
|
|
103
|
-
<Button variant="kolbox" iconOnly="plus" aria-label={newLabel} onClick={onNew} />
|
|
104
|
-
</span>
|
|
105
|
-
)}
|
|
106
|
-
</div>
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/* folio: FolioWrite's strip (13.3, W18) class for class; its colors are rules on the folio tokens (kol-components-molecules.css) */
|
|
111
67
|
return (
|
|
112
68
|
<div data-accent={accent === 'secondary' ? accent : undefined} role="tablist" aria-label={ariaLabel} onKeyDown={onKeyDown}
|
|
113
|
-
className={`kol-tabs-document
|
|
69
|
+
className={`kol-tabs-document relative flex h-10 shrink-0 items-stretch overflow-x-auto [scrollbar-width:none] after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:h-px after:content-[''] ${className}`.trim()}>
|
|
114
70
|
{tabs.map((t) => {
|
|
115
71
|
const on = t.value === value
|
|
116
|
-
const
|
|
72
|
+
const lit = on || t.value === paired
|
|
73
|
+
const closeShown = on && !t.dirty
|
|
117
74
|
return (
|
|
118
75
|
<div key={t.value} role="presentation" {...cell(t)}
|
|
119
|
-
className={`kol-tabs-document-tab${
|
|
120
|
-
<button {...tabProps(t)} className=
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
76
|
+
className={`kol-tabs-document-tab${lit ? ' is-active' : ''} group relative flex shrink-0 items-center gap-1 pr-2 pl-3`}>
|
|
77
|
+
<button {...tabProps(t)} className="kol-tabs-document-label flex min-w-0 items-center gap-2 self-stretch outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
78
|
+
<KolboxGlyph name={t.icon || 'file'} className="kol-tabs-document-glyph" />
|
|
79
|
+
<span className="max-w-[220px] truncate">{t.label}</span>
|
|
80
|
+
</button>
|
|
81
|
+
{onOpenBeside && !lit && (
|
|
82
|
+
<Button iconOnly="panel-right" aria-label={`Open ${t.label} beside`} onClick={() => onOpenBeside(t.value)}
|
|
83
|
+
className="opacity-0 group-hover:opacity-100 focus-visible:opacity-100" />
|
|
84
|
+
)}
|
|
85
|
+
{onClose && (
|
|
86
|
+
<span className="kol-tabs-document-slot relative flex items-center justify-center">
|
|
87
|
+
{t.dirty && <span aria-label="Unsaved changes" role="img" className="kol-tabs-document-dot pointer-events-none absolute size-1.5 rounded-full group-hover:opacity-0 group-focus-within:opacity-0" />}
|
|
88
|
+
<Button iconOnly="x" aria-label={`Close ${t.label}`} onClick={() => onClose(t.value)}
|
|
89
|
+
className={closeShown ? '' : 'opacity-0 group-hover:opacity-100 group-focus-within:opacity-100'} />
|
|
90
|
+
</span>
|
|
91
|
+
)}
|
|
124
92
|
</div>
|
|
125
93
|
)
|
|
126
94
|
})}
|
|
127
|
-
{paired && onCloseSplit &&
|
|
128
|
-
|
|
95
|
+
{paired && onCloseSplit && (
|
|
96
|
+
<span className="flex shrink-0 items-center px-2">
|
|
97
|
+
<Button tone="ghost" iconLeft="panel-right" onClick={onCloseSplit}>Close split</Button>
|
|
98
|
+
</span>
|
|
99
|
+
)}
|
|
100
|
+
{onNew && (
|
|
101
|
+
<span className="flex shrink-0 items-center px-2">
|
|
102
|
+
<Button iconOnly="plus" aria-label={newLabel} onClick={onNew} />
|
|
103
|
+
</span>
|
|
104
|
+
)}
|
|
129
105
|
</div>
|
|
130
106
|
)
|
|
131
107
|
}
|
|
@@ -34,7 +34,9 @@ import { floatSurfaceClass } from '../utilities/tone.js'
|
|
|
34
34
|
* keeps one line that scrolls sideways with no scrollbar, `.kol-scroll-fade--x` fading the clipped edge(s), and the
|
|
35
35
|
* active tab scrolled into view when it changes — arrow keys included; `wrap` breaks the tabs onto a second line.
|
|
36
36
|
* Every variant but `stacked`, which has its phone bar
|
|
37
|
-
* @param {'underline'|'chip'|'text'|'stacked'|'
|
|
37
|
+
* @param {'underline'|'chip'|'text'|'stacked'|'track'} [variant='underline'] `track` (kolbox's tabs, W31.2 batch 3; a plain variant
|
|
38
|
+
* since plan-2026-11-29-one-set-fold W3 run 2): the tab track, see `TabsTrack` below; takes `tabs`, `value`, `onChange`, `size`
|
|
39
|
+
* (sm, md) and `className` only. `kolbox` and `folio` are accepted and draw `track` (on the retirement ledger).
|
|
38
40
|
* @param {string} [look] @deprecated 2026-10-30 — the old spelling of `variant`; `variant` wins when both are passed
|
|
39
41
|
* @param {'mono'|'sans'|'mono-light'} [type='mono'] `underline` only: the tab's type — `mono-light` is `sans`'s row on JetBrains Mono at 300 (his word, 2026-10-30)
|
|
40
42
|
* @param {boolean} [filled=false] - `chip` only: every chip shows at rest (Button `tab-filled`), so the row reads as choices
|
|
@@ -84,17 +86,19 @@ import { floatSurfaceClass } from '../utilities/tone.js'
|
|
|
84
86
|
* Tabs are `{ id, label }` or `{ value, label }` (either key), plus `icon` for stacked; a stacked tab's `selected`
|
|
85
87
|
* lights it whatever `value` is — action slots (the transport) light more than one.
|
|
86
88
|
*/
|
|
87
|
-
/* `variant="
|
|
88
|
-
* chrome in kol-theme `.kol-tabs
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* rest oq-64, the ink on hover. Tabs are strings or `{ value, label, disabled, tooltip }`: a disabled
|
|
92
|
-
* no hover or focus and shows its `tooltip
|
|
93
|
-
* equally and the padding gives way.
|
|
94
|
-
|
|
89
|
+
/* `variant="track"` (kolbox's Tabs, plan-2026-11-18-kolbox-system W31.2 batch 3, 2026-11-18; a plain variant since
|
|
90
|
+
* plan-2026-11-29-one-set-fold W3 run 2), chrome in kol-theme `.kol-tabs-track`, its look `--kol-tabs-track-*`. `size` sm
|
|
91
|
+
* (its default) the tab track: the control height on the track's fill, 2 in, the tabs 1 apart at radius 4, 12 in, the
|
|
92
|
+
* current one on the stronger fill in the ink; md the top rail's mode track: 32 on the ground, 4 in, the tabs touching, 8
|
|
93
|
+
* in. The UI text, the rest oq-64, the ink on hover. Tabs are strings or `{ value, label, disabled, tooltip }`: a disabled
|
|
94
|
+
* tab is 40%, takes no hover or focus and shows its `tooltip`. In a track narrower than the labels and their padding the
|
|
95
|
+
* tabs share it equally and the padding gives way. kolbox sets the fills, the type and the height
|
|
96
|
+
* (kol-components-molecules.css). `kol-tabs--kolbox-sm` stays on the sm box as a hook for kol-fxr's touch height
|
|
97
|
+
* (retirement ledger). */
|
|
98
|
+
function TabsTrack({ tabs = [], value, onChange, size = 'sm', className = '', accent }) {
|
|
95
99
|
const md = size === 'md'
|
|
96
100
|
return (
|
|
97
|
-
<div data-accent={accent === 'secondary' ? accent : undefined} role="tablist" className={`kol-tabs
|
|
101
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} role="tablist" className={`kol-tabs-track kol-tabs-track--${md ? 'md' : 'sm kol-tabs--kolbox-sm'} inline-flex items-center ${md ? 'h-8 p-1' : 'gap-px p-0.5'} ${className}`}>
|
|
98
102
|
{tabs.map((t) => {
|
|
99
103
|
const { value: v, label, disabled, tooltip } = typeof t === 'string' ? { value: t, label: t } : t
|
|
100
104
|
const on = v === value
|
|
@@ -111,12 +115,15 @@ function TabsKolbox({ tabs = [], value, onChange, size = 'sm', className = '', a
|
|
|
111
115
|
{label}
|
|
112
116
|
</button>
|
|
113
117
|
)
|
|
114
|
-
return tooltip ? <span key={v} className="flex h-full flex-1 [&>span]:h-full [&>span]:flex-1 [&_button]:w-full">{<Tooltip
|
|
118
|
+
return tooltip ? <span key={v} className="flex h-full flex-1 [&>span]:h-full [&>span]:flex-1 [&_button]:w-full">{<Tooltip label={tooltip}>{tab}</Tooltip>}</span> : tab
|
|
115
119
|
})}
|
|
116
120
|
</div>
|
|
117
121
|
)
|
|
118
122
|
}
|
|
119
123
|
|
|
124
|
+
/* the old theme words: accepted, they draw `track` (W3 run 2, on the retirement ledger) */
|
|
125
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
126
|
+
|
|
120
127
|
export const TABBAR_H = 56
|
|
121
128
|
/* the pill's height (W16, round 3 — fxr's live nav: was TABBAR_H) — a page under it owes TABBAR_PILL_H + TABBAR_PILL_INSET */
|
|
122
129
|
export const TABBAR_PILL_H = 66
|
|
@@ -142,7 +149,7 @@ export const tabbarPillSlot = (at, { count, labels = false, split = false } = {}
|
|
|
142
149
|
const COLLAPSE_MS = 300
|
|
143
150
|
|
|
144
151
|
export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, variant, look: lookLegacy, type, trailing, filled = false, placement = 'inline', shape = 'bar', collapsed = false, onExpand, edge, border, shadow, dock, active, foldable, folded, onFoldChange, foldSide, foldTone, surface, split, labels, size, tracked = false, overflow = 'scroll', ariaLabel, className, style, accent }) {
|
|
145
|
-
if (variant === '
|
|
152
|
+
if (variant === 'track' || THEME_WORDS.includes(variant)) return <TabsTrack tabs={raw} value={value} onChange={onChange} size={size} className={className} accent={accent} />
|
|
146
153
|
const tabs = raw.map((t) => ({ ...t, id: t.id ?? t.value }))
|
|
147
154
|
const look = variant ?? lookLegacy ?? 'underline'
|
|
148
155
|
const wrap = overflow === 'wrap'
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
2
1
|
import Input from '../atoms/Input.jsx'
|
|
3
2
|
import Button from '../atoms/Button.jsx'
|
|
4
|
-
import ButtonGroup from '../molecules/ButtonGroup.jsx'
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* FindBar — find and replace over a document, one bar across its top (Folio's FindBar, 2026-11-22). It holds no
|
|
8
6
|
* document state: the host keeps the query, the replacement, the count and match case, and does the finding.
|
|
9
7
|
*
|
|
10
8
|
* The find field takes focus when the bar mounts. In either field Enter is the next match, Shift+Enter the previous;
|
|
11
|
-
* Escape anywhere in the bar closes it. Chrome in kol-theme `.kol-find-bar
|
|
9
|
+
* Escape anywhere in the bar closes it. Chrome in kol-theme `.kol-find-bar`, its line `--kol-find-bar-line` (kolbox the one edge).
|
|
12
10
|
*
|
|
13
11
|
* <FindBar query={q} onQueryChange={setQ} replacement={r} onReplacementChange={setR} count="3 found"
|
|
14
12
|
* onPrev={prev} onNext={next} onReplace={one} onReplaceAll={all} matchCase={mc} onMatchCase={setMc} onClose={close} />
|
|
15
13
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* ONE BAR (plan-2026-11-29-one-set-fold W3 run 2): 48 high on the rail ground, the line under it, Input md (the rail's search)
|
|
15
|
+
* and Buttons, the theme's look on each.
|
|
16
|
+
* @param {'kolbox'|'folio'} [variant] - accepted and nothing (on the retirement ledger). Folio's own bar (56 in, arrow
|
|
17
|
+
* glyphs, Folio's Input and Buttons) went to `_tmp/2026-11-29-one-set-fold/FindBar.pre-w3b.jsx`
|
|
18
18
|
* @param {string} query - The find field's text
|
|
19
19
|
* @param {(value: string) => void} onQueryChange
|
|
20
20
|
* @param {string} replacement - The replace field's text
|
|
@@ -29,42 +29,28 @@ import ButtonGroup from '../molecules/ButtonGroup.jsx'
|
|
|
29
29
|
* @param {() => void} onClose
|
|
30
30
|
* @param {string} [className] - Extra classes on the bar
|
|
31
31
|
*/
|
|
32
|
-
export default function FindBar({ variant
|
|
32
|
+
export default function FindBar({ variant, query, // eslint-disable-line no-unused-vars
|
|
33
|
+
onQueryChange, replacement, onReplacementChange, count, onPrev, onNext, onReplace, onReplaceAll, matchCase, onMatchCase, onClose, className = '' }) {
|
|
33
34
|
/* Enter steps only from a field, so a focused button still presses on Enter */
|
|
34
35
|
const onKeyDown = (e) => {
|
|
35
36
|
if (e.key === 'Escape') { e.preventDefault(); onClose?.() }
|
|
36
37
|
if (e.key === 'Enter' && e.target.tagName === 'INPUT') { e.preventDefault(); e.shiftKey ? onPrev?.() : onNext?.() }
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<IconLoader name="search" size={16} />
|
|
42
|
-
<Input variant="folio" autoFocus aria-label="Find" placeholder="Find" value={query} onChange={(e) => onQueryChange(e.target.value)} className="w-[220px]" />
|
|
43
|
-
<span className="kol-find-bar-count w-[64px] tabular-nums">{count}</span>
|
|
44
|
-
<ButtonGroup layout="joined" variant="folio" ariaLabel="Matches" options={[{ icon: 'arrow-left', ariaLabel: 'Previous match', onPress: onPrev }, { icon: 'arrow-right', ariaLabel: 'Next match', onPress: onNext }]} />
|
|
45
|
-
<button type="button" aria-pressed={matchCase} onClick={() => onMatchCase(!matchCase)} className={`kol-find-bar-case${matchCase ? ' is-on' : ''} h-[28px] rounded-[3px] px-[8px]`}>Aa</button>
|
|
46
|
-
<span className="kol-find-bar-rule mx-[8px] h-[20px] w-px" />
|
|
47
|
-
<Input variant="folio" aria-label="Replace with" placeholder="Replace with" value={replacement} onChange={(e) => onReplacementChange(e.target.value)} className="w-[220px]" />
|
|
48
|
-
<Button variant="folio" keepFocus onClick={onReplace}>Replace</Button>
|
|
49
|
-
<Button variant="folio" keepFocus onClick={onReplaceAll}>Replace all</Button>
|
|
50
|
-
<Button variant="folio" keepFocus iconOnly="x" aria-label="Close find" onClick={onClose} className="kol-find-bar-close ml-auto" />
|
|
51
|
-
</div>
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
/* kolbox: the rail header's 48 and its insets (12 in, 8 at the end), the rail's search field (Input md) and kolbox's
|
|
55
|
-
own find's buttons; Folio's order and words */
|
|
40
|
+
/* the rail header's 48 and its insets (12 in, 8 at the end), the rail's search field (Input md) and kolbox's own find's
|
|
41
|
+
buttons; Folio's order and words */
|
|
56
42
|
return (
|
|
57
|
-
<div className={`kol-find-bar
|
|
58
|
-
<Input
|
|
43
|
+
<div className={`kol-find-bar flex h-12 shrink-0 items-center gap-2 border-b pr-2 pl-3 ${className}`.trim()} onKeyDown={onKeyDown}>
|
|
44
|
+
<Input size="md" iconLeft="search" autoFocus aria-label="Find" placeholder="Find" value={query} onChange={(e) => onQueryChange(e.target.value)} className="w-60" />
|
|
59
45
|
<span className="kol-find-bar-count kol-kolbox-row w-16 shrink-0 tabular-nums">{count}</span>
|
|
60
|
-
<Button
|
|
61
|
-
<Button
|
|
62
|
-
<Button
|
|
46
|
+
<Button iconOnly="chevron-up" aria-label="Previous match" onClick={onPrev} />
|
|
47
|
+
<Button iconOnly="chevron-down" aria-label="Next match" onClick={onNext} />
|
|
48
|
+
<Button tone="ghost" pressed={Boolean(matchCase)} aria-label="Match case" onClick={() => onMatchCase(!matchCase)}>Aa</Button>
|
|
63
49
|
<span className="kol-find-bar-rule mx-2 h-5 w-px shrink-0" />
|
|
64
|
-
<Input
|
|
65
|
-
<Button
|
|
66
|
-
<Button
|
|
67
|
-
<Button
|
|
50
|
+
<Input size="md" iconLeft="arrow-right" aria-label="Replace with" placeholder="Replace with" value={replacement} onChange={(e) => onReplacementChange(e.target.value)} className="w-60" />
|
|
51
|
+
<Button onClick={onReplace}>Replace</Button>
|
|
52
|
+
<Button onClick={onReplaceAll}>Replace all</Button>
|
|
53
|
+
<Button iconOnly="x" aria-label="Close find" onClick={onClose} className="ml-auto" />
|
|
68
54
|
</div>
|
|
69
55
|
)
|
|
70
56
|
}
|