@kolkrabbi/kol-shell 0.96.0 → 0.98.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.96.0",
3
+ "version": "0.98.0",
4
4
  "private": false,
5
5
  "description": "The application shell",
6
6
  "license": "MIT",
@@ -15,16 +15,16 @@
15
15
  "@kolkrabbi/kol-component": ">=0.323.0",
16
16
  "@kolkrabbi/kol-framework": ">=0.55.0",
17
17
  "@kolkrabbi/kol-icons": ">=0.16.0",
18
- "@kolkrabbi/kol-theme": ">=0.201.0",
18
+ "@kolkrabbi/kol-theme": ">=0.207.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-icons": "^0.55.0",
25
- "@kolkrabbi/kol-component": "^0.323.0",
26
24
  "@kolkrabbi/kol-framework": "^0.67.0",
27
- "@kolkrabbi/kol-theme": "^0.206.0"
25
+ "@kolkrabbi/kol-icons": "^0.56.0",
26
+ "@kolkrabbi/kol-component": "^0.323.0",
27
+ "@kolkrabbi/kol-theme": "^0.207.0"
28
28
  },
29
29
  "files": [
30
30
  "src",
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from 'react'
2
2
  import { TabsRow, TABBAR_H, TABBAR_PILL_H, TABBAR_PILL_INSET, tabbarPillWidth, tabbarPillSlot, floatSurfaceClass, usePopover, PopoverPanel } from '@kolkrabbi/kol-component'
3
- import MoreRows from './MoreSheet.jsx'
3
+ import MoreRows, { FloatMenu } from './MoreSheet.jsx'
4
4
 
5
5
  /* taxonomy-ok: molecule — TabsRow's pill + MoreRows sheets of Buttons */
6
6
 
@@ -69,8 +69,13 @@ import MoreRows from './MoreSheet.jsx'
69
69
  * `--kol-oq-04` ground and `--kol-surface-on-primary` ink (`.kol-btn-nav`'s hover tokens).
70
70
  *
71
71
  * THE FLOAT (AppFloatNav, 2026-10-30):
72
- * @param {Array} items[].sub `[{ label, icon?, onPress }]` — a row that opens its own rows above its slot instead of
73
- * routing (fxr: Randomiser → Generate, Effects); lit while they are open
72
+ * @param {Array} items[].sub `[{ label, icon?, onPress?, path?, sub? }]` — a row that opens its own rows above its slot instead of
73
+ * routing (fxr: Randomiser → Generate, Effects); lit while they are open. A row without
74
+ * `onPress` routes to its `path`
75
+ * NESTED LEVELS (FloatsOwnItems, kol-fxr 2026-10-31): a sub row with its own `sub` opens a level, the same row shape to any
76
+ * depth — `sub`, the More's `actions` and the transport's `sheetFor` rows alike (MoreSheet's `FloatMenu`). On the `dock` a
77
+ * level opens BESIDE its row (the + menu's popover); on every phone variant it REPLACES the card's rows under a Back row. A
78
+ * leaf runs and closes every level; Escape and an outside press close all; ↑ ↓ move, → / Enter open a level, ← goes back one.
74
79
  * Its menus are the floating style B (`variant="float"` on the rows, `.kol-more-sheet-float`) — the board's.
75
80
  * @param {boolean} menuBorder the sheets' 1px hairline (`.kol-more-sheet-bordered`) — off by default, the board's menus have none
76
81
  * THE FOUR VARIANTS (user ruling 2026-10-30): `mobile` · `dock` · `panel` · `transport` — nothing else.
@@ -120,7 +125,8 @@ function FloatNav({ items = [], currentPath = '/', onNavigate, actions = [], sha
120
125
  const [moreEl, setMoreEl] = useState(null)
121
126
  const findMore = useCallback((n) => setMoreEl(n?.querySelector('button[aria-label="More"]') ?? null), [])
122
127
  /* offset: 12 off the pill — the slot sits 4 inside it; crossAxis drops the card's bottom to the pill's */
123
- const morePop = usePopover({ open: dock && open, onOpenChange: setOpen, placement: 'right-end', offset: { mainAxis: 16, crossAxis: 4 }, click: false, referenceElement: moreEl })
128
+ /* an outside press closes it — except one on a nested level, which hangs beside it in its own portal (FloatMenu) */
129
+ const morePop = usePopover({ open: dock && open, onOpenChange: setOpen, placement: 'right-end', offset: { mainAxis: 16, crossAxis: 4 }, click: false, referenceElement: moreEl, dismiss: { outsidePress: (e) => !e.target?.closest?.('.kol-float-level') } })
124
130
  /* the row whose `sub` rows are open */
125
131
  const [sub, setSub] = useState(null)
126
132
  useEffect(() => { setOpen(false); setSub(null) }, [currentPath])
@@ -184,6 +190,11 @@ function FloatNav({ items = [], currentPath = '/', onNavigate, actions = [], sha
184
190
  : { bottom: pill ? `calc(env(safe-area-inset-bottom, 0px) + ${TABBAR_PILL_INSET}px)` : 'env(safe-area-inset-bottom, 0px)' }),
185
191
  width: 'max-content', minWidth: 220, maxWidth: `calc(100vw - ${(pill ? TABBAR_PILL_H : TABBAR_H) + 36}px)`,
186
192
  }
193
+ const card = `kol-more-sheet kol-more-sheet-float ${floatSurfaceClass(surface, true)}${menuBorder ? ' kol-more-sheet-bordered' : ''}`
194
+ /* a sub row (any level) picked: close everything; its `onPress` has run, else it routes */
195
+ const pickSub = (x) => { setSub(null); if (!x.onPress && x.path) onNavigate?.(x.path) }
196
+ /* a nested leaf in More: close it; its `onPress` has run, else it routes */
197
+ const pickMoreLeaf = (x) => { setOpen(false); if (!x.onPress && x.path) onNavigate?.(x.path) }
187
198
  const press = (v) => {
188
199
  if (v === MORE) { setSub(null); setOpen((o) => !o); return }
189
200
  const item = inBar.find((i) => key(i) === v)
@@ -199,8 +210,10 @@ function FloatNav({ items = [], currentPath = '/', onNavigate, actions = [], sha
199
210
  <button type="button" aria-label="Close" className="kol-phone-nav-scrim" onClick={() => setSub(null)} />
200
211
  )}
201
212
  {sub && (
202
- <div className={`kol-phone-nav-more kol-more-sheet kol-more-sheet-float ${floatSurfaceClass(surface, true)}${menuBorder ? ' kol-more-sheet-bordered' : ''}`} role="menu" aria-label={inBar.find((i) => key(i) === sub)?.label} style={overSlot(inBar.findIndex((i) => key(i) === sub))}>
203
- <MoreRows variant="float" actions={inBar.find((i) => key(i) === sub)?.sub} onPick={() => setSub(null)} />
213
+ <div className={`kol-phone-nav-more ${card}`} role="menu" aria-label={inBar.find((i) => key(i) === sub)?.label} style={overSlot(inBar.findIndex((i) => key(i) === sub))}>
214
+ <FloatMenu beside={dock} cardClass={card} onLeaf={pickSub}>
215
+ <MoreRows variant="float" actions={inBar.find((i) => key(i) === sub)?.sub} onPick={pickSub} />
216
+ </FloatMenu>
204
217
  </div>
205
218
  )}
206
219
  {open && !dock && (
@@ -209,16 +222,20 @@ function FloatNav({ items = [], currentPath = '/', onNavigate, actions = [], sha
209
222
  <button type="button" aria-label="Close more" className={`kol-phone-nav-scrim${moreKeepsOpen ? '' : ' kol-overlay-scrim'}`} onClick={() => setOpen(false)} />
210
223
  )}
211
224
  {open && !dock && (
212
- <div className={`kol-phone-nav-more kol-more-sheet kol-more-sheet-float ${floatSurfaceClass(surface, true)}${menuBorder ? ' kol-more-sheet-bordered' : ''}`} role="menu" aria-label="More" style={sheetStyle}>
225
+ <div className={`kol-phone-nav-more ${card}`} role="menu" aria-label="More" style={sheetStyle}>
213
226
  {/* the nav, the page's actions, then the pinned foot (frame A2) */}
227
+ <FloatMenu cardClass={card} onLeaf={pickMoreLeaf}>
214
228
  <MoreRows variant="float" actions={actions} items={before} itemsFirst active={active} onPick={(x) => { setOpen(false); if (x.onPress && !actions.includes(x)) { x.onPress(); return } if (x.path) onNavigate?.(x.path) }} />
215
229
  {after.length > 0 && <MoreRows variant="float" items={after} active={active} onPick={(x) => { setOpen(false); if (x.onPress) { x.onPress(); return } if (x.path) onNavigate?.(x.path) }} />}
230
+ </FloatMenu>
216
231
  </div>
217
232
  )}
218
233
  {dock && (
219
- <PopoverPanel popover={morePop} panel={false} focus={false} className={`kol-more-sheet kol-more-sheet-float ${floatSurfaceClass(surface, true)}${menuBorder ? ' kol-more-sheet-bordered' : ''}`} style={{ minWidth: 220, maxWidth: 'calc(100vw - 24px)' }}>
234
+ <PopoverPanel popover={morePop} panel={false} focus={false} className={card} style={{ minWidth: 220, maxWidth: 'calc(100vw - 24px)' }}>
235
+ <FloatMenu beside cardClass={card} onLeaf={pickMoreLeaf}>
220
236
  <MoreRows variant="float" actions={actions} items={before} itemsFirst active={active} onPick={(x) => { setOpen(false); if (x.onPress && !actions.includes(x)) { x.onPress(); return } if (x.path) onNavigate?.(x.path) }} />
221
237
  {after.length > 0 && <MoreRows variant="float" items={after} active={active} onPick={(x) => { setOpen(false); if (x.onPress) { x.onPress(); return } if (x.path) onNavigate?.(x.path) }} />}
238
+ </FloatMenu>
222
239
  </PopoverPanel>
223
240
  )}
224
241
  {/* `contents` — no box; it only hands the ··· slot to the popover */}
@@ -260,8 +277,8 @@ function FloatNav({ items = [], currentPath = '/', onNavigate, actions = [], sha
260
277
  * `onPress` and closes the sheet.
261
278
  *
262
279
  * @param {Array} items `[{ id, icon, label, onPress?, selected? }]` in pill order
263
- * @param {Object} sheetFor `{ [id]: [{ label, icon?, onPress, checked? }] }` — rows for a slot that opens a sheet;
264
- * `checked` marks the current pick with the 22px check (MoreRows)
280
+ * @param {Object} sheetFor `{ [id]: [{ label, icon?, onPress, checked?, sub? }] }` — rows for a slot that opens a sheet;
281
+ * `checked` marks the current pick with the 22px check (MoreRows); `sub` opens a level in place
265
282
  * @param {'bottom'|'top'} placement the pill's edge (default bottom)
266
283
  * @param {boolean} foldable a sideways swipe folds it into the right edge tab
267
284
  * @param {boolean} folded · {Function} onFoldChange the folded state, controlled (else the pill holds it)
@@ -303,7 +320,9 @@ function Transport({ items = [], sheetFor = {}, placement = 'bottom', foldable =
303
320
  )}
304
321
  {sheet && (
305
322
  <div className={`kol-phone-nav-more kol-more-sheet kol-more-sheet-float ${floatSurfaceClass(surface, true)}${menuBorder ? ' kol-more-sheet-bordered' : ''}`} role="menu" aria-label={items[at]?.label} style={sheetStyle}>
306
- <MoreRows variant="float" actions={sheetFor[sheet]} onPick={() => setSheet(null)} />
323
+ <FloatMenu onLeaf={() => setSheet(null)}>
324
+ <MoreRows variant="float" actions={sheetFor[sheet]} onPick={() => setSheet(null)} />
325
+ </FloatMenu>
307
326
  </div>
308
327
  )}
309
328
  <TabsRow
package/src/AppHub.jsx CHANGED
@@ -313,7 +313,7 @@ function HubFrame({
313
313
  /* HOME'S BUTTONS ON A PHONE (user 2026-10-23: *"put new and walkthrough in the more button … crowded under the files"*):
314
314
  * with the bar, New and Walkthrough ride the top of its More sheet on Home and the page's foot row goes; with the drawer
315
315
  * (no More), they stay on the page */
316
- const barOn = ['bar', 'pill'].includes(shell?.touch ?? RAIL_PRESETS.app.phone)
316
+ const barOn = ['bar', 'pill', 'floats'].includes(shell?.touch ?? RAIL_PRESETS.app.phone)
317
317
  const onHome = home && currentPath === homePath
318
318
  /* the signed-in account as a row — Home's menu and the phone's More end on it (HomeMenuAccountRow) */
319
319
  const accountAction = signIn?.signedIn && (signIn.user || signIn.account || signIn.onProfile)
@@ -413,7 +413,7 @@ function HubFrame({
413
413
  <AppShell
414
414
  items={rows}
415
415
  bottomItems={bottom}
416
- barItems={signedOutHome && home.chromes?.length ? home.chromes.map((c) => ({ id: c.label, label: c.label, icon: c.icon, onPress: c.onPress })) : barItems}
416
+ barItems={signedOutHome && home.chromes?.length ? home.chromes.map((c) => ({ id: c.label, label: c.label, icon: c.icon, onPress: c.onPress, sub: c.sub })) : barItems}
417
417
  barActions={homeActions}
418
418
  phoneNav={(() => {
419
419
  const sheet = [...rows, ...bottom.map((r) => ({ ...r, icon: r.icon === ACCOUNT_GLYPH ? 'user' : r.icon, foot: true }))]
package/src/AppShell.jsx CHANGED
@@ -58,7 +58,7 @@ import { TABBAR_H, TABBAR_PILL_H, TABBAR_PILL_INSET, MastheadContext, RAIL_PRESE
58
58
  * lands the rail on the new rest. Fixed here, not in a consumer: the route-entry effect
59
59
  * below runs after its children's, so a consumer could only hide the rail a frame late
60
60
  * (fxr's `HomeStage` rAF). The Hub passes it for the signed-out Home
61
- * @param {'shell'|'bare'|'overlay'|'drawer'|'bar'|'pill'} props.touch the touch-primary policy (default 'shell' = the rail regardless):
61
+ * @param {'shell'|'bare'|'overlay'|'drawer'|'bar'|'pill'|'floats'} props.touch the touch-primary policy (default 'shell' = the rail regardless):
62
62
  * 'drawer' takes the rail OFF-CANVAS below `drawerBelow`, hands its width
63
63
  * back to the content, and renders a trigger that brings it in over a scrim.
64
64
  * Tapping a destination closes it. (ShellRailNoDrawerOnMobile, kol-chess
@@ -78,6 +78,20 @@ import { TABBAR_H, TABBAR_PILL_H, TABBAR_PILL_INSET, MastheadContext, RAIL_PRESE
78
78
  * description. One app, one header — media-hub wore both. NO DEFAULT (user, 2026-09-29): unset,
79
79
  * every page renders as its own props say, so a consumer's bump moves nothing
80
80
  * (fxr · mirror · monitor are mono by ruling).
81
+ * @param {Object} [props.floats] THE TWO FLOATS (PhoneTwoFloatLayout, kol-fxr 2026-10-31 — fxr's Labs on a phone, frame E):
82
+ * `touch="floats"` puts the nav in an AppFloatNav `panel` overlay pinned at the TOP (the
83
+ * bar's rows and actions), an AppFloatNav `transport` overlay over the foot, and between
84
+ * them the stage (children) and a bottom Rail. `{ transport: { items, sheetFor, … },
85
+ * rail: node, railHeight = '50dvh' }`. The stage starts under the top float and the Rail's
86
+ * rows scroll clear of the transport — both insets are `TABBAR_PILL_INSET + TABBAR_PILL_H +
87
+ * TABBAR_PILL_INSET` plus the safe area; the Rail rises on `--kol-shadow-rail-up`, no rule.
88
+ * THE PAGE'S OWN ROWS (FloatsOwnItems, kol-fxr 2026-10-31 — *"keep it as flexible as possible"*):
89
+ * `floats.items` (AppFloatNav items — `{ path | id, icon, label, onPress?, selected?, sub? }`)
90
+ * take the top float's slots and `floats.actions` (`[{ label, icon?, onPress, sub? }]`) its
91
+ * More's actions, wherever the app passes them — the page's route, typically. THE ONE RULE:
92
+ * the More keeps the app's whole nav (`barItems`, else items + bottomItems) — the page's
93
+ * rows replace the slots, never the way back (a `phoneNav.sheetItems` still wins). Unset,
94
+ * the top float is the app's nav and `barActions`, as 0.97.0
81
95
  * @param {Array} [props.barActions] `[{ label, icon?, onPress }]` — the page's buttons in the bar's More sheet, under the nav (PhoneNav `actions`)
82
96
  * @param {'mobile'|'panel'|'transport'} [props.navVariant='mobile'] THE PHONE PILL'S PRESET (PhoneNavVariants, kol-fxr 2026-10-28 —
83
97
  * the Home pill kept its hairline while Labs tuned its own by hand): `mobile` (was `nav`) is no hairline,
@@ -170,6 +184,7 @@ export default function AppShell({
170
184
  drawerOpenOn = NO_PATHS,
171
185
  barItems,
172
186
  barActions,
187
+ floats: floatsProp,
173
188
  navVariant = 'mobile',
174
189
  moreItems,
175
190
  phoneNav,
@@ -198,10 +213,16 @@ export default function AppShell({
198
213
  const drawer = touch === 'drawer' && narrow
199
214
  /* the bar steps aside on a tool's paths — no bar, no bar height; the rail stays off too (a phone has no rail) */
200
215
  /* `pill` is the bar in TabsRow's pill shape (user 2026-10-23) — the same rows, the same More, floated off the edge */
201
- const barLike = touch === 'bar' || touch === 'pill'
216
+ const barLike = touch === 'bar' || touch === 'pill' || touch === 'floats'
202
217
  /* the preset's phone shape when the app did not say (AppHub passes it through) */
203
218
  const barAside = barLike && narrow && barHiddenOn.some((x) => (x === '/' ? currentPath === '/' : currentPath === x || currentPath?.startsWith(`${x}/`)))
204
219
  const bar = barLike && narrow && !barAside
220
+ /* THE TWO FLOATS: the bar is the top float, and the page is a column — the stage, then the Rail */
221
+ const floats = bar && touch === 'floats'
222
+ const floatClear = `${TABBAR_PILL_INSET + TABBAR_PILL_H + TABBAR_PILL_INSET}px`
223
+ /* the app's nav, and the page's own rows when it passes them — the app's nav then lives in the top float's More */
224
+ const appNav = barItems ?? [...(items ?? []), ...(bottomItems ?? [])]
225
+ const pageRows = floats && floatsProp?.items?.length ? floatsProp.items : null
205
226
  const [drawerOpen, setDrawerOpen] = useState(false)
206
227
  useEffect(() => { if (!drawer) setDrawerOpen(false) }, [drawer])
207
228
  useEffect(() => {
@@ -403,7 +424,8 @@ export default function AppShell({
403
424
  onClick={() => setDrawerOpen(false)}
404
425
  />
405
426
  )}
406
- {bar && <AppFloatNav items={barItems ?? [...(items ?? []), ...(bottomItems ?? [])]} actions={barActions} shape={touch === 'pill' ? 'pill' : 'bar'} variant={navVariant} moreItems={moreItems} {...phoneNav} currentPath={currentPath} onNavigate={navigate} />}
427
+ {bar && <AppFloatNav items={pageRows ?? appNav} actions={floats && floatsProp?.actions ? floatsProp.actions : barActions} shape={touch === 'bar' ? 'bar' : 'pill'} variant={floats ? 'panel' : navVariant} moreItems={moreItems} {...(pageRows && { sheetItems: appNav })} {...phoneNav} currentPath={currentPath} onNavigate={navigate} />}
428
+ {floats && floatsProp?.transport?.items?.length > 0 && <AppFloatNav variant="transport" foldable {...floatsProp.transport} />}
407
429
  {!navHidden && !bar && !barAside && (
408
430
  <Rail
409
431
  items={items}
@@ -425,9 +447,18 @@ export default function AppShell({
425
447
  * through the drag and the snap (RailFlatGrabOpen) */}
426
448
  <div className="bg-surface-primary min-w-0" style={{ marginLeft: `var(--kol-shell-rail-width)`, '--kol-shell-page-wash': pageWash, /* `bar` pads the page by its height; `pill` FLOATS OVER the page (user 2026-10-23: *"why doesn't it overlay the bottom"*) —
427
449
  * no pad, the page runs under it, and `--kol-shell-bar-clear` is what a scroll region's last row and a fixed foot clear */
428
- ...(bar && touch !== 'pill' && { '--kol-shell-bar-h': `calc(${TABBAR_H}px + env(safe-area-inset-bottom, 0px))`, paddingBottom: 'var(--kol-shell-bar-h)' }),
429
- ...(bar && touch === 'pill' && { '--kol-shell-bar-h': '0px', '--kol-shell-bar-clear': `calc(${TABBAR_PILL_H + TABBAR_PILL_INSET}px + env(safe-area-inset-bottom, 0px))` }), ...(barAside && { '--kol-shell-bar-h': '0px' }) }}>
430
- {children}
450
+ ...(bar && touch === 'bar' && { '--kol-shell-bar-h': `calc(${TABBAR_H}px + env(safe-area-inset-bottom, 0px))`, paddingBottom: 'var(--kol-shell-bar-h)' }),
451
+ ...(bar && touch === 'pill' && { '--kol-shell-bar-h': '0px', '--kol-shell-bar-clear': `calc(${TABBAR_PILL_H + TABBAR_PILL_INSET}px + env(safe-area-inset-bottom, 0px))` }), ...(barAside && { '--kol-shell-bar-h': '0px' }), ...(floats && { '--kol-shell-bar-h': '0px' }) }}>
452
+ {floats ? (
453
+ <div className="flex h-dvh flex-col">
454
+ {/* THE STAGE OWNS THE PAGE'S GROUND (PhoneTwoFloatLayout): it paints the wash under the top float too and hands
455
+ * the page `transparent` — PageLayout's rule (kol-components-shell.css), one owner per pixel, no band under the float */}
456
+ <div className="min-h-0 flex-1 overflow-y-auto" style={{ paddingTop: `calc(env(safe-area-inset-top, 0px) + ${floatClear})`, background: pageWash ?? undefined, '--kol-shell-page-wash': pageWash ? 'transparent' : undefined, '--kol-shell-bar-h': floatClear }}>{children}</div>
457
+ {floatsProp?.rail != null && (
458
+ <div className="shrink-0 overflow-y-auto bg-surface-primary shadow-[var(--kol-shadow-rail-up)]" style={{ maxHeight: floatsProp.railHeight ?? '50dvh', paddingBottom: `calc(${floatClear} + env(safe-area-inset-bottom, 0px))` }}>{floatsProp.rail}</div>
459
+ )}
460
+ </div>
461
+ ) : children}
431
462
  </div>
432
463
  </div>
433
464
  </SettingsToggleContext.Provider>
package/src/MoreSheet.jsx CHANGED
@@ -1,6 +1,11 @@
1
- import { Avatar, Button } from '@kolkrabbi/kol-component'
1
+ import { createContext, useContext, useEffect, useRef, useState } from 'react'
2
+ import { Avatar, Button, usePopover, PopoverPanel } from '@kolkrabbi/kol-component'
2
3
  import { Icon } from '@kolkrabbi/kol-icons'
3
4
 
5
+ /* the open level a row sits in (FloatMenu); null outside one, where a row's `sub` is ignored as before */
6
+ const Level = createContext(null)
7
+ const FLOAT_ROW = 'w-full justify-start kol-btn-float'
8
+
4
9
  /* taxonomy-ok: molecule — a column of nav Buttons */
5
10
 
6
11
  /**
@@ -25,19 +30,28 @@ export default function MoreRows({ actions = [], items = [], active, onPick, ite
25
30
  /* the float row's height, inset and gap are the theme's (`.kol-more-sheet-float`, round 3) — no h-11 / gap-3 utility,
26
31
  * which would outrank the components layer */
27
32
  const float = variant === 'float'
28
- const rowCls = float ? 'w-full justify-start kol-btn-float' : 'w-full justify-start h-11 gap-3'
33
+ const rowCls = float ? FLOAT_ROW : 'w-full justify-start h-11 gap-3'
34
+ const level = useContext(Level)
29
35
  const glyph = float ? 'var(--kol-float-ic)' : 22
30
36
  const acts = (
31
37
  <>
32
- {actions.map((a) => (
33
- <Button key={a.label} variant="nav" size="lg" iconLeft={a.checked === undefined && !a.avatar ? a.icon : undefined} iconSize={glyph} className={rowCls} onClick={() => { onPick?.(a); a.onPress?.() }}>
34
- {a.avatar && <Avatar src={a.avatar} alt="" size="xs" />}
35
- {a.checked !== undefined && (
36
- <span className="inline-flex items-center justify-center shrink-0" style={{ width: float ? 'var(--kol-float-ic)' : 22, height: float ? 'var(--kol-float-ic)' : 22 }}>{a.checked && <Icon name="check" size={22} />}</span>
37
- )}
38
- {a.label}
39
- </Button>
40
- ))}
38
+ {actions.map((a) => {
39
+ /* a row with `sub` inside a FloatMenu opens its level instead of picking — the chevron at the row's end */
40
+ const nests = level && a.sub?.length > 0
41
+ return (
42
+ /* a nesting row draws its own glyph so the label can take the room between it and the chevron; 8 apart, as Button's */
43
+ <Button key={a.label} variant="nav" size="lg" iconLeft={a.checked === undefined && !a.avatar && !nests ? a.icon : undefined} iconSize={glyph}
44
+ className={rowCls} style={nests ? { gap: 8 } : undefined}
45
+ aria-haspopup={nests ? 'menu' : undefined} aria-expanded={nests ? level.isOpen(a) : undefined}
46
+ onClick={(e) => { if (nests) { level.open(a, e.currentTarget); return } onPick?.(a); a.onPress?.() }}>
47
+ {a.avatar && <Avatar src={a.avatar} alt="" size="xs" />}
48
+ {a.checked !== undefined && (
49
+ <span className="inline-flex items-center justify-center shrink-0" style={{ width: float ? 'var(--kol-float-ic)' : 22, height: float ? 'var(--kol-float-ic)' : 22 }}>{a.checked && <Icon name="check" size={22} />}</span>
50
+ )}
51
+ {nests ? <>{a.icon && <Icon name={a.icon} size={glyph} />}<span className="flex-1 text-left">{a.label}</span><Icon name="chevron-right" size={glyph} className="shrink-0 text-oq-48" /></> : a.label}
52
+ </Button>
53
+ )
54
+ })}
41
55
  </>
42
56
  )
43
57
  const dests = (
@@ -60,3 +74,77 @@ export default function MoreRows({ actions = [], items = [], active, onPick, ite
60
74
  )
61
75
  return itemsFirst ? <>{dests}{acts}</> : <>{acts}{dests}</>
62
76
  }
77
+
78
+ const rowKey = (r) => r.id ?? r.path ?? r.label
79
+
80
+ /**
81
+ * FloatMenu — A float's card with NESTED LEVELS (FloatsOwnItems, kol-fxr 2026-10-31 — *"does the float nav offer nested
82
+ * menus"*). Wraps the card's first level (`children`, MoreRows); a MoreRows action with `sub` opens the next level, the same
83
+ * row shape to any depth (`sub[].sub[].sub…`). How a level opens is one rule, by room:
84
+ * - `beside` (the desk's `dock`) — a card of the same chrome beside its parent row, right of it, the bottom edges on one
85
+ * line, through the existing popover (`usePopover` + `PopoverPanel`, flips and shifts at the window's edge);
86
+ * - else (every phone variant) — the level REPLACES the card's rows, under a Back row naming the parent.
87
+ * A leaf runs its `onPress`, then `onLeaf(row)` closes every level (the caller closes the card — Escape and an outside press
88
+ * are the card's, and closing it closes everything). Keys: ↑ ↓ move, → or Enter opens a level, ← goes back one.
89
+ *
90
+ * @param {boolean} beside levels open beside their row (else they replace the card's rows)
91
+ * @param {string} cardClass a beside level's chrome — the first card's classes
92
+ * @param {Function} onLeaf `(row) => void` — a nested leaf was picked (its `onPress` has run); close everything here
93
+ */
94
+ export function FloatMenu({ beside = false, cardClass = '', onLeaf, children }) {
95
+ /* the open rows, outermost first — `{ row, el }`, `el` the row a beside level hangs off.
96
+ * ponytail: the row object is kept as opened; a consumer that rebuilds its rows mid-open sees the old `sub` until reopened */
97
+ const [trail, setTrail] = useState([])
98
+ const at = (depth) => ({
99
+ open: (row, el) => setTrail((t) => (t[depth] && rowKey(t[depth].row) === rowKey(row) ? t.slice(0, depth) : [...t.slice(0, depth), { row, el }])),
100
+ isOpen: (row) => !!trail[depth] && rowKey(trail[depth].row) === rowKey(row),
101
+ })
102
+ const back = (depth) => { const parent = trail[depth - 1]?.el; setTrail((t) => t.slice(0, depth - 1)); if (beside) parent?.focus({ preventScroll: true }) }
103
+ const keys = (depth) => (e) => {
104
+ const rows = [...e.currentTarget.querySelectorAll('button')]
105
+ const i = rows.indexOf(document.activeElement)
106
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') rows[(i + (e.key === 'ArrowDown' ? 1 : -1) + rows.length) % rows.length]?.focus()
107
+ else if (e.key === 'ArrowRight' && e.target.getAttribute?.('aria-haspopup')) { if (e.target.getAttribute('aria-expanded') !== 'true') e.target.click() }
108
+ else if (e.key === 'ArrowLeft' && depth > 0) back(depth)
109
+ else return
110
+ e.preventDefault()
111
+ e.stopPropagation()
112
+ }
113
+ const level = (depth, rows, lead) => (
114
+ <Level.Provider value={at(depth)}>
115
+ <LevelRows key={`${depth}:${rowKey(trail[depth - 1].row)}`} onKeyDown={keys(depth)}>
116
+ {lead}
117
+ <MoreRows variant="float" actions={rows} onPick={onLeaf} />
118
+ </LevelRows>
119
+ </Level.Provider>
120
+ )
121
+
122
+ if (!beside && trail.length) {
123
+ const d = trail.length
124
+ return level(d, trail[d - 1].row.sub, (
125
+ <Button variant="nav" size="lg" iconLeft="chevron-left" iconSize="var(--kol-float-ic)" className={FLOAT_ROW} onClick={() => back(d)}>{trail[d - 1].row.label}</Button>
126
+ ))
127
+ }
128
+ return (
129
+ <Level.Provider value={at(0)}>
130
+ <div className="contents" onKeyDown={keys(0)}>{children}</div>
131
+ {beside && trail.map((s, i) => (
132
+ <Beside key={i} anchor={s.el} cardClass={cardClass}>{level(i + 1, s.row.sub)}</Beside>
133
+ ))}
134
+ </Level.Provider>
135
+ )
136
+ }
137
+
138
+ /* a nested level's rows — its first row takes the focus when it opens, so the keys carry on in it */
139
+ function LevelRows({ onKeyDown, children }) {
140
+ const ref = useRef(null)
141
+ useEffect(() => { ref.current?.querySelector('button')?.focus({ preventScroll: true }) }, [])
142
+ return <div ref={ref} className="contents" onKeyDown={onKeyDown}>{children}</div>
143
+ }
144
+
145
+ /* a level beside its row — the + menu's popover: right of the row, 12 off the card (the row sits 6 in), the bottom edges on
146
+ * one line. `kol-float-level` marks it so a parent popover's outside press lets it be */
147
+ function Beside({ anchor, cardClass, children }) {
148
+ const pop = usePopover({ open: true, placement: 'right-end', offset: { mainAxis: 18, crossAxis: 6 }, click: false, dismiss: false, role: 'menu', referenceElement: anchor })
149
+ return <PopoverPanel popover={pop} panel={false} focus={false} className={`kol-float-level ${cardClass}`} style={{ minWidth: 220, maxWidth: 'calc(100vw - 24px)' }}>{children}</PopoverPanel>
150
+ }