@kolkrabbi/kol-component 0.314.0 → 0.316.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.314.0",
3
+ "version": "0.316.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "embla-carousel-react": "^8.6.0",
27
27
  "pdfjs-dist": "^6.3.289",
28
28
  "react-syntax-highlighter": "^16.1.1",
29
- "@kolkrabbi/kol-markdown": "^0.2.0",
30
- "@kolkrabbi/kol-search": "^0.3.0"
29
+ "@kolkrabbi/kol-search": "^0.3.0",
30
+ "@kolkrabbi/kol-markdown": "^0.2.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@kolkrabbi/kol-icons": ">=0.22.0",
@@ -0,0 +1,25 @@
1
+ /**
2
+ * ProgressBar — How far along something is. A thin track and its fill, and a caption under it (record's project card:
3
+ * `3/7 done` — DocumentLibraryAndBoardParts, kol-website 2026-10-29). The fill takes the status tones the chips wear, or
4
+ * the ink when none is given.
5
+ *
6
+ * @param {number} value
7
+ * @param {number} max default 100
8
+ * @param {boolean|ReactNode|Function} caption `true` → `value/max`; a node; or `(value, max) => node`; omit for none
9
+ * @param {'success'|'warning'|'error'|'info'} tone the fill's colour (default the ink)
10
+ * @param {string} ariaLabel
11
+ */
12
+ const TONE = { success: 'var(--ui-success)', warning: 'var(--ui-warning)', error: 'var(--ui-error)', info: 'var(--ui-info)' }
13
+
14
+ export default function ProgressBar({ value = 0, max = 100, caption, tone, ariaLabel, className = '' }) {
15
+ const pct = max > 0 ? Math.max(0, Math.min(100, (value / max) * 100)) : 0
16
+ const text = caption === true ? `${value}/${max}` : typeof caption === 'function' ? caption(value, max) : caption
17
+ return (
18
+ <div className={`flex flex-col gap-1 ${className}`.trim()}>
19
+ <div role="progressbar" aria-valuenow={value} aria-valuemin={0} aria-valuemax={max} aria-label={ariaLabel} className="h-1 overflow-hidden rounded bg-fg-08">
20
+ <div className="h-full transition-[width] duration-300" style={{ width: `${pct}%`, background: TONE[tone] ?? 'var(--kol-fg-64)' }} />
21
+ </div>
22
+ {text != null && text !== false && <span className="kol-mono-10 text-meta">{text}</span>}
23
+ </div>
24
+ )
25
+ }
@@ -6,15 +6,23 @@ import { useEffect } from 'react'
6
6
  * box is scrolled, and `data-fade-bottom` while more lies below; kol-theme's `.kol-scroll-fade` draws the two fades from
7
7
  * them. Re-read on scroll and whenever the box or its content changes size. One rule for every vertically scrolling rail
8
8
  * or list that clips: the site rail, the app rail, the workshop's rails.
9
+ *
10
+ * `axis="x"` (TabsRowOverflow, kol-website 2026-10-29): the same for a row that scrolls sideways — `data-fade-left` once
11
+ * scrolled, `data-fade-right` while more lies to the right; `.kol-scroll-fade--x` draws them.
9
12
  */
10
- export default function useScrollFade(ref, enabled = true) {
13
+ export default function useScrollFade(ref, enabled = true, axis = 'y') {
11
14
  useEffect(() => {
12
15
  const el = ref.current
13
16
  if (!el || !enabled) return undefined
14
- const read = () => {
15
- el.toggleAttribute('data-fade-top', el.scrollTop > 1)
16
- el.toggleAttribute('data-fade-bottom', el.scrollTop + el.clientHeight < el.scrollHeight - 1)
17
- }
17
+ const read = axis === 'x'
18
+ ? () => {
19
+ el.toggleAttribute('data-fade-left', el.scrollLeft > 1)
20
+ el.toggleAttribute('data-fade-right', el.scrollLeft + el.clientWidth < el.scrollWidth - 1)
21
+ }
22
+ : () => {
23
+ el.toggleAttribute('data-fade-top', el.scrollTop > 1)
24
+ el.toggleAttribute('data-fade-bottom', el.scrollTop + el.clientHeight < el.scrollHeight - 1)
25
+ }
18
26
  read()
19
27
  el.addEventListener('scroll', read, { passive: true })
20
28
  const ro = new ResizeObserver(read)
@@ -26,8 +34,7 @@ export default function useScrollFade(ref, enabled = true) {
26
34
  el.removeEventListener('scroll', read)
27
35
  ro.disconnect()
28
36
  mo.disconnect()
29
- el.removeAttribute('data-fade-top')
30
- el.removeAttribute('data-fade-bottom')
37
+ for (const a of ['top', 'bottom', 'left', 'right']) el.removeAttribute(`data-fade-${a}`)
31
38
  }
32
- }, [ref, enabled])
39
+ }, [ref, enabled, axis])
33
40
  }
package/src/index.js CHANGED
@@ -230,6 +230,12 @@ export { default as MediaPlayer, VideoSheet, AudioSheet, AudioPreview, AudioPlay
230
230
  export { AudioTile, VideoTile, formatLength } from './molecules/PlayTile.jsx'
231
231
  export { default as PlaybackBar } from './molecules/PlaybackBar.jsx'
232
232
  export { default as QuickLookFrame } from './molecules/QuickLookFrame.jsx'
233
+ export { default as FileQuickLook } from './organisms/FileQuickLook.jsx'
234
+ export { default as FlipCard } from './utilities/FlipCard.jsx'
235
+ export { default as Kanban } from './organisms/Kanban.jsx'
236
+ export { default as SortableGrid } from './organisms/SortableGrid.jsx'
237
+ export { default as ProgressBar } from './atoms/ProgressBar.jsx'
238
+ export { default as formatAge } from './utilities/formatAge.js'
233
239
  export { default as MediaTile } from './molecules/MediaTile.jsx'
234
240
  export { default as RowMenuButton } from './molecules/RowMenuButton.jsx'
235
241
  export { default as DocPage } from './molecules/DocPage.jsx'
@@ -37,11 +37,15 @@ import OptionRow from './OptionRow.jsx'
37
37
  * info maps onto the --ui-* ladder (.kol-status-chip--* in kol-theme); the
38
38
  * chip wears the ACTIVE option's tone. No tone → the plain Tag look.
39
39
  *
40
+ * `cycle` (DocumentLibraryAndBoardParts, kol-website 2026-10-29 — record's project status and card size): a click steps
41
+ * to the next option, no menu and no chevron — the same chip, so a status that cycles and one that opens a list look
42
+ * alike. `placeholder` is the label while `value` matches no option (record's `·` for an unsized card).
43
+ *
40
44
  * variant="primary" — the toneless pill wears the Dropdown-primary fill
41
45
  * instead of the neutral mix (RecordManager's select columns, user frame
42
46
  * 2026-08-09: "use status pill, but same look as dropdown primary"). An
43
47
  * option's tone always outranks the variant. */
44
- export function StatusChip({ value, options = [], onChange, variant = 'neutral', size = 'sm' }) {
48
+ export function StatusChip({ value, options = [], onChange, variant = 'neutral', size = 'sm', cycle = false, placeholder, ariaLabel }) {
45
49
  const [open, setOpen] = useState(false)
46
50
  const popover = usePopover({
47
51
  open,
@@ -61,6 +65,19 @@ export function StatusChip({ value, options = [], onChange, variant = 'neutral',
61
65
  * this?") carries visible air; 2px is the minimum that restores it.
62
66
  * mono-12 at its own 16px leading. The chevron is a direct child of the flex
63
67
  * row, centred by items-center; it cannot sit off the label's middle. */
68
+ if (cycle) {
69
+ const next = norm[(norm.findIndex((o) => o.value === value) + 1) % (norm.length || 1)]
70
+ return (
71
+ <button
72
+ type="button"
73
+ aria-label={ariaLabel}
74
+ className={`kol-status-chip${toneCls} kol-mono-12 inline-flex items-center gap-2 rounded-full border-0 px-2 py-0.5 cursor-pointer`}
75
+ onClick={() => next && onChange?.(next.value)}
76
+ >
77
+ {activeOpt?.label ?? placeholder ?? value}
78
+ </button>
79
+ )
80
+ }
64
81
  const chip = (interactive) => (
65
82
  <button
66
83
  type="button"
@@ -1,4 +1,5 @@
1
- import { useRef, useState } from 'react'
1
+ import { useLayoutEffect, useRef, useState } from 'react'
2
+ import useScrollFade from '../hooks/useScrollFade.js'
2
3
  import CloseButton from '../atoms/CloseButton.jsx'
3
4
  import Button from '../atoms/Button.jsx'
4
5
  import { Icon } from '@kolkrabbi/kol-icons'
@@ -24,6 +25,11 @@ import { RAIL_ROW } from '../hooks/railRow.js'
24
25
  * @param {Function} onMinimise () => void — show + wire the trailing minimise chevron
25
26
  *
26
27
  * ONE TAB COMPONENT, FOUR LOOKS (TabsStackedLayout, kol-monitor 2026-10-17 — four components drew one control):
28
+ * @param {'scroll'|'wrap'} [overflow='scroll'] A ROW WIDER THAN ITS COLUMN (TabsRowOverflow, kol-website 2026-10-29 — six
29
+ * underline tabs are 394px, so at 390 the page scrolled sideways and record wrapped the row in its own div): `scroll`
30
+ * keeps one line that scrolls sideways with no scrollbar, `.kol-scroll-fade--x` fading the clipped edge(s), and the
31
+ * active tab scrolled into view when it changes — arrow keys included; `wrap` breaks the tabs onto a second line.
32
+ * Every look but `stacked`, which has its phone bar
27
33
  * @param {'underline'|'chip'|'text'|'stacked'} [look='underline']
28
34
  * underline — this row, as it always was
29
35
  * chip — the active tab a filled chip, the rest quiet (was `TabChips`); `size` is the control rung
@@ -63,12 +69,32 @@ export const tabbarPillWidth = (count) => count * TABBAR_PILL_TAB + 14
63
69
  /* the collapse's motion — one duration for the width and the glyph swap (300, user 2026-10-23: 180 read as abrupt) */
64
70
  const COLLAPSE_MS = 300
65
71
 
66
- export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, look = 'underline', placement = 'inline', shape = 'bar', collapsed = false, onExpand, edge, border, shadow, dock, active, foldable, folded, onFoldChange, foldSide, size, tracked = false, ariaLabel, className, style }) {
72
+ export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, look = 'underline', placement = 'inline', shape = 'bar', collapsed = false, onExpand, edge, border, shadow, dock, active, foldable, folded, onFoldChange, foldSide, size, tracked = false, overflow = 'scroll', ariaLabel, className, style }) {
67
73
  const tabs = raw.map((t) => ({ ...t, id: t.id ?? t.value }))
68
- if (look === 'chip') return <ChipTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 'sm'} ariaLabel={ariaLabel} className={className ?? ''} />
69
- if (look === 'text') return <TextTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 14} tracked={tracked} className={className ?? 'gap-6'} style={style} />
74
+ const wrap = overflow === 'wrap'
75
+ if (look === 'chip') return <Overflow mode={overflow} value={value}><ChipTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 'sm'} ariaLabel={ariaLabel} className={`${wrap ? 'flex-wrap ' : ''}${className ?? ''}`} /></Overflow>
76
+ if (look === 'text') return <Overflow mode={overflow} value={value}><TextTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 14} tracked={tracked} className={`${wrap ? 'flex-wrap gap-y-2 ' : ''}${className ?? 'gap-6'}`} style={style} /></Overflow>
70
77
  if (look === 'stacked') return <StackedTabs tabs={tabs} value={value} onChange={onChange} placement={placement} shape={shape} collapsed={collapsed} onExpand={onExpand} edge={edge} border={border} shadow={shadow} dock={dock} active={active} foldable={foldable} folded={folded} onFoldChange={onFoldChange} foldSide={foldSide} ariaLabel={ariaLabel} className={className ?? ''} />
71
- return <UnderlineTabs tabs={tabs} value={value} onChange={onChange} onClose={onClose} onMinimise={onMinimise} />
78
+ return <Overflow mode={overflow} value={value}><UnderlineTabs tabs={tabs} value={value} onChange={onChange} onClose={onClose} onMinimise={onMinimise} wrap={wrap} /></Overflow>
79
+ }
80
+
81
+ /* `overflow="scroll"`: the row in a sideways scroller that fades its clipped edges and keeps the active tab (`data-active`)
82
+ * in view — by the scroller's own scrollLeft, never scrollIntoView, which would scroll the page too. `wrap` draws as is. */
83
+ function Overflow({ mode, value, children }) {
84
+ const ref = useRef(null)
85
+ const scroll = mode !== 'wrap'
86
+ useScrollFade(ref, scroll, 'x')
87
+ useLayoutEffect(() => {
88
+ const strip = ref.current
89
+ const tab = strip?.querySelector('[data-active]')
90
+ if (!scroll || !strip || !tab) return
91
+ const s = strip.getBoundingClientRect()
92
+ const t = tab.getBoundingClientRect()
93
+ if (t.left < s.left) strip.scrollLeft += t.left - s.left
94
+ else if (t.right > s.right) strip.scrollLeft += t.right - s.right
95
+ }, [value, scroll])
96
+ if (!scroll) return children
97
+ return <div ref={ref} className="kol-tabs-scroll kol-scroll-fade--x">{children}</div>
72
98
  }
73
99
 
74
100
  /* chip — TabChips verbatim */
@@ -79,7 +105,7 @@ function ChipTabs({ tabs, value, onChange, size, ariaLabel, className }) {
79
105
  const active = t.id === value
80
106
  return (
81
107
  /* a tab is selected, not pressed — the role's own attribute replaces Button's aria-pressed */
82
- <Button key={t.id} variant="tab" size={size} pressed={active} role="tab" aria-selected={active} aria-pressed={undefined} onClick={() => onChange?.(t.id)}>
108
+ <Button key={t.id} variant="tab" size={size} pressed={active} role="tab" aria-selected={active} aria-pressed={undefined} data-active={active || undefined} onClick={() => onChange?.(t.id)}>
83
109
  {t.label}
84
110
  </Button>
85
111
  )
@@ -95,6 +121,7 @@ function TextTabs({ tabs, value, onChange, size, tracked, className, style }) {
95
121
  {tabs.map((opt) => (
96
122
  <span
97
123
  key={opt.id}
124
+ data-active={value === opt.id || undefined}
98
125
  onClick={() => onChange?.(opt.id)}
99
126
  className={`kol-helper-${size} cursor-pointer select-none ${value === opt.id ? 'text-fg-96' : 'text-fg-32 hover:text-fg-48'}`}
100
127
  style={tracked ? { letterSpacing: 1 } : undefined}
@@ -236,7 +263,7 @@ function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapse
236
263
  )
237
264
  }
238
265
 
239
- function UnderlineTabs({ tabs, value, onChange, onClose, onMinimise }) {
266
+ function UnderlineTabs({ tabs, value, onChange, onClose, onMinimise, wrap }) {
240
267
  const listRef = useRef(null)
241
268
  const activeIdx = tabs.findIndex((t) => t.id === value)
242
269
 
@@ -250,14 +277,14 @@ function UnderlineTabs({ tabs, value, onChange, onClose, onMinimise }) {
250
277
  }
251
278
 
252
279
  return (
253
- <div className="flex items-stretch gap-4 h-10">
280
+ <div className={`flex items-stretch gap-4 ${wrap ? 'min-h-10' : 'h-10'}`}>
254
281
  {onClose && (
255
282
  /* the one close, at the rung whose glyph is the 12 this hand-rolled
256
283
  * (2026-09-03) — xs SOLO is 12, so the drawing does not move */
257
284
  <CloseButton onClick={onClose} size="xs" className="self-center" />
258
285
  )}
259
286
 
260
- <div ref={listRef} role="tablist" onKeyDown={onKeyDown} className="flex items-stretch gap-4">
287
+ <div ref={listRef} role="tablist" onKeyDown={onKeyDown} className={`flex items-stretch gap-4${wrap ? ' flex-wrap gap-y-1' : ''}`}>
261
288
  {tabs.map((t, i) => {
262
289
  const isActive = t.id === value
263
290
  return (
@@ -266,6 +293,7 @@ function UnderlineTabs({ tabs, value, onChange, onClose, onMinimise }) {
266
293
  type="button"
267
294
  role="tab"
268
295
  aria-selected={isActive}
296
+ data-active={isActive || undefined}
269
297
  tabIndex={isActive || (activeIdx === -1 && i === 0) ? 0 : -1}
270
298
  onClick={() => onChange?.(t.id)}
271
299
  className={[
@@ -0,0 +1,54 @@
1
+ import Button from '../atoms/Button.jsx'
2
+ import FullscreenOverlay from '../utilities/FullscreenOverlay.jsx'
3
+ import QuickLookFrame from '../molecules/QuickLookFrame.jsx'
4
+ import KindPreview from '../molecules/KindPreview.jsx'
5
+ import { kindOf, extOf, KIND_LABEL } from '../utilities/mediaKinds.js'
6
+
7
+ /* taxonomy-ok: organism — nests FullscreenOverlay (utility) + QuickLookFrame / KindPreview (molecules) + Button (atom). */
8
+
9
+ /**
10
+ * FileQuickLook — Quick Look over a list of files. The composition three places drew by hand — kol-styleguide's
11
+ * `DocumentIndex`, record's `QuickLook` (Bucket.jsx) and its documents table (DocumentLibraryAndBoardParts, kol-website
12
+ * 2026-10-29 — *"I already asked for tables, and download and file preview"*): `FullscreenOverlay` dims the page,
13
+ * `QuickLookFrame` holds the file, pages ‹ › through the list and carries a download; an image shows directly, anything
14
+ * else through `KindPreview`.
15
+ *
16
+ * @param {Array} files `[{ key, name?, title?, url?, size?, type? }]` — `key` classifies (its extension), `type` is
17
+ * the content type when known
18
+ * @param {number} index the open file; `null` closes
19
+ * @param {Function} onIndex (i) => void — ‹ › paging
20
+ * @param {Function} onClose
21
+ * @param {Function} urlOf (file) => string — default `file.url`
22
+ * @param {boolean} download the download button in the header (default true)
23
+ * @param {Function} meta (file) => node — the header's facts (default: the size, else the kind)
24
+ * @param {ReactNode} actions more header controls, before the download
25
+ */
26
+ const sizeLabel = (n) => (n >= 1048576 ? `${(n / 1048576).toFixed(1)} MB` : `${Math.max(1, Math.round(n / 1024))} KB`)
27
+ const nameOf = (f) => f.name ?? f.title ?? f.key?.split('/').pop() ?? ''
28
+
29
+ export default function FileQuickLook({ files = [], index, onIndex, onClose, urlOf = (f) => f.url, download = true, meta, actions }) {
30
+ const f = index == null ? null : files[index]
31
+ if (!f) return null
32
+ const url = urlOf(f)
33
+ const kind = kindOf({ key: f.key ?? nameOf(f), contentType: f.type ?? f.contentType })
34
+ const facts = meta ? meta(f) : (f.size ? sizeLabel(f.size) : (KIND_LABEL[kind] ?? extOf(f.key ?? '').toUpperCase()))
35
+ const nav = files.length > 1
36
+ ? { index, total: files.length, onPrev: () => onIndex?.((index - 1 + files.length) % files.length), onNext: () => onIndex?.((index + 1) % files.length) }
37
+ : undefined
38
+ return (
39
+ /* QUICK LOOK DIMS, it does not black out — the list stays in view (MediaLibraryPages' rule) */
40
+ <FullscreenOverlay open onClose={onClose} closeButton={false} scrim>
41
+ <QuickLookFrame
42
+ title={nameOf(f)}
43
+ meta={facts}
44
+ actions={<>{actions}{download && url && <Button variant="nav" size="sm" iconOnly="download" href={url} download={nameOf(f)} aria-label="Download" />}</>}
45
+ onClose={onClose}
46
+ nav={nav}
47
+ >
48
+ {kind === 'image'
49
+ ? <img src={url} alt={nameOf(f)} className="kol-quicklook-media" />
50
+ : <KindPreview key={url} o={{ key: (f.key ?? url).split('?')[0], contentType: f.type ?? f.contentType, size: f.size, url }} fit="sheet" urlOf={() => url} />}
51
+ </QuickLookFrame>
52
+ </FullscreenOverlay>
53
+ )
54
+ }
@@ -0,0 +1,110 @@
1
+ import { useState } from 'react'
2
+ import Button from '../atoms/Button.jsx'
3
+
4
+ /* taxonomy-ok: organism — nests Button (atom); the cards are the consumer's (`renderCard`). */
5
+
6
+ /**
7
+ * Kanban — Cards in columns, moved between them. record's Capture board, made the DS's (DocumentLibraryAndBoardParts,
8
+ * kol-website 2026-10-29 — *"DASHBOARD NEEDS TO CONSUME DS COMPONENTS"*). Controlled: the board draws `cards` in
9
+ * `columns` by `order` and reports a move; the consumer owns the data and the write-back.
10
+ *
11
+ * A card moves three ways: dragged into a column (it lands last) or onto a card (it lands before it), within a column
12
+ * or between, and by its ‹ › buttons, which a keyboard reaches and a phone can press — at 390 the columns stack.
13
+ * Something dragged in from outside the board lands too: give `externalType`, the `dataTransfer` key the outside item
14
+ * sets, and `onExternalDrop` receives its payload (record drags inbox lines in).
15
+ *
16
+ * @param {Array} columns `[{ id, label, tone? }]` — tone ∈ success · warning · error · info (the header's dot)
17
+ * @param {Array} cards `[{ id, column, order, … }]` — a card with `archived` is not drawn
18
+ * @param {Function} onMove (cardId, toColumn, beforeId | null) => void
19
+ * @param {Function} renderCard (card) => node — the card's body
20
+ * @param {Function} cardActions (card) => node — the hover row, right of ‹ ›
21
+ * @param {Function} columnActions (column, cards) => node — beside the count ("archive all")
22
+ * @param {ReactNode} footer under the board (the archive list)
23
+ * @param {string} externalType the `dataTransfer` key an outside drag carries
24
+ * @param {Function} onExternalDrop (column, beforeId | null, payload) => void
25
+ * @param {ReactNode} empty a column with no cards (default `—`)
26
+ */
27
+ const CARD_TYPE = 'application/x-kol-kanban-card'
28
+ const TONE = { success: 'var(--ui-success)', warning: 'var(--ui-warning)', error: 'var(--ui-error)', info: 'var(--ui-info)' }
29
+
30
+ export default function Kanban({ columns = [], cards = [], onMove, renderCard, cardActions, columnActions, footer, externalType, onExternalDrop, empty = '—', className = '' }) {
31
+ const [over, setOver] = useState(null) // { column, before }
32
+ const ids = columns.map((c) => c.id)
33
+ const accepts = (e) => e.dataTransfer.types.includes(CARD_TYPE) || (externalType && e.dataTransfer.types.includes(externalType))
34
+
35
+ const drop = (e, column, before) => {
36
+ e.preventDefault()
37
+ e.stopPropagation()
38
+ setOver(null)
39
+ const id = e.dataTransfer.getData(CARD_TYPE)
40
+ if (id) { if (id !== before) onMove?.(id, column, before); return }
41
+ if (externalType) {
42
+ const payload = e.dataTransfer.getData(externalType)
43
+ if (payload) onExternalDrop?.(column, before, payload)
44
+ }
45
+ }
46
+ const dragOver = (column, before) => (e) => {
47
+ if (!accepts(e)) return
48
+ e.preventDefault()
49
+ e.stopPropagation()
50
+ if (over?.column !== column || over?.before !== before) setOver({ column, before })
51
+ }
52
+ const step = (card, d) => {
53
+ const i = ids.indexOf(card.column) + d
54
+ if (i >= 0 && i < ids.length) onMove?.(card.id, ids[i], null)
55
+ }
56
+
57
+ return (
58
+ <div className={className}>
59
+ <div className="kol-kanban" style={{ '--kol-kanban-cols': columns.length }} onDragLeave={(e) => { if (!e.currentTarget.contains(e.relatedTarget)) setOver(null) }}>
60
+ {columns.map((col, ci) => {
61
+ const list = cards.filter((c) => c.column === col.id && !c.archived).sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
62
+ return (
63
+ <section
64
+ key={col.id}
65
+ aria-label={col.label}
66
+ className={`kol-kanban-column${over?.column === col.id ? ' is-over' : ''}`}
67
+ onDragOver={dragOver(col.id, null)}
68
+ onDrop={(e) => drop(e, col.id, null)}
69
+ >
70
+ {/* wraps: a column action ("Archive") never runs past a narrow column */}
71
+ <header className="flex flex-wrap items-center justify-between gap-x-2 gap-y-1">
72
+ <span className="flex items-center gap-1.5">
73
+ {col.tone && <span className="inline-block size-2 rounded-full" style={{ background: TONE[col.tone] }} />}
74
+ <span className="kol-mono-12 text-emphasis">{col.label}</span>
75
+ </span>
76
+ <span className="flex items-center gap-2">
77
+ <span className="kol-mono-10 text-meta tabular-nums">{list.length}</span>
78
+ {columnActions?.(col, list)}
79
+ </span>
80
+ </header>
81
+ <ul className="flex flex-col gap-2 m-0 p-0 list-none">
82
+ {list.map((card) => (
83
+ <li
84
+ key={card.id}
85
+ draggable
86
+ onDragStart={(e) => { e.dataTransfer.setData(CARD_TYPE, card.id); e.dataTransfer.effectAllowed = 'move' }}
87
+ onDragOver={dragOver(col.id, card.id)}
88
+ onDrop={(e) => drop(e, col.id, card.id)}
89
+ className={`kol-kanban-card group${over?.column === col.id && over.before === card.id ? ' is-drop-target' : ''}`}
90
+ >
91
+ {renderCard?.(card)}
92
+ <div className="flex items-center justify-between gap-2">
93
+ <span className="flex items-center gap-0.5">
94
+ <Button variant="nav" size="sm" iconOnly="chevron-left" disabled={ci === 0} onClick={() => step(card, -1)} aria-label={`Move to ${columns[ci - 1]?.label ?? ''}`.trim()} />
95
+ <Button variant="nav" size="sm" iconOnly="chevron-right" disabled={ci === columns.length - 1} onClick={() => step(card, 1)} aria-label={`Move to ${columns[ci + 1]?.label ?? ''}`.trim()} />
96
+ </span>
97
+ {cardActions && <span className="flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100">{cardActions(card)}</span>}
98
+ </div>
99
+ </li>
100
+ ))}
101
+ {!list.length && <li className="kol-sans-body-03 text-meta">{empty}</li>}
102
+ </ul>
103
+ </section>
104
+ )
105
+ })}
106
+ </div>
107
+ {footer}
108
+ </div>
109
+ )
110
+ }
@@ -0,0 +1,54 @@
1
+ import { useState } from 'react'
2
+ import Button from '../atoms/Button.jsx'
3
+
4
+ /* taxonomy-ok: organism — nests Button (atom, the drag handle); the items are the consumer's (`renderItem`). */
5
+
6
+ /**
7
+ * SortableGrid — A grid of cards reordered by drag. record's Projects grid (DocumentLibraryAndBoardParts, kol-website
8
+ * 2026-10-29): `auto-fill` tracks at least `min` wide, each item dragged by its handle onto another to take its place.
9
+ * The handle is a button, so a keyboard reorders too — ← ↑ one back, → ↓ one on. The item's wrapper wears
10
+ * `is-dragging` and `is-drop-target` (kol-theme `.kol-sortable-item`).
11
+ *
12
+ * @param {Array} items
13
+ * @param {Function} getId (item) => key (default `item.id`)
14
+ * @param {Function} renderItem (item, { handle, dragging, dropTarget, index }) => node — put `handle` where the grip goes
15
+ * @param {Function} onReorder (from, to) => void — indexes into `items`
16
+ * @param {number} min the smallest track, px (default 280, record's)
17
+ */
18
+ const TYPE = 'application/x-kol-sortable'
19
+
20
+ export default function SortableGrid({ items = [], getId = (it) => it.id, renderItem, onReorder, min = 280, className = '' }) {
21
+ const [drag, setDrag] = useState(null)
22
+ const [target, setTarget] = useState(null)
23
+ const end = () => { setDrag(null); setTarget(null) }
24
+ const move = (from, to) => { if (to >= 0 && to < items.length && to !== from) onReorder?.(from, to) }
25
+ return (
26
+ <div className={`kol-sortable-grid ${className}`.trim()} style={{ '--kol-sortable-min': `${min}px` }}>
27
+ {items.map((item, i) => {
28
+ const handle = onReorder ? (
29
+ <Button
30
+ variant="nav" size="sm" iconOnly="drag-handle" aria-label="Drag to reorder"
31
+ className="kol-sortable-handle"
32
+ draggable
33
+ onDragStart={(e) => { e.dataTransfer.setData(TYPE, String(i)); e.dataTransfer.effectAllowed = 'move'; setDrag(i) }}
34
+ onDragEnd={end}
35
+ onKeyDown={(e) => {
36
+ if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') { e.preventDefault(); move(i, i - 1) }
37
+ if (e.key === 'ArrowRight' || e.key === 'ArrowDown') { e.preventDefault(); move(i, i + 1) }
38
+ }}
39
+ />
40
+ ) : null
41
+ return (
42
+ <div
43
+ key={getId(item)}
44
+ className={`kol-sortable-item${drag === i ? ' is-dragging' : ''}${target === i && drag !== i ? ' is-drop-target' : ''}`}
45
+ onDragOver={(e) => { if (!e.dataTransfer.types.includes(TYPE)) return; e.preventDefault(); if (target !== i) setTarget(i) }}
46
+ onDrop={(e) => { const from = Number(e.dataTransfer.getData(TYPE)); e.preventDefault(); end(); if (!Number.isNaN(from)) move(from, i) }}
47
+ >
48
+ {renderItem?.(item, { handle, dragging: drag === i, dropTarget: target === i && drag !== i, index: i })}
49
+ </div>
50
+ )
51
+ })}
52
+ </div>
53
+ )
54
+ }
@@ -0,0 +1,54 @@
1
+ import { useState } from 'react'
2
+
3
+ /**
4
+ * FlipCard — A face that turns to show its back. A face that turns over in place to show its back. Born in kol-hardware's
5
+ * frames (2026-09-27, kol-mirror's channel flip); moved here for record's project cards (DocumentLibraryAndBoardParts,
6
+ * kol-website 2026-10-29 — *"DASHBOARD NEEDS TO CONSUME DS COMPONENTS"*), and kol-hardware re-exports it. The body
7
+ * turns; everything around it holds still, so the back is the same shaped object as the front.
8
+ *
9
+ * THE FACES SWAP BY BACKFACE, NOT BY A CLOCK (FlipCardFaceSwap, kol-monitor 2026-10-24 — user: *"the card flipps,
10
+ * but the image snaps in once its landed. not believable."*). Both faces hide their backface and the back is pre-rotated
11
+ * 180° in the preserve-3d turner, so the back shows exactly as the card passes edge-on, whatever the easing. The face
12
+ * that is away is `inert` (and aria-hidden): out of tab order.
13
+ *
14
+ * TWO SHAPES. Without `height` the front sets the card's size and the back lies over it, scrolling what does not fit
15
+ * (mirror's strip). With `height` the card is a fixed tile and each face scrolls its own overflow (record's 240 card).
16
+ *
17
+ * @param {boolean} flipped controlled; omit it and the card keeps its own (`defaultFlipped`)
18
+ * @param {Function} onFlippedChange (flipped) => void
19
+ * @param {ReactNode|Function} front · back a node, or `({ flipped, flip, setFlipped }) => node` — a face's own
20
+ * button turns the card ("Details →", "‹ Back")
21
+ * @param {number|string} width the card's width
22
+ * @param {number|string} height a fixed height (record's 240); omitted, the front's height
23
+ * @param {number} duration ms (default 450, mirror's)
24
+ */
25
+ export default function FlipCard({ flipped: flippedProp, defaultFlipped = false, onFlippedChange, front, back, width, height, duration = 450, className = '' }) {
26
+ const [own, setOwn] = useState(defaultFlipped)
27
+ const flipped = flippedProp ?? own
28
+ const setFlipped = (v) => {
29
+ const next = typeof v === 'function' ? v(flipped) : v
30
+ if (flippedProp === undefined) setOwn(next)
31
+ onFlippedChange?.(next)
32
+ }
33
+ const api = { flipped, flip: () => setFlipped(!flipped), setFlipped }
34
+ const face = (f) => (typeof f === 'function' ? f(api) : f)
35
+ const hidden = { backfaceVisibility: 'hidden', WebkitBackfaceVisibility: 'hidden' }
36
+ const fixed = height != null
37
+ const scroll = { overflowY: 'auto', scrollbarWidth: 'none' }
38
+ return (
39
+ <div className={className} style={{ perspective: 1400, position: 'relative', width, height }}>
40
+ <div style={{ transition: `transform ${duration}ms ease`, transformStyle: 'preserve-3d', transform: flipped ? 'rotateY(180deg)' : 'none', ...(fixed ? { position: 'relative', height: '100%' } : null) }}>
41
+ <div aria-hidden={flipped || undefined} inert={flipped || undefined} style={fixed ? { position: 'absolute', inset: 0, ...scroll, ...hidden } : hidden}>
42
+ {face(front)}
43
+ </div>
44
+ <div
45
+ aria-hidden={!flipped || undefined}
46
+ inert={!flipped || undefined}
47
+ style={{ position: 'absolute', inset: 0, transform: 'rotateY(180deg)', ...scroll, ...hidden }}
48
+ >
49
+ {face(back)}
50
+ </div>
51
+ </div>
52
+ </div>
53
+ )
54
+ }
@@ -0,0 +1,9 @@
1
+ /* formatAge — how long ago, in the fewest characters: `now` under an hour, `5h` under a day, `3d` after. record's board
2
+ * reads a card's time in its column this way (DocumentLibraryAndBoardParts, kol-website 2026-10-29). '' for no time. */
3
+ export default function formatAge(ms, now = Date.now()) {
4
+ if (!ms) return ''
5
+ const d = now - ms
6
+ if (d < 36e5) return 'now'
7
+ if (d < 864e5) return `${Math.floor(d / 36e5)}h`
8
+ return `${Math.floor(d / 864e5)}d`
9
+ }