@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
package/CHANGELOG.md CHANGED
@@ -1,9 +1,32 @@
1
1
 
2
+ ## [3.55.2] - 2024-01-22
3
+
4
+ ### Bug Fixes
5
+
6
+ - double fetch [#134](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/134)
7
+
8
+ ## [3.55.1] - 2024-01-22
9
+
10
+ ### Bug Fixes
11
+
12
+ - catch errors [#133](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/133)
13
+ - catch errors [#133](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/133)
14
+ - check parameter [#132](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/132)
15
+ ### Changes
16
+
17
+ - release and publish to npm new version 3.55.1
18
+ - doc
19
+ - lint + formatt
20
+ - update nixos to 23-11
21
+
2
22
  ## [3.55.0] - 2023-11-29
3
23
 
4
24
  ### Add Features
5
25
 
6
26
  - various changes [#131](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/131)
27
+ ### Changes
28
+
29
+ - release and publish to npm new version 3.55.0
7
30
 
8
31
  ## [3.54.0] - 2023-11-23
9
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schukai/monster",
3
- "version": "3.55.0",
3
+ "version": "3.55.2",
4
4
  "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
5
5
  "keywords": [
6
6
  "framework",
@@ -29,6 +29,15 @@ export {Rest};
29
29
  */
30
30
  const intersectionObserverHandlerSymbol = Symbol("intersectionObserverHandler");
31
31
 
32
+ /**
33
+ * @private
34
+ * Original at source/components/datatable/datasource/rest.mjs
35
+ * @type {symbol}
36
+ */
37
+ const rawDataSymbol = Symbol.for(
38
+ "@schukai/monster/data/datasource/server/restapi/rawdata",
39
+ );
40
+
32
41
  /**
33
42
  * @private
34
43
  * @type {symbol}
@@ -98,7 +107,8 @@ class Rest extends Datasource {
98
107
  * @property {Object} datatable Datatable definitions
99
108
  * @property {string} datatable.id The id of the datatable control
100
109
  * @property {Object} response Response definitions
101
- * @property {string} response.errorMessagePath The path to the error message in the response
110
+ * @property {Object} response.path Path definitions (changed in 3.56.0)
111
+ * @property {string} response.path.message Path to the message (changed in 3.56.0)
102
112
  * @property {Object} read Read configuration
103
113
  * @property {string} read.url The url of the rest api
104
114
  * @property {string} read.method The method of the rest api
@@ -124,7 +134,7 @@ class Rest extends Datasource {
124
134
  },
125
135
 
126
136
  features: {
127
- autoInit: true,
137
+ autoInit: false,
128
138
  filter: false,
129
139
  },
130
140
 
@@ -136,13 +146,16 @@ class Rest extends Datasource {
136
146
  filter: {
137
147
  id: undefined,
138
148
  },
139
-
149
+
140
150
  datatable: {
141
151
  id: undefined,
142
152
  },
143
153
 
144
154
  response: {
145
- errorMessagePath: "sys.message",
155
+ path: {
156
+ message: "sys.message",
157
+ code: "sys.code",
158
+ }
146
159
  },
147
160
  });
148
161
  }
@@ -192,7 +205,6 @@ class Rest extends Datasource {
192
205
  * @returns {Promise<never>|*}
193
206
  */
194
207
  fetch() {
195
- const self = this;
196
208
  const opt = clone(this.getOption("read"));
197
209
  this[dataSourceSymbol].setOption("read", opt);
198
210
 
@@ -206,36 +218,32 @@ class Rest extends Datasource {
206
218
  url = formatter.format(url);
207
219
 
208
220
  this[dataSourceSymbol].setOption("read.url", url);
209
-
210
- return new Promise((resolve, reject) => {
211
221
 
212
- fireCustomEvent(self, "monster-datasource-fetch", {
213
- datasource: self,
222
+ return new Promise((resolve, reject) => {
223
+ fireCustomEvent(this, "monster-datasource-fetch", {
224
+ datasource: this,
214
225
  });
215
226
 
216
227
  setTimeout(() => {
217
- self[dataSourceSymbol].read().then((response) => {
218
- fireCustomEvent(self, "monster-datasource-fetched", {
219
- datasource: self,
220
- });
228
+ this[dataSourceSymbol]
229
+ .read()
230
+ .then((response) => {
231
+ fireCustomEvent(this, "monster-datasource-fetched", {
232
+ datasource: this,
233
+ });
234
+
235
+ resolve(response);
236
+ })
237
+ .catch((error) => {
238
+ fireCustomEvent(this, "monster-datasource-error", {
239
+ error: error,
240
+ });
221
241
 
222
- resolve(response);
223
-
224
- })
225
- .catch((error) => {
226
- fireCustomEvent(self, "monster-datasource-error", {
227
- error: error,
242
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error.toString());
243
+ reject(error);
228
244
  });
229
-
230
- addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, error.toString());
231
- reject(error);
232
-
233
- });
234
- },0);
235
-
245
+ }, 0);
236
246
  });
237
-
238
-
239
247
  }
240
248
 
241
249
  /**
@@ -301,7 +309,6 @@ function removeFilter() {
301
309
  }
302
310
  }
303
311
 
304
-
305
312
  /**
306
313
  * @private
307
314
  */
@@ -320,13 +327,11 @@ function initFilter() {
320
327
  );
321
328
 
322
329
  this[filterObserverSymbol] = new Observer(() => {
323
-
324
330
  const query = filterControl.getOption("query", undefined);
325
331
  this.setParameters({query: query});
326
332
  this.fetch()
327
333
  .then((response) => {
328
-
329
- if(!(response instanceof Response) ){
334
+ if (!(response instanceof Response)) {
330
335
  throw new Error("Response is not an instance of Response");
331
336
  }
332
337
 
@@ -335,25 +340,29 @@ function initFilter() {
335
340
  filterControl?.showSuccess();
336
341
  }
337
342
 
343
+ if (response.bodyUsed === true) {
344
+ return handleIntersectionObserver.call(this, response[rawDataSymbol], response, filterControl);
345
+ }
346
+
338
347
  response
339
- .json()
340
- .then((json) => {
341
- const path = new Pathfinder(json);
342
- const error = path.getVia(
343
- this.getOption("response.errorMessagePath"),
344
- );
345
- if (error) {
346
- filterControl?.showFailureMessage(error);
347
- return;
348
+ .text()
349
+ .then((jsonAsText) => {
350
+ let json;
351
+ try {
352
+ json = JSON.parse(jsonAsText);
353
+ } catch (e) {
354
+ let message = e instanceof Error ? e.message : `${e}`;
355
+ filterControl?.showFailureMessage(message);
356
+ return Promise.reject(e);
348
357
  }
349
358
 
350
- filterControl?.showFailureMessage(e.message);
359
+ return handleIntersectionObserver.call(this,json, response, filterControl);
360
+
361
+
351
362
  })
352
363
  .catch((e) => {
353
364
  filterControl?.showFailureMessage(e.message);
354
365
  });
355
-
356
-
357
366
  })
358
367
  .catch((e) => {
359
368
  this.dispatchEvent(
@@ -366,13 +375,36 @@ function initFilter() {
366
375
 
367
376
  filterControl?.showFailureMessage(e.message);
368
377
  return Promise.reject(e);
369
-
370
378
  });
371
379
  });
372
380
 
373
381
  filterControl.attachObserver(this[filterObserverSymbol]);
374
382
  }
375
383
 
384
+ function handleIntersectionObserver(json, response, filterControl) {
385
+
386
+ const path = new Pathfinder(json);
387
+
388
+ const codePath = this.getOption("response.path.code");
389
+
390
+ if (path.exists(codePath)) {
391
+ const code = `${path.getVia(codePath)}`;
392
+ if (code && code === "200") {
393
+ filterControl?.showSuccess();
394
+ return Promise.resolve(response);
395
+ }
396
+
397
+ const messagePath = this.getOption("response.path.message");
398
+ if (path.exists(messagePath)) {
399
+ const message = path.getVia(messagePath);
400
+ filterControl?.showFailureMessage(message);
401
+ return Promise.reject(new Error(message));
402
+ }
403
+
404
+ return Promise.reject(new Error("Response code is not 200"));
405
+ }
406
+ }
407
+
376
408
  /**
377
409
  * @private
378
410
  */
@@ -389,7 +421,6 @@ function initAutoInit() {
389
421
 
390
422
  setTimeout(() => {
391
423
  this.fetch().catch(() => {
392
-
393
424
  });
394
425
  }, 0);
395
426
  }
@@ -111,7 +111,7 @@ class Header extends Base {
111
111
  }
112
112
 
113
113
  /**
114
- *
114
+ *
115
115
  * @param direction
116
116
  */
117
117
  setDirection(direction) {