@kolkrabbi/kol-shell 0.130.0 → 0.132.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.
@@ -1,148 +0,0 @@
1
- import { useRef, useState } from 'react'
2
- import { NavRail, CommandOverlay, useMediaQuery, useRailKeys, floatMotion, useFloatPresence } 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 · the bottom Rail 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` 264, `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
- * ONE inspector slot (PropertyRail, 264 on the sheet radius), and a `bottom` Rail under both. 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 {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)
31
- * @param {Array} [defaultExpanded] paths of the nav's sections open at mount (NavRail's own; nothing auto-expands)
32
- * @param {ReactNode} [railFooter] the expanded Rail's foot (default RailDisplayControls: theme · Collapse · Hide)
33
- * @param {string|string[]} [breadcrumb] the words beside RailTrigger while the nav is hidden
34
- * @param {Object} [bar] TopControlsBar's props (`document` · `tabs` · `tab` · `onTab` · `onSearch` · `action` · `menu` · `start` · `center` · `end`); `menu` — `[{ label, icon?, onPress }]` — is FloatActionMenu in the top-right corner; `panels` is the frame's
35
- * @param {ReactNode} [eyebrow] a line in the 40 under the bar (float-operational W4.2, 9:14340's WORKSPACE / TASKS): 25 under
36
- * the bar, taking no height, so the content still starts 40 down. Below `md` it sits in flow
37
- * under the bar
38
- * @param {ReactNode|Function} [inspector] the one inspector — a node, or `({ hide }) => node` (hand `hide` to PropertyRail's `onCollapse`)
39
- * @param {ReactNode} [bottom] the bottom Rail (float-operational W1.1, 9:14340's Task index dock + filter capsule): runs under
40
- * the content AND the inspector, 24 below them, at its own height — the content row takes
41
- * what is left. Below `md` it scrolls with the content, after the inspector
42
- * @param {string} [inspectorLabel] its name in Panels ▾ (default "Inspector")
43
- * @param {boolean} [inspectorHidden] controlled; `defaultInspectorHidden` uncontrolled · {Function} [onInspectorHiddenChange]
44
- * @param {'solid'|'glass-dark'|'glass-light'} [surface] what the floats are made of (default `solid`)
45
- * @param {boolean} [panels=true] Panels ⌄ (PanelsRestore) in the bar while a Rail is hidden; `false` drops it — the way back is
46
- * RailTrigger's "Show navigation" row and `⇧\` (FloatSearchAndPanels, 2026-11-04)
47
- * @param {Object} [search] CommandOverlay's props (`open` · `onClose` · `results` · `query` · `onQueryChange` · `onSelect` …):
48
- * the search modal, drawn on this frame's `surface`; the app keeps the data
49
- * @param {boolean|Object} [motion=true] the float family's motion, handed to every piece (FloatActionStatesAndMotion,
50
- * 2026-11-04): the nav Rail's expand ↔ collapse (width) and hide ↔ show (the width opens from and
51
- * closes to 0, fading), RailFlyout and RailTrigger's card in and out, the search modal, and the
52
- * + and its card. `true` the `--kol-float-*` tokens · `false` none · `{ duration, ease }` per app
53
- * @param {ReactNode} children the content
54
- * @param {string} [className]
55
- */
56
- export default function FloatLayout({
57
- nav = [], currentPath = '', onNavigate, title, icon, onSwitch, onSearch,
58
- rail, defaultRail = 'expanded', onRailChange, railKeys, railMode = 'push', defaultExpanded, railFooter, breadcrumb,
59
- bar = {}, eyebrow, inspector, bottom, inspectorLabel = 'Inspector', inspectorHidden, defaultInspectorHidden = false, onInspectorHiddenChange,
60
- surface = 'solid', panels = true, search, motion = true, children, className = '',
61
- }) {
62
- const [ownRail, setOwnRail] = useState(defaultRail)
63
- const [ownHidden, setOwnHidden] = useState(defaultInspectorHidden)
64
- const railNow = rail ?? ownRail
65
- const hidden = inspectorHidden ?? ownHidden
66
- const lastShown = useRef(railNow === 'hidden' ? 'expanded' : railNow)
67
- if (railNow !== 'hidden') lastShown.current = railNow
68
- const setRail = (r) => { if (rail === undefined) setOwnRail(r); onRailChange?.(r) }
69
- const setHidden = (h) => { if (inspectorHidden === undefined) setOwnHidden(h); onInspectorHiddenChange?.(h) }
70
-
71
- const phone = useMediaQuery('(max-width: 767px)')
72
- const shown = phone ? 'hidden' : railNow
73
- const overlay = railMode === 'overlay'
74
- const fm = floatMotion(motion)
75
- /* the rail is held while it hides, so its width closes to 0 instead of the page jumping (FloatActionStatesAndMotion) */
76
- const railShown = shown !== 'hidden'
77
- const railPresence = useFloatPresence(railShown, fm.rail)
78
- const lastRail = useRef(shown)
79
- if (railShown) lastRail.current = shown
80
- const railState = railShown ? shown : lastRail.current
81
-
82
- // the hover flyout: a section's rows beside the 72 Rail, kept open while the pointer is on the slot or the card
83
- const [fly, setFly] = useState(null)
84
- /* the last card is kept so RailFlyout can play its leave after `fly` clears */
85
- const lastFly = useRef(null)
86
- if (fly) lastFly.current = fly
87
- const timer = useRef(0)
88
- const hold = () => clearTimeout(timer.current)
89
- const drop = () => { hold(); timer.current = setTimeout(() => setFly(null), 160) }
90
- const onItemHover = (item, el) => {
91
- if (!item) return drop()
92
- hold()
93
- setFly(item.sub?.length ? { item, el } : null)
94
- }
95
-
96
- /* the rail keys (useRailKeys): `\` 264 ↔ 72, `⇧\` hide ↔ show at its last width (`lastShown`) */
97
- useRailKeys(railKeys, {
98
- onCollapse: () => { if (railNow !== 'hidden') { setFly(null); setRail(railNow === 'expanded' ? 'collapsed' : 'expanded') } },
99
- onHide: () => setRail(railNow === 'hidden' ? lastShown.current : 'hidden'),
100
- })
101
-
102
- const restore = [
103
- ...(railNow === 'hidden' && !phone ? [{ label: 'Navigation', icon: 'panel-left', onPress: () => setRail(lastShown.current) }] : []),
104
- ...(inspector && hidden ? [{ label: inspectorLabel, icon: 'panel-right', onPress: () => setHidden(false) }] : []),
105
- ]
106
- const body = typeof inspector === 'function' ? inspector({ hide: () => setHidden(true) }) : inspector
107
-
108
- return (
109
- <div className={`kol-float-layout relative flex h-dvh gap-6 overflow-hidden bg-surface-primary p-6 max-md:p-4 ${className}`.trim()} style={fm.style}>
110
- {railPresence.mounted && (
111
- <NavRail variant="float" items={nav} currentPath={currentPath} onNavigate={onNavigate} motion={motion}
112
- collapsed={railState === 'collapsed'} onCollapsedChange={(c) => { setFly(null); setRail(c ? 'collapsed' : 'expanded') }}
113
- title={title} icon={icon} onSwitch={onSwitch} onSearch={onSearch} onHide={() => setRail('hidden')}
114
- onItemHover={shown === 'collapsed' ? onItemHover : undefined} defaultExpanded={defaultExpanded}
115
- footer={railState === 'expanded' ? (railFooter ?? <RailDisplayControls onCollapse={() => setRail('collapsed')} onHide={() => setRail('hidden')} />) : undefined}
116
- className={`${overlay ? 'absolute inset-y-6 left-6 z-[var(--kol-z-sticky)] !h-auto' : 'shrink-0'}${railPresence.entering ? ' is-entering' : ''}${railPresence.exiting ? ' is-exiting' : ''}`} />
117
- )}
118
- {shown === 'collapsed' && lastFly.current && (
119
- <span className="contents" onMouseEnter={hold} onMouseLeave={drop}>
120
- <RailFlyout icon={lastFly.current.item.icon} title={lastFly.current.item.label} items={lastFly.current.item.sub} active={currentPath}
121
- anchor={lastFly.current.el} open={!!fly} surface={surface} motion={motion}
122
- onOpenChange={(o) => { if (!o) setFly(null) }}
123
- onPick={(i) => { setFly(null); if (i.path) onNavigate?.(i.path) }} />
124
- </span>
125
- )}
126
- <div className="flex min-w-0 flex-1 flex-col gap-10 max-md:gap-6">
127
- <div className="relative min-w-0 shrink-0">
128
- <div className="flex min-w-0 items-center gap-4">
129
- {shown === 'hidden' && <RailTrigger items={nav} currentPath={currentPath} onNavigate={onNavigate} title={title} breadcrumb={phone ? undefined : breadcrumb} surface={surface} motion={motion}
130
- onRestore={phone ? undefined : () => setRail(lastShown.current)}
131
- className={overlay && !phone ? 'absolute inset-y-0 left-0 z-[var(--kol-z-sticky)]' : 'shrink-0'} />}
132
- <TopControlsBar motion={motion} {...bar} panels={panels && restore.length ? { items: restore } : undefined} surface={surface}
133
- className={`min-w-0 flex-1 max-md:overflow-x-auto max-md:[scrollbar-width:none] ${bar.className ?? ''}`.trim()} />
134
- </div>
135
- {eyebrow && <div className="kol-float-layout-eyebrow absolute inset-x-0 top-full pt-[25px] max-md:static max-md:pt-6">{eyebrow}</div>}
136
- </div>
137
- <div className="flex min-h-0 flex-1 flex-col gap-6 max-md:overflow-y-auto">
138
- <div className="flex min-h-0 flex-1 gap-6 max-md:flex-none max-md:flex-col">
139
- <div className="kol-float-layout-content min-w-0 flex-1 overflow-y-auto max-md:flex-none max-md:overflow-visible">{children}</div>
140
- {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>}
141
- </div>
142
- {bottom && <div className="kol-float-layout-bottom min-w-0 shrink-0">{bottom}</div>}
143
- </div>
144
- </div>
145
- {search && <CommandOverlay {...search} surface={surface} motion={motion} />}
146
- </div>
147
- )
148
- }