vintage-frames 0.8.0 → 0.10.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.
@@ -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 g } from "../focus-modality.js";
14
- import { deriveDragOutline as _, deriveOpenArt as v, dotOutline as y, penPhase as b } from "../open-art.js";
15
- import { LitElement as x, css as S, html as C, nothing as w } from "lit";
16
- import { property as T, state as E } from "lit/decorators.js";
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 D, O = {
18
+ var k, A = {
19
19
  large: 32,
20
20
  small: 16
21
- }, k = 1, A = 8, j = (e, t) => t <= 0 ? Math.max(e, 0) : Math.min(Math.max(e, 0), t), M = class extends c(x) {
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
- D = this;
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 g(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, () => [[
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.#K,
29
+ this.#Z,
30
30
  !0
31
- ]]), this.#d = (e, t, n) => ({
32
- x: j(e, n.width - a(this.offsetWidth, this)),
33
- y: j(t, n.height - a(this.offsetHeight, this))
34
- }), this.#f = new s(this, (e, t, n) => this.#d(e, t, n)), this.#p = null, this.#m = new h(this, {
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.#k();
38
- let t = this.#f.seed();
39
- return this.#p = {
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.#v()
52
+ size: this.#C()
50
53
  }, t;
51
54
  },
52
55
  onDrag: (e, t, n) => {
53
- this.#x(e, t, n);
56
+ this.#E(e, t, n);
54
57
  },
55
58
  onDragEnd: (e, t) => {
56
- this.#S(e, t);
59
+ this.#D(e, t);
57
60
  }
58
- }), this.#h = new m(this, () => [[
61
+ }), this.#g = new m(this, () => [[
59
62
  document,
60
63
  "keydown",
61
- this.#g,
64
+ this.#_,
62
65
  !0
63
- ]]), this.#g = (e) => {
64
- e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.#m.cancel());
65
- }, this.#O = !1, this.#M = () => {
66
- this.#P(), this.#R();
67
- }, this.#N = () => {
68
- this.#F();
69
- }, this.#U = (e) => {
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.#L();
89
+ this.#l = e.timeStamp, this.#H();
73
90
  let i = !e.shiftKey && !e.metaKey;
74
- this.selectable && (i ? this.#H(!0) : this.#H(!this.selected)), this.#a = i && n && this.#i !== null, this.editable && t && n && !r && !e.shiftKey && !e.metaKey && this.#I(), this.#B && (this.focus({ preventScroll: !0 }), this.focusRule.suppress()), this.#m.onPointerDown(e);
75
- }, this.#W = () => {
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.#G = (e) => {
78
- if (this.#m.onPointerUp(e), !this.#a || (this.#a = !1, e.type !== "pointerup")) return;
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.#K = (e) => {
98
+ }, this.#Z = (e) => {
82
99
  let t = e.composedPath();
83
- if (t.includes(this) || (this.#L(), e.shiftKey || e.metaKey)) return;
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 D);
103
+ let e = t.find((e) => e instanceof k);
87
104
  if (e?.selected && e.#i === n) return;
88
105
  }
89
- this.#H(!1);
90
- }, this.#q = (e) => {
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.#Y(a);
95
- }, this.#J = (e) => {
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.#Y(e);
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.#X = (e) => {
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.#Z = (t) => {
105
- if (this.#L(), !(this._editing || t.defaultPrevented)) {
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.#H(!this.selected);
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 ? A : k, n = t.key === "ArrowLeft" ? -e : t.key === "ArrowRight" ? e : 0, r = t.key === "ArrowUp" ? -e : t.key === "ArrowDown" ? e : 0;
126
- this.#k();
127
- let i = this.#f.seed();
128
- this.#f.moveTo(i.x + n, i.y + r);
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, S`
152
+ this.styles = [d, w`
136
153
  :host {
137
154
  display: inline-block;
138
155
  cursor: var(--vf-cursor, default);
@@ -213,7 +230,7 @@ var D, O = {
213
230
  centring below is still a whole number of system px. */
214
231
  .caption {
215
232
  position: relative;
216
- margin-top: calc(var(--vf-scale, 1) * var(--vf-icon-gap, 2px));
233
+ margin-top: calc(var(--vf-scale, 1) * var(--vf-icon-gap, 0px));
217
234
  }
218
235
  .label {
219
236
  ${u}
@@ -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
- #v() {
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.#f.seed(), n = this.#T(this.#_(), e);
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.#f.offset,
399
- size: this.#v(),
427
+ offset: this.#p.offset,
428
+ size: this.#C(),
400
429
  move: (e, t) => {
401
- n && this.#E(n, e, t);
430
+ n && this.#j(n, e, t);
402
431
  },
403
432
  drop: (e, n) => {
404
- this.#f.moveTo(t.x + e, t.y + n);
433
+ this.#p.moveTo(t.x + e, t.y + n);
405
434
  },
406
435
  end: () => n?.canvas.remove()
407
436
  };
408
437
  }
409
- #y(e) {
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
- #b(e) {
450
+ #T(e) {
422
451
  return [this, ...e.followers.map((e) => e.icon)];
423
452
  }
424
- #x(t, n, r) {
425
- let i = this.#p;
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.#L(), this.#a = !1, i.proposal = {
461
+ this.#H(), this.#a = !1, i.proposal = {
433
462
  left: i.origin.x,
434
463
  top: i.origin.y
435
- }, this.#h.attach();
436
- let r = this.#w();
437
- i.outline = this.#T(i.frame, r), i.followers = this.#y(r), e(this, "vf-drag-start", {
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.#b(i)
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.#E(i.outline, a, o);
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.#D(i));
480
+ e(this, "vf-drag", this.#M(i));
452
481
  }
453
- #S(t, n) {
454
- let r = this.#p;
455
- if (this.#p = null, !r?.proposal) return;
456
- this.#h.detach(), r.outline?.canvas.remove();
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,85 +491,78 @@ var D, O = {
462
491
  e(this, "vf-drag-cancel", {});
463
492
  return;
464
493
  }
465
- let i = this.#D(r);
466
- e(this, "vf-drop", i, { cancelable: !0 }) && this.#C(r, i);
494
+ let i = this.#M(r);
495
+ e(this, "vf-drop", i, { cancelable: !0 }) && this.#O(r, i);
467
496
  }
468
- #C(e, t) {
497
+ #O(e, t) {
469
498
  if (e.followers.length === 0) {
470
- this.#f.moveTo(t.left, t.top);
499
+ this.#p.moveTo(t.left, t.top);
471
500
  return;
472
501
  }
473
- let n = this.#f.bounds, r = (e, t) => ({
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.#f.offset),
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 a = -Infinity, o = Infinity;
484
- for (let e of i) a = Math.max(a, -t(e)), o = Math.min(o, r - n(e) - t(e));
485
- return o < a && (o = Infinity), Math.min(Math.max(e, a), o);
486
- }, o = a(t.left - e.origin.x, (e) => e.corner.x, (e) => e.size.width, n.width), s = a(t.top - e.origin.y, (e) => e.corner.y, (e) => e.size.height, n.height);
487
- this.#f.moveTo(e.origin.x + o, e.origin.y + s);
488
- for (let t of e.followers) t.drop(o, s);
489
- }
490
- #w() {
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
- #T(e, t) {
523
+ #A(e, t) {
495
524
  let n = this.renderRoot, a = n?.querySelector(".frame");
496
525
  if (!a) return null;
497
- let o = r(this), s = (t) => ({
498
- x: Math.round((t.left - e.left) / o),
499
- y: Math.round((t.top - e.top) / o),
500
- width: Math.round(t.width / o),
501
- height: Math.round(t.height / o)
502
- }), c = Math.round(e.width / o), l = Math.round(e.height / o), u = n.querySelector(".art"), d = n.querySelector(".name"), f = this.open && this._ghost ? this._ghost : this.#t, p = f != null && (f instanceof HTMLCanvasElement ? f.width > 0 : f.complete && f.naturalWidth > 0), m = p ? f.getBoundingClientRect() : null, h = _(p ? f : null, {
503
- width: c,
504
- height: l,
505
- art: m && m.width > 0 ? s(m) : null,
506
- cell: u ? s(u.getBoundingClientRect()) : {
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) => ({
527
+ x: Math.round((e.left - l) / o),
528
+ y: Math.round((e.top - u) / o),
529
+ width: Math.round(e.width / o),
530
+ height: Math.round(e.height / o)
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, {
532
+ width: m,
533
+ height: h,
534
+ art: v && v.width > 0 ? p(v) : null,
535
+ cell: s ? p(s.getBoundingClientRect()) : {
507
536
  x: 0,
508
537
  y: 0,
509
- width: c,
510
- height: l
538
+ width: m,
539
+ height: h
511
540
  },
512
- plate: d ? s(d.getBoundingClientRect()) : null
541
+ plate: c ? p(c) : null
513
542
  });
514
- if (!h) return null;
515
- let g = document.createElement("canvas");
516
- g.className = "drag-outline";
517
- let v = g.style;
518
- v.position = "absolute", v.display = "block", v.pointerEvents = "none", v.filter = "invert(1)", v.mixBlendMode = "difference", v.imageRendering = "pixelated", v.width = i(h.width), v.height = i(h.height);
519
- let y = {
520
- x: 0,
521
- y: 0
543
+ if (!b) return null;
544
+ let x = document.createElement("canvas");
545
+ x.className = "drag-outline";
546
+ let S = x.style;
547
+ S.position = "absolute", S.display = "block", S.pointerEvents = "none", S.filter = "invert(1)", S.mixBlendMode = "difference", S.imageRendering = "pixelated", S.width = i(b.width), S.height = i(b.height);
548
+ let C = t ?? a, w = t ? t.getBoundingClientRect() : e, T = {
549
+ x: Math.round((l - w.left) / o),
550
+ y: Math.round((u - w.top) / o)
522
551
  };
523
- if (t) {
524
- let n = t.getBoundingClientRect();
525
- y = {
526
- x: Math.round((e.left - n.left) / o),
527
- y: Math.round((e.top - n.top) / o)
528
- }, t.append(g);
529
- } else a.append(g);
530
- return {
531
- ring: h,
532
- canvas: g,
533
- base: y,
552
+ return C.append(x), {
553
+ ring: b,
554
+ canvas: x,
555
+ base: T,
534
556
  phase: -1
535
557
  };
536
558
  }
537
- #E(e, t, n) {
559
+ #j(e, t, n) {
538
560
  let r = e.base.x + t, a = e.base.y + n;
539
561
  e.canvas.style.left = i(r), e.canvas.style.top = i(a);
540
- let o = b(r, a);
541
- o !== e.phase && (e.phase = o, y(e.ring, e.canvas, o));
562
+ let o = S(r, a);
563
+ o !== e.phase && (e.phase = o, x(e.ring, e.canvas, o));
542
564
  }
543
- #D(e) {
565
+ #M(e) {
544
566
  let { left: t, top: n } = e.proposal ?? {
545
567
  left: e.origin.x,
546
568
  top: e.origin.y
@@ -552,32 +574,32 @@ var D, O = {
552
574
  top: n,
553
575
  x: e.frame.left + (t - e.origin.x) * i,
554
576
  y: e.frame.top + (n - e.origin.y) * i,
555
- icons: this.#b(e)
577
+ icons: this.#T(e)
556
578
  };
557
579
  }
558
580
  connectedCallback() {
559
- super.connectedCallback(), this.#V(), this.#R(), this.selectable && this.selected && this.#u.attach(), this.addEventListener("keydown", this.#Z);
581
+ super.connectedCallback(), this.#K(), this.#U(), this.selectable && this.selected && this.#u.attach(), this.addEventListener("keydown", this.#ne);
560
582
  }
561
583
  disconnectedCallback() {
562
- super.disconnectedCallback(), this.removeEventListener("keydown", this.#Z), this.#L(), this.#p?.outline?.canvas.remove();
563
- for (let e of this.#p?.followers ?? []) e.end();
564
- this.#p = null;
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();
565
587
  }
566
588
  updated(e) {
567
- if (e.has("selectable") && this.#V(), (e.has("selectable") || e.has("selected") || e.has("label")) && this.#R(), (e.has("selected") || e.has("selectable")) && (this.selectable && this.selected ? this.#u.attach() : this.#u.detach()), e.has("_editing") && this._editing) {
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) {
568
590
  let e = this.renderRoot.querySelector("input");
569
591
  e?.focus(), e?.select();
570
592
  }
571
- (e.has("label") || e.has("_draft") || e.has("_editing")) && this.#A(), (e.has("open") || e.has("size")) && this.#P();
593
+ (e.has("label") || e.has("_draft") || e.has("_editing")) && this.#F(), (e.has("open") || e.has("size")) && this.#z();
572
594
  }
573
- #O;
574
- #k() {
575
- this.#O ||= l(this, `vf-icon${this.label ? ` ("${this.label}")` : ""}`, "<vf-icon movable label=\"Read Me\" width=\"64\" top=\"16\" left=\"16\">");
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\">");
576
598
  }
577
599
  firstUpdated() {
578
- document.fonts.ready.then(() => this.#A());
600
+ document.fonts.ready.then(() => this.#F());
579
601
  }
580
- #A() {
602
+ #F() {
581
603
  let e = this.renderRoot?.querySelector(".name");
582
604
  if (!e) {
583
605
  this.#e = 0;
@@ -589,14 +611,14 @@ var D, O = {
589
611
  n.selectNodeContents(e), t = n.getBoundingClientRect().width, n.detach();
590
612
  }
591
613
  let n = t / r(this) + 2, i = Math.max(2, Math.ceil(n / 2) * 2);
592
- this.#e = this._editing && t === 0 ? Math.max(i, O[this.size]) : i, e.style.width = this.#j;
614
+ this.#e = this._editing && t === 0 ? Math.max(i, A[this.size]) : i, e.style.width = this.#I;
593
615
  }
594
- get #j() {
616
+ get #I() {
595
617
  return this.#e ? `calc(var(--vf-scale, 1) * ${this.#e}px)` : "";
596
618
  }
597
- #M;
598
- #N;
599
- #P() {
619
+ #L;
620
+ #R;
621
+ #z() {
600
622
  let e = this.renderRoot?.querySelector(`slot[name='${this.size}']`), t = null;
601
623
  for (let n of e?.assignedElements({ flatten: !0 }) ?? []) {
602
624
  let e = n instanceof HTMLImageElement || n instanceof HTMLCanvasElement ? n : n.querySelector("img, canvas");
@@ -605,9 +627,9 @@ var D, O = {
605
627
  break;
606
628
  }
607
629
  }
608
- t !== this.#t && (this.#t?.removeEventListener("load", this.#N), this.#t?.removeEventListener("error", this.#N), this.#t = t, t?.addEventListener("load", this.#N), t?.addEventListener("error", this.#N)), this.#F();
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();
609
631
  }
610
- #F() {
632
+ #B() {
611
633
  let e = this.#t, t = e instanceof HTMLImageElement ? e.complete && e.naturalWidth > 0 : e != null && e.width > 0;
612
634
  if (!this.open || e == null || !t) {
613
635
  this._ghost = null, this.#o = "";
@@ -615,7 +637,7 @@ var D, O = {
615
637
  }
616
638
  let n = e instanceof HTMLImageElement ? `${this.size} ${e.currentSrc}` : "";
617
639
  if (n !== "" && n === this.#o && this._ghost) return;
618
- let r = v(e);
640
+ let r = b(e);
619
641
  if (r) {
620
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)`;
621
643
  let t = e instanceof HTMLImageElement ? e.alt : "";
@@ -623,16 +645,16 @@ var D, O = {
623
645
  }
624
646
  this._ghost = r, this.#o = r ? n : "";
625
647
  }
626
- #I() {
627
- this.#L(), this.#c = window.setTimeout(() => {
648
+ #V() {
649
+ this.#H(), this.#c = window.setTimeout(() => {
628
650
  this.#c = 0, this.startEditing();
629
651
  }, 800);
630
652
  }
631
- #L() {
653
+ #H() {
632
654
  this.#c &&= (clearTimeout(this.#c), 0);
633
655
  }
634
656
  startEditing() {
635
- this.#L(), !(!this.editable || this._editing) && (this.#s = this.label, this._draft = this.label, this._editing = !0);
657
+ this.#H(), !(!this.editable || this._editing) && (this.#s = this.label, this._draft = this.label, this._editing = !0);
636
658
  }
637
659
  commitEditing() {
638
660
  if (!this._editing) return;
@@ -656,45 +678,45 @@ var D, O = {
656
678
  }
657
679
  render() {
658
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)` : "";
659
- return C`<div
681
+ return T`<div
660
682
  class="frame vf-snap"
661
683
  part="frame"
662
684
  style=${o}
663
- @pointerdown=${this.#U}
664
- @pointermove=${this.#m.onPointerMove}
665
- @pointerup=${this.#G}
666
- @pointercancel=${this.#G}
667
- @dblclick=${this.#W}
685
+ @pointerdown=${this.#J}
686
+ @pointermove=${this.#h.onPointerMove}
687
+ @pointerup=${this.#X}
688
+ @pointercancel=${this.#X}
689
+ @dblclick=${this.#Y}
668
690
  >
669
691
  <div class=${a} part="icon">
670
- ${this.size === "small" ? C`<slot name="small" @slotchange=${this.#M}></slot>` : C`<slot name="large" @slotchange=${this.#M}></slot>`}${this._ghost ?? w}
692
+ ${this.size === "small" ? T`<slot name="small" @slotchange=${this.#L}></slot>` : T`<slot name="large" @slotchange=${this.#L}></slot>`}${this._ghost ?? E}
671
693
  </div>
672
- ${r ? C`<div class=${i}>
694
+ ${r ? T`<div class=${i}>
673
695
  <!-- No whitespace around the span: it is the measured run, and a
674
696
  stray space would widen it. -->
675
697
  <div class="label" part="label"><span
676
698
  class="name"
677
699
  part="plate"
678
- style=${this.#e ? `width: ${this.#j}` : ""}
700
+ style=${this.#e ? `width: ${this.#I}` : ""}
679
701
  >${t}</span
680
702
  ></div>
681
- ${e ? C`<div class="rename-box">
703
+ ${e ? T`<div class="rename-box">
682
704
  <input
683
705
  class="rename"
684
706
  part="input"
685
707
  type="text"
686
708
  maxlength=${this.maxlength}
687
709
  .value=${this._draft}
688
- @beforeinput=${this.#q}
689
- @input=${this.#J}
690
- @keydown=${this.#X}
710
+ @beforeinput=${this.#Q}
711
+ @input=${this.#$}
712
+ @keydown=${this.#te}
691
713
  @blur=${this.commitEditing}
692
714
  />
693
- </div>` : w}
694
- </div>` : w}
715
+ </div>` : E}
716
+ </div>` : E}
695
717
  </div>`;
696
718
  }
697
- #R() {
719
+ #U() {
698
720
  if (!this.selectable) {
699
721
  this.#n.role = null, this.#n.ariaSelected = null, this.#n.ariaLabel = null;
700
722
  return;
@@ -703,22 +725,22 @@ var D, O = {
703
725
  this.#n.role = "option", this.#n.ariaSelected = this.selected ? "true" : "false", this.#n.ariaLabel = null;
704
726
  return;
705
727
  }
706
- this.#n.role = "img", this.#n.ariaSelected = null, this.#n.ariaLabel = this.label || this.#z || null;
728
+ this.#n.role = "img", this.#n.ariaSelected = null, this.#n.ariaLabel = this.label || this.#W || null;
707
729
  }
708
- get #z() {
730
+ get #W() {
709
731
  return this.#t instanceof HTMLImageElement ? this.#t.alt : "";
710
732
  }
711
- get #B() {
733
+ get #G() {
712
734
  return this.selectable;
713
735
  }
714
- #V() {
715
- this.hasAttribute("tabindex") || (this.#B ? this.tabIndex = 0 : this.removeAttribute("tabindex"));
736
+ #K() {
737
+ this.hasAttribute("tabindex") || (this.#G ? this.tabIndex = 0 : this.removeAttribute("tabindex"));
716
738
  }
717
- #H(t) {
739
+ #q(t) {
718
740
  t !== this.selected && (this.selected = t, e(this, "vf-select", { selected: t }));
719
741
  }
720
742
  setSelected(e) {
721
- this.#H(e);
743
+ this.#q(e);
722
744
  }
723
745
  touches(e) {
724
746
  let t = this.renderRoot;
@@ -731,43 +753,57 @@ var D, O = {
731
753
  }
732
754
  return !1;
733
755
  }
734
- #U;
735
- #W;
736
- #G;
737
- #K;
738
- #q;
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
+ }
739
770
  #J;
740
- #Y(t) {
771
+ #Y;
772
+ #X;
773
+ #Z;
774
+ #Q;
775
+ #$;
776
+ #ee(t) {
741
777
  e(this, "vf-name-too-long", {
742
778
  attempted: t,
743
779
  accepted: t.slice(0, this.maxlength),
744
780
  limit: this.maxlength
745
781
  });
746
782
  }
747
- #X;
748
- #Z;
783
+ #te;
784
+ #ne;
749
785
  };
750
- o([T()], M.prototype, "label", void 0), o([T({ reflect: !0 })], M.prototype, "size", void 0), o([T({
786
+ o([D()], P.prototype, "label", void 0), o([D({ reflect: !0 })], P.prototype, "size", void 0), o([D({
751
787
  type: Boolean,
752
788
  reflect: !0
753
- })], M.prototype, "selectable", void 0), o([T({
789
+ })], P.prototype, "selectable", void 0), o([D({
754
790
  type: Boolean,
755
791
  reflect: !0
756
- })], M.prototype, "selected", void 0), o([T({
792
+ })], P.prototype, "selected", void 0), o([D({
757
793
  type: Boolean,
758
794
  reflect: !0
759
- })], M.prototype, "target", void 0), o([T({
795
+ })], P.prototype, "target", void 0), o([D({
760
796
  type: Boolean,
761
797
  reflect: !0
762
- })], M.prototype, "color", void 0), o([T({
798
+ })], P.prototype, "color", void 0), o([D({
763
799
  type: Boolean,
764
800
  reflect: !0
765
- })], M.prototype, "open", void 0), o([T({
801
+ })], P.prototype, "open", void 0), o([D({
766
802
  type: Boolean,
767
803
  reflect: !0
768
- })], M.prototype, "movable", void 0), o([T({
804
+ })], P.prototype, "movable", void 0), o([D({
769
805
  type: Boolean,
770
806
  reflect: !0
771
- })], M.prototype, "editable", void 0), o([T({ type: Number })], M.prototype, "width", void 0), o([T({ type: Number })], M.prototype, "maxlength", void 0), o([E()], M.prototype, "_editing", void 0), o([E()], M.prototype, "_draft", void 0), o([E()], M.prototype, "_ghost", void 0), M = D = o([t("vf-icon")], M);
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);
772
808
  //#endregion
773
- export { M as VfIcon };
809
+ export { P as VfIcon };