@kolkrabbi/kol-component 0.378.0 → 0.379.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 +4 -3
- package/src/atoms/BezierPathEditor.jsx +1 -1
- package/src/atoms/Button.jsx +84 -1
- package/src/atoms/Figure.jsx +19 -1
- package/src/atoms/FunctionPlot.jsx +1 -1
- package/src/atoms/Input.jsx +105 -1
- package/src/atoms/Kbd.jsx +42 -2
- package/src/atoms/Link.jsx +20 -0
- package/src/atoms/OriginPicker.jsx +9 -5
- package/src/atoms/SectionFooter.jsx +22 -0
- package/src/atoms/SectionHeader.jsx +24 -0
- package/src/atoms/SizeOrDownload.jsx +1 -1
- package/src/atoms/Textarea.jsx +11 -2
- package/src/atoms/ToggleCheckbox.jsx +23 -1
- package/src/atoms/ToggleSwitch.jsx +39 -0
- package/src/atoms/ViewToggle.jsx +2 -2
- package/src/atoms/XYPad.jsx +25 -0
- package/src/hooks/useDragResize.js +1 -1
- package/src/index.js +26 -3
- package/src/molecules/AccountMenu.jsx +14 -1
- package/src/molecules/AlignmentGrid.jsx +13 -1
- package/src/molecules/ButtonGroup.jsx +73 -1
- package/src/molecules/ButtonSplit.jsx +64 -3
- 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 +3 -3
- package/src/molecules/DividerLabel.jsx +19 -0
- package/src/molecules/Dropdown.jsx +111 -1
- package/src/molecules/DropdownStepper.jsx +29 -0
- package/src/molecules/FieldPair.jsx +41 -2
- package/src/molecules/LabeledControl.jsx +51 -0
- package/src/molecules/Menu.jsx +239 -3
- package/src/molecules/Modal.jsx +214 -9
- package/src/molecules/ModalShell.jsx +18 -5
- package/src/molecules/OptionRow.jsx +1 -1
- package/src/molecules/ParamBindDot.jsx +29 -2
- package/src/molecules/QuantityInput.jsx +48 -0
- package/src/molecules/RailHeader.jsx +32 -2
- package/src/molecules/SectionText.jsx +54 -1
- package/src/molecules/Slider.jsx +101 -2
- 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 +35 -1
- package/src/molecules/Toast.jsx +55 -0
- package/src/molecules/TreeRow.jsx +87 -1
- 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 +396 -21
- 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 -1
- package/src/organisms/MediaLibraryPages.jsx +1 -1
- package/src/organisms/Rail.jsx +33 -1
- package/src/organisms/RailSwitcher.jsx +62 -0
- package/src/organisms/ReadingContents.jsx +63 -1
- package/src/organisms/SectionSplit.jsx +1 -1
- package/src/organisms/SettingsPanel.jsx +45 -1
- 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 +141 -2
- 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 +298 -2
- package/src/utilities/SelectionOverlay.jsx +74 -1
- package/src/utilities/kolboxGlyph.jsx +10 -0
|
@@ -42,6 +42,15 @@
|
|
|
42
42
|
* `'settings'` (plan-2026-11-12-float-rails-figma W13.1): the generator settings window's row (`Dialog
|
|
43
43
|
* variant="settings"`): the label in Inter 10 at oq-64, 6 over the control; `horizontal` puts it beside the
|
|
44
44
|
* control, 8 apart, the label hugging its text (a `labelWidth` still sets a column).
|
|
45
|
+
* `'kolbox'` (plan-2026-11-18-kolbox-system W31.2, 2026-11-18): kolbox's row carried class for class, the label
|
|
46
|
+
* Inter 12 / 16 medium in oq-64. `horizontal`: the label in a 76 column (a `labelWidth` sets another, 160 for a
|
|
47
|
+
* window's longer labels), 8 from the control, the row at least 28; stacked: the label 4 over a row of controls
|
|
48
|
+
* 4 apart. `controlFirst`: the control at the left, inset 4, then 8 apart the label in Inter 11 / 15, the row as
|
|
49
|
+
* tall as its control. Chrome in kol-theme `.kol-labeled-control--kolbox`.
|
|
50
|
+
* `'folio'` (Folio batch C, 2026-11-22): Folio's Setting carried class for class. Stacked: the label (Folio's
|
|
51
|
+
* label, 10 semibold, tracked, capitals) 8 over the control; `horizontal`: the label (12 / 16 medium) in a 48
|
|
52
|
+
* column, 12 from the control. Both labels in Folio's muted ink. Chrome in kol-theme `.kol-labeled-control--folio`.
|
|
53
|
+
* controlFirst — bool, `kolbox` only: the control before its label (kolbox's Clip content row).
|
|
45
54
|
* labelClass — the label's type and ink, replacing the variant's (a row that keeps its own label look: Slider's
|
|
46
55
|
* kol-helper-12, a toggle's words in the settings ink). On `panel` it defaults to kol-helper-8.
|
|
47
56
|
* children — the control body.
|
|
@@ -66,8 +75,50 @@ export default function LabeledControl({
|
|
|
66
75
|
labelPosition = 'bottom',
|
|
67
76
|
labelClass,
|
|
68
77
|
gap = 0,
|
|
78
|
+
controlFirst = false,
|
|
69
79
|
...rest
|
|
70
80
|
}) {
|
|
81
|
+
if (variant === 'kolbox') {
|
|
82
|
+
const mark = { 'data-labeled-control': '', ...rest }
|
|
83
|
+
if (controlFirst) {
|
|
84
|
+
return (
|
|
85
|
+
<div {...mark} className={`kol-labeled-control--kolbox flex items-center gap-2 pl-1 ${className}`.trim()}>
|
|
86
|
+
{children}
|
|
87
|
+
<span className="kol-labeled-control-help min-w-0 flex-1 truncate">{label}</span>
|
|
88
|
+
</div>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
if (!(horizontal ?? inline ?? false)) {
|
|
92
|
+
return (
|
|
93
|
+
<div {...mark} className={`kol-labeled-control--kolbox flex flex-col gap-1 ${className}`.trim()}>
|
|
94
|
+
<span className="kol-labeled-control-label">{label}</span>
|
|
95
|
+
<div className="flex min-w-0 items-center gap-1">{children}</div>
|
|
96
|
+
</div>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
return (
|
|
100
|
+
<div {...mark} className={`kol-labeled-control--kolbox flex min-h-(--kol-kolbox-ctl) items-center gap-2 ${className}`.trim()}>
|
|
101
|
+
<span className={`kol-labeled-control-label ${labelWidth == null ? 'w-19 ' : ''}shrink-0 truncate`} style={labelWidth == null ? undefined : { width: labelWidth }}>{label}</span>
|
|
102
|
+
<div className="flex min-w-0 flex-1 items-center gap-2">{children}</div>
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
if (variant === 'folio') {
|
|
107
|
+
if (horizontal ?? inline ?? false) {
|
|
108
|
+
return (
|
|
109
|
+
<div {...rest} className={`kol-labeled-control--folio flex items-center gap-[12px] ${className}`.trim()}>
|
|
110
|
+
<p className="kol-labeled-control-label w-[48px] shrink-0">{label}</p>
|
|
111
|
+
<div className="flex min-w-0 flex-1 items-center">{children}</div>
|
|
112
|
+
</div>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
return (
|
|
116
|
+
<div {...rest} className={`kol-labeled-control--folio flex flex-col gap-[8px] ${className}`.trim()}>
|
|
117
|
+
<p className="kol-labeled-control-title">{label}</p>
|
|
118
|
+
{children}
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
71
122
|
if (variant === 'panel') {
|
|
72
123
|
const isRow = labelPosition === 'left' || labelPosition === 'right'
|
|
73
124
|
const labelEl = label && (
|
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
6
|
import { MenuList, MenuLabel, panelClass } from './MenuList.jsx'
|
|
6
|
-
import { PopoverPanel, usePopover } from '../utilities/Popover.jsx'
|
|
7
|
+
import { PopoverPanel, PopoverLayer, usePopover } from '../utilities/Popover.jsx'
|
|
7
8
|
import { TONE_VARS } from '../utilities/tone.js'
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -63,6 +64,232 @@ export const MenuPanel = ({ variant, sheet = false, className = '', children, ..
|
|
|
63
64
|
|
|
64
65
|
export { MenuLabel }
|
|
65
66
|
|
|
67
|
+
|
|
68
|
+
/* ── the kolbox look (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18) ──
|
|
69
|
+
* kolbox's Menu carried line for line, the chrome in kol-theme `.kol-menu--kolbox` and its rows. Its own API, which no
|
|
70
|
+
* other look shares: an `anchor` (an element, a ref, or anything with getBoundingClientRect), controlled `open` with
|
|
71
|
+
* `onClose`, `onSelect(row)`, and `groups` `[[row, ...], { title, rows: [...] }]` with a rule between groups; a row is
|
|
72
|
+
* `{ label, value, icon, check, shortcut, tag, submenu, disabled, highlighted, inset }`; `highlighted` marks the chosen row
|
|
73
|
+
* (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
|
|
74
|
+
* same thing: `aria-label`, `minWidth`, `panelClassName` (the panel's class), `children` (a node above the rows: the
|
|
75
|
+
* 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
|
|
76
|
+
* (a Dropdown's list lying over its field). */
|
|
77
|
+
|
|
78
|
+
/* One row: a leading check or icon, the label, then a shortcut, a tag or a submenu chevron. The active row (the pointer's
|
|
79
|
+
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
|
|
80
|
+
under a resting pointer (a dropdown laid over its field) opens with no row lit.
|
|
81
|
+
`inset`: a row with no glyph held in the glyph's column. */
|
|
82
|
+
function MenuRowKolbox({ row, index, lead, active, onEnter, onPick }) {
|
|
83
|
+
const { label, icon, check, shortcut, tag, submenu, disabled, inset } = row
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
role={check === undefined ? 'menuitem' : 'menuitemcheckbox'}
|
|
87
|
+
aria-checked={check === undefined ? undefined : !!check}
|
|
88
|
+
aria-disabled={disabled || undefined}
|
|
89
|
+
aria-haspopup={submenu ? 'menu' : undefined}
|
|
90
|
+
data-menu-row={index}
|
|
91
|
+
data-active={active || undefined}
|
|
92
|
+
data-chosen={row.highlighted || undefined}
|
|
93
|
+
onPointerMove={disabled || active ? undefined : onEnter}
|
|
94
|
+
onClick={disabled ? undefined : onPick}
|
|
95
|
+
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' : ''}`}
|
|
96
|
+
>
|
|
97
|
+
{lead ? (
|
|
98
|
+
<span className="flex size-4 shrink-0 items-center justify-center">
|
|
99
|
+
{check ? <KolboxGlyph name="check" size={12} /> : icon ? <KolboxGlyph name={icon} /> : null}
|
|
100
|
+
</span>
|
|
101
|
+
) : icon ? <KolboxGlyph name={icon} /> : inset && <span className="size-4 shrink-0" />}
|
|
102
|
+
<span className="flex-1">{label}</span>
|
|
103
|
+
{shortcut && <span className={`shrink-0 ${active ? '' : 'kol-menu-sub--kolbox'}`}>{shortcut}</span>}
|
|
104
|
+
{tag && <span className={`kol-menu-tag--kolbox${active ? ' is-active' : ''} px-1`}>{tag}</span>}
|
|
105
|
+
{submenu && <KolboxGlyph name="chevron-right" className={active ? '' : 'kol-menu-sub--kolbox'} />}
|
|
106
|
+
</div>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* MenuScroll — the foot of a kolbox menu taller than the window (Menu family, W31.2 batch 4; Figma 288:8017): the full
|
|
112
|
+
* 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
|
|
113
|
+
* frame, until the end or the pointer leaves. It sits sticky on the menu's own fill so the rows pass under it.
|
|
114
|
+
* `Menu variant="kolbox"` draws it on its own; `panel` is the scrolling panel's ref.
|
|
115
|
+
*/
|
|
116
|
+
export function MenuScroll({ panel }) {
|
|
117
|
+
const run = useRef(0)
|
|
118
|
+
const stop = () => cancelAnimationFrame(run.current)
|
|
119
|
+
const go = () => {
|
|
120
|
+
const p = panel.current
|
|
121
|
+
if (!p) return
|
|
122
|
+
p.scrollTop += 4
|
|
123
|
+
run.current = requestAnimationFrame(go)
|
|
124
|
+
}
|
|
125
|
+
useEffect(() => stop, [])
|
|
126
|
+
return (
|
|
127
|
+
<div data-menu-more="" aria-hidden onPointerEnter={go} onPointerLeave={stop}
|
|
128
|
+
className="kol-menu-scroll--kolbox sticky -bottom-2 -mx-2 -mb-2 flex h-6 shrink-0 items-center justify-center">
|
|
129
|
+
<KolboxGlyph name="chevron-down" />
|
|
130
|
+
</div>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* Flyouts: a row whose `submenu` holds groups (the same shape) opens a second Menu, on hover, a click, ArrowRight or
|
|
135
|
+
Enter; ArrowLeft in the flyout closes it and gives the keys back. A pick in a flyout runs this Menu's onSelect and
|
|
136
|
+
closes every level. The child is a panel beside this whole panel, not hung from its row; the row stays lit in the
|
|
137
|
+
accent while its child is open. A list taller than the window scrolls and ends in MenuScroll while there is more below.
|
|
138
|
+
The keys: the arrows move the lit row, Enter picks, a letter jumps to the next row that starts with it, Escape (the
|
|
139
|
+
layer's) closes. */
|
|
140
|
+
function MenuKolbox({ anchor, open, onClose, onSelect, groups = [], 'aria-label': label, placement = 'bottom-start', panelClassName = '', minWidth, nested = false, children }) {
|
|
141
|
+
const all = groups.map((g) => (Array.isArray(g) ? { rows: g } : g))
|
|
142
|
+
const rows = all.flatMap((g) => g.rows)
|
|
143
|
+
/* the lead column is kept for checks only, so a checked list lines up; a row's icon sits in its row */
|
|
144
|
+
const lead = rows.some((r) => r.check !== undefined)
|
|
145
|
+
/* no row is lit on open (the accent is the pointer's and the keys'); the chosen row (`highlighted`) is where the keys
|
|
146
|
+
start and, under `placement="over"`, the row laid on the field */
|
|
147
|
+
const chosen = rows.findIndex((r) => r.highlighted)
|
|
148
|
+
const [active, setActive] = useState(-1)
|
|
149
|
+
const [flyout, setFlyout] = useState(null)
|
|
150
|
+
useEffect(() => { if (open) setActive(-1); else setFlyout(null) }, [open])
|
|
151
|
+
|
|
152
|
+
/* focus once, when the panel mounts: a flyout takes the keys while it is open */
|
|
153
|
+
const panel = useRef(null)
|
|
154
|
+
const [more, setMore] = useState(false)
|
|
155
|
+
const measure = useCallback(() => { const p = panel.current; if (p) setMore(p.scrollHeight - p.scrollTop - p.clientHeight > 1) }, [])
|
|
156
|
+
const mount = useCallback((node) => { panel.current = node; node?.focus({ preventScroll: true }); if (node) requestAnimationFrame(measure) }, [measure])
|
|
157
|
+
const refocus = () => panel.current?.focus({ preventScroll: true })
|
|
158
|
+
/* the keys move the lit row; a long list follows it */
|
|
159
|
+
useEffect(() => { panel.current?.querySelector(`[data-menu-row="${active}"]`)?.scrollIntoView({ block: 'nearest' }) }, [active])
|
|
160
|
+
|
|
161
|
+
const pick = (row) => { onSelect?.(row); onClose?.() }
|
|
162
|
+
const show = (i) => { if (flyout !== null && flyout !== i) refocus(); setFlyout(i !== null && rows[i]?.submenu && !rows[i].disabled ? i : null) }
|
|
163
|
+
const press = (i) => (rows[i].submenu ? show(i) : pick(rows[i]))
|
|
164
|
+
const key = (e) => {
|
|
165
|
+
/* the page's own shortcuts never see a key meant for the menu; Escape goes on to the layer's listener */
|
|
166
|
+
if (e.key !== 'Escape') e.stopPropagation()
|
|
167
|
+
if (e.key === 'ArrowLeft' && nested) { e.preventDefault(); onClose?.(); return }
|
|
168
|
+
const live = rows.map((r, i) => (r.disabled ? -1 : i)).filter((i) => i >= 0)
|
|
169
|
+
if (!live.length) return
|
|
170
|
+
const at = live.indexOf(active)
|
|
171
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); show(null); setActive(at < 0 && live.includes(chosen) ? chosen : live[(at + 1) % live.length]) }
|
|
172
|
+
if (e.key === 'ArrowUp') { e.preventDefault(); show(null); setActive(live[at < 0 ? live.length - 1 : (at - 1 + live.length) % live.length]) }
|
|
173
|
+
if (e.key === 'ArrowRight' && rows[active]?.submenu) { e.preventDefault(); show(active) }
|
|
174
|
+
/* preventDefault: else the Enter's keypress lands on the trigger that takes focus back, and opens it again */
|
|
175
|
+
if (e.key === 'Enter' && rows[active] && !rows[active].disabled) { e.preventDefault(); press(active) }
|
|
176
|
+
/* a letter jumps to the next live row that starts with it */
|
|
177
|
+
if (e.key.length === 1 && /\S/.test(e.key) && !e.metaKey && !e.ctrlKey && !e.altKey && e.target.tagName !== 'INPUT') {
|
|
178
|
+
const k = e.key.toLowerCase()
|
|
179
|
+
const next = [...live.slice(at + 1), ...live.slice(0, at + 1)].find((i) => String(rows[i].label).toLowerCase().startsWith(k))
|
|
180
|
+
if (next !== undefined) { show(null); setActive(next) }
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
let n = -1
|
|
185
|
+
const sub = flyout !== null ? rows[flyout] : null
|
|
186
|
+
return (
|
|
187
|
+
<>
|
|
188
|
+
<PopoverLayer anchor={anchor} open={open} onClose={onClose} placement={placement} kind="menu">
|
|
189
|
+
<div
|
|
190
|
+
role="menu"
|
|
191
|
+
aria-label={label}
|
|
192
|
+
tabIndex={-1}
|
|
193
|
+
ref={mount}
|
|
194
|
+
onKeyDown={key}
|
|
195
|
+
onScroll={measure}
|
|
196
|
+
data-kolbox-menu=""
|
|
197
|
+
style={minWidth != null ? { minWidth } : undefined}
|
|
198
|
+
className={`kol-menu--kolbox kol-kolbox-surface flex min-w-40 flex-col overflow-y-auto p-2 outline-none ${panelClassName}`}
|
|
199
|
+
>
|
|
200
|
+
{children}
|
|
201
|
+
{all.map((g, gi) => (
|
|
202
|
+
<Fragment key={gi}>
|
|
203
|
+
{gi > 0 && <div role="separator" className="kol-menu-rule--kolbox -mx-2 my-1 h-px shrink-0" />}
|
|
204
|
+
{g.title && <div className="kol-menu-heading--kolbox flex h-6 shrink-0 items-center px-2">{g.title}</div>}
|
|
205
|
+
{g.rows.map((row) => {
|
|
206
|
+
const i = ++n
|
|
207
|
+
return <MenuRowKolbox key={i} row={row} index={i} lead={lead} active={i === active || i === flyout} onEnter={() => { setActive(i); show(i) }} onPick={() => press(i)} />
|
|
208
|
+
})}
|
|
209
|
+
</Fragment>
|
|
210
|
+
))}
|
|
211
|
+
{more && <MenuScroll panel={panel} />}
|
|
212
|
+
</div>
|
|
213
|
+
</PopoverLayer>
|
|
214
|
+
{sub?.submenu && (
|
|
215
|
+
<MenuKolbox
|
|
216
|
+
key={flyout}
|
|
217
|
+
nested
|
|
218
|
+
anchor={panel.current}
|
|
219
|
+
open={open}
|
|
220
|
+
placement="beside"
|
|
221
|
+
aria-label={sub.label}
|
|
222
|
+
groups={sub.submenu}
|
|
223
|
+
onSelect={pick}
|
|
224
|
+
onClose={() => { setFlyout(null); refocus() }}
|
|
225
|
+
/>
|
|
226
|
+
)}
|
|
227
|
+
</>
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Menu's own rows under the kolbox look (Folio on kolbox, 2026-11-22), so a host that passes `items` switches by the
|
|
232
|
+
variant alone: `{ label, onClick, kbd, checked, disabled, icon, items }`, `{ divider: true }` (a new group) and
|
|
233
|
+
`{ heading }` (a titled group) become kolbox's groups; a row's `onClick` runs as it is picked. `anchor` may also be a
|
|
234
|
+
point `{ x, y }` (a right-click list): the list opens at it. */
|
|
235
|
+
const kolboxGroupsOf = (items) => {
|
|
236
|
+
const groups = [{ rows: [] }]
|
|
237
|
+
for (const it of items) {
|
|
238
|
+
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 }
|
|
239
|
+
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 })
|
|
240
|
+
}
|
|
241
|
+
return groups.filter((g) => g.rows.length)
|
|
242
|
+
}
|
|
243
|
+
function MenuKolboxItems({ items, anchor, onSelect, ...props }) {
|
|
244
|
+
const point = anchor != null && !('current' in anchor) && typeof anchor.getBoundingClientRect !== 'function' && anchor.x != null
|
|
245
|
+
const { x, y } = point ? anchor : {}
|
|
246
|
+
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
|
|
247
|
+
return <MenuKolbox {...props} anchor={at} groups={kolboxGroupsOf(items)} onSelect={(row) => { onSelect?.(row); row.run?.() }} />
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* ── the folio look (Folio migration batch B, 2026-11-22) ──
|
|
251
|
+
* Folio's menu list (apps/folio EditorChrome `Items`) carried class for class, the chrome in kol-theme `.kol-menu--folio`.
|
|
252
|
+
* The host owns the trigger, as kolbox's does; the list is drawn in place, never portalled, so it keeps the frame's
|
|
253
|
+
* `data-folio-*` switches. KOL's words: `open`, `onClose`, `items` (`{ label, onClick, kbd, checked, disabled }` or
|
|
254
|
+
* `{ divider: true }`), `aria-label`, `minWidth`, `panelClassName` (where the list sits: the host's `absolute ...`).
|
|
255
|
+
* `anchor` a point `{ x, y }`: a right-click list, fixed at the point and kept on screen, closed by any press, a scroll or
|
|
256
|
+
* the window's blur. Without one a press outside the host's wrapper (the list's parent) closes it. Escape closes either.
|
|
257
|
+
* The check column is drawn when any row says `checked`; the key column when a row says `kbd`. A row's click closes
|
|
258
|
+
* the list, then runs. */
|
|
259
|
+
function MenuFolioCheck({ checked }) {
|
|
260
|
+
return <span aria-hidden className="kol-menu-check--folio inline-flex size-[16px] shrink-0 items-center justify-center">{checked ? '✓' : ''}</span>
|
|
261
|
+
}
|
|
262
|
+
function MenuFolio({ open, onClose, items = [], anchor, 'aria-label': label, minWidth, panelClassName = '' }) {
|
|
263
|
+
const panel = useRef(null)
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
if (!open) return undefined
|
|
266
|
+
const esc = (e) => e.key === 'Escape' && onClose?.()
|
|
267
|
+
if (anchor) {
|
|
268
|
+
const shut = () => onClose?.()
|
|
269
|
+
addEventListener('mousedown', shut); addEventListener('keydown', esc); addEventListener('scroll', shut, true); addEventListener('blur', shut)
|
|
270
|
+
return () => { removeEventListener('mousedown', shut); removeEventListener('keydown', esc); removeEventListener('scroll', shut, true); removeEventListener('blur', shut) }
|
|
271
|
+
}
|
|
272
|
+
const off = (e) => { if (!panel.current?.parentElement?.contains(e.target)) onClose?.() }
|
|
273
|
+
addEventListener('mousedown', off); addEventListener('keydown', esc)
|
|
274
|
+
return () => { removeEventListener('mousedown', off); removeEventListener('keydown', esc) }
|
|
275
|
+
}, [open, onClose, anchor])
|
|
276
|
+
if (!open) return null
|
|
277
|
+
const lead = items.some((it) => it.checked !== undefined)
|
|
278
|
+
const rows = items.filter((it) => !it.divider).length, seps = items.length - rows
|
|
279
|
+
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
|
|
280
|
+
return (
|
|
281
|
+
<span ref={panel} role="menu" aria-label={label} style={{ ...at, ...(minWidth != null ? { minWidth } : null) }} onMouseDown={(e) => e.stopPropagation()}
|
|
282
|
+
className={`kol-menu--folio z-50 flex min-w-[240px] flex-col rounded-[4px] border py-[6px] ${anchor ? 'fixed' : ''} ${panelClassName}`}>
|
|
283
|
+
{items.map((it, i) => (it.divider ? <span key={i} className="kol-menu-rule--folio my-[6px] h-px" /> : (
|
|
284
|
+
<button key={`${it.label}${i}`} type="button" role="menuitem" disabled={it.disabled} onMouseDown={(e) => e.preventDefault()} onClick={() => { onClose?.(); it.onClick?.() }}
|
|
285
|
+
className="kol-menu-row--folio flex h-[32px] items-center gap-[16px] px-[14px] text-left">
|
|
286
|
+
{lead && <MenuFolioCheck checked={it.checked} />}{it.label}{it.kbd !== undefined && <span className="kol-menu-kbd--folio ml-auto">{it.kbd}</span>}
|
|
287
|
+
</button>
|
|
288
|
+
)))}
|
|
289
|
+
</span>
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
|
|
66
293
|
/**
|
|
67
294
|
* Menu — THE menu engine (plan-2026-10-31-menu-engine W1). Every list that floats over a trigger is this: the Menu*
|
|
68
295
|
* menus, Dropdown (a `fused` select), MultiSelect (columns), MenuItem (a menubar entry), ContextMenu (a point).
|
|
@@ -77,8 +304,17 @@ export { MenuLabel }
|
|
|
77
304
|
* open / onOpenChange controlled, when the caller needs the state
|
|
78
305
|
* variant 'float' — the float list; `sheet` makes it the More sheet (20 radius, 6 in)
|
|
79
306
|
* offset the gap under the trigger (default 4; a fused panel sits at -1, a point anchor at 2 — pass one to override)
|
|
307
|
+
* variant 'kolbox' (plan-2026-11-18-kolbox-system W31.2 batch 4): kolbox's menu, its own API — see `MenuKolbox` above;
|
|
308
|
+
* it also reads `items` and a point `anchor` (Folio on kolbox, 2026-11-22) — see `MenuKolboxItems`
|
|
309
|
+
* variant 'folio' (Folio migration batch B): Folio's list, drawn in place, the host's trigger — see `MenuFolio` above
|
|
80
310
|
*/
|
|
81
|
-
export function Menu({
|
|
311
|
+
export function Menu(props) {
|
|
312
|
+
if (props.variant === 'kolbox') return props.items ? <MenuKolboxItems {...props} /> : <MenuKolbox {...props} />
|
|
313
|
+
if (props.variant === 'folio') return <MenuFolio {...props} />
|
|
314
|
+
return <MenuOn {...props} />
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function MenuOn({
|
|
82
318
|
items, trigger, anchor, align = 'start', minWidth, offset, defaultOpen = false, open: openProp, onOpenChange,
|
|
83
319
|
stayOpen = false, closeOnSelect = true, fused = false, search, role = 'menu', variant, sheet = false,
|
|
84
320
|
panelClassName = '', panelStyle, rootClassName, className = '', children,
|
package/src/molecules/Modal.jsx
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react'
|
|
1
|
+
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
|
2
2
|
import { createPortal } from 'react-dom'
|
|
3
|
+
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
3
4
|
import Button from '../atoms/Button.jsx'
|
|
4
5
|
import Input from '../atoms/Input.jsx'
|
|
5
6
|
import ToggleCheckbox from '../atoms/ToggleCheckbox.jsx'
|
|
6
7
|
import ButtonGroup from './ButtonGroup.jsx'
|
|
7
8
|
import Header from './Header.jsx'
|
|
8
9
|
import ModalShell from './ModalShell.jsx'
|
|
10
|
+
import { KolboxShell, PopoverLayer } from '../utilities/Popover.jsx'
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Modal — promise-based prompt + confirm + alert dialogs.
|
|
@@ -122,7 +124,7 @@ export function ModalProvider({ children, variant = 'bordered', container }) {
|
|
|
122
124
|
return (
|
|
123
125
|
<ModalCtx.Provider value={{ prompt, confirm, alert, form }}>
|
|
124
126
|
{children}
|
|
125
|
-
{state && typeof document !== 'undefined' && createPortal(
|
|
127
|
+
{variant === 'kolbox' ? <ModalViewKolbox state={state} closeWith={closeWith} /> : state && typeof document !== 'undefined' && createPortal(
|
|
126
128
|
<ModalView state={state} closeWith={closeWith} variant={state.variant ?? variant} contained={!!container} />,
|
|
127
129
|
container ?? document.body,
|
|
128
130
|
)}
|
|
@@ -292,6 +294,84 @@ function ModalView({ state, closeWith, variant, contained }) {
|
|
|
292
294
|
)
|
|
293
295
|
}
|
|
294
296
|
|
|
297
|
+
|
|
298
|
+
/* ── the kolbox look (plan-2026-11-18-kolbox-system W31.2 batch 4, 2026-11-18) ──
|
|
299
|
+
* `ModalProvider variant="kolbox"`: every prompt, confirm and alert is kolbox's ModalPrompt or ModalConfirm, carried line
|
|
300
|
+
* for line, in `ModalDialog variant="kolbox"`. The calls are useModal's, KOL's words: `confirm(title, { okLabel,
|
|
301
|
+
* cancelLabel, body })`, `alert(title, { okLabel, body })` (the action alone), `prompt(title, defaultValue, { okLabel,
|
|
302
|
+
* cancelLabel, placeholder })`. The confirm: the title as its heading, `body` under it, the cancel (ghost) and the action
|
|
303
|
+
* (primary); Enter confirms unless a button has the focus (it answers for itself); Escape and the dim cancel. The prompt:
|
|
304
|
+
* one Input with the value selected; Enter submits. The provider draws its two dialogs in place (they portal
|
|
305
|
+
* themselves); `container` and a per-call `variant` are not read in this look. */
|
|
306
|
+
function ModalConfirmKolbox({ open, title, message, action = 'OK', cancel = 'Cancel', onConfirm, onCancel }) {
|
|
307
|
+
const ok = useRef(onConfirm); ok.current = onConfirm
|
|
308
|
+
useEffect(() => {
|
|
309
|
+
if (!open) return
|
|
310
|
+
const onKey = (e) => {
|
|
311
|
+
if (e.key !== 'Enter' || e.target?.closest?.('button')) return
|
|
312
|
+
e.preventDefault()
|
|
313
|
+
ok.current?.()
|
|
314
|
+
}
|
|
315
|
+
document.addEventListener('keydown', onKey)
|
|
316
|
+
return () => document.removeEventListener('keydown', onKey)
|
|
317
|
+
}, [open])
|
|
318
|
+
return (
|
|
319
|
+
<ModalDialogKolbox
|
|
320
|
+
open={open}
|
|
321
|
+
onClose={onCancel}
|
|
322
|
+
title={title}
|
|
323
|
+
footer={(
|
|
324
|
+
<>
|
|
325
|
+
{cancel != null && <Button variant="kolbox" tone="ghost" onClick={onCancel}>{cancel}</Button>}
|
|
326
|
+
<Button variant="kolbox" tone="primary" onClick={onConfirm} data-modal-ok>{action}</Button>
|
|
327
|
+
</>
|
|
328
|
+
)}
|
|
329
|
+
>
|
|
330
|
+
{message && <p className="kol-modal-body--kolbox px-4 pb-4" data-modal-confirm>{message}</p>}
|
|
331
|
+
</ModalDialogKolbox>
|
|
332
|
+
)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function ModalPromptKolbox({ open, title, label, value = '', placeholder, action = 'OK', cancel = 'Cancel', onSubmit, onCancel }) {
|
|
336
|
+
const [draft, setDraft] = useState(value)
|
|
337
|
+
const field = useRef(null)
|
|
338
|
+
/* after the dialog has moved the focus into its shell, the field takes it with the value selected */
|
|
339
|
+
useEffect(() => { if (open) { setDraft(value ?? ''); setTimeout(() => field.current?.select(), 0) } }, [open]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
340
|
+
return (
|
|
341
|
+
<ModalDialogKolbox
|
|
342
|
+
open={open}
|
|
343
|
+
onClose={onCancel}
|
|
344
|
+
title={title}
|
|
345
|
+
footer={(
|
|
346
|
+
<>
|
|
347
|
+
<Button variant="kolbox" tone="ghost" onClick={onCancel}>{cancel}</Button>
|
|
348
|
+
<Button variant="kolbox" tone="primary" onClick={() => onSubmit?.(draft)} data-modal-ok>{action}</Button>
|
|
349
|
+
</>
|
|
350
|
+
)}
|
|
351
|
+
>
|
|
352
|
+
<div className="px-4 pb-4" data-modal-prompt>
|
|
353
|
+
<Input variant="kolbox" ref={field} aria-label={label ?? title} placeholder={placeholder} value={draft} onChange={(e) => setDraft(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && onSubmit?.(draft)} />
|
|
354
|
+
</div>
|
|
355
|
+
</ModalDialogKolbox>
|
|
356
|
+
)
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function ModalViewKolbox({ state, closeWith }) {
|
|
360
|
+
const s = state ?? {}
|
|
361
|
+
const confirming = s.kind === 'confirm' || s.kind === 'alert'
|
|
362
|
+
const answer = (ok) => (s.options ? { ok, values: Object.fromEntries(s.options.map((o) => [o.id, !!o.defaultValue])) } : ok)
|
|
363
|
+
return (
|
|
364
|
+
<>
|
|
365
|
+
<ModalPromptKolbox open={s.kind === 'prompt'} title={s.title} value={s.defaultValue} placeholder={s.placeholder}
|
|
366
|
+
action={s.okLabel} cancel={s.cancelLabel} onSubmit={(v) => closeWith(v)} onCancel={() => closeWith(null)} />
|
|
367
|
+
<ModalConfirmKolbox open={confirming} title={s.title} message={s.body} action={s.okLabel}
|
|
368
|
+
cancel={s.kind === 'alert' ? null : s.cancelLabel}
|
|
369
|
+
onConfirm={() => closeWith(s.kind === 'alert' ? undefined : answer(true))}
|
|
370
|
+
onCancel={() => closeWith(s.kind === 'alert' ? undefined : answer(false))} />
|
|
371
|
+
</>
|
|
372
|
+
)
|
|
373
|
+
}
|
|
374
|
+
|
|
295
375
|
/* Warn once, not per call — the fallback swallowing a missing ModalProvider
|
|
296
376
|
* silently is how kol-fxr ran months on native window.confirm without
|
|
297
377
|
* noticing (ModalConfirmLabels, 2026-08-12). */
|
|
@@ -338,7 +418,8 @@ export function useModal() {
|
|
|
338
418
|
* variant="modal"` (`icon` · title · − when `onMinimise` · ×) over the children. `blocking` (default true) keeps the
|
|
339
419
|
* scrim: a blocking task dims the scene, a utility window does not (row 89) — `blocking={false}` drops the scrim and the
|
|
340
420
|
* press-outside close and leaves the scene live (QuickLookFrame float is the utility window proper).
|
|
341
|
-
* @param {'lift'|'bordered'|'float'} [variant='lift']
|
|
421
|
+
* @param {'lift'|'bordered'|'float'|'kolbox'|'folio'} [variant='lift'] `kolbox` (W31.2 batch 4): kolbox's Modal, see `ModalDialogKolbox`;
|
|
422
|
+
* `folio` (Folio migration batch B): Folio's dialog, `title`, `width` (720), `children`, see `ModalDialogFolio`
|
|
342
423
|
* @param {string} [icon] float: the header's glyph
|
|
343
424
|
* @param {Function} [onMinimise] float: the − control
|
|
344
425
|
* @param {boolean} [blocking=true]
|
|
@@ -360,9 +441,132 @@ export function useModal() {
|
|
|
360
441
|
* @param {Array} [sections] settings: `[{ key, label, state }]`
|
|
361
442
|
* @param {string} [section] · @param {Function} [onSection]
|
|
362
443
|
* @param {ReactNode} [aside] · @param {ReactNode} [footer] · @param {number} [height=656]
|
|
444
|
+
* @param {string} [sectionsLabel='Settings'] settings: the section list's title (the generator calls its list Steps, W23.3)
|
|
445
|
+
* @param {string} [movable] settings · kolbox: a key; the window drags by its header (see `useMovable`)
|
|
446
|
+
* @param {{x?: number, right?: number, y: number}} [place] kolbox: where the window opens until it is moved, in place of centred: its top at `y`, its left at `x` or its right edge at `right`; kept whole on screen
|
|
363
447
|
*/
|
|
364
|
-
|
|
448
|
+
/* `variant="kolbox"` (W31.2 batch 4): kolbox's Modal carried line for line: the kolbox panel shell (`ModalShell
|
|
449
|
+
* variant="kolbox"`) centred on the dim (fg-ab-24), 480 wide (`--kol-kolbox-modal-w`) unless `width` (any CSS length)
|
|
450
|
+
* says otherwise. Escape (the last layer's) and a click on the dim close it. `blocking={false}`: a window over a live
|
|
451
|
+
* scene, no dim; a press, scroll or pinch outside it reaches what is under it and never closes it. Focus moves into the dialog on open and back
|
|
452
|
+
* to whatever held it on close. The shell's `title`, `leading`, `actions`, `footer` and `aria-label` pass through;
|
|
453
|
+
* `className` reaches the dialog beside its own. */
|
|
454
|
+
/* A WINDOW THAT MOVES (plan-2026-11-18-kolbox-system W23.1, 2026-11-18; his "still cant grab this modal to move it out
|
|
455
|
+
* of the way"): `movable` (a key, e.g. "generator") lets a press on the window's header, outside its controls, drag it.
|
|
456
|
+
* It can be moved out of the way, never lost: its header stays on screen top to bottom, its left edge (the title,
|
|
457
|
+
* where it is grabbed) stays on screen, and it may hang off the right edge until 160 px of it are left, so it can
|
|
458
|
+
* always be grabbed back. Once moved it is fixed at its own left and top, so a
|
|
459
|
+
* change of content never re-centres it, and its place is kept per key while the app is open. Only the kolbox and
|
|
460
|
+
* settings variants take it; unset, nothing changes. */
|
|
461
|
+
const SPOTS = new Map()
|
|
462
|
+
const NO_DRAG = 'button, input, select, textarea, a, [role="button"], [role="combobox"], [role="tab"], [role="switch"], [contenteditable="true"], [data-no-drag]'
|
|
463
|
+
const KEEP = 160
|
|
464
|
+
function useMovable(key, ref, place) {
|
|
465
|
+
const [at, setAt] = useState(() => (key ? SPOTS.get(key) ?? null : null))
|
|
466
|
+
/* `place` (kolbox): where the window opens until it is moved, kept whole on screen (8 from each edge) */
|
|
467
|
+
const [placed, setPlaced] = useState(null)
|
|
468
|
+
useLayoutEffect(() => {
|
|
469
|
+
const el = ref.current
|
|
470
|
+
if (!place || at || !el) return
|
|
471
|
+
const m = 8
|
|
472
|
+
const x = place.x ?? place.right - el.offsetWidth
|
|
473
|
+
setPlaced({ x: Math.max(m, Math.min(x, window.innerWidth - el.offsetWidth - m)), y: Math.max(m, Math.min(place.y, window.innerHeight - el.offsetHeight - m)) })
|
|
474
|
+
}, [place?.x, place?.right, place?.y]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
475
|
+
const moved = useRef(false)
|
|
476
|
+
const fit = (x, y, w) => {
|
|
477
|
+
const hh = ref.current?.firstElementChild?.offsetHeight ?? 0
|
|
478
|
+
return { x: Math.max(0, Math.min(x, window.innerWidth - KEEP)), y: Math.max(0, Math.min(y, window.innerHeight - hh)) }
|
|
479
|
+
}
|
|
480
|
+
useEffect(() => { if (key && at) SPOTS.set(key, at) }, [key, at])
|
|
481
|
+
useEffect(() => {
|
|
482
|
+
if (!key) return undefined
|
|
483
|
+
const onResize = () => setAt((a) => { const el = ref.current; return a && el ? fit(a.x, a.y, el.offsetWidth) : a })
|
|
484
|
+
window.addEventListener('resize', onResize)
|
|
485
|
+
return () => window.removeEventListener('resize', onResize)
|
|
486
|
+
}, [key]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
487
|
+
const onPointerDown = (e) => {
|
|
488
|
+
const el = ref.current, head = el?.firstElementChild
|
|
489
|
+
if (!key || e.button !== 0 || !head?.contains(e.target) || e.target.closest(NO_DRAG)) return
|
|
490
|
+
e.preventDefault()
|
|
491
|
+
const r = el.getBoundingClientRect(), sx = e.clientX, sy = e.clientY
|
|
492
|
+
const move = (ev) => {
|
|
493
|
+
const p = fit(r.left + ev.clientX - sx, r.top + ev.clientY - sy, r.width)
|
|
494
|
+
if (p.x !== r.left || p.y !== r.top) moved.current = true
|
|
495
|
+
setAt(p)
|
|
496
|
+
}
|
|
497
|
+
const up = () => {
|
|
498
|
+
window.removeEventListener('pointermove', move)
|
|
499
|
+
window.removeEventListener('pointerup', up)
|
|
500
|
+
window.removeEventListener('pointercancel', up)
|
|
501
|
+
/* the click a drag's release raises on the dim is not a press outside */
|
|
502
|
+
setTimeout(() => { moved.current = false })
|
|
503
|
+
}
|
|
504
|
+
window.addEventListener('pointermove', move)
|
|
505
|
+
window.addEventListener('pointerup', up)
|
|
506
|
+
window.addEventListener('pointercancel', up)
|
|
507
|
+
}
|
|
508
|
+
const spot = at ?? placed
|
|
509
|
+
return {
|
|
510
|
+
style: spot ? { position: 'fixed', left: spot.x, top: spot.y, margin: 0 } : null,
|
|
511
|
+
onPointerDown: key ? onPointerDown : undefined,
|
|
512
|
+
handle: key ? '[&>header]:cursor-grab [&>header]:active:cursor-grabbing' : '',
|
|
513
|
+
dragged: () => moved.current,
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function ModalDialogKolbox({ open, onClose, width = 'var(--kol-kolbox-modal-w)', className = '', variant, movable, blocking = true, place, ...shell }) {
|
|
518
|
+
const ref = useRef(null)
|
|
519
|
+
const mv = useMovable(movable, ref, place)
|
|
520
|
+
useEffect(() => {
|
|
521
|
+
if (!open) return
|
|
522
|
+
const back = document.activeElement
|
|
523
|
+
ref.current?.focus({ preventScroll: true })
|
|
524
|
+
return () => back?.focus?.({ preventScroll: true })
|
|
525
|
+
}, [open])
|
|
526
|
+
const close = () => { if (!mv.dragged()) onClose?.() }
|
|
527
|
+
return (
|
|
528
|
+
<PopoverLayer open={open} onClose={close} placement="center" kind="modal" blocking={blocking}>
|
|
529
|
+
<KolboxShell ref={ref} tabIndex={-1} aria-modal={blocking ? 'true' : undefined} onClose={onClose} width={width} className={`outline-none ${mv.handle} ${className}`}
|
|
530
|
+
{...shell} style={mv.style ? { width, ...mv.style } : { width }} onPointerDown={mv.onPointerDown} />
|
|
531
|
+
</PopoverLayer>
|
|
532
|
+
)
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/* `variant="folio"` (Folio migration batch B, 2026-11-22): Folio's New overlay carried class for class (kol-theme
|
|
536
|
+
* `.kol-modal-dialog--folio`): `ModalShell variant="folio"` 14% down on the Folio dim, `width` wide (720) and never wider
|
|
537
|
+
* than the window, a 64 header (the title, the 32 ×) over a rule, then `children`. Drawn in place, never portalled, so
|
|
538
|
+
* it keeps the frame's `data-folio-*`. Escape and a press on the dim close it. */
|
|
539
|
+
function ModalDialogFolio({ open, onClose, title, width = 720, children }) {
|
|
540
|
+
useEffect(() => {
|
|
541
|
+
if (!open) return undefined
|
|
542
|
+
const esc = (e) => e.key === 'Escape' && onClose?.()
|
|
543
|
+
addEventListener('keydown', esc)
|
|
544
|
+
return () => removeEventListener('keydown', esc)
|
|
545
|
+
}, [open, onClose])
|
|
546
|
+
if (!open) return null
|
|
547
|
+
return (
|
|
548
|
+
<div className="kol-modal-dim--folio fixed inset-0 z-50 flex items-start justify-center px-[16px] pt-[14vh]" onMouseDown={onClose}>
|
|
549
|
+
<ModalShell variant="folio" role="dialog" aria-label={title} onMouseDown={(e) => e.stopPropagation()} className="kol-modal-dialog--folio max-w-full" style={{ width }}>
|
|
550
|
+
<div className="kol-modal-head--folio flex h-[64px] items-center justify-between border-b pl-[24px] pr-[16px]">
|
|
551
|
+
<p className="kol-modal-title--folio">{title}</p>
|
|
552
|
+
<button type="button" aria-label="Close" onClick={onClose} className="kol-modal-close--folio flex size-[32px] items-center justify-center rounded-[3px]"><IconLoader name="x" size={14} /></button>
|
|
553
|
+
</div>
|
|
554
|
+
{children}
|
|
555
|
+
</ModalShell>
|
|
556
|
+
</div>
|
|
557
|
+
)
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export function ModalDialog(props) {
|
|
561
|
+
if (props.variant === 'kolbox') return <ModalDialogKolbox {...props} />
|
|
562
|
+
if (props.variant === 'folio') return <ModalDialogFolio {...props} />
|
|
563
|
+
return <ModalDialogOn {...props} />
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function ModalDialogOn({ open, onClose, title, width, variant = 'lift', icon, onMinimise, blocking = true, container, kind, headerEnd, sections, section, onSection, aside, footer, height = 656, movable, sectionsLabel = 'Settings', children }) {
|
|
365
567
|
const look = variant === 'settings' ? 'settings' : modalVariant(variant, 'lift')
|
|
568
|
+
const shellRef = useRef(null)
|
|
569
|
+
const mv = useMovable(variant === 'settings' && !container ? movable : undefined, shellRef)
|
|
366
570
|
const float = look === 'float'
|
|
367
571
|
useEffect(() => {
|
|
368
572
|
if (!open) return undefined
|
|
@@ -377,15 +581,16 @@ export function ModalDialog({ open, onClose, title, width, variant = 'lift', ico
|
|
|
377
581
|
return createPortal(
|
|
378
582
|
<div onMouseDown={blocking ? onClose : undefined} className={blocking ? 'kol-overlay-scrim' : 'pointer-events-none'}
|
|
379
583
|
style={{ position: container ? 'absolute' : 'fixed', inset: 0, zIndex: 150, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
380
|
-
<ModalShell variant="settings" role="dialog" aria-modal={blocking ? 'true' : undefined} aria-label={title} data-dialog onMouseDown={(e) => e.stopPropagation()}
|
|
381
|
-
|
|
382
|
-
|
|
584
|
+
<ModalShell ref={shellRef} variant="settings" role="dialog" aria-modal={blocking ? 'true' : undefined} aria-label={title} data-dialog onMouseDown={(e) => e.stopPropagation()}
|
|
585
|
+
onPointerDown={mv.onPointerDown}
|
|
586
|
+
className={`kol-settings-window pointer-events-auto overflow-hidden ${mv.handle}`.trim()}
|
|
587
|
+
style={{ width: `min(${width ?? 880}px, calc(${within} - 32px))`, height: `min(${height}px, calc(${withinH} - 32px))`, ...mv.style }}
|
|
383
588
|
header={<Header variant="settings" title={title} kind={kind} end={headerEnd} onClose={onClose} />}
|
|
384
589
|
footer={footer && <footer className="flex items-center gap-3 h-[60px] shrink-0 px-6 border-t border-oq-16">{footer}</footer>}>
|
|
385
590
|
<div className="flex flex-1 min-h-0">
|
|
386
591
|
{sections?.length > 0 && (
|
|
387
|
-
<nav aria-label=
|
|
388
|
-
<p className="pl-[10px] pb-[14px] text-[9px] font-medium leading-[11px] uppercase text-oq-64">
|
|
592
|
+
<nav aria-label={sectionsLabel} className="w-[156px] shrink-0 overflow-y-auto bg-surface-primary border-r border-oq-16 px-2 pt-[21px] pb-4">
|
|
593
|
+
<p className="pl-[10px] pb-[14px] text-[9px] font-medium leading-[11px] uppercase text-oq-64">{sectionsLabel}</p>
|
|
389
594
|
<div role="tablist" aria-orientation="vertical" className="flex flex-col gap-1.5"
|
|
390
595
|
onKeyDown={(e) => {
|
|
391
596
|
const dir = { ArrowDown: 1, ArrowUp: -1 }[e.key]
|