@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
|
@@ -27,34 +27,32 @@ export class MrdField {
|
|
|
27
27
|
render() {
|
|
28
28
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
29
29
|
const { item, locale, value } = this;
|
|
30
|
-
if (item.type === ClientLayoutItemType.RELATION
|
|
31
|
-
|
|
32
|
-
return (h(Host, null, h("mrd-relation-field", { name: rel.name, label: rel.label, required: rel.required, disabled: (_a = rel.disabled) !== null && _a !== void 0 ? _a : false, locale: locale, relatedClass: rel.relatedClass, mostSignificantClass: (_b = rel.mostSignificantClass) !== null && _b !== void 0 ? _b : '', displayType: (_c = rel.displayType) !== null && _c !== void 0 ? _c : ClientLayoutItemRelationDisplayType.SEARCH, editBehavior: (_d = rel.editBehavior) !== null && _d !== void 0 ? _d : null, commonRelation: rel.commonRelation, multiple: (_e = rel.multiple) !== null && _e !== void 0 ? _e : false, dropdownValues: (_f = rel.dropdownValues) !== null && _f !== void 0 ? _f : [], value: value, onMrdChange: this.handleChange, onMrdBlur: this.handleBlur, onMrdSearch: this.handleSearch, onMrdFetchAll: this.handleFetchAll })));
|
|
30
|
+
if (item.type === ClientLayoutItemType.RELATION) {
|
|
31
|
+
return (h(Host, null, h("mrd-relation-field", { name: item.name, label: item.label, required: item.required, disabled: (_a = item.disabled) !== null && _a !== void 0 ? _a : false, locale: locale, relatedClass: item.relatedClass, mostSignificantClass: (_b = item.mostSignificantClass) !== null && _b !== void 0 ? _b : '', displayType: (_c = item.displayType) !== null && _c !== void 0 ? _c : ClientLayoutItemRelationDisplayType.SEARCH, editBehavior: (_d = item.editBehavior) !== null && _d !== void 0 ? _d : null, commonRelation: item.commonRelation, multiple: (_e = item.multiple) !== null && _e !== void 0 ? _e : false, dropdownValues: (_f = item.dropdownValues) !== null && _f !== void 0 ? _f : [], value: value, onMrdChange: this.handleChange, onMrdBlur: this.handleBlur, onMrdSearch: this.handleSearch, onMrdFetchAll: this.handleFetchAll })));
|
|
33
32
|
}
|
|
34
|
-
if (item.type !== ClientLayoutItemType.FIELD
|
|
33
|
+
if (item.type !== ClientLayoutItemType.FIELD) {
|
|
35
34
|
return h(Host, null);
|
|
36
35
|
}
|
|
37
|
-
const field = item.field;
|
|
38
36
|
const commonProps = {
|
|
39
|
-
name:
|
|
40
|
-
label:
|
|
41
|
-
required:
|
|
42
|
-
disabled: (_g =
|
|
37
|
+
name: item.name,
|
|
38
|
+
label: item.label,
|
|
39
|
+
required: item.required,
|
|
40
|
+
disabled: (_g = item.disabled) !== null && _g !== void 0 ? _g : false,
|
|
43
41
|
locale,
|
|
44
42
|
onMrdChange: this.handleChange,
|
|
45
43
|
onMrdBlur: this.handleBlur,
|
|
46
44
|
};
|
|
47
|
-
switch (
|
|
45
|
+
switch (item.dataType) {
|
|
48
46
|
case ClientLayoutItemFieldDataType.TEXT:
|
|
49
|
-
return (h(Host, null, h("mrd-text-field", Object.assign({}, commonProps, { value: (_h = value) !== null && _h !== void 0 ? _h : '', placeholder: (_j =
|
|
47
|
+
return (h(Host, null, h("mrd-text-field", Object.assign({}, commonProps, { value: (_h = value) !== null && _h !== void 0 ? _h : '', placeholder: (_j = item.placeholder) !== null && _j !== void 0 ? _j : '' }))));
|
|
50
48
|
case ClientLayoutItemFieldDataType.TEXTBLOCK:
|
|
51
|
-
return (h(Host, null, h("mrd-textarea-field", Object.assign({}, commonProps, { value: (_k = value) !== null && _k !== void 0 ? _k : '', placeholder: (_l =
|
|
49
|
+
return (h(Host, null, h("mrd-textarea-field", Object.assign({}, commonProps, { value: (_k = value) !== null && _k !== void 0 ? _k : '', placeholder: (_l = item.placeholder) !== null && _l !== void 0 ? _l : '' }))));
|
|
52
50
|
case ClientLayoutItemFieldDataType.INTEGER:
|
|
53
51
|
case ClientLayoutItemFieldDataType.DECIMAL:
|
|
54
52
|
case ClientLayoutItemFieldDataType.PERCENTAGE:
|
|
55
|
-
return (h(Host, null, h("mrd-number-field", Object.assign({}, commonProps, { value: (_m = value) !== null && _m !== void 0 ? _m : null, dataType:
|
|
53
|
+
return (h(Host, null, h("mrd-number-field", Object.assign({}, commonProps, { value: (_m = value) !== null && _m !== void 0 ? _m : null, dataType: item.dataType, decimalPrecision: (_o = item.decimalPrecision) !== null && _o !== void 0 ? _o : 2, placeholder: (_p = item.placeholder) !== null && _p !== void 0 ? _p : '' }))));
|
|
56
54
|
case ClientLayoutItemFieldDataType.CURRENCY:
|
|
57
|
-
return (h(Host, null, h("mrd-currency-field", Object.assign({}, commonProps, { value: (_q = value) !== null && _q !== void 0 ? _q : { amount: null, currency: (_r =
|
|
55
|
+
return (h(Host, null, h("mrd-currency-field", Object.assign({}, commonProps, { value: (_q = value) !== null && _q !== void 0 ? _q : { amount: null, currency: (_r = item.currencyCode) !== null && _r !== void 0 ? _r : 'EUR' } }))));
|
|
58
56
|
case ClientLayoutItemFieldDataType.BOOLEAN:
|
|
59
57
|
return (h(Host, null, h("mrd-boolean-field", Object.assign({}, commonProps, { value: (_s = value) !== null && _s !== void 0 ? _s : false }))));
|
|
60
58
|
case ClientLayoutItemFieldDataType.DATE:
|
|
@@ -64,17 +62,17 @@ export class MrdField {
|
|
|
64
62
|
case ClientLayoutItemFieldDataType.TIME:
|
|
65
63
|
return (h(Host, null, h("mrd-time-field", Object.assign({}, commonProps, { value: (_v = value) !== null && _v !== void 0 ? _v : '' }))));
|
|
66
64
|
case ClientLayoutItemFieldDataType.EMAIL:
|
|
67
|
-
return (h(Host, null, h("mrd-email-field", Object.assign({}, commonProps, { value: (_w = value) !== null && _w !== void 0 ? _w : '', placeholder: (_x =
|
|
65
|
+
return (h(Host, null, h("mrd-email-field", Object.assign({}, commonProps, { value: (_w = value) !== null && _w !== void 0 ? _w : '', placeholder: (_x = item.placeholder) !== null && _x !== void 0 ? _x : '' }))));
|
|
68
66
|
case ClientLayoutItemFieldDataType.HYPERLINK:
|
|
69
|
-
return (h(Host, null, h("mrd-hyperlink-field", Object.assign({}, commonProps, { value: (_y = value) !== null && _y !== void 0 ? _y : '', placeholder: (_z =
|
|
67
|
+
return (h(Host, null, h("mrd-hyperlink-field", Object.assign({}, commonProps, { value: (_y = value) !== null && _y !== void 0 ? _y : '', placeholder: (_z = item.placeholder) !== null && _z !== void 0 ? _z : '' }))));
|
|
70
68
|
case ClientLayoutItemFieldDataType.LIST:
|
|
71
|
-
return (h(Host, null, h("mrd-list-field", Object.assign({}, commonProps, { value: (_0 = value) !== null && _0 !== void 0 ? _0 : '', multiple: (_1 =
|
|
69
|
+
return (h(Host, null, h("mrd-list-field", Object.assign({}, commonProps, { value: (_0 = value) !== null && _0 !== void 0 ? _0 : '', multiple: (_1 = item.multiple) !== null && _1 !== void 0 ? _1 : false, listItems: (_2 = item.listItems) !== null && _2 !== void 0 ? _2 : [] }))));
|
|
72
70
|
case ClientLayoutItemFieldDataType.FILE:
|
|
73
|
-
return (h(Host, null, h("mrd-file-field", Object.assign({}, commonProps, { value: value, accept: (_3 =
|
|
71
|
+
return (h(Host, null, h("mrd-file-field", Object.assign({}, commonProps, { value: value, accept: (_3 = item.accept) !== null && _3 !== void 0 ? _3 : '', maxSize: (_4 = item.maxSize) !== null && _4 !== void 0 ? _4 : 0, onMrdUpload: this.handleUpload }))));
|
|
74
72
|
case ClientLayoutItemFieldDataType.IMAGE:
|
|
75
|
-
return (h(Host, null, h("mrd-image-field", Object.assign({}, commonProps, { value: value, accept: (_5 =
|
|
73
|
+
return (h(Host, null, h("mrd-image-field", Object.assign({}, commonProps, { value: value, accept: (_5 = item.accept) !== null && _5 !== void 0 ? _5 : 'image/*', maxSize: (_6 = item.maxSize) !== null && _6 !== void 0 ? _6 : 0, onMrdUpload: this.handleUpload }))));
|
|
76
74
|
case ClientLayoutItemFieldDataType.LONGTEXT:
|
|
77
|
-
return (h(Host, null, h("mrd-longtext-field", Object.assign({}, commonProps, { value: (_7 = value) !== null && _7 !== void 0 ? _7 : '', placeholder: (_8 =
|
|
75
|
+
return (h(Host, null, h("mrd-longtext-field", Object.assign({}, commonProps, { value: (_7 = value) !== null && _7 !== void 0 ? _7 : '', placeholder: (_8 = item.placeholder) !== null && _8 !== void 0 ? _8 : '' }))));
|
|
78
76
|
case ClientLayoutItemFieldDataType.JSON:
|
|
79
77
|
return h(Host, null);
|
|
80
78
|
default:
|
|
@@ -45,17 +45,17 @@ export class MrdForm {
|
|
|
45
45
|
const newHref = this.getHref(value);
|
|
46
46
|
if (newHref === prevHref)
|
|
47
47
|
return;
|
|
48
|
-
for (const
|
|
49
|
-
if (
|
|
48
|
+
for (const item of this.collectDependentDropdowns()) {
|
|
49
|
+
if (item.commonRelation !== name)
|
|
50
50
|
continue;
|
|
51
51
|
// Clear the dependent field's current selection (options have changed)
|
|
52
|
-
this.formValues = Object.assign(Object.assign({}, this.formValues), { [
|
|
52
|
+
this.formValues = Object.assign(Object.assign({}, this.formValues), { [item.name]: null });
|
|
53
53
|
this.mrdFetchAll.emit({
|
|
54
|
-
name:
|
|
55
|
-
relatedClass:
|
|
56
|
-
mostSignificantClass:
|
|
57
|
-
commonRelation:
|
|
58
|
-
filter:
|
|
54
|
+
name: item.name,
|
|
55
|
+
relatedClass: item.relatedClass,
|
|
56
|
+
mostSignificantClass: item.mostSignificantClass,
|
|
57
|
+
commonRelation: item.commonRelation,
|
|
58
|
+
filter: item.commonRelation + '_href',
|
|
59
59
|
filterValue: newHref, // empty string when dependency was cleared → host should clear the list
|
|
60
60
|
});
|
|
61
61
|
}
|
|
@@ -130,24 +130,20 @@ export class MrdForm {
|
|
|
130
130
|
var _a, _b;
|
|
131
131
|
const allItems = this.collectFields((_b = (_a = this.layout) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : []);
|
|
132
132
|
// Strategy 1: direct match on mostSignificantClass
|
|
133
|
-
const direct = allItems.find(item =>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
});
|
|
138
|
-
if (direct === null || direct === void 0 ? void 0 : direct.relation)
|
|
139
|
-
return direct.relation.name;
|
|
133
|
+
const direct = allItems.find(item => item.type === ClientLayoutItemType.RELATION &&
|
|
134
|
+
item.mostSignificantClass === this.referenceClass);
|
|
135
|
+
if (direct === null || direct === void 0 ? void 0 : direct.name)
|
|
136
|
+
return direct.name;
|
|
140
137
|
// Strategy 2: a DROPDOWN whose commonRelation field was omitted from the layout
|
|
141
138
|
const layoutRelationNames = new Set(allItems
|
|
142
139
|
.filter(item => item.type === ClientLayoutItemType.RELATION)
|
|
143
|
-
.map(item => item.
|
|
140
|
+
.map(item => item.name));
|
|
144
141
|
for (const item of allItems) {
|
|
145
|
-
const rel = item.relation;
|
|
146
142
|
if (item.type === ClientLayoutItemType.RELATION &&
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
!layoutRelationNames.has(
|
|
150
|
-
return
|
|
143
|
+
item.editBehavior === ClientLayoutItemRelationEditBehavior.DROPDOWN &&
|
|
144
|
+
item.commonRelation &&
|
|
145
|
+
!layoutRelationNames.has(item.commonRelation)) {
|
|
146
|
+
return item.commonRelation;
|
|
151
147
|
}
|
|
152
148
|
}
|
|
153
149
|
return null;
|
|
@@ -162,25 +158,21 @@ export class MrdForm {
|
|
|
162
158
|
collectDependentDropdowns() {
|
|
163
159
|
var _a, _b;
|
|
164
160
|
return this.collectFields((_b = (_a = this.layout) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : [])
|
|
165
|
-
.filter(item =>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
((_a = item.relation) === null || _a === void 0 ? void 0 : _a.editBehavior) === ClientLayoutItemRelationEditBehavior.DROPDOWN &&
|
|
169
|
-
!!item.relation.commonRelation;
|
|
170
|
-
})
|
|
171
|
-
.map(item => item.relation);
|
|
161
|
+
.filter(item => item.type === ClientLayoutItemType.RELATION &&
|
|
162
|
+
item.editBehavior === ClientLayoutItemRelationEditBehavior.DROPDOWN &&
|
|
163
|
+
!!item.commonRelation);
|
|
172
164
|
}
|
|
173
165
|
/** Emit mrdFetchAll for every dependent DROPDOWN whose filter value is currently set. */
|
|
174
166
|
emitDependentFetchAll() {
|
|
175
|
-
for (const
|
|
176
|
-
const filterValue = this.getHref(this.formValues[
|
|
167
|
+
for (const item of this.collectDependentDropdowns()) {
|
|
168
|
+
const filterValue = this.getHref(this.formValues[item.commonRelation]);
|
|
177
169
|
if (filterValue) {
|
|
178
170
|
this.mrdFetchAll.emit({
|
|
179
|
-
name:
|
|
180
|
-
relatedClass:
|
|
181
|
-
mostSignificantClass:
|
|
182
|
-
commonRelation:
|
|
183
|
-
filter:
|
|
171
|
+
name: item.name,
|
|
172
|
+
relatedClass: item.relatedClass,
|
|
173
|
+
mostSignificantClass: item.mostSignificantClass,
|
|
174
|
+
commonRelation: item.commonRelation,
|
|
175
|
+
filter: item.commonRelation + '_href',
|
|
184
176
|
filterValue,
|
|
185
177
|
});
|
|
186
178
|
}
|
|
@@ -210,15 +202,14 @@ export class MrdForm {
|
|
|
210
202
|
return fields;
|
|
211
203
|
}
|
|
212
204
|
validate() {
|
|
213
|
-
var _a, _b
|
|
205
|
+
var _a, _b;
|
|
214
206
|
const newErrors = {};
|
|
215
207
|
const allFields = this.collectFields((_b = (_a = this.layout) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : []);
|
|
216
208
|
for (const item of allFields) {
|
|
217
|
-
|
|
218
|
-
if (!def)
|
|
209
|
+
if (!item.name)
|
|
219
210
|
continue;
|
|
220
|
-
if (
|
|
221
|
-
newErrors[
|
|
211
|
+
if (item.required && !validateRequired(this.formValues[item.name])) {
|
|
212
|
+
newErrors[item.name] = t('required', this.locale);
|
|
222
213
|
}
|
|
223
214
|
}
|
|
224
215
|
this.errors = newErrors;
|
|
@@ -266,8 +257,10 @@ export class MrdForm {
|
|
|
266
257
|
const payload = {};
|
|
267
258
|
const allFields = this.collectFields((_b = (_a = this.layout) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : []);
|
|
268
259
|
for (const item of allFields) {
|
|
269
|
-
if (item.
|
|
270
|
-
|
|
260
|
+
if (!item.name)
|
|
261
|
+
continue;
|
|
262
|
+
const name = item.name;
|
|
263
|
+
if (item.type === ClientLayoutItemType.FIELD) {
|
|
271
264
|
const value = this.formValues[name];
|
|
272
265
|
if (value instanceof File)
|
|
273
266
|
continue;
|
|
@@ -277,8 +270,7 @@ export class MrdForm {
|
|
|
277
270
|
continue;
|
|
278
271
|
payload[name] = current;
|
|
279
272
|
}
|
|
280
|
-
else if (item.type === ClientLayoutItemType.RELATION
|
|
281
|
-
const name = item.relation.name;
|
|
273
|
+
else if (item.type === ClientLayoutItemType.RELATION) {
|
|
282
274
|
const current = this.normalizeRelationValue(this.formValues[name]);
|
|
283
275
|
const initial = this.normalizeRelationValue(this.initialValues[name]);
|
|
284
276
|
if (this.deepEqual(current, initial))
|
|
@@ -290,14 +282,14 @@ export class MrdForm {
|
|
|
290
282
|
}
|
|
291
283
|
renderItems(items) {
|
|
292
284
|
return items.map(item => {
|
|
293
|
-
var _a
|
|
285
|
+
var _a;
|
|
294
286
|
if (item.type === ClientLayoutItemType.SECTION) {
|
|
295
287
|
return (h("fieldset", { class: "mrd-form__section" }, item.label && h("legend", { class: "mrd-form__section-legend" }, item.label), h("div", { class: "mrd-form__section-body" }, item.items && this.renderItems(item.items))));
|
|
296
288
|
}
|
|
297
289
|
if (item.type === ClientLayoutItemType.GROUP) {
|
|
298
290
|
return (h("div", { class: "mrd-form__group" }, item.label && h("div", { class: "mrd-form__group-label" }, item.label), h("div", { class: "mrd-form__group-body" }, item.items && this.renderItems(item.items))));
|
|
299
291
|
}
|
|
300
|
-
const fieldName = (
|
|
292
|
+
const fieldName = (_a = item.name) !== null && _a !== void 0 ? _a : '';
|
|
301
293
|
const fieldValue = this.formValues[fieldName];
|
|
302
294
|
return (h("div", { class: "mrd-form__field" }, h("mrd-field", { item: item, locale: this.locale, value: fieldValue, onMrdChange: this.handleFieldChange, onMrdBlur: this.handleFieldChange, onMrdSearch: this.handleSearch, onMrdFetchAll: this.handleFetchAll, onMrdUpload: this.handleUpload }), this.errors[fieldName] && (h("span", { class: "mrd-form__field-error" }, this.errors[fieldName]))));
|
|
303
295
|
});
|