@kolkrabbi/kol-shell 0.79.0 → 0.81.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.79.0",
3
+ "version": "0.81.0",
4
4
  "private": false,
5
5
  "description": "The application shell",
6
6
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "peerDependencies": {
15
15
  "@kolkrabbi/kol-component": ">=0.299.0",
16
- "@kolkrabbi/kol-framework": ">=0.53.0",
16
+ "@kolkrabbi/kol-framework": ">=0.55.0",
17
17
  "@kolkrabbi/kol-icons": ">=0.16.0",
18
18
  "@kolkrabbi/kol-theme": ">=0.187.0",
19
19
  "gsap": "^3.13.0",
@@ -21,10 +21,10 @@
21
21
  "react-dom": "^18.3.0 || ^19.0.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@kolkrabbi/kol-component": "^0.299.0",
24
+ "@kolkrabbi/kol-component": "^0.301.0",
25
25
  "@kolkrabbi/kol-icons": "^0.45.0",
26
- "@kolkrabbi/kol-theme": "^0.187.0",
27
- "@kolkrabbi/kol-framework": "^0.54.0"
26
+ "@kolkrabbi/kol-framework": "^0.55.0",
27
+ "@kolkrabbi/kol-theme": "^0.189.0"
28
28
  },
29
29
  "files": [
30
30
  "src",
package/src/AppHub.jsx CHANGED
@@ -46,7 +46,12 @@ 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 {'light'|'dark'} defaultTheme THE APP'S DEFAULT THEME (AppHubDefaultTheme, kol-mirror 2026-10-24 — *"make this repo dark mode
50
+ * default"*): reset and the toggle's system choice land on it instead of the OS (kol-framework ≥0.55.0
51
+ * reads `data-theme-default`, which the Hub stamps). `app.defaultTheme` says the same. Omit it and
52
+ * nothing changes
53
+ * @param {Object} app `{ name, subtitle, logomark (svg url), about (string | paragraphs), links [{label,url}], docs [{ label, paragraphs }] }` —
54
+ * `docs` is the rail's Docs tab, an app's explanatory prose as data (SettingsRailDocsTab, 2026-10-24)
50
55
  * @param {Array} items the tool's rail rows `{ icon, path, label }` — Home is the mark, Settings is pinned
51
56
  * @param {string} currentPath · {Function} onNavigate · {ElementType} iconComponent as AppShell
52
57
  * @param {string} homePath where Home lives (default `/`); anything else puts the tool at `/`
@@ -65,8 +70,9 @@ import { CommandOverlay, LabeledControlSection, MediaLibrary, ModalProvider, RAI
65
70
  * their options and values, or a text `value`; the Hub draws every control, label, value and
66
71
  * note in its own class and tone), the theme toggle and reset in its footer. ONE SHAPE ON
67
72
  * 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
73
+ * rail?"* · *"not 2 lines"*): the tab row is exactly Settings · Shortcuts · About · Docs —
74
+ * the three drawn by the Hub from `shortcuts`, `app.about` + `app.links` (the links under About,
75
+ * SettingsRailDocsTab 2026-10-24) and `app.docs` (an app's prose, `[{ label, paragraphs }]`), on studio-hub as
70
76
  * on every hub; an app has NO tab of its own (a fifth word does not fit the rail on one
71
77
  * line) — its rows all go under Settings as sections, and the rail scrolls. Reset is live on
72
78
  * every rail: it hands the theme back to the system (the Hub's own setting), then runs the
@@ -125,16 +131,26 @@ const RAIL_TABS = {
125
131
  },
126
132
  about: {
127
133
  label: 'About',
134
+ /* the links draw under About (SettingsRailDocsTab, kol-mirror 2026-10-24): Repo's list folds in here, so the row's
135
+ * fourth word can be Docs and it stays one line */
128
136
  draw: ({ app }) => (
129
137
  <div className="flex flex-col gap-8">
130
138
  {app.about && <LabeledControlSection label={app.name}><About about={app.about} /></LabeledControlSection>}
139
+ {app.links?.length > 0 && <LabeledControlSection label="Links"><SettingsLinks links={app.links} /></LabeledControlSection>}
131
140
  <SettingsColophon />
132
141
  </div>
133
142
  ),
134
143
  },
135
- repo: {
136
- label: 'Repo',
137
- draw: ({ app }) => <LabeledControlSection label="Links"><SettingsLinks links={app.links ?? []} /></LabeledControlSection>,
144
+ docs: {
145
+ label: 'Docs',
146
+ /* an app's explanatory prose AS DATA — `app.docs: [{ label, paragraphs }]`, each a section in About's voice, out of
147
+ * the settings sections' notes (user, on mirror's rail: *"settings are so overloaded with information that its hard to
148
+ * navigate … we should just start a documentation tab for it"*). No JSX: `About` warns on a node */
149
+ draw: ({ app }) => (
150
+ <div className="flex flex-col gap-8">
151
+ {app.docs.map((d, i) => <LabeledControlSection key={d.label ?? i} label={d.label}><About about={d.paragraphs ?? d.text} /></LabeledControlSection>)}
152
+ </div>
153
+ ),
138
154
  },
139
155
  }
140
156
  /* the rail's rows: typed, text, or nothing — a `render` row is JSX and is dropped here with a warning */
@@ -150,6 +166,8 @@ export default function AppHub(props) {
150
166
 
151
167
  function HubFrame({
152
168
  app = {},
169
+ /* the app's default theme (AppHubDefaultTheme, kol-mirror 2026-10-24): what reset and the toggle's system fall back to */
170
+ defaultTheme,
153
171
  items = [],
154
172
  currentPath,
155
173
  onNavigate,
@@ -184,14 +202,24 @@ function HubFrame({
184
202
  const [settingsTab, setSettingsTab] = useState('settings')
185
203
  const modal = useModal()
186
204
  const theme = useTheme()
205
+ /* THE DEFAULT THEME IS A ROOT ATTRIBUTE kol-framework's theme reads (`data-theme-default`): reset (`theme.clear()`)
206
+ * and the toggle's alt-click hand the page to it, not to the OS — a dark-first app stays dark on a light-mode Mac */
207
+ const themeDefault = defaultTheme ?? app.defaultTheme
208
+ useEffect(() => {
209
+ if (!themeDefault) return undefined
210
+ document.documentElement.dataset.themeDefault = themeDefault
211
+ return () => { delete document.documentElement.dataset.themeDefault }
212
+ }, [themeDefault])
187
213
  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) */
214
+ /* THE RAIL'S TABS, the same four on every hub: Settings · Shortcuts · About · Docs, the three from what the app already
215
+ * passes — Repo's links sit under About since SettingsRailDocsTab (kol-mirror 2026-10-24: *"settings are so overloaded with
216
+ * information … we should just start a documentation tab for it"*), so the fourth word is the app's prose, `app.docs`, drawn
217
+ * when it has any; an app's `tabs` are not drawn — its rows belong under Settings (dev warns) */
190
218
  if (settingsDrawer && settings.tabs?.length) warnJsx('settings.tabs', 'The rail has no app tabs — put the rows under settings.sections.')
191
219
  const railTabs = settingsDrawer ? [
192
220
  ...(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 }] : []),
221
+ ...((app.about || app.links?.length) ? [{ value: 'about', label: RAIL_TABS.about.label, named: RAIL_TABS.about }] : []),
222
+ ...(app.docs?.length ? [{ value: 'docs', label: RAIL_TABS.docs.label, named: RAIL_TABS.docs }] : []),
195
223
  ] : []
196
224
  if (settingsDrawer && settings.content != null) warnRailJsx('content')
197
225
  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'
@@ -83,7 +83,13 @@ import CatalogGrid from './CatalogGrid.jsx'
83
83
  * @param {ReactNode} lead a node between the masthead and the catalog (HubHome's quick links on a phone)
84
84
  * @param {ElementType} iconComponent icon renderer seam for ContentFilters
85
85
  * @param {boolean} showCountOnlyWhenFiltering (default true)
86
+ * @param {boolean} flipped · backHover the cards' back (AppCardWholeFlip, 2026-10-24): `flipped` turns every card that has a `back`
87
+ * (a page turns them on a key), `backHover` opts the hover reveal in; a card's own from `toCard` wins
86
88
  * @param {Object} filtersProps spread onto ContentFilters last — e.g. `{ mutuallyExclusiveFilters: ['category', 'u_label'] }`
89
+ *
90
+ * THE PAGE KEEPS ITS PLACE per history entry (CatalogPageKeepsPlaceOnBack, kol-mirror 2026-10-24): Back restores the
91
+ * chips, the search, LIST / GRID, the page's own view and the fixed region's scroll; a fresh navigation starts clean.
92
+ * Always on — see `usePlace` below.
87
93
  */
88
94
  const LAYOUTS = [
89
95
  { value: 'list', label: 'LIST' },
@@ -142,19 +148,64 @@ const stop = (e) => { e.preventDefault(); e.stopPropagation() }
142
148
  * 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
149
  * 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
150
  * 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 }) {
151
+ /* THE PLACE PER HISTORY ENTRY (CatalogPageKeepsPlaceOnBack, kol-mirror 2026-10-24 — user: *"going back from module or
152
+ * patch to library or some hub page, previous location is not respected"*). Back is `navigate(-1)`: the route is right,
153
+ * and the page remounts with every piece of its state fresh — ContentFilters' chips, search and LIST / GRID, and the fixed
154
+ * mode's own scroll region, which no router scroll restoration reaches. The page keeps its place in a module-level map
155
+ * keyed on the HISTORY ENTRY (react-router writes `{ key }` into `history.state`, a hash router too) and the catalog's
156
+ * name, so Back and Forward restore it and a fresh navigation — a new entry — starts clean. Always on: there is nothing
157
+ * to configure, and the consumer's half (a view in the URL) stays the consumer's. No `history.state.key` (no router) =
158
+ * no place, the page as before. Fifty entries, the oldest out. */
159
+ const PLACES = new Map()
160
+ const PLACE_CAP = 50
161
+ const historyKey = () => {
162
+ try { const s = window.history.state; return s?.key ?? (s?.idx != null ? `idx:${s.idx}` : null) } catch { return null }
163
+ }
164
+ function usePlace(name) {
165
+ /* read once per mount — the entry the page was mounted under */
166
+ const key = useMemo(() => { const k = historyKey(); return k ? `${k}|${name ?? ''}` : null }, [name])
167
+ const saved = key ? PLACES.get(key) : undefined
168
+ const write = (patch) => {
169
+ if (!key) return
170
+ const next = { ...(PLACES.get(key) ?? {}), ...patch }
171
+ PLACES.delete(key); PLACES.set(key, next)
172
+ if (PLACES.size > PLACE_CAP) PLACES.delete(PLACES.keys().next().value)
173
+ }
174
+ return { saved, write }
175
+ }
176
+
177
+ function ScrollRegion({ bleed, place, children }) {
146
178
  const ref = useRef(null)
147
179
  const [under, setUnder] = useState(false)
180
+ /* the place's scrollTop, PENDING until the region is tall enough to take it — on mount the rows are laid out but a
181
+ * cover may not be, and a scrollTop set past the current scrollHeight clamps to 0 */
182
+ const pendingRef = useRef(place?.saved?.scrollTop || null)
148
183
  useEffect(() => {
149
184
  const el = ref.current
150
185
  if (!el) return undefined
186
+ const restore = () => {
187
+ const want = pendingRef.current
188
+ if (want != null && el.scrollHeight - el.clientHeight >= want) { el.scrollTop = want; pendingRef.current = null }
189
+ }
151
190
  const read = () => setUnder(el.scrollTop > 0)
191
+ /* written from the scroll event alone, never from the resize read, and never a 0 that is the CLAMP rather than the
192
+ * user: the region's content goes before the element does on the way out, scrollTop snaps to 0 and the browser fires
193
+ * one last scroll — the trace showed it overwriting the 240 just written. A region with nothing to scroll, a region
194
+ * no longer in the document, or a pending restore sitting at 0 all read as that clamp */
195
+ const onScroll = () => {
196
+ read()
197
+ if (!el.isConnected || el.scrollHeight <= el.clientHeight) return
198
+ if (pendingRef.current != null && el.scrollTop === 0) return
199
+ pendingRef.current = null
200
+ if (el.clientHeight > 0) place?.write({ scrollTop: el.scrollTop })
201
+ }
202
+ restore()
152
203
  read()
153
- el.addEventListener('scroll', read, { passive: true })
154
- const ro = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(read)
204
+ el.addEventListener('scroll', onScroll, { passive: true })
205
+ const ro = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => { restore(); read() })
155
206
  ro?.observe(el)
156
207
  if (el.firstElementChild) ro?.observe(el.firstElementChild)
157
- return () => { el.removeEventListener('scroll', read); ro?.disconnect() }
208
+ return () => { el.removeEventListener('scroll', onScroll); ro?.disconnect() }
158
209
  }, [])
159
210
  const fade = (
160
211
  <div
@@ -255,6 +306,8 @@ export default function CatalogPage({
255
306
  filtersProps,
256
307
  phoneLayout = 'list',
257
308
  lead,
309
+ flipped,
310
+ backHover,
258
311
  children,
259
312
  className = '',
260
313
  style,
@@ -268,6 +321,14 @@ export default function CatalogPage({
268
321
  * the theme's fallback of 6, the pre-0.137.0 geometry. */
269
322
  const [cols, setCols] = useState(null)
270
323
 
324
+ /* the place (CatalogPageKeepsPlaceOnBack): what this page restores on Back — the chips, the search, LIST / GRID, the
325
+ * view when it is the page's own, the region's scroll. The consumer's `filtersProps` handlers still fire. */
326
+ const place = usePlace(filtersTitle ?? header?.title ?? preset)
327
+ const [search, setSearch] = useState(() => place.saved?.search ?? '')
328
+ /* the filter panel's open state is part of the place too: the chips come back where they were seen */
329
+ const [filtersOpen, setFiltersOpen] = useState(() => place.saved?.open ?? false)
330
+ const { onFilterChange: consumerOnFilterChange, initialFilters: consumerInitialFilters, onLayoutChange: consumerOnLayoutChange, ...restFiltersProps } = filtersProps ?? {}
331
+
271
332
  /* the page's ONE menu for its `app` cards and rows (AppItem.jsx) — closed, it renders nothing */
272
333
  return (
273
334
  <AppItemMenuProvider>
@@ -287,11 +348,18 @@ export default function CatalogPage({
287
348
  viewModeOptions={views}
288
349
  trailingActions={trailingActions}
289
350
  viewMode={view}
290
- onViewModeChange={onViewChange}
291
- defaultViewMode={defaultView}
351
+ onViewModeChange={(v) => { place.write({ view: v }); onViewChange?.(v) }}
352
+ defaultViewMode={place.saved?.view ?? defaultView}
292
353
  layoutOptions={open || phoneRows ? undefined : layouts}
293
- defaultLayout={defaultLayout}
354
+ defaultLayout={place.saved?.layout ?? defaultLayout}
355
+ onLayoutChange={(l) => { place.write({ layout: l }); consumerOnLayoutChange?.(l) }}
294
356
  layout={phoneRows ? 'list' : undefined}
357
+ initialFilters={place.saved?.filters ?? consumerInitialFilters}
358
+ onFilterChange={(set, vm) => { place.write({ filters: [...set] }); consumerOnFilterChange?.(set, vm) }}
359
+ searchValue={search}
360
+ onSearchChange={(q) => { setSearch(q); place.write({ search: q }) }}
361
+ filtersOpen={filtersOpen}
362
+ onFiltersOpenChange={(o) => { setFiltersOpen(o); place.write({ open: o }) }}
295
363
  renderItem={(rows, viewMode, layout) => {
296
364
  if (open) return null
297
365
  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 })
@@ -325,7 +393,7 @@ export default function CatalogPage({
325
393
  const { key: _key, ...forwarded } = c
326
394
  return layout === 'list'
327
395
  ? <ContentRow key={key} {...forwarded} variant={c.variant ?? rowVariant} />
328
- : <ContentCard key={key} {...forwarded} variant={c.variant ?? cardVariant} fit={c.fit ?? 'cover'} />
396
+ : <ContentCard key={key} {...forwarded} variant={c.variant ?? cardVariant} fit={c.fit ?? 'cover'} flipped={c.flipped ?? flipped} backHover={c.backHover ?? backHover} />
329
397
  })}
330
398
  </CatalogGrid>
331
399
  )
@@ -333,9 +401,9 @@ export default function CatalogPage({
333
401
  * (ContentFiltersFillChain) ends here, in a scroller; the page itself never scrolls */
334
402
  /* TO THE PAGE'S EDGE (user 2026-10-23: *"padding bottom is still there clipping"*): with no foot row under it the
335
403
  * 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
404
+ return mode === 'fixed' ? <ScrollRegion bleed={!actions} place={place}>{grid}</ScrollRegion> : grid
337
405
  }}
338
- {...filtersProps}
406
+ {...restFiltersProps}
339
407
  />
340
408
  </div>
341
409
  {children}
package/src/HubHome.jsx CHANGED
@@ -57,6 +57,8 @@ import { useTouchPrimary } from './TouchDeviceOverlay.jsx'
57
57
  * file's cover; the consumer stores it as the file's `cover`. Absent → no Cover row. With `images`
58
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
59
  * @param {Function} onBack `(file, src)` — the rail's Back pick over the file's `images`; the consumer stores it as `back`
60
+ * @param {boolean} flipped · backHover the cards' back (AppCardWholeFlip, 2026-10-24): `flipped` turns every card that has a `back` — the
61
+ * page turns them on a key; `backHover` opts the hover reveal in (default off)
60
62
  * @param {Function} onImages `(file, next)` — the rail's Upload tile and × write the WHOLE list back (`[{ id, src, label? }]`, the
61
63
  * rail names a new image's id); the consumer stores it as the file's `images`. Absent → no tile, no ×.
62
64
  * An image removed while it was the cover or the back clears it: `onCover(file, null)` · `onBack(file, null)`
@@ -126,6 +128,8 @@ export default function HubHome({
126
128
  onCover,
127
129
  onBack,
128
130
  onImages,
131
+ flipped,
132
+ backHover,
129
133
  filterGroups,
130
134
  action,
131
135
  views = HUB_VIEWS,
@@ -223,6 +227,8 @@ export default function HubHome({
223
227
  header={{ title: title ?? app.name, subtitle: subtitle ?? app.subtitle, size: 'sm', voice: 'mono', actions: headerMenu, actionsPlacement: headerMenu ? 'head' : undefined }}
224
228
  items={items}
225
229
  toCard={toCard}
230
+ flipped={flipped}
231
+ backHover={backHover}
226
232
  filtersTitle="All Files"
227
233
  filterGroups={groups?.map(({ exclusive: _x, ...g }) => g)}
228
234
  filtersProps={exclusive?.length ? { mutuallyExclusiveFilters: exclusive } : undefined}