@schukai/monster 3.101.3 → 3.102.1
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 +23 -0
- package/package.json +1 -1
- package/source/components/accessibility/locale-picker.mjs +1 -1
- package/source/components/content/viewer.mjs +289 -0
- package/source/components/datatable/change-button.mjs +1 -1
- package/source/components/datatable/dataset.mjs +1 -1
- package/source/components/datatable/datasource/rest.mjs +1 -1
- package/source/components/datatable/datasource.mjs +1 -1
- package/source/components/datatable/datatable.mjs +1196 -1192
- package/source/components/datatable/filter.mjs +1 -1
- package/source/components/datatable/save-button.mjs +1 -1
- package/source/components/datatable/status.mjs +1 -1
- package/source/components/form/action-button.mjs +1 -1
- package/source/components/form/button.mjs +2 -2
- package/source/components/form/confirm-button.mjs +1 -1
- package/source/components/form/form.mjs +32 -28
- package/source/components/form/popper-button.mjs +1 -1
- package/source/components/form/select.mjs +2198 -2157
- package/source/components/host/viewer.mjs +3 -264
- package/source/components/layout/tabs.mjs +3 -3
- package/source/components/notify/message.mjs +1 -1
- package/source/components/notify/notify.mjs +1 -1
- package/source/dom/customelement.mjs +1 -1
- package/source/dom/updater.mjs +796 -768
- /package/source/components/{host → content}/style/viewer.pcss +0 -0
- /package/source/components/{host → content}/stylesheet/viewer.mjs +0 -0
@@ -12,272 +12,11 @@
|
|
12
12
|
* SPDX-License-Identifier: AGPL-3.0
|
13
13
|
*/
|
14
14
|
|
15
|
-
import {
|
16
|
-
assembleMethodSymbol,
|
17
|
-
CustomElement,
|
18
|
-
registerCustomElement,
|
19
|
-
} from "../../dom/customelement.mjs";
|
20
|
-
import "../notify/notify.mjs";
|
21
|
-
import { ViewerStyleSheet } from "./stylesheet/viewer.mjs";
|
22
|
-
import { instanceSymbol } from "../../constants.mjs";
|
23
|
-
import { isString } from "../../types/is.mjs";
|
24
|
-
import { getGlobal } from "../../types/global.mjs";
|
25
|
-
|
15
|
+
import { Viewer as NewViewer } from "../content/viewer.mjs";
|
26
16
|
export { Viewer };
|
27
17
|
|
28
18
|
/**
|
29
|
-
* @private
|
30
|
-
* @type {symbol}
|
31
|
-
*/
|
32
|
-
const viewerElementSymbol = Symbol("viewerElement");
|
33
|
-
|
34
|
-
/**
|
35
|
-
* The Viewer component is used to show a PDF, HTML or Image.
|
36
|
-
*
|
37
19
|
* @copyright schukai GmbH
|
38
|
-
* @
|
39
|
-
*/
|
40
|
-
class Viewer extends CustomElement {
|
41
|
-
/**
|
42
|
-
* This method is called by the `instanceof` operator.
|
43
|
-
* @return {symbol}
|
44
|
-
*/
|
45
|
-
static get [instanceSymbol]() {
|
46
|
-
return Symbol.for("@schukai/monster/components/host/viewer@@instance");
|
47
|
-
}
|
48
|
-
|
49
|
-
/**
|
50
|
-
* To set the options via the HTML tag, the attribute `data-monster-options` must be used.
|
51
|
-
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
52
|
-
*
|
53
|
-
* The individual configuration values can be found in the table.
|
54
|
-
*
|
55
|
-
* @property {Object} templates Template definitions
|
56
|
-
* @property {string} templates.main Main template
|
57
|
-
* @property {Object} classes Css classes
|
58
|
-
* @property {Object} features Feature definitions
|
59
|
-
*/
|
60
|
-
get defaults() {
|
61
|
-
return Object.assign({}, super.defaults, {
|
62
|
-
templates: {
|
63
|
-
main: getTemplate(),
|
64
|
-
},
|
65
|
-
content: "<slot>",
|
66
|
-
classes: {
|
67
|
-
viewer: "",
|
68
|
-
},
|
69
|
-
features: {},
|
70
|
-
});
|
71
|
-
}
|
72
|
-
|
73
|
-
/**
|
74
|
-
*
|
75
|
-
* @param html
|
76
|
-
* @returns {Viewer}
|
77
|
-
*/
|
78
|
-
setContent(html) {
|
79
|
-
this.setOption("content", html);
|
80
|
-
return this;
|
81
|
-
}
|
82
|
-
|
83
|
-
/**
|
84
|
-
*
|
85
|
-
* @param {Blob|URL|string} data
|
86
|
-
* @param {boolean} navigation
|
87
|
-
* @param {boolean} toolbar
|
88
|
-
* @param {boolean} scrollbar
|
89
|
-
*/
|
90
|
-
setPDF(data, navigation = true, toolbar = true, scrollbar = false) {
|
91
|
-
const hashes =
|
92
|
-
"#toolbar=" +
|
93
|
-
(toolbar ? "1" : "0") +
|
94
|
-
"&navpanes=" +
|
95
|
-
(navigation ? "1" : "0") +
|
96
|
-
"&scrollbar=" +
|
97
|
-
(scrollbar ? "1" : "0");
|
98
|
-
|
99
|
-
let pdfContent = "";
|
100
|
-
if (isBlob(data)) {
|
101
|
-
pdfContent = URL.createObjectURL(data);
|
102
|
-
pdfContent += hashes;
|
103
|
-
} else if (isURL(data)) {
|
104
|
-
pdfContent = data;
|
105
|
-
// check if the url already contains the hashes
|
106
|
-
if (pdfContent.indexOf("#") === -1) {
|
107
|
-
pdfContent += hashes;
|
108
|
-
}
|
109
|
-
} else if (isString(data)) {
|
110
|
-
//URL.createObjectURL(data);
|
111
|
-
const blobObj = new Blob([atob(data)], { type: "application/pdf" });
|
112
|
-
const url = window.URL.createObjectURL(blobObj);
|
113
|
-
|
114
|
-
pdfContent = data;
|
115
|
-
} else {
|
116
|
-
throw new Error("Blob or URL expected");
|
117
|
-
}
|
118
|
-
|
119
|
-
const html =
|
120
|
-
'<object data="' +
|
121
|
-
pdfContent +
|
122
|
-
'" width="100%" height="100%" type="application/pdf"></object>';
|
123
|
-
this.setContent(html);
|
124
|
-
}
|
125
|
-
|
126
|
-
/**
|
127
|
-
*
|
128
|
-
* @param {Blob|URL|string} data
|
129
|
-
*/
|
130
|
-
setImage(data) {
|
131
|
-
if (isBlob(data)) {
|
132
|
-
data = URL.createObjectURL(data);
|
133
|
-
} else if (isURL(data)) {
|
134
|
-
// nothing to do
|
135
|
-
} else if (isString(data)) {
|
136
|
-
// nothing to do
|
137
|
-
} else {
|
138
|
-
throw new Error("Blob or URL expected");
|
139
|
-
}
|
140
|
-
|
141
|
-
const html = '<img src="' + data + '" alt="image" />';
|
142
|
-
this.setContent(html);
|
143
|
-
}
|
144
|
-
|
145
|
-
/**
|
146
|
-
*
|
147
|
-
* if the data is a string, it is interpreted as html
|
148
|
-
* if the data is a url, the html is loaded from the url and set as content
|
149
|
-
* if the data is an HTMLElement, the outerHTML is used as content
|
150
|
-
*
|
151
|
-
* @param {HTMLElement|URL|string|Blob} data
|
152
|
-
*/
|
153
|
-
setHTML(data) {
|
154
|
-
if (data instanceof Blob) {
|
155
|
-
blobToText(data)
|
156
|
-
.then((html) => {
|
157
|
-
this.setHTML(html);
|
158
|
-
})
|
159
|
-
.catch((error) => {
|
160
|
-
throw new Error(error);
|
161
|
-
});
|
162
|
-
|
163
|
-
return;
|
164
|
-
} else if (data instanceof HTMLElement) {
|
165
|
-
data = data.outerHTML;
|
166
|
-
} else if (isString(data)) {
|
167
|
-
// nothing to do
|
168
|
-
} else if (isURL(data)) {
|
169
|
-
// fetch element
|
170
|
-
getGlobal()
|
171
|
-
.fetch(data)
|
172
|
-
.then((response) => {
|
173
|
-
return response.text();
|
174
|
-
})
|
175
|
-
.then((html) => {
|
176
|
-
this.setHTML(html);
|
177
|
-
})
|
178
|
-
.catch((error) => {
|
179
|
-
throw new Error(error);
|
180
|
-
});
|
181
|
-
} else {
|
182
|
-
throw new Error("HTMLElement or string expected");
|
183
|
-
}
|
184
|
-
|
185
|
-
this.setContent(data);
|
186
|
-
}
|
187
|
-
|
188
|
-
/**
|
189
|
-
*
|
190
|
-
* @return {Viewer}
|
191
|
-
*/
|
192
|
-
[assembleMethodSymbol]() {
|
193
|
-
super[assembleMethodSymbol]();
|
194
|
-
|
195
|
-
initControlReferences.call(this);
|
196
|
-
initEventHandler.call(this);
|
197
|
-
}
|
198
|
-
|
199
|
-
/**
|
200
|
-
*
|
201
|
-
* @return {string}
|
202
|
-
*/
|
203
|
-
static getTag() {
|
204
|
-
return "monster-viewer";
|
205
|
-
}
|
206
|
-
|
207
|
-
/**
|
208
|
-
* @return {CSSStyleSheet[]}
|
209
|
-
*/
|
210
|
-
static getCSSStyleSheet() {
|
211
|
-
return [ViewerStyleSheet];
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
/**
|
216
|
-
* @private
|
217
|
-
* @param variable
|
218
|
-
* @return {boolean}
|
219
|
-
*/
|
220
|
-
function isURL(variable) {
|
221
|
-
try {
|
222
|
-
new URL(variable);
|
223
|
-
return true;
|
224
|
-
} catch (error) {
|
225
|
-
return false;
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
/**
|
230
|
-
* @private
|
231
|
-
* @param variable
|
232
|
-
* @return {boolean}
|
233
|
-
*/
|
234
|
-
function isBlob(variable) {
|
235
|
-
return variable instanceof Blob;
|
236
|
-
}
|
237
|
-
|
238
|
-
/**
|
239
|
-
* @private
|
240
|
-
* @param blob
|
241
|
-
* @return {Promise<unknown>}
|
242
|
-
*/
|
243
|
-
function blobToText(blob) {
|
244
|
-
return new Promise((resolve, reject) => {
|
245
|
-
const reader = new FileReader();
|
246
|
-
reader.onloadend = () => resolve(reader.result);
|
247
|
-
reader.onerror = reject;
|
248
|
-
reader.readAsText(blob);
|
249
|
-
});
|
250
|
-
}
|
251
|
-
|
252
|
-
/**
|
253
|
-
* @private
|
254
|
-
* @return {Select}
|
255
|
-
* @throws {Error} no shadow-root is defined
|
256
|
-
*/
|
257
|
-
function initControlReferences() {
|
258
|
-
if (!this.shadowRoot) {
|
259
|
-
throw new Error("no shadow-root is defined");
|
260
|
-
}
|
261
|
-
|
262
|
-
this[viewerElementSymbol] = this.shadowRoot.getElementById("viewer");
|
263
|
-
}
|
264
|
-
|
265
|
-
/**
|
266
|
-
* @private
|
20
|
+
* @deprecated since 3.102.0 use Content/Viewer instead
|
267
21
|
*/
|
268
|
-
|
269
|
-
return this;
|
270
|
-
}
|
271
|
-
|
272
|
-
/**
|
273
|
-
* @private
|
274
|
-
* @return {string}
|
275
|
-
*/
|
276
|
-
function getTemplate() {
|
277
|
-
// language=HTML
|
278
|
-
return `
|
279
|
-
<div id="viewer" data-monster-role="viewer" part="viewer" data-monster-replace="path:content" data-monster-attributes="class path:classes.viewer">
|
280
|
-
</div>`;
|
281
|
-
}
|
282
|
-
|
283
|
-
registerCustomElement(Viewer);
|
22
|
+
class Viewer extends NewViewer {}
|
@@ -150,9 +150,9 @@ const resizeObserverSymbol = Symbol("resizeObserver");
|
|
150
150
|
* @example /examples/components/layout/tabs-active Active Tabs
|
151
151
|
* @example /examples/components/layout/tabs-removable Removable Tabs
|
152
152
|
*
|
153
|
-
* @issue https://localhost.alvine.dev:
|
154
|
-
* @issue https://localhost.alvine.dev:
|
155
|
-
* @issue https://localhost.alvine.dev:
|
153
|
+
* @issue https://localhost.alvine.dev:8440/development/issues/closed/268.html
|
154
|
+
* @issue https://localhost.alvine.dev:8440/development/issues/closed/271.html
|
155
|
+
* @issue https://localhost.alvine.dev:8440/development/issues/closed/273.html
|
156
156
|
*
|
157
157
|
* @since 3.74.0
|
158
158
|
* @copyright schukai GmbH
|
@@ -72,7 +72,7 @@ const removeEventHandlerSymbol = Symbol("removeEventHandler");
|
|
72
72
|
*
|
73
73
|
* @example /examples/components/notify/message-simple Message
|
74
74
|
*
|
75
|
-
* @issue https://localhost.alvine.dev:
|
75
|
+
* @issue https://localhost.alvine.dev:8440/development/issues/closed/269.html
|
76
76
|
*
|
77
77
|
* @since 1.0.0
|
78
78
|
* @copyright schukai GmbH
|
@@ -52,7 +52,7 @@ const queueSymbol = Symbol("queue");
|
|
52
52
|
* @example /examples/components/notify/notify-simple Notify
|
53
53
|
* @example /examples/components/notify/notify-inline Inline Notify
|
54
54
|
*
|
55
|
-
* @issue https://localhost.alvine.dev:
|
55
|
+
* @issue https://localhost.alvine.dev:8440/development/issues/closed/269.html
|
56
56
|
*
|
57
57
|
* @since 1.0.0
|
58
58
|
* @copyright schukai GmbH
|
@@ -964,7 +964,7 @@ function initOptionObserver() {
|
|
964
964
|
/**
|
965
965
|
* @private
|
966
966
|
* @return {object}
|
967
|
-
* @throws {TypeError} value is not
|
967
|
+
* @throws {TypeError} value is not an object
|
968
968
|
*/
|
969
969
|
function getOptionsFromScriptTag() {
|
970
970
|
if (!this.hasAttribute(ATTRIBUTE_OPTIONS_SELECTOR)) {
|