vintage-frames 0.12.1 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 { deriveDragOutline as y, deriveOpenArt as b, dotOutline as x, penPhase as S, xorPenCanvas as C } from "../open-art.js";
14
+ import { FocusRuleController as w } from "../focus-modality.js";
15
+ import { LitElement as T, css as E, html as D, nothing as O } from "lit";
16
+ import { property as k, state as A } from "lit/decorators.js";
17
17
  //#region src/components/vf-icon.ts
18
- var k, A = {
18
+ var j, M = {
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
+ }, N = 1, P = 8, F = (e, t) => t <= 0 ? Math.max(e, 0) : Math.min(Math.max(e, 0), t), I = class extends c(T) {
22
22
  static {
23
- k = this;
23
+ j = 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 w(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: F(e, n.width - a(this.offsetWidth, this)),
36
+ y: F(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 j);
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 ? P : N, 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, E`
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) => ({
@@ -541,28 +566,26 @@ var k, A = {
541
566
  plate: c ? p(c) : null
542
567
  });
543
568
  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)
569
+ let x = C("drag-outline"), S = x.style;
570
+ S.position = "absolute", S.width = i(b.width), S.height = i(b.height);
571
+ let w = t ?? a, T = t ? t.getBoundingClientRect() : e, E = {
572
+ x: Math.round((l - T.left) / o),
573
+ y: Math.round((u - T.top) / o)
551
574
  };
552
- return C.append(x), {
575
+ return w.append(x), {
553
576
  ring: b,
554
577
  canvas: x,
555
- base: T,
578
+ base: E,
556
579
  phase: -1
557
580
  };
558
581
  }
559
- #j(e, t, n) {
582
+ #P(e, t, n) {
560
583
  let r = e.base.x + t, a = e.base.y + n;
561
584
  e.canvas.style.left = i(r), e.canvas.style.top = i(a);
562
585
  let o = S(r, a);
563
586
  o !== e.phase && (e.phase = o, x(e.ring, e.canvas, o));
564
587
  }
565
- #M(e) {
588
+ #F(e) {
566
589
  let { left: t, top: n } = e.proposal ?? {
567
590
  left: e.origin.x,
568
591
  top: e.origin.y
@@ -574,32 +597,32 @@ var k, A = {
574
597
  top: n,
575
598
  x: e.frame.left + (t - e.origin.x) * i,
576
599
  y: e.frame.top + (n - e.origin.y) * i,
577
- icons: this.#T(e)
600
+ icons: this.#O(e)
578
601
  };
579
602
  }
580
603
  connectedCallback() {
581
- super.connectedCallback(), this.#K(), this.#U(), this.selectable && this.selected && this.#u.attach(), this.addEventListener("keydown", this.#ne);
604
+ super.connectedCallback(), this.#Y(), this.#K(), this.selectable && this.selected && this.#p.attach(), this.addEventListener("keydown", this.#oe);
582
605
  }
583
606
  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();
607
+ super.disconnectedCallback(), this.removeEventListener("keydown", this.#oe), this.#G(), this.#_?.outline?.canvas.remove();
608
+ for (let e of this.#_?.followers ?? []) e.end();
609
+ this.#_ = null, this.#x?.finish();
587
610
  }
588
611
  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) {
612
+ 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
613
  let e = this.renderRoot.querySelector("input");
591
614
  e?.focus(), e?.select();
592
615
  }
593
- (e.has("label") || e.has("_draft") || e.has("_editing")) && this.#F(), (e.has("open") || e.has("size")) && this.#z();
616
+ (e.has("label") || e.has("_draft") || e.has("_editing")) && this.#R(), (e.has("open") || e.has("size")) && this.#H();
594
617
  }
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\">");
618
+ #I;
619
+ #L() {
620
+ this.#I ||= l(this, `vf-icon${this.label ? ` ("${this.label}")` : ""}`, "<vf-icon movable label=\"Read Me\" width=\"64\" top=\"16\" left=\"16\">");
598
621
  }
599
622
  firstUpdated() {
600
- document.fonts.ready.then(() => this.#F());
623
+ document.fonts.ready.then(() => this.#R());
601
624
  }
602
- #F() {
625
+ #R() {
603
626
  let e = this.renderRoot?.querySelector(".name");
604
627
  if (!e) {
605
628
  this.#e = 0;
@@ -611,14 +634,14 @@ var k, A = {
611
634
  n.selectNodeContents(e), t = n.getBoundingClientRect().width, n.detach();
612
635
  }
613
636
  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;
637
+ this.#e = this._editing && t === 0 ? Math.max(i, M[this.size]) : i, e.style.width = this.#z;
615
638
  }
616
- get #I() {
639
+ get #z() {
617
640
  return this.#e ? `calc(var(--vf-scale, 1) * ${this.#e}px)` : "";
618
641
  }
619
- #L;
620
- #R;
621
- #z() {
642
+ #B;
643
+ #V;
644
+ #H() {
622
645
  let e = this.renderRoot?.querySelector(`slot[name='${this.size}']`), t = null;
623
646
  for (let n of e?.assignedElements({ flatten: !0 }) ?? []) {
624
647
  let e = n instanceof HTMLImageElement || n instanceof HTMLCanvasElement ? n : n.querySelector("img, canvas");
@@ -627,9 +650,9 @@ var k, A = {
627
650
  break;
628
651
  }
629
652
  }
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();
653
+ 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
654
  }
632
- #B() {
655
+ #U() {
633
656
  let e = this.#t, t = e instanceof HTMLImageElement ? e.complete && e.naturalWidth > 0 : e != null && e.width > 0;
634
657
  if (!this.open || e == null || !t) {
635
658
  this._ghost = null, this.#o = "";
@@ -645,16 +668,16 @@ var k, A = {
645
668
  }
646
669
  this._ghost = r, this.#o = r ? n : "";
647
670
  }
648
- #V() {
649
- this.#H(), this.#c = window.setTimeout(() => {
671
+ #W() {
672
+ this.#G(), this.#c = window.setTimeout(() => {
650
673
  this.#c = 0, this.startEditing();
651
674
  }, 800);
652
675
  }
653
- #H() {
676
+ #G() {
654
677
  this.#c &&= (clearTimeout(this.#c), 0);
655
678
  }
656
679
  startEditing() {
657
- this.#H(), !(!this.editable || this._editing) && (this.#s = this.label, this._draft = this.label, this._editing = !0);
680
+ this.#G(), !(!this.editable || this._editing) && (this.#s = this.label, this._draft = this.label, this._editing = !0);
658
681
  }
659
682
  commitEditing() {
660
683
  if (!this._editing) return;
@@ -678,45 +701,45 @@ var k, A = {
678
701
  }
679
702
  render() {
680
703
  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
704
+ return D`<div
682
705
  class="frame vf-snap"
683
706
  part="frame"
684
707
  style=${o}
685
- @pointerdown=${this.#J}
686
- @pointermove=${this.#h.onPointerMove}
687
- @pointerup=${this.#X}
688
- @pointercancel=${this.#X}
689
- @dblclick=${this.#Y}
708
+ @pointerdown=${this.#Z}
709
+ @pointermove=${this.#v.onPointerMove}
710
+ @pointerup=${this.#$}
711
+ @pointercancel=${this.#$}
712
+ @dblclick=${this.#Q}
690
713
  >
691
714
  <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}
715
+ ${this.size === "small" ? D`<slot name="small" @slotchange=${this.#B}></slot>` : D`<slot name="large" @slotchange=${this.#B}></slot>`}${this._ghost ?? O}
693
716
  </div>
694
- ${r ? T`<div class=${i}>
717
+ ${r ? D`<div class=${i}>
695
718
  <!-- No whitespace around the span: it is the measured run, and a
696
719
  stray space would widen it. -->
697
720
  <div class="label" part="label"><span
698
721
  class="name"
699
722
  part="plate"
700
- style=${this.#e ? `width: ${this.#I}` : ""}
723
+ style=${this.#e ? `width: ${this.#z}` : ""}
701
724
  >${t}</span
702
725
  ></div>
703
- ${e ? T`<div class="rename-box">
726
+ ${e ? D`<div class="rename-box">
704
727
  <input
705
728
  class="rename"
706
729
  part="input"
707
730
  type="text"
708
731
  maxlength=${this.maxlength}
709
732
  .value=${this._draft}
710
- @beforeinput=${this.#Q}
711
- @input=${this.#$}
712
- @keydown=${this.#te}
733
+ @beforeinput=${this.#ne}
734
+ @input=${this.#re}
735
+ @keydown=${this.#ae}
713
736
  @blur=${this.commitEditing}
714
737
  />
715
- </div>` : E}
716
- </div>` : E}
738
+ </div>` : O}
739
+ </div>` : O}
717
740
  </div>`;
718
741
  }
719
- #U() {
742
+ #K() {
720
743
  if (!this.selectable) {
721
744
  this.#n.role = null, this.#n.ariaSelected = null, this.#n.ariaLabel = null;
722
745
  return;
@@ -725,22 +748,22 @@ var k, A = {
725
748
  this.#n.role = "option", this.#n.ariaSelected = this.selected ? "true" : "false", this.#n.ariaLabel = null;
726
749
  return;
727
750
  }
728
- this.#n.role = "img", this.#n.ariaSelected = null, this.#n.ariaLabel = this.label || this.#W || null;
751
+ this.#n.role = "img", this.#n.ariaSelected = null, this.#n.ariaLabel = this.label || this.#q || null;
729
752
  }
730
- get #W() {
753
+ get #q() {
731
754
  return this.#t instanceof HTMLImageElement ? this.#t.alt : "";
732
755
  }
733
- get #G() {
756
+ get #J() {
734
757
  return this.selectable;
735
758
  }
736
- #K() {
737
- this.hasAttribute("tabindex") || (this.#G ? this.tabIndex = 0 : this.removeAttribute("tabindex"));
759
+ #Y() {
760
+ this.hasAttribute("tabindex") || (this.#J ? this.tabIndex = 0 : this.removeAttribute("tabindex"));
738
761
  }
739
- #q(t) {
762
+ #X(t) {
740
763
  t !== this.selected && (this.selected = t, e(this, "vf-select", { selected: t }));
741
764
  }
742
765
  setSelected(e) {
743
- this.#q(e);
766
+ this.#X(e);
744
767
  }
745
768
  touches(e) {
746
769
  let t = this.renderRoot;
@@ -753,57 +776,68 @@ var k, A = {
753
776
  }
754
777
  return !1;
755
778
  }
779
+ cellRect() {
780
+ return this.checkVisibility() ? this.renderRoot?.querySelector(".art")?.getBoundingClientRect() ?? this.getBoundingClientRect() : null;
781
+ }
756
782
  moveTo(e, t) {
757
- this.#v?.finish(), this.#P(), this.#p.seed(), this.#p.moveTo(e, t);
783
+ this.#x?.finish(), this.#L(), this.#g.seed(), this.#g.moveTo(e, t);
758
784
  }
759
785
  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) => {
786
+ if (this.#x?.finish(), await this.updateComplete, this.#x?.finish(), !this.isConnected) return !1;
787
+ this.#L();
788
+ 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());
789
+ return o ? (this.#P(o, 0, 0), new Promise((e) => {
764
790
  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;
791
+ t = v(Math.hypot(i, a), (e) => this.#P(o, Math.round(i * e), Math.round(a * e)), () => {
792
+ this.#x === t && (this.#x = null, this.#S.detach()), o.canvas.remove(), this.isConnected && this.#g.moveTo(r.x, r.y), e(!0);
793
+ }), this.#x = t, this.#S.attach();
794
+ })) : (this.#g.moveTo(r.x, r.y), !1);
795
+ }
773
796
  #Z;
774
797
  #Q;
775
798
  #$;
776
- #ee(t) {
799
+ #ee(e, t) {
800
+ let n = this.#d;
801
+ 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 = {
802
+ time: n.time,
803
+ x: n.x,
804
+ y: n.y
805
+ }, !1);
806
+ }
807
+ #te;
808
+ #ne;
809
+ #re;
810
+ #ie(t) {
777
811
  e(this, "vf-name-too-long", {
778
812
  attempted: t,
779
813
  accepted: t.slice(0, this.maxlength),
780
814
  limit: this.maxlength
781
815
  });
782
816
  }
783
- #te;
784
- #ne;
817
+ #ae;
818
+ #oe;
785
819
  };
786
- o([D()], P.prototype, "label", void 0), o([D({ reflect: !0 })], P.prototype, "size", void 0), o([D({
820
+ o([k()], I.prototype, "label", void 0), o([k({ reflect: !0 })], I.prototype, "size", void 0), o([k({
787
821
  type: Boolean,
788
822
  reflect: !0
789
- })], P.prototype, "selectable", void 0), o([D({
823
+ })], I.prototype, "selectable", void 0), o([k({
790
824
  type: Boolean,
791
825
  reflect: !0
792
- })], P.prototype, "selected", void 0), o([D({
826
+ })], I.prototype, "selected", void 0), o([k({
793
827
  type: Boolean,
794
828
  reflect: !0
795
- })], P.prototype, "target", void 0), o([D({
829
+ })], I.prototype, "target", void 0), o([k({
796
830
  type: Boolean,
797
831
  reflect: !0
798
- })], P.prototype, "color", void 0), o([D({
832
+ })], I.prototype, "color", void 0), o([k({
799
833
  type: Boolean,
800
834
  reflect: !0
801
- })], P.prototype, "open", void 0), o([D({
835
+ })], I.prototype, "open", void 0), o([k({
802
836
  type: Boolean,
803
837
  reflect: !0
804
- })], P.prototype, "movable", void 0), o([D({
838
+ })], I.prototype, "movable", void 0), o([k({
805
839
  type: Boolean,
806
840
  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);
841
+ })], I.prototype, "editable", void 0), o([k({ type: Number })], I.prototype, "width", void 0), o([k({ type: Number })], I.prototype, "maxlength", void 0), o([A()], I.prototype, "_editing", void 0), o([A()], I.prototype, "_draft", void 0), o([A()], I.prototype, "_ghost", void 0), I = j = o([t("vf-icon")], I);
808
842
  //#endregion
809
- export { P as VfIcon };
843
+ export { I as VfIcon };