@mmlogic/components 0.3.4 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/dist/{collection/utils/cell-renderer.js → mosterdcomponents/cell-renderer-CbRwLOo8.js} +9 -3
  2. package/dist/mosterdcomponents/cell-renderer-CbRwLOo8.js.map +1 -0
  3. package/dist/{esm/index.js → mosterdcomponents/client-layout-D88nn5zf.js} +4 -1
  4. package/dist/mosterdcomponents/client-layout-D88nn5zf.js.map +1 -0
  5. package/dist/{collection/utils/format.js → mosterdcomponents/format-BAfsQfy1.js} +12 -7
  6. package/dist/mosterdcomponents/format-BAfsQfy1.js.map +1 -0
  7. package/dist/{collection/utils/i18n.js → mosterdcomponents/i18n-hoGGKbKU.js} +6 -1
  8. package/dist/mosterdcomponents/i18n-hoGGKbKU.js.map +1 -0
  9. package/dist/mosterdcomponents/index-B_tPFIvS.js +4585 -0
  10. package/dist/mosterdcomponents/index-B_tPFIvS.js.map +1 -0
  11. package/dist/mosterdcomponents/index-I5SuYv7a.js +4 -0
  12. package/dist/mosterdcomponents/index-I5SuYv7a.js.map +1 -0
  13. package/dist/mosterdcomponents/index.esm.js +5 -1
  14. package/dist/mosterdcomponents/index.esm.js.map +1 -0
  15. package/dist/mosterdcomponents/mosterdcomponents.css +180 -1
  16. package/dist/mosterdcomponents/mosterdcomponents.esm.js +50 -1
  17. package/dist/mosterdcomponents/mosterdcomponents.esm.js.map +1 -0
  18. package/dist/mosterdcomponents/mrd-boolean-field.entry.js +37 -0
  19. package/dist/mosterdcomponents/mrd-boolean-field.entry.js.map +1 -0
  20. package/dist/mosterdcomponents/mrd-currency-field.entry.js +67 -0
  21. package/dist/mosterdcomponents/mrd-currency-field.entry.js.map +1 -0
  22. package/dist/mosterdcomponents/mrd-date-field.entry.js +46 -0
  23. package/dist/mosterdcomponents/mrd-date-field.entry.js.map +1 -0
  24. package/dist/mosterdcomponents/mrd-datetime-field.entry.js +78 -0
  25. package/dist/mosterdcomponents/mrd-datetime-field.entry.js.map +1 -0
  26. package/dist/mosterdcomponents/mrd-email-field.entry.js +50 -0
  27. package/dist/mosterdcomponents/mrd-email-field.entry.js.map +1 -0
  28. package/dist/{collection/components/mrd-field/mrd-field.js → mosterdcomponents/mrd-field.entry.js} +28 -179
  29. package/dist/mosterdcomponents/mrd-field.entry.js.map +1 -0
  30. package/dist/mosterdcomponents/mrd-file-field.entry.js +108 -0
  31. package/dist/mosterdcomponents/mrd-file-field.entry.js.map +1 -0
  32. package/dist/{collection/components/mrd-form/mrd-form.js → mosterdcomponents/mrd-form.entry.js} +82 -280
  33. package/dist/mosterdcomponents/mrd-form.entry.js.map +1 -0
  34. package/dist/mosterdcomponents/mrd-hyperlink-field.entry.js +87 -0
  35. package/dist/mosterdcomponents/mrd-hyperlink-field.entry.js.map +1 -0
  36. package/dist/mosterdcomponents/mrd-image-field.entry.js +122 -0
  37. package/dist/mosterdcomponents/mrd-image-field.entry.js.map +1 -0
  38. package/dist/{collection/components/mrd-layout-section/mrd-layout-section.js → mosterdcomponents/mrd-layout-section.entry.js} +31 -418
  39. package/dist/mosterdcomponents/mrd-layout-section.entry.js.map +1 -0
  40. package/dist/mosterdcomponents/mrd-list-field.entry.js +107 -0
  41. package/dist/mosterdcomponents/mrd-list-field.entry.js.map +1 -0
  42. package/dist/mosterdcomponents/mrd-longtext-field.entry.js +47 -0
  43. package/dist/mosterdcomponents/mrd-longtext-field.entry.js.map +1 -0
  44. package/dist/mosterdcomponents/mrd-number-field.entry.js +87 -0
  45. package/dist/mosterdcomponents/mrd-number-field.entry.js.map +1 -0
  46. package/dist/mosterdcomponents/mrd-relation-field.entry.js +267 -0
  47. package/dist/mosterdcomponents/mrd-relation-field.entry.js.map +1 -0
  48. package/dist/mosterdcomponents/mrd-secret-field.entry.js +49 -0
  49. package/dist/mosterdcomponents/mrd-secret-field.entry.js.map +1 -0
  50. package/dist/{collection/components/mrd-table/mrd-table.js → mosterdcomponents/mrd-table.entry.js} +67 -398
  51. package/dist/mosterdcomponents/mrd-table.entry.js.map +1 -0
  52. package/dist/mosterdcomponents/mrd-text-field.entry.js +47 -0
  53. package/dist/mosterdcomponents/mrd-text-field.entry.js.map +1 -0
  54. package/dist/mosterdcomponents/mrd-textarea-field.entry.js +86 -0
  55. package/dist/mosterdcomponents/mrd-textarea-field.entry.js.map +1 -0
  56. package/dist/mosterdcomponents/mrd-time-field.entry.js +46 -0
  57. package/dist/mosterdcomponents/mrd-time-field.entry.js.map +1 -0
  58. package/dist/{esm/quill-CiuCgGz_.js → mosterdcomponents/quill-C9pgw_k-.js} +16282 -1397
  59. package/dist/mosterdcomponents/quill-C9pgw_k-.js.map +1 -0
  60. package/dist/{collection/utils/validation.js → mosterdcomponents/validation-ixb43cqU.js} +12 -5
  61. package/dist/mosterdcomponents/validation-ixb43cqU.js.map +1 -0
  62. package/dist/types/components/mrd-form/mrd-form.d.ts +13 -1
  63. package/dist/types/components/mrd-relation-field/mrd-relation-field.d.ts +3 -0
  64. package/dist/types/components/mrd-table/mrd-table.d.ts +4 -0
  65. package/dist/types/components.d.ts +19 -9
  66. package/package.json +1 -1
  67. package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -5
  68. package/dist/cjs/index-BPj2cBXs.js +0 -1570
  69. package/dist/cjs/index.cjs.js +0 -66
  70. package/dist/cjs/loader.cjs.js +0 -13
  71. package/dist/cjs/mosterdcomponents.cjs.js +0 -25
  72. package/dist/cjs/mrd-boolean-field_20.cjs.entry.js +0 -3848
  73. package/dist/cjs/quill-DmFfnC1f.js +0 -16272
  74. package/dist/collection/collection-manifest.json +0 -32
  75. package/dist/collection/components/mrd-boolean-field/mrd-boolean-field.js +0 -199
  76. package/dist/collection/components/mrd-boolean-field/mrd-boolean-field.scss +0 -77
  77. package/dist/collection/components/mrd-currency-field/mrd-currency-field.js +0 -248
  78. package/dist/collection/components/mrd-currency-field/mrd-currency-field.scss +0 -100
  79. package/dist/collection/components/mrd-date-field/mrd-date-field.js +0 -206
  80. package/dist/collection/components/mrd-date-field/mrd-date-field.scss +0 -66
  81. package/dist/collection/components/mrd-datetime-field/mrd-datetime-field.js +0 -240
  82. package/dist/collection/components/mrd-datetime-field/mrd-datetime-field.scss +0 -66
  83. package/dist/collection/components/mrd-email-field/mrd-email-field.js +0 -230
  84. package/dist/collection/components/mrd-email-field/mrd-email-field.scss +0 -69
  85. package/dist/collection/components/mrd-field/mrd-field.scss +0 -118
  86. package/dist/collection/components/mrd-file-field/mrd-file-field.js +0 -341
  87. package/dist/collection/components/mrd-file-field/mrd-file-field.scss +0 -153
  88. package/dist/collection/components/mrd-form/mrd-form.scss +0 -148
  89. package/dist/collection/components/mrd-hyperlink-field/mrd-hyperlink-field.js +0 -291
  90. package/dist/collection/components/mrd-hyperlink-field/mrd-hyperlink-field.scss +0 -91
  91. package/dist/collection/components/mrd-image-field/mrd-image-field.js +0 -356
  92. package/dist/collection/components/mrd-image-field/mrd-image-field.scss +0 -190
  93. package/dist/collection/components/mrd-layout-section/mrd-layout-section.scss +0 -445
  94. package/dist/collection/components/mrd-list-field/mrd-list-field.js +0 -313
  95. package/dist/collection/components/mrd-list-field/mrd-list-field.scss +0 -109
  96. package/dist/collection/components/mrd-longtext-field/mrd-longtext-field.js +0 -227
  97. package/dist/collection/components/mrd-longtext-field/mrd-longtext-field.scss +0 -78
  98. package/dist/collection/components/mrd-number-field/mrd-number-field.js +0 -316
  99. package/dist/collection/components/mrd-number-field/mrd-number-field.scss +0 -77
  100. package/dist/collection/components/mrd-relation-field/mrd-relation-field.js +0 -678
  101. package/dist/collection/components/mrd-relation-field/mrd-relation-field.scss +0 -266
  102. package/dist/collection/components/mrd-secret-field/mrd-secret-field.js +0 -229
  103. package/dist/collection/components/mrd-secret-field/mrd-secret-field.scss +0 -73
  104. package/dist/collection/components/mrd-table/mrd-table.scss +0 -742
  105. package/dist/collection/components/mrd-text-field/mrd-text-field.js +0 -227
  106. package/dist/collection/components/mrd-text-field/mrd-text-field.scss +0 -69
  107. package/dist/collection/components/mrd-textarea-field/mrd-textarea-field.js +0 -267
  108. package/dist/collection/components/mrd-textarea-field/mrd-textarea-field.scss +0 -79
  109. package/dist/collection/components/mrd-time-field/mrd-time-field.js +0 -206
  110. package/dist/collection/components/mrd-time-field/mrd-time-field.scss +0 -66
  111. package/dist/collection/dev/api.js +0 -136
  112. package/dist/collection/dev/app.js +0 -868
  113. package/dist/collection/dev/auth.js +0 -156
  114. package/dist/collection/dev/example-data.js +0 -403
  115. package/dist/collection/dev/sprites.svg +0 -55
  116. package/dist/collection/index.js +0 -1
  117. package/dist/collection/types/client-layout.js +0 -64
  118. package/dist/collection/types/index.js +0 -1
  119. package/dist/components/client-layout.js +0 -1
  120. package/dist/components/format.js +0 -1
  121. package/dist/components/i18n.js +0 -1
  122. package/dist/components/index.js +0 -1
  123. package/dist/components/mrd-boolean-field.js +0 -1
  124. package/dist/components/mrd-boolean-field2.js +0 -1
  125. package/dist/components/mrd-currency-field.js +0 -1
  126. package/dist/components/mrd-currency-field2.js +0 -1
  127. package/dist/components/mrd-date-field.js +0 -1
  128. package/dist/components/mrd-date-field2.js +0 -1
  129. package/dist/components/mrd-datetime-field.js +0 -1
  130. package/dist/components/mrd-datetime-field2.js +0 -1
  131. package/dist/components/mrd-email-field.js +0 -1
  132. package/dist/components/mrd-email-field2.js +0 -1
  133. package/dist/components/mrd-field.js +0 -1
  134. package/dist/components/mrd-field2.js +0 -1
  135. package/dist/components/mrd-file-field.js +0 -1
  136. package/dist/components/mrd-file-field2.js +0 -1
  137. package/dist/components/mrd-form.js +0 -1
  138. package/dist/components/mrd-hyperlink-field.js +0 -1
  139. package/dist/components/mrd-hyperlink-field2.js +0 -1
  140. package/dist/components/mrd-image-field.js +0 -1
  141. package/dist/components/mrd-image-field2.js +0 -1
  142. package/dist/components/mrd-layout-section.js +0 -1
  143. package/dist/components/mrd-list-field.js +0 -1
  144. package/dist/components/mrd-list-field2.js +0 -1
  145. package/dist/components/mrd-longtext-field.js +0 -1
  146. package/dist/components/mrd-longtext-field2.js +0 -1
  147. package/dist/components/mrd-number-field.js +0 -1
  148. package/dist/components/mrd-number-field2.js +0 -1
  149. package/dist/components/mrd-relation-field.js +0 -1
  150. package/dist/components/mrd-relation-field2.js +0 -1
  151. package/dist/components/mrd-secret-field.js +0 -1
  152. package/dist/components/mrd-secret-field2.js +0 -1
  153. package/dist/components/mrd-table.js +0 -1
  154. package/dist/components/mrd-table2.js +0 -1
  155. package/dist/components/mrd-text-field.js +0 -1
  156. package/dist/components/mrd-text-field2.js +0 -1
  157. package/dist/components/mrd-textarea-field.js +0 -1
  158. package/dist/components/mrd-textarea-field2.js +0 -1
  159. package/dist/components/mrd-time-field.js +0 -1
  160. package/dist/components/mrd-time-field2.js +0 -1
  161. package/dist/components/quill.js +0 -1
  162. package/dist/components/validation.js +0 -1
  163. package/dist/esm/app-globals-DQuL1Twl.js +0 -3
  164. package/dist/esm/index-_tsCCkAi.js +0 -1561
  165. package/dist/esm/loader.js +0 -11
  166. package/dist/esm/mosterdcomponents.js +0 -21
  167. package/dist/esm/mrd-boolean-field_20.entry.js +0 -3827
  168. package/dist/index.cjs.js +0 -1
  169. package/dist/index.js +0 -1
  170. package/dist/mosterdcomponents/p-CiuCgGz_.js +0 -1
  171. package/dist/mosterdcomponents/p-DQuL1Twl.js +0 -1
  172. package/dist/mosterdcomponents/p-_tsCCkAi.js +0 -2
  173. package/dist/mosterdcomponents/p-c9839596.entry.js +0 -1
@@ -1,206 +0,0 @@
1
- import { Host, h } from "@stencil/core";
2
- import { t } from "../../utils/i18n";
3
- import { validateRequired } from "../../utils/validation";
4
- export class MrdTimeField {
5
- constructor() {
6
- this.name = '';
7
- this.label = '';
8
- this.value = '';
9
- this.required = false;
10
- this.disabled = false;
11
- this.locale = navigator.language;
12
- this.error = '';
13
- this.handleChange = (e) => {
14
- const val = e.target.value;
15
- if (this.required && !validateRequired(val)) {
16
- this.error = t('required', this.locale);
17
- }
18
- else {
19
- this.error = '';
20
- }
21
- this.mrdChange.emit({ name: this.name, value: val });
22
- };
23
- this.handleBlur = (e) => {
24
- const val = e.target.value;
25
- this.mrdBlur.emit({ name: this.name, value: val });
26
- };
27
- }
28
- render() {
29
- const hasError = !!this.error;
30
- return (h(Host, { key: 'c507996709437d8982f9175b286e25598997002d' }, h("div", { key: 'd5f1b7f14d26cae8298cd40491898b39044158f8', class: "mrd-time-field" }, this.label && (h("label", { key: '10976e18df09240e00b045314c4ddd3845d4bfdc', class: `mrd-time-field__label${this.required ? ' mrd-time-field__label--required' : ''}` }, this.label)), h("input", { key: 'bc557333f107a371a7005f9b56dd0395190e63d7', class: `mrd-time-field__input${hasError ? ' mrd-time-field__input--error' : ''}`, type: "time", name: this.name, value: this.value, required: this.required, disabled: this.disabled, onChange: this.handleChange, onBlur: this.handleBlur }), hasError && h("span", { key: 'b5a09c2aa063fa9e2fc3aba411e86b57d879c408', class: "mrd-time-field__error" }, this.error))));
31
- }
32
- static get is() { return "mrd-time-field"; }
33
- static get encapsulation() { return "scoped"; }
34
- static get originalStyleUrls() {
35
- return {
36
- "$": ["mrd-time-field.scss"]
37
- };
38
- }
39
- static get styleUrls() {
40
- return {
41
- "$": ["mrd-time-field.css"]
42
- };
43
- }
44
- static get properties() {
45
- return {
46
- "name": {
47
- "type": "string",
48
- "mutable": false,
49
- "complexType": {
50
- "original": "string",
51
- "resolved": "string",
52
- "references": {}
53
- },
54
- "required": false,
55
- "optional": false,
56
- "docs": {
57
- "tags": [],
58
- "text": ""
59
- },
60
- "getter": false,
61
- "setter": false,
62
- "reflect": false,
63
- "attribute": "name",
64
- "defaultValue": "''"
65
- },
66
- "label": {
67
- "type": "string",
68
- "mutable": false,
69
- "complexType": {
70
- "original": "string",
71
- "resolved": "string",
72
- "references": {}
73
- },
74
- "required": false,
75
- "optional": false,
76
- "docs": {
77
- "tags": [],
78
- "text": ""
79
- },
80
- "getter": false,
81
- "setter": false,
82
- "reflect": false,
83
- "attribute": "label",
84
- "defaultValue": "''"
85
- },
86
- "value": {
87
- "type": "string",
88
- "mutable": false,
89
- "complexType": {
90
- "original": "string",
91
- "resolved": "string",
92
- "references": {}
93
- },
94
- "required": false,
95
- "optional": false,
96
- "docs": {
97
- "tags": [],
98
- "text": ""
99
- },
100
- "getter": false,
101
- "setter": false,
102
- "reflect": false,
103
- "attribute": "value",
104
- "defaultValue": "''"
105
- },
106
- "required": {
107
- "type": "boolean",
108
- "mutable": false,
109
- "complexType": {
110
- "original": "boolean",
111
- "resolved": "boolean",
112
- "references": {}
113
- },
114
- "required": false,
115
- "optional": false,
116
- "docs": {
117
- "tags": [],
118
- "text": ""
119
- },
120
- "getter": false,
121
- "setter": false,
122
- "reflect": false,
123
- "attribute": "required",
124
- "defaultValue": "false"
125
- },
126
- "disabled": {
127
- "type": "boolean",
128
- "mutable": false,
129
- "complexType": {
130
- "original": "boolean",
131
- "resolved": "boolean",
132
- "references": {}
133
- },
134
- "required": false,
135
- "optional": false,
136
- "docs": {
137
- "tags": [],
138
- "text": ""
139
- },
140
- "getter": false,
141
- "setter": false,
142
- "reflect": false,
143
- "attribute": "disabled",
144
- "defaultValue": "false"
145
- },
146
- "locale": {
147
- "type": "string",
148
- "mutable": false,
149
- "complexType": {
150
- "original": "string",
151
- "resolved": "string",
152
- "references": {}
153
- },
154
- "required": false,
155
- "optional": false,
156
- "docs": {
157
- "tags": [],
158
- "text": ""
159
- },
160
- "getter": false,
161
- "setter": false,
162
- "reflect": false,
163
- "attribute": "locale",
164
- "defaultValue": "navigator.language"
165
- }
166
- };
167
- }
168
- static get states() {
169
- return {
170
- "error": {}
171
- };
172
- }
173
- static get events() {
174
- return [{
175
- "method": "mrdChange",
176
- "name": "mrdChange",
177
- "bubbles": true,
178
- "cancelable": true,
179
- "composed": true,
180
- "docs": {
181
- "tags": [],
182
- "text": ""
183
- },
184
- "complexType": {
185
- "original": "{ name: string; value: string }",
186
- "resolved": "{ name: string; value: string; }",
187
- "references": {}
188
- }
189
- }, {
190
- "method": "mrdBlur",
191
- "name": "mrdBlur",
192
- "bubbles": true,
193
- "cancelable": true,
194
- "composed": true,
195
- "docs": {
196
- "tags": [],
197
- "text": ""
198
- },
199
- "complexType": {
200
- "original": "{ name: string; value: string }",
201
- "resolved": "{ name: string; value: string; }",
202
- "references": {}
203
- }
204
- }];
205
- }
206
- }
@@ -1,66 +0,0 @@
1
- :host {
2
- display: block;
3
- }
4
-
5
- .mrd-time-field {
6
- display: flex;
7
- flex-direction: column;
8
- gap: var(--mrd-space-1);
9
- width: 100%;
10
- }
11
-
12
- .mrd-time-field__label {
13
- display: block;
14
- font-family: var(--mrd-font-family);
15
- font-size: var(--mrd-label-font-size);
16
- font-weight: var(--mrd-label-font-weight);
17
- color: var(--mrd-label-color);
18
- }
19
-
20
- .mrd-time-field__label--required::after {
21
- content: ' *';
22
- color: var(--mrd-color-danger);
23
- }
24
-
25
- .mrd-time-field__input {
26
- display: block;
27
- width: 100%;
28
- height: var(--mrd-input-height);
29
- padding: var(--mrd-input-padding-y) var(--mrd-input-padding-x);
30
- font-family: var(--mrd-font-family);
31
- font-size: var(--mrd-font-size-base);
32
- color: var(--mrd-input-color);
33
- background-color: var(--mrd-input-bg);
34
- border: var(--mrd-border-width) solid var(--mrd-border-color);
35
- border-radius: var(--mrd-border-radius);
36
- transition: border-color var(--mrd-transition), box-shadow var(--mrd-transition);
37
- outline: none;
38
- appearance: none;
39
- box-sizing: border-box;
40
- cursor: pointer;
41
- }
42
-
43
- .mrd-time-field__input:focus {
44
- border-color: var(--mrd-border-color-focus);
45
- box-shadow: var(--mrd-shadow-focus);
46
- }
47
-
48
- .mrd-time-field__input:disabled {
49
- background-color: var(--mrd-input-bg-disabled);
50
- cursor: not-allowed;
51
- opacity: 0.7;
52
- }
53
-
54
- .mrd-time-field__input--error {
55
- border-color: var(--mrd-border-color-error);
56
- }
57
-
58
- .mrd-time-field__input--error:focus {
59
- box-shadow: var(--mrd-shadow-focus-error);
60
- }
61
-
62
- .mrd-time-field__error {
63
- font-family: var(--mrd-font-family);
64
- font-size: var(--mrd-error-font-size);
65
- color: var(--mrd-error-color);
66
- }
@@ -1,136 +0,0 @@
1
- /* =====================================================================
2
- API HELPERS
3
- ===================================================================== */
4
-
5
- const API_BASE = 'http://localhost:8080';
6
-
7
- /**
8
- * Generic fetch wrapper. Accepts both absolute URLs (from _links.self.href)
9
- * and relative paths (prefixed with API_BASE).
10
- */
11
- async function apiRequest(method, path, token, body) {
12
- const opts = {
13
- method,
14
- headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
15
- };
16
- if (body !== undefined) opts.body = JSON.stringify(body);
17
- const url = path.startsWith('http') ? path : API_BASE + path;
18
- const resp = await fetch(url, opts);
19
- const text = await resp.text();
20
- let json;
21
- try { json = JSON.parse(text); } catch (_) { json = text; }
22
- return { status: resp.status, ok: resp.ok, body: json };
23
- }
24
-
25
- async function apiFetchTenants(token) {
26
- const { ok, status, body } = await apiRequest('GET', '/tenants', token);
27
- if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
28
- return body; // array of { tenantCode, name, description, logo }
29
- }
30
-
31
- async function apiFetchTypes(token, tenantCode) {
32
- const { ok, status, body } = await apiRequest('GET', `/metadata/${tenantCode}/types`, token);
33
- if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
34
- return body; // array of { name, pluralName, type, ... }
35
- }
36
-
37
- async function apiFetchForm(token, tenantCode, pluralName, formHref = null) {
38
- const path = formHref || `/metadata/${tenantCode}/form?types=${pluralName}`;
39
- const { ok, status, body } = await apiRequest('GET', path, token);
40
- if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
41
- const raw = (body && body.layouts && body.layouts.length > 0) ? body.layouts[0]
42
- : (Array.isArray(body) && body.length > 0) ? body[0]
43
- : body;
44
- return mapApiLayoutToMrdForm(raw);
45
- }
46
-
47
- async function apiFetchDashboard(token, tenantCode, pluralName) {
48
- const language = navigator.language;
49
- const { ok, status, body } = await apiRequest('GET', `/metadata/${tenantCode}/dashboard/${pluralName}?language=${language}`, token);
50
- if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
51
- return body; // { layouts, views, _links }
52
- }
53
-
54
- async function apiFetchClassDashboard(token, tenantCode, pluralName, name) {
55
- const qs = new URLSearchParams({ language: navigator.language });
56
- if (name) qs.set('name', name);
57
- const { ok, status, body } = await apiRequest('GET', `/metadata/${tenantCode}/dashboard/${pluralName}?${qs}`, token);
58
- if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
59
- return body;
60
- }
61
-
62
- async function apiFetchGeneralDashboard(token, tenantCode, name) {
63
- const qs = new URLSearchParams({ language: navigator.language });
64
- if (name) qs.set('name', name);
65
- const { ok, status, body } = await apiRequest('GET', `/metadata/${tenantCode}/dashboard?${qs}`, token);
66
- if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
67
- return body;
68
- }
69
-
70
- async function apiFetchNavigationPane(token, tenantCode, name) {
71
- const qs = new URLSearchParams({ language: navigator.language });
72
- if (name) qs.set('name', name);
73
- const { ok, status, body } = await apiRequest('GET', `/metadata/${tenantCode}/navigationPane?${qs}`, token);
74
- if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
75
- return body;
76
- }
77
-
78
-
79
- async function apiFetchPage(token, baseHref, pageNumber, sort = '') {
80
- const sep = baseHref.includes('?') ? '&' : '?';
81
- let url = `${baseHref}${sep}page=${pageNumber}`;
82
- if (sort) url += `&sort=${encodeURIComponent(sort)}`;
83
- const { ok, status, body } = await apiRequest('GET', url, token);
84
- if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
85
- return body; // { _embedded, _links, page }
86
- }
87
-
88
- async function apiSubmitForm(token, tenantCode, pluralName, values) {
89
- const { status, ok, body } = await apiRequest('POST', `/data/${tenantCode}/${pluralName}`, token, values);
90
- return { status, ok, body };
91
- }
92
-
93
- async function apiUploadFile(token, tenantCode, file) {
94
- // Step 1: obtain a one-time upload URL
95
- const { ok, status, body } = await apiRequest('GET', `/data/${tenantCode}/upload`, token);
96
- if (!ok) throw new Error(`Upload-URL ophalen mislukt (${status})`);
97
- const uploadUrl = typeof body === 'string' ? body : String(body);
98
-
99
- // Step 2: upload the file as multipart (no auth required)
100
- const formData = new FormData();
101
- formData.append('file', file);
102
- const resp = await fetch(uploadUrl, { method: 'POST', body: formData });
103
- if (!resp.ok) throw new Error(`Bestand uploaden mislukt (${resp.status})`);
104
- const uris = await resp.json();
105
- if (!Array.isArray(uris) || uris.length === 0) throw new Error('Geen binary URI ontvangen na upload');
106
- return uris[0];
107
- }
108
-
109
- async function apiSearchRelation(token, tenantCode, mostSignificantClass, query) {
110
- const q = encodeURIComponent(query);
111
- const { ok, status, body } = await apiRequest('GET', `/data/${tenantCode}/${mostSignificantClass}?q=${q}`, token);
112
- if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
113
- const items = (body._embedded && body._embedded[mostSignificantClass]) || [];
114
- return items.map(item => ({
115
- id: item._links.self.href,
116
- label: item.name || item.label || '?',
117
- }));
118
- }
119
-
120
- /* =====================================================================
121
- LAYOUT MAPPERS
122
- mrd-form and mrd-field now accept the flat API format directly.
123
- No transformation needed — pass the raw layout through as-is.
124
- ===================================================================== */
125
-
126
- /**
127
- * Extract a ClientLayout from the raw API form response.
128
- * The API sends flat items (name, dataType, relatedClass at root level)
129
- * which mrd-form/mrd-field read directly.
130
- */
131
- function mapApiLayoutToMrdForm(raw) {
132
- if (!raw) return raw;
133
- // Unwrap OBJECT_FORM_DASHBOARD: keep items at top level, drop type wrapper
134
- if (Array.isArray(raw.items)) return raw;
135
- return raw;
136
- }