@kolkrabbi/kol-component 0.389.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/Modal.jsx +2 -0
- package/src/molecules/TocRow.jsx +4 -3
- package/src/organisms/CommandOverlay.jsx +48 -117
- 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",
|
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}
|
package/src/molecules/TocRow.jsx
CHANGED
|
@@ -9,15 +9,16 @@
|
|
|
9
9
|
* @param {ReactNode} label
|
|
10
10
|
* @param {boolean} [current]
|
|
11
11
|
* @param {string} [href]
|
|
12
|
+
* @param {ElementType} [linkComponent] a router's Link for `href` (it gets `to`); default `a`
|
|
12
13
|
* @param {Function} [onClick]
|
|
13
14
|
* @param {string} [className]
|
|
14
15
|
*/
|
|
15
|
-
export default function TocRow({ number, label, current = false, href, onClick, className = '' }) {
|
|
16
|
-
const Tag = href ? 'a' : 'button'
|
|
16
|
+
export default function TocRow({ number, label, current = false, href, linkComponent, onClick, className = '' }) {
|
|
17
|
+
const Tag = href ? (linkComponent ?? 'a') : 'button'
|
|
17
18
|
const n = typeof number === 'number' ? String(number).padStart(2, '0') : number
|
|
18
19
|
return (
|
|
19
20
|
<Tag
|
|
20
|
-
{...(href ? { href } : { type: 'button' })}
|
|
21
|
+
{...(href ? (Tag === 'a' ? { href } : { to: href }) : { type: 'button' })}
|
|
21
22
|
onClick={onClick}
|
|
22
23
|
aria-current={current ? 'location' : undefined}
|
|
23
24
|
className={`group flex h-8 w-full items-center gap-4 rounded-[var(--kol-float-list-r)] px-3 text-left no-underline cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)] ${current ? 'bg-fg-12' : 'hover:bg-fg-04'} ${className}`.trim()}
|
|
@@ -6,7 +6,6 @@ import OptionRow from '../molecules/OptionRow.jsx'
|
|
|
6
6
|
import { PopoverLayer } from '../utilities/Popover.jsx'
|
|
7
7
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
8
8
|
import SearchInput from '../molecules/SearchInput.jsx'
|
|
9
|
-
import ModalShell from '../molecules/ModalShell.jsx'
|
|
10
9
|
import Tag from '../atoms/Tag.jsx'
|
|
11
10
|
import TabsRow from '../molecules/TabsRow.jsx'
|
|
12
11
|
import { shortcutInScope } from './ShortcutsOverlay.jsx'
|
|
@@ -153,10 +152,10 @@ function unfold(rows, opened) {
|
|
|
153
152
|
* @param {string} [selectLabel] the footer's Enter line while a row is highlighted (default
|
|
154
153
|
* `Go to page`) — a modal whose rows are not pages says what
|
|
155
154
|
* Enter does instead (the rack's module search: `Add module`)
|
|
156
|
-
* @param {
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
155
|
+
* @param {Array} [groups] the grouped build instead (see `CommandOverlayGrouped`): the host keeps the rows and the
|
|
156
|
+
* lit row. Without it this build: the KOL search modal (the overlay panel, the field in a
|
|
157
|
+
* grey tone, OptionRow rows, the Kbd footer), as it was drawn up to 0.341.1.
|
|
158
|
+
* @param {'kolbox'|'folio'} [variant] the old theme words, accepted: they ask for the grouped build (W3, on the ledger).
|
|
160
159
|
*/
|
|
161
160
|
function CommandOverlayDefault({
|
|
162
161
|
open,
|
|
@@ -498,32 +497,30 @@ function CommandOverlayDefault({
|
|
|
498
497
|
)
|
|
499
498
|
}
|
|
500
499
|
|
|
501
|
-
/* ── kolbox
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
* `
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
|
|
514
|
-
* Escape is the layer's. */
|
|
515
|
-
function MatchKolbox({ label, query }) {
|
|
500
|
+
/* ── grouped (kolbox's ModalSearch, plan-2026-11-18-kolbox-system W31.2 batch 5; one build since plan-2026-11-29-one-set-fold W3) ──
|
|
501
|
+
* The search modal the host draws from `groups`: the panel `--kol-command-w` wide (576), radius 12, on the one floating
|
|
502
|
+
* surface, in PopoverLayer's body on the dim, 20% down. The field (Input lg, the lens, the ⌘K mark while empty), the
|
|
503
|
+
* tabs (TabsRow track), then the groups: a title and its rows (TreeRow lg, touching, the active one lit, the hint at the
|
|
504
|
+
* right), then a rule and the foot (↑↓ Navigate, ↵ Run, Esc Close). Presentational: the host passes the rows and keeps the
|
|
505
|
+
* state. CommandOverlay's words: `open`, `onClose`, `query`, `onQueryChange`, `placeholder`, `tabs` [{ value, label }],
|
|
506
|
+
* `onSelect(row)`, `mode` ('search', or 'shortcuts': the S sheet, the same panel with no field and no tabs, Enter folds a
|
|
507
|
+
* key's section back up and never runs it). Its own: `tab`, `onTab`, `groups` [{ title, rows: [{ id, icon, label, body,
|
|
508
|
+
* hint, kbd, disabled, disabledHint, items, open }] }] (a row with `items` is a fold), `active` (an index into the rows in
|
|
509
|
+
* group order), `onActive(index)`, `empty` (what can be searched, said when nothing is found: plan-2026-11-19 C5.1b). Keys
|
|
510
|
+
* in the field: ↑↓ move the lit row over disabled rows, Enter runs it, Tab and ⇧Tab step the tabs, → and ← open and close
|
|
511
|
+
* a fold while the field is empty, ⌘↵ all folds; Escape is the layer's. Its look is `--kol-command-*` in kol-theme. */
|
|
512
|
+
function MatchLabel({ label, query }) {
|
|
516
513
|
/* a label the host has marked itself (a node) is drawn as it is */
|
|
517
514
|
if (typeof label !== 'string') return label
|
|
518
515
|
const at = query ? label.toLowerCase().indexOf(query.toLowerCase()) : -1
|
|
519
516
|
if (at < 0) return label
|
|
520
517
|
return <>{label.slice(0, at)}<span className="underline decoration-2 underline-offset-[3px]">{label.slice(at, at + query.length)}</span>{label.slice(at + query.length)}</>
|
|
521
518
|
}
|
|
522
|
-
const
|
|
519
|
+
const FootKey = ({ k, children }) => <span className="flex items-center gap-1"><KbdKeys size="sm" keys={k} />{children}</span>
|
|
523
520
|
/* a fold's rows indented to its label: the row's 12 inset, the 20 icon and its 12 gap */
|
|
524
|
-
const
|
|
521
|
+
const FOLD_INDENT = { paddingLeft: 'calc(var(--kol-spacing-3) * 2 + 20px)' }
|
|
525
522
|
|
|
526
|
-
function
|
|
523
|
+
function CommandOverlayGrouped({ open, onClose, mode = 'search', query = '', onQueryChange, placeholder = 'Search tools, actions, pages…', tabs = [], tab, onTab, groups = [], active = -1, onActive, onSelect, empty, mark = '⌘K', 'aria-label': ariaLabel }) {
|
|
527
524
|
const field = mode !== 'shortcuts'
|
|
528
525
|
const input = useRef(null)
|
|
529
526
|
const panel = useRef(null)
|
|
@@ -597,11 +594,11 @@ function CommandOverlayKolbox({ open, onClose, mode = 'search', query = '', onQu
|
|
|
597
594
|
data-kolbox-search=""
|
|
598
595
|
tabIndex={field ? undefined : -1}
|
|
599
596
|
onKeyDown={field ? undefined : key}
|
|
600
|
-
className="kol-command
|
|
597
|
+
className="kol-command-panel kol-kolbox-surface mt-[20vh] flex max-w-[calc(100vw-var(--kol-spacing-8))] flex-col self-start overflow-hidden outline-none"
|
|
601
598
|
>
|
|
602
599
|
{field && (
|
|
603
600
|
<div className="flex flex-col gap-2 p-2">
|
|
604
|
-
<Input
|
|
601
|
+
<Input
|
|
605
602
|
ref={input}
|
|
606
603
|
size="lg"
|
|
607
604
|
iconLeft="search"
|
|
@@ -614,8 +611,8 @@ function CommandOverlayKolbox({ open, onClose, mode = 'search', query = '', onQu
|
|
|
614
611
|
value={query}
|
|
615
612
|
onChange={(e) => onQueryChange?.(e.target.value)}
|
|
616
613
|
onKeyDown={key}
|
|
617
|
-
slotRight={!query && mark && <KbdKeys
|
|
618
|
-
{tabs.length > 0 && <TabsRow variant="
|
|
614
|
+
slotRight={!query && mark && <KbdKeys size="sm" keys={mark} />} />
|
|
615
|
+
{tabs.length > 0 && <TabsRow variant="track" tabs={tabs} value={tab} onChange={onTab} className="h-10! w-full [&>button]:flex-1 [&>button]:px-4" />}
|
|
619
616
|
</div>
|
|
620
617
|
)}
|
|
621
618
|
{(rows.length > 0 || field) && (
|
|
@@ -636,7 +633,7 @@ function CommandOverlayKolbox({ open, onClose, mode = 'search', query = '', onQu
|
|
|
636
633
|
return (
|
|
637
634
|
<TreeRow
|
|
638
635
|
key={r.id}
|
|
639
|
-
variant="kolbox"
|
|
636
|
+
variant="kolbox" /* TreeRow's own fold is W5: until then its theme word draws this row */
|
|
640
637
|
size="lg"
|
|
641
638
|
id={`${listId}-${i}`}
|
|
642
639
|
role="option"
|
|
@@ -648,16 +645,16 @@ function CommandOverlayKolbox({ open, onClose, mode = 'search', query = '', onQu
|
|
|
648
645
|
icon={r.of ? undefined : r.icon}
|
|
649
646
|
label={r.body
|
|
650
647
|
/* `body`, an optional second line (Folio's word): the row grows to hold it; a row without one is as before */
|
|
651
|
-
? <span className="flex min-w-0 flex-col"><span className="truncate"><
|
|
652
|
-
: <
|
|
648
|
+
? <span className="flex min-w-0 flex-col"><span className="truncate"><MatchLabel label={r.label} query={query} /></span><span className="kol-command-body truncate">{r.body}</span></span>
|
|
649
|
+
: <MatchLabel label={r.label} query={query} />}
|
|
653
650
|
className={r.body ? 'h-auto! min-h-10 py-1.5' : undefined}
|
|
654
651
|
active={i === active}
|
|
655
652
|
disabled={r.disabled}
|
|
656
653
|
onMouseDown={(e) => e.preventDefault()}
|
|
657
654
|
onMouseEnter={() => !r.disabled && onActive?.(i)}
|
|
658
655
|
onClick={() => pick(r)}
|
|
659
|
-
trailing={hint && (r.kbd && hint === r.hint ? <KbdKeys
|
|
660
|
-
{...(r.of ? { style:
|
|
656
|
+
trailing={hint && (r.kbd && hint === r.hint ? <KbdKeys keys={hint} size="md" className="pl-3" /> : <span className="kol-command-hint max-w-1/2 shrink-0 truncate pl-3">{hint}</span>)}
|
|
657
|
+
{...(r.of ? { style: FOLD_INDENT } : {})}
|
|
661
658
|
/>
|
|
662
659
|
)
|
|
663
660
|
})}
|
|
@@ -666,14 +663,14 @@ function CommandOverlayKolbox({ open, onClose, mode = 'search', query = '', onQu
|
|
|
666
663
|
</div>}
|
|
667
664
|
<div role="separator" className="kol-command-rule mt-2 h-px shrink-0" />
|
|
668
665
|
<footer className="kol-command-foot flex h-10 shrink-0 items-center gap-4 px-4">
|
|
669
|
-
{rows.length > 1 && <
|
|
670
|
-
{rows.length > 0 && <
|
|
666
|
+
{rows.length > 1 && <FootKey k="↑↓">Navigate</FootKey>}
|
|
667
|
+
{rows.length > 0 && <FootKey k="↵">{enter}</FootKey>}
|
|
671
668
|
<button type="button" onMouseDown={(e) => e.preventDefault()} onClick={onClose} className="outline-none">
|
|
672
|
-
<
|
|
669
|
+
<FootKey k="Esc">Close</FootKey>
|
|
673
670
|
</button>
|
|
674
671
|
{folds.length > 0 && !query && (
|
|
675
672
|
<button type="button" onMouseDown={(e) => e.preventDefault()} onClick={toggleAll} className="ml-auto outline-none" data-fold-all>
|
|
676
|
-
<
|
|
673
|
+
<FootKey k="⌘↵">{allOpen ? 'Collapse all' : 'Expand all'}</FootKey>
|
|
677
674
|
</button>
|
|
678
675
|
)}
|
|
679
676
|
</footer>
|
|
@@ -684,84 +681,13 @@ function CommandOverlayKolbox({ open, onClose, mode = 'search', query = '', onQu
|
|
|
684
681
|
)
|
|
685
682
|
}
|
|
686
683
|
|
|
687
|
-
/* ──
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
* then each row: `label` (a node, the matches marked by the host) with `group` at the right, `hint`
|
|
693
|
-
* under it, `body` (Folio's word: a line of the text) under that
|
|
694
|
-
* mode 'commands' the command list (Folio's CommandPalette, ⇧⌘P): 640 wide, no dim, the field, then rows of `label`
|
|
695
|
-
* with `hint` (the keys) at the right
|
|
696
|
-
* CommandOverlay's words: `open`, `onClose`, `query`, `onQueryChange`, `placeholder`, `results` `[{ id, label, group,
|
|
697
|
-
* hint, body }]`, `onSelect(row)` (also on Enter with no row in `commands`, so Enter there always closes), `aria-label`.
|
|
698
|
-
* kolbox's: `active`, `onActive`, `empty` (said under the field when it is set). Keys in the field: ↑↓ move the lit
|
|
699
|
-
* row, Enter picks, Escape closes. */
|
|
700
|
-
function CommandOverlayFolio({ open, onClose, mode = 'search', query = '', onQueryChange, placeholder, results = [], active = 0, onActive, onSelect, empty, 'aria-label': label }) {
|
|
701
|
-
const commands = mode === 'commands'
|
|
702
|
-
const input = useRef(null)
|
|
703
|
-
useEffect(() => { if (open && !commands) setTimeout(() => input.current?.focus(), 0) }, [open]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
704
|
-
if (!open) return null
|
|
705
|
-
const onKey = (e) => {
|
|
706
|
-
if (e.key === 'Escape') onClose?.()
|
|
707
|
-
if (e.key === 'ArrowDown') { e.preventDefault(); onActive?.(Math.min(active + 1, results.length - 1)) }
|
|
708
|
-
if (e.key === 'ArrowUp') { e.preventDefault(); onActive?.(Math.max(active - 1, 0)) }
|
|
709
|
-
if (e.key === 'Enter') {
|
|
710
|
-
if (commands) { e.preventDefault(); onSelect?.(results[active]) }
|
|
711
|
-
else if (results[active]) onSelect?.(results[active])
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
if (commands) {
|
|
715
|
-
return (
|
|
716
|
-
<div className="fixed inset-0 z-50 flex items-start justify-center px-[16px] pt-[12vh]" onMouseDown={onClose}>
|
|
717
|
-
<ModalShell variant="folio" role="dialog" aria-label={label} onMouseDown={(e) => e.stopPropagation()} className="kol-command--folio kol-command--folio-commands max-h-[60vh] w-[640px] max-w-full overflow-hidden">
|
|
718
|
-
<input autoFocus aria-label="Command" placeholder={placeholder} value={query} onChange={(e) => onQueryChange?.(e.target.value)} onKeyDown={onKey}
|
|
719
|
-
className="kol-command-field--folio h-[48px] shrink-0 border-b bg-transparent px-[16px] outline-none" />
|
|
720
|
-
<div role="listbox" aria-label={label} className="min-h-0 overflow-y-auto py-[6px]">
|
|
721
|
-
{results.map((r, i) => (
|
|
722
|
-
<button key={r.id ?? r.label} type="button" role="option" aria-selected={i === active} onMouseEnter={() => onActive?.(i)} onClick={() => onSelect?.(r)} className={`kol-command-row--folio${i === active ? ' is-active' : ''} flex h-[32px] w-full items-center px-[16px] text-left`}>
|
|
723
|
-
{r.label}<span className="kol-command-hint--folio ml-auto">{r.hint ?? ''}</span>
|
|
724
|
-
</button>
|
|
725
|
-
))}
|
|
726
|
-
{empty && <p className="kol-folio-meta kol-command-empty--folio px-[16px] py-[8px]">{empty}</p>}
|
|
727
|
-
</div>
|
|
728
|
-
</ModalShell>
|
|
729
|
-
</div>
|
|
730
|
-
)
|
|
731
|
-
}
|
|
732
|
-
return (
|
|
733
|
-
<div className="kol-modal-dim--folio fixed inset-0 z-50 flex items-start justify-center px-[16px] pt-[12vh]" onMouseDown={onClose}>
|
|
734
|
-
<ModalShell variant="folio" role="dialog" aria-label={label} className="kol-command--folio kol-command--folio-search max-h-[70vh] w-full max-w-[720px] overflow-hidden" onMouseDown={(e) => e.stopPropagation()}>
|
|
735
|
-
<label className="kol-command-head--folio flex h-[56px] shrink-0 items-center gap-[12px] border-b px-[18px]">
|
|
736
|
-
<IconLoader name="search" size={18} />
|
|
737
|
-
<input ref={input} value={query} onChange={(e) => onQueryChange?.(e.target.value)} onKeyDown={onKey} placeholder={placeholder} className="kol-command-search--folio min-w-0 flex-1 bg-transparent outline-none" />
|
|
738
|
-
<span className="kol-folio-meta kol-command-hint--folio">esc</span>
|
|
739
|
-
</label>
|
|
740
|
-
<div className="overflow-y-auto">
|
|
741
|
-
{empty && <p className="kol-folio-body kol-command-empty--folio px-[18px] py-[20px]">{empty}</p>}
|
|
742
|
-
{results.map((r, i) => (
|
|
743
|
-
<button key={r.id} type="button" onMouseEnter={() => onActive?.(i)} onClick={() => onSelect?.(r)} className={`kol-command-result--folio${i === active ? ' is-active' : ''} flex w-full flex-col gap-[6px] border-b px-[18px] py-[14px] text-left`}>
|
|
744
|
-
<span className="flex items-baseline justify-between gap-[16px]">
|
|
745
|
-
<span className="kol-folio-shelf">{r.label}</span>
|
|
746
|
-
<span className="kol-folio-label kol-command-hint--folio shrink-0">{r.group}</span>
|
|
747
|
-
</span>
|
|
748
|
-
{r.hint && <span className="kol-folio-meta kol-command-hint--folio">{r.hint}</span>}
|
|
749
|
-
{r.body && <span className="kol-folio-body kol-command-hint--folio">{r.body}</span>}
|
|
750
|
-
</button>
|
|
751
|
-
))}
|
|
752
|
-
</div>
|
|
753
|
-
</ModalShell>
|
|
754
|
-
</div>
|
|
755
|
-
)
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
/* ── kolbox, from `results` (Folio on kolbox, 2026-11-22) ──
|
|
759
|
-
* The folio branch's words under the kolbox look, so a host switches by the variant alone: `results` `[{ id, label, group,
|
|
760
|
-
* hint, body }]` become kolbox's groups (each `group` a titled group, in the order they first come; `hint` at the row's
|
|
761
|
-
* right, as key caps when it is one combo); `body`, when a row has one, is a second line under its label. `mode`
|
|
762
|
-
* 'commands' is the same panel with no group titles: the command list. The row handed to `onSelect` is the host's own. */
|
|
684
|
+
/* ── grouped, from `results` (Folio on kolbox, 2026-11-22) ──
|
|
685
|
+
* `results` `[{ id, label, group, hint, body }]` drawn as the grouped build: each `group` a titled group, in the order
|
|
686
|
+
* they first come; `hint` at the row's right, as key caps when it is one combo; `body`, when a row has one, a second line
|
|
687
|
+
* under its label. `mode` 'commands' is the same panel with no group titles: the command list. The row handed to
|
|
688
|
+
* `onSelect` is the host's own. Reached by an old theme word in `variant` with `results` (Folio's and kol-fxr's hosts). */
|
|
763
689
|
export const isKeyCombo = (s) => typeof s === 'string' && /^[⌘⇧⌥⌃]*[^\s⌘⇧⌥⌃]+$/.test(s)
|
|
764
|
-
function
|
|
690
|
+
function CommandOverlayFromResults({ results, mode, ...props }) {
|
|
765
691
|
const groups = []
|
|
766
692
|
results.forEach((r, i) => {
|
|
767
693
|
const title = mode === 'commands' ? undefined : r.group
|
|
@@ -770,11 +696,16 @@ function CommandOverlayKolboxResults({ results, mode, ...props }) {
|
|
|
770
696
|
g.rows.push({ ...r, id: r.id ?? `${i}:${typeof r.label === 'string' ? r.label : ''}`, hint: r.hint || undefined, kbd: isKeyCombo(r.hint) })
|
|
771
697
|
})
|
|
772
698
|
/* the field's ⌘K mark is the search modal's own key; the command list does not open on it */
|
|
773
|
-
return <
|
|
699
|
+
return <CommandOverlayGrouped {...props} mode="search" groups={groups} mark={mode === 'commands' ? null : undefined} />
|
|
774
700
|
}
|
|
775
701
|
|
|
702
|
+
/* WHICH BUILD (plan-2026-11-29-one-set-fold W3, decided for his review): `groups`, or `mode="commands"` (the command list
|
|
703
|
+
* from `results`), asks for the grouped build, which the host keeps (`active`, `tab`); without them the default build
|
|
704
|
+
* keeps its own state over `results` and `suggestions`. The old
|
|
705
|
+
* theme words in `variant` are accepted and ask for the grouped build, reading `results` when given (on the retirement
|
|
706
|
+
* ledger); the theme draws its look. Folio's own search modal and command list went to _tmp/2026-11-29-one-set-fold/. */
|
|
707
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
776
708
|
export default function CommandOverlay(props) {
|
|
777
|
-
if (props.
|
|
778
|
-
|
|
779
|
-
return <CommandOverlayDefault {...props} />
|
|
709
|
+
if (props.groups == null && props.mode !== 'commands' && !THEME_WORDS.includes(props.variant)) return <CommandOverlayDefault {...props} />
|
|
710
|
+
return props.results ? <CommandOverlayFromResults {...props} /> : <CommandOverlayGrouped {...props} />
|
|
780
711
|
}
|
|
@@ -20,36 +20,53 @@ import { LabeledControlSection } from './SettingsPanel.jsx'
|
|
|
20
20
|
* chapter, 12 under the count, 4 between rows; `current` lifted fg-16), then `progress` (`Through the book` and the
|
|
21
21
|
* share in mono over the float ProgressBar, 12 apart). Each part renders only when given.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* Folio's parts, optional (plan-2026-11-29-one-set-fold W3; Folio batch E, its own build until then): `eyebrow` over the
|
|
24
|
+
* book, `title` (the list's head, the `count` at its right), a chapter's `sections` under the current one (anchors, in
|
|
25
|
+
* past the number), a document's `headings` when there are no `chapters`, `empty` when there are neither, `progressText`
|
|
26
|
+
* for the share's figure (`3 / 9`), and `linkComponent` (a router's Link for a chapter's `href`).
|
|
27
|
+
*
|
|
28
|
+
* @param {ReactNode} [eyebrow] · {ReactNode} [book] · {ReactNode} [author] · {ReactNode} [title] · {ReactNode} [count] `9 interludes`
|
|
24
29
|
* @param {Array} chapters `[{ id, label, href? }]`
|
|
25
30
|
* @param {string} [current] the id the reader is in
|
|
26
31
|
* @param {Function} [onSelect] `(id) => void`
|
|
32
|
+
* @param {Array} [sections] the current chapter's headings `[{ id, label }]`, drawn under it
|
|
33
|
+
* @param {Array} [headings] a document's headings `[{ id, label }]`, drawn when there are no chapters
|
|
34
|
+
* @param {ReactNode} [empty] the line when there are neither
|
|
35
|
+
* @param {ElementType} [linkComponent] a router's Link for a chapter's `href`; default `a`
|
|
27
36
|
* @param {number} [progress] 0–100; unset, no progress line
|
|
28
37
|
* @param {string} [progressLabel] default `Through the book`
|
|
38
|
+
* @param {ReactNode} [progressText] the figure; default the share, `42%`
|
|
29
39
|
* @param {string} [className]
|
|
40
|
+
* @param {'folio'} [variant] the old theme word, accepted and does nothing (W3, on the retirement ledger); Folio's own
|
|
41
|
+
* build went to _tmp/2026-11-29-one-set-fold/
|
|
30
42
|
*/
|
|
31
|
-
function
|
|
43
|
+
export default function ReadingContents({ eyebrow, book, author, title, count, chapters = [], current, onSelect, sections = [], headings = [], empty, linkComponent, progress, progressLabel = 'Through the book', progressText, className = '' }) {
|
|
44
|
+
const ruler = (text) => <span className="kol-float-ruler uppercase text-fg-64">{text}</span>
|
|
32
45
|
return (
|
|
33
46
|
<div data-reading-contents="" className={`flex flex-col gap-6 ${className}`.trim()}>
|
|
34
|
-
{(book || author) && (
|
|
47
|
+
{(eyebrow || book || author) && (
|
|
35
48
|
<div className="flex flex-col gap-1">
|
|
49
|
+
{eyebrow && <span className="kol-float-hint text-fg-64">{eyebrow}</span>}
|
|
36
50
|
{book && <span className="kol-float-section text-fg-emphasis">{book}</span>}
|
|
37
51
|
{author && <span className="kol-float-hint text-fg-64">{author}</span>}
|
|
38
52
|
</div>
|
|
39
53
|
)}
|
|
40
|
-
{(count || chapters.length > 0) && (
|
|
54
|
+
{(title || count || chapters.length > 0 || headings.length > 0 || empty) && (
|
|
41
55
|
<LabeledControlSection as="nav" aria-label="Contents" rowGap={1}
|
|
42
|
-
label={count &&
|
|
43
|
-
{chapters.
|
|
44
|
-
<TocRow key={c.id} number={i + 1} label={c.label} href={c.href} current={c.id === current} onClick={onSelect ? () => onSelect(c.id) : undefined} className="h-9"
|
|
45
|
-
|
|
56
|
+
label={title ? ruler(title) : count && ruler(count)} end={title && count ? ruler(count) : undefined}>
|
|
57
|
+
{chapters.length > 0 ? chapters.flatMap((c, i) => [
|
|
58
|
+
<TocRow key={c.id} number={i + 1} label={c.label} href={c.href} linkComponent={linkComponent} current={c.id === current} onClick={onSelect ? () => onSelect(c.id) : undefined} className="h-9" />,
|
|
59
|
+
...(c.id === current ? sections.map((h) => <TocRow key={`${c.id}#${h.id}`} label={h.label} href={`#${h.id}`} className="pl-11" />) : []),
|
|
60
|
+
]) : headings.length > 0 ? headings.map((h, i) => (
|
|
61
|
+
<TocRow key={h.id} number={i + 1} label={h.label} href={`#${h.id}`} />
|
|
62
|
+
)) : empty && <span className="kol-float-hint px-3 text-fg-64">{empty}</span>}
|
|
46
63
|
</LabeledControlSection>
|
|
47
64
|
)}
|
|
48
65
|
{progress != null && (
|
|
49
66
|
<div className="flex flex-col gap-3">
|
|
50
67
|
<div className="flex items-center justify-between">
|
|
51
68
|
<span className="kol-float-hint text-fg-64">{progressLabel}</span>
|
|
52
|
-
<span className="kol-float-timecode tabular-nums text-fg-emphasis">{Math.round(progress)}
|
|
69
|
+
<span className="kol-float-timecode tabular-nums text-fg-emphasis">{progressText ?? `${Math.round(progress)}%`}</span>
|
|
53
70
|
</div>
|
|
54
71
|
<ProgressBar value={progress} ariaLabel={progressLabel} />
|
|
55
72
|
</div>
|
|
@@ -57,65 +74,3 @@ function ReadingContentsDefault({ book, author, count, chapters = [], current, o
|
|
|
57
74
|
</div>
|
|
58
75
|
)
|
|
59
76
|
}
|
|
60
|
-
|
|
61
|
-
/* ── folio (Folio batch E, 2026-11-22) ─────────────────────────────────────────────────────────────────────────────
|
|
62
|
-
* Folio's contents, carried from apps/folio's FolioDocument (the reader's left Rail, above the library tree): the
|
|
63
|
-
* `eyebrow` in Folio's label, the `book` title, the `author` line (Folio puts its chapter count or the document's kind
|
|
64
|
-
* there), 12 apart; then the list under its head (`title`, `Contents` by default, and the `count`, over a rule in the
|
|
65
|
-
* ink); then, for a book, `progress` (0 to 100) under `progressLabel` and its figure (`progressText`, the reader's
|
|
66
|
-
* "1 / 3"). Parts 28 apart, each drawn only when given. ReadingContents' words: `chapters` ({ id, label, href }),
|
|
67
|
-
* `current`. Folio's own: `sections` (the current chapter's headings, { id, label }, as anchors under it), `headings` (a
|
|
68
|
-
* document's headings when it is not a book, drawn quieter), `empty` (the line when there are neither), `linkComponent`
|
|
69
|
-
* (a router's Link for a chapter; default `a`) and `progressText`. */
|
|
70
|
-
function ReadingContentsFolio({ eyebrow, book, author, title = 'Contents', count, chapters = [], current, sections = [], headings = [], empty, linkComponent: L = 'a', progress, progressLabel = 'Through the book', progressText, className = '' }) {
|
|
71
|
-
const go = (href) => (L === 'a' ? { href } : { to: href })
|
|
72
|
-
return (
|
|
73
|
-
<div className={`kol-reading-contents--folio flex flex-col gap-[28px] ${className}`.trim()}>
|
|
74
|
-
<div className="flex flex-col gap-[12px]">
|
|
75
|
-
{eyebrow != null && <p className="kol-folio-label kol-reading-contents-muted">{eyebrow}</p>}
|
|
76
|
-
{book != null && <p className="kol-folio-book break-words">{book}</p>}
|
|
77
|
-
{author != null && <p className="kol-folio-body kol-reading-contents-muted">{author}</p>}
|
|
78
|
-
</div>
|
|
79
|
-
<nav aria-label="Contents" className="flex flex-col gap-[4px]">
|
|
80
|
-
<div className="kol-reading-contents-head flex justify-between border-b pb-[15px]">
|
|
81
|
-
<p className="kol-folio-nav">{title}</p>
|
|
82
|
-
<p className="kol-folio-meta kol-reading-contents-muted">{count}</p>
|
|
83
|
-
</div>
|
|
84
|
-
{chapters.length ? chapters.map((c, n) => {
|
|
85
|
-
const on = c.id === current
|
|
86
|
-
return (
|
|
87
|
-
<div key={c.id} className="flex flex-col">
|
|
88
|
-
<L {...go(c.href)} aria-current={on ? 'page' : undefined} className={`kol-reading-contents-row flex gap-[14px] rounded-[3px] px-[12px] py-[11px] ${on ? 'is-current' : ''}`.trim()}>
|
|
89
|
-
<span className="kol-folio-meta kol-reading-contents-number tabular-nums">{String(n + 1).padStart(2, '0')}</span>
|
|
90
|
-
<span className="kol-folio-nav min-w-0 flex-1">{c.label}</span>
|
|
91
|
-
</L>
|
|
92
|
-
{on && sections.length > 0 && (
|
|
93
|
-
<div className="kol-reading-contents-sections ml-[38px] flex flex-col border-l py-[4px]">
|
|
94
|
-
{sections.map((h) => <a key={h.id} href={`#${h.id}`} className="kol-folio-meta kol-reading-contents-quiet py-[6px] pl-[12px]">{h.label}</a>)}
|
|
95
|
-
</div>
|
|
96
|
-
)}
|
|
97
|
-
</div>
|
|
98
|
-
)
|
|
99
|
-
}) : headings.length ? headings.map((h, n) => (
|
|
100
|
-
<a key={h.id} href={`#${h.id}`} className="kol-reading-contents-heading kol-reading-contents-quiet flex gap-[12px] rounded-[3px] px-[12px] py-[9px]">
|
|
101
|
-
<span className="kol-folio-meta tabular-nums">{String(n + 1).padStart(2, '0')}</span>
|
|
102
|
-
<span className="kol-folio-nav min-w-0 flex-1">{h.label}</span>
|
|
103
|
-
</a>
|
|
104
|
-
)) : <p className="kol-folio-meta kol-reading-contents-muted px-[12px] py-[9px]">{empty}</p>}
|
|
105
|
-
</nav>
|
|
106
|
-
{progress != null && (
|
|
107
|
-
<div className="kol-reading-contents-progress flex flex-col gap-[12px] border-t pt-[19px]">
|
|
108
|
-
<div className="kol-folio-meta flex justify-between">
|
|
109
|
-
<p className="kol-reading-contents-muted">{progressLabel}</p>
|
|
110
|
-
<p className="kol-reading-contents-figure font-bold">{progressText}</p>
|
|
111
|
-
</div>
|
|
112
|
-
<div className="kol-reading-contents-track h-[4px]"><div className="kol-reading-contents-fill h-full" style={{ width: `${progress}%` }} /></div>
|
|
113
|
-
</div>
|
|
114
|
-
)}
|
|
115
|
-
</div>
|
|
116
|
-
)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default function ReadingContents(props) {
|
|
120
|
-
return props.variant === 'folio' ? <ReadingContentsFolio {...props} /> : <ReadingContentsDefault {...props} />
|
|
121
|
-
}
|
|
@@ -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}
|