@schukai/monster 3.69.2 → 3.71.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/CHANGELOG.md +29 -4
- package/package.json +1 -1
- package/source/components/datatable/dataset.mjs +278 -202
- package/source/components/datatable/datasource/dom.mjs +1 -1
- package/source/components/datatable/datasource/rest.mjs +410 -404
- package/source/components/datatable/filter.mjs +1 -0
- package/source/components/datatable/save-button.mjs +1 -9
- package/source/components/datatable/style/datatable.pcss +1 -1
- package/source/components/datatable/style/filter-controls-defaults.pcss +1 -1
- package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +8 -17
- package/source/components/form/context-error.mjs +2 -0
- package/source/components/form/context-help.mjs +1 -0
- package/source/components/form/field-set.mjs +222 -225
- package/source/components/form/form.mjs +185 -545
- package/source/components/form/select.mjs +24 -9
- package/source/components/form/style/field-set.pcss +84 -7
- package/source/components/form/style/form.pcss +5 -3
- package/source/components/form/style/select.pcss +5 -4
- package/source/components/form/stylesheet/field-set.mjs +7 -14
- package/source/components/form/stylesheet/form.mjs +8 -17
- package/source/components/form/stylesheet/select.mjs +7 -14
- package/source/components/layout/style/collapse.pcss +0 -2
- package/source/components/layout/stylesheet/collapse.mjs +7 -14
- package/source/components/style/form.pcss +66 -3
- package/source/components/style/mixin/property.pcss +8 -1
- package/source/components/style/typography.pcss +4 -12
- package/source/components/stylesheet/form.mjs +8 -17
- package/source/components/stylesheet/mixin/form.mjs +7 -16
- package/source/components/stylesheet/mixin/property.mjs +6 -13
- package/source/components/stylesheet/typography.mjs +7 -16
- package/source/data/datasource/server/restapi.mjs +191 -180
- package/source/data/datasource/server.mjs +118 -74
- package/source/data/diff.mjs +1 -1
- package/source/dom/customelement.mjs +4 -0
- package/source/dom/updater.mjs +1 -1
- package/source/types/tokenlist.mjs +2 -2
- package/test/cases/components/form/form.mjs +1 -182
- package/test/cases/components/host/details.mjs +1 -1
- package/test/cases/components/host/host.mjs +1 -1
- package/test/cases/components/host/overlay.mjs +1 -1
- package/test/cases/data/diff.mjs +37 -0
- package/test/cases/dom/customcontrol.mjs +1 -1
- package/test/cases/dom/customelement.mjs +2 -2
- package/source/components/style/mixin/form.pcss +0 -242
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
* SPDX-License-Identifier: AGPL-3.0
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
15
|
+
import {internalSymbol, instanceSymbol} from "../../../constants.mjs";
|
|
16
|
+
import {isObject, isFunction, isArray} from "../../../types/is.mjs";
|
|
17
|
+
import {diff} from "../../diff.mjs";
|
|
18
|
+
import {Server} from "../server.mjs";
|
|
19
|
+
import {WriteError} from "./restapi/writeerror.mjs";
|
|
20
|
+
import {DataFetchError} from "./restapi/data-fetch-error.mjs";
|
|
20
21
|
|
|
21
|
-
export {
|
|
22
|
+
export {RestAPI};
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* @type {symbol}
|
|
@@ -27,9 +28,10 @@ export { RestAPI };
|
|
|
27
28
|
* @since 3.12.0
|
|
28
29
|
*/
|
|
29
30
|
const rawDataSymbol = Symbol.for(
|
|
30
|
-
|
|
31
|
+
"@schukai/monster/data/datasource/server/restapi/rawdata",
|
|
31
32
|
);
|
|
32
33
|
|
|
34
|
+
|
|
33
35
|
/**
|
|
34
36
|
* The RestAPI is a class that enables a REST API server.
|
|
35
37
|
*
|
|
@@ -41,138 +43,145 @@ const rawDataSymbol = Symbol.for(
|
|
|
41
43
|
* @summary The RestAPI is a class that binds a REST API server.
|
|
42
44
|
*/
|
|
43
45
|
class RestAPI extends Server {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} [options] options contains definitions for the datasource.
|
|
49
|
+
*/
|
|
50
|
+
constructor(options) {
|
|
51
|
+
super();
|
|
52
|
+
|
|
53
|
+
if (isObject(options)) {
|
|
54
|
+
this.setOptions(options);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* This method is called by the `instanceof` operator.
|
|
60
|
+
* @returns {symbol}
|
|
61
|
+
* @since 2.1.0
|
|
62
|
+
*/
|
|
63
|
+
static get [instanceSymbol]() {
|
|
64
|
+
return Symbol.for("@schukai/monster/data/datasource/server/restapi");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @property {Object} write={} Options
|
|
69
|
+
* @property {Object} write.init={} An options object containing any custom settings that you want to apply to the request. The parameters are identical to those of the {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request|Request constructor}
|
|
70
|
+
* @property {string} write.init.method=POST
|
|
71
|
+
* @property {Object} write.init.headers Object containing any custom headers that you want to apply to the request.
|
|
72
|
+
* @property {string} write.responseCallback Callback function to be executed after the request has been completed.
|
|
73
|
+
* @property {string} write.acceptedStatus=[200,201]
|
|
74
|
+
* @property {string} write.url URL
|
|
75
|
+
* @property {Object} write.mapping the mapping is applied before writing.
|
|
76
|
+
* @property {String} write.mapping.transformer Transformer to select the appropriate entries
|
|
77
|
+
* @property {Monster.Data.Datasource~exampleCallback[]} write.mapping.callback with the help of the callback, the structures can be adjusted before writing.
|
|
78
|
+
* @property {Object} write.report
|
|
79
|
+
* @property {String} write.report.path Path to validations
|
|
80
|
+
* @property {Object} write.partial
|
|
81
|
+
* @property {Function} write.partial.callback Callback function to be executed after the request has been completed. (obj, diffResult) => obj
|
|
82
|
+
* @property {Object} write.sheathing
|
|
83
|
+
* @property {Object} write.sheathing.object Object to be wrapped
|
|
84
|
+
* @property {string} write.sheathing.path Path to the data
|
|
85
|
+
* @property {Object} read={} Options
|
|
86
|
+
* @property {Object} read.init={} An options object containing any custom settings that you want to apply to the request. The parameters are identical to those of the {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request|Request constructor}
|
|
87
|
+
* @property {string} read.init.method=GET
|
|
88
|
+
* @property {string} read.acceptedStatus=[200]
|
|
89
|
+
* @property {string} read.url URL
|
|
90
|
+
* @property {Object} read.mapping the mapping is applied after reading.
|
|
91
|
+
* @property {String} read.mapping.transformer Transformer to select the appropriate entries
|
|
92
|
+
* @property {Monster.Data.Datasource~exampleCallback[]} read.mapping.callback with the help of the callback, the structures can be adjusted after reading.
|
|
93
|
+
*/
|
|
94
|
+
get defaults() {
|
|
95
|
+
return Object.assign({}, super.defaults, {
|
|
96
|
+
write: {
|
|
97
|
+
init: {
|
|
98
|
+
method: "POST",
|
|
99
|
+
},
|
|
100
|
+
responseCallback: undefined,
|
|
101
|
+
acceptedStatus: [200, 201],
|
|
102
|
+
url: null,
|
|
103
|
+
mapping: {
|
|
104
|
+
transformer: undefined,
|
|
105
|
+
callbacks: [],
|
|
106
|
+
},
|
|
107
|
+
sheathing: {
|
|
108
|
+
object: undefined,
|
|
109
|
+
path: undefined,
|
|
110
|
+
},
|
|
111
|
+
report: {
|
|
112
|
+
path: undefined,
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
partial: {
|
|
116
|
+
callback: null,
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
read: {
|
|
120
|
+
init: {
|
|
121
|
+
method: "GET",
|
|
122
|
+
},
|
|
123
|
+
responseCallback: undefined,
|
|
124
|
+
acceptedStatus: [200],
|
|
125
|
+
url: null,
|
|
126
|
+
mapping: {
|
|
127
|
+
transformer: undefined,
|
|
128
|
+
callbacks: [],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @return {Promise}
|
|
136
|
+
* @throws {Error} the options does not contain a valid json definition
|
|
137
|
+
* @throws {TypeError} value is not a object
|
|
138
|
+
* @throws {Error} the data cannot be read
|
|
139
|
+
*/
|
|
140
|
+
read() {
|
|
141
|
+
let init = this.getOption("read.init");
|
|
142
|
+
if (!isObject(init)) init = {};
|
|
143
|
+
if (!init["method"]) init["method"] = "GET";
|
|
144
|
+
|
|
145
|
+
let callback = this.getOption("read.responseCallback");
|
|
146
|
+
if (!callback) {
|
|
147
|
+
callback = (obj) => {
|
|
148
|
+
this.set(this.transformServerPayload.call(this, obj));
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return fetchData.call(this, init, "read", callback);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @return {Promise}
|
|
157
|
+
* @throws {WriteError} the data cannot be written
|
|
158
|
+
*/
|
|
159
|
+
write() {
|
|
160
|
+
let init = this.getOption("write.init");
|
|
161
|
+
if (!isObject(init)) init = {};
|
|
162
|
+
if (typeof init["headers"] !== "object") {
|
|
163
|
+
init["headers"] = {
|
|
164
|
+
"Content-Type": "application/json",
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (!init["method"]) init["method"] = "POST";
|
|
168
|
+
|
|
169
|
+
const obj = this.prepareServerPayload(this.get());
|
|
170
|
+
init["body"] = JSON.stringify(obj);
|
|
171
|
+
|
|
172
|
+
const callback = this.getOption("write.responseCallback");
|
|
173
|
+
return fetchData.call(this, init, "write", callback);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @return {RestAPI}
|
|
178
|
+
*/
|
|
179
|
+
getClone() {
|
|
180
|
+
return new RestAPI(
|
|
181
|
+
this[internalSymbol].getRealSubject()["options"].read,
|
|
182
|
+
this[internalSymbol].getRealSubject()["options"].write,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
176
185
|
}
|
|
177
186
|
|
|
178
187
|
/**
|
|
@@ -183,45 +192,47 @@ class RestAPI extends Server {
|
|
|
183
192
|
* @returns {Promise<string>}
|
|
184
193
|
*/
|
|
185
194
|
function fetchData(init, key, callback) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
195
|
+
let response;
|
|
196
|
+
|
|
197
|
+
return fetch(this.getOption(`${key}.url`), init)
|
|
198
|
+
.then((resp) => {
|
|
199
|
+
response = resp;
|
|
200
|
+
|
|
201
|
+
const acceptedStatus = this.getOption(`${key}.acceptedStatus`, [200]).map(Number);
|
|
202
|
+
|
|
203
|
+
if (acceptedStatus.indexOf(resp.status) === -1) {
|
|
204
|
+
throw new DataFetchError(
|
|
205
|
+
`the response does not contain an accepted status (actual: ${resp.status}).`,
|
|
206
|
+
response,
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return resp.text();
|
|
211
|
+
})
|
|
212
|
+
.then((body) => {
|
|
213
|
+
let obj;
|
|
214
|
+
|
|
215
|
+
try {
|
|
216
|
+
obj = JSON.parse(body);
|
|
217
|
+
|
|
218
|
+
response[rawDataSymbol] = obj;
|
|
219
|
+
} catch (e) {
|
|
220
|
+
if (body.length > 100) {
|
|
221
|
+
body = `${body.substring(0, 97)}...`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
throw new DataFetchError(
|
|
225
|
+
`the response does not contain a valid json (actual: ${body}).`,
|
|
226
|
+
response,
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (callback && isFunction(callback)) {
|
|
231
|
+
callback(obj);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return response;
|
|
235
|
+
}).catch((e) => {
|
|
236
|
+
throw e;
|
|
237
|
+
});
|
|
227
238
|
}
|
|
@@ -12,13 +12,21 @@
|
|
|
12
12
|
* SPDX-License-Identifier: AGPL-3.0
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
import { isObject
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
15
|
+
import {instanceSymbol} from "../../constants.mjs";
|
|
16
|
+
import {isArray, isFunction, isObject} from "../../types/is.mjs";
|
|
17
|
+
import {Datasource} from "../datasource.mjs";
|
|
18
|
+
import {diff} from "../diff.mjs";
|
|
19
|
+
import {Pathfinder} from "../pathfinder.mjs";
|
|
20
|
+
import {Pipe} from "../pipe.mjs";
|
|
20
21
|
|
|
21
|
-
export {
|
|
22
|
+
export {Server};
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
* @type {symbol}
|
|
28
|
+
*/
|
|
29
|
+
const serverVersionSymbol = Symbol("serverVersion");
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
32
|
* Base class for all server data sources
|
|
@@ -30,54 +38,82 @@ export { Server };
|
|
|
30
38
|
* @summary The Server class encapsulates the access to a server datasource
|
|
31
39
|
*/
|
|
32
40
|
class Server extends Datasource {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
41
|
+
/**
|
|
42
|
+
* This method is called by the `instanceof` operator.
|
|
43
|
+
* @returns {symbol}
|
|
44
|
+
*/
|
|
45
|
+
static get [instanceSymbol]() {
|
|
46
|
+
return Symbol.for("@schukai/monster/data/datasource/server");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* This prepares the data that comes from the server.
|
|
51
|
+
* Should not be called directly.
|
|
52
|
+
*
|
|
53
|
+
* @private
|
|
54
|
+
* @param {Object} payload
|
|
55
|
+
* @returns {Object}
|
|
56
|
+
*/
|
|
57
|
+
transformServerPayload(payload) {
|
|
58
|
+
payload = doTransform.call(this, "read", payload);
|
|
59
|
+
this[serverVersionSymbol] = payload;
|
|
60
|
+
|
|
61
|
+
const dataPath = this.getOption("read.path");
|
|
62
|
+
if (dataPath) {
|
|
63
|
+
payload = new Pathfinder(payload).getVia(dataPath);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return payload;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* This prepares the data for writing and should not be called directly.
|
|
71
|
+
*
|
|
72
|
+
* @private
|
|
73
|
+
* @param {Object} payload
|
|
74
|
+
* @returns {Object}
|
|
75
|
+
*/
|
|
76
|
+
prepareServerPayload(payload) {
|
|
77
|
+
payload = doTransform.call(this, "write", payload);
|
|
78
|
+
payload = doDiff.call(this, payload);
|
|
79
|
+
|
|
80
|
+
const sheathingObject = this.getOption("write.sheathing.object");
|
|
81
|
+
const sheathingPath = this.getOption("write.sheathing.path");
|
|
82
|
+
|
|
83
|
+
if (sheathingObject && sheathingPath) {
|
|
84
|
+
const sub = payload;
|
|
85
|
+
payload = sheathingObject;
|
|
86
|
+
new Pathfinder(payload).setVia(sheathingPath, sub);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return payload;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* @param obj
|
|
96
|
+
* @returns {*}
|
|
97
|
+
*/
|
|
98
|
+
function doDiff(obj) {
|
|
99
|
+
if (this[serverVersionSymbol] === null || this[serverVersionSymbol] === undefined) {
|
|
100
|
+
return obj;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const callback = this.getOption("write.partial.callback");
|
|
104
|
+
if (!isFunction(callback)) {
|
|
105
|
+
return obj;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const results = diff(this[serverVersionSymbol], obj);
|
|
109
|
+
if (!results) {
|
|
110
|
+
return obj;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
obj = callback(obj, results);
|
|
114
|
+
this[serverVersionSymbol] = obj;
|
|
115
|
+
|
|
116
|
+
return obj;
|
|
81
117
|
}
|
|
82
118
|
|
|
83
119
|
/**
|
|
@@ -87,24 +123,32 @@ class Server extends Datasource {
|
|
|
87
123
|
* @returns {Object}
|
|
88
124
|
*/
|
|
89
125
|
function doTransform(type, obj) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
126
|
+
const transformation = this.getOption(`${type}.mapping.transformer`);
|
|
127
|
+
if (transformation !== undefined && transformation !== null) {
|
|
128
|
+
const pipe = new Pipe(transformation);
|
|
129
|
+
const callbacks = this.getOption(`${type}.mapping.callbacks`);
|
|
130
|
+
|
|
131
|
+
if (isArray(callbacks)) {
|
|
132
|
+
for (const callback of callbacks) {
|
|
133
|
+
if (typeof callback === "function") {
|
|
134
|
+
pipe.setCallback(callback);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (isObject(callbacks)) {
|
|
140
|
+
for (const key in callbacks) {
|
|
141
|
+
if (
|
|
142
|
+
callbacks.hasOwnProperty(key) &&
|
|
143
|
+
typeof callbacks[key] === "function"
|
|
144
|
+
) {
|
|
145
|
+
pipe.setCallback(key, callbacks[key]);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
obj = pipe.run(obj);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return obj;
|
|
110
154
|
}
|
package/source/data/diff.mjs
CHANGED
|
@@ -327,6 +327,7 @@ class CustomElement extends HTMLElement {
|
|
|
327
327
|
* @property {Object} templates Specifies the templates used by the control.
|
|
328
328
|
* @property {string} templates.main=undefined Specifies the main template used by the control.
|
|
329
329
|
* @property {Object} templateMapping Specifies the mapping of templates.
|
|
330
|
+
* @property {string} display=block Specifies the display mode of the control.
|
|
330
331
|
* @since 1.8.0
|
|
331
332
|
*/
|
|
332
333
|
get defaults() {
|
|
@@ -338,6 +339,7 @@ class CustomElement extends HTMLElement {
|
|
|
338
339
|
main: undefined,
|
|
339
340
|
},
|
|
340
341
|
templateMapping: {},
|
|
342
|
+
display: "block"
|
|
341
343
|
};
|
|
342
344
|
}
|
|
343
345
|
|
|
@@ -595,6 +597,8 @@ class CustomElement extends HTMLElement {
|
|
|
595
597
|
let elements;
|
|
596
598
|
let nodeList;
|
|
597
599
|
|
|
600
|
+
this.style.setProperty("display", this.getOption("display"));
|
|
601
|
+
|
|
598
602
|
// Extract options from attributes and set them
|
|
599
603
|
const AttributeOptions = getOptionsFromAttributes.call(this);
|
|
600
604
|
if (
|
package/source/dom/updater.mjs
CHANGED
|
@@ -44,7 +44,7 @@ import { findDocumentTemplate } from "./template.mjs";
|
|
|
44
44
|
export { Updater, addObjectWithUpdaterToElement };
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* The updater class connects an object with the
|
|
47
|
+
* The updater class connects an object with the DOM. In this way, structures and contents in the DOM can be
|
|
48
48
|
* programmatically adapted via attributes.
|
|
49
49
|
*
|
|
50
50
|
* For example, to include a string from an object, the attribute `data-monster-replace` can be used.
|