@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
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState } from 'react'
|
|
2
2
|
import SettingsPanel, { LabeledControlSection, SettingsRow } from './SettingsPanel.jsx'
|
|
3
3
|
import CommandOverlay, { isKeyCombo } from './CommandOverlay.jsx'
|
|
4
|
-
import ModalShell from '../molecules/ModalShell.jsx'
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* ShortcutsOverlay — The keyboard shortcut sheet. the keyboard-shortcut sheet: blurred scrim, centred
|
|
@@ -44,13 +43,11 @@ import ModalShell from '../molecules/ModalShell.jsx'
|
|
|
44
43
|
* @param {Array} props.shortcuts - `[{ label, combo }]` or `[{ section, items: [{ id, label, combo }] }]` — the same array `SettingsShortcuts` takes (ShellHomeSystemMonitorGaps, kol-monitor 2026-08-27: the overlay read `keys` while the settings block read `combo`; `combo` is the name, `keys` is tolerated for a release)
|
|
45
44
|
* @param {Function} props.onClose
|
|
46
45
|
* @param {string} [props.title] the header, beside the × (default `Shortcuts`)
|
|
47
|
-
* @param {'overlay'|'rail'|'
|
|
48
|
-
* never hand-builds the rail (kol-monitor's ShortcutsRail, 2026-10-18). `
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* dim close it. `kolbox` (Folio on kolbox, 2026-11-22): kolbox's S sheet, `CommandOverlay variant="kolbox"
|
|
53
|
-
* mode="shortcuts"`, from the same array (see `ShortcutsOverlayKolbox`)
|
|
46
|
+
* @param {'overlay'|'rail'|'search'} [props.variant] centred (default) or the right rail — SettingsPanel's two forms, so an
|
|
47
|
+
* app never hand-builds the rail (kol-monitor's ShortcutsRail, 2026-10-18). `search` (Folio on kolbox, 2026-11-22, its
|
|
48
|
+
* plain name since plan-2026-11-29-one-set-fold W3): the keymap in the search modal, `CommandOverlay mode="shortcuts"`
|
|
49
|
+
* with `groups`, from the same array (see `ShortcutsOverlaySearch`). The old theme words `kolbox` and `folio` are
|
|
50
|
+
* accepted and ask for `search` (on the retirement ledger); Folio's own flat list went to _tmp/2026-11-29-one-set-fold/.
|
|
54
51
|
* @param {string} [props.currentPath] sections may carry `routes: ['/rack']` (CommandOverlayModes, kol-monitor
|
|
55
52
|
* 2026-10-17 — user: *"im in dev, how can I cable lock here?"*): with a path, only the sections that work here
|
|
56
53
|
* are drawn (ShortcutsOverlayList, kol-monitor 2026-10-18 — the muted ELSEWHERE block is gone). A section without `routes`
|
|
@@ -63,46 +60,27 @@ export const shortcutInScope = (section, path) => !section?.routes?.length || pa
|
|
|
63
60
|
|
|
64
61
|
const isSectioned = (list) => Array.isArray(list?.[0]?.items)
|
|
65
62
|
|
|
66
|
-
/*
|
|
67
|
-
* the title on the header with the × beside it, a Divider, then the sections exactly as monitor's ⇧S rail draws
|
|
68
|
-
* them (LabeledControlSection divided · SettingsRow text · the combo in mono). Same props as before, plus `title`. */
|
|
69
|
-
function ShortcutsOverlayFolio({ shortcuts = [], onClose, title = 'Shortcuts' }) {
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
const esc = (e) => e.key === 'Escape' && onClose?.()
|
|
72
|
-
addEventListener('keydown', esc)
|
|
73
|
-
return () => removeEventListener('keydown', esc)
|
|
74
|
-
}, [onClose])
|
|
75
|
-
return (
|
|
76
|
-
<div className="kol-modal-dim--folio fixed inset-0 z-50 flex items-center justify-center px-[16px]" onMouseDown={onClose}>
|
|
77
|
-
<ModalShell variant="folio" role="dialog" aria-label={title} onMouseDown={(e) => e.stopPropagation()} className="kol-shortcuts--folio w-full max-w-[460px] gap-[4px] p-[20px]">
|
|
78
|
-
<p className="kol-folio-label kol-shortcuts-title--folio pb-[10px]">{title}</p>
|
|
79
|
-
{shortcuts.map((it) => (
|
|
80
|
-
<div key={it.label} className="kol-shortcuts-row--folio flex items-baseline justify-between gap-[16px] border-t py-[9px]">
|
|
81
|
-
<span className="kol-folio-body">{it.label}</span>
|
|
82
|
-
<kbd className="kol-folio-meta kol-shortcuts-combo--folio whitespace-nowrap">{it.combo ?? it.keys}</kbd>
|
|
83
|
-
</div>
|
|
84
|
-
))}
|
|
85
|
-
</ModalShell>
|
|
86
|
-
</div>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/* `variant="kolbox"` (Folio on kolbox, 2026-11-22): kolbox's S sheet, which kolbox draws as `CommandOverlay variant="kolbox"
|
|
63
|
+
/* `variant="search"` (Folio on kolbox, 2026-11-22): the S sheet, which kolbox draws as the grouped `CommandOverlay
|
|
91
64
|
* mode="shortcuts"` (its WindowShortcuts), from the same `shortcuts`: one group under `title`; a sectioned list's sections
|
|
92
65
|
* are its folds, open. A combo that is one key chord is drawn as key caps, any other text (`S, or ⌥S while writing`) as
|
|
93
66
|
* the row's hint. The sheet keeps its own lit row; Escape and the dim close it. */
|
|
94
|
-
function
|
|
67
|
+
function ShortcutsOverlaySearch({ shortcuts = [], onClose, currentPath, title }) {
|
|
95
68
|
const [active, setActive] = useState(0)
|
|
96
69
|
const row = (it, i, at = '') => ({ id: `${at}${i}:${it.label}`, label: it.label, hint: it.combo ?? it.keys, kbd: isKeyCombo(it.combo ?? it.keys) })
|
|
97
70
|
const rows = isSectioned(shortcuts)
|
|
98
71
|
? shortcuts.filter((s) => shortcutInScope(s, currentPath)).map((s, n) => ({ id: `cat:${s.section ?? n}`, label: s.section, open: true, items: (s.items ?? []).map((it, i) => row(it, i, `${n}/`)) }))
|
|
99
72
|
: shortcuts.map((it, i) => row(it, i))
|
|
100
|
-
return <CommandOverlay
|
|
73
|
+
return <CommandOverlay open mode="shortcuts" onClose={onClose} groups={[{ title, rows }]} active={active} onActive={setActive} />
|
|
101
74
|
}
|
|
102
75
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
76
|
+
/* the old theme words in `variant`: accepted, they ask for `search` (W3, on the retirement ledger) */
|
|
77
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
78
|
+
/* ONE OVERLAY, NOT TWO (user 2026-10-18, retiring the near-copy): the sheet is `SettingsPanel variant="overlay"` —
|
|
79
|
+
* the title on the header with the × beside it, a Divider, then the sections exactly as monitor's ⇧S rail draws
|
|
80
|
+
* them (LabeledControlSection divided · SettingsRow text · the combo in mono). Same props as before, plus `title`. */
|
|
81
|
+
export default function ShortcutsOverlay({ shortcuts = [], onClose, currentPath, title = 'Shortcuts', variant: variantProp = 'overlay' }) {
|
|
82
|
+
const variant = THEME_WORDS.includes(variantProp) ? 'search' : variantProp
|
|
83
|
+
if (variant === 'search') return <ShortcutsOverlaySearch shortcuts={shortcuts} onClose={onClose} currentPath={currentPath} title={title} />
|
|
106
84
|
const sections = isSectioned(shortcuts)
|
|
107
85
|
? shortcuts.filter((s) => shortcutInScope(s, currentPath))
|
|
108
86
|
: [{ items: shortcuts }]
|
|
@@ -51,12 +51,13 @@ import { Tooltip } from '../utilities/Popover.jsx'
|
|
|
51
51
|
* @param {string} accentColor outline + handle + label color (default var(--kol-accent-primary))
|
|
52
52
|
* @param {Function} labelFormatter (box) => string — dimension readout (default `${round(w)} × ${round(h)}`)
|
|
53
53
|
* @param {string} rotateTitle tooltip on the rotate handle (default 'Rotate')
|
|
54
|
-
* @param {'
|
|
54
|
+
* @param {'corners'} variant the corner build (see CORNERS below); unset, the default build. The old theme words
|
|
55
|
+
* `kolbox` and `folio` are accepted and ask for `corners` (plan-2026-11-29-one-set-fold W3, on the ledger)
|
|
55
56
|
* @param {number} scale screen px per virtual px (default: the zoom); a host whose stage is also fitted passes
|
|
56
57
|
* fit × zoom so 1 screen px stays 1
|
|
57
58
|
*
|
|
58
|
-
*
|
|
59
|
-
* like in figma"): one solid 1 screen px accent line, four white 6 squares with a 1px accent edge at the corners only
|
|
59
|
+
* CORNERS (`variant="corners"`, was `variant="kolbox"`, plan-2026-11-19-kolbox-whats-left R2, his Figma reference "this is
|
|
60
|
+
* how shape looks like in figma"; its plain name since plan-2026-11-29-one-set-fold W3, decided for his review): one solid 1 screen px accent line, four white 6 squares with a 1px accent edge at the corners only
|
|
60
61
|
* (SelectionBox 28:9356's handle size), no name, and the size on an accent chip centred 8 px under the box (the design's
|
|
61
62
|
* label: medium 10 / 14, 8 by 2 in, radius 4, the accent's own ink). The sides and the rotate are NOT drawn but still
|
|
62
63
|
* answer the pointer: an 8 px band on each side (`data-handle` N, E, S, W, the resize cursors) and a 16 px zone just
|
|
@@ -78,6 +79,9 @@ const HANDLE_DIRS = [
|
|
|
78
79
|
* compensation — fxr's number. */
|
|
79
80
|
const ROTATE_OFFSET = 22
|
|
80
81
|
|
|
82
|
+
/* the old theme words in `variant`: accepted, they ask for `corners` (W3, on the retirement ledger) */
|
|
83
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
84
|
+
|
|
81
85
|
export default function SelectionOverlay({
|
|
82
86
|
box,
|
|
83
87
|
showHandles = true,
|
|
@@ -96,7 +100,7 @@ export default function SelectionOverlay({
|
|
|
96
100
|
const zoom = useContext(CanvasZoomContext)
|
|
97
101
|
|
|
98
102
|
if (!box || box.x == null) return null /* no positional box → no chrome */
|
|
99
|
-
if (variant === '
|
|
103
|
+
if (variant === 'corners' || THEME_WORDS.includes(variant)) return <SelectionCorners box={box} s={scale || zoom || 1} showHandles={showHandles} showRotate={showRotate} showLabel={showLabel} labelFormatter={labelFormatter} />
|
|
100
104
|
|
|
101
105
|
const { x, y, w, h } = box
|
|
102
106
|
const size = handleSize / zoom
|
|
@@ -211,14 +215,14 @@ export default function SelectionOverlay({
|
|
|
211
215
|
)
|
|
212
216
|
}
|
|
213
217
|
|
|
214
|
-
/* the
|
|
215
|
-
const
|
|
218
|
+
/* the corner build (see the header): every screen-constant size is `n * px`, px being one screen px in virtual px */
|
|
219
|
+
const CORNERS = [
|
|
216
220
|
{ dir: 'NW', cursor: 'nwse-resize', x: 0, y: 0 },
|
|
217
221
|
{ dir: 'NE', cursor: 'nesw-resize', x: 1, y: 0 },
|
|
218
222
|
{ dir: 'SE', cursor: 'nwse-resize', x: 1, y: 1 },
|
|
219
223
|
{ dir: 'SW', cursor: 'nesw-resize', x: 0, y: 1 },
|
|
220
224
|
]
|
|
221
|
-
function
|
|
225
|
+
function SelectionCorners({ box, s, showHandles = true, showRotate, showLabel = true, labelFormatter }) {
|
|
222
226
|
const { x, y, w, h } = box
|
|
223
227
|
const px = 1 / s
|
|
224
228
|
const hs = 6 * px, band = 8 * px, rz = 16 * px
|
|
@@ -230,10 +234,10 @@ function KolboxSelection({ box, s, showHandles = true, showRotate, showLabel = t
|
|
|
230
234
|
const zone = { position: 'absolute', pointerEvents: 'auto' }
|
|
231
235
|
return (
|
|
232
236
|
<>
|
|
233
|
-
<div data-selection="
|
|
237
|
+
<div data-selection="corners" style={{ position: 'absolute', left: x, top: y, width: w, height: h, transform: rot ? `rotate(${rot}deg)` : undefined, pointerEvents: 'none', zIndex: 100 }}>
|
|
234
238
|
{/* a spread shadow, not an outline: an outline's width is rounded to whole layout px before the zoom scales it */}
|
|
235
239
|
<div data-selection-line style={{ position: 'absolute', inset: 0, boxShadow: `0 0 0 ${px}px ${accent}` }} />
|
|
236
|
-
{rotate &&
|
|
240
|
+
{rotate && CORNERS.map(({ dir, x: cx, y: cy }) => (
|
|
237
241
|
<div key={`r${dir}`} data-handle="ROT" style={{ ...zone, left: cx ? '100%' : -rz, top: cy ? '100%' : -rz, width: rz, height: rz, cursor: 'var(--kol-cursor-rotate, grab)' }} />
|
|
238
242
|
))}
|
|
239
243
|
{showHandles && (
|
|
@@ -242,7 +246,7 @@ function KolboxSelection({ box, s, showHandles = true, showRotate, showLabel = t
|
|
|
242
246
|
<div data-handle="S" style={{ ...zone, left: hs, right: hs, bottom: -band / 2, height: band, cursor: 'ns-resize' }} />
|
|
243
247
|
<div data-handle="W" style={{ ...zone, top: hs, bottom: hs, left: -band / 2, width: band, cursor: 'ew-resize' }} />
|
|
244
248
|
<div data-handle="E" style={{ ...zone, top: hs, bottom: hs, right: -band / 2, width: band, cursor: 'ew-resize' }} />
|
|
245
|
-
{
|
|
249
|
+
{CORNERS.map(({ dir, cursor, x: cx, y: cy }) => (
|
|
246
250
|
<div
|
|
247
251
|
key={dir}
|
|
248
252
|
data-handle={dir}
|