@kolkrabbi/kol-component 0.377.0 → 0.379.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 +5 -4
- package/src/atoms/BezierPathEditor.jsx +1 -1
- package/src/atoms/Button.jsx +84 -1
- package/src/atoms/Figure.jsx +19 -1
- package/src/atoms/FunctionPlot.jsx +1 -1
- package/src/atoms/Input.jsx +105 -1
- package/src/atoms/Kbd.jsx +42 -2
- package/src/atoms/Link.jsx +20 -0
- package/src/atoms/OriginPicker.jsx +9 -5
- package/src/atoms/SectionFooter.jsx +22 -0
- package/src/atoms/SectionHeader.jsx +24 -0
- package/src/atoms/SizeOrDownload.jsx +1 -1
- package/src/atoms/Textarea.jsx +11 -2
- package/src/atoms/ToggleCheckbox.jsx +23 -1
- package/src/atoms/ToggleSwitch.jsx +39 -0
- package/src/atoms/ViewToggle.jsx +2 -2
- package/src/atoms/XYPad.jsx +25 -0
- package/src/hooks/useDragResize.js +1 -1
- package/src/index.js +26 -3
- package/src/molecules/AccountMenu.jsx +14 -1
- package/src/molecules/AlignmentGrid.jsx +13 -1
- package/src/molecules/ButtonGroup.jsx +73 -1
- package/src/molecules/ButtonSplit.jsx +64 -3
- package/src/molecules/Chip.jsx +26 -0
- package/src/molecules/CodeBlock.jsx +39 -2
- package/src/molecules/ColorInputRow.jsx +125 -4
- package/src/molecules/ColorSwatch.jsx +43 -2
- package/src/molecules/ContentCard.jsx +104 -3
- package/src/molecules/ContentMedia.jsx +1 -1
- package/src/molecules/ContentRow.jsx +3 -3
- package/src/molecules/DividerLabel.jsx +19 -0
- package/src/molecules/Dropdown.jsx +111 -1
- package/src/molecules/DropdownStepper.jsx +29 -0
- package/src/molecules/FieldPair.jsx +41 -2
- package/src/molecules/Header.jsx +8 -4
- package/src/molecules/LabeledControl.jsx +51 -0
- package/src/molecules/Menu.jsx +239 -3
- package/src/molecules/Modal.jsx +216 -10
- package/src/molecules/ModalShell.jsx +21 -8
- package/src/molecules/OptionRow.jsx +1 -1
- package/src/molecules/ParamBindDot.jsx +29 -2
- package/src/molecules/QuantityInput.jsx +48 -0
- package/src/molecules/RailFloat.jsx +4 -3
- package/src/molecules/RailHeader.jsx +32 -2
- package/src/molecules/SectionText.jsx +54 -1
- package/src/molecules/Slider.jsx +101 -2
- package/src/molecules/SplitToolButton.jsx +4 -6
- package/src/molecules/SwatchControls.jsx +28 -0
- package/src/molecules/SwatchGrid.jsx +39 -0
- package/src/molecules/TabsDocument.jsx +131 -0
- package/src/molecules/TabsRow.jsx +35 -1
- package/src/molecules/Toast.jsx +55 -0
- package/src/molecules/TreeRow.jsx +87 -1
- package/src/organisms/AppItemMenuProvider.jsx +2 -2
- package/src/organisms/ColorPickerPopover.jsx +133 -4
- package/src/organisms/ColumnBrowser.jsx +1 -1
- package/src/organisms/CommandOverlay.jsx +396 -21
- package/src/organisms/FindBar.jsx +70 -0
- package/src/organisms/FramedMediaBand.jsx +2 -2
- package/src/organisms/GalleryCarousel.jsx +1 -1
- package/src/organisms/LogoSystem.jsx +38 -0
- package/src/organisms/LogoTuner.jsx +32 -0
- package/src/organisms/MediaLibrary.jsx +1 -1
- package/src/organisms/MediaLibraryPages.jsx +1 -1
- package/src/organisms/Rail.jsx +33 -1
- package/src/organisms/RailSwitcher.jsx +62 -0
- package/src/organisms/ReadingContents.jsx +63 -1
- package/src/organisms/SectionSplit.jsx +1 -1
- package/src/organisms/SettingsPanel.jsx +64 -6
- package/src/organisms/ShortcutsOverlay.jsx +46 -2
- package/src/organisms/SpectrumControls.jsx +112 -19
- package/src/organisms/StatusBar.jsx +30 -0
- package/src/organisms/Table.jsx +141 -2
- package/src/organisms/TimelineDock.jsx +281 -1
- package/src/organisms/logoBoard.jsx +61 -0
- package/src/utilities/AssetPlaceholder.jsx +1 -1
- package/src/utilities/EditorShell.jsx +42 -1
- package/src/utilities/OverlayGlassPanel.jsx +1 -1
- package/src/utilities/Popover.jsx +298 -2
- package/src/utilities/SelectionOverlay.jsx +74 -1
- package/src/utilities/kolboxGlyph.jsx +10 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
1
|
+
import { useMemo, useRef, useState } from 'react'
|
|
2
2
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
3
|
import ColorSwatch from './ColorSwatch.jsx'
|
|
4
|
-
import Input from '../atoms/Input.jsx'
|
|
4
|
+
import Input, { selectOnFirstPress, useKolboxField } from '../atoms/Input.jsx'
|
|
5
|
+
import FieldPair from './FieldPair.jsx'
|
|
5
6
|
import { usePopover, PopoverPanel, Tooltip } from '../utilities/Popover.jsx'
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -66,7 +67,7 @@ import { usePopover, PopoverPanel, Tooltip } from '../utilities/Popover.jsx'
|
|
|
66
67
|
* transparentTone — TransparentX stroke tone for the null/unused swatch:
|
|
67
68
|
* 'warning' (default) | 'error' | 'info' | 'success'
|
|
68
69
|
*/
|
|
69
|
-
|
|
70
|
+
function ColorInputRowDefault({
|
|
70
71
|
value,
|
|
71
72
|
onChange,
|
|
72
73
|
label,
|
|
@@ -160,7 +161,7 @@ export default function ColorInputRow({
|
|
|
160
161
|
{chip('stretch')}
|
|
161
162
|
<span
|
|
162
163
|
aria-hidden="true"
|
|
163
|
-
className={`absolute inset-0 inline-flex items-center justify-center rounded-[var(--kol-radius-
|
|
164
|
+
className={`absolute inset-0 inline-flex items-center justify-center rounded-[var(--kol-radius-2)] transition-opacity bg-fg-ab-48 text-white pointer-events-none ${
|
|
164
165
|
locked ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'
|
|
165
166
|
}`}
|
|
166
167
|
>
|
|
@@ -279,3 +280,123 @@ export default function ColorInputRow({
|
|
|
279
280
|
</>
|
|
280
281
|
)
|
|
281
282
|
}
|
|
283
|
+
|
|
284
|
+
/* ── kolbox (plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18) ─────────────────────────────────────────────────
|
|
285
|
+
* kolbox's FillRow (Figma 84:12831), carried from apps/kolbox/src/ui/FillRow.jsx: one joined field (oq-16, radius 4, no
|
|
286
|
+
* outline) holding the hex segment (the 16 swatch and the hex in Inter 11, padding 6 and 8, gap 8) and, after a 1px
|
|
287
|
+
* gap in the rail ground (1 by 22, W16.5), the opacity segment (the value mono 11 and "%" muted, 8 in, the % 16 after the
|
|
288
|
+
* value and 4 off the end); with `actions` the row is FieldPair
|
|
289
|
+
* kolbox's: the field over both field columns of the rail's grid, the actions on its icon columns (R3.1). The
|
|
290
|
+
* swatch opens the caller's color overlay through `onSwatch` (with `lit` while it is open), or else the row's own
|
|
291
|
+
* `picker` (ColorPickerPopover variant="kolbox": this row is a molecule and cannot import the organism, so the caller
|
|
292
|
+
* hands it in), beside the rail level with the swatch. The hex is edited in place (one press selects it, a short hex grows on Enter or blur: `expandHex`); a value that is not a plain hex shows
|
|
293
|
+
* `resolved` on the swatch and its own text in the field. `opacity` 0 to 100 through `onOpacity` (read-only without it);
|
|
294
|
+
* null draws no opacity segment. `clearable`: emptying the hex commits null (an optional color, unset). `hidden` (the paint's eye is off) dims the opacity value; the color stays readable. `label` names the row's parts for a reader; this look draws no label. */
|
|
295
|
+
const HEX_KOLBOX = /^[0-9a-f]{6}$/i
|
|
296
|
+
/* a short hex grows on commit: 1 character six times, 2 three times, 3 each doubled; 6 as written; anything else is null */
|
|
297
|
+
export function expandHex(raw) {
|
|
298
|
+
const d = String(raw ?? '').trim().replace(/^#/, '')
|
|
299
|
+
if (!/^[0-9a-f]+$/i.test(d)) return null
|
|
300
|
+
if (d.length === 1) return d.repeat(6)
|
|
301
|
+
if (d.length === 2) return d.repeat(3)
|
|
302
|
+
if (d.length === 3) return [...d].map((c) => c + c).join('')
|
|
303
|
+
return d.length === 6 ? d : null
|
|
304
|
+
}
|
|
305
|
+
function ColorInputRowKolbox({ label, value, resolved, onChange, onSwatch, opacity, onOpacity, actions, lit = false, hidden = false, clearable = false, picker: Picker }) {
|
|
306
|
+
const hex = HEX_KOLBOX.test(String(value ?? '').replace('#', '')) ? String(value).replace('#', '').toUpperCase() : null
|
|
307
|
+
const swatch = resolved ?? (hex ? `#${hex}` : null)
|
|
308
|
+
const swatchRef = useRef(null)
|
|
309
|
+
const [picking, setPicking] = useState(false)
|
|
310
|
+
/* the row's own picker opens beside the rail (never over it), level with the swatch; outside a rail, beside the swatch */
|
|
311
|
+
const anchor = useMemo(() => ({
|
|
312
|
+
getBoundingClientRect() {
|
|
313
|
+
const sw = swatchRef.current?.getBoundingClientRect()
|
|
314
|
+
const rail = swatchRef.current?.closest('[data-rail]')?.getBoundingClientRect()
|
|
315
|
+
return rail ? { left: rail.left, right: rail.left, top: sw.top, bottom: sw.top } : sw
|
|
316
|
+
},
|
|
317
|
+
contains: (t) => !!swatchRef.current?.contains(t),
|
|
318
|
+
}), [])
|
|
319
|
+
/* the hex and the opacity are kolbox's fields (Input's useKolboxField): Escape restores, the opacity's arrows step */
|
|
320
|
+
const hexField = useKolboxField(hex ?? String(value ?? ''), (text) => {
|
|
321
|
+
if (clearable && !text) { if (value) onChange?.(null); return }
|
|
322
|
+
const d = expandHex(text)
|
|
323
|
+
if (d) onChange?.(`#${d.toLowerCase()}`)
|
|
324
|
+
}, { step: false })
|
|
325
|
+
const op = opacity == null ? null : Math.round(opacity)
|
|
326
|
+
const opField = useKolboxField(op, (text) => { const n = parseFloat(text); if (Number.isFinite(n)) onOpacity?.(Math.min(100, Math.max(0, n))) })
|
|
327
|
+
const field = (
|
|
328
|
+
<div className={`kol-color-row-field flex h-(--kol-kolbox-ctl) min-w-0 flex-1 items-stretch${lit || picking ? ' is-lit' : ''}`} data-fill-field>
|
|
329
|
+
<div className="flex min-w-0 flex-1 items-center gap-2 pr-2 pl-1.5" data-fill-hex>
|
|
330
|
+
<Tooltip variant="kolbox" asChild label={label}>
|
|
331
|
+
<button
|
|
332
|
+
ref={swatchRef}
|
|
333
|
+
type="button"
|
|
334
|
+
aria-label={`${label}: ${swatch ?? hexField.value}`}
|
|
335
|
+
aria-expanded={onSwatch ? lit : picking}
|
|
336
|
+
className="kol-color-row-swatch relative size-3.5 shrink-0 outline-none focus-visible:outline-solid focus-visible:outline-1"
|
|
337
|
+
style={{ background: swatch ?? 'transparent' }}
|
|
338
|
+
onClick={(e) => (onSwatch ? onSwatch(e) : setPicking((o) => !o))}
|
|
339
|
+
/>
|
|
340
|
+
</Tooltip>
|
|
341
|
+
<input
|
|
342
|
+
className="kol-color-row-hex min-w-0 flex-1 self-stretch bg-transparent uppercase outline-none"
|
|
343
|
+
aria-label={`${label} hex`}
|
|
344
|
+
{...hexField}
|
|
345
|
+
onMouseDown={selectOnFirstPress}
|
|
346
|
+
/>
|
|
347
|
+
</div>
|
|
348
|
+
{op != null && (
|
|
349
|
+
<>
|
|
350
|
+
{/* Figma's pair (W16.5): a 1 by 22 gap in the rail's ground; the number 8 in, the % 16 after it and 4 off the end */}
|
|
351
|
+
<span className="kol-color-row-rule my-px w-px shrink-0" />
|
|
352
|
+
<label className="flex shrink-0 items-center gap-4 self-stretch pr-1 pl-2" data-fill-opacity>
|
|
353
|
+
<input
|
|
354
|
+
aria-label={`${label} opacity`}
|
|
355
|
+
readOnly={!onOpacity}
|
|
356
|
+
{...opField}
|
|
357
|
+
onMouseDown={selectOnFirstPress}
|
|
358
|
+
className="kol-color-row-opacity field-sizing-content min-w-0 self-stretch bg-transparent outline-none"
|
|
359
|
+
/>
|
|
360
|
+
<span className="kol-color-row-unit">%</span>
|
|
361
|
+
</label>
|
|
362
|
+
</>
|
|
363
|
+
)}
|
|
364
|
+
</div>
|
|
365
|
+
)
|
|
366
|
+
const picker = !onSwatch && Picker && (
|
|
367
|
+
<Picker
|
|
368
|
+
variant="kolbox"
|
|
369
|
+
anchor={anchor}
|
|
370
|
+
open={picking}
|
|
371
|
+
onClose={() => setPicking(false)}
|
|
372
|
+
color={swatch && HEX_KOLBOX.test(swatch.replace('#', '')) ? swatch : undefined}
|
|
373
|
+
opacity={op ?? 100}
|
|
374
|
+
onChange={({ value: v, opacity: o }) => { onChange?.(v.toLowerCase()); if (op != null && o !== op) onOpacity?.(o) }}
|
|
375
|
+
/>
|
|
376
|
+
)
|
|
377
|
+
const root = `kol-color-row--kolbox min-w-0 flex-1 ${hidden ? 'is-hidden' : ''}`
|
|
378
|
+
/* with actions the row is a rail row: the field spans the grid's two field columns, the actions sit on its icon
|
|
379
|
+
columns (FieldPair kolbox, R3.1); alone it is a field that fills its cell */
|
|
380
|
+
return actions
|
|
381
|
+
? <><FieldPair variant="kolbox" span className={root} data-fill-row first={field} trailing={actions} />{picker}</>
|
|
382
|
+
: <div className={`${root} flex h-(--kol-kolbox-ctl) items-center`} data-fill-row>{field}{picker}</div>
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/* ── folio (Folio batch C, 2026-11-22): Folio's SwatchRow, carried class for class. The swatch (the `picker`,
|
|
386
|
+
* ColorPickerPopover variant="folio", handed in as kolbox's is: a molecule cannot import the organism), the `label`
|
|
387
|
+
* (12 / 16 medium, taking the room) and the hex (mono 12 / 16, capitals, Folio's muted ink), 12 apart. `swatches`
|
|
388
|
+
* ([name, hex]) go to the picker; `onChange(hex)`. Chrome in kol-theme `.kol-color-row--folio`. ── */
|
|
389
|
+
function ColorInputRowFolio({ label, value, swatches, onChange, picker: Picker }) {
|
|
390
|
+
return (
|
|
391
|
+
<div className="kol-color-row--folio flex w-full items-center gap-[12px]">
|
|
392
|
+
{Picker && <Picker variant="folio" label={label} color={value} swatches={swatches} onChange={onChange} />}
|
|
393
|
+
<p className="kol-color-row-label min-w-0 flex-1 truncate">{label}</p>
|
|
394
|
+
<p className="kol-color-row-value shrink-0 uppercase">{value}</p>
|
|
395
|
+
</div>
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export default function ColorInputRow(props) {
|
|
400
|
+
if (props.variant === 'folio') return <ColorInputRowFolio {...props} />
|
|
401
|
+
return props.variant === 'kolbox' ? <ColorInputRowKolbox {...props} /> : <ColorInputRowDefault {...props} />
|
|
402
|
+
}
|
|
@@ -24,7 +24,20 @@
|
|
|
24
24
|
* used by tightly-packed grid layouts.
|
|
25
25
|
* variant — 'default' (border-based chrome) |
|
|
26
26
|
* 'halo' (macOS-port double box-shadow halo). Halo
|
|
27
|
-
* overrides `frame` since it provides its own ring.
|
|
27
|
+
* overrides `frame` since it provides its own ring. |
|
|
28
|
+
* 'folio' (Folio's Swatch, Folio batch C, 2026-11-22, carried
|
|
29
|
+
* class for class): always a button, 24 square at radius 4,
|
|
30
|
+
* `frame` Folio's hairline round it, `selected` a 2px outline
|
|
31
|
+
* of Folio's ink 2 off it; `title` is the native title, `size`
|
|
32
|
+
* and `radius` are not read. With no `hex` the caller paints
|
|
33
|
+
* it (an accent swatch: `data-folio-accent` and `hex`
|
|
34
|
+
* `var(--kol-folio-green)`). Chrome in kol-theme
|
|
35
|
+
* `.kol-color-swatch--folio`. |
|
|
36
|
+
* 'kolbox' (Folio on kolbox, 2026-11-22): SwatchGrid kolbox's
|
|
37
|
+
* cell as one chip, always a button: `size` square (24), radius
|
|
38
|
+
* 2, `frame` its 1px oq-24 ring inside it, `selected` the 2px
|
|
39
|
+
* accent ring 1 off the secondary surface (chrome
|
|
40
|
+
* `.kol-swatch-grid-cell`); `title` names it in Tooltip kolbox.
|
|
28
41
|
* hoverable — boolean (default true). When false, no hover border
|
|
29
42
|
* state is applied even if `onClick` is set. For static
|
|
30
43
|
* chips that just open a popover (e.g. inspector fill /
|
|
@@ -55,7 +68,7 @@ const NAMED_PX = {
|
|
|
55
68
|
|
|
56
69
|
const RADIUS_CLASSES = {
|
|
57
70
|
none: 'rounded-none',
|
|
58
|
-
tight: 'rounded-[var(--kol-radius-
|
|
71
|
+
tight: 'rounded-[var(--kol-radius-2)]',
|
|
59
72
|
sm: 'rounded',
|
|
60
73
|
full: 'rounded-full',
|
|
61
74
|
}
|
|
@@ -84,6 +97,34 @@ export default function ColorSwatch({
|
|
|
84
97
|
className = '',
|
|
85
98
|
...rest
|
|
86
99
|
}) {
|
|
100
|
+
if (variant === 'kolbox') {
|
|
101
|
+
return (
|
|
102
|
+
<Tooltip variant="kolbox" asChild label={title}>
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
aria-pressed={selected}
|
|
106
|
+
onClick={onClick}
|
|
107
|
+
{...rest}
|
|
108
|
+
className={`kol-swatch-grid-cell${selected ? ' is-current ring-2 ring-offset-1' : frame ? ' ring-1 ring-inset' : ''} shrink-0 outline-none ${className}`.trim()}
|
|
109
|
+
style={{ width: size, height: size, background: hex, ...rest.style }}
|
|
110
|
+
/>
|
|
111
|
+
</Tooltip>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
if (variant === 'folio') {
|
|
115
|
+
return (
|
|
116
|
+
<button
|
|
117
|
+
type="button"
|
|
118
|
+
aria-pressed={selected}
|
|
119
|
+
/* title-ok: a port, verbatim (Folio batch C): Folio's swatches name their color in the browser's own tooltip */
|
|
120
|
+
title={title}
|
|
121
|
+
onClick={onClick}
|
|
122
|
+
{...rest}
|
|
123
|
+
className={`kol-color-swatch--folio size-[24px] rounded-[4px] ${frame ? 'border ' : ''}${selected ? 'is-selected outline outline-2 outline-offset-2' : ''} ${className}`}
|
|
124
|
+
style={hex ? { background: hex, ...rest.style } : rest.style}
|
|
125
|
+
/>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
87
128
|
const interactive = typeof onClick === 'function'
|
|
88
129
|
const resolvedSize = NAMED_PX[size] ?? size
|
|
89
130
|
const isNamed = typeof resolvedSize === 'string'
|
|
@@ -3,6 +3,9 @@ import ContentMedia from './ContentMedia.jsx'
|
|
|
3
3
|
import ContentText from './ContentText.jsx'
|
|
4
4
|
import { useAppItem } from './AppItem.jsx'
|
|
5
5
|
import { toneClass } from '../utilities/tone.js'
|
|
6
|
+
import Button from '../atoms/Button.jsx'
|
|
7
|
+
import { Tooltip } from '../utilities/Popover.jsx'
|
|
8
|
+
import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* ContentCard — the card form of the content-card system. Variants differ in
|
|
@@ -179,7 +182,7 @@ const MEDIA = {
|
|
|
179
182
|
const ALIAS = { default: 'file', print: 'catalog', work: 'showcase', typeface: 'showcaseCanvas' }
|
|
180
183
|
const LAYOUT_KEY = { canvas: 'showcaseCanvas', drawer: 'showcase' }
|
|
181
184
|
|
|
182
|
-
|
|
185
|
+
function ContentCardDefault({
|
|
183
186
|
variant: variantProp = 'file',
|
|
184
187
|
layout,
|
|
185
188
|
hero = false,
|
|
@@ -543,7 +546,7 @@ export default function ContentCard({
|
|
|
543
546
|
'data-back': backMode && backMode !== 'flip-card' ? backMode : undefined,
|
|
544
547
|
'data-back-hover': backMode && backMode !== 'flip-card' && backHover ? '' : undefined,
|
|
545
548
|
'data-flipped': backMode && backMode !== 'flip-card' && flipped ? '' : undefined,
|
|
546
|
-
className: `kol-card group flex ${toneClass(tone)} ${box.layout === 'canvas' && reveal != null ? 'has-reveal' : ''} ${expanded ? 'flex-col md:flex-row-reverse' : 'flex-col'} ${box.layout === 'drawer' ? 'relative overflow-hidden rounded-[var(--kol-radius-
|
|
549
|
+
className: `kol-card group flex ${toneClass(tone)} ${box.layout === 'canvas' && reveal != null ? 'has-reveal' : ''} ${expanded ? 'flex-col md:flex-row-reverse' : 'flex-col'} ${box.layout === 'drawer' ? 'relative overflow-hidden rounded-[var(--kol-radius-4)]' : ''} ${framed ? 'overflow-hidden rounded-[var(--kol-radius-4)]' : ''} ${box.border ? 'border' : ''} ${box.layout === 'canvas' ? 'relative' : ''} ${interactive ? 'cursor-pointer select-none' : ''} ${hoverBg && interactive ? 'kol-content-hover' : ''} ${interactive && box.frameHover ? 'kol-content-hover-frame' : ''} ${className}`.trim(),
|
|
547
550
|
style: {
|
|
548
551
|
/* same reason as ContentRow: rest colors are PROPERTIES, because an
|
|
549
552
|
* inline background/borderColor outranks the hover class and the step
|
|
@@ -568,7 +571,7 @@ export default function ContentCard({
|
|
|
568
571
|
<div className="kol-card-turn" data-back="flip-card" data-back-hover={backHover ? '' : undefined} data-flipped={flipped ? '' : undefined} style={{ gridColumn: common.style.gridColumn, gridRow: common.style.gridRow }}>
|
|
569
572
|
<div className="kol-card-turn-inner">
|
|
570
573
|
<div className="kol-card-face kol-card-face--front">{root}</div>
|
|
571
|
-
<div className="kol-card-face kol-card-face--back overflow-hidden rounded-[var(--kol-radius-
|
|
574
|
+
<div className="kol-card-face kol-card-face--back overflow-hidden rounded-[var(--kol-radius-4)] bg-surface-secondary" aria-hidden={!flipped || undefined}>
|
|
572
575
|
<ContentMedia ratio={null} radius={false} fit="cover">{backNode}</ContentMedia>
|
|
573
576
|
</div>
|
|
574
577
|
</div>
|
|
@@ -604,3 +607,101 @@ export default function ContentCard({
|
|
|
604
607
|
}
|
|
605
608
|
return turn(<article {...common}>{turned}</article>)
|
|
606
609
|
}
|
|
610
|
+
|
|
611
|
+
/* ── kolbox (plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18) ─────────────────────────────────────────────────
|
|
612
|
+
* kolbox's FileCard (Figma `FileCard`; round 4 W13, his card law), carried from apps/kolbox/src/home/FileCard.jsx; its
|
|
613
|
+
* geometry is Figma's file browser card, measured (plan-2026-11-23 W6): the cover 16:9 (167 on Figma's 297 card; the
|
|
614
|
+
* file's thumbnail whole, fitted and centred on oq-08), the 24 mark and buttons 16 in from the cover's corners, the foot
|
|
615
|
+
* 59 with 12 / 16 padding: the file glyph, the name and the meta line 2 under it. Opens on a double click or Enter. kolbox's words, which the
|
|
616
|
+
* default card has no twin for: `file` { id, name, thumb, modified, size, mark: { icon, label } }, `onOpen(file)`,
|
|
617
|
+
* `onDownload(file)` (the download beside the star), `onSettings(file)` (the cog), `onRemove(file)` (the trash under
|
|
618
|
+
* it), `onStar(file)` (the star, lit while `file.starred`), `onMenu(file, event)` (right click); each part drawn only when
|
|
619
|
+
* given. `file.icon` names the foot's glyph (default `file`; a folder card passes `folder`).
|
|
620
|
+
* Folio on kolbox (2026-11-22): `media`, a node drawn centred in the cover in place of `file.thumb` (Folio's generated
|
|
621
|
+
* jacket); `meta`, a node in place of the foot's second line (Folio's call number, shelf and flags). Unset, the card
|
|
622
|
+
* draws as before. */
|
|
623
|
+
|
|
624
|
+
/* "2 hours ago" from a stored time, in the browser's own words; the ISO day */
|
|
625
|
+
const RTF_KOLBOX = new Intl.RelativeTimeFormat('en', { numeric: 'always' })
|
|
626
|
+
const STEPS_KOLBOX = [['year', 31536e6], ['month', 2592e6], ['week', 6048e5], ['day', 864e5], ['hour', 36e5], ['minute', 6e4], ['second', 1e3]]
|
|
627
|
+
export const fileAgo = (t) => {
|
|
628
|
+
if (!t) return ''
|
|
629
|
+
const d = t - Date.now()
|
|
630
|
+
const [unit, ms] = STEPS_KOLBOX.find(([, s]) => Math.abs(d) >= s) ?? STEPS_KOLBOX[STEPS_KOLBOX.length - 1]
|
|
631
|
+
return RTF_KOLBOX.format(Math.round(d / ms), unit)
|
|
632
|
+
}
|
|
633
|
+
export const fileDay = (t) => (t ? new Date(t).toISOString().slice(0, 10) : '')
|
|
634
|
+
|
|
635
|
+
function ContentCardKolbox({ file, media, meta, onOpen, onDownload, onStar, onSettings, onRemove, onMenu }) {
|
|
636
|
+
const stop = (fn) => (e) => { e.stopPropagation(); fn(file, e) }
|
|
637
|
+
return (
|
|
638
|
+
<div
|
|
639
|
+
role="listitem"
|
|
640
|
+
tabIndex={0}
|
|
641
|
+
aria-label={file.name}
|
|
642
|
+
onDoubleClick={() => onOpen?.(file)}
|
|
643
|
+
onKeyDown={(e) => { if (e.key === 'Enter' && e.target === e.currentTarget) onOpen?.(file) }}
|
|
644
|
+
onContextMenu={onMenu ? (e) => { e.preventDefault(); onMenu(file, e) } : undefined}
|
|
645
|
+
className="kol-content-card--kolbox flex cursor-default flex-col overflow-hidden border outline-none"
|
|
646
|
+
data-file-card={file.id}
|
|
647
|
+
>
|
|
648
|
+
<div className="kol-content-card-cover relative aspect-video min-h-0 shrink-0" data-file-cover>
|
|
649
|
+
{media != null ? <div className="flex size-full items-center justify-center">{media}</div> : file.thumb && <img src={file.thumb} alt="" className="size-full object-contain" />}
|
|
650
|
+
{file.mark && (
|
|
651
|
+
<span className="absolute top-4 left-4">
|
|
652
|
+
<Tooltip variant="kolbox" label={file.mark.label}>
|
|
653
|
+
<span role="img" aria-label={file.mark.label} className="kol-content-card-mark kol-content-card-on-panel flex size-6 items-center justify-center" data-file-mark>
|
|
654
|
+
<KolboxGlyph name={file.mark.icon} />
|
|
655
|
+
</span>
|
|
656
|
+
</Tooltip>
|
|
657
|
+
</span>
|
|
658
|
+
)}
|
|
659
|
+
<span className="absolute top-4 right-4 flex gap-1">
|
|
660
|
+
{onDownload && <Tooltip variant="kolbox" label="Download"><Button variant="kolbox" iconOnly="download" aria-label="Download" onClick={stop(onDownload)} onDoubleClick={(e) => e.stopPropagation()} className="kol-content-card-on-panel size-6!" /></Tooltip>}
|
|
661
|
+
{onStar && <Tooltip variant="kolbox" label={file.starred ? 'Unstar' : 'Star'}><Button variant="kolbox" iconOnly="star" aria-label="Star" pressed={!!file.starred} onClick={stop(onStar)} onDoubleClick={(e) => e.stopPropagation()} className="kol-content-card-on-panel size-6!" /></Tooltip>}
|
|
662
|
+
</span>
|
|
663
|
+
</div>
|
|
664
|
+
<div className="kol-content-card-foot flex h-[59px] shrink-0 items-center gap-3 border-t px-4 py-3">
|
|
665
|
+
<KolboxGlyph name={file.icon ?? 'file'} className="kol-content-card-icon" />
|
|
666
|
+
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
667
|
+
<span className="kol-content-card-name truncate">{file.name}</span>
|
|
668
|
+
{meta != null
|
|
669
|
+
? <span className="kol-content-card-meta flex items-center gap-3 truncate" data-file-meta>{meta}</span>
|
|
670
|
+
: file.size != null
|
|
671
|
+
? <span className="kol-content-card-meta flex gap-3 truncate" data-file-meta><span>{fileDay(file.modified)}</span><span>{file.size}</span></span>
|
|
672
|
+
: <span className="kol-content-card-edited truncate">Edited {fileAgo(file.modified)}</span>}
|
|
673
|
+
</div>
|
|
674
|
+
{(onSettings || onRemove) && (
|
|
675
|
+
<span className="-mr-2 flex shrink-0 flex-col" onDoubleClick={(e) => e.stopPropagation()}>
|
|
676
|
+
{onSettings && <Tooltip variant="kolbox" label="Settings"><Button variant="kolbox" iconOnly="settings-01" aria-label="Settings" onClick={stop(onSettings)} className="size-6!" /></Tooltip>}
|
|
677
|
+
{onRemove && <Tooltip variant="kolbox" label="Delete"><Button variant="kolbox" iconOnly="trash" aria-label="Delete" onClick={stop(onRemove)} className="size-6!" /></Tooltip>}
|
|
678
|
+
</span>
|
|
679
|
+
)}
|
|
680
|
+
</div>
|
|
681
|
+
</div>
|
|
682
|
+
)
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/* ── folio (Folio batch E, 2026-11-22) ─────────────────────────────────────────────────────────────────────────────
|
|
686
|
+
* Folio's cover card, carried from apps/folio's FolioShelf ("Fresh on your shelf"): the `media` (Folio's generated
|
|
687
|
+
* jacket, a node the caller draws at the card's width) over three lines 6 apart, 12 under the cover: the `title` in
|
|
688
|
+
* Folio's shelf type, two lines held open and underlined on hover, the `meta` (chapters or call number) and the `label`
|
|
689
|
+
* (the shelf, with its language flags) in Folio's meta type, muted. The whole card is one link: `href`, drawn by
|
|
690
|
+
* `linkComponent` (a router's Link; default `a`); `style` carries the caller's width cap. */
|
|
691
|
+
function ContentCardFolio({ media, title, meta, label, href, linkComponent: L = 'a', style, className = '' }) {
|
|
692
|
+
return (
|
|
693
|
+
<L {...(L === 'a' ? { href } : { to: href })} className={`kol-content-card--folio group flex min-w-0 flex-1 flex-col gap-[12px] ${className}`.trim()} style={style}>
|
|
694
|
+
{media}
|
|
695
|
+
<span className="flex flex-col gap-[6px]">
|
|
696
|
+
<span className="kol-folio-shelf line-clamp-2 min-h-[38px] group-hover:underline">{title}</span>
|
|
697
|
+
{meta != null && <span className="kol-folio-meta kol-content-card-muted">{meta}</span>}
|
|
698
|
+
{label != null && <span className="kol-folio-meta-sm kol-content-card-muted flex items-center gap-[6px]">{label}</span>}
|
|
699
|
+
</span>
|
|
700
|
+
</L>
|
|
701
|
+
)
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
export default function ContentCard(props) {
|
|
705
|
+
if (props.variant === 'folio') return <ContentCardFolio {...props} />
|
|
706
|
+
return props.variant === 'kolbox' ? <ContentCardKolbox {...props} /> : <ContentCardDefault {...props} />
|
|
707
|
+
}
|
|
@@ -122,7 +122,7 @@ export default function ContentMedia({
|
|
|
122
122
|
if (children == null) {
|
|
123
123
|
return <AssetPlaceholder radius={radius} aspectRatio={ratio ?? undefined} className={ratio == null ? `h-full ${className}` : className} />
|
|
124
124
|
}
|
|
125
|
-
const round = radius ? 'rounded-[var(--kol-radius-
|
|
125
|
+
const round = radius ? 'rounded-[var(--kol-radius-4)]' : ''
|
|
126
126
|
return (
|
|
127
127
|
<div
|
|
128
128
|
className={`relative ${fillHeight ? 'h-full w-auto' : 'w-full'} overflow-hidden ${round} ${FIT[fit] ?? FIT.cover} ${frame ? 'bg-fg-04 border border-fg-08' : ''} ${border ? 'border border-fg-08' : ''} ${zoom ? `kol-media-zoom${zoom === 'hero' ? ' is-hero' : ''}` : ''} ${borderHover ? 'transition-colors hover:border-fg-16' : ''} ${ratio == null ? 'h-full' : ''} ${className}`.trim()}
|
|
@@ -93,7 +93,7 @@ const BOX = {
|
|
|
93
93
|
* (136 thumb + 2×16 pad), so this is a change of KIND, not of value; the
|
|
94
94
|
* text has 136 to live in and the tags line goes single-row below md
|
|
95
95
|
* (ContentText's showcase ramp) so the cut lands on the chips, not mid-row. */
|
|
96
|
-
showcase: { thumb: 'fill', ratio: '1 / 1', pad: S4, gap: S4, frame: 'transparent', frameHover: 'var(--kol-fg-08)', bg: 'var(--kol-surface-secondary)', minH: 168, heightSm: 168, align: 'items-stretch', thumbRadius: 'var(--kol-radius-
|
|
96
|
+
showcase: { thumb: 'fill', ratio: '1 / 1', pad: S4, gap: S4, frame: 'transparent', frameHover: 'var(--kol-fg-08)', bg: 'var(--kol-surface-secondary)', minH: 168, heightSm: 168, align: 'items-stretch', thumbRadius: 'var(--kol-radius-2)', thumbBorder: false },
|
|
97
97
|
/* ROSTER — a PICKABLE row (ContentRowRosterVariant, kol-chess 2026-08-31):
|
|
98
98
|
* filled tile, no border, no divider, fixed height, square thumb, two
|
|
99
99
|
* truncated lines that FILL the row rather than setting it.
|
|
@@ -334,7 +334,7 @@ export default function ContentRow({
|
|
|
334
334
|
radius={!box.clip}
|
|
335
335
|
border={box.thumbBorder ?? false}
|
|
336
336
|
bg={box.thumbBg}
|
|
337
|
-
className={box.thumbRadius ? 'rounded-[var(--kol-radius-
|
|
337
|
+
className={box.thumbRadius ? 'rounded-[var(--kol-radius-2)]' : ''}
|
|
338
338
|
>
|
|
339
339
|
{media}
|
|
340
340
|
</ContentMedia>
|
|
@@ -380,7 +380,7 @@ export default function ContentRow({
|
|
|
380
380
|
)
|
|
381
381
|
|
|
382
382
|
const common = {
|
|
383
|
-
className: `kol-row group flex ${toneClass(tone)} ${box.column ? 'flex-col' : ''} ${box.align} ${box.height != null ? 'kol-row--fixed' : ''} ${box.heightSm != null ? 'kol-row--fixed-sm' : ''} ${box.divider ? 'kol-row--divided' : ''} ${box.frame ? 'rounded-[var(--kol-radius-
|
|
383
|
+
className: `kol-row group flex ${toneClass(tone)} ${box.column ? 'flex-col' : ''} ${box.align} ${box.height != null ? 'kol-row--fixed' : ''} ${box.heightSm != null ? 'kol-row--fixed-sm' : ''} ${box.divider ? 'kol-row--divided' : ''} ${box.frame ? 'rounded-[var(--kol-radius-4)] border' : ''} ${box.clip ? 'overflow-hidden rounded-[var(--kol-radius-4)]' : ''} ${interactive ? 'cursor-pointer select-none' : ''} ${interactive && hover ? 'kol-content-hover' : ''} ${interactive && box.frameHover ? 'kol-content-hover-frame' : ''} ${className}`.trim(),
|
|
384
384
|
style: vars,
|
|
385
385
|
}
|
|
386
386
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DividerLabel — A label, then a rule to the row's end. a group's name over a list, ruled off: the label in 11 / 15 at
|
|
3
|
+
* oq-64, 8 apart a 1px oq-24 rule that takes the rest of the row (kolbox's GroupLabel over the effect rows,
|
|
4
|
+
* plan-2026-11-18-kolbox-system W31.2, 2026-11-18, carried class for class). A label and a Divider, so a molecule;
|
|
5
|
+
* `Divider` itself takes no label. The family and weight are the row's. Chrome in kol-theme `.kol-divider-label`.
|
|
6
|
+
*
|
|
7
|
+
* <DividerLabel>Vector effects</DividerLabel>
|
|
8
|
+
*
|
|
9
|
+
* @param {ReactNode} children - The label
|
|
10
|
+
* @param {string} [className] - Extra classes on the row
|
|
11
|
+
*/
|
|
12
|
+
export default function DividerLabel({ children, className = '' }) {
|
|
13
|
+
return (
|
|
14
|
+
<div className={`kol-divider-label flex items-center gap-2 ${className}`.trim()}>
|
|
15
|
+
<span className="kol-divider-label-text">{children}</span>
|
|
16
|
+
<span className="kol-divider-label-rule h-px flex-1" />
|
|
17
|
+
</div>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -3,6 +3,7 @@ import { toneClass } from '../utilities/tone.js'
|
|
|
3
3
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
4
4
|
import { MenuList } from './MenuList.jsx'
|
|
5
5
|
import { Menu } from './Menu.jsx'
|
|
6
|
+
import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
6
7
|
import { glyphSize, indicatorSize } from '../hooks/glyphLadders.js'
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -66,7 +67,116 @@ const ROW = { xs: `kol-mono-8 ${ROW_PAD.xs} ${ROW_H.xs}`, sm: `kol-mono-12 ${ROW
|
|
|
66
67
|
|
|
67
68
|
const LEGACY_VARIANTS = { default: 'primary', subtle: 'primary', minimal: 'outline' }
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
/* `variant="kolbox"` (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18): kolbox's Dropdown carried line for line,
|
|
71
|
+
* the chrome in kol-theme `.kol-dd--kolbox`. The closed field with the 12 chevron at the right: a button that opens
|
|
72
|
+
* `Menu variant="kolbox"` OVER itself (28.5: the chosen row on the field, the left edges together, at least as wide as
|
|
73
|
+
* the field, flipped to the field's right edge near the window's, 4 from it), with a check on the current option.
|
|
74
|
+
* `options` strings or `{ value, label }`; `onChange` gets the value as a string. Enter, Space or ArrowDown opens; in the
|
|
75
|
+
* menu the arrows move, Enter picks, a letter jumps, Escape closes; focus comes back to the field.
|
|
76
|
+
* size sm (unset) the 28 field; xs the 24 filter (Home's), no fill, Figma's filter measured (plan-2026-11-23-editor-
|
|
77
|
+
* measured-against-figma W7): the value 8 in, the chevron's glyph 5 after it and 7 off the right edge
|
|
78
|
+
* tone unset: the outlined field, the oq-24 line only (the master's default), the line the accent while open or
|
|
79
|
+
* focused; `grey`: the unbordered field (oq-16 at sm, bare at xs), padding 12 left and 4 right, the chevron 4
|
|
80
|
+
* after the value, so it hugs its value (the top rail's zoom)
|
|
81
|
+
* menu a trigger for its own overlay instead of the option list (the zoom's): menu({ anchor, open, onClose }) is drawn
|
|
82
|
+
* in place of the Menu, and the field reads `value` as it is
|
|
83
|
+
* ariaLabel what it chooses, as KOL's Dropdown; other props (disabled, data-*) land on the button
|
|
84
|
+
* Folio on kolbox (2026-11-22): a number option's value reaches `onChange` as a number (every other as a string); a
|
|
85
|
+
* `value` no option holds is shown as it is; `align` (folio's) is read and dropped, the list lies over its field */
|
|
86
|
+
function DropdownKolbox({ size, tone, value, options = [], onChange, menu, ariaLabel, align: _align, className = '', variant, ...rest }) {
|
|
87
|
+
const ref = useRef(null)
|
|
88
|
+
const [open, setOpen] = useState(false)
|
|
89
|
+
const outlined = tone !== 'grey'
|
|
90
|
+
const xs = size === 'xs'
|
|
91
|
+
/* `{ divider: true }` starts a new group (Menu draws the line between groups); a `{ heading }` is not a row here */
|
|
92
|
+
const all = options.map((o) => (typeof o === 'string' ? { value: o, label: o } : o)).filter((o) => !o?.heading)
|
|
93
|
+
const opts = all.filter((o) => !o?.divider)
|
|
94
|
+
/* a value that no option holds (a node, or an action's name: Folio's Heading, Save to bucket) is shown as it is */
|
|
95
|
+
const current = opts.find((o) => String(o.value) === String(value)) ?? (value != null && value !== '' && opts.length ? { label: value } : opts[0]) ?? { label: value }
|
|
96
|
+
const close = () => { setOpen(false); ref.current?.focus({ preventScroll: true }) }
|
|
97
|
+
const groups = [[]]
|
|
98
|
+
/* the check column only when the field holds one of its options (an action list, Folio's Save to bucket, has none) */
|
|
99
|
+
const held = opts.includes(current)
|
|
100
|
+
for (const o of all) {
|
|
101
|
+
if (o.divider) { if (groups.at(-1).length) groups.push([]); continue }
|
|
102
|
+
const on = o === current
|
|
103
|
+
groups.at(-1).push({ label: o.label, value: o.value, check: held ? on : undefined, highlighted: on })
|
|
104
|
+
}
|
|
105
|
+
return (
|
|
106
|
+
<>
|
|
107
|
+
<button
|
|
108
|
+
ref={ref}
|
|
109
|
+
type="button"
|
|
110
|
+
aria-haspopup="menu"
|
|
111
|
+
aria-expanded={open}
|
|
112
|
+
aria-label={ariaLabel}
|
|
113
|
+
data-kol-dropdown=""
|
|
114
|
+
onClick={() => (open ? close() : setOpen(true))}
|
|
115
|
+
onKeyDown={(e) => {
|
|
116
|
+
/* the field's own keys, kept from the page's shortcuts as a native select's are */
|
|
117
|
+
if (!['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(e.key)) return
|
|
118
|
+
e.preventDefault(); e.stopPropagation()
|
|
119
|
+
if (e.key !== 'ArrowUp') setOpen(true)
|
|
120
|
+
}}
|
|
121
|
+
className={`kol-dd--kolbox${outlined ? ' kol-dd--kolbox-outlined' : ''}${outlined && open ? ' is-open' : ''}${!outlined && !xs ? ' kol-dd--kolbox-filled' : ''} relative flex min-w-0 cursor-pointer items-center disabled:cursor-default disabled:opacity-40 ${xs ? 'h-6 bg-transparent' : 'h-(--kol-kolbox-ctl)'} text-left outline-none ${outlined ? (xs ? 'gap-0.5 border pr-[3px] pl-[7px]' : 'gap-2 border px-2') : 'gap-1 pr-1 pl-3 focus-visible:outline-1'} ${className}`}
|
|
122
|
+
{...rest}
|
|
123
|
+
>
|
|
124
|
+
<span className="min-w-0 flex-1 truncate">{current?.label}</span>
|
|
125
|
+
<KolboxGlyph name="chevron-down" className="kol-dd-caret--kolbox pointer-events-none" />
|
|
126
|
+
</button>
|
|
127
|
+
{menu ? menu({ anchor: ref, open, onClose: close }) : <Menu
|
|
128
|
+
variant="kolbox"
|
|
129
|
+
anchor={ref}
|
|
130
|
+
open={open}
|
|
131
|
+
onClose={close}
|
|
132
|
+
onSelect={(row) => onChange?.(typeof row.value === 'number' ? row.value : String(row.value))}
|
|
133
|
+
groups={groups}
|
|
134
|
+
placement="over"
|
|
135
|
+
aria-label={ariaLabel}
|
|
136
|
+
minWidth={ref.current?.offsetWidth}
|
|
137
|
+
/>}
|
|
138
|
+
</>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* `variant="folio"` (Folio migration batch B, 2026-11-22): Folio's Choice carried class for class, the chrome in kol-theme
|
|
143
|
+
* `.kol-dd--folio`. The button is as wide as its text (its type is the caller's or the row's), the ⌄ after it; the list
|
|
144
|
+
* opens under it in place (never portalled, so it keeps the frame's `data-folio-*`), the current row green with its ✓.
|
|
145
|
+
* Esc or a press outside closes. `options` `{ value, label }` (a label may be a node; `value` reaches `onChange` as it
|
|
146
|
+
* is), `ariaLabel`, `disabled`, `className` (the button's). Folio's own word: `align` left (unset), right, bottom-left,
|
|
147
|
+
* bottom-right: the list's edge and side. */
|
|
148
|
+
function DropdownFolio({ value, options = [], onChange, ariaLabel, disabled, align = 'left', className = '' }) {
|
|
149
|
+
const [open, setOpen] = useState(false)
|
|
150
|
+
const box = useRef(null)
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (!open) return undefined
|
|
153
|
+
const off = (e) => { if (!box.current?.contains(e.target)) setOpen(false) }
|
|
154
|
+
const esc = (e) => e.key === 'Escape' && setOpen(false)
|
|
155
|
+
addEventListener('mousedown', off); addEventListener('keydown', esc)
|
|
156
|
+
return () => { removeEventListener('mousedown', off); removeEventListener('keydown', esc) }
|
|
157
|
+
}, [open])
|
|
158
|
+
const current = options.find((o) => o.value === value)?.label ?? value
|
|
159
|
+
return (
|
|
160
|
+
<span ref={box} className="relative inline-flex">
|
|
161
|
+
<button type="button" aria-label={ariaLabel} aria-haspopup="listbox" aria-expanded={open} disabled={disabled} onClick={() => setOpen(!open)} className={`kol-dd--folio inline-flex items-center gap-[4px] rounded-[3px] disabled:cursor-default ${className}`}>
|
|
162
|
+
{current}{!disabled && <span aria-hidden className="kol-dd-caret--folio">⌄</span>}
|
|
163
|
+
</button>
|
|
164
|
+
{open && (
|
|
165
|
+
<span role="listbox" aria-label={ariaLabel} className={`kol-dd-list--folio absolute z-50 flex min-w-[160px] flex-col rounded-[3px] border py-[4px] ${/right/.test(align) ? 'right-0' : 'left-0'} ${/bottom/.test(align) ? 'bottom-[calc(100%+6px)]' : 'top-[calc(100%+6px)]'}`}>
|
|
166
|
+
{options.map((o) => (
|
|
167
|
+
<button key={o.value} type="button" role="option" aria-selected={o.value === value} onClick={() => { setOpen(false); onChange?.(o.value) }} className={`kol-dd-option--folio${o.value === value ? ' is-current' : ''} flex items-center gap-[8px] whitespace-nowrap px-[12px] py-[7px] text-left`}>
|
|
168
|
+
<span aria-hidden className="kol-dd-check--folio inline-flex size-[16px] shrink-0 items-center justify-center">{o.value === value ? '✓' : ''}</span>{o.label}
|
|
169
|
+
</button>
|
|
170
|
+
))}
|
|
171
|
+
</span>
|
|
172
|
+
)}
|
|
173
|
+
</span>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const Dropdown = (props) => (props.variant === 'kolbox' ? <DropdownKolbox {...props} /> : props.variant === 'folio' ? <DropdownFolio {...props} /> : <DropdownOn {...props} />)
|
|
178
|
+
|
|
179
|
+
const DropdownOn = ({
|
|
70
180
|
options = [],
|
|
71
181
|
value,
|
|
72
182
|
onChange,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Button from '../atoms/Button.jsx'
|
|
2
|
+
import Dropdown from './Dropdown.jsx'
|
|
3
|
+
|
|
4
|
+
/* taxonomy-ok: molecule — a Dropdown with its previous and next Buttons */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* DropdownStepper — A Dropdown with the previous and next buttons round it (plan-2026-11-18-kolbox-system W31.2
|
|
8
|
+
* batch 4, 2026-11-18; kolbox's, Labs' preset stepper): `onStep(-1)` and `onStep(1)` walk the options, the Dropdown picks
|
|
9
|
+
* any. With one option the buttons are not drawn. It renders its three parts with no wrapper, so they sit in the
|
|
10
|
+
* caller's row. `variant` reaches the Buttons (icon-only chevrons) and the Dropdown (`kolbox` is kolbox's look). Input.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} [value]
|
|
13
|
+
* @param {Array} [options] Dropdown's options
|
|
14
|
+
* @param {Function} [onChange] `(value)`
|
|
15
|
+
* @param {Function} [onStep] `(-1 | 1)`
|
|
16
|
+
* @param {string} [prevLabel='Previous'] @param {string} [nextLabel='Next'] the buttons' names
|
|
17
|
+
* @param {string} [variant]
|
|
18
|
+
* @param {string} [className='min-w-0 flex-1'] the Dropdown's
|
|
19
|
+
*/
|
|
20
|
+
export default function DropdownStepper({ value, options = [], onChange, onStep, prevLabel = 'Previous', nextLabel = 'Next', variant, className = 'min-w-0 flex-1' }) {
|
|
21
|
+
const steps = options.length > 1
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
{steps && <Button variant={variant} iconOnly="chevron-left" aria-label={prevLabel} onClick={() => onStep?.(-1)} />}
|
|
25
|
+
<Dropdown variant={variant} className={className} value={value} options={options} onChange={onChange} />
|
|
26
|
+
{steps && <Button variant={variant} iconOnly="chevron-right" aria-label={nextLabel} onClick={() => onStep?.(1)} />}
|
|
27
|
+
</>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -5,12 +5,51 @@ import Input from '../atoms/Input.jsx'
|
|
|
5
5
|
* two-up position fields). Two `Input`s 8 apart, each led by its letter (`prefix`), sharing one `variant` and `size`;
|
|
6
6
|
* the pair fills its row, each field half. A position, a size, a range — any two values that are read together.
|
|
7
7
|
*
|
|
8
|
+
* `variant="kolbox"` (kolbox's PropertyRow, Figma 70:12121, plan-2026-11-18-kolbox-system W31.2, 2026-11-18, carried
|
|
9
|
+
* class for class): two slots instead of two Inputs' props, `first` and `second`, then `trailing` (icons or a tag). THE
|
|
10
|
+
* RAIL'S ONE GRID (plan-2026-11-19-kolbox-whats-left R3.1): the row is a grid on `--kol-kolbox-row-cols`, the tracks
|
|
11
|
+
* LabeledControlSection kolbox sets for every row it holds: two field columns and two 16 icon columns, 8 apart (in the
|
|
12
|
+
* 240 rail: 76, 76, 16, 16, his design's Stroke row, 149:26890). `first` takes column 1 (`span`: columns 1 and 2, a
|
|
13
|
+
* row of one field), `second` column 2, `trailing` the icon columns from the right, so a lone icon sits on the last and
|
|
14
|
+
* a pair on both. Outside a section the tracks are two equal columns and the trailing's own width. Each control fills
|
|
15
|
+
* its cell. It draws nothing of its own; the wrapper carries `data-property-row`.
|
|
16
|
+
*
|
|
17
|
+
* `variant="folio"` (Folio's SettingPair, Folio batch C, 2026-11-22, carried class for class): two 32 fields 8 apart at
|
|
18
|
+
* radius 4, padded 16, Folio's hairline round each (green while it has focus), each led by its `prefix` in the muted
|
|
19
|
+
* ink; the value in mono 12 / 16. `fields` as the default's, each a plain input's props. Chrome in kol-theme
|
|
20
|
+
* `.kol-field-pair--folio`.
|
|
21
|
+
*
|
|
8
22
|
* @param {Array} fields two Input prop sets — `[{ prefix: 'X', value, onChange, ... }, { prefix: 'Y', ... }]`
|
|
9
|
-
* @param {'float'|'filled'|'outline'} [variant] passed to both
|
|
23
|
+
* @param {'float'|'filled'|'outline'|'kolbox'|'folio'} [variant] passed to both Inputs; `kolbox` takes the slots below
|
|
10
24
|
* @param {'sm'|'md'|'lg'} [size] passed to both
|
|
25
|
+
* @param {ReactNode} [first] kolbox: the left cell
|
|
26
|
+
* @param {ReactNode} [second] kolbox: the right cell
|
|
27
|
+
* @param {ReactNode} [trailing] kolbox: the icon columns
|
|
28
|
+
* @param {boolean} [span] kolbox: `first` spans both field columns
|
|
11
29
|
* @param {string} [className]
|
|
12
30
|
*/
|
|
13
|
-
export default function FieldPair({ fields = [], variant, size, className = '' }) {
|
|
31
|
+
export default function FieldPair({ fields = [], variant, size, first, second, trailing, span = false, className = '', ...rest }) {
|
|
32
|
+
if (variant === 'kolbox') {
|
|
33
|
+
return (
|
|
34
|
+
<div {...rest} className={`grid min-w-0 grid-cols-[var(--kol-kolbox-row-cols,minmax(0,1fr)_minmax(0,1fr)_auto)] items-center gap-2 ${className}`.trim()} data-property-row>
|
|
35
|
+
<div className={`flex min-w-0 ${span ? 'col-span-2' : ''}`}>{first}</div>
|
|
36
|
+
{!span && <div className="flex min-w-0">{second}</div>}
|
|
37
|
+
{trailing && <div className="col-start-3 -col-end-1 flex items-center justify-end gap-2">{trailing}</div>}
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
if (variant === 'folio') {
|
|
42
|
+
return (
|
|
43
|
+
<div {...rest} className={`kol-field-pair--folio flex items-center gap-[8px] ${className}`.trim()}>
|
|
44
|
+
{fields.map(({ prefix, ...f }) => (
|
|
45
|
+
<label key={prefix} className="kol-field-pair-field flex h-[32px] min-w-0 flex-1 items-center rounded-[4px] border px-[16px]">
|
|
46
|
+
<span className="kol-field-pair-prefix shrink-0 pr-[4px]">{prefix}</span>
|
|
47
|
+
<input {...f} className="min-w-0 flex-1 bg-transparent outline-none" />
|
|
48
|
+
</label>
|
|
49
|
+
))}
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
14
53
|
return (
|
|
15
54
|
<div className={`flex items-center gap-2 ${className}`.trim()}>
|
|
16
55
|
{fields.slice(0, 2).map((f, i) => (
|