@kolkrabbi/kol-shell 0.104.0 → 0.105.1

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.104.0",
3
+ "version": "0.105.1",
4
4
  "private": false,
5
5
  "description": "The application shell",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
12
12
  "./src/*": "./src/*"
13
13
  },
14
14
  "peerDependencies": {
15
- "@kolkrabbi/kol-component": ">=0.337.0",
15
+ "@kolkrabbi/kol-component": ">=0.339.1",
16
16
  "@kolkrabbi/kol-framework": ">=0.55.0",
17
17
  "@kolkrabbi/kol-icons": ">=0.16.0",
18
18
  "@kolkrabbi/kol-theme": ">=0.211.1",
@@ -21,10 +21,10 @@
21
21
  "react-dom": "^18.3.0 || ^19.0.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@kolkrabbi/kol-component": "^0.338.1",
25
- "@kolkrabbi/kol-framework": "^0.69.0",
26
- "@kolkrabbi/kol-theme": "^0.211.1",
27
- "@kolkrabbi/kol-icons": "^0.64.0"
24
+ "@kolkrabbi/kol-component": "^0.339.1",
25
+ "@kolkrabbi/kol-framework": "^0.70.0",
26
+ "@kolkrabbi/kol-icons": "^0.64.0",
27
+ "@kolkrabbi/kol-theme": "^0.211.1"
28
28
  },
29
29
  "files": [
30
30
  "src",
package/src/AppHub.jsx CHANGED
@@ -8,7 +8,7 @@ import HubSettingsRail, { hubThemeToggle } from './HubSettingsRail.jsx'
8
8
  import HubDev from './HubDev.jsx'
9
9
  import { warnJsx } from './warnJsx.js'
10
10
  import { Icon } from '@kolkrabbi/kol-icons'
11
- import { Avatar, CommandOverlay, MediaLibrary, ModalProvider, RAIL_PRESETS, ShortcutsOverlay, shortcutInScope, useModal } from '@kolkrabbi/kol-component'
11
+ import { Avatar, CommandOverlay, MediaLibrary, ModalProvider, RAIL_PRESETS, ShortcutsOverlay, railShortcuts, shortcutInScope, useModal } from '@kolkrabbi/kol-component'
12
12
 
13
13
  /* taxonomy-ok: organism — nests AppShell / HubHome / HubSettings / HubSettingsRail / HubDev (relative) + kol-component's CommandOverlay */
14
14
 
@@ -28,7 +28,7 @@ import { Avatar, CommandOverlay, MediaLibrary, ModalProvider, RAIL_PRESETS, Shor
28
28
  * Router-agnostic like AppShell: pass `currentPath` + `onNavigate`, and your router's element
29
29
  * (`<Outlet/>`) as children.
30
30
  *
31
- * KEYS: `,` toggles Settings · `S` toggles the shortcuts sheet · `⇧S` the shortcuts rail · `\` hides the rail ·
31
+ * KEYS: `,` toggles Settings · `S` toggles the shortcuts sheet · `⇧S` the shortcuts rail · `\` expands ↔ collapses the rail · `⇧\` hides ↔ shows it (AppShell's `railKeys`, listed in the keymap as Rail) ·
32
32
  * ⌥1…9 walks the rail top to bottom, mark first, Settings last · ⌘K / Ctrl+K the search modal. None fire while typing.
33
33
  *
34
34
  * ⌘K IS ONE MODAL (user 2026-10-23, HubHomeContract's review: *"no search command k"*; one modal, not two): the
@@ -172,7 +172,7 @@ function HubFrame({
172
172
  dev,
173
173
  media,
174
174
  signIn,
175
- shortcuts = [],
175
+ shortcuts: appShortcuts = [],
176
176
  themeToggle,
177
177
  settingsPath = '/settings',
178
178
  homePath = '/',
@@ -186,6 +186,8 @@ function HubFrame({
186
186
  }) {
187
187
  /* `shell.foot`: the rail's pinned foot as the app edits it — the rest of `shell` is AppShell's */
188
188
  const { foot: footEdit, ...shellProps } = shell ?? {}
189
+ /* the app's keymap, then the rail keys (RailShortcutsAllFrames, 2026-11-04) — the sheet, ⌘K, Settings and the rail read one list */
190
+ const shortcuts = [...appShortcuts, ...railShortcuts(shellProps.railKeys)]
189
191
  const [sheet, setSheet] = useState(false)
190
192
  const [rail, setRail] = useState(false)
191
193
  const [search, setSearch] = useState(false)
@@ -425,7 +427,6 @@ function HubFrame({
425
427
  onNavigate={go}
426
428
  iconComponent={railIcon}
427
429
  appName={app.name}
428
- railToggleKey={'\\'}
429
430
  railHidden={railHidden}
430
431
  settingsPath={settingsPage ? settingsPath : undefined}
431
432
  settingsKey={settingsPage ? ',' : undefined}
package/src/AppShell.jsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react'
2
2
  import { Button } from '@kolkrabbi/kol-component'
3
- import { NavRail } from '@kolkrabbi/kol-component'
3
+ import { NavRail, useRailKeys } from '@kolkrabbi/kol-component'
4
4
  import { NavHiddenContext } from './navHidden.js'
5
5
  import { SettingsToggleContext } from './settingsToggle.js'
6
6
  import TouchDeviceOverlay, { useTouchPrimary } from './TouchDeviceOverlay.jsx'
@@ -50,8 +50,14 @@ import { TABBAR_H, TABBAR_PILL_H, TABBAR_PILL_INSET, MastheadContext, RAIL_PRESE
50
50
  * @param {'expand'|'enter'} [props.railSections] how a section row opens — the preset's unless passed: `expand` opens it in place (the
51
51
  * accordion), `enter` replaces the list with its rows under a Back row
52
52
  * (`NavRail sections`, 2026-10-06 — labs' catalog)
53
- * @param {string} props.railToggleKey a key that toggles the rail (e.g. '\\') — ignored while typing in a field;
54
- * the rail comes back on every `currentPath` change (ShellHomeSystem, 2026-08-27)
53
+ * @param {false|Object} [props.railKeys] THE RAIL KEYS (RailShortcutsAllFrames, 2026-11-04 — the same prop on SiteLayout and
54
+ * FloatLayout, kol-component's `useRailKeys`): `\` expands ↔ collapses the rail, `⇧\`
55
+ * hides ↔ shows it (showing returns it as it was). Ignored while typing and with ⌘ / ⌃ / ⌥
56
+ * held. On by default; `false` turns both off, `{ collapse, hide }` rebinds either
57
+ * (`'\\'`, `'shift+\\'`). The rail still comes back on every `currentPath` change
58
+ * (ShellHomeSystem, 2026-08-27)
59
+ * @param {string} props.railToggleKey the old single key — an alias that maps onto `railKeys.hide` (`'\\'` keeps `\`
60
+ * hiding, as before); `railKeys` wins when both are passed
55
61
  * @param {Object|boolean} [props.railTrigger] THE HIDDEN RAIL'S TRIGGER (float-everything W9 row 129, 2026-11-04): while the rail is
56
62
  * hidden, `RailTrigger` at the page's top-left corner (24 in) — the 44 float button and a
57
63
  * breadcrumb, a press opens the whole nav as a float card. `true`, or RailTrigger's props
@@ -181,6 +187,7 @@ export default function AppShell({
181
187
  railFade = true,
182
188
  rail = 'app',
183
189
  railSections,
190
+ railKeys,
184
191
  railToggleKey,
185
192
  railHidden = false,
186
193
  railTrigger,
@@ -338,19 +345,18 @@ export default function AppShell({
338
345
  root.style.setProperty('--kol-shell-page-wash', pageWash)
339
346
  return () => root.style.removeProperty('--kol-shell-page-wash')
340
347
  }, [pageWash])
341
- /* one key toggles the rail — never while typing in a field */
348
+ /* the rail keys — `\` expand ↔ collapse (the app rail's own grab toggle, through `railToggle`), `⇧\` hide ↔ show */
349
+ const railToggle = useRef(null)
350
+ /* the rail's state when it hid — showing returns it open or collapsed, as it was (FloatLayout's `lastShown`) */
351
+ const wasOpen = useRef(false)
352
+ useRailKeys(railKeys ?? (railToggleKey ? { hide: railToggleKey } : undefined), {
353
+ onCollapse: () => { if (!navHidden) railToggle.current?.() },
354
+ onHide: () => { if (!navHidden) wasOpen.current = !!railToggle.current?.open; setNavHidden(!navHidden) },
355
+ })
356
+ /* runs after the remounted rail's own effect (children first), so the snap lands on the live rail */
342
357
  useEffect(() => {
343
- if (!railToggleKey) return undefined
344
- const onKey = (e) => {
345
- if (e.key !== railToggleKey || e.metaKey || e.ctrlKey || e.altKey) return
346
- const t = e.target
347
- if (t?.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t?.tagName)) return
348
- e.preventDefault()
349
- setNavHidden((h) => !h)
350
- }
351
- window.addEventListener('keydown', onKey)
352
- return () => window.removeEventListener('keydown', onKey)
353
- }, [railToggleKey])
358
+ if (!navHidden && wasOpen.current) railToggle.current?.snap?.(true)
359
+ }, [navHidden])
354
360
 
355
361
  /* Option+digit → the rail ROW in that position (never while typing).
356
362
  *
@@ -452,6 +458,7 @@ export default function AppShell({
452
458
  fade={railFade}
453
459
  preset={rail}
454
460
  sections={railSections}
461
+ toggleRef={railToggle}
455
462
  />
456
463
  )}
457
464
  {/* THE BACK OF THE BACK — surface-primary, always, in every app; the
@@ -1,5 +1,5 @@
1
1
  import { useRef, useState } from 'react'
2
- import { NavRail, useMediaQuery } from '@kolkrabbi/kol-component'
2
+ import { NavRail, useMediaQuery, useRailKeys } from '@kolkrabbi/kol-component'
3
3
  import TopControlsBar from './TopControlsBar.jsx'
4
4
  import RailTrigger from './RailTrigger.jsx'
5
5
  import RailFlyout from './RailFlyout.jsx'
@@ -22,6 +22,12 @@ import RailDisplayControls from './RailDisplayControls.jsx'
22
22
  * @param {string} currentPath · {Function} onNavigate `(path) => void`
23
23
  * @param {string} [title] · {string} [icon] · {Function} [onSwitch] · {Function} [onSearch] the nav Rail's switcher and search
24
24
  * @param {'expanded'|'collapsed'|'hidden'} [rail] the nav Rail's state (controlled); `defaultRail` uncontrolled (default `expanded`) · {Function} [onRailChange]
25
+ * @param {false|Object} [railKeys] `\` expanded ↔ collapsed, `⇧\` hide ↔ show (back to its last width) — kol-component's
26
+ * `useRailKeys`, the same prop on AppShell and SiteLayout; `false` off, `{ collapse, hide }` rebinds
27
+ * @param {'push'|'overlay'} [railMode='push'] `push` lays the rail beside the content (it resizes the page); `overlay` floats it
28
+ * over the content at the frame's 24 inset, so expand, collapse and hide never move the page — the
29
+ * content keeps its full width, the top bar and Panels ⌄ stay where they are, and the hidden
30
+ * state's RailTrigger sits over the bar's start (FloatRailOverlayShadowRestore, 2026-11-04)
25
31
  * @param {Array} [defaultExpanded] paths of the nav's sections open at mount (NavRail's own; nothing auto-expands)
26
32
  * @param {ReactNode} [railFooter] the expanded Rail's foot (default RailDisplayControls: theme · Collapse · Hide)
27
33
  * @param {string|string[]} [breadcrumb] the words beside RailTrigger while the nav is hidden
@@ -41,7 +47,7 @@ import RailDisplayControls from './RailDisplayControls.jsx'
41
47
  */
42
48
  export default function FloatLayout({
43
49
  nav = [], currentPath = '', onNavigate, title, icon, onSwitch, onSearch,
44
- rail, defaultRail = 'expanded', onRailChange, defaultExpanded, railFooter, breadcrumb,
50
+ rail, defaultRail = 'expanded', onRailChange, railKeys, railMode = 'push', defaultExpanded, railFooter, breadcrumb,
45
51
  bar = {}, eyebrow, inspector, bottom, inspectorLabel = 'Inspector', inspectorHidden, defaultInspectorHidden = false, onInspectorHiddenChange,
46
52
  surface = 'solid', children, className = '',
47
53
  }) {
@@ -56,6 +62,7 @@ export default function FloatLayout({
56
62
 
57
63
  const phone = useMediaQuery('(max-width: 767px)')
58
64
  const shown = phone ? 'hidden' : railNow
65
+ const overlay = railMode === 'overlay'
59
66
 
60
67
  // the hover flyout: a section's rows beside the 72 Rail, kept open while the pointer is on the slot or the card
61
68
  const [fly, setFly] = useState(null)
@@ -68,6 +75,12 @@ export default function FloatLayout({
68
75
  setFly(item.sub?.length ? { item, el } : null)
69
76
  }
70
77
 
78
+ /* the rail keys (useRailKeys): `\` 280 ↔ 72, `⇧\` hide ↔ show at its last width (`lastShown`) */
79
+ useRailKeys(railKeys, {
80
+ onCollapse: () => { if (railNow !== 'hidden') { setFly(null); setRail(railNow === 'expanded' ? 'collapsed' : 'expanded') } },
81
+ onHide: () => setRail(railNow === 'hidden' ? lastShown.current : 'hidden'),
82
+ })
83
+
71
84
  const restore = [
72
85
  ...(railNow === 'hidden' && !phone ? [{ label: 'Navigation', icon: 'panel-left', onPress: () => setRail(lastShown.current) }] : []),
73
86
  ...(inspector && hidden ? [{ label: inspectorLabel, icon: 'panel-right', onPress: () => setHidden(false) }] : []),
@@ -75,14 +88,14 @@ export default function FloatLayout({
75
88
  const body = typeof inspector === 'function' ? inspector({ hide: () => setHidden(true) }) : inspector
76
89
 
77
90
  return (
78
- <div className={`kol-float-layout flex h-dvh gap-6 overflow-hidden bg-surface-primary p-6 max-md:p-4 ${className}`.trim()}>
91
+ <div className={`kol-float-layout relative flex h-dvh gap-6 overflow-hidden bg-surface-primary p-6 max-md:p-4 ${className}`.trim()}>
79
92
  {shown !== 'hidden' && (
80
93
  <NavRail variant="float" items={nav} currentPath={currentPath} onNavigate={onNavigate}
81
94
  collapsed={shown === 'collapsed'} onCollapsedChange={(c) => { setFly(null); setRail(c ? 'collapsed' : 'expanded') }}
82
95
  title={title} icon={icon} onSwitch={onSwitch} onSearch={onSearch} onHide={() => setRail('hidden')}
83
96
  onItemHover={shown === 'collapsed' ? onItemHover : undefined} defaultExpanded={defaultExpanded}
84
97
  footer={shown === 'expanded' ? (railFooter ?? <RailDisplayControls onCollapse={() => setRail('collapsed')} onHide={() => setRail('hidden')} />) : undefined}
85
- className="shrink-0" />
98
+ className={overlay ? 'absolute inset-y-6 left-6 z-[var(--kol-z-sticky)] !h-auto' : 'shrink-0'} />
86
99
  )}
87
100
  {shown === 'collapsed' && fly && (
88
101
  <span className="contents" onMouseEnter={hold} onMouseLeave={drop}>
@@ -94,7 +107,9 @@ export default function FloatLayout({
94
107
  <div className="flex min-w-0 flex-1 flex-col gap-10 max-md:gap-6">
95
108
  <div className="relative min-w-0 shrink-0">
96
109
  <div className="flex min-w-0 items-center gap-4">
97
- {shown === 'hidden' && <RailTrigger items={nav} currentPath={currentPath} onNavigate={onNavigate} title={title} breadcrumb={phone ? undefined : breadcrumb} surface={surface} className="shrink-0" />}
110
+ {shown === 'hidden' && <RailTrigger items={nav} currentPath={currentPath} onNavigate={onNavigate} title={title} breadcrumb={phone ? undefined : breadcrumb} surface={surface}
111
+ onRestore={phone ? undefined : () => setRail(lastShown.current)}
112
+ className={overlay && !phone ? 'absolute inset-y-0 left-0 z-[var(--kol-z-sticky)]' : 'shrink-0'} />}
98
113
  <TopControlsBar {...bar} panels={restore.length ? { items: restore } : undefined} surface={surface}
99
114
  className={`min-w-0 flex-1 max-md:overflow-x-auto max-md:[scrollbar-width:none] ${bar.className ?? ''}`.trim()} />
100
115
  </div>
@@ -18,13 +18,15 @@ import MoreRows, { FloatMenu } from './MoreSheet.jsx'
18
18
  * @param {string} title the card's head (the app's name)
19
19
  * @param {string|string[]} breadcrumb the words beside the button, or crumbs joined by ` / `
20
20
  * @param {'solid'|'glass-dark'|'glass-light'} surface what the button and the card are made of (default `solid`)
21
+ * @param {Function} [onRestore] a "Show navigation" row at the card's foot brings the rail back as it was (FloatRailOverlayShadowRestore,
22
+ * 2026-11-04 — FloatLayout passes its `lastShown`, the same path as Panels ⌄); unset, no row
21
23
  * @param {string} className
22
24
  */
23
- export default function RailTrigger({ items = [], currentPath = '/', onNavigate, title, breadcrumb, surface = 'solid', className = '' }) {
25
+ export default function RailTrigger({ items = [], currentPath = '/', onNavigate, title, breadcrumb, surface = 'solid', onRestore, className = '' }) {
24
26
  const [open, setOpen] = useState(false)
25
27
  const popover = usePopover({ open, onOpenChange: setOpen, placement: 'bottom-start', offset: 8, dismiss: { outsidePress: (e) => !e.target?.closest?.('.kol-float-level') } })
26
28
  const card = `kol-more-sheet kol-more-sheet-float ${floatSurfaceClass(surface, true)}`
27
- const pick = (x) => { setOpen(false); if (x.onPress) { x.onPress(); return } if (x.path) onNavigate?.(x.path) }
29
+ const pick = (x) => { setOpen(false); if (x.restore) { onRestore?.(); return } if (x.onPress) { x.onPress(); return } if (x.path) onNavigate?.(x.path) }
28
30
  return (
29
31
  <div className={`kol-rail-trigger kol-float-chrome inline-flex items-center gap-4 ${className}`.trim()}>
30
32
  <span ref={popover.refs.setReference} {...popover.getReferenceProps()} className="inline-flex">
@@ -39,7 +41,8 @@ export default function RailTrigger({ items = [], currentPath = '/', onNavigate,
39
41
  </div>
40
42
  )}
41
43
  <FloatMenu cardClass={card} onLeaf={pick}>
42
- <MoreRows variant="float" items={items} active={currentPath} onPick={pick} />
44
+ <MoreRows variant="float" items={items.filter((i) => !i.heading)} active={currentPath} onPick={pick} itemsFirst
45
+ actions={onRestore ? [{ label: 'Show navigation', icon: 'panel-left', restore: true }] : undefined} />
43
46
  </FloatMenu>
44
47
  </PopoverPanel>
45
48
  </div>