@kolkrabbi/kol-shell 0.75.0 → 0.77.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.
@@ -0,0 +1,275 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react'
2
+ import { ActionButton, ContentCard, ContentFilters, ContentRow, Divider, PageHeader, SECTION_TEXT_LEVELS, CanvasStudio, IconFrame, useMediaQuery } from '@kolkrabbi/kol-component'
3
+ import { Icon } from '@kolkrabbi/kol-icons'
4
+ import PageShell from './PageShell.jsx'
5
+ import CatalogGrid from './CatalogGrid.jsx'
6
+ import { warnJsx } from './warnJsx.js'
7
+
8
+ /* taxonomy-ok: organism — nests PageShell / CatalogGrid (relative) + kol-component's ContentFilters, ContentCard, ContentRow, CanvasStudio, PageHeader */
9
+
10
+ /**
11
+ * StudioCreate — A catalog of parts beside a case. monitor's `CreatePage` made once
12
+ * (plan-2026-10-23 § 3.4 — user: *"the create tab, which is a combination of catalog and studio, where monitor has rack
13
+ * modules and mirror has mixer modules … reference monitor rather than mixer"*). The page is read off
14
+ * `kol-monitor/src/pages/CreatePage.jsx`, structure for structure: a page that is FIXED on the case view and SCROLLS on
15
+ * the parts view; the dot grid over the whole page, under the chrome; an editable masthead (the case's name and
16
+ * description — the pencil in the filter row opens them); `ContentFilters` with the view strip CASE ⇄ PARTS, the parts
17
+ * view a catalog of the parts (the consumer's groups, LIST and GRID), the case view the consumer's case on
18
+ * `CanvasStudio`; a bottom bar with the zoom readout and the consumer's case actions. What a part is, what a row is,
19
+ * and what Insert does are the consumer's — monitor's rows and HP, mirror's channel strips.
20
+ *
21
+ * @param {Object} header `{ title, subtitle, onTitleChange?, onSubtitleChange? }` — the masthead; with the
22
+ * handlers the pencil makes both editable (the consumer persists them), without them it
23
+ * is a plain masthead
24
+ * @param {Array} parts the items of the parts catalog (ContentFilters filters and searches them; `name` /
25
+ * `title` are what the search reads)
26
+ * @param {Array} partGroups ContentFilters' `[{ label, key, values, exclusive? }]` for the parts
27
+ * @param {Function} toCard `(part, { layout }) => card props` — spread onto a `catalog` card (grid) or row (list)
28
+ * on `CatalogGrid`, the Catalog's own grid; pass `zoom: false` to match a Library;
29
+ * `onClick` is the consumer's (monitor opens the part's page)
30
+ * @param {Function} onPlace `(part) => void` — the Insert action (`ActionButton` in the card's and the row's
31
+ * `actions` slot, the plate) on every part; a drag is the consumer's
32
+ * (`onPartPointerDown`), as monitor's is
33
+ * @param {Function} onPartPointerDown `(part, event) => void` — the seam for a consumer's own drag from the pool
34
+ * @param {Object} labels `{ case: 'CASE', parts: 'PARTS', partsTitle: 'All Parts', caseTitle: 'Case' }` — the strip
35
+ * and the catalog titles (monitor: CASE, MODULES, All Modules)
36
+ * @param {number} caseCount what the case holds, for the count beside the title (monitor: the placed modules)
37
+ * @param {ReactNode} caseControls the consumer's controls ABOVE the case (monitor: the Add row and Set HP dialogs, each
38
+ * shown by one of its `caseActions`)
39
+ * @param {ReactNode} caseActions the consumer's buttons in the bottom bar's right (monitor: rows, HP, case preview)
40
+ * @param {{label: string, onClick: Function}} caseLink the link beside the zoom readout, drawn here (monitor: "Open in
41
+ * Rack"); a node is still drawn, with a dev warning (2026-10-24)
42
+ * @param {boolean} showCase draw the case (default true; monitor's case-preview toggle)
43
+ * @param {Object} view · onViewChange · defaultView the canvas view, the consumer's to persist (CanvasStudio's)
44
+ * @param {'case'|'parts'} defaultPage which view opens (default `case`)
45
+ * @param {'case'|'parts'} page · {Function} onPageChange the view, controlled — a consumer's Insert shows the case
46
+ * (monitor's rule), a slot on the case opens the parts (mirror's)
47
+ * @param {Function} canvas `({ gridRef, view, onViewChange }) => node` — a consumer that already HAS a viewport on
48
+ * `CanvasStudio` (monitor's `RackViewport`, with its snap keys and workbench) renders it
49
+ * here instead of `children`; it takes the page's gridRef and view so the whole-page grid
50
+ * and the zoom readout still follow it
51
+ * @param {ReactNode} children the case itself, drawn on this page's own `CanvasStudio` when no `canvas` is given
52
+ * @param {string} className · style on the page
53
+ */
54
+ export default function StudioCreate({
55
+ header = {},
56
+ parts = [],
57
+ partGroups = [],
58
+ toCard,
59
+ onPlace,
60
+ onPartPointerDown,
61
+ labels = {},
62
+ caseCount = 0,
63
+ caseControls,
64
+ caseActions,
65
+ caseLink,
66
+ showCase = true,
67
+ view,
68
+ onViewChange,
69
+ defaultView,
70
+ defaultPage = 'case',
71
+ page: pageProp,
72
+ onPageChange,
73
+ canvas,
74
+ children,
75
+ className = '',
76
+ style,
77
+ }) {
78
+ const L = { case: 'CASE', parts: 'PARTS', partsTitle: 'All Parts', caseTitle: 'Case', ...labels }
79
+ const [ownPage, setOwnPage] = useState(defaultPage)
80
+ const page = pageProp ?? ownPage
81
+ const setPage = (p) => { setOwnPage(p); onPageChange?.(p) }
82
+ const [editing, setEditing] = useState(false)
83
+ const titleRef = useRef(null)
84
+ const gridRef = useRef(null)
85
+ const editable = !!(header.onTitleChange || header.onSubtitleChange)
86
+
87
+ /* the canvas view: the consumer's when passed, else this page's — the zoom readout reads and writes it either way */
88
+ const [ownView, setOwnView] = useState(defaultView ?? { zoom: 1, x: 0, y: 0 })
89
+ const v = view ?? ownView
90
+ const setV = useCallback((next) => {
91
+ const resolved = typeof next === 'function' ? next(view ?? ownView) : next
92
+ if (!view) setOwnView(resolved)
93
+ onViewChange?.(resolved)
94
+ }, [view, ownView, onViewChange])
95
+ const applyZoom = (fn) => setV((cur) => ({ ...cur, zoom: Math.min(2, Math.max(0.1, fn(cur.zoom))) }))
96
+ const [zoomInput, setZoomInput] = useState('100')
97
+ const zoomEditing = useRef(false)
98
+ useEffect(() => { if (!zoomEditing.current) setZoomInput(String(Math.round(v.zoom * 100))) }, [v.zoom])
99
+
100
+ /* the exclusive groups, by key; the flag stays here */
101
+ const exclusive = partGroups.filter((g) => g.exclusive).map((g) => g.key)
102
+ const groups = partGroups.map(({ exclusive: _x, ...g }) => g)
103
+
104
+ /* THE PAGE MASTHEAD, EDITABLE (review 2, § 7.3 — *"create page both desktop and mobile is using a different header than all
105
+ * other pages?"*): both fields wear `SECTION_TEXT_LEVELS.app`'s own classes — the title's and the lede's — with no
106
+ * height or line-height of their own, inside `PageHeader level="app"`, so an uneditable Create and Library's masthead
107
+ * are the same header; editing shows only the caret and the underline */
108
+ const titleCls = SECTION_TEXT_LEVELS.app.title
109
+ const ledeCls = SECTION_TEXT_LEVELS.app.lede
110
+ const field = (value, onChange, cls) => (
111
+ <input
112
+ ref={cls === titleCls ? titleRef : undefined}
113
+ type="text"
114
+ value={value ?? ''}
115
+ onChange={(e) => onChange?.(e.target.value)}
116
+ onBlur={() => setEditing(false)}
117
+ onKeyDown={(e) => { if (e.key === 'Enter') setEditing(false) }}
118
+ readOnly={!editing}
119
+ className={`block p-0 bg-transparent text-inherit outline-none border-none ${cls}`}
120
+ /* `1lh` — the class's own line-height: an input otherwise sizes to the font's metrics (69 for the 60 title) */
121
+ style={{ width: `${String(value ?? '').length + 1}ch`, height: '1lh', cursor: editing ? 'text' : 'default', boxShadow: editing ? 'inset 0 -1px 0 var(--kol-fg-12)' : 'none', caretColor: editing ? 'auto' : 'transparent', pointerEvents: editing ? 'auto' : 'none' }}
122
+ />
123
+ )
124
+
125
+ /* INSERT is its own control, never the card's click (monitor, user 2026-09-02): the card opens the part's page. It is
126
+ * the card's and the row's `actions` slot — the plate, where an app card carries its cog and trash (review 2, § 3.1:
127
+ * *"someone attached an insert to the end of a random card"*) */
128
+ const insert = (part) => onPlace ? (
129
+ <ActionButton chrome="inline" size="sm" icon="plus" label="Insert" onAction={(e) => { e?.stopPropagation(); onPlace(part) }} />
130
+ ) : undefined
131
+ const [cols, setCols] = useState(null)
132
+ /* a phone gets the rows alone, no LIST GRID line — CatalogPage's `phoneLayout` rule, the same rung (768) */
133
+ const phoneRows = useMediaQuery('(max-width: 767px)')
134
+
135
+ return (
136
+ /* Create sits on the app tier's fg-02 wash and holds still on both views: the case is a fixed canvas, the parts scroll in their own region */
137
+ <PageShell mode="fixed" className={className} style={{ '--kol-shell-page-wash': 'var(--kol-fg-02)', '--kol-catalog-n': cols ?? undefined, position: 'relative', isolation: 'isolate', ...style }}>
138
+ {/* the dot grid on the WHOLE page — over the wash, under the chrome, the padding ignored; CanvasStudio drives it
139
+ * through gridRef so it rides the zoom and the pan (monitor, user 2026-08-27) */}
140
+ {page === 'case' && showCase && <div ref={gridRef} aria-hidden style={{ position: 'absolute', inset: 0, zIndex: -1, pointerEvents: 'none' }} />}
141
+ {/* the chrome floats ABOVE the canvas: the case runs under the masthead and the filter row (monitor, 2026-09-02) */}
142
+ <div style={{ position: 'relative', zIndex: 'var(--kol-z-sticky)' }}>
143
+ <PageHeader
144
+ level="app"
145
+ title={editable ? field(header.title, header.onTitleChange, titleCls) : header.title}
146
+ subtitle={editable ? field(header.subtitle, header.onSubtitleChange, ledeCls) : header.subtitle}
147
+ />
148
+ </div>
149
+
150
+ <div style={{ flex: 1, display: 'flex', flexDirection: 'column', minHeight: 0, position: 'relative', zIndex: 'var(--kol-z-sticky)' }}>
151
+ <ContentFilters
152
+ tone="sunken"
153
+ items={page === 'case' ? [] : parts}
154
+ title={page === 'case' ? L.caseTitle : L.partsTitle}
155
+ totalCount={page === 'case' ? caseCount : parts.length}
156
+ filterGroups={page === 'case' ? [] : groups}
157
+ mutuallyExclusiveFilters={exclusive}
158
+ showCountOnlyWhenFiltering
159
+ headerActions={editable ? (
160
+ /* BARE, as the filter and the search beside it (user 2026-10-23: *"icon frame with background color? breaks
161
+ * consistency"*) — IconFrame nav, 16 in the 32 box; the press keeps the title's focus, the click toggles */
162
+ <IconFrame
163
+ name="edit"
164
+ variant="nav"
165
+ size="md"
166
+ iconSize={16}
167
+ aria-label="Rename"
168
+ onPointerDown={(e) => e.preventDefault()}
169
+ onClick={() => {
170
+ setEditing((prev) => {
171
+ if (prev) { titleRef.current?.blur(); window.getSelection()?.removeAllRanges(); return false }
172
+ requestAnimationFrame(() => { titleRef.current?.focus(); titleRef.current?.select() })
173
+ return true
174
+ })
175
+ }}
176
+ />
177
+ ) : undefined}
178
+ viewModeOptions={[{ value: 'case', label: L.case }, { value: 'parts', label: L.parts }]}
179
+ viewMode={page}
180
+ onViewModeChange={setPage}
181
+ layoutOptions={page === 'parts' && !phoneRows ? [{ value: 'list', label: 'LIST' }, { value: 'grid', label: 'GRID' }] : undefined}
182
+ defaultLayout="list"
183
+ layout={phoneRows ? 'list' : undefined}
184
+ renderItem={(items, _mode, layout) => {
185
+ if (page === 'case') {
186
+ return (
187
+ <div style={{ display: 'flex', flexDirection: 'column', flex: 1, minHeight: 0 }}>
188
+ {caseControls}
189
+ {caseControls && <Divider className="mb-4" />}
190
+ {showCase && (canvas ? canvas({ gridRef, view: v, onViewChange: setV }) : (
191
+ /* the canvas is the whole page: the case is never cut by the viewport's box (monitor, 2026-09-02) */
192
+ <CanvasStudio gridRef={gridRef} view={v} onViewChange={setV} style={{ flex: 1, margin: '0 calc(var(--kol-shell-page-pad) * -1)', overflow: 'visible' }}>
193
+ {children}
194
+ </CanvasStudio>
195
+ ))}
196
+ </div>
197
+ )
198
+ }
199
+ /* ONE CARD FOR THE SET (user 2026-10-23: *"why are we using a different card for PARTS? when file has so many
200
+ * props"*): a part is the `app` card and row, the files' own — no verbs, so no cog or trash; INSERT is the
201
+ * plate's action. On `CatalogGrid`, the Catalog's own grid, six at most, the list three across */
202
+ return (
203
+ /* the parts scroll in their own region — the page holds still on both views (user 2026-10-23) */
204
+ <div style={{ flex: 1, minHeight: 0, overflowY: 'auto', paddingBottom: 'calc(var(--kol-spacing-6) + var(--kol-shell-bar-clear, 0px))' }}>
205
+ <CatalogGrid layout={layout} onColumns={setCols} listColumns={3}>
206
+ {items.map((part) => {
207
+ const { key, ...props } = toCard ? toCard(part, { layout }) : { title: part.title ?? part.name }
208
+ const k = key ?? part.id ?? part.name
209
+ const item = layout === 'grid'
210
+ ? <ContentCard key={onPartPointerDown ? undefined : k} variant="app" {...props} actions={insert(part)} />
211
+ : <ContentRow key={onPartPointerDown ? undefined : k} variant="app" {...props} actions={insert(part)} />
212
+ return onPartPointerDown ? <div key={k} onPointerDown={(e) => onPartPointerDown(part, e)}>{item}</div> : item
213
+ })}
214
+ </CatalogGrid>
215
+ </div>
216
+ )
217
+ }}
218
+ />
219
+
220
+ {/* the bottom bar — the zoom readout is the canvas's; the right side is the consumer's (monitor: rows, HP, the case preview) */}
221
+ {page === 'case' && (
222
+ /* above the phone bar or pill when the shell draws one (`--kol-shell-bar-h`, 2026-10-23: it sat under the bar) */
223
+ <div className="fixed flex items-center justify-between" style={{ bottom: 'calc(var(--kol-shell-bar-h, 0px) + var(--kol-shell-bar-clear, 0px) + 24px)', left: 'calc(var(--kol-shell-rail-width, 0px) + 24px)', right: 24, zIndex: 'var(--kol-z-sticky)' }}>
224
+ <div className="flex items-center gap-2">
225
+ <span onClick={() => applyZoom((z) => z - 0.1)} className="kol-helper-12 text-fg-48 hover:text-fg-96 cursor-pointer select-none">−</span>
226
+ <input
227
+ type="text"
228
+ inputMode="numeric"
229
+ value={zoomInput}
230
+ onFocus={(e) => { zoomEditing.current = true; e.target.select() }}
231
+ onChange={(e) => setZoomInput(e.target.value)}
232
+ onBlur={() => {
233
+ zoomEditing.current = false
234
+ const n = parseInt(zoomInput, 10)
235
+ if (!isNaN(n)) applyZoom(() => n / 100)
236
+ else setZoomInput(String(Math.round(v.zoom * 100)))
237
+ }}
238
+ onKeyDown={(e) => { if (e.key === 'Enter') e.target.blur() }}
239
+ className="kol-helper-12 text-fg-64 bg-transparent text-right border-none outline-none"
240
+ style={{ width: 32 }}
241
+ aria-label="Zoom"
242
+ />
243
+ <span className="kol-helper-12 text-fg-32">%</span>
244
+ <span onClick={() => applyZoom((z) => z + 0.1)} className="kol-helper-12 text-fg-48 hover:text-fg-96 cursor-pointer select-none">+</span>
245
+ {caseLink && (
246
+ <span style={{ marginLeft: 16 }}>
247
+ {caseLink.label != null
248
+ ? <span onClick={caseLink.onClick} className="kol-helper-12 text-fg-48 hover:text-fg-96 cursor-pointer select-none">{caseLink.label}</span>
249
+ : (warnJsx('StudioCreate caseLink', 'Pass { label, onClick }.'), caseLink)}
250
+ </span>
251
+ )}
252
+ </div>
253
+ <div className="flex items-center gap-1">{caseActions}</div>
254
+ </div>
255
+ )}
256
+ </div>
257
+ </PageShell>
258
+ )
259
+ }
260
+
261
+ /* a bar button for `caseActions` — monitor's rows / HP / case-preview toggles wear this; exported so a consumer
262
+ * writes the three in one line each */
263
+ export function StudioCreateAction({ icon, label, onClick, pressed }) {
264
+ return (
265
+ <button
266
+ type="button"
267
+ onClick={onClick}
268
+ aria-label={label}
269
+ aria-pressed={pressed}
270
+ className={`${pressed ? 'text-oq-96' : 'text-oq-80'} hover:text-oq-96 transition-colors cursor-pointer bg-transparent border-none p-2 leading-none`}
271
+ >
272
+ <Icon name={icon} size={20} />
273
+ </button>
274
+ )
275
+ }
@@ -1,14 +1,17 @@
1
1
  import { useEffect, useRef, useState } from 'react'
2
2
  import { Button, pushLayer, popLayer, isTopLayer } from '@kolkrabbi/kol-component'
3
+ import { warnJsx } from './warnJsx.js'
3
4
 
4
5
  /**
5
6
  * WalkthroughPanel — A stepped intro card. the absolutely-centred stepped intro card (both repos'
6
7
  * HomePage): chevron Buttons either side, text column + illustration pane.
7
8
  *
8
- * Steps are content: `[{ title, text: [..], illustration?, actions? }]` —
9
- * `illustration` is a render slot (monitor globs SVGs, mirror uses a JPEG),
10
- * a step with `actions` renders that node centred instead of the text/image
11
- * split (the "Get started" step).
9
+ * Steps are content: `[{ title, text: [..], cover?, illustration?, actions? }]` —
10
+ * `cover` is an image src the panel draws itself (full-bleed, at 60 %), `illustration` a render slot for a
11
+ * DRAWING (monitor globs SVGs); a step with `actions` renders them centred instead of the text/image split
12
+ * (the "Get started" step). THE ACTIONS ARE DATA (user 2026-10-24: Mirror and Monitor each drew their own
13
+ * Button there, one of them not the DS's): `[{ label, onClick, icon? }]`, drawn here as `Button tone="grey"
14
+ * size="md"`; a node is still drawn, with a dev warning.
12
15
  *
13
16
  * `onClose` draws an X INSIDE the card, top-right (user, 2026-09-26, on media-hub:
14
17
  * the panel had no close of its own, so every app put one outside the card or on a
@@ -72,7 +75,9 @@ export default function WalkthroughPanel({ steps = [], iconComponent, onClose })
72
75
  )}
73
76
  {current.actions ? (
74
77
  <div style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 12 }}>
75
- {current.actions}
78
+ {Array.isArray(current.actions)
79
+ ? current.actions.map((a, i) => <Button key={a.label ?? i} tone="grey" size="md" iconLeft={a.icon} iconComponent={iconComponent} onClick={a.onClick}>{a.label}</Button>)
80
+ : (warnJsx('walkthrough[].actions', 'Pass [{ label, onClick }]; the panel draws the buttons.'), current.actions)}
76
81
  </div>
77
82
  ) : (
78
83
  <>
@@ -85,9 +90,9 @@ export default function WalkthroughPanel({ steps = [], iconComponent, onClose })
85
90
  </div>
86
91
  <span className="text-fg-48 kol-helper-12">{step + 1} / {steps.length}</span>
87
92
  </div>
88
- {current.illustration && (
93
+ {(current.cover || current.illustration) && (
89
94
  <div style={{ flex: '0 0 50%', overflow: 'hidden' }}>
90
- {current.illustration}
95
+ {current.cover ? <img src={current.cover} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover', opacity: 0.6 }} /> : current.illustration}
91
96
  </div>
92
97
  )}
93
98
  </>
package/src/index.js CHANGED
@@ -30,6 +30,7 @@ export { ShortcutsOverlay, shortcutInScope } from '@kolkrabbi/kol-component'
30
30
  export { Logomark } from '@kolkrabbi/kol-component'
31
31
  // the app tier, shipped once (ShellHomeSystem, kol-fxr 2026-08-27)
32
32
  export { default as CatalogPage } from './CatalogPage.jsx'
33
+ export { default as CatalogGrid } from './CatalogGrid.jsx'
33
34
  export { default as SettingsShortcuts } from './SettingsShortcuts.jsx'
34
35
  export { default as SettingsLinks, SettingsColophon } from './SettingsLinks.jsx'
35
36
  export { default as TouchDeviceOverlay, useTouchPrimary } from './TouchDeviceOverlay.jsx'
@@ -40,5 +41,7 @@ export { default as HubSettings } from './HubSettings.jsx'
40
41
  export { default as HubDev } from './HubDev.jsx'
41
42
  // the Studio — the Hub + Home · Library · Create · Use · pages · Settings, the workstation (apps review §6c, 2026-09-29)
42
43
  export { default as AppStudio } from './AppStudio.jsx'
44
+ // Create: a catalog of parts beside the case on the studio canvas — monitor's page made once (plan-2026-10-23 § 3.4)
45
+ export { default as StudioCreate, StudioCreateAction } from './StudioCreate.jsx'
43
46
  // a consumer slot in the opened rail — the page portals into it (NavRailConsumerSlot, kol-monitor 2026-10-15)
44
47
  export { RailSlotProvider, useRailSlot } from '@kolkrabbi/kol-component'
package/src/warnJsx.js ADDED
@@ -0,0 +1,9 @@
1
+ /* JSX WHERE DATA IS EXPECTED — one dev warning per place (user 2026-10-24: *"we are literally avoiding this custom per
2
+ * repo shit"*). The Hub's surfaces take data and draw it themselves; an element or a render function handed to one of
3
+ * these props is the hole every drift came through, so it is named once in the console and never silently accepted. */
4
+ const warned = new Set()
5
+ export function warnJsx(where, note = '') {
6
+ if (!import.meta.env?.DEV || warned.has(where)) return
7
+ warned.add(where)
8
+ console.warn(`kol-shell: ${where} takes data, not JSX — the Hub draws it (2026-10-24). ${note}`.trim())
9
+ }