@schukai/monster 3.55.0 → 3.55.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/package.json +1 -1
  3. package/source/components/datatable/datasource/rest.mjs +77 -46
  4. package/source/components/datatable/datatable/header.mjs +1 -1
  5. package/source/components/datatable/datatable.mjs +586 -591
  6. package/source/components/datatable/embedded-pagination.mjs +42 -49
  7. package/source/components/datatable/filter/util.mjs +115 -99
  8. package/source/components/datatable/filter.mjs +905 -842
  9. package/source/components/datatable/pagination.mjs +333 -334
  10. package/source/components/datatable/status.mjs +134 -156
  11. package/source/components/datatable/stylesheet/column-bar.mjs +14 -8
  12. package/source/components/datatable/stylesheet/dataset.mjs +14 -8
  13. package/source/components/datatable/stylesheet/datasource.mjs +14 -8
  14. package/source/components/datatable/stylesheet/datatable.mjs +14 -8
  15. package/source/components/datatable/stylesheet/embedded-pagination.mjs +14 -8
  16. package/source/components/datatable/stylesheet/filter-button.mjs +14 -8
  17. package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +14 -8
  18. package/source/components/datatable/stylesheet/filter-date-range.mjs +14 -8
  19. package/source/components/datatable/stylesheet/filter-range.mjs +14 -8
  20. package/source/components/datatable/stylesheet/filter.mjs +14 -8
  21. package/source/components/datatable/stylesheet/pagination.mjs +14 -8
  22. package/source/components/datatable/stylesheet/select-filter.mjs +14 -8
  23. package/source/components/datatable/stylesheet/status.mjs +14 -8
  24. package/source/components/form/action-button.mjs +3 -1
  25. package/source/components/form/confirm-button.mjs +3 -1
  26. package/source/components/form/context-error.mjs +161 -164
  27. package/source/components/form/context-help.mjs +3 -1
  28. package/source/components/form/form.mjs +3 -1
  29. package/source/components/form/message-state-button.mjs +3 -1
  30. package/source/components/form/popper-button.mjs +6 -4
  31. package/source/components/form/popper.mjs +310 -310
  32. package/source/components/form/select.mjs +2 -2
  33. package/source/components/form/state-button.mjs +3 -1
  34. package/source/components/form/stylesheet/action-button.mjs +14 -8
  35. package/source/components/form/stylesheet/api-button.mjs +14 -8
  36. package/source/components/form/stylesheet/button-bar.mjs +14 -8
  37. package/source/components/form/stylesheet/button.mjs +14 -8
  38. package/source/components/form/stylesheet/confirm-button.mjs +14 -8
  39. package/source/components/form/stylesheet/context-error.mjs +14 -8
  40. package/source/components/form/stylesheet/context-help.mjs +14 -8
  41. package/source/components/form/stylesheet/form.mjs +14 -8
  42. package/source/components/form/stylesheet/message-state-button.mjs +14 -8
  43. package/source/components/form/stylesheet/popper-button.mjs +14 -8
  44. package/source/components/form/stylesheet/popper.mjs +14 -8
  45. package/source/components/form/stylesheet/select.mjs +14 -8
  46. package/source/components/form/stylesheet/state-button.mjs +14 -8
  47. package/source/components/form/stylesheet/tabs.mjs +14 -8
  48. package/source/components/form/stylesheet/tree-select.mjs +14 -8
  49. package/source/components/form/tabs.mjs +754 -758
  50. package/source/components/host/collapse.mjs +2 -4
  51. package/source/components/host/config-manager.mjs +11 -9
  52. package/source/components/host/stylesheet/call-button.mjs +14 -8
  53. package/source/components/host/stylesheet/collapse.mjs +14 -8
  54. package/source/components/host/stylesheet/config-manager.mjs +14 -8
  55. package/source/components/host/stylesheet/details.mjs +14 -8
  56. package/source/components/host/stylesheet/host.mjs +14 -8
  57. package/source/components/host/stylesheet/overlay.mjs +14 -8
  58. package/source/components/host/stylesheet/toggle-button.mjs +14 -8
  59. package/source/components/host/stylesheet/viewer.mjs +14 -8
  60. package/source/components/host/util.mjs +2 -2
  61. package/source/components/notify/stylesheet/message.mjs +14 -8
  62. package/source/components/notify/stylesheet/notify.mjs +14 -8
  63. package/source/components/state/stylesheet/log.mjs +14 -8
  64. package/source/components/state/stylesheet/state.mjs +14 -8
  65. package/source/components/stylesheet/badge.mjs +14 -8
  66. package/source/components/stylesheet/border.mjs +14 -8
  67. package/source/components/stylesheet/button.mjs +14 -8
  68. package/source/components/stylesheet/card.mjs +14 -8
  69. package/source/components/stylesheet/color.mjs +14 -8
  70. package/source/components/stylesheet/common.mjs +14 -8
  71. package/source/components/stylesheet/control.mjs +14 -8
  72. package/source/components/stylesheet/data-grid.mjs +14 -8
  73. package/source/components/stylesheet/display.mjs +14 -8
  74. package/source/components/stylesheet/floating-ui.mjs +14 -8
  75. package/source/components/stylesheet/form.mjs +14 -8
  76. package/source/components/stylesheet/host.mjs +14 -8
  77. package/source/components/stylesheet/icons.mjs +14 -8
  78. package/source/components/stylesheet/link.mjs +14 -8
  79. package/source/components/stylesheet/normalize.mjs +14 -8
  80. package/source/components/stylesheet/popper.mjs +14 -8
  81. package/source/components/stylesheet/property.mjs +14 -8
  82. package/source/components/stylesheet/ripple.mjs +14 -8
  83. package/source/components/stylesheet/skeleton.mjs +14 -8
  84. package/source/components/stylesheet/space.mjs +14 -8
  85. package/source/components/stylesheet/spinner.mjs +14 -8
  86. package/source/components/stylesheet/table.mjs +14 -8
  87. package/source/components/stylesheet/theme.mjs +14 -8
  88. package/source/components/stylesheet/typography.mjs +14 -8
  89. package/source/components/tree-menu/stylesheet/tree-menu.mjs +14 -8
  90. package/source/data/datasource/server/restapi.mjs +1 -0
  91. package/source/data/transformer.mjs +6 -8
  92. package/source/dom/attributes.mjs +5 -5
  93. package/source/dom/customelement.mjs +2 -2
  94. package/source/dom/updater.mjs +697 -700
  95. package/source/dom/util.mjs +2 -2
  96. package/source/monster.mjs +0 -1
  97. package/source/types/noderecursiveiterator.mjs +9 -7
  98. package/source/types/version.mjs +1 -1
  99. package/source/util/sleep.mjs +3 -4
  100. package/test/cases/monster.mjs +1 -1
@@ -3,63 +3,63 @@
3
3
  * SPDX-License-Identifier: AGPL-3.0
4
4
  */
5
5
 
6
- import {Datasource} from "./datasource.mjs";
6
+ import { Datasource } from "./datasource.mjs";
7
7
  import {
8
- assembleMethodSymbol,
9
- CustomElement,
10
- registerCustomElement,
11
- getSlottedElements,
8
+ assembleMethodSymbol,
9
+ CustomElement,
10
+ registerCustomElement,
11
+ getSlottedElements,
12
12
  } from "../../dom/customelement.mjs";
13
- import {findTargetElementFromEvent} from "../../dom/events.mjs";
13
+ import { findTargetElementFromEvent } from "../../dom/events.mjs";
14
14
  import {
15
- isString,
16
- isFunction,
17
- isInstance,
18
- isObject,
19
- isArray,
15
+ isString,
16
+ isFunction,
17
+ isInstance,
18
+ isObject,
19
+ isArray,
20
20
  } from "../../types/is.mjs";
21
- import {Observer} from "../../types/observer.mjs";
21
+ import { Observer } from "../../types/observer.mjs";
22
22
  import {
23
- ATTRIBUTE_DATATABLE_HEAD,
24
- ATTRIBUTE_DATATABLE_GRID_TEMPLATE,
25
- ATTRIBUTE_DATASOURCE_SELECTOR,
26
- ATTRIBUTE_DATATABLE_ALIGN,
27
- ATTRIBUTE_DATATABLE_SORTABLE,
28
- ATTRIBUTE_DATATABLE_MODE,
29
- ATTRIBUTE_DATATABLE_INDEX,
30
- ATTRIBUTE_DATATABLE_MODE_HIDDEN,
31
- ATTRIBUTE_DATATABLE_MODE_VISIBLE,
32
- ATTRIBUTE_DATATABLE_RESPONSIVE_BREAKPOINT,
33
- ATTRIBUTE_DATATABLE_MODE_FIXED,
23
+ ATTRIBUTE_DATATABLE_HEAD,
24
+ ATTRIBUTE_DATATABLE_GRID_TEMPLATE,
25
+ ATTRIBUTE_DATASOURCE_SELECTOR,
26
+ ATTRIBUTE_DATATABLE_ALIGN,
27
+ ATTRIBUTE_DATATABLE_SORTABLE,
28
+ ATTRIBUTE_DATATABLE_MODE,
29
+ ATTRIBUTE_DATATABLE_INDEX,
30
+ ATTRIBUTE_DATATABLE_MODE_HIDDEN,
31
+ ATTRIBUTE_DATATABLE_MODE_VISIBLE,
32
+ ATTRIBUTE_DATATABLE_RESPONSIVE_BREAKPOINT,
33
+ ATTRIBUTE_DATATABLE_MODE_FIXED,
34
34
  } from "./constants.mjs";
35
- import {instanceSymbol} from "../../constants.mjs";
35
+ import { instanceSymbol } from "../../constants.mjs";
36
36
  import {
37
- Header,
38
- createOrderStatement,
39
- DIRECTION_ASC,
40
- DIRECTION_DESC,
41
- DIRECTION_NONE,
37
+ Header,
38
+ createOrderStatement,
39
+ DIRECTION_ASC,
40
+ DIRECTION_DESC,
41
+ DIRECTION_NONE,
42
42
  } from "./datatable/header.mjs";
43
- import {getStoredFilterConfigKey} from "./filter/util.mjs";
44
- import {DatatableStyleSheet} from "./stylesheet/datatable.mjs";
43
+ import { getStoredFilterConfigKey } from "./filter/util.mjs";
44
+ import { DatatableStyleSheet } from "./stylesheet/datatable.mjs";
45
45
  import {
46
- handleDataSourceChanges,
47
- datasourceLinkedElementSymbol,
46
+ handleDataSourceChanges,
47
+ datasourceLinkedElementSymbol,
48
48
  } from "./util.mjs";
49
49
  import "./columnbar.mjs";
50
50
  import "./filter-button.mjs";
51
- import {getDocument, getWindow} from "../../dom/util.mjs";
52
- import {addAttributeToken} from "../../dom/attributes.mjs";
53
- import {ATTRIBUTE_ERRORMESSAGE} from "../../dom/constants.mjs";
54
- import {getDocumentTranslations} from "../../i18n/translations.mjs";
51
+ import { getDocument, getWindow } from "../../dom/util.mjs";
52
+ import { addAttributeToken } from "../../dom/attributes.mjs";
53
+ import { ATTRIBUTE_ERRORMESSAGE } from "../../dom/constants.mjs";
54
+ import { getDocumentTranslations } from "../../i18n/translations.mjs";
55
55
  import "../state/state.mjs";
56
56
  import "../host/collapse.mjs";
57
- import {generateUniqueConfigKey} from "../host/util.mjs";
57
+ import { generateUniqueConfigKey } from "../host/util.mjs";
58
58
 
59
59
  import "./datasource/dom.mjs";
60
60
  import "./datasource/rest.mjs";
61
61
 
62
- export {DataTable};
62
+ export { DataTable };
63
63
 
64
64
  /**
65
65
  * @private
@@ -120,210 +120,209 @@ const columnBarElementSymbol = Symbol("columnBarElement");
120
120
  * @summary A data table
121
121
  */
122
122
  class DataTable extends CustomElement {
123
- /**
124
- * This method is called by the `instanceof` operator.
125
- * @returns {symbol}
126
- */
127
- static get [instanceSymbol]() {
128
- return Symbol.for("@schukai/monster/components/datatable@@instance");
129
- }
130
-
131
- /**
132
- * To set the options via the html tag the attribute `data-monster-options` must be used.
133
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
134
- *
135
- * The individual configuration values can be found in the table.
136
- *
137
- * @property {Object} templates Template definitions
138
- * @property {string} templates.main Main template
139
- * @property {Object} datasource Datasource configuration
140
- * @property {string} datasource.selector Selector for the datasource
141
- * @property {Object} mapping Mapping configuration
142
- * @property {string} mapping.data Data mapping
143
- * @property {Array} data Data
144
- * @property {Array} headers Headers
145
- * @property {Object} responsive Responsive configuration
146
- * @property {number} responsive.breakpoint Breakpoint for responsive mode
147
- * @property {Object} labels Labels
148
- * @property {string} labels.theListContainsNoEntries Label for empty state
149
- * @property {Object} features Features
150
- * @property {boolean} features.settings Settings feature
151
- * @property {boolean} features.footer Footer feature
152
- * @property {boolean} features.autoInit Auto init feature (init datasource automatically)
153
- * @property {Object} templateMapping Template mapping
154
- * @property {string} templateMapping.row-key Row key
155
- * @property {string} templateMapping.filter-id Filter id
156
- **/
157
- get defaults() {
158
- return Object.assign(
159
- {},
160
- super.defaults,
161
- {
162
- templates: {
163
- main: getTemplate(),
164
- emptyState: getEmptyTemplate()
165
- },
166
-
167
- datasource: {
168
- selector: null,
169
- },
170
-
171
- mapping: {
172
- data: "dataset",
173
- },
174
-
175
- data: [],
176
- headers: [],
177
-
178
- responsive: {
179
- breakpoint: 800,
180
- },
181
-
182
- labels: {
183
- theListContainsNoEntries: "The list contains no entries",
184
- },
185
-
186
- features: {
187
- settings: true,
188
- footer: true,
189
- autoInit: true,
190
- },
191
-
192
- templateMapping: {
193
- "row-key": null,
194
- "filter-id": null,
195
- },
196
- },
197
- initOptionsFromArguments.call(this),
198
- );
199
- }
200
-
201
- /**
202
- *
203
- * @param {string} selector
204
- * @returns {NodeListOf<*>}
205
- */
206
- getGridElements(selector) {
207
- return this[gridElementSymbol].querySelectorAll(selector);
208
- }
209
-
210
- /**
211
- *
212
- * @return {string}
213
- */
214
- static getTag() {
215
- return "monster-datatable";
216
- }
217
-
218
- /**
219
- *
220
- * @return {Monster.Components.Form.Form}
221
- */
222
- [assembleMethodSymbol]() {
223
- const rawKey = this.getOption("templateMapping.row-key");
224
-
225
- if (rawKey === null) {
226
- if (this.id !== null && this.id !== "") {
227
- const rawKey = this.getOption("templateMapping.row-key");
228
- if (rawKey === null) {
229
- this.setOption("templateMapping.row-key", this.id + "-row");
230
- }
231
- } else {
232
- this.setOption("templateMapping.row-key", "row");
233
- }
234
- }
235
-
236
- if (this.id !== null && this.id !== "") {
237
- this.setOption("templateMapping.filter-id", "" + this.id + "-filter");
238
- } else {
239
- this.setOption("templateMapping.filter-id", "filter");
240
- }
241
-
242
- super[assembleMethodSymbol]();
243
-
244
- initControlReferences.call(this);
245
- initEventHandler.call(this);
246
-
247
- const selector = this.getOption("datasource.selector");
248
-
249
- if (isString(selector)) {
250
- const elements = document.querySelectorAll(selector);
251
- if (elements.length !== 1) {
252
- throw new Error("the selector must match exactly one element");
253
- }
254
-
255
- const element = elements[0];
256
-
257
- if (!isInstance(element, Datasource)) {
258
- throw new TypeError("the element must be a datasource");
259
- }
260
-
261
- this[datasourceLinkedElementSymbol] = element;
262
-
263
- setTimeout(() => {
264
- handleDataSourceChanges.call(this);
265
- element.datasource.attachObserver(
266
- new Observer(handleDataSourceChanges.bind(this)),
267
- );
268
- }, 0);
269
- }
270
-
271
- getHostConfig
272
- .call(this, getColumnVisibilityConfigKey)
273
- .then((config) => {
274
-
275
- const headerOrderMap = new Map();
276
-
277
- getHostConfig
278
- .call(this, getStoredOrderConfigKey)
279
- .then((orderConfig) => {
280
-
281
- if (isArray(orderConfig) || orderConfig.length > 0) {
282
- for (let i = 0; i < orderConfig.length; i++) {
283
- const item = orderConfig[i];
284
- const parts = item.split(" ");
285
- const field = parts[0];
286
- const direction = parts[1] || DIRECTION_ASC;
287
- headerOrderMap.set(field, direction);
288
- }
289
- }
290
-
291
- }).then(() => {
292
-
293
- const headers = this.getOption("headers", undefined);
294
- console.log(headers);
295
-
296
- try {
297
- initGridAndStructs.call(this, config, headerOrderMap);
298
- } catch (error) {
299
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error?.message || error.toString());
300
- }
301
-
302
-
303
-
304
-
305
- updateColumnBar.call(this);
306
-
307
- })
308
- .catch((error) => {
309
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error?.message || error.toString());
310
- });
311
-
312
-
313
- })
314
- .catch((error) => {
315
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error?.message || error.toString());
316
- })
317
-
318
- }
319
-
320
- /**
321
- *
322
- * @return {CSSStyleSheet[]}
323
- */
324
- static getCSSStyleSheet() {
325
- return [DatatableStyleSheet];
326
- }
123
+ /**
124
+ * This method is called by the `instanceof` operator.
125
+ * @returns {symbol}
126
+ */
127
+ static get [instanceSymbol]() {
128
+ return Symbol.for("@schukai/monster/components/datatable@@instance");
129
+ }
130
+
131
+ /**
132
+ * To set the options via the html tag the attribute `data-monster-options` must be used.
133
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
134
+ *
135
+ * The individual configuration values can be found in the table.
136
+ *
137
+ * @property {Object} templates Template definitions
138
+ * @property {string} templates.main Main template
139
+ * @property {Object} datasource Datasource configuration
140
+ * @property {string} datasource.selector Selector for the datasource
141
+ * @property {Object} mapping Mapping configuration
142
+ * @property {string} mapping.data Data mapping
143
+ * @property {Array} data Data
144
+ * @property {Array} headers Headers
145
+ * @property {Object} responsive Responsive configuration
146
+ * @property {number} responsive.breakpoint Breakpoint for responsive mode
147
+ * @property {Object} labels Labels
148
+ * @property {string} labels.theListContainsNoEntries Label for empty state
149
+ * @property {Object} features Features
150
+ * @property {boolean} features.settings Settings feature
151
+ * @property {boolean} features.footer Footer feature
152
+ * @property {boolean} features.autoInit Auto init feature (init datasource automatically)
153
+ * @property {Object} templateMapping Template mapping
154
+ * @property {string} templateMapping.row-key Row key
155
+ * @property {string} templateMapping.filter-id Filter id
156
+ **/
157
+ get defaults() {
158
+ return Object.assign(
159
+ {},
160
+ super.defaults,
161
+ {
162
+ templates: {
163
+ main: getTemplate(),
164
+ emptyState: getEmptyTemplate(),
165
+ },
166
+
167
+ datasource: {
168
+ selector: null,
169
+ },
170
+
171
+ mapping: {
172
+ data: "dataset",
173
+ },
174
+
175
+ data: [],
176
+ headers: [],
177
+
178
+ responsive: {
179
+ breakpoint: 800,
180
+ },
181
+
182
+ labels: {
183
+ theListContainsNoEntries: "The list contains no entries",
184
+ },
185
+
186
+ features: {
187
+ settings: true,
188
+ footer: true,
189
+ autoInit: true,
190
+ },
191
+
192
+ templateMapping: {
193
+ "row-key": null,
194
+ "filter-id": null,
195
+ },
196
+ },
197
+ initOptionsFromArguments.call(this),
198
+ );
199
+ }
200
+
201
+ /**
202
+ *
203
+ * @param {string} selector
204
+ * @returns {NodeListOf<*>}
205
+ */
206
+ getGridElements(selector) {
207
+ return this[gridElementSymbol].querySelectorAll(selector);
208
+ }
209
+
210
+ /**
211
+ *
212
+ * @return {string}
213
+ */
214
+ static getTag() {
215
+ return "monster-datatable";
216
+ }
217
+
218
+ /**
219
+ *
220
+ * @return {Monster.Components.Form.Form}
221
+ */
222
+ [assembleMethodSymbol]() {
223
+ const rawKey = this.getOption("templateMapping.row-key");
224
+
225
+ if (rawKey === null) {
226
+ if (this.id !== null && this.id !== "") {
227
+ const rawKey = this.getOption("templateMapping.row-key");
228
+ if (rawKey === null) {
229
+ this.setOption("templateMapping.row-key", this.id + "-row");
230
+ }
231
+ } else {
232
+ this.setOption("templateMapping.row-key", "row");
233
+ }
234
+ }
235
+
236
+ if (this.id !== null && this.id !== "") {
237
+ this.setOption("templateMapping.filter-id", "" + this.id + "-filter");
238
+ } else {
239
+ this.setOption("templateMapping.filter-id", "filter");
240
+ }
241
+
242
+ super[assembleMethodSymbol]();
243
+
244
+ initControlReferences.call(this);
245
+ initEventHandler.call(this);
246
+
247
+ const selector = this.getOption("datasource.selector");
248
+
249
+ if (isString(selector)) {
250
+ const elements = document.querySelectorAll(selector);
251
+ if (elements.length !== 1) {
252
+ throw new Error("the selector must match exactly one element");
253
+ }
254
+
255
+ const element = elements[0];
256
+
257
+ if (!isInstance(element, Datasource)) {
258
+ throw new TypeError("the element must be a datasource");
259
+ }
260
+
261
+ this[datasourceLinkedElementSymbol] = element;
262
+
263
+ setTimeout(() => {
264
+ handleDataSourceChanges.call(this);
265
+ element.datasource.attachObserver(
266
+ new Observer(handleDataSourceChanges.bind(this)),
267
+ );
268
+ }, 0);
269
+ }
270
+
271
+ getHostConfig
272
+ .call(this, getColumnVisibilityConfigKey)
273
+ .then((config) => {
274
+ const headerOrderMap = new Map();
275
+
276
+ getHostConfig
277
+ .call(this, getStoredOrderConfigKey)
278
+ .then((orderConfig) => {
279
+ if (isArray(orderConfig) || orderConfig.length > 0) {
280
+ for (let i = 0; i < orderConfig.length; i++) {
281
+ const item = orderConfig[i];
282
+ const parts = item.split(" ");
283
+ const field = parts[0];
284
+ const direction = parts[1] || DIRECTION_ASC;
285
+ headerOrderMap.set(field, direction);
286
+ }
287
+ }
288
+ })
289
+ .then(() => {
290
+ try {
291
+ initGridAndStructs.call(this, config, headerOrderMap);
292
+ } catch (error) {
293
+ addAttributeToken(
294
+ this,
295
+ ATTRIBUTE_ERRORMESSAGE,
296
+ error?.message || error.toString(),
297
+ );
298
+ }
299
+
300
+ updateColumnBar.call(this);
301
+ })
302
+ .catch((error) => {
303
+ addAttributeToken(
304
+ this,
305
+ ATTRIBUTE_ERRORMESSAGE,
306
+ error?.message || error.toString(),
307
+ );
308
+ });
309
+ })
310
+ .catch((error) => {
311
+ addAttributeToken(
312
+ this,
313
+ ATTRIBUTE_ERRORMESSAGE,
314
+ error?.message || error.toString(),
315
+ );
316
+ });
317
+ }
318
+
319
+ /**
320
+ *
321
+ * @return {CSSStyleSheet[]}
322
+ */
323
+ static getCSSStyleSheet() {
324
+ return [DatatableStyleSheet];
325
+ }
327
326
  }
328
327
 
329
328
  /**
@@ -331,7 +330,7 @@ class DataTable extends CustomElement {
331
330
  * @returns {string}
332
331
  */
333
332
  function getColumnVisibilityConfigKey() {
334
- return generateUniqueConfigKey("datatable", this?.id, "columns-visibility");
333
+ return generateUniqueConfigKey("datatable", this?.id, "columns-visibility");
335
334
  }
336
335
 
337
336
  /**
@@ -339,7 +338,7 @@ function getColumnVisibilityConfigKey() {
339
338
  * @returns {string}
340
339
  */
341
340
  function getFilterConfigKey() {
342
- return generateUniqueConfigKey("datatable", this?.id, "filter");
341
+ return generateUniqueConfigKey("datatable", this?.id, "filter");
343
342
  }
344
343
 
345
344
  /**
@@ -347,281 +346,279 @@ function getFilterConfigKey() {
347
346
  * @returns {Promise}
348
347
  */
349
348
  function getHostConfig(callback) {
350
- const document = getDocument();
351
- const host = document.querySelector("monster-host");
352
-
353
- if (!(host && this.id)) {
354
- return Promise.resolve({});
355
- }
356
-
357
- if (!host || !isFunction(host?.getConfig)) {
358
- throw new TypeError("the host must be a monster-host");
359
- }
360
-
361
- const configKey = callback.call(this);
362
- return host.hasConfig(configKey).then((hasConfig) => {
363
- if (hasConfig) {
364
- return host.getConfig(configKey);
365
- } else {
366
- return {};
367
- }
368
- });
369
-
349
+ const document = getDocument();
350
+ const host = document.querySelector("monster-host");
351
+
352
+ if (!(host && this.id)) {
353
+ return Promise.resolve({});
354
+ }
355
+
356
+ if (!host || !isFunction(host?.getConfig)) {
357
+ throw new TypeError("the host must be a monster-host");
358
+ }
359
+
360
+ const configKey = callback.call(this);
361
+ return host.hasConfig(configKey).then((hasConfig) => {
362
+ if (hasConfig) {
363
+ return host.getConfig(configKey);
364
+ } else {
365
+ return {};
366
+ }
367
+ });
370
368
  }
371
369
 
372
370
  /**
373
371
  * @private
374
372
  */
375
373
  function updateColumnBar() {
376
- if (!this[columnBarElementSymbol]) {
377
- return;
378
- }
379
-
380
- const columns = [];
381
- for (const header of this.getOption("headers")) {
382
- const mode = header.getInternal("mode");
383
-
384
- if (mode === ATTRIBUTE_DATATABLE_MODE_FIXED) {
385
- continue;
386
- }
387
-
388
- columns.push({
389
- visible: mode !== ATTRIBUTE_DATATABLE_MODE_HIDDEN,
390
- name: header.label,
391
- index: header.index,
392
- });
393
- }
394
-
395
- this[columnBarElementSymbol].setOption("columns", columns);
374
+ if (!this[columnBarElementSymbol]) {
375
+ return;
376
+ }
377
+
378
+ const columns = [];
379
+ for (const header of this.getOption("headers")) {
380
+ const mode = header.getInternal("mode");
381
+
382
+ if (mode === ATTRIBUTE_DATATABLE_MODE_FIXED) {
383
+ continue;
384
+ }
385
+
386
+ columns.push({
387
+ visible: mode !== ATTRIBUTE_DATATABLE_MODE_HIDDEN,
388
+ name: header.label,
389
+ index: header.index,
390
+ });
391
+ }
392
+
393
+ this[columnBarElementSymbol].setOption("columns", columns);
396
394
  }
397
395
 
398
396
  /**
399
397
  * @private
400
398
  */
401
399
  function updateHeaderFromColumnBar() {
402
- if (!this[columnBarElementSymbol]) {
403
- return;
404
- }
400
+ if (!this[columnBarElementSymbol]) {
401
+ return;
402
+ }
405
403
 
406
- const options = this[columnBarElementSymbol].getOption("columns");
407
- if (!isArray(options)) return;
404
+ const options = this[columnBarElementSymbol].getOption("columns");
405
+ if (!isArray(options)) return;
408
406
 
409
- const invisibleMap = {};
407
+ const invisibleMap = {};
410
408
 
411
- for (let i = 0; i < options.length; i++) {
412
- const option = options[i];
413
- invisibleMap[option.index] = option.visible;
414
- }
409
+ for (let i = 0; i < options.length; i++) {
410
+ const option = options[i];
411
+ invisibleMap[option.index] = option.visible;
412
+ }
415
413
 
416
- for (const header of this.getOption("headers")) {
417
- const mode = header.getInternal("mode");
414
+ for (const header of this.getOption("headers")) {
415
+ const mode = header.getInternal("mode");
418
416
 
419
- if (mode === ATTRIBUTE_DATATABLE_MODE_FIXED) {
420
- continue;
421
- }
417
+ if (mode === ATTRIBUTE_DATATABLE_MODE_FIXED) {
418
+ continue;
419
+ }
422
420
 
423
- if (invisibleMap[header.index] === false) {
424
- header.setInternal("mode", ATTRIBUTE_DATATABLE_MODE_HIDDEN);
425
- } else {
426
- header.setInternal("mode", ATTRIBUTE_DATATABLE_MODE_VISIBLE);
427
- }
428
- }
421
+ if (invisibleMap[header.index] === false) {
422
+ header.setInternal("mode", ATTRIBUTE_DATATABLE_MODE_HIDDEN);
423
+ } else {
424
+ header.setInternal("mode", ATTRIBUTE_DATATABLE_MODE_VISIBLE);
425
+ }
426
+ }
429
427
  }
430
428
 
431
429
  /**
432
430
  * @private
433
431
  */
434
432
  function updateConfigColumnBar() {
435
- if (!this[columnBarElementSymbol]) {
436
- return;
437
- }
438
-
439
- const options = this[columnBarElementSymbol].getOption("columns");
440
- if (!isArray(options)) return;
441
-
442
- const map = {};
443
- for (let i = 0; i < options.length; i++) {
444
- const option = options[i];
445
- map[option.name] = option.visible;
446
- }
447
-
448
- const document = getDocument();
449
- const host = document.querySelector("monster-host");
450
- if (!(host && this.id)) {
451
- return;
452
- }
453
- const configKey = getColumnVisibilityConfigKey.call(this);
454
-
455
- try {
456
- host.setConfig(configKey, map);
457
- } catch (error) {
458
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, String(error));
459
- }
433
+ if (!this[columnBarElementSymbol]) {
434
+ return;
435
+ }
436
+
437
+ const options = this[columnBarElementSymbol].getOption("columns");
438
+ if (!isArray(options)) return;
439
+
440
+ const map = {};
441
+ for (let i = 0; i < options.length; i++) {
442
+ const option = options[i];
443
+ map[option.name] = option.visible;
444
+ }
445
+
446
+ const document = getDocument();
447
+ const host = document.querySelector("monster-host");
448
+ if (!(host && this.id)) {
449
+ return;
450
+ }
451
+ const configKey = getColumnVisibilityConfigKey.call(this);
452
+
453
+ try {
454
+ host.setConfig(configKey, map);
455
+ } catch (error) {
456
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, String(error));
457
+ }
460
458
  }
461
459
 
462
460
  /**
463
461
  * @private
464
462
  */
465
463
  function initEventHandler() {
466
- const self = this;
467
-
468
- getWindow().addEventListener("resize", (event) => {
469
- updateGrid.call(self);
470
- });
471
-
472
- self[columnBarElementSymbol].attachObserver(
473
- new Observer((e) => {
474
- updateHeaderFromColumnBar.call(self);
475
- updateGrid.call(self);
476
- updateConfigColumnBar.call(self);
477
- }),
478
- );
479
-
480
- self[gridHeadersElementSymbol].addEventListener("click", function (event) {
481
- let element = null;
482
- const datasource = self[datasourceLinkedElementSymbol];
483
- if (!datasource) {
484
- return;
485
- }
486
-
487
- element = findTargetElementFromEvent(event, ATTRIBUTE_DATATABLE_SORTABLE);
488
- if (element) {
489
- const index = element.parentNode.getAttribute(ATTRIBUTE_DATATABLE_INDEX);
490
- const headers = self.getOption("headers");
491
-
492
- event.preventDefault();
493
-
494
- headers[index].changeDirection();
495
-
496
- setTimeout(function () {
497
- /** hotfix, normally this should be done via the updater, no idea why this is not possible. */
498
- element.setAttribute(
499
- ATTRIBUTE_DATATABLE_SORTABLE,
500
- `${headers[index].field} ${headers[index].direction}`,
501
- );
502
-
503
- storeOrderStatement.call(self, true);
504
-
505
- }, 0);
506
- }
507
- });
464
+ const self = this;
465
+
466
+ getWindow().addEventListener("resize", (event) => {
467
+ updateGrid.call(self);
468
+ });
469
+
470
+ self[columnBarElementSymbol].attachObserver(
471
+ new Observer((e) => {
472
+ updateHeaderFromColumnBar.call(self);
473
+ updateGrid.call(self);
474
+ updateConfigColumnBar.call(self);
475
+ }),
476
+ );
477
+
478
+ self[gridHeadersElementSymbol].addEventListener("click", function (event) {
479
+ let element = null;
480
+ const datasource = self[datasourceLinkedElementSymbol];
481
+ if (!datasource) {
482
+ return;
483
+ }
484
+
485
+ element = findTargetElementFromEvent(event, ATTRIBUTE_DATATABLE_SORTABLE);
486
+ if (element) {
487
+ const index = element.parentNode.getAttribute(ATTRIBUTE_DATATABLE_INDEX);
488
+ const headers = self.getOption("headers");
489
+
490
+ event.preventDefault();
491
+
492
+ headers[index].changeDirection();
493
+
494
+ setTimeout(function () {
495
+ /** hotfix, normally this should be done via the updater, no idea why this is not possible. */
496
+ element.setAttribute(
497
+ ATTRIBUTE_DATATABLE_SORTABLE,
498
+ `${headers[index].field} ${headers[index].direction}`,
499
+ );
500
+
501
+ storeOrderStatement.call(self, true);
502
+ }, 0);
503
+ }
504
+ });
508
505
  }
509
506
 
510
507
  /**
511
508
  * @private
512
509
  */
513
510
  function initGridAndStructs(hostConfig, headerOrderMap) {
514
- const rowID = this.getOption("templateMapping.row-key");
515
-
516
- if (!this[gridElementSymbol]) {
517
- throw new Error("no grid element is defined");
518
- }
519
-
520
- let template;
521
- getSlottedElements.call(this).forEach((e) => {
522
- if (e instanceof HTMLTemplateElement && e.id === rowID) {
523
- template = e;
524
- }
525
- });
526
-
527
- if (!template) {
528
- throw new Error("no template is defined");
529
- }
530
-
531
- const rowCount = template.content.children.length;
532
-
533
- const headers = [];
534
-
535
- for (let i = 0; i < rowCount; i++) {
536
- let hClass = "";
537
- const row = template.content.children[i];
538
-
539
- let mode = "";
540
- if (row.hasAttribute(ATTRIBUTE_DATATABLE_MODE)) {
541
- mode = row.getAttribute(ATTRIBUTE_DATATABLE_MODE);
542
- }
543
-
544
- let grid = row.getAttribute(ATTRIBUTE_DATATABLE_GRID_TEMPLATE);
545
- if (!grid || grid === "" || grid === "auto") {
546
- grid = "minmax(0, 1fr)";
547
- }
548
-
549
- let label = "";
550
- let labelKey = "";
551
-
552
- if (row.hasAttribute(ATTRIBUTE_DATATABLE_HEAD)) {
553
- label = row.getAttribute(ATTRIBUTE_DATATABLE_HEAD);
554
- labelKey = label;
555
-
556
- try {
557
- if (label.startsWith("i18n:")) {
558
- label = label.substring(5, label.length);
559
- label = getDocumentTranslations().getText(label, label);
560
- }
561
- } catch (e) {
562
- label = "i18n error " + label;
563
- }
564
- }
565
-
566
- if (!label) {
567
- label = i + 1 + "";
568
- mode = ATTRIBUTE_DATATABLE_MODE_FIXED;
569
- labelKey = label;
570
- }
571
-
572
- if (isObject(hostConfig) && hostConfig.hasOwnProperty(label)) {
573
- if (hostConfig[label] === false) {
574
- mode = ATTRIBUTE_DATATABLE_MODE_HIDDEN;
575
- } else {
576
- mode = ATTRIBUTE_DATATABLE_MODE_VISIBLE;
577
- }
578
- }
579
-
580
- let align = "";
581
- if (row.hasAttribute(ATTRIBUTE_DATATABLE_ALIGN)) {
582
- align = row.getAttribute(ATTRIBUTE_DATATABLE_ALIGN);
583
- }
584
-
585
- switch (align) {
586
- case "center":
587
- hClass = "flex-center";
588
- break;
589
- case "end":
590
- hClass = "flex-end";
591
- break;
592
- case "start":
593
- hClass = "flex-start";
594
- break;
595
- default:
596
- hClass = "flex-start";
597
- }
598
-
599
- let field = "";
600
- if (row.hasAttribute(ATTRIBUTE_DATATABLE_SORTABLE)) {
601
- field = row.getAttribute(ATTRIBUTE_DATATABLE_SORTABLE);
602
- }
603
-
604
- if (mode === ATTRIBUTE_DATATABLE_MODE_HIDDEN) {
605
- hClass += " hidden";
606
- }
607
-
608
- const header = new Header();
609
- header.setInternals({
610
- field: field,
611
- label: label,
612
- classes: hClass,
613
- index: i,
614
- mode: mode,
615
- grid: grid,
616
- labelKey: labelKey,
617
- direction: headerOrderMap.get(field) || DIRECTION_NONE,
618
- });
619
-
620
- headers.push(header);
621
- }
622
-
623
- this.setOption("headers", headers);
624
- storeOrderStatement.call(this, this.getOption("features.autoInit"));
511
+ const rowID = this.getOption("templateMapping.row-key");
512
+
513
+ if (!this[gridElementSymbol]) {
514
+ throw new Error("no grid element is defined");
515
+ }
516
+
517
+ let template;
518
+ getSlottedElements.call(this).forEach((e) => {
519
+ if (e instanceof HTMLTemplateElement && e.id === rowID) {
520
+ template = e;
521
+ }
522
+ });
523
+
524
+ if (!template) {
525
+ throw new Error("no template is defined");
526
+ }
527
+
528
+ const rowCount = template.content.children.length;
529
+
530
+ const headers = [];
531
+
532
+ for (let i = 0; i < rowCount; i++) {
533
+ let hClass = "";
534
+ const row = template.content.children[i];
535
+
536
+ let mode = "";
537
+ if (row.hasAttribute(ATTRIBUTE_DATATABLE_MODE)) {
538
+ mode = row.getAttribute(ATTRIBUTE_DATATABLE_MODE);
539
+ }
540
+
541
+ let grid = row.getAttribute(ATTRIBUTE_DATATABLE_GRID_TEMPLATE);
542
+ if (!grid || grid === "" || grid === "auto") {
543
+ grid = "minmax(0, 1fr)";
544
+ }
545
+
546
+ let label = "";
547
+ let labelKey = "";
548
+
549
+ if (row.hasAttribute(ATTRIBUTE_DATATABLE_HEAD)) {
550
+ label = row.getAttribute(ATTRIBUTE_DATATABLE_HEAD);
551
+ labelKey = label;
552
+
553
+ try {
554
+ if (label.startsWith("i18n:")) {
555
+ label = label.substring(5, label.length);
556
+ label = getDocumentTranslations().getText(label, label);
557
+ }
558
+ } catch (e) {
559
+ label = "i18n error " + label;
560
+ }
561
+ }
562
+
563
+ if (!label) {
564
+ label = i + 1 + "";
565
+ mode = ATTRIBUTE_DATATABLE_MODE_FIXED;
566
+ labelKey = label;
567
+ }
568
+
569
+ if (isObject(hostConfig) && hostConfig.hasOwnProperty(label)) {
570
+ if (hostConfig[label] === false) {
571
+ mode = ATTRIBUTE_DATATABLE_MODE_HIDDEN;
572
+ } else {
573
+ mode = ATTRIBUTE_DATATABLE_MODE_VISIBLE;
574
+ }
575
+ }
576
+
577
+ let align = "";
578
+ if (row.hasAttribute(ATTRIBUTE_DATATABLE_ALIGN)) {
579
+ align = row.getAttribute(ATTRIBUTE_DATATABLE_ALIGN);
580
+ }
581
+
582
+ switch (align) {
583
+ case "center":
584
+ hClass = "flex-center";
585
+ break;
586
+ case "end":
587
+ hClass = "flex-end";
588
+ break;
589
+ case "start":
590
+ hClass = "flex-start";
591
+ break;
592
+ default:
593
+ hClass = "flex-start";
594
+ }
595
+
596
+ let field = "";
597
+ if (row.hasAttribute(ATTRIBUTE_DATATABLE_SORTABLE)) {
598
+ field = row.getAttribute(ATTRIBUTE_DATATABLE_SORTABLE);
599
+ }
600
+
601
+ if (mode === ATTRIBUTE_DATATABLE_MODE_HIDDEN) {
602
+ hClass += " hidden";
603
+ }
604
+
605
+ const header = new Header();
606
+ header.setInternals({
607
+ field: field,
608
+ label: label,
609
+ classes: hClass,
610
+ index: i,
611
+ mode: mode,
612
+ grid: grid,
613
+ labelKey: labelKey,
614
+ direction: headerOrderMap.get(field) || DIRECTION_NONE,
615
+ });
616
+
617
+ headers.push(header);
618
+ }
619
+
620
+ this.setOption("headers", headers);
621
+ storeOrderStatement.call(this, this.getOption("features.autoInit"));
625
622
  }
626
623
 
627
624
  /**
@@ -629,81 +626,79 @@ function initGridAndStructs(hostConfig, headerOrderMap) {
629
626
  * @returns {string}
630
627
  */
631
628
  export function getStoredOrderConfigKey() {
632
- return generateUniqueConfigKey("datatable", this?.id, "stored-order");
629
+ return generateUniqueConfigKey("datatable", this?.id, "stored-order");
633
630
  }
634
631
 
635
-
636
632
  /**
637
633
  * @private
638
634
  */
639
635
  function storeOrderStatement(doFetch) {
640
- const headers = this.getOption("headers");
641
- const statement = createOrderStatement(headers);
642
- setDataSource.call(this, {orderBy: statement}, doFetch);
643
-
644
- const document = getDocument();
645
- const host = document.querySelector("monster-host");
646
- if (!(host && this.id)) {
647
- return;
648
- }
649
-
650
- const configKey = getStoredOrderConfigKey.call(this);
651
-
652
- // statement explode with , and remove all empty
653
- const list = statement.split(",").filter((item) => item.trim() !== "");
654
- if (list.length === 0) {
655
- // host.deleteConfig(configKey);
656
- return;
657
- }
658
-
659
- host.setConfig(configKey, list);
660
-
636
+ const headers = this.getOption("headers");
637
+ const statement = createOrderStatement(headers);
638
+ setDataSource.call(this, { orderBy: statement }, doFetch);
639
+
640
+ const document = getDocument();
641
+ const host = document.querySelector("monster-host");
642
+ if (!(host && this.id)) {
643
+ return;
644
+ }
645
+
646
+ const configKey = getStoredOrderConfigKey.call(this);
647
+
648
+ // statement explode with , and remove all empty
649
+ const list = statement.split(",").filter((item) => item.trim() !== "");
650
+ if (list.length === 0) {
651
+ // host.deleteConfig(configKey);
652
+ return;
653
+ }
654
+
655
+ host.setConfig(configKey, list);
661
656
  }
662
657
 
663
658
  /**
664
659
  * @private
665
660
  */
666
661
  function updateGrid() {
667
- if (!this[gridElementSymbol]) {
668
- throw new Error("no grid element is defined");
669
- }
670
-
671
- let gridTemplateColumns = "";
672
-
673
- const headers = this.getOption("headers");
674
-
675
- let styles = "";
676
-
677
- for (let i = 0; i < headers.length; i++) {
678
- const header = headers[i];
679
-
680
- if (header.mode === ATTRIBUTE_DATATABLE_MODE_HIDDEN) {
681
- styles += `[data-monster-role=datatable]>[data-monster-head="${header.labelKey}"] { display: none; }\n`;
682
- styles += `[data-monster-role=datatable-headers]>[data-monster-index="${header.index}"] { display: none; }\n`;
683
- } else {
684
- gridTemplateColumns += `${header.grid} `;
685
- }
686
- }
687
-
688
- const sheet = new CSSStyleSheet();
689
- if (styles !== "") sheet.replaceSync(styles);
690
- this.shadowRoot.adoptedStyleSheets = [...DataTable.getCSSStyleSheet(), sheet];
691
-
692
- const bodyWidth = getDocument().body.getBoundingClientRect().width;
693
-
694
- const breakpoint = this.getOption("responsive.breakpoint");
695
-
696
- if (bodyWidth > breakpoint) {
697
- this[
698
- gridElementSymbol
699
- ].style.gridTemplateColumns = `${gridTemplateColumns}`;
700
- this[
701
- gridHeadersElementSymbol
702
- ].style.gridTemplateColumns = `${gridTemplateColumns}`;
703
- } else {
704
- this[gridElementSymbol].style.gridTemplateColumns = "auto";
705
- this[gridHeadersElementSymbol].style.gridTemplateColumns = "auto";
706
- }
662
+ if (!this[gridElementSymbol]) {
663
+ throw new Error("no grid element is defined");
664
+ }
665
+
666
+ let gridTemplateColumns = "";
667
+
668
+ const headers = this.getOption("headers");
669
+
670
+ let styles = "";
671
+
672
+ for (let i = 0; i < headers.length; i++) {
673
+ const header = headers[i];
674
+
675
+ if (header.mode === ATTRIBUTE_DATATABLE_MODE_HIDDEN) {
676
+ styles += `[data-monster-role=datatable]>[data-monster-head="${header.labelKey}"] { display: none; }\n`;
677
+ styles += `[data-monster-role=datatable-headers]>[data-monster-index="${header.index}"] { display: none; }\n`;
678
+ } else {
679
+ gridTemplateColumns += `${header.grid} `;
680
+ }
681
+ }
682
+
683
+ const sheet = new CSSStyleSheet();
684
+ if (styles !== "") sheet.replaceSync(styles);
685
+ this.shadowRoot.adoptedStyleSheets = [...DataTable.getCSSStyleSheet(), sheet];
686
+
687
+ const bodyWidth = getDocument().body.getBoundingClientRect().width;
688
+
689
+ const breakpoint = this.getOption("responsive.breakpoint");
690
+
691
+ if (bodyWidth > breakpoint) {
692
+ this[
693
+ gridElementSymbol
694
+ ].style.gridTemplateColumns = `${gridTemplateColumns}`;
695
+ this[
696
+ gridHeadersElementSymbol
697
+ ].style.gridTemplateColumns = `${gridTemplateColumns}`;
698
+ } else {
699
+ this[gridElementSymbol].style.gridTemplateColumns = "auto";
700
+ this[gridHeadersElementSymbol].style.gridTemplateColumns = "auto";
701
+ }
707
702
  }
708
703
 
709
704
  /**
@@ -711,20 +706,20 @@ function updateGrid() {
711
706
  * @param {Monster.Components.Datatable.Header[]} headers
712
707
  * @param {bool} doFetch
713
708
  */
714
- function setDataSource({orderBy}, doFetch) {
715
- const datasource = this[datasourceLinkedElementSymbol];
709
+ function setDataSource({ orderBy }, doFetch) {
710
+ const datasource = this[datasourceLinkedElementSymbol];
716
711
 
717
- if (!datasource) {
718
- return;
719
- }
712
+ if (!datasource) {
713
+ return;
714
+ }
720
715
 
721
- if (isFunction(datasource?.setParameters)) {
722
- datasource.setParameters({orderBy});
723
- }
716
+ if (isFunction(datasource?.setParameters)) {
717
+ datasource.setParameters({ orderBy });
718
+ }
724
719
 
725
- if (doFetch !== false && isFunction(datasource?.fetch)) {
726
- datasource.fetch();
727
- }
720
+ if (doFetch !== false && isFunction(datasource?.fetch)) {
721
+ datasource.fetch();
722
+ }
728
723
  }
729
724
 
730
725
  /**
@@ -732,20 +727,20 @@ function setDataSource({orderBy}, doFetch) {
732
727
  * @return {Monster.Components.Datatable.Form}
733
728
  */
734
729
  function initControlReferences() {
735
- if (!this.shadowRoot) {
736
- throw new Error("no shadow-root is defined");
737
- }
738
-
739
- this[gridElementSymbol] = this.shadowRoot.querySelector(
740
- "[data-monster-role=datatable]",
741
- );
742
- this[gridHeadersElementSymbol] = this.shadowRoot.querySelector(
743
- "[data-monster-role=datatable-headers]",
744
- );
745
- this[columnBarElementSymbol] =
746
- this.shadowRoot.querySelector("monster-column-bar");
747
-
748
- return this;
730
+ if (!this.shadowRoot) {
731
+ throw new Error("no shadow-root is defined");
732
+ }
733
+
734
+ this[gridElementSymbol] = this.shadowRoot.querySelector(
735
+ "[data-monster-role=datatable]",
736
+ );
737
+ this[gridHeadersElementSymbol] = this.shadowRoot.querySelector(
738
+ "[data-monster-role=datatable-headers]",
739
+ );
740
+ this[columnBarElementSymbol] =
741
+ this.shadowRoot.querySelector("monster-column-bar");
742
+
743
+ return this;
749
744
  }
750
745
 
751
746
  /**
@@ -755,22 +750,22 @@ function initControlReferences() {
755
750
  * @throws {Error} the datasource could not be initialized
756
751
  */
757
752
  function initOptionsFromArguments() {
758
- const options = {};
759
- const selector = this.getAttribute(ATTRIBUTE_DATASOURCE_SELECTOR);
760
-
761
- if (selector) {
762
- options.datasource = {selector: selector};
763
- }
764
-
765
- const breakpoint = this.getAttribute(
766
- ATTRIBUTE_DATATABLE_RESPONSIVE_BREAKPOINT,
767
- );
768
- if (breakpoint) {
769
- options.responsive = {};
770
- options.responsive.breakpoint = parseInt(breakpoint);
771
- }
772
-
773
- return options;
753
+ const options = {};
754
+ const selector = this.getAttribute(ATTRIBUTE_DATASOURCE_SELECTOR);
755
+
756
+ if (selector) {
757
+ options.datasource = { selector: selector };
758
+ }
759
+
760
+ const breakpoint = this.getAttribute(
761
+ ATTRIBUTE_DATATABLE_RESPONSIVE_BREAKPOINT,
762
+ );
763
+ if (breakpoint) {
764
+ options.responsive = {};
765
+ options.responsive.breakpoint = parseInt(breakpoint);
766
+ }
767
+
768
+ return options;
774
769
  }
775
770
 
776
771
  /**
@@ -778,7 +773,7 @@ function initOptionsFromArguments() {
778
773
  * @return {string}
779
774
  */
780
775
  function getEmptyTemplate() {
781
- return `<monster-state data-monster-role="empty-without-action">
776
+ return `<monster-state data-monster-role="empty-without-action">
782
777
  <div part="visual">
783
778
  <svg width="4rem" height="4rem" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
784
779
  <path d="m21.5 22h-19c-1.378 0-2.5-1.121-2.5-2.5v-7c0-.07.015-.141.044-.205l3.969-8.82c.404-.896 1.299-1.475 2.28-1.475h11.414c.981 0 1.876.579 2.28 1.475l3.969 8.82c.029.064.044.135.044.205v7c0 1.379-1.122 2.5-2.5 2.5zm-20.5-9.393v6.893c0 .827.673 1.5 1.5 1.5h19c.827 0 1.5-.673 1.5-1.5v-6.893l-3.925-8.723c-.242-.536-.779-.884-1.368-.884h-11.414c-.589 0-1.126.348-1.368.885z"/>
@@ -796,8 +791,8 @@ function getEmptyTemplate() {
796
791
  * @return {string}
797
792
  */
798
793
  function getTemplate() {
799
- // language=HTML
800
- return `
794
+ // language=HTML
795
+ return `
801
796
  <div data-monster-role="control" part="control">
802
797
  <template id="headers-row">
803
798
  <div data-monster-attributes="class path:headers-row.classname,