@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.
- package/accordion/index.mjs +5 -5
- package/calendar/index.mjs +1 -1
- package/carousel/index.mjs +57 -143
- package/charts/core/index.mjs +30 -20
- package/charts/core/src/attributes.d.ts +18 -0
- package/charts/core/src/index.d.ts +2 -0
- package/charts/core/src/view-window.d.ts +46 -0
- package/charts/hierarchy/index.mjs +245 -256
- package/charts/hierarchy/src/components/mp-hierarchy-chart.d.ts +1 -3
- package/charts/sparkline/index.mjs +27 -26
- package/charts/trend/index.mjs +21 -20
- package/checkbox/index.mjs +1 -1
- package/checkbox/src/components/mp-checkbox.d.ts +1 -0
- package/chunks/attributes-L3eKsbdy.mjs +16 -0
- package/chunks/color-mode-warning-71FmlzWX.mjs +13 -0
- package/chunks/{form-check.styles-B0pxJ6YC.mjs → form-check.styles-DqvBnspm.mjs} +24 -3
- package/chunks/{mp-calendar.element-CJ8-t-Zn.mjs → mp-calendar.element-BIHS9SZZ.mjs} +11 -6
- package/chunks/{mp-checkbox-CzwS7Y_t.mjs → mp-checkbox-zV83gILn.mjs} +44 -36
- package/chunks/mp-datatable-eRpl7-2V.mjs +2238 -0
- package/chunks/{mp-datetime-picker.element-D1CiLbHm.mjs → mp-datetime-picker.element-Cxu5-qRE.mjs} +29 -32
- package/chunks/{mp-pagination-Dea75mD4.mjs → mp-pagination-hGy4dL7p.mjs} +9 -4
- package/chunks/{mp-radio-cL46sUA0.mjs → mp-radio-BhRVNdKp.mjs} +32 -28
- package/chunks/{mp-select-BNrbPwN4.mjs → mp-select-CgqYFvUj.mjs} +41 -26
- package/chunks/{mp-splitter-Ckn1kN4v.mjs → mp-splitter-DLehrw3Y.mjs} +144 -120
- package/chunks/{mp-timepicker.element-COZEUIoE.mjs → mp-timepicker.element-BiB9lkgc.mjs} +58 -45
- package/chunks/{mp-toggle-button-eo_aTQtu.mjs → mp-toggle-button-CaS9uYLE.mjs} +26 -24
- package/chunks/{mp-treeview-C8iltDbq.mjs → mp-treeview-CaMTDrvY.mjs} +51 -50
- package/chunks/{overlay-controller-D6agzzOI.mjs → overlay-controller-BHDagokg.mjs} +130 -70
- package/chunks/{id-DNZVAnGC.mjs → resource.service--lqLwEqk.mjs} +144 -206
- package/chunks/view-window-DGvFiDnW.mjs +263 -0
- package/code-snippet/index.mjs +70 -66
- package/code-snippet/src/hljs-loaders.generated.d.ts +1 -1
- package/custom-elements.json +65750 -0
- package/datatable/index.mjs +6 -5
- package/datatable/src/components/column-resize.d.ts +11 -0
- package/datatable/src/components/mp-datatable.d.ts +206 -1
- package/datatable/src/index.d.ts +3 -1
- package/datatable/src/types/column-def.d.ts +61 -0
- package/datatable/src/types/filter.d.ts +138 -0
- package/datatable/src/types/index.d.ts +3 -2
- package/datatable/src/types/labels.d.ts +58 -0
- package/datepicker/index.mjs +10 -9
- package/datetime-picker/index.mjs +1 -1
- package/datetime-picker/src/mp-datetime-picker.element.d.ts +3 -0
- package/dock/index.mjs +430 -463
- package/dock/src/components/mint-dock-manager.element.d.ts +25 -2
- package/dock/src/core/resize.d.ts +60 -0
- package/dropdown-menu/index.mjs +4 -2
- package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +6 -1
- package/dropdown-menu/src/index.d.ts +1 -1
- package/dropdown-menu/src/types/dropdown.d.ts +14 -1
- package/dropdown-menu/src/types/index.d.ts +1 -1
- package/file-manager/index.mjs +63 -61
- package/file-manager/src/components/mp-file-manager.d.ts +4 -3
- package/multi-range/index.mjs +56 -50
- package/multi-range/src/mint-multi-range.element.d.ts +4 -10
- package/multi-range/src/pointer-geometry.d.ts +31 -0
- package/navbar/index.mjs +89 -439
- package/overlay/index.mjs +5 -2
- package/overlay/src/index.d.ts +2 -0
- package/overlay/src/overlay-controller.d.ts +27 -14
- package/overlay/src/overlay-portal.d.ts +53 -0
- package/overlay/src/placement.d.ts +48 -0
- package/package.json +7 -1
- package/pagination/index.mjs +1 -1
- package/phone-input/index.mjs +44 -40
- package/phone-input/src/components/stack.d.ts +8 -0
- package/query-builder/index.mjs +418 -466
- package/query-builder/src/dnd/drag-controller.d.ts +12 -8
- package/query-builder/src/mp-query-builder.element.d.ts +5 -1
- package/query-builder/src/mp-query-condition.element.d.ts +1 -0
- package/radio/index.mjs +1 -1
- package/radio-group/index.mjs +1 -1
- package/ribbon/index.mjs +477 -498
- package/ribbon/src/core/band-text-color.d.ts +10 -0
- package/ribbon/src/core/key-tip-allocator.d.ts +10 -0
- package/ribbon/src/core/plan-reduce-steps.d.ts +62 -0
- package/ribbon/src/mp-ribbon.element.d.ts +0 -27
- package/scheduler/index.mjs +726 -711
- package/scheduler/src/components/mp-scheduler.d.ts +19 -3
- package/scheduler/src/drag/drag-manager.d.ts +1 -9
- package/scheduler/src/input/input-handler.d.ts +12 -2
- package/scheduler/src/utils/geometry.d.ts +39 -0
- package/scheduler/src/views/timeline-view.d.ts +0 -1
- package/scheduler-core/index.mjs +84 -71
- package/scheduler-core/src/services/resource.service.d.ts +0 -12
- package/scheduler-core/src/services/timeline.service.d.ts +0 -9
- package/select/index.mjs +1 -1
- package/select/src/components/mp-select.d.ts +1 -0
- package/signature-pad/index.mjs +21 -23
- package/signature-pad/src/canvas-point.d.ts +26 -0
- package/signature-pad/src/mp-signature-pad.element.d.ts +1 -7
- package/splitter/index.mjs +1 -1
- package/splitter/src/components/mp-splitter.d.ts +16 -0
- package/splitter/src/managers/index.d.ts +1 -0
- package/splitter/src/managers/rescale-panel-sizes.d.ts +14 -0
- package/swiper-core/index.mjs +2 -2
- package/theming/bs-theme-preboot.js +1 -0
- package/theming/color-mode.css +36 -0
- package/theming/index.d.ts +1 -0
- package/theming/index.mjs +327 -0
- package/theming/src/components/mp-theme-toggle.d.ts +71 -0
- package/theming/src/cookie.d.ts +31 -0
- package/theming/src/index.d.ts +5 -0
- package/theming/src/preboot.d.ts +1 -0
- package/theming/src/resolve.d.ts +36 -0
- package/theming/src/store.d.ts +27 -0
- package/theming/src/styles/theme-toggle.styles.d.ts +2 -0
- package/theming/src/testing/fake-broadcast-channel.d.ts +35 -0
- package/theming/src/toggle-modes.d.ts +23 -0
- package/tile-manager/index.mjs +252 -211
- package/tile-manager/src/components/mint-tile-manager.element.d.ts +8 -0
- package/tile-manager/src/utils/grid-geometry.d.ts +49 -0
- package/timeline/index.mjs +156 -164
- package/timeline/src/components/mp-timeline.d.ts +41 -7
- package/timepicker/index.mjs +7 -4
- package/timepicker/src/mp-time-list.element.d.ts +26 -0
- package/timepicker/src/mp-timepicker.element.d.ts +3 -0
- package/toggle-button/index.mjs +1 -1
- package/tree-select/index.mjs +21 -9
- package/treeview/index.mjs +1 -1
- package/treeview/src/components/mp-treeview.d.ts +6 -4
- package/chunks/color-DIeST-IS.mjs +0 -224
- package/chunks/mp-datatable-UJI8E73X.mjs +0 -1400
- package/datatable/src/styles/datatable.styles.d.ts +0 -2
- package/query-builder/src/mp-query-condition.element.template.d.ts +0 -2
package/tile-manager/index.mjs
CHANGED
|
@@ -1,107 +1,147 @@
|
|
|
1
|
-
import { html as f, unsafeCSS as
|
|
2
|
-
import { L as
|
|
3
|
-
function w(
|
|
4
|
-
return
|
|
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(
|
|
7
|
-
if (!
|
|
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 } },
|
|
10
|
-
if (
|
|
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(
|
|
14
|
-
const
|
|
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 =
|
|
18
|
-
const g = [...
|
|
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 !==
|
|
22
|
-
return { layout: y(
|
|
23
|
-
const c =
|
|
24
|
-
[i, ...
|
|
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:
|
|
26
|
+
return { layout: s.map((u) => ({
|
|
27
27
|
id: u.id,
|
|
28
|
-
position:
|
|
28
|
+
position: p.get(u.id) ?? { ...u.position }
|
|
29
29
|
})), blocked: !1 };
|
|
30
30
|
}
|
|
31
|
-
function y(
|
|
32
|
-
return
|
|
31
|
+
function y(s) {
|
|
32
|
+
return s.map((t) => ({ id: t.id, position: { ...t.position } }));
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
const { colSpan:
|
|
36
|
-
if (
|
|
37
|
-
if (!t.some((
|
|
38
|
-
return { id:
|
|
39
|
-
const r =
|
|
40
|
-
return r ? { id:
|
|
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
|
|
42
|
+
function M(s, t, e) {
|
|
43
43
|
const i = t.reduce(
|
|
44
|
-
(r,
|
|
44
|
+
(r, a) => Math.max(r, a.position.rowStart + a.position.rowSpan - 1),
|
|
45
45
|
0
|
|
46
|
-
) +
|
|
47
|
-
if (
|
|
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
|
|
50
|
-
const
|
|
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:
|
|
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:
|
|
61
|
+
return { rowStart: r, colStart: l, colSpan: s.colSpan, rowSpan: s.rowSpan };
|
|
62
62
|
}
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
return k(
|
|
65
|
+
function P(s, t, e) {
|
|
66
|
+
return k(s, t, e, 10);
|
|
67
67
|
}
|
|
68
|
-
function k(
|
|
69
|
-
if (
|
|
70
|
-
const { result: i, changed:
|
|
71
|
-
return
|
|
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
|
|
74
|
-
return
|
|
75
|
-
const r = i.position.rowStart -
|
|
76
|
-
return r !== 0 ? r : i.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,
|
|
79
|
-
const r = [...t, ...i.result.filter((d) => d.id !==
|
|
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:
|
|
82
|
-
changed: i.changed ||
|
|
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
|
|
89
|
-
if (
|
|
90
|
-
for (let e = 1; e <
|
|
91
|
-
let
|
|
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({ ...
|
|
94
|
-
|
|
93
|
+
if (w({ ...s, rowStart: e }, t[i].position)) {
|
|
94
|
+
o = !0;
|
|
95
95
|
break;
|
|
96
96
|
}
|
|
97
|
-
if (!
|
|
98
|
-
}
|
|
99
|
-
return
|
|
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
|
|
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
|
-
}`),
|
|
321
|
-
let
|
|
322
|
-
const
|
|
323
|
-
class
|
|
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
|
|
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 = [
|
|
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])),
|
|
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=${
|
|
412
|
+
style=${o}
|
|
373
413
|
>
|
|
374
414
|
${t.map((i) => {
|
|
375
|
-
const
|
|
376
|
-
return
|
|
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">${
|
|
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
|
|
385
|
-
width: e.colSpan *
|
|
386
|
-
height: e.rowSpan *
|
|
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
|
-
|
|
430
|
+
a ? `transform: ${a}` : "",
|
|
391
431
|
d ? `width: ${d.width}px` : "",
|
|
392
432
|
d ? `height: ${d.height}px` : ""
|
|
393
|
-
].filter(Boolean).join("; "),
|
|
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=${
|
|
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=${
|
|
446
|
+
data-dragging=${o ? "true" : "false"}
|
|
407
447
|
data-resizing=${i ? "true" : "false"}
|
|
408
|
-
data-blocked=${
|
|
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=${(
|
|
416
|
-
@keydown=${(
|
|
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=${(
|
|
467
|
+
@pointerdown=${(h) => this.onResizeHandlePointerDown(h, t, "side")}></div>
|
|
428
468
|
<div class="tile__resize-bottom" data-resize="bottom"
|
|
429
|
-
@pointerdown=${(
|
|
469
|
+
@pointerdown=${(h) => this.onResizeHandlePointerDown(h, t, "bottom")}></div>
|
|
430
470
|
<div class="tile__resize-corner" data-resize="corner"
|
|
431
|
-
@pointerdown=${(
|
|
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
|
|
462
|
-
this.cellMetrics = { width:
|
|
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
|
|
468
|
-
if (!
|
|
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
|
|
472
|
-
return `translate(${
|
|
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,
|
|
491
|
-
super.attributeChangedCallback(t, e,
|
|
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((
|
|
501
|
-
const i =
|
|
502
|
-
i && this.flipPreviousRects.set(i,
|
|
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
|
|
558
|
+
const o = this.activeTileId();
|
|
510
559
|
e.querySelectorAll(".tile").forEach((i) => {
|
|
511
|
-
const
|
|
512
|
-
if (!
|
|
513
|
-
const r = this.flipPreviousRects.get(
|
|
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
|
|
516
|
-
if (Math.abs(
|
|
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(${
|
|
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,
|
|
530
|
-
t.button !== 0 && t.pointerType === "mouse" || e.disableResize || this.resizeMode === "off" || this.gestureState.kind === "idle" && (t.stopPropagation(), t.preventDefault(), this.beginResize(t, e,
|
|
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
|
|
535
|
-
if (
|
|
536
|
-
const
|
|
537
|
-
Math.hypot(
|
|
538
|
-
}, r = (
|
|
539
|
-
|
|
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",
|
|
590
|
+
window.addEventListener("pointermove", n), window.addEventListener("pointerup", r), window.addEventListener("pointercancel", r);
|
|
542
591
|
}
|
|
543
592
|
armTouchDrag(t, e) {
|
|
544
|
-
const
|
|
545
|
-
this.gestureState.kind === "arming-touch-drag" && this.gestureState.pointerId ===
|
|
546
|
-
},
|
|
547
|
-
if (!(this.gestureState.kind !== "arming-touch-drag" || this.gestureState.pointerId !==
|
|
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,
|
|
602
|
+
this.beginDragFromTouchArm(e, o, i, n);
|
|
554
603
|
}
|
|
555
|
-
},
|
|
604
|
+
}, q);
|
|
556
605
|
this.gestureState = {
|
|
557
606
|
kind: "arming-touch-drag",
|
|
558
|
-
pointerId:
|
|
607
|
+
pointerId: n,
|
|
559
608
|
tileId: e.id,
|
|
560
|
-
startX:
|
|
609
|
+
startX: o,
|
|
561
610
|
startY: i,
|
|
562
|
-
timer:
|
|
611
|
+
timer: a,
|
|
563
612
|
pressingTimer: r
|
|
564
613
|
}, this.gestureKind = "arming-touch-drag";
|
|
565
|
-
const
|
|
566
|
-
if (c.pointerId !==
|
|
567
|
-
const
|
|
568
|
-
Math.hypot(
|
|
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 ===
|
|
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",
|
|
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,
|
|
580
|
-
this.
|
|
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
|
|
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:
|
|
601
|
-
tileId:
|
|
602
|
-
pointerOffset: { dx:
|
|
603
|
-
currentRect: { ...
|
|
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:
|
|
651
|
+
}, this.gestureKind = "drag", this.lastPointerPosition = { x: o, y: i }, this.attachWindowListeners(), this.announceDragBegin(t), !0;
|
|
606
652
|
}
|
|
607
|
-
beginResize(t, e,
|
|
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:
|
|
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((
|
|
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
|
|
665
|
-
if (!
|
|
666
|
-
t.currentRect =
|
|
667
|
-
const i = this.effectiveColumnCount,
|
|
668
|
-
this.tiles.map((
|
|
669
|
-
{ id: e.id, rect:
|
|
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 =
|
|
718
|
+
this.previewLayout = n.layout;
|
|
673
719
|
const r = t.blocked;
|
|
674
|
-
t.blocked =
|
|
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
|
|
678
|
-
if (!
|
|
679
|
-
const i = this.
|
|
680
|
-
|
|
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
|
|
729
|
+
const o = this.lastPointerPosition;
|
|
691
730
|
if (!o) return null;
|
|
692
|
-
const
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
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
|
|
710
|
-
const
|
|
711
|
-
return
|
|
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
|
|
715
|
-
(!
|
|
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
|
|
730
|
-
|
|
731
|
-
t.kind === "drag" ? `Tile moved to row ${
|
|
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
|
|
773
|
-
if (
|
|
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 (
|
|
828
|
+
if (o.tileId === e.id) {
|
|
788
829
|
if (t.key === "Escape" || t.key === "Enter") {
|
|
789
830
|
t.preventDefault();
|
|
790
|
-
const i =
|
|
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((
|
|
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((
|
|
815
|
-
if (
|
|
816
|
-
let r =
|
|
817
|
-
if (t.key === "Home" ? r = 0 : t.key === "End" ? r = i.length - 1 : t.key === "ArrowRight" || t.key === "ArrowDown" ? r = (
|
|
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
|
|
820
|
-
return this.focusedTileId =
|
|
821
|
-
this.shadowRoot?.querySelector(`.tile[data-tile-id="${
|
|
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,
|
|
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,
|
|
837
|
-
const i = this.effectiveColumnCount,
|
|
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 +
|
|
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 +
|
|
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
|
-
},
|
|
888
|
+
}, l = v(
|
|
848
889
|
this.tiles.map((c) => ({ id: c.id, position: c.position, locked: !!c.disableMove })),
|
|
849
|
-
{ id: t.id, rect:
|
|
890
|
+
{ id: t.id, rect: a },
|
|
850
891
|
i
|
|
851
892
|
);
|
|
852
|
-
if (
|
|
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
|
|
858
|
-
return
|
|
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(
|
|
903
|
+
detail: this.cloneSnapshot(l.layout),
|
|
863
904
|
bubbles: !1,
|
|
864
905
|
composed: !0
|
|
865
906
|
})
|
|
866
|
-
),
|
|
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
|
-
|
|
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",
|
|
920
|
+
typeof customElements < "u" && !customElements.get("mp-tile-manager") && customElements.define("mp-tile-manager", X);
|
|
880
921
|
export {
|
|
881
|
-
|
|
922
|
+
X as MintTileManagerElement,
|
|
882
923
|
v as pack,
|
|
883
924
|
w as rectsOverlap
|
|
884
925
|
};
|