@mmlogic/components 0.5.14 → 0.5.16
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/{cell-renderer-mjS630f1.js → cell-renderer-CLVKTVVQ.js} +105 -1
- package/dist/cjs/{client-layout-CqVuJumR.js → client-layout-Eg2VwW-7.js} +2 -0
- package/dist/cjs/index.cjs.js +2 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mosterdcomponents.cjs.js +1 -1
- package/dist/cjs/{mrd-boolean-field_25.cjs.entry.js → mrd-boolean-field_28.cjs.entry.js} +1168 -314
- package/dist/cjs/mrd-merge-view.cjs.entry.js +4 -4
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/fields/mrd-textarea-field/mrd-textarea-field.js +47 -2
- package/dist/collection/components/form/mrd-field/mrd-field.css +69 -0
- package/dist/collection/components/form/mrd-field/mrd-field.js +95 -25
- package/dist/collection/components/form/mrd-form/mrd-form.css +29 -0
- package/dist/collection/components/form/mrd-form/mrd-form.js +44 -8
- package/dist/collection/components/layout/mrd-layout-section/field-value.js +19 -2
- package/dist/collection/components/layout/mrd-layout-section/layout-helpers.js +10 -0
- package/dist/collection/components/layout/mrd-layout-section/mrd-layout-section.css +4 -3
- package/dist/collection/components/layout/mrd-layout-section/mrd-layout-section.js +169 -18
- package/dist/collection/components/memo/mrd-memo-container/mrd-memo-container.css +204 -0
- package/dist/collection/components/memo/mrd-memo-container/mrd-memo-container.js +769 -0
- package/dist/collection/components/memo/mrd-memo-list/mrd-memo-list.css +164 -0
- package/dist/collection/components/memo/mrd-memo-list/mrd-memo-list.js +559 -0
- package/dist/collection/components/memo/mrd-memo-view/mrd-memo-view.css +108 -0
- package/dist/collection/components/memo/mrd-memo-view/mrd-memo-view.js +204 -0
- package/dist/collection/components/merge/mrd-merge-view/mrd-merge-view.js +2 -2
- package/dist/collection/components/table/mrd-table/mrd-table.js +9 -6
- package/dist/collection/dev/app.js +30 -15
- package/dist/collection/dev/example-data.js +15 -1
- package/dist/collection/types/client-layout.js +1 -0
- package/dist/collection/utils/i18n.js +104 -0
- package/dist/collection/utils/query-params.js +9 -0
- package/dist/components/client-layout.js +1 -1
- package/dist/components/i18n.js +1 -1
- package/dist/components/index.js +1 -1
- 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-memo-container.d.ts +11 -0
- package/dist/components/mrd-memo-container.js +1 -0
- package/dist/components/mrd-memo-container2.js +1 -0
- package/dist/components/mrd-memo-list.d.ts +11 -0
- package/dist/components/mrd-memo-list.js +1 -0
- package/dist/components/mrd-memo-list2.js +1 -0
- package/dist/components/mrd-memo-view.d.ts +11 -0
- package/dist/components/mrd-memo-view.js +1 -0
- package/dist/components/mrd-memo-view2.js +1 -0
- package/dist/components/mrd-merge-view.js +1 -1
- package/dist/components/mrd-table2.js +1 -1
- package/dist/components/mrd-textarea-field2.js +1 -1
- package/dist/components/query-params.js +1 -1
- package/dist/components/table-query.js +1 -0
- package/dist/esm/{cell-renderer-BDY8UXkH.js → cell-renderer-4NKEzZWw.js} +105 -1
- package/dist/esm/{client-layout-Bc42CfJB.js → client-layout-BJkVeSq6.js} +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mosterdcomponents.js +1 -1
- package/dist/esm/{mrd-boolean-field_25.entry.js → mrd-boolean-field_28.entry.js} +1166 -315
- package/dist/esm/mrd-merge-view.entry.js +4 -4
- package/dist/mosterdcomponents/{cell-renderer-B8u5BCK-.js.map → cell-renderer-CMUxFREW.js.map} +1 -1
- package/dist/mosterdcomponents/client-layout-BJkVeSq6.js.map +1 -0
- package/dist/mosterdcomponents/{field-helpers-CNQcI3Hf.js.map → field-helpers-BWAp5fD8.js.map} +1 -1
- package/dist/mosterdcomponents/{file-upload-common-C9wp47CB.js.map → file-upload-common-DDWuC9-3.js.map} +1 -1
- package/dist/mosterdcomponents/i18n-OzbszktW.js.map +1 -0
- package/dist/mosterdcomponents/index-CkcFwdPc.js.map +1 -0
- package/dist/mosterdcomponents/index.esm.js +1 -1
- package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
- package/dist/mosterdcomponents/p-8a7fa81d.entry.js +3 -0
- package/dist/mosterdcomponents/{p-Bc42CfJB.js → p-BJkVeSq6.js} +1 -1
- package/dist/mosterdcomponents/p-BMx6VAJ6.js +1 -0
- package/dist/mosterdcomponents/{p-e8b0880f.entry.js → p-e68dfbb0.entry.js} +1 -1
- package/dist/mosterdcomponents/query-params-3TXd5CUO.js.map +1 -0
- package/dist/mosterdcomponents/table-query-DJq1uKqJ.js.map +1 -0
- package/dist/mosterdcomponents/{validation-CjjTt66G.js.map → validation-B_0Lx9DE.js.map} +1 -1
- package/dist/types/components/fields/mrd-textarea-field/mrd-textarea-field.d.ts +10 -0
- package/dist/types/components/form/mrd-field/mrd-field.d.ts +16 -0
- package/dist/types/components/form/mrd-form/mrd-form.d.ts +6 -0
- package/dist/types/components/layout/mrd-layout-section/field-value.d.ts +4 -0
- package/dist/types/components/layout/mrd-layout-section/layout-helpers.d.ts +3 -0
- package/dist/types/components/layout/mrd-layout-section/mrd-layout-section.d.ts +25 -1
- package/dist/types/components/memo/mrd-memo-container/mrd-memo-container.d.ts +173 -0
- package/dist/types/components/memo/mrd-memo-list/mrd-memo-list.d.ts +91 -0
- package/dist/types/components/memo/mrd-memo-view/mrd-memo-view.d.ts +33 -0
- package/dist/types/components.d.ts +571 -1
- package/dist/types/types/client-layout.d.ts +1 -0
- package/dist/types/utils/query-params.d.ts +16 -0
- package/package.json +1 -1
- package/dist/mosterdcomponents/client-layout-Bc42CfJB.js.map +0 -1
- package/dist/mosterdcomponents/i18n-ydNM87-Q.js.map +0 -1
- package/dist/mosterdcomponents/index-DhffneUF.js.map +0 -1
- package/dist/mosterdcomponents/p-Dkm4WxMy.js +0 -1
- package/dist/mosterdcomponents/p-c834951a.entry.js +0 -3
- package/dist/mosterdcomponents/query-params-BZbQoeYF.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-DVbdkYO3.js');
|
|
4
|
-
var clientLayout = require('./client-layout-
|
|
5
|
-
var cellRenderer = require('./cell-renderer-
|
|
4
|
+
var clientLayout = require('./client-layout-Eg2VwW-7.js');
|
|
5
|
+
var cellRenderer = require('./cell-renderer-CLVKTVVQ.js');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Whether a layout item can appear in the merge diff at all. m-n relations
|
|
@@ -257,14 +257,14 @@ const MrdMergeView = class {
|
|
|
257
257
|
var _a, _b;
|
|
258
258
|
let stepContent;
|
|
259
259
|
if (this.step === 'search') {
|
|
260
|
-
stepContent = (index.h(MergeSearchStep, { key: '
|
|
260
|
+
stepContent = (index.h(MergeSearchStep, { key: '88ddac4f8f60a736bc6bc898b553e24771023b82', locale: this.locale, searchQuery: this.searchQuery, searchResults: this.searchResults, isLoading: this.isLoading, onSearchInput: this.handleSearchInput, onSelect: this.handleSelect }));
|
|
261
261
|
}
|
|
262
262
|
else {
|
|
263
263
|
const diff = diffFields(this.fields, this.currentRecord, this.candidate);
|
|
264
264
|
const bLabel = candidateLabel(this.candidate);
|
|
265
265
|
stepContent = this.step === 'compare' ? (index.h(MergeCompareStep, { locale: this.locale, currentLabel: this.currentLabel, candidateLabel: bLabel, conflicts: diff.conflicts, autoFilled: diff.autoFilled, recordA: this.currentRecord, recordB: (_a = this.candidate) !== null && _a !== void 0 ? _a : {}, resolutions: this.resolutions, openHistoryKey: this.openHistoryKey, onResolve: this.handleResolve, onToggleHistory: this.handleToggleHistory, onChangeCandidate: this.handleChangeCandidate, onContinue: this.handleContinue })) : (index.h(MergeConfirmStep, { locale: this.locale, candidateLabel: bLabel, conflicts: diff.conflicts, autoFilled: diff.autoFilled, resolutions: this.resolutions, recordB: (_b = this.candidate) !== null && _b !== void 0 ? _b : {}, openHistoryKey: this.openHistoryKey, onToggleHistory: this.handleToggleHistory, onBack: this.handleBack, onConfirm: this.handleConfirm }));
|
|
266
266
|
}
|
|
267
|
-
return (index.h(index.Host, { key: '
|
|
267
|
+
return (index.h(index.Host, { key: '3606faba4c86ae1d981b7c40e4f1cb9cde19cf50' }, index.h("div", { key: '9605009fec0a7c79a5cd32141d930ea04e5efaad', class: "mrd-merge-view" }, stepContent)));
|
|
268
268
|
}
|
|
269
269
|
get el() { return index.getElement(this); }
|
|
270
270
|
};
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"components/form/mrd-form/mrd-form.js",
|
|
25
25
|
"components/invoice/mrd-invoice-view/mrd-invoice-view.js",
|
|
26
26
|
"components/layout/mrd-layout-section/mrd-layout-section.js",
|
|
27
|
+
"components/memo/mrd-memo-container/mrd-memo-container.js",
|
|
28
|
+
"components/memo/mrd-memo-list/mrd-memo-list.js",
|
|
29
|
+
"components/memo/mrd-memo-view/mrd-memo-view.js",
|
|
27
30
|
"components/merge/mrd-merge-view/mrd-merge-view.js",
|
|
28
31
|
"components/table/mrd-table/mrd-table.js"
|
|
29
32
|
],
|
|
@@ -10,12 +10,29 @@ export class MrdTextareaField {
|
|
|
10
10
|
this.required = false;
|
|
11
11
|
this.disabled = false;
|
|
12
12
|
this.locale = navigator.language;
|
|
13
|
+
/** Focus the editor as soon as it's ready — opt-in, since auto-focusing every
|
|
14
|
+
* textarea field on mount would be wrong for a regular multi-field form. */
|
|
15
|
+
this.autofocus = false;
|
|
13
16
|
this.error = '';
|
|
14
17
|
this.editorReady = false;
|
|
15
18
|
}
|
|
16
19
|
componentDidLoad() {
|
|
17
20
|
this.initQuill();
|
|
18
21
|
}
|
|
22
|
+
/** The host may reuse the same element for a different record (e.g. mrd-memo-
|
|
23
|
+
* container's quick-create/edit dialog editing a second memo without the
|
|
24
|
+
* dialog itself remounting) — Quill only reads `value` once at construction,
|
|
25
|
+
* so re-apply it here when it changes to something the editor doesn't already
|
|
26
|
+
* hold. Guarded against our own emitted mrdChange feeding back in as a no-op. */
|
|
27
|
+
valueChanged(newValue) {
|
|
28
|
+
if (!this.editorReady || !this.quill)
|
|
29
|
+
return;
|
|
30
|
+
if (newValue === this.getSanitizedHtml())
|
|
31
|
+
return;
|
|
32
|
+
this.quill.setText('');
|
|
33
|
+
if (newValue)
|
|
34
|
+
this.quill.clipboard.dangerouslyPasteHTML(newValue);
|
|
35
|
+
}
|
|
19
36
|
async initQuill() {
|
|
20
37
|
try {
|
|
21
38
|
// Dynamically import Quill
|
|
@@ -37,6 +54,7 @@ export class MrdTextareaField {
|
|
|
37
54
|
],
|
|
38
55
|
},
|
|
39
56
|
});
|
|
57
|
+
this.quill = quill;
|
|
40
58
|
if (this.value) {
|
|
41
59
|
quill.clipboard.dangerouslyPasteHTML(this.value);
|
|
42
60
|
}
|
|
@@ -51,8 +69,9 @@ export class MrdTextareaField {
|
|
|
51
69
|
this.mrdBlur.emit({ name: this.name, value: html });
|
|
52
70
|
}
|
|
53
71
|
});
|
|
54
|
-
void quill; // hold reference if needed later
|
|
55
72
|
this.editorReady = true;
|
|
73
|
+
if (this.autofocus)
|
|
74
|
+
quill.focus();
|
|
56
75
|
}
|
|
57
76
|
catch (err) {
|
|
58
77
|
console.error('Failed to load Quill editor:', err);
|
|
@@ -64,7 +83,7 @@ export class MrdTextareaField {
|
|
|
64
83
|
return DOMPurify.sanitize(html);
|
|
65
84
|
}
|
|
66
85
|
render() {
|
|
67
|
-
return (h(Host, { key: '
|
|
86
|
+
return (h(Host, { key: '5dad54667601fce064107311e741e4e0dad94298' }, h("div", { key: 'bd7bd538155ec3172fa8cc1cf4cf66ad23d07a3b', class: "mrd-textarea-field" }, h(FieldLabel, { key: 'a3fe2c714340bbdcd3521e9782f87f3773c65e62', base: "mrd-textarea-field", label: this.label, required: this.required }), h("div", { key: 'a7a628f94bc628fd358c7fc876ee1bdd2c7ef520', class: controlClass('mrd-textarea-field', !!this.error, 'container') }, h("div", { key: '30ecd27d9e928094178f8f011524ff5633cb875e', class: "mrd-textarea-field__editor" })), h(FieldError, { key: '589d5cbf28c3ae1bdbe5f663aaf6cae840bdcffe', base: "mrd-textarea-field", error: this.error }))));
|
|
68
87
|
}
|
|
69
88
|
static get is() { return "mrd-textarea-field"; }
|
|
70
89
|
static get encapsulation() { return "scoped"; }
|
|
@@ -219,6 +238,26 @@ export class MrdTextareaField {
|
|
|
219
238
|
"reflect": false,
|
|
220
239
|
"attribute": "locale",
|
|
221
240
|
"defaultValue": "navigator.language"
|
|
241
|
+
},
|
|
242
|
+
"autofocus": {
|
|
243
|
+
"type": "boolean",
|
|
244
|
+
"mutable": false,
|
|
245
|
+
"complexType": {
|
|
246
|
+
"original": "boolean",
|
|
247
|
+
"resolved": "boolean",
|
|
248
|
+
"references": {}
|
|
249
|
+
},
|
|
250
|
+
"required": false,
|
|
251
|
+
"optional": false,
|
|
252
|
+
"docs": {
|
|
253
|
+
"tags": [],
|
|
254
|
+
"text": "Focus the editor as soon as it's ready \u2014 opt-in, since auto-focusing every\ntextarea field on mount would be wrong for a regular multi-field form."
|
|
255
|
+
},
|
|
256
|
+
"getter": false,
|
|
257
|
+
"setter": false,
|
|
258
|
+
"reflect": false,
|
|
259
|
+
"attribute": "autofocus",
|
|
260
|
+
"defaultValue": "false"
|
|
222
261
|
}
|
|
223
262
|
};
|
|
224
263
|
}
|
|
@@ -262,4 +301,10 @@ export class MrdTextareaField {
|
|
|
262
301
|
}];
|
|
263
302
|
}
|
|
264
303
|
static get elementRef() { return "el"; }
|
|
304
|
+
static get watchers() {
|
|
305
|
+
return [{
|
|
306
|
+
"propName": "value",
|
|
307
|
+
"methodName": "valueChanged"
|
|
308
|
+
}];
|
|
309
|
+
}
|
|
265
310
|
}
|
|
@@ -102,4 +102,73 @@
|
|
|
102
102
|
}
|
|
103
103
|
.mrd-field__history-editor-add:hover {
|
|
104
104
|
background-color: var(--mrd-color-primary-light);
|
|
105
|
+
}
|
|
106
|
+
.mrd-field__multi {
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-direction: column;
|
|
109
|
+
gap: var(--mrd-space-1);
|
|
110
|
+
}
|
|
111
|
+
.mrd-field__multi__label {
|
|
112
|
+
display: block;
|
|
113
|
+
font-family: var(--mrd-font-family);
|
|
114
|
+
font-size: var(--mrd-label-font-size);
|
|
115
|
+
font-weight: var(--mrd-label-font-weight);
|
|
116
|
+
color: var(--mrd-label-color);
|
|
117
|
+
}
|
|
118
|
+
.mrd-field__multi__label--required::after {
|
|
119
|
+
content: " *";
|
|
120
|
+
color: var(--mrd-color-danger);
|
|
121
|
+
}
|
|
122
|
+
.mrd-field__multi__error {
|
|
123
|
+
font-family: var(--mrd-font-family);
|
|
124
|
+
font-size: var(--mrd-error-font-size);
|
|
125
|
+
color: var(--mrd-error-color);
|
|
126
|
+
}
|
|
127
|
+
.mrd-field__multi-row {
|
|
128
|
+
display: flex;
|
|
129
|
+
align-items: flex-start;
|
|
130
|
+
gap: var(--mrd-space-2);
|
|
131
|
+
}
|
|
132
|
+
.mrd-field__multi-row-input {
|
|
133
|
+
flex: 1 1 0;
|
|
134
|
+
min-width: 0;
|
|
135
|
+
}
|
|
136
|
+
.mrd-field__multi-remove {
|
|
137
|
+
display: inline-flex;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
flex-shrink: 0;
|
|
141
|
+
width: 2rem;
|
|
142
|
+
height: var(--mrd-input-height);
|
|
143
|
+
padding: 0;
|
|
144
|
+
background: transparent;
|
|
145
|
+
border: none;
|
|
146
|
+
border-radius: var(--mrd-border-radius-sm);
|
|
147
|
+
color: var(--mrd-color-neutral-400);
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
transition: color var(--mrd-transition-fast), background-color var(--mrd-transition-fast);
|
|
150
|
+
}
|
|
151
|
+
.mrd-field__multi-remove:hover {
|
|
152
|
+
color: var(--mrd-color-danger);
|
|
153
|
+
background-color: var(--mrd-color-danger-light);
|
|
154
|
+
}
|
|
155
|
+
.mrd-field__multi-remove svg {
|
|
156
|
+
width: 1rem;
|
|
157
|
+
height: 1rem;
|
|
158
|
+
}
|
|
159
|
+
.mrd-field__multi-add {
|
|
160
|
+
align-self: flex-start;
|
|
161
|
+
padding: var(--mrd-space-1) var(--mrd-space-3);
|
|
162
|
+
font-family: var(--mrd-font-family);
|
|
163
|
+
font-size: var(--mrd-font-size-xs);
|
|
164
|
+
font-weight: var(--mrd-font-weight-medium);
|
|
165
|
+
color: var(--mrd-color-primary);
|
|
166
|
+
background: transparent;
|
|
167
|
+
border: var(--mrd-border-width) solid var(--mrd-color-primary);
|
|
168
|
+
border-radius: var(--mrd-border-radius-md);
|
|
169
|
+
cursor: pointer;
|
|
170
|
+
transition: background-color var(--mrd-transition-fast), color var(--mrd-transition-fast);
|
|
171
|
+
}
|
|
172
|
+
.mrd-field__multi-add:hover {
|
|
173
|
+
background-color: var(--mrd-color-primary-light);
|
|
105
174
|
}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
import { ClientLayoutItemType, ClientLayoutItemFieldDataType, ClientLayoutItemRelationDisplayType, } from "../../../types";
|
|
3
3
|
import { t } from "../../../utils/i18n";
|
|
4
|
+
import { FieldLabel, FieldError, requiredError } from "../../fields/field-helpers";
|
|
4
5
|
export class MrdField {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.locale = navigator.language;
|
|
7
8
|
this.historyEntries = [];
|
|
8
9
|
this.currentValue = undefined;
|
|
10
|
+
this.multiValues = [];
|
|
11
|
+
this.multiError = '';
|
|
12
|
+
this.handleMultiRowBlur = () => {
|
|
13
|
+
var _a;
|
|
14
|
+
this.multiError = requiredError(this.multiValues, (_a = this.item.required) !== null && _a !== void 0 ? _a : false, this.locale);
|
|
15
|
+
this.mrdBlur.emit({ name: this.item.name, value: this.multiValues });
|
|
16
|
+
};
|
|
9
17
|
this.handleChange = (e) => {
|
|
10
18
|
var _a, _b, _c, _d;
|
|
11
19
|
e.stopPropagation();
|
|
@@ -50,9 +58,11 @@ export class MrdField {
|
|
|
50
58
|
}
|
|
51
59
|
componentWillLoad() {
|
|
52
60
|
this.initHistoryState();
|
|
61
|
+
this.initMultiState();
|
|
53
62
|
}
|
|
54
63
|
valueChanged() {
|
|
55
64
|
this.initHistoryState();
|
|
65
|
+
this.initMultiState();
|
|
56
66
|
}
|
|
57
67
|
initHistoryState() {
|
|
58
68
|
var _a, _b, _c, _d, _e;
|
|
@@ -63,6 +73,43 @@ export class MrdField {
|
|
|
63
73
|
this.currentValue = (_e = raw === null || raw === void 0 ? void 0 : raw.current) !== null && _e !== void 0 ? _e : raw;
|
|
64
74
|
this.historyEntries = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.history) ? [...raw.history] : [];
|
|
65
75
|
}
|
|
76
|
+
/** LIST/FILE/IMAGE already own their multiple-value UI end to end; every
|
|
77
|
+
* other scalar dataType routes through the generic repeater below instead
|
|
78
|
+
* of each leaf field re-implementing add/remove itself (FINDING-0149). */
|
|
79
|
+
isMultiScalar() {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
if (((_a = this.item) === null || _a === void 0 ? void 0 : _a.type) !== ClientLayoutItemType.FIELD || !((_b = this.item) === null || _b === void 0 ? void 0 : _b.multiple))
|
|
82
|
+
return false;
|
|
83
|
+
const dt = this.item.dataType;
|
|
84
|
+
return dt !== ClientLayoutItemFieldDataType.LIST
|
|
85
|
+
&& dt !== ClientLayoutItemFieldDataType.FILE
|
|
86
|
+
&& dt !== ClientLayoutItemFieldDataType.IMAGE;
|
|
87
|
+
}
|
|
88
|
+
initMultiState() {
|
|
89
|
+
if (!this.isMultiScalar())
|
|
90
|
+
return;
|
|
91
|
+
const v = this.value;
|
|
92
|
+
this.multiValues = Array.isArray(v) ? [...v] : (v != null && v !== '' ? [v] : []);
|
|
93
|
+
}
|
|
94
|
+
emptyRowValue() {
|
|
95
|
+
var _a;
|
|
96
|
+
switch (this.item.dataType) {
|
|
97
|
+
case ClientLayoutItemFieldDataType.INTEGER:
|
|
98
|
+
case ClientLayoutItemFieldDataType.DECIMAL:
|
|
99
|
+
case ClientLayoutItemFieldDataType.PERCENTAGE:
|
|
100
|
+
return null;
|
|
101
|
+
case ClientLayoutItemFieldDataType.CURRENCY:
|
|
102
|
+
return { amount: null, currency: (_a = this.item.currencyCode) !== null && _a !== void 0 ? _a : 'EUR' };
|
|
103
|
+
case ClientLayoutItemFieldDataType.BOOLEAN:
|
|
104
|
+
return false;
|
|
105
|
+
default:
|
|
106
|
+
return '';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
emitMultiChange(values) {
|
|
110
|
+
this.multiValues = values;
|
|
111
|
+
this.mrdChange.emit({ name: this.item.name, value: values });
|
|
112
|
+
}
|
|
66
113
|
getDisplayValue() {
|
|
67
114
|
var _a, _b, _c, _d;
|
|
68
115
|
const hist = (_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.historyEnabled) !== null && _b !== void 0 ? _b : (_d = (_c = this.item) === null || _c === void 0 ? void 0 : _c.field) === null || _d === void 0 ? void 0 : _d.historyEnabled;
|
|
@@ -91,6 +138,9 @@ export class MrdField {
|
|
|
91
138
|
value: { current: this.currentValue, history: entries },
|
|
92
139
|
});
|
|
93
140
|
}
|
|
141
|
+
renderRemoveIcon() {
|
|
142
|
+
return (h("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true" }, h("path", { "fill-rule": "evenodd", d: "M8.75 1A2.75 2.75 0 006 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 10.23 1.482l.149-.022.841 10.518A2.75 2.75 0 007.596 19h4.807a2.75 2.75 0 002.742-2.53l.841-10.52.149.023a.75.75 0 00.23-1.482A41.03 41.03 0 0014 4.193V3.75A2.75 2.75 0 0011.25 1h-2.5zM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4zM8.58 7.72a.75.75 0 00-1.5.06l.3 7.5a.75.75 0 101.5-.06l-.3-7.5zm4.34.06a.75.75 0 10-1.5-.06l-.3 7.5a.75.75 0 101.5.06l.3-7.5z", "clip-rule": "evenodd" })));
|
|
143
|
+
}
|
|
94
144
|
renderHistoryEditor() {
|
|
95
145
|
var _a, _b, _c, _d;
|
|
96
146
|
const hist = (_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.historyEnabled) !== null && _b !== void 0 ? _b : (_d = (_c = this.item) === null || _c === void 0 ? void 0 : _c.field) === null || _d === void 0 ? void 0 : _d.historyEnabled;
|
|
@@ -108,62 +158,80 @@ export class MrdField {
|
|
|
108
158
|
const addEntry = () => {
|
|
109
159
|
this.emitHistoryChange([...this.historyEntries, { value: '', until: '' }]);
|
|
110
160
|
};
|
|
111
|
-
return (h("div", { class: "mrd-field__history-editor" }, this.historyEntries.length > 0 && (h("span", { class: "mrd-field__history-editor-label" }, t('history_badge_tooltip', locale))), this.historyEntries.map((entry, i) => (h("div", { key: String(i), class: "mrd-field__history-editor-row" }, h("input", { class: "mrd-field__history-editor-value", type: valueType, value: entry.value, onInput: (e) => updateEntry(i, 'value', e.target.value) }), h("span", { class: "mrd-field__history-editor-sep" }, t('history_until', locale)), h("input", { class: "mrd-field__history-editor-until", type: "date", value: entry.until, onInput: (e) => updateEntry(i, 'until', e.target.value) }), h("button", { type: "button", class: "mrd-field__history-editor-remove", onClick: () => removeEntry(i), "aria-label": t('remove', locale) },
|
|
161
|
+
return (h("div", { class: "mrd-field__history-editor" }, this.historyEntries.length > 0 && (h("span", { class: "mrd-field__history-editor-label" }, t('history_badge_tooltip', locale))), this.historyEntries.map((entry, i) => (h("div", { key: String(i), class: "mrd-field__history-editor-row" }, h("input", { class: "mrd-field__history-editor-value", type: valueType, value: entry.value, onInput: (e) => updateEntry(i, 'value', e.target.value) }), h("span", { class: "mrd-field__history-editor-sep" }, t('history_until', locale)), h("input", { class: "mrd-field__history-editor-until", type: "date", value: entry.until, onInput: (e) => updateEntry(i, 'until', e.target.value) }), h("button", { type: "button", class: "mrd-field__history-editor-remove", onClick: () => removeEntry(i), "aria-label": t('remove', locale) }, this.renderRemoveIcon())))), h("button", { type: "button", class: "mrd-field__history-editor-add", onClick: addEntry }, "+ ", t('add', locale))));
|
|
112
162
|
}
|
|
113
|
-
renderLeafField(displayValue) {
|
|
114
|
-
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;
|
|
163
|
+
renderLeafField(displayValue, onChange = this.handleChange, onBlur = this.handleBlur, overrides = {}) {
|
|
164
|
+
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;
|
|
115
165
|
const { item, locale } = this;
|
|
116
166
|
const commonProps = {
|
|
117
167
|
name: item.name,
|
|
118
|
-
label: item.label,
|
|
119
|
-
required: item.required,
|
|
120
|
-
disabled: (
|
|
168
|
+
label: (_a = overrides.label) !== null && _a !== void 0 ? _a : item.label,
|
|
169
|
+
required: (_b = overrides.required) !== null && _b !== void 0 ? _b : item.required,
|
|
170
|
+
disabled: (_c = item.disabled) !== null && _c !== void 0 ? _c : false,
|
|
121
171
|
locale,
|
|
122
|
-
onMrdChange:
|
|
123
|
-
onMrdBlur:
|
|
172
|
+
onMrdChange: onChange,
|
|
173
|
+
onMrdBlur: onBlur,
|
|
124
174
|
};
|
|
125
175
|
switch (item.dataType) {
|
|
126
176
|
case ClientLayoutItemFieldDataType.TEXT:
|
|
127
|
-
return (h("mrd-text-field", Object.assign({}, commonProps, { value: (
|
|
177
|
+
return (h("mrd-text-field", Object.assign({}, commonProps, { value: (_d = displayValue) !== null && _d !== void 0 ? _d : '', placeholder: (_e = item.placeholder) !== null && _e !== void 0 ? _e : '' })));
|
|
128
178
|
case ClientLayoutItemFieldDataType.TEXTBLOCK:
|
|
129
|
-
return (h("mrd-textarea-field", Object.assign({}, commonProps, { value: (
|
|
179
|
+
return (h("mrd-textarea-field", Object.assign({}, commonProps, { value: (_f = displayValue) !== null && _f !== void 0 ? _f : '', placeholder: (_g = item.placeholder) !== null && _g !== void 0 ? _g : '' })));
|
|
130
180
|
case ClientLayoutItemFieldDataType.INTEGER:
|
|
131
181
|
case ClientLayoutItemFieldDataType.DECIMAL:
|
|
132
182
|
case ClientLayoutItemFieldDataType.PERCENTAGE:
|
|
133
|
-
return (h("mrd-number-field", Object.assign({}, commonProps, { value: (
|
|
183
|
+
return (h("mrd-number-field", Object.assign({}, commonProps, { value: (_h = displayValue) !== null && _h !== void 0 ? _h : null, dataType: item.dataType, decimalPrecision: (_j = item.decimalPrecision) !== null && _j !== void 0 ? _j : 2, placeholder: (_k = item.placeholder) !== null && _k !== void 0 ? _k : '' })));
|
|
134
184
|
case ClientLayoutItemFieldDataType.CURRENCY:
|
|
135
185
|
return (h("mrd-currency-field", Object.assign({}, commonProps, {
|
|
136
186
|
// Input-only fallback: it preselects the layout's currencyCode in the dropdown
|
|
137
187
|
// before an amount exists. The field never emits this shape back — an empty
|
|
138
188
|
// amount emits null (FINDING-0141).
|
|
139
|
-
value: (
|
|
189
|
+
value: (_l = displayValue) !== null && _l !== void 0 ? _l : { amount: null, currency: (_m = item.currencyCode) !== null && _m !== void 0 ? _m : 'EUR' }
|
|
140
190
|
})));
|
|
141
191
|
case ClientLayoutItemFieldDataType.BOOLEAN:
|
|
142
|
-
return (h("mrd-boolean-field", Object.assign({}, commonProps, { value: (
|
|
192
|
+
return (h("mrd-boolean-field", Object.assign({}, commonProps, { value: (_o = displayValue) !== null && _o !== void 0 ? _o : false })));
|
|
143
193
|
case ClientLayoutItemFieldDataType.DATE:
|
|
144
|
-
return (h("mrd-date-field", Object.assign({}, commonProps, { value: (
|
|
194
|
+
return (h("mrd-date-field", Object.assign({}, commonProps, { value: (_p = displayValue) !== null && _p !== void 0 ? _p : '' })));
|
|
145
195
|
case ClientLayoutItemFieldDataType.DATETIME:
|
|
146
|
-
return (h("mrd-datetime-field", Object.assign({}, commonProps, { value: (
|
|
196
|
+
return (h("mrd-datetime-field", Object.assign({}, commonProps, { value: (_q = displayValue) !== null && _q !== void 0 ? _q : '' })));
|
|
147
197
|
case ClientLayoutItemFieldDataType.TIME:
|
|
148
|
-
return (h("mrd-time-field", Object.assign({}, commonProps, { value: (
|
|
198
|
+
return (h("mrd-time-field", Object.assign({}, commonProps, { value: (_r = displayValue) !== null && _r !== void 0 ? _r : '' })));
|
|
149
199
|
case ClientLayoutItemFieldDataType.EMAIL:
|
|
150
|
-
return (h("mrd-email-field", Object.assign({}, commonProps, { value: (
|
|
200
|
+
return (h("mrd-email-field", Object.assign({}, commonProps, { value: (_s = displayValue) !== null && _s !== void 0 ? _s : '', placeholder: (_t = item.placeholder) !== null && _t !== void 0 ? _t : '' })));
|
|
151
201
|
case ClientLayoutItemFieldDataType.HYPERLINK:
|
|
152
|
-
return (h("mrd-hyperlink-field", Object.assign({}, commonProps, { value: (
|
|
202
|
+
return (h("mrd-hyperlink-field", Object.assign({}, commonProps, { value: (_u = displayValue) !== null && _u !== void 0 ? _u : '', placeholder: (_v = item.placeholder) !== null && _v !== void 0 ? _v : '' })));
|
|
153
203
|
case ClientLayoutItemFieldDataType.LIST:
|
|
154
|
-
return (h("mrd-list-field", Object.assign({}, commonProps, { value: (
|
|
204
|
+
return (h("mrd-list-field", Object.assign({}, commonProps, { value: (_w = displayValue) !== null && _w !== void 0 ? _w : '', multiple: (_x = item.multiple) !== null && _x !== void 0 ? _x : false, listItems: (_y = item.listItems) !== null && _y !== void 0 ? _y : [] })));
|
|
155
205
|
case ClientLayoutItemFieldDataType.FILE:
|
|
156
|
-
return (h("mrd-file-field", Object.assign({}, commonProps, { value: displayValue, accept: (
|
|
206
|
+
return (h("mrd-file-field", Object.assign({}, commonProps, { value: displayValue, accept: (_z = item.accept) !== null && _z !== void 0 ? _z : '', maxSize: (_0 = item.maxSize) !== null && _0 !== void 0 ? _0 : 0, multiple: (_1 = item.multiple) !== null && _1 !== void 0 ? _1 : false, onMrdUpload: this.handleUpload })));
|
|
157
207
|
case ClientLayoutItemFieldDataType.IMAGE:
|
|
158
|
-
return (h("mrd-image-field", Object.assign({}, commonProps, { value: displayValue, accept: (
|
|
208
|
+
return (h("mrd-image-field", Object.assign({}, commonProps, { value: displayValue, accept: (_2 = item.accept) !== null && _2 !== void 0 ? _2 : 'image/*', maxSize: (_3 = item.maxSize) !== null && _3 !== void 0 ? _3 : 0, multiple: (_4 = item.multiple) !== null && _4 !== void 0 ? _4 : false, onMrdUpload: this.handleUpload })));
|
|
159
209
|
case ClientLayoutItemFieldDataType.LONGTEXT:
|
|
160
|
-
return (h("mrd-longtext-field", Object.assign({}, commonProps, { value: (
|
|
210
|
+
return (h("mrd-longtext-field", Object.assign({}, commonProps, { value: (_5 = displayValue) !== null && _5 !== void 0 ? _5 : '', placeholder: (_6 = item.placeholder) !== null && _6 !== void 0 ? _6 : '' })));
|
|
161
211
|
case ClientLayoutItemFieldDataType.SECRET:
|
|
162
|
-
return (h("mrd-secret-field", Object.assign({}, commonProps, { value: (
|
|
212
|
+
return (h("mrd-secret-field", Object.assign({}, commonProps, { value: (_7 = displayValue) !== null && _7 !== void 0 ? _7 : '', placeholder: (_8 = item.placeholder) !== null && _8 !== void 0 ? _8 : '' })));
|
|
163
213
|
default:
|
|
164
214
|
return null;
|
|
165
215
|
}
|
|
166
216
|
}
|
|
217
|
+
/** Repeatable-row UI for a scalar dataType with multiple: true — mirrors the
|
|
218
|
+
* add/remove pattern already established by renderHistoryEditor(), reusing
|
|
219
|
+
* the single-row renderLeafField() per entry instead of duplicating repeat
|
|
220
|
+
* UI into every leaf field component (FINDING-0149). */
|
|
221
|
+
renderMultiScalarField() {
|
|
222
|
+
var _a, _b;
|
|
223
|
+
const { item, locale } = this;
|
|
224
|
+
const updateRow = (i, val) => {
|
|
225
|
+
this.emitMultiChange(this.multiValues.map((v, idx) => (idx === i ? val : v)));
|
|
226
|
+
};
|
|
227
|
+
const removeRow = (i) => {
|
|
228
|
+
this.emitMultiChange(this.multiValues.filter((_, idx) => idx !== i));
|
|
229
|
+
};
|
|
230
|
+
const addRow = () => {
|
|
231
|
+
this.emitMultiChange([...this.multiValues, this.emptyRowValue()]);
|
|
232
|
+
};
|
|
233
|
+
return (h("div", { class: "mrd-field__multi" }, h(FieldLabel, { base: "mrd-field__multi", label: (_a = item.label) !== null && _a !== void 0 ? _a : '', required: (_b = item.required) !== null && _b !== void 0 ? _b : false }), this.multiValues.map((v, i) => (h("div", { key: String(i), class: "mrd-field__multi-row" }, h("div", { class: "mrd-field__multi-row-input" }, this.renderLeafField(v, (e) => { e.stopPropagation(); updateRow(i, e.detail.value); }, (e) => { e.stopPropagation(); this.handleMultiRowBlur(); }, { label: '', required: false })), h("button", { type: "button", class: "mrd-field__multi-remove", onClick: () => removeRow(i), "aria-label": t('remove', locale) }, this.renderRemoveIcon())))), h("button", { type: "button", class: "mrd-field__multi-add", onClick: addRow }, "+ ", t('add', locale)), h(FieldError, { base: "mrd-field__multi", error: this.multiError })));
|
|
234
|
+
}
|
|
167
235
|
render() {
|
|
168
236
|
var _a, _b, _c, _d, _e, _f;
|
|
169
237
|
const { item, locale, value } = this;
|
|
@@ -174,7 +242,7 @@ export class MrdField {
|
|
|
174
242
|
return h(Host, null);
|
|
175
243
|
}
|
|
176
244
|
const displayValue = this.getDisplayValue();
|
|
177
|
-
return (h(Host, null, h("div", { class: "mrd-field__inner" }, this.renderLeafField(displayValue), this.renderHistoryEditor())));
|
|
245
|
+
return (h(Host, null, h("div", { class: "mrd-field__inner" }, this.isMultiScalar() ? this.renderMultiScalarField() : this.renderLeafField(displayValue), this.renderHistoryEditor())));
|
|
178
246
|
}
|
|
179
247
|
static get is() { return "mrd-field"; }
|
|
180
248
|
static get encapsulation() { return "scoped"; }
|
|
@@ -256,7 +324,9 @@ export class MrdField {
|
|
|
256
324
|
static get states() {
|
|
257
325
|
return {
|
|
258
326
|
"historyEntries": {},
|
|
259
|
-
"currentValue": {}
|
|
327
|
+
"currentValue": {},
|
|
328
|
+
"multiValues": {},
|
|
329
|
+
"multiError": {}
|
|
260
330
|
};
|
|
261
331
|
}
|
|
262
332
|
static get events() {
|
|
@@ -126,4 +126,33 @@
|
|
|
126
126
|
}
|
|
127
127
|
.mrd-form__cancel:active {
|
|
128
128
|
background-color: var(--mrd-color-neutral-200);
|
|
129
|
+
}
|
|
130
|
+
.mrd-form__delete {
|
|
131
|
+
display: inline-flex;
|
|
132
|
+
align-items: center;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
height: var(--mrd-input-height);
|
|
135
|
+
padding: 0 var(--mrd-space-6);
|
|
136
|
+
margin-right: auto;
|
|
137
|
+
background-color: transparent;
|
|
138
|
+
color: var(--mrd-color-danger);
|
|
139
|
+
font-family: var(--mrd-font-family);
|
|
140
|
+
font-size: var(--mrd-font-size-base);
|
|
141
|
+
font-weight: var(--mrd-font-weight-medium);
|
|
142
|
+
border: var(--mrd-border-width) solid var(--mrd-color-danger);
|
|
143
|
+
border-radius: var(--mrd-border-radius);
|
|
144
|
+
cursor: pointer;
|
|
145
|
+
transition: background-color var(--mrd-transition), color var(--mrd-transition);
|
|
146
|
+
}
|
|
147
|
+
.mrd-form__delete:hover {
|
|
148
|
+
background-color: var(--mrd-color-danger-light);
|
|
149
|
+
color: var(--mrd-color-danger-dark);
|
|
150
|
+
}
|
|
151
|
+
.mrd-form__delete:focus {
|
|
152
|
+
outline: none;
|
|
153
|
+
box-shadow: 0 0 0 3px var(--mrd-color-danger-light);
|
|
154
|
+
}
|
|
155
|
+
.mrd-form__delete:active {
|
|
156
|
+
background-color: var(--mrd-color-danger-light);
|
|
157
|
+
border-color: var(--mrd-color-danger-dark);
|
|
129
158
|
}
|
|
@@ -27,6 +27,11 @@ export class MrdForm {
|
|
|
27
27
|
this.referenceClass = '';
|
|
28
28
|
/** When true, a cancel button is shown next to the submit button. */
|
|
29
29
|
this.showCancel = false;
|
|
30
|
+
/** When true, a delete button is shown next to the submit button (edit mode only —
|
|
31
|
+
* the host decides when a delete affordance makes sense, e.g. only for an existing
|
|
32
|
+
* record). Deletion itself (confirmation, the actual API call) is entirely the
|
|
33
|
+
* host's responsibility; mrd-form only emits the request via mrdDelete. */
|
|
34
|
+
this.showDelete = false;
|
|
30
35
|
/**
|
|
31
36
|
* The currently logged-in user, resolved by the host via /accounts/me.
|
|
32
37
|
* Used to pre-fill RELATION fields whose defaultValue is "@me".
|
|
@@ -314,15 +319,11 @@ export class MrdForm {
|
|
|
314
319
|
normalizeRelationValue(value) {
|
|
315
320
|
if (value == null || value === '')
|
|
316
321
|
return null;
|
|
317
|
-
if (typeof value === 'string')
|
|
318
|
-
return value || null;
|
|
319
322
|
if (Array.isArray(value)) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (typeof value === 'object' && 'id' in value) {
|
|
323
|
-
return value.id || null;
|
|
323
|
+
const hrefs = value.map(v => this.getHref(v)).filter(v => v !== '');
|
|
324
|
+
return hrefs.length ? hrefs : null;
|
|
324
325
|
}
|
|
325
|
-
return null;
|
|
326
|
+
return this.getHref(value) || null;
|
|
326
327
|
}
|
|
327
328
|
deepEqual(a, b) {
|
|
328
329
|
if (a === b)
|
|
@@ -395,7 +396,7 @@ export class MrdForm {
|
|
|
395
396
|
return h(Host, null);
|
|
396
397
|
}
|
|
397
398
|
const dir = this.locale.startsWith('ar') ? 'rtl' : 'ltr';
|
|
398
|
-
return (h(Host, null, h("form", { class: "mrd-form", dir: dir, onSubmit: this.handleSubmit, noValidate: true }, this.layout.title && h("h2", { class: "mrd-form__title" }, this.layout.title), h("div", { class: "mrd-form__body" }, this.renderItems(this.layout.items)), h("div", { class: "mrd-form__footer" }, h("button", { type: "submit", class: "mrd-form__submit" }, t('submit', this.locale)), this.showCancel && (h("button", { type: "button", class: "mrd-form__cancel", onClick: () => this.mrdCancel.emit() }, t('cancel', this.locale)))))));
|
|
399
|
+
return (h(Host, null, h("form", { class: "mrd-form", dir: dir, onSubmit: this.handleSubmit, noValidate: true }, this.layout.title && h("h2", { class: "mrd-form__title" }, this.layout.title), h("div", { class: "mrd-form__body" }, this.renderItems(this.layout.items)), h("div", { class: "mrd-form__footer" }, this.showDelete && (h("button", { type: "button", class: "mrd-form__delete", onClick: () => this.mrdDelete.emit() }, t('delete', this.locale))), h("button", { type: "submit", class: "mrd-form__submit" }, t('submit', this.locale)), this.showCancel && (h("button", { type: "button", class: "mrd-form__cancel", onClick: () => this.mrdCancel.emit() }, t('cancel', this.locale)))))));
|
|
399
400
|
}
|
|
400
401
|
static get is() { return "mrd-form"; }
|
|
401
402
|
static get encapsulation() { return "scoped"; }
|
|
@@ -538,6 +539,26 @@ export class MrdForm {
|
|
|
538
539
|
"attribute": "show-cancel",
|
|
539
540
|
"defaultValue": "false"
|
|
540
541
|
},
|
|
542
|
+
"showDelete": {
|
|
543
|
+
"type": "boolean",
|
|
544
|
+
"mutable": false,
|
|
545
|
+
"complexType": {
|
|
546
|
+
"original": "boolean",
|
|
547
|
+
"resolved": "boolean",
|
|
548
|
+
"references": {}
|
|
549
|
+
},
|
|
550
|
+
"required": false,
|
|
551
|
+
"optional": false,
|
|
552
|
+
"docs": {
|
|
553
|
+
"tags": [],
|
|
554
|
+
"text": "When true, a delete button is shown next to the submit button (edit mode only \u2014\nthe host decides when a delete affordance makes sense, e.g. only for an existing\nrecord). Deletion itself (confirmation, the actual API call) is entirely the\nhost's responsibility; mrd-form only emits the request via mrdDelete."
|
|
555
|
+
},
|
|
556
|
+
"getter": false,
|
|
557
|
+
"setter": false,
|
|
558
|
+
"reflect": false,
|
|
559
|
+
"attribute": "show-delete",
|
|
560
|
+
"defaultValue": "false"
|
|
561
|
+
},
|
|
541
562
|
"me": {
|
|
542
563
|
"type": "unknown",
|
|
543
564
|
"mutable": false,
|
|
@@ -608,6 +629,21 @@ export class MrdForm {
|
|
|
608
629
|
"resolved": "void",
|
|
609
630
|
"references": {}
|
|
610
631
|
}
|
|
632
|
+
}, {
|
|
633
|
+
"method": "mrdDelete",
|
|
634
|
+
"name": "mrdDelete",
|
|
635
|
+
"bubbles": true,
|
|
636
|
+
"cancelable": true,
|
|
637
|
+
"composed": true,
|
|
638
|
+
"docs": {
|
|
639
|
+
"tags": [],
|
|
640
|
+
"text": ""
|
|
641
|
+
},
|
|
642
|
+
"complexType": {
|
|
643
|
+
"original": "void",
|
|
644
|
+
"resolved": "void",
|
|
645
|
+
"references": {}
|
|
646
|
+
}
|
|
611
647
|
}, {
|
|
612
648
|
"method": "mrdSearch",
|
|
613
649
|
"name": "mrdSearch",
|
|
@@ -94,7 +94,7 @@ function renderHistoryBadge(ctx, item, raw) {
|
|
|
94
94
|
ctx.on.toggleHistory(isOpen ? null : item.name);
|
|
95
95
|
} }, h("svg", { class: "mrd-layout-section__history-icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true" }, h("path", { "fill-rule": "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zm.75-13a.75.75 0 00-1.5 0v5c0 .207.085.394.22.53l2.5 2.5a.75.75 0 101.06-1.06L10.75 9.69V5z", "clip-rule": "evenodd" }))), isOpen && (h("div", { class: "mrd-layout-section__history-popover", role: "listbox" }, sorted.map((entry, i) => (h("div", { key: String(i), class: "mrd-layout-section__history-entry" }, entry.value, " (", t('history_until', ctx.locale), " ", formatDate(entry.until, ctx.locale), ")")))))));
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
function fieldRenderState(ctx, item) {
|
|
98
98
|
var _a, _b;
|
|
99
99
|
if (!item.name)
|
|
100
100
|
return null;
|
|
@@ -104,10 +104,27 @@ export function renderField(ctx, item) {
|
|
|
104
104
|
? raw.current
|
|
105
105
|
: raw;
|
|
106
106
|
const renderedValue = renderFieldValue(ctx, item, rawValue);
|
|
107
|
+
return { raw, rawValue, renderedValue, isEmpty: renderedValue == null };
|
|
108
|
+
}
|
|
109
|
+
/** Whether a FIELD item would render anything at all (value, or a showEmpty
|
|
110
|
+
* placeholder). A `header` field always renders. Used by mrd-layout-section
|
|
111
|
+
* to decide whether a preceding HEADER item's block is entirely empty. */
|
|
112
|
+
export function isFieldVisible(ctx, item) {
|
|
113
|
+
if (item.header)
|
|
114
|
+
return true;
|
|
115
|
+
const state = fieldRenderState(ctx, item);
|
|
116
|
+
if (!state)
|
|
117
|
+
return false;
|
|
118
|
+
return !state.isEmpty || showsEmpty(item);
|
|
119
|
+
}
|
|
120
|
+
export function renderField(ctx, item) {
|
|
121
|
+
const state = fieldRenderState(ctx, item);
|
|
122
|
+
if (!state)
|
|
123
|
+
return null;
|
|
124
|
+
const { raw, rawValue, renderedValue, isEmpty } = state;
|
|
107
125
|
if (item.header) {
|
|
108
126
|
return (h("h1", { class: "mrd-layout-section__field-header", key: item.name }, typeof renderedValue === 'string' ? renderedValue : rawValue != null ? String(rawValue) : item.label));
|
|
109
127
|
}
|
|
110
|
-
const isEmpty = renderedValue == null;
|
|
111
128
|
if (isEmpty && !showsEmpty(item))
|
|
112
129
|
return null;
|
|
113
130
|
const isBlock = item.dataType === ClientLayoutItemFieldDataType.TEXTBLOCK
|
|
@@ -12,6 +12,16 @@ export function showsEmpty(item) {
|
|
|
12
12
|
var _a, _b, _c, _d, _e;
|
|
13
13
|
return (_e = (_c = (_a = item.showEmpty) !== null && _a !== void 0 ? _a : (_b = item.field) === null || _b === void 0 ? void 0 : _b.showEmpty) !== null && _c !== void 0 ? _c : (_d = item.relation) === null || _d === void 0 ? void 0 : _d.showEmpty) !== null && _e !== void 0 ? _e : false;
|
|
14
14
|
}
|
|
15
|
+
/** Whether a RELATION item has a resolvable link value (`_links[item.name]`
|
|
16
|
+
* carries either a multi-value `values[]` or a single `name`). */
|
|
17
|
+
export function hasRelationValue(item, data) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
if (!item.name)
|
|
20
|
+
return false;
|
|
21
|
+
const links = ((_a = data === null || data === void 0 ? void 0 : data._links) !== null && _a !== void 0 ? _a : {});
|
|
22
|
+
const link = links[item.name];
|
|
23
|
+
return !!(((_b = link === null || link === void 0 ? void 0 : link.values) === null || _b === void 0 ? void 0 : _b.length) || (link === null || link === void 0 ? void 0 : link.name));
|
|
24
|
+
}
|
|
15
25
|
/** Depth-first flatten of the SECTION/GROUP tree. */
|
|
16
26
|
export function flattenItems(items) {
|
|
17
27
|
const result = [];
|
|
@@ -101,10 +101,11 @@
|
|
|
101
101
|
padding: 0;
|
|
102
102
|
}
|
|
103
103
|
.mrd-layout-section__header {
|
|
104
|
-
font-size: var(--mrd-font-size-
|
|
104
|
+
font-size: var(--mrd-font-size-sm);
|
|
105
105
|
font-weight: var(--mrd-font-weight-semibold);
|
|
106
|
-
color: var(--mrd-color-neutral-
|
|
107
|
-
|
|
106
|
+
color: var(--mrd-color-neutral-500);
|
|
107
|
+
letter-spacing: 0.01em;
|
|
108
|
+
margin: var(--mrd-space-5) 0 var(--mrd-space-2) 0;
|
|
108
109
|
padding: 0;
|
|
109
110
|
}
|
|
110
111
|
.mrd-layout-section__text {
|