@kolkrabbi/kol-component 0.340.0 → 0.341.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.340.0",
3
+ "version": "0.341.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,9 +29,9 @@
29
29
  "embla-carousel-react": "^8.6.0",
30
30
  "pdfjs-dist": "^6.3.289",
31
31
  "react-syntax-highlighter": "^16.1.1",
32
- "@kolkrabbi/kol-search": "^0.3.0",
32
+ "@kolkrabbi/kol-growth": "^0.5.0",
33
33
  "@kolkrabbi/kol-markdown": "^0.2.0",
34
- "@kolkrabbi/kol-growth": "^0.5.0"
34
+ "@kolkrabbi/kol-search": "^0.3.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@kolkrabbi/kol-icons": ">=0.61.1",
@@ -0,0 +1,26 @@
1
+ import { useEffect, useRef, useState } from 'react'
2
+
3
+ /**
4
+ * useFloatPresence — keeps a float in the tree for `ms` after `open` goes false, so its leave can play
5
+ * (FloatActionStatesAndMotion, kol-website 2026-11-04). CSS cannot animate an unmount; this is the whole of the JS.
6
+ * Reduced motion, or `ms` 0, unmounts at once.
7
+ *
8
+ * @param {boolean} open
9
+ * @param {number} ms how long the leave runs (`floatMotion(motion).ms`)
10
+ * @returns {{ mounted: boolean, entering: boolean, exiting: boolean }} `entering` — opened after having been closed (never
11
+ * on first mount, so a page does not animate its chrome in on load)
12
+ */
13
+ export default function useFloatPresence(open, ms) {
14
+ const [state, setState] = useState(open ? 'open' : 'closed')
15
+ const first = useRef(true)
16
+ useEffect(() => {
17
+ if (first.current) { first.current = false; return undefined }
18
+ if (open) { setState('enter'); return undefined }
19
+ const still = typeof window !== 'undefined' && window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
20
+ if (!ms || still) { setState('closed'); return undefined }
21
+ setState('exit')
22
+ const t = setTimeout(() => setState('closed'), ms)
23
+ return () => clearTimeout(t)
24
+ }, [open, ms])
25
+ return { mounted: open || state !== 'closed', entering: open && state !== 'open', exiting: !open && state !== 'closed' }
26
+ }
package/src/index.js CHANGED
@@ -55,6 +55,7 @@ export { default as OverlayGlassPanel } from './utilities/OverlayGlassPanel.jsx'
55
55
  export { default as Pill } from './atoms/Pill.jsx'
56
56
  export { usePopover, PopoverPanel, Tooltip } from './utilities/Popover.jsx'
57
57
  export { floatSurfaceClass, FLOAT_SURFACES } from './utilities/tone.js'
58
+ export { floatMotion, FLOAT_MOTION } from './utilities/motion.js'
58
59
  /* armLongPress — the touch hold the panel value controls report (moved from kol-hardware 2026-10-01) */
59
60
  export { armLongPress } from './utilities/armLongPress.js'
60
61
  export { default as ContextMenu, useContextMenu } from './molecules/ContextMenu.jsx'
@@ -324,6 +325,7 @@ export { SOLO, ADJACENT, INDICATOR, glyphSize, indicatorSize } from './hooks/gly
324
325
 
325
326
  // hooks
326
327
  export { default as usePrefersReducedMotion } from './hooks/usePrefersReducedMotion.js'
328
+ export { default as useFloatPresence } from './hooks/useFloatPresence.js'
327
329
  export { default as useReveal } from './hooks/useReveal.js'
328
330
  export { default as useScrollSpy } from './hooks/useScrollSpy.js'
329
331
  export { default as useScrollFade } from './hooks/useScrollFade.js'
@@ -147,9 +147,15 @@ export function Menu({
147
147
  if (!open || !rootRef.current) return
148
148
  const cs = getComputedStyle(rootRef.current.firstElementChild ?? rootRef.current)
149
149
  const vars = {}
150
- for (const v of TONE_VARS) { const val = cs.getPropertyValue(v).trim(); if (val) vars[v] = val }
150
+ /* A FLOAT PANEL IS A FLOAT SURFACE (FloatMenuPanelInk, kol-website 2026-11-04): the theme's, as RailTrigger's card,
151
+ * the search modal and the float Dropdown (which pins `--kol-tone-panel-bg` on its trigger) — never the trigger's
152
+ * ground. Its rows read theme ink (fg-88, the fg-16 lift), so an inverted trigger's panel-bg painted them out. */
153
+ for (const v of TONE_VARS) {
154
+ if (variant === 'float' && v.startsWith('--kol-tone-panel')) continue
155
+ const val = cs.getPropertyValue(v).trim(); if (val) vars[v] = val
156
+ }
151
157
  setAmbient(vars)
152
- }, [open])
158
+ }, [open, variant])
153
159
 
154
160
  let rows = items ?? []
155
161
  if (search) {
@@ -6,6 +6,8 @@ import Kbd from '../atoms/Kbd.jsx'
6
6
  import OptionRow from '../molecules/OptionRow.jsx'
7
7
  import Button from '../atoms/Button.jsx'
8
8
  import { floatSurfaceClass } from '../utilities/tone.js'
9
+ import { floatMotion } from '../utilities/motion.js'
10
+ import useFloatPresence from '../hooks/useFloatPresence.js'
9
11
  import { shortcutInScope } from './ShortcutsOverlay.jsx'
10
12
 
11
13
  /* ONE COLUMN (2026-09-30): rows, headings and footer sit on the field's own
@@ -154,6 +156,9 @@ function unfold(rows, opened) {
154
156
  * is RailTrigger's (`kol-more-sheet-float` on `--kol-float-menu-r`, the float surface and
155
157
  * shadow), the field the float SearchInput, the rows float Buttons (Inter, `--kol-float-row`,
156
158
  * the lit row fg-16). Unset, the search modal is drawn as before. FloatLayout's `search` passes its own
159
+ * @param {boolean|Object} [motion=true] with `surface`, the card fades and scales in and out over a fading scrim, held in
160
+ * the tree while it leaves (FloatActionStatesAndMotion, 2026-11-04): `true` the
161
+ * `--kol-float-*` tokens · `false` none · `{ duration, ease }` per app
157
162
  */
158
163
  export default function CommandOverlay({
159
164
  open,
@@ -183,8 +188,12 @@ export default function CommandOverlay({
183
188
  shortcuts = [],
184
189
  currentPath,
185
190
  surface,
191
+ motion = true,
186
192
  }) {
187
193
  const float = surface != null
194
+ const fm = floatMotion(motion)
195
+ const presence = useFloatPresence(open, float ? fm.ms : 0)
196
+ const exit = float && presence.exiting ? '' : undefined
188
197
  const panelRef = useRef(null)
189
198
  const listRef = useRef(null)
190
199
  const listId = useId()
@@ -236,7 +245,7 @@ export default function CommandOverlay({
236
245
  listRef.current?.querySelectorAll('[role="option"]')[active]?.scrollIntoView({ block: 'nearest' })
237
246
  }, [active])
238
247
 
239
- if (!open) return null
248
+ if (!(float ? presence.mounted : open)) return null
240
249
 
241
250
  /* A row that KEEPS THE MODAL OPEN — `keepOpen`, or an `action` row (the contract below always said
242
251
  * so; until 0.252.0 every pick closed — ShellSearchOverlayActionKeepsOpen, kol-fxr 2026-10-13). It
@@ -310,7 +319,7 @@ export default function CommandOverlay({
310
319
  }
311
320
 
312
321
  return (
313
- <div className="fixed inset-0 flex items-start justify-center pt-[20vh]" style={{ zIndex: 'var(--kol-z-modal, 100)' }}>
322
+ <div className="fixed inset-0 flex items-start justify-center pt-[20vh]" style={{ zIndex: 'var(--kol-z-modal, 100)', ...(float ? fm.style : null) }}>
314
323
  {/* A BUTTON, not a div (OverlayScrimTapDismiss, 2026-09-01): iOS Safari
315
324
  * does not bubble tap-clicks from non-interactive elements, so the div's
316
325
  * onClick never fired on a phone and the only way out was the close
@@ -319,7 +328,8 @@ export default function CommandOverlay({
319
328
  <button
320
329
  type="button"
321
330
  aria-label="Close search"
322
- className="absolute inset-0 kol-overlay-scrim"
331
+ className={`absolute inset-0 kol-overlay-scrim${float ? ' kol-float-fade' : ''}`}
332
+ data-exit={exit}
323
333
  onClick={onClose}
324
334
  />
325
335
  <div
@@ -330,7 +340,8 @@ export default function CommandOverlay({
330
340
  role="dialog"
331
341
  aria-modal="true"
332
342
  aria-label="Search"
333
- className={`${float ? `kol-more-sheet kol-more-sheet-float kol-float-chrome ${floatSurfaceClass(surface, true)} relative w-full overflow-hidden` : 'kol-overlay-panel'} mx-4 ${noField ? 'outline-none ' : ''}${expanded ? 'max-w-[var(--kol-content-panel)]' : 'max-w-lg'}`}
343
+ data-exit={exit}
344
+ className={`${float ? `kol-more-sheet kol-more-sheet-float kol-float-chrome kol-float-motion ${floatSurfaceClass(surface, true)} relative w-full overflow-hidden` : 'kol-overlay-panel'} mx-4 ${noField ? 'outline-none ' : ''}${expanded ? 'max-w-[var(--kol-content-panel)]' : 'max-w-lg'}`}
334
345
  >
335
346
  {/* THE MODE, said out loud (user 2026-08-01: "how do you set search
336
347
  * mode? theres no helper, message or mode clearly readble"). Two
@@ -3,6 +3,7 @@ import { Icon } from '@kolkrabbi/kol-icons'
3
3
  import Kbd from '../atoms/Kbd.jsx'
4
4
  import TreeRow from '../molecules/TreeRow.jsx'
5
5
  import { Tooltip } from '../utilities/Popover.jsx'
6
+ import { floatMotion } from '../utilities/motion.js'
6
7
 
7
8
  /* taxonomy-ok: organism — nests TreeRow (molecule) + Kbd (atom) + Tooltip (utility) + kol-icons's Icon. */
8
9
 
@@ -34,10 +35,15 @@ import { Tooltip } from '../utilities/Popover.jsx'
34
35
  * @param {ReactNode} [footer]
35
36
  * @param {Function} [onItemHover] collapsed only: `(item, element)` when the pointer enters a slot, `(null, null)` when it
36
37
  * leaves — the seam a hover flyout hangs off (kol-shell's RailFlyout, FloatLayout 2026-11-04)
38
+ * @param {boolean|Object} [motion=true] expand ↔ collapse eases the width and fades the new rows in, and the slots and rows ease
39
+ * their hover (`.kol-float-rail`, FloatActionStatesAndMotion 2026-11-04): `true` the
40
+ * `--kol-float-*` tokens · `false` none · `{ duration, ease }` per app. Hide and show are
41
+ * FloatLayout's (it holds the rail while it leaves)
37
42
  */
38
43
  const isOn = (path, current) => !!path && path === current
39
44
 
40
- export default function NavRailFloat({ items = [], currentPath = '', onNavigate, collapsed = false, onCollapsedChange, title, icon = 'grid', onSwitch, switcher, onSearch, onHide, defaultExpanded = [], footer, onItemHover, className = '' }) {
45
+ export default function NavRailFloat({ items = [], currentPath = '', onNavigate, collapsed = false, onCollapsedChange, title, icon = 'grid', onSwitch, switcher, onSearch, onHide, defaultExpanded = [], footer, onItemHover, motion = true, className = '' }) {
46
+ const motionStyle = floatMotion(motion).style
41
47
  const [open, setOpen] = useState(() => new Set(defaultExpanded))
42
48
  const toggle = (path) => setOpen((s) => { const n = new Set(s); n.has(path) ? n.delete(path) : n.add(path); return n })
43
49
  const go = (path) => () => onNavigate?.(path)
@@ -52,7 +58,7 @@ export default function NavRailFloat({ items = [], currentPath = '', onNavigate,
52
58
  </Tooltip>
53
59
  )
54
60
  return (
55
- <nav aria-label="Navigation" className={`flex h-full w-[72px] flex-col items-center gap-1 rounded-[var(--kol-float-menu-r)] bg-surface-secondary shadow-[var(--kol-shadow-float)] py-3.5 ${className}`.trim()}>
61
+ <nav aria-label="Navigation" style={motionStyle} className={`kol-float-rail flex h-full w-[72px] flex-col items-center gap-1 rounded-[var(--kol-float-menu-r)] bg-surface-secondary shadow-[var(--kol-shadow-float)] py-3.5 ${className}`.trim()}>
56
62
  {onCollapsedChange && slot('expand', 'Expand', 'panel-left', { well: true, onClick: () => onCollapsedChange(false) })}
57
63
  <div className="flex min-h-0 w-full flex-1 flex-col items-center gap-1 overflow-y-auto py-3 [scrollbar-width:none]">
58
64
  {items.map((it, i) => {
@@ -74,7 +80,7 @@ export default function NavRailFloat({ items = [], currentPath = '', onNavigate,
74
80
  }
75
81
 
76
82
  return (
77
- <nav aria-label="Navigation" className={`flex h-full w-[280px] flex-col gap-3 rounded-[var(--kol-float-menu-r)] bg-surface-secondary shadow-[var(--kol-shadow-float)] p-3 ${className}`.trim()}>
83
+ <nav aria-label="Navigation" style={motionStyle} className={`kol-float-rail flex h-full w-[280px] flex-col gap-3 rounded-[var(--kol-float-menu-r)] bg-surface-secondary shadow-[var(--kol-shadow-float)] p-3 ${className}`.trim()}>
78
84
  {switcher ?? (title && (
79
85
  <button type="button" onClick={onSwitch} className="flex h-10 w-full items-center gap-2.5 rounded-[var(--kol-float-list-r)] px-2.5 text-left cursor-pointer hover:bg-fg-08 focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]">
80
86
  <Icon name={icon} size={18} className="shrink-0 text-oq-96" />
@@ -1,5 +1,7 @@
1
1
  import { cloneElement, createContext, isValidElement, useContext, useLayoutEffect, useState, version as reactVersion } from 'react'
2
2
  import { toneClass, TONE_VARS } from './tone.js'
3
+ import { floatMotion } from './motion.js'
4
+ import useFloatPresence from '../hooks/useFloatPresence.js'
3
5
  import {
4
6
  useFloating,
5
7
  autoUpdate,
@@ -260,6 +262,10 @@ function TooltipOn({
260
262
  * focus — wrap in FloatingFocusManager (default: true)
261
263
  * className — extra classes on the panel
262
264
  * style — extra inline styles merged with floatingStyles
265
+ * motion — the float card's enter and leave (FloatActionStatesAndMotion, 2026-11-04): unset, the panel
266
+ * mounts and unmounts as it always has; `true` · `{ duration, ease }` fades it in and out from its
267
+ * trigger's side (`.kol-float-motion`, `--kol-float-*`), held in the tree while it leaves; `false`
268
+ * the same card with no motion
263
269
  */
264
270
  /* how many floats this one is opened from inside — context crosses portals, the DOM order does not */
265
271
  const FloatDepth = (globalThis[Symbol.for('@kolkrabbi/kol-component/FloatDepth')] ??= createContext(0))
@@ -278,18 +284,21 @@ export function PopoverPanel({
278
284
  * that, so nothing existing moves; a tone paints that tone's ground instead,
279
285
  * through the same `toneClass` every other control uses. */
280
286
  tone,
287
+ motion,
281
288
  className = '',
282
289
  style: extraStyle,
283
290
  }) {
284
291
  const depth = useContext(FloatDepth)
285
- if (!popover.open) return null
292
+ const fm = motion == null ? null : floatMotion(motion)
293
+ const presence = useFloatPresence(popover.open, fm?.ms ?? 0)
294
+ if (!(fm ? presence.mounted : popover.open)) return null
286
295
 
287
296
  const { refs, floatingStyles, context, getFloatingProps } = popover
288
297
  /* kol-popover-float rides every floating node (panel chrome or not): it
289
298
  * carries the stacking guarantee — floats must top overlay chrome
290
299
  * (.kol-overlay z-100), or a dropdown inside a FullscreenOverlay renders
291
300
  * under the sheet and its options can't be clicked. */
292
- const cls = ['kol-popover-float', panel && 'kol-popover', tone && toneClass(tone), className].filter(Boolean).join(' ')
301
+ const cls = ['kol-popover-float', panel && 'kol-popover', tone && toneClass(tone), fm && 'kol-float-motion', className].filter(Boolean).join(' ')
293
302
 
294
303
  /* `data-editor-keep-selection` mirrors the marker on the EditorShell
295
304
  * root. Popovers render via FloatingPortal (mounted on <body>, outside
@@ -301,9 +310,11 @@ export function PopoverPanel({
301
310
  const node = (
302
311
  <div
303
312
  ref={refs.setFloating}
304
- style={{ ...floatingStyles, ...(depth ? { '--kol-float-depth': depth } : null), ...extraStyle }}
313
+ style={{ ...floatingStyles, ...(depth ? { '--kol-float-depth': depth } : null), ...fm?.style, ...extraStyle }}
305
314
  className={cls}
306
315
  data-editor-keep-selection
316
+ data-side={fm ? popover.placement?.split('-')[0] : undefined}
317
+ data-exit={fm && presence.exiting ? '' : undefined}
307
318
  {...getFloatingProps()}
308
319
  >
309
320
  <FloatDepth.Provider value={depth + 1}>{children}</FloatDepth.Provider>
@@ -112,3 +112,25 @@ export const GRAB_COLUMN = {
112
112
  range: 1,
113
113
  travel: { duration: 2.8, ease: EASE.outGsap },
114
114
  }
115
+
116
+ /* THE FLOAT FAMILY'S MOTION (FloatActionStatesAndMotion, kol-website 2026-11-04). The CSS side is `--kol-float-*` in
117
+ * kol-design-tokens.css and `.kol-float-motion` · `-rail` · `-turn` in kol-animation.css; these are the same numbers for
118
+ * the one thing CSS cannot do — hold a card in the tree while it leaves. */
119
+ export const FLOAT_MOTION = { duration: DURATION.base, rail: DURATION.slow, hoverOpacity: 0.88, pressScale: 0.96 }
120
+
121
+ /**
122
+ * floatMotion — the `motion` prop of the float pieces and FloatLayout, resolved once:
123
+ * true (default) the tokens
124
+ * false no motion — the durations go to 0ms
125
+ * { duration, ease } per app: `duration` in ms (both clocks), `ease` a CSS curve or a cubic-bezier array (EASE.*)
126
+ * Returns `{ style, ms, rail }`: `style` sets the `--kol-float-*` vars on the piece's root (or nothing), `ms` / `rail` how long
127
+ * a card or the rail is held in the tree while it leaves.
128
+ */
129
+ export function floatMotion(motion = true) {
130
+ if (motion === false) return { style: { '--kol-float-duration': '0ms', '--kol-float-duration-rail': '0ms' }, ms: 0, rail: 0 }
131
+ const o = motion && typeof motion === 'object' ? motion : {}
132
+ const style = {}
133
+ if (o.duration != null) style['--kol-float-duration'] = style['--kol-float-duration-rail'] = `${o.duration}ms`
134
+ if (o.ease) style['--kol-float-ease'] = Array.isArray(o.ease) ? `cubic-bezier(${o.ease.join(', ')})` : o.ease
135
+ return { style: Object.keys(style).length ? style : undefined, ms: o.duration ?? FLOAT_MOTION.duration, rail: o.duration ?? FLOAT_MOTION.rail }
136
+ }