@kolkrabbi/kol-component 0.261.0 → 0.263.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.261.0",
3
+ "version": "0.263.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,6 +21,9 @@ import { PopoverPanel, usePopover } from '../utilities/Popover.jsx'
21
21
  */
22
22
  /* the ladder's tokens, so the touch rung (D5, 2026-09-29) grows the trigger with its row */
23
23
  const TRIGGER_H = { xs: 'var(--kol-ctl-xs)', sm: 'var(--kol-ctl-sm)', md: 'var(--kol-ctl-md)', lg: 'var(--kol-ctl-lg)' }
24
+ /* and its type: xs wears its rows' face, as `Button size="xs"` beside it does (MenuItemXsTriggerType,
25
+ * kol-monitor 2026-10-15 — 12px helper type in a 22px box) */
26
+ const TRIGGER_BY_SIZE = { xs: 'kol-mono-8 px-2', sm: 'kol-helper-12 px-3', md: 'kol-helper-12 px-3', lg: 'kol-helper-12 px-3' }
24
27
 
25
28
  export function MenuItem({
26
29
  label,
@@ -61,7 +64,7 @@ export function MenuItem({
61
64
  ref={popover.refs.setReference}
62
65
  {...popover.getReferenceProps()}
63
66
  type="button"
64
- className={`kol-menu-btn kol-helper-12 px-3 inline-flex items-center gap-2 rounded text-body hover:text-emphasis transition-colors ${buttonClassName}`}
67
+ className={`kol-menu-btn ${TRIGGER_BY_SIZE[size] ?? TRIGGER_BY_SIZE.md} inline-flex items-center gap-2 rounded text-body hover:text-emphasis transition-colors ${buttonClassName}`}
65
68
  style={{ height: TRIGGER_H[size] ?? TRIGGER_H.md }}
66
69
  >
67
70
  <span>{label}</span>
@@ -24,6 +24,8 @@
24
24
  * @param {string} as element to render (`div` · `button` · `li`)
25
25
  * @param {boolean} hover false = hover paints nothing (the media browser's ruling, 2026-09-02)
26
26
  * @param {boolean} muted a row that is there but not the point (fg-48)
27
+ * @param {boolean} disabled a row that is there but cannot be picked: the disabled opacity, no
28
+ * hover, not-allowed — the caller keeps it out of its keyboard order
27
29
  *
28
30
  * `ROW_HEIGHT` / `ROW_TYPE` / `ROW_FILL` are exported for a row that cannot take this anatomy (the
29
31
  * media rows view's table row: twisty, drag hit, columns) — it still sits on the same ramp and fills.
@@ -60,6 +62,7 @@ export default function OptionRow({
60
62
  trail = false,
61
63
  hover = true,
62
64
  muted = false,
65
+ disabled = false,
63
66
  icon,
64
67
  leading,
65
68
  label,
@@ -69,12 +72,13 @@ export default function OptionRow({
69
72
  children,
70
73
  ...rest
71
74
  }) {
72
- const state = selected ? ROW_FILL.selected : active ? ROW_FILL.active : trail ? ROW_FILL.trail
75
+ const state = disabled ? 'text-fg-80 opacity-[var(--kol-opacity-disabled)]'
76
+ : selected ? ROW_FILL.selected : active ? ROW_FILL.active : trail ? ROW_FILL.trail
73
77
  : `${muted ? 'text-fg-48' : 'text-fg-80'}${hover ? ` hover:${TONE}` : ''}`
74
78
  const lead = leading ?? (icon && <Icon name={icon} size={glyphSize(size)} />)
75
79
  return (
76
80
  <Tag
77
- className={`flex items-center gap-2 px-4 border border-transparent ${ROW_HEIGHT[size] ?? ROW_HEIGHT.md} rounded-[var(--kol-radius-sm)] cursor-pointer text-left ${type ?? ROW_TYPE[size] ?? ROW_TYPE.md} transition-colors ${state} ${className}`.trim()}
81
+ className={`flex items-center gap-2 px-4 border border-transparent ${ROW_HEIGHT[size] ?? ROW_HEIGHT.md} rounded-[var(--kol-radius-sm)] ${disabled ? 'cursor-not-allowed' : 'cursor-pointer'} text-left ${type ?? ROW_TYPE[size] ?? ROW_TYPE.md} transition-colors ${state} ${className}`.trim()}
78
82
  {...rest}
79
83
  >
80
84
  {/* the glyph takes the row's ink when selected — a grey mark on a white fill reads as a hole */}
@@ -913,8 +913,10 @@ function LibraryHeader({ title, buckets, bucketId, appRoot, onBucket, bucketMeta
913
913
  * like a home button"). The crumb row's root already did exactly this and the wordmark above it
914
914
  * did nothing — the one element every file manager makes clickable was the one that was inert.
915
915
  * Without the prop it stays a plain <h1>, so nothing existing changes. */
916
+ /* CENTRED, not baseline (MediaPickerHeaderCentred, kol-monitor 2026-10-16): on the baseline the
917
+ * controls' 12px text sat on the display title's, so every control box hung below the wordmark */
916
918
  return (
917
- <header className="flex items-baseline justify-between gap-4">
919
+ <header className="flex items-center justify-between gap-4">
918
920
  {onHome ? (
919
921
  <button type="button" onClick={onHome}
920
922
  className={`${titleCls} text-fg-96 min-w-0 truncate text-left cursor-pointer transition-opacity hover:opacity-64`}
@@ -952,8 +954,9 @@ function LibraryHeader({ title, buckets, bucketId, appRoot, onBucket, bucketMeta
952
954
  </div>
953
955
  {/* THE × IS THE CARD'S, NOT A CONTROL (media-picker-close-and-title, kol-mirror 2026-10-15 — user:
954
956
  * "you ever seen a close out button before??", pointing at the Display Settings drawer). Alone at
955
- * the far end of the title's row, outside the control cluster — the drawer's shape. */}
956
- {onClose && <CloseButton onClick={onClose} className="shrink-0 self-center" />}
957
+ * the far end of the title's row, outside the control cluster — the drawer's shape. It centres with
958
+ * the row like every control in it. */}
959
+ {onClose && <CloseButton onClick={onClose} className="shrink-0" />}
957
960
  </header>
958
961
  )
959
962
  }
@@ -76,7 +76,7 @@ export function HighlightMatch({ label, query, ranges }) {
76
76
  *
77
77
  * @param {boolean} open mount/unmount the overlay
78
78
  * @param {Function} onClose () => void — backdrop click, Escape, post-select
79
- * @param {Array} results pre-filtered rows: { id, label, group?, hint?, icon? }
79
+ * @param {Array} results pre-filtered rows: { id, label, group?, hint?, icon?, disabled?, disabledHint? }
80
80
  * @param {Array} [suggestions] rows shown while the query is empty (same shape) —
81
81
  * the search modal opens on somewhere to go, not a blank box
82
82
  * @param {string} query controlled query (drives the highlight slice)
@@ -126,7 +126,14 @@ export default function ShellSearchOverlay({
126
126
  * index 0 counts as a selection and Enter navigates somewhere unasked. */
127
127
  const [navigated, setNavigated] = useState(false)
128
128
  const results = groupRows(query ? rawResults : suggestions)
129
- const active = results.length > 0 ? Math.min(activeIndex, results.length - 1) : -1
129
+ /* a `disabled` row is drawn but never active: ↑↓ step over it, Enter and click never reach
130
+ * `onSelect` (ShellSearchDisabledRow, kol-monitor 2026-10-15 — a module with no room on the rack) */
131
+ const clamped = Math.min(activeIndex, results.length - 1)
132
+ const active = clamped >= 0 && !results[clamped].disabled ? clamped : -1
133
+ const step = (from, dir) => {
134
+ for (let i = from + dir; i >= 0 && i < results.length; i += dir) if (!results[i].disabled) return i
135
+ return from
136
+ }
130
137
 
131
138
  /* Focus in on open, restore the opener on close. querySelector instead of
132
139
  * a ref through SearchInput — ref-as-prop needs React 19 and the package
@@ -143,7 +150,7 @@ export default function ShellSearchOverlay({
143
150
  * suggestions for a category's presets). Keyed on the row ids, not the array's identity, so a
144
151
  * consumer passing a fresh array every render does not snap the highlight back to the top. */
145
152
  const rowsKey = results.map((r) => r.id).join('\u0000')
146
- useEffect(() => { setActiveIndex(0); setNavigated(false) }, [query, open, rowsKey])
153
+ useEffect(() => { setActiveIndex(Math.max(0, results.findIndex((r) => !r.disabled))); setNavigated(false) }, [query, open, rowsKey]) // eslint-disable-line react-hooks/exhaustive-deps
147
154
 
148
155
  /* Keep the active row visible inside the scrolling list. */
149
156
  useEffect(() => {
@@ -158,6 +165,7 @@ export default function ShellSearchOverlay({
158
165
  * still reaches `onSelect`, and the closure stays the consumer's to run there: the overlay running
159
166
  * it too would fire it twice in every shell that already does (workshop's tag rows). */
160
167
  const select = (item) => {
168
+ if (item?.disabled) return
161
169
  onSelect?.(item)
162
170
  if (!(item?.keepOpen || typeof item?.action === 'function')) onClose?.()
163
171
  }
@@ -171,11 +179,11 @@ export default function ShellSearchOverlay({
171
179
  } else if (e.key === 'ArrowDown') {
172
180
  e.preventDefault()
173
181
  setNavigated(true)
174
- setActiveIndex((i) => Math.min(i + 1, results.length - 1))
182
+ setActiveIndex((i) => step(Math.min(i, results.length - 1), 1))
175
183
  } else if (e.key === 'ArrowUp') {
176
184
  e.preventDefault()
177
185
  setNavigated(true)
178
- setActiveIndex((i) => Math.max(i - 1, 0))
186
+ setActiveIndex((i) => step(Math.min(i, results.length - 1), -1))
179
187
  } else if (e.key === 'Enter') {
180
188
  e.preventDefault()
181
189
  /* ⌘ENTER OPENS EVERY HIT (user 2026-09-30: *"enter would focus searched item, and maybe
@@ -258,6 +266,8 @@ export default function ShellSearchOverlay({
258
266
  * hint subtext shown when the LABEL was not what matched
259
267
  * href a destination; dismisses the search modal
260
268
  * action a closure, run by the consumer's `onSelect`; the search modal STAYS OPEN (tag rows)
269
+ * disabled drawn muted, skipped by ↑↓, never reaches `onSelect`; `disabledHint` replaces
270
+ * `hint` with the reason (a full rack: "no room")
261
271
  * keepOpen the row selects and the search modal STAYS OPEN — a drill-in (category →
262
272
  * its items, a "← All" row back); the consumer swaps `suggestions`/`results`
263
273
  * Built by `buildShellSearchItems` (showcase/src/nav/shell-nav.js). */}
@@ -282,14 +292,16 @@ export default function ShellSearchOverlay({
282
292
  id={optionId(item)}
283
293
  role="option"
284
294
  aria-selected={i === active}
295
+ aria-disabled={item.disabled || undefined}
285
296
  active={i === active}
297
+ disabled={item.disabled}
286
298
  icon={item.icon}
287
299
  label={<HighlightMatch label={item.label} query={query} ranges={item.highlights} />}
288
- hint={item.hint}
300
+ hint={(item.disabled && item.disabledHint) || item.hint}
289
301
  /* preventDefault keeps focus in the input through the click */
290
302
  onMouseDown={(e) => e.preventDefault()}
291
303
  onClick={() => select(item)}
292
- onMouseEnter={() => { setActiveIndex(i); setNavigated(true) }}
304
+ onMouseEnter={() => { if (!item.disabled) { setActiveIndex(i); setNavigated(true) } }}
293
305
  />
294
306
  </li>
295
307
  )
@@ -156,6 +156,9 @@ const TooltipNest = createContext(null)
156
156
  * element that takes a ref: an intrinsic tag always does; a component only if it forwards one
157
157
  * (React 18 needs forwardRef), so Button / IconFrame keep the wrapper. Its own ref and handlers are
158
158
  * kept — the reference props merge over the child's. */
159
+ /* `disabled` (HardwareNativeTitle, kol-monitor 2026-10-15): the tooltip stays mounted but never
160
+ * opens — a jack mid-patch. Dropping the label instead would swap the tree and remount the trigger
161
+ * under the pointer. */
159
162
  const childRefOf = (el) => ('ref' in (el.props ?? {}) ? el.props.ref : reactVersion.startsWith('18') ? el.ref : undefined)
160
163
 
161
164
  export function Tooltip(props) {
@@ -173,12 +176,13 @@ function TooltipOn({
173
176
  children,
174
177
  triggerClassName = 'inline-flex',
175
178
  asChild = false,
179
+ disabled = false,
176
180
  }) {
177
181
  const [open, setOpen] = useState(false)
178
182
  const [covered, setCovered] = useState(false)
179
183
  const parent = useContext(TooltipNest)
180
184
  const popover = usePopover({
181
- open: open && !covered,
185
+ open: open && !covered && !disabled,
182
186
  onOpenChange: (v) => { setOpen(v); parent?.(v) },
183
187
  placement,
184
188
  offset,
@@ -194,7 +198,7 @@ function TooltipOn({
194
198
  * trigger's RESOLVED `--kol-tone-*` onto the panel. No tone in effect = nothing copied, and the
195
199
  * tooltip keeps its own surface. */
196
200
  const [ambient, setAmbient] = useState(null)
197
- const shown = open && !covered
201
+ const shown = open && !covered && !disabled
198
202
  useLayoutEffect(() => {
199
203
  const ref = popover.refs.reference.current
200
204
  /* the SURROUNDINGS' tone, not the trigger's own: an `asChild` trigger can be a variant button