@mmlogic/components 0.1.10 → 0.1.11
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.
- package/README.md +196 -61
- package/dist/cjs/format-DBr-GTvS.js +308 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mosterdcomponents.cjs.js +1 -1
- package/dist/cjs/mrd-boolean-field_16.cjs.entry.js +29 -110
- package/dist/cjs/mrd-table.cjs.entry.js +318 -62
- package/dist/collection/components/mrd-table/mrd-table.js +386 -62
- package/dist/collection/components/mrd-table/mrd-table.scss +388 -0
- package/dist/collection/dev/app.js +48 -4
- package/dist/collection/dev/sprites.svg +55 -0
- package/dist/collection/utils/i18n.js +144 -0
- package/dist/components/i18n.js +1 -1
- package/dist/components/mrd-table.js +1 -1
- package/dist/esm/format-EzhfM0uw.js +299 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mosterdcomponents.js +1 -1
- package/dist/esm/mrd-boolean-field_16.entry.js +1 -82
- package/dist/esm/mrd-table.entry.js +318 -62
- package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
- package/dist/mosterdcomponents/p-27f6947a.entry.js +1 -0
- package/dist/mosterdcomponents/p-EzhfM0uw.js +1 -0
- package/dist/mosterdcomponents/p-ca5f9919.entry.js +1 -0
- package/dist/types/components/mrd-table/mrd-table.d.ts +52 -18
- package/dist/types/components.d.ts +23 -3
- package/dist/types/utils/cell-renderer.d.ts +27 -0
- package/package.json +1 -1
- package/dist/cjs/format-CDw-zie_.js +0 -82
- package/dist/esm/format-Dt-aHxkM.js +0 -74
- package/dist/mosterdcomponents/p-Dt-aHxkM.js +0 -1
- package/dist/mosterdcomponents/p-baf08615.entry.js +0 -1
- package/dist/mosterdcomponents/p-bb567c32.entry.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-BPj2cBXs.js');
|
|
4
|
+
var format = require('./format-DBr-GTvS.js');
|
|
4
5
|
var index$1 = require('./index.cjs.js');
|
|
5
|
-
var format = require('./format-CDw-zie_.js');
|
|
6
6
|
|
|
7
7
|
const mrdBooleanFieldScss = () => `.sc-mrd-boolean-field-h{display:block}.mrd-boolean-field.sc-mrd-boolean-field{display:flex;align-items:center;width:100%}.mrd-boolean-field__toggle-label.sc-mrd-boolean-field{display:flex;align-items:center;gap:var(--mrd-space-3);cursor:pointer;user-select:none}.mrd-boolean-field__checkbox.sc-mrd-boolean-field{position:absolute;opacity:0;width:0;height:0;pointer-events:none}.mrd-boolean-field__checkbox.sc-mrd-boolean-field:checked+.mrd-boolean-field__toggle.sc-mrd-boolean-field{background-color:var(--mrd-color-primary)}.mrd-boolean-field__checkbox.sc-mrd-boolean-field:checked+.mrd-boolean-field__toggle.sc-mrd-boolean-field::after{transform:translateX(20px)}.mrd-boolean-field__checkbox.sc-mrd-boolean-field:focus+.mrd-boolean-field__toggle.sc-mrd-boolean-field{box-shadow:var(--mrd-shadow-focus)}.mrd-boolean-field__checkbox.sc-mrd-boolean-field:disabled+.mrd-boolean-field__toggle.sc-mrd-boolean-field{opacity:0.5;cursor:not-allowed}.mrd-boolean-field__toggle.sc-mrd-boolean-field{position:relative;display:inline-block;width:44px;height:24px;background-color:var(--mrd-color-neutral-300);border-radius:var(--mrd-border-radius-full);transition:background-color var(--mrd-transition);flex-shrink:0}.mrd-boolean-field__toggle.sc-mrd-boolean-field::after{content:'';position:absolute;top:2px;left:2px;width:20px;height:20px;background-color:var(--mrd-color-white);border-radius:50%;transition:transform var(--mrd-transition);box-shadow:var(--mrd-shadow-sm)}.mrd-boolean-field__text.sc-mrd-boolean-field{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-base);color:var(--mrd-color-neutral-800)}.mrd-boolean-field__text--required.sc-mrd-boolean-field::after{content:' *';color:var(--mrd-color-danger)}`;
|
|
8
8
|
|
|
@@ -35,87 +35,6 @@ const MrdBooleanField = class {
|
|
|
35
35
|
};
|
|
36
36
|
MrdBooleanField.style = mrdBooleanFieldScss();
|
|
37
37
|
|
|
38
|
-
const translations = {
|
|
39
|
-
nl: {
|
|
40
|
-
required: 'Dit veld is verplicht',
|
|
41
|
-
select_placeholder: 'Selecteer een optie',
|
|
42
|
-
search_placeholder: 'Zoeken...',
|
|
43
|
-
upload_file: 'Bestand uploaden',
|
|
44
|
-
choose_file: 'Bestand kiezen',
|
|
45
|
-
clear: 'Wissen',
|
|
46
|
-
today: 'Vandaag',
|
|
47
|
-
invalid_email: 'Voer een geldig e-mailadres in',
|
|
48
|
-
invalid_url: 'Voer een geldige URL in',
|
|
49
|
-
invalid_number: 'Voer een geldig getal in',
|
|
50
|
-
drop_file_here: 'Sleep bestand hierheen of',
|
|
51
|
-
browse: 'bladeren',
|
|
52
|
-
file_too_large: 'Bestand is te groot',
|
|
53
|
-
search_results: 'Zoekresultaten',
|
|
54
|
-
no_results: 'Geen resultaten gevonden',
|
|
55
|
-
loading: 'Laden...',
|
|
56
|
-
submit: 'Opslaan',
|
|
57
|
-
cancel: 'Annuleren',
|
|
58
|
-
remove: 'Verwijderen',
|
|
59
|
-
add: 'Toevoegen',
|
|
60
|
-
yes: 'Ja',
|
|
61
|
-
no: 'Nee',
|
|
62
|
-
},
|
|
63
|
-
en: {
|
|
64
|
-
required: 'This field is required',
|
|
65
|
-
select_placeholder: 'Select an option',
|
|
66
|
-
search_placeholder: 'Search...',
|
|
67
|
-
upload_file: 'Upload file',
|
|
68
|
-
choose_file: 'Choose file',
|
|
69
|
-
clear: 'Clear',
|
|
70
|
-
today: 'Today',
|
|
71
|
-
invalid_email: 'Please enter a valid email address',
|
|
72
|
-
invalid_url: 'Please enter a valid URL',
|
|
73
|
-
invalid_number: 'Please enter a valid number',
|
|
74
|
-
drop_file_here: 'Drop file here or',
|
|
75
|
-
browse: 'browse',
|
|
76
|
-
file_too_large: 'File is too large',
|
|
77
|
-
search_results: 'Search results',
|
|
78
|
-
no_results: 'No results found',
|
|
79
|
-
loading: 'Loading...',
|
|
80
|
-
submit: 'Save',
|
|
81
|
-
cancel: 'Cancel',
|
|
82
|
-
remove: 'Remove',
|
|
83
|
-
add: 'Add',
|
|
84
|
-
yes: 'Yes',
|
|
85
|
-
no: 'No',
|
|
86
|
-
},
|
|
87
|
-
ar: {
|
|
88
|
-
required: 'هذا الحقل مطلوب',
|
|
89
|
-
select_placeholder: 'اختر خياراً',
|
|
90
|
-
search_placeholder: 'بحث...',
|
|
91
|
-
upload_file: 'رفع ملف',
|
|
92
|
-
choose_file: 'اختر ملفاً',
|
|
93
|
-
clear: 'مسح',
|
|
94
|
-
today: 'اليوم',
|
|
95
|
-
invalid_email: 'يرجى إدخال عنوان بريد إلكتروني صحيح',
|
|
96
|
-
invalid_url: 'يرجى إدخال رابط صحيح',
|
|
97
|
-
invalid_number: 'يرجى إدخال رقم صحيح',
|
|
98
|
-
drop_file_here: 'اسحب الملف هنا أو',
|
|
99
|
-
browse: 'تصفح',
|
|
100
|
-
file_too_large: 'الملف كبير جداً',
|
|
101
|
-
search_results: 'نتائج البحث',
|
|
102
|
-
no_results: 'لم يتم العثور على نتائج',
|
|
103
|
-
loading: 'جار التحميل...',
|
|
104
|
-
submit: 'حفظ',
|
|
105
|
-
cancel: 'إلغاء',
|
|
106
|
-
remove: 'إزالة',
|
|
107
|
-
add: 'إضافة',
|
|
108
|
-
yes: 'نعم',
|
|
109
|
-
no: 'لا',
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
function t(key, locale) {
|
|
113
|
-
var _a, _b, _c;
|
|
114
|
-
const lang = locale.split('-')[0].toLowerCase();
|
|
115
|
-
const dict = (_a = translations[lang]) !== null && _a !== void 0 ? _a : translations['en'];
|
|
116
|
-
return (_c = (_b = dict[key]) !== null && _b !== void 0 ? _b : translations['en'][key]) !== null && _c !== void 0 ? _c : key;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
38
|
function validateRequired(value) {
|
|
120
39
|
if (value === null || value === undefined)
|
|
121
40
|
return false;
|
|
@@ -190,7 +109,7 @@ const MrdCurrencyField = class {
|
|
|
190
109
|
const raw = e.target.value;
|
|
191
110
|
const parsed = format.parseLocalizedNumber(raw, this.locale);
|
|
192
111
|
if (this.required && !validateRequired(raw)) {
|
|
193
|
-
this.error = t('required', this.locale);
|
|
112
|
+
this.error = format.t('required', this.locale);
|
|
194
113
|
}
|
|
195
114
|
else {
|
|
196
115
|
this.error = '';
|
|
@@ -235,7 +154,7 @@ const MrdDateField = class {
|
|
|
235
154
|
this.handleChange = (e) => {
|
|
236
155
|
const val = e.target.value;
|
|
237
156
|
if (this.required && !validateRequired(val)) {
|
|
238
|
-
this.error = t('required', this.locale);
|
|
157
|
+
this.error = format.t('required', this.locale);
|
|
239
158
|
}
|
|
240
159
|
else {
|
|
241
160
|
this.error = '';
|
|
@@ -271,7 +190,7 @@ const MrdDatetimeField = class {
|
|
|
271
190
|
this.handleChange = (e) => {
|
|
272
191
|
const val = e.target.value;
|
|
273
192
|
if (this.required && !validateRequired(val)) {
|
|
274
|
-
this.error = t('required', this.locale);
|
|
193
|
+
this.error = format.t('required', this.locale);
|
|
275
194
|
}
|
|
276
195
|
else {
|
|
277
196
|
this.error = '';
|
|
@@ -312,10 +231,10 @@ const MrdEmailField = class {
|
|
|
312
231
|
this.handleBlur = (e) => {
|
|
313
232
|
const val = e.target.value;
|
|
314
233
|
if (this.required && !validateRequired(val)) {
|
|
315
|
-
this.error = t('required', this.locale);
|
|
234
|
+
this.error = format.t('required', this.locale);
|
|
316
235
|
}
|
|
317
236
|
else if (val && !validateEmail(val)) {
|
|
318
|
-
this.error = t('invalid_email', this.locale);
|
|
237
|
+
this.error = format.t('invalid_email', this.locale);
|
|
319
238
|
}
|
|
320
239
|
else {
|
|
321
240
|
this.error = '';
|
|
@@ -488,7 +407,7 @@ const MrdFileField = class {
|
|
|
488
407
|
return;
|
|
489
408
|
}
|
|
490
409
|
if (this.maxSize > 0 && file.size > this.maxSize) {
|
|
491
|
-
this.error = t('file_too_large', this.locale);
|
|
410
|
+
this.error = format.t('file_too_large', this.locale);
|
|
492
411
|
return;
|
|
493
412
|
}
|
|
494
413
|
this.error = '';
|
|
@@ -506,7 +425,7 @@ const MrdFileField = class {
|
|
|
506
425
|
hasError ? 'mrd-file-field__zone--error' : '',
|
|
507
426
|
this.disabled || this.uploading ? 'mrd-file-field__zone--disabled' : '',
|
|
508
427
|
].filter(Boolean).join(' ');
|
|
509
|
-
return (index.h(index.Host, { key: '2090102df8169226c1e66f87cbc837296e4b55d4' }, index.h("div", { key: '7a37a09df1bfa2eaf28ed04c806ad5f7c0337bb0', class: "mrd-file-field" }, this.label && (index.h("label", { key: '8f1fcb8adbb66b792be902c7c548e50db99b6a53', class: `mrd-file-field__label${this.required ? ' mrd-file-field__label--required' : ''}` }, this.label)), index.h("div", { key: '66d992298f537b24d69ce3ead3dd229f6d124f3d', class: zoneClass, onClick: this.handleZoneClick, onDragOver: this.handleDragOver, onDragLeave: this.handleDragLeave, onDrop: this.handleDrop }, index.h("input", { key: '95ba6560e71ee08c6b2526802727b29a18cdc454', ref: el => (this.fileInputRef = el), class: "mrd-file-field__input", type: "file", name: this.name, accept: this.accept, disabled: this.disabled || this.uploading, required: this.required && !hasFile, onChange: this.handleInputChange }), hasFile ? (index.h("div", { class: "mrd-file-field__selected" }, this.uploading ? (index.h("span", { class: "mrd-file-field__spinner", "aria-label": t('loading', this.locale) })) : (index.h("svg", { class: "mrd-file-field__icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, index.h("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }), index.h("polyline", { points: "14 2 14 8 20 8" }))), index.h("span", { class: "mrd-file-field__filename" }, this.fileName), !this.uploading && (index.h("button", { class: "mrd-file-field__clear", type: "button", onClick: this.handleClear, "aria-label": t('clear', this.locale) }, "\u2715")))) : (index.h("div", { class: "mrd-file-field__prompt" }, index.h("svg", { class: "mrd-file-field__upload-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, index.h("polyline", { points: "16 16 12 12 8 16" }), index.h("line", { x1: "12", y1: "12", x2: "12", y2: "21" }), index.h("path", { d: "M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3" })), index.h("span", null, t('drop_file_here', this.locale), ' ', index.h("span", { class: "mrd-file-field__browse" }, t('browse', this.locale)))))), hasError && index.h("span", { key: 'a6020e63bebb01e31a980a903f81badd486585aa', class: "mrd-file-field__error" }, this.error))));
|
|
428
|
+
return (index.h(index.Host, { key: '2090102df8169226c1e66f87cbc837296e4b55d4' }, index.h("div", { key: '7a37a09df1bfa2eaf28ed04c806ad5f7c0337bb0', class: "mrd-file-field" }, this.label && (index.h("label", { key: '8f1fcb8adbb66b792be902c7c548e50db99b6a53', class: `mrd-file-field__label${this.required ? ' mrd-file-field__label--required' : ''}` }, this.label)), index.h("div", { key: '66d992298f537b24d69ce3ead3dd229f6d124f3d', class: zoneClass, onClick: this.handleZoneClick, onDragOver: this.handleDragOver, onDragLeave: this.handleDragLeave, onDrop: this.handleDrop }, index.h("input", { key: '95ba6560e71ee08c6b2526802727b29a18cdc454', ref: el => (this.fileInputRef = el), class: "mrd-file-field__input", type: "file", name: this.name, accept: this.accept, disabled: this.disabled || this.uploading, required: this.required && !hasFile, onChange: this.handleInputChange }), hasFile ? (index.h("div", { class: "mrd-file-field__selected" }, this.uploading ? (index.h("span", { class: "mrd-file-field__spinner", "aria-label": format.t('loading', this.locale) })) : (index.h("svg", { class: "mrd-file-field__icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, index.h("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }), index.h("polyline", { points: "14 2 14 8 20 8" }))), index.h("span", { class: "mrd-file-field__filename" }, this.fileName), !this.uploading && (index.h("button", { class: "mrd-file-field__clear", type: "button", onClick: this.handleClear, "aria-label": format.t('clear', this.locale) }, "\u2715")))) : (index.h("div", { class: "mrd-file-field__prompt" }, index.h("svg", { class: "mrd-file-field__upload-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, index.h("polyline", { points: "16 16 12 12 8 16" }), index.h("line", { x1: "12", y1: "12", x2: "12", y2: "21" }), index.h("path", { d: "M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3" })), index.h("span", null, format.t('drop_file_here', this.locale), ' ', index.h("span", { class: "mrd-file-field__browse" }, format.t('browse', this.locale)))))), hasError && index.h("span", { key: 'a6020e63bebb01e31a980a903f81badd486585aa', class: "mrd-file-field__error" }, this.error))));
|
|
510
429
|
}
|
|
511
430
|
static get watchers() { return {
|
|
512
431
|
"value": [{
|
|
@@ -737,7 +656,7 @@ const MrdForm = class {
|
|
|
737
656
|
if (!def)
|
|
738
657
|
continue;
|
|
739
658
|
if (def.required && !validateRequired(this.formValues[def.name])) {
|
|
740
|
-
newErrors[def.name] = t('required', this.locale);
|
|
659
|
+
newErrors[def.name] = format.t('required', this.locale);
|
|
741
660
|
}
|
|
742
661
|
}
|
|
743
662
|
this.errors = newErrors;
|
|
@@ -796,7 +715,7 @@ const MrdForm = class {
|
|
|
796
715
|
return index.h(index.Host, null);
|
|
797
716
|
}
|
|
798
717
|
const dir = this.locale.startsWith('ar') ? 'rtl' : 'ltr';
|
|
799
|
-
return (index.h(index.Host, null, index.h("form", { class: "mrd-form", dir: dir, onSubmit: this.handleSubmit, noValidate: true }, this.layout.title && index.h("h2", { class: "mrd-form__title" }, this.layout.title), index.h("div", { class: "mrd-form__body" }, this.renderItems(this.layout.items)), index.h("div", { class: "mrd-form__footer" }, index.h("button", { type: "submit", class: "mrd-form__submit" }, t('submit', this.locale)), this.showCancel && (index.h("button", { type: "button", class: "mrd-form__cancel", onClick: () => this.mrdCancel.emit() }, t('cancel', this.locale)))))));
|
|
718
|
+
return (index.h(index.Host, null, index.h("form", { class: "mrd-form", dir: dir, onSubmit: this.handleSubmit, noValidate: true }, this.layout.title && index.h("h2", { class: "mrd-form__title" }, this.layout.title), index.h("div", { class: "mrd-form__body" }, this.renderItems(this.layout.items)), index.h("div", { class: "mrd-form__footer" }, index.h("button", { type: "submit", class: "mrd-form__submit" }, format.t('submit', this.locale)), this.showCancel && (index.h("button", { type: "button", class: "mrd-form__cancel", onClick: () => this.mrdCancel.emit() }, format.t('cancel', this.locale)))))));
|
|
800
719
|
}
|
|
801
720
|
static get watchers() { return {
|
|
802
721
|
"values": [{
|
|
@@ -828,10 +747,10 @@ const MrdHyperlinkField = class {
|
|
|
828
747
|
this.handleBlur = (e) => {
|
|
829
748
|
const val = e.target.value;
|
|
830
749
|
if (this.required && !validateRequired(val)) {
|
|
831
|
-
this.error = t('required', this.locale);
|
|
750
|
+
this.error = format.t('required', this.locale);
|
|
832
751
|
}
|
|
833
752
|
else if (val && !validateUrl(val)) {
|
|
834
|
-
this.error = t('invalid_url', this.locale);
|
|
753
|
+
this.error = format.t('invalid_url', this.locale);
|
|
835
754
|
}
|
|
836
755
|
else {
|
|
837
756
|
this.error = '';
|
|
@@ -923,7 +842,7 @@ const MrdImageField = class {
|
|
|
923
842
|
return;
|
|
924
843
|
}
|
|
925
844
|
if (this.maxSize > 0 && file.size > this.maxSize) {
|
|
926
|
-
this.error = t('file_too_large', this.locale);
|
|
845
|
+
this.error = format.t('file_too_large', this.locale);
|
|
927
846
|
return;
|
|
928
847
|
}
|
|
929
848
|
if (!file.type.startsWith('image/')) {
|
|
@@ -951,7 +870,7 @@ const MrdImageField = class {
|
|
|
951
870
|
hasError ? 'mrd-image-field__zone--error' : '',
|
|
952
871
|
this.disabled || this.uploading ? 'mrd-image-field__zone--disabled' : '',
|
|
953
872
|
].filter(Boolean).join(' ');
|
|
954
|
-
return (index.h(index.Host, { key: '76b5a36a7f5a420ded3400c8a1481843363d1cbe' }, index.h("div", { key: '3544df84aaf427a25518bafe13d60cf89ed28537', class: "mrd-image-field" }, this.label && (index.h("label", { key: 'dca64c1600cb98526eb4b91a908106087f099ad1', class: `mrd-image-field__label${this.required ? ' mrd-image-field__label--required' : ''}` }, this.label)), index.h("div", { key: 'ce07f32126f0956e47ff6fc41ff231590e0503d3', class: zoneClass, onClick: this.handleZoneClick, onDragOver: this.handleDragOver, onDragLeave: this.handleDragLeave, onDrop: this.handleDrop }, index.h("input", { key: '660fbae5f730834c465522a11dd674fc8e50a54e', ref: el => (this.fileInputRef = el), class: "mrd-image-field__input", type: "file", name: this.name, accept: this.accept, disabled: this.disabled || this.uploading, required: this.required && !this.previewUrl, onChange: this.handleInputChange }), this.previewUrl ? (index.h("div", { class: "mrd-image-field__preview-container" }, index.h("div", { class: "mrd-image-field__preview-thumb" }, index.h("img", { class: "mrd-image-field__preview", src: this.previewUrl, alt: this.fileName }), this.uploading && index.h("div", { class: "mrd-image-field__preview-overlay" }, index.h("span", { class: "mrd-image-field__spinner" }))), index.h("div", { class: "mrd-image-field__preview-info" }, index.h("span", { class: "mrd-image-field__preview-name" }, this.fileName), this.uploading && (index.h("span", { class: "mrd-image-field__upload-status" }, t('loading', this.locale)))), !this.uploading && (index.h("button", { class: "mrd-image-field__clear", type: "button", onClick: this.handleClear, "aria-label": t('clear', this.locale) }, t('remove', this.locale))))) : (index.h("div", { class: "mrd-image-field__prompt" }, index.h("svg", { class: "mrd-image-field__upload-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, index.h("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), index.h("circle", { cx: "8.5", cy: "8.5", r: "1.5" }), index.h("polyline", { points: "21 15 16 10 5 21" })), index.h("span", null, t('drop_file_here', this.locale), ' ', index.h("span", { class: "mrd-image-field__browse" }, t('browse', this.locale)))))), hasError && index.h("span", { key: '9b8f9563fea63bd12c38f5c480e9cbd24106c3af', class: "mrd-image-field__error" }, this.error))));
|
|
873
|
+
return (index.h(index.Host, { key: '76b5a36a7f5a420ded3400c8a1481843363d1cbe' }, index.h("div", { key: '3544df84aaf427a25518bafe13d60cf89ed28537', class: "mrd-image-field" }, this.label && (index.h("label", { key: 'dca64c1600cb98526eb4b91a908106087f099ad1', class: `mrd-image-field__label${this.required ? ' mrd-image-field__label--required' : ''}` }, this.label)), index.h("div", { key: 'ce07f32126f0956e47ff6fc41ff231590e0503d3', class: zoneClass, onClick: this.handleZoneClick, onDragOver: this.handleDragOver, onDragLeave: this.handleDragLeave, onDrop: this.handleDrop }, index.h("input", { key: '660fbae5f730834c465522a11dd674fc8e50a54e', ref: el => (this.fileInputRef = el), class: "mrd-image-field__input", type: "file", name: this.name, accept: this.accept, disabled: this.disabled || this.uploading, required: this.required && !this.previewUrl, onChange: this.handleInputChange }), this.previewUrl ? (index.h("div", { class: "mrd-image-field__preview-container" }, index.h("div", { class: "mrd-image-field__preview-thumb" }, index.h("img", { class: "mrd-image-field__preview", src: this.previewUrl, alt: this.fileName }), this.uploading && index.h("div", { class: "mrd-image-field__preview-overlay" }, index.h("span", { class: "mrd-image-field__spinner" }))), index.h("div", { class: "mrd-image-field__preview-info" }, index.h("span", { class: "mrd-image-field__preview-name" }, this.fileName), this.uploading && (index.h("span", { class: "mrd-image-field__upload-status" }, format.t('loading', this.locale)))), !this.uploading && (index.h("button", { class: "mrd-image-field__clear", type: "button", onClick: this.handleClear, "aria-label": format.t('clear', this.locale) }, format.t('remove', this.locale))))) : (index.h("div", { class: "mrd-image-field__prompt" }, index.h("svg", { class: "mrd-image-field__upload-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, index.h("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), index.h("circle", { cx: "8.5", cy: "8.5", r: "1.5" }), index.h("polyline", { points: "21 15 16 10 5 21" })), index.h("span", null, format.t('drop_file_here', this.locale), ' ', index.h("span", { class: "mrd-image-field__browse" }, format.t('browse', this.locale)))))), hasError && index.h("span", { key: '9b8f9563fea63bd12c38f5c480e9cbd24106c3af', class: "mrd-image-field__error" }, this.error))));
|
|
955
874
|
}
|
|
956
875
|
static get watchers() { return {
|
|
957
876
|
"value": [{
|
|
@@ -985,7 +904,7 @@ const MrdListField = class {
|
|
|
985
904
|
const vals = Array.from(select.selectedOptions).map(o => o.value);
|
|
986
905
|
this.selected = vals;
|
|
987
906
|
if (this.required && !validateRequired(vals)) {
|
|
988
|
-
this.error = t('required', this.locale);
|
|
907
|
+
this.error = format.t('required', this.locale);
|
|
989
908
|
}
|
|
990
909
|
else {
|
|
991
910
|
this.error = '';
|
|
@@ -995,7 +914,7 @@ const MrdListField = class {
|
|
|
995
914
|
else {
|
|
996
915
|
const val = select.value;
|
|
997
916
|
if (this.required && !validateRequired(val)) {
|
|
998
|
-
this.error = t('required', this.locale);
|
|
917
|
+
this.error = format.t('required', this.locale);
|
|
999
918
|
}
|
|
1000
919
|
else {
|
|
1001
920
|
this.error = '';
|
|
@@ -1015,7 +934,7 @@ const MrdListField = class {
|
|
|
1015
934
|
this.selected = [...this.selected, key];
|
|
1016
935
|
}
|
|
1017
936
|
if (this.required && !validateRequired(this.selected)) {
|
|
1018
|
-
this.error = t('required', this.locale);
|
|
937
|
+
this.error = format.t('required', this.locale);
|
|
1019
938
|
}
|
|
1020
939
|
else {
|
|
1021
940
|
this.error = '';
|
|
@@ -1048,7 +967,7 @@ const MrdListField = class {
|
|
|
1048
967
|
return (index.h("label", { key: lv.key, class: "mrd-list-field__checkbox-item" }, index.h("input", { type: "checkbox", checked: this.selected.includes(lv.key), disabled: this.disabled, onChange: () => this.toggleCheckbox(lv.key) }), (lv.color || lv.backgroundColor) && (index.h("span", { class: "mrd-list-field__color-dot", style: { backgroundColor: (_b = (_a = lv.backgroundColor) !== null && _a !== void 0 ? _a : lv.color) !== null && _b !== void 0 ? _b : '' } })), index.h("span", null, lv.label)));
|
|
1049
968
|
})), hasError && index.h("span", { class: "mrd-list-field__error" }, this.error))));
|
|
1050
969
|
}
|
|
1051
|
-
return (index.h(index.Host, null, index.h("div", { class: "mrd-list-field" }, this.label && (index.h("label", { class: `mrd-list-field__label${this.required ? ' mrd-list-field__label--required' : ''}` }, this.label)), index.h("select", { class: `mrd-list-field__select${hasError ? ' mrd-list-field__select--error' : ''}`, name: this.name, required: this.required, disabled: this.disabled, onChange: this.handleSelectChange, onBlur: this.handleBlur }, index.h("option", { value: "" }, t('select_placeholder', this.locale)), this.listItems.map(lv => {
|
|
970
|
+
return (index.h(index.Host, null, index.h("div", { class: "mrd-list-field" }, this.label && (index.h("label", { class: `mrd-list-field__label${this.required ? ' mrd-list-field__label--required' : ''}` }, this.label)), index.h("select", { class: `mrd-list-field__select${hasError ? ' mrd-list-field__select--error' : ''}`, name: this.name, required: this.required, disabled: this.disabled, onChange: this.handleSelectChange, onBlur: this.handleBlur }, index.h("option", { value: "" }, format.t('select_placeholder', this.locale)), this.listItems.map(lv => {
|
|
1052
971
|
var _a, _b;
|
|
1053
972
|
const bg = (_b = (_a = lv.backgroundColor) !== null && _a !== void 0 ? _a : lv.color) !== null && _b !== void 0 ? _b : null;
|
|
1054
973
|
const style = bg ? { backgroundColor: bg, color: this.getContrastColor(bg) } : {};
|
|
@@ -1083,10 +1002,10 @@ const MrdNumberField = class {
|
|
|
1083
1002
|
const raw = e.target.value;
|
|
1084
1003
|
const parsed = format.parseLocalizedNumber(raw, this.locale);
|
|
1085
1004
|
if (this.required && (parsed === null || raw === '')) {
|
|
1086
|
-
this.error = t('required', this.locale);
|
|
1005
|
+
this.error = format.t('required', this.locale);
|
|
1087
1006
|
}
|
|
1088
1007
|
else if (raw !== '' && !validateNumber(parsed, this.dataType)) {
|
|
1089
|
-
this.error = t('invalid_number', this.locale);
|
|
1008
|
+
this.error = format.t('invalid_number', this.locale);
|
|
1090
1009
|
}
|
|
1091
1010
|
else {
|
|
1092
1011
|
this.error = '';
|
|
@@ -1236,7 +1155,7 @@ const MrdRelationField = class {
|
|
|
1236
1155
|
this.mrdChange.emit({ name: this.name, value: result.id });
|
|
1237
1156
|
}
|
|
1238
1157
|
if (this.required && !validateRequired(this.selectedItems)) {
|
|
1239
|
-
this.error = t('required', this.locale);
|
|
1158
|
+
this.error = format.t('required', this.locale);
|
|
1240
1159
|
}
|
|
1241
1160
|
else {
|
|
1242
1161
|
this.error = '';
|
|
@@ -1250,7 +1169,7 @@ const MrdRelationField = class {
|
|
|
1250
1169
|
this.handleDropdownChange = (e) => {
|
|
1251
1170
|
const val = e.target.value;
|
|
1252
1171
|
if (this.required && !validateRequired(val)) {
|
|
1253
|
-
this.error = t('required', this.locale);
|
|
1172
|
+
this.error = format.t('required', this.locale);
|
|
1254
1173
|
}
|
|
1255
1174
|
else {
|
|
1256
1175
|
this.error = '';
|
|
@@ -1314,19 +1233,19 @@ const MrdRelationField = class {
|
|
|
1314
1233
|
const hasError = !!this.error;
|
|
1315
1234
|
if (this.editBehavior === index$1.ClientLayoutItemRelationEditBehavior.DROPDOWN) {
|
|
1316
1235
|
const currentValue = Array.isArray(this.value) ? ((_a = this.value[0]) !== null && _a !== void 0 ? _a : '') : ((_b = this.value) !== null && _b !== void 0 ? _b : '');
|
|
1317
|
-
return (index.h(index.Host, null, index.h("div", { class: "mrd-relation-field" }, this.label && (index.h("label", { class: `mrd-relation-field__label${this.required ? ' mrd-relation-field__label--required' : ''}` }, this.label)), index.h("select", { class: `mrd-relation-field__select${hasError ? ' mrd-relation-field__select--error' : ''}`, name: this.name, required: this.required, disabled: this.disabled, onChange: this.handleDropdownChange }, index.h("option", { value: "" }, t('select_placeholder', this.locale)), this.allRecords.map(record => (index.h("option", { key: record.id, value: record.id, selected: record.id === currentValue }, record.label)))), hasError && index.h("span", { class: "mrd-relation-field__error" }, this.error))));
|
|
1236
|
+
return (index.h(index.Host, null, index.h("div", { class: "mrd-relation-field" }, this.label && (index.h("label", { class: `mrd-relation-field__label${this.required ? ' mrd-relation-field__label--required' : ''}` }, this.label)), index.h("select", { class: `mrd-relation-field__select${hasError ? ' mrd-relation-field__select--error' : ''}`, name: this.name, required: this.required, disabled: this.disabled, onChange: this.handleDropdownChange }, index.h("option", { value: "" }, format.t('select_placeholder', this.locale)), this.allRecords.map(record => (index.h("option", { key: record.id, value: record.id, selected: record.id === currentValue }, record.label)))), hasError && index.h("span", { class: "mrd-relation-field__error" }, this.error))));
|
|
1318
1237
|
}
|
|
1319
1238
|
if (this.displayType === index$1.ClientLayoutItemRelationDisplayType.DROPDOWN) {
|
|
1320
1239
|
const currentValue = Array.isArray(this.value) ? ((_c = this.value[0]) !== null && _c !== void 0 ? _c : '') : ((_d = this.value) !== null && _d !== void 0 ? _d : '');
|
|
1321
|
-
return (index.h(index.Host, null, index.h("div", { class: "mrd-relation-field" }, this.label && (index.h("label", { class: `mrd-relation-field__label${this.required ? ' mrd-relation-field__label--required' : ''}` }, this.label)), index.h("select", { class: `mrd-relation-field__select${hasError ? ' mrd-relation-field__select--error' : ''}`, name: this.name, required: this.required, disabled: this.disabled, onChange: this.handleDropdownChange }, index.h("option", { value: "" }, t('select_placeholder', this.locale)), this.dropdownValues.map(dv => (index.h("option", { key: dv.key, value: dv.key, selected: dv.key === currentValue }, dv.label)))), hasError && index.h("span", { class: "mrd-relation-field__error" }, this.error))));
|
|
1240
|
+
return (index.h(index.Host, null, index.h("div", { class: "mrd-relation-field" }, this.label && (index.h("label", { class: `mrd-relation-field__label${this.required ? ' mrd-relation-field__label--required' : ''}` }, this.label)), index.h("select", { class: `mrd-relation-field__select${hasError ? ' mrd-relation-field__select--error' : ''}`, name: this.name, required: this.required, disabled: this.disabled, onChange: this.handleDropdownChange }, index.h("option", { value: "" }, format.t('select_placeholder', this.locale)), this.dropdownValues.map(dv => (index.h("option", { key: dv.key, value: dv.key, selected: dv.key === currentValue }, dv.label)))), hasError && index.h("span", { class: "mrd-relation-field__error" }, this.error))));
|
|
1322
1241
|
}
|
|
1323
1242
|
// SEARCH mode
|
|
1324
1243
|
const labelEl = this.label && (index.h("label", { class: `mrd-relation-field__label${this.required ? ' mrd-relation-field__label--required' : ''}` }, this.label));
|
|
1325
1244
|
// Single selection: show selected value as a badge, hide the search input
|
|
1326
1245
|
if (!this.multiple && this.selectedItems.length > 0) {
|
|
1327
|
-
return (index.h(index.Host, null, index.h("div", { class: "mrd-relation-field" }, labelEl, index.h("div", { class: `mrd-relation-field__selected-value${hasError ? ' mrd-relation-field__selected-value--error' : ''}` }, index.h("span", { class: "mrd-relation-field__selected-name" }, this.selectedItems[0].label), index.h("button", { type: "button", class: "mrd-relation-field__selected-clear", onClick: this.clearSelection, "aria-label": t('remove', this.locale) }, "\u2715")), hasError && index.h("span", { class: "mrd-relation-field__error" }, this.error))));
|
|
1246
|
+
return (index.h(index.Host, null, index.h("div", { class: "mrd-relation-field" }, labelEl, index.h("div", { class: `mrd-relation-field__selected-value${hasError ? ' mrd-relation-field__selected-value--error' : ''}` }, index.h("span", { class: "mrd-relation-field__selected-name" }, this.selectedItems[0].label), index.h("button", { type: "button", class: "mrd-relation-field__selected-clear", onClick: this.clearSelection, "aria-label": format.t('remove', this.locale) }, "\u2715")), hasError && index.h("span", { class: "mrd-relation-field__error" }, this.error))));
|
|
1328
1247
|
}
|
|
1329
|
-
return (index.h(index.Host, null, index.h("div", { class: "mrd-relation-field" }, labelEl, this.multiple && this.selectedItems.length > 0 && (index.h("div", { class: "mrd-relation-field__tags" }, this.selectedItems.map(item => (index.h("span", { key: item.id, class: "mrd-relation-field__tag" }, item.label, index.h("button", { type: "button", class: "mrd-relation-field__tag-remove", onClick: () => this.handleRemoveSelected(item.id), "aria-label": t('remove', this.locale) }, "\u2715")))))), index.h("div", { class: "mrd-relation-field__search-wrapper" }, index.h("input", { class: `mrd-relation-field__search${hasError ? ' mrd-relation-field__search--error' : ''}`, type: "text", value: this.searchQuery, placeholder: t('search_placeholder', this.locale), disabled: this.disabled, onInput: this.handleSearchInput, onKeyDown: this.handleKeyDown, onBlur: this.handleBlur }), this.isLoading && (index.h("span", { class: "mrd-relation-field__spinner", "aria-label": t('loading', this.locale) }))), this.showResults && (index.h("div", { class: "mrd-relation-field__results" }, this.searchResults.length === 0 && !this.isLoading ? (index.h("div", { class: "mrd-relation-field__no-results" }, t('no_results', this.locale))) : (this.searchResults.map((result, i) => (index.h("div", { key: result.id, class: `mrd-relation-field__result-item${i === this.highlightedIndex ? ' mrd-relation-field__result-item--highlighted' : ''}`, onMouseDown: () => this.handleResultSelect(result) }, index.h("span", { class: "mrd-relation-field__result-label" }, result.label), result.description && (index.h("span", { class: "mrd-relation-field__result-desc" }, result.description)))))))), hasError && index.h("span", { class: "mrd-relation-field__error" }, this.error))));
|
|
1248
|
+
return (index.h(index.Host, null, index.h("div", { class: "mrd-relation-field" }, labelEl, this.multiple && this.selectedItems.length > 0 && (index.h("div", { class: "mrd-relation-field__tags" }, this.selectedItems.map(item => (index.h("span", { key: item.id, class: "mrd-relation-field__tag" }, item.label, index.h("button", { type: "button", class: "mrd-relation-field__tag-remove", onClick: () => this.handleRemoveSelected(item.id), "aria-label": format.t('remove', this.locale) }, "\u2715")))))), index.h("div", { class: "mrd-relation-field__search-wrapper" }, index.h("input", { class: `mrd-relation-field__search${hasError ? ' mrd-relation-field__search--error' : ''}`, type: "text", value: this.searchQuery, placeholder: format.t('search_placeholder', this.locale), disabled: this.disabled, onInput: this.handleSearchInput, onKeyDown: this.handleKeyDown, onBlur: this.handleBlur }), this.isLoading && (index.h("span", { class: "mrd-relation-field__spinner", "aria-label": format.t('loading', this.locale) }))), this.showResults && (index.h("div", { class: "mrd-relation-field__results" }, this.searchResults.length === 0 && !this.isLoading ? (index.h("div", { class: "mrd-relation-field__no-results" }, format.t('no_results', this.locale))) : (this.searchResults.map((result, i) => (index.h("div", { key: result.id, class: `mrd-relation-field__result-item${i === this.highlightedIndex ? ' mrd-relation-field__result-item--highlighted' : ''}`, onMouseDown: () => this.handleResultSelect(result) }, index.h("span", { class: "mrd-relation-field__result-label" }, result.label), result.description && (index.h("span", { class: "mrd-relation-field__result-desc" }, result.description)))))))), hasError && index.h("span", { class: "mrd-relation-field__error" }, this.error))));
|
|
1330
1249
|
}
|
|
1331
1250
|
};
|
|
1332
1251
|
MrdRelationField.style = mrdRelationFieldScss();
|
|
@@ -1353,7 +1272,7 @@ const MrdTextField = class {
|
|
|
1353
1272
|
this.handleBlur = (e) => {
|
|
1354
1273
|
const val = e.target.value;
|
|
1355
1274
|
if (this.required && !validateRequired(val)) {
|
|
1356
|
-
this.error = t('required', this.locale);
|
|
1275
|
+
this.error = format.t('required', this.locale);
|
|
1357
1276
|
}
|
|
1358
1277
|
else {
|
|
1359
1278
|
this.error = '';
|
|
@@ -1422,7 +1341,7 @@ const MrdTextareaField = class {
|
|
|
1422
1341
|
if (!range) {
|
|
1423
1342
|
const html = (_b = (_a = this.editorEl.querySelector('.ql-editor')) === null || _a === void 0 ? void 0 : _a.innerHTML) !== null && _b !== void 0 ? _b : '';
|
|
1424
1343
|
if (this.required && !validateRequired(html)) {
|
|
1425
|
-
this.error = t('required', this.locale);
|
|
1344
|
+
this.error = format.t('required', this.locale);
|
|
1426
1345
|
}
|
|
1427
1346
|
else {
|
|
1428
1347
|
this.error = '';
|
|
@@ -1460,7 +1379,7 @@ const MrdTimeField = class {
|
|
|
1460
1379
|
this.handleChange = (e) => {
|
|
1461
1380
|
const val = e.target.value;
|
|
1462
1381
|
if (this.required && !validateRequired(val)) {
|
|
1463
|
-
this.error = t('required', this.locale);
|
|
1382
|
+
this.error = format.t('required', this.locale);
|
|
1464
1383
|
}
|
|
1465
1384
|
else {
|
|
1466
1385
|
this.error = '';
|