@mmlogic/components 0.5.15 → 0.5.17

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.
Files changed (40) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/mosterdcomponents.cjs.js +1 -1
  3. package/dist/cjs/mrd-boolean-field_28.cjs.entry.js +361 -56
  4. package/dist/collection/collection-manifest.json +2 -2
  5. package/dist/collection/components/documents/mrd-document-container/mrd-document-container.js +31 -4
  6. package/dist/collection/components/form/mrd-field/mrd-field.css +69 -0
  7. package/dist/collection/components/form/mrd-field/mrd-field.js +95 -25
  8. package/dist/collection/components/layout/mrd-layout-section/field-value.js +19 -2
  9. package/dist/collection/components/layout/mrd-layout-section/layout-helpers.js +10 -0
  10. package/dist/collection/components/layout/mrd-layout-section/mrd-layout-section.css +4 -3
  11. package/dist/collection/components/layout/mrd-layout-section/mrd-layout-section.js +174 -17
  12. package/dist/collection/components/memo/mrd-memo-container/mrd-memo-container.js +105 -6
  13. package/dist/collection/components/memo/mrd-memo-list/mrd-memo-list.css +14 -0
  14. package/dist/collection/components/memo/mrd-memo-list/mrd-memo-list.js +50 -2
  15. package/dist/collection/components/table/mrd-table/mrd-table.js +105 -2
  16. package/dist/collection/dev/api.js +17 -0
  17. package/dist/collection/dev/app.js +49 -15
  18. package/dist/collection/dev/example-data.js +15 -1
  19. package/dist/components/mrd-document-container2.js +1 -1
  20. package/dist/components/mrd-field2.js +1 -1
  21. package/dist/components/mrd-layout-section.js +1 -1
  22. package/dist/components/mrd-memo-container2.js +1 -1
  23. package/dist/components/mrd-memo-list2.js +1 -1
  24. package/dist/components/mrd-table2.js +1 -1
  25. package/dist/esm/loader.js +1 -1
  26. package/dist/esm/mosterdcomponents.js +1 -1
  27. package/dist/esm/mrd-boolean-field_28.entry.js +361 -56
  28. package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
  29. package/dist/mosterdcomponents/p-f72668e9.entry.js +3 -0
  30. package/dist/types/components/documents/mrd-document-container/mrd-document-container.d.ts +7 -0
  31. package/dist/types/components/form/mrd-field/mrd-field.d.ts +16 -0
  32. package/dist/types/components/layout/mrd-layout-section/field-value.d.ts +4 -0
  33. package/dist/types/components/layout/mrd-layout-section/layout-helpers.d.ts +3 -0
  34. package/dist/types/components/layout/mrd-layout-section/mrd-layout-section.d.ts +52 -0
  35. package/dist/types/components/memo/mrd-memo-container/mrd-memo-container.d.ts +26 -1
  36. package/dist/types/components/memo/mrd-memo-list/mrd-memo-list.d.ts +12 -0
  37. package/dist/types/components/table/mrd-table/mrd-table.d.ts +45 -0
  38. package/dist/types/components.d.ts +92 -0
  39. package/package.json +1 -1
  40. package/dist/mosterdcomponents/p-d64ba1f2.entry.js +0 -3
@@ -37,6 +37,11 @@ export class MrdMemoList {
37
37
  /** listItems of the FIELD bound to the `labels` slot, resolved by mrd-layout-section
38
38
  * from its own items array, same reason mrd-memo-view needs it. */
39
39
  this.labelsListItems = null;
40
+ /** False when the list is already scoped to its own container (a company's own
41
+ * memo tab) — showing "belongs to: <this same company>" on every card there
42
+ * would be redundant. True everywhere else (top-level VIEW, or a RELATED_VIEW
43
+ * scoped by a different relation, e.g. a person's authored-memos list). */
44
+ this.showContainerLink = true;
40
45
  this.rows = [];
41
46
  this.loading = false;
42
47
  this.exhausted = false;
@@ -138,6 +143,14 @@ export class MrdMemoList {
138
143
  return 0;
139
144
  return String(raw).replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim().length;
140
145
  }
146
+ renderContainer(row) {
147
+ if (!this.showContainerLink)
148
+ return null;
149
+ const link = this.slotLink(row, 'container');
150
+ if (!(link === null || link === void 0 ? void 0 : link.href) || !link.name)
151
+ return null;
152
+ return (h("button", { type: "button", class: "mrd-memo-list__card-container", onClick: e => { e.stopPropagation(); this.mrdNavigate.emit({ href: link.href, label: link.name }); } }, link.name));
153
+ }
141
154
  renderLabels(row) {
142
155
  const raw = this.slotValue(row, 'labels');
143
156
  const keys = Array.isArray(raw) ? raw.map(String) : (raw != null && raw !== '' ? [String(raw)] : []);
@@ -182,10 +195,10 @@ export class MrdMemoList {
182
195
  e.preventDefault();
183
196
  this.mrdEdit.emit({ row });
184
197
  }
185
- } }, h("div", { class: "mrd-memo-list__card-header" }, title && h("span", { class: "mrd-memo-list__card-title" }, title), important && (h("span", { class: "mrd-memo-list__card-important", title: t('memo_important', this.locale) }, h("svg", { viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true" }, h("path", { d: "M12 2l2.9 6.26L22 9.27l-5 4.87L18.18 21 12 17.27 5.82 21 7 14.14l-5-4.87 7.1-1.01z" }))))), this.renderBody(row, href), this.renderLabels(row), h("div", { class: "mrd-memo-list__card-meta" }, (author === null || author === void 0 ? void 0 : author.name) && h("span", { class: "mrd-memo-list__card-author" }, author.name), dateRaw != null && dateRaw !== '' && (h("span", { class: "mrd-memo-list__card-date" }, formatDateTime(dateRaw, this.locale))))));
198
+ } }, h("div", { class: "mrd-memo-list__card-header" }, title && h("span", { class: "mrd-memo-list__card-title" }, title), important && (h("span", { class: "mrd-memo-list__card-important", title: t('memo_important', this.locale) }, h("svg", { viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true" }, h("path", { d: "M12 2l2.9 6.26L22 9.27l-5 4.87L18.18 21 12 17.27 5.82 21 7 14.14l-5-4.87 7.1-1.01z" }))))), this.renderBody(row, href), this.renderLabels(row), h("div", { class: "mrd-memo-list__card-meta" }, (author === null || author === void 0 ? void 0 : author.name) && h("span", { class: "mrd-memo-list__card-author" }, author.name), dateRaw != null && dateRaw !== '' && (h("span", { class: "mrd-memo-list__card-date" }, formatDateTime(dateRaw, this.locale)))), this.renderContainer(row)));
186
199
  }
187
200
  render() {
188
- return (h(Host, { key: 'c4c5ce4e96bf2aa754d85b260db8920fdde9311d' }, h("div", { key: '0db49511231edbf946f98734e0bab91cbdf31795', class: "mrd-memo-list" }, this.rows.map((row, i) => this.renderCard(row, i)), this.started && !this.loading && this.rows.length === 0 && (h("div", { key: '2a7a027673d01d63523ce252fe2fbff8ba0515fd', class: "mrd-memo-list__empty" }, t('no_results', this.locale))), !this.exhausted && this.rows.length > 0 && (h("button", { key: '45dfd4a9ccab721d422935c48509d46989c9a360', type: "button", class: "mrd-memo-list__load-more", disabled: this.loading, onClick: this.loadMore }, t('load_more', this.locale))))));
201
+ return (h(Host, { key: '18294fc609b741d38f9933d3ae01d20d6dda5ec5' }, h("div", { key: 'ac6c1adc6575ae1edb2cd507c8ac31b1f28ea35c', class: "mrd-memo-list" }, this.rows.map((row, i) => this.renderCard(row, i)), this.started && !this.loading && this.rows.length === 0 && (h("div", { key: '271281b2e087f8fd55dc51b32b1fe4cce387cdcb', class: "mrd-memo-list__empty" }, t('no_results', this.locale))), !this.exhausted && this.rows.length > 0 && (h("button", { key: '24861c35323d759d69bfd4f358657fe201ca7727', type: "button", class: "mrd-memo-list__load-more", disabled: this.loading, onClick: this.loadMore }, t('load_more', this.locale))))));
189
202
  }
190
203
  static get is() { return "mrd-memo-list"; }
191
204
  static get encapsulation() { return "scoped"; }
@@ -354,6 +367,26 @@ export class MrdMemoList {
354
367
  "getter": false,
355
368
  "setter": false,
356
369
  "defaultValue": "null"
370
+ },
371
+ "showContainerLink": {
372
+ "type": "boolean",
373
+ "mutable": false,
374
+ "complexType": {
375
+ "original": "boolean",
376
+ "resolved": "boolean",
377
+ "references": {}
378
+ },
379
+ "required": false,
380
+ "optional": false,
381
+ "docs": {
382
+ "tags": [],
383
+ "text": "False when the list is already scoped to its own container (a company's own\nmemo tab) \u2014 showing \"belongs to: <this same company>\" on every card there\nwould be redundant. True everywhere else (top-level VIEW, or a RELATED_VIEW\nscoped by a different relation, e.g. a person's authored-memos list)."
384
+ },
385
+ "getter": false,
386
+ "setter": false,
387
+ "reflect": false,
388
+ "attribute": "show-container-link",
389
+ "defaultValue": "true"
357
390
  }
358
391
  };
359
392
  }
@@ -402,6 +435,21 @@ export class MrdMemoList {
402
435
  }
403
436
  }
404
437
  }
438
+ }, {
439
+ "method": "mrdNavigate",
440
+ "name": "mrdNavigate",
441
+ "bubbles": true,
442
+ "cancelable": true,
443
+ "composed": true,
444
+ "docs": {
445
+ "tags": [],
446
+ "text": "The container link on a card was clicked \u2014 this is real navigation (to the\ncontainer record), unrelated to mrdEdit."
447
+ },
448
+ "complexType": {
449
+ "original": "{ href?: string; label: string }",
450
+ "resolved": "{ href?: string | undefined; label: string; }",
451
+ "references": {}
452
+ }
405
453
  }];
406
454
  }
407
455
  static get methods() {
@@ -120,6 +120,10 @@ export class MrdTable {
120
120
  this.aggregationsPending = false;
121
121
  /** Lower bound on total derived from setPage() hasNext info; grows as pages load. */
122
122
  this.minKnownTotal = 0;
123
+ /** Self-asked answer for standalone use (the `canCreate` prop is undefined) — defaults to
124
+ * hidden (TASK-0299) until the host answers mrdCheckCapabilities via setCanCreate(). Ignored
125
+ * when the host controls `canCreate` directly; see effectiveCanCreate(). */
126
+ this.selfCanCreate = false;
123
127
  this.handleScroll = (e) => {
124
128
  const scroller = e.currentTarget;
125
129
  const { renderStart, renderEnd } = computeWindow(scroller.scrollTop, this.rowHeight, this.tableHeight, this.baseTotal);
@@ -154,6 +158,14 @@ export class MrdTable {
154
158
  this.searchOpen = false;
155
159
  this.searchQuery = '';
156
160
  this.stashedFilters = null;
161
+ this.emitCapabilitiesCheck();
162
+ }
163
+ /** A parent-record navigation can reuse the same `item` reference while only `parentId`
164
+ * changes (e.g. clicking a different dossier for the same RELATED_VIEW layout) — itemChanged()
165
+ * would not fire for that. Re-ask so a stale canCreate answer from the previous parent never
166
+ * leaks into the new one. */
167
+ parentIdChanged() {
168
+ this.emitCapabilitiesCheck();
157
169
  }
158
170
  // ── Lifecycle ──────────────────────────────────────────────────────────────
159
171
  componentWillLoad() {
@@ -161,6 +173,7 @@ export class MrdTable {
161
173
  this.applyDefaultSort((_c = (_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.view) === null || _b === void 0 ? void 0 : _b.defaultSort) !== null && _c !== void 0 ? _c : '');
162
174
  }
163
175
  componentDidLoad() {
176
+ this.emitCapabilitiesCheck();
164
177
  this.staleCheckTimer = setInterval(() => this.checkStalePages(), STALE_CHECK_INTERVAL_MS);
165
178
  // A table inside a hidden tab pane renders and loads page 0 without ever having a box, so
166
179
  // the width freeze cannot measure anything. ResizeObserver fires the moment the pane is
@@ -279,6 +292,14 @@ export class MrdTable {
279
292
  // Fresh totals can be wider than the ones the columns were checked against.
280
293
  this.fixedContentMeasured = false;
281
294
  }
295
+ /** Host answer to mrdCheckCapabilities — whether the current user may create a record for
296
+ * the table's currently bound route (standalone use only; ignored while the `canCreate`
297
+ * prop is set, since the host controls it directly in that mode). Call it any time after
298
+ * the event fires; a stale answer for an old binding is discarded automatically
299
+ * (selfCanCreate is reset to false before every new mrdCheckCapabilities emission). */
300
+ async setCanCreate(value) {
301
+ this.selfCanCreate = value;
302
+ }
282
303
  // ── Lifecycle ──────────────────────────────────────────────────────────────
283
304
  disconnectedCallback() {
284
305
  if (this.resizeObserver) {
@@ -638,6 +659,22 @@ export class MrdTable {
638
659
  dataClass: v.dataClass,
639
660
  });
640
661
  }
662
+ /** Asks the host whether creating is allowed for the table's current binding (item, parent
663
+ * and active view) — only in standalone use (`canCreate` prop undefined). A host that
664
+ * controls `canCreate` directly already knows the answer, so the table never asks on its
665
+ * own in that mode. Resets selfCanCreate to false first so the add button stays hidden for
666
+ * the new binding until the host answers — it never inherits the previous binding's answer. */
667
+ emitCapabilitiesCheck() {
668
+ var _a, _b;
669
+ if (this.canCreate !== undefined)
670
+ return;
671
+ this.selfCanCreate = false;
672
+ const v = this.allViews[this.activeViewIdx];
673
+ if (!(v === null || v === void 0 ? void 0 : v.dataClass))
674
+ return;
675
+ const isRelatedView = ((_a = this.item) === null || _a === void 0 ? void 0 : _a.type) === 'RELATED_VIEW';
676
+ 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
+ }
641
678
  /** Build query params for a page request from current sort, view filters, filterClass and active column filters.
642
679
  *
643
680
  * `q` and column filters are mutually exclusive on the backend — combining them breaks
@@ -672,11 +709,17 @@ export class MrdTable {
672
709
  var _a, _b, _c;
673
710
  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 : []);
674
711
  }
712
+ /** `canCreate` when the host controls it directly, else the table's own self-asked answer. */
713
+ get effectiveCanCreate() {
714
+ return this.canCreate !== undefined ? this.canCreate : this.selfCanCreate;
715
+ }
675
716
  get tableActions() {
676
717
  var _a, _b;
677
718
  const raw = (_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.actions) !== null && _b !== void 0 ? _b : [];
678
719
  return (raw !== null && raw !== void 0 ? raw : []).reduce((acc, a) => {
679
- if (a === 'NEW')
720
+ // Hidden (not just disabled) until creating is confirmed allowed for this binding —
721
+ // see effectiveCanCreate() / emitCapabilitiesCheck() (TASK-0299).
722
+ if (a === 'NEW' && this.effectiveCanCreate)
680
723
  acc.push({ action: 'create', label: t('table_new_record', this.locale), icon: 'assets/sprites.svg#icon-plus', variant: 'primary', disabled: this.readOnly });
681
724
  if (a === 'EXPORT')
682
725
  acc.push({ action: 'export', label: t('table_export_excel', this.locale), icon: 'assets/sprites.svg#icon-file-excel' });
@@ -1084,6 +1127,7 @@ export class MrdTable {
1084
1127
  this.searchOpen = false;
1085
1128
  this.searchQuery = '';
1086
1129
  this.stashedFilters = null;
1130
+ this.emitCapabilitiesCheck();
1087
1131
  this.init();
1088
1132
  }
1089
1133
  toggleViewPopover(e) {
@@ -1475,6 +1519,25 @@ export class MrdTable {
1475
1519
  "reflect": false,
1476
1520
  "attribute": "read-only",
1477
1521
  "defaultValue": "false"
1522
+ },
1523
+ "canCreate": {
1524
+ "type": "boolean",
1525
+ "mutable": false,
1526
+ "complexType": {
1527
+ "original": "boolean",
1528
+ "resolved": "boolean | undefined",
1529
+ "references": {}
1530
+ },
1531
+ "required": false,
1532
+ "optional": true,
1533
+ "docs": {
1534
+ "tags": [],
1535
+ "text": "Whether the current user may create a record for the table's bound route. Leave\n`undefined` for standalone use \u2014 the table then asks on its own via mrdCheckCapabilities\nand hides the create button until setCanCreate() answers. Set it explicitly when a host\nalready knows the answer (e.g. mrd-layout-section, which asks once per binding and hands\nthe answer to whichever body it mounts) \u2014 the table then trusts it directly and never\nasks on its own (TASK-0299)."
1536
+ },
1537
+ "getter": false,
1538
+ "setter": false,
1539
+ "reflect": false,
1540
+ "attribute": "can-create"
1478
1541
  }
1479
1542
  };
1480
1543
  }
@@ -1503,7 +1566,8 @@ export class MrdTable {
1503
1566
  "jsonModal": {},
1504
1567
  "aggregations": {},
1505
1568
  "aggregationsTotal": {},
1506
- "minKnownTotal": {}
1569
+ "minKnownTotal": {},
1570
+ "selfCanCreate": {}
1507
1571
  };
1508
1572
  }
1509
1573
  static get events() {
@@ -1608,6 +1672,21 @@ export class MrdTable {
1608
1672
  "resolved": "{ path: string; qs: string; aggQs: string; }",
1609
1673
  "references": {}
1610
1674
  }
1675
+ }, {
1676
+ "method": "mrdCheckCapabilities",
1677
+ "name": "mrdCheckCapabilities",
1678
+ "bubbles": true,
1679
+ "cancelable": true,
1680
+ "composed": true,
1681
+ "docs": {
1682
+ "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)."
1684
+ },
1685
+ "complexType": {
1686
+ "original": "{ type: string; refType?: string; refId?: string; filterClass?: string }",
1687
+ "resolved": "{ type: string; refType?: string | undefined; refId?: string | undefined; filterClass?: string | undefined; }",
1688
+ "references": {}
1689
+ }
1611
1690
  }];
1612
1691
  }
1613
1692
  static get methods() {
@@ -1692,6 +1771,27 @@ export class MrdTable {
1692
1771
  "text": "Inject aggregation totals returned by the /aggregations endpoint.",
1693
1772
  "tags": []
1694
1773
  }
1774
+ },
1775
+ "setCanCreate": {
1776
+ "complexType": {
1777
+ "signature": "(value: boolean) => Promise<void>",
1778
+ "parameters": [{
1779
+ "name": "value",
1780
+ "type": "boolean",
1781
+ "docs": ""
1782
+ }],
1783
+ "references": {
1784
+ "Promise": {
1785
+ "location": "global",
1786
+ "id": "global::Promise"
1787
+ }
1788
+ },
1789
+ "return": "Promise<void>"
1790
+ },
1791
+ "docs": {
1792
+ "text": "Host answer to mrdCheckCapabilities \u2014 whether the current user may create a record for\nthe table's currently bound route (standalone use only; ignored while the `canCreate`\nprop is set, since the host controls it directly in that mode). Call it any time after\nthe event fires; a stale answer for an old binding is discarded automatically\n(selfCanCreate is reset to false before every new mrdCheckCapabilities emission).",
1793
+ "tags": []
1794
+ }
1695
1795
  }
1696
1796
  };
1697
1797
  }
@@ -1703,6 +1803,9 @@ export class MrdTable {
1703
1803
  }, {
1704
1804
  "propName": "item",
1705
1805
  "methodName": "itemChanged"
1806
+ }, {
1807
+ "propName": "parentId",
1808
+ "methodName": "parentIdChanged"
1706
1809
  }];
1707
1810
  }
1708
1811
  }
@@ -108,6 +108,23 @@ async function apiFetchPage(token, baseHref, pageNumber, sort = '') {
108
108
  return body; // { _embedded, _links, page }
109
109
  }
110
110
 
111
+ /** Answers mrdCheckCapabilities/mrdViewCheckCapabilities (TASK-0299): same route/path
112
+ * variables the table already fetches its rows from, `/capabilities` appended.
113
+ * VIEW: GET /data/{tenant}/{type}/capabilities
114
+ * RELATED_VIEW: GET /data/{tenant}/{refType}/{refId}/{type}/capabilities
115
+ * `filterClass`, when the view declares one, is appended the same way the row fetch
116
+ * sends it — `?type={filterClass}` — so a "contents" view filtered to `document` asks
117
+ * specifically whether a document may be created here. */
118
+ async function apiFetchCapabilities(token, baseHref, refType, refId, type, filterClass) {
119
+ const path = refType
120
+ ? `${baseHref}/${refType}/${refId}/${type}/capabilities`
121
+ : `${baseHref}/${type}/capabilities`;
122
+ const url = filterClass ? `${path}?type=${encodeURIComponent(filterClass)}` : path;
123
+ const { ok, status, body } = await apiRequest('GET', url, token);
124
+ if (!ok) throw new Error(`${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
125
+ return body; // { mayCreate }
126
+ }
127
+
111
128
  async function apiSubmitForm(token, tenantCode, pluralName, values) {
112
129
  const { status, ok, body } = await apiWriteAndFetch('POST', `/data/${tenantCode}/${pluralName}`, token, values);
113
130
  return { status, ok, body };
@@ -16,6 +16,7 @@ let _navHistory = []; // stack van { dashboardData, dashboardRecord,
16
16
  let _meUser = null; // { id: href, label: name } — resolved once after login via /accounts/me
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
+ let _detailCanCreate = true; // Detail View tab: mock answer to mrdViewCheckCapabilities (TASK-0299 demo)
19
20
 
20
21
  /* =====================================================================
21
22
  UTILITIES
@@ -193,6 +194,16 @@ function showCompanyDetail(row) {
193
194
  await section.setViewPage(name, page, mockRows, mockRows.length);
194
195
  });
195
196
 
197
+ // TASK-0299: mock answer so the "Share classes" tab's add button shows up
198
+ // (its layout item declares actions: ['NEW', 'EXPORT']) — a real host would
199
+ // call apiFetchCapabilities() instead, as the Live API tab does below.
200
+ // _detailCanCreate is toggleable (see onDetailViewCanCreateToggle) so both the
201
+ // hidden and visible states can be demonstrated without a live backend.
202
+ section.addEventListener('mrdViewCheckCapabilities', async (e) => {
203
+ logEvent('mrdViewCheckCapabilities', e.detail);
204
+ await section.setViewCanCreate(e.detail.name, _detailCanCreate);
205
+ });
206
+
196
207
  wrapper.appendChild(section);
197
208
  container.appendChild(wrapper);
198
209
  });
@@ -214,6 +225,16 @@ function onDetailViewReadOnlyToggle(checked) {
214
225
  });
215
226
  }
216
227
 
228
+ /** canCreate demo (TASK-0299): flips the mock answer to mrdViewCheckCapabilities and
229
+ * re-applies it to any already-rendered "Share classes" table via setViewCanCreate() —
230
+ * no re-fetch, so the add button appears/disappears immediately. */
231
+ function onDetailViewCanCreateToggle(checked) {
232
+ _detailCanCreate = checked;
233
+ document.querySelectorAll('#detail-sections mrd-layout-section').forEach((section) => {
234
+ section.setViewCanCreate('shareClasses', checked);
235
+ });
236
+ }
237
+
217
238
  /* =====================================================================
218
239
  DOCUMENT PREVIEW TAB
219
240
  ===================================================================== */
@@ -567,6 +588,21 @@ async function renderSection(index) {
567
588
  }
568
589
  });
569
590
 
591
+ // TASK-0299: the table's add button stays hidden until this answers — real call
592
+ // against GET /data/{tenant}/{refType}/{refId}/{type}/capabilities (or the top-level
593
+ // /{type}/capabilities form for a VIEW without a parent).
594
+ section.addEventListener('mrdViewCheckCapabilities', async (e) => {
595
+ if (generation !== _sectionGeneration) return;
596
+ const { name, type, refType, refId, filterClass } = e.detail;
597
+ logEvent('mrdViewCheckCapabilities', e.detail);
598
+ try {
599
+ const result = await apiFetchCapabilities(authGetToken(), _baseHref, refType, refId, type, filterClass);
600
+ await section.setViewCanCreate(name, !!result?.mayCreate);
601
+ } catch (err) {
602
+ console.error('[mrdViewCheckCapabilities] mislukt', name, err);
603
+ }
604
+ });
605
+
570
606
  section.addEventListener('mrdNavigate', async (e) => {
571
607
  if (generation !== _sectionGeneration) return;
572
608
  await handleNavigate(e.detail);
@@ -1173,8 +1209,20 @@ customElements.whenDefined('mrd-form').then(() => {
1173
1209
  form.values = window.EXAMPLE_VALUES;
1174
1210
 
1175
1211
  form.addEventListener('mrdSubmit', (e) => { console.log('[mrdSubmit]', e.detail); logEvent('mrdSubmit', e.detail); });
1176
- form.addEventListener('mrdSearch', (e) => { console.log('[mrdSearch]', e.detail); logEvent('mrdSearch', e.detail); });
1177
1212
  form.addEventListener('mrdFetchAll', (e) => { console.log('[mrdFetchAll]', e.detail); logEvent('mrdFetchAll', e.detail); });
1213
+
1214
+ // No live API backs this tab, so simulate the "Employee" lookup behind the
1215
+ // required projectManager SEARCH relation against EXAMPLE_EMPLOYEES —
1216
+ // mirrors the live-API tab's mrdSearch handler further down this file.
1217
+ form.addEventListener('mrdSearch', (e) => {
1218
+ console.log('[mrdSearch]', e.detail);
1219
+ logEvent('mrdSearch', e.detail);
1220
+ const { name, query } = e.detail;
1221
+ if (!query || query.length < 2) return;
1222
+ const mock = window.EXAMPLE_EMPLOYEES.filter(r => r.label.toLowerCase().includes(query.toLowerCase()));
1223
+ const host = Array.from(form.querySelectorAll('mrd-relation-field')).find(el => el.name === name);
1224
+ if (host && typeof host.setSearchResults === 'function') host.setSearchResults(mock);
1225
+ });
1178
1226
  });
1179
1227
 
1180
1228
  /* =====================================================================
@@ -1229,20 +1277,6 @@ function initLocaleControl() {
1229
1277
 
1230
1278
  initLocaleControl();
1231
1279
 
1232
- document.getElementById('btn-inject-results').addEventListener('click', () => {
1233
- const relationField = document.querySelector('mrd-relation-field');
1234
- if (relationField && typeof relationField.setSearchResults === 'function') {
1235
- relationField.setSearchResults([
1236
- { id: '1', label: 'Alice Johnson', description: 'Senior Engineer' },
1237
- { id: '2', label: 'Bob van der Berg', description: 'Product Manager' },
1238
- { id: '3', label: 'Carol Martínez', description: 'UX Designer' },
1239
- { id: '4', label: 'David Müller', description: 'DevOps Lead' },
1240
- ]);
1241
- } else {
1242
- logEvent('info', 'Type 2+ chars in the Project Manager field first, then click this');
1243
- }
1244
- });
1245
-
1246
1280
  /* =====================================================================
1247
1281
  BOOT
1248
1282
  ===================================================================== */
@@ -52,7 +52,10 @@ window.EXAMPLE_LAYOUT = {
52
52
  label: "Contact & Links",
53
53
  items: [
54
54
  { type: "FIELD", name: "contactEmail", label: "Contact Email", dataType: "EMAIL", required: true, placeholder: "project@company.com" },
55
- { type: "FIELD", name: "repositoryUrl", label: "Repository URL", dataType: "HYPERLINK", required: false, placeholder: "https://github.com/..." }
55
+ { type: "FIELD", name: "repositoryUrl", label: "Repository URL", dataType: "HYPERLINK", required: false, placeholder: "https://github.com/..." },
56
+ // multiple on a scalar dataType (TASK-0274): mrd-field renders a
57
+ // repeatable row per array entry instead of a single input.
58
+ { type: "FIELD", name: "stakeholderEmails", label: "Stakeholder Emails (multiple)", dataType: "EMAIL", required: false, multiple: true, placeholder: "name@company.com" }
56
59
  ]
57
60
  },
58
61
  {
@@ -92,6 +95,7 @@ window.EXAMPLE_VALUES = {
92
95
  isPublic: true,
93
96
  startDate: "2026-01-15",
94
97
  contactEmail: "team@mosterd.nl",
98
+ stakeholderEmails: ["sponsor@acme.com", "steering-committee@acme.com"],
95
99
  // FILE/IMAGE values from the API are { href, fileName } — same shape as everywhere
96
100
  // else in this library (mrd-table, mrd-document-view) — so the field shows the real
97
101
  // filename instead of the href's UUID.
@@ -102,6 +106,16 @@ window.EXAMPLE_VALUES = {
102
106
  ],
103
107
  };
104
108
 
109
+ /** Mock "database" behind the Embedded Form tab's `projectManager` SEARCH
110
+ * relation — there is no live API there, so app.js filters this list itself
111
+ * in response to mrdSearch and feeds it back via setSearchResults(). */
112
+ window.EXAMPLE_EMPLOYEES = [
113
+ { id: '/data/demo/employees/1', label: 'Alice Johnson', description: 'Senior Engineer' },
114
+ { id: '/data/demo/employees/2', label: 'Bob van der Berg', description: 'Product Manager' },
115
+ { id: '/data/demo/employees/3', label: 'Carol Martínez', description: 'UX Designer' },
116
+ { id: '/data/demo/employees/4', label: 'David Müller', description: 'DevOps Lead' },
117
+ ];
118
+
105
119
  // ─── Companies detail view demo ────────────────────────────────────────────────
106
120
 
107
121
  /** Column definitions for the companies list table. */
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as r,createEvent as e,h as o,Host as i,transformTag as n}from"@stencil/core/internal/client";import{e as d}from"./client-layout.js";import{t as s}from"./i18n.js";import{a}from"./document-attachments.js";import{d as c}from"./mrd-document-list2.js";import{d as l}from"./mrd-table2.js";const m=t(class extends r{constructor(t){super(),!1!==t&&this.__registerHost(),this.mrdLoadPage=e(this,"mrdLoadPage",7),this.mrdLoadDistinct=e(this,"mrdLoadDistinct",7),this.mrdLoadAggregations=e(this,"mrdLoadAggregations",7),this.mrdNavigate=e(this,"mrdNavigate",7),this.mrdAction=e(this,"mrdAction",7),this.mrdUpdateObject=e(this,"mrdUpdateObject",7),this.mrdUpload=e(this,"mrdUpload",7),this.mrdCreateObject=e(this,"mrdCreateObject",7),this.item=null,this.parentId="",this.containerHref="",this.viewKey="",this.height=460,this.locale=navigator.language,this.readOnly=!1,this.mode="tree",this.canCreate=!1,this.targetLabel="",this.tableInited=!1,this.createFolder=()=>{var t;null===(t=this.listEl)||void 0===t||t.createFolder()},this.pickFile=()=>{var t;this.readOnly||null===(t=this.fileInputEl)||void 0===t||t.click()},this.onFilePicked=t=>{var r,e;const o=t.target,i=null===(r=o.files)||void 0===r?void 0:r[0];i&&(null===(e=this.listEl)||void 0===e||e.uploadFile(i)),o.value=""}}componentDidRender(){var t;if("list"===this.mode&&this.tableEl&&!this.tableInited){this.tableInited=!0;const r=this.tableEl;Promise.resolve(null===(t=r.componentOnReady)||void 0===t?void 0:t.call(r)).then((()=>r.init()))}}setMode(t){t!==this.mode&&(this.canCreate=!1,this.tableInited=!1,this.mode=t)}renderToolbar(){return o("div",{class:"mrd-document-container__toolbar"},"tree"===this.mode&&o("button",{type:"button",class:"mrd-document-container__action",disabled:this.readOnly||!this.canCreate,title:this.readOnly?s("readonly_access",this.locale):void 0,onClick:this.createFolder},o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},o("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),o("path",{d:"M12 11v4M10 13h4"})),s("new_folder",this.locale)),"tree"===this.mode&&o("button",{type:"button",class:"mrd-document-container__action",disabled:this.readOnly||!this.canCreate,title:this.readOnly?s("readonly_access",this.locale):this.targetLabel?`${s("doc_upload_to",this.locale)} ${this.targetLabel}`:void 0,onClick:this.pickFile},o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},o("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),o("path",{d:"M12 3v13M7 8l5-5 5 5"})),s("doc_upload",this.locale)),o("input",{type:"file",class:"mrd-document-container__file-input",ref:t=>this.fileInputEl=t,onChange:this.onFilePicked}),o("div",{class:"mrd-document-container__seg",role:"group","aria-label":s("doc_view_switch",this.locale)},o("button",{class:"mrd-document-container__seg-btn","aria-pressed":String("tree"===this.mode),title:s("doc_view_tree",this.locale),"aria-label":s("doc_view_tree",this.locale),onClick:()=>this.setMode("tree")},o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},o("path",{d:"M3 5h6M3 12h9M3 19h6"}),o("circle",{cx:"18",cy:"5",r:"1.6"}),o("circle",{cx:"18",cy:"19",r:"1.6"}),o("path",{d:"M16 12h4"}))),o("button",{class:"mrd-document-container__seg-btn","aria-pressed":String("list"===this.mode),title:s("doc_view_list",this.locale),"aria-label":s("doc_view_list",this.locale),onClick:()=>this.setMode("list")},o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},o("path",{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"})))))}renderTree(){return o("mrd-document-list",{"data-doclist":this.viewKey,ref:t=>this.listEl=t,item:this.item,archetype:this.archetype,parentId:this.parentId,containerHref:this.containerHref,locale:this.locale,readOnly:this.readOnly,onMrdLoadDistinct:t=>{t.stopPropagation(),this.mrdLoadDistinct.emit(t.detail)},onMrdLoadPage:t=>{t.stopPropagation(),this.mrdLoadPage.emit(t.detail)},onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(Object.assign(Object.assign({},t.detail),{navigateBehaviour:d.OVERLAY_PAGE}))},onMrdCanCreate:t=>{t.stopPropagation(),this.canCreate=t.detail},onMrdTargetLabel:t=>{t.stopPropagation(),this.targetLabel=t.detail},onMrdUpdateObject:t=>{t.stopPropagation(),this.mrdUpdateObject.emit(t.detail)},onMrdUpload:t=>{t.stopPropagation(),this.mrdUpload.emit(t.detail)},onMrdCreateObject:t=>{t.stopPropagation(),this.mrdCreateObject.emit(t.detail)}})}renderList(){return o("mrd-table",{"data-view":this.viewKey,ref:t=>this.tableEl=t,item:this.item,parentId:this.parentId,locale:this.locale,readOnly:this.readOnly,onMrdLoadPage:t=>{t.stopPropagation(),this.mrdLoadPage.emit(t.detail)},onMrdLoadAggregations:t=>{t.stopPropagation(),this.mrdLoadAggregations.emit(t.detail)},onMrdRowClick:t=>{var r,e,o;t.stopPropagation();const{row:i,listContext:n}=t.detail;this.mrdNavigate.emit({href:null===(e=null===(r=null==i?void 0:i._links)||void 0===r?void 0:r.self)||void 0===e?void 0:e.href,label:null!==(o=null==i?void 0:i.name)&&void 0!==o?o:"",navigateBehaviour:d.OVERLAY_PAGE,listContext:n,attachments:a(this.archetype,i)})},onMrdAction:t=>{t.stopPropagation(),this.mrdAction.emit(t.detail)}})}render(){const t="tree"===this.mode;return o(i,{key:"6792d49f08dd19f6c51e4b656df06bbd8bc14f3e"},this.renderToolbar(),o("div",{key:"702f4c288f8c40bd2c5999beb392b9dfd022b0bc",class:{"mrd-document-container__body":!0,"mrd-document-container__body--tree":t},style:t?{height:`${this.height}px`,overflowY:"auto"}:{}},t?this.renderTree():this.renderList()))}get el(){return this}static get style(){return".sc-mrd-document-container-h{display:block}.mrd-document-container__toolbar.sc-mrd-document-container{display:flex;align-items:center;justify-content:flex-end;gap:var(--mrd-space-2);padding:var(--mrd-space-2) 0;border-bottom:1px solid var(--mrd-color-neutral-100)}.mrd-document-container__body--tree.sc-mrd-document-container{border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);overflow:hidden}.mrd-document-container__action.sc-mrd-document-container{display:inline-flex;align-items:center;gap:var(--mrd-space-2);height:1.625rem;padding:0 var(--mrd-space-3);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-700);background:var(--mrd-color-white);border:1px solid var(--mrd-color-neutral-200);border-radius:var(--mrd-border-radius);cursor:pointer;transition:background var(--mrd-transition-fast), border-color var(--mrd-transition-fast)}.mrd-document-container__action.sc-mrd-document-container svg.sc-mrd-document-container{width:1rem;height:1rem;color:var(--mrd-color-folder)}.mrd-document-container__action.sc-mrd-document-container:hover:not(:disabled){background:var(--mrd-color-neutral-50);border-color:var(--mrd-color-neutral-300)}.mrd-document-container__action.sc-mrd-document-container:disabled{opacity:0.5;cursor:not-allowed}.mrd-document-container__file-input.sc-mrd-document-container{display:none}.mrd-document-container__seg.sc-mrd-document-container{display:inline-flex;gap:2px;padding:2px;background:var(--mrd-color-neutral-100);border-radius:var(--mrd-border-radius)}.mrd-document-container__seg-btn.sc-mrd-document-container{width:1.875rem;height:1.625rem;display:grid;place-items:center;border:none;background:none;border-radius:var(--mrd-border-radius-sm);color:var(--mrd-color-neutral-500);cursor:pointer;transition:color var(--mrd-transition-fast), background var(--mrd-transition-fast)}.mrd-document-container__seg-btn.sc-mrd-document-container:hover{color:var(--mrd-color-neutral-800)}.mrd-document-container__seg-btn[aria-pressed=true].sc-mrd-document-container{background:var(--mrd-color-white);color:var(--mrd-color-primary-dark);box-shadow:var(--mrd-shadow-sm)}.mrd-document-container__seg-btn.sc-mrd-document-container svg.sc-mrd-document-container{width:1rem;height:1rem}"}},[2,"mrd-document-container",{item:[16],archetype:[16],parentId:[1,"parent-id"],containerHref:[1,"container-href"],viewKey:[1,"view-key"],height:[2],locale:[1],readOnly:[4,"read-only"],mode:[32],canCreate:[32],targetLabel:[32]}]);function h(){"undefined"!=typeof customElements&&["mrd-document-container","mrd-document-list","mrd-table"].forEach((t=>{switch(t){case"mrd-document-container":customElements.get(n(t))||customElements.define(n(t),m);break;case"mrd-document-list":customElements.get(n(t))||c();break;case"mrd-table":customElements.get(n(t))||l()}}))}export{m as M,h as d}
1
+ import{proxyCustomElement as t,HTMLElement as r,createEvent as e,h as o,Host as i,transformTag as n}from"@stencil/core/internal/client";import{e as d}from"./client-layout.js";import{t as a}from"./i18n.js";import{a as s}from"./document-attachments.js";import{d as c}from"./mrd-document-list2.js";import{d as l}from"./mrd-table2.js";const m=t(class extends r{constructor(t){super(),!1!==t&&this.__registerHost(),this.mrdLoadPage=e(this,"mrdLoadPage",7),this.mrdLoadDistinct=e(this,"mrdLoadDistinct",7),this.mrdLoadAggregations=e(this,"mrdLoadAggregations",7),this.mrdNavigate=e(this,"mrdNavigate",7),this.mrdAction=e(this,"mrdAction",7),this.mrdUpdateObject=e(this,"mrdUpdateObject",7),this.mrdUpload=e(this,"mrdUpload",7),this.mrdCreateObject=e(this,"mrdCreateObject",7),this.item=null,this.parentId="",this.containerHref="",this.viewKey="",this.height=460,this.locale=navigator.language,this.readOnly=!1,this.mayCreate=!1,this.mode="tree",this.canCreate=!1,this.targetLabel="",this.tableInited=!1,this.createFolder=()=>{var t;null===(t=this.listEl)||void 0===t||t.createFolder()},this.pickFile=()=>{var t;!this.readOnly&&this.mayCreate&&(null===(t=this.fileInputEl)||void 0===t||t.click())},this.onFilePicked=t=>{var r,e;const o=t.target,i=null===(r=o.files)||void 0===r?void 0:r[0];i&&(null===(e=this.listEl)||void 0===e||e.uploadFile(i)),o.value=""}}componentDidRender(){var t;if("list"===this.mode&&this.tableEl&&!this.tableInited){this.tableInited=!0;const r=this.tableEl;Promise.resolve(null===(t=r.componentOnReady)||void 0===t?void 0:t.call(r)).then((()=>r.init()))}}setMode(t){t!==this.mode&&(this.canCreate=!1,this.tableInited=!1,this.mode=t)}renderToolbar(){return o("div",{class:"mrd-document-container__toolbar"},"tree"===this.mode&&this.mayCreate&&o("button",{type:"button",class:"mrd-document-container__action",disabled:this.readOnly||!this.canCreate,title:this.readOnly?a("readonly_access",this.locale):void 0,onClick:this.createFolder},o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},o("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),o("path",{d:"M12 11v4M10 13h4"})),a("new_folder",this.locale)),"tree"===this.mode&&this.mayCreate&&o("button",{type:"button",class:"mrd-document-container__action",disabled:this.readOnly||!this.canCreate,title:this.readOnly?a("readonly_access",this.locale):this.targetLabel?`${a("doc_upload_to",this.locale)} ${this.targetLabel}`:void 0,onClick:this.pickFile},o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},o("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),o("path",{d:"M12 3v13M7 8l5-5 5 5"})),a("doc_upload",this.locale)),o("input",{type:"file",class:"mrd-document-container__file-input",ref:t=>this.fileInputEl=t,onChange:this.onFilePicked}),o("div",{class:"mrd-document-container__seg",role:"group","aria-label":a("doc_view_switch",this.locale)},o("button",{class:"mrd-document-container__seg-btn","aria-pressed":String("tree"===this.mode),title:a("doc_view_tree",this.locale),"aria-label":a("doc_view_tree",this.locale),onClick:()=>this.setMode("tree")},o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},o("path",{d:"M3 5h6M3 12h9M3 19h6"}),o("circle",{cx:"18",cy:"5",r:"1.6"}),o("circle",{cx:"18",cy:"19",r:"1.6"}),o("path",{d:"M16 12h4"}))),o("button",{class:"mrd-document-container__seg-btn","aria-pressed":String("list"===this.mode),title:a("doc_view_list",this.locale),"aria-label":a("doc_view_list",this.locale),onClick:()=>this.setMode("list")},o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},o("path",{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"})))))}renderTree(){return o("mrd-document-list",{"data-doclist":this.viewKey,ref:t=>this.listEl=t,item:this.item,archetype:this.archetype,parentId:this.parentId,containerHref:this.containerHref,locale:this.locale,readOnly:this.readOnly,onMrdLoadDistinct:t=>{t.stopPropagation(),this.mrdLoadDistinct.emit(t.detail)},onMrdLoadPage:t=>{t.stopPropagation(),this.mrdLoadPage.emit(t.detail)},onMrdNavigate:t=>{t.stopPropagation(),this.mrdNavigate.emit(Object.assign(Object.assign({},t.detail),{navigateBehaviour:d.OVERLAY_PAGE}))},onMrdCanCreate:t=>{t.stopPropagation(),this.canCreate=t.detail},onMrdTargetLabel:t=>{t.stopPropagation(),this.targetLabel=t.detail},onMrdUpdateObject:t=>{t.stopPropagation(),this.mrdUpdateObject.emit(t.detail)},onMrdUpload:t=>{t.stopPropagation(),this.mrdUpload.emit(t.detail)},onMrdCreateObject:t=>{t.stopPropagation(),this.mrdCreateObject.emit(t.detail)}})}renderList(){return o("mrd-table",{"data-view":this.viewKey,ref:t=>this.tableEl=t,item:this.item,parentId:this.parentId,locale:this.locale,readOnly:this.readOnly,canCreate:this.mayCreate,onMrdLoadPage:t=>{t.stopPropagation(),this.mrdLoadPage.emit(t.detail)},onMrdLoadAggregations:t=>{t.stopPropagation(),this.mrdLoadAggregations.emit(t.detail)},onMrdRowClick:t=>{var r,e,o;t.stopPropagation();const{row:i,listContext:n}=t.detail;this.mrdNavigate.emit({href:null===(e=null===(r=null==i?void 0:i._links)||void 0===r?void 0:r.self)||void 0===e?void 0:e.href,label:null!==(o=null==i?void 0:i.name)&&void 0!==o?o:"",navigateBehaviour:d.OVERLAY_PAGE,listContext:n,attachments:s(this.archetype,i)})},onMrdAction:t=>{t.stopPropagation(),this.mrdAction.emit(t.detail)}})}render(){const t="tree"===this.mode;return o(i,{key:"4b674a508ac7ddf6af80a40836b72dc65f41c741"},this.renderToolbar(),o("div",{key:"19968916f685a2e3cd075dabf170f67fb104251c",class:{"mrd-document-container__body":!0,"mrd-document-container__body--tree":t},style:t?{height:`${this.height}px`,overflowY:"auto"}:{}},t?this.renderTree():this.renderList()))}get el(){return this}static get style(){return".sc-mrd-document-container-h{display:block}.mrd-document-container__toolbar.sc-mrd-document-container{display:flex;align-items:center;justify-content:flex-end;gap:var(--mrd-space-2);padding:var(--mrd-space-2) 0;border-bottom:1px solid var(--mrd-color-neutral-100)}.mrd-document-container__body--tree.sc-mrd-document-container{border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);overflow:hidden}.mrd-document-container__action.sc-mrd-document-container{display:inline-flex;align-items:center;gap:var(--mrd-space-2);height:1.625rem;padding:0 var(--mrd-space-3);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-700);background:var(--mrd-color-white);border:1px solid var(--mrd-color-neutral-200);border-radius:var(--mrd-border-radius);cursor:pointer;transition:background var(--mrd-transition-fast), border-color var(--mrd-transition-fast)}.mrd-document-container__action.sc-mrd-document-container svg.sc-mrd-document-container{width:1rem;height:1rem;color:var(--mrd-color-folder)}.mrd-document-container__action.sc-mrd-document-container:hover:not(:disabled){background:var(--mrd-color-neutral-50);border-color:var(--mrd-color-neutral-300)}.mrd-document-container__action.sc-mrd-document-container:disabled{opacity:0.5;cursor:not-allowed}.mrd-document-container__file-input.sc-mrd-document-container{display:none}.mrd-document-container__seg.sc-mrd-document-container{display:inline-flex;gap:2px;padding:2px;background:var(--mrd-color-neutral-100);border-radius:var(--mrd-border-radius)}.mrd-document-container__seg-btn.sc-mrd-document-container{width:1.875rem;height:1.625rem;display:grid;place-items:center;border:none;background:none;border-radius:var(--mrd-border-radius-sm);color:var(--mrd-color-neutral-500);cursor:pointer;transition:color var(--mrd-transition-fast), background var(--mrd-transition-fast)}.mrd-document-container__seg-btn.sc-mrd-document-container:hover{color:var(--mrd-color-neutral-800)}.mrd-document-container__seg-btn[aria-pressed=true].sc-mrd-document-container{background:var(--mrd-color-white);color:var(--mrd-color-primary-dark);box-shadow:var(--mrd-shadow-sm)}.mrd-document-container__seg-btn.sc-mrd-document-container svg.sc-mrd-document-container{width:1rem;height:1rem}"}},[2,"mrd-document-container",{item:[16],archetype:[16],parentId:[1,"parent-id"],containerHref:[1,"container-href"],viewKey:[1,"view-key"],height:[2],locale:[1],readOnly:[4,"read-only"],mayCreate:[4,"may-create"],mode:[32],canCreate:[32],targetLabel:[32]}]);function h(){"undefined"!=typeof customElements&&["mrd-document-container","mrd-document-list","mrd-table"].forEach((t=>{switch(t){case"mrd-document-container":customElements.get(n(t))||customElements.define(n(t),m);break;case"mrd-document-list":customElements.get(n(t))||c();break;case"mrd-table":customElements.get(n(t))||l()}}))}export{m as M,h as d}
@@ -1 +1 @@
1
- import{proxyCustomElement as r,HTMLElement as e,createEvent as i,h as d,Host as l,transformTag as t}from"@stencil/core/internal/client";import{b as o,a,c as s}from"./client-layout.js";import{t as n}from"./i18n.js";import{d as m}from"./mrd-boolean-field2.js";import{d as c}from"./mrd-currency-field2.js";import{d as u}from"./mrd-date-field2.js";import{d as f}from"./mrd-datetime-field2.js";import{d as v}from"./mrd-email-field2.js";import{d as h}from"./mrd-file-field2.js";import{d as p}from"./mrd-hyperlink-field2.js";import{d as b}from"./mrd-image-field2.js";import{d as y}from"./mrd-list-field2.js";import{d as g}from"./mrd-longtext-field2.js";import{d as _}from"./mrd-number-field2.js";import{d as j}from"./mrd-relation-field2.js";import{d as k}from"./mrd-secret-field2.js";import{d as x}from"./mrd-text-field2.js";import{d as w}from"./mrd-textarea-field2.js";import{d as E}from"./mrd-time-field2.js";const O=r(class extends e{constructor(r){super(),!1!==r&&this.__registerHost(),this.mrdChange=i(this,"mrdChange",7),this.mrdBlur=i(this,"mrdBlur",7),this.mrdSearch=i(this,"mrdSearch",7),this.mrdFetchAll=i(this,"mrdFetchAll",7),this.mrdUpload=i(this,"mrdUpload",7),this.locale=navigator.language,this.historyEntries=[],this.currentValue=void 0,this.handleChange=r=>{var e,i,d,l;r.stopPropagation(),(null!==(i=null===(e=this.item)||void 0===e?void 0:e.historyEnabled)&&void 0!==i?i:null===(l=null===(d=this.item)||void 0===d?void 0:d.field)||void 0===l?void 0:l.historyEnabled)?(this.currentValue=r.detail.value,this.mrdChange.emit({name:r.detail.name,value:{current:r.detail.value,history:this.historyEntries}})):this.mrdChange.emit(r.detail)},this.handleBlur=r=>{var e,i,d,l;r.stopPropagation();const t=null!==(i=null===(e=this.item)||void 0===e?void 0:e.historyEnabled)&&void 0!==i?i:null===(l=null===(d=this.item)||void 0===d?void 0:d.field)||void 0===l?void 0:l.historyEnabled;this.mrdBlur.emit(t?{name:r.detail.name,value:{current:this.currentValue,history:this.historyEntries}}:r.detail)},this.handleSearch=r=>{r.stopPropagation(),this.mrdSearch.emit(r.detail)},this.handleFetchAll=r=>{r.stopPropagation(),this.mrdFetchAll.emit(r.detail)},this.handleUpload=r=>{r.stopPropagation(),this.mrdUpload.emit(r.detail)}}componentWillLoad(){this.initHistoryState()}valueChanged(){this.initHistoryState()}initHistoryState(){var r,e,i,d,l;if(!(null!==(e=null===(r=this.item)||void 0===r?void 0:r.historyEnabled)&&void 0!==e?e:null===(d=null===(i=this.item)||void 0===i?void 0:i.field)||void 0===d?void 0:d.historyEnabled))return;const t=this.value;this.currentValue=null!==(l=null==t?void 0:t.current)&&void 0!==l?l:t,this.historyEntries=Array.isArray(null==t?void 0:t.history)?[...t.history]:[]}getDisplayValue(){var r,e,i,d;return(null!==(e=null===(r=this.item)||void 0===r?void 0:r.historyEnabled)&&void 0!==e?e:null===(d=null===(i=this.item)||void 0===i?void 0:i.field)||void 0===d?void 0:d.historyEnabled)&&null!==this.value&&"object"==typeof this.value&&"current"in this.value?this.value.current:this.value}historyValueInputType(){var r;switch(null===(r=this.item)||void 0===r?void 0:r.dataType){case o.DATE:return"date";case o.DATETIME:return"datetime-local";case o.TIME:return"time";case o.INTEGER:case o.DECIMAL:case o.PERCENTAGE:return"number";case o.EMAIL:return"email";default:return"text"}}emitHistoryChange(r){this.historyEntries=r,this.mrdChange.emit({name:this.item.name,value:{current:this.currentValue,history:r}})}renderHistoryEditor(){var r,e,i,l;if(!(null!==(e=null===(r=this.item)||void 0===r?void 0:r.historyEnabled)&&void 0!==e?e:null===(l=null===(i=this.item)||void 0===i?void 0:i.field)||void 0===l?void 0:l.historyEnabled))return null;const{locale:t}=this,o=this.historyValueInputType(),a=(r,e,i)=>{const d=this.historyEntries.map(((d,l)=>l===r?Object.assign(Object.assign({},d),{[e]:i}):d));this.emitHistoryChange(d)},s=r=>{this.emitHistoryChange(this.historyEntries.filter(((e,i)=>i!==r)))};return d("div",{class:"mrd-field__history-editor"},this.historyEntries.length>0&&d("span",{class:"mrd-field__history-editor-label"},n("history_badge_tooltip",t)),this.historyEntries.map(((r,e)=>d("div",{key:String(e),class:"mrd-field__history-editor-row"},d("input",{class:"mrd-field__history-editor-value",type:o,value:r.value,onInput:r=>a(e,"value",r.target.value)}),d("span",{class:"mrd-field__history-editor-sep"},n("history_until",t)),d("input",{class:"mrd-field__history-editor-until",type:"date",value:r.until,onInput:r=>a(e,"until",r.target.value)}),d("button",{type:"button",class:"mrd-field__history-editor-remove",onClick:()=>s(e),"aria-label":n("remove",t)},d("svg",{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},d("path",{"fill-rule":"evenodd",d:"M8.75 1A2.75 2.75 0 006 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 10.23 1.482l.149-.022.841 10.518A2.75 2.75 0 007.596 19h4.807a2.75 2.75 0 002.742-2.53l.841-10.52.149.023a.75.75 0 00.23-1.482A41.03 41.03 0 0014 4.193V3.75A2.75 2.75 0 0011.25 1h-2.5zM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4zM8.58 7.72a.75.75 0 00-1.5.06l.3 7.5a.75.75 0 101.5-.06l-.3-7.5zm4.34.06a.75.75 0 10-1.5-.06l-.3 7.5a.75.75 0 101.5.06l.3-7.5z","clip-rule":"evenodd"})))))),d("button",{type:"button",class:"mrd-field__history-editor-add",onClick:()=>{this.emitHistoryChange([...this.historyEntries,{value:"",until:""}])}},"+ ",n("add",t)))}renderLeafField(r){var e,i,l,t,a,s,n,m,c,u,f,v,h,p,b,y,g,_,j,k,x,w,E,O,z,C,M,A,S,V,B;const{item:I,locale:U}=this,F={name:I.name,label:I.label,required:I.required,disabled:null!==(e=I.disabled)&&void 0!==e&&e,locale:U,onMrdChange:this.handleChange,onMrdBlur:this.handleBlur};switch(I.dataType){case o.TEXT:return d("mrd-text-field",Object.assign({},F,{value:null!==(i=r)&&void 0!==i?i:"",placeholder:null!==(l=I.placeholder)&&void 0!==l?l:""}));case o.TEXTBLOCK:return d("mrd-textarea-field",Object.assign({},F,{value:null!==(t=r)&&void 0!==t?t:"",placeholder:null!==(a=I.placeholder)&&void 0!==a?a:""}));case o.INTEGER:case o.DECIMAL:case o.PERCENTAGE:return d("mrd-number-field",Object.assign({},F,{value:null!==(s=r)&&void 0!==s?s:null,dataType:I.dataType,decimalPrecision:null!==(n=I.decimalPrecision)&&void 0!==n?n:2,placeholder:null!==(m=I.placeholder)&&void 0!==m?m:""}));case o.CURRENCY:return d("mrd-currency-field",Object.assign({},F,{value:null!==(c=r)&&void 0!==c?c:{amount:null,currency:null!==(u=I.currencyCode)&&void 0!==u?u:"EUR"}}));case o.BOOLEAN:return d("mrd-boolean-field",Object.assign({},F,{value:null!==(f=r)&&void 0!==f&&f}));case o.DATE:return d("mrd-date-field",Object.assign({},F,{value:null!==(v=r)&&void 0!==v?v:""}));case o.DATETIME:return d("mrd-datetime-field",Object.assign({},F,{value:null!==(h=r)&&void 0!==h?h:""}));case o.TIME:return d("mrd-time-field",Object.assign({},F,{value:null!==(p=r)&&void 0!==p?p:""}));case o.EMAIL:return d("mrd-email-field",Object.assign({},F,{value:null!==(b=r)&&void 0!==b?b:"",placeholder:null!==(y=I.placeholder)&&void 0!==y?y:""}));case o.HYPERLINK:return d("mrd-hyperlink-field",Object.assign({},F,{value:null!==(g=r)&&void 0!==g?g:"",placeholder:null!==(_=I.placeholder)&&void 0!==_?_:""}));case o.LIST:return d("mrd-list-field",Object.assign({},F,{value:null!==(j=r)&&void 0!==j?j:"",multiple:null!==(k=I.multiple)&&void 0!==k&&k,listItems:null!==(x=I.listItems)&&void 0!==x?x:[]}));case o.FILE:return d("mrd-file-field",Object.assign({},F,{value:r,accept:null!==(w=I.accept)&&void 0!==w?w:"",maxSize:null!==(E=I.maxSize)&&void 0!==E?E:0,multiple:null!==(O=I.multiple)&&void 0!==O&&O,onMrdUpload:this.handleUpload}));case o.IMAGE:return d("mrd-image-field",Object.assign({},F,{value:r,accept:null!==(z=I.accept)&&void 0!==z?z:"image/*",maxSize:null!==(C=I.maxSize)&&void 0!==C?C:0,multiple:null!==(M=I.multiple)&&void 0!==M&&M,onMrdUpload:this.handleUpload}));case o.LONGTEXT:return d("mrd-longtext-field",Object.assign({},F,{value:null!==(A=r)&&void 0!==A?A:"",placeholder:null!==(S=I.placeholder)&&void 0!==S?S:""}));case o.SECRET:return d("mrd-secret-field",Object.assign({},F,{value:null!==(V=r)&&void 0!==V?V:"",placeholder:null!==(B=I.placeholder)&&void 0!==B?B:""}));default:return null}}render(){var r,e,i,t,o,n;const{item:m,locale:c,value:u}=this;if(m.type===a.RELATION)return d(l,null,d("mrd-relation-field",{name:m.name,label:m.label,required:m.required,disabled:null!==(r=m.disabled)&&void 0!==r&&r,locale:c,relatedClass:m.relatedClass,mostSignificantClass:null!==(e=m.mostSignificantClass)&&void 0!==e?e:"",displayType:null!==(i=m.displayType)&&void 0!==i?i:s.SEARCH,editBehavior:null!==(t=m.editBehavior)&&void 0!==t?t:null,commonRelation:m.commonRelation,multiple:null!==(o=m.multiple)&&void 0!==o&&o,dropdownValues:null!==(n=m.dropdownValues)&&void 0!==n?n:[],value:u,onMrdChange:this.handleChange,onMrdBlur:this.handleBlur,onMrdSearch:this.handleSearch,onMrdFetchAll:this.handleFetchAll}));if(m.type!==a.FIELD)return d(l,null);const f=this.getDisplayValue();return d(l,null,d("div",{class:"mrd-field__inner"},this.renderLeafField(f),this.renderHistoryEditor()))}get el(){return this}static get watchers(){return{value:[{valueChanged:0}]}}static get style(){return".sc-mrd-field-h{display:block}.mrd-field__inner.sc-mrd-field{display:block;width:100%}.mrd-field__history-editor.sc-mrd-field{margin-top:var(--mrd-space-2);display:flex;flex-direction:column;gap:var(--mrd-space-1)}.mrd-field__history-editor-label.sc-mrd-field{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-500)}.mrd-field__history-editor-row.sc-mrd-field{display:flex;align-items:center;gap:var(--mrd-space-2)}.mrd-field__history-editor-sep.sc-mrd-field{flex-shrink:0;font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500)}.mrd-field__history-editor-value.sc-mrd-field{flex:1 1 0;min-width:0;height:var(--mrd-input-height);padding:0 var(--mrd-space-3);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800);background-color:var(--mrd-color-white);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-md);outline:none;transition:border-color var(--mrd-transition-fast), box-shadow var(--mrd-transition-fast)}.mrd-field__history-editor-value.sc-mrd-field:focus{border-color:var(--mrd-color-primary);box-shadow:var(--mrd-shadow-focus)}.mrd-field__history-editor-until.sc-mrd-field{flex:0 0 10rem;height:var(--mrd-input-height);padding:0 var(--mrd-space-3);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800);background-color:var(--mrd-color-white);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-md);outline:none;transition:border-color var(--mrd-transition-fast), box-shadow var(--mrd-transition-fast)}.mrd-field__history-editor-until.sc-mrd-field:focus{border-color:var(--mrd-color-primary);box-shadow:var(--mrd-shadow-focus)}.mrd-field__history-editor-remove.sc-mrd-field{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2rem;height:2rem;padding:0;background:transparent;border:none;border-radius:var(--mrd-border-radius-sm);color:var(--mrd-color-neutral-400);cursor:pointer;transition:color var(--mrd-transition-fast), background-color var(--mrd-transition-fast)}.mrd-field__history-editor-remove.sc-mrd-field:hover{color:var(--mrd-color-danger);background-color:var(--mrd-color-danger-light)}.mrd-field__history-editor-remove.sc-mrd-field svg.sc-mrd-field{width:1rem;height:1rem}.mrd-field__history-editor-add.sc-mrd-field{align-self:flex-start;padding:var(--mrd-space-1) var(--mrd-space-3);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-primary);background:transparent;border:var(--mrd-border-width) solid var(--mrd-color-primary);border-radius:var(--mrd-border-radius-md);cursor:pointer;transition:background-color var(--mrd-transition-fast), color var(--mrd-transition-fast)}.mrd-field__history-editor-add.sc-mrd-field:hover{background-color:var(--mrd-color-primary-light)}"}},[2,"mrd-field",{item:[16],locale:[1],value:[16],historyEntries:[32],currentValue:[32]},void 0,{value:[{valueChanged:0}]}]);function z(){"undefined"!=typeof customElements&&["mrd-field","mrd-boolean-field","mrd-currency-field","mrd-date-field","mrd-datetime-field","mrd-email-field","mrd-file-field","mrd-hyperlink-field","mrd-image-field","mrd-list-field","mrd-longtext-field","mrd-number-field","mrd-relation-field","mrd-secret-field","mrd-text-field","mrd-textarea-field","mrd-time-field"].forEach((r=>{switch(r){case"mrd-field":customElements.get(t(r))||customElements.define(t(r),O);break;case"mrd-boolean-field":customElements.get(t(r))||m();break;case"mrd-currency-field":customElements.get(t(r))||c();break;case"mrd-date-field":customElements.get(t(r))||u();break;case"mrd-datetime-field":customElements.get(t(r))||f();break;case"mrd-email-field":customElements.get(t(r))||v();break;case"mrd-file-field":customElements.get(t(r))||h();break;case"mrd-hyperlink-field":customElements.get(t(r))||p();break;case"mrd-image-field":customElements.get(t(r))||b();break;case"mrd-list-field":customElements.get(t(r))||y();break;case"mrd-longtext-field":customElements.get(t(r))||g();break;case"mrd-number-field":customElements.get(t(r))||_();break;case"mrd-relation-field":customElements.get(t(r))||j();break;case"mrd-secret-field":customElements.get(t(r))||k();break;case"mrd-text-field":customElements.get(t(r))||x();break;case"mrd-textarea-field":customElements.get(t(r))||w();break;case"mrd-time-field":customElements.get(t(r))||E()}}))}export{O as M,z as d}
1
+ import{proxyCustomElement as r,HTMLElement as e,createEvent as i,h as d,Host as l,transformTag as t}from"@stencil/core/internal/client";import{a as o,b as a,c as s}from"./client-layout.js";import{t as m}from"./i18n.js";import{r as n,F as u,a as c}from"./field-helpers.js";import{d as f}from"./mrd-boolean-field2.js";import{d as v}from"./mrd-currency-field2.js";import{d as h}from"./mrd-date-field2.js";import{d as p}from"./mrd-datetime-field2.js";import{d as b}from"./mrd-email-field2.js";import{d as y}from"./mrd-file-field2.js";import{d as _}from"./mrd-hyperlink-field2.js";import{d as g}from"./mrd-image-field2.js";import{d as k}from"./mrd-list-field2.js";import{d as x}from"./mrd-longtext-field2.js";import{d as w}from"./mrd-number-field2.js";import{d as j}from"./mrd-relation-field2.js";import{d as E}from"./mrd-secret-field2.js";import{d as z}from"./mrd-text-field2.js";import{d as O}from"./mrd-textarea-field2.js";import{d as C}from"./mrd-time-field2.js";const M=r(class extends e{constructor(r){super(),!1!==r&&this.__registerHost(),this.mrdChange=i(this,"mrdChange",7),this.mrdBlur=i(this,"mrdBlur",7),this.mrdSearch=i(this,"mrdSearch",7),this.mrdFetchAll=i(this,"mrdFetchAll",7),this.mrdUpload=i(this,"mrdUpload",7),this.locale=navigator.language,this.historyEntries=[],this.currentValue=void 0,this.multiValues=[],this.multiError="",this.handleMultiRowBlur=()=>{var r;this.multiError=n(this.multiValues,null!==(r=this.item.required)&&void 0!==r&&r,this.locale),this.mrdBlur.emit({name:this.item.name,value:this.multiValues})},this.handleChange=r=>{var e,i,d,l;r.stopPropagation(),(null!==(i=null===(e=this.item)||void 0===e?void 0:e.historyEnabled)&&void 0!==i?i:null===(l=null===(d=this.item)||void 0===d?void 0:d.field)||void 0===l?void 0:l.historyEnabled)?(this.currentValue=r.detail.value,this.mrdChange.emit({name:r.detail.name,value:{current:r.detail.value,history:this.historyEntries}})):this.mrdChange.emit(r.detail)},this.handleBlur=r=>{var e,i,d,l;r.stopPropagation();const t=null!==(i=null===(e=this.item)||void 0===e?void 0:e.historyEnabled)&&void 0!==i?i:null===(l=null===(d=this.item)||void 0===d?void 0:d.field)||void 0===l?void 0:l.historyEnabled;this.mrdBlur.emit(t?{name:r.detail.name,value:{current:this.currentValue,history:this.historyEntries}}:r.detail)},this.handleSearch=r=>{r.stopPropagation(),this.mrdSearch.emit(r.detail)},this.handleFetchAll=r=>{r.stopPropagation(),this.mrdFetchAll.emit(r.detail)},this.handleUpload=r=>{r.stopPropagation(),this.mrdUpload.emit(r.detail)}}componentWillLoad(){this.initHistoryState(),this.initMultiState()}valueChanged(){this.initHistoryState(),this.initMultiState()}initHistoryState(){var r,e,i,d,l;if(!(null!==(e=null===(r=this.item)||void 0===r?void 0:r.historyEnabled)&&void 0!==e?e:null===(d=null===(i=this.item)||void 0===i?void 0:i.field)||void 0===d?void 0:d.historyEnabled))return;const t=this.value;this.currentValue=null!==(l=null==t?void 0:t.current)&&void 0!==l?l:t,this.historyEntries=Array.isArray(null==t?void 0:t.history)?[...t.history]:[]}isMultiScalar(){var r,e;if((null===(r=this.item)||void 0===r?void 0:r.type)!==o.FIELD||!(null===(e=this.item)||void 0===e?void 0:e.multiple))return!1;const i=this.item.dataType;return i!==a.LIST&&i!==a.FILE&&i!==a.IMAGE}initMultiState(){if(!this.isMultiScalar())return;const r=this.value;this.multiValues=Array.isArray(r)?[...r]:null!=r&&""!==r?[r]:[]}emptyRowValue(){var r;switch(this.item.dataType){case a.INTEGER:case a.DECIMAL:case a.PERCENTAGE:return null;case a.CURRENCY:return{amount:null,currency:null!==(r=this.item.currencyCode)&&void 0!==r?r:"EUR"};case a.BOOLEAN:return!1;default:return""}}emitMultiChange(r){this.multiValues=r,this.mrdChange.emit({name:this.item.name,value:r})}getDisplayValue(){var r,e,i,d;return(null!==(e=null===(r=this.item)||void 0===r?void 0:r.historyEnabled)&&void 0!==e?e:null===(d=null===(i=this.item)||void 0===i?void 0:i.field)||void 0===d?void 0:d.historyEnabled)&&null!==this.value&&"object"==typeof this.value&&"current"in this.value?this.value.current:this.value}historyValueInputType(){var r;switch(null===(r=this.item)||void 0===r?void 0:r.dataType){case a.DATE:return"date";case a.DATETIME:return"datetime-local";case a.TIME:return"time";case a.INTEGER:case a.DECIMAL:case a.PERCENTAGE:return"number";case a.EMAIL:return"email";default:return"text"}}emitHistoryChange(r){this.historyEntries=r,this.mrdChange.emit({name:this.item.name,value:{current:this.currentValue,history:r}})}renderRemoveIcon(){return d("svg",{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},d("path",{"fill-rule":"evenodd",d:"M8.75 1A2.75 2.75 0 006 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 10.23 1.482l.149-.022.841 10.518A2.75 2.75 0 007.596 19h4.807a2.75 2.75 0 002.742-2.53l.841-10.52.149.023a.75.75 0 00.23-1.482A41.03 41.03 0 0014 4.193V3.75A2.75 2.75 0 0011.25 1h-2.5zM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4zM8.58 7.72a.75.75 0 00-1.5.06l.3 7.5a.75.75 0 101.5-.06l-.3-7.5zm4.34.06a.75.75 0 10-1.5-.06l-.3 7.5a.75.75 0 101.5.06l.3-7.5z","clip-rule":"evenodd"}))}renderHistoryEditor(){var r,e,i,l;if(!(null!==(e=null===(r=this.item)||void 0===r?void 0:r.historyEnabled)&&void 0!==e?e:null===(l=null===(i=this.item)||void 0===i?void 0:i.field)||void 0===l?void 0:l.historyEnabled))return null;const{locale:t}=this,o=this.historyValueInputType(),a=(r,e,i)=>{const d=this.historyEntries.map(((d,l)=>l===r?Object.assign(Object.assign({},d),{[e]:i}):d));this.emitHistoryChange(d)},s=r=>{this.emitHistoryChange(this.historyEntries.filter(((e,i)=>i!==r)))};return d("div",{class:"mrd-field__history-editor"},this.historyEntries.length>0&&d("span",{class:"mrd-field__history-editor-label"},m("history_badge_tooltip",t)),this.historyEntries.map(((r,e)=>d("div",{key:String(e),class:"mrd-field__history-editor-row"},d("input",{class:"mrd-field__history-editor-value",type:o,value:r.value,onInput:r=>a(e,"value",r.target.value)}),d("span",{class:"mrd-field__history-editor-sep"},m("history_until",t)),d("input",{class:"mrd-field__history-editor-until",type:"date",value:r.until,onInput:r=>a(e,"until",r.target.value)}),d("button",{type:"button",class:"mrd-field__history-editor-remove",onClick:()=>s(e),"aria-label":m("remove",t)},this.renderRemoveIcon())))),d("button",{type:"button",class:"mrd-field__history-editor-add",onClick:()=>{this.emitHistoryChange([...this.historyEntries,{value:"",until:""}])}},"+ ",m("add",t)))}renderLeafField(r,e=this.handleChange,i=this.handleBlur,l={}){var t,o,s,m,n,u,c,f,v,h,p,b,y,_,g,k,x,w,j,E,z,O,C,M,S,A,V,q,B,F,I,R,U;const{item:H,locale:T}=this,L={name:H.name,label:null!==(t=l.label)&&void 0!==t?t:H.label,required:null!==(o=l.required)&&void 0!==o?o:H.required,disabled:null!==(s=H.disabled)&&void 0!==s&&s,locale:T,onMrdChange:e,onMrdBlur:i};switch(H.dataType){case a.TEXT:return d("mrd-text-field",Object.assign({},L,{value:null!==(m=r)&&void 0!==m?m:"",placeholder:null!==(n=H.placeholder)&&void 0!==n?n:""}));case a.TEXTBLOCK:return d("mrd-textarea-field",Object.assign({},L,{value:null!==(u=r)&&void 0!==u?u:"",placeholder:null!==(c=H.placeholder)&&void 0!==c?c:""}));case a.INTEGER:case a.DECIMAL:case a.PERCENTAGE:return d("mrd-number-field",Object.assign({},L,{value:null!==(f=r)&&void 0!==f?f:null,dataType:H.dataType,decimalPrecision:null!==(v=H.decimalPrecision)&&void 0!==v?v:2,placeholder:null!==(h=H.placeholder)&&void 0!==h?h:""}));case a.CURRENCY:return d("mrd-currency-field",Object.assign({},L,{value:null!==(p=r)&&void 0!==p?p:{amount:null,currency:null!==(b=H.currencyCode)&&void 0!==b?b:"EUR"}}));case a.BOOLEAN:return d("mrd-boolean-field",Object.assign({},L,{value:null!==(y=r)&&void 0!==y&&y}));case a.DATE:return d("mrd-date-field",Object.assign({},L,{value:null!==(_=r)&&void 0!==_?_:""}));case a.DATETIME:return d("mrd-datetime-field",Object.assign({},L,{value:null!==(g=r)&&void 0!==g?g:""}));case a.TIME:return d("mrd-time-field",Object.assign({},L,{value:null!==(k=r)&&void 0!==k?k:""}));case a.EMAIL:return d("mrd-email-field",Object.assign({},L,{value:null!==(x=r)&&void 0!==x?x:"",placeholder:null!==(w=H.placeholder)&&void 0!==w?w:""}));case a.HYPERLINK:return d("mrd-hyperlink-field",Object.assign({},L,{value:null!==(j=r)&&void 0!==j?j:"",placeholder:null!==(E=H.placeholder)&&void 0!==E?E:""}));case a.LIST:return d("mrd-list-field",Object.assign({},L,{value:null!==(z=r)&&void 0!==z?z:"",multiple:null!==(O=H.multiple)&&void 0!==O&&O,listItems:null!==(C=H.listItems)&&void 0!==C?C:[]}));case a.FILE:return d("mrd-file-field",Object.assign({},L,{value:r,accept:null!==(M=H.accept)&&void 0!==M?M:"",maxSize:null!==(S=H.maxSize)&&void 0!==S?S:0,multiple:null!==(A=H.multiple)&&void 0!==A&&A,onMrdUpload:this.handleUpload}));case a.IMAGE:return d("mrd-image-field",Object.assign({},L,{value:r,accept:null!==(V=H.accept)&&void 0!==V?V:"image/*",maxSize:null!==(q=H.maxSize)&&void 0!==q?q:0,multiple:null!==(B=H.multiple)&&void 0!==B&&B,onMrdUpload:this.handleUpload}));case a.LONGTEXT:return d("mrd-longtext-field",Object.assign({},L,{value:null!==(F=r)&&void 0!==F?F:"",placeholder:null!==(I=H.placeholder)&&void 0!==I?I:""}));case a.SECRET:return d("mrd-secret-field",Object.assign({},L,{value:null!==(R=r)&&void 0!==R?R:"",placeholder:null!==(U=H.placeholder)&&void 0!==U?U:""}));default:return null}}renderMultiScalarField(){var r,e;const{item:i,locale:l}=this,t=(r,e)=>{this.emitMultiChange(this.multiValues.map(((i,d)=>d===r?e:i)))},o=r=>{this.emitMultiChange(this.multiValues.filter(((e,i)=>i!==r)))};return d("div",{class:"mrd-field__multi"},d(u,{base:"mrd-field__multi",label:null!==(r=i.label)&&void 0!==r?r:"",required:null!==(e=i.required)&&void 0!==e&&e}),this.multiValues.map(((r,e)=>d("div",{key:String(e),class:"mrd-field__multi-row"},d("div",{class:"mrd-field__multi-row-input"},this.renderLeafField(r,(r=>{r.stopPropagation(),t(e,r.detail.value)}),(r=>{r.stopPropagation(),this.handleMultiRowBlur()}),{label:"",required:!1})),d("button",{type:"button",class:"mrd-field__multi-remove",onClick:()=>o(e),"aria-label":m("remove",l)},this.renderRemoveIcon())))),d("button",{type:"button",class:"mrd-field__multi-add",onClick:()=>{this.emitMultiChange([...this.multiValues,this.emptyRowValue()])}},"+ ",m("add",l)),d(c,{base:"mrd-field__multi",error:this.multiError}))}render(){var r,e,i,t,a,m;const{item:n,locale:u,value:c}=this;if(n.type===o.RELATION)return d(l,null,d("mrd-relation-field",{name:n.name,label:n.label,required:n.required,disabled:null!==(r=n.disabled)&&void 0!==r&&r,locale:u,relatedClass:n.relatedClass,mostSignificantClass:null!==(e=n.mostSignificantClass)&&void 0!==e?e:"",displayType:null!==(i=n.displayType)&&void 0!==i?i:s.SEARCH,editBehavior:null!==(t=n.editBehavior)&&void 0!==t?t:null,commonRelation:n.commonRelation,multiple:null!==(a=n.multiple)&&void 0!==a&&a,dropdownValues:null!==(m=n.dropdownValues)&&void 0!==m?m:[],value:c,onMrdChange:this.handleChange,onMrdBlur:this.handleBlur,onMrdSearch:this.handleSearch,onMrdFetchAll:this.handleFetchAll}));if(n.type!==o.FIELD)return d(l,null);const f=this.getDisplayValue();return d(l,null,d("div",{class:"mrd-field__inner"},this.isMultiScalar()?this.renderMultiScalarField():this.renderLeafField(f),this.renderHistoryEditor()))}get el(){return this}static get watchers(){return{value:[{valueChanged:0}]}}static get style(){return'.sc-mrd-field-h{display:block}.mrd-field__inner.sc-mrd-field{display:block;width:100%}.mrd-field__history-editor.sc-mrd-field{margin-top:var(--mrd-space-2);display:flex;flex-direction:column;gap:var(--mrd-space-1)}.mrd-field__history-editor-label.sc-mrd-field{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-500)}.mrd-field__history-editor-row.sc-mrd-field{display:flex;align-items:center;gap:var(--mrd-space-2)}.mrd-field__history-editor-sep.sc-mrd-field{flex-shrink:0;font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500)}.mrd-field__history-editor-value.sc-mrd-field{flex:1 1 0;min-width:0;height:var(--mrd-input-height);padding:0 var(--mrd-space-3);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800);background-color:var(--mrd-color-white);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-md);outline:none;transition:border-color var(--mrd-transition-fast), box-shadow var(--mrd-transition-fast)}.mrd-field__history-editor-value.sc-mrd-field:focus{border-color:var(--mrd-color-primary);box-shadow:var(--mrd-shadow-focus)}.mrd-field__history-editor-until.sc-mrd-field{flex:0 0 10rem;height:var(--mrd-input-height);padding:0 var(--mrd-space-3);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800);background-color:var(--mrd-color-white);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-md);outline:none;transition:border-color var(--mrd-transition-fast), box-shadow var(--mrd-transition-fast)}.mrd-field__history-editor-until.sc-mrd-field:focus{border-color:var(--mrd-color-primary);box-shadow:var(--mrd-shadow-focus)}.mrd-field__history-editor-remove.sc-mrd-field{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2rem;height:2rem;padding:0;background:transparent;border:none;border-radius:var(--mrd-border-radius-sm);color:var(--mrd-color-neutral-400);cursor:pointer;transition:color var(--mrd-transition-fast), background-color var(--mrd-transition-fast)}.mrd-field__history-editor-remove.sc-mrd-field:hover{color:var(--mrd-color-danger);background-color:var(--mrd-color-danger-light)}.mrd-field__history-editor-remove.sc-mrd-field svg.sc-mrd-field{width:1rem;height:1rem}.mrd-field__history-editor-add.sc-mrd-field{align-self:flex-start;padding:var(--mrd-space-1) var(--mrd-space-3);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-primary);background:transparent;border:var(--mrd-border-width) solid var(--mrd-color-primary);border-radius:var(--mrd-border-radius-md);cursor:pointer;transition:background-color var(--mrd-transition-fast), color var(--mrd-transition-fast)}.mrd-field__history-editor-add.sc-mrd-field:hover{background-color:var(--mrd-color-primary-light)}.mrd-field__multi.sc-mrd-field{display:flex;flex-direction:column;gap:var(--mrd-space-1)}.mrd-field__multi__label.sc-mrd-field{display:block;font-family:var(--mrd-font-family);font-size:var(--mrd-label-font-size);font-weight:var(--mrd-label-font-weight);color:var(--mrd-label-color)}.mrd-field__multi__label--required.sc-mrd-field::after{content:" *";color:var(--mrd-color-danger)}.mrd-field__multi__error.sc-mrd-field{font-family:var(--mrd-font-family);font-size:var(--mrd-error-font-size);color:var(--mrd-error-color)}.mrd-field__multi-row.sc-mrd-field{display:flex;align-items:flex-start;gap:var(--mrd-space-2)}.mrd-field__multi-row-input.sc-mrd-field{flex:1 1 0;min-width:0}.mrd-field__multi-remove.sc-mrd-field{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2rem;height:var(--mrd-input-height);padding:0;background:transparent;border:none;border-radius:var(--mrd-border-radius-sm);color:var(--mrd-color-neutral-400);cursor:pointer;transition:color var(--mrd-transition-fast), background-color var(--mrd-transition-fast)}.mrd-field__multi-remove.sc-mrd-field:hover{color:var(--mrd-color-danger);background-color:var(--mrd-color-danger-light)}.mrd-field__multi-remove.sc-mrd-field svg.sc-mrd-field{width:1rem;height:1rem}.mrd-field__multi-add.sc-mrd-field{align-self:flex-start;padding:var(--mrd-space-1) var(--mrd-space-3);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-primary);background:transparent;border:var(--mrd-border-width) solid var(--mrd-color-primary);border-radius:var(--mrd-border-radius-md);cursor:pointer;transition:background-color var(--mrd-transition-fast), color var(--mrd-transition-fast)}.mrd-field__multi-add.sc-mrd-field:hover{background-color:var(--mrd-color-primary-light)}'}},[2,"mrd-field",{item:[16],locale:[1],value:[16],historyEntries:[32],currentValue:[32],multiValues:[32],multiError:[32]},void 0,{value:[{valueChanged:0}]}]);function S(){"undefined"!=typeof customElements&&["mrd-field","mrd-boolean-field","mrd-currency-field","mrd-date-field","mrd-datetime-field","mrd-email-field","mrd-file-field","mrd-hyperlink-field","mrd-image-field","mrd-list-field","mrd-longtext-field","mrd-number-field","mrd-relation-field","mrd-secret-field","mrd-text-field","mrd-textarea-field","mrd-time-field"].forEach((r=>{switch(r){case"mrd-field":customElements.get(t(r))||customElements.define(t(r),M);break;case"mrd-boolean-field":customElements.get(t(r))||f();break;case"mrd-currency-field":customElements.get(t(r))||v();break;case"mrd-date-field":customElements.get(t(r))||h();break;case"mrd-datetime-field":customElements.get(t(r))||p();break;case"mrd-email-field":customElements.get(t(r))||b();break;case"mrd-file-field":customElements.get(t(r))||y();break;case"mrd-hyperlink-field":customElements.get(t(r))||_();break;case"mrd-image-field":customElements.get(t(r))||g();break;case"mrd-list-field":customElements.get(t(r))||k();break;case"mrd-longtext-field":customElements.get(t(r))||x();break;case"mrd-number-field":customElements.get(t(r))||w();break;case"mrd-relation-field":customElements.get(t(r))||j();break;case"mrd-secret-field":customElements.get(t(r))||E();break;case"mrd-text-field":customElements.get(t(r))||z();break;case"mrd-textarea-field":customElements.get(t(r))||O();break;case"mrd-time-field":customElements.get(t(r))||C()}}))}export{M,S as d}