@mmlogic/components 0.5.0 → 0.5.1

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.
@@ -1920,7 +1920,7 @@ const MrdDocumentList = class {
1920
1920
  MrdDocumentList.ROOT = '__root__';
1921
1921
  MrdDocumentList.style = mrdDocumentListCss();
1922
1922
 
1923
- const mrdDocumentViewCss = () => `.sc-mrd-document-view-h{display:block}.mrd-document-view.sc-mrd-document-view{max-width:640px}.mrd-document-view__body.sc-mrd-document-view{display:flex;flex-direction:column;gap:var(--mrd-space-6)}.mrd-document-view__crumb.sc-mrd-document-view{display:inline-flex;align-items:center;gap:var(--mrd-space-2);margin-bottom:var(--mrd-space-4);padding:var(--mrd-space-1) var(--mrd-space-3);background:var(--mrd-color-primary-light);border:1px solid transparent;border-radius:var(--mrd-border-radius);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-primary-dark);cursor:pointer}.mrd-document-view__crumb.sc-mrd-document-view:hover{border-color:var(--mrd-color-primary)}.mrd-document-view__crumb-icon.sc-mrd-document-view{width:0.875rem;height:0.875rem;flex-shrink:0}.mrd-document-view__title.sc-mrd-document-view{font-size:var(--mrd-font-size-2xl);font-weight:var(--mrd-font-weight-bold);color:var(--mrd-color-neutral-900);letter-spacing:-0.02em;margin:0 0 var(--mrd-space-1) 0}.mrd-document-view__date.sc-mrd-document-view{font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-400);font-variant-numeric:tabular-nums;margin:0 0 var(--mrd-space-6) 0}.mrd-document-view__file-meta.sc-mrd-document-view{display:flex;align-items:center;gap:var(--mrd-space-4);margin-bottom:var(--mrd-space-2)}.mrd-document-view__file-name.sc-mrd-document-view{flex:1;min-width:0;font-weight:var(--mrd-font-weight-semibold);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800);word-break:break-word}.mrd-document-view__download.sc-mrd-document-view{display:inline-flex;align-items:center;gap:var(--mrd-space-2);flex-shrink:0;height:2rem;padding:0 var(--mrd-space-3);background:var(--mrd-color-white);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);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-700);cursor:pointer}.mrd-document-view__download.sc-mrd-document-view:hover{background:var(--mrd-color-neutral-100);color:var(--mrd-color-neutral-900)}.mrd-document-view__download.sc-mrd-document-view svg.sc-mrd-document-view{width:0.9375rem;height:0.9375rem}.mrd-document-view__summary-body.sc-mrd-document-view{font-size:var(--mrd-font-size-base);color:var(--mrd-color-neutral-700);line-height:var(--mrd-line-height-relaxed)}`;
1923
+ const mrdDocumentViewCss = () => `.sc-mrd-document-view-h{display:block}.mrd-document-view.sc-mrd-document-view{max-width:640px}.mrd-document-view__body.sc-mrd-document-view{display:flex;flex-direction:column;gap:var(--mrd-space-6)}.mrd-document-view__container.sc-mrd-document-view{display:flex;flex-direction:column;align-items:flex-start;gap:var(--mrd-space-1);margin-bottom:var(--mrd-space-6)}.mrd-document-view__container-link.sc-mrd-document-view{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-document-view__container-link.sc-mrd-document-view:hover{text-decoration:underline}.mrd-document-view__folder.sc-mrd-document-view{display:inline-flex;align-items:center;gap:var(--mrd-space-1);font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-400);word-break:break-word}.mrd-document-view__folder-icon.sc-mrd-document-view{width:0.75rem;height:0.75rem;flex-shrink:0}.mrd-document-view__title.sc-mrd-document-view{font-size:var(--mrd-font-size-2xl);font-weight:var(--mrd-font-weight-bold);color:var(--mrd-color-neutral-900);letter-spacing:-0.02em;margin:0 0 var(--mrd-space-1) 0}.mrd-document-view__date.sc-mrd-document-view{font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-400);font-variant-numeric:tabular-nums;margin:0 0 var(--mrd-space-6) 0}.mrd-document-view__file-meta.sc-mrd-document-view{display:flex;align-items:center;margin-bottom:var(--mrd-space-2)}.mrd-document-view__download.sc-mrd-document-view{display:inline-flex;align-items:center;gap:var(--mrd-space-2);flex-shrink:0;height:2rem;padding:0 var(--mrd-space-3);background:var(--mrd-color-white);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);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-700);cursor:pointer}.mrd-document-view__download.sc-mrd-document-view:hover{background:var(--mrd-color-neutral-100);color:var(--mrd-color-neutral-900)}.mrd-document-view__download.sc-mrd-document-view svg.sc-mrd-document-view{width:0.9375rem;height:0.9375rem}.mrd-document-view__summary-body.sc-mrd-document-view{font-size:var(--mrd-font-size-base);color:var(--mrd-color-neutral-700);line-height:var(--mrd-line-height-relaxed)}`;
1924
1924
 
1925
1925
  const MrdDocumentView = class {
1926
1926
  constructor(hostRef) {
@@ -1967,16 +1967,22 @@ const MrdDocumentView = class {
1967
1967
  const links = ((_d = (_c = this.data) === null || _c === void 0 ? void 0 : _c._links) !== null && _d !== void 0 ? _d : {});
1968
1968
  return links[field];
1969
1969
  }
1970
+ /** Container link (styled like relation links in layout sections: primary text
1971
+ * link) plus a muted, non-interactive folder path when present. */
1970
1972
  renderContainer() {
1971
1973
  const link = this.slotLink('container');
1972
- if (!(link === null || link === void 0 ? void 0 : link.href) || !link.name)
1974
+ const hasLink = !!((link === null || link === void 0 ? void 0 : link.href) && link.name);
1975
+ const folderRaw = this.slotValue('folder');
1976
+ const folder = folderRaw != null && folderRaw !== '' ? String(folderRaw) : null;
1977
+ if (!hasLink && !folder)
1973
1978
  return null;
1974
- return (index.h("button", { class: "mrd-document-view__crumb", onClick: () => this.mrdNavigate.emit({ href: link.href, label: link.name }) }, index.h("svg", { class: "mrd-document-view__crumb-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, index.h("path", { d: "M19 12H5M12 19l-7-7 7-7" })), link.name));
1979
+ return (index.h("div", { class: "mrd-document-view__container" }, hasLink && (index.h("button", { type: "button", class: "mrd-document-view__container-link", onClick: () => this.mrdNavigate.emit({ href: link.href, label: link.name }) }, link.name)), folder && (index.h("span", { class: "mrd-document-view__folder" }, index.h("svg", { class: "mrd-document-view__folder-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, index.h("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" })), folder))));
1975
1980
  }
1976
- /** Filename + download button — the only file-related UI this component owns;
1977
- * inline preview rendering is entirely the host's responsibility. */
1981
+ /** Download button — the only file-related UI this component owns; the filename
1982
+ * is deliberately not shown (rarely relevant, the title identifies the document)
1983
+ * and inline preview rendering is entirely the host's responsibility. */
1978
1984
  renderFileMeta(fileName, href) {
1979
- return (index.h("div", { class: "mrd-document-view__file-meta" }, index.h("span", { class: "mrd-document-view__file-name" }, fileName), href && (index.h("button", { type: "button", class: "mrd-document-view__download", onClick: () => this.mrdDownload.emit({ href, fileName }) }, index.h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, index.h("path", { d: "M12 3v12m0 0l-4-4m4 4l4-4M4 21h16" })), t('download', this.locale)))));
1985
+ return (index.h("div", { class: "mrd-document-view__file-meta" }, href && (index.h("button", { type: "button", class: "mrd-document-view__download", onClick: () => this.mrdDownload.emit({ href, fileName }) }, index.h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, index.h("path", { d: "M12 3v12m0 0l-4-4m4 4l4-4M4 21h16" })), t('download', this.locale)))));
1980
1986
  }
1981
1987
  render() {
1982
1988
  var _a, _b;
@@ -1989,7 +1995,7 @@ const MrdDocumentView = class {
1989
1995
  const fileRaw = this.slotValue('file');
1990
1996
  const fileHref = (_a = fileRaw === null || fileRaw === void 0 ? void 0 : fileRaw.href) !== null && _a !== void 0 ? _a : '';
1991
1997
  const fileName = (_b = fileRaw === null || fileRaw === void 0 ? void 0 : fileRaw.fileName) !== null && _b !== void 0 ? _b : (fileRaw ? String(fileRaw) : '');
1992
- return (index.h(index.Host, { key: 'e25995d61813ad0d285497c0abe74de0c1624cea' }, index.h("div", { key: '1d8e6c12c5db53bffd28b4bcff84a950c22cc8d8', class: "mrd-document-view" }, index.h("div", { key: 'b583648e524acd8156f92989b685b6343164738c', class: "mrd-document-view__body" }, index.h("div", { key: '8992b15a52edd64e2f0fd3269213302ab3989a20', class: "mrd-document-view__meta" }, this.renderContainer(), title && index.h("h1", { key: '0742816ed6ac927fa12410d723c9b0b8470800c7', class: "mrd-document-view__title" }, title), date && index.h("p", { key: '4803d2773ef904e3788a865db8e4653e5cb9d8df', class: "mrd-document-view__date" }, date), fileRaw && this.renderFileMeta(fileName, fileHref), summary && (index.h("div", { key: '502e9e844d474b692246e36c96245ba5321d2a9e', class: "mrd-document-view__summary" }, index.h("div", { key: 'b37d4c9cb9bc65c5abb0a4e1809e285032868e2c', class: "mrd-document-view__summary-body", innerHTML: summary }))))))));
1998
+ return (index.h(index.Host, { key: 'd4e8d4a6c5c66677df3d4e80943fc4538d9a2be7' }, index.h("div", { key: 'c67bb1742590dc3ab3cec959f20dfa9030268411', class: "mrd-document-view" }, index.h("div", { key: '5da6e15d1f67990a9ee06bc07b717e5fa17a2ee7', class: "mrd-document-view__body" }, index.h("div", { key: '0fc38933add3fff48096c48d2fb6cd06fb5d1eac', class: "mrd-document-view__meta" }, title && index.h("h1", { key: 'e9ac8d99f9afae6b64dd7e6bd461c54b92a6ea39', class: "mrd-document-view__title" }, title), date && index.h("p", { key: '8591d77b300ed3c021cfa64b8e9564dee98199cd', class: "mrd-document-view__date" }, date), this.renderContainer(), fileRaw && this.renderFileMeta(fileName, fileHref), summary && (index.h("div", { key: '8a6d630afcf187fa86c9bab77d06d93695fd5c9f', class: "mrd-document-view__summary" }, index.h("div", { key: 'bd98e2cf740d08837accd8d260973d4e51cd24f7', class: "mrd-document-view__summary-body", innerHTML: summary }))))))));
1993
1999
  }
1994
2000
  static get watchers() { return {
1995
2001
  "data": [{
@@ -4164,14 +4170,11 @@ const TableCell = ({ col, row, locale, onDownload, onOpenTextblock, onOpenJson }
4164
4170
  };
4165
4171
  /** Formats the aggregation total for one column, '' when not applicable. */
4166
4172
  function formatAggregationValue(col, aggregations, locale) {
4167
- var _a;
4173
+ var _a, _b;
4168
4174
  if (col.type !== 'FIELD' || !col.aggregate || !aggregations)
4169
4175
  return '';
4170
4176
  const fn = col.aggregate.toLowerCase();
4171
- const aggData = aggregations[fn];
4172
- const val = typeof aggData === 'object' && aggData !== null
4173
- ? aggData[(_a = col.name) !== null && _a !== void 0 ? _a : '']
4174
- : undefined;
4177
+ const val = (_a = aggregations[fn]) === null || _a === void 0 ? void 0 : _a[(_b = col.name) !== null && _b !== void 0 ? _b : ''];
4175
4178
  if (val == null)
4176
4179
  return '';
4177
4180
  const dt = col.dataType;
@@ -4576,10 +4579,8 @@ const MrdTable = class {
4576
4579
  }
4577
4580
  /** Inject aggregation totals returned by the /aggregations endpoint. */
4578
4581
  async setAggregations(data) {
4579
- var _a;
4580
- const total = (_a = data.total) !== null && _a !== void 0 ? _a : (typeof data.count === 'number' ? data.count : undefined);
4581
- if (total != null)
4582
- this.aggregationsTotal = total;
4582
+ if (data.total != null)
4583
+ this.aggregationsTotal = data.total;
4583
4584
  this.aggregations = data;
4584
4585
  }
4585
4586
  // ── Lifecycle ──────────────────────────────────────────────────────────────
@@ -10,26 +10,38 @@
10
10
  flex-direction: column;
11
11
  gap: var(--mrd-space-6);
12
12
  }
13
- .mrd-document-view__crumb {
14
- display: inline-flex;
15
- align-items: center;
16
- gap: var(--mrd-space-2);
17
- margin-bottom: var(--mrd-space-4);
18
- padding: var(--mrd-space-1) var(--mrd-space-3);
19
- background: var(--mrd-color-primary-light);
20
- border: 1px solid transparent;
21
- border-radius: var(--mrd-border-radius);
13
+ .mrd-document-view__container {
14
+ display: flex;
15
+ flex-direction: column;
16
+ align-items: flex-start;
17
+ gap: var(--mrd-space-1);
18
+ margin-bottom: var(--mrd-space-6);
19
+ }
20
+ .mrd-document-view__container-link {
21
+ background: none;
22
+ border: none;
23
+ padding: 0;
22
24
  font-family: var(--mrd-font-family);
23
25
  font-size: var(--mrd-font-size-sm);
24
- color: var(--mrd-color-primary-dark);
26
+ font-weight: var(--mrd-font-weight-semibold);
27
+ color: var(--mrd-color-primary);
25
28
  cursor: pointer;
29
+ text-align: left;
26
30
  }
27
- .mrd-document-view__crumb:hover {
28
- border-color: var(--mrd-color-primary);
31
+ .mrd-document-view__container-link:hover {
32
+ text-decoration: underline;
29
33
  }
30
- .mrd-document-view__crumb-icon {
31
- width: 0.875rem;
32
- height: 0.875rem;
34
+ .mrd-document-view__folder {
35
+ display: inline-flex;
36
+ align-items: center;
37
+ gap: var(--mrd-space-1);
38
+ font-size: var(--mrd-font-size-xs);
39
+ color: var(--mrd-color-neutral-400);
40
+ word-break: break-word;
41
+ }
42
+ .mrd-document-view__folder-icon {
43
+ width: 0.75rem;
44
+ height: 0.75rem;
33
45
  flex-shrink: 0;
34
46
  }
35
47
  .mrd-document-view__title {
@@ -48,17 +60,8 @@
48
60
  .mrd-document-view__file-meta {
49
61
  display: flex;
50
62
  align-items: center;
51
- gap: var(--mrd-space-4);
52
63
  margin-bottom: var(--mrd-space-2);
53
64
  }
54
- .mrd-document-view__file-name {
55
- flex: 1;
56
- min-width: 0;
57
- font-weight: var(--mrd-font-weight-semibold);
58
- font-size: var(--mrd-font-size-sm);
59
- color: var(--mrd-color-neutral-800);
60
- word-break: break-word;
61
- }
62
65
  .mrd-document-view__download {
63
66
  display: inline-flex;
64
67
  align-items: center;
@@ -4,9 +4,10 @@ import { formatDate } from "../../../utils/format";
4
4
  import { attachmentsFromRecord } from "../../../utils/document-attachments";
5
5
  /**
6
6
  * Archetype-driven single-document view. Given a `commons.document` binding and a
7
- * data record, renders the document recognisably — title, filename/download,
8
- * summary and date — plus a navigation link to the container (the dossier),
9
- * instead of a generic field form.
7
+ * data record, renders the document recognisably — title, date, a navigation
8
+ * link to the container (the dossier) presented like any other data-object link
9
+ * (primary-coloured text link), an optional muted folder path, a download button
10
+ * and summary — instead of a generic field form.
10
11
  *
11
12
  * The component keys on the slot→field map (`archetype.slots`) to locate values:
12
13
  * value slots read `data[field]`; the `container` relation slot reads
@@ -59,16 +60,22 @@ export class MrdDocumentView {
59
60
  const links = ((_d = (_c = this.data) === null || _c === void 0 ? void 0 : _c._links) !== null && _d !== void 0 ? _d : {});
60
61
  return links[field];
61
62
  }
63
+ /** Container link (styled like relation links in layout sections: primary text
64
+ * link) plus a muted, non-interactive folder path when present. */
62
65
  renderContainer() {
63
66
  const link = this.slotLink('container');
64
- if (!(link === null || link === void 0 ? void 0 : link.href) || !link.name)
67
+ const hasLink = !!((link === null || link === void 0 ? void 0 : link.href) && link.name);
68
+ const folderRaw = this.slotValue('folder');
69
+ const folder = folderRaw != null && folderRaw !== '' ? String(folderRaw) : null;
70
+ if (!hasLink && !folder)
65
71
  return null;
66
- return (h("button", { class: "mrd-document-view__crumb", onClick: () => this.mrdNavigate.emit({ href: link.href, label: link.name }) }, h("svg", { class: "mrd-document-view__crumb-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M19 12H5M12 19l-7-7 7-7" })), link.name));
72
+ return (h("div", { class: "mrd-document-view__container" }, hasLink && (h("button", { type: "button", class: "mrd-document-view__container-link", onClick: () => this.mrdNavigate.emit({ href: link.href, label: link.name }) }, link.name)), folder && (h("span", { class: "mrd-document-view__folder" }, h("svg", { class: "mrd-document-view__folder-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("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" })), folder))));
67
73
  }
68
- /** Filename + download button — the only file-related UI this component owns;
69
- * inline preview rendering is entirely the host's responsibility. */
74
+ /** Download button — the only file-related UI this component owns; the filename
75
+ * is deliberately not shown (rarely relevant, the title identifies the document)
76
+ * and inline preview rendering is entirely the host's responsibility. */
70
77
  renderFileMeta(fileName, href) {
71
- return (h("div", { class: "mrd-document-view__file-meta" }, h("span", { class: "mrd-document-view__file-name" }, fileName), href && (h("button", { type: "button", class: "mrd-document-view__download", onClick: () => this.mrdDownload.emit({ href, fileName }) }, h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M12 3v12m0 0l-4-4m4 4l4-4M4 21h16" })), t('download', this.locale)))));
78
+ return (h("div", { class: "mrd-document-view__file-meta" }, href && (h("button", { type: "button", class: "mrd-document-view__download", onClick: () => this.mrdDownload.emit({ href, fileName }) }, h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M12 3v12m0 0l-4-4m4 4l4-4M4 21h16" })), t('download', this.locale)))));
72
79
  }
73
80
  render() {
74
81
  var _a, _b;
@@ -81,7 +88,7 @@ export class MrdDocumentView {
81
88
  const fileRaw = this.slotValue('file');
82
89
  const fileHref = (_a = fileRaw === null || fileRaw === void 0 ? void 0 : fileRaw.href) !== null && _a !== void 0 ? _a : '';
83
90
  const fileName = (_b = fileRaw === null || fileRaw === void 0 ? void 0 : fileRaw.fileName) !== null && _b !== void 0 ? _b : (fileRaw ? String(fileRaw) : '');
84
- return (h(Host, { key: 'e25995d61813ad0d285497c0abe74de0c1624cea' }, h("div", { key: '1d8e6c12c5db53bffd28b4bcff84a950c22cc8d8', class: "mrd-document-view" }, h("div", { key: 'b583648e524acd8156f92989b685b6343164738c', class: "mrd-document-view__body" }, h("div", { key: '8992b15a52edd64e2f0fd3269213302ab3989a20', class: "mrd-document-view__meta" }, this.renderContainer(), title && h("h1", { key: '0742816ed6ac927fa12410d723c9b0b8470800c7', class: "mrd-document-view__title" }, title), date && h("p", { key: '4803d2773ef904e3788a865db8e4653e5cb9d8df', class: "mrd-document-view__date" }, date), fileRaw && this.renderFileMeta(fileName, fileHref), summary && (h("div", { key: '502e9e844d474b692246e36c96245ba5321d2a9e', class: "mrd-document-view__summary" }, h("div", { key: 'b37d4c9cb9bc65c5abb0a4e1809e285032868e2c', class: "mrd-document-view__summary-body", innerHTML: summary }))))))));
91
+ return (h(Host, { key: 'd4e8d4a6c5c66677df3d4e80943fc4538d9a2be7' }, h("div", { key: 'c67bb1742590dc3ab3cec959f20dfa9030268411', class: "mrd-document-view" }, h("div", { key: '5da6e15d1f67990a9ee06bc07b717e5fa17a2ee7', class: "mrd-document-view__body" }, h("div", { key: '0fc38933add3fff48096c48d2fb6cd06fb5d1eac', class: "mrd-document-view__meta" }, title && h("h1", { key: 'e9ac8d99f9afae6b64dd7e6bd461c54b92a6ea39', class: "mrd-document-view__title" }, title), date && h("p", { key: '8591d77b300ed3c021cfa64b8e9564dee98199cd', class: "mrd-document-view__date" }, date), this.renderContainer(), fileRaw && this.renderFileMeta(fileName, fileHref), summary && (h("div", { key: '8a6d630afcf187fa86c9bab77d06d93695fd5c9f', class: "mrd-document-view__summary" }, h("div", { key: 'bd98e2cf740d08837accd8d260973d4e51cd24f7', class: "mrd-document-view__summary-body", innerHTML: summary }))))))));
85
92
  }
86
93
  static get is() { return "mrd-document-view"; }
87
94
  static get encapsulation() { return "scoped"; }
@@ -198,10 +198,8 @@ export class MrdTable {
198
198
  }
199
199
  /** Inject aggregation totals returned by the /aggregations endpoint. */
200
200
  async setAggregations(data) {
201
- var _a;
202
- const total = (_a = data.total) !== null && _a !== void 0 ? _a : (typeof data.count === 'number' ? data.count : undefined);
203
- if (total != null)
204
- this.aggregationsTotal = total;
201
+ if (data.total != null)
202
+ this.aggregationsTotal = data.total;
205
203
  this.aggregations = data;
206
204
  }
207
205
  // ── Lifecycle ──────────────────────────────────────────────────────────────
@@ -46,14 +46,11 @@ export const TableCell = ({ col, row, locale, onDownload, onOpenTextblock, onOpe
46
46
  };
47
47
  /** Formats the aggregation total for one column, '' when not applicable. */
48
48
  export function formatAggregationValue(col, aggregations, locale) {
49
- var _a;
49
+ var _a, _b;
50
50
  if (col.type !== 'FIELD' || !col.aggregate || !aggregations)
51
51
  return '';
52
52
  const fn = col.aggregate.toLowerCase();
53
- const aggData = aggregations[fn];
54
- const val = typeof aggData === 'object' && aggData !== null
55
- ? aggData[(_a = col.name) !== null && _a !== void 0 ? _a : '']
56
- : undefined;
53
+ const val = (_a = aggregations[fn]) === null || _a === void 0 ? void 0 : _a[(_b = col.name) !== null && _b !== void 0 ? _b : ''];
57
54
  if (val == null)
58
55
  return '';
59
56
  const dt = col.dataType;
@@ -428,7 +428,7 @@ window.EXAMPLE_FIELD_TYPES_DATA = {
428
428
 
429
429
  window.EXAMPLE_DOCUMENT_ARCHETYPE = {
430
430
  archetype: 'commons.document',
431
- slots: { title: 'name', date: 'createdDate', summary: 'description', file: 'file', container: 'dossier' },
431
+ slots: { title: 'name', date: 'createdDate', summary: 'description', file: 'file', container: 'dossier', folder: 'folder' },
432
432
  };
433
433
 
434
434
  window.EXAMPLE_DOCUMENT_DATA = {
@@ -436,6 +436,7 @@ window.EXAMPLE_DOCUMENT_DATA = {
436
436
  createdDate: '2026-03-14',
437
437
  description: '<p>Signed engagement contract for the FY2026 period. Reviewed and countersigned by both parties.</p>',
438
438
  file: { href: '/data/demo/documents/1/file', fileName: 'contract-2026-acme.pdf' },
439
+ folder: 'correspondence/2026',
439
440
  _links: {
440
441
  dossier: { href: '/data/demo/dossiers/42', name: 'Acme Corp — Dossier 2026' },
441
442
  },
@@ -1 +1 @@
1
- import{proxyCustomElement as e,HTMLElement as r,createEvent as d,h as t,Host as o,transformTag as i}from"@stencil/core/internal/client";import{t as n}from"./i18n.js";import{f as a}from"./format.js";import{a as m}from"./document-attachments.js";const c=e(class extends r{constructor(e){super(),!1!==e&&this.__registerHost(),this.mrdNavigate=d(this,"mrdNavigate",7),this.mrdDownload=d(this,"mrdDownload",7),this.mrdAttachments=d(this,"mrdAttachments",7),this.data={},this.locale=navigator.language,this.lastAttachmentHref=null}componentDidLoad(){this.emitAttachmentsIfNeeded()}dataChanged(){this.emitAttachmentsIfNeeded()}emitAttachmentsIfNeeded(){var e,r;const d=m(this.archetype,this.data),t=null!==(r=null===(e=d[0])||void 0===e?void 0:e.href)&&void 0!==r?r:null;t!==this.lastAttachmentHref&&(this.lastAttachmentHref=t,this.mrdAttachments.emit({attachments:d}))}slotValue(e){var r,d;const t=null===(d=null===(r=this.archetype)||void 0===r?void 0:r.slots)||void 0===d?void 0:d[e];if(t)return this.data[t]}slotLink(e){var r,d,t,o;const i=null===(d=null===(r=this.archetype)||void 0===r?void 0:r.slots)||void 0===d?void 0:d[e];if(i)return(null!==(o=null===(t=this.data)||void 0===t?void 0:t._links)&&void 0!==o?o:{})[i]}renderContainer(){const e=this.slotLink("container");return(null==e?void 0:e.href)&&e.name?t("button",{class:"mrd-document-view__crumb",onClick:()=>this.mrdNavigate.emit({href:e.href,label:e.name})},t("svg",{class:"mrd-document-view__crumb-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},t("path",{d:"M19 12H5M12 19l-7-7 7-7"})),e.name):null}renderFileMeta(e,r){return t("div",{class:"mrd-document-view__file-meta"},t("span",{class:"mrd-document-view__file-name"},e),r&&t("button",{type:"button",class:"mrd-document-view__download",onClick:()=>this.mrdDownload.emit({href:r,fileName:e})},t("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},t("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M4 21h16"})),n("download",this.locale)))}render(){var e,r;const d=this.slotValue("title"),i=null!=d&&""!==d?String(d):null,n=this.slotValue("date"),m=null!=n&&""!==n?a(n,this.locale):null,c=this.slotValue("summary"),s=null!=c&&""!==c?String(c):null,l=this.slotValue("file"),u=null!==(e=null==l?void 0:l.href)&&void 0!==e?e:"",v=null!==(r=null==l?void 0:l.fileName)&&void 0!==r?r:l?String(l):"";return t(o,{key:"e25995d61813ad0d285497c0abe74de0c1624cea"},t("div",{key:"1d8e6c12c5db53bffd28b4bcff84a950c22cc8d8",class:"mrd-document-view"},t("div",{key:"b583648e524acd8156f92989b685b6343164738c",class:"mrd-document-view__body"},t("div",{key:"8992b15a52edd64e2f0fd3269213302ab3989a20",class:"mrd-document-view__meta"},this.renderContainer(),i&&t("h1",{key:"0742816ed6ac927fa12410d723c9b0b8470800c7",class:"mrd-document-view__title"},i),m&&t("p",{key:"4803d2773ef904e3788a865db8e4653e5cb9d8df",class:"mrd-document-view__date"},m),l&&this.renderFileMeta(v,u),s&&t("div",{key:"502e9e844d474b692246e36c96245ba5321d2a9e",class:"mrd-document-view__summary"},t("div",{key:"b37d4c9cb9bc65c5abb0a4e1809e285032868e2c",class:"mrd-document-view__summary-body",innerHTML:s}))))))}static get watchers(){return{data:[{dataChanged:0}]}}static get style(){return".sc-mrd-document-view-h{display:block}.mrd-document-view.sc-mrd-document-view{max-width:640px}.mrd-document-view__body.sc-mrd-document-view{display:flex;flex-direction:column;gap:var(--mrd-space-6)}.mrd-document-view__crumb.sc-mrd-document-view{display:inline-flex;align-items:center;gap:var(--mrd-space-2);margin-bottom:var(--mrd-space-4);padding:var(--mrd-space-1) var(--mrd-space-3);background:var(--mrd-color-primary-light);border:1px solid transparent;border-radius:var(--mrd-border-radius);font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-primary-dark);cursor:pointer}.mrd-document-view__crumb.sc-mrd-document-view:hover{border-color:var(--mrd-color-primary)}.mrd-document-view__crumb-icon.sc-mrd-document-view{width:0.875rem;height:0.875rem;flex-shrink:0}.mrd-document-view__title.sc-mrd-document-view{font-size:var(--mrd-font-size-2xl);font-weight:var(--mrd-font-weight-bold);color:var(--mrd-color-neutral-900);letter-spacing:-0.02em;margin:0 0 var(--mrd-space-1) 0}.mrd-document-view__date.sc-mrd-document-view{font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-400);font-variant-numeric:tabular-nums;margin:0 0 var(--mrd-space-6) 0}.mrd-document-view__file-meta.sc-mrd-document-view{display:flex;align-items:center;gap:var(--mrd-space-4);margin-bottom:var(--mrd-space-2)}.mrd-document-view__file-name.sc-mrd-document-view{flex:1;min-width:0;font-weight:var(--mrd-font-weight-semibold);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800);word-break:break-word}.mrd-document-view__download.sc-mrd-document-view{display:inline-flex;align-items:center;gap:var(--mrd-space-2);flex-shrink:0;height:2rem;padding:0 var(--mrd-space-3);background:var(--mrd-color-white);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);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-700);cursor:pointer}.mrd-document-view__download.sc-mrd-document-view:hover{background:var(--mrd-color-neutral-100);color:var(--mrd-color-neutral-900)}.mrd-document-view__download.sc-mrd-document-view svg.sc-mrd-document-view{width:0.9375rem;height:0.9375rem}.mrd-document-view__summary-body.sc-mrd-document-view{font-size:var(--mrd-font-size-base);color:var(--mrd-color-neutral-700);line-height:var(--mrd-line-height-relaxed)}"}},[2,"mrd-document-view",{archetype:[16],data:[16],locale:[1]},void 0,{data:[{dataChanged:0}]}]);function s(){"undefined"!=typeof customElements&&["mrd-document-view"].forEach((e=>{"mrd-document-view"===e&&(customElements.get(i(e))||customElements.define(i(e),c))}))}export{c as M,s as d}
1
+ import{proxyCustomElement as e,HTMLElement as r,createEvent as d,h as t,Host as i,transformTag as o}from"@stencil/core/internal/client";import{t as n}from"./i18n.js";import{f as a}from"./format.js";import{a as m}from"./document-attachments.js";const c=e(class extends r{constructor(e){super(),!1!==e&&this.__registerHost(),this.mrdNavigate=d(this,"mrdNavigate",7),this.mrdDownload=d(this,"mrdDownload",7),this.mrdAttachments=d(this,"mrdAttachments",7),this.data={},this.locale=navigator.language,this.lastAttachmentHref=null}componentDidLoad(){this.emitAttachmentsIfNeeded()}dataChanged(){this.emitAttachmentsIfNeeded()}emitAttachmentsIfNeeded(){var e,r;const d=m(this.archetype,this.data),t=null!==(r=null===(e=d[0])||void 0===e?void 0:e.href)&&void 0!==r?r:null;t!==this.lastAttachmentHref&&(this.lastAttachmentHref=t,this.mrdAttachments.emit({attachments:d}))}slotValue(e){var r,d;const t=null===(d=null===(r=this.archetype)||void 0===r?void 0:r.slots)||void 0===d?void 0:d[e];if(t)return this.data[t]}slotLink(e){var r,d,t,i;const o=null===(d=null===(r=this.archetype)||void 0===r?void 0:r.slots)||void 0===d?void 0:d[e];if(o)return(null!==(i=null===(t=this.data)||void 0===t?void 0:t._links)&&void 0!==i?i:{})[o]}renderContainer(){const e=this.slotLink("container"),r=!(!(null==e?void 0:e.href)||!e.name),d=this.slotValue("folder"),i=null!=d&&""!==d?String(d):null;return r||i?t("div",{class:"mrd-document-view__container"},r&&t("button",{type:"button",class:"mrd-document-view__container-link",onClick:()=>this.mrdNavigate.emit({href:e.href,label:e.name})},e.name),i&&t("span",{class:"mrd-document-view__folder"},t("svg",{class:"mrd-document-view__folder-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},t("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"})),i)):null}renderFileMeta(e,r){return t("div",{class:"mrd-document-view__file-meta"},r&&t("button",{type:"button",class:"mrd-document-view__download",onClick:()=>this.mrdDownload.emit({href:r,fileName:e})},t("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},t("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M4 21h16"})),n("download",this.locale)))}render(){var e,r;const d=this.slotValue("title"),o=null!=d&&""!==d?String(d):null,n=this.slotValue("date"),m=null!=n&&""!==n?a(n,this.locale):null,c=this.slotValue("summary"),l=null!=c&&""!==c?String(c):null,s=this.slotValue("file"),u=null!==(e=null==s?void 0:s.href)&&void 0!==e?e:"",v=null!==(r=null==s?void 0:s.fileName)&&void 0!==r?r:s?String(s):"";return t(i,{key:"d4e8d4a6c5c66677df3d4e80943fc4538d9a2be7"},t("div",{key:"c67bb1742590dc3ab3cec959f20dfa9030268411",class:"mrd-document-view"},t("div",{key:"5da6e15d1f67990a9ee06bc07b717e5fa17a2ee7",class:"mrd-document-view__body"},t("div",{key:"0fc38933add3fff48096c48d2fb6cd06fb5d1eac",class:"mrd-document-view__meta"},o&&t("h1",{key:"e9ac8d99f9afae6b64dd7e6bd461c54b92a6ea39",class:"mrd-document-view__title"},o),m&&t("p",{key:"8591d77b300ed3c021cfa64b8e9564dee98199cd",class:"mrd-document-view__date"},m),this.renderContainer(),s&&this.renderFileMeta(v,u),l&&t("div",{key:"8a6d630afcf187fa86c9bab77d06d93695fd5c9f",class:"mrd-document-view__summary"},t("div",{key:"bd98e2cf740d08837accd8d260973d4e51cd24f7",class:"mrd-document-view__summary-body",innerHTML:l}))))))}static get watchers(){return{data:[{dataChanged:0}]}}static get style(){return".sc-mrd-document-view-h{display:block}.mrd-document-view.sc-mrd-document-view{max-width:640px}.mrd-document-view__body.sc-mrd-document-view{display:flex;flex-direction:column;gap:var(--mrd-space-6)}.mrd-document-view__container.sc-mrd-document-view{display:flex;flex-direction:column;align-items:flex-start;gap:var(--mrd-space-1);margin-bottom:var(--mrd-space-6)}.mrd-document-view__container-link.sc-mrd-document-view{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-document-view__container-link.sc-mrd-document-view:hover{text-decoration:underline}.mrd-document-view__folder.sc-mrd-document-view{display:inline-flex;align-items:center;gap:var(--mrd-space-1);font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-400);word-break:break-word}.mrd-document-view__folder-icon.sc-mrd-document-view{width:0.75rem;height:0.75rem;flex-shrink:0}.mrd-document-view__title.sc-mrd-document-view{font-size:var(--mrd-font-size-2xl);font-weight:var(--mrd-font-weight-bold);color:var(--mrd-color-neutral-900);letter-spacing:-0.02em;margin:0 0 var(--mrd-space-1) 0}.mrd-document-view__date.sc-mrd-document-view{font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-400);font-variant-numeric:tabular-nums;margin:0 0 var(--mrd-space-6) 0}.mrd-document-view__file-meta.sc-mrd-document-view{display:flex;align-items:center;margin-bottom:var(--mrd-space-2)}.mrd-document-view__download.sc-mrd-document-view{display:inline-flex;align-items:center;gap:var(--mrd-space-2);flex-shrink:0;height:2rem;padding:0 var(--mrd-space-3);background:var(--mrd-color-white);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);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-700);cursor:pointer}.mrd-document-view__download.sc-mrd-document-view:hover{background:var(--mrd-color-neutral-100);color:var(--mrd-color-neutral-900)}.mrd-document-view__download.sc-mrd-document-view svg.sc-mrd-document-view{width:0.9375rem;height:0.9375rem}.mrd-document-view__summary-body.sc-mrd-document-view{font-size:var(--mrd-font-size-base);color:var(--mrd-color-neutral-700);line-height:var(--mrd-line-height-relaxed)}"}},[2,"mrd-document-view",{archetype:[16],data:[16],locale:[1]},void 0,{data:[{dataChanged:0}]}]);function l(){"undefined"!=typeof customElements&&["mrd-document-view"].forEach((e=>{"mrd-document-view"===e&&(customElements.get(o(e))||customElements.define(o(e),c))}))}export{c as M,l as d}