@kolkrabbi/kol-component 0.381.0 → 0.383.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 +4 -5
- package/src/atoms/BezierPathEditor.jsx +2 -0
- package/src/atoms/Button.jsx +3 -0
- package/src/atoms/FunctionPlot.jsx +2 -0
- package/src/atoms/IconFrame.jsx +2 -0
- package/src/atoms/IconToggle.jsx +2 -0
- package/src/atoms/Input.jsx +6 -1
- package/src/atoms/Kbd.jsx +2 -1
- package/src/atoms/Link.jsx +2 -1
- package/src/atoms/OriginPicker.jsx +2 -0
- package/src/atoms/ToggleBracket.jsx +2 -0
- package/src/atoms/ToggleCheckbox.jsx +2 -0
- package/src/atoms/ToggleSwitch.jsx +2 -0
- package/src/index.js +0 -5
- package/src/molecules/AccountMenu.jsx +2 -1
- package/src/molecules/ButtonSplit.jsx +6 -5
- package/src/molecules/ColorInputRow.jsx +3 -3
- package/src/molecules/ContentCard.jsx +2 -1
- package/src/molecules/Dropdown.jsx +14 -8
- package/src/molecules/Menu.jsx +8 -6
- package/src/molecules/MenuItem.jsx +2 -1
- package/src/molecules/Modal.jsx +18 -5
- package/src/molecules/ParamBindDot.jsx +5 -3
- package/src/molecules/Slider.jsx +10 -9
- package/src/molecules/StepList.jsx +2 -1
- package/src/molecules/SwatchControls.jsx +2 -1
- package/src/molecules/TabsDocument.jsx +3 -3
- package/src/molecules/TabsRow.jsx +4 -4
- package/src/molecules/TreeRow.jsx +2 -1
- package/src/utilities/Popover.jsx +37 -18
- package/src/organisms/LogoSystem.jsx +0 -38
- package/src/organisms/LogoTuner.jsx +0 -32
- package/src/organisms/logoBoard.jsx +0 -61
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.383.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,10 +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-tuner": "^0.1.0",
|
|
36
|
-
"@kolkrabbi/kol-markdown": "^0.2.0",
|
|
37
35
|
"@kolkrabbi/kol-search": "^0.3.0",
|
|
38
|
-
"@kolkrabbi/kol-growth": "^0.5.0"
|
|
36
|
+
"@kolkrabbi/kol-growth": "^0.5.0",
|
|
37
|
+
"@kolkrabbi/kol-markdown": "^0.2.0"
|
|
39
38
|
},
|
|
40
39
|
"peerDependencies": {
|
|
41
40
|
"@kolkrabbi/kol-icons": ">=0.69.0",
|
|
@@ -46,7 +45,7 @@
|
|
|
46
45
|
"react-dom": "^18.3.0 || ^19.0.0"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"@kolkrabbi/kol-icons": "^0.
|
|
48
|
+
"@kolkrabbi/kol-icons": "^0.74.1"
|
|
50
49
|
},
|
|
51
50
|
"files": [
|
|
52
51
|
"src",
|
|
@@ -49,6 +49,7 @@ export default function BezierPathEditor({
|
|
|
49
49
|
minPoints = 2,
|
|
50
50
|
ariaLabel = 'Path editor',
|
|
51
51
|
className = '',
|
|
52
|
+
accent,
|
|
52
53
|
}) {
|
|
53
54
|
const ref = useRef(null)
|
|
54
55
|
const drag = useRef(null) /* { i, part: 'anchor'|'hl'|'hr' } */
|
|
@@ -137,6 +138,7 @@ export default function BezierPathEditor({
|
|
|
137
138
|
|
|
138
139
|
return (
|
|
139
140
|
<div
|
|
141
|
+
data-accent={accent === 'secondary' ? accent : undefined}
|
|
140
142
|
ref={ref}
|
|
141
143
|
role="group"
|
|
142
144
|
aria-label={ariaLabel}
|
package/src/atoms/Button.jsx
CHANGED
|
@@ -41,6 +41,7 @@ import { InTooltipKolbox, Tooltip } from '../utilities/Popover.jsx'
|
|
|
41
41
|
* @param {'kolbox'} props.variant - also `kolbox` (plan-2026-11-18-kolbox-system W31.2 batch 3, 2026-11-18): kolbox's button, `--kol-kolbox-ctl` high (24), 12 in, radius 4, a 1px line, Inter 12 / 16 / 500, one size. Its grounds are tones: `primary` the accent with the on-accent ink (110% brightness on hover), `secondary` (also unset) the oq-16 field with the oq-24 line (the line's oq-24 on hover), `ghost` bare in oq-64 (the field and the ink on hover); `pressed` is its lit look (the accent tint, the accent ink) and sets aria-pressed. `iconLeft` is a 16 glyph 8 off the label. With `iconOnly` it is kolbox's icon button: a 28 box, the glyph in oq-64, the ink on hover over a 28 oq-16 frame drawn centred on the glyph, so a caller may set a 16 or 24 box and the frame still lights 28; `pressed` lights the frame in the accent tint with the accent glyph; `aria-pressed` is always set; `children` stand in for a glyph that is not an icon. The glyph is your icons by the set's name at 16 with the stroke lift (`.kol-kolbox-icon`, KolboxGlyph); `iconComponent` is not read here (C9.2: kolbox's data carries the set's names).
|
|
42
42
|
* @param {'folio'} props.variant - also `folio` (Folio migration batch A, 2026-11-22): Folio's buttons carried class for class, the chrome in kol-theme `.kol-btn--folio` and `.kol-icon-btn--folio`, the colors Folio's (`--kol-folio-*`). `size` picks the shape: `md` (default) Folio's editor tool, 32 high, 10 in, radius 3, Inter 11, a 16 `iconLeft` 8 off the label; `lg` Folio's page action, 42 high, 16 in, radius 3, a 1px line, the label 12 / 600 and its `glyph` (a character, 16) 12 after it. Grounds are tones: `ghost` (md's default) bare in the ink, the surface on hover; `outline` (lg's default) the paper with the rule line; `primary` the accent fill with the paper ink. `pressed` is its lit look (the accent's soft ground and strong ink) and sets aria-pressed. With `iconOnly` it is Folio's tool icon: a 32 square at radius 4, the glyph 20, the paper on hover, lit when `pressed`. A press does not take the focus (`mousedown` is prevented), so the editor's selection stays.
|
|
43
43
|
* @param {string} props.glyph - folio `lg` only: the character after the label (`+`, `⌄`, `→`)
|
|
44
|
+
* @param {'primary'|'secondary'} [props.accent='primary'] - which of the theme's two accents the part draws (KolboxAccentBlueAndSecondary, 2026-11-28): `secondary` stamps `data-accent="secondary"`, which points every primary accent token at the secondary's on the part and inside it (kol-theme kol-color.css). A theme with no secondary draws its primary.
|
|
44
45
|
* @param {string} props.kbd - a key cap after the label, inside the button (float-everything W2 row 12, 2026-11-04): `Kbd size="sm"`, a leading ⌘ drawn as the `command` icon.
|
|
45
46
|
*/
|
|
46
47
|
const warned = new Set()
|
|
@@ -77,8 +78,10 @@ const Button = ({
|
|
|
77
78
|
tone = 'default',
|
|
78
79
|
kbd,
|
|
79
80
|
glyph,
|
|
81
|
+
accent,
|
|
80
82
|
...props
|
|
81
83
|
}) => {
|
|
84
|
+
if (accent === 'secondary') props['data-accent'] = accent
|
|
82
85
|
/* an icon-only kolbox button names itself in a tooltip unless it already sits in one */
|
|
83
86
|
const inTip = useContext(InTooltipKolbox)
|
|
84
87
|
/* `variant="bare"` (MetricRebuild, 2026-10-31): a pressable SURFACE — a stat tile, a bar row, a column head — that
|
|
@@ -40,6 +40,7 @@ export default function FunctionPlot({
|
|
|
40
40
|
labels = true,
|
|
41
41
|
ariaLabel = 'Function plot',
|
|
42
42
|
className = '',
|
|
43
|
+
accent,
|
|
43
44
|
}) {
|
|
44
45
|
const ref = useRef(null)
|
|
45
46
|
const [w, setW] = useState(0)
|
|
@@ -73,6 +74,7 @@ export default function FunctionPlot({
|
|
|
73
74
|
|
|
74
75
|
return (
|
|
75
76
|
<div
|
|
77
|
+
data-accent={accent === 'secondary' ? accent : undefined}
|
|
76
78
|
ref={ref}
|
|
77
79
|
role="img"
|
|
78
80
|
aria-label={ariaLabel}
|
package/src/atoms/IconFrame.jsx
CHANGED
|
@@ -86,8 +86,10 @@ export default function IconFrame({
|
|
|
86
86
|
href,
|
|
87
87
|
tone = 'default',
|
|
88
88
|
className = '',
|
|
89
|
+
accent,
|
|
89
90
|
...rest
|
|
90
91
|
}) {
|
|
92
|
+
if (accent === 'secondary') rest['data-accent'] = accent
|
|
91
93
|
if (!name) return null
|
|
92
94
|
const radiusCls = radius === 'full' ? ' kol-icon-frame-radius-full' : ''
|
|
93
95
|
const resolvedIconSize = iconSize ?? GLYPH[size] ?? GLYPH.md
|
package/src/atoms/IconToggle.jsx
CHANGED
|
@@ -40,8 +40,10 @@ export default function IconToggle({
|
|
|
40
40
|
disabled = false,
|
|
41
41
|
iconComponent: IconCmp = IconLoader,
|
|
42
42
|
className = '',
|
|
43
|
+
accent,
|
|
43
44
|
...rest
|
|
44
45
|
}) {
|
|
46
|
+
if (accent === 'secondary') rest['data-accent'] = accent
|
|
45
47
|
const cls = `kol-icon-toggle kol-icon-toggle-${size}${tone === 'danger' ? ' kol-icon-toggle-danger' : ''} ${className}`.trim()
|
|
46
48
|
return (
|
|
47
49
|
<Tooltip label={title ?? label} triggerClassName="inline-flex shrink-0">
|
package/src/atoms/Input.jsx
CHANGED
|
@@ -24,6 +24,8 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
24
24
|
* `(text) => void`) it is kolbox's field (`useKolboxField`): Enter or leaving commits a
|
|
25
25
|
* changed value, Escape restores the value from before the edit and leaves, ArrowUp and
|
|
26
26
|
* ArrowDown step a number by 1 (Shift 10) and commit. Chrome in kol-theme `.kol-input--kolbox`.
|
|
27
|
+
* md with no `iconLeft` is 8 in, as sm (KolboxInputPlainTextField, 2026-11-28). `text`
|
|
28
|
+
* sets a field for words in the sans 11 / 16; unset, sm keeps the mono for values.
|
|
27
29
|
* variant="folio" — Folio's field (Folio migration batch A, 2026-11-22), carried class for class: a bare
|
|
28
30
|
* <input> 32 high, 16 in, radius 4, the rule line on the paper, the value JetBrains Mono
|
|
29
31
|
* 12 / 16 in the ink, the accent line focused; no shell, so the slots and `size` are not
|
|
@@ -171,6 +173,7 @@ export default function Input({
|
|
|
171
173
|
className = '',
|
|
172
174
|
inputClassName = '',
|
|
173
175
|
hug = false,
|
|
176
|
+
text = false,
|
|
174
177
|
...inputProps
|
|
175
178
|
}) {
|
|
176
179
|
/* kolbox's field is its own default size (sm); every other look defaults to md */
|
|
@@ -244,8 +247,10 @@ export default function Input({
|
|
|
244
247
|
* search (32), lg the search modal's (44). A slot that holds nothing is not drawn, so it takes no space. */
|
|
245
248
|
if (variant === 'kolbox') {
|
|
246
249
|
const k = KOLBOX_SIZE[size] ?? KOLBOX_SIZE.sm
|
|
250
|
+
/* md with no glyph sets plain words 8 from each edge, as sm does; the glyph is what insets md's text */
|
|
251
|
+
const box = size === 'md' && !iconLeft ? k.box.replace('px-1', 'px-2') : k.box
|
|
247
252
|
return (
|
|
248
|
-
<label className={`kol-input--kolbox kol-input--kolbox-${KOLBOX_SIZE[size] ? size : 'sm'} flex min-w-0 items-center has-disabled:opacity-40 ${
|
|
253
|
+
<label className={`kol-input--kolbox kol-input--kolbox-${KOLBOX_SIZE[size] ? size : 'sm'}${text ? ' kol-input--kolbox-text' : ''} flex min-w-0 items-center has-disabled:opacity-40 ${box} ${className}`}>
|
|
249
254
|
{iconLeft && <IconLoader name={iconLeft} size={k.icon} className="kol-input-icon kol-kolbox-icon shrink-0" />}
|
|
250
255
|
{prefix !== undefined && <span className="kol-input-lead w-4 shrink-0">{prefix}</span>}
|
|
251
256
|
<input type={type} value={value} onChange={onChange} placeholder={placeholder} disabled={disabled} className={`kol-input-value min-w-0 ${hug ? 'field-sizing-content' : 'flex-1'} bg-transparent text-left outline-none`} {...inputProps}
|
package/src/atoms/Kbd.jsx
CHANGED
|
@@ -31,7 +31,8 @@ const GLYPH = { sm: 10, md: 12 }
|
|
|
31
31
|
/* kolbox: the same boxes, its type in the theme rule */
|
|
32
32
|
const KOLBOX_SIZE = { sm: 'h-4 min-w-4 px-1', md: 'h-5 min-w-5 px-1.5' }
|
|
33
33
|
|
|
34
|
-
export default function Kbd({ size = 'md', icon, variant = 'default', onAccent = false, className = '', children, ...rest }) {
|
|
34
|
+
export default function Kbd({ size = 'md', icon, variant = 'default', onAccent = false, className = '', children, accent, ...rest }) {
|
|
35
|
+
if (accent === 'secondary') rest['data-accent'] = accent
|
|
35
36
|
if (variant === 'kolbox') {
|
|
36
37
|
return (
|
|
37
38
|
<kbd
|
package/src/atoms/Link.jsx
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* @param {ReactNode} children - The words
|
|
12
12
|
* @param {string} [className] - Extra classes on the button
|
|
13
13
|
*/
|
|
14
|
-
export default function Link({ children, className = '', ...rest }) {
|
|
14
|
+
export default function Link({ children, className = '', accent, ...rest }) {
|
|
15
|
+
if (accent === 'secondary') rest['data-accent'] = accent
|
|
15
16
|
return (
|
|
16
17
|
<button type="button" className={`kol-link shrink-0 whitespace-nowrap outline-none hover:underline focus-visible:outline-solid focus-visible:outline-1 ${className}`} {...rest}>
|
|
17
18
|
{children}
|
|
@@ -52,6 +52,7 @@ export default function OriginPicker({
|
|
|
52
52
|
tone = 'default',
|
|
53
53
|
ariaLabel = 'Origin',
|
|
54
54
|
className = '',
|
|
55
|
+
accent,
|
|
55
56
|
}) {
|
|
56
57
|
const refs = useRef([])
|
|
57
58
|
const sel = [STEPS.indexOf(value?.[0]), STEPS.indexOf(value?.[1])]
|
|
@@ -75,6 +76,7 @@ export default function OriginPicker({
|
|
|
75
76
|
|
|
76
77
|
return (
|
|
77
78
|
<div
|
|
79
|
+
data-accent={accent === 'secondary' ? accent : undefined}
|
|
78
80
|
role="radiogroup"
|
|
79
81
|
aria-label={ariaLabel}
|
|
80
82
|
className={[
|
|
@@ -15,8 +15,10 @@ const ToggleBracket = ({
|
|
|
15
15
|
onLabel = 'ON',
|
|
16
16
|
variant = 'default',
|
|
17
17
|
className = '',
|
|
18
|
+
accent,
|
|
18
19
|
...props
|
|
19
20
|
}) => {
|
|
21
|
+
if (accent === 'secondary') props['data-accent'] = accent
|
|
20
22
|
const handleClick = () => {
|
|
21
23
|
if (onToggle) onToggle(!value)
|
|
22
24
|
if (onChange) onChange(!value)
|
|
@@ -44,8 +44,10 @@ const ToggleSwitch = ({
|
|
|
44
44
|
size = 'md',
|
|
45
45
|
className = '',
|
|
46
46
|
hint,
|
|
47
|
+
accent,
|
|
47
48
|
...props
|
|
48
49
|
}) => {
|
|
50
|
+
if (accent === 'secondary') props['data-accent'] = accent
|
|
49
51
|
const handleClick = () => {
|
|
50
52
|
if (onToggle) onToggle(!checked)
|
|
51
53
|
if (onChange) onChange(!checked)
|
package/src/index.js
CHANGED
|
@@ -277,11 +277,6 @@ export { default as FeaturedCarousel } from './organisms/FeaturedCarousel.jsx'
|
|
|
277
277
|
export { default as FeaturesCardSection } from './organisms/FeaturesCardSection.jsx'
|
|
278
278
|
/* the growing line on @kolkrabbi/kol-growth (GrowthLineStage, kol-atlas 2026-10-30) */
|
|
279
279
|
export { default as GrowthLineStage } from './organisms/GrowthLineStage.jsx'
|
|
280
|
-
/* the form tuner's two boards on @kolkrabbi/kol-tuner (W27.4, 2026-11-19) */
|
|
281
|
-
export { default as LogoSystem } from './organisms/LogoSystem.jsx'
|
|
282
|
-
export { default as LogoTuner } from './organisms/LogoTuner.jsx'
|
|
283
|
-
/* the boards' palettes, for a host drawing beside them (a sheet of rolls) */
|
|
284
|
-
export { inksOf as logoInks } from './organisms/logoBoard.jsx'
|
|
285
280
|
/* the app loader's runtime half and its intro claim (LoaderAppIntro, kol-fxr 2026-11-01) — here because GrowthLineStage
|
|
286
281
|
* claims it; kol-framework re-exports it, which stays its documented home */
|
|
287
282
|
export { hideLoaderApp, claimIntro, introClaimed, endIntro, releaseIntro } from './utilities/loaderApp.js'
|
|
@@ -20,7 +20,8 @@ import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
|
20
20
|
* trigger only: the xs Avatar (20) on oq-16 then the 12 chevron in oq-64, 4 apart, the accent's focus line. No menu yet
|
|
21
21
|
* (kolbox has none to open, its no-function list); `items` and `align` are not read. Other props land on the button.
|
|
22
22
|
*/
|
|
23
|
-
export default function AccountMenu({ initial, src, name = 'Account', items = [], align = 'end', size = 'md', className = '', variant, ...rest }) {
|
|
23
|
+
export default function AccountMenu({ initial, src, name = 'Account', items = [], align = 'end', size = 'md', className = '', variant, accent, ...rest }) {
|
|
24
|
+
if (accent === 'secondary') rest['data-accent'] = accent
|
|
24
25
|
if (variant === 'kolbox') {
|
|
25
26
|
return (
|
|
26
27
|
<button type="button" aria-label={name} aria-haspopup="menu" data-account-chip
|
|
@@ -28,8 +28,9 @@ import { Menu } from './Menu.jsx'
|
|
|
28
28
|
* @param {boolean} [disabled] the main action off; the menu still opens
|
|
29
29
|
* @param {string} [menuLabel='More actions'] the ⌄'s aria-label
|
|
30
30
|
* @param {string} [placement='bottom-end'] · {string} [className]
|
|
31
|
+
* @param {'primary'|'secondary'} [accent='primary'] the theme's accent the split draws (data-accent, kol-color.css)
|
|
31
32
|
*/
|
|
32
|
-
export default function ButtonSplit({ children, icon, onClick, items = [], menu, variant = 'default', tone, size = 'md', disabled = false, menuLabel = 'More actions', placement = 'bottom-end', className = '', onMenu, menuOpen, iconOnly, pressed, tooltip, 'aria-label': ariaLabel }) {
|
|
33
|
+
export default function ButtonSplit({ children, icon, onClick, items = [], menu, variant = 'default', tone, size = 'md', disabled = false, menuLabel = 'More actions', placement = 'bottom-end', className = '', accent, onMenu, menuOpen, iconOnly, pressed, tooltip, 'aria-label': ariaLabel }) {
|
|
33
34
|
const [open, setOpen] = useState(false)
|
|
34
35
|
const popover = usePopover({ open, onOpenChange: setOpen, placement, offset: 6, role: 'menu' })
|
|
35
36
|
/* `variant="kolbox"` (plan-2026-11-18-kolbox-system W31.2 batch 3, 2026-11-18): kolbox's SplitButton carried class for
|
|
@@ -49,7 +50,7 @@ export default function ButtonSplit({ children, icon, onClick, items = [], menu,
|
|
|
49
50
|
</button>
|
|
50
51
|
)
|
|
51
52
|
return (
|
|
52
|
-
<div className={`kol-btn-split--kolbox kol-btn-split--kolbox-icon${pressed ? ' is-pressed' : ''} inline-flex shrink-0 gap-px ${className}`.trim()}>
|
|
53
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-btn-split--kolbox kol-btn-split--kolbox-icon${pressed ? ' is-pressed' : ''} inline-flex shrink-0 gap-px ${className}`.trim()}>
|
|
53
54
|
{tooltip ? <Tooltip variant="kolbox" label={tooltip}>{main}</Tooltip> : main}
|
|
54
55
|
<Tooltip variant="kolbox" asChild label={menuLabel}>
|
|
55
56
|
<button type="button" aria-label={menuLabel} aria-expanded={!!menuOpen} onClick={onMenu}
|
|
@@ -61,7 +62,7 @@ export default function ButtonSplit({ children, icon, onClick, items = [], menu,
|
|
|
61
62
|
)
|
|
62
63
|
}
|
|
63
64
|
return (
|
|
64
|
-
<div className={`kol-btn-split--kolbox inline-flex shrink-0 gap-px ${className}`}>
|
|
65
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-btn-split--kolbox inline-flex shrink-0 gap-px ${className}`}>
|
|
65
66
|
<Button variant="kolbox" tone={tone} iconLeft={icon} onClick={onClick} className="rounded-r-none">{children}</Button>
|
|
66
67
|
<Tooltip variant="kolbox" asChild label={menuLabel}><Button variant="kolbox" tone={tone} iconLeft="chevron-down" onClick={onMenu} aria-label={menuLabel} className="rounded-l-none px-1" /></Tooltip>
|
|
67
68
|
</div>
|
|
@@ -73,7 +74,7 @@ export default function ButtonSplit({ children, icon, onClick, items = [], menu,
|
|
|
73
74
|
* `items` on `Menu variant="folio"` under its right edge, in place (never portalled). Esc or a press outside closes. */
|
|
74
75
|
if (variant === 'folio') {
|
|
75
76
|
return (
|
|
76
|
-
<span className={`kol-btn-split--folio${tone === 'primary' ? ' kol-btn-split--folio-primary' : ''} relative inline-flex ${className}`.trim()}>
|
|
77
|
+
<span data-accent={accent === 'secondary' ? accent : undefined} className={`kol-btn-split--folio${tone === 'primary' ? ' kol-btn-split--folio-primary' : ''} relative inline-flex ${className}`.trim()}>
|
|
77
78
|
<span className="kol-btn-split-box flex h-[32px] shrink-0 overflow-hidden rounded-[4px] border">
|
|
78
79
|
<button type="button" onClick={onClick} className="kol-btn-split-main whitespace-nowrap px-[16px]">{children}</button>
|
|
79
80
|
<span aria-hidden className="w-px bg-current opacity-20" />
|
|
@@ -89,7 +90,7 @@ export default function ButtonSplit({ children, icon, onClick, items = [], menu,
|
|
|
89
90
|
const shared = { tone, size }
|
|
90
91
|
const pick = (it) => () => { if (it.disabled) return; it.onPress?.(); close() }
|
|
91
92
|
return (
|
|
92
|
-
<div className={`kol-btn-split inline-flex items-stretch ${className}`.trim()}>
|
|
93
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-btn-split inline-flex items-stretch ${className}`.trim()}>
|
|
93
94
|
<Button {...shared} iconLeft={icon} iconSize={12} disabled={disabled} onClick={onClick} className="flex-1 min-w-0 rounded-r-none">{children}</Button>
|
|
94
95
|
<span aria-hidden="true" className="w-px shrink-0 bg-oq-16" />
|
|
95
96
|
<span ref={popover.refs.setReference} {...popover.getReferenceProps()} className="inline-flex">
|
|
@@ -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 ColorInputRowKolbox({ label, value, resolved, onChange, onSwatch, opacity, onOpacity, actions, lit = false, hidden = false, clearable = false, picker: Picker }) {
|
|
305
|
+
function ColorInputRowKolbox({ 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)
|
|
@@ -378,8 +378,8 @@ function ColorInputRowKolbox({ label, value, resolved, onChange, onSwatch, opaci
|
|
|
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 variant="kolbox" span className={root} data-fill-row first={field} trailing={actions} />{picker}</>
|
|
382
|
-
: <div className={`${root} flex h-(--kol-kolbox-ctl) items-center`} data-fill-row>{field}{picker}</div>
|
|
381
|
+
? <><FieldPair variant="kolbox" span className={root} data-accent={accent === 'secondary' ? accent : undefined} data-fill-row first={field} trailing={actions} />{picker}</>
|
|
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
385
|
/* ── folio (Folio batch C, 2026-11-22): Folio's SwatchRow, carried class for class. The swatch (the `picker`,
|
|
@@ -632,10 +632,11 @@ export const fileAgo = (t) => {
|
|
|
632
632
|
}
|
|
633
633
|
export const fileDay = (t) => (t ? new Date(t).toISOString().slice(0, 10) : '')
|
|
634
634
|
|
|
635
|
-
function ContentCardKolbox({ file, media, meta, onOpen, onDownload, onStar, onSettings, onRemove, onMenu }) {
|
|
635
|
+
function ContentCardKolbox({ file, media, meta, onOpen, onDownload, onStar, onSettings, onRemove, onMenu, accent }) {
|
|
636
636
|
const stop = (fn) => (e) => { e.stopPropagation(); fn(file, e) }
|
|
637
637
|
return (
|
|
638
638
|
<div
|
|
639
|
+
data-accent={accent === 'secondary' ? accent : undefined}
|
|
639
640
|
role="listitem"
|
|
640
641
|
tabIndex={0}
|
|
641
642
|
aria-label={file.name}
|
|
@@ -63,8 +63,10 @@ const LEGACY_VARIANTS = { default: 'primary', subtle: 'primary', minimal: 'outli
|
|
|
63
63
|
|
|
64
64
|
/* `variant="kolbox"` (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18): kolbox's Dropdown carried line for line,
|
|
65
65
|
* the chrome in kol-theme `.kol-dd--kolbox`. The closed field with the 12 chevron at the right: a button that opens
|
|
66
|
-
* `Menu variant="kolbox"`
|
|
67
|
-
*
|
|
66
|
+
* `Menu variant="kolbox"` UNDER itself, 4 apart, and over it only when there is no room under (KolboxDropdownOpensUnder,
|
|
67
|
+
* kol-fxr 2026-11-28, as Figma's lists; it lay over the field, the chosen row on it, until then), at least as wide as the
|
|
68
|
+
* field, with a check on the current option.
|
|
69
|
+
* align left (unset): the list's left edge on the field's; right: its right edge on the field's.
|
|
68
70
|
* `options` strings or `{ value, label }`; `onChange` gets the value as a string. Enter, Space or ArrowDown opens; in the
|
|
69
71
|
* menu the arrows move, Enter picks, a letter jumps, Escape closes; focus comes back to the field.
|
|
70
72
|
* size sm (unset) the 28 field; xs the 24 filter (Home's), no fill, Figma's filter measured (plan-2026-11-23-editor-
|
|
@@ -76,8 +78,8 @@ const LEGACY_VARIANTS = { default: 'primary', subtle: 'primary', minimal: 'outli
|
|
|
76
78
|
* in place of the Menu, and the field reads `value` as it is
|
|
77
79
|
* ariaLabel what it chooses, as KOL's Dropdown; other props (disabled, data-*) land on the button
|
|
78
80
|
* Folio on kolbox (2026-11-22): a number option's value reaches `onChange` as a number (every other as a string); a
|
|
79
|
-
* `value` no option holds is shown as it is
|
|
80
|
-
function DropdownKolbox({ size, tone, value, options = [], onChange, menu, ariaLabel, align
|
|
81
|
+
* `value` no option holds is shown as it is */
|
|
82
|
+
function DropdownKolbox({ size, tone, value, options = [], onChange, menu, ariaLabel, align = 'left', className = '', variant, accent, ...rest }) {
|
|
81
83
|
const ref = useRef(null)
|
|
82
84
|
const [open, setOpen] = useState(false)
|
|
83
85
|
const outlined = tone !== 'grey'
|
|
@@ -105,6 +107,7 @@ function DropdownKolbox({ size, tone, value, options = [], onChange, menu, ariaL
|
|
|
105
107
|
aria-expanded={open}
|
|
106
108
|
aria-label={ariaLabel}
|
|
107
109
|
data-kol-dropdown=""
|
|
110
|
+
data-accent={accent === 'secondary' ? accent : undefined}
|
|
108
111
|
onClick={() => (open ? close() : setOpen(true))}
|
|
109
112
|
onKeyDown={(e) => {
|
|
110
113
|
/* the field's own keys, kept from the page's shortcuts as a native select's are */
|
|
@@ -125,7 +128,8 @@ function DropdownKolbox({ size, tone, value, options = [], onChange, menu, ariaL
|
|
|
125
128
|
onClose={close}
|
|
126
129
|
onSelect={(row) => onChange?.(typeof row.value === 'number' ? row.value : String(row.value))}
|
|
127
130
|
groups={groups}
|
|
128
|
-
placement=
|
|
131
|
+
placement={align === 'right' ? 'bottom-end' : 'bottom-start'}
|
|
132
|
+
accent={accent}
|
|
129
133
|
aria-label={ariaLabel}
|
|
130
134
|
minWidth={ref.current?.offsetWidth}
|
|
131
135
|
/>}
|
|
@@ -139,7 +143,7 @@ function DropdownKolbox({ size, tone, value, options = [], onChange, menu, ariaL
|
|
|
139
143
|
* Esc or a press outside closes. `options` `{ value, label }` (a label may be a node; `value` reaches `onChange` as it
|
|
140
144
|
* is), `ariaLabel`, `disabled`, `className` (the button's). Folio's own word: `align` left (unset), right, bottom-left,
|
|
141
145
|
* bottom-right: the list's edge and side. */
|
|
142
|
-
function DropdownFolio({ value, options = [], onChange, ariaLabel, disabled, align = 'left', className = '' }) {
|
|
146
|
+
function DropdownFolio({ value, options = [], onChange, ariaLabel, disabled, align = 'left', className = '', accent }) {
|
|
143
147
|
const [open, setOpen] = useState(false)
|
|
144
148
|
const box = useRef(null)
|
|
145
149
|
useEffect(() => {
|
|
@@ -151,7 +155,7 @@ function DropdownFolio({ value, options = [], onChange, ariaLabel, disabled, ali
|
|
|
151
155
|
}, [open])
|
|
152
156
|
const current = options.find((o) => o.value === value)?.label ?? value
|
|
153
157
|
return (
|
|
154
|
-
<span ref={box} className="relative inline-flex">
|
|
158
|
+
<span data-accent={accent === 'secondary' ? accent : undefined} ref={box} className="relative inline-flex">
|
|
155
159
|
<button type="button" aria-label={ariaLabel} aria-haspopup="listbox" aria-expanded={open} disabled={disabled} onClick={() => setOpen(!open)} className={`kol-dd--folio inline-flex items-center gap-[4px] rounded-[3px] disabled:cursor-default ${className}`}>
|
|
156
160
|
{current}{!disabled && <span aria-hidden className="kol-dd-caret--folio">⌄</span>}
|
|
157
161
|
</button>
|
|
@@ -237,7 +241,8 @@ const DropdownOn = ({
|
|
|
237
241
|
* list stays open, and the trigger reads `label` — no fake summary row, no ✓ typed into labels. */
|
|
238
242
|
multiple = false,
|
|
239
243
|
label,
|
|
240
|
-
className = ''
|
|
244
|
+
className = '',
|
|
245
|
+
accent,
|
|
241
246
|
}) => {
|
|
242
247
|
const [isOpen, setIsOpen] = useState(defaultOpen)
|
|
243
248
|
|
|
@@ -419,6 +424,7 @@ const DropdownOn = ({
|
|
|
419
424
|
stayOpen={stayOpen}
|
|
420
425
|
closeOnSelect={!multiple}
|
|
421
426
|
rootClassName={`kol-dd-root relative inline-block align-middle ${className}`}
|
|
427
|
+
accent={accent}
|
|
422
428
|
trigger={trig}
|
|
423
429
|
panelClassName={`${resolvedVariant ? `kol-dd-panel--${resolvedVariant}` : ''} ${toneClass(tone)} ${inPanel ? 'kol-hw-panel' : ''}`.replace(/\s+/g, ' ').trim()}
|
|
424
430
|
panelStyle={{
|
package/src/molecules/Menu.jsx
CHANGED
|
@@ -125,7 +125,7 @@ export function MenuScroll({ panel }) {
|
|
|
125
125
|
accent while its child is open. A list taller than the window scrolls and ends in MenuScroll while there is more below.
|
|
126
126
|
The keys: the arrows move the lit row, Enter picks, a letter jumps to the next row that starts with it, Escape (the
|
|
127
127
|
layer's) closes. */
|
|
128
|
-
function MenuKolbox({ anchor, open, onClose, onSelect, groups = [], 'aria-label': label, placement = 'bottom-start', panelClassName = '', minWidth, nested = false, children }) {
|
|
128
|
+
function MenuKolbox({ anchor, open, onClose, onSelect, groups = [], 'aria-label': label, placement = 'bottom-start', panelClassName = '', minWidth, nested = false, accent, children }) {
|
|
129
129
|
const all = groups.map((g) => (Array.isArray(g) ? { rows: g } : g))
|
|
130
130
|
const rows = all.flatMap((g) => g.rows)
|
|
131
131
|
/* the lead column is kept for checks only, so a checked list lines up; a row's icon sits in its row */
|
|
@@ -175,6 +175,7 @@ function MenuKolbox({ anchor, open, onClose, onSelect, groups = [], 'aria-label'
|
|
|
175
175
|
<>
|
|
176
176
|
<PopoverLayer anchor={anchor} open={open} onClose={onClose} placement={placement} kind="menu">
|
|
177
177
|
<div
|
|
178
|
+
data-accent={accent === 'secondary' ? accent : undefined}
|
|
178
179
|
role="menu"
|
|
179
180
|
aria-label={label}
|
|
180
181
|
tabIndex={-1}
|
|
@@ -208,6 +209,7 @@ function MenuKolbox({ anchor, open, onClose, onSelect, groups = [], 'aria-label'
|
|
|
208
209
|
placement="beside"
|
|
209
210
|
aria-label={sub.label}
|
|
210
211
|
groups={sub.submenu}
|
|
212
|
+
accent={accent}
|
|
211
213
|
onSelect={pick}
|
|
212
214
|
onClose={() => { setFlyout(null); refocus() }}
|
|
213
215
|
/>
|
|
@@ -247,7 +249,7 @@ function MenuKolboxItems({ items, anchor, onSelect, ...props }) {
|
|
|
247
249
|
function MenuFolioCheck({ checked }) {
|
|
248
250
|
return <span aria-hidden className="kol-menu-check--folio inline-flex size-[16px] shrink-0 items-center justify-center">{checked ? '✓' : ''}</span>
|
|
249
251
|
}
|
|
250
|
-
function MenuFolio({ open, onClose, items = [], anchor, 'aria-label': label, minWidth, panelClassName = '' }) {
|
|
252
|
+
function MenuFolio({ open, onClose, items = [], anchor, 'aria-label': label, minWidth, panelClassName = '', accent }) {
|
|
251
253
|
const panel = useRef(null)
|
|
252
254
|
useEffect(() => {
|
|
253
255
|
if (!open) return undefined
|
|
@@ -266,7 +268,7 @@ function MenuFolio({ open, onClose, items = [], anchor, 'aria-label': label, min
|
|
|
266
268
|
const rows = items.filter((it) => !it.divider).length, seps = items.length - rows
|
|
267
269
|
const at = anchor ? { left: Math.min(anchor.x, innerWidth - 260), top: Math.max(8, Math.min(anchor.y, innerHeight - (rows * 32 + seps * 13 + 16) - 8)) } : null
|
|
268
270
|
return (
|
|
269
|
-
<span ref={panel} role="menu" aria-label={label} style={{ ...at, ...(minWidth != null ? { minWidth } : null) }} onMouseDown={(e) => e.stopPropagation()}
|
|
271
|
+
<span data-accent={accent === 'secondary' ? accent : undefined} ref={panel} role="menu" aria-label={label} style={{ ...at, ...(minWidth != null ? { minWidth } : null) }} onMouseDown={(e) => e.stopPropagation()}
|
|
270
272
|
className={`kol-menu--folio z-50 flex min-w-[240px] flex-col rounded-[4px] border py-[6px] ${anchor ? 'fixed' : ''} ${panelClassName}`}>
|
|
271
273
|
{items.map((it, i) => (it.divider ? <span key={i} className="kol-menu-rule--folio my-[6px] h-px" /> : (
|
|
272
274
|
<button key={`${it.label}${i}`} type="button" role="menuitem" disabled={it.disabled} onMouseDown={(e) => e.preventDefault()} onClick={() => { onClose?.(); it.onClick?.() }}
|
|
@@ -304,7 +306,7 @@ export function Menu(props) {
|
|
|
304
306
|
function MenuOn({
|
|
305
307
|
items, trigger, anchor, align = 'start', minWidth, offset, defaultOpen = false, open: openProp, onOpenChange,
|
|
306
308
|
stayOpen = false, closeOnSelect = true, fused = false, search, role = 'menu',
|
|
307
|
-
panelClassName = '', panelStyle, rootClassName, className = '', children,
|
|
309
|
+
panelClassName = '', panelStyle, rootClassName, className = '', accent, children,
|
|
308
310
|
}) {
|
|
309
311
|
const [own, setOwn] = useState(defaultOpen)
|
|
310
312
|
const controlled = openProp !== undefined
|
|
@@ -348,7 +350,7 @@ function MenuOn({
|
|
|
348
350
|
return (
|
|
349
351
|
<>
|
|
350
352
|
{trigger && (
|
|
351
|
-
<span ref={(el) => { rootRef.current = el; popover.refs.setReference(el) }} className={rootClassName ?? `inline-flex align-middle ${className}`.trim()}>
|
|
353
|
+
<span data-accent={accent === 'secondary' ? accent : undefined} ref={(el) => { rootRef.current = el; popover.refs.setReference(el) }} className={rootClassName ?? `inline-flex align-middle ${className}`.trim()}>
|
|
352
354
|
{trigger({ open, props: { ...popover.getReferenceProps(), 'aria-pressed': undefined } })}
|
|
353
355
|
</span>
|
|
354
356
|
)}
|
|
@@ -357,7 +359,7 @@ function MenuOn({
|
|
|
357
359
|
className={`kol-menu-panel${fused ? ' kol-menu-panel--fused' : ' w-max'} ${panelClassName}`.replace(/\s+/g, ' ').trim()}
|
|
358
360
|
style={{ ...ambient, ...(minWidth ? { minWidth } : null), ...panelStyle }}>
|
|
359
361
|
{/* a row's click closes the menu (it bubbles from `[data-menu-item]`); a flyout row only toggles */}
|
|
360
|
-
<div role="none" className="flex flex-col gap-[var(--kol-spacing-0-5)] min-h-0" onClick={(e) => { if (closeOnSelect && e.target.closest('[data-menu-item]')) setOpen(false) }}>
|
|
362
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} role="none" className="flex flex-col gap-[var(--kol-spacing-0-5)] min-h-0" onClick={(e) => { if (closeOnSelect && e.target.closest('[data-menu-item]')) setOpen(false) }}>
|
|
361
363
|
<MenuList items={items} search={search}>
|
|
362
364
|
{typeof children === 'function' ? children({ close: () => setOpen(false) }) : children}
|
|
363
365
|
</MenuList>
|
|
@@ -125,7 +125,7 @@ const ROW_BY_SIZE = { xs: 'kol-mono-8 px-2 h-5', sm: 'kol-helper-12 px-2 h-8', m
|
|
|
125
125
|
* row still fills a fixed panel through `w-full` and lets a content-sized one hug its longest label. */
|
|
126
126
|
const INDICATOR = { dot: 'ascii-dot', check: 'check', chevron: 'chevron-right' }
|
|
127
127
|
|
|
128
|
-
export function MenuRow({ href, onClick, onPointerEnter, onPointerLeave, disabled, prefix, iconLeft, indicator, kbd, shortcut, hover = true, height, size = 'sm', rowClass, tone, children }) {
|
|
128
|
+
export function MenuRow({ href, onClick, onPointerEnter, onPointerLeave, disabled, prefix, iconLeft, indicator, kbd, shortcut, hover = true, height, size = 'sm', rowClass, tone, accent, children }) {
|
|
129
129
|
/* `href` makes the row a real link — cmd/ctrl-click and middle-click open a new tab (DocumentHeader, 2026-10-31);
|
|
130
130
|
* a plain click still runs `onClick` (the app's router), which may preventDefault */
|
|
131
131
|
const Row = href && !disabled ? 'a' : 'button'
|
|
@@ -133,6 +133,7 @@ export function MenuRow({ href, onClick, onPointerEnter, onPointerLeave, disable
|
|
|
133
133
|
<Row
|
|
134
134
|
{...(Row === 'a' ? { href, onClick: (e) => { if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) return; onClick?.(e) } } : { type: 'button', onClick })}
|
|
135
135
|
data-menu-item
|
|
136
|
+
data-accent={accent === 'secondary' ? accent : undefined}
|
|
136
137
|
onPointerEnter={onPointerEnter}
|
|
137
138
|
onPointerLeave={onPointerLeave}
|
|
138
139
|
disabled={Row === 'button' ? disabled : undefined}
|
package/src/molecules/Modal.jsx
CHANGED
|
@@ -168,10 +168,15 @@ function ModalView({ state, closeWith, variant, contained }) {
|
|
|
168
168
|
else dialogRef.current?.querySelector('[data-modal-ok]')?.focus(contained ? { preventScroll: true } : undefined)
|
|
169
169
|
}, [state.kind])
|
|
170
170
|
|
|
171
|
+
/* Enter acts on its KEY UP (PromptEnterReopensItsOpener, kol-fxr 2026-11-28): acting on the key down handed the focus
|
|
172
|
+
* back to the opener while the key was still down, and the same press (its keypress or a repeat) pressed the opener
|
|
173
|
+
* again. The key down only arms it, inside the box; the key up of that press submits. */
|
|
174
|
+
const enterArmed = useRef(false)
|
|
171
175
|
useEffect(() => {
|
|
176
|
+
const onUp = (e) => { if (e.key === 'Enter' && enterArmed.current) { enterArmed.current = false; submit() } }
|
|
172
177
|
const onKey = (e) => {
|
|
173
178
|
if (e.key === 'Escape') cancel()
|
|
174
|
-
if (e.key === 'Enter' && e.target.tagName !== 'BUTTON')
|
|
179
|
+
if (e.key === 'Enter' && e.target.tagName !== 'BUTTON') { e.preventDefault(); if (!e.repeat) enterArmed.current = true }
|
|
175
180
|
if (e.key === 'Tab') {
|
|
176
181
|
const els = [...(dialogRef.current?.querySelectorAll('button, input') ?? [])].filter((el) => !el.disabled)
|
|
177
182
|
if (!els.length) return
|
|
@@ -184,7 +189,8 @@ function ModalView({ state, closeWith, variant, contained }) {
|
|
|
184
189
|
/* contained, the keys are the box's: Tab, Enter and Esc elsewhere on the page stay the page's */
|
|
185
190
|
const on = contained ? overlayRef.current : window
|
|
186
191
|
on?.addEventListener('keydown', onKey)
|
|
187
|
-
|
|
192
|
+
on?.addEventListener('keyup', onUp)
|
|
193
|
+
return () => { on?.removeEventListener('keydown', onKey); on?.removeEventListener('keyup', onUp) }
|
|
188
194
|
}, [state.kind, val, values, fieldVals, closeWith]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
189
195
|
|
|
190
196
|
return (
|
|
@@ -282,15 +288,20 @@ function ModalView({ state, closeWith, variant, contained }) {
|
|
|
282
288
|
* themselves); `container` and a per-call `variant` are not read in this look. */
|
|
283
289
|
function ModalConfirmKolbox({ open, title, message, action = 'OK', cancel = 'Cancel', onConfirm, onCancel }) {
|
|
284
290
|
const ok = useRef(onConfirm); ok.current = onConfirm
|
|
291
|
+
/* Enter arms on its key down and confirms on its key up (PromptEnterReopensItsOpener), so the opener that takes the
|
|
292
|
+
focus back never hears the press */
|
|
285
293
|
useEffect(() => {
|
|
286
294
|
if (!open) return
|
|
295
|
+
let armed = false
|
|
287
296
|
const onKey = (e) => {
|
|
288
297
|
if (e.key !== 'Enter' || e.target?.closest?.('button')) return
|
|
289
298
|
e.preventDefault()
|
|
290
|
-
|
|
299
|
+
if (!e.repeat) armed = true
|
|
291
300
|
}
|
|
301
|
+
const onUp = (e) => { if (e.key === 'Enter' && armed) { armed = false; ok.current?.() } }
|
|
292
302
|
document.addEventListener('keydown', onKey)
|
|
293
|
-
|
|
303
|
+
document.addEventListener('keyup', onUp)
|
|
304
|
+
return () => { document.removeEventListener('keydown', onKey); document.removeEventListener('keyup', onUp) }
|
|
294
305
|
}, [open])
|
|
295
306
|
return (
|
|
296
307
|
<ModalDialogKolbox
|
|
@@ -312,6 +323,8 @@ function ModalConfirmKolbox({ open, title, message, action = 'OK', cancel = 'Can
|
|
|
312
323
|
function ModalPromptKolbox({ open, title, label, value = '', placeholder, action = 'OK', cancel = 'Cancel', onSubmit, onCancel }) {
|
|
313
324
|
const [draft, setDraft] = useState(value)
|
|
314
325
|
const field = useRef(null)
|
|
326
|
+
/* Enter arms on its key down in the field and submits on its key up (PromptEnterReopensItsOpener) */
|
|
327
|
+
const armed = useRef(false)
|
|
315
328
|
/* after the dialog has moved the focus into its shell, the field takes it with the value selected */
|
|
316
329
|
useEffect(() => { if (open) { setDraft(value ?? ''); setTimeout(() => field.current?.select(), 0) } }, [open]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
317
330
|
return (
|
|
@@ -327,7 +340,7 @@ function ModalPromptKolbox({ open, title, label, value = '', placeholder, action
|
|
|
327
340
|
)}
|
|
328
341
|
>
|
|
329
342
|
<div className="px-4 pb-4" data-modal-prompt>
|
|
330
|
-
<Input variant="kolbox" ref={field} aria-label={label ?? title} placeholder={placeholder} value={draft} onChange={(e) => setDraft(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && onSubmit?.(draft)} />
|
|
343
|
+
<Input variant="kolbox" ref={field} aria-label={label ?? title} placeholder={placeholder} value={draft} onChange={(e) => setDraft(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); if (!e.repeat) armed.current = true } }} onKeyUp={(e) => { if (e.key === 'Enter' && armed.current) { armed.current = false; onSubmit?.(draft) } }} />
|
|
331
344
|
</div>
|
|
332
345
|
</ModalDialogKolbox>
|
|
333
346
|
)
|
|
@@ -50,6 +50,7 @@ function ParamBindDotDefault({
|
|
|
50
50
|
align = 'end',
|
|
51
51
|
minWidth = 180,
|
|
52
52
|
className = '',
|
|
53
|
+
accent,
|
|
53
54
|
}) {
|
|
54
55
|
const tip = tooltip ?? (bound ? (mode ? `Bound · ${mode}` : 'Bound') : 'Modulate')
|
|
55
56
|
const name = [`Modulate${label ? ` ${label}` : ''}`, bound && mode ? `(${mode})` : ''].filter(Boolean).join(' ')
|
|
@@ -59,6 +60,7 @@ function ParamBindDotDefault({
|
|
|
59
60
|
<button
|
|
60
61
|
type="button"
|
|
61
62
|
aria-label={name}
|
|
63
|
+
data-accent={accent === 'secondary' ? accent : undefined}
|
|
62
64
|
{...props}
|
|
63
65
|
className={[
|
|
64
66
|
'kol-param-bind-dot group inline-flex shrink-0 items-center justify-center p-0 border-0 bg-transparent cursor-pointer rounded-[var(--kol-radius-2)] outline-none',
|
|
@@ -83,19 +85,19 @@ function ParamBindDotDefault({
|
|
|
83
85
|
* from apps/kolbox/src/labs/Params.jsx (the binding itself stays the caller's): a 16 hit box, a 6 dot hollow on the muted
|
|
84
86
|
* ring, filled in the accent once `bound`; the kolbox Tooltip (`tooltip`, else "Modulate"); a press opens Menu kolbox
|
|
85
87
|
* beside it with `items` ({ label, checked, onClick }) as one group. */
|
|
86
|
-
function ParamBindDotKolbox({ bound = false, items = [], label, tooltip, minWidth = 180 }) {
|
|
88
|
+
function ParamBindDotKolbox({ bound = false, items = [], label, tooltip, minWidth = 180, accent }) {
|
|
87
89
|
const ref = useRef(null)
|
|
88
90
|
const [open, setOpen] = useState(false)
|
|
89
91
|
return (
|
|
90
92
|
<>
|
|
91
93
|
<Tooltip variant="kolbox" label={tooltip ?? 'Modulate'}>
|
|
92
|
-
<button ref={ref} type="button" aria-label={`Modulate${label ? ` ${label}` : ''}`} aria-haspopup="menu" aria-expanded={open} data-bind-dot
|
|
94
|
+
<button ref={ref} type="button" aria-label={`Modulate${label ? ` ${label}` : ''}`} aria-haspopup="menu" aria-expanded={open} data-bind-dot data-accent={accent === 'secondary' ? accent : undefined}
|
|
93
95
|
onClick={() => setOpen((o) => !o)}
|
|
94
96
|
className="kol-bind-dot--kolbox inline-flex size-4 shrink-0 items-center justify-center rounded-full outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
95
97
|
<span className={`kol-bind-dot-mark${bound ? ' is-bound' : ''} size-1.5 rounded-full`} />
|
|
96
98
|
</button>
|
|
97
99
|
</Tooltip>
|
|
98
|
-
<Menu variant="kolbox" aria-label="Modulate" anchor={ref} open={open} onClose={() => setOpen(false)} minWidth={minWidth}
|
|
100
|
+
<Menu variant="kolbox" accent={accent} aria-label="Modulate" anchor={ref} open={open} onClose={() => setOpen(false)} minWidth={minWidth}
|
|
99
101
|
groups={[items.map((it, i) => ({ label: it.label, value: i, check: !!it.checked }))]} onSelect={(r) => items[r.value]?.onClick?.()} />
|
|
100
102
|
</>
|
|
101
103
|
)
|
package/src/molecules/Slider.jsx
CHANGED
|
@@ -68,7 +68,7 @@ import LabeledControl from './LabeledControl.jsx'
|
|
|
68
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
69
|
* as a number; kolbox's field keys: one press selects it, the arrows step it (Shift ten steps), Escape restores the value
|
|
70
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 = '' }) {
|
|
71
|
+
function SliderKolbox({ value, min, max, step, onChange, formatValue, readout = 'value', ariaLabel, stops, className = '', accent }) {
|
|
72
72
|
const [draft, setDraft] = useState(null)
|
|
73
73
|
const before = useRef(value)
|
|
74
74
|
const format = formatValue ?? ((v) => v)
|
|
@@ -95,7 +95,7 @@ function SliderKolbox({ value, min, max, step, onChange, formatValue, readout =
|
|
|
95
95
|
const range = marks ? <span className="relative flex min-w-0 flex-1 items-center">{input}{marks}</span> : input
|
|
96
96
|
if (readout === 'input') {
|
|
97
97
|
return (
|
|
98
|
-
<div className={`kol-slider--kolbox flex h-(--kol-kolbox-ctl) min-w-0 items-center gap-0.5 ${className}`}>
|
|
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
99
|
<div className="kol-slider-field flex h-(--kol-kolbox-ctl) min-w-0 flex-1 items-center px-2">{range}</div>
|
|
100
100
|
<input
|
|
101
101
|
type="text"
|
|
@@ -132,7 +132,7 @@ function SliderKolbox({ value, min, max, step, onChange, formatValue, readout =
|
|
|
132
132
|
)
|
|
133
133
|
}
|
|
134
134
|
return (
|
|
135
|
-
<div className={`kol-slider--kolbox flex h-(--kol-kolbox-ctl) min-w-0 items-center gap-3 ${className}`}>
|
|
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
136
|
{range}
|
|
137
137
|
<span className="kol-slider-value w-10 shrink-0 text-right">{format(value)}</span>
|
|
138
138
|
</div>
|
|
@@ -167,6 +167,7 @@ const Slider = ({
|
|
|
167
167
|
height,
|
|
168
168
|
onHold,
|
|
169
169
|
stops,
|
|
170
|
+
accent,
|
|
170
171
|
'aria-label': ariaLabel,
|
|
171
172
|
}) => {
|
|
172
173
|
/* Label ↔ input pairing — the <label> is a sibling of the range input, so
|
|
@@ -266,7 +267,7 @@ const Slider = ({
|
|
|
266
267
|
}
|
|
267
268
|
|
|
268
269
|
if (variant === 'kolbox') {
|
|
269
|
-
return <SliderKolbox value={value} min={min} max={max} step={step} onChange={onChange} formatValue={formatValue} readout={readout} ariaLabel={ariaLabel} stops={stops} className={className} />
|
|
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} />
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
/* folio (Folio migration batch A, 2026-11-22): Folio's Slider carried class for class (apps/folio Chrome.jsx): a 24
|
|
@@ -275,7 +276,7 @@ const Slider = ({
|
|
|
275
276
|
const format = formatValue ?? ((n) => n)
|
|
276
277
|
const run = `${((value - min) / (max - min)) * 100}%`
|
|
277
278
|
return (
|
|
278
|
-
<div className={`kol-slider--folio flex h-[24px] w-full items-center gap-[12px] ${className}`}>
|
|
279
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-slider--folio flex h-[24px] w-full items-center gap-[12px] ${className}`}>
|
|
279
280
|
<input type="range" min={min} max={max} step={step} value={value} onChange={handleChange} aria-label={ariaLabel} style={{ '--run': run }}
|
|
280
281
|
className="kol-slider-input h-[24px] min-w-0 flex-1 cursor-pointer appearance-none bg-transparent" />
|
|
281
282
|
<span className="kol-slider-value w-[32px] shrink-0 text-right tabular-nums">{format(value)}</span>
|
|
@@ -296,18 +297,18 @@ const Slider = ({
|
|
|
296
297
|
)
|
|
297
298
|
const labelClass = `kol-helper-12 text-fg-80 ${disabled ? 'opacity-50' : ''}`.trim()
|
|
298
299
|
const row = ({ className: cls, style: st, onClick, children }) => {
|
|
299
|
-
if (!label) return <div className={cls} style={st} onClick={onClick}>{children}</div>
|
|
300
|
+
if (!label) return <div data-accent={accent === 'secondary' ? accent : undefined} className={cls} style={st} onClick={onClick}>{children}</div>
|
|
300
301
|
const outer = cls.split(/\s+/).filter((c) => !/^(control-slider|shadow-none|h-7)$/.test(c)).join(' ')
|
|
301
302
|
return (
|
|
302
|
-
<LabeledControl horizontal label={labelEl} labelWidth="fit-content" labelClass={labelClass}
|
|
303
|
+
<LabeledControl data-accent={accent === 'secondary' ? accent : undefined} horizontal label={labelEl} labelWidth="fit-content" labelClass={labelClass}
|
|
303
304
|
className={`${/(^|\s)(hidden|block|flex|inline-flex|grid)(?=\s|$)/.test(outer) ? '' : 'inline-flex'} ${outer}`} style={st} onClick={onClick}>
|
|
304
305
|
<div className={`flex w-full ${cls.split(/\s+/).filter((c) => /^(control-slider|shadow-none|h-7|gap-3)$/.test(c)).join(' ')}`}>{children}</div>
|
|
305
306
|
</LabeledControl>
|
|
306
307
|
)
|
|
307
308
|
}
|
|
308
309
|
const column = ({ className: cls, style: st, onClick, children }) => (label
|
|
309
|
-
? <LabeledControl label={labelEl} labelClass={labelClass} className={cls} style={st} onClick={onClick}>{children}</LabeledControl>
|
|
310
|
-
: <div className={cls} style={st} onClick={onClick}>{children}</div>)
|
|
310
|
+
? <LabeledControl data-accent={accent === 'secondary' ? accent : undefined} label={labelEl} labelClass={labelClass} className={cls} style={st} onClick={onClick}>{children}</LabeledControl>
|
|
311
|
+
: <div data-accent={accent === 'secondary' ? accent : undefined} className={cls} style={st} onClick={onClick}>{children}</div>)
|
|
311
312
|
|
|
312
313
|
if (variant === 'dual') {
|
|
313
314
|
const v1 = value ?? min
|
|
@@ -50,6 +50,7 @@ export default function StepList({
|
|
|
50
50
|
onAdd,
|
|
51
51
|
addLabel = 'Add a step',
|
|
52
52
|
className = '',
|
|
53
|
+
accent,
|
|
53
54
|
}) {
|
|
54
55
|
const listRef = useRef(null)
|
|
55
56
|
const { drag, startDrag } = usePointerSort(readOnly ? null : onMove)
|
|
@@ -58,7 +59,7 @@ export default function StepList({
|
|
|
58
59
|
const rows = () => listRef.current?.querySelectorAll('.kol-step-list-item')
|
|
59
60
|
|
|
60
61
|
return (
|
|
61
|
-
<ul ref={listRef} className={`flex flex-col gap-1 ${className}`.trim()}>
|
|
62
|
+
<ul data-accent={accent === 'secondary' ? accent : undefined} ref={listRef} className={`flex flex-col gap-1 ${className}`.trim()}>
|
|
62
63
|
{items.map((it, i) => {
|
|
63
64
|
const active = i === activeIndex
|
|
64
65
|
const dragging = drag && drag.from === i
|
|
@@ -82,6 +82,7 @@ export function SwatchStack({
|
|
|
82
82
|
onClear,
|
|
83
83
|
variant = 'default',
|
|
84
84
|
className = '',
|
|
85
|
+
accent,
|
|
85
86
|
}) {
|
|
86
87
|
if (variant === 'kolbox') {
|
|
87
88
|
const chip = (key, label, pos) => (
|
|
@@ -92,7 +93,7 @@ export function SwatchStack({
|
|
|
92
93
|
const fill = chip('fill', 'Fill color', 'top-1 left-1')
|
|
93
94
|
const stroke = chip('stroke', 'Stroke color', 'top-3 left-[11px]')
|
|
94
95
|
return (
|
|
95
|
-
<div className={`kol-swatch-stack--kolbox relative size-8 shrink-0 ${className}`.trim()} data-swatch-stack={activePaint}>
|
|
96
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} className={`kol-swatch-stack--kolbox relative size-8 shrink-0 ${className}`.trim()} data-swatch-stack={activePaint}>
|
|
96
97
|
{activePaint === 'fill' ? [stroke, fill] : [fill, stroke]}
|
|
97
98
|
<button type="button" aria-label="Swap colors" onClick={onSwap}
|
|
98
99
|
className="kol-swatch-stack-swap absolute top-0 right-0 inline-flex outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
@@ -40,7 +40,7 @@ import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
|
40
40
|
*/
|
|
41
41
|
export default function TabsDocument({
|
|
42
42
|
variant = 'folio', tabs = [], value, onChange, onClose, onNew, newLabel = 'New', paired,
|
|
43
|
-
onOpenBeside, onCloseSplit, onTabContextMenu, onTabDragStart, ariaLabel = 'Open documents', className = '',
|
|
43
|
+
onOpenBeside, onCloseSplit, onTabContextMenu, onTabDragStart, ariaLabel = 'Open documents', className = '', accent,
|
|
44
44
|
}) {
|
|
45
45
|
const kolbox = variant === 'kolbox'
|
|
46
46
|
const focusable = tabs.some((t) => t.value === value) ? value : tabs[0]?.value
|
|
@@ -66,7 +66,7 @@ export default function TabsDocument({
|
|
|
66
66
|
|
|
67
67
|
if (kolbox) {
|
|
68
68
|
return (
|
|
69
|
-
<div role="tablist" aria-label={ariaLabel} onKeyDown={onKeyDown}
|
|
69
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} role="tablist" aria-label={ariaLabel} onKeyDown={onKeyDown}
|
|
70
70
|
className={`kol-tabs-document--kolbox relative flex h-10 shrink-0 items-stretch overflow-x-auto [scrollbar-width:none] after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:h-px after:content-[''] ${className}`.trim()}>
|
|
71
71
|
{tabs.map((t) => {
|
|
72
72
|
const on = t.value === value
|
|
@@ -109,7 +109,7 @@ export default function TabsDocument({
|
|
|
109
109
|
|
|
110
110
|
/* folio: FolioWrite's strip (13.3, W18) class for class; its colors are rules on the folio tokens (kol-components-molecules.css) */
|
|
111
111
|
return (
|
|
112
|
-
<div role="tablist" aria-label={ariaLabel} onKeyDown={onKeyDown}
|
|
112
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} role="tablist" aria-label={ariaLabel} onKeyDown={onKeyDown}
|
|
113
113
|
className={`kol-tabs-document--folio flex h-[44px] shrink-0 items-end gap-[2px] overflow-x-auto px-[56px] [scrollbar-width:none] ${className}`.trim()}>
|
|
114
114
|
{tabs.map((t) => {
|
|
115
115
|
const on = t.value === value
|
|
@@ -91,10 +91,10 @@ import { floatSurfaceClass } from '../utilities/tone.js'
|
|
|
91
91
|
* rest oq-64, the ink on hover. Tabs are strings or `{ value, label, disabled, tooltip }`: a disabled tab is 40%, takes
|
|
92
92
|
* no hover or focus and shows its `tooltip` in `Tooltip variant="kolbox"` (batch 4; the `tooltipComponent` seam is gone). In a track narrower than the labels and their padding the tabs share it
|
|
93
93
|
* equally and the padding gives way. */
|
|
94
|
-
function TabsKolbox({ tabs = [], value, onChange, size = 'sm', className = '' }) {
|
|
94
|
+
function TabsKolbox({ tabs = [], value, onChange, size = 'sm', className = '', accent }) {
|
|
95
95
|
const md = size === 'md'
|
|
96
96
|
return (
|
|
97
|
-
<div role="tablist" className={`kol-tabs--kolbox kol-tabs--kolbox-${md ? 'md' : 'sm'} inline-flex items-center ${md ? 'h-8 p-1' : 'h-(--kol-kolbox-ctl) gap-px p-0.5'} ${className}`}>
|
|
97
|
+
<div data-accent={accent === 'secondary' ? accent : undefined} role="tablist" className={`kol-tabs--kolbox kol-tabs--kolbox-${md ? 'md' : 'sm'} inline-flex items-center ${md ? 'h-8 p-1' : 'h-(--kol-kolbox-ctl) gap-px p-0.5'} ${className}`}>
|
|
98
98
|
{tabs.map((t) => {
|
|
99
99
|
const { value: v, label, disabled, tooltip } = typeof t === 'string' ? { value: t, label: t } : t
|
|
100
100
|
const on = v === value
|
|
@@ -141,8 +141,8 @@ export const tabbarPillSlot = (at, { count, labels = false, split = false } = {}
|
|
|
141
141
|
/* the collapse's motion — one duration for the width and the glyph swap (300, user 2026-10-23: 180 read as abrupt) */
|
|
142
142
|
const COLLAPSE_MS = 300
|
|
143
143
|
|
|
144
|
-
export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, variant, look: lookLegacy, type, trailing, filled = false, placement = 'inline', shape = 'bar', collapsed = false, onExpand, edge, border, shadow, dock, active, foldable, folded, onFoldChange, foldSide, foldTone, surface, split, labels, size, tracked = false, overflow = 'scroll', ariaLabel, className, style }) {
|
|
145
|
-
if (variant === 'kolbox') return <TabsKolbox tabs={raw} value={value} onChange={onChange} size={size} className={className} />
|
|
144
|
+
export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, variant, look: lookLegacy, type, trailing, filled = false, placement = 'inline', shape = 'bar', collapsed = false, onExpand, edge, border, shadow, dock, active, foldable, folded, onFoldChange, foldSide, foldTone, surface, split, labels, size, tracked = false, overflow = 'scroll', ariaLabel, className, style, accent }) {
|
|
145
|
+
if (variant === 'kolbox') return <TabsKolbox tabs={raw} value={value} onChange={onChange} size={size} className={className} accent={accent} />
|
|
146
146
|
const tabs = raw.map((t) => ({ ...t, id: t.id ?? t.value }))
|
|
147
147
|
const look = variant ?? lookLegacy ?? 'underline'
|
|
148
148
|
const wrap = overflow === 'wrap'
|
|
@@ -152,7 +152,8 @@ function TreeRowFolio({ label, count, expanded, onToggle, active = false, href,
|
|
|
152
152
|
return <Link {...target} aria-current={active ? 'page' : undefined} className={`kol-tree-row--folio${active ? ' is-active' : ''} block truncate rounded-[3px] py-[6px] pl-[28px] pr-[8px] ${className}`.trim()} {...own}>{label}</Link>
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
export default function TreeRow(props) {
|
|
155
|
+
export default function TreeRow({ accent, ...props }) {
|
|
156
|
+
if (accent === 'secondary') props['data-accent'] = accent
|
|
156
157
|
if (props.variant === 'folio') return <TreeRowFolio {...props} />
|
|
157
158
|
return props.variant === 'kolbox' ? <TreeRowKolbox {...props} /> : <TreeRowDefault {...props} />
|
|
158
159
|
}
|
|
@@ -148,7 +148,7 @@ export function usePopover({
|
|
|
148
148
|
*
|
|
149
149
|
* A portal to document.body (never inside a rail), fixed at its anchor (an element, a ref, or anything with
|
|
150
150
|
* getBoundingClientRect), closing on a press outside it and its anchor, and on Escape. placement: bottom-start (a menu
|
|
151
|
-
* dropped from its trigger), left-start / right-start (a panel beside the rail), beside, over, or center (a Modal: the
|
|
151
|
+
* dropped from its trigger; bottom-end the same on its right edge), left-start / right-start (a panel beside the rail), beside, over, or center (a Modal: the
|
|
152
152
|
* layer is the dim, and a click on the dim closes it, on click so focus can go back to the trigger after the press;
|
|
153
153
|
* `blocking={false}`: no dim, the layer lets every press and wheel through to what is under it, and only the window
|
|
154
154
|
* itself takes them).
|
|
@@ -193,7 +193,8 @@ export function PopoverLayer({ anchor, open, onClose, placement = 'bottom-start'
|
|
|
193
193
|
panel.style.maxHeight = `${h}px`
|
|
194
194
|
}
|
|
195
195
|
let x, y
|
|
196
|
-
|
|
196
|
+
/* under the anchor, 4 apart, over it when there is no room under; `bottom-end` puts the right edges together */
|
|
197
|
+
if (placement === 'bottom-start' || placement === 'bottom-end') { x = placement === 'bottom-end' ? r.right - box.getBoundingClientRect().width : r.left; y = r.bottom + 4; if (y + h > vh - 8) y = r.top - h - 4 }
|
|
197
198
|
else if (placement === 'left-start') { x = r.left - w - 8; y = r.top; if (x < 8) x = r.right + 8 }
|
|
198
199
|
/* a child menu: the anchor is the parent PANEL; the child stands 4 off its right edge (its left when the window
|
|
199
200
|
ends), its top level with the parent's top, moved up only as far as it must to fit */
|
|
@@ -277,9 +278,10 @@ export function PopoverLayer({ anchor, open, onClose, placement = 'bottom-start'
|
|
|
277
278
|
}
|
|
278
279
|
|
|
279
280
|
/* Tooltip `variant="kolbox"` (W31.2 batch 4): kolbox's Tooltip carried line for line, CSS-placed, no floating-ui. It
|
|
280
|
-
* wraps its trigger; the tip shows
|
|
281
|
-
*
|
|
282
|
-
* the trigger
|
|
281
|
+
* wraps its trigger; the tip shows under it, 6 clear, after `delay` ms (1000) of hover or keyboard focus, at once when
|
|
282
|
+
* another tip closed under 500 ms ago, and closes at once on leave, press or blur (KolboxTooltipDelayAndSize, 2026-11-28).
|
|
283
|
+
* Centred on the trigger with its point, then shifted back inside the window (8 from its edge) when a trigger near the
|
|
284
|
+
* edge would push it past; over the trigger when there is no room under it. Inside a rail (`[data-rail]`) the tip stands level with its trigger, at
|
|
283
285
|
* its left, so it never sits over a section's divider line above the trigger's row; a tip too long to stand there
|
|
284
286
|
* wraps to the rail's width. Takes `label`, `children` and `asChild` (no wrapper: the tip hangs on the one child element);
|
|
285
287
|
* renders its wrapper even with no label, as kolbox's did. */
|
|
@@ -288,15 +290,29 @@ export function PopoverLayer({ anchor, open, onClose, placement = 'bottom-start'
|
|
|
288
290
|
* modal container". It is now portalled to <body>, fixed, and placed from the trigger's box, as the kolbox menus and
|
|
289
291
|
* dropdowns are (PopoverLayer); same plate, same places. Shown on hover or keyboard focus; no label, no plate. */
|
|
290
292
|
const TIP_EDGE = 8
|
|
291
|
-
const TIP_GAP =
|
|
293
|
+
const TIP_GAP = 6
|
|
294
|
+
/* Figma's manner (KolboxTooltipDelayAndSize, kol-fxr 2026-11-28): a tip opens after its trigger has held the pointer or
|
|
295
|
+
the focus `delay` ms (1000), and closes at once on leave, press or blur; a tip asked for within TIP_WARM ms of the last
|
|
296
|
+
one closing opens at once, so moving along a toolbar reads each name without the wait */
|
|
297
|
+
const TIP_WARM = 500
|
|
298
|
+
let tipClosedAt = -Infinity
|
|
292
299
|
/* true inside a kolbox tooltip's trigger: an icon-only kolbox Button there leaves the tip to it (Button.jsx) */
|
|
293
300
|
export const InTooltipKolbox = (globalThis[Symbol.for('@kolkrabbi/kol-component/InTooltipKolbox')] ??= createContext(false))
|
|
294
|
-
function TooltipKolbox({ label, asChild = false, children }) {
|
|
301
|
+
function TooltipKolbox({ label, asChild = false, delay = 1000, children }) {
|
|
295
302
|
const wrap = useRef(null)
|
|
296
303
|
const tip = useRef(null)
|
|
297
|
-
const
|
|
304
|
+
const timer = useRef(null)
|
|
305
|
+
const [open, setOpenState] = useState(false)
|
|
298
306
|
const [pos, setPos] = useState(null)
|
|
299
307
|
const show = label != null && label !== '' && open
|
|
308
|
+
const shown = useRef(false); shown.current = show
|
|
309
|
+
const setOpen = (v) => {
|
|
310
|
+
clearTimeout(timer.current)
|
|
311
|
+
if (!v) { if (shown.current) tipClosedAt = performance.now(); return setOpenState(false) }
|
|
312
|
+
if (performance.now() - tipClosedAt < TIP_WARM) return setOpenState(true)
|
|
313
|
+
timer.current = setTimeout(() => setOpenState(true), delay)
|
|
314
|
+
}
|
|
315
|
+
useEffect(() => () => { clearTimeout(timer.current); if (shown.current) tipClosedAt = performance.now() }, [])
|
|
300
316
|
|
|
301
317
|
useLayoutEffect(() => {
|
|
302
318
|
if (!show) return setPos(null)
|
|
@@ -308,9 +324,9 @@ function TooltipKolbox({ label, asChild = false, children }) {
|
|
|
308
324
|
const vw = window.innerWidth, vh = window.innerHeight
|
|
309
325
|
t.style.maxWidth = ''; t.style.whiteSpace = ''; t.style.height = ''
|
|
310
326
|
let w = t.offsetWidth, h = t.offsetHeight
|
|
311
|
-
let x, y, wrapped = null
|
|
327
|
+
let x, y, wrapped = null, side = 'bottom'
|
|
312
328
|
/* inside a rail the tip stands level with its trigger, at its left, so it never sits over a section's divider */
|
|
313
|
-
if (rail && r.left - TIP_GAP - w >= rail.left + TIP_EDGE) { x = r.left - TIP_GAP - w; y = r.top + r.height / 2 - h / 2 }
|
|
329
|
+
if (rail && r.left - TIP_GAP - w >= rail.left + TIP_EDGE) { x = r.left - TIP_GAP - w; y = r.top + r.height / 2 - h / 2; side = 'left' }
|
|
314
330
|
else {
|
|
315
331
|
/* a tip too long for the rail wraps to the rail's width */
|
|
316
332
|
if (rail && w > rail.width - 2 * TIP_EDGE) {
|
|
@@ -320,21 +336,23 @@ function TooltipKolbox({ label, asChild = false, children }) {
|
|
|
320
336
|
}
|
|
321
337
|
const lo = (rail ? rail.left : 0) + TIP_EDGE, hi = (rail ? rail.right : vw) - TIP_EDGE - w
|
|
322
338
|
x = Math.max(lo, Math.min(r.left + r.width / 2 - w / 2, hi))
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (y
|
|
339
|
+
/* under the trigger, centred; no room under: over it */
|
|
340
|
+
y = r.bottom + TIP_GAP
|
|
341
|
+
if (y + h > vh - TIP_EDGE) { y = r.top - TIP_GAP - h; side = 'top' }
|
|
326
342
|
}
|
|
327
343
|
x = Math.max(TIP_EDGE, Math.min(x, vw - TIP_EDGE - w))
|
|
328
344
|
y = Math.max(TIP_EDGE, Math.min(y, vh - TIP_EDGE - h))
|
|
329
|
-
|
|
345
|
+
/* the point stays on the trigger's centre when the box was shifted inside the window */
|
|
346
|
+
setPos({ x, y, wrapped, side, point: Math.max(10, Math.min(r.left + r.width / 2 - x, w - 10)) })
|
|
330
347
|
}, [show, label])
|
|
331
348
|
|
|
332
349
|
const tipNode = show && typeof document !== 'undefined' && createPortal(
|
|
333
350
|
<span
|
|
334
351
|
ref={tip}
|
|
335
352
|
role="tooltip"
|
|
336
|
-
|
|
337
|
-
|
|
353
|
+
data-side={pos?.side}
|
|
354
|
+
className="kol-tooltip--kolbox pointer-events-none fixed z-[60] flex h-6 items-center px-2 py-1 whitespace-nowrap"
|
|
355
|
+
style={{ left: pos?.x ?? 0, top: pos?.y ?? 0, opacity: pos ? 1 : 0, '--kol-tip-point': pos ? `${pos.point}px` : undefined, ...(pos?.wrapped ? { maxWidth: pos.wrapped, whiteSpace: 'normal', height: 'auto', paddingTop: 'var(--kol-spacing-1)', paddingBottom: 'var(--kol-spacing-1)' } : null) }}
|
|
338
356
|
>
|
|
339
357
|
{label}
|
|
340
358
|
</span>,
|
|
@@ -343,6 +361,7 @@ function TooltipKolbox({ label, asChild = false, children }) {
|
|
|
343
361
|
const on = {
|
|
344
362
|
onPointerEnter: (e) => e.pointerType !== 'touch' && setOpen(true),
|
|
345
363
|
onPointerLeave: () => setOpen(false),
|
|
364
|
+
onPointerDown: () => setOpen(false),
|
|
346
365
|
onFocus: (e) => e.target.matches?.(':focus-visible') && setOpen(true),
|
|
347
366
|
onBlur: () => setOpen(false),
|
|
348
367
|
}
|
|
@@ -356,7 +375,7 @@ function TooltipKolbox({ label, asChild = false, children }) {
|
|
|
356
375
|
const ref = (node) => { wrap.current = node; if (typeof theirs === 'function') theirs(node); else if (theirs) theirs.current = node }
|
|
357
376
|
return (
|
|
358
377
|
<>
|
|
359
|
-
{cloneElement(children, { ref, onPointerEnter: chain('onPointerEnter'), onPointerLeave: chain('onPointerLeave'), onFocus: chain('onFocus'), onBlur: chain('onBlur') })}
|
|
378
|
+
{cloneElement(children, { ref, onPointerEnter: chain('onPointerEnter'), onPointerLeave: chain('onPointerLeave'), onPointerDown: chain('onPointerDown'), onFocus: chain('onFocus'), onBlur: chain('onBlur') })}
|
|
360
379
|
{tipNode}
|
|
361
380
|
</>
|
|
362
381
|
)
|
|
@@ -410,7 +429,7 @@ const TooltipNest = (globalThis[Symbol.for('@kolkrabbi/kol-component/TooltipNest
|
|
|
410
429
|
const childRefOf = (el) => ('ref' in (el.props ?? {}) ? el.props.ref : reactVersion.startsWith('18') ? el.ref : undefined)
|
|
411
430
|
|
|
412
431
|
export function Tooltip(props) {
|
|
413
|
-
if (props.variant === 'kolbox') return <TooltipKolbox label={props.label} asChild={props.asChild}>{props.children}</TooltipKolbox>
|
|
432
|
+
if (props.variant === 'kolbox') return <TooltipKolbox label={props.label} asChild={props.asChild} delay={props.delay}>{props.children}</TooltipKolbox>
|
|
414
433
|
if (props.variant === 'folio') return <TooltipFolio label={props.label}>{props.children}</TooltipFolio>
|
|
415
434
|
/* no label → no tooltip: several call sites pass an optional hint, and an empty panel is worse
|
|
416
435
|
* than none. A separate component so the hooks below never run conditionally. */
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useMemo, useRef } from 'react'
|
|
2
|
-
import { system, systemDrag, grid } from '@kolkrabbi/kol-tuner'
|
|
3
|
-
import { Board, Keylines, Labels, inksOf, useLight } from './logoBoard.jsx'
|
|
4
|
-
|
|
5
|
-
/* LOGOSYSTEM (W27.4, 2026-11-19): the System board of @kolkrabbi/kol-tuner (the canvas's system-01-arcs), a mark built
|
|
6
|
-
* from measures, nothing placed by hand. It draws the form, the wedges, the construction and the math, the grid, the
|
|
7
|
-
* keylines, a reference image and the six handles (y, axisAt, x, angle, footAt, footSize). The settings are the host's:
|
|
8
|
-
* `settings` is the engine's System props as they stand, a handle drag calls `onDrag(key, value)` with the measure under
|
|
9
|
-
* the pointer, a double-click on a handle calls `onDragReset()`, a file dropped on the board calls `onFile(file)`.
|
|
10
|
-
* `reference` is `{ src, w, h }`, drawn faint behind the form. `peek` draws the form alone. */
|
|
11
|
-
export default function LogoSystem({ settings: p, reference, peek = false, onDrag, onDragReset, onFile, className = '' }) {
|
|
12
|
-
const inks = inksOf(p), themeLight = useLight(), light = inks ? inks.light : themeLight, svg = useRef(null), dragging = useRef(null)
|
|
13
|
-
const v = useMemo(() => system(p), [p])
|
|
14
|
-
const grey = p.fill === 'grey', strokeAlpha = grey ? 0.85 : 0.5
|
|
15
|
-
const gridD = p.grid && p.grid !== 'off' && !peek && v.measures ? grid(p.grid, (+p.gridStep || 1) * v.measures.x * (v.box || 480), +p.gridTurn || 0) : ''
|
|
16
|
-
const at = (e) => { const pt = svg.current.createSVGPoint(); pt.x = e.clientX; pt.y = e.clientY; const q = pt.matrixTransform(svg.current.getScreenCTM().inverse()); return [q.x - 600, q.y - 400] }
|
|
17
|
-
const move = (e) => { const k = dragging.current; if (!k) return; const m = at(e); onDrag?.(k, systemDrag(p, k, m[0], m[1])) }
|
|
18
|
-
const refBox = reference && (() => { const k = Math.min(v.box / reference.w, v.box / reference.h), w = reference.w * k, h = reference.h * k; return { x: -w / 2, y: -h / 2, w, h } })()
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<div className={`h-full w-full ${className}`.trim()} onDragOver={(e) => e.preventDefault()} onDrop={(e) => { e.preventDefault(); onFile?.(e.dataTransfer.files[0]) }}>
|
|
22
|
-
<Board svgRef={svg} inks={inks} label="Mark built from a few measures">
|
|
23
|
-
{refBox && <image href={reference.src} x={refBox.x} y={refBox.y} width={refBox.w} height={refBox.h} className="kol-logo-ref" />}
|
|
24
|
-
{gridD && <path d={gridD} className="kol-logo-grid" />}
|
|
25
|
-
<path d={v.d} className={`kol-logo-form${grey && !peek ? ' is-grey' : ''}`} />
|
|
26
|
-
{!peek && p.math && <path d={v.wedges} className="kol-logo-wedges" />}
|
|
27
|
-
{!peek && <path d={(p.construction ? v.guides : '') + (p.math ? v.dims : '')} className="kol-logo-lines" opacity={strokeAlpha} />}
|
|
28
|
-
{!peek && p.handles && v.handlePts.map((h) => (
|
|
29
|
-
<circle key={h.k} data-handle={h.k} cx={h.p[0]} cy={h.p[1]} r="9" className="kol-logo-handle"
|
|
30
|
-
onPointerDown={(e) => { e.preventDefault(); e.stopPropagation(); dragging.current = h.k; e.currentTarget.setPointerCapture(e.pointerId) }}
|
|
31
|
-
onPointerMove={move} onPointerUp={() => { dragging.current = null }} onDoubleClick={(e) => { e.preventDefault(); dragging.current = null; onDragReset?.() }} />
|
|
32
|
-
))}
|
|
33
|
-
{p.keylines && !peek && <Keylines box={(v.box || 480) * 1.2} light={light} />}
|
|
34
|
-
{!peek && p.math && <Labels list={v.dimLabels} />}
|
|
35
|
-
</Board>
|
|
36
|
-
</div>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react'
|
|
2
|
-
import { tuner } from '@kolkrabbi/kol-tuner'
|
|
3
|
-
import { Board, Keylines, Labels, inksOf, useLight } from './logoBoard.jsx'
|
|
4
|
-
|
|
5
|
-
/* LOGOTUNER (W27.4, 2026-11-19): the Tuner board of @kolkrabbi/kol-tuner (the canvas's tuner-01-form), a dropped logo
|
|
6
|
-
* rebuilt from circles and lines on one ladder. It draws the form, the traced line, the circles and dots, the curvature
|
|
7
|
-
* comb, the grid, the keylines and the labels. The settings are the host's: `settings` is the engine's Tuner props,
|
|
8
|
-
* `image` the `Image` it reads (an SVG carries its text as `image.__svg`), and a file dropped on the board or picked by
|
|
9
|
-
* a click calls `onFile(file)`; the host reads it into `image`. `peek` draws the tuned form alone. */
|
|
10
|
-
export default function LogoTuner({ settings: p, image = null, peek = false, onFile, className = '' }) {
|
|
11
|
-
const inks = inksOf(p), themeLight = useLight(), light = inks ? inks.light : themeLight
|
|
12
|
-
const v = useMemo(() => tuner(peek ? { ...p, view: 'tuned' } : p, image), [p, image, peek])
|
|
13
|
-
const grey = p.fill !== 'ink', strokeAlpha = grey ? 0.85 : 0.5
|
|
14
|
-
const pick = (e) => { onFile?.(e.target.files[0]); e.target.value = '' }
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<label className={`block h-full w-full cursor-pointer ${className}`.trim()} title="Choose a logo: an SVG or a black and white image"
|
|
18
|
-
onDragOver={(e) => e.preventDefault()} onDrop={(e) => { e.preventDefault(); onFile?.(e.dataTransfer.files[0]) }}>
|
|
19
|
-
<Board inks={inks} label="A form rebuilt from circles and lines">
|
|
20
|
-
{!peek && v.gridD && <path d={v.gridD} className="kol-logo-grid" />}
|
|
21
|
-
<path d={v.d} className={`kol-logo-form${grey && !peek ? ' is-grey' : ''}`} fillRule={v.fillRule || 'evenodd'} />
|
|
22
|
-
{!peek && [v.comb0, v.comb1, v.comb2].map((d, i) => d && <path key={i} d={d} className={`kol-logo-comb is-${i}`} />)}
|
|
23
|
-
{!peek && p.outline && p.view !== 'original' && <path d={v.orig} className="kol-logo-trace" />}
|
|
24
|
-
{!peek && <path d={(p.construction ? v.circles : '') + (p.math ? v.guides : '')} className="kol-logo-lines" opacity={strokeAlpha} />}
|
|
25
|
-
{!peek && p.construction && <path d={v.dots} className="kol-logo-dots" />}
|
|
26
|
-
{!peek && p.keylines && <Keylines box={(v.box || 480) * 1.2} ox={v.boxX} oy={v.boxY} light={light} />}
|
|
27
|
-
{!peek && p.math && <Labels list={v.labels} />}
|
|
28
|
-
</Board>
|
|
29
|
-
<input type="file" accept="image/*,.svg" aria-label="Choose a logo: an SVG or a black and white image" className="sr-only" onChange={pick} />
|
|
30
|
-
</label>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
import { KeylineGuide } from '../atoms/IconPlate.jsx'
|
|
3
|
-
|
|
4
|
-
/* What LogoSystem and LogoTuner share (from apps/tuner, W27.4 2026-11-19): the board, the keylines on it, the labels,
|
|
5
|
-
* the ground the keylines are drawn on. The board is the Line Swell canvas's 1200 x 800 frame with its origin at the
|
|
6
|
-
* centre; it scales to its box and keeps its ratio. Its inks are `.kol-logo-*` rules in kol-components-organisms.css. */
|
|
7
|
-
|
|
8
|
-
/* which ground the keylines sit on: the page's data-theme, followed on a flip */
|
|
9
|
-
export function useLight() {
|
|
10
|
-
const read = () => document.documentElement.dataset.theme === 'light'
|
|
11
|
-
const [light, setLight] = useState(read)
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const o = new MutationObserver(() => setLight(read()))
|
|
14
|
-
o.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] })
|
|
15
|
-
return () => o.disconnect()
|
|
16
|
-
}, [])
|
|
17
|
-
return light
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/* the 24-unit keylines from KeylineGuide, laid on the board at `box` around (ox, oy) */
|
|
21
|
-
export function Keylines({ box, ox = 0, oy = 0, light }) {
|
|
22
|
-
return (
|
|
23
|
-
<foreignObject x={ox - box / 2} y={oy - box / 2} width={box} height={box} pointerEvents="none">
|
|
24
|
-
<div style={{ position: 'relative', width: '100%', height: '100%' }}><KeylineGuide light={light} /></div>
|
|
25
|
-
</foreignObject>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* the canvas's palettes (line-swell.js PALETTES), ink then ground; `custom` takes the settings' own ink and ground */
|
|
30
|
-
const PALETTES = {
|
|
31
|
-
'ink on paper': ['#111111', '#f4f4f4'], 'paper on ink': ['#ffffff', '#000000'], 'white on blue': ['#ffffff', '#0a1fff'],
|
|
32
|
-
'blue on paper': ['#0a1fff', '#f1f1f1'], 'red on ink': ['#e5303f', '#111111'], 'light on grey': ['#fafafa', '#35363a'],
|
|
33
|
-
}
|
|
34
|
-
/* the board's own inks when the settings carry a palette (as the canvas boards draw), else null: the theme's inks.
|
|
35
|
-
`light` says which keylines suit the ground (the engine's keylines rule: luminance over 128) */
|
|
36
|
-
export function inksOf(p) {
|
|
37
|
-
if (!p?.palette) return null
|
|
38
|
-
const pal = PALETTES[p.palette] ?? PALETTES['ink on paper'], custom = p.palette === 'custom'
|
|
39
|
-
const ink = custom ? (p.ink || pal[0]) : pal[0], ground = custom ? (p.ground || pal[1]) : pal[1]
|
|
40
|
-
const g = String(ground).replace('#', ''), lum = g.length === 6 ? parseInt(g.slice(0, 2), 16) * 0.299 + parseInt(g.slice(2, 4), 16) * 0.587 + parseInt(g.slice(4, 6), 16) * 0.114 : 255
|
|
41
|
-
return { ink, ground, light: lum > 128 }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/* the board: the 1200 x 800 frame, centred and scaled to fit; `svgRef` reads pointer positions in board units.
|
|
45
|
-
`inks` (inksOf): the ground behind the board and the ink of its form, lines and labels; the grey form is the
|
|
46
|
-
canvas's #b3b3b3 there */
|
|
47
|
-
export function Board({ svgRef, label, inks = null, children }) {
|
|
48
|
-
return (
|
|
49
|
-
<svg ref={svgRef} viewBox="0 0 1200 800" preserveAspectRatio="xMidYMid meet" role="img" aria-label={label}
|
|
50
|
-
style={inks ? { '--kol-logo-ink': inks.ink, '--kol-logo-ground': inks.ground } : undefined}
|
|
51
|
-
className={`kol-logo-board block h-full w-full touch-none select-none${inks ? ' is-inked' : ''}`}>
|
|
52
|
-
<g transform="translate(600 400)">{children}</g>
|
|
53
|
-
</svg>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/* labels the engine places on the board, as text in board units so they scale with it; the canvas laid them as 15/16
|
|
58
|
-
* HTML with its top 13 above the point, so the baseline lands 1 above it */
|
|
59
|
-
export function Labels({ list }) {
|
|
60
|
-
return list.map((l, i) => <text key={i} x={l.x} y={l.y - 1} className="kol-logo-label" pointerEvents="none" xmlSpace="preserve">{l.t}</text>)
|
|
61
|
-
}
|