@kolkrabbi/kol-component 0.264.0 → 0.265.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
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IconPlate — A glyph's specimen plate. The box IS the size: the ground, the keyline guide and the glyph
|
|
3
|
+
* share one square, so a 20 plate is 20px and the guide's lines are the glyph's own grid (CompareGridDevTab,
|
|
4
|
+
* kol-monitor 2026-10-17 — the icon gallery, the open-questions review and monitor's Dev tab each drew this
|
|
5
|
+
* plate by hand, and only one of the three sized it right).
|
|
6
|
+
*
|
|
7
|
+
* The ground is a SPECIMEN ground, literal on purpose: a light or dark plate the app theme never touches,
|
|
8
|
+
* so a glyph is judged on the same paper in either theme. The guide is the 24-unit keyline grid
|
|
9
|
+
* (Material-style: dashed diagonals, the three keyline rectangles, the centre circle).
|
|
10
|
+
*
|
|
11
|
+
* The plate draws no glyph of its own — pass one as children, sized to the plate (`<Icon size={size} />`,
|
|
12
|
+
* raw SVG markup, anything). `size="fill"` takes the parent's width and stays square.
|
|
13
|
+
*
|
|
14
|
+
* @param {number|'fill'} [size=24] the plate's edge in px, or 'fill'
|
|
15
|
+
* @param {'light'|'dark'} [ground='light']
|
|
16
|
+
* @param {boolean} [guide=false] the keyline grid behind the glyph
|
|
17
|
+
*/
|
|
18
|
+
export default function IconPlate({ size = 24, ground = 'light', guide = false, className = '', style, children, ...rest }) {
|
|
19
|
+
const light = ground !== 'dark'
|
|
20
|
+
const box = size === 'fill' ? { width: '100%', aspectRatio: '1 / 1' } : { width: size, height: size }
|
|
21
|
+
return (
|
|
22
|
+
<span
|
|
23
|
+
{...rest}
|
|
24
|
+
className={`relative inline-flex shrink-0 items-center justify-center overflow-hidden ${className}`.trim()}
|
|
25
|
+
style={{ ...box, background: light ? '#FFFFFF' : '#0E0E11', color: light ? '#0E0E11' : '#FFFFFF', ...style }}
|
|
26
|
+
>
|
|
27
|
+
{guide && <KeylineGuide light={light} />}
|
|
28
|
+
{children}
|
|
29
|
+
</span>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* KeylineGuide — The 24-unit keyline grid. Fills its positioned parent; diagonals in teal, keylines in
|
|
35
|
+
* magenta on a light ground and yellow on a dark one.
|
|
36
|
+
*
|
|
37
|
+
* @param {boolean} [light=true] which ground it is drawn on
|
|
38
|
+
*/
|
|
39
|
+
export function KeylineGuide({ light = true }) {
|
|
40
|
+
const key = light ? '#CA3ABC' : '#F2D24B'
|
|
41
|
+
return (
|
|
42
|
+
<svg aria-hidden="true" width="100%" height="100%" viewBox="0 0 24 24" style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
|
|
43
|
+
<g stroke="#0A8DA4" strokeWidth="0.1" strokeDasharray="0.4 0.6" fill="none">
|
|
44
|
+
<path d="M0 0 L24 24" />
|
|
45
|
+
<path d="M24 0 L0 24" />
|
|
46
|
+
</g>
|
|
47
|
+
<g stroke={key} strokeWidth="0.1" strokeDasharray="0.4 0.6" fill="none">
|
|
48
|
+
<rect x="4" y="2" width="16" height="20" rx="1" />
|
|
49
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
50
|
+
<rect x="2" y="4" width="20" height="16" rx="1" />
|
|
51
|
+
<circle cx="12" cy="12" r="4" />
|
|
52
|
+
</g>
|
|
53
|
+
</svg>
|
|
54
|
+
)
|
|
55
|
+
}
|
package/src/index.js
CHANGED
|
@@ -35,6 +35,7 @@ export { default as DocsToc } from './molecules/DocsToc.jsx'
|
|
|
35
35
|
export { default as DropdownTagFilter } from './molecules/DropdownTagFilter.jsx'
|
|
36
36
|
export { default as EmptyState } from './molecules/EmptyState.jsx'
|
|
37
37
|
export { default as IconFrame } from './atoms/IconFrame.jsx'
|
|
38
|
+
export { default as IconPlate, KeylineGuide } from './atoms/IconPlate.jsx'
|
|
38
39
|
export { default as IconToggle } from './atoms/IconToggle.jsx'
|
|
39
40
|
export { default as ExitPreview } from './utilities/ExitPreview.jsx'
|
|
40
41
|
export { default as Figure } from './atoms/Figure.jsx'
|
|
@@ -127,11 +128,12 @@ export { default as ShapeDropdown } from './molecules/ShapeDropdown.jsx'
|
|
|
127
128
|
export { default as ShellDrawer } from './molecules/ShellDrawer.jsx'
|
|
128
129
|
export { default as ShellSearchOverlay } from './organisms/ShellSearchOverlay.jsx'
|
|
129
130
|
/* the keymap sheet — moved in from kol-shell 2026-09-28 so the workshop shell and the apps open ONE sheet on S */
|
|
130
|
-
export { default as ShortcutsOverlay } from './organisms/ShortcutsOverlay.jsx'
|
|
131
|
+
export { default as ShortcutsOverlay, shortcutInScope } from './organisms/ShortcutsOverlay.jsx'
|
|
131
132
|
export { default as Slider } from './molecules/Slider.jsx'
|
|
132
133
|
export { default as SpecList } from './molecules/SpecList.jsx'
|
|
133
134
|
export { default as SpectrumControls, HueStrip, SBSquare, WheelTriangle, AlphaStrip } from './organisms/SpectrumControls.jsx'
|
|
134
135
|
export { default as ColorPickerPopover } from './organisms/ColorPickerPopover.jsx'
|
|
136
|
+
export { default as CompareGrid } from './organisms/CompareGrid.jsx'
|
|
135
137
|
export { default as SplitToolButton } from './molecules/SplitToolButton.jsx'
|
|
136
138
|
export { default as ToolPalette } from './organisms/ToolPalette.jsx'
|
|
137
139
|
export { default as DocumentEditor } from './organisms/DocumentEditor.jsx'
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react'
|
|
2
|
+
import IconPlate from '../atoms/IconPlate.jsx'
|
|
3
|
+
import IconToggle from '../atoms/IconToggle.jsx'
|
|
4
|
+
import Pill from '../atoms/Pill.jsx'
|
|
5
|
+
import SegmentedToggle from '../atoms/SegmentedToggle.jsx'
|
|
6
|
+
import ViewToggle from '../atoms/ViewToggle.jsx'
|
|
7
|
+
|
|
8
|
+
/* taxonomy-ok: organism — a toolbar of atoms over a wall of IconPlate pairs */
|
|
9
|
+
|
|
10
|
+
const SIZES = [24, 48, 96, 128]
|
|
11
|
+
const GROUNDS = [
|
|
12
|
+
{ value: 'dark', label: 'Dark ground', icon: 'mode-toggle-01' },
|
|
13
|
+
{ value: 'light', label: 'Light ground', icon: 'brightness' },
|
|
14
|
+
]
|
|
15
|
+
/* states are the consumer's words (monitor: same · redrawn · missing); shown capitalised, in the order
|
|
16
|
+
* they first appear */
|
|
17
|
+
const stateLabel = (s) => s.charAt(0).toUpperCase() + s.slice(1)
|
|
18
|
+
const ACTUAL = 16
|
|
19
|
+
|
|
20
|
+
/* a side is a node or a renderer `(ctx) => node`; ctx is `{ size, ground, guide }` */
|
|
21
|
+
const draw = (side, ctx) => (typeof side === 'function' ? side(ctx) : side)
|
|
22
|
+
|
|
23
|
+
function Side({ name, item, side, size, ground, guide, showActual }) {
|
|
24
|
+
const node = item[side]
|
|
25
|
+
const missing = node == null
|
|
26
|
+
return (
|
|
27
|
+
<span className="inline-flex flex-col items-center gap-2">
|
|
28
|
+
<IconPlate size={size} ground={ground} guide={guide && !missing}>
|
|
29
|
+
{missing ? <span className="kol-mono-10 opacity-60 px-1 text-center break-all">{item.candidate ?? item.label}</span> : draw(node, { size, ground, guide })}
|
|
30
|
+
</IconPlate>
|
|
31
|
+
<span className="flex items-center gap-2">
|
|
32
|
+
{showActual && !missing && <IconPlate size={ACTUAL} ground={ground}>{draw(node, { size: ACTUAL, ground, guide: false })}</IconPlate>}
|
|
33
|
+
<span className="kol-mono-12 text-meta">{name}</span>
|
|
34
|
+
</span>
|
|
35
|
+
</span>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* CompareGrid — Two versions of many things, side by side. Each item is a pair of plates, A beside B, each
|
|
41
|
+
* side named in words, the item's name under the pair (CompareGridDevTab, kol-monitor 2026-10-17 — user:
|
|
42
|
+
* *"why are we inventing the wheel for this every time in multiple repos … the way you diff local vs DS is
|
|
43
|
+
* very confusing, its ill labeled, hard to read"*). The open-questions icon review was the readable one;
|
|
44
|
+
* this is it, for any two renderers.
|
|
45
|
+
*
|
|
46
|
+
* The toolbar is controls, not text: size (24 · 48 · 96 · 128), ground, guide, and a filter by state. A
|
|
47
|
+
* side draws at the chosen size on an `IconPlate`, with its real 16px size beside its name. A missing side
|
|
48
|
+
* is an empty plate carrying the item's name.
|
|
49
|
+
*
|
|
50
|
+
* @param {Array} items `[{ id, label, a, b, state?, candidate? }]` — `a` / `b` a node, or
|
|
51
|
+
* `({ size, ground, guide }) => node` (an Icon sized to `size`); `state` is the consumer's
|
|
52
|
+
* word ('same' · 'redrawn' · 'missing'), a chip and the filter; `candidate` names what an
|
|
53
|
+
* empty side would map to
|
|
54
|
+
* @param {Object} labels `{ a, b }` — what each side IS ("monitor" / "kol-icons", "old" / "new")
|
|
55
|
+
* @param {number} [defaultSize=96]
|
|
56
|
+
* @param {'light'|'dark'} [defaultGround='light']
|
|
57
|
+
* @param {boolean} [defaultGuide=true]
|
|
58
|
+
* @param {boolean} [showActual=true] the 16px real size beside each side's name
|
|
59
|
+
*/
|
|
60
|
+
export default function CompareGrid({ items = [], labels = { a: 'A', b: 'B' }, defaultSize = 96, defaultGround = 'light', defaultGuide = true, showActual = true, className = '' }) {
|
|
61
|
+
const [size, setSize] = useState(defaultSize)
|
|
62
|
+
const [ground, setGround] = useState(defaultGround)
|
|
63
|
+
const [guide, setGuide] = useState(defaultGuide)
|
|
64
|
+
const [filter, setFilter] = useState('all')
|
|
65
|
+
|
|
66
|
+
const states = useMemo(() => [...new Set(items.map((i) => i.state).filter(Boolean))], [items])
|
|
67
|
+
const counts = useMemo(() => Object.fromEntries(states.map((s) => [s, items.filter((i) => i.state === s).length])), [items, states])
|
|
68
|
+
const hasStates = states.length > 0
|
|
69
|
+
const shown = filter === 'all' ? items : items.filter((i) => i.state === filter)
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div className={`flex flex-col gap-6 ${className}`.trim()}>
|
|
73
|
+
<div className="flex flex-wrap items-center gap-4">
|
|
74
|
+
<SegmentedToggle ariaLabel="Size" value={size} onChange={setSize} options={SIZES.map((v) => ({ value: v, label: String(v) }))} size="sm" />
|
|
75
|
+
<ViewToggle variant="icon" options={GROUNDS} viewMode={ground} onViewChange={setGround} />
|
|
76
|
+
<IconToggle icon="grid" label="Guide" title="Keyline guide" pressed={guide} onChange={setGuide} size="sm" />
|
|
77
|
+
{hasStates && (
|
|
78
|
+
<SegmentedToggle
|
|
79
|
+
ariaLabel="Show"
|
|
80
|
+
value={filter}
|
|
81
|
+
onChange={setFilter}
|
|
82
|
+
size="sm"
|
|
83
|
+
options={[{ value: 'all', label: `All ${items.length}` }, ...states.map((s) => ({ value: s, label: `${stateLabel(s)} ${counts[s]}` }))]}
|
|
84
|
+
/>
|
|
85
|
+
)}
|
|
86
|
+
</div>
|
|
87
|
+
<div className="grid gap-4" style={{ gridTemplateColumns: `repeat(auto-fill, minmax(min(100%, ${2 * size + 52}px), 1fr))` }}>
|
|
88
|
+
{shown.map((item) => (
|
|
89
|
+
<div key={item.id} className="flex flex-col items-center gap-3 rounded border border-fg-08 p-3">
|
|
90
|
+
<div className="flex items-start gap-3">
|
|
91
|
+
<Side name={labels.a} item={item} side="a" size={size} ground={ground} guide={guide} showActual={showActual} />
|
|
92
|
+
<Side name={labels.b} item={item} side="b" size={size} ground={ground} guide={guide} showActual={showActual} />
|
|
93
|
+
</div>
|
|
94
|
+
<span className="flex flex-wrap items-center justify-center gap-2">
|
|
95
|
+
<span className="kol-mono-12 text-emphasis">{item.label}</span>
|
|
96
|
+
{item.state && <Pill size="sm" variant={item.state === 'same' ? 'secondary' : 'primary'}>{stateLabel(item.state)}</Pill>}
|
|
97
|
+
</span>
|
|
98
|
+
</div>
|
|
99
|
+
))}
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
@@ -4,6 +4,8 @@ import SearchInput from '../molecules/SearchInput.jsx'
|
|
|
4
4
|
import Tag from '../atoms/Tag.jsx'
|
|
5
5
|
import Kbd from '../atoms/Kbd.jsx'
|
|
6
6
|
import OptionRow from '../molecules/OptionRow.jsx'
|
|
7
|
+
import Button from '../atoms/Button.jsx'
|
|
8
|
+
import { Tooltip } from '../utilities/Popover.jsx'
|
|
7
9
|
|
|
8
10
|
/* ONE COLUMN (2026-09-30): rows, headings and footer sit on the field's own
|
|
9
11
|
* geometry — the p-2 inset, then the md control's 1px ring + 16px pad — so
|
|
@@ -91,6 +93,10 @@ export function HighlightMatch({ label, query, ranges }) {
|
|
|
91
93
|
* @param {Function} [onOpenResults] (query) => void — ⌘/Ctrl+Enter: every hit, on the consumer's
|
|
92
94
|
* own results surface. Plain Enter keeps its meaning.
|
|
93
95
|
* @param {string} [resultsLabel] the footer's second line for ⌘Enter (e.g. `All results`)
|
|
96
|
+
* @param {Function} [onBack] a drill-in's way back (CommandOverlayModes, kol-monitor 2026-10-17): set, the
|
|
97
|
+
* field row leads with a back arrow, and Backspace on an empty field calls it —
|
|
98
|
+
* instead of a "← All" row that scrolls away with the list
|
|
99
|
+
* @param {string} [backLabel] the arrow's tooltip (default `Back`) — name where it goes ("All modules")
|
|
94
100
|
* @param {string} [selectLabel] the footer's Enter line while a row is highlighted (default
|
|
95
101
|
* `Go to page`) — a modal whose rows are not pages says what
|
|
96
102
|
* Enter does instead (the rack's module search: `Add module`)
|
|
@@ -117,6 +123,8 @@ export default function ShellSearchOverlay({
|
|
|
117
123
|
onOpenResults,
|
|
118
124
|
resultsLabel = 'All results',
|
|
119
125
|
selectLabel = 'Go to page',
|
|
126
|
+
onBack,
|
|
127
|
+
backLabel = 'Back',
|
|
120
128
|
}) {
|
|
121
129
|
const panelRef = useRef(null)
|
|
122
130
|
const listRef = useRef(null)
|
|
@@ -173,7 +181,10 @@ export default function ShellSearchOverlay({
|
|
|
173
181
|
const optionId = (item) => `${listId}-${item.id}`
|
|
174
182
|
|
|
175
183
|
const handleKeyDown = (e) => {
|
|
176
|
-
if (e.key === '
|
|
184
|
+
if (e.key === 'Backspace' && !query && onBack) {
|
|
185
|
+
e.preventDefault()
|
|
186
|
+
onBack()
|
|
187
|
+
} else if (e.key === 'Escape') {
|
|
177
188
|
e.preventDefault()
|
|
178
189
|
onClose?.()
|
|
179
190
|
} else if (e.key === 'ArrowDown') {
|
|
@@ -237,9 +248,15 @@ export default function ShellSearchOverlay({
|
|
|
237
248
|
)}
|
|
238
249
|
{/* A REAL FIELD, inset in the panel (2026-09-30, shadcn's search modal as
|
|
239
250
|
* the aim) — the flush `bare` strip read as a hole, not a control. */}
|
|
240
|
-
<div className="kol-tone-grey p-2">
|
|
251
|
+
<div className="kol-tone-grey p-2 flex items-center gap-2">
|
|
252
|
+
{onBack && (
|
|
253
|
+
<Tooltip label={backLabel}>
|
|
254
|
+
{/* mousedown keeps focus in the field, as the rows do */}
|
|
255
|
+
<Button iconOnly="arrow-left" tone="ghost" size="md" aria-label={backLabel} onMouseDown={(e) => e.preventDefault()} onClick={onBack} />
|
|
256
|
+
</Tooltip>
|
|
257
|
+
)}
|
|
241
258
|
<SearchInput
|
|
242
|
-
className="w-full"
|
|
259
|
+
className="w-full min-w-0 flex-1"
|
|
243
260
|
value={query}
|
|
244
261
|
onChange={(e) => onQueryChange?.(e.target.value)}
|
|
245
262
|
placeholder={chips.length > 0 ? 'Narrow these results…' : placeholder}
|
|
@@ -41,8 +41,16 @@ import SettingsSections from './SettingsSections.jsx'
|
|
|
41
41
|
*
|
|
42
42
|
* @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)
|
|
43
43
|
* @param {Function} props.onClose
|
|
44
|
+
* @param {string} [props.currentPath] sections may carry `routes: ['/rack']` (CommandOverlayModes, kol-monitor
|
|
45
|
+
* 2026-10-17 — user: *"im in dev, how can I cable lock here?"*): with a path, the sections that work here come
|
|
46
|
+
* first and the rest sit muted under ELSEWHERE, never as if they worked here. A section without `routes`
|
|
47
|
+
* works everywhere. Bind keys from the same scope with `shortcutInScope`.
|
|
44
48
|
*/
|
|
45
49
|
|
|
50
|
+
/** Does a shortcut section work on `path`? No `routes` → everywhere; a route matches itself and below it. */
|
|
51
|
+
export const shortcutInScope = (section, path) => !section?.routes?.length || path == null
|
|
52
|
+
|| section.routes.some((r) => path === r || path.startsWith(`${r.replace(/\/$/, '')}/`))
|
|
53
|
+
|
|
46
54
|
const isSectioned = (list) => Array.isArray(list?.[0]?.items)
|
|
47
55
|
|
|
48
56
|
/* A shortcut as a settings ROW: the label on the left, the combo as the row's
|
|
@@ -57,7 +65,7 @@ const toRow = ({ label, combo, keys }) => ({
|
|
|
57
65
|
value: <span className="text-fg-32 kol-helper-12 sm:whitespace-nowrap">{combo ?? keys}</span>,
|
|
58
66
|
})
|
|
59
67
|
|
|
60
|
-
export default function ShortcutsOverlay({ shortcuts = [], onClose }) {
|
|
68
|
+
export default function ShortcutsOverlay({ shortcuts = [], onClose, currentPath }) {
|
|
61
69
|
useEffect(() => {
|
|
62
70
|
const onKey = (e) => { if (e.key === 'Escape') onClose?.() }
|
|
63
71
|
window.addEventListener('keydown', onKey)
|
|
@@ -65,6 +73,8 @@ export default function ShortcutsOverlay({ shortcuts = [], onClose }) {
|
|
|
65
73
|
}, [onClose])
|
|
66
74
|
|
|
67
75
|
const sectioned = isSectioned(shortcuts)
|
|
76
|
+
const here = sectioned ? shortcuts.filter((s) => shortcutInScope(s, currentPath)) : []
|
|
77
|
+
const elsewhere = sectioned ? shortcuts.filter((s) => !shortcutInScope(s, currentPath)) : []
|
|
68
78
|
|
|
69
79
|
return (
|
|
70
80
|
<div
|
|
@@ -95,9 +105,15 @@ export default function ShortcutsOverlay({ shortcuts = [], onClose }) {
|
|
|
95
105
|
>
|
|
96
106
|
<SettingsSections
|
|
97
107
|
sections={sectioned
|
|
98
|
-
?
|
|
108
|
+
? here.map(({ section, items = [] }) => ({ label: section, rowGap: 1, rows: items.map(toRow) }))
|
|
99
109
|
: [{ rowGap: 1, rows: shortcuts.map(toRow) }]}
|
|
100
110
|
/>
|
|
111
|
+
{elsewhere.length > 0 && (
|
|
112
|
+
<div className="flex flex-col gap-4 opacity-[var(--kol-opacity-disabled)]">
|
|
113
|
+
<span className="kol-helper-10 text-fg-48">ELSEWHERE</span>
|
|
114
|
+
<SettingsSections sections={elsewhere.map(({ section, items = [] }) => ({ label: section, rowGap: 1, rows: items.map(toRow) }))} />
|
|
115
|
+
</div>
|
|
116
|
+
)}
|
|
101
117
|
</div>
|
|
102
118
|
</div>
|
|
103
119
|
)
|