@kolkrabbi/kol-component 0.334.0 → 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 +3 -3
- package/src/atoms/SectionLabel.jsx +29 -0
- package/src/index.js +11 -0
- package/src/molecules/ContentRow.jsx +30 -1
- package/src/molecules/DocsToc.jsx +16 -1
- package/src/molecules/EmptyState.jsx +15 -1
- package/src/molecules/FlyoutRow.jsx +10 -0
- package/src/molecules/IndexRow.jsx +37 -0
- package/src/molecules/LayerRow.jsx +53 -0
- package/src/molecules/Modal.jsx +58 -19
- package/src/molecules/NoticeBanner.jsx +28 -0
- package/src/molecules/QuickLookFrame.jsx +31 -27
- package/src/molecules/QuickLookHeader.jsx +60 -0
- package/src/molecules/SectionText.jsx +15 -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/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
|
@@ -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
|