@kolkrabbi/kol-component 0.124.0 → 0.125.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.124.0",
3
+ "version": "0.125.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",
@@ -61,6 +61,19 @@ const Dropdown = ({
61
61
  * Both write variables on the panel that `.kol-dd-list` reads. */
62
62
  maxRows = 10,
63
63
  rowHeight,
64
+ /* `onOptionHover(value | null)` (DropdownOptionHoverPreview, kol-mirror
65
+ * 2026-08-28): the pointer entering a row reports its value, leaving reports
66
+ * `null` — so a picker over a VISUAL setting can preview the hovered option
67
+ * live and revert on leave. mirror's blend-mode picker applies the hovered
68
+ * mode to the composite: you scrub 16 modes against the actual image instead
69
+ * of committing to each one to look at it. The same case is every picker over
70
+ * easing curves, palettes, filters, fonts — the DS owns the panel, only the
71
+ * consumer knows what to preview, so this reports and nothing else.
72
+ *
73
+ * `null` fires ON CLOSE too, and that half is load-bearing: a panel dismissed
74
+ * while a row is hovered would otherwise leave the consumer previewing
75
+ * forever. It never fires while closed — a closed dropdown has no rows. */
76
+ onOptionHover,
64
77
  defaultOpen = false,
65
78
  className = ''
66
79
  }) => {
@@ -96,6 +109,21 @@ const Dropdown = ({
96
109
  setIsOpen(false)
97
110
  }
98
111
 
112
+ /* the hover report, and the close that ends it. `hovered` is a ref, not
113
+ * state — the preview is the consumer's business and re-rendering the panel
114
+ * on every row crossed would be a render per pointermove for nothing. */
115
+ const hovered = useRef(null)
116
+ const reportHover = (v) => {
117
+ if (hovered.current === v) return
118
+ hovered.current = v
119
+ onOptionHover?.(v)
120
+ }
121
+ useEffect(() => {
122
+ if (isOpen || hovered.current == null) return
123
+ hovered.current = null
124
+ onOptionHover?.(null)
125
+ }, [isOpen]) // eslint-disable-line react-hooks/exhaustive-deps
126
+
99
127
  const currentOption = options.find((opt) => opt.value === value) || options[0]
100
128
 
101
129
  /* A clamped list (Popover caps the panel to the viewport) can open with the
@@ -174,6 +202,8 @@ const Dropdown = ({
174
202
  * brighten. The check mark is what marks the current value. */
175
203
  hover={false}
176
204
  height={rowHeight}
205
+ onPointerEnter={onOptionHover ? () => reportHover(option.value) : undefined}
206
+ onPointerLeave={onOptionHover ? () => reportHover(null) : undefined}
177
207
  onClick={() => handleSelect(option)}
178
208
  shortcut={isActive ? <Icon name="check" size={11} /> : undefined}
179
209
  >
@@ -99,12 +99,14 @@ export function MenuItem({
99
99
  * - children — main label, flex-1.
100
100
  * - shortcut — trailing content (text shortcut hint, ✓ marker, or icon).
101
101
  */
102
- export function MenuDropdownItem({ onClick, disabled, prefix, iconLeft, shortcut, hover = true, height, children }) {
102
+ export function MenuDropdownItem({ onClick, onPointerEnter, onPointerLeave, disabled, prefix, iconLeft, shortcut, hover = true, height, children }) {
103
103
  return (
104
104
  <button
105
105
  type="button"
106
106
  data-menu-item
107
107
  onClick={onClick}
108
+ onPointerEnter={onPointerEnter}
109
+ onPointerLeave={onPointerLeave}
108
110
  disabled={disabled}
109
111
  role="menuitem"
110
112
  style={height != null ? { height } : undefined}