@kolkrabbi/kol-component 0.385.0 → 0.387.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/ToggleCheckbox.jsx +8 -23
- package/src/atoms/ToggleSwitch.jsx +13 -42
- package/src/atoms/XYPad.jsx +12 -31
- package/src/molecules/AlignmentGrid.jsx +13 -7
- package/src/molecules/ColorInputRow.jsx +31 -23
- package/src/molecules/ColorSwatch.jsx +17 -49
- package/src/molecules/ParamBindDot.jsx +49 -54
- package/src/molecules/QuantityInput.jsx +37 -46
- package/src/molecules/Slider.jsx +48 -111
- package/src/molecules/SwatchControls.jsx +12 -7
- package/src/molecules/SwatchGrid.jsx +6 -9
- package/src/organisms/ColorPickerPopover.jsx +1 -1
- package/src/organisms/SpectrumControls.jsx +54 -137
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.387.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"embla-carousel-react": "^8.6.0",
|
|
33
33
|
"pdfjs-dist": "^6.3.289",
|
|
34
34
|
"react-syntax-highlighter": "^16.1.1",
|
|
35
|
+
"@kolkrabbi/kol-search": "^0.3.0",
|
|
35
36
|
"@kolkrabbi/kol-growth": "^0.5.0",
|
|
36
|
-
"@kolkrabbi/kol-markdown": "^0.2.0"
|
|
37
|
-
"@kolkrabbi/kol-search": "^0.3.0"
|
|
37
|
+
"@kolkrabbi/kol-markdown": "^0.2.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@kolkrabbi/kol-icons": ">=0.69.0",
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
2
|
|
|
4
3
|
/* `variant="media"` (ContentFiltersCollection, kol-r2b2 2026-08-27): inside a
|
|
5
4
|
* media frame the unchecked hairline vanished over a photo; this variant's
|
|
6
5
|
* UNCHECKED box carries the media control's solid plate (`--kol-oq-12`) so it
|
|
7
6
|
* reads over any image. Checked stays the white plate + black check.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* ONE CHECKBOX, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W2 run 2): the box, its line and fill, the check and,
|
|
8
|
+
* with no label, the hit box are `--kol-check-*` (kol-theme kol-components-atoms.css, Toggle Checkbox); the default theme
|
|
9
|
+
* leaves them unset, `data-theme-variant="kolbox"` sets kolbox's (a 16 box at radius 4 in a 24 hit box, unchecked the
|
|
10
|
+
* field with the oq-24 line, checked the accent with the check in the on-accent ink). `variant="kolbox"` is accepted and
|
|
11
|
+
* draws the default checkbox (its branch is in `_tmp/2026-11-29-one-set-fold/`); with no `label`, name it with
|
|
12
|
+
* `aria-label`. */
|
|
12
13
|
const VARIANT_CLASS = { media: 'toggle-checkbox--media' }
|
|
13
14
|
const ToggleCheckbox = ({
|
|
14
15
|
label,
|
|
@@ -18,26 +19,10 @@ const ToggleCheckbox = ({
|
|
|
18
19
|
className = '',
|
|
19
20
|
hint,
|
|
20
21
|
accent,
|
|
22
|
+
'aria-label': ariaLabel,
|
|
21
23
|
...props
|
|
22
24
|
}) => {
|
|
23
25
|
if (accent === 'secondary') props['data-accent'] = accent
|
|
24
|
-
if (variant === 'kolbox') {
|
|
25
|
-
return (
|
|
26
|
-
<button
|
|
27
|
-
type="button"
|
|
28
|
-
role="checkbox"
|
|
29
|
-
aria-checked={checked}
|
|
30
|
-
onClick={() => onChange?.(!checked)}
|
|
31
|
-
className={`kol-toggle-checkbox--kolbox${checked ? ' is-active' : ''} inline-flex size-(--kol-kolbox-ctl) shrink-0 items-center justify-center outline-none focus-visible:outline-solid focus-visible:outline-1 ${className}`}
|
|
32
|
-
{...props}
|
|
33
|
-
>
|
|
34
|
-
<span className="kol-toggle-checkbox-box flex size-4 items-center justify-center border">
|
|
35
|
-
{checked && <IconLoader name="check" size={12} className="kol-kolbox-icon shrink-0" />}
|
|
36
|
-
</span>
|
|
37
|
-
</button>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
26
|
const handleChange = (event) => {
|
|
42
27
|
const next = event.target.checked
|
|
43
28
|
if (onChange) onChange(next)
|
|
@@ -52,7 +37,7 @@ const ToggleCheckbox = ({
|
|
|
52
37
|
type="checkbox"
|
|
53
38
|
checked={checked}
|
|
54
39
|
onChange={handleChange}
|
|
55
|
-
aria-
|
|
40
|
+
aria-label={ariaLabel}
|
|
56
41
|
/>
|
|
57
42
|
<span className="toggle-checkbox-indicator" aria-hidden="true">
|
|
58
43
|
<svg viewBox="0 0 12 9" width="12" height="9">
|
|
@@ -6,18 +6,14 @@ import React from 'react'
|
|
|
6
6
|
* variant="bare" (default) — label + track, no box
|
|
7
7
|
* variant="primary" — filled shell (surface-secondary), button geometry
|
|
8
8
|
* variant="outline" — bordered shell (border-oq-16), button geometry
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
* track round an 8 knob that travels 8, the hit box 24 high; off the rule track, on the
|
|
18
|
-
* accent, the knob the paper; one size, no label (`aria-label`), role="switch" with
|
|
19
|
-
* aria-checked. Chrome in kol-theme `.kol-toggle-switch--folio`.
|
|
20
|
-
*
|
|
9
|
+
* ONE SWITCH, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W2 run 2): the track, the knob, its travel and
|
|
10
|
+
* colours, the bare switch's hit box and the focus line are `--kol-switch-*` (kol-theme
|
|
11
|
+
* kol-components-atoms.css, Toggle Switch); the default theme leaves them unset and draws what
|
|
12
|
+
* it always drew, `data-theme-variant="kolbox"` sets kolbox's (a 28 × 16 track, a 12 knob 2 in,
|
|
13
|
+
* a 24 hit box 4 in at radius 4, off oq-24 and the ink, on the accent and the on-accent, one
|
|
14
|
+
* size). `variant="kolbox"` and `"folio"` are accepted and draw the bare switch (their branches
|
|
15
|
+
* are in `_tmp/2026-11-29-one-set-fold/`). Every switch is role="switch" with aria-checked.
|
|
16
|
+
|
|
21
17
|
* size="xs" / "sm" / "md" (default) / "lg" — shells match button heights
|
|
22
18
|
* (22/26/32/40); the track scales with size in all variants. xs is the
|
|
23
19
|
* panel rung (2026-09-01).
|
|
@@ -33,6 +29,8 @@ import React from 'react'
|
|
|
33
29
|
|
|
34
30
|
const SIZE_TYPE = { xs: 'kol-mono-8', sm: 'kol-mono-12', md: 'kol-mono-14', lg: 'kol-mono-16' }
|
|
35
31
|
const LEGACY_VARIANTS = { plain: 'bare', default: 'outline' }
|
|
32
|
+
/* the old theme words in `variant`: accepted, drawn as the bare switch (W2 run 2, on the retirement ledger) */
|
|
33
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
36
34
|
let warnedLabel = false
|
|
37
35
|
|
|
38
36
|
const ToggleSwitch = ({
|
|
@@ -58,35 +56,7 @@ const ToggleSwitch = ({
|
|
|
58
56
|
console.warn('ToggleSwitch: `label` is deprecated — wrap the switch in <LabeledControl horizontal label="…">')
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<button
|
|
64
|
-
type="button"
|
|
65
|
-
role="switch"
|
|
66
|
-
aria-checked={checked}
|
|
67
|
-
onClick={handleClick}
|
|
68
|
-
className={`kol-toggle-switch--kolbox inline-flex h-(--kol-kolbox-ctl) shrink-0 items-center px-1 outline-none focus-visible:outline-solid focus-visible:outline-1 disabled:opacity-40 ${className}`}
|
|
69
|
-
data-state={checked ? 'on' : 'off'}
|
|
70
|
-
{...props}
|
|
71
|
-
>
|
|
72
|
-
<span className="kol-toggle-switch-track flex h-4 w-7 items-center rounded-full p-0.5 transition-colors">
|
|
73
|
-
<span className={`kol-toggle-switch-knob size-3 rounded-full transition-transform${checked ? ' translate-x-3' : ''}`} />
|
|
74
|
-
</span>
|
|
75
|
-
</button>
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* folio (Folio migration batch A, 2026-11-22): Folio's Switch carried class for class (apps/folio Chrome.jsx) */
|
|
80
|
-
if (variant === 'folio') {
|
|
81
|
-
return (
|
|
82
|
-
<button type="button" role="switch" aria-checked={checked} onClick={handleClick} {...props}
|
|
83
|
-
className={`kol-toggle-switch--folio relative h-[12px] w-[20px] shrink-0 rounded-full transition-colors before:absolute before:inset-x-0 before:top-1/2 before:h-[24px] before:-translate-y-1/2 before:content-[''] ${className}`}>
|
|
84
|
-
<span className={`kol-toggle-switch-knob absolute left-[2px] top-[2px] size-[8px] rounded-full transition-transform ${checked ? 'translate-x-[8px]' : ''}`} />
|
|
85
|
-
</button>
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const resolvedVariant = LEGACY_VARIANTS[variant] || variant
|
|
59
|
+
const resolvedVariant = THEME_WORDS.includes(variant) ? 'bare' : LEGACY_VARIANTS[variant] || variant
|
|
90
60
|
|
|
91
61
|
const cls = [
|
|
92
62
|
'toggle-switch',
|
|
@@ -102,7 +72,8 @@ const ToggleSwitch = ({
|
|
|
102
72
|
className={cls}
|
|
103
73
|
data-state={checked ? 'on' : 'off'}
|
|
104
74
|
onClick={handleClick}
|
|
105
|
-
|
|
75
|
+
role="switch"
|
|
76
|
+
aria-checked={checked}
|
|
106
77
|
{...props}
|
|
107
78
|
>
|
|
108
79
|
<span className="toggle-switch-label">
|
package/src/atoms/XYPad.jsx
CHANGED
|
@@ -29,9 +29,11 @@ import { useRef } from 'react'
|
|
|
29
29
|
* @param {Function} onChange - `(x, y) => void` on pointer down and on every move while a button is held — the caller coalesces if it wants one patch per gesture
|
|
30
30
|
* @param {ReactNode} xLabel - Left label above the pad
|
|
31
31
|
* @param {ReactNode} yLabel - Right label above the pad
|
|
32
|
-
* @param {'default'|'kolbox'} [variant
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* @param {'default'|'kolbox'} [variant] - accepted and nothing (plan-2026-11-29-one-set-fold W2 run 2, on the retirement
|
|
33
|
+
* ledger): one pad, its look the theme's. The labels' type and ink, the ground, its line and radius, the guides and the
|
|
34
|
+
* puck are `--kol-xy-*` (kol-theme); the default theme leaves them unset, `data-theme-variant="kolbox"` sets kolbox's
|
|
35
|
+
* (no line, the field's ground at radius 4, 1px guides in the edge, the puck in the ink, the labels Inter 11 / 15 in
|
|
36
|
+
* oq-64). Every pad takes `w-full min-w-0`, as kolbox's did. The old branch is in `_tmp/2026-11-29-one-set-fold/`.
|
|
35
37
|
* @param {string} [className] - Extra classes on the wrapper
|
|
36
38
|
*/
|
|
37
39
|
export default function XYPad({
|
|
@@ -41,7 +43,6 @@ export default function XYPad({
|
|
|
41
43
|
onChange,
|
|
42
44
|
xLabel,
|
|
43
45
|
yLabel,
|
|
44
|
-
variant = 'default',
|
|
45
46
|
className = '',
|
|
46
47
|
}) {
|
|
47
48
|
const ref = useRef(null)
|
|
@@ -70,30 +71,10 @@ export default function XYPad({
|
|
|
70
71
|
const puckX = ((xValue - xMin) / span(xMax, xMin)) * 100
|
|
71
72
|
const puckY = (1 - (yValue - yMin) / span(yMax, yMin)) * 100
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<div className={`kol-xy-pad--kolbox flex w-full min-w-0 flex-col gap-1 ${className}`.trim()}>
|
|
76
|
-
<div className="kol-xy-pad-labels flex justify-between">
|
|
77
|
-
<span>{xLabel}</span>
|
|
78
|
-
<span>{yLabel}</span>
|
|
79
|
-
</div>
|
|
80
|
-
<div
|
|
81
|
-
ref={ref}
|
|
82
|
-
onPointerDown={onPointerDown}
|
|
83
|
-
onPointerMove={onPointerMove}
|
|
84
|
-
className="kol-xy-pad relative aspect-square w-full cursor-crosshair touch-none"
|
|
85
|
-
>
|
|
86
|
-
<div className="kol-xy-pad-guide absolute inset-x-0 top-1/2 h-px" />
|
|
87
|
-
<div className="kol-xy-pad-guide absolute inset-y-0 left-1/2 w-px" />
|
|
88
|
-
<div className="kol-xy-pad-puck pointer-events-none absolute -mt-1.5 -ml-1.5 size-3 rounded-full" style={{ left: `${puckX}%`, top: `${puckY}%` }} />
|
|
89
|
-
</div>
|
|
90
|
-
</div>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
74
|
+
/* one pad, its look the theme's (`--kol-xy-*`, kol-theme kol-components-atoms.css, XYPad) */
|
|
94
75
|
return (
|
|
95
|
-
<div className={`flex flex-col gap-1 ${className}`.trim()}>
|
|
96
|
-
<div className="
|
|
76
|
+
<div className={`kol-xy flex w-full min-w-0 flex-col gap-1 ${className}`.trim()}>
|
|
77
|
+
<div className="kol-xy-pad-labels flex justify-between">
|
|
97
78
|
<span>{xLabel}</span>
|
|
98
79
|
<span>{yLabel}</span>
|
|
99
80
|
</div>
|
|
@@ -101,14 +82,14 @@ export default function XYPad({
|
|
|
101
82
|
ref={ref}
|
|
102
83
|
onPointerDown={onPointerDown}
|
|
103
84
|
onPointerMove={onPointerMove}
|
|
104
|
-
className="relative w-full aspect-square
|
|
85
|
+
className="kol-xy-pad relative w-full aspect-square cursor-crosshair touch-none"
|
|
105
86
|
>
|
|
106
87
|
{/* crosshair guides */}
|
|
107
|
-
<div className="absolute inset-x-0 top-1/2
|
|
108
|
-
<div className="absolute inset-y-0 left-1/2
|
|
88
|
+
<div className="kol-xy-pad-guide absolute inset-x-0 top-1/2 h-px" />
|
|
89
|
+
<div className="kol-xy-pad-guide absolute inset-y-0 left-1/2 w-px" />
|
|
109
90
|
{/* puck */}
|
|
110
91
|
<div
|
|
111
|
-
className="
|
|
92
|
+
className="kol-xy-pad-puck absolute pointer-events-none"
|
|
112
93
|
style={{ left: `${puckX}%`, top: `${puckY}%` }}
|
|
113
94
|
/>
|
|
114
95
|
</div>
|
|
@@ -24,9 +24,14 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
24
24
|
* @param {Array} items - `[{ axis, mode, icon, title }]` cells (default the standard 6, three per axis)
|
|
25
25
|
* @param {'xs'|'sm'|'md'|'lg'} size - The strips' rung (default 'sm')
|
|
26
26
|
* @param {string} className - Extra classes on the wrapper
|
|
27
|
-
* @param {'
|
|
28
|
-
*
|
|
27
|
+
* @param {'stacked'|'strips'} [layout='stacked'] - `stacked`: the X strip over the Y strip. `strips` (kolbox's align row,
|
|
28
|
+
* plan-2026-11-18-kolbox-system W31.2 batch 3; a layout of its own since plan-2026-11-29-one-set-fold W2 run 4): the X
|
|
29
|
+
* and Y strips side by side, each filling its cell of a slot `FieldPair` (two cells 8 apart), each cell its own action;
|
|
30
|
+
* `items` carry the set's glyph names. The strips are ButtonGroup's icon group, which still takes its theme word until
|
|
31
|
+
* ButtonGroup folds (W3). `variant="kolbox"` and `"folio"` are accepted and draw `strips`; the old branch is in
|
|
32
|
+
* `_tmp/2026-11-29-one-set-fold/AlignmentGrid.pre-fields3.jsx`.
|
|
29
33
|
*/
|
|
34
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
30
35
|
const ALIGN_BUTTONS = [
|
|
31
36
|
{ axis: 'h', mode: 'start', icon: 'align-horizontal-left-solid', title: 'Align left' },
|
|
32
37
|
{ axis: 'h', mode: 'center', icon: 'align-horizontal-center-solid', title: 'Align horizontal center' },
|
|
@@ -36,16 +41,17 @@ const ALIGN_BUTTONS = [
|
|
|
36
41
|
{ axis: 'v', mode: 'end', icon: 'align-vertical-bottom-solid', title: 'Align bottom' },
|
|
37
42
|
]
|
|
38
43
|
|
|
39
|
-
export default function AlignmentGrid({ onAlign, items = ALIGN_BUTTONS, size = 'sm', className = '', variant }) {
|
|
44
|
+
export default function AlignmentGrid({ onAlign, items = ALIGN_BUTTONS, size = 'sm', className = '', layout: layoutProp, variant }) {
|
|
40
45
|
const strip = (axis) => items.filter((b) => b.axis === axis)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
const layout = layoutProp ?? (THEME_WORDS.includes(variant) ? 'strips' : 'stacked')
|
|
47
|
+
/* layout="strips" (kolbox's AlignmentRow carried): the two strips as icon groups, each filling its cell of a slot
|
|
48
|
+
* FieldPair (two cells 8 apart). `variant="kolbox"` on the ButtonGroup names its icon group build until W3 folds it. */
|
|
49
|
+
if (layout === 'strips') {
|
|
44
50
|
const group = (axis) => (
|
|
45
51
|
<ButtonGroup layout="joined" variant="kolbox" className="w-full"
|
|
46
52
|
options={strip(axis).map((b) => ({ icon: b.icon, ariaLabel: b.title, onPress: () => onAlign?.(b.axis, b.mode) }))} />
|
|
47
53
|
)
|
|
48
|
-
return <FieldPair
|
|
54
|
+
return <FieldPair className={className} first={group('h')} second={group('v')} />
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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, { selectOnFirstPress,
|
|
4
|
+
import Input, { selectOnFirstPress, useFieldCommit } from '../atoms/Input.jsx'
|
|
5
5
|
import FieldPair from './FieldPair.jsx'
|
|
6
6
|
import { usePopover, PopoverPanel, Tooltip } from '../utilities/Popover.jsx'
|
|
7
7
|
|
|
@@ -281,14 +281,14 @@ function ColorInputRowDefault({
|
|
|
281
281
|
)
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
/* ── kolbox
|
|
285
|
-
*
|
|
286
|
-
*
|
|
284
|
+
/* ── joined (kolbox's FillRow, plan-2026-11-18-kolbox-system W31.2 batch 5, 2026-11-18; `joined` for everyone since
|
|
285
|
+
* plan-2026-11-29-one-set-fold W2 run 3) ─────────────────────────────────────────────────────────────────────────────
|
|
286
|
+
* kolbox's FillRow (Figma 84:12831), carried from apps/kolbox/src/ui/FillRow.jsx: one joined field (the theme's field
|
|
287
|
+
* fill `--kol-color-row-bg`, radius 4, no 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
288
|
* 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
|
|
289
|
+
* value and 4 off the end); with `actions` the row is FieldPair's slot row: the field over both field columns of the rail's grid, the actions on its icon columns (R3.1). The
|
|
290
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
|
|
291
|
+
* `picker` (ColorPickerPopover: this row is a molecule and cannot import the organism, so the caller
|
|
292
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
293
|
* `resolved` on the swatch and its own text in the field. `opacity` 0 to 100 through `onOpacity` (read-only without it);
|
|
294
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. */
|
|
@@ -302,7 +302,7 @@ export function expandHex(raw) {
|
|
|
302
302
|
if (d.length === 3) return [...d].map((c) => c + c).join('')
|
|
303
303
|
return d.length === 6 ? d : null
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function ColorInputRowJoined({ label, value, resolved, onChange, onSwatch, opacity, onOpacity, actions, lit = false, hidden = false, clearable = false, picker: Picker, accent }) {
|
|
306
306
|
const hex = HEX_KOLBOX.test(String(value ?? '').replace('#', '')) ? String(value).replace('#', '').toUpperCase() : null
|
|
307
307
|
const swatch = resolved ?? (hex ? `#${hex}` : null)
|
|
308
308
|
const swatchRef = useRef(null)
|
|
@@ -316,18 +316,18 @@ function ColorInputRowKolbox({ label, value, resolved, onChange, onSwatch, opaci
|
|
|
316
316
|
},
|
|
317
317
|
contains: (t) => !!swatchRef.current?.contains(t),
|
|
318
318
|
}), [])
|
|
319
|
-
/* the hex and the opacity are
|
|
320
|
-
const hexField =
|
|
319
|
+
/* the hex and the opacity are commit fields (Input's useFieldCommit): Escape restores, the opacity's arrows step */
|
|
320
|
+
const hexField = useFieldCommit(hex ?? String(value ?? ''), (text) => {
|
|
321
321
|
if (clearable && !text) { if (value) onChange?.(null); return }
|
|
322
322
|
const d = expandHex(text)
|
|
323
323
|
if (d) onChange?.(`#${d.toLowerCase()}`)
|
|
324
324
|
}, { step: false })
|
|
325
325
|
const op = opacity == null ? null : Math.round(opacity)
|
|
326
|
-
const opField =
|
|
326
|
+
const opField = useFieldCommit(op, (text) => { const n = parseFloat(text); if (Number.isFinite(n)) onOpacity?.(Math.min(100, Math.max(0, n))) })
|
|
327
327
|
const field = (
|
|
328
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
329
|
<div className="flex min-w-0 flex-1 items-center gap-2 pr-2 pl-1.5" data-fill-hex>
|
|
330
|
-
<Tooltip
|
|
330
|
+
<Tooltip asChild label={label}>
|
|
331
331
|
<button
|
|
332
332
|
ref={swatchRef}
|
|
333
333
|
type="button"
|
|
@@ -374,21 +374,22 @@ function ColorInputRowKolbox({ label, value, resolved, onChange, onSwatch, opaci
|
|
|
374
374
|
onChange={({ value: v, opacity: o }) => { onChange?.(v.toLowerCase()); if (op != null && o !== op) onOpacity?.(o) }}
|
|
375
375
|
/>
|
|
376
376
|
)
|
|
377
|
-
const root = `kol-color-row--
|
|
377
|
+
const root = `kol-color-row--joined min-w-0 flex-1 ${hidden ? 'is-hidden' : ''}`
|
|
378
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
379
|
columns (FieldPair kolbox, R3.1); alone it is a field that fills its cell */
|
|
380
380
|
return actions
|
|
381
|
-
? <><FieldPair
|
|
381
|
+
? <><FieldPair span className={root} data-accent={accent === 'secondary' ? accent : undefined} data-fill-row first={field} trailing={actions} />{picker}</>
|
|
382
382
|
: <div className={`${root} flex h-(--kol-kolbox-ctl) items-center`} data-accent={accent === 'secondary' ? accent : undefined} data-fill-row>{field}{picker}</div>
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
/* ──
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
|
|
385
|
+
/* ── variant="readonly" (Folio's SwatchRow, Folio batch C, 2026-11-22, carried class for class; a variant of its own since
|
|
386
|
+
* plan-2026-11-29-one-set-fold W2 run 3, a different job: a colour shown, not typed). The swatch (the `picker`,
|
|
387
|
+
* ColorPickerPopover, handed in as the joined row's is: a molecule cannot import the organism), the `label` (12 / 16
|
|
388
|
+
* medium, taking the room) and the hex (mono 12 / 16, capitals, muted), 12 apart. `swatches` ([name, hex]) go to the
|
|
389
|
+
* picker; `onChange(hex)`. Chrome in kol-theme `.kol-color-row--readonly`, the hex in oq-64 (was Folio's muted). ── */
|
|
390
|
+
function ColorInputRowReadonly({ label, value, swatches, onChange, picker: Picker, className = '' }) {
|
|
390
391
|
return (
|
|
391
|
-
<div className=
|
|
392
|
+
<div className={`kol-color-row--readonly flex w-full items-center gap-[12px] ${className}`.trim()}>
|
|
392
393
|
{Picker && <Picker variant="folio" label={label} color={value} swatches={swatches} onChange={onChange} />}
|
|
393
394
|
<p className="kol-color-row-label min-w-0 flex-1 truncate">{label}</p>
|
|
394
395
|
<p className="kol-color-row-value shrink-0 uppercase">{value}</p>
|
|
@@ -396,7 +397,14 @@ function ColorInputRowFolio({ label, value, swatches, onChange, picker: Picker }
|
|
|
396
397
|
)
|
|
397
398
|
}
|
|
398
399
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
400
|
+
/* ONE ROW, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W2 run 3). Three builds, picked by what the row is for,
|
|
401
|
+
* never by the theme: the labelled row (default: palette refs, lock, token column), `joined` (the swatch, hex and
|
|
402
|
+
* opacity in one commit field, with `actions`, `picker`, `onSwatch`, `lit`, `hidden`, `clearable`), and
|
|
403
|
+
* `variant="readonly"` (a colour line, no field). `variant="kolbox"` draws `joined` and `variant="folio"` draws
|
|
404
|
+
* `readonly`, the builds those words named; the old branches are in `_tmp/2026-11-29-one-set-fold/`. */
|
|
405
|
+
const THEME_WORDS = { kolbox: 'joined', folio: 'readonly' }
|
|
406
|
+
export default function ColorInputRow({ variant, joined, ...props }) {
|
|
407
|
+
const build = THEME_WORDS[variant] ?? variant
|
|
408
|
+
if (build === 'readonly') return <ColorInputRowReadonly {...props} />
|
|
409
|
+
return (joined ?? build === 'joined') ? <ColorInputRowJoined {...props} /> : <ColorInputRowDefault {...props} />
|
|
402
410
|
}
|
|
@@ -16,28 +16,22 @@
|
|
|
16
16
|
* or 'control-sm' (26px — the kol-control-sm row height, so
|
|
17
17
|
* a swatch sits flush beside sm input chrome in a paint bar;
|
|
18
18
|
* ColorSwatchFieldSizing 2026-08-12). Default 24.
|
|
19
|
-
* radius — 'sm' (4px
|
|
19
|
+
* radius — 'sm' (4px) | 'tight' (2px) | 'none' | 'full' (circle).
|
|
20
|
+
* Unset, the theme's (`--kol-swatch-r`, 4px; kolbox 2px).
|
|
20
21
|
* Default was 'tight' until 2026-08-12 — flipped to 'sm' per
|
|
21
22
|
* the system radius law (containers are 4px everywhere);
|
|
22
23
|
* square-corner contexts opt out via 'tight'/'none'.
|
|
23
|
-
* frame — boolean (default true).
|
|
24
|
-
*
|
|
24
|
+
* frame — boolean (default true). The theme's ring inside the chip
|
|
25
|
+
* (`--kol-swatch-frame`; unset none, kolbox a 1px oq-24 line);
|
|
26
|
+
* false, none — used by tightly-packed grid layouts.
|
|
25
27
|
* variant — 'default' (border-based chrome) |
|
|
26
28
|
* 'halo' (macOS-port double box-shadow halo). Halo
|
|
27
|
-
* overrides `frame` since it provides its own ring.
|
|
28
|
-
* '
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
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.
|
|
29
|
+
* overrides `frame` since it provides its own ring.
|
|
30
|
+
* 'kolbox' and 'folio' are accepted and draw the default:
|
|
31
|
+
* ONE SWATCH, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold
|
|
32
|
+
* W2 run 3; their branches are in _tmp/2026-11-29-one-set-fold/).
|
|
33
|
+
* The selected chrome is the theme's too (`--kol-swatch-sel-border`,
|
|
34
|
+
* `-sel-ring`; kolbox the 2px accent ring 1 off the secondary surface).
|
|
41
35
|
* hoverable — boolean (default true). When false, no hover border
|
|
42
36
|
* state is applied even if `onClick` is set. For static
|
|
43
37
|
* chips that just open a popover (e.g. inspector fill /
|
|
@@ -66,6 +60,7 @@ const NAMED_PX = {
|
|
|
66
60
|
'control-sm': 26, // kol-control-sm outer height — paint-bar swatch flush with sm input chrome
|
|
67
61
|
}
|
|
68
62
|
|
|
63
|
+
/* unset: no class, the theme's `--kol-swatch-r` (kol-theme `.kol-color-swatch`) */
|
|
69
64
|
const RADIUS_CLASSES = {
|
|
70
65
|
none: 'rounded-none',
|
|
71
66
|
tight: 'rounded-[var(--kol-radius-2)]',
|
|
@@ -86,7 +81,7 @@ export default function ColorSwatch({
|
|
|
86
81
|
hex,
|
|
87
82
|
selected = false,
|
|
88
83
|
size = 24,
|
|
89
|
-
radius
|
|
84
|
+
radius,
|
|
90
85
|
frame = true,
|
|
91
86
|
variant = 'default',
|
|
92
87
|
hoverable = true,
|
|
@@ -97,34 +92,6 @@ export default function ColorSwatch({
|
|
|
97
92
|
className = '',
|
|
98
93
|
...rest
|
|
99
94
|
}) {
|
|
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
|
-
}
|
|
128
95
|
const interactive = typeof onClick === 'function'
|
|
129
96
|
const resolvedSize = NAMED_PX[size] ?? size
|
|
130
97
|
const isNamed = typeof resolvedSize === 'string'
|
|
@@ -132,7 +99,7 @@ export default function ColorSwatch({
|
|
|
132
99
|
const sizeStyle = isNamed ? null : { width: resolvedSize, height: resolvedSize }
|
|
133
100
|
|
|
134
101
|
const isHalo = variant === 'halo'
|
|
135
|
-
const radiusCls = RADIUS_CLASSES[radius] ??
|
|
102
|
+
const radiusCls = RADIUS_CLASSES[radius] ?? ''
|
|
136
103
|
|
|
137
104
|
/* Halo provides its own ring via box-shadow → no border classes.
|
|
138
105
|
* frame=false → consumer wants a borderless chip (e.g. swatch grids
|
|
@@ -146,9 +113,10 @@ export default function ColorSwatch({
|
|
|
146
113
|
* `frame` and `hoverable` are kept on the API but no longer drive a
|
|
147
114
|
* default-state border; they're advisory for future variants. */
|
|
148
115
|
const cls = [
|
|
149
|
-
'relative shrink-0 inline-flex overflow-hidden',
|
|
116
|
+
'kol-color-swatch relative shrink-0 inline-flex overflow-hidden',
|
|
150
117
|
radiusCls,
|
|
151
|
-
!isHalo && selected ? '
|
|
118
|
+
!isHalo && selected ? 'is-selected' : '',
|
|
119
|
+
showBorder && !selected ? 'is-framed' : '',
|
|
152
120
|
interactive ? 'cursor-pointer' : '',
|
|
153
121
|
sizeCls,
|
|
154
122
|
className,
|