@kolkrabbi/kol-component 0.387.0 → 0.389.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/molecules/AccountMenu.jsx +11 -6
- package/src/molecules/AlignmentGrid.jsx +5 -5
- package/src/molecules/ButtonGroup.jsx +30 -48
- package/src/molecules/ButtonSplit.jsx +66 -66
- package/src/molecules/ContextMenu.jsx +1 -1
- package/src/molecules/Dropdown.jsx +24 -56
- package/src/molecules/Menu.jsx +190 -255
- package/src/molecules/MenuItem.jsx +45 -12
- package/src/molecules/MenuList.jsx +48 -17
- package/src/molecules/ParamBindDot.jsx +8 -24
- package/src/molecules/TabsDocument.jsx +42 -66
- package/src/molecules/TabsRow.jsx +19 -12
- package/src/organisms/FindBar.jsx +18 -32
- package/src/utilities/Popover.jsx +8 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -192,7 +192,7 @@ export { default as ContentRow } from './molecules/ContentRow.jsx'
|
|
|
192
192
|
export { default as ContentItem } from './molecules/ContentItem.jsx'
|
|
193
193
|
export { default as ContentCollection } from './organisms/ContentCollection.jsx'
|
|
194
194
|
export { MenuItem, MenuRow, MenuDivider, MenuFlyout, MenuDropdownItem, MenuDropdownDivider, MenuDropdownNest } from './molecules/MenuItem.jsx'
|
|
195
|
-
export { Menu, MenuTrigger, MenuPanel, MenuLabel, MenuFilter, MenuDatePicker, MenuMore, MenuScroll } from './molecules/Menu.jsx'
|
|
195
|
+
export { Menu, MenuTrigger, MenuPanel, MenuLabel, MenuFilter, MenuDatePicker, MenuMore, MenuScroll, MenuKolbox, MenuFolio } from './molecules/Menu.jsx'
|
|
196
196
|
export { MenuList } from './molecules/MenuList.jsx'
|
|
197
197
|
export { ModalProvider, useModal, ModalDialog, ModalDialog as Dialog } from './molecules/Modal.jsx'
|
|
198
198
|
export { default as ModalShell } from './molecules/ModalShell.jsx'
|
|
@@ -16,16 +16,21 @@ import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
|
16
16
|
* @param {'start'|'end'} [align] default `end`
|
|
17
17
|
* @param {'sm'|'md'|'lg'} [size] the circle (default md)
|
|
18
18
|
* @param {string} [className]
|
|
19
|
-
* @param {
|
|
20
|
-
* trigger only: the xs Avatar (20) on
|
|
21
|
-
* (
|
|
19
|
+
* @param {boolean} [compact] the chip (kolbox's AccountChip, W31.2 batch 4, 2026-11-18; a plain prop since
|
|
20
|
+
* plan-2026-11-29-one-set-fold W3 run 2), the trigger only: the xs Avatar (20) on the chip's fill then the 12 chevron in
|
|
21
|
+
* oq-64, 4 apart, the accent's focus line. No menu (its host has none to open); `items` and `align` are not read. Other
|
|
22
|
+
* props land on the button. Chrome in kol-theme `.kol-account-chip`, the fill `--kol-account-chip-fill` (kolbox the field)
|
|
23
|
+
* @param {'kolbox'|'folio'} [variant] accepted (on the retirement ledger): `kolbox` draws `compact`
|
|
22
24
|
*/
|
|
23
|
-
|
|
25
|
+
/* the old theme word: `kolbox` draws the chip (W3 run 2, on the retirement ledger) */
|
|
26
|
+
const THEME_WORDS = ['kolbox']
|
|
27
|
+
|
|
28
|
+
export default function AccountMenu({ initial, src, name = 'Account', items = [], align = 'end', size = 'md', className = '', variant, compact, accent, ...rest }) {
|
|
24
29
|
if (accent === 'secondary') rest['data-accent'] = accent
|
|
25
|
-
if (
|
|
30
|
+
if (compact ?? THEME_WORDS.includes(variant)) {
|
|
26
31
|
return (
|
|
27
32
|
<button type="button" aria-label={name} aria-haspopup="menu" data-account-chip
|
|
28
|
-
className={`kol-account-chip
|
|
33
|
+
className={`kol-account-chip inline-flex shrink-0 items-center gap-1 rounded-full outline-none focus-visible:outline-solid focus-visible:outline-1 focus-visible:outline-offset-1 ${className}`.trim()} {...rest}>
|
|
29
34
|
<Avatar initial={initial} src={src} size="xs" />
|
|
30
35
|
<KolboxGlyph name="chevron-down" size={12} className="kol-account-chip-caret" />
|
|
31
36
|
</button>
|
|
@@ -27,8 +27,8 @@ import { glyphSize } from '../hooks/glyphLadders.js'
|
|
|
27
27
|
* @param {'stacked'|'strips'} [layout='stacked'] - `stacked`: the X strip over the Y strip. `strips` (kolbox's align row,
|
|
28
28
|
* plan-2026-11-18-kolbox-system W31.2 batch 3; a layout of its own since plan-2026-11-29-one-set-fold W2 run 4): the X
|
|
29
29
|
* and Y strips side by side, each filling its cell of a slot `FieldPair` (two cells 8 apart), each cell its own action;
|
|
30
|
-
* `items` carry the set's glyph names. The strips are ButtonGroup's icon group
|
|
31
|
-
*
|
|
30
|
+
* `items` carry the set's glyph names. The strips are ButtonGroup's icon group (`variant="icons"`, W3 run 2).
|
|
31
|
+
* `variant="kolbox"` and `"folio"` are accepted and draw `strips`; the old branch is in
|
|
32
32
|
* `_tmp/2026-11-29-one-set-fold/AlignmentGrid.pre-fields3.jsx`.
|
|
33
33
|
*/
|
|
34
34
|
const THEME_WORDS = ['kolbox', 'folio']
|
|
@@ -44,11 +44,11 @@ const ALIGN_BUTTONS = [
|
|
|
44
44
|
export default function AlignmentGrid({ onAlign, items = ALIGN_BUTTONS, size = 'sm', className = '', layout: layoutProp, variant }) {
|
|
45
45
|
const strip = (axis) => items.filter((b) => b.axis === axis)
|
|
46
46
|
const layout = layoutProp ?? (THEME_WORDS.includes(variant) ? 'strips' : 'stacked')
|
|
47
|
-
/* layout="strips" (kolbox's AlignmentRow carried): the two strips as icon groups, each filling its cell of
|
|
48
|
-
* FieldPair (two cells 8 apart)
|
|
47
|
+
/* layout="strips" (kolbox's AlignmentRow carried): the two strips as ButtonGroup's icon groups, each filling its cell of
|
|
48
|
+
* a slot FieldPair (two cells 8 apart) */
|
|
49
49
|
if (layout === 'strips') {
|
|
50
50
|
const group = (axis) => (
|
|
51
|
-
<ButtonGroup layout="joined" variant="
|
|
51
|
+
<ButtonGroup layout="joined" variant="icons" className="w-full"
|
|
52
52
|
options={strip(axis).map((b) => ({ icon: b.icon, ariaLabel: b.title, onPress: () => onAlign?.(b.axis, b.mode) }))} />
|
|
53
53
|
)
|
|
54
54
|
return <FieldPair className={className} first={group('h')} second={group('v')} />
|
|
@@ -87,12 +87,13 @@
|
|
|
87
87
|
* `kol-tone-sunken` wrapper reaches it too. Unset = inherit.
|
|
88
88
|
* ariaLabel — accessible name for the group
|
|
89
89
|
* className — additional classes on the outer shell
|
|
90
|
-
* variant="
|
|
91
|
-
* own action; `tone` unset (cells) or `sunken`
|
|
92
|
-
*
|
|
93
|
-
* variant="
|
|
94
|
-
* `[{ value, label }]`, the picked cell lit
|
|
95
|
-
*
|
|
90
|
+
* variant="icons" — the icon group (kolbox's IconGroup, a plain variant since plan-2026-11-29-one-set-fold W3 run 2):
|
|
91
|
+
* `options` `[{ icon, ariaLabel, pressed, onPress }]`, each its own action; `tone` unset (cells) or `sunken`
|
|
92
|
+
* (the track). Chrome in kol-theme `.kol-btn-group--icons`, its look `--kol-btn-group-*`
|
|
93
|
+
* variant="track" — a choice that stays, drawn on the tab track (TabsRow `variant="track"`'s sm track and cells):
|
|
94
|
+
* `options` `[{ value, label, disabled? }]`, the picked cell lit and aria-pressed, `ariaLabel` names it
|
|
95
|
+
* variant="kolbox" | "folio" — accepted (on the retirement ledger): without `value` they draw `icons`, with one `track`.
|
|
96
|
+
* Folio's own segmented row and frameless tool row went to `_tmp/2026-11-29-one-set-fold/ButtonGroup.pre-w3b.jsx`
|
|
96
97
|
*/
|
|
97
98
|
import { toneClass } from '../utilities/tone.js'
|
|
98
99
|
import { Tooltip } from '../utilities/Popover.jsx'
|
|
@@ -142,53 +143,31 @@ export default function ButtonGroup({ layout = 'row', align = 'center', title, c
|
|
|
142
143
|
)
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
/* layout="joined" variant="
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
function
|
|
146
|
+
/* layout="joined" variant="icons" (kolbox's IconGroup, W31.2 batch 3, 2026-11-18; a plain variant since plan-2026-11-29-one-set-fold
|
|
147
|
+
* W3 run 2). Each option is its own action, an icon Button (`{ icon, ariaLabel, pressed, onPress }`): no `value`, every
|
|
148
|
+
* option lights by its own `pressed`. Unset tone: each glyph in its own cell on the group's fill, 1px apart so the ground
|
|
149
|
+
* shows between them, radius 4 on the group's outer corners only. `tone="sunken"`: square cells the group's height side
|
|
150
|
+
* by side on the fill, the pressed cell (aria-pressed only) the ground inside the group's line, the others bare. Chrome
|
|
151
|
+
* in kol-theme `.kol-btn-group--icons`, its look `--kol-btn-group-*` (kolbox: the field fill, the one edge, the control
|
|
152
|
+
* height). */
|
|
153
|
+
function JoinedIcons({ options, tone, className }) {
|
|
153
154
|
const sunken = tone === 'sunken'
|
|
154
155
|
return (
|
|
155
|
-
<div className={`kol-btn-group--
|
|
156
|
+
<div className={`kol-btn-group--icons${sunken ? ' kol-btn-group--icons-sunken' : ' gap-px overflow-hidden'} inline-flex shrink-0 ${className}`}>
|
|
156
157
|
{options.map(({ icon, ariaLabel, pressed, onPress }) => (sunken
|
|
157
|
-
? <Button key={ariaLabel}
|
|
158
|
-
: <Button key={ariaLabel}
|
|
158
|
+
? <Button key={ariaLabel} iconOnly={icon} aria-label={ariaLabel} aria-pressed={!!pressed} onClick={onPress} className="aspect-square h-full! w-auto!" />
|
|
159
|
+
: <Button key={ariaLabel} iconOnly={icon} aria-label={ariaLabel} pressed={pressed} onClick={onPress} className="flex-1 rounded-none" />))}
|
|
159
160
|
</div>
|
|
160
161
|
)
|
|
161
162
|
}
|
|
162
163
|
|
|
163
|
-
/* layout="joined" variant="
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
|
|
168
|
-
* `.kol-btn-group--folio`. */
|
|
169
|
-
function JoinedFolio({ value, onChange, options, ariaLabel, className }) {
|
|
170
|
-
if (value == null) {
|
|
171
|
-
return (
|
|
172
|
-
<span role="group" aria-label={ariaLabel} className={`flex shrink-0 items-center ${className}`.trim()}>
|
|
173
|
-
{options.map(({ icon, ariaLabel: name, pressed, onPress }) => <Button key={name} variant="folio" keepFocus iconOnly={icon} aria-label={name} pressed={pressed} onClick={onPress} />)}
|
|
174
|
-
</span>
|
|
175
|
-
)
|
|
176
|
-
}
|
|
177
|
-
return (
|
|
178
|
-
<div role="group" aria-label={ariaLabel} className={`kol-btn-group--folio flex h-[32px] overflow-hidden rounded-[4px] border ${className}`.trim()}>
|
|
179
|
-
{options.map((opt) => (
|
|
180
|
-
<button key={opt.value} type="button" aria-pressed={value === opt.value} onClick={() => onChange?.(opt.value)} className="kol-btn-group-cell flex-1 whitespace-nowrap px-[16px]">{opt.label}</button>
|
|
181
|
-
))}
|
|
182
|
-
</div>
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
/* layout="joined" variant="kolbox" with a `value` (Folio on kolbox, 2026-11-22): kolbox's choice that stays (Off and On,
|
|
186
|
-
* Miter, Round and Bevel) is its tab track, so this draws TabsRow kolbox sm's track and cells (its chrome,
|
|
187
|
-
* `.kol-tabs--kolbox-sm`, kol-components-molecules.css) as a group: `options` `[{ value, label }]`, the picked cell lit and
|
|
188
|
-
* aria-pressed, `ariaLabel` names it. */
|
|
189
|
-
function JoinedKolboxChoice({ value, onChange, options, ariaLabel, className }) {
|
|
164
|
+
/* layout="joined" variant="track" (Folio on kolbox, 2026-11-22; a plain variant since W3 run 2): a choice that stays (Off
|
|
165
|
+
* and On, Miter, Round and Bevel) on the tab track, TabsRow `variant="track"` sm's track and cells (`.kol-tabs-track`,
|
|
166
|
+
* kol-components-molecules.css) as a group: `options` `[{ value, label }]`, the picked cell lit and aria-pressed,
|
|
167
|
+
* `ariaLabel` names it. `kol-tabs--kolbox-sm` stays on the box as a hook for kol-fxr's touch height (retirement ledger). */
|
|
168
|
+
function JoinedTrack({ value, onChange, options, ariaLabel, className }) {
|
|
190
169
|
return (
|
|
191
|
-
<div role="group" aria-label={ariaLabel} className={`kol-tabs--
|
|
170
|
+
<div role="group" aria-label={ariaLabel} className={`kol-tabs-track kol-tabs-track--sm kol-tabs--kolbox-sm inline-flex items-center gap-px p-0.5 ${className}`.trim()}>
|
|
192
171
|
{options.map((opt) => (
|
|
193
172
|
<button key={opt.value} type="button" aria-pressed={opt.value === value} disabled={opt.disabled} onClick={() => onChange?.(opt.value)}
|
|
194
173
|
className={`kol-tabs-tab${opt.value === value ? ' is-active' : ''} flex h-full min-w-0 flex-1 items-center justify-center px-3 whitespace-nowrap outline-none focus-visible:outline-solid focus-visible:outline-1 disabled:opacity-40`}>{opt.label}</button>
|
|
@@ -197,11 +176,14 @@ function JoinedKolboxChoice({ value, onChange, options, ariaLabel, className })
|
|
|
197
176
|
)
|
|
198
177
|
}
|
|
199
178
|
|
|
179
|
+
/* the old theme words: accepted, `icons` without a value, `track` with one (W3 run 2, on the retirement ledger) */
|
|
180
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
200
181
|
|
|
201
182
|
/* layout="joined" — the segmented control (SegmentedToggle's implementation, moved here 2026-11-06) */
|
|
202
|
-
function Joined({ value, onChange, options = [], variant = 'default', size = 'md', tone = 'default', ariaLabel, className = '' }) {
|
|
203
|
-
|
|
204
|
-
if (variant === '
|
|
183
|
+
function Joined({ value, onChange, options = [], variant: variantProp = 'default', size = 'md', tone = 'default', ariaLabel, className = '' }) {
|
|
184
|
+
const variant = THEME_WORDS.includes(variantProp) ? (value == null ? 'icons' : 'track') : variantProp
|
|
185
|
+
if (variant === 'icons') return <JoinedIcons options={options} tone={tone} className={className} />
|
|
186
|
+
if (variant === 'track') return <JoinedTrack value={value} onChange={onChange} options={options} ariaLabel={ariaLabel} className={className} />
|
|
205
187
|
const cellType = { xs: 'kol-mono-8', sm: 'kol-mono-12', md: 'kol-mono-14', lg: 'kol-mono-16' }[size]
|
|
206
188
|
const stateless = value == null
|
|
207
189
|
const focusIdx = Math.max(0, options.findIndex((opt) => opt.value === value))
|
|
@@ -3,7 +3,6 @@ import Button from '../atoms/Button.jsx'
|
|
|
3
3
|
import { IconLoader } from '@kolkrabbi/kol-icons'
|
|
4
4
|
import { PopoverPanel, Tooltip, usePopover } from '../utilities/Popover.jsx'
|
|
5
5
|
import KolboxGlyph from '../utilities/kolboxGlyph.jsx'
|
|
6
|
-
import { Menu } from './Menu.jsx'
|
|
7
6
|
|
|
8
7
|
/* taxonomy-ok: molecule — two Buttons (atoms) and a divider, the ⌄ opening a PopoverPanel (utility) of rows */
|
|
9
8
|
|
|
@@ -18,94 +17,95 @@ import { Menu } from './Menu.jsx'
|
|
|
18
17
|
* @param {Function} onClick the main action
|
|
19
18
|
* @param {Array} [items] `[{ label, icon?, onPress, disabled? }]` — the menu's rows
|
|
20
19
|
* @param {Function} [menu] `(close) => ReactNode` — the menu's content instead of `items`
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
20
|
+
* ONE SPLIT, THREE SHAPES (plan-2026-11-29-one-set-fold W3 run 2), picked by what the caller passes, never by a theme:
|
|
21
|
+
* - the menu its own (the default): `items` (or `menu`) open under the ⌄ in a PopoverPanel at `placement`
|
|
22
|
+
* (`bottom-end`, the list's right edge under the split's right edge)
|
|
23
|
+
* - `onMenu` (kolbox's SplitButton): the host opens its own menu, the ⌄'s press is `onMenu`; the action and a narrow ⌄
|
|
24
|
+
* are two Buttons of one tone 1px apart, square where they meet, the hovered half the fg-04 hover over its fill, the
|
|
25
|
+
* ghost tone filling both halves on hover or `is-open` (kol-theme `.kol-btn-split--narrow`, its fill
|
|
26
|
+
* `--kol-btn-split-fill`)
|
|
27
|
+
* - `iconOnly` (a glyph name, the tool dock's slot): a 32 tile and a 16 by 32 ⌄, 1 apart; `pressed` the armed look,
|
|
28
|
+
* `tooltip` the main half's tooltip label, `aria-label` the main half's name, `menuOpen` the ⌄'s menu is open (its
|
|
29
|
+
* quiet fill); the ⌄ is `onMenu`, else it opens `items` as above (`.kol-btn-split--icon`)
|
|
30
|
+
* @param {Function} [onMenu] the ⌄'s press when the host opens its menu
|
|
31
|
+
* @param {'kolbox'|'folio'} [variant] accepted (on the retirement ledger): `kolbox` draws the `onMenu` shape, `folio` the
|
|
32
|
+
* default. Folio's own split (its line, its green) is in `_tmp/2026-11-29-one-set-fold/`
|
|
27
33
|
* @param {string} [tone] · {'xs'|'sm'|'md'|'lg'} [size='md']
|
|
28
34
|
* @param {boolean} [disabled] the main action off; the menu still opens
|
|
29
35
|
* @param {string} [menuLabel='More actions'] the ⌄'s aria-label
|
|
30
36
|
* @param {string} [placement='bottom-end'] · {string} [className]
|
|
31
37
|
* @param {'primary'|'secondary'} [accent='primary'] the theme's accent the split draws (data-accent, kol-color.css)
|
|
32
38
|
*/
|
|
33
|
-
|
|
39
|
+
/* the old theme words: `kolbox` the host-menu shape, `folio` the default (W3 run 2, on the retirement ledger) */
|
|
40
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
41
|
+
|
|
42
|
+
export default function ButtonSplit({ children, icon, onClick, items = [], menu, variant, tone, size = 'md', disabled = false, menuLabel = 'More actions', placement = 'bottom-end', className = '', accent, onMenu, menuOpen, iconOnly, pressed, tooltip, 'aria-label': ariaLabel }) {
|
|
34
43
|
const [open, setOpen] = useState(false)
|
|
35
44
|
const popover = usePopover({ open, onOpenChange: setOpen, placement, offset: 6, role: 'menu' })
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
const dataAccent = accent === 'secondary' ? accent : undefined
|
|
46
|
+
const close = () => setOpen(false)
|
|
47
|
+
const pick = (it) => () => { if (it.disabled) return; it.onPress?.(); close() }
|
|
48
|
+
/* the menu its own: the rows of `items` (or `menu`) in a PopoverPanel under the ⌄ */
|
|
49
|
+
const panel = (
|
|
50
|
+
<PopoverPanel popover={popover} panel={false} focus={false}
|
|
51
|
+
className="w-max bg-surface-secondary border border-oq-08 rounded shadow-lg">
|
|
52
|
+
{menu ? menu(close) : items.map((it) => (
|
|
53
|
+
<button key={it.label} type="button" disabled={it.disabled} onClick={pick(it)}
|
|
54
|
+
className="w-full kol-helper-12 px-3 h-8 flex items-center gap-2 text-body hover:text-emphasis disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-body text-left">
|
|
55
|
+
<span className="flex-1 truncate">{it.label}</span>
|
|
56
|
+
</button>
|
|
57
|
+
))}
|
|
58
|
+
</PopoverPanel>
|
|
59
|
+
)
|
|
60
|
+
/* the icon-only form (the tool dock's slot with a fold), Figma's dock as measured 2026-11-20 (W16.3): two boxes 1
|
|
61
|
+
* apart, no divider and no joined half. The tool a 32 tile with the 22 glyph (Figma's draw 16 to 18, W2), rounded on all
|
|
62
|
+
* four corners, solid accent while `pressed`; the ⌄ its own 16 by 32 button, no fill at rest (pressed or not), the quiet
|
|
63
|
+
* fill on hover and while its menu is open (`menuOpen`); `tooltip` names the main half */
|
|
64
|
+
if (iconOnly) {
|
|
65
|
+
const main = (
|
|
66
|
+
<button type="button" aria-label={ariaLabel} aria-pressed={!!pressed} disabled={disabled} onClick={onClick}
|
|
67
|
+
className="kol-btn-split-main inline-flex size-8 shrink-0 items-center justify-center outline-none focus-visible:outline-solid focus-visible:outline-1">
|
|
68
|
+
<IconLoader name={iconOnly} size={22} className="kol-kolbox-icon shrink-0" />
|
|
69
|
+
</button>
|
|
70
|
+
)
|
|
71
|
+
const lit = menuOpen ?? (!onMenu && open)
|
|
72
|
+
const chevron = (
|
|
73
|
+
<button type="button" aria-label={menuLabel} aria-expanded={!!lit} onClick={onMenu}
|
|
74
|
+
className={`kol-btn-split-menu${lit ? ' is-open' : ''} inline-flex h-8 w-4 shrink-0 items-center justify-center outline-none focus-visible:outline-solid focus-visible:outline-1`}>
|
|
75
|
+
<KolboxGlyph name="chevron-down" />
|
|
76
|
+
</button>
|
|
77
|
+
)
|
|
64
78
|
return (
|
|
65
|
-
<div data-accent={
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
<div data-accent={dataAccent} className={`kol-btn-split--narrow kol-btn-split--icon${pressed ? ' is-pressed' : ''} inline-flex shrink-0 gap-px ${className}`.trim()}>
|
|
80
|
+
{tooltip ? <Tooltip label={tooltip}>{main}</Tooltip> : main}
|
|
81
|
+
{onMenu
|
|
82
|
+
? <Tooltip asChild label={menuLabel}>{chevron}</Tooltip>
|
|
83
|
+
: <span ref={popover.refs.setReference} {...popover.getReferenceProps()} className="inline-flex"><Tooltip asChild label={menuLabel}>{chevron}</Tooltip></span>}
|
|
84
|
+
{!onMenu && panel}
|
|
68
85
|
</div>
|
|
69
86
|
)
|
|
70
87
|
}
|
|
71
|
-
/*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
if (variant === 'folio') {
|
|
88
|
+
/* the host opens its menu (kolbox's SplitButton, W31.2 batch 3, 2026-11-18): the action and its ⌄ as two Buttons of one
|
|
89
|
+
* tone, 1px apart, square where they meet; the hovered half takes the fg-04 hover over its own fill (kol-theme
|
|
90
|
+
* `.kol-btn-split--narrow`). `onMenu` is the ⌄'s press. */
|
|
91
|
+
if (onMenu || variant === THEME_WORDS[0]) {
|
|
76
92
|
return (
|
|
77
|
-
<
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<button type="button" aria-label={menuLabel} aria-haspopup="menu" aria-expanded={open} onClick={() => setOpen(!open)} className="flex w-[32px] items-center justify-center"><IconLoader name="chevron-down" size={16} /></button>
|
|
82
|
-
</span>
|
|
83
|
-
<Menu variant="folio" open={open} onClose={() => setOpen(false)} aria-label={menuLabel} minWidth={160}
|
|
84
|
-
panelClassName="absolute right-0 top-[calc(100%+4px)] whitespace-nowrap"
|
|
85
|
-
items={items.map((it) => ({ label: it.label, onClick: it.onPress, disabled: it.disabled }))} />
|
|
86
|
-
</span>
|
|
93
|
+
<div data-accent={dataAccent} className={`kol-btn-split--narrow inline-flex shrink-0 gap-px ${className}`}>
|
|
94
|
+
<Button tone={tone} iconLeft={icon} onClick={onClick} className="rounded-r-none">{children}</Button>
|
|
95
|
+
<Tooltip asChild label={menuLabel}><Button tone={tone} iconLeft="chevron-down" onClick={onMenu} aria-label={menuLabel} className="rounded-l-none px-1" /></Tooltip>
|
|
96
|
+
</div>
|
|
87
97
|
)
|
|
88
98
|
}
|
|
89
|
-
const close = () => setOpen(false)
|
|
90
99
|
const shared = { tone, size }
|
|
91
|
-
const pick = (it) => () => { if (it.disabled) return; it.onPress?.(); close() }
|
|
92
100
|
return (
|
|
93
|
-
<div data-accent={
|
|
101
|
+
<div data-accent={dataAccent} className={`kol-btn-split inline-flex items-stretch ${className}`.trim()}>
|
|
94
102
|
<Button {...shared} iconLeft={icon} iconSize={12} disabled={disabled} onClick={onClick} className="flex-1 min-w-0 rounded-r-none">{children}</Button>
|
|
95
103
|
<span aria-hidden="true" className="w-px shrink-0 bg-oq-16" />
|
|
96
104
|
<span ref={popover.refs.setReference} {...popover.getReferenceProps()} className="inline-flex">
|
|
97
105
|
<Button {...shared} iconOnly="chevron-down" iconSize={12} pressed={open} aria-label={menuLabel}
|
|
98
106
|
className="rounded-l-none" />
|
|
99
107
|
</span>
|
|
100
|
-
|
|
101
|
-
className="w-max bg-surface-secondary border border-oq-08 rounded shadow-lg">
|
|
102
|
-
{menu ? menu(close) : items.map((it) => (
|
|
103
|
-
<button key={it.label} type="button" disabled={it.disabled} onClick={pick(it)}
|
|
104
|
-
className="w-full kol-helper-12 px-3 h-8 flex items-center gap-2 text-body hover:text-emphasis disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:text-body text-left">
|
|
105
|
-
<span className="flex-1 truncate">{it.label}</span>
|
|
106
|
-
</button>
|
|
107
|
-
))}
|
|
108
|
-
</PopoverPanel>
|
|
108
|
+
{panel}
|
|
109
109
|
</div>
|
|
110
110
|
)
|
|
111
111
|
}
|
|
@@ -50,7 +50,7 @@ export default function ContextMenu({ menu, children, variant, className = '' })
|
|
|
50
50
|
}, [menu.open])
|
|
51
51
|
if (!menu.open) return null
|
|
52
52
|
return (
|
|
53
|
-
<Menu anchor={{ x: menu.x, y: menu.y }} open onOpenChange={(v) => { if (!v) menu.close() }} variant={variant} panelClassName={`min-w-44 ${className}`.trim()}>
|
|
53
|
+
<Menu anchor={{ x: menu.x, y: menu.y }} placement="right-start" offset={2} open onOpenChange={(v) => { if (!v) menu.close() }} variant={variant} panelClassName={`min-w-44 ${className}`.trim()}>
|
|
54
54
|
{/* Any click inside closes — a menu item that leaves the menu open after acting is the one interaction people
|
|
55
55
|
* report as broken. Items keep their own onClick; this runs after it on the way up. */}
|
|
56
56
|
<div onClick={menu.close} role="none" className="flex flex-col gap-[var(--kol-spacing-0-5)]">
|
|
@@ -61,25 +61,24 @@ const ROW = { xs: `kol-mono-8 ${ROW_PAD.xs} ${ROW_H.xs}`, sm: `kol-mono-12 ${ROW
|
|
|
61
61
|
|
|
62
62
|
const LEGACY_VARIANTS = { default: 'primary', subtle: 'primary', minimal: 'outline' }
|
|
63
63
|
|
|
64
|
-
/*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* field,
|
|
69
|
-
* align left (unset): the list's left edge on the field's; right: its right edge on the field's.
|
|
70
|
-
* `options` strings or `{ value, label }`; `onChange` gets the value as a string
|
|
71
|
-
* menu the arrows move, Enter picks, a letter jumps, Escape closes; focus comes back to
|
|
72
|
-
*
|
|
64
|
+
/* THE FIELD (plan-2026-11-29-one-set-fold W3; kolbox's Dropdown, W31.2 batch 4, carried line for line): `fused={false}`.
|
|
65
|
+
* The closed field with the 12 chevron at the right: a button that opens the one `Menu` UNDER itself, 4 apart, and over
|
|
66
|
+
* it only when there is no room under (KolboxDropdownOpensUnder, kol-fxr 2026-11-28, as Figma's lists), at least as wide
|
|
67
|
+
* as the field, with a check on the current option. Its look is the theme's (`--kol-dd-field-*`, kol-theme `.kol-dd-field`):
|
|
68
|
+
* the default theme draws KOL's field, `data-theme-variant="kolbox"` kolbox's (28, xs the 24 filter, the kolbox line).
|
|
69
|
+
* align left (unset): the list's left edge on the field's; right (or Folio's bottom-right): its right edge on the field's.
|
|
70
|
+
* `options` strings or `{ value, label }`; `onChange` gets the value as a string (a number option's as a number). Enter,
|
|
71
|
+
* Space or ArrowDown opens; in the menu the arrows move, Enter picks, a letter jumps, Escape closes; focus comes back to
|
|
72
|
+
* the field.
|
|
73
|
+
* size sm (unset) the field; xs the filter (Home's), no fill, Figma's filter measured (plan-2026-11-23-editor-
|
|
73
74
|
* measured-against-figma W7): the value 8 in, the chevron's glyph 5 after it and 7 off the right edge
|
|
74
|
-
* tone unset: the outlined field, the
|
|
75
|
-
*
|
|
76
|
-
* after the value, so it hugs its value (the top rail's zoom)
|
|
75
|
+
* tone unset: the outlined field, the line only; `grey`: the unbordered field (the field fill at sm, bare at xs),
|
|
76
|
+
* padding 12 left and 4 right, the chevron 4 after the value, so it hugs its value (the top rail's zoom)
|
|
77
77
|
* menu a trigger for its own overlay instead of the option list (the zoom's): menu({ anchor, open, onClose }) is drawn
|
|
78
78
|
* in place of the Menu, and the field reads `value` as it is
|
|
79
79
|
* ariaLabel what it chooses, as KOL's Dropdown; other props (disabled, data-*) land on the button
|
|
80
|
-
*
|
|
81
|
-
|
|
82
|
-
function DropdownKolbox({ size, tone, value, options = [], onChange, menu, ariaLabel, align = 'left', className = '', variant, accent, ...rest }) {
|
|
80
|
+
* a `value` no option holds is shown as it is (Folio on kolbox, 2026-11-22) */
|
|
81
|
+
function DropdownField({ size, tone, value, options = [], onChange, menu, ariaLabel, align = 'left', className = '', variant, accent, ...rest }) { // eslint-disable-line no-unused-vars
|
|
83
82
|
const ref = useRef(null)
|
|
84
83
|
const [open, setOpen] = useState(false)
|
|
85
84
|
const outlined = tone !== 'grey'
|
|
@@ -98,6 +97,7 @@ function DropdownKolbox({ size, tone, value, options = [], onChange, menu, ariaL
|
|
|
98
97
|
const on = o === current
|
|
99
98
|
groups.at(-1).push({ label: o.label, value: o.value, check: held ? on : undefined, highlighted: on })
|
|
100
99
|
}
|
|
100
|
+
/* `kol-dd--kolbox` and `kol-dd-caret--kolbox` ride along as hooks for kol-fxr's own rules, on the retirement ledger */
|
|
101
101
|
return (
|
|
102
102
|
<>
|
|
103
103
|
<button
|
|
@@ -115,20 +115,19 @@ function DropdownKolbox({ size, tone, value, options = [], onChange, menu, ariaL
|
|
|
115
115
|
e.preventDefault(); e.stopPropagation()
|
|
116
116
|
if (e.key !== 'ArrowUp') setOpen(true)
|
|
117
117
|
}}
|
|
118
|
-
className={`kol-dd--kolbox${outlined ? ' kol-dd--
|
|
118
|
+
className={`kol-dd-field kol-dd--kolbox${outlined ? ' kol-dd-field--outlined' : ''}${outlined && open ? ' is-open' : ''}${!outlined && !xs ? ' kol-dd-field--filled' : ''} relative flex min-w-0 cursor-pointer items-center disabled:cursor-default disabled:opacity-40 ${xs ? 'h-[var(--kol-dd-field-xs-h,var(--kol-ctl-xs))] bg-transparent' : 'h-[var(--kol-dd-field-h,var(--kol-ctl-sm))]'} text-left outline-none ${outlined ? (xs ? 'gap-0.5 border pr-[3px] pl-[7px]' : 'gap-2 border px-2') : 'gap-1 pr-1 pl-3 focus-visible:outline-1'} ${className}`}
|
|
119
119
|
{...rest}
|
|
120
120
|
>
|
|
121
121
|
<span className="min-w-0 flex-1 truncate">{current?.label}</span>
|
|
122
|
-
<KolboxGlyph name="chevron-down" className="kol-dd-caret--kolbox pointer-events-none" />
|
|
122
|
+
<KolboxGlyph name="chevron-down" className="kol-dd-field-caret kol-dd-caret--kolbox pointer-events-none" />
|
|
123
123
|
</button>
|
|
124
124
|
{menu ? menu({ anchor: ref, open, onClose: close }) : <Menu
|
|
125
|
-
variant="kolbox"
|
|
126
125
|
anchor={ref}
|
|
127
126
|
open={open}
|
|
128
127
|
onClose={close}
|
|
129
128
|
onSelect={(row) => onChange?.(typeof row.value === 'number' ? row.value : String(row.value))}
|
|
130
129
|
groups={groups}
|
|
131
|
-
placement={align
|
|
130
|
+
placement={/right/.test(align) ? 'bottom-end' : 'bottom-start'}
|
|
132
131
|
accent={accent}
|
|
133
132
|
aria-label={ariaLabel}
|
|
134
133
|
minWidth={ref.current?.offsetWidth}
|
|
@@ -137,42 +136,11 @@ function DropdownKolbox({ size, tone, value, options = [], onChange, menu, ariaL
|
|
|
137
136
|
)
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
/*
|
|
141
|
-
*
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* bottom-right: the list's edge and side. */
|
|
146
|
-
function DropdownFolio({ value, options = [], onChange, ariaLabel, disabled, align = 'left', className = '', accent }) {
|
|
147
|
-
const [open, setOpen] = useState(false)
|
|
148
|
-
const box = useRef(null)
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
if (!open) return undefined
|
|
151
|
-
const off = (e) => { if (!box.current?.contains(e.target)) setOpen(false) }
|
|
152
|
-
const esc = (e) => e.key === 'Escape' && setOpen(false)
|
|
153
|
-
addEventListener('mousedown', off); addEventListener('keydown', esc)
|
|
154
|
-
return () => { removeEventListener('mousedown', off); removeEventListener('keydown', esc) }
|
|
155
|
-
}, [open])
|
|
156
|
-
const current = options.find((o) => o.value === value)?.label ?? value
|
|
157
|
-
return (
|
|
158
|
-
<span data-accent={accent === 'secondary' ? accent : undefined} ref={box} className="relative inline-flex">
|
|
159
|
-
<button type="button" aria-label={ariaLabel} aria-haspopup="listbox" aria-expanded={open} disabled={disabled} onClick={() => setOpen(!open)} className={`kol-dd--folio inline-flex items-center gap-[4px] rounded-[3px] disabled:cursor-default ${className}`}>
|
|
160
|
-
{current}{!disabled && <span aria-hidden className="kol-dd-caret--folio">⌄</span>}
|
|
161
|
-
</button>
|
|
162
|
-
{open && (
|
|
163
|
-
<span role="listbox" aria-label={ariaLabel} className={`kol-dd-list--folio absolute z-50 flex min-w-[160px] flex-col rounded-[3px] border py-[4px] ${/right/.test(align) ? 'right-0' : 'left-0'} ${/bottom/.test(align) ? 'bottom-[calc(100%+6px)]' : 'top-[calc(100%+6px)]'}`}>
|
|
164
|
-
{options.map((o) => (
|
|
165
|
-
<button key={o.value} type="button" role="option" aria-selected={o.value === value} onClick={() => { setOpen(false); onChange?.(o.value) }} className={`kol-dd-option--folio${o.value === value ? ' is-current' : ''} flex items-center gap-[8px] whitespace-nowrap px-[12px] py-[7px] text-left`}>
|
|
166
|
-
<span aria-hidden className="kol-dd-check--folio inline-flex size-[16px] shrink-0 items-center justify-center">{o.value === value ? '✓' : ''}</span>{o.label}
|
|
167
|
-
</button>
|
|
168
|
-
))}
|
|
169
|
-
</span>
|
|
170
|
-
)}
|
|
171
|
-
</span>
|
|
172
|
-
)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const Dropdown = (props) => (props.variant === 'kolbox' ? <DropdownKolbox {...props} /> : props.variant === 'folio' ? <DropdownFolio {...props} /> : <DropdownOn {...props} />)
|
|
139
|
+
/* the old theme words in `variant`: accepted, and they ask for the field (`fused={false}`), the build kolbox and Folio
|
|
140
|
+
* drew (W3, on the retirement ledger); the theme draws its look. Folio's own list went to _tmp/2026-11-29-one-set-fold/. */
|
|
141
|
+
const THEME_WORDS = ['kolbox', 'folio']
|
|
142
|
+
/* `fused` (true unset): the one-piece select, its list continuing the trigger; false: the field, its list a Menu under it */
|
|
143
|
+
const Dropdown = ({ fused, ...props }) => ((fused ?? !THEME_WORDS.includes(props.variant)) ? <DropdownOn {...props} /> : <DropdownField {...props} />)
|
|
176
144
|
|
|
177
145
|
const DropdownOn = ({
|
|
178
146
|
options = [],
|
|
@@ -271,7 +239,7 @@ const DropdownOn = ({
|
|
|
271
239
|
|
|
272
240
|
/* `variant="raised"` retires into `tone="faint"` (2026-10-31) — the alias, until nobody passes it */
|
|
273
241
|
if (variant === 'raised') { variant = undefined; tone = 'faint' }
|
|
274
|
-
const resolvedVariant = LEGACY_VARIANTS[variant] || variant
|
|
242
|
+
const resolvedVariant = THEME_WORDS.includes(variant) ? undefined : LEGACY_VARIANTS[variant] || variant
|
|
275
243
|
|
|
276
244
|
/* The panel is `Menu fused` (plan-2026-10-31-menu-engine W1.3): below the trigger, never flipped (the fused edge
|
|
277
245
|
* assumes below), the trigger's width, a listbox. */
|