@mmlogic/components 0.3.11 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-BPj2cBXs.js → index-CAzwGt9u.js} +38 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mosterdcomponents.cjs.js +1 -1
- package/dist/cjs/mrd-boolean-field_23.cjs.entry.js +1203 -1084
- package/dist/collection/collection-manifest.json +23 -23
- package/dist/collection/components/{mrd-document-container/mrd-document-container.scss → documents/mrd-document-container/mrd-document-container.css} +3 -3
- package/dist/collection/components/{mrd-document-container → documents/mrd-document-container}/mrd-document-container.js +7 -7
- package/dist/collection/components/documents/mrd-document-list/folder-tree.js +109 -0
- package/dist/collection/components/{mrd-document-list/mrd-document-list.scss → documents/mrd-document-list/mrd-document-list.css} +6 -4
- package/dist/collection/components/{mrd-document-list → documents/mrd-document-list}/mrd-document-list.js +83 -240
- package/dist/collection/components/documents/mrd-document-list/tree-view.js +75 -0
- package/dist/collection/components/{mrd-document-view/mrd-document-view.scss → documents/mrd-document-view/mrd-document-view.css} +1 -1
- package/dist/collection/components/{mrd-document-view → documents/mrd-document-view}/mrd-document-view.js +4 -4
- package/dist/collection/components/fields/field-helpers.js +17 -0
- package/dist/collection/components/fields/file-upload-common.js +38 -0
- package/dist/collection/components/{mrd-boolean-field/mrd-boolean-field.scss → fields/mrd-boolean-field/mrd-boolean-field.css} +3 -3
- package/dist/collection/components/{mrd-boolean-field → fields/mrd-boolean-field}/mrd-boolean-field.js +1 -1
- package/dist/collection/components/{mrd-currency-field/mrd-currency-field.scss → fields/mrd-currency-field/mrd-currency-field.css} +11 -9
- package/dist/collection/components/{mrd-currency-field → fields/mrd-currency-field}/mrd-currency-field.js +7 -13
- package/dist/collection/components/{mrd-date-field/mrd-date-field.scss → fields/mrd-date-field/mrd-date-field.css} +8 -10
- package/dist/collection/components/{mrd-date-field → fields/mrd-date-field}/mrd-date-field.js +3 -10
- package/dist/collection/components/{mrd-datetime-field/mrd-datetime-field.scss → fields/mrd-datetime-field/mrd-datetime-field.css} +8 -10
- package/dist/collection/components/{mrd-datetime-field → fields/mrd-datetime-field}/mrd-datetime-field.js +3 -10
- package/dist/collection/components/{mrd-email-field/mrd-email-field.scss → fields/mrd-email-field/mrd-email-field.css} +2 -11
- package/dist/collection/components/{mrd-email-field → fields/mrd-email-field}/mrd-email-field.js +6 -13
- package/dist/collection/components/{mrd-file-field/mrd-file-field.scss → fields/mrd-file-field/mrd-file-field.css} +19 -24
- package/dist/collection/components/{mrd-file-field → fields/mrd-file-field}/mrd-file-field.js +13 -24
- package/dist/collection/components/{mrd-hyperlink-field/mrd-hyperlink-field.scss → fields/mrd-hyperlink-field/mrd-hyperlink-field.css} +7 -16
- package/dist/collection/components/{mrd-hyperlink-field → fields/mrd-hyperlink-field}/mrd-hyperlink-field.js +9 -15
- package/dist/collection/components/{mrd-image-field/mrd-image-field.scss → fields/mrd-image-field/mrd-image-field.css} +15 -24
- package/dist/collection/components/{mrd-image-field → fields/mrd-image-field}/mrd-image-field.js +13 -28
- package/dist/collection/components/{mrd-list-field/mrd-list-field.scss → fields/mrd-list-field/mrd-list-field.css} +18 -21
- package/dist/collection/components/{mrd-list-field → fields/mrd-list-field}/mrd-list-field.js +10 -25
- package/dist/collection/components/{mrd-longtext-field/mrd-longtext-field.scss → fields/mrd-longtext-field/mrd-longtext-field.css} +21 -18
- package/dist/collection/components/{mrd-longtext-field → fields/mrd-longtext-field}/mrd-longtext-field.js +3 -10
- package/dist/collection/components/{mrd-number-field/mrd-number-field.scss → fields/mrd-number-field/mrd-number-field.css} +9 -10
- package/dist/collection/components/{mrd-number-field → fields/mrd-number-field}/mrd-number-field.js +7 -6
- package/dist/collection/components/{mrd-relation-field/mrd-relation-field.scss → fields/mrd-relation-field/mrd-relation-field.css} +61 -59
- package/dist/collection/components/{mrd-relation-field → fields/mrd-relation-field}/mrd-relation-field.js +16 -26
- package/dist/collection/components/{mrd-secret-field/mrd-secret-field.scss → fields/mrd-secret-field/mrd-secret-field.css} +7 -10
- package/dist/collection/components/{mrd-secret-field → fields/mrd-secret-field}/mrd-secret-field.js +4 -11
- package/dist/collection/components/{mrd-text-field/mrd-text-field.scss → fields/mrd-text-field/mrd-text-field.css} +2 -11
- package/dist/collection/components/{mrd-text-field → fields/mrd-text-field}/mrd-text-field.js +3 -10
- package/dist/collection/components/{mrd-textarea-field/mrd-textarea-field.scss → fields/mrd-textarea-field/mrd-textarea-field.css} +7 -10
- package/dist/collection/components/{mrd-textarea-field → fields/mrd-textarea-field}/mrd-textarea-field.js +3 -9
- package/dist/collection/components/{mrd-time-field/mrd-time-field.scss → fields/mrd-time-field/mrd-time-field.css} +8 -10
- package/dist/collection/components/{mrd-time-field → fields/mrd-time-field}/mrd-time-field.js +3 -10
- package/dist/collection/components/{mrd-field/mrd-field.scss → form/mrd-field/mrd-field.css} +1 -1
- package/dist/collection/components/{mrd-field → form/mrd-field}/mrd-field.js +3 -3
- package/dist/collection/components/{mrd-form/mrd-form.scss → form/mrd-form/mrd-form.css} +1 -1
- package/dist/collection/components/{mrd-form → form/mrd-form}/mrd-form.js +5 -5
- package/dist/collection/components/layout/mrd-layout-section/field-value.js +111 -0
- package/dist/collection/components/layout/mrd-layout-section/layout-helpers.js +29 -0
- package/dist/collection/components/{mrd-layout-section/mrd-layout-section.scss → layout/mrd-layout-section/mrd-layout-section.css} +4 -4
- package/dist/collection/components/{mrd-layout-section → layout/mrd-layout-section}/mrd-layout-section.js +52 -142
- package/dist/collection/components/{mrd-table/mrd-table.scss → table/mrd-table/mrd-table.css} +11 -13
- package/dist/collection/components/{mrd-table → table/mrd-table}/mrd-table.js +111 -439
- package/dist/collection/components/table/mrd-table/table-filter-popup.js +85 -0
- package/dist/collection/components/table/mrd-table/table-parts.js +110 -0
- package/dist/collection/components/table/mrd-table/table-query.js +178 -0
- package/dist/collection/components/table/mrd-table/virtual-scroll.js +49 -0
- package/dist/collection/dev/app.js +19 -18
- package/dist/collection/dev/example-data.js +58 -43
- package/dist/collection/utils/i18n.js +8 -0
- package/dist/collection/utils/query-params.js +43 -0
- package/dist/components/field-helpers.js +1 -0
- package/dist/components/file-upload-common.js +1 -0
- package/dist/components/i18n.js +1 -1
- package/dist/components/mrd-boolean-field2.js +1 -1
- package/dist/components/mrd-currency-field2.js +1 -1
- package/dist/components/mrd-date-field2.js +1 -1
- package/dist/components/mrd-datetime-field2.js +1 -1
- package/dist/components/mrd-document-container2.js +1 -1
- package/dist/components/mrd-document-list2.js +1 -1
- package/dist/components/mrd-document-view2.js +1 -1
- package/dist/components/mrd-email-field2.js +1 -1
- package/dist/components/mrd-file-field2.js +1 -1
- package/dist/components/mrd-form.js +1 -1
- package/dist/components/mrd-hyperlink-field2.js +1 -1
- package/dist/components/mrd-image-field2.js +1 -1
- package/dist/components/mrd-layout-section.js +1 -1
- package/dist/components/mrd-list-field2.js +1 -1
- package/dist/components/mrd-longtext-field2.js +1 -1
- package/dist/components/mrd-number-field2.js +1 -1
- package/dist/components/mrd-relation-field2.js +1 -1
- package/dist/components/mrd-secret-field2.js +1 -1
- package/dist/components/mrd-table2.js +1 -1
- package/dist/components/mrd-text-field2.js +1 -1
- package/dist/components/mrd-textarea-field2.js +1 -1
- package/dist/components/mrd-time-field2.js +1 -1
- package/dist/components/query-params.js +1 -0
- package/dist/esm/{index-_tsCCkAi.js → index-DiSEJMA8.js} +38 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/mosterdcomponents.js +2 -2
- package/dist/esm/mrd-boolean-field_23.entry.js +1203 -1084
- package/dist/mosterdcomponents/mosterdcomponents.css +1 -1
- package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
- package/dist/mosterdcomponents/p-9b3c0917.entry.js +1 -0
- package/dist/mosterdcomponents/p-DiSEJMA8.js +2 -0
- package/dist/types/components/{mrd-document-container → documents/mrd-document-container}/mrd-document-container.d.ts +2 -2
- package/dist/types/components/documents/mrd-document-list/folder-tree.d.ts +66 -0
- package/dist/types/components/{mrd-document-list → documents/mrd-document-list}/mrd-document-list.d.ts +4 -37
- package/dist/types/components/documents/mrd-document-list/tree-view.d.ts +32 -0
- package/dist/types/components/{mrd-document-view → documents/mrd-document-view}/mrd-document-view.d.ts +2 -2
- package/dist/types/components/fields/field-helpers.d.ts +18 -0
- package/dist/types/components/fields/file-upload-common.d.ts +18 -0
- package/dist/types/components/{mrd-boolean-field → fields/mrd-boolean-field}/mrd-boolean-field.d.ts +1 -1
- package/dist/types/components/{mrd-currency-field → fields/mrd-currency-field}/mrd-currency-field.d.ts +2 -2
- package/dist/types/components/{mrd-date-field → fields/mrd-date-field}/mrd-date-field.d.ts +1 -1
- package/dist/types/components/{mrd-datetime-field → fields/mrd-datetime-field}/mrd-datetime-field.d.ts +1 -1
- package/dist/types/components/{mrd-email-field → fields/mrd-email-field}/mrd-email-field.d.ts +1 -1
- package/dist/types/components/{mrd-file-field → fields/mrd-file-field}/mrd-file-field.d.ts +2 -4
- package/dist/types/components/{mrd-hyperlink-field → fields/mrd-hyperlink-field}/mrd-hyperlink-field.d.ts +2 -2
- package/dist/types/components/{mrd-image-field → fields/mrd-image-field}/mrd-image-field.d.ts +2 -4
- package/dist/types/components/{mrd-list-field → fields/mrd-list-field}/mrd-list-field.d.ts +2 -2
- package/dist/types/components/{mrd-longtext-field → fields/mrd-longtext-field}/mrd-longtext-field.d.ts +1 -1
- package/dist/types/components/{mrd-number-field → fields/mrd-number-field}/mrd-number-field.d.ts +2 -2
- package/dist/types/components/{mrd-relation-field → fields/mrd-relation-field}/mrd-relation-field.d.ts +2 -2
- package/dist/types/components/{mrd-secret-field → fields/mrd-secret-field}/mrd-secret-field.d.ts +1 -1
- package/dist/types/components/{mrd-text-field → fields/mrd-text-field}/mrd-text-field.d.ts +1 -1
- package/dist/types/components/{mrd-textarea-field → fields/mrd-textarea-field}/mrd-textarea-field.d.ts +1 -1
- package/dist/types/components/{mrd-time-field → fields/mrd-time-field}/mrd-time-field.d.ts +1 -1
- package/dist/types/components/{mrd-field → form/mrd-field}/mrd-field.d.ts +2 -2
- package/dist/types/components/{mrd-form → form/mrd-form}/mrd-form.d.ts +2 -2
- package/dist/types/components/layout/mrd-layout-section/field-value.d.ts +22 -0
- package/dist/types/components/layout/mrd-layout-section/layout-helpers.d.ts +8 -0
- package/dist/types/components/{mrd-layout-section → layout/mrd-layout-section}/mrd-layout-section.d.ts +4 -11
- package/dist/types/components/{mrd-table → table/mrd-table}/mrd-table.d.ts +6 -13
- package/dist/types/components/table/mrd-table/table-filter-popup.d.ts +35 -0
- package/dist/types/components/table/mrd-table/table-parts.d.ts +61 -0
- package/dist/types/components/table/mrd-table/table-query.d.ts +50 -0
- package/dist/types/components/table/mrd-table/virtual-scroll.d.ts +26 -0
- package/dist/types/components.d.ts +3 -5
- package/dist/types/utils/query-params.d.ts +14 -0
- package/package.json +7 -2
- package/dist/components/validation.js +0 -1
- package/dist/mosterdcomponents/p-_tsCCkAi.js +0 -2
- package/dist/mosterdcomponents/p-a9618055.entry.js +0 -1
package/dist/collection/components/{mrd-file-field → fields/mrd-file-field}/mrd-file-field.js
RENAMED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
-
import { t } from "
|
|
2
|
+
import { t } from "../../../utils/i18n";
|
|
3
|
+
import { FieldLabel, FieldError } from "../field-helpers";
|
|
4
|
+
import { validateUploadFile, uploadZoneClass, makeDragHandlers } from "../file-upload-common";
|
|
3
5
|
export class MrdFileField {
|
|
4
6
|
constructor() {
|
|
5
7
|
this.name = '';
|
|
@@ -19,20 +21,7 @@ export class MrdFileField {
|
|
|
19
21
|
const files = e.target.files;
|
|
20
22
|
this.handleFile((_a = files === null || files === void 0 ? void 0 : files[0]) !== null && _a !== void 0 ? _a : null);
|
|
21
23
|
};
|
|
22
|
-
this.
|
|
23
|
-
e.preventDefault();
|
|
24
|
-
this.isDragging = true;
|
|
25
|
-
};
|
|
26
|
-
this.handleDragLeave = () => {
|
|
27
|
-
this.isDragging = false;
|
|
28
|
-
};
|
|
29
|
-
this.handleDrop = (e) => {
|
|
30
|
-
var _a, _b, _c;
|
|
31
|
-
e.preventDefault();
|
|
32
|
-
this.isDragging = false;
|
|
33
|
-
const file = (_c = (_b = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : null;
|
|
34
|
-
this.handleFile(file);
|
|
35
|
-
};
|
|
24
|
+
this.drag = makeDragHandlers(dragging => (this.isDragging = dragging), file => this.handleFile(file));
|
|
36
25
|
this.handleZoneClick = () => {
|
|
37
26
|
var _a;
|
|
38
27
|
if (!this.disabled && !this.uploading) {
|
|
@@ -66,8 +55,9 @@ export class MrdFileField {
|
|
|
66
55
|
this.mrdChange.emit({ name: this.name, value: null });
|
|
67
56
|
return;
|
|
68
57
|
}
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
const uploadError = validateUploadFile(file, this.maxSize, this.locale);
|
|
59
|
+
if (uploadError) {
|
|
60
|
+
this.error = uploadError;
|
|
71
61
|
return;
|
|
72
62
|
}
|
|
73
63
|
this.error = '';
|
|
@@ -79,13 +69,12 @@ export class MrdFileField {
|
|
|
79
69
|
render() {
|
|
80
70
|
const hasFile = this.uploading || (typeof this.value === 'string' && this.value) || this.fileName;
|
|
81
71
|
const hasError = !!this.error;
|
|
82
|
-
const zoneClass =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return (h(Host, { key: '095bb39f3cb1680cf5e7e51bdfd06d8eb087f237' }, h("div", { key: '7e5b5fe6e63b6530221083c8bcb82bcac59a5fe7', class: "mrd-file-field" }, this.label && (h("label", { key: 'c34723f4199371d6fe8ea87463d878b89c038590', class: `mrd-file-field__label${this.required ? ' mrd-file-field__label--required' : ''}` }, this.label)), h("div", { key: '4727667345d3cd4a5c65a431744a09f366943c13', class: zoneClass, onClick: this.handleZoneClick, onDragOver: this.handleDragOver, onDragLeave: this.handleDragLeave, onDrop: this.handleDrop }, h("input", { key: '45ed41c0f094dbe269561c8586e473f908cdf4a4', 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 ? (h("div", { class: "mrd-file-field__selected" }, this.uploading ? (h("span", { class: "mrd-file-field__spinner", "aria-label": t('loading', this.locale) })) : (h("svg", { class: "mrd-file-field__icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }), h("polyline", { points: "14 2 14 8 20 8" }))), h("span", { class: "mrd-file-field__filename" }, this.fileName), !this.uploading && (h("button", { class: "mrd-file-field__clear", type: "button", onClick: this.handleClear, "aria-label": t('clear', this.locale) }, "\u2715")))) : (h("div", { class: "mrd-file-field__prompt" }, h("svg", { class: "mrd-file-field__upload-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("polyline", { points: "16 16 12 12 8 16" }), h("line", { x1: "12", y1: "12", x2: "12", y2: "21" }), h("path", { d: "M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3" })), h("span", null, t('drop_file_here', this.locale), ' ', h("span", { class: "mrd-file-field__browse" }, t('browse', this.locale)))))), hasError && h("span", { key: '00ce94ead3c32ed63e903cfd9d8480084a308d84', class: "mrd-file-field__error" }, this.error))));
|
|
72
|
+
const zoneClass = uploadZoneClass('mrd-file-field', {
|
|
73
|
+
dragging: this.isDragging,
|
|
74
|
+
error: hasError,
|
|
75
|
+
disabled: this.disabled || this.uploading,
|
|
76
|
+
});
|
|
77
|
+
return (h(Host, { key: '2c4cee79cd0f95ed3750dfc86007a2b36aa3da15' }, h("div", { key: '5b47d0f83e8e38b22bb04409544ec2af580274f1', class: "mrd-file-field" }, h(FieldLabel, { key: '47a92d5680670bf750854fa6e7883da54a40baec', base: "mrd-file-field", label: this.label, required: this.required }), h("div", { key: '684f6ab39c32635fb5ca966ccab4a061d8682f89', class: zoneClass, onClick: this.handleZoneClick, onDragOver: this.drag.onDragOver, onDragLeave: this.drag.onDragLeave, onDrop: this.drag.onDrop }, h("input", { key: 'a47231d8c68280623daf0c5a2e4341417e7a88d0', 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 ? (h("div", { class: "mrd-file-field__selected" }, this.uploading ? (h("span", { class: "mrd-file-field__spinner", "aria-label": t('loading', this.locale) })) : (h("svg", { class: "mrd-file-field__icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }), h("polyline", { points: "14 2 14 8 20 8" }))), h("span", { class: "mrd-file-field__filename" }, this.fileName), !this.uploading && (h("button", { class: "mrd-file-field__clear", type: "button", onClick: this.handleClear, "aria-label": t('clear', this.locale) }, "\u2715")))) : (h("div", { class: "mrd-file-field__prompt" }, h("svg", { class: "mrd-file-field__upload-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("polyline", { points: "16 16 12 12 8 16" }), h("line", { x1: "12", y1: "12", x2: "12", y2: "21" }), h("path", { d: "M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3" })), h("span", null, t('drop_file_here', this.locale), ' ', h("span", { class: "mrd-file-field__browse" }, t('browse', this.locale)))))), h(FieldError, { key: '5f18e91aa94319a5571c368e745c108fb0d371a7', base: "mrd-file-field", error: this.error }))));
|
|
89
78
|
}
|
|
90
79
|
static get is() { return "mrd-file-field"; }
|
|
91
80
|
static get encapsulation() { return "scoped"; }
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
gap: var(--mrd-space-1);
|
|
9
9
|
width: 100%;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
.mrd-hyperlink-field__label {
|
|
13
12
|
display: block;
|
|
14
13
|
font-family: var(--mrd-font-family);
|
|
@@ -16,12 +15,10 @@
|
|
|
16
15
|
font-weight: var(--mrd-label-font-weight);
|
|
17
16
|
color: var(--mrd-label-color);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
.mrd-hyperlink-field__label--required::after {
|
|
21
|
-
content:
|
|
19
|
+
content: " *";
|
|
22
20
|
color: var(--mrd-color-danger);
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
.mrd-hyperlink-field__input {
|
|
26
23
|
display: block;
|
|
27
24
|
width: 100%;
|
|
@@ -38,29 +35,29 @@
|
|
|
38
35
|
appearance: none;
|
|
39
36
|
box-sizing: border-box;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
.mrd-hyperlink-field__input::placeholder {
|
|
43
39
|
color: var(--mrd-input-placeholder-color);
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
.mrd-hyperlink-field__input:focus {
|
|
47
42
|
border-color: var(--mrd-border-color-focus);
|
|
48
43
|
box-shadow: var(--mrd-shadow-focus);
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
.mrd-hyperlink-field__input:disabled {
|
|
52
46
|
background-color: var(--mrd-input-bg-disabled);
|
|
53
47
|
cursor: not-allowed;
|
|
54
48
|
opacity: 0.7;
|
|
55
49
|
}
|
|
56
|
-
|
|
57
50
|
.mrd-hyperlink-field__input--error {
|
|
58
51
|
border-color: var(--mrd-border-color-error);
|
|
59
52
|
}
|
|
60
|
-
|
|
61
53
|
.mrd-hyperlink-field__input--error:focus {
|
|
62
54
|
box-shadow: var(--mrd-shadow-focus-error);
|
|
63
55
|
}
|
|
56
|
+
.mrd-hyperlink-field__error {
|
|
57
|
+
font-family: var(--mrd-font-family);
|
|
58
|
+
font-size: var(--mrd-error-font-size);
|
|
59
|
+
color: var(--mrd-error-color);
|
|
60
|
+
}
|
|
64
61
|
|
|
65
62
|
.mrd-hyperlink-field__input--name {
|
|
66
63
|
margin-top: var(--mrd-space-1);
|
|
@@ -82,10 +79,4 @@
|
|
|
82
79
|
font-family: var(--mrd-font-family);
|
|
83
80
|
font-size: var(--mrd-font-size-base);
|
|
84
81
|
color: var(--mrd-color-neutral-400);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.mrd-hyperlink-field__error {
|
|
88
|
-
font-family: var(--mrd-font-family);
|
|
89
|
-
font-size: var(--mrd-error-font-size);
|
|
90
|
-
color: var(--mrd-error-color);
|
|
91
|
-
}
|
|
82
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
-
import { t } from "
|
|
3
|
-
import {
|
|
2
|
+
import { t } from "../../../utils/i18n";
|
|
3
|
+
import { validateUrl } from "../../../utils/validation";
|
|
4
|
+
import { FieldLabel, FieldError, controlClass, requiredError } from "../field-helpers";
|
|
4
5
|
export class MrdHyperlinkField {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.name = '';
|
|
@@ -22,15 +23,8 @@ export class MrdHyperlinkField {
|
|
|
22
23
|
this.mrdChange.emit({ name: this.name, value: this.buildValue() });
|
|
23
24
|
};
|
|
24
25
|
this.handleBlur = () => {
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
}
|
|
28
|
-
else if (this.internalHref && !validateUrl(this.internalHref)) {
|
|
29
|
-
this.error = t('invalid_url', this.locale);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
this.error = '';
|
|
33
|
-
}
|
|
26
|
+
this.error = requiredError(this.internalHref, this.required, this.locale)
|
|
27
|
+
|| (this.internalHref && !validateUrl(this.internalHref) ? t('invalid_url', this.locale) : '');
|
|
34
28
|
this.mrdBlur.emit({ name: this.name, value: this.buildValue() });
|
|
35
29
|
};
|
|
36
30
|
}
|
|
@@ -63,7 +57,7 @@ export class MrdHyperlinkField {
|
|
|
63
57
|
? h("a", { class: "mrd-hyperlink-field__link", href: this.internalHref, target: "_blank", rel: "noopener noreferrer" }, this.internalName || this.internalHref)
|
|
64
58
|
: h("span", { class: "mrd-hyperlink-field__empty" }, "\u2014"))));
|
|
65
59
|
}
|
|
66
|
-
return (h(Host, null, h("div", { class: "mrd-hyperlink-field" },
|
|
60
|
+
return (h(Host, null, h("div", { class: "mrd-hyperlink-field" }, h(FieldLabel, { base: "mrd-hyperlink-field", label: this.label, required: this.required }), h("input", { class: controlClass('mrd-hyperlink-field', hasError), type: "url", name: this.name, value: this.internalHref, placeholder: this.placeholder || 'https://', required: this.required, onInput: this.handleHrefInput, onBlur: this.handleBlur }), h("input", { class: "mrd-hyperlink-field__input mrd-hyperlink-field__input--name", type: "text", value: this.internalName, placeholder: t('hyperlink_name', this.locale), onInput: this.handleNameInput, onBlur: this.handleBlur }), h(FieldError, { base: "mrd-hyperlink-field", error: this.error }))));
|
|
67
61
|
}
|
|
68
62
|
static get is() { return "mrd-hyperlink-field"; }
|
|
69
63
|
static get encapsulation() { return "scoped"; }
|
|
@@ -128,7 +122,7 @@ export class MrdHyperlinkField {
|
|
|
128
122
|
"references": {
|
|
129
123
|
"HyperlinkValue": {
|
|
130
124
|
"location": "import",
|
|
131
|
-
"path": "
|
|
125
|
+
"path": "../../../types/client-layout",
|
|
132
126
|
"id": "src/types/client-layout.ts::HyperlinkValue",
|
|
133
127
|
"referenceLocation": "HyperlinkValue"
|
|
134
128
|
}
|
|
@@ -252,7 +246,7 @@ export class MrdHyperlinkField {
|
|
|
252
246
|
"references": {
|
|
253
247
|
"HyperlinkValue": {
|
|
254
248
|
"location": "import",
|
|
255
|
-
"path": "
|
|
249
|
+
"path": "../../../types/client-layout",
|
|
256
250
|
"id": "src/types/client-layout.ts::HyperlinkValue",
|
|
257
251
|
"referenceLocation": "HyperlinkValue"
|
|
258
252
|
}
|
|
@@ -274,7 +268,7 @@ export class MrdHyperlinkField {
|
|
|
274
268
|
"references": {
|
|
275
269
|
"HyperlinkValue": {
|
|
276
270
|
"location": "import",
|
|
277
|
-
"path": "
|
|
271
|
+
"path": "../../../types/client-layout",
|
|
278
272
|
"id": "src/types/client-layout.ts::HyperlinkValue",
|
|
279
273
|
"referenceLocation": "HyperlinkValue"
|
|
280
274
|
}
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
gap: var(--mrd-space-1);
|
|
9
9
|
width: 100%;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
.mrd-image-field__label {
|
|
13
12
|
display: block;
|
|
14
13
|
font-family: var(--mrd-font-family);
|
|
@@ -16,11 +15,15 @@
|
|
|
16
15
|
font-weight: var(--mrd-label-font-weight);
|
|
17
16
|
color: var(--mrd-label-color);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
.mrd-image-field__label--required::after {
|
|
21
|
-
content:
|
|
19
|
+
content: " *";
|
|
22
20
|
color: var(--mrd-color-danger);
|
|
23
21
|
}
|
|
22
|
+
.mrd-image-field__error {
|
|
23
|
+
font-family: var(--mrd-font-family);
|
|
24
|
+
font-size: var(--mrd-error-font-size);
|
|
25
|
+
color: var(--mrd-error-color);
|
|
26
|
+
}
|
|
24
27
|
|
|
25
28
|
.mrd-image-field__zone {
|
|
26
29
|
display: flex;
|
|
@@ -34,26 +37,17 @@
|
|
|
34
37
|
min-height: 100px;
|
|
35
38
|
position: relative;
|
|
36
39
|
}
|
|
37
|
-
|
|
38
|
-
.mrd-image-field__zone:hover {
|
|
39
|
-
border-color: var(--mrd-color-primary);
|
|
40
|
-
background-color: var(--mrd-color-primary-light);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.mrd-image-field__zone--dragging {
|
|
40
|
+
.mrd-image-field__zone:hover, .mrd-image-field__zone--dragging {
|
|
44
41
|
border-color: var(--mrd-color-primary);
|
|
45
42
|
background-color: var(--mrd-color-primary-light);
|
|
46
43
|
}
|
|
47
|
-
|
|
48
44
|
.mrd-image-field__zone--error {
|
|
49
45
|
border-color: var(--mrd-border-color-error);
|
|
50
46
|
}
|
|
51
|
-
|
|
52
47
|
.mrd-image-field__zone--disabled {
|
|
53
48
|
opacity: 0.6;
|
|
54
49
|
cursor: not-allowed;
|
|
55
50
|
}
|
|
56
|
-
|
|
57
51
|
.mrd-image-field__zone--disabled:hover {
|
|
58
52
|
border-color: var(--mrd-border-color);
|
|
59
53
|
background-color: var(--mrd-color-neutral-50);
|
|
@@ -139,7 +133,7 @@
|
|
|
139
133
|
.mrd-image-field__preview-overlay {
|
|
140
134
|
position: absolute;
|
|
141
135
|
inset: 0;
|
|
142
|
-
background:
|
|
136
|
+
background: rgba(255, 255, 255, 0.7);
|
|
143
137
|
display: flex;
|
|
144
138
|
align-items: center;
|
|
145
139
|
justify-content: center;
|
|
@@ -153,11 +147,14 @@
|
|
|
153
147
|
border: 2px solid var(--mrd-color-neutral-300);
|
|
154
148
|
border-top-color: var(--mrd-color-primary);
|
|
155
149
|
border-radius: 50%;
|
|
156
|
-
animation: mrd-
|
|
150
|
+
animation: mrd-spin 0.6s linear infinite;
|
|
157
151
|
}
|
|
158
152
|
|
|
159
|
-
@keyframes mrd-
|
|
160
|
-
|
|
153
|
+
@keyframes mrd-spin {
|
|
154
|
+
to {
|
|
155
|
+
transform: rotate(360deg);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
161
158
|
.mrd-image-field__upload-status {
|
|
162
159
|
font-family: var(--mrd-font-family);
|
|
163
160
|
font-size: var(--mrd-font-size-xs);
|
|
@@ -181,10 +178,4 @@
|
|
|
181
178
|
.mrd-image-field__clear:hover {
|
|
182
179
|
background-color: var(--mrd-color-danger);
|
|
183
180
|
color: var(--mrd-color-white);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.mrd-image-field__error {
|
|
187
|
-
font-family: var(--mrd-font-family);
|
|
188
|
-
font-size: var(--mrd-error-font-size);
|
|
189
|
-
color: var(--mrd-error-color);
|
|
190
|
-
}
|
|
181
|
+
}
|
package/dist/collection/components/{mrd-image-field → fields/mrd-image-field}/mrd-image-field.js
RENAMED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
-
import { t } from "
|
|
2
|
+
import { t } from "../../../utils/i18n";
|
|
3
|
+
import { FieldLabel, FieldError } from "../field-helpers";
|
|
4
|
+
import { validateUploadFile, uploadZoneClass, makeDragHandlers } from "../file-upload-common";
|
|
3
5
|
export class MrdImageField {
|
|
4
6
|
constructor() {
|
|
5
7
|
this.name = '';
|
|
@@ -20,20 +22,7 @@ export class MrdImageField {
|
|
|
20
22
|
const files = e.target.files;
|
|
21
23
|
this.handleFile((_a = files === null || files === void 0 ? void 0 : files[0]) !== null && _a !== void 0 ? _a : null);
|
|
22
24
|
};
|
|
23
|
-
this.
|
|
24
|
-
e.preventDefault();
|
|
25
|
-
this.isDragging = true;
|
|
26
|
-
};
|
|
27
|
-
this.handleDragLeave = () => {
|
|
28
|
-
this.isDragging = false;
|
|
29
|
-
};
|
|
30
|
-
this.handleDrop = (e) => {
|
|
31
|
-
var _a, _b, _c;
|
|
32
|
-
e.preventDefault();
|
|
33
|
-
this.isDragging = false;
|
|
34
|
-
const file = (_c = (_b = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : null;
|
|
35
|
-
this.handleFile(file);
|
|
36
|
-
};
|
|
25
|
+
this.drag = makeDragHandlers(dragging => (this.isDragging = dragging), file => this.handleFile(file));
|
|
37
26
|
this.handleZoneClick = () => {
|
|
38
27
|
var _a;
|
|
39
28
|
if (!this.disabled && !this.uploading) {
|
|
@@ -70,12 +59,9 @@ export class MrdImageField {
|
|
|
70
59
|
this.mrdChange.emit({ name: this.name, value: null });
|
|
71
60
|
return;
|
|
72
61
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
if (!file.type.startsWith('image/')) {
|
|
78
|
-
this.error = 'Please select an image file';
|
|
62
|
+
const uploadError = validateUploadFile(file, this.maxSize, this.locale, true);
|
|
63
|
+
if (uploadError) {
|
|
64
|
+
this.error = uploadError;
|
|
79
65
|
return;
|
|
80
66
|
}
|
|
81
67
|
this.error = '';
|
|
@@ -93,13 +79,12 @@ export class MrdImageField {
|
|
|
93
79
|
}
|
|
94
80
|
render() {
|
|
95
81
|
const hasError = !!this.error;
|
|
96
|
-
const zoneClass =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return (h(Host, { key: '97db2df72839f36b7a46e153a5dd1c208c52b522' }, h("div", { key: 'c8f2d3d858f90d322d26082aaf5adb57acfc78f4', class: "mrd-image-field" }, this.label && (h("label", { key: '6625e5031ff0b7c06f76c1ea0387f1bd5c1858a4', class: `mrd-image-field__label${this.required ? ' mrd-image-field__label--required' : ''}` }, this.label)), h("div", { key: '364216e6a96e845e21c42e821fdff02bd2612ff8', class: zoneClass, onClick: this.handleZoneClick, onDragOver: this.handleDragOver, onDragLeave: this.handleDragLeave, onDrop: this.handleDrop }, h("input", { key: '0487706ddd9f48cda1cb0c2a178809d90674486b', 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 ? (h("div", { class: "mrd-image-field__preview-container" }, h("div", { class: "mrd-image-field__preview-thumb" }, h("img", { class: "mrd-image-field__preview", src: this.previewUrl, alt: this.fileName }), this.uploading && h("div", { class: "mrd-image-field__preview-overlay" }, h("span", { class: "mrd-image-field__spinner" }))), h("div", { class: "mrd-image-field__preview-info" }, h("span", { class: "mrd-image-field__preview-name" }, this.fileName), this.uploading && (h("span", { class: "mrd-image-field__upload-status" }, t('loading', this.locale)))), !this.uploading && (h("button", { class: "mrd-image-field__clear", type: "button", onClick: this.handleClear, "aria-label": t('clear', this.locale) }, t('remove', this.locale))))) : (h("div", { class: "mrd-image-field__prompt" }, h("svg", { class: "mrd-image-field__upload-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), h("circle", { cx: "8.5", cy: "8.5", r: "1.5" }), h("polyline", { points: "21 15 16 10 5 21" })), h("span", null, t('drop_file_here', this.locale), ' ', h("span", { class: "mrd-image-field__browse" }, t('browse', this.locale)))))), hasError && h("span", { key: 'bd505ef4f4b67c4e9138d8825c6e600f583f4cab', class: "mrd-image-field__error" }, this.error))));
|
|
82
|
+
const zoneClass = uploadZoneClass('mrd-image-field', {
|
|
83
|
+
dragging: this.isDragging,
|
|
84
|
+
error: hasError,
|
|
85
|
+
disabled: this.disabled || this.uploading,
|
|
86
|
+
});
|
|
87
|
+
return (h(Host, { key: 'ab78d93ab6c810363a8993bea4545f7406680e58' }, h("div", { key: '727ae5d9c1cce22d90d26229a9ea5d677abb4b07', class: "mrd-image-field" }, h(FieldLabel, { key: 'aab0e9fcc0204e8ea617453b5ca458f683194125', base: "mrd-image-field", label: this.label, required: this.required }), h("div", { key: '1241faff26c47a303fd0431201f490c6b8725987', class: zoneClass, onClick: this.handleZoneClick, onDragOver: this.drag.onDragOver, onDragLeave: this.drag.onDragLeave, onDrop: this.drag.onDrop }, h("input", { key: '70e3b8f869927ad525465ace96ed3ea24f5b7555', 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 ? (h("div", { class: "mrd-image-field__preview-container" }, h("div", { class: "mrd-image-field__preview-thumb" }, h("img", { class: "mrd-image-field__preview", src: this.previewUrl, alt: this.fileName }), this.uploading && h("div", { class: "mrd-image-field__preview-overlay" }, h("span", { class: "mrd-image-field__spinner" }))), h("div", { class: "mrd-image-field__preview-info" }, h("span", { class: "mrd-image-field__preview-name" }, this.fileName), this.uploading && (h("span", { class: "mrd-image-field__upload-status" }, t('loading', this.locale)))), !this.uploading && (h("button", { class: "mrd-image-field__clear", type: "button", onClick: this.handleClear, "aria-label": t('clear', this.locale) }, t('remove', this.locale))))) : (h("div", { class: "mrd-image-field__prompt" }, h("svg", { class: "mrd-image-field__upload-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), h("circle", { cx: "8.5", cy: "8.5", r: "1.5" }), h("polyline", { points: "21 15 16 10 5 21" })), h("span", null, t('drop_file_here', this.locale), ' ', h("span", { class: "mrd-image-field__browse" }, t('browse', this.locale)))))), h(FieldError, { key: '01552a994c1e5a9f25129586a95562c32a377046', base: "mrd-image-field", error: this.error }))));
|
|
103
88
|
}
|
|
104
89
|
static get is() { return "mrd-image-field"; }
|
|
105
90
|
static get encapsulation() { return "scoped"; }
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
gap: var(--mrd-space-1);
|
|
9
9
|
width: 100%;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
.mrd-list-field__label {
|
|
13
12
|
display: block;
|
|
14
13
|
font-family: var(--mrd-font-family);
|
|
@@ -16,52 +15,56 @@
|
|
|
16
15
|
font-weight: var(--mrd-label-font-weight);
|
|
17
16
|
color: var(--mrd-label-color);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
.mrd-list-field__label--required::after {
|
|
21
|
-
content:
|
|
19
|
+
content: " *";
|
|
22
20
|
color: var(--mrd-color-danger);
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
.mrd-list-field__select {
|
|
26
23
|
display: block;
|
|
27
24
|
width: 100%;
|
|
28
25
|
height: var(--mrd-input-height);
|
|
29
26
|
padding: var(--mrd-input-padding-y) var(--mrd-input-padding-x);
|
|
30
|
-
padding-right: calc(var(--mrd-input-padding-x) + 1.5rem);
|
|
31
27
|
font-family: var(--mrd-font-family);
|
|
32
28
|
font-size: var(--mrd-font-size-base);
|
|
33
29
|
color: var(--mrd-input-color);
|
|
34
30
|
background-color: var(--mrd-input-bg);
|
|
35
|
-
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
|
|
36
|
-
background-repeat: no-repeat;
|
|
37
|
-
background-position: right var(--mrd-space-3) center;
|
|
38
31
|
border: var(--mrd-border-width) solid var(--mrd-border-color);
|
|
39
32
|
border-radius: var(--mrd-border-radius);
|
|
40
33
|
transition: border-color var(--mrd-transition), box-shadow var(--mrd-transition);
|
|
41
34
|
outline: none;
|
|
42
35
|
appearance: none;
|
|
43
|
-
cursor: pointer;
|
|
44
36
|
box-sizing: border-box;
|
|
45
37
|
}
|
|
46
|
-
|
|
38
|
+
.mrd-list-field__select::placeholder {
|
|
39
|
+
color: var(--mrd-input-placeholder-color);
|
|
40
|
+
}
|
|
47
41
|
.mrd-list-field__select:focus {
|
|
48
42
|
border-color: var(--mrd-border-color-focus);
|
|
49
43
|
box-shadow: var(--mrd-shadow-focus);
|
|
50
44
|
}
|
|
51
|
-
|
|
52
45
|
.mrd-list-field__select:disabled {
|
|
53
46
|
background-color: var(--mrd-input-bg-disabled);
|
|
54
47
|
cursor: not-allowed;
|
|
55
48
|
opacity: 0.7;
|
|
56
49
|
}
|
|
57
|
-
|
|
58
50
|
.mrd-list-field__select--error {
|
|
59
51
|
border-color: var(--mrd-border-color-error);
|
|
60
52
|
}
|
|
61
|
-
|
|
62
53
|
.mrd-list-field__select--error:focus {
|
|
63
54
|
box-shadow: var(--mrd-shadow-focus-error);
|
|
64
55
|
}
|
|
56
|
+
.mrd-list-field__select {
|
|
57
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
|
|
58
|
+
background-repeat: no-repeat;
|
|
59
|
+
background-position: right var(--mrd-space-3) center;
|
|
60
|
+
padding-right: calc(var(--mrd-input-padding-x) + 1.5rem);
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
}
|
|
63
|
+
.mrd-list-field__error {
|
|
64
|
+
font-family: var(--mrd-font-family);
|
|
65
|
+
font-size: var(--mrd-error-font-size);
|
|
66
|
+
color: var(--mrd-error-color);
|
|
67
|
+
}
|
|
65
68
|
|
|
66
69
|
.mrd-list-field__checkbox-list {
|
|
67
70
|
display: flex;
|
|
@@ -87,7 +90,7 @@
|
|
|
87
90
|
cursor: pointer;
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
.mrd-list-field__checkbox-item input[type=
|
|
93
|
+
.mrd-list-field__checkbox-item input[type=checkbox] {
|
|
91
94
|
width: 1rem;
|
|
92
95
|
height: 1rem;
|
|
93
96
|
cursor: pointer;
|
|
@@ -100,10 +103,4 @@
|
|
|
100
103
|
height: 12px;
|
|
101
104
|
border-radius: 50%;
|
|
102
105
|
flex-shrink: 0;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.mrd-list-field__error {
|
|
106
|
-
font-family: var(--mrd-font-family);
|
|
107
|
-
font-size: var(--mrd-error-font-size);
|
|
108
|
-
color: var(--mrd-error-color);
|
|
109
|
-
}
|
|
106
|
+
}
|
package/dist/collection/components/{mrd-list-field → fields/mrd-list-field}/mrd-list-field.js
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
-
import { t } from "
|
|
3
|
-
import {
|
|
2
|
+
import { t } from "../../../utils/i18n";
|
|
3
|
+
import { FieldLabel, FieldError, controlClass, requiredError } from "../field-helpers";
|
|
4
4
|
export class MrdListField {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.name = '';
|
|
@@ -19,22 +19,12 @@ export class MrdListField {
|
|
|
19
19
|
if (this.multiple) {
|
|
20
20
|
const vals = Array.from(select.selectedOptions).map(o => o.value);
|
|
21
21
|
this.selected = vals;
|
|
22
|
-
|
|
23
|
-
this.error = t('required', this.locale);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
this.error = '';
|
|
27
|
-
}
|
|
22
|
+
this.error = requiredError(vals, this.required, this.locale);
|
|
28
23
|
this.mrdChange.emit({ name: this.name, value: vals });
|
|
29
24
|
}
|
|
30
25
|
else {
|
|
31
26
|
const val = select.value;
|
|
32
|
-
|
|
33
|
-
this.error = t('required', this.locale);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
this.error = '';
|
|
37
|
-
}
|
|
27
|
+
this.error = requiredError(val, this.required, this.locale);
|
|
38
28
|
this.mrdChange.emit({ name: this.name, value: val });
|
|
39
29
|
}
|
|
40
30
|
};
|
|
@@ -49,12 +39,7 @@ export class MrdListField {
|
|
|
49
39
|
else {
|
|
50
40
|
this.selected = [...this.selected, key];
|
|
51
41
|
}
|
|
52
|
-
|
|
53
|
-
this.error = t('required', this.locale);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this.error = '';
|
|
57
|
-
}
|
|
42
|
+
this.error = requiredError(this.selected, this.required, this.locale);
|
|
58
43
|
this.mrdChange.emit({ name: this.name, value: this.selected });
|
|
59
44
|
};
|
|
60
45
|
}
|
|
@@ -78,17 +63,17 @@ export class MrdListField {
|
|
|
78
63
|
const hasError = !!this.error;
|
|
79
64
|
const currentValue = Array.isArray(this.value) ? ((_a = this.value[0]) !== null && _a !== void 0 ? _a : '') : ((_b = this.value) !== null && _b !== void 0 ? _b : '');
|
|
80
65
|
if (this.multiple) {
|
|
81
|
-
return (h(Host, null, h("div", { class: "mrd-list-field" },
|
|
66
|
+
return (h(Host, null, h("div", { class: "mrd-list-field" }, h(FieldLabel, { base: "mrd-list-field", label: this.label, required: this.required }), h("div", { class: controlClass('mrd-list-field', hasError, 'checkbox-list') }, this.listItems.map(lv => {
|
|
82
67
|
var _a, _b;
|
|
83
68
|
return (h("label", { key: lv.key, class: "mrd-list-field__checkbox-item" }, h("input", { type: "checkbox", checked: this.selected.includes(lv.key), disabled: this.disabled, onChange: () => this.toggleCheckbox(lv.key) }), (lv.color || lv.backgroundColor) && (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 : '' } })), h("span", null, lv.label)));
|
|
84
|
-
})),
|
|
69
|
+
})), h(FieldError, { base: "mrd-list-field", error: this.error }))));
|
|
85
70
|
}
|
|
86
|
-
return (h(Host, null, h("div", { class: "mrd-list-field" },
|
|
71
|
+
return (h(Host, null, h("div", { class: "mrd-list-field" }, h(FieldLabel, { base: "mrd-list-field", label: this.label, required: this.required }), h("select", { class: controlClass('mrd-list-field', hasError, 'select'), name: this.name, required: this.required, disabled: this.disabled, onChange: this.handleSelectChange, onBlur: this.handleBlur }, h("option", { value: "" }, t('select_placeholder', this.locale)), this.listItems.map(lv => {
|
|
87
72
|
var _a, _b;
|
|
88
73
|
const bg = (_b = (_a = lv.backgroundColor) !== null && _a !== void 0 ? _a : lv.color) !== null && _b !== void 0 ? _b : null;
|
|
89
74
|
const style = bg ? { backgroundColor: bg, color: this.getContrastColor(bg) } : {};
|
|
90
75
|
return (h("option", { key: lv.key, value: lv.key, selected: lv.key === currentValue, style: style }, lv.label));
|
|
91
|
-
})),
|
|
76
|
+
})), h(FieldError, { base: "mrd-list-field", error: this.error }))));
|
|
92
77
|
}
|
|
93
78
|
static get is() { return "mrd-list-field"; }
|
|
94
79
|
static get encapsulation() { return "scoped"; }
|
|
@@ -253,7 +238,7 @@ export class MrdListField {
|
|
|
253
238
|
"references": {
|
|
254
239
|
"ClientListValue": {
|
|
255
240
|
"location": "import",
|
|
256
|
-
"path": "
|
|
241
|
+
"path": "../../../types",
|
|
257
242
|
"id": "src/types/index.ts::ClientListValue",
|
|
258
243
|
"referenceLocation": "ClientListValue"
|
|
259
244
|
}
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
gap: var(--mrd-space-1);
|
|
9
9
|
width: 100%;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
.mrd-longtext-field__label {
|
|
13
12
|
display: block;
|
|
14
13
|
font-family: var(--mrd-font-family);
|
|
@@ -16,16 +15,14 @@
|
|
|
16
15
|
font-weight: var(--mrd-label-font-weight);
|
|
17
16
|
color: var(--mrd-label-color);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
.mrd-longtext-field__label--required::after {
|
|
21
|
-
content:
|
|
19
|
+
content: " *";
|
|
22
20
|
color: var(--mrd-color-danger);
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
.mrd-longtext-field__input {
|
|
26
23
|
display: block;
|
|
27
24
|
width: 100%;
|
|
28
|
-
|
|
25
|
+
height: var(--mrd-input-height);
|
|
29
26
|
padding: var(--mrd-input-padding-y) var(--mrd-input-padding-x);
|
|
30
27
|
font-family: var(--mrd-font-family);
|
|
31
28
|
font-size: var(--mrd-font-size-base);
|
|
@@ -35,27 +32,39 @@
|
|
|
35
32
|
border-radius: var(--mrd-border-radius);
|
|
36
33
|
transition: border-color var(--mrd-transition), box-shadow var(--mrd-transition);
|
|
37
34
|
outline: none;
|
|
38
|
-
|
|
35
|
+
appearance: none;
|
|
39
36
|
box-sizing: border-box;
|
|
40
|
-
line-height: 1.5;
|
|
41
37
|
}
|
|
42
|
-
|
|
43
38
|
.mrd-longtext-field__input::placeholder {
|
|
44
39
|
color: var(--mrd-input-placeholder-color);
|
|
45
40
|
}
|
|
46
|
-
|
|
47
41
|
.mrd-longtext-field__input:focus {
|
|
48
42
|
border-color: var(--mrd-border-color-focus);
|
|
49
43
|
box-shadow: var(--mrd-shadow-focus);
|
|
50
44
|
}
|
|
51
|
-
|
|
45
|
+
.mrd-longtext-field__input:disabled {
|
|
46
|
+
background-color: var(--mrd-input-bg-disabled);
|
|
47
|
+
cursor: not-allowed;
|
|
48
|
+
opacity: 0.7;
|
|
49
|
+
}
|
|
52
50
|
.mrd-longtext-field__input--error {
|
|
53
51
|
border-color: var(--mrd-border-color-error);
|
|
54
52
|
}
|
|
55
|
-
|
|
56
53
|
.mrd-longtext-field__input--error:focus {
|
|
57
54
|
box-shadow: var(--mrd-shadow-focus-error);
|
|
58
55
|
}
|
|
56
|
+
.mrd-longtext-field__error {
|
|
57
|
+
font-family: var(--mrd-font-family);
|
|
58
|
+
font-size: var(--mrd-error-font-size);
|
|
59
|
+
color: var(--mrd-error-color);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.mrd-longtext-field__input {
|
|
63
|
+
height: auto;
|
|
64
|
+
min-height: calc(var(--mrd-input-height) * 5);
|
|
65
|
+
resize: vertical;
|
|
66
|
+
line-height: 1.5;
|
|
67
|
+
}
|
|
59
68
|
|
|
60
69
|
.mrd-longtext-field__content {
|
|
61
70
|
font-family: var(--mrd-font-family);
|
|
@@ -69,10 +78,4 @@
|
|
|
69
78
|
border: var(--mrd-border-width) solid var(--mrd-border-color);
|
|
70
79
|
border-radius: var(--mrd-border-radius);
|
|
71
80
|
line-height: 1.5;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.mrd-longtext-field__error {
|
|
75
|
-
font-family: var(--mrd-font-family);
|
|
76
|
-
font-size: var(--mrd-error-font-size);
|
|
77
|
-
color: var(--mrd-error-color);
|
|
78
|
-
}
|
|
81
|
+
}
|