@kolkrabbi/kol-component 0.385.0 → 0.386.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.385.0",
3
+ "version": "0.386.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -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
- * `variant="kolbox"` (plan-2026-11-18-kolbox-system W31.2, 2026-11-18), carried class for class: a 16 box at radius 4 in a
9
- * 28 hit box, unchecked the field's oq-16 fill with an oq-24 line, checked the accent fill and line with your icons'
10
- * `check` at 12 in the on-accent ink; no label of its own (name it with `aria-label`; a row labels it), a role="checkbox"
11
- * button with aria-checked, the focus ring the accent's. Chrome in kol-theme `.kol-toggle-checkbox--kolbox`. */
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-checked={checked}
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
- * variant="kolbox" — kolbox's switch (plan-2026-11-18-kolbox-system W31.2, 2026-11-18), carried class for class:
10
- * a 28 × 16 track with a 12 knob 2 in, inside a 28-high hit box at radius 4; off the oq-24
11
- * track and the ink knob, on the accent track and the on-accent knob; one size, no label
12
- * (name it with `aria-label`; a row's LabeledControl gives the words), role="switch" with
13
- * aria-checked, the focus ring the accent's, disabled 40%. Chrome in kol-theme
14
- * `.kol-toggle-switch--kolbox`.
15
- *
16
- * variant="folio" — Folio's switch (Folio migration batch A, 2026-11-22), carried class for class: a 20 × 12
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
- if (variant === 'kolbox') {
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
- aria-pressed={checked}
75
+ role="switch"
76
+ aria-checked={checked}
106
77
  {...props}
107
78
  >
108
79
  <span className="toggle-switch-label">
@@ -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='default'] - The look. `kolbox` (plan-2026-11-18-kolbox-system W31.2, 2026-11-18):
33
- * kolbox's pad carried class for class: no stroke, the field's oq-16 ground at radius 4, 1px oq-24 guides, the puck in
34
- * the ink, the labels Inter 11 / 15 in oq-64; it also takes `w-full min-w-0`. Chrome in kol-theme `.kol-xy-pad--kolbox`.
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
- if (variant === 'kolbox') {
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="flex justify-between kol-helper-10 tracking-widest text-meta">
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 border border-oq-16 bg-fg-04 rounded cursor-crosshair touch-none"
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 border-t border-oq-08" />
108
- <div className="absolute inset-y-0 left-1/2 border-l border-oq-08" />
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="absolute w-3 h-3 -ml-1.5 -mt-1.5 rounded-full bg-fg-96 border border-oq-04 pointer-events-none"
92
+ className="kol-xy-pad-puck absolute pointer-events-none"
112
93
  style={{ left: `${puckX}%`, top: `${puckY}%` }}
113
94
  />
114
95
  </div>
@@ -1,58 +1,53 @@
1
1
  import { useEffect, useState } from 'react'
2
+ import Input, { useFieldCommit, selectOnFirstPress } from '../atoms/Input.jsx'
3
+ import Button from '../atoms/Button.jsx'
2
4
 
3
5
  /**
4
- * QuantityInput — Pick a whole-number quantity. a compact integer quantity picker with two control layouts.
6
+ * QuantityInput — Pick a whole-number quantity. a compact integer quantity picker with three control layouts.
5
7
  *
6
8
  * controls="chevron" (default) — value with a stacked up/down chevron pair
7
9
  * on the right, inside a full-width field.
8
10
  * controls="split" — a − value + pill (minus and plus flank the
9
11
  * value). The former `QuantityStepper`.
12
+ * controls="field" — the value in an `Input` (sm) between two icon `Button`s, − and +
13
+ * (your icons' `minus` and `plus`), 4 apart, the root as wide as its row:
14
+ * kolbox's stepper, every theme's since W2 run 2 (their look the theme's).
10
15
  *
11
- * Display-only value (not a text-editable input) — for an editable number
12
- * field with bump chevrons use `Stepper`. Size auto-adapts to the viewport
13
- * (sm < 768 ≤ md < 1024 ≤ lg) unless `size` pins it. Controlled: `value` +
14
- * `(next) => onChange`, clamped to [min, max].
16
+ * The value is typed in every layout (kolbox's, adopted in W2 run 2): Enter or leaving commits it, held to
17
+ * [min, max] and snapped to `step`; Escape restores; ArrowUp and ArrowDown step it. Size auto-adapts to the
18
+ * viewport (sm < 768 ≤ md < 1024 ≤ lg) unless `size` pins it. Controlled: `value` + `(next) => onChange`.
19
+ * `variant="kolbox"` and `"folio"` are accepted and draw `controls="field"` (plan-2026-11-29-one-set-fold W2 run 2;
20
+ * the old branches are in `_tmp/2026-11-29-one-set-fold/`).
15
21
  *
16
22
  * @param {number} value current quantity (default 1)
17
23
  * @param {Function} onChange (next) => void
18
24
  * @param {number} min lower bound (default 1)
19
25
  * @param {number} max upper bound (default 99)
20
- * @param {string} controls 'chevron' (default) | 'split'
26
+ * @param {string} controls 'chevron' (default) | 'split' | 'field'
21
27
  * @param {string} size 'sm' | 'md' | 'lg' — pins the responsive size
22
28
  * @param {string} unit a word after the value (`22 px`)
23
29
  * @param {string} ariaLabel what the value is; the − + read `Decrease <it>` / `Increase <it>` (default quantity)
24
- * @param {'folio'} variant also `folio` (Folio migration batch A, 2026-11-22): Folio's stepper, two 32 squares at radius
25
- * 4 with the rule line round the value (JetBrains Mono 12 / 16), the step glyphs 12 / 500;
26
- * 8 apart, the root as wide as its row; a bound dims its square to 40%
27
- * @param {number} step FOLIO: how far one press moves the value (default 1; the reader's sizes step by 2)
28
- * @param {ReactNode} down FOLIO: the − square's text (`A−`)
29
- * @param {ReactNode} up FOLIO: the + square's text (`A+`)
30
- * @param {string} downLabel FOLIO: the − square's name (`Smaller text`)
31
- * @param {string} upLabel FOLIO: the + square's name (`Larger text`)
32
- * @param {'kolbox'} variant also `kolbox` (Folio on kolbox, 2026-11-22): kolbox has no stepper of its own, so it is built
33
- * from its parts: `Input variant="kolbox"` (its sm field, `--kol-kolbox-ctl` high: the value
34
- * in mono with `unit` after it, typed and committed on Enter or leaving, ↑↓ step it) between
35
- * two kolbox icon Buttons, − and + (your icons' `minus` and `plus`), 4 apart, the root as wide
36
- * as its row. `step`, `min`, `max` as folio's: a typed value is held to the range and the step;
37
- * a button at a bound is disabled. `downLabel`, `upLabel` name the buttons (else
38
- * `Decrease <ariaLabel>`, `Increase <ariaLabel>`); `down`, `up` are not drawn (the set's glyphs are)
30
+ * @param {number} step how far one press moves the value in `field` (default 1); a typed value snaps to it
31
+ * @param {string} downLabel the − button's name in `field` (else `Decrease <ariaLabel>`)
32
+ * @param {string} upLabel the + button's name in `field` (else `Increase <ariaLabel>`)
33
+ * @param {ReactNode} down accepted, not drawn (folio's square text; the set's glyphs are)
34
+ * @param {ReactNode} up accepted, not drawn
39
35
  * @param {string} className extra classes on the root
40
36
  */
41
- import Input from '../atoms/Input.jsx'
42
- import Button from '../atoms/Button.jsx'
43
-
44
37
  const SIZE_MAP = {
45
38
  sm: { fontSize: 11, paddingY: 12, paddingX: 24, radius: 20, icon: 10 },
46
39
  md: { fontSize: 12, paddingY: 14, paddingX: 24, radius: 22, icon: 12 },
47
40
  lg: { fontSize: 14, paddingY: 16, paddingX: 24, radius: 24, icon: 14 },
48
41
  }
49
42
 
43
+ const THEME_WORDS = ['kolbox', 'folio']
44
+
50
45
  const QuantityInput = ({
51
46
  value = 1,
52
47
  onChange,
53
48
  min = 1,
54
49
  max = 99,
55
- controls = 'chevron',
50
+ controls: controlsProp = 'chevron',
56
51
  size,
57
52
  variant,
58
53
  unit,
@@ -92,32 +87,28 @@ const QuantityInput = ({
92
87
  return () => window.removeEventListener('resize', updateWidth)
93
88
  }, [])
94
89
 
90
+ /* the old theme words: accepted, they draw the field stepper they drew (on the retirement ledger) */
91
+ const controls = THEME_WORDS.includes(variant) ? 'field' : controlsProp
95
92
  const metrics = SIZE_MAP[resolvedSize] || SIZE_MAP.md
96
93
  const increment = () => { if (value < max) onChange?.(value + 1) }
97
94
  const decrement = () => { if (value > min) onChange?.(value - 1) }
98
95
 
99
- /* folio (Folio migration batch A, 2026-11-22): Folio's Stepper carried class for class (apps/folio Chrome.jsx), two 32
100
- * squares round the value, stepping by `step`; the chrome in kol-theme `.kol-quantity-input--folio` */
101
- if (variant === 'folio') {
102
- const stepCls = 'kol-quantity-input-step flex size-[32px] items-center justify-center rounded-[4px] border disabled:opacity-40'
103
- return (
104
- <div className={`kol-quantity-input--folio flex items-center gap-[8px] ${className}`.trim()}>
105
- <button type="button" aria-label={downLabel} disabled={value <= min} onClick={() => onChange?.(value - step)} className={stepCls}>{down}</button>
106
- <p className="kol-quantity-input-value flex-1 text-center tabular-nums">{value}{unit ? ` ${unit}` : ''}</p>
107
- <button type="button" aria-label={upLabel} disabled={value >= max} onClick={() => onChange?.(value + step)} className={stepCls}>{up}</button>
108
- </div>
109
- )
110
- }
96
+ /* a typed value, held to the range and snapped to the step (kolbox's, every layout's since W2 run 2) */
97
+ const to = (n) => Math.min(max, Math.max(min, min + Math.round((n - min) / step) * step))
98
+ const commit = (text) => { const n = parseFloat(text); if (Number.isFinite(n) && to(n) !== value) onChange?.(to(n)) }
99
+ const field = useFieldCommit(value, commit)
100
+ const typed = (style) => (
101
+ <input type="text" inputMode="numeric" aria-label={ariaLabel} spellCheck={false} {...field} onMouseDown={selectOnFirstPress}
102
+ style={{ fieldSizing: 'content', padding: 0, border: 'none', outline: 'none', background: 'transparent', ...style }} />
103
+ )
111
104
 
112
- /* kolbox (Folio on kolbox, 2026-11-22): kolbox's field between its two icon buttons */
113
- if (variant === 'kolbox') {
114
- const to = (n) => Math.min(max, Math.max(min, min + Math.round((n - min) / step) * step))
115
- const commit = (text) => { const n = parseFloat(text); if (Number.isFinite(n) && to(n) !== value) onChange?.(to(n)) }
105
+ /* controls="field" (kolbox's stepper, Folio on kolbox 2026-11-22): the field between its two icon buttons */
106
+ if (controls === 'field') {
116
107
  return (
117
108
  <div className={`flex min-w-0 items-center gap-1 ${className}`.trim()}>
118
- <Button variant="kolbox" iconOnly="minus" aria-label={downLabel ?? `Decrease ${ariaLabel}`} disabled={value <= min} onClick={() => onChange?.(to(value - step))} />
119
- <Input variant="kolbox" aria-label={ariaLabel} value={value} onCommit={commit} suffix={unit} className="flex-1" />
120
- <Button variant="kolbox" iconOnly="plus" aria-label={upLabel ?? `Increase ${ariaLabel}`} disabled={value >= max} onClick={() => onChange?.(to(value + step))} />
109
+ <Button iconOnly="minus" aria-label={downLabel ?? `Decrease ${ariaLabel}`} disabled={value <= min} onClick={() => onChange?.(to(value - step))} />
110
+ <Input size="sm" aria-label={ariaLabel} value={value} onCommit={commit} suffix={unit} className="flex-1" />
111
+ <Button iconOnly="plus" aria-label={upLabel ?? `Increase ${ariaLabel}`} disabled={value >= max} onClick={() => onChange?.(to(value + step))} />
121
112
  </div>
122
113
  )
123
114
  }
@@ -146,7 +137,7 @@ const QuantityInput = ({
146
137
  }}
147
138
  >
148
139
  <button type="button" onClick={decrement} disabled={value <= min} style={btn(value <= min)} aria-label="Decrease quantity">−</button>
149
- <span style={{ minWidth: '24px', textAlign: 'center', color: 'var(--kol-surface-on-primary)', fontFamily: 'var(--kol-font-family-mono)', fontSize: `${metrics.fontSize}px`, lineHeight: '120%' }}>{value}</span>
140
+ {typed({ minWidth: '24px', textAlign: 'center', color: 'var(--kol-surface-on-primary)', fontFamily: 'var(--kol-font-family-mono)', fontSize: `${metrics.fontSize}px`, lineHeight: '120%' })}
150
141
  <button type="button" onClick={increment} disabled={value >= max} style={btn(value >= max)} aria-label="Increase quantity">+</button>
151
142
  </div>
152
143
  )
@@ -168,7 +159,7 @@ const QuantityInput = ({
168
159
  fontFamily: 'var(--kol-font-family-mono)', boxSizing: 'border-box',
169
160
  }}
170
161
  >
171
- <span>{value}</span>
162
+ {typed({ color: 'inherit', font: 'inherit', lineHeight: 'inherit' })}
172
163
  <div style={{ position: 'absolute', right: `${metrics.paddingX}px`, top: '50%', transform: 'translateY(-50%)', display: 'flex', flexDirection: 'column' }}>
173
164
  <button type="button" onClick={increment} disabled={value >= max} style={{ backgroundColor: 'transparent', border: 'none', padding: '0', cursor: value >= max ? 'not-allowed' : 'pointer', opacity: value >= max ? 0.3 : 1, lineHeight: 0, display: 'block' }} aria-label="Increase quantity">
174
165
  <svg width={metrics.icon} height={metrics.icon} viewBox="0 0 12 12" fill="none">
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
2
- import Input, { selectOnFirstPress } from '../atoms/Input.jsx'
2
+ import Input from '../atoms/Input.jsx'
3
3
  import SliderPanel from './SliderPanel.jsx'
4
4
  import LabeledControl from './LabeledControl.jsx'
5
5
 
@@ -47,9 +47,8 @@ import LabeledControl from './LabeledControl.jsx'
47
47
  * @param {Object} props.style - forwarded to the wrapper; the seam for `--kol-slider-track` / `--kol-slider-playhead`
48
48
  * @param {number} props.defaultValue - alt-click the control resets to this (falls back to `min`). Same contract on Knob
49
49
  * @param {'input'|'value'|'none'} props.readout - `input` (default) an editable Input · `value` a plain right-aligned span, Knob's own display-only readout · `none`.
50
- * @param {'minimal'|'dual'|'scrub'|'panel'|'kolbox'} props.variant - `kolbox` (W31.2 batch 3): kolbox's track (2px oq-24, the run in the ink to the value, a 12 ink thumb) in a 24 row (`--kol-kolbox-ctl`); `readout` `value` (its default) the mono 12 value beside it, 40 wide, or `input` the track in an oq-16 field and the value in a text field 2 apart; no visible label (`aria-label` names it), `formatValue` defaults to the raw value · `dual` = two thumbs on one rail · `scrub` = a media scrubber: the thin track with the 4 × 28 pill knob (`.kol-playback-scrub`; `PlaybackBar`'s, 2026-10-02) · `panel` = the rack slider (was kol-hardware `Fader`, merged 2026-10-01): a drawn 2px track for a hardware panel; takes `value · onChange · min · max · step · label` plus `onHold`
51
- * @param {'folio'} props.variant - also `folio` (Folio migration batch A, 2026-11-22): Folio's slider, a 24 row, the 2px track in the rule with the run in the accent to a 12 accent thumb, the value (JetBrains Mono 12 / 16, `formatValue` its words, raw by default) 32 wide at the right, 12 off; no visible label (`aria-label`). Chrome in kol-theme `.kol-slider--folio`
52
- * @param {number[]} props.stops - kolbox only: values marked on the track, a 2 mark each under the thumb's centre (a variable font's named weights)
50
+ * @param {'minimal'|'dual'|'scrub'|'panel'} props.variant - `dual` = two thumbs on one rail; `scrub` = a media scrubber: the thin track with the 4 × 28 pill knob (`.kol-playback-scrub`; `PlaybackBar`'s, 2026-10-02); `panel` = the rack slider (was kol-hardware `Fader`, merged 2026-10-01): a drawn 2px track for a hardware panel; takes `value`, `onChange`, `min`, `max`, `step` and `label` plus `onHold`. `kolbox` and `folio` are accepted and draw `minimal` with the `value` readout by default (plan-2026-11-29-one-set-fold W2 run 2): ONE SLIDER, ITS LOOK THE THEME'S, the row's gap, the range's hit height and field, the run, the readout's width, padding and type are `--kol-slider-*` (kol-theme, Slider); the default theme leaves them unset, `data-theme-variant="kolbox"` sets kolbox's (the 2px oq-24 track with the run in the ink, a 16 range, the value mono 12 / 16 40 wide; with the `input` readout the track in an oq-16 field and the number 2 apart, at least 48). The old branches are in `_tmp/2026-11-29-one-set-fold/`
51
+ * @param {number[]} props.stops - values marked on the track, a 2 mark each under the thumb's centre (a variable font's named weights); every horizontal slider's since W2 run 2
53
52
  * @param {'horizontal'|'vertical'} props.direction - `vertical` stands the track upright at `height`, label above and readout below (2026-10-02 — the volume ranges were hand-drawn for want of it). On `panel`, horizontal takes the row and shows a readout
54
53
  * @param {number} props.height - vertical only — the track's length in px (default 96; panel 60)
55
54
  * @param {string} props['aria-label'] - names the range when there is no visible `label`
@@ -61,83 +60,9 @@ import LabeledControl from './LabeledControl.jsx'
61
60
  * @param {number|null} props.playhead - dual only — marker position in min…max; null renders nothing and attaches no listeners
62
61
  * @param {Function} props.onPlayheadChange - dual only — (next: number) => void; omit and the marker is not draggable and the rail does not seek
63
62
  */
64
- /* `variant="kolbox"` (plan-2026-11-18-kolbox-system W31.2 batch 3, 2026-11-18): kolbox's Slider carried class for
65
- * class, its own component so its draft is its own state. `readout` value (its default): the bare track, the value
66
- * beside it, 12 apart; `input`: the track in its own field, then 2 apart the number in a field as wide as its value
67
- * and at least 48. The number is a text field, not type="number": Chrome draws a number field's value in the OS
68
- * region's format ("0,08" on an Icelandic Mac) whatever the page's lang. A draft holds what is typed until it reads
69
- * as a number; kolbox's field keys: one press selects it, the arrows step it (Shift ten steps), Escape restores the value
70
- * from before the edit. Chrome in kol-theme `.kol-slider--kolbox`. */
71
- function SliderKolbox({ value, min, max, step, onChange, formatValue, readout = 'value', ariaLabel, stops, className = '', accent }) {
72
- const [draft, setDraft] = useState(null)
73
- const before = useRef(value)
74
- const format = formatValue ?? ((v) => v)
75
- const p = Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100))
76
- /* a stop: a 2 mark on the track, under the thumb's centre at that value (the thumb is 12, so its centre runs 6 to
77
- the width less 6) */
78
- const marks = stops?.length > 0 && stops.map((v) => (
79
- <span key={v} data-slider-stop={v} className="pointer-events-none absolute top-1/2 size-0.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-oq-64"
80
- style={{ left: `calc(6px + (100% - 12px) * ${(v - min) / (max - min)})` }} />
81
- ))
82
- const input = (
83
- <input
84
- type="range"
85
- className="kol-slider-input min-w-0 flex-1"
86
- style={{ '--p': `${p}%` }}
87
- aria-label={ariaLabel}
88
- value={value}
89
- min={min}
90
- max={max}
91
- step={step}
92
- onChange={(e) => onChange?.(Number(e.target.value))}
93
- />
94
- )
95
- const range = marks ? <span className="relative flex min-w-0 flex-1 items-center">{input}{marks}</span> : input
96
- if (readout === 'input') {
97
- return (
98
- <div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-slider--kolbox flex h-(--kol-kolbox-ctl) min-w-0 items-center gap-0.5 ${className}`}>
99
- <div className="kol-slider-field flex h-(--kol-kolbox-ctl) min-w-0 flex-1 items-center px-2">{range}</div>
100
- <input
101
- type="text"
102
- inputMode="decimal"
103
- aria-label={ariaLabel}
104
- className="kol-slider-number field-sizing-content h-(--kol-kolbox-ctl) min-w-12 shrink-0 px-2 text-left outline-none focus-visible:outline-1 focus-visible:-outline-offset-1"
105
- value={draft ?? String(format(value))}
106
- onChange={(e) => {
107
- /* parseFloat: a formatted value keeps its unit while it is typed ("45°") */
108
- const s = e.target.value, n = parseFloat(s)
109
- setDraft(s)
110
- if (s.trim() !== '' && Number.isFinite(n)) onChange?.(n)
111
- }}
112
- onMouseDown={selectOnFirstPress}
113
- onFocus={() => { before.current = value }}
114
- onBlur={() => setDraft(null)}
115
- onKeyDown={(e) => {
116
- if (e.key === 'Enter') { e.preventDefault(); e.currentTarget.blur(); return }
117
- /* Escape puts back the value from before the edit and leaves the field (kolbox's field, useKolboxField) */
118
- if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); setDraft(null); if (before.current !== value) onChange?.(before.current); e.currentTarget.blur(); return }
119
- if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return
120
- e.preventDefault()
121
- const dec = String(step).split('.')[1]?.length ?? 0
122
- const by = (e.shiftKey ? 10 : 1) * (e.key === 'ArrowUp' ? step : -step)
123
- const n = Math.min(max, Math.max(min, value + by))
124
- setDraft(null)
125
- before.current = Number(n.toFixed(dec))
126
- onChange?.(before.current)
127
- const el = e.currentTarget
128
- requestAnimationFrame(() => { if (document.activeElement === el) el.select() })
129
- }}
130
- />
131
- </div>
132
- )
133
- }
134
- return (
135
- <div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-slider--kolbox flex h-(--kol-kolbox-ctl) min-w-0 items-center gap-3 ${className}`}>
136
- {range}
137
- <span className="kol-slider-value w-10 shrink-0 text-right">{format(value)}</span>
138
- </div>
139
- )
140
- }
63
+ /* the old theme words in `variant`: accepted, drawn as the minimal slider with their old default readout, `value`
64
+ (plan-2026-11-29-one-set-fold W2 run 2, on the retirement ledger) */
65
+ const THEME_WORDS = ['kolbox', 'folio']
141
66
 
142
67
  const Slider = ({
143
68
  label,
@@ -173,6 +98,9 @@ const Slider = ({
173
98
  /* Label ↔ input pairing — the <label> is a sibling of the range input, so
174
99
  * without an htmlFor/id pair the visible label confers no accessible name. */
175
100
  const sliderId = useId()
101
+ const themeWord = THEME_WORDS.includes(variant)
102
+ if (themeWord) variant = 'minimal'
103
+ const readoutKind = readout ?? (themeWord ? 'value' : 'input')
176
104
 
177
105
  const handleChange = (e) => {
178
106
  if (onChange) {
@@ -239,8 +167,10 @@ const Slider = ({
239
167
  [onPlayheadChange, seekTo],
240
168
  )
241
169
 
170
+ const skipCommit = useRef(false)
242
171
  const commit = () => {
243
172
  setEditing(false)
173
+ if (skipCommit.current) { skipCommit.current = false; return }
244
174
  /* parseFloat, so a formatted value typed back (`45°`, `0,5`) still reads; an empty field reverts */
245
175
  const parsed = parseFloat(String(draft).replace(',', '.'))
246
176
  if (!Number.isFinite(parsed) || onChange == null) {
@@ -252,9 +182,21 @@ const Slider = ({
252
182
  setDraft(String(clamped))
253
183
  }
254
184
 
185
+ /* the readout's keys, every slider's (kolbox's, adopted in W2 run 2): Enter commits, Escape puts back the value from
186
+ * before the edit and leaves the field, ArrowUp and ArrowDown move it one `step` (Shift ten) and commit at once */
255
187
  const onKeyDown = (e) => {
256
188
  if (e.key === 'Enter') { e.currentTarget.blur() }
257
- if (e.key === 'Escape') { setDraft(displayValue); setEditing(false); e.currentTarget.blur() }
189
+ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); setDraft(displayValue); setEditing(false); skipCommit.current = true; e.currentTarget.blur() }
190
+ if ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && onChange && !disabled) {
191
+ e.preventDefault()
192
+ const dec = String(step).split('.')[1]?.length ?? 0
193
+ const by = (e.shiftKey ? 10 : 1) * (e.key === 'ArrowUp' ? step : -step)
194
+ const next = Number(Math.min(max, Math.max(min, value + by)).toFixed(dec))
195
+ onChange(next)
196
+ setDraft(fmt(next))
197
+ const el = e.currentTarget
198
+ requestAnimationFrame(() => { if (document.activeElement === el) el.select() })
199
+ }
258
200
  }
259
201
 
260
202
  /* alt-click anywhere on the control resets — Knob carries the same
@@ -266,24 +208,6 @@ const Slider = ({
266
208
  onChange(defaultValue ?? min)
267
209
  }
268
210
 
269
- if (variant === 'kolbox') {
270
- return <SliderKolbox value={value} min={min} max={max} step={step} onChange={onChange} formatValue={formatValue} readout={readout} ariaLabel={ariaLabel} stops={stops} className={className} accent={accent} />
271
- }
272
-
273
- /* folio (Folio migration batch A, 2026-11-22): Folio's Slider carried class for class (apps/folio Chrome.jsx): a 24
274
- * row, the native range (its track and thumb in kol-theme `.kol-slider--folio`), the value beside it, 32 wide */
275
- if (variant === 'folio') {
276
- const format = formatValue ?? ((n) => n)
277
- const run = `${((value - min) / (max - min)) * 100}%`
278
- return (
279
- <div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-slider--folio flex h-[24px] w-full items-center gap-[12px] ${className}`}>
280
- <input type="range" min={min} max={max} step={step} value={value} onChange={handleChange} aria-label={ariaLabel} style={{ '--run': run }}
281
- className="kol-slider-input h-[24px] min-w-0 flex-1 cursor-pointer appearance-none bg-transparent" />
282
- <span className="kol-slider-value w-[32px] shrink-0 text-right tabular-nums">{format(value)}</span>
283
- </div>
284
- )
285
- }
286
-
287
211
  if (variant === 'panel') {
288
212
  return <SliderPanel value={value} onChange={onChange} min={min} max={max} step={step} label={label} direction={direction} height={height} onHold={onHold} />
289
213
  }
@@ -298,11 +222,11 @@ const Slider = ({
298
222
  const labelClass = `kol-helper-12 text-fg-80 ${disabled ? 'opacity-50' : ''}`.trim()
299
223
  const row = ({ className: cls, style: st, onClick, children }) => {
300
224
  if (!label) return <div data-accent={accent === 'secondary' ? accent : undefined} className={cls} style={st} onClick={onClick}>{children}</div>
301
- const outer = cls.split(/\s+/).filter((c) => !/^(control-slider|shadow-none|h-7)$/.test(c)).join(' ')
225
+ const outer = cls.split(/\s+/).filter((c) => !/^(control-slider|control-slider--input|shadow-none|h-7)$/.test(c)).join(' ')
302
226
  return (
303
227
  <LabeledControl data-accent={accent === 'secondary' ? accent : undefined} horizontal label={labelEl} labelWidth="fit-content" labelClass={labelClass}
304
228
  className={`${/(^|\s)(hidden|block|flex|inline-flex|grid)(?=\s|$)/.test(outer) ? '' : 'inline-flex'} ${outer}`} style={st} onClick={onClick}>
305
- <div className={`flex w-full ${cls.split(/\s+/).filter((c) => /^(control-slider|shadow-none|h-7|gap-3)$/.test(c)).join(' ')}`}>{children}</div>
229
+ <div className={`flex w-full ${cls.split(/\s+/).filter((c) => /^(control-slider|control-slider--input|shadow-none|h-7)$/.test(c)).join(' ')}`}>{children}</div>
306
230
  </LabeledControl>
307
231
  )
308
232
  }
@@ -316,7 +240,7 @@ const Slider = ({
316
240
  /* an empty label is no label: `label1="" label2=""` (SettingsRange, RailSettings) drew an empty 16px row that pushed the rail low */
317
241
  const showLabels = !!(label1 || label2)
318
242
  const ratio = max > min ? (playhead - min) / (max - min) : 0
319
- return row({ className: `control-slider gap-3 shadow-none ${className}`, style, children: <>
243
+ return row({ className: `control-slider shadow-none ${className}`, style, children: <>
320
244
  <div className="flex-1">
321
245
  {showLabels && (
322
246
  <div
@@ -372,7 +296,7 @@ const Slider = ({
372
296
  const scrub = variant === 'scrub'
373
297
  const length = vertical ? height ?? 96 : size
374
298
 
375
- const range = (
299
+ const rangeInput = (
376
300
  <input
377
301
  id={sliderId}
378
302
  type="range"
@@ -384,12 +308,24 @@ const Slider = ({
384
308
  disabled={disabled}
385
309
  aria-label={ariaLabel}
386
310
  className={`${scrub ? 'kol-playback-scrub' : 'slider-black cursor-pointer disabled:cursor-default'} disabled:opacity-50 ${vertical ? '-rotate-90 flex-none' : length ? 'flex-none' : 'flex-1 w-full min-w-0'}`}
387
- /* upright, the drag is vertical — so the page's pan is the horizontal one */
388
- style={length ? { width: length, ...(vertical && { touchAction: 'pan-x' }) } : undefined}
311
+ /* upright, the drag is vertical — so the page's pan is the horizontal one. `--p` is the run's end, for a theme
312
+ * that draws the run (`--kol-slider-run`; kolbox the ink) */
313
+ style={{ '--p': `${Math.min(100, Math.max(0, ((value - min) / ((max - min) || 1)) * 100))}%`, ...(length && { width: length, ...(vertical && { touchAction: 'pan-x' }) }) }}
389
314
  />
390
315
  )
316
+ /* a stop (kolbox's, every slider's since W2 run 2): a 2 mark on the track under the thumb's centre at that value (the
317
+ thumb is 12, so its centre runs 6 in from each end of the track, which sits `--kol-slider-field-px` in) */
318
+ const range = stops?.length > 0 && !vertical && !scrub ? (
319
+ <span className={`relative flex items-center ${length ? 'flex-none' : 'min-w-0 flex-1'}`}>
320
+ {rangeInput}
321
+ {stops.map((v) => (
322
+ <span key={v} data-slider-stop={v} className="pointer-events-none absolute top-1/2 size-0.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-oq-64"
323
+ style={{ left: `calc(var(--kol-slider-field-px, 0px) + 6px + (100% - 12px - 2 * var(--kol-slider-field-px, 0px)) * ${(v - min) / ((max - min) || 1)})` }} />
324
+ ))}
325
+ </span>
326
+ ) : rangeInput
391
327
 
392
- const readoutNode = (readout ?? 'input') === 'input' ? (
328
+ const readoutNode = readoutKind === 'input' ? (
393
329
  <Input
394
330
  type="text"
395
331
  inputMode="decimal"
@@ -399,18 +335,19 @@ const Slider = ({
399
335
  chars={displayWidth}
400
336
  value={draft}
401
337
  disabled={disabled}
338
+ aria-label={ariaLabel}
402
339
  onFocus={(e) => { setEditing(true); e.target.select() }}
403
340
  onChange={(e) => setDraft(e.target.value)}
404
341
  onBlur={commit}
405
342
  onKeyDown={onKeyDown}
406
- inputClassName="text-center"
343
+ className="kol-slider-number"
407
344
  />
408
- ) : readout === 'value' ? (
345
+ ) : readoutKind === 'value' ? (
409
346
  /* `value` is Knob's readout, not a second design — a mixer running
410
347
  * ~23 faders in a 24px row cannot afford an input chip on every one, and
411
348
  * that is why the easy call sites could not move. */
412
349
  <span
413
- className={`kol-helper-12 shrink-0 w-fit text-right ${disabled ? 'opacity-50' : ''}`}
350
+ className={`kol-slider-value shrink-0 ${disabled ? 'opacity-50' : ''}`}
414
351
  style={fontSize ? { fontSize } : undefined}
415
352
  >
416
353
  {displayValue}
@@ -425,7 +362,7 @@ const Slider = ({
425
362
  </> })
426
363
  }
427
364
 
428
- return row({ className: `control-slider gap-3 shadow-none ${scrub ? 'h-7' : ''} ${className}`, style, onClick: onAltReset, children: <>
365
+ return row({ className: `control-slider shadow-none ${readoutKind === 'input' ? 'control-slider--input' : ''} ${scrub ? 'h-7' : ''} ${className}`, style, onClick: onAltReset, children: <>
429
366
  {range}
430
367
  {readoutNode}
431
368
  </> })