@kolkrabbi/kol-shell 0.82.0 → 0.84.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 +5 -5
- package/src/MoreSheet.jsx +7 -2
- package/src/PhoneNav.jsx +45 -8
- package/src/TransportPill.jsx +80 -0
- package/src/index.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.84.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The application shell",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"react-dom": "^18.3.0 || ^19.0.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@kolkrabbi/kol-
|
|
25
|
-
"@kolkrabbi/kol-
|
|
26
|
-
"@kolkrabbi/kol-
|
|
27
|
-
"@kolkrabbi/kol-
|
|
24
|
+
"@kolkrabbi/kol-component": "^0.308.0",
|
|
25
|
+
"@kolkrabbi/kol-framework": "^0.60.0",
|
|
26
|
+
"@kolkrabbi/kol-icons": "^0.50.0",
|
|
27
|
+
"@kolkrabbi/kol-theme": "^0.194.0"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"src",
|
package/src/MoreSheet.jsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Button } from '@kolkrabbi/kol-component'
|
|
2
|
+
import { Icon } from '@kolkrabbi/kol-icons'
|
|
2
3
|
|
|
3
4
|
/* taxonomy-ok: molecule — a column of nav Buttons */
|
|
4
5
|
|
|
@@ -8,7 +9,8 @@ import { Button } from '@kolkrabbi/kol-component'
|
|
|
8
9
|
* (user 2026-10-23: *"we could even make similar dropdown as we use in phone nav"*). The sheet's chrome is
|
|
9
10
|
* `.kol-more-sheet` — the pill's ground and hairline, a 24px rounding, 8px pad — on whatever box holds the rows.
|
|
10
11
|
*
|
|
11
|
-
* @param {Array} actions `[{ label, icon?, onPress }]` — the page's own buttons, first
|
|
12
|
+
* @param {Array} actions `[{ label, icon?, onPress, checked? }]` — the page's own buttons, first. A row with `checked`
|
|
13
|
+
* (a pick list — TransportPill's loop lengths) draws the 22px check, or keeps its space when false
|
|
12
14
|
* @param {Array} items `[{ path, label, icon? }]` — destinations, after a divider's worth of nothing
|
|
13
15
|
* @param {string} active the item path that is current
|
|
14
16
|
* @param {Function} onPick `(item | action) => void` — after the row's own press; the sheet closes here
|
|
@@ -17,7 +19,10 @@ export default function MoreRows({ actions = [], items = [], active, onPick }) {
|
|
|
17
19
|
return (
|
|
18
20
|
<>
|
|
19
21
|
{actions.map((a) => (
|
|
20
|
-
<Button key={a.label} variant="nav" size="lg" iconLeft={a.icon} iconSize={22} className="w-full justify-start h-11 gap-3" onClick={() => { onPick?.(a); a.onPress?.() }}>
|
|
22
|
+
<Button key={a.label} variant="nav" size="lg" iconLeft={a.checked === undefined ? a.icon : undefined} iconSize={22} className="w-full justify-start h-11 gap-3" onClick={() => { onPick?.(a); a.onPress?.() }}>
|
|
23
|
+
{a.checked !== undefined && (
|
|
24
|
+
<span className="inline-flex items-center justify-center shrink-0" style={{ width: 22, height: 22 }}>{a.checked && <Icon name="check" size={22} />}</span>
|
|
25
|
+
)}
|
|
21
26
|
{a.label}
|
|
22
27
|
</Button>
|
|
23
28
|
))}
|
package/src/PhoneNav.jsx
CHANGED
|
@@ -22,6 +22,18 @@ import MoreRows from './MoreSheet.jsx'
|
|
|
22
22
|
* @param {Array} actions `[{ label, icon?, onPress }]` — the page's own buttons, at the top of More (Home's New and
|
|
23
23
|
* Walkthrough on a phone, user 2026-10-23); with any, More shows even with five or fewer rows
|
|
24
24
|
* @param {'bar'|'pill'} shape TabsRow's phone shape (AppShell `touch="pill"`); the More sheet floats above either
|
|
25
|
+
*
|
|
26
|
+
* THE PANEL PICKER (PhoneNavTopAndFold, kol-fxr 2026-10-27, frame E — the nav on top, the open panel at the bottom). The
|
|
27
|
+
* pill only; a `bar` ignores these:
|
|
28
|
+
* @param {'bottom'|'top'} placement the pill's edge; at `top` the More sheet opens below it
|
|
29
|
+
* @param {boolean} border the pill's hairline (default true; frame E has none)
|
|
30
|
+
* @param {'fill'|'circle'} active the lit slot's shape (TabsRow `active`); frame E is `circle`
|
|
31
|
+
* @param {boolean} foldable a sideways swipe folds the pill into a left edge tab; a tap on the tab restores it
|
|
32
|
+
* @param {boolean} folded · {Function} onFoldChange the folded state, so the app can keep it (else PhoneNav holds it)
|
|
33
|
+
* @param {boolean} moreKeepsOpen More opens its sheet without collapsing the pill to the ×, and More lights only while
|
|
34
|
+
* its sheet is open; nothing else closes
|
|
35
|
+
* An item may carry `onPress` (a panel, not a route — the app owns what it opens and whether a second tap closes it) and
|
|
36
|
+
* `selected` (lit whatever the route says; more than one may be).
|
|
25
37
|
*/
|
|
26
38
|
const MORE = '__more'
|
|
27
39
|
const MAX = 5
|
|
@@ -30,7 +42,7 @@ const activePath = (items, path) => items
|
|
|
30
42
|
.filter((i) => (i.path === '/' ? path === '/' : path === i.path || path.startsWith(`${i.path}/`)))
|
|
31
43
|
.sort((a, b) => b.path.length - a.path.length)[0]?.path
|
|
32
44
|
|
|
33
|
-
export default function PhoneNav({ items = [], currentPath = '/', onNavigate, actions = [], shape = 'bar' }) {
|
|
45
|
+
export default function PhoneNav({ items = [], currentPath = '/', onNavigate, actions = [], shape = 'bar', placement = 'bottom', border = true, active: activeShape, foldable = false, folded, onFoldChange, moreKeepsOpen = false }) {
|
|
34
46
|
const [open, setOpen] = useState(false)
|
|
35
47
|
useEffect(() => { setOpen(false) }, [currentPath])
|
|
36
48
|
useEffect(() => {
|
|
@@ -47,23 +59,41 @@ export default function PhoneNav({ items = [], currentPath = '/', onNavigate, ac
|
|
|
47
59
|
const active = activePath(items, currentPath)
|
|
48
60
|
const value = open || inMore.some((i) => i.path === active) ? MORE : active
|
|
49
61
|
|
|
50
|
-
const
|
|
51
|
-
|
|
62
|
+
const key = (i) => i.path ?? i.id ?? i.label
|
|
63
|
+
const tabs = inBar.map((i) => ({ value: key(i), label: i.label, icon: i.icon, selected: i.selected ?? (moreKeepsOpen ? key(i) === active : undefined) }))
|
|
64
|
+
if (hasMore) tabs.push({ value: MORE, label: 'More', icon: 'more', selected: moreKeepsOpen ? open : undefined })
|
|
52
65
|
/* THE SHEET HUGS ITS WORDS AND SITS BESIDE THE × (user 2026-10-23, his reference: iOS Photos' menu next to its ×, *"but
|
|
53
66
|
* align to bottom"*) — to the left of the collapsed ×, a 12px gap, the two bottom edges on one line */
|
|
54
67
|
const pill = shape === 'pill'
|
|
55
|
-
const
|
|
68
|
+
const top = pill && placement === 'top'
|
|
69
|
+
const sheetStyle = moreKeepsOpen && pill ? {
|
|
70
|
+
/* the pill stays whole, so the sheet hangs off its right end, 12 off its face (frame E: below a top pill) */
|
|
71
|
+
left: 'auto',
|
|
72
|
+
right: `calc(50% - ${tabbarPillWidth(tabs.length) / 2}px)`,
|
|
73
|
+
[top ? 'top' : 'bottom']: `calc(env(safe-area-inset-${top ? 'top' : 'bottom'}, 0px) + ${TABBAR_PILL_INSET + TABBAR_H + 12}px)`,
|
|
74
|
+
...(top ? { bottom: 'auto' } : {}),
|
|
75
|
+
width: 'max-content', minWidth: 220, maxWidth: 'calc(100vw - 24px)',
|
|
76
|
+
} : {
|
|
56
77
|
left: 'auto',
|
|
57
78
|
right: pill ? `calc(50% - ${tabbarPillWidth(tabs.length) / 2}px + ${TABBAR_H + 12}px)` : `calc(${100 / tabs.length}% + 8px)`,
|
|
58
|
-
|
|
79
|
+
...(top
|
|
80
|
+
? { top: `calc(env(safe-area-inset-top, 0px) + ${TABBAR_PILL_INSET}px)`, bottom: 'auto' }
|
|
81
|
+
: { bottom: pill ? `calc(env(safe-area-inset-bottom, 0px) + ${TABBAR_PILL_INSET}px)` : 'env(safe-area-inset-bottom, 0px)' }),
|
|
59
82
|
width: 'max-content', minWidth: 220, maxWidth: `calc(100vw - ${TABBAR_H + 36}px)`,
|
|
60
83
|
}
|
|
84
|
+
const press = (v) => {
|
|
85
|
+
if (v === MORE) { setOpen((o) => !o); return }
|
|
86
|
+
const item = inBar.find((i) => key(i) === v)
|
|
87
|
+
if (item?.onPress) { item.onPress(); return }
|
|
88
|
+
onNavigate?.(v)
|
|
89
|
+
}
|
|
61
90
|
|
|
62
91
|
return (
|
|
63
92
|
<>
|
|
64
93
|
{open && (
|
|
65
94
|
/* a BUTTON scrim — iOS does not bubble a tap from a div (OverlayScrimTapDismiss, 2026-09-01) */
|
|
66
|
-
|
|
95
|
+
/* with `moreKeepsOpen` the panel under it stays in view: a clear scrim, a tap off the sheet still closes it */
|
|
96
|
+
<button type="button" aria-label="Close more" className={`kol-phone-nav-scrim${moreKeepsOpen ? '' : ' kol-overlay-scrim'}`} onClick={() => setOpen(false)} />
|
|
67
97
|
)}
|
|
68
98
|
{open && (
|
|
69
99
|
<div className="kol-phone-nav-more kol-more-sheet" role="menu" aria-label="More" style={sheetStyle}>
|
|
@@ -74,11 +104,18 @@ export default function PhoneNav({ items = [], currentPath = '/', onNavigate, ac
|
|
|
74
104
|
look="stacked"
|
|
75
105
|
placement="phone"
|
|
76
106
|
shape={shape}
|
|
77
|
-
collapsed={open}
|
|
107
|
+
collapsed={open && !moreKeepsOpen}
|
|
78
108
|
onExpand={() => setOpen(false)}
|
|
109
|
+
edge={top ? 'top' : 'bottom'}
|
|
110
|
+
border={border}
|
|
111
|
+
active={activeShape}
|
|
112
|
+
foldable={foldable}
|
|
113
|
+
folded={folded}
|
|
114
|
+
onFoldChange={(v) => { if (v) setOpen(false); onFoldChange?.(v) }}
|
|
115
|
+
foldSide="left"
|
|
79
116
|
tabs={tabs}
|
|
80
117
|
value={value}
|
|
81
|
-
onChange={
|
|
118
|
+
onChange={press}
|
|
82
119
|
/>
|
|
83
120
|
</>
|
|
84
121
|
)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import { TabsRow, TABBAR_H, TABBAR_PILL_INSET, TABBAR_PILL_TAB, tabbarPillWidth } from '@kolkrabbi/kol-component'
|
|
3
|
+
import MoreRows from './MoreSheet.jsx'
|
|
4
|
+
|
|
5
|
+
/* taxonomy-ok: molecule — TabsRow's phone pill of action slots + a MoreRows sheet */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TransportPill — The transport, on a phone, as a pill (TransportPill, kol-fxr 2026-10-27, frame E). PhoneNav's pill —
|
|
9
|
+
* the same TabsRow, so the slots, the 28px glyphs and the 44×44 circle are the nav's — holding ACTIONS instead of
|
|
10
|
+
* destinations. It floats over the open panel, so it carries the shadow the nav does not, and folds to a RIGHT edge tab.
|
|
11
|
+
*
|
|
12
|
+
* A slot fires `onPress`; `selected` lights it (play and pause are a radio pair the consumer owns, so both are just
|
|
13
|
+
* `selected`). A slot named in `sheetFor` opens a sheet of rows anchored above it instead, lit while open; a row runs its
|
|
14
|
+
* `onPress` and closes the sheet.
|
|
15
|
+
*
|
|
16
|
+
* @param {Array} items `[{ id, icon, label, onPress?, selected? }]` in pill order
|
|
17
|
+
* @param {Object} sheetFor `{ [id]: [{ label, icon?, onPress, checked? }] }` — rows for a slot that opens a sheet;
|
|
18
|
+
* `checked` marks the current pick with the 22px check (MoreRows)
|
|
19
|
+
* @param {'bottom'|'top'} placement the pill's edge (default bottom)
|
|
20
|
+
* @param {boolean} foldable a sideways swipe folds it into the right edge tab
|
|
21
|
+
* @param {boolean} folded · {Function} onFoldChange the folded state, controlled (else the pill holds it)
|
|
22
|
+
*/
|
|
23
|
+
export default function TransportPill({ items = [], sheetFor = {}, placement = 'bottom', foldable = false, folded, onFoldChange }) {
|
|
24
|
+
const [sheet, setSheet] = useState(null)
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!sheet) return undefined
|
|
27
|
+
const onKey = (e) => { if (e.key === 'Escape') setSheet(null) }
|
|
28
|
+
window.addEventListener('keydown', onKey)
|
|
29
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
30
|
+
}, [sheet])
|
|
31
|
+
|
|
32
|
+
const top = placement === 'top'
|
|
33
|
+
const tabs = items.map((i) => ({ value: i.id, label: i.label, icon: i.icon, selected: sheet === i.id || !!i.selected }))
|
|
34
|
+
const press = (id) => {
|
|
35
|
+
if (sheetFor[id]) { setSheet((s) => (s === id ? null : id)); return }
|
|
36
|
+
setSheet(null)
|
|
37
|
+
items.find((i) => i.id === id)?.onPress?.()
|
|
38
|
+
}
|
|
39
|
+
/* the sheet centres on its slot: the pill's left edge + its 7px pad + the slot's centre */
|
|
40
|
+
const W = tabbarPillWidth(items.length)
|
|
41
|
+
const at = items.findIndex((i) => i.id === sheet)
|
|
42
|
+
const sheetStyle = {
|
|
43
|
+
left: `calc(50% - ${W / 2}px + 7px + ${at * TABBAR_PILL_TAB + TABBAR_PILL_TAB / 2}px)`,
|
|
44
|
+
right: 'auto',
|
|
45
|
+
transform: 'translateX(-50%)',
|
|
46
|
+
[top ? 'top' : 'bottom']: `calc(env(safe-area-inset-${top ? 'top' : 'bottom'}, 0px) + ${TABBAR_PILL_INSET + TABBAR_H + 12}px)`,
|
|
47
|
+
...(top ? { bottom: 'auto' } : {}),
|
|
48
|
+
width: 'max-content', minWidth: 160,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<>
|
|
53
|
+
{sheet && (
|
|
54
|
+
/* a clear BUTTON scrim — the panel under it stays in view, a tap off the sheet closes it */
|
|
55
|
+
<button type="button" aria-label="Close" className="kol-phone-nav-scrim" onClick={() => setSheet(null)} />
|
|
56
|
+
)}
|
|
57
|
+
{sheet && (
|
|
58
|
+
<div className="kol-phone-nav-more kol-more-sheet" role="menu" aria-label={items[at]?.label} style={sheetStyle}>
|
|
59
|
+
<MoreRows actions={sheetFor[sheet]} onPick={() => setSheet(null)} />
|
|
60
|
+
</div>
|
|
61
|
+
)}
|
|
62
|
+
<TabsRow
|
|
63
|
+
look="stacked"
|
|
64
|
+
placement="phone"
|
|
65
|
+
shape="pill"
|
|
66
|
+
edge={top ? 'top' : 'bottom'}
|
|
67
|
+
border={false}
|
|
68
|
+
shadow
|
|
69
|
+
active="circle"
|
|
70
|
+
foldable={foldable}
|
|
71
|
+
folded={folded}
|
|
72
|
+
onFoldChange={(v) => { if (v) setSheet(null); onFoldChange?.(v) }}
|
|
73
|
+
foldSide="right"
|
|
74
|
+
ariaLabel="Transport"
|
|
75
|
+
tabs={tabs}
|
|
76
|
+
onChange={press}
|
|
77
|
+
/>
|
|
78
|
+
</>
|
|
79
|
+
)
|
|
80
|
+
}
|
package/src/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export { NavHiddenContext, useNavHidden } from './navHidden.js'
|
|
|
15
15
|
export { SettingsToggleContext, useSettingsToggle } from './settingsToggle.js'
|
|
16
16
|
export { NavRail } from '@kolkrabbi/kol-component' // lives in kol-component since 2026-10-22
|
|
17
17
|
export { default as PhoneNav } from './PhoneNav.jsx'
|
|
18
|
+
export { default as TransportPill } from './TransportPill.jsx'
|
|
18
19
|
export { default as PageShell, PageBleed } from './PageShell.jsx'
|
|
19
20
|
/* PageHeader MOVED to @kolkrabbi/kol-component 2026-09-03 (page-header-one-masthead).
|
|
20
21
|
* Not re-exported: every kol-shell consumer already has kol-component as a peer,
|
|
@@ -27,7 +28,7 @@ export { default as SettingsScaffold } from './SettingsScaffold.jsx'
|
|
|
27
28
|
export { default as WalkthroughPanel } from './WalkthroughPanel.jsx'
|
|
28
29
|
/* lives in kol-component since 0.228.0 — re-exported so every kol-shell import keeps resolving */
|
|
29
30
|
export { ShortcutsOverlay, shortcutInScope } from '@kolkrabbi/kol-component'
|
|
30
|
-
export { Logomark } from '@kolkrabbi/kol-component'
|
|
31
|
+
export { VectorLoader, Logomark } from '@kolkrabbi/kol-component'
|
|
31
32
|
// the app tier, shipped once (ShellHomeSystem, kol-fxr 2026-08-27)
|
|
32
33
|
export { default as CatalogPage } from './CatalogPage.jsx'
|
|
33
34
|
export { default as CatalogGrid } from './CatalogGrid.jsx'
|