@mmlogic/components 0.5.17 → 0.5.18
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_28.cjs.entry.js +98 -13
- package/dist/collection/components/layout/mrd-layout-section/mrd-layout-section.js +77 -11
- package/dist/collection/components/table/mrd-table/mrd-table.js +94 -8
- package/dist/collection/dev/api.js +3 -1
- package/dist/collection/dev/app.js +42 -3
- package/dist/components/mrd-layout-section.js +1 -1
- package/dist/components/mrd-table2.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mosterdcomponents.js +1 -1
- package/dist/esm/mrd-boolean-field_28.entry.js +98 -13
- package/dist/mosterdcomponents/cell-renderer-CMUxFREW.js.map +1 -0
- package/dist/mosterdcomponents/client-layout-BJkVeSq6.js.map +1 -0
- package/dist/mosterdcomponents/document-attachments-BufPmMRv.js.map +1 -0
- package/dist/mosterdcomponents/field-helpers-BWAp5fD8.js.map +1 -0
- package/dist/mosterdcomponents/file-upload-common-DDWuC9-3.js.map +1 -0
- package/dist/mosterdcomponents/format-gcecItcD.js.map +1 -0
- package/dist/mosterdcomponents/i18n-OzbszktW.js.map +1 -0
- package/dist/mosterdcomponents/index-1ayBojyN.js.map +1 -0
- package/dist/mosterdcomponents/index-CkcFwdPc.js.map +1 -0
- package/dist/mosterdcomponents/index.esm.js.map +1 -0
- package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
- package/dist/mosterdcomponents/mosterdcomponents.esm.js.map +1 -0
- package/dist/mosterdcomponents/p-29d6dcbc.entry.js +3 -0
- package/dist/mosterdcomponents/purify.es-_duHfPgC.js.map +1 -0
- package/dist/mosterdcomponents/query-params-3TXd5CUO.js.map +1 -0
- package/dist/mosterdcomponents/quill-C9pgw_k-.js.map +1 -0
- package/dist/mosterdcomponents/table-query-DJq1uKqJ.js.map +1 -0
- package/dist/mosterdcomponents/validation-B_0Lx9DE.js.map +1 -0
- package/dist/types/components/layout/mrd-layout-section/mrd-layout-section.d.ts +24 -2
- package/dist/types/components/table/mrd-table/mrd-table.d.ts +33 -3
- package/dist/types/components.d.ts +34 -4
- package/package.json +1 -1
- package/dist/mosterdcomponents/p-f72668e9.entry.js +0 -3
|
@@ -76,6 +76,12 @@ export class MrdTable {
|
|
|
76
76
|
* explaining why) so a viewer-role user can see at a glance that this dashboard
|
|
77
77
|
* is read-only. Sorting, filtering and export stay available — those don't mutate data. */
|
|
78
78
|
this.readOnly = false;
|
|
79
|
+
/** When false, skips the standalone mrdCheckCapabilities round trip entirely and renders
|
|
80
|
+
* the create action immediately as allowed — for a tenant that has no access control
|
|
81
|
+
* configured, the answer would always be true anyway (FINDING-0171 / TASK-0322). Ignored
|
|
82
|
+
* while `canCreate` is set explicitly (the host already controls the answer directly in
|
|
83
|
+
* that mode). Default `true` keeps today's ask-and-hide behaviour unchanged. */
|
|
84
|
+
this.accessControlEnabled = true;
|
|
79
85
|
// ── Internal state ─────────────────────────────────────────────────────────
|
|
80
86
|
/** Index into allViews[] for the currently displayed view. 0 = primary, 1+ = alternatives. */
|
|
81
87
|
this.activeViewIdx = 0;
|
|
@@ -124,6 +130,9 @@ export class MrdTable {
|
|
|
124
130
|
* hidden (TASK-0299) until the host answers mrdCheckCapabilities via setCanCreate(). Ignored
|
|
125
131
|
* when the host controls `canCreate` directly; see effectiveCanCreate(). */
|
|
126
132
|
this.selfCanCreate = false;
|
|
133
|
+
/** Self-asked companion to selfCanCreate — the concrete types setCanCreate() reported allowed,
|
|
134
|
+
* or `undefined` while unanswered / when the host's mrdCheckCapabilities answer omitted it. */
|
|
135
|
+
this.selfAllowedTypes = undefined;
|
|
127
136
|
this.handleScroll = (e) => {
|
|
128
137
|
const scroller = e.currentTarget;
|
|
129
138
|
const { renderStart, renderEnd } = computeWindow(scroller.scrollTop, this.rowHeight, this.tableHeight, this.baseTotal);
|
|
@@ -297,8 +306,9 @@ export class MrdTable {
|
|
|
297
306
|
* prop is set, since the host controls it directly in that mode). Call it any time after
|
|
298
307
|
* the event fires; a stale answer for an old binding is discarded automatically
|
|
299
308
|
* (selfCanCreate is reset to false before every new mrdCheckCapabilities emission). */
|
|
300
|
-
async setCanCreate(value) {
|
|
309
|
+
async setCanCreate(value, allowedTypes) {
|
|
301
310
|
this.selfCanCreate = value;
|
|
311
|
+
this.selfAllowedTypes = allowedTypes;
|
|
302
312
|
}
|
|
303
313
|
// ── Lifecycle ──────────────────────────────────────────────────────────────
|
|
304
314
|
disconnectedCallback() {
|
|
@@ -668,11 +678,22 @@ export class MrdTable {
|
|
|
668
678
|
var _a, _b;
|
|
669
679
|
if (this.canCreate !== undefined)
|
|
670
680
|
return;
|
|
681
|
+
if (!this.accessControlEnabled)
|
|
682
|
+
return;
|
|
671
683
|
this.selfCanCreate = false;
|
|
684
|
+
this.selfAllowedTypes = undefined;
|
|
672
685
|
const v = this.allViews[this.activeViewIdx];
|
|
673
686
|
if (!(v === null || v === void 0 ? void 0 : v.dataClass))
|
|
674
687
|
return;
|
|
675
688
|
const isRelatedView = ((_a = this.item) === null || _a === void 0 ? void 0 : _a.type) === 'RELATED_VIEW';
|
|
689
|
+
// A host binding `item` and `parentId` as separate properties (e.g. Angular) can apply
|
|
690
|
+
// them in either order — this can run while `parentId` still holds its default `''`,
|
|
691
|
+
// before the real parent record has landed. Asking here would emit refId: '' for a
|
|
692
|
+
// RELATED_VIEW, which a host's `refType && refId` check reads as "no parent" and answers
|
|
693
|
+
// via the plain, unscoped capabilities route instead of the parent-scoped one
|
|
694
|
+
// (FINDING-0175 / TASK-0316). Skip; parentIdChanged() re-asks once it lands.
|
|
695
|
+
if (isRelatedView && !this.parentId)
|
|
696
|
+
return;
|
|
676
697
|
this.mrdCheckCapabilities.emit(Object.assign(Object.assign({ type: v.dataClass }, (isRelatedView ? { refType: (_b = v.fromClass) !== null && _b !== void 0 ? _b : '', refId: this.parentId } : {})), (v.filterClass ? { filterClass: v.filterClass } : {})));
|
|
677
698
|
}
|
|
678
699
|
/** Build query params for a page request from current sort, view filters, filterClass and active column filters.
|
|
@@ -709,9 +730,33 @@ export class MrdTable {
|
|
|
709
730
|
var _a, _b, _c;
|
|
710
731
|
return ((_c = (_b = (_a = this.allViews[this.activeViewIdx]) === null || _a === void 0 ? void 0 : _a.view) === null || _b === void 0 ? void 0 : _b.values) !== null && _c !== void 0 ? _c : []);
|
|
711
732
|
}
|
|
712
|
-
/** `canCreate` when the host controls it directly
|
|
733
|
+
/** `canCreate` when the host controls it directly; else, when access control is disabled,
|
|
734
|
+
* always allowed; else the table's own self-asked answer. */
|
|
713
735
|
get effectiveCanCreate() {
|
|
714
|
-
|
|
736
|
+
if (this.canCreate !== undefined)
|
|
737
|
+
return this.canCreate;
|
|
738
|
+
if (!this.accessControlEnabled)
|
|
739
|
+
return true;
|
|
740
|
+
return this.selfCanCreate;
|
|
741
|
+
}
|
|
742
|
+
/** `allowedTypes` when the host controls it directly, else the table's own self-asked
|
|
743
|
+
* answer. `undefined` means "unknown — don't filter", not "nothing allowed". */
|
|
744
|
+
get effectiveAllowedTypes() {
|
|
745
|
+
if (this.allowedTypes !== undefined)
|
|
746
|
+
return this.allowedTypes;
|
|
747
|
+
return this.selfAllowedTypes;
|
|
748
|
+
}
|
|
749
|
+
/** `item.createTypes` intersected with effectiveAllowedTypes when that is known, so the
|
|
750
|
+
* create-type picker only offers concrete types a create POST would actually accept
|
|
751
|
+
* (FINDING-0176 / TASK-0314). Unfiltered when the answer isn't known (undefined) — an
|
|
752
|
+
* older host/API that never reports allowedTypes keeps today's unfiltered behaviour. */
|
|
753
|
+
get effectiveCreateTypes() {
|
|
754
|
+
var _a;
|
|
755
|
+
const all = (_a = this.item) === null || _a === void 0 ? void 0 : _a.createTypes;
|
|
756
|
+
const allowed = this.effectiveAllowedTypes;
|
|
757
|
+
if (!all || allowed == null)
|
|
758
|
+
return all;
|
|
759
|
+
return all.filter(ct => allowed.includes(ct.type));
|
|
715
760
|
}
|
|
716
761
|
get tableActions() {
|
|
717
762
|
var _a, _b;
|
|
@@ -1149,8 +1194,7 @@ export class MrdTable {
|
|
|
1149
1194
|
}
|
|
1150
1195
|
// ── Render: toolbar ────────────────────────────────────────────────────────
|
|
1151
1196
|
renderToolbar() {
|
|
1152
|
-
|
|
1153
|
-
return (h(Toolbar, { locale: this.locale, filterCount: this.activeFilters.size, actions: this.tableActions, views: this.allViews, activeViewIdx: this.activeViewIdx, viewPopoverOpen: this.viewPopoverOpen, createPickerOpen: this.createPickerOpen, createTypes: (_a = this.item) === null || _a === void 0 ? void 0 : _a.createTypes, readOnly: this.readOnly, searchEnabled: this.searchEnabled, searchOpen: this.searchOpen, searchQuery: this.searchQuery, cb: {
|
|
1197
|
+
return (h(Toolbar, { locale: this.locale, filterCount: this.activeFilters.size, actions: this.tableActions, views: this.allViews, activeViewIdx: this.activeViewIdx, viewPopoverOpen: this.viewPopoverOpen, createPickerOpen: this.createPickerOpen, createTypes: this.effectiveCreateTypes, readOnly: this.readOnly, searchEnabled: this.searchEnabled, searchOpen: this.searchOpen, searchQuery: this.searchQuery, cb: {
|
|
1154
1198
|
onClearAllFilters: () => this.clearAllFilters(),
|
|
1155
1199
|
onViewSwitch: idx => this.handleViewSwitch(idx),
|
|
1156
1200
|
onToggleViewPopover: e => this.toggleViewPopover(e),
|
|
@@ -1538,6 +1582,43 @@ export class MrdTable {
|
|
|
1538
1582
|
"setter": false,
|
|
1539
1583
|
"reflect": false,
|
|
1540
1584
|
"attribute": "can-create"
|
|
1585
|
+
},
|
|
1586
|
+
"allowedTypes": {
|
|
1587
|
+
"type": "unknown",
|
|
1588
|
+
"mutable": false,
|
|
1589
|
+
"complexType": {
|
|
1590
|
+
"original": "string[] | null",
|
|
1591
|
+
"resolved": "null | string[] | undefined",
|
|
1592
|
+
"references": {}
|
|
1593
|
+
},
|
|
1594
|
+
"required": false,
|
|
1595
|
+
"optional": true,
|
|
1596
|
+
"docs": {
|
|
1597
|
+
"tags": [],
|
|
1598
|
+
"text": "Concrete types (`item.createTypes[].type`) the current user may actually create, when\n`item.createTypes` offers a picker for a family type \u2014 narrows it down to only the types\na create POST would accept (FINDING-0176 / TASK-0314). Leave `undefined` for standalone\nuse \u2014 the table takes it from the second argument of setCanCreate() alongside `canCreate`.\nSet it explicitly (e.g. from mrd-layout-section, alongside `canCreate`) when the host\nalready has the answer. `undefined` (not yet answered, or an older host/API that doesn't\nreport it) means \"don't filter\" \u2014 `item.createTypes` is shown unfiltered, same as before\nthis existed."
|
|
1599
|
+
},
|
|
1600
|
+
"getter": false,
|
|
1601
|
+
"setter": false
|
|
1602
|
+
},
|
|
1603
|
+
"accessControlEnabled": {
|
|
1604
|
+
"type": "boolean",
|
|
1605
|
+
"mutable": false,
|
|
1606
|
+
"complexType": {
|
|
1607
|
+
"original": "boolean",
|
|
1608
|
+
"resolved": "boolean",
|
|
1609
|
+
"references": {}
|
|
1610
|
+
},
|
|
1611
|
+
"required": false,
|
|
1612
|
+
"optional": false,
|
|
1613
|
+
"docs": {
|
|
1614
|
+
"tags": [],
|
|
1615
|
+
"text": "When false, skips the standalone mrdCheckCapabilities round trip entirely and renders\nthe create action immediately as allowed \u2014 for a tenant that has no access control\nconfigured, the answer would always be true anyway (FINDING-0171 / TASK-0322). Ignored\nwhile `canCreate` is set explicitly (the host already controls the answer directly in\nthat mode). Default `true` keeps today's ask-and-hide behaviour unchanged."
|
|
1616
|
+
},
|
|
1617
|
+
"getter": false,
|
|
1618
|
+
"setter": false,
|
|
1619
|
+
"reflect": false,
|
|
1620
|
+
"attribute": "access-control-enabled",
|
|
1621
|
+
"defaultValue": "true"
|
|
1541
1622
|
}
|
|
1542
1623
|
};
|
|
1543
1624
|
}
|
|
@@ -1567,7 +1648,8 @@ export class MrdTable {
|
|
|
1567
1648
|
"aggregations": {},
|
|
1568
1649
|
"aggregationsTotal": {},
|
|
1569
1650
|
"minKnownTotal": {},
|
|
1570
|
-
"selfCanCreate": {}
|
|
1651
|
+
"selfCanCreate": {},
|
|
1652
|
+
"selfAllowedTypes": {}
|
|
1571
1653
|
};
|
|
1572
1654
|
}
|
|
1573
1655
|
static get events() {
|
|
@@ -1680,7 +1762,7 @@ export class MrdTable {
|
|
|
1680
1762
|
"composed": true,
|
|
1681
1763
|
"docs": {
|
|
1682
1764
|
"tags": [],
|
|
1683
|
-
"text": "Standalone use only (never fires while the `canCreate` prop is set \u2014 see there). Fired\nonce per table binding (initial load, and whenever the bound item, parent record or active\nview changes) to ask the host whether the current user may create a record here. Carries\nthe same route the table already uses for its own rows, unconstructed \u2014 VIEW:\nGET /data/{tenant}/{type}/capabilities; RELATED_VIEW: GET /data/{tenant}/{refType}/{refId}/{type}/capabilities.\n`filterClass`, when the view declares one, is the same subtype the row fetch sends as\n`?type=` \u2014 e.g. a \"contents\" RELATED_VIEW filtered to `document` asks specifically whether\na document may be created here, not any content type.\nThe add button stays hidden until the host calls setCanCreate() (FINDING-0155 / TASK-0299)."
|
|
1765
|
+
"text": "Standalone use only (never fires while the `canCreate` prop is set \u2014 see there). Fired\nonce per table binding (initial load, and whenever the bound item, parent record or active\nview changes) to ask the host whether the current user may create a record here. Carries\nthe same route the table already uses for its own rows, unconstructed \u2014 VIEW:\nGET /data/{tenant}/{type}/capabilities; RELATED_VIEW: GET /data/{tenant}/{refType}/{refId}/{type}/capabilities.\n`filterClass`, when the view declares one, is the same subtype the row fetch sends as\n`?type=` \u2014 e.g. a \"contents\" RELATED_VIEW filtered to `document` asks specifically whether\na document may be created here, not any content type.\nThe add button stays hidden until the host calls setCanCreate() (FINDING-0155 / TASK-0299).\nsetCanCreate()'s optional second argument narrows `item.createTypes`'s picker down to the\nconcrete types the answer allows, when the API's capabilities response reports them\n(FINDING-0176 / TASK-0314)."
|
|
1684
1766
|
},
|
|
1685
1767
|
"complexType": {
|
|
1686
1768
|
"original": "{ type: string; refType?: string; refId?: string; filterClass?: string }",
|
|
@@ -1774,11 +1856,15 @@ export class MrdTable {
|
|
|
1774
1856
|
},
|
|
1775
1857
|
"setCanCreate": {
|
|
1776
1858
|
"complexType": {
|
|
1777
|
-
"signature": "(value: boolean) => Promise<void>",
|
|
1859
|
+
"signature": "(value: boolean, allowedTypes?: string[]) => Promise<void>",
|
|
1778
1860
|
"parameters": [{
|
|
1779
1861
|
"name": "value",
|
|
1780
1862
|
"type": "boolean",
|
|
1781
1863
|
"docs": ""
|
|
1864
|
+
}, {
|
|
1865
|
+
"name": "allowedTypes",
|
|
1866
|
+
"type": "string[] | undefined",
|
|
1867
|
+
"docs": ""
|
|
1782
1868
|
}],
|
|
1783
1869
|
"references": {
|
|
1784
1870
|
"Promise": {
|
|
@@ -122,7 +122,9 @@ async function apiFetchCapabilities(token, baseHref, refType, refId, type, filte
|
|
|
122
122
|
const url = filterClass ? `${path}?type=${encodeURIComponent(filterClass)}` : path;
|
|
123
123
|
const { ok, status, body } = await apiRequest('GET', url, token);
|
|
124
124
|
if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
|
|
125
|
-
return body; // { mayCreate }
|
|
125
|
+
return body; // { mayCreate, allowedTypes? } — allowedTypes (TASK-0313/TASK-0314) lists the
|
|
126
|
+
// concrete types (createTypes[].type) the caller may create when `type` was a
|
|
127
|
+
// family; empty exactly when mayCreate is false.
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
async function apiSubmitForm(token, tenantCode, pluralName, values) {
|
|
@@ -17,6 +17,9 @@ let _meUser = null; // { id: href, label: name } — resolved once
|
|
|
17
17
|
let _detailReadOnly = false; // Detail View tab: readOnly toggle (TASK-0248 demo)
|
|
18
18
|
let _liveApiReadOnly = false; // Live API tab: readOnly toggle (TASK-0248 demo)
|
|
19
19
|
let _detailCanCreate = true; // Detail View tab: mock answer to mrdViewCheckCapabilities (TASK-0299 demo)
|
|
20
|
+
let _detailAllowedTypesFiltered = false; // Detail View tab: allowedTypes demo (TASK-0314)
|
|
21
|
+
let _detailAccessControlEnabled = true; // Detail View tab: accessControlEnabled toggle (TASK-0322 demo)
|
|
22
|
+
let _liveApiAccessControlEnabled = true; // Live API tab: accessControlEnabled toggle (TASK-0322 demo)
|
|
20
23
|
|
|
21
24
|
/* =====================================================================
|
|
22
25
|
UTILITIES
|
|
@@ -180,6 +183,7 @@ function showCompanyDetail(row) {
|
|
|
180
183
|
section.data = company;
|
|
181
184
|
section.locale = _locale;
|
|
182
185
|
section.readOnly = _detailReadOnly;
|
|
186
|
+
section.accessControlEnabled = _detailAccessControlEnabled;
|
|
183
187
|
|
|
184
188
|
section.addEventListener('mrdNavigate', (e) => {
|
|
185
189
|
logEvent('mrdNavigate', e.detail);
|
|
@@ -199,9 +203,14 @@ function showCompanyDetail(row) {
|
|
|
199
203
|
// call apiFetchCapabilities() instead, as the Live API tab does below.
|
|
200
204
|
// _detailCanCreate is toggleable (see onDetailViewCanCreateToggle) so both the
|
|
201
205
|
// hidden and visible states can be demonstrated without a live backend.
|
|
206
|
+
// TASK-0314: when _detailAllowedTypesFiltered is on, the mock answer also reports
|
|
207
|
+
// allowedTypes: ['ordinaryShares'] — the "Share classes" createTypes picker offers
|
|
208
|
+
// ordinaryShares + preferenceShares, so this demonstrates preferenceShares dropping
|
|
209
|
+
// out of the menu even though the layout item still declares both.
|
|
202
210
|
section.addEventListener('mrdViewCheckCapabilities', async (e) => {
|
|
203
211
|
logEvent('mrdViewCheckCapabilities', e.detail);
|
|
204
|
-
|
|
212
|
+
const allowedTypes = _detailAllowedTypesFiltered ? ['ordinaryShares'] : undefined;
|
|
213
|
+
await section.setViewCanCreate(e.detail.name, _detailCanCreate, allowedTypes);
|
|
205
214
|
});
|
|
206
215
|
|
|
207
216
|
wrapper.appendChild(section);
|
|
@@ -231,7 +240,27 @@ function onDetailViewReadOnlyToggle(checked) {
|
|
|
231
240
|
function onDetailViewCanCreateToggle(checked) {
|
|
232
241
|
_detailCanCreate = checked;
|
|
233
242
|
document.querySelectorAll('#detail-sections mrd-layout-section').forEach((section) => {
|
|
234
|
-
section.setViewCanCreate('shareClasses', checked);
|
|
243
|
+
section.setViewCanCreate('shareClasses', checked, _detailAllowedTypesFiltered ? ['ordinaryShares'] : undefined);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** allowedTypes demo (TASK-0314): re-applies the mock capabilities answer with/without
|
|
248
|
+
* allowedTypes so the "Share classes" +-button's picker narrows to "Ordinary shares"
|
|
249
|
+
* only, without re-fetching. */
|
|
250
|
+
function onDetailViewAllowedTypesToggle(checked) {
|
|
251
|
+
_detailAllowedTypesFiltered = checked;
|
|
252
|
+
document.querySelectorAll('#detail-sections mrd-layout-section').forEach((section) => {
|
|
253
|
+
section.setViewCanCreate('shareClasses', _detailCanCreate, checked ? ['ordinaryShares'] : undefined);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** accessControlEnabled demo (TASK-0322): when disabled, mrd-layout-section skips
|
|
258
|
+
* mrdViewCheckCapabilities entirely and the "Share classes" add button shows up
|
|
259
|
+
* immediately, regardless of the mock canCreate answer above. */
|
|
260
|
+
function onDetailViewAccessControlToggle(disabled) {
|
|
261
|
+
_detailAccessControlEnabled = !disabled;
|
|
262
|
+
document.querySelectorAll('#detail-sections mrd-layout-section').forEach((section) => {
|
|
263
|
+
section.accessControlEnabled = _detailAccessControlEnabled;
|
|
235
264
|
});
|
|
236
265
|
}
|
|
237
266
|
|
|
@@ -531,6 +560,7 @@ async function renderSection(index) {
|
|
|
531
560
|
section.data = _dashboardRecord ?? { _links: _dashboardData._links ?? {} };
|
|
532
561
|
section.locale = _locale;
|
|
533
562
|
section.readOnly = _liveApiReadOnly;
|
|
563
|
+
section.accessControlEnabled = _liveApiAccessControlEnabled;
|
|
534
564
|
// Dashboard-level archetypes describe the object itself → single-document view.
|
|
535
565
|
// Only apply to the main object layout, not tab-page (related) layouts.
|
|
536
566
|
section.archetypes = (!layout.tabPage && _dashboardData.archetypes) ? _dashboardData.archetypes : [];
|
|
@@ -597,7 +627,7 @@ async function renderSection(index) {
|
|
|
597
627
|
logEvent('mrdViewCheckCapabilities', e.detail);
|
|
598
628
|
try {
|
|
599
629
|
const result = await apiFetchCapabilities(authGetToken(), _baseHref, refType, refId, type, filterClass);
|
|
600
|
-
await section.setViewCanCreate(name, !!result?.mayCreate);
|
|
630
|
+
await section.setViewCanCreate(name, !!result?.mayCreate, result?.allowedTypes);
|
|
601
631
|
} catch (err) {
|
|
602
632
|
console.error('[mrdViewCheckCapabilities] mislukt', name, err);
|
|
603
633
|
}
|
|
@@ -747,6 +777,15 @@ function onLiveApiReadOnlyToggle(checked) {
|
|
|
747
777
|
if (section) section.readOnly = checked;
|
|
748
778
|
}
|
|
749
779
|
|
|
780
|
+
/** accessControlEnabled demo (TASK-0322): when disabled, mrd-layout-section skips
|
|
781
|
+
* mrdViewCheckCapabilities entirely (no apiFetchCapabilities call) and every
|
|
782
|
+
* VIEW/RELATED_VIEW's create affordance shows up immediately. */
|
|
783
|
+
function onLiveApiAccessControlToggle(disabled) {
|
|
784
|
+
_liveApiAccessControlEnabled = !disabled;
|
|
785
|
+
const section = document.querySelector('#sections-container mrd-layout-section');
|
|
786
|
+
if (section) section.accessControlEnabled = _liveApiAccessControlEnabled;
|
|
787
|
+
}
|
|
788
|
+
|
|
750
789
|
function toggleJsonViewer() {
|
|
751
790
|
const viewer = document.getElementById('json-viewer');
|
|
752
791
|
const btn = document.getElementById('btn-json-toggle');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as t,proxyCustomElement as e,HTMLElement as r,createEvent as o,Host as i,transformTag as a}from"@stencil/core/internal/client";import{a as n,b as s,r as l,A as d,i as c,e as m,h as u,f as v,g as h}from"./client-layout.js";import{t as y}from"./i18n.js";import{C as f}from"./cell-renderer.js";import{a as p}from"./format.js";import{d as b}from"./mrd-boolean-field2.js";import{d as _}from"./mrd-document-container2.js";import{d as g}from"./mrd-document-list2.js";import{d as w}from"./mrd-document-view2.js";import{d as k}from"./mrd-email-view2.js";import{d as x}from"./mrd-invoice-view2.js";import{d as j}from"./mrd-list-field2.js";import{d as C}from"./mrd-memo-container2.js";import{d as z}from"./mrd-memo-list2.js";import{d as O}from"./mrd-memo-view2.js";import{d as M}from"./mrd-table2.js";import{d as V}from"./mrd-text-field2.js";import{d as L}from"./mrd-textarea-field2.js";function E(t){var e,r,o,i;return t.type===n.RELATED_VIEW?null!==(r=null!==(e=t.relatedClass)&&void 0!==e?e:t.name)&&void 0!==r?r:"":null!==(i=null!==(o=t.dataClass)&&void 0!==o?o:t.name)&&void 0!==i?i:""}function I(t){var e,r,o,i,a;return null!==(a=null!==(o=null!==(e=t.showEmpty)&&void 0!==e?e:null===(r=t.field)||void 0===r?void 0:r.showEmpty)&&void 0!==o?o:null===(i=t.relation)||void 0===i?void 0:i.showEmpty)&&void 0!==a&&a}function A(t,e){var r,o;if(!t.name)return!1;const i=(null!==(r=null==e?void 0:e._links)&&void 0!==r?r:{})[t.name];return!(!(null===(o=null==i?void 0:i.values)||void 0===o?void 0:o.length)&&!(null==i?void 0:i.name))}function P(t){const e=[];for(const r of t)e.push(r),r.items&&e.push(...P(r.items));return e}function $(e,r,o,i){return t("button",{class:"mrd-layout-section__download-link",onClick:()=>r&&e.on.download({href:r,fileName:o})},t("svg",{class:"mrd-layout-section__file-icon",viewBox:"0 0 24 24","aria-hidden":"true"},t("path",{fill:"currentColor",d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13zm-3 8l-3-3 1.41-1.41L10 14.17l4.59-4.58L16 11l-6 6z"})),i)}function D(e,r,o){var i,a,n,l,d,c,m,u,v,h,p;const b=r.dataType;switch(b){case s.HYPERLINK:{const e=null!==(i=null==o?void 0:o.href)&&void 0!==i?i:o+"",r=null!==(l=null!==(n=null!==(a=null==o?void 0:o.name)&&void 0!==a?a:null==o?void 0:o.text)&&void 0!==n?n:null==o?void 0:o.label)&&void 0!==l?l:e;return t("a",{class:"mrd-layout-section__link",href:e,target:"_blank",rel:"noopener noreferrer"},r)}case s.TEXTBLOCK:return t("div",{class:"mrd-layout-section__prose",innerHTML:o+""});case s.LONGTEXT:return t("pre",{class:"mrd-layout-section__pre"},o+"");case s.JSON:return t("pre",{class:"mrd-layout-section__pre",innerHTML:f.formatJson(o)});case s.FILE:{const t=null!==(d=null==o?void 0:o.fileName)&&void 0!==d?d:o+"",r=null!==(c=null==o?void 0:o.href)&&void 0!==c?c:"";return $(e,r,t,t||y("download",e.locale))}case s.IMAGE:{const i=null!==(m=null==o?void 0:o.href)&&void 0!==m?m:"",a=null!==(u=null==o?void 0:o.fileName)&&void 0!==u?u:"",n=e.imagePreviews[r.name];return n?t("button",{class:"mrd-layout-section__image-thumb-btn",onClick:()=>e.on.openImage(n),title:a||void 0},t("img",{class:"mrd-layout-section__image-thumb",src:n,alt:a})):$(e,i,a,a||i)}case s.BOOLEAN:return t("span",{class:"mrd-layout-section__boolean mrd-layout-section__boolean--"+(o?"true":"false")},y(o?"yes":"no",e.locale));case s.LIST:{const e=(null!==(v=r.listItems)&&void 0!==v?v:[]).find((t=>t.key===o+"")),i=null!==(h=null==e?void 0:e.label)&&void 0!==h?h:o+"",a=null==e?void 0:e.color,n=null==e?void 0:e.backgroundColor;return a&&n?t("span",{class:"mrd-layout-section__badge",style:{color:a,backgroundColor:n}},i):a?t("span",{class:"mrd-layout-section__badge-dot-row"},t("span",{class:"mrd-layout-section__badge-dot",style:{backgroundColor:a}}),i):i}case s.SECRET:return o?t("span",{class:"mrd-layout-section__secret-masked"},"••••••••"):null;default:return f.renderValue(b,o,null!==(p=r.listItems)&&void 0!==p?p:[],e.locale)||null}}function T(e,r){var o,i;if(!r.name)return null;const a=e.data[r.name],n=(null!==(o=r.historyEnabled)&&void 0!==o?o:null===(i=r.field)||void 0===i?void 0:i.historyEnabled)&&null!==a&&"object"==typeof a&&"current"in a?a.current:a,l=function(e,r,o){if(null==o||""===o)return null;if(r.multiple&&Array.isArray(o)){if(r.dataType===s.FILE||r.dataType===s.IMAGE)return t("div",{class:"mrd-layout-section__file-list"},o.map(((o,i)=>t("div",{class:"mrd-layout-section__file-list-item",key:i+""},D(e,r,o)))));const i=o.map((t=>D(e,r,t)));return i.every((t=>"string"==typeof t||null==t))?i.filter(Boolean).join(", ")||null:t("span",null,i.map(((e,r)=>t("span",{key:r+""},e,r<i.length-1?", ":""))))}return D(e,r,o)}(e,r,n);return{raw:a,rawValue:n,renderedValue:l,isEmpty:null==l}}function H(t,e){if(e.header)return!0;const r=T(t,e);return!!r&&(!r.isEmpty||I(e))}const N=e(class extends r{constructor(t){super(),!1!==t&&this.__registerHost(),this.mrdNavigate=o(this,"mrdNavigate",7),this.mrdSearch=o(this,"mrdSearch",7),this.mrdDownload=o(this,"mrdDownload",7),this.mrdLoadViewPage=o(this,"mrdLoadViewPage",7),this.mrdLoadImage=o(this,"mrdLoadImage",7),this.mrdAttachments=o(this,"mrdAttachments",7),this.mrdViewAction=o(this,"mrdViewAction",7),this.mrdLoadViewAggregations=o(this,"mrdLoadViewAggregations",7),this.mrdLoadViewDistinct=o(this,"mrdLoadViewDistinct",7),this.mrdViewCheckCapabilities=o(this,"mrdViewCheckCapabilities",7),this.mrdUpdateObject=o(this,"mrdUpdateObject",7),this.mrdDeleteObject=o(this,"mrdDeleteObject",7),this.mrdViewUpload=o(this,"mrdViewUpload",7),this.mrdCreateObject=o(this,"mrdCreateObject",7),this.items=[],this.data={},this.views={},this.links={},this.locale=navigator.language,this.archetypes=[],this.readOnly=!1,this.me=null,this.searchQueryMap={},this.searchResultsMap={},this.imagePreviewUrl=null,this.imagePreviews={},this.openHistoryField=null,this.canCreateMap={},this.historyClickOutside=null,this.capabilitiesAsked=new Map,this.searchTimers={},this.handleViewLoadPage=(t,e)=>{t.stopPropagation(),this.mrdLoadViewPage.emit({name:e,page:t.detail.page,sort:t.detail.sort,path:t.detail.path,qs:t.detail.qs})},this.handleSearchInput=(t,e)=>{this.searchQueryMap=Object.assign(Object.assign({},this.searchQueryMap),{[t]:e}),this.searchTimers[t]&&clearTimeout(this.searchTimers[t]),e.length<2?this.searchResultsMap=Object.assign(Object.assign({},this.searchResultsMap),{[t]:[]}):this.searchTimers[t]=setTimeout((()=>{this.mrdSearch.emit({query:e,dataClass:t})}),300)}}componentDidLoad(){this.emitCapabilitiesChecks(),setTimeout((()=>{this.initEmbeddedTables(),this.emitLoadImages()}),0),this.historyClickOutside=t=>{this.el.contains(t.target)||(this.openHistoryField=null)},document.addEventListener("mousedown",this.historyClickOutside)}disconnectedCallback(){this.historyClickOutside&&(document.removeEventListener("mousedown",this.historyClickOutside),this.historyClickOutside=null)}dataChanged(t){t&&Object.keys(t).length>0&&(this.emitCapabilitiesChecks(),setTimeout((()=>this.initEmbeddedTables()),0))}itemsChanged(){this.emitCapabilitiesChecks()}async initEmbeddedTables(){const t=this.el.querySelectorAll("mrd-table[data-view]");for(const e of Array.from(t))"function"==typeof e.init&&await e.init();const e=this.el.querySelectorAll("mrd-memo-list[data-view]");for(const t of Array.from(e))"function"==typeof t.init&&await t.init()}emitLoadImages(){for(const t of P(this.items))if(t.type===n.FIELD&&t.dataType===s.IMAGE){const e=t.name,r=this.data[e],o=null==r?void 0:r.href;o&&this.mrdLoadImage.emit({fieldName:e,href:o})}}computeParentId(){var t,e,r,o,i;return null!==(i=(null!==(o=null===(r=null===(e=null===(t=this.data)||void 0===t?void 0:t._links)||void 0===e?void 0:e.self)||void 0===r?void 0:r.href)&&void 0!==o?o:"").split("/").filter(Boolean).pop())&&void 0!==i?i:""}emitCapabilitiesChecks(){var t,e,r,o;const i=this.computeParentId();for(const a of P(this.items)){if(a.type!==n.VIEW&&a.type!==n.RELATED_VIEW)continue;const s=E(a);if(!s||!a.view)continue;const l=a.type===n.RELATED_VIEW,d=null!==(e=null!==(t=a.dataClass)&&void 0!==t?t:a.relatedClass)&&void 0!==e?e:s,c=l?null!==(r=a.fromClass)&&void 0!==r?r:"":void 0,m=l?i:void 0,u=null!==(o=a.filterClass)&&void 0!==o?o:void 0,v=JSON.stringify([d,c,m,u]);if(this.capabilitiesAsked.get(s)!==v){if(this.capabilitiesAsked.set(s,v),s in this.canCreateMap){const t=Object.assign({},this.canCreateMap);delete t[s],this.canCreateMap=t}this.mrdViewCheckCapabilities.emit(Object.assign(Object.assign({name:s,type:d},void 0!==c?{refType:c,refId:m}:{}),u?{filterClass:u}:{}))}}}async setSearchResults(t,e){const r=null!=e?e:this.resolveSearchKey();r&&(this.searchResultsMap=Object.assign(Object.assign({},this.searchResultsMap),{[r]:t}))}async setViewPage(t,e,r,o,i,a){if(a){const e=this.el.querySelector(`mrd-document-list[data-doclist="${t}"]`);return void((null==e?void 0:e.setDocuments)&&await e.setDocuments(a,r))}const n=this.el.querySelector(`mrd-table[data-view="${t}"]`);if(n)return void 0!==o&&(n.totalElements=o),void await n.setPage(e,r,i);const s=this.el.querySelector(`mrd-memo-list[data-view="${t}"]`);s&&await s.setPage(e,r,i)}async setViewAggregations(t,e){const r=this.el.querySelector(`mrd-table[data-view="${t}"]`);r&&await r.setAggregations(e)}async setViewCanCreate(t,e){this.canCreateMap=Object.assign(Object.assign({},this.canCreateMap),{[t]:e})}async setViewDistinct(t,e,r){const o=this.el.querySelector(`mrd-document-list[data-doclist="${t}"]`);(null==o?void 0:o.setDistinct)&&await o.setDistinct(e,r)}async setViewFileReference(t,e){const r=this.el.querySelector(`mrd-document-list[data-doclist="${t}"]`);(null==r?void 0:r.setFileReference)&&await r.setFileReference(e)}async setViewCreatedObject(t,e){const r=this.el.querySelector(`mrd-document-list[data-doclist="${t}"]`);if(null==r?void 0:r.setCreatedHref)return void await r.setCreatedHref(e);const o=this.el.querySelector(`mrd-memo-container[data-view="${t}"]`);(null==o?void 0:o.refresh)&&await o.refresh()}async setImagePreview(t,e){this.imagePreviews=Object.assign(Object.assign({},this.imagePreviews),{[t]:e})}async openImagePreview(t){this.imagePreviewUrl=t}resolveSearchKey(){var t;const e=P(this.items).filter((t=>t.type===n.SEARCH));return 1===e.length&&null!==(t=e[0].dataClass)&&void 0!==t?t:null}fieldCtx(){return{locale:this.locale,data:this.data,imagePreviews:this.imagePreviews,openHistoryField:this.openHistoryField,on:{download:t=>this.mrdDownload.emit(t),openImage:t=>{this.imagePreviewUrl=t},toggleHistory:t=>{this.openHistoryField=t}}}}renderField(e){return function(e,r){const o=T(e,r);if(!o)return null;const{raw:i,rawValue:a,renderedValue:n,isEmpty:l}=o;return r.header?t("h1",{class:"mrd-layout-section__field-header",key:r.name},"string"==typeof n?n:null!=a?a+"":r.label):l&&!I(r)?null:t("div",{class:`mrd-layout-section__field${r.dataType===s.TEXTBLOCK||r.dataType===s.LONGTEXT||r.dataType===s.JSON?" mrd-layout-section__field--block":""}${l?" mrd-layout-section__field--empty":""}`,key:r.name},t("span",{class:"mrd-layout-section__field-label"},r.label),t("span",{class:"mrd-layout-section__field-value"},l?y("value_empty",e.locale):n,function(e,r,o){var i,a,n;if(!(null!==(i=r.historyEnabled)&&void 0!==i?i:null===(a=r.field)||void 0===a?void 0:a.historyEnabled)||!r.name)return null;const s=null!==(n=null==o?void 0:o.history)&&void 0!==n?n:[];if(!s.length)return null;const l=[...s].sort(((t,e)=>e.until.localeCompare(t.until))),d=e.openHistoryField===r.name;return t("span",{class:"mrd-layout-section__history-wrap"},t("button",{type:"button",class:"mrd-layout-section__history-btn",title:y("history_badge_tooltip",e.locale),"aria-label":y("history_badge_tooltip",e.locale),onClick:t=>{t.stopPropagation(),e.on.toggleHistory(d?null:r.name)}},t("svg",{class:"mrd-layout-section__history-icon",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},t("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"}))),d&&t("div",{class:"mrd-layout-section__history-popover",role:"listbox"},l.map(((r,o)=>t("div",{key:o+"",class:"mrd-layout-section__history-entry"},r.value," (",y("history_until",e.locale)," ",p(r.until,e.locale),")")))))}(e,r,i)))}(this.fieldCtx(),e)}renderRelation(e){var r,o,i;if(!e.name)return null;const a=(null!==(o=null===(r=this.data)||void 0===r?void 0:r._links)&&void 0!==o?o:{})[e.name],n=(e,r)=>t("button",{key:e,class:"mrd-layout-section__relation-link",onClick:()=>this.mrdNavigate.emit({href:e,label:r})},r);let s;(null===(i=null==a?void 0:a.values)||void 0===i?void 0:i.length)?s=a.values.map((t=>n(t.href,t.name))):(null==a?void 0:a.name)&&(s=n(a.href,a.name));const l=!A(e,this.data);return l&&!I(e)?null:t("div",{class:"mrd-layout-section__field"+(l?" mrd-layout-section__field--empty":""),key:e.name},t("span",{class:"mrd-layout-section__field-label"},e.label),t("span",{class:"mrd-layout-section__field-value"},l?y("value_empty",this.locale):s))}renderSearch(e){var r,o,i;if(!e.dataClass)return null;const a=e.dataClass,n=null!==(r=this.searchQueryMap[a])&&void 0!==r?r:"",s=null!==(o=this.searchResultsMap[a])&&void 0!==o?o:[];return t("div",{class:"mrd-layout-section__search",key:"search-"+a},t("div",{class:"mrd-layout-section__search-wrap"},t("svg",{class:"mrd-layout-section__search-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},t("path",{"fill-rule":"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z","clip-rule":"evenodd"})),t("input",{class:"mrd-layout-section__search-input",type:"text",value:n,placeholder:null!==(i=e.label)&&void 0!==i?i:"",onInput:t=>this.handleSearchInput(a,t.target.value)})),s.length>0&&t("ul",{class:"mrd-layout-section__search-results"},s.map((e=>t("li",{key:e.id,class:"mrd-layout-section__search-result"},t("button",{class:"mrd-layout-section__search-result-btn",onClick:()=>this.mrdNavigate.emit({href:e.id,label:e.label})},t("span",{class:"mrd-layout-section__search-result-label"},e.label),e.description&&t("span",{class:"mrd-layout-section__search-result-desc"},e.description)))))))}renderRelatedView(e){var r,o,i,a,s,m,u,v,h,y;const f=E(e);if(!f)return null;if(!e.view)return null;const p=null!==(r=e.showTitle)&&void 0!==r&&r,b=null!==(s=null===(a=null===(i=null===(o=this.data)||void 0===o?void 0:o._links)||void 0===i?void 0:i.self)||void 0===a?void 0:a.href)&&void 0!==s?s:"",_=this.computeParentId(),g=l(null!==(m=e.archetypes)&&void 0!==m?m:null===(u=e.view)||void 0===u?void 0:u.archetypes,d),w=g?void 0:l(null!==(v=e.archetypes)&&void 0!==v?v:null===(h=e.view)||void 0===h?void 0:h.archetypes,c),k=function(t,e,r){if(t.type!==n.RELATED_VIEW||!t.fromClass||!r)return"";const o=e.split("/").filter(Boolean);if(o.length<2)return"";const[i,a]=o;return`/${i}/${a}/${t.fromClass}/${r}`}(e,b,_),x=e.type!==n.RELATED_VIEW||e.inverseRelation===(null===(y=null==w?void 0:w.slots)||void 0===y?void 0:y.container),j=x?k:"",C=e.type===n.RELATED_VIEW&&x;return t("div",{class:"mrd-layout-section__related-view",key:"view-"+f},p&&e.label&&t("h3",{class:"mrd-layout-section__related-view-title"},e.label),g&&this.renderDocumentContainer(e,f,_,g,k),w&&this.renderMemoContainer(e,f,_,w,j,x,!C),!g&&!w&&this.renderTable(e,f,_))}renderDocumentContainer(e,r,o,i,a){var n;return t("mrd-document-container",{item:e,archetype:i,parentId:o,containerHref:a,viewKey:r,locale:this.locale,readOnly:this.readOnly,mayCreate:null!==(n=this.canCreateMap[r])&&void 0!==n&&n,onMrdLoadDistinct:t=>{t.stopPropagation(),this.mrdLoadViewDistinct.emit(Object.assign({name:r},t.detail))},onMrdLoadPage:t=>{t.stopPropagation(),this.mrdLoadViewPage.emit(Object.assign({name:r},t.detail))},onMrdLoadAggregations:t=>{var o;t.stopPropagation(),this.mrdLoadViewAggregations.emit(Object.assign({name:r,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r},t.detail))},onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(t.detail)},onMrdAction:t=>{var o;t.stopPropagation(),this.mrdViewAction.emit(Object.assign({name:r,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r},t.detail))},onMrdUpdateObject:t=>{t.stopPropagation(),this.mrdUpdateObject.emit(t.detail)},onMrdUpload:t=>{t.stopPropagation(),this.mrdViewUpload.emit(Object.assign({name:r},t.detail))},onMrdCreateObject:t=>{t.stopPropagation(),this.mrdCreateObject.emit(Object.assign({name:r},t.detail))}})}renderMemoContainer(e,r,o,i,a,n,s){var l,d,c,u,v;const h=null!==(u=null===(c=null===(d=null===(l=e.view)||void 0===l?void 0:l.values)||void 0===d?void 0:d.find((t=>{var e;return t.name===(null===(e=i.slots)||void 0===e?void 0:e.labels)})))||void 0===c?void 0:c.listItems)&&void 0!==u?u:null;return t("mrd-memo-container",{"data-view":r,item:e,archetype:i,parentId:o,containerHref:a,containerRelated:n,showContainerLink:s,viewKey:r,locale:this.locale,readOnly:this.readOnly,canCreate:null!==(v=this.canCreateMap[r])&&void 0!==v&&v,me:this.me,labelsListItems:h,onMrdNavigate:t=>{var r;t.stopPropagation(),this.mrdNavigate.emit(Object.assign(Object.assign({},t.detail),{navigateBehaviour:null!==(r=e.navigateBehaviour)&&void 0!==r?r:m.PAGE}))},onMrdLoadPage:t=>{t.stopPropagation(),this.mrdLoadViewPage.emit(Object.assign({name:r},t.detail))},onMrdLoadAggregations:t=>{var o;t.stopPropagation(),this.mrdLoadViewAggregations.emit(Object.assign({name:r,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r},t.detail))},onMrdAction:t=>{var o;t.stopPropagation(),this.mrdViewAction.emit(Object.assign({name:r,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r},t.detail))},onMrdCreateObject:t=>{t.stopPropagation(),this.mrdCreateObject.emit(Object.assign({name:r},t.detail))},onMrdUpdateObject:t=>{t.stopPropagation(),this.mrdUpdateObject.emit(t.detail)},onMrdDeleteObject:t=>{t.stopPropagation(),this.mrdDeleteObject.emit(t.detail)}})}renderTable(e,r,o){var i;return t("mrd-table",{"data-view":r,item:e,parentId:o,locale:this.locale,readOnly:this.readOnly,canCreate:null!==(i=this.canCreateMap[r])&&void 0!==i&&i,onMrdLoadPage:t=>this.handleViewLoadPage(t,r),onMrdLoadAggregations:t=>{var o;t.stopPropagation(),this.mrdLoadViewAggregations.emit(Object.assign({name:r,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r},t.detail))},onMrdRowClick:t=>{var r,o,i,a;t.stopPropagation();const{row:n,listContext:s}=t.detail;this.mrdNavigate.emit({href:null===(o=null===(r=null==n?void 0:n._links)||void 0===r?void 0:r.self)||void 0===o?void 0:o.href,label:null!==(i=null==n?void 0:n.name)&&void 0!==i?i:"",navigateBehaviour:null!==(a=e.navigateBehaviour)&&void 0!==a?a:m.PAGE,listContext:s})},onMrdAction:t=>{var o;t.stopPropagation(),this.mrdViewAction.emit({name:r,action:t.detail.action,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r,path:t.detail.path,qs:t.detail.qs,parentPath:t.detail.parentPath,basicType:t.detail.basicType})}})}isHeaderBlockEmpty(t,e){const r=this.fieldCtx();for(let o=e+1;o<t.length;o++){const e=t[o];if(e.type===n.HEADER||e.type===n.SECTION||e.type===n.GROUP)break;if(e.type===n.FIELD&&H(r,e))return!1;if(e.type===n.RELATION&&(A(e,this.data)||I(e)))return!1;if(e.type!==n.FIELD&&e.type!==n.RELATION)return!1}return!0}renderItem(e,r=this.items,o=-1){var i,a;switch(e.type){case n.FIELD:return this.renderField(e);case n.RELATION:return this.renderRelation(e);case n.HEADER:return o>=0&&this.isHeaderBlockEmpty(r,o)?null:t("h2",{class:"mrd-layout-section__header",key:"header-"+e.label},e.label);case n.TEXT:return t("div",{class:"mrd-layout-section__text",key:"text-"+e.label,innerHTML:null!==(i=e.label)&&void 0!==i?i:""});case n.NAVIGATE:return t("button",{class:"mrd-layout-section__navigate",key:"nav-"+e.label,onClick:()=>{var t,r,o;return this.mrdNavigate.emit({label:null!==(t=e.label)&&void 0!==t?t:"",navigate:null!==(r=e.navigate)&&void 0!==r?r:{dataClass:null!==(o=e.dataClass)&&void 0!==o?o:"",icon:e.icon,navigationType:e.navigationType}})}},e.label);case n.SEARCH:return this.renderSearch(e);case n.SECTION:case n.GROUP:return t("div",{class:"mrd-layout-section__group",key:"group-"+e.label},e.label&&t("h3",{class:"mrd-layout-section__group-title"},e.label),(null!==(a=e.items)&&void 0!==a?a:[]).map(((t,r)=>{var o;return this.renderItem(t,null!==(o=e.items)&&void 0!==o?o:[],r)})));case n.RELATED_VIEW:case n.VIEW:return this.renderRelatedView(e);default:return null}}renderImageModal(){return this.imagePreviewUrl?t("div",{class:"mrd-layout-section__modal-backdrop",onClick:()=>{this.imagePreviewUrl=null}},t("div",{class:"mrd-layout-section__modal",onClick:t=>t.stopPropagation()},t("button",{class:"mrd-layout-section__modal-close",onClick:()=>{this.imagePreviewUrl=null}},"✕"),t("img",{class:"mrd-layout-section__modal-image",src:this.imagePreviewUrl,alt:""}))):null}relatedItems(t){return this.items.filter((e=>e!==t&&(e.type===n.VIEW||e.type===n.RELATED_VIEW||e.type===n.SEARCH)))}renderDocumentObject(e){return[t("mrd-document-view",{archetype:e,data:this.data,locale:this.locale,onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(t.detail)},onMrdDownload:t=>{t.stopPropagation(),this.mrdDownload.emit(t.detail)},onMrdAttachments:t=>{t.stopPropagation(),this.mrdAttachments.emit(t.detail)}}),...this.relatedItems().map((t=>this.renderItem(t)))]}renderInvoiceObject(e){var r,o,i;const a=null!==(r=this.items.find((t=>{var e,r;return(t.type===n.VIEW||t.type===n.RELATED_VIEW)&&!!l(null!==(e=t.archetypes)&&void 0!==e?e:null===(r=t.view)||void 0===r?void 0:r.archetypes,u)})))&&void 0!==r?r:null,s=null!==(i=null===(o=this.items.find((t=>{var r;return t.name===(null===(r=e.slots)||void 0===r?void 0:r.status)})))||void 0===o?void 0:o.listItems)&&void 0!==i?i:null;return[t("mrd-invoice-view",{archetype:e,data:this.data,locale:this.locale,statusListItems:s,onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(t.detail)},onMrdDownload:t=>{t.stopPropagation(),this.mrdDownload.emit(t.detail)},onMrdAttachments:t=>{t.stopPropagation(),this.mrdAttachments.emit(t.detail)}},a&&t("div",{slot:"lines"},this.renderRelatedView(a))),...this.relatedItems(a).map((t=>this.renderItem(t)))]}renderEmailObject(e){return[t("mrd-email-view",{archetype:e,data:this.data,locale:this.locale,onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(t.detail)},onMrdDownload:t=>{t.stopPropagation(),this.mrdDownload.emit(t.detail)},onMrdAttachments:t=>{t.stopPropagation(),this.mrdAttachments.emit(t.detail)}}),...this.relatedItems().map((t=>this.renderItem(t)))]}renderMemoObject(e){var r,o;const i=null!==(o=null===(r=this.items.find((t=>{var r;return t.name===(null===(r=e.slots)||void 0===r?void 0:r.labels)})))||void 0===r?void 0:r.listItems)&&void 0!==o?o:null;return[t("mrd-memo-view",{archetype:e,data:this.data,locale:this.locale,labelsListItems:i,onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(t.detail)}}),...this.relatedItems().map((t=>this.renderItem(t)))]}render(){const e=l(this.archetypes,d),r=e?void 0:l(this.archetypes,v),o=e||r?void 0:l(this.archetypes,h),a=e||r||o?void 0:l(this.archetypes,c),n=e||r||o||a;return t(i,{key:"508ca481c777d65d1739f7b5f30f5f3ad8722655"},t("div",{key:"c02630235a2a21511b391ff7b5bebeca1bcc6903",class:"mrd-layout-section"},e&&this.renderDocumentObject(e),r&&this.renderInvoiceObject(r),o&&this.renderEmailObject(o),a&&this.renderMemoObject(a),!n&&this.items.map(((t,e)=>this.renderItem(t,this.items,e)))),this.renderImageModal())}get el(){return this}static get watchers(){return{data:[{dataChanged:0}],items:[{itemsChanged:0}]}}static get style(){return".sc-mrd-layout-section-h{display:block;width:100%}.mrd-layout-section.sc-mrd-layout-section{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);color:var(--mrd-color-neutral-800)}.mrd-layout-section__field.sc-mrd-layout-section{display:grid;grid-template-columns:200px 1fr;align-items:baseline;gap:0 var(--mrd-space-2);padding:var(--mrd-space-1) 0}.mrd-layout-section__field--block.sc-mrd-layout-section{grid-template-columns:1fr}.mrd-layout-section__field-label.sc-mrd-layout-section{font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-normal);color:var(--mrd-color-neutral-500);padding-top:1px}.mrd-layout-section__field-value.sc-mrd-layout-section{font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-800);word-break:break-word;display:inline-flex;align-items:center;gap:var(--mrd-space-1)}.mrd-layout-section__field--empty.sc-mrd-layout-section .mrd-layout-section__field-value.sc-mrd-layout-section{color:var(--mrd-color-neutral-400);font-weight:var(--mrd-font-weight-normal)}.mrd-layout-section__history-wrap.sc-mrd-layout-section{position:relative;display:inline-flex;align-items:center}.mrd-layout-section__history-btn.sc-mrd-layout-section{display:inline-flex;align-items:center;justify-content:center;width:1.25rem;height:1.25rem;padding:0;background:transparent;border:none;border-radius:var(--mrd-border-radius-sm);color:var(--mrd-color-neutral-400);cursor:pointer;flex-shrink:0;transition:color var(--mrd-transition-fast), background-color var(--mrd-transition-fast)}.mrd-layout-section__history-btn.sc-mrd-layout-section:hover{color:var(--mrd-color-neutral-700);background-color:var(--mrd-color-neutral-100)}.mrd-layout-section__history-btn.sc-mrd-layout-section:focus{outline:none;box-shadow:var(--mrd-shadow-focus)}.mrd-layout-section__history-icon.sc-mrd-layout-section{width:0.875rem;height:0.875rem}.mrd-layout-section__history-popover.sc-mrd-layout-section{position:absolute;top:calc(100% + 0.25rem);left:0;min-width:24rem;max-width:24rem;background-color:var(--mrd-color-white);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-md);box-shadow:var(--mrd-shadow-md);padding:var(--mrd-space-1) 0;z-index:var(--mrd-z-dropdown)}.mrd-layout-section__history-entry.sc-mrd-layout-section{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-normal);color:var(--mrd-color-neutral-700);padding:var(--mrd-space-2) var(--mrd-space-3);line-height:var(--mrd-line-height-normal)}.mrd-layout-section__history-entry.sc-mrd-layout-section:not(:last-child){border-bottom:var(--mrd-border-width) solid var(--mrd-color-neutral-100)}.mrd-layout-section__field-header.sc-mrd-layout-section{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-4) 0;padding:0}.mrd-layout-section__header.sc-mrd-layout-section{font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-neutral-500);letter-spacing:0.01em;margin:var(--mrd-space-5) 0 var(--mrd-space-2) 0;padding:0}.mrd-layout-section__text.sc-mrd-layout-section{font-size:var(--mrd-font-size-base);color:var(--mrd-color-neutral-700);line-height:var(--mrd-line-height-relaxed);margin:var(--mrd-space-2) 0}.mrd-layout-section__navigate.sc-mrd-layout-section{display:inline-flex;align-items:center;gap:var(--mrd-space-2);padding:var(--mrd-space-2) var(--mrd-space-3);background:none;border:1px solid var(--mrd-color-neutral-300);border-radius:var(--mrd-border-radius);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-primary);cursor:pointer;margin:var(--mrd-space-2) 0}.mrd-layout-section__navigate.sc-mrd-layout-section:hover{background-color:var(--mrd-color-primary-light);border-color:var(--mrd-color-primary)}.mrd-layout-section__link.sc-mrd-layout-section{color:var(--mrd-color-primary);text-decoration:none}.mrd-layout-section__link.sc-mrd-layout-section:hover{text-decoration:underline}.mrd-layout-section__relation-link.sc-mrd-layout-section{background:none;border:none;padding:0;font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-primary);cursor:pointer;text-align:left}.mrd-layout-section__relation-link.sc-mrd-layout-section:hover{text-decoration:underline}.mrd-layout-section__download-link.sc-mrd-layout-section{display:inline-flex;align-items:center;gap:var(--mrd-space-1);background:none;border:none;padding:0;font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-primary);cursor:pointer;text-align:left}.mrd-layout-section__download-link.sc-mrd-layout-section:hover{text-decoration:underline;color:var(--mrd-color-primary-dark)}.mrd-layout-section__file-icon.sc-mrd-layout-section{flex-shrink:0;width:1rem;height:1rem}.mrd-layout-section__file-list.sc-mrd-layout-section{display:flex;flex-direction:column;align-items:flex-start;gap:var(--mrd-space-1)}.mrd-layout-section__file-list-item.sc-mrd-layout-section{min-width:0;max-width:100%}.mrd-layout-section__boolean--true.sc-mrd-layout-section{color:var(--mrd-color-success);font-weight:var(--mrd-font-weight-semibold)}.mrd-layout-section__boolean--false.sc-mrd-layout-section{color:var(--mrd-color-neutral-400)}.mrd-layout-section__badge.sc-mrd-layout-section{display:inline-block;font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);padding:2px var(--mrd-space-3);border-radius:10px}.mrd-layout-section__badge-dot-row.sc-mrd-layout-section{display:inline-flex;align-items:center;gap:var(--mrd-space-2)}.mrd-layout-section__badge-dot.sc-mrd-layout-section{display:inline-block;width:10px;height:10px;border-radius:50%;flex-shrink:0}.mrd-layout-section__secret-masked.sc-mrd-layout-section{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);color:var(--mrd-label-color);letter-spacing:0.15em;user-select:none;pointer-events:none}.mrd-layout-section__pre.sc-mrd-layout-section{font-family:var(--mrd-font-family-mono);font-size:var(--mrd-font-size-xs);background-color:var(--mrd-color-neutral-50);border:1px solid var(--mrd-color-neutral-200);border-radius:var(--mrd-border-radius);padding:var(--mrd-space-3);margin:0;max-height:calc(15 * var(--mrd-font-size-xs));overflow-x:auto;overflow-y:auto;white-space:pre-wrap;word-break:break-word}.mrd-layout-section__group.sc-mrd-layout-section{margin:var(--mrd-space-4) 0}.mrd-layout-section__group-title.sc-mrd-layout-section{font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-neutral-500);margin:0 0 var(--mrd-space-2) 0;padding-bottom:0;letter-spacing:0.01em}.mrd-layout-section__related-view.sc-mrd-layout-section{margin:var(--mrd-space-4) 0}.mrd-layout-section__related-view-title.sc-mrd-layout-section{font-size:var(--mrd-font-size-lg);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-neutral-800);margin:0 0 var(--mrd-space-3) 0}.mrd-layout-section__search.sc-mrd-layout-section{position:relative;margin:var(--mrd-space-2) 0}.mrd-layout-section__search-wrap.sc-mrd-layout-section{position:relative}.mrd-layout-section__search-icon.sc-mrd-layout-section{position:absolute;left:var(--mrd-input-padding-x);top:50%;transform:translateY(-50%);width:1rem;height:1rem;color:var(--mrd-color-neutral-400);pointer-events:none}.mrd-layout-section__search-input.sc-mrd-layout-section{display:block;width:100%;height:var(--mrd-input-height);padding:var(--mrd-input-padding-y) var(--mrd-input-padding-x) var(--mrd-input-padding-y) calc(var(--mrd-input-padding-x) + 1rem + var(--mrd-space-2));font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);color:var(--mrd-input-color);background-color:var(--mrd-input-bg);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);outline:none;appearance:none;box-sizing:border-box}.mrd-layout-section__search-input.sc-mrd-layout-section:focus{border-color:var(--mrd-border-color-focus);box-shadow:var(--mrd-shadow-focus)}.mrd-layout-section__search-input.sc-mrd-layout-section::placeholder{color:var(--mrd-input-placeholder-color)}.mrd-layout-section__search-results.sc-mrd-layout-section{position:absolute;top:100%;left:0;right:0;background-color:var(--mrd-color-white);border:1px solid var(--mrd-color-neutral-300);border-top:none;border-radius:0 0 var(--mrd-border-radius) var(--mrd-border-radius);box-shadow:var(--mrd-shadow-sm);z-index:100;max-height:300px;overflow-y:auto;list-style:none;margin:0;padding:var(--mrd-space-1) 0}.mrd-layout-section__search-result.sc-mrd-layout-section{margin:0;padding:0}.mrd-layout-section__search-result-btn.sc-mrd-layout-section{display:flex;flex-direction:column;width:100%;padding:var(--mrd-space-2) var(--mrd-space-3);background:none;border:none;text-align:left;cursor:pointer;font-family:var(--mrd-font-family)}.mrd-layout-section__search-result-btn.sc-mrd-layout-section:hover{background-color:var(--mrd-color-primary-light)}.mrd-layout-section__search-result-label.sc-mrd-layout-section{font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-800)}.mrd-layout-section__search-result-desc.sc-mrd-layout-section{font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500);margin-top:var(--mrd-space-1)}.mrd-layout-section__image-thumb-btn.sc-mrd-layout-section{background:none;border:none;padding:0;cursor:pointer;display:inline-block;border-radius:var(--mrd-border-radius);overflow:hidden;line-height:0}.mrd-layout-section__image-thumb-btn.sc-mrd-layout-section:hover .mrd-layout-section__image-thumb.sc-mrd-layout-section{opacity:0.85}.mrd-layout-section__image-thumb.sc-mrd-layout-section{display:block;max-width:160px;max-height:100px;border-radius:var(--mrd-border-radius);object-fit:cover;transition:opacity 0.15s}.mrd-layout-section__modal-backdrop.sc-mrd-layout-section{position:fixed;inset:0;background:rgba(0, 0, 0, 0.6);z-index:300;display:flex;align-items:center;justify-content:center}.mrd-layout-section__modal.sc-mrd-layout-section{position:relative;background:var(--mrd-color-white);border-radius:var(--mrd-border-radius);padding:var(--mrd-space-3);max-width:min(90vw, 900px);max-height:90vh;display:flex;align-items:center;justify-content:center;box-shadow:var(--mrd-shadow-lg)}.mrd-layout-section__modal-close.sc-mrd-layout-section{position:absolute;top:var(--mrd-space-2);right:var(--mrd-space-2);background:rgba(0, 0, 0, 0.5);border:none;border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;color:var(--mrd-color-white);cursor:pointer;font-size:var(--mrd-font-size-sm);line-height:1;z-index:1}.mrd-layout-section__modal-close.sc-mrd-layout-section:hover{background:rgba(0, 0, 0, 0.8)}.mrd-layout-section__modal-image.sc-mrd-layout-section{display:block;max-width:100%;max-height:calc(90vh - 2rem);border-radius:var(--mrd-border-radius);object-fit:contain}"}},[2,"mrd-layout-section",{items:[16],data:[16],views:[16],links:[16],locale:[1],archetypes:[16],readOnly:[4,"read-only"],me:[16],searchQueryMap:[32],searchResultsMap:[32],imagePreviewUrl:[32],imagePreviews:[32],openHistoryField:[32],canCreateMap:[32],setSearchResults:[64],setViewPage:[64],setViewAggregations:[64],setViewCanCreate:[64],setViewDistinct:[64],setViewFileReference:[64],setViewCreatedObject:[64],setImagePreview:[64],openImagePreview:[64]},void 0,{data:[{dataChanged:0}],items:[{itemsChanged:0}]}]),B=N,R=function(){"undefined"!=typeof customElements&&["mrd-layout-section","mrd-boolean-field","mrd-document-container","mrd-document-list","mrd-document-view","mrd-email-view","mrd-invoice-view","mrd-list-field","mrd-memo-container","mrd-memo-list","mrd-memo-view","mrd-table","mrd-text-field","mrd-textarea-field"].forEach((t=>{switch(t){case"mrd-layout-section":customElements.get(a(t))||customElements.define(a(t),N);break;case"mrd-boolean-field":customElements.get(a(t))||b();break;case"mrd-document-container":customElements.get(a(t))||_();break;case"mrd-document-list":customElements.get(a(t))||g();break;case"mrd-document-view":customElements.get(a(t))||w();break;case"mrd-email-view":customElements.get(a(t))||k();break;case"mrd-invoice-view":customElements.get(a(t))||x();break;case"mrd-list-field":customElements.get(a(t))||j();break;case"mrd-memo-container":customElements.get(a(t))||C();break;case"mrd-memo-list":customElements.get(a(t))||z();break;case"mrd-memo-view":customElements.get(a(t))||O();break;case"mrd-table":customElements.get(a(t))||M();break;case"mrd-text-field":customElements.get(a(t))||V();break;case"mrd-textarea-field":customElements.get(a(t))||L()}}))};export{B as MrdLayoutSection,R as defineCustomElement}
|
|
1
|
+
import{h as t,proxyCustomElement as e,HTMLElement as r,createEvent as o,Host as i,transformTag as a}from"@stencil/core/internal/client";import{a as s,b as n,r as l,A as d,i as c,e as m,h as u,f as v,g as h}from"./client-layout.js";import{t as y}from"./i18n.js";import{C as f}from"./cell-renderer.js";import{a as p}from"./format.js";import{d as b}from"./mrd-boolean-field2.js";import{d as _}from"./mrd-document-container2.js";import{d as g}from"./mrd-document-list2.js";import{d as w}from"./mrd-document-view2.js";import{d as k}from"./mrd-email-view2.js";import{d as x}from"./mrd-invoice-view2.js";import{d as j}from"./mrd-list-field2.js";import{d as C}from"./mrd-memo-container2.js";import{d as z}from"./mrd-memo-list2.js";import{d as O}from"./mrd-memo-view2.js";import{d as M}from"./mrd-table2.js";import{d as V}from"./mrd-text-field2.js";import{d as L}from"./mrd-textarea-field2.js";function E(t){var e,r,o,i;return t.type===s.RELATED_VIEW?null!==(r=null!==(e=t.relatedClass)&&void 0!==e?e:t.name)&&void 0!==r?r:"":null!==(i=null!==(o=t.dataClass)&&void 0!==o?o:t.name)&&void 0!==i?i:""}function A(t){var e,r,o,i,a;return null!==(a=null!==(o=null!==(e=t.showEmpty)&&void 0!==e?e:null===(r=t.field)||void 0===r?void 0:r.showEmpty)&&void 0!==o?o:null===(i=t.relation)||void 0===i?void 0:i.showEmpty)&&void 0!==a&&a}function I(t,e){var r,o;if(!t.name)return!1;const i=(null!==(r=null==e?void 0:e._links)&&void 0!==r?r:{})[t.name];return!(!(null===(o=null==i?void 0:i.values)||void 0===o?void 0:o.length)&&!(null==i?void 0:i.name))}function P(t){const e=[];for(const r of t)e.push(r),r.items&&e.push(...P(r.items));return e}function T(e,r,o,i){return t("button",{class:"mrd-layout-section__download-link",onClick:()=>r&&e.on.download({href:r,fileName:o})},t("svg",{class:"mrd-layout-section__file-icon",viewBox:"0 0 24 24","aria-hidden":"true"},t("path",{fill:"currentColor",d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13zm-3 8l-3-3 1.41-1.41L10 14.17l4.59-4.58L16 11l-6 6z"})),i)}function $(e,r,o){var i,a,s,l,d,c,m,u,v,h,p;const b=r.dataType;switch(b){case n.HYPERLINK:{const e=null!==(i=null==o?void 0:o.href)&&void 0!==i?i:o+"",r=null!==(l=null!==(s=null!==(a=null==o?void 0:o.name)&&void 0!==a?a:null==o?void 0:o.text)&&void 0!==s?s:null==o?void 0:o.label)&&void 0!==l?l:e;return t("a",{class:"mrd-layout-section__link",href:e,target:"_blank",rel:"noopener noreferrer"},r)}case n.TEXTBLOCK:return t("div",{class:"mrd-layout-section__prose",innerHTML:o+""});case n.LONGTEXT:return t("pre",{class:"mrd-layout-section__pre"},o+"");case n.JSON:return t("pre",{class:"mrd-layout-section__pre",innerHTML:f.formatJson(o)});case n.FILE:{const t=null!==(d=null==o?void 0:o.fileName)&&void 0!==d?d:o+"",r=null!==(c=null==o?void 0:o.href)&&void 0!==c?c:"";return T(e,r,t,t||y("download",e.locale))}case n.IMAGE:{const i=null!==(m=null==o?void 0:o.href)&&void 0!==m?m:"",a=null!==(u=null==o?void 0:o.fileName)&&void 0!==u?u:"",s=e.imagePreviews[r.name];return s?t("button",{class:"mrd-layout-section__image-thumb-btn",onClick:()=>e.on.openImage(s),title:a||void 0},t("img",{class:"mrd-layout-section__image-thumb",src:s,alt:a})):T(e,i,a,a||i)}case n.BOOLEAN:return t("span",{class:"mrd-layout-section__boolean mrd-layout-section__boolean--"+(o?"true":"false")},y(o?"yes":"no",e.locale));case n.LIST:{const e=(null!==(v=r.listItems)&&void 0!==v?v:[]).find((t=>t.key===o+"")),i=null!==(h=null==e?void 0:e.label)&&void 0!==h?h:o+"",a=null==e?void 0:e.color,s=null==e?void 0:e.backgroundColor;return a&&s?t("span",{class:"mrd-layout-section__badge",style:{color:a,backgroundColor:s}},i):a?t("span",{class:"mrd-layout-section__badge-dot-row"},t("span",{class:"mrd-layout-section__badge-dot",style:{backgroundColor:a}}),i):i}case n.SECRET:return o?t("span",{class:"mrd-layout-section__secret-masked"},"••••••••"):null;default:return f.renderValue(b,o,null!==(p=r.listItems)&&void 0!==p?p:[],e.locale)||null}}function D(e,r){var o,i;if(!r.name)return null;const a=e.data[r.name],s=(null!==(o=r.historyEnabled)&&void 0!==o?o:null===(i=r.field)||void 0===i?void 0:i.historyEnabled)&&null!==a&&"object"==typeof a&&"current"in a?a.current:a,l=function(e,r,o){if(null==o||""===o)return null;if(r.multiple&&Array.isArray(o)){if(r.dataType===n.FILE||r.dataType===n.IMAGE)return t("div",{class:"mrd-layout-section__file-list"},o.map(((o,i)=>t("div",{class:"mrd-layout-section__file-list-item",key:i+""},$(e,r,o)))));const i=o.map((t=>$(e,r,t)));return i.every((t=>"string"==typeof t||null==t))?i.filter(Boolean).join(", ")||null:t("span",null,i.map(((e,r)=>t("span",{key:r+""},e,r<i.length-1?", ":""))))}return $(e,r,o)}(e,r,s);return{raw:a,rawValue:s,renderedValue:l,isEmpty:null==l}}function H(t,e){if(e.header)return!0;const r=D(t,e);return!!r&&(!r.isEmpty||A(e))}const N=e(class extends r{constructor(t){super(),!1!==t&&this.__registerHost(),this.mrdNavigate=o(this,"mrdNavigate",7),this.mrdSearch=o(this,"mrdSearch",7),this.mrdDownload=o(this,"mrdDownload",7),this.mrdLoadViewPage=o(this,"mrdLoadViewPage",7),this.mrdLoadImage=o(this,"mrdLoadImage",7),this.mrdAttachments=o(this,"mrdAttachments",7),this.mrdViewAction=o(this,"mrdViewAction",7),this.mrdLoadViewAggregations=o(this,"mrdLoadViewAggregations",7),this.mrdLoadViewDistinct=o(this,"mrdLoadViewDistinct",7),this.mrdViewCheckCapabilities=o(this,"mrdViewCheckCapabilities",7),this.mrdUpdateObject=o(this,"mrdUpdateObject",7),this.mrdDeleteObject=o(this,"mrdDeleteObject",7),this.mrdViewUpload=o(this,"mrdViewUpload",7),this.mrdCreateObject=o(this,"mrdCreateObject",7),this.items=[],this.data={},this.views={},this.links={},this.locale=navigator.language,this.archetypes=[],this.readOnly=!1,this.accessControlEnabled=!0,this.me=null,this.searchQueryMap={},this.searchResultsMap={},this.imagePreviewUrl=null,this.imagePreviews={},this.openHistoryField=null,this.canCreateMap={},this.allowedTypesMap={},this.historyClickOutside=null,this.capabilitiesAsked=new Map,this.searchTimers={},this.handleViewLoadPage=(t,e)=>{t.stopPropagation(),this.mrdLoadViewPage.emit({name:e,page:t.detail.page,sort:t.detail.sort,path:t.detail.path,qs:t.detail.qs})},this.handleSearchInput=(t,e)=>{this.searchQueryMap=Object.assign(Object.assign({},this.searchQueryMap),{[t]:e}),this.searchTimers[t]&&clearTimeout(this.searchTimers[t]),e.length<2?this.searchResultsMap=Object.assign(Object.assign({},this.searchResultsMap),{[t]:[]}):this.searchTimers[t]=setTimeout((()=>{this.mrdSearch.emit({query:e,dataClass:t})}),300)}}componentDidLoad(){this.emitCapabilitiesChecks(),setTimeout((()=>{this.initEmbeddedTables(),this.emitLoadImages()}),0),this.historyClickOutside=t=>{this.el.contains(t.target)||(this.openHistoryField=null)},document.addEventListener("mousedown",this.historyClickOutside)}disconnectedCallback(){this.historyClickOutside&&(document.removeEventListener("mousedown",this.historyClickOutside),this.historyClickOutside=null)}dataChanged(t){t&&Object.keys(t).length>0&&(this.emitCapabilitiesChecks(),setTimeout((()=>this.initEmbeddedTables()),0))}itemsChanged(){this.emitCapabilitiesChecks()}async initEmbeddedTables(){const t=this.el.querySelectorAll("mrd-table[data-view]");for(const e of Array.from(t))"function"==typeof e.init&&await e.init();const e=this.el.querySelectorAll("mrd-memo-list[data-view]");for(const t of Array.from(e))"function"==typeof t.init&&await t.init()}emitLoadImages(){for(const t of P(this.items))if(t.type===s.FIELD&&t.dataType===n.IMAGE){const e=t.name,r=this.data[e],o=null==r?void 0:r.href;o&&this.mrdLoadImage.emit({fieldName:e,href:o})}}computeParentId(){var t,e,r,o,i;return null!==(i=(null!==(o=null===(r=null===(e=null===(t=this.data)||void 0===t?void 0:t._links)||void 0===e?void 0:e.self)||void 0===r?void 0:r.href)&&void 0!==o?o:"").split("/").filter(Boolean).pop())&&void 0!==i?i:""}emitCapabilitiesChecks(){var t,e,r,o;if(!this.accessControlEnabled)return;const i=this.computeParentId();for(const a of P(this.items)){if(a.type!==s.VIEW&&a.type!==s.RELATED_VIEW)continue;const n=E(a);if(!n||!a.view)continue;const l=a.type===s.RELATED_VIEW,d=null!==(e=null!==(t=a.dataClass)&&void 0!==t?t:a.relatedClass)&&void 0!==e?e:n,c=l?null!==(r=a.fromClass)&&void 0!==r?r:"":void 0,m=l?i:void 0,u=null!==(o=a.filterClass)&&void 0!==o?o:void 0;if(l&&!m)continue;const v=JSON.stringify([d,c,m,u]);if(this.capabilitiesAsked.get(n)!==v){if(this.capabilitiesAsked.set(n,v),n in this.canCreateMap){const t=Object.assign({},this.canCreateMap);delete t[n],this.canCreateMap=t}if(n in this.allowedTypesMap){const t=Object.assign({},this.allowedTypesMap);delete t[n],this.allowedTypesMap=t}this.mrdViewCheckCapabilities.emit(Object.assign(Object.assign({name:n,type:d},void 0!==c?{refType:c,refId:m}:{}),u?{filterClass:u}:{}))}}}async setSearchResults(t,e){const r=null!=e?e:this.resolveSearchKey();r&&(this.searchResultsMap=Object.assign(Object.assign({},this.searchResultsMap),{[r]:t}))}async setViewPage(t,e,r,o,i,a){if(a){const e=this.el.querySelector(`mrd-document-list[data-doclist="${t}"]`);return void((null==e?void 0:e.setDocuments)&&await e.setDocuments(a,r))}const s=this.el.querySelector(`mrd-table[data-view="${t}"]`);if(s)return void 0!==o&&(s.totalElements=o),void await s.setPage(e,r,i);const n=this.el.querySelector(`mrd-memo-list[data-view="${t}"]`);n&&await n.setPage(e,r,i)}async setViewAggregations(t,e){const r=this.el.querySelector(`mrd-table[data-view="${t}"]`);r&&await r.setAggregations(e)}async setViewCanCreate(t,e,r){this.canCreateMap=Object.assign(Object.assign({},this.canCreateMap),{[t]:e}),this.allowedTypesMap=Object.assign(Object.assign({},this.allowedTypesMap),{[t]:r})}effectiveCanCreate(t){var e;return!this.accessControlEnabled||null!==(e=this.canCreateMap[t])&&void 0!==e&&e}effectiveAllowedTypes(t){return this.accessControlEnabled?this.allowedTypesMap[t]:void 0}async setViewDistinct(t,e,r){const o=this.el.querySelector(`mrd-document-list[data-doclist="${t}"]`);(null==o?void 0:o.setDistinct)&&await o.setDistinct(e,r)}async setViewFileReference(t,e){const r=this.el.querySelector(`mrd-document-list[data-doclist="${t}"]`);(null==r?void 0:r.setFileReference)&&await r.setFileReference(e)}async setViewCreatedObject(t,e){const r=this.el.querySelector(`mrd-document-list[data-doclist="${t}"]`);if(null==r?void 0:r.setCreatedHref)return void await r.setCreatedHref(e);const o=this.el.querySelector(`mrd-memo-container[data-view="${t}"]`);(null==o?void 0:o.refresh)&&await o.refresh()}async setImagePreview(t,e){this.imagePreviews=Object.assign(Object.assign({},this.imagePreviews),{[t]:e})}async openImagePreview(t){this.imagePreviewUrl=t}resolveSearchKey(){var t;const e=P(this.items).filter((t=>t.type===s.SEARCH));return 1===e.length&&null!==(t=e[0].dataClass)&&void 0!==t?t:null}fieldCtx(){return{locale:this.locale,data:this.data,imagePreviews:this.imagePreviews,openHistoryField:this.openHistoryField,on:{download:t=>this.mrdDownload.emit(t),openImage:t=>{this.imagePreviewUrl=t},toggleHistory:t=>{this.openHistoryField=t}}}}renderField(e){return function(e,r){const o=D(e,r);if(!o)return null;const{raw:i,rawValue:a,renderedValue:s,isEmpty:l}=o;return r.header?t("h1",{class:"mrd-layout-section__field-header",key:r.name},"string"==typeof s?s:null!=a?a+"":r.label):l&&!A(r)?null:t("div",{class:`mrd-layout-section__field${r.dataType===n.TEXTBLOCK||r.dataType===n.LONGTEXT||r.dataType===n.JSON?" mrd-layout-section__field--block":""}${l?" mrd-layout-section__field--empty":""}`,key:r.name},t("span",{class:"mrd-layout-section__field-label"},r.label),t("span",{class:"mrd-layout-section__field-value"},l?y("value_empty",e.locale):s,function(e,r,o){var i,a,s;if(!(null!==(i=r.historyEnabled)&&void 0!==i?i:null===(a=r.field)||void 0===a?void 0:a.historyEnabled)||!r.name)return null;const n=null!==(s=null==o?void 0:o.history)&&void 0!==s?s:[];if(!n.length)return null;const l=[...n].sort(((t,e)=>e.until.localeCompare(t.until))),d=e.openHistoryField===r.name;return t("span",{class:"mrd-layout-section__history-wrap"},t("button",{type:"button",class:"mrd-layout-section__history-btn",title:y("history_badge_tooltip",e.locale),"aria-label":y("history_badge_tooltip",e.locale),onClick:t=>{t.stopPropagation(),e.on.toggleHistory(d?null:r.name)}},t("svg",{class:"mrd-layout-section__history-icon",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},t("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"}))),d&&t("div",{class:"mrd-layout-section__history-popover",role:"listbox"},l.map(((r,o)=>t("div",{key:o+"",class:"mrd-layout-section__history-entry"},r.value," (",y("history_until",e.locale)," ",p(r.until,e.locale),")")))))}(e,r,i)))}(this.fieldCtx(),e)}renderRelation(e){var r,o,i;if(!e.name)return null;const a=(null!==(o=null===(r=this.data)||void 0===r?void 0:r._links)&&void 0!==o?o:{})[e.name],s=(e,r)=>t("button",{key:e,class:"mrd-layout-section__relation-link",onClick:()=>this.mrdNavigate.emit({href:e,label:r})},r);let n;(null===(i=null==a?void 0:a.values)||void 0===i?void 0:i.length)?n=a.values.map((t=>s(t.href,t.name))):(null==a?void 0:a.name)&&(n=s(a.href,a.name));const l=!I(e,this.data);return l&&!A(e)?null:t("div",{class:"mrd-layout-section__field"+(l?" mrd-layout-section__field--empty":""),key:e.name},t("span",{class:"mrd-layout-section__field-label"},e.label),t("span",{class:"mrd-layout-section__field-value"},l?y("value_empty",this.locale):n))}renderSearch(e){var r,o,i;if(!e.dataClass)return null;const a=e.dataClass,s=null!==(r=this.searchQueryMap[a])&&void 0!==r?r:"",n=null!==(o=this.searchResultsMap[a])&&void 0!==o?o:[];return t("div",{class:"mrd-layout-section__search",key:"search-"+a},t("div",{class:"mrd-layout-section__search-wrap"},t("svg",{class:"mrd-layout-section__search-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},t("path",{"fill-rule":"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z","clip-rule":"evenodd"})),t("input",{class:"mrd-layout-section__search-input",type:"text",value:s,placeholder:null!==(i=e.label)&&void 0!==i?i:"",onInput:t=>this.handleSearchInput(a,t.target.value)})),n.length>0&&t("ul",{class:"mrd-layout-section__search-results"},n.map((e=>t("li",{key:e.id,class:"mrd-layout-section__search-result"},t("button",{class:"mrd-layout-section__search-result-btn",onClick:()=>this.mrdNavigate.emit({href:e.id,label:e.label})},t("span",{class:"mrd-layout-section__search-result-label"},e.label),e.description&&t("span",{class:"mrd-layout-section__search-result-desc"},e.description)))))))}renderRelatedView(e){var r,o,i,a,n,m,u,v,h,y;const f=E(e);if(!f)return null;if(!e.view)return null;const p=null!==(r=e.showTitle)&&void 0!==r&&r,b=null!==(n=null===(a=null===(i=null===(o=this.data)||void 0===o?void 0:o._links)||void 0===i?void 0:i.self)||void 0===a?void 0:a.href)&&void 0!==n?n:"",_=this.computeParentId(),g=l(null!==(m=e.archetypes)&&void 0!==m?m:null===(u=e.view)||void 0===u?void 0:u.archetypes,d),w=g?void 0:l(null!==(v=e.archetypes)&&void 0!==v?v:null===(h=e.view)||void 0===h?void 0:h.archetypes,c),k=function(t,e,r){if(t.type!==s.RELATED_VIEW||!t.fromClass||!r)return"";const o=e.split("/").filter(Boolean);if(o.length<2)return"";const[i,a]=o;return`/${i}/${a}/${t.fromClass}/${r}`}(e,b,_),x=e.type!==s.RELATED_VIEW||e.inverseRelation===(null===(y=null==w?void 0:w.slots)||void 0===y?void 0:y.container),j=x?k:"",C=e.type===s.RELATED_VIEW&&x;return t("div",{class:"mrd-layout-section__related-view",key:"view-"+f},p&&e.label&&t("h3",{class:"mrd-layout-section__related-view-title"},e.label),g&&this.renderDocumentContainer(e,f,_,g,k),w&&this.renderMemoContainer(e,f,_,w,j,x,!C),!g&&!w&&this.renderTable(e,f,_))}renderDocumentContainer(e,r,o,i,a){return t("mrd-document-container",{item:e,archetype:i,parentId:o,containerHref:a,viewKey:r,locale:this.locale,readOnly:this.readOnly,mayCreate:this.effectiveCanCreate(r),onMrdLoadDistinct:t=>{t.stopPropagation(),this.mrdLoadViewDistinct.emit(Object.assign({name:r},t.detail))},onMrdLoadPage:t=>{t.stopPropagation(),this.mrdLoadViewPage.emit(Object.assign({name:r},t.detail))},onMrdLoadAggregations:t=>{var o;t.stopPropagation(),this.mrdLoadViewAggregations.emit(Object.assign({name:r,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r},t.detail))},onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(t.detail)},onMrdAction:t=>{var o;t.stopPropagation(),this.mrdViewAction.emit(Object.assign({name:r,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r},t.detail))},onMrdUpdateObject:t=>{t.stopPropagation(),this.mrdUpdateObject.emit(t.detail)},onMrdUpload:t=>{t.stopPropagation(),this.mrdViewUpload.emit(Object.assign({name:r},t.detail))},onMrdCreateObject:t=>{t.stopPropagation(),this.mrdCreateObject.emit(Object.assign({name:r},t.detail))}})}renderMemoContainer(e,r,o,i,a,s,n){var l,d,c,u;const v=null!==(u=null===(c=null===(d=null===(l=e.view)||void 0===l?void 0:l.values)||void 0===d?void 0:d.find((t=>{var e;return t.name===(null===(e=i.slots)||void 0===e?void 0:e.labels)})))||void 0===c?void 0:c.listItems)&&void 0!==u?u:null;return t("mrd-memo-container",{"data-view":r,item:e,archetype:i,parentId:o,containerHref:a,containerRelated:s,showContainerLink:n,viewKey:r,locale:this.locale,readOnly:this.readOnly,canCreate:this.effectiveCanCreate(r),me:this.me,labelsListItems:v,onMrdNavigate:t=>{var r;t.stopPropagation(),this.mrdNavigate.emit(Object.assign(Object.assign({},t.detail),{navigateBehaviour:null!==(r=e.navigateBehaviour)&&void 0!==r?r:m.PAGE}))},onMrdLoadPage:t=>{t.stopPropagation(),this.mrdLoadViewPage.emit(Object.assign({name:r},t.detail))},onMrdLoadAggregations:t=>{var o;t.stopPropagation(),this.mrdLoadViewAggregations.emit(Object.assign({name:r,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r},t.detail))},onMrdAction:t=>{var o;t.stopPropagation(),this.mrdViewAction.emit(Object.assign({name:r,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r},t.detail))},onMrdCreateObject:t=>{t.stopPropagation(),this.mrdCreateObject.emit(Object.assign({name:r},t.detail))},onMrdUpdateObject:t=>{t.stopPropagation(),this.mrdUpdateObject.emit(t.detail)},onMrdDeleteObject:t=>{t.stopPropagation(),this.mrdDeleteObject.emit(t.detail)}})}renderTable(e,r,o){return t("mrd-table",{"data-view":r,item:e,parentId:o,locale:this.locale,readOnly:this.readOnly,canCreate:this.effectiveCanCreate(r),allowedTypes:this.effectiveAllowedTypes(r),accessControlEnabled:this.accessControlEnabled,onMrdLoadPage:t=>this.handleViewLoadPage(t,r),onMrdLoadAggregations:t=>{var o;t.stopPropagation(),this.mrdLoadViewAggregations.emit(Object.assign({name:r,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r},t.detail))},onMrdRowClick:t=>{var r,o,i,a;t.stopPropagation();const{row:s,listContext:n}=t.detail;this.mrdNavigate.emit({href:null===(o=null===(r=null==s?void 0:s._links)||void 0===r?void 0:r.self)||void 0===o?void 0:o.href,label:null!==(i=null==s?void 0:s.name)&&void 0!==i?i:"",navigateBehaviour:null!==(a=e.navigateBehaviour)&&void 0!==a?a:m.PAGE,listContext:n})},onMrdAction:t=>{var o;t.stopPropagation(),this.mrdViewAction.emit({name:r,action:t.detail.action,dataClass:null!==(o=e.dataClass)&&void 0!==o?o:r,path:t.detail.path,qs:t.detail.qs,parentPath:t.detail.parentPath,basicType:t.detail.basicType})}})}isHeaderBlockEmpty(t,e){const r=this.fieldCtx();for(let o=e+1;o<t.length;o++){const e=t[o];if(e.type===s.HEADER||e.type===s.SECTION||e.type===s.GROUP)break;if(e.type===s.FIELD&&H(r,e))return!1;if(e.type===s.RELATION&&(I(e,this.data)||A(e)))return!1;if(e.type!==s.FIELD&&e.type!==s.RELATION)return!1}return!0}renderItem(e,r=this.items,o=-1){var i,a;switch(e.type){case s.FIELD:return this.renderField(e);case s.RELATION:return this.renderRelation(e);case s.HEADER:return o>=0&&this.isHeaderBlockEmpty(r,o)?null:t("h2",{class:"mrd-layout-section__header",key:"header-"+e.label},e.label);case s.TEXT:return t("div",{class:"mrd-layout-section__text",key:"text-"+e.label,innerHTML:null!==(i=e.label)&&void 0!==i?i:""});case s.NAVIGATE:return t("button",{class:"mrd-layout-section__navigate",key:"nav-"+e.label,onClick:()=>{var t,r,o;return this.mrdNavigate.emit({label:null!==(t=e.label)&&void 0!==t?t:"",navigate:null!==(r=e.navigate)&&void 0!==r?r:{dataClass:null!==(o=e.dataClass)&&void 0!==o?o:"",icon:e.icon,navigationType:e.navigationType}})}},e.label);case s.SEARCH:return this.renderSearch(e);case s.SECTION:case s.GROUP:return t("div",{class:"mrd-layout-section__group",key:"group-"+e.label},e.label&&t("h3",{class:"mrd-layout-section__group-title"},e.label),(null!==(a=e.items)&&void 0!==a?a:[]).map(((t,r)=>{var o;return this.renderItem(t,null!==(o=e.items)&&void 0!==o?o:[],r)})));case s.RELATED_VIEW:case s.VIEW:return this.renderRelatedView(e);default:return null}}renderImageModal(){return this.imagePreviewUrl?t("div",{class:"mrd-layout-section__modal-backdrop",onClick:()=>{this.imagePreviewUrl=null}},t("div",{class:"mrd-layout-section__modal",onClick:t=>t.stopPropagation()},t("button",{class:"mrd-layout-section__modal-close",onClick:()=>{this.imagePreviewUrl=null}},"✕"),t("img",{class:"mrd-layout-section__modal-image",src:this.imagePreviewUrl,alt:""}))):null}relatedItems(t){return this.items.filter((e=>e!==t&&(e.type===s.VIEW||e.type===s.RELATED_VIEW||e.type===s.SEARCH)))}renderDocumentObject(e){return[t("mrd-document-view",{archetype:e,data:this.data,locale:this.locale,onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(t.detail)},onMrdDownload:t=>{t.stopPropagation(),this.mrdDownload.emit(t.detail)},onMrdAttachments:t=>{t.stopPropagation(),this.mrdAttachments.emit(t.detail)}}),...this.relatedItems().map((t=>this.renderItem(t)))]}renderInvoiceObject(e){var r,o,i;const a=null!==(r=this.items.find((t=>{var e,r;return(t.type===s.VIEW||t.type===s.RELATED_VIEW)&&!!l(null!==(e=t.archetypes)&&void 0!==e?e:null===(r=t.view)||void 0===r?void 0:r.archetypes,u)})))&&void 0!==r?r:null,n=null!==(i=null===(o=this.items.find((t=>{var r;return t.name===(null===(r=e.slots)||void 0===r?void 0:r.status)})))||void 0===o?void 0:o.listItems)&&void 0!==i?i:null;return[t("mrd-invoice-view",{archetype:e,data:this.data,locale:this.locale,statusListItems:n,onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(t.detail)},onMrdDownload:t=>{t.stopPropagation(),this.mrdDownload.emit(t.detail)},onMrdAttachments:t=>{t.stopPropagation(),this.mrdAttachments.emit(t.detail)}},a&&t("div",{slot:"lines"},this.renderRelatedView(a))),...this.relatedItems(a).map((t=>this.renderItem(t)))]}renderEmailObject(e){return[t("mrd-email-view",{archetype:e,data:this.data,locale:this.locale,onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(t.detail)},onMrdDownload:t=>{t.stopPropagation(),this.mrdDownload.emit(t.detail)},onMrdAttachments:t=>{t.stopPropagation(),this.mrdAttachments.emit(t.detail)}}),...this.relatedItems().map((t=>this.renderItem(t)))]}renderMemoObject(e){var r,o;const i=null!==(o=null===(r=this.items.find((t=>{var r;return t.name===(null===(r=e.slots)||void 0===r?void 0:r.labels)})))||void 0===r?void 0:r.listItems)&&void 0!==o?o:null;return[t("mrd-memo-view",{archetype:e,data:this.data,locale:this.locale,labelsListItems:i,onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(t.detail)}}),...this.relatedItems().map((t=>this.renderItem(t)))]}render(){const e=l(this.archetypes,d),r=e?void 0:l(this.archetypes,v),o=e||r?void 0:l(this.archetypes,h),a=e||r||o?void 0:l(this.archetypes,c),s=e||r||o||a;return t(i,{key:"97351c57865614662e888b3c0278a61d866a74e1"},t("div",{key:"43e8f0fda8fcd3300b879d05ac692ce331c896d5",class:"mrd-layout-section"},e&&this.renderDocumentObject(e),r&&this.renderInvoiceObject(r),o&&this.renderEmailObject(o),a&&this.renderMemoObject(a),!s&&this.items.map(((t,e)=>this.renderItem(t,this.items,e)))),this.renderImageModal())}get el(){return this}static get watchers(){return{data:[{dataChanged:0}],items:[{itemsChanged:0}]}}static get style(){return".sc-mrd-layout-section-h{display:block;width:100%}.mrd-layout-section.sc-mrd-layout-section{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);color:var(--mrd-color-neutral-800)}.mrd-layout-section__field.sc-mrd-layout-section{display:grid;grid-template-columns:200px 1fr;align-items:baseline;gap:0 var(--mrd-space-2);padding:var(--mrd-space-1) 0}.mrd-layout-section__field--block.sc-mrd-layout-section{grid-template-columns:1fr}.mrd-layout-section__field-label.sc-mrd-layout-section{font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-normal);color:var(--mrd-color-neutral-500);padding-top:1px}.mrd-layout-section__field-value.sc-mrd-layout-section{font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-800);word-break:break-word;display:inline-flex;align-items:center;gap:var(--mrd-space-1)}.mrd-layout-section__field--empty.sc-mrd-layout-section .mrd-layout-section__field-value.sc-mrd-layout-section{color:var(--mrd-color-neutral-400);font-weight:var(--mrd-font-weight-normal)}.mrd-layout-section__history-wrap.sc-mrd-layout-section{position:relative;display:inline-flex;align-items:center}.mrd-layout-section__history-btn.sc-mrd-layout-section{display:inline-flex;align-items:center;justify-content:center;width:1.25rem;height:1.25rem;padding:0;background:transparent;border:none;border-radius:var(--mrd-border-radius-sm);color:var(--mrd-color-neutral-400);cursor:pointer;flex-shrink:0;transition:color var(--mrd-transition-fast), background-color var(--mrd-transition-fast)}.mrd-layout-section__history-btn.sc-mrd-layout-section:hover{color:var(--mrd-color-neutral-700);background-color:var(--mrd-color-neutral-100)}.mrd-layout-section__history-btn.sc-mrd-layout-section:focus{outline:none;box-shadow:var(--mrd-shadow-focus)}.mrd-layout-section__history-icon.sc-mrd-layout-section{width:0.875rem;height:0.875rem}.mrd-layout-section__history-popover.sc-mrd-layout-section{position:absolute;top:calc(100% + 0.25rem);left:0;min-width:24rem;max-width:24rem;background-color:var(--mrd-color-white);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-md);box-shadow:var(--mrd-shadow-md);padding:var(--mrd-space-1) 0;z-index:var(--mrd-z-dropdown)}.mrd-layout-section__history-entry.sc-mrd-layout-section{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-normal);color:var(--mrd-color-neutral-700);padding:var(--mrd-space-2) var(--mrd-space-3);line-height:var(--mrd-line-height-normal)}.mrd-layout-section__history-entry.sc-mrd-layout-section:not(:last-child){border-bottom:var(--mrd-border-width) solid var(--mrd-color-neutral-100)}.mrd-layout-section__field-header.sc-mrd-layout-section{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-4) 0;padding:0}.mrd-layout-section__header.sc-mrd-layout-section{font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-neutral-500);letter-spacing:0.01em;margin:var(--mrd-space-5) 0 var(--mrd-space-2) 0;padding:0}.mrd-layout-section__text.sc-mrd-layout-section{font-size:var(--mrd-font-size-base);color:var(--mrd-color-neutral-700);line-height:var(--mrd-line-height-relaxed);margin:var(--mrd-space-2) 0}.mrd-layout-section__navigate.sc-mrd-layout-section{display:inline-flex;align-items:center;gap:var(--mrd-space-2);padding:var(--mrd-space-2) var(--mrd-space-3);background:none;border:1px solid var(--mrd-color-neutral-300);border-radius:var(--mrd-border-radius);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-primary);cursor:pointer;margin:var(--mrd-space-2) 0}.mrd-layout-section__navigate.sc-mrd-layout-section:hover{background-color:var(--mrd-color-primary-light);border-color:var(--mrd-color-primary)}.mrd-layout-section__link.sc-mrd-layout-section{color:var(--mrd-color-primary);text-decoration:none}.mrd-layout-section__link.sc-mrd-layout-section:hover{text-decoration:underline}.mrd-layout-section__relation-link.sc-mrd-layout-section{background:none;border:none;padding:0;font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-primary);cursor:pointer;text-align:left}.mrd-layout-section__relation-link.sc-mrd-layout-section:hover{text-decoration:underline}.mrd-layout-section__download-link.sc-mrd-layout-section{display:inline-flex;align-items:center;gap:var(--mrd-space-1);background:none;border:none;padding:0;font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-primary);cursor:pointer;text-align:left}.mrd-layout-section__download-link.sc-mrd-layout-section:hover{text-decoration:underline;color:var(--mrd-color-primary-dark)}.mrd-layout-section__file-icon.sc-mrd-layout-section{flex-shrink:0;width:1rem;height:1rem}.mrd-layout-section__file-list.sc-mrd-layout-section{display:flex;flex-direction:column;align-items:flex-start;gap:var(--mrd-space-1)}.mrd-layout-section__file-list-item.sc-mrd-layout-section{min-width:0;max-width:100%}.mrd-layout-section__boolean--true.sc-mrd-layout-section{color:var(--mrd-color-success);font-weight:var(--mrd-font-weight-semibold)}.mrd-layout-section__boolean--false.sc-mrd-layout-section{color:var(--mrd-color-neutral-400)}.mrd-layout-section__badge.sc-mrd-layout-section{display:inline-block;font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);padding:2px var(--mrd-space-3);border-radius:10px}.mrd-layout-section__badge-dot-row.sc-mrd-layout-section{display:inline-flex;align-items:center;gap:var(--mrd-space-2)}.mrd-layout-section__badge-dot.sc-mrd-layout-section{display:inline-block;width:10px;height:10px;border-radius:50%;flex-shrink:0}.mrd-layout-section__secret-masked.sc-mrd-layout-section{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);color:var(--mrd-label-color);letter-spacing:0.15em;user-select:none;pointer-events:none}.mrd-layout-section__pre.sc-mrd-layout-section{font-family:var(--mrd-font-family-mono);font-size:var(--mrd-font-size-xs);background-color:var(--mrd-color-neutral-50);border:1px solid var(--mrd-color-neutral-200);border-radius:var(--mrd-border-radius);padding:var(--mrd-space-3);margin:0;max-height:calc(15 * var(--mrd-font-size-xs));overflow-x:auto;overflow-y:auto;white-space:pre-wrap;word-break:break-word}.mrd-layout-section__group.sc-mrd-layout-section{margin:var(--mrd-space-4) 0}.mrd-layout-section__group-title.sc-mrd-layout-section{font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-neutral-500);margin:0 0 var(--mrd-space-2) 0;padding-bottom:0;letter-spacing:0.01em}.mrd-layout-section__related-view.sc-mrd-layout-section{margin:var(--mrd-space-4) 0}.mrd-layout-section__related-view-title.sc-mrd-layout-section{font-size:var(--mrd-font-size-lg);font-weight:var(--mrd-font-weight-semibold);color:var(--mrd-color-neutral-800);margin:0 0 var(--mrd-space-3) 0}.mrd-layout-section__search.sc-mrd-layout-section{position:relative;margin:var(--mrd-space-2) 0}.mrd-layout-section__search-wrap.sc-mrd-layout-section{position:relative}.mrd-layout-section__search-icon.sc-mrd-layout-section{position:absolute;left:var(--mrd-input-padding-x);top:50%;transform:translateY(-50%);width:1rem;height:1rem;color:var(--mrd-color-neutral-400);pointer-events:none}.mrd-layout-section__search-input.sc-mrd-layout-section{display:block;width:100%;height:var(--mrd-input-height);padding:var(--mrd-input-padding-y) var(--mrd-input-padding-x) var(--mrd-input-padding-y) calc(var(--mrd-input-padding-x) + 1rem + var(--mrd-space-2));font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);color:var(--mrd-input-color);background-color:var(--mrd-input-bg);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);outline:none;appearance:none;box-sizing:border-box}.mrd-layout-section__search-input.sc-mrd-layout-section:focus{border-color:var(--mrd-border-color-focus);box-shadow:var(--mrd-shadow-focus)}.mrd-layout-section__search-input.sc-mrd-layout-section::placeholder{color:var(--mrd-input-placeholder-color)}.mrd-layout-section__search-results.sc-mrd-layout-section{position:absolute;top:100%;left:0;right:0;background-color:var(--mrd-color-white);border:1px solid var(--mrd-color-neutral-300);border-top:none;border-radius:0 0 var(--mrd-border-radius) var(--mrd-border-radius);box-shadow:var(--mrd-shadow-sm);z-index:100;max-height:300px;overflow-y:auto;list-style:none;margin:0;padding:var(--mrd-space-1) 0}.mrd-layout-section__search-result.sc-mrd-layout-section{margin:0;padding:0}.mrd-layout-section__search-result-btn.sc-mrd-layout-section{display:flex;flex-direction:column;width:100%;padding:var(--mrd-space-2) var(--mrd-space-3);background:none;border:none;text-align:left;cursor:pointer;font-family:var(--mrd-font-family)}.mrd-layout-section__search-result-btn.sc-mrd-layout-section:hover{background-color:var(--mrd-color-primary-light)}.mrd-layout-section__search-result-label.sc-mrd-layout-section{font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-800)}.mrd-layout-section__search-result-desc.sc-mrd-layout-section{font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500);margin-top:var(--mrd-space-1)}.mrd-layout-section__image-thumb-btn.sc-mrd-layout-section{background:none;border:none;padding:0;cursor:pointer;display:inline-block;border-radius:var(--mrd-border-radius);overflow:hidden;line-height:0}.mrd-layout-section__image-thumb-btn.sc-mrd-layout-section:hover .mrd-layout-section__image-thumb.sc-mrd-layout-section{opacity:0.85}.mrd-layout-section__image-thumb.sc-mrd-layout-section{display:block;max-width:160px;max-height:100px;border-radius:var(--mrd-border-radius);object-fit:cover;transition:opacity 0.15s}.mrd-layout-section__modal-backdrop.sc-mrd-layout-section{position:fixed;inset:0;background:rgba(0, 0, 0, 0.6);z-index:300;display:flex;align-items:center;justify-content:center}.mrd-layout-section__modal.sc-mrd-layout-section{position:relative;background:var(--mrd-color-white);border-radius:var(--mrd-border-radius);padding:var(--mrd-space-3);max-width:min(90vw, 900px);max-height:90vh;display:flex;align-items:center;justify-content:center;box-shadow:var(--mrd-shadow-lg)}.mrd-layout-section__modal-close.sc-mrd-layout-section{position:absolute;top:var(--mrd-space-2);right:var(--mrd-space-2);background:rgba(0, 0, 0, 0.5);border:none;border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;color:var(--mrd-color-white);cursor:pointer;font-size:var(--mrd-font-size-sm);line-height:1;z-index:1}.mrd-layout-section__modal-close.sc-mrd-layout-section:hover{background:rgba(0, 0, 0, 0.8)}.mrd-layout-section__modal-image.sc-mrd-layout-section{display:block;max-width:100%;max-height:calc(90vh - 2rem);border-radius:var(--mrd-border-radius);object-fit:contain}"}},[2,"mrd-layout-section",{items:[16],data:[16],views:[16],links:[16],locale:[1],archetypes:[16],readOnly:[4,"read-only"],accessControlEnabled:[4,"access-control-enabled"],me:[16],searchQueryMap:[32],searchResultsMap:[32],imagePreviewUrl:[32],imagePreviews:[32],openHistoryField:[32],canCreateMap:[32],allowedTypesMap:[32],setSearchResults:[64],setViewPage:[64],setViewAggregations:[64],setViewCanCreate:[64],setViewDistinct:[64],setViewFileReference:[64],setViewCreatedObject:[64],setImagePreview:[64],openImagePreview:[64]},void 0,{data:[{dataChanged:0}],items:[{itemsChanged:0}]}]),B=N,R=function(){"undefined"!=typeof customElements&&["mrd-layout-section","mrd-boolean-field","mrd-document-container","mrd-document-list","mrd-document-view","mrd-email-view","mrd-invoice-view","mrd-list-field","mrd-memo-container","mrd-memo-list","mrd-memo-view","mrd-table","mrd-text-field","mrd-textarea-field"].forEach((t=>{switch(t){case"mrd-layout-section":customElements.get(a(t))||customElements.define(a(t),N);break;case"mrd-boolean-field":customElements.get(a(t))||b();break;case"mrd-document-container":customElements.get(a(t))||_();break;case"mrd-document-list":customElements.get(a(t))||g();break;case"mrd-document-view":customElements.get(a(t))||w();break;case"mrd-email-view":customElements.get(a(t))||k();break;case"mrd-invoice-view":customElements.get(a(t))||x();break;case"mrd-list-field":customElements.get(a(t))||j();break;case"mrd-memo-container":customElements.get(a(t))||C();break;case"mrd-memo-list":customElements.get(a(t))||z();break;case"mrd-memo-view":customElements.get(a(t))||O();break;case"mrd-table":customElements.get(a(t))||M();break;case"mrd-text-field":customElements.get(a(t))||V();break;case"mrd-textarea-field":customElements.get(a(t))||L()}}))};export{B as MrdLayoutSection,R as defineCustomElement}
|