vintage-frames 0.6.2 → 0.7.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.
@@ -1,69 +1,108 @@
1
1
  import { emit as e } from "../events.js";
2
2
  import { vfElement as t } from "../define.js";
3
- import { ScaleController as n, effectiveScale as r, toSysExact as i } from "../scale.js";
4
- import a from "../_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/decorate.js";
5
- import { PlacementController as o, VfPositioned as s, warnMovableContract as c } from "../position.js";
6
- import { vfBodyDecls as l } from "../styles/recipes/body-face.js";
7
- import { vfBase as u } from "../styles/recipes/host.js";
8
- import { vfFocusUnderline as d } from "../styles/recipes/focus.js";
9
- import { GridSnapController as f } from "../grid-snap.js";
10
- import { DocumentListenersController as p } from "../document-listeners.js";
11
- import { DragController as m } from "../drag.js";
3
+ import { ScaleController as n, effectiveScale as r, sysLength as i, toSysExact as a } from "../scale.js";
4
+ import o from "../_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/decorate.js";
5
+ import { PlacementController as s, VfPositioned as c, warnMovableContract as l } from "../position.js";
6
+ import { vfBodyDecls as u } from "../styles/recipes/body-face.js";
7
+ import { vfBase as d } from "../styles/recipes/host.js";
8
+ import { vfFocusUnderline as f } from "../styles/recipes/focus.js";
9
+ import { GridSnapController as p } from "../grid-snap.js";
10
+ import { DocumentListenersController as m } from "../document-listeners.js";
11
+ import { DragController as h } from "../drag.js";
12
12
  import "../motion.js";
13
- import { FocusRuleController as h } from "../focus-modality.js";
14
- import { deriveOpenArt as g } from "../open-art.js";
15
- import { LitElement as _, css as v, html as y, nothing as b } from "lit";
16
- import { property as x, state as S } from "lit/decorators.js";
13
+ import { FocusRuleController as g } from "../focus-modality.js";
14
+ import { deriveDragOutline as _, deriveOpenArt as v, dotOutline as y } from "../open-art.js";
15
+ import { LitElement as b, css as x, html as S, nothing as C } from "lit";
16
+ import { property as w, state as T } from "lit/decorators.js";
17
17
  //#region src/components/vf-icon.ts
18
- var C = {
18
+ var E, D = {
19
19
  large: 32,
20
20
  small: 16
21
- }, w = 1, T = 8, E = (e, t) => t <= 0 ? Math.max(e, 0) : Math.min(Math.max(e, 0), t), D = class extends s(_) {
21
+ }, O = 1, k = 8, A = (e, t) => t <= 0 ? Math.max(e, 0) : Math.min(Math.max(e, 0), t), j = class extends c(b) {
22
+ static {
23
+ E = this;
24
+ }
22
25
  constructor(...t) {
23
- super(...t), this.label = "", this.size = "large", this.selectable = !1, this.selected = !1, this.color = !1, this.open = !1, this.movable = !1, this.editable = !1, this.maxlength = 31, this.scale = new n(this), this.gridSnap = new f(this), this.focusRule = new h(this), this._editing = !1, this._draft = "", this.#e = 0, this._ghost = null, this.#t = null, this.#n = this.attachInternals(), this.#i = "", this.#a = "", this.#o = 0, this.#s = -Infinity, this.#c = new p(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 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, () => [[
24
27
  document,
25
28
  "pointerdown",
26
- this.#A,
29
+ this.#K,
27
30
  !0
28
- ]]), this.#l = (e, t, n) => ({
29
- x: E(e, n.width - i(this.offsetWidth, this)),
30
- y: E(t, n.height - i(this.offsetHeight, this))
31
- }), this.#u = new o(this, (e, t, n) => this.#l(e, t, n)), this.#d = {
32
- x: 0,
33
- y: 0
34
- }, this.#f = new m(this, {
35
- onDragStart: (e) => !this.movable || e.button !== 0 || this._editing ? null : (this.#m(), this.#d = this.#u.seed()),
36
- onDrag: (e, t) => {
37
- (e !== this.#d.x || t !== this.#d.y) && this.#S(), this.#u.moveTo(e, t);
31
+ ]]), this.#d = (e, t, n) => ({
32
+ x: A(e, n.width - a(this.offsetWidth, this)),
33
+ y: A(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, {
35
+ onDragStart: (e) => {
36
+ if (!this.movable || e.button !== 0 || this._editing) return null;
37
+ this.#k();
38
+ let t = this.#f.seed();
39
+ return this.#p = {
40
+ origin: t,
41
+ frame: this.#_(),
42
+ pointer: {
43
+ clientX: e.clientX,
44
+ clientY: e.clientY
45
+ },
46
+ proposal: null,
47
+ outline: null,
48
+ followers: [],
49
+ size: this.#v()
50
+ }, t;
51
+ },
52
+ onDrag: (e, t, n) => {
53
+ this.#x(e, t, n);
54
+ },
55
+ onDragEnd: (e, t) => {
56
+ this.#S(e, t);
38
57
  }
39
- }), this.#p = !1, this.#_ = () => {
40
- this.#y(), this.#C();
41
- }, this.#v = () => {
42
- this.#b();
43
- }, this.#O = (e) => {
58
+ }), this.#h = new m(this, () => [[
59
+ document,
60
+ "keydown",
61
+ this.#g,
62
+ !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) => {
44
70
  if (e.button !== 0 || this._editing) return;
45
- let t = e.composedPath().some((e) => e instanceof HTMLElement && e.classList.contains("label")), n = this.selected, r = e.timeStamp - this.#s < 800;
46
- this.#s = e.timeStamp, this.#S(), this.selectable && (e.shiftKey || e.metaKey ? this.#D(!this.selected) : this.#D(!0)), this.editable && t && n && !r && !e.shiftKey && !e.metaKey && this.#x(), this.#T && (this.focus({ preventScroll: !0 }), this.focusRule.suppress()), this.#f.onPointerDown(e);
47
- }, this.#k = () => {
71
+ 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();
73
+ 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 = () => {
48
76
  this._editing || e(this, "vf-open", {});
49
- }, this.#A = (e) => {
50
- e.composedPath().includes(this) || (this.#S(), !(e.shiftKey || e.metaKey) && this.#D(!1));
51
- }, this.#j = (e) => {
77
+ }, this.#G = (e) => {
78
+ if (this.#m.onPointerUp(e), !this.#a || (this.#a = !1, e.type !== "pointerup")) return;
79
+ let t = this.#i;
80
+ if (t) for (let e of t.querySelectorAll("vf-icon")) e !== this && e.selected && e.setSelected(!1);
81
+ }, this.#K = (e) => {
82
+ let t = e.composedPath();
83
+ if (t.includes(this) || (this.#L(), e.shiftKey || e.metaKey)) return;
84
+ let n = this.#i;
85
+ if (n !== null) {
86
+ let e = t.find((e) => e instanceof E);
87
+ if (e?.selected && e.#i === n) return;
88
+ }
89
+ this.#H(!1);
90
+ }, this.#q = (e) => {
52
91
  let t = e.target, n = e.data ?? e.dataTransfer?.getData("text") ?? "";
53
92
  if (n === "") return;
54
93
  let r = t.selectionStart ?? t.value.length, i = t.selectionEnd ?? r, a = t.value.slice(0, r) + n + t.value.slice(i);
55
- a.length > this.maxlength && this.#N(a);
56
- }, this.#M = (e) => {
94
+ a.length > this.maxlength && this.#Y(a);
95
+ }, this.#J = (e) => {
57
96
  let t = e.target;
58
97
  if (t.value.length > this.maxlength) {
59
98
  let e = t.value, n = Math.min(t.selectionStart ?? this.maxlength, this.maxlength);
60
- t.value = e.slice(0, this.maxlength), t.setSelectionRange(n, n), this.#N(e);
99
+ t.value = e.slice(0, this.maxlength), t.setSelectionRange(n, n), this.#Y(e);
61
100
  }
62
101
  this._draft = t.value;
63
- }, this.#P = (e) => {
102
+ }, this.#X = (e) => {
64
103
  e.key === "Enter" ? (e.preventDefault(), this.commitEditing(), this.focus()) : e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.cancelEditing(), this.focus());
65
- }, this.#F = (t) => {
66
- if (this.#S(), !(this._editing || t.defaultPrevented)) {
104
+ }, this.#Z = (t) => {
105
+ if (this.#L(), !(this._editing || t.defaultPrevented)) {
67
106
  if ((t.metaKey || t.ctrlKey) && !t.altKey && (t.key.toLowerCase() === "o" || t.key === "ArrowDown")) {
68
107
  t.preventDefault(), e(this, "vf-open", {});
69
108
  return;
@@ -75,7 +114,7 @@ var C = {
75
114
  return;
76
115
  case " ":
77
116
  if (!this.selectable) return;
78
- t.preventDefault(), this.focusRule.reveal(), this.#D(!this.selected);
117
+ t.preventDefault(), this.focusRule.reveal(), this.#H(!this.selected);
79
118
  return;
80
119
  case "ArrowLeft":
81
120
  case "ArrowRight":
@@ -83,17 +122,17 @@ var C = {
83
122
  case "ArrowDown": {
84
123
  if (!this.movable) return;
85
124
  t.preventDefault(), this.focusRule.reveal();
86
- let e = t.shiftKey ? T : w, n = t.key === "ArrowLeft" ? -e : t.key === "ArrowRight" ? e : 0, r = t.key === "ArrowUp" ? -e : t.key === "ArrowDown" ? e : 0;
87
- this.#m();
88
- let i = this.#u.seed();
89
- this.#u.moveTo(i.x + n, i.y + r);
125
+ let e = t.shiftKey ? k : O, 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);
90
129
  }
91
130
  }
92
131
  }
93
132
  };
94
133
  }
95
134
  static {
96
- this.styles = [u, v`
135
+ this.styles = [d, x`
97
136
  :host {
98
137
  display: inline-block;
99
138
  cursor: var(--vf-cursor, default);
@@ -110,6 +149,13 @@ var C = {
110
149
  flex-direction: column;
111
150
  align-items: center;
112
151
  }
152
+ /* The frame is the drag handle, so a touch on a movable icon is the
153
+ drag and never the page's pan — the window and dialog title bars
154
+ set the same. Only when movable: suppressing scrolling over an icon
155
+ that cannot be dragged would be a behavior change for nothing. */
156
+ :host([movable]) .frame {
157
+ touch-action: none;
158
+ }
113
159
  .art {
114
160
  position: relative;
115
161
  display: flex;
@@ -135,6 +181,15 @@ var C = {
135
181
  :host([selected][color]) .art {
136
182
  filter: brightness(0.5);
137
183
  }
184
+ /* The destination highlight under a drag: the selected treatment of
185
+ the art alone — the Finder inverted the folder an icon was dragged
186
+ over — with none of selected's semantics, and the plate untouched. */
187
+ :host([target]) .art {
188
+ filter: invert(1);
189
+ }
190
+ :host([target][color]) .art {
191
+ filter: brightness(0.5);
192
+ }
138
193
  /* The open ghost replaces the slotted art while there is one — the
139
194
  slot stays in the tree (it is where the art loads and re-loads
140
195
  from) but paints nothing. Gated on the class, not :host([open]):
@@ -161,7 +216,7 @@ var C = {
161
216
  margin-top: calc(var(--vf-scale, 1) * var(--vf-icon-gap, 2px));
162
217
  }
163
218
  .label {
164
- ${l}
219
+ ${u}
165
220
  font-weight: var(--vf-font-weight, 700);
166
221
  /* Whole system px, never a ratio — layout contract rule 2. 12, not
167
222
  the face's 16px em: the Finder's plate is 12 system px tall, and
@@ -249,7 +304,7 @@ var C = {
249
304
  selection paint at this edge, which is the whole reason it has no
250
305
  border of its own (see .rename-box). */
251
306
  height: calc(var(--vf-scale, 1) * var(--vf-icon-label-height, 12px));
252
- ${l}
307
+ ${u}
253
308
  font-weight: var(--vf-font-weight, 700);
254
309
  line-height: calc(
255
310
  var(--vf-scale, 1) * var(--vf-icon-label-height, 12px)
@@ -292,12 +347,12 @@ var C = {
292
347
  as a visible focus (see focus-modality.ts). */
293
348
  .caption.focus-rule .label::after {
294
349
  --vf-focus-underline-offset: -2px;
295
- ${d}
350
+ ${f}
296
351
  }
297
352
  /* No name, no plate — the rule falls back to the art cell. */
298
353
  .art.focus-rule::after {
299
354
  --vf-focus-underline-offset: -2px;
300
- ${d}
355
+ ${f}
301
356
  }
302
357
  :host(:focus) {
303
358
  outline: none;
@@ -308,9 +363,11 @@ var C = {
308
363
  #t;
309
364
  #n;
310
365
  get #r() {
311
- return this.closest("[role=\"listbox\"]") !== null;
366
+ return this.#i !== null;
367
+ }
368
+ get #i() {
369
+ return this.closest("vf-icon-field, [role=\"listbox\"]");
312
370
  }
313
- #i;
314
371
  #a;
315
372
  #o;
316
373
  #s;
@@ -319,27 +376,204 @@ var C = {
319
376
  #u;
320
377
  #d;
321
378
  #f;
379
+ #p;
380
+ #m;
381
+ #h;
382
+ #g;
383
+ #_() {
384
+ return this.renderRoot?.querySelector(".frame")?.getBoundingClientRect() ?? this.getBoundingClientRect();
385
+ }
386
+ #v() {
387
+ return {
388
+ width: a(this.offsetWidth, this),
389
+ height: a(this.offsetHeight, this)
390
+ };
391
+ }
392
+ followDrag(e) {
393
+ if (!this.movable || this._editing) return null;
394
+ let t = this.#f.seed(), n = this.#T(this.#_(), e);
395
+ return {
396
+ icon: this,
397
+ origin: t,
398
+ size: this.#v(),
399
+ move: (e, t) => {
400
+ n && this.#E(n, e, t);
401
+ },
402
+ drop: (e, n) => {
403
+ this.#f.moveTo(t.x + e, t.y + n);
404
+ },
405
+ end: () => n?.canvas.remove()
406
+ };
407
+ }
408
+ #y(e) {
409
+ if (!this.selected) return [];
410
+ let t = this.#i;
411
+ if (!t) return [];
412
+ let n = [];
413
+ for (let r of t.querySelectorAll("vf-icon")) {
414
+ if (r === this || !r.selected) continue;
415
+ let t = r.followDrag(e);
416
+ t && n.push(t);
417
+ }
418
+ return n;
419
+ }
420
+ #b(e) {
421
+ return [this, ...e.followers.map((e) => e.icon)];
422
+ }
423
+ #x(t, n, r) {
424
+ let i = this.#p;
425
+ if (!i) return;
426
+ if (i.pointer = {
427
+ clientX: r.clientX,
428
+ clientY: r.clientY
429
+ }, !i.proposal) {
430
+ if (t === i.origin.x && n === i.origin.y) return;
431
+ this.#L(), this.#a = !1, i.proposal = {
432
+ left: i.origin.x,
433
+ top: i.origin.y
434
+ }, this.#h.attach();
435
+ let r = this.#w();
436
+ i.outline = this.#T(i.frame, r), i.followers = this.#y(r), e(this, "vf-drag-start", {
437
+ left: i.origin.x,
438
+ top: i.origin.y,
439
+ icons: this.#b(i)
440
+ });
441
+ }
442
+ if (t === i.proposal.left && n === i.proposal.top) return;
443
+ i.proposal = {
444
+ left: t,
445
+ top: n
446
+ };
447
+ let a = t - i.origin.x, o = n - i.origin.y;
448
+ i.outline && this.#E(i.outline, a, o);
449
+ for (let e of i.followers) e.move(a, o);
450
+ e(this, "vf-drag", this.#D(i));
451
+ }
452
+ #S(t, n) {
453
+ let r = this.#p;
454
+ if (this.#p = null, !r?.proposal) return;
455
+ this.#h.detach(), r.outline?.canvas.remove();
456
+ for (let e of r.followers) e.end();
457
+ if (t && (r.pointer = {
458
+ clientX: t.clientX,
459
+ clientY: t.clientY
460
+ }), n) {
461
+ e(this, "vf-drag-cancel", {});
462
+ return;
463
+ }
464
+ let i = this.#D(r);
465
+ e(this, "vf-drop", i, { cancelable: !0 }) && this.#C(r, i);
466
+ }
467
+ #C(e, t) {
468
+ if (e.followers.length === 0) {
469
+ this.#f.moveTo(t.left, t.top);
470
+ return;
471
+ }
472
+ let n = this.#f.bounds, r = [{
473
+ origin: e.origin,
474
+ size: e.size
475
+ }, ...e.followers.map((e) => ({
476
+ origin: e.origin,
477
+ size: e.size
478
+ }))], i = (e, t, n, i) => {
479
+ let a = -Infinity, o = Infinity;
480
+ for (let e of r) a = Math.max(a, -t(e)), o = Math.min(o, i - n(e) - t(e));
481
+ return o < a && (o = Infinity), Math.min(Math.max(e, a), o);
482
+ }, a = i(t.left - e.origin.x, (e) => e.origin.x, (e) => e.size.width, n.width), o = i(t.top - e.origin.y, (e) => e.origin.y, (e) => e.size.height, n.height);
483
+ this.#f.moveTo(e.origin.x + a, e.origin.y + o);
484
+ for (let t of e.followers) t.drop(a, o);
485
+ }
486
+ #w() {
487
+ let t = { surface: null };
488
+ return e(this, "vf-drag-surface-request", t, { composed: !1 }), t.surface;
489
+ }
490
+ #T(e, t) {
491
+ let n = this.renderRoot, a = n?.querySelector(".frame");
492
+ if (!a) return null;
493
+ let o = r(this), s = (t) => ({
494
+ x: Math.round((t.left - e.left) / o),
495
+ y: Math.round((t.top - e.top) / o),
496
+ width: Math.round(t.width / o),
497
+ height: Math.round(t.height / o)
498
+ }), 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, {
499
+ width: c,
500
+ height: l,
501
+ art: m && m.width > 0 ? s(m) : null,
502
+ cell: u ? s(u.getBoundingClientRect()) : {
503
+ x: 0,
504
+ y: 0,
505
+ width: c,
506
+ height: l
507
+ },
508
+ plate: d ? s(d.getBoundingClientRect()) : null
509
+ });
510
+ if (!h) return null;
511
+ let g = document.createElement("canvas");
512
+ g.className = "drag-outline";
513
+ let v = g.style;
514
+ 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);
515
+ let y = {
516
+ x: 0,
517
+ y: 0
518
+ };
519
+ if (t) {
520
+ let n = t.getBoundingClientRect();
521
+ y = {
522
+ x: Math.round((e.left - n.left) / o),
523
+ y: Math.round((e.top - n.top) / o)
524
+ }, t.append(g);
525
+ } else a.append(g);
526
+ return {
527
+ ring: h,
528
+ canvas: g,
529
+ base: y,
530
+ phase: -1
531
+ };
532
+ }
533
+ #E(e, t, n) {
534
+ let r = e.base.x + t, a = e.base.y + n;
535
+ e.canvas.style.left = i(r), e.canvas.style.top = i(a);
536
+ let o = ((r + a) % 2 + 2) % 2;
537
+ o !== e.phase && (e.phase = o, y(e.ring, e.canvas, o));
538
+ }
539
+ #D(e) {
540
+ let { left: t, top: n } = e.proposal ?? {
541
+ left: e.origin.x,
542
+ top: e.origin.y
543
+ }, i = r(this);
544
+ return {
545
+ clientX: e.pointer.clientX,
546
+ clientY: e.pointer.clientY,
547
+ left: t,
548
+ top: n,
549
+ x: e.frame.left + (t - e.origin.x) * i,
550
+ y: e.frame.top + (n - e.origin.y) * i,
551
+ icons: this.#b(e)
552
+ };
553
+ }
322
554
  connectedCallback() {
323
- super.connectedCallback(), this.#E(), this.#C(), this.addEventListener("keydown", this.#F);
555
+ super.connectedCallback(), this.#V(), this.#R(), this.selectable && this.selected && this.#u.attach(), this.addEventListener("keydown", this.#Z);
324
556
  }
325
557
  disconnectedCallback() {
326
- super.disconnectedCallback(), this.removeEventListener("keydown", this.#F), this.#S();
558
+ super.disconnectedCallback(), this.removeEventListener("keydown", this.#Z), this.#L(), this.#p?.outline?.canvas.remove();
559
+ for (let e of this.#p?.followers ?? []) e.end();
560
+ this.#p = null;
327
561
  }
328
562
  updated(e) {
329
- if (e.has("selectable") && this.#E(), (e.has("selectable") || e.has("selected") || e.has("label")) && this.#C(), (e.has("selected") || e.has("selectable")) && (this.selectable && this.selected ? this.#c.attach() : this.#c.detach()), e.has("_editing") && this._editing) {
563
+ 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) {
330
564
  let e = this.renderRoot.querySelector("input");
331
565
  e?.focus(), e?.select();
332
566
  }
333
- (e.has("label") || e.has("_draft") || e.has("_editing")) && this.#h(), (e.has("open") || e.has("size")) && this.#y();
567
+ (e.has("label") || e.has("_draft") || e.has("_editing")) && this.#A(), (e.has("open") || e.has("size")) && this.#P();
334
568
  }
335
- #p;
336
- #m() {
337
- this.#p ||= c(this, `vf-icon${this.label ? ` ("${this.label}")` : ""}`, "<vf-icon movable label=\"Read Me\" width=\"64\" top=\"16\" left=\"16\">");
569
+ #O;
570
+ #k() {
571
+ this.#O ||= l(this, `vf-icon${this.label ? ` ("${this.label}")` : ""}`, "<vf-icon movable label=\"Read Me\" width=\"64\" top=\"16\" left=\"16\">");
338
572
  }
339
573
  firstUpdated() {
340
- document.fonts.ready.then(() => this.#h());
574
+ document.fonts.ready.then(() => this.#A());
341
575
  }
342
- #h() {
576
+ #A() {
343
577
  let e = this.renderRoot?.querySelector(".name");
344
578
  if (!e) {
345
579
  this.#e = 0;
@@ -351,14 +585,14 @@ var C = {
351
585
  n.selectNodeContents(e), t = n.getBoundingClientRect().width, n.detach();
352
586
  }
353
587
  let n = t / r(this) + 2, i = Math.max(2, Math.ceil(n / 2) * 2);
354
- this.#e = this._editing && t === 0 ? Math.max(i, C[this.size]) : i, e.style.width = this.#g;
588
+ this.#e = this._editing && t === 0 ? Math.max(i, D[this.size]) : i, e.style.width = this.#j;
355
589
  }
356
- get #g() {
590
+ get #j() {
357
591
  return this.#e ? `calc(var(--vf-scale, 1) * ${this.#e}px)` : "";
358
592
  }
359
- #_;
360
- #v;
361
- #y() {
593
+ #M;
594
+ #N;
595
+ #P() {
362
596
  let e = this.renderRoot?.querySelector(`slot[name='${this.size}']`), t = null;
363
597
  for (let n of e?.assignedElements({ flatten: !0 }) ?? []) {
364
598
  let e = n instanceof HTMLImageElement || n instanceof HTMLCanvasElement ? n : n.querySelector("img, canvas");
@@ -367,39 +601,39 @@ var C = {
367
601
  break;
368
602
  }
369
603
  }
370
- 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.#b();
604
+ 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();
371
605
  }
372
- #b() {
606
+ #F() {
373
607
  let e = this.#t, t = e instanceof HTMLImageElement ? e.complete && e.naturalWidth > 0 : e != null && e.width > 0;
374
608
  if (!this.open || e == null || !t) {
375
- this._ghost = null, this.#i = "";
609
+ this._ghost = null, this.#o = "";
376
610
  return;
377
611
  }
378
612
  let n = e instanceof HTMLImageElement ? `${this.size} ${e.currentSrc}` : "";
379
- if (n !== "" && n === this.#i && this._ghost) return;
380
- let r = g(e);
613
+ if (n !== "" && n === this.#o && this._ghost) return;
614
+ let r = v(e);
381
615
  if (r) {
382
616
  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)`;
383
617
  let t = e instanceof HTMLImageElement ? e.alt : "";
384
618
  t && (r.setAttribute("role", "img"), r.setAttribute("aria-label", t));
385
619
  }
386
- this._ghost = r, this.#i = r ? n : "";
620
+ this._ghost = r, this.#o = r ? n : "";
387
621
  }
388
- #x() {
389
- this.#S(), this.#o = window.setTimeout(() => {
390
- this.#o = 0, this.startEditing();
622
+ #I() {
623
+ this.#L(), this.#c = window.setTimeout(() => {
624
+ this.#c = 0, this.startEditing();
391
625
  }, 800);
392
626
  }
393
- #S() {
394
- this.#o &&= (clearTimeout(this.#o), 0);
627
+ #L() {
628
+ this.#c &&= (clearTimeout(this.#c), 0);
395
629
  }
396
630
  startEditing() {
397
- this.#S(), !(!this.editable || this._editing) && (this.#a = this.label, this._draft = this.label, this._editing = !0);
631
+ this.#L(), !(!this.editable || this._editing) && (this.#s = this.label, this._draft = this.label, this._editing = !0);
398
632
  }
399
633
  commitEditing() {
400
634
  if (!this._editing) return;
401
635
  this._editing = !1;
402
- let t = this.#a, n = this._draft;
636
+ let t = this.#s, n = this._draft;
403
637
  if (n.trim() === "") {
404
638
  this._draft = t, n !== t && e(this, "vf-name-rejected", {
405
639
  attempted: n,
@@ -414,49 +648,49 @@ var C = {
414
648
  }));
415
649
  }
416
650
  cancelEditing() {
417
- this._editing && (this._editing = !1, this._draft = this.#a);
651
+ this._editing && (this._editing = !1, this._draft = this.#s);
418
652
  }
419
653
  render() {
420
654
  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)` : "";
421
- return y`<div
655
+ return S`<div
422
656
  class="frame vf-snap"
423
657
  part="frame"
424
658
  style=${o}
425
- @pointerdown=${this.#O}
426
- @pointermove=${this.#f.onPointerMove}
427
- @pointerup=${this.#f.onPointerUp}
428
- @pointercancel=${this.#f.onPointerUp}
429
- @dblclick=${this.#k}
659
+ @pointerdown=${this.#U}
660
+ @pointermove=${this.#m.onPointerMove}
661
+ @pointerup=${this.#G}
662
+ @pointercancel=${this.#G}
663
+ @dblclick=${this.#W}
430
664
  >
431
665
  <div class=${a} part="icon">
432
- ${this.size === "small" ? y`<slot name="small" @slotchange=${this.#_}></slot>` : y`<slot name="large" @slotchange=${this.#_}></slot>`}${this._ghost ?? b}
666
+ ${this.size === "small" ? S`<slot name="small" @slotchange=${this.#M}></slot>` : S`<slot name="large" @slotchange=${this.#M}></slot>`}${this._ghost ?? C}
433
667
  </div>
434
- ${r ? y`<div class=${i}>
668
+ ${r ? S`<div class=${i}>
435
669
  <!-- No whitespace around the span: it is the measured run, and a
436
670
  stray space would widen it. -->
437
671
  <div class="label" part="label"><span
438
672
  class="name"
439
673
  part="plate"
440
- style=${this.#e ? `width: ${this.#g}` : ""}
674
+ style=${this.#e ? `width: ${this.#j}` : ""}
441
675
  >${t}</span
442
676
  ></div>
443
- ${e ? y`<div class="rename-box">
677
+ ${e ? S`<div class="rename-box">
444
678
  <input
445
679
  class="rename"
446
680
  part="input"
447
681
  type="text"
448
682
  maxlength=${this.maxlength}
449
683
  .value=${this._draft}
450
- @beforeinput=${this.#j}
451
- @input=${this.#M}
452
- @keydown=${this.#P}
684
+ @beforeinput=${this.#q}
685
+ @input=${this.#J}
686
+ @keydown=${this.#X}
453
687
  @blur=${this.commitEditing}
454
688
  />
455
- </div>` : b}
456
- </div>` : b}
689
+ </div>` : C}
690
+ </div>` : C}
457
691
  </div>`;
458
692
  }
459
- #C() {
693
+ #R() {
460
694
  if (!this.selectable) {
461
695
  this.#n.role = null, this.#n.ariaSelected = null, this.#n.ariaLabel = null;
462
696
  return;
@@ -465,53 +699,71 @@ var C = {
465
699
  this.#n.role = "option", this.#n.ariaSelected = this.selected ? "true" : "false", this.#n.ariaLabel = null;
466
700
  return;
467
701
  }
468
- this.#n.role = "img", this.#n.ariaSelected = null, this.#n.ariaLabel = this.label || this.#w || null;
702
+ this.#n.role = "img", this.#n.ariaSelected = null, this.#n.ariaLabel = this.label || this.#z || null;
469
703
  }
470
- get #w() {
704
+ get #z() {
471
705
  return this.#t instanceof HTMLImageElement ? this.#t.alt : "";
472
706
  }
473
- get #T() {
707
+ get #B() {
474
708
  return this.selectable;
475
709
  }
476
- #E() {
477
- this.hasAttribute("tabindex") || (this.#T ? this.tabIndex = 0 : this.removeAttribute("tabindex"));
710
+ #V() {
711
+ this.hasAttribute("tabindex") || (this.#B ? this.tabIndex = 0 : this.removeAttribute("tabindex"));
478
712
  }
479
- #D(t) {
713
+ #H(t) {
480
714
  t !== this.selected && (this.selected = t, e(this, "vf-select", { selected: t }));
481
715
  }
482
- #O;
483
- #k;
484
- #A;
485
- #j;
486
- #M;
487
- #N(t) {
716
+ setSelected(e) {
717
+ this.#H(e);
718
+ }
719
+ touches(e) {
720
+ let t = this.renderRoot;
721
+ if (!t) return !1;
722
+ for (let n of [".art", ".name"]) {
723
+ let r = t.querySelector(n);
724
+ if (!r) continue;
725
+ let i = r.getBoundingClientRect();
726
+ if (i.left < e.right && i.right > e.left && i.top < e.bottom && i.bottom > e.top) return !0;
727
+ }
728
+ return !1;
729
+ }
730
+ #U;
731
+ #W;
732
+ #G;
733
+ #K;
734
+ #q;
735
+ #J;
736
+ #Y(t) {
488
737
  e(this, "vf-name-too-long", {
489
738
  attempted: t,
490
739
  accepted: t.slice(0, this.maxlength),
491
740
  limit: this.maxlength
492
741
  });
493
742
  }
494
- #P;
495
- #F;
743
+ #X;
744
+ #Z;
496
745
  };
497
- a([x()], D.prototype, "label", void 0), a([x({ reflect: !0 })], D.prototype, "size", void 0), a([x({
746
+ o([w()], j.prototype, "label", void 0), o([w({ reflect: !0 })], j.prototype, "size", void 0), o([w({
747
+ type: Boolean,
748
+ reflect: !0
749
+ })], j.prototype, "selectable", void 0), o([w({
498
750
  type: Boolean,
499
751
  reflect: !0
500
- })], D.prototype, "selectable", void 0), a([x({
752
+ })], j.prototype, "selected", void 0), o([w({
501
753
  type: Boolean,
502
754
  reflect: !0
503
- })], D.prototype, "selected", void 0), a([x({
755
+ })], j.prototype, "target", void 0), o([w({
504
756
  type: Boolean,
505
757
  reflect: !0
506
- })], D.prototype, "color", void 0), a([x({
758
+ })], j.prototype, "color", void 0), o([w({
507
759
  type: Boolean,
508
760
  reflect: !0
509
- })], D.prototype, "open", void 0), a([x({
761
+ })], j.prototype, "open", void 0), o([w({
510
762
  type: Boolean,
511
763
  reflect: !0
512
- })], D.prototype, "movable", void 0), a([x({
764
+ })], j.prototype, "movable", void 0), o([w({
513
765
  type: Boolean,
514
766
  reflect: !0
515
- })], D.prototype, "editable", void 0), a([x({ type: Number })], D.prototype, "width", void 0), a([x({ type: Number })], D.prototype, "maxlength", void 0), a([S()], D.prototype, "_editing", void 0), a([S()], D.prototype, "_draft", void 0), a([S()], D.prototype, "_ghost", void 0), D = a([t("vf-icon")], D);
767
+ })], j.prototype, "editable", void 0), o([w({ type: Number })], j.prototype, "width", void 0), o([w({ type: Number })], j.prototype, "maxlength", void 0), o([T()], j.prototype, "_editing", void 0), o([T()], j.prototype, "_draft", void 0), o([T()], j.prototype, "_ghost", void 0), j = E = o([t("vf-icon")], j);
516
768
  //#endregion
517
- export { D as VfIcon };
769
+ export { j as VfIcon };