@luxalgo/vela-ui 0.4.1 → 0.4.3
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/CHANGELOG.md +27 -0
- package/dist/button.js +2 -2
- package/dist/callout-bubble.js +1 -1
- package/dist/checkbox.js +2 -2
- package/dist/{chunk-5A54GODF.js → chunk-DEL7MTW3.js} +1 -1
- package/dist/{chunk-ODPGOUQT.js → chunk-H3YWXJNS.js} +25 -13
- package/dist/{chunk-EDYD5XKJ.js → chunk-LLKAVT7F.js} +1 -0
- package/dist/{chunk-BIU66EHS.js → chunk-QQVUO4LC.js} +1 -1
- package/dist/{chunk-7LYWI32I.js → chunk-RCKTOJIA.js} +1 -1
- package/dist/{chunk-JEGB72M4.js → chunk-TMVE3R66.js} +1 -1
- package/dist/{chunk-CZRHHVSB.js → chunk-UJBKIO26.js} +1 -1
- package/dist/collapsible.js +1 -1
- package/dist/context-menu.js +2 -2
- package/dist/date-picker.js +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dropdown-menu.d.ts +10 -0
- package/dist/dropdown-menu.js +2 -2
- package/dist/empty.js +1 -1
- package/dist/field.d.ts +2 -0
- package/dist/field.js +10 -6
- package/dist/glyph-select.js +2 -2
- package/dist/hover-card.js +1 -1
- package/dist/icons.js +1 -1
- package/dist/input-group.js +2 -2
- package/dist/item.js +1 -1
- package/dist/manifest.json +2 -1
- package/dist/number-input.js +2 -2
- package/dist/select.js +2 -2
- package/dist/sort-button.js +1 -1
- package/dist/tabs.js +1 -1
- package/dist/theme.schema.json +1 -1
- package/dist/toast.js +1 -1
- package/dist/toggle-group.js +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/registry/dropdown-menu.ts +45 -12
- package/registry/field.ts +11 -0
- package/src/components/dropdown-menu.ts +45 -12
- package/src/components/field.ts +11 -0
- package/src/lib/icons.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to `@luxalgo/vela-ui`, newest first. Vela's own changes, including how it
|
|
4
4
|
uses the kit, are in [Vela's changelog](../../CHANGELOG.md).
|
|
5
5
|
|
|
6
|
+
## [0.4.3]
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- **A dropdown menu opens against any box.** `openAt` takes a rectangle as well as a point,
|
|
11
|
+
such as the box of a button the menu does not own as its trigger:
|
|
12
|
+
`menu.openAt(button.getBoundingClientRect())`. The list opens on the menu's `side` of the
|
|
13
|
+
box, with its `align` and offsets, and on the box's other side when that one lacks room,
|
|
14
|
+
so it never covers the button. It keeps its place in its host like any other open menu.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **An open menu follows its host when the page scrolls.** A dropdown menu opened from its
|
|
19
|
+
trigger stayed at the same place on screen while the page scrolled the trigger away. A
|
|
20
|
+
menu opened with `openAt`, a context menu included, jumped to the top of the window. An
|
|
21
|
+
open menu now keeps its place inside its host, whichever way it opened, and still stays
|
|
22
|
+
where it is when its trigger moves inside the host.
|
|
23
|
+
|
|
24
|
+
## [0.4.2]
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **Section headings can carry a mark.** `fieldSection` takes an `info` element, such as a help
|
|
29
|
+
mark, and places it after the heading text, centered on it.
|
|
30
|
+
- **A question-mark icon.** The icon set draws `help`, a question mark for help marks, in the
|
|
31
|
+
16-pixel chrome tier beside `info`.
|
|
32
|
+
|
|
6
33
|
## [0.4.1]
|
|
7
34
|
|
|
8
35
|
### Added
|
package/dist/button.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { BUTTON_CSS, BUTTON_STYLE_ID, buttonDef, buttonVariants, createButton } from './chunk-
|
|
1
|
+
export { BUTTON_CSS, BUTTON_STYLE_ID, buttonDef, buttonVariants, createButton } from './chunk-UJBKIO26.js';
|
|
2
2
|
import './chunk-FYVQO5TN.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-LLKAVT7F.js';
|
|
4
4
|
import './chunk-LZWZV2ZS.js';
|
|
5
5
|
import './chunk-Q6WTDVH6.js';
|
|
6
6
|
import './chunk-6QCILIT2.js';
|
package/dist/callout-bubble.js
CHANGED
|
@@ -6,7 +6,7 @@ import './chunk-TAKSIV57.js';
|
|
|
6
6
|
import './chunk-MMTMOV6R.js';
|
|
7
7
|
import './chunk-3Q32K4PE.js';
|
|
8
8
|
import './chunk-A72NWYNP.js';
|
|
9
|
-
import { iconAt } from './chunk-
|
|
9
|
+
import { iconAt } from './chunk-LLKAVT7F.js';
|
|
10
10
|
import { addSlot } from './chunk-Q6WTDVH6.js';
|
|
11
11
|
import { t } from './chunk-6QCILIT2.js';
|
|
12
12
|
import { defineComponent } from './chunk-VMCR3S2A.js';
|
package/dist/checkbox.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { Checkbox, checkboxController, checkboxDef, checkboxVariants, createCheckbox } from './chunk-
|
|
1
|
+
export { Checkbox, checkboxController, checkboxDef, checkboxVariants, createCheckbox } from './chunk-QQVUO4LC.js';
|
|
2
2
|
import './chunk-A72NWYNP.js';
|
|
3
3
|
import './chunk-GUIYFQ27.js';
|
|
4
|
-
import './chunk-
|
|
4
|
+
import './chunk-LLKAVT7F.js';
|
|
5
5
|
import './chunk-LZWZV2ZS.js';
|
|
6
6
|
import './chunk-Q6WTDVH6.js';
|
|
7
7
|
import './chunk-6QCILIT2.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { openPopoverTrigger, closeOpenPopovers, Popover } from './chunk-BWSOMG3G.js';
|
|
2
|
-
import { iconEl } from './chunk-
|
|
2
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
3
3
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
4
4
|
import { t } from './chunk-6QCILIT2.js';
|
|
5
5
|
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
@@ -5,7 +5,7 @@ import { holdForExit } from './chunk-S7USVSYP.js';
|
|
|
5
5
|
import { floatingLayerHost } from './chunk-RH53NQGE.js';
|
|
6
6
|
import { zagPositioning, splitPlacement } from './chunk-3Q32K4PE.js';
|
|
7
7
|
import { normalizeProps, nextUid, runMachine, spreadProps } from './chunk-GUIYFQ27.js';
|
|
8
|
-
import { iconEl } from './chunk-
|
|
8
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
9
9
|
import { addSlot } from './chunk-Q6WTDVH6.js';
|
|
10
10
|
import { t } from './chunk-6QCILIT2.js';
|
|
11
11
|
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
@@ -53,8 +53,11 @@ var Surface = class _Surface {
|
|
|
53
53
|
this.items = [];
|
|
54
54
|
/** Branch item id → the surface it opens. */
|
|
55
55
|
this.subs = /* @__PURE__ */ new Map();
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
56
|
+
/** What this level opened against, as an offset inside the host: its trigger's rect, or
|
|
57
|
+
* the point or rectangle `openAt` was given. Held in the host's space, not the
|
|
58
|
+
* viewport's, so the list keeps its place in the host: a trigger that then moves leaves
|
|
59
|
+
* it still (favorite chips shifting the caret), and a page that scrolls the host carries
|
|
60
|
+
* it along. Null on a submenu, which follows its row. */
|
|
58
61
|
this.pinnedAnchor = null;
|
|
59
62
|
/** The open state last announced — see {@link announce}. */
|
|
60
63
|
this.shown = false;
|
|
@@ -82,14 +85,10 @@ var Surface = class _Surface {
|
|
|
82
85
|
id: opts.id,
|
|
83
86
|
...opts.placement,
|
|
84
87
|
onSelect: (id) => this.onSelect(id),
|
|
85
|
-
getAnchorRect: () => this.
|
|
88
|
+
getAnchorRect: () => this.anchorRect(),
|
|
86
89
|
onOpenChange: (open) => {
|
|
87
|
-
if (open
|
|
88
|
-
|
|
89
|
-
this.pinnedAnchor = { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
90
|
-
} else {
|
|
91
|
-
this.pinnedAnchor = null;
|
|
92
|
-
}
|
|
90
|
+
if (!open) this.pinnedAnchor = null;
|
|
91
|
+
else if (trigger && !this.pinnedAnchor) this.pin(trigger.getBoundingClientRect());
|
|
93
92
|
opts.onOpenChange?.(open);
|
|
94
93
|
},
|
|
95
94
|
triggerId: opts.triggerId
|
|
@@ -132,6 +131,18 @@ var Surface = class _Surface {
|
|
|
132
131
|
get api() {
|
|
133
132
|
return this.ctrl.connect(this.handle.service);
|
|
134
133
|
}
|
|
134
|
+
/** Anchor this level to `rect`, given in viewport coordinates. */
|
|
135
|
+
pin(rect) {
|
|
136
|
+
const origin = this.host.getBoundingClientRect();
|
|
137
|
+
this.pinnedAnchor = { x: rect.x - origin.x, y: rect.y - origin.y, width: rect.width, height: rect.height };
|
|
138
|
+
}
|
|
139
|
+
/** The anchor in viewport coordinates, where the host stands now. */
|
|
140
|
+
anchorRect() {
|
|
141
|
+
const anchor = this.pinnedAnchor;
|
|
142
|
+
if (!anchor) return null;
|
|
143
|
+
const origin = this.host.getBoundingClientRect();
|
|
144
|
+
return { x: origin.x + anchor.x, y: origin.y + anchor.y, width: anchor.width, height: anchor.height };
|
|
145
|
+
}
|
|
135
146
|
announce(open) {
|
|
136
147
|
this.shown = open;
|
|
137
148
|
announceSurface(this.list, open, "menu", this.opener);
|
|
@@ -328,11 +339,12 @@ var DropdownMenu = class {
|
|
|
328
339
|
open() {
|
|
329
340
|
this.api.setOpen(true);
|
|
330
341
|
}
|
|
331
|
-
|
|
332
|
-
|
|
342
|
+
openAt(at, clientY = 0) {
|
|
343
|
+
const rect = typeof at === "number" ? { x: at, y: clientY, width: 0, height: 0 } : { x: at.x, y: at.y, width: at.width, height: at.height };
|
|
333
344
|
const api = this.api;
|
|
345
|
+
queueMicrotask(() => this.root.pin(rect));
|
|
334
346
|
api.setOpen(true);
|
|
335
|
-
api.reposition({ getAnchorRect: () => (
|
|
347
|
+
api.reposition({ getAnchorRect: () => this.root.anchorRect() });
|
|
336
348
|
}
|
|
337
349
|
close() {
|
|
338
350
|
this.api.setOpen(false);
|
|
@@ -135,6 +135,7 @@ registerIcon("grip", S('<circle cx="6" cy="3.5" r="1"/><circle cx="10" cy="3.5"
|
|
|
135
135
|
registerIcon("kebab", S('<circle cx="8" cy="3.2" r="1.2"/><circle cx="8" cy="8" r="1.2"/><circle cx="8" cy="12.8" r="1.2"/>', 'fill="currentColor" stroke="none"'));
|
|
136
136
|
registerIcon("burger", S('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));
|
|
137
137
|
registerIcon("info", S('<path d="M8 7.4v4.4"/><circle cx="8" cy="4.6" r="0.9" fill="currentColor" stroke="none"/>'));
|
|
138
|
+
registerIcon("help", S('<path d="M6.1 6a1.9 1.9 0 1 1 2.85 1.65c-.6.3-.95.7-.95 1.25v.45"/><circle cx="8" cy="11.5" r="0.9" fill="currentColor" stroke="none"/>'));
|
|
138
139
|
registerIcon("reset", S('<path d="M2 8a6 6 0 1 0 6-6 6.5 6.5 0 0 0-4.5 1.83L2 5.33"/><path d="M2 2v3.33h3.33"/>'));
|
|
139
140
|
registerIcon("circle-check", S('<circle cx="8" cy="8" r="6.2"/><path d="m5.4 8.2 1.8 1.8 3.4-3.7"/>'));
|
|
140
141
|
registerIcon("circle-info", S('<circle cx="8" cy="8" r="6.2"/><path d="M8 7.4v3.6"/><circle cx="8" cy="5.1" r="0.8" fill="currentColor" stroke="none"/>'));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ownTeardown } from './chunk-A72NWYNP.js';
|
|
2
2
|
import { nextUid, runMachine, normalizeProps, spreadProps } from './chunk-GUIYFQ27.js';
|
|
3
|
-
import { iconEl } from './chunk-
|
|
3
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
4
4
|
import { variants } from './chunk-LZWZV2ZS.js';
|
|
5
5
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
6
6
|
import { t } from './chunk-6QCILIT2.js';
|
|
@@ -2,7 +2,7 @@ import { kitTranslator } from './chunk-FVH6L7FM.js';
|
|
|
2
2
|
import { msg, textOf } from './chunk-FN2BUFNM.js';
|
|
3
3
|
import { ownTeardown } from './chunk-A72NWYNP.js';
|
|
4
4
|
import { nextUid, runMachine, normalizeProps, spreadProps } from './chunk-GUIYFQ27.js';
|
|
5
|
-
import { iconEl } from './chunk-
|
|
5
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
6
6
|
import { variants } from './chunk-LZWZV2ZS.js';
|
|
7
7
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
8
8
|
import { t } from './chunk-6QCILIT2.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { openPopoverTrigger, closeOpenPopovers, Popover } from './chunk-BWSOMG3G.js';
|
|
2
2
|
import { ownTeardown } from './chunk-A72NWYNP.js';
|
|
3
3
|
import { nextUid, runMachine, normalizeProps, spreadProps } from './chunk-GUIYFQ27.js';
|
|
4
|
-
import { iconEl } from './chunk-
|
|
4
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
5
5
|
import { variants } from './chunk-LZWZV2ZS.js';
|
|
6
6
|
import { addSlot, h } from './chunk-Q6WTDVH6.js';
|
|
7
7
|
import { t } from './chunk-6QCILIT2.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createKbd } from './chunk-FYVQO5TN.js';
|
|
2
|
-
import { iconEl } from './chunk-
|
|
2
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
3
3
|
import { variants } from './chunk-LZWZV2ZS.js';
|
|
4
4
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
5
5
|
import { t } from './chunk-6QCILIT2.js';
|
package/dist/collapsible.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { nextUid } from './chunk-GUIYFQ27.js';
|
|
2
|
-
import { iconEl } from './chunk-
|
|
2
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
3
3
|
import { variants } from './chunk-LZWZV2ZS.js';
|
|
4
4
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
5
5
|
import { t } from './chunk-6QCILIT2.js';
|
package/dist/context-menu.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DropdownMenu } from './chunk-
|
|
1
|
+
import { DropdownMenu } from './chunk-H3YWXJNS.js';
|
|
2
2
|
import { kitTranslator } from './chunk-FVH6L7FM.js';
|
|
3
3
|
import './chunk-FN2BUFNM.js';
|
|
4
4
|
import './chunk-J2QJATCD.js';
|
|
@@ -9,7 +9,7 @@ import './chunk-MMTMOV6R.js';
|
|
|
9
9
|
import './chunk-3Q32K4PE.js';
|
|
10
10
|
import { ownTeardown } from './chunk-A72NWYNP.js';
|
|
11
11
|
import './chunk-GUIYFQ27.js';
|
|
12
|
-
import './chunk-
|
|
12
|
+
import './chunk-LLKAVT7F.js';
|
|
13
13
|
import './chunk-Q6WTDVH6.js';
|
|
14
14
|
import './chunk-6QCILIT2.js';
|
|
15
15
|
import './chunk-VMCR3S2A.js';
|
package/dist/date-picker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { calendarSettings, monthNames, yearLabel, weekdayNames, yearBeforeMonth, plainInteger } from './chunk-GVRX3UAV.js';
|
|
2
2
|
import { msg, textOf } from './chunk-FN2BUFNM.js';
|
|
3
|
-
import { iconEl } from './chunk-
|
|
3
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
4
4
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
5
5
|
import { t } from './chunk-6QCILIT2.js';
|
|
6
6
|
import { defineComponent } from './chunk-VMCR3S2A.js';
|
package/dist/dialog.js
CHANGED
|
@@ -9,7 +9,7 @@ import './chunk-MMTMOV6R.js';
|
|
|
9
9
|
import './chunk-3Q32K4PE.js';
|
|
10
10
|
import { disposeWithin } from './chunk-A72NWYNP.js';
|
|
11
11
|
import { normalizeProps, nextUid, runMachine, spreadProps } from './chunk-GUIYFQ27.js';
|
|
12
|
-
import { iconEl } from './chunk-
|
|
12
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
13
13
|
import './chunk-Q6WTDVH6.js';
|
|
14
14
|
import { t } from './chunk-6QCILIT2.js';
|
|
15
15
|
import { defineComponent } from './chunk-VMCR3S2A.js';
|
package/dist/dropdown-menu.d.ts
CHANGED
|
@@ -106,6 +106,16 @@ declare class DropdownMenu {
|
|
|
106
106
|
open(): void;
|
|
107
107
|
/** Open anchored to a viewport point (context menus). */
|
|
108
108
|
openAt(clientX: number, clientY: number): void;
|
|
109
|
+
/** Open against a rectangle in viewport coordinates, such as the box of a button the menu
|
|
110
|
+
* does not own as its trigger (`button.getBoundingClientRect()`): on the menu's side of
|
|
111
|
+
* it, with its alignment and offsets, and on the rectangle's other side when that one
|
|
112
|
+
* lacks room. */
|
|
113
|
+
openAt(rect: {
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
width: number;
|
|
117
|
+
height: number;
|
|
118
|
+
}): void;
|
|
109
119
|
close(): void;
|
|
110
120
|
/** Swap the item descriptors (e.g. checked states) and re-project. */
|
|
111
121
|
setItems(items: readonly MenuItemDescriptor[]): void;
|
package/dist/dropdown-menu.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DropdownMenu, createDropdownMenu, dropdownMenuController, dropdownMenuDef } from './chunk-
|
|
1
|
+
export { DropdownMenu, createDropdownMenu, dropdownMenuController, dropdownMenuDef } from './chunk-H3YWXJNS.js';
|
|
2
2
|
import './chunk-FVH6L7FM.js';
|
|
3
3
|
import './chunk-FN2BUFNM.js';
|
|
4
4
|
import './chunk-J2QJATCD.js';
|
|
@@ -8,7 +8,7 @@ import './chunk-TAKSIV57.js';
|
|
|
8
8
|
import './chunk-MMTMOV6R.js';
|
|
9
9
|
import './chunk-3Q32K4PE.js';
|
|
10
10
|
import './chunk-GUIYFQ27.js';
|
|
11
|
-
import './chunk-
|
|
11
|
+
import './chunk-LLKAVT7F.js';
|
|
12
12
|
import './chunk-Q6WTDVH6.js';
|
|
13
13
|
import './chunk-6QCILIT2.js';
|
|
14
14
|
import './chunk-VMCR3S2A.js';
|
package/dist/empty.js
CHANGED
package/dist/field.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ declare function fieldGrid(opts?: FieldGridOptions): HTMLElement;
|
|
|
25
25
|
interface FieldSectionOptions {
|
|
26
26
|
variant?: FieldGridVariant;
|
|
27
27
|
first?: boolean;
|
|
28
|
+
/** Placed after the heading text and centered on it, such as a help mark. */
|
|
29
|
+
info?: HTMLElement;
|
|
28
30
|
}
|
|
29
31
|
/** Uppercase group heading that spans the field grid. */
|
|
30
32
|
declare function fieldSection(title: string, opts?: FieldSectionOptions): HTMLElement;
|
package/dist/field.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TextArea } from './chunk-ALAHGSLC.js';
|
|
2
|
-
import { NumberInput } from './chunk-
|
|
3
|
-
import { Select } from './chunk-
|
|
4
|
-
import { widthField } from './chunk-
|
|
2
|
+
import { NumberInput } from './chunk-RCKTOJIA.js';
|
|
3
|
+
import { Select } from './chunk-TMVE3R66.js';
|
|
4
|
+
import { widthField } from './chunk-DEL7MTW3.js';
|
|
5
5
|
import { Input } from './chunk-5BJV5FY5.js';
|
|
6
6
|
import { ColorField } from './chunk-TGJNHUYV.js';
|
|
7
7
|
import './chunk-FVH6L7FM.js';
|
|
@@ -13,10 +13,10 @@ import './chunk-RH53NQGE.js';
|
|
|
13
13
|
import './chunk-TAKSIV57.js';
|
|
14
14
|
import './chunk-MMTMOV6R.js';
|
|
15
15
|
import './chunk-3Q32K4PE.js';
|
|
16
|
-
import { Checkbox } from './chunk-
|
|
16
|
+
import { Checkbox } from './chunk-QQVUO4LC.js';
|
|
17
17
|
import { disposeWithin } from './chunk-A72NWYNP.js';
|
|
18
18
|
import './chunk-GUIYFQ27.js';
|
|
19
|
-
import './chunk-
|
|
19
|
+
import './chunk-LLKAVT7F.js';
|
|
20
20
|
import './chunk-LZWZV2ZS.js';
|
|
21
21
|
import './chunk-Q6WTDVH6.js';
|
|
22
22
|
import { t } from './chunk-6QCILIT2.js';
|
|
@@ -39,7 +39,7 @@ var fieldDef = defineComponent({
|
|
|
39
39
|
var GAP = `${FIELD_GAP_PX}px`;
|
|
40
40
|
var injectFieldStyles = defineStyles(
|
|
41
41
|
"vela-ui-field",
|
|
42
|
-
css`@layer vela.ui{[data-slot~=field-grid]{align-content:start;align-items:center;column-gap:${GAP};row-gap:${GAP}}[data-slot~=field-grid]:where(:not([hidden])){display:grid}[data-slot~=field-grid][data-variant=inputs]{grid-template-columns:max-content 1fr}[data-slot~=field-grid][data-variant=inputs][data-mobile]{grid-template-columns:minmax(0,1fr) auto}[data-slot~=field-grid][data-variant=settings]{grid-template-columns:max-content max-content;column-gap:12px}[data-slot~=field-grid][data-variant=settings][data-mobile]{grid-template-columns:minmax(0,1fr) max-content}[data-slot~=field-row]:where(:not([hidden])){display:contents}[data-slot~=field-span]{grid-column:1/-1}[data-slot~=field-label]{opacity:.9;white-space:nowrap;text-overflow:ellipsis;font-size:14px;overflow:hidden}[data-slot~=field-label][data-size=sm]{font-size:inherit;opacity:.85}[data-slot~=field-cell]{justify-self:start;align-items:center;gap:8px;display:flex}[data-slot~=field-bool]:where(:not([hidden])){align-items:center;gap:8px;min-height:22px;display:flex}[data-slot~=field-stacked]:where(:not([hidden])){flex-direction:column;gap:8px;display:flex}[data-slot~=field-stacked-head]{justify-content:center;align-items:center;gap:8px;display:flex}[data-slot~=field-inline]:where(:not([hidden])){flex-wrap:wrap;align-items:center;gap:12px;display:flex}[data-slot~=field-inline-item],[data-slot~=field-toggle-label]{align-items:center;gap:8px;display:flex}[data-slot~=field-section]{font-size:${t.fontSize.sm};letter-spacing:.05em;text-transform:uppercase;color:${t.fg.muted};grid-column:1/-1;margin:24px 0 0;padding-bottom:8px;font-weight:700}[data-slot~=field-section][data-variant=inputs]{margin:0;padding:20px 0 8px;font-size:11px;font-weight:600}[data-slot~=field-section][data-variant=inputs][data-first]{padding-top:4px}[data-slot~=field-sep]{grid-column:1/-1;height:14px}}`
|
|
42
|
+
css`@layer vela.ui{[data-slot~=field-grid]{align-content:start;align-items:center;column-gap:${GAP};row-gap:${GAP}}[data-slot~=field-grid]:where(:not([hidden])){display:grid}[data-slot~=field-grid][data-variant=inputs]{grid-template-columns:max-content 1fr}[data-slot~=field-grid][data-variant=inputs][data-mobile]{grid-template-columns:minmax(0,1fr) auto}[data-slot~=field-grid][data-variant=settings]{grid-template-columns:max-content max-content;column-gap:12px}[data-slot~=field-grid][data-variant=settings][data-mobile]{grid-template-columns:minmax(0,1fr) max-content}[data-slot~=field-row]:where(:not([hidden])){display:contents}[data-slot~=field-span]{grid-column:1/-1}[data-slot~=field-label]{opacity:.9;white-space:nowrap;text-overflow:ellipsis;font-size:14px;overflow:hidden}[data-slot~=field-label][data-size=sm]{font-size:inherit;opacity:.85}[data-slot~=field-cell]{justify-self:start;align-items:center;gap:8px;display:flex}[data-slot~=field-bool]:where(:not([hidden])){align-items:center;gap:8px;min-height:22px;display:flex}[data-slot~=field-stacked]:where(:not([hidden])){flex-direction:column;gap:8px;display:flex}[data-slot~=field-stacked-head]{justify-content:center;align-items:center;gap:8px;display:flex}[data-slot~=field-inline]:where(:not([hidden])){flex-wrap:wrap;align-items:center;gap:12px;display:flex}[data-slot~=field-inline-item],[data-slot~=field-toggle-label]{align-items:center;gap:8px;display:flex}[data-slot~=field-section]{font-size:${t.fontSize.sm};letter-spacing:.05em;text-transform:uppercase;color:${t.fg.muted};grid-column:1/-1;margin:24px 0 0;padding-bottom:8px;font-weight:700}[data-slot~=field-section][data-variant=inputs]{margin:0;padding:20px 0 8px;font-size:11px;font-weight:600}[data-slot~=field-section][data-variant=inputs][data-first]{padding-top:4px}[data-slot~=field-section][data-info]:where(:not([hidden])){align-items:center;gap:6px;display:flex}[data-slot~=field-sep]{grid-column:1/-1;height:14px}}`
|
|
43
43
|
);
|
|
44
44
|
var DIM_CSS = ".vela-field-dim { opacity: 0.4 !important; pointer-events: none !important; }";
|
|
45
45
|
function injectStyles2(doc) {
|
|
@@ -67,6 +67,10 @@ function fieldSection(title, opts = {}) {
|
|
|
67
67
|
if (opts.variant) el.dataset.variant = opts.variant;
|
|
68
68
|
if (opts.first) el.dataset.first = "";
|
|
69
69
|
el.textContent = title;
|
|
70
|
+
if (opts.info) {
|
|
71
|
+
el.dataset.info = "";
|
|
72
|
+
el.appendChild(opts.info);
|
|
73
|
+
}
|
|
70
74
|
return el;
|
|
71
75
|
}
|
|
72
76
|
function fieldSeparator() {
|
package/dist/glyph-select.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { GlyphSelect, WIDTH_FIELD_OPTIONS, closeWidthPopover, createGlyphSelect, glyphSelectController, glyphSelectDef, lineWidthGlyph, widthField, widthFieldOptions } from './chunk-
|
|
1
|
+
export { GlyphSelect, WIDTH_FIELD_OPTIONS, closeWidthPopover, createGlyphSelect, glyphSelectController, glyphSelectDef, lineWidthGlyph, widthField, widthFieldOptions } from './chunk-DEL7MTW3.js';
|
|
2
2
|
import './chunk-BWSOMG3G.js';
|
|
3
3
|
import './chunk-J2QJATCD.js';
|
|
4
4
|
import './chunk-S7USVSYP.js';
|
|
@@ -7,7 +7,7 @@ import './chunk-TAKSIV57.js';
|
|
|
7
7
|
import './chunk-MMTMOV6R.js';
|
|
8
8
|
import './chunk-3Q32K4PE.js';
|
|
9
9
|
import './chunk-A72NWYNP.js';
|
|
10
|
-
import './chunk-
|
|
10
|
+
import './chunk-LLKAVT7F.js';
|
|
11
11
|
import './chunk-Q6WTDVH6.js';
|
|
12
12
|
import './chunk-6QCILIT2.js';
|
|
13
13
|
import './chunk-VMCR3S2A.js';
|
package/dist/hover-card.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { shortcutKeys } from './chunk-FYVQO5TN.js';
|
|
2
2
|
import { viewportRect, placePopover, intersectRects } from './chunk-3Q32K4PE.js';
|
|
3
|
-
import { iconEl } from './chunk-
|
|
3
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
4
4
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
5
5
|
import { t } from './chunk-6QCILIT2.js';
|
|
6
6
|
import { defineComponent } from './chunk-VMCR3S2A.js';
|
package/dist/icons.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { icon, iconAt, iconEl, iconMarkup, registerIcon, svg16, svg24, svg24Solid } from './chunk-
|
|
1
|
+
export { icon, iconAt, iconEl, iconMarkup, registerIcon, svg16, svg24, svg24Solid } from './chunk-LLKAVT7F.js';
|
|
2
2
|
import './chunk-X66RJAIS.js';
|
package/dist/input-group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createButton } from './chunk-
|
|
1
|
+
import { createButton } from './chunk-UJBKIO26.js';
|
|
2
2
|
import './chunk-FYVQO5TN.js';
|
|
3
|
-
import { iconEl } from './chunk-
|
|
3
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
4
4
|
import { variants } from './chunk-LZWZV2ZS.js';
|
|
5
5
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
6
6
|
import { t } from './chunk-6QCILIT2.js';
|
package/dist/item.js
CHANGED
package/dist/manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": "@luxalgo/vela-ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"tokens": [
|
|
5
5
|
"space-1",
|
|
6
6
|
"space-2",
|
|
@@ -2098,6 +2098,7 @@
|
|
|
2098
2098
|
],
|
|
2099
2099
|
"attributes": [
|
|
2100
2100
|
"data-first",
|
|
2101
|
+
"data-info",
|
|
2101
2102
|
"data-mobile"
|
|
2102
2103
|
]
|
|
2103
2104
|
},
|
package/dist/number-input.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { NUMBER_CSS, NUMBER_STYLE_ID, NumberInput, clampNumber, createNumberInput, numberInputController, numberInputDef, numberInputVariants, snapToStep } from './chunk-
|
|
1
|
+
export { NUMBER_CSS, NUMBER_STYLE_ID, NumberInput, clampNumber, createNumberInput, numberInputController, numberInputDef, numberInputVariants, snapToStep } from './chunk-RCKTOJIA.js';
|
|
2
2
|
import './chunk-FVH6L7FM.js';
|
|
3
3
|
import './chunk-FN2BUFNM.js';
|
|
4
4
|
import './chunk-A72NWYNP.js';
|
|
5
5
|
import './chunk-GUIYFQ27.js';
|
|
6
|
-
import './chunk-
|
|
6
|
+
import './chunk-LLKAVT7F.js';
|
|
7
7
|
import './chunk-LZWZV2ZS.js';
|
|
8
8
|
import './chunk-Q6WTDVH6.js';
|
|
9
9
|
import './chunk-6QCILIT2.js';
|
package/dist/select.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SELECT_CSS, SELECT_STYLE_ID, Select, createSelect, decorateSelectScroll, fillSelectList, openSelectList, selectController, selectDef, selectVariants, toggleSelectList } from './chunk-
|
|
1
|
+
export { SELECT_CSS, SELECT_STYLE_ID, Select, createSelect, decorateSelectScroll, fillSelectList, openSelectList, selectController, selectDef, selectVariants, toggleSelectList } from './chunk-TMVE3R66.js';
|
|
2
2
|
import './chunk-BWSOMG3G.js';
|
|
3
3
|
import './chunk-J2QJATCD.js';
|
|
4
4
|
import './chunk-S7USVSYP.js';
|
|
@@ -8,7 +8,7 @@ import './chunk-MMTMOV6R.js';
|
|
|
8
8
|
import './chunk-3Q32K4PE.js';
|
|
9
9
|
import './chunk-A72NWYNP.js';
|
|
10
10
|
import './chunk-GUIYFQ27.js';
|
|
11
|
-
import './chunk-
|
|
11
|
+
import './chunk-LLKAVT7F.js';
|
|
12
12
|
import './chunk-LZWZV2ZS.js';
|
|
13
13
|
import './chunk-Q6WTDVH6.js';
|
|
14
14
|
import './chunk-6QCILIT2.js';
|
package/dist/sort-button.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { kitTranslator } from './chunk-FVH6L7FM.js';
|
|
2
2
|
import { msg, textOf } from './chunk-FN2BUFNM.js';
|
|
3
3
|
import { nextUid } from './chunk-GUIYFQ27.js';
|
|
4
|
-
import { iconEl } from './chunk-
|
|
4
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
5
5
|
import { variants } from './chunk-LZWZV2ZS.js';
|
|
6
6
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
7
7
|
import { t } from './chunk-6QCILIT2.js';
|
package/dist/tabs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ownTeardown } from './chunk-A72NWYNP.js';
|
|
2
2
|
import { nextUid, runMachine, normalizeProps, spreadProps } from './chunk-GUIYFQ27.js';
|
|
3
|
-
import { iconEl } from './chunk-
|
|
3
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
4
4
|
import { variants } from './chunk-LZWZV2ZS.js';
|
|
5
5
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
6
6
|
import { t } from './chunk-6QCILIT2.js';
|
package/dist/theme.schema.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"title": "@luxalgo/vela-ui 0.4.
|
|
3
|
+
"title": "@luxalgo/vela-ui 0.4.3 theme",
|
|
4
4
|
"description": "The input of createTheme. Every field is optional: an empty theme is the dark theme.",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"additionalProperties": false,
|
package/dist/toast.js
CHANGED
|
@@ -3,7 +3,7 @@ import { msg, textOf } from './chunk-FN2BUFNM.js';
|
|
|
3
3
|
import { ensureUIHost } from './chunk-RH53NQGE.js';
|
|
4
4
|
import './chunk-TAKSIV57.js';
|
|
5
5
|
import './chunk-MMTMOV6R.js';
|
|
6
|
-
import { iconEl } from './chunk-
|
|
6
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
7
7
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
8
8
|
import { t } from './chunk-6QCILIT2.js';
|
|
9
9
|
import { defineComponent } from './chunk-VMCR3S2A.js';
|
package/dist/toggle-group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ownTeardown } from './chunk-A72NWYNP.js';
|
|
2
2
|
import { nextUid, runMachine, normalizeProps, spreadProps } from './chunk-GUIYFQ27.js';
|
|
3
|
-
import { iconEl } from './chunk-
|
|
3
|
+
import { iconEl } from './chunk-LLKAVT7F.js';
|
|
4
4
|
import { variants } from './chunk-LZWZV2ZS.js';
|
|
5
5
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
6
6
|
import { t } from './chunk-6QCILIT2.js';
|
package/llms.txt
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxalgo/vela-ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "The component kit of Vela: one file per component, Zag state machines for behavior, CSS in cascade layers over design tokens.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "LuxAlgo",
|
|
@@ -394,6 +394,14 @@ interface SurfaceOptions {
|
|
|
394
394
|
submenu?: boolean;
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
/** The rectangle a menu level is placed against. */
|
|
398
|
+
interface AnchorRect {
|
|
399
|
+
x: number;
|
|
400
|
+
y: number;
|
|
401
|
+
width: number;
|
|
402
|
+
height: number;
|
|
403
|
+
}
|
|
404
|
+
|
|
397
405
|
/** How far a row sits inside its list: the list's padding (6px) plus its border (1px). */
|
|
398
406
|
const ROW_INSET_PX = 7;
|
|
399
407
|
/** The space between a submenu and the list it opened from. */
|
|
@@ -420,9 +428,12 @@ class Surface {
|
|
|
420
428
|
private items: readonly MenuItemDescriptor[] = [];
|
|
421
429
|
/** Branch item id → the surface it opens. */
|
|
422
430
|
private readonly subs = new Map<string, Surface>();
|
|
423
|
-
/**
|
|
424
|
-
*
|
|
425
|
-
|
|
431
|
+
/** What this level opened against, as an offset inside the host: its trigger's rect, or
|
|
432
|
+
* the point or rectangle `openAt` was given. Held in the host's space, not the
|
|
433
|
+
* viewport's, so the list keeps its place in the host: a trigger that then moves leaves
|
|
434
|
+
* it still (favorite chips shifting the caret), and a page that scrolls the host carries
|
|
435
|
+
* it along. Null on a submenu, which follows its row. */
|
|
436
|
+
private pinnedAnchor: AnchorRect | null = null;
|
|
426
437
|
/** The open state last announced — see {@link announce}. */
|
|
427
438
|
private shown = false;
|
|
428
439
|
/** The list's exit animation after a close; a reopen cancels it. */
|
|
@@ -454,14 +465,11 @@ class Surface {
|
|
|
454
465
|
id: opts.id,
|
|
455
466
|
...opts.placement,
|
|
456
467
|
onSelect: (id) => this.onSelect(id),
|
|
457
|
-
getAnchorRect: () => this.
|
|
468
|
+
getAnchorRect: () => this.anchorRect(),
|
|
458
469
|
onOpenChange: (open) => {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
} else {
|
|
463
|
-
this.pinnedAnchor = null;
|
|
464
|
-
}
|
|
470
|
+
// An anchor already there is the point this opening was asked at.
|
|
471
|
+
if (!open) this.pinnedAnchor = null;
|
|
472
|
+
else if (trigger && !this.pinnedAnchor) this.pin(trigger.getBoundingClientRect());
|
|
465
473
|
opts.onOpenChange?.(open);
|
|
466
474
|
},
|
|
467
475
|
triggerId: opts.triggerId,
|
|
@@ -512,6 +520,20 @@ class Surface {
|
|
|
512
520
|
return this.ctrl.connect(this.handle.service);
|
|
513
521
|
}
|
|
514
522
|
|
|
523
|
+
/** Anchor this level to `rect`, given in viewport coordinates. */
|
|
524
|
+
pin(rect: AnchorRect): void {
|
|
525
|
+
const origin = this.host.getBoundingClientRect();
|
|
526
|
+
this.pinnedAnchor = { x: rect.x - origin.x, y: rect.y - origin.y, width: rect.width, height: rect.height };
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/** The anchor in viewport coordinates, where the host stands now. */
|
|
530
|
+
anchorRect(): AnchorRect | null {
|
|
531
|
+
const anchor = this.pinnedAnchor;
|
|
532
|
+
if (!anchor) return null;
|
|
533
|
+
const origin = this.host.getBoundingClientRect();
|
|
534
|
+
return { x: origin.x + anchor.x, y: origin.y + anchor.y, width: anchor.width, height: anchor.height };
|
|
535
|
+
}
|
|
536
|
+
|
|
515
537
|
private announce(open: boolean): void {
|
|
516
538
|
this.shown = open;
|
|
517
539
|
announceSurface(this.list, open, 'menu', this.opener);
|
|
@@ -740,10 +762,21 @@ export class DropdownMenu {
|
|
|
740
762
|
}
|
|
741
763
|
|
|
742
764
|
/** Open anchored to a viewport point (context menus). */
|
|
743
|
-
openAt(clientX: number, clientY: number): void
|
|
765
|
+
openAt(clientX: number, clientY: number): void;
|
|
766
|
+
/** Open against a rectangle in viewport coordinates, such as the box of a button the menu
|
|
767
|
+
* does not own as its trigger (`button.getBoundingClientRect()`): on the menu's side of
|
|
768
|
+
* it, with its alignment and offsets, and on the rectangle's other side when that one
|
|
769
|
+
* lacks room. */
|
|
770
|
+
openAt(rect: { x: number; y: number; width: number; height: number }): void;
|
|
771
|
+
openAt(at: number | { x: number; y: number; width: number; height: number }, clientY = 0): void {
|
|
772
|
+
// Read now: the caller's rectangle may be one it goes on changing.
|
|
773
|
+
const rect: AnchorRect = typeof at === 'number' ? { x: at, y: clientY, width: 0, height: 0 } : { x: at.x, y: at.y, width: at.width, height: at.height };
|
|
744
774
|
const api = this.api;
|
|
775
|
+
// Queued, as the machine's own events are: a close still under way lands first, and
|
|
776
|
+
// must not take this anchor with it.
|
|
777
|
+
queueMicrotask(() => this.root.pin(rect));
|
|
745
778
|
api.setOpen(true);
|
|
746
|
-
api.reposition({ getAnchorRect: () => (
|
|
779
|
+
api.reposition({ getAnchorRect: () => this.root.anchorRect() });
|
|
747
780
|
}
|
|
748
781
|
|
|
749
782
|
close(): void {
|
package/registry/field.ts
CHANGED
|
@@ -144,6 +144,11 @@ const injectFieldStyles = defineStyles(
|
|
|
144
144
|
&[data-variant='inputs'][data-first] {
|
|
145
145
|
padding-top: 4px;
|
|
146
146
|
}
|
|
147
|
+
&[data-info]:where(:not([hidden])) {
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 6px;
|
|
151
|
+
}
|
|
147
152
|
}
|
|
148
153
|
[data-slot~='field-sep'] {
|
|
149
154
|
grid-column: 1 / -1;
|
|
@@ -187,6 +192,8 @@ export function fieldGrid(opts: FieldGridOptions = {}): HTMLElement {
|
|
|
187
192
|
export interface FieldSectionOptions {
|
|
188
193
|
variant?: FieldGridVariant;
|
|
189
194
|
first?: boolean;
|
|
195
|
+
/** Placed after the heading text and centered on it, such as a help mark. */
|
|
196
|
+
info?: HTMLElement;
|
|
190
197
|
}
|
|
191
198
|
|
|
192
199
|
/** Uppercase group heading that spans the field grid. */
|
|
@@ -197,6 +204,10 @@ export function fieldSection(title: string, opts: FieldSectionOptions = {}): HTM
|
|
|
197
204
|
if (opts.variant) el.dataset.variant = opts.variant;
|
|
198
205
|
if (opts.first) el.dataset.first = '';
|
|
199
206
|
el.textContent = title;
|
|
207
|
+
if (opts.info) {
|
|
208
|
+
el.dataset.info = '';
|
|
209
|
+
el.appendChild(opts.info);
|
|
210
|
+
}
|
|
200
211
|
return el;
|
|
201
212
|
}
|
|
202
213
|
|
|
@@ -394,6 +394,14 @@ interface SurfaceOptions {
|
|
|
394
394
|
submenu?: boolean;
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
/** The rectangle a menu level is placed against. */
|
|
398
|
+
interface AnchorRect {
|
|
399
|
+
x: number;
|
|
400
|
+
y: number;
|
|
401
|
+
width: number;
|
|
402
|
+
height: number;
|
|
403
|
+
}
|
|
404
|
+
|
|
397
405
|
/** How far a row sits inside its list: the list's padding (6px) plus its border (1px). */
|
|
398
406
|
const ROW_INSET_PX = 7;
|
|
399
407
|
/** The space between a submenu and the list it opened from. */
|
|
@@ -420,9 +428,12 @@ class Surface {
|
|
|
420
428
|
private items: readonly MenuItemDescriptor[] = [];
|
|
421
429
|
/** Branch item id → the surface it opens. */
|
|
422
430
|
private readonly subs = new Map<string, Surface>();
|
|
423
|
-
/**
|
|
424
|
-
*
|
|
425
|
-
|
|
431
|
+
/** What this level opened against, as an offset inside the host: its trigger's rect, or
|
|
432
|
+
* the point or rectangle `openAt` was given. Held in the host's space, not the
|
|
433
|
+
* viewport's, so the list keeps its place in the host: a trigger that then moves leaves
|
|
434
|
+
* it still (favorite chips shifting the caret), and a page that scrolls the host carries
|
|
435
|
+
* it along. Null on a submenu, which follows its row. */
|
|
436
|
+
private pinnedAnchor: AnchorRect | null = null;
|
|
426
437
|
/** The open state last announced — see {@link announce}. */
|
|
427
438
|
private shown = false;
|
|
428
439
|
/** The list's exit animation after a close; a reopen cancels it. */
|
|
@@ -454,14 +465,11 @@ class Surface {
|
|
|
454
465
|
id: opts.id,
|
|
455
466
|
...opts.placement,
|
|
456
467
|
onSelect: (id) => this.onSelect(id),
|
|
457
|
-
getAnchorRect: () => this.
|
|
468
|
+
getAnchorRect: () => this.anchorRect(),
|
|
458
469
|
onOpenChange: (open) => {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
} else {
|
|
463
|
-
this.pinnedAnchor = null;
|
|
464
|
-
}
|
|
470
|
+
// An anchor already there is the point this opening was asked at.
|
|
471
|
+
if (!open) this.pinnedAnchor = null;
|
|
472
|
+
else if (trigger && !this.pinnedAnchor) this.pin(trigger.getBoundingClientRect());
|
|
465
473
|
opts.onOpenChange?.(open);
|
|
466
474
|
},
|
|
467
475
|
triggerId: opts.triggerId,
|
|
@@ -512,6 +520,20 @@ class Surface {
|
|
|
512
520
|
return this.ctrl.connect(this.handle.service);
|
|
513
521
|
}
|
|
514
522
|
|
|
523
|
+
/** Anchor this level to `rect`, given in viewport coordinates. */
|
|
524
|
+
pin(rect: AnchorRect): void {
|
|
525
|
+
const origin = this.host.getBoundingClientRect();
|
|
526
|
+
this.pinnedAnchor = { x: rect.x - origin.x, y: rect.y - origin.y, width: rect.width, height: rect.height };
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/** The anchor in viewport coordinates, where the host stands now. */
|
|
530
|
+
anchorRect(): AnchorRect | null {
|
|
531
|
+
const anchor = this.pinnedAnchor;
|
|
532
|
+
if (!anchor) return null;
|
|
533
|
+
const origin = this.host.getBoundingClientRect();
|
|
534
|
+
return { x: origin.x + anchor.x, y: origin.y + anchor.y, width: anchor.width, height: anchor.height };
|
|
535
|
+
}
|
|
536
|
+
|
|
515
537
|
private announce(open: boolean): void {
|
|
516
538
|
this.shown = open;
|
|
517
539
|
announceSurface(this.list, open, 'menu', this.opener);
|
|
@@ -740,10 +762,21 @@ export class DropdownMenu {
|
|
|
740
762
|
}
|
|
741
763
|
|
|
742
764
|
/** Open anchored to a viewport point (context menus). */
|
|
743
|
-
openAt(clientX: number, clientY: number): void
|
|
765
|
+
openAt(clientX: number, clientY: number): void;
|
|
766
|
+
/** Open against a rectangle in viewport coordinates, such as the box of a button the menu
|
|
767
|
+
* does not own as its trigger (`button.getBoundingClientRect()`): on the menu's side of
|
|
768
|
+
* it, with its alignment and offsets, and on the rectangle's other side when that one
|
|
769
|
+
* lacks room. */
|
|
770
|
+
openAt(rect: { x: number; y: number; width: number; height: number }): void;
|
|
771
|
+
openAt(at: number | { x: number; y: number; width: number; height: number }, clientY = 0): void {
|
|
772
|
+
// Read now: the caller's rectangle may be one it goes on changing.
|
|
773
|
+
const rect: AnchorRect = typeof at === 'number' ? { x: at, y: clientY, width: 0, height: 0 } : { x: at.x, y: at.y, width: at.width, height: at.height };
|
|
744
774
|
const api = this.api;
|
|
775
|
+
// Queued, as the machine's own events are: a close still under way lands first, and
|
|
776
|
+
// must not take this anchor with it.
|
|
777
|
+
queueMicrotask(() => this.root.pin(rect));
|
|
745
778
|
api.setOpen(true);
|
|
746
|
-
api.reposition({ getAnchorRect: () => (
|
|
779
|
+
api.reposition({ getAnchorRect: () => this.root.anchorRect() });
|
|
747
780
|
}
|
|
748
781
|
|
|
749
782
|
close(): void {
|
package/src/components/field.ts
CHANGED
|
@@ -144,6 +144,11 @@ const injectFieldStyles = defineStyles(
|
|
|
144
144
|
&[data-variant='inputs'][data-first] {
|
|
145
145
|
padding-top: 4px;
|
|
146
146
|
}
|
|
147
|
+
&[data-info]:where(:not([hidden])) {
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 6px;
|
|
151
|
+
}
|
|
147
152
|
}
|
|
148
153
|
[data-slot~='field-sep'] {
|
|
149
154
|
grid-column: 1 / -1;
|
|
@@ -187,6 +192,8 @@ export function fieldGrid(opts: FieldGridOptions = {}): HTMLElement {
|
|
|
187
192
|
export interface FieldSectionOptions {
|
|
188
193
|
variant?: FieldGridVariant;
|
|
189
194
|
first?: boolean;
|
|
195
|
+
/** Placed after the heading text and centered on it, such as a help mark. */
|
|
196
|
+
info?: HTMLElement;
|
|
190
197
|
}
|
|
191
198
|
|
|
192
199
|
/** Uppercase group heading that spans the field grid. */
|
|
@@ -197,6 +204,10 @@ export function fieldSection(title: string, opts: FieldSectionOptions = {}): HTM
|
|
|
197
204
|
if (opts.variant) el.dataset.variant = opts.variant;
|
|
198
205
|
if (opts.first) el.dataset.first = '';
|
|
199
206
|
el.textContent = title;
|
|
207
|
+
if (opts.info) {
|
|
208
|
+
el.dataset.info = '';
|
|
209
|
+
el.appendChild(opts.info);
|
|
210
|
+
}
|
|
200
211
|
return el;
|
|
201
212
|
}
|
|
202
213
|
|
package/src/lib/icons.ts
CHANGED
|
@@ -185,6 +185,8 @@ registerIcon('burger', S('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));
|
|
|
185
185
|
// The ⓘ hint glyph: an "i" drawn as geometry (dot + stem) so it centers exactly in its
|
|
186
186
|
// badge — a text "i" would sit at the font's mercy. The badge draws the circle.
|
|
187
187
|
registerIcon('info', S('<path d="M8 7.4v4.4"/><circle cx="8" cy="4.6" r="0.9" fill="currentColor" stroke="none"/>'));
|
|
188
|
+
// The help mark's glyph, a question mark drawn the same way: the badge draws the circle.
|
|
189
|
+
registerIcon('help', S('<path d="M6.1 6a1.9 1.9 0 1 1 2.85 1.65c-.6.3-.95.7-.95 1.25v.45"/><circle cx="8" cy="11.5" r="0.9" fill="currentColor" stroke="none"/>'));
|
|
188
190
|
registerIcon('reset', S('<path d="M2 8a6 6 0 1 0 6-6 6.5 6.5 0 0 0-4.5 1.83L2 5.33"/><path d="M2 2v3.33h3.33"/>'));
|
|
189
191
|
|
|
190
192
|
// ── status glyphs (toasts, notices) ──
|