@kolkrabbi/kol-component 0.378.0 → 0.380.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 +5 -4
- package/src/atoms/Badge.jsx +1 -5
- package/src/atoms/BezierPathEditor.jsx +1 -1
- package/src/atoms/Button.jsx +88 -12
- package/src/atoms/Figure.jsx +19 -1
- package/src/atoms/FunctionPlot.jsx +1 -1
- package/src/atoms/Input.jsx +107 -7
- package/src/atoms/Kbd.jsx +42 -2
- package/src/atoms/Link.jsx +20 -0
- package/src/atoms/OriginPicker.jsx +9 -5
- package/src/atoms/Pill.jsx +1 -3
- package/src/atoms/ProgressBar.jsx +3 -6
- package/src/atoms/SectionFooter.jsx +22 -0
- package/src/atoms/SectionHeader.jsx +24 -0
- package/src/atoms/SectionLabel.jsx +0 -22
- package/src/atoms/SizeOrDownload.jsx +1 -1
- package/src/atoms/Tag.jsx +4 -7
- package/src/atoms/Textarea.jsx +12 -7
- package/src/atoms/ToggleCheckbox.jsx +25 -5
- package/src/atoms/ToggleSwitch.jsx +41 -7
- package/src/atoms/ViewToggle.jsx +2 -29
- package/src/atoms/XYPad.jsx +25 -0
- package/src/hooks/useDragResize.js +1 -1
- package/src/index.js +26 -4
- package/src/molecules/AccountMenu.jsx +16 -3
- package/src/molecules/AlignmentGrid.jsx +13 -1
- package/src/molecules/ButtonGroup.jsx +78 -15
- package/src/molecules/ButtonSplit.jsx +75 -28
- package/src/molecules/Chip.jsx +26 -0
- package/src/molecules/CodeBlock.jsx +39 -2
- package/src/molecules/ColorInputRow.jsx +125 -4
- package/src/molecules/ColorSwatch.jsx +43 -2
- package/src/molecules/ContentCard.jsx +104 -3
- package/src/molecules/ContentMedia.jsx +1 -1
- package/src/molecules/ContentRow.jsx +4 -32
- package/src/molecules/ContextMenu.jsx +0 -1
- package/src/molecules/DividerLabel.jsx +19 -0
- package/src/molecules/DocsToc.jsx +1 -16
- package/src/molecules/Dropdown.jsx +115 -18
- package/src/molecules/DropdownStepper.jsx +29 -0
- package/src/molecules/EmptyState.jsx +1 -15
- package/src/molecules/FieldPair.jsx +41 -2
- package/src/molecules/Header.jsx +4 -4
- package/src/molecules/IndexRow.jsx +1 -1
- package/src/molecules/InlineAddRow.jsx +2 -2
- package/src/molecules/LabeledControl.jsx +56 -11
- package/src/molecules/LayerRow.jsx +1 -1
- package/src/molecules/LinkAddRow.jsx +5 -7
- package/src/molecules/Menu.jsx +250 -33
- package/src/molecules/MenuFloat.jsx +6 -12
- package/src/molecules/MenuList.jsx +5 -11
- package/src/molecules/Modal.jsx +228 -55
- package/src/molecules/ModalHeader.jsx +12 -20
- package/src/molecules/ModalShell.jsx +20 -10
- package/src/molecules/NoticeBanner.jsx +1 -1
- package/src/molecules/OptionRow.jsx +1 -1
- package/src/molecules/PanelsMenu.jsx +2 -2
- package/src/molecules/ParamBindDot.jsx +29 -2
- package/src/molecules/PasswordInput.jsx +1 -1
- package/src/molecules/QuantityInput.jsx +45 -13
- package/src/molecules/QuickLookFrame.jsx +2 -31
- package/src/molecules/RailHeader.jsx +37 -16
- package/src/molecules/ReadingActions.jsx +2 -2
- package/src/molecules/ReadingNotes.jsx +3 -3
- package/src/molecules/ReadingSettings.jsx +8 -8
- package/src/molecules/SearchInput.jsx +4 -5
- package/src/molecules/SectionText.jsx +56 -10
- package/src/molecules/SettingsControls.jsx +23 -23
- package/src/molecules/Slider.jsx +103 -55
- package/src/molecules/SpecList.jsx +1 -21
- package/src/molecules/SplitToolButton.jsx +4 -6
- package/src/molecules/SwatchControls.jsx +28 -0
- package/src/molecules/SwatchGrid.jsx +39 -0
- package/src/molecules/TabsDocument.jsx +131 -0
- package/src/molecules/TabsRow.jsx +40 -50
- package/src/molecules/TaskRow.jsx +2 -2
- package/src/molecules/Toast.jsx +55 -0
- package/src/molecules/TocRow.jsx +1 -1
- package/src/molecules/TreeRow.jsx +87 -1
- package/src/molecules/WorkspaceSwitcher.jsx +3 -6
- package/src/organisms/AppItemMenuProvider.jsx +2 -2
- package/src/organisms/ColorPickerPopover.jsx +133 -4
- package/src/organisms/ColumnBrowser.jsx +1 -1
- package/src/organisms/CommandOverlay.jsx +362 -87
- package/src/organisms/ContentFilters.jsx +4 -12
- package/src/organisms/FindBar.jsx +70 -0
- package/src/organisms/FramedMediaBand.jsx +2 -2
- package/src/organisms/GalleryCarousel.jsx +1 -1
- package/src/organisms/LogoSystem.jsx +38 -0
- package/src/organisms/LogoTuner.jsx +32 -0
- package/src/organisms/MediaLibrary.jsx +1 -56
- package/src/organisms/MediaLibraryPages.jsx +1 -1
- package/src/organisms/NavRail.jsx +1 -4
- package/src/organisms/Rail.jsx +33 -1
- package/src/organisms/RailSwitcher.jsx +62 -0
- package/src/organisms/ReadingContents.jsx +65 -3
- package/src/organisms/ReadingOverview.jsx +5 -5
- package/src/organisms/ReadingPanel.jsx +1 -1
- package/src/organisms/SectionSplit.jsx +1 -1
- package/src/organisms/SettingsPanel.jsx +64 -41
- package/src/organisms/ShortcutsOverlay.jsx +46 -2
- package/src/organisms/SpectrumControls.jsx +112 -19
- package/src/organisms/StatusBar.jsx +30 -0
- package/src/organisms/Table.jsx +136 -45
- package/src/organisms/TimelineDock.jsx +281 -1
- package/src/organisms/logoBoard.jsx +61 -0
- package/src/utilities/AssetPlaceholder.jsx +1 -1
- package/src/utilities/EditorShell.jsx +42 -1
- package/src/utilities/OverlayGlassPanel.jsx +1 -1
- package/src/utilities/Popover.jsx +299 -5
- package/src/utilities/SelectionOverlay.jsx +60 -31
- package/src/utilities/kolboxGlyph.jsx +10 -0
- package/src/molecules/FloatModuleHeader.jsx +0 -11
- package/src/organisms/NavRailFloat.jsx +0 -139
|
@@ -26,7 +26,7 @@ export default function IndexRow({ title, cells = [], checked = false, onCheck,
|
|
|
26
26
|
aria-selected={onClick ? selected : undefined}
|
|
27
27
|
className={`flex h-7 w-full items-center gap-3 rounded-[var(--kol-float-list-r)] px-2.5 ${onClick ? 'cursor-pointer focus-visible:outline-none focus-visible:shadow-[var(--kol-float-focus)]' : ''} ${selected ? 'bg-fg-12' : 'hover:bg-fg-04'} ${className}`.trim()}
|
|
28
28
|
>
|
|
29
|
-
{onCheck && <span onClick={(e) => e.stopPropagation()} className="inline-flex shrink-0"><ToggleCheckbox
|
|
29
|
+
{onCheck && <span onClick={(e) => e.stopPropagation()} className="inline-flex shrink-0"><ToggleCheckbox checked={checked} onChange={onCheck} aria-label="Done" /></span>}
|
|
30
30
|
<span className={`kol-float-hint min-w-0 flex-1 truncate ${checked ? 'text-fg-48' : 'text-fg-emphasis'}`}>{title}</span>
|
|
31
31
|
{cells.map((c, i) => {
|
|
32
32
|
const cell = c && typeof c === 'object' && 'value' in c ? c : { value: c }
|
|
@@ -6,12 +6,12 @@ import Kbd from '../atoms/Kbd.jsx'
|
|
|
6
6
|
* InlineAddRow — Add a row where the next row would be. `+ New brief · ↵` (float-everything W3 row 41, 2026-11-04 —
|
|
7
7
|
* the exploration's inline add). A full-width `Input` led by the plus and trailed by the return cap: type, press
|
|
8
8
|
* Enter, `onAdd(text)` fires and the field clears; Escape clears it. Nothing opens, nothing moves — the row is the
|
|
9
|
-
* form.
|
|
9
|
+
* form.
|
|
10
10
|
*
|
|
11
11
|
* @param {string} label the placeholder — what the row adds (`New brief`)
|
|
12
12
|
* @param {Function} onAdd `(text) => void` on Enter with a non-empty, trimmed value
|
|
13
13
|
* @param {boolean} [kbd] the ↵ cap at the end (default true)
|
|
14
|
-
* @param {'
|
|
14
|
+
* @param {'filled'|'outline'} [variant]
|
|
15
15
|
* @param {'sm'|'md'|'lg'} [size]
|
|
16
16
|
* @param {string} [className]
|
|
17
17
|
*/
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Props:
|
|
16
16
|
* label — any node: the label text, or an icon with text (a ToggleSwitch row's glyph). A string takes the
|
|
17
|
-
* variant's label style (kol-helper-10, tracked
|
|
17
|
+
* variant's label style (kol-helper-10, tracked).
|
|
18
18
|
* hint — optional secondary text after the label (lower-case, less
|
|
19
19
|
* weight). Useful for current-value displays, units, etc.
|
|
20
20
|
* horizontal — bool. true: the label beside the control (left); false (default): the label above it
|
|
@@ -34,14 +34,18 @@
|
|
|
34
34
|
* variant — `'panel'` is the hardware panel label (was kol-hardware `PanelLabel`, merged
|
|
35
35
|
* 2026-10-01): `kol-helper-8`, uppercase, hugging the control; it takes
|
|
36
36
|
* `labelPosition` (`top · bottom · left · right`, default bottom), `labelClass` and `gap`.
|
|
37
|
-
* `'float'` (float-everything W3 row 37, 2026-11-04): the label over a capsule — the float hint role
|
|
38
|
-
* (Inter 12) at fg-64, no uppercase, no tracking, `--kol-float-label-gap` from the control; `horizontal` keeps
|
|
39
|
-
* the same label in the `--kol-float-label-w` column (a `labelWidth` still wins), the row at least the float
|
|
40
|
-
* sm height. Every float row is this (plan-2026-11-12-float-system W2.1); the wrapper carries
|
|
41
|
-
* `data-labeled-control`.
|
|
42
37
|
* `'settings'` (plan-2026-11-12-float-rails-figma W13.1): the generator settings window's row (`Dialog
|
|
43
38
|
* variant="settings"`): the label in Inter 10 at oq-64, 6 over the control; `horizontal` puts it beside the
|
|
44
39
|
* control, 8 apart, the label hugging its text (a `labelWidth` still sets a column).
|
|
40
|
+
* `'kolbox'` (plan-2026-11-18-kolbox-system W31.2, 2026-11-18): kolbox's row carried class for class, the label
|
|
41
|
+
* Inter 12 / 16 medium in oq-64. `horizontal`: the label in a 76 column (a `labelWidth` sets another, 160 for a
|
|
42
|
+
* window's longer labels), 8 from the control, the row at least 28; stacked: the label 4 over a row of controls
|
|
43
|
+
* 4 apart. `controlFirst`: the control at the left, inset 4, then 8 apart the label in Inter 11 / 15, the row as
|
|
44
|
+
* tall as its control. Chrome in kol-theme `.kol-labeled-control--kolbox`.
|
|
45
|
+
* `'folio'` (Folio batch C, 2026-11-22): Folio's Setting carried class for class. Stacked: the label (Folio's
|
|
46
|
+
* label, 10 semibold, tracked, capitals) 8 over the control; `horizontal`: the label (12 / 16 medium) in a 48
|
|
47
|
+
* column, 12 from the control. Both labels in Folio's muted ink. Chrome in kol-theme `.kol-labeled-control--folio`.
|
|
48
|
+
* controlFirst — bool, `kolbox` only: the control before its label (kolbox's Clip content row).
|
|
45
49
|
* labelClass — the label's type and ink, replacing the variant's (a row that keeps its own label look: Slider's
|
|
46
50
|
* kol-helper-12, a toggle's words in the settings ink). On `panel` it defaults to kol-helper-8.
|
|
47
51
|
* children — the control body.
|
|
@@ -66,8 +70,50 @@ export default function LabeledControl({
|
|
|
66
70
|
labelPosition = 'bottom',
|
|
67
71
|
labelClass,
|
|
68
72
|
gap = 0,
|
|
73
|
+
controlFirst = false,
|
|
69
74
|
...rest
|
|
70
75
|
}) {
|
|
76
|
+
if (variant === 'kolbox') {
|
|
77
|
+
const mark = { 'data-labeled-control': '', ...rest }
|
|
78
|
+
if (controlFirst) {
|
|
79
|
+
return (
|
|
80
|
+
<div {...mark} className={`kol-labeled-control--kolbox flex items-center gap-2 pl-1 ${className}`.trim()}>
|
|
81
|
+
{children}
|
|
82
|
+
<span className="kol-labeled-control-help min-w-0 flex-1 truncate">{label}</span>
|
|
83
|
+
</div>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
if (!(horizontal ?? inline ?? false)) {
|
|
87
|
+
return (
|
|
88
|
+
<div {...mark} className={`kol-labeled-control--kolbox flex flex-col gap-1 ${className}`.trim()}>
|
|
89
|
+
<span className="kol-labeled-control-label">{label}</span>
|
|
90
|
+
<div className="flex min-w-0 items-center gap-1">{children}</div>
|
|
91
|
+
</div>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
return (
|
|
95
|
+
<div {...mark} className={`kol-labeled-control--kolbox flex min-h-(--kol-kolbox-ctl) items-center gap-2 ${className}`.trim()}>
|
|
96
|
+
<span className={`kol-labeled-control-label ${labelWidth == null ? 'w-19 ' : ''}shrink-0 truncate`} style={labelWidth == null ? undefined : { width: labelWidth }}>{label}</span>
|
|
97
|
+
<div className="flex min-w-0 flex-1 items-center gap-2">{children}</div>
|
|
98
|
+
</div>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
if (variant === 'folio') {
|
|
102
|
+
if (horizontal ?? inline ?? false) {
|
|
103
|
+
return (
|
|
104
|
+
<div {...rest} className={`kol-labeled-control--folio flex items-center gap-[12px] ${className}`.trim()}>
|
|
105
|
+
<p className="kol-labeled-control-label w-[48px] shrink-0">{label}</p>
|
|
106
|
+
<div className="flex min-w-0 flex-1 items-center">{children}</div>
|
|
107
|
+
</div>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
return (
|
|
111
|
+
<div {...rest} className={`kol-labeled-control--folio flex flex-col gap-[8px] ${className}`.trim()}>
|
|
112
|
+
<p className="kol-labeled-control-title">{label}</p>
|
|
113
|
+
{children}
|
|
114
|
+
</div>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
71
117
|
if (variant === 'panel') {
|
|
72
118
|
const isRow = labelPosition === 'left' || labelPosition === 'right'
|
|
73
119
|
const labelEl = label && (
|
|
@@ -84,12 +130,11 @@ export default function LabeledControl({
|
|
|
84
130
|
)
|
|
85
131
|
}
|
|
86
132
|
const showLabel = !!label
|
|
87
|
-
const float = variant === 'float'
|
|
88
133
|
const settings = variant === 'settings'
|
|
89
|
-
const lw = labelWidth ?? (
|
|
90
|
-
const gapClass =
|
|
134
|
+
const lw = labelWidth ?? (settings ? 'fit-content' : 48)
|
|
135
|
+
const gapClass = settings ? (horizontal ?? inline ? 'gap-2' : 'gap-1.5') : null
|
|
91
136
|
const mark = { 'data-labeled-control': '', ...rest }
|
|
92
|
-
const labelType = labelClass ?? (
|
|
137
|
+
const labelType = labelClass ?? (settings ? SETTINGS_LABEL : 'kol-helper-10 tracking-widest text-meta')
|
|
93
138
|
/* a display class from the caller replaces the wrapper's own (`hidden md:flex` must hold) */
|
|
94
139
|
const display = DISPLAY.test(className) ? '' : 'flex'
|
|
95
140
|
/* …and so does a gap class: the caller's spacing, not two utilities racing */
|
|
@@ -113,7 +158,7 @@ export default function LabeledControl({
|
|
|
113
158
|
* showed as "C" or not at all. Label on its line, the value under it. */
|
|
114
159
|
const labelAuto = lw === 'auto'
|
|
115
160
|
return (
|
|
116
|
-
<div {...mark} className={`${display} ${labelAuto ? `flex-col items-start gap-1 sm:flex-row ${text ? 'sm:items-baseline' : 'sm:items-center'} sm:gap-3` : `${text ? 'items-baseline' : 'items-center'} ${ownGap ? '' : gapClass ?? 'gap-3'}`}${
|
|
161
|
+
<div {...mark} className={`${display} ${labelAuto ? `flex-col items-start gap-1 sm:flex-row ${text ? 'sm:items-baseline' : 'sm:items-center'} sm:gap-3` : `${text ? 'items-baseline' : 'items-center'} ${ownGap ? '' : gapClass ?? 'gap-3'}`}${className}`}>
|
|
117
162
|
{showLabel && (
|
|
118
163
|
<span
|
|
119
164
|
/* A LABEL NEVER WRAPS (review 2, § 6.2 — the helper law by construction, 01-foundations/03-typography.md:29):
|
|
@@ -30,7 +30,7 @@ import TreeRow from './TreeRow.jsx'
|
|
|
30
30
|
*/
|
|
31
31
|
export default function LayerRow({ variant = 'row', icon = 'layers', name, selected = false, visible = true, onToggleVisible, locked = false, onToggleLock, depth = 0, onClick, className = '' }) {
|
|
32
32
|
if (variant === 'head') {
|
|
33
|
-
const btn = (label, glyph, on, fn) => <Button
|
|
33
|
+
const btn = (label, glyph, on, fn) => <Button tone="ghost" size="sm" iconOnly={glyph} aria-label={label} aria-pressed={on} onClick={fn} />
|
|
34
34
|
return (
|
|
35
35
|
<div className={`flex items-center gap-2 ${className}`.trim()}>
|
|
36
36
|
<IconLoader name={icon} size={18} className="shrink-0 text-oq-64" />
|
|
@@ -7,9 +7,8 @@ import Button from '../atoms/Button.jsx'
|
|
|
7
7
|
* LinkAddRow — Add a named link. `name · URL · Add link` (float-everything W3 row 43, 2026-11-04 — the exploration's
|
|
8
8
|
* project links card). One row: the name field, the URL field (mono, `https://…`) taking the room, and the Add
|
|
9
9
|
* button; Enter in either field adds too. `onAdd({ name, url })` fires with both trimmed and the fields clear; the
|
|
10
|
-
* button is disabled until the URL has something. With `title` the row sits under a head — the title at the
|
|
11
|
-
*
|
|
12
|
-
* draws the capsules; the default is the filled shell.
|
|
10
|
+
* button is disabled until the URL has something. With `title` the row sits under a head — the title at the body
|
|
11
|
+
* size with the open-in-new glyph linking to `href`.
|
|
13
12
|
*
|
|
14
13
|
* @param {Function} onAdd `({ name, url }) => void`
|
|
15
14
|
* @param {string} [title] the head's name (`kol-vault`)
|
|
@@ -17,13 +16,12 @@ import Button from '../atoms/Button.jsx'
|
|
|
17
16
|
* @param {string} [namePlaceholder] default `Link name`
|
|
18
17
|
* @param {string} [urlPlaceholder] default `https://…`
|
|
19
18
|
* @param {string} [addLabel] default `Add link`
|
|
20
|
-
* @param {'
|
|
19
|
+
* @param {'filled'|'outline'} [variant]
|
|
21
20
|
* @param {string} [className]
|
|
22
21
|
*/
|
|
23
22
|
export default function LinkAddRow({ onAdd, title, href, namePlaceholder = 'Link name', urlPlaceholder = 'https://…', addLabel = 'Add link', variant, className = '' }) {
|
|
24
23
|
const [name, setName] = useState('')
|
|
25
24
|
const [url, setUrl] = useState('')
|
|
26
|
-
const float = variant === 'float'
|
|
27
25
|
const ready = url.trim().length > 0
|
|
28
26
|
const add = () => { if (!ready) return; onAdd?.({ name: name.trim(), url: url.trim() }); setName(''); setUrl('') }
|
|
29
27
|
const onKey = (e) => { if (e.key === 'Enter') add() }
|
|
@@ -32,12 +30,12 @@ export default function LinkAddRow({ onAdd, title, href, namePlaceholder = 'Link
|
|
|
32
30
|
<div className="flex flex-wrap items-center gap-2">
|
|
33
31
|
<Input variant={variant} size="md" placeholder={namePlaceholder} value={name} onChange={(e) => setName(e.target.value)} onKeyDown={onKey} className="w-64 max-w-full" />
|
|
34
32
|
<Input variant={variant} size="md" type="url" inputMode="url" placeholder={urlPlaceholder} value={url} onChange={(e) => setUrl(e.target.value)} onKeyDown={onKey} width="100%" className="flex-1 min-w-40" inputClassName="font-mono" />
|
|
35
|
-
<Button
|
|
33
|
+
<Button size="md" disabled={!ready} onClick={add}>{addLabel}</Button>
|
|
36
34
|
</div>
|
|
37
35
|
)
|
|
38
36
|
if (!title) return <div className={className}>{row}</div>
|
|
39
37
|
return (
|
|
40
|
-
<div className={`flex flex-col gap-4 ${
|
|
38
|
+
<div className={`flex flex-col gap-4 ${className}`.trim()}>
|
|
41
39
|
<div className="flex items-center justify-between gap-4">
|
|
42
40
|
<span className="kol-float-body text-fg-emphasis">{title}</span>
|
|
43
41
|
{href && (
|
package/src/molecules/Menu.jsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
|
1
|
+
import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
|
2
2
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
3
|
import Button from '../atoms/Button.jsx'
|
|
4
|
+
import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
4
5
|
import { MenuRow, MenuDivider } from './MenuItem.jsx'
|
|
5
|
-
import { MenuList, MenuLabel
|
|
6
|
-
import { PopoverPanel, usePopover } from '../utilities/Popover.jsx'
|
|
6
|
+
import { MenuList, MenuLabel } from './MenuList.jsx'
|
|
7
|
+
import { PopoverPanel, PopoverLayer, usePopover } from '../utilities/Popover.jsx'
|
|
7
8
|
import { TONE_VARS } from '../utilities/tone.js'
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -31,24 +32,12 @@ import { TONE_VARS } from '../utilities/tone.js'
|
|
|
31
32
|
* · `tone: 'danger'` the destructive row (the error ink).
|
|
32
33
|
* `search` ({ placeholder, empty }) puts a search field above the rows and filters them by label.
|
|
33
34
|
* `children` sit above the rows.
|
|
34
|
-
*
|
|
35
|
-
* THE FLOAT LOOK (float-everything W4, 2026-11-04 — rows 46–60 of the gap map): `variant="float"` on any of them. The
|
|
36
|
-
* panel is a list on `--kol-float-list-r` (8), 4 in, the float surface and shadow; its rows are 34, 12 in, Inter 12/500,
|
|
37
|
-
* lifted on `--kol-fg-16`; a flyout opens 8 off the row on the same list. `MenuMore variant="float"` is the More sheet —
|
|
38
|
-
* `--kol-float-menu-r` (20), 6 in. `MenuTrigger variant="float"` is a `Button variant="float"` capsule on the float well;
|
|
39
|
-
* `MenuDatePicker variant="float"` sets its value in mono — the date chip (row 33). Today's defaults do not move.
|
|
40
35
|
*/
|
|
41
36
|
|
|
42
37
|
/* the ⋮ — kol-icons `more-vertical` (user 2026-10-31: *"just make a vertical version"* — was `more` turned 90°) */
|
|
43
38
|
const MORE = <IconLoader name="more-vertical" size={16} />
|
|
44
39
|
|
|
45
|
-
export function MenuTrigger({ open = false, iconOnly, icon, iconComponent, variant,
|
|
46
|
-
/* the float trigger: a capsule on the float well, lit fg-16 while its menu is open; `mono` for a value (the date chip) */
|
|
47
|
-
if (variant === 'float') {
|
|
48
|
-
const cls = `kol-menu-trigger kol-menu-trigger--float${mono ? ' kol-menu-trigger--mono' : ''} ${rest.className ?? ''}`.trim()
|
|
49
|
-
if (iconOnly) return <Button variant="float" size={size ?? 'md'} pressed={open} iconOnly={iconOnly === true ? 'more-vertical' : iconOnly} iconComponent={iconOnly === true ? MORE : iconComponent} {...rest} className={cls} />
|
|
50
|
-
return <Button variant="float" size={size ?? 'md'} pressed={open} iconLeft={icon} iconComponent={iconComponent} {...rest} className={cls}>{children}</Button>
|
|
51
|
-
}
|
|
40
|
+
export function MenuTrigger({ open = false, iconOnly, icon, iconComponent, variant, size, children, ...rest }) {
|
|
52
41
|
if (iconOnly) {
|
|
53
42
|
return <Button variant="tab" size="sm" pressed={open} iconOnly={iconOnly === true ? 'more-vertical' : iconOnly} iconComponent={iconOnly === true ? MORE : iconComponent} {...rest} className={`kol-menu-trigger ${rest.className ?? ''}`.trim()} />
|
|
54
43
|
}
|
|
@@ -57,12 +46,238 @@ export function MenuTrigger({ open = false, iconOnly, icon, iconComponent, varia
|
|
|
57
46
|
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>
|
|
58
47
|
}
|
|
59
48
|
|
|
60
|
-
export const MenuPanel = ({
|
|
61
|
-
<div className={`kol-menu-panel flex flex-col gap-[var(--kol-spacing-0-5)] ${
|
|
49
|
+
export const MenuPanel = ({ className = '', children, ...rest }) => (
|
|
50
|
+
<div className={`kol-menu-panel flex flex-col gap-[var(--kol-spacing-0-5)] ${className}`.replace(/\s+/g, ' ').trim()} {...rest}>{children}</div>
|
|
62
51
|
)
|
|
63
52
|
|
|
64
53
|
export { MenuLabel }
|
|
65
54
|
|
|
55
|
+
|
|
56
|
+
/* ── the kolbox look (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18) ──
|
|
57
|
+
* kolbox's Menu carried line for line, the chrome in kol-theme `.kol-menu--kolbox` and its rows. Its own API, which no
|
|
58
|
+
* other look shares: an `anchor` (an element, a ref, or anything with getBoundingClientRect), controlled `open` with
|
|
59
|
+
* `onClose`, `onSelect(row)`, and `groups` `[[row, ...], { title, rows: [...] }]` with a rule between groups; a row is
|
|
60
|
+
* `{ label, value, icon, check, shortcut, tag, submenu, disabled, highlighted, inset }`; `highlighted` marks the chosen row
|
|
61
|
+
* (where the keys start, the row an `over` list lays on its field), never a lit row: a menu opens with none lit. KOL's words where they are the
|
|
62
|
+
* same thing: `aria-label`, `minWidth`, `panelClassName` (the panel's class), `children` (a node above the rows: the
|
|
63
|
+
* zoom menu's field). A row's `icon` is the set's name. `placement` is the layer's (`PopoverLayer`): bottom-start, left-start, right-start, beside, over
|
|
64
|
+
* (a Dropdown's list lying over its field). */
|
|
65
|
+
|
|
66
|
+
/* One row: a leading check or icon, the label, then a shortcut, a tag or a submenu chevron. The active row (the pointer's
|
|
67
|
+
or the keys') is solid accent with on-accent ink. The pointer lights a row when it moves on it, so a list that opens
|
|
68
|
+
under a resting pointer (a dropdown laid over its field) opens with no row lit.
|
|
69
|
+
`inset`: a row with no glyph held in the glyph's column. */
|
|
70
|
+
function MenuRowKolbox({ row, index, lead, active, onEnter, onPick }) {
|
|
71
|
+
const { label, icon, check, shortcut, tag, submenu, disabled, inset } = row
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
role={check === undefined ? 'menuitem' : 'menuitemcheckbox'}
|
|
75
|
+
aria-checked={check === undefined ? undefined : !!check}
|
|
76
|
+
aria-disabled={disabled || undefined}
|
|
77
|
+
aria-haspopup={submenu ? 'menu' : undefined}
|
|
78
|
+
data-menu-row={index}
|
|
79
|
+
data-active={active || undefined}
|
|
80
|
+
data-chosen={row.highlighted || undefined}
|
|
81
|
+
onPointerMove={disabled || active ? undefined : onEnter}
|
|
82
|
+
onClick={disabled ? undefined : onPick}
|
|
83
|
+
className={`kol-menu-row--kolbox${disabled ? ' is-disabled' : active ? ' is-active' : ''} flex h-6 shrink-0 cursor-default items-center gap-2 px-2 whitespace-nowrap${disabled ? ' opacity-50' : ''}`}
|
|
84
|
+
>
|
|
85
|
+
{lead ? (
|
|
86
|
+
<span className="flex size-4 shrink-0 items-center justify-center">
|
|
87
|
+
{check ? <KolboxGlyph name="check" size={12} /> : icon ? <KolboxGlyph name={icon} /> : null}
|
|
88
|
+
</span>
|
|
89
|
+
) : icon ? <KolboxGlyph name={icon} /> : inset && <span className="size-4 shrink-0" />}
|
|
90
|
+
<span className="flex-1">{label}</span>
|
|
91
|
+
{shortcut && <span className={`shrink-0 ${active ? '' : 'kol-menu-sub--kolbox'}`}>{shortcut}</span>}
|
|
92
|
+
{tag && <span className={`kol-menu-tag--kolbox${active ? ' is-active' : ''} px-1`}>{tag}</span>}
|
|
93
|
+
{submenu && <KolboxGlyph name="chevron-right" className={active ? '' : 'kol-menu-sub--kolbox'} />}
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* MenuScroll — the foot of a kolbox menu taller than the window (Menu family, W31.2 batch 4; Figma 288:8017): the full
|
|
100
|
+
* panel width, 24 high, the 12 chevron-down centred in oq-64. While the pointer is on it the panel scrolls down, 4 px a
|
|
101
|
+
* frame, until the end or the pointer leaves. It sits sticky on the menu's own fill so the rows pass under it.
|
|
102
|
+
* `Menu variant="kolbox"` draws it on its own; `panel` is the scrolling panel's ref.
|
|
103
|
+
*/
|
|
104
|
+
export function MenuScroll({ panel }) {
|
|
105
|
+
const run = useRef(0)
|
|
106
|
+
const stop = () => cancelAnimationFrame(run.current)
|
|
107
|
+
const go = () => {
|
|
108
|
+
const p = panel.current
|
|
109
|
+
if (!p) return
|
|
110
|
+
p.scrollTop += 4
|
|
111
|
+
run.current = requestAnimationFrame(go)
|
|
112
|
+
}
|
|
113
|
+
useEffect(() => stop, [])
|
|
114
|
+
return (
|
|
115
|
+
<div data-menu-more="" aria-hidden onPointerEnter={go} onPointerLeave={stop}
|
|
116
|
+
className="kol-menu-scroll--kolbox sticky -bottom-2 -mx-2 -mb-2 flex h-6 shrink-0 items-center justify-center">
|
|
117
|
+
<KolboxGlyph name="chevron-down" />
|
|
118
|
+
</div>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Flyouts: a row whose `submenu` holds groups (the same shape) opens a second Menu, on hover, a click, ArrowRight or
|
|
123
|
+
Enter; ArrowLeft in the flyout closes it and gives the keys back. A pick in a flyout runs this Menu's onSelect and
|
|
124
|
+
closes every level. The child is a panel beside this whole panel, not hung from its row; the row stays lit in the
|
|
125
|
+
accent while its child is open. A list taller than the window scrolls and ends in MenuScroll while there is more below.
|
|
126
|
+
The keys: the arrows move the lit row, Enter picks, a letter jumps to the next row that starts with it, Escape (the
|
|
127
|
+
layer's) closes. */
|
|
128
|
+
function MenuKolbox({ anchor, open, onClose, onSelect, groups = [], 'aria-label': label, placement = 'bottom-start', panelClassName = '', minWidth, nested = false, children }) {
|
|
129
|
+
const all = groups.map((g) => (Array.isArray(g) ? { rows: g } : g))
|
|
130
|
+
const rows = all.flatMap((g) => g.rows)
|
|
131
|
+
/* the lead column is kept for checks only, so a checked list lines up; a row's icon sits in its row */
|
|
132
|
+
const lead = rows.some((r) => r.check !== undefined)
|
|
133
|
+
/* no row is lit on open (the accent is the pointer's and the keys'); the chosen row (`highlighted`) is where the keys
|
|
134
|
+
start and, under `placement="over"`, the row laid on the field */
|
|
135
|
+
const chosen = rows.findIndex((r) => r.highlighted)
|
|
136
|
+
const [active, setActive] = useState(-1)
|
|
137
|
+
const [flyout, setFlyout] = useState(null)
|
|
138
|
+
useEffect(() => { if (open) setActive(-1); else setFlyout(null) }, [open])
|
|
139
|
+
|
|
140
|
+
/* focus once, when the panel mounts: a flyout takes the keys while it is open */
|
|
141
|
+
const panel = useRef(null)
|
|
142
|
+
const [more, setMore] = useState(false)
|
|
143
|
+
const measure = useCallback(() => { const p = panel.current; if (p) setMore(p.scrollHeight - p.scrollTop - p.clientHeight > 1) }, [])
|
|
144
|
+
const mount = useCallback((node) => { panel.current = node; node?.focus({ preventScroll: true }); if (node) requestAnimationFrame(measure) }, [measure])
|
|
145
|
+
const refocus = () => panel.current?.focus({ preventScroll: true })
|
|
146
|
+
/* the keys move the lit row; a long list follows it */
|
|
147
|
+
useEffect(() => { panel.current?.querySelector(`[data-menu-row="${active}"]`)?.scrollIntoView({ block: 'nearest' }) }, [active])
|
|
148
|
+
|
|
149
|
+
const pick = (row) => { onSelect?.(row); onClose?.() }
|
|
150
|
+
const show = (i) => { if (flyout !== null && flyout !== i) refocus(); setFlyout(i !== null && rows[i]?.submenu && !rows[i].disabled ? i : null) }
|
|
151
|
+
const press = (i) => (rows[i].submenu ? show(i) : pick(rows[i]))
|
|
152
|
+
const key = (e) => {
|
|
153
|
+
/* the page's own shortcuts never see a key meant for the menu; Escape goes on to the layer's listener */
|
|
154
|
+
if (e.key !== 'Escape') e.stopPropagation()
|
|
155
|
+
if (e.key === 'ArrowLeft' && nested) { e.preventDefault(); onClose?.(); return }
|
|
156
|
+
const live = rows.map((r, i) => (r.disabled ? -1 : i)).filter((i) => i >= 0)
|
|
157
|
+
if (!live.length) return
|
|
158
|
+
const at = live.indexOf(active)
|
|
159
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); show(null); setActive(at < 0 && live.includes(chosen) ? chosen : live[(at + 1) % live.length]) }
|
|
160
|
+
if (e.key === 'ArrowUp') { e.preventDefault(); show(null); setActive(live[at < 0 ? live.length - 1 : (at - 1 + live.length) % live.length]) }
|
|
161
|
+
if (e.key === 'ArrowRight' && rows[active]?.submenu) { e.preventDefault(); show(active) }
|
|
162
|
+
/* preventDefault: else the Enter's keypress lands on the trigger that takes focus back, and opens it again */
|
|
163
|
+
if (e.key === 'Enter' && rows[active] && !rows[active].disabled) { e.preventDefault(); press(active) }
|
|
164
|
+
/* a letter jumps to the next live row that starts with it */
|
|
165
|
+
if (e.key.length === 1 && /\S/.test(e.key) && !e.metaKey && !e.ctrlKey && !e.altKey && e.target.tagName !== 'INPUT') {
|
|
166
|
+
const k = e.key.toLowerCase()
|
|
167
|
+
const next = [...live.slice(at + 1), ...live.slice(0, at + 1)].find((i) => String(rows[i].label).toLowerCase().startsWith(k))
|
|
168
|
+
if (next !== undefined) { show(null); setActive(next) }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
let n = -1
|
|
173
|
+
const sub = flyout !== null ? rows[flyout] : null
|
|
174
|
+
return (
|
|
175
|
+
<>
|
|
176
|
+
<PopoverLayer anchor={anchor} open={open} onClose={onClose} placement={placement} kind="menu">
|
|
177
|
+
<div
|
|
178
|
+
role="menu"
|
|
179
|
+
aria-label={label}
|
|
180
|
+
tabIndex={-1}
|
|
181
|
+
ref={mount}
|
|
182
|
+
onKeyDown={key}
|
|
183
|
+
onScroll={measure}
|
|
184
|
+
data-kolbox-menu=""
|
|
185
|
+
style={minWidth != null ? { minWidth } : undefined}
|
|
186
|
+
className={`kol-menu--kolbox kol-kolbox-surface flex min-w-40 flex-col overflow-y-auto p-2 outline-none ${panelClassName}`}
|
|
187
|
+
>
|
|
188
|
+
{children}
|
|
189
|
+
{all.map((g, gi) => (
|
|
190
|
+
<Fragment key={gi}>
|
|
191
|
+
{gi > 0 && <div role="separator" className="kol-menu-rule--kolbox -mx-2 my-1 h-px shrink-0" />}
|
|
192
|
+
{g.title && <div className="kol-menu-heading--kolbox flex h-6 shrink-0 items-center px-2">{g.title}</div>}
|
|
193
|
+
{g.rows.map((row) => {
|
|
194
|
+
const i = ++n
|
|
195
|
+
return <MenuRowKolbox key={i} row={row} index={i} lead={lead} active={i === active || i === flyout} onEnter={() => { setActive(i); show(i) }} onPick={() => press(i)} />
|
|
196
|
+
})}
|
|
197
|
+
</Fragment>
|
|
198
|
+
))}
|
|
199
|
+
{more && <MenuScroll panel={panel} />}
|
|
200
|
+
</div>
|
|
201
|
+
</PopoverLayer>
|
|
202
|
+
{sub?.submenu && (
|
|
203
|
+
<MenuKolbox
|
|
204
|
+
key={flyout}
|
|
205
|
+
nested
|
|
206
|
+
anchor={panel.current}
|
|
207
|
+
open={open}
|
|
208
|
+
placement="beside"
|
|
209
|
+
aria-label={sub.label}
|
|
210
|
+
groups={sub.submenu}
|
|
211
|
+
onSelect={pick}
|
|
212
|
+
onClose={() => { setFlyout(null); refocus() }}
|
|
213
|
+
/>
|
|
214
|
+
)}
|
|
215
|
+
</>
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/* Menu's own rows under the kolbox look (Folio on kolbox, 2026-11-22), so a host that passes `items` switches by the
|
|
220
|
+
variant alone: `{ label, onClick, kbd, checked, disabled, icon, items }`, `{ divider: true }` (a new group) and
|
|
221
|
+
`{ heading }` (a titled group) become kolbox's groups; a row's `onClick` runs as it is picked. `anchor` may also be a
|
|
222
|
+
point `{ x, y }` (a right-click list): the list opens at it. */
|
|
223
|
+
const kolboxGroupsOf = (items) => {
|
|
224
|
+
const groups = [{ rows: [] }]
|
|
225
|
+
for (const it of items) {
|
|
226
|
+
if (it.divider || it.heading) { if (groups.at(-1).rows.length || groups.at(-1).title) groups.push({ rows: [] }); if (it.heading) groups.at(-1).title = it.heading; continue }
|
|
227
|
+
groups.at(-1).rows.push({ label: it.label, check: it.checked, shortcut: it.kbd || undefined, disabled: it.disabled, icon: typeof it.icon === 'string' ? it.icon : undefined, submenu: it.items?.length ? kolboxGroupsOf(it.items) : undefined, run: it.onClick })
|
|
228
|
+
}
|
|
229
|
+
return groups.filter((g) => g.rows.length)
|
|
230
|
+
}
|
|
231
|
+
function MenuKolboxItems({ items, anchor, onSelect, ...props }) {
|
|
232
|
+
const point = anchor != null && !('current' in anchor) && typeof anchor.getBoundingClientRect !== 'function' && anchor.x != null
|
|
233
|
+
const { x, y } = point ? anchor : {}
|
|
234
|
+
const at = useMemo(() => (point ? { getBoundingClientRect: () => ({ x, y, left: x, right: x, top: y, bottom: y, width: 0, height: 0 }) } : anchor), [point, x, y, point ? null : anchor]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
235
|
+
return <MenuKolbox {...props} anchor={at} groups={kolboxGroupsOf(items)} onSelect={(row) => { onSelect?.(row); row.run?.() }} />
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* ── the folio look (Folio migration batch B, 2026-11-22) ──
|
|
239
|
+
* Folio's menu list (apps/folio EditorChrome `Items`) carried class for class, the chrome in kol-theme `.kol-menu--folio`.
|
|
240
|
+
* The host owns the trigger, as kolbox's does; the list is drawn in place, never portalled, so it keeps the frame's
|
|
241
|
+
* `data-folio-*` switches. KOL's words: `open`, `onClose`, `items` (`{ label, onClick, kbd, checked, disabled }` or
|
|
242
|
+
* `{ divider: true }`), `aria-label`, `minWidth`, `panelClassName` (where the list sits: the host's `absolute ...`).
|
|
243
|
+
* `anchor` a point `{ x, y }`: a right-click list, fixed at the point and kept on screen, closed by any press, a scroll or
|
|
244
|
+
* the window's blur. Without one a press outside the host's wrapper (the list's parent) closes it. Escape closes either.
|
|
245
|
+
* The check column is drawn when any row says `checked`; the key column when a row says `kbd`. A row's click closes
|
|
246
|
+
* the list, then runs. */
|
|
247
|
+
function MenuFolioCheck({ checked }) {
|
|
248
|
+
return <span aria-hidden className="kol-menu-check--folio inline-flex size-[16px] shrink-0 items-center justify-center">{checked ? '✓' : ''}</span>
|
|
249
|
+
}
|
|
250
|
+
function MenuFolio({ open, onClose, items = [], anchor, 'aria-label': label, minWidth, panelClassName = '' }) {
|
|
251
|
+
const panel = useRef(null)
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
if (!open) return undefined
|
|
254
|
+
const esc = (e) => e.key === 'Escape' && onClose?.()
|
|
255
|
+
if (anchor) {
|
|
256
|
+
const shut = () => onClose?.()
|
|
257
|
+
addEventListener('mousedown', shut); addEventListener('keydown', esc); addEventListener('scroll', shut, true); addEventListener('blur', shut)
|
|
258
|
+
return () => { removeEventListener('mousedown', shut); removeEventListener('keydown', esc); removeEventListener('scroll', shut, true); removeEventListener('blur', shut) }
|
|
259
|
+
}
|
|
260
|
+
const off = (e) => { if (!panel.current?.parentElement?.contains(e.target)) onClose?.() }
|
|
261
|
+
addEventListener('mousedown', off); addEventListener('keydown', esc)
|
|
262
|
+
return () => { removeEventListener('mousedown', off); removeEventListener('keydown', esc) }
|
|
263
|
+
}, [open, onClose, anchor])
|
|
264
|
+
if (!open) return null
|
|
265
|
+
const lead = items.some((it) => it.checked !== undefined)
|
|
266
|
+
const rows = items.filter((it) => !it.divider).length, seps = items.length - rows
|
|
267
|
+
const at = anchor ? { left: Math.min(anchor.x, innerWidth - 260), top: Math.max(8, Math.min(anchor.y, innerHeight - (rows * 32 + seps * 13 + 16) - 8)) } : null
|
|
268
|
+
return (
|
|
269
|
+
<span ref={panel} role="menu" aria-label={label} style={{ ...at, ...(minWidth != null ? { minWidth } : null) }} onMouseDown={(e) => e.stopPropagation()}
|
|
270
|
+
className={`kol-menu--folio z-50 flex min-w-[240px] flex-col rounded-[4px] border py-[6px] ${anchor ? 'fixed' : ''} ${panelClassName}`}>
|
|
271
|
+
{items.map((it, i) => (it.divider ? <span key={i} className="kol-menu-rule--folio my-[6px] h-px" /> : (
|
|
272
|
+
<button key={`${it.label}${i}`} type="button" role="menuitem" disabled={it.disabled} onMouseDown={(e) => e.preventDefault()} onClick={() => { onClose?.(); it.onClick?.() }}
|
|
273
|
+
className="kol-menu-row--folio flex h-[32px] items-center gap-[16px] px-[14px] text-left">
|
|
274
|
+
{lead && <MenuFolioCheck checked={it.checked} />}{it.label}{it.kbd !== undefined && <span className="kol-menu-kbd--folio ml-auto">{it.kbd}</span>}
|
|
275
|
+
</button>
|
|
276
|
+
)))}
|
|
277
|
+
</span>
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
|
|
66
281
|
/**
|
|
67
282
|
* Menu — THE menu engine (plan-2026-10-31-menu-engine W1). Every list that floats over a trigger is this: the Menu*
|
|
68
283
|
* menus, Dropdown (a `fused` select), MultiSelect (columns), MenuItem (a menubar entry), ContextMenu (a point).
|
|
@@ -75,12 +290,20 @@ export { MenuLabel }
|
|
|
75
290
|
* `kol-tone-*` wrapper floats on that tone's surface
|
|
76
291
|
* closeOnSelect false keeps the panel open while rows toggle (a multiselect)
|
|
77
292
|
* open / onOpenChange controlled, when the caller needs the state
|
|
78
|
-
* variant 'float' — the float list; `sheet` makes it the More sheet (20 radius, 6 in)
|
|
79
293
|
* offset the gap under the trigger (default 4; a fused panel sits at -1, a point anchor at 2 — pass one to override)
|
|
294
|
+
* variant 'kolbox' (plan-2026-11-18-kolbox-system W31.2 batch 4): kolbox's menu, its own API — see `MenuKolbox` above;
|
|
295
|
+
* it also reads `items` and a point `anchor` (Folio on kolbox, 2026-11-22) — see `MenuKolboxItems`
|
|
296
|
+
* variant 'folio' (Folio migration batch B): Folio's list, drawn in place, the host's trigger — see `MenuFolio` above
|
|
80
297
|
*/
|
|
81
|
-
export function Menu({
|
|
298
|
+
export function Menu(props) {
|
|
299
|
+
if (props.variant === 'kolbox') return props.items ? <MenuKolboxItems {...props} /> : <MenuKolbox {...props} />
|
|
300
|
+
if (props.variant === 'folio') return <MenuFolio {...props} />
|
|
301
|
+
return <MenuOn {...props} />
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function MenuOn({
|
|
82
305
|
items, trigger, anchor, align = 'start', minWidth, offset, defaultOpen = false, open: openProp, onOpenChange,
|
|
83
|
-
stayOpen = false, closeOnSelect = true, fused = false, search, role = 'menu',
|
|
306
|
+
stayOpen = false, closeOnSelect = true, fused = false, search, role = 'menu',
|
|
84
307
|
panelClassName = '', panelStyle, rootClassName, className = '', children,
|
|
85
308
|
}) {
|
|
86
309
|
const [own, setOwn] = useState(defaultOpen)
|
|
@@ -114,15 +337,11 @@ export function Menu({
|
|
|
114
337
|
if (!open || !rootRef.current) return
|
|
115
338
|
const cs = getComputedStyle(rootRef.current.firstElementChild ?? rootRef.current)
|
|
116
339
|
const vars = {}
|
|
117
|
-
/* A FLOAT PANEL IS A FLOAT SURFACE (FloatMenuPanelInk, kol-website 2026-11-04): the theme's, as RailTrigger's card,
|
|
118
|
-
* the search modal and the float Dropdown (which pins `--kol-tone-panel-bg` on its trigger) — never the trigger's
|
|
119
|
-
* ground. Its rows read theme ink (fg-88, the fg-16 lift), so an inverted trigger's panel-bg painted them out. */
|
|
120
340
|
for (const v of TONE_VARS) {
|
|
121
|
-
if (variant === 'float' && v.startsWith('--kol-tone-panel')) continue
|
|
122
341
|
const val = cs.getPropertyValue(v).trim(); if (val) vars[v] = val
|
|
123
342
|
}
|
|
124
343
|
setAmbient(vars)
|
|
125
|
-
}, [open
|
|
344
|
+
}, [open])
|
|
126
345
|
|
|
127
346
|
/* the wrapper takes the ref (a Button need not forward one); the trigger takes the handlers and the aria —
|
|
128
347
|
* `aria-pressed` cleared, an open menu is `aria-expanded`, its fill is the trigger's `pressed` */
|
|
@@ -135,11 +354,11 @@ export function Menu({
|
|
|
135
354
|
)}
|
|
136
355
|
{open && (
|
|
137
356
|
<PopoverPanel popover={popover} panel={false} focus={false}
|
|
138
|
-
className={`kol-menu-panel${fused ? ' kol-menu-panel--fused' : ' w-max'} ${
|
|
357
|
+
className={`kol-menu-panel${fused ? ' kol-menu-panel--fused' : ' w-max'} ${panelClassName}`.replace(/\s+/g, ' ').trim()}
|
|
139
358
|
style={{ ...ambient, ...(minWidth ? { minWidth } : null), ...panelStyle }}>
|
|
140
359
|
{/* a row's click closes the menu (it bubbles from `[data-menu-item]`); a flyout row only toggles */}
|
|
141
360
|
<div role="none" className="flex flex-col gap-[var(--kol-spacing-0-5)] min-h-0" onClick={(e) => { if (closeOnSelect && e.target.closest('[data-menu-item]')) setOpen(false) }}>
|
|
142
|
-
<MenuList items={items} search={search}
|
|
361
|
+
<MenuList items={items} search={search}>
|
|
143
362
|
{typeof children === 'function' ? children({ close: () => setOpen(false) }) : children}
|
|
144
363
|
</MenuList>
|
|
145
364
|
</div>
|
|
@@ -209,18 +428,16 @@ export function MenuDatePicker({ groups = [], value, onChange, label, icon = 'ca
|
|
|
209
428
|
]),
|
|
210
429
|
...(compare ? [{ divider: true }, { key: 'compare', label: compare.label, kbd: compare.kbd, onClick: compare.onClick }] : []),
|
|
211
430
|
]
|
|
212
|
-
/* the float date chip (row 33): the value in mono on the well, the calendar glyph 16 */
|
|
213
431
|
return (
|
|
214
432
|
<Menu align={align} minWidth={minWidth} offset={8} items={items} variant={variant}
|
|
215
|
-
trigger={({ open, props }) => <MenuTrigger open={open} icon={icon} iconComponent={iconComponent} variant={variant}
|
|
433
|
+
trigger={({ open, props }) => <MenuTrigger open={open} icon={icon} iconComponent={iconComponent} variant={variant} {...props}>{label}</MenuTrigger>} />
|
|
216
434
|
)
|
|
217
435
|
}
|
|
218
436
|
|
|
219
|
-
/** MenuMore — the ⋮ chip and its rows (`items`, as `Menu`'s); `label` names it for a screen reader.
|
|
220
|
-
* the More sheet (row 53): the ⋮ as a float circle, the rows in a sheet on `--kol-float-menu-r`. */
|
|
437
|
+
/** MenuMore — the ⋮ chip and its rows (`items`, as `Menu`'s); `label` names it for a screen reader. */
|
|
221
438
|
export function MenuMore({ label, items = [], align = 'end', minWidth = 224, defaultOpen, stayOpen, variant }) {
|
|
222
439
|
return (
|
|
223
|
-
<Menu align={align} minWidth={minWidth} offset={8} items={items} defaultOpen={defaultOpen} stayOpen={stayOpen} variant={variant}
|
|
440
|
+
<Menu align={align} minWidth={minWidth} offset={8} items={items} defaultOpen={defaultOpen} stayOpen={stayOpen} variant={variant}
|
|
224
441
|
trigger={({ open, props }) => <MenuTrigger open={open} iconOnly aria-label={label} variant={variant} {...props} />} />
|
|
225
442
|
)
|
|
226
443
|
}
|
|
@@ -24,26 +24,20 @@ const FLOAT_ROW = 'w-full justify-start kol-btn-float'
|
|
|
24
24
|
* @param {Array} items `[{ path, label, icon? }]` — destinations, after a divider's worth of nothing
|
|
25
25
|
* @param {string} active the item path that is current
|
|
26
26
|
* @param {Function} onPick `(item | action) => void` — after the row's own press; the sheet closes here
|
|
27
|
-
* @param {'float'} variant the floating style (round 3, W16 2026-10-31): each row a `kol-btn-float` pill — 40 (48 on touch)
|
|
28
|
-
* tall, 12 in, an 18 (20) glyph, the current row oq-16 — in a `.kol-more-sheet-float`; AppFloatNav
|
|
29
|
-
* and the signed-out Home pass it. Unset, the rows are A
|
|
30
27
|
* @param {boolean} itemsFirst the destinations above the actions (PhoneNav's More, 2026-10-28: the whole nav, then the
|
|
31
28
|
* page's buttons); Home's masthead button keeps actions first
|
|
32
29
|
*/
|
|
33
|
-
export default function MenuFloatRows({ actions = [], items = [], active, onPick, itemsFirst = false
|
|
34
|
-
|
|
35
|
-
* which would outrank the components layer */
|
|
36
|
-
const float = variant === 'float'
|
|
37
|
-
const rowCls = float ? FLOAT_ROW : 'w-full justify-start h-11 gap-3'
|
|
30
|
+
export default function MenuFloatRows({ actions = [], items = [], active, onPick, itemsFirst = false }) {
|
|
31
|
+
const rowCls = 'w-full justify-start h-11 gap-3'
|
|
38
32
|
const level = useContext(Level)
|
|
39
|
-
const glyph =
|
|
33
|
+
const glyph = 22
|
|
40
34
|
const acts = (
|
|
41
35
|
<>
|
|
42
36
|
{actions.map((a) => {
|
|
43
37
|
/* a row with `sub` inside a MenuFloat opens its level instead of picking — the chevron at the row's end */
|
|
44
38
|
const nests = level && a.sub?.length > 0
|
|
45
39
|
/* the account row is the ModalHeader (menu-system W4.1) — avatar · title, pressable */
|
|
46
|
-
if (a.avatar && !nests) return <ModalHeader key={a.label}
|
|
40
|
+
if (a.avatar && !nests) return <ModalHeader key={a.label} avatar={a.avatar} title={a.label} onClick={() => { onPick?.(a); a.onPress?.() }} />
|
|
47
41
|
return (
|
|
48
42
|
/* a nesting row draws its own glyph so the label can take the room between it and the chevron; 8 apart, as Button's */
|
|
49
43
|
<Button key={a.label} variant="nav" size="lg" iconLeft={a.checked === undefined && !nests ? a.icon : undefined} iconSize={glyph} disabled={a.disabled}
|
|
@@ -51,7 +45,7 @@ export default function MenuFloatRows({ actions = [], items = [], active, onPick
|
|
|
51
45
|
aria-haspopup={nests ? 'menu' : undefined} aria-expanded={nests ? level.isOpen(a) : undefined}
|
|
52
46
|
onClick={(e) => { if (nests) { level.open(a, e.currentTarget); return } onPick?.(a); a.onPress?.() }}>
|
|
53
47
|
{a.checked !== undefined && (
|
|
54
|
-
<span className="inline-flex items-center justify-center shrink-0" style={{ width:
|
|
48
|
+
<span className="inline-flex items-center justify-center shrink-0" style={{ width: 22, height: 22 }}>{a.checked && <IconLoader name="check" size={22} />}</span>
|
|
55
49
|
)}
|
|
56
50
|
{nests ? <>{a.icon && <IconLoader name={a.icon} size={glyph} />}<span className="flex-1 text-left">{a.label}</span><IconLoader name="chevron-right" size={glyph} className="shrink-0 text-oq-48" /></> : a.label}
|
|
57
51
|
</Button>
|
|
@@ -123,7 +117,7 @@ export function MenuFloat({ beside = false, cardClass = '', onLeaf, title, title
|
|
|
123
117
|
<Level.Provider value={at(depth)}>
|
|
124
118
|
<LevelRows key={`${depth}:${rowKey(trail[depth - 1].row)}`} onKeyDown={keys(depth)}>
|
|
125
119
|
{lead}
|
|
126
|
-
<MenuFloatRows
|
|
120
|
+
<MenuFloatRows actions={rows} onPick={onLeaf} />
|
|
127
121
|
</LevelRows>
|
|
128
122
|
</Level.Provider>
|
|
129
123
|
)
|