@mintplayer/web-components 2.1.1 → 2.3.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 (128) hide show
  1. package/a11y/index.mjs +26 -2
  2. package/a11y/src/dismiss-stack.d.ts +25 -0
  3. package/a11y/src/error-text.d.ts +41 -0
  4. package/a11y/src/focus-restore.d.ts +116 -0
  5. package/a11y/src/focus-trap.d.ts +69 -0
  6. package/a11y/src/form-associated.d.ts +48 -0
  7. package/a11y/src/host-aria.d.ts +154 -0
  8. package/a11y/src/index.d.ts +16 -0
  9. package/a11y/src/inert-regions.d.ts +52 -0
  10. package/a11y/src/live-announcer.d.ts +8 -0
  11. package/a11y/src/roving-focus.d.ts +118 -0
  12. package/a11y/src/testing/expect-idref-resolves.d.ts +31 -0
  13. package/a11y/src/testing/index.d.ts +1 -0
  14. package/accordion/index.d.ts +1 -0
  15. package/accordion/index.mjs +549 -0
  16. package/accordion/src/components/index.d.ts +3 -0
  17. package/accordion/src/components/mp-accordion-tab.d.ts +30 -0
  18. package/accordion/src/components/mp-accordion.d.ts +66 -0
  19. package/accordion/src/index.d.ts +3 -0
  20. package/accordion/src/styles/index.d.ts +1 -0
  21. package/calendar/index.mjs +1 -1
  22. package/calendar/src/mp-calendar.element.d.ts +2 -0
  23. package/carousel/index.d.ts +1 -0
  24. package/carousel/index.mjs +994 -0
  25. package/carousel/src/components/index.d.ts +1 -0
  26. package/carousel/src/components/mp-carousel.d.ts +58 -0
  27. package/carousel/src/index.d.ts +3 -0
  28. package/carousel/src/styles/index.d.ts +1 -0
  29. package/carousel/src/types/carousel.d.ts +10 -0
  30. package/carousel/src/types/index.d.ts +1 -0
  31. package/checkbox/index.mjs +1 -1
  32. package/checkbox/src/components/mp-checkbox.d.ts +59 -1
  33. package/chunks/focus-restore-DxuP1Oe2.mjs +94 -0
  34. package/chunks/focus-trap-DTOLJ5bb.mjs +121 -0
  35. package/chunks/form-associated-axmc5sY0.mjs +58 -0
  36. package/chunks/host-aria-WSGs7SPQ.mjs +152 -0
  37. package/chunks/inert-regions-DXCnn1LN.mjs +48 -0
  38. package/chunks/invalid-feedback.styles-he0JYrJm.mjs +11 -0
  39. package/chunks/{live-announcer-CZDTKulf.mjs → live-announcer-Bi0orG4n.mjs} +9 -9
  40. package/chunks/{mp-calendar.element-UC68iDbi.mjs → mp-calendar.element-u6uS31_j.mjs} +136 -105
  41. package/chunks/mp-checkbox-Ph2mMRGz.mjs +312 -0
  42. package/chunks/{mp-datatable-Bfw0KGkV.mjs → mp-datatable-BwTlh9A_.mjs} +265 -103
  43. package/chunks/{mp-pagination-BGxsawFL.mjs → mp-pagination-Dea75mD4.mjs} +25 -22
  44. package/chunks/mp-radio-BjW1HNSc.mjs +300 -0
  45. package/chunks/{mp-select-BDS1-YGn.mjs → mp-select-Ctu-v1-p.mjs} +163 -40
  46. package/chunks/{mp-splitter-C8cGCmac.mjs → mp-splitter-LszuRDbR.mjs} +53 -46
  47. package/chunks/{mp-tab-page-D1b4x-y2.mjs → mp-tab-page-CaCzX1ym.mjs} +46 -45
  48. package/chunks/{mp-timepicker.element-BwEiwX92.mjs → mp-timepicker.element-Bz393NDQ.mjs} +93 -86
  49. package/chunks/{mp-toggle-button-dLZNDUVz.mjs → mp-toggle-button-Kz6sIgBJ.mjs} +131 -37
  50. package/chunks/{mp-treeview-C48F63xb.mjs → mp-treeview-tkWu28iF.mjs} +67 -43
  51. package/chunks/overlay-controller-DPt13i8p.mjs +314 -0
  52. package/chunks/roving-focus-CrL9982a.mjs +129 -0
  53. package/code-snippet/index.mjs +21 -13
  54. package/code-snippet/src/mp-code-snippet.element.d.ts +6 -0
  55. package/datatable/index.mjs +1 -1
  56. package/datatable/src/components/mp-datatable.d.ts +50 -0
  57. package/datatable/src/types/index.d.ts +2 -0
  58. package/datatable/src/types/labels.d.ts +30 -0
  59. package/datepicker/index.mjs +45 -22
  60. package/datepicker/src/mp-datepicker.element.d.ts +30 -0
  61. package/datetime-picker/index.mjs +15 -9
  62. package/dock/index.mjs +365 -209
  63. package/dock/src/components/mint-dock-manager.element.d.ts +63 -3
  64. package/dropdown-menu/index.mjs +135 -90
  65. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +12 -3
  66. package/file-manager/index.mjs +279 -214
  67. package/file-manager/src/components/mp-file-manager.d.ts +22 -0
  68. package/file-manager/src/types/messages.d.ts +9 -0
  69. package/multi-range/index.mjs +26 -10
  70. package/multi-range/src/mint-multi-range.element.d.ts +7 -0
  71. package/navbar/index.mjs +53 -39
  72. package/navbar/src/components/mp-navbar.d.ts +1 -0
  73. package/otp-input/index.mjs +82 -48
  74. package/otp-input/src/mint-otp-input.element.d.ts +31 -3
  75. package/overlay/index.mjs +2 -258
  76. package/overlay/src/overlay-controller.d.ts +64 -4
  77. package/package.json +21 -1
  78. package/pagination/index.mjs +1 -1
  79. package/query-builder/index.mjs +117 -87
  80. package/query-builder/src/model/messages.d.ts +9 -0
  81. package/radio/index.mjs +2 -160
  82. package/radio/src/components/mp-radio.d.ts +58 -3
  83. package/radio-group/index.d.ts +1 -0
  84. package/radio-group/index.mjs +145 -0
  85. package/radio-group/src/components/mp-radio-group.d.ts +52 -0
  86. package/radio-group/src/index.d.ts +1 -0
  87. package/radio-group/src/styles/radio-group.styles.d.ts +2 -0
  88. package/ribbon/index.mjs +316 -304
  89. package/ribbon/src/mp-ribbon.element.d.ts +16 -0
  90. package/scheduler/index.mjs +219 -132
  91. package/scheduler/src/components/mp-scheduler.d.ts +3 -0
  92. package/scheduler/src/views/base-view.d.ts +23 -0
  93. package/select/index.mjs +1 -1
  94. package/select/src/components/mp-select.d.ts +60 -3
  95. package/shell/index.mjs +142 -31
  96. package/shell/src/components/mp-shell.d.ts +1 -0
  97. package/signature-pad/index.d.ts +1 -0
  98. package/signature-pad/index.mjs +230 -0
  99. package/signature-pad/src/index.d.ts +2 -0
  100. package/signature-pad/src/mp-signature-pad.element.d.ts +143 -0
  101. package/signature-pad/src/mp-signature-pad.element.template.d.ts +2 -0
  102. package/signature-pad/src/types/signature.d.ts +12 -0
  103. package/splitter/index.mjs +1 -1
  104. package/splitter/src/components/mp-splitter.d.ts +7 -0
  105. package/splitter/src/index.d.ts +1 -1
  106. package/swiper-core/index.d.ts +1 -0
  107. package/swiper-core/index.mjs +184 -0
  108. package/swiper-core/src/index-machine.d.ts +59 -0
  109. package/swiper-core/src/index.d.ts +4 -0
  110. package/swiper-core/src/keymap.d.ts +2 -0
  111. package/swiper-core/src/models/index.d.ts +1 -0
  112. package/swiper-core/src/models/types.d.ts +99 -0
  113. package/swiper-core/src/pointer-arbiter.d.ts +45 -0
  114. package/tab-control/index.mjs +1 -1
  115. package/tile-manager/index.mjs +110 -93
  116. package/timeline/index.mjs +138 -54
  117. package/timeline/src/components/mp-timeline.d.ts +15 -0
  118. package/timepicker/index.mjs +1 -1
  119. package/timepicker/src/mp-time-list.element.d.ts +13 -4
  120. package/timepicker/src/mp-timepicker.element.d.ts +29 -0
  121. package/toggle-button/index.mjs +1 -1
  122. package/toggle-button/src/components/mp-toggle-button.d.ts +32 -1
  123. package/tree-select/index.mjs +233 -121
  124. package/tree-select/src/components/mp-tree-select.d.ts +37 -0
  125. package/treeview/index.mjs +1 -1
  126. package/treeview/src/components/mp-treeview.d.ts +10 -1
  127. package/chunks/mp-checkbox-BokLL7BS.mjs +0 -211
  128. package/dropdown/src/styles/dropdown.styles.d.ts +0 -2
@@ -0,0 +1,99 @@
1
+ export type SwipeOrientation = 'horizontal' | 'vertical';
2
+ /**
3
+ * Semantic navigation intents. Input arbiters (pointer, wheel, keyboard) reduce
4
+ * raw input to these; the consumer routes them into an {@link IndexMachine}
5
+ * (or its own index logic — a scroll-snap consumer needs no machine at all).
6
+ */
7
+ export type SwipeIntent = 'previous' | 'next' | 'first' | 'last';
8
+ export interface PointerArbiterConfig {
9
+ orientation: SwipeOrientation;
10
+ /**
11
+ * Primary-axis movement (px) before the gesture locks onto its axis and the
12
+ * caller should start calling preventDefault(). 3px — deliberately small so
13
+ * the lock can engage on the first or second move event, before Firefox
14
+ * Android's APZ claims a downward gesture as pull-to-refresh.
15
+ */
16
+ swipeThresholdPx?: number;
17
+ /**
18
+ * How long (ms) a press must survive before it is treated as a drag rather
19
+ * than a tap. A release inside this window is reported as a tap and produces
20
+ * no drag events.
21
+ */
22
+ startDelayMs?: number;
23
+ }
24
+ export interface PointerArbiterCallbacks {
25
+ /** The press outlived the start delay: a drag is now in progress. */
26
+ onDragStart?(): void;
27
+ /** Live primary-axis delta from the drag origin, in px. */
28
+ onDragMove?(deltaPx: number): void;
29
+ /** The pointer lifted after a settled drag. */
30
+ onDragEnd?(deltaPx: number): void;
31
+ /** The pointer lifted inside the start-delay window. */
32
+ onTap?(): void;
33
+ }
34
+ export interface WheelArbiterConfig {
35
+ orientation: SwipeOrientation;
36
+ /** Accumulated primary-axis delta (px) that resolves to one intent. */
37
+ intentThresholdPx?: number;
38
+ /** Quiet period (ms) after an intent during which further deltas are ignored. */
39
+ cooldownMs?: number;
40
+ }
41
+ export interface WheelArbiterCallbacks {
42
+ onIntent?(intent: Extract<SwipeIntent, 'previous' | 'next'>): void;
43
+ }
44
+ /**
45
+ * A wheel/trackpad input arbiter: feed it wheel deltas, it emits at most one
46
+ * intent per physical gesture. `wheel(deltaPx)` returns `true` when the caller
47
+ * should preventDefault() (the arbiter owns the axis for this gesture).
48
+ */
49
+ export interface WheelArbiter {
50
+ wheel(deltaPx: number): boolean;
51
+ destroy(): void;
52
+ }
53
+ /**
54
+ * Handle to an in-flight transition, with the interruption contract every
55
+ * swipe UI needs: `finish()` jumps to the end state and MUST invoke the
56
+ * transition's `onDone`; `cancel()` abandons it and MUST NOT.
57
+ */
58
+ export interface TransitionHandle {
59
+ finish(): void;
60
+ cancel(): void;
61
+ }
62
+ /**
63
+ * What the machine needs from its environment. Positions are expressed as a
64
+ * unit-free ratio in slide units: ratio 0 = slide 0 at rest, 1.5 = halfway
65
+ * between slides 1 and 2. During a wrap transition the ratio transiently
66
+ * leaves [0, count-1] (e.g. `count` = the after-last wrap cell); the host maps
67
+ * logical ratios to physical positions (a transform, a scroll offset, …).
68
+ */
69
+ export interface IndexMachineHost {
70
+ /** Park the track at a position instantly (resting state or live drag). */
71
+ applyOffsetRatio(ratio: number): void;
72
+ /**
73
+ * Animate between two positions over `durationMs` (> 0 — the machine handles
74
+ * zero-duration moves itself). How the motion looks — a transform, a
75
+ * crossfade timed to match, … — is entirely the host's business.
76
+ */
77
+ runTransition(fromRatio: number, toRatio: number, durationMs: number, onDone: () => void): TransitionHandle;
78
+ }
79
+ export interface IndexMachineCallbacks {
80
+ /** The committed index changed (never fires for snap-backs or no-ops). */
81
+ onIndexChange?(index: number): void;
82
+ onAnimationStart?(): void;
83
+ onAnimationEnd?(): void;
84
+ }
85
+ export interface IndexMachineConfig {
86
+ /** Number of navigable slides (excluding any wrap cells the host renders). */
87
+ count: number;
88
+ /**
89
+ * Wrap-around at the edges. Enforced HERE, so every input path — buttons,
90
+ * keyboard, drag release — obeys the same rule.
91
+ */
92
+ wrap?: boolean;
93
+ /** Transition duration. The machine drops it to 0 under reduced motion. */
94
+ durationMs?: number;
95
+ /** Minimum drag distance (px) for a release to commit a slide change. */
96
+ minimumOffsetPx?: number;
97
+ /** Supplier consulted per transition; true → the move is instant. */
98
+ prefersReducedMotion?: () => boolean;
99
+ }
@@ -0,0 +1,45 @@
1
+ import { PointerArbiterCallbacks, PointerArbiterConfig } from './models';
2
+ /**
3
+ * Pointer-gesture arbiter: coordinates in, drag/tap semantics out.
4
+ *
5
+ * Never touches a DOM event — callers feed it (x, y) pairs from whatever input
6
+ * they listen to (touch, pointer, synthetic) and honour its boolean verdicts:
7
+ * `pointerMove`/`pointerUp` return `true` when the caller should
8
+ * `preventDefault()` (the gesture has locked onto this widget's axis and
9
+ * native scroll / pull-to-refresh must not run).
10
+ *
11
+ * The two constants encode hard-won behavior — see
12
+ * docs/prd/vertical-swipe-firefox-android.md:
13
+ * - 3px lock threshold with primary-dominates-perpendicular arbitration, so
14
+ * preventDefault() can fire before Firefox Android's APZ claims the gesture,
15
+ * while a 4px off-axis jitter still leaves native page scroll alone.
16
+ * - 20ms start delay so a tap settles without being recognised as a drag; a
17
+ * release inside the window is a tap and produces no drag events at all.
18
+ */
19
+ export declare class PointerArbiter {
20
+ private readonly callbacks;
21
+ private static readonly DEFAULT_THRESHOLD_PX;
22
+ private static readonly DEFAULT_START_DELAY_MS;
23
+ private readonly thresholdPx;
24
+ private readonly startDelayMs;
25
+ private orientation;
26
+ private origin;
27
+ private locked;
28
+ private dragging;
29
+ private lastDeltaPx;
30
+ private startTimer;
31
+ private destroyed;
32
+ constructor(config: PointerArbiterConfig, callbacks?: PointerArbiterCallbacks);
33
+ setOrientation(orientation: PointerArbiterConfig['orientation']): void;
34
+ /** `touch-action` the consumer should set on the gesture surface. */
35
+ get touchAction(): 'pan-x' | 'pan-y';
36
+ pointerDown(x: number, y: number): void;
37
+ /** Returns true when the caller should preventDefault() on this move event. */
38
+ pointerMove(x: number, y: number): boolean;
39
+ /** Returns true when the caller should preventDefault() on the end event. */
40
+ pointerUp(): boolean;
41
+ /** Abandon the gesture without emitting anything (e.g. pointercancel). */
42
+ abort(): void;
43
+ destroy(): void;
44
+ private reset;
45
+ }
@@ -1,4 +1,4 @@
1
- import { M as t, a as r, t as s } from "../chunks/mp-tab-page-D1b4x-y2.mjs";
1
+ import { M as t, a as r, t as s } from "../chunks/mp-tab-page-CaCzX1ym.mjs";
2
2
  export {
3
3
  t as MpTabControl,
4
4
  r as MpTabPage,
@@ -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-CZDTKulf.mjs";
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 } }, r = l.filter((u) => u.locked && u.id !== t.id).map((u) => ({ id: u.id, position: { ...u.position } }));
10
- if (r.some(
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, ...r], a = l.filter((u) => !u.locked && u.id !== t.id).slice().sort((u, m) => {
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, ...r, ...c].map((u) => [u.id, u.position])
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 o = R({ colSpan: n, rowSpan: i }, t, e);
40
- return o ? { id: l.id, position: o } : null;
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
- (o, s) => Math.max(o, s.position.rowStart + s.position.rowSpan - 1),
44
+ (r, s) => Math.max(r, s.position.rowStart + s.position.rowSpan - 1),
45
45
  0
46
- ) + l.rowSpan, r = e - l.colSpan + 1;
47
- if (r < 1) return null;
48
- for (let o = 1; o <= i; o++)
49
- for (let s = 0; s < r; 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: o, colStart: a, colSpan: l.colSpan, rowSpan: l.rowSpan },
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: o, colStart: a, colSpan: l.colSpan, rowSpan: l.rowSpan };
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: r } = M(l, t);
71
- return r ? k(i, t, e, n - 1) : i;
70
+ const { result: i, changed: o } = E(l, t);
71
+ return o ? k(i, t, e, n - 1) : i;
72
72
  }
73
- function M(l, t, e) {
74
- return l.slice().sort((i, r) => {
75
- const o = i.position.rowStart - r.position.rowStart;
76
- return o !== 0 ? o : i.position.colStart - r.position.colStart;
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, r) => {
79
- const o = [...t, ...i.result.filter((d) => d.id !== r.id)], s = E(r.position, o), a = s.rowStart !== r.position.rowStart;
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: r.id, position: s }],
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 E(l, t) {
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, G = 5;
323
- class O extends z {
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 r = e.get(i.id);
377
- return r ? this.renderTile(r, i.position) : b;
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, r = (n || i) && this.blocked, o = this.gestureKind === "arming-touch-drag" && this.activeTileId() === t.id, s = this.computeActiveTransform(t.id), a = this.cellMetrics, d = i && a.width > 0 ? {
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=${r ? "true" : "false"}
404
- data-pressing=${o ? "true" : "false"}
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, r = parseFloat(e.columnGap) || 0, o = parseFloat(e.rowGap) || 0, s = (n.width - (i - 1) * r) / i, a = parseFloat(e.gridAutoRows) || n.width / i;
457
- this.cellMetrics = { width: s, height: a, gapX: r, gapY: o };
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 r = i.getBoundingClientRect(), o = this.cellMetrics, s = e.currentRect, a = n.x - r.left - e.pointerOffset.dx, d = n.y - r.top - e.pointerOffset.dy, c = (s.colStart - 1) * (o.width + o.gapX), h = (s.rowStart - 1) * (o.height + o.gapY);
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 r = i.dataset.tileId;
507
- if (!r || r === n) return;
508
- const o = this.flipPreviousRects.get(r);
509
- if (!o) return;
510
- const s = i.getBoundingClientRect(), a = o.left - s.left, d = o.top - s.top;
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, r = (s) => {
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) >= G && (window.removeEventListener("pointermove", r), window.removeEventListener("pointerup", o), window.removeEventListener("pointercancel", o), this.beginDrag(s, e));
533
- }, o = (s) => {
534
- s.pointerId === t.pointerId && (window.removeEventListener("pointermove", r), window.removeEventListener("pointerup", o), window.removeEventListener("pointercancel", o));
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", r), window.addEventListener("pointerup", o), window.addEventListener("pointercancel", o);
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, r = t.pointerId, o = window.setTimeout(() => {
540
- this.gestureState.kind === "arming-touch-drag" && this.gestureState.pointerId === r && this.requestUpdate();
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 !== r)) {
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, r);
553
+ this.beginDragFromTouchArm(e, n, i, o);
549
554
  }
550
555
  }, $);
551
556
  this.gestureState = {
552
557
  kind: "arming-touch-drag",
553
- pointerId: r,
558
+ pointerId: o,
554
559
  tileId: e.id,
555
560
  startX: n,
556
561
  startY: i,
557
562
  timer: s,
558
- pressingTimer: o
563
+ pressingTimer: r
559
564
  }, this.gestureKind = "arming-touch-drag";
560
565
  const a = (c) => {
561
- if (c.pointerId !== r || this.gestureState.kind !== "arming-touch-drag") return;
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 === r && (this.gestureState.kind === "arming-touch-drag" && this.cleanupTouchArming(), window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", d));
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 r = this.shadowRoot?.querySelector(".tile-grid");
577
- if (!r) return;
578
- const o = this.cellMetrics, s = r.getBoundingClientRect(), a = s.left + (t.position.colStart - 1) * (o.width + o.gapX), d = s.top + (t.position.rowStart - 1) * (o.height + o.gapY);
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, r = n.getBoundingClientRect(), o = r.left + (e.position.colStart - 1) * (i.width + i.gapX), s = r.top + (e.position.rowStart - 1) * (i.height + i.gapY);
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 - o, dy: t.clientY - s },
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, r = v(
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 = r.layout;
668
- const o = t.blocked;
669
- t.blocked = r.blocked, r.blocked && !o && this.liveAnnouncer.announce("Move blocked by a locked tile."), this.blocked = r.blocked, this.requestUpdate();
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, r = this.effectiveColumnCount, o = this.lastPointerPosition;
675
- if (!o) return null;
676
- const s = n.getBoundingClientRect(), a = o.x - s.left - t.pointerOffset.dx, d = o.y - s.top - t.pointerOffset.dy, c = Math.round(a / (i.width + i.gapX)) + 1, h = Math.round(d / (i.height + i.gapY)) + 1;
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, r - e.position.colSpan + 1)),
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, r = this.lastPointerPosition;
686
- if (!r) return null;
687
- const o = r.x - t.startPointer.x, s = r.y - t.startPointer.y, a = Math.round(o / (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);
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((o) => [o.id, o.position])), i = this.tiles.map((o) => {
705
- const s = e.find((a) => a.id === o.id);
706
- return s ? { ...o, position: s.position } : o;
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((o) => {
709
- const s = n.get(o.id);
710
- (!s || !this.positionsEqual(s, o.position)) && this.dispatchEvent(
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: o.id, position: o.position },
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 r = e.find((o) => o.id === t.tileId);
725
- r && this.liveAnnouncer.announce(
726
- t.kind === "drag" ? `Tile moved to row ${r.position.rowStart}, column ${r.position.colStart}` : `Tile resized to ${r.position.colSpan} columns by ${r.position.rowSpan} rows`
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 = { kind: "move", tileId: e.id }, this.liveAnnouncer.announce(
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(), this.keyboardState = { kind: "idle" }, this.liveAnnouncer.announce(t.key === "Enter" ? "Move committed." : "Move cancelled.");
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), r = i.findIndex((a) => a.id === e.id);
798
- if (r < 0) return !1;
799
- let o = r;
800
- if (t.key === "Home" ? o = 0 : t.key === "End" ? o = i.length - 1 : t.key === "ArrowRight" || t.key === "ArrowDown" ? o = (r + 1) % i.length : o = (r - 1 + i.length) % i.length, o === r) return !0;
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[o];
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, r = e === "ArrowLeft" ? -1 : e === "ArrowRight" ? 1 : 0, o = e === "ArrowUp" ? -1 : e === "ArrowDown" ? 1 : 0, s = n ? {
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 + r, i - t.position.colStart + 1)),
824
- rowSpan: Math.max(1, t.position.rowSpan + o)
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 + r, i - t.position.colSpan + 1)),
827
- rowStart: Math.max(1, t.position.rowStart + o),
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", O);
879
+ typeof customElements < "u" && !customElements.get("mp-tile-manager") && customElements.define("mp-tile-manager", G);
863
880
  export {
864
- O as MintTileManagerElement,
881
+ G as MintTileManagerElement,
865
882
  v as pack,
866
883
  w as rectsOverlap
867
884
  };