@kolkrabbi/kol-component 0.388.0 → 0.390.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/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/Modal.jsx +2 -0
- package/src/molecules/TabsDocument.jsx +42 -66
- package/src/molecules/TabsRow.jsx +19 -12
- package/src/molecules/TocRow.jsx +4 -3
- package/src/organisms/CommandOverlay.jsx +48 -117
- package/src/organisms/FindBar.jsx +18 -32
- package/src/organisms/ReadingContents.jsx +26 -71
- package/src/organisms/ShortcutsOverlay.jsx +17 -39
- package/src/utilities/SelectionOverlay.jsx +14 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.390.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"embla-carousel-react": "^8.6.0",
|
|
33
33
|
"pdfjs-dist": "^6.3.289",
|
|
34
34
|
"react-syntax-highlighter": "^16.1.1",
|
|
35
|
+
"@kolkrabbi/kol-markdown": "^0.2.0",
|
|
35
36
|
"@kolkrabbi/kol-search": "^0.3.0",
|
|
36
|
-
"@kolkrabbi/kol-growth": "^0.5.0"
|
|
37
|
-
"@kolkrabbi/kol-markdown": "^0.2.0"
|
|
37
|
+
"@kolkrabbi/kol-growth": "^0.5.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@kolkrabbi/kol-icons": ">=0.69.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"react-dom": "^18.3.0 || ^19.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@kolkrabbi/kol-icons": "^0.
|
|
48
|
+
"@kolkrabbi/kol-icons": "^0.75.0"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"src",
|
|
@@ -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
|
}
|
package/src/molecules/Modal.jsx
CHANGED
|
@@ -229,6 +229,7 @@ function ModalView({ state, closeWith, contained }) {
|
|
|
229
229
|
<div className="px-4 pb-4" data-modal-prompt>
|
|
230
230
|
<Input
|
|
231
231
|
variant="kolbox"
|
|
232
|
+
text
|
|
232
233
|
ref={inputRef}
|
|
233
234
|
type={state.type}
|
|
234
235
|
autoComplete={state.type === 'password' ? 'current-password' : undefined}
|
|
@@ -245,6 +246,7 @@ function ModalView({ state, closeWith, contained }) {
|
|
|
245
246
|
<Input
|
|
246
247
|
key={f.id}
|
|
247
248
|
variant="kolbox"
|
|
249
|
+
text
|
|
248
250
|
ref={i === 0 ? inputRef : undefined}
|
|
249
251
|
type={f.type ?? 'text'}
|
|
250
252
|
autoComplete={f.autoComplete}
|
|
@@ -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
|
}
|