@kolkrabbi/kol-component 0.378.0 → 0.380.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/atoms/Badge.jsx +1 -5
- package/src/atoms/BezierPathEditor.jsx +1 -1
- package/src/atoms/Button.jsx +88 -12
- package/src/atoms/Figure.jsx +19 -1
- package/src/atoms/FunctionPlot.jsx +1 -1
- package/src/atoms/Input.jsx +107 -7
- package/src/atoms/Kbd.jsx +42 -2
- package/src/atoms/Link.jsx +20 -0
- package/src/atoms/OriginPicker.jsx +9 -5
- package/src/atoms/Pill.jsx +1 -3
- package/src/atoms/ProgressBar.jsx +3 -6
- package/src/atoms/SectionFooter.jsx +22 -0
- package/src/atoms/SectionHeader.jsx +24 -0
- package/src/atoms/SectionLabel.jsx +0 -22
- package/src/atoms/SizeOrDownload.jsx +1 -1
- package/src/atoms/Tag.jsx +4 -7
- package/src/atoms/Textarea.jsx +12 -7
- package/src/atoms/ToggleCheckbox.jsx +25 -5
- package/src/atoms/ToggleSwitch.jsx +41 -7
- package/src/atoms/ViewToggle.jsx +2 -29
- package/src/atoms/XYPad.jsx +25 -0
- package/src/hooks/useDragResize.js +1 -1
- package/src/index.js +26 -4
- package/src/molecules/AccountMenu.jsx +16 -3
- package/src/molecules/AlignmentGrid.jsx +13 -1
- package/src/molecules/ButtonGroup.jsx +78 -15
- package/src/molecules/ButtonSplit.jsx +75 -28
- package/src/molecules/Chip.jsx +26 -0
- package/src/molecules/CodeBlock.jsx +39 -2
- package/src/molecules/ColorInputRow.jsx +125 -4
- package/src/molecules/ColorSwatch.jsx +43 -2
- package/src/molecules/ContentCard.jsx +104 -3
- package/src/molecules/ContentMedia.jsx +1 -1
- package/src/molecules/ContentRow.jsx +4 -32
- package/src/molecules/ContextMenu.jsx +0 -1
- package/src/molecules/DividerLabel.jsx +19 -0
- package/src/molecules/DocsToc.jsx +1 -16
- package/src/molecules/Dropdown.jsx +115 -18
- package/src/molecules/DropdownStepper.jsx +29 -0
- package/src/molecules/EmptyState.jsx +1 -15
- package/src/molecules/FieldPair.jsx +41 -2
- package/src/molecules/Header.jsx +4 -4
- package/src/molecules/IndexRow.jsx +1 -1
- package/src/molecules/InlineAddRow.jsx +2 -2
- package/src/molecules/LabeledControl.jsx +56 -11
- package/src/molecules/LayerRow.jsx +1 -1
- package/src/molecules/LinkAddRow.jsx +5 -7
- package/src/molecules/Menu.jsx +250 -33
- package/src/molecules/MenuFloat.jsx +6 -12
- package/src/molecules/MenuList.jsx +5 -11
- package/src/molecules/Modal.jsx +228 -55
- package/src/molecules/ModalHeader.jsx +12 -20
- package/src/molecules/ModalShell.jsx +20 -10
- package/src/molecules/NoticeBanner.jsx +1 -1
- package/src/molecules/OptionRow.jsx +1 -1
- package/src/molecules/PanelsMenu.jsx +2 -2
- package/src/molecules/ParamBindDot.jsx +29 -2
- package/src/molecules/PasswordInput.jsx +1 -1
- package/src/molecules/QuantityInput.jsx +45 -13
- package/src/molecules/QuickLookFrame.jsx +2 -31
- package/src/molecules/RailHeader.jsx +37 -16
- package/src/molecules/ReadingActions.jsx +2 -2
- package/src/molecules/ReadingNotes.jsx +3 -3
- package/src/molecules/ReadingSettings.jsx +8 -8
- package/src/molecules/SearchInput.jsx +4 -5
- package/src/molecules/SectionText.jsx +56 -10
- package/src/molecules/SettingsControls.jsx +23 -23
- package/src/molecules/Slider.jsx +103 -55
- package/src/molecules/SpecList.jsx +1 -21
- package/src/molecules/SplitToolButton.jsx +4 -6
- package/src/molecules/SwatchControls.jsx +28 -0
- package/src/molecules/SwatchGrid.jsx +39 -0
- package/src/molecules/TabsDocument.jsx +131 -0
- package/src/molecules/TabsRow.jsx +40 -50
- package/src/molecules/TaskRow.jsx +2 -2
- package/src/molecules/Toast.jsx +55 -0
- package/src/molecules/TocRow.jsx +1 -1
- package/src/molecules/TreeRow.jsx +87 -1
- package/src/molecules/WorkspaceSwitcher.jsx +3 -6
- package/src/organisms/AppItemMenuProvider.jsx +2 -2
- package/src/organisms/ColorPickerPopover.jsx +133 -4
- package/src/organisms/ColumnBrowser.jsx +1 -1
- package/src/organisms/CommandOverlay.jsx +362 -87
- package/src/organisms/ContentFilters.jsx +4 -12
- package/src/organisms/FindBar.jsx +70 -0
- package/src/organisms/FramedMediaBand.jsx +2 -2
- package/src/organisms/GalleryCarousel.jsx +1 -1
- package/src/organisms/LogoSystem.jsx +38 -0
- package/src/organisms/LogoTuner.jsx +32 -0
- package/src/organisms/MediaLibrary.jsx +1 -56
- package/src/organisms/MediaLibraryPages.jsx +1 -1
- package/src/organisms/NavRail.jsx +1 -4
- package/src/organisms/Rail.jsx +33 -1
- package/src/organisms/RailSwitcher.jsx +62 -0
- package/src/organisms/ReadingContents.jsx +65 -3
- package/src/organisms/ReadingOverview.jsx +5 -5
- package/src/organisms/ReadingPanel.jsx +1 -1
- package/src/organisms/SectionSplit.jsx +1 -1
- package/src/organisms/SettingsPanel.jsx +64 -41
- package/src/organisms/ShortcutsOverlay.jsx +46 -2
- package/src/organisms/SpectrumControls.jsx +112 -19
- package/src/organisms/StatusBar.jsx +30 -0
- package/src/organisms/Table.jsx +136 -45
- package/src/organisms/TimelineDock.jsx +281 -1
- package/src/organisms/logoBoard.jsx +61 -0
- package/src/utilities/AssetPlaceholder.jsx +1 -1
- package/src/utilities/EditorShell.jsx +42 -1
- package/src/utilities/OverlayGlassPanel.jsx +1 -1
- package/src/utilities/Popover.jsx +299 -5
- package/src/utilities/SelectionOverlay.jsx +60 -31
- package/src/utilities/kolboxGlyph.jsx +10 -0
- package/src/molecules/FloatModuleHeader.jsx +0 -11
- package/src/organisms/NavRailFloat.jsx +0 -139
|
@@ -11,13 +11,13 @@ import LabeledControl from './LabeledControl.jsx'
|
|
|
11
11
|
/**
|
|
12
12
|
* The SETTINGS parts — what the generator settings window (`ModalDialog variant="settings"`) draws that is MORE than one
|
|
13
13
|
* base control (plan-2026-11-12-one-header W6.1; the user, P9: *"whats the point of taking a base, and wrapping it and
|
|
14
|
-
* adding nothing"*). A plain row is `LabeledControl
|
|
15
|
-
* readout="input"`, `Dropdown
|
|
14
|
+
* adding nothing"*). A plain row is `LabeledControl` around the base itself — `Slider
|
|
15
|
+
* readout="input"`, `Dropdown`, `Input`, `TabsRow`, a bare float
|
|
16
16
|
* `ToggleSwitch` in a `horizontal` row — never a Settings* part. What stays here composes several:
|
|
17
17
|
*
|
|
18
18
|
* SettingsGrid the two-up grid a group lays its rows in
|
|
19
19
|
* SettingsPoint an X / Y pair of float Inputs (the prefix names the axis)
|
|
20
|
-
* SettingsRamp an A→B row, `LabeledControl
|
|
20
|
+
* SettingsRamp an A→B row, `LabeledControl horizontal`: value A · curve · value B (float Input ·
|
|
21
21
|
* float Dropdown · float Input); `SettingsRampHead` the VALUE A · CURVE · VALUE B row over them
|
|
22
22
|
* SettingsLights a list of points — X · Y · radius · intensity float Inputs · delete — and Add light
|
|
23
23
|
* SettingsFieldMap the field's gradient strip: FIELD MAP over a 26 strip (`background`) and two captions
|
|
@@ -51,7 +51,7 @@ export function SettingsPoint({ value = [0.5, 0.5], onChange, min, max, disabled
|
|
|
51
51
|
const [x, y] = value
|
|
52
52
|
const clamp = (n) => Math.min(max ?? Infinity, Math.max(min ?? -Infinity, n))
|
|
53
53
|
const field = (axis, v, set) => (
|
|
54
|
-
<Input
|
|
54
|
+
<Input size="sm" prefix={axis} value={String(v)} disabled={disabled} aria-label={`${ariaLabel ?? 'Point'} ${axis}`}
|
|
55
55
|
onCommit={(s) => set(clamp(num(s, v)))} width="100%" />
|
|
56
56
|
)
|
|
57
57
|
return (
|
|
@@ -73,16 +73,16 @@ export const SettingsRampHead = () => (
|
|
|
73
73
|
export function SettingsRamp({ label, value = { a: 0, b: 1, curve: 'linear' }, onChange, curves = [], disabled, partial, ...rest }) {
|
|
74
74
|
const set = (k) => (v) => onChange?.({ ...value, [k]: v })
|
|
75
75
|
const box = (k) => (
|
|
76
|
-
<Input
|
|
76
|
+
<Input size="sm" value={String(value[k])} aria-label={`${label} value ${k.toUpperCase()}`} disabled={disabled || partial?.[k]}
|
|
77
77
|
onCommit={(s) => set(k)(num(s, value[k]))} width="100%" className={partial?.[k] ? 'opacity-40' : ''} />
|
|
78
78
|
)
|
|
79
79
|
return (
|
|
80
80
|
<Dim disabled={disabled} {...rest}>
|
|
81
|
-
<LabeledControl
|
|
81
|
+
<LabeledControl horizontal label={label}>
|
|
82
82
|
<div className="grid grid-cols-[minmax(0,87fr)_minmax(0,122fr)_minmax(0,87fr)] gap-x-2 items-center">
|
|
83
83
|
{box('a')}
|
|
84
84
|
<div className={partial?.curve ? 'opacity-40' : ''}>
|
|
85
|
-
<Dropdown
|
|
85
|
+
<Dropdown size="sm" value={value.curve} onChange={set('curve')} options={curves} ariaLabel={`${label} curve`} disabled={disabled || partial?.curve} className={FILL} />
|
|
86
86
|
</div>
|
|
87
87
|
{box('b')}
|
|
88
88
|
</div>
|
|
@@ -94,7 +94,7 @@ export function SettingsRamp({ label, value = { a: 0, b: 1, curve: 'linear' }, o
|
|
|
94
94
|
export function SettingsLights({ value = [], onChange, disabled }) {
|
|
95
95
|
const set = (i, k, n) => onChange?.(value.map((l, j) => (j === i ? { ...l, [k]: n } : l)))
|
|
96
96
|
const cell = (i, k, v, label) => (
|
|
97
|
-
<Input
|
|
97
|
+
<Input size="sm" value={String(v)} aria-label={`Light ${i + 1} ${label}`} width="100%"
|
|
98
98
|
onCommit={(s) => set(i, k, num(s, v))} />
|
|
99
99
|
)
|
|
100
100
|
return (
|
|
@@ -106,10 +106,10 @@ export function SettingsLights({ value = [], onChange, disabled }) {
|
|
|
106
106
|
{value.map((l, i) => (
|
|
107
107
|
<div key={i} className="grid grid-cols-[repeat(4,minmax(0,1fr))_28px] gap-x-2 items-center">
|
|
108
108
|
{cell(i, 'x', l.x, 'X')}{cell(i, 'y', l.y, 'Y')}{cell(i, 'radius', l.radius, 'radius')}{cell(i, 'intensity', l.intensity, 'intensity')}
|
|
109
|
-
<Button
|
|
109
|
+
<Button tone="ghost" size="sm" iconOnly="trash" aria-label={`Delete light ${i + 1}`} onClick={() => onChange?.(value.filter((_, j) => j !== i))} />
|
|
110
110
|
</div>
|
|
111
111
|
))}
|
|
112
|
-
<Button
|
|
112
|
+
<Button tone="ghost" size="sm" className="self-start" onClick={() => onChange?.([...value, { x: 0.5, y: 0.5, radius: 0.3, intensity: 1 }])}>+ Add light</Button>
|
|
113
113
|
</Dim>
|
|
114
114
|
)
|
|
115
115
|
}
|
|
@@ -129,18 +129,18 @@ export function SettingsFieldMap({ background, left, right, label = 'Field map'
|
|
|
129
129
|
|
|
130
130
|
/* ── retired 2026-11-12: each renders its base; on the retirement ledger until no repo imports it ─────────────────── */
|
|
131
131
|
|
|
132
|
-
/** @deprecated 2026-11-12 — `LabeledControl
|
|
132
|
+
/** @deprecated 2026-11-12 — `LabeledControl` around the control (`col-span-2` for a wide cell) */
|
|
133
133
|
export function SettingsCell({ label, span = 1, disabled, className = '', children, ...rest }) {
|
|
134
134
|
return (
|
|
135
135
|
<Dim disabled={disabled} className={`${span === 2 ? 'col-span-2' : ''} ${className}`.trim()} {...rest}>
|
|
136
|
-
<LabeledControl
|
|
136
|
+
<LabeledControl label={label}>{children}</LabeledControl>
|
|
137
137
|
</Dim>
|
|
138
138
|
)
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/** @deprecated 2026-11-12 — `Slider
|
|
141
|
+
/** @deprecated 2026-11-12 — `Slider readout="input"` (`format` → `formatValue`) */
|
|
142
142
|
export function SettingsSlider({ value, onChange, min = 0, max = 1, step = 0.01, format, disabled, 'aria-label': ariaLabel }) {
|
|
143
|
-
return <Slider
|
|
143
|
+
return <Slider readout="input" value={value} onChange={onChange} min={min} max={max} step={step} formatValue={format} disabled={disabled} aria-label={ariaLabel} />
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
/** @deprecated 2026-11-12 — `Slider variant="dual"` (`value` / `value2`, the formatted values as `label1` / `label2`) */
|
|
@@ -152,29 +152,29 @@ export function SettingsRange({ value = [0, 1], onChange, min = 0, max = 1, step
|
|
|
152
152
|
)
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
/** @deprecated 2026-11-12 — `Dropdown
|
|
155
|
+
/** @deprecated 2026-11-12 — `Dropdown` */
|
|
156
156
|
export function SettingsSelect({ value, onChange, options = [], disabled, ariaLabel, className = '' }) {
|
|
157
|
-
return <Dropdown
|
|
157
|
+
return <Dropdown size="sm" value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} disabled={disabled} className={`${FILL} ${className}`.trim()} />
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
/** @deprecated 2026-11-12 — `TabsRow
|
|
160
|
+
/** @deprecated 2026-11-12 — `TabsRow` */
|
|
161
161
|
export function SettingsSegmented({ value, onChange, options = [], ariaLabel }) {
|
|
162
|
-
return <TabsRow
|
|
162
|
+
return <TabsRow size="xs" tabs={options} value={value} onChange={onChange} ariaLabel={ariaLabel} className="w-full [&>*]:flex-1" />
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
/** @deprecated 2026-11-12 — `LabeledControl
|
|
165
|
+
/** @deprecated 2026-11-12 — `LabeledControl horizontal` around a bare `ToggleSwitch` */
|
|
166
166
|
export function SettingsToggle({ label, checked, onChange, disabled }) {
|
|
167
167
|
return (
|
|
168
|
-
<LabeledControl
|
|
169
|
-
<ToggleSwitch
|
|
168
|
+
<LabeledControl horizontal label={label} labelWidth="fit-content" className={disabled ? 'opacity-40' : ''}>
|
|
169
|
+
<ToggleSwitch checked={!!checked} onChange={onChange} aria-label={label} disabled={disabled} />
|
|
170
170
|
</LabeledControl>
|
|
171
171
|
)
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
/** @deprecated 2026-11-12 — `Input
|
|
174
|
+
/** @deprecated 2026-11-12 — `Input` */
|
|
175
175
|
export function SettingsText({ value, onChange, onCommit, type = 'text', placeholder, disabled, 'aria-label': ariaLabel, className = '' }) {
|
|
176
176
|
return (
|
|
177
|
-
<Input
|
|
177
|
+
<Input size="sm" type={type} value={value ?? ''} placeholder={placeholder} aria-label={ariaLabel} disabled={disabled} width="100%" className={className}
|
|
178
178
|
onChange={onChange ? (e) => onChange(type === 'number' ? Number(e.target.value) : e.target.value) : undefined} onCommit={onCommit} />
|
|
179
179
|
)
|
|
180
180
|
}
|
package/src/molecules/Slider.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
|
|
2
|
-
import Input from '../atoms/Input.jsx'
|
|
2
|
+
import Input, { selectOnFirstPress } from '../atoms/Input.jsx'
|
|
3
3
|
import SliderPanel from './SliderPanel.jsx'
|
|
4
4
|
import LabeledControl from './LabeledControl.jsx'
|
|
5
5
|
|
|
@@ -20,7 +20,7 @@ import LabeledControl from './LabeledControl.jsx'
|
|
|
20
20
|
* routes were documented and neither was wired, so consumers were reaching into
|
|
21
21
|
* `.slider-black` by specificity from their own stylesheets).
|
|
22
22
|
* `--kol-slider-playhead` works the same way on the dual rail.
|
|
23
|
-
* The minimal
|
|
23
|
+
* The minimal track reads the shared track tokens (`--kol-track-h` · `-r` · `-bg` · `-run`, kol-theme
|
|
24
24
|
* `.kol-track`, 2026-11-07) — ProgressBar draws the same track from them.
|
|
25
25
|
*
|
|
26
26
|
* DUAL + PLAYHEAD (SliderDualThumbAndPlayhead, kol-mirror 2026-08-30):
|
|
@@ -46,8 +46,10 @@ import LabeledControl from './LabeledControl.jsx'
|
|
|
46
46
|
* @param {string} props.fontSize - Font size for label/value (e.g., '11px')
|
|
47
47
|
* @param {Object} props.style - forwarded to the wrapper; the seam for `--kol-slider-track` / `--kol-slider-playhead`
|
|
48
48
|
* @param {number} props.defaultValue - alt-click the control resets to this (falls back to `min`). Same contract on Knob
|
|
49
|
-
* @param {'input'|'value'|'none'} props.readout - `input` (default) an editable Input · `value` a plain right-aligned span, Knob's own display-only readout · `none`.
|
|
50
|
-
* @param {'minimal'|'dual'|'scrub'|'panel'|'
|
|
49
|
+
* @param {'input'|'value'|'none'} props.readout - `input` (default) an editable Input · `value` a plain right-aligned span, Knob's own display-only readout · `none`.
|
|
50
|
+
* @param {'minimal'|'dual'|'scrub'|'panel'|'kolbox'} props.variant - `kolbox` (W31.2 batch 3): kolbox's track (2px oq-24, the run in the ink to the value, a 12 ink thumb) in a 24 row (`--kol-kolbox-ctl`); `readout` `value` (its default) the mono 12 value beside it, 40 wide, or `input` the track in an oq-16 field and the value in a text field 2 apart; no visible label (`aria-label` names it), `formatValue` defaults to the raw value · `dual` = two thumbs on one rail · `scrub` = a media scrubber: the thin track with the 4 × 28 pill knob (`.kol-playback-scrub`; `PlaybackBar`'s, 2026-10-02) · `panel` = the rack slider (was kol-hardware `Fader`, merged 2026-10-01): a drawn 2px track for a hardware panel; takes `value · onChange · min · max · step · label` plus `onHold`
|
|
51
|
+
* @param {'folio'} props.variant - also `folio` (Folio migration batch A, 2026-11-22): Folio's slider, a 24 row, the 2px track in the rule with the run in the accent to a 12 accent thumb, the value (JetBrains Mono 12 / 16, `formatValue` its words, raw by default) 32 wide at the right, 12 off; no visible label (`aria-label`). Chrome in kol-theme `.kol-slider--folio`
|
|
52
|
+
* @param {number[]} props.stops - kolbox only: values marked on the track, a 2 mark each under the thumb's centre (a variable font's named weights)
|
|
51
53
|
* @param {'horizontal'|'vertical'} props.direction - `vertical` stands the track upright at `height`, label above and readout below (2026-10-02 — the volume ranges were hand-drawn for want of it). On `panel`, horizontal takes the row and shows a readout
|
|
52
54
|
* @param {number} props.height - vertical only — the track's length in px (default 96; panel 60)
|
|
53
55
|
* @param {string} props['aria-label'] - names the range when there is no visible `label`
|
|
@@ -59,6 +61,84 @@ import LabeledControl from './LabeledControl.jsx'
|
|
|
59
61
|
* @param {number|null} props.playhead - dual only — marker position in min…max; null renders nothing and attaches no listeners
|
|
60
62
|
* @param {Function} props.onPlayheadChange - dual only — (next: number) => void; omit and the marker is not draggable and the rail does not seek
|
|
61
63
|
*/
|
|
64
|
+
/* `variant="kolbox"` (plan-2026-11-18-kolbox-system W31.2 batch 3, 2026-11-18): kolbox's Slider carried class for
|
|
65
|
+
* class, its own component so its draft is its own state. `readout` value (its default): the bare track, the value
|
|
66
|
+
* beside it, 12 apart; `input`: the track in its own field, then 2 apart the number in a field as wide as its value
|
|
67
|
+
* and at least 48. The number is a text field, not type="number": Chrome draws a number field's value in the OS
|
|
68
|
+
* region's format ("0,08" on an Icelandic Mac) whatever the page's lang. A draft holds what is typed until it reads
|
|
69
|
+
* as a number; kolbox's field keys: one press selects it, the arrows step it (Shift ten steps), Escape restores the value
|
|
70
|
+
* from before the edit. Chrome in kol-theme `.kol-slider--kolbox`. */
|
|
71
|
+
function SliderKolbox({ value, min, max, step, onChange, formatValue, readout = 'value', ariaLabel, stops, className = '' }) {
|
|
72
|
+
const [draft, setDraft] = useState(null)
|
|
73
|
+
const before = useRef(value)
|
|
74
|
+
const format = formatValue ?? ((v) => v)
|
|
75
|
+
const p = Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100))
|
|
76
|
+
/* a stop: a 2 mark on the track, under the thumb's centre at that value (the thumb is 12, so its centre runs 6 to
|
|
77
|
+
the width less 6) */
|
|
78
|
+
const marks = stops?.length > 0 && stops.map((v) => (
|
|
79
|
+
<span key={v} data-slider-stop={v} className="pointer-events-none absolute top-1/2 size-0.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-oq-64"
|
|
80
|
+
style={{ left: `calc(6px + (100% - 12px) * ${(v - min) / (max - min)})` }} />
|
|
81
|
+
))
|
|
82
|
+
const input = (
|
|
83
|
+
<input
|
|
84
|
+
type="range"
|
|
85
|
+
className="kol-slider-input min-w-0 flex-1"
|
|
86
|
+
style={{ '--p': `${p}%` }}
|
|
87
|
+
aria-label={ariaLabel}
|
|
88
|
+
value={value}
|
|
89
|
+
min={min}
|
|
90
|
+
max={max}
|
|
91
|
+
step={step}
|
|
92
|
+
onChange={(e) => onChange?.(Number(e.target.value))}
|
|
93
|
+
/>
|
|
94
|
+
)
|
|
95
|
+
const range = marks ? <span className="relative flex min-w-0 flex-1 items-center">{input}{marks}</span> : input
|
|
96
|
+
if (readout === 'input') {
|
|
97
|
+
return (
|
|
98
|
+
<div className={`kol-slider--kolbox flex h-(--kol-kolbox-ctl) min-w-0 items-center gap-0.5 ${className}`}>
|
|
99
|
+
<div className="kol-slider-field flex h-(--kol-kolbox-ctl) min-w-0 flex-1 items-center px-2">{range}</div>
|
|
100
|
+
<input
|
|
101
|
+
type="text"
|
|
102
|
+
inputMode="decimal"
|
|
103
|
+
aria-label={ariaLabel}
|
|
104
|
+
className="kol-slider-number field-sizing-content h-(--kol-kolbox-ctl) min-w-12 shrink-0 px-2 text-left outline-none focus-visible:outline-1 focus-visible:-outline-offset-1"
|
|
105
|
+
value={draft ?? String(format(value))}
|
|
106
|
+
onChange={(e) => {
|
|
107
|
+
/* parseFloat: a formatted value keeps its unit while it is typed ("45°") */
|
|
108
|
+
const s = e.target.value, n = parseFloat(s)
|
|
109
|
+
setDraft(s)
|
|
110
|
+
if (s.trim() !== '' && Number.isFinite(n)) onChange?.(n)
|
|
111
|
+
}}
|
|
112
|
+
onMouseDown={selectOnFirstPress}
|
|
113
|
+
onFocus={() => { before.current = value }}
|
|
114
|
+
onBlur={() => setDraft(null)}
|
|
115
|
+
onKeyDown={(e) => {
|
|
116
|
+
if (e.key === 'Enter') { e.preventDefault(); e.currentTarget.blur(); return }
|
|
117
|
+
/* Escape puts back the value from before the edit and leaves the field (kolbox's field, useKolboxField) */
|
|
118
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); setDraft(null); if (before.current !== value) onChange?.(before.current); e.currentTarget.blur(); return }
|
|
119
|
+
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return
|
|
120
|
+
e.preventDefault()
|
|
121
|
+
const dec = String(step).split('.')[1]?.length ?? 0
|
|
122
|
+
const by = (e.shiftKey ? 10 : 1) * (e.key === 'ArrowUp' ? step : -step)
|
|
123
|
+
const n = Math.min(max, Math.max(min, value + by))
|
|
124
|
+
setDraft(null)
|
|
125
|
+
before.current = Number(n.toFixed(dec))
|
|
126
|
+
onChange?.(before.current)
|
|
127
|
+
const el = e.currentTarget
|
|
128
|
+
requestAnimationFrame(() => { if (document.activeElement === el) el.select() })
|
|
129
|
+
}}
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
return (
|
|
135
|
+
<div className={`kol-slider--kolbox flex h-(--kol-kolbox-ctl) min-w-0 items-center gap-3 ${className}`}>
|
|
136
|
+
{range}
|
|
137
|
+
<span className="kol-slider-value w-10 shrink-0 text-right">{format(value)}</span>
|
|
138
|
+
</div>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
62
142
|
const Slider = ({
|
|
63
143
|
label,
|
|
64
144
|
min = 0,
|
|
@@ -86,6 +166,7 @@ const Slider = ({
|
|
|
86
166
|
direction,
|
|
87
167
|
height,
|
|
88
168
|
onHold,
|
|
169
|
+
stops,
|
|
89
170
|
'aria-label': ariaLabel,
|
|
90
171
|
}) => {
|
|
91
172
|
/* Label ↔ input pairing — the <label> is a sibling of the range input, so
|
|
@@ -184,6 +265,24 @@ const Slider = ({
|
|
|
184
265
|
onChange(defaultValue ?? min)
|
|
185
266
|
}
|
|
186
267
|
|
|
268
|
+
if (variant === 'kolbox') {
|
|
269
|
+
return <SliderKolbox value={value} min={min} max={max} step={step} onChange={onChange} formatValue={formatValue} readout={readout} ariaLabel={ariaLabel} stops={stops} className={className} />
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/* folio (Folio migration batch A, 2026-11-22): Folio's Slider carried class for class (apps/folio Chrome.jsx): a 24
|
|
273
|
+
* row, the native range (its track and thumb in kol-theme `.kol-slider--folio`), the value beside it, 32 wide */
|
|
274
|
+
if (variant === 'folio') {
|
|
275
|
+
const format = formatValue ?? ((n) => n)
|
|
276
|
+
const run = `${((value - min) / (max - min)) * 100}%`
|
|
277
|
+
return (
|
|
278
|
+
<div className={`kol-slider--folio flex h-[24px] w-full items-center gap-[12px] ${className}`}>
|
|
279
|
+
<input type="range" min={min} max={max} step={step} value={value} onChange={handleChange} aria-label={ariaLabel} style={{ '--run': run }}
|
|
280
|
+
className="kol-slider-input h-[24px] min-w-0 flex-1 cursor-pointer appearance-none bg-transparent" />
|
|
281
|
+
<span className="kol-slider-value w-[32px] shrink-0 text-right tabular-nums">{format(value)}</span>
|
|
282
|
+
</div>
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
|
|
187
286
|
if (variant === 'panel') {
|
|
188
287
|
return <SliderPanel value={value} onChange={onChange} min={min} max={max} step={step} label={label} direction={direction} height={height} onHold={onHold} />
|
|
189
288
|
}
|
|
@@ -272,57 +371,6 @@ const Slider = ({
|
|
|
272
371
|
const scrub = variant === 'scrub'
|
|
273
372
|
const length = vertical ? height ?? 96 : size
|
|
274
373
|
|
|
275
|
-
/* the float slider: track and thumb only, at the float sm height (plan-2026-11-12-float-system W2.1 — the label head it
|
|
276
|
-
* carried went; the user: "SOME IDIOT tried to put label on the slider instead of using a fucking LABELEDCONTROL").
|
|
277
|
-
* Its name is a LabeledControl's: a `label` passed here is drawn by `LabeledControl variant="float"`, the `value`
|
|
278
|
-
* readout as its hint. The run is the value as a percent on the track. */
|
|
279
|
-
if (variant === 'float') {
|
|
280
|
-
const pct = max > min ? ((value - min) / (max - min)) * 100 : 0
|
|
281
|
-
const track = (
|
|
282
|
-
<input
|
|
283
|
-
id={sliderId}
|
|
284
|
-
type="range"
|
|
285
|
-
min={min} max={max} step={step} value={value}
|
|
286
|
-
onChange={handleChange}
|
|
287
|
-
onClick={onAltReset}
|
|
288
|
-
disabled={disabled}
|
|
289
|
-
aria-label={ariaLabel ?? (typeof label === 'string' ? label : undefined)}
|
|
290
|
-
className={`kol-slider-float block min-w-0 ${readout === 'input' ? 'flex-1 w-full' : label ? 'w-full' : className || 'w-full'}`.trim()}
|
|
291
|
-
style={{ '--kol-slider-pct': `${pct}%`, ...(length ? { width: length } : null), ...(label || readout === 'input' ? null : style) }}
|
|
292
|
-
/>
|
|
293
|
-
)
|
|
294
|
-
/* the value pill: the float Input, its width the widest value in `ch` (never a fixed px — validate:float F4) */
|
|
295
|
-
const box = readout === 'input' && (
|
|
296
|
-
<Input
|
|
297
|
-
type="text"
|
|
298
|
-
inputMode="decimal"
|
|
299
|
-
variant="float"
|
|
300
|
-
size="sm"
|
|
301
|
-
chars={Math.max(2, fmt(min).length, fmt(max).length)}
|
|
302
|
-
value={draft}
|
|
303
|
-
disabled={disabled}
|
|
304
|
-
aria-label={`${ariaLabel ?? (typeof label === 'string' ? label : 'Value')} value`}
|
|
305
|
-
/* editing shows the raw number (a `50%` reading is typed as 0.5, the engine's unit) */
|
|
306
|
-
onFocus={(e) => { const el = e.target; setEditing(true); setDraft(String(value)); requestAnimationFrame(() => el.select()) }}
|
|
307
|
-
onChange={(e) => setDraft(e.target.value)}
|
|
308
|
-
onBlur={commit}
|
|
309
|
-
onKeyDown={onKeyDown}
|
|
310
|
-
className="shrink-0"
|
|
311
|
-
inputClassName="text-center"
|
|
312
|
-
/>
|
|
313
|
-
)
|
|
314
|
-
const control = box
|
|
315
|
-
? <div className={`flex min-w-0 items-center gap-3 ${label ? 'w-full' : className || 'w-full'}`.trim()} style={label ? undefined : style}>{track}{box}</div>
|
|
316
|
-
: track
|
|
317
|
-
if (!label) return control
|
|
318
|
-
return (
|
|
319
|
-
<LabeledControl variant="float" label={label} hint={readout === 'value' ? displayValue : undefined} className={`${disabled ? 'opacity-40' : ''} ${className}`.trim()}>
|
|
320
|
-
{control}
|
|
321
|
-
</LabeledControl>
|
|
322
|
-
)
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
374
|
const range = (
|
|
327
375
|
<input
|
|
328
376
|
id={sliderId}
|
|
@@ -8,28 +8,8 @@ import Divider from '../atoms/Divider.jsx'
|
|
|
8
8
|
*
|
|
9
9
|
* @param {Array<{label: string, value: ReactNode}>} items rows, keyed by label
|
|
10
10
|
* @param {boolean} framed wrap the list in leading + trailing Divider
|
|
11
|
-
* @param {'float'} [variant] `float` (float-everything W8 row 126, 2026-11-04 — kol-float--style 48:3982): the info
|
|
12
|
-
* sheet — `title` in Inter 16 (`kol-float-body-lg`) over key · value rows on the sheet radius
|
|
13
|
-
* (`--kol-float-menu-r`, surface-secondary, 24 in), no dividers (the no-borders law): the key in
|
|
14
|
-
* `kol-float-hint` on fg-64 in a 126 column, the value beside it in Inter 13 on the emphasis ink, 12 between rows
|
|
15
|
-
* @param {ReactNode} [title] float: the sheet's heading (`Book information`)
|
|
16
11
|
*/
|
|
17
|
-
export default function SpecList({ items = [], framed = false,
|
|
18
|
-
if (variant === 'float') {
|
|
19
|
-
return (
|
|
20
|
-
<section className={`flex w-full flex-col gap-5 rounded-[var(--kol-float-menu-r)] bg-surface-secondary p-6 ${className}`.trim()}>
|
|
21
|
-
{title && <h3 className="kol-float-body-lg m-0 text-fg-emphasis">{title}</h3>}
|
|
22
|
-
<dl className="m-0 flex flex-col gap-3">
|
|
23
|
-
{items.map((item) => (
|
|
24
|
-
<div key={item.label} className="grid grid-cols-[126px_1fr] items-baseline gap-4">
|
|
25
|
-
<dt className="kol-float-hint text-fg-64">{item.label}</dt>
|
|
26
|
-
<dd className="kol-float-hint m-0 text-fg-emphasis" style={{ fontSize: 13 }}>{item.value}</dd>
|
|
27
|
-
</div>
|
|
28
|
-
))}
|
|
29
|
-
</dl>
|
|
30
|
-
</section>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
12
|
+
export default function SpecList({ items = [], framed = false, className = '' }) {
|
|
33
13
|
return (
|
|
34
14
|
<>
|
|
35
15
|
{framed && <Divider />}
|
|
@@ -66,14 +66,12 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
66
66
|
* @param {string} props.className - Additional classes on the trigger
|
|
67
67
|
*/
|
|
68
68
|
|
|
69
|
-
/* Corner fold marker —
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* this is that. Lives inside the button so it dims with kol-btn-quiet and
|
|
73
|
-
* inverts with kol-btn-pressed (currentColor). */
|
|
69
|
+
/* Corner fold marker — drawn here, not an icon: it belongs to this button only
|
|
70
|
+
* (out of the icon set 2026-11-23, his ruling). Lives inside the button so it dims
|
|
71
|
+
* with kol-btn-quiet and inverts with kol-btn-pressed (currentColor). */
|
|
74
72
|
const FoldIndicator = () => (
|
|
75
73
|
<span aria-hidden="true" className="pointer-events-none absolute right-0.5 bottom-0.5 opacity-70 inline-flex">
|
|
76
|
-
<
|
|
74
|
+
<svg width="4" height="4" viewBox="0 0 4 4" fill="none"><path d="M0 4L4 4L4 0Z" fill="currentColor" /></svg>
|
|
77
75
|
</span>
|
|
78
76
|
)
|
|
79
77
|
|
|
@@ -68,6 +68,11 @@ function PaintChip({ id, label, color, slot, onSwap }) {
|
|
|
68
68
|
* @param {'fill'|'stroke'} activePaint which chip paints on top. Default 'fill'
|
|
69
69
|
* @param {Function} onSwap () => void — either chip or the swap arrow
|
|
70
70
|
* @param {Function} onClear () => void — the "set to none" marker
|
|
71
|
+
* @param {'default'|'kolbox'} variant `kolbox` (kolbox's SwatchStack, plan-2026-11-18-kolbox-system W31.2, 2026-11-18,
|
|
72
|
+
* carried class for class): the stack scaled into the 32 dock cell, 16 chips at 4 / 4 and 12 / 11, each with a halo of
|
|
73
|
+
* the ground then the oq-24 line; the swap arrow (your icons' `swap`, 12) top right in oq-64, the ink on hover; the
|
|
74
|
+
* none marker an 8 disc of the ink with the error slash. Chrome in kol-theme `.kol-swatch-stack--kolbox`.
|
|
75
|
+
* @param {string} className kolbox: extra classes on the stack
|
|
71
76
|
*/
|
|
72
77
|
export function SwatchStack({
|
|
73
78
|
fillColor = '#FFFFFF',
|
|
@@ -75,7 +80,30 @@ export function SwatchStack({
|
|
|
75
80
|
activePaint = 'fill',
|
|
76
81
|
onSwap,
|
|
77
82
|
onClear,
|
|
83
|
+
variant = 'default',
|
|
84
|
+
className = '',
|
|
78
85
|
}) {
|
|
86
|
+
if (variant === 'kolbox') {
|
|
87
|
+
const chip = (key, label, pos) => (
|
|
88
|
+
<button key={key} type="button" aria-label={label} onClick={onSwap} data-paint={label}
|
|
89
|
+
className={`kol-swatch-stack-chip absolute size-4 rounded-full outline-none focus-visible:outline-solid focus-visible:outline-1 ${pos}`}
|
|
90
|
+
style={{ background: key === 'fill' ? fillColor : strokeColor }} />
|
|
91
|
+
)
|
|
92
|
+
const fill = chip('fill', 'Fill color', 'top-1 left-1')
|
|
93
|
+
const stroke = chip('stroke', 'Stroke color', 'top-3 left-[11px]')
|
|
94
|
+
return (
|
|
95
|
+
<div className={`kol-swatch-stack--kolbox relative size-8 shrink-0 ${className}`.trim()} data-swatch-stack={activePaint}>
|
|
96
|
+
{activePaint === 'fill' ? [stroke, fill] : [fill, stroke]}
|
|
97
|
+
<button type="button" aria-label="Swap colors" onClick={onSwap}
|
|
98
|
+
className="kol-swatch-stack-swap absolute top-0 right-0 inline-flex outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
99
|
+
<IconLoader name="swap" size={12} className="kol-kolbox-icon shrink-0" />
|
|
100
|
+
</button>
|
|
101
|
+
<button type="button" aria-label="Clear color" onClick={onClear}
|
|
102
|
+
className="kol-swatch-stack-none absolute bottom-0 left-0 size-2 overflow-hidden rounded-full" />
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
79
107
|
const fill = <PaintChip key="fill" id="fill" label="Fill color" color={fillColor} slot={FILL_SLOT} onSwap={onSwap} />
|
|
80
108
|
const stroke = <PaintChip key="stroke" id="stroke" label="Stroke color" color={strokeColor} slot={STROKE_SLOT} onSwap={onSwap} />
|
|
81
109
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* taxonomy-ok: molecule — a listbox of swatches, the current one ringed */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SwatchGrid — Pick one color from a grid of swatches (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18;
|
|
5
|
+
* kolbox's, the swatches under "On this page" in its color popover). Squares at radius 2, 8 across, 8 apart; each ringed
|
|
6
|
+
* by a 1px oq-24 line inside it, the current one by a 2px accent ring 1 off the secondary surface. A listbox of options,
|
|
7
|
+
* each named by its color. Its one look. Input.
|
|
8
|
+
*
|
|
9
|
+
* @param {string[]} colors any CSS colors
|
|
10
|
+
* @param {string} [value] the current one
|
|
11
|
+
* @param {Function} [onChange] `(color)`
|
|
12
|
+
* @param {string} [className]
|
|
13
|
+
* @param {'folio'|'kolbox'} [variant] `folio` (Folio's Swatches, Folio batch C, 2026-11-22, carried class for class): a row of
|
|
14
|
+
* the caller's swatches (`children`, each a `ColorSwatch variant="folio"`), 8 apart, a group named by `aria-label`;
|
|
15
|
+
* `colors`, `value` and `onChange` are not read. `kolbox` with `children` (Folio on kolbox, 2026-11-22): the same row of
|
|
16
|
+
* the caller's swatches (`ColorSwatch variant="kolbox"`), 8 apart; without children, kolbox's grid as above.
|
|
17
|
+
*/
|
|
18
|
+
export default function SwatchGrid({ colors = [], value, onChange, className = '', variant, children, ...rest }) {
|
|
19
|
+
/* kolbox (Folio on kolbox, 2026-11-22) with `children`: a row of the caller's swatches (`ColorSwatch variant="kolbox"`),
|
|
20
|
+
8 apart as the grid's, wrapping; a group named by `aria-label` */
|
|
21
|
+
if (variant === 'kolbox' && children) return <div role="group" aria-label={rest['aria-label']} className={`flex flex-wrap gap-2 ${className}`.trim()}>{children}</div>
|
|
22
|
+
if (variant === 'folio') return <div role="group" aria-label={rest['aria-label']} className={`flex gap-[8px] ${className}`.trim()}>{children}</div>
|
|
23
|
+
return (
|
|
24
|
+
<div role="listbox" aria-label="Swatches" className={`grid grid-cols-8 gap-2 ${className}`}>
|
|
25
|
+
{colors.map((c) => (
|
|
26
|
+
<button
|
|
27
|
+
key={c}
|
|
28
|
+
type="button"
|
|
29
|
+
role="option"
|
|
30
|
+
aria-label={c}
|
|
31
|
+
aria-selected={c === value}
|
|
32
|
+
onClick={() => onChange?.(c)}
|
|
33
|
+
className={`kol-swatch-grid-cell${c === value ? ' is-current ring-2 ring-offset-1' : ' ring-1 ring-inset'} aspect-square outline-none`}
|
|
34
|
+
style={{ background: c }}
|
|
35
|
+
/>
|
|
36
|
+
))}
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
2
|
+
import Button from '../atoms/Button.jsx'
|
|
3
|
+
import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* TabsDocument — A strip of open documents. One tab per open document (its glyph, its name, its close), the current one
|
|
7
|
+
* on its own ground, a plus after the last that opens a new one (plan-2026-11-22 folio-on-kolbox; drawn after Figma's
|
|
8
|
+
* desktop tab strip, his reference). Holds no document state and no router: the host passes the tabs and answers the
|
|
9
|
+
* callbacks. `TabsRow` switches views inside a page; this strip switches documents, so it carries close, unsaved, open
|
|
10
|
+
* beside and drag, which TabsRow does not.
|
|
11
|
+
*
|
|
12
|
+
* A tablist of tabs: arrow keys, Home and End move between the tabs (Enter or Space opens one); each tab's close button
|
|
13
|
+
* is in the Tab order, named "Close <name>".
|
|
14
|
+
*
|
|
15
|
+
* <TabsDocument variant="kolbox" tabs={[{ value: '/a', label: 'notes.md', icon: 'file-md', dirty: true }]}
|
|
16
|
+
* value="/a" onChange={open} onClose={close} onNew={create} />
|
|
17
|
+
*
|
|
18
|
+
* @param {'kolbox'|'folio'} [variant='folio'] - The look. `kolbox` (the editor style): a 40 strip on the panel ground with
|
|
19
|
+
* the field line under it, tabs 12 / 16, the current one on the field wash (light: the top rail's track pair, canvas
|
|
20
|
+
* strip and ground tab), the others flat in oq-64; the glyph 16, the close a kolbox icon button; an unsaved tab shows a
|
|
21
|
+
* dot in the close's place until hovered. `folio` (the default): Folio's own strip, carried class for class from
|
|
22
|
+
* apps/folio's FolioWrite (44 high, 36 tabs on the paper, Inter 11, a text "New"); it draws no glyph.
|
|
23
|
+
* @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 (kolbox only; `file` when unset); `dirty` shows the unsaved dot
|
|
25
|
+
* @param {string} [value] - The current tab's value
|
|
26
|
+
* @param {(value: string) => void} [onChange] - A tab pressed (the current one included, as Folio's tab button is)
|
|
27
|
+
* @param {(value: string) => void} [onClose] - A tab's close pressed; no close button without it
|
|
28
|
+
* @param {() => void} [onNew] - The plus after the last tab; none without it
|
|
29
|
+
* @param {string} [newLabel='New'] - The plus's name (folio: its visible text)
|
|
30
|
+
* @param {string} [paired] - The tab open beside the current one (a split): drawn on the current ground; folio chains the two
|
|
31
|
+
* with its green line
|
|
32
|
+
* @param {(value: string) => void} [onOpenBeside] - A tab's "Open beside" button (shown on hover, not on the current or the
|
|
33
|
+
* paired tab); none without it
|
|
34
|
+
* @param {() => void} [onCloseSplit] - With `paired`, a "Close split" button after the tabs
|
|
35
|
+
* @param {(event: MouseEvent, tab: object) => void} [onTabContextMenu] - A tab's context menu; the host opens its menu
|
|
36
|
+
* @param {(event: DragEvent, tab: object) => void} [onTabDragStart] - Makes the other tabs draggable (not the current one);
|
|
37
|
+
* the host sets the drag data
|
|
38
|
+
* @param {string} [ariaLabel='Open documents'] - Names the tablist
|
|
39
|
+
* @param {string} [className] - Extra classes on the strip
|
|
40
|
+
*/
|
|
41
|
+
export default function TabsDocument({
|
|
42
|
+
variant = 'folio', tabs = [], value, onChange, onClose, onNew, newLabel = 'New', paired,
|
|
43
|
+
onOpenBeside, onCloseSplit, onTabContextMenu, onTabDragStart, ariaLabel = 'Open documents', className = '',
|
|
44
|
+
}) {
|
|
45
|
+
const kolbox = variant === 'kolbox'
|
|
46
|
+
const focusable = tabs.some((t) => t.value === value) ? value : tabs[0]?.value
|
|
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
|
+
const onKeyDown = (e) => {
|
|
49
|
+
const all = [...e.currentTarget.querySelectorAll('[role="tab"]')]
|
|
50
|
+
const at = all.indexOf(document.activeElement)
|
|
51
|
+
if (at < 0) return
|
|
52
|
+
const to = { ArrowRight: at + 1, ArrowLeft: at - 1, Home: 0, End: all.length - 1 }[e.key]
|
|
53
|
+
if (to == null) return
|
|
54
|
+
e.preventDefault()
|
|
55
|
+
all[(to + all.length) % all.length]?.focus()
|
|
56
|
+
}
|
|
57
|
+
const cell = (t) => ({
|
|
58
|
+
onContextMenu: onTabContextMenu ? (e) => onTabContextMenu(e, t) : undefined,
|
|
59
|
+
draggable: Boolean(onTabDragStart) && t.value !== value,
|
|
60
|
+
onDragStart: onTabDragStart ? (e) => onTabDragStart(e, t) : undefined,
|
|
61
|
+
})
|
|
62
|
+
const tabProps = (t) => ({
|
|
63
|
+
type: 'button', role: 'tab', 'aria-selected': t.value === value, tabIndex: t.value === focusable ? 0 : -1,
|
|
64
|
+
onClick: () => onChange?.(t.value),
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
if (kolbox) {
|
|
68
|
+
return (
|
|
69
|
+
<div 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
|
+
return (
|
|
112
|
+
<div role="tablist" aria-label={ariaLabel} onKeyDown={onKeyDown}
|
|
113
|
+
className={`kol-tabs-document--folio flex h-[44px] shrink-0 items-end gap-[2px] overflow-x-auto px-[56px] [scrollbar-width:none] ${className}`.trim()}>
|
|
114
|
+
{tabs.map((t) => {
|
|
115
|
+
const on = t.value === value
|
|
116
|
+
const chained = paired && (on || t.value === paired)
|
|
117
|
+
return (
|
|
118
|
+
<div key={t.value} role="presentation" {...cell(t)}
|
|
119
|
+
className={`kol-tabs-document-tab${on || t.value === paired ? ' is-active' : ''}${chained ? ' is-chained' : ''} group flex h-[36px] shrink-0 items-center gap-[8px] rounded-t-[3px] pl-[14px] pr-[6px]`}>
|
|
120
|
+
<button {...tabProps(t)} className={`kol-tabs-document-label kol-folio-meta max-w-[220px] truncate${on ? ' is-current font-semibold' : ''}`}>{t.label}</button>
|
|
121
|
+
{t.dirty && <span aria-label="Unsaved changes" role="img" className="kol-tabs-document-dot size-[6px] rounded-full" />}
|
|
122
|
+
{onOpenBeside && !on && t.value !== paired && <button type="button" aria-label={`Open ${t.label} beside`} title="Open beside" onClick={() => onOpenBeside(t.value)} className="kol-tabs-document-btn flex size-[20px] items-center justify-center rounded-[3px] opacity-0 group-hover:opacity-100"><IconLoader name="panel-right" size={12} /></button>}
|
|
123
|
+
{onClose && <button type="button" aria-label={`Close ${t.label}`} onClick={() => onClose(t.value)} className="kol-tabs-document-btn flex size-[20px] items-center justify-center rounded-[3px] opacity-60 hover:opacity-100"><IconLoader name="x" size={12} /></button>}
|
|
124
|
+
</div>
|
|
125
|
+
)
|
|
126
|
+
})}
|
|
127
|
+
{paired && onCloseSplit && <button type="button" onClick={onCloseSplit} className="kol-tabs-document-text kol-folio-meta flex h-[36px] shrink-0 items-center gap-[6px] px-[12px]"><IconLoader name="panel-right" size={12} />Close split</button>}
|
|
128
|
+
{onNew && <button type="button" onClick={onNew} className="kol-tabs-document-text kol-folio-meta flex h-[36px] shrink-0 items-center gap-[6px] px-[12px]"><IconLoader name="plus" size={12} />{newLabel}</button>}
|
|
129
|
+
</div>
|
|
130
|
+
)
|
|
131
|
+
}
|