@mintplayer/web-components 2.15.0 → 2.17.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.
Files changed (126) hide show
  1. package/accordion/index.mjs +5 -5
  2. package/calendar/index.mjs +1 -1
  3. package/carousel/index.mjs +57 -143
  4. package/charts/core/index.mjs +30 -20
  5. package/charts/core/src/attributes.d.ts +18 -0
  6. package/charts/core/src/index.d.ts +2 -0
  7. package/charts/core/src/view-window.d.ts +46 -0
  8. package/charts/hierarchy/index.mjs +245 -256
  9. package/charts/hierarchy/src/components/mp-hierarchy-chart.d.ts +1 -3
  10. package/charts/sparkline/index.mjs +27 -26
  11. package/charts/trend/index.mjs +21 -20
  12. package/checkbox/index.mjs +1 -1
  13. package/checkbox/src/components/mp-checkbox.d.ts +1 -0
  14. package/chunks/attributes-L3eKsbdy.mjs +16 -0
  15. package/chunks/color-mode-warning-71FmlzWX.mjs +13 -0
  16. package/chunks/{form-check.styles-B0pxJ6YC.mjs → form-check.styles-DqvBnspm.mjs} +24 -3
  17. package/chunks/{mp-calendar.element-CJ8-t-Zn.mjs → mp-calendar.element-BIHS9SZZ.mjs} +11 -6
  18. package/chunks/{mp-checkbox-CzwS7Y_t.mjs → mp-checkbox-zV83gILn.mjs} +44 -36
  19. package/chunks/mp-datatable-eRpl7-2V.mjs +2238 -0
  20. package/chunks/{mp-datetime-picker.element-D1CiLbHm.mjs → mp-datetime-picker.element-Cxu5-qRE.mjs} +29 -32
  21. package/chunks/{mp-pagination-Dea75mD4.mjs → mp-pagination-hGy4dL7p.mjs} +9 -4
  22. package/chunks/{mp-radio-cL46sUA0.mjs → mp-radio-BhRVNdKp.mjs} +32 -28
  23. package/chunks/{mp-select-BNrbPwN4.mjs → mp-select-CgqYFvUj.mjs} +41 -26
  24. package/chunks/{mp-splitter-Ckn1kN4v.mjs → mp-splitter-DLehrw3Y.mjs} +144 -120
  25. package/chunks/{mp-timepicker.element-COZEUIoE.mjs → mp-timepicker.element-BiB9lkgc.mjs} +58 -45
  26. package/chunks/{mp-toggle-button-eo_aTQtu.mjs → mp-toggle-button-CaS9uYLE.mjs} +26 -24
  27. package/chunks/{mp-treeview-C8iltDbq.mjs → mp-treeview-CaMTDrvY.mjs} +51 -50
  28. package/chunks/{overlay-controller-D6agzzOI.mjs → overlay-controller-BHDagokg.mjs} +130 -70
  29. package/chunks/{id-DNZVAnGC.mjs → resource.service--lqLwEqk.mjs} +144 -206
  30. package/chunks/view-window-DGvFiDnW.mjs +263 -0
  31. package/code-snippet/index.mjs +70 -66
  32. package/code-snippet/src/hljs-loaders.generated.d.ts +1 -1
  33. package/custom-elements.json +65750 -0
  34. package/datatable/index.mjs +6 -5
  35. package/datatable/src/components/column-resize.d.ts +11 -0
  36. package/datatable/src/components/mp-datatable.d.ts +206 -1
  37. package/datatable/src/index.d.ts +3 -1
  38. package/datatable/src/types/column-def.d.ts +61 -0
  39. package/datatable/src/types/filter.d.ts +138 -0
  40. package/datatable/src/types/index.d.ts +3 -2
  41. package/datatable/src/types/labels.d.ts +58 -0
  42. package/datepicker/index.mjs +10 -9
  43. package/datetime-picker/index.mjs +1 -1
  44. package/datetime-picker/src/mp-datetime-picker.element.d.ts +3 -0
  45. package/dock/index.mjs +430 -463
  46. package/dock/src/components/mint-dock-manager.element.d.ts +25 -2
  47. package/dock/src/core/resize.d.ts +60 -0
  48. package/dropdown-menu/index.mjs +4 -2
  49. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +6 -1
  50. package/dropdown-menu/src/index.d.ts +1 -1
  51. package/dropdown-menu/src/types/dropdown.d.ts +14 -1
  52. package/dropdown-menu/src/types/index.d.ts +1 -1
  53. package/file-manager/index.mjs +63 -61
  54. package/file-manager/src/components/mp-file-manager.d.ts +4 -3
  55. package/multi-range/index.mjs +56 -50
  56. package/multi-range/src/mint-multi-range.element.d.ts +4 -10
  57. package/multi-range/src/pointer-geometry.d.ts +31 -0
  58. package/navbar/index.mjs +89 -439
  59. package/overlay/index.mjs +5 -2
  60. package/overlay/src/index.d.ts +2 -0
  61. package/overlay/src/overlay-controller.d.ts +27 -14
  62. package/overlay/src/overlay-portal.d.ts +53 -0
  63. package/overlay/src/placement.d.ts +48 -0
  64. package/package.json +7 -1
  65. package/pagination/index.mjs +1 -1
  66. package/phone-input/index.mjs +44 -40
  67. package/phone-input/src/components/stack.d.ts +8 -0
  68. package/query-builder/index.mjs +418 -466
  69. package/query-builder/src/dnd/drag-controller.d.ts +12 -8
  70. package/query-builder/src/mp-query-builder.element.d.ts +5 -1
  71. package/query-builder/src/mp-query-condition.element.d.ts +1 -0
  72. package/radio/index.mjs +1 -1
  73. package/radio-group/index.mjs +1 -1
  74. package/ribbon/index.mjs +477 -498
  75. package/ribbon/src/core/band-text-color.d.ts +10 -0
  76. package/ribbon/src/core/key-tip-allocator.d.ts +10 -0
  77. package/ribbon/src/core/plan-reduce-steps.d.ts +62 -0
  78. package/ribbon/src/mp-ribbon.element.d.ts +0 -27
  79. package/scheduler/index.mjs +726 -711
  80. package/scheduler/src/components/mp-scheduler.d.ts +19 -3
  81. package/scheduler/src/drag/drag-manager.d.ts +1 -9
  82. package/scheduler/src/input/input-handler.d.ts +12 -2
  83. package/scheduler/src/utils/geometry.d.ts +39 -0
  84. package/scheduler/src/views/timeline-view.d.ts +0 -1
  85. package/scheduler-core/index.mjs +84 -71
  86. package/scheduler-core/src/services/resource.service.d.ts +0 -12
  87. package/scheduler-core/src/services/timeline.service.d.ts +0 -9
  88. package/select/index.mjs +1 -1
  89. package/select/src/components/mp-select.d.ts +1 -0
  90. package/signature-pad/index.mjs +21 -23
  91. package/signature-pad/src/canvas-point.d.ts +26 -0
  92. package/signature-pad/src/mp-signature-pad.element.d.ts +1 -7
  93. package/splitter/index.mjs +1 -1
  94. package/splitter/src/components/mp-splitter.d.ts +16 -0
  95. package/splitter/src/managers/index.d.ts +1 -0
  96. package/splitter/src/managers/rescale-panel-sizes.d.ts +14 -0
  97. package/swiper-core/index.mjs +2 -2
  98. package/theming/bs-theme-preboot.js +1 -0
  99. package/theming/color-mode.css +36 -0
  100. package/theming/index.d.ts +1 -0
  101. package/theming/index.mjs +327 -0
  102. package/theming/src/components/mp-theme-toggle.d.ts +71 -0
  103. package/theming/src/cookie.d.ts +31 -0
  104. package/theming/src/index.d.ts +5 -0
  105. package/theming/src/preboot.d.ts +1 -0
  106. package/theming/src/resolve.d.ts +36 -0
  107. package/theming/src/store.d.ts +27 -0
  108. package/theming/src/styles/theme-toggle.styles.d.ts +2 -0
  109. package/theming/src/testing/fake-broadcast-channel.d.ts +35 -0
  110. package/theming/src/toggle-modes.d.ts +23 -0
  111. package/tile-manager/index.mjs +252 -211
  112. package/tile-manager/src/components/mint-tile-manager.element.d.ts +8 -0
  113. package/tile-manager/src/utils/grid-geometry.d.ts +49 -0
  114. package/timeline/index.mjs +156 -164
  115. package/timeline/src/components/mp-timeline.d.ts +41 -7
  116. package/timepicker/index.mjs +7 -4
  117. package/timepicker/src/mp-time-list.element.d.ts +26 -0
  118. package/timepicker/src/mp-timepicker.element.d.ts +3 -0
  119. package/toggle-button/index.mjs +1 -1
  120. package/tree-select/index.mjs +21 -9
  121. package/treeview/index.mjs +1 -1
  122. package/treeview/src/components/mp-treeview.d.ts +6 -4
  123. package/chunks/color-DIeST-IS.mjs +0 -224
  124. package/chunks/mp-datatable-UJI8E73X.mjs +0 -1400
  125. package/datatable/src/styles/datatable.styles.d.ts +0 -2
  126. package/query-builder/src/mp-query-condition.element.template.d.ts +0 -2
@@ -1,107 +1,147 @@
1
- import { html as f, unsafeCSS as x, LitElement as z, nothing as b } from "lit";
2
- import { L as _ } from "../chunks/live-announcer-Bi0orG4n.mjs";
3
- function w(l, t) {
4
- return l.colStart < t.colStart + t.colSpan && t.colStart < l.colStart + l.colSpan && l.rowStart < t.rowStart + t.rowSpan && t.rowStart < l.rowStart + l.rowSpan;
1
+ import { html as f, unsafeCSS as C, LitElement as T, nothing as b } from "lit";
2
+ import { L as R } from "../chunks/live-announcer-Bi0orG4n.mjs";
3
+ function w(s, t) {
4
+ return s.colStart < t.colStart + t.colSpan && t.colStart < s.colStart + s.colSpan && s.rowStart < t.rowStart + t.rowSpan && t.rowStart < s.rowStart + s.rowSpan;
5
5
  }
6
- function v(l, t, e) {
7
- if (!l.find((u) => u.id === t.id))
6
+ function v(s, t, e) {
7
+ if (!s.find((u) => u.id === t.id))
8
8
  throw new Error(`pack: pinned tile "${t.id}" is not in the tiles array`);
9
- const i = { id: t.id, position: { ...t.rect } }, o = l.filter((u) => u.locked && u.id !== t.id).map((u) => ({ id: u.id, position: { ...u.position } }));
10
- if (o.some(
9
+ const i = { id: t.id, position: { ...t.rect } }, n = s.filter((u) => u.locked && u.id !== t.id).map((u) => ({ id: u.id, position: { ...u.position } }));
10
+ if (n.some(
11
11
  (u) => w(u.position, i.position)
12
12
  ))
13
- return { layout: y(l), blocked: !0 };
14
- const s = [i, ...o], a = l.filter((u) => !u.locked && u.id !== t.id).slice().sort((u, m) => {
13
+ return { layout: y(s), blocked: !0 };
14
+ const a = [i, ...n], l = s.filter((u) => !u.locked && u.id !== t.id).slice().sort((u, m) => {
15
15
  const g = u.position.rowStart - m.position.rowStart;
16
16
  return g !== 0 ? g : u.position.colStart - m.position.colStart;
17
- }), d = a.reduce((u, m) => {
18
- const g = [...s, ...u], S = C(m, g, e);
17
+ }), d = l.reduce((u, m) => {
18
+ const g = [...a, ...u], S = E(m, g, e);
19
19
  return S ? [...u, S] : u;
20
20
  }, []);
21
- if (d.length !== a.length)
22
- return { layout: y(l), blocked: !0 };
23
- const c = T(d, s, e), h = new Map(
24
- [i, ...o, ...c].map((u) => [u.id, u.position])
21
+ if (d.length !== l.length)
22
+ return { layout: y(s), blocked: !0 };
23
+ const c = P(d, a, e), p = new Map(
24
+ [i, ...n, ...c].map((u) => [u.id, u.position])
25
25
  );
26
- return { layout: l.map((u) => ({
26
+ return { layout: s.map((u) => ({
27
27
  id: u.id,
28
- position: h.get(u.id) ?? { ...u.position }
28
+ position: p.get(u.id) ?? { ...u.position }
29
29
  })), blocked: !1 };
30
30
  }
31
- function y(l) {
32
- return l.map((t) => ({ id: t.id, position: { ...t.position } }));
31
+ function y(s) {
32
+ return s.map((t) => ({ id: t.id, position: { ...t.position } }));
33
33
  }
34
- function C(l, t, e) {
35
- const { colSpan: n, rowSpan: i } = l.position;
36
- if (n > e) return null;
37
- if (!t.some((s) => w(l.position, s.position)))
38
- return { id: l.id, position: { ...l.position } };
39
- const r = R({ colSpan: n, rowSpan: i }, t, e);
40
- return r ? { id: l.id, position: r } : null;
34
+ function E(s, t, e) {
35
+ const { colSpan: o, rowSpan: i } = s.position;
36
+ if (o > e) return null;
37
+ if (!t.some((a) => w(s.position, a.position)))
38
+ return { id: s.id, position: { ...s.position } };
39
+ const r = M({ colSpan: o, rowSpan: i }, t, e);
40
+ return r ? { id: s.id, position: r } : null;
41
41
  }
42
- function R(l, t, e) {
42
+ function M(s, t, e) {
43
43
  const i = t.reduce(
44
- (r, s) => Math.max(r, s.position.rowStart + s.position.rowSpan - 1),
44
+ (r, a) => Math.max(r, a.position.rowStart + a.position.rowSpan - 1),
45
45
  0
46
- ) + l.rowSpan, o = e - l.colSpan + 1;
47
- if (o < 1) return null;
46
+ ) + s.rowSpan, n = e - s.colSpan + 1;
47
+ if (n < 1) return null;
48
48
  for (let r = 1; r <= i; r++)
49
- for (let s = 0; s < o; s++) {
50
- const a = s + 1;
49
+ for (let a = 0; a < n; a++) {
50
+ const l = a + 1;
51
51
  let d = !1;
52
52
  for (let c = 0; c < t.length; c++)
53
53
  if (w(
54
- { rowStart: r, colStart: a, colSpan: l.colSpan, rowSpan: l.rowSpan },
54
+ { rowStart: r, colStart: l, colSpan: s.colSpan, rowSpan: s.rowSpan },
55
55
  t[c].position
56
56
  )) {
57
57
  d = !0;
58
58
  break;
59
59
  }
60
60
  if (!d)
61
- return { rowStart: r, colStart: a, colSpan: l.colSpan, rowSpan: l.rowSpan };
61
+ return { rowStart: r, colStart: l, colSpan: s.colSpan, rowSpan: s.rowSpan };
62
62
  }
63
63
  return null;
64
64
  }
65
- function T(l, t, e) {
66
- return k(l, t, e, 10);
65
+ function P(s, t, e) {
66
+ return k(s, t, e, 10);
67
67
  }
68
- function k(l, t, e, n) {
69
- if (n <= 0) return l;
70
- const { result: i, changed: o } = E(l, t);
71
- return o ? k(i, t, e, n - 1) : i;
68
+ function k(s, t, e, o) {
69
+ if (o <= 0) return s;
70
+ const { result: i, changed: n } = I(s, t);
71
+ return n ? k(i, t, e, o - 1) : i;
72
72
  }
73
- function E(l, t, e) {
74
- return l.slice().sort((i, o) => {
75
- const r = i.position.rowStart - o.position.rowStart;
76
- return r !== 0 ? r : i.position.colStart - o.position.colStart;
73
+ function I(s, t, e) {
74
+ return s.slice().sort((i, n) => {
75
+ const r = i.position.rowStart - n.position.rowStart;
76
+ return r !== 0 ? r : i.position.colStart - n.position.colStart;
77
77
  }).reduce(
78
- (i, o) => {
79
- const r = [...t, ...i.result.filter((d) => d.id !== o.id)], s = M(o.position, r), a = s.rowStart !== o.position.rowStart;
78
+ (i, n) => {
79
+ const r = [...t, ...i.result.filter((d) => d.id !== n.id)], a = $(n.position, r), l = a.rowStart !== n.position.rowStart;
80
80
  return {
81
- result: [...i.result, { id: o.id, position: s }],
82
- changed: i.changed || a
81
+ result: [...i.result, { id: n.id, position: a }],
82
+ changed: i.changed || l
83
83
  };
84
84
  },
85
85
  { result: [], changed: !1 }
86
86
  );
87
87
  }
88
- function M(l, t) {
89
- if (l.rowStart <= 1) return l;
90
- for (let e = 1; e < l.rowStart; e++) {
91
- let n = !1;
88
+ function $(s, t) {
89
+ if (s.rowStart <= 1) return s;
90
+ for (let e = 1; e < s.rowStart; e++) {
91
+ let o = !1;
92
92
  for (let i = 0; i < t.length; i++)
93
- if (w({ ...l, rowStart: e }, t[i].position)) {
94
- n = !0;
93
+ if (w({ ...s, rowStart: e }, t[i].position)) {
94
+ o = !0;
95
95
  break;
96
96
  }
97
- if (!n) return { ...l, rowStart: e };
98
- }
99
- return l;
97
+ if (!o) return { ...s, rowStart: e };
98
+ }
99
+ return s;
100
+ }
101
+ function x(s) {
102
+ const t = s.width + s.gapX, e = s.height + s.gapY;
103
+ return !(t > 0) || !(e > 0) || !Number.isFinite(t) || !Number.isFinite(e) ? null : { x: t, y: e };
104
+ }
105
+ function z(s, t) {
106
+ return {
107
+ x: (s.colStart - 1) * (t.width + t.gapX),
108
+ y: (s.rowStart - 1) * (t.height + t.gapY)
109
+ };
110
+ }
111
+ function _({ pointer: s, gridOrigin: t, pointerOffset: e }) {
112
+ return {
113
+ x: s.x - t.x - e.x,
114
+ y: s.y - t.y - e.y
115
+ };
116
+ }
117
+ function L(s, t, e, o) {
118
+ const i = x(e);
119
+ if (!i) return null;
120
+ const n = _(s), r = Math.round(n.x / i.x) + 1, a = Math.round(n.y / i.y) + 1;
121
+ return {
122
+ colStart: Math.max(1, Math.min(r, o - t.colSpan + 1)),
123
+ rowStart: Math.max(1, a),
124
+ colSpan: t.colSpan,
125
+ rowSpan: t.rowSpan
126
+ };
127
+ }
128
+ function A(s, t, e) {
129
+ const o = _(s), i = z(t, e);
130
+ return { x: Math.round(o.x - i.x), y: Math.round(o.y - i.y) };
131
+ }
132
+ function D(s, t, e, o, i, n) {
133
+ const r = x(i);
134
+ if (!r) return null;
135
+ const a = Math.round(s.x / r.x), l = Math.round(s.y / r.y);
136
+ return {
137
+ colSpan: t === "bottom" ? e.colSpan : Math.max(1, Math.min(e.colSpan + a, n - o + 1)),
138
+ rowSpan: t === "side" ? e.rowSpan : Math.max(1, e.rowSpan + l)
139
+ };
100
140
  }
101
141
  f`<!-- Tile shells are rendered dynamically by render(). This file exists so the
102
142
  codegen-wc target produces a \`styles\` export from the sibling .scss; the
103
143
  \`template\` export it generates is intentionally unused. -->`;
104
- const P = x(`:host {
144
+ const G = C(`:host {
105
145
  display: block;
106
146
  position: relative;
107
147
  box-sizing: border-box;
@@ -317,17 +357,17 @@ const P = x(`:host {
317
357
  .tile:focus-visible {
318
358
  outline: 2px solid var(--bs-primary, #0d6efd);
319
359
  outline-offset: -2px;
320
- }`), I = "Press M to enter move mode. In move mode, arrow keys move the tile, Shift with arrow keys resize it, Enter commits, Escape cancels.";
321
- let L = 0;
322
- const $ = 600, A = 10, D = 150, q = 5;
323
- class G extends z {
360
+ }`), F = "Press M to enter move mode. In move mode, arrow keys move the tile, Shift with arrow keys resize it, Enter commits, Escape cancels.";
361
+ let U = 0;
362
+ const q = 600, K = 10, O = 150, W = 5;
363
+ class X extends T {
324
364
  constructor() {
325
- super(...arguments), this.tiles = [], this.columnCount = null, this.minColumnWidth = "200px", this.minRowHeight = "8rem", this.gap = "0.5rem", this.dragMode = "header", this.resizeMode = "hover", this.animateReflow = !0, this.label = null, this.gestureState = { kind: "idle" }, this.keyboardState = { kind: "idle" }, this.previewLayout = null, this.gestureKind = "idle", this.blocked = !1, this.effectiveColumnCount = 1, this.focusedTileId = null, this.liveAnnouncer = new _(this), this.instanceId = `mp-tile-manager-${++L}`, this.hostResizeObserver = null, this.flipPreviousRects = /* @__PURE__ */ new Map(), this.cellMetrics = { width: 0, height: 0, gapX: 0, gapY: 0 }, this.onWindowPointerMove = (t) => this.handlePointerMove(t), this.onWindowPointerUp = (t) => this.handlePointerUp(t), this.onWindowPointerCancel = (t) => this.handlePointerCancel(t), this.onWindowKeyDown = (t) => this.handleEscapeKey(t), this.onVisibilityChange = () => {
365
+ super(...arguments), this.tiles = [], this.columnCount = null, this.minColumnWidth = "200px", this.minRowHeight = "8rem", this.gap = "0.5rem", this.dragMode = "header", this.resizeMode = "hover", this.animateReflow = !0, this.label = null, this.gestureState = { kind: "idle" }, this.keyboardState = { kind: "idle" }, this.previewLayout = null, this.gestureKind = "idle", this.blocked = !1, this.effectiveColumnCount = 1, this.focusedTileId = null, this.liveAnnouncer = new R(this), this.instanceId = `mp-tile-manager-${++U}`, this.hostResizeObserver = null, this.flipPreviousRects = /* @__PURE__ */ new Map(), this.cellMetrics = { width: 0, height: 0, gapX: 0, gapY: 0 }, this.onWindowPointerMove = (t) => this.handlePointerMove(t), this.onWindowPointerUp = (t) => this.handlePointerUp(t), this.onWindowPointerCancel = (t) => this.handlePointerCancel(t), this.onWindowKeyDown = (t) => this.handleEscapeKey(t), this.onVisibilityChange = () => {
326
366
  document.visibilityState === "hidden" && this.cancelGesture();
327
367
  }, this.lastPointerPosition = null;
328
368
  }
329
369
  static {
330
- this.styles = [P];
370
+ this.styles = [G];
331
371
  }
332
372
  static get observedAttributes() {
333
373
  return [
@@ -363,39 +403,39 @@ class G extends z {
363
403
  return `${this.instanceId}-instructions`;
364
404
  }
365
405
  render() {
366
- const t = this.previewLayout ?? this.tiles.map((i) => ({ id: i.id, position: i.position })), e = new Map(this.tiles.map((i) => [i.id, i])), n = this.computeGridStyle();
406
+ const t = this.previewLayout ?? this.tiles.map((i) => ({ id: i.id, position: i.position })), e = new Map(this.tiles.map((i) => [i.id, i])), o = this.computeGridStyle();
367
407
  return f`
368
408
  <div
369
409
  class="tile-grid"
370
410
  role="region"
371
411
  aria-label=${this.label ?? "Tile board"}
372
- style=${n}
412
+ style=${o}
373
413
  >
374
414
  ${t.map((i) => {
375
- const o = e.get(i.id);
376
- return o ? this.renderTile(o, i.position) : b;
415
+ const n = e.get(i.id);
416
+ return n ? this.renderTile(n, i.position) : b;
377
417
  })}
378
418
  </div>
379
- <div id=${this.instructionsId} class="tile-grid__sr-only">${I}</div>
419
+ <div id=${this.instructionsId} class="tile-grid__sr-only">${F}</div>
380
420
  ${this.liveAnnouncer.template()}
381
421
  `;
382
422
  }
383
423
  renderTile(t, e) {
384
- const n = this.gestureKind === "drag" && this.activeTileId() === t.id, i = this.gestureKind === "resize" && this.activeTileId() === t.id, o = (n || i) && this.blocked, r = this.gestureKind === "arming-touch-drag" && this.activeTileId() === t.id, s = this.computeActiveTransform(t.id), a = this.cellMetrics, d = i && a.width > 0 ? {
385
- width: e.colSpan * a.width + (e.colSpan - 1) * a.gapX,
386
- height: e.rowSpan * a.height + (e.rowSpan - 1) * a.gapY
424
+ const o = this.gestureKind === "drag" && this.activeTileId() === t.id, i = this.gestureKind === "resize" && this.activeTileId() === t.id, n = (o || i) && this.blocked, r = this.gestureKind === "arming-touch-drag" && this.activeTileId() === t.id, a = this.computeActiveTransform(t.id), l = this.cellMetrics, d = i && l.width > 0 ? {
425
+ width: e.colSpan * l.width + (e.colSpan - 1) * l.gapX,
426
+ height: e.rowSpan * l.height + (e.rowSpan - 1) * l.gapY
387
427
  } : null, c = [
388
428
  `grid-column: ${e.colStart} / span ${e.colSpan}`,
389
429
  `grid-row: ${e.rowStart} / span ${e.rowSpan}`,
390
- s ? `transform: ${s}` : "",
430
+ a ? `transform: ${a}` : "",
391
431
  d ? `width: ${d.width}px` : "",
392
432
  d ? `height: ${d.height}px` : ""
393
- ].filter(Boolean).join("; "), h = this.resolveFocusableTileId() === t.id;
433
+ ].filter(Boolean).join("; "), p = this.resolveFocusableTileId() === t.id;
394
434
  return f`
395
435
  <div
396
436
  class="tile"
397
437
  role="button"
398
- tabindex=${h ? "0" : "-1"}
438
+ tabindex=${p ? "0" : "-1"}
399
439
  aria-describedby=${// On the TILE, not the region: the instructions describe what a
400
440
  // focused tile can do, and SRs read describedby at the focus target.
401
441
  this.instructionsId}
@@ -403,17 +443,17 @@ class G extends z {
403
443
  // token IS the move-mode state, re-derived every render (§11a).
404
444
  this.keyboardState.kind === "move" && this.keyboardState.tileId === t.id ? "true" : "false"}
405
445
  data-tile-id=${t.id}
406
- data-dragging=${n ? "true" : "false"}
446
+ data-dragging=${o ? "true" : "false"}
407
447
  data-resizing=${i ? "true" : "false"}
408
- data-blocked=${o ? "true" : "false"}
448
+ data-blocked=${n ? "true" : "false"}
409
449
  data-pressing=${r ? "true" : "false"}
410
450
  data-drag-mode=${this.dragMode}
411
451
  data-locked-move=${t.disableMove ? "true" : "false"}
412
452
  data-locked-resize=${t.disableResize ? "true" : "false"}
413
453
  aria-label=${t.label ?? b}
414
454
  style=${c}
415
- @pointerdown=${(p) => this.onTilePointerDown(p, t)}
416
- @keydown=${(p) => this.onTileKeyDown(p, t)}
455
+ @pointerdown=${(h) => this.onTilePointerDown(h, t)}
456
+ @keydown=${(h) => this.onTileKeyDown(h, t)}
417
457
  @focus=${() => this.onTileFocus(t)}
418
458
  >
419
459
  <div class="tile__header-shell">
@@ -424,11 +464,11 @@ class G extends z {
424
464
  </div>
425
465
  ${t.disableResize || this.resizeMode === "off" ? b : f`
426
466
  <div class="tile__resize-side" data-resize="side"
427
- @pointerdown=${(p) => this.onResizeHandlePointerDown(p, t, "side")}></div>
467
+ @pointerdown=${(h) => this.onResizeHandlePointerDown(h, t, "side")}></div>
428
468
  <div class="tile__resize-bottom" data-resize="bottom"
429
- @pointerdown=${(p) => this.onResizeHandlePointerDown(p, t, "bottom")}></div>
469
+ @pointerdown=${(h) => this.onResizeHandlePointerDown(h, t, "bottom")}></div>
430
470
  <div class="tile__resize-corner" data-resize="corner"
431
- @pointerdown=${(p) => this.onResizeHandlePointerDown(p, t, "corner")}></div>
471
+ @pointerdown=${(h) => this.onResizeHandlePointerDown(h, t, "corner")}></div>
432
472
  `}
433
473
  </div>
434
474
  `;
@@ -458,18 +498,27 @@ class G extends z {
458
498
  const d = e.gridTemplateColumns.split(/\s+/).filter(Boolean);
459
499
  this.effectiveColumnCount = Math.max(1, d.length);
460
500
  }
461
- const n = t.getBoundingClientRect(), i = this.effectiveColumnCount, o = parseFloat(e.columnGap) || 0, r = parseFloat(e.rowGap) || 0, s = (n.width - (i - 1) * o) / i, a = parseFloat(e.gridAutoRows) || n.width / i;
462
- this.cellMetrics = { width: s, height: a, gapX: o, gapY: r };
501
+ const o = t.getBoundingClientRect(), i = this.effectiveColumnCount, n = parseFloat(e.columnGap) || 0, r = parseFloat(e.rowGap) || 0, a = (o.width - (i - 1) * n) / i, l = parseFloat(e.gridAutoRows) || o.width / i;
502
+ this.cellMetrics = { width: a, height: l, gapX: n, gapY: r };
463
503
  }
464
504
  computeActiveTransform(t) {
465
505
  const e = this.gestureState;
466
506
  if (e.kind !== "drag" || e.tileId !== t) return null;
467
- const n = this.lastPointerPosition;
468
- if (!n) return null;
507
+ const o = this.lastPointerPosition;
508
+ if (!o) return null;
469
509
  const i = this.shadowRoot?.querySelector(".tile-grid");
470
510
  if (!i) return null;
471
- const o = i.getBoundingClientRect(), r = this.cellMetrics, s = e.currentRect, a = n.x - o.left - e.pointerOffset.dx, d = n.y - o.top - e.pointerOffset.dy, c = (s.colStart - 1) * (r.width + r.gapX), h = (s.rowStart - 1) * (r.height + r.gapY);
472
- return `translate(${Math.round(a - c)}px, ${Math.round(d - h)}px)`;
511
+ const n = A(this.dragPointer(i, e, o), e.currentRect, this.cellMetrics);
512
+ return `translate(${n.x}px, ${n.y}px)`;
513
+ }
514
+ /** The numbers the pure drag geometry needs: pointer, live grid origin, grab offset. */
515
+ dragPointer(t, e, o) {
516
+ const i = t.getBoundingClientRect();
517
+ return {
518
+ pointer: o,
519
+ gridOrigin: { x: i.left, y: i.top },
520
+ pointerOffset: { x: e.pointerOffset.dx, y: e.pointerOffset.dy }
521
+ };
473
522
  }
474
523
  // ---------------- Lifecycle ----------------
475
524
  connectedCallback() {
@@ -487,8 +536,8 @@ class G extends z {
487
536
  }));
488
537
  }), this.hostResizeObserver.observe(this);
489
538
  }
490
- attributeChangedCallback(t, e, n) {
491
- super.attributeChangedCallback(t, e, n), t === "animate-reflow" && (this.animateReflow = !(n === null || n === "false" || n === "0"));
539
+ attributeChangedCallback(t, e, o) {
540
+ super.attributeChangedCallback(t, e, o), t === "animate-reflow" && (this.animateReflow = !(o === null || o === "false" || o === "0"));
492
541
  }
493
542
  // ---------------- FLIP animator ----------------
494
543
  willUpdate(t) {
@@ -497,25 +546,25 @@ class G extends z {
497
546
  return;
498
547
  }
499
548
  const e = this.shadowRoot?.querySelector(".tile-grid");
500
- e && (this.flipPreviousRects.clear(), e.querySelectorAll(".tile").forEach((n) => {
501
- const i = n.dataset.tileId;
502
- i && this.flipPreviousRects.set(i, n.getBoundingClientRect());
549
+ e && (this.flipPreviousRects.clear(), e.querySelectorAll(".tile").forEach((o) => {
550
+ const i = o.dataset.tileId;
551
+ i && this.flipPreviousRects.set(i, o.getBoundingClientRect());
503
552
  }));
504
553
  }
505
554
  updated(t) {
506
555
  if ((t.has("columnCount") || t.has("minColumnWidth") || t.has("minRowHeight") || t.has("gap")) && this.updateLayoutCache(), !this.shouldAnimate() || this.flipPreviousRects.size === 0) return;
507
556
  const e = this.shadowRoot?.querySelector(".tile-grid");
508
557
  if (!e) return;
509
- const n = this.activeTileId();
558
+ const o = this.activeTileId();
510
559
  e.querySelectorAll(".tile").forEach((i) => {
511
- const o = i.dataset.tileId;
512
- if (!o || o === n) return;
513
- const r = this.flipPreviousRects.get(o);
560
+ const n = i.dataset.tileId;
561
+ if (!n || n === o) return;
562
+ const r = this.flipPreviousRects.get(n);
514
563
  if (!r) return;
515
- const s = i.getBoundingClientRect(), a = r.left - s.left, d = r.top - s.top;
516
- if (Math.abs(a) < 0.5 && Math.abs(d) < 0.5) return;
564
+ const a = i.getBoundingClientRect(), l = r.left - a.left, d = r.top - a.top;
565
+ if (Math.abs(l) < 0.5 && Math.abs(d) < 0.5) return;
517
566
  const c = i.style.transition;
518
- i.style.transition = "none", i.style.transform = `translate(${a}px, ${d}px)`, requestAnimationFrame(() => {
567
+ i.style.transition = "none", i.style.transform = `translate(${l}px, ${d}px)`, requestAnimationFrame(() => {
519
568
  i.style.transition = c, i.style.transform = "";
520
569
  });
521
570
  }), this.flipPreviousRects.clear();
@@ -526,90 +575,87 @@ class G extends z {
526
575
  onTilePointerDown(t, e) {
527
576
  t.button !== 0 && t.pointerType === "mouse" || this.gestureState.kind === "idle" && (this.dragMode === "off" || e.disableMove || (this.dragMode === "header" || t.pointerType === "touch") && !t.composedPath().some((i) => i instanceof HTMLElement && i.classList?.contains("tile__header-shell")) || (t.pointerType === "touch" ? this.armTouchDrag(t, e) : this.armPointerDrag(t, e)));
528
577
  }
529
- onResizeHandlePointerDown(t, e, n) {
530
- t.button !== 0 && t.pointerType === "mouse" || e.disableResize || this.resizeMode === "off" || this.gestureState.kind === "idle" && (t.stopPropagation(), t.preventDefault(), this.beginResize(t, e, n));
578
+ onResizeHandlePointerDown(t, e, o) {
579
+ t.button !== 0 && t.pointerType === "mouse" || e.disableResize || this.resizeMode === "off" || this.gestureState.kind === "idle" && (t.stopPropagation(), t.preventDefault(), this.beginResize(t, e, o));
531
580
  }
532
581
  // ---------------- Drag arming ----------------
533
582
  armPointerDrag(t, e) {
534
- const n = t.clientX, i = t.clientY, o = (s) => {
535
- if (s.pointerId !== t.pointerId) return;
536
- const a = s.clientX - n, d = s.clientY - i;
537
- Math.hypot(a, d) >= q && (window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", r), window.removeEventListener("pointercancel", r), this.beginDrag(s, e));
538
- }, r = (s) => {
539
- s.pointerId === t.pointerId && (window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", r), window.removeEventListener("pointercancel", r));
583
+ const o = t.clientX, i = t.clientY, n = (a) => {
584
+ if (a.pointerId !== t.pointerId) return;
585
+ const l = a.clientX - o, d = a.clientY - i;
586
+ Math.hypot(l, d) >= W && (window.removeEventListener("pointermove", n), window.removeEventListener("pointerup", r), window.removeEventListener("pointercancel", r), this.beginDrag(a, e));
587
+ }, r = (a) => {
588
+ a.pointerId === t.pointerId && (window.removeEventListener("pointermove", n), window.removeEventListener("pointerup", r), window.removeEventListener("pointercancel", r));
540
589
  };
541
- window.addEventListener("pointermove", o), window.addEventListener("pointerup", r), window.addEventListener("pointercancel", r);
590
+ window.addEventListener("pointermove", n), window.addEventListener("pointerup", r), window.addEventListener("pointercancel", r);
542
591
  }
543
592
  armTouchDrag(t, e) {
544
- const n = t.clientX, i = t.clientY, o = t.pointerId, r = window.setTimeout(() => {
545
- this.gestureState.kind === "arming-touch-drag" && this.gestureState.pointerId === o && this.requestUpdate();
546
- }, D), s = window.setTimeout(() => {
547
- if (!(this.gestureState.kind !== "arming-touch-drag" || this.gestureState.pointerId !== o)) {
593
+ const o = t.clientX, i = t.clientY, n = t.pointerId, r = window.setTimeout(() => {
594
+ this.gestureState.kind === "arming-touch-drag" && this.gestureState.pointerId === n && this.requestUpdate();
595
+ }, O), a = window.setTimeout(() => {
596
+ if (!(this.gestureState.kind !== "arming-touch-drag" || this.gestureState.pointerId !== n)) {
548
597
  this.cleanupTouchArming();
549
598
  try {
550
599
  navigator.vibrate?.(10);
551
600
  } catch {
552
601
  }
553
- this.beginDragFromTouchArm(e, n, i, o);
602
+ this.beginDragFromTouchArm(e, o, i, n);
554
603
  }
555
- }, $);
604
+ }, q);
556
605
  this.gestureState = {
557
606
  kind: "arming-touch-drag",
558
- pointerId: o,
607
+ pointerId: n,
559
608
  tileId: e.id,
560
- startX: n,
609
+ startX: o,
561
610
  startY: i,
562
- timer: s,
611
+ timer: a,
563
612
  pressingTimer: r
564
613
  }, this.gestureKind = "arming-touch-drag";
565
- const a = (c) => {
566
- if (c.pointerId !== o || this.gestureState.kind !== "arming-touch-drag") return;
567
- const h = c.clientX - n, p = c.clientY - i;
568
- Math.hypot(h, p) > A && (this.cleanupTouchArming(), window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", d));
614
+ const l = (c) => {
615
+ if (c.pointerId !== n || this.gestureState.kind !== "arming-touch-drag") return;
616
+ const p = c.clientX - o, h = c.clientY - i;
617
+ Math.hypot(p, h) > K && (this.cleanupTouchArming(), window.removeEventListener("pointermove", l), window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", d));
569
618
  }, d = (c) => {
570
- c.pointerId === o && (this.gestureState.kind === "arming-touch-drag" && this.cleanupTouchArming(), window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", d));
619
+ c.pointerId === n && (this.gestureState.kind === "arming-touch-drag" && this.cleanupTouchArming(), window.removeEventListener("pointermove", l), window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", d));
571
620
  };
572
- window.addEventListener("pointermove", a), window.addEventListener("pointerup", d), window.addEventListener("pointercancel", d);
621
+ window.addEventListener("pointermove", l), window.addEventListener("pointerup", d), window.addEventListener("pointercancel", d);
573
622
  }
574
623
  cleanupTouchArming() {
575
624
  if (this.gestureState.kind !== "arming-touch-drag") return;
576
625
  const { timer: t, pressingTimer: e } = this.gestureState;
577
626
  t !== null && window.clearTimeout(t), e !== null && window.clearTimeout(e), this.gestureState = { kind: "idle" }, this.gestureKind = "idle", this.requestUpdate();
578
627
  }
579
- beginDragFromTouchArm(t, e, n, i) {
580
- this.updateLayoutCache();
581
- const o = this.shadowRoot?.querySelector(".tile-grid");
582
- if (!o) return;
583
- const r = this.cellMetrics, s = o.getBoundingClientRect(), a = s.left + (t.position.colStart - 1) * (r.width + r.gapX), d = s.top + (t.position.rowStart - 1) * (r.height + r.gapY);
584
- this.gestureState = {
585
- kind: "drag",
586
- pointerId: i,
587
- tileId: t.id,
588
- pointerOffset: { dx: e - a, dy: n - d },
589
- currentRect: { ...t.position },
590
- blocked: !1
591
- }, this.gestureKind = "drag", this.lastPointerPosition = { x: e, y: n }, this.attachWindowListeners(), this.announceDragBegin(t), this.requestUpdate();
628
+ beginDragFromTouchArm(t, e, o, i) {
629
+ this.startDrag(t, i, e, o) && this.requestUpdate();
592
630
  }
593
631
  beginDrag(t, e) {
632
+ this.startDrag(e, t.pointerId, t.clientX, t.clientY) && this.runPackerForCurrentGesture();
633
+ }
634
+ /**
635
+ * Enter the drag state for a pointer at (x, y). Refreshes the layout cache
636
+ * once at gesture start, so the metrics are fresh even if the grid resized
637
+ * since the last cache tick. Returns false when there is no grid to drag in.
638
+ */
639
+ startDrag(t, e, o, i) {
594
640
  this.updateLayoutCache();
595
641
  const n = this.shadowRoot?.querySelector(".tile-grid");
596
- if (!n) return;
597
- const i = this.cellMetrics, o = n.getBoundingClientRect(), r = o.left + (e.position.colStart - 1) * (i.width + i.gapX), s = o.top + (e.position.rowStart - 1) * (i.height + i.gapY);
598
- this.gestureState = {
642
+ if (!n) return !1;
643
+ const r = n.getBoundingClientRect(), a = z(t.position, this.cellMetrics);
644
+ return this.gestureState = {
599
645
  kind: "drag",
600
- pointerId: t.pointerId,
601
- tileId: e.id,
602
- pointerOffset: { dx: t.clientX - r, dy: t.clientY - s },
603
- currentRect: { ...e.position },
646
+ pointerId: e,
647
+ tileId: t.id,
648
+ pointerOffset: { dx: o - (r.left + a.x), dy: i - (r.top + a.y) },
649
+ currentRect: { ...t.position },
604
650
  blocked: !1
605
- }, this.gestureKind = "drag", this.lastPointerPosition = { x: t.clientX, y: t.clientY }, this.attachWindowListeners(), this.announceDragBegin(e), this.runPackerForCurrentGesture();
651
+ }, this.gestureKind = "drag", this.lastPointerPosition = { x: o, y: i }, this.attachWindowListeners(), this.announceDragBegin(t), !0;
606
652
  }
607
- beginResize(t, e, n) {
653
+ beginResize(t, e, o) {
608
654
  this.gestureState = {
609
655
  kind: "resize",
610
656
  pointerId: t.pointerId,
611
657
  tileId: e.id,
612
- mode: n,
658
+ mode: o,
613
659
  startPointer: { x: t.clientX, y: t.clientY },
614
660
  startSpans: { colSpan: e.position.colSpan, rowSpan: e.position.rowSpan },
615
661
  currentRect: { ...e.position },
@@ -656,46 +702,41 @@ class G extends z {
656
702
  runPackerForCurrentGesture() {
657
703
  const t = this.gestureState;
658
704
  if (t.kind !== "drag" && t.kind !== "resize") return;
659
- const e = this.tiles.find((s) => s.id === t.tileId);
705
+ const e = this.tiles.find((a) => a.id === t.tileId);
660
706
  if (!e) {
661
707
  this.cancelGesture();
662
708
  return;
663
709
  }
664
- const n = t.kind === "drag" ? this.computeDragRect(t, e) : this.computeResizeRect(t, e);
665
- if (!n) return;
666
- t.currentRect = n;
667
- const i = this.effectiveColumnCount, o = v(
668
- this.tiles.map((s) => ({ id: s.id, position: s.position, locked: !!s.disableMove })),
669
- { id: e.id, rect: n },
710
+ const o = t.kind === "drag" ? this.computeDragRect(t, e) : this.computeResizeRect(t, e);
711
+ if (!o) return;
712
+ t.currentRect = o;
713
+ const i = this.effectiveColumnCount, n = v(
714
+ this.tiles.map((a) => ({ id: a.id, position: a.position, locked: !!a.disableMove })),
715
+ { id: e.id, rect: o },
670
716
  i
671
717
  );
672
- this.previewLayout = o.layout;
718
+ this.previewLayout = n.layout;
673
719
  const r = t.blocked;
674
- t.blocked = o.blocked, o.blocked && !r && this.liveAnnouncer.announce("Move blocked by a locked tile."), this.blocked = o.blocked, this.requestUpdate();
720
+ t.blocked = n.blocked, n.blocked && !r && this.liveAnnouncer.announce("Move blocked by a locked tile."), this.blocked = n.blocked, this.requestUpdate();
675
721
  }
676
722
  computeDragRect(t, e) {
677
- const n = this.shadowRoot?.querySelector(".tile-grid");
678
- if (!n) return null;
679
- const i = this.cellMetrics, o = this.effectiveColumnCount, r = this.lastPointerPosition;
680
- if (!r) return null;
681
- const s = n.getBoundingClientRect(), a = r.x - s.left - t.pointerOffset.dx, d = r.y - s.top - t.pointerOffset.dy, c = Math.round(a / (i.width + i.gapX)) + 1, h = Math.round(d / (i.height + i.gapY)) + 1;
682
- return {
683
- colStart: Math.max(1, Math.min(c, o - e.position.colSpan + 1)),
684
- rowStart: Math.max(1, h),
685
- colSpan: e.position.colSpan,
686
- rowSpan: e.position.rowSpan
687
- };
723
+ const o = this.shadowRoot?.querySelector(".tile-grid");
724
+ if (!o) return null;
725
+ const i = this.lastPointerPosition;
726
+ return i ? L(this.dragPointer(o, t, i), e.position, this.cellMetrics, this.effectiveColumnCount) : null;
688
727
  }
689
728
  computeResizeRect(t, e) {
690
- const n = this.cellMetrics, i = this.effectiveColumnCount, o = this.lastPointerPosition;
729
+ const o = this.lastPointerPosition;
691
730
  if (!o) return null;
692
- const r = o.x - t.startPointer.x, s = o.y - t.startPointer.y, a = Math.round(r / (n.width + n.gapX)), d = Math.round(s / (n.height + n.gapY)), c = t.mode === "bottom" ? t.startSpans.colSpan : Math.max(1, Math.min(t.startSpans.colSpan + a, i - e.position.colStart + 1)), h = t.mode === "side" ? t.startSpans.rowSpan : Math.max(1, t.startSpans.rowSpan + d);
693
- return {
694
- colStart: e.position.colStart,
695
- rowStart: e.position.rowStart,
696
- colSpan: c,
697
- rowSpan: h
698
- };
731
+ const i = D(
732
+ { x: o.x - t.startPointer.x, y: o.y - t.startPointer.y },
733
+ t.mode,
734
+ t.startSpans,
735
+ e.position.colStart,
736
+ this.cellMetrics,
737
+ this.effectiveColumnCount
738
+ );
739
+ return i ? { colStart: e.position.colStart, rowStart: e.position.rowStart, ...i } : null;
699
740
  }
700
741
  // ---------------- Commit / cancel ----------------
701
742
  commitGesture() {
@@ -706,13 +747,13 @@ class G extends z {
706
747
  this.cleanupGesture();
707
748
  return;
708
749
  }
709
- const n = new Map(this.tiles.map((r) => [r.id, r.position])), i = this.tiles.map((r) => {
710
- const s = e.find((a) => a.id === r.id);
711
- return s ? { ...r, position: s.position } : r;
750
+ const o = new Map(this.tiles.map((r) => [r.id, r.position])), i = this.tiles.map((r) => {
751
+ const a = e.find((l) => l.id === r.id);
752
+ return a ? { ...r, position: a.position } : r;
712
753
  });
713
754
  this.tiles = i, e.forEach((r) => {
714
- const s = n.get(r.id);
715
- (!s || !this.positionsEqual(s, r.position)) && this.dispatchEvent(
755
+ const a = o.get(r.id);
756
+ (!a || !this.positionsEqual(a, r.position)) && this.dispatchEvent(
716
757
  new CustomEvent("tilepositionchange", {
717
758
  detail: { id: r.id, position: r.position },
718
759
  bubbles: !1,
@@ -726,9 +767,9 @@ class G extends z {
726
767
  composed: !0
727
768
  })
728
769
  );
729
- const o = e.find((r) => r.id === t.tileId);
730
- o && this.liveAnnouncer.announce(
731
- t.kind === "drag" ? `Tile moved to row ${o.position.rowStart}, column ${o.position.colStart}` : `Tile resized to ${o.position.colSpan} columns by ${o.position.rowSpan} rows`
770
+ const n = e.find((r) => r.id === t.tileId);
771
+ n && this.liveAnnouncer.announce(
772
+ t.kind === "drag" ? `Tile moved to row ${n.position.rowStart}, column ${n.position.colStart}` : `Tile resized to ${n.position.colSpan} columns by ${n.position.rowSpan} rows`
732
773
  ), this.cleanupGesture();
733
774
  }
734
775
  cancelGesture(t = "cancel") {
@@ -769,8 +810,8 @@ class G extends z {
769
810
  }
770
811
  // ---------------- Keyboard ----------------
771
812
  onTileKeyDown(t, e) {
772
- const n = this.keyboardState;
773
- if (n.kind === "idle") {
813
+ const o = this.keyboardState;
814
+ if (o.kind === "idle") {
774
815
  if (t.key === "m" || t.key === "M") {
775
816
  if (e.disableMove && e.disableResize) return;
776
817
  t.preventDefault(), this.keyboardState = {
@@ -784,13 +825,13 @@ class G extends z {
784
825
  }
785
826
  return this.handleFocusNavigation(t, e), void 0;
786
827
  }
787
- if (n.tileId === e.id) {
828
+ if (o.tileId === e.id) {
788
829
  if (t.key === "Escape" || t.key === "Enter") {
789
830
  t.preventDefault();
790
- const i = n.kind === "move" ? n.entryTiles : null;
831
+ const i = o.kind === "move" ? o.entryTiles : null;
791
832
  this.keyboardState = { kind: "idle" }, this.requestUpdate(), t.key === "Escape" && i && (this.tiles = i, this.requestUpdate(), this.dispatchEvent(
792
833
  new CustomEvent("tilelayoutchange", {
793
- detail: this.cloneSnapshot(i.map((o) => ({ id: o.id, position: o.position }))),
834
+ detail: this.cloneSnapshot(i.map((n) => ({ id: n.id, position: n.position }))),
794
835
  bubbles: !1,
795
836
  composed: !0
796
837
  })
@@ -811,14 +852,14 @@ class G extends z {
811
852
  */
812
853
  handleFocusNavigation(t, e) {
813
854
  if (!(t.key === "ArrowUp" || t.key === "ArrowDown" || t.key === "ArrowLeft" || t.key === "ArrowRight" || t.key === "Home" || t.key === "End") || this.tiles.length <= 1) return !1;
814
- const i = [...this.tiles].sort((a, d) => a.position.rowStart !== d.position.rowStart ? a.position.rowStart - d.position.rowStart : a.position.colStart - d.position.colStart), o = i.findIndex((a) => a.id === e.id);
815
- if (o < 0) return !1;
816
- let r = o;
817
- if (t.key === "Home" ? r = 0 : t.key === "End" ? r = i.length - 1 : t.key === "ArrowRight" || t.key === "ArrowDown" ? r = (o + 1) % i.length : r = (o - 1 + i.length) % i.length, r === o) return !0;
855
+ const i = [...this.tiles].sort((l, d) => l.position.rowStart !== d.position.rowStart ? l.position.rowStart - d.position.rowStart : l.position.colStart - d.position.colStart), n = i.findIndex((l) => l.id === e.id);
856
+ if (n < 0) return !1;
857
+ let r = n;
858
+ if (t.key === "Home" ? r = 0 : t.key === "End" ? r = i.length - 1 : t.key === "ArrowRight" || t.key === "ArrowDown" ? r = (n + 1) % i.length : r = (n - 1 + i.length) % i.length, r === n) return !0;
818
859
  t.preventDefault();
819
- const s = i[r];
820
- return this.focusedTileId = s.id, this.requestUpdate(), queueMicrotask(() => {
821
- this.shadowRoot?.querySelector(`.tile[data-tile-id="${s.id}"]`)?.focus();
860
+ const a = i[r];
861
+ return this.focusedTileId = a.id, this.requestUpdate(), queueMicrotask(() => {
862
+ this.shadowRoot?.querySelector(`.tile[data-tile-id="${a.id}"]`)?.focus();
822
863
  }), !0;
823
864
  }
824
865
  onTileFocus(t) {
@@ -831,39 +872,39 @@ class G extends z {
831
872
  * outside the board lands on exactly one tile.
832
873
  */
833
874
  resolveFocusableTileId() {
834
- return this.tiles.length === 0 ? null : this.focusedTileId && this.tiles.some((e) => e.id === this.focusedTileId) ? this.focusedTileId : [...this.tiles].sort((e, n) => e.position.rowStart !== n.position.rowStart ? e.position.rowStart - n.position.rowStart : e.position.colStart - n.position.colStart)[0]?.id ?? null;
875
+ return this.tiles.length === 0 ? null : this.focusedTileId && this.tiles.some((e) => e.id === this.focusedTileId) ? this.focusedTileId : [...this.tiles].sort((e, o) => e.position.rowStart !== o.position.rowStart ? e.position.rowStart - o.position.rowStart : e.position.colStart - o.position.colStart)[0]?.id ?? null;
835
876
  }
836
- applyKeyboardStep(t, e, n) {
837
- const i = this.effectiveColumnCount, o = e === "ArrowLeft" ? -1 : e === "ArrowRight" ? 1 : 0, r = e === "ArrowUp" ? -1 : e === "ArrowDown" ? 1 : 0, s = n ? {
877
+ applyKeyboardStep(t, e, o) {
878
+ const i = this.effectiveColumnCount, n = e === "ArrowLeft" ? -1 : e === "ArrowRight" ? 1 : 0, r = e === "ArrowUp" ? -1 : e === "ArrowDown" ? 1 : 0, a = o ? {
838
879
  colStart: t.position.colStart,
839
880
  rowStart: t.position.rowStart,
840
- colSpan: Math.max(1, Math.min(t.position.colSpan + o, i - t.position.colStart + 1)),
881
+ colSpan: Math.max(1, Math.min(t.position.colSpan + n, i - t.position.colStart + 1)),
841
882
  rowSpan: Math.max(1, t.position.rowSpan + r)
842
883
  } : {
843
- colStart: Math.max(1, Math.min(t.position.colStart + o, i - t.position.colSpan + 1)),
884
+ colStart: Math.max(1, Math.min(t.position.colStart + n, i - t.position.colSpan + 1)),
844
885
  rowStart: Math.max(1, t.position.rowStart + r),
845
886
  colSpan: t.position.colSpan,
846
887
  rowSpan: t.position.rowSpan
847
- }, a = v(
888
+ }, l = v(
848
889
  this.tiles.map((c) => ({ id: c.id, position: c.position, locked: !!c.disableMove })),
849
- { id: t.id, rect: s },
890
+ { id: t.id, rect: a },
850
891
  i
851
892
  );
852
- if (a.blocked) {
893
+ if (l.blocked) {
853
894
  this.liveAnnouncer.announce("Move blocked.");
854
895
  return;
855
896
  }
856
897
  const d = this.tiles.map((c) => {
857
- const h = a.layout.find((p) => p.id === c.id);
858
- return h ? { ...c, position: h.position } : c;
898
+ const p = l.layout.find((h) => h.id === c.id);
899
+ return p ? { ...c, position: p.position } : c;
859
900
  });
860
901
  this.tiles = d, this.dispatchEvent(
861
902
  new CustomEvent("tilelayoutchange", {
862
- detail: this.cloneSnapshot(a.layout),
903
+ detail: this.cloneSnapshot(l.layout),
863
904
  bubbles: !1,
864
905
  composed: !0
865
906
  })
866
- ), a.layout.forEach((c) => {
907
+ ), l.layout.forEach((c) => {
867
908
  this.dispatchEvent(
868
909
  new CustomEvent("tilepositionchange", {
869
910
  detail: { id: c.id, position: c.position },
@@ -872,13 +913,13 @@ class G extends z {
872
913
  })
873
914
  );
874
915
  }), this.liveAnnouncer.announce(
875
- n ? `Tile resized to ${s.colSpan} columns by ${s.rowSpan} rows` : `Tile moved to row ${s.rowStart}, column ${s.colStart}`
916
+ o ? `Tile resized to ${a.colSpan} columns by ${a.rowSpan} rows` : `Tile moved to row ${a.rowStart}, column ${a.colStart}`
876
917
  );
877
918
  }
878
919
  }
879
- typeof customElements < "u" && !customElements.get("mp-tile-manager") && customElements.define("mp-tile-manager", G);
920
+ typeof customElements < "u" && !customElements.get("mp-tile-manager") && customElements.define("mp-tile-manager", X);
880
921
  export {
881
- G as MintTileManagerElement,
922
+ X as MintTileManagerElement,
882
923
  v as pack,
883
924
  w as rectsOverlap
884
925
  };