@kolkrabbi/kol-component 0.313.1 → 0.315.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.313.1",
3
+ "version": "0.315.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-search": "^0.3.0",
30
- "@kolkrabbi/kol-markdown": "^0.2.0"
29
+ "@kolkrabbi/kol-markdown": "^0.2.0",
30
+ "@kolkrabbi/kol-search": "^0.3.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
+ }
@@ -0,0 +1,33 @@
1
+ import { useEffect } from 'react'
2
+
3
+ /**
4
+ * useScrollFade — the scroll state a `.kol-scroll-fade` box fades by (TimeSetAndSiteRailFade, kol-website 2026-10-29 —
5
+ * user: *"FADE WHAT VERTICALLY SCROLLS into clipping!!!"*). On the element `ref` points at it sets `data-fade-top` once the
6
+ * box is scrolled, and `data-fade-bottom` while more lies below; kol-theme's `.kol-scroll-fade` draws the two fades from
7
+ * them. Re-read on scroll and whenever the box or its content changes size. One rule for every vertically scrolling rail
8
+ * or list that clips: the site rail, the app rail, the workshop's rails.
9
+ */
10
+ export default function useScrollFade(ref, enabled = true) {
11
+ useEffect(() => {
12
+ const el = ref.current
13
+ 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
+ }
18
+ read()
19
+ el.addEventListener('scroll', read, { passive: true })
20
+ const ro = new ResizeObserver(read)
21
+ ro.observe(el)
22
+ for (const c of el.children) ro.observe(c)
23
+ const mo = new MutationObserver(() => { for (const c of el.children) ro.observe(c); read() })
24
+ mo.observe(el, { childList: true })
25
+ return () => {
26
+ el.removeEventListener('scroll', read)
27
+ ro.disconnect()
28
+ mo.disconnect()
29
+ el.removeAttribute('data-fade-top')
30
+ el.removeAttribute('data-fade-bottom')
31
+ }
32
+ }, [ref, enabled])
33
+ }
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'
@@ -268,6 +274,11 @@ export { SOLO, ADJACENT, INDICATOR, glyphSize, indicatorSize } from './hooks/gly
268
274
  export { default as usePrefersReducedMotion } from './hooks/usePrefersReducedMotion.js'
269
275
  export { default as useReveal } from './hooks/useReveal.js'
270
276
  export { default as useScrollSpy } from './hooks/useScrollSpy.js'
277
+ export { default as useScrollFade } from './hooks/useScrollFade.js'
278
+ /* the time set — Timeline · Month · Week · Day over one model (TimeSetAndSiteRailFade, 2026-10-29; kol-atlas's views) */
279
+ export { default as TimeSet } from './organisms/TimeSet.jsx'
280
+ export { timelineModel } from './organisms/time/model.js'
281
+ export { renderTimeline, mountTimeline, printTimeline } from './organisms/time/view.js'
271
282
  export { default as useTilt } from './hooks/useTilt.js'
272
283
  export { default as usePlayback } from './hooks/usePlayback.js'
273
284
  export { default as useCoarsePointer } from './hooks/useCoarsePointer.js'
@@ -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"
@@ -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
+ }
@@ -5,6 +5,7 @@ import gsap from 'gsap'
5
5
  * app rail and the site rail are one component, and a site must not install the app shell
6
6
  * for its sidebar — the PageHeader precedent. kol-shell re-exports it. */
7
7
  import Button from '../atoms/Button.jsx'
8
+ import useScrollFade from '../hooks/useScrollFade.js'
8
9
  import { Tooltip } from '../utilities/Popover.jsx'
9
10
  import { GRAB } from '../utilities/motion.js'
10
11
  /* the grab pill's proximity wake, travel and dwell — ONE implementation, shared
@@ -339,6 +340,9 @@ function AppRail({
339
340
  const snapOpenRef = useRef(null)
340
341
  const slotRef = useRef(null)
341
342
  const ctx = useRailSlot()
343
+ /* the list fades where it clips — the head once scrolled, the foot while more lies below (kol-theme `.kol-scroll-fade`) */
344
+ const listRef = useRef(null)
345
+ useScrollFade(listRef, fade)
342
346
  const setSlot = ctx?.setSlot
343
347
  const setCtxOpen = ctx?.setRailOpen
344
348
  const slotOpen = drawer || railOpen
@@ -416,7 +420,7 @@ function AppRail({
416
420
  {/* THE LIST IS ITS OWN REGION (2026-10-02): it takes the room between the mark and the pinned
417
421
  * bottom rows — what the bare spacer used to hold — scrolls when the rows outrun the window,
418
422
  * and fades at its foot unless `fade={false}`. Same column, same gap, as the rail's own. */}
419
- <div style={ctx && slotOpen ? { flex: '0 1 auto' } : undefined} className={`kol-shell-rail-list flex min-h-0 w-full flex-1 flex-col items-start gap-2 overflow-y-auto overflow-x-hidden ${fade ? 'kol-shell-rail-list--fade' : ''}`.trim()}>
423
+ <div ref={listRef} style={ctx && slotOpen ? { flex: '0 1 auto' } : undefined} className={`kol-shell-rail-list flex min-h-0 w-full flex-1 flex-col items-start gap-2 overflow-y-auto overflow-x-hidden ${fade ? 'kol-shell-rail-list--fade kol-scroll-fade' : ''}`.trim()}>
420
424
  {section ? (
421
425
  <>
422
426
  <RailItem icon="arrow-left" path={section.path} label={section.label} currentPath="" onNavigate={() => setEntered(trail.slice(0, -1).map((t) => t.path))} iconComponent={iconComponent} railOpen={drawer || railOpen} />
@@ -3,6 +3,7 @@ import { createPortal } from 'react-dom'
3
3
  import { Icon } from '@kolkrabbi/kol-icons'
4
4
  import { Tooltip } from '../utilities/Popover.jsx'
5
5
  import useDragResize from '../hooks/useDragResize.js'
6
+ import useScrollFade from '../hooks/useScrollFade.js'
6
7
 
7
8
  /* taxonomy-ok: organism — NavRail's site variant; nests Tooltip (utility) + kol-icons' Icon.
8
9
  * Carried class-for-class from kol-framework's SideNav.jsx (2026-10-22, the one nav rail):
@@ -212,6 +213,10 @@ export default function NavRailSite({
212
213
  defaultOpen = [],
213
214
  openOnRoute = false,
214
215
  }) {
216
+ /* the tree fades where it clips — the head once scrolled, the foot while more lies below (kol-theme `.kol-scroll-fade`;
217
+ * TimeSetAndSiteRailFade, 2026-10-29) */
218
+ const scrollRef = useRef(null)
219
+ useScrollFade(scrollRef, fade)
215
220
  const Glyph = iconComponent ?? Icon
216
221
  const isPageActive = (to) => (isActive ? isActive(to) : pathname === to)
217
222
  /* a leaf is lit by its route, or — an action leaf — by its own `active` */
@@ -491,7 +496,7 @@ export default function NavRailSite({
491
496
  * collapsed tree they scrolled off below the footer — "pinned" only
492
497
  * held while the tree was shorter than the rail. They are the block
493
498
  * after it now, above the footer, the tree scrolling underneath. */}
494
- <div className={`kol-sidenav-scroll flex-1 overflow-y-auto pt-4 [scrollbar-width:thin] ${fade ? 'pb-12 kol-sidenav-scroll--fade' : 'pb-4'}`}>
499
+ <div ref={scrollRef} className={`kol-sidenav-scroll flex-1 overflow-y-auto pt-4 [scrollbar-width:thin] ${fade ? 'pb-12 kol-scroll-fade' : 'pb-4'}`}>
495
500
  <nav aria-label="Sections">
496
501
  <ul className="kol-sidenav-tree flex flex-col gap-[2px]">
497
502
  {navTree.map(renderCat)}
@@ -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,25 @@
1
+ import { useEffect, useMemo, useRef } from 'react'
2
+ import { timelineModel } from './time/model.js'
3
+ import { mountTimeline } from './time/view.js'
4
+
5
+ /**
6
+ * TimeSet — a project in time, four ways: Timeline (phases across the whole project, dated checkpoints, breaks, the Today
7
+ * line) · Month · Week · Day, one switch, one legend, a phase's detail on click. kol-atlas's timeline views carried
8
+ * verbatim (TimeSetAndSiteRailFade, kol-website 2026-10-29 — user: *"in kol-atlas there are date components … we might
9
+ * just need day? and then we have a full 'time' set?"*), Day added. The views are plain HTML from `time/view.js`; this
10
+ * mounts them. Styles: kol-theme's `kol-components-time.css` (`--tl-*`, mapped to KOL's tokens).
11
+ *
12
+ * @param {Array} milestones parseProject's milestones (kol-atlas's shape) — `{ id, title, when, phases: [{ id, title, when,
13
+ * dw?, reason?, marks, items: [{ num, text, kind, date?, time? }] }] }`; or pass `model`
14
+ * @param {Object} model a `timelineModel(milestones)` already built
15
+ * @param {string} today ISO day the Today line marks (default: the real today)
16
+ * @param {Date|string} now the moment Day's Today line marks (default: now)
17
+ * @param {string} view 'timeline' | 'month' | 'week' | 'day' — the view to open on (else the viewer's last)
18
+ * @param {string} storageKey where the viewer's view is remembered (default `kol-time-view`)
19
+ */
20
+ export default function TimeSet({ milestones, model, today, now, view, storageKey, className = '' }) {
21
+ const ref = useRef(null)
22
+ const m = useMemo(() => model ?? timelineModel(milestones ?? []), [model, milestones])
23
+ useEffect(() => mountTimeline(ref.current, m, { today, now, view, storageKey }), [m, today, now, view, storageKey])
24
+ return <div ref={ref} className={className} />
25
+ }
@@ -0,0 +1,56 @@
1
+ /* The timeline's data, from parseProject's milestones: every date resolved to an ISO day, nothing typed here.
2
+ * Pure and JSON-safe, so the dev page and the artifact build (scripts/timeline-artifact.mjs) read the same model.
3
+ *
4
+ * kol-atlas's apps/workspace/src/timeline/model.js, carried verbatim into kol-component (TimeSetAndSiteRailFade, kol-website
5
+ * 2026-10-29). Two changes: atlas's `isOptional` is inlined (it lived in its render engine), and an item may carry a `time`
6
+ * ("14:00") — the Day view places it on its hour. A milestone is `{ id, title, when, phases }`, a phase `{ id, title, when,
7
+ * dw?, reason?, marks: [[mark, kind]], items: [{ num, text, kind: 'c' | …, date?, time? }] }` — parseProject's shape. */
8
+ /* a milestone is optional when every phase is parked (atlas's engine/render.js `isOptional`) */
9
+ const isOptional = (m) => m.phases.length > 0 && m.phases.every((p) => p.marks.some((k) => k[1] === 'park'))
10
+
11
+ const MONTHS = { jan: 0, feb: 1, mar: 2, apr: 3, may: 4, jun: 5, jul: 6, aug: 7, sep: 8, oct: 9, nov: 10, dec: 11 }
12
+ const iso = (y, m, d) => new Date(Date.UTC(y, m, d)).toISOString().slice(0, 10)
13
+ const addDays = (s, n) => { const d = new Date(s + 'T00:00:00Z'); d.setUTCDate(d.getUTCDate() + n); return d.toISOString().slice(0, 10) }
14
+ const dayDiff = (a, b) => Math.round((new Date(b + 'T00:00:00Z') - new Date(a + 'T00:00:00Z')) / 864e5)
15
+
16
+ /* "26 – 30 Oct" · "26 Oct – 6 Nov" · "26 Oct – 16 Dec 2026" · "27 Oct" → [start, end]. A missing month takes the
17
+ * end's; a missing year takes `year`, minus one when the day would land after `before` (a range crossing New Year). */
18
+ function parseRange(s, year, before) {
19
+ const parts = s.replace(/\s+/g, ' ').trim().split(/\s*[–-]\s*/)
20
+ const read = (p) => { const m = /^(\d{1,2})(?: ([A-Za-z]{3})[a-z]*)?(?: (\d{4}))?$/.exec(p.trim()); return m ? { d: +m[1], m: m[2] ? MONTHS[m[2].toLowerCase()] : undefined, y: m[3] ? +m[3] : undefined } : null }
21
+ const a = read(parts[0]), b = read(parts[parts.length - 1])
22
+ if (!a || !b) return null
23
+ const y = b.y || year
24
+ if (a.m === undefined) a.m = b.m
25
+ const end = iso(y, b.m, b.d)
26
+ let start = iso(a.y || y, a.m, a.d)
27
+ if (start > end) start = iso((a.y || y) - 1, a.m, a.d)
28
+ if (before && end > before) return [iso((a.y || y) - 1, a.m, a.d), iso(y - 1, b.m, b.d)]
29
+ return [start, end]
30
+ }
31
+
32
+ const num = (t) => (/^((?:M)?\d+(?:\.\d+)?)\s+/.exec(t) || [])[1] || ''
33
+ const name = (t) => t.replace(/^(?:M?\d+(?:\.\d+)?)\s+/, '')
34
+
35
+ export function timelineModel(ms) {
36
+ const milestones = ms.map((m) => {
37
+ const yearOf = +(/(\d{4})\s*$/.exec(m.when) || [])[1]
38
+ const [mStart, mEnd] = parseRange(m.when, yearOf)
39
+ const slack = addDays(mEnd, 7)
40
+ const phases = m.phases.map((p) => {
41
+ const [start, end] = parseRange(p.when, yearOf, slack) || [mStart, mEnd]
42
+ return {
43
+ id: p.id, num: num(p.title), name: name(p.title), start, end, acceptance: p.dw || '',
44
+ confirm: p.marks.some((k) => k[1] !== 'park') ? p.reason : '', optional: p.marks.some((k) => k[1] === 'park'),
45
+ items: p.items.map((it) => ({ num: it.num, text: it.text, checkpoint: it.kind === 'c', date: it.date ? parseRange(it.date, yearOf, slack)[0] : '', time: it.time || '' })),
46
+ }
47
+ })
48
+ return { id: m.id, num: num(m.title), name: name(m.title), start: mStart, end: mEnd, optional: isOptional(m), phases }
49
+ })
50
+ const checkpoints = milestones.flatMap((m) => m.phases.flatMap((p) => p.items.filter((i) => i.checkpoint && i.date).map((i) => ({ date: i.date, time: i.time, label: i.text, num: i.num, phase: p.id, ms: m.num }))))
51
+ /* breaks: gaps of more than a weekend between one milestone's end and the next one's start */
52
+ const breaks = milestones.slice(1).map((m, i) => [addDays(milestones[i].end, 1), addDays(m.start, -1)]).filter(([a, b]) => dayDiff(a, b) > 3)
53
+ const first = milestones[0].start, last = milestones[milestones.length - 1].end
54
+ const mon = (s) => addDays(s, -((new Date(s + 'T00:00:00Z').getUTCDay() + 6) % 7))
55
+ return { start: mon(first), end: addDays(mon(last), 6), first, last, milestones, checkpoints, breaks }
56
+ }
@@ -0,0 +1,201 @@
1
+ /* The timeline views: model (model.js) in, HTML out — Timeline (Gantt) · Month · Week · Day, a phase's detail on click.
2
+ * No imports and no framework, so the timeline on Plan (/plan) and the artifact (scripts/timeline-artifact.mjs) run
3
+ * this same file. Styles: timeline.css, every colour a --tl-* variable each host sets.
4
+ *
5
+ * kol-atlas's apps/workspace/src/timeline/view.js, carried verbatim into kol-component (TimeSetAndSiteRailFade, kol-website
6
+ * 2026-10-29 — *"we might just need day? and then we have a full 'time' set?"*). Added: DAY — one day by hour, the phases
7
+ * running that day and its untimed checkpoints in an all-day lane, timed ones on their hour, the Today line at the hour
8
+ * now; the view is remembered under `kol-time-view`. The styles are kol-theme's kol-components-time.css. */
9
+
10
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
11
+ const MONTH = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
12
+ const WD = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
13
+ const VIEWS = [['timeline', 'Timeline'], ['month', 'Month'], ['week', 'Week'], ['day', 'Day']]
14
+
15
+ const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' })[c])
16
+ const D = (s) => new Date(s + 'T00:00:00Z')
17
+ const add = (s, n) => { const d = D(s); d.setUTCDate(d.getUTCDate() + n); return d.toISOString().slice(0, 10) }
18
+ const diff = (a, b) => Math.round((D(b) - D(a)) / 864e5)
19
+ const wd = (s) => (D(s).getUTCDay() + 6) % 7 // 0 = Monday
20
+ const monday = (s) => add(s, -wd(s))
21
+ const day = (s) => D(s).getUTCDate() + ' ' + MON[D(s).getUTCMonth()]
22
+ const dayY = (s) => day(s) + ' ' + D(s).getUTCFullYear()
23
+ const range = (a, b) => (a === b ? day(a) : D(a).getUTCMonth() === D(b).getUTCMonth() ? D(a).getUTCDate() + ' – ' + day(b) : day(a) + ' – ' + day(b))
24
+ const weekNo = (s) => { const d = D(s); d.setUTCDate(d.getUTCDate() + 3 - wd(s)); const y = new Date(Date.UTC(d.getUTCFullYear(), 0, 4)); return 1 + Math.round((d - y) / 864e5 / 7) }
25
+ const workdays = (a, b) => { let n = 0; for (let d = a; d <= b; d = add(d, 1)) if (wd(d) < 5) n++; return n }
26
+ const clamp = (s, a, b) => (s < a ? a : s > b ? b : s)
27
+ const inBreak = (m, s) => m.breaks.some(([a, b]) => s >= a && s <= b)
28
+
29
+ const phases = (m) => m.milestones.flatMap((ms, i) => ms.phases.map((p) => ({ ...p, msi: i, ms })))
30
+ const msClass = (i, ms) => 'tl-m' + (i + 1) + (ms.optional ? ' tl-opt' : '')
31
+ const marks = (p) => (p.confirm ? '<span class="tl-confirm" title="To confirm: ' + esc(p.confirm) + '"><i></i>To confirm</span>' : '')
32
+
33
+ function legend(m) {
34
+ return '<div class="tl-legend">' + m.milestones.map((ms, i) => '<span><b class="tl-sw ' + msClass(i, ms) + '"></b>' + esc(ms.num + ' ' + ms.name) + (ms.optional ? ' (optional)' : '') + '</span>').join('') +
35
+ '<span><b class="tl-dia"></b>Checkpoint</span><span class="tl-confirm"><i></i>To confirm</span><span><b class="tl-sw tl-sw-break"></b>Break</span><span><b class="tl-sw tl-sw-today"></b>Today</span></div>'
36
+ }
37
+
38
+ /* ---------- Timeline: one row per milestone and phase across the whole project ---------- */
39
+ function timeline(m, st) {
40
+ const total = diff(m.start, m.end) + 1
41
+ const x = (s) => (diff(m.start, s) / total) * 100
42
+ const w = (a, b) => ((diff(a, b) + 1) / total) * 100
43
+ const rows = []
44
+ m.milestones.forEach((ms, i) => {
45
+ rows.push({ kind: 'ms', ms, i })
46
+ ms.phases.forEach((p) => rows.push({ kind: 'ph', ms, i, p }))
47
+ })
48
+ const H = 34
49
+ let scale = '', bg = '', firstLab = true
50
+ for (let d = m.start; d <= m.end; d = add(d, 1)) {
51
+ /* a month label on each 1st, and on the range's first day only when its month has room before the next 1st; the year on the first label and on January */
52
+ if (D(d).getUTCDate() === 1 || (d === m.start && D(d).getUTCDate() < 20)) { scale += '<span class="tl-mo" style="left:' + x(d) + '%">' + MONTH[D(d).getUTCMonth()] + (D(d).getUTCMonth() === 0 || firstLab ? ' ' + D(d).getUTCFullYear() : '') + '</span>'; firstLab = false }
53
+ if (wd(d) === 0) scale += '<span class="tl-wk" style="left:' + x(d) + '%">' + D(d).getUTCDate() + '</span>', bg += '<i class="tl-vline" style="left:' + x(d) + '%"></i>'
54
+ if (wd(d) === 5) bg += '<i class="tl-weekend" style="left:' + x(d) + '%;width:' + w(d, add(d, 1)) + '%"></i>'
55
+ }
56
+ m.breaks.forEach(([a, b]) => { bg += '<i class="tl-break" style="left:' + x(a) + '%;width:' + w(a, b) + '%"><span>Break</span></i>' })
57
+ if (st.today >= m.start && st.today <= m.end) bg += '<i class="tl-today" style="left:' + (x(st.today) + 50 / total) + '%"><span>Today</span></i>'
58
+ const labels = rows.map((r) => r.kind === 'ms'
59
+ ? '<div class="tl-lab tl-lab-ms" style="height:' + H + 'px"><b>' + esc(r.ms.num) + '</b> ' + esc(r.ms.name) + (r.ms.optional ? ' <span class="tl-tag">Optional</span>' : '') + '</div>'
60
+ : '<button class="tl-lab' + (st.sel === r.p.id ? ' is-sel' : '') + '" data-phase="' + r.p.id + '" style="height:' + H + 'px"><span class="tl-num">' + esc(r.p.num) + '</span>' + esc(r.p.name) + marks(r.p) + '</button>').join('')
61
+ const bars = rows.map((r, k) => {
62
+ const top = k * H + 7
63
+ if (r.kind === 'ms') return '<div class="tl-band ' + msClass(r.i, r.ms) + '" style="top:' + top + 'px;left:' + x(r.ms.start) + '%;width:' + w(r.ms.start, r.ms.end) + '%" title="' + esc(r.ms.num + ' ' + r.ms.name + ' · ' + range(r.ms.start, r.ms.end)) + '"></div>'
64
+ const p = r.p
65
+ const cps = p.items.filter((it) => it.checkpoint && it.date).map((it) => '<span class="tl-cp' + (x(it.date) > 82 ? ' is-left' : '') + '" style="top:' + (top + 2) + 'px;left:' + (x(it.date) + 50 / total) + '%" title="' + esc(day(it.date) + ' · ' + it.text) + '"><b class="tl-dia"></b><em>' + esc(it.text.replace(/^[^:]+:\s*/, '')) + '</em></span>').join('')
66
+ return '<button class="tl-barp ' + msClass(r.i, r.ms) + (st.sel === p.id ? ' is-sel' : '') + '" data-phase="' + p.id + '" style="top:' + top + 'px;left:' + x(p.start) + '%;width:' + w(p.start, p.end) + '%" title="' + esc(p.num + ' ' + p.name + ' · ' + range(p.start, p.end)) + '"></button>' + cps
67
+ }).join('')
68
+ return '<div class="tl-gantt"><div class="tl-ggrid"><div class="tl-gl"><div class="tl-gh">Phase</div>' + labels + '</div>' +
69
+ '<div class="tl-gr"><div class="tl-gh tl-scale">' + scale + '</div><div class="tl-plot" style="height:' + rows.length * H + 'px">' + bg + bars + '</div></div></div></div>'
70
+ }
71
+
72
+ /* ---------- Month: weeks as rows, phases as bars across the days, checkpoints on their day ---------- */
73
+ function month(m, st) {
74
+ const c = D(st.cursor), y = c.getUTCFullYear(), mo = c.getUTCMonth()
75
+ const first = new Date(Date.UTC(y, mo, 1)).toISOString().slice(0, 10)
76
+ const last = new Date(Date.UTC(y, mo + 1, 0)).toISOString().slice(0, 10)
77
+ const all = phases(m)
78
+ let out = '<div class="tl-month"><div class="tl-wdays">' + WD.map((d) => '<span>' + d + '</span>').join('') + '</div>'
79
+ for (let ws = monday(first); ws <= last; ws = add(ws, 7)) {
80
+ const we = add(ws, 6)
81
+ const segs = all.filter((p) => p.start <= we && p.end >= ws).map((p) => ({ p, s: p.start < ws ? ws : p.start, e: p.end > we ? we : p.end }))
82
+ const lanes = []
83
+ segs.forEach((g) => { let l = lanes.findIndex((end) => end < g.s); if (l < 0) { l = lanes.length; lanes.push('') } lanes[l] = g.e; g.lane = l })
84
+ const span = 3 + lanes.length // day row, checkpoint row, the lanes, a closing gap
85
+ let cells = '', cps = ''
86
+ for (let i = 0; i < 7; i++) {
87
+ const d = add(ws, i)
88
+ const cls = ['tl-day', d < first || d > last ? 'is-out' : '', i > 4 ? 'is-we' : '', inBreak(m, d) ? 'is-break' : '', d === st.today ? 'is-today' : ''].filter(Boolean).join(' ')
89
+ cells += '<div class="' + cls + '" style="grid-column:' + (i + 1) + ';grid-row:1 / span ' + span + '"><span class="tl-dn">' + D(d).getUTCDate() + '</span></div>'
90
+ const here = m.checkpoints.filter((k) => k.date === d)
91
+ if (here.length) cps += '<div class="tl-mcp" style="grid-column:' + (i + 1) + ';grid-row:2">' + here.map((k) => '<button data-phase="' + k.phase + '" title="' + esc(k.label) + '"><b class="tl-dia"></b>' + esc(k.label.replace(/^[^:]+:\s*/, '')) + '</button>').join('') + '</div>'
92
+ }
93
+ const bars = segs.map((g) => '<button class="tl-seg ' + msClass(g.p.msi, g.p.ms) + (g.s === g.p.start ? ' is-start' : '') + (g.e === g.p.end ? ' is-end' : '') + (st.sel === g.p.id ? ' is-sel' : '') + '" data-phase="' + g.p.id + '" style="grid-column:' + (wd(g.s) + 1) + ' / ' + (wd(g.e) + 2) + ';grid-row:' + (g.lane + 3) + '" title="' + esc(g.p.num + ' ' + g.p.name + ' · ' + range(g.p.start, g.p.end)) + '"><span>' + esc(g.p.num + ' ' + g.p.name) + '</span></button>').join('')
94
+ out += '<div class="tl-week" style="grid-template-rows:30px auto' + ' auto'.repeat(lanes.length) + ' 8px">' + cells + cps + bars + '</div>'
95
+ }
96
+ return out + '</div>'
97
+ }
98
+
99
+ /* ---------- Week: the seven days with their checkpoints, then what is running ---------- */
100
+ function week(m, st) {
101
+ const ws = monday(st.cursor), we = add(ws, 6)
102
+ let strip = ''
103
+ for (let i = 0; i < 7; i++) {
104
+ const d = add(ws, i)
105
+ const here = m.checkpoints.filter((k) => k.date === d)
106
+ strip += '<div class="tl-wday' + (i > 4 ? ' is-we' : '') + (inBreak(m, d) ? ' is-break' : '') + (d === st.today ? ' is-today' : '') + '"><span class="tl-wdh">' + WD[i] + ' <b>' + D(d).getUTCDate() + '</b></span>' +
107
+ here.map((k) => '<button class="tl-wcp" data-phase="' + k.phase + '"><b class="tl-dia"></b><span>' + esc(k.label) + '</span><em>' + esc(k.num) + '</em></button>').join('') + '</div>'
108
+ }
109
+ const act = phases(m).filter((p) => p.start <= we && p.end >= ws)
110
+ const state = (p) => p.start >= ws ? 'Starts ' + WD[wd(p.start)] + ' ' + day(p.start) : p.end <= we ? 'Ends ' + WD[wd(p.end)] + ' ' + day(p.end) : 'Day ' + workdays(p.start, ws < p.start ? p.start : ws) + ' of ' + workdays(p.start, p.end)
111
+ const list = act.length
112
+ ? act.map((p) => '<button class="tl-act' + (st.sel === p.id ? ' is-sel' : '') + '" data-phase="' + p.id + '"><b class="tl-sw ' + msClass(p.msi, p.ms) + '"></b><span class="tl-act-t"><span class="tl-num">' + esc(p.num) + '</span>' + esc(p.name) + marks(p) + '</span><span class="tl-act-d">' + esc(range(p.start, p.end)) + '</span><span class="tl-act-s">' + esc(state(p)) + '</span>' + (p.acceptance ? '<span class="tl-act-a"><b>Acceptance:</b> ' + esc(p.acceptance) + '</span>' : '') + '</button>').join('')
113
+ : '<p class="tl-empty">' + (inBreak(m, ws) || inBreak(m, we) ? 'Break: no phase runs this week.' : 'No phase runs this week.') + '</p>'
114
+ return '<div class="tl-weekv"><div class="tl-wstrip">' + strip + '</div><h3 class="tl-h">Running this week</h3>' + list + '</div>'
115
+ }
116
+
117
+ /* ---------- Day: one day by hour — what runs all day, then each hour with its timed checkpoints, the Today line at now ---------- */
118
+ const H0 = 7, H1 = 20 // the hours a working day shows; a timed item outside them widens the range
119
+ const hourOf = (t) => (/^(\d{1,2})(?::(\d{2}))?/.exec(t || '') || []).slice(1).map((n) => +(n || 0))
120
+ function dayView(m, st) {
121
+ const d = st.cursor
122
+ const run = phases(m).filter((p) => p.start <= d && p.end >= d)
123
+ const here = m.checkpoints.filter((k) => k.date === d)
124
+ const timed = here.filter((k) => k.time), untimed = here.filter((k) => !k.time)
125
+ const hs = timed.map((k) => hourOf(k.time)[0])
126
+ /* on today the range also reaches the hour now, so the Today line always has a place */
127
+ const nowH = d === st.today && st.now != null ? Math.floor(st.now / 60) : null
128
+ const from = Math.min(H0, ...hs, ...(nowH != null ? [nowH] : [])), to = Math.max(H1, ...hs.map((h) => h + 1), ...(nowH != null ? [nowH + 1] : []))
129
+ const all = '<div class="tl-dall"><span class="tl-dlab">All day</span><div class="tl-dall-b">' +
130
+ (run.length || untimed.length
131
+ ? run.map((p) => '<button class="tl-dseg ' + msClass(p.msi, p.ms) + (st.sel === p.id ? ' is-sel' : '') + '" data-phase="' + p.id + '" title="' + esc(p.num + ' ' + p.name + ' · ' + range(p.start, p.end)) + '"><span>' + esc(p.num + ' ' + p.name) + '</span></button>').join('') +
132
+ untimed.map((k) => '<button class="tl-wcp" data-phase="' + k.phase + '"><b class="tl-dia"></b><span>' + esc(k.label) + '</span><em>' + esc(k.num) + '</em></button>').join('')
133
+ : '<p class="tl-empty">' + (inBreak(m, d) ? 'Break: no phase runs today.' : 'No phase runs this day.') + '</p>') + '</div></div>'
134
+ let rows = ''
135
+ for (let h = from; h < to; h++) {
136
+ const at = timed.filter((k) => hourOf(k.time)[0] === h)
137
+ rows += '<div class="tl-hour"><span class="tl-hl">' + String(h).padStart(2, '0') + ':00</span><div class="tl-hb">' +
138
+ at.map((k) => '<button class="tl-wcp" data-phase="' + k.phase + '"><b class="tl-dia"></b><span>' + esc(k.time + ' · ' + k.label) + '</span><em>' + esc(k.num) + '</em></button>').join('') + '</div></div>'
139
+ }
140
+ const now = d === st.today && st.now != null && st.now >= from * 60 && st.now < to * 60
141
+ ? '<i class="tl-dnow" style="top:calc(' + ((st.now - from * 60) / ((to - from) * 60)) * 100 + '% )"><span>Today</span></i>' : ''
142
+ return '<div class="tl-dayv' + (inBreak(m, d) ? ' is-break' : '') + '">' + all + '<div class="tl-hours">' + rows + now + '</div></div>'
143
+ }
144
+
145
+ function detail(m, st) {
146
+ const p = phases(m).find((q) => q.id === st.sel)
147
+ if (!p) return ''
148
+ return '<aside class="tl-detail"><button class="tl-x" data-close aria-label="Close">×</button>' +
149
+ '<p class="tl-eyebrow">' + esc(p.ms.num + ' ' + p.ms.name) + (p.ms.optional ? ' · Optional' : '') + '</p>' +
150
+ '<h3><span class="tl-num">' + esc(p.num) + '</span>' + esc(p.name) + '</h3>' +
151
+ '<p class="tl-meta"><b>Dates:</b> ' + esc(range(p.start, p.end)) + ' · ' + workdays(p.start, p.end) + ' working days</p>' +
152
+ (p.confirm ? '<p class="tl-meta"><span class="tl-confirm"><i></i>To confirm</span> ' + esc(p.confirm) + '</p>' : '') +
153
+ (p.acceptance ? '<p class="tl-meta"><b>Acceptance:</b> ' + esc(p.acceptance) + '</p>' : '') +
154
+ '<ol class="tl-items">' + p.items.map((it) => '<li><span class="tl-num">' + esc(it.num) + '</span>' + (it.checkpoint ? '<b class="tl-dia"></b>' : '') + esc(it.text) + (it.date ? ' <em>' + esc(WD[wd(it.date)] + ' ' + day(it.date)) + '</em>' : '') + '</li>').join('') + '</ol></aside>'
155
+ }
156
+
157
+ export function renderTimeline(m, st) {
158
+ const nav = st.view === 'timeline' ? '<span class="tl-title">' + esc(dayY(m.first) + ' – ' + dayY(m.last)) + '</span>'
159
+ : '<span class="tl-nav"><button data-nav="-1" aria-label="Previous">‹</button><span class="tl-title">' +
160
+ (st.view === 'month' ? MONTH[D(st.cursor).getUTCMonth()] + ' ' + D(st.cursor).getUTCFullYear() : st.view === 'day' ? WD[wd(st.cursor)] + ' ' + dayY(st.cursor) : 'Week ' + weekNo(st.cursor) + ' · ' + range(monday(st.cursor), add(monday(st.cursor), 6)) + ' ' + D(add(monday(st.cursor), 6)).getUTCFullYear()) +
161
+ '</span><button data-nav="1" aria-label="Next">›</button><button class="tl-todayb" data-nav="0">Today</button></span>'
162
+ const body = st.view === 'month' ? month(m, st) : st.view === 'week' ? week(m, st) : st.view === 'day' ? dayView(m, st) : timeline(m, st)
163
+ return '<div class="tl-bar"><div class="tl-switch" role="group" aria-label="View">' + VIEWS.map(([k, l]) => '<button data-view="' + k + '" aria-pressed="' + (st.view === k) + '">' + l + '</button>').join('') + '</div>' + nav + '</div>' +
164
+ legend(m) + '<div class="tl-body is-' + st.view + (st.sel ? ' has-detail' : '') + '">' + body + detail(m, st) + '</div>'
165
+ }
166
+
167
+ /* the Timeline view alone, static, for print (scripts/timeline-print.mjs): legend and chart, no controls */
168
+ export function printTimeline(m, today) {
169
+ return legend(m) + timeline(m, { today, sel: null })
170
+ }
171
+
172
+ /* the controller: one delegated click handler, state in a closure, the view remembered per viewer */
173
+ export function mountTimeline(root, m, opts = {}) {
174
+ const today = opts.today || new Date().toISOString().slice(0, 10)
175
+ const home = clamp(today, m.first, m.last)
176
+ let saved = null
177
+ try { saved = localStorage.getItem(opts.storageKey ?? 'kol-time-view') } catch { /* storage blocked: start on Timeline */ }
178
+ /* `now` — minutes since midnight, for the Day view's Today line */
179
+ const at = opts.now ? new Date(opts.now) : new Date()
180
+ const st = { view: VIEWS.some(([k]) => k === (opts.view ?? saved)) ? (opts.view ?? saved) : 'timeline', cursor: home, sel: null, today, now: at.getHours() * 60 + at.getMinutes() }
181
+ const draw = () => { root.innerHTML = renderTimeline(m, st) }
182
+ const onClick = (e) => {
183
+ const t = e.target.closest('[data-view],[data-nav],[data-phase],[data-close]')
184
+ if (!t || !root.contains(t)) return
185
+ if (t.dataset.view) { st.view = t.dataset.view; try { localStorage.setItem(opts.storageKey ?? 'kol-time-view', st.view) } catch { /* not remembered */ } }
186
+ else if (t.dataset.nav !== undefined) {
187
+ const n = +t.dataset.nav
188
+ if (n === 0) st.cursor = home
189
+ else if (st.view === 'month') { const d = D(st.cursor); d.setUTCDate(1); d.setUTCMonth(d.getUTCMonth() + n); st.cursor = clamp(d.toISOString().slice(0, 10), m.first.slice(0, 8) + '01', m.last) }
190
+ else if (st.view === 'day') st.cursor = clamp(add(st.cursor, n), m.start, m.end)
191
+ else st.cursor = clamp(add(st.cursor, 7 * n), monday(m.first), m.last)
192
+ }
193
+ else if (t.dataset.phase) st.sel = st.sel === t.dataset.phase ? null : t.dataset.phase
194
+ else if (t.dataset.close !== undefined) st.sel = null
195
+ draw()
196
+ }
197
+ root.classList.add('tl')
198
+ root.addEventListener('click', onClick)
199
+ draw()
200
+ return () => root.removeEventListener('click', onClick)
201
+ }
@@ -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
+ }