@kolkrabbi/kol-component 0.97.1 → 0.97.2

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.97.1",
3
+ "version": "0.97.2",
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",
@@ -35,6 +35,7 @@ import { Icon } from '@kolkrabbi/kol-icons'
35
35
  * @param {Function} onPrefix (prefix) => void
36
36
  * @param {{files: object[], index: number}|null} quickLook the open Quick Look, or null
37
37
  * @param {Function} onQuickLook (quickLook|null) => void — space opens / closes, ↑/↓ step while open
38
+ * @param {Function} onPick (file|null) => void — the picked file whenever it changes (a folder pick or an outside prefix change → null)
38
39
  * @param {Function} urlOf (o) => string — the object's public URL for the preview image
39
40
  * @param {Function} kindOf (o) => 'image' | 'video' | 'audio' | string
40
41
  * @param {Object} kindLabel kind → label shown when there is no visual preview
@@ -141,6 +142,7 @@ export default function ColumnBrowser({
141
142
  onPrefix = () => {},
142
143
  quickLook = null,
143
144
  onQuickLook,
145
+ onPick,
144
146
  urlOf,
145
147
  kindOf = defaultKindOf,
146
148
  kindLabel = DEFAULT_KIND_LABEL,
@@ -149,6 +151,11 @@ export default function ColumnBrowser({
149
151
  className = '',
150
152
  }) {
151
153
  const [picked, setPicked] = useState(null)
154
+ /* `onPick` (ColumnBrowserOnPick, kol-r2b2 2026-08-27): the picked file, for
155
+ * a Finder-style breadcrumb — fired whenever it changes; a folder pick or an
156
+ * outside prefix change fires null */
157
+ const pick = (o) => { setPicked(o); onPick?.(o) }
158
+ useEffect(() => { if (picked) pick(null) }, [prefix]) // eslint-disable-line react-hooks/exhaustive-deps
152
159
  // Keyboard cursor: which column, which row. Clicks keep it in sync.
153
160
  const [cursor, setCursor] = useState({ col: 0, idx: 0 })
154
161
  /* the cursor is NOT drawn until the keyboard is used (ColumnBrowserCursorStart,
@@ -171,8 +178,8 @@ export default function ColumnBrowser({
171
178
  }
172
179
  const land = (level, item) => {
173
180
  if (!item) return
174
- if (item.type === 'folder') { setPicked(null); onPrefix(level + item.name) }
175
- else setPicked(item.o)
181
+ if (item.type === 'folder') { pick(null); onPrefix(level + item.name) }
182
+ else pick(item.o)
176
183
  }
177
184
 
178
185
  const onKeyDown = (e) => {
@@ -206,7 +213,7 @@ export default function ColumnBrowser({
206
213
  const opened = lv[col].slice(lv[col - 1].length)
207
214
  const idx = Math.max(0, parentItems.findIndex((it) => it.type === 'folder' && it.name === opened))
208
215
  setCursor({ col: col - 1, idx })
209
- setPicked(null)
216
+ pick(null)
210
217
  onPrefix(lv[col])
211
218
  }
212
219
  }
@@ -228,7 +235,7 @@ export default function ColumnBrowser({
228
235
  do { idx += step } while (items[idx] && items[idx].type !== 'file')
229
236
  if (!items[idx]) return
230
237
  setCursor({ col, idx })
231
- setPicked(items[idx].o)
238
+ pick(items[idx].o)
232
239
  const siblings = items.filter((it) => it.type === 'file').map((it) => it.o)
233
240
  onQuickLook?.({ files: siblings, index: siblings.findIndex((o) => o.key === items[idx].o.key) })
234
241
  }
@@ -267,7 +274,7 @@ export default function ColumnBrowser({
267
274
  active={f === activeFolder}
268
275
  cursor={cursorActive && cursor.col === k && cursor.idx === i}
269
276
  trailing={<Icon name="chevron-right" size={12} className="text-fg-32" />}
270
- onClick={() => { setCursor({ col: k, idx: i }); setCursorActive(true); rootRef.current?.focus(); setPicked(null); onPrefix(level + f) }}
277
+ onClick={() => { setCursor({ col: k, idx: i }); setCursorActive(true); rootRef.current?.focus(); pick(null); onPrefix(level + f) }}
271
278
  />
272
279
  ))}
273
280
  {files.map((o, i) => (
@@ -278,7 +285,7 @@ export default function ColumnBrowser({
278
285
  muted={shown?.key !== o.key}
279
286
  active={shown?.key === o.key}
280
287
  cursor={cursorActive && cursor.col === k && cursor.idx === folders.length + i}
281
- onClick={() => { setCursor({ col: k, idx: folders.length + i }); setCursorActive(true); rootRef.current?.focus(); setPicked(o) }}
288
+ onClick={() => { setCursor({ col: k, idx: folders.length + i }); setCursorActive(true); rootRef.current?.focus(); pick(o) }}
282
289
  />
283
290
  ))}
284
291
  {folders.length === 0 && files.length === 0 && (