@kolkrabbi/kol-component 0.295.1 → 0.297.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/atoms/CloseButton.jsx +24 -4
- package/src/atoms/IconToggle.jsx +1 -1
- package/src/hooks/canvasViewport.js +400 -0
- package/src/hooks/railRow.js +11 -0
- package/src/index.js +9 -4
- package/src/molecules/AppItem.jsx +60 -38
- package/src/molecules/ContentCard.jsx +6 -3
- package/src/molecules/ContentRow.jsx +5 -3
- package/src/molecules/ContentText.jsx +12 -11
- package/src/molecules/LabeledControl.jsx +3 -1
- package/src/molecules/MenuItem.jsx +1 -1
- package/src/molecules/PageHeader.jsx +2 -1
- package/src/molecules/Rail.jsx +5 -3
- package/src/molecules/SectionText.jsx +6 -2
- package/src/molecules/TabsRow.jsx +65 -9
- package/src/molecules/TextFold.jsx +1 -1
- package/src/organisms/AppItemMenuProvider.jsx +159 -0
- package/src/organisms/Canvas.jsx +49 -258
- package/src/organisms/CanvasStudio.jsx +128 -0
- package/src/organisms/CommandOverlay.jsx +7 -5
- package/src/organisms/CurveEditor.jsx +1 -1
- package/src/organisms/MediaGalleryModes.jsx +1 -1
- package/src/organisms/MediaLibrary.jsx +31 -9
- package/src/organisms/MediaLibraryPages.jsx +30 -6
- package/src/organisms/NavRail.jsx +68 -56
- package/src/organisms/SettingsPanel.jsx +16 -9
- package/src/organisms/SettingsSections.jsx +31 -6
- package/src/utilities/imageToDataUrl.js +39 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useLayoutEffect, useRef } from 'react'
|
|
2
|
+
import { CanvasZoomContext } from '../hooks/canvasZoom.js'
|
|
3
|
+
import { useCanvasViewport, CANVAS_GRID_CELL, CANVAS_GRID_IMAGE } from '../hooks/canvasViewport.js'
|
|
4
|
+
import { Tooltip } from '../utilities/Popover.jsx'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* CanvasStudio — An infinite dotted surface to arrange things on. The studio canvas: the background the rack's
|
|
8
|
+
* modules and the desk's channel strips sit on (the canvas family, 2026-10-23). kol-monitor's
|
|
9
|
+
* `RackViewport` and kol-mirror's desk each carried a copy of it — the same dot grid, the same
|
|
10
|
+
* Space-and-drag, their own zoom modifier — and `apps/rack` and `apps/mixer` run on this one now.
|
|
11
|
+
*
|
|
12
|
+
* It is the BACKGROUND ONLY: the dot grid, pan, zoom, the lock and the keys. What sits on it —
|
|
13
|
+
* modules snapping to HP, the patch cables, the workbench, the desk's embla loop — stays the
|
|
14
|
+
* app's, rendered as `children` (in the pan-zoom layer) or `overlay` (screen space, over it).
|
|
15
|
+
* `CanvasEditor` is its sibling: a fixed artboard with rulers; both read `useCanvasViewport`,
|
|
16
|
+
* so a gesture or a key means the same thing on either. The keys are `CANVAS_KEYS`.
|
|
17
|
+
*
|
|
18
|
+
* The grid: a 1px `--kol-fg-12` dot on a 36px cell, the cell scaled by the zoom and the field
|
|
19
|
+
* offset by the pan, so the surface moves under the work. A consumer may host it on a bigger box
|
|
20
|
+
* (monitor's Create paints it on the whole page) through `gridRef` — same cell, same offset.
|
|
21
|
+
*
|
|
22
|
+
* @param {boolean} grid the dot grid (default true); with `onGridChange` it is controlled
|
|
23
|
+
* @param {Function} onGridChange (on) => void — `G` and the consumer's own toggle both land here
|
|
24
|
+
* @param {boolean} locked the view lock — every pan and zoom returns early while on; with `onLockChange` controlled
|
|
25
|
+
* @param {Function} onLockChange (on) => void — `L` lands here
|
|
26
|
+
* @param {{zoom: number, x: number, y: number}} view the view, controlled; `defaultView` seeds an uncontrolled one
|
|
27
|
+
* @param {Object} defaultView `{ zoom, x, y }` (default zoom 1 at 0, 0)
|
|
28
|
+
* @param {Function} onViewChange (view) => void — persist it if you want it back
|
|
29
|
+
* @param {number} minZoom the zoom floor (default 0.1 — a 1716px rack fits a 390 phone)
|
|
30
|
+
* @param {number} maxZoom the zoom ceiling (default 2)
|
|
31
|
+
* @param {boolean} fit FIT THE HEIGHT on open (user 2026-10-23, the rack on a phone: *"youd have to start every time
|
|
32
|
+
* by zooming in"*): the zoom that puts the content's full height in the surface, clamped, at
|
|
33
|
+
* 0, 0 — and ⌘0 returns to that fit, not to 100 %. The width may overhang; pan to it
|
|
34
|
+
* @param {React.RefObject<HTMLElement>} gridRef an element to paint the grid on INSTEAD of the surface — a bigger box
|
|
35
|
+
* @param {React.RefObject<HTMLElement>} surfaceRef a ref to the surface element, for an overlay that measures against it (cables)
|
|
36
|
+
* @param {'studio'|'editor'|'none'} touch the touch policy (default `studio`: one finger pans unless on a control, two pan and pinch)
|
|
37
|
+
* @param {boolean} spaceWhenOver Space grabs only while the pointer is over the surface (an app whose Space is the transport's elsewhere)
|
|
38
|
+
* @param {string} ignore a selector whose matches keep their own wheel and touch (an inner scroller); default fields and `[data-scroll-own]`
|
|
39
|
+
* @param {Function} onSpaceTap a Space press released without a pan
|
|
40
|
+
* @param {ReactNode} backdrop a node behind the children, inside the pan-zoom layer
|
|
41
|
+
* @param {ReactNode} overlay nodes in screen space over the layer — cables, chips
|
|
42
|
+
* @param {string} className on the surface
|
|
43
|
+
* @param {Object} style on the surface, last — `overflow` and `touchAction` may be overridden here
|
|
44
|
+
* @param {ReactNode} children what sits on the surface, in the pan-zoom layer
|
|
45
|
+
*/
|
|
46
|
+
export default function CanvasStudio({
|
|
47
|
+
grid = true,
|
|
48
|
+
onGridChange,
|
|
49
|
+
locked,
|
|
50
|
+
onLockChange,
|
|
51
|
+
view,
|
|
52
|
+
defaultView,
|
|
53
|
+
onViewChange,
|
|
54
|
+
minZoom = 0.1,
|
|
55
|
+
maxZoom = 2,
|
|
56
|
+
fit = false,
|
|
57
|
+
gridRef,
|
|
58
|
+
surfaceRef,
|
|
59
|
+
touch = 'studio',
|
|
60
|
+
spaceWhenOver = false,
|
|
61
|
+
ignore,
|
|
62
|
+
onSpaceTap,
|
|
63
|
+
backdrop,
|
|
64
|
+
overlay,
|
|
65
|
+
className = '',
|
|
66
|
+
style,
|
|
67
|
+
children,
|
|
68
|
+
}) {
|
|
69
|
+
const own = useRef(null)
|
|
70
|
+
const ref = surfaceRef ?? own
|
|
71
|
+
const layer = useRef(null)
|
|
72
|
+
/* the fit: the layer's untransformed height (its own box, so zoom 1) against the surface's; nothing measurable → rest */
|
|
73
|
+
const fitView = () => {
|
|
74
|
+
const sh = ref.current?.clientHeight, h = layer.current?.scrollHeight
|
|
75
|
+
if (!fit || !sh || !h) return undefined
|
|
76
|
+
return { zoom: Math.min(maxZoom, Math.max(minZoom, sh / h)), x: 0, y: 0 }
|
|
77
|
+
}
|
|
78
|
+
const vp = useCanvasViewport({
|
|
79
|
+
ref, view, defaultView, onViewChange, minZoom, maxZoom, rest: fitView,
|
|
80
|
+
locked, onLockChange, grid, onGridChange, gridKey: true, lockKey: true,
|
|
81
|
+
touch, spaceWhenOver, ignore, onSpaceTap,
|
|
82
|
+
})
|
|
83
|
+
const { zoom, x, y } = vp.view
|
|
84
|
+
/* on open, the fit is the view — after layout, so the layer has its height */
|
|
85
|
+
useLayoutEffect(() => { if (fit) vp.reset() }, [fit]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
86
|
+
const cell = `${CANVAS_GRID_CELL * zoom}px ${CANVAS_GRID_CELL * zoom}px`
|
|
87
|
+
const gridStyle = vp.grid && !gridRef ? { backgroundImage: CANVAS_GRID_IMAGE, backgroundSize: cell, backgroundPosition: `${x}px ${y}px` } : null
|
|
88
|
+
|
|
89
|
+
/* a hosted grid rides the same zoom and pan — the host keeps its own colour, only the dots are written */
|
|
90
|
+
useLayoutEffect(() => {
|
|
91
|
+
const el = gridRef?.current
|
|
92
|
+
if (!el) return undefined
|
|
93
|
+
if (vp.grid) {
|
|
94
|
+
el.style.setProperty('background-image', CANVAS_GRID_IMAGE)
|
|
95
|
+
el.style.setProperty('background-size', cell)
|
|
96
|
+
el.style.setProperty('background-position', `${x}px ${y}px`)
|
|
97
|
+
} else {
|
|
98
|
+
el.style.removeProperty('background-image')
|
|
99
|
+
el.style.removeProperty('background-size')
|
|
100
|
+
el.style.removeProperty('background-position')
|
|
101
|
+
}
|
|
102
|
+
return undefined
|
|
103
|
+
}, [gridRef, vp.grid, cell, x, y])
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<CanvasZoomContext.Provider value={zoom}>
|
|
107
|
+
<div
|
|
108
|
+
ref={ref}
|
|
109
|
+
className={`kol-canvas-studio relative overflow-hidden select-none ${className}`.trim()}
|
|
110
|
+
style={{ flex: 1, minHeight: 0, touchAction: touch === 'none' ? undefined : 'none', cursor: vp.cursor, ...gridStyle, ...style }}
|
|
111
|
+
>
|
|
112
|
+
{/* no transition on the transform: chrome that sizes by 1/zoom updates in the same frame */}
|
|
113
|
+
<div ref={layer} style={{ transform: vp.transform, transformOrigin: '0 0', width: '100%', pointerEvents: vp.deaf ? 'none' : 'auto' }}>
|
|
114
|
+
{backdrop}
|
|
115
|
+
{children}
|
|
116
|
+
</div>
|
|
117
|
+
{overlay}
|
|
118
|
+
{vp.showFps && (
|
|
119
|
+
<div className="absolute bottom-3 right-3 z-[3]">
|
|
120
|
+
<Tooltip label="Framerate — press F to hide" asChild>
|
|
121
|
+
<span className="px-2 py-1 rounded border border-fg-08 bg-surface-secondary kol-mono-12 text-emphasis tabular-nums">{vp.fps} fps</span>
|
|
122
|
+
</Tooltip>
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
</CanvasZoomContext.Provider>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
@@ -71,9 +71,10 @@ const MODE_PLACEHOLDER = { search: 'Search…', add: 'Add…' }
|
|
|
71
71
|
* its keys in place — label left, combo right, never run. The index keeps two keys with one label apart. */
|
|
72
72
|
function shortcutFolds(shortcuts, path) {
|
|
73
73
|
return shortcuts.filter((s) => shortcutInScope(s, path)).map((s) => ({
|
|
74
|
-
/*
|
|
75
|
-
*
|
|
76
|
-
|
|
74
|
+
/* EVERY section starts OPEN (user 2026-10-23: *"you should see the shortcuts expanded, not choose navigate or
|
|
75
|
+
* help, so expand all should be collapse all, with expanded the default"*) — the footer reads Collapse all on
|
|
76
|
+
* open and folds them all in one press. Until then only a section with matching `routes` opened. */
|
|
77
|
+
id: `cat:${s.section}`, label: s.section, group: 'Shortcuts', open: true,
|
|
77
78
|
items: (s.items ?? []).map((it, i) => ({ id: it.id ?? `${i}:${it.label}`, label: it.label, hint: it.combo ?? it.keys })),
|
|
78
79
|
}))
|
|
79
80
|
}
|
|
@@ -93,10 +94,11 @@ function unfold(rows, opened) {
|
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
/**
|
|
96
|
-
* CommandOverlay — The ⌘K overlay: search, add, go, shortcuts. Was `ShellSearchOverlay` (still exported, an
|
|
97
|
+
* CommandOverlay — The ⌘K search modal. The ⌘K overlay: search, add, go, shortcuts. Was `ShellSearchOverlay` (still exported, an
|
|
97
98
|
* alias). `mode` names what the overlay is for — `search` (default) · `add` · `shortcuts` (`go` is search's old name). In
|
|
98
99
|
* `shortcuts` it draws `shortcuts` (the AppHub keymap) with NO field, as fold rows: the current page's sections
|
|
99
|
-
* under "Shortcuts",
|
|
100
|
+
* under "Shortcuts", every one open on arrival (its keys in place, label and combo, never run), the footer's
|
|
101
|
+
* Collapse all folding them. AppHub's `S` opens this; its ⌘K opens `search` over files, pages and the same keymap.
|
|
100
102
|
*
|
|
101
103
|
* FOLD ROWS, any mode: a row with `items` is a category — Enter / → / click opens it in place, ← or Enter again
|
|
102
104
|
* closes it; its children are ordinary rows (Enter selects them). An "All" category is just a fold row holding
|
|
@@ -158,7 +158,7 @@ export default function CurveEditor({ value, onChange, stock = null, validate, k
|
|
|
158
158
|
<span className="kol-helper-10 text-meta">Curve</span>
|
|
159
159
|
<Dropdown size="sm" variant="subtle" className="w-full" options={kinds} value={kind} onChange={setKind} />
|
|
160
160
|
{!isCustom && (
|
|
161
|
-
<p className="kol-
|
|
161
|
+
<p className="kol-mono-10 text-meta">Editing “{stock.label}” forks it to a custom curve.</p>
|
|
162
162
|
)}
|
|
163
163
|
|
|
164
164
|
{kind === 'epicycle' && (
|
|
@@ -7,7 +7,7 @@ import MediaViewer from './MediaViewer.jsx'
|
|
|
7
7
|
const LABELS = { carousel: 'Carousel', grid: 'Grid', waterfall: 'Waterfall' }
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* MediaGalleryModes — One media set, three ways to
|
|
10
|
+
* MediaGalleryModes — One media set, three ways to view it. (MediaGalleryModes, kol-branding
|
|
11
11
|
* 2026-10-21 — the user: *"a carousel is a nice viewing experience, unless you are looking for
|
|
12
12
|
* specific thing, then you might wanna grid or waterfall the images"*.) The viewer switches
|
|
13
13
|
* carousel (`GalleryCarousel`) · grid · waterfall (`MediaTileGallery`); any item opens the one
|
|
@@ -15,6 +15,8 @@ import { MenuItem, MenuDropdownItem, MenuDropdownDivider } from '../molecules/Me
|
|
|
15
15
|
import MediaViewer from './MediaViewer.jsx'
|
|
16
16
|
import { MediaLibraryBrowse, MediaLibraryLibrary, SETTINGS_BASE } from './MediaLibraryPages.jsx'
|
|
17
17
|
import MediaLibraryExplorer from './MediaLibraryExplorer.jsx'
|
|
18
|
+
import { MastheadContext } from '../utilities/masthead.js'
|
|
19
|
+
import useMediaQuery from '../hooks/useMediaQuery.js'
|
|
18
20
|
import { SettingsChipRow, chipCls } from './SettingsPanel.jsx'
|
|
19
21
|
import { filterMedia } from '../utilities/mediaSearch.js'
|
|
20
22
|
|
|
@@ -877,7 +879,7 @@ function PickerBody({ items, viewMode, onOpen, onPick }) {
|
|
|
877
879
|
if (loading) return <p className="kol-helper-12 text-meta">Loading…</p>
|
|
878
880
|
const files = items.filter((r) => r.type !== 'folder')
|
|
879
881
|
const shownFolders = items.filter((r) => r.type === 'folder')
|
|
880
|
-
if (items.length === 0) return <p className="kol-
|
|
882
|
+
if (items.length === 0) return <p className="kol-mono-12 text-meta">Nothing here.</p>
|
|
881
883
|
return (
|
|
882
884
|
<div className="kol-media-scroll flex flex-col gap-3">
|
|
883
885
|
{shownFolders.length > 0 && (
|
|
@@ -1076,32 +1078,52 @@ function PickerBrowse({ client, accept, onClose, onSelect, title = 'MEDIA', ...b
|
|
|
1076
1078
|
const [settings, setSettings] = useState(() => ({ ...SETTINGS_BASE, columnHeight: `calc(var(--kol-media-picker-h) - ${PICKER_CHROME}px)` }))
|
|
1077
1079
|
const [bucket, setBucket] = useState(browseProps.bucket)
|
|
1078
1080
|
const [file, setFile] = useState(null)
|
|
1079
|
-
const
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1081
|
+
const fits = (f) => !!f && acceptsKind(accept)({ ...f, kind: kindOf(f) })
|
|
1082
|
+
const ok = fits(file)
|
|
1083
|
+
const use = (f = file) => {
|
|
1084
|
+
onSelect?.(client.mediaUrl(f.storageKey ?? f.key, bucket ?? undefined), { contentType: f.contentType, kind: kindOf(f) })
|
|
1082
1085
|
onClose?.()
|
|
1083
1086
|
}
|
|
1087
|
+
/* ON A PHONE THERE IS NO FOOT (user 2026-10-23: *"on mobile you just select the image and maybe dropdown says insert"*):
|
|
1088
|
+
* a tap selects, the row's menu leads with Insert, and the × on the title row is the way out — Escape has no key there */
|
|
1089
|
+
const phone = useMediaQuery('(max-width: 767px)')
|
|
1090
|
+
/* ON A PHONE THE CARD'S BODY SCROLLS (user 2026-10-23: *"media tab doesn't scroll"*): the stack hugs its rows and
|
|
1091
|
+
* expects the PAGE to scroll, as r2b2's does — inside the card, which clips, nothing did, so rows past the fold were
|
|
1092
|
+
* unreachable. The browse page takes the card's remaining height and scrolls, header and all. */
|
|
1084
1093
|
return (
|
|
1085
1094
|
/* NO X (user 2026-10-20: *"at this point just use escape"*). Escape, the backdrop and Cancel close it.
|
|
1086
1095
|
* The X moved three times (overlay corner → title row, 2026-10-10 → beside the gear → corner again)
|
|
1087
1096
|
* and was wrong each time; without it the card's block-start lane goes too (`pt-5`). */
|
|
1088
1097
|
<FullscreenOverlay open scrim onClose={onClose} closeButton={false}>
|
|
1089
1098
|
<div className="kol-media-picker gap-4 pt-5">
|
|
1099
|
+
{/* THE PICKER READS AS THE MEDIA APP (user 2026-10-23, beside kol-r2b2 on a phone): the title in the display voice —
|
|
1100
|
+
* a modal card, not a page of the app, so the shell's masthead does not reach it — and the listing opening at
|
|
1101
|
+
* the title root, the buckets as rows (the database glyph), each with its count. The browse surface's own
|
|
1102
|
+
* `startAtRoot`; one bucket collapses it as ever. */}
|
|
1103
|
+
<MastheadContext.Provider value={null}>
|
|
1090
1104
|
<MediaLibraryBrowse
|
|
1091
1105
|
{...browseProps}
|
|
1092
1106
|
client={client}
|
|
1093
1107
|
title={title}
|
|
1094
1108
|
bucket={bucket}
|
|
1109
|
+
startAtRoot
|
|
1095
1110
|
onBucketChange={(id) => { setBucket(id); browseProps.onBucketChange?.(id) }}
|
|
1096
1111
|
settings={settings}
|
|
1097
1112
|
onSettingsChange={setSettings}
|
|
1098
1113
|
onPickFile={setFile}
|
|
1114
|
+
onHeaderClose={phone ? onClose : undefined}
|
|
1115
|
+
className={phone ? 'min-h-0 flex-1 overflow-y-auto' : browseProps.className}
|
|
1116
|
+
onInsert={phone ? use : undefined}
|
|
1117
|
+
canInsert={fits}
|
|
1099
1118
|
/>
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
<
|
|
1103
|
-
|
|
1104
|
-
|
|
1119
|
+
</MastheadContext.Provider>
|
|
1120
|
+
{!phone && (
|
|
1121
|
+
<div className="mt-auto flex items-center justify-end gap-4">
|
|
1122
|
+
<span className="kol-mono-12 text-fg-48 truncate mr-auto">{file ? file.key : 'Select a file'}</span>
|
|
1123
|
+
<Button tone="grey" size="md" onClick={onClose}>Cancel</Button>
|
|
1124
|
+
<Button size="md" disabled={!ok} onClick={() => use()}>Use</Button>
|
|
1125
|
+
</div>
|
|
1126
|
+
)}
|
|
1105
1127
|
</div>
|
|
1106
1128
|
</FullscreenOverlay>
|
|
1107
1129
|
)
|
|
@@ -1049,6 +1049,10 @@ export function MediaLibraryBrowse({
|
|
|
1049
1049
|
folderTree, headerActions, headerTrailing, refreshKey, onOpen, autoFocus = false, settingsFooter, className = '', banner,
|
|
1050
1050
|
/* `onHeaderClose` — a × alone at the far end of the title row, outside the controls (the picker card) */
|
|
1051
1051
|
onHeaderClose,
|
|
1052
|
+
/* `onInsert(o)` — a file row's menu LEADS with Insert (the picker on a phone, user 2026-10-23: *"you just select the
|
|
1053
|
+
* image and maybe dropdown says insert"*); `canInsert(o)` gates it per file (the picker's `accept`) */
|
|
1054
|
+
onInsert,
|
|
1055
|
+
canInsert,
|
|
1052
1056
|
/* `smartFolder` — a smart folder's id to open ON (a Home tile linking straight to one); the chips
|
|
1053
1057
|
* take over from there (media D1 plan v2) */
|
|
1054
1058
|
smartFolder,
|
|
@@ -1107,6 +1111,8 @@ export function MediaLibraryBrowse({
|
|
|
1107
1111
|
* and returns the list. Rows are the search modal's shape; a row with `run` calls it instead of
|
|
1108
1112
|
* jumping to `id` as a file key. */
|
|
1109
1113
|
searchSuggestions,
|
|
1114
|
+
/* `startAtRoot` — open at the title root, the buckets listed, instead of inside `bucket` (the picker, 2026-10-23) */
|
|
1115
|
+
startAtRoot = false,
|
|
1110
1116
|
/* `bucketLevel` — keep title → bucket → folders with ONE bucket (kol-client-olina 2026-09-23).
|
|
1111
1117
|
* Absent, a one-bucket consumer collapses the level as ruled 2026-09-03. */
|
|
1112
1118
|
bucketLevel = false,
|
|
@@ -1122,7 +1128,7 @@ export function MediaLibraryBrowse({
|
|
|
1122
1128
|
const [ownPrefix, setOwnPrefix] = useState('')
|
|
1123
1129
|
const prefix = prefixProp ?? ownPrefix
|
|
1124
1130
|
const setPrefix = (v) => { if (v) setAppRoot(false); if (prefixProp == null) setOwnPrefix(v); onPrefix?.(v) }
|
|
1125
|
-
const [appRoot, setAppRoot] = useState(
|
|
1131
|
+
const [appRoot, setAppRoot] = useState(!!startAtRoot)
|
|
1126
1132
|
const [ownBucket, setOwnBucket] = useState(bucket)
|
|
1127
1133
|
const bucketId = bucket ?? ownBucket
|
|
1128
1134
|
const lib = useBucketLibrary({ client, bucket: bucketId, defaults, settings: settingsProp, onSettingsChange, refreshKey })
|
|
@@ -1946,6 +1952,17 @@ export function MediaLibraryBrowse({
|
|
|
1946
1952
|
const ROOT = title
|
|
1947
1953
|
const label = bucketMeta.label || 'bucket'
|
|
1948
1954
|
const VROOT = single ? '' : `${ROOT}/${label}/`
|
|
1955
|
+
/* THE PICKER'S TILES AND COUNTS BY DEFAULT (user 2026-10-23, the Hub's Media on a phone beside kol-website's media app:
|
|
1956
|
+
* folders read bare, files drew a kind glyph). A consumer's `thumbnailFor` / `folderMeta` still win; without them an
|
|
1957
|
+
* image file shows itself (the client's URL, lazy) and a folder counts the files under it in the loaded listing. */
|
|
1958
|
+
const thumbOf = thumbnailFor ?? ((o) => (hasUrl && kindOf(o) === 'image'
|
|
1959
|
+
? <img src={mediaUrl(unroot(o.key))} alt="" loading="lazy" decoding="async" className="w-full h-full object-cover" />
|
|
1960
|
+
: null))
|
|
1961
|
+
const metaOf = folderMeta ?? ((path) => {
|
|
1962
|
+
const pre = unroot(path).replace(/\/?$/, '/')
|
|
1963
|
+
const n = objects.filter((o) => o.key.startsWith(pre) && !o.key.endsWith('/')).length
|
|
1964
|
+
return n ? `${n} item${n === 1 ? '' : 's'}` : ''
|
|
1965
|
+
})
|
|
1949
1966
|
const unroot = (p) => (VROOT && p.startsWith(VROOT) ? p.slice(VROOT.length) : p)
|
|
1950
1967
|
/* ONE LEVEL, ONE ANSWER. The column view merges the baked tree with the live partition inside its
|
|
1951
1968
|
* `partition` prop; the row view used the live partition alone and therefore disagreed with the
|
|
@@ -2074,8 +2091,8 @@ export function MediaLibraryBrowse({
|
|
|
2074
2091
|
kindLabel={KIND_LABEL}
|
|
2075
2092
|
formatSize={formatSize}
|
|
2076
2093
|
formatDate={formatDate}
|
|
2077
|
-
thumbnailFor={
|
|
2078
|
-
folderMeta={
|
|
2094
|
+
thumbnailFor={thumbOf}
|
|
2095
|
+
folderMeta={metaOf}
|
|
2079
2096
|
/* the PROP wins when a consumer passes one; otherwise the `···`
|
|
2080
2097
|
owns it through settings (item 15) */
|
|
2081
2098
|
stackView={stackView ?? settings.stackView ?? 'list'}
|
|
@@ -2192,7 +2209,7 @@ export function MediaLibraryBrowse({
|
|
|
2192
2209
|
onContextMenu={(e) => menu.openAt(e, { type: 'folder', path, targets: targetsFor(path) })}
|
|
2193
2210
|
drag={dragFor?.(path)}
|
|
2194
2211
|
dropFiles={dropFilesTo?.(path)}
|
|
2195
|
-
meta={
|
|
2212
|
+
meta={metaOf(path) || undefined}
|
|
2196
2213
|
cols={rowCols}
|
|
2197
2214
|
onToggle={() => toggleRow(path)}
|
|
2198
2215
|
onClick={(e) => { if (!selectRow(path, e, order)) rowPickFolder(path) }}
|
|
@@ -2205,14 +2222,14 @@ export function MediaLibraryBrowse({
|
|
|
2205
2222
|
onOpenFile={(o) => { const lvl = rowLevel(o.key.slice(0, o.key.lastIndexOf('/') + 1), treeObjects).files; openQuickLook({ files: lvl, index: Math.max(0, lvl.findIndex((f) => f.key === o.key)) }) }}
|
|
2206
2223
|
selectRow={selectRow} order={order} selectedKeys={rowSelection}
|
|
2207
2224
|
onRowContextMenu={(e, payload) => menu.openAt(e, payload)} dragFor={dragFor} dropFilesTo={dropFilesTo}
|
|
2208
|
-
formatDate={formatDate} folderMeta={
|
|
2225
|
+
formatDate={formatDate} folderMeta={metaOf} thumbnailFor={thumbOf} cols={rowCols}
|
|
2209
2226
|
pickedKey={pickedFolder ?? pickedFile?.key ?? null} currentKey={prefix}
|
|
2210
2227
|
/>}
|
|
2211
2228
|
</Fragment>
|
|
2212
2229
|
)
|
|
2213
2230
|
})}
|
|
2214
2231
|
{rowLevel('', treeObjects).files.map((o) => (
|
|
2215
|
-
<FileRow key={o.key} o={o} formatDate={formatDate} thumb={
|
|
2232
|
+
<FileRow key={o.key} o={o} formatDate={formatDate} thumb={thumbOf(o)} cols={rowCols}
|
|
2216
2233
|
selected={rowSelection.has(o.key) || pickedFile?.key === o.key}
|
|
2217
2234
|
onDoubleClick={() => { const lvl = rowLevel('', treeObjects).files; openQuickLook({ files: lvl, index: Math.max(0, lvl.findIndex((f) => f.key === o.key)) }) }}
|
|
2218
2235
|
onContextMenu={(e) => menu.openAt(e, { type: 'file', path: o.key, o, targets: targetsFor(o.key) })}
|
|
@@ -2694,8 +2711,15 @@ export function MediaLibraryBrowse({
|
|
|
2694
2711
|
)
|
|
2695
2712
|
}
|
|
2696
2713
|
const qlFile = onPickFile && target.type === 'file' ? objects.find((o) => o.key === target.path) : null
|
|
2714
|
+
const insFile = onInsert && target.type === 'file' ? (objects.find((o) => o.key === target.path) ?? target.o) : null
|
|
2697
2715
|
return (
|
|
2698
2716
|
<>
|
|
2717
|
+
{insFile && (!canInsert || canInsert(insFile)) && (
|
|
2718
|
+
<>
|
|
2719
|
+
<MenuDropdownItem iconLeft={<Icon name="plus" size={14} />} onClick={() => { onInsert(insFile); close() }}>Insert</MenuDropdownItem>
|
|
2720
|
+
<MenuDropdownDivider />
|
|
2721
|
+
</>
|
|
2722
|
+
)}
|
|
2699
2723
|
{/* A PICKER'S TAP SELECTS (`tapSelects`), so Quick Look needs a door of its own on a
|
|
2700
2724
|
* phone — the menu (kol-fxr 2026-10-08). Only with `onPickFile`; others are unchanged. */}
|
|
2701
2725
|
{qlFile && (
|
|
@@ -15,6 +15,7 @@ import useGrabEdge from '../hooks/useGrabEdge.js'
|
|
|
15
15
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
16
16
|
import Logomark from '../atoms/Logomark.jsx'
|
|
17
17
|
import { useRailSlot } from '../hooks/railSlot.jsx'
|
|
18
|
+
import { RAIL_ROW } from '../hooks/railRow.js'
|
|
18
19
|
import NavRailSite from './NavRailSite.jsx'
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -69,8 +70,19 @@ import NavRailSite from './NavRailSite.jsx'
|
|
|
69
70
|
* wrong — arriving on a route reveals nothing, by construction rather than by a
|
|
70
71
|
* flag a consumer has to remember.
|
|
71
72
|
*
|
|
73
|
+
* THE PRESETS (user 2026-10-24: *"the rail, do you make a preset for this? like catalog has preset?"*) — three rails, one
|
|
74
|
+
* name each, in `RAIL_PRESETS` below: `app` is the studio rail (this file's AppRail: the 48px rail that grabs open,
|
|
75
|
+
* sections ENTER and EXPAND, the pill on the phone, Media · Sign in · Settings at the foot); `site` is the brand rail
|
|
76
|
+
* (NavRailSite — brand.kolkrabbi.io); `workshop` is the workshop rail (kol-workshop's ShellSidebar, registered through
|
|
77
|
+
* `registerRailPreset` since kol-component cannot import kol-workshop). AppShell passes the preset and reads its phone
|
|
78
|
+
* shape; an app passes nothing else about the rail.
|
|
79
|
+
*
|
|
80
|
+
* THE WORDS (user 2026-10-24): a section ENTERS (its rows replace the list under a Back row) and EXITS (Back); a section
|
|
81
|
+
* EXPANDS (its rows open under it in place) and COLLAPSES. No other words, in code or docs.
|
|
82
|
+
*
|
|
83
|
+
* @param {'app'|'site'|'workshop'} preset which rail (default `app`); `variant="site"` is the old spelling of `preset="site"`
|
|
72
84
|
* @param {Array} items `{ icon, path, label, sub?: [{ icon?, path, label }] }`
|
|
73
|
-
* a section (`sub`) with `to` is a FOLDER NOTE: its icon and label open `to`, its chevron
|
|
85
|
+
* a section (`sub`) with `to` is a FOLDER NOTE: its icon and label open `to`, its chevron expands or enters
|
|
74
86
|
* @param {Array} bottomItems pinned below the rule (Settings)
|
|
75
87
|
* @param {Object} logomark `{ svgUrl, title }` — the mark, and the app name beside it when open
|
|
76
88
|
* @param {string} currentPath active match: '/' exact, else prefix → aria-current="page"
|
|
@@ -175,12 +187,8 @@ function useRailDrag(railRef, grabRef, onSnap, snapRef, enabled = true) {
|
|
|
175
187
|
/* one row: the rung exactly where the closed rail had it, then the label and
|
|
176
188
|
* (with `sub`) the chevron — the row clips to the rail's width */
|
|
177
189
|
/* the L2 glyph goes through the same injection seam Button gives L1 */
|
|
178
|
-
function IconAt({ name, size, component }) {
|
|
179
|
-
const Cmp = component || Icon
|
|
180
|
-
return <Cmp name={name} size={size} />
|
|
181
|
-
}
|
|
182
190
|
|
|
183
|
-
function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconComponent, railOpen, onOpenRail, onEnter }) {
|
|
191
|
+
function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconComponent, railOpen, onOpenRail, onEnter, depth = 0 }) {
|
|
184
192
|
const [open, setOpen] = useState(false)
|
|
185
193
|
/* A SECTION ROW IS NOT A DESTINATION (RailSectionPressOpensRail, kol-fxr
|
|
186
194
|
* 2026-08-30 — user: *"if I press effects from collapsed nav it should maybe
|
|
@@ -202,7 +210,7 @@ function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconCom
|
|
|
202
210
|
* section's name shut the nav and loaded nothing. */
|
|
203
211
|
/* FOLDER NOTE (2026-10-22, user: "like foldernote in obsidian where a parent/group/folder can
|
|
204
212
|
* also be a note"). Opt-in per section: give it `to` and its icon and label open that page,
|
|
205
|
-
* while the chevron alone
|
|
213
|
+
* while the chevron alone expands or enters — `RailSection`'s `to` split in kol-workshop. A
|
|
206
214
|
* section without `to` is unchanged. */
|
|
207
215
|
const press = () => {
|
|
208
216
|
if (isSection && to) { onNavigate?.(to); return }
|
|
@@ -214,16 +222,20 @@ function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconCom
|
|
|
214
222
|
const active = target === '/' ? currentPath === '/' : currentPath.startsWith(target)
|
|
215
223
|
return (
|
|
216
224
|
<>
|
|
217
|
-
|
|
225
|
+
{/* an expanded row is the SAME row as its parent — same glyph, same type, same ink — shifted so its icon starts on
|
|
226
|
+
* the parent's LABEL column (user 2026-10-23: *"same image size same text size but aligned to where the word LABS
|
|
227
|
+
* starts"*): the label sits 44px in (the 32px rung + the 12px gap) and the glyph 6px inside its rung, so one step is 38px — the child's glyph starts on the parent's label column */}
|
|
228
|
+
<div className="flex items-center gap-3 w-full overflow-hidden shrink-0" style={depth ? { paddingLeft: depth * 38 } : undefined}>
|
|
218
229
|
{/* the DS tooltip, not the browser's (the native-title sweep, 2026-09-26) — to the RIGHT,
|
|
219
230
|
* out over the page, since the collapsed rail's glyph is all there is to read */}
|
|
220
231
|
<Tooltip label={label} placement="right" triggerClassName="inline-flex shrink-0">
|
|
221
232
|
<Button
|
|
222
233
|
iconOnly={icon}
|
|
223
|
-
iconSize={
|
|
234
|
+
iconSize={RAIL_ROW.glyph}
|
|
224
235
|
iconComponent={iconComponent}
|
|
225
236
|
variant="nav"
|
|
226
|
-
|
|
237
|
+
/* an expanded row sits on the sm rung (26), the glyph and the type unchanged */
|
|
238
|
+
size={depth ? 'sm' : 'md'}
|
|
227
239
|
className="shrink-0"
|
|
228
240
|
/* nav ACTIVE keys off aria-current="page" (kol-components-atoms.css) —
|
|
229
241
|
* a brighter glyph, never the pressed fill */
|
|
@@ -237,7 +249,7 @@ function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconCom
|
|
|
237
249
|
/>
|
|
238
250
|
</Tooltip>
|
|
239
251
|
<span
|
|
240
|
-
className=
|
|
252
|
+
className={`${RAIL_ROW.label} text-oq-96 flex-1 min-w-0 truncate cursor-pointer`}
|
|
241
253
|
onClick={press}
|
|
242
254
|
>
|
|
243
255
|
{label}
|
|
@@ -261,39 +273,18 @@ function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconCom
|
|
|
261
273
|
</Tooltip>
|
|
262
274
|
)}
|
|
263
275
|
</div>
|
|
264
|
-
{
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
aria-current={on ? 'page' : undefined}
|
|
277
|
-
>
|
|
278
|
-
{s.icon && (
|
|
279
|
-
<span
|
|
280
|
-
className="w-5 h-5 shrink-0 inline-flex items-center justify-center"
|
|
281
|
-
style={{ color: on ? 'var(--kol-oq-96)' : 'var(--kol-oq-64)' }}
|
|
282
|
-
aria-hidden="true"
|
|
283
|
-
>
|
|
284
|
-
<IconAt name={s.icon} size={12} component={iconComponent} />
|
|
285
|
-
</span>
|
|
286
|
-
)}
|
|
287
|
-
<span
|
|
288
|
-
className="kol-helper-12 uppercase flex-1 min-w-0 truncate"
|
|
289
|
-
style={{ color: on ? 'var(--kol-oq-96)' : 'var(--kol-oq-64)' }}
|
|
290
|
-
>
|
|
291
|
-
{s.label}
|
|
292
|
-
</span>
|
|
293
|
-
</div>
|
|
294
|
-
</Tooltip>
|
|
295
|
-
)
|
|
296
|
-
})}
|
|
276
|
+
{/* EXPAND: the rows open under their section as FULL rows, one label column in (user 2026-10-23 — the 12px glyph,
|
|
277
|
+
* oq-64, 18px-gutter L2 row is retired: *"why are the sub items so small? low opacity?"*). An expanded row may expand
|
|
278
|
+
* again; it recurses. THE EXPANDED ROWS ARE A GROUP (user 2026-10-24: *"should the expanded list not be a little
|
|
279
|
+
* tighter? … I dont see that its a contained group"*): their own container, `.kol-rail-group`, the rows at the sm
|
|
280
|
+
* rung (26) with the same 20 glyph and type, on a 4px gap — against the top level's 32 rows on 8 */}
|
|
281
|
+
{railOpen && open && !onEnter && (
|
|
282
|
+
<div className="kol-rail-group flex w-full flex-col items-start gap-1">
|
|
283
|
+
{sub.map((s) => (
|
|
284
|
+
<RailItem key={s.path} {...s} depth={depth + 1} currentPath={currentPath} onNavigate={onNavigate} iconComponent={iconComponent} railOpen={railOpen} onOpenRail={onOpenRail} />
|
|
285
|
+
))}
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
297
288
|
</>
|
|
298
289
|
)
|
|
299
290
|
}
|
|
@@ -304,8 +295,21 @@ function RailItem({ icon, path, to, label, sub, currentPath, onNavigate, iconCom
|
|
|
304
295
|
* renders exactly as before — it takes SideNav's props (`navTree`, `isActive`, `background`,
|
|
305
296
|
* `currentPath`, `onNavigate(event, to)` …). kol-framework's `SideNav` is that variant under the
|
|
306
297
|
* old name, with react-router and the theme toggle wired in. */
|
|
307
|
-
|
|
308
|
-
|
|
298
|
+
/* THE PRESET TABLE — what each named rail is; AppShell reads `phone` for the bar's shape. `workshop` is registered. */
|
|
299
|
+
export const RAIL_PRESETS = {
|
|
300
|
+
app: { sections: 'enter', phone: 'pill', foot: ['media', 'signIn', 'settings'] },
|
|
301
|
+
site: { component: NavRailSite },
|
|
302
|
+
workshop: { component: null },
|
|
303
|
+
}
|
|
304
|
+
/* a package that owns a rail registers it under its name (kol-workshop → `workshop`); the name then renders here */
|
|
305
|
+
export function registerRailPreset(name, Component) { RAIL_PRESETS[name] = { ...(RAIL_PRESETS[name] ?? {}), component: Component } }
|
|
306
|
+
|
|
307
|
+
export default function NavRail({ variant, preset, ...props }) {
|
|
308
|
+
const name = preset ?? (variant === 'site' ? 'site' : 'app')
|
|
309
|
+
if (name === 'app') return <AppRail {...props} sections={props.sections ?? RAIL_PRESETS.app.sections} />
|
|
310
|
+
const Named = RAIL_PRESETS[name]?.component
|
|
311
|
+
if (!Named) { if (import.meta.env?.DEV) console.warn(`NavRail: no rail registered as preset "${name}"`); return null }
|
|
312
|
+
return <Named {...props} />
|
|
309
313
|
}
|
|
310
314
|
|
|
311
315
|
function AppRail({
|
|
@@ -318,17 +322,20 @@ function AppRail({
|
|
|
318
322
|
hidden = false,
|
|
319
323
|
drawer = false,
|
|
320
324
|
fade = true,
|
|
321
|
-
sections = '
|
|
325
|
+
sections = 'expand',
|
|
322
326
|
}) {
|
|
323
327
|
const railRef = useRef(null)
|
|
324
328
|
const grabRef = useRef(null)
|
|
325
329
|
const [railOpen, setRailOpen] = useState(false)
|
|
326
330
|
/* ENTER MODE (`sections="enter"`, 2026-10-06 — the user, on labs: "having a 'enter' mode in the
|
|
327
331
|
* left sidebar instead of collapse folder?"): pressing a section replaces the list with that
|
|
328
|
-
* section's rows under a Back row, instead of
|
|
329
|
-
* every rail had and keeps
|
|
330
|
-
*
|
|
331
|
-
|
|
332
|
+
* section's rows under a Back row, instead of expanding it in place. `expand` is the accordion
|
|
333
|
+
* every rail had and keeps (`fold` was its old spelling and still reads as `expand`).
|
|
334
|
+
* ONE RULE (user 2026-10-24: *"EFFECTS in LABS is supposed to COLLAPSE, thats the last step"*): a section whose rows
|
|
335
|
+
* hold sections of their own ENTERS; a section whose rows are leaves EXPANDS and COLLAPSES in place, its rows the
|
|
336
|
+
* expanded rows above. Chrome enters → Labs enters → Effects expands. `entered` is a PATH STACK; Back EXITS one level,
|
|
337
|
+
* the mark still goes home. */
|
|
338
|
+
const [entered, setEntered] = useState([])
|
|
332
339
|
const snapOpenRef = useRef(null)
|
|
333
340
|
const slotRef = useRef(null)
|
|
334
341
|
const ctx = useRailSlot()
|
|
@@ -342,11 +349,15 @@ function AppRail({
|
|
|
342
349
|
useGrabEdge(grabRef)
|
|
343
350
|
useRailDrag(railRef, grabRef, setRailOpen, snapOpenRef, !drawer)
|
|
344
351
|
if (hidden) return null
|
|
345
|
-
const enterMode = sections === 'enter'
|
|
346
|
-
const
|
|
352
|
+
const enterMode = (sections === 'fold' ? 'expand' : sections) === 'enter'
|
|
353
|
+
const enters = (item) => enterMode && !!item.sub?.some((s) => s.sub?.length > 0)
|
|
354
|
+
/* the entered sections, root first — a stale path (the items changed under it) ends the walk */
|
|
355
|
+
const trail = []
|
|
356
|
+
if (enterMode) for (const p of entered) { const next = (trail.at(-1)?.sub ?? items).find((i) => i.path === p); if (!next) break; trail.push(next) }
|
|
357
|
+
const section = trail.at(-1) ?? null
|
|
347
358
|
const row = (item) => (
|
|
348
359
|
<RailItem key={item.path} {...item} currentPath={currentPath} onNavigate={onNavigate} iconComponent={iconComponent} railOpen={drawer || railOpen} onOpenRail={() => snapOpenRef.current?.()}
|
|
349
|
-
onEnter={
|
|
360
|
+
onEnter={enters(item) ? () => setEntered([item.path]) : undefined} />
|
|
350
361
|
)
|
|
351
362
|
return (
|
|
352
363
|
<div
|
|
@@ -404,8 +415,9 @@ function AppRail({
|
|
|
404
415
|
<div style={ctx && slotOpen ? { flex: '0 1 auto' } : undefined} className={`kol-shell-rail-list flex min-h-0 w-full flex-1 flex-col items-start gap-2 overflow-y-auto overflow-x-hidden ${fade ? 'kol-shell-rail-list--fade' : ''}`.trim()}>
|
|
405
416
|
{section ? (
|
|
406
417
|
<>
|
|
407
|
-
<RailItem icon="arrow-left" path={section.path} label={section.label} currentPath="" onNavigate={() => setEntered(
|
|
408
|
-
{section.sub.map((s) => <RailItem key={s.path} {...s} currentPath={currentPath} onNavigate={onNavigate} iconComponent={iconComponent} railOpen={drawer || railOpen}
|
|
418
|
+
<RailItem icon="arrow-left" path={section.path} label={section.label} currentPath="" onNavigate={() => setEntered(trail.slice(0, -1).map((t) => t.path))} iconComponent={iconComponent} railOpen={drawer || railOpen} />
|
|
419
|
+
{section.sub.map((s) => <RailItem key={s.path} {...s} currentPath={currentPath} onNavigate={onNavigate} iconComponent={iconComponent} railOpen={drawer || railOpen}
|
|
420
|
+
onEnter={enters(s) ? () => setEntered([...trail.map((t) => t.path), s.path]) : undefined} />)}
|
|
409
421
|
</>
|
|
410
422
|
) : items.map(row)}
|
|
411
423
|
</div>
|