@kolkrabbi/kol-shell 0.78.1 → 0.80.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-shell",
3
- "version": "0.78.1",
3
+ "version": "0.80.0",
4
4
  "private": false,
5
5
  "description": "The application shell",
6
6
  "license": "MIT",
@@ -12,19 +12,19 @@
12
12
  "./src/*": "./src/*"
13
13
  },
14
14
  "peerDependencies": {
15
- "@kolkrabbi/kol-component": ">=0.296.0",
15
+ "@kolkrabbi/kol-component": ">=0.299.0",
16
16
  "@kolkrabbi/kol-framework": ">=0.53.0",
17
17
  "@kolkrabbi/kol-icons": ">=0.16.0",
18
- "@kolkrabbi/kol-theme": ">=0.184.0",
18
+ "@kolkrabbi/kol-theme": ">=0.187.0",
19
19
  "gsap": "^3.13.0",
20
20
  "react": "^18.3.0 || ^19.0.0",
21
21
  "react-dom": "^18.3.0 || ^19.0.0"
22
22
  },
23
23
  "devDependencies": {
24
+ "@kolkrabbi/kol-component": "^0.299.0",
25
+ "@kolkrabbi/kol-framework": "^0.54.0",
24
26
  "@kolkrabbi/kol-icons": "^0.45.0",
25
- "@kolkrabbi/kol-component": "^0.297.0",
26
- "@kolkrabbi/kol-framework": "^0.53.0",
27
- "@kolkrabbi/kol-theme": "^0.185.0"
27
+ "@kolkrabbi/kol-theme": "^0.187.0"
28
28
  },
29
29
  "files": [
30
30
  "src",
package/src/AppHub.jsx CHANGED
@@ -46,7 +46,8 @@ import { CommandOverlay, LabeledControlSection, MediaLibrary, ModalProvider, RAI
46
46
  * picker over the consumer's client, Sign in asks for the password in the DS dialog and hands it to the consumer. `shell.bottomItems` still replaces
47
47
  * the whole foot, as it always did.
48
48
  *
49
- * @param {Object} app `{ name, subtitle, logomark (svg url), about (node), links [{label,url}] }`
49
+ * @param {Object} app `{ name, subtitle, logomark (svg url), about (string | paragraphs), links [{label,url}], docs [{ label, paragraphs }] }` —
50
+ * `docs` is the rail's Docs tab, an app's explanatory prose as data (SettingsRailDocsTab, 2026-10-24)
50
51
  * @param {Array} items the tool's rail rows `{ icon, path, label }` — Home is the mark, Settings is pinned
51
52
  * @param {string} currentPath · {Function} onNavigate · {ElementType} iconComponent as AppShell
52
53
  * @param {string} homePath where Home lives (default `/`); anything else puts the tool at `/`
@@ -65,8 +66,9 @@ import { CommandOverlay, LabeledControlSection, MediaLibrary, ModalProvider, RAI
65
66
  * their options and values, or a text `value`; the Hub draws every control, label, value and
66
67
  * note in its own class and tone), the theme toggle and reset in its footer. ONE SHAPE ON
67
68
  * EVERY RAIL (user 2026-10-24: *"is there no criteria of what information goes into settings
68
- * rail?"* · *"not 2 lines"*): the tab row is exactly Settings · Shortcuts · About · Repo —
69
- * the three drawn by the Hub from `shortcuts`, `app.about` and `app.links`, on studio-hub as
69
+ * rail?"* · *"not 2 lines"*): the tab row is exactly Settings · Shortcuts · About · Docs —
70
+ * the three drawn by the Hub from `shortcuts`, `app.about` + `app.links` (the links under About,
71
+ * SettingsRailDocsTab 2026-10-24) and `app.docs` (an app's prose, `[{ label, paragraphs }]`), on studio-hub as
70
72
  * on every hub; an app has NO tab of its own (a fifth word does not fit the rail on one
71
73
  * line) — its rows all go under Settings as sections, and the rail scrolls. Reset is live on
72
74
  * every rail: it hands the theme back to the system (the Hub's own setting), then runs the
@@ -125,16 +127,26 @@ const RAIL_TABS = {
125
127
  },
126
128
  about: {
127
129
  label: 'About',
130
+ /* the links draw under About (SettingsRailDocsTab, kol-mirror 2026-10-24): Repo's list folds in here, so the row's
131
+ * fourth word can be Docs and it stays one line */
128
132
  draw: ({ app }) => (
129
133
  <div className="flex flex-col gap-8">
130
134
  {app.about && <LabeledControlSection label={app.name}><About about={app.about} /></LabeledControlSection>}
135
+ {app.links?.length > 0 && <LabeledControlSection label="Links"><SettingsLinks links={app.links} /></LabeledControlSection>}
131
136
  <SettingsColophon />
132
137
  </div>
133
138
  ),
134
139
  },
135
- repo: {
136
- label: 'Repo',
137
- draw: ({ app }) => <LabeledControlSection label="Links"><SettingsLinks links={app.links ?? []} /></LabeledControlSection>,
140
+ docs: {
141
+ label: 'Docs',
142
+ /* an app's explanatory prose AS DATA — `app.docs: [{ label, paragraphs }]`, each a section in About's voice, out of
143
+ * the settings sections' notes (user, on mirror's rail: *"settings are so overloaded with information that its hard to
144
+ * navigate … we should just start a documentation tab for it"*). No JSX: `About` warns on a node */
145
+ draw: ({ app }) => (
146
+ <div className="flex flex-col gap-8">
147
+ {app.docs.map((d, i) => <LabeledControlSection key={d.label ?? i} label={d.label}><About about={d.paragraphs ?? d.text} /></LabeledControlSection>)}
148
+ </div>
149
+ ),
138
150
  },
139
151
  }
140
152
  /* the rail's rows: typed, text, or nothing — a `render` row is JSX and is dropped here with a warning */
@@ -185,13 +197,15 @@ function HubFrame({
185
197
  const modal = useModal()
186
198
  const theme = useTheme()
187
199
  if (themeToggle != null) warnJsx('themeToggle', 'The Hub draws the theme toggle itself; drop the prop.')
188
- /* THE RAIL'S TABS, the same four on every hub: Settings · Shortcuts · About · Repo, the three from what the app already
189
- * passes; an app's `tabs` are not drawn — its rows belong under Settings (dev warns) */
200
+ /* THE RAIL'S TABS, the same four on every hub: Settings · Shortcuts · About · Docs, the three from what the app already
201
+ * passes — Repo's links sit under About since SettingsRailDocsTab (kol-mirror 2026-10-24: *"settings are so overloaded with
202
+ * information … we should just start a documentation tab for it"*), so the fourth word is the app's prose, `app.docs`, drawn
203
+ * when it has any; an app's `tabs` are not drawn — its rows belong under Settings (dev warns) */
190
204
  if (settingsDrawer && settings.tabs?.length) warnJsx('settings.tabs', 'The rail has no app tabs — put the rows under settings.sections.')
191
205
  const railTabs = settingsDrawer ? [
192
206
  ...(shortcuts.length ? [{ value: 'shortcuts', label: RAIL_TABS.shortcuts.label, named: RAIL_TABS.shortcuts }] : []),
193
- ...(app.about ? [{ value: 'about', label: RAIL_TABS.about.label, named: RAIL_TABS.about }] : []),
194
- ...(app.links?.length ? [{ value: 'repo', label: RAIL_TABS.repo.label, named: RAIL_TABS.repo }] : []),
207
+ ...((app.about || app.links?.length) ? [{ value: 'about', label: RAIL_TABS.about.label, named: RAIL_TABS.about }] : []),
208
+ ...(app.docs?.length ? [{ value: 'docs', label: RAIL_TABS.docs.label, named: RAIL_TABS.docs }] : []),
195
209
  ] : []
196
210
  if (settingsDrawer && settings.content != null) warnRailJsx('content')
197
211
  const railRows = settingsDrawer ? railSections(settings.sections) : []
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef, useState } from 'react'
1
+ import { useEffect, useMemo, useRef, useState } from 'react'
2
2
  import { ActionButton, AppItemMenuProvider, ContentCard, ContentFilters, ContentRow, SizeOrDownload, formatSize, useMediaQuery } from '@kolkrabbi/kol-component'
3
3
  import PageShell from './PageShell.jsx'
4
4
  import { PageHeader } from '@kolkrabbi/kol-component'
@@ -84,6 +84,10 @@ import CatalogGrid from './CatalogGrid.jsx'
84
84
  * @param {ElementType} iconComponent icon renderer seam for ContentFilters
85
85
  * @param {boolean} showCountOnlyWhenFiltering (default true)
86
86
  * @param {Object} filtersProps spread onto ContentFilters last — e.g. `{ mutuallyExclusiveFilters: ['category', 'u_label'] }`
87
+ *
88
+ * THE PAGE KEEPS ITS PLACE per history entry (CatalogPageKeepsPlaceOnBack, kol-mirror 2026-10-24): Back restores the
89
+ * chips, the search, LIST / GRID, the page's own view and the fixed region's scroll; a fresh navigation starts clean.
90
+ * Always on — see `usePlace` below.
87
91
  */
88
92
  const LAYOUTS = [
89
93
  { value: 'list', label: 'LIST' },
@@ -142,19 +146,64 @@ const stop = (e) => { e.preventDefault(); e.stopPropagation() }
142
146
  * the fixed mode's scroll region with a 32px fade from the page's ground at its TOP edge, only once rows have scrolled
143
147
  * under it, so a cut row reads as folded under the edge. The top alone (user 2026-10-23: *"I dont think we need it on bottom"*). A fade, not a
144
148
  * shadow: on this ground a shadow has nothing to fall on. `bleed` runs the region through the page's bottom pad. */
145
- function ScrollRegion({ bleed, children }) {
149
+ /* THE PLACE PER HISTORY ENTRY (CatalogPageKeepsPlaceOnBack, kol-mirror 2026-10-24 — user: *"going back from module or
150
+ * patch to library or some hub page, previous location is not respected"*). Back is `navigate(-1)`: the route is right,
151
+ * and the page remounts with every piece of its state fresh — ContentFilters' chips, search and LIST / GRID, and the fixed
152
+ * mode's own scroll region, which no router scroll restoration reaches. The page keeps its place in a module-level map
153
+ * keyed on the HISTORY ENTRY (react-router writes `{ key }` into `history.state`, a hash router too) and the catalog's
154
+ * name, so Back and Forward restore it and a fresh navigation — a new entry — starts clean. Always on: there is nothing
155
+ * to configure, and the consumer's half (a view in the URL) stays the consumer's. No `history.state.key` (no router) =
156
+ * no place, the page as before. Fifty entries, the oldest out. */
157
+ const PLACES = new Map()
158
+ const PLACE_CAP = 50
159
+ const historyKey = () => {
160
+ try { const s = window.history.state; return s?.key ?? (s?.idx != null ? `idx:${s.idx}` : null) } catch { return null }
161
+ }
162
+ function usePlace(name) {
163
+ /* read once per mount — the entry the page was mounted under */
164
+ const key = useMemo(() => { const k = historyKey(); return k ? `${k}|${name ?? ''}` : null }, [name])
165
+ const saved = key ? PLACES.get(key) : undefined
166
+ const write = (patch) => {
167
+ if (!key) return
168
+ const next = { ...(PLACES.get(key) ?? {}), ...patch }
169
+ PLACES.delete(key); PLACES.set(key, next)
170
+ if (PLACES.size > PLACE_CAP) PLACES.delete(PLACES.keys().next().value)
171
+ }
172
+ return { saved, write }
173
+ }
174
+
175
+ function ScrollRegion({ bleed, place, children }) {
146
176
  const ref = useRef(null)
147
177
  const [under, setUnder] = useState(false)
178
+ /* the place's scrollTop, PENDING until the region is tall enough to take it — on mount the rows are laid out but a
179
+ * cover may not be, and a scrollTop set past the current scrollHeight clamps to 0 */
180
+ const pendingRef = useRef(place?.saved?.scrollTop || null)
148
181
  useEffect(() => {
149
182
  const el = ref.current
150
183
  if (!el) return undefined
184
+ const restore = () => {
185
+ const want = pendingRef.current
186
+ if (want != null && el.scrollHeight - el.clientHeight >= want) { el.scrollTop = want; pendingRef.current = null }
187
+ }
151
188
  const read = () => setUnder(el.scrollTop > 0)
189
+ /* written from the scroll event alone, never from the resize read, and never a 0 that is the CLAMP rather than the
190
+ * user: the region's content goes before the element does on the way out, scrollTop snaps to 0 and the browser fires
191
+ * one last scroll — the trace showed it overwriting the 240 just written. A region with nothing to scroll, a region
192
+ * no longer in the document, or a pending restore sitting at 0 all read as that clamp */
193
+ const onScroll = () => {
194
+ read()
195
+ if (!el.isConnected || el.scrollHeight <= el.clientHeight) return
196
+ if (pendingRef.current != null && el.scrollTop === 0) return
197
+ pendingRef.current = null
198
+ if (el.clientHeight > 0) place?.write({ scrollTop: el.scrollTop })
199
+ }
200
+ restore()
152
201
  read()
153
- el.addEventListener('scroll', read, { passive: true })
154
- const ro = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(read)
202
+ el.addEventListener('scroll', onScroll, { passive: true })
203
+ const ro = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => { restore(); read() })
155
204
  ro?.observe(el)
156
205
  if (el.firstElementChild) ro?.observe(el.firstElementChild)
157
- return () => { el.removeEventListener('scroll', read); ro?.disconnect() }
206
+ return () => { el.removeEventListener('scroll', onScroll); ro?.disconnect() }
158
207
  }, [])
159
208
  const fade = (
160
209
  <div
@@ -268,6 +317,14 @@ export default function CatalogPage({
268
317
  * the theme's fallback of 6, the pre-0.137.0 geometry. */
269
318
  const [cols, setCols] = useState(null)
270
319
 
320
+ /* the place (CatalogPageKeepsPlaceOnBack): what this page restores on Back — the chips, the search, LIST / GRID, the
321
+ * view when it is the page's own, the region's scroll. The consumer's `filtersProps` handlers still fire. */
322
+ const place = usePlace(filtersTitle ?? header?.title ?? preset)
323
+ const [search, setSearch] = useState(() => place.saved?.search ?? '')
324
+ /* the filter panel's open state is part of the place too: the chips come back where they were seen */
325
+ const [filtersOpen, setFiltersOpen] = useState(() => place.saved?.open ?? false)
326
+ const { onFilterChange: consumerOnFilterChange, initialFilters: consumerInitialFilters, onLayoutChange: consumerOnLayoutChange, ...restFiltersProps } = filtersProps ?? {}
327
+
271
328
  /* the page's ONE menu for its `app` cards and rows (AppItem.jsx) — closed, it renders nothing */
272
329
  return (
273
330
  <AppItemMenuProvider>
@@ -287,11 +344,18 @@ export default function CatalogPage({
287
344
  viewModeOptions={views}
288
345
  trailingActions={trailingActions}
289
346
  viewMode={view}
290
- onViewModeChange={onViewChange}
291
- defaultViewMode={defaultView}
347
+ onViewModeChange={(v) => { place.write({ view: v }); onViewChange?.(v) }}
348
+ defaultViewMode={place.saved?.view ?? defaultView}
292
349
  layoutOptions={open || phoneRows ? undefined : layouts}
293
- defaultLayout={defaultLayout}
350
+ defaultLayout={place.saved?.layout ?? defaultLayout}
351
+ onLayoutChange={(l) => { place.write({ layout: l }); consumerOnLayoutChange?.(l) }}
294
352
  layout={phoneRows ? 'list' : undefined}
353
+ initialFilters={place.saved?.filters ?? consumerInitialFilters}
354
+ onFilterChange={(set, vm) => { place.write({ filters: [...set] }); consumerOnFilterChange?.(set, vm) }}
355
+ searchValue={search}
356
+ onSearchChange={(q) => { setSearch(q); place.write({ search: q }) }}
357
+ filtersOpen={filtersOpen}
358
+ onFiltersOpenChange={(o) => { setFiltersOpen(o); place.write({ open: o }) }}
295
359
  renderItem={(rows, viewMode, layout) => {
296
360
  if (open) return null
297
361
  const cards = rows.map((item) => { const c = toCard ? toCard(item, { view: viewMode, layout }) : { title: item.title ?? item.name, detail: item.detail }; return preset === 'shelf' ? toSlideCard(c, { layout }) : c })
@@ -333,9 +397,9 @@ export default function CatalogPage({
333
397
  * (ContentFiltersFillChain) ends here, in a scroller; the page itself never scrolls */
334
398
  /* TO THE PAGE'S EDGE (user 2026-10-23: *"padding bottom is still there clipping"*): with no foot row under it the
335
399
  * region bleeds through the page's bottom pad, so a cut row reads as scrolling under the edge, not stopped above a band */
336
- return mode === 'fixed' ? <ScrollRegion bleed={!actions}>{grid}</ScrollRegion> : grid
400
+ return mode === 'fixed' ? <ScrollRegion bleed={!actions} place={place}>{grid}</ScrollRegion> : grid
337
401
  }}
338
- {...filtersProps}
402
+ {...restFiltersProps}
339
403
  />
340
404
  </div>
341
405
  {children}
package/src/HubHome.jsx CHANGED
@@ -38,8 +38,11 @@ import { useTouchPrimary } from './TouchDeviceOverlay.jsx'
38
38
  * @param {string} title · subtitle Home's own masthead instead — for a Home that is not the front
39
39
  * door (media-hub's Library at `/library`, 2026-09-26: it said "Media")
40
40
  * @param {Array} files the user's files, the ONLY source of cards:
41
- * `[{ id, name, updatedAt (ms), bytes?, cover? (src | node), tags?: string[],
42
- * note?: string, mark?: { icon, label, of? }, details?: [{ label, value }] }]` — `mark` is a glyph
41
+ * `[{ id, name, updatedAt (ms), bytes?, cover? (src | node), back? (src | node), images?: [{ id, src, label? }],
42
+ * tags?: string[], note?: string, mark?: { icon, label, of? }, details?: [{ label, value }] }]` — `back` is the card's
43
+ * second cover, revealed on hover (AppCardBackCover, monitor: the rack behind the output); `images` are the
44
+ * file's pictures, the rail's Files section (FileRailImages): quicklook, remove, upload, and the cover and back
45
+ * picked from them; `mark` is a glyph
43
46
  * on the cover's other corner for what the file is (FXR: the chrome it was made with) — newest first wherever they come from; a
44
47
  * file may carry the keys its `filterGroups` read (monitor's `type`)
45
48
  * @param {Function} onOpen `(file)` — the card and the row click; required with `files`
@@ -51,7 +54,12 @@ import { useTouchPrimary } from './TouchDeviceOverlay.jsx'
51
54
  * @param {Function} onTags `(file, tags)` — the rail's tag chips write through it; absent → tags read-only
52
55
  * @param {Function} onNote `(file, text)` — the rail's note (a plain description, 2026-10-23) writes through it; absent → read-only
53
56
  * @param {Function} onCover `(file, src)` — the rail's Upload image (2026-10-24): the DS picker's webp data URL for the
54
- * file's cover; the consumer stores it as the file's `cover`. Absent → no Cover row
57
+ * file's cover; the consumer stores it as the file's `cover`. Absent → no Cover row. With `images`
58
+ * on the file it is the Cover PICK instead — `src` is the picked image's, or `null` when that image is removed (FileRailImages)
59
+ * @param {Function} onBack `(file, src)` — the rail's Back pick over the file's `images`; the consumer stores it as `back`
60
+ * @param {Function} onImages `(file, next)` — the rail's Upload tile and × write the WHOLE list back (`[{ id, src, label? }]`, the
61
+ * rail names a new image's id); the consumer stores it as the file's `images`. Absent → no tile, no ×.
62
+ * An image removed while it was the cover or the back clears it: `onCover(file, null)` · `onBack(file, null)`
55
63
  * @param {Object} touch QUICK LINKS ON A PHONE, opt-in (studio-hub review 2, § 7.2 — *"fxr would use the quicklinks
56
64
  * for picking chrome right on mobile, while monitor and mirror wouldn't"*):
57
65
  * `{ doors: [{ icon, label, onPress }] }` — on a coarse pointer or below `md`, the doors as a
@@ -116,6 +124,8 @@ export default function HubHome({
116
124
  onTags,
117
125
  onNote,
118
126
  onCover,
127
+ onBack,
128
+ onImages,
119
129
  filterGroups,
120
130
  action,
121
131
  views = HUB_VIEWS,
@@ -161,6 +171,7 @@ export default function HubHome({
161
171
  date: item.updatedAt,
162
172
  size: item.bytes,
163
173
  media: item.cover,
174
+ back: item.back,
164
175
  tags: item.tags,
165
176
  details: item.details,
166
177
  onTags: onTags ? (tags) => onTags(item, tags) : undefined,
@@ -168,6 +179,10 @@ export default function HubHome({
168
179
  mark: item.mark,
169
180
  onNote: onNote ? (text) => onNote(item, text) : undefined,
170
181
  onCover: onCover ? (src) => onCover(item, src) : undefined,
182
+ /* the rail's Files section (FileRailImages, 2026-10-24): the file's images, and the picks and writes over them */
183
+ images: item.images,
184
+ onBack: onBack ? (src) => onBack(item, src) : undefined,
185
+ onImages: onImages ? (next) => onImages(item, next) : undefined,
171
186
  verbs: Object.keys(verbs).length ? verbs : undefined,
172
187
  download: onDownload ? () => onDownload(item) : undefined,
173
188
  onClick: onOpen ? () => onOpen(item) : undefined,
package/src/PageShell.jsx CHANGED
@@ -52,7 +52,7 @@
52
52
  * surface swap would hide. The ink stays `text-auto` (surface-on-primary).
53
53
  * ONE OWNER PER PIXEL (2026-09-03): the variable means what is LEFT to paint.
54
54
  * kol-shell's `AppShell` hands the wash down for this to paint; kol-framework's
55
- * `PageLayout` paints it on its own plane and hands down `transparent`, so a
55
+ * `SiteLayout` paints it on its own plane and hands down `transparent`, so a
56
56
  * PageShell inside it does not paint it again (it used to — two 0.02 layers).
57
57
  *
58
58
  * @param {'scroll'|'fixed'} mode scroll (default) | fixed — see above