@kolkrabbi/kol-component 0.333.3 → 0.335.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/Badge.jsx +5 -1
- package/src/atoms/Button.jsx +15 -2
- package/src/atoms/Delta.jsx +27 -0
- package/src/atoms/Input.jsx +18 -1
- package/src/atoms/LiveDot.jsx +19 -0
- package/src/atoms/Pill.jsx +3 -1
- package/src/atoms/ProgressBar.jsx +7 -4
- package/src/atoms/SectionLabel.jsx +29 -0
- package/src/atoms/SegmentedToggle.jsx +4 -1
- package/src/atoms/SizeChip.jsx +24 -0
- package/src/atoms/Tag.jsx +9 -3
- package/src/atoms/Textarea.jsx +5 -1
- package/src/atoms/ToggleCheckbox.jsx +7 -4
- package/src/atoms/ToggleSwitch.jsx +7 -2
- package/src/atoms/ValueField.jsx +24 -0
- package/src/atoms/ViewToggle.jsx +27 -0
- package/src/index.js +24 -0
- package/src/molecules/AccountMenu.jsx +27 -0
- package/src/molecules/ColorField.jsx +30 -0
- package/src/molecules/ContentRow.jsx +30 -1
- package/src/molecules/ContextMenu.jsx +3 -2
- package/src/molecules/DocsToc.jsx +16 -1
- package/src/molecules/Dropdown.jsx +15 -4
- package/src/molecules/EmptyState.jsx +15 -1
- package/src/molecules/FieldPair.jsx +21 -0
- package/src/molecules/FlyoutRow.jsx +10 -0
- package/src/molecules/IndexRow.jsx +37 -0
- package/src/molecules/InlineAddRow.jsx +38 -0
- package/src/molecules/LabeledControl.jsx +6 -2
- package/src/molecules/LayerRow.jsx +53 -0
- package/src/molecules/LinkAddRow.jsx +52 -0
- package/src/molecules/Menu.jsx +46 -24
- package/src/molecules/MenuItem.jsx +8 -3
- package/src/molecules/Modal.jsx +58 -19
- package/src/molecules/NoticeBanner.jsx +28 -0
- package/src/molecules/PanelsMenu.jsx +34 -0
- package/src/molecules/PasswordInput.jsx +38 -0
- package/src/molecules/QuantityInput.jsx +17 -0
- package/src/molecules/QuickLookFrame.jsx +31 -27
- package/src/molecules/QuickLookHeader.jsx +60 -0
- package/src/molecules/SearchInput.jsx +5 -4
- package/src/molecules/SectionText.jsx +15 -1
- package/src/molecules/Slider.jsx +26 -1
- package/src/molecules/SpecList.jsx +21 -1
- package/src/molecules/SummaryLine.jsx +18 -0
- package/src/molecules/TabsRow.jsx +54 -7
- package/src/molecules/TaskRow.jsx +43 -0
- package/src/molecules/TocRow.jsx +29 -0
- package/src/molecules/TreeRow.jsx +72 -0
- package/src/molecules/WorkspaceSwitcher.jsx +24 -0
- package/src/organisms/ContentFilters.jsx +12 -4
- package/src/organisms/MediaLibrary.jsx +55 -0
- package/src/organisms/NavDrawer.jsx +67 -0
- package/src/organisms/NavRail.jsx +4 -1
- package/src/organisms/NavRailFloat.jsx +110 -0
- package/src/organisms/Table.jsx +50 -1
|
@@ -6,6 +6,7 @@ import Divider from '../atoms/Divider.jsx'
|
|
|
6
6
|
import Dropdown from '../molecules/Dropdown.jsx'
|
|
7
7
|
import Input from '../atoms/Input.jsx'
|
|
8
8
|
import ViewToggle from '../atoms/ViewToggle.jsx'
|
|
9
|
+
import SearchInput from '../molecules/SearchInput.jsx'
|
|
9
10
|
import FullscreenOverlay from '../utilities/FullscreenOverlay.jsx'
|
|
10
11
|
import { Tooltip } from '../utilities/Popover.jsx'
|
|
11
12
|
import MediaTile from '../molecules/MediaTile.jsx'
|
|
@@ -1049,6 +1050,14 @@ function PickerShell({ onClose, onPick }) {
|
|
|
1049
1050
|
* @param {boolean} flat start in flat mode
|
|
1050
1051
|
* @param {Function} onClose modal only — Esc, backdrop, close button
|
|
1051
1052
|
* @param {Function} onSelect `(url, { contentType, kind })`. In `modal` it also closes.
|
|
1053
|
+
*
|
|
1054
|
+
* `float` (float-everything W6 row 87, 2026-11-04 — kol-float--style 46:2960): the asset window — a 310 float panel,
|
|
1055
|
+
* non-modal (no scrim, the scene stays live), `kol-float-solid` on the sheet radius, 20 in. The title in
|
|
1056
|
+
* `kol-float-window` with the × · a float SearchInput · the files as rows (a 44 × 54 cover on 6, the name in Inter 13,
|
|
1057
|
+
* `ext · size` in mono 10, a check on the picked one) — a press picks (`onSelect`) · `onImport` draws `+ Import`
|
|
1058
|
+
* (a float button, secondary) beside the count. Same `open` · `client` · `accept` · `onClose` · `onSelect` as `modal`.
|
|
1059
|
+
* @param {string} title float: the window's title (default `Assets`)
|
|
1060
|
+
* @param {Function} onImport float: shows the import button · {string} importLabel (default `Import`)
|
|
1052
1061
|
*/
|
|
1053
1062
|
export default function MediaLibrary({
|
|
1054
1063
|
variant = 'page',
|
|
@@ -1063,6 +1072,7 @@ export default function MediaLibrary({
|
|
|
1063
1072
|
...pageProps
|
|
1064
1073
|
}) {
|
|
1065
1074
|
const opts = { client, accept, pageSize, defaultSort, flat }
|
|
1075
|
+
if (variant === 'float') return open ? withProvider(<FloatPicker onClose={onClose} onPick={onSelect} {...pageProps} />, opts) : null
|
|
1066
1076
|
if (variant === 'modal') {
|
|
1067
1077
|
if (!open) return null
|
|
1068
1078
|
return withProvider(<PickerShell onClose={onClose} onPick={onSelect} />, opts)
|
|
@@ -1139,6 +1149,51 @@ function PickerBrowse({ client, accept, onClose, onSelect, title = 'MEDIA', ...b
|
|
|
1139
1149
|
)
|
|
1140
1150
|
}
|
|
1141
1151
|
|
|
1152
|
+
/* THE ASSET WINDOW (`variant="float"`, W6 row 87) — read-only, a picker: rows from the provider, the search its own */
|
|
1153
|
+
function FloatPicker({ onClose, onPick, onImport, importLabel = 'Import', title = 'Assets', className = '' }) {
|
|
1154
|
+
const { sorted, search, setSearch, mediaUrl, loading, error } = useMediaLibrary()
|
|
1155
|
+
const [picked, setPicked] = useState(null)
|
|
1156
|
+
const files = sorted.filter((o) => o.type !== 'folder')
|
|
1157
|
+
const pick = (o) => { setPicked(o.key); onPick?.(mediaUrl(o.fullKey ?? o.key), { contentType: o.contentType, kind: o.kind }) }
|
|
1158
|
+
return (
|
|
1159
|
+
<section role="dialog" aria-label={title} className={`kol-float-solid flex w-[310px] max-w-full flex-col gap-4 rounded-[var(--kol-float-menu-r)] p-5 ${className}`.trim()}>
|
|
1160
|
+
<div className="flex items-center gap-3">
|
|
1161
|
+
<span className="kol-float-window min-w-0 flex-1 truncate text-fg-emphasis">{title}</span>
|
|
1162
|
+
{onClose && (
|
|
1163
|
+
<button type="button" aria-label="Close" onClick={onClose} className="inline-flex size-6 shrink-0 items-center justify-center rounded-full text-oq-64 hover:bg-fg-08 hover:text-oq-96 cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
|
|
1164
|
+
<Icon name="x" size={16} />
|
|
1165
|
+
</button>
|
|
1166
|
+
)}
|
|
1167
|
+
</div>
|
|
1168
|
+
<SearchInput variant="float" value={search ?? ''} onChange={(e) => setSearch(e.target.value)} placeholder="Search assets…" />
|
|
1169
|
+
<ul className="m-0 flex max-h-[320px] list-none flex-col gap-1 overflow-y-auto p-0 [scrollbar-width:none]">
|
|
1170
|
+
{error && <li className="kol-float-hint text-ui-error">Couldn’t load: {error}</li>}
|
|
1171
|
+
{!error && loading && <li className="kol-float-hint text-fg-64">Loading…</li>}
|
|
1172
|
+
{!error && !loading && files.length === 0 && <li className="kol-float-hint text-fg-64">Nothing here.</li>}
|
|
1173
|
+
{files.map((o) => (
|
|
1174
|
+
<li key={o.key}>
|
|
1175
|
+
<button type="button" onClick={() => pick(o)} aria-pressed={picked === o.key}
|
|
1176
|
+
className={`flex w-full items-center gap-3 rounded-[var(--kol-float-list-r)] p-1 text-left cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)] ${picked === o.key ? 'bg-fg-16' : 'hover:bg-fg-08'}`}>
|
|
1177
|
+
<span className="h-[54px] w-11 shrink-0 overflow-hidden rounded-md bg-fg-08"><Thumb row={o} mediaUrl={mediaUrl} /></span>
|
|
1178
|
+
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
1179
|
+
<span className="kol-float-hint truncate text-fg-emphasis" style={{ fontSize: 13 }}>{o.displayKey}</span>
|
|
1180
|
+
<span className="kol-float-ruler truncate uppercase text-fg-64">{[o.key.split('.').pop(), formatSize(o.size)].filter(Boolean).join(' · ')}</span>
|
|
1181
|
+
</span>
|
|
1182
|
+
{picked === o.key && <Icon name="check" size={14} className="mr-2 shrink-0 text-oq-96" />}
|
|
1183
|
+
</button>
|
|
1184
|
+
</li>
|
|
1185
|
+
))}
|
|
1186
|
+
</ul>
|
|
1187
|
+
{(onImport || files.length > 0) && (
|
|
1188
|
+
<div className="flex items-center gap-3">
|
|
1189
|
+
{onImport && <Button variant="float" tone="secondary" size="md" iconLeft="plus" onClick={onImport}>{importLabel}</Button>}
|
|
1190
|
+
<span className="kol-float-label text-fg-64">{files.length} {files.length === 1 ? 'asset' : 'assets'}</span>
|
|
1191
|
+
</div>
|
|
1192
|
+
)}
|
|
1193
|
+
</section>
|
|
1194
|
+
)
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1142
1197
|
/** @deprecated 2026-08-01 — alias of `MediaLibrary variant="modal"`. Kept so
|
|
1143
1198
|
* existing call sites and the fxr editor's `onPick` naming keep working;
|
|
1144
1199
|
* drops when nobody imports it (04-retirements.md). */
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import { Icon } from '@kolkrabbi/kol-icons'
|
|
3
|
+
import TreeRow from '../molecules/TreeRow.jsx'
|
|
4
|
+
|
|
5
|
+
/* taxonomy-ok: organism — nests TreeRow (molecule) + kol-icons's Icon. */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* NavDrawer — The hidden nav, called up on demand. (float-everything W6 row 94, 2026-11-04 — kol-float--style 46:3115.)
|
|
9
|
+
* When the sidebar is hidden (kol-shell's RailTrigger), this is what the trigger opens: a 280 float overlay on the
|
|
10
|
+
* sheet radius, `kol-float-solid`, 16 in, over the page at its top-left — no scrim, it is not a blocking task. The
|
|
11
|
+
* title (`kol-float-body`) and × on one row; the tree under it — `TreeRow size="md"` for a destination, its `sub` rows
|
|
12
|
+
* `TreeRow size="xs"` (26) indented beneath; `footer` at the foot (`All pages ↓`). Escape and the × close it; picking
|
|
13
|
+
* a row navigates and closes it.
|
|
14
|
+
*
|
|
15
|
+
* @param {boolean} open · {Function} onClose
|
|
16
|
+
* @param {string} [title]
|
|
17
|
+
* @param {Array} items `{ icon, label, path, count?, sub?: [...] }` (a `{ heading }` draws a section label)
|
|
18
|
+
* @param {string} [currentPath]
|
|
19
|
+
* @param {Function} [onNavigate] `(path) => void`
|
|
20
|
+
* @param {Array} [defaultExpanded] sections open on open; default — the section holding `currentPath`
|
|
21
|
+
* @param {ReactNode} [footer]
|
|
22
|
+
* @param {boolean} [fixed=true] false renders it in flow (a preview, a story)
|
|
23
|
+
*/
|
|
24
|
+
export default function NavDrawer({ open, onClose, title, items = [], currentPath = '', onNavigate, defaultExpanded, footer, fixed = true, className = '' }) {
|
|
25
|
+
const here = items.filter((it) => it.sub?.some((c) => c.path === currentPath)).map((it) => it.path)
|
|
26
|
+
const [expanded, setExpanded] = useState(() => new Set(defaultExpanded ?? here))
|
|
27
|
+
const toggle = (p) => setExpanded((s) => { const n = new Set(s); n.has(p) ? n.delete(p) : n.add(p); return n })
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!open) return undefined
|
|
30
|
+
const onKey = (e) => { if (e.key === 'Escape') onClose?.() }
|
|
31
|
+
window.addEventListener('keydown', onKey)
|
|
32
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
33
|
+
}, [open, onClose])
|
|
34
|
+
if (!open) return null
|
|
35
|
+
const go = (p) => () => { onNavigate?.(p); onClose?.() }
|
|
36
|
+
return (
|
|
37
|
+
<nav aria-label={title ?? 'Navigation'}
|
|
38
|
+
className={`kol-float-solid flex max-h-[calc(100dvh-32px)] w-[280px] flex-col gap-3 rounded-[var(--kol-float-menu-r)] p-4 ${fixed ? 'fixed left-4 top-4 z-[var(--kol-z-overlay)]' : ''} ${className}`.trim()}>
|
|
39
|
+
<div className="flex items-center gap-3 pl-1">
|
|
40
|
+
<span className="kol-float-body min-w-0 flex-1 truncate text-fg-emphasis">{title}</span>
|
|
41
|
+
{onClose && (
|
|
42
|
+
<button type="button" aria-label="Close" onClick={onClose} className="inline-flex size-6 shrink-0 items-center justify-center rounded-full text-oq-64 hover:bg-fg-08 hover:text-oq-96 cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
|
|
43
|
+
<Icon name="x" size={16} />
|
|
44
|
+
</button>
|
|
45
|
+
)}
|
|
46
|
+
</div>
|
|
47
|
+
<div className="flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto [scrollbar-width:none]">
|
|
48
|
+
{items.map((it, i) => {
|
|
49
|
+
if (it.heading) return <span key={`h${i}`} className="kol-float-ruler px-2.5 pb-1 pt-3 text-fg-64">{it.heading}</span>
|
|
50
|
+
const kids = it.sub ?? []
|
|
51
|
+
const isOpen = expanded.has(it.path)
|
|
52
|
+
return (
|
|
53
|
+
<div key={it.path ?? it.label} className="flex flex-col gap-0.5">
|
|
54
|
+
<TreeRow size="md" icon={it.icon} label={it.label} count={it.count}
|
|
55
|
+
active={it.path === currentPath} open={isOpen && kids.some((c) => c.path === currentPath)}
|
|
56
|
+
onClick={kids.length ? () => toggle(it.path) : go(it.path)} aria-expanded={kids.length ? isOpen : undefined} />
|
|
57
|
+
{isOpen && kids.map((c) => (
|
|
58
|
+
<TreeRow key={c.path} size="xs" depth={1} icon={c.icon} label={c.label} count={c.count} active={c.path === currentPath} onClick={go(c.path)} />
|
|
59
|
+
))}
|
|
60
|
+
</div>
|
|
61
|
+
)
|
|
62
|
+
})}
|
|
63
|
+
</div>
|
|
64
|
+
{footer && <div className="shrink-0 pl-1">{footer}</div>}
|
|
65
|
+
</nav>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -18,6 +18,7 @@ import VectorLoader from '../atoms/VectorLoader.jsx'
|
|
|
18
18
|
import { useRailSlot } from '../hooks/railSlot.jsx'
|
|
19
19
|
import { RAIL_ROW } from '../hooks/railRow.js'
|
|
20
20
|
import NavRailSite from './NavRailSite.jsx'
|
|
21
|
+
import NavRailFloat from './NavRailFloat.jsx'
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* NavRail — the flat rail. ONE fixed column, every child a direct child of it
|
|
@@ -82,7 +83,8 @@ import NavRailSite from './NavRailSite.jsx'
|
|
|
82
83
|
* EXPANDS (its rows open under it in place) and COLLAPSES. No other words, in code or docs.
|
|
83
84
|
*
|
|
84
85
|
* @param {'app'|'site'|'workshop'} preset which rail (default `app`); `variant="site"` is the old spelling of `preset="site"`
|
|
85
|
-
* @param {'top'} variant `top` — the horizontal top rail (TopRail): logomark · items · `actions` (the right slot)
|
|
86
|
+
* @param {'top'|'float'} variant `top` — the horizontal top rail (TopRail): logomark · items · `actions` (the right slot);
|
|
87
|
+
* `float` — the float sidebar, expanded 280 · collapsed 72 (NavRailFloat.jsx, float-everything W9 rows 127 · 128)
|
|
86
88
|
* @param {Array} items `{ icon, path, label, sub?: [{ icon?, path, label }] }`
|
|
87
89
|
* a section (`sub`) with `to` is a FOLDER NOTE: its icon and label open `to`, its chevron expands or enters
|
|
88
90
|
* @param {Array} bottomItems pinned below the rule (Settings)
|
|
@@ -323,6 +325,7 @@ export function registerRailPreset(name, Component) { RAIL_PRESETS[name] = { ...
|
|
|
323
325
|
|
|
324
326
|
export default function NavRail({ variant, preset, ...props }) {
|
|
325
327
|
if (variant === 'top') return <TopRail {...props} />
|
|
328
|
+
if (variant === 'float') return <NavRailFloat {...props} />
|
|
326
329
|
const name = preset ?? (variant === 'site' ? 'site' : 'app')
|
|
327
330
|
if (name === 'app') return <AppRail {...props} sections={props.sections ?? RAIL_PRESETS.app.sections} />
|
|
328
331
|
const Named = RAIL_PRESETS[name]?.component
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Icon } from '@kolkrabbi/kol-icons'
|
|
3
|
+
import Kbd from '../atoms/Kbd.jsx'
|
|
4
|
+
import TreeRow from '../molecules/TreeRow.jsx'
|
|
5
|
+
import { Tooltip } from '../utilities/Popover.jsx'
|
|
6
|
+
|
|
7
|
+
/* taxonomy-ok: organism — nests TreeRow (molecule) + Kbd (atom) + Tooltip (utility) + kol-icons's Icon. */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* NavRailFloat — the float sidebar, `NavRail variant="float"` (float-everything W9 rows 122 · 127 · 128 · 131,
|
|
11
|
+
* 2026-11-04 — kol-float--style 48:4015 expanded, 48:4277 rail). Its own path: none of the app rail's grab, drag or
|
|
12
|
+
* width token. Two states, the rail's words — EXPANDED (280) and COLLAPSED (72):
|
|
13
|
+
*
|
|
14
|
+
* expanded the switcher row (glyph · title · ⌄, or your `switcher`) · the search capsule (`Search pages ⌘K`) · the
|
|
15
|
+
* tree: a `{ heading }` entry is a section label (`kol-float-ruler`, fg-64, as authored), an item a
|
|
16
|
+
* `TreeRow size="lg"` (40 · 18 glyph · Inter 13 · count · chevron), its `sub` rows `TreeRow size="sm"`
|
|
17
|
+
* indented under it · `footer` at the foot (kol-shell's RailDisplayControls, a theme row)
|
|
18
|
+
* collapsed 44 round slots on a 72 rail, 20 glyphs; the lit slot fg-16 with a 3 × 14 bar at the rail's edge — a
|
|
19
|
+
* section with the current page inside lights too; a heading becomes a 16 gap. Expand on top and search ·
|
|
20
|
+
* hide at the foot, on the well. Each slot names itself in the float Tooltip
|
|
21
|
+
*
|
|
22
|
+
* On `surface-secondary` at the sheet radius, 12 in, full height of its container. Nothing auto-expands: a section
|
|
23
|
+
* opens by its chevron, or by `defaultExpanded`.
|
|
24
|
+
*
|
|
25
|
+
* @param {Array} items `{ heading }` | `{ icon, label, path, count?, sub?: [{ icon, label, path, count? }] }`
|
|
26
|
+
* @param {string} currentPath the active path (exact match)
|
|
27
|
+
* @param {Function} onNavigate `(path) => void`
|
|
28
|
+
* @param {boolean} [collapsed] the 72 rail · {Function} [onCollapsedChange]
|
|
29
|
+
* @param {string} [title] · {string} [icon='grid'] · {Function} [onSwitch] the switcher row; `switcher` replaces it
|
|
30
|
+
* @param {Function} [onSearch] shows the search capsule (and the rail's search slot)
|
|
31
|
+
* @param {Function} [onHide] the rail's hide slot (expanded: put kol-shell's RailDisplayControls in `footer`)
|
|
32
|
+
* @param {Array} [defaultExpanded] paths of sections open at mount
|
|
33
|
+
* @param {ReactNode} [footer]
|
|
34
|
+
*/
|
|
35
|
+
const isOn = (path, current) => !!path && path === current
|
|
36
|
+
|
|
37
|
+
export default function NavRailFloat({ items = [], currentPath = '', onNavigate, collapsed = false, onCollapsedChange, title, icon = 'grid', onSwitch, switcher, onSearch, onHide, defaultExpanded = [], footer, className = '' }) {
|
|
38
|
+
const [open, setOpen] = useState(() => new Set(defaultExpanded))
|
|
39
|
+
const toggle = (path) => setOpen((s) => { const n = new Set(s); n.has(path) ? n.delete(path) : n.add(path); return n })
|
|
40
|
+
const go = (path) => () => onNavigate?.(path)
|
|
41
|
+
|
|
42
|
+
if (collapsed) {
|
|
43
|
+
const slot = (key, label, glyph, { on = false, well = false, onClick } = {}) => (
|
|
44
|
+
<Tooltip key={key} label={label} placement="right" variant="float" asChild>
|
|
45
|
+
<button type="button" aria-label={label} aria-current={on ? 'page' : undefined} onClick={onClick}
|
|
46
|
+
className={`relative inline-flex size-11 shrink-0 items-center justify-center rounded-full cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)] ${on ? 'bg-fg-16 text-oq-96' : well ? 'bg-[var(--kol-float-well)] text-oq-64 hover:text-oq-96' : 'text-oq-64 hover:bg-fg-08 hover:text-oq-96'}`}>
|
|
47
|
+
<Icon name={glyph} size={well ? 18 : 20} />
|
|
48
|
+
</button>
|
|
49
|
+
</Tooltip>
|
|
50
|
+
)
|
|
51
|
+
return (
|
|
52
|
+
<nav aria-label="Navigation" className={`flex h-full w-[72px] flex-col items-center gap-1 rounded-[var(--kol-float-menu-r)] bg-surface-secondary py-3.5 ${className}`.trim()}>
|
|
53
|
+
{onCollapsedChange && slot('expand', 'Expand', 'panel-left', { well: true, onClick: () => onCollapsedChange(false) })}
|
|
54
|
+
<div className="flex min-h-0 w-full flex-1 flex-col items-center gap-1 overflow-y-auto py-3 [scrollbar-width:none]">
|
|
55
|
+
{items.map((it, i) => {
|
|
56
|
+
if (it.heading) return i === 0 ? null : <span key={`h${i}`} className="h-4 shrink-0" aria-hidden />
|
|
57
|
+
const on = isOn(it.path, currentPath) || !!it.sub?.some((c) => isOn(c.path, currentPath))
|
|
58
|
+
return (
|
|
59
|
+
<span key={it.path ?? it.label} className="relative flex w-full justify-center">
|
|
60
|
+
{on && <span className="absolute left-[5px] top-1/2 h-3.5 w-[3px] -translate-y-1/2 rounded-full bg-[var(--kol-surface-on-primary)]" aria-hidden />}
|
|
61
|
+
{slot(it.path ?? it.label, it.label, it.icon, { on, onClick: go(it.path) })}
|
|
62
|
+
</span>
|
|
63
|
+
)
|
|
64
|
+
})}
|
|
65
|
+
</div>
|
|
66
|
+
{onSearch && slot('search', 'Search pages', 'search', { well: true, onClick: onSearch })}
|
|
67
|
+
{onHide && slot('hide', 'Hide', 'hamburger', { well: true, onClick: onHide })}
|
|
68
|
+
</nav>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<nav aria-label="Navigation" className={`flex h-full w-[280px] flex-col gap-3 rounded-[var(--kol-float-menu-r)] bg-surface-secondary p-3 ${className}`.trim()}>
|
|
74
|
+
{switcher ?? (title && (
|
|
75
|
+
<button type="button" onClick={onSwitch} className="flex h-10 w-full items-center gap-2.5 rounded-[var(--kol-float-list-r)] px-2.5 text-left cursor-pointer hover:bg-fg-08 focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
|
|
76
|
+
<Icon name={icon} size={18} className="shrink-0 text-oq-96" />
|
|
77
|
+
<span className="kol-float-body-lg min-w-0 flex-1 truncate text-fg-emphasis">{title}</span>
|
|
78
|
+
{onSwitch && <Icon name="chevron-down" size={14} className="shrink-0 text-oq-64" />}
|
|
79
|
+
</button>
|
|
80
|
+
))}
|
|
81
|
+
{onSearch && (
|
|
82
|
+
<button type="button" onClick={onSearch} className="flex h-[var(--kol-float-h-md)] w-full items-center gap-2.5 rounded-full bg-[var(--kol-float-well)] pl-3 pr-2 text-left cursor-pointer hover:bg-fg-08 focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
|
|
83
|
+
<Icon name="search" size={16} className="shrink-0 text-oq-64" />
|
|
84
|
+
<span className="kol-float-hint min-w-0 flex-1 truncate text-fg-64">Search pages</span>
|
|
85
|
+
<Kbd size="sm" icon="command">K</Kbd>
|
|
86
|
+
</button>
|
|
87
|
+
)}
|
|
88
|
+
<div className="flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto [scrollbar-width:none]">
|
|
89
|
+
{items.map((it, i) => {
|
|
90
|
+
if (it.heading) return <span key={`h${i}`} className={`kol-float-ruler px-2.5 pb-1 text-fg-64 ${i === 0 ? 'pt-1' : 'pt-4'}`}>{it.heading}</span>
|
|
91
|
+
const kids = it.sub ?? []
|
|
92
|
+
const isOpen = open.has(it.path)
|
|
93
|
+
const childOn = kids.some((c) => isOn(c.path, currentPath))
|
|
94
|
+
return (
|
|
95
|
+
<div key={it.path ?? it.label} className="flex flex-col gap-0.5">
|
|
96
|
+
<TreeRow size="lg" icon={it.icon} label={it.label} count={it.count}
|
|
97
|
+
active={isOn(it.path, currentPath)} open={childOn && isOpen}
|
|
98
|
+
expanded={kids.length ? isOpen : undefined} onToggle={kids.length ? () => toggle(it.path) : undefined}
|
|
99
|
+
onClick={kids.length && !it.to ? () => toggle(it.path) : go(it.to ?? it.path)} />
|
|
100
|
+
{isOpen && kids.map((c) => (
|
|
101
|
+
<TreeRow key={c.path} size="sm" depth={1} icon={c.icon} label={c.label} count={c.count} active={isOn(c.path, currentPath)} onClick={go(c.path)} />
|
|
102
|
+
))}
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
105
|
+
})}
|
|
106
|
+
</div>
|
|
107
|
+
{footer && <div className="flex shrink-0 flex-col gap-2">{footer}</div>}
|
|
108
|
+
</nav>
|
|
109
|
+
)
|
|
110
|
+
}
|
package/src/organisms/Table.jsx
CHANGED
|
@@ -17,6 +17,15 @@ import { INDICATOR } from '../hooks/glyphLadders.js'
|
|
|
17
17
|
* sorts itself needs no state from the page. Pass `sortValue(row)` when the
|
|
18
18
|
* rendered cell is not what should be compared (a chip, a link, a date
|
|
19
19
|
* string).
|
|
20
|
+
*
|
|
21
|
+
* FLOAT (`variant="float"`, float-everything W8 rows 115 · 116, 2026-11-04 — kol-float--style 48:2780 analytics,
|
|
22
|
+
* 48:3257 catalog): its own render, none of `.kol-table`'s rules. The head in mono (`kol-float-ruler`, 10, uppercase
|
|
23
|
+
* by the table's role) on the emphasis ink; body cells in `kol-float-timecode` (mono 12) on fg-64, or the float sans
|
|
24
|
+
* (`kol-float-hint`) for a column with `sans: true`; 12 · 16 in a cell, no rules between rows (the no-borders law —
|
|
25
|
+
* rows lift fg-08 under the pointer instead). `align: 'right'` right-aligns a column (the numbers, the share). A cell's
|
|
26
|
+
* `render` draws covers and status pills (`Pill variant="float"`) — the catalog's cover · title · status row.
|
|
27
|
+
* `framed` sets it on a sheet (surface-secondary on `--kol-float-menu-r`, 8 in) — the catalog; unframed it sits on
|
|
28
|
+
* whatever float holds it — the analytics card.
|
|
20
29
|
*/
|
|
21
30
|
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' })
|
|
22
31
|
|
|
@@ -33,7 +42,7 @@ const WIDTHS = {
|
|
|
33
42
|
column: '',
|
|
34
43
|
}
|
|
35
44
|
|
|
36
|
-
const Table = ({ caption, columns, rows, variant = 'default', className = '', width = 'panel', rowClassName, compact = false, lastRule = false }) => {
|
|
45
|
+
const Table = ({ caption, columns, rows, variant = 'default', className = '', width = 'panel', rowClassName, compact = false, lastRule = false, framed = false }) => {
|
|
37
46
|
const [sort, setSort] = useState({ key: null, dir: null })
|
|
38
47
|
|
|
39
48
|
const cycle = (key) =>
|
|
@@ -55,6 +64,8 @@ const Table = ({ caption, columns, rows, variant = 'default', className = '', wi
|
|
|
55
64
|
})
|
|
56
65
|
}, [rows, columns, sort])
|
|
57
66
|
|
|
67
|
+
if (variant === 'float') return <FloatTable caption={caption} columns={columns} rows={sorted} sort={sort} cycle={cycle} framed={framed} rowClassName={rowClassName} className={`${WIDTHS[width] ?? WIDTHS.panel} ${className}`.trim()} />
|
|
68
|
+
|
|
58
69
|
const variantClass = variant === 'simple' ? 'kol-table--simple' : ''
|
|
59
70
|
/* compact — record-surface density (RecordManager, 2026-08-09): the default
|
|
60
71
|
* 12/16 cell box read as bloated rows against the reference table. */
|
|
@@ -113,4 +124,42 @@ const Table = ({ caption, columns, rows, variant = 'default', className = '', wi
|
|
|
113
124
|
)
|
|
114
125
|
}
|
|
115
126
|
|
|
127
|
+
function FloatTable({ caption, columns, rows, sort, cycle, framed, rowClassName, className }) {
|
|
128
|
+
const align = (c) => (c.align === 'right' ? 'text-right' : 'text-left')
|
|
129
|
+
return (
|
|
130
|
+
<div className={`w-full overflow-x-auto ${framed ? 'rounded-[var(--kol-float-menu-r)] bg-surface-secondary p-2' : ''} ${className}`.trim()}>
|
|
131
|
+
<table className="w-full border-collapse">
|
|
132
|
+
{caption ? <caption className="sr-only">{caption}</caption> : null}
|
|
133
|
+
<thead>
|
|
134
|
+
<tr>
|
|
135
|
+
{columns.map((c) => (
|
|
136
|
+
<th key={c.accessor} scope="col" style={c.style} className={`kol-float-ruler whitespace-nowrap px-4 py-3 font-normal uppercase text-fg-emphasis first:pl-3 ${align(c)}`}
|
|
137
|
+
aria-sort={sort.key === c.accessor ? (sort.dir === 'asc' ? 'ascending' : 'descending') : undefined}>
|
|
138
|
+
{c.sortable ? (
|
|
139
|
+
<button type="button" onClick={() => cycle(c.accessor)} className="inline-flex items-center gap-1 uppercase cursor-pointer">
|
|
140
|
+
{c.header}
|
|
141
|
+
<Icon name={sort.key === c.accessor && sort.dir === 'desc' ? 'arrow-down' : 'arrow-up'} size={10} className={sort.key === c.accessor ? 'text-oq-96' : 'opacity-0'} />
|
|
142
|
+
</button>
|
|
143
|
+
) : c.header}
|
|
144
|
+
</th>
|
|
145
|
+
))}
|
|
146
|
+
</tr>
|
|
147
|
+
</thead>
|
|
148
|
+
<tbody>
|
|
149
|
+
{rows.map((row, i) => (
|
|
150
|
+
<tr key={row.id ?? row.token ?? i} className={`group${rowClassName ? ` ${rowClassName(row, i)}` : ''}`}>
|
|
151
|
+
{columns.map((c) => (
|
|
152
|
+
<td key={c.accessor} style={c.style}
|
|
153
|
+
className={`${c.sans ? 'kol-float-hint' : 'kol-float-timecode'} whitespace-nowrap px-4 py-3 text-fg-64 group-hover:bg-fg-08 group-hover:text-fg-emphasis first:rounded-l-[var(--kol-float-list-r)] first:pl-3 last:rounded-r-[var(--kol-float-list-r)] ${align(c)}`}>
|
|
154
|
+
{c.render ? c.render(row) : row[c.accessor] ?? '—'}
|
|
155
|
+
</td>
|
|
156
|
+
))}
|
|
157
|
+
</tr>
|
|
158
|
+
))}
|
|
159
|
+
</tbody>
|
|
160
|
+
</table>
|
|
161
|
+
</div>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
116
165
|
export default Table
|