@kolkrabbi/kol-component 0.375.0 → 0.377.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/ToggleSwitch.jsx +10 -0
- package/src/index.js +9 -1
- package/src/molecules/ButtonGroup.jsx +5 -1
- package/src/molecules/ButtonSplit.jsx +63 -0
- package/src/molecules/Header.jsx +96 -0
- package/src/molecules/MenuFloat.jsx +164 -0
- package/src/molecules/Modal.jsx +18 -26
- package/src/molecules/ModalHeader.jsx +5 -14
- package/src/molecules/QuickLookFrame.jsx +4 -3
- package/src/molecules/RailFloat.jsx +30 -23
- package/src/molecules/RailHeader.jsx +10 -33
- package/src/molecules/SettingsControls.jsx +100 -155
- package/src/molecules/Slider.jsx +32 -8
- package/src/organisms/NavRailFloat.jsx +9 -14
- package/src/organisms/ReadingContents.jsx +1 -1
- package/src/organisms/ReadingPanel.jsx +8 -9
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
|
-
import
|
|
2
|
+
import Header from './Header.jsx'
|
|
3
3
|
import { floatSurfaceClass } from '../utilities/tone.js'
|
|
4
4
|
|
|
5
|
-
/* taxonomy-ok: molecule —
|
|
5
|
+
/* taxonomy-ok: molecule — Header (molecule) in the header slot over a body and a footer slot; the float module every float Rail is drawn on */
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* RailFloat (was `FloatModule`, renamed 2026-11-12; the old name stays a deprecated alias) — the one float Rail shell (plan-2026-11-12-float-system W4.1; the user: *"why arent all rails in the same
|
|
9
9
|
* shell? also the floating nav?? because it should ALSO have a collapsed state"*). Three slots on the float surface at the
|
|
10
10
|
* sheet radius (plan-2026-11-12-float-rails-figma W4.1, his approved tree):
|
|
11
11
|
*
|
|
12
|
-
* header `header`, default a `
|
|
12
|
+
* header `header`, default a `Header` (the title, `actions`, expand, collapse-h, collapse-v); renders when any is given
|
|
13
13
|
* body the children, scrolling under the header with its scrollbar hidden
|
|
14
14
|
* footer `footer`, after the body, outside its scroll; renders only when given
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
* the footer hidden (never removed), drawn as the pill of `--kol-float-
|
|
16
|
+
* Collapsed-v is the SAME component (P14 *"EVEN THE FOLDED will get header body and footer"*): the same header, the body
|
|
17
|
+
* and the footer hidden (never removed), drawn as the pill of `--kol-float-collapsed-h`, fully round, at the module's width.
|
|
18
18
|
* PropertyRail (kol-shell), NavRail float and the reader's Contents draw on it. It lives in kol-component so NavRail float
|
|
19
19
|
* can use it without a reverse dependency; kol-shell re-exports it (the way NavRail itself moved, ARCHITECTURE §3 2026-10-22).
|
|
20
20
|
*
|
|
21
21
|
* Every size is a token of the float spec (docs/documentation/04-compositions/25-float-spec.md): the width
|
|
22
22
|
* `--kol-float-module-w` (`wide` `--kol-float-module-w-wide`), the radius `--kol-float-menu-r`, the rows
|
|
23
|
-
* `--kol-float-module-gap` (`compact` spacing-2), the
|
|
23
|
+
* `--kol-float-module-gap` (`compact` spacing-2), the collapsed-v pill `--kol-float-collapsed-h`.
|
|
24
24
|
*
|
|
25
|
-
* @param {ReactNode} [header] the header slot; unset, a
|
|
26
|
-
* @param {
|
|
27
|
-
*
|
|
28
|
-
* @param {ReactNode} [
|
|
29
|
-
* @param {
|
|
30
|
-
*
|
|
25
|
+
* @param {ReactNode} [header] the header slot; unset, a Header of `title` · `head` · `actions` · the toggles
|
|
26
|
+
* @param {'property'|'nav'} [headerVariant='property'] the Header's variant while open (`nav`: NavRail float's switcher,
|
|
27
|
+
* with `icon` and `onSwitch`); collapsed-v, the pill is always the plain title
|
|
28
|
+
* @param {ReactNode} [title] the header's title, and the collapsed pill's
|
|
29
|
+
* @param {ReactNode} [head] replaces the title in the open header (a consumer's own switcher)
|
|
30
|
+
* @param {ReactNode} [actions] the Header's `end`: before the toggles; not on the collapsed pill
|
|
31
|
+
* @param {Function} [onExpand] · {Function} [onCollapseH] the Header's expand and collapse-h; not on the collapsed pill
|
|
32
|
+
* @param {boolean} [collapsibleV] the collapse-v chevron in the header; `collapsedV` controlled, `defaultCollapsedV`
|
|
33
|
+
* uncontrolled, `onCollapseV(collapsedV)` on every press. Deprecated aliases: `foldable` ·
|
|
34
|
+
* `folded` · `defaultFolded` · `onFold`
|
|
31
35
|
* @param {boolean} [compact] the tool Rail's rhythm: rows spacing-2 apart (default `--kol-float-module-gap`)
|
|
32
36
|
* @param {boolean} [wide] the wide module width
|
|
33
37
|
* @param {number|string} [width] an explicit width (a phone's `100%`, a footprint token); unset, the module width
|
|
@@ -39,27 +43,30 @@ import { floatSurfaceClass } from '../utilities/tone.js'
|
|
|
39
43
|
*/
|
|
40
44
|
const INSET = { md: 'p-4', sm: 'p-3', none: '' }
|
|
41
45
|
|
|
42
|
-
export default function RailFloat({ header, title, head, actions,
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
+
export default function RailFloat({ header, headerVariant = 'property', icon, onSwitch, title, head, actions, onExpand, onCollapseH, collapsibleV, collapsedV, defaultCollapsedV, onCollapseV, foldable, folded, defaultFolded, onFold, compact = false, wide = false, width, inset = 'md', surface = 'solid', footer, as: Tag = 'section', className = '', bodyClassName = '', style, 'aria-label': ariaLabel, children }) {
|
|
47
|
+
const canV = collapsibleV ?? foldable ?? false
|
|
48
|
+
const ctlV = collapsedV ?? folded
|
|
49
|
+
const [ownV, setOwnV] = useState(defaultCollapsedV ?? defaultFolded ?? false)
|
|
50
|
+
const isV = canV && (ctlV ?? ownV)
|
|
51
|
+
const toggleV = () => { const next = !isV; if (ctlV === undefined) setOwnV(next); (onCollapseV ?? onFold)?.(next) }
|
|
46
52
|
const w = width ?? `var(--kol-float-module-w${wide ? '-wide' : ''})`
|
|
47
53
|
const label = ariaLabel ?? (typeof title === 'string' ? title : undefined)
|
|
48
54
|
const gap = compact ? 'gap-2' : 'gap-[var(--kol-float-module-gap)]'
|
|
49
|
-
const headerSlot = header ?? ((head || title || actions ||
|
|
50
|
-
<
|
|
55
|
+
const headerSlot = header ?? ((head || title || actions || canV || onExpand || onCollapseH) && (isV
|
|
56
|
+
? <Header variant="property" title={title} collapsedV onCollapseV={toggleV} />
|
|
57
|
+
: <Header variant={headerVariant} icon={icon} onSwitch={onSwitch} title={head ?? title} end={actions} onExpand={onExpand} onCollapseH={onCollapseH} onCollapseV={canV ? toggleV : undefined} />
|
|
51
58
|
))
|
|
52
|
-
const shape =
|
|
59
|
+
const shape = isV
|
|
53
60
|
? 'flex-row items-center rounded-full pl-4 pr-1.5'
|
|
54
61
|
: `flex-col ${gap} rounded-[var(--kol-float-menu-r)] ${INSET[inset] ?? INSET.md}`
|
|
55
62
|
return (
|
|
56
|
-
<Tag data-float-module={
|
|
57
|
-
className={`kol-float-module kol-float-chrome flex min-h-0 ${
|
|
63
|
+
<Tag data-float-module={isV ? 'collapsed' : 'open'} aria-label={label} style={{ ...style, width: w, ...(isV && { height: 'var(--kol-float-collapsed-h)' }) }}
|
|
64
|
+
className={`kol-float-module kol-float-chrome flex min-h-0 ${isV ? 'shrink-0' : ''} ${shape} ${floatSurfaceClass(surface, true)} ${className}`.replace(/\s+/g, ' ').trim()}>
|
|
58
65
|
{headerSlot}
|
|
59
|
-
<div data-float-module-body="" hidden={
|
|
66
|
+
<div data-float-module-body="" hidden={isV} className={`flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-width:none] ${gap} ${bodyClassName}`.trim()}>
|
|
60
67
|
{children}
|
|
61
68
|
</div>
|
|
62
|
-
{footer && <div data-float-module-footer="" hidden={
|
|
69
|
+
{footer && <div data-float-module-footer="" hidden={isV} className="flex shrink-0 flex-col">{footer}</div>}
|
|
63
70
|
</Tag>
|
|
64
71
|
)
|
|
65
72
|
}
|
|
@@ -1,31 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Button from '../atoms/Button.jsx'
|
|
1
|
+
import Header from './Header.jsx'
|
|
3
2
|
|
|
4
|
-
/* taxonomy-ok: molecule — the
|
|
3
|
+
/* taxonomy-ok: molecule — the rail kit's title line; `variant="float"` is Header variant="property" */
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
* RailHeader —
|
|
8
|
-
*
|
|
6
|
+
* RailHeader — the rail kit's title line (RailKit 2026-10-24): title (helper-14 uppercase), a subtitle, the header's
|
|
7
|
+
* actions before the × (which Rail draws). The node Rail's `header` slot takes it; SettingsPanel wears it.
|
|
9
8
|
*
|
|
10
|
-
* `variant="
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* `variant="float"` (plan-2026-11-12-float-rails-figma W4.1; the user: *"why is header not component?"*) — RailFloat's
|
|
14
|
-
* header, open and folded alike: the title slot filling the row and truncating (`kol-float-panel`, the emphasis ink), then
|
|
15
|
-
* `end`: the actions and the fold, 4 apart, 8 off the title. The TITLE IS A SLOT: text takes the panel role, a node
|
|
16
|
-
* (NavRail float's switcher row) fills the title position as it is. The fold is a float ghost sm Button whose glyph is the
|
|
17
|
-
* 12 chevron token (`--kol-float-chev-sm`, 14 on touch), never the float button's 18 glyph (P15 *"USE 12px chevron"*).
|
|
18
|
-
* Each part renders only when given: no `onFold`, no fold; no `actions`, no slot.
|
|
9
|
+
* `variant="float"` is `Header variant="property"` (plan-2026-11-12-one-header W1.1) — deprecated under this name, on the
|
|
10
|
+
* retirement ledger: `actions` → `end`, `collapsedV` / `onCollapseV` (the old `folded` / `onFold` still accepted).
|
|
11
|
+
* The default line stays here: it is not one of Header's four variants.
|
|
19
12
|
*
|
|
20
13
|
* @param {'default'|'float'} [variant='default']
|
|
21
|
-
* @param {ReactNode} [title]
|
|
22
|
-
* @param {ReactNode} [subtitle] default: the line under the title
|
|
23
|
-
* @param {ReactNode} [actions] default: before the ×; float: before the fold (expand, collapse)
|
|
24
|
-
* @param {boolean} [folded] float: the fold's state — ⌄ (Open) when folded, ⌃ (Fold) when open
|
|
25
|
-
* @param {Function} [onFold] float: the fold's press; unset, no fold
|
|
26
|
-
* @param {string} [className]
|
|
14
|
+
* @param {ReactNode} [title] · {ReactNode} [subtitle] · {ReactNode} [actions] · {string} [className]
|
|
27
15
|
*/
|
|
28
|
-
export default function RailHeader({ variant = 'default', title, subtitle, actions,
|
|
16
|
+
export default function RailHeader({ variant = 'default', title, subtitle, actions, collapsedV, onCollapseV, folded, onFold, className = '' }) {
|
|
29
17
|
if (variant !== 'float') {
|
|
30
18
|
return (
|
|
31
19
|
<div className={`flex min-w-0 items-center gap-2 ${className}`.trim()}>
|
|
@@ -37,16 +25,5 @@ export default function RailHeader({ variant = 'default', title, subtitle, actio
|
|
|
37
25
|
</div>
|
|
38
26
|
)
|
|
39
27
|
}
|
|
40
|
-
|
|
41
|
-
<Button variant="float" tone="ghost" size="sm" iconOnly={folded ? 'chevron-down' : 'chevron-up'} className="[--kol-float-ic:var(--kol-float-chev-sm)]"
|
|
42
|
-
aria-label={folded ? 'Open' : 'Fold'} aria-expanded={!folded} onClick={onFold} />
|
|
43
|
-
)
|
|
44
|
-
return (
|
|
45
|
-
<div data-float-module-header="" className={`flex w-full min-w-0 shrink-0 items-center justify-between gap-2 ${className}`.trim()}>
|
|
46
|
-
{title != null && title !== false && (isValidElement(title)
|
|
47
|
-
? <div data-rail-header-title="" className="flex min-w-0 flex-1">{title}</div>
|
|
48
|
-
: <span className="kol-float-panel text-emphasis min-w-0 flex-1 truncate">{title}</span>)}
|
|
49
|
-
{(actions || fold) && <span className="ml-auto flex shrink-0 items-center gap-1">{actions}{fold}</span>}
|
|
50
|
-
</div>
|
|
51
|
-
)
|
|
28
|
+
return <Header variant="property" title={title} end={actions} collapsedV={collapsedV ?? folded ?? false} onCollapseV={onCollapseV ?? onFold} className={className} />
|
|
52
29
|
}
|
|
@@ -1,163 +1,58 @@
|
|
|
1
1
|
import Input from '../atoms/Input.jsx'
|
|
2
2
|
import Button from '../atoms/Button.jsx'
|
|
3
|
-
import ButtonGroup from './ButtonGroup.jsx'
|
|
4
3
|
import ToggleSwitch from '../atoms/ToggleSwitch.jsx'
|
|
5
4
|
import Dropdown from './Dropdown.jsx'
|
|
6
5
|
import Slider from './Slider.jsx'
|
|
6
|
+
import TabsRow from './TabsRow.jsx'
|
|
7
7
|
import LabeledControl from './LabeledControl.jsx'
|
|
8
|
-
import { useEffect, useState } from 'react'
|
|
9
8
|
|
|
10
|
-
/* taxonomy-ok: molecule — the settings window's
|
|
9
|
+
/* taxonomy-ok: molecule — the settings window's composite parts, each built from shipped float atoms */
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
|
-
* The SETTINGS
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* The SETTINGS parts — what the generator settings window (`ModalDialog variant="settings"`) draws that is MORE than one
|
|
13
|
+
* base control (plan-2026-11-12-one-header W6.1; the user, P9: *"whats the point of taking a base, and wrapping it and
|
|
14
|
+
* adding nothing"*). A plain row is `LabeledControl variant="float"` around the base itself — `Slider variant="float"
|
|
15
|
+
* readout="input"`, `Dropdown variant="float"`, `Input variant="float"`, `TabsRow variant="float"`, a bare float
|
|
16
|
+
* `ToggleSwitch` in a `horizontal` row — never a Settings* part. What stays here composes several:
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* SettingsRange two handles on one track (From / To) — the dual Slider, boxed, both values number boxes
|
|
26
|
-
* SettingsSelect the boxed Dropdown (`options` `[{ value, label }]`)
|
|
27
|
-
* SettingsSegmented the boxed SegmentedToggle (Rows / Columns), the lit cell on oq-16
|
|
28
|
-
* SettingsToggle `LabeledControl variant="settings" horizontal`: its words, then the ToggleSwitch
|
|
29
|
-
* SettingsText the boxed Input (text or number)
|
|
30
|
-
* SettingsPoint an X / Y pair of number fields
|
|
31
|
-
* SettingsRamp an A→B row, `LabeledControl variant="settings" horizontal` (an 88 label column): value A · curve ·
|
|
32
|
-
* value B (`SettingsRampHead` the VALUE A · CURVE · VALUE B row)
|
|
33
|
-
* SettingsLights a list of points — X · Y · radius · intensity · delete — and Add light
|
|
34
|
-
* SettingsFieldMap the field's gradient strip: FIELD MAP over a 26 strip (`background`) and two captions
|
|
35
|
-
* SettingsDisclosure a group that starts closed: `LabeledControlSection variant="settings"` whose label is the toggle
|
|
36
|
-
* (the 12 chevron, More geometry … its note)
|
|
18
|
+
* SettingsGrid the two-up grid a group lays its rows in
|
|
19
|
+
* SettingsPoint an X / Y pair of float Inputs (the prefix names the axis)
|
|
20
|
+
* SettingsRamp an A→B row, `LabeledControl variant="float" horizontal`: value A · curve · value B (float Input ·
|
|
21
|
+
* float Dropdown · float Input); `SettingsRampHead` the VALUE A · CURVE · VALUE B row over them
|
|
22
|
+
* SettingsLights a list of points — X · Y · radius · intensity float Inputs · delete — and Add light
|
|
23
|
+
* SettingsFieldMap the field's gradient strip: FIELD MAP over a 26 strip (`background`) and two captions
|
|
24
|
+
* (SettingsDisclosure lives beside LabeledControlSection in organisms/SettingsPanel.jsx)
|
|
37
25
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
26
|
+
* Retired 2026-11-12 (deprecated aliases on the retirement ledger, each now rendering its base): SettingsCell →
|
|
27
|
+
* LabeledControl · SettingsSlider → Slider float `readout="input"` · SettingsRange → Slider `dual` · SettingsSelect →
|
|
28
|
+
* Dropdown float · SettingsSegmented → TabsRow float · SettingsToggle → LabeledControl `horizontal` + ToggleSwitch ·
|
|
29
|
+
* SettingsText → Input float. Their originals: `_tmp/2026-11-12-one-header/SettingsControls.before.jsx`.
|
|
30
|
+
*
|
|
31
|
+
* `disabled` on a part dims it to 40% and takes it out of the tab order (a control whose engine param does not exist yet).
|
|
40
32
|
*/
|
|
41
33
|
|
|
42
|
-
const FIELD = 'h-7 w-full min-w-0 rounded-[5px] border border-oq-16 bg-surface-primary'
|
|
43
|
-
const INK = 'text-[11px] leading-[13px] text-fg-96 font-(family-name:--kol-font-family-float)'
|
|
44
34
|
const LABEL = 'text-[10px] leading-[12px] text-oq-64 font-(family-name:--kol-font-family-float)'
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const Dim = ({ disabled, className = '', row, children, ...rest }) => (
|
|
35
|
+
const INK = 'text-[11px] leading-[13px] text-fg-96 font-(family-name:--kol-font-family-float)'
|
|
36
|
+
/* a float Dropdown filling its cell */
|
|
37
|
+
const FILL = 'w-full [&_.kol-dd-trigger]:w-full [&_.kol-dd-trigger]:justify-between'
|
|
38
|
+
const num = (s, fallback) => { const n = parseFloat(String(s).replace(',', '.')); return Number.isFinite(n) ? n : fallback }
|
|
39
|
+
|
|
40
|
+
/* a disabled part: a fieldset disables every input and button inside it natively */
|
|
41
|
+
const Dim = ({ disabled, className = '', children, ...rest }) => (
|
|
53
42
|
<fieldset disabled={disabled || undefined} aria-disabled={disabled || undefined} {...rest}
|
|
54
|
-
className={`min-w-0 m-0 p-0
|
|
55
|
-
{
|
|
43
|
+
className={`min-w-0 m-0 p-0 border-0 ${disabled ? 'opacity-40' : ''} ${className}`.trim()}>
|
|
44
|
+
{children}
|
|
56
45
|
</fieldset>
|
|
57
46
|
)
|
|
58
47
|
|
|
59
48
|
export const SettingsGrid = ({ className = '', children }) => <div className={`grid grid-cols-2 gap-x-3 gap-y-[7px] ${className}`.trim()}>{children}</div>
|
|
60
49
|
|
|
61
|
-
export function
|
|
62
|
-
return (
|
|
63
|
-
<Dim disabled={disabled} className={`${span === 2 ? 'col-span-2' : ''} ${className}`.trim()} {...rest}>
|
|
64
|
-
<LabeledControl variant="settings" label={label}>{children}</LabeledControl>
|
|
65
|
-
</Dim>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/* a slider's value as a number box (the float spec: a slider's value is the caller's number box, never raw text — the
|
|
70
|
-
* user's Figma issue 60, "no Input shown, just raw text"): the formatted value at rest, typed numbers commit on Enter or
|
|
71
|
-
* blur, clamped to the range; Escape reverts */
|
|
72
|
-
function NumberBox({ value, onCommit, min, max, format, disabled, label, fit = false, className = '' }) {
|
|
73
|
-
const [draft, setDraft] = useState(null)
|
|
74
|
-
useEffect(() => { setDraft(null) }, [value])
|
|
75
|
-
const commit = () => {
|
|
76
|
-
const n = parseFloat(String(draft ?? '').replace(',', '.'))
|
|
77
|
-
if (draft != null && Number.isFinite(n)) onCommit?.(Math.min(max, Math.max(min, n)))
|
|
78
|
-
setDraft(null)
|
|
79
|
-
}
|
|
80
|
-
return (
|
|
81
|
-
<input type="text" inputMode="decimal" value={draft ?? format(value)} disabled={disabled} aria-label={label}
|
|
82
|
-
onFocus={(e) => { setDraft(String(value)); requestAnimationFrame(() => e.target.select()) }} onChange={(e) => setDraft(e.target.value)} onBlur={commit}
|
|
83
|
-
onKeyDown={(e) => { if (e.key === 'Enter') e.currentTarget.blur(); if (e.key === 'Escape') { setDraft(null); requestAnimationFrame(() => e.target.blur()) } }}
|
|
84
|
-
style={fit ? { width: `${Math.max(1, String(draft ?? format(value)).length)}ch` } : undefined}
|
|
85
|
-
className={`${MONO} min-w-0 bg-transparent border-0 p-0 focus:outline-none tabular-nums ${className}`.trim()} />
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function SettingsSlider({ value, onChange, min = 0, max = 1, step = 0.01, format = (v) => String(v), disabled, 'aria-label': ariaLabel }) {
|
|
90
|
-
return (
|
|
91
|
-
<Dim disabled={disabled} className={FIELD} row="gap-3 pl-[9px] pr-2">
|
|
92
|
-
<Slider variant="float" readout="none" value={value} onChange={onChange} min={min} max={max} step={step} disabled={disabled}
|
|
93
|
-
aria-label={ariaLabel} className="flex-1 min-w-0 [&_.kol-slider-float]:h-4" />
|
|
94
|
-
<NumberBox value={value} onCommit={onChange} min={min} max={max} format={format} disabled={disabled} label={`${ariaLabel ?? 'Value'} value`} className="w-[52px] shrink-0" />
|
|
95
|
-
</Dim>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function SettingsRange({ value = [0, 1], onChange, min = 0, max = 1, step = 0.01, format = (v) => String(v), disabled, 'aria-label': ariaLabel }) {
|
|
100
|
-
const [a, b] = value
|
|
101
|
-
return (
|
|
102
|
-
<Dim disabled={disabled} className={FIELD} row="gap-2 px-2">
|
|
103
|
-
<NumberBox value={a} onCommit={(v) => onChange?.([Math.min(v, b), b])} min={min} max={max} format={format} disabled={disabled} label={`${ariaLabel ?? 'Range'} from`} className="shrink-0" fit />
|
|
104
|
-
<Slider variant="dual" value={a} value2={b} min={min} max={max} step={step} aria-label={ariaLabel}
|
|
105
|
-
onChange={(v) => onChange?.([Math.min(v, b), b])} onChange2={(v) => onChange?.([a, Math.max(v, a)])}
|
|
106
|
-
label1="" label2="" className="flex-1 min-w-0" />
|
|
107
|
-
<NumberBox value={b} onCommit={(v) => onChange?.([a, Math.max(v, a)])} min={min} max={max} format={format} disabled={disabled} label={`${ariaLabel ?? 'Range'} to`} className="shrink-0 text-right" fit />
|
|
108
|
-
</Dim>
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function SettingsSelect({ value, onChange, options = [], disabled, ariaLabel, className = '' }) {
|
|
113
|
-
return (
|
|
114
|
-
<Dim disabled={disabled} className="w-full">
|
|
115
|
-
<Dropdown value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} size="sm"
|
|
116
|
-
className={`w-full [&_.kol-dd-trigger]:w-full [&_.kol-dd-trigger]:!h-7 [&_.kol-dd-trigger]:!rounded-[5px] [&_.kol-dd-trigger]:!border [&_.kol-dd-trigger]:!border-(--kol-oq-16) [&_.kol-dd-trigger]:!bg-(--kol-surface-primary) [&_.kol-dd-trigger]:!px-2 [&_.kol-dd-trigger]:!text-[11px] [&_.kol-dd-trigger]:!font-normal [&_.kol-dd-trigger]:!text-(--kol-fg-96) [&_.kol-dd-trigger]:font-(family-name:--kol-font-family-float) [&_.kol-dd-trigger]:justify-between [&_.kol-dd-caret]:text-(--kol-oq-64) ${className}`.trim()} />
|
|
117
|
-
</Dim>
|
|
118
|
-
)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function SettingsSegmented({ value, onChange, options = [], disabled, ariaLabel }) {
|
|
122
|
-
return (
|
|
123
|
-
<Dim disabled={disabled} className={`${FIELD} p-0.5`}>
|
|
124
|
-
<ButtonGroup layout="joined" value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} size="sm"
|
|
125
|
-
className="!flex w-full h-full !border-0 !bg-transparent !p-0 gap-0 [&_.kol-seg-cell]:flex-1 [&_.kol-seg-cell]:h-full [&_.kol-seg-cell]:!rounded-[3px] [&_.kol-seg-cell]:!border-0 [&_.kol-seg-cell]:!bg-transparent [&_.kol-seg-cell]:!text-[10px] [&_.kol-seg-cell]:!text-(--kol-oq-64) [&_.kol-seg-cell]:font-(family-name:--kol-font-family-float) [&_.kol-seg-cell.is-active]:!bg-(--kol-oq-16) [&_.kol-seg-cell.is-active]:!text-(--kol-fg-96) [&_.kol-seg-cell.is-active]:font-medium" />
|
|
126
|
-
</Dim>
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function SettingsToggle({ label, checked, onChange, disabled }) {
|
|
131
|
-
return (
|
|
132
|
-
<Dim disabled={disabled} className="h-7" row="min-w-0">
|
|
133
|
-
<LabeledControl variant="settings" horizontal label={label} labelClass={INK}>
|
|
134
|
-
<ToggleSwitch checked={!!checked} onChange={onChange} aria-label={label} disabled={disabled} />
|
|
135
|
-
</LabeledControl>
|
|
136
|
-
</Dim>
|
|
137
|
-
)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function SettingsText({ value, onChange, onCommit, type = 'text', placeholder, disabled, 'aria-label': ariaLabel, className = '' }) {
|
|
141
|
-
return (
|
|
142
|
-
<Dim disabled={disabled} className="w-full">
|
|
143
|
-
<Input variant="outline" size="sm" type={type} value={value ?? ''} placeholder={placeholder} aria-label={ariaLabel}
|
|
144
|
-
onChange={onChange ? (e) => onChange(type === 'number' ? Number(e.target.value) : e.target.value) : undefined}
|
|
145
|
-
onCommit={onCommit} disabled={disabled}
|
|
146
|
-
className={`${FIELD} !px-2 !py-0 [&_input]:text-[11px] [&_input]:text-(--kol-fg-96) [&_input]:font-(family-name:--kol-font-family-float) ${className}`.trim()} />
|
|
147
|
-
</Dim>
|
|
148
|
-
)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export function SettingsPoint({ value = [0.5, 0.5], onChange, min, max, step = 0.01, disabled, 'aria-label': ariaLabel }) {
|
|
50
|
+
export function SettingsPoint({ value = [0.5, 0.5], onChange, min, max, disabled, 'aria-label': ariaLabel }) {
|
|
152
51
|
const [x, y] = value
|
|
153
52
|
const clamp = (n) => Math.min(max ?? Infinity, Math.max(min ?? -Infinity, n))
|
|
154
53
|
const field = (axis, v, set) => (
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
<input type="number" value={v} min={min} max={max} step={step} disabled={disabled} aria-label={`${ariaLabel ?? 'Point'} ${axis}`}
|
|
158
|
-
onChange={(e) => { const n = Number(e.target.value); if (Number.isFinite(n)) set(clamp(n)) }}
|
|
159
|
-
className={`${INK} w-full min-w-0 bg-transparent border-0 p-0 focus:outline-none tabular-nums`} />
|
|
160
|
-
</label>
|
|
54
|
+
<Input variant="float" size="sm" prefix={axis} value={String(v)} disabled={disabled} aria-label={`${ariaLabel ?? 'Point'} ${axis}`}
|
|
55
|
+
onCommit={(s) => set(clamp(num(s, v)))} width="100%" />
|
|
161
56
|
)
|
|
162
57
|
return (
|
|
163
58
|
<Dim disabled={disabled} className="grid grid-cols-2 gap-2">
|
|
@@ -167,8 +62,9 @@ export function SettingsPoint({ value = [0.5, 0.5], onChange, min, max, step = 0
|
|
|
167
62
|
)
|
|
168
63
|
}
|
|
169
64
|
|
|
65
|
+
/* the head over a ramp table: an empty label column (the float label width), then the three columns */
|
|
170
66
|
export const SettingsRampHead = () => (
|
|
171
|
-
<div className="grid grid-cols-[
|
|
67
|
+
<div className="grid grid-cols-[var(--kol-float-label-w)_minmax(0,87fr)_minmax(0,122fr)_minmax(0,87fr)] gap-x-2 pb-0.5" aria-hidden="true">
|
|
172
68
|
<span />
|
|
173
69
|
{['Value A', 'Curve', 'Value B'].map((t) => <span key={t} className={`${LABEL} uppercase text-center`}>{t}</span>)}
|
|
174
70
|
</div>
|
|
@@ -176,20 +72,19 @@ export const SettingsRampHead = () => (
|
|
|
176
72
|
|
|
177
73
|
export function SettingsRamp({ label, value = { a: 0, b: 1, curve: 'linear' }, onChange, curves = [], disabled, partial, ...rest }) {
|
|
178
74
|
const set = (k) => (v) => onChange?.({ ...value, [k]: v })
|
|
179
|
-
const
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
className={`${FIELD} ${INK} px-2 focus:outline-none focus-visible:shadow-[var(--kol-float-focus)] tabular-nums ${partial?.[k] ? 'opacity-40' : ''}`} />
|
|
75
|
+
const box = (k) => (
|
|
76
|
+
<Input variant="float" size="sm" value={String(value[k])} aria-label={`${label} value ${k.toUpperCase()}`} disabled={disabled || partial?.[k]}
|
|
77
|
+
onCommit={(s) => set(k)(num(s, value[k]))} width="100%" className={partial?.[k] ? 'opacity-40' : ''} />
|
|
183
78
|
)
|
|
184
79
|
return (
|
|
185
80
|
<Dim disabled={disabled} {...rest}>
|
|
186
|
-
<LabeledControl variant="
|
|
81
|
+
<LabeledControl variant="float" horizontal label={label}>
|
|
187
82
|
<div className="grid grid-cols-[minmax(0,87fr)_minmax(0,122fr)_minmax(0,87fr)] gap-x-2 items-center">
|
|
188
|
-
{
|
|
83
|
+
{box('a')}
|
|
189
84
|
<div className={partial?.curve ? 'opacity-40' : ''}>
|
|
190
|
-
<
|
|
85
|
+
<Dropdown variant="float" size="sm" value={value.curve} onChange={set('curve')} options={curves} ariaLabel={`${label} curve`} disabled={disabled || partial?.curve} className={FILL} />
|
|
191
86
|
</div>
|
|
192
|
-
{
|
|
87
|
+
{box('b')}
|
|
193
88
|
</div>
|
|
194
89
|
</LabeledControl>
|
|
195
90
|
</Dim>
|
|
@@ -198,25 +93,23 @@ export function SettingsRamp({ label, value = { a: 0, b: 1, curve: 'linear' }, o
|
|
|
198
93
|
|
|
199
94
|
export function SettingsLights({ value = [], onChange, disabled }) {
|
|
200
95
|
const set = (i, k, n) => onChange?.(value.map((l, j) => (j === i ? { ...l, [k]: n } : l)))
|
|
201
|
-
const cell = (i, k, v, label
|
|
202
|
-
<
|
|
203
|
-
|
|
204
|
-
className={`${FIELD} ${INK} px-2 focus:outline-none focus-visible:shadow-[var(--kol-float-focus)] tabular-nums`} />
|
|
96
|
+
const cell = (i, k, v, label) => (
|
|
97
|
+
<Input variant="float" size="sm" value={String(v)} aria-label={`Light ${i + 1} ${label}`} width="100%"
|
|
98
|
+
onCommit={(s) => set(i, k, num(s, v))} />
|
|
205
99
|
)
|
|
206
100
|
return (
|
|
207
101
|
<Dim disabled={disabled} className="flex flex-col gap-1">
|
|
208
|
-
<div className="grid grid-cols-[
|
|
102
|
+
<div className="grid grid-cols-[repeat(4,minmax(0,1fr))_28px] gap-x-2 pb-0.5" aria-hidden="true">
|
|
209
103
|
{['X', 'Y', 'Radius', 'Intensity'].map((t) => <span key={t} className={`${LABEL} uppercase`}>{t}</span>)}
|
|
210
104
|
<span />
|
|
211
105
|
</div>
|
|
212
106
|
{value.map((l, i) => (
|
|
213
|
-
<div key={i} className="grid grid-cols-[
|
|
107
|
+
<div key={i} className="grid grid-cols-[repeat(4,minmax(0,1fr))_28px] gap-x-2 items-center">
|
|
214
108
|
{cell(i, 'x', l.x, 'X')}{cell(i, 'y', l.y, 'Y')}{cell(i, 'radius', l.radius, 'radius')}{cell(i, 'intensity', l.intensity, 'intensity')}
|
|
215
|
-
<Button tone="ghost"
|
|
109
|
+
<Button variant="float" tone="ghost" size="sm" iconOnly="trash" aria-label={`Delete light ${i + 1}`} onClick={() => onChange?.(value.filter((_, j) => j !== i))} />
|
|
216
110
|
</div>
|
|
217
111
|
))}
|
|
218
|
-
<
|
|
219
|
-
className={`${INK} self-start h-7 px-2 rounded-[5px] hover:bg-(--kol-oq-08) focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]`}>+ Add light</button>
|
|
112
|
+
<Button variant="float" tone="ghost" size="sm" className="self-start" onClick={() => onChange?.([...value, { x: 0.5, y: 0.5, radius: 0.3, intensity: 1 }])}>+ Add light</Button>
|
|
220
113
|
</Dim>
|
|
221
114
|
)
|
|
222
115
|
}
|
|
@@ -233,3 +126,55 @@ export function SettingsFieldMap({ background, left, right, label = 'Field map'
|
|
|
233
126
|
</div>
|
|
234
127
|
)
|
|
235
128
|
}
|
|
129
|
+
|
|
130
|
+
/* ── retired 2026-11-12: each renders its base; on the retirement ledger until no repo imports it ─────────────────── */
|
|
131
|
+
|
|
132
|
+
/** @deprecated 2026-11-12 — `LabeledControl variant="float"` around the control (`col-span-2` for a wide cell) */
|
|
133
|
+
export function SettingsCell({ label, span = 1, disabled, className = '', children, ...rest }) {
|
|
134
|
+
return (
|
|
135
|
+
<Dim disabled={disabled} className={`${span === 2 ? 'col-span-2' : ''} ${className}`.trim()} {...rest}>
|
|
136
|
+
<LabeledControl variant="float" label={label}>{children}</LabeledControl>
|
|
137
|
+
</Dim>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** @deprecated 2026-11-12 — `Slider variant="float" readout="input"` (`format` → `formatValue`) */
|
|
142
|
+
export function SettingsSlider({ value, onChange, min = 0, max = 1, step = 0.01, format, disabled, 'aria-label': ariaLabel }) {
|
|
143
|
+
return <Slider variant="float" readout="input" value={value} onChange={onChange} min={min} max={max} step={step} formatValue={format} disabled={disabled} aria-label={ariaLabel} />
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** @deprecated 2026-11-12 — `Slider variant="dual"` (`value` / `value2`, the formatted values as `label1` / `label2`) */
|
|
147
|
+
export function SettingsRange({ value = [0, 1], onChange, min = 0, max = 1, step = 0.01, format = (v) => String(v), disabled, 'aria-label': ariaLabel }) {
|
|
148
|
+
const [a, b] = value
|
|
149
|
+
return (
|
|
150
|
+
<Slider variant="dual" value={a} value2={b} min={min} max={max} step={step} disabled={disabled} aria-label={ariaLabel} label1={format(a)} label2={format(b)}
|
|
151
|
+
onChange={(v) => onChange?.([Math.min(v, b), b])} onChange2={(v) => onChange?.([a, Math.max(v, a)])} />
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** @deprecated 2026-11-12 — `Dropdown variant="float"` */
|
|
156
|
+
export function SettingsSelect({ value, onChange, options = [], disabled, ariaLabel, className = '' }) {
|
|
157
|
+
return <Dropdown variant="float" size="sm" value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} disabled={disabled} className={`${FILL} ${className}`.trim()} />
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** @deprecated 2026-11-12 — `TabsRow variant="float"` */
|
|
161
|
+
export function SettingsSegmented({ value, onChange, options = [], ariaLabel }) {
|
|
162
|
+
return <TabsRow variant="float" size="xs" tabs={options} value={value} onChange={onChange} ariaLabel={ariaLabel} className="w-full [&>*]:flex-1" />
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** @deprecated 2026-11-12 — `LabeledControl variant="float" horizontal` around a bare `ToggleSwitch variant="float"` */
|
|
166
|
+
export function SettingsToggle({ label, checked, onChange, disabled }) {
|
|
167
|
+
return (
|
|
168
|
+
<LabeledControl variant="float" horizontal label={label} labelWidth="fit-content" className={disabled ? 'opacity-40' : ''}>
|
|
169
|
+
<ToggleSwitch variant="float" checked={!!checked} onChange={onChange} aria-label={label} disabled={disabled} />
|
|
170
|
+
</LabeledControl>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** @deprecated 2026-11-12 — `Input variant="float"` */
|
|
175
|
+
export function SettingsText({ value, onChange, onCommit, type = 'text', placeholder, disabled, 'aria-label': ariaLabel, className = '' }) {
|
|
176
|
+
return (
|
|
177
|
+
<Input variant="float" size="sm" type={type} value={value ?? ''} placeholder={placeholder} aria-label={ariaLabel} disabled={disabled} width="100%" className={className}
|
|
178
|
+
onChange={onChange ? (e) => onChange(type === 'number' ? Number(e.target.value) : e.target.value) : undefined} onCommit={onCommit} />
|
|
179
|
+
)
|
|
180
|
+
}
|
package/src/molecules/Slider.jsx
CHANGED
|
@@ -46,7 +46,7 @@ import LabeledControl from './LabeledControl.jsx'
|
|
|
46
46
|
* @param {string} props.fontSize - Font size for label/value (e.g., '11px')
|
|
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
|
-
* @param {'input'|'value'|'none'} props.readout - `input` (default) an editable Input · `value` a plain right-aligned span, Knob's own display-only readout · `none`
|
|
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`. On `float` unset is `none`; `input` puts the value as an `Input variant="float"` pill at the track's right, sized in `ch` to the widest value (plan-2026-11-12-one-header W6.1 — the settings window's rows; typed values commit on Enter or blur, clamped, Escape reverts)
|
|
50
50
|
* @param {'minimal'|'dual'|'scrub'|'panel'|'float'} 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 · label` plus `onHold` · `float` (float-everything W2 row 23, 2026-11-04; track only since 2026-11-12): the 3px capsule track at the float sm height — the run fg-64 to a 12 thumb (`.kol-slider-float`); a `label` is drawn by `LabeledControl variant="float"`, a `value` readout as its hint, `formatValue` its words (`65%`)
|
|
51
51
|
* @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
|
|
52
52
|
* @param {number} props.height - vertical only — the track's length in px (default 96; panel 60)
|
|
@@ -74,7 +74,7 @@ const Slider = ({
|
|
|
74
74
|
readoutPreset,
|
|
75
75
|
fontSize,
|
|
76
76
|
defaultValue,
|
|
77
|
-
readout
|
|
77
|
+
readout,
|
|
78
78
|
variant = 'minimal',
|
|
79
79
|
value2,
|
|
80
80
|
onChange2,
|
|
@@ -159,7 +159,8 @@ const Slider = ({
|
|
|
159
159
|
|
|
160
160
|
const commit = () => {
|
|
161
161
|
setEditing(false)
|
|
162
|
-
|
|
162
|
+
/* parseFloat, so a formatted value typed back (`45°`, `0,5`) still reads; an empty field reverts */
|
|
163
|
+
const parsed = parseFloat(String(draft).replace(',', '.'))
|
|
163
164
|
if (!Number.isFinite(parsed) || onChange == null) {
|
|
164
165
|
setDraft(displayValue)
|
|
165
166
|
return
|
|
@@ -286,14 +287,37 @@ const Slider = ({
|
|
|
286
287
|
onClick={onAltReset}
|
|
287
288
|
disabled={disabled}
|
|
288
289
|
aria-label={ariaLabel ?? (typeof label === 'string' ? label : undefined)}
|
|
289
|
-
className={`kol-slider-float block min-w-0 ${label ? 'w-full' : className || 'w-full'}`.trim()}
|
|
290
|
-
style={{ '--kol-slider-pct': `${pct}%`, ...(length ? { width: length } : null), ...(label ? null : style) }}
|
|
290
|
+
className={`kol-slider-float block min-w-0 ${readout === 'input' ? 'flex-1 w-full' : label ? 'w-full' : className || 'w-full'}`.trim()}
|
|
291
|
+
style={{ '--kol-slider-pct': `${pct}%`, ...(length ? { width: length } : null), ...(label || readout === 'input' ? null : style) }}
|
|
291
292
|
/>
|
|
292
293
|
)
|
|
293
|
-
|
|
294
|
+
/* the value pill: the float Input, its width the widest value in `ch` (never a fixed px — validate:float F4) */
|
|
295
|
+
const box = readout === 'input' && (
|
|
296
|
+
<Input
|
|
297
|
+
type="text"
|
|
298
|
+
inputMode="decimal"
|
|
299
|
+
variant="float"
|
|
300
|
+
size="sm"
|
|
301
|
+
chars={Math.max(2, fmt(min).length, fmt(max).length)}
|
|
302
|
+
value={draft}
|
|
303
|
+
disabled={disabled}
|
|
304
|
+
aria-label={`${ariaLabel ?? (typeof label === 'string' ? label : 'Value')} value`}
|
|
305
|
+
/* editing shows the raw number (a `50%` reading is typed as 0.5, the engine's unit) */
|
|
306
|
+
onFocus={(e) => { const el = e.target; setEditing(true); setDraft(String(value)); requestAnimationFrame(() => el.select()) }}
|
|
307
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
308
|
+
onBlur={commit}
|
|
309
|
+
onKeyDown={onKeyDown}
|
|
310
|
+
className="shrink-0"
|
|
311
|
+
inputClassName="text-center"
|
|
312
|
+
/>
|
|
313
|
+
)
|
|
314
|
+
const control = box
|
|
315
|
+
? <div className={`flex min-w-0 items-center gap-3 ${label ? 'w-full' : className || 'w-full'}`.trim()} style={label ? undefined : style}>{track}{box}</div>
|
|
316
|
+
: track
|
|
317
|
+
if (!label) return control
|
|
294
318
|
return (
|
|
295
319
|
<LabeledControl variant="float" label={label} hint={readout === 'value' ? displayValue : undefined} className={`${disabled ? 'opacity-40' : ''} ${className}`.trim()}>
|
|
296
|
-
{
|
|
320
|
+
{control}
|
|
297
321
|
</LabeledControl>
|
|
298
322
|
)
|
|
299
323
|
}
|
|
@@ -316,7 +340,7 @@ const Slider = ({
|
|
|
316
340
|
/>
|
|
317
341
|
)
|
|
318
342
|
|
|
319
|
-
const readoutNode = readout === 'input' ? (
|
|
343
|
+
const readoutNode = (readout ?? 'input') === 'input' ? (
|
|
320
344
|
<Input
|
|
321
345
|
type="text"
|
|
322
346
|
inputMode="decimal"
|