@kolkrabbi/kol-component 0.255.0 → 0.257.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.255.0",
3
+ "version": "0.257.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,13 +40,16 @@ export function MenuItem({
40
40
  * beside it, so media's phone `···` stood 32 next to a 26 `sm` search field. `size` pins it to the
41
41
  * control heights (01-foundations/09-sizes: 22 · 26 · 32 · 40); `md` is the 32 it always was. */
42
42
  size = 'md',
43
+ /* the panel's gap below the trigger. A trigger inside a taller bar passes a negative value so
44
+ * the panel's top lands on the bar's own line (MenuItemOffset, kol-fxr 2026-10-13) */
45
+ offset = 4,
43
46
  }) {
44
47
  const [open, setOpen] = useState(defaultOpen)
45
48
  const popover = usePopover({
46
49
  open,
47
50
  onOpenChange: setOpen,
48
51
  placement: align === 'end' ? 'bottom-end' : 'bottom-start',
49
- offset: 4,
52
+ offset,
50
53
  role: 'menu',
51
54
  })
52
55
 
@@ -62,6 +62,7 @@ import { glyphSize } from '../hooks/glyphLadders.js'
62
62
  * A variant may carry its own `onSelect()` — that row does its own thing instead of `onChange`
63
63
  * (Text: "Text" arms the tool, "Kinetic type" inserts a layer). Without `lastPicked` the trigger
64
64
  * remembers the last row picked from the menu (kol-fxr ToolPalette, editor-panels-the-held-specs A3).
65
+ * @param {string} props.placement - Where the fold opens, floating-ui's placement — a vertical `ToolPalette` passes `'right-start'` (default: 'bottom-start')
65
66
  * @param {string} props.className - Additional classes on the trigger
66
67
  */
67
68
 
@@ -87,6 +88,7 @@ const SplitToolButton = ({
87
88
  onTrigger,
88
89
  disabled = false,
89
90
  iconComponent: IconC = Icon,
91
+ placement = 'bottom-start',
90
92
  className = '',
91
93
  'aria-label': ariaLabel,
92
94
  }) => {
@@ -94,7 +96,7 @@ const SplitToolButton = ({
94
96
  const popover = usePopover({
95
97
  open,
96
98
  onOpenChange: setOpen,
97
- placement: 'bottom-start',
99
+ placement,
98
100
  offset: 4,
99
101
  role: 'menu',
100
102
  })
@@ -805,6 +805,29 @@ export function useFrameGeom(containerRef, virtualWidth = CANVAS_VIRTUAL_W) {
805
805
  */
806
806
  export function CanvasRuler({ containerRef, virtualWidth = CANVAS_VIRTUAL_W, disabled = false }) {
807
807
  const geom = useFrameGeom(containerRef, virtualWidth)
808
+ const hPointer = useRef(null)
809
+ const vPointer = useRef(null)
810
+
811
+ /* The pointer line on each ruler follows the container's own pointermove — written straight
812
+ * to the two <line>s, so a mouse move never re-renders a few hundred ticks. */
813
+ useEffect(() => {
814
+ const el = containerRef.current
815
+ if (!el) return
816
+ const move = (e) => {
817
+ const r = el.getBoundingClientRect()
818
+ hPointer.current?.setAttribute('transform', `translate(${e.clientX - r.left} 0)`)
819
+ vPointer.current?.setAttribute('transform', `translate(0 ${e.clientY - r.top})`)
820
+ hPointer.current?.setAttribute('visibility', 'visible')
821
+ vPointer.current?.setAttribute('visibility', 'visible')
822
+ }
823
+ const leave = () => {
824
+ hPointer.current?.setAttribute('visibility', 'hidden')
825
+ vPointer.current?.setAttribute('visibility', 'hidden')
826
+ }
827
+ el.addEventListener('pointermove', move)
828
+ el.addEventListener('pointerleave', leave)
829
+ return () => { el.removeEventListener('pointermove', move); el.removeEventListener('pointerleave', leave) }
830
+ }, [containerRef])
808
831
 
809
832
  const startGuideDrag = (axis) => (e) => {
810
833
  if (disabled || e.button !== 0) return
@@ -815,47 +838,59 @@ export function CanvasRuler({ containerRef, virtualWidth = CANVAS_VIRTUAL_W, dis
815
838
  }
816
839
 
817
840
  if (!geom || geom.pxPer <= 0) return null
818
- const step = niceStep(geom.pxPer)
819
- const hTicks = ticksFor(geom.left, geom.pxPer, geom.cw, step)
820
- const vTicks = ticksFor(geom.top, geom.pxPer, geom.ch, step)
841
+ /* Three ranks (CanvasRulerGraduated, kol-fxr 2026-10-13): the major at `niceStep`, the medium
842
+ * at half of it, the minor at a tenth — counted by index `k`, not by value, so a 25 step's
843
+ * 2.5 minors never round onto each other. */
844
+ const step = niceStep(geom.pxPer)
845
+ const minor = step / 10
846
+ const graduate = (origin, span) => {
847
+ const out = []
848
+ const last = Math.floor((span - origin) / geom.pxPer / minor)
849
+ for (let k = Math.ceil(-origin / geom.pxPer / minor); k <= last; k++) {
850
+ out.push({ k, s: origin + k * minor * geom.pxPer, rank: k % 10 === 0 ? 0 : k % 5 === 0 ? 1 : 2 })
851
+ }
852
+ return out
853
+ }
854
+ const hTicks = graduate(geom.left, geom.cw)
855
+ const vTicks = graduate(geom.top, geom.ch)
821
856
 
822
- /* Ruler chrome rides the themed fg ramp so it flips with light/dark: an 8%
823
- * bar with fg ticks/labels, all naturally contrast-correct in both themes —
824
- * no hardcoded greys. */
825
- const tickColor = 'var(--kol-fg-48)'
857
+ /* No band: the bar is transparent and the pasteboard shows through, one hairline at the inner
858
+ * edge. Ink rides the themed fg ramp so it flips with light/dark. */
859
+ const LEN = [RULER, 9, 4]
860
+ const tickColor = ['var(--kol-fg-48)', 'var(--kol-fg-24)', 'var(--kol-fg-24)']
826
861
  const textColor = 'var(--kol-fg-64)'
827
- const barBg = 'var(--kol-fg-08)'
828
862
  const borderColor = 'var(--kol-oq-16)'
829
- const labelStyle = { fontFamily: 'var(--kol-font-family-mono)', fontSize: 9 }
863
+ const labelStyle = { fontFamily: 'var(--kol-font-family-sans)', fontSize: 10 }
864
+ const label = (k) => Math.round(k * minor)
830
865
 
831
866
  return (
832
867
  <>
833
868
  <svg width="100%" height={RULER}
834
869
  onPointerDown={startGuideDrag('h')}
835
870
  style={{ position: 'absolute', top: 0, left: 0, zIndex: 4, cursor: 'row-resize' }}>
836
- <rect x={0} y={0} width="100%" height={RULER} fill={barBg} />
837
- {hTicks.map(({ v, s }) => (
838
- <g key={v}>
839
- <line x1={s} y1={RULER - 5} x2={s} y2={RULER} stroke={tickColor} strokeWidth={1} />
840
- <text x={s + 2} y={9} fill={textColor} style={labelStyle}>{v}</text>
871
+ {hTicks.map(({ k, s, rank }) => (
872
+ <g key={k}>
873
+ <line x1={s} y1={RULER - LEN[rank]} x2={s} y2={RULER} stroke={tickColor[rank]} strokeWidth={1} />
874
+ {rank === 0 && <text x={s + 3} y={10} fill={textColor} style={labelStyle}>{label(k)}</text>}
841
875
  </g>
842
876
  ))}
843
877
  <line x1={0} y1={RULER - 0.5} x2="100%" y2={RULER - 0.5} stroke={borderColor} strokeWidth={1} />
878
+ <line ref={hPointer} x1={0.5} y1={0} x2={0.5} y2={RULER} stroke={textColor} strokeWidth={1} visibility="hidden" />
844
879
  </svg>
845
880
  <svg width={RULER} height="100%"
846
881
  onPointerDown={startGuideDrag('v')}
847
882
  style={{ position: 'absolute', top: 0, left: 0, zIndex: 4, cursor: 'col-resize' }}>
848
- <rect x={0} y={0} width={RULER} height="100%" fill={barBg} />
849
- {vTicks.map(({ v, s }) => (
850
- <g key={v}>
851
- <line x1={RULER - 5} y1={s} x2={RULER} y2={s} stroke={tickColor} strokeWidth={1} />
852
- <text x={9} y={s - 2} fill={textColor} style={labelStyle}
853
- transform={`rotate(-90 9 ${s - 2})`}>{v}</text>
883
+ {vTicks.map(({ k, s, rank }) => (
884
+ <g key={k}>
885
+ <line x1={RULER - LEN[rank]} y1={s} x2={RULER} y2={s} stroke={tickColor[rank]} strokeWidth={1} />
886
+ {rank === 0 && <text x={10} y={s - 3} fill={textColor} style={labelStyle}
887
+ transform={`rotate(-90 10 ${s - 3})`}>{label(k)}</text>}
854
888
  </g>
855
889
  ))}
856
890
  <line x1={RULER - 0.5} y1={0} x2={RULER - 0.5} y2="100%" stroke={borderColor} strokeWidth={1} />
891
+ <line ref={vPointer} x1={0} y1={0.5} x2={RULER} y2={0.5} stroke={textColor} strokeWidth={1} visibility="hidden" />
857
892
  </svg>
858
- <div style={{ position: 'absolute', top: 0, left: 0, width: RULER, height: RULER, background: barBg, borderRight: `1px solid ${borderColor}`, borderBottom: `1px solid ${borderColor}`, zIndex: 4, pointerEvents: 'none' }} />
893
+ <div style={{ position: 'absolute', top: 0, left: 0, width: RULER, height: RULER, borderRight: `1px solid ${borderColor}`, borderBottom: `1px solid ${borderColor}`, zIndex: 4, pointerEvents: 'none', display: 'flex', alignItems: 'center', justifyContent: 'center', color: textColor, ...labelStyle }}>px</div>
859
894
  </>
860
895
  )
861
896
  }
@@ -337,6 +337,7 @@ export function MediaLibraryProvider({
337
337
 
338
338
  const value = useMemo(() => {
339
339
  const annotated = objects.map((o) => ({ ...o, kind: kindOf(o) }))
340
+ const storageOf = new Map(objects.filter((o) => o.storageKey).map((o) => [o.key, o.storageKey]))
340
341
  const scoped = prefix ? annotated.filter((o) => o.key.startsWith(prefix)) : annotated
341
342
  const folders = foldersUnder(scoped, prefix)
342
343
  /* level = the direct children; flat = every object under the prefix */
@@ -415,7 +416,9 @@ export function MediaLibraryProvider({
415
416
  bucket,
416
417
  buckets,
417
418
  setBucket,
418
- mediaUrl: client?.mediaUrl ? (key) => client.mediaUrl(key, bucket ?? undefined) : (key) => key,
419
+ /* a PATH resolves to the row's `storageKey` — the object never moves, rename and move edit
420
+ * the row (MediaLibraryUrlOnStorageKey, kol-website 2026-10-13); no `storageKey`, the path */
421
+ mediaUrl: client?.mediaUrl ? (key) => client.mediaUrl(storageOf.get(key) ?? key, bucket ?? undefined) : (key) => key,
419
422
  proxied: client?.proxied ?? ((url) => url),
420
423
  }
421
424
  }, [objects, prefix, flat, sort, search, kinds, paging, pageSize, loading, error, accept, client, bucket, buckets])
@@ -1081,7 +1084,7 @@ function PickerBrowse({ client, accept, onClose, onSelect, title = 'MEDIA', ...b
1081
1084
  const [file, setFile] = useState(null)
1082
1085
  const ok = !!file && acceptsKind(accept)({ ...file, kind: kindOf(file) })
1083
1086
  const use = () => {
1084
- onSelect?.(client.mediaUrl(file.key, bucket ?? undefined), { contentType: file.contentType, kind: kindOf(file) })
1087
+ onSelect?.(client.mediaUrl(file.storageKey ?? file.key, bucket ?? undefined), { contentType: file.contentType, kind: kindOf(file) })
1085
1088
  onClose?.()
1086
1089
  }
1087
1090
  return (
@@ -244,7 +244,10 @@ function useBucketLibrary({ client, bucket, defaults, settings: controlled, onSe
244
244
  const folderInfo = loaded.folders ?? {}
245
245
  const setFolderInfo = (fn) => setLoaded((prev) => ({ ...prev, folders: fn(prev.folders ?? {}) }))
246
246
  const error = ready ? loaded.error : null
247
- const mediaUrl = (key) => client?.mediaUrl?.(key, bucketId ?? undefined) ?? key
247
+ /* a PATH resolves to the row's `storageKey` — the object never moves, rename and move edit the
248
+ * row (MediaLibraryUrlOnStorageKey, kol-website 2026-10-13); no `storageKey`, the path */
249
+ const storageOf = useMemo(() => new Map(objects.filter((o) => o.storageKey).map((o) => [o.key, o.storageKey])), [objects])
250
+ const mediaUrl = (key) => client?.mediaUrl?.(storageOf.get(key) ?? key, bucketId ?? undefined) ?? key
248
251
  const downloadUrl = (key) => client?.downloadUrl?.(key, bucketId ?? undefined) ?? mediaUrl(key)
249
252
  const writable = !!bucketMeta.writable && !!(client?.deleteObject || client?.renameObject)
250
253
  /* A CLIENT WITH NO `mediaUrl` HAS NO URLS (kol-fxr 2026-10-08: a stored preset is not a fetchable
@@ -28,6 +28,7 @@ import { Tooltip } from '../utilities/Popover.jsx'
28
28
  * @param {string} props.activeId - The armed tool's id — a `tool` item's, or any variant's of a tool fold
29
29
  * @param {Function} props.onSelect - (id) => void — a tool (or a tool variant) was armed
30
30
  * @param {Function} props.onAction - (id) => void — an action (or an action variant) was run
31
+ * @param {'horizontal'|'vertical'} props.orientation - A row (default), or a one-button-wide strip: hairline dividers across it, folds opening to its right (ToolPaletteVertical, kol-fxr 2026-10-13)
31
32
  * @param {'xs'|'sm'|'md'|'lg'} props.size - The rung — 22 · 26 · 32 · 40 (default: 'md', the source's 32)
32
33
  * @param {ElementType} props.iconComponent - Glyph renderer receiving `{ name, size, className, style }` (default: DS `Icon`)
33
34
  * @param {string} props.className - Additional classes on the row
@@ -39,13 +40,18 @@ const ToolPalette = ({
39
40
  activeId,
40
41
  onSelect,
41
42
  onAction,
43
+ orientation = 'horizontal',
42
44
  size = 'md',
43
45
  iconComponent = Icon,
44
46
  className = '',
45
- }) => (
46
- <div className={`kol-tool-palette flex items-center gap-1 min-w-0 overflow-x-auto ${className}`.trim()}>
47
+ }) => {
48
+ const vertical = orientation === 'vertical'
49
+ return (
50
+ <div className={`kol-tool-palette flex items-center gap-1 ${vertical ? 'flex-col min-h-0 overflow-y-auto' : 'min-w-0 overflow-x-auto'} ${className}`.trim()}>
47
51
  {items.map((it, i) => {
48
- if (it.kind === 'divider') return <Divider key={`d${i}`} variant="vertical" height={20} className="mx-1.5 shrink-0" />
52
+ if (it.kind === 'divider') return vertical
53
+ ? <Divider key={`d${i}`} variant="horizontal" className="my-1.5 shrink-0 self-stretch" />
54
+ : <Divider key={`d${i}`} variant="vertical" height={20} className="mx-1.5 shrink-0" />
49
55
  if (it.kind === 'split') {
50
56
  const variants = (it.variants ?? []).map((v) => (v.action && !it.action ? { ...v, onSelect: () => onAction?.(v.id) } : v))
51
57
  const run = (id) => (it.action ? onAction : onSelect)?.(id)
@@ -53,7 +59,8 @@ const ToolPalette = ({
53
59
  <SplitToolButton key={it.id} variants={variants} value={activeId} size={size} iconComponent={iconComponent}
54
60
  active={!it.action && variants.some((v) => v.id === activeId && !v.action)}
55
61
  onChange={run} onTrigger={it.action ? run : undefined}
56
- disabled={it.disabled} blurOnClick aria-label={it.label} />
62
+ disabled={it.disabled} blurOnClick aria-label={it.label}
63
+ placement={vertical ? 'right-start' : undefined} />
57
64
  )
58
65
  }
59
66
  const isTool = it.kind === 'tool'
@@ -68,6 +75,7 @@ const ToolPalette = ({
68
75
  )
69
76
  })}
70
77
  </div>
71
- )
78
+ )
79
+ }
72
80
 
73
81
  export default ToolPalette