vintage-frames 0.12.1 → 0.12.2

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