@schukai/monster 3.53.0 → 3.55.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +1 -1
  3. package/source/components/datatable/datasource/rest.mjs +358 -309
  4. package/source/components/datatable/datatable/header.mjs +8 -0
  5. package/source/components/datatable/datatable.mjs +606 -557
  6. package/source/components/datatable/embedded-pagination.mjs +50 -62
  7. package/source/components/datatable/filter/util.mjs +122 -0
  8. package/source/components/datatable/filter.mjs +893 -708
  9. package/source/components/datatable/pagination.mjs +335 -310
  10. package/source/components/datatable/status.mjs +248 -0
  11. package/source/components/datatable/style/datatable.pcss +1 -0
  12. package/source/components/datatable/style/embedded-pagination.pcss +59 -2
  13. package/source/components/datatable/style/filter.pcss +4 -0
  14. package/source/components/datatable/style/pagination.pcss +28 -4
  15. package/source/components/datatable/style/status.pcss +42 -0
  16. package/source/components/datatable/stylesheet/column-bar.mjs +1 -1
  17. package/source/components/datatable/stylesheet/datatable.mjs +1 -1
  18. package/source/components/datatable/stylesheet/filter-button.mjs +1 -1
  19. package/source/components/datatable/stylesheet/filter.mjs +1 -1
  20. package/source/components/datatable/stylesheet/pagination.mjs +1 -1
  21. package/source/components/datatable/stylesheet/status.mjs +27 -0
  22. package/source/components/form/action-button.mjs +1 -1
  23. package/source/components/form/api-button.mjs +1 -1
  24. package/source/components/form/button-bar.mjs +1 -1
  25. package/source/components/form/button.mjs +1 -1
  26. package/source/components/form/confirm-button.mjs +1 -1
  27. package/source/components/form/context-error.mjs +275 -0
  28. package/source/components/form/context-help.mjs +5 -5
  29. package/source/components/form/form.mjs +2 -2
  30. package/source/components/form/message-state-button.mjs +2 -2
  31. package/source/components/form/popper-button.mjs +7 -4
  32. package/source/components/form/popper.mjs +317 -309
  33. package/source/components/form/reload.mjs +1 -1
  34. package/source/components/form/select.mjs +9 -3
  35. package/source/components/form/shadow-reload.mjs +1 -1
  36. package/source/components/form/state-button.mjs +2 -1
  37. package/source/components/form/style/context-error.pcss +32 -0
  38. package/source/components/form/style/context-help.pcss +22 -5
  39. package/source/components/form/stylesheet/context-error.mjs +27 -0
  40. package/source/components/form/stylesheet/context-help.mjs +1 -1
  41. package/source/components/form/stylesheet/select.mjs +1 -1
  42. package/source/components/form/stylesheet/tabs.mjs +1 -1
  43. package/source/components/form/tabs.mjs +757 -707
  44. package/source/components/form/template.mjs +1 -1
  45. package/source/components/form/tree-select.mjs +1 -1
  46. package/source/components/host/collapse.mjs +22 -5
  47. package/source/components/host/config-manager.mjs +39 -2
  48. package/source/components/host/host.mjs +14 -0
  49. package/source/components/host/stylesheet/call-button.mjs +1 -1
  50. package/source/components/host/stylesheet/overlay.mjs +1 -1
  51. package/source/components/host/stylesheet/toggle-button.mjs +1 -1
  52. package/source/components/host/util.mjs +6 -1
  53. package/source/components/notify/stylesheet/message.mjs +1 -1
  54. package/source/components/stylesheet/icons.mjs +1 -1
  55. package/source/data/transformer.mjs +39 -42
  56. package/source/dom/customelement.mjs +1 -1
  57. package/source/dom/updater.mjs +700 -688
  58. package/source/dom/util.mjs +42 -0
  59. package/source/i18n/providers/embed.mjs +3 -3
  60. package/source/monster.mjs +6 -0
  61. package/source/text/formatter.mjs +2 -2
  62. package/source/types/observer.mjs +1 -1
  63. package/source/types/version.mjs +1 -1
  64. package/source/util/sleep.mjs +18 -0
  65. package/test/cases/components/form/button.mjs +2 -1
  66. package/test/cases/components/form/select.mjs +1 -1
  67. package/test/cases/components/form/tree-select.mjs +1 -1
  68. package/test/cases/data/transformer.mjs +2 -2
  69. package/test/cases/dom/updater.mjs +67 -46
  70. package/test/cases/monster.mjs +1 -1
  71. package/test/web/test.html +2 -2
  72. package/test/web/tests.js +18 -13
@@ -3,16 +3,18 @@
3
3
  * SPDX-License-Identifier: AGPL-3.0
4
4
  */
5
5
 
6
- import { registerCustomElement } from "../../dom/customelement.mjs";
7
- import { EmbeddedPaginationStyleSheet } from "./stylesheet/embedded-pagination.mjs";
8
- import { instanceSymbol } from "../../constants.mjs";
6
+ import {assembleMethodSymbol, registerCustomElement} from "../../dom/customelement.mjs";
7
+ import {EmbeddedPaginationStyleSheet} from "./stylesheet/embedded-pagination.mjs";
8
+ import {instanceSymbol} from "../../constants.mjs";
9
+
9
10
  import "../form/select.mjs";
10
- import { Pagination } from "./pagination.mjs";
11
+ import {Pagination} from "./pagination.mjs";
11
12
 
12
13
  import "./datasource/dom.mjs";
13
14
  import "./datasource/rest.mjs";
14
15
 
15
- export { EmbeddedPagination };
16
+
17
+ export {EmbeddedPagination};
16
18
 
17
19
  /**
18
20
  * The EmbeddedPagination component is used to show the current page and the total number of pages.
@@ -47,67 +49,53 @@ export { EmbeddedPagination };
47
49
  * @summary A datatable
48
50
  */
49
51
  class EmbeddedPagination extends Pagination {
50
- /**
51
- * This method is called by the `instanceof` operator.
52
- * @returns {symbol}
53
- */
54
- static get [instanceSymbol]() {
55
- return Symbol.for("@schukai/monster/components/embedded-pagination");
56
- }
52
+ /**
53
+ * This method is called by the `instanceof` operator.
54
+ * @returns {symbol}
55
+ */
56
+ static get [instanceSymbol]() {
57
+ return Symbol.for("@schukai/monster/components/embedded-pagination");
58
+ }
57
59
 
58
- /**
59
- *
60
- * @return {string}
61
- */
62
- static getTag() {
63
- return "monster-embedded-pagination";
64
- }
60
+ [assembleMethodSymbol]() {
61
+ super[assembleMethodSymbol]();
62
+ }
65
63
 
66
- /**
67
- *
68
- * @return {CSSStyleSheet[]}
69
- */
70
- static getCSSStyleSheet() {
71
- return [EmbeddedPaginationStyleSheet];
72
- }
73
- }
64
+ get defaults() {
65
+ return Object.assign(
66
+ {},
67
+ super.defaults,
68
+ {
69
+ classes: {
70
+ spinner: "monster-spinner monster-theme-primary-3",
71
+ spinnerContainer: "monster-theme-primary-2 ",
72
+ error: "monster-theme-error-2 monster-bg-color-primary-2",
73
+ errorContainer: "monster-theme-primary-2",
74
+ },
75
+
76
+ }
77
+ );
74
78
 
75
- /**
76
- * @private
77
- * @return {string}
78
- */
79
- function getTemplate() {
80
- // language=HTML
81
- return `
82
- <template id="items">
83
- <li><a data-monster-attributes="class path:items.class,
84
- href path:items.href,
85
- aria-label path:items.description,
86
- disabled path:items.disabled:?disabled:undefined,
87
- data-page-no path:items.pageNo,
88
- aria-current path:items.current"
89
- data-monster-role="pagination-item"
90
- data-monster-replace="path:items.label"></a></li>
91
- </template>
79
+ }
80
+
81
+ /**
82
+ *
83
+ * @return {string}
84
+ */
85
+ static getTag() {
86
+ return "monster-embedded-pagination";
87
+ }
88
+
89
+
90
+ /**
91
+ * @private
92
+ * @returns {CSSStyleSheet}
93
+ */
94
+ static getControlCSSStyleSheet() {
95
+ return EmbeddedPaginationStyleSheet;
96
+ }
92
97
 
93
- <div data-monster-role="control">
94
- <nav data-monster-role="pagination" role="navigation" aria-label="pagination">
95
- <ul class="pagination-list" data-monster-insert="items path:pagination.items">
96
- <li part="pagination-prev"><a data-monster-role="pagination-prev"
97
- data-monster-attributes="
98
- class path:pagination.prevClass | prefix: previous,
99
- data-page-no path:pagination.prevNo,
100
- href path:pagination.prevHref | prefix: #"
101
- data-monster-replace="path:labels.previous">Previous</a></li>
102
- <li part="pagination-next"><a data-monster-role="pagination-next"
103
- data-monster-attributes="class path:pagination.nextClass | prefix: next,
104
- data-page-no path:pagination.nextNo,
105
- href path:pagination.nextHref | prefix: #"
106
- data-monster-replace="path:labels.next">Next</a></li>
107
- </ul>
108
- </nav>
109
- </div>
110
- `;
111
98
  }
112
99
 
100
+
113
101
  registerCustomElement(EmbeddedPagination);
@@ -0,0 +1,122 @@
1
+ import {generateUniqueConfigKey} from "../../host/util.mjs";
2
+
3
+
4
+ /**
5
+ * @private
6
+ * @returns {string}
7
+ */
8
+ export function getFilterConfigKey() {
9
+ return generateUniqueConfigKey("datatable", this?.id, "filter");
10
+ }
11
+
12
+ /**
13
+ * @private
14
+ * @returns {string}
15
+ */
16
+ export function getStoredFilterConfigKey() {
17
+ return generateUniqueConfigKey("datatable", this?.id, "stored-filter");
18
+ }
19
+
20
+ /**
21
+ * @private
22
+ * @param {String} str
23
+ * @param {String} field
24
+ * @returns {String}
25
+ * @throws {Error} if no field is defined
26
+ */
27
+ export function parseDateInput(str, field) {
28
+ if (!str) {
29
+ return "";
30
+ }
31
+
32
+ if (!field) {
33
+ throw new Error("no field is defined");
34
+ }
35
+
36
+ // Define the supported formats
37
+ //let formats = ['DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD', 'YYYY/MM/DD', 'DD.MM.YYYY'];
38
+ const formats = ["YYYY-MM-DD"];
39
+ // Determine the current date format of the localization
40
+ const currentDateFormat = new Intl.DateTimeFormat()
41
+ .format(new Date())
42
+ .replace(/\d/g, "D");
43
+ // formats.push(currentDateFormat);
44
+
45
+ // Run through the supported formats and try to parse the date
46
+ for (let i = 0; i < formats.length; i++) {
47
+ const format = formats[i];
48
+ // Replace the corresponding placeholders in the format string with regular expressions
49
+
50
+ try {
51
+ const pattern = format
52
+ .replace("DD", "\\d{2}")
53
+ .replace("MM", "\\d{2}")
54
+ .replace("YYYY", "\\d{4}");
55
+ const rangePattern =
56
+ "(?<from>" + pattern + ")\\s*-\\s*(?<to>" + pattern + ")";
57
+
58
+ const rangeRegex = new RegExp("^" + rangePattern + "$", "g");
59
+
60
+ if (rangeRegex.test(str)) {
61
+ rangeRegex.lastIndex = 0;
62
+
63
+ const rangeResult = rangeRegex.exec(str);
64
+
65
+ if (!rangeResult) {
66
+ continue;
67
+ }
68
+
69
+ const from = rangeResult?.groups?.from;
70
+ const to = rangeResult?.groups?.to;
71
+
72
+ if (from && to) {
73
+ return ("(" + field + ">='" + from + " 00:00:00' AND " + field + "<='" + to + " 23:59:59')");
74
+ }
75
+
76
+ if (from) {
77
+ return "(" + field + ">='" + from + " 00:00:00')";
78
+ } else if (to) {
79
+ return "(" + field + "<='" + to + "' 23:59:59')";
80
+ }
81
+
82
+ return "false";
83
+ }
84
+
85
+ const prefix = str.substring(0, 1) === "-";
86
+ const suffix = str.substring(str.length - 1, str.length) === "-";
87
+
88
+ if (prefix) {
89
+ str = str.substring(1, str.length);
90
+ } else if (suffix) {
91
+ str = str.substring(0, str.length - 1);
92
+ }
93
+
94
+ const regex = new RegExp("^(?<date>" + pattern + ")$", "g");
95
+ if (regex.test(str)) {
96
+ regex.lastIndex = 0;
97
+ const result = regex.exec(str);
98
+
99
+ if (!result) {
100
+ continue;
101
+ }
102
+
103
+ const date = result?.groups?.date;
104
+ if (date) {
105
+ if (prefix) {
106
+ return "(" + field + "<='" + date + " 23:59:59')";
107
+ } else if (suffix) {
108
+ return "(" + field + ">='" + date + "' 00:00:00')";
109
+ }
110
+ return (
111
+ "(" + field + ">='" + date + " 00:00:00' AND " + field + "<='" + date + " 23:59:59')"
112
+ );
113
+ } else {
114
+ return "false";
115
+ }
116
+ }
117
+ } catch (e) {
118
+ }
119
+ }
120
+
121
+ return "false";
122
+ }