@kolkrabbi/kol-shell 0.129.0 → 0.130.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 +4 -4
- package/src/AppFloatNav.jsx +1 -1
- package/src/DocumentCapsule.jsx +1 -1
- package/src/FloatActionMenu.jsx +1 -1
- package/src/RailTrigger.jsx +1 -1
- package/src/TopControlsBar.jsx +1 -1
- package/src/index.js +2 -0
- package/src/MenuFloat.jsx +0 -160
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.130.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.
|
|
15
|
+
"@kolkrabbi/kol-component": ">=0.377.0",
|
|
16
16
|
"@kolkrabbi/kol-framework": ">=0.55.0",
|
|
17
17
|
"@kolkrabbi/kol-icons": ">=0.69.0",
|
|
18
18
|
"@kolkrabbi/kol-theme": ">=0.224.0",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"react-dom": "^18.3.0 || ^19.0.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@kolkrabbi/kol-component": "
|
|
24
|
+
"@kolkrabbi/kol-component": ">=0.377.0",
|
|
25
25
|
"@kolkrabbi/kol-icons": "^0.71.0",
|
|
26
|
-
"@kolkrabbi/kol-theme": "^0.
|
|
26
|
+
"@kolkrabbi/kol-theme": "^0.225.0",
|
|
27
27
|
"@kolkrabbi/kol-framework": "^0.74.1"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
package/src/AppFloatNav.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react'
|
|
2
2
|
import { Button, TabsRow, Tooltip, TABBAR_H, TABBAR_PILL_H, TABBAR_PILL_INSET, tabbarPillWidth, tabbarPillSlot, floatSurfaceClass, usePopover, PopoverPanel, useMediaQuery } from '@kolkrabbi/kol-component'
|
|
3
3
|
import { hasIcon } from '@kolkrabbi/kol-icons'
|
|
4
|
-
import MenuFloatRows,
|
|
4
|
+
import { MenuFloatRows, MenuFloat } from '@kolkrabbi/kol-component'
|
|
5
5
|
import Timecode from './Timecode.jsx'
|
|
6
6
|
|
|
7
7
|
/* taxonomy-ok: molecule — TabsRow's pill + MenuFloatRows sheets of Buttons */
|
package/src/DocumentCapsule.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
import { Button, MenuTrigger, usePopover, PopoverPanel, floatSurfaceClass } from '@kolkrabbi/kol-component'
|
|
3
3
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
4
|
-
import MenuFloatRows,
|
|
4
|
+
import { MenuFloatRows, MenuFloat } from '@kolkrabbi/kol-component'
|
|
5
5
|
|
|
6
6
|
/* taxonomy-ok: molecule — a float Button, a float MenuTrigger (the name), the More sheet's rows */
|
|
7
7
|
|
package/src/FloatActionMenu.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
import { Button, PopoverPanel, usePopover, floatSurfaceClass, floatMotion } from '@kolkrabbi/kol-component'
|
|
3
|
-
import MenuFloatRows,
|
|
3
|
+
import { MenuFloatRows, MenuFloat } from '@kolkrabbi/kol-component'
|
|
4
4
|
|
|
5
5
|
/* taxonomy-ok: molecule — a round Button that opens the More sheet's rows */
|
|
6
6
|
|
package/src/RailTrigger.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
import { Button, usePopover, PopoverPanel, floatSurfaceClass, floatMotion } from '@kolkrabbi/kol-component'
|
|
3
|
-
import MenuFloatRows,
|
|
3
|
+
import { MenuFloatRows, MenuFloat } from '@kolkrabbi/kol-component'
|
|
4
4
|
|
|
5
5
|
/* taxonomy-ok: molecule — a float Button that opens the More sheet's rows */
|
|
6
6
|
|
package/src/TopControlsBar.jsx
CHANGED
|
@@ -2,7 +2,7 @@ import { useState } from 'react'
|
|
|
2
2
|
import FloatActionMenu from './FloatActionMenu.jsx'
|
|
3
3
|
import { Button, TabsRow, usePopover, PopoverPanel, floatSurfaceClass } from '@kolkrabbi/kol-component'
|
|
4
4
|
import DocumentCapsule from './DocumentCapsule.jsx'
|
|
5
|
-
import MenuFloatRows,
|
|
5
|
+
import { MenuFloatRows, MenuFloat } from '@kolkrabbi/kol-component'
|
|
6
6
|
|
|
7
7
|
/* taxonomy-ok: organism — the top bar: DocumentCapsule · TabsRow float · float Buttons · PanelsRestore */
|
|
8
8
|
|
package/src/index.js
CHANGED
|
@@ -30,6 +30,8 @@ export { default as TopControlsBar, PanelsRestore } from './TopControlsBar.jsx'
|
|
|
30
30
|
export { default as ReaderBar, ProgressDock } from './ReaderBar.jsx'
|
|
31
31
|
export { default as RailTrigger } from './RailTrigger.jsx'
|
|
32
32
|
export { default as FloatActionMenu } from './FloatActionMenu.jsx'
|
|
33
|
+
/* the float menu card and its rows live in kol-component since 2026-11-12 (ButtonSplit's float menu is the same one) */
|
|
34
|
+
export { MenuFloat, MenuFloatRows } from '@kolkrabbi/kol-component'
|
|
33
35
|
// the app's menu bar inside the browser, menus as data (plan-2026-11-05-float-editor W1.1)
|
|
34
36
|
export { default as MenuBar } from './MenuBar.jsx'
|
|
35
37
|
export { default as RailFlyout } from './RailFlyout.jsx'
|
package/src/MenuFloat.jsx
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, useEffect, useRef, useState } from 'react'
|
|
2
|
-
import { Button, Header, ModalHeader, usePopover, PopoverPanel } from '@kolkrabbi/kol-component'
|
|
3
|
-
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
4
|
-
|
|
5
|
-
/* the open level a row sits in (MenuFloat); null outside one, where a row's `sub` is ignored as before */
|
|
6
|
-
const Level = (globalThis[Symbol.for('@kolkrabbi/kol-shell/FloatMenuLevel')] ??= createContext(null))
|
|
7
|
-
const FLOAT_ROW = 'w-full justify-start kol-btn-float'
|
|
8
|
-
|
|
9
|
-
/* taxonomy-ok: molecule — a column of nav Buttons */
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* MenuFloatRows — The sheet's rows, wherever the sheet opens. the one list of 44px nav rows (mono-16, 22px glyphs,
|
|
13
|
-
* the pill's rounding on each) that the phone bar's More sheet and Home's masthead button both draw
|
|
14
|
-
* (user 2026-10-23: *"we could even make similar dropdown as we use in phone nav"*). The sheet's chrome is
|
|
15
|
-
* `.kol-more-sheet` — the pill's ground and hairline, a 24px rounding, 8px pad — on whatever box holds the rows.
|
|
16
|
-
*
|
|
17
|
-
* @param {Array} actions `[{ label, icon?, avatar?, onPress, checked? }]` — the page's own buttons, first. `avatar` (a picture
|
|
18
|
-
* url — the account row) draws in the glyph's place. A row with `checked`
|
|
19
|
-
* (a pick list — TransportPill's loop lengths) draws the 22px check, or keeps its space when false
|
|
20
|
-
* @param {Array} items `[{ path, label, icon? }]` — destinations, after a divider's worth of nothing
|
|
21
|
-
* @param {string} active the item path that is current
|
|
22
|
-
* @param {Function} onPick `(item | action) => void` — after the row's own press; the sheet closes here
|
|
23
|
-
* @param {'float'} variant the floating style (round 3, W16 2026-10-31): each row a `kol-btn-float` pill — 40 (48 on touch)
|
|
24
|
-
* tall, 12 in, an 18 (20) glyph, the current row oq-16 — in a `.kol-more-sheet-float`; AppFloatNav
|
|
25
|
-
* and the signed-out Home pass it. Unset, the rows are A
|
|
26
|
-
* @param {boolean} itemsFirst the destinations above the actions (PhoneNav's More, 2026-10-28: the whole nav, then the
|
|
27
|
-
* page's buttons); Home's masthead button keeps actions first
|
|
28
|
-
*/
|
|
29
|
-
export default function MenuFloatRows({ actions = [], items = [], active, onPick, itemsFirst = false, variant }) {
|
|
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,
|
|
31
|
-
* which would outrank the components layer */
|
|
32
|
-
const float = variant === 'float'
|
|
33
|
-
const rowCls = float ? FLOAT_ROW : 'w-full justify-start h-11 gap-3'
|
|
34
|
-
const level = useContext(Level)
|
|
35
|
-
const glyph = float ? 'var(--kol-float-ic)' : 22
|
|
36
|
-
const acts = (
|
|
37
|
-
<>
|
|
38
|
-
{actions.map((a) => {
|
|
39
|
-
/* a row with `sub` inside a MenuFloat opens its level instead of picking — the chevron at the row's end */
|
|
40
|
-
const nests = level && a.sub?.length > 0
|
|
41
|
-
/* the account row is the ModalHeader (menu-system W4.1) — avatar · title, pressable */
|
|
42
|
-
if (a.avatar && !nests) return <ModalHeader key={a.label} variant={float ? 'float' : 'default'} avatar={a.avatar} title={a.label} onClick={() => { onPick?.(a); a.onPress?.() }} />
|
|
43
|
-
return (
|
|
44
|
-
/* a nesting row draws its own glyph so the label can take the room between it and the chevron; 8 apart, as Button's */
|
|
45
|
-
<Button key={a.label} variant="nav" size="lg" iconLeft={a.checked === undefined && !nests ? a.icon : undefined} iconSize={glyph}
|
|
46
|
-
className={rowCls} style={nests ? { gap: 8 } : undefined}
|
|
47
|
-
aria-haspopup={nests ? 'menu' : undefined} aria-expanded={nests ? level.isOpen(a) : undefined}
|
|
48
|
-
onClick={(e) => { if (nests) { level.open(a, e.currentTarget); return } onPick?.(a); a.onPress?.() }}>
|
|
49
|
-
{a.checked !== undefined && (
|
|
50
|
-
<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 && <IconLoader name="check" size={22} />}</span>
|
|
51
|
-
)}
|
|
52
|
-
{nests ? <>{a.icon && <IconLoader name={a.icon} size={glyph} />}<span className="flex-1 text-left">{a.label}</span><IconLoader name="chevron-right" size={glyph} className="shrink-0 text-oq-48" /></> : a.label}
|
|
53
|
-
</Button>
|
|
54
|
-
)
|
|
55
|
-
})}
|
|
56
|
-
</>
|
|
57
|
-
)
|
|
58
|
-
const dests = (
|
|
59
|
-
<>
|
|
60
|
-
{items.map((i) => (
|
|
61
|
-
<Button
|
|
62
|
-
key={i.path ?? i.id ?? i.label}
|
|
63
|
-
variant="nav"
|
|
64
|
-
size="lg"
|
|
65
|
-
iconLeft={i.icon}
|
|
66
|
-
iconSize={glyph}
|
|
67
|
-
aria-current={i.path != null && i.path === active ? 'page' : undefined}
|
|
68
|
-
className={rowCls}
|
|
69
|
-
onClick={() => onPick?.(i)}
|
|
70
|
-
>
|
|
71
|
-
{i.label}
|
|
72
|
-
</Button>
|
|
73
|
-
))}
|
|
74
|
-
</>
|
|
75
|
-
)
|
|
76
|
-
return itemsFirst ? <>{dests}{acts}</> : <>{acts}{dests}</>
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const rowKey = (r) => r.id ?? r.path ?? r.label
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* MenuFloat — A float's card with NESTED LEVELS (FloatsOwnItems, kol-fxr 2026-10-31 — *"does the float nav offer nested
|
|
83
|
-
* menus"*). Wraps the card's first level (`children`, MenuFloatRows); a MenuFloatRows action with `sub` opens the next level, the same
|
|
84
|
-
* row shape to any depth (`sub[].sub[].sub…`). How a level opens is one rule, by room:
|
|
85
|
-
* - `beside` (the desk's `dock`) — a card of the same chrome beside its parent row, right of it, the bottom edges on one
|
|
86
|
-
* line, through the existing popover (`usePopover` + `PopoverPanel`, flips and shifts at the window's edge);
|
|
87
|
-
* - else (every phone variant) — the level REPLACES the card's rows, under a Back row naming the parent.
|
|
88
|
-
* A leaf runs its `onPress`, then `onLeaf(row)` closes every level (the caller closes the card — Escape and an outside press
|
|
89
|
-
* are the card's, and closing it closes everything). Keys: ↑ ↓ move, → or Enter opens a level, ← goes back one.
|
|
90
|
-
*
|
|
91
|
-
* @param {boolean} beside levels open beside their row (else they replace the card's rows)
|
|
92
|
-
* @param {string} cardClass a beside level's chrome — the first card's classes
|
|
93
|
-
* @param {Function} onLeaf `(row) => void` — a nested leaf was picked (its `onPress` has run); close everything here
|
|
94
|
-
* @param {ReactNode} [title] the card's header — Header variant="property", the header every float Rail wears (the user
|
|
95
|
-
* 2026-11-12: *"why is it so hard TO USE THE SAME FUCKING HEADER"*); each opener passes the label of
|
|
96
|
-
* the button that opened it. Unset, no header
|
|
97
|
-
* @param {ReactNode} [titleActions] the header's actions slot (RailTrigger's ×)
|
|
98
|
-
*/
|
|
99
|
-
export function MenuFloat({ beside = false, cardClass = '', onLeaf, title, titleActions, children }) {
|
|
100
|
-
/* the open rows, outermost first — `{ row, el }`, `el` the row a beside level hangs off.
|
|
101
|
-
* ponytail: the row object is kept as opened; a consumer that rebuilds its rows mid-open sees the old `sub` until reopened */
|
|
102
|
-
const [trail, setTrail] = useState([])
|
|
103
|
-
const at = (depth) => ({
|
|
104
|
-
open: (row, el) => setTrail((t) => (t[depth] && rowKey(t[depth].row) === rowKey(row) ? t.slice(0, depth) : [...t.slice(0, depth), { row, el }])),
|
|
105
|
-
isOpen: (row) => !!trail[depth] && rowKey(trail[depth].row) === rowKey(row),
|
|
106
|
-
})
|
|
107
|
-
const back = (depth) => { const parent = trail[depth - 1]?.el; setTrail((t) => t.slice(0, depth - 1)); if (beside) parent?.focus({ preventScroll: true }) }
|
|
108
|
-
const keys = (depth) => (e) => {
|
|
109
|
-
const rows = [...e.currentTarget.querySelectorAll('button')]
|
|
110
|
-
const i = rows.indexOf(document.activeElement)
|
|
111
|
-
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') rows[(i + (e.key === 'ArrowDown' ? 1 : -1) + rows.length) % rows.length]?.focus()
|
|
112
|
-
else if (e.key === 'ArrowRight' && e.target.getAttribute?.('aria-haspopup')) { if (e.target.getAttribute('aria-expanded') !== 'true') e.target.click() }
|
|
113
|
-
else if (e.key === 'ArrowLeft' && depth > 0) back(depth)
|
|
114
|
-
else return
|
|
115
|
-
e.preventDefault()
|
|
116
|
-
e.stopPropagation()
|
|
117
|
-
}
|
|
118
|
-
const level = (depth, rows, lead) => (
|
|
119
|
-
<Level.Provider value={at(depth)}>
|
|
120
|
-
<LevelRows key={`${depth}:${rowKey(trail[depth - 1].row)}`} onKeyDown={keys(depth)}>
|
|
121
|
-
{lead}
|
|
122
|
-
<MenuFloatRows variant="float" actions={rows} onPick={onLeaf} />
|
|
123
|
-
</LevelRows>
|
|
124
|
-
</Level.Provider>
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
/* the header stays on top while a level replaces the rows; title 12 in, as the rows' labels */
|
|
128
|
-
const head = title != null && title !== false && (
|
|
129
|
-
<Header variant="property" title={title} end={titleActions} className={`pl-3 ${titleActions ? 'pr-1' : 'pr-3'} pt-1 pb-2`} />
|
|
130
|
-
)
|
|
131
|
-
if (!beside && trail.length) {
|
|
132
|
-
const d = trail.length
|
|
133
|
-
return <>{head}{level(d, trail[d - 1].row.sub, (
|
|
134
|
-
<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>
|
|
135
|
-
))}</>
|
|
136
|
-
}
|
|
137
|
-
return (
|
|
138
|
-
<Level.Provider value={at(0)}>
|
|
139
|
-
{head}
|
|
140
|
-
<div className="contents" onKeyDown={keys(0)}>{children}</div>
|
|
141
|
-
{beside && trail.map((s, i) => (
|
|
142
|
-
<Beside key={i} anchor={s.el} cardClass={cardClass}>{level(i + 1, s.row.sub)}</Beside>
|
|
143
|
-
))}
|
|
144
|
-
</Level.Provider>
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/* a nested level's rows — its first row takes the focus when it opens, so the keys carry on in it */
|
|
149
|
-
function LevelRows({ onKeyDown, children }) {
|
|
150
|
-
const ref = useRef(null)
|
|
151
|
-
useEffect(() => { ref.current?.querySelector('button')?.focus({ preventScroll: true }) }, [])
|
|
152
|
-
return <div ref={ref} className="contents" onKeyDown={onKeyDown}>{children}</div>
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/* 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
|
|
156
|
-
* one line. `kol-float-level` marks it so a parent popover's outside press lets it be */
|
|
157
|
-
function Beside({ anchor, cardClass, children }) {
|
|
158
|
-
const pop = usePopover({ open: true, placement: 'right-end', offset: { mainAxis: 18, crossAxis: 6 }, click: false, dismiss: false, role: 'menu', referenceElement: anchor })
|
|
159
|
-
return <PopoverPanel popover={pop} panel={false} focus={false} className={`kol-float-level ${cardClass}`} style={{ minWidth: 220, maxWidth: 'calc(100vw - 24px)' }}>{children}</PopoverPanel>
|
|
160
|
-
}
|