@kolkrabbi/kol-component 0.296.0 → 0.298.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.296.0",
3
+ "version": "0.298.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,7 +24,9 @@ import useGrabEdge from './useGrabEdge.js'
24
24
  *
25
25
  * - CLICK TOGGLES expand↔collapse: pointerup with < 3px of travel is a
26
26
  * click, never a resize — drags only start past the slop, so toggle
27
- * presses can't jitter the rail.
27
+ * presses can't jitter the rail. Expanding by a press lands on the
28
+ * stylesheet's rung for the viewport, not a remembered drag width
29
+ * (2026-10-24).
28
30
  * - DRAG resizes; live width goes to --kol-sidenav-w on :root so the grid,
29
31
  * shell-header brand block and aside follow one number. Dragging under
30
32
  * --kol-sidenav-snap stamps :root[data-sidenav="collapsed"].
@@ -189,6 +191,10 @@ export default function useDragResize(ref, options = {}) {
189
191
  const toggleCollapsed = () => {
190
192
  const { collapsed: c } = readBack(names)
191
193
  stampCollapsed(names, !c)
194
+ /* EXPANDING BY A PRESS LANDS ON THE RUNG (user 2026-10-24: "clicking the rail when collapsed should go to
195
+ * that default"): the stylesheet's width for this viewport (264 · 320 from 1536), never a remembered drag
196
+ * width — the override is cleared, and persisted as cleared */
197
+ if (c) writeWidth(names, null)
192
198
  syncAndPersist()
193
199
  }
194
200
 
package/src/index.js CHANGED
@@ -105,6 +105,7 @@ export { default as CodeBlock } from './molecules/CodeBlock.jsx'
105
105
  export { default as ColorInputRow } from './molecules/ColorInputRow.jsx'
106
106
  export { default as ColorRamp } from './molecules/ColorRamp.jsx'
107
107
  export { default as TextFold } from './molecules/TextFold.jsx'
108
+ export { default as PageControls } from './molecules/PageControls.jsx'
108
109
  export { default as ColorSwatch } from './molecules/ColorSwatch.jsx'
109
110
  export { default as Dropdown } from './molecules/Dropdown.jsx'
110
111
  /* MultiSelect — several pick-one settings in one dropdown, a column each (2026-10-01, first cut) */
@@ -68,20 +68,25 @@ const placeholder = (
68
68
  * cover's other corner and reads in the rail. Always runs the same hooks (one
69
69
  * context read), so ContentCard / ContentRow call it unconditionally.
70
70
  */
71
- export function useAppItem(variant, { title, verbs, download, menuItems, date, size, media, tone, tags, details, onTags, note, onNote, mark }) {
71
+ export function useAppItem(variant, { title, verbs, download, menuItems, date, size, media, tone, tags, details, onTags, note, onNote, mark, onCover, onInsert, row = false }) {
72
72
  const ctx = useContext(MenuCtx)
73
73
  if (variant !== 'app') return null
74
74
  const menu = ctx?.menu
75
75
  const hasMenu = !!menu && !!(verbs?.rename || verbs?.duplicate || verbs?.remove || menuItems)
76
76
  const openMenu = hasMenu ? (e) => menu.openAt(e, { name: title, verbs, menuItems }) : undefined
77
- /* the cog opens the file's info rail (user ruling 2026-10-23); right-click keeps the menu */
78
- const openInfo = ctx ? () => ctx.openInfo({ name: title, verbs, download, tags, details, onTags, note, onNote, mark }) : undefined
77
+ /* the card's date and size, as text — the rail prints the same two under Details (user 2026-10-24: *"why is date
78
+ * and size not included in file info?"*) */
79
+ const dateText = typeof date === 'number' ? new Date(date).toISOString().slice(0, 10) : date
80
+ const sizeText = typeof size === 'number' ? formatSize(size) : size
81
+ /* the cog opens the file's info rail (user ruling 2026-10-23); right-click keeps the menu. `onCover(src)` is the
82
+ * rail's Upload image (2026-10-24) */
83
+ const openInfo = ctx ? () => ctx.openInfo({ name: title, verbs, download, tags, details, onTags, note, onNote, mark, date: dateText, size: sizeText, onCover }) : undefined
79
84
  /* the cover's download stops its click at the control, as the plate does — a card that opens on click
80
85
  * opened under the download too (AppCardDownloadClickBubbles, kol-monitor 2026-10-23) */
81
86
  return {
82
87
  tone: tone ?? 'secondary',
83
- date: typeof date === 'number' ? new Date(date).toISOString().slice(0, 10) : date,
84
- size: typeof size === 'number' ? formatSize(size) : size,
88
+ date: dateText,
89
+ size: sizeText,
85
90
  media: typeof media === 'string' ? <img src={media} alt={title ?? ''} className="size-full object-cover" /> : media ?? placeholder,
86
91
  control: download ? <ActionButton chrome="media" icon="download" confirmIcon="check" label="Download" confirmLabel="Downloaded" onAction={(e) => { e?.stopPropagation(); return download(e) }} /> : undefined,
87
92
  /* THE MARK (user 2026-10-24, FXR's files: *"show together with a label on the card … an icon of each chrome as an
@@ -95,8 +100,18 @@ export function useAppItem(variant, { title, verbs, download, menuItems, date, s
95
100
  <span className="kol-action-glyph inline-grid place-items-center" style={{ width: 20, height: 20 }}><Icon name={mark.icon} size={20} /></span>
96
101
  </span>
97
102
  </Tooltip>
103
+ /* INSERT ON A CARD (StudioCreate's parts, 2026-10-24 — every card the same fields and icons, so a part keeps its plate):
104
+ * the cover's other corner, in the download's box — a mark and Insert never meet (a part carries no mark) */
105
+ ) : onInsert && !row ? (
106
+ <ActionButton chrome="media" icon="plus" confirmIcon="check" label="Insert" confirmLabel="Inserted" onAction={(e) => { e?.stopPropagation(); return onInsert(e) }} />
107
+ ) : undefined,
108
+ /* the plate — cog over trash; on a row, Insert sits before the plate (the row has no cover corner to spare) */
109
+ actions: openInfo || verbs?.remove || (onInsert && row) ? (
110
+ <div className="flex h-full items-stretch gap-2">
111
+ {onInsert && row && <div className="flex items-center" onClick={(e) => e.stopPropagation()}><ActionButton chrome="inline" size="sm" icon="plus" confirmIcon="check" label="Insert" confirmLabel="Inserted" onAction={(e) => { e?.stopPropagation(); return onInsert(e) }} /></div>}
112
+ {(openInfo || verbs?.remove) && <AppPlate name={title} verbs={verbs} onSettings={openInfo} />}
113
+ </div>
98
114
  ) : undefined,
99
- actions: openInfo || verbs?.remove ? <AppPlate name={title} verbs={verbs} onSettings={openInfo} /> : undefined,
100
115
  onContextMenu: openMenu,
101
116
  }
102
117
  }
@@ -131,8 +131,12 @@ const MEDIA = {
131
131
  showcase: { zoom: true },
132
132
  /* frame OFF by default (ListingCardThumbBorder, user 2026-08-27: "I hate
133
133
  * border — remove border"): the article thumb's hairline is opt-in —
134
- * `frame` turns it on, and with it the fg-08 → fg-16 hover step */
135
- article: { frame: false, borderHover: true, zoom: true },
134
+ * `frame` turns it on, and with it the fg-08 → fg-16 hover step.
135
+ * ZOOM OFF (user 2026-10-24, site-hub W4: "an annoying habit of using article
136
+ * contentcard with a stupid zoom on hover"): a page link is not image-led —
137
+ * the thumb stays put, as the app card's hover fill went (2026-10-23). `zoom`
138
+ * stays an opt-in prop; the hero rung is hero's own. */
139
+ article: { frame: false, borderHover: true, zoom: false },
136
140
  }
137
141
 
138
142
  /* VARIANTS ARE CONTENT KINDS, NEVER PAGE NAMES (user ruling 2026-08-29:
@@ -213,8 +217,8 @@ export default function ContentCard({
213
217
  /* `app` (CatalogAppVariant, kol-fxr 2026-10-23) is the `file` card with its parts slotted from
214
218
  * `verbs`, `download`, `menuItems`, and `tags`, `details`, `onTags` for the info rail — AppItem.jsx.
215
219
  * None of them reach ContentText; an app card's `tags` are the rail's, never chips on the plate. */
216
- const app = useAppItem(variantProp, { title: text.title, verbs: text.verbs, download: text.download, menuItems: text.menuItems, date: text.date, size: text.size, media, tone, tags: text.tags, details: text.details, onTags: text.onTags, note: text.note, onNote: text.onNote, mark: text.mark })
217
- delete text.verbs; delete text.download; delete text.menuItems; delete text.details; delete text.onTags; delete text.note; delete text.onNote; delete text.mark
220
+ const app = useAppItem(variantProp, { title: text.title, verbs: text.verbs, download: text.download, menuItems: text.menuItems, date: text.date, size: text.size, media, tone, tags: text.tags, details: text.details, onTags: text.onTags, note: text.note, onNote: text.onNote, mark: text.mark, onCover: text.onCover, onInsert: text.onInsert })
221
+ delete text.verbs; delete text.download; delete text.menuItems; delete text.details; delete text.onTags; delete text.note; delete text.onNote; delete text.mark; delete text.onCover; delete text.onInsert
218
222
  if (app) {
219
223
  delete text.tags
220
224
  variantProp = 'file'
@@ -196,8 +196,8 @@ export default function ContentRow({
196
196
  /* `app` (CatalogAppVariant, kol-fxr 2026-10-23) is the `file` row with its parts slotted from
197
197
  * `verbs`, `download`, `menuItems`, and `tags`, `details`, `onTags` for the info rail — AppItem.jsx.
198
198
  * None of them reach ContentText; an app row's `tags` are the rail's, never chips in the row. */
199
- const app = useAppItem(variantProp, { title: text.title, verbs: text.verbs, download: text.download, menuItems: text.menuItems, date: text.date, size: text.size, media, tone, tags: text.tags, details: text.details, onTags: text.onTags, note: text.note, onNote: text.onNote, mark: text.mark })
200
- delete text.verbs; delete text.download; delete text.menuItems; delete text.details; delete text.onTags; delete text.note; delete text.onNote; delete text.mark
199
+ const app = useAppItem(variantProp, { title: text.title, verbs: text.verbs, download: text.download, menuItems: text.menuItems, date: text.date, size: text.size, media, tone, tags: text.tags, details: text.details, onTags: text.onTags, note: text.note, onNote: text.onNote, mark: text.mark, onCover: text.onCover, onInsert: text.onInsert, row: true })
200
+ delete text.verbs; delete text.download; delete text.menuItems; delete text.details; delete text.onTags; delete text.note; delete text.onNote; delete text.mark; delete text.onCover; delete text.onInsert
201
201
  if (app) {
202
202
  delete text.tags
203
203
  variantProp = 'file'
@@ -0,0 +1,69 @@
1
+ import Tag from '../atoms/Tag.jsx'
2
+ import SegmentedToggle from '../atoms/SegmentedToggle.jsx'
3
+ import TabsRow from './TabsRow.jsx'
4
+
5
+ /* taxonomy-ok: molecule — composes Tag, SegmentedToggle (atoms) and TabsRow (a molecule of chips) into one strip */
6
+
7
+ /**
8
+ * PageControls — The page's own controls, one strip. the controls a PAGE carries for itself — which series show,
9
+ * which view, where to jump, what the dots mean, how many are showing — in one sticky strip under the page
10
+ * header, every page the same (site-hub W4, user 2026-10-24: kol-branding's Compare and Moods carried the same
11
+ * five pieces in two orders, each page hand-laying its own sticky bar). Not content filters: `ContentFilters`
12
+ * narrows a COLLECTION by its facets; this strip drives the page's rendering.
13
+ *
14
+ * The slots, in the order they are drawn — an empty slot is not there:
15
+ * row 1 toggles · views · count the series chips (Tag), the view switches (SegmentedToggle), the readout
16
+ * row 2 jump the section tabs (TabsRow look="chip"), scrolling sideways when long
17
+ * row 3 legend a dot and a name per series, as many columns as series
18
+ *
19
+ * STICKY by default: `sticky top-0` on the page's z-sticky rung, a hairline under it, the surface painted so the
20
+ * page scrolls beneath — kol-branding's StickyBar line, carried. The host page gives it the page's horizontal
21
+ * edge (a `kol-shell-page-bleed` in the app shell, nothing on a site plane).
22
+ *
23
+ * @param {Object} [toggles] `{ label, items: [{ id, label, active }], onToggle(id) }` — Tag chips, pressed = showing
24
+ * @param {Array} [views] `[{ label, value, onChange, options: [{ value, label }] }]` — one SegmentedToggle each
25
+ * @param {ReactNode}[count] the readout on the row's right (`15 / 15`)
26
+ * @param {Object} [jump] `{ label, value, onChange, tabs: [{ id, label }] }` — TabsRow chips
27
+ * @param {Array} [legend] `[{ id, label, color }]` — a dot (`color`, a CSS color) and a name per series
28
+ * @param {boolean} [sticky=true]
29
+ * @param {string} [className]
30
+ */
31
+ export default function PageControls({ toggles, views = [], count, jump, legend, sticky = true, className = '' }) {
32
+ const rowOne = toggles || views.length > 0 || count != null
33
+ return (
34
+ <div
35
+ className={`${sticky ? 'md:sticky top-0 z-[calc(var(--kol-z-sticky)-1)]' : ''} flex flex-col gap-3 border-b border-fg-08 bg-surface-primary bg-[linear-gradient(var(--kol-shell-page-wash,transparent),var(--kol-shell-page-wash,transparent))] py-3 ${className}`.replace(/\s+/g, ' ').trim()}
36
+ >
37
+ {rowOne && (
38
+ <div className="flex flex-wrap items-center gap-x-6 gap-y-3">
39
+ {toggles && (
40
+ <div className="flex flex-wrap items-center gap-2" role="group" aria-label={toggles.label}>
41
+ {toggles.items.map((t) => (
42
+ <Tag key={t.id} hash={false} active={t.active} onClick={() => toggles.onToggle(t.id)}>{t.label}</Tag>
43
+ ))}
44
+ </div>
45
+ )}
46
+ {views.map((v) => (
47
+ <SegmentedToggle key={v.label} ariaLabel={v.label} size="sm" value={v.value} onChange={v.onChange} options={v.options} />
48
+ ))}
49
+ {count != null && <span className="kol-mono-12 text-fg-48 ml-auto">{count}</span>}
50
+ </div>
51
+ )}
52
+ {jump && (
53
+ <div className="overflow-x-auto">
54
+ <TabsRow look="chip" size="sm" ariaLabel={jump.label} value={jump.value} onChange={jump.onChange} tabs={jump.tabs} />
55
+ </div>
56
+ )}
57
+ {legend && legend.length > 0 && (
58
+ <div className="grid grid-cols-1 gap-4 xl:[grid-template-columns:var(--cols)]" style={{ '--cols': `repeat(${legend.length}, minmax(0, 1fr))` }}>
59
+ {legend.map((l) => (
60
+ <span key={l.id} className="flex items-center gap-2 min-w-0">
61
+ <span className="h-2.5 w-2.5 flex-none rounded-full border border-fg-24" style={{ background: l.color }} aria-hidden="true" />
62
+ <span className="kol-mono-12 truncate">{l.label}</span>
63
+ </span>
64
+ ))}
65
+ </div>
66
+ )}
67
+ </div>
68
+ )
69
+ }
@@ -6,7 +6,9 @@ import Tag from '../atoms/Tag.jsx'
6
6
  import Input from '../atoms/Input.jsx'
7
7
  import Textarea from '../atoms/Textarea.jsx'
8
8
  import IconFrame from '../atoms/IconFrame.jsx'
9
+ import Button from '../atoms/Button.jsx'
9
10
  import { Tooltip } from '../utilities/Popover.jsx'
11
+ import { pickImage } from '../utilities/imageToDataUrl.js'
10
12
  import SettingsPanel, { SettingsFooter } from './SettingsPanel.jsx'
11
13
  import SettingsSections from './SettingsSections.jsx'
12
14
 
@@ -27,6 +29,11 @@ import SettingsSections from './SettingsSections.jsx'
27
29
  * READ AND EDIT (user 2026-10-23): the rail opens read-only — name, tags, note, details as text — and the pencil on its
28
30
  * header line (Create's rename glyph, `IconFrame nav`) toggles edit mode. `note` / `onNote` arrived the same day: a plain
29
31
  * description on a file, HubHome's `note` and `onNote(file, text)`.
32
+ *
33
+ * DATE · SIZE · COVER (user 2026-10-24: *"why is date and size not included in file info? same with upload image?"* ·
34
+ * *"why is edit 32px icon when others are 26px??"*): Details opens with the card's own Date and Size; in edit mode a
35
+ * Cover row offers Upload image — the DS picker, a webp data URL, handed to the file's `onCover(src)` (HubHome's
36
+ * `onCover(file, src)`); and the pencil is the rows' `sm` frame (26), as the × beside it.
30
37
  */
31
38
  /* the rail's body — READ MODE by default, the header's pencil opens EDIT MODE (user 2026-10-23: *"use the same edit icon
32
39
  * from create? to edit mode or read mode?"*): read shows the name, the tag chips and the note as text; edit swaps in the
@@ -34,7 +41,7 @@ import SettingsSections from './SettingsSections.jsx'
34
41
  * stays while the consumer's state catches up. ONE row per field, no section label over a lone row of the same name
35
42
  * (user 2026-10-23: the rail read NAME / NAME, TAGS / TAGS / ADD). */
36
43
  function FileRailBody({ item, editing, onRenamed }) {
37
- const { name, verbs, tags, details, note, onTags, onNote, mark } = item
44
+ const { name, verbs, tags, details, note, onTags, onNote, mark, date, size, onCover } = item
38
45
  const [draftName, setDraftName] = useState(name ?? '')
39
46
  const [draftTags, setDraftTags] = useState(tags ?? [])
40
47
  const [newTag, setNewTag] = useState('')
@@ -80,11 +87,18 @@ function FileRailBody({ item, editing, onRenamed }) {
80
87
  ...((editNote || draftNote.trim()) ? [editNote
81
88
  ? { label: 'Note', align: 'fill', render: () => <Textarea size="sm" rows={3} value={draftNote} onChange={(e) => setDraftNote(e.target.value)} onBlur={commitNote} placeholder="Add a note" aria-label="Note" /> }
82
89
  : { label: 'Note', text: true, value: text(draftNote.trim(), 'text-right') }] : []),
90
+ /* edit mode: the cover — Upload image hands the DS picker's data URL to `onCover` (2026-10-24) */
91
+ ...((editing && onCover) ? [{ label: 'Cover', align: 'fill', render: () => (
92
+ <Button size="sm" tone="grey" onClick={async () => { const src = await pickImage(); if (src) onCover(src) }}>Upload image</Button>
93
+ ) }] : []),
83
94
  ]
84
95
  const sections = [
85
96
  { rows },
86
- ...((mark || details?.length) ? [{ label: 'Details', rows: [
87
- /* the mark first — FXR's chrome: Chrome, Editor (`of` names the axis; `label` the value) */
97
+ ...((date || size || mark || details?.length) ? [{ label: 'Details', rows: [
98
+ /* the card's own date and size first (user 2026-10-24) */
99
+ ...(date ? [{ label: 'Date', text: true, value: text(date) }] : []),
100
+ ...(size ? [{ label: 'Size', text: true, value: text(size) }] : []),
101
+ /* then the mark — FXR's chrome: Chrome, Editor (`of` names the axis; `label` the value) */
88
102
  ...(mark ? [{ label: mark.of ?? 'Kind', text: true, value: text(mark.label) }] : []),
89
103
  ...(details ?? []).map(({ label, value }) => ({ label, text: true, value: text(value) })),
90
104
  ] }] : []),
@@ -115,7 +129,7 @@ export default function AppItemMenuProvider({ children }) {
115
129
  const [info, setInfo] = useState(null)
116
130
  const [editing, setEditing] = useState(false)
117
131
  const close = () => setInfo(null)
118
- const editable = !!(info?.verbs?.rename || info?.onTags || info?.onNote)
132
+ const editable = !!(info?.verbs?.rename || info?.onTags || info?.onNote || info?.onCover)
119
133
  return (
120
134
  /* each open is stamped, so the rail keeps its drafts across a rename (the key no longer follows the name) and the
121
135
  * foot's Delete confirm names the file as renamed, not as opened */
@@ -133,8 +147,9 @@ export default function AppItemMenuProvider({ children }) {
133
147
  </ContextMenu>
134
148
  <SettingsPanel
135
149
  open={!!info} variant="rail" title="File" onClose={close} footer={info ? fileRailFoot(info, ask, close) : undefined}
136
- /* the pencil — bare, as Create's rename and the catalog's filter and search are (IconFrame nav, 16 in the 32 box) */
137
- headerActions={editable ? <IconFrame name="edit" variant="nav" size="md" iconSize={16} onClick={() => setEditing((v) => !v)} aria-label={editing ? 'Done editing' : 'Edit'} /> : undefined}
150
+ /* the pencil — bare, as Create's rename is; the rows' `sm` frame (26), the same box as the × beside it (user
151
+ * 2026-10-24: *"why is edit 32px icon when others are 26px??"*) */
152
+ headerActions={editable ? <IconFrame name="edit" variant="nav" size="sm" onClick={() => setEditing((v) => !v)} aria-label={editing ? 'Done editing' : 'Edit'} /> : undefined}
138
153
  >
139
154
  {/* `key` resets the drafts per file */}
140
155
  {info && <FileRailBody key={info.openId} item={info} editing={editing} onRenamed={(name) => setInfo((i) => i && { ...i, name })} />}
@@ -24,6 +24,13 @@ import useDragResize from '../hooks/useDragResize.js'
24
24
  * and no `pages` (Home) renders as a plain link row — it has nothing to
25
25
  * disclose.
26
26
  *
27
+ * THE FOLDERNOTE (user 2026-10-24, site-hub: "make a prop so you can choose if
28
+ * you want to make the category a clickable page. this is how its set in
29
+ * kol-branding"): a category with `to` AND `pages` is a page of its own — its
30
+ * row is a link that opens the page and discloses the pages under it; the
31
+ * caret alone toggles the disclosure without navigating. Lit by its own route
32
+ * or any page beneath. No `to` = the disclosure button it always was.
33
+ *
27
34
  * The 2026-08-01 "TWO LEVELS ONLY" ruling was the BRAND APP's, about its
28
35
  * scroll-spied `#anchor` section layer — that layer stays dead (an `{ id }`
29
36
  * leaf is dropped). It was inscribed here as a law for every consumer, and
@@ -107,9 +114,12 @@ import useDragResize from '../hooks/useDragResize.js'
107
114
  * `themeToggle` `false` drops the theme slot (default `true`)
108
115
  * `iconComponent` the hop glyph's renderer, kol-shell's seam — `(props:
109
116
  * { name, size }) => element`; default the DS `Icon`
110
- * `expandOnSelect` `false` keeps the rail collapsed when a row navigates or
111
- * dispatches — an app rail stays a rail. Default `true`, the
112
- * brand ruling ("pressing any icon would expand the sidebar")
117
+ * `expandOnSelect` `true` expands the rail when a row navigates, dispatches
118
+ * or discloses from the collapsed state. Default `false`
119
+ * (user 2026-10-24: "dont auto expand rail when you click an
120
+ * icon when its collapsed" — reversing the 2026-08-09 brand
121
+ * ruling "pressing any icon would expand the sidebar"): a
122
+ * collapsed rail stays collapsed, the press does its job
113
123
  * `defaultCollapsed` boots collapsed when nothing is stored (useDragResize)
114
124
  * `background` (2026-08-09, prop): `true` (default) paints the rail surface;
115
125
  * `false` renders chromeless so the rail can float over a consumer's media
@@ -119,12 +129,13 @@ import useDragResize from '../hooks/useDragResize.js'
119
129
  */
120
130
 
121
131
  const pageBase =
122
- 'kol-sidenav-link kol-helper-10 block relative py-[4px] pl-14 pr-6 no-underline transition-colors duration-150'
132
+ 'kol-sidenav-link kol-helper-10 block relative py-[4px] pl-[calc(var(--kol-pad-chrome-x)+2rem)] pr-6 no-underline transition-colors duration-150'
123
133
 
124
134
  /* The active-dot pseudo-element is positioned by `--kol-sidenav-dot-left`
125
- * (kol-components-atoms.css). The page row indents 3.5rem (pl-14); the dot
126
- * sits 0.875rem inside that, in the gutter the icon column leaves. */
127
- const pageStyle = { '--kol-sidenav-dot-left': '2.625rem' }
135
+ * (kol-components-atoms.css). The page row indents one step past the chrome inset
136
+ * (`--kol-pad-chrome-x` + the icon column + the gap, 2026-10-24 — it was a literal
137
+ * 3.5rem); the dot sits 0.875rem inside that, in the gutter the icon column leaves. */
138
+ const pageStyle = { '--kol-sidenav-dot-left': 'calc(var(--kol-pad-chrome-x) + 1.125rem)' }
128
139
  /* Category and page must not share a stop: category `emphasis`, page `strong`
129
140
  * — two rungs of one ladder, so the tree reads as hierarchy (elder ruling). */
130
141
  const pageCls = `${pageBase} text-strong hover:text-emphasis`
@@ -140,7 +151,18 @@ const leavesOf = (rows) => rows.flatMap((r) => (r.children ? leavesOf(rowsOf(r.c
140
151
  /* A nested row sits one --kol-spacing-3 step further in per depth. Inline,
141
152
  * not a rule: `pl-14` rides the leaf as a utility and outranks anything in
142
153
  * this layer. Depth 0 carries no indent so a flat tree renders unchanged. */
143
- const indentOf = (depth) => `calc(3.5rem + ${depth} * var(--kol-spacing-3))`
154
+ const indentOf = (depth) => `calc(var(--kol-pad-chrome-x) + 2rem + ${depth} * var(--kol-spacing-3))`
155
+
156
+ /* the route leaf is always an `<a href>` handing the route to `onNavigate(event, to)` — the
157
+ * router lives in the consumer (kol-framework's `SideNav` wraps this with react-router). A
158
+ * modified click (cmd, ctrl, shift, middle) is left to the browser, as a NavLink left it.
159
+ * Hoisted out of the component so its identity is stable across renders (see `leafProps`). */
160
+ function RouteLeaf({ to, href, active, onNavigate, className, style, children, onPress }) {
161
+ return (
162
+ <a href={href} style={style} className={className(active)} aria-current={active ? 'page' : undefined}
163
+ onClick={(e) => { if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return; e.preventDefault(); onPress?.(); onNavigate(e, to) }}>{children}</a>
164
+ )
165
+ }
144
166
 
145
167
  export default function NavRailSite({
146
168
  currentPath: pathname = '',
@@ -164,7 +186,7 @@ export default function NavRailSite({
164
186
  footer,
165
187
  themeToggle = true,
166
188
  iconComponent,
167
- expandOnSelect = true,
189
+ expandOnSelect = false,
168
190
  defaultCollapsed = false,
169
191
  }) {
170
192
  const Glyph = iconComponent ?? Icon
@@ -190,16 +212,11 @@ export default function NavRailSite({
190
212
  setOpenPanel(null)
191
213
  if (collapsed && expandOnSelect) toggleCollapsed()
192
214
  }
193
- /* the route leaf is always an `<a href>` handing the route to `onNavigate(event, to)` — the
194
- * router lives in the consumer (kol-framework's `SideNav` wraps this with react-router). A
195
- * modified click (cmd, ctrl, shift, middle) is left to the browser, as a NavLink left it. */
196
- const RouteLeaf = ({ to, className, style, children }) => {
197
- const active = isPageActive(to)
198
- return (
199
- <a href={hrefFor ? hrefFor(to) : to} style={style} className={className(active)} aria-current={active ? 'page' : undefined}
200
- onClick={(e) => { if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return; e.preventDefault(); handleNavigate(e, to) }}>{children}</a>
201
- )
202
- }
215
+ /* what a route leaf needs from this render — `RouteLeaf` itself is hoisted above the component
216
+ * (2026-10-24): declared in here it was a NEW component type every render, so React threw every
217
+ * row's DOM away and rebuilt it on each toggle, disclosure or route — the rail flashed and lost
218
+ * hover and focus on the collapse. */
219
+ const leafProps = (to) => ({ to, href: hrefFor ? hrefFor(to) : to, active: isPageActive(to), onNavigate: handleNavigate })
203
220
 
204
221
  /* Which categories are disclosed. INDEPENDENT per category (elder ruling
205
222
  * 2026-08-01) — arriving somewhere must not silently close wherever you
@@ -249,11 +266,14 @@ export default function NavRailSite({
249
266
  * up the way a category does — when one of its leaves is the current route. */
250
267
  const renderRows = (rows, depth) => rows.map((row, i) => {
251
268
  if (row.children) {
252
- const lit = leavesOf(rowsOf(row.children)).some(isLeafActive)
253
269
  return (
254
270
  <li key={row.id ?? `${row.label}-${i}`}>
255
271
  <div
256
- className={`kol-sidenav-group kol-helper-10${lit ? ' text-emphasis' : ' text-subtle'}`}
272
+ /* UPPERCASE (user 2026-10-24, the another-creation reference: "look at uppercase sections") — the fork's
273
+ * `uppercase` utility returns, as the reference carries it; the group is a section label in the rows' voice.
274
+ * ONE INK (user 2026-10-24: "just keep them same opacity"): the label never lights — the row's dot says
275
+ * which row is active, and a label that brightened said it twice. */
276
+ className="kol-sidenav-group kol-helper-10 uppercase text-subtle"
257
277
  style={depth ? { paddingLeft: indentOf(depth) } : undefined}
258
278
  >
259
279
  {row.label}
@@ -263,7 +283,9 @@ export default function NavRailSite({
263
283
  )
264
284
  }
265
285
  /* the dot keeps its 0.875rem lead on the text at every depth */
266
- const leafStyle = depth ? { paddingLeft: indentOf(depth), '--kol-sidenav-dot-left': `calc(2.625rem + ${depth} * var(--kol-spacing-3))` } : pageStyle
286
+ /* a row under a group sits 2px further in than the step, dot and text together, so the dot's edge lines up under
287
+ * the group label's first letter (user 2026-10-24: "just indent the dot+text by 2px to right") */
288
+ const leafStyle = depth ? { paddingLeft: `calc(${indentOf(depth)} + 2px)`, '--kol-sidenav-dot-left': `calc(var(--kol-pad-chrome-x) + 1.125rem + 2px + ${depth} * var(--kol-spacing-3))` } : pageStyle
267
289
  if (row.onSelect) {
268
290
  return (
269
291
  <li key={row.id ?? `${row.label}-${i}`}>
@@ -281,7 +303,7 @@ export default function NavRailSite({
281
303
  }
282
304
  return (
283
305
  <li key={row.to}>
284
- <RouteLeaf to={row.to} style={leafStyle} className={(active) => (active ? pageActiveCls : pageCls)}>
306
+ <RouteLeaf {...leafProps(row.to)} style={leafStyle} className={(active) => (active ? pageActiveCls : pageCls)}>
285
307
  {row.label}
286
308
  </RouteLeaf>
287
309
  </li>
@@ -293,6 +315,8 @@ export default function NavRailSite({
293
315
  const pages = pagesOf(cat)
294
316
  const isOpen = openCats.has(cat.id)
295
317
  const isLink = !pages.length && cat.to
318
+ /* the FOLDERNOTE: a category that is a page of its own (`to` with `pages`) */
319
+ const isFolder = pages.length > 0 && !!cat.to
296
320
  const isPanel = !pages.length && !cat.to && !!cat.panel
297
321
  const isAction = !pages.length && !cat.to && !isPanel && cat.onSelect
298
322
  /* THE COLLAPSE RULE: no icon, no route, no action = a LABEL over
@@ -318,8 +342,28 @@ export default function NavRailSite({
318
342
  /* A category is a <button>, not a link — it has no route by
319
343
  definition, and an <a href> would promise a page that does
320
344
  not exist. Clicking it discloses its pages. */
321
- const head = isLink ? (
322
- <RouteLeaf to={cat.to} className={(active) => `${rowCls}${active ? ' is-active' : ''}`}>
345
+ const head = isFolder ? (
346
+ /* the row opens the page and discloses; the caret beside it (a sibling — a button cannot sit
347
+ * inside a link) toggles the disclosure alone */
348
+ <>
349
+ <RouteLeaf {...leafProps(cat.to)} onPress={() => discloseCat(cat.id)} className={(active) => `${rowCls}${(active || isActiveCat(cat)) ? ' is-active' : ''}`}>
350
+ {glyph}
351
+ <span className="kol-sidenav-hop-label flex-1 min-w-0">{cat.label}</span>
352
+ </RouteLeaf>
353
+ <button
354
+ type="button"
355
+ /* no display utility on the caret — it would outrank the collapsed rule's display:none (the 2026-08-09 defect; the
356
+ * box lives in .kol-sidenav-hop-caret, kol-framework.css) */
357
+ className={`kol-sidenav-hop-caret bg-transparent border-0 cursor-pointer p-0 text-emphasis${isOpen ? '' : ' -rotate-90'}`}
358
+ aria-expanded={isOpen}
359
+ aria-label={isOpen ? `Collapse ${cat.label}` : `Expand ${cat.label}`}
360
+ onClick={() => (collapsed ? (expandOnSelect && toggleCollapsed(), discloseCat(cat.id)) : toggleCat(cat.id))}
361
+ >
362
+ <Icon name="chevron-down" size={12} />
363
+ </button>
364
+ </>
365
+ ) : isLink ? (
366
+ <RouteLeaf {...leafProps(cat.to)} className={(active) => `${rowCls}${active ? ' is-active' : ''}`}>
323
367
  {glyph}
324
368
  <span className="kol-sidenav-hop-label flex-1 min-w-0">{cat.label}</span>
325
369
  </RouteLeaf>
@@ -354,7 +398,7 @@ export default function NavRailSite({
354
398
  * an expand that lands on a closed tree. */
355
399
  onClick={() => {
356
400
  if (collapsed) {
357
- toggleCollapsed()
401
+ if (expandOnSelect) toggleCollapsed()
358
402
  discloseCat(cat.id)
359
403
  } else {
360
404
  toggleCat(cat.id)
@@ -366,7 +410,7 @@ export default function NavRailSite({
366
410
  {/* plain wrapper span — Icon stamps inline-flex on its own
367
411
  * element, which would outrank the rail's display:none */}
368
412
  <span
369
- className={`kol-sidenav-hop-caret transition-transform duration-150${isOpen ? '' : ' -rotate-90'}`}
413
+ className={`kol-sidenav-hop-caret${isOpen ? '' : ' -rotate-90'}`}
370
414
  aria-hidden="true"
371
415
  >
372
416
  <Icon name="chevron-down" size={12} />
@@ -377,11 +421,12 @@ export default function NavRailSite({
377
421
  <li key={cat.id} className="relative">
378
422
  {/* Collapsed rail hides the label — the tooltip is the only
379
423
  thing naming the row. Portalled, so overflow can't clip it. */}
380
- {collapsed ? (
381
- <Tooltip label={cat.label} placement="right" triggerClassName="block">
382
- {head}
383
- </Tooltip>
384
- ) : head}
424
+ {/* ONE TREE IN BOTH STATES (2026-10-24, the clip model): the Tooltip wraps the row expanded too,
425
+ disabled — wrapping only when collapsed rebuilt every row on the toggle, losing hover and
426
+ focus and flashing the rail. Portalled, so overflow can't clip it. */}
427
+ <Tooltip label={cat.label} placement="right" triggerClassName="block" disabled={!collapsed}>
428
+ {head}
429
+ </Tooltip>
385
430
 
386
431
  {!isLink && !isAction && !isPanel && isOpen && (
387
432
  <ul className="kol-sidenav-list">{renderRows(pages, 0)}</ul>
@@ -420,8 +465,8 @@ export default function NavRailSite({
420
465
  </nav>
421
466
  </div>
422
467
 
423
- {/* hop-bare carries its own gutter padding; collapsed falls back to
424
- `icon` — a full-width label can't sit in the collapsed rail. */}
468
+ {/* the theme slot holds a TREE ROW (kol-framework's SideNav passes `ThemeToggle variant="row"`,
469
+ 2026-10-24): it wears .kol-sidenav-hop and follows the collapse as the rows do. */}
425
470
  <div className="pb-4">
426
471
  {/* the theme slot is the consumer's: kol-component cannot import kol-framework's
427
472
  * toggle, so `themeToggle` is a render function `({ collapsed }) => node` (kol-framework's
@@ -0,0 +1,39 @@
1
+ /**
2
+ * imageToDataUrl — a picked image file as a small data URL, for a card's cover (the file rail's Upload
3
+ * image, 2026-10-24 — plan home-library-detail-one-card 2.2). Decodes the file, fits it inside `max`
4
+ * on its longer side, encodes webp at `quality`. What the editor's `captureThumb` writes for a save,
5
+ * for a picture the user supplies.
6
+ *
7
+ * @param {File} file
8
+ * @param {Object} [opts]
9
+ * @param {number} [opts.max=640] the longer side, px
10
+ * @param {number} [opts.quality=0.82]
11
+ * @returns {Promise<string>} `data:image/webp;base64,…`
12
+ */
13
+ export default async function imageToDataUrl(file, { max = 640, quality = 0.82 } = {}) {
14
+ const bitmap = await createImageBitmap(file)
15
+ const scale = Math.min(1, max / Math.max(bitmap.width, bitmap.height))
16
+ const w = Math.max(1, Math.round(bitmap.width * scale))
17
+ const h = Math.max(1, Math.round(bitmap.height * scale))
18
+ const canvas = document.createElement('canvas')
19
+ canvas.width = w
20
+ canvas.height = h
21
+ canvas.getContext('2d').drawImage(bitmap, 0, 0, w, h)
22
+ bitmap.close?.()
23
+ return canvas.toDataURL('image/webp', quality)
24
+ }
25
+
26
+ /** pickImage — opens the file chooser for one image and resolves with its data URL, or null when cancelled. */
27
+ export function pickImage(opts) {
28
+ return new Promise((resolve) => {
29
+ const input = document.createElement('input')
30
+ input.type = 'file'
31
+ input.accept = 'image/*'
32
+ input.onchange = async () => {
33
+ const f = input.files?.[0]
34
+ resolve(f ? await imageToDataUrl(f, opts).catch(() => null) : null)
35
+ }
36
+ input.oncancel = () => resolve(null)
37
+ input.click()
38
+ })
39
+ }