@kolkrabbi/kol-shell 0.88.0 → 0.89.1
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/AppHub.jsx +20 -88
- package/src/HubSettingsRail.jsx +108 -0
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.1",
|
|
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.316.0",
|
|
16
16
|
"@kolkrabbi/kol-framework": ">=0.55.0",
|
|
17
17
|
"@kolkrabbi/kol-icons": ">=0.16.0",
|
|
18
18
|
"@kolkrabbi/kol-theme": ">=0.187.0",
|
|
@@ -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-component": "^0.313.0",
|
|
24
|
+
"@kolkrabbi/kol-component": "^0.316.0",
|
|
26
25
|
"@kolkrabbi/kol-icons": "^0.52.0",
|
|
27
|
-
"@kolkrabbi/kol-theme": "^0.
|
|
26
|
+
"@kolkrabbi/kol-theme": "^0.199.0",
|
|
27
|
+
"@kolkrabbi/kol-framework": "^0.64.0"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"src",
|
package/src/AppHub.jsx
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'react'
|
|
2
|
-
/* THE TOGGLE IS THE HUB'S (user 2026-10-24:
|
|
3
|
-
|
|
4
|
-
props on every rail — no app passes a toggle. kol-framework is kol-shell's peer for this (ARCHITECTURE §3: the shell
|
|
5
|
-
consumes component + framework). `useTheme` is the Hub's own setting: reset hands the theme back to the system. */
|
|
6
|
-
import ThemeToggle from '@kolkrabbi/kol-framework/src/ThemeToggle.jsx'
|
|
7
|
-
import { useTheme } from '@kolkrabbi/kol-framework/src/theme.js'
|
|
2
|
+
/* THE TOGGLE IS THE HUB'S (user 2026-10-24): kol-framework's ThemeToggle with the Hub's props, drawn by HubSettingsRail
|
|
3
|
+
(`hubThemeToggle`) and used on the page tier too — no app passes a toggle. */
|
|
8
4
|
import AppShell from './AppShell.jsx'
|
|
9
5
|
import HubHome from './HubHome.jsx'
|
|
10
6
|
import HubSettings from './HubSettings.jsx'
|
|
7
|
+
import HubSettingsRail, { hubThemeToggle } from './HubSettingsRail.jsx'
|
|
11
8
|
import HubDev from './HubDev.jsx'
|
|
12
|
-
import SettingsLinks, { SettingsColophon } from './SettingsLinks.jsx'
|
|
13
|
-
import About from './About.jsx'
|
|
14
9
|
import { warnJsx } from './warnJsx.js'
|
|
15
10
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
16
|
-
import { Avatar,
|
|
11
|
+
import { Avatar, CommandOverlay, MediaLibrary, ModalProvider, RAIL_PRESETS, ShortcutsOverlay, shortcutInScope, useModal } from '@kolkrabbi/kol-component'
|
|
17
12
|
|
|
18
|
-
/* taxonomy-ok: organism — nests AppShell / HubHome / HubSettings / HubDev (relative) + kol-component's CommandOverlay */
|
|
13
|
+
/* taxonomy-ok: organism — nests AppShell / HubHome / HubSettings / HubSettingsRail / HubDev (relative) + kol-component's CommandOverlay */
|
|
19
14
|
|
|
20
15
|
/**
|
|
21
16
|
* AppHub — An app's shell and hub in one. Shell + Hub in one call; the app passes its Tool as children (the app anatomy,
|
|
@@ -139,39 +134,9 @@ const SETTINGS_DRAWER = '#settings'
|
|
|
139
134
|
const typing = (t) => t?.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t?.tagName)
|
|
140
135
|
const match = (label, q) => !q || String(label ?? '').toLowerCase().includes(q.toLowerCase())
|
|
141
136
|
|
|
142
|
-
/*
|
|
143
|
-
const toggle =
|
|
137
|
+
/* the Hub's toggle — HubSettingsRail's, so the page and the rail draw one */
|
|
138
|
+
const toggle = hubThemeToggle
|
|
144
139
|
|
|
145
|
-
/* THE RAIL'S NAMED TABS — drawn here, from what the Hub already holds, so a consumer passes a word and no JSX */
|
|
146
|
-
const RAIL_TABS = {
|
|
147
|
-
shortcuts: {
|
|
148
|
-
label: 'Shortcuts',
|
|
149
|
-
draw: ({ shortcuts }) => <SettingsSections divided sections={shortcuts.map((s) => ({ label: s.section, rows: (s.items ?? []).map((k, i) => ({ id: k.id ?? `${i}:${k.label}`, label: k.label, value: k.combo ?? k.keys })) }))} />,
|
|
150
|
-
},
|
|
151
|
-
about: {
|
|
152
|
-
label: 'About',
|
|
153
|
-
/* the links draw under About (SettingsRailDocsTab, kol-mirror 2026-10-24): Repo's list folds in here, so the row's
|
|
154
|
-
* fourth word can be Docs and it stays one line */
|
|
155
|
-
draw: ({ app }) => (
|
|
156
|
-
<div className="flex flex-col gap-8">
|
|
157
|
-
{app.about && <LabeledControlSection label={app.name}><About about={app.about} /></LabeledControlSection>}
|
|
158
|
-
{app.links?.length > 0 && <LabeledControlSection label="Links"><SettingsLinks links={app.links} /></LabeledControlSection>}
|
|
159
|
-
<SettingsColophon />
|
|
160
|
-
</div>
|
|
161
|
-
),
|
|
162
|
-
},
|
|
163
|
-
docs: {
|
|
164
|
-
label: 'Docs',
|
|
165
|
-
/* an app's explanatory prose AS DATA — `app.docs: [{ label, paragraphs }]`, each a section in About's voice, out of
|
|
166
|
-
* the settings sections' notes (user, on mirror's rail: *"settings are so overloaded with information that its hard to
|
|
167
|
-
* navigate … we should just start a documentation tab for it"*). No JSX: `About` warns on a node */
|
|
168
|
-
draw: ({ app }) => (
|
|
169
|
-
<div className="flex flex-col gap-8">
|
|
170
|
-
{app.docs.map((d, i) => <LabeledControlSection key={d.label ?? i} label={d.label}><About about={d.paragraphs ?? d.text} /></LabeledControlSection>)}
|
|
171
|
-
</div>
|
|
172
|
-
),
|
|
173
|
-
},
|
|
174
|
-
}
|
|
175
140
|
/* the rail's rows: typed, text, or nothing — a `render` row is JSX and is dropped here with a warning */
|
|
176
141
|
const railSections = (sections = []) => sections.map((s) => ({
|
|
177
142
|
...s,
|
|
@@ -225,7 +190,6 @@ function HubFrame({
|
|
|
225
190
|
const [settingsTab, setSettingsTab] = useState('settings')
|
|
226
191
|
const account = signIn?.signedIn && signIn.account ? signIn.account : null
|
|
227
192
|
const modal = useModal()
|
|
228
|
-
const theme = useTheme()
|
|
229
193
|
/* THE DEFAULT THEME IS A ROOT ATTRIBUTE kol-framework's theme reads (`data-theme-default`): reset (`theme.clear()`)
|
|
230
194
|
* and the toggle's alt-click hand the page to it, not to the OS — a dark-first app stays dark on a light-mode Mac */
|
|
231
195
|
const themeDefault = defaultTheme ?? app.defaultTheme
|
|
@@ -235,20 +199,11 @@ function HubFrame({
|
|
|
235
199
|
return () => { delete document.documentElement.dataset.themeDefault }
|
|
236
200
|
}, [themeDefault])
|
|
237
201
|
if (themeToggle != null) warnJsx('themeToggle', 'The Hub draws the theme toggle itself; drop the prop.')
|
|
238
|
-
/*
|
|
239
|
-
*
|
|
240
|
-
* information … we should just start a documentation tab for it"*), so the fourth word is the app's prose, `app.docs`, drawn
|
|
241
|
-
* when it has any; an app's `tabs` are not drawn — its rows belong under Settings (dev warns) */
|
|
202
|
+
/* the rail's tabs are HubSettingsRail's (Settings · Shortcuts · About · Docs); an app's `tabs` are not drawn — its rows
|
|
203
|
+
* belong under Settings (dev warns) */
|
|
242
204
|
if (settingsDrawer && settings.tabs?.length) warnJsx('settings.tabs', 'The rail has no app tabs — put the rows under settings.sections.')
|
|
243
|
-
const railTabs = settingsDrawer ? [
|
|
244
|
-
...(shortcuts.length ? [{ value: 'shortcuts', label: RAIL_TABS.shortcuts.label, named: RAIL_TABS.shortcuts }] : []),
|
|
245
|
-
...((app.about || app.links?.length) ? [{ value: 'about', label: RAIL_TABS.about.label, named: RAIL_TABS.about }] : []),
|
|
246
|
-
...(app.docs?.length ? [{ value: 'docs', label: RAIL_TABS.docs.label, named: RAIL_TABS.docs }] : []),
|
|
247
|
-
] : []
|
|
248
205
|
if (settingsDrawer && settings.content != null) warnRailJsx('content')
|
|
249
206
|
const railRows = settingsDrawer ? railSections(settings.sections) : []
|
|
250
|
-
/* reset, live everywhere: the theme back to the system, then the app's own */
|
|
251
|
-
const reset = () => { theme.clear(); settings?.drawer?.onReset?.() }
|
|
252
207
|
/* SIGN IN ASKS IN THE DS DIALOG (review 2, § 5.2 — fxr's RailSignIn, verbatim copy): signed out, the password prompt —
|
|
253
208
|
* empty cancels — then `onPress(password)`; signed in, the sign-out confirm, then `onPress(null)` */
|
|
254
209
|
const askSignIn = async () => {
|
|
@@ -460,43 +415,20 @@ function HubFrame({
|
|
|
460
415
|
{media && (
|
|
461
416
|
<MediaLibrary variant="picker" open={mediaOpen} client={media.client} accept={media.accept} onClose={() => setMediaOpen(false)} onSelect={(url, meta) => { setMediaOpen(false); media.onSelect?.(url, meta) }} />
|
|
462
417
|
)}
|
|
463
|
-
{/* THE RAIL tier — studio-hub's, the template
|
|
464
|
-
* RAIL"*): `sections` in the rail, the theme toggle (the Hub's props) and reset in its footer; with `tabs`, a text
|
|
465
|
-
* TabsRow under the header — Settings first, then the app's (Monitor: Shortcuts, About, Repo; Mirror: Performance)
|
|
466
|
-
* — like the labs rail's levels, never a page. Rows only: the Hub draws every string, so no rail can wear a class
|
|
467
|
-
* the template does not */}
|
|
418
|
+
{/* THE RAIL tier — studio-hub's, the template: HubSettingsRail (lifted out of here for kol-workshop, 2026-10-29) */}
|
|
468
419
|
{(settingsDrawer || account) && (
|
|
469
|
-
<
|
|
420
|
+
<HubSettingsRail
|
|
470
421
|
open={settingsOpen}
|
|
471
|
-
variant="rail"
|
|
472
|
-
title={settings?.drawer?.title ?? 'Settings'}
|
|
473
422
|
onClose={() => setSettingsOpen(false)}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
{
|
|
478
|
-
{(
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
<>
|
|
484
|
-
{tabs.length > 1 && <TabsRow look="text" size={12} tracked className="flex-wrap gap-x-6 gap-y-2" tabs={tabs} value={tab} onChange={setSettingsTab} ariaLabel="Settings tabs" />}
|
|
485
|
-
{tab === 'account'
|
|
486
|
-
? (
|
|
487
|
-
<div className="flex flex-col gap-8">
|
|
488
|
-
{account.content}
|
|
489
|
-
{account.sections?.length > 0 && <SettingsSections sections={railSections(account.sections)} divided />}
|
|
490
|
-
{account.footer && <Button tone="outline" size="sm" className="self-start" onClick={account.footer.onPress}>{account.footer.label}</Button>}
|
|
491
|
-
</div>
|
|
492
|
-
)
|
|
493
|
-
: tab === 'settings'
|
|
494
|
-
? (railRows.length > 0 && <SettingsSections sections={railRows} divided />)
|
|
495
|
-
: railTabs.find((x) => x.value === tab)?.named?.draw({ app, shortcuts })}
|
|
496
|
-
</>
|
|
497
|
-
)
|
|
498
|
-
})()}
|
|
499
|
-
</SettingsPanel>
|
|
423
|
+
title={settings?.drawer?.title ?? 'Settings'}
|
|
424
|
+
sections={settingsDrawer ? railRows : undefined}
|
|
425
|
+
app={app}
|
|
426
|
+
shortcuts={shortcuts}
|
|
427
|
+
account={account ? { ...account, sections: account.sections && railSections(account.sections) } : undefined}
|
|
428
|
+
tab={settingsTab}
|
|
429
|
+
onTabChange={setSettingsTab}
|
|
430
|
+
onReset={settings?.drawer?.onReset}
|
|
431
|
+
/>
|
|
500
432
|
)}
|
|
501
433
|
</AppShell>
|
|
502
434
|
)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import ThemeToggle from '@kolkrabbi/kol-framework/src/ThemeToggle.jsx'
|
|
3
|
+
import { useTheme } from '@kolkrabbi/kol-framework/src/theme.js'
|
|
4
|
+
import { Button, LabeledControlSection, SettingsFooter, SettingsPanel, SettingsSections, TabsRow } from '@kolkrabbi/kol-component'
|
|
5
|
+
import SettingsLinks, { SettingsColophon } from './SettingsLinks.jsx'
|
|
6
|
+
import About from './About.jsx'
|
|
7
|
+
|
|
8
|
+
/* taxonomy-ok: organism — nests SettingsLinks / About (relative) + kol-component's SettingsPanel / SettingsSections / TabsRow */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* HubSettingsRail — The hub's settings rail. AppHub's rail tier, lifted out of AppHub as it was
|
|
12
|
+
* (WorkshopSettingsRailAndBars, kol-hq 2026-10-29 — user: *"this should be implemented on workshop as well … I dont want
|
|
13
|
+
* any reinventions"*), so kol-workshop's `ShellLayout` opens the same rail: Settings · Shortcuts · About · Docs, the
|
|
14
|
+
* theme toggle and a live reset in the footer.
|
|
15
|
+
*
|
|
16
|
+
* @param {boolean} open · onClose
|
|
17
|
+
* @param {string} title default `Settings`
|
|
18
|
+
* @param {Array} sections the Settings tab's rows (`SettingsSections` shape); omitted, there is no Settings tab and
|
|
19
|
+
* no named tabs (AppHub's account-only rail)
|
|
20
|
+
* @param {Object} app `{ name, about, links, docs }` — About draws from `about` + `links`, Docs from `docs`
|
|
21
|
+
* @param {Array} shortcuts `[{ section, items: [{ id, label, combo }] }]` — the Shortcuts tab
|
|
22
|
+
* @param {Object} account `{ content, sections, footer }` — the Account tab, first, while signed in
|
|
23
|
+
* @param {string} tab · onTabChange controlled tab (optional — the rail keeps its own otherwise)
|
|
24
|
+
* @param {Function} onReset the app's reset, after the theme goes back to the system
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/* THE TOGGLE'S PROPS ARE THE HUB'S — studio-hub's `fill="none" label={false} size="sm"`, nothing else */
|
|
28
|
+
export const hubThemeToggle = <ThemeToggle variant="button" fill="none" label={false} size="sm" tone="default" />
|
|
29
|
+
|
|
30
|
+
/* THE RAIL'S NAMED TABS — drawn here, from what the Hub already holds, so a consumer passes a word and no JSX */
|
|
31
|
+
const RAIL_TABS = {
|
|
32
|
+
shortcuts: {
|
|
33
|
+
label: 'Shortcuts',
|
|
34
|
+
draw: ({ shortcuts }) => <SettingsSections divided sections={shortcuts.map((s) => ({ label: s.section, rows: (s.items ?? []).map((k, i) => ({ id: k.id ?? `${i}:${k.label}`, label: k.label, value: k.combo ?? k.keys })) }))} />,
|
|
35
|
+
},
|
|
36
|
+
about: {
|
|
37
|
+
label: 'About',
|
|
38
|
+
/* the links draw under About (SettingsRailDocsTab, kol-mirror 2026-10-24): Repo's list folds in here, so the row's
|
|
39
|
+
* fourth word can be Docs and it stays one line */
|
|
40
|
+
draw: ({ app }) => (
|
|
41
|
+
<div className="flex flex-col gap-8">
|
|
42
|
+
{app.about && <LabeledControlSection label={app.name}><About about={app.about} /></LabeledControlSection>}
|
|
43
|
+
{app.links?.length > 0 && <LabeledControlSection label="Links"><SettingsLinks links={app.links} /></LabeledControlSection>}
|
|
44
|
+
<SettingsColophon />
|
|
45
|
+
</div>
|
|
46
|
+
),
|
|
47
|
+
},
|
|
48
|
+
docs: {
|
|
49
|
+
label: 'Docs',
|
|
50
|
+
/* an app's explanatory prose AS DATA — `app.docs: [{ label, paragraphs }]`, each a section in About's voice, out of
|
|
51
|
+
* the settings sections' notes (user, on mirror's rail: *"settings are so overloaded with information that its hard to
|
|
52
|
+
* navigate … we should just start a documentation tab for it"*). No JSX: `About` warns on a node */
|
|
53
|
+
draw: ({ app }) => (
|
|
54
|
+
<div className="flex flex-col gap-8">
|
|
55
|
+
{app.docs.map((d, i) => <LabeledControlSection key={d.label ?? i} label={d.label}><About about={d.paragraphs ?? d.text} /></LabeledControlSection>)}
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default function HubSettingsRail({ open, onClose, title = 'Settings', sections, app = {}, shortcuts = [], account, tab: tabProp, onTabChange, onReset }) {
|
|
62
|
+
const [ownTab, setOwnTab] = useState('settings')
|
|
63
|
+
const theme = useTheme()
|
|
64
|
+
const hasSettings = sections != null
|
|
65
|
+
/* THE RAIL'S TABS, the same four on every hub: Settings · Shortcuts · About · Docs, the three from what the app already
|
|
66
|
+
* passes — Repo's links sit under About since SettingsRailDocsTab, so the fourth word is the app's prose, `app.docs`,
|
|
67
|
+
* drawn when it has any */
|
|
68
|
+
const railTabs = hasSettings ? [
|
|
69
|
+
...(shortcuts.length ? [{ value: 'shortcuts', label: RAIL_TABS.shortcuts.label, named: RAIL_TABS.shortcuts }] : []),
|
|
70
|
+
...((app.about || app.links?.length) ? [{ value: 'about', label: RAIL_TABS.about.label, named: RAIL_TABS.about }] : []),
|
|
71
|
+
...(app.docs?.length ? [{ value: 'docs', label: RAIL_TABS.docs.label, named: RAIL_TABS.docs }] : []),
|
|
72
|
+
] : []
|
|
73
|
+
/* the Account tab first, while signed in (SettingsAccountTab); then Settings and the Hub's named tabs */
|
|
74
|
+
const tabs = [...(account ? [{ id: 'account', label: 'Account' }] : []), ...(hasSettings ? [{ id: 'settings', label: 'Settings' }] : []), ...railTabs.map((t) => ({ id: t.value, label: t.label }))]
|
|
75
|
+
const want = tabProp ?? ownTab
|
|
76
|
+
const tab = tabs.some((t) => t.id === want) ? want : tabs[0]?.id
|
|
77
|
+
const setTab = onTabChange ?? setOwnTab
|
|
78
|
+
/* reset, live everywhere: the theme back to the system, then the app's own */
|
|
79
|
+
const reset = () => { theme.clear(); onReset?.() }
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
/* THE RAIL tier — studio-hub's, the template (user 2026-10-24: *"In studio what kind of settings tier is there? ITS A
|
|
83
|
+
* RAIL"*): `sections` in the rail, the theme toggle (the Hub's props) and reset in its footer; with tabs, a text
|
|
84
|
+
* TabsRow under the header — never a page */
|
|
85
|
+
<SettingsPanel
|
|
86
|
+
open={open}
|
|
87
|
+
variant="rail"
|
|
88
|
+
title={title}
|
|
89
|
+
onClose={onClose}
|
|
90
|
+
/* the footer on every rail: the toggle, and a live reset */
|
|
91
|
+
footer={<SettingsFooter onReset={reset}>{hubThemeToggle}</SettingsFooter>}
|
|
92
|
+
>
|
|
93
|
+
{/* the tab row wraps in the 380 rail — five tabs (Mirror's Performance beside the Hub's three) overran it */}
|
|
94
|
+
{tabs.length > 1 && <TabsRow look="text" size={12} tracked overflow="wrap" className="gap-x-6" tabs={tabs} value={tab} onChange={setTab} ariaLabel="Settings tabs" />}
|
|
95
|
+
{tab === 'account'
|
|
96
|
+
? (
|
|
97
|
+
<div className="flex flex-col gap-8">
|
|
98
|
+
{account.content}
|
|
99
|
+
{account.sections?.length > 0 && <SettingsSections sections={account.sections} divided />}
|
|
100
|
+
{account.footer && <Button tone="outline" size="sm" className="self-start" onClick={account.footer.onPress}>{account.footer.label}</Button>}
|
|
101
|
+
</div>
|
|
102
|
+
)
|
|
103
|
+
: tab === 'settings'
|
|
104
|
+
? (sections?.length > 0 && <SettingsSections sections={sections} divided />)
|
|
105
|
+
: railTabs.find((x) => x.value === tab)?.named?.draw({ app, shortcuts })}
|
|
106
|
+
</SettingsPanel>
|
|
107
|
+
)
|
|
108
|
+
}
|
package/src/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export { default as TouchDeviceOverlay, useTouchPrimary } from './TouchDeviceOve
|
|
|
39
39
|
export { default as AppHub } from './AppHub.jsx'
|
|
40
40
|
export { default as HubHome } from './HubHome.jsx'
|
|
41
41
|
export { default as HubSettings } from './HubSettings.jsx'
|
|
42
|
+
export { default as HubSettingsRail, hubThemeToggle } from './HubSettingsRail.jsx'
|
|
42
43
|
export { default as HubDev } from './HubDev.jsx'
|
|
43
44
|
// the Studio — the Hub + Home · Library · Create · Use · pages · Settings, the workstation (apps review §6c, 2026-09-29)
|
|
44
45
|
export { default as AppStudio } from './AppStudio.jsx'
|