@schukai/monster 3.61.0 → 3.62.0

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