@kolkrabbi/kol-component 0.386.0 → 0.388.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 +3 -3
- package/src/index.js +1 -1
- package/src/molecules/AlignmentGrid.jsx +13 -7
- package/src/molecules/ColorInputRow.jsx +31 -23
- package/src/molecules/ColorSwatch.jsx +17 -49
- package/src/molecules/ContextMenu.jsx +1 -1
- package/src/molecules/Dropdown.jsx +24 -56
- package/src/molecules/Menu.jsx +190 -255
- package/src/molecules/MenuItem.jsx +45 -12
- package/src/molecules/MenuList.jsx +48 -17
- package/src/molecules/ParamBindDot.jsx +33 -54
- package/src/molecules/SwatchControls.jsx +12 -7
- package/src/molecules/SwatchGrid.jsx +6 -9
- package/src/organisms/ColorPickerPopover.jsx +1 -1
- package/src/organisms/SpectrumControls.jsx +54 -137
- package/src/utilities/Popover.jsx +8 -4
|
@@ -37,11 +37,20 @@ import { useCallback, useEffect, useId, useRef } from 'react'
|
|
|
37
37
|
* half the knob hangs off the edge. */
|
|
38
38
|
const HANDLE_R = 7
|
|
39
39
|
|
|
40
|
+
/* ONE SET, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W2 run 4): the handle, the strips and the checker are
|
|
41
|
+
* `--kol-spectrum-*` (kol-theme kol-components-organisms.css, Spectrum controls), the default theme leaving them unset
|
|
42
|
+
* and `data-theme-variant="kolbox"` setting kolbox's. The inset is read here too, so the drag math matches the drawing
|
|
43
|
+
* (kolbox's handle runs to the box's edge, inset 0). `variant="kolbox"` is accepted and does nothing; its branches are in
|
|
44
|
+
* `_tmp/2026-11-29-one-set-fold/SpectrumControls.pre-fields3.jsx`. */
|
|
45
|
+
const insetOf = (node) => {
|
|
46
|
+
const v = parseFloat(getComputedStyle(node).getPropertyValue('--kol-spectrum-inset'))
|
|
47
|
+
return Number.isFinite(v) ? v : HANDLE_R
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
const HUE_GRADIENT =
|
|
41
51
|
'linear-gradient(to right, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%), hsl(360,100%,50%))'
|
|
42
52
|
|
|
43
|
-
/*
|
|
44
|
-
*
|
|
53
|
+
/*
|
|
45
54
|
* HueStrip — A hue slider. 1D hue slider: a rainbow bar with a draggable knob. Pointer
|
|
46
55
|
* drag anywhere on the strip; focus + Left/Right (or Down/Up) arrow keys
|
|
47
56
|
* nudge hue by 1° (role="slider").
|
|
@@ -49,7 +58,7 @@ const HUE_GRADIENT =
|
|
|
49
58
|
* @param {number} hue controlled hue, 0–360
|
|
50
59
|
* @param {Function} onChange (hue: number) => void — fires on press, drag, and arrow keys
|
|
51
60
|
*/
|
|
52
|
-
function
|
|
61
|
+
export function HueStrip({ hue, onChange, className = '' }) {
|
|
53
62
|
const ref = useRef(null)
|
|
54
63
|
const dragging = useRef(false)
|
|
55
64
|
|
|
@@ -57,10 +66,11 @@ function HueStripDefault({ hue, onChange }) {
|
|
|
57
66
|
const node = ref.current
|
|
58
67
|
if (!node) return
|
|
59
68
|
const rect = node.getBoundingClientRect()
|
|
60
|
-
const
|
|
69
|
+
const inset = insetOf(node)
|
|
70
|
+
const inner = rect.width - 2 * inset
|
|
61
71
|
if (inner <= 0) return
|
|
62
|
-
const ratio = Math.max(0, Math.min(1, (clientX - rect.left -
|
|
63
|
-
onChange(ratio * 360)
|
|
72
|
+
const ratio = Math.max(0, Math.min(1, (clientX - rect.left - inset) / inner))
|
|
73
|
+
onChange?.(ratio * 360)
|
|
64
74
|
}, [onChange])
|
|
65
75
|
|
|
66
76
|
const onDown = (e) => {
|
|
@@ -88,7 +98,7 @@ function HueStripDefault({ hue, onChange }) {
|
|
|
88
98
|
else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') next = Math.max(0, hue - 1)
|
|
89
99
|
if (next === null) return
|
|
90
100
|
e.preventDefault()
|
|
91
|
-
onChange(next)
|
|
101
|
+
onChange?.(next)
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
const pos = (hue / 360) * 100
|
|
@@ -104,12 +114,12 @@ function HueStripDefault({ hue, onChange }) {
|
|
|
104
114
|
aria-valuenow={Math.round(hue)}
|
|
105
115
|
onPointerDown={onDown}
|
|
106
116
|
onKeyDown={onKeyDown}
|
|
107
|
-
className=
|
|
108
|
-
style={{
|
|
117
|
+
className={`kol-spectrum-strip kol-hue-strip relative cursor-pointer touch-none ${className}`.trim()}
|
|
118
|
+
style={{ background: HUE_GRADIENT, '--kol-spectrum-hue': `hsl(${hue} 100% 50%)` }}
|
|
109
119
|
>
|
|
110
120
|
{/* Handle positions inside an inset region so 0..100% maps to the
|
|
111
121
|
* area where the knob can sit without spilling out. */}
|
|
112
|
-
<div className="absolute inset-y-0"
|
|
122
|
+
<div className="kol-spectrum-inset absolute inset-y-0">
|
|
113
123
|
<Handle left={`${pos}%`} top="50%" />
|
|
114
124
|
</div>
|
|
115
125
|
</div>
|
|
@@ -119,8 +129,7 @@ function HueStripDefault({ hue, onChange }) {
|
|
|
119
129
|
/* the transparency checker behind an alpha ramp — literal greys, like the spectra (not themeable) */
|
|
120
130
|
const CHECKER = 'repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0 0 / 8px 8px'
|
|
121
131
|
|
|
122
|
-
/*
|
|
123
|
-
*
|
|
132
|
+
/*
|
|
124
133
|
* AlphaStrip — An opacity slider. HueStrip's twin for alpha: the colour ramped from transparent to
|
|
125
134
|
* opaque over a checker, same knob, same inset (ColorPickerPopover, kol-monitor 2026-10-17). Focus +
|
|
126
135
|
* Left/Right (or Down/Up) nudge alpha by 1% (role="slider").
|
|
@@ -129,7 +138,7 @@ const CHECKER = 'repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0 0 / 8px 8p
|
|
|
129
138
|
* @param {string} color the opaque colour the ramp ends on (any CSS colour)
|
|
130
139
|
* @param {Function} onChange (alpha: number) => void — fires on press, drag, and arrow keys
|
|
131
140
|
*/
|
|
132
|
-
function
|
|
141
|
+
export function AlphaStrip({ alpha = 1, color = 'currentColor', onChange, className = '' }) {
|
|
133
142
|
const ref = useRef(null)
|
|
134
143
|
const dragging = useRef(false)
|
|
135
144
|
|
|
@@ -137,9 +146,10 @@ function AlphaStripDefault({ alpha, color, onChange }) {
|
|
|
137
146
|
const node = ref.current
|
|
138
147
|
if (!node) return
|
|
139
148
|
const rect = node.getBoundingClientRect()
|
|
140
|
-
const
|
|
149
|
+
const inset = insetOf(node)
|
|
150
|
+
const inner = rect.width - 2 * inset
|
|
141
151
|
if (inner <= 0) return
|
|
142
|
-
onChange(Math.max(0, Math.min(1, (clientX - rect.left -
|
|
152
|
+
onChange?.(Math.max(0, Math.min(1, (clientX - rect.left - inset) / inner)))
|
|
143
153
|
}, [onChange])
|
|
144
154
|
|
|
145
155
|
useEffect(() => {
|
|
@@ -161,7 +171,7 @@ function AlphaStripDefault({ alpha, color, onChange }) {
|
|
|
161
171
|
else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') next = Math.max(0, alpha - 0.01)
|
|
162
172
|
if (next === null) return
|
|
163
173
|
e.preventDefault()
|
|
164
|
-
onChange(next)
|
|
174
|
+
onChange?.(next)
|
|
165
175
|
}
|
|
166
176
|
|
|
167
177
|
return (
|
|
@@ -175,18 +185,17 @@ function AlphaStripDefault({ alpha, color, onChange }) {
|
|
|
175
185
|
aria-valuenow={Math.round(alpha * 100)}
|
|
176
186
|
onPointerDown={(e) => { dragging.current = true; update(e.clientX); e.preventDefault() }}
|
|
177
187
|
onKeyDown={onKeyDown}
|
|
178
|
-
className=
|
|
179
|
-
style={{
|
|
188
|
+
className={`kol-spectrum-strip relative cursor-pointer touch-none ${className}`.trim()}
|
|
189
|
+
style={{ background: `linear-gradient(to right, transparent, ${color}), var(--kol-spectrum-checker, ${CHECKER})` }}
|
|
180
190
|
>
|
|
181
|
-
<div className="absolute inset-y-0"
|
|
191
|
+
<div className="kol-spectrum-inset absolute inset-y-0">
|
|
182
192
|
<Handle left={`${alpha * 100}%`} top="50%" />
|
|
183
193
|
</div>
|
|
184
194
|
</div>
|
|
185
195
|
)
|
|
186
196
|
}
|
|
187
197
|
|
|
188
|
-
/*
|
|
189
|
-
*
|
|
198
|
+
/*
|
|
190
199
|
* SBSquare — Pick saturation and value on a square. 2D saturation/value picker: white→hue horizontal gradient with
|
|
191
200
|
* a black overlay fading upward, crosshair handle. Fills its container
|
|
192
201
|
* (consumer owns the size — and the rounding: apply `rounded-[var(--kol-radius-2)]
|
|
@@ -198,7 +207,7 @@ function AlphaStripDefault({ alpha, color, onChange }) {
|
|
|
198
207
|
* @param {number} val controlled value/brightness, 0–100
|
|
199
208
|
* @param {Function} onChange (sat: number, val: number) => void
|
|
200
209
|
*/
|
|
201
|
-
function
|
|
210
|
+
export function SBSquare({ hue = 0, sat = 100, val = 100, onChange, className = '' }) {
|
|
202
211
|
const ref = useRef(null)
|
|
203
212
|
const dragging = useRef(false)
|
|
204
213
|
|
|
@@ -206,12 +215,13 @@ function SBSquareDefault({ hue, sat, val, onChange }) {
|
|
|
206
215
|
const node = ref.current
|
|
207
216
|
if (!node) return
|
|
208
217
|
const rect = node.getBoundingClientRect()
|
|
209
|
-
const
|
|
210
|
-
const
|
|
218
|
+
const inset = insetOf(node)
|
|
219
|
+
const innerW = rect.width - 2 * inset
|
|
220
|
+
const innerH = rect.height - 2 * inset
|
|
211
221
|
if (innerW <= 0 || innerH <= 0) return
|
|
212
|
-
const sx = Math.max(0, Math.min(1, (clientX - rect.left -
|
|
213
|
-
const sy = Math.max(0, Math.min(1, (clientY - rect.top -
|
|
214
|
-
onChange(sx * 100, (1 - sy) * 100)
|
|
222
|
+
const sx = Math.max(0, Math.min(1, (clientX - rect.left - inset) / innerW))
|
|
223
|
+
const sy = Math.max(0, Math.min(1, (clientY - rect.top - inset) / innerH))
|
|
224
|
+
onChange?.(sx * 100, (1 - sy) * 100)
|
|
215
225
|
}, [onChange])
|
|
216
226
|
|
|
217
227
|
const onDown = (e) => {
|
|
@@ -235,6 +245,7 @@ function SBSquareDefault({ hue, sat, val, onChange }) {
|
|
|
235
245
|
|
|
236
246
|
const onKeyDown = (e) => {
|
|
237
247
|
const clamp = (v) => Math.max(0, Math.min(100, v))
|
|
248
|
+
if (!onChange) return
|
|
238
249
|
if (e.key === 'ArrowRight') onChange(clamp(sat + 1), val)
|
|
239
250
|
else if (e.key === 'ArrowLeft') onChange(clamp(sat - 1), val)
|
|
240
251
|
else if (e.key === 'ArrowUp') onChange(sat, clamp(val + 1))
|
|
@@ -260,10 +271,10 @@ function SBSquareDefault({ hue, sat, val, onChange }) {
|
|
|
260
271
|
aria-valuetext={`Saturation ${Math.round(sat)}%, brightness ${Math.round(val)}%`}
|
|
261
272
|
onPointerDown={onDown}
|
|
262
273
|
onKeyDown={onKeyDown}
|
|
263
|
-
className=
|
|
274
|
+
className={`kol-spectrum-sb relative cursor-crosshair touch-none w-full h-full ${className}`.trim()}
|
|
264
275
|
style={{ background: sb }}
|
|
265
276
|
>
|
|
266
|
-
<div className="absolute"
|
|
277
|
+
<div className="kol-spectrum-inset absolute">
|
|
267
278
|
<Handle left={`${sat}%`} top={`${100 - val}%`} />
|
|
268
279
|
</div>
|
|
269
280
|
</div>
|
|
@@ -316,13 +327,12 @@ function vertexAt(angleRad) {
|
|
|
316
327
|
* @param {number} val controlled value/brightness, 0–100
|
|
317
328
|
* @param {Function} onChangeHue (hue: number) => void — ring drag / hue arrow keys
|
|
318
329
|
* @param {Function} onChangeSV (sat: number, val: number) => void — triangle drag / value arrow keys
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
330
|
+
* The handles' halo and ring and the wrapper's focus ring are the theme's (`--kol-wheel-*`, kol-theme Spectrum controls):
|
|
331
|
+
* kolbox's ring in the ink over a hairline of the ground and a round accent focus ring 2 out. `variant` is accepted and
|
|
332
|
+
* does nothing (W2 run 4).
|
|
322
333
|
* @param {string} [className] extra classes on the wrapper
|
|
323
334
|
*/
|
|
324
|
-
export function WheelTriangle({ hue, sat, val, onChangeHue, onChangeSV,
|
|
325
|
-
const kolbox = variant === 'kolbox'
|
|
335
|
+
export function WheelTriangle({ hue, sat, val, onChangeHue, onChangeSV, className = '' }) {
|
|
326
336
|
const svgRef = useRef(null)
|
|
327
337
|
const dragMode = useRef(null) /* { type: 'ring' } | { type: 'tri', offsetX, offsetY } | null */
|
|
328
338
|
|
|
@@ -467,9 +477,7 @@ export function WheelTriangle({ hue, sat, val, onChangeHue, onChangeSV, variant
|
|
|
467
477
|
aria-valuenow={Math.round(hue)}
|
|
468
478
|
aria-valuetext={`Hue ${Math.round(hue)} degrees, saturation ${Math.round(sat)}%, brightness ${Math.round(val)}%`}
|
|
469
479
|
onKeyDown={onKeyDown}
|
|
470
|
-
className={
|
|
471
|
-
? `kol-wheel-triangle--kolbox aspect-square max-h-full max-w-full rounded-full outline-none focus-visible:outline-solid focus-visible:outline-1 focus-visible:outline-offset-2 ${className}`
|
|
472
|
-
: `aspect-square max-h-full max-w-full ${className}`.trim()}
|
|
480
|
+
className={`kol-wheel-triangle aspect-square max-h-full max-w-full ${className}`.trim()}
|
|
473
481
|
>
|
|
474
482
|
<svg
|
|
475
483
|
ref={svgRef}
|
|
@@ -519,8 +527,8 @@ export function WheelTriangle({ hue, sat, val, onChangeHue, onChangeSV, variant
|
|
|
519
527
|
<polygon points={trianglePoints} fill={`url(#${blackFadeId})`} />
|
|
520
528
|
|
|
521
529
|
{/* Handles. Ring handle is larger than the SV handle to match the Ref. */}
|
|
522
|
-
<SvgHandle cx={ringHx} cy={ringHy} r={3.2}
|
|
523
|
-
<SvgHandle cx={handleX} cy={handleY} r={2.0}
|
|
530
|
+
<SvgHandle cx={ringHx} cy={ringHy} r={3.2} />
|
|
531
|
+
<SvgHandle cx={handleX} cy={handleY} r={2.0} />
|
|
524
532
|
</svg>
|
|
525
533
|
</div>
|
|
526
534
|
)
|
|
@@ -529,29 +537,20 @@ export function WheelTriangle({ hue, sat, val, onChangeHue, onChangeSV, variant
|
|
|
529
537
|
/* ────────── Internal helpers (not exported) ────────── */
|
|
530
538
|
|
|
531
539
|
/* DOM handle for HueStrip / SBSquare. Solid white-stroked circle with thin
|
|
532
|
-
* black halo (matching the macOS-port look)
|
|
540
|
+
* black halo (matching the macOS-port look); size, fill and ring the theme's
|
|
541
|
+
* (`.kol-spectrum-handle`). */
|
|
533
542
|
function Handle({ left, top }) {
|
|
534
|
-
return
|
|
535
|
-
<span
|
|
536
|
-
className="absolute pointer-events-none rounded-full bg-fg"
|
|
537
|
-
style={{
|
|
538
|
-
left, top,
|
|
539
|
-
width: 14, height: 14,
|
|
540
|
-
transform: 'translate(-50%, -50%)',
|
|
541
|
-
boxShadow: '0 0 0 1px #000, 0 0 0 2px #505050',
|
|
542
|
-
}}
|
|
543
|
-
/>
|
|
544
|
-
)
|
|
543
|
+
return <span className="kol-spectrum-handle absolute pointer-events-none rounded-full" style={{ left, top }} />
|
|
545
544
|
}
|
|
546
545
|
|
|
547
546
|
/* SVG handle for WheelTriangle. Two concentric circles to stay sharp at any
|
|
548
547
|
* zoom — outer black halo + white outline. */
|
|
549
|
-
function SvgHandle({ cx, cy, r = 2.4
|
|
550
|
-
/*
|
|
548
|
+
function SvgHandle({ cx, cy, r = 2.4 }) {
|
|
549
|
+
/* the strokes are the theme's (`--kol-wheel-halo`, `--kol-wheel-ring`; unset, #000 and #FFF) */
|
|
551
550
|
return (
|
|
552
551
|
<g pointerEvents="none">
|
|
553
|
-
<circle cx={cx} cy={cy} r={r + 0.5} fill="none"
|
|
554
|
-
<circle cx={cx} cy={cy} r={r} fill="none"
|
|
552
|
+
<circle cx={cx} cy={cy} r={r + 0.5} fill="none" className="kol-wheel-triangle-halo" strokeOpacity="0.7" strokeWidth="0.5" />
|
|
553
|
+
<circle cx={cx} cy={cy} r={r} fill="none" className="kol-wheel-triangle-ring" strokeWidth="1.4" />
|
|
555
554
|
</g>
|
|
556
555
|
)
|
|
557
556
|
}
|
|
@@ -581,85 +580,3 @@ export default function SpectrumControls({ value, onChange }) {
|
|
|
581
580
|
</div>
|
|
582
581
|
)
|
|
583
582
|
}
|
|
584
|
-
|
|
585
|
-
/* ── kolbox (plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18) ─────────────────────────────────────────────────
|
|
586
|
-
* kolbox's ColorField, HueSlider and OpacitySlider, carried from apps/kolbox/src/ui as `variant="kolbox"` of SBSquare,
|
|
587
|
-
* HueStrip and AlphaStrip, on these parts' own words (`hue`, `sat` and `val` 0–100, `alpha` 0–1). Pointer down and drag,
|
|
588
|
-
* no keys (kolbox's have none); the handle a 12 ring in the ink. `className` lands on the part. */
|
|
589
|
-
|
|
590
|
-
/* pointer down on the element and drag: move(x, y), each clamped to 0..1 of its box */
|
|
591
|
-
function dragKolbox(e, move) {
|
|
592
|
-
const box = e.currentTarget
|
|
593
|
-
const at = (ev) => { const r = box.getBoundingClientRect(); move(Math.min(1, Math.max(0, (ev.clientX - r.left) / r.width)), Math.min(1, Math.max(0, (ev.clientY - r.top) / r.height))) }
|
|
594
|
-
box.setPointerCapture(e.pointerId)
|
|
595
|
-
at(e)
|
|
596
|
-
const up = () => { box.removeEventListener('pointermove', at); box.removeEventListener('pointerup', up) }
|
|
597
|
-
box.addEventListener('pointermove', at)
|
|
598
|
-
box.addEventListener('pointerup', up)
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/* the saturation and brightness square at the hue (Figma plan W13 state 4); onChange(sat, val) */
|
|
602
|
-
function SBSquareKolbox({ hue = 0, sat = 100, val = 100, onChange, className = '' }) {
|
|
603
|
-
return (
|
|
604
|
-
<div
|
|
605
|
-
role="slider"
|
|
606
|
-
aria-label="Saturation and brightness"
|
|
607
|
-
aria-valuetext={`${Math.round(sat)}%, ${Math.round(val)}%`}
|
|
608
|
-
onPointerDown={(e) => dragKolbox(e, (x, y) => onChange?.(x * 100, (1 - y) * 100))}
|
|
609
|
-
className={`relative aspect-square w-full cursor-crosshair touch-none ${className}`}
|
|
610
|
-
style={{ background: `linear-gradient(to top, black, transparent), linear-gradient(to right, white, hsl(${hue} 100% 50%))` }}
|
|
611
|
-
>
|
|
612
|
-
<span className="kol-spectrum-handle--kolbox pointer-events-none absolute size-3 -translate-1/2 rounded-full" style={{ left: `${sat}%`, top: `${100 - val}%` }} />
|
|
613
|
-
</div>
|
|
614
|
-
)
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
/* the hue run, 0 to 360, 12 high, its thumb the hue */
|
|
618
|
-
function HueStripKolbox({ hue = 0, onChange, className = '' }) {
|
|
619
|
-
return (
|
|
620
|
-
<div
|
|
621
|
-
role="slider"
|
|
622
|
-
aria-label="Hue"
|
|
623
|
-
aria-valuemin={0}
|
|
624
|
-
aria-valuemax={360}
|
|
625
|
-
aria-valuenow={Math.round(hue)}
|
|
626
|
-
onPointerDown={(e) => dragKolbox(e, (x) => onChange?.(x * 360))}
|
|
627
|
-
className={`relative h-3 w-full cursor-pointer touch-none rounded-full ${className}`}
|
|
628
|
-
style={{ background: 'linear-gradient(to right, hsl(0 100% 50%), hsl(60 100% 50%), hsl(120 100% 50%), hsl(180 100% 50%), hsl(240 100% 50%), hsl(300 100% 50%), hsl(360 100% 50%))' }}
|
|
629
|
-
>
|
|
630
|
-
<span className="kol-spectrum-handle--kolbox pointer-events-none absolute top-1/2 size-3 -translate-1/2 rounded-full" style={{ left: `${(hue / 360) * 100}%`, background: `hsl(${hue} 100% 50%)` }} />
|
|
631
|
-
</div>
|
|
632
|
-
)
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
/* the opacity run, clear to `color` over the checker; onChange(alpha), in whole percents */
|
|
636
|
-
function AlphaStripKolbox({ alpha = 1, color = 'currentColor', onChange, className = '' }) {
|
|
637
|
-
const value = alpha * 100
|
|
638
|
-
return (
|
|
639
|
-
<div
|
|
640
|
-
role="slider"
|
|
641
|
-
aria-label="Opacity"
|
|
642
|
-
aria-valuemin={0}
|
|
643
|
-
aria-valuemax={100}
|
|
644
|
-
aria-valuenow={Math.round(value)}
|
|
645
|
-
onPointerDown={(e) => dragKolbox(e, (x) => onChange?.(Math.round(x * 100) / 100))}
|
|
646
|
-
className={`kol-alpha-strip--kolbox relative h-3 w-full cursor-pointer touch-none rounded-full ${className}`}
|
|
647
|
-
>
|
|
648
|
-
<span className="absolute inset-0 rounded-full" style={{ background: `linear-gradient(to right, transparent, ${color})` }} />
|
|
649
|
-
<span className="kol-spectrum-handle--kolbox pointer-events-none absolute top-1/2 size-3 -translate-1/2 rounded-full" style={{ left: `${value}%` }} />
|
|
650
|
-
</div>
|
|
651
|
-
)
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/** SBSquare — Pick saturation and value on a square. @param {'default'|'kolbox'} [variant] `kolbox`: kolbox's ColorField (above) */
|
|
655
|
-
export function SBSquare(props) {
|
|
656
|
-
return props.variant === 'kolbox' ? <SBSquareKolbox {...props} /> : <SBSquareDefault {...props} />
|
|
657
|
-
}
|
|
658
|
-
/** HueStrip — A hue slider. @param {'default'|'kolbox'} [variant] `kolbox`: kolbox's HueSlider (above) */
|
|
659
|
-
export function HueStrip(props) {
|
|
660
|
-
return props.variant === 'kolbox' ? <HueStripKolbox {...props} /> : <HueStripDefault {...props} />
|
|
661
|
-
}
|
|
662
|
-
/** AlphaStrip — An opacity slider. @param {'default'|'kolbox'} [variant] `kolbox`: kolbox's OpacitySlider (above) */
|
|
663
|
-
export function AlphaStrip(props) {
|
|
664
|
-
return props.variant === 'kolbox' ? <AlphaStripKolbox {...props} /> : <AlphaStripDefault {...props} />
|
|
665
|
-
}
|
|
@@ -163,8 +163,9 @@ export function usePopover({
|
|
|
163
163
|
const anchorEl = (anchor) => (anchor && 'current' in anchor ? anchor.current : anchor)
|
|
164
164
|
const later = (a, b) => !!(a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING)
|
|
165
165
|
/* spend a press: stop it here, and swallow the mouse events and the click it raises until the press ends. Several
|
|
166
|
-
layers may close on one press; the first spends it, the rest find it stopped and do nothing more.
|
|
167
|
-
|
|
166
|
+
layers may close on one press; the first spends it, the rest find it stopped and do nothing more. Menu's press outside
|
|
167
|
+
spends a press on the canvas the same way (plan-2026-11-29-one-set-fold W3). */
|
|
168
|
+
export function spend(e) {
|
|
168
169
|
if (e.cancelBubble) return
|
|
169
170
|
e.stopPropagation(); e.preventDefault()
|
|
170
171
|
const stop = (ev) => { ev.stopPropagation(); ev.preventDefault() }
|
|
@@ -555,6 +556,9 @@ function PopoverPanelOn({
|
|
|
555
556
|
motion,
|
|
556
557
|
className = '',
|
|
557
558
|
style: extraStyle,
|
|
559
|
+
/* Menu's panel (plan-2026-11-29-one-set-fold W3): its own attributes and handlers on the floating node, and its ref */
|
|
560
|
+
floatingProps,
|
|
561
|
+
panelRef,
|
|
558
562
|
}) {
|
|
559
563
|
const depth = useContext(FloatDepth)
|
|
560
564
|
const fm = motion == null ? null : floatMotion(motion)
|
|
@@ -577,13 +581,13 @@ function PopoverPanelOn({
|
|
|
577
581
|
* for non-editor consumers since they ignore the attr. */
|
|
578
582
|
const node = (
|
|
579
583
|
<div
|
|
580
|
-
ref={refs.setFloating}
|
|
584
|
+
ref={panelRef ? (n) => { refs.setFloating(n); panelRef(n) } : refs.setFloating}
|
|
581
585
|
style={{ ...floatingStyles, ...(depth ? { '--kol-float-depth': depth } : null), ...fm?.style, ...extraStyle }}
|
|
582
586
|
className={cls}
|
|
583
587
|
data-editor-keep-selection
|
|
584
588
|
data-side={fm ? popover.placement?.split('-')[0] : undefined}
|
|
585
589
|
data-exit={fm && presence.exiting ? '' : undefined}
|
|
586
|
-
{...getFloatingProps()}
|
|
590
|
+
{...getFloatingProps(floatingProps)}
|
|
587
591
|
>
|
|
588
592
|
<FloatDepth.Provider value={depth + 1}>{children}</FloatDepth.Provider>
|
|
589
593
|
</div>
|