@mmlogic/components 0.3.2 → 0.3.4

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 (64) hide show
  1. package/dist/cjs/index.cjs.js +1 -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_19.cjs.entry.js → mrd-boolean-field_20.cjs.entry.js} +594 -67
  5. package/dist/collection/collection-manifest.json +1 -0
  6. package/dist/collection/components/mrd-field/mrd-field.js +142 -27
  7. package/dist/collection/components/mrd-field/mrd-field.scss +118 -0
  8. package/dist/collection/components/mrd-form/mrd-form.js +3 -3
  9. package/dist/collection/components/mrd-hyperlink-field/mrd-hyperlink-field.js +79 -18
  10. package/dist/collection/components/mrd-hyperlink-field/mrd-hyperlink-field.scss +22 -0
  11. package/dist/collection/components/mrd-image-field/mrd-image-field.js +1 -1
  12. package/dist/collection/components/mrd-layout-section/mrd-layout-section.js +54 -15
  13. package/dist/collection/components/mrd-layout-section/mrd-layout-section.scss +76 -0
  14. package/dist/collection/components/mrd-longtext-field/mrd-longtext-field.js +1 -1
  15. package/dist/collection/components/mrd-number-field/mrd-number-field.js +2 -2
  16. package/dist/collection/components/mrd-secret-field/mrd-secret-field.js +229 -0
  17. package/dist/collection/components/mrd-secret-field/mrd-secret-field.scss +73 -0
  18. package/dist/collection/components/mrd-table/mrd-table.js +46 -6
  19. package/dist/collection/components/mrd-table/mrd-table.scss +36 -0
  20. package/dist/collection/components/mrd-text-field/mrd-text-field.js +1 -1
  21. package/dist/collection/components/mrd-textarea-field/mrd-textarea-field.js +1 -1
  22. package/dist/collection/components/mrd-time-field/mrd-time-field.js +1 -1
  23. package/dist/collection/dev/api.js +1 -1
  24. package/dist/collection/dev/app.js +9 -4
  25. package/dist/collection/dev/example-data.js +12 -2
  26. package/dist/collection/types/client-layout.js +1 -0
  27. package/dist/collection/utils/cell-renderer.js +2 -0
  28. package/dist/collection/utils/i18n.js +269 -1
  29. package/dist/collection/utils/validation.js +6 -2
  30. package/dist/components/client-layout.js +1 -1
  31. package/dist/components/format.js +1 -1
  32. package/dist/components/i18n.js +1 -1
  33. package/dist/components/mrd-field2.js +1 -1
  34. package/dist/components/mrd-form.js +1 -1
  35. package/dist/components/mrd-hyperlink-field2.js +1 -1
  36. package/dist/components/mrd-image-field2.js +1 -1
  37. package/dist/components/mrd-layout-section.js +1 -1
  38. package/dist/components/mrd-longtext-field2.js +1 -1
  39. package/dist/components/mrd-number-field2.js +1 -1
  40. package/dist/components/mrd-secret-field.d.ts +11 -0
  41. package/dist/components/mrd-secret-field.js +1 -0
  42. package/dist/components/mrd-secret-field2.js +1 -0
  43. package/dist/components/mrd-table2.js +1 -1
  44. package/dist/components/mrd-text-field2.js +1 -1
  45. package/dist/components/mrd-textarea-field2.js +1 -1
  46. package/dist/components/mrd-time-field2.js +1 -1
  47. package/dist/components/validation.js +1 -1
  48. package/dist/esm/index.js +1 -0
  49. package/dist/esm/loader.js +1 -1
  50. package/dist/esm/mosterdcomponents.js +1 -1
  51. package/dist/esm/{mrd-boolean-field_19.entry.js → mrd-boolean-field_20.entry.js} +594 -68
  52. package/dist/mosterdcomponents/index.esm.js +1 -1
  53. package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
  54. package/dist/mosterdcomponents/p-c9839596.entry.js +1 -0
  55. package/dist/types/components/mrd-field/mrd-field.d.ts +14 -0
  56. package/dist/types/components/mrd-hyperlink-field/mrd-hyperlink-field.d.ts +12 -4
  57. package/dist/types/components/mrd-layout-section/mrd-layout-section.d.ts +5 -0
  58. package/dist/types/components/mrd-secret-field/mrd-secret-field.d.ts +22 -0
  59. package/dist/types/components/mrd-table/mrd-table.d.ts +6 -0
  60. package/dist/types/components.d.ts +109 -13
  61. package/dist/types/types/client-layout.d.ts +14 -1
  62. package/dist/types/utils/cell-renderer.d.ts +1 -0
  63. package/package.json +1 -1
  64. package/dist/mosterdcomponents/p-2a099635.entry.js +0 -1
@@ -2,6 +2,7 @@ import { Host, h } from "@stencil/core";
2
2
  import { ClientLayoutItemType, ClientLayoutItemFieldDataType, } from "../../types/client-layout";
3
3
  import { CellRenderer } from "../../utils/cell-renderer";
4
4
  import { t } from "../../utils/i18n";
5
+ import { formatDate } from "../../utils/format";
5
6
  export class MrdLayoutSection {
6
7
  constructor() {
7
8
  /** Items from one layout entry in ClientDashboardMetadata.layouts[]. */
@@ -17,6 +18,8 @@ export class MrdLayoutSection {
17
18
  this.searchResultsMap = {};
18
19
  this.imagePreviewUrl = null;
19
20
  this.imagePreviews = {};
21
+ this.openHistoryField = null;
22
+ this.historyClickOutside = null;
20
23
  this.searchTimers = {};
21
24
  this.handleViewLoadPage = (e, name) => {
22
25
  e.stopPropagation();
@@ -40,6 +43,17 @@ export class MrdLayoutSection {
40
43
  this.initEmbeddedTables();
41
44
  this.emitLoadImages();
42
45
  }, 0);
46
+ this.historyClickOutside = (e) => {
47
+ if (!this.el.contains(e.target))
48
+ this.openHistoryField = null;
49
+ };
50
+ document.addEventListener('mousedown', this.historyClickOutside);
51
+ }
52
+ disconnectedCallback() {
53
+ if (this.historyClickOutside) {
54
+ document.removeEventListener('mousedown', this.historyClickOutside);
55
+ this.historyClickOutside = null;
56
+ }
43
57
  }
44
58
  dataChanged(newVal) {
45
59
  if (newVal && Object.keys(newVal).length > 0) {
@@ -124,13 +138,13 @@ export class MrdLayoutSection {
124
138
  return null;
125
139
  }
126
140
  renderSingleFieldValue(item, value) {
127
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
141
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
128
142
  const dt = item.dataType;
129
143
  switch (dt) {
130
144
  case ClientLayoutItemFieldDataType.HYPERLINK: {
131
145
  const v = value;
132
146
  const href = (_a = v === null || v === void 0 ? void 0 : v.href) !== null && _a !== void 0 ? _a : String(value);
133
- const label = (_c = (_b = v === null || v === void 0 ? void 0 : v.text) !== null && _b !== void 0 ? _b : v === null || v === void 0 ? void 0 : v.label) !== null && _c !== void 0 ? _c : href;
147
+ const label = (_d = (_c = (_b = v === null || v === void 0 ? void 0 : v.name) !== null && _b !== void 0 ? _b : v === null || v === void 0 ? void 0 : v.text) !== null && _c !== void 0 ? _c : v === null || v === void 0 ? void 0 : v.label) !== null && _d !== void 0 ? _d : href;
134
148
  return (h("a", { class: "mrd-layout-section__link", href: href, target: "_blank", rel: "noopener noreferrer" }, label));
135
149
  }
136
150
  case ClientLayoutItemFieldDataType.TEXTBLOCK:
@@ -141,14 +155,14 @@ export class MrdLayoutSection {
141
155
  return h("pre", { class: "mrd-layout-section__pre", innerHTML: CellRenderer.formatJson(value) });
142
156
  case ClientLayoutItemFieldDataType.FILE: {
143
157
  const v = value;
144
- const fileName = (_d = v === null || v === void 0 ? void 0 : v.fileName) !== null && _d !== void 0 ? _d : String(value);
145
- const href = (_e = v === null || v === void 0 ? void 0 : v.href) !== null && _e !== void 0 ? _e : '';
158
+ const fileName = (_e = v === null || v === void 0 ? void 0 : v.fileName) !== null && _e !== void 0 ? _e : String(value);
159
+ const href = (_f = v === null || v === void 0 ? void 0 : v.href) !== null && _f !== void 0 ? _f : '';
146
160
  return (h("button", { class: "mrd-layout-section__download-link", onClick: () => href && this.mrdDownload.emit({ href, fileName }) }, h("svg", { class: "mrd-layout-section__file-icon", viewBox: "0 0 24 24", "aria-hidden": "true" }, h("path", { fill: "currentColor", d: "M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13zm-3 8l-3-3 1.41-1.41L10 14.17l4.59-4.58L16 11l-6 6z" })), t('download', this.locale)));
147
161
  }
148
162
  case ClientLayoutItemFieldDataType.IMAGE: {
149
163
  const v = value;
150
- const href = (_f = v === null || v === void 0 ? void 0 : v.href) !== null && _f !== void 0 ? _f : '';
151
- const fileName = (_g = v === null || v === void 0 ? void 0 : v.fileName) !== null && _g !== void 0 ? _g : '';
164
+ const href = (_g = v === null || v === void 0 ? void 0 : v.href) !== null && _g !== void 0 ? _g : '';
165
+ const fileName = (_h = v === null || v === void 0 ? void 0 : v.fileName) !== null && _h !== void 0 ? _h : '';
152
166
  const previewUrl = this.imagePreviews[item.name];
153
167
  if (previewUrl) {
154
168
  return (h("button", { class: "mrd-layout-section__image-thumb-btn", onClick: () => { this.imagePreviewUrl = previewUrl; }, title: fileName || undefined }, h("img", { class: "mrd-layout-section__image-thumb", src: previewUrl, alt: fileName })));
@@ -158,8 +172,8 @@ export class MrdLayoutSection {
158
172
  case ClientLayoutItemFieldDataType.BOOLEAN:
159
173
  return (h("span", { class: `mrd-layout-section__boolean mrd-layout-section__boolean--${value ? 'true' : 'false'}` }, value ? t('yes', this.locale) : t('no', this.locale)));
160
174
  case ClientLayoutItemFieldDataType.LIST: {
161
- const listItem = ((_h = item.listItems) !== null && _h !== void 0 ? _h : []).find(li => li.key === String(value));
162
- const label = (_j = listItem === null || listItem === void 0 ? void 0 : listItem.label) !== null && _j !== void 0 ? _j : String(value);
175
+ const listItem = ((_j = item.listItems) !== null && _j !== void 0 ? _j : []).find(li => li.key === String(value));
176
+ const label = (_k = listItem === null || listItem === void 0 ? void 0 : listItem.label) !== null && _k !== void 0 ? _k : String(value);
163
177
  const color = listItem === null || listItem === void 0 ? void 0 : listItem.color;
164
178
  const bg = listItem === null || listItem === void 0 ? void 0 : listItem.backgroundColor;
165
179
  if (color && bg) {
@@ -170,8 +184,10 @@ export class MrdLayoutSection {
170
184
  }
171
185
  return label;
172
186
  }
187
+ case ClientLayoutItemFieldDataType.SECRET:
188
+ return value ? h("span", { class: "mrd-layout-section__secret-masked" }, '••••••••') : null;
173
189
  default: {
174
- const text = CellRenderer.renderValue(dt, value, (_k = item.listItems) !== null && _k !== void 0 ? _k : [], this.locale);
190
+ const text = CellRenderer.renderValue(dt, value, (_l = item.listItems) !== null && _l !== void 0 ? _l : [], this.locale);
175
191
  return text || null;
176
192
  }
177
193
  }
@@ -188,10 +204,31 @@ export class MrdLayoutSection {
188
204
  }
189
205
  return this.renderSingleFieldValue(item, rawValue);
190
206
  }
207
+ renderHistoryBadge(item, raw) {
208
+ var _a, _b, _c;
209
+ const hist = (_a = item.historyEnabled) !== null && _a !== void 0 ? _a : (_b = item.field) === null || _b === void 0 ? void 0 : _b.historyEnabled;
210
+ if (!hist || !item.name)
211
+ return null;
212
+ const history = (_c = raw === null || raw === void 0 ? void 0 : raw.history) !== null && _c !== void 0 ? _c : [];
213
+ if (!history.length)
214
+ return null;
215
+ const sorted = [...history].sort((a, b) => b.until.localeCompare(a.until));
216
+ const isOpen = this.openHistoryField === item.name;
217
+ const { locale } = this;
218
+ return (h("span", { class: "mrd-layout-section__history-wrap" }, h("button", { type: "button", class: "mrd-layout-section__history-btn", title: t('history_badge_tooltip', locale), "aria-label": t('history_badge_tooltip', locale), onClick: (e) => {
219
+ e.stopPropagation();
220
+ this.openHistoryField = isOpen ? null : item.name;
221
+ } }, h("svg", { class: "mrd-layout-section__history-icon", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true" }, h("path", { "fill-rule": "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zm.75-13a.75.75 0 00-1.5 0v5c0 .207.085.394.22.53l2.5 2.5a.75.75 0 101.06-1.06L10.75 9.69V5z", "clip-rule": "evenodd" }))), isOpen && (h("div", { class: "mrd-layout-section__history-popover", role: "listbox" }, sorted.map((entry, i) => (h("div", { key: String(i), class: "mrd-layout-section__history-entry" }, entry.value, " (", t('history_until', locale), " ", formatDate(entry.until, locale), ")")))))));
222
+ }
191
223
  renderField(item) {
224
+ var _a, _b;
192
225
  if (!item.name)
193
226
  return null;
194
- const rawValue = this.data[item.name];
227
+ const raw = this.data[item.name];
228
+ const hist = (_a = item.historyEnabled) !== null && _a !== void 0 ? _a : (_b = item.field) === null || _b === void 0 ? void 0 : _b.historyEnabled;
229
+ const rawValue = hist && raw !== null && typeof raw === 'object' && 'current' in raw
230
+ ? raw.current
231
+ : raw;
195
232
  const renderedValue = this.renderFieldValue(item, rawValue);
196
233
  if (item.header) {
197
234
  return (h("h1", { class: "mrd-layout-section__field-header", key: item.name }, typeof renderedValue === 'string' ? renderedValue : rawValue != null ? String(rawValue) : item.label));
@@ -201,7 +238,7 @@ export class MrdLayoutSection {
201
238
  const isBlock = item.dataType === ClientLayoutItemFieldDataType.TEXTBLOCK
202
239
  || item.dataType === ClientLayoutItemFieldDataType.LONGTEXT
203
240
  || item.dataType === ClientLayoutItemFieldDataType.JSON;
204
- return (h("div", { class: `mrd-layout-section__field${isBlock ? ' mrd-layout-section__field--block' : ''}`, key: item.name }, h("span", { class: "mrd-layout-section__field-label" }, item.label), h("span", { class: "mrd-layout-section__field-value" }, renderedValue)));
241
+ return (h("div", { class: `mrd-layout-section__field${isBlock ? ' mrd-layout-section__field--block' : ''}`, key: item.name }, h("span", { class: "mrd-layout-section__field-label" }, item.label), h("span", { class: "mrd-layout-section__field-value" }, renderedValue, this.renderHistoryBadge(item, raw))));
205
242
  }
206
243
  renderRelation(item) {
207
244
  var _a, _b, _c;
@@ -262,6 +299,7 @@ export class MrdLayoutSection {
262
299
  path: e.detail.path,
263
300
  qs: e.detail.qs,
264
301
  parentPath: e.detail.parentPath,
302
+ basicType: e.detail.basicType,
265
303
  });
266
304
  } })));
267
305
  }
@@ -296,7 +334,7 @@ export class MrdLayoutSection {
296
334
  return (h("div", { class: "mrd-layout-section__modal-backdrop", onClick: () => { this.imagePreviewUrl = null; } }, h("div", { class: "mrd-layout-section__modal", onClick: (e) => e.stopPropagation() }, h("button", { class: "mrd-layout-section__modal-close", onClick: () => { this.imagePreviewUrl = null; } }, "\u2715"), h("img", { class: "mrd-layout-section__modal-image", src: this.imagePreviewUrl, alt: "" }))));
297
335
  }
298
336
  render() {
299
- return (h(Host, { key: '0a3a58f5c80716bc0a7ba1b9468b721706d2ce4a' }, h("div", { key: '7cf63580c584811c1bb84b419e8d13026e432fba', class: "mrd-layout-section" }, this.items.map(item => this.renderItem(item))), this.renderImageModal()));
337
+ return (h(Host, { key: '8966198eebd98570d2db2f4d2fe9ef3f8b466ec6' }, h("div", { key: '645ddbfdd829a0f9c1a4eab18105662af6c078b2', class: "mrd-layout-section" }, this.items.map(item => this.renderItem(item))), this.renderImageModal()));
300
338
  }
301
339
  static get is() { return "mrd-layout-section"; }
302
340
  static get encapsulation() { return "scoped"; }
@@ -439,7 +477,8 @@ export class MrdLayoutSection {
439
477
  "searchQueryMap": {},
440
478
  "searchResultsMap": {},
441
479
  "imagePreviewUrl": {},
442
- "imagePreviews": {}
480
+ "imagePreviews": {},
481
+ "openHistoryField": {}
443
482
  };
444
483
  }
445
484
  static get events() {
@@ -536,8 +575,8 @@ export class MrdLayoutSection {
536
575
  "text": "Re-emitted from an embedded mrd-table's mrdAction; host builds the target URL from dataClass."
537
576
  },
538
577
  "complexType": {
539
- "original": "{ name: string; action: string; dataClass: string; path?: string; qs?: string; parentPath?: string | null }",
540
- "resolved": "{ name: string; action: string; dataClass: string; path?: string | undefined; qs?: string | undefined; parentPath?: string | null | undefined; }",
578
+ "original": "{ name: string; action: string; dataClass: string; path?: string; qs?: string; parentPath?: string | null; basicType?: string }",
579
+ "resolved": "{ name: string; action: string; dataClass: string; path?: string | undefined; qs?: string | undefined; parentPath?: string | null | undefined; basicType?: string | undefined; }",
541
580
  "references": {}
542
581
  }
543
582
  }, {
@@ -24,6 +24,73 @@
24
24
  font-weight: var(--mrd-font-weight-medium);
25
25
  color: var(--mrd-color-neutral-800);
26
26
  word-break: break-word;
27
+ display: inline-flex;
28
+ align-items: center;
29
+ gap: var(--mrd-space-1);
30
+ }
31
+
32
+ .mrd-layout-section__history-wrap {
33
+ position: relative;
34
+ display: inline-flex;
35
+ align-items: center;
36
+ }
37
+
38
+ .mrd-layout-section__history-btn {
39
+ display: inline-flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ width: 1.25rem;
43
+ height: 1.25rem;
44
+ padding: 0;
45
+ background: transparent;
46
+ border: none;
47
+ border-radius: var(--mrd-border-radius-sm);
48
+ color: var(--mrd-color-neutral-400);
49
+ cursor: pointer;
50
+ flex-shrink: 0;
51
+ transition: color var(--mrd-transition-fast), background-color var(--mrd-transition-fast);
52
+ }
53
+
54
+ .mrd-layout-section__history-btn:hover {
55
+ color: var(--mrd-color-neutral-700);
56
+ background-color: var(--mrd-color-neutral-100);
57
+ }
58
+
59
+ .mrd-layout-section__history-btn:focus {
60
+ outline: none;
61
+ box-shadow: var(--mrd-shadow-focus);
62
+ }
63
+
64
+ .mrd-layout-section__history-icon {
65
+ width: 0.875rem;
66
+ height: 0.875rem;
67
+ }
68
+
69
+ .mrd-layout-section__history-popover {
70
+ position: absolute;
71
+ top: calc(100% + 0.25rem);
72
+ left: 0;
73
+ min-width: 24rem;
74
+ max-width: 24rem;
75
+ background-color: var(--mrd-color-white);
76
+ border: var(--mrd-border-width) solid var(--mrd-border-color);
77
+ border-radius: var(--mrd-border-radius-md);
78
+ box-shadow: var(--mrd-shadow-md);
79
+ padding: var(--mrd-space-1) 0;
80
+ z-index: var(--mrd-z-dropdown);
81
+ }
82
+
83
+ .mrd-layout-section__history-entry {
84
+ font-family: var(--mrd-font-family);
85
+ font-size: var(--mrd-font-size-sm);
86
+ font-weight: var(--mrd-font-weight-normal);
87
+ color: var(--mrd-color-neutral-700);
88
+ padding: var(--mrd-space-2) var(--mrd-space-3);
89
+ line-height: var(--mrd-line-height-normal);
90
+ }
91
+
92
+ .mrd-layout-section__history-entry:not(:last-child) {
93
+ border-bottom: var(--mrd-border-width) solid var(--mrd-color-neutral-100);
27
94
  }
28
95
 
29
96
  .mrd-layout-section__field-header {
@@ -154,6 +221,15 @@
154
221
  flex-shrink: 0;
155
222
  }
156
223
 
224
+ .mrd-layout-section__secret-masked {
225
+ font-family: var(--mrd-font-family);
226
+ font-size: var(--mrd-font-size-base);
227
+ color: var(--mrd-label-color);
228
+ letter-spacing: 0.15em;
229
+ user-select: none;
230
+ pointer-events: none;
231
+ }
232
+
157
233
  .mrd-layout-section__pre {
158
234
  font-family: var(--mrd-font-family-mono);
159
235
  font-size: var(--mrd-font-size-xs);
@@ -28,7 +28,7 @@ export class MrdLongtextField {
28
28
  }
29
29
  render() {
30
30
  const hasError = !!this.error;
31
- return (h(Host, { key: '3142f97e26fdef5547c8dd9d236ed8bc40d5c65f' }, h("div", { key: 'b78567596d8c6459c8e9b28ea6b02d3fe65fd16c', class: "mrd-longtext-field" }, this.label && (h("label", { key: 'e85d8657fcc49fc7e15c06b8a98b34c03738ef5b', class: `mrd-longtext-field__label${this.required ? ' mrd-longtext-field__label--required' : ''}` }, this.label)), this.disabled ? (h("pre", { class: "mrd-longtext-field__content" }, this.value)) : (h("textarea", { class: `mrd-longtext-field__input${hasError ? ' mrd-longtext-field__input--error' : ''}`, name: this.name, placeholder: this.placeholder, required: this.required, rows: 10, onInput: this.handleInput, onBlur: this.handleBlur }, this.value)), hasError && h("span", { key: '63cdcaf136e345197c42516f150752ec1d8665fa', class: "mrd-longtext-field__error" }, this.error))));
31
+ return (h(Host, { key: '10d998b80f54cf7b10be26bf451d808c78579e69' }, h("div", { key: 'af45fe94a41f668bf6ddca670b42e065ee83ef23', class: "mrd-longtext-field" }, this.label && (h("label", { key: '31a08490d695ac9f4bbe5dff6a1ae3bb2a94337d', class: `mrd-longtext-field__label${this.required ? ' mrd-longtext-field__label--required' : ''}` }, this.label)), this.disabled ? (h("pre", { class: "mrd-longtext-field__content" }, this.value)) : (h("textarea", { class: `mrd-longtext-field__input${hasError ? ' mrd-longtext-field__input--error' : ''}`, name: this.name, placeholder: this.placeholder, required: this.required, rows: 10, onInput: this.handleInput, onBlur: this.handleBlur }, this.value)), hasError && h("span", { key: '7f133e72a882a8aaf33245445829754da1e6377b', class: "mrd-longtext-field__error" }, this.error))));
32
32
  }
33
33
  static get is() { return "mrd-longtext-field"; }
34
34
  static get encapsulation() { return "scoped"; }
@@ -69,7 +69,7 @@ export class MrdNumberField {
69
69
  const hasError = !!this.error;
70
70
  const suffix = this.dataType === ClientLayoutItemFieldDataType.PERCENTAGE ? '%' :
71
71
  this.dataType === ClientLayoutItemFieldDataType.DECIMAL ? '' : '';
72
- return (h(Host, { key: 'ba3488fb12f72bb04164e3e94c028fb8a085f1f2' }, h("div", { key: '582e30a2a256c16cc3b0cab6e64460a0a5ec1fa2', class: "mrd-number-field" }, this.label && (h("label", { key: '87fe77ce80e888406ecedaa450e8c3d2a61c790a', class: `mrd-number-field__label${this.required ? ' mrd-number-field__label--required' : ''}` }, this.label)), h("div", { key: 'e3d8cf06f585add372e385d6e6ef7d60ece8071b', class: "mrd-number-field__input-wrapper" }, h("input", { key: '04710b67ee0dcb9db327e25b2467b1b3499bc9a8', class: `mrd-number-field__input${hasError ? ' mrd-number-field__input--error' : ''}`, type: "text", inputMode: "decimal", name: this.name, value: this.displayValue, placeholder: this.placeholder || (suffix ? `0${suffix}` : '0'), required: this.required, disabled: this.disabled, onInput: this.handleInput, onBlur: this.handleBlur, onFocus: this.handleFocus })), hasError && h("span", { key: '9713244d784c82213ea835a5a6d47d468ccb0bb9', class: "mrd-number-field__error" }, this.error))));
72
+ return (h(Host, { key: '195beed4d6453597320b79654feaabe8f742eff2' }, h("div", { key: 'c641d7a4d27ba28dd34acda98d38f245945d20bb', class: "mrd-number-field" }, this.label && (h("label", { key: '2a5f6eb48889a3ab0aa76d6b2ca5d59b20625bb2', class: `mrd-number-field__label${this.required ? ' mrd-number-field__label--required' : ''}` }, this.label)), h("div", { key: 'a844b89e6a278629a8aefa4ac72e5e18e5904cab', class: "mrd-number-field__input-wrapper" }, h("input", { key: '1ce9c3d67b458601a0de95b3b8478ef05df73069', class: `mrd-number-field__input${hasError ? ' mrd-number-field__input--error' : ''}`, type: "text", inputMode: "decimal", name: this.name, value: this.displayValue, placeholder: this.placeholder || (suffix ? `0${suffix}` : '0'), required: this.required, disabled: this.disabled, onInput: this.handleInput, onBlur: this.handleBlur, onFocus: this.handleFocus })), hasError && h("span", { key: '4226614a65a8d27543d1287e2c1f61f67c427e63', class: "mrd-number-field__error" }, this.error))));
73
73
  }
74
74
  static get is() { return "mrd-number-field"; }
75
75
  static get encapsulation() { return "scoped"; }
@@ -230,7 +230,7 @@ export class MrdNumberField {
230
230
  "mutable": false,
231
231
  "complexType": {
232
232
  "original": "ClientLayoutItemFieldDataType",
233
- "resolved": "ClientLayoutItemFieldDataType.BOOLEAN | ClientLayoutItemFieldDataType.CURRENCY | ClientLayoutItemFieldDataType.DATE | ClientLayoutItemFieldDataType.DATETIME | ClientLayoutItemFieldDataType.DECIMAL | ClientLayoutItemFieldDataType.EMAIL | ClientLayoutItemFieldDataType.FILE | ClientLayoutItemFieldDataType.HYPERLINK | ClientLayoutItemFieldDataType.IMAGE | ClientLayoutItemFieldDataType.INTEGER | ClientLayoutItemFieldDataType.JSON | ClientLayoutItemFieldDataType.LIST | ClientLayoutItemFieldDataType.LONGTEXT | ClientLayoutItemFieldDataType.PERCENTAGE | ClientLayoutItemFieldDataType.TEXT | ClientLayoutItemFieldDataType.TEXTBLOCK | ClientLayoutItemFieldDataType.TIME",
233
+ "resolved": "ClientLayoutItemFieldDataType.BOOLEAN | ClientLayoutItemFieldDataType.CURRENCY | ClientLayoutItemFieldDataType.DATE | ClientLayoutItemFieldDataType.DATETIME | ClientLayoutItemFieldDataType.DECIMAL | ClientLayoutItemFieldDataType.EMAIL | ClientLayoutItemFieldDataType.FILE | ClientLayoutItemFieldDataType.HYPERLINK | ClientLayoutItemFieldDataType.IMAGE | ClientLayoutItemFieldDataType.INTEGER | ClientLayoutItemFieldDataType.JSON | ClientLayoutItemFieldDataType.LIST | ClientLayoutItemFieldDataType.LONGTEXT | ClientLayoutItemFieldDataType.PERCENTAGE | ClientLayoutItemFieldDataType.SECRET | ClientLayoutItemFieldDataType.TEXT | ClientLayoutItemFieldDataType.TEXTBLOCK | ClientLayoutItemFieldDataType.TIME",
234
234
  "references": {
235
235
  "ClientLayoutItemFieldDataType": {
236
236
  "location": "import",
@@ -0,0 +1,229 @@
1
+ import { Host, h } from "@stencil/core";
2
+ import { t } from "../../utils/i18n";
3
+ import { validateRequired } from "../../utils/validation";
4
+ export class MrdSecretField {
5
+ constructor() {
6
+ this.name = '';
7
+ this.label = '';
8
+ this.value = '';
9
+ this.placeholder = '';
10
+ this.required = false;
11
+ this.disabled = false;
12
+ this.locale = navigator.language;
13
+ this.error = '';
14
+ this.handleInput = (e) => {
15
+ const val = e.target.value;
16
+ this.mrdChange.emit({ name: this.name, value: val });
17
+ };
18
+ this.handleBlur = (e) => {
19
+ const val = e.target.value;
20
+ if (this.required && !validateRequired(val)) {
21
+ this.error = t('required', this.locale);
22
+ }
23
+ else {
24
+ this.error = '';
25
+ }
26
+ this.mrdBlur.emit({ name: this.name, value: val });
27
+ };
28
+ }
29
+ render() {
30
+ const hasError = !!this.error;
31
+ return (h(Host, { key: '08f1aa9d8ab9f4e41abb6d3286e5e383427a5409' }, h("div", { key: 'fabe38aa130e211cea81f2c2f227bc15ad3ebf7d', class: "mrd-secret-field" }, this.label && (h("label", { key: '69af8844eff8ce84daa622635c79130fb491eb0b', class: `mrd-secret-field__label${this.required ? ' mrd-secret-field__label--required' : ''}` }, this.label)), this.disabled
32
+ ? (h("span", { class: "mrd-secret-field__masked", "aria-label": this.label }, this.value ? '••••••••' : ''))
33
+ : (h("input", { class: `mrd-secret-field__input${hasError ? ' mrd-secret-field__input--error' : ''}`, type: "password", name: this.name, value: this.value, placeholder: this.placeholder, required: this.required, autocomplete: "new-password", onInput: this.handleInput, onBlur: this.handleBlur })), hasError && h("span", { key: 'e602004f0bb10916d1015e3c2b003523a292997c', class: "mrd-secret-field__error" }, this.error))));
34
+ }
35
+ static get is() { return "mrd-secret-field"; }
36
+ static get encapsulation() { return "scoped"; }
37
+ static get originalStyleUrls() {
38
+ return {
39
+ "$": ["mrd-secret-field.scss"]
40
+ };
41
+ }
42
+ static get styleUrls() {
43
+ return {
44
+ "$": ["mrd-secret-field.css"]
45
+ };
46
+ }
47
+ static get properties() {
48
+ return {
49
+ "name": {
50
+ "type": "string",
51
+ "mutable": false,
52
+ "complexType": {
53
+ "original": "string",
54
+ "resolved": "string",
55
+ "references": {}
56
+ },
57
+ "required": false,
58
+ "optional": false,
59
+ "docs": {
60
+ "tags": [],
61
+ "text": ""
62
+ },
63
+ "getter": false,
64
+ "setter": false,
65
+ "reflect": false,
66
+ "attribute": "name",
67
+ "defaultValue": "''"
68
+ },
69
+ "label": {
70
+ "type": "string",
71
+ "mutable": false,
72
+ "complexType": {
73
+ "original": "string",
74
+ "resolved": "string",
75
+ "references": {}
76
+ },
77
+ "required": false,
78
+ "optional": false,
79
+ "docs": {
80
+ "tags": [],
81
+ "text": ""
82
+ },
83
+ "getter": false,
84
+ "setter": false,
85
+ "reflect": false,
86
+ "attribute": "label",
87
+ "defaultValue": "''"
88
+ },
89
+ "value": {
90
+ "type": "string",
91
+ "mutable": false,
92
+ "complexType": {
93
+ "original": "string",
94
+ "resolved": "string",
95
+ "references": {}
96
+ },
97
+ "required": false,
98
+ "optional": false,
99
+ "docs": {
100
+ "tags": [],
101
+ "text": ""
102
+ },
103
+ "getter": false,
104
+ "setter": false,
105
+ "reflect": false,
106
+ "attribute": "value",
107
+ "defaultValue": "''"
108
+ },
109
+ "placeholder": {
110
+ "type": "string",
111
+ "mutable": false,
112
+ "complexType": {
113
+ "original": "string",
114
+ "resolved": "string",
115
+ "references": {}
116
+ },
117
+ "required": false,
118
+ "optional": false,
119
+ "docs": {
120
+ "tags": [],
121
+ "text": ""
122
+ },
123
+ "getter": false,
124
+ "setter": false,
125
+ "reflect": false,
126
+ "attribute": "placeholder",
127
+ "defaultValue": "''"
128
+ },
129
+ "required": {
130
+ "type": "boolean",
131
+ "mutable": false,
132
+ "complexType": {
133
+ "original": "boolean",
134
+ "resolved": "boolean",
135
+ "references": {}
136
+ },
137
+ "required": false,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": ""
142
+ },
143
+ "getter": false,
144
+ "setter": false,
145
+ "reflect": false,
146
+ "attribute": "required",
147
+ "defaultValue": "false"
148
+ },
149
+ "disabled": {
150
+ "type": "boolean",
151
+ "mutable": false,
152
+ "complexType": {
153
+ "original": "boolean",
154
+ "resolved": "boolean",
155
+ "references": {}
156
+ },
157
+ "required": false,
158
+ "optional": false,
159
+ "docs": {
160
+ "tags": [],
161
+ "text": ""
162
+ },
163
+ "getter": false,
164
+ "setter": false,
165
+ "reflect": false,
166
+ "attribute": "disabled",
167
+ "defaultValue": "false"
168
+ },
169
+ "locale": {
170
+ "type": "string",
171
+ "mutable": false,
172
+ "complexType": {
173
+ "original": "string",
174
+ "resolved": "string",
175
+ "references": {}
176
+ },
177
+ "required": false,
178
+ "optional": false,
179
+ "docs": {
180
+ "tags": [],
181
+ "text": ""
182
+ },
183
+ "getter": false,
184
+ "setter": false,
185
+ "reflect": false,
186
+ "attribute": "locale",
187
+ "defaultValue": "navigator.language"
188
+ }
189
+ };
190
+ }
191
+ static get states() {
192
+ return {
193
+ "error": {}
194
+ };
195
+ }
196
+ static get events() {
197
+ return [{
198
+ "method": "mrdChange",
199
+ "name": "mrdChange",
200
+ "bubbles": true,
201
+ "cancelable": true,
202
+ "composed": true,
203
+ "docs": {
204
+ "tags": [],
205
+ "text": ""
206
+ },
207
+ "complexType": {
208
+ "original": "{ name: string; value: string }",
209
+ "resolved": "{ name: string; value: string; }",
210
+ "references": {}
211
+ }
212
+ }, {
213
+ "method": "mrdBlur",
214
+ "name": "mrdBlur",
215
+ "bubbles": true,
216
+ "cancelable": true,
217
+ "composed": true,
218
+ "docs": {
219
+ "tags": [],
220
+ "text": ""
221
+ },
222
+ "complexType": {
223
+ "original": "{ name: string; value: string }",
224
+ "resolved": "{ name: string; value: string; }",
225
+ "references": {}
226
+ }
227
+ }];
228
+ }
229
+ }
@@ -0,0 +1,73 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ .mrd-secret-field {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: var(--mrd-space-1);
9
+ width: 100%;
10
+ }
11
+
12
+ .mrd-secret-field__label {
13
+ display: block;
14
+ font-family: var(--mrd-font-family);
15
+ font-size: var(--mrd-label-font-size);
16
+ font-weight: var(--mrd-label-font-weight);
17
+ color: var(--mrd-label-color);
18
+ }
19
+
20
+ .mrd-secret-field__label--required::after {
21
+ content: ' *';
22
+ color: var(--mrd-color-danger);
23
+ }
24
+
25
+ .mrd-secret-field__input {
26
+ display: block;
27
+ width: 100%;
28
+ height: var(--mrd-input-height);
29
+ padding: var(--mrd-input-padding-y) var(--mrd-input-padding-x);
30
+ font-family: var(--mrd-font-family);
31
+ font-size: var(--mrd-font-size-base);
32
+ color: var(--mrd-input-color);
33
+ background-color: var(--mrd-input-bg);
34
+ border: var(--mrd-border-width) solid var(--mrd-border-color);
35
+ border-radius: var(--mrd-border-radius);
36
+ transition: border-color var(--mrd-transition), box-shadow var(--mrd-transition);
37
+ outline: none;
38
+ appearance: none;
39
+ box-sizing: border-box;
40
+ }
41
+
42
+ .mrd-secret-field__input::placeholder {
43
+ color: var(--mrd-input-placeholder-color);
44
+ }
45
+
46
+ .mrd-secret-field__input:focus {
47
+ border-color: var(--mrd-border-color-focus);
48
+ box-shadow: var(--mrd-shadow-focus);
49
+ }
50
+
51
+ .mrd-secret-field__input--error {
52
+ border-color: var(--mrd-border-color-error);
53
+ }
54
+
55
+ .mrd-secret-field__input--error:focus {
56
+ box-shadow: var(--mrd-shadow-focus-error);
57
+ }
58
+
59
+ .mrd-secret-field__error {
60
+ font-family: var(--mrd-font-family);
61
+ font-size: var(--mrd-error-font-size);
62
+ color: var(--mrd-error-color);
63
+ }
64
+
65
+ .mrd-secret-field__masked {
66
+ display: block;
67
+ font-family: var(--mrd-font-family);
68
+ font-size: var(--mrd-font-size-base);
69
+ color: var(--mrd-label-color);
70
+ letter-spacing: 0.15em;
71
+ user-select: none;
72
+ pointer-events: none;
73
+ }