@mintplayer/web-components 1.0.0 → 1.2.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 (237) 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-Con0yQue.mjs +1125 -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 +260 -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 +41 -0
  31. package/datatable/src/types/index.d.ts +2 -0
  32. package/datatable/src/types/tree.d.ts +42 -0
  33. package/datepicker/index.mjs +240 -0
  34. package/datepicker/src/index.d.ts +1 -0
  35. package/datepicker/src/mp-datepicker.element.d.ts +94 -0
  36. package/datepicker/src/mp-datepicker.element.template.d.ts +2 -0
  37. package/datetime-picker/index.mjs +427 -0
  38. package/datetime-picker/src/index.d.ts +1 -0
  39. package/datetime-picker/src/mp-datetime-picker.element.d.ts +174 -0
  40. package/datetime-picker/src/mp-datetime-picker.element.template.d.ts +2 -0
  41. package/dock/index.mjs +2402 -0
  42. package/dock/src/components/index.d.ts +1 -0
  43. package/dock/src/components/mint-dock-manager.element.d.ts +313 -0
  44. package/dock/src/components/mint-dock-manager.element.template.d.ts +2 -0
  45. package/dock/src/index.d.ts +2 -0
  46. package/dock/src/types/dock-layout.d.ts +65 -0
  47. package/dock/src/types/index.d.ts +1 -0
  48. package/file-manager/index.mjs +1263 -0
  49. package/file-manager/src/components/index.d.ts +2 -0
  50. package/file-manager/src/components/mp-file-manager.d.ts +320 -0
  51. package/file-manager/src/index.d.ts +5 -0
  52. package/file-manager/src/styles/file-manager.styles.d.ts +2 -0
  53. package/file-manager/src/styles/index.d.ts +1 -0
  54. package/file-manager/src/types/file-system-node.d.ts +24 -0
  55. package/file-manager/src/types/index.d.ts +3 -0
  56. package/file-manager/src/types/messages.d.ts +43 -0
  57. package/multi-range/index.mjs +407 -0
  58. package/multi-range/src/index.d.ts +2 -0
  59. package/multi-range/src/mint-multi-range.element.d.ts +124 -0
  60. package/multi-range/src/mint-multi-range.element.template.d.ts +2 -0
  61. package/multi-range/src/types/multi-range-orientation.d.ts +1 -0
  62. package/otp-input/index.mjs +362 -0
  63. package/otp-input/src/index.d.ts +4 -0
  64. package/otp-input/src/mint-otp-input.element.d.ts +134 -0
  65. package/otp-input/src/mint-otp-input.element.template.d.ts +2 -0
  66. package/otp-input/src/types/otp-input-case.d.ts +1 -0
  67. package/otp-input/src/types/otp-input-size.d.ts +1 -0
  68. package/otp-input/src/types/otp-input-type.d.ts +1 -0
  69. package/overlay/index.mjs +260 -0
  70. package/overlay/src/index.d.ts +2 -0
  71. package/overlay/src/overlay-controller.d.ts +205 -0
  72. package/package.json +1 -1
  73. package/pagination/index.mjs +5 -0
  74. package/pagination/src/components/index.d.ts +2 -0
  75. package/pagination/src/components/mp-pagination.d.ts +95 -0
  76. package/pagination/src/index.d.ts +2 -0
  77. package/pagination/src/styles/index.d.ts +1 -0
  78. package/pagination/src/styles/pagination.styles.d.ts +2 -0
  79. package/query-builder/index.mjs +3720 -0
  80. package/query-builder/src/context.d.ts +14 -0
  81. package/query-builder/src/dnd/drag-controller.d.ts +69 -0
  82. package/query-builder/src/index.d.ts +23 -0
  83. package/query-builder/src/model/default-tree.d.ts +7 -0
  84. package/query-builder/src/model/editor.d.ts +15 -0
  85. package/query-builder/src/model/errors.d.ts +6 -0
  86. package/query-builder/src/model/expression.d.ts +22 -0
  87. package/query-builder/src/model/field-def.d.ts +17 -0
  88. package/query-builder/src/model/messages.d.ts +17 -0
  89. package/query-builder/src/model/operator-overrides.d.ts +21 -0
  90. package/query-builder/src/model/operators.d.ts +8 -0
  91. package/query-builder/src/model/saved-query.d.ts +6 -0
  92. package/query-builder/src/model/sort.d.ts +9 -0
  93. package/query-builder/src/model/tree-ops.d.ts +56 -0
  94. package/query-builder/src/mp-query-builder.element.d.ts +158 -0
  95. package/query-builder/src/mp-query-builder.element.template.d.ts +2 -0
  96. package/query-builder/src/mp-query-condition.element.d.ts +44 -0
  97. package/query-builder/src/mp-query-condition.element.template.d.ts +2 -0
  98. package/query-builder/src/mp-query-group.element.d.ts +52 -0
  99. package/query-builder/src/mp-query-group.element.template.d.ts +2 -0
  100. package/query-builder/src/mp-query-subquery.element.d.ts +37 -0
  101. package/query-builder/src/mp-query-subquery.element.template.d.ts +2 -0
  102. package/query-builder/src/preview/render-expression.d.ts +23 -0
  103. package/query-builder/src/value-editors/builtin-editors.d.ts +6 -0
  104. package/query-builder/src/visitor/visit-tree.d.ts +29 -0
  105. package/query-builder/src/visitor/visitor-types.d.ts +15 -0
  106. package/radio/index.mjs +162 -0
  107. package/radio/src/components/index.d.ts +2 -0
  108. package/radio/src/components/mp-radio.d.ts +63 -0
  109. package/radio/src/index.d.ts +2 -0
  110. package/ribbon/index.mjs +3151 -0
  111. package/ribbon/src/index.d.ts +10 -0
  112. package/ribbon/src/items/index.d.ts +15 -0
  113. package/ribbon/src/items/mp-ribbon-button.element.d.ts +10 -0
  114. package/ribbon/src/items/mp-ribbon-checkbox.element.d.ts +11 -0
  115. package/ribbon/src/items/mp-ribbon-color-picker.element.d.ts +12 -0
  116. package/ribbon/src/items/mp-ribbon-combobox.element.d.ts +19 -0
  117. package/ribbon/src/items/mp-ribbon-dropdown-button.element.d.ts +16 -0
  118. package/ribbon/src/items/mp-ribbon-gallery-item.element.d.ts +15 -0
  119. package/ribbon/src/items/mp-ribbon-gallery.element.d.ts +11 -0
  120. package/ribbon/src/items/mp-ribbon-group-button.element.d.ts +18 -0
  121. package/ribbon/src/items/mp-ribbon-item-base.d.ts +68 -0
  122. package/ribbon/src/items/mp-ribbon-menu-item.element.d.ts +13 -0
  123. package/ribbon/src/items/mp-ribbon-menu-separator.element.d.ts +6 -0
  124. package/ribbon/src/items/mp-ribbon-split-button.element.d.ts +23 -0
  125. package/ribbon/src/items/mp-ribbon-template-item.element.d.ts +12 -0
  126. package/ribbon/src/items/mp-ribbon-toggle-button.element.d.ts +12 -0
  127. package/ribbon/src/mp-quick-access-toolbar.element.d.ts +35 -0
  128. package/ribbon/src/mp-ribbon-contextual-tab-set.element.d.ts +18 -0
  129. package/ribbon/src/mp-ribbon-group.element.d.ts +59 -0
  130. package/ribbon/src/mp-ribbon-tab.element.d.ts +72 -0
  131. package/ribbon/src/mp-ribbon.element.d.ts +211 -0
  132. package/ribbon/src/types/ribbon.types.d.ts +4 -0
  133. package/scheduler/index.mjs +3567 -0
  134. package/scheduler/src/components/mp-scheduler.d.ts +238 -0
  135. package/scheduler/src/drag/drag-manager.d.ts +90 -0
  136. package/scheduler/src/drag/drag-preview.d.ts +42 -0
  137. package/scheduler/src/drag/drag-state-machine.d.ts +102 -0
  138. package/scheduler/src/drag/drag-types.d.ts +104 -0
  139. package/scheduler/src/drag/index.d.ts +4 -0
  140. package/scheduler/src/events/event-types.d.ts +58 -0
  141. package/scheduler/src/events/index.d.ts +2 -0
  142. package/scheduler/src/events/scheduler-event-emitter.d.ts +52 -0
  143. package/scheduler/src/index.d.ts +6 -0
  144. package/scheduler/src/input/index.d.ts +2 -0
  145. package/scheduler/src/input/input-handler.d.ts +105 -0
  146. package/scheduler/src/input/pointer-event.d.ts +39 -0
  147. package/scheduler/src/state/scheduler-state.d.ts +189 -0
  148. package/scheduler/src/styles/scheduler.styles.d.ts +2 -0
  149. package/scheduler/src/views/base-view.d.ts +87 -0
  150. package/scheduler/src/views/day-view.d.ts +25 -0
  151. package/scheduler/src/views/index.d.ts +6 -0
  152. package/scheduler/src/views/month-view.d.ts +27 -0
  153. package/scheduler/src/views/timeline-view.d.ts +23 -0
  154. package/scheduler/src/views/week-view.d.ts +28 -0
  155. package/scheduler/src/views/year-view.d.ts +25 -0
  156. package/scheduler-core/index.mjs +174 -0
  157. package/scheduler-core/src/index.d.ts +3 -0
  158. package/scheduler-core/src/models/drag-state.d.ts +43 -0
  159. package/scheduler-core/src/models/event.d.ts +111 -0
  160. package/scheduler-core/src/models/events.d.ts +108 -0
  161. package/scheduler-core/src/models/index.d.ts +7 -0
  162. package/scheduler-core/src/models/options.d.ts +88 -0
  163. package/scheduler-core/src/models/resource.d.ts +58 -0
  164. package/scheduler-core/src/models/time-slot.d.ts +31 -0
  165. package/scheduler-core/src/models/types.d.ts +20 -0
  166. package/scheduler-core/src/services/date.service.d.ts +140 -0
  167. package/scheduler-core/src/services/index.d.ts +4 -0
  168. package/scheduler-core/src/services/position.service.d.ts +35 -0
  169. package/scheduler-core/src/services/resource.service.d.ts +83 -0
  170. package/scheduler-core/src/services/timeline.service.d.ts +103 -0
  171. package/scheduler-core/src/utils/color.d.ts +24 -0
  172. package/scheduler-core/src/utils/dom.d.ts +54 -0
  173. package/scheduler-core/src/utils/id.d.ts +16 -0
  174. package/scheduler-core/src/utils/index.d.ts +3 -0
  175. package/select/index.mjs +4 -0
  176. package/select/src/components/index.d.ts +2 -0
  177. package/select/src/components/mp-select.d.ts +82 -0
  178. package/select/src/index.d.ts +2 -0
  179. package/splitter/index.mjs +10 -0
  180. package/splitter/src/components/index.d.ts +2 -0
  181. package/splitter/src/components/mp-splitter.d.ts +109 -0
  182. package/splitter/src/index.d.ts +11 -0
  183. package/splitter/src/input/index.d.ts +4 -0
  184. package/splitter/src/input/input-handler.d.ts +36 -0
  185. package/splitter/src/input/pointer-event.d.ts +9 -0
  186. package/splitter/src/managers/index.d.ts +2 -0
  187. package/splitter/src/managers/resize-manager.d.ts +13 -0
  188. package/splitter/src/state/index.d.ts +2 -0
  189. package/splitter/src/state/splitter-state.d.ts +24 -0
  190. package/splitter/src/styles/index.d.ts +1 -0
  191. package/splitter/src/styles/splitter.styles.d.ts +2 -0
  192. package/splitter/src/types/direction.d.ts +1 -0
  193. package/splitter/src/types/index.d.ts +5 -0
  194. package/splitter/src/types/panel-info.d.ts +6 -0
  195. package/splitter/src/types/point.d.ts +4 -0
  196. package/splitter/src/types/resize-operation.d.ts +13 -0
  197. package/tab-control/index.mjs +6 -0
  198. package/tab-control/src/components/index.d.ts +3 -0
  199. package/tab-control/src/components/mp-tab-control.d.ts +50 -0
  200. package/tab-control/src/components/mp-tab-page.d.ts +35 -0
  201. package/tab-control/src/index.d.ts +4 -0
  202. package/tab-control/src/styles/index.d.ts +1 -0
  203. package/tab-control/src/styles/tab-control.styles.d.ts +2 -0
  204. package/tab-control/src/types/index.d.ts +1 -0
  205. package/tab-control/src/types/tabs-position.d.ts +1 -0
  206. package/tile-manager/index.mjs +867 -0
  207. package/tile-manager/src/components/index.d.ts +2 -0
  208. package/tile-manager/src/components/mint-tile-manager.element.d.ts +204 -0
  209. package/tile-manager/src/components/mint-tile-manager.element.template.d.ts +2 -0
  210. package/tile-manager/src/index.d.ts +4 -0
  211. package/tile-manager/src/types/grid-rect.d.ts +12 -0
  212. package/tile-manager/src/types/index.d.ts +3 -0
  213. package/tile-manager/src/types/tile-layout-snapshot.d.ts +15 -0
  214. package/tile-manager/src/types/tile-position.d.ts +10 -0
  215. package/tile-manager/src/utils/index.d.ts +1 -0
  216. package/tile-manager/src/utils/pack.d.ts +24 -0
  217. package/timepicker/index.mjs +5 -0
  218. package/timepicker/src/index.d.ts +2 -0
  219. package/timepicker/src/mp-time-list.element.d.ts +76 -0
  220. package/timepicker/src/mp-time-list.element.template.d.ts +2 -0
  221. package/timepicker/src/mp-timepicker.element.d.ts +87 -0
  222. package/timepicker/src/mp-timepicker.element.template.d.ts +2 -0
  223. package/toggle-button/index.mjs +5 -0
  224. package/toggle-button/src/components/index.d.ts +2 -0
  225. package/toggle-button/src/components/mp-toggle-button.d.ts +50 -0
  226. package/toggle-button/src/index.d.ts +3 -0
  227. package/toggle-button/src/styles/index.d.ts +1 -0
  228. package/toggle-button/src/styles/toggle-button.styles.d.ts +2 -0
  229. package/treeview/index.mjs +5 -0
  230. package/treeview/src/components/index.d.ts +2 -0
  231. package/treeview/src/components/mp-treeview.d.ts +113 -0
  232. package/treeview/src/index.d.ts +4 -0
  233. package/treeview/src/styles/index.d.ts +1 -0
  234. package/treeview/src/styles/treeview.styles.d.ts +2 -0
  235. package/treeview/src/types/index.d.ts +1 -0
  236. package/treeview/src/types/tree-node.d.ts +14 -0
  237. package/custom-elements.json +0 -1774
@@ -0,0 +1,1125 @@
1
+ import { unsafeCSS as C, LitElement as S, nothing as c, html as h } from "lit";
2
+ import { repeat as $ } from "lit/directives/repeat.js";
3
+ import { styleMap as f } from "lit/directives/style-map.js";
4
+ import "./mp-pagination-BGxsawFL.mjs";
5
+ import "./mp-checkbox-BokLL7BS.mjs";
6
+ const I = C(`@charset "UTF-8";
7
+ :host {
8
+ display: block;
9
+ width: 100%;
10
+ position: relative;
11
+ --mp-datatable-border-color: var(--bs-border-color, rgba(0, 0, 0, 0.125));
12
+ --mp-datatable-row-hover-bg: var(--bs-table-hover-bg, rgba(0, 0, 0, 0.04));
13
+ --mp-datatable-row-selected-bg: var(--bs-list-group-active-bg, var(--bs-primary, #0d6efd));
14
+ --mp-datatable-row-selected-color: var(--bs-list-group-active-color, #fff);
15
+ --mp-datatable-cut-opacity: 0.55;
16
+ --mp-datatable-resize-handle-color: var(--bs-primary, #0d6efd);
17
+ }
18
+
19
+ * {
20
+ box-sizing: border-box;
21
+ }
22
+
23
+ .datatable-shell {
24
+ display: flex;
25
+ flex-direction: column;
26
+ width: 100%;
27
+ height: 100%;
28
+ }
29
+
30
+ .datatable-scroll {
31
+ overflow: auto;
32
+ flex: 1 1 auto;
33
+ }
34
+
35
+ .datatable-scroll.datatable-virtual {
36
+ max-height: var(--mp-datatable-virtual-max-height, 480px);
37
+ }
38
+ .datatable-scroll.datatable-virtual thead th {
39
+ position: sticky;
40
+ top: 0;
41
+ z-index: 1;
42
+ background-color: var(--bs-body-bg, #fff);
43
+ }
44
+ .datatable-scroll.datatable-virtual thead th[data-sortable=true]:hover {
45
+ background-color: var(--bs-body-bg, #fff);
46
+ background-image: linear-gradient(var(--mp-datatable-row-hover-bg), var(--mp-datatable-row-hover-bg));
47
+ }
48
+
49
+ tr.virtual-spacer {
50
+ pointer-events: none;
51
+ }
52
+
53
+ tr.virtual-spacer > td {
54
+ border-bottom: 0;
55
+ }
56
+
57
+ table {
58
+ width: 100%;
59
+ border-collapse: collapse;
60
+ margin: 0;
61
+ table-layout: auto;
62
+ }
63
+
64
+ table.measured {
65
+ table-layout: fixed;
66
+ }
67
+
68
+ tbody td {
69
+ white-space: nowrap;
70
+ overflow: hidden;
71
+ text-overflow: ellipsis;
72
+ }
73
+
74
+ thead th {
75
+ background-color: var(--bs-table-bg, transparent);
76
+ border-bottom: 1px solid var(--mp-datatable-border-color);
77
+ text-align: left;
78
+ font-weight: 600;
79
+ padding: 0.5rem 0.75rem;
80
+ white-space: nowrap;
81
+ position: relative;
82
+ user-select: none;
83
+ }
84
+
85
+ thead th[data-sortable=true] {
86
+ cursor: pointer;
87
+ padding-right: 2rem;
88
+ }
89
+ thead th[data-sortable=true]::before, thead th[data-sortable=true]::after {
90
+ position: absolute;
91
+ display: block;
92
+ opacity: 0.3;
93
+ bottom: 0.5em;
94
+ }
95
+ thead th[data-sortable=true]::before {
96
+ content: "↑";
97
+ right: 1em;
98
+ }
99
+ thead th[data-sortable=true]::after {
100
+ content: "↓";
101
+ right: 0.5em;
102
+ }
103
+ thead th[data-sortable=true][aria-sort=ascending]::after {
104
+ opacity: 1;
105
+ }
106
+ thead th[data-sortable=true][aria-sort=descending]::before {
107
+ opacity: 1;
108
+ }
109
+
110
+ thead th[data-sortable=true]:hover {
111
+ background-color: var(--mp-datatable-row-hover-bg);
112
+ }
113
+
114
+ .header-cell {
115
+ display: inline-flex;
116
+ align-items: center;
117
+ gap: 0.4rem;
118
+ }
119
+
120
+ .sort-index {
121
+ position: absolute;
122
+ right: 0.1em;
123
+ bottom: 0.3em;
124
+ font-size: 0.65em;
125
+ font-weight: bold;
126
+ opacity: 0.7;
127
+ }
128
+
129
+ .resize-handle {
130
+ position: absolute;
131
+ right: 0;
132
+ top: 0;
133
+ width: 6px;
134
+ height: 100%;
135
+ cursor: col-resize;
136
+ user-select: none;
137
+ z-index: 2;
138
+ }
139
+
140
+ .resize-handle:hover,
141
+ .resize-handle.active {
142
+ background-color: var(--mp-datatable-resize-handle-color);
143
+ }
144
+
145
+ tbody td {
146
+ padding: 0.5rem 0.75rem;
147
+ border-bottom: 1px solid var(--mp-datatable-border-color);
148
+ vertical-align: middle;
149
+ }
150
+
151
+ tbody tr {
152
+ cursor: default;
153
+ }
154
+
155
+ tbody tr[data-clickable=true] {
156
+ cursor: pointer;
157
+ }
158
+
159
+ tbody tr:hover {
160
+ background-color: var(--mp-datatable-row-hover-bg);
161
+ }
162
+
163
+ tbody tr[data-selected=true] {
164
+ background-color: var(--mp-datatable-row-selected-bg);
165
+ color: var(--mp-datatable-row-selected-color);
166
+ }
167
+
168
+ tbody tr[data-cut=true] {
169
+ opacity: var(--mp-datatable-cut-opacity);
170
+ }
171
+
172
+ tbody tr[data-focused=true] {
173
+ outline: 2px solid var(--bs-primary, #0d6efd);
174
+ outline-offset: -2px;
175
+ }
176
+
177
+ .checkbox-cell {
178
+ width: 2.5rem;
179
+ text-align: center;
180
+ }
181
+
182
+ .tree-chevron-cell {
183
+ width: 2rem;
184
+ padding-right: 0;
185
+ white-space: nowrap;
186
+ user-select: none;
187
+ }
188
+
189
+ .tree-chevron {
190
+ appearance: none;
191
+ background: transparent;
192
+ border: 0;
193
+ padding: 0;
194
+ width: 1.5rem;
195
+ height: 1.5rem;
196
+ line-height: 1;
197
+ cursor: pointer;
198
+ color: var(--bs-body-color, inherit);
199
+ font-size: 0.85em;
200
+ border-radius: 0.25rem;
201
+ display: inline-flex;
202
+ align-items: center;
203
+ justify-content: center;
204
+ }
205
+ .tree-chevron:hover {
206
+ background-color: var(--mp-datatable-row-hover-bg);
207
+ }
208
+ .tree-chevron:focus-visible {
209
+ outline: 2px solid var(--bs-primary, #0d6efd);
210
+ outline-offset: 1px;
211
+ }
212
+
213
+ tbody tr[data-placeholder=true] {
214
+ cursor: default;
215
+ opacity: 0.6;
216
+ pointer-events: none;
217
+ }
218
+
219
+ .tree-placeholder-cell {
220
+ color: var(--bs-secondary-color, #6c757d);
221
+ font-style: italic;
222
+ padding-left: 1.25rem;
223
+ }
224
+
225
+ .empty-state,
226
+ .loading-state {
227
+ padding: 2rem 1rem;
228
+ text-align: center;
229
+ color: var(--bs-secondary-color, #6c757d);
230
+ }
231
+
232
+ .datatable-footer {
233
+ display: flex;
234
+ align-items: center;
235
+ justify-content: space-between;
236
+ padding: 0.5rem 0;
237
+ gap: 1rem;
238
+ flex-wrap: wrap;
239
+ flex: 0 0 auto;
240
+ }
241
+
242
+ .datatable-per-page,
243
+ .datatable-pagination {
244
+ flex: 0 1 auto;
245
+ }
246
+
247
+ @media (prefers-reduced-motion: reduce) {
248
+ .resize-handle {
249
+ transition: none !important;
250
+ }
251
+ }`);
252
+ function R(l, e, t) {
253
+ if (t) {
254
+ const r = l.findIndex((i) => i.property === e);
255
+ return r === -1 ? [...l, { property: e, direction: "ascending" }] : l[r].direction === "ascending" ? l.map(
256
+ (i, a) => a === r ? { ...i, direction: "descending" } : i
257
+ ) : l.filter((i, a) => a !== r);
258
+ }
259
+ const s = l.length === 1 && l[0].property === e;
260
+ return [
261
+ {
262
+ property: e,
263
+ direction: s && l[0].direction === "ascending" ? "descending" : "ascending"
264
+ }
265
+ ];
266
+ }
267
+ function b(l, e) {
268
+ return e.length === 0 ? l.slice() : l.map((t, s) => ({ row: t, index: s })).sort((t, s) => {
269
+ for (const r of e) {
270
+ const i = w(t.row, r.property), a = w(s.row, r.property), o = E(i, a);
271
+ if (o !== 0)
272
+ return r.direction === "ascending" ? o : -o;
273
+ }
274
+ return t.index - s.index;
275
+ }).map(({ row: t }) => t);
276
+ }
277
+ function w(l, e) {
278
+ if (!(l == null || typeof l != "object"))
279
+ return l[e];
280
+ }
281
+ function E(l, e) {
282
+ return l === e ? 0 : l == null ? 1 : e == null ? -1 : typeof l == "number" && typeof e == "number" ? l - e : l instanceof Date && e instanceof Date ? l.getTime() - e.getTime() : String(l).localeCompare(String(e));
283
+ }
284
+ let z = 0;
285
+ class M extends S {
286
+ constructor() {
287
+ super(...arguments), this.instanceId = `mp-datatable-${++z}`, this._columns = [], this._data = [], this._sortColumns = [], this._selectionMode = "none", this._selectedIds = /* @__PURE__ */ new Set(), this._cutIds = /* @__PURE__ */ new Set(), this._focusedRowKey = null, this._rowKey = (e, t) => {
288
+ const s = e;
289
+ return s && s.id != null ? String(s.id) : `row-${t}`;
290
+ }, this._columnWidths = /* @__PURE__ */ new Map(), this._hasMeasuredInitial = !1, this._loading = !1, this._emptyMessage = "No data", this._pagination = !1, this._page = 1, this._perPage = 20, this._perPageOptions = [10, 20, 50], this._autoSort = !0, this._totalRecords = null, this._virtualScroll = !1, this._itemSize = 40, this._virtualBuffer = 10, this._virtualRange = { startIndex: 0, endIndex: 0 }, this._scrollElement = null, this._resizeObserver = null, this._scrollListener = null, this._viewportHeight = 0, this._tree = !1, this._idKey = null, this._childCountKey = null, this._treeIndent = 1.25, this._expandedIds = /* @__PURE__ */ new Set(), this._selectionStrategy = "flat", this._childCache = /* @__PURE__ */ new Map(), this._childTotals = /* @__PURE__ */ new Map(), this._pendingFetches = /* @__PURE__ */ new Set(), this._cachedFlatList = null, this._cachedIndeterminateKeys = null, this._resizableColumns = !0, this.resizeState = null, this.onColumnResizeMove = (e) => {
291
+ if (!this.resizeState) return;
292
+ const t = e.clientX - this.resizeState.startX, s = Math.max(40, this.resizeState.startWidth + t);
293
+ this._columnWidths = new Map(this._columnWidths), this._columnWidths.set(this.resizeState.columnName, s), this.requestUpdate();
294
+ }, this.onColumnResizeEnd = (e) => {
295
+ if (this.resizeState) {
296
+ this.resizeState.handle.classList.remove("active"), this.resizeState.handle.removeEventListener("pointermove", this.onColumnResizeMove), this.resizeState.handle.removeEventListener("pointerup", this.onColumnResizeEnd), this.resizeState.handle.removeEventListener("pointercancel", this.onColumnResizeEnd);
297
+ try {
298
+ this.resizeState.handle.releasePointerCapture(e.pointerId);
299
+ } catch {
300
+ }
301
+ this.resizeState = null;
302
+ }
303
+ };
304
+ }
305
+ static {
306
+ this.styles = [I];
307
+ }
308
+ static get observedAttributes() {
309
+ return [
310
+ ...super.observedAttributes ?? [],
311
+ "selection-mode",
312
+ "pagination",
313
+ "resizable-columns",
314
+ "auto-sort",
315
+ "empty-message",
316
+ "virtual-scroll",
317
+ "item-size",
318
+ "tree",
319
+ "tree-indent",
320
+ "selection-strategy"
321
+ ];
322
+ }
323
+ /** When true, the WC sorts `data` itself using `sortRows`. Set `false` if the consumer sorts externally. */
324
+ get autoSort() {
325
+ return this._autoSort;
326
+ }
327
+ set autoSort(e) {
328
+ this._autoSort = !!e, this.requestUpdate();
329
+ }
330
+ /**
331
+ * Per-row renderer. When set, the WC delegates row content production to
332
+ * this callback (used by the Angular wrapper to host `*bsRowTemplate`
333
+ * templates). Returning `undefined` falls back to per-column `cellRenderer`s.
334
+ */
335
+ get rowRenderer() {
336
+ return this._rowRenderer;
337
+ }
338
+ set rowRenderer(e) {
339
+ this._rowRenderer = e, this.requestUpdate();
340
+ }
341
+ /** Enable scroll-position-driven virtualization. Rows outside the viewport are not rendered. */
342
+ get virtualScroll() {
343
+ return this._virtualScroll;
344
+ }
345
+ set virtualScroll(e) {
346
+ const t = !!e;
347
+ this._virtualScroll !== t && (this._virtualScroll = t, this.requestUpdate());
348
+ }
349
+ /** Approximate row height in px (used by virtual scroll). Default `40`. */
350
+ get itemSize() {
351
+ return this._itemSize;
352
+ }
353
+ set itemSize(e) {
354
+ const t = Math.max(1, Math.floor(e || 0)) || 40;
355
+ this._itemSize !== t && (this._itemSize = t, this.requestUpdate());
356
+ }
357
+ /** Off-screen row buffer (each side) for virtual scrolling. */
358
+ get virtualBuffer() {
359
+ return this._virtualBuffer;
360
+ }
361
+ set virtualBuffer(e) {
362
+ const t = Math.max(0, Math.floor(e || 0));
363
+ this._virtualBuffer !== t && (this._virtualBuffer = t, this.requestUpdate());
364
+ }
365
+ get columns() {
366
+ return this._columns;
367
+ }
368
+ set columns(e) {
369
+ this._columns = Array.isArray(e) ? e : [], this.requestUpdate();
370
+ }
371
+ get data() {
372
+ return this._data;
373
+ }
374
+ set data(e) {
375
+ this._data = Array.isArray(e) ? e : [], this.requestUpdate();
376
+ }
377
+ get sortColumns() {
378
+ return [...this._sortColumns];
379
+ }
380
+ set sortColumns(e) {
381
+ this._sortColumns = Array.isArray(e) ? [...e] : [], this.requestUpdate();
382
+ }
383
+ get selectionMode() {
384
+ return this._selectionMode;
385
+ }
386
+ set selectionMode(e) {
387
+ this._selectionMode = e, e === "none" && this._selectedIds.clear(), this.requestUpdate();
388
+ }
389
+ get selectedIds() {
390
+ return [...this._selectedIds];
391
+ }
392
+ set selectedIds(e) {
393
+ this._selectedIds = new Set(e ?? []), this.requestUpdate();
394
+ }
395
+ get cutIds() {
396
+ return [...this._cutIds];
397
+ }
398
+ set cutIds(e) {
399
+ this._cutIds = new Set(e ?? []), this.requestUpdate();
400
+ }
401
+ get focusedRowKey() {
402
+ return this._focusedRowKey;
403
+ }
404
+ set focusedRowKey(e) {
405
+ this._focusedRowKey = e, this.requestUpdate();
406
+ }
407
+ get rowKey() {
408
+ return this._rowKey;
409
+ }
410
+ set rowKey(e) {
411
+ this._rowKey = typeof e == "function" ? e : this._rowKey, this.requestUpdate();
412
+ }
413
+ // ─── Tree-mode public API ────────────────────────────────────────────────
414
+ /** Enable tree mode (chevron column, nested expansion, lazy children). */
415
+ get tree() {
416
+ return this._tree;
417
+ }
418
+ set tree(e) {
419
+ const t = !!e;
420
+ this._tree !== t && (this._tree = t, this.requestUpdate());
421
+ }
422
+ /**
423
+ * Property name or function that extracts the stable row identity used as
424
+ * the expansion key and as `parentId` in `mp-datatable-fetch-request`.
425
+ * Required when `tree=true`.
426
+ */
427
+ get idKey() {
428
+ return this._idKey;
429
+ }
430
+ set idKey(e) {
431
+ this._idKey = e, this.requestUpdate();
432
+ }
433
+ /**
434
+ * Property name on the row that holds the direct-child count. Drives both
435
+ * chevron visibility AND placeholder reservation. Required when `tree=true`.
436
+ */
437
+ get childCountKey() {
438
+ return this._childCountKey;
439
+ }
440
+ set childCountKey(e) {
441
+ this._childCountKey = e || null, this.requestUpdate();
442
+ }
443
+ /** Indent in rem per depth level on the chevron cell. Default `1.25`. */
444
+ get treeIndent() {
445
+ return this._treeIndent;
446
+ }
447
+ set treeIndent(e) {
448
+ const t = Number(e);
449
+ this._treeIndent = Number.isFinite(t) && t >= 0 ? t : 1.25, this.requestUpdate();
450
+ }
451
+ /** Two-way binding target: set of expanded-row id values (per `idKey`). */
452
+ get expandedIds() {
453
+ return new Set(this._expandedIds);
454
+ }
455
+ set expandedIds(e) {
456
+ e ? e instanceof Set ? this._expandedIds = new Set(e) : this._expandedIds = new Set(e) : this._expandedIds = /* @__PURE__ */ new Set(), this.requestUpdate();
457
+ }
458
+ /** `'flat'` (default) or `'cascading'`. When `tree=true`, cascading is recommended. */
459
+ get selectionStrategy() {
460
+ return this._selectionStrategy;
461
+ }
462
+ set selectionStrategy(e) {
463
+ this._selectionStrategy = e === "cascading" ? "cascading" : "flat", this.requestUpdate();
464
+ }
465
+ get loading() {
466
+ return this._loading;
467
+ }
468
+ set loading(e) {
469
+ this._loading = !!e, this.requestUpdate();
470
+ }
471
+ get emptyMessage() {
472
+ return this._emptyMessage;
473
+ }
474
+ set emptyMessage(e) {
475
+ this._emptyMessage = e || "No data", this.requestUpdate();
476
+ }
477
+ get pagination() {
478
+ return this._pagination;
479
+ }
480
+ set pagination(e) {
481
+ this._pagination = !!e, this.requestUpdate();
482
+ }
483
+ get page() {
484
+ return this._page;
485
+ }
486
+ set page(e) {
487
+ const t = Math.max(1, Math.floor(e || 1));
488
+ this._page !== t && (this._page = t, this.requestUpdate());
489
+ }
490
+ get perPage() {
491
+ return this._perPage;
492
+ }
493
+ set perPage(e) {
494
+ const t = Math.max(1, Math.floor(e || 1));
495
+ this._perPage !== t && (this._perPage = t, this._page = 1, this.requestUpdate());
496
+ }
497
+ get perPageOptions() {
498
+ return [...this._perPageOptions];
499
+ }
500
+ set perPageOptions(e) {
501
+ this._perPageOptions = Array.isArray(e) && e.length > 0 ? [...e] : [10, 20, 50], this.requestUpdate();
502
+ }
503
+ /**
504
+ * Caller-supplied total record count for external paging. Set this when
505
+ * `[fetch]` returns one page at a time so the pagination footer can show
506
+ * the correct total. Leave as `null` (default) to use `_data.length`.
507
+ */
508
+ get totalRecords() {
509
+ return this._totalRecords;
510
+ }
511
+ set totalRecords(e) {
512
+ const t = e == null ? null : Math.max(0, Math.floor(e));
513
+ this._totalRecords !== t && (this._totalRecords = t, this.requestUpdate());
514
+ }
515
+ /** True when the consumer is paging externally (totalRecords exceeds the in-memory rows). */
516
+ isExternallyPaged() {
517
+ return this._totalRecords != null && this._totalRecords > this._data.length;
518
+ }
519
+ attributeChangedCallback(e, t, s) {
520
+ if (super.attributeChangedCallback(e, t, s), e === "selection-mode") {
521
+ const r = s;
522
+ (r === "none" || r === "single" || r === "multiple") && (this.selectionMode = r);
523
+ } else if (e === "pagination")
524
+ this.pagination = s !== null;
525
+ else if (e === "resizable-columns")
526
+ this.resizableColumns = s !== null;
527
+ else if (e === "auto-sort")
528
+ this.autoSort = s !== "false";
529
+ else if (e === "empty-message")
530
+ this.emptyMessage = s ?? "No data";
531
+ else if (e === "virtual-scroll")
532
+ this.virtualScroll = s !== null;
533
+ else if (e === "item-size") {
534
+ const r = Number(s);
535
+ Number.isFinite(r) && (this.itemSize = r);
536
+ } else if (e === "tree")
537
+ this.tree = s !== null;
538
+ else if (e === "tree-indent") {
539
+ const r = Number(s);
540
+ Number.isFinite(r) && (this.treeIndent = r);
541
+ } else e === "selection-strategy" && (this.selectionStrategy = s === "cascading" ? "cascading" : "flat");
542
+ }
543
+ get resizableColumns() {
544
+ return this._resizableColumns;
545
+ }
546
+ set resizableColumns(e) {
547
+ this._resizableColumns = !!e, this.requestUpdate();
548
+ }
549
+ connectedCallback() {
550
+ super.connectedCallback();
551
+ }
552
+ firstUpdated() {
553
+ this._scrollElement = this.shadowRoot?.querySelector(".datatable-scroll"), this._scrollElement && (this._scrollListener = () => this.refreshVirtualRange(), this._scrollElement.addEventListener("scroll", this._scrollListener, { passive: !0 }), typeof ResizeObserver < "u" && (this._resizeObserver = new ResizeObserver(() => this.refreshVirtualRange()), this._resizeObserver.observe(this._scrollElement))), this.refreshVirtualRange();
554
+ }
555
+ willUpdate(e) {
556
+ super.willUpdate(e), this._cachedFlatList = null, this._cachedIndeterminateKeys = null;
557
+ }
558
+ updated(e) {
559
+ super.updated(e), this.refreshVirtualRange(), this.maybeMeasureInitialColumnWidths();
560
+ }
561
+ /**
562
+ * Run the auto-size-once pass after the first batch of rows lands in the
563
+ * DOM. Columns with an explicit `col.width` are pinned to that value
564
+ * without measurement; the rest are measured from their natural
565
+ * (`table-layout: auto`) width via `getBoundingClientRect()` on the
566
+ * `<th>`. Once any column gets a width, `_hasMeasuredInitial` flips and
567
+ * the table renders with `table-layout: fixed` so the widths are
568
+ * authoritative and overflowing content clips with ellipsis.
569
+ */
570
+ maybeMeasureInitialColumnWidths() {
571
+ if (this._hasMeasuredInitial || this._columns.length === 0 || this._data.length === 0 || !this.shadowRoot || this.shadowRoot.querySelectorAll('tbody tr[data-row-key]:not([data-placeholder="true"])').length === 0) return;
572
+ const t = new Map(this._columnWidths);
573
+ let s = !1;
574
+ for (const r of this._columns) {
575
+ if (t.has(r.name)) continue;
576
+ if (typeof r.width == "number") {
577
+ t.set(r.name, r.width), s = !0;
578
+ continue;
579
+ }
580
+ const i = this.measureColumnWidth(r.name);
581
+ i != null && (t.set(r.name, i), s = !0);
582
+ }
583
+ s && (this._columnWidths = t, this._hasMeasuredInitial = !0, this.requestUpdate());
584
+ }
585
+ measureColumnWidth(e) {
586
+ if (!this.shadowRoot) return null;
587
+ const t = this.shadowRoot.querySelector(`th[data-column="${e}"]`);
588
+ if (!t) return null;
589
+ const s = Math.ceil(t.getBoundingClientRect().width);
590
+ return s > 0 ? s : null;
591
+ }
592
+ disconnectedCallback() {
593
+ super.disconnectedCallback(), this._scrollElement && this._scrollListener && this._scrollElement.removeEventListener("scroll", this._scrollListener), this._scrollListener = null, this._resizeObserver?.disconnect(), this._resizeObserver = null, this._scrollElement = null;
594
+ }
595
+ refreshVirtualRange() {
596
+ if (!this._virtualScroll || !this._scrollElement) return;
597
+ const e = this._scrollElement.scrollTop, t = this._scrollElement.clientHeight;
598
+ this._viewportHeight = t;
599
+ const s = this.getEffectiveData().length, r = this._itemSize, i = Math.max(0, Math.floor(e / r) - this._virtualBuffer), a = Math.ceil(t / r), o = Math.min(s, i + a + this._virtualBuffer * 2);
600
+ (i !== this._virtualRange.startIndex || o !== this._virtualRange.endIndex) && (this._virtualRange = { startIndex: i, endIndex: o }, this.requestUpdate()), this._tree && this.maybeFetchPlaceholdersInViewport();
601
+ }
602
+ /**
603
+ * Walk the visible viewport for placeholder rows whose parent isn't cached
604
+ * and isn't already in-flight. Emit a fetch-request per such parent.
605
+ */
606
+ maybeFetchPlaceholdersInViewport() {
607
+ const e = this.getFlatList(), { startIndex: t, endIndex: s } = this._virtualRange, r = this._virtualScroll ? t : 0, i = this._virtualScroll ? s : e.length, a = /* @__PURE__ */ new Set();
608
+ for (let o = r; o < i; o++) {
609
+ const n = e[o];
610
+ !n.isPlaceholder || n.parentId == null || this._childCache.has(n.parentId) || this._pendingFetches.has(n.parentId) || a.add(n.parentId);
611
+ }
612
+ for (const o of a) this.requestChildrenFetch(o);
613
+ }
614
+ render() {
615
+ const e = this.computeVisibleRows(), t = this._totalRecords ?? this._data.length, s = this.pagination && !this._tree ? Math.max(1, Math.ceil(t / this._perPage)) : 1, r = this._selectionMode === "multiple", i = this._columns.length + (r ? 1 : 0) + (this._tree ? 1 : 0), a = this.getVirtualSpacerHeights(), o = (this._tree ? this.getFlatList().length : this._data.length) + 1;
616
+ return h`
617
+ <div class="datatable-shell">
618
+ <div class="datatable-scroll ${this._virtualScroll ? "datatable-virtual" : ""}" role="presentation">
619
+ <table
620
+ role=${this._tree ? "treegrid" : "grid"}
621
+ aria-rowcount=${o}
622
+ class=${this._hasMeasuredInitial ? "measured" : ""}
623
+ >
624
+ <thead>
625
+ <tr role="row" aria-rowindex="1">
626
+ ${this._tree ? h`<th class="tree-chevron-cell" scope="col" aria-label="Expand or collapse"></th>` : c}
627
+ ${r ? h`<th class="checkbox-cell" scope="col">
628
+ <mp-checkbox
629
+ aria-label="Deselect all"
630
+ aria-hidden=${this._selectedIds.size === 0 ? "true" : c}
631
+ style=${f({ visibility: this._selectedIds.size > 0 ? "visible" : "hidden" })}
632
+ .checked=${!1}
633
+ .indeterminate=${this._selectedIds.size > 0}
634
+ @change=${this.onDeselectAll}
635
+ ></mp-checkbox>
636
+ </th>` : c}
637
+ ${this._columns.map((n, d) => this.renderHeader(n, d))}
638
+ </tr>
639
+ </thead>
640
+ <tbody>
641
+ ${this._loading ? h`<tr><td colspan=${i} class="loading-state">Loading…</td></tr>` : e.length === 0 ? h`<tr><td colspan=${i} class="empty-state">${this._emptyMessage}</td></tr>` : h`
642
+ ${a.top > 0 ? h`<tr class="virtual-spacer" aria-hidden="true"><td colspan=${i} style=${f({ height: `${a.top}px`, padding: "0", border: "0" })}></td></tr>` : c}
643
+ ${$(
644
+ e,
645
+ ({ key: n }) => n,
646
+ ({ key: n, rowIndex: d, flat: g }) => this.renderRow(g, n, d, r)
647
+ )}
648
+ ${a.bottom > 0 ? h`<tr class="virtual-spacer" aria-hidden="true"><td colspan=${i} style=${f({ height: `${a.bottom}px`, padding: "0", border: "0" })}></td></tr>` : c}
649
+ `}
650
+ </tbody>
651
+ </table>
652
+ </div>
653
+ ${this._pagination && !this._tree ? this.renderFooter(s) : c}
654
+ </div>
655
+ `;
656
+ }
657
+ getVirtualSpacerHeights() {
658
+ if (!this._virtualScroll) return { top: 0, bottom: 0 };
659
+ const e = this.getEffectiveData().length, { startIndex: t, endIndex: s } = this._virtualRange;
660
+ return {
661
+ top: t * this._itemSize,
662
+ bottom: Math.max(0, (e - s) * this._itemSize)
663
+ };
664
+ }
665
+ renderHeader(e, t) {
666
+ const s = e.sortable ?? !0, r = this._sortColumns.findIndex((d) => d.property === e.name), i = r >= 0 ? this._sortColumns[r].direction : null, a = this._columnWidths.get(e.name) ?? e.width, o = e.headerRenderer ? e.headerRenderer(e) : e.label ?? e.name, n = {};
667
+ return typeof a == "number" && (n.width = `${a}px`, n.minWidth = `${a}px`), h`
668
+ <th
669
+ scope="col"
670
+ data-column=${e.name}
671
+ data-sortable=${s ? "true" : "false"}
672
+ aria-sort=${i ? i === "ascending" ? "ascending" : "descending" : "none"}
673
+ style=${f(n)}
674
+ @click=${(d) => this.onHeaderClick(e, d)}
675
+ >
676
+ <span class="header-cell">
677
+ <span>${x(o)}</span>
678
+ ${r >= 0 && this._sortColumns.length > 1 ? h`<span class="sort-index">${r + 1}</span>` : c}
679
+ </span>
680
+ ${this._resizableColumns ? h`<span
681
+ class="resize-handle"
682
+ role="separator"
683
+ aria-orientation="vertical"
684
+ aria-label="Resize column ${e.label ?? e.name}"
685
+ @pointerdown=${(d) => this.startColumnResize(e, d)}
686
+ ></span>` : c}
687
+ </th>
688
+ `;
689
+ }
690
+ renderRow(e, t, s, r) {
691
+ const { row: i, depth: a, isExpanded: o, isPlaceholder: n } = e, d = !n && this._selectedIds.has(t), g = !n && this._cutIds.has(t), _ = !n && this._focusedRowKey === t, p = n ? 0 : this.extractChildCount(i), m = this._tree && !n && p > 0, y = !n && i != null && this.isParentIndeterminate(i);
692
+ return h`
693
+ <tr
694
+ role="row"
695
+ aria-rowindex=${s + 2}
696
+ aria-level=${this._tree ? a + 1 : c}
697
+ aria-expanded=${this._tree && p > 0 ? o ? "true" : "false" : c}
698
+ aria-busy=${n ? "true" : c}
699
+ aria-selected=${!n && this._selectionMode !== "none" ? d ? "true" : "false" : c}
700
+ data-row-key=${t}
701
+ data-selected=${d ? "true" : "false"}
702
+ data-cut=${g ? "true" : "false"}
703
+ data-focused=${_ ? "true" : "false"}
704
+ data-placeholder=${n ? "true" : "false"}
705
+ data-depth=${this._tree ? String(a) : c}
706
+ data-clickable=${!n && (this._selectionMode !== "none" || this.hasRowClickListeners()) ? "true" : "false"}
707
+ @click=${n ? null : (u) => this.onRowClick(i, t, s, u)}
708
+ @dblclick=${n ? null : (u) => this.onRowDblClick(i, t, s, u)}
709
+ @contextmenu=${n ? null : (u) => this.onRowContextMenu(i, t, s, u)}
710
+ @keydown=${this._tree && !n ? (u) => this.onRowKeydown(i, e.parentId, a, o, p, u) : null}
711
+ >
712
+ ${this._tree ? h`<td class="tree-chevron-cell" style=${f({ paddingInlineStart: `${a * this._treeIndent}rem` })}>
713
+ ${m ? h`<button
714
+ type="button"
715
+ class="tree-chevron"
716
+ aria-label=${o ? "Collapse row" : "Expand row"}
717
+ aria-expanded=${o ? "true" : "false"}
718
+ data-expanded=${o ? "true" : "false"}
719
+ @click=${(u) => this.toggleExpand(i, e.parentId, a, u)}
720
+ >${o ? "▾" : "▸"}</button>` : c}
721
+ </td>` : c}
722
+ ${r ? h`<td class="checkbox-cell" @click=${(u) => u.stopPropagation()}>
723
+ ${n ? c : h`<mp-checkbox
724
+ aria-label=${`Select row ${s + 1}`}
725
+ .checked=${d}
726
+ .indeterminate=${y}
727
+ @change=${(u) => this.onRowCheckboxToggle(i, t, s, u)}
728
+ ></mp-checkbox>`}
729
+ </td>` : c}
730
+ ${this._rowRenderer ? this.renderRowFromRenderer(i, s, { depth: a, isExpanded: o, isPlaceholder: n }) : n ? h`<td colspan=${this._columns.length} class="tree-placeholder-cell" aria-label="Loading">…</td>` : this._columns.map((u) => this.renderCell(i, u, s))}
731
+ </tr>
732
+ `;
733
+ }
734
+ renderRowFromRenderer(e, t, s) {
735
+ const r = this._rowRenderer(e, t, s);
736
+ if (r == null)
737
+ return s.isPlaceholder ? h`<td colspan=${this._columns.length} class="tree-placeholder-cell" aria-label="Loading">…</td>` : this._columns.map((i) => this.renderCell(e, i, t));
738
+ if (Array.isArray(r) || P(r)) {
739
+ const i = [];
740
+ for (const a of r) i.push(a);
741
+ return i;
742
+ }
743
+ return r;
744
+ }
745
+ renderCell(e, t, s) {
746
+ const r = t.cellRenderer ? t.cellRenderer(e, t, s) : K(e, t);
747
+ return h`<td class=${t.cellClass ?? ""} data-column=${t.name}>${x(r)}</td>`;
748
+ }
749
+ renderFooter(e) {
750
+ const t = Array.from({ length: e }, (s, r) => r + 1);
751
+ return h`
752
+ <div class="datatable-footer">
753
+ <mp-pagination
754
+ class="datatable-per-page"
755
+ aria-label="Rows per page"
756
+ .pageNumbers=${this._perPageOptions}
757
+ .selectedPageNumber=${this._perPage}
758
+ .showArrows=${!1}
759
+ @mp-pagination-page-change=${(s) => this.setPerPage(s.detail.page)}
760
+ ></mp-pagination>
761
+ <mp-pagination
762
+ class="datatable-pagination"
763
+ .pageNumbers=${t}
764
+ .selectedPageNumber=${this._page}
765
+ .numberOfBoxes=${7}
766
+ .showArrows=${!0}
767
+ @mp-pagination-page-change=${(s) => this.gotoPage(s.detail.page)}
768
+ ></mp-pagination>
769
+ </div>
770
+ `;
771
+ }
772
+ setPerPage(e) {
773
+ const t = Math.max(1, Math.floor(e || 1));
774
+ this._perPage !== t && (this._perPage = t, this._page = 1, this.requestUpdate(), this.dispatchEvent(
775
+ new CustomEvent("mp-datatable-per-page-change", {
776
+ detail: { perPage: t },
777
+ bubbles: !0,
778
+ composed: !0
779
+ })
780
+ ), this.dispatchEvent(
781
+ new CustomEvent("mp-datatable-page-change", {
782
+ detail: { page: 1 },
783
+ bubbles: !0,
784
+ composed: !0
785
+ })
786
+ ));
787
+ }
788
+ getEffectiveData() {
789
+ if (this._tree)
790
+ return this.getFlatList().map((t) => t.row);
791
+ let e = this._data;
792
+ if (this._autoSort && this._sortColumns.length > 0 && (e = b(e, this._sortColumns)), this._pagination && !this.isExternallyPaged()) {
793
+ const t = (this._page - 1) * this._perPage;
794
+ e = e.slice(t, t + this._perPage);
795
+ }
796
+ return e;
797
+ }
798
+ /**
799
+ * Flat list of visible rows including expansion + placeholders. Computed
800
+ * each render in tree mode; flat mode produces a trivial mapping of `_data`
801
+ * (after sort+pagination) with default metadata.
802
+ *
803
+ * Memoised via `_cachedFlatList`, cleared in `willUpdate`. Multiple calls
804
+ * during the same render cycle (`computeVisibleRows`,
805
+ * `getVirtualSpacerHeights`, aria-rowcount) share one computation.
806
+ */
807
+ getFlatList() {
808
+ if (this._cachedFlatList !== null) return this._cachedFlatList;
809
+ if (!this._tree) {
810
+ const r = (() => {
811
+ let i = this._data;
812
+ if (this._autoSort && this._sortColumns.length > 0 && (i = b(i, this._sortColumns)), this._pagination && !this.isExternallyPaged()) {
813
+ const a = (this._page - 1) * this._perPage;
814
+ i = i.slice(a, a + this._perPage);
815
+ }
816
+ return i;
817
+ })();
818
+ return this._cachedFlatList = r.map((i, a) => ({
819
+ row: i,
820
+ key: this._rowKey(i, a),
821
+ depth: 0,
822
+ parentId: null,
823
+ isExpanded: !1,
824
+ isPlaceholder: !1
825
+ }));
826
+ }
827
+ const e = [], t = this._autoSort && this._sortColumns.length > 0 ? b(this._data, this._sortColumns) : this._data, s = (r, i, a) => {
828
+ for (const o of r) {
829
+ const n = this.extractId(o), d = n != null && this._expandedIds.has(n), g = this.extractChildCount(o), _ = this._rowKey(o, e.length);
830
+ if (e.push({ row: o, key: _, depth: i, parentId: a, isExpanded: d, isPlaceholder: !1 }), !d || g === 0 || n == null) continue;
831
+ const p = this._childCache.get(n);
832
+ if (p && p.length > 0) {
833
+ const m = this._autoSort && this._sortColumns.length > 0 ? b(p, this._sortColumns) : p;
834
+ s(m, i + 1, n);
835
+ const y = this._childTotals.get(n) ?? p.length, u = Math.max(0, y - p.length);
836
+ for (let v = 0; v < u; v++)
837
+ e.push({
838
+ row: void 0,
839
+ key: `__placeholder-${String(n)}-${p.length + v}`,
840
+ depth: i + 1,
841
+ parentId: n,
842
+ isExpanded: !1,
843
+ isPlaceholder: !0
844
+ });
845
+ } else
846
+ for (let m = 0; m < g; m++)
847
+ e.push({
848
+ row: void 0,
849
+ key: `__placeholder-${String(n)}-${m}`,
850
+ depth: i + 1,
851
+ parentId: n,
852
+ isExpanded: !1,
853
+ isPlaceholder: !0
854
+ });
855
+ }
856
+ };
857
+ return s(t, 0, null), this._cachedFlatList = e;
858
+ }
859
+ computeVisibleRows() {
860
+ const e = this.getFlatList(), t = this._tree ? 0 : this._pagination ? (this._page - 1) * this._perPage : 0;
861
+ let s = e, r = 0;
862
+ if (this._virtualScroll) {
863
+ const { startIndex: i, endIndex: a } = this._virtualRange;
864
+ s = e.slice(i, a), r = i;
865
+ }
866
+ return s.map((i, a) => {
867
+ const o = t + r + a;
868
+ return { row: i.row, rowIndex: o, key: i.key, flat: i };
869
+ });
870
+ }
871
+ // ─── Tree-mode helpers ───────────────────────────────────────────────────
872
+ extractId(e) {
873
+ return !this._idKey || e == null || typeof e != "object" ? null : typeof this._idKey == "function" ? this._idKey(e) : e[this._idKey];
874
+ }
875
+ extractChildCount(e) {
876
+ if (!this._childCountKey || e == null || typeof e != "object") return 0;
877
+ const t = e[this._childCountKey];
878
+ return typeof t == "number" && t > 0 ? t : 0;
879
+ }
880
+ /** Walks the loaded subtree of `row` and returns the rowKey for every descendant. */
881
+ collectDescendantKeys(e) {
882
+ const t = this.extractId(e), s = t != null ? this._childCache.get(t) : void 0;
883
+ if (!s) return [];
884
+ const r = [];
885
+ for (const i of s) {
886
+ r.push(this._rowKey(i, -1));
887
+ const a = this.collectDescendantKeys(i);
888
+ for (const o of a) r.push(o);
889
+ }
890
+ return r;
891
+ }
892
+ /** Some-but-not-all loaded descendants selected → indeterminate parent checkbox. */
893
+ isParentIndeterminate(e) {
894
+ return this._selectionStrategy !== "cascading" || e == null ? !1 : this.getIndeterminateKeys().has(this._rowKey(e, -1));
895
+ }
896
+ /**
897
+ * Per-render memo: the set of row keys whose loaded subtree is partially
898
+ * selected. Built in one DFS over `_childCache` so each loaded parent is
899
+ * visited exactly once per render. Replaces the previous
900
+ * `collectDescendantKeys`-per-visible-row recursion which was O(visible ×
901
+ * descendants) per render.
902
+ */
903
+ getIndeterminateKeys() {
904
+ if (this._cachedIndeterminateKeys !== null) return this._cachedIndeterminateKeys;
905
+ const e = /* @__PURE__ */ new Set();
906
+ if (this._selectionStrategy !== "cascading" || !this._tree)
907
+ return this._cachedIndeterminateKeys = e;
908
+ const t = (s) => {
909
+ const r = this.extractId(s);
910
+ if (r == null) return { selected: 0, total: 0 };
911
+ const i = this._childCache.get(r);
912
+ if (!i || i.length === 0) return { selected: 0, total: 0 };
913
+ let a = 0, o = 0;
914
+ for (const n of i) {
915
+ const d = this._rowKey(n, -1), g = this._selectedIds.has(d) ? 1 : 0, _ = t(n);
916
+ a += g + _.selected, o += 1 + _.total;
917
+ }
918
+ return o > 0 && a > 0 && a < o && e.add(this._rowKey(s, -1)), { selected: a, total: o };
919
+ };
920
+ for (const s of this._data) t(s);
921
+ return this._cachedIndeterminateKeys = e;
922
+ }
923
+ /**
924
+ * Toggle a row's expanded state. On expand, fires a fetch-request event if
925
+ * children aren't cached yet so the wrapper can bridge to the consumer's
926
+ * `[fetch]` callback. Always fires `expanded-ids-change`.
927
+ */
928
+ toggleExpand(e, t, s, r) {
929
+ r.stopPropagation(), r.preventDefault();
930
+ const i = this.extractId(e);
931
+ if (i == null) return;
932
+ const a = new Set(this._expandedIds);
933
+ let o;
934
+ a.has(i) ? (a.delete(i), o = !1) : (a.add(i), o = !0), this._expandedIds = a, o ? (this.dispatchEvent(
935
+ new CustomEvent("mp-datatable-row-expand", {
936
+ detail: { row: e, depth: s, parentId: t },
937
+ bubbles: !0,
938
+ composed: !0
939
+ })
940
+ ), this.extractChildCount(e) > 0 && !this._childCache.has(i) && !this._pendingFetches.has(i) && this.requestChildrenFetch(i)) : this.dispatchEvent(
941
+ new CustomEvent("mp-datatable-row-collapse", {
942
+ detail: { row: e, depth: s, parentId: t },
943
+ bubbles: !0,
944
+ composed: !0
945
+ })
946
+ ), this.emitExpandedIdsChange(), this.requestUpdate();
947
+ }
948
+ emitExpandedIdsChange() {
949
+ this.dispatchEvent(
950
+ new CustomEvent("mp-datatable-expanded-ids-change", {
951
+ detail: { expandedIds: new Set(this._expandedIds) },
952
+ bubbles: !0,
953
+ composed: !0
954
+ })
955
+ );
956
+ }
957
+ /** Emit a fetch-request event the wrapper will bridge to the consumer's `[fetch]`. */
958
+ requestChildrenFetch(e) {
959
+ e != null && this._pendingFetches.add(e), this.dispatchEvent(
960
+ new CustomEvent("mp-datatable-fetch-request", {
961
+ detail: {
962
+ parentId: e,
963
+ page: 1,
964
+ perPage: this._perPage,
965
+ sortColumns: [...this._sortColumns]
966
+ },
967
+ bubbles: !0,
968
+ composed: !0
969
+ })
970
+ );
971
+ }
972
+ /**
973
+ * Public method called by the framework wrapper after the consumer's
974
+ * `[fetch]` callback resolves. Populates the cache + total for the parent,
975
+ * clears the pending flag, and rerenders so placeholders disappear.
976
+ */
977
+ setFetchResponse(e, t) {
978
+ e != null && (this._pendingFetches.delete(e), this._childCache.set(e, [...t.data]), this._childTotals.set(e, t.totalRecords), this.requestUpdate());
979
+ }
980
+ /** Drop cached children for one parent (or all). Used on sort change / refresh. */
981
+ invalidateChildren(e) {
982
+ e === void 0 ? (this._childCache.clear(), this._childTotals.clear(), this._pendingFetches.clear()) : (this._childCache.delete(e), this._childTotals.delete(e), this._pendingFetches.delete(e)), this.requestUpdate();
983
+ }
984
+ /** Keyboard handling on a tree-mode row. Arrow keys + Enter/Space toggle expansion. */
985
+ onRowKeydown(e, t, s, r, i, a) {
986
+ a.key === "ArrowRight" && i > 0 && !r ? this.toggleExpand(e, t, s, a) : a.key === "ArrowLeft" && r ? this.toggleExpand(e, t, s, a) : (a.key === "Enter" || a.key === " ") && i > 0 && this.toggleExpand(e, t, s, a);
987
+ }
988
+ hasRowClickListeners() {
989
+ return !0;
990
+ }
991
+ onHeaderClick(e, t) {
992
+ if (!(e.sortable ?? !0) || t.target.closest(".resize-handle")) return;
993
+ const i = R(this._sortColumns, e.name, t.shiftKey);
994
+ this._sortColumns = i, this.requestUpdate(), this.dispatchEvent(
995
+ new CustomEvent("mp-datatable-sort-change", {
996
+ detail: { sortColumns: i },
997
+ bubbles: !0,
998
+ composed: !0
999
+ })
1000
+ );
1001
+ }
1002
+ onRowClick(e, t, s, r) {
1003
+ r.target.closest('input[type="checkbox"]') || (this._focusedRowKey = t, this.handleSelectionOnClick(t, r), this.requestUpdate(), this.dispatchEvent(
1004
+ new CustomEvent("mp-datatable-row-click", {
1005
+ detail: { row: e, rowIndex: s, rowKey: t, originalEvent: r },
1006
+ bubbles: !0,
1007
+ composed: !0
1008
+ })
1009
+ ));
1010
+ }
1011
+ onRowDblClick(e, t, s, r) {
1012
+ this.dispatchEvent(
1013
+ new CustomEvent("mp-datatable-row-dblclick", {
1014
+ detail: { row: e, rowIndex: s, rowKey: t, originalEvent: r },
1015
+ bubbles: !0,
1016
+ composed: !0
1017
+ })
1018
+ );
1019
+ }
1020
+ onRowContextMenu(e, t, s, r) {
1021
+ this._selectionMode !== "none" && !this._selectedIds.has(t) && (this._selectedIds = /* @__PURE__ */ new Set([t]), this._focusedRowKey = t, this.emitSelectionChange(), this.requestUpdate()), this.dispatchEvent(
1022
+ new CustomEvent("mp-datatable-row-contextmenu", {
1023
+ detail: { row: e, rowIndex: s, rowKey: t, originalEvent: r },
1024
+ bubbles: !0,
1025
+ composed: !0,
1026
+ cancelable: !0
1027
+ })
1028
+ );
1029
+ }
1030
+ onRowCheckboxToggle(e, t, s, r) {
1031
+ if (this._selectionMode !== "none") {
1032
+ if (this._selectionMode === "single")
1033
+ this._selectedIds = /* @__PURE__ */ new Set([t]);
1034
+ else {
1035
+ const i = new Set(this._selectedIds), a = !i.has(t);
1036
+ if (a ? i.add(t) : i.delete(t), this._tree && this._selectionStrategy === "cascading" && e != null) {
1037
+ const o = this.collectDescendantKeys(e);
1038
+ if (a)
1039
+ for (const n of o) i.add(n);
1040
+ else
1041
+ for (const n of o) i.delete(n);
1042
+ }
1043
+ this._selectedIds = i;
1044
+ }
1045
+ this.emitSelectionChange(), this.requestUpdate();
1046
+ }
1047
+ }
1048
+ /**
1049
+ * Clears the entire selection. The header checkbox is only rendered when
1050
+ * at least one row is selected — a true "select all" affordance would be
1051
+ * misleading because the WC doesn't know about rows outside the current
1052
+ * pagination slice or virtual-scroll window. Click semantics are
1053
+ * therefore one-way: visible → deselect-all → hidden again.
1054
+ */
1055
+ onDeselectAll() {
1056
+ this._selectedIds.size !== 0 && (this._selectedIds = /* @__PURE__ */ new Set(), this.emitSelectionChange(), this.requestUpdate());
1057
+ }
1058
+ handleSelectionOnClick(e, t) {
1059
+ if (this._selectionMode !== "none") {
1060
+ if (this._selectionMode === "single") {
1061
+ this._selectedIds = /* @__PURE__ */ new Set([e]), this.emitSelectionChange();
1062
+ return;
1063
+ }
1064
+ if (t.shiftKey && this._focusedRowKey && this._focusedRowKey !== e) {
1065
+ const s = this.computeVisibleRows(), r = s.findIndex((a) => a.key === this._focusedRowKey), i = s.findIndex((a) => a.key === e);
1066
+ if (r >= 0 && i >= 0) {
1067
+ const [a, o] = r < i ? [r, i] : [i, r], n = s.slice(a, o + 1).map((d) => d.key);
1068
+ this._selectedIds = /* @__PURE__ */ new Set([...this._selectedIds, ...n]), this.emitSelectionChange();
1069
+ return;
1070
+ }
1071
+ }
1072
+ if (t.ctrlKey || t.metaKey) {
1073
+ const s = new Set(this._selectedIds);
1074
+ s.has(e) ? s.delete(e) : s.add(e), this._selectedIds = s, this.emitSelectionChange();
1075
+ return;
1076
+ }
1077
+ this._selectedIds = /* @__PURE__ */ new Set([e]), this.emitSelectionChange();
1078
+ }
1079
+ }
1080
+ emitSelectionChange() {
1081
+ this.dispatchEvent(
1082
+ new CustomEvent("mp-datatable-selection-change", {
1083
+ detail: { selectedIds: [...this._selectedIds] },
1084
+ bubbles: !0,
1085
+ composed: !0
1086
+ })
1087
+ );
1088
+ }
1089
+ gotoPage(e) {
1090
+ const t = this._totalRecords ?? this._data.length, s = Math.max(1, Math.ceil(t / this._perPage));
1091
+ this._page = Math.max(1, Math.min(s, e)), this.requestUpdate(), this.dispatchEvent(
1092
+ new CustomEvent("mp-datatable-page-change", {
1093
+ detail: { page: this._page },
1094
+ bubbles: !0,
1095
+ composed: !0
1096
+ })
1097
+ );
1098
+ }
1099
+ startColumnResize(e, t) {
1100
+ if (!this._resizableColumns) return;
1101
+ t.preventDefault(), t.stopPropagation();
1102
+ const s = t.currentTarget, r = s.closest("th");
1103
+ if (!r) return;
1104
+ const i = r.getBoundingClientRect().width;
1105
+ this.resizeState = { columnName: e.name, startX: t.clientX, startWidth: i, handle: s }, s.classList.add("active"), s.setPointerCapture(t.pointerId), s.addEventListener("pointermove", this.onColumnResizeMove), s.addEventListener("pointerup", this.onColumnResizeEnd), s.addEventListener("pointercancel", this.onColumnResizeEnd);
1106
+ }
1107
+ }
1108
+ function K(l, e) {
1109
+ if (l == null || typeof l != "object") return "";
1110
+ const t = l[e.name];
1111
+ return t == null ? "" : String(t);
1112
+ }
1113
+ function P(l) {
1114
+ return l != null && typeof l != "string" && typeof l[Symbol.iterator] == "function";
1115
+ }
1116
+ function x(l) {
1117
+ return l == null || l === !1 ? c : (l instanceof Node || typeof l == "object" && "_$litType$" in l, l);
1118
+ }
1119
+ typeof customElements < "u" && !customElements.get("mp-datatable") && customElements.define("mp-datatable", M);
1120
+ export {
1121
+ M,
1122
+ R as c,
1123
+ I as d,
1124
+ b as s
1125
+ };