@kolkrabbi/kol-component 0.377.0 → 0.379.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 +5 -4
- package/src/atoms/BezierPathEditor.jsx +1 -1
- package/src/atoms/Button.jsx +84 -1
- package/src/atoms/Figure.jsx +19 -1
- package/src/atoms/FunctionPlot.jsx +1 -1
- package/src/atoms/Input.jsx +105 -1
- package/src/atoms/Kbd.jsx +42 -2
- package/src/atoms/Link.jsx +20 -0
- package/src/atoms/OriginPicker.jsx +9 -5
- package/src/atoms/SectionFooter.jsx +22 -0
- package/src/atoms/SectionHeader.jsx +24 -0
- package/src/atoms/SizeOrDownload.jsx +1 -1
- package/src/atoms/Textarea.jsx +11 -2
- package/src/atoms/ToggleCheckbox.jsx +23 -1
- package/src/atoms/ToggleSwitch.jsx +39 -0
- package/src/atoms/ViewToggle.jsx +2 -2
- package/src/atoms/XYPad.jsx +25 -0
- package/src/hooks/useDragResize.js +1 -1
- package/src/index.js +26 -3
- package/src/molecules/AccountMenu.jsx +14 -1
- package/src/molecules/AlignmentGrid.jsx +13 -1
- package/src/molecules/ButtonGroup.jsx +73 -1
- package/src/molecules/ButtonSplit.jsx +64 -3
- package/src/molecules/Chip.jsx +26 -0
- package/src/molecules/CodeBlock.jsx +39 -2
- package/src/molecules/ColorInputRow.jsx +125 -4
- package/src/molecules/ColorSwatch.jsx +43 -2
- package/src/molecules/ContentCard.jsx +104 -3
- package/src/molecules/ContentMedia.jsx +1 -1
- package/src/molecules/ContentRow.jsx +3 -3
- package/src/molecules/DividerLabel.jsx +19 -0
- package/src/molecules/Dropdown.jsx +111 -1
- package/src/molecules/DropdownStepper.jsx +29 -0
- package/src/molecules/FieldPair.jsx +41 -2
- package/src/molecules/Header.jsx +8 -4
- package/src/molecules/LabeledControl.jsx +51 -0
- package/src/molecules/Menu.jsx +239 -3
- package/src/molecules/Modal.jsx +216 -10
- package/src/molecules/ModalShell.jsx +21 -8
- package/src/molecules/OptionRow.jsx +1 -1
- package/src/molecules/ParamBindDot.jsx +29 -2
- package/src/molecules/QuantityInput.jsx +48 -0
- package/src/molecules/RailFloat.jsx +4 -3
- package/src/molecules/RailHeader.jsx +32 -2
- package/src/molecules/SectionText.jsx +54 -1
- package/src/molecules/Slider.jsx +101 -2
- package/src/molecules/SplitToolButton.jsx +4 -6
- package/src/molecules/SwatchControls.jsx +28 -0
- package/src/molecules/SwatchGrid.jsx +39 -0
- package/src/molecules/TabsDocument.jsx +131 -0
- package/src/molecules/TabsRow.jsx +35 -1
- package/src/molecules/Toast.jsx +55 -0
- package/src/molecules/TreeRow.jsx +87 -1
- package/src/organisms/AppItemMenuProvider.jsx +2 -2
- package/src/organisms/ColorPickerPopover.jsx +133 -4
- package/src/organisms/ColumnBrowser.jsx +1 -1
- package/src/organisms/CommandOverlay.jsx +396 -21
- package/src/organisms/FindBar.jsx +70 -0
- package/src/organisms/FramedMediaBand.jsx +2 -2
- package/src/organisms/GalleryCarousel.jsx +1 -1
- package/src/organisms/LogoSystem.jsx +38 -0
- package/src/organisms/LogoTuner.jsx +32 -0
- package/src/organisms/MediaLibrary.jsx +1 -1
- package/src/organisms/MediaLibraryPages.jsx +1 -1
- package/src/organisms/Rail.jsx +33 -1
- package/src/organisms/RailSwitcher.jsx +62 -0
- package/src/organisms/ReadingContents.jsx +63 -1
- package/src/organisms/SectionSplit.jsx +1 -1
- package/src/organisms/SettingsPanel.jsx +64 -6
- package/src/organisms/ShortcutsOverlay.jsx +46 -2
- package/src/organisms/SpectrumControls.jsx +112 -19
- package/src/organisms/StatusBar.jsx +30 -0
- package/src/organisms/Table.jsx +141 -2
- package/src/organisms/TimelineDock.jsx +281 -1
- package/src/organisms/logoBoard.jsx +61 -0
- package/src/utilities/AssetPlaceholder.jsx +1 -1
- package/src/utilities/EditorShell.jsx +42 -1
- package/src/utilities/OverlayGlassPanel.jsx +1 -1
- package/src/utilities/Popover.jsx +298 -2
- package/src/utilities/SelectionOverlay.jsx +74 -1
- package/src/utilities/kolboxGlyph.jsx +10 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { cloneElement, createContext, isValidElement, useContext, useLayoutEffect, useState, version as reactVersion } from 'react'
|
|
1
|
+
import { cloneElement, createContext, forwardRef, isValidElement, useContext, useEffect, useLayoutEffect, useRef, useState, version as reactVersion } from 'react'
|
|
2
|
+
import { createPortal } from 'react-dom'
|
|
2
3
|
import { toneClass, TONE_VARS } from './tone.js'
|
|
3
4
|
import { floatMotion } from './motion.js'
|
|
4
5
|
import useFloatPresence from '../hooks/useFloatPresence.js'
|
|
6
|
+
import Button from '../atoms/Button.jsx'
|
|
5
7
|
import {
|
|
6
8
|
useFloating,
|
|
7
9
|
autoUpdate,
|
|
@@ -137,6 +139,250 @@ export function usePopover({
|
|
|
137
139
|
return { ...data, floatingStyles, ...interactions, open }
|
|
138
140
|
}
|
|
139
141
|
|
|
142
|
+
|
|
143
|
+
/* ── the kolbox variant's layer (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18) ──
|
|
144
|
+
* kolbox's OverlayLayer carried line for line: the layer `Menu`, `PopoverPanel` and `ModalDialog` draw their kolbox look
|
|
145
|
+
* in. Not floating-ui: its placements (`over`, a Dropdown's list lying over its field, 28.5; `beside`, a child menu
|
|
146
|
+
* beside its parent panel) and its press-outside (on the window in the capture phase, 28.4) are kolbox's behavior and
|
|
147
|
+
* belong to its variant only; KOL's default and float keep usePopover.
|
|
148
|
+
*
|
|
149
|
+
* A portal to document.body (never inside a rail), fixed at its anchor (an element, a ref, or anything with
|
|
150
|
+
* getBoundingClientRect), closing on a press outside it and its anchor, and on Escape. placement: bottom-start (a menu
|
|
151
|
+
* dropped from its trigger), left-start / right-start (a panel beside the rail), beside, over, or center (a Modal: the
|
|
152
|
+
* layer is the dim, and a click on the dim closes it, on click so focus can go back to the trigger after the press;
|
|
153
|
+
* `blocking={false}`: no dim, the layer lets every press and wheel through to what is under it, and only the window
|
|
154
|
+
* itself takes them).
|
|
155
|
+
* Unplaced, the layer is transparent, not hidden, so a Menu can take focus on its first frame. Nested layers: a layer
|
|
156
|
+
* opened later (a Dropdown's Menu inside a Popover or Modal) sits after it in the body, so a press inside it is not
|
|
157
|
+
* outside this one, and Escape closes only the last layer. Exported for a kolbox part that draws its own panel in it (the
|
|
158
|
+
* search window, until it moves). */
|
|
159
|
+
const anchorEl = (anchor) => (anchor && 'current' in anchor ? anchor.current : anchor)
|
|
160
|
+
const later = (a, b) => !!(a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING)
|
|
161
|
+
/* spend a press: stop it here, and swallow the mouse events and the click it raises until the press ends. Several
|
|
162
|
+
layers may close on one press; the first spends it, the rest find it stopped and do nothing more. */
|
|
163
|
+
function spend(e) {
|
|
164
|
+
if (e.cancelBubble) return
|
|
165
|
+
e.stopPropagation(); e.preventDefault()
|
|
166
|
+
const stop = (ev) => { ev.stopPropagation(); ev.preventDefault() }
|
|
167
|
+
const kinds = ['mousedown', 'mousemove', 'mouseup', 'click', 'pointermove', 'pointerup']
|
|
168
|
+
kinds.forEach((k) => window.addEventListener(k, stop, true))
|
|
169
|
+
const end = () => setTimeout(() => kinds.forEach((k) => window.removeEventListener(k, stop, true)))
|
|
170
|
+
window.addEventListener('pointerup', end, { capture: true, once: true })
|
|
171
|
+
window.addEventListener('pointercancel', end, { capture: true, once: true })
|
|
172
|
+
}
|
|
173
|
+
export function PopoverLayer({ anchor, open, onClose, placement = 'bottom-start', kind, blocking = true, children }) {
|
|
174
|
+
const ref = useRef(null)
|
|
175
|
+
const [pos, setPos] = useState(null)
|
|
176
|
+
|
|
177
|
+
useLayoutEffect(() => {
|
|
178
|
+
if (!open) return setPos(null)
|
|
179
|
+
if (placement === 'center') return setPos({})
|
|
180
|
+
const place = () => {
|
|
181
|
+
const a = anchorEl(anchor), box = ref.current
|
|
182
|
+
if (!a || !box) return
|
|
183
|
+
const r = a.getBoundingClientRect(), w = box.offsetWidth
|
|
184
|
+
/* a panel beside its anchor keeps its top on the anchor: one too tall for the room under it shrinks, and its body
|
|
185
|
+
scrolls, rather than moving up (160 at least, then it moves up as far as it must) */
|
|
186
|
+
const panel = (placement === 'left-start' || placement === 'right-start') ? box.firstElementChild : null
|
|
187
|
+
if (panel) panel.style.maxHeight = ''
|
|
188
|
+
let h = box.offsetHeight
|
|
189
|
+
const vw = window.innerWidth, vh = window.innerHeight
|
|
190
|
+
if (panel && r.top + h > vh - 8) {
|
|
191
|
+
const top = Math.max(8, Math.min(r.top, vh - 8 - 160))
|
|
192
|
+
h = Math.min(h, vh - 8 - top)
|
|
193
|
+
panel.style.maxHeight = `${h}px`
|
|
194
|
+
}
|
|
195
|
+
let x, y
|
|
196
|
+
if (placement === 'bottom-start') { x = r.left; y = r.bottom + 4; if (y + h > vh - 8) y = r.top - h - 4 }
|
|
197
|
+
else if (placement === 'left-start') { x = r.left - w - 8; y = r.top; if (x < 8) x = r.right + 8 }
|
|
198
|
+
/* a child menu: the anchor is the parent PANEL; the child stands 4 off its right edge (its left when the window
|
|
199
|
+
ends), its top level with the parent's top, moved up only as far as it must to fit */
|
|
200
|
+
else if (placement === 'beside') { x = r.right + 4; y = r.top; if (x + w > vw - 8) x = r.left - w - 4 }
|
|
201
|
+
/* over (28.5): the list opens OVER its field, its left edge on the field's, the chosen row (`data-chosen`) lying on
|
|
202
|
+
the field. A list that fits the window moves only as far as it must at an edge. A list taller than the window
|
|
203
|
+
starts where its rows would start, runs to the window's foot (160 at least) and scrolls its rows so the chosen
|
|
204
|
+
one still lies on the field */
|
|
205
|
+
else if (placement === 'over') {
|
|
206
|
+
const row = box.querySelector('[data-chosen]'), list = box.querySelector('[data-kolbox-menu]')
|
|
207
|
+
x = r.left; y = r.top
|
|
208
|
+
/* past the right edge the menu flips to the field's right edge; the window margin is 4 */
|
|
209
|
+
if (x + w > vw - 4) x = r.right - w
|
|
210
|
+
if (row && list) {
|
|
211
|
+
list.style.maxHeight = ''; list.scrollTop = 0
|
|
212
|
+
const rr = row.getBoundingClientRect(), lt = list.getBoundingClientRect().top
|
|
213
|
+
y = r.top + r.height / 2 - (rr.top - lt + rr.height / 2)
|
|
214
|
+
if (list.scrollHeight > vh - 8) {
|
|
215
|
+
const top = Math.max(4, Math.min(y, vh - 4 - 160))
|
|
216
|
+
h = vh - 4 - top
|
|
217
|
+
list.style.maxHeight = `${h}px`
|
|
218
|
+
list.scrollTop = top - y
|
|
219
|
+
y = top
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else { x = r.right + 8; y = r.top; if (x + w > vw - 8) x = r.left - w - 8 }
|
|
224
|
+
const m = placement === 'over' ? 4 : 8
|
|
225
|
+
setPos({ x: Math.max(m, Math.min(x, vw - w - m)), y: Math.max(m, Math.min(y, vh - h - m)) })
|
|
226
|
+
}
|
|
227
|
+
place()
|
|
228
|
+
/* a scroll inside the overlay (a long list) never moves it */
|
|
229
|
+
const scrolled = (e) => { if (!ref.current?.contains(e.target)) place() }
|
|
230
|
+
window.addEventListener('resize', place)
|
|
231
|
+
window.addEventListener('scroll', scrolled, true)
|
|
232
|
+
return () => { window.removeEventListener('resize', place); window.removeEventListener('scroll', scrolled, true) }
|
|
233
|
+
}, [open, anchor, placement])
|
|
234
|
+
|
|
235
|
+
/* A press outside closes (28.4). On the window in the capture phase: an editor's canvas may stop its own presses, so
|
|
236
|
+
a listener on the document never hears them. A press on the canvas (`[data-canvas]`) that closes an overlay is
|
|
237
|
+
spent on closing: it goes no further and the mouse events and click it would raise are swallowed, so the canvas
|
|
238
|
+
neither deselects nor starts a drag. */
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
if (!open) return
|
|
241
|
+
const down = (e) => {
|
|
242
|
+
const me = ref.current, hit = e.target.closest?.('[data-kolbox-overlay]')
|
|
243
|
+
if (!me || placement === 'center' || (hit && hit !== me && later(me, hit))) return
|
|
244
|
+
if (me.contains(e.target) || anchorEl(anchor)?.contains?.(e.target)) return
|
|
245
|
+
/* a window beside the rail (kind "popover") holds through a press on the canvas; it closes by its close, Escape or
|
|
246
|
+
its caller's toggle. A press on a layer goes on to the canvas (it selects, and a window on the old selection
|
|
247
|
+
goes with it); a press on the empty canvas is spent, so it does not drop the selection the window edits */
|
|
248
|
+
if (kind === 'popover' && e.target.closest?.('[data-canvas]')) {
|
|
249
|
+
if (!e.target.closest('[data-layer-id]')) spend(e)
|
|
250
|
+
return
|
|
251
|
+
}
|
|
252
|
+
onClose?.()
|
|
253
|
+
if (e.target.closest?.('[data-canvas]')) spend(e)
|
|
254
|
+
}
|
|
255
|
+
const key = (e) => {
|
|
256
|
+
const all = document.querySelectorAll('[data-kolbox-overlay]')
|
|
257
|
+
if (e.key === 'Escape' && all[all.length - 1] === ref.current) onClose?.()
|
|
258
|
+
}
|
|
259
|
+
window.addEventListener('pointerdown', down, true)
|
|
260
|
+
document.addEventListener('keydown', key)
|
|
261
|
+
return () => { window.removeEventListener('pointerdown', down, true); document.removeEventListener('keydown', key) }
|
|
262
|
+
}, [open, anchor, onClose, placement, kind])
|
|
263
|
+
|
|
264
|
+
if (!open) return null
|
|
265
|
+
return createPortal(
|
|
266
|
+
<div
|
|
267
|
+
ref={ref}
|
|
268
|
+
data-kolbox-overlay={kind}
|
|
269
|
+
className={placement !== 'center' ? 'fixed z-50' : blocking ? 'kol-popover-layer--kolbox-dim fixed inset-0 z-50 flex items-center justify-center' : 'pointer-events-none fixed inset-0 z-50 flex items-center justify-center [&>*]:pointer-events-auto'}
|
|
270
|
+
onClick={placement === 'center' && blocking ? (e) => e.target === e.currentTarget && onClose?.() : undefined}
|
|
271
|
+
style={placement === 'center' ? undefined : { left: pos?.x ?? 0, top: pos?.y ?? 0, opacity: pos ? 1 : 0 }}
|
|
272
|
+
>
|
|
273
|
+
{children}
|
|
274
|
+
</div>,
|
|
275
|
+
document.body,
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* Tooltip `variant="kolbox"` (W31.2 batch 4): kolbox's Tooltip carried line for line, CSS-placed, no floating-ui. It
|
|
280
|
+
* wraps its trigger; the tip shows above it on hover or keyboard focus, on the one floating surface. Centred on the
|
|
281
|
+
* trigger, then shifted back inside the window (8 from its edge) when a trigger near the edge would push it past; below
|
|
282
|
+
* the trigger when there is no room above it. Inside a rail (`[data-rail]`) the tip stands level with its trigger, at
|
|
283
|
+
* its left, so it never sits over a section's divider line above the trigger's row; a tip too long to stand there
|
|
284
|
+
* wraps to the rail's width. Takes `label`, `children` and `asChild` (no wrapper: the tip hangs on the one child element);
|
|
285
|
+
* renders its wrapper even with no label, as kolbox's did. */
|
|
286
|
+
/* ON THE LAYER ABOVE (plan-2026-11-18-kolbox-system W23.2, 2026-11-18): the tip was placed in CSS inside its trigger's
|
|
287
|
+
* wrapper, so any ancestor with overflow hidden (every kolbox window and popover shell) cut it; "a popup … clipped by
|
|
288
|
+
* modal container". It is now portalled to <body>, fixed, and placed from the trigger's box, as the kolbox menus and
|
|
289
|
+
* dropdowns are (PopoverLayer); same plate, same places. Shown on hover or keyboard focus; no label, no plate. */
|
|
290
|
+
const TIP_EDGE = 8
|
|
291
|
+
const TIP_GAP = 4
|
|
292
|
+
/* true inside a kolbox tooltip's trigger: an icon-only kolbox Button there leaves the tip to it (Button.jsx) */
|
|
293
|
+
export const InTooltipKolbox = (globalThis[Symbol.for('@kolkrabbi/kol-component/InTooltipKolbox')] ??= createContext(false))
|
|
294
|
+
function TooltipKolbox({ label, asChild = false, children }) {
|
|
295
|
+
const wrap = useRef(null)
|
|
296
|
+
const tip = useRef(null)
|
|
297
|
+
const [open, setOpen] = useState(false)
|
|
298
|
+
const [pos, setPos] = useState(null)
|
|
299
|
+
const show = label != null && label !== '' && open
|
|
300
|
+
|
|
301
|
+
useLayoutEffect(() => {
|
|
302
|
+
if (!show) return setPos(null)
|
|
303
|
+
const t = tip.current, w0 = wrap.current
|
|
304
|
+
if (!t || !w0) return
|
|
305
|
+
const r = w0.getBoundingClientRect()
|
|
306
|
+
const railEl = w0.closest('[data-rail]')
|
|
307
|
+
const rail = railEl?.getBoundingClientRect()
|
|
308
|
+
const vw = window.innerWidth, vh = window.innerHeight
|
|
309
|
+
t.style.maxWidth = ''; t.style.whiteSpace = ''; t.style.height = ''
|
|
310
|
+
let w = t.offsetWidth, h = t.offsetHeight
|
|
311
|
+
let x, y, wrapped = null
|
|
312
|
+
/* inside a rail the tip stands level with its trigger, at its left, so it never sits over a section's divider */
|
|
313
|
+
if (rail && r.left - TIP_GAP - w >= rail.left + TIP_EDGE) { x = r.left - TIP_GAP - w; y = r.top + r.height / 2 - h / 2 }
|
|
314
|
+
else {
|
|
315
|
+
/* a tip too long for the rail wraps to the rail's width */
|
|
316
|
+
if (rail && w > rail.width - 2 * TIP_EDGE) {
|
|
317
|
+
wrapped = rail.width - 2 * TIP_EDGE
|
|
318
|
+
Object.assign(t.style, { maxWidth: `${wrapped}px`, whiteSpace: 'normal', height: 'auto' })
|
|
319
|
+
w = t.offsetWidth; h = t.offsetHeight
|
|
320
|
+
}
|
|
321
|
+
const lo = (rail ? rail.left : 0) + TIP_EDGE, hi = (rail ? rail.right : vw) - TIP_EDGE - w
|
|
322
|
+
x = Math.max(lo, Math.min(r.left + r.width / 2 - w / 2, hi))
|
|
323
|
+
y = r.top - TIP_GAP - h
|
|
324
|
+
/* no room above: below the trigger */
|
|
325
|
+
if (y < TIP_EDGE) y = r.bottom + TIP_GAP
|
|
326
|
+
}
|
|
327
|
+
x = Math.max(TIP_EDGE, Math.min(x, vw - TIP_EDGE - w))
|
|
328
|
+
y = Math.max(TIP_EDGE, Math.min(y, vh - TIP_EDGE - h))
|
|
329
|
+
setPos({ x, y, wrapped })
|
|
330
|
+
}, [show, label])
|
|
331
|
+
|
|
332
|
+
const tipNode = show && typeof document !== 'undefined' && createPortal(
|
|
333
|
+
<span
|
|
334
|
+
ref={tip}
|
|
335
|
+
role="tooltip"
|
|
336
|
+
className="kol-tooltip--kolbox kol-kolbox-surface pointer-events-none fixed z-[60] flex h-7 items-center px-2 whitespace-nowrap transition-opacity"
|
|
337
|
+
style={{ left: pos?.x ?? 0, top: pos?.y ?? 0, opacity: pos ? 1 : 0, ...(pos?.wrapped ? { maxWidth: pos.wrapped, whiteSpace: 'normal', height: 'auto', paddingTop: 'var(--kol-spacing-1)', paddingBottom: 'var(--kol-spacing-1)' } : null) }}
|
|
338
|
+
>
|
|
339
|
+
{label}
|
|
340
|
+
</span>,
|
|
341
|
+
document.body,
|
|
342
|
+
)
|
|
343
|
+
const on = {
|
|
344
|
+
onPointerEnter: (e) => e.pointerType !== 'touch' && setOpen(true),
|
|
345
|
+
onPointerLeave: () => setOpen(false),
|
|
346
|
+
onFocus: (e) => e.target.matches?.(':focus-visible') && setOpen(true),
|
|
347
|
+
onBlur: () => setOpen(false),
|
|
348
|
+
}
|
|
349
|
+
/* `asChild`: the tip hangs on its one child element itself, no wrapper in the layout (an icon-only kolbox Button,
|
|
350
|
+
whose parent's rules address it as a direct child); the child's own handlers run first */
|
|
351
|
+
if (asChild && isValidElement(children)) {
|
|
352
|
+
const own = children.props
|
|
353
|
+
const chain = (k) => (e) => { own[k]?.(e); on[k](e) }
|
|
354
|
+
/* the child's own ref is kept beside the tip's */
|
|
355
|
+
const theirs = childRefOf(children)
|
|
356
|
+
const ref = (node) => { wrap.current = node; if (typeof theirs === 'function') theirs(node); else if (theirs) theirs.current = node }
|
|
357
|
+
return (
|
|
358
|
+
<>
|
|
359
|
+
{cloneElement(children, { ref, onPointerEnter: chain('onPointerEnter'), onPointerLeave: chain('onPointerLeave'), onFocus: chain('onFocus'), onBlur: chain('onBlur') })}
|
|
360
|
+
{tipNode}
|
|
361
|
+
</>
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
return (
|
|
365
|
+
/* a trigger that fills its row (w-full) makes the wrapper fill it too, so wrapping a control never narrows it */
|
|
366
|
+
<span ref={wrap} data-kol-tooltip="" className="relative inline-flex has-[>.w-full]:flex has-[>.w-full]:w-full" {...on}>
|
|
367
|
+
<InTooltipKolbox.Provider value>{children}</InTooltipKolbox.Provider>
|
|
368
|
+
{tipNode}
|
|
369
|
+
</span>
|
|
370
|
+
)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/* Tooltip `variant="folio"` (Folio migration batch A, 2026-11-22): Folio's Tooltip carried class for class (apps/folio
|
|
374
|
+
* EditorChrome.jsx): a hairline box at radius 4 padded 4 by 8, 6 over its trigger, the text 11 / 15; shown on hover or
|
|
375
|
+
* focus inside its wrapper, placed in CSS, no portal (so it keeps the frame's `data-folio-*`; an overflow-hidden parent
|
|
376
|
+
* clips it, as Folio's did). Chrome in kol-theme `.kol-tooltip--folio`. */
|
|
377
|
+
function TooltipFolio({ label, children }) {
|
|
378
|
+
return (
|
|
379
|
+
<span className="group relative inline-flex">
|
|
380
|
+
{children}
|
|
381
|
+
<span role="tooltip" className="kol-tooltip--folio pointer-events-none invisible absolute bottom-[calc(100%+6px)] left-1/2 z-50 -translate-x-1/2 whitespace-nowrap rounded-[4px] border px-[8px] py-[4px] group-focus-within:visible group-hover:visible">{label}</span>
|
|
382
|
+
</span>
|
|
383
|
+
)
|
|
384
|
+
}
|
|
385
|
+
|
|
140
386
|
/**
|
|
141
387
|
* Tooltip — hover-triggered popover with text content. Wraps any trigger
|
|
142
388
|
* element. Built on `usePopover` with `hover: true`, `click: false`,
|
|
@@ -164,6 +410,8 @@ const TooltipNest = (globalThis[Symbol.for('@kolkrabbi/kol-component/TooltipNest
|
|
|
164
410
|
const childRefOf = (el) => ('ref' in (el.props ?? {}) ? el.props.ref : reactVersion.startsWith('18') ? el.ref : undefined)
|
|
165
411
|
|
|
166
412
|
export function Tooltip(props) {
|
|
413
|
+
if (props.variant === 'kolbox') return <TooltipKolbox label={props.label} asChild={props.asChild}>{props.children}</TooltipKolbox>
|
|
414
|
+
if (props.variant === 'folio') return <TooltipFolio label={props.label}>{props.children}</TooltipFolio>
|
|
167
415
|
/* no label → no tooltip: several call sites pass an optional hint, and an empty panel is worse
|
|
168
416
|
* than none. A separate component so the hooks below never run conditionally. */
|
|
169
417
|
if (props.label == null || props.label === '') return props.children
|
|
@@ -270,7 +518,55 @@ function TooltipOn({
|
|
|
270
518
|
/* how many floats this one is opened from inside — context crosses portals, the DOM order does not */
|
|
271
519
|
const FloatDepth = (globalThis[Symbol.for('@kolkrabbi/kol-component/FloatDepth')] ??= createContext(0))
|
|
272
520
|
|
|
273
|
-
|
|
521
|
+
|
|
522
|
+
/* The kolbox panel shell (W31.2 batch 4): kolbox's PopoverShell carried line for line, the panel every kolbox popover
|
|
523
|
+
* and window draws: radius 16, the secondary surface on the one floating surface (`.kol-kolbox-surface`), 240 wide
|
|
524
|
+
* (`--kol-kolbox-popover-w`) unless `width` says otherwise. Header: a `leading` slot (tabs, or an icon and name), the
|
|
525
|
+
* `title`, the `actions`, close (only with `onClose`: a dialog with none cannot be dismissed). The body is the
|
|
526
|
+
* children; `footer`, when given, is a row of buttons under it. Drawn by `PopoverPanel variant="kolbox"` beside its
|
|
527
|
+
* anchor, by `ModalDialog variant="kolbox"` centred, and on its own as `ModalShell variant="kolbox"`. Other props
|
|
528
|
+
* (aria-modal, data-*) and the ref go on the dialog. Not exported from the package. */
|
|
529
|
+
export const KolboxShell = forwardRef(function KolboxShell({ onClose, title, leading, actions, footer, width, className = '', children, ...rest }, ref) {
|
|
530
|
+
return (
|
|
531
|
+
<section
|
|
532
|
+
ref={ref}
|
|
533
|
+
role="dialog"
|
|
534
|
+
aria-label={typeof title === 'string' ? title : undefined}
|
|
535
|
+
data-kolbox-popover=""
|
|
536
|
+
className={`kol-modal--kolbox kol-kolbox-surface flex flex-col overflow-hidden ${className}`}
|
|
537
|
+
style={width ? { width } : undefined}
|
|
538
|
+
{...rest}
|
|
539
|
+
>
|
|
540
|
+
<header className="flex shrink-0 items-center gap-1 py-2 pr-2 pl-4">
|
|
541
|
+
{leading}
|
|
542
|
+
{title && <h2 className="kol-modal-title--kolbox min-w-0 flex-1 truncate">{title}</h2>}
|
|
543
|
+
{!title && <span className="flex-1" />}
|
|
544
|
+
{actions}
|
|
545
|
+
{onClose && <Button variant="kolbox" iconOnly="x" aria-label="Close" onClick={onClose} />}
|
|
546
|
+
</header>
|
|
547
|
+
<div className="flex min-h-0 flex-1 flex-col overflow-y-auto">{children}</div>
|
|
548
|
+
{footer && <footer className="flex shrink-0 items-center justify-end gap-2 px-4 pb-4">{footer}</footer>}
|
|
549
|
+
</section>
|
|
550
|
+
)
|
|
551
|
+
})
|
|
552
|
+
|
|
553
|
+
/* `variant="kolbox"` (W31.2 batch 4): kolbox's Popover carried line for line, `ModalShell variant="kolbox"` (its shell)
|
|
554
|
+
* in `PopoverLayer`, beside its anchor: `anchor`, `open`, `onClose`, `placement` (left-start by default, beside the right
|
|
555
|
+
* rail), and the shell's `title`, `leading`, `actions`, `footer`, `width`, `aria-label`, `className`, `children`. */
|
|
556
|
+
function PopoverKolbox({ anchor, open, onClose, placement = 'left-start', variant, ...shell }) {
|
|
557
|
+
return (
|
|
558
|
+
<PopoverLayer anchor={anchor} open={open} onClose={onClose} placement={placement} kind="popover">
|
|
559
|
+
<KolboxShell onClose={onClose} {...shell} />
|
|
560
|
+
</PopoverLayer>
|
|
561
|
+
)
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
export function PopoverPanel(props) {
|
|
565
|
+
if (props.variant === 'kolbox') return <PopoverKolbox {...props} />
|
|
566
|
+
return <PopoverPanelOn {...props} />
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function PopoverPanelOn({
|
|
274
570
|
popover,
|
|
275
571
|
children,
|
|
276
572
|
panel = true,
|
|
@@ -51,11 +51,21 @@ 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 {'float'}
|
|
54
|
+
* @param {'float'|'kolbox'} variant THE FLOAT LOOK (plan-2026-11-05-float-editor W2.6; his frame 19:6066 — "New text" ·
|
|
55
55
|
* "600 × 160"): a solid 1px oq-64 outline, 6 square handles filled at full ink, the
|
|
56
56
|
* rotate handle a 6 circle, `name` above the box's top-left (`kol-float-label`, oq-64) and
|
|
57
57
|
* the size cap under it (`kol-float-ruler` on oq-08, the float list round). Unset, as before
|
|
58
58
|
* @param {string} name the object's name, drawn above the box by the float look
|
|
59
|
+
* @param {number} scale screen px per virtual px (default: the zoom); a host whose stage is also fitted passes
|
|
60
|
+
* fit × zoom so 1 screen px stays 1
|
|
61
|
+
*
|
|
62
|
+
* THE KOLBOX LOOK (`variant="kolbox"`, plan-2026-11-19-kolbox-whats-left R2, his Figma reference "this is how shape looks
|
|
63
|
+
* like in figma"): one solid 1 screen px accent line, four white 6 squares with a 1px accent edge at the corners only
|
|
64
|
+
* (SelectionBox 28:9356's handle size), no name, and the size on an accent chip centred 8 px under the box (the design's
|
|
65
|
+
* 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
|
|
66
|
+
* 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
|
|
67
|
+
* outside each corner (`data-handle="ROT"`, the host's `--kol-cursor-rotate`). `showHandles` false draws the line
|
|
68
|
+
* alone (hover, a multi-selection's member).
|
|
59
69
|
*/
|
|
60
70
|
const HANDLE_DIRS = [
|
|
61
71
|
{ dir: 'NW', cursor: 'nwse-resize', x: 0, y: 0 },
|
|
@@ -83,6 +93,7 @@ export default function SelectionOverlay({
|
|
|
83
93
|
rotateTitle = 'Rotate',
|
|
84
94
|
variant,
|
|
85
95
|
name,
|
|
96
|
+
scale,
|
|
86
97
|
}) {
|
|
87
98
|
/* Chrome renders in virtual px inside the zoomed transform — divide by zoom
|
|
88
99
|
* so handles / outline / label stay screen-constant at any zoom. 1 outside a
|
|
@@ -90,6 +101,7 @@ export default function SelectionOverlay({
|
|
|
90
101
|
const zoom = useContext(CanvasZoomContext)
|
|
91
102
|
|
|
92
103
|
if (!box || box.x == null) return null /* no positional box → no chrome */
|
|
104
|
+
if (variant === 'kolbox') return <KolboxSelection box={box} s={scale || zoom || 1} showHandles={showHandles} showRotate={showRotate} showLabel={showLabel} labelFormatter={labelFormatter} />
|
|
93
105
|
if (variant === 'float') return <FloatSelection box={box} zoom={zoom} showHandles={showHandles} showRotate={showRotate} showLabel={showLabel} name={name} labelFormatter={labelFormatter} rotateTitle={rotateTitle} />
|
|
94
106
|
|
|
95
107
|
const { x, y, w, h } = box
|
|
@@ -242,3 +254,64 @@ function FloatSelection({ box, zoom, showHandles = true, showRotate, showLabel =
|
|
|
242
254
|
</>
|
|
243
255
|
)
|
|
244
256
|
}
|
|
257
|
+
|
|
258
|
+
/* the kolbox look (see the header): every screen-constant size is `n * px`, px being one screen px in virtual px */
|
|
259
|
+
const KOLBOX_CORNERS = [
|
|
260
|
+
{ dir: 'NW', cursor: 'nwse-resize', x: 0, y: 0 },
|
|
261
|
+
{ dir: 'NE', cursor: 'nesw-resize', x: 1, y: 0 },
|
|
262
|
+
{ dir: 'SE', cursor: 'nwse-resize', x: 1, y: 1 },
|
|
263
|
+
{ dir: 'SW', cursor: 'nesw-resize', x: 0, y: 1 },
|
|
264
|
+
]
|
|
265
|
+
function KolboxSelection({ box, s, showHandles = true, showRotate, showLabel = true, labelFormatter }) {
|
|
266
|
+
const { x, y, w, h } = box
|
|
267
|
+
const px = 1 / s
|
|
268
|
+
const hs = 6 * px, band = 8 * px, rz = 16 * px
|
|
269
|
+
const rotate = showRotate ?? showHandles
|
|
270
|
+
const rot = typeof box.rotation === 'number' ? box.rotation : 0
|
|
271
|
+
const rad = (rot * Math.PI) / 180
|
|
272
|
+
const halfBoundsH = (Math.abs(w * Math.sin(rad)) + Math.abs(h * Math.cos(rad))) / 2
|
|
273
|
+
const accent = 'var(--kol-accent-primary)'
|
|
274
|
+
const zone = { position: 'absolute', pointerEvents: 'auto' }
|
|
275
|
+
return (
|
|
276
|
+
<>
|
|
277
|
+
<div data-selection="kolbox" style={{ position: 'absolute', left: x, top: y, width: w, height: h, transform: rot ? `rotate(${rot}deg)` : undefined, pointerEvents: 'none', zIndex: 100 }}>
|
|
278
|
+
{/* a spread shadow, not an outline: an outline's width is rounded to whole layout px before the zoom scales it */}
|
|
279
|
+
<div data-selection-line style={{ position: 'absolute', inset: 0, boxShadow: `0 0 0 ${px}px ${accent}` }} />
|
|
280
|
+
{rotate && KOLBOX_CORNERS.map(({ dir, x: cx, y: cy }) => (
|
|
281
|
+
<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)' }} />
|
|
282
|
+
))}
|
|
283
|
+
{showHandles && (
|
|
284
|
+
<>
|
|
285
|
+
<div data-handle="N" style={{ ...zone, left: hs, right: hs, top: -band / 2, height: band, cursor: 'ns-resize' }} />
|
|
286
|
+
<div data-handle="S" style={{ ...zone, left: hs, right: hs, bottom: -band / 2, height: band, cursor: 'ns-resize' }} />
|
|
287
|
+
<div data-handle="W" style={{ ...zone, top: hs, bottom: hs, left: -band / 2, width: band, cursor: 'ew-resize' }} />
|
|
288
|
+
<div data-handle="E" style={{ ...zone, top: hs, bottom: hs, right: -band / 2, width: band, cursor: 'ew-resize' }} />
|
|
289
|
+
{KOLBOX_CORNERS.map(({ dir, cursor, x: cx, y: cy }) => (
|
|
290
|
+
<div
|
|
291
|
+
key={dir}
|
|
292
|
+
data-handle={dir}
|
|
293
|
+
data-selection-handle
|
|
294
|
+
style={{ ...zone, left: `calc(${cx * 100}% - ${hs / 2}px)`, top: `calc(${cy * 100}% - ${hs / 2}px)`, width: hs, height: hs, background: '#fff', boxShadow: `inset 0 0 0 ${px}px ${accent}`, cursor }}
|
|
295
|
+
/>
|
|
296
|
+
))}
|
|
297
|
+
</>
|
|
298
|
+
)}
|
|
299
|
+
</div>
|
|
300
|
+
{showLabel && (
|
|
301
|
+
<div style={{ position: 'absolute', left: x + w / 2, top: y + h / 2 + halfBoundsH + 8 * px, width: 0, height: 0, zIndex: 100, pointerEvents: 'none' }}>
|
|
302
|
+
<span
|
|
303
|
+
data-selection-size
|
|
304
|
+
style={{
|
|
305
|
+
position: 'absolute', left: 0, top: 0, transform: `translateX(-50%) scale(${px})`, transformOrigin: 'top center',
|
|
306
|
+
display: 'flex', alignItems: 'center', height: 18, padding: '2px 8px', boxSizing: 'border-box', borderRadius: 4,
|
|
307
|
+
fontFamily: 'var(--kol-font-family-sans)', fontSize: 10, lineHeight: '14px', fontWeight: 500, whiteSpace: 'nowrap',
|
|
308
|
+
background: accent, color: 'var(--kol-accent-on-primary)',
|
|
309
|
+
}}
|
|
310
|
+
>
|
|
311
|
+
{labelFormatter(box)}
|
|
312
|
+
</span>
|
|
313
|
+
</div>
|
|
314
|
+
)}
|
|
315
|
+
</>
|
|
316
|
+
)
|
|
317
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
2
|
+
|
|
3
|
+
/* kolbox's glyph (plan-2026-11-18-kolbox-system W31.2 batch 4): your icons by the set's own name, 16 with the stroke lift
|
|
4
|
+
* (`.kol-kolbox-icon`); every chevron 12 with the dock chevron's stroke (`.kol-kolbox-chevron`), whatever size is asked
|
|
5
|
+
* (28.6, his "chevrons too big"). The package's kolbox parts draw it; not in the index: apps/kolbox reaches it as
|
|
6
|
+
* `@kolkrabbi/kol-component/utilities/kolboxGlyph` for its loose glyphs (plan-2026-11-19-kolbox-whats-left C9.2). */
|
|
7
|
+
export default function KolboxGlyph({ name, size = 16, className = '' }) {
|
|
8
|
+
const chevron = name?.startsWith('chevron-')
|
|
9
|
+
return <IconLoader name={name} size={chevron ? 12 : size} className={`${chevron ? 'kol-kolbox-chevron' : 'kol-kolbox-icon'} shrink-0 ${className}`} />
|
|
10
|
+
}
|