@mintplayer/web-components 1.0.0 → 1.1.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 (236) hide show
  1. package/a11y/index.mjs +2 -56
  2. package/calendar/index.mjs +2 -363
  3. package/checkbox/index.mjs +4 -0
  4. package/checkbox/src/components/index.d.ts +2 -0
  5. package/checkbox/src/components/mp-checkbox.d.ts +69 -0
  6. package/checkbox/src/index.d.ts +2 -0
  7. package/chunks/color-C4VT0EL7.mjs +847 -0
  8. package/chunks/form-check.styles-jBlHetYX.mjs +151 -0
  9. package/chunks/live-announcer-CZDTKulf.mjs +58 -0
  10. package/chunks/mp-calendar.element-UC68iDbi.mjs +365 -0
  11. package/chunks/mp-checkbox-BokLL7BS.mjs +211 -0
  12. package/chunks/mp-datatable-CpAu8JJD.mjs +750 -0
  13. package/chunks/mp-pagination-BGxsawFL.mjs +326 -0
  14. package/chunks/mp-select-BDS1-YGn.mjs +254 -0
  15. package/chunks/mp-splitter-C8cGCmac.mjs +633 -0
  16. package/chunks/mp-tab-page-D1b4x-y2.mjs +414 -0
  17. package/chunks/mp-timepicker.element-BwEiwX92.mjs +428 -0
  18. package/chunks/mp-toggle-button-dLZNDUVz.mjs +534 -0
  19. package/chunks/mp-treeview-Bfq4_IVW.mjs +474 -0
  20. package/code-snippet/index.mjs +16 -13
  21. package/datatable/index.mjs +7 -0
  22. package/datatable/src/components/index.d.ts +2 -0
  23. package/datatable/src/components/mp-datatable.d.ts +156 -0
  24. package/datatable/src/index.d.ts +6 -0
  25. package/datatable/src/sort/compute-next-sort.d.ts +18 -0
  26. package/datatable/src/sort/index.d.ts +3 -0
  27. package/datatable/src/sort/sort-rows.d.ts +6 -0
  28. package/datatable/src/styles/datatable.styles.d.ts +2 -0
  29. package/datatable/src/styles/index.d.ts +1 -0
  30. package/datatable/src/types/column-def.d.ts +30 -0
  31. package/datatable/src/types/index.d.ts +1 -0
  32. package/datepicker/index.mjs +240 -0
  33. package/datepicker/src/index.d.ts +1 -0
  34. package/datepicker/src/mp-datepicker.element.d.ts +94 -0
  35. package/datepicker/src/mp-datepicker.element.template.d.ts +2 -0
  36. package/datetime-picker/index.mjs +427 -0
  37. package/datetime-picker/src/index.d.ts +1 -0
  38. package/datetime-picker/src/mp-datetime-picker.element.d.ts +174 -0
  39. package/datetime-picker/src/mp-datetime-picker.element.template.d.ts +2 -0
  40. package/dock/index.mjs +2402 -0
  41. package/dock/src/components/index.d.ts +1 -0
  42. package/dock/src/components/mint-dock-manager.element.d.ts +313 -0
  43. package/dock/src/components/mint-dock-manager.element.template.d.ts +2 -0
  44. package/dock/src/index.d.ts +2 -0
  45. package/dock/src/types/dock-layout.d.ts +65 -0
  46. package/dock/src/types/index.d.ts +1 -0
  47. package/file-manager/index.mjs +1263 -0
  48. package/file-manager/src/components/index.d.ts +2 -0
  49. package/file-manager/src/components/mp-file-manager.d.ts +320 -0
  50. package/file-manager/src/index.d.ts +5 -0
  51. package/file-manager/src/styles/file-manager.styles.d.ts +2 -0
  52. package/file-manager/src/styles/index.d.ts +1 -0
  53. package/file-manager/src/types/file-system-node.d.ts +24 -0
  54. package/file-manager/src/types/index.d.ts +3 -0
  55. package/file-manager/src/types/messages.d.ts +43 -0
  56. package/multi-range/index.mjs +407 -0
  57. package/multi-range/src/index.d.ts +2 -0
  58. package/multi-range/src/mint-multi-range.element.d.ts +124 -0
  59. package/multi-range/src/mint-multi-range.element.template.d.ts +2 -0
  60. package/multi-range/src/types/multi-range-orientation.d.ts +1 -0
  61. package/otp-input/index.mjs +362 -0
  62. package/otp-input/src/index.d.ts +4 -0
  63. package/otp-input/src/mint-otp-input.element.d.ts +134 -0
  64. package/otp-input/src/mint-otp-input.element.template.d.ts +2 -0
  65. package/otp-input/src/types/otp-input-case.d.ts +1 -0
  66. package/otp-input/src/types/otp-input-size.d.ts +1 -0
  67. package/otp-input/src/types/otp-input-type.d.ts +1 -0
  68. package/overlay/index.mjs +260 -0
  69. package/overlay/src/index.d.ts +2 -0
  70. package/overlay/src/overlay-controller.d.ts +205 -0
  71. package/package.json +1 -1
  72. package/pagination/index.mjs +5 -0
  73. package/pagination/src/components/index.d.ts +2 -0
  74. package/pagination/src/components/mp-pagination.d.ts +95 -0
  75. package/pagination/src/index.d.ts +2 -0
  76. package/pagination/src/styles/index.d.ts +1 -0
  77. package/pagination/src/styles/pagination.styles.d.ts +2 -0
  78. package/query-builder/index.mjs +3720 -0
  79. package/query-builder/src/context.d.ts +14 -0
  80. package/query-builder/src/dnd/drag-controller.d.ts +69 -0
  81. package/query-builder/src/index.d.ts +23 -0
  82. package/query-builder/src/model/default-tree.d.ts +7 -0
  83. package/query-builder/src/model/editor.d.ts +15 -0
  84. package/query-builder/src/model/errors.d.ts +6 -0
  85. package/query-builder/src/model/expression.d.ts +22 -0
  86. package/query-builder/src/model/field-def.d.ts +17 -0
  87. package/query-builder/src/model/messages.d.ts +17 -0
  88. package/query-builder/src/model/operator-overrides.d.ts +21 -0
  89. package/query-builder/src/model/operators.d.ts +8 -0
  90. package/query-builder/src/model/saved-query.d.ts +6 -0
  91. package/query-builder/src/model/sort.d.ts +9 -0
  92. package/query-builder/src/model/tree-ops.d.ts +56 -0
  93. package/query-builder/src/mp-query-builder.element.d.ts +158 -0
  94. package/query-builder/src/mp-query-builder.element.template.d.ts +2 -0
  95. package/query-builder/src/mp-query-condition.element.d.ts +44 -0
  96. package/query-builder/src/mp-query-condition.element.template.d.ts +2 -0
  97. package/query-builder/src/mp-query-group.element.d.ts +52 -0
  98. package/query-builder/src/mp-query-group.element.template.d.ts +2 -0
  99. package/query-builder/src/mp-query-subquery.element.d.ts +37 -0
  100. package/query-builder/src/mp-query-subquery.element.template.d.ts +2 -0
  101. package/query-builder/src/preview/render-expression.d.ts +23 -0
  102. package/query-builder/src/value-editors/builtin-editors.d.ts +6 -0
  103. package/query-builder/src/visitor/visit-tree.d.ts +29 -0
  104. package/query-builder/src/visitor/visitor-types.d.ts +15 -0
  105. package/radio/index.mjs +162 -0
  106. package/radio/src/components/index.d.ts +2 -0
  107. package/radio/src/components/mp-radio.d.ts +63 -0
  108. package/radio/src/index.d.ts +2 -0
  109. package/ribbon/index.mjs +3151 -0
  110. package/ribbon/src/index.d.ts +10 -0
  111. package/ribbon/src/items/index.d.ts +15 -0
  112. package/ribbon/src/items/mp-ribbon-button.element.d.ts +10 -0
  113. package/ribbon/src/items/mp-ribbon-checkbox.element.d.ts +11 -0
  114. package/ribbon/src/items/mp-ribbon-color-picker.element.d.ts +12 -0
  115. package/ribbon/src/items/mp-ribbon-combobox.element.d.ts +19 -0
  116. package/ribbon/src/items/mp-ribbon-dropdown-button.element.d.ts +16 -0
  117. package/ribbon/src/items/mp-ribbon-gallery-item.element.d.ts +15 -0
  118. package/ribbon/src/items/mp-ribbon-gallery.element.d.ts +11 -0
  119. package/ribbon/src/items/mp-ribbon-group-button.element.d.ts +18 -0
  120. package/ribbon/src/items/mp-ribbon-item-base.d.ts +68 -0
  121. package/ribbon/src/items/mp-ribbon-menu-item.element.d.ts +13 -0
  122. package/ribbon/src/items/mp-ribbon-menu-separator.element.d.ts +6 -0
  123. package/ribbon/src/items/mp-ribbon-split-button.element.d.ts +23 -0
  124. package/ribbon/src/items/mp-ribbon-template-item.element.d.ts +12 -0
  125. package/ribbon/src/items/mp-ribbon-toggle-button.element.d.ts +12 -0
  126. package/ribbon/src/mp-quick-access-toolbar.element.d.ts +35 -0
  127. package/ribbon/src/mp-ribbon-contextual-tab-set.element.d.ts +18 -0
  128. package/ribbon/src/mp-ribbon-group.element.d.ts +59 -0
  129. package/ribbon/src/mp-ribbon-tab.element.d.ts +72 -0
  130. package/ribbon/src/mp-ribbon.element.d.ts +211 -0
  131. package/ribbon/src/types/ribbon.types.d.ts +4 -0
  132. package/scheduler/index.mjs +3567 -0
  133. package/scheduler/src/components/mp-scheduler.d.ts +238 -0
  134. package/scheduler/src/drag/drag-manager.d.ts +90 -0
  135. package/scheduler/src/drag/drag-preview.d.ts +42 -0
  136. package/scheduler/src/drag/drag-state-machine.d.ts +102 -0
  137. package/scheduler/src/drag/drag-types.d.ts +104 -0
  138. package/scheduler/src/drag/index.d.ts +4 -0
  139. package/scheduler/src/events/event-types.d.ts +58 -0
  140. package/scheduler/src/events/index.d.ts +2 -0
  141. package/scheduler/src/events/scheduler-event-emitter.d.ts +52 -0
  142. package/scheduler/src/index.d.ts +6 -0
  143. package/scheduler/src/input/index.d.ts +2 -0
  144. package/scheduler/src/input/input-handler.d.ts +105 -0
  145. package/scheduler/src/input/pointer-event.d.ts +39 -0
  146. package/scheduler/src/state/scheduler-state.d.ts +189 -0
  147. package/scheduler/src/styles/scheduler.styles.d.ts +2 -0
  148. package/scheduler/src/views/base-view.d.ts +87 -0
  149. package/scheduler/src/views/day-view.d.ts +25 -0
  150. package/scheduler/src/views/index.d.ts +6 -0
  151. package/scheduler/src/views/month-view.d.ts +27 -0
  152. package/scheduler/src/views/timeline-view.d.ts +23 -0
  153. package/scheduler/src/views/week-view.d.ts +28 -0
  154. package/scheduler/src/views/year-view.d.ts +25 -0
  155. package/scheduler-core/index.mjs +174 -0
  156. package/scheduler-core/src/index.d.ts +3 -0
  157. package/scheduler-core/src/models/drag-state.d.ts +43 -0
  158. package/scheduler-core/src/models/event.d.ts +111 -0
  159. package/scheduler-core/src/models/events.d.ts +108 -0
  160. package/scheduler-core/src/models/index.d.ts +7 -0
  161. package/scheduler-core/src/models/options.d.ts +88 -0
  162. package/scheduler-core/src/models/resource.d.ts +58 -0
  163. package/scheduler-core/src/models/time-slot.d.ts +31 -0
  164. package/scheduler-core/src/models/types.d.ts +20 -0
  165. package/scheduler-core/src/services/date.service.d.ts +140 -0
  166. package/scheduler-core/src/services/index.d.ts +4 -0
  167. package/scheduler-core/src/services/position.service.d.ts +35 -0
  168. package/scheduler-core/src/services/resource.service.d.ts +83 -0
  169. package/scheduler-core/src/services/timeline.service.d.ts +103 -0
  170. package/scheduler-core/src/utils/color.d.ts +24 -0
  171. package/scheduler-core/src/utils/dom.d.ts +54 -0
  172. package/scheduler-core/src/utils/id.d.ts +16 -0
  173. package/scheduler-core/src/utils/index.d.ts +3 -0
  174. package/select/index.mjs +4 -0
  175. package/select/src/components/index.d.ts +2 -0
  176. package/select/src/components/mp-select.d.ts +82 -0
  177. package/select/src/index.d.ts +2 -0
  178. package/splitter/index.mjs +10 -0
  179. package/splitter/src/components/index.d.ts +2 -0
  180. package/splitter/src/components/mp-splitter.d.ts +109 -0
  181. package/splitter/src/index.d.ts +11 -0
  182. package/splitter/src/input/index.d.ts +4 -0
  183. package/splitter/src/input/input-handler.d.ts +36 -0
  184. package/splitter/src/input/pointer-event.d.ts +9 -0
  185. package/splitter/src/managers/index.d.ts +2 -0
  186. package/splitter/src/managers/resize-manager.d.ts +13 -0
  187. package/splitter/src/state/index.d.ts +2 -0
  188. package/splitter/src/state/splitter-state.d.ts +24 -0
  189. package/splitter/src/styles/index.d.ts +1 -0
  190. package/splitter/src/styles/splitter.styles.d.ts +2 -0
  191. package/splitter/src/types/direction.d.ts +1 -0
  192. package/splitter/src/types/index.d.ts +5 -0
  193. package/splitter/src/types/panel-info.d.ts +6 -0
  194. package/splitter/src/types/point.d.ts +4 -0
  195. package/splitter/src/types/resize-operation.d.ts +13 -0
  196. package/tab-control/index.mjs +6 -0
  197. package/tab-control/src/components/index.d.ts +3 -0
  198. package/tab-control/src/components/mp-tab-control.d.ts +50 -0
  199. package/tab-control/src/components/mp-tab-page.d.ts +35 -0
  200. package/tab-control/src/index.d.ts +4 -0
  201. package/tab-control/src/styles/index.d.ts +1 -0
  202. package/tab-control/src/styles/tab-control.styles.d.ts +2 -0
  203. package/tab-control/src/types/index.d.ts +1 -0
  204. package/tab-control/src/types/tabs-position.d.ts +1 -0
  205. package/tile-manager/index.mjs +867 -0
  206. package/tile-manager/src/components/index.d.ts +2 -0
  207. package/tile-manager/src/components/mint-tile-manager.element.d.ts +204 -0
  208. package/tile-manager/src/components/mint-tile-manager.element.template.d.ts +2 -0
  209. package/tile-manager/src/index.d.ts +4 -0
  210. package/tile-manager/src/types/grid-rect.d.ts +12 -0
  211. package/tile-manager/src/types/index.d.ts +3 -0
  212. package/tile-manager/src/types/tile-layout-snapshot.d.ts +15 -0
  213. package/tile-manager/src/types/tile-position.d.ts +10 -0
  214. package/tile-manager/src/utils/index.d.ts +1 -0
  215. package/tile-manager/src/utils/pack.d.ts +24 -0
  216. package/timepicker/index.mjs +5 -0
  217. package/timepicker/src/index.d.ts +2 -0
  218. package/timepicker/src/mp-time-list.element.d.ts +76 -0
  219. package/timepicker/src/mp-time-list.element.template.d.ts +2 -0
  220. package/timepicker/src/mp-timepicker.element.d.ts +87 -0
  221. package/timepicker/src/mp-timepicker.element.template.d.ts +2 -0
  222. package/toggle-button/index.mjs +5 -0
  223. package/toggle-button/src/components/index.d.ts +2 -0
  224. package/toggle-button/src/components/mp-toggle-button.d.ts +50 -0
  225. package/toggle-button/src/index.d.ts +3 -0
  226. package/toggle-button/src/styles/index.d.ts +1 -0
  227. package/toggle-button/src/styles/toggle-button.styles.d.ts +2 -0
  228. package/treeview/index.mjs +5 -0
  229. package/treeview/src/components/index.d.ts +2 -0
  230. package/treeview/src/components/mp-treeview.d.ts +113 -0
  231. package/treeview/src/index.d.ts +4 -0
  232. package/treeview/src/styles/index.d.ts +1 -0
  233. package/treeview/src/styles/treeview.styles.d.ts +2 -0
  234. package/treeview/src/types/index.d.ts +1 -0
  235. package/treeview/src/types/tree-node.d.ts +14 -0
  236. package/custom-elements.json +0 -1774
@@ -0,0 +1,867 @@
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";
3
+ function w(l, t) {
4
+ return l.colStart < t.colStart + t.colSpan && t.colStart < l.colStart + l.colSpan && l.rowStart < t.rowStart + t.rowSpan && t.rowStart < l.rowStart + l.rowSpan;
5
+ }
6
+ function v(l, t, e) {
7
+ if (!l.find((u) => u.id === t.id))
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(
11
+ (u) => w(u.position, i.position)
12
+ ))
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) => {
15
+ const g = u.position.rowStart - m.position.rowStart;
16
+ return g !== 0 ? g : u.position.colStart - m.position.colStart;
17
+ }), d = a.reduce((u, m) => {
18
+ const g = [...s, ...u], S = C(m, g, e);
19
+ return S ? [...u, S] : u;
20
+ }, []);
21
+ if (d.length !== a.length)
22
+ return { layout: y(l), blocked: !0 };
23
+ const c = T(d, s, e), h = new Map(
24
+ [i, ...r, ...c].map((u) => [u.id, u.position])
25
+ );
26
+ return { layout: l.map((u) => ({
27
+ id: u.id,
28
+ position: h.get(u.id) ?? { ...u.position }
29
+ })), blocked: !1 };
30
+ }
31
+ function y(l) {
32
+ return l.map((t) => ({ id: t.id, position: { ...t.position } }));
33
+ }
34
+ function C(l, t, e) {
35
+ const { colSpan: n, rowSpan: i } = l.position;
36
+ if (n > e) return null;
37
+ if (!t.some((s) => w(l.position, s.position)))
38
+ return { id: l.id, position: { ...l.position } };
39
+ const o = R({ colSpan: n, rowSpan: i }, t, e);
40
+ return o ? { id: l.id, position: o } : null;
41
+ }
42
+ function R(l, t, e) {
43
+ const i = t.reduce(
44
+ (o, s) => Math.max(o, s.position.rowStart + s.position.rowSpan - 1),
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++) {
50
+ const a = s + 1;
51
+ let d = !1;
52
+ for (let c = 0; c < t.length; c++)
53
+ if (w(
54
+ { rowStart: o, colStart: a, colSpan: l.colSpan, rowSpan: l.rowSpan },
55
+ t[c].position
56
+ )) {
57
+ d = !0;
58
+ break;
59
+ }
60
+ if (!d)
61
+ return { rowStart: o, colStart: a, colSpan: l.colSpan, rowSpan: l.rowSpan };
62
+ }
63
+ return null;
64
+ }
65
+ function T(l, t, e) {
66
+ return k(l, t, e, 10);
67
+ }
68
+ function k(l, t, e, n) {
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;
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;
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;
80
+ return {
81
+ result: [...i.result, { id: r.id, position: s }],
82
+ changed: i.changed || a
83
+ };
84
+ },
85
+ { result: [], changed: !1 }
86
+ );
87
+ }
88
+ function E(l, t) {
89
+ if (l.rowStart <= 1) return l;
90
+ for (let e = 1; e < l.rowStart; e++) {
91
+ let n = !1;
92
+ for (let i = 0; i < t.length; i++)
93
+ if (w({ ...l, rowStart: e }, t[i].position)) {
94
+ n = !0;
95
+ break;
96
+ }
97
+ if (!n) return { ...l, rowStart: e };
98
+ }
99
+ return l;
100
+ }
101
+ f`<!-- Tile shells are rendered dynamically by render(). This file exists so the
102
+ codegen-wc target produces a \`styles\` export from the sibling .scss; the
103
+ \`template\` export it generates is intentionally unused. -->`;
104
+ const P = x(`:host {
105
+ display: block;
106
+ position: relative;
107
+ box-sizing: border-box;
108
+ width: 100%;
109
+ contain: layout paint style;
110
+ --bs-tile-radius: 0.5rem;
111
+ --bs-tile-bg: var(--bs-body-bg, #fff);
112
+ --bs-tile-border: var(--bs-border-color, #dee2e6);
113
+ --bs-tile-shadow: var(--bs-box-shadow-sm, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075));
114
+ --bs-tile-handle-color: var(--bs-secondary, #6c757d);
115
+ --bs-tile-blocked-color: var(--bs-danger, #dc3545);
116
+ }
117
+
118
+ .tile-grid {
119
+ display: grid;
120
+ grid-auto-rows: var(--mp-tile-row-height, 8rem);
121
+ gap: var(--mp-tile-gap, 0.5rem);
122
+ width: 100%;
123
+ position: relative;
124
+ }
125
+
126
+ .tile {
127
+ position: relative;
128
+ display: flex;
129
+ flex-direction: column;
130
+ background: var(--bs-tile-bg);
131
+ border: 1px solid var(--bs-tile-border);
132
+ border-radius: var(--bs-tile-radius);
133
+ box-shadow: var(--bs-tile-shadow);
134
+ overflow: hidden;
135
+ min-width: 0;
136
+ min-height: 0;
137
+ transition: transform 150ms cubic-bezier(0.2, 0, 0, 1);
138
+ will-change: transform;
139
+ }
140
+
141
+ .tile[data-dragging=true] {
142
+ z-index: 5;
143
+ cursor: grabbing;
144
+ box-shadow: var(--bs-box-shadow, 0 0.5rem 1rem rgba(0, 0, 0, 0.15));
145
+ transition: none;
146
+ }
147
+
148
+ .tile[data-resizing=true] {
149
+ z-index: 4;
150
+ transition: width 150ms cubic-bezier(0.2, 0, 0, 1), height 150ms cubic-bezier(0.2, 0, 0, 1);
151
+ }
152
+
153
+ .tile[data-blocked=true] {
154
+ outline: 2px solid var(--bs-tile-blocked-color);
155
+ outline-offset: -2px;
156
+ animation: tile-shake 200ms ease-in-out;
157
+ }
158
+
159
+ @keyframes tile-shake {
160
+ 0%, 100% {
161
+ transform: translateX(0);
162
+ }
163
+ 25% {
164
+ transform: translateX(-3px);
165
+ }
166
+ 75% {
167
+ transform: translateX(3px);
168
+ }
169
+ }
170
+ .tile[data-pressing=true] {
171
+ filter: brightness(0.96);
172
+ transition: filter 100ms ease-out;
173
+ }
174
+
175
+ .tile__header-shell {
176
+ flex: 0 0 auto;
177
+ user-select: none;
178
+ -webkit-user-select: none;
179
+ -webkit-touch-callout: none;
180
+ cursor: grab;
181
+ }
182
+
183
+ .tile__header-shell ::slotted(*) {
184
+ display: flex;
185
+ align-items: center;
186
+ gap: 0.5rem;
187
+ padding: 0.5rem 0.75rem;
188
+ font-size: 0.875rem;
189
+ font-weight: 500;
190
+ color: var(--bs-body-color, inherit);
191
+ background: linear-gradient(to bottom, rgba(var(--bs-primary-rgb, 13, 110, 253), 0.1), rgba(var(--bs-primary-rgb, 13, 110, 253), 0.04));
192
+ border-bottom: 1px solid var(--bs-border-color, #dee2e6);
193
+ overflow: hidden;
194
+ text-overflow: ellipsis;
195
+ white-space: nowrap;
196
+ touch-action: none;
197
+ user-select: none;
198
+ -webkit-user-select: none;
199
+ -webkit-touch-callout: none;
200
+ }
201
+
202
+ .tile[data-drag-mode=off] .tile__header-shell,
203
+ .tile[data-locked-move=true] .tile__header-shell {
204
+ cursor: default;
205
+ }
206
+
207
+ .tile__content-shell {
208
+ flex: 1 1 auto;
209
+ min-width: 0;
210
+ min-height: 0;
211
+ overflow: auto;
212
+ }
213
+
214
+ .tile__resize-side,
215
+ .tile__resize-bottom,
216
+ .tile__resize-corner {
217
+ position: absolute;
218
+ z-index: 2;
219
+ background: transparent;
220
+ touch-action: none;
221
+ -webkit-user-select: none;
222
+ user-select: none;
223
+ opacity: 0;
224
+ transition: opacity 120ms ease-out;
225
+ }
226
+
227
+ .tile:hover .tile__resize-side,
228
+ .tile:hover .tile__resize-bottom,
229
+ .tile:hover .tile__resize-corner,
230
+ :host([resize-mode=always]) .tile__resize-side,
231
+ :host([resize-mode=always]) .tile__resize-bottom,
232
+ :host([resize-mode=always]) .tile__resize-corner {
233
+ opacity: 1;
234
+ }
235
+
236
+ @media (pointer: coarse) {
237
+ .tile__resize-side,
238
+ .tile__resize-bottom,
239
+ .tile__resize-corner {
240
+ opacity: 1;
241
+ }
242
+ }
243
+ .tile__resize-side {
244
+ right: -2px;
245
+ top: 25%;
246
+ bottom: 25%;
247
+ width: 6px;
248
+ cursor: ew-resize;
249
+ }
250
+
251
+ .tile__resize-bottom {
252
+ left: 25%;
253
+ right: 25%;
254
+ bottom: -2px;
255
+ height: 6px;
256
+ cursor: ns-resize;
257
+ }
258
+
259
+ .tile__resize-corner {
260
+ right: -2px;
261
+ bottom: -2px;
262
+ width: 14px;
263
+ height: 14px;
264
+ cursor: nwse-resize;
265
+ }
266
+
267
+ .tile__resize-corner::before {
268
+ content: "";
269
+ position: absolute;
270
+ right: 3px;
271
+ bottom: 3px;
272
+ width: 8px;
273
+ height: 8px;
274
+ border-right: 2px solid var(--bs-tile-handle-color);
275
+ border-bottom: 2px solid var(--bs-tile-handle-color);
276
+ border-bottom-right-radius: 2px;
277
+ }
278
+
279
+ :host([resize-mode=off]) .tile__resize-side,
280
+ :host([resize-mode=off]) .tile__resize-bottom,
281
+ :host([resize-mode=off]) .tile__resize-corner {
282
+ display: none;
283
+ }
284
+
285
+ .tile[data-locked-resize=true] .tile__resize-side,
286
+ .tile[data-locked-resize=true] .tile__resize-bottom,
287
+ .tile[data-locked-resize=true] .tile__resize-corner {
288
+ display: none;
289
+ }
290
+
291
+ .tile-grid__live-region,
292
+ .tile-grid__sr-only {
293
+ position: absolute;
294
+ width: 1px;
295
+ height: 1px;
296
+ margin: -1px;
297
+ padding: 0;
298
+ overflow: hidden;
299
+ clip: rect(0, 0, 0, 0);
300
+ white-space: nowrap;
301
+ border: 0;
302
+ }
303
+
304
+ @media (prefers-reduced-motion: reduce) {
305
+ .tile {
306
+ transition: none !important;
307
+ }
308
+ .tile[data-blocked=true] {
309
+ animation: none;
310
+ }
311
+ }
312
+ :host(:focus-visible) {
313
+ outline: 2px solid var(--bs-primary, #0d6efd);
314
+ outline-offset: 2px;
315
+ }
316
+
317
+ .tile:focus-visible {
318
+ outline: 2px solid var(--bs-primary, #0d6efd);
319
+ outline-offset: -2px;
320
+ }`), I = "Press M to enter move mode. In move mode, arrow keys move the tile, Shift with arrow keys resize it, Enter commits, Escape cancels.";
321
+ let L = 0;
322
+ const $ = 600, A = 10, D = 150, G = 5;
323
+ class O extends z {
324
+ constructor() {
325
+ super(...arguments), this.tiles = [], this.columnCount = null, this.minColumnWidth = "200px", this.minRowHeight = "8rem", this.gap = "0.5rem", this.dragMode = "header", this.resizeMode = "hover", this.animateReflow = !0, this.label = null, this.gestureState = { kind: "idle" }, this.keyboardState = { kind: "idle" }, this.previewLayout = null, this.gestureKind = "idle", this.blocked = !1, this.effectiveColumnCount = 1, this.focusedTileId = null, this.liveAnnouncer = new _(this), this.instanceId = `mp-tile-manager-${++L}`, this.hostResizeObserver = null, this.flipPreviousRects = /* @__PURE__ */ new Map(), this.cellMetrics = { width: 0, height: 0, gapX: 0, gapY: 0 }, this.onWindowPointerMove = (t) => this.handlePointerMove(t), this.onWindowPointerUp = (t) => this.handlePointerUp(t), this.onWindowPointerCancel = (t) => this.handlePointerCancel(t), this.onWindowKeyDown = (t) => this.handleEscapeKey(t), this.onVisibilityChange = () => {
326
+ document.visibilityState === "hidden" && this.cancelGesture();
327
+ }, this.lastPointerPosition = null;
328
+ }
329
+ static {
330
+ this.styles = [P];
331
+ }
332
+ static get observedAttributes() {
333
+ return [
334
+ ...super.observedAttributes ?? [],
335
+ "column-count",
336
+ "min-column-width",
337
+ "min-row-height",
338
+ "gap",
339
+ "drag-mode",
340
+ "resize-mode",
341
+ "animate-reflow",
342
+ "label"
343
+ ];
344
+ }
345
+ static {
346
+ this.properties = {
347
+ tiles: { attribute: !1 },
348
+ columnCount: { attribute: "column-count", type: Number },
349
+ minColumnWidth: { attribute: "min-column-width", type: String },
350
+ minRowHeight: { attribute: "min-row-height", type: String },
351
+ gap: { attribute: "gap", type: String },
352
+ dragMode: { attribute: "drag-mode", type: String, reflect: !0 },
353
+ resizeMode: { attribute: "resize-mode", type: String, reflect: !0 },
354
+ animateReflow: { attribute: "animate-reflow", type: Boolean },
355
+ label: { attribute: "label", type: String },
356
+ previewLayout: { state: !0 },
357
+ gestureKind: { state: !0 },
358
+ blocked: { state: !0 },
359
+ focusedTileId: { state: !0 }
360
+ };
361
+ }
362
+ get instructionsId() {
363
+ return `${this.instanceId}-instructions`;
364
+ }
365
+ render() {
366
+ const t = this.previewLayout ?? this.tiles.map((i) => ({ id: i.id, position: i.position })), e = new Map(this.tiles.map((i) => [i.id, i])), n = this.computeGridStyle();
367
+ return f`
368
+ <div
369
+ class="tile-grid"
370
+ role="region"
371
+ aria-label=${this.label ?? "Tile board"}
372
+ aria-describedby=${this.instructionsId}
373
+ style=${n}
374
+ >
375
+ ${t.map((i) => {
376
+ const r = e.get(i.id);
377
+ return r ? this.renderTile(r, i.position) : b;
378
+ })}
379
+ </div>
380
+ <div id=${this.instructionsId} class="tile-grid__sr-only">${I}</div>
381
+ ${this.liveAnnouncer.template()}
382
+ `;
383
+ }
384
+ 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 ? {
386
+ width: e.colSpan * a.width + (e.colSpan - 1) * a.gapX,
387
+ height: e.rowSpan * a.height + (e.rowSpan - 1) * a.gapY
388
+ } : null, c = [
389
+ `grid-column: ${e.colStart} / span ${e.colSpan}`,
390
+ `grid-row: ${e.rowStart} / span ${e.rowSpan}`,
391
+ s ? `transform: ${s}` : "",
392
+ d ? `width: ${d.width}px` : "",
393
+ d ? `height: ${d.height}px` : ""
394
+ ].filter(Boolean).join("; "), h = this.resolveFocusableTileId() === t.id;
395
+ return f`
396
+ <div
397
+ class="tile"
398
+ role="button"
399
+ tabindex=${h ? "0" : "-1"}
400
+ data-tile-id=${t.id}
401
+ data-dragging=${n ? "true" : "false"}
402
+ data-resizing=${i ? "true" : "false"}
403
+ data-blocked=${r ? "true" : "false"}
404
+ data-pressing=${o ? "true" : "false"}
405
+ data-drag-mode=${this.dragMode}
406
+ data-locked-move=${t.disableMove ? "true" : "false"}
407
+ data-locked-resize=${t.disableResize ? "true" : "false"}
408
+ aria-label=${t.label ?? b}
409
+ style=${c}
410
+ @pointerdown=${(p) => this.onTilePointerDown(p, t)}
411
+ @keydown=${(p) => this.onTileKeyDown(p, t)}
412
+ @focus=${() => this.onTileFocus(t)}
413
+ >
414
+ <div class="tile__header-shell">
415
+ <slot name=${`${t.id}-header`}></slot>
416
+ </div>
417
+ <div class="tile__content-shell">
418
+ <slot name=${`${t.id}-content`}></slot>
419
+ </div>
420
+ ${t.disableResize || this.resizeMode === "off" ? b : f`
421
+ <div class="tile__resize-side" data-resize="side"
422
+ @pointerdown=${(p) => this.onResizeHandlePointerDown(p, t, "side")}></div>
423
+ <div class="tile__resize-bottom" data-resize="bottom"
424
+ @pointerdown=${(p) => this.onResizeHandlePointerDown(p, t, "bottom")}></div>
425
+ <div class="tile__resize-corner" data-resize="corner"
426
+ @pointerdown=${(p) => this.onResizeHandlePointerDown(p, t, "corner")}></div>
427
+ `}
428
+ </div>
429
+ `;
430
+ }
431
+ computeGridStyle() {
432
+ return [
433
+ `grid-template-columns: ${this.columnCount && this.columnCount > 0 ? `repeat(${this.columnCount}, minmax(0, 1fr))` : `repeat(auto-fit, minmax(${this.minColumnWidth}, 1fr))`}`,
434
+ `--mp-tile-row-height: ${this.minRowHeight}`,
435
+ `--mp-tile-gap: ${this.gap}`
436
+ ].join("; ");
437
+ }
438
+ /**
439
+ * Refresh the cached layout metrics by reading layout / computed-style state
440
+ * once. Called from firstUpdated, the ResizeObserver tick, and updated()
441
+ * when an input that affects metrics changes — never from render().
442
+ */
443
+ updateLayoutCache() {
444
+ const t = this.shadowRoot?.querySelector(".tile-grid");
445
+ if (!t) {
446
+ this.effectiveColumnCount = this.columnCount && this.columnCount > 0 ? this.columnCount : 1;
447
+ return;
448
+ }
449
+ const e = getComputedStyle(t);
450
+ if (this.columnCount && this.columnCount > 0)
451
+ this.effectiveColumnCount = this.columnCount;
452
+ else {
453
+ const d = e.gridTemplateColumns.split(/\s+/).filter(Boolean);
454
+ this.effectiveColumnCount = Math.max(1, d.length);
455
+ }
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 };
458
+ }
459
+ computeActiveTransform(t) {
460
+ const e = this.gestureState;
461
+ if (e.kind !== "drag" || e.tileId !== t) return null;
462
+ const n = this.lastPointerPosition;
463
+ if (!n) return null;
464
+ const i = this.shadowRoot?.querySelector(".tile-grid");
465
+ 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);
467
+ return `translate(${Math.round(a - c)}px, ${Math.round(d - h)}px)`;
468
+ }
469
+ // ---------------- Lifecycle ----------------
470
+ connectedCallback() {
471
+ super.connectedCallback(), document.addEventListener("visibilitychange", this.onVisibilityChange);
472
+ }
473
+ disconnectedCallback() {
474
+ this.cancelGesture(), this.detachWindowListeners(), document.removeEventListener("visibilitychange", this.onVisibilityChange), this.hostResizeObserver?.disconnect(), this.hostResizeObserver = null, super.disconnectedCallback();
475
+ }
476
+ firstUpdated() {
477
+ this.updateLayoutCache();
478
+ let t = !1;
479
+ this.hostResizeObserver = new ResizeObserver(() => {
480
+ t || (t = !0, requestAnimationFrame(() => {
481
+ t = !1, this.updateLayoutCache();
482
+ }));
483
+ }), this.hostResizeObserver.observe(this);
484
+ }
485
+ attributeChangedCallback(t, e, n) {
486
+ super.attributeChangedCallback(t, e, n), t === "animate-reflow" && (this.animateReflow = !(n === null || n === "false" || n === "0"));
487
+ }
488
+ // ---------------- FLIP animator ----------------
489
+ willUpdate(t) {
490
+ if (!this.shouldAnimate()) {
491
+ this.flipPreviousRects.clear();
492
+ return;
493
+ }
494
+ const e = this.shadowRoot?.querySelector(".tile-grid");
495
+ e && (this.flipPreviousRects.clear(), e.querySelectorAll(".tile").forEach((n) => {
496
+ const i = n.dataset.tileId;
497
+ i && this.flipPreviousRects.set(i, n.getBoundingClientRect());
498
+ }));
499
+ }
500
+ updated(t) {
501
+ if ((t.has("columnCount") || t.has("minColumnWidth") || t.has("minRowHeight") || t.has("gap")) && this.updateLayoutCache(), !this.shouldAnimate() || this.flipPreviousRects.size === 0) return;
502
+ const e = this.shadowRoot?.querySelector(".tile-grid");
503
+ if (!e) return;
504
+ const n = this.activeTileId();
505
+ 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
+ if (Math.abs(a) < 0.5 && Math.abs(d) < 0.5) return;
512
+ const c = i.style.transition;
513
+ i.style.transition = "none", i.style.transform = `translate(${a}px, ${d}px)`, requestAnimationFrame(() => {
514
+ i.style.transition = c, i.style.transform = "";
515
+ });
516
+ }), this.flipPreviousRects.clear();
517
+ }
518
+ shouldAnimate() {
519
+ return !this.animateReflow || typeof window > "u" || typeof window.matchMedia != "function" ? !1 : !window.matchMedia("(prefers-reduced-motion: reduce)").matches;
520
+ }
521
+ onTilePointerDown(t, e) {
522
+ 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)));
523
+ }
524
+ onResizeHandlePointerDown(t, e, n) {
525
+ t.button !== 0 && t.pointerType === "mouse" || e.disableResize || this.resizeMode === "off" || this.gestureState.kind === "idle" && (t.stopPropagation(), t.preventDefault(), this.beginResize(t, e, n));
526
+ }
527
+ // ---------------- Drag arming ----------------
528
+ armPointerDrag(t, e) {
529
+ const n = t.clientX, i = t.clientY, r = (s) => {
530
+ if (s.pointerId !== t.pointerId) return;
531
+ 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));
535
+ };
536
+ window.addEventListener("pointermove", r), window.addEventListener("pointerup", o), window.addEventListener("pointercancel", o);
537
+ }
538
+ 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();
541
+ }, D), s = window.setTimeout(() => {
542
+ if (!(this.gestureState.kind !== "arming-touch-drag" || this.gestureState.pointerId !== r)) {
543
+ this.cleanupTouchArming();
544
+ try {
545
+ navigator.vibrate?.(10);
546
+ } catch {
547
+ }
548
+ this.beginDragFromTouchArm(e, n, i, r);
549
+ }
550
+ }, $);
551
+ this.gestureState = {
552
+ kind: "arming-touch-drag",
553
+ pointerId: r,
554
+ tileId: e.id,
555
+ startX: n,
556
+ startY: i,
557
+ timer: s,
558
+ pressingTimer: o
559
+ }, this.gestureKind = "arming-touch-drag";
560
+ const a = (c) => {
561
+ if (c.pointerId !== r || this.gestureState.kind !== "arming-touch-drag") return;
562
+ const h = c.clientX - n, p = c.clientY - i;
563
+ Math.hypot(h, p) > A && (this.cleanupTouchArming(), window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", d));
564
+ }, 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));
566
+ };
567
+ window.addEventListener("pointermove", a), window.addEventListener("pointerup", d), window.addEventListener("pointercancel", d);
568
+ }
569
+ cleanupTouchArming() {
570
+ if (this.gestureState.kind !== "arming-touch-drag") return;
571
+ const { timer: t, pressingTimer: e } = this.gestureState;
572
+ t !== null && window.clearTimeout(t), e !== null && window.clearTimeout(e), this.gestureState = { kind: "idle" }, this.gestureKind = "idle", this.requestUpdate();
573
+ }
574
+ beginDragFromTouchArm(t, e, n, i) {
575
+ 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);
579
+ this.gestureState = {
580
+ kind: "drag",
581
+ pointerId: i,
582
+ tileId: t.id,
583
+ pointerOffset: { dx: e - a, dy: n - d },
584
+ currentRect: { ...t.position },
585
+ blocked: !1
586
+ }, this.gestureKind = "drag", this.lastPointerPosition = { x: e, y: n }, this.attachWindowListeners(), this.announceDragBegin(t), this.requestUpdate();
587
+ }
588
+ beginDrag(t, e) {
589
+ this.updateLayoutCache();
590
+ const n = this.shadowRoot?.querySelector(".tile-grid");
591
+ 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);
593
+ this.gestureState = {
594
+ kind: "drag",
595
+ pointerId: t.pointerId,
596
+ tileId: e.id,
597
+ pointerOffset: { dx: t.clientX - o, dy: t.clientY - s },
598
+ currentRect: { ...e.position },
599
+ blocked: !1
600
+ }, this.gestureKind = "drag", this.lastPointerPosition = { x: t.clientX, y: t.clientY }, this.attachWindowListeners(), this.announceDragBegin(e), this.runPackerForCurrentGesture();
601
+ }
602
+ beginResize(t, e, n) {
603
+ this.gestureState = {
604
+ kind: "resize",
605
+ pointerId: t.pointerId,
606
+ tileId: e.id,
607
+ mode: n,
608
+ startPointer: { x: t.clientX, y: t.clientY },
609
+ startSpans: { colSpan: e.position.colSpan, rowSpan: e.position.rowSpan },
610
+ currentRect: { ...e.position },
611
+ blocked: !1
612
+ }, this.gestureKind = "resize", this.lastPointerPosition = { x: t.clientX, y: t.clientY }, this.attachWindowListeners(), this.announceResizeBegin(e), this.runPackerForCurrentGesture();
613
+ }
614
+ announceDragBegin(t) {
615
+ const e = t.label ?? `tile at row ${t.position.rowStart}, column ${t.position.colStart}`;
616
+ this.liveAnnouncer.announce(`Dragging ${e}.`);
617
+ }
618
+ announceResizeBegin(t) {
619
+ const e = t.label ?? `tile at row ${t.position.rowStart}, column ${t.position.colStart}`;
620
+ this.liveAnnouncer.announce(`Resizing ${e}.`);
621
+ }
622
+ attachWindowListeners() {
623
+ window.addEventListener("pointermove", this.onWindowPointerMove), window.addEventListener("pointerup", this.onWindowPointerUp), window.addEventListener("pointercancel", this.onWindowPointerCancel), window.addEventListener("keydown", this.onWindowKeyDown);
624
+ }
625
+ detachWindowListeners() {
626
+ window.removeEventListener("pointermove", this.onWindowPointerMove), window.removeEventListener("pointerup", this.onWindowPointerUp), window.removeEventListener("pointercancel", this.onWindowPointerCancel), window.removeEventListener("keydown", this.onWindowKeyDown);
627
+ }
628
+ handleEscapeKey(t) {
629
+ t.key === "Escape" && this.gestureState.kind !== "idle" && (t.preventDefault(), this.cancelGesture());
630
+ }
631
+ // ---------------- Pointer move / up / cancel ----------------
632
+ handlePointerMove(t) {
633
+ const e = this.gestureState;
634
+ e.kind === "idle" || e.kind === "arming-touch-drag" || t.pointerId === e.pointerId && (this.lastPointerPosition = { x: t.clientX, y: t.clientY }, this.runPackerForCurrentGesture());
635
+ }
636
+ handlePointerUp(t) {
637
+ const e = this.gestureState;
638
+ if (!(e.kind === "idle" || e.kind === "arming-touch-drag") && t.pointerId === e.pointerId) {
639
+ if (e.blocked) {
640
+ this.cancelGesture("blocked");
641
+ return;
642
+ }
643
+ this.commitGesture();
644
+ }
645
+ }
646
+ handlePointerCancel(t) {
647
+ const e = this.gestureState;
648
+ e.kind !== "idle" && (e.kind !== "arming-touch-drag" && t.pointerId !== e.pointerId || this.cancelGesture());
649
+ }
650
+ // ---------------- Packer integration ----------------
651
+ runPackerForCurrentGesture() {
652
+ const t = this.gestureState;
653
+ if (t.kind !== "drag" && t.kind !== "resize") return;
654
+ const e = this.tiles.find((s) => s.id === t.tileId);
655
+ if (!e) {
656
+ this.cancelGesture();
657
+ return;
658
+ }
659
+ const n = t.kind === "drag" ? this.computeDragRect(t, e) : this.computeResizeRect(t, e);
660
+ if (!n) return;
661
+ t.currentRect = n;
662
+ const i = this.effectiveColumnCount, r = v(
663
+ this.tiles.map((s) => ({ id: s.id, position: s.position, locked: !!s.disableMove })),
664
+ { id: e.id, rect: n },
665
+ i
666
+ );
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();
670
+ }
671
+ computeDragRect(t, e) {
672
+ const n = this.shadowRoot?.querySelector(".tile-grid");
673
+ 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;
677
+ return {
678
+ colStart: Math.max(1, Math.min(c, r - e.position.colSpan + 1)),
679
+ rowStart: Math.max(1, h),
680
+ colSpan: e.position.colSpan,
681
+ rowSpan: e.position.rowSpan
682
+ };
683
+ }
684
+ 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);
688
+ return {
689
+ colStart: e.position.colStart,
690
+ rowStart: e.position.rowStart,
691
+ colSpan: c,
692
+ rowSpan: h
693
+ };
694
+ }
695
+ // ---------------- Commit / cancel ----------------
696
+ commitGesture() {
697
+ const t = this.gestureState;
698
+ if (t.kind !== "drag" && t.kind !== "resize") return;
699
+ const e = this.previewLayout;
700
+ if (!e) {
701
+ this.cleanupGesture();
702
+ return;
703
+ }
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;
707
+ });
708
+ this.tiles = i, e.forEach((o) => {
709
+ const s = n.get(o.id);
710
+ (!s || !this.positionsEqual(s, o.position)) && this.dispatchEvent(
711
+ new CustomEvent("tilepositionchange", {
712
+ detail: { id: o.id, position: o.position },
713
+ bubbles: !1,
714
+ composed: !0
715
+ })
716
+ );
717
+ }), this.dispatchEvent(
718
+ new CustomEvent("tilelayoutchange", {
719
+ detail: this.cloneSnapshot(e),
720
+ bubbles: !1,
721
+ composed: !0
722
+ })
723
+ );
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`
727
+ ), this.cleanupGesture();
728
+ }
729
+ cancelGesture(t = "cancel") {
730
+ const e = this.gestureState;
731
+ t === "blocked" && (e.kind === "drag" || e.kind === "resize") && this.dispatchEvent(
732
+ new CustomEvent("tilegestureblocked", {
733
+ detail: { id: e.tileId, reason: "locked-overlap" },
734
+ bubbles: !1,
735
+ composed: !0
736
+ })
737
+ ), this.cleanupGesture();
738
+ }
739
+ cleanupGesture() {
740
+ this.gestureState.kind === "arming-touch-drag" && this.cleanupTouchArming(), this.detachWindowListeners(), this.gestureState = { kind: "idle" }, this.gestureKind = "idle", this.previewLayout = null, this.blocked = !1, this.lastPointerPosition = null, this.requestUpdate();
741
+ }
742
+ positionsEqual(t, e) {
743
+ return t.colStart === e.colStart && t.rowStart === e.rowStart && t.colSpan === e.colSpan && t.rowSpan === e.rowSpan;
744
+ }
745
+ cloneSnapshot(t) {
746
+ return t.map((e) => ({ id: e.id, position: { ...e.position } }));
747
+ }
748
+ activeTileId() {
749
+ const t = this.gestureState;
750
+ return t.kind === "drag" || t.kind === "resize" || t.kind === "arming-touch-drag" ? t.tileId : null;
751
+ }
752
+ // ---------------- Public API ----------------
753
+ /** Read-only snapshot of the current layout. Mirrors `BsDockManagerComponent.captureLayout()`. */
754
+ captureLayout() {
755
+ return this.tiles.map((t) => ({ id: t.id, position: { ...t.position } }));
756
+ }
757
+ /**
758
+ * True while a drag or resize is in flight. The Angular wrapper uses this to
759
+ * avoid clobbering `tiles` mid-gesture. Touch long-press arming does NOT
760
+ * count — the WC isn't yet owning the layout during the hold.
761
+ */
762
+ get isGestureActive() {
763
+ return this.gestureState.kind === "drag" || this.gestureState.kind === "resize";
764
+ }
765
+ // ---------------- Keyboard ----------------
766
+ onTileKeyDown(t, e) {
767
+ const n = this.keyboardState;
768
+ if (n.kind === "idle") {
769
+ if (t.key === "m" || t.key === "M") {
770
+ if (e.disableMove && e.disableResize) return;
771
+ t.preventDefault(), this.keyboardState = { kind: "move", tileId: e.id }, this.liveAnnouncer.announce(
772
+ "Move mode enabled. Use arrow keys to move, Shift with arrow keys to resize, Enter to commit, Escape to cancel."
773
+ );
774
+ return;
775
+ }
776
+ return this.handleFocusNavigation(t, e), void 0;
777
+ }
778
+ if (n.tileId === e.id) {
779
+ if (t.key === "Escape" || t.key === "Enter") {
780
+ t.preventDefault(), this.keyboardState = { kind: "idle" }, this.liveAnnouncer.announce(t.key === "Enter" ? "Move committed." : "Move cancelled.");
781
+ return;
782
+ }
783
+ if (t.key.startsWith("Arrow")) {
784
+ t.preventDefault();
785
+ const i = t.shiftKey;
786
+ this.applyKeyboardStep(e, t.key, i);
787
+ }
788
+ }
789
+ }
790
+ /**
791
+ * Outside move mode, arrow keys move *focus* between tiles (row-major
792
+ * order — top-to-bottom, left-to-right by gridcell position). Home/End
793
+ * jump to first/last enabled tile. Returns true if the event was handled.
794
+ */
795
+ handleFocusNavigation(t, e) {
796
+ 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;
801
+ t.preventDefault();
802
+ const s = i[o];
803
+ return this.focusedTileId = s.id, this.requestUpdate(), queueMicrotask(() => {
804
+ this.shadowRoot?.querySelector(`.tile[data-tile-id="${s.id}"]`)?.focus();
805
+ }), !0;
806
+ }
807
+ onTileFocus(t) {
808
+ this.focusedTileId !== t.id && (this.focusedTileId = t.id, this.requestUpdate());
809
+ }
810
+ /**
811
+ * The single tile that should carry `tabindex="0"` to act as the board's
812
+ * tab stop. Defaults to the previously-focused tile, then the first tile in
813
+ * row-major order. All other tiles render with `tabindex="-1"` so Tab from
814
+ * outside the board lands on exactly one tile.
815
+ */
816
+ resolveFocusableTileId() {
817
+ 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
+ }
819
+ 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 ? {
821
+ colStart: t.position.colStart,
822
+ 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)
825
+ } : {
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),
828
+ colSpan: t.position.colSpan,
829
+ rowSpan: t.position.rowSpan
830
+ }, a = v(
831
+ this.tiles.map((c) => ({ id: c.id, position: c.position, locked: !!c.disableMove })),
832
+ { id: t.id, rect: s },
833
+ i
834
+ );
835
+ if (a.blocked) {
836
+ this.liveAnnouncer.announce("Move blocked.");
837
+ return;
838
+ }
839
+ const d = this.tiles.map((c) => {
840
+ const h = a.layout.find((p) => p.id === c.id);
841
+ return h ? { ...c, position: h.position } : c;
842
+ });
843
+ this.tiles = d, this.dispatchEvent(
844
+ new CustomEvent("tilelayoutchange", {
845
+ detail: this.cloneSnapshot(a.layout),
846
+ bubbles: !1,
847
+ composed: !0
848
+ })
849
+ ), a.layout.forEach((c) => {
850
+ this.dispatchEvent(
851
+ new CustomEvent("tilepositionchange", {
852
+ detail: { id: c.id, position: c.position },
853
+ bubbles: !1,
854
+ composed: !0
855
+ })
856
+ );
857
+ }), this.liveAnnouncer.announce(
858
+ n ? `Tile resized to ${s.colSpan} columns by ${s.rowSpan} rows` : `Tile moved to row ${s.rowStart}, column ${s.colStart}`
859
+ );
860
+ }
861
+ }
862
+ typeof customElements < "u" && !customElements.get("mp-tile-manager") && customElements.define("mp-tile-manager", O);
863
+ export {
864
+ O as MintTileManagerElement,
865
+ v as pack,
866
+ w as rectsOverlap
867
+ };