@mmlogic/components 0.5.14 → 0.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/cjs/{cell-renderer-mjS630f1.js → cell-renderer-CLVKTVVQ.js} +105 -1
  2. package/dist/cjs/{client-layout-CqVuJumR.js → client-layout-Eg2VwW-7.js} +2 -0
  3. package/dist/cjs/index.cjs.js +2 -1
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/mosterdcomponents.cjs.js +1 -1
  6. package/dist/cjs/{mrd-boolean-field_25.cjs.entry.js → mrd-boolean-field_28.cjs.entry.js} +1168 -314
  7. package/dist/cjs/mrd-merge-view.cjs.entry.js +4 -4
  8. package/dist/collection/collection-manifest.json +3 -0
  9. package/dist/collection/components/fields/mrd-textarea-field/mrd-textarea-field.js +47 -2
  10. package/dist/collection/components/form/mrd-field/mrd-field.css +69 -0
  11. package/dist/collection/components/form/mrd-field/mrd-field.js +95 -25
  12. package/dist/collection/components/form/mrd-form/mrd-form.css +29 -0
  13. package/dist/collection/components/form/mrd-form/mrd-form.js +44 -8
  14. package/dist/collection/components/layout/mrd-layout-section/field-value.js +19 -2
  15. package/dist/collection/components/layout/mrd-layout-section/layout-helpers.js +10 -0
  16. package/dist/collection/components/layout/mrd-layout-section/mrd-layout-section.css +4 -3
  17. package/dist/collection/components/layout/mrd-layout-section/mrd-layout-section.js +169 -18
  18. package/dist/collection/components/memo/mrd-memo-container/mrd-memo-container.css +204 -0
  19. package/dist/collection/components/memo/mrd-memo-container/mrd-memo-container.js +769 -0
  20. package/dist/collection/components/memo/mrd-memo-list/mrd-memo-list.css +164 -0
  21. package/dist/collection/components/memo/mrd-memo-list/mrd-memo-list.js +559 -0
  22. package/dist/collection/components/memo/mrd-memo-view/mrd-memo-view.css +108 -0
  23. package/dist/collection/components/memo/mrd-memo-view/mrd-memo-view.js +204 -0
  24. package/dist/collection/components/merge/mrd-merge-view/mrd-merge-view.js +2 -2
  25. package/dist/collection/components/table/mrd-table/mrd-table.js +9 -6
  26. package/dist/collection/dev/app.js +30 -15
  27. package/dist/collection/dev/example-data.js +15 -1
  28. package/dist/collection/types/client-layout.js +1 -0
  29. package/dist/collection/utils/i18n.js +104 -0
  30. package/dist/collection/utils/query-params.js +9 -0
  31. package/dist/components/client-layout.js +1 -1
  32. package/dist/components/i18n.js +1 -1
  33. package/dist/components/index.js +1 -1
  34. package/dist/components/mrd-field2.js +1 -1
  35. package/dist/components/mrd-form.js +1 -1
  36. package/dist/components/mrd-layout-section.js +1 -1
  37. package/dist/components/mrd-memo-container.d.ts +11 -0
  38. package/dist/components/mrd-memo-container.js +1 -0
  39. package/dist/components/mrd-memo-container2.js +1 -0
  40. package/dist/components/mrd-memo-list.d.ts +11 -0
  41. package/dist/components/mrd-memo-list.js +1 -0
  42. package/dist/components/mrd-memo-list2.js +1 -0
  43. package/dist/components/mrd-memo-view.d.ts +11 -0
  44. package/dist/components/mrd-memo-view.js +1 -0
  45. package/dist/components/mrd-memo-view2.js +1 -0
  46. package/dist/components/mrd-merge-view.js +1 -1
  47. package/dist/components/mrd-table2.js +1 -1
  48. package/dist/components/mrd-textarea-field2.js +1 -1
  49. package/dist/components/query-params.js +1 -1
  50. package/dist/components/table-query.js +1 -0
  51. package/dist/esm/{cell-renderer-BDY8UXkH.js → cell-renderer-4NKEzZWw.js} +105 -1
  52. package/dist/esm/{client-layout-Bc42CfJB.js → client-layout-BJkVeSq6.js} +2 -1
  53. package/dist/esm/index.js +1 -1
  54. package/dist/esm/loader.js +1 -1
  55. package/dist/esm/mosterdcomponents.js +1 -1
  56. package/dist/esm/{mrd-boolean-field_25.entry.js → mrd-boolean-field_28.entry.js} +1166 -315
  57. package/dist/esm/mrd-merge-view.entry.js +4 -4
  58. package/dist/mosterdcomponents/{cell-renderer-B8u5BCK-.js.map → cell-renderer-CMUxFREW.js.map} +1 -1
  59. package/dist/mosterdcomponents/client-layout-BJkVeSq6.js.map +1 -0
  60. package/dist/mosterdcomponents/{field-helpers-CNQcI3Hf.js.map → field-helpers-BWAp5fD8.js.map} +1 -1
  61. package/dist/mosterdcomponents/{file-upload-common-C9wp47CB.js.map → file-upload-common-DDWuC9-3.js.map} +1 -1
  62. package/dist/mosterdcomponents/i18n-OzbszktW.js.map +1 -0
  63. package/dist/mosterdcomponents/index-CkcFwdPc.js.map +1 -0
  64. package/dist/mosterdcomponents/index.esm.js +1 -1
  65. package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
  66. package/dist/mosterdcomponents/p-8a7fa81d.entry.js +3 -0
  67. package/dist/mosterdcomponents/{p-Bc42CfJB.js → p-BJkVeSq6.js} +1 -1
  68. package/dist/mosterdcomponents/p-BMx6VAJ6.js +1 -0
  69. package/dist/mosterdcomponents/{p-e8b0880f.entry.js → p-e68dfbb0.entry.js} +1 -1
  70. package/dist/mosterdcomponents/query-params-3TXd5CUO.js.map +1 -0
  71. package/dist/mosterdcomponents/table-query-DJq1uKqJ.js.map +1 -0
  72. package/dist/mosterdcomponents/{validation-CjjTt66G.js.map → validation-B_0Lx9DE.js.map} +1 -1
  73. package/dist/types/components/fields/mrd-textarea-field/mrd-textarea-field.d.ts +10 -0
  74. package/dist/types/components/form/mrd-field/mrd-field.d.ts +16 -0
  75. package/dist/types/components/form/mrd-form/mrd-form.d.ts +6 -0
  76. package/dist/types/components/layout/mrd-layout-section/field-value.d.ts +4 -0
  77. package/dist/types/components/layout/mrd-layout-section/layout-helpers.d.ts +3 -0
  78. package/dist/types/components/layout/mrd-layout-section/mrd-layout-section.d.ts +25 -1
  79. package/dist/types/components/memo/mrd-memo-container/mrd-memo-container.d.ts +173 -0
  80. package/dist/types/components/memo/mrd-memo-list/mrd-memo-list.d.ts +91 -0
  81. package/dist/types/components/memo/mrd-memo-view/mrd-memo-view.d.ts +33 -0
  82. package/dist/types/components.d.ts +571 -1
  83. package/dist/types/types/client-layout.d.ts +1 -0
  84. package/dist/types/utils/query-params.d.ts +16 -0
  85. package/package.json +1 -1
  86. package/dist/mosterdcomponents/client-layout-Bc42CfJB.js.map +0 -1
  87. package/dist/mosterdcomponents/i18n-ydNM87-Q.js.map +0 -1
  88. package/dist/mosterdcomponents/index-DhffneUF.js.map +0 -1
  89. package/dist/mosterdcomponents/p-Dkm4WxMy.js +0 -1
  90. package/dist/mosterdcomponents/p-c834951a.entry.js +0 -3
  91. package/dist/mosterdcomponents/query-params-BZbQoeYF.js.map +0 -1
@@ -0,0 +1,769 @@
1
+ import { Host, h } from "@stencil/core";
2
+ import { ClientLayoutItemType } from "../../../types/client-layout";
3
+ import { t } from "../../../utils/i18n";
4
+ import { buildListPath } from "../../../utils/query-params";
5
+ /**
6
+ * Owns a memo collection view: a single toolbar (view switch + "New memo") plus
7
+ * the two interchangeable bodies — the card list (`mrd-memo-list`) and the flat
8
+ * table (`mrd-table`). Mirrors `mrd-document-container`'s structure.
9
+ *
10
+ * There is no memo detail page: both "New memo" and clicking an existing memo
11
+ * (card or table row) open the same small dialog — just the fields a person
12
+ * actually fills in (body, and only the optional slots the archetype actually
13
+ * maps: title/labels/important). date/author/container are already known
14
+ * context and never shown. Create emits `mrdCreateObject` (same contract
15
+ * mrd-document-list already uses for its inline file-drop create); editing an
16
+ * existing memo emits `mrdUpdateObject` (same generic PATCH contract used
17
+ * elsewhere, e.g. mrd-document-list's drag-move) and optimistically patches the
18
+ * displayed row/card itself, since that PATCH is fire-and-forget on the host.
19
+ *
20
+ * `mrd-layout-section` renders one of these per memo VIEW / RELATED_VIEW and
21
+ * forwards the re-emitted load/action/create/update events to the host.
22
+ */
23
+ export class MrdMemoContainer {
24
+ constructor() {
25
+ /** The VIEW or RELATED_VIEW layout item (dataClass, fromClass, view config). */
26
+ this.item = null;
27
+ /** Parent record id — required for RELATED_VIEW path building. */
28
+ this.parentId = '';
29
+ /** Canonical parent href — set when this is a RELATED_VIEW embedded under a
30
+ * parent record, which already gives a new memo something to attach to. */
31
+ this.containerHref = '';
32
+ /** False when this RELATED_VIEW's parent is related via a relation other than
33
+ * the archetype's container slot (e.g. a person's "memos I authored" list,
34
+ * related via `author`) — mrd-layout-section resolves this from the item's
35
+ * `inverseRelation`. In that case the parent is not a valid container for a
36
+ * new memo, and — unlike a top-level VIEW with no context at all — falling
37
+ * back to `me` would be wrong too (creating a memo "on myself" from someone
38
+ * else's authored-memos list makes no sense), so "New memo" is hidden outright. */
39
+ this.containerRelated = true;
40
+ /** True unless this is a container-scoped RELATED_VIEW (a company's own memo
41
+ * tab, say) where every card's container is obviously the page you're
42
+ * already on — forwarded to mrd-memo-list to show/hide its per-card
43
+ * container link. A top-level VIEW or an author-scoped RELATED_VIEW both
44
+ * still need it, since the container isn't implied by the page context. */
45
+ this.showContainerLink = true;
46
+ /** Lookup key used for the embedded `data-view` attribute. */
47
+ this.viewKey = '';
48
+ this.locale = navigator.language;
49
+ /** listItems of the FIELD bound to the `labels` slot; forwarded to whichever
50
+ * body is mounted and used to render the dialog's label checkboxes. */
51
+ this.labelsListItems = null;
52
+ /** When true, this dashboard is read-only: "New memo" is disabled with a
53
+ * tooltip, cards/rows are not clickable, and the embedded table's own
54
+ * create action is disabled too. */
55
+ this.readOnly = false;
56
+ /** The active account's linked person record (userProfile.links.person), if any.
57
+ * Used both to gate "New memo" (see effectiveContainerHref) and, on submit, to
58
+ * fill the author slot. */
59
+ this.me = null;
60
+ /** Active body: card list or flat table. */
61
+ this.mode = 'cards';
62
+ this.dialogOpen = false;
63
+ /** Href of the memo being edited; null while creating. */
64
+ this.editingHref = null;
65
+ this.dialogBody = '';
66
+ this.dialogTitle = '';
67
+ this.dialogLabels = [];
68
+ this.dialogImportant = false;
69
+ this.dialogTouched = false;
70
+ /** True while the dialog shows the delete confirmation step in place of the
71
+ * form fields — mirrors mrd-merge-view's MergeConfirmStep (same panel,
72
+ * swapped content) rather than stacking a second modal. */
73
+ this.deleteConfirmOpen = false;
74
+ /** Whether the currently mounted body has been init()'d. Reset on every mode switch. */
75
+ this.listInited = false;
76
+ this.tableInited = false;
77
+ this.escapeHandler = null;
78
+ this.openCreate = () => {
79
+ if (!this.canAdd)
80
+ return;
81
+ this.editingHref = null;
82
+ this.dialogBody = '';
83
+ this.dialogTitle = '';
84
+ this.dialogLabels = [];
85
+ this.dialogImportant = false;
86
+ this.dialogTouched = false;
87
+ this.deleteConfirmOpen = false;
88
+ this.dialogOpen = true;
89
+ };
90
+ /** Opens the same dialog pre-filled from an existing memo row/record —
91
+ * triggered by clicking a card or a table row. No separate detail page. */
92
+ this.openEdit = (row) => {
93
+ var _a, _b;
94
+ if (this.readOnly)
95
+ return;
96
+ const href = (_b = (_a = row === null || row === void 0 ? void 0 : row._links) === null || _a === void 0 ? void 0 : _a.self) === null || _b === void 0 ? void 0 : _b.href;
97
+ if (!href)
98
+ return;
99
+ this.editingHref = href;
100
+ const bodyRaw = this.slotValue(row, 'body');
101
+ this.dialogBody = bodyRaw != null ? String(bodyRaw) : '';
102
+ const titleRaw = this.slotValue(row, 'title');
103
+ this.dialogTitle = titleRaw != null ? String(titleRaw) : '';
104
+ const labelsRaw = this.slotValue(row, 'labels');
105
+ this.dialogLabels = Array.isArray(labelsRaw)
106
+ ? labelsRaw.map(String)
107
+ : (labelsRaw != null && labelsRaw !== '' ? [String(labelsRaw)] : []);
108
+ this.dialogImportant = !!this.slotValue(row, 'important');
109
+ this.dialogTouched = false;
110
+ this.deleteConfirmOpen = false;
111
+ this.dialogOpen = true;
112
+ };
113
+ this.closeDialog = () => {
114
+ this.dialogOpen = false;
115
+ this.deleteConfirmOpen = false;
116
+ };
117
+ this.openDeleteConfirm = () => {
118
+ this.deleteConfirmOpen = true;
119
+ };
120
+ this.cancelDeleteConfirm = () => {
121
+ this.deleteConfirmOpen = false;
122
+ };
123
+ this.confirmDelete = () => {
124
+ var _a;
125
+ if (!this.editingHref)
126
+ return;
127
+ const href = this.editingHref;
128
+ this.mrdDeleteObject.emit({ href });
129
+ if (this.mode === 'cards') {
130
+ (_a = this.listEl) === null || _a === void 0 ? void 0 : _a.removeRow(href);
131
+ }
132
+ else {
133
+ this.refresh();
134
+ }
135
+ this.deleteConfirmOpen = false;
136
+ this.dialogOpen = false;
137
+ };
138
+ this.submitDialog = () => {
139
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
140
+ this.dialogTouched = true;
141
+ if (!this.dialogBody.trim())
142
+ return;
143
+ const slots = (_b = (_a = this.archetype) === null || _a === void 0 ? void 0 : _a.slots) !== null && _b !== void 0 ? _b : {};
144
+ if (this.editingHref) {
145
+ // Every shown field is sent explicitly, even when cleared/unchecked —
146
+ // this is a PATCH, so omitting a field would leave its old value intact.
147
+ const values = { [(_c = slots.body) !== null && _c !== void 0 ? _c : 'body']: this.dialogBody };
148
+ if (this.hasTitleSlot)
149
+ values[(_d = slots.title) !== null && _d !== void 0 ? _d : 'title'] = this.dialogTitle.trim() || null;
150
+ if (((_e = this.labelsListItems) !== null && _e !== void 0 ? _e : []).length)
151
+ values[(_f = slots.labels) !== null && _f !== void 0 ? _f : 'labels'] = this.dialogLabels;
152
+ if (this.hasImportantSlot)
153
+ values[(_g = slots.important) !== null && _g !== void 0 ? _g : 'important'] = this.dialogImportant;
154
+ this.mrdUpdateObject.emit({ href: this.editingHref, values });
155
+ if (this.mode === 'cards') {
156
+ (_h = this.listEl) === null || _h === void 0 ? void 0 : _h.patchRow(this.editingHref, values);
157
+ }
158
+ else {
159
+ this.refresh();
160
+ }
161
+ }
162
+ else {
163
+ if (!this.canAdd)
164
+ return;
165
+ const values = {
166
+ [(_j = slots.body) !== null && _j !== void 0 ? _j : 'body']: this.dialogBody,
167
+ // now(), same token/format mrd-form's own defaultValue resolution uses.
168
+ [(_k = slots.date) !== null && _k !== void 0 ? _k : 'date']: new Date().toISOString().replace(/\.\d{3}Z$/, 'Z'),
169
+ };
170
+ if (this.hasTitleSlot && this.dialogTitle.trim())
171
+ values[(_l = slots.title) !== null && _l !== void 0 ? _l : 'title'] = this.dialogTitle.trim();
172
+ if (((_m = this.labelsListItems) !== null && _m !== void 0 ? _m : []).length && this.dialogLabels.length)
173
+ values[(_o = slots.labels) !== null && _o !== void 0 ? _o : 'labels'] = this.dialogLabels;
174
+ if (this.hasImportantSlot && this.dialogImportant)
175
+ values[(_p = slots.important) !== null && _p !== void 0 ? _p : 'important'] = true;
176
+ if (this.meHref())
177
+ values[(_q = slots.author) !== null && _q !== void 0 ? _q : 'author'] = this.meHref();
178
+ // Always explicit — relation values are never inferred from the URL elsewhere
179
+ // in this codebase (e.g. mrd-form's own submit payload), so don't assume it here.
180
+ values[(_r = slots.container) !== null && _r !== void 0 ? _r : 'container'] = this.effectiveContainerHref;
181
+ this.mrdCreateObject.emit({ path: this.buildCreatePath(), values });
182
+ }
183
+ this.dialogOpen = false;
184
+ };
185
+ }
186
+ disconnectedCallback() {
187
+ this.unbindEscape();
188
+ }
189
+ /** Escape backs out of the delete-confirm step first (matches Cancel there),
190
+ * or closes the whole dialog. Bound to `document` — bubbling from inside the
191
+ * Quill editor is not reliable enough to rely on a local key handler. */
192
+ dialogOpenChanged(open) {
193
+ if (open) {
194
+ this.escapeHandler = (e) => {
195
+ if (e.key !== 'Escape')
196
+ return;
197
+ if (this.deleteConfirmOpen)
198
+ this.cancelDeleteConfirm();
199
+ else
200
+ this.closeDialog();
201
+ };
202
+ document.addEventListener('keydown', this.escapeHandler);
203
+ }
204
+ else {
205
+ this.unbindEscape();
206
+ }
207
+ }
208
+ unbindEscape() {
209
+ if (this.escapeHandler) {
210
+ document.removeEventListener('keydown', this.escapeHandler);
211
+ this.escapeHandler = null;
212
+ }
213
+ }
214
+ /** Neither body self-loads: like mrd-table, both wait for init(). mrd-layout-section
215
+ * init()s whichever is mounted at load time via its own querySelector pass; when the
216
+ * user switches mode here, the freshly mounted body needs the same treatment. */
217
+ componentDidRender() {
218
+ var _a, _b;
219
+ if (this.mode === 'cards' && this.listEl && !this.listInited) {
220
+ this.listInited = true;
221
+ const list = this.listEl;
222
+ Promise.resolve((_a = list.componentOnReady) === null || _a === void 0 ? void 0 : _a.call(list)).then(() => list.init());
223
+ }
224
+ if (this.mode === 'table' && this.tableEl && !this.tableInited) {
225
+ this.tableInited = true;
226
+ const table = this.tableEl;
227
+ Promise.resolve((_b = table.componentOnReady) === null || _b === void 0 ? void 0 : _b.call(table)).then(() => table.init());
228
+ }
229
+ }
230
+ setMode(mode) {
231
+ if (mode === this.mode)
232
+ return;
233
+ this.listInited = false;
234
+ this.tableInited = false;
235
+ this.mode = mode;
236
+ }
237
+ /** Re-request page 0 of whichever body is currently mounted — called by
238
+ * mrd-layout-section after a successful mrdCreateObject, and by this
239
+ * component itself after an edit to a table row (which has no per-row
240
+ * optimistic-patch method the way mrd-memo-list does). */
241
+ async refresh() {
242
+ if (this.mode === 'cards' && this.listEl) {
243
+ await this.listEl.init();
244
+ }
245
+ else if (this.mode === 'table' && this.tableEl) {
246
+ await this.tableEl.init();
247
+ }
248
+ }
249
+ /** `me` is typed as RelationSearchResult ({ id, label }) but hosts differ on
250
+ * which shape they actually populate: this repo's own dev preview resolves
251
+ * it via /accounts/me as a real { id, label } RelationSearchResult, while
252
+ * content-app feeds it from userProfile.links.person, the raw API link shape
253
+ * ({ href, name }). Both occur in practice — same dual tolerance as
254
+ * mrd-form's own getHref(). */
255
+ meHref() {
256
+ var _a, _b;
257
+ const m = this.me;
258
+ return (_b = (_a = m === null || m === void 0 ? void 0 : m.id) !== null && _a !== void 0 ? _a : m === null || m === void 0 ? void 0 : m.href) !== null && _b !== void 0 ? _b : '';
259
+ }
260
+ /** Value of a value-slot: reads row[field] via the slot→field map. */
261
+ slotValue(row, slot) {
262
+ var _a, _b;
263
+ const field = (_b = (_a = this.archetype) === null || _a === void 0 ? void 0 : _a.slots) === null || _b === void 0 ? void 0 : _b[slot];
264
+ if (!field)
265
+ return undefined;
266
+ return row[field];
267
+ }
268
+ get hasTitleSlot() {
269
+ var _a, _b;
270
+ return !!((_b = (_a = this.archetype) === null || _a === void 0 ? void 0 : _a.slots) === null || _b === void 0 ? void 0 : _b.title);
271
+ }
272
+ get hasImportantSlot() {
273
+ var _a, _b;
274
+ return !!((_b = (_a = this.archetype) === null || _a === void 0 ? void 0 : _a.slots) === null || _b === void 0 ? void 0 : _b.important);
275
+ }
276
+ /** A parent record already gives a new memo somewhere to attach to (RELATED_VIEW);
277
+ * otherwise fall back to the account's own linked person (top-level VIEW) — but
278
+ * only when containerRelated allows it (see its doc comment). */
279
+ get effectiveContainerHref() {
280
+ if (!this.containerRelated)
281
+ return '';
282
+ return this.containerHref || this.meHref();
283
+ }
284
+ /** The author slot is always filled from `me` (there is no author picker in
285
+ * the dialog), so without it there is nothing valid to create — regardless
286
+ * of whether a parent record already supplies a container. */
287
+ get canAdd() {
288
+ return !this.readOnly && !!this.meHref() && !!this.effectiveContainerHref;
289
+ }
290
+ /** Path for creating a new memo: `/{dataClass}` for a top-level VIEW, or
291
+ * `/{fromClass}/{parentId}/{dataClass}` when nested under a parent record. */
292
+ buildCreatePath() {
293
+ var _a, _b, _c, _d, _e, _f, _g;
294
+ return buildListPath({
295
+ isRelatedView: ((_a = this.item) === null || _a === void 0 ? void 0 : _a.type) === ClientLayoutItemType.RELATED_VIEW,
296
+ fromClass: (_b = this.item) === null || _b === void 0 ? void 0 : _b.fromClass,
297
+ parentId: this.parentId,
298
+ dataClass: (_f = (_d = (_c = this.item) === null || _c === void 0 ? void 0 : _c.filterClass) !== null && _d !== void 0 ? _d : (_e = this.item) === null || _e === void 0 ? void 0 : _e.dataClass) !== null && _f !== void 0 ? _f : (_g = this.item) === null || _g === void 0 ? void 0 : _g.relatedClass,
299
+ });
300
+ }
301
+ renderToolbar() {
302
+ return (h("div", { class: "mrd-memo-container__toolbar" }, this.mode === 'cards' && (h("button", { type: "button", class: "mrd-memo-container__action", disabled: !this.canAdd, title: this.readOnly ? t('readonly_access', this.locale) : undefined, onClick: this.openCreate }, 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 5v14M5 12h14" })), t('memo_new', this.locale))), h("div", { class: "mrd-memo-container__seg", role: "group", "aria-label": t('doc_view_switch', this.locale) }, h("button", { class: "mrd-memo-container__seg-btn", "aria-pressed": String(this.mode === 'cards'), title: t('memo_view_cards', this.locale), "aria-label": t('memo_view_cards', this.locale), onClick: () => this.setMode('cards') }, h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("rect", { x: "3", y: "4", width: "7", height: "7", rx: "1" }), h("rect", { x: "14", y: "4", width: "7", height: "7", rx: "1" }), h("rect", { x: "3", y: "15", width: "7", height: "5", rx: "1" }), h("rect", { x: "14", y: "15", width: "7", height: "5", rx: "1" }))), h("button", { class: "mrd-memo-container__seg-btn", "aria-pressed": String(this.mode === 'table'), title: t('memo_view_table', this.locale), "aria-label": t('memo_view_table', this.locale), onClick: () => this.setMode('table') }, 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: "M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01" }))))));
303
+ }
304
+ renderDeleteConfirm() {
305
+ return (h("div", null, h("h2", { class: "mrd-memo-container__modal-title" }, t('memo_delete_confirm_title', this.locale)), h("p", { class: "mrd-memo-container__modal-warning" }, t('memo_delete_confirm_body', this.locale)), h("div", { class: "mrd-memo-container__modal-actions" }, h("button", { type: "button", class: "mrd-memo-container__modal-cancel", onClick: this.cancelDeleteConfirm }, t('cancel', this.locale)), h("button", { type: "button", class: "mrd-memo-container__modal-delete-confirm", onClick: this.confirmDelete }, t('delete', this.locale)))));
306
+ }
307
+ renderForm() {
308
+ var _a, _b, _c;
309
+ const bodyMissing = this.dialogTouched && !this.dialogBody.trim();
310
+ return [
311
+ h("h2", { class: "mrd-memo-container__modal-title" }, t(this.editingHref ? 'memo_edit' : 'memo_new', this.locale)),
312
+ h("div", { class: "mrd-memo-container__modal-field" }, h("mrd-textarea-field", { key: (_a = this.editingHref) !== null && _a !== void 0 ? _a : 'new', name: "body", value: this.dialogBody, required: true, autofocus: true, locale: this.locale, onMrdChange: (e) => { this.dialogBody = e.detail.value; } }), bodyMissing && h("span", { class: "mrd-memo-container__modal-error" }, t('required', this.locale))),
313
+ this.hasTitleSlot && (h("div", { class: "mrd-memo-container__modal-field" }, h("mrd-text-field", { name: "title", label: t('memo_field_title', this.locale), value: this.dialogTitle, locale: this.locale, onMrdChange: (e) => { this.dialogTitle = e.detail.value; } }))),
314
+ !!((_b = this.labelsListItems) !== null && _b !== void 0 ? _b : []).length && (h("div", { class: "mrd-memo-container__modal-field" }, h("mrd-list-field", { name: "labels", label: t('memo_field_labels', this.locale), value: this.dialogLabels, multiple: true, listItems: (_c = this.labelsListItems) !== null && _c !== void 0 ? _c : [], locale: this.locale, onMrdChange: (e) => {
315
+ this.dialogLabels = Array.isArray(e.detail.value) ? e.detail.value : [e.detail.value].filter(Boolean);
316
+ } }))),
317
+ this.hasImportantSlot && (h("div", { class: "mrd-memo-container__modal-field" }, h("mrd-boolean-field", { name: "important", label: t('memo_important', this.locale), value: this.dialogImportant, locale: this.locale, onMrdChange: (e) => { this.dialogImportant = e.detail.value; } }))),
318
+ h("div", { class: "mrd-memo-container__modal-actions" }, this.editingHref && (h("button", { type: "button", class: "mrd-memo-container__modal-delete", onClick: this.openDeleteConfirm }, t('delete', this.locale))), h("button", { type: "button", class: "mrd-memo-container__modal-cancel", onClick: this.closeDialog }, t('cancel', this.locale)), h("button", { type: "button", class: "mrd-memo-container__modal-submit", onClick: this.submitDialog }, t('submit', this.locale))),
319
+ ];
320
+ }
321
+ renderDialog() {
322
+ if (!this.dialogOpen)
323
+ return null;
324
+ return (h("div", { class: "mrd-memo-container__modal-backdrop", onClick: this.closeDialog }, h("div", { class: "mrd-memo-container__modal", onClick: (e) => e.stopPropagation() }, this.deleteConfirmOpen ? this.renderDeleteConfirm() : this.renderForm())));
325
+ }
326
+ renderCards() {
327
+ return (h("mrd-memo-list", { "data-view": this.viewKey, ref: el => (this.listEl = el), item: this.item, archetype: this.archetype, parentId: this.parentId, locale: this.locale, readOnly: this.readOnly, labelsListItems: this.labelsListItems, showContainerLink: this.showContainerLink, onMrdLoadPage: (e) => {
328
+ e.stopPropagation();
329
+ this.mrdLoadPage.emit(e.detail);
330
+ }, onMrdEdit: (e) => {
331
+ e.stopPropagation();
332
+ this.openEdit(e.detail.row);
333
+ }, onMrdNavigate: (e) => {
334
+ e.stopPropagation();
335
+ this.mrdNavigate.emit(e.detail);
336
+ } }));
337
+ }
338
+ renderTable() {
339
+ return (h("mrd-table", { "data-view": this.viewKey, ref: el => (this.tableEl = el), item: this.item, parentId: this.parentId, locale: this.locale, readOnly: this.readOnly, onMrdLoadPage: (e) => {
340
+ e.stopPropagation();
341
+ this.mrdLoadPage.emit(e.detail);
342
+ }, onMrdLoadAggregations: (e) => {
343
+ e.stopPropagation();
344
+ this.mrdLoadAggregations.emit(e.detail);
345
+ }, onMrdRowClick: (e) => {
346
+ e.stopPropagation();
347
+ this.openEdit(e.detail.row);
348
+ }, onMrdAction: (e) => {
349
+ e.stopPropagation();
350
+ this.mrdAction.emit(e.detail);
351
+ } }));
352
+ }
353
+ render() {
354
+ return (h(Host, { key: 'a000221db6b1ba12351f38619f319b277b791f68' }, this.renderToolbar(), h("div", { key: '712951c8e391ed693bf6e4263c4f1076172b0451', class: "mrd-memo-container__body" }, this.mode === 'cards' ? this.renderCards() : this.renderTable()), this.renderDialog()));
355
+ }
356
+ static get is() { return "mrd-memo-container"; }
357
+ static get encapsulation() { return "scoped"; }
358
+ static get originalStyleUrls() {
359
+ return {
360
+ "$": ["mrd-memo-container.scss"]
361
+ };
362
+ }
363
+ static get styleUrls() {
364
+ return {
365
+ "$": ["mrd-memo-container.css"]
366
+ };
367
+ }
368
+ static get properties() {
369
+ return {
370
+ "item": {
371
+ "type": "unknown",
372
+ "mutable": false,
373
+ "complexType": {
374
+ "original": "ClientLayoutItem | null",
375
+ "resolved": "ClientLayoutItem | null",
376
+ "references": {
377
+ "ClientLayoutItem": {
378
+ "location": "import",
379
+ "path": "../../../types/client-layout",
380
+ "id": "src/types/client-layout.ts::ClientLayoutItem",
381
+ "referenceLocation": "ClientLayoutItem"
382
+ }
383
+ }
384
+ },
385
+ "required": false,
386
+ "optional": false,
387
+ "docs": {
388
+ "tags": [],
389
+ "text": "The VIEW or RELATED_VIEW layout item (dataClass, fromClass, view config)."
390
+ },
391
+ "getter": false,
392
+ "setter": false,
393
+ "defaultValue": "null"
394
+ },
395
+ "archetype": {
396
+ "type": "unknown",
397
+ "mutable": false,
398
+ "complexType": {
399
+ "original": "ClientArchetype",
400
+ "resolved": "ClientArchetype",
401
+ "references": {
402
+ "ClientArchetype": {
403
+ "location": "import",
404
+ "path": "../../../types/client-layout",
405
+ "id": "src/types/client-layout.ts::ClientArchetype",
406
+ "referenceLocation": "ClientArchetype"
407
+ }
408
+ }
409
+ },
410
+ "required": true,
411
+ "optional": false,
412
+ "docs": {
413
+ "tags": [],
414
+ "text": "Resolved `commons.memo` archetype binding."
415
+ },
416
+ "getter": false,
417
+ "setter": false
418
+ },
419
+ "parentId": {
420
+ "type": "string",
421
+ "mutable": false,
422
+ "complexType": {
423
+ "original": "string",
424
+ "resolved": "string",
425
+ "references": {}
426
+ },
427
+ "required": false,
428
+ "optional": false,
429
+ "docs": {
430
+ "tags": [],
431
+ "text": "Parent record id \u2014 required for RELATED_VIEW path building."
432
+ },
433
+ "getter": false,
434
+ "setter": false,
435
+ "reflect": false,
436
+ "attribute": "parent-id",
437
+ "defaultValue": "''"
438
+ },
439
+ "containerHref": {
440
+ "type": "string",
441
+ "mutable": false,
442
+ "complexType": {
443
+ "original": "string",
444
+ "resolved": "string",
445
+ "references": {}
446
+ },
447
+ "required": false,
448
+ "optional": false,
449
+ "docs": {
450
+ "tags": [],
451
+ "text": "Canonical parent href \u2014 set when this is a RELATED_VIEW embedded under a\nparent record, which already gives a new memo something to attach to."
452
+ },
453
+ "getter": false,
454
+ "setter": false,
455
+ "reflect": false,
456
+ "attribute": "container-href",
457
+ "defaultValue": "''"
458
+ },
459
+ "containerRelated": {
460
+ "type": "boolean",
461
+ "mutable": false,
462
+ "complexType": {
463
+ "original": "boolean",
464
+ "resolved": "boolean",
465
+ "references": {}
466
+ },
467
+ "required": false,
468
+ "optional": false,
469
+ "docs": {
470
+ "tags": [],
471
+ "text": "False when this RELATED_VIEW's parent is related via a relation other than\nthe archetype's container slot (e.g. a person's \"memos I authored\" list,\nrelated via `author`) \u2014 mrd-layout-section resolves this from the item's\n`inverseRelation`. In that case the parent is not a valid container for a\nnew memo, and \u2014 unlike a top-level VIEW with no context at all \u2014 falling\nback to `me` would be wrong too (creating a memo \"on myself\" from someone\nelse's authored-memos list makes no sense), so \"New memo\" is hidden outright."
472
+ },
473
+ "getter": false,
474
+ "setter": false,
475
+ "reflect": false,
476
+ "attribute": "container-related",
477
+ "defaultValue": "true"
478
+ },
479
+ "showContainerLink": {
480
+ "type": "boolean",
481
+ "mutable": false,
482
+ "complexType": {
483
+ "original": "boolean",
484
+ "resolved": "boolean",
485
+ "references": {}
486
+ },
487
+ "required": false,
488
+ "optional": false,
489
+ "docs": {
490
+ "tags": [],
491
+ "text": "True unless this is a container-scoped RELATED_VIEW (a company's own memo\ntab, say) where every card's container is obviously the page you're\nalready on \u2014 forwarded to mrd-memo-list to show/hide its per-card\ncontainer link. A top-level VIEW or an author-scoped RELATED_VIEW both\nstill need it, since the container isn't implied by the page context."
492
+ },
493
+ "getter": false,
494
+ "setter": false,
495
+ "reflect": false,
496
+ "attribute": "show-container-link",
497
+ "defaultValue": "true"
498
+ },
499
+ "viewKey": {
500
+ "type": "string",
501
+ "mutable": false,
502
+ "complexType": {
503
+ "original": "string",
504
+ "resolved": "string",
505
+ "references": {}
506
+ },
507
+ "required": false,
508
+ "optional": false,
509
+ "docs": {
510
+ "tags": [],
511
+ "text": "Lookup key used for the embedded `data-view` attribute."
512
+ },
513
+ "getter": false,
514
+ "setter": false,
515
+ "reflect": false,
516
+ "attribute": "view-key",
517
+ "defaultValue": "''"
518
+ },
519
+ "locale": {
520
+ "type": "string",
521
+ "mutable": false,
522
+ "complexType": {
523
+ "original": "string",
524
+ "resolved": "string",
525
+ "references": {}
526
+ },
527
+ "required": false,
528
+ "optional": false,
529
+ "docs": {
530
+ "tags": [],
531
+ "text": ""
532
+ },
533
+ "getter": false,
534
+ "setter": false,
535
+ "reflect": false,
536
+ "attribute": "locale",
537
+ "defaultValue": "navigator.language"
538
+ },
539
+ "labelsListItems": {
540
+ "type": "unknown",
541
+ "mutable": false,
542
+ "complexType": {
543
+ "original": "ClientListValue[] | null",
544
+ "resolved": "ClientListValue[] | null",
545
+ "references": {
546
+ "ClientListValue": {
547
+ "location": "import",
548
+ "path": "../../../types/client-layout",
549
+ "id": "src/types/client-layout.ts::ClientListValue",
550
+ "referenceLocation": "ClientListValue"
551
+ }
552
+ }
553
+ },
554
+ "required": false,
555
+ "optional": false,
556
+ "docs": {
557
+ "tags": [],
558
+ "text": "listItems of the FIELD bound to the `labels` slot; forwarded to whichever\nbody is mounted and used to render the dialog's label checkboxes."
559
+ },
560
+ "getter": false,
561
+ "setter": false,
562
+ "defaultValue": "null"
563
+ },
564
+ "readOnly": {
565
+ "type": "boolean",
566
+ "mutable": false,
567
+ "complexType": {
568
+ "original": "boolean",
569
+ "resolved": "boolean",
570
+ "references": {}
571
+ },
572
+ "required": false,
573
+ "optional": false,
574
+ "docs": {
575
+ "tags": [],
576
+ "text": "When true, this dashboard is read-only: \"New memo\" is disabled with a\ntooltip, cards/rows are not clickable, and the embedded table's own\ncreate action is disabled too."
577
+ },
578
+ "getter": false,
579
+ "setter": false,
580
+ "reflect": false,
581
+ "attribute": "read-only",
582
+ "defaultValue": "false"
583
+ },
584
+ "me": {
585
+ "type": "unknown",
586
+ "mutable": false,
587
+ "complexType": {
588
+ "original": "RelationSearchResult | null",
589
+ "resolved": "RelationSearchResult | null",
590
+ "references": {
591
+ "RelationSearchResult": {
592
+ "location": "import",
593
+ "path": "../../../types/client-layout",
594
+ "id": "src/types/client-layout.ts::RelationSearchResult",
595
+ "referenceLocation": "RelationSearchResult"
596
+ }
597
+ }
598
+ },
599
+ "required": false,
600
+ "optional": false,
601
+ "docs": {
602
+ "tags": [],
603
+ "text": "The active account's linked person record (userProfile.links.person), if any.\nUsed both to gate \"New memo\" (see effectiveContainerHref) and, on submit, to\nfill the author slot."
604
+ },
605
+ "getter": false,
606
+ "setter": false,
607
+ "defaultValue": "null"
608
+ }
609
+ };
610
+ }
611
+ static get states() {
612
+ return {
613
+ "mode": {},
614
+ "dialogOpen": {},
615
+ "editingHref": {},
616
+ "dialogBody": {},
617
+ "dialogTitle": {},
618
+ "dialogLabels": {},
619
+ "dialogImportant": {},
620
+ "dialogTouched": {},
621
+ "deleteConfirmOpen": {}
622
+ };
623
+ }
624
+ static get events() {
625
+ return [{
626
+ "method": "mrdLoadPage",
627
+ "name": "mrdLoadPage",
628
+ "bubbles": true,
629
+ "cancelable": true,
630
+ "composed": true,
631
+ "docs": {
632
+ "tags": [],
633
+ "text": ""
634
+ },
635
+ "complexType": {
636
+ "original": "{ page: number; sort: string; path: string; qs: string }",
637
+ "resolved": "{ page: number; sort: string; path: string; qs: string; }",
638
+ "references": {}
639
+ }
640
+ }, {
641
+ "method": "mrdLoadAggregations",
642
+ "name": "mrdLoadAggregations",
643
+ "bubbles": true,
644
+ "cancelable": true,
645
+ "composed": true,
646
+ "docs": {
647
+ "tags": [],
648
+ "text": ""
649
+ },
650
+ "complexType": {
651
+ "original": "{ path: string; qs: string; aggQs: string }",
652
+ "resolved": "{ path: string; qs: string; aggQs: string; }",
653
+ "references": {}
654
+ }
655
+ }, {
656
+ "method": "mrdNavigate",
657
+ "name": "mrdNavigate",
658
+ "bubbles": true,
659
+ "cancelable": true,
660
+ "composed": true,
661
+ "docs": {
662
+ "tags": [],
663
+ "text": "A card's container link was clicked \u2014 real navigation, unrelated to the\nquick-edit dialog (mrdEdit is internal, handled by this component itself)."
664
+ },
665
+ "complexType": {
666
+ "original": "{ href?: string; label: string }",
667
+ "resolved": "{ href?: string | undefined; label: string; }",
668
+ "references": {}
669
+ }
670
+ }, {
671
+ "method": "mrdAction",
672
+ "name": "mrdAction",
673
+ "bubbles": true,
674
+ "cancelable": true,
675
+ "composed": true,
676
+ "docs": {
677
+ "tags": [],
678
+ "text": "Only the embedded table's own toolbar (export, etc.) still routes through this."
679
+ },
680
+ "complexType": {
681
+ "original": "{ action: string; path?: string; qs?: string; parentPath?: string | null; basicType?: string }",
682
+ "resolved": "{ action: string; path?: string | undefined; qs?: string | undefined; parentPath?: string | null | undefined; basicType?: string | undefined; }",
683
+ "references": {}
684
+ }
685
+ }, {
686
+ "method": "mrdCreateObject",
687
+ "name": "mrdCreateObject",
688
+ "bubbles": true,
689
+ "cancelable": true,
690
+ "composed": true,
691
+ "docs": {
692
+ "tags": [],
693
+ "text": "Quick-create submit. Host POSTs `values` to `path`, same as mrd-document-list's."
694
+ },
695
+ "complexType": {
696
+ "original": "{ path: string; values: Record<string, unknown> }",
697
+ "resolved": "{ path: string; values: Record<string, unknown>; }",
698
+ "references": {
699
+ "Record": {
700
+ "location": "global",
701
+ "id": "global::Record"
702
+ }
703
+ }
704
+ }
705
+ }, {
706
+ "method": "mrdUpdateObject",
707
+ "name": "mrdUpdateObject",
708
+ "bubbles": true,
709
+ "cancelable": true,
710
+ "composed": true,
711
+ "docs": {
712
+ "tags": [],
713
+ "text": "Quick-edit submit. Host PATCHes `href` with `values`, same as mrd-document-list's drag-move."
714
+ },
715
+ "complexType": {
716
+ "original": "{ href: string; values: Record<string, unknown> }",
717
+ "resolved": "{ href: string; values: Record<string, unknown>; }",
718
+ "references": {
719
+ "Record": {
720
+ "location": "global",
721
+ "id": "global::Record"
722
+ }
723
+ }
724
+ }
725
+ }, {
726
+ "method": "mrdDeleteObject",
727
+ "name": "mrdDeleteObject",
728
+ "bubbles": true,
729
+ "cancelable": true,
730
+ "composed": true,
731
+ "docs": {
732
+ "tags": [],
733
+ "text": "Confirmed delete. Host DELETEs `href` \u2014 fire-and-forget, same as mrdUpdateObject;\nthe row is removed optimistically here rather than waiting on a callback."
734
+ },
735
+ "complexType": {
736
+ "original": "{ href: string }",
737
+ "resolved": "{ href: string; }",
738
+ "references": {}
739
+ }
740
+ }];
741
+ }
742
+ static get methods() {
743
+ return {
744
+ "refresh": {
745
+ "complexType": {
746
+ "signature": "() => Promise<void>",
747
+ "parameters": [],
748
+ "references": {
749
+ "Promise": {
750
+ "location": "global",
751
+ "id": "global::Promise"
752
+ }
753
+ },
754
+ "return": "Promise<void>"
755
+ },
756
+ "docs": {
757
+ "text": "Re-request page 0 of whichever body is currently mounted \u2014 called by\nmrd-layout-section after a successful mrdCreateObject, and by this\ncomponent itself after an edit to a table row (which has no per-row\noptimistic-patch method the way mrd-memo-list does).",
758
+ "tags": []
759
+ }
760
+ }
761
+ };
762
+ }
763
+ static get watchers() {
764
+ return [{
765
+ "propName": "dialogOpen",
766
+ "methodName": "dialogOpenChanged"
767
+ }];
768
+ }
769
+ }