@mintplayer/web-components 2.2.0 → 2.4.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/a11y/index.mjs +26 -2
- package/a11y/src/dismiss-stack.d.ts +25 -0
- package/a11y/src/error-text.d.ts +41 -0
- package/a11y/src/focus-restore.d.ts +116 -0
- package/a11y/src/focus-trap.d.ts +69 -0
- package/a11y/src/form-associated.d.ts +48 -0
- package/a11y/src/host-aria.d.ts +154 -0
- package/a11y/src/index.d.ts +16 -0
- package/a11y/src/inert-regions.d.ts +52 -0
- package/a11y/src/live-announcer.d.ts +8 -0
- package/a11y/src/roving-focus.d.ts +118 -0
- package/a11y/src/testing/expect-idref-resolves.d.ts +31 -0
- package/a11y/src/testing/index.d.ts +1 -0
- package/accordion/index.mjs +180 -174
- package/accordion/src/components/mp-accordion.d.ts +18 -13
- package/calendar/index.mjs +1 -1
- package/calendar/src/mp-calendar.element.d.ts +2 -0
- package/carousel/index.mjs +211 -164
- package/carousel/src/components/mp-carousel.d.ts +1 -0
- package/checkbox/index.mjs +1 -1
- package/checkbox/src/components/mp-checkbox.d.ts +59 -1
- package/chunks/color-CpFtrIoX.mjs +899 -0
- package/chunks/focus-restore-DxuP1Oe2.mjs +94 -0
- package/chunks/focus-trap-DTOLJ5bb.mjs +121 -0
- package/chunks/form-associated-axmc5sY0.mjs +58 -0
- package/chunks/host-aria-WSGs7SPQ.mjs +152 -0
- package/chunks/inert-regions-DXCnn1LN.mjs +48 -0
- package/chunks/invalid-feedback.styles-he0JYrJm.mjs +11 -0
- package/chunks/{live-announcer-CZDTKulf.mjs → live-announcer-Bi0orG4n.mjs} +9 -9
- package/chunks/{mp-calendar.element-UC68iDbi.mjs → mp-calendar.element-u6uS31_j.mjs} +136 -105
- package/chunks/mp-checkbox-Ph2mMRGz.mjs +312 -0
- package/chunks/{mp-datatable-Bfw0KGkV.mjs → mp-datatable-BwTlh9A_.mjs} +265 -103
- package/chunks/{mp-pagination-BGxsawFL.mjs → mp-pagination-Dea75mD4.mjs} +25 -22
- package/chunks/mp-radio-BjW1HNSc.mjs +300 -0
- package/chunks/{mp-select-BDS1-YGn.mjs → mp-select-Ctu-v1-p.mjs} +163 -40
- package/chunks/{mp-splitter-C8cGCmac.mjs → mp-splitter-LszuRDbR.mjs} +53 -46
- package/chunks/{mp-tab-page-D1b4x-y2.mjs → mp-tab-page-CaCzX1ym.mjs} +46 -45
- package/chunks/{mp-timepicker.element-BwEiwX92.mjs → mp-timepicker.element-Bz393NDQ.mjs} +93 -86
- package/chunks/{mp-toggle-button-dLZNDUVz.mjs → mp-toggle-button-Kz6sIgBJ.mjs} +131 -37
- package/chunks/{mp-treeview-C48F63xb.mjs → mp-treeview-tkWu28iF.mjs} +67 -43
- package/chunks/overlay-controller-DPt13i8p.mjs +314 -0
- package/chunks/roving-focus-CrL9982a.mjs +129 -0
- package/code-snippet/index.mjs +21 -13
- package/code-snippet/src/mp-code-snippet.element.d.ts +6 -0
- package/datatable/index.mjs +1 -1
- package/datatable/src/components/mp-datatable.d.ts +50 -0
- package/datatable/src/types/index.d.ts +2 -0
- package/datatable/src/types/labels.d.ts +30 -0
- package/datepicker/index.mjs +45 -22
- package/datepicker/src/mp-datepicker.element.d.ts +30 -0
- package/datetime-picker/index.mjs +15 -9
- package/dock/index.mjs +365 -209
- package/dock/src/components/mint-dock-manager.element.d.ts +63 -3
- package/dropdown-menu/index.mjs +135 -90
- package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +12 -3
- package/file-manager/index.mjs +279 -214
- package/file-manager/src/components/mp-file-manager.d.ts +22 -0
- package/file-manager/src/types/messages.d.ts +9 -0
- package/multi-range/index.mjs +26 -10
- package/multi-range/src/mint-multi-range.element.d.ts +7 -0
- package/navbar/index.mjs +53 -39
- package/navbar/src/components/mp-navbar.d.ts +1 -0
- package/otp-input/index.mjs +82 -48
- package/otp-input/src/mint-otp-input.element.d.ts +31 -3
- package/overlay/index.mjs +2 -258
- package/overlay/src/overlay-controller.d.ts +64 -4
- package/package.json +9 -1
- package/pagination/index.mjs +1 -1
- package/query-builder/index.mjs +117 -87
- package/query-builder/src/model/messages.d.ts +9 -0
- package/radio/index.mjs +2 -160
- package/radio/src/components/mp-radio.d.ts +58 -3
- package/radio-group/index.d.ts +1 -0
- package/radio-group/index.mjs +145 -0
- package/radio-group/src/components/mp-radio-group.d.ts +52 -0
- package/radio-group/src/index.d.ts +1 -0
- package/radio-group/src/styles/radio-group.styles.d.ts +2 -0
- package/ribbon/index.mjs +316 -304
- package/ribbon/src/mp-ribbon.element.d.ts +16 -0
- package/scheduler/index.mjs +892 -493
- package/scheduler/src/components/mp-scheduler.d.ts +30 -0
- package/scheduler/src/input/input-handler.d.ts +2 -0
- package/scheduler/src/views/base-view.d.ts +43 -6
- package/scheduler/src/views/timeline-view.d.ts +6 -0
- package/scheduler-core/index.mjs +73 -70
- package/scheduler-core/src/models/index.d.ts +1 -0
- package/scheduler-core/src/models/messages.d.ts +69 -0
- package/scheduler-core/src/models/options.d.ts +4 -0
- package/select/index.mjs +1 -1
- package/select/src/components/mp-select.d.ts +60 -3
- package/shell/index.mjs +142 -31
- package/shell/src/components/mp-shell.d.ts +1 -0
- package/signature-pad/index.d.ts +1 -0
- package/signature-pad/index.mjs +230 -0
- package/signature-pad/src/index.d.ts +2 -0
- package/signature-pad/src/mp-signature-pad.element.d.ts +143 -0
- package/signature-pad/src/mp-signature-pad.element.template.d.ts +2 -0
- package/signature-pad/src/types/signature.d.ts +12 -0
- package/splitter/index.mjs +1 -1
- package/splitter/src/components/mp-splitter.d.ts +7 -0
- package/tab-control/index.mjs +1 -1
- package/tile-manager/index.mjs +110 -93
- package/timeline/index.mjs +138 -54
- package/timeline/src/components/mp-timeline.d.ts +15 -0
- package/timepicker/index.mjs +1 -1
- package/timepicker/src/mp-time-list.element.d.ts +13 -4
- package/timepicker/src/mp-timepicker.element.d.ts +29 -0
- package/toggle-button/index.mjs +1 -1
- package/toggle-button/src/components/mp-toggle-button.d.ts +32 -1
- package/tree-select/index.mjs +233 -121
- package/tree-select/src/components/mp-tree-select.d.ts +37 -0
- package/treeview/index.mjs +1 -1
- package/treeview/src/components/mp-treeview.d.ts +10 -1
- package/chunks/color-CyamnJnn.mjs +0 -847
- package/chunks/mp-checkbox-BokLL7BS.mjs +0 -211
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import { Signature } from './types/signature';
|
|
3
|
+
/**
|
|
4
|
+
* mp-signature-pad — freehand signature capture with a typed alternative.
|
|
5
|
+
*
|
|
6
|
+
* Freehand drawing is inherently pointer-only — there is no keyboard
|
|
7
|
+
* equivalent for a hand-drawn stroke. The typed-signature input below the
|
|
8
|
+
* canvas is the accessible alternative: its value is stored on
|
|
9
|
+
* `Signature.text` and rendered onto the canvas in a script font, so a
|
|
10
|
+
* keyboard-only user produces the same artifact through the same model.
|
|
11
|
+
* Undo and Clear are plain buttons in the tab order.
|
|
12
|
+
*
|
|
13
|
+
* Properties / attributes:
|
|
14
|
+
* - `signature` (property only) the full model: `{ strokes, text }`.
|
|
15
|
+
* - `width` / `height` canvas dimensions in pixels.
|
|
16
|
+
* - `input-label` accessible name of the canvas (role="img");
|
|
17
|
+
* a host `aria-label` wins, as everywhere in
|
|
18
|
+
* the library. Defaults to 'Signature pad'.
|
|
19
|
+
* - `type-label` / `undo-label` / `clear-label` control labels.
|
|
20
|
+
* - `show-accessibility-toggle` shows the typed alternative; default true
|
|
21
|
+
* (it is the only keyboard path), switch off
|
|
22
|
+
* with an explicit "false" value.
|
|
23
|
+
*
|
|
24
|
+
* Events (bubbles + composed):
|
|
25
|
+
* - `signature-change` detail = the current Signature, on every mutation
|
|
26
|
+
* (stroke point, typed character, undo, clear).
|
|
27
|
+
*/
|
|
28
|
+
export declare class MpSignaturePadElement extends LitElement {
|
|
29
|
+
static styles: import('lit').CSSResult[];
|
|
30
|
+
static properties: {
|
|
31
|
+
signature: {
|
|
32
|
+
attribute: boolean;
|
|
33
|
+
};
|
|
34
|
+
width: {
|
|
35
|
+
attribute: string;
|
|
36
|
+
type: NumberConstructor;
|
|
37
|
+
reflect: boolean;
|
|
38
|
+
};
|
|
39
|
+
height: {
|
|
40
|
+
attribute: string;
|
|
41
|
+
type: NumberConstructor;
|
|
42
|
+
reflect: boolean;
|
|
43
|
+
};
|
|
44
|
+
inputLabel: {
|
|
45
|
+
attribute: string;
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
reflect: boolean;
|
|
48
|
+
};
|
|
49
|
+
typeLabel: {
|
|
50
|
+
attribute: string;
|
|
51
|
+
type: StringConstructor;
|
|
52
|
+
reflect: boolean;
|
|
53
|
+
};
|
|
54
|
+
undoLabel: {
|
|
55
|
+
attribute: string;
|
|
56
|
+
type: StringConstructor;
|
|
57
|
+
reflect: boolean;
|
|
58
|
+
};
|
|
59
|
+
clearLabel: {
|
|
60
|
+
attribute: string;
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
reflect: boolean;
|
|
63
|
+
};
|
|
64
|
+
showAccessibilityToggle: {
|
|
65
|
+
attribute: string;
|
|
66
|
+
converter: {
|
|
67
|
+
fromAttribute: (v: string | null) => boolean;
|
|
68
|
+
};
|
|
69
|
+
reflect: boolean;
|
|
70
|
+
};
|
|
71
|
+
ariaLabelForRender: {
|
|
72
|
+
attribute: string;
|
|
73
|
+
type: StringConstructor;
|
|
74
|
+
reflect: boolean;
|
|
75
|
+
};
|
|
76
|
+
ariaLabelledByForSync: {
|
|
77
|
+
attribute: string;
|
|
78
|
+
type: StringConstructor;
|
|
79
|
+
reflect: boolean;
|
|
80
|
+
};
|
|
81
|
+
ariaDescribedByForSync: {
|
|
82
|
+
attribute: string;
|
|
83
|
+
type: StringConstructor;
|
|
84
|
+
reflect: boolean;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
inputLabel: string | null;
|
|
90
|
+
typeLabel: string;
|
|
91
|
+
undoLabel: string;
|
|
92
|
+
clearLabel: string;
|
|
93
|
+
/**
|
|
94
|
+
* Shows the typed alternative. Named and defaulted exactly like
|
|
95
|
+
* bs-color-picker's showAccessibilityToggle: ON by default (the typed
|
|
96
|
+
* input is the only keyboard path a canvas can have), switched off with
|
|
97
|
+
* show-accessibility-toggle="false" only for deliberate draw-only flows
|
|
98
|
+
* that accept losing keyboard operability.
|
|
99
|
+
*/
|
|
100
|
+
showAccessibilityToggle: boolean;
|
|
101
|
+
/** Mirror of the host aria-label attribute; exists only to trigger re-renders. */
|
|
102
|
+
ariaLabelForRender: string | null;
|
|
103
|
+
ariaLabelledByForSync: string | null;
|
|
104
|
+
ariaDescribedByForSync: string | null;
|
|
105
|
+
private _signature;
|
|
106
|
+
private _isDrawing;
|
|
107
|
+
private _context;
|
|
108
|
+
private canvasEl?;
|
|
109
|
+
private typedInputEl?;
|
|
110
|
+
/** Tier-2 naming: host aria-labelledby/-describedby resolve to the canvas. */
|
|
111
|
+
private readonly hostAria;
|
|
112
|
+
get signature(): Signature;
|
|
113
|
+
set signature(next: Signature | null | undefined);
|
|
114
|
+
connectedCallback(): void;
|
|
115
|
+
disconnectedCallback(): void;
|
|
116
|
+
/** Focus the pad = focus its typed-signature input (the keyboard entry point). */
|
|
117
|
+
focus(options?: FocusOptions): void;
|
|
118
|
+
undo(): void;
|
|
119
|
+
clear(): void;
|
|
120
|
+
protected firstUpdated(): void;
|
|
121
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
122
|
+
/**
|
|
123
|
+
* Map a pointer event into canvas BITMAP coordinates. `offsetX/offsetY` are
|
|
124
|
+
* CSS pixels of the rendered box; when the canvas is CSS-sized (e.g.
|
|
125
|
+
* `width: 100%`) those disagree with the `width`/`height` drawing space and
|
|
126
|
+
* every stroke would land offset and stretched. Scaling by
|
|
127
|
+
* bitmap-size / rendered-rect keeps drawing correct under any CSS sizing.
|
|
128
|
+
*/
|
|
129
|
+
private toCanvasPoint;
|
|
130
|
+
private onPointerStart;
|
|
131
|
+
private onPointerMove;
|
|
132
|
+
private onPointerEnd;
|
|
133
|
+
private onTypedInput;
|
|
134
|
+
/** Repaint the canvas from the model: every stroke, then the typed text. */
|
|
135
|
+
private redraw;
|
|
136
|
+
private dispatchSignatureChange;
|
|
137
|
+
protected render(): TemplateResult;
|
|
138
|
+
}
|
|
139
|
+
declare global {
|
|
140
|
+
interface HTMLElementTagNameMap {
|
|
141
|
+
'mp-signature-pad': MpSignaturePadElement;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Point {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export interface Stroke {
|
|
6
|
+
points: Point[];
|
|
7
|
+
}
|
|
8
|
+
export interface Signature {
|
|
9
|
+
strokes: Stroke[];
|
|
10
|
+
/** Typed-signature alternative for users who cannot draw with a pointer. */
|
|
11
|
+
text?: string;
|
|
12
|
+
}
|
package/splitter/index.mjs
CHANGED
|
@@ -76,6 +76,13 @@ export declare class MpSplitter extends LitElement {
|
|
|
76
76
|
* valuemax = (panels[i].size + panels[i+1].size - minPanelSize) as %.
|
|
77
77
|
*/
|
|
78
78
|
private updateDividerAriaValues;
|
|
79
|
+
/**
|
|
80
|
+
* updatePanelsFromSlot clears with innerHTML = '' — a focused divider is
|
|
81
|
+
* destroyed on every slot change (panes added/removed while the user is
|
|
82
|
+
* mid-resize), dropping focus to <body>. Keyed by position: divider N still
|
|
83
|
+
* separates the same region after a rebuild.
|
|
84
|
+
*/
|
|
85
|
+
private readonly dividerFocusRestore;
|
|
79
86
|
private updatePanelsFromSlot;
|
|
80
87
|
/**
|
|
81
88
|
* Read each panel-wrapper's measured pixel size and persist it as the
|
package/tab-control/index.mjs
CHANGED
package/tile-manager/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { html as f, unsafeCSS as x, LitElement as z, nothing as b } from "lit";
|
|
2
|
-
import { L as _ } from "../chunks/live-announcer-
|
|
2
|
+
import { L as _ } from "../chunks/live-announcer-Bi0orG4n.mjs";
|
|
3
3
|
function w(l, t) {
|
|
4
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;
|
|
5
5
|
}
|
|
6
6
|
function v(l, t, e) {
|
|
7
7
|
if (!l.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 } }, o = l.filter((u) => u.locked && u.id !== t.id).map((u) => ({ id: u.id, position: { ...u.position } }));
|
|
10
|
+
if (o.some(
|
|
11
11
|
(u) => w(u.position, i.position)
|
|
12
12
|
))
|
|
13
13
|
return { layout: y(l), blocked: !0 };
|
|
14
|
-
const s = [i, ...
|
|
14
|
+
const s = [i, ...o], a = l.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
17
|
}), d = a.reduce((u, m) => {
|
|
@@ -21,7 +21,7 @@ function v(l, t, e) {
|
|
|
21
21
|
if (d.length !== a.length)
|
|
22
22
|
return { layout: y(l), blocked: !0 };
|
|
23
23
|
const c = T(d, s, e), h = new Map(
|
|
24
|
-
[i, ...
|
|
24
|
+
[i, ...o, ...c].map((u) => [u.id, u.position])
|
|
25
25
|
);
|
|
26
26
|
return { layout: l.map((u) => ({
|
|
27
27
|
id: u.id,
|
|
@@ -36,29 +36,29 @@ function C(l, t, e) {
|
|
|
36
36
|
if (n > e) return null;
|
|
37
37
|
if (!t.some((s) => w(l.position, s.position)))
|
|
38
38
|
return { id: l.id, position: { ...l.position } };
|
|
39
|
-
const
|
|
40
|
-
return
|
|
39
|
+
const r = R({ colSpan: n, rowSpan: i }, t, e);
|
|
40
|
+
return r ? { id: l.id, position: r } : null;
|
|
41
41
|
}
|
|
42
42
|
function R(l, t, e) {
|
|
43
43
|
const i = t.reduce(
|
|
44
|
-
(
|
|
44
|
+
(r, s) => Math.max(r, s.position.rowStart + s.position.rowSpan - 1),
|
|
45
45
|
0
|
|
46
|
-
) + l.rowSpan,
|
|
47
|
-
if (
|
|
48
|
-
for (let
|
|
49
|
-
for (let s = 0; s <
|
|
46
|
+
) + l.rowSpan, o = e - l.colSpan + 1;
|
|
47
|
+
if (o < 1) return null;
|
|
48
|
+
for (let r = 1; r <= i; r++)
|
|
49
|
+
for (let s = 0; s < o; s++) {
|
|
50
50
|
const a = s + 1;
|
|
51
51
|
let d = !1;
|
|
52
52
|
for (let c = 0; c < t.length; c++)
|
|
53
53
|
if (w(
|
|
54
|
-
{ rowStart:
|
|
54
|
+
{ rowStart: r, colStart: a, colSpan: l.colSpan, rowSpan: l.rowSpan },
|
|
55
55
|
t[c].position
|
|
56
56
|
)) {
|
|
57
57
|
d = !0;
|
|
58
58
|
break;
|
|
59
59
|
}
|
|
60
60
|
if (!d)
|
|
61
|
-
return { rowStart:
|
|
61
|
+
return { rowStart: r, colStart: a, colSpan: l.colSpan, rowSpan: l.rowSpan };
|
|
62
62
|
}
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
@@ -67,25 +67,25 @@ function T(l, t, e) {
|
|
|
67
67
|
}
|
|
68
68
|
function k(l, t, e, n) {
|
|
69
69
|
if (n <= 0) return l;
|
|
70
|
-
const { result: i, changed:
|
|
71
|
-
return
|
|
70
|
+
const { result: i, changed: o } = E(l, t);
|
|
71
|
+
return o ? k(i, t, e, n - 1) : i;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
return l.slice().sort((i,
|
|
75
|
-
const
|
|
76
|
-
return
|
|
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;
|
|
77
77
|
}).reduce(
|
|
78
|
-
(i,
|
|
79
|
-
const
|
|
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;
|
|
80
80
|
return {
|
|
81
|
-
result: [...i.result, { id:
|
|
81
|
+
result: [...i.result, { id: o.id, position: s }],
|
|
82
82
|
changed: i.changed || a
|
|
83
83
|
};
|
|
84
84
|
},
|
|
85
85
|
{ result: [], changed: !1 }
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function M(l, t) {
|
|
89
89
|
if (l.rowStart <= 1) return l;
|
|
90
90
|
for (let e = 1; e < l.rowStart; e++) {
|
|
91
91
|
let n = !1;
|
|
@@ -319,8 +319,8 @@ const P = x(`:host {
|
|
|
319
319
|
outline-offset: -2px;
|
|
320
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
321
|
let L = 0;
|
|
322
|
-
const $ = 600, A = 10, D = 150,
|
|
323
|
-
class
|
|
322
|
+
const $ = 600, A = 10, D = 150, q = 5;
|
|
323
|
+
class G extends z {
|
|
324
324
|
constructor() {
|
|
325
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 = () => {
|
|
326
326
|
document.visibilityState === "hidden" && this.cancelGesture();
|
|
@@ -369,12 +369,11 @@ class O extends z {
|
|
|
369
369
|
class="tile-grid"
|
|
370
370
|
role="region"
|
|
371
371
|
aria-label=${this.label ?? "Tile board"}
|
|
372
|
-
aria-describedby=${this.instructionsId}
|
|
373
372
|
style=${n}
|
|
374
373
|
>
|
|
375
374
|
${t.map((i) => {
|
|
376
|
-
const
|
|
377
|
-
return
|
|
375
|
+
const o = e.get(i.id);
|
|
376
|
+
return o ? this.renderTile(o, i.position) : b;
|
|
378
377
|
})}
|
|
379
378
|
</div>
|
|
380
379
|
<div id=${this.instructionsId} class="tile-grid__sr-only">${I}</div>
|
|
@@ -382,7 +381,7 @@ class O extends z {
|
|
|
382
381
|
`;
|
|
383
382
|
}
|
|
384
383
|
renderTile(t, e) {
|
|
385
|
-
const n = this.gestureKind === "drag" && this.activeTileId() === t.id, i = this.gestureKind === "resize" && this.activeTileId() === t.id,
|
|
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 ? {
|
|
386
385
|
width: e.colSpan * a.width + (e.colSpan - 1) * a.gapX,
|
|
387
386
|
height: e.rowSpan * a.height + (e.rowSpan - 1) * a.gapY
|
|
388
387
|
} : null, c = [
|
|
@@ -397,11 +396,17 @@ class O extends z {
|
|
|
397
396
|
class="tile"
|
|
398
397
|
role="button"
|
|
399
398
|
tabindex=${h ? "0" : "-1"}
|
|
399
|
+
aria-describedby=${// On the TILE, not the region: the instructions describe what a
|
|
400
|
+
// focused tile can do, and SRs read describedby at the focus target.
|
|
401
|
+
this.instructionsId}
|
|
402
|
+
aria-pressed=${// Always written, both values (scheduler precedent): the pressed
|
|
403
|
+
// token IS the move-mode state, re-derived every render (§11a).
|
|
404
|
+
this.keyboardState.kind === "move" && this.keyboardState.tileId === t.id ? "true" : "false"}
|
|
400
405
|
data-tile-id=${t.id}
|
|
401
406
|
data-dragging=${n ? "true" : "false"}
|
|
402
407
|
data-resizing=${i ? "true" : "false"}
|
|
403
|
-
data-blocked=${
|
|
404
|
-
data-pressing=${
|
|
408
|
+
data-blocked=${o ? "true" : "false"}
|
|
409
|
+
data-pressing=${r ? "true" : "false"}
|
|
405
410
|
data-drag-mode=${this.dragMode}
|
|
406
411
|
data-locked-move=${t.disableMove ? "true" : "false"}
|
|
407
412
|
data-locked-resize=${t.disableResize ? "true" : "false"}
|
|
@@ -453,8 +458,8 @@ class O extends z {
|
|
|
453
458
|
const d = e.gridTemplateColumns.split(/\s+/).filter(Boolean);
|
|
454
459
|
this.effectiveColumnCount = Math.max(1, d.length);
|
|
455
460
|
}
|
|
456
|
-
const n = t.getBoundingClientRect(), i = this.effectiveColumnCount,
|
|
457
|
-
this.cellMetrics = { width: s, height: a, gapX:
|
|
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 };
|
|
458
463
|
}
|
|
459
464
|
computeActiveTransform(t) {
|
|
460
465
|
const e = this.gestureState;
|
|
@@ -463,7 +468,7 @@ class O extends z {
|
|
|
463
468
|
if (!n) return null;
|
|
464
469
|
const i = this.shadowRoot?.querySelector(".tile-grid");
|
|
465
470
|
if (!i) return null;
|
|
466
|
-
const
|
|
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);
|
|
467
472
|
return `translate(${Math.round(a - c)}px, ${Math.round(d - h)}px)`;
|
|
468
473
|
}
|
|
469
474
|
// ---------------- Lifecycle ----------------
|
|
@@ -503,11 +508,11 @@ class O extends z {
|
|
|
503
508
|
if (!e) return;
|
|
504
509
|
const n = this.activeTileId();
|
|
505
510
|
e.querySelectorAll(".tile").forEach((i) => {
|
|
506
|
-
const
|
|
507
|
-
if (!
|
|
508
|
-
const
|
|
509
|
-
if (!
|
|
510
|
-
const s = i.getBoundingClientRect(), a =
|
|
511
|
+
const o = i.dataset.tileId;
|
|
512
|
+
if (!o || o === n) return;
|
|
513
|
+
const r = this.flipPreviousRects.get(o);
|
|
514
|
+
if (!r) return;
|
|
515
|
+
const s = i.getBoundingClientRect(), a = r.left - s.left, d = r.top - s.top;
|
|
511
516
|
if (Math.abs(a) < 0.5 && Math.abs(d) < 0.5) return;
|
|
512
517
|
const c = i.style.transition;
|
|
513
518
|
i.style.transition = "none", i.style.transform = `translate(${a}px, ${d}px)`, requestAnimationFrame(() => {
|
|
@@ -526,43 +531,43 @@ class O extends z {
|
|
|
526
531
|
}
|
|
527
532
|
// ---------------- Drag arming ----------------
|
|
528
533
|
armPointerDrag(t, e) {
|
|
529
|
-
const n = t.clientX, i = t.clientY,
|
|
534
|
+
const n = t.clientX, i = t.clientY, o = (s) => {
|
|
530
535
|
if (s.pointerId !== t.pointerId) return;
|
|
531
536
|
const a = s.clientX - n, d = s.clientY - i;
|
|
532
|
-
Math.hypot(a, d) >=
|
|
533
|
-
},
|
|
534
|
-
s.pointerId === t.pointerId && (window.removeEventListener("pointermove",
|
|
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));
|
|
535
540
|
};
|
|
536
|
-
window.addEventListener("pointermove",
|
|
541
|
+
window.addEventListener("pointermove", o), window.addEventListener("pointerup", r), window.addEventListener("pointercancel", r);
|
|
537
542
|
}
|
|
538
543
|
armTouchDrag(t, e) {
|
|
539
|
-
const n = t.clientX, i = t.clientY,
|
|
540
|
-
this.gestureState.kind === "arming-touch-drag" && this.gestureState.pointerId ===
|
|
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();
|
|
541
546
|
}, D), s = window.setTimeout(() => {
|
|
542
|
-
if (!(this.gestureState.kind !== "arming-touch-drag" || this.gestureState.pointerId !==
|
|
547
|
+
if (!(this.gestureState.kind !== "arming-touch-drag" || this.gestureState.pointerId !== o)) {
|
|
543
548
|
this.cleanupTouchArming();
|
|
544
549
|
try {
|
|
545
550
|
navigator.vibrate?.(10);
|
|
546
551
|
} catch {
|
|
547
552
|
}
|
|
548
|
-
this.beginDragFromTouchArm(e, n, i,
|
|
553
|
+
this.beginDragFromTouchArm(e, n, i, o);
|
|
549
554
|
}
|
|
550
555
|
}, $);
|
|
551
556
|
this.gestureState = {
|
|
552
557
|
kind: "arming-touch-drag",
|
|
553
|
-
pointerId:
|
|
558
|
+
pointerId: o,
|
|
554
559
|
tileId: e.id,
|
|
555
560
|
startX: n,
|
|
556
561
|
startY: i,
|
|
557
562
|
timer: s,
|
|
558
|
-
pressingTimer:
|
|
563
|
+
pressingTimer: r
|
|
559
564
|
}, this.gestureKind = "arming-touch-drag";
|
|
560
565
|
const a = (c) => {
|
|
561
|
-
if (c.pointerId !==
|
|
566
|
+
if (c.pointerId !== o || this.gestureState.kind !== "arming-touch-drag") return;
|
|
562
567
|
const h = c.clientX - n, p = c.clientY - i;
|
|
563
568
|
Math.hypot(h, p) > A && (this.cleanupTouchArming(), window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", d));
|
|
564
569
|
}, d = (c) => {
|
|
565
|
-
c.pointerId ===
|
|
570
|
+
c.pointerId === o && (this.gestureState.kind === "arming-touch-drag" && this.cleanupTouchArming(), window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", d));
|
|
566
571
|
};
|
|
567
572
|
window.addEventListener("pointermove", a), window.addEventListener("pointerup", d), window.addEventListener("pointercancel", d);
|
|
568
573
|
}
|
|
@@ -573,9 +578,9 @@ class O extends z {
|
|
|
573
578
|
}
|
|
574
579
|
beginDragFromTouchArm(t, e, n, i) {
|
|
575
580
|
this.updateLayoutCache();
|
|
576
|
-
const
|
|
577
|
-
if (!
|
|
578
|
-
const
|
|
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);
|
|
579
584
|
this.gestureState = {
|
|
580
585
|
kind: "drag",
|
|
581
586
|
pointerId: i,
|
|
@@ -589,12 +594,12 @@ class O extends z {
|
|
|
589
594
|
this.updateLayoutCache();
|
|
590
595
|
const n = this.shadowRoot?.querySelector(".tile-grid");
|
|
591
596
|
if (!n) return;
|
|
592
|
-
const i = this.cellMetrics,
|
|
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);
|
|
593
598
|
this.gestureState = {
|
|
594
599
|
kind: "drag",
|
|
595
600
|
pointerId: t.pointerId,
|
|
596
601
|
tileId: e.id,
|
|
597
|
-
pointerOffset: { dx: t.clientX -
|
|
602
|
+
pointerOffset: { dx: t.clientX - r, dy: t.clientY - s },
|
|
598
603
|
currentRect: { ...e.position },
|
|
599
604
|
blocked: !1
|
|
600
605
|
}, this.gestureKind = "drag", this.lastPointerPosition = { x: t.clientX, y: t.clientY }, this.attachWindowListeners(), this.announceDragBegin(e), this.runPackerForCurrentGesture();
|
|
@@ -659,32 +664,32 @@ class O extends z {
|
|
|
659
664
|
const n = t.kind === "drag" ? this.computeDragRect(t, e) : this.computeResizeRect(t, e);
|
|
660
665
|
if (!n) return;
|
|
661
666
|
t.currentRect = n;
|
|
662
|
-
const i = this.effectiveColumnCount,
|
|
667
|
+
const i = this.effectiveColumnCount, o = v(
|
|
663
668
|
this.tiles.map((s) => ({ id: s.id, position: s.position, locked: !!s.disableMove })),
|
|
664
669
|
{ id: e.id, rect: n },
|
|
665
670
|
i
|
|
666
671
|
);
|
|
667
|
-
this.previewLayout =
|
|
668
|
-
const
|
|
669
|
-
t.blocked =
|
|
672
|
+
this.previewLayout = o.layout;
|
|
673
|
+
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();
|
|
670
675
|
}
|
|
671
676
|
computeDragRect(t, e) {
|
|
672
677
|
const n = this.shadowRoot?.querySelector(".tile-grid");
|
|
673
678
|
if (!n) return null;
|
|
674
|
-
const i = this.cellMetrics,
|
|
675
|
-
if (!
|
|
676
|
-
const s = n.getBoundingClientRect(), a =
|
|
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;
|
|
677
682
|
return {
|
|
678
|
-
colStart: Math.max(1, Math.min(c,
|
|
683
|
+
colStart: Math.max(1, Math.min(c, o - e.position.colSpan + 1)),
|
|
679
684
|
rowStart: Math.max(1, h),
|
|
680
685
|
colSpan: e.position.colSpan,
|
|
681
686
|
rowSpan: e.position.rowSpan
|
|
682
687
|
};
|
|
683
688
|
}
|
|
684
689
|
computeResizeRect(t, e) {
|
|
685
|
-
const n = this.cellMetrics, i = this.effectiveColumnCount,
|
|
686
|
-
if (!
|
|
687
|
-
const
|
|
690
|
+
const n = this.cellMetrics, i = this.effectiveColumnCount, o = this.lastPointerPosition;
|
|
691
|
+
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);
|
|
688
693
|
return {
|
|
689
694
|
colStart: e.position.colStart,
|
|
690
695
|
rowStart: e.position.rowStart,
|
|
@@ -701,15 +706,15 @@ class O extends z {
|
|
|
701
706
|
this.cleanupGesture();
|
|
702
707
|
return;
|
|
703
708
|
}
|
|
704
|
-
const n = new Map(this.tiles.map((
|
|
705
|
-
const s = e.find((a) => a.id ===
|
|
706
|
-
return s ? { ...
|
|
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;
|
|
707
712
|
});
|
|
708
|
-
this.tiles = i, e.forEach((
|
|
709
|
-
const s = n.get(
|
|
710
|
-
(!s || !this.positionsEqual(s,
|
|
713
|
+
this.tiles = i, e.forEach((r) => {
|
|
714
|
+
const s = n.get(r.id);
|
|
715
|
+
(!s || !this.positionsEqual(s, r.position)) && this.dispatchEvent(
|
|
711
716
|
new CustomEvent("tilepositionchange", {
|
|
712
|
-
detail: { id:
|
|
717
|
+
detail: { id: r.id, position: r.position },
|
|
713
718
|
bubbles: !1,
|
|
714
719
|
composed: !0
|
|
715
720
|
})
|
|
@@ -721,9 +726,9 @@ class O extends z {
|
|
|
721
726
|
composed: !0
|
|
722
727
|
})
|
|
723
728
|
);
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
t.kind === "drag" ? `Tile moved to row ${
|
|
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`
|
|
727
732
|
), this.cleanupGesture();
|
|
728
733
|
}
|
|
729
734
|
cancelGesture(t = "cancel") {
|
|
@@ -768,7 +773,11 @@ class O extends z {
|
|
|
768
773
|
if (n.kind === "idle") {
|
|
769
774
|
if (t.key === "m" || t.key === "M") {
|
|
770
775
|
if (e.disableMove && e.disableResize) return;
|
|
771
|
-
t.preventDefault(), this.keyboardState = {
|
|
776
|
+
t.preventDefault(), this.keyboardState = {
|
|
777
|
+
kind: "move",
|
|
778
|
+
tileId: e.id,
|
|
779
|
+
entryTiles: this.tiles.map((i) => ({ ...i, position: { ...i.position } }))
|
|
780
|
+
}, this.requestUpdate(), this.liveAnnouncer.announce(
|
|
772
781
|
"Move mode enabled. Use arrow keys to move, Shift with arrow keys to resize, Enter to commit, Escape to cancel."
|
|
773
782
|
);
|
|
774
783
|
return;
|
|
@@ -777,7 +786,15 @@ class O extends z {
|
|
|
777
786
|
}
|
|
778
787
|
if (n.tileId === e.id) {
|
|
779
788
|
if (t.key === "Escape" || t.key === "Enter") {
|
|
780
|
-
t.preventDefault()
|
|
789
|
+
t.preventDefault();
|
|
790
|
+
const i = n.kind === "move" ? n.entryTiles : null;
|
|
791
|
+
this.keyboardState = { kind: "idle" }, this.requestUpdate(), t.key === "Escape" && i && (this.tiles = i, this.requestUpdate(), this.dispatchEvent(
|
|
792
|
+
new CustomEvent("tilelayoutchange", {
|
|
793
|
+
detail: this.cloneSnapshot(i.map((o) => ({ id: o.id, position: o.position }))),
|
|
794
|
+
bubbles: !1,
|
|
795
|
+
composed: !0
|
|
796
|
+
})
|
|
797
|
+
)), this.liveAnnouncer.announce(t.key === "Enter" ? "Move committed." : "Move cancelled and reverted.");
|
|
781
798
|
return;
|
|
782
799
|
}
|
|
783
800
|
if (t.key.startsWith("Arrow")) {
|
|
@@ -794,12 +811,12 @@ class O extends z {
|
|
|
794
811
|
*/
|
|
795
812
|
handleFocusNavigation(t, e) {
|
|
796
813
|
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;
|
|
797
|
-
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),
|
|
798
|
-
if (
|
|
799
|
-
let
|
|
800
|
-
if (t.key === "Home" ?
|
|
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;
|
|
801
818
|
t.preventDefault();
|
|
802
|
-
const s = i[
|
|
819
|
+
const s = i[r];
|
|
803
820
|
return this.focusedTileId = s.id, this.requestUpdate(), queueMicrotask(() => {
|
|
804
821
|
this.shadowRoot?.querySelector(`.tile[data-tile-id="${s.id}"]`)?.focus();
|
|
805
822
|
}), !0;
|
|
@@ -817,14 +834,14 @@ class O extends z {
|
|
|
817
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;
|
|
818
835
|
}
|
|
819
836
|
applyKeyboardStep(t, e, n) {
|
|
820
|
-
const i = this.effectiveColumnCount,
|
|
837
|
+
const i = this.effectiveColumnCount, o = e === "ArrowLeft" ? -1 : e === "ArrowRight" ? 1 : 0, r = e === "ArrowUp" ? -1 : e === "ArrowDown" ? 1 : 0, s = n ? {
|
|
821
838
|
colStart: t.position.colStart,
|
|
822
839
|
rowStart: t.position.rowStart,
|
|
823
|
-
colSpan: Math.max(1, Math.min(t.position.colSpan +
|
|
824
|
-
rowSpan: Math.max(1, t.position.rowSpan +
|
|
840
|
+
colSpan: Math.max(1, Math.min(t.position.colSpan + o, i - t.position.colStart + 1)),
|
|
841
|
+
rowSpan: Math.max(1, t.position.rowSpan + r)
|
|
825
842
|
} : {
|
|
826
|
-
colStart: Math.max(1, Math.min(t.position.colStart +
|
|
827
|
-
rowStart: Math.max(1, t.position.rowStart +
|
|
843
|
+
colStart: Math.max(1, Math.min(t.position.colStart + o, i - t.position.colSpan + 1)),
|
|
844
|
+
rowStart: Math.max(1, t.position.rowStart + r),
|
|
828
845
|
colSpan: t.position.colSpan,
|
|
829
846
|
rowSpan: t.position.rowSpan
|
|
830
847
|
}, a = v(
|
|
@@ -859,9 +876,9 @@ class O extends z {
|
|
|
859
876
|
);
|
|
860
877
|
}
|
|
861
878
|
}
|
|
862
|
-
typeof customElements < "u" && !customElements.get("mp-tile-manager") && customElements.define("mp-tile-manager",
|
|
879
|
+
typeof customElements < "u" && !customElements.get("mp-tile-manager") && customElements.define("mp-tile-manager", G);
|
|
863
880
|
export {
|
|
864
|
-
|
|
881
|
+
G as MintTileManagerElement,
|
|
865
882
|
v as pack,
|
|
866
883
|
w as rectsOverlap
|
|
867
884
|
};
|