@kolkrabbi/kol-component 0.341.1 → 0.342.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.341.1",
3
+ "version": "0.342.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,9 +29,9 @@
29
29
  "embla-carousel-react": "^8.6.0",
30
30
  "pdfjs-dist": "^6.3.289",
31
31
  "react-syntax-highlighter": "^16.1.1",
32
- "@kolkrabbi/kol-growth": "^0.5.0",
32
+ "@kolkrabbi/kol-search": "^0.3.0",
33
33
  "@kolkrabbi/kol-markdown": "^0.2.0",
34
- "@kolkrabbi/kol-search": "^0.3.0"
34
+ "@kolkrabbi/kol-growth": "^0.5.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@kolkrabbi/kol-icons": ">=0.61.1",
@@ -42,7 +42,7 @@
42
42
  "react-dom": "^18.3.0 || ^19.0.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@kolkrabbi/kol-icons": "^0.64.0"
45
+ "@kolkrabbi/kol-icons": "^0.65.0"
46
46
  },
47
47
  "files": [
48
48
  "src",
@@ -51,6 +51,11 @@ 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'} variant THE FLOAT LOOK (plan-2026-11-05-float-editor W2.6; his frame 19:6066 — "New text" ·
55
+ * "600 × 160"): a solid 1px oq-64 outline, 6 square handles filled at full ink, the
56
+ * rotate handle a 6 circle, `name` above the box's top-left (`kol-float-label`, oq-64) and
57
+ * the size cap under it (`kol-float-ruler` on oq-08, the float list round). Unset, as before
58
+ * @param {string} name the object's name, drawn above the box by the float look
54
59
  */
55
60
  const HANDLE_DIRS = [
56
61
  { dir: 'NW', cursor: 'nwse-resize', x: 0, y: 0 },
@@ -76,6 +81,8 @@ export default function SelectionOverlay({
76
81
  accentColor = 'var(--kol-accent-primary)',
77
82
  labelFormatter = (b) => `${Math.round(b.w)} × ${Math.round(b.h)}`,
78
83
  rotateTitle = 'Rotate',
84
+ variant,
85
+ name,
79
86
  }) {
80
87
  /* Chrome renders in virtual px inside the zoomed transform — divide by zoom
81
88
  * so handles / outline / label stay screen-constant at any zoom. 1 outside a
@@ -83,6 +90,7 @@ export default function SelectionOverlay({
83
90
  const zoom = useContext(CanvasZoomContext)
84
91
 
85
92
  if (!box || box.x == null) return null /* no positional box → no chrome */
93
+ if (variant === 'float') return <FloatSelection box={box} zoom={zoom} showHandles={showHandles} showRotate={showRotate} showLabel={showLabel} name={name} labelFormatter={labelFormatter} rotateTitle={rotateTitle} />
86
94
 
87
95
  const { x, y, w, h } = box
88
96
  const size = handleSize / zoom
@@ -196,3 +204,41 @@ export default function SelectionOverlay({
196
204
  </>
197
205
  )
198
206
  }
207
+
208
+ /* the float look — the same handles and data-handle routing, drawn as his frame draws the selection; every screen-constant
209
+ * size divides by the zoom (6 handles, the 1px outline) and the two labels counter-scale, as the default look does */
210
+ function FloatSelection({ box, zoom, showHandles = true, showRotate, showLabel = true, name, labelFormatter, rotateTitle }) {
211
+ const { x, y, w, h } = box
212
+ const size = 6 / zoom
213
+ const rotate = showRotate ?? showHandles
214
+ const rot = typeof box.rotation === 'number' ? box.rotation : 0
215
+ const ink = 'var(--kol-surface-on-primary)'
216
+ const counter = { transform: `scale(${1 / zoom})`, pointerEvents: 'none', whiteSpace: 'nowrap', zIndex: 100 }
217
+ return (
218
+ <>
219
+ <div style={{ position: 'absolute', left: x, top: y, width: w, height: h, transform: rot ? `rotate(${rot}deg)` : undefined, pointerEvents: 'none', zIndex: 100 }}>
220
+ <div style={{ position: 'absolute', inset: 0, boxShadow: `0 0 0 ${1 / zoom}px var(--kol-oq-64)` }} />
221
+ {rotate && (
222
+ <Tooltip label={rotateTitle} asChild>
223
+ <div data-handle="ROT" style={{ position: 'absolute', left: `calc(50% - ${size / 2}px)`, top: -(ROTATE_OFFSET / zoom), width: size, height: size, borderRadius: '50%', background: ink, cursor: 'grab', pointerEvents: 'auto' }} />
224
+ </Tooltip>
225
+ )}
226
+ {showHandles && HANDLE_DIRS.map(({ dir, cursor, x: hx, y: hy }) => (
227
+ <div key={dir} data-handle={dir} style={{ position: 'absolute', left: `calc(${hx * 100}% - ${size / 2}px)`, top: `calc(${hy * 100}% - ${size / 2}px)`, width: size, height: size, background: ink, cursor, pointerEvents: 'auto' }} />
228
+ ))}
229
+ </div>
230
+ {/* each label hangs off a zero-size anchor so the counter-scale keeps its edge on the anchor */}
231
+ {showLabel && name && (
232
+ <div style={{ position: 'absolute', left: x, top: y - 8 / zoom, width: 0, height: 0, zIndex: 100 }}>
233
+ <span className="kol-float-label text-oq-64" style={{ ...counter, position: 'absolute', left: 0, bottom: 0, transformOrigin: 'left bottom' }}>{name}</span>
234
+ </div>
235
+ )}
236
+ {showLabel && (
237
+ <div style={{ position: 'absolute', left: x + w / 2, top: y + h + 8 / zoom, width: 0, height: 0, zIndex: 100 }}>
238
+ <span className="kol-float-ruler text-emphasis bg-oq-08 rounded-[var(--kol-float-list-r)] px-2 py-1"
239
+ style={{ ...counter, position: 'absolute', left: 0, top: 0, transform: `translateX(-50%) scale(${1 / zoom})`, transformOrigin: 'top center' }}>{labelFormatter(box)}</span>
240
+ </div>
241
+ )}
242
+ </>
243
+ )
244
+ }