@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.
- package/dist/cjs/index.cjs.js +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mosterdcomponents.cjs.js +1 -1
- package/dist/cjs/{mrd-boolean-field_19.cjs.entry.js → mrd-boolean-field_20.cjs.entry.js} +594 -67
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/mrd-field/mrd-field.js +142 -27
- package/dist/collection/components/mrd-field/mrd-field.scss +118 -0
- package/dist/collection/components/mrd-form/mrd-form.js +3 -3
- package/dist/collection/components/mrd-hyperlink-field/mrd-hyperlink-field.js +79 -18
- package/dist/collection/components/mrd-hyperlink-field/mrd-hyperlink-field.scss +22 -0
- package/dist/collection/components/mrd-image-field/mrd-image-field.js +1 -1
- package/dist/collection/components/mrd-layout-section/mrd-layout-section.js +54 -15
- package/dist/collection/components/mrd-layout-section/mrd-layout-section.scss +76 -0
- package/dist/collection/components/mrd-longtext-field/mrd-longtext-field.js +1 -1
- package/dist/collection/components/mrd-number-field/mrd-number-field.js +2 -2
- package/dist/collection/components/mrd-secret-field/mrd-secret-field.js +229 -0
- package/dist/collection/components/mrd-secret-field/mrd-secret-field.scss +73 -0
- package/dist/collection/components/mrd-table/mrd-table.js +46 -6
- package/dist/collection/components/mrd-table/mrd-table.scss +36 -0
- package/dist/collection/components/mrd-text-field/mrd-text-field.js +1 -1
- package/dist/collection/components/mrd-textarea-field/mrd-textarea-field.js +1 -1
- package/dist/collection/components/mrd-time-field/mrd-time-field.js +1 -1
- package/dist/collection/dev/api.js +1 -1
- package/dist/collection/dev/app.js +9 -4
- package/dist/collection/dev/example-data.js +12 -2
- package/dist/collection/types/client-layout.js +1 -0
- package/dist/collection/utils/cell-renderer.js +2 -0
- package/dist/collection/utils/i18n.js +269 -1
- package/dist/collection/utils/validation.js +6 -2
- package/dist/components/client-layout.js +1 -1
- package/dist/components/format.js +1 -1
- package/dist/components/i18n.js +1 -1
- package/dist/components/mrd-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-longtext-field2.js +1 -1
- package/dist/components/mrd-number-field2.js +1 -1
- package/dist/components/mrd-secret-field.d.ts +11 -0
- package/dist/components/mrd-secret-field.js +1 -0
- package/dist/components/mrd-secret-field2.js +1 -0
- 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/validation.js +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mosterdcomponents.js +1 -1
- package/dist/esm/{mrd-boolean-field_19.entry.js → mrd-boolean-field_20.entry.js} +594 -68
- package/dist/mosterdcomponents/index.esm.js +1 -1
- package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
- package/dist/mosterdcomponents/p-c9839596.entry.js +1 -0
- package/dist/types/components/mrd-field/mrd-field.d.ts +14 -0
- package/dist/types/components/mrd-hyperlink-field/mrd-hyperlink-field.d.ts +12 -4
- package/dist/types/components/mrd-layout-section/mrd-layout-section.d.ts +5 -0
- package/dist/types/components/mrd-secret-field/mrd-secret-field.d.ts +22 -0
- package/dist/types/components/mrd-table/mrd-table.d.ts +6 -0
- package/dist/types/components.d.ts +109 -13
- package/dist/types/types/client-layout.d.ts +14 -1
- package/dist/types/utils/cell-renderer.d.ts +1 -0
- package/package.json +1 -1
- package/dist/mosterdcomponents/p-2a099635.entry.js +0 -1
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"components/mrd-longtext-field/mrd-longtext-field.js",
|
|
16
16
|
"components/mrd-number-field/mrd-number-field.js",
|
|
17
17
|
"components/mrd-relation-field/mrd-relation-field.js",
|
|
18
|
+
"components/mrd-secret-field/mrd-secret-field.js",
|
|
18
19
|
"components/mrd-table/mrd-table.js",
|
|
19
20
|
"components/mrd-text-field/mrd-text-field.js",
|
|
20
21
|
"components/mrd-textarea-field/mrd-textarea-field.js",
|
|
@@ -1,15 +1,39 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
import { ClientLayoutItemType, ClientLayoutItemFieldDataType, ClientLayoutItemRelationDisplayType, } from "../../types";
|
|
3
|
+
import { t } from "../../utils/i18n";
|
|
3
4
|
export class MrdField {
|
|
4
5
|
constructor() {
|
|
5
6
|
this.locale = navigator.language;
|
|
7
|
+
this.historyEntries = [];
|
|
8
|
+
this.currentValue = undefined;
|
|
6
9
|
this.handleChange = (e) => {
|
|
10
|
+
var _a, _b, _c, _d;
|
|
7
11
|
e.stopPropagation();
|
|
8
|
-
this.
|
|
12
|
+
const hist = (_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.historyEnabled) !== null && _b !== void 0 ? _b : (_d = (_c = this.item) === null || _c === void 0 ? void 0 : _c.field) === null || _d === void 0 ? void 0 : _d.historyEnabled;
|
|
13
|
+
if (hist) {
|
|
14
|
+
this.currentValue = e.detail.value;
|
|
15
|
+
this.mrdChange.emit({
|
|
16
|
+
name: e.detail.name,
|
|
17
|
+
value: { current: e.detail.value, history: this.historyEntries },
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.mrdChange.emit(e.detail);
|
|
22
|
+
}
|
|
9
23
|
};
|
|
10
24
|
this.handleBlur = (e) => {
|
|
25
|
+
var _a, _b, _c, _d;
|
|
11
26
|
e.stopPropagation();
|
|
12
|
-
this.
|
|
27
|
+
const hist = (_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.historyEnabled) !== null && _b !== void 0 ? _b : (_d = (_c = this.item) === null || _c === void 0 ? void 0 : _c.field) === null || _d === void 0 ? void 0 : _d.historyEnabled;
|
|
28
|
+
if (hist) {
|
|
29
|
+
this.mrdBlur.emit({
|
|
30
|
+
name: e.detail.name,
|
|
31
|
+
value: { current: this.currentValue, history: this.historyEntries },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.mrdBlur.emit(e.detail);
|
|
36
|
+
}
|
|
13
37
|
};
|
|
14
38
|
this.handleSearch = (e) => {
|
|
15
39
|
e.stopPropagation();
|
|
@@ -24,63 +48,141 @@ export class MrdField {
|
|
|
24
48
|
this.mrdUpload.emit(e.detail);
|
|
25
49
|
};
|
|
26
50
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
componentWillLoad() {
|
|
52
|
+
this.initHistoryState();
|
|
53
|
+
}
|
|
54
|
+
valueChanged() {
|
|
55
|
+
this.initHistoryState();
|
|
56
|
+
}
|
|
57
|
+
initHistoryState() {
|
|
58
|
+
var _a, _b, _c, _d, _e;
|
|
59
|
+
const hist = (_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.historyEnabled) !== null && _b !== void 0 ? _b : (_d = (_c = this.item) === null || _c === void 0 ? void 0 : _c.field) === null || _d === void 0 ? void 0 : _d.historyEnabled;
|
|
60
|
+
if (!hist)
|
|
61
|
+
return;
|
|
62
|
+
const raw = this.value;
|
|
63
|
+
this.currentValue = (_e = raw === null || raw === void 0 ? void 0 : raw.current) !== null && _e !== void 0 ? _e : raw;
|
|
64
|
+
this.historyEntries = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.history) ? [...raw.history] : [];
|
|
65
|
+
}
|
|
66
|
+
getDisplayValue() {
|
|
67
|
+
var _a, _b, _c, _d;
|
|
68
|
+
const hist = (_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.historyEnabled) !== null && _b !== void 0 ? _b : (_d = (_c = this.item) === null || _c === void 0 ? void 0 : _c.field) === null || _d === void 0 ? void 0 : _d.historyEnabled;
|
|
69
|
+
if (hist && this.value !== null && typeof this.value === 'object' && 'current' in this.value) {
|
|
70
|
+
return this.value.current;
|
|
32
71
|
}
|
|
33
|
-
|
|
34
|
-
|
|
72
|
+
return this.value;
|
|
73
|
+
}
|
|
74
|
+
historyValueInputType() {
|
|
75
|
+
var _a;
|
|
76
|
+
switch ((_a = this.item) === null || _a === void 0 ? void 0 : _a.dataType) {
|
|
77
|
+
case ClientLayoutItemFieldDataType.DATE: return 'date';
|
|
78
|
+
case ClientLayoutItemFieldDataType.DATETIME: return 'datetime-local';
|
|
79
|
+
case ClientLayoutItemFieldDataType.TIME: return 'time';
|
|
80
|
+
case ClientLayoutItemFieldDataType.INTEGER:
|
|
81
|
+
case ClientLayoutItemFieldDataType.DECIMAL:
|
|
82
|
+
case ClientLayoutItemFieldDataType.PERCENTAGE: return 'number';
|
|
83
|
+
case ClientLayoutItemFieldDataType.EMAIL: return 'email';
|
|
84
|
+
default: return 'text';
|
|
35
85
|
}
|
|
86
|
+
}
|
|
87
|
+
emitHistoryChange(entries) {
|
|
88
|
+
this.historyEntries = entries;
|
|
89
|
+
this.mrdChange.emit({
|
|
90
|
+
name: this.item.name,
|
|
91
|
+
value: { current: this.currentValue, history: entries },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
renderHistoryEditor() {
|
|
95
|
+
var _a, _b, _c, _d;
|
|
96
|
+
const hist = (_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.historyEnabled) !== null && _b !== void 0 ? _b : (_d = (_c = this.item) === null || _c === void 0 ? void 0 : _c.field) === null || _d === void 0 ? void 0 : _d.historyEnabled;
|
|
97
|
+
if (!hist)
|
|
98
|
+
return null;
|
|
99
|
+
const { locale } = this;
|
|
100
|
+
const valueType = this.historyValueInputType();
|
|
101
|
+
const updateEntry = (i, field, val) => {
|
|
102
|
+
const updated = this.historyEntries.map((e, idx) => idx === i ? Object.assign(Object.assign({}, e), { [field]: val }) : e);
|
|
103
|
+
this.emitHistoryChange(updated);
|
|
104
|
+
};
|
|
105
|
+
const removeEntry = (i) => {
|
|
106
|
+
this.emitHistoryChange(this.historyEntries.filter((_, idx) => idx !== i));
|
|
107
|
+
};
|
|
108
|
+
const addEntry = () => {
|
|
109
|
+
this.emitHistoryChange([...this.historyEntries, { value: '', until: '' }]);
|
|
110
|
+
};
|
|
111
|
+
return (h("div", { class: "mrd-field__history-editor" }, this.historyEntries.length > 0 && (h("span", { class: "mrd-field__history-editor-label" }, t('history_badge_tooltip', locale))), this.historyEntries.map((entry, i) => (h("div", { key: String(i), class: "mrd-field__history-editor-row" }, h("input", { class: "mrd-field__history-editor-value", type: valueType, value: entry.value, onInput: (e) => updateEntry(i, 'value', e.target.value) }), h("span", { class: "mrd-field__history-editor-sep" }, t('history_until', locale)), h("input", { class: "mrd-field__history-editor-until", type: "date", value: entry.until, onInput: (e) => updateEntry(i, 'until', e.target.value) }), h("button", { type: "button", class: "mrd-field__history-editor-remove", onClick: () => removeEntry(i), "aria-label": t('remove', locale) }, h("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true" }, h("path", { "fill-rule": "evenodd", d: "M8.75 1A2.75 2.75 0 006 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 10.23 1.482l.149-.022.841 10.518A2.75 2.75 0 007.596 19h4.807a2.75 2.75 0 002.742-2.53l.841-10.52.149.023a.75.75 0 00.23-1.482A41.03 41.03 0 0014 4.193V3.75A2.75 2.75 0 0011.25 1h-2.5zM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4zM8.58 7.72a.75.75 0 00-1.5.06l.3 7.5a.75.75 0 101.5-.06l-.3-7.5zm4.34.06a.75.75 0 10-1.5-.06l-.3 7.5a.75.75 0 101.5.06l.3-7.5z", "clip-rule": "evenodd" })))))), h("button", { type: "button", class: "mrd-field__history-editor-add", onClick: addEntry }, "+ ", t('add', locale))));
|
|
112
|
+
}
|
|
113
|
+
renderLeafField(displayValue) {
|
|
114
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
115
|
+
const { item, locale } = this;
|
|
36
116
|
const commonProps = {
|
|
37
117
|
name: item.name,
|
|
38
118
|
label: item.label,
|
|
39
119
|
required: item.required,
|
|
40
|
-
disabled: (
|
|
120
|
+
disabled: (_a = item.disabled) !== null && _a !== void 0 ? _a : false,
|
|
41
121
|
locale,
|
|
42
122
|
onMrdChange: this.handleChange,
|
|
43
123
|
onMrdBlur: this.handleBlur,
|
|
44
124
|
};
|
|
45
125
|
switch (item.dataType) {
|
|
46
126
|
case ClientLayoutItemFieldDataType.TEXT:
|
|
47
|
-
return (h(
|
|
127
|
+
return (h("mrd-text-field", Object.assign({}, commonProps, { value: (_b = displayValue) !== null && _b !== void 0 ? _b : '', placeholder: (_c = item.placeholder) !== null && _c !== void 0 ? _c : '' })));
|
|
48
128
|
case ClientLayoutItemFieldDataType.TEXTBLOCK:
|
|
49
|
-
return (h(
|
|
129
|
+
return (h("mrd-textarea-field", Object.assign({}, commonProps, { value: (_d = displayValue) !== null && _d !== void 0 ? _d : '', placeholder: (_e = item.placeholder) !== null && _e !== void 0 ? _e : '' })));
|
|
50
130
|
case ClientLayoutItemFieldDataType.INTEGER:
|
|
51
131
|
case ClientLayoutItemFieldDataType.DECIMAL:
|
|
52
132
|
case ClientLayoutItemFieldDataType.PERCENTAGE:
|
|
53
|
-
return (h(
|
|
133
|
+
return (h("mrd-number-field", Object.assign({}, commonProps, { value: (_f = displayValue) !== null && _f !== void 0 ? _f : null, dataType: item.dataType, decimalPrecision: (_g = item.decimalPrecision) !== null && _g !== void 0 ? _g : 2, placeholder: (_h = item.placeholder) !== null && _h !== void 0 ? _h : '' })));
|
|
54
134
|
case ClientLayoutItemFieldDataType.CURRENCY:
|
|
55
|
-
return (h(
|
|
135
|
+
return (h("mrd-currency-field", Object.assign({}, commonProps, { value: (_j = displayValue) !== null && _j !== void 0 ? _j : { amount: null, currency: (_k = item.currencyCode) !== null && _k !== void 0 ? _k : 'EUR' } })));
|
|
56
136
|
case ClientLayoutItemFieldDataType.BOOLEAN:
|
|
57
|
-
return (h(
|
|
137
|
+
return (h("mrd-boolean-field", Object.assign({}, commonProps, { value: (_l = displayValue) !== null && _l !== void 0 ? _l : false })));
|
|
58
138
|
case ClientLayoutItemFieldDataType.DATE:
|
|
59
|
-
return (h(
|
|
139
|
+
return (h("mrd-date-field", Object.assign({}, commonProps, { value: (_m = displayValue) !== null && _m !== void 0 ? _m : '' })));
|
|
60
140
|
case ClientLayoutItemFieldDataType.DATETIME:
|
|
61
|
-
return (h(
|
|
141
|
+
return (h("mrd-datetime-field", Object.assign({}, commonProps, { value: (_o = displayValue) !== null && _o !== void 0 ? _o : '' })));
|
|
62
142
|
case ClientLayoutItemFieldDataType.TIME:
|
|
63
|
-
return (h(
|
|
143
|
+
return (h("mrd-time-field", Object.assign({}, commonProps, { value: (_p = displayValue) !== null && _p !== void 0 ? _p : '' })));
|
|
64
144
|
case ClientLayoutItemFieldDataType.EMAIL:
|
|
65
|
-
return (h(
|
|
145
|
+
return (h("mrd-email-field", Object.assign({}, commonProps, { value: (_q = displayValue) !== null && _q !== void 0 ? _q : '', placeholder: (_r = item.placeholder) !== null && _r !== void 0 ? _r : '' })));
|
|
66
146
|
case ClientLayoutItemFieldDataType.HYPERLINK:
|
|
67
|
-
return (h(
|
|
147
|
+
return (h("mrd-hyperlink-field", Object.assign({}, commonProps, { value: (_s = displayValue) !== null && _s !== void 0 ? _s : '', placeholder: (_t = item.placeholder) !== null && _t !== void 0 ? _t : '' })));
|
|
68
148
|
case ClientLayoutItemFieldDataType.LIST:
|
|
69
|
-
return (h(
|
|
149
|
+
return (h("mrd-list-field", Object.assign({}, commonProps, { value: (_u = displayValue) !== null && _u !== void 0 ? _u : '', multiple: (_v = item.multiple) !== null && _v !== void 0 ? _v : false, listItems: (_w = item.listItems) !== null && _w !== void 0 ? _w : [] })));
|
|
70
150
|
case ClientLayoutItemFieldDataType.FILE:
|
|
71
|
-
return (h(
|
|
151
|
+
return (h("mrd-file-field", Object.assign({}, commonProps, { value: displayValue, accept: (_x = item.accept) !== null && _x !== void 0 ? _x : '', maxSize: (_y = item.maxSize) !== null && _y !== void 0 ? _y : 0, onMrdUpload: this.handleUpload })));
|
|
72
152
|
case ClientLayoutItemFieldDataType.IMAGE:
|
|
73
|
-
return (h(
|
|
153
|
+
return (h("mrd-image-field", Object.assign({}, commonProps, { value: displayValue, accept: (_z = item.accept) !== null && _z !== void 0 ? _z : 'image/*', maxSize: (_0 = item.maxSize) !== null && _0 !== void 0 ? _0 : 0, onMrdUpload: this.handleUpload })));
|
|
74
154
|
case ClientLayoutItemFieldDataType.LONGTEXT:
|
|
75
|
-
return (h(
|
|
76
|
-
case ClientLayoutItemFieldDataType.
|
|
77
|
-
return h(
|
|
155
|
+
return (h("mrd-longtext-field", Object.assign({}, commonProps, { value: (_1 = displayValue) !== null && _1 !== void 0 ? _1 : '', placeholder: (_2 = item.placeholder) !== null && _2 !== void 0 ? _2 : '' })));
|
|
156
|
+
case ClientLayoutItemFieldDataType.SECRET:
|
|
157
|
+
return (h("mrd-secret-field", Object.assign({}, commonProps, { value: (_3 = displayValue) !== null && _3 !== void 0 ? _3 : '', placeholder: (_4 = item.placeholder) !== null && _4 !== void 0 ? _4 : '' })));
|
|
78
158
|
default:
|
|
79
|
-
return
|
|
159
|
+
return null;
|
|
80
160
|
}
|
|
81
161
|
}
|
|
162
|
+
render() {
|
|
163
|
+
var _a, _b, _c, _d, _e, _f;
|
|
164
|
+
const { item, locale, value } = this;
|
|
165
|
+
if (item.type === ClientLayoutItemType.RELATION) {
|
|
166
|
+
return (h(Host, null, h("mrd-relation-field", { name: item.name, label: item.label, required: item.required, disabled: (_a = item.disabled) !== null && _a !== void 0 ? _a : false, locale: locale, relatedClass: item.relatedClass, mostSignificantClass: (_b = item.mostSignificantClass) !== null && _b !== void 0 ? _b : '', displayType: (_c = item.displayType) !== null && _c !== void 0 ? _c : ClientLayoutItemRelationDisplayType.SEARCH, editBehavior: (_d = item.editBehavior) !== null && _d !== void 0 ? _d : null, commonRelation: item.commonRelation, multiple: (_e = item.multiple) !== null && _e !== void 0 ? _e : false, dropdownValues: (_f = item.dropdownValues) !== null && _f !== void 0 ? _f : [], value: value, onMrdChange: this.handleChange, onMrdBlur: this.handleBlur, onMrdSearch: this.handleSearch, onMrdFetchAll: this.handleFetchAll })));
|
|
167
|
+
}
|
|
168
|
+
if (item.type !== ClientLayoutItemType.FIELD) {
|
|
169
|
+
return h(Host, null);
|
|
170
|
+
}
|
|
171
|
+
const displayValue = this.getDisplayValue();
|
|
172
|
+
return (h(Host, null, h("div", { class: "mrd-field__inner" }, this.renderLeafField(displayValue), this.renderHistoryEditor())));
|
|
173
|
+
}
|
|
82
174
|
static get is() { return "mrd-field"; }
|
|
83
175
|
static get encapsulation() { return "scoped"; }
|
|
176
|
+
static get originalStyleUrls() {
|
|
177
|
+
return {
|
|
178
|
+
"$": ["mrd-field.scss"]
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
static get styleUrls() {
|
|
182
|
+
return {
|
|
183
|
+
"$": ["mrd-field.css"]
|
|
184
|
+
};
|
|
185
|
+
}
|
|
84
186
|
static get properties() {
|
|
85
187
|
return {
|
|
86
188
|
"item": {
|
|
@@ -146,6 +248,12 @@ export class MrdField {
|
|
|
146
248
|
}
|
|
147
249
|
};
|
|
148
250
|
}
|
|
251
|
+
static get states() {
|
|
252
|
+
return {
|
|
253
|
+
"historyEntries": {},
|
|
254
|
+
"currentValue": {}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
149
257
|
static get events() {
|
|
150
258
|
return [{
|
|
151
259
|
"method": "mrdChange",
|
|
@@ -229,4 +337,11 @@ export class MrdField {
|
|
|
229
337
|
}
|
|
230
338
|
}];
|
|
231
339
|
}
|
|
340
|
+
static get elementRef() { return "el"; }
|
|
341
|
+
static get watchers() {
|
|
342
|
+
return [{
|
|
343
|
+
"propName": "value",
|
|
344
|
+
"methodName": "valueChanged"
|
|
345
|
+
}];
|
|
346
|
+
}
|
|
232
347
|
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.mrd-field__inner {
|
|
6
|
+
display: block;
|
|
7
|
+
width: 100%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.mrd-field__history-editor {
|
|
11
|
+
margin-top: var(--mrd-space-2);
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: var(--mrd-space-1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.mrd-field__history-editor-label {
|
|
18
|
+
font-family: var(--mrd-font-family);
|
|
19
|
+
font-size: var(--mrd-font-size-xs);
|
|
20
|
+
font-weight: var(--mrd-font-weight-medium);
|
|
21
|
+
color: var(--mrd-color-neutral-500);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.mrd-field__history-editor-row {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: var(--mrd-space-2);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.mrd-field__history-editor-sep {
|
|
31
|
+
flex-shrink: 0;
|
|
32
|
+
font-family: var(--mrd-font-family);
|
|
33
|
+
font-size: var(--mrd-font-size-xs);
|
|
34
|
+
color: var(--mrd-color-neutral-500);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.mrd-field__history-editor-value {
|
|
38
|
+
flex: 1 1 0;
|
|
39
|
+
min-width: 0;
|
|
40
|
+
height: var(--mrd-input-height);
|
|
41
|
+
padding: 0 var(--mrd-space-3);
|
|
42
|
+
font-family: var(--mrd-font-family);
|
|
43
|
+
font-size: var(--mrd-font-size-sm);
|
|
44
|
+
color: var(--mrd-color-neutral-800);
|
|
45
|
+
background-color: var(--mrd-color-white);
|
|
46
|
+
border: var(--mrd-border-width) solid var(--mrd-border-color);
|
|
47
|
+
border-radius: var(--mrd-border-radius-md);
|
|
48
|
+
outline: none;
|
|
49
|
+
transition: border-color var(--mrd-transition-fast), box-shadow var(--mrd-transition-fast);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.mrd-field__history-editor-value:focus {
|
|
53
|
+
border-color: var(--mrd-color-primary);
|
|
54
|
+
box-shadow: var(--mrd-shadow-focus);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.mrd-field__history-editor-until {
|
|
58
|
+
flex: 0 0 10rem;
|
|
59
|
+
height: var(--mrd-input-height);
|
|
60
|
+
padding: 0 var(--mrd-space-3);
|
|
61
|
+
font-family: var(--mrd-font-family);
|
|
62
|
+
font-size: var(--mrd-font-size-sm);
|
|
63
|
+
color: var(--mrd-color-neutral-800);
|
|
64
|
+
background-color: var(--mrd-color-white);
|
|
65
|
+
border: var(--mrd-border-width) solid var(--mrd-border-color);
|
|
66
|
+
border-radius: var(--mrd-border-radius-md);
|
|
67
|
+
outline: none;
|
|
68
|
+
transition: border-color var(--mrd-transition-fast), box-shadow var(--mrd-transition-fast);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.mrd-field__history-editor-until:focus {
|
|
72
|
+
border-color: var(--mrd-color-primary);
|
|
73
|
+
box-shadow: var(--mrd-shadow-focus);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.mrd-field__history-editor-remove {
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
flex-shrink: 0;
|
|
81
|
+
width: 2rem;
|
|
82
|
+
height: 2rem;
|
|
83
|
+
padding: 0;
|
|
84
|
+
background: transparent;
|
|
85
|
+
border: none;
|
|
86
|
+
border-radius: var(--mrd-border-radius-sm);
|
|
87
|
+
color: var(--mrd-color-neutral-400);
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
transition: color var(--mrd-transition-fast), background-color var(--mrd-transition-fast);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.mrd-field__history-editor-remove:hover {
|
|
93
|
+
color: var(--mrd-color-danger);
|
|
94
|
+
background-color: var(--mrd-color-danger-light);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.mrd-field__history-editor-remove svg {
|
|
98
|
+
width: 1rem;
|
|
99
|
+
height: 1rem;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.mrd-field__history-editor-add {
|
|
103
|
+
align-self: flex-start;
|
|
104
|
+
padding: var(--mrd-space-1) var(--mrd-space-3);
|
|
105
|
+
font-family: var(--mrd-font-family);
|
|
106
|
+
font-size: var(--mrd-font-size-xs);
|
|
107
|
+
font-weight: var(--mrd-font-weight-medium);
|
|
108
|
+
color: var(--mrd-color-primary);
|
|
109
|
+
background: transparent;
|
|
110
|
+
border: var(--mrd-border-width) solid var(--mrd-color-primary);
|
|
111
|
+
border-radius: var(--mrd-border-radius-md);
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
transition: background-color var(--mrd-transition-fast), color var(--mrd-transition-fast);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.mrd-field__history-editor-add:hover {
|
|
117
|
+
background-color: var(--mrd-color-primary-light);
|
|
118
|
+
}
|
|
@@ -261,10 +261,10 @@ export class MrdForm {
|
|
|
261
261
|
continue;
|
|
262
262
|
const name = item.name;
|
|
263
263
|
if (item.type === ClientLayoutItemType.FIELD) {
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
264
|
+
const rawValue = this.formValues[name];
|
|
265
|
+
if (rawValue instanceof File)
|
|
266
266
|
continue;
|
|
267
|
-
const current = this.normalizeFieldValue(
|
|
267
|
+
const current = this.normalizeFieldValue(rawValue);
|
|
268
268
|
const initial = this.normalizeFieldValue(this.initialValues[name]);
|
|
269
269
|
if (this.deepEqual(current, initial))
|
|
270
270
|
continue;
|
|
@@ -10,28 +10,60 @@ export class MrdHyperlinkField {
|
|
|
10
10
|
this.required = false;
|
|
11
11
|
this.disabled = false;
|
|
12
12
|
this.locale = navigator.language;
|
|
13
|
+
this.internalHref = '';
|
|
14
|
+
this.internalName = '';
|
|
13
15
|
this.error = '';
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
this.mrdChange.emit({ name: this.name, value:
|
|
16
|
+
this.handleHrefInput = (e) => {
|
|
17
|
+
this.internalHref = e.target.value;
|
|
18
|
+
this.mrdChange.emit({ name: this.name, value: this.buildValue() });
|
|
17
19
|
};
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
this.handleNameInput = (e) => {
|
|
21
|
+
this.internalName = e.target.value;
|
|
22
|
+
this.mrdChange.emit({ name: this.name, value: this.buildValue() });
|
|
23
|
+
};
|
|
24
|
+
this.handleBlur = () => {
|
|
25
|
+
if (this.required && !validateRequired(this.internalHref)) {
|
|
21
26
|
this.error = t('required', this.locale);
|
|
22
27
|
}
|
|
23
|
-
else if (
|
|
28
|
+
else if (this.internalHref && !validateUrl(this.internalHref)) {
|
|
24
29
|
this.error = t('invalid_url', this.locale);
|
|
25
30
|
}
|
|
26
31
|
else {
|
|
27
32
|
this.error = '';
|
|
28
33
|
}
|
|
29
|
-
this.mrdBlur.emit({ name: this.name, value:
|
|
34
|
+
this.mrdBlur.emit({ name: this.name, value: this.buildValue() });
|
|
30
35
|
};
|
|
31
36
|
}
|
|
37
|
+
componentWillLoad() {
|
|
38
|
+
this.parseValue(this.value);
|
|
39
|
+
}
|
|
40
|
+
valueChanged(val) {
|
|
41
|
+
this.parseValue(val);
|
|
42
|
+
}
|
|
43
|
+
parseValue(val) {
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
if (val !== null && val !== undefined && typeof val === 'object' && 'href' in val) {
|
|
46
|
+
this.internalHref = (_a = val.href) !== null && _a !== void 0 ? _a : '';
|
|
47
|
+
this.internalName = (_b = val.name) !== null && _b !== void 0 ? _b : '';
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.internalHref = (_c = val) !== null && _c !== void 0 ? _c : '';
|
|
51
|
+
this.internalName = '';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
buildValue() {
|
|
55
|
+
return this.internalName.trim()
|
|
56
|
+
? { href: this.internalHref, name: this.internalName }
|
|
57
|
+
: { href: this.internalHref };
|
|
58
|
+
}
|
|
32
59
|
render() {
|
|
33
60
|
const hasError = !!this.error;
|
|
34
|
-
|
|
61
|
+
if (this.disabled) {
|
|
62
|
+
return (h(Host, null, h("div", { class: "mrd-hyperlink-field" }, this.label && h("span", { class: "mrd-hyperlink-field__label" }, this.label), this.internalHref
|
|
63
|
+
? h("a", { class: "mrd-hyperlink-field__link", href: this.internalHref, target: "_blank", rel: "noopener noreferrer" }, this.internalName || this.internalHref)
|
|
64
|
+
: h("span", { class: "mrd-hyperlink-field__empty" }, "\u2014"))));
|
|
65
|
+
}
|
|
66
|
+
return (h(Host, null, h("div", { class: "mrd-hyperlink-field" }, this.label && (h("label", { class: `mrd-hyperlink-field__label${this.required ? ' mrd-hyperlink-field__label--required' : ''}` }, this.label)), h("input", { class: `mrd-hyperlink-field__input${hasError ? ' mrd-hyperlink-field__input--error' : ''}`, 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 }), hasError && h("span", { class: "mrd-hyperlink-field__error" }, this.error))));
|
|
35
67
|
}
|
|
36
68
|
static get is() { return "mrd-hyperlink-field"; }
|
|
37
69
|
static get encapsulation() { return "scoped"; }
|
|
@@ -91,9 +123,16 @@ export class MrdHyperlinkField {
|
|
|
91
123
|
"type": "string",
|
|
92
124
|
"mutable": false,
|
|
93
125
|
"complexType": {
|
|
94
|
-
"original": "string",
|
|
95
|
-
"resolved": "string",
|
|
96
|
-
"references": {
|
|
126
|
+
"original": "HyperlinkValue | string",
|
|
127
|
+
"resolved": "HyperlinkValue | string",
|
|
128
|
+
"references": {
|
|
129
|
+
"HyperlinkValue": {
|
|
130
|
+
"location": "import",
|
|
131
|
+
"path": "../../types/client-layout",
|
|
132
|
+
"id": "src/types/client-layout.ts::HyperlinkValue",
|
|
133
|
+
"referenceLocation": "HyperlinkValue"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
97
136
|
},
|
|
98
137
|
"required": false,
|
|
99
138
|
"optional": false,
|
|
@@ -191,6 +230,8 @@ export class MrdHyperlinkField {
|
|
|
191
230
|
}
|
|
192
231
|
static get states() {
|
|
193
232
|
return {
|
|
233
|
+
"internalHref": {},
|
|
234
|
+
"internalName": {},
|
|
194
235
|
"error": {}
|
|
195
236
|
};
|
|
196
237
|
}
|
|
@@ -206,9 +247,16 @@ export class MrdHyperlinkField {
|
|
|
206
247
|
"text": ""
|
|
207
248
|
},
|
|
208
249
|
"complexType": {
|
|
209
|
-
"original": "{ name: string; value:
|
|
210
|
-
"resolved": "{ name: string; value:
|
|
211
|
-
"references": {
|
|
250
|
+
"original": "{ name: string; value: HyperlinkValue }",
|
|
251
|
+
"resolved": "{ name: string; value: HyperlinkValue; }",
|
|
252
|
+
"references": {
|
|
253
|
+
"HyperlinkValue": {
|
|
254
|
+
"location": "import",
|
|
255
|
+
"path": "../../types/client-layout",
|
|
256
|
+
"id": "src/types/client-layout.ts::HyperlinkValue",
|
|
257
|
+
"referenceLocation": "HyperlinkValue"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
212
260
|
}
|
|
213
261
|
}, {
|
|
214
262
|
"method": "mrdBlur",
|
|
@@ -221,10 +269,23 @@ export class MrdHyperlinkField {
|
|
|
221
269
|
"text": ""
|
|
222
270
|
},
|
|
223
271
|
"complexType": {
|
|
224
|
-
"original": "{ name: string; value:
|
|
225
|
-
"resolved": "{ name: string; value:
|
|
226
|
-
"references": {
|
|
272
|
+
"original": "{ name: string; value: HyperlinkValue }",
|
|
273
|
+
"resolved": "{ name: string; value: HyperlinkValue; }",
|
|
274
|
+
"references": {
|
|
275
|
+
"HyperlinkValue": {
|
|
276
|
+
"location": "import",
|
|
277
|
+
"path": "../../types/client-layout",
|
|
278
|
+
"id": "src/types/client-layout.ts::HyperlinkValue",
|
|
279
|
+
"referenceLocation": "HyperlinkValue"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
227
282
|
}
|
|
228
283
|
}];
|
|
229
284
|
}
|
|
285
|
+
static get watchers() {
|
|
286
|
+
return [{
|
|
287
|
+
"propName": "value",
|
|
288
|
+
"methodName": "valueChanged"
|
|
289
|
+
}];
|
|
290
|
+
}
|
|
230
291
|
}
|
|
@@ -62,6 +62,28 @@
|
|
|
62
62
|
box-shadow: var(--mrd-shadow-focus-error);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
.mrd-hyperlink-field__input--name {
|
|
66
|
+
margin-top: var(--mrd-space-1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.mrd-hyperlink-field__link {
|
|
70
|
+
font-family: var(--mrd-font-family);
|
|
71
|
+
font-size: var(--mrd-font-size-base);
|
|
72
|
+
color: var(--mrd-color-primary);
|
|
73
|
+
text-decoration: underline;
|
|
74
|
+
word-break: break-all;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.mrd-hyperlink-field__link:hover {
|
|
78
|
+
opacity: 0.8;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.mrd-hyperlink-field__empty {
|
|
82
|
+
font-family: var(--mrd-font-family);
|
|
83
|
+
font-size: var(--mrd-font-size-base);
|
|
84
|
+
color: var(--mrd-color-neutral-400);
|
|
85
|
+
}
|
|
86
|
+
|
|
65
87
|
.mrd-hyperlink-field__error {
|
|
66
88
|
font-family: var(--mrd-font-family);
|
|
67
89
|
font-size: var(--mrd-error-font-size);
|
|
@@ -99,7 +99,7 @@ export class MrdImageField {
|
|
|
99
99
|
hasError ? 'mrd-image-field__zone--error' : '',
|
|
100
100
|
this.disabled || this.uploading ? 'mrd-image-field__zone--disabled' : '',
|
|
101
101
|
].filter(Boolean).join(' ');
|
|
102
|
-
return (h(Host, { key: '
|
|
102
|
+
return (h(Host, { key: '71be4c1df559cff87280cac30be58beab3149064' }, h("div", { key: '9d0811d87068ce258aca9b2c5223a5594af9f6a3', class: "mrd-image-field" }, this.label && (h("label", { key: '63e129db968a2edfcc04fcac466d908ba4715158', class: `mrd-image-field__label${this.required ? ' mrd-image-field__label--required' : ''}` }, this.label)), h("div", { key: 'c7e560ad4dda43499707a2d1771a8eb561653a1b', class: zoneClass, onClick: this.handleZoneClick, onDragOver: this.handleDragOver, onDragLeave: this.handleDragLeave, onDrop: this.handleDrop }, h("input", { key: 'd325ee1aa3baccd689cc579e4cfa21abe977a575', 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: 'b0442d6f5c07ef22443194b3f1a95d2dfc409c4e', class: "mrd-image-field__error" }, this.error))));
|
|
103
103
|
}
|
|
104
104
|
static get is() { return "mrd-image-field"; }
|
|
105
105
|
static get encapsulation() { return "scoped"; }
|