@kolkrabbi/kol-component 0.347.0 → 0.348.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 +1 -1
- package/src/atoms/Divider.jsx +4 -2
- package/src/index.js +1 -1
- package/src/molecules/Dropdown.jsx +37 -35
- package/src/molecules/Menu.jsx +8 -47
- package/src/molecules/MenuItem.jsx +7 -5
- package/src/molecules/MenuList.jsx +79 -0
- package/src/molecules/WorkspaceSwitcher.jsx +8 -11
- package/src/molecules/MenuPopover.jsx +0 -21
package/package.json
CHANGED
package/src/atoms/Divider.jsx
CHANGED
|
@@ -15,10 +15,12 @@ import React from 'react'
|
|
|
15
15
|
* stretches to the row (DividerHeightFill, kol-monitor 2026-10-18: eurorack panels separate
|
|
16
16
|
* jack and knob groups with full-height rules); `className` padding insets it
|
|
17
17
|
* @param {string} props.opacity - Opacity level (01, 02, 04, 08, 12, 16, 24, 32, 48, 64, 80, 88, 96) (default: '08')
|
|
18
|
+
* @param {'fg'|'oq'} props.ink - the ramp the rule is drawn on (default 'fg'); 'oq' the opaque ramp — a menu's rule
|
|
19
|
+
* (MenuDivider, plan-2026-11-07-menu-system W1.2), whose translucent fg would show through a filled panel
|
|
18
20
|
*/
|
|
19
|
-
const Divider = ({ variant = 'horizontal', className = '', opacity = '08', inverse = false, height = 16 }) => {
|
|
21
|
+
const Divider = ({ variant = 'horizontal', className = '', opacity = '08', inverse = false, height = 16, ink = 'fg' }) => {
|
|
20
22
|
const isVertical = variant === 'vertical'
|
|
21
|
-
const opacityClass = inverse ? `bg-
|
|
23
|
+
const opacityClass = inverse ? `bg-${ink}-inverse-${opacity}` : `bg-${ink}-${opacity}`
|
|
22
24
|
|
|
23
25
|
if (isVertical) {
|
|
24
26
|
/* THE RULE IS CENTRED ON WHAT IT SEPARATES, not stretched to the row.
|
package/src/index.js
CHANGED
|
@@ -174,7 +174,7 @@ export { default as ContentItem } from './molecules/ContentItem.jsx'
|
|
|
174
174
|
export { default as ContentCollection } from './organisms/ContentCollection.jsx'
|
|
175
175
|
export { MenuItem, MenuRow, MenuDivider, MenuFlyout, MenuDropdownItem, MenuDropdownDivider, MenuDropdownNest } from './molecules/MenuItem.jsx'
|
|
176
176
|
export { Menu, MenuTrigger, MenuPanel, MenuLabel, MenuFilter, MenuDatePicker, MenuMore } from './molecules/Menu.jsx'
|
|
177
|
-
export {
|
|
177
|
+
export { MenuList } from './molecules/MenuList.jsx'
|
|
178
178
|
export { ModalProvider, useModal, Dialog } from './molecules/Modal.jsx'
|
|
179
179
|
/* the generator settings window's controls (plan-2026-11-05-float-editor W7.2) — `Dialog variant="settings"`'s rows */
|
|
180
180
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
|
2
2
|
import { toneClass } from '../utilities/tone.js'
|
|
3
3
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
4
|
-
import {
|
|
4
|
+
import { MenuList } from './MenuList.jsx'
|
|
5
5
|
import { Menu } from './Menu.jsx'
|
|
6
6
|
import { glyphSize, indicatorSize } from '../hooks/glyphLadders.js'
|
|
7
7
|
|
|
@@ -274,6 +274,41 @@ const Dropdown = ({
|
|
|
274
274
|
</button>
|
|
275
275
|
)
|
|
276
276
|
|
|
277
|
+
/* the options as MenuList rows (plan-2026-11-07-menu-system W1.1 — rows are mapped in MenuList only) */
|
|
278
|
+
const headingCls = `${resolvedSize === 'xs' ? 'kol-mono-8' : 'kol-helper-12'} ${ROW_H[resolvedSize] ?? ROW_H.sm} ${ROW_PAD[resolvedSize] ?? ROW_PAD.sm} flex shrink-0 items-center text-meta`
|
|
279
|
+
const items = options.map((option, i) => {
|
|
280
|
+
if (option?.divider) return { divider: true, key: `divider-${i}` }
|
|
281
|
+
if (option?.heading) return { heading: option.heading, key: `heading-${i}` }
|
|
282
|
+
const isActive = multiple ? picked.has(option.value) : option.value === currentOption?.value
|
|
283
|
+
return {
|
|
284
|
+
key: option.value,
|
|
285
|
+
/* NO HOVER STATE ANYWHERE ON A DROPDOWN (user 2026-08-28) — the indicator marks the current value. */
|
|
286
|
+
hover: false,
|
|
287
|
+
size: resolvedSize,
|
|
288
|
+
/* a float row is the float list's (`.kol-menu-panel--float .kol-menu-row`), whatever the trigger's rung; the
|
|
289
|
+
* current one is lifted (row 54: "selected / checked") — still no hover */
|
|
290
|
+
rowClass: float ? `kol-menu-row${isActive ? ' kol-menu-row--current' : ''}` : (ROW[resolvedSize] ?? ROW.sm),
|
|
291
|
+
height: rowHeight,
|
|
292
|
+
onPointerEnter: onOptionHover ? () => reportHover(option.value) : undefined,
|
|
293
|
+
onPointerLeave: onOptionHover ? () => reportHover(null) : undefined,
|
|
294
|
+
onClick: () => handleSelect(option),
|
|
295
|
+
/* The current row's mark is the INDICATOR, always — • for the one pick, ✓ (the check icon) for each
|
|
296
|
+
* row on in a `multiple` (plan-2026-10-31-menu-engine W2). An option's own `shortcut` shows on the
|
|
297
|
+
* rows that are not current — the tool-palette idiom (editor-set-is-behind-its-source, 2026-09-03). */
|
|
298
|
+
indicator: isActive ? (multiple ? 'check' : 'dot') : undefined,
|
|
299
|
+
shortcut: isActive ? undefined : option.shortcut,
|
|
300
|
+
/* an option's leading glyph — the ADJACENT ladder, because it sits in a line box beside a label, never the solo rung */
|
|
301
|
+
label: option.icon ? (
|
|
302
|
+
<>
|
|
303
|
+
<span className="shrink-0 inline-flex items-center" style={{ marginRight: 'var(--kol-spacing-2)' }}>
|
|
304
|
+
<Icon name={option.icon} size={glyphSize(resolvedSize)} />
|
|
305
|
+
</span>
|
|
306
|
+
{option.label}
|
|
307
|
+
</>
|
|
308
|
+
) : option.label,
|
|
309
|
+
}
|
|
310
|
+
})
|
|
311
|
+
|
|
277
312
|
return (
|
|
278
313
|
<Menu
|
|
279
314
|
fused
|
|
@@ -298,40 +333,7 @@ const Dropdown = ({
|
|
|
298
333
|
<div className="kol-dd-div" />
|
|
299
334
|
|
|
300
335
|
<div ref={listRef} className="kol-dd-list" role="listbox" aria-multiselectable={multiple || undefined} style={scale !== 1 ? { zoom: scale } : undefined}>
|
|
301
|
-
{
|
|
302
|
-
if (option?.divider) return <MenuDivider key={`divider-${i}`} />
|
|
303
|
-
if (option?.heading) return <div key={`heading-${i}`} className={`${resolvedSize === 'xs' ? 'kol-mono-8' : 'kol-helper-12'} ${ROW_H[resolvedSize] ?? ROW_H.sm} ${ROW_PAD[resolvedSize] ?? ROW_PAD.sm} flex shrink-0 items-center text-meta`}>{option.heading}</div>
|
|
304
|
-
const isActive = multiple ? picked.has(option.value) : option.value === currentOption?.value
|
|
305
|
-
return (
|
|
306
|
-
<MenuRow
|
|
307
|
-
key={option.value}
|
|
308
|
-
/* NO HOVER STATE ANYWHERE ON A DROPDOWN (user 2026-08-28) — the indicator marks the current value. */
|
|
309
|
-
hover={false}
|
|
310
|
-
size={resolvedSize}
|
|
311
|
-
/* a float row is the float list's (`.kol-menu-panel--float .kol-menu-row`), whatever the trigger's rung; the
|
|
312
|
-
* current one is lifted (row 54: "selected / checked") — still no hover */
|
|
313
|
-
rowClass={float ? `kol-menu-row${isActive ? ' kol-menu-row--current' : ''}` : (ROW[resolvedSize] ?? ROW.sm)}
|
|
314
|
-
height={rowHeight}
|
|
315
|
-
onPointerEnter={onOptionHover ? () => reportHover(option.value) : undefined}
|
|
316
|
-
onPointerLeave={onOptionHover ? () => reportHover(null) : undefined}
|
|
317
|
-
onClick={() => handleSelect(option)}
|
|
318
|
-
/* The current row's mark is the INDICATOR, always — • for the one pick, ✓ (the check icon) for each
|
|
319
|
-
* row on in a `multiple` (plan-2026-10-31-menu-engine W2). An option's own `shortcut` shows on the
|
|
320
|
-
* rows that are not current — the tool-palette idiom (editor-set-is-behind-its-source, 2026-09-03). */
|
|
321
|
-
indicator={isActive ? (multiple ? 'check' : 'dot') : undefined}
|
|
322
|
-
shortcut={isActive ? undefined : option.shortcut}
|
|
323
|
-
>
|
|
324
|
-
{/* an option's leading glyph — the ADJACENT ladder, because it
|
|
325
|
-
* sits in a line box beside a label, never the solo rung */}
|
|
326
|
-
{option.icon && (
|
|
327
|
-
<span className="shrink-0 inline-flex items-center" style={{ marginRight: 'var(--kol-spacing-2)' }}>
|
|
328
|
-
<Icon name={option.icon} size={glyphSize(resolvedSize)} />
|
|
329
|
-
</span>
|
|
330
|
-
)}
|
|
331
|
-
{option.label}
|
|
332
|
-
</MenuRow>
|
|
333
|
-
)
|
|
334
|
-
})}
|
|
336
|
+
<MenuList items={items} dividerClassName="my-1" headingClassName={headingCls} />
|
|
335
337
|
</div>
|
|
336
338
|
</Menu>
|
|
337
339
|
)
|
package/src/molecules/Menu.jsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
|
2
2
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
3
3
|
import Button from '../atoms/Button.jsx'
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { PopoverPanel, usePopover
|
|
4
|
+
import { MenuRow, MenuDivider } from './MenuItem.jsx'
|
|
5
|
+
import { MenuList, MenuLabel, panelClass } from './MenuList.jsx'
|
|
6
|
+
import { PopoverPanel, usePopover } from '../utilities/Popover.jsx'
|
|
7
7
|
import { TONE_VARS } from '../utilities/tone.js'
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -12,6 +12,7 @@ import { TONE_VARS } from '../utilities/tone.js'
|
|
|
12
12
|
* MenuTrigger the chip: `Button variant="tab" size="sm"`, `pressed` while open; `iconOnly` is the ⋮
|
|
13
13
|
* MenuPanel the faint raised panel (kol-theme `.kol-menu-panel`)
|
|
14
14
|
* MenuRow · MenuDivider · MenuLabel · MenuFlyout — the parts (MenuRow / MenuFlyout / MenuDivider live in MenuItem.jsx)
|
|
15
|
+
* MenuList the rows from `items` — the one place rows are mapped (MenuList.jsx, 2026-11-07); Menu renders it in its panel
|
|
15
16
|
* Menu the base: `trigger` (render prop `({ open, props })`) + `items` (rows as data)
|
|
16
17
|
* MenuFilter · MenuDatePicker · MenuMore — ready-made menus, data and callbacks only
|
|
17
18
|
*
|
|
@@ -56,44 +57,11 @@ export function MenuTrigger({ open = false, iconOnly, icon, iconComponent, varia
|
|
|
56
57
|
return <Button variant="tab" size="sm" pressed={open} iconLeft={icon} iconComponent={iconComponent} {...rest} className={`kol-menu-trigger kol-menu-trigger--quiet ${rest.className ?? ''}`.trim()}>{children}</Button>
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
/* `variant="float"` the list (8) · `sheet` the More sheet (20) on it */
|
|
60
|
-
const panelClass = (variant, sheet) => (variant === 'float' ? `kol-menu-panel--float${sheet ? ' kol-menu-panel--sheet' : ''}` : '')
|
|
61
|
-
|
|
62
60
|
export const MenuPanel = ({ variant, sheet = false, className = '', children, ...rest }) => (
|
|
63
61
|
<div className={`kol-menu-panel ${panelClass(variant, sheet)} ${className}`.replace(/\s+/g, ' ').trim()} {...rest}>{children}</div>
|
|
64
62
|
)
|
|
65
63
|
|
|
66
|
-
export
|
|
67
|
-
|
|
68
|
-
const glyph = (icon, size) => (typeof icon === 'string' ? <Icon name={icon} size={size} /> : icon)
|
|
69
|
-
/* a row's trailing marks — real icons and Kbd only (W2): `indicator` 'dot' | 'check' | 'chevron', `checked` = 'check',
|
|
70
|
-
* `kbd` a key cap, `trailing` an icon name for an action (download) */
|
|
71
|
-
const indicatorOf = (it) => it.indicator ?? (it.checked ? 'check' : undefined)
|
|
72
|
-
|
|
73
|
-
function Rows({ items, variant }) {
|
|
74
|
-
const float = variant === 'float'
|
|
75
|
-
return items.map((it, i) => {
|
|
76
|
-
if (it.divider) return <MenuDivider key={`d${i}`} className="kol-menu-rule" />
|
|
77
|
-
if (it.heading) return <MenuLabel key={`h${i}`}>{it.heading}</MenuLabel>
|
|
78
|
-
const icon = it.icon && <span className="text-oq-88 inline-flex">{glyph(it.icon, 16)}</span>
|
|
79
|
-
const cls = `kol-menu-row kol-helper-12${it.current ? ' kol-menu-row--current' : ''}${it.tone === 'danger' ? ' kol-menu-row--danger' : ''}`
|
|
80
|
-
const row = it.items?.length && !it.disabled ? (
|
|
81
|
-
/* a float flyout is the same list, 8 off the row (row 55) */
|
|
82
|
-
<MenuFlyout flyout iconLeft={icon} label={it.label} rowClass={cls} panelClassName={`kol-menu-panel ${panelClass(variant)} min-w-[200px]`.replace(/\s+/g, ' ')} panelStyle={{ marginLeft: float ? 8 : 4 }}>
|
|
83
|
-
<Rows items={it.items} variant={variant} />
|
|
84
|
-
</MenuFlyout>
|
|
85
|
-
) : (
|
|
86
|
-
<MenuRow href={it.href} disabled={it.disabled} rowClass={cls} onClick={it.onClick} iconLeft={icon} indicator={indicatorOf(it)} kbd={it.kbd}
|
|
87
|
-
shortcut={it.trailing ? <span className="text-oq-88 inline-flex">{glyph(it.trailing, it.trailingSize ?? 14)}</span> : undefined}>
|
|
88
|
-
{it.label}
|
|
89
|
-
</MenuRow>
|
|
90
|
-
)
|
|
91
|
-
const key = it.key ?? `r${i}`
|
|
92
|
-
return it.tooltip
|
|
93
|
-
? <Tooltip key={key} label={it.tooltip} placement="left" triggerClassName="block w-full">{row}</Tooltip>
|
|
94
|
-
: <div key={key}>{row}</div>
|
|
95
|
-
})
|
|
96
|
-
}
|
|
64
|
+
export { MenuLabel }
|
|
97
65
|
|
|
98
66
|
/**
|
|
99
67
|
* Menu — THE menu engine (plan-2026-10-31-menu-engine W1). Every list that floats over a trigger is this: the Menu*
|
|
@@ -119,7 +87,6 @@ export function Menu({
|
|
|
119
87
|
const controlled = openProp !== undefined
|
|
120
88
|
const open = controlled ? openProp : own
|
|
121
89
|
const setOpen = (v) => { if (!controlled) setOwn(v); onOpenChange?.(v) }
|
|
122
|
-
const [q, setQ] = useState('')
|
|
123
90
|
const popover = usePopover({
|
|
124
91
|
open,
|
|
125
92
|
onOpenChange: setOpen,
|
|
@@ -157,12 +124,6 @@ export function Menu({
|
|
|
157
124
|
setAmbient(vars)
|
|
158
125
|
}, [open, variant])
|
|
159
126
|
|
|
160
|
-
let rows = items ?? []
|
|
161
|
-
if (search) {
|
|
162
|
-
const s = q.toLowerCase()
|
|
163
|
-
rows = rows.filter((it) => it.label == null || String(it.label).toLowerCase().includes(s))
|
|
164
|
-
if (!rows.some((it) => it.label != null)) rows = [...rows, { key: 'empty', label: search.empty || 'Nothing matches', disabled: true }]
|
|
165
|
-
}
|
|
166
127
|
/* the wrapper takes the ref (a Button need not forward one); the trigger takes the handlers and the aria —
|
|
167
128
|
* `aria-pressed` cleared, an open menu is `aria-expanded`, its fill is the trigger's `pressed` */
|
|
168
129
|
return (
|
|
@@ -178,9 +139,9 @@ export function Menu({
|
|
|
178
139
|
style={{ ...ambient, ...(minWidth ? { minWidth } : null), ...panelStyle }}>
|
|
179
140
|
{/* a row's click closes the menu (it bubbles from `[data-menu-item]`); a flyout row only toggles */}
|
|
180
141
|
<div role="none" className="flex flex-col min-h-0" onClick={(e) => { if (closeOnSelect && e.target.closest('[data-menu-item]')) setOpen(false) }}>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
142
|
+
<MenuList items={items} search={search} variant={variant}>
|
|
143
|
+
{typeof children === 'function' ? children({ close: () => setOpen(false) }) : children}
|
|
144
|
+
</MenuList>
|
|
184
145
|
</div>
|
|
185
146
|
</PopoverPanel>
|
|
186
147
|
)}
|
|
@@ -2,6 +2,7 @@ import { useLayoutEffect, useRef, useState } from 'react'
|
|
|
2
2
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
3
3
|
import { Menu } from './Menu.jsx'
|
|
4
4
|
import Kbd from '../atoms/Kbd.jsx'
|
|
5
|
+
import Divider from '../atoms/Divider.jsx'
|
|
5
6
|
import { indicatorSize } from '../hooks/glyphLadders.js'
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -164,11 +165,12 @@ export function MenuRow({ href, onClick, onPointerEnter, onPointerLeave, disable
|
|
|
164
165
|
)
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
/* `className` — the rule's
|
|
168
|
-
* panel the
|
|
169
|
-
/* MenuDivider — a rule between a menu's groups
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
/* `className` — the rule's spacing, whole (MetricDashboardUpstream, kol-website 2026-10-31); `kol-menu-rule` is the
|
|
169
|
+
* panel's edge-to-edge rule, its ink set by the panel (oq-16, float oq-08). */
|
|
170
|
+
/* MenuDivider — a rule between a menu's groups: the Divider atom on the oq ramp, oq-08 (plan-2026-11-07-menu-system
|
|
171
|
+
* W1.2 — was a bare `border-t`). Was `MenuDropdownDivider` (alias kept, 2026-10-31). */
|
|
172
|
+
export function MenuDivider({ className = 'my-1' }) {
|
|
173
|
+
return <Divider ink="oq" opacity="08" className={className} />
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
/**
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Icon } from '@kolkrabbi/kol-icons'
|
|
3
|
+
import SearchInput from './SearchInput.jsx'
|
|
4
|
+
import { MenuRow, MenuDivider, MenuFlyout } from './MenuItem.jsx'
|
|
5
|
+
import { Tooltip } from '../utilities/Popover.jsx'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* MenuList — THE rows of every menu (plan-2026-11-07-menu-system W1.1). `Menu`, `Dropdown` and `ContextMenu` (through
|
|
9
|
+
* `Menu`) render it inside their PopoverPanel; nothing else maps rows. It is the list only — no panel, no trigger.
|
|
10
|
+
*
|
|
11
|
+
* <MenuList variant="float" search={{ placeholder: 'Find' }} items={[
|
|
12
|
+
* { heading: 'Graph interval' }, // a MenuLabel
|
|
13
|
+
* { label: 'Days', current: true, indicator: 'dot', onClick },
|
|
14
|
+
* { divider: true }, // a MenuDivider
|
|
15
|
+
* { label: 'Browser', icon: 'layout', items: [...] }, // a flyout of the same rows
|
|
16
|
+
* ]} />
|
|
17
|
+
*
|
|
18
|
+
* items rows as data — the row keys `Menu` documents: `label` · `icon` · `trailing` (+ `trailingSize`) · `current`
|
|
19
|
+
* · `indicator` 'dot' | 'check' | 'chevron' · `checked` · `kbd` · `disabled` + `tooltip` · `tone: 'danger'`
|
|
20
|
+
* · `href` · `onClick` · `items` (a flyout) · `key`. A row may also carry MenuRow's own `rowClass` · `hover`
|
|
21
|
+
* · `size` · `height` · `shortcut` · `prefix` · `onPointerEnter` / `onPointerLeave` (Dropdown's rows do).
|
|
22
|
+
* search `{ placeholder, empty }` — a search field above the rows that filters them by label
|
|
23
|
+
* children sit above the rows (under the search)
|
|
24
|
+
* variant 'float' the float list's rows and flyouts · 'sheet' the More sheet's (the same rows)
|
|
25
|
+
* dividerClassName the rule's class, whole (default `kol-menu-rule` — the panel's edge-to-edge rule)
|
|
26
|
+
* headingClassName the heading's class, whole (default the MenuLabel's)
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/* `variant="float"` the list (8) · `sheet` the More sheet (20) on it */
|
|
30
|
+
export const panelClass = (variant, sheet) => (variant === 'float' ? `kol-menu-panel--float${sheet ? ' kol-menu-panel--sheet' : ''}` : '')
|
|
31
|
+
|
|
32
|
+
export const MenuLabel = ({ className = 'kol-menu-label kol-helper-12', children }) => <div className={className}>{children}</div>
|
|
33
|
+
|
|
34
|
+
const glyph = (icon, size) => (typeof icon === 'string' ? <Icon name={icon} size={size} /> : icon)
|
|
35
|
+
/* a row's trailing marks — real icons and Kbd only (W2): `indicator` 'dot' | 'check' | 'chevron', `checked` = 'check',
|
|
36
|
+
* `kbd` a key cap, `trailing` an icon name for an action (download) */
|
|
37
|
+
const indicatorOf = (it) => it.indicator ?? (it.checked ? 'check' : undefined)
|
|
38
|
+
|
|
39
|
+
export function MenuList({ items = [], search, variant, dividerClassName = 'kol-menu-rule', headingClassName, children }) {
|
|
40
|
+
const float = variant === 'float' || variant === 'sheet'
|
|
41
|
+
const [q, setQ] = useState('')
|
|
42
|
+
let rows = items
|
|
43
|
+
if (search) {
|
|
44
|
+
const s = q.toLowerCase()
|
|
45
|
+
rows = rows.filter((it) => it.label == null || String(it.label).toLowerCase().includes(s))
|
|
46
|
+
if (!rows.some((it) => it.label != null)) rows = [...rows, { key: 'empty', label: search.empty || 'Nothing matches', disabled: true }]
|
|
47
|
+
}
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
{search && <div className="pb-1"><SearchInput variant={float ? 'float' : 'outline'} size="sm" value={q} onChange={(e) => setQ(e.target?.value ?? e)} onClear={() => setQ('')} placeholder={search.placeholder || 'Search'} /></div>}
|
|
51
|
+
{children}
|
|
52
|
+
{rows.map((it, i) => {
|
|
53
|
+
if (it.divider) return <MenuDivider key={it.key ?? `d${i}`} className={dividerClassName} />
|
|
54
|
+
if (it.heading) return <MenuLabel key={it.key ?? `h${i}`} className={headingClassName}>{it.heading}</MenuLabel>
|
|
55
|
+
const icon = it.icon && <span className="text-oq-88 inline-flex">{glyph(it.icon, 16)}</span>
|
|
56
|
+
const cls = it.rowClass ?? `kol-menu-row kol-helper-12${it.current ? ' kol-menu-row--current' : ''}${it.tone === 'danger' ? ' kol-menu-row--danger' : ''}`
|
|
57
|
+
const row = it.items?.length && !it.disabled ? (
|
|
58
|
+
/* a float flyout is the same list, 8 off the row (row 55) */
|
|
59
|
+
<MenuFlyout flyout iconLeft={icon} label={it.label} rowClass={cls} panelClassName={`kol-menu-panel ${float ? 'kol-menu-panel--float' : ''} min-w-[200px]`.replace(/\s+/g, ' ')} panelStyle={{ marginLeft: float ? 8 : 4 }}>
|
|
60
|
+
<MenuList items={it.items} variant={variant} dividerClassName={dividerClassName} headingClassName={headingClassName} />
|
|
61
|
+
</MenuFlyout>
|
|
62
|
+
) : (
|
|
63
|
+
<MenuRow href={it.href} disabled={it.disabled} rowClass={cls} onClick={it.onClick} iconLeft={icon} prefix={it.prefix}
|
|
64
|
+
indicator={indicatorOf(it)} kbd={it.kbd} hover={it.hover} size={it.size} height={it.height}
|
|
65
|
+
onPointerEnter={it.onPointerEnter} onPointerLeave={it.onPointerLeave}
|
|
66
|
+
shortcut={it.shortcut ?? (it.trailing ? <span className="text-oq-88 inline-flex">{glyph(it.trailing, it.trailingSize ?? 14)}</span> : undefined)}>
|
|
67
|
+
{it.label}
|
|
68
|
+
</MenuRow>
|
|
69
|
+
)
|
|
70
|
+
const key = it.key ?? `r${i}`
|
|
71
|
+
return it.tooltip
|
|
72
|
+
? <Tooltip key={key} label={it.tooltip} placement="left" triggerClassName="block w-full">{row}</Tooltip>
|
|
73
|
+
: <div key={key}>{row}</div>
|
|
74
|
+
})}
|
|
75
|
+
</>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default MenuList
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import Dropdown from './Dropdown.jsx'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* WorkspaceSwitcher — Which workspace you are in. `
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* WorkspaceSwitcher — Which workspace you are in. `Personal / Kolkrabbi ⌄` (float-everything W4 row 58, 2026-11-04 —
|
|
5
|
+
* the exploration's workspace selector at the top of a rail). A `Dropdown` of the workspaces — a button, no label of
|
|
6
|
+
* its own (plan-2026-11-07-menu-system W1.2): the caller names it with `LabeledControl`
|
|
7
|
+
* (`<LabeledControl label="Workspace" variant="float"><WorkspaceSwitcher … /></LabeledControl>`). `variant="float"` is
|
|
8
|
+
* the float select on the well, the default the sm dropdown. A workspace is `{ value, label, icon? }`; a nested one
|
|
9
|
+
* reads `Studio / Personal` in its label.
|
|
8
10
|
*
|
|
9
|
-
* @param {string} [label] default `Workspace`
|
|
11
|
+
* @param {string} [label] what it chooses, for a screen reader — default `Workspace`
|
|
10
12
|
* @param {Array} workspaces Dropdown options
|
|
11
13
|
* @param {string} value
|
|
12
14
|
* @param {Function} onChange `(value) => void`
|
|
@@ -15,10 +17,5 @@ import Dropdown from './Dropdown.jsx'
|
|
|
15
17
|
*/
|
|
16
18
|
export default function WorkspaceSwitcher({ label = 'Workspace', workspaces = [], value, onChange, variant, className = '' }) {
|
|
17
19
|
const float = variant === 'float'
|
|
18
|
-
return
|
|
19
|
-
<div className={`inline-flex flex-col gap-3 ${className}`.trim()}>
|
|
20
|
-
<span className="kol-float-label uppercase tracking-[0.03em] text-fg-64">{label}</span>
|
|
21
|
-
<Dropdown variant={float ? 'float' : undefined} size={float ? 'md' : undefined} options={workspaces} value={value} onChange={onChange} ariaLabel={label} />
|
|
22
|
-
</div>
|
|
23
|
-
)
|
|
20
|
+
return <Dropdown variant={float ? 'float' : undefined} size={float ? 'md' : undefined} options={workspaces} value={value} onChange={onChange} ariaLabel={label} className={className} />
|
|
24
21
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { MenuItem as MenuTrigger } from './MenuItem.jsx'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated 2026-07-02 — alias of MenuItem (menu-family unify). Drops when nobody imports it (04-retirements.md).
|
|
5
|
-
* MenuPopover — Old name for MenuItem. DEPRECATED alias of MenuItem (2026-07-02 menu-family
|
|
6
|
-
* unification).
|
|
7
|
-
*
|
|
8
|
-
* The two triggers had an identical API (label, children incl. ({ close })
|
|
9
|
-
* render-prop, align, panelClassName, panelStyle, buttonClassName,
|
|
10
|
-
* defaultOpen) and did the same job — MenuPopover with hand-rolled
|
|
11
|
-
* fixed positioning, MenuItem on floating-ui (portal, auto-flip, focus
|
|
12
|
-
* management). One implementation now: MenuItem. This alias keeps existing
|
|
13
|
-
* call-sites working; migrate imports to MenuItem. Removal in the next major.
|
|
14
|
-
*
|
|
15
|
-
* Compose the rows with the exported `MenuDropdownItem` / `MenuDropdownDivider`
|
|
16
|
-
* / `MenuDropdownNest` from MenuItem.jsx — this file no longer ships its own
|
|
17
|
-
* duplicate row/divider components (they were dead: never barrel-exported).
|
|
18
|
-
*/
|
|
19
|
-
export function MenuPopover(props) {
|
|
20
|
-
return <MenuTrigger {...props} />
|
|
21
|
-
}
|