@kolkrabbi/kol-component 0.175.0 → 0.176.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolkrabbi/kol-component",
3
- "version": "0.175.0",
3
+ "version": "0.176.0",
4
4
  "description": "KOL design-system components — atoms through organisms, emitting canonical kol-* classes. Pairs with @kolkrabbi/kol-theme for styling.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -12,13 +12,13 @@ import { glyphSize } from '../hooks/glyphLadders.js'
12
12
  *
13
13
  * @param {Object} props
14
14
  * @param {ReactNode} props.children - Button content
15
- * @param {'primary'|'secondary'|'accent'|'outline'|'ghost'|'nav'|'danger'|'grey'|'control'} props.variant - Visual variant. `danger` is the destructive treatment (--ui-error fill); `nav` is the chrome rung — transparent, oq-64 ink, one step brighter than `ghost`; `control` is an alias for `ghost` (legacy call-sites).
15
+ * @param {'primary'|'secondary'|'accent'|'outline'|'ghost'|'nav'|'danger'|'grey'|'control'} props.variant - Visual variant. UNSET (the default) inherits the tone of the nearest `kol-tone-*` wrapper, else renders primary; the five ground variants are aliases of `tone`. `danger` is the destructive treatment (--ui-error fill); `nav` is the chrome rung — transparent, oq-64 ink, one step brighter than `ghost`; `control` is an alias for `ghost` (legacy call-sites).
16
16
  * @param {'xs'|'sm'|'md'|'lg'} props.size - Button size (default: 'md'); xs is the panel rung (ControlsXsRung, 2026-09-01) — kol-mono-8 in a 22px shell (20 icon-only), opt-in by prop
17
17
  * @param {string} props.iconLeft - Icon name to display on the left
18
18
  * @param {string} props.iconRight - Icon name to display on the right
19
19
  * @param {string} props.iconLeftHover - Icon to show on hover (left position)
20
20
  * @param {string} props.iconRightHover - Icon to show on hover (right position)
21
- * @param {'default'|'sunken'} props.tone - `sunken` = the control set's dark well + fg-96 ink (ControlToneSunken); `inverse` aliased
21
+ * @param {'primary'|'secondary'|'outline'|'ghost'|'grey'|'sunken'} props.tone - the ground (tone-is-the-ground-axis, 2026-09-03) — wins over `variant` on the same element; unset = inherit the wrapper's. `sunken` = the control set's dark well + fg-96 ink (ControlToneSunken); `inverse` aliased
22
22
  * @param {string} props.iconOnly - Icon name for icon-only button
23
23
  * @param {string} props.iconOnlyHover - Icon to show on hover (icon-only)
24
24
  * @param {boolean} props.animateIcon - Disable default hover states to focus on icon animation
@@ -38,7 +38,7 @@ import { glyphSize } from '../hooks/glyphLadders.js'
38
38
  */
39
39
  const Button = ({
40
40
  children,
41
- variant = 'primary',
41
+ variant,
42
42
  size = 'md',
43
43
  iconLeft,
44
44
  iconRight,
@@ -73,27 +73,16 @@ const Button = ({
73
73
  // variant="control" keep working post-migration).
74
74
  const resolvedVariant = variant === 'control' ? 'ghost' : variant
75
75
 
76
- const variantClass = resolvedVariant === 'primary'
77
- ? 'kol-btn-primary'
78
- : resolvedVariant === 'accent'
79
- ? 'kol-btn-accent'
80
- : resolvedVariant === 'outline'
81
- ? 'kol-btn-outline'
82
- : resolvedVariant === 'ghost'
83
- ? 'kol-btn-ghost'
84
- : resolvedVariant === 'danger'
85
- ? 'kol-btn-danger'
86
- : resolvedVariant === 'grey'
87
- ? 'kol-btn-grey'
88
- /* `nav` — transparent box, oq-64 ink (2026-08-01). The class had lived in
89
- * the theme since the shell landed with NO component able to emit it, so
90
- * every consumer that wanted this exact weight hand-wrote the box instead:
91
- * that orphan is the direct cause of the four-container header. It is the
92
- * chrome rung — one step brighter than `ghost` at oq-48 — and it is what
93
- * `text-fg-64` meant every time a call site typed it. */
94
- : resolvedVariant === 'nav'
95
- ? 'kol-btn-nav'
96
- : 'kol-btn-secondary'
76
+ /* THE GROUND IS A TONE (tone-is-the-ground-axis, 2026-09-03). No variant →
77
+ * NO class: the button paints from the `--kol-tone-*` properties it inherits
78
+ * from a toned wrapper, else the theme's primary fallback — that is how a
79
+ * set gets its tone "already set". An explicit variant stamps its class,
80
+ * which is an alias of the tone (primary · secondary · outline · ghost ·
81
+ * grey) or its own bundle (nav · danger · accent); `nav` is ghost's chrome
82
+ * rung, oq-80 ink + aria-current — it had lived in the theme with no
83
+ * component able to emit it, the direct cause of the four-container header. */
84
+ const KNOWN = ['primary', 'secondary', 'accent', 'outline', 'ghost', 'nav', 'danger', 'grey']
85
+ const variantClass = !resolvedVariant ? '' : KNOWN.includes(resolvedVariant) ? `kol-btn-${resolvedVariant}` : 'kol-btn-secondary'
97
86
 
98
87
  // Add size class — pairs the padding rule with its mono type class.
99
88
  const sizeClass = size === 'sm'
@@ -60,7 +60,7 @@ import { toneClass } from '../utilities/tone.js'
60
60
  * Want the wash, the pressed fill or the disabled dim? That is `Button`.
61
61
  *
62
62
  * @param {string} name icon name (kol-icons)
63
- * @param {string} variant primary|secondary|accent|outline|ghost|nav|grey|danger
63
+ * @param {string} variant primary|secondary|accent|outline|ghost|nav|grey|danger — unset inherits the nearest `kol-tone-*` wrapper's tone, else secondary
64
64
  * @param {string} size xs|sm|md|lg — square + glyph together (xs = 20px square, 12 glyph; the panel rung, 2026-09-01)
65
65
  * @param {string} radius sm (default, the system's 4px) | full (9999px).
66
66
  * Two values, nothing between: a round frame is its
@@ -78,7 +78,7 @@ const GLYPH = SOLO
78
78
 
79
79
  export default function IconFrame({
80
80
  name,
81
- variant = 'secondary',
81
+ variant,
82
82
  size = 'md',
83
83
  radius = 'sm',
84
84
  iconSize = null,
@@ -92,7 +92,8 @@ export default function IconFrame({
92
92
  const radiusCls = radius === 'full' ? ' kol-icon-frame-radius-full' : ''
93
93
  const resolvedIconSize = iconSize ?? GLYPH[size] ?? GLYPH.md
94
94
  /* `tone="sunken"` (ControlToneSunken, 2026-08-28) — the control set's dark well + fg-96 ink, no states, as ever */
95
- const cls = `kol-icon-frame kol-icon-frame-${variant} kol-icon-frame-${size}${radiusCls} ${toneClass(tone)} ${className}`.replace(/\s+/g, ' ').trim()
95
+ /* no variant no class: the frame inherits a wrapper's tone, else secondary (2026-09-03) */
96
+ const cls = `kol-icon-frame${variant ? ` kol-icon-frame-${variant}` : ''} kol-icon-frame-${size}${radiusCls} ${toneClass(tone)} ${className}`.replace(/\s+/g, ' ').trim()
96
97
  const glyph = <Icon name={name} size={resolvedIconSize} />
97
98
 
98
99
  /* The element follows the affordance, and the CLASS is identical in all three
@@ -6,7 +6,8 @@ import { glyphSize } from '../hooks/glyphLadders.js'
6
6
  /**
7
7
  * Input — single-input atom built on the .kol-control shell.
8
8
  *
9
- * variant="filled" (default) persistent solid bg (= button primary chrome)
9
+ * variant unset (default) the nearest `kol-tone-*` wrapper's tone, else filled
10
+ * variant="filled" — persistent solid bg (= button primary chrome)
10
11
  * variant="outline" — bordered, transparent bg — THE secondary
11
12
  * treatment (2026-07-08 chrome law: one
12
13
  * secondary, always subordinate to filled)
@@ -61,7 +62,7 @@ export default function Input({
61
62
  value,
62
63
  onChange,
63
64
  onCommit,
64
- variant = 'filled',
65
+ variant,
65
66
  tone = 'default',
66
67
  size = 'md',
67
68
  chars,
@@ -95,7 +96,8 @@ export default function Input({
95
96
 
96
97
  const shellCls = [
97
98
  'kol-control',
98
- `kol-control--${resolvedVariant}`,
99
+ /* no variant → no modifier: the shell inherits a wrapper's tone, else filled (2026-09-03) */
100
+ resolvedVariant && `kol-control--${resolvedVariant}`,
99
101
  `kol-control-${size}`,
100
102
  SIZE_TYPE[size],
101
103
  'cursor-text',
@@ -78,7 +78,7 @@ const ViewToggle = ({
78
78
  * consumer subtracted it with a `-ml-1` on the neighbour. `-mx-1` draws the padding inward from the
79
79
  * declared box — the chips sit where the box says, the well bleeds 4px into the gap. */
80
80
  const containerClasses = isIconVariant
81
- ? `kol-view-toggle inline-flex items-center gap-1 p-1 -mx-1 bg-surface-secondary rounded ${toneClass(tone)} ${className}`.replace(/\s+/g, ' ').trim()
81
+ ? `kol-view-toggle inline-flex items-center gap-1 p-1 -mx-1 rounded ${toneClass(tone)} ${className}`.replace(/\s+/g, ' ').trim()
82
82
  : `flex gap-2 ${className}`
83
83
 
84
84
  const buttonClasses = (isActive) => {
@@ -95,7 +95,7 @@ const ViewToggle = ({
95
95
  * hover; that's deliberately gone.) */
96
96
  return isActive
97
97
  ? `kol-control kol-control--filled kol-control-${size} kol-mono-${size === 'md' ? '14' : '12'}`
98
- : `kol-control kol-control-${size} kol-mono-${size === 'md' ? '14' : '12'} text-meta hover:text-emphasis`
98
+ : `kol-control kol-control--plain kol-control-${size} kol-mono-${size === 'md' ? '14' : '12'} text-meta hover:text-emphasis`
99
99
  }
100
100
 
101
101
  return (
@@ -1,5 +1,5 @@
1
- import { useEffect, useRef, useState } from 'react'
2
- import { toneClass } from '../utilities/tone.js'
1
+ import { useEffect, useLayoutEffect, useRef, useState } from 'react'
2
+ import { toneClass, TONE_VARS } from '../utilities/tone.js'
3
3
  import { Icon } from '@kolkrabbi/kol-icons'
4
4
  import { MenuDropdownItem } from './MenuItem.jsx'
5
5
  import { PopoverPanel, usePopover } from '../utilities/Popover.jsx'
@@ -13,7 +13,9 @@ import { indicatorSize } from '../hooks/glyphLadders.js'
13
13
  * active, focus ring all come from the button rules in kol-theme.
14
14
  * `.kol-dd-*` classes only add trigger layout + the open/panel fusion.
15
15
  *
16
- * variant="primary" (default) filled trigger; open panel continues the
16
+ * variant unset (default) the tone of the nearest `kol-tone-*` wrapper,
17
+ * else primary (tone-is-the-ground-axis, 2026-09-03)
18
+ * variant="primary" — filled trigger; open panel continues the
17
19
  * same fill (one piece: no border, no gap, hairline divider inside)
18
20
  * variant="grey" — oq-12 filled trigger (opaque per the fill
19
21
  * law); panel continues it
@@ -46,7 +48,7 @@ const Dropdown = ({
46
48
  value,
47
49
  onChange,
48
50
  size,
49
- variant = 'primary',
51
+ variant,
50
52
  tone = 'default',
51
53
  /* DropdownGhostWidthAndListHeight (kol-mirror 2026-08-28 — user, on the
52
54
  * studio's 30-option Source picker in a ~300px shelf: "1 it's way too tall,
@@ -80,6 +82,22 @@ const Dropdown = ({
80
82
  }) => {
81
83
  const [isOpen, setIsOpen] = useState(defaultOpen)
82
84
 
85
+ /* THE PANEL IS PORTALLED (FloatingPortal → body), so a tone the trigger
86
+ * INHERITS from a toned wrapper never reaches it through the cascade — the
87
+ * exact failure the 2026-08-30 page-wash attempt hit. On open, copy the
88
+ * trigger's RESOLVED `--kol-tone-*` onto the panel as inline style: an
89
+ * explicit variant / tone class on the panel sets the same values, and the
90
+ * ambient case is the one only this can serve. */
91
+ const triggerRef = useRef(null)
92
+ const [ambient, setAmbient] = useState(null)
93
+ useLayoutEffect(() => {
94
+ if (!isOpen || !triggerRef.current) return
95
+ const cs = getComputedStyle(triggerRef.current)
96
+ const vars = {}
97
+ for (const v of TONE_VARS) { const val = cs.getPropertyValue(v).trim(); if (val) vars[v] = val }
98
+ setAmbient(vars)
99
+ }, [isOpen])
100
+
83
101
  // sm everywhere unless explicitly overridden (see docblock size law).
84
102
  const resolvedSize = size || 'sm'
85
103
 
@@ -141,7 +159,7 @@ const Dropdown = ({
141
159
  'kol-btn',
142
160
  /* grey is dropdown-only chrome (2026-07-15) — no kol-btn-* class so it
143
161
  * never leaks into Button's variant set */
144
- resolvedVariant === 'grey' ? 'kol-dd-trigger--grey' : `kol-btn-${resolvedVariant}`,
162
+ resolvedVariant === 'grey' ? 'kol-dd-trigger--grey' : resolvedVariant && `kol-btn-${resolvedVariant}`,
145
163
  `kol-btn-${resolvedSize}`,
146
164
  SIZE_TYPE[resolvedSize],
147
165
  'kol-dd-trigger',
@@ -153,7 +171,7 @@ const Dropdown = ({
153
171
  return (
154
172
  <div className={`kol-dd-root relative inline-block align-middle ${className}`}>
155
173
  <button
156
- ref={popover.refs.setReference}
174
+ ref={(el) => { triggerRef.current = el; popover.refs.setReference(el) }}
157
175
  {...popover.getReferenceProps()}
158
176
  type="button"
159
177
  className={triggerCls}
@@ -181,8 +199,9 @@ const Dropdown = ({
181
199
  popover={popover}
182
200
  panel={false}
183
201
  focus={false}
184
- className={`kol-dd-panel kol-dd-panel--${resolvedVariant} ${toneClass(tone)}`.trim()}
202
+ className={`kol-dd-panel ${resolvedVariant ? `kol-dd-panel--${resolvedVariant}` : ''} ${toneClass(tone)}`.replace(/\s+/g, ' ').trim()}
185
203
  style={{
204
+ ...ambient,
186
205
  '--kol-dd-max-rows': maxRows ?? 10,
187
206
  /* xs rows are 20px; the panel's max-height reads the row height */
188
207
  ...(resolvedSize === 'xs' && rowHeight == null ? { '--kol-dd-row-h': '20px' } : null),
@@ -77,7 +77,7 @@ export default function SearchInput({
77
77
  shortcutHint,
78
78
  onFocus,
79
79
  size = 'md',
80
- variant = 'filled',
80
+ variant,
81
81
  tone = 'default',
82
82
  bare = false,
83
83
  expanding = false,
@@ -157,7 +157,7 @@ export default function SearchInput({
157
157
  control: 22 · 26 · 32 · 40 (01-foundations/09-sizes.md). This was a
158
158
  hardcoded 36 — the LG square — so an expanding search sat beside a
159
159
  `kol-btn-md` filter button at two different sizes. */
160
- className={`kol-expand flex items-center rounded-full ${isOpen ? (toneClass(tone) ? 'kol-tone-sunken' : 'bg-fg-04') : ''} ${className}`.trim()}
160
+ className={`kol-expand flex items-center rounded-full ${isOpen ? `kol-expand--open ${toneClass(tone)}` : ''} ${className}`.replace(/\s+/g, ' ').trim()}
161
161
  style={{ height: isOpen ? fieldH : square, width: isOpen ? expandedWidth : square }}
162
162
  >
163
163
  {/* THE GLYPH IS THE CLOSED STATE, and only that (user ruling
@@ -201,7 +201,7 @@ export default function SearchInput({
201
201
  /* kol-control--bare: zero-chrome marker so the theme's coarse-pointer
202
202
  * 16px floor covers this body plan too (OverlaySearchFieldZoomsIOS) */
203
203
  ? 'kol-control--bare flex w-full gap-2.5 px-4 py-3'
204
- : `kol-control kol-control--${variant} kol-control-${size} gap-2${toneClass(tone) ? ' kol-tone-sunken' : ''}`,
204
+ : `kol-control${variant ? ` kol-control--${variant}` : ''} kol-control-${size} gap-2${toneClass(tone) ? ` ${toneClass(tone)}` : ''}`,
205
205
  'items-center cursor-text',
206
206
  SIZE_TYPE[size],
207
207
  className,
@@ -1,8 +1,31 @@
1
1
  /**
2
- * toneClass — the control set's ONE sunken tone (ControlToneSunken,
3
- * kol-website 2026-08-28; user ruling: it is not "inverse" — the control does
4
- * not invert anything, it sits BELOW the plane it is on — call it `sunken`).
5
- * `inverse` (0.117.0's name) is an alias: every consumer on it renders the same
6
- * pixel. The rules are kol-theme's `.kol-tone-sunken`.
2
+ * toneClass — the control set's TONE, six values (tone-is-the-ground-axis,
3
+ * kol-client-olina 2026-09-03; the six-tone list is the user's).
4
+ *
5
+ * primary · secondary · outline · ghost · grey · sunken
6
+ *
7
+ * A tone is a ground-and-ink bundle — `--kol-tone-*` custom properties in
8
+ * kol-theme (kol-components-molecules.css, TONE) that every control paints
9
+ * from. `default` is NOT a tone: it is the absence of one — the control
10
+ * inherits its wrapper's tone (one `kol-tone-*` class on any ancestor), else
11
+ * its family's fallback. That is the whole mechanism of "get a set with it
12
+ * already set": nothing is stamped, so the inheritance is not blocked.
13
+ *
14
+ * `inverse` is `sunken`'s alias (0.117.0's name — ControlToneSunken,
15
+ * kol-website 2026-08-28; user ruling: the control does not invert anything,
16
+ * it sits BELOW the plane it is on).
7
17
  */
8
- export const toneClass = (tone) => (tone === 'sunken' || tone === 'inverse' ? 'kol-tone-sunken' : '')
18
+ export const TONES = ['primary', 'secondary', 'outline', 'ghost', 'grey', 'sunken']
19
+
20
+ export const toneClass = (tone) =>
21
+ tone === 'inverse' ? 'kol-tone-sunken' : TONES.includes(tone) ? `kol-tone-${tone}` : ''
22
+
23
+ /* the properties a bundle sets — Dropdown copies them from its trigger onto
24
+ * the PORTALLED panel, which the cascade cannot reach */
25
+ export const TONE_VARS = [
26
+ 'bg', 'image', 'fg', 'border',
27
+ 'hover-bg', 'hover-image', 'hover-fg', 'hover-border',
28
+ 'active-bg', 'active-image',
29
+ 'pressed-bg', 'pressed-image', 'pressed-fg',
30
+ 'panel-bg', 'panel-border-w', 'panel-border',
31
+ ].map((k) => `--kol-tone-${k}`)