@mmlogic/components 0.3.11 → 0.4.0

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 (138) hide show
  1. package/dist/cjs/{index-BPj2cBXs.js → index-CAzwGt9u.js} +38 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mosterdcomponents.cjs.js +1 -1
  4. package/dist/cjs/mrd-boolean-field_23.cjs.entry.js +1203 -1084
  5. package/dist/collection/collection-manifest.json +23 -23
  6. package/dist/collection/components/{mrd-document-container/mrd-document-container.scss → documents/mrd-document-container/mrd-document-container.css} +3 -3
  7. package/dist/collection/components/{mrd-document-container → documents/mrd-document-container}/mrd-document-container.js +7 -7
  8. package/dist/collection/components/documents/mrd-document-list/folder-tree.js +109 -0
  9. package/dist/collection/components/{mrd-document-list/mrd-document-list.scss → documents/mrd-document-list/mrd-document-list.css} +6 -4
  10. package/dist/collection/components/{mrd-document-list → documents/mrd-document-list}/mrd-document-list.js +83 -240
  11. package/dist/collection/components/documents/mrd-document-list/tree-view.js +75 -0
  12. package/dist/collection/components/{mrd-document-view/mrd-document-view.scss → documents/mrd-document-view/mrd-document-view.css} +1 -1
  13. package/dist/collection/components/{mrd-document-view → documents/mrd-document-view}/mrd-document-view.js +4 -4
  14. package/dist/collection/components/fields/field-helpers.js +17 -0
  15. package/dist/collection/components/fields/file-upload-common.js +38 -0
  16. package/dist/collection/components/{mrd-boolean-field/mrd-boolean-field.scss → fields/mrd-boolean-field/mrd-boolean-field.css} +3 -3
  17. package/dist/collection/components/{mrd-boolean-field → fields/mrd-boolean-field}/mrd-boolean-field.js +1 -1
  18. package/dist/collection/components/{mrd-currency-field/mrd-currency-field.scss → fields/mrd-currency-field/mrd-currency-field.css} +11 -9
  19. package/dist/collection/components/{mrd-currency-field → fields/mrd-currency-field}/mrd-currency-field.js +7 -13
  20. package/dist/collection/components/{mrd-date-field/mrd-date-field.scss → fields/mrd-date-field/mrd-date-field.css} +8 -10
  21. package/dist/collection/components/{mrd-date-field → fields/mrd-date-field}/mrd-date-field.js +3 -10
  22. package/dist/collection/components/{mrd-datetime-field/mrd-datetime-field.scss → fields/mrd-datetime-field/mrd-datetime-field.css} +8 -10
  23. package/dist/collection/components/{mrd-datetime-field → fields/mrd-datetime-field}/mrd-datetime-field.js +3 -10
  24. package/dist/collection/components/{mrd-email-field/mrd-email-field.scss → fields/mrd-email-field/mrd-email-field.css} +2 -11
  25. package/dist/collection/components/{mrd-email-field → fields/mrd-email-field}/mrd-email-field.js +6 -13
  26. package/dist/collection/components/{mrd-file-field/mrd-file-field.scss → fields/mrd-file-field/mrd-file-field.css} +19 -24
  27. package/dist/collection/components/{mrd-file-field → fields/mrd-file-field}/mrd-file-field.js +13 -24
  28. package/dist/collection/components/{mrd-hyperlink-field/mrd-hyperlink-field.scss → fields/mrd-hyperlink-field/mrd-hyperlink-field.css} +7 -16
  29. package/dist/collection/components/{mrd-hyperlink-field → fields/mrd-hyperlink-field}/mrd-hyperlink-field.js +9 -15
  30. package/dist/collection/components/{mrd-image-field/mrd-image-field.scss → fields/mrd-image-field/mrd-image-field.css} +15 -24
  31. package/dist/collection/components/{mrd-image-field → fields/mrd-image-field}/mrd-image-field.js +13 -28
  32. package/dist/collection/components/{mrd-list-field/mrd-list-field.scss → fields/mrd-list-field/mrd-list-field.css} +18 -21
  33. package/dist/collection/components/{mrd-list-field → fields/mrd-list-field}/mrd-list-field.js +10 -25
  34. package/dist/collection/components/{mrd-longtext-field/mrd-longtext-field.scss → fields/mrd-longtext-field/mrd-longtext-field.css} +21 -18
  35. package/dist/collection/components/{mrd-longtext-field → fields/mrd-longtext-field}/mrd-longtext-field.js +3 -10
  36. package/dist/collection/components/{mrd-number-field/mrd-number-field.scss → fields/mrd-number-field/mrd-number-field.css} +9 -10
  37. package/dist/collection/components/{mrd-number-field → fields/mrd-number-field}/mrd-number-field.js +7 -6
  38. package/dist/collection/components/{mrd-relation-field/mrd-relation-field.scss → fields/mrd-relation-field/mrd-relation-field.css} +61 -59
  39. package/dist/collection/components/{mrd-relation-field → fields/mrd-relation-field}/mrd-relation-field.js +16 -26
  40. package/dist/collection/components/{mrd-secret-field/mrd-secret-field.scss → fields/mrd-secret-field/mrd-secret-field.css} +7 -10
  41. package/dist/collection/components/{mrd-secret-field → fields/mrd-secret-field}/mrd-secret-field.js +4 -11
  42. package/dist/collection/components/{mrd-text-field/mrd-text-field.scss → fields/mrd-text-field/mrd-text-field.css} +2 -11
  43. package/dist/collection/components/{mrd-text-field → fields/mrd-text-field}/mrd-text-field.js +3 -10
  44. package/dist/collection/components/{mrd-textarea-field/mrd-textarea-field.scss → fields/mrd-textarea-field/mrd-textarea-field.css} +7 -10
  45. package/dist/collection/components/{mrd-textarea-field → fields/mrd-textarea-field}/mrd-textarea-field.js +3 -9
  46. package/dist/collection/components/{mrd-time-field/mrd-time-field.scss → fields/mrd-time-field/mrd-time-field.css} +8 -10
  47. package/dist/collection/components/{mrd-time-field → fields/mrd-time-field}/mrd-time-field.js +3 -10
  48. package/dist/collection/components/{mrd-field/mrd-field.scss → form/mrd-field/mrd-field.css} +1 -1
  49. package/dist/collection/components/{mrd-field → form/mrd-field}/mrd-field.js +3 -3
  50. package/dist/collection/components/{mrd-form/mrd-form.scss → form/mrd-form/mrd-form.css} +1 -1
  51. package/dist/collection/components/{mrd-form → form/mrd-form}/mrd-form.js +5 -5
  52. package/dist/collection/components/layout/mrd-layout-section/field-value.js +111 -0
  53. package/dist/collection/components/layout/mrd-layout-section/layout-helpers.js +29 -0
  54. package/dist/collection/components/{mrd-layout-section/mrd-layout-section.scss → layout/mrd-layout-section/mrd-layout-section.css} +4 -4
  55. package/dist/collection/components/{mrd-layout-section → layout/mrd-layout-section}/mrd-layout-section.js +52 -142
  56. package/dist/collection/components/{mrd-table/mrd-table.scss → table/mrd-table/mrd-table.css} +11 -13
  57. package/dist/collection/components/{mrd-table → table/mrd-table}/mrd-table.js +111 -439
  58. package/dist/collection/components/table/mrd-table/table-filter-popup.js +85 -0
  59. package/dist/collection/components/table/mrd-table/table-parts.js +110 -0
  60. package/dist/collection/components/table/mrd-table/table-query.js +178 -0
  61. package/dist/collection/components/table/mrd-table/virtual-scroll.js +49 -0
  62. package/dist/collection/dev/app.js +19 -18
  63. package/dist/collection/dev/example-data.js +58 -43
  64. package/dist/collection/utils/i18n.js +8 -0
  65. package/dist/collection/utils/query-params.js +43 -0
  66. package/dist/components/field-helpers.js +1 -0
  67. package/dist/components/file-upload-common.js +1 -0
  68. package/dist/components/i18n.js +1 -1
  69. package/dist/components/mrd-boolean-field2.js +1 -1
  70. package/dist/components/mrd-currency-field2.js +1 -1
  71. package/dist/components/mrd-date-field2.js +1 -1
  72. package/dist/components/mrd-datetime-field2.js +1 -1
  73. package/dist/components/mrd-document-container2.js +1 -1
  74. package/dist/components/mrd-document-list2.js +1 -1
  75. package/dist/components/mrd-document-view2.js +1 -1
  76. package/dist/components/mrd-email-field2.js +1 -1
  77. package/dist/components/mrd-file-field2.js +1 -1
  78. package/dist/components/mrd-form.js +1 -1
  79. package/dist/components/mrd-hyperlink-field2.js +1 -1
  80. package/dist/components/mrd-image-field2.js +1 -1
  81. package/dist/components/mrd-layout-section.js +1 -1
  82. package/dist/components/mrd-list-field2.js +1 -1
  83. package/dist/components/mrd-longtext-field2.js +1 -1
  84. package/dist/components/mrd-number-field2.js +1 -1
  85. package/dist/components/mrd-relation-field2.js +1 -1
  86. package/dist/components/mrd-secret-field2.js +1 -1
  87. package/dist/components/mrd-table2.js +1 -1
  88. package/dist/components/mrd-text-field2.js +1 -1
  89. package/dist/components/mrd-textarea-field2.js +1 -1
  90. package/dist/components/mrd-time-field2.js +1 -1
  91. package/dist/components/query-params.js +1 -0
  92. package/dist/esm/{index-_tsCCkAi.js → index-DiSEJMA8.js} +38 -1
  93. package/dist/esm/loader.js +2 -2
  94. package/dist/esm/mosterdcomponents.js +2 -2
  95. package/dist/esm/mrd-boolean-field_23.entry.js +1203 -1084
  96. package/dist/mosterdcomponents/mosterdcomponents.css +1 -1
  97. package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
  98. package/dist/mosterdcomponents/p-9b3c0917.entry.js +1 -0
  99. package/dist/mosterdcomponents/p-DiSEJMA8.js +2 -0
  100. package/dist/types/components/{mrd-document-container → documents/mrd-document-container}/mrd-document-container.d.ts +2 -2
  101. package/dist/types/components/documents/mrd-document-list/folder-tree.d.ts +66 -0
  102. package/dist/types/components/{mrd-document-list → documents/mrd-document-list}/mrd-document-list.d.ts +4 -37
  103. package/dist/types/components/documents/mrd-document-list/tree-view.d.ts +32 -0
  104. package/dist/types/components/{mrd-document-view → documents/mrd-document-view}/mrd-document-view.d.ts +2 -2
  105. package/dist/types/components/fields/field-helpers.d.ts +18 -0
  106. package/dist/types/components/fields/file-upload-common.d.ts +18 -0
  107. package/dist/types/components/{mrd-boolean-field → fields/mrd-boolean-field}/mrd-boolean-field.d.ts +1 -1
  108. package/dist/types/components/{mrd-currency-field → fields/mrd-currency-field}/mrd-currency-field.d.ts +2 -2
  109. package/dist/types/components/{mrd-date-field → fields/mrd-date-field}/mrd-date-field.d.ts +1 -1
  110. package/dist/types/components/{mrd-datetime-field → fields/mrd-datetime-field}/mrd-datetime-field.d.ts +1 -1
  111. package/dist/types/components/{mrd-email-field → fields/mrd-email-field}/mrd-email-field.d.ts +1 -1
  112. package/dist/types/components/{mrd-file-field → fields/mrd-file-field}/mrd-file-field.d.ts +2 -4
  113. package/dist/types/components/{mrd-hyperlink-field → fields/mrd-hyperlink-field}/mrd-hyperlink-field.d.ts +2 -2
  114. package/dist/types/components/{mrd-image-field → fields/mrd-image-field}/mrd-image-field.d.ts +2 -4
  115. package/dist/types/components/{mrd-list-field → fields/mrd-list-field}/mrd-list-field.d.ts +2 -2
  116. package/dist/types/components/{mrd-longtext-field → fields/mrd-longtext-field}/mrd-longtext-field.d.ts +1 -1
  117. package/dist/types/components/{mrd-number-field → fields/mrd-number-field}/mrd-number-field.d.ts +2 -2
  118. package/dist/types/components/{mrd-relation-field → fields/mrd-relation-field}/mrd-relation-field.d.ts +2 -2
  119. package/dist/types/components/{mrd-secret-field → fields/mrd-secret-field}/mrd-secret-field.d.ts +1 -1
  120. package/dist/types/components/{mrd-text-field → fields/mrd-text-field}/mrd-text-field.d.ts +1 -1
  121. package/dist/types/components/{mrd-textarea-field → fields/mrd-textarea-field}/mrd-textarea-field.d.ts +1 -1
  122. package/dist/types/components/{mrd-time-field → fields/mrd-time-field}/mrd-time-field.d.ts +1 -1
  123. package/dist/types/components/{mrd-field → form/mrd-field}/mrd-field.d.ts +2 -2
  124. package/dist/types/components/{mrd-form → form/mrd-form}/mrd-form.d.ts +2 -2
  125. package/dist/types/components/layout/mrd-layout-section/field-value.d.ts +22 -0
  126. package/dist/types/components/layout/mrd-layout-section/layout-helpers.d.ts +8 -0
  127. package/dist/types/components/{mrd-layout-section → layout/mrd-layout-section}/mrd-layout-section.d.ts +4 -11
  128. package/dist/types/components/{mrd-table → table/mrd-table}/mrd-table.d.ts +6 -13
  129. package/dist/types/components/table/mrd-table/table-filter-popup.d.ts +35 -0
  130. package/dist/types/components/table/mrd-table/table-parts.d.ts +61 -0
  131. package/dist/types/components/table/mrd-table/table-query.d.ts +50 -0
  132. package/dist/types/components/table/mrd-table/virtual-scroll.d.ts +26 -0
  133. package/dist/types/components.d.ts +3 -5
  134. package/dist/types/utils/query-params.d.ts +14 -0
  135. package/package.json +7 -2
  136. package/dist/components/validation.js +0 -1
  137. package/dist/mosterdcomponents/p-_tsCCkAi.js +0 -2
  138. package/dist/mosterdcomponents/p-a9618055.entry.js +0 -1
@@ -1,7 +1,9 @@
1
1
  import { Host, h } from "@stencil/core";
2
- import { ClientLayoutItemType } from "../../types/client-layout";
3
- import { t } from "../../utils/i18n";
4
- import { formatDate } from "../../utils/format";
2
+ import { ClientLayoutItemType } from "../../../types/client-layout";
3
+ import { t } from "../../../utils/i18n";
4
+ import { applyViewFilters, buildListPath } from "../../../utils/query-params";
5
+ import { makeContainerNode, makeFolderNode, computeTotals, segmentsOf, folderStringOf, stripExtension, applyFolderDistinct, applyDocMove, } from "./folder-tree";
6
+ import { renderLoadingRow, renderNodeChildren, renderContainerNode } from "./tree-view";
5
7
  /**
6
8
  * Archetype-driven document collection view. Renders documents as a lazy,
7
9
  * file-explorer-style folder tree, grouped by the `commons.document` archetype's
@@ -76,7 +78,7 @@ export class MrdDocumentList {
76
78
  return;
77
79
  const { target, container } = resolved;
78
80
  const tempId = `${container.id}/__new__${this.newFolderSeq++}`;
79
- const node = this.makeFolderNode(tempId, '', container.id);
81
+ const node = makeFolderNode(tempId, '', container.id);
80
82
  node.pending = true;
81
83
  node.editing = true;
82
84
  target.children = [...target.children, node];
@@ -215,7 +217,7 @@ export class MrdDocumentList {
215
217
  }
216
218
  /** Seed the single implied container from context and load its folders. */
217
219
  seedSingleContainer() {
218
- const node = this.makeContainerNode(this.containerHref, this.containerField, 0);
220
+ const node = makeContainerNode(this.containerHref, this.containerField, 0);
219
221
  this.nodeIndex.set(node.id, node);
220
222
  this.containers = [node];
221
223
  this.rootLoading = false;
@@ -262,61 +264,37 @@ export class MrdDocumentList {
262
264
  * type (e.g. "contents"), filtered down to the concrete `filterClass` via the
263
265
  * `type` query param — see baseParams(). */
264
266
  buildDataPath() {
265
- var _a, _b, _c;
267
+ var _a, _b;
266
268
  const it = this.item;
267
- const dataClass = (_b = (_a = it === null || it === void 0 ? void 0 : it.dataClass) !== null && _a !== void 0 ? _a : it === null || it === void 0 ? void 0 : it.relatedClass) !== null && _b !== void 0 ? _b : '';
268
- if ((it === null || it === void 0 ? void 0 : it.type) === ClientLayoutItemType.RELATED_VIEW) {
269
- return `/${(_c = it.fromClass) !== null && _c !== void 0 ? _c : ''}/${this.parentId}/${dataClass}`;
270
- }
271
- return `/${dataClass}`;
269
+ return buildListPath({
270
+ isRelatedView: (it === null || it === void 0 ? void 0 : it.type) === ClientLayoutItemType.RELATED_VIEW,
271
+ fromClass: it === null || it === void 0 ? void 0 : it.fromClass,
272
+ parentId: this.parentId,
273
+ dataClass: (_b = (_a = it === null || it === void 0 ? void 0 : it.dataClass) !== null && _a !== void 0 ? _a : it === null || it === void 0 ? void 0 : it.relatedClass) !== null && _b !== void 0 ? _b : '',
274
+ });
272
275
  }
273
276
  /** Path for creating a new document (file-drop). Unlike buildDataPath(), this
274
277
  * must target the concrete type: `dataClass`/`relatedClass` can be an abstract
275
278
  * base type (e.g. "contents") that cannot be POSTed to directly, so prefer
276
279
  * `filterClass` (e.g. "documents") when present. */
277
280
  buildCreatePath() {
278
- var _a, _b, _c, _d;
281
+ var _a, _b, _c;
279
282
  const it = this.item;
280
- const dataClass = (_c = (_b = (_a = it === null || it === void 0 ? void 0 : it.filterClass) !== null && _a !== void 0 ? _a : it === null || it === void 0 ? void 0 : it.dataClass) !== null && _b !== void 0 ? _b : it === null || it === void 0 ? void 0 : it.relatedClass) !== null && _c !== void 0 ? _c : '';
281
- if ((it === null || it === void 0 ? void 0 : it.type) === ClientLayoutItemType.RELATED_VIEW) {
282
- return `/${(_d = it.fromClass) !== null && _d !== void 0 ? _d : ''}/${this.parentId}/${dataClass}`;
283
- }
284
- return `/${dataClass}`;
283
+ return buildListPath({
284
+ isRelatedView: (it === null || it === void 0 ? void 0 : it.type) === ClientLayoutItemType.RELATED_VIEW,
285
+ fromClass: it === null || it === void 0 ? void 0 : it.fromClass,
286
+ parentId: this.parentId,
287
+ dataClass: (_c = (_b = (_a = it === null || it === void 0 ? void 0 : it.filterClass) !== null && _a !== void 0 ? _a : it === null || it === void 0 ? void 0 : it.dataClass) !== null && _b !== void 0 ? _b : it === null || it === void 0 ? void 0 : it.relatedClass) !== null && _c !== void 0 ? _c : '',
288
+ });
285
289
  }
286
290
  /** View-level static filters + filterClass, shared by every request. */
287
291
  baseParams() {
288
- var _a, _b, _c, _d, _e, _f, _g;
292
+ var _a, _b, _c;
289
293
  const p = new URLSearchParams();
290
294
  const filterClass = (_a = this.item) === null || _a === void 0 ? void 0 : _a.filterClass;
291
295
  if (filterClass)
292
296
  p.set('type', filterClass);
293
- for (const f of ((_d = (_c = (_b = this.item) === null || _b === void 0 ? void 0 : _b.view) === null || _c === void 0 ? void 0 : _c.filter) !== null && _d !== void 0 ? _d : [])) {
294
- if (!f.name)
295
- continue;
296
- if (f.operator === 'EMPTY') {
297
- p.set(f.name, '');
298
- continue;
299
- }
300
- if (f.operator === 'NOT_EMPTY') {
301
- p.set(f.name + '_notempty', 'true');
302
- continue;
303
- }
304
- if (f.operator === 'STARTS_WITH') {
305
- p.set(f.name + '_startswith', String((_e = f.value) !== null && _e !== void 0 ? _e : ''));
306
- continue;
307
- }
308
- if (f.operator === 'FROM') {
309
- p.set(f.name + '_from', String((_f = f.value) !== null && _f !== void 0 ? _f : ''));
310
- continue;
311
- }
312
- if (f.operator === 'TO') {
313
- p.set(f.name + '_to', String((_g = f.value) !== null && _g !== void 0 ? _g : ''));
314
- continue;
315
- }
316
- if (f.value != null) {
317
- p.set(f.name, String(f.value));
318
- }
319
- }
297
+ applyViewFilters(p, (_c = (_b = this.item) === null || _b === void 0 ? void 0 : _b.view) === null || _c === void 0 ? void 0 : _c.filter);
320
298
  return p;
321
299
  }
322
300
  emitContainerDistinct() {
@@ -383,7 +361,7 @@ export class MrdDocumentList {
383
361
  if (!v.value || typeof v.value !== 'object')
384
362
  continue;
385
363
  const href = v.value.href;
386
- const node = this.makeContainerNode(href, v.value.name, v.count);
364
+ const node = makeContainerNode(href, v.value.name, v.count);
387
365
  nodes.push(node);
388
366
  this.nodeIndex.set(node.id, node);
389
367
  }
@@ -401,38 +379,7 @@ export class MrdDocumentList {
401
379
  const container = this.nodeIndex.get(containerId);
402
380
  if (!container)
403
381
  return;
404
- container.children = [];
405
- container.hasDocs = false;
406
- container.docCount = 0;
407
- for (const v of values) {
408
- const raw = typeof v.value === 'string' ? v.value : v.value == null ? '' : String(v.value);
409
- const segs = this.splitFolder(raw);
410
- if (segs.length === 0) {
411
- // Root documents — the container's own direct documents.
412
- container.hasDocs = true;
413
- container.docCount = v.count;
414
- container.fullPath = raw;
415
- continue;
416
- }
417
- let node = container;
418
- const acc = [];
419
- for (const seg of segs) {
420
- acc.push(seg);
421
- let child = node.children.find(c => c.label === seg);
422
- if (!child) {
423
- child = this.makeFolderNode(container.id + '/' + acc.join('/'), seg, container.id);
424
- node.children.push(child);
425
- this.nodeIndex.set(child.id, child);
426
- }
427
- node = child;
428
- }
429
- node.hasDocs = true;
430
- node.docCount = v.count;
431
- node.fullPath = raw;
432
- }
433
- this.computeTotals(container);
434
- container.foldersLoaded = true;
435
- container.loading = false;
382
+ applyFolderDistinct(container, values, this.nodeIndex);
436
383
  // If the container has root documents, load them now (they show inline on expand).
437
384
  if (container.hasDocs && !container.docsLoaded) {
438
385
  this.emitDocuments(container, container);
@@ -440,36 +387,6 @@ export class MrdDocumentList {
440
387
  this.bump();
441
388
  }
442
389
  // ── Tree helpers ─────────────────────────────────────────────────────────
443
- /** Normalise a folder path: null/""/"/" → root ([]); else split on "/" dropping empties. */
444
- splitFolder(path) {
445
- if (path == null)
446
- return [];
447
- const s = String(path).trim();
448
- if (s === '' || s === '/')
449
- return [];
450
- return s.split('/').map(x => x.trim()).filter(Boolean);
451
- }
452
- makeContainerNode(href, label, count) {
453
- return {
454
- id: 'c:' + href, kind: 'container', label, href,
455
- hasDocs: false, docCount: 0, totalCount: count, children: [],
456
- open: false, loading: false, foldersLoaded: false, docsLoaded: false, docs: [],
457
- };
458
- }
459
- makeFolderNode(id, label, containerId) {
460
- return {
461
- id, kind: 'folder', label, containerId,
462
- hasDocs: false, docCount: 0, totalCount: 0, children: [],
463
- open: false, loading: false, foldersLoaded: false, docsLoaded: false, docs: [],
464
- };
465
- }
466
- computeTotals(node) {
467
- let total = node.docCount;
468
- for (const c of node.children)
469
- total += this.computeTotals(c);
470
- node.totalCount = total;
471
- return total;
472
- }
473
390
  /** Force a re-render after mutating nodes in place. */
474
391
  bump() {
475
392
  this.containers = [...this.containers];
@@ -519,14 +436,6 @@ export class MrdDocumentList {
519
436
  async createFolder() {
520
437
  this.startCreateFolder();
521
438
  }
522
- /** Folder path segments of a node relative to its container (derived from its id). */
523
- segmentsOf(node, container) {
524
- if (node.kind === 'container')
525
- return [];
526
- const prefix = container.id + '/';
527
- const rest = node.id.startsWith(prefix) ? node.id.slice(prefix.length) : '';
528
- return rest ? rest.split('/') : [];
529
- }
530
439
  commitFolder() {
531
440
  const node = this.pendingNode;
532
441
  const parent = this.pendingParent;
@@ -551,7 +460,7 @@ export class MrdDocumentList {
551
460
  }
552
461
  // Finalise: swap the temp id for the real path-derived id so a later distinct
553
462
  // value with the same folder string merges onto this node.
554
- const segs = [...this.segmentsOf(parent, container), name];
463
+ const segs = [...segmentsOf(parent, container), name];
555
464
  this.nodeIndex.delete(node.id);
556
465
  node.id = container.id + '/' + segs.join('/');
557
466
  node.fullPath = '/' + segs.join('/');
@@ -600,10 +509,6 @@ export class MrdDocumentList {
600
509
  this.bump();
601
510
  this.mrdUpload.emit({ file });
602
511
  }
603
- /** Strip a single trailing extension for the document title. */
604
- stripExtension(name) {
605
- return name.replace(/\.[^./\\]+$/, '');
606
- }
607
512
  /** Host callback with the uploaded file reference. Builds the create payload
608
513
  * from the archetype slots and requests the new document. */
609
514
  async setFileReference(uri) {
@@ -611,16 +516,20 @@ export class MrdDocumentList {
611
516
  if (!up)
612
517
  return;
613
518
  const { file, node, container } = up;
614
- const folder = this.folderStringOf(node, container);
519
+ const folder = folderStringOf(node, container);
615
520
  const values = {
616
521
  [this.fileField]: uri,
617
- [this.titleField]: this.stripExtension(file.name),
522
+ [this.titleField]: stripExtension(file.name),
618
523
  [this.folderField]: folder,
619
- [this.containerField]: container.href,
620
524
  };
525
+ // The create path already embeds the container (/{fromClass}/{parentId}/...)
526
+ // when this is the seeded single-container context; omit the redundant field.
527
+ if (!this.isSeededSingleContainer()) {
528
+ values[this.containerField] = container.href;
529
+ }
621
530
  this.mrdCreateObject.emit({ path: this.buildCreatePath(), values });
622
531
  // Optimistically show the new document (no href until a reload).
623
- const optimistic = { [this.titleField]: this.stripExtension(file.name), _optimistic: true };
532
+ const optimistic = { [this.titleField]: stripExtension(file.name), _optimistic: true };
624
533
  const wasUnloadedEmpty = !node.docsLoaded && node.docCount === 0;
625
534
  node.hasDocs = true;
626
535
  node.pending = false;
@@ -649,16 +558,6 @@ export class MrdDocumentList {
649
558
  this.lastOptimisticDoc = null;
650
559
  this.bump();
651
560
  }
652
- /** Folder string a node represents: the raw distinct value when it holds
653
- * documents, else derived from its path segments; null for a container root. */
654
- folderStringOf(node, container) {
655
- if (node.kind === 'container')
656
- return null;
657
- if (node.fullPath != null && node.fullPath !== '')
658
- return node.fullPath;
659
- const segs = this.segmentsOf(node, container);
660
- return segs.length ? '/' + segs.join('/') : null;
661
- }
662
561
  moveDocument(toNode, toContainer) {
663
562
  var _a, _b;
664
563
  const doc = this.dragDoc;
@@ -670,26 +569,14 @@ export class MrdDocumentList {
670
569
  : (fromNode.containerId ? this.nodeIndex.get(fromNode.containerId) : undefined);
671
570
  if (!fromContainer)
672
571
  return;
673
- const targetFolder = this.folderStringOf(toNode, toContainer);
674
- const sourceFolder = this.folderStringOf(fromNode, fromContainer);
572
+ const targetFolder = folderStringOf(toNode, toContainer);
573
+ const sourceFolder = folderStringOf(fromNode, fromContainer);
675
574
  const sameContainer = toContainer === fromContainer;
676
575
  // No-op: dropped back onto its own folder.
677
576
  if (toNode === fromNode || (sameContainer && targetFolder === sourceFolder))
678
577
  return;
679
- // ── Optimistic tree update (fire-and-forget; no refetch) ──
680
- fromNode.docs = fromNode.docs.filter(d => d !== doc);
681
- fromNode.docCount = Math.max(0, fromNode.docCount - 1);
682
- // A now-empty folder should stop showing an expand chevron (it disappears on
683
- // the next reload anyway, since it is derived from document folder strings).
684
- if (fromNode.docsLoaded)
685
- fromNode.hasDocs = fromNode.docs.length > 0;
686
- toNode.hasDocs = true;
687
- toNode.pending = false; // a pending folder is now materialised
688
- toNode.docCount += 1;
689
- if (toNode.kind === 'folder')
690
- toNode.fullPath = targetFolder !== null && targetFolder !== void 0 ? targetFolder : '';
691
- if (toNode.docsLoaded)
692
- toNode.docs = [...toNode.docs, doc];
578
+ // Optimistic tree update (fire-and-forget; no refetch).
579
+ applyDocMove(doc, fromNode, toNode, targetFolder);
693
580
  this.recomputeContainerTotals(fromContainer, -1);
694
581
  if (!sameContainer)
695
582
  this.recomputeContainerTotals(toContainer, +1);
@@ -707,7 +594,7 @@ export class MrdDocumentList {
707
594
  * loaded; otherwise just nudge the aggregate badge by the delta. */
708
595
  recomputeContainerTotals(container, delta) {
709
596
  if (container.foldersLoaded) {
710
- this.computeTotals(container);
597
+ computeTotals(container);
711
598
  }
712
599
  else {
713
600
  container.totalCount = Math.max(0, container.totalCount + delta);
@@ -720,103 +607,56 @@ export class MrdDocumentList {
720
607
  this.mrdNavigate.emit({ href, label });
721
608
  }
722
609
  // ── Render ───────────────────────────────────────────────────────────────
723
- renderChevron(open, leaf) {
724
- return (h("span", { class: `mrd-document-list__chev${leaf ? ' mrd-document-list__chev--leaf' : ''}${open ? ' mrd-document-list__chev--open' : ''}` }, 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: "M9 6l6 6-6 6" }))));
725
- }
726
- renderDossierIcon() {
727
- return (h("svg", { class: "mrd-document-list__icon mrd-document-list__icon--dossier", 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" })));
728
- }
729
- renderFolderIcon() {
730
- return (h("svg", { class: "mrd-document-list__icon mrd-document-list__icon--folder", 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" })));
731
- }
732
- renderDocIcon() {
733
- return (h("svg", { class: "mrd-document-list__icon mrd-document-list__icon--doc", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }), h("path", { d: "M14 2v6h6" })));
734
- }
735
- indent(depth) {
736
- return h("span", { class: "mrd-document-list__indent", style: { width: `${depth * 18}px` } });
737
- }
738
- renderDocRow(doc, node, container, depth) {
739
- var _a, _b, _c, _d, _e;
740
- const label = (_b = (_a = doc === null || doc === void 0 ? void 0 : doc[this.titleField]) !== null && _a !== void 0 ? _a : doc === null || doc === void 0 ? void 0 : doc.name) !== null && _b !== void 0 ? _b : '';
741
- const dateRaw = this.dateField ? doc === null || doc === void 0 ? void 0 : doc[this.dateField] : undefined;
742
- const date = dateRaw ? formatDate(dateRaw, this.locale) : '';
743
- return (h("div", { class: "mrd-document-list__row mrd-document-list__row--doc", key: (_e = (_d = (_c = doc === null || doc === void 0 ? void 0 : doc._links) === null || _c === void 0 ? void 0 : _c.self) === null || _d === void 0 ? void 0 : _d.href) !== null && _e !== void 0 ? _e : label, draggable: true, onClick: () => this.openDoc(doc), onDragStart: (e) => this.onDocDragStart(e, doc, node), onDragEnd: this.onDocDragEnd, onDragOver: (e) => this.onNodeDragOver(e, node), onDragLeave: () => this.onNodeDragLeave(node), onDrop: (e) => this.onNodeDrop(e, node, container) }, this.indent(depth), this.renderChevron(false, true), this.renderDocIcon(), h("span", { class: "mrd-document-list__label" }, label), date && h("span", { class: "mrd-document-list__date" }, date)));
744
- }
745
- renderLoadingRow(depth) {
746
- return (h("div", { class: "mrd-document-list__loading", key: "loading" }, this.indent(depth), h("span", { class: "mrd-document-list__spinner" }), t('loading', this.locale)));
747
- }
748
- renderChildren(container, node, depth) {
749
- const out = [];
750
- // Direct documents of this node (root docs live on the container node).
751
- if (node.hasDocs) {
752
- if (node.docsLoaded) {
753
- for (const doc of node.docs)
754
- out.push(this.renderDocRow(doc, node, container, depth));
755
- }
756
- else if (node.loading) {
757
- out.push(this.renderLoadingRow(depth));
758
- }
759
- }
760
- // Child folders.
761
- for (const child of node.children) {
762
- out.push(this.renderFolderNode(container, child, depth));
763
- }
764
- // An uploading file dropped onto this node.
765
- if (node.id === this.uploadingNodeId)
766
- out.push(this.renderUploadingRow(depth));
767
- return out;
768
- }
769
- renderUploadingRow(depth) {
770
- return (h("div", { class: "mrd-document-list__loading", key: "uploading" }, this.indent(depth), h("span", { class: "mrd-document-list__spinner" }), t('upload_file', this.locale)));
771
- }
772
- renderFolderEditRow(node, depth) {
773
- return (h("div", { class: "mrd-document-list__node", key: node.id }, h("div", { class: "mrd-document-list__row mrd-document-list__row--edit" }, this.indent(depth), this.renderChevron(false, true), this.renderFolderIcon(), h("input", { class: "mrd-document-list__name-input", type: "text", placeholder: t('folder_name_placeholder', this.locale), ref: el => (this.pendingInputEl = el), onInput: this.onPendingInput, onKeyDown: this.onPendingKeyDown, onBlur: () => this.cancelFolder() })), node.error && (h("div", { class: "mrd-document-list__error", style: { paddingLeft: `${depth * 18 + 52}px` } }, node.error))));
774
- }
775
- renderFolderNode(container, node, depth) {
776
- if (node.editing)
777
- return this.renderFolderEditRow(node, depth);
778
- const leaf = node.children.length === 0 && !node.hasDocs;
779
- const selected = node.id === this.selectedId;
780
- const cls = 'mrd-document-list__row'
781
- + (selected ? ' mrd-document-list__row--selected' : '')
782
- + (node.pending ? ' mrd-document-list__row--pending' : '')
783
- + (node.id === this.dropTargetId ? ' mrd-document-list__row--drop' : '');
784
- return (h("div", { class: "mrd-document-list__node", key: node.id }, h("div", { class: cls, onClick: () => this.toggleFolder(container, node), onDragOver: (e) => this.onNodeDragOver(e, node), onDragLeave: () => this.onNodeDragLeave(node), onDrop: (e) => this.onNodeDrop(e, node, container) }, this.indent(depth), this.renderChevron(node.open, leaf), this.renderFolderIcon(), h("span", { class: "mrd-document-list__label" }, node.label), h("span", { class: "mrd-document-list__count" }, node.totalCount)), node.open && h("div", { class: "mrd-document-list__kids" }, this.renderChildren(container, node, depth + 1))));
785
- }
786
- renderContainerNode(node, depth) {
787
- const selected = node.id === this.selectedId;
788
- const cls = 'mrd-document-list__row mrd-document-list__row--dossier'
789
- + (selected ? ' mrd-document-list__row--selected' : '')
790
- + (node.id === this.dropTargetId ? ' mrd-document-list__row--drop' : '');
791
- return (h("div", { class: "mrd-document-list__node", key: node.id }, h("div", { class: cls, onClick: () => this.toggleContainer(node), onDragOver: (e) => this.onNodeDragOver(e, node), onDragLeave: () => this.onNodeDragLeave(node), onDrop: (e) => this.onNodeDrop(e, node, node) }, this.indent(depth), this.renderChevron(node.open, false), this.renderDossierIcon(), h("span", { class: "mrd-document-list__label" }, node.label), h("span", { class: "mrd-document-list__count" }, node.totalCount)), node.open && (h("div", { class: "mrd-document-list__kids" }, node.loading && !node.foldersLoaded
792
- ? this.renderLoadingRow(depth + 1)
793
- : this.renderChildren(node, node, depth + 1)))));
610
+ treeCtx() {
611
+ return {
612
+ locale: this.locale,
613
+ titleField: this.titleField,
614
+ dateField: this.dateField,
615
+ selectedId: this.selectedId,
616
+ dropTargetId: this.dropTargetId,
617
+ uploadingNodeId: this.uploadingNodeId,
618
+ on: {
619
+ toggleContainer: node => this.toggleContainer(node),
620
+ toggleFolder: (container, node) => this.toggleFolder(container, node),
621
+ openDoc: doc => this.openDoc(doc),
622
+ docDragStart: this.onDocDragStart,
623
+ docDragEnd: this.onDocDragEnd,
624
+ nodeDragOver: this.onNodeDragOver,
625
+ nodeDragLeave: this.onNodeDragLeave,
626
+ nodeDrop: this.onNodeDrop,
627
+ pendingInput: this.onPendingInput,
628
+ pendingKeyDown: this.onPendingKeyDown,
629
+ cancelFolder: () => this.cancelFolder(),
630
+ setPendingInputEl: el => (this.pendingInputEl = el),
631
+ },
632
+ };
794
633
  }
795
634
  render() {
635
+ const ctx = this.treeCtx();
796
636
  let body;
797
637
  if (this.rootLoading) {
798
- body = this.renderLoadingRow(0);
638
+ body = renderLoadingRow(ctx, 0);
799
639
  }
800
640
  else if (this.containers.length === 0) {
801
- body = h("div", { key: '9c38a2e26320a8173ba82cac412c1b32a8a1882e', class: "mrd-document-list__empty" }, t('no_results', this.locale));
641
+ body = h("div", { key: 'ce40dab51ab61447838e5059159ae4778209a6f3', class: "mrd-document-list__empty" }, t('no_results', this.locale));
802
642
  }
803
643
  else if (this.singleContainer) {
804
644
  // Dossier context: render the single container's folder tree at the root.
805
645
  const only = this.containers[0];
806
646
  if (only.loading && !only.foldersLoaded) {
807
- body = this.renderLoadingRow(0);
647
+ body = renderLoadingRow(ctx, 0);
808
648
  }
809
649
  else {
810
- const kids = this.renderChildren(only, only, 0);
650
+ const kids = renderNodeChildren(ctx, only, only, 0);
811
651
  body = kids.length
812
652
  ? kids
813
653
  : h("div", { class: "mrd-document-list__empty" }, t('doc_empty_drop', this.locale));
814
654
  }
815
655
  }
816
656
  else {
817
- body = this.containers.map(c => this.renderContainerNode(c, 0));
657
+ body = this.containers.map(c => renderContainerNode(ctx, c, 0));
818
658
  }
819
- return (h(Host, { key: 'dd83a6a609e01d21a2b5da5b3ab929f6f9315402' }, h("div", { key: 'd539d938e1efd759730cccc90c4d6c2e535db936', class: 'mrd-document-list' + (this.rootDropActive ? ' mrd-document-list--drop-active' : ''), onDragOver: this.onRootDragOver, onDragLeave: this.onRootDragLeave, onDrop: this.onRootDrop }, body)));
659
+ return (h(Host, { key: '9e1f7805ae18bce506c530a481db902900ad95f3' }, h("div", { key: 'a51334634e94310a71650ad49f17f0a20e2aed4d', class: 'mrd-document-list' + (this.rootDropActive ? ' mrd-document-list--drop-active' : ''), onDragOver: this.onRootDragOver, onDragLeave: this.onRootDragLeave, onDrop: this.onRootDrop }, body)));
820
660
  }
821
661
  static get is() { return "mrd-document-list"; }
822
662
  static get encapsulation() { return "scoped"; }
@@ -841,7 +681,7 @@ export class MrdDocumentList {
841
681
  "references": {
842
682
  "ClientLayoutItem": {
843
683
  "location": "import",
844
- "path": "../../types/client-layout",
684
+ "path": "../../../types/client-layout",
845
685
  "id": "src/types/client-layout.ts::ClientLayoutItem",
846
686
  "referenceLocation": "ClientLayoutItem"
847
687
  }
@@ -866,7 +706,7 @@ export class MrdDocumentList {
866
706
  "references": {
867
707
  "ClientArchetype": {
868
708
  "location": "import",
869
- "path": "../../types/client-layout",
709
+ "path": "../../../types/client-layout",
870
710
  "id": "src/types/client-layout.ts::ClientArchetype",
871
711
  "referenceLocation": "ClientArchetype"
872
712
  }
@@ -1097,9 +937,10 @@ export class MrdDocumentList {
1097
937
  "id": "global::Promise"
1098
938
  },
1099
939
  "DistinctValue": {
1100
- "location": "local",
1101
- "path": "/Users/michiel/Mosterd/mosterd-components/src/components/mrd-document-list/mrd-document-list.tsx",
1102
- "id": "src/components/mrd-document-list/mrd-document-list.tsx::DistinctValue"
940
+ "location": "import",
941
+ "path": "./folder-tree",
942
+ "id": "src/components/documents/mrd-document-list/folder-tree.ts::DistinctValue",
943
+ "referenceLocation": "DistinctValue"
1103
944
  }
1104
945
  },
1105
946
  "return": "Promise<void>"
@@ -1127,9 +968,10 @@ export class MrdDocumentList {
1127
968
  "id": "global::Promise"
1128
969
  },
1129
970
  "DocRow": {
1130
- "location": "local",
1131
- "path": "/Users/michiel/Mosterd/mosterd-components/src/components/mrd-document-list/mrd-document-list.tsx",
1132
- "id": "src/components/mrd-document-list/mrd-document-list.tsx::DocRow"
971
+ "location": "import",
972
+ "path": "./folder-tree",
973
+ "id": "src/components/documents/mrd-document-list/folder-tree.ts::DocRow",
974
+ "referenceLocation": "DocRow"
1133
975
  }
1134
976
  },
1135
977
  "return": "Promise<void>"
@@ -1174,9 +1016,10 @@ export class MrdDocumentList {
1174
1016
  "id": "global::Record"
1175
1017
  },
1176
1018
  "DocRow": {
1177
- "location": "local",
1178
- "path": "/Users/michiel/Mosterd/mosterd-components/src/components/mrd-document-list/mrd-document-list.tsx",
1179
- "id": "src/components/mrd-document-list/mrd-document-list.tsx::DocRow"
1019
+ "location": "import",
1020
+ "path": "./folder-tree",
1021
+ "id": "src/components/documents/mrd-document-list/folder-tree.ts::DocRow",
1022
+ "referenceLocation": "DocRow"
1180
1023
  }
1181
1024
  },
1182
1025
  "return": "Promise<void>"
@@ -0,0 +1,75 @@
1
+ import { h } from "@stencil/core";
2
+ import { t } from "../../../utils/i18n";
3
+ import { formatDate } from "../../../utils/format";
4
+ function chevron(open, leaf) {
5
+ return (h("span", { class: `mrd-document-list__chev${leaf ? ' mrd-document-list__chev--leaf' : ''}${open ? ' mrd-document-list__chev--open' : ''}` }, 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: "M9 6l6 6-6 6" }))));
6
+ }
7
+ function dossierIcon() {
8
+ return (h("svg", { class: "mrd-document-list__icon mrd-document-list__icon--dossier", 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" })));
9
+ }
10
+ function folderIcon() {
11
+ return (h("svg", { class: "mrd-document-list__icon mrd-document-list__icon--folder", 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" })));
12
+ }
13
+ function docIcon() {
14
+ return (h("svg", { class: "mrd-document-list__icon mrd-document-list__icon--doc", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }), h("path", { d: "M14 2v6h6" })));
15
+ }
16
+ function indent(depth) {
17
+ return h("span", { class: "mrd-document-list__indent", style: { width: `${depth * 18}px` } });
18
+ }
19
+ export function renderLoadingRow(ctx, depth) {
20
+ return (h("div", { class: "mrd-document-list__loading", key: "loading" }, indent(depth), h("span", { class: "mrd-document-list__spinner" }), t('loading', ctx.locale)));
21
+ }
22
+ function renderUploadingRow(ctx, depth) {
23
+ return (h("div", { class: "mrd-document-list__loading", key: "uploading" }, indent(depth), h("span", { class: "mrd-document-list__spinner" }), t('upload_file', ctx.locale)));
24
+ }
25
+ function renderDocRow(ctx, doc, node, container, depth) {
26
+ var _a, _b, _c, _d, _e;
27
+ const label = (_b = (_a = doc === null || doc === void 0 ? void 0 : doc[ctx.titleField]) !== null && _a !== void 0 ? _a : doc === null || doc === void 0 ? void 0 : doc.name) !== null && _b !== void 0 ? _b : '';
28
+ const dateRaw = ctx.dateField ? doc === null || doc === void 0 ? void 0 : doc[ctx.dateField] : undefined;
29
+ const date = dateRaw ? formatDate(dateRaw, ctx.locale) : '';
30
+ return (h("div", { class: "mrd-document-list__row mrd-document-list__row--doc", key: (_e = (_d = (_c = doc === null || doc === void 0 ? void 0 : doc._links) === null || _c === void 0 ? void 0 : _c.self) === null || _d === void 0 ? void 0 : _d.href) !== null && _e !== void 0 ? _e : label, draggable: true, onClick: () => ctx.on.openDoc(doc), onDragStart: (e) => ctx.on.docDragStart(e, doc, node), onDragEnd: ctx.on.docDragEnd, onDragOver: (e) => ctx.on.nodeDragOver(e, node), onDragLeave: () => ctx.on.nodeDragLeave(node), onDrop: (e) => ctx.on.nodeDrop(e, node, container) }, indent(depth), chevron(false, true), docIcon(), h("span", { class: "mrd-document-list__label" }, label), date && h("span", { class: "mrd-document-list__date" }, date)));
31
+ }
32
+ function renderFolderEditRow(ctx, node, depth) {
33
+ return (h("div", { class: "mrd-document-list__node", key: node.id }, h("div", { class: "mrd-document-list__row mrd-document-list__row--edit" }, indent(depth), chevron(false, true), folderIcon(), h("input", { class: "mrd-document-list__name-input", type: "text", placeholder: t('folder_name_placeholder', ctx.locale), ref: el => ctx.on.setPendingInputEl(el), onInput: ctx.on.pendingInput, onKeyDown: ctx.on.pendingKeyDown, onBlur: () => ctx.on.cancelFolder() })), node.error && (h("div", { class: "mrd-document-list__error", style: { paddingLeft: `${depth * 18 + 52}px` } }, node.error))));
34
+ }
35
+ export function renderNodeChildren(ctx, container, node, depth) {
36
+ const out = [];
37
+ // Direct documents of this node (root docs live on the container node).
38
+ if (node.hasDocs) {
39
+ if (node.docsLoaded) {
40
+ for (const doc of node.docs)
41
+ out.push(renderDocRow(ctx, doc, node, container, depth));
42
+ }
43
+ else if (node.loading) {
44
+ out.push(renderLoadingRow(ctx, depth));
45
+ }
46
+ }
47
+ // Child folders.
48
+ for (const child of node.children) {
49
+ out.push(renderFolderNode(ctx, container, child, depth));
50
+ }
51
+ // An uploading file dropped onto this node.
52
+ if (node.id === ctx.uploadingNodeId)
53
+ out.push(renderUploadingRow(ctx, depth));
54
+ return out;
55
+ }
56
+ export function renderFolderNode(ctx, container, node, depth) {
57
+ if (node.editing)
58
+ return renderFolderEditRow(ctx, node, depth);
59
+ const leaf = node.children.length === 0 && !node.hasDocs;
60
+ const selected = node.id === ctx.selectedId;
61
+ const cls = 'mrd-document-list__row'
62
+ + (selected ? ' mrd-document-list__row--selected' : '')
63
+ + (node.pending ? ' mrd-document-list__row--pending' : '')
64
+ + (node.id === ctx.dropTargetId ? ' mrd-document-list__row--drop' : '');
65
+ return (h("div", { class: "mrd-document-list__node", key: node.id }, h("div", { class: cls, onClick: () => ctx.on.toggleFolder(container, node), onDragOver: (e) => ctx.on.nodeDragOver(e, node), onDragLeave: () => ctx.on.nodeDragLeave(node), onDrop: (e) => ctx.on.nodeDrop(e, node, container) }, indent(depth), chevron(node.open, leaf), folderIcon(), h("span", { class: "mrd-document-list__label" }, node.label), h("span", { class: "mrd-document-list__count" }, node.totalCount)), node.open && h("div", { class: "mrd-document-list__kids" }, renderNodeChildren(ctx, container, node, depth + 1))));
66
+ }
67
+ export function renderContainerNode(ctx, node, depth) {
68
+ const selected = node.id === ctx.selectedId;
69
+ const cls = 'mrd-document-list__row mrd-document-list__row--dossier'
70
+ + (selected ? ' mrd-document-list__row--selected' : '')
71
+ + (node.id === ctx.dropTargetId ? ' mrd-document-list__row--drop' : '');
72
+ return (h("div", { class: "mrd-document-list__node", key: node.id }, h("div", { class: cls, onClick: () => ctx.on.toggleContainer(node), onDragOver: (e) => ctx.on.nodeDragOver(e, node), onDragLeave: () => ctx.on.nodeDragLeave(node), onDrop: (e) => ctx.on.nodeDrop(e, node, node) }, indent(depth), chevron(node.open, false), dossierIcon(), h("span", { class: "mrd-document-list__label" }, node.label), h("span", { class: "mrd-document-list__count" }, node.totalCount)), node.open && (h("div", { class: "mrd-document-list__kids" }, node.loading && !node.foldersLoaded
73
+ ? renderLoadingRow(ctx, depth + 1)
74
+ : renderNodeChildren(ctx, node, node, depth + 1)))));
75
+ }
@@ -118,4 +118,4 @@
118
118
  font-size: var(--mrd-font-size-base);
119
119
  color: var(--mrd-color-neutral-700);
120
120
  line-height: var(--mrd-line-height-relaxed);
121
- }
121
+ }
@@ -1,6 +1,6 @@
1
1
  import { Host, h } from "@stencil/core";
2
- import { t } from "../../utils/i18n";
3
- import { formatDate } from "../../utils/format";
2
+ import { t } from "../../../utils/i18n";
3
+ import { formatDate } from "../../../utils/format";
4
4
  /**
5
5
  * Archetype-driven single-document view. Given a `commons.document` binding and a
6
6
  * data record, renders the document recognisably — title, file preview/download,
@@ -56,7 +56,7 @@ export class MrdDocumentView {
56
56
  const date = dateRaw != null && dateRaw !== '' ? formatDate(dateRaw, this.locale) : null;
57
57
  const summaryRaw = this.slotValue('summary');
58
58
  const summary = summaryRaw != null && summaryRaw !== '' ? String(summaryRaw) : null;
59
- return (h(Host, { key: '0a2071925ecdb21738376d66fa4babf4590e694c' }, h("div", { key: 'a2d29c0b6e211cab142adc780466bc885a602e96', class: "mrd-document-view" }, this.renderContainer(), title && h("h1", { key: '7f5ac202c21bc8a70f0dd15e2e1fa06e651b5bce', class: "mrd-document-view__title" }, title), date && h("p", { key: 'b1dce94d5fd8bfd5e078644f631a38f91b87e7ff', class: "mrd-document-view__date" }, date), this.renderFile(), summary && (h("div", { key: '588b9ca40a49ae9ea303852620bde75333b440ab', class: "mrd-document-view__summary" }, h("div", { key: 'd3b8adb85ac346b72451e789c10aedd539c966de', class: "mrd-document-view__summary-body", innerHTML: summary }))))));
59
+ return (h(Host, { key: '0c64c72eaf5e1eefc2ca9aebb2543081eb1eae32' }, h("div", { key: '70cce81b089fee81a4c163a6ba5fbcc8cb46131c', class: "mrd-document-view" }, this.renderContainer(), title && h("h1", { key: '50f85b32a6740d6cf57fdf1bb0bcc597b5e97b31', class: "mrd-document-view__title" }, title), date && h("p", { key: 'b3c8fb3b4382104858d49ef9a1597034665122bb', class: "mrd-document-view__date" }, date), this.renderFile(), summary && (h("div", { key: '2046c1eca7601549115de0c95ff778abaf5faf46', class: "mrd-document-view__summary" }, h("div", { key: '875863d3e438eee3d4df10473a93f09370fde08c', class: "mrd-document-view__summary-body", innerHTML: summary }))))));
60
60
  }
61
61
  static get is() { return "mrd-document-view"; }
62
62
  static get encapsulation() { return "scoped"; }
@@ -81,7 +81,7 @@ export class MrdDocumentView {
81
81
  "references": {
82
82
  "ClientArchetype": {
83
83
  "location": "import",
84
- "path": "../../types/client-layout",
84
+ "path": "../../../types/client-layout",
85
85
  "id": "src/types/client-layout.ts::ClientArchetype",
86
86
  "referenceLocation": "ClientArchetype"
87
87
  }