@kolkrabbi/kol-component 0.378.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.
Files changed (79) hide show
  1. package/package.json +4 -3
  2. package/src/atoms/BezierPathEditor.jsx +1 -1
  3. package/src/atoms/Button.jsx +84 -1
  4. package/src/atoms/Figure.jsx +19 -1
  5. package/src/atoms/FunctionPlot.jsx +1 -1
  6. package/src/atoms/Input.jsx +105 -1
  7. package/src/atoms/Kbd.jsx +42 -2
  8. package/src/atoms/Link.jsx +20 -0
  9. package/src/atoms/OriginPicker.jsx +9 -5
  10. package/src/atoms/SectionFooter.jsx +22 -0
  11. package/src/atoms/SectionHeader.jsx +24 -0
  12. package/src/atoms/SizeOrDownload.jsx +1 -1
  13. package/src/atoms/Textarea.jsx +11 -2
  14. package/src/atoms/ToggleCheckbox.jsx +23 -1
  15. package/src/atoms/ToggleSwitch.jsx +39 -0
  16. package/src/atoms/ViewToggle.jsx +2 -2
  17. package/src/atoms/XYPad.jsx +25 -0
  18. package/src/hooks/useDragResize.js +1 -1
  19. package/src/index.js +26 -3
  20. package/src/molecules/AccountMenu.jsx +14 -1
  21. package/src/molecules/AlignmentGrid.jsx +13 -1
  22. package/src/molecules/ButtonGroup.jsx +73 -1
  23. package/src/molecules/ButtonSplit.jsx +64 -3
  24. package/src/molecules/Chip.jsx +26 -0
  25. package/src/molecules/CodeBlock.jsx +39 -2
  26. package/src/molecules/ColorInputRow.jsx +125 -4
  27. package/src/molecules/ColorSwatch.jsx +43 -2
  28. package/src/molecules/ContentCard.jsx +104 -3
  29. package/src/molecules/ContentMedia.jsx +1 -1
  30. package/src/molecules/ContentRow.jsx +3 -3
  31. package/src/molecules/DividerLabel.jsx +19 -0
  32. package/src/molecules/Dropdown.jsx +111 -1
  33. package/src/molecules/DropdownStepper.jsx +29 -0
  34. package/src/molecules/FieldPair.jsx +41 -2
  35. package/src/molecules/LabeledControl.jsx +51 -0
  36. package/src/molecules/Menu.jsx +239 -3
  37. package/src/molecules/Modal.jsx +214 -9
  38. package/src/molecules/ModalShell.jsx +18 -5
  39. package/src/molecules/OptionRow.jsx +1 -1
  40. package/src/molecules/ParamBindDot.jsx +29 -2
  41. package/src/molecules/QuantityInput.jsx +48 -0
  42. package/src/molecules/RailHeader.jsx +32 -2
  43. package/src/molecules/SectionText.jsx +54 -1
  44. package/src/molecules/Slider.jsx +101 -2
  45. package/src/molecules/SplitToolButton.jsx +4 -6
  46. package/src/molecules/SwatchControls.jsx +28 -0
  47. package/src/molecules/SwatchGrid.jsx +39 -0
  48. package/src/molecules/TabsDocument.jsx +131 -0
  49. package/src/molecules/TabsRow.jsx +35 -1
  50. package/src/molecules/Toast.jsx +55 -0
  51. package/src/molecules/TreeRow.jsx +87 -1
  52. package/src/organisms/AppItemMenuProvider.jsx +2 -2
  53. package/src/organisms/ColorPickerPopover.jsx +133 -4
  54. package/src/organisms/ColumnBrowser.jsx +1 -1
  55. package/src/organisms/CommandOverlay.jsx +396 -21
  56. package/src/organisms/FindBar.jsx +70 -0
  57. package/src/organisms/FramedMediaBand.jsx +2 -2
  58. package/src/organisms/GalleryCarousel.jsx +1 -1
  59. package/src/organisms/LogoSystem.jsx +38 -0
  60. package/src/organisms/LogoTuner.jsx +32 -0
  61. package/src/organisms/MediaLibrary.jsx +1 -1
  62. package/src/organisms/MediaLibraryPages.jsx +1 -1
  63. package/src/organisms/Rail.jsx +33 -1
  64. package/src/organisms/RailSwitcher.jsx +62 -0
  65. package/src/organisms/ReadingContents.jsx +63 -1
  66. package/src/organisms/SectionSplit.jsx +1 -1
  67. package/src/organisms/SettingsPanel.jsx +45 -1
  68. package/src/organisms/ShortcutsOverlay.jsx +46 -2
  69. package/src/organisms/SpectrumControls.jsx +112 -19
  70. package/src/organisms/StatusBar.jsx +30 -0
  71. package/src/organisms/Table.jsx +141 -2
  72. package/src/organisms/TimelineDock.jsx +281 -1
  73. package/src/organisms/logoBoard.jsx +61 -0
  74. package/src/utilities/AssetPlaceholder.jsx +1 -1
  75. package/src/utilities/EditorShell.jsx +42 -1
  76. package/src/utilities/OverlayGlassPanel.jsx +1 -1
  77. package/src/utilities/Popover.jsx +298 -2
  78. package/src/utilities/SelectionOverlay.jsx +74 -1
  79. package/src/utilities/kolboxGlyph.jsx +10 -0
@@ -40,7 +40,8 @@ const HANDLE_R = 7
40
40
  const HUE_GRADIENT =
41
41
  '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
42
 
43
- /**
43
+ /* (the default look; the exported HueStrip below picks the look)
44
+ *
44
45
  * HueStrip — A hue slider. 1D hue slider: a rainbow bar with a draggable knob. Pointer
45
46
  * drag anywhere on the strip; focus + Left/Right (or Down/Up) arrow keys
46
47
  * nudge hue by 1° (role="slider").
@@ -48,7 +49,7 @@ const HUE_GRADIENT =
48
49
  * @param {number} hue controlled hue, 0–360
49
50
  * @param {Function} onChange (hue: number) => void — fires on press, drag, and arrow keys
50
51
  */
51
- export function HueStrip({ hue, onChange }) {
52
+ function HueStripDefault({ hue, onChange }) {
52
53
  const ref = useRef(null)
53
54
  const dragging = useRef(false)
54
55
 
@@ -103,7 +104,7 @@ export function HueStrip({ hue, onChange }) {
103
104
  aria-valuenow={Math.round(hue)}
104
105
  onPointerDown={onDown}
105
106
  onKeyDown={onKeyDown}
106
- className="relative rounded-[var(--kol-radius-xs)] cursor-pointer touch-none"
107
+ className="relative rounded-[var(--kol-radius-2)] cursor-pointer touch-none"
107
108
  style={{ height: 12, background: HUE_GRADIENT }}
108
109
  >
109
110
  {/* Handle positions inside an inset region so 0..100% maps to the
@@ -118,7 +119,8 @@ export function HueStrip({ hue, onChange }) {
118
119
  /* the transparency checker behind an alpha ramp — literal greys, like the spectra (not themeable) */
119
120
  const CHECKER = 'repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0 0 / 8px 8px'
120
121
 
121
- /**
122
+ /* (the default look; the exported AlphaStrip below picks the look)
123
+ *
122
124
  * AlphaStrip — An opacity slider. HueStrip's twin for alpha: the colour ramped from transparent to
123
125
  * opaque over a checker, same knob, same inset (ColorPickerPopover, kol-monitor 2026-10-17). Focus +
124
126
  * Left/Right (or Down/Up) nudge alpha by 1% (role="slider").
@@ -127,7 +129,7 @@ const CHECKER = 'repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0 0 / 8px 8p
127
129
  * @param {string} color the opaque colour the ramp ends on (any CSS colour)
128
130
  * @param {Function} onChange (alpha: number) => void — fires on press, drag, and arrow keys
129
131
  */
130
- export function AlphaStrip({ alpha, color, onChange }) {
132
+ function AlphaStripDefault({ alpha, color, onChange }) {
131
133
  const ref = useRef(null)
132
134
  const dragging = useRef(false)
133
135
 
@@ -173,7 +175,7 @@ export function AlphaStrip({ alpha, color, onChange }) {
173
175
  aria-valuenow={Math.round(alpha * 100)}
174
176
  onPointerDown={(e) => { dragging.current = true; update(e.clientX); e.preventDefault() }}
175
177
  onKeyDown={onKeyDown}
176
- className="relative rounded-[var(--kol-radius-xs)] cursor-pointer touch-none"
178
+ className="relative rounded-[var(--kol-radius-2)] cursor-pointer touch-none"
177
179
  style={{ height: 12, background: `linear-gradient(to right, transparent, ${color}), ${CHECKER}` }}
178
180
  >
179
181
  <div className="absolute inset-y-0" style={{ left: HANDLE_R, right: HANDLE_R }}>
@@ -183,10 +185,11 @@ export function AlphaStrip({ alpha, color, onChange }) {
183
185
  )
184
186
  }
185
187
 
186
- /**
188
+ /* (the default look; the exported SBSquare below picks the look)
189
+ *
187
190
  * SBSquare — Pick saturation and value on a square. 2D saturation/value picker: white→hue horizontal gradient with
188
191
  * a black overlay fading upward, crosshair handle. Fills its container
189
- * (consumer owns the size — and the rounding: apply `rounded-[var(--kol-radius-xs)]
192
+ * (consumer owns the size — and the rounding: apply `rounded-[var(--kol-radius-2)]
190
193
  * overflow-hidden` on the wrapper). Focus + arrow keys nudge: Left/Right =
191
194
  * saturation ±1, Up/Down = value ±1 (role="slider").
192
195
  *
@@ -195,7 +198,7 @@ export function AlphaStrip({ alpha, color, onChange }) {
195
198
  * @param {number} val controlled value/brightness, 0–100
196
199
  * @param {Function} onChange (sat: number, val: number) => void
197
200
  */
198
- export function SBSquare({ hue, sat, val, onChange }) {
201
+ function SBSquareDefault({ hue, sat, val, onChange }) {
199
202
  const ref = useRef(null)
200
203
  const dragging = useRef(false)
201
204
 
@@ -242,7 +245,7 @@ export function SBSquare({ hue, sat, val, onChange }) {
242
245
 
243
246
  const sb = `linear-gradient(to bottom, transparent 0%, #000 100%), linear-gradient(to right, #fff 0%, hsl(${hue},100%,50%) 100%)`
244
247
  /* Gradient field is rectangular — rounding is the consumer's job (apply
245
- * `rounded-[var(--kol-radius-xs)] overflow-hidden` on the wrapper). Putting border-radius
248
+ * `rounded-[var(--kol-radius-2)] overflow-hidden` on the wrapper). Putting border-radius
246
249
  * on the gradient itself produces tiny antialiasing artifacts at the
247
250
  * corners; clipping via overflow-hidden on the parent is cleaner. */
248
251
  return (
@@ -313,8 +316,13 @@ function vertexAt(angleRad) {
313
316
  * @param {number} val controlled value/brightness, 0–100
314
317
  * @param {Function} onChangeHue (hue: number) => void — ring drag / hue arrow keys
315
318
  * @param {Function} onChangeSV (sat: number, val: number) => void — triangle drag / value arrow keys
319
+ * @param {'default'|'kolbox'} [variant='default'] `kolbox` (kolbox's ColorWheel, plan-2026-11-18-kolbox-system W31.2,
320
+ * 2026-11-18): the same wheel, its handles a ring in the ink over a hairline of the ground (so it reads on the
321
+ * triangle's white corner) and a round focus ring in the accent, 2 out. Chrome in kol-theme `.kol-wheel-triangle--kolbox`.
322
+ * @param {string} [className] extra classes on the wrapper
316
323
  */
317
- export function WheelTriangle({ hue, sat, val, onChangeHue, onChangeSV }) {
324
+ export function WheelTriangle({ hue, sat, val, onChangeHue, onChangeSV, variant = 'default', className = '' }) {
325
+ const kolbox = variant === 'kolbox'
318
326
  const svgRef = useRef(null)
319
327
  const dragMode = useRef(null) /* { type: 'ring' } | { type: 'tri', offsetX, offsetY } | null */
320
328
 
@@ -459,7 +467,9 @@ export function WheelTriangle({ hue, sat, val, onChangeHue, onChangeSV }) {
459
467
  aria-valuenow={Math.round(hue)}
460
468
  aria-valuetext={`Hue ${Math.round(hue)} degrees, saturation ${Math.round(sat)}%, brightness ${Math.round(val)}%`}
461
469
  onKeyDown={onKeyDown}
462
- className="aspect-square max-h-full max-w-full"
470
+ className={kolbox
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()}
463
473
  >
464
474
  <svg
465
475
  ref={svgRef}
@@ -509,8 +519,8 @@ export function WheelTriangle({ hue, sat, val, onChangeHue, onChangeSV }) {
509
519
  <polygon points={trianglePoints} fill={`url(#${blackFadeId})`} />
510
520
 
511
521
  {/* Handles. Ring handle is larger than the SV handle to match the Ref. */}
512
- <SvgHandle cx={ringHx} cy={ringHy} r={3.2} />
513
- <SvgHandle cx={handleX} cy={handleY} r={2.0} />
522
+ <SvgHandle cx={ringHx} cy={ringHy} r={3.2} kolbox={kolbox} />
523
+ <SvgHandle cx={handleX} cy={handleY} r={2.0} kolbox={kolbox} />
514
524
  </svg>
515
525
  </div>
516
526
  )
@@ -536,11 +546,12 @@ function Handle({ left, top }) {
536
546
 
537
547
  /* SVG handle for WheelTriangle. Two concentric circles to stay sharp at any
538
548
  * zoom — outer black halo + white outline. */
539
- function SvgHandle({ cx, cy, r = 2.4 }) {
549
+ function SvgHandle({ cx, cy, r = 2.4, kolbox = false }) {
550
+ /* kolbox: the ring in the ink over a hairline of the ground (the theme's `.kol-wheel-triangle--kolbox` strokes) */
540
551
  return (
541
552
  <g pointerEvents="none">
542
- <circle cx={cx} cy={cy} r={r + 0.5} fill="none" stroke="#000" strokeOpacity="0.7" strokeWidth="0.5" />
543
- <circle cx={cx} cy={cy} r={r} fill="none" stroke="#FFF" strokeWidth="1.4" />
553
+ <circle cx={cx} cy={cy} r={r + 0.5} fill="none" stroke={kolbox ? undefined : '#000'} className={kolbox ? 'kol-wheel-triangle-halo' : undefined} strokeOpacity="0.7" strokeWidth="0.5" />
554
+ <circle cx={cx} cy={cy} r={r} fill="none" stroke={kolbox ? undefined : '#FFF'} className={kolbox ? 'kol-wheel-triangle-ring' : undefined} strokeWidth="1.4" />
544
555
  </g>
545
556
  )
546
557
  }
@@ -548,7 +559,7 @@ function SvgHandle({ cx, cy, r = 2.4 }) {
548
559
  /**
549
560
  * SpectrumControls — A hue strip over a saturation square. The composed classic square picker: HueStrip stacked
550
561
  * over a fill-height SBSquare, per the source color panel's Hue mode layout
551
- * (SBSquare wrapped in `rounded-[var(--kol-radius-xs)] overflow-hidden`, see its comment).
562
+ * (SBSquare wrapped in `rounded-[var(--kol-radius-2)] overflow-hidden`, see its comment).
552
563
  * Fills its container — the consumer owns the outer size. For the ring
553
564
  * picker, use WheelTriangle directly; the primitives are also exported for
554
565
  * custom layouts.
@@ -564,9 +575,91 @@ export default function SpectrumControls({ value, onChange }) {
564
575
  return (
565
576
  <div className="flex flex-col gap-3 w-full h-full min-h-0">
566
577
  <HueStrip hue={hue} onChange={(h) => onChange({ hue: h, sat, val })} />
567
- <div className="flex-1 min-h-0 rounded-[var(--kol-radius-xs)] overflow-hidden">
578
+ <div className="flex-1 min-h-0 rounded-[var(--kol-radius-2)] overflow-hidden">
568
579
  <SBSquare hue={hue} sat={sat} val={val} onChange={(s, v) => onChange({ hue, sat: s, val: v })} />
569
580
  </div>
570
581
  </div>
571
582
  )
572
583
  }
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
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * StatusBar — a document's status along its foot (Folio's StatusBar, 2026-11-22): the counts on the left, the host's
3
+ * cells on the right (the format, the language, the zoom, the encoding). It holds no state; the cells are the host's.
4
+ * Spaces in `left` are kept (Folio spaces its counts with them). Chrome in kol-theme `.kol-status-bar--kolbox` and
5
+ * `.kol-status-bar--folio`.
6
+ *
7
+ * <StatusBar left="212 words 1,204 characters 18 lines">
8
+ * <Dropdown variant="kolbox" ... /><span>UTF-8 LF</span>
9
+ * </StatusBar>
10
+ *
11
+ * @param {'kolbox'|'folio'} [variant='kolbox'] - kolbox: 32 high on the rail ground, the kolbox line over it, the text
12
+ * kolbox's help voice (11 / 15), the counts in oq-64. folio: Folio's bar carried class for class (40, its rule, meta).
13
+ * @param {ReactNode} [left] - The text on the left
14
+ * @param {ReactNode} [children] - The right-hand cells, 16 apart (folio 24)
15
+ * @param {string} [className] - Extra classes on the bar
16
+ */
17
+ export default function StatusBar({ variant = 'kolbox', left, children, className = '' }) {
18
+ if (variant === 'folio') return (
19
+ <div className={`kol-status-bar--folio flex h-[40px] shrink-0 items-center justify-between gap-[24px] whitespace-pre border-t px-[56px] ${className}`.trim()}>
20
+ <p className="kol-status-bar-left">{left}</p>
21
+ <div className="flex items-center gap-[24px]">{children}</div>
22
+ </div>
23
+ )
24
+ return (
25
+ <div className={`kol-status-bar--kolbox kol-kolbox-help flex h-8 shrink-0 items-center justify-between gap-4 whitespace-pre border-t pr-2 pl-3 ${className}`.trim()}>
26
+ <p className="kol-status-bar-left min-w-0 overflow-hidden text-ellipsis">{left}</p>
27
+ <div className="flex shrink-0 items-center gap-4">{children}</div>
28
+ </div>
29
+ )
30
+ }
@@ -1,6 +1,10 @@
1
- import { useMemo, useState } from 'react'
1
+ import { Fragment, useMemo, useState } from 'react'
2
2
  import { IconLoader } from '@kolkrabbi/kol-icons'
3
3
  import { INDICATOR } from '../hooks/glyphLadders.js'
4
+ import Button from '../atoms/Button.jsx'
5
+ import { Tooltip } from '../utilities/Popover.jsx'
6
+ import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
7
+ import { fileAgo } from '../molecules/ContentCard.jsx'
4
8
 
5
9
  /**
6
10
  * Table — data table.
@@ -42,7 +46,7 @@ const WIDTHS = {
42
46
  column: '',
43
47
  }
44
48
 
45
- const Table = ({ caption, columns, rows, variant = 'default', className = '', width = 'panel', rowClassName, compact = false, lastRule = false, framed = false }) => {
49
+ const TableDefault = ({ caption, columns, rows, variant = 'default', className = '', width = 'panel', rowClassName, compact = false, lastRule = false, framed = false }) => {
46
50
  const [sort, setSort] = useState({ key: null, dir: null })
47
51
 
48
52
  const cycle = (key) =>
@@ -162,4 +166,139 @@ function FloatTable({ caption, columns, rows, sort, cycle, framed, rowClassName,
162
166
  )
163
167
  }
164
168
 
169
+
170
+ /* ── kolbox (plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18) ─────────────────────────────────────────────────
171
+ * kolbox's FileList with its FileListHeader and FileListRow (Figma `FileList`), carried from apps/kolbox/src/home: 20
172
+ * under the title row, the head row (39), then one row per file, 48 high, touching. Opens on a double click or Enter.
173
+ * Table's words: `rows` (the files: { id, name, modified, created, size }), `sort` ('modified' | 'created' | 'name'; the
174
+ * sorted column's name in the ink with its arrow). kolbox's own: `onOpen(file)`; `onSettings(file)`, `onRemove(file)`
175
+ * (the cog and the trash; with either, the Size column and the actions gutter), `onMenu(file, event)` (right click).
176
+ * Columns (Figma's file list, measured: plan-2026-11-23 W6): the star's 33, Name at half the row, then Last modified,
177
+ * Created and Active in file (and Size) sharing the rest; the head 39, the cells full height; the row inset 32 at the
178
+ * right as a margin, so its hover ends there; under 768 Created and Active in file give way. `onStar(file)`: the star, lit while
179
+ * `file.starred`; absent, the column is empty. `file.icon` names the name's glyph (default `file`). */
180
+ const FILE_COLS_KOLBOX = 'grid grid-cols-[33px_50%_repeat(3,minmax(0,1fr))] mr-8 max-md:grid-cols-[33px_minmax(0,1fr)_104px] max-md:mr-4'
181
+ const FILE_COLS_ACTIONS_KOLBOX = 'grid grid-cols-[33px_50%_repeat(4,minmax(0,1fr))_64px] mr-8 max-md:grid-cols-[33px_minmax(0,1fr)_104px_64px_64px] max-md:mr-4'
182
+ const PHONE_HIDDEN_KOLBOX = 'max-md:hidden'
183
+
184
+ function TableHeadKolbox({ sort, actions = false }) {
185
+ const col = (key, label, pad = 'pl-2', hide = '') => (
186
+ <span role="columnheader" className={`flex items-center gap-1 whitespace-nowrap ${pad} ${sort === key ? 'is-sorted' : ''} ${hide}`}>
187
+ {label}{sort === key && <KolboxGlyph name="arrow-down" size={12} />}
188
+ </span>
189
+ )
190
+ return (
191
+ <div role="row" className={`kol-table-head ${actions ? FILE_COLS_ACTIONS_KOLBOX : FILE_COLS_KOLBOX} h-[39px] shrink-0`} data-file-list-header>
192
+ <span role="columnheader" aria-label="Star" className="self-center" />
193
+ {col('name', 'Name', '')}
194
+ {col('modified', 'Last modified')}
195
+ {col('created', 'Created', 'pl-2', PHONE_HIDDEN_KOLBOX)}
196
+ {col('active', 'Active in file', 'pl-2', PHONE_HIDDEN_KOLBOX)}
197
+ {actions && col('size', 'Size')}
198
+ {actions && <span role="columnheader" aria-label="Actions" />}
199
+ </div>
200
+ )
201
+ }
202
+
203
+ function TableRowKolbox({ file, onOpen, actions = false, onStar, onSettings, onRemove, onMenu }) {
204
+ const stop = (fn) => (e) => { e.stopPropagation(); fn(file, e) }
205
+ return (
206
+ <div
207
+ role="row"
208
+ tabIndex={0}
209
+ aria-label={file.name}
210
+ onDoubleClick={() => onOpen?.(file)}
211
+ onKeyDown={(e) => { if (e.key === 'Enter' && e.target === e.currentTarget) onOpen?.(file) }}
212
+ onContextMenu={onMenu ? (e) => { e.preventDefault(); onMenu(file, e) } : undefined}
213
+ className={`kol-table-row ${actions ? FILE_COLS_ACTIONS_KOLBOX : FILE_COLS_KOLBOX} h-12 shrink-0 cursor-default outline-none`}
214
+ data-file-row={file.id}
215
+ >
216
+ <span role="cell" className="flex items-center justify-center">
217
+ {onStar && <Tooltip variant="kolbox" label={file.starred ? 'Unstar' : 'Star'}><Button variant="kolbox" iconOnly="star" aria-label="Star" pressed={!!file.starred} onClick={stop(onStar)} onDoubleClick={(e) => e.stopPropagation()} /></Tooltip>}
218
+ </span>
219
+ <span role="cell" className="flex min-w-0 items-center gap-3 pl-2">
220
+ <KolboxGlyph name={file.icon ?? 'file'} className="kol-table-icon" />
221
+ <span className="kol-table-name truncate">{file.name}</span>
222
+ </span>
223
+ <span role="cell" className="flex min-w-0 items-center pl-2"><span className="truncate">{fileAgo(file.modified)}</span></span>
224
+ <span role="cell" className={`flex min-w-0 items-center pl-2 ${PHONE_HIDDEN_KOLBOX}`}><span className="truncate">{fileAgo(file.created)}</span></span>
225
+ <span role="cell" className={PHONE_HIDDEN_KOLBOX} />
226
+ {actions && <span role="cell" className="kol-table-size flex items-center pl-2">{file.size}</span>}
227
+ {actions && (
228
+ <span role="cell" className="flex items-center justify-end" onDoubleClick={(e) => e.stopPropagation()}>
229
+ {onSettings && <Tooltip variant="kolbox" label="Settings"><Button variant="kolbox" iconOnly="settings-01" aria-label="Settings" onClick={stop(onSettings)} /></Tooltip>}
230
+ {onRemove && <Tooltip variant="kolbox" label="Delete"><Button variant="kolbox" iconOnly="trash" aria-label="Delete" onClick={stop(onRemove)} /></Tooltip>}
231
+ </span>
232
+ )}
233
+ </div>
234
+ )
235
+ }
236
+
237
+ /* Folio on kolbox (2026-11-22): `columns` ({ header, width?, phone?, render(row) }, Table folio's words) draws the
238
+ caller's own columns in kolbox's head and rows: the same 40 head and 48 rows, the 33 gutter and the 32 inset, a column
239
+ with no `width` taking the rest, `phone: false` giving way under 768. `rowKey(row)` keys a row (default `row.id`).
240
+ Without `columns` the file list draws as before. */
241
+ function TableKolboxColumns({ columns, rows, rowKey = (r) => r.id, onOpen, className }) {
242
+ const track = (list) => ['33px', ...list.map((c) => (c.width ? `${c.width}px` : 'minmax(0,1fr)'))].join(' ')
243
+ const phone = columns.filter((c) => c.phone !== false)
244
+ const grid = 'grid grid-cols-(--kol-table-cols) gap-x-2 pr-8 max-md:grid-cols-(--kol-table-cols-phone) max-md:pr-4'
245
+ const hide = (c) => (c.phone === false ? 'max-md:hidden' : '')
246
+ return (
247
+ <div role="table" className={`kol-table--kolbox min-h-0 flex-1 overflow-y-auto pt-5 max-md:flex-none max-md:overflow-visible ${className}`.trim()} style={{ '--kol-table-cols': track(columns), '--kol-table-cols-phone': track(phone) }} data-file-list>
248
+ <div role="row" className={`kol-table-head ${grid} h-10 shrink-0 items-center`} data-file-list-header>
249
+ <span role="columnheader" aria-hidden />
250
+ {columns.map((c, i) => <span key={i} role="columnheader" className={`truncate ${hide(c)}`}>{c.header}</span>)}
251
+ </div>
252
+ {rows.map((row) => (
253
+ <div key={rowKey(row)} role="row" tabIndex={0} onDoubleClick={() => onOpen?.(row)} onKeyDown={(e) => { if (e.key === 'Enter' && e.target === e.currentTarget) onOpen?.(row) }}
254
+ className={`kol-table-row ${grid} h-12 shrink-0 cursor-default items-center outline-none`} data-file-row={rowKey(row)}>
255
+ <span role="cell" aria-hidden />
256
+ {columns.map((c, i) => <span key={i} role="cell" className={`flex min-w-0 items-center ${hide(c)}`}>{c.render(row)}</span>)}
257
+ </div>
258
+ ))}
259
+ </div>
260
+ )
261
+ }
262
+
263
+ function TableKolbox({ rows = [], sort, columns, rowKey, onOpen, onStar, onSettings, onRemove, onMenu, className = '' }) {
264
+ if (columns) return <TableKolboxColumns columns={columns} rows={rows} rowKey={rowKey} onOpen={onOpen} className={className} />
265
+ const actions = !!(onSettings || onRemove)
266
+ return (
267
+ <div role="table" className={`kol-table--kolbox min-h-0 flex-1 overflow-y-auto pt-5 max-md:flex-none max-md:overflow-visible max-md:pb-28 ${className}`.trim()} data-file-list>
268
+ <TableHeadKolbox sort={sort} actions={actions} />
269
+ {rows.map((f) => <TableRowKolbox key={f.id} file={f} onOpen={onOpen} actions={actions} onStar={onStar} onSettings={onSettings} onRemove={onRemove} onMenu={onMenu} />)}
270
+ </div>
271
+ )
272
+ }
273
+
274
+ /* ── folio (Folio batch E, 2026-11-22) ─────────────────────────────────────────────────────────────────────────────
275
+ * Folio's table of books, carried from apps/folio's FolioShelf ("All books"): the head row 34 high in Folio's label
276
+ * type, muted, over a 2px rule in the ink; one row per book 70 high on a hairline, lit on hover, the whole row a link;
277
+ * columns 20 apart and a trailing arrow. Table's words: `columns` ({ header, width?, render(row) }: a column with no
278
+ * `width` takes the rest; `render` draws the whole cell, its own width with it) and `rows`. Folio's own: `rowKey(row)`,
279
+ * `rowHref(row)` with `linkComponent` (a router's Link; default `a`), and `empty` (the node drawn when there are no
280
+ * rows). */
281
+ function TableFolio({ columns = [], rows = [], rowKey = (r) => r.id, rowHref, linkComponent: L = 'a', empty, className = '' }) {
282
+ return (
283
+ <div className={`kol-table--folio flex flex-col ${className}`.trim()}>
284
+ <div className="kol-folio-label kol-table-head flex h-[34px] items-center gap-[20px] border-b-2">
285
+ {columns.map((c, i) => <p key={i} className={c.width ? 'shrink-0' : 'min-w-0 flex-1'} style={c.width ? { width: c.width } : undefined}>{c.header}</p>)}
286
+ <span className="w-[18px] shrink-0" />
287
+ </div>
288
+ {rows.map((row) => {
289
+ const href = rowHref?.(row)
290
+ return (
291
+ <L key={rowKey(row)} {...(L === 'a' ? { href } : { to: href })} className="kol-table-row group flex h-[70px] items-center gap-[20px] border-b">
292
+ {columns.map((c, i) => <Fragment key={i}>{c.render(row)}</Fragment>)}
293
+ <span className="kol-table-arrow shrink-0"><IconLoader name="arrow-right" size={18} /></span>
294
+ </L>
295
+ )
296
+ })}
297
+ {rows.length === 0 && empty}
298
+ </div>
299
+ )
300
+ }
301
+
302
+ const Table = (props) => (props.variant === 'folio' ? <TableFolio {...props} /> : props.variant === 'kolbox' ? <TableKolbox {...props} /> : <TableDefault {...props} />)
303
+
165
304
  export default Table