@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
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,29 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
## [3.102.1] - 2025-01-29
|
6
|
+
|
7
|
+
### Bug Fixes
|
8
|
+
|
9
|
+
- move viewer to content folder
|
10
|
+
### Changes
|
11
|
+
|
12
|
+
- update node
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
## [3.102.0] - 2025-01-27
|
17
|
+
|
18
|
+
### Add Features
|
19
|
+
|
20
|
+
- new databind for int[] and string[]
|
21
|
+
- **select:** new ignoreValues feature [#287](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/287)
|
22
|
+
### Changes
|
23
|
+
|
24
|
+
- close issue [#285](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/285) [#286](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/286)
|
25
|
+
|
26
|
+
|
27
|
+
|
5
28
|
## [3.101.3] - 2025-01-27
|
6
29
|
|
7
30
|
### Bug Fixes
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.13","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"3.
|
1
|
+
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.13","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"3.102.1"}
|
@@ -75,7 +75,7 @@ const detectedLanguagesSymbol = Symbol("detectedLanguages");
|
|
75
75
|
* @example /examples/components/accessibility/locale-picker-simple Simple example
|
76
76
|
* @example /examples/components/accessibility/locale-picker-reset Reset Selection
|
77
77
|
*
|
78
|
-
* @issue https://localhost.alvine.dev:
|
78
|
+
* @issue https://localhost.alvine.dev:8440/development/issues/closed/276.html
|
79
79
|
*
|
80
80
|
* @since 3.97.0
|
81
81
|
* @copyright schukai GmbH
|
@@ -0,0 +1,289 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. All rights reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
*
|
5
|
+
* This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
|
6
|
+
* The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
|
7
|
+
*
|
8
|
+
* For those who do not wish to adhere to the AGPLv3, a commercial license is available.
|
9
|
+
* Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
|
10
|
+
* For more information about purchasing a commercial license, please contact schukai GmbH.
|
11
|
+
*
|
12
|
+
* SPDX-License-Identifier: AGPL-3.0
|
13
|
+
*/
|
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
|
+
|
26
|
+
export { Viewer };
|
27
|
+
|
28
|
+
/**
|
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
|
+
* @fragments /fragments/components/content/viewer
|
38
|
+
*
|
39
|
+
* @example /examples/components/content/pdf-viewer with a PDF
|
40
|
+
* @example /examples/components/content/image-viewer with an image
|
41
|
+
* @example /examples/components/content/html-viewer with HTML content
|
42
|
+
*
|
43
|
+
* @copyright schukai GmbH
|
44
|
+
* @summary A simple viewer component for PDF, HTML and images.
|
45
|
+
*/
|
46
|
+
class Viewer extends CustomElement {
|
47
|
+
/**
|
48
|
+
* This method is called by the `instanceof` operator.
|
49
|
+
* @return {symbol}
|
50
|
+
*/
|
51
|
+
static get [instanceSymbol]() {
|
52
|
+
return Symbol.for("@schukai/monster/components/content/viewer@@instance");
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* To set the options via the HTML tag, the attribute `data-monster-options` must be used.
|
57
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
58
|
+
*
|
59
|
+
* The individual configuration values can be found in the table.
|
60
|
+
*
|
61
|
+
* @property {Object} templates Template definitions
|
62
|
+
* @property {string} templates.main Main template
|
63
|
+
* @property {Object} classes Css classes
|
64
|
+
* @property {Object} features Feature definitions
|
65
|
+
*/
|
66
|
+
get defaults() {
|
67
|
+
return Object.assign({}, super.defaults, {
|
68
|
+
templates: {
|
69
|
+
main: getTemplate(),
|
70
|
+
},
|
71
|
+
content: "<slot></slot>",
|
72
|
+
classes: {
|
73
|
+
viewer: "",
|
74
|
+
},
|
75
|
+
features: {},
|
76
|
+
});
|
77
|
+
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
*
|
81
|
+
* @param {string} content
|
82
|
+
* @returns {Viewer}
|
83
|
+
*/
|
84
|
+
setContent(content) {
|
85
|
+
this.setOption("content", content);
|
86
|
+
return this;
|
87
|
+
}
|
88
|
+
|
89
|
+
/**
|
90
|
+
*
|
91
|
+
* @param {Blob|URL|string} data
|
92
|
+
* @param {boolean} navigation
|
93
|
+
* @param {boolean} toolbar
|
94
|
+
* @param {boolean} scrollbar
|
95
|
+
*/
|
96
|
+
setPDF(data, navigation = true, toolbar = true, scrollbar = false) {
|
97
|
+
const hashes =
|
98
|
+
"#toolbar=" +
|
99
|
+
(toolbar ? "1" : "0") +
|
100
|
+
"&navpanes=" +
|
101
|
+
(navigation ? "1" : "0") +
|
102
|
+
"&scrollbar=" +
|
103
|
+
(scrollbar ? "1" : "0");
|
104
|
+
|
105
|
+
let pdfContent = "";
|
106
|
+
if (isBlob(data)) {
|
107
|
+
pdfContent = URL.createObjectURL(data);
|
108
|
+
pdfContent += hashes;
|
109
|
+
} else if (isURL(data)) {
|
110
|
+
pdfContent = data;
|
111
|
+
// check if the url already contains the hashes
|
112
|
+
if (pdfContent.indexOf("#") === -1) {
|
113
|
+
pdfContent += hashes;
|
114
|
+
}
|
115
|
+
} else if (isString(data)) {
|
116
|
+
//URL.createObjectURL(data);
|
117
|
+
const blobObj = new Blob([atob(data)], { type: "application/pdf" });
|
118
|
+
const url = window.URL.createObjectURL(blobObj);
|
119
|
+
|
120
|
+
pdfContent = data;
|
121
|
+
} else {
|
122
|
+
throw new Error("Blob or URL expected");
|
123
|
+
}
|
124
|
+
|
125
|
+
const html =
|
126
|
+
'<object data="' +
|
127
|
+
pdfContent +
|
128
|
+
'" width="100%" height="100%" type="application/pdf"></object>';
|
129
|
+
this.setContent(html);
|
130
|
+
}
|
131
|
+
|
132
|
+
/**
|
133
|
+
*
|
134
|
+
* @param {Blob|URL|string} data
|
135
|
+
*/
|
136
|
+
setImage(data) {
|
137
|
+
if (isBlob(data)) {
|
138
|
+
data = URL.createObjectURL(data);
|
139
|
+
} else if (isURL(data)) {
|
140
|
+
// nothing to do
|
141
|
+
} else if (isString(data)) {
|
142
|
+
// nothing to do
|
143
|
+
} else {
|
144
|
+
throw new Error("Blob or URL expected");
|
145
|
+
}
|
146
|
+
|
147
|
+
const html = '<img src="' + data + '" alt="image" />';
|
148
|
+
this.setContent(html);
|
149
|
+
}
|
150
|
+
|
151
|
+
/**
|
152
|
+
*
|
153
|
+
* if the data is a string, it is interpreted as HTML.
|
154
|
+
* if the data is an url, the HTML is loaded from the url and set as content.
|
155
|
+
* if the data is an HTMLElement, the outerHTML is used as content.
|
156
|
+
*
|
157
|
+
* @param {HTMLElement|URL|string|Blob} data
|
158
|
+
*/
|
159
|
+
setHTML(data) {
|
160
|
+
if (data instanceof Blob) {
|
161
|
+
blobToText(data)
|
162
|
+
.then((html) => {
|
163
|
+
this.setHTML(html);
|
164
|
+
})
|
165
|
+
.catch((error) => {
|
166
|
+
throw new Error(error);
|
167
|
+
});
|
168
|
+
|
169
|
+
return;
|
170
|
+
} else if (data instanceof HTMLElement) {
|
171
|
+
data = data.outerHTML;
|
172
|
+
} else if (isString(data)) {
|
173
|
+
// nothing to do
|
174
|
+
} else if (isURL(data)) {
|
175
|
+
// fetch element
|
176
|
+
getGlobal()
|
177
|
+
.fetch(data)
|
178
|
+
.then((response) => {
|
179
|
+
return response.text();
|
180
|
+
})
|
181
|
+
.then((html) => {
|
182
|
+
this.setHTML(html);
|
183
|
+
})
|
184
|
+
.catch((error) => {
|
185
|
+
throw new Error(error);
|
186
|
+
});
|
187
|
+
} else {
|
188
|
+
throw new Error("HTMLElement or string expected");
|
189
|
+
}
|
190
|
+
|
191
|
+
this.setContent(data);
|
192
|
+
}
|
193
|
+
|
194
|
+
/**
|
195
|
+
*
|
196
|
+
* @return {Viewer}
|
197
|
+
*/
|
198
|
+
[assembleMethodSymbol]() {
|
199
|
+
super[assembleMethodSymbol]();
|
200
|
+
|
201
|
+
initControlReferences.call(this);
|
202
|
+
initEventHandler.call(this);
|
203
|
+
}
|
204
|
+
|
205
|
+
/**
|
206
|
+
*
|
207
|
+
* @return {string}
|
208
|
+
*/
|
209
|
+
static getTag() {
|
210
|
+
return "monster-viewer";
|
211
|
+
}
|
212
|
+
|
213
|
+
/**
|
214
|
+
* @return {CSSStyleSheet[]}
|
215
|
+
*/
|
216
|
+
static getCSSStyleSheet() {
|
217
|
+
return [ViewerStyleSheet];
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
/**
|
222
|
+
* @private
|
223
|
+
* @param variable
|
224
|
+
* @return {boolean}
|
225
|
+
*/
|
226
|
+
function isURL(variable) {
|
227
|
+
try {
|
228
|
+
new URL(variable);
|
229
|
+
return true;
|
230
|
+
} catch (error) {
|
231
|
+
return false;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
/**
|
236
|
+
* @private
|
237
|
+
* @param variable
|
238
|
+
* @return {boolean}
|
239
|
+
*/
|
240
|
+
function isBlob(variable) {
|
241
|
+
return variable instanceof Blob;
|
242
|
+
}
|
243
|
+
|
244
|
+
/**
|
245
|
+
* @private
|
246
|
+
* @param blob
|
247
|
+
* @return {Promise<unknown>}
|
248
|
+
*/
|
249
|
+
function blobToText(blob) {
|
250
|
+
return new Promise((resolve, reject) => {
|
251
|
+
const reader = new FileReader();
|
252
|
+
reader.onloadend = () => resolve(reader.result);
|
253
|
+
reader.onerror = reject;
|
254
|
+
reader.readAsText(blob);
|
255
|
+
});
|
256
|
+
}
|
257
|
+
|
258
|
+
/**
|
259
|
+
* @private
|
260
|
+
* @return {Select}
|
261
|
+
* @throws {Error} no shadow-root is defined
|
262
|
+
*/
|
263
|
+
function initControlReferences() {
|
264
|
+
if (!this.shadowRoot) {
|
265
|
+
throw new Error("no shadow-root is defined");
|
266
|
+
}
|
267
|
+
|
268
|
+
this[viewerElementSymbol] = this.shadowRoot.getElementById("viewer");
|
269
|
+
}
|
270
|
+
|
271
|
+
/**
|
272
|
+
* @private
|
273
|
+
*/
|
274
|
+
function initEventHandler() {
|
275
|
+
return this;
|
276
|
+
}
|
277
|
+
|
278
|
+
/**
|
279
|
+
* @private
|
280
|
+
* @return {string}
|
281
|
+
*/
|
282
|
+
function getTemplate() {
|
283
|
+
// language=HTML
|
284
|
+
return `
|
285
|
+
<div id="viewer" data-monster-role="viewer" part="viewer" data-monster-replace="path:content" data-monster-attributes="class path:classes.viewer">
|
286
|
+
</div>`;
|
287
|
+
}
|
288
|
+
|
289
|
+
registerCustomElement(Viewer);
|
@@ -53,7 +53,7 @@ const overlayLinkedElementSymbol = Symbol("overlayLinkedElement");
|
|
53
53
|
*
|
54
54
|
* @example /examples/components/datatable/change-button-simple Simple change button
|
55
55
|
*
|
56
|
-
* @issue https://localhost.alvine.dev:
|
56
|
+
* @issue https://localhost.alvine.dev:8440/development/issues/closed/274.html
|
57
57
|
*
|
58
58
|
* @copyright schukai GmbH
|
59
59
|
* @summary The Status component is used to show the current status of a datasource.
|
@@ -50,7 +50,7 @@ export { DataSet };
|
|
50
50
|
* @example /examples/components/datatable/dataset-dom Dom dataset
|
51
51
|
* @example /examples/components/datatable/dataset-rest Rest dataset
|
52
52
|
*
|
53
|
-
* @issue https://localhost.alvine.dev:
|
53
|
+
* @issue https://localhost.alvine.dev:8440/development/issues/closed/272.html
|
54
54
|
*
|
55
55
|
* @copyright schukai GmbH
|
56
56
|
* @summary A dataset component that can be used to show the data of a data source
|
@@ -70,7 +70,7 @@ const filterObserverSymbol = Symbol("filterObserver");
|
|
70
70
|
* @example /examples/components/datatable/datasource-rest-auto-init Auto init
|
71
71
|
* @example /examples/components/datatable/datasource-rest-do-fetch Rest datasource with fetch
|
72
72
|
*
|
73
|
-
* @issue https://localhost.alvine.dev:
|
73
|
+
* @issue https://localhost.alvine.dev:8440/development/issues/closed/272.html
|
74
74
|
*
|
75
75
|
* @copyright schukai GmbH
|
76
76
|
* @summary A rest api datasource for the datatable or other components
|
@@ -36,7 +36,7 @@ const dataSourceSymbol = Symbol.for(
|
|
36
36
|
*
|
37
37
|
* @example /examples/components/datatable/datasource
|
38
38
|
*
|
39
|
-
* @issue https://localhost.alvine.dev:
|
39
|
+
* @issue https://localhost.alvine.dev:8440/development/issues/closed/272.html
|
40
40
|
*
|
41
41
|
* @copyright schukai GmbH
|
42
42
|
* @summary A generic datasource
|