@schukai/monster 3.110.4 → 3.112.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 +25 -0
- package/package.json +1 -1
- package/source/components/content/camera.mjs +488 -0
- package/source/components/content/style/camera-capture.pcss +37 -0
- package/source/components/content/stylesheet/camera-capture.mjs +38 -0
- package/source/components/datatable/status.mjs +175 -177
- package/source/components/form/reload.mjs +1 -2
- package/source/components/form/util/fetch.mjs +5 -2
- package/source/components/layout/popper.mjs +1 -1
- package/source/components/layout/slider.mjs +1 -1
- package/source/components/time/month-calendar.mjs +819 -0
- package/source/components/time/style/month-calendar.pcss +100 -0
- package/source/components/time/stylesheet/month-calendar.mjs +31 -0
- package/source/components/time/timeline/collection.mjs +205 -0
- package/source/components/time/timeline/item.mjs +184 -0
- package/source/components/time/timeline/segment.mjs +169 -0
- package/source/components/time/timeline/style/segment.pcss +18 -0
- package/source/components/time/timeline/stylesheet/segment.mjs +38 -0
- package/source/data/datasource/server/restapi/data-fetch-error.mjs +3 -3
- package/source/data/datasource/server/restapi.mjs +1 -1
- package/source/data/transformer.mjs +60 -0
- package/source/monster.mjs +4 -0
- package/source/text/bracketed-key-value-hash.mjs +187 -187
- package/source/types/base.mjs +6 -5
- package/source/types/basewithoptions.mjs +4 -1
- package/source/types/internal.mjs +1 -1
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/test.html +2 -2
- package/test/web/tests.js +1136 -977
@@ -13,26 +13,26 @@
|
|
13
13
|
*/
|
14
14
|
|
15
15
|
import {
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
assembleMethodSymbol,
|
17
|
+
CustomElement,
|
18
|
+
registerCustomElement,
|
19
19
|
} from "../../dom/customelement.mjs";
|
20
|
-
import {findElementWithSelectorUpwards} from "../../dom/util.mjs";
|
21
|
-
import {ThemeStyleSheet} from "../stylesheet/theme.mjs";
|
22
|
-
import {Datasource} from "./datasource.mjs";
|
23
|
-
import {SpinnerStyleSheet} from "../stylesheet/spinner.mjs";
|
24
|
-
import {isString} from "../../types/is.mjs";
|
25
|
-
import {instanceSymbol} from "../../constants.mjs";
|
20
|
+
import { findElementWithSelectorUpwards } from "../../dom/util.mjs";
|
21
|
+
import { ThemeStyleSheet } from "../stylesheet/theme.mjs";
|
22
|
+
import { Datasource } from "./datasource.mjs";
|
23
|
+
import { SpinnerStyleSheet } from "../stylesheet/spinner.mjs";
|
24
|
+
import { isString } from "../../types/is.mjs";
|
25
|
+
import { instanceSymbol } from "../../constants.mjs";
|
26
26
|
import "../form/select.mjs";
|
27
27
|
|
28
28
|
import "./datasource/dom.mjs";
|
29
29
|
import "./datasource/rest.mjs";
|
30
30
|
import "../form/popper.mjs";
|
31
31
|
import "../form/context-error.mjs";
|
32
|
-
import {StatusStyleSheet} from "./stylesheet/status.mjs";
|
33
|
-
import {Formatter} from "../../text/formatter.mjs";
|
32
|
+
import { StatusStyleSheet } from "./stylesheet/status.mjs";
|
33
|
+
import { Formatter } from "../../text/formatter.mjs";
|
34
34
|
|
35
|
-
export {DatasourceStatus};
|
35
|
+
export { DatasourceStatus };
|
36
36
|
|
37
37
|
/**
|
38
38
|
* @private
|
@@ -59,97 +59,96 @@ const datasourceLinkedElementSymbol = Symbol("datasourceLinkedElement");
|
|
59
59
|
* @summary The Status component is used to show the current status of a datasource.
|
60
60
|
*/
|
61
61
|
class DatasourceStatus extends CustomElement {
|
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
|
-
}
|
62
|
+
/**
|
63
|
+
*/
|
64
|
+
constructor() {
|
65
|
+
super();
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* This method is called by the `instanceof` operator.
|
70
|
+
* @return {symbol}
|
71
|
+
*/
|
72
|
+
static get [instanceSymbol]() {
|
73
|
+
return Symbol.for("@schukai/monster/components/datatable/status@@instance");
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* To set the options via the HTML tag, the attribute `data-monster-options` must be used.
|
78
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
79
|
+
*
|
80
|
+
* The individual configuration values can be found in the table.
|
81
|
+
*
|
82
|
+
* @property {Object} templates Template definitions
|
83
|
+
* @property {string} templates.main Main template
|
84
|
+
* @property {Object} datasource Datasource configuration
|
85
|
+
* @property {string} datasource.selector The selector of the datasource
|
86
|
+
* @property {Object} callbacks Callbacks
|
87
|
+
* @property {Function} callbacks.onError Callback function for error handling <code>function(message: string, event: Event): string</code>
|
88
|
+
* @property {Object} timeouts Timeouts
|
89
|
+
* @property {number} timeouts.message Timeout for the message
|
90
|
+
* @property {Object} state State
|
91
|
+
*/
|
92
|
+
get defaults() {
|
93
|
+
return Object.assign({}, super.defaults, {
|
94
|
+
templates: {
|
95
|
+
main: getTemplate(),
|
96
|
+
},
|
97
|
+
|
98
|
+
datasource: {
|
99
|
+
selector: null,
|
100
|
+
},
|
101
|
+
|
102
|
+
callbacks: {
|
103
|
+
onError: null,
|
104
|
+
},
|
105
|
+
|
106
|
+
timeouts: {
|
107
|
+
message: 4000,
|
108
|
+
},
|
109
|
+
|
110
|
+
state: {
|
111
|
+
spinner: "hide",
|
112
|
+
},
|
113
|
+
});
|
114
|
+
}
|
115
|
+
|
116
|
+
/**
|
117
|
+
*
|
118
|
+
* @return {string}
|
119
|
+
*/
|
120
|
+
static getTag() {
|
121
|
+
return "monster-datasource-status";
|
122
|
+
}
|
123
|
+
|
124
|
+
/**
|
125
|
+
* @private
|
126
|
+
*/
|
127
|
+
[assembleMethodSymbol]() {
|
128
|
+
super[assembleMethodSymbol]();
|
129
|
+
|
130
|
+
initControlReferences.call(this);
|
131
|
+
initEventHandler.call(this);
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
*
|
136
|
+
* @param message
|
137
|
+
* @param timeout
|
138
|
+
* @returns {DatasourceStatus}
|
139
|
+
*/
|
140
|
+
setErrorMessage(message, timeout) {
|
141
|
+
this[errorElementSymbol].setErrorMessage(message, timeout);
|
142
|
+
return this;
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
*
|
147
|
+
* @return [CSSStyleSheet]
|
148
|
+
*/
|
149
|
+
static getCSSStyleSheet() {
|
150
|
+
return [StatusStyleSheet, SpinnerStyleSheet, ThemeStyleSheet];
|
151
|
+
}
|
153
152
|
}
|
154
153
|
|
155
154
|
/**
|
@@ -158,85 +157,84 @@ class DatasourceStatus extends CustomElement {
|
|
158
157
|
* @throws {Error} no shadow-root is defined
|
159
158
|
*/
|
160
159
|
function initControlReferences() {
|
161
|
-
|
162
|
-
|
163
|
-
|
160
|
+
if (!this.shadowRoot) {
|
161
|
+
throw new Error("no shadow-root is defined");
|
162
|
+
}
|
164
163
|
|
165
|
-
|
166
|
-
|
167
|
-
|
164
|
+
this[errorElementSymbol] = this.shadowRoot.querySelector(
|
165
|
+
"monster-context-error",
|
166
|
+
);
|
168
167
|
}
|
169
168
|
|
170
169
|
/**
|
171
170
|
* @private
|
172
171
|
*/
|
173
172
|
function initEventHandler() {
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
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
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
}
|
173
|
+
const selector = this.getOption("datasource.selector", "");
|
174
|
+
const self = this;
|
175
|
+
|
176
|
+
if (isString(selector)) {
|
177
|
+
const element = findElementWithSelectorUpwards(this, selector);
|
178
|
+
if (element === null) {
|
179
|
+
throw new Error("the selector must match exactly one element");
|
180
|
+
}
|
181
|
+
|
182
|
+
if (!(element instanceof Datasource)) {
|
183
|
+
throw new TypeError("the element must be a datasource");
|
184
|
+
}
|
185
|
+
|
186
|
+
let fadeOutTimer = null;
|
187
|
+
|
188
|
+
this[datasourceLinkedElementSymbol] = element;
|
189
|
+
element.addEventListener("monster-datasource-fetched", function () {
|
190
|
+
fadeOutTimer = setTimeout(() => {
|
191
|
+
self.setOption("state.spinner", "hide");
|
192
|
+
}, 800);
|
193
|
+
});
|
194
|
+
|
195
|
+
element.addEventListener("monster-datasource-fetch", function () {
|
196
|
+
if (fadeOutTimer) {
|
197
|
+
clearTimeout(fadeOutTimer);
|
198
|
+
fadeOutTimer = null;
|
199
|
+
}
|
200
|
+
|
201
|
+
self.setOption("state.spinner", "show");
|
202
|
+
});
|
203
|
+
|
204
|
+
element.addEventListener("monster-datasource-error", function (event) {
|
205
|
+
if (fadeOutTimer) {
|
206
|
+
clearTimeout(fadeOutTimer);
|
207
|
+
fadeOutTimer = null;
|
208
|
+
}
|
209
|
+
|
210
|
+
self.setOption("state.spinner", "hide");
|
211
|
+
|
212
|
+
const timeout = self.getOption("timeouts.message", 4000);
|
213
|
+
let msg = "Cannot load data";
|
214
|
+
|
215
|
+
try {
|
216
|
+
if (event.detail.error instanceof Error) {
|
217
|
+
msg = event.detail.error.message;
|
218
|
+
} else if (event.detail.error instanceof Object) {
|
219
|
+
msg = JSON.stringify(event.detail.error);
|
220
|
+
} else if (event.detail.error instanceof String) {
|
221
|
+
msg = event.detail.error;
|
222
|
+
} else if (event.detail.error instanceof Number) {
|
223
|
+
msg = event.detail.error.toString();
|
224
|
+
} else {
|
225
|
+
msg = event.detail.error;
|
226
|
+
}
|
227
|
+
} catch (e) {
|
228
|
+
} finally {
|
229
|
+
const callback = self.getOption("callbacks.onError", null);
|
230
|
+
if (callback) {
|
231
|
+
callback.call(self, msg, event);
|
232
|
+
} else {
|
233
|
+
self[errorElementSymbol].setErrorMessage(msg, timeout);
|
234
|
+
}
|
235
|
+
}
|
236
|
+
});
|
237
|
+
}
|
240
238
|
}
|
241
239
|
|
242
240
|
/**
|
@@ -244,8 +242,8 @@ function initEventHandler() {
|
|
244
242
|
* @return {string}
|
245
243
|
*/
|
246
244
|
function getTemplate() {
|
247
|
-
|
248
|
-
|
245
|
+
// language=HTML
|
246
|
+
return `
|
249
247
|
<div data-monster-role="control" part="control"
|
250
248
|
data-monster-attributes="disabled path:disabled | if:true">
|
251
249
|
<monster-context-error
|
@@ -76,7 +76,8 @@ function loadAndAssignContent(element, url, options, filter) {
|
|
76
76
|
if (oldScript.defer) newScript.defer = oldScript.defer;
|
77
77
|
if (oldScript.crossOrigin) newScript.crossOrigin = oldScript.crossOrigin;
|
78
78
|
if (oldScript.integrity) newScript.integrity = oldScript.integrity;
|
79
|
-
if (oldScript.referrerPolicy)
|
79
|
+
if (oldScript.referrerPolicy)
|
80
|
+
newScript.referrerPolicy = oldScript.referrerPolicy;
|
80
81
|
newScript.textContent = oldScript.textContent;
|
81
82
|
document.head.appendChild(newScript);
|
82
83
|
if (oldScript.parentNode) {
|
@@ -121,7 +122,9 @@ function loadContent(url, options) {
|
|
121
122
|
if (statusClass === "4") {
|
122
123
|
throw new Error(`client error ${response.statusText}`);
|
123
124
|
}
|
124
|
-
throw new Error(
|
125
|
+
throw new Error(
|
126
|
+
`undefined status (${response.status} / ${response.statusText}) or type (${response.type})`,
|
127
|
+
);
|
125
128
|
}
|
126
129
|
return response.text().then((content) => ({
|
127
130
|
content,
|
@@ -745,7 +745,7 @@ function getTemplate() {
|
|
745
745
|
<div data-monster-role="slider" part="slides">
|
746
746
|
<slot></slot>
|
747
747
|
</div>
|
748
|
-
<div data-monster-role="thumbnails"></div>
|
748
|
+
<div data-monster-role="thumbnails" part="thumbnails"></div>
|
749
749
|
<div class="next" data-monster-role="next" part="next" part="next">
|
750
750
|
<slot name="next"></slot>
|
751
751
|
</div>
|