vintage-frames 0.9.0 → 0.10.1
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 +211 -5
- package/dist/components/vf-icon-field.d.ts +29 -1
- package/dist/components/vf-icon-field.js +93 -34
- package/dist/components/vf-icon.d.ts +48 -1
- package/dist/components/vf-icon.js +204 -161
- package/dist/components/vf-list.js +2 -13
- package/dist/components/vf-scroll-area.d.ts +4 -4
- package/dist/components/vf-scroll-area.js +3 -7
- package/dist/components/vf-text-area.js +2 -8
- package/dist/grid-snap.d.ts +11 -4
- package/dist/grid-snap.js +6 -8
- package/dist/index.d.ts +3 -2
- package/dist/index.js +42 -42
- package/dist/motion.d.ts +31 -0
- package/dist/motion.js +15 -1
- package/dist/position.d.ts +10 -0
- package/dist/position.js +8 -1
- package/dist/styles/recipes/rule.d.ts +0 -5
- package/docs/SPEC.md +12 -10
- package/editor/vscode.html-custom-data.json +2 -2
- package/editor/web-types.json +3 -3
- package/package.json +1 -1
|
@@ -9,36 +9,39 @@ import { vfFocusUnderline as f } from "../styles/recipes/focus.js";
|
|
|
9
9
|
import { GridSnapController as p } from "../grid-snap.js";
|
|
10
10
|
import { DocumentListenersController as m } from "../document-listeners.js";
|
|
11
11
|
import { DragController as h } from "../drag.js";
|
|
12
|
-
import "../motion.js";
|
|
13
|
-
import { FocusRuleController as
|
|
14
|
-
import { deriveDragOutline as
|
|
15
|
-
import { LitElement as
|
|
16
|
-
import { property as
|
|
12
|
+
import { prefersReducedMotion as g, runOutlineTravel as _ } from "../motion.js";
|
|
13
|
+
import { FocusRuleController as v } from "../focus-modality.js";
|
|
14
|
+
import { deriveDragOutline as y, deriveOpenArt as b, dotOutline as x, penPhase as S } from "../open-art.js";
|
|
15
|
+
import { LitElement as C, css as w, html as T, nothing as E } from "lit";
|
|
16
|
+
import { property as D, state as O } from "lit/decorators.js";
|
|
17
17
|
//#region src/components/vf-icon.ts
|
|
18
|
-
var
|
|
18
|
+
var k, A = {
|
|
19
19
|
large: 32,
|
|
20
20
|
small: 16
|
|
21
|
-
},
|
|
21
|
+
}, j = 1, M = 8, N = (e, t) => t <= 0 ? Math.max(e, 0) : Math.min(Math.max(e, 0), t), P = class extends c(C) {
|
|
22
22
|
static {
|
|
23
|
-
|
|
23
|
+
k = this;
|
|
24
24
|
}
|
|
25
25
|
constructor(...t) {
|
|
26
|
-
super(...t), this.label = "", this.size = "large", this.selectable = !1, this.selected = !1, this.target = !1, this.color = !1, this.open = !1, this.movable = !1, this.editable = !1, this.maxlength = 31, this.scale = new n(this), this.gridSnap = new p(this), this.focusRule = new
|
|
26
|
+
super(...t), this.label = "", this.size = "large", this.selectable = !1, this.selected = !1, this.target = !1, this.color = !1, this.open = !1, this.movable = !1, this.editable = !1, this.maxlength = 31, this.scale = new n(this), this.gridSnap = new p(this), this.focusRule = new v(this), this._editing = !1, this._draft = "", this.#e = 0, this._ghost = null, this.#t = null, this.#n = this.attachInternals(), this.#a = !1, this.#o = "", this.#s = "", this.#c = 0, this.#l = -Infinity, this.#u = new m(this, () => [[
|
|
27
27
|
document,
|
|
28
28
|
"pointerdown",
|
|
29
|
-
this.#
|
|
29
|
+
this.#Z,
|
|
30
30
|
!0
|
|
31
|
-
]]), this.#d = (e, t, n) => ({
|
|
32
|
-
x:
|
|
33
|
-
y:
|
|
34
|
-
}
|
|
31
|
+
]]), this.#d = (e, t, n) => this.#f() ? {
|
|
32
|
+
x: Math.max(e, 0),
|
|
33
|
+
y: Math.max(t, 0)
|
|
34
|
+
} : {
|
|
35
|
+
x: N(e, n.width - a(this.offsetWidth, this)),
|
|
36
|
+
y: N(t, n.height - a(this.offsetHeight, this))
|
|
37
|
+
}, this.#p = new s(this, (e, t, n) => this.#d(e, t, n)), this.#m = null, this.#h = new h(this, {
|
|
35
38
|
onDragStart: (e) => {
|
|
36
39
|
if (!this.movable || e.button !== 0 || this._editing) return null;
|
|
37
|
-
this.#
|
|
38
|
-
let t = this.#
|
|
39
|
-
return this.#
|
|
40
|
+
this.#P();
|
|
41
|
+
let t = this.#p.seed();
|
|
42
|
+
return this.#m = {
|
|
40
43
|
origin: t,
|
|
41
|
-
frame: this.#
|
|
44
|
+
frame: this.#S(),
|
|
42
45
|
pointer: {
|
|
43
46
|
clientX: e.clientX,
|
|
44
47
|
clientY: e.clientY
|
|
@@ -46,63 +49,77 @@ var D, O = {
|
|
|
46
49
|
proposal: null,
|
|
47
50
|
outline: null,
|
|
48
51
|
followers: [],
|
|
49
|
-
size: this.#
|
|
52
|
+
size: this.#C()
|
|
50
53
|
}, t;
|
|
51
54
|
},
|
|
52
55
|
onDrag: (e, t, n) => {
|
|
53
|
-
this.#
|
|
56
|
+
this.#E(e, t, n);
|
|
54
57
|
},
|
|
55
58
|
onDragEnd: (e, t) => {
|
|
56
|
-
this.#
|
|
59
|
+
this.#D(e, t);
|
|
57
60
|
}
|
|
58
|
-
}), this.#
|
|
61
|
+
}), this.#g = new m(this, () => [[
|
|
59
62
|
document,
|
|
60
63
|
"keydown",
|
|
61
|
-
this.#
|
|
64
|
+
this.#_,
|
|
62
65
|
!0
|
|
63
|
-
]]), this.#
|
|
64
|
-
e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.#
|
|
65
|
-
}, this.#
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.#
|
|
69
|
-
|
|
66
|
+
]]), this.#_ = (e) => {
|
|
67
|
+
e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.#h.cancel());
|
|
68
|
+
}, this.#v = null, this.#y = new m(this, () => [[
|
|
69
|
+
document,
|
|
70
|
+
"pointerdown",
|
|
71
|
+
this.#b,
|
|
72
|
+
!0
|
|
73
|
+
], [
|
|
74
|
+
document,
|
|
75
|
+
"keydown",
|
|
76
|
+
this.#x,
|
|
77
|
+
!0
|
|
78
|
+
]]), this.#b = () => {
|
|
79
|
+
this.#v?.finish();
|
|
80
|
+
}, this.#x = (e) => {
|
|
81
|
+
e.key !== "Escape" || !this.#v || (e.preventDefault(), e.stopPropagation(), this.#v.finish());
|
|
82
|
+
}, this.#N = !1, this.#L = () => {
|
|
83
|
+
this.#z(), this.#U();
|
|
84
|
+
}, this.#R = () => {
|
|
85
|
+
this.#B();
|
|
86
|
+
}, this.#J = (e) => {
|
|
70
87
|
if (e.button !== 0 || this._editing) return;
|
|
71
88
|
let t = e.composedPath().some((e) => e instanceof HTMLElement && e.classList.contains("label")), n = this.selected, r = e.timeStamp - this.#l < 800;
|
|
72
|
-
this.#l = e.timeStamp, this.#
|
|
89
|
+
this.#l = e.timeStamp, this.#H();
|
|
73
90
|
let i = !e.shiftKey && !e.metaKey;
|
|
74
|
-
this.selectable && (i ? this.#
|
|
75
|
-
}, this.#
|
|
91
|
+
this.selectable && (i ? this.#q(!0) : this.#q(!this.selected)), this.#a = i && n && this.#i !== null, this.editable && t && n && !r && !e.shiftKey && !e.metaKey && this.#V(), this.#G && (this.focus({ preventScroll: !0 }), this.focusRule.suppress()), this.#h.onPointerDown(e);
|
|
92
|
+
}, this.#Y = () => {
|
|
76
93
|
this._editing || e(this, "vf-open", {});
|
|
77
|
-
}, this.#
|
|
78
|
-
if (this.#
|
|
94
|
+
}, this.#X = (e) => {
|
|
95
|
+
if (this.#h.onPointerUp(e), !this.#a || (this.#a = !1, e.type !== "pointerup")) return;
|
|
79
96
|
let t = this.#i;
|
|
80
97
|
if (t) for (let e of t.querySelectorAll("vf-icon")) e !== this && e.selected && e.setSelected(!1);
|
|
81
|
-
}, this.#
|
|
98
|
+
}, this.#Z = (e) => {
|
|
82
99
|
let t = e.composedPath();
|
|
83
|
-
if (t.includes(this) || (this.#
|
|
100
|
+
if (t.includes(this) || (this.#H(), e.shiftKey || e.metaKey)) return;
|
|
84
101
|
let n = this.#i;
|
|
85
102
|
if (n !== null) {
|
|
86
|
-
let e = t.find((e) => e instanceof
|
|
103
|
+
let e = t.find((e) => e instanceof k);
|
|
87
104
|
if (e?.selected && e.#i === n) return;
|
|
88
105
|
}
|
|
89
|
-
this.#
|
|
90
|
-
}, this.#
|
|
106
|
+
this.#q(!1);
|
|
107
|
+
}, this.#Q = (e) => {
|
|
91
108
|
let t = e.target, n = e.data ?? e.dataTransfer?.getData("text") ?? "";
|
|
92
109
|
if (n === "") return;
|
|
93
110
|
let r = t.selectionStart ?? t.value.length, i = t.selectionEnd ?? r, a = t.value.slice(0, r) + n + t.value.slice(i);
|
|
94
|
-
a.length > this.maxlength && this.#
|
|
95
|
-
}, this
|
|
111
|
+
a.length > this.maxlength && this.#ee(a);
|
|
112
|
+
}, this.#$ = (e) => {
|
|
96
113
|
let t = e.target;
|
|
97
114
|
if (t.value.length > this.maxlength) {
|
|
98
115
|
let e = t.value, n = Math.min(t.selectionStart ?? this.maxlength, this.maxlength);
|
|
99
|
-
t.value = e.slice(0, this.maxlength), t.setSelectionRange(n, n), this.#
|
|
116
|
+
t.value = e.slice(0, this.maxlength), t.setSelectionRange(n, n), this.#ee(e);
|
|
100
117
|
}
|
|
101
118
|
this._draft = t.value;
|
|
102
|
-
}, this.#
|
|
119
|
+
}, this.#te = (e) => {
|
|
103
120
|
e.key === "Enter" ? (e.preventDefault(), this.commitEditing(), this.focus()) : e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.cancelEditing(), this.focus());
|
|
104
|
-
}, this.#
|
|
105
|
-
if (this.#
|
|
121
|
+
}, this.#ne = (t) => {
|
|
122
|
+
if (this.#H(), !(this._editing || t.defaultPrevented)) {
|
|
106
123
|
if ((t.metaKey || t.ctrlKey) && !t.altKey && (t.key.toLowerCase() === "o" || t.key === "ArrowDown")) {
|
|
107
124
|
t.preventDefault(), e(this, "vf-open", {});
|
|
108
125
|
return;
|
|
@@ -114,7 +131,7 @@ var D, O = {
|
|
|
114
131
|
return;
|
|
115
132
|
case " ":
|
|
116
133
|
if (!this.selectable) return;
|
|
117
|
-
t.preventDefault(), this.focusRule.reveal(), this.#
|
|
134
|
+
t.preventDefault(), this.focusRule.reveal(), this.#q(!this.selected);
|
|
118
135
|
return;
|
|
119
136
|
case "ArrowLeft":
|
|
120
137
|
case "ArrowRight":
|
|
@@ -122,17 +139,17 @@ var D, O = {
|
|
|
122
139
|
case "ArrowDown": {
|
|
123
140
|
if (!this.movable) return;
|
|
124
141
|
t.preventDefault(), this.focusRule.reveal();
|
|
125
|
-
let e = t.shiftKey ?
|
|
126
|
-
this.#
|
|
127
|
-
let i = this.#
|
|
128
|
-
this.#
|
|
142
|
+
let e = t.shiftKey ? M : j, n = t.key === "ArrowLeft" ? -e : t.key === "ArrowRight" ? e : 0, r = t.key === "ArrowUp" ? -e : t.key === "ArrowDown" ? e : 0;
|
|
143
|
+
this.#P();
|
|
144
|
+
let i = this.#p.seed();
|
|
145
|
+
this.#p.moveTo(i.x + n, i.y + r);
|
|
129
146
|
}
|
|
130
147
|
}
|
|
131
148
|
}
|
|
132
149
|
};
|
|
133
150
|
}
|
|
134
151
|
static {
|
|
135
|
-
this.styles = [d,
|
|
152
|
+
this.styles = [d, w`
|
|
136
153
|
:host {
|
|
137
154
|
display: inline-block;
|
|
138
155
|
cursor: var(--vf-cursor, default);
|
|
@@ -375,15 +392,27 @@ var D, O = {
|
|
|
375
392
|
#l;
|
|
376
393
|
#u;
|
|
377
394
|
#d;
|
|
378
|
-
#f
|
|
395
|
+
#f() {
|
|
396
|
+
let e = this.offsetParent, t = this.assignedSlot ?? this.parentNode;
|
|
397
|
+
for (; t && t !== e;) if (t instanceof Element) {
|
|
398
|
+
if (t.localName === "vf-scroll-area") return !0;
|
|
399
|
+
t = t.assignedSlot ?? t.parentNode;
|
|
400
|
+
} else t = t instanceof ShadowRoot ? t.host : null;
|
|
401
|
+
return !1;
|
|
402
|
+
}
|
|
379
403
|
#p;
|
|
380
404
|
#m;
|
|
381
405
|
#h;
|
|
382
406
|
#g;
|
|
383
|
-
#_
|
|
407
|
+
#_;
|
|
408
|
+
#v;
|
|
409
|
+
#y;
|
|
410
|
+
#b;
|
|
411
|
+
#x;
|
|
412
|
+
#S() {
|
|
384
413
|
return this.renderRoot?.querySelector(".frame")?.getBoundingClientRect() ?? this.getBoundingClientRect();
|
|
385
414
|
}
|
|
386
|
-
#
|
|
415
|
+
#C() {
|
|
387
416
|
return {
|
|
388
417
|
width: a(this.offsetWidth, this),
|
|
389
418
|
height: a(this.offsetHeight, this)
|
|
@@ -391,22 +420,22 @@ var D, O = {
|
|
|
391
420
|
}
|
|
392
421
|
followDrag(e) {
|
|
393
422
|
if (!this.movable || this._editing) return null;
|
|
394
|
-
let t = this.#
|
|
423
|
+
let t = this.#p.seed(), n = this.#A(this.#S(), e);
|
|
395
424
|
return {
|
|
396
425
|
icon: this,
|
|
397
426
|
origin: t,
|
|
398
|
-
offset: this.#
|
|
399
|
-
size: this.#
|
|
427
|
+
offset: this.#p.offset,
|
|
428
|
+
size: this.#C(),
|
|
400
429
|
move: (e, t) => {
|
|
401
|
-
n && this.#
|
|
430
|
+
n && this.#j(n, e, t);
|
|
402
431
|
},
|
|
403
432
|
drop: (e, n) => {
|
|
404
|
-
this.#
|
|
433
|
+
this.#p.moveTo(t.x + e, t.y + n);
|
|
405
434
|
},
|
|
406
435
|
end: () => n?.canvas.remove()
|
|
407
436
|
};
|
|
408
437
|
}
|
|
409
|
-
#
|
|
438
|
+
#w(e) {
|
|
410
439
|
if (!this.selected) return [];
|
|
411
440
|
let t = this.#i;
|
|
412
441
|
if (!t) return [];
|
|
@@ -418,26 +447,26 @@ var D, O = {
|
|
|
418
447
|
}
|
|
419
448
|
return n;
|
|
420
449
|
}
|
|
421
|
-
#
|
|
450
|
+
#T(e) {
|
|
422
451
|
return [this, ...e.followers.map((e) => e.icon)];
|
|
423
452
|
}
|
|
424
|
-
#
|
|
425
|
-
let i = this.#
|
|
453
|
+
#E(t, n, r) {
|
|
454
|
+
let i = this.#m;
|
|
426
455
|
if (!i) return;
|
|
427
456
|
if (i.pointer = {
|
|
428
457
|
clientX: r.clientX,
|
|
429
458
|
clientY: r.clientY
|
|
430
459
|
}, !i.proposal) {
|
|
431
460
|
if (t === i.origin.x && n === i.origin.y) return;
|
|
432
|
-
this.#
|
|
461
|
+
this.#H(), this.#a = !1, i.proposal = {
|
|
433
462
|
left: i.origin.x,
|
|
434
463
|
top: i.origin.y
|
|
435
|
-
}, this.#
|
|
436
|
-
let r = this.#
|
|
437
|
-
i.outline = this.#
|
|
464
|
+
}, this.#g.attach();
|
|
465
|
+
let r = this.#k();
|
|
466
|
+
i.outline = this.#A(i.frame, r), i.followers = this.#w(r), e(this, "vf-drag-start", {
|
|
438
467
|
left: i.origin.x,
|
|
439
468
|
top: i.origin.y,
|
|
440
|
-
icons: this.#
|
|
469
|
+
icons: this.#T(i)
|
|
441
470
|
});
|
|
442
471
|
}
|
|
443
472
|
if (t === i.proposal.left && n === i.proposal.top) return;
|
|
@@ -446,14 +475,14 @@ var D, O = {
|
|
|
446
475
|
top: n
|
|
447
476
|
};
|
|
448
477
|
let a = t - i.origin.x, o = n - i.origin.y;
|
|
449
|
-
i.outline && this.#
|
|
478
|
+
i.outline && this.#j(i.outline, a, o);
|
|
450
479
|
for (let e of i.followers) e.move(a, o);
|
|
451
|
-
e(this, "vf-drag", this.#
|
|
480
|
+
e(this, "vf-drag", this.#M(i));
|
|
452
481
|
}
|
|
453
|
-
#
|
|
454
|
-
let r = this.#
|
|
455
|
-
if (this.#
|
|
456
|
-
this.#
|
|
482
|
+
#D(t, n) {
|
|
483
|
+
let r = this.#m;
|
|
484
|
+
if (this.#m = null, !r?.proposal) return;
|
|
485
|
+
this.#g.detach(), r.outline?.canvas.remove();
|
|
457
486
|
for (let e of r.followers) e.end();
|
|
458
487
|
if (t && (r.pointer = {
|
|
459
488
|
clientX: t.clientX,
|
|
@@ -462,36 +491,36 @@ var D, O = {
|
|
|
462
491
|
e(this, "vf-drag-cancel", {});
|
|
463
492
|
return;
|
|
464
493
|
}
|
|
465
|
-
let i = this.#
|
|
466
|
-
e(this, "vf-drop", i, { cancelable: !0 }) && this.#
|
|
494
|
+
let i = this.#M(r);
|
|
495
|
+
e(this, "vf-drop", i, { cancelable: !0 }) && this.#O(r, i);
|
|
467
496
|
}
|
|
468
|
-
#
|
|
497
|
+
#O(e, t) {
|
|
469
498
|
if (e.followers.length === 0) {
|
|
470
|
-
this.#
|
|
499
|
+
this.#p.moveTo(t.left, t.top);
|
|
471
500
|
return;
|
|
472
501
|
}
|
|
473
|
-
let n = this.#
|
|
502
|
+
let n = this.#p.bounds, r = (e, t) => ({
|
|
474
503
|
x: e.x - t.x,
|
|
475
504
|
y: e.y - t.y
|
|
476
505
|
}), i = [{
|
|
477
|
-
corner: r(e.origin, this.#
|
|
506
|
+
corner: r(e.origin, this.#p.offset),
|
|
478
507
|
size: e.size
|
|
479
508
|
}, ...e.followers.map((e) => ({
|
|
480
509
|
corner: r(e.origin, e.offset),
|
|
481
510
|
size: e.size
|
|
482
|
-
}))], a = (e, t, n, r) => {
|
|
483
|
-
let
|
|
484
|
-
for (let e of i)
|
|
485
|
-
return
|
|
486
|
-
},
|
|
487
|
-
this.#
|
|
488
|
-
for (let t of e.followers) t.drop(
|
|
489
|
-
}
|
|
490
|
-
#
|
|
511
|
+
}))], a = this.#f(), o = (e, t, n, r) => {
|
|
512
|
+
let o = -Infinity, s = Infinity;
|
|
513
|
+
for (let e of i) o = Math.max(o, -t(e)), a || (s = Math.min(s, r - n(e) - t(e)));
|
|
514
|
+
return s < o && (s = Infinity), Math.min(Math.max(e, o), s);
|
|
515
|
+
}, s = o(t.left - e.origin.x, (e) => e.corner.x, (e) => e.size.width, n.width), c = o(t.top - e.origin.y, (e) => e.corner.y, (e) => e.size.height, n.height);
|
|
516
|
+
this.#p.moveTo(e.origin.x + s, e.origin.y + c);
|
|
517
|
+
for (let t of e.followers) t.drop(s, c);
|
|
518
|
+
}
|
|
519
|
+
#k() {
|
|
491
520
|
let t = { surface: null };
|
|
492
521
|
return e(this, "vf-drag-surface-request", t, { composed: !1 }), t.surface;
|
|
493
522
|
}
|
|
494
|
-
#
|
|
523
|
+
#A(e, t) {
|
|
495
524
|
let n = this.renderRoot, a = n?.querySelector(".frame");
|
|
496
525
|
if (!a) return null;
|
|
497
526
|
let o = r(this), s = n.querySelector(".art"), c = n.querySelector(".name")?.getBoundingClientRect() ?? null, l = c ? Math.min(e.left, c.left) : e.left, u = c ? Math.min(e.top, c.top) : e.top, d = c ? Math.max(e.right, c.right) : e.right, f = c ? Math.max(e.bottom, c.bottom) : e.bottom, p = (e) => ({
|
|
@@ -499,10 +528,10 @@ var D, O = {
|
|
|
499
528
|
y: Math.round((e.top - u) / o),
|
|
500
529
|
width: Math.round(e.width / o),
|
|
501
530
|
height: Math.round(e.height / o)
|
|
502
|
-
}), m = Math.round((d - l) / o), h = Math.round((f - u) / o), g = this.open && this._ghost ? this._ghost : this.#t,
|
|
531
|
+
}), m = Math.round((d - l) / o), h = Math.round((f - u) / o), g = this.open && this._ghost ? this._ghost : this.#t, _ = g != null && (g instanceof HTMLCanvasElement ? g.width > 0 : g.complete && g.naturalWidth > 0), v = _ ? g.getBoundingClientRect() : null, b = y(_ ? g : null, {
|
|
503
532
|
width: m,
|
|
504
533
|
height: h,
|
|
505
|
-
art:
|
|
534
|
+
art: v && v.width > 0 ? p(v) : null,
|
|
506
535
|
cell: s ? p(s.getBoundingClientRect()) : {
|
|
507
536
|
x: 0,
|
|
508
537
|
y: 0,
|
|
@@ -527,13 +556,13 @@ var D, O = {
|
|
|
527
556
|
phase: -1
|
|
528
557
|
};
|
|
529
558
|
}
|
|
530
|
-
#
|
|
559
|
+
#j(e, t, n) {
|
|
531
560
|
let r = e.base.x + t, a = e.base.y + n;
|
|
532
561
|
e.canvas.style.left = i(r), e.canvas.style.top = i(a);
|
|
533
|
-
let o =
|
|
534
|
-
o !== e.phase && (e.phase = o,
|
|
562
|
+
let o = S(r, a);
|
|
563
|
+
o !== e.phase && (e.phase = o, x(e.ring, e.canvas, o));
|
|
535
564
|
}
|
|
536
|
-
#
|
|
565
|
+
#M(e) {
|
|
537
566
|
let { left: t, top: n } = e.proposal ?? {
|
|
538
567
|
left: e.origin.x,
|
|
539
568
|
top: e.origin.y
|
|
@@ -545,32 +574,32 @@ var D, O = {
|
|
|
545
574
|
top: n,
|
|
546
575
|
x: e.frame.left + (t - e.origin.x) * i,
|
|
547
576
|
y: e.frame.top + (n - e.origin.y) * i,
|
|
548
|
-
icons: this.#
|
|
577
|
+
icons: this.#T(e)
|
|
549
578
|
};
|
|
550
579
|
}
|
|
551
580
|
connectedCallback() {
|
|
552
|
-
super.connectedCallback(), this.#
|
|
581
|
+
super.connectedCallback(), this.#K(), this.#U(), this.selectable && this.selected && this.#u.attach(), this.addEventListener("keydown", this.#ne);
|
|
553
582
|
}
|
|
554
583
|
disconnectedCallback() {
|
|
555
|
-
super.disconnectedCallback(), this.removeEventListener("keydown", this.#
|
|
556
|
-
for (let e of this.#
|
|
557
|
-
this.#
|
|
584
|
+
super.disconnectedCallback(), this.removeEventListener("keydown", this.#ne), this.#H(), this.#m?.outline?.canvas.remove();
|
|
585
|
+
for (let e of this.#m?.followers ?? []) e.end();
|
|
586
|
+
this.#m = null, this.#v?.finish();
|
|
558
587
|
}
|
|
559
588
|
updated(e) {
|
|
560
|
-
if (e.has("selectable") && this.#
|
|
589
|
+
if (e.has("selectable") && this.#K(), (e.has("selectable") || e.has("selected") || e.has("label")) && this.#U(), (e.has("selected") || e.has("selectable")) && (this.selectable && this.selected ? this.#u.attach() : this.#u.detach()), e.has("_editing") && this._editing) {
|
|
561
590
|
let e = this.renderRoot.querySelector("input");
|
|
562
591
|
e?.focus(), e?.select();
|
|
563
592
|
}
|
|
564
|
-
(e.has("label") || e.has("_draft") || e.has("_editing")) && this.#
|
|
593
|
+
(e.has("label") || e.has("_draft") || e.has("_editing")) && this.#F(), (e.has("open") || e.has("size")) && this.#z();
|
|
565
594
|
}
|
|
566
|
-
#
|
|
567
|
-
#
|
|
568
|
-
this.#
|
|
595
|
+
#N;
|
|
596
|
+
#P() {
|
|
597
|
+
this.#N ||= l(this, `vf-icon${this.label ? ` ("${this.label}")` : ""}`, "<vf-icon movable label=\"Read Me\" width=\"64\" top=\"16\" left=\"16\">");
|
|
569
598
|
}
|
|
570
599
|
firstUpdated() {
|
|
571
|
-
document.fonts.ready.then(() => this.#
|
|
600
|
+
document.fonts.ready.then(() => this.#F());
|
|
572
601
|
}
|
|
573
|
-
#
|
|
602
|
+
#F() {
|
|
574
603
|
let e = this.renderRoot?.querySelector(".name");
|
|
575
604
|
if (!e) {
|
|
576
605
|
this.#e = 0;
|
|
@@ -582,14 +611,14 @@ var D, O = {
|
|
|
582
611
|
n.selectNodeContents(e), t = n.getBoundingClientRect().width, n.detach();
|
|
583
612
|
}
|
|
584
613
|
let n = t / r(this) + 2, i = Math.max(2, Math.ceil(n / 2) * 2);
|
|
585
|
-
this.#e = this._editing && t === 0 ? Math.max(i,
|
|
614
|
+
this.#e = this._editing && t === 0 ? Math.max(i, A[this.size]) : i, e.style.width = this.#I;
|
|
586
615
|
}
|
|
587
|
-
get #
|
|
616
|
+
get #I() {
|
|
588
617
|
return this.#e ? `calc(var(--vf-scale, 1) * ${this.#e}px)` : "";
|
|
589
618
|
}
|
|
590
|
-
#
|
|
591
|
-
#
|
|
592
|
-
#
|
|
619
|
+
#L;
|
|
620
|
+
#R;
|
|
621
|
+
#z() {
|
|
593
622
|
let e = this.renderRoot?.querySelector(`slot[name='${this.size}']`), t = null;
|
|
594
623
|
for (let n of e?.assignedElements({ flatten: !0 }) ?? []) {
|
|
595
624
|
let e = n instanceof HTMLImageElement || n instanceof HTMLCanvasElement ? n : n.querySelector("img, canvas");
|
|
@@ -598,9 +627,9 @@ var D, O = {
|
|
|
598
627
|
break;
|
|
599
628
|
}
|
|
600
629
|
}
|
|
601
|
-
t !== this.#t && (this.#t?.removeEventListener("load", this.#
|
|
630
|
+
t !== this.#t && (this.#t?.removeEventListener("load", this.#R), this.#t?.removeEventListener("error", this.#R), this.#t = t, t?.addEventListener("load", this.#R), t?.addEventListener("error", this.#R)), this.#B();
|
|
602
631
|
}
|
|
603
|
-
#
|
|
632
|
+
#B() {
|
|
604
633
|
let e = this.#t, t = e instanceof HTMLImageElement ? e.complete && e.naturalWidth > 0 : e != null && e.width > 0;
|
|
605
634
|
if (!this.open || e == null || !t) {
|
|
606
635
|
this._ghost = null, this.#o = "";
|
|
@@ -608,7 +637,7 @@ var D, O = {
|
|
|
608
637
|
}
|
|
609
638
|
let n = e instanceof HTMLImageElement ? `${this.size} ${e.currentSrc}` : "";
|
|
610
639
|
if (n !== "" && n === this.#o && this._ghost) return;
|
|
611
|
-
let r =
|
|
640
|
+
let r = b(e);
|
|
612
641
|
if (r) {
|
|
613
642
|
r.className = "ghost", r.style.width = `calc(var(--vf-scale, 1) * ${r.width}px)`, r.style.height = `calc(var(--vf-scale, 1) * ${r.height}px)`;
|
|
614
643
|
let t = e instanceof HTMLImageElement ? e.alt : "";
|
|
@@ -616,16 +645,16 @@ var D, O = {
|
|
|
616
645
|
}
|
|
617
646
|
this._ghost = r, this.#o = r ? n : "";
|
|
618
647
|
}
|
|
619
|
-
#
|
|
620
|
-
this.#
|
|
648
|
+
#V() {
|
|
649
|
+
this.#H(), this.#c = window.setTimeout(() => {
|
|
621
650
|
this.#c = 0, this.startEditing();
|
|
622
651
|
}, 800);
|
|
623
652
|
}
|
|
624
|
-
#
|
|
653
|
+
#H() {
|
|
625
654
|
this.#c &&= (clearTimeout(this.#c), 0);
|
|
626
655
|
}
|
|
627
656
|
startEditing() {
|
|
628
|
-
this.#
|
|
657
|
+
this.#H(), !(!this.editable || this._editing) && (this.#s = this.label, this._draft = this.label, this._editing = !0);
|
|
629
658
|
}
|
|
630
659
|
commitEditing() {
|
|
631
660
|
if (!this._editing) return;
|
|
@@ -649,45 +678,45 @@ var D, O = {
|
|
|
649
678
|
}
|
|
650
679
|
render() {
|
|
651
680
|
let e = this._editing, t = e ? this._draft : this.label, n = this.focusRule.marked && !e, r = t !== "" || e, i = `caption${e ? " editing" : ""}${n && t ? " focus-rule" : ""}`, a = `art${this.open && this._ghost ? " open" : ""}${n && !t ? " focus-rule" : ""}`, o = this.width ? `width: calc(var(--vf-scale, 1) * ${this.width}px)` : "";
|
|
652
|
-
return
|
|
681
|
+
return T`<div
|
|
653
682
|
class="frame vf-snap"
|
|
654
683
|
part="frame"
|
|
655
684
|
style=${o}
|
|
656
|
-
@pointerdown=${this.#
|
|
657
|
-
@pointermove=${this.#
|
|
658
|
-
@pointerup=${this.#
|
|
659
|
-
@pointercancel=${this.#
|
|
660
|
-
@dblclick=${this.#
|
|
685
|
+
@pointerdown=${this.#J}
|
|
686
|
+
@pointermove=${this.#h.onPointerMove}
|
|
687
|
+
@pointerup=${this.#X}
|
|
688
|
+
@pointercancel=${this.#X}
|
|
689
|
+
@dblclick=${this.#Y}
|
|
661
690
|
>
|
|
662
691
|
<div class=${a} part="icon">
|
|
663
|
-
${this.size === "small" ?
|
|
692
|
+
${this.size === "small" ? T`<slot name="small" @slotchange=${this.#L}></slot>` : T`<slot name="large" @slotchange=${this.#L}></slot>`}${this._ghost ?? E}
|
|
664
693
|
</div>
|
|
665
|
-
${r ?
|
|
694
|
+
${r ? T`<div class=${i}>
|
|
666
695
|
<!-- No whitespace around the span: it is the measured run, and a
|
|
667
696
|
stray space would widen it. -->
|
|
668
697
|
<div class="label" part="label"><span
|
|
669
698
|
class="name"
|
|
670
699
|
part="plate"
|
|
671
|
-
style=${this.#e ? `width: ${this.#
|
|
700
|
+
style=${this.#e ? `width: ${this.#I}` : ""}
|
|
672
701
|
>${t}</span
|
|
673
702
|
></div>
|
|
674
|
-
${e ?
|
|
703
|
+
${e ? T`<div class="rename-box">
|
|
675
704
|
<input
|
|
676
705
|
class="rename"
|
|
677
706
|
part="input"
|
|
678
707
|
type="text"
|
|
679
708
|
maxlength=${this.maxlength}
|
|
680
709
|
.value=${this._draft}
|
|
681
|
-
@beforeinput=${this.#
|
|
682
|
-
@input=${this
|
|
683
|
-
@keydown=${this.#
|
|
710
|
+
@beforeinput=${this.#Q}
|
|
711
|
+
@input=${this.#$}
|
|
712
|
+
@keydown=${this.#te}
|
|
684
713
|
@blur=${this.commitEditing}
|
|
685
714
|
/>
|
|
686
|
-
</div>` :
|
|
687
|
-
</div>` :
|
|
715
|
+
</div>` : E}
|
|
716
|
+
</div>` : E}
|
|
688
717
|
</div>`;
|
|
689
718
|
}
|
|
690
|
-
#
|
|
719
|
+
#U() {
|
|
691
720
|
if (!this.selectable) {
|
|
692
721
|
this.#n.role = null, this.#n.ariaSelected = null, this.#n.ariaLabel = null;
|
|
693
722
|
return;
|
|
@@ -696,22 +725,22 @@ var D, O = {
|
|
|
696
725
|
this.#n.role = "option", this.#n.ariaSelected = this.selected ? "true" : "false", this.#n.ariaLabel = null;
|
|
697
726
|
return;
|
|
698
727
|
}
|
|
699
|
-
this.#n.role = "img", this.#n.ariaSelected = null, this.#n.ariaLabel = this.label || this.#
|
|
728
|
+
this.#n.role = "img", this.#n.ariaSelected = null, this.#n.ariaLabel = this.label || this.#W || null;
|
|
700
729
|
}
|
|
701
|
-
get #
|
|
730
|
+
get #W() {
|
|
702
731
|
return this.#t instanceof HTMLImageElement ? this.#t.alt : "";
|
|
703
732
|
}
|
|
704
|
-
get #
|
|
733
|
+
get #G() {
|
|
705
734
|
return this.selectable;
|
|
706
735
|
}
|
|
707
|
-
#
|
|
708
|
-
this.hasAttribute("tabindex") || (this.#
|
|
736
|
+
#K() {
|
|
737
|
+
this.hasAttribute("tabindex") || (this.#G ? this.tabIndex = 0 : this.removeAttribute("tabindex"));
|
|
709
738
|
}
|
|
710
|
-
#
|
|
739
|
+
#q(t) {
|
|
711
740
|
t !== this.selected && (this.selected = t, e(this, "vf-select", { selected: t }));
|
|
712
741
|
}
|
|
713
742
|
setSelected(e) {
|
|
714
|
-
this.#
|
|
743
|
+
this.#q(e);
|
|
715
744
|
}
|
|
716
745
|
touches(e) {
|
|
717
746
|
let t = this.renderRoot;
|
|
@@ -724,43 +753,57 @@ var D, O = {
|
|
|
724
753
|
}
|
|
725
754
|
return !1;
|
|
726
755
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
756
|
+
moveTo(e, t) {
|
|
757
|
+
this.#v?.finish(), this.#P(), this.#p.seed(), this.#p.moveTo(e, t);
|
|
758
|
+
}
|
|
759
|
+
async dragTo(e, t) {
|
|
760
|
+
if (this.#v?.finish(), await this.updateComplete, this.#v?.finish(), !this.isConnected) return !1;
|
|
761
|
+
this.#P();
|
|
762
|
+
let n = this.#p.seed(), r = this.#p.resolve(e, t), i = r.x - n.x, a = r.y - n.y, o = i === 0 && a === 0 || g() || this._editing || this.#m !== null ? null : this.#A(this.#S(), this.#k());
|
|
763
|
+
return o ? (this.#j(o, 0, 0), new Promise((e) => {
|
|
764
|
+
let t = null;
|
|
765
|
+
t = _(Math.hypot(i, a), (e) => this.#j(o, Math.round(i * e), Math.round(a * e)), () => {
|
|
766
|
+
this.#v === t && (this.#v = null, this.#y.detach()), o.canvas.remove(), this.isConnected && this.#p.moveTo(r.x, r.y), e(!0);
|
|
767
|
+
}), this.#v = t, this.#y.attach();
|
|
768
|
+
})) : (this.#p.moveTo(r.x, r.y), !1);
|
|
769
|
+
}
|
|
732
770
|
#J;
|
|
733
|
-
#Y
|
|
771
|
+
#Y;
|
|
772
|
+
#X;
|
|
773
|
+
#Z;
|
|
774
|
+
#Q;
|
|
775
|
+
#$;
|
|
776
|
+
#ee(t) {
|
|
734
777
|
e(this, "vf-name-too-long", {
|
|
735
778
|
attempted: t,
|
|
736
779
|
accepted: t.slice(0, this.maxlength),
|
|
737
780
|
limit: this.maxlength
|
|
738
781
|
});
|
|
739
782
|
}
|
|
740
|
-
#
|
|
741
|
-
#
|
|
783
|
+
#te;
|
|
784
|
+
#ne;
|
|
742
785
|
};
|
|
743
|
-
o([
|
|
786
|
+
o([D()], P.prototype, "label", void 0), o([D({ reflect: !0 })], P.prototype, "size", void 0), o([D({
|
|
744
787
|
type: Boolean,
|
|
745
788
|
reflect: !0
|
|
746
|
-
})],
|
|
789
|
+
})], P.prototype, "selectable", void 0), o([D({
|
|
747
790
|
type: Boolean,
|
|
748
791
|
reflect: !0
|
|
749
|
-
})],
|
|
792
|
+
})], P.prototype, "selected", void 0), o([D({
|
|
750
793
|
type: Boolean,
|
|
751
794
|
reflect: !0
|
|
752
|
-
})],
|
|
795
|
+
})], P.prototype, "target", void 0), o([D({
|
|
753
796
|
type: Boolean,
|
|
754
797
|
reflect: !0
|
|
755
|
-
})],
|
|
798
|
+
})], P.prototype, "color", void 0), o([D({
|
|
756
799
|
type: Boolean,
|
|
757
800
|
reflect: !0
|
|
758
|
-
})],
|
|
801
|
+
})], P.prototype, "open", void 0), o([D({
|
|
759
802
|
type: Boolean,
|
|
760
803
|
reflect: !0
|
|
761
|
-
})],
|
|
804
|
+
})], P.prototype, "movable", void 0), o([D({
|
|
762
805
|
type: Boolean,
|
|
763
806
|
reflect: !0
|
|
764
|
-
})],
|
|
807
|
+
})], P.prototype, "editable", void 0), o([D({ type: Number })], P.prototype, "width", void 0), o([D({ type: Number })], P.prototype, "maxlength", void 0), o([O()], P.prototype, "_editing", void 0), o([O()], P.prototype, "_draft", void 0), o([O()], P.prototype, "_ghost", void 0), P = k = o([t("vf-icon")], P);
|
|
765
808
|
//#endregion
|
|
766
|
-
export {
|
|
809
|
+
export { P as VfIcon };
|