@kolkrabbi/kol-component 0.384.0 → 0.385.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/molecules/FieldPair.jsx +20 -40
- package/src/molecules/LabeledControl.jsx +20 -51
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.385.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
|
|
@@ -5,56 +5,36 @@ import Input from '../atoms/Input.jsx'
|
|
|
5
5
|
* two-up position fields). Two `Input`s 8 apart, each led by its letter (`prefix`), sharing one `variant` and `size`;
|
|
6
6
|
* the pair fills its row, each field half. A position, a size, a range — any two values that are read together.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* ONE PAIR (plan-2026-11-29-one-set-fold W2, slots adopted for everyone; kolbox's PropertyRow, Figma 70:12121): two slots,
|
|
9
|
+
* `first` and `second`, then `trailing` (icons or a tag); `fields` fills the two slots with Inputs. THE RAIL'S ONE GRID
|
|
10
|
+
* (plan-2026-11-19-kolbox-whats-left R3.1): the row is a grid on `--kol-kolbox-row-cols`, the tracks
|
|
11
11
|
* LabeledControlSection kolbox sets for every row it holds: two field columns and two 16 icon columns, 8 apart (in the
|
|
12
12
|
* 240 rail: 76, 76, 16, 16, his design's Stroke row, 149:26890). `first` takes column 1 (`span`: columns 1 and 2, a
|
|
13
13
|
* row of one field), `second` column 2, `trailing` the icon columns from the right, so a lone icon sits on the last and
|
|
14
|
-
* a pair on both. Outside a section the tracks are
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* radius 4, padded 16, Folio's hairline round each (green while it has focus), each led by its `prefix` in the muted
|
|
19
|
-
* ink; the value in mono 12 / 16. `fields` as the default's, each a plain input's props. Chrome in kol-theme
|
|
20
|
-
* `.kol-field-pair--folio`.
|
|
14
|
+
* a pair on both. Outside a section the tracks are the theme's `--kol-field-pair-cols` (unset: two equal columns, and
|
|
15
|
+
* the trailing's own width after them when there is one; kolbox always keeps that third column). Each control fills its
|
|
16
|
+
* cell. It draws nothing of its own; the wrapper carries `data-property-row`. `variant="kolbox"` and `variant="folio"`
|
|
17
|
+
* are accepted and do nothing (their branches are in `_tmp/2026-11-29-one-set-fold/`; folio's own fields are two Inputs).
|
|
21
18
|
*
|
|
22
19
|
* @param {Array} fields two Input prop sets — `[{ prefix: 'X', value, onChange, ... }, { prefix: 'Y', ... }]`
|
|
23
|
-
* @param {'filled'|'outline'
|
|
20
|
+
* @param {'filled'|'outline'} [variant] passed to both `fields` Inputs
|
|
24
21
|
* @param {'sm'|'md'|'lg'} [size] passed to both
|
|
25
|
-
* @param {ReactNode} [first]
|
|
26
|
-
* @param {ReactNode} [second]
|
|
27
|
-
* @param {ReactNode} [trailing]
|
|
28
|
-
* @param {boolean} [span]
|
|
22
|
+
* @param {ReactNode} [first] the left cell (in place of `fields[0]`)
|
|
23
|
+
* @param {ReactNode} [second] the right cell (in place of `fields[1]`)
|
|
24
|
+
* @param {ReactNode} [trailing] the icon columns
|
|
25
|
+
* @param {boolean} [span] `first` spans both field columns
|
|
29
26
|
* @param {string} [className]
|
|
30
27
|
*/
|
|
31
28
|
export default function FieldPair({ fields = [], variant, size, first, second, trailing, span = false, className = '', ...rest }) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
{!span && <div className="flex min-w-0">{second}</div>}
|
|
37
|
-
{trailing && <div className="col-start-3 -col-end-1 flex items-center justify-end gap-2">{trailing}</div>}
|
|
38
|
-
</div>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
if (variant === 'folio') {
|
|
42
|
-
return (
|
|
43
|
-
<div {...rest} className={`kol-field-pair--folio flex items-center gap-[8px] ${className}`.trim()}>
|
|
44
|
-
{fields.map(({ prefix, ...f }) => (
|
|
45
|
-
<label key={prefix} className="kol-field-pair-field flex h-[32px] min-w-0 flex-1 items-center rounded-[4px] border px-[16px]">
|
|
46
|
-
<span className="kol-field-pair-prefix shrink-0 pr-[4px]">{prefix}</span>
|
|
47
|
-
<input {...f} className="min-w-0 flex-1 bg-transparent outline-none" />
|
|
48
|
-
</label>
|
|
49
|
-
))}
|
|
50
|
-
</div>
|
|
51
|
-
)
|
|
52
|
-
}
|
|
29
|
+
const field = (f, i) => f && <Input key={f.key ?? f.prefix ?? i} variant={variant} size={size} width="100%" className="flex-1 min-w-0" {...f} />
|
|
30
|
+
const one = first ?? field(fields[0], 0)
|
|
31
|
+
const two = second ?? field(fields[1], 1)
|
|
32
|
+
const cols = trailing ? 'minmax(0,1fr) minmax(0,1fr) auto' : 'minmax(0,1fr) minmax(0,1fr)'
|
|
53
33
|
return (
|
|
54
|
-
<div className={`
|
|
55
|
-
{
|
|
56
|
-
|
|
57
|
-
|
|
34
|
+
<div {...rest} className={`grid min-w-0 items-center gap-2 ${className}`.trim()} style={{ gridTemplateColumns: `var(--kol-kolbox-row-cols, var(--kol-field-pair-cols, ${cols}))`, ...rest.style }} data-property-row>
|
|
35
|
+
<div className={`flex min-w-0 ${span ? 'col-span-2' : ''}`}>{one}</div>
|
|
36
|
+
{!span && <div className="flex min-w-0">{two}</div>}
|
|
37
|
+
{trailing && <div className="col-start-3 -col-end-1 flex items-center justify-end gap-2">{trailing}</div>}
|
|
58
38
|
</div>
|
|
59
39
|
)
|
|
60
40
|
}
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
* `'settings'` (plan-2026-11-12-float-rails-figma W13.1): the generator settings window's row (`Dialog
|
|
38
38
|
* variant="settings"`): the label in Inter 10 at oq-64, 6 over the control; `horizontal` puts it beside the
|
|
39
39
|
* control, 8 apart, the label hugging its text (a `labelWidth` still sets a column).
|
|
40
|
-
* `'kolbox'` (plan-2026-11-
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
40
|
+
* `'kolbox'` and `'folio'` are accepted and do nothing (plan-2026-11-29-one-set-fold W2; their branches are
|
|
41
|
+
* in `_tmp/2026-11-29-one-set-fold/`): the look is the theme's. The label's type and ink, its column, the gaps,
|
|
42
|
+
* the row's least height and the body are `--kol-label-*` (kol-theme kol-components-molecules.css,
|
|
43
|
+
* LabeledControl); the default theme leaves them unset, `data-theme-variant="kolbox"` sets kolbox's (the label
|
|
44
|
+
* the UI text 11 / 16 at the label weight in oq-64, horizontal a 76 column 8 from the control and the row at
|
|
45
|
+
* least 24, the control cell a row 8 apart; stacked the label 4 over a row of controls 4 apart).
|
|
46
|
+
* controlFirst — bool: the control at the left, inset 4, then 8 apart its label (a checkbox row, kolbox's Clip content
|
|
47
|
+
* row), the row as tall as its control. The label is the help type (`--kol-label-help-*`; kolbox 11 / 15 in
|
|
48
|
+
* oq-64, unset the row's own).
|
|
49
49
|
* labelClass — the label's type and ink, replacing the variant's (a row that keeps its own label look: Slider's
|
|
50
50
|
* kol-helper-12, a toggle's words in the settings ink). On `panel` it defaults to kol-helper-8.
|
|
51
51
|
* children — the control body.
|
|
@@ -73,44 +73,11 @@ export default function LabeledControl({
|
|
|
73
73
|
controlFirst = false,
|
|
74
74
|
...rest
|
|
75
75
|
}) {
|
|
76
|
-
if (
|
|
77
|
-
const mark = { 'data-labeled-control': '', ...rest }
|
|
78
|
-
if (controlFirst) {
|
|
79
|
-
return (
|
|
80
|
-
<div {...mark} className={`kol-labeled-control--kolbox flex items-center gap-2 pl-1 ${className}`.trim()}>
|
|
81
|
-
{children}
|
|
82
|
-
<span className="kol-labeled-control-help min-w-0 flex-1 truncate">{label}</span>
|
|
83
|
-
</div>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
if (!(horizontal ?? inline ?? false)) {
|
|
87
|
-
return (
|
|
88
|
-
<div {...mark} className={`kol-labeled-control--kolbox flex flex-col gap-1 ${className}`.trim()}>
|
|
89
|
-
<span className="kol-labeled-control-label">{label}</span>
|
|
90
|
-
<div className="flex min-w-0 items-center gap-1">{children}</div>
|
|
91
|
-
</div>
|
|
92
|
-
)
|
|
93
|
-
}
|
|
76
|
+
if (controlFirst) {
|
|
94
77
|
return (
|
|
95
|
-
<div {...
|
|
96
|
-
<span className={`kol-labeled-control-label ${labelWidth == null ? 'w-19 ' : ''}shrink-0 truncate`} style={labelWidth == null ? undefined : { width: labelWidth }}>{label}</span>
|
|
97
|
-
<div className="flex min-w-0 flex-1 items-center gap-2">{children}</div>
|
|
98
|
-
</div>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
if (variant === 'folio') {
|
|
102
|
-
if (horizontal ?? inline ?? false) {
|
|
103
|
-
return (
|
|
104
|
-
<div {...rest} className={`kol-labeled-control--folio flex items-center gap-[12px] ${className}`.trim()}>
|
|
105
|
-
<p className="kol-labeled-control-label w-[48px] shrink-0">{label}</p>
|
|
106
|
-
<div className="flex min-w-0 flex-1 items-center">{children}</div>
|
|
107
|
-
</div>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
return (
|
|
111
|
-
<div {...rest} className={`kol-labeled-control--folio flex flex-col gap-[8px] ${className}`.trim()}>
|
|
112
|
-
<p className="kol-labeled-control-title">{label}</p>
|
|
78
|
+
<div data-labeled-control="" {...rest} className={`flex items-center gap-2 pl-1 ${className}`.trim()}>
|
|
113
79
|
{children}
|
|
80
|
+
<span className="kol-labeled-control-help min-w-0 flex-1 truncate">{label}</span>
|
|
114
81
|
</div>
|
|
115
82
|
)
|
|
116
83
|
}
|
|
@@ -131,10 +98,12 @@ export default function LabeledControl({
|
|
|
131
98
|
}
|
|
132
99
|
const showLabel = !!label
|
|
133
100
|
const settings = variant === 'settings'
|
|
134
|
-
|
|
101
|
+
/* the column: the caller's, the settings row's hug, else the theme's (unset 48) */
|
|
102
|
+
const lw = labelWidth ?? (settings ? 'fit-content' : 'var(--kol-label-w, 48px)')
|
|
135
103
|
const gapClass = settings ? (horizontal ?? inline ? 'gap-2' : 'gap-1.5') : null
|
|
136
104
|
const mark = { 'data-labeled-control': '', ...rest }
|
|
137
|
-
|
|
105
|
+
/* the label's own type is the theme's (`.kol-labeled-control-label`, unset kol-helper-10 tracked in the meta ink) */
|
|
106
|
+
const labelType = labelClass ?? (settings ? SETTINGS_LABEL : 'kol-labeled-control-label')
|
|
138
107
|
/* a display class from the caller replaces the wrapper's own (`hidden md:flex` must hold) */
|
|
139
108
|
const display = DISPLAY.test(className) ? '' : 'flex'
|
|
140
109
|
/* …and so does a gap class: the caller's spacing, not two utilities racing */
|
|
@@ -158,7 +127,7 @@ export default function LabeledControl({
|
|
|
158
127
|
* showed as "C" or not at all. Label on its line, the value under it. */
|
|
159
128
|
const labelAuto = lw === 'auto'
|
|
160
129
|
return (
|
|
161
|
-
<div {...mark} className={`${display} ${labelAuto ? `flex-col items-start gap-1 sm:flex-row ${text ? 'sm:items-baseline' : 'sm:items-center'} sm:gap-3` :
|
|
130
|
+
<div {...mark} className={`${display} ${labelAuto ? `flex-col items-start gap-1 sm:flex-row ${text ? 'sm:items-baseline' : 'sm:items-center'} sm:gap-3` : `kol-labeled-control-row ${text ? 'items-baseline' : 'items-center'} ${ownGap ? '' : gapClass ?? ''}`}${className}`}>
|
|
162
131
|
{showLabel && (
|
|
163
132
|
<span
|
|
164
133
|
/* A LABEL NEVER WRAPS (review 2, § 6.2 — the helper law by construction, 01-foundations/03-typography.md:29):
|
|
@@ -169,17 +138,17 @@ export default function LabeledControl({
|
|
|
169
138
|
{labelInner}
|
|
170
139
|
</span>
|
|
171
140
|
)}
|
|
172
|
-
<div className={`${text ? 'flex ' : settings ? 'flex items-center ' : ''}${labelAuto ? 'min-w-0 max-w-full sm:overflow-hidden' : 'flex-1 min-w-0'}`}>{children}</div>
|
|
141
|
+
<div className={`${text ? 'flex ' : settings ? 'flex items-center ' : labelAuto ? '' : 'kol-labeled-control-cell '}${labelAuto ? 'min-w-0 max-w-full sm:overflow-hidden' : 'flex-1 min-w-0'}`}>{children}</div>
|
|
173
142
|
</div>
|
|
174
143
|
)
|
|
175
144
|
}
|
|
176
145
|
|
|
177
146
|
return (
|
|
178
|
-
<div {...mark} className={`${display} flex-col ${ownGap ? '' : gapClass ?? '
|
|
147
|
+
<div {...mark} className={`${display} flex-col ${settings ? '' : 'kol-labeled-control-stack'} ${ownGap ? '' : gapClass ?? ''} ${className}`}>
|
|
179
148
|
{showLabel && (
|
|
180
149
|
<span className={labelType}>{labelInner}</span>
|
|
181
150
|
)}
|
|
182
|
-
{children}
|
|
151
|
+
{settings ? children : <div className="kol-labeled-control-body">{children}</div>}
|
|
183
152
|
</div>
|
|
184
153
|
)
|
|
185
154
|
}
|