@kolkrabbi/kol-shell 0.101.1 → 0.102.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.101.1",
3
+ "version": "0.102.0",
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.335.0",
15
+ "@kolkrabbi/kol-component": ">=0.337.0",
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.335.0",
24
+ "@kolkrabbi/kol-component": "^0.337.0",
25
+ "@kolkrabbi/kol-icons": "^0.64.0",
25
26
  "@kolkrabbi/kol-framework": "^0.69.0",
26
- "@kolkrabbi/kol-theme": "^0.211.1",
27
- "@kolkrabbi/kol-icons": "^0.61.1"
27
+ "@kolkrabbi/kol-theme": "^0.211.1"
28
28
  },
29
29
  "files": [
30
30
  "src",
@@ -0,0 +1,100 @@
1
+ import { useRef, useState } from 'react'
2
+ import { NavRail, useMediaQuery } from '@kolkrabbi/kol-component'
3
+ import TopControlsBar from './TopControlsBar.jsx'
4
+ import RailTrigger from './RailTrigger.jsx'
5
+ import RailFlyout from './RailFlyout.jsx'
6
+ import RailDisplayControls from './RailDisplayControls.jsx'
7
+
8
+ /* taxonomy-ok: module — the float page frame: NavRail float · RailTrigger · RailFlyout · TopControlsBar · PanelsRestore · the inspector slot */
9
+
10
+ /**
11
+ * FloatLayout — The float workspace frame (plan-2026-11-04-float-views W1.1 — kol-float--style 9:15449 "Adaptive
12
+ * workspace", its rules 9:15179). Assembled from the float chrome, nothing drawn here: the nav Rail (`NavRail
13
+ * variant="float"`) in three states — `expanded` 280, `collapsed` 72 (a section's rows open beside a slot on hover,
14
+ * RailFlyout), `hidden` 0 (RailTrigger and the breadcrumb take the corner) — the 64 TopControlsBar, the content slot,
15
+ * and ONE inspector slot (PropertyRail, 272 on the sheet radius). 24 round the page and between the Rails, 40 under the bar.
16
+ *
17
+ * Visibility controls space, selection controls content: a hidden Rail is never removed — Panels ▾ (PanelsRestore)
18
+ * shows in the bar exactly while one is hidden and brings it back as it was (the nav at its last width). Below `md` the
19
+ * nav is the trigger and the inspector stacks under the content.
20
+ *
21
+ * @param {Array} nav NavRail float items — `{ heading }` | `{ icon, label, path, count?, sub? }`
22
+ * @param {string} currentPath · {Function} onNavigate `(path) => void`
23
+ * @param {string} [title] · {string} [icon] · {Function} [onSwitch] · {Function} [onSearch] the nav Rail's switcher and search
24
+ * @param {'expanded'|'collapsed'|'hidden'} [rail] the nav Rail's state (controlled); `defaultRail` uncontrolled (default `expanded`) · {Function} [onRailChange]
25
+ * @param {ReactNode} [railFooter] the expanded Rail's foot (default RailDisplayControls: theme · Collapse · Hide)
26
+ * @param {string|string[]} [breadcrumb] the words beside RailTrigger while the nav is hidden
27
+ * @param {Object} [bar] TopControlsBar's props (`document` · `tabs` · `tab` · `onTab` · `onSearch` · `action` · `start` · `center` · `end`); `panels` is the frame's
28
+ * @param {ReactNode|Function} [inspector] the one inspector — a node, or `({ hide }) => node` (hand `hide` to PropertyRail's `onCollapse`)
29
+ * @param {string} [inspectorLabel] its name in Panels ▾ (default "Inspector")
30
+ * @param {boolean} [inspectorHidden] controlled; `defaultInspectorHidden` uncontrolled · {Function} [onInspectorHiddenChange]
31
+ * @param {'solid'|'glass-dark'|'glass-light'} [surface] what the floats are made of (default `solid`)
32
+ * @param {ReactNode} children the content
33
+ * @param {string} [className]
34
+ */
35
+ export default function FloatLayout({
36
+ nav = [], currentPath = '', onNavigate, title, icon, onSwitch, onSearch,
37
+ rail, defaultRail = 'expanded', onRailChange, railFooter, breadcrumb,
38
+ bar = {}, inspector, inspectorLabel = 'Inspector', inspectorHidden, defaultInspectorHidden = false, onInspectorHiddenChange,
39
+ surface = 'solid', children, className = '',
40
+ }) {
41
+ const [ownRail, setOwnRail] = useState(defaultRail)
42
+ const [ownHidden, setOwnHidden] = useState(defaultInspectorHidden)
43
+ const railNow = rail ?? ownRail
44
+ const hidden = inspectorHidden ?? ownHidden
45
+ const lastShown = useRef(railNow === 'hidden' ? 'expanded' : railNow)
46
+ if (railNow !== 'hidden') lastShown.current = railNow
47
+ const setRail = (r) => { if (rail === undefined) setOwnRail(r); onRailChange?.(r) }
48
+ const setHidden = (h) => { if (inspectorHidden === undefined) setOwnHidden(h); onInspectorHiddenChange?.(h) }
49
+
50
+ const phone = useMediaQuery('(max-width: 767px)')
51
+ const shown = phone ? 'hidden' : railNow
52
+
53
+ // the hover flyout: a section's rows beside the 72 Rail, kept open while the pointer is on the slot or the card
54
+ const [fly, setFly] = useState(null)
55
+ const timer = useRef(0)
56
+ const hold = () => clearTimeout(timer.current)
57
+ const drop = () => { hold(); timer.current = setTimeout(() => setFly(null), 160) }
58
+ const onItemHover = (item, el) => {
59
+ if (!item) return drop()
60
+ hold()
61
+ setFly(item.sub?.length ? { item, el } : null)
62
+ }
63
+
64
+ const restore = [
65
+ ...(railNow === 'hidden' && !phone ? [{ label: 'Navigation', icon: 'panel-left', onPress: () => setRail(lastShown.current) }] : []),
66
+ ...(inspector && hidden ? [{ label: inspectorLabel, icon: 'panel-right', onPress: () => setHidden(false) }] : []),
67
+ ]
68
+ const body = typeof inspector === 'function' ? inspector({ hide: () => setHidden(true) }) : inspector
69
+
70
+ return (
71
+ <div className={`kol-float-layout flex h-dvh gap-6 overflow-hidden bg-surface-primary p-6 max-md:p-4 ${className}`.trim()}>
72
+ {shown !== 'hidden' && (
73
+ <NavRail variant="float" items={nav} currentPath={currentPath} onNavigate={onNavigate}
74
+ collapsed={shown === 'collapsed'} onCollapsedChange={(c) => { setFly(null); setRail(c ? 'collapsed' : 'expanded') }}
75
+ title={title} icon={icon} onSwitch={onSwitch} onSearch={onSearch} onHide={() => setRail('hidden')}
76
+ onItemHover={shown === 'collapsed' ? onItemHover : undefined}
77
+ footer={shown === 'expanded' ? (railFooter ?? <RailDisplayControls onCollapse={() => setRail('collapsed')} onHide={() => setRail('hidden')} />) : undefined}
78
+ className="shrink-0" />
79
+ )}
80
+ {shown === 'collapsed' && fly && (
81
+ <span className="contents" onMouseEnter={hold} onMouseLeave={drop}>
82
+ <RailFlyout icon={fly.item.icon} title={fly.item.label} items={fly.item.sub} active={currentPath} anchor={fly.el} surface={surface}
83
+ onOpenChange={(o) => { if (!o) setFly(null) }}
84
+ onPick={(i) => { setFly(null); if (i.path) onNavigate?.(i.path) }} />
85
+ </span>
86
+ )}
87
+ <div className="flex min-w-0 flex-1 flex-col gap-10 max-md:gap-6">
88
+ <div className="flex min-w-0 shrink-0 items-center gap-4">
89
+ {shown === 'hidden' && <RailTrigger items={nav} currentPath={currentPath} onNavigate={onNavigate} title={title} breadcrumb={phone ? undefined : breadcrumb} surface={surface} className="shrink-0" />}
90
+ <TopControlsBar {...bar} panels={restore.length ? { items: restore } : undefined} surface={surface}
91
+ className={`min-w-0 flex-1 max-md:overflow-x-auto max-md:[scrollbar-width:none] ${bar.className ?? ''}`.trim()} />
92
+ </div>
93
+ <div className="flex min-h-0 flex-1 gap-6 max-md:flex-col max-md:overflow-y-auto">
94
+ <div className="kol-float-layout-content min-w-0 flex-1 overflow-y-auto max-md:flex-none max-md:overflow-visible">{children}</div>
95
+ {body && !hidden && <aside aria-label={inspectorLabel} className="max-h-full shrink-0 self-start overflow-y-auto [scrollbar-width:none] max-md:max-h-none max-md:self-stretch">{body}</aside>}
96
+ </div>
97
+ </div>
98
+ </div>
99
+ )
100
+ }
package/src/index.js CHANGED
@@ -31,6 +31,8 @@ export { default as RailTrigger } from './RailTrigger.jsx'
31
31
  export { default as RailFlyout } from './RailFlyout.jsx'
32
32
  export { default as RailDisplayControls } from './RailDisplayControls.jsx'
33
33
  export { AccountFooter, StatusStrip, Breadcrumb, FooterStrip, PeriodNav, DataStatus } from './WorkspaceStrips.jsx'
34
+ // the float page frame, assembled from the chrome above (plan-2026-11-04-float-views W1.1)
35
+ export { default as FloatLayout } from './FloatLayout.jsx'
34
36
  export { default as PhoneNav, PHONE_NAV_VARIANTS } from './PhoneNav.jsx'
35
37
  export { default as TransportPill } from './TransportPill.jsx'
36
38
  export { default as PageShell, PageBleed } from './PageShell.jsx'