@mmlogic/components 0.1.30 → 0.3.0
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.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mosterdcomponents.cjs.js +1 -1
- package/dist/cjs/mrd-boolean-field_19.cjs.entry.js +349 -297
- package/dist/collection/components/mrd-field/mrd-field.js +18 -20
- package/dist/collection/components/mrd-form/mrd-form.js +38 -46
- package/dist/collection/components/mrd-layout-section/mrd-layout-section.js +82 -212
- package/dist/collection/components/mrd-table/mrd-table.js +255 -219
- package/dist/collection/dev/api.js +32 -103
- package/dist/collection/dev/app.js +386 -283
- package/dist/collection/dev/example-data.js +111 -299
- package/dist/collection/utils/cell-renderer.js +7 -5
- package/dist/components/mrd-field2.js +1 -1
- package/dist/components/mrd-form.js +1 -1
- package/dist/components/mrd-layout-section.js +1 -1
- package/dist/components/mrd-table2.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mosterdcomponents.js +1 -1
- package/dist/esm/mrd-boolean-field_19.entry.js +349 -297
- package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
- package/dist/mosterdcomponents/p-f6d0f02b.entry.js +1 -0
- package/dist/types/components/mrd-layout-section/mrd-layout-section.d.ts +16 -29
- package/dist/types/components/mrd-table/mrd-table.d.ts +36 -24
- package/dist/types/components.d.ts +39 -85
- package/dist/types/types/client-layout.d.ts +39 -15
- package/package.json +1 -1
- package/dist/mosterdcomponents/p-9ecefa81.entry.js +0 -1
|
@@ -51,14 +51,31 @@ async function apiFetchDashboard(token, tenantCode, pluralName) {
|
|
|
51
51
|
return body; // { layouts, views, _links }
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return
|
|
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;
|
|
60
76
|
}
|
|
61
77
|
|
|
78
|
+
|
|
62
79
|
async function apiFetchPage(token, baseHref, pageNumber, sort = '') {
|
|
63
80
|
const sep = baseHref.includes('?') ? '&' : '?';
|
|
64
81
|
let url = `${baseHref}${sep}page=${pageNumber}`;
|
|
@@ -102,106 +119,18 @@ async function apiSearchRelation(token, tenantCode, mostSignificantClass, query)
|
|
|
102
119
|
|
|
103
120
|
/* =====================================================================
|
|
104
121
|
LAYOUT MAPPERS
|
|
105
|
-
|
|
106
|
-
|
|
122
|
+
mrd-form and mrd-field now accept the flat API format directly.
|
|
123
|
+
No transformation needed — pass the raw layout through as-is.
|
|
107
124
|
===================================================================== */
|
|
108
125
|
|
|
109
126
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
function mapApiItem(item) {
|
|
114
|
-
if (item.type === 'FIELD') {
|
|
115
|
-
if (item.field) return item; // already nested — pass through
|
|
116
|
-
return {
|
|
117
|
-
type: 'FIELD',
|
|
118
|
-
field: {
|
|
119
|
-
name: item.name,
|
|
120
|
-
label: item.label,
|
|
121
|
-
dataType: item.dataType,
|
|
122
|
-
required: !!item.required,
|
|
123
|
-
multiple: !!item.multiple,
|
|
124
|
-
header: !!item.header,
|
|
125
|
-
defaultValue: item.defaultValue ?? null,
|
|
126
|
-
listItems: item.listItems ?? null,
|
|
127
|
-
aggregate: item.aggregate ?? null,
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
if (item.type === 'RELATION') {
|
|
132
|
-
if (item.relation) return item; // already nested — pass through
|
|
133
|
-
return {
|
|
134
|
-
type: 'RELATION',
|
|
135
|
-
relation: {
|
|
136
|
-
name: item.name,
|
|
137
|
-
label: item.label,
|
|
138
|
-
relatedClass: item.relatedClass,
|
|
139
|
-
mostSignificantClass: item.mostSignificantClass ?? null,
|
|
140
|
-
displayType: item.editBehavior ?? 'SEARCH',
|
|
141
|
-
editBehavior: item.editBehavior ?? null,
|
|
142
|
-
commonRelation: item.commonRelation ?? null,
|
|
143
|
-
required: !!item.required,
|
|
144
|
-
multiple: !!item.multiple,
|
|
145
|
-
defaultValue: item.defaultValue ?? null,
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
if (Array.isArray(item.items)) {
|
|
150
|
-
return { ...item, items: item.items.map(mapApiItem) };
|
|
151
|
-
}
|
|
152
|
-
return item;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Map API layout (OBJECT_FORM_DASHBOARD shape) → ClientLayout for mrd-form.
|
|
157
|
-
*
|
|
158
|
-
* IMPORTANT: always map editBehavior and commonRelation from the API response —
|
|
159
|
-
* omitting them causes relation fields to fall back to SEARCH mode.
|
|
160
|
-
* _relationMeta must be keyed by BOTH relatedClass AND mostSignificantClass
|
|
161
|
-
* because mrdSearch sends mostSignificantClass as the lookup key.
|
|
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.
|
|
162
130
|
*/
|
|
163
131
|
function mapApiLayoutToMrdForm(raw) {
|
|
164
|
-
if (!raw
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
type: 'FIELD',
|
|
170
|
-
field: {
|
|
171
|
-
name: item.name,
|
|
172
|
-
label: item.label,
|
|
173
|
-
dataType: item.dataType,
|
|
174
|
-
required: !!item.required,
|
|
175
|
-
multiple: !!item.multiple,
|
|
176
|
-
header: !!item.header,
|
|
177
|
-
defaultValue: item.defaultValue ?? null,
|
|
178
|
-
listItems: item.listItems ?? null,
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
if (item.type === 'RELATION') {
|
|
183
|
-
return {
|
|
184
|
-
type: 'RELATION',
|
|
185
|
-
relation: {
|
|
186
|
-
name: item.name,
|
|
187
|
-
label: item.label,
|
|
188
|
-
relatedClass: item.relatedClass,
|
|
189
|
-
mostSignificantClass: item.mostSignificantClass ?? null,
|
|
190
|
-
displayType: item.editBehavior ?? 'SEARCH',
|
|
191
|
-
editBehavior: item.editBehavior ?? null,
|
|
192
|
-
commonRelation: item.commonRelation ?? null,
|
|
193
|
-
required: !!item.required,
|
|
194
|
-
multiple: !!item.multiple,
|
|
195
|
-
defaultValue: item.defaultValue ?? null,
|
|
196
|
-
},
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
// SECTION / GROUP — recurse into children
|
|
200
|
-
if (Array.isArray(item.items)) {
|
|
201
|
-
return { ...item, items: item.items.map(mapItem) };
|
|
202
|
-
}
|
|
203
|
-
return item;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return { items: raw.items.map(mapItem) };
|
|
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;
|
|
207
136
|
}
|