@kolkrabbi/kol-component 0.329.0 → 0.331.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolkrabbi/kol-component",
3
- "version": "0.329.0",
3
+ "version": "0.331.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "embla-carousel-react": "^8.6.0",
27
27
  "pdfjs-dist": "^6.3.289",
28
28
  "react-syntax-highlighter": "^16.1.1",
29
- "@kolkrabbi/kol-growth": "^0.4.0",
30
29
  "@kolkrabbi/kol-search": "^0.3.0",
30
+ "@kolkrabbi/kol-growth": "^0.4.0",
31
31
  "@kolkrabbi/kol-markdown": "^0.2.0"
32
32
  },
33
33
  "peerDependencies": {
@@ -39,7 +39,7 @@
39
39
  "react-dom": "^18.3.0 || ^19.0.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@kolkrabbi/kol-icons": "^0.56.1"
42
+ "@kolkrabbi/kol-icons": "^0.60.0"
43
43
  },
44
44
  "files": [
45
45
  "src",
@@ -0,0 +1,171 @@
1
+ import { useEffect, useRef, useState } from 'react'
2
+ import { pathD, nearestSegmentT, splitSegment } from '../hooks/pathMath.js'
3
+
4
+ /* anchor · handle radius (px) per control rung; the hit target rides a wider transparent ring */
5
+ const RADII = { xs: [3.5, 2.5], sm: [4.5, 3], md: [5.5, 3.5] }
6
+ const HIT = 6
7
+
8
+ const clamp01 = (v) => Math.min(1, Math.max(0, v))
9
+
10
+ /**
11
+ * BezierPathEditor — Shape a path by dragging its nodes. a 2D bezier node editor: anchors with in / out
12
+ * handles, drawn in a box of any aspect, holding a value of normalised points.
13
+ *
14
+ * Lobby BezierPathEditor (kol-fxr, 2026-10-31): fxr hand-built two SVG editors for one job — the organic
15
+ * band's edge profile (`ProfileEditor`) and a kinetic layer's custom path (`CustomPathPoints`). KOL's
16
+ * `CurveEditor` authors expressions, not a drawn path, and `PathNodeOverlay` is stage chrome on the
17
+ * 1080-virtual canvas; this is the field-sized control. The geometry is `pathMath`'s (`pathD`,
18
+ * `nearestSegmentT`, `splitSegment`), so the path it draws is the one the editor's engine draws.
19
+ *
20
+ * VALUE. `[{ x, y, hl?, hr? }]`, x and y in 0–1 (0 = left / top). `hl` / `hr` are the in / out handles as
21
+ * OFFSETS from the anchor (`{ x, y }`, same units), so moving an anchor carries its handles; a node without
22
+ * one is a corner on that side. Controlled: every gesture fires `onChange(points)` with a new array, and a
23
+ * consumer with rules (ends locked, endpoints sharing y) enforces them there.
24
+ *
25
+ * GESTURES. Drag an anchor or a handle · double-click the box to add a node (split into the nearest
26
+ * segment, shape-preserving) · alt-click an anchor to delete it (never below `minPoints`). Anchors are
27
+ * clamped to the box; handles may leave it.
28
+ *
29
+ * INKS (the icon ink law — oq, never fg): the box is the control ground (surface-secondary), the path
30
+ * oq-80, leashes oq-24, handles oq-48, anchors the accent. No border.
31
+ *
32
+ * <BezierPathEditor value={pts} onChange={setPts} aspect={2} closed={false} size="sm" />
33
+ *
34
+ * @param {Array<{x:number, y:number, hl?:{x:number,y:number}, hr?:{x:number,y:number}}>} value - The nodes, normalised 0–1; handles are offsets from the anchor
35
+ * @param {(points:Array) => void} onChange - Fired with the next node array on every drag move, add and delete
36
+ * @param {boolean} [closed=false] - Close the path (last node joins the first)
37
+ * @param {number} [aspect=1] - The box's width ÷ height; it fills its container's width
38
+ * @param {'xs'|'sm'|'md'} [size='sm'] - The control rung — the anchor and handle sizes
39
+ * @param {number} [minPoints=2] - Alt-click never deletes below this many nodes
40
+ * @param {string} [ariaLabel='Path editor'] - The box's accessible name
41
+ * @param {string} [className] - Extra classes on the box
42
+ */
43
+ export default function BezierPathEditor({
44
+ value = [],
45
+ onChange,
46
+ closed = false,
47
+ aspect = 1,
48
+ size = 'sm',
49
+ minPoints = 2,
50
+ ariaLabel = 'Path editor',
51
+ className = '',
52
+ }) {
53
+ const ref = useRef(null)
54
+ const drag = useRef(null) /* { i, part: 'anchor'|'hl'|'hr' } */
55
+ const [box, setBox] = useState({ w: 0, h: 0 })
56
+ const [rA, rH] = RADII[size] ?? RADII.sm
57
+
58
+ useEffect(() => {
59
+ const el = ref.current
60
+ if (!el) return
61
+ const ro = new ResizeObserver(([e]) => setBox({ w: e.contentRect.width, h: e.contentRect.height }))
62
+ ro.observe(el)
63
+ return () => ro.disconnect()
64
+ }, [])
65
+
66
+ /* the 0–1 square is inset by an anchor's reach, so a node on an edge draws whole */
67
+ const pad = rA + 2
68
+ const w = Math.max(1, box.w - pad * 2), h = Math.max(1, box.h - pad * 2)
69
+ const pts = Array.isArray(value) ? value : []
70
+ /* normalised value → pathMath's absolute pixel nodes ({ x, y, in, out }) */
71
+ const abs = pts.map((p) => ({
72
+ x: pad + p.x * w, y: pad + p.y * h,
73
+ in: p.hl ? { x: pad + (p.x + p.hl.x) * w, y: pad + (p.y + p.hl.y) * h } : null,
74
+ out: p.hr ? { x: pad + (p.x + p.hr.x) * w, y: pad + (p.y + p.hr.y) * h } : null,
75
+ }))
76
+ const fromAbs = (n) => {
77
+ const p = { x: clamp01((n.x - pad) / w), y: clamp01((n.y - pad) / h) }
78
+ if (n.in) p.hl = { x: (n.in.x - pad) / w - p.x, y: (n.in.y - pad) / h - p.y }
79
+ if (n.out) p.hr = { x: (n.out.x - pad) / w - p.x, y: (n.out.y - pad) / h - p.y }
80
+ return p
81
+ }
82
+
83
+ const local = (e) => {
84
+ const r = ref.current.getBoundingClientRect()
85
+ return { x: (e.clientX - r.left - pad) / w, y: (e.clientY - r.top - pad) / h }
86
+ }
87
+
88
+ const onDown = (i, part) => (e) => {
89
+ e.stopPropagation()
90
+ if (part === 'anchor' && e.altKey) {
91
+ if (pts.length > minPoints) onChange?.(pts.filter((_, k) => k !== i))
92
+ return
93
+ }
94
+ e.preventDefault()
95
+ drag.current = { i, part }
96
+ try { ref.current.setPointerCapture(e.pointerId) } catch { /* */ }
97
+ }
98
+
99
+ const onMove = (e) => {
100
+ const d = drag.current
101
+ if (!d) return
102
+ const { x, y } = local(e)
103
+ onChange?.(pts.map((p, k) => {
104
+ if (k !== d.i) return p
105
+ if (d.part === 'anchor') return { ...p, x: clamp01(x), y: clamp01(y) }
106
+ return { ...p, [d.part]: { x: x - p.x, y: y - p.y } }
107
+ }))
108
+ }
109
+
110
+ const onUp = (e) => {
111
+ drag.current = null
112
+ try { ref.current.releasePointerCapture(e.pointerId) } catch { /* */ }
113
+ }
114
+
115
+ const onDoubleClick = (e) => {
116
+ if (e.target.closest('[data-node]')) return
117
+ const { x, y } = local(e)
118
+ const px = pad + x * w, py = pad + y * h
119
+ if (abs.length < 2) {
120
+ onChange?.([...pts, { x: clamp01(x), y: clamp01(y) }])
121
+ return
122
+ }
123
+ const segs = abs.length - 1 + (closed ? 1 : 0)
124
+ let best = { i: 0, t: 0.5, dist: Infinity }
125
+ for (let i = 0; i < segs; i++) {
126
+ const hit = nearestSegmentT(abs[i], abs[(i + 1) % abs.length], px, py)
127
+ if (hit.dist < best.dist) best = { i, ...hit }
128
+ }
129
+ const j = (best.i + 1) % abs.length
130
+ const sp = splitSegment(abs[best.i], abs[j], best.t)
131
+ const next = pts.slice()
132
+ next[best.i] = fromAbs(sp.a)
133
+ next[j] = fromAbs(sp.b)
134
+ next.splice(best.i + 1, 0, fromAbs(sp.mid))
135
+ onChange?.(next)
136
+ }
137
+
138
+ return (
139
+ <div
140
+ ref={ref}
141
+ role="group"
142
+ aria-label={ariaLabel}
143
+ className={`kol-bezier-path-editor relative w-full overflow-hidden touch-none select-none rounded-[var(--kol-radius-sm)] bg-[var(--kol-tone-bg,var(--kol-surface-secondary))] ${className}`.trim()}
144
+ style={{ aspectRatio: String(aspect) }}
145
+ onPointerMove={onMove}
146
+ onPointerUp={onUp}
147
+ onPointerCancel={onUp}
148
+ onDoubleClick={onDoubleClick}
149
+ >
150
+ {box.w > 0 && (
151
+ <svg className="absolute inset-0 overflow-visible" width={box.w} height={box.h} viewBox={`0 0 ${box.w} ${box.h}`}>
152
+ <path d={pathD(abs, closed)} fill="none" stroke="var(--kol-oq-80)" strokeWidth="1.5" />
153
+ {abs.map((n, i) => (
154
+ <g key={i} data-node="">
155
+ {['in', 'out'].map((side) => n[side] && (
156
+ <g key={side}>
157
+ <line x1={n.x} y1={n.y} x2={n[side].x} y2={n[side].y} stroke="var(--kol-oq-24)" strokeWidth="1" />
158
+ <circle cx={n[side].x} cy={n[side].y} r={rH + HIT} fill="transparent" className="cursor-grab"
159
+ onPointerDown={onDown(i, side === 'in' ? 'hl' : 'hr')} />
160
+ <circle cx={n[side].x} cy={n[side].y} r={rH} fill="var(--kol-oq-48)" pointerEvents="none" />
161
+ </g>
162
+ ))}
163
+ <circle cx={n.x} cy={n.y} r={rA + HIT} fill="transparent" className="cursor-grab" onPointerDown={onDown(i, 'anchor')} />
164
+ <circle cx={n.x} cy={n.y} r={rA} fill="var(--kol-accent-primary)" pointerEvents="none" />
165
+ </g>
166
+ ))}
167
+ </svg>
168
+ )}
169
+ </div>
170
+ )
171
+ }
@@ -0,0 +1,109 @@
1
+ import { useEffect, useRef, useState } from 'react'
2
+
3
+ const PAD = 6
4
+ const fmt = (v) => (Math.abs(v) >= 100 ? v.toFixed(0) : v.toFixed(2))
5
+
6
+ /**
7
+ * FunctionPlot — Plot y = f(u) over one loop. a read-only plot of a function over u ∈ 0–1 with a cursor at
8
+ * the current u: the curve faint ahead of the cursor, solid behind it, a dot on the current value.
9
+ *
10
+ * Lobby FunctionPlot (kol-fxr, 2026-10-31): fxr's `params/ModulationEditor.jsx` drew its `ExprPlot` on a
11
+ * hand-built `<canvas>` with hard-coded colours. This is it in SVG on the KOL inks, so it follows light and
12
+ * dark with no colour reads. It samples one point per pixel of its width; it fills its container's width.
13
+ *
14
+ * DATA. `fn(u) → number` (sampled across u = 0…1), or `samples` (evenly spaced over u, used as given).
15
+ * The range is `min` / `max`, or the samples' own extent when unset (a flat line gets ±0.5).
16
+ * A live plot (audio, noise) is the caller re-rendering with a new `fn` or `cursor`.
17
+ *
18
+ * INKS (the icon ink law — oq, never fg): ground oq-04, the zero line oq-24 (drawn only when 0 is in range),
19
+ * the extent labels oq-48, the curve, cursor and dot in the accent.
20
+ *
21
+ * <FunctionPlot fn={(u) => Math.sin(u * Math.PI * 2)} cursor={phase} height={64} />
22
+ *
23
+ * @param {(u:number) => number} [fn] - The function to plot over u ∈ 0–1 (ignored when `samples` is given)
24
+ * @param {number[]} [samples] - Precomputed values, evenly spaced over u = 0…1
25
+ * @param {number} [min] - Bottom of the range (default: the lowest sample)
26
+ * @param {number} [max] - Top of the range (default: the highest sample)
27
+ * @param {number} [cursor] - The current u, 0–1 — draws the cursor line and dot; omit for none
28
+ * @param {number} [height=64] - The plot's height in px
29
+ * @param {boolean} [labels=true] - Show the range's max / min values at the left edge
30
+ * @param {string} [ariaLabel='Function plot'] - The plot's accessible name
31
+ * @param {string} [className] - Extra classes on the plot
32
+ */
33
+ export default function FunctionPlot({
34
+ fn,
35
+ samples,
36
+ min,
37
+ max,
38
+ cursor,
39
+ height = 64,
40
+ labels = true,
41
+ ariaLabel = 'Function plot',
42
+ className = '',
43
+ }) {
44
+ const ref = useRef(null)
45
+ const [w, setW] = useState(0)
46
+
47
+ useEffect(() => {
48
+ const el = ref.current
49
+ if (!el) return
50
+ const ro = new ResizeObserver(([e]) => setW(e.contentRect.width))
51
+ ro.observe(el)
52
+ return () => ro.disconnect()
53
+ }, [])
54
+
55
+ const innerW = Math.max(1, w - PAD * 2)
56
+ const innerH = Math.max(1, height - PAD * 2)
57
+ const vs = samples?.length
58
+ ? samples
59
+ : fn ? Array.from({ length: Math.round(innerW) + 1 }, (_, i) => fn(i / Math.round(innerW))) : []
60
+ const finite = vs.filter(Number.isFinite)
61
+ let lo = min ?? (finite.length ? Math.min(...finite) : 0)
62
+ let hi = max ?? (finite.length ? Math.max(...finite) : 1)
63
+ if (hi === lo) { lo -= 0.5; hi += 0.5 }
64
+ const toX = (u) => PAD + u * innerW
65
+ const toY = (v) => PAD + innerH * (1 - (v - lo) / (hi - lo))
66
+
67
+ const n = vs.length - 1
68
+ const pts = vs.map((v, i) => [toX(n > 0 ? i / n : 0), toY(Number.isFinite(v) ? v : lo)])
69
+ const line = (list) => list.map(([x, y], i) => `${i ? 'L' : 'M'}${x.toFixed(1)} ${y.toFixed(1)}`).join('')
70
+ const u = cursor == null ? null : Math.min(1, Math.max(0, cursor))
71
+ const at = u == null || n < 1 ? -1 : Math.round(u * n)
72
+ const cy = at < 0 ? 0 : (fn && !samples?.length ? toY(fn(u)) : pts[at][1])
73
+
74
+ return (
75
+ <div
76
+ ref={ref}
77
+ role="img"
78
+ aria-label={ariaLabel}
79
+ className={`kol-function-plot relative w-full overflow-hidden rounded-[var(--kol-radius-xs)] bg-[var(--kol-oq-04)] ${className}`.trim()}
80
+ style={{ height }}
81
+ >
82
+ {w > 0 && (
83
+ <svg className="absolute inset-0" width={w} height={height} viewBox={`0 0 ${w} ${height}`} aria-hidden="true">
84
+ {lo < 0 && hi > 0 && (
85
+ <line x1={PAD} x2={w - PAD} y1={toY(0)} y2={toY(0)} stroke="var(--kol-oq-24)" strokeWidth="1" />
86
+ )}
87
+ {pts.length > 1 && (
88
+ <>
89
+ <path d={line(pts)} fill="none" stroke="var(--kol-accent-primary)" strokeOpacity={at < 0 ? 1 : 0.25} strokeWidth={at < 0 ? 1.5 : 1} />
90
+ {at > 0 && <path d={line(pts.slice(0, at + 1))} fill="none" stroke="var(--kol-accent-primary)" strokeWidth="1.5" />}
91
+ </>
92
+ )}
93
+ {at >= 0 && (
94
+ <>
95
+ <line x1={toX(u)} x2={toX(u)} y1={PAD} y2={height - PAD} stroke="var(--kol-accent-primary)" strokeOpacity="0.4" strokeWidth="1" />
96
+ <circle cx={toX(u)} cy={cy} r="2.5" fill="var(--kol-accent-primary)" />
97
+ </>
98
+ )}
99
+ </svg>
100
+ )}
101
+ {labels && (
102
+ <>
103
+ <span className="kol-mono-10 absolute left-2 top-0.5 text-[var(--kol-oq-48)] pointer-events-none">{fmt(hi)}</span>
104
+ <span className="kol-mono-10 absolute left-2 bottom-0.5 text-[var(--kol-oq-48)] pointer-events-none">{fmt(lo)}</span>
105
+ </>
106
+ )}
107
+ </div>
108
+ )
109
+ }
package/src/index.js CHANGED
@@ -85,6 +85,10 @@ export { default as ViewToggle } from './atoms/ViewToggle.jsx'
85
85
  export { default as XYPad } from './atoms/XYPad.jsx'
86
86
  /* lobby OriginPicker (kol-fxr, 2026-10-31) — the 3×3 origin / anchor value picker */
87
87
  export { default as OriginPicker } from './atoms/OriginPicker.jsx'
88
+ /* lobby kol-fxr plan 51 4.4 (2026-10-31) — the bezier node editor, the function plot, the param bind dot */
89
+ export { default as BezierPathEditor } from './atoms/BezierPathEditor.jsx'
90
+ export { default as FunctionPlot } from './atoms/FunctionPlot.jsx'
91
+ export { default as ParamBindDot } from './molecules/ParamBindDot.jsx'
88
92
  export { default as InspectorRail } from './molecules/InspectorRail.jsx'
89
93
  /* SelectionOverlay's two siblings — same 1080-virtual contract, same zoom
90
94
  * division (editor-panels-the-held-specs B2). `pathMath` is their geometry,
@@ -202,6 +206,9 @@ export { default as FeaturedCarousel } from './organisms/FeaturedCarousel.jsx'
202
206
  export { default as FeaturesCardSection } from './organisms/FeaturesCardSection.jsx'
203
207
  /* the growing line on @kolkrabbi/kol-growth (GrowthLineStage, kol-atlas 2026-10-30) */
204
208
  export { default as GrowthLineStage } from './organisms/GrowthLineStage.jsx'
209
+ /* the app loader's runtime half and its intro claim (LoaderAppIntro, kol-fxr 2026-11-01) — here because GrowthLineStage
210
+ * claims it; kol-framework re-exports it, which stays its documented home */
211
+ export { hideLoaderApp, claimIntro, introClaimed, endIntro, releaseIntro } from './utilities/loaderApp.js'
205
212
  export { default as SectionHero, default as FullBleedHero } from './organisms/SectionHero.jsx'
206
213
  export { default as SectionSplit } from './organisms/SectionSplit.jsx'
207
214
  export { default as SectionCards } from './organisms/SectionCards.jsx'
@@ -1,13 +1,13 @@
1
1
  import { useState } from 'react'
2
2
  import SearchInput from './SearchInput.jsx'
3
- import { MenuDropdownItem } from './MenuItem.jsx'
3
+ import { MenuRow } from './MenuItem.jsx'
4
4
  import { PopoverPanel, usePopover } from '../utilities/Popover.jsx'
5
5
 
6
6
  /**
7
7
  * Combobox — A searchable value field: type to filter, pick a row. (MetricDashboardUpstream, kol-website 2026-10-31 —
8
8
  * metric's filter-value picker, plausible.io's.) Built from the parts, never a fork of them: the field is `SearchInput`
9
9
  * (outline, sm) and the list is `Dropdown`'s own panel (`kol-dd-panel` · `kol-dd-div` · `kol-dd-list`, rows
10
- * `MenuDropdownItem` at Dropdown's sm row), matched to the field's width and hung 1px under it.
10
+ * `MenuRow` at Dropdown's sm row), matched to the field's width and hung 1px under it.
11
11
  *
12
12
  * <Combobox value={q} onChange={setQ} options={[{ value: '/blog', label: '/blog' }]} placeholder="Select a value" />
13
13
  *
@@ -44,13 +44,13 @@ export default function Combobox({ value, onChange, options = [], placeholder, a
44
44
  onChange={(e) => { onChange(e.target?.value ?? e); setOpen(true) }}
45
45
  onClear={() => onChange('')}
46
46
  />
47
- <PopoverPanel popover={popover} panel={false} focus={false} className="kol-dd-panel" style={{ '--kol-dd-max-rows': 8, '--kol-dd-row-h': 'var(--kol-ctl-sm)' }}>
47
+ <PopoverPanel popover={popover} panel={false} focus={false} className="kol-menu-panel kol-menu-panel--fused" style={{ '--kol-dd-max-rows': 8, '--kol-dd-row-h': 'var(--kol-ctl-sm)' }}>
48
48
  <div className="kol-dd-div" />
49
49
  <div className="kol-dd-list" role="listbox">
50
50
  {shown.map((o) => (
51
- <MenuDropdownItem key={o.value} hover={false} size="sm" rowClass={ROW_SM} onClick={() => { onChange(o.value); setOpen(false) }}>
51
+ <MenuRow key={o.value} hover={false} size="sm" rowClass={ROW_SM} onClick={() => { onChange(o.value); setOpen(false) }}>
52
52
  {o.label}
53
- </MenuDropdownItem>
53
+ </MenuRow>
54
54
  ))}
55
55
  {!shown.length && <div className={`${ROW_SM} flex items-center text-meta`}>No matches</div>}
56
56
  </div>
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useEffect, useState } from 'react'
2
- import { usePopover, PopoverPanel } from '../utilities/Popover.jsx'
2
+ import { Menu } from './Menu.jsx'
3
3
  import { pushLayer, popLayer } from '../utilities/layerStack.js'
4
4
 
5
5
  /**
@@ -10,7 +10,7 @@ import { pushLayer, popLayer } from '../utilities/layerStack.js'
10
10
  * move, delete) had no surface to be invoked from: the operations existed on
11
11
  * the client and nothing could reach them. This is that surface.
12
12
  *
13
- * Built on `usePopover`'s `referenceElement` seam rather than a new floating
13
+ * Built on `Menu`'s `anchor` (since 2026-10-31; before, `usePopover`'s seam directly) rather than a new floating
14
14
  * implementation — a context menu is a popover whose anchor is a point instead
15
15
  * of an element, and floating-ui takes a virtual element for exactly this. So
16
16
  * it inherits flip, shift, the portal, dismissal and the `.kol-popover` chrome,
@@ -19,7 +19,7 @@ import { pushLayer, popLayer } from '../utilities/layerStack.js'
19
19
  * const menu = useContextMenu()
20
20
  * <li onContextMenu={(e) => menu.openAt(e, row)}>…</li>
21
21
  * <ContextMenu menu={menu}>
22
- * {(row) => <MenuDropdownItem onClick={() => rename(row)}>Rename</MenuDropdownItem>}
22
+ * {(row) => <MenuRow onClick={() => rename(row)}>Rename</MenuRow>}
23
23
  * </ContextMenu>
24
24
  *
25
25
  * `children` may be a render function taking the payload handed to `openAt`,
@@ -36,31 +36,8 @@ export function useContextMenu() {
36
36
 
37
37
  const close = useCallback(() => setState(null), [])
38
38
 
39
- const popover = usePopover({
40
- open: !!state,
41
- onOpenChange: (v) => { if (!v) close() },
42
- placement: 'right-start',
43
- offset: 2,
44
- click: false,
45
- role: 'menu',
46
- })
47
-
48
- /* A VIRTUAL ELEMENT — a zero-size rect at the pointer. It goes through
49
- * `setPositionReference`, NOT the `elements.reference` option: floating-ui
50
- * rejects a virtual element there ("must be a real DOM element") because that
51
- * slot also feeds the interaction hooks, which call `getAttribute` on it.
52
- * `setPositionReference` is the seam for exactly this — position from a point,
53
- * interactions from nothing. */
54
- const { setPositionReference } = popover.refs
55
- useEffect(() => {
56
- if (!state) return
57
- const { x, y } = state
58
- setPositionReference({
59
- getBoundingClientRect: () => ({ width: 0, height: 0, x, y, top: y, left: x, right: x, bottom: y }),
60
- })
61
- }, [state, setPositionReference])
62
-
63
- return { open: !!state, payload: state?.payload ?? null, openAt, close, popover }
39
+ /* the point and the panel are `Menu`'s (plan-2026-10-31-menu-engine W1.4): it takes `anchor={{ x, y }}` */
40
+ return { open: !!state, x: state?.x, y: state?.y, payload: state?.payload ?? null, openAt, close }
64
41
  }
65
42
 
66
43
  export default function ContextMenu({ menu, children, className = '' }) {
@@ -73,19 +50,12 @@ export default function ContextMenu({ menu, children, className = '' }) {
73
50
  }, [menu.open])
74
51
  if (!menu.open) return null
75
52
  return (
76
- /* `focus={false}` — FloatingFocusManager reads attributes off the reference,
77
- * and a point has none. Dismissal is outside-click and Escape, which the
78
- * popover already wires. */
79
- <PopoverPanel popover={menu.popover} focus={false} className={`kol-dd-list min-w-44 ${className}`.trim()}>
80
- {/* Any click inside closes — a menu item that leaves the menu open after
81
- * acting is the one interaction people report as broken. Items keep their
82
- * own onClick; this runs after it on the way up. */}
83
- {/* A COLUMN, not a block: the items are `inline-flex`, so in a block they are one line of
84
- * inline boxes to the float's shrink-to-fit, and the menu took the width of every label
85
- * side by side — 510px for seven short verbs, past the edge of a phone. */}
53
+ <Menu anchor={{ x: menu.x, y: menu.y }} open onOpenChange={(v) => { if (!v) menu.close() }} panelClassName={`min-w-44 ${className}`.trim()}>
54
+ {/* Any click inside closes — a menu item that leaves the menu open after acting is the one interaction people
55
+ * report as broken. Items keep their own onClick; this runs after it on the way up. */}
86
56
  <div onClick={menu.close} role="none" className="flex flex-col">
87
57
  {typeof children === 'function' ? children(menu.payload) : children}
88
58
  </div>
89
- </PopoverPanel>
59
+ </Menu>
90
60
  )
91
61
  }