@kolkrabbi/kol-component 0.290.0 → 0.292.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.292.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"embla-carousel-react": "^8.6.0",
|
|
27
27
|
"pdfjs-dist": "^6.3.289",
|
|
28
28
|
"react-syntax-highlighter": "^16.1.1",
|
|
29
|
-
"@kolkrabbi/kol-
|
|
30
|
-
"@kolkrabbi/kol-
|
|
29
|
+
"@kolkrabbi/kol-markdown": "^0.1.3",
|
|
30
|
+
"@kolkrabbi/kol-search": "^0.3.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@kolkrabbi/kol-icons": ">=0.22.0",
|
package/src/index.js
CHANGED
|
@@ -55,6 +55,7 @@ export { usePopover, PopoverPanel, Tooltip } from './utilities/Popover.jsx'
|
|
|
55
55
|
/* armLongPress — the touch hold the panel value controls report (moved from kol-hardware 2026-10-01) */
|
|
56
56
|
export { armLongPress } from './utilities/armLongPress.js'
|
|
57
57
|
export { default as ContextMenu, useContextMenu } from './molecules/ContextMenu.jsx'
|
|
58
|
+
export { AppItemMenuProvider } from './molecules/AppItem.jsx'
|
|
58
59
|
export { default as ProsePreview } from './utilities/ProsePreview.jsx'
|
|
59
60
|
export { default as QuantityInput } from './molecules/QuantityInput.jsx'
|
|
60
61
|
/* Knob — the survivor's name (2026-10-02): `variant` dial · panel. `RotaryDial` is the alias, on the ledger. */
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react'
|
|
2
|
+
import { Icon } from '@kolkrabbi/kol-icons'
|
|
3
|
+
import ActionButton from './ActionButton.jsx'
|
|
4
|
+
import ContextMenu, { useContextMenu } from './ContextMenu.jsx'
|
|
5
|
+
import { MenuDropdownItem } from './MenuItem.jsx'
|
|
6
|
+
import { useModal } from './Modal.jsx'
|
|
7
|
+
import formatSize from '../utilities/formatSize.js'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The `app` variant of ContentCard and ContentRow (CatalogAppVariant, kol-fxr 2026-10-23): kol-fxr's
|
|
11
|
+
* approved saved-file card, so every app's library takes it by a bump. It is the `file` card and row
|
|
12
|
+
* with the parts slotted — download on the cover, a cog over a trash in the plate, Rename · Duplicate ·
|
|
13
|
+
* Delete on the cog and on right-click. The consumer passes raw writes (`verbs`); the dialogs are asked
|
|
14
|
+
* here. A verb not passed is not drawn.
|
|
15
|
+
*
|
|
16
|
+
* The menu is ONE per page: `AppItemMenuProvider` (CatalogPage mounts it) holds it, and every app card
|
|
17
|
+
* and row opens it. Without a provider the card still draws download and trash, but no cog and no
|
|
18
|
+
* right-click menu.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const MenuCtx = createContext(null)
|
|
22
|
+
|
|
23
|
+
const useAsk = () => {
|
|
24
|
+
const modal = useModal()
|
|
25
|
+
return {
|
|
26
|
+
rename: async (name, verbs) => {
|
|
27
|
+
const next = await modal.prompt('Rename:', name ?? '')
|
|
28
|
+
if (next != null && next.trim() && next.trim() !== name) verbs.rename(next.trim())
|
|
29
|
+
},
|
|
30
|
+
remove: async (name, verbs) => {
|
|
31
|
+
if (await modal.confirm(`Delete “${name || 'Untitled'}”?`, { okLabel: 'Delete' })) verbs.remove()
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const glyph = (name) => <Icon name={name} size={14} />
|
|
37
|
+
|
|
38
|
+
export function AppItemMenuProvider({ children }) {
|
|
39
|
+
const menu = useContextMenu()
|
|
40
|
+
const ask = useAsk()
|
|
41
|
+
return (
|
|
42
|
+
<MenuCtx.Provider value={menu}>
|
|
43
|
+
{children}
|
|
44
|
+
<ContextMenu menu={menu}>
|
|
45
|
+
{(item) => item && (
|
|
46
|
+
<>
|
|
47
|
+
{item.verbs?.rename && <MenuDropdownItem iconLeft={glyph('edit')} onClick={() => ask.rename(item.name, item.verbs)}>Rename</MenuDropdownItem>}
|
|
48
|
+
{item.verbs?.duplicate && <MenuDropdownItem iconLeft={glyph('copy')} onClick={item.verbs.duplicate}>Duplicate</MenuDropdownItem>}
|
|
49
|
+
{item.verbs?.remove && <MenuDropdownItem iconLeft={glyph('trash')} onClick={() => ask.remove(item.name, item.verbs)}>Delete</MenuDropdownItem>}
|
|
50
|
+
{item.menuItems}
|
|
51
|
+
</>
|
|
52
|
+
)}
|
|
53
|
+
</ContextMenu>
|
|
54
|
+
</MenuCtx.Provider>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* the plate's two actions, stacked over its padded height; a plate press never opens the card */
|
|
59
|
+
function AppPlate({ name, verbs, onSettings }) {
|
|
60
|
+
const ask = useAsk()
|
|
61
|
+
return (
|
|
62
|
+
<div className="flex h-full flex-col items-center justify-between" onClick={(e) => e.stopPropagation()}>
|
|
63
|
+
{onSettings && <ActionButton chrome="inline" size="sm" icon="settings-01" confirmIcon="settings-01" label="Settings" onAction={onSettings} />}
|
|
64
|
+
{verbs?.remove && <ActionButton chrome="inline" size="sm" icon="trash" confirmIcon="trash" label="Delete" onAction={() => ask.remove(name, verbs)} />}
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const placeholder = (
|
|
70
|
+
<div className="size-full flex items-center justify-center bg-oq-04 text-fg-24" aria-label="No preview yet">
|
|
71
|
+
<Icon name="image" size={24} />
|
|
72
|
+
</div>
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* useAppItem(variant, props) — the `file` props an `app` item draws with, or null for any other variant.
|
|
77
|
+
* Always runs the same hooks (one context read), so ContentCard / ContentRow call it unconditionally.
|
|
78
|
+
*/
|
|
79
|
+
export function useAppItem(variant, { title, verbs, download, menuItems, date, size, media, tone }) {
|
|
80
|
+
const menu = useContext(MenuCtx)
|
|
81
|
+
if (variant !== 'app') return null
|
|
82
|
+
const hasMenu = !!menu && !!(verbs?.rename || verbs?.duplicate || verbs?.remove || menuItems)
|
|
83
|
+
const openMenu = hasMenu ? (e) => menu.openAt(e, { name: title, verbs, menuItems }) : undefined
|
|
84
|
+
return {
|
|
85
|
+
tone: tone ?? 'secondary',
|
|
86
|
+
date: typeof date === 'number' ? new Date(date).toISOString().slice(0, 10) : date,
|
|
87
|
+
size: typeof size === 'number' ? formatSize(size) : size,
|
|
88
|
+
media: typeof media === 'string' ? <img src={media} alt={title ?? ''} className="size-full object-cover" /> : media ?? placeholder,
|
|
89
|
+
control: download ? <ActionButton chrome="media" icon="download" confirmIcon="check" label="Download" confirmLabel="Downloaded" onAction={download} /> : undefined,
|
|
90
|
+
actions: openMenu || verbs?.remove ? <AppPlate name={title} verbs={verbs} onSettings={openMenu} /> : undefined,
|
|
91
|
+
onContextMenu: openMenu,
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useLayoutEffect, useRef, useState } from 'react'
|
|
2
2
|
import ContentMedia from './ContentMedia.jsx'
|
|
3
3
|
import ContentText from './ContentText.jsx'
|
|
4
|
+
import { useAppItem } from './AppItem.jsx'
|
|
4
5
|
import { toneClass } from '../utilities/tone.js'
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -26,6 +27,11 @@ import { toneClass } from '../utilities/tone.js'
|
|
|
26
27
|
* (named `pad`, not `size` — `size` is the ruled TEXT slot). Image-only cards
|
|
27
28
|
* (print) pass no text slots and render no plate. Exotic chrome (drawers,
|
|
28
29
|
* keylines, specimens) is consumer content through `media`.
|
|
30
|
+
*
|
|
31
|
+
* APP (CatalogAppVariant, kol-fxr 2026-10-23): `variant="app"` is the `file` card with an app
|
|
32
|
+
* library's parts slotted from `verbs` (`{ rename?, duplicate?, remove? }`), `download` and
|
|
33
|
+
* `menuItems` — download on the cover, cog over trash in the plate, the page's one menu on
|
|
34
|
+
* right-click. `date` takes ms, `size` bytes, `media` a src. See AppItem.jsx.
|
|
29
35
|
*/
|
|
30
36
|
|
|
31
37
|
/* ruled defaults — defaults, not hardcodes; `ratio` stays overridable while
|
|
@@ -204,6 +210,20 @@ export default function ContentCard({
|
|
|
204
210
|
className = '',
|
|
205
211
|
...text
|
|
206
212
|
}) {
|
|
213
|
+
/* `app` (CatalogAppVariant, kol-fxr 2026-10-23) is the `file` card with its parts slotted from
|
|
214
|
+
* `verbs` · `download` · `menuItems` — AppItem.jsx. They never reach ContentText. */
|
|
215
|
+
const app = useAppItem(variantProp, { title: text.title, verbs: text.verbs, download: text.download, menuItems: text.menuItems, date: text.date, size: text.size, media, tone })
|
|
216
|
+
delete text.verbs; delete text.download; delete text.menuItems
|
|
217
|
+
if (app) {
|
|
218
|
+
variantProp = 'file'
|
|
219
|
+
tone = app.tone
|
|
220
|
+
media = app.media
|
|
221
|
+
control = app.control ?? control
|
|
222
|
+
actions = app.actions ?? actions
|
|
223
|
+
onContextMenu = app.onContextMenu ?? onContextMenu
|
|
224
|
+
text.date = app.date
|
|
225
|
+
text.size = app.size
|
|
226
|
+
}
|
|
207
227
|
const aliased = ALIAS[variantProp] ?? variantProp
|
|
208
228
|
/* `layout` only re-keys inside the showcase family — it is not a general
|
|
209
229
|
* escape hatch that would let any variant borrow another's box. */
|
|
@@ -309,7 +329,7 @@ export default function ContentCard({
|
|
|
309
329
|
zIndex: box.layout === 'canvas' ? 1 : undefined,
|
|
310
330
|
}}
|
|
311
331
|
>
|
|
312
|
-
{hasText && <ContentText variant={variant} form={isHero ? 'hero' : 'card'} className={actionsW ? 'min-w-0 pr-[var(--kol-plate-actions-w)]' : ''} tagVariant={tagVariant ?? (/surface-/.test(ground ?? '') ? 'tertiary' : 'primary')} {...textSlots} />}
|
|
332
|
+
{hasText && <ContentText variant={app ? 'app' : variant} form={isHero ? 'hero' : 'card'} className={actionsW ? 'min-w-0 pr-[var(--kol-plate-actions-w)]' : ''} tagVariant={tagVariant ?? (/surface-/.test(ground ?? '') ? 'tertiary' : 'primary')} {...textSlots} />}
|
|
313
333
|
{/* ABSOLUTE, not a flex sibling: the plate's height moves with the title
|
|
314
334
|
* and the meta, so a laid-out stack would stretch or drift with it. The
|
|
315
335
|
* inset reads the SAME pad token the plate uses, so the icons sit the
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ContentMedia from './ContentMedia.jsx'
|
|
2
2
|
import ContentText from './ContentText.jsx'
|
|
3
|
+
import { useAppItem } from './AppItem.jsx'
|
|
3
4
|
import { toneClass } from '../utilities/tone.js'
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -11,7 +12,8 @@ import { toneClass } from '../utilities/tone.js'
|
|
|
11
12
|
* 36 square thumb when `media` is passed (none without); article rides a 120px 16:9 thumb; work a framed 64px row; typeface a
|
|
12
13
|
* framed no-thumb block.
|
|
13
14
|
*
|
|
14
|
-
* @param {string} variant file | catalog | print | article | work | typeface | roster
|
|
15
|
+
* @param {string} variant file | app | catalog | print | article | work | typeface | roster
|
|
16
|
+
* (`app` = the file row with `verbs` · `menuItems` slotted — AppItem.jsx)
|
|
15
17
|
* (`default` is an alias of `file`). `roster` is the pickable
|
|
16
18
|
* row: filled tile, no border or divider, a FIXED 56px height the
|
|
17
19
|
* content fills, a 40px square thumb and two truncated lines.
|
|
@@ -191,6 +193,19 @@ export default function ContentRow({
|
|
|
191
193
|
className = '',
|
|
192
194
|
...text
|
|
193
195
|
}) {
|
|
196
|
+
/* `app` (CatalogAppVariant, kol-fxr 2026-10-23) is the `file` row with its parts slotted from
|
|
197
|
+
* `verbs` · `download` · `menuItems` — AppItem.jsx. They never reach ContentText. */
|
|
198
|
+
const app = useAppItem(variantProp, { title: text.title, verbs: text.verbs, download: text.download, menuItems: text.menuItems, date: text.date, size: text.size, media, tone })
|
|
199
|
+
delete text.verbs; delete text.download; delete text.menuItems
|
|
200
|
+
if (app) {
|
|
201
|
+
variantProp = 'file'
|
|
202
|
+
tone = app.tone
|
|
203
|
+
media = app.media
|
|
204
|
+
actions = app.actions ?? actions
|
|
205
|
+
onContextMenu = app.onContextMenu ?? onContextMenu
|
|
206
|
+
text.date = app.date
|
|
207
|
+
text.size = app.size
|
|
208
|
+
}
|
|
194
209
|
const aliased = ALIAS[variantProp] ?? variantProp
|
|
195
210
|
const variant = aliased.startsWith('showcase') && layout ? LAYOUT_KEY[layout] ?? aliased : aliased
|
|
196
211
|
const box = BOX[variant] ?? BOX.file
|
|
@@ -267,7 +282,7 @@ export default function ContentRow({
|
|
|
267
282
|
* (a rendered alphabet, a waveform, a sparkline) is never the family's. */
|
|
268
283
|
const inner = box.column ? (
|
|
269
284
|
<>
|
|
270
|
-
<ContentText variant={variant} form="row" className="w-full" tagVariant={tagVariant ?? (/surface-/.test(ground ?? '') ? 'tertiary' : 'primary')} {...text} />
|
|
285
|
+
<ContentText variant={app ? 'app' : variant} form="row" className="w-full" tagVariant={tagVariant ?? (/surface-/.test(ground ?? '') ? 'tertiary' : 'primary')} {...text} />
|
|
271
286
|
{footer}
|
|
272
287
|
</>
|
|
273
288
|
) : (
|
|
@@ -305,11 +320,11 @@ export default function ContentRow({
|
|
|
305
320
|
<div className="flex flex-1 min-w-0 items-stretch" style={{ padding: box.plate, gap: box.plateGap ?? box.plate }}>
|
|
306
321
|
{/* the meta line's leading is its type size, so its baseline lands on the bottom pad, level with the last
|
|
307
322
|
* control — at its 16px line the digits sat ~4px above it (user 2026-10-22) */}
|
|
308
|
-
<ContentText variant={variant} form="row" className="min-w-0 flex-1 justify-between [&_.kol-mono-12]:leading-none" tagVariant={tagVariant ?? (/surface-/.test(ground ?? '') ? 'tertiary' : 'primary')} {...text} />
|
|
323
|
+
<ContentText variant={app ? 'app' : variant} form="row" className="min-w-0 flex-1 justify-between [&_.kol-mono-12]:leading-none" tagVariant={tagVariant ?? (/surface-/.test(ground ?? '') ? 'tertiary' : 'primary')} {...text} />
|
|
309
324
|
{actions && <div className="shrink-0">{actions}</div>}
|
|
310
325
|
</div>
|
|
311
326
|
) : (
|
|
312
|
-
<ContentText variant={variant} form="row" className={`flex-1 ${box.height != null ? 'py-[2px]' : ''}`.trim()} tagVariant={tagVariant ?? (/surface-/.test(ground ?? '') ? 'tertiary' : 'primary')} {...text} />
|
|
327
|
+
<ContentText variant={app ? 'app' : variant} form="row" className={`flex-1 ${box.height != null ? 'py-[2px]' : ''}`.trim()} tagVariant={tagVariant ?? (/surface-/.test(ground ?? '') ? 'tertiary' : 'primary')} {...text} />
|
|
313
328
|
)}
|
|
314
329
|
{/* `specs` rides the trailing edge on EVERY variant — year · material ·
|
|
315
330
|
* edition is a content difference, not a geometry one, and minting a
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @param {ReactNode} date default · article · typeface
|
|
23
23
|
* @param {'card'|'row'|'hero'} form the block's form; `hero` is article's featured text (ContentCard `hero`)
|
|
24
24
|
* @param {ReactNode} size default · article (file size / read length)
|
|
25
|
-
* @param {ReactNode} meta work
|
|
25
|
+
* @param {ReactNode} meta work · slide · app (a line under the title)
|
|
26
26
|
* @param {number} gap inner line gap in px (defaults per variant/form)
|
|
27
27
|
* @param {string} tagVariant the Tag variant the `tags` slot draws (default `primary` — a soft ink wash that reads as a chip
|
|
28
28
|
* on a plain surface; CardTagsNoVisibleFill, kol-website 2026-09-01: `tertiary` is surface-primary with no border and was
|
|
@@ -59,6 +59,12 @@ const RAMP = {
|
|
|
59
59
|
card: { title: 'kol-sans-heading-05 text-emphasis truncate', date: 'kol-mono-12 text-meta', size: 'kol-mono-12 text-meta' },
|
|
60
60
|
row: { title: 'kol-sans-heading-05 text-emphasis truncate', date: 'kol-mono-12 text-meta', size: 'kol-mono-12 text-meta' },
|
|
61
61
|
},
|
|
62
|
+
/* APP — the `file` text with a `meta` line under the title (AppCardMeta, kol-monitor 2026-10-23: a module's
|
|
63
|
+
* `6HP 3U — Control`, a patch's `12 modules, 9 connections`). Without `meta` it is the file text. */
|
|
64
|
+
app: {
|
|
65
|
+
card: { title: 'kol-sans-heading-05 text-emphasis truncate', meta: 'kol-mono-12 text-meta truncate', date: 'kol-mono-12 text-meta', size: 'kol-mono-12 text-meta' },
|
|
66
|
+
row: { title: 'kol-sans-heading-05 text-emphasis truncate', meta: 'kol-mono-12 text-meta truncate', date: 'kol-mono-12 text-meta', size: 'kol-mono-12 text-meta' },
|
|
67
|
+
},
|
|
62
68
|
/* SLIDE — a deck (slide-variant-and-shelf-preset, kol-client-olina 2026-09-03;
|
|
63
69
|
* user: "they are genuinely different with 16:9 layout and those exposed
|
|
64
70
|
* properties"). file's voices plus a `meta` line — the slide count. */
|
|
@@ -154,6 +160,7 @@ const RAMP = {
|
|
|
154
160
|
* read off the shipped components and the live pages they render on. */
|
|
155
161
|
const ORDER = {
|
|
156
162
|
file: { card: ['title', ['group', 'date', 'size']], row: ['title', ['group', 'date', 'size']] },
|
|
163
|
+
app: { card: ['title', 'meta', ['group', 'date', 'size']], row: ['title', 'meta', ['group', 'date', 'size']] },
|
|
157
164
|
/* slide: title, then date · size · slide count on one baseline (read off olina's /slide-deck) */
|
|
158
165
|
slide: { card: ['title', ['group', 'date', 'size', 'meta']], row: ['title', ['group', 'date', 'size', 'meta']] },
|
|
159
166
|
catalog: { card: ['title', 'detail'], row: [['lead', 'title', 'detail']] },
|