@schukai/monster 3.95.1 → 3.96.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 +22 -0
- package/package.json +1 -1
- package/source/components/datatable/dataset.mjs +331 -305
- package/source/components/datatable/datasource/dom.mjs +35 -1
- package/source/components/datatable/datasource/rest.mjs +99 -69
- package/source/components/datatable/datasource.mjs +15 -15
- package/source/components/datatable/embedded-pagination.mjs +11 -0
- package/source/components/datatable/pagination.mjs +41 -25
- package/source/components/datatable/status.mjs +1 -3
- package/source/components/datatable/style/pagination.pcss +2 -2
- package/source/components/datatable/stylesheet/pagination.mjs +1 -1
- package/source/components/datatable/util.mjs +2 -1
- package/source/components/form/select.mjs +1 -1
- package/source/components/form/toggle-switch.mjs +2 -6
- package/source/components/host/config-manager.mjs +1 -3
- package/source/components/layout/tabs.mjs +897 -895
- package/source/components/notify/message.mjs +10 -14
- package/source/components/notify/notify.mjs +9 -13
- package/source/components/notify/stylesheet/notify.mjs +13 -6
- package/source/components/state/log.mjs +184 -184
- package/source/components/state/stylesheet/log.mjs +13 -6
- package/source/data/datasource/server/restapi.mjs +22 -16
- package/source/data/datasource/server.mjs +1 -0
- package/source/data/transformer.mjs +803 -806
- package/source/dom/updater.mjs +767 -767
- package/source/i18n/time-ago.mjs +1352 -636
- package/source/monster.mjs +2 -0
- package/source/types/has.mjs +26 -0
- package/source/types/version.mjs +1 -1
- package/test/cases/components/form/form.mjs +166 -125
- package/test/cases/monster.mjs +1 -1
- package/test/web/import.js +1 -0
- package/test/web/test.html +2 -2
- package/test/web/tests.js +2080 -1433
@@ -108,21 +108,17 @@ class Message extends CustomElement {
|
|
108
108
|
* @property {string} content The content of the message
|
109
109
|
*/
|
110
110
|
get defaults() {
|
111
|
-
return Object.assign(
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
features: {
|
117
|
-
close: true,
|
118
|
-
disappear: true,
|
119
|
-
},
|
120
|
-
content: "<slot></slot>",
|
121
|
-
templates: {
|
122
|
-
main: getTemplate(),
|
123
|
-
},
|
111
|
+
return Object.assign({}, super.defaults, {
|
112
|
+
timeout: 6000,
|
113
|
+
features: {
|
114
|
+
close: true,
|
115
|
+
disappear: true,
|
124
116
|
},
|
125
|
-
|
117
|
+
content: "<slot></slot>",
|
118
|
+
templates: {
|
119
|
+
main: getTemplate(),
|
120
|
+
},
|
121
|
+
});
|
126
122
|
}
|
127
123
|
|
128
124
|
/**
|
@@ -73,20 +73,16 @@ class Notify extends CustomElement {
|
|
73
73
|
* @property {string} classes.control The control class of the notify element.
|
74
74
|
*/
|
75
75
|
get defaults() {
|
76
|
-
return Object.assign(
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
orientation: "left top",
|
81
|
-
templates: {
|
82
|
-
main: getTemplate(),
|
83
|
-
},
|
84
|
-
classes: {
|
85
|
-
container: "",
|
86
|
-
control: "center"
|
87
|
-
}
|
76
|
+
return Object.assign({}, super.defaults, {
|
77
|
+
orientation: "left top",
|
78
|
+
templates: {
|
79
|
+
main: getTemplate(),
|
88
80
|
},
|
89
|
-
|
81
|
+
classes: {
|
82
|
+
container: "",
|
83
|
+
control: "center",
|
84
|
+
},
|
85
|
+
});
|
90
86
|
}
|
91
87
|
|
92
88
|
/**
|
@@ -10,10 +10,10 @@
|
|
10
10
|
* For more information about purchasing a commercial license, please contact schukai GmbH.
|
11
11
|
*/
|
12
12
|
|
13
|
-
import {addAttributeToken} from "../../../dom/attributes.mjs";
|
14
|
-
import {ATTRIBUTE_ERRORMESSAGE} from "../../../dom/constants.mjs";
|
13
|
+
import { addAttributeToken } from "../../../dom/attributes.mjs";
|
14
|
+
import { ATTRIBUTE_ERRORMESSAGE } from "../../../dom/constants.mjs";
|
15
15
|
|
16
|
-
export {NotifyStyleSheet}
|
16
|
+
export { NotifyStyleSheet };
|
17
17
|
|
18
18
|
/**
|
19
19
|
* @private
|
@@ -22,10 +22,17 @@ export {NotifyStyleSheet}
|
|
22
22
|
const NotifyStyleSheet = new CSSStyleSheet();
|
23
23
|
|
24
24
|
try {
|
25
|
-
|
25
|
+
NotifyStyleSheet.insertRule(
|
26
|
+
`
|
26
27
|
@layer notify {
|
27
28
|
.block{display:block}.inline{display:inline}.inline-block{display:inline-block}.grid{display:grid}.inline-grid{display:inline-grid}.flex{display:flex}.inline-flex{display:inline-flex}.hidden,.hide,.none{display:none}.visible{visibility:visible}.invisible{visibility:hidden}.monster-border-primary-1,.monster-border-primary-2,.monster-border-primary-3,.monster-border-primary-4{border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width)}.monster-border-0{border-radius:0;border-style:none;border-width:0}.monster-border-primary-1{border-color:var(--monster-bg-color-primary-1)}.monster-border-primary-2{border-color:var(--monster-bg-color-primary-2)}.monster-border-primary-3{border-color:var(--monster-bg-color-primary-3)}.monster-border-primary-4{border-color:var(--monster-bg-color-primary-4)}.monster-border-secondary-1,.monster-border-secondary-2,.monster-border-secondary-3,.monster-border-secondary-4{border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width)}.monster-border-secondary-1{border-color:var(--monster-bg-color-secondary-1)}.monster-border-secondary-2{border-color:var(--monster-bg-color-secondary-2)}.monster-border-secondary-3{border-color:var(--monster-bg-color-secondary-3)}.monster-border-secondary-4{border-color:var(--monster-bg-color-secondary-4)}.monster-border-tertiary-1,.monster-border-tertiary-2,.monster-border-tertiary-3,.monster-border-tertiary-4{border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width)}.monster-border-tertiary-1{border-color:var(--monster-bg-color-tertiary-1)}.monster-border-tertiary-2{border-color:var(--monster-bg-color-tertiary-2)}.monster-border-tertiary-3{border-color:var(--monster-bg-color-tertiary-3)}.monster-border-tertiary-4{border-color:var(--monster-bg-color-tertiary-4)}[data-monster-role=control]{box-sizing:border-box;outline:none;width:100%}[data-monster-role=control].flex{align-items:center;display:flex;flex-direction:row}:host{box-sizing:border-box;display:block}div[data-monster-role=control]{align-items:flex-start;border:0;box-sizing:border-box;display:flex;flex-direction:row;justify-content:space-between;margin:0;max-height:100vH;pointer-events:none;right:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:25rem;z-index:var(--monster-z-index-modal-overlay)}div[data-monster-role=control]:not(.inline){position:absolute}div[data-monster-role=control].inline{--monster-message-border-shadow:none}[data-monster-role=control][data-monster-orientation*=left]{left:0;right:auto}[data-monster-role=control][data-monster-orientation*=right]{left:auto;right:0}[data-monster-role=control][data-monster-orientation*=center]{left:50%;transform:translate(-50%)}[data-monster-role=control][data-monster-orientation*=bottom]{align-items:flex-end;bottom:0}[data-monster-role=control][data-monster-orientation*=top]{align-items:flex-start;top:0}[data-monster-role=container]{width:100%}[data-monster-role=message]{background-clip:padding-box;background-color:var(--monster-bg-color-primary-1);border-color:var(--monster-message-border-color,rgba(0,0,0,.1));border-radius:var(--monster-message-border-radius,.25rem);border-style:var(--monster-message-border-style,solid);border-width:var(--monster-message-border-width,1px);box-shadow:var(--monster-message-border-shadow,0 .5rem 1rem rgba(0,0,0,.15));color:var(--monster-color-primary-1);display:flex;font-size:.875rem;margin:var(--monster-message-margin-top,15px) var(--monster-message-margin-right,5px) var(--monster-message-margin-bottom,0) var(--monster-message-margin-left,0);max-height:200px;max-width:100%;overflow:hidden;padding:var(--monster-message-padding-top,5px) var(--monster-message-padding-right,5px) var(--monster-message-padding-bottom,5px) var(--monster-message-padding-left,5px);pointer-events:auto;position:relative;text-overflow:ellipsis;-webkit-user-select:text;-moz-user-select:text;user-select:text;width:100%}[data-monster-role=message]:first-child{margin-top:0}[data-monster-role=message].fadeout{border:0;margin-bottom:0;margin-top:0;max-height:0;padding-bottom:0;padding-top:0;transition:all .2s cubic-bezier(1,-.04,0,1.03)}
|
28
|
-
}`,
|
29
|
+
}`,
|
30
|
+
0,
|
31
|
+
);
|
29
32
|
} catch (e) {
|
30
|
-
|
33
|
+
addAttributeToken(
|
34
|
+
document.getRootNode().querySelector("html"),
|
35
|
+
ATTRIBUTE_ERRORMESSAGE,
|
36
|
+
e + "",
|
37
|
+
);
|
31
38
|
}
|
@@ -12,20 +12,20 @@
|
|
12
12
|
* SPDX-License-Identifier: AGPL-3.0
|
13
13
|
*/
|
14
14
|
|
15
|
-
import {instanceSymbol} from "../../constants.mjs";
|
15
|
+
import { instanceSymbol } from "../../constants.mjs";
|
16
16
|
import {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
assembleMethodSymbol,
|
18
|
+
CustomElement,
|
19
|
+
getSlottedElements,
|
20
|
+
registerCustomElement,
|
21
21
|
} from "../../dom/customelement.mjs";
|
22
|
-
import {LogStyleSheet} from "./stylesheet/log.mjs";
|
23
|
-
import {Entry} from "./log/entry.mjs";
|
24
|
-
import {validateInstance, validateString} from "../../types/validate.mjs";
|
22
|
+
import { LogStyleSheet } from "./stylesheet/log.mjs";
|
23
|
+
import { Entry } from "./log/entry.mjs";
|
24
|
+
import { validateInstance, validateString } from "../../types/validate.mjs";
|
25
25
|
import "./state.mjs";
|
26
|
-
import {getWindow} from "../../dom/util.mjs";
|
26
|
+
import { getWindow } from "../../dom/util.mjs";
|
27
27
|
|
28
|
-
export {Log};
|
28
|
+
export { Log };
|
29
29
|
|
30
30
|
/**
|
31
31
|
* @private
|
@@ -53,146 +53,146 @@ const emptyStateElementSymbol = Symbol("emptyStateElement");
|
|
53
53
|
* @summary The log entry is a single entry in the log.
|
54
54
|
**/
|
55
55
|
class Log extends CustomElement {
|
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
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
56
|
+
/**
|
57
|
+
* @return {void}
|
58
|
+
*/
|
59
|
+
[assembleMethodSymbol]() {
|
60
|
+
super[assembleMethodSymbol]();
|
61
|
+
|
62
|
+
initControlReferences.call(this);
|
63
|
+
initEventHandler.call(this);
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* This method is called by the `instanceof` operator.
|
68
|
+
* @return {symbol}
|
69
|
+
*/
|
70
|
+
static get [instanceSymbol]() {
|
71
|
+
return Symbol.for("@schukai/monster/components/state/log@@instance");
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* To set the options via the HTML tag, the attribute `data-monster-options` must be used.
|
76
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
77
|
+
*
|
78
|
+
* The individual configuration values can be found in the table.
|
79
|
+
*
|
80
|
+
* @property {Object} templates Template definitions
|
81
|
+
* @property {string} templates.main Main template
|
82
|
+
* @property {Object} labels Labels
|
83
|
+
* @property {string} labels.nothingToReport Label for empty state
|
84
|
+
* @property {Object} classes Classes
|
85
|
+
* @property {string} classes.direction Direction of the log: ascending or descending
|
86
|
+
* @property {number} updateFrequency Update frequency in milliseconds for the timestamp
|
87
|
+
*/
|
88
|
+
get defaults() {
|
89
|
+
return Object.assign({}, super.defaults, {
|
90
|
+
templates: {
|
91
|
+
main: getTemplate(),
|
92
|
+
},
|
93
|
+
|
94
|
+
labels: {
|
95
|
+
nothingToReport: "There is nothing to report yet.",
|
96
|
+
},
|
97
|
+
|
98
|
+
features: {
|
99
|
+
direction: "ascending",
|
100
|
+
},
|
101
|
+
|
102
|
+
updateFrequency: 10000,
|
103
|
+
|
104
|
+
entries: [],
|
105
|
+
|
106
|
+
timestamp: 0,
|
107
|
+
});
|
108
|
+
}
|
109
|
+
|
110
|
+
/**
|
111
|
+
* @return {void}
|
112
|
+
*/
|
113
|
+
connectedCallback() {
|
114
|
+
super.connectedCallback();
|
115
|
+
|
116
|
+
const slottedElements = getSlottedElements.call(this);
|
117
|
+
if (slottedElements.size > 0) {
|
118
|
+
this[emptyStateElementSymbol].style.display = "none";
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Clear the log
|
124
|
+
*
|
125
|
+
* @return {Log}
|
126
|
+
*/
|
127
|
+
clear() {
|
128
|
+
this[logElementSymbol].setOption("entries", []);
|
129
|
+
return this;
|
130
|
+
}
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Add an entry to the log
|
134
|
+
* @param {Entry} entry
|
135
|
+
* @return {Log}
|
136
|
+
*/
|
137
|
+
addEntry(entry) {
|
138
|
+
validateInstance(entry, Entry);
|
139
|
+
|
140
|
+
if (entry.date === undefined || entry.date === null) {
|
141
|
+
entry.date = new Date();
|
142
|
+
}
|
143
|
+
|
144
|
+
const entries = this.getOption("entries");
|
145
|
+
if (this.getOption("features.direction") === "ascending") {
|
146
|
+
entries.unshift(entry);
|
147
|
+
} else {
|
148
|
+
entries.push(entry);
|
149
|
+
}
|
150
|
+
|
151
|
+
/** this field is not used, but triggers a change event */
|
152
|
+
this.setOption("length", entries.length - 1);
|
153
|
+
|
154
|
+
return this;
|
155
|
+
}
|
156
|
+
|
157
|
+
/**
|
158
|
+
* Add a log message
|
159
|
+
*
|
160
|
+
* @param {string} message
|
161
|
+
* @param {Date} date
|
162
|
+
* @return {Log}
|
163
|
+
* @throws {TypeError} message is not a string
|
164
|
+
*/
|
165
|
+
addMessage(message, date) {
|
166
|
+
if (!date) {
|
167
|
+
date = new Date();
|
168
|
+
}
|
169
|
+
|
170
|
+
validateString(message);
|
171
|
+
|
172
|
+
this.addEntry(
|
173
|
+
new Entry({
|
174
|
+
message: message,
|
175
|
+
date: date,
|
176
|
+
}),
|
177
|
+
);
|
178
|
+
|
179
|
+
return this;
|
180
|
+
}
|
181
|
+
|
182
|
+
/**
|
183
|
+
*
|
184
|
+
* @return {string}
|
185
|
+
*/
|
186
|
+
static getTag() {
|
187
|
+
return "monster-log";
|
188
|
+
}
|
189
|
+
|
190
|
+
/**
|
191
|
+
* @return {CSSStyleSheet[]}
|
192
|
+
*/
|
193
|
+
static getCSSStyleSheet() {
|
194
|
+
return [LogStyleSheet];
|
195
|
+
}
|
196
196
|
}
|
197
197
|
|
198
198
|
/**
|
@@ -201,44 +201,44 @@ class Log extends CustomElement {
|
|
201
201
|
* @throws {Error} no shadow-root is defined
|
202
202
|
*/
|
203
203
|
function initControlReferences() {
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
204
|
+
if (!this.shadowRoot) {
|
205
|
+
throw new Error("no shadow-root is defined");
|
206
|
+
}
|
207
|
+
|
208
|
+
this[logElementSymbol] = this.shadowRoot.querySelector(
|
209
|
+
"[data-monster-role=control]",
|
210
|
+
);
|
211
|
+
this[emptyStateElementSymbol] = this.shadowRoot.querySelector(
|
212
|
+
"[data-monster-role=empty-state]",
|
213
|
+
);
|
214
214
|
}
|
215
215
|
|
216
216
|
/**
|
217
217
|
* @private
|
218
218
|
*/
|
219
219
|
function initEventHandler() {
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
220
|
+
if (!this.shadowRoot) {
|
221
|
+
throw new Error("no shadow-root is defined");
|
222
|
+
}
|
223
|
+
|
224
|
+
this.shadowRoot.addEventListener("slotchange", (event) => {
|
225
|
+
const slottedElements = getSlottedElements.call(this);
|
226
|
+
|
227
|
+
if (slottedElements.size > 0) {
|
228
|
+
this[emptyStateElementSymbol].style.display = "none";
|
229
|
+
} else {
|
230
|
+
this[emptyStateElementSymbol].style.display = "block";
|
231
|
+
}
|
232
|
+
});
|
233
|
+
|
234
|
+
setInterval(() => {
|
235
|
+
getWindow().requestAnimationFrame(() => {
|
236
|
+
const timestamp = new Date().toTimeString();
|
237
|
+
this.setOption("timestamp", timestamp);
|
238
|
+
});
|
239
|
+
}, this.getOption("updateFrequency"));
|
240
|
+
|
241
|
+
return this;
|
242
242
|
}
|
243
243
|
|
244
244
|
/**
|
@@ -246,8 +246,8 @@ function initEventHandler() {
|
|
246
246
|
* @return {string}
|
247
247
|
*/
|
248
248
|
function getTemplate() {
|
249
|
-
|
250
|
-
|
249
|
+
// language=HTML
|
250
|
+
return `
|
251
251
|
<template id="entry">
|
252
252
|
<li data-monster-role="entry">
|
253
253
|
<span data-monster-replace="path:entry.user"
|
@@ -10,10 +10,10 @@
|
|
10
10
|
* For more information about purchasing a commercial license, please contact schukai GmbH.
|
11
11
|
*/
|
12
12
|
|
13
|
-
import {addAttributeToken} from "../../../dom/attributes.mjs";
|
14
|
-
import {ATTRIBUTE_ERRORMESSAGE} from "../../../dom/constants.mjs";
|
13
|
+
import { addAttributeToken } from "../../../dom/attributes.mjs";
|
14
|
+
import { ATTRIBUTE_ERRORMESSAGE } from "../../../dom/constants.mjs";
|
15
15
|
|
16
|
-
export {LogStyleSheet}
|
16
|
+
export { LogStyleSheet };
|
17
17
|
|
18
18
|
/**
|
19
19
|
* @private
|
@@ -22,10 +22,17 @@ export {LogStyleSheet}
|
|
22
22
|
const LogStyleSheet = new CSSStyleSheet();
|
23
23
|
|
24
24
|
try {
|
25
|
-
|
25
|
+
LogStyleSheet.insertRule(
|
26
|
+
`
|
26
27
|
@layer log {
|
27
28
|
[data-monster-role=control]{box-sizing:border-box;outline:none;width:100%}[data-monster-role=control].flex{align-items:center;display:flex;flex-direction:row}:host{box-sizing:border-box;display:block}.block{display:block}.inline{display:inline}.inline-block{display:inline-block}.grid{display:grid}.inline-grid{display:inline-grid}.flex{display:flex}.inline-flex{display:inline-flex}.hidden,.hide,.none{display:none}.visible{visibility:visible}.invisible{visibility:hidden}.monster-border-primary-1,.monster-border-primary-2,.monster-border-primary-3,.monster-border-primary-4{border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width)}.monster-border-0{border-radius:0;border-style:none;border-width:0}.monster-border-primary-1{border-color:var(--monster-bg-color-primary-1)}.monster-border-primary-2{border-color:var(--monster-bg-color-primary-2)}.monster-border-primary-3{border-color:var(--monster-bg-color-primary-3)}.monster-border-primary-4{border-color:var(--monster-bg-color-primary-4)}.monster-border-secondary-1,.monster-border-secondary-2,.monster-border-secondary-3,.monster-border-secondary-4{border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width)}.monster-border-secondary-1{border-color:var(--monster-bg-color-secondary-1)}.monster-border-secondary-2{border-color:var(--monster-bg-color-secondary-2)}.monster-border-secondary-3{border-color:var(--monster-bg-color-secondary-3)}.monster-border-secondary-4{border-color:var(--monster-bg-color-secondary-4)}.monster-border-tertiary-1,.monster-border-tertiary-2,.monster-border-tertiary-3,.monster-border-tertiary-4{border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width)}.monster-border-tertiary-1{border-color:var(--monster-bg-color-tertiary-1)}.monster-border-tertiary-2{border-color:var(--monster-bg-color-tertiary-2)}.monster-border-tertiary-3{border-color:var(--monster-bg-color-tertiary-3)}.monster-border-tertiary-4{border-color:var(--monster-bg-color-tertiary-4)}[data-monster-role=entries]{align-items:flex-start;border:0;box-sizing:border-box;display:flex;flex-direction:column;margin:0;padding:0;position:relative}[data-monster-role=entries] ul{list-style-type:none;margin:0;padding:0 0 0 1.8rem;width:100%}[data-monster-role=entries] ul:before{border-left:1px dotted var(--monster-bg-color-primary-3);bottom:0;content:\"\";display:block;height:100%;left:1rem;position:absolute;top:0;width:2px}[data-monster-role=entries] ul li{background-color:var(--monster-bg-color-primary-1);color:var(--monster-color-primary-1);margin:0;padding:.35rem .3rem;position:relative}:is([data-monster-role=entries] ul li) .title{font-stretch:expanded;font-weight:bolder}:is([data-monster-role=entries] ul li) .title:before{content:\"—\";font-weight:400;margin-right:.3rem}[data-monster-role=entries] ul li:before{background:var(--monster-bg-color-primary-3);border:1px solid var(--monster-color-primary-2);border-radius:50%;box-sizing:border-box;content:\"\";height:6px;left:calc(-1rem + 1.25px);position:absolute;top:.85rem;width:6px}
|
28
|
-
}`,
|
29
|
+
}`,
|
30
|
+
0,
|
31
|
+
);
|
29
32
|
} catch (e) {
|
30
|
-
|
33
|
+
addAttributeToken(
|
34
|
+
document.getRootNode().querySelector("html"),
|
35
|
+
ATTRIBUTE_ERRORMESSAGE,
|
36
|
+
e + "",
|
37
|
+
);
|
31
38
|
}
|
@@ -18,6 +18,7 @@ import { diff } from "../../diff.mjs";
|
|
18
18
|
import { Server } from "../server.mjs";
|
19
19
|
import { WriteError } from "./restapi/writeerror.mjs";
|
20
20
|
import { DataFetchError } from "./restapi/data-fetch-error.mjs";
|
21
|
+
import { clone } from "../../../util/clone.mjs";
|
21
22
|
|
22
23
|
export { RestAPI };
|
23
24
|
|
@@ -63,7 +64,7 @@ class RestAPI extends Server {
|
|
63
64
|
|
64
65
|
/**
|
65
66
|
* @property {Object} write={} Options
|
66
|
-
* @property {Object} write.init={} An
|
67
|
+
* @property {Object} write.init={} An option 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}
|
67
68
|
* @property {string} write.init.method=POST
|
68
69
|
* @property {Object} write.init.headers Object containing any custom headers that you want to apply to the request.
|
69
70
|
* @property {string} write.responseCallback Callback function to be executed after the request has been completed.
|
@@ -71,7 +72,7 @@ class RestAPI extends Server {
|
|
71
72
|
* @property {string} write.url URL
|
72
73
|
* @property {Object} write.mapping the mapping is applied before writing.
|
73
74
|
* @property {String} write.mapping.transformer Transformer to select the appropriate entries
|
74
|
-
* @property {
|
75
|
+
* @property {exampleCallback[]} write.mapping.callback with the help of the callback, the structures can be adjusted before writing.
|
75
76
|
* @property {Object} write.report
|
76
77
|
* @property {String} write.report.path Path to validations
|
77
78
|
* @property {Object} write.partial
|
@@ -80,13 +81,13 @@ class RestAPI extends Server {
|
|
80
81
|
* @property {Object} write.sheathing.object Object to be wrapped
|
81
82
|
* @property {string} write.sheathing.path Path to the data
|
82
83
|
* @property {Object} read={} Options
|
83
|
-
* @property {Object} read.init={} An
|
84
|
+
* @property {Object} read.init={} An option 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}
|
84
85
|
* @property {string} read.init.method=GET
|
85
|
-
* @property {
|
86
|
+
* @property {array} read.acceptedStatus=[200]
|
86
87
|
* @property {string} read.url URL
|
87
88
|
* @property {Object} read.mapping the mapping is applied after reading.
|
88
89
|
* @property {String} read.mapping.transformer Transformer to select the appropriate entries
|
89
|
-
* @property {
|
90
|
+
* @property {exampleCallback[]} read.mapping.callback with the help of the callback, the structures can be adjusted after reading.
|
90
91
|
*/
|
91
92
|
get defaults() {
|
92
93
|
return Object.assign({}, super.defaults, {
|
@@ -94,19 +95,19 @@ class RestAPI extends Server {
|
|
94
95
|
init: {
|
95
96
|
method: "POST",
|
96
97
|
},
|
97
|
-
responseCallback:
|
98
|
+
responseCallback: null,
|
98
99
|
acceptedStatus: [200, 201],
|
99
100
|
url: null,
|
100
101
|
mapping: {
|
101
|
-
transformer:
|
102
|
+
transformer: null,
|
102
103
|
callbacks: [],
|
103
104
|
},
|
104
105
|
sheathing: {
|
105
|
-
object:
|
106
|
-
path:
|
106
|
+
object: null,
|
107
|
+
path: null,
|
107
108
|
},
|
108
109
|
report: {
|
109
|
-
path:
|
110
|
+
path: null,
|
110
111
|
},
|
111
112
|
|
112
113
|
partial: {
|
@@ -118,11 +119,11 @@ class RestAPI extends Server {
|
|
118
119
|
method: "GET",
|
119
120
|
},
|
120
121
|
path: null,
|
121
|
-
responseCallback:
|
122
|
+
responseCallback: null,
|
122
123
|
acceptedStatus: [200],
|
123
124
|
url: null,
|
124
125
|
mapping: {
|
125
|
-
transformer:
|
126
|
+
transformer: null,
|
126
127
|
callbacks: [],
|
127
128
|
},
|
128
129
|
},
|
@@ -175,10 +176,15 @@ class RestAPI extends Server {
|
|
175
176
|
* @return {RestAPI}
|
176
177
|
*/
|
177
178
|
getClone() {
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
);
|
179
|
+
const api = new RestAPI();
|
180
|
+
|
181
|
+
const read = clone(this[internalSymbol].getRealSubject()["options"].read);
|
182
|
+
const write = clone(this[internalSymbol].getRealSubject()["options"].write);
|
183
|
+
|
184
|
+
api.setOption("read", read);
|
185
|
+
api.setOption("write", write);
|
186
|
+
|
187
|
+
return api;
|
182
188
|
}
|
183
189
|
}
|
184
190
|
|
@@ -125,6 +125,7 @@ function doDiff(obj) {
|
|
125
125
|
*/
|
126
126
|
function doTransform(type, obj) {
|
127
127
|
const transformation = this.getOption(`${type}.mapping.transformer`);
|
128
|
+
|
128
129
|
if (transformation !== undefined && transformation !== null) {
|
129
130
|
const pipe = new Pipe(transformation);
|
130
131
|
const callbacks = this.getOption(`${type}.mapping.callbacks`);
|