vintage-frames 0.7.2 → 0.9.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/custom-elements.json +891 -63
- package/dist/components/vf-desktop.d.ts +4 -2
- package/dist/components/vf-desktop.js +2 -2
- package/dist/components/vf-dialog.d.ts +17 -20
- package/dist/components/vf-dialog.js +73 -135
- package/dist/components/vf-icon.d.ts +15 -5
- package/dist/components/vf-icon.js +38 -41
- package/dist/components/vf-scroll-area.d.ts +4 -2
- package/dist/components/vf-scroll-area.js +2 -2
- package/dist/components/vf-window.d.ts +4 -2
- package/dist/components/vf-window.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/open-art.d.ts +24 -11
- package/dist/open-art.js +18 -16
- package/dist/position.d.ts +55 -6
- package/dist/position.js +120 -58
- package/docs/SPEC.md +15 -15
- package/editor/vscode.html-custom-data.json +159 -4
- package/editor/web-types.json +318 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37,11 +37,11 @@ import { ScrollRailController as it, renderScrollRail as at } from "./scroll-rai
|
|
|
37
37
|
import { VfScrollArea as ot } from "./components/vf-scroll-area.js";
|
|
38
38
|
import { VfWindow as st } from "./components/vf-window.js";
|
|
39
39
|
import { VfModalDialog as ct, modalDialogStyles as lt } from "./modal-dialog.js";
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
40
|
+
import { VfDialog as ut } from "./components/vf-dialog.js";
|
|
41
|
+
import { VfSeparator as dt } from "./components/vf-separator.js";
|
|
42
|
+
import { VfFormControl as ft } from "./form-control.js";
|
|
43
|
+
import { VfButton as pt } from "./components/vf-button.js";
|
|
44
|
+
import { VfButtonGroup as mt } from "./components/vf-button-group.js";
|
|
45
45
|
import { VfSwatch as ht } from "./components/vf-swatch.js";
|
|
46
46
|
import { VfToggleControl as gt } from "./toggle-control.js";
|
|
47
47
|
import { VfCheckbox as _t } from "./components/vf-checkbox.js";
|
|
@@ -72,4 +72,4 @@ import { VfStack as Ut } from "./components/vf-stack.js";
|
|
|
72
72
|
import { VfContainer as Wt } from "./components/vf-container.js";
|
|
73
73
|
import { CURSOR_ARROW as Gt, CURSOR_CROSSHAIR as Kt, CURSOR_I_BEAM as qt, CURSOR_WAIT as Jt } from "./cursor-art.js";
|
|
74
74
|
import { applyCursor as Yt } from "./cursor.js";
|
|
75
|
-
export { ze as BLINK_FLIPS, Be as BLINK_INTERVAL_MS, Ee as BUTTON_FACE, De as BUTTON_FRAME, Ge as CARET_DOWN, Ke as CHECKBOX_X, qe as CHECKMARK, r as CLASSIC_DPI, i as CSS_REFERENCE_DPI, Gt as CURSOR_ARROW, Kt as CURSOR_CROSSHAIR, qt as CURSOR_I_BEAM, Jt as CURSOR_WAIT, Te as DocumentListenersController, Le as DragController, bt as FocusRuleController, Ce as GridSnapController, G as PATTERNS, K as PATTERN_NAMES, q as PATTERN_SIZE, D as PIXEL_GRID_METRICS, Ve as PRESS_HOLD_MS, xe as PatternFillController, T as PlacementController, Je as RADIO_DOT, Ye as RADIO_FACE, Xe as RADIO_RING, Ze as RADIO_RING_PRESSED, He as RENAME_DELAY_MS, Oe as RING_FRAME, ke as RING_HOLE, Ae as RING_INSET, ie as RULE_EDGES, je as SCREEN_CORNER, Qe as SLIDER_THUMB, $e as SLIDER_THUMB_FACE, et as STEPPER, tt as STEPPER_DOWN_FILL, nt as STEPPER_UP_FILL, a as SYSTEM_PX_IN_CSS_PX, d as ScaleController, it as ScrollRailController, Re as ScrollStateController, R as TILE_LATTICE, ge as TileRasterCache, be as TrackWidthController, k as VF_BODY_FAMILY, M as VF_DISPLAY_FAMILY,
|
|
75
|
+
export { ze as BLINK_FLIPS, Be as BLINK_INTERVAL_MS, Ee as BUTTON_FACE, De as BUTTON_FRAME, Ge as CARET_DOWN, Ke as CHECKBOX_X, qe as CHECKMARK, r as CLASSIC_DPI, i as CSS_REFERENCE_DPI, Gt as CURSOR_ARROW, Kt as CURSOR_CROSSHAIR, qt as CURSOR_I_BEAM, Jt as CURSOR_WAIT, Te as DocumentListenersController, Le as DragController, bt as FocusRuleController, Ce as GridSnapController, G as PATTERNS, K as PATTERN_NAMES, q as PATTERN_SIZE, D as PIXEL_GRID_METRICS, Ve as PRESS_HOLD_MS, xe as PatternFillController, T as PlacementController, Je as RADIO_DOT, Ye as RADIO_FACE, Xe as RADIO_RING, Ze as RADIO_RING_PRESSED, He as RENAME_DELAY_MS, Oe as RING_FRAME, ke as RING_HOLE, Ae as RING_INSET, ie as RULE_EDGES, je as SCREEN_CORNER, Qe as SLIDER_THUMB, $e as SLIDER_THUMB_FACE, et as STEPPER, tt as STEPPER_DOWN_FILL, nt as STEPPER_UP_FILL, a as SYSTEM_PX_IN_CSS_PX, d as ScaleController, it as ScrollRailController, Re as ScrollStateController, R as TILE_LATTICE, ge as TileRasterCache, be as TrackWidthController, k as VF_BODY_FAMILY, M as VF_DISPLAY_FAMILY, pt as VfButton, mt as VfButtonGroup, _t as VfCheckbox, Wt as VfContainer, Fe as VfDesktop, ut as VfDialog, Vt as VfFieldset, ft as VfFormControl, Ht as VfGrid, Pt as VfIcon, Ft as VfIconField, Nt as VfImg, jt as VfLabel, zt as VfList, Bt as VfListItem, Lt as VfMenu, It as VfMenuBar, Rt as VfMenuItem, ct as VfModalDialog, Et as VfNumberField, Dt as VfOption, Mt as VfParagraph, E as VfPositioned, kt as VfProgressBar, vt as VfRadio, yt as VfRadioGroup, ot as VfScrollArea, Ot as VfSelect, dt as VfSeparator, Ie as VfSized, At as VfSlider, Ut as VfStack, ht as VfSwatch, Tt as VfTextArea, Ct as VfTextControlBase, wt as VfTextField, gt as VfToggleControl, st as VfWindow, Yt as applyCursor, f as applyScale, t as defineElement, o as devicePxPerSystemPx, p as effectiveScale, e as emit, xt as focusModality, m as getScale, s as getZoom, rt as glyphSvg, lt as modalDialogStyles, h as onScaleChange, c as onZoomChange, J as parsePattern, ae as parseRule, Y as patternHex, X as patternMotif, _e as patternOverride, Z as patternRects, Ue as prefersReducedMotion, A as registerBodyFace, N as registerDisplayFace, O as registerEmbeddedFont, at as renderScrollRail, we as requestGridSnap, l as resetZoomBaseline, oe as ruleClasses, We as runSelectionBlink, g as snapSys, _ as snapToDevicePx, v as snapToSystemPx, Me as steppedCornerClip, Ne as steppedRectClip, Pe as steppedRingClip, y as sys, b as sysLength, x as sysLengths, S as systemPxQuantum, ve as tileGrid, z as tileImage, B as tileRaster, V as tileRects, H as tileSpan, C as toSys, w as toSysExact, St as trackFocusModality, u as truePixelRatio, I as vfBase, j as vfBodyDecls, te as vfChromeFrame, P as vfDisplay, F as vfDisplayDecls, Q as vfDots, n as vfElement, me as vfField, ue as vfFocus, de as vfFocusRing, fe as vfFocusUnderline, ee as vfHardShadowDecls, ne as vfModalFrame, re as vfPanel, Se as vfPatternFill, se as vfRule, he as vfScrollRail, L as vfStaticText, $ as vfStripes, ye as vfTileGrid, U as vfTileMaskSize, W as vfTileSize, ce as vfTitleBar, pe as vfToggle, le as vfWindowWidgets };
|
package/dist/open-art.d.ts
CHANGED
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
* where the source is opaque, so intersecting the silhouette with itself
|
|
25
25
|
* shifted one pixel each way leaves exactly the pixels whose neighbors are
|
|
26
26
|
* all opaque — the interior. The ring the erosion removes is the outline.
|
|
27
|
+
* The ghost erodes with the four edge neighbors; the drag outline with all
|
|
28
|
+
* eight, a region inset — {@link deriveDragOutline} says why it matters.
|
|
27
29
|
*/
|
|
28
30
|
/**
|
|
29
31
|
* Derive the open ghost from an icon's art: a canvas at the art's natural
|
|
@@ -39,7 +41,7 @@
|
|
|
39
41
|
* an environment refusing a 2d context.
|
|
40
42
|
*/
|
|
41
43
|
export declare function deriveOpenArt(art: HTMLImageElement | HTMLCanvasElement): HTMLCanvasElement | null;
|
|
42
|
-
/** A box inside
|
|
44
|
+
/** A box inside the outline's box, in system px. */
|
|
43
45
|
export interface DragOutlineBox {
|
|
44
46
|
x: number;
|
|
45
47
|
y: number;
|
|
@@ -47,11 +49,12 @@ export interface DragOutlineBox {
|
|
|
47
49
|
height: number;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
|
-
* Where an icon's parts sit inside
|
|
51
|
-
* icon, so the outline lands on the same pixels the frame
|
|
52
|
+
* Where an icon's parts sit inside the outline's box, in system px —
|
|
53
|
+
* measured by the icon, so the outline lands on the same pixels the frame
|
|
54
|
+
* paints.
|
|
52
55
|
*/
|
|
53
56
|
export interface DragOutlineGeometry {
|
|
54
|
-
/** The frame. */
|
|
57
|
+
/** The outline's box: the frame, widened to a name plate that overhangs it. */
|
|
55
58
|
width: number;
|
|
56
59
|
height: number;
|
|
57
60
|
/**
|
|
@@ -66,18 +69,28 @@ export interface DragOutlineGeometry {
|
|
|
66
69
|
plate: DragOutlineBox | null;
|
|
67
70
|
}
|
|
68
71
|
/**
|
|
69
|
-
* Derive the outline an icon drags as: the
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
72
|
+
* Derive the outline an icon drags as: the boundary of the mask united with
|
|
73
|
+
* the name plate's rectangle — one shape, the one-pixel ring a 3×3 box
|
|
74
|
+
* erosion removes from it, so where the art and the plate abut the outline
|
|
75
|
+
* wraps around both — solid black on transparent, one canvas the size of
|
|
76
|
+
* the outline's box (the icon's frame, widened to a plate that overhangs
|
|
77
|
+
* it) at one image px per system px. Not yet dotted: the ring is derived
|
|
78
|
+
* once per drag, and {@link dotOutline} re-applies the checker at each
|
|
79
|
+
* step's phase.
|
|
80
|
+
*
|
|
81
|
+
* The box, not the ghost's four-neighbor plus: it is the region inset
|
|
82
|
+
* `FrameRgn` painted a frame from, and the difference shows on a 45° edge.
|
|
83
|
+
* A one-pixel diagonal is all one parity of the checker, so the pen would
|
|
84
|
+
* keep all of it or none — and over the dither "none" is the dither's own
|
|
85
|
+
* ink diagonal, no line at all. Under the box a 45° edge is two pixels
|
|
86
|
+
* wide and carries both parities, so one full diagonal of dots survives at
|
|
87
|
+
* either phase.
|
|
75
88
|
*
|
|
76
89
|
* Art the pipeline cannot draw falls back to the cell's rectangle — the
|
|
77
90
|
* ghost's rule: never a blank where a state cannot show. Compositing only,
|
|
78
91
|
* never a readback, so cross-origin art derives too.
|
|
79
92
|
*
|
|
80
|
-
* Returns null for a
|
|
93
|
+
* Returns null for a box with no size, or an environment refusing a 2d
|
|
81
94
|
* context.
|
|
82
95
|
*/
|
|
83
96
|
export declare function deriveDragOutline(art: HTMLImageElement | HTMLCanvasElement | null, geometry: DragOutlineGeometry): HTMLCanvasElement | null;
|
package/dist/open-art.js
CHANGED
|
@@ -44,22 +44,24 @@ var i = null, a = () => {
|
|
|
44
44
|
function s(t, n) {
|
|
45
45
|
let { width: r, height: i } = n;
|
|
46
46
|
if (!r || !i) return null;
|
|
47
|
-
let a = e(r, i);
|
|
48
|
-
if (!a) return null;
|
|
49
|
-
let
|
|
50
|
-
if (t &&
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
let a = e(r, i), o = e(r, i), s = e(r, i);
|
|
48
|
+
if (!a || !o || !s) return null;
|
|
49
|
+
let c = t ? n.art : null;
|
|
50
|
+
if (t && c && c.width > 0 && c.height > 0 ? (a.ctx.drawImage(t, c.x, c.y, c.width, c.height), a.ctx.globalCompositeOperation = "source-in", a.ctx.fillStyle = "#000", a.ctx.fillRect(0, 0, r, i), a.ctx.globalCompositeOperation = "destination-in", a.ctx.fillRect(n.cell.x, n.cell.y, n.cell.width, n.cell.height), a.ctx.globalCompositeOperation = "source-over") : (a.ctx.fillStyle = "#000", a.ctx.fillRect(n.cell.x, n.cell.y, n.cell.width, n.cell.height)), n.plate) {
|
|
51
|
+
let e = n.plate;
|
|
52
|
+
a.ctx.fillStyle = "#000", a.ctx.fillRect(e.x, e.y, e.width, e.height);
|
|
53
|
+
}
|
|
54
|
+
o.ctx.drawImage(a.canvas, 0, 0), o.ctx.globalCompositeOperation = "destination-in";
|
|
55
|
+
for (let e of [
|
|
56
|
+
-1,
|
|
57
|
+
0,
|
|
58
|
+
1
|
|
59
|
+
]) for (let t of [
|
|
60
|
+
-1,
|
|
61
|
+
0,
|
|
62
|
+
1
|
|
63
|
+
]) (e || t) && o.ctx.drawImage(a.canvas, e, t);
|
|
64
|
+
return s.ctx.drawImage(a.canvas, 0, 0), s.ctx.globalCompositeOperation = "destination-out", s.ctx.drawImage(o.canvas, 0, 0), s.ctx.globalCompositeOperation = "source-over", s.canvas;
|
|
63
65
|
}
|
|
64
66
|
function c(e, t) {
|
|
65
67
|
return +(((e + t) % 2 + 2) % 2 == 0);
|
package/dist/position.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { LitElement } from 'lit';
|
|
2
2
|
type Constructor<T = object> = new (...args: any[]) => T;
|
|
3
|
+
/**
|
|
4
|
+
* The nine placement origins — which point of a placed element's own box
|
|
5
|
+
* `left`/`top` place, the vertical keyword first. `top left` is the default.
|
|
6
|
+
*/
|
|
7
|
+
export type PlacementOrigin = 'top left' | 'top center' | 'top right' | 'center left' | 'center' | 'center right' | 'bottom left' | 'bottom center' | 'bottom right';
|
|
8
|
+
/** A system-px offset, `{ x, y }`. */
|
|
9
|
+
type Offset = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
3
13
|
/**
|
|
4
14
|
* The mixin's surface, as a `declare class` for the same TS4094 reason
|
|
5
15
|
* {@link VfToggleControlInterface} states: TypeScript cannot name the
|
|
@@ -10,12 +20,14 @@ export declare abstract class VfPositionedInterface extends LitElement {
|
|
|
10
20
|
top?: number | null;
|
|
11
21
|
left?: number | null;
|
|
12
22
|
fixed: boolean;
|
|
23
|
+
origin?: PlacementOrigin | null;
|
|
13
24
|
}
|
|
14
|
-
/** A host that takes the placement trio. */
|
|
25
|
+
/** A host that takes the placement trio and its origin. */
|
|
15
26
|
type PositionedHost = HTMLElement & {
|
|
16
27
|
top?: number | null;
|
|
17
28
|
left?: number | null;
|
|
18
29
|
fixed?: boolean;
|
|
30
|
+
origin?: string | null;
|
|
19
31
|
};
|
|
20
32
|
/**
|
|
21
33
|
* Explicit placement — `top`/`left` in whole system px, on **every** component.
|
|
@@ -52,9 +64,9 @@ type PositionedHost = HTMLElement & {
|
|
|
52
64
|
*
|
|
53
65
|
* The anchor is CSS's own: the nearest positioned ancestor's padding box. The
|
|
54
66
|
* kit's containers are all deliberate anchors — a desktop's raster, a window's
|
|
55
|
-
* content region (the frame's inner edge, below
|
|
56
|
-
* inset
|
|
57
|
-
*
|
|
67
|
+
* or a dialog's content region (the frame's inner edge, below any title bar,
|
|
68
|
+
* with no inset — flow content starts there too, exactly the DITL
|
|
69
|
+
* convention), a stack's box, a fieldset's border box, a scroll area's
|
|
58
70
|
* scrolled plane. In a non-kit parent, give the parent `position: relative`,
|
|
59
71
|
* the one line of CSS this feature can't write for you.
|
|
60
72
|
*
|
|
@@ -94,6 +106,27 @@ type PositionedHost = HTMLElement & {
|
|
|
94
106
|
* plane's box is never grown by an absolutely positioned child. One funnel
|
|
95
107
|
* covers a drop, an arrow nudge and a page's own `icon.left = …` alike.
|
|
96
108
|
*
|
|
109
|
+
* **`origin`** names which point of the host's own box the pair places —
|
|
110
|
+
* nine keywords, vertical then horizontal (`top center`, `bottom right`,
|
|
111
|
+
* `center`), `top left` the default. A title stays centered on its `left`
|
|
112
|
+
* whatever its text; a button group keeps its bottom-right corner in from
|
|
113
|
+
* the dialog's however long its labels run. The point is measured, not
|
|
114
|
+
* transformed: the controller reads the host's border box in whole system px
|
|
115
|
+
* (w × h) and writes `left` as the stated `L` less ⌈w·fx⌉ (`fx` 0, ½ or 1),
|
|
116
|
+
* `top` the same way — the ceiling sends an odd size's leftover half toward
|
|
117
|
+
* the start, the tie rule the kit's other centering uses. A ResizeObserver
|
|
118
|
+
* keeps the offset current through a relabel or a late font, and each such
|
|
119
|
+
* rewrite is announced like any other write. A zoom step changes CSS px, not
|
|
120
|
+
* system px, so it recomputes the same offset. `translate: -50% 0` would have
|
|
121
|
+
* been the no-JavaScript version, and fails twice: a percentage of an odd
|
|
122
|
+
* width is half a pixel, which smears the 1-bit art, and a transform makes
|
|
123
|
+
* the host the containing block for `position: fixed` descendants — a placed
|
|
124
|
+
* group holding a `vf-select` would trap its list. `top left` is the plain
|
|
125
|
+
* code path: no observer, no measurement, the same inline style as before
|
|
126
|
+
* the attribute existed. An unknown value places as `top left` and warns once
|
|
127
|
+
* per element. On its own the attribute places nothing: it changes what the
|
|
128
|
+
* pair means, and is inert on a host in flow.
|
|
129
|
+
*
|
|
97
130
|
* **`fixed`** holds the placement against the *visible* region of the nearest
|
|
98
131
|
* scrolling ancestor instead of its scrolled plane — a tool strip over a
|
|
99
132
|
* document, a column header over rows — and the flag alone places at (0,0).
|
|
@@ -127,8 +160,12 @@ export declare const VfPositioned: <T extends Constructor<LitElement>>(Base: T)
|
|
|
127
160
|
* expected to carry no border of its own (the three do not), so its border
|
|
128
161
|
* box is its padding box; `scaleAt` is the element whose `--vf-scale` the
|
|
129
162
|
* conversion reads — the component's host.
|
|
163
|
+
*
|
|
164
|
+
* With `child`, the pair to write to *that* element so its box's corner
|
|
165
|
+
* lands on the point: the offset its `origin` adds is folded in, and is zero
|
|
166
|
+
* for a child with none.
|
|
130
167
|
*/
|
|
131
|
-
export declare function placementIn(anchor: Element, clientX: number, clientY: number, scaleAt?: Element): {
|
|
168
|
+
export declare function placementIn(anchor: Element, clientX: number, clientY: number, scaleAt?: Element, child?: Element): {
|
|
132
169
|
left: number;
|
|
133
170
|
top: number;
|
|
134
171
|
};
|
|
@@ -191,7 +228,14 @@ export declare class PlacementController {
|
|
|
191
228
|
*/
|
|
192
229
|
get bounds(): PlacementBounds;
|
|
193
230
|
/**
|
|
194
|
-
* The
|
|
231
|
+
* The offset the host's stated pair sits from its box's top-left corner,
|
|
232
|
+
* in whole system px — what its `origin` adds, `(0, 0)` without one. A
|
|
233
|
+
* group drag reads it to clamp each member's box rather than its pair.
|
|
234
|
+
*/
|
|
235
|
+
get offset(): Readonly<Offset>;
|
|
236
|
+
/**
|
|
237
|
+
* The origin a move adds its delta to, in system px — the stated pair,
|
|
238
|
+
* which with an `origin` is the origin point rather than the corner.
|
|
195
239
|
*
|
|
196
240
|
* A stated coordinate is authoritative and needs no measuring — including
|
|
197
241
|
* the one this controller wrote last time. Otherwise the host is wherever
|
|
@@ -200,6 +244,7 @@ export declare class PlacementController {
|
|
|
200
244
|
* (`left: 10%` and `left: 1em` are perfectly good ways to place one, and
|
|
201
245
|
* both resolve to px here), everything else through its in-flow offset,
|
|
202
246
|
* which is measured against the same padding box `left`/`top` will be.
|
|
247
|
+
* That read is the corner, so the origin's offset is added back.
|
|
203
248
|
*/
|
|
204
249
|
seed(): {
|
|
205
250
|
x: number;
|
|
@@ -221,6 +266,10 @@ export declare class PlacementController {
|
|
|
221
266
|
* the gesture into that phantom, walking the host to the parent's origin
|
|
222
267
|
* while the user drags away from it. The box at the moment of the press is
|
|
223
268
|
* the one the user is pushing against.
|
|
269
|
+
*
|
|
270
|
+
* The pair is the origin point; the clamp is a rule about the *box*. So
|
|
271
|
+
* the origin's offset comes off before the clamp and goes back on after,
|
|
272
|
+
* and a dragged title stays centered on wherever it was dropped.
|
|
224
273
|
*/
|
|
225
274
|
moveTo(x: number, y: number): void;
|
|
226
275
|
}
|
package/dist/position.js
CHANGED
|
@@ -1,99 +1,158 @@
|
|
|
1
1
|
import { emit as e } from "./events.js";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { property as
|
|
2
|
+
import { effectiveScale as t, snapSys as n, sysLength as r, toSysExact as i } from "./scale.js";
|
|
3
|
+
import a from "./_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/decorate.js";
|
|
4
|
+
import { property as o } from "lit/decorators.js";
|
|
5
5
|
//#region src/position.ts
|
|
6
|
-
var
|
|
6
|
+
var s = /* @__PURE__ */ new Map([
|
|
7
|
+
["top left", [0, 0]],
|
|
8
|
+
["top center", [.5, 0]],
|
|
9
|
+
["top right", [1, 0]],
|
|
10
|
+
["center left", [0, .5]],
|
|
11
|
+
["center", [.5, .5]],
|
|
12
|
+
["center right", [1, .5]],
|
|
13
|
+
["bottom left", [0, 1]],
|
|
14
|
+
["bottom center", [.5, 1]],
|
|
15
|
+
["bottom right", [1, 1]]
|
|
16
|
+
]), c = s.get("top left"), l = {
|
|
17
|
+
x: 0,
|
|
18
|
+
y: 0
|
|
19
|
+
};
|
|
20
|
+
function u(e, t, [n, r], i) {
|
|
21
|
+
return {
|
|
22
|
+
x: Math.ceil(Math.round(e / i) * n),
|
|
23
|
+
y: Math.ceil(Math.round(t / i) * r)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var d = {
|
|
7
27
|
inline: "block",
|
|
8
28
|
"inline-block": "block",
|
|
9
29
|
"inline-flex": "flex",
|
|
10
30
|
"inline-grid": "grid",
|
|
11
31
|
"inline-table": "table"
|
|
12
|
-
},
|
|
32
|
+
}, f = (e) => {
|
|
13
33
|
class t extends e {
|
|
14
34
|
constructor(...e) {
|
|
15
|
-
super(...e), this.fixed = !1, new
|
|
35
|
+
super(...e), this.fixed = !1, new h(this);
|
|
16
36
|
}
|
|
17
37
|
}
|
|
18
|
-
return
|
|
38
|
+
return a([o({ type: Number })], t.prototype, "top", void 0), a([o({ type: Number })], t.prototype, "left", void 0), a([o({
|
|
19
39
|
type: Boolean,
|
|
20
40
|
reflect: !0
|
|
21
|
-
})], t.prototype, "fixed", void 0), t;
|
|
22
|
-
},
|
|
41
|
+
})], t.prototype, "fixed", void 0), a([o({ reflect: !0 })], t.prototype, "origin", void 0), t;
|
|
42
|
+
}, p = /* @__PURE__ */ new WeakMap();
|
|
43
|
+
function m(e) {
|
|
44
|
+
return p.get(e)?.offset ?? l;
|
|
45
|
+
}
|
|
46
|
+
var h = class {
|
|
23
47
|
#e;
|
|
24
48
|
#t = null;
|
|
25
49
|
#n = null;
|
|
26
50
|
#r = !1;
|
|
27
|
-
#i =
|
|
28
|
-
#a =
|
|
51
|
+
#i = null;
|
|
52
|
+
#a = !1;
|
|
53
|
+
#o = null;
|
|
54
|
+
#s = c;
|
|
55
|
+
#c = !1;
|
|
56
|
+
#l = !1;
|
|
57
|
+
#u = 0;
|
|
58
|
+
#d = 0;
|
|
59
|
+
#f = null;
|
|
29
60
|
constructor(e) {
|
|
30
|
-
this.#e = e, e.addController(this);
|
|
61
|
+
this.#e = e, e.addController(this), p.set(e, this);
|
|
62
|
+
}
|
|
63
|
+
get offset() {
|
|
64
|
+
if (this.#s === c) return l;
|
|
65
|
+
if (this.#a) return {
|
|
66
|
+
x: this.#u,
|
|
67
|
+
y: this.#d
|
|
68
|
+
};
|
|
69
|
+
let e = this.#e.getBoundingClientRect();
|
|
70
|
+
return u(e.width, e.height, this.#s, t(this.#e));
|
|
31
71
|
}
|
|
32
72
|
hostConnected() {
|
|
33
|
-
this.#
|
|
73
|
+
this.#a && (this.#r || this.#l) && this.#y();
|
|
34
74
|
}
|
|
35
75
|
hostDisconnected() {
|
|
36
|
-
this.#
|
|
76
|
+
this.#b();
|
|
37
77
|
}
|
|
38
78
|
hostUpdated() {
|
|
39
|
-
let e = this.#e.top ?? null, t = this.#e.left ?? null,
|
|
40
|
-
if (e === null && t === null && !
|
|
41
|
-
if (!this.#
|
|
42
|
-
this.#r && this.#
|
|
79
|
+
let e = this.#e.top ?? null, t = this.#e.left ?? null, n = this.#e.fixed === !0, r = this.#e.origin ?? null, i = this.#e.style;
|
|
80
|
+
if (r !== this.#o && (this.#o = r, this.#s = this.#p(r)), e === null && t === null && !n) {
|
|
81
|
+
if (!this.#a) return;
|
|
82
|
+
this.#r && this.#v(), this.#b(), this.#a = !1, this.#r = !1, this.#l = !1, this.#u = 0, this.#d = 0, i.removeProperty("position"), i.removeProperty("top"), i.removeProperty("left"), i.removeProperty("right"), i.removeProperty("bottom"), i.removeProperty("margin"), this.#g(null, null);
|
|
43
83
|
return;
|
|
44
84
|
}
|
|
45
|
-
if (this.#
|
|
46
|
-
let a = this.#
|
|
47
|
-
this.#
|
|
85
|
+
if (this.#a && e === this.#t && t === this.#n && n === this.#r && r === this.#i) return;
|
|
86
|
+
let a = this.#a && this.#r, o = this.#s !== c;
|
|
87
|
+
if (this.#a = !0, this.#t = e, this.#n = t, this.#r = n, this.#i = r, this.#l = o, i.position = n ? "sticky" : "absolute", o) {
|
|
88
|
+
let e = this.#e.getBoundingClientRect();
|
|
89
|
+
(e.width > 0 || e.height > 0) && this.#h(e.width, e.height);
|
|
90
|
+
} else this.#u = 0, this.#d = 0;
|
|
91
|
+
this.#m(), i.right = "auto", i.bottom = "auto", n ? a || this.#_() : (a && this.#v(), i.margin = "0"), n || o ? this.#y() : this.#b(), this.#g(t ?? 0, e ?? 0);
|
|
92
|
+
}
|
|
93
|
+
#p(e) {
|
|
94
|
+
if (e == null) return c;
|
|
95
|
+
let t = e.trim().replace(/\s+/g, " ");
|
|
96
|
+
return t === "" ? c : s.get(t) || (this.#c || (this.#c = !0, console.warn(`${this.#e.localName}: origin="${e}" is not a placement origin — one of top left, top center, top right, center left, center, center right, bottom left, bottom center, bottom right. Placing as top left.`)), c);
|
|
97
|
+
}
|
|
98
|
+
#m() {
|
|
99
|
+
let e = this.#e.style;
|
|
100
|
+
e.top = r((this.#t ?? 0) - this.#d), e.left = r((this.#n ?? 0) - this.#u);
|
|
101
|
+
}
|
|
102
|
+
#h(e, n) {
|
|
103
|
+
let r = u(e, n, this.#s, t(this.#e));
|
|
104
|
+
return r.x === this.#u && r.y === this.#d ? !1 : (this.#u = r.x, this.#d = r.y, !0);
|
|
48
105
|
}
|
|
49
|
-
#
|
|
106
|
+
#g(t, n) {
|
|
50
107
|
e(this.#e, "vf-placement-change", {
|
|
51
108
|
left: t,
|
|
52
109
|
top: n
|
|
53
110
|
}, { composed: !1 });
|
|
54
111
|
}
|
|
55
|
-
#
|
|
112
|
+
#_() {
|
|
56
113
|
let e = this.#e.style;
|
|
57
|
-
e.maxWidth = "fit-content", e.zIndex = "1", this.#
|
|
114
|
+
e.maxWidth = "fit-content", e.zIndex = "1", this.#x = !1;
|
|
58
115
|
let t = this.#e.getBoundingClientRect();
|
|
59
|
-
(t.width > 0 || t.height > 0) && this.#
|
|
116
|
+
(t.width > 0 || t.height > 0) && this.#S(t.width, t.height);
|
|
60
117
|
}
|
|
61
|
-
#
|
|
62
|
-
this.#
|
|
118
|
+
#v() {
|
|
119
|
+
this.#x = !1;
|
|
63
120
|
let e = this.#e.style;
|
|
64
121
|
e.removeProperty("display"), e.removeProperty("max-width"), e.removeProperty("z-index");
|
|
65
122
|
}
|
|
66
|
-
#
|
|
67
|
-
this.#
|
|
68
|
-
let t = e[e.length - 1]?.borderBoxSize?.[0]
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
123
|
+
#y() {
|
|
124
|
+
this.#f ??= new ResizeObserver((e) => {
|
|
125
|
+
let t = e[e.length - 1]?.borderBoxSize?.[0], n = t ? {
|
|
126
|
+
width: t.inlineSize,
|
|
127
|
+
height: t.blockSize
|
|
128
|
+
} : this.#e.getBoundingClientRect();
|
|
129
|
+
this.#r && this.#S(n.width, n.height), this.#l && this.#h(n.width, n.height) && (this.#m(), this.#g(this.#n ?? 0, this.#t ?? 0));
|
|
130
|
+
}), this.#f.observe(this.#e);
|
|
131
|
+
}
|
|
132
|
+
#b() {
|
|
133
|
+
this.#f?.disconnect(), this.#f = null;
|
|
75
134
|
}
|
|
76
|
-
#
|
|
77
|
-
#
|
|
135
|
+
#x = !1;
|
|
136
|
+
#S(e, t) {
|
|
78
137
|
let n = this.#e.style;
|
|
79
|
-
if (!this.#
|
|
138
|
+
if (!this.#x) {
|
|
80
139
|
let e = getComputedStyle(this.#e).display;
|
|
81
140
|
if (e) {
|
|
82
|
-
let t =
|
|
83
|
-
t && (n.display = t), this.#
|
|
141
|
+
let t = d[e];
|
|
142
|
+
t && (n.display = t), this.#x = !0;
|
|
84
143
|
}
|
|
85
144
|
}
|
|
86
145
|
n.margin = `0 ${-e}px ${-t}px 0`;
|
|
87
146
|
}
|
|
88
147
|
};
|
|
89
|
-
function
|
|
90
|
-
let
|
|
148
|
+
function g(e, t, r, a = e, o) {
|
|
149
|
+
let s = e.getBoundingClientRect(), c = o ? m(o) : l;
|
|
91
150
|
return {
|
|
92
|
-
left:
|
|
93
|
-
top:
|
|
151
|
+
left: n(i(t - s.left, a) + c.x, a),
|
|
152
|
+
top: n(i(r - s.top, a) + c.y, a)
|
|
94
153
|
};
|
|
95
154
|
}
|
|
96
|
-
var
|
|
155
|
+
var _ = class {
|
|
97
156
|
#e;
|
|
98
157
|
#t;
|
|
99
158
|
#n = !1;
|
|
@@ -107,36 +166,39 @@ var u = class {
|
|
|
107
166
|
get bounds() {
|
|
108
167
|
return this.#r ?? this.#i();
|
|
109
168
|
}
|
|
169
|
+
get offset() {
|
|
170
|
+
return m(this.#e);
|
|
171
|
+
}
|
|
110
172
|
seed() {
|
|
111
173
|
let e = this.#e;
|
|
112
174
|
if (this.#r = this.#i(), e.left != null || e.top != null) return {
|
|
113
175
|
x: e.left ?? 0,
|
|
114
176
|
y: e.top ?? 0
|
|
115
177
|
};
|
|
116
|
-
let
|
|
178
|
+
let t = getComputedStyle(e), r = v.has(t.position), a = r ? parseFloat(t.left) || 0 : e.offsetLeft, o = r ? parseFloat(t.top) || 0 : e.offsetTop, s = this.offset;
|
|
117
179
|
return {
|
|
118
|
-
x:
|
|
119
|
-
y:
|
|
180
|
+
x: n(i(a, e), e) + s.x,
|
|
181
|
+
y: n(i(o, e), e) + s.y
|
|
120
182
|
};
|
|
121
183
|
}
|
|
122
|
-
moveTo(e,
|
|
123
|
-
let r = this.#e, i = this.#t(e,
|
|
124
|
-
r.left =
|
|
184
|
+
moveTo(e, t) {
|
|
185
|
+
let r = this.#e, { x: i, y: a } = this.offset, o = this.#t(e - i, t - a, this.#r ?? this.#i());
|
|
186
|
+
r.left = n(o.x + i, r), r.top = n(o.y + a, r), this.#n = !0;
|
|
125
187
|
}
|
|
126
188
|
#i() {
|
|
127
189
|
let e = this.#e, t = e.offsetParent, n = t && t.clientWidth > 0 && t.clientHeight > 0 ? t : null;
|
|
128
190
|
return {
|
|
129
|
-
width:
|
|
130
|
-
height:
|
|
191
|
+
width: i(n?.clientWidth ?? window.innerWidth, e),
|
|
192
|
+
height: i(n?.clientHeight ?? window.innerHeight, e)
|
|
131
193
|
};
|
|
132
194
|
}
|
|
133
|
-
},
|
|
195
|
+
}, v = /* @__PURE__ */ new Set([
|
|
134
196
|
"absolute",
|
|
135
197
|
"fixed",
|
|
136
198
|
"sticky"
|
|
137
199
|
]);
|
|
138
|
-
function
|
|
139
|
-
let r = e.top != null || e.left != null || e.fixed === !0, i =
|
|
200
|
+
function y(e, t, n) {
|
|
201
|
+
let r = e.top != null || e.left != null || e.fixed === !0, i = v.has(getComputedStyle(e).position), a = null;
|
|
140
202
|
if (!r && !i) a = "unplaced";
|
|
141
203
|
else {
|
|
142
204
|
let t = e.offsetParent;
|
|
@@ -145,4 +207,4 @@ function f(e, t, n) {
|
|
|
145
207
|
return a !== null && (console.warn(a === "unplaced" ? `${t}: movable, but in normal flow — so the first drag has to pull it out, reflowing everything after it on the page. State the origin in system px and it never was in flow: ${n}` : `${t}: the positioning parent has no box, so there is nowhere to drag to. Give it a size (and \`position: relative\`, if it is not a kit container) — the clamp is falling back to the viewport meanwhile.`), !0);
|
|
146
208
|
}
|
|
147
209
|
//#endregion
|
|
148
|
-
export {
|
|
210
|
+
export { _ as PlacementController, f as VfPositioned, g as placementIn, y as warnMovableContract };
|