@kolkrabbi/kol-component 0.384.0 → 0.386.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/atoms/Input.jsx +46 -100
- package/src/atoms/Kbd.jsx +15 -25
- package/src/atoms/Textarea.jsx +14 -15
- package/src/atoms/ToggleCheckbox.jsx +8 -23
- package/src/atoms/ToggleSwitch.jsx +13 -42
- package/src/atoms/XYPad.jsx +12 -31
- package/src/molecules/FieldPair.jsx +20 -40
- package/src/molecules/LabeledControl.jsx +20 -51
- package/src/molecules/QuantityInput.jsx +37 -46
- package/src/molecules/Slider.jsx +48 -111
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.386.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"embla-carousel-react": "^8.6.0",
|
|
33
33
|
"pdfjs-dist": "^6.3.289",
|
|
34
34
|
"react-syntax-highlighter": "^16.1.1",
|
|
35
|
-
"@kolkrabbi/kol-
|
|
35
|
+
"@kolkrabbi/kol-growth": "^0.5.0",
|
|
36
36
|
"@kolkrabbi/kol-markdown": "^0.2.0",
|
|
37
|
-
"@kolkrabbi/kol-
|
|
37
|
+
"@kolkrabbi/kol-search": "^0.3.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@kolkrabbi/kol-icons": ">=0.69.0",
|
package/src/atoms/Input.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef, useState } from 'react'
|
|
2
2
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
3
|
import { toneClass } from '../utilities/tone.js'
|
|
4
4
|
import { glyphSize } from '../hooks/glyphLadders.js'
|
|
@@ -11,25 +11,16 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
11
11
|
* variant="outline" — bordered, transparent bg — THE secondary
|
|
12
12
|
* treatment (2026-07-08 chrome law: one
|
|
13
13
|
* secondary, always subordinate to filled)
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* `(text) => void`) it is kolbox's field (`useKolboxField`): Enter or leaving commits a
|
|
25
|
-
* changed value, Escape restores the value from before the edit and leaves, ArrowUp and
|
|
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.
|
|
29
|
-
* variant="folio" — Folio's field (Folio migration batch A, 2026-11-22), carried class for class: a bare
|
|
30
|
-
* <input> 32 high, 16 in, radius 4, the rule line on the paper, the value JetBrains Mono
|
|
31
|
-
* 12 / 16 in the ink, the accent line focused; no shell, so the slots and `size` are not
|
|
32
|
-
* read and the width is the caller's `className`. Chrome in kol-theme `.kol-input--folio`.
|
|
14
|
+
* ONE INPUT, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W2): height, padding, gap, radius, the fill, the
|
|
15
|
+
* focus line, the value's and the affixes' type, the glyph's size and line are
|
|
16
|
+
* `--kol-input-*` (kol-theme kol-components-atoms.css, Input); the default theme leaves them
|
|
17
|
+
* unset and draws what the default path always drew, `data-theme-variant="kolbox"` sets
|
|
18
|
+
* kolbox's per size (sm the 24 field, md the rail's search 32, lg the search modal's 44).
|
|
19
|
+
* `variant="kolbox"` and `variant="folio"` are accepted and do nothing but keep their old
|
|
20
|
+
* default size, sm (their branches are in `_tmp/2026-11-29-one-set-fold/`).
|
|
21
|
+
* Every field: the press that focuses it selects its whole value, a second press places the
|
|
22
|
+
* caret; `hug` sizes the value to its text (a number field, its unit right after it); `text`
|
|
23
|
+
* marks a field for words (a theme may set its type, kolbox the sans 11 / 16).
|
|
33
24
|
* tone="inverse" — the dark chip (`fg-ab-24`) for a washed plane
|
|
34
25
|
* (ControlToneInverse, 2026-08-27); same prop on ViewToggle · Dropdown
|
|
35
26
|
* size="xs" — the panel rung (ControlsXsRung, 2026-09-01):
|
|
@@ -45,6 +36,9 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
45
36
|
* `type="number"` + `onCommit` the draft/commit
|
|
46
37
|
* number idiom outright (parse and clamp at the
|
|
47
38
|
* call site; fxr's NumberField, retired 2026-09-03).
|
|
39
|
+
* It is `useFieldCommit` (W2, adopted for every field): a changed value
|
|
40
|
+
* commits on Enter or leaving, Escape restores and leaves, ArrowUp and
|
|
41
|
+
* ArrowDown step a number by 1 (Shift 10) and commit.
|
|
48
42
|
* variant="ghost" — legacy alias, resolves to outline
|
|
49
43
|
* variant="property" — the Figma property field (PropertyField,
|
|
50
44
|
* 2026-08-12): filled chrome, dim `affordance`
|
|
@@ -88,17 +82,13 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
88
82
|
* Input owns prefix/suffix/icon layout + the inner <input> styling.
|
|
89
83
|
*/
|
|
90
84
|
|
|
91
|
-
/*
|
|
92
|
-
const
|
|
93
|
-
sm: { box: 'h-(--kol-kolbox-ctl) gap-1 px-2 focus-within:outline-1 focus-within:-outline-offset-1', icon: 16 },
|
|
94
|
-
md: { box: 'h-8 gap-2 px-1 focus-within:outline-1 focus-within:-outline-offset-1', icon: 18 },
|
|
95
|
-
lg: { box: 'h-11 gap-3 px-3', icon: 20 },
|
|
96
|
-
}
|
|
85
|
+
/* the old theme words in `variant`: accepted, nothing but their old default size (W2, on the retirement ledger) */
|
|
86
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
97
87
|
|
|
98
88
|
const SIZE_TYPE = { xs: 'kol-mono-8', sm: 'kol-mono-12', md: 'kol-mono-14', lg: 'kol-mono-16' }
|
|
99
89
|
|
|
100
|
-
/*
|
|
101
|
-
A mousedown handler for any
|
|
90
|
+
/* a field's first press: the press that focuses a field selects its whole value; a press in a focused field places the
|
|
91
|
+
caret. A mousedown handler for any field <input> (ColorInputRow's hex and opacity take it too). */
|
|
102
92
|
export function selectOnFirstPress(e) {
|
|
103
93
|
const el = e.currentTarget
|
|
104
94
|
if (e.button !== 0 || document.activeElement === el || el.disabled || el.readOnly) return
|
|
@@ -107,7 +97,7 @@ export function selectOnFirstPress(e) {
|
|
|
107
97
|
el.select()
|
|
108
98
|
}
|
|
109
99
|
|
|
110
|
-
/*
|
|
100
|
+
/* the field's arrow step: a number, alone or with a unit after it (12, -4.5, 45°, 50%), moves by `by`; anything else
|
|
111
101
|
(a hex, a word, empty) does not step and gives null */
|
|
112
102
|
const STEPPABLE = /^\s*(-?\d*\.?\d+)\s*(°|%|px|pt|ms|s|x)?\s*$/
|
|
113
103
|
export function stepText(text, by) {
|
|
@@ -117,11 +107,11 @@ export function stepText(text, by) {
|
|
|
117
107
|
return `${Number((parseFloat(m[1]) + by).toFixed(places))}${m[2] ?? ''}`
|
|
118
108
|
}
|
|
119
109
|
|
|
120
|
-
/*
|
|
110
|
+
/* the field's commit, one place for every field (Input's own, ColorInputRow's hex and opacity, Slider's readout): a draft
|
|
121
111
|
while editing; Enter or leaving commits it, when it differs; Escape puts back the value from before the edit and
|
|
122
112
|
leaves the field; ArrowUp and ArrowDown step a number by 1, with Shift by 10, and commit at once (`step: false`
|
|
123
113
|
for a value that is not a number). `commit(text)` gets the trimmed text. Returns the <input>'s props. */
|
|
124
|
-
export function
|
|
114
|
+
export function useFieldCommit(value, commit, { step = true } = {}) {
|
|
125
115
|
const shown = value == null ? '' : String(value)
|
|
126
116
|
const [draft, setDraft] = useState(null)
|
|
127
117
|
const live = useRef(null)
|
|
@@ -148,6 +138,9 @@ export function useKolboxField(value, commit, { step = true } = {}) {
|
|
|
148
138
|
}
|
|
149
139
|
}
|
|
150
140
|
|
|
141
|
+
/** @deprecated 2026-11-29 → useFieldCommit (the same hook; plan-2026-11-29-one-set-fold W2, on the retirement ledger) */
|
|
142
|
+
export const useKolboxField = useFieldCommit
|
|
143
|
+
|
|
151
144
|
export default function Input({
|
|
152
145
|
type = 'text',
|
|
153
146
|
value,
|
|
@@ -176,8 +169,8 @@ export default function Input({
|
|
|
176
169
|
text = false,
|
|
177
170
|
...inputProps
|
|
178
171
|
}) {
|
|
179
|
-
/*
|
|
180
|
-
const size = sizeProp ?? (variant
|
|
172
|
+
/* md, or sm for a caller still passing an old theme word (its field was sm) */
|
|
173
|
+
const size = sizeProp ?? (THEME_WORDS.includes(variant) ? 'sm' : 'md')
|
|
181
174
|
const isNumber = type === 'number'
|
|
182
175
|
const fixedChars = typeof chars === 'number'
|
|
183
176
|
// The text-adjacent ladder — an Input's icon sits in the rung's line box
|
|
@@ -190,10 +183,11 @@ export default function Input({
|
|
|
190
183
|
// ghost folds into outline (2026-07-08 chrome law): one secondary treatment.
|
|
191
184
|
// property rides the filled chrome — it is a behaviour variant, not new paint.
|
|
192
185
|
const isProperty = variant === 'property'
|
|
193
|
-
const resolvedVariant = variant === 'ghost' ? 'outline' : isProperty ? 'filled' : variant
|
|
186
|
+
const resolvedVariant = variant === 'ghost' ? 'outline' : isProperty ? 'filled' : THEME_WORDS.includes(variant) ? undefined : variant
|
|
194
187
|
|
|
195
188
|
const shellCls = [
|
|
196
189
|
'kol-control',
|
|
190
|
+
'kol-input',
|
|
197
191
|
/* no variant → no modifier: the shell inherits a wrapper's tone, else filled (2026-09-03) */
|
|
198
192
|
resolvedVariant && `kol-control--${resolvedVariant}`,
|
|
199
193
|
`kol-control-${size}`,
|
|
@@ -203,6 +197,7 @@ export default function Input({
|
|
|
203
197
|
'cursor-text',
|
|
204
198
|
/* the dark chip on a washed plane (ControlToneInverse, kol-website 2026-08-27) */
|
|
205
199
|
toneClass(tone),
|
|
200
|
+
text && 'kol-input--text',
|
|
206
201
|
isProperty && 'w-full',
|
|
207
202
|
className,
|
|
208
203
|
].filter(Boolean).join(' ')
|
|
@@ -211,64 +206,14 @@ export default function Input({
|
|
|
211
206
|
* `${len}ch` hugs the value with no probe element, and stays number-safe
|
|
212
207
|
* where the HTML `size` attr is ignored (<input type="number">). +2px keeps
|
|
213
208
|
* the caret from clipping at the end. Tracks `value` → controlled only. */
|
|
214
|
-
/* commit-on-blur/Enter (ControlsXsRung, 2026-09-01
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
const
|
|
218
|
-
/* the ref mirrors the draft so a blur that lands in the same tick as the
|
|
219
|
-
* last keystroke commits what was typed, not the last RENDER's draft */
|
|
220
|
-
const draftRef = useRef(value ?? '')
|
|
221
|
-
const kolboxField = useKolboxField(value, onCommit)
|
|
222
|
-
useEffect(() => { if (onCommit) { setDraft(value ?? ''); draftRef.current = value ?? '' } }, [value, onCommit])
|
|
209
|
+
/* commit-on-blur/Enter (ControlsXsRung, 2026-09-01; the field's commit since W2): `useFieldCommit` keeps a draft
|
|
210
|
+
* while editing and drops it after the commit, so the field shows `value` again and a commit the caller REJECTED falls
|
|
211
|
+
* back to the last good value (kol-fxr's NumberField existed for that re-snap). `onChange` still fires live. */
|
|
212
|
+
const field = useFieldCommit(value, onCommit)
|
|
223
213
|
const commitProps = onCommit
|
|
224
|
-
? {
|
|
225
|
-
value: draft,
|
|
226
|
-
onChange: (e) => { draftRef.current = e.target.value; setDraft(e.target.value); onChange?.(e) },
|
|
227
|
-
/* RE-SNAP AFTER EVERY COMMIT, not only when `value` changes. The
|
|
228
|
-
* effect above re-syncs the draft on a value change — so a commit the
|
|
229
|
-
* caller REJECTED (invalid input, value kept) left the bad draft on
|
|
230
|
-
* screen, and `1` → `19` → `19x` showed `19x` after blur. kol-fxr's
|
|
231
|
-
* `NumberField` existed for exactly this line (34 lines wrapping this
|
|
232
|
-
* atom: commit, then `setDraft(String(value))`); with the re-snap here
|
|
233
|
-
* it is `<Input type="number" onCommit>` and no component
|
|
234
|
-
* (editor-panels-the-held-specs A8, 2026-09-03). The order matters —
|
|
235
|
-
* commit first, so a caller that DOES accept the value re-renders
|
|
236
|
-
* with the new prop and the effect wins over this fallback. */
|
|
237
|
-
onBlur: () => { onCommit(String(draftRef.current).trim()); draftRef.current = value ?? ''; setDraft(value ?? '') },
|
|
238
|
-
onKeyDown: (e) => {
|
|
239
|
-
if (e.key === 'Enter') e.currentTarget.blur()
|
|
240
|
-
if (e.key === 'Escape') { draftRef.current = value ?? ''; setDraft(value ?? ''); e.currentTarget.blur() }
|
|
241
|
-
},
|
|
242
|
-
}
|
|
214
|
+
? { ...field, onChange: (e) => { field.onChange(e); onChange?.(e) } }
|
|
243
215
|
: null
|
|
244
216
|
|
|
245
|
-
/* `variant="kolbox"` (plan-2026-11-18-kolbox-system W31.2 batch 3, 2026-11-18): kolbox's Input carried class for
|
|
246
|
-
* class, the chrome in kol-theme `.kol-input--kolbox`. Its sizes are its three fields: sm the field (`--kol-kolbox-ctl`, 24), md the rail's
|
|
247
|
-
* search (32), lg the search modal's (44). A slot that holds nothing is not drawn, so it takes no space. */
|
|
248
|
-
if (variant === 'kolbox') {
|
|
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
|
|
252
|
-
return (
|
|
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}`}>
|
|
254
|
-
{iconLeft && <IconLoader name={iconLeft} size={k.icon} className="kol-input-icon kol-kolbox-icon shrink-0" />}
|
|
255
|
-
{prefix !== undefined && <span className="kol-input-lead w-4 shrink-0">{prefix}</span>}
|
|
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}
|
|
257
|
-
{...(onCommit ? kolboxField : null)}
|
|
258
|
-
onMouseDown={(e) => { inputProps.onMouseDown?.(e); selectOnFirstPress(e) }} />
|
|
259
|
-
{suffix !== undefined && <span className="kol-input-suffix shrink-0">{suffix}</span>}
|
|
260
|
-
{slotRight}
|
|
261
|
-
</label>
|
|
262
|
-
)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/* `variant="folio"` (Folio migration batch A, 2026-11-22): Folio's text field carried class for class (apps/folio
|
|
266
|
-
* EditorChrome.jsx Input), the bare field with no shell, the chrome in kol-theme `.kol-input--folio`. The width is the
|
|
267
|
-
* caller's `className`. */
|
|
268
|
-
if (variant === 'folio') {
|
|
269
|
-
return <input type={type} value={value} onChange={onChange} placeholder={placeholder} disabled={disabled} {...inputProps} className={`kol-input--folio h-[32px] rounded-[4px] border px-[16px] outline-none ${className}`} />
|
|
270
|
-
}
|
|
271
|
-
|
|
272
217
|
const propertyLen = Math.max(String(value ?? placeholder ?? '').length, 1)
|
|
273
218
|
|
|
274
219
|
/* the error: a mark inside, a message under (row 36) */
|
|
@@ -292,14 +237,14 @@ export default function Input({
|
|
|
292
237
|
const heightCls = `${size === 'xs' ? 'h-3' : size === 'sm' ? 'h-4' : size === 'md' ? 'h-[18px]' : 'h-[22px]'} pointer-coarse:not-[.kol-hw-panel_*]:h-[22px]`
|
|
293
238
|
|
|
294
239
|
const inputCls = [
|
|
295
|
-
'min-w-0 bg-transparent border-none outline-none text-auto',
|
|
240
|
+
'kol-input-value min-w-0 bg-transparent border-none outline-none text-auto',
|
|
296
241
|
heightCls,
|
|
297
|
-
!fixedChars && !isProperty && 'flex-1',
|
|
242
|
+
hug ? 'field-sizing-content' : !fixedChars && !isProperty && 'flex-1',
|
|
298
243
|
/* Balance the dim prefix/suffix visual weight with extra inner padding
|
|
299
244
|
* on the opposite side. Without this the bright value sits closer to
|
|
300
|
-
* the affordance than to the empty edge, reads off-balance. */
|
|
301
|
-
prefix !== undefined && '
|
|
302
|
-
suffix !== undefined && '
|
|
245
|
+
* the affordance than to the empty edge, reads off-balance (`.kol-input-value--lead` / `--suffix`, the theme's). */
|
|
246
|
+
prefix !== undefined && 'kol-input-value--lead',
|
|
247
|
+
suffix !== undefined && 'kol-input-value--suffix',
|
|
303
248
|
isNumber && 'hide-number-spinners',
|
|
304
249
|
inputClassName,
|
|
305
250
|
].filter(Boolean).join(' ')
|
|
@@ -312,15 +257,15 @@ export default function Input({
|
|
|
312
257
|
aria-invalid={error ? true : undefined}
|
|
313
258
|
>
|
|
314
259
|
{slotLeft && (
|
|
315
|
-
<span className="flex items-center shrink-0
|
|
260
|
+
<span className="kol-input-slot flex items-center shrink-0">{slotLeft}</span>
|
|
316
261
|
)}
|
|
317
262
|
{iconLeft && (
|
|
318
|
-
<span aria-hidden="true" className="flex items-center
|
|
319
|
-
<IconLoader name={iconLeft} size={resolvedIconSize} />
|
|
263
|
+
<span aria-hidden="true" className="kol-input-icon flex items-center shrink-0">
|
|
264
|
+
<IconLoader name={iconLeft} size={iconSize ?? `var(--kol-input-icon, ${resolvedIconSize}px)`} />
|
|
320
265
|
</span>
|
|
321
266
|
)}
|
|
322
267
|
{prefix !== undefined && (
|
|
323
|
-
<span aria-hidden="true" className="
|
|
268
|
+
<span aria-hidden="true" className="kol-input-lead shrink-0">{prefix}</span>
|
|
324
269
|
)}
|
|
325
270
|
{affordance !== undefined && (
|
|
326
271
|
<span aria-hidden="true" className="text-meta pr-1.5 shrink-0 inline-flex items-center">{affordance}</span>
|
|
@@ -345,15 +290,16 @@ export default function Input({
|
|
|
345
290
|
{...inputProps}
|
|
346
291
|
/* the commit pair LAST, so nothing spread above it can shadow onBlur / onKeyDown */
|
|
347
292
|
{...(commitProps || {})}
|
|
293
|
+
onMouseDown={(e) => { inputProps.onMouseDown?.(e); selectOnFirstPress(e) }}
|
|
348
294
|
/>
|
|
349
295
|
{unit !== undefined && (
|
|
350
296
|
<span aria-hidden="true" className="text-meta shrink-0">{unit}</span>
|
|
351
297
|
)}
|
|
352
298
|
{suffix !== undefined && (
|
|
353
|
-
<span aria-hidden="true" className="
|
|
299
|
+
<span aria-hidden="true" className="kol-input-suffix shrink-0">{suffix}</span>
|
|
354
300
|
)}
|
|
355
301
|
{slotRight && (
|
|
356
|
-
<span className="flex items-center shrink-0
|
|
302
|
+
<span className="kol-input-trail flex items-center shrink-0 ml-auto">{slotRight}</span>
|
|
357
303
|
)}
|
|
358
304
|
{errorMark}
|
|
359
305
|
</label>
|
package/src/atoms/Kbd.jsx
CHANGED
|
@@ -13,45 +13,35 @@
|
|
|
13
13
|
* is a GLYPH, never a typed character in the mono face.
|
|
14
14
|
* It follows the cap: 10 in `sm`, 12 in `md` (2026-10-02 —
|
|
15
15
|
* it was 12 in both, so in the small ⌘K cap the ⌘ outgrew the K)
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* ONE CAP, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W2): the plate, the ink, the gap, the type and the glyph's
|
|
17
|
+
* line are `--kol-kbd-*` (kol-theme kol-components-atoms.css); the default theme leaves them
|
|
18
|
+
* unset, `data-theme-variant="kolbox"` sets kolbox's (its canvas plate, mono 10 / 14 and 11 / 16,
|
|
19
|
+
* no gap, a 1px glyph line).
|
|
20
|
+
* @param {'default'|'kolbox'} variant `kolbox` is accepted and does nothing (its branch is in `_tmp/2026-11-29-one-set-fold/`).
|
|
21
|
+
* @param {boolean} onAccent on a lit accent row the cap takes the on-accent ink over a 15% wash of it.
|
|
20
22
|
*
|
|
21
23
|
* KbdKeys (a member of Kbd): a drawn shortcut ('⌘⇧S') split into one cap per key, each modifier its own and the rest
|
|
22
24
|
* one key; ⌘ is the `command` glyph. `keys`, `size`, `onAccent`, `variant`, `className`.
|
|
23
25
|
*/
|
|
24
26
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
25
27
|
|
|
28
|
+
/* the box per size; the plate, ink, gap and type in the theme rule (`.kol-kbd`, `.kol-kbd-sm`, `.kol-kbd-md`) */
|
|
26
29
|
const SIZE = {
|
|
27
|
-
sm: 'h-4 min-w-4 px-1
|
|
28
|
-
md: 'h-5 min-w-5 px-1.5
|
|
30
|
+
sm: 'kol-kbd-sm h-4 min-w-4 px-1',
|
|
31
|
+
md: 'kol-kbd-md h-5 min-w-5 px-1.5',
|
|
29
32
|
}
|
|
30
33
|
const GLYPH = { sm: 10, md: 12 }
|
|
31
|
-
/* kolbox: the same boxes, its type in the theme rule */
|
|
32
|
-
const KOLBOX_SIZE = { sm: 'h-4 min-w-4 px-1', md: 'h-5 min-w-5 px-1.5' }
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
/* `variant` is read by nobody: the old `kolbox` is accepted and does nothing (W2, on the retirement ledger) */
|
|
36
|
+
export default function Kbd({ size = 'md', icon, variant, onAccent = false, className = '', children, accent, ...rest }) {
|
|
35
37
|
if (accent === 'secondary') rest['data-accent'] = accent
|
|
36
|
-
if (variant === 'kolbox') {
|
|
37
|
-
return (
|
|
38
|
-
<kbd
|
|
39
|
-
aria-hidden="true"
|
|
40
|
-
className={`kol-kbd--kolbox kol-kbd--kolbox-${size}${onAccent ? ' kol-kbd--kolbox-on-accent' : ''} inline-flex shrink-0 items-center justify-center ${KOLBOX_SIZE[size] ?? KOLBOX_SIZE.md} ${className}`.trim()}
|
|
41
|
-
{...rest}
|
|
42
|
-
>
|
|
43
|
-
{icon && <IconLoader name={icon} size={GLYPH[size] ?? GLYPH.md} className="kol-kolbox-icon shrink-0" />}
|
|
44
|
-
{children}
|
|
45
|
-
</kbd>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
38
|
return (
|
|
49
39
|
<kbd
|
|
50
40
|
aria-hidden="true"
|
|
51
|
-
className={`
|
|
41
|
+
className={`kol-kbd ${SIZE[size] ?? SIZE.md}${onAccent ? ' kol-kbd--on-accent' : ''} inline-flex items-center justify-center shrink-0 ${className}`.trim()}
|
|
52
42
|
{...rest}
|
|
53
43
|
>
|
|
54
|
-
{icon && <IconLoader name={icon} size={GLYPH[size] ?? GLYPH.md} />}
|
|
44
|
+
{icon && <IconLoader name={icon} size={GLYPH[size] ?? GLYPH.md} className="kol-kbd-icon shrink-0" />}
|
|
55
45
|
{children}
|
|
56
46
|
</kbd>
|
|
57
47
|
)
|
|
@@ -69,8 +59,8 @@ export function KbdKeys({ keys, size, onAccent, variant, className = '' }) {
|
|
|
69
59
|
<span aria-hidden className={`inline-flex shrink-0 items-center gap-0.5 ${className}`} data-keys={keys}>
|
|
70
60
|
{keysOf(keys).map((k, i) => (
|
|
71
61
|
k === '⌘'
|
|
72
|
-
? <Kbd key={i} size={size}
|
|
73
|
-
: <Kbd key={i} size={size}
|
|
62
|
+
? <Kbd key={i} size={size} onAccent={onAccent} icon="command" />
|
|
63
|
+
: <Kbd key={i} size={size} onAccent={onAccent}>{k}</Kbd>
|
|
74
64
|
))}
|
|
75
65
|
</span>
|
|
76
66
|
)
|
package/src/atoms/Textarea.jsx
CHANGED
|
@@ -8,12 +8,12 @@ import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
|
8
8
|
* variant="filled" (default) — persistent solid bg
|
|
9
9
|
* variant="ghost" — legacy alias, resolves to outline
|
|
10
10
|
* variant="outline" — bordered, transparent bg
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* ONE TEXTAREA, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W2): the fill, the line, the padding, the type
|
|
12
|
+
* and how it resizes are `--kol-textarea-*` (kol-theme kol-components-atoms.css); the
|
|
13
|
+
* default theme leaves them unset (the grip below), `data-theme-variant="kolbox"` sets
|
|
14
|
+
* kolbox's (the field, the one edge, 8 by 4 in, mono 12 / 16, native vertical resize, no
|
|
15
|
+
* grip). `variant="kolbox"` is accepted and does nothing but keep its old rows, the
|
|
16
|
+
* browser's own (its branch is in `_tmp/2026-11-29-one-set-fold/`).
|
|
17
17
|
* size="sm" / "md" (default) / "lg" — padding + type class
|
|
18
18
|
*
|
|
19
19
|
* Default rows = 3 (kept short — long content gets scrollbars instead of
|
|
@@ -37,6 +37,8 @@ import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
const SIZE_TYPE = { xs: 'kol-mono-8', sm: 'kol-mono-12', md: 'kol-mono-14', lg: 'kol-mono-16' }
|
|
40
|
+
/* the old theme words in `variant`: accepted, nothing but their old rows (W2, on the retirement ledger) */
|
|
41
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
40
42
|
|
|
41
43
|
export default function Textarea({
|
|
42
44
|
value,
|
|
@@ -50,16 +52,14 @@ export default function Textarea({
|
|
|
50
52
|
className = '',
|
|
51
53
|
...props
|
|
52
54
|
}) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// ghost folds into outline (2026-07-08 chrome law): one secondary treatment.
|
|
58
|
-
const resolvedVariant = variant === 'ghost' ? 'outline' : variant
|
|
55
|
+
// ghost folds into outline (2026-07-08 chrome law): one secondary treatment. The theme words are nothing.
|
|
56
|
+
const themeWord = THEME_WORDS.includes(variant)
|
|
57
|
+
const resolvedVariant = variant === 'ghost' ? 'outline' : themeWord ? undefined : variant
|
|
59
58
|
|
|
60
59
|
const wrapperCls = [
|
|
61
60
|
'kol-control',
|
|
62
|
-
|
|
61
|
+
'kol-textarea',
|
|
62
|
+
resolvedVariant && `kol-control--${resolvedVariant}`,
|
|
63
63
|
'kol-control--textarea',
|
|
64
64
|
`kol-control-${size}`,
|
|
65
65
|
SIZE_TYPE[size],
|
|
@@ -77,12 +77,11 @@ export default function Textarea({
|
|
|
77
77
|
<label className={wrapperCls} aria-disabled={disabled || undefined}>
|
|
78
78
|
<textarea
|
|
79
79
|
{...valueProps}
|
|
80
|
-
rows={rows ?? 3}
|
|
80
|
+
rows={rows ?? (themeWord ? undefined : 3)}
|
|
81
81
|
placeholder={placeholder}
|
|
82
82
|
disabled={disabled}
|
|
83
83
|
spellCheck={false}
|
|
84
84
|
className="block w-full bg-transparent border-none outline-none text-auto"
|
|
85
|
-
style={{ resize: 'none' }}
|
|
86
85
|
{...props}
|
|
87
86
|
/>
|
|
88
87
|
<span
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
2
|
|
|
4
3
|
/* `variant="media"` (ContentFiltersCollection, kol-r2b2 2026-08-27): inside a
|
|
5
4
|
* media frame the unchecked hairline vanished over a photo; this variant's
|
|
6
5
|
* UNCHECKED box carries the media control's solid plate (`--kol-oq-12`) so it
|
|
7
6
|
* reads over any image. Checked stays the white plate + black check.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* ONE CHECKBOX, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W2 run 2): the box, its line and fill, the check and,
|
|
8
|
+
* with no label, the hit box are `--kol-check-*` (kol-theme kol-components-atoms.css, Toggle Checkbox); the default theme
|
|
9
|
+
* leaves them unset, `data-theme-variant="kolbox"` sets kolbox's (a 16 box at radius 4 in a 24 hit box, unchecked the
|
|
10
|
+
* field with the oq-24 line, checked the accent with the check in the on-accent ink). `variant="kolbox"` is accepted and
|
|
11
|
+
* draws the default checkbox (its branch is in `_tmp/2026-11-29-one-set-fold/`); with no `label`, name it with
|
|
12
|
+
* `aria-label`. */
|
|
12
13
|
const VARIANT_CLASS = { media: 'toggle-checkbox--media' }
|
|
13
14
|
const ToggleCheckbox = ({
|
|
14
15
|
label,
|
|
@@ -18,26 +19,10 @@ const ToggleCheckbox = ({
|
|
|
18
19
|
className = '',
|
|
19
20
|
hint,
|
|
20
21
|
accent,
|
|
22
|
+
'aria-label': ariaLabel,
|
|
21
23
|
...props
|
|
22
24
|
}) => {
|
|
23
25
|
if (accent === 'secondary') props['data-accent'] = accent
|
|
24
|
-
if (variant === 'kolbox') {
|
|
25
|
-
return (
|
|
26
|
-
<button
|
|
27
|
-
type="button"
|
|
28
|
-
role="checkbox"
|
|
29
|
-
aria-checked={checked}
|
|
30
|
-
onClick={() => onChange?.(!checked)}
|
|
31
|
-
className={`kol-toggle-checkbox--kolbox${checked ? ' is-active' : ''} inline-flex size-(--kol-kolbox-ctl) shrink-0 items-center justify-center outline-none focus-visible:outline-solid focus-visible:outline-1 ${className}`}
|
|
32
|
-
{...props}
|
|
33
|
-
>
|
|
34
|
-
<span className="kol-toggle-checkbox-box flex size-4 items-center justify-center border">
|
|
35
|
-
{checked && <IconLoader name="check" size={12} className="kol-kolbox-icon shrink-0" />}
|
|
36
|
-
</span>
|
|
37
|
-
</button>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
26
|
const handleChange = (event) => {
|
|
42
27
|
const next = event.target.checked
|
|
43
28
|
if (onChange) onChange(next)
|
|
@@ -52,7 +37,7 @@ const ToggleCheckbox = ({
|
|
|
52
37
|
type="checkbox"
|
|
53
38
|
checked={checked}
|
|
54
39
|
onChange={handleChange}
|
|
55
|
-
aria-
|
|
40
|
+
aria-label={ariaLabel}
|
|
56
41
|
/>
|
|
57
42
|
<span className="toggle-checkbox-indicator" aria-hidden="true">
|
|
58
43
|
<svg viewBox="0 0 12 9" width="12" height="9">
|
|
@@ -6,18 +6,14 @@ import React from 'react'
|
|
|
6
6
|
* variant="bare" (default) — label + track, no box
|
|
7
7
|
* variant="primary" — filled shell (surface-secondary), button geometry
|
|
8
8
|
* variant="outline" — bordered shell (border-oq-16), button geometry
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
* track round an 8 knob that travels 8, the hit box 24 high; off the rule track, on the
|
|
18
|
-
* accent, the knob the paper; one size, no label (`aria-label`), role="switch" with
|
|
19
|
-
* aria-checked. Chrome in kol-theme `.kol-toggle-switch--folio`.
|
|
20
|
-
*
|
|
9
|
+
* ONE SWITCH, ITS LOOK THE THEME'S (plan-2026-11-29-one-set-fold W2 run 2): the track, the knob, its travel and
|
|
10
|
+
* colours, the bare switch's hit box and the focus line are `--kol-switch-*` (kol-theme
|
|
11
|
+
* kol-components-atoms.css, Toggle Switch); the default theme leaves them unset and draws what
|
|
12
|
+
* it always drew, `data-theme-variant="kolbox"` sets kolbox's (a 28 × 16 track, a 12 knob 2 in,
|
|
13
|
+
* a 24 hit box 4 in at radius 4, off oq-24 and the ink, on the accent and the on-accent, one
|
|
14
|
+
* size). `variant="kolbox"` and `"folio"` are accepted and draw the bare switch (their branches
|
|
15
|
+
* are in `_tmp/2026-11-29-one-set-fold/`). Every switch is role="switch" with aria-checked.
|
|
16
|
+
|
|
21
17
|
* size="xs" / "sm" / "md" (default) / "lg" — shells match button heights
|
|
22
18
|
* (22/26/32/40); the track scales with size in all variants. xs is the
|
|
23
19
|
* panel rung (2026-09-01).
|
|
@@ -33,6 +29,8 @@ import React from 'react'
|
|
|
33
29
|
|
|
34
30
|
const SIZE_TYPE = { xs: 'kol-mono-8', sm: 'kol-mono-12', md: 'kol-mono-14', lg: 'kol-mono-16' }
|
|
35
31
|
const LEGACY_VARIANTS = { plain: 'bare', default: 'outline' }
|
|
32
|
+
/* the old theme words in `variant`: accepted, drawn as the bare switch (W2 run 2, on the retirement ledger) */
|
|
33
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
36
34
|
let warnedLabel = false
|
|
37
35
|
|
|
38
36
|
const ToggleSwitch = ({
|
|
@@ -58,35 +56,7 @@ const ToggleSwitch = ({
|
|
|
58
56
|
console.warn('ToggleSwitch: `label` is deprecated — wrap the switch in <LabeledControl horizontal label="…">')
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<button
|
|
64
|
-
type="button"
|
|
65
|
-
role="switch"
|
|
66
|
-
aria-checked={checked}
|
|
67
|
-
onClick={handleClick}
|
|
68
|
-
className={`kol-toggle-switch--kolbox inline-flex h-(--kol-kolbox-ctl) shrink-0 items-center px-1 outline-none focus-visible:outline-solid focus-visible:outline-1 disabled:opacity-40 ${className}`}
|
|
69
|
-
data-state={checked ? 'on' : 'off'}
|
|
70
|
-
{...props}
|
|
71
|
-
>
|
|
72
|
-
<span className="kol-toggle-switch-track flex h-4 w-7 items-center rounded-full p-0.5 transition-colors">
|
|
73
|
-
<span className={`kol-toggle-switch-knob size-3 rounded-full transition-transform${checked ? ' translate-x-3' : ''}`} />
|
|
74
|
-
</span>
|
|
75
|
-
</button>
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* folio (Folio migration batch A, 2026-11-22): Folio's Switch carried class for class (apps/folio Chrome.jsx) */
|
|
80
|
-
if (variant === 'folio') {
|
|
81
|
-
return (
|
|
82
|
-
<button type="button" role="switch" aria-checked={checked} onClick={handleClick} {...props}
|
|
83
|
-
className={`kol-toggle-switch--folio relative h-[12px] w-[20px] shrink-0 rounded-full transition-colors before:absolute before:inset-x-0 before:top-1/2 before:h-[24px] before:-translate-y-1/2 before:content-[''] ${className}`}>
|
|
84
|
-
<span className={`kol-toggle-switch-knob absolute left-[2px] top-[2px] size-[8px] rounded-full transition-transform ${checked ? 'translate-x-[8px]' : ''}`} />
|
|
85
|
-
</button>
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const resolvedVariant = LEGACY_VARIANTS[variant] || variant
|
|
59
|
+
const resolvedVariant = THEME_WORDS.includes(variant) ? 'bare' : LEGACY_VARIANTS[variant] || variant
|
|
90
60
|
|
|
91
61
|
const cls = [
|
|
92
62
|
'toggle-switch',
|
|
@@ -102,7 +72,8 @@ const ToggleSwitch = ({
|
|
|
102
72
|
className={cls}
|
|
103
73
|
data-state={checked ? 'on' : 'off'}
|
|
104
74
|
onClick={handleClick}
|
|
105
|
-
|
|
75
|
+
role="switch"
|
|
76
|
+
aria-checked={checked}
|
|
106
77
|
{...props}
|
|
107
78
|
>
|
|
108
79
|
<span className="toggle-switch-label">
|