@kolkrabbi/kol-component 0.272.0 → 0.273.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.272.0",
3
+ "version": "0.273.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -43,6 +43,10 @@ import Kbd from '../atoms/Kbd.jsx'
43
43
  * @param {Function} onOpenChange (expanding) (bool) => void — trigger click / Escape
44
44
  * @param {number} expandedWidth (expanding) open pill width in px (default 280)
45
45
  * @param {string} triggerLabel (expanding) aria-label on the icon trigger (default 'Open search')
46
+ * @param {Function} [onBack] a drill-in's way back: the leading search glyph becomes a back arrow IN THE SAME
47
+ * SLOT, so the field never moves (CommandOverlay's second layer — user 2026-10-18:
48
+ * *"why would the back move the input?!"*)
49
+ * @param {string} [backLabel] the back arrow's aria-label (default `Back`)
46
50
  * @param {string} className extra classes on the shell
47
51
  */
48
52
 
@@ -88,6 +92,8 @@ export default function SearchInput({
88
92
  iconSize,
89
93
  fieldHeight,
90
94
  triggerLabel = 'Open search',
95
+ onBack,
96
+ backLabel = 'Back',
91
97
  className = '',
92
98
  ...inputProps
93
99
  }) {
@@ -226,13 +232,26 @@ export default function SearchInput({
226
232
 
227
233
  return (
228
234
  <label className={shellCls}>
229
- <span
230
- aria-hidden="true"
231
- className={`flex items-center shrink-0 ${bare ? 'text-oq-48' : 'text-auto opacity-50'}`}
232
- >
233
- {/* ADJACENT — this glyph sits in the field's line box beside the query */}
234
- <Icon name="search" size={iconSize ?? glyphSize(size)} />
235
- </span>
235
+ {onBack ? (
236
+ <button
237
+ type="button"
238
+ aria-label={backLabel}
239
+ /* mousedown keeps focus in the field */
240
+ onMouseDown={(e) => e.preventDefault()}
241
+ onClick={onBack}
242
+ className={`flex items-center shrink-0 cursor-pointer transition-colors ${bare ? 'text-oq-48 hover:text-oq-96' : 'text-auto opacity-50 hover:opacity-100'}`}
243
+ >
244
+ <Icon name="arrow-left" size={iconSize ?? glyphSize(size)} />
245
+ </button>
246
+ ) : (
247
+ <span
248
+ aria-hidden="true"
249
+ className={`flex items-center shrink-0 ${bare ? 'text-oq-48' : 'text-auto opacity-50'}`}
250
+ >
251
+ {/* ADJACENT — this glyph sits in the field's line box beside the query */}
252
+ <Icon name="search" size={iconSize ?? glyphSize(size)} />
253
+ </span>
254
+ )}
236
255
  <input
237
256
  type="search"
238
257
  value={value ?? ''}
@@ -4,8 +4,6 @@ import SearchInput from '../molecules/SearchInput.jsx'
4
4
  import Tag from '../atoms/Tag.jsx'
5
5
  import Kbd from '../atoms/Kbd.jsx'
6
6
  import OptionRow from '../molecules/OptionRow.jsx'
7
- import Button from '../atoms/Button.jsx'
8
- import { Tooltip } from '../utilities/Popover.jsx'
9
7
  import { shortcutInScope } from './ShortcutsOverlay.jsx'
10
8
 
11
9
  /* ONE COLUMN (2026-09-30): rows, headings and footer sit on the field's own
@@ -121,7 +119,7 @@ function shortcutRows(shortcuts, path, cat) {
121
119
  * own results surface. Plain Enter keeps its meaning.
122
120
  * @param {string} [resultsLabel] the footer's second line for ⌘Enter (e.g. `All results`)
123
121
  * @param {Function} [onBack] a drill-in's way back (CommandOverlayModes, kol-monitor 2026-10-17): set, the
124
- * field row leads with a back arrow, and Backspace on an empty field calls it —
122
+ * search glyph becomes a back arrow in its slot (the field never moves); Backspace on an empty field calls it —
125
123
  * instead of a "← All" row that scrolls away with the list
126
124
  * @param {string} [backLabel] the arrow's tooltip (default `Back`) — name where it goes ("All modules")
127
125
  * @param {string} [selectLabel] the footer's Enter line while a row is highlighted (default
@@ -294,25 +292,23 @@ export default function CommandOverlay({
294
292
  )}
295
293
  {/* A REAL FIELD, inset in the panel (2026-09-30, shadcn's search modal as
296
294
  * the aim) — the flush `bare` strip read as a hole, not a control. */}
297
- {(!noField || back) && (
295
+ {!noField && (
298
296
  <div className="kol-tone-grey p-2 flex items-center gap-2">
299
- {back && (
300
- <Tooltip label={noField ? 'Shortcuts' : backLabel}>
301
- {/* mousedown keeps focus in the field, as the rows do */}
302
- <Button iconOnly="arrow-left" tone="ghost" size="md" aria-label={noField ? 'Shortcuts' : backLabel} onMouseDown={(e) => e.preventDefault()} onClick={back} />
303
- </Tooltip>
304
- )}
305
- {!noField && <SearchInput
297
+ {/* THE BACK ARROW TAKES THE SEARCH GLYPH'S SLOT (user 2026-10-18: *"why would the back move the input?!"*) —
298
+ * a button beside the field shrank it and shifted the caret on every drill-in */}
299
+ <SearchInput
306
300
  className="w-full min-w-0 flex-1"
307
301
  value={query}
308
302
  onChange={(e) => onQueryChange?.(e.target.value)}
309
303
  placeholder={chips.length > 0 ? 'Narrow these results…' : placeholder}
310
304
  onKeyDown={handleKeyDown}
305
+ onBack={back}
306
+ backLabel={backLabel}
311
307
  role="combobox"
312
308
  aria-expanded={results.length > 0}
313
309
  aria-controls={listId}
314
310
  aria-activedescendant={active >= 0 ? optionId(results[active]) : undefined}
315
- />}
311
+ />
316
312
  </div>
317
313
  )}
318
314
 
@@ -344,15 +340,21 @@ export default function CommandOverlay({
344
340
  ref={listRef}
345
341
  id={listId}
346
342
  role="listbox"
347
- className={`kol-tone-grey h-80 overflow-y-auto px-2 pb-2${noField && !back ? ' pt-2' : ''}`}
343
+ className={`kol-tone-grey h-80 overflow-y-auto px-2 pb-2${noField ? ' pt-2' : ''}`}
348
344
  >
349
345
  {results.map((item, i) => {
350
346
  const heading = (item.group ?? '') !== (results[i - 1]?.group ?? '') || i === 0
351
347
  return (
352
348
  <li key={item.id} role="presentation">
353
- {heading && item.group && (
349
+ {heading && item.group && (noField && back && i === 0 ? (
350
+ /* shortcuts' second layer: the arrow leads the category's own heading — nothing moves */
351
+ <button type="button" aria-label="Shortcuts" onMouseDown={(e) => e.preventDefault()} onClick={back}
352
+ className="kol-helper-12 text-fg-48 hover:text-fg-80 transition-colors flex items-center gap-2 px-4 border-x border-transparent pt-3 pb-2 cursor-pointer">
353
+ <Icon name="arrow-left" size={12} />{item.group}
354
+ </button>
355
+ ) : (
354
356
  <p className="kol-helper-12 text-fg-48 px-4 border-x border-transparent pt-3 pb-2">{item.group}</p>
355
- )}
357
+ ))}
356
358
  <OptionRow
357
359
  id={optionId(item)}
358
360
  role="option"