@mmlogic/components 0.1.7 → 0.1.9
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_16.cjs.entry.js +204 -30
- package/dist/collection/components/mrd-field/mrd-field.js +35 -16
- package/dist/collection/components/mrd-form/mrd-form.js +238 -3
- package/dist/collection/components/mrd-form/mrd-form.scss +32 -0
- package/dist/collection/components/mrd-relation-field/mrd-relation-field.js +121 -12
- package/dist/collection/dev/api.js +198 -0
- package/dist/collection/dev/app.js +521 -0
- package/dist/collection/dev/auth.js +156 -0
- package/dist/collection/dev/example-data.js +256 -0
- package/dist/components/mrd-field2.js +1 -1
- package/dist/components/mrd-form.js +1 -1
- package/dist/components/mrd-relation-field2.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mosterdcomponents.js +1 -1
- package/dist/esm/mrd-boolean-field_16.entry.js +205 -31
- package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
- package/dist/mosterdcomponents/p-2a8cb2eb.entry.js +1 -0
- package/dist/types/components/mrd-field/mrd-field.d.ts +9 -0
- package/dist/types/components/mrd-form/mrd-form.d.ts +52 -0
- package/dist/types/components/mrd-relation-field/mrd-relation-field.d.ts +14 -1
- package/dist/types/components.d.ts +50 -2
- package/dist/types/types/client-layout.d.ts +1 -0
- package/package.json +1 -1
- package/dist/mosterdcomponents/p-45c40269.entry.js +0 -1
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -6,7 +6,7 @@ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
|
|
|
6
6
|
const defineCustomElements = async (win, options) => {
|
|
7
7
|
if (typeof window === 'undefined') return undefined;
|
|
8
8
|
await appGlobals.globalScripts();
|
|
9
|
-
return index.bootstrapLazy([["mrd-table.cjs",[[2,"mrd-table",{"columns":[16],"rows":[16],"locale":[1],"totalElements":[2,"total-elements"],"pageSize":[2,"page-size"],"rowHeight":[2,"row-height"],"tableHeight":[2,"table-height"],"defaultSort":[1,"default-sort"],"loadedPages":[32],"requestedPages":[32],"renderStart":[32],"renderEnd":[32],"colWidths":[32],"sortField":[32],"sortDir":[32],"init":[64],"setPage":[64]}]]],["mrd-boolean-field_16.cjs",[[2,"mrd-form",{"layout":[16],"locale":[1],"values":[16],"formValues":[32],"errors":[32],"submitted":[32],"setFieldValue":[64]},null,{"values":[{"valuesChanged":0}]}],[2,"mrd-field",{"item":[16],"locale":[1],"value":[16]}],[2,"mrd-boolean-field",{"name":[1],"label":[1],"value":[4],"required":[4],"disabled":[4],"locale":[1],"checked":[32]}],[2,"mrd-currency-field",{"name":[1],"label":[1],"value":[16],"required":[4],"disabled":[4],"locale":[1],"amountDisplay":[32],"currency":[32],"error":[32]}],[2,"mrd-date-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-datetime-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-email-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-file-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"accept":[1],"maxSize":[2,"max-size"],"fileName":[32],"isDragging":[32],"error":[32]}],[2,"mrd-hyperlink-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-image-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"accept":[1],"maxSize":[2,"max-size"],"previewUrl":[32],"fileName":[32],"isDragging":[32],"error":[32]}],[2,"mrd-list-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"multiple":[4],"locale":[1],"listItems":[16],"error":[32],"selected":[32]}],[2,"mrd-number-field",{"name":[1],"label":[1],"value":[2],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"dataType":[1,"data-type"],"decimalPrecision":[2,"decimal-precision"],"displayValue":[32],"error":[32]}],[2,"mrd-relation-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"relatedClass":[1,"related-class"],"mostSignificantClass":[1,"most-significant-class"],"displayType":[1,"display-type"],"multiple":[4],"dropdownValues":[16],"value":[1],"searchQuery":[32],"searchResults":[32],"isLoading":[32],"selectedItems":[32],"showResults":[32],"error":[32],"highlightedIndex":[32],"setSearchResults":[64],"setLoading":[64]}],[2,"mrd-text-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-textarea-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32],"editorReady":[32]}],[2,"mrd-time-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}]]]], options);
|
|
9
|
+
return index.bootstrapLazy([["mrd-table.cjs",[[2,"mrd-table",{"columns":[16],"rows":[16],"locale":[1],"totalElements":[2,"total-elements"],"pageSize":[2,"page-size"],"rowHeight":[2,"row-height"],"tableHeight":[2,"table-height"],"defaultSort":[1,"default-sort"],"loadedPages":[32],"requestedPages":[32],"renderStart":[32],"renderEnd":[32],"colWidths":[32],"sortField":[32],"sortDir":[32],"init":[64],"setPage":[64]}]]],["mrd-boolean-field_16.cjs",[[2,"mrd-form",{"layout":[16],"locale":[1],"values":[16],"referenceHref":[1,"reference-href"],"referenceClass":[1,"reference-class"],"showCancel":[4,"show-cancel"],"formValues":[32],"errors":[32],"submitted":[32],"setFieldValue":[64]},null,{"values":[{"valuesChanged":0}]}],[2,"mrd-field",{"item":[16],"locale":[1],"value":[16]}],[2,"mrd-boolean-field",{"name":[1],"label":[1],"value":[4],"required":[4],"disabled":[4],"locale":[1],"checked":[32]}],[2,"mrd-currency-field",{"name":[1],"label":[1],"value":[16],"required":[4],"disabled":[4],"locale":[1],"amountDisplay":[32],"currency":[32],"error":[32]}],[2,"mrd-date-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-datetime-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-email-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-file-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"accept":[1],"maxSize":[2,"max-size"],"fileName":[32],"isDragging":[32],"error":[32]}],[2,"mrd-hyperlink-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-image-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"accept":[1],"maxSize":[2,"max-size"],"previewUrl":[32],"fileName":[32],"isDragging":[32],"error":[32]}],[2,"mrd-list-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"multiple":[4],"locale":[1],"listItems":[16],"error":[32],"selected":[32]}],[2,"mrd-number-field",{"name":[1],"label":[1],"value":[2],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"dataType":[1,"data-type"],"decimalPrecision":[2,"decimal-precision"],"displayValue":[32],"error":[32]}],[2,"mrd-relation-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"relatedClass":[1,"related-class"],"mostSignificantClass":[1,"most-significant-class"],"displayType":[1,"display-type"],"editBehavior":[1,"edit-behavior"],"commonRelation":[1,"common-relation"],"multiple":[4],"dropdownValues":[16],"value":[1],"searchQuery":[32],"searchResults":[32],"allRecords":[32],"isLoading":[32],"selectedItems":[32],"showResults":[32],"error":[32],"highlightedIndex":[32],"setAllRecords":[64],"setSearchResults":[64],"setLoading":[64]}],[2,"mrd-text-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-textarea-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32],"editorReady":[32]}],[2,"mrd-time-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}]]]], options);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.setNonce = index.setNonce;
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["mrd-table.cjs",[[2,"mrd-table",{"columns":[16],"rows":[16],"locale":[1],"totalElements":[2,"total-elements"],"pageSize":[2,"page-size"],"rowHeight":[2,"row-height"],"tableHeight":[2,"table-height"],"defaultSort":[1,"default-sort"],"loadedPages":[32],"requestedPages":[32],"renderStart":[32],"renderEnd":[32],"colWidths":[32],"sortField":[32],"sortDir":[32],"init":[64],"setPage":[64]}]]],["mrd-boolean-field_16.cjs",[[2,"mrd-form",{"layout":[16],"locale":[1],"values":[16],"formValues":[32],"errors":[32],"submitted":[32],"setFieldValue":[64]},null,{"values":[{"valuesChanged":0}]}],[2,"mrd-field",{"item":[16],"locale":[1],"value":[16]}],[2,"mrd-boolean-field",{"name":[1],"label":[1],"value":[4],"required":[4],"disabled":[4],"locale":[1],"checked":[32]}],[2,"mrd-currency-field",{"name":[1],"label":[1],"value":[16],"required":[4],"disabled":[4],"locale":[1],"amountDisplay":[32],"currency":[32],"error":[32]}],[2,"mrd-date-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-datetime-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-email-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-file-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"accept":[1],"maxSize":[2,"max-size"],"fileName":[32],"isDragging":[32],"error":[32]}],[2,"mrd-hyperlink-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-image-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"accept":[1],"maxSize":[2,"max-size"],"previewUrl":[32],"fileName":[32],"isDragging":[32],"error":[32]}],[2,"mrd-list-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"multiple":[4],"locale":[1],"listItems":[16],"error":[32],"selected":[32]}],[2,"mrd-number-field",{"name":[1],"label":[1],"value":[2],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"dataType":[1,"data-type"],"decimalPrecision":[2,"decimal-precision"],"displayValue":[32],"error":[32]}],[2,"mrd-relation-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"relatedClass":[1,"related-class"],"mostSignificantClass":[1,"most-significant-class"],"displayType":[1,"display-type"],"multiple":[4],"dropdownValues":[16],"value":[1],"searchQuery":[32],"searchResults":[32],"isLoading":[32],"selectedItems":[32],"showResults":[32],"error":[32],"highlightedIndex":[32],"setSearchResults":[64],"setLoading":[64]}],[2,"mrd-text-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-textarea-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32],"editorReady":[32]}],[2,"mrd-time-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}]]]], options);
|
|
22
|
+
return index.bootstrapLazy([["mrd-table.cjs",[[2,"mrd-table",{"columns":[16],"rows":[16],"locale":[1],"totalElements":[2,"total-elements"],"pageSize":[2,"page-size"],"rowHeight":[2,"row-height"],"tableHeight":[2,"table-height"],"defaultSort":[1,"default-sort"],"loadedPages":[32],"requestedPages":[32],"renderStart":[32],"renderEnd":[32],"colWidths":[32],"sortField":[32],"sortDir":[32],"init":[64],"setPage":[64]}]]],["mrd-boolean-field_16.cjs",[[2,"mrd-form",{"layout":[16],"locale":[1],"values":[16],"referenceHref":[1,"reference-href"],"referenceClass":[1,"reference-class"],"showCancel":[4,"show-cancel"],"formValues":[32],"errors":[32],"submitted":[32],"setFieldValue":[64]},null,{"values":[{"valuesChanged":0}]}],[2,"mrd-field",{"item":[16],"locale":[1],"value":[16]}],[2,"mrd-boolean-field",{"name":[1],"label":[1],"value":[4],"required":[4],"disabled":[4],"locale":[1],"checked":[32]}],[2,"mrd-currency-field",{"name":[1],"label":[1],"value":[16],"required":[4],"disabled":[4],"locale":[1],"amountDisplay":[32],"currency":[32],"error":[32]}],[2,"mrd-date-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-datetime-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-email-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-file-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"accept":[1],"maxSize":[2,"max-size"],"fileName":[32],"isDragging":[32],"error":[32]}],[2,"mrd-hyperlink-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-image-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"accept":[1],"maxSize":[2,"max-size"],"previewUrl":[32],"fileName":[32],"isDragging":[32],"error":[32]}],[2,"mrd-list-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"multiple":[4],"locale":[1],"listItems":[16],"error":[32],"selected":[32]}],[2,"mrd-number-field",{"name":[1],"label":[1],"value":[2],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"dataType":[1,"data-type"],"decimalPrecision":[2,"decimal-precision"],"displayValue":[32],"error":[32]}],[2,"mrd-relation-field",{"name":[1],"label":[1],"required":[4],"disabled":[4],"locale":[1],"relatedClass":[1,"related-class"],"mostSignificantClass":[1,"most-significant-class"],"displayType":[1,"display-type"],"editBehavior":[1,"edit-behavior"],"commonRelation":[1,"common-relation"],"multiple":[4],"dropdownValues":[16],"value":[1],"searchQuery":[32],"searchResults":[32],"allRecords":[32],"isLoading":[32],"selectedItems":[32],"showResults":[32],"error":[32],"highlightedIndex":[32],"setAllRecords":[64],"setSearchResults":[64],"setLoading":[64]}],[2,"mrd-text-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}],[2,"mrd-textarea-field",{"name":[1],"label":[1],"value":[1],"placeholder":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32],"editorReady":[32]}],[2,"mrd-time-field",{"name":[1],"label":[1],"value":[1],"required":[4],"disabled":[4],"locale":[1],"error":[32]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -336,6 +336,7 @@ const MrdField = class {
|
|
|
336
336
|
this.mrdChange = index.createEvent(this, "mrdChange");
|
|
337
337
|
this.mrdBlur = index.createEvent(this, "mrdBlur");
|
|
338
338
|
this.mrdSearch = index.createEvent(this, "mrdSearch");
|
|
339
|
+
this.mrdFetchAll = index.createEvent(this, "mrdFetchAll");
|
|
339
340
|
this.locale = navigator.language;
|
|
340
341
|
this.handleChange = (e) => {
|
|
341
342
|
e.stopPropagation();
|
|
@@ -349,13 +350,17 @@ const MrdField = class {
|
|
|
349
350
|
e.stopPropagation();
|
|
350
351
|
this.mrdSearch.emit(e.detail);
|
|
351
352
|
};
|
|
353
|
+
this.handleFetchAll = (e) => {
|
|
354
|
+
e.stopPropagation();
|
|
355
|
+
this.mrdFetchAll.emit(e.detail);
|
|
356
|
+
};
|
|
352
357
|
}
|
|
353
358
|
render() {
|
|
354
|
-
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;
|
|
359
|
+
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;
|
|
355
360
|
const { item, locale, value } = this;
|
|
356
361
|
if (item.type === index$1.ClientLayoutItemType.RELATION && item.relation) {
|
|
357
362
|
const rel = item.relation;
|
|
358
|
-
return (index.h(index.Host, null, index.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 : index$1.ClientLayoutItemRelationDisplayType.SEARCH,
|
|
363
|
+
return (index.h(index.Host, null, index.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 : index$1.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 })));
|
|
359
364
|
}
|
|
360
365
|
if (item.type !== index$1.ClientLayoutItemType.FIELD || !item.field) {
|
|
361
366
|
return index.h(index.Host, null);
|
|
@@ -365,40 +370,40 @@ const MrdField = class {
|
|
|
365
370
|
name: field.name,
|
|
366
371
|
label: field.label,
|
|
367
372
|
required: field.required,
|
|
368
|
-
disabled: (
|
|
373
|
+
disabled: (_g = field.disabled) !== null && _g !== void 0 ? _g : false,
|
|
369
374
|
locale,
|
|
370
375
|
onMrdChange: this.handleChange,
|
|
371
376
|
onMrdBlur: this.handleBlur,
|
|
372
377
|
};
|
|
373
378
|
switch (field.dataType) {
|
|
374
379
|
case index$1.ClientLayoutItemFieldDataType.TEXT:
|
|
375
|
-
return (index.h(index.Host, null, index.h("mrd-text-field", Object.assign({}, commonProps, { value: (
|
|
380
|
+
return (index.h(index.Host, null, index.h("mrd-text-field", Object.assign({}, commonProps, { value: (_h = value) !== null && _h !== void 0 ? _h : '', placeholder: (_j = field.placeholder) !== null && _j !== void 0 ? _j : '' }))));
|
|
376
381
|
case index$1.ClientLayoutItemFieldDataType.TEXTBLOCK:
|
|
377
|
-
return (index.h(index.Host, null, index.h("mrd-textarea-field", Object.assign({}, commonProps, { value: (
|
|
382
|
+
return (index.h(index.Host, null, index.h("mrd-textarea-field", Object.assign({}, commonProps, { value: (_k = value) !== null && _k !== void 0 ? _k : '', placeholder: (_l = field.placeholder) !== null && _l !== void 0 ? _l : '' }))));
|
|
378
383
|
case index$1.ClientLayoutItemFieldDataType.INTEGER:
|
|
379
384
|
case index$1.ClientLayoutItemFieldDataType.DECIMAL:
|
|
380
385
|
case index$1.ClientLayoutItemFieldDataType.PERCENTAGE:
|
|
381
|
-
return (index.h(index.Host, null, index.h("mrd-number-field", Object.assign({}, commonProps, { value: (
|
|
386
|
+
return (index.h(index.Host, null, index.h("mrd-number-field", Object.assign({}, commonProps, { value: (_m = value) !== null && _m !== void 0 ? _m : null, dataType: field.dataType, decimalPrecision: (_o = field.decimalPrecision) !== null && _o !== void 0 ? _o : 2, placeholder: (_p = field.placeholder) !== null && _p !== void 0 ? _p : '' }))));
|
|
382
387
|
case index$1.ClientLayoutItemFieldDataType.CURRENCY:
|
|
383
|
-
return (index.h(index.Host, null, index.h("mrd-currency-field", Object.assign({}, commonProps, { value: (
|
|
388
|
+
return (index.h(index.Host, null, index.h("mrd-currency-field", Object.assign({}, commonProps, { value: (_q = value) !== null && _q !== void 0 ? _q : { amount: null, currency: (_r = field.currencyCode) !== null && _r !== void 0 ? _r : 'EUR' } }))));
|
|
384
389
|
case index$1.ClientLayoutItemFieldDataType.BOOLEAN:
|
|
385
|
-
return (index.h(index.Host, null, index.h("mrd-boolean-field", Object.assign({}, commonProps, { value: (
|
|
390
|
+
return (index.h(index.Host, null, index.h("mrd-boolean-field", Object.assign({}, commonProps, { value: (_s = value) !== null && _s !== void 0 ? _s : false }))));
|
|
386
391
|
case index$1.ClientLayoutItemFieldDataType.DATE:
|
|
387
|
-
return (index.h(index.Host, null, index.h("mrd-date-field", Object.assign({}, commonProps, { value: (
|
|
392
|
+
return (index.h(index.Host, null, index.h("mrd-date-field", Object.assign({}, commonProps, { value: (_t = value) !== null && _t !== void 0 ? _t : '' }))));
|
|
388
393
|
case index$1.ClientLayoutItemFieldDataType.DATETIME:
|
|
389
|
-
return (index.h(index.Host, null, index.h("mrd-datetime-field", Object.assign({}, commonProps, { value: (
|
|
394
|
+
return (index.h(index.Host, null, index.h("mrd-datetime-field", Object.assign({}, commonProps, { value: (_u = value) !== null && _u !== void 0 ? _u : '' }))));
|
|
390
395
|
case index$1.ClientLayoutItemFieldDataType.TIME:
|
|
391
|
-
return (index.h(index.Host, null, index.h("mrd-time-field", Object.assign({}, commonProps, { value: (
|
|
396
|
+
return (index.h(index.Host, null, index.h("mrd-time-field", Object.assign({}, commonProps, { value: (_v = value) !== null && _v !== void 0 ? _v : '' }))));
|
|
392
397
|
case index$1.ClientLayoutItemFieldDataType.EMAIL:
|
|
393
|
-
return (index.h(index.Host, null, index.h("mrd-email-field", Object.assign({}, commonProps, { value: (
|
|
398
|
+
return (index.h(index.Host, null, index.h("mrd-email-field", Object.assign({}, commonProps, { value: (_w = value) !== null && _w !== void 0 ? _w : '', placeholder: (_x = field.placeholder) !== null && _x !== void 0 ? _x : '' }))));
|
|
394
399
|
case index$1.ClientLayoutItemFieldDataType.HYPERLINK:
|
|
395
|
-
return (index.h(index.Host, null, index.h("mrd-hyperlink-field", Object.assign({}, commonProps, { value: (
|
|
400
|
+
return (index.h(index.Host, null, index.h("mrd-hyperlink-field", Object.assign({}, commonProps, { value: (_y = value) !== null && _y !== void 0 ? _y : '', placeholder: (_z = field.placeholder) !== null && _z !== void 0 ? _z : '' }))));
|
|
396
401
|
case index$1.ClientLayoutItemFieldDataType.LIST:
|
|
397
|
-
return (index.h(index.Host, null, index.h("mrd-list-field", Object.assign({}, commonProps, { value: (
|
|
402
|
+
return (index.h(index.Host, null, index.h("mrd-list-field", Object.assign({}, commonProps, { value: (_0 = value) !== null && _0 !== void 0 ? _0 : '', multiple: (_1 = field.multiple) !== null && _1 !== void 0 ? _1 : false, listItems: (_2 = field.listItems) !== null && _2 !== void 0 ? _2 : [] }))));
|
|
398
403
|
case index$1.ClientLayoutItemFieldDataType.FILE:
|
|
399
|
-
return (index.h(index.Host, null, index.h("mrd-file-field", Object.assign({}, commonProps, { accept: (
|
|
404
|
+
return (index.h(index.Host, null, index.h("mrd-file-field", Object.assign({}, commonProps, { accept: (_3 = field.accept) !== null && _3 !== void 0 ? _3 : '', maxSize: (_4 = field.maxSize) !== null && _4 !== void 0 ? _4 : 0 }))));
|
|
400
405
|
case index$1.ClientLayoutItemFieldDataType.IMAGE:
|
|
401
|
-
return (index.h(index.Host, null, index.h("mrd-image-field", Object.assign({}, commonProps, { accept: (
|
|
406
|
+
return (index.h(index.Host, null, index.h("mrd-image-field", Object.assign({}, commonProps, { accept: (_5 = field.accept) !== null && _5 !== void 0 ? _5 : 'image/*', maxSize: (_6 = field.maxSize) !== null && _6 !== void 0 ? _6 : 0 }))));
|
|
402
407
|
default:
|
|
403
408
|
return index.h(index.Host, null);
|
|
404
409
|
}
|
|
@@ -477,29 +482,78 @@ const MrdFileField = class {
|
|
|
477
482
|
};
|
|
478
483
|
MrdFileField.style = mrdFileFieldScss();
|
|
479
484
|
|
|
480
|
-
const mrdFormScss = () => `.sc-mrd-form-h{display:block}.mrd-form.sc-mrd-form{font-family:var(--mrd-font-family);width:100%}.mrd-form__title.sc-mrd-form{font-size:var(--mrd-font-size-2xl);font-weight:var(--mrd-font-weight-bold);color:var(--mrd-color-neutral-900);margin:0 0 var(--mrd-space-6) 0}.mrd-form__body.sc-mrd-form{display:flex;flex-direction:column;gap:var(--mrd-space-5)}.mrd-form__field.sc-mrd-form{display:flex;flex-direction:column;gap:var(--mrd-space-1)}.mrd-form__field-error.sc-mrd-form{font-family:var(--mrd-font-family);font-size:var(--mrd-error-font-size);color:var(--mrd-error-color)}.mrd-form__section.sc-mrd-form{border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-md);padding:var(--mrd-space-4) var(--mrd-space-5);margin:0}.mrd-form__section-legend.sc-mrd-form{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-neutral-700);padding:0 var(--mrd-space-2)}.mrd-form__section-body.sc-mrd-form{display:flex;flex-direction:column;gap:var(--mrd-space-4);margin-top:var(--mrd-space-2)}.mrd-form__group.sc-mrd-form{display:flex;flex-direction:column;gap:var(--mrd-space-2)}.mrd-form__group-label.sc-mrd-form{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-neutral-500);text-transform:uppercase;letter-spacing:0.05em}.mrd-form__group-body.sc-mrd-form{display:flex;flex-direction:column;gap:var(--mrd-space-4);padding-left:var(--mrd-space-4);border-left:3px solid var(--mrd-color-neutral-200)}.mrd-form__footer.sc-mrd-form{margin-top:var(--mrd-space-8);padding-top:var(--mrd-space-5);border-top:var(--mrd-border-width) solid var(--mrd-border-color);display:flex;justify-content:flex-end}.mrd-form__submit.sc-mrd-form{display:inline-flex;align-items:center;justify-content:center;height:var(--mrd-input-height);padding:0 var(--mrd-space-6);background-color:var(--mrd-color-primary);color:var(--mrd-color-white);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);font-weight:var(--mrd-font-weight-medium);border:none;border-radius:var(--mrd-border-radius);cursor:pointer;transition:background-color var(--mrd-transition)}.mrd-form__submit.sc-mrd-form:hover{background-color:var(--mrd-color-primary-hover)}.mrd-form__submit.sc-mrd-form:focus{outline:none;box-shadow:var(--mrd-shadow-focus)}.mrd-form__submit.sc-mrd-form:active{background-color:var(--mrd-color-primary-dark)}`;
|
|
485
|
+
const mrdFormScss = () => `.sc-mrd-form-h{display:block}.mrd-form.sc-mrd-form{font-family:var(--mrd-font-family);width:100%}.mrd-form__title.sc-mrd-form{font-size:var(--mrd-font-size-2xl);font-weight:var(--mrd-font-weight-bold);color:var(--mrd-color-neutral-900);margin:0 0 var(--mrd-space-6) 0}.mrd-form__body.sc-mrd-form{display:flex;flex-direction:column;gap:var(--mrd-space-5)}.mrd-form__field.sc-mrd-form{display:flex;flex-direction:column;gap:var(--mrd-space-1)}.mrd-form__field-error.sc-mrd-form{font-family:var(--mrd-font-family);font-size:var(--mrd-error-font-size);color:var(--mrd-error-color)}.mrd-form__section.sc-mrd-form{border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-md);padding:var(--mrd-space-4) var(--mrd-space-5);margin:0}.mrd-form__section-legend.sc-mrd-form{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-neutral-700);padding:0 var(--mrd-space-2)}.mrd-form__section-body.sc-mrd-form{display:flex;flex-direction:column;gap:var(--mrd-space-4);margin-top:var(--mrd-space-2)}.mrd-form__group.sc-mrd-form{display:flex;flex-direction:column;gap:var(--mrd-space-2)}.mrd-form__group-label.sc-mrd-form{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-neutral-500);text-transform:uppercase;letter-spacing:0.05em}.mrd-form__group-body.sc-mrd-form{display:flex;flex-direction:column;gap:var(--mrd-space-4);padding-left:var(--mrd-space-4);border-left:3px solid var(--mrd-color-neutral-200)}.mrd-form__footer.sc-mrd-form{margin-top:var(--mrd-space-8);padding-top:var(--mrd-space-5);border-top:var(--mrd-border-width) solid var(--mrd-border-color);display:flex;justify-content:flex-end;gap:var(--mrd-space-3)}.mrd-form__submit.sc-mrd-form{display:inline-flex;align-items:center;justify-content:center;height:var(--mrd-input-height);padding:0 var(--mrd-space-6);background-color:var(--mrd-color-primary);color:var(--mrd-color-white);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);font-weight:var(--mrd-font-weight-medium);border:none;border-radius:var(--mrd-border-radius);cursor:pointer;transition:background-color var(--mrd-transition)}.mrd-form__submit.sc-mrd-form:hover{background-color:var(--mrd-color-primary-hover)}.mrd-form__submit.sc-mrd-form:focus{outline:none;box-shadow:var(--mrd-shadow-focus)}.mrd-form__submit.sc-mrd-form:active{background-color:var(--mrd-color-primary-dark)}.mrd-form__cancel.sc-mrd-form{display:inline-flex;align-items:center;justify-content:center;height:var(--mrd-input-height);padding:0 var(--mrd-space-6);background-color:transparent;color:var(--mrd-color-neutral-600);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);font-weight:var(--mrd-font-weight-medium);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);cursor:pointer;transition:background-color var(--mrd-transition), color var(--mrd-transition)}.mrd-form__cancel.sc-mrd-form:hover{background-color:var(--mrd-color-neutral-100);color:var(--mrd-color-neutral-800)}.mrd-form__cancel.sc-mrd-form:focus{outline:none;box-shadow:var(--mrd-shadow-focus)}.mrd-form__cancel.sc-mrd-form:active{background-color:var(--mrd-color-neutral-200)}`;
|
|
481
486
|
|
|
482
487
|
const MrdForm = class {
|
|
483
488
|
constructor(hostRef) {
|
|
484
489
|
index.registerInstance(this, hostRef);
|
|
485
490
|
this.mrdSubmit = index.createEvent(this, "mrdSubmit");
|
|
491
|
+
this.mrdCancel = index.createEvent(this, "mrdCancel");
|
|
486
492
|
this.mrdSearch = index.createEvent(this, "mrdSearch");
|
|
493
|
+
this.mrdFetchAll = index.createEvent(this, "mrdFetchAll");
|
|
487
494
|
this.locale = navigator.language;
|
|
488
495
|
this.values = {};
|
|
496
|
+
/**
|
|
497
|
+
* Absolute href of the parent/reference object (e.g. the clientAgreement href
|
|
498
|
+
* when creating an invoice from within a client agreement).
|
|
499
|
+
* Combined with `referenceClass`, mrd-form will automatically pre-fill the
|
|
500
|
+
* matching relation field so dependent DROPDOWN fields can be fetched on load
|
|
501
|
+
* — without the host app needing to know anything about the form layout.
|
|
502
|
+
*/
|
|
503
|
+
/**
|
|
504
|
+
* Absolute href of the parent/reference object (e.g. the clientAgreement href
|
|
505
|
+
* when creating an invoice from within a client agreement).
|
|
506
|
+
* Combined with `referenceClass`, mrd-form will automatically pre-fill the
|
|
507
|
+
* matching relation field so dependent DROPDOWN fields can be fetched on load.
|
|
508
|
+
*/
|
|
509
|
+
this.referenceHref = '';
|
|
510
|
+
/**
|
|
511
|
+
* The `mostSignificantClass` of the parent/reference object
|
|
512
|
+
* (e.g. `'clientAgreements'`). Used to locate the matching RELATION field.
|
|
513
|
+
*/
|
|
514
|
+
this.referenceClass = '';
|
|
515
|
+
/** When true, a cancel button is shown next to the submit button. */
|
|
516
|
+
this.showCancel = false;
|
|
489
517
|
this.formValues = {};
|
|
490
518
|
this.errors = {};
|
|
491
519
|
this.submitted = false;
|
|
492
520
|
this.handleFieldChange = (e) => {
|
|
493
521
|
const { name, value } = e.detail;
|
|
522
|
+
const prevHref = this.getHref(this.formValues[name]);
|
|
494
523
|
this.formValues = Object.assign(Object.assign({}, this.formValues), { [name]: value });
|
|
495
524
|
if (this.errors[name]) {
|
|
496
525
|
this.errors = Object.assign(Object.assign({}, this.errors), { [name]: '' });
|
|
497
526
|
}
|
|
527
|
+
// When a field changes, check if it is the commonRelation dependency for any
|
|
528
|
+
// DROPDOWN relation. If so, reset the dependent field and re-fetch its options.
|
|
529
|
+
// Skip when the effective href did not change (e.g. mrdBlur fires after mrdChange
|
|
530
|
+
// with the same value, which would otherwise trigger a duplicate fetch).
|
|
531
|
+
const newHref = this.getHref(value);
|
|
532
|
+
if (newHref === prevHref)
|
|
533
|
+
return;
|
|
534
|
+
for (const rel of this.collectDependentDropdowns()) {
|
|
535
|
+
if (rel.commonRelation !== name)
|
|
536
|
+
continue;
|
|
537
|
+
// Clear the dependent field's current selection (options have changed)
|
|
538
|
+
this.formValues = Object.assign(Object.assign({}, this.formValues), { [rel.name]: null });
|
|
539
|
+
this.mrdFetchAll.emit({
|
|
540
|
+
name: rel.name,
|
|
541
|
+
relatedClass: rel.relatedClass,
|
|
542
|
+
mostSignificantClass: rel.mostSignificantClass,
|
|
543
|
+
commonRelation: rel.commonRelation,
|
|
544
|
+
filter: rel.commonRelation,
|
|
545
|
+
filterValue: newHref, // empty string when dependency was cleared → host should clear the list
|
|
546
|
+
});
|
|
547
|
+
}
|
|
498
548
|
};
|
|
499
549
|
this.handleSearch = (e) => {
|
|
500
550
|
e.stopPropagation();
|
|
501
551
|
this.mrdSearch.emit(e.detail);
|
|
502
552
|
};
|
|
553
|
+
this.handleFetchAll = (e) => {
|
|
554
|
+
e.stopPropagation();
|
|
555
|
+
this.mrdFetchAll.emit(e.detail);
|
|
556
|
+
};
|
|
503
557
|
this.handleSubmit = (e) => {
|
|
504
558
|
e.preventDefault();
|
|
505
559
|
this.submitted = true;
|
|
@@ -512,12 +566,71 @@ const MrdForm = class {
|
|
|
512
566
|
var _a;
|
|
513
567
|
this.formValues = Object.assign({}, ((_a = this.values) !== null && _a !== void 0 ? _a : {}));
|
|
514
568
|
}
|
|
569
|
+
componentDidLoad() {
|
|
570
|
+
// Apply reference pre-fill and emit mrdFetchAll for dependent DROPDOWN fields.
|
|
571
|
+
// Deferred so Angular/host prop bindings are settled before we read them.
|
|
572
|
+
setTimeout(() => {
|
|
573
|
+
this.applyReferenceValue();
|
|
574
|
+
this.emitDependentFetchAll();
|
|
575
|
+
}, 0);
|
|
576
|
+
}
|
|
515
577
|
/** Sync formValues when the values prop is set from outside after mount
|
|
516
578
|
* (e.g. when pre-filling an existing record in edit mode). */
|
|
517
579
|
valuesChanged(newValues) {
|
|
518
580
|
this.formValues = Object.assign({}, (newValues !== null && newValues !== void 0 ? newValues : {}));
|
|
581
|
+
this.applyReferenceValue();
|
|
519
582
|
this.errors = {};
|
|
520
583
|
this.submitted = false;
|
|
584
|
+
// Re-check DROPDOWN dependencies now that formValues are updated
|
|
585
|
+
setTimeout(() => this.emitDependentFetchAll(), 0);
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* When referenceHref + referenceClass are set, find the matching layout field
|
|
589
|
+
* and inject its value into formValues. This allows dependent DROPDOWN fields
|
|
590
|
+
* (those with commonRelation pointing to that field) to be fetched on load
|
|
591
|
+
* without the host app doing any form-domain logic.
|
|
592
|
+
*
|
|
593
|
+
* Two lookup strategies:
|
|
594
|
+
* 1. Find a RELATION whose mostSignificantClass matches referenceClass.
|
|
595
|
+
* 2. Fallback: find a DROPDOWN whose commonRelation field is absent from the
|
|
596
|
+
* layout (API omitted it because it is implied by the reference context).
|
|
597
|
+
*/
|
|
598
|
+
applyReferenceValue() {
|
|
599
|
+
if (!this.referenceHref || !this.referenceClass)
|
|
600
|
+
return;
|
|
601
|
+
const fieldName = this.resolveReferenceFieldName();
|
|
602
|
+
if (!fieldName)
|
|
603
|
+
return;
|
|
604
|
+
// Only set when not already present (don't overwrite an explicit value)
|
|
605
|
+
if (!this.formValues[fieldName]) {
|
|
606
|
+
this.formValues = Object.assign(Object.assign({}, this.formValues), { [fieldName]: this.referenceHref });
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
resolveReferenceFieldName() {
|
|
610
|
+
var _a, _b;
|
|
611
|
+
const allItems = this.collectFields((_b = (_a = this.layout) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : []);
|
|
612
|
+
// Strategy 1: direct match on mostSignificantClass
|
|
613
|
+
const direct = allItems.find(item => {
|
|
614
|
+
var _a;
|
|
615
|
+
return item.type === index$1.ClientLayoutItemType.RELATION &&
|
|
616
|
+
((_a = item.relation) === null || _a === void 0 ? void 0 : _a.mostSignificantClass) === this.referenceClass;
|
|
617
|
+
});
|
|
618
|
+
if (direct === null || direct === void 0 ? void 0 : direct.relation)
|
|
619
|
+
return direct.relation.name;
|
|
620
|
+
// Strategy 2: a DROPDOWN whose commonRelation field was omitted from the layout
|
|
621
|
+
const layoutRelationNames = new Set(allItems
|
|
622
|
+
.filter(item => item.type === index$1.ClientLayoutItemType.RELATION)
|
|
623
|
+
.map(item => item.relation.name));
|
|
624
|
+
for (const item of allItems) {
|
|
625
|
+
const rel = item.relation;
|
|
626
|
+
if (item.type === index$1.ClientLayoutItemType.RELATION &&
|
|
627
|
+
(rel === null || rel === void 0 ? void 0 : rel.editBehavior) === index$1.ClientLayoutItemRelationEditBehavior.DROPDOWN &&
|
|
628
|
+
rel.commonRelation &&
|
|
629
|
+
!layoutRelationNames.has(rel.commonRelation)) {
|
|
630
|
+
return rel.commonRelation;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return null;
|
|
521
634
|
}
|
|
522
635
|
async setFieldValue(name, value) {
|
|
523
636
|
this.formValues = Object.assign(Object.assign({}, this.formValues), { [name]: value });
|
|
@@ -525,6 +638,45 @@ const MrdForm = class {
|
|
|
525
638
|
this.errors = Object.assign(Object.assign({}, this.errors), { [name]: '' });
|
|
526
639
|
}
|
|
527
640
|
}
|
|
641
|
+
/** Collect all RELATION items that use editBehavior=DROPDOWN with a commonRelation. */
|
|
642
|
+
collectDependentDropdowns() {
|
|
643
|
+
var _a, _b;
|
|
644
|
+
return this.collectFields((_b = (_a = this.layout) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : [])
|
|
645
|
+
.filter(item => {
|
|
646
|
+
var _a;
|
|
647
|
+
return item.type === index$1.ClientLayoutItemType.RELATION &&
|
|
648
|
+
((_a = item.relation) === null || _a === void 0 ? void 0 : _a.editBehavior) === index$1.ClientLayoutItemRelationEditBehavior.DROPDOWN &&
|
|
649
|
+
!!item.relation.commonRelation;
|
|
650
|
+
})
|
|
651
|
+
.map(item => item.relation);
|
|
652
|
+
}
|
|
653
|
+
/** Emit mrdFetchAll for every dependent DROPDOWN whose filter value is currently set. */
|
|
654
|
+
emitDependentFetchAll() {
|
|
655
|
+
for (const rel of this.collectDependentDropdowns()) {
|
|
656
|
+
const filterValue = this.getHref(this.formValues[rel.commonRelation]);
|
|
657
|
+
if (filterValue) {
|
|
658
|
+
this.mrdFetchAll.emit({
|
|
659
|
+
name: rel.name,
|
|
660
|
+
relatedClass: rel.relatedClass,
|
|
661
|
+
mostSignificantClass: rel.mostSignificantClass,
|
|
662
|
+
commonRelation: rel.commonRelation,
|
|
663
|
+
filter: rel.commonRelation,
|
|
664
|
+
filterValue,
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
/** Extract a plain href string from a form value, which can be a string or
|
|
670
|
+
* a RelationSearchResult-like object with an `id` field. */
|
|
671
|
+
getHref(value) {
|
|
672
|
+
if (!value)
|
|
673
|
+
return '';
|
|
674
|
+
if (typeof value === 'string')
|
|
675
|
+
return value;
|
|
676
|
+
if (typeof value === 'object' && 'id' in value)
|
|
677
|
+
return value.id;
|
|
678
|
+
return '';
|
|
679
|
+
}
|
|
528
680
|
collectFields(items) {
|
|
529
681
|
const fields = [];
|
|
530
682
|
for (const item of items) {
|
|
@@ -594,7 +746,7 @@ const MrdForm = class {
|
|
|
594
746
|
}
|
|
595
747
|
const fieldName = (_d = (_b = (_a = item.field) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : (_c = item.relation) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : '';
|
|
596
748
|
const fieldValue = this.formValues[fieldName];
|
|
597
|
-
return (index.h("div", { class: "mrd-form__field" }, index.h("mrd-field", { item: item, locale: this.locale, value: fieldValue, onMrdChange: this.handleFieldChange, onMrdBlur: this.handleFieldChange, onMrdSearch: this.handleSearch }), this.errors[fieldName] && (index.h("span", { class: "mrd-form__field-error" }, this.errors[fieldName]))));
|
|
749
|
+
return (index.h("div", { class: "mrd-form__field" }, index.h("mrd-field", { item: item, locale: this.locale, value: fieldValue, onMrdChange: this.handleFieldChange, onMrdBlur: this.handleFieldChange, onMrdSearch: this.handleSearch, onMrdFetchAll: this.handleFetchAll }), this.errors[fieldName] && (index.h("span", { class: "mrd-form__field-error" }, this.errors[fieldName]))));
|
|
598
750
|
});
|
|
599
751
|
}
|
|
600
752
|
render() {
|
|
@@ -602,7 +754,7 @@ const MrdForm = class {
|
|
|
602
754
|
return index.h(index.Host, null);
|
|
603
755
|
}
|
|
604
756
|
const dir = this.locale.startsWith('ar') ? 'rtl' : 'ltr';
|
|
605
|
-
return (index.h(index.Host, null, index.h("form", { class: "mrd-form", dir: dir, onSubmit: this.handleSubmit, noValidate: true }, this.layout.title && index.h("h2", { class: "mrd-form__title" }, this.layout.title), index.h("div", { class: "mrd-form__body" }, this.renderItems(this.layout.items)), index.h("div", { class: "mrd-form__footer" }, index.h("button", { type: "submit", class: "mrd-form__submit" }, t('submit', this.locale))))));
|
|
757
|
+
return (index.h(index.Host, null, index.h("form", { class: "mrd-form", dir: dir, onSubmit: this.handleSubmit, noValidate: true }, this.layout.title && index.h("h2", { class: "mrd-form__title" }, this.layout.title), index.h("div", { class: "mrd-form__body" }, this.renderItems(this.layout.items)), index.h("div", { class: "mrd-form__footer" }, index.h("button", { type: "submit", class: "mrd-form__submit" }, t('submit', this.locale)), this.showCancel && (index.h("button", { type: "button", class: "mrd-form__cancel", onClick: () => this.mrdCancel.emit() }, t('cancel', this.locale)))))));
|
|
606
758
|
}
|
|
607
759
|
static get watchers() { return {
|
|
608
760
|
"values": [{
|
|
@@ -918,6 +1070,7 @@ const MrdRelationField = class {
|
|
|
918
1070
|
this.mrdChange = index.createEvent(this, "mrdChange");
|
|
919
1071
|
this.mrdBlur = index.createEvent(this, "mrdBlur");
|
|
920
1072
|
this.mrdSearch = index.createEvent(this, "mrdSearch");
|
|
1073
|
+
this.mrdFetchAll = index.createEvent(this, "mrdFetchAll");
|
|
921
1074
|
this.name = '';
|
|
922
1075
|
this.label = '';
|
|
923
1076
|
this.required = false;
|
|
@@ -933,6 +1086,7 @@ const MrdRelationField = class {
|
|
|
933
1086
|
this.value = null;
|
|
934
1087
|
this.searchQuery = '';
|
|
935
1088
|
this.searchResults = [];
|
|
1089
|
+
this.allRecords = [];
|
|
936
1090
|
this.isLoading = false;
|
|
937
1091
|
this.selectedItems = [];
|
|
938
1092
|
this.showResults = false;
|
|
@@ -1041,6 +1195,9 @@ const MrdRelationField = class {
|
|
|
1041
1195
|
this.mrdBlur.emit({ name: this.name, value: val });
|
|
1042
1196
|
};
|
|
1043
1197
|
}
|
|
1198
|
+
async setAllRecords(records) {
|
|
1199
|
+
this.allRecords = records;
|
|
1200
|
+
}
|
|
1044
1201
|
async setSearchResults(results) {
|
|
1045
1202
|
this.searchResults = results;
|
|
1046
1203
|
this.isLoading = false;
|
|
@@ -1054,24 +1211,41 @@ const MrdRelationField = class {
|
|
|
1054
1211
|
var _a;
|
|
1055
1212
|
// Pre-fill selectedItems when value is passed as { id, label } objects
|
|
1056
1213
|
// (e.g. when editing an existing record fetched from the API).
|
|
1057
|
-
if (
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1214
|
+
if (this.value) {
|
|
1215
|
+
if (Array.isArray(this.value)) {
|
|
1216
|
+
if (this.value.length > 0 && typeof this.value[0] === 'object') {
|
|
1217
|
+
this.selectedItems = this.value;
|
|
1218
|
+
this.searchQuery = '';
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
else if (typeof this.value === 'object') {
|
|
1222
|
+
this.selectedItems = [this.value];
|
|
1223
|
+
this.searchQuery = (_a = this.value.label) !== null && _a !== void 0 ? _a : '';
|
|
1063
1224
|
}
|
|
1064
1225
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1226
|
+
}
|
|
1227
|
+
componentDidLoad() {
|
|
1228
|
+
// Only emit when there is no commonRelation dependency — the form orchestrates those.
|
|
1229
|
+
if (this.editBehavior === index$1.ClientLayoutItemRelationEditBehavior.DROPDOWN && !this.commonRelation) {
|
|
1230
|
+
// Defer to next tick so parent event listeners are registered after DOM patching
|
|
1231
|
+
setTimeout(() => {
|
|
1232
|
+
this.mrdFetchAll.emit({
|
|
1233
|
+
name: this.name,
|
|
1234
|
+
relatedClass: this.relatedClass,
|
|
1235
|
+
mostSignificantClass: this.mostSignificantClass || undefined,
|
|
1236
|
+
});
|
|
1237
|
+
}, 0);
|
|
1068
1238
|
}
|
|
1069
1239
|
}
|
|
1070
1240
|
render() {
|
|
1071
|
-
var _a, _b;
|
|
1241
|
+
var _a, _b, _c, _d;
|
|
1072
1242
|
const hasError = !!this.error;
|
|
1073
|
-
if (this.
|
|
1243
|
+
if (this.editBehavior === index$1.ClientLayoutItemRelationEditBehavior.DROPDOWN) {
|
|
1074
1244
|
const currentValue = Array.isArray(this.value) ? ((_a = this.value[0]) !== null && _a !== void 0 ? _a : '') : ((_b = this.value) !== null && _b !== void 0 ? _b : '');
|
|
1245
|
+
return (index.h(index.Host, null, index.h("div", { class: "mrd-relation-field" }, this.label && (index.h("label", { class: `mrd-relation-field__label${this.required ? ' mrd-relation-field__label--required' : ''}` }, this.label)), index.h("select", { class: `mrd-relation-field__select${hasError ? ' mrd-relation-field__select--error' : ''}`, name: this.name, required: this.required, disabled: this.disabled, onChange: this.handleDropdownChange }, index.h("option", { value: "" }, t('select_placeholder', this.locale)), this.allRecords.map(record => (index.h("option", { key: record.id, value: record.id, selected: record.id === currentValue }, record.label)))), hasError && index.h("span", { class: "mrd-relation-field__error" }, this.error))));
|
|
1246
|
+
}
|
|
1247
|
+
if (this.displayType === index$1.ClientLayoutItemRelationDisplayType.DROPDOWN) {
|
|
1248
|
+
const currentValue = Array.isArray(this.value) ? ((_c = this.value[0]) !== null && _c !== void 0 ? _c : '') : ((_d = this.value) !== null && _d !== void 0 ? _d : '');
|
|
1075
1249
|
return (index.h(index.Host, null, index.h("div", { class: "mrd-relation-field" }, this.label && (index.h("label", { class: `mrd-relation-field__label${this.required ? ' mrd-relation-field__label--required' : ''}` }, this.label)), index.h("select", { class: `mrd-relation-field__select${hasError ? ' mrd-relation-field__select--error' : ''}`, name: this.name, required: this.required, disabled: this.disabled, onChange: this.handleDropdownChange }, index.h("option", { value: "" }, t('select_placeholder', this.locale)), this.dropdownValues.map(dv => (index.h("option", { key: dv.key, value: dv.key, selected: dv.key === currentValue }, dv.label)))), hasError && index.h("span", { class: "mrd-relation-field__error" }, this.error))));
|
|
1076
1250
|
}
|
|
1077
1251
|
// SEARCH mode
|
|
@@ -15,13 +15,17 @@ export class MrdField {
|
|
|
15
15
|
e.stopPropagation();
|
|
16
16
|
this.mrdSearch.emit(e.detail);
|
|
17
17
|
};
|
|
18
|
+
this.handleFetchAll = (e) => {
|
|
19
|
+
e.stopPropagation();
|
|
20
|
+
this.mrdFetchAll.emit(e.detail);
|
|
21
|
+
};
|
|
18
22
|
}
|
|
19
23
|
render() {
|
|
20
|
-
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;
|
|
24
|
+
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;
|
|
21
25
|
const { item, locale, value } = this;
|
|
22
26
|
if (item.type === ClientLayoutItemType.RELATION && item.relation) {
|
|
23
27
|
const rel = item.relation;
|
|
24
|
-
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,
|
|
28
|
+
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 })));
|
|
25
29
|
}
|
|
26
30
|
if (item.type !== ClientLayoutItemType.FIELD || !item.field) {
|
|
27
31
|
return h(Host, null);
|
|
@@ -31,40 +35,40 @@ export class MrdField {
|
|
|
31
35
|
name: field.name,
|
|
32
36
|
label: field.label,
|
|
33
37
|
required: field.required,
|
|
34
|
-
disabled: (
|
|
38
|
+
disabled: (_g = field.disabled) !== null && _g !== void 0 ? _g : false,
|
|
35
39
|
locale,
|
|
36
40
|
onMrdChange: this.handleChange,
|
|
37
41
|
onMrdBlur: this.handleBlur,
|
|
38
42
|
};
|
|
39
43
|
switch (field.dataType) {
|
|
40
44
|
case ClientLayoutItemFieldDataType.TEXT:
|
|
41
|
-
return (h(Host, null, h("mrd-text-field", Object.assign({}, commonProps, { value: (
|
|
45
|
+
return (h(Host, null, h("mrd-text-field", Object.assign({}, commonProps, { value: (_h = value) !== null && _h !== void 0 ? _h : '', placeholder: (_j = field.placeholder) !== null && _j !== void 0 ? _j : '' }))));
|
|
42
46
|
case ClientLayoutItemFieldDataType.TEXTBLOCK:
|
|
43
|
-
return (h(Host, null, h("mrd-textarea-field", Object.assign({}, commonProps, { value: (
|
|
47
|
+
return (h(Host, null, h("mrd-textarea-field", Object.assign({}, commonProps, { value: (_k = value) !== null && _k !== void 0 ? _k : '', placeholder: (_l = field.placeholder) !== null && _l !== void 0 ? _l : '' }))));
|
|
44
48
|
case ClientLayoutItemFieldDataType.INTEGER:
|
|
45
49
|
case ClientLayoutItemFieldDataType.DECIMAL:
|
|
46
50
|
case ClientLayoutItemFieldDataType.PERCENTAGE:
|
|
47
|
-
return (h(Host, null, h("mrd-number-field", Object.assign({}, commonProps, { value: (
|
|
51
|
+
return (h(Host, null, h("mrd-number-field", Object.assign({}, commonProps, { value: (_m = value) !== null && _m !== void 0 ? _m : null, dataType: field.dataType, decimalPrecision: (_o = field.decimalPrecision) !== null && _o !== void 0 ? _o : 2, placeholder: (_p = field.placeholder) !== null && _p !== void 0 ? _p : '' }))));
|
|
48
52
|
case ClientLayoutItemFieldDataType.CURRENCY:
|
|
49
|
-
return (h(Host, null, h("mrd-currency-field", Object.assign({}, commonProps, { value: (
|
|
53
|
+
return (h(Host, null, h("mrd-currency-field", Object.assign({}, commonProps, { value: (_q = value) !== null && _q !== void 0 ? _q : { amount: null, currency: (_r = field.currencyCode) !== null && _r !== void 0 ? _r : 'EUR' } }))));
|
|
50
54
|
case ClientLayoutItemFieldDataType.BOOLEAN:
|
|
51
|
-
return (h(Host, null, h("mrd-boolean-field", Object.assign({}, commonProps, { value: (
|
|
55
|
+
return (h(Host, null, h("mrd-boolean-field", Object.assign({}, commonProps, { value: (_s = value) !== null && _s !== void 0 ? _s : false }))));
|
|
52
56
|
case ClientLayoutItemFieldDataType.DATE:
|
|
53
|
-
return (h(Host, null, h("mrd-date-field", Object.assign({}, commonProps, { value: (
|
|
57
|
+
return (h(Host, null, h("mrd-date-field", Object.assign({}, commonProps, { value: (_t = value) !== null && _t !== void 0 ? _t : '' }))));
|
|
54
58
|
case ClientLayoutItemFieldDataType.DATETIME:
|
|
55
|
-
return (h(Host, null, h("mrd-datetime-field", Object.assign({}, commonProps, { value: (
|
|
59
|
+
return (h(Host, null, h("mrd-datetime-field", Object.assign({}, commonProps, { value: (_u = value) !== null && _u !== void 0 ? _u : '' }))));
|
|
56
60
|
case ClientLayoutItemFieldDataType.TIME:
|
|
57
|
-
return (h(Host, null, h("mrd-time-field", Object.assign({}, commonProps, { value: (
|
|
61
|
+
return (h(Host, null, h("mrd-time-field", Object.assign({}, commonProps, { value: (_v = value) !== null && _v !== void 0 ? _v : '' }))));
|
|
58
62
|
case ClientLayoutItemFieldDataType.EMAIL:
|
|
59
|
-
return (h(Host, null, h("mrd-email-field", Object.assign({}, commonProps, { value: (
|
|
63
|
+
return (h(Host, null, h("mrd-email-field", Object.assign({}, commonProps, { value: (_w = value) !== null && _w !== void 0 ? _w : '', placeholder: (_x = field.placeholder) !== null && _x !== void 0 ? _x : '' }))));
|
|
60
64
|
case ClientLayoutItemFieldDataType.HYPERLINK:
|
|
61
|
-
return (h(Host, null, h("mrd-hyperlink-field", Object.assign({}, commonProps, { value: (
|
|
65
|
+
return (h(Host, null, h("mrd-hyperlink-field", Object.assign({}, commonProps, { value: (_y = value) !== null && _y !== void 0 ? _y : '', placeholder: (_z = field.placeholder) !== null && _z !== void 0 ? _z : '' }))));
|
|
62
66
|
case ClientLayoutItemFieldDataType.LIST:
|
|
63
|
-
return (h(Host, null, h("mrd-list-field", Object.assign({}, commonProps, { value: (
|
|
67
|
+
return (h(Host, null, h("mrd-list-field", Object.assign({}, commonProps, { value: (_0 = value) !== null && _0 !== void 0 ? _0 : '', multiple: (_1 = field.multiple) !== null && _1 !== void 0 ? _1 : false, listItems: (_2 = field.listItems) !== null && _2 !== void 0 ? _2 : [] }))));
|
|
64
68
|
case ClientLayoutItemFieldDataType.FILE:
|
|
65
|
-
return (h(Host, null, h("mrd-file-field", Object.assign({}, commonProps, { accept: (
|
|
69
|
+
return (h(Host, null, h("mrd-file-field", Object.assign({}, commonProps, { accept: (_3 = field.accept) !== null && _3 !== void 0 ? _3 : '', maxSize: (_4 = field.maxSize) !== null && _4 !== void 0 ? _4 : 0 }))));
|
|
66
70
|
case ClientLayoutItemFieldDataType.IMAGE:
|
|
67
|
-
return (h(Host, null, h("mrd-image-field", Object.assign({}, commonProps, { accept: (
|
|
71
|
+
return (h(Host, null, h("mrd-image-field", Object.assign({}, commonProps, { accept: (_5 = field.accept) !== null && _5 !== void 0 ? _5 : 'image/*', maxSize: (_6 = field.maxSize) !== null && _6 !== void 0 ? _6 : 0 }))));
|
|
68
72
|
default:
|
|
69
73
|
return h(Host, null);
|
|
70
74
|
}
|
|
@@ -182,6 +186,21 @@ export class MrdField {
|
|
|
182
186
|
"resolved": "{ query: string; relatedClass: string; }",
|
|
183
187
|
"references": {}
|
|
184
188
|
}
|
|
189
|
+
}, {
|
|
190
|
+
"method": "mrdFetchAll",
|
|
191
|
+
"name": "mrdFetchAll",
|
|
192
|
+
"bubbles": true,
|
|
193
|
+
"cancelable": true,
|
|
194
|
+
"composed": true,
|
|
195
|
+
"docs": {
|
|
196
|
+
"tags": [],
|
|
197
|
+
"text": ""
|
|
198
|
+
},
|
|
199
|
+
"complexType": {
|
|
200
|
+
"original": "{ name: string; relatedClass: string; mostSignificantClass?: string; commonRelation?: string; filter?: string; filterValue?: string }",
|
|
201
|
+
"resolved": "{ name: string; relatedClass: string; mostSignificantClass?: string | undefined; commonRelation?: string | undefined; filter?: string | undefined; filterValue?: string | undefined; }",
|
|
202
|
+
"references": {}
|
|
203
|
+
}
|
|
185
204
|
}];
|
|
186
205
|
}
|
|
187
206
|
}
|