@schukai/monster 4.111.0 → 4.113.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 +21 -0
- package/package.json +1 -1
- package/source/components/form/select-link.mjs +275 -0
- package/source/components/form/select.mjs +290 -38
- package/source/components/layout/stylesheet/vertical-tabs.mjs +130 -0
- package/source/components/layout/vertical-tabs.mjs +1399 -0
- package/source/monster.mjs +2 -0
- package/test/cases/components/form/select.mjs +116 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
## [4.113.0] - 2026-01-30
|
|
6
|
+
|
|
7
|
+
### Add Features
|
|
8
|
+
|
|
9
|
+
- Improve selection handling in select.mjs
|
|
10
|
+
- Implement two linked selection components and associated functionality [#381](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/381)
|
|
11
|
+
- Add two selection dependency with UI and mock data
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- move mock to development mock
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [4.112.0] - 2026-01-29
|
|
19
|
+
|
|
20
|
+
### Add Features
|
|
21
|
+
|
|
22
|
+
- Add vertical tabs component for enhanced UI navigation [#380](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/380)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
5
26
|
## [4.111.0] - 2026-01-28
|
|
6
27
|
|
|
7
28
|
### Add Features
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@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":"4.
|
|
1
|
+
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@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":"4.113.0"}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright © Volker Schukai 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 Volker Schukai.
|
|
11
|
+
*
|
|
12
|
+
* SPDX-License-Identifier: AGPL-3.0
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { instanceSymbol } from "../../constants.mjs";
|
|
16
|
+
import {
|
|
17
|
+
assembleMethodSymbol,
|
|
18
|
+
registerCustomElement,
|
|
19
|
+
} from "../../dom/customelement.mjs";
|
|
20
|
+
import { addErrorAttribute } from "../../dom/error.mjs";
|
|
21
|
+
import { getDocument } from "../../dom/util.mjs";
|
|
22
|
+
import { isArray, isObject, isString } from "../../types/is.mjs";
|
|
23
|
+
import { CustomElement } from "../../dom/customelement.mjs";
|
|
24
|
+
|
|
25
|
+
export { SelectLink };
|
|
26
|
+
|
|
27
|
+
const sourceElementSymbol = Symbol("sourceElement");
|
|
28
|
+
const targetElementSymbol = Symbol("targetElement");
|
|
29
|
+
const observerSymbol = Symbol("observer");
|
|
30
|
+
const handlerSymbol = Symbol("handler");
|
|
31
|
+
const boundSymbol = Symbol("bound");
|
|
32
|
+
|
|
33
|
+
class SelectLink extends CustomElement {
|
|
34
|
+
static get [instanceSymbol]() {
|
|
35
|
+
return Symbol.for("@schukai/monster/components/form/select-link@@instance");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static getTag() {
|
|
39
|
+
return "monster-select-link";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get defaults() {
|
|
43
|
+
return Object.assign({}, super.defaults, {
|
|
44
|
+
shadowMode: false,
|
|
45
|
+
source: "",
|
|
46
|
+
target: "",
|
|
47
|
+
param: "",
|
|
48
|
+
emptyValue: "",
|
|
49
|
+
disableTarget: true,
|
|
50
|
+
clearSelection: true,
|
|
51
|
+
clearOptions: true,
|
|
52
|
+
clearTotalMessage: true,
|
|
53
|
+
clearMessageOnValue: true,
|
|
54
|
+
emptyMessage: "",
|
|
55
|
+
autoFetch: true,
|
|
56
|
+
autoFetchOnEmpty: false,
|
|
57
|
+
syncOnInit: true,
|
|
58
|
+
events: [
|
|
59
|
+
"monster-selected",
|
|
60
|
+
"monster-changed",
|
|
61
|
+
"monster-selection-removed",
|
|
62
|
+
"monster-selection-cleared",
|
|
63
|
+
],
|
|
64
|
+
debug: false,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[assembleMethodSymbol]() {
|
|
69
|
+
super[assembleMethodSymbol]();
|
|
70
|
+
bindSelects.call(this);
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
disconnectedCallback() {
|
|
75
|
+
unbindSelects.call(this);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function resolveElement(value) {
|
|
80
|
+
if (value instanceof HTMLElement) {
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!isString(value) || value.trim() === "") {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const selector = value.trim();
|
|
89
|
+
const doc = getDocument();
|
|
90
|
+
let element = null;
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
element = doc.querySelector(selector);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
element = null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!element) {
|
|
99
|
+
element = doc.getElementById(selector.replace(/^#/, ""));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return element instanceof HTMLElement ? element : null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function bindSelects() {
|
|
106
|
+
const source = resolveElement(this.getOption("source"));
|
|
107
|
+
const target = resolveElement(this.getOption("target"));
|
|
108
|
+
|
|
109
|
+
if (!(source && target)) {
|
|
110
|
+
if (!this[observerSymbol] && getDocument().body) {
|
|
111
|
+
const observer = new MutationObserver(() => {
|
|
112
|
+
bindSelects.call(this);
|
|
113
|
+
});
|
|
114
|
+
observer.observe(getDocument().body, {
|
|
115
|
+
childList: true,
|
|
116
|
+
subtree: true,
|
|
117
|
+
});
|
|
118
|
+
this[observerSymbol] = observer;
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (this[observerSymbol]) {
|
|
124
|
+
this[observerSymbol].disconnect();
|
|
125
|
+
delete this[observerSymbol];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this[sourceElementSymbol] = source;
|
|
129
|
+
this[targetElementSymbol] = target;
|
|
130
|
+
|
|
131
|
+
if (this[boundSymbol]) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const events = this.getOption("events");
|
|
136
|
+
const handler = () => syncTarget.call(this);
|
|
137
|
+
this[handlerSymbol] = handler;
|
|
138
|
+
|
|
139
|
+
if (isArray(events)) {
|
|
140
|
+
for (const eventName of events) {
|
|
141
|
+
if (isString(eventName) && eventName !== "") {
|
|
142
|
+
source.addEventListener(eventName, handler);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this[boundSymbol] = true;
|
|
148
|
+
|
|
149
|
+
if (this.getOption("syncOnInit") === true) {
|
|
150
|
+
queueMicrotask(() => {
|
|
151
|
+
syncTarget.call(this);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function unbindSelects() {
|
|
157
|
+
if (this[observerSymbol]) {
|
|
158
|
+
this[observerSymbol].disconnect();
|
|
159
|
+
delete this[observerSymbol];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const source = this[sourceElementSymbol];
|
|
163
|
+
const handler = this[handlerSymbol];
|
|
164
|
+
const events = this.getOption("events");
|
|
165
|
+
|
|
166
|
+
if (source && handler && isArray(events)) {
|
|
167
|
+
for (const eventName of events) {
|
|
168
|
+
if (isString(eventName) && eventName !== "") {
|
|
169
|
+
source.removeEventListener(eventName, handler);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
delete this[sourceElementSymbol];
|
|
175
|
+
delete this[targetElementSymbol];
|
|
176
|
+
delete this[handlerSymbol];
|
|
177
|
+
delete this[boundSymbol];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function syncTarget() {
|
|
181
|
+
const source = this[sourceElementSymbol];
|
|
182
|
+
const target = this[targetElementSymbol];
|
|
183
|
+
const param = this.getOption("param");
|
|
184
|
+
|
|
185
|
+
if (!(source && target)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (!isString(param) || param.trim() === "") {
|
|
190
|
+
addErrorAttribute(this, "Missing param option.");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
let value = source.value;
|
|
195
|
+
if (isArray(value)) {
|
|
196
|
+
value = value.join(",");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const isEmpty = value === null || value === undefined || value === "";
|
|
200
|
+
const emptyValue = this.getOption("emptyValue");
|
|
201
|
+
const autoFetch = this.getOption("autoFetch") === true;
|
|
202
|
+
const autoFetchOnEmpty = this.getOption("autoFetchOnEmpty") === true;
|
|
203
|
+
const disableTarget = this.getOption("disableTarget") === true;
|
|
204
|
+
const debug = this.getOption("debug") === true;
|
|
205
|
+
|
|
206
|
+
if (debug) {
|
|
207
|
+
console.log("[select-link]", {
|
|
208
|
+
source: source.id || source.tagName,
|
|
209
|
+
target: target.id || target.tagName,
|
|
210
|
+
param,
|
|
211
|
+
value,
|
|
212
|
+
isEmpty,
|
|
213
|
+
disableTarget,
|
|
214
|
+
autoFetch,
|
|
215
|
+
autoFetchOnEmpty,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (isEmpty) {
|
|
220
|
+
if (disableTarget === true) {
|
|
221
|
+
target.setAttribute("disabled", "");
|
|
222
|
+
if (debug) {
|
|
223
|
+
console.log("[select-link] target disabled (empty)");
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (this.getOption("clearSelection") === true) {
|
|
228
|
+
target.setOption("selection", []);
|
|
229
|
+
}
|
|
230
|
+
if (this.getOption("clearOptions") === true) {
|
|
231
|
+
target.setOption("options", []);
|
|
232
|
+
}
|
|
233
|
+
if (this.getOption("clearTotalMessage") === true) {
|
|
234
|
+
target.setOption("messages.total", "");
|
|
235
|
+
}
|
|
236
|
+
const emptyMessage = this.getOption("emptyMessage");
|
|
237
|
+
if (isString(emptyMessage) && emptyMessage !== "") {
|
|
238
|
+
target.setOption("messages.control", emptyMessage);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const params = Object.assign({}, target.getOption("filter.params", {}));
|
|
242
|
+
params[param] = emptyValue;
|
|
243
|
+
target.setOption("filter.params", params);
|
|
244
|
+
|
|
245
|
+
if (autoFetchOnEmpty && typeof target.fetch === "function") {
|
|
246
|
+
target.fetch().catch((e) => {
|
|
247
|
+
addErrorAttribute(target, e);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (disableTarget === true) {
|
|
254
|
+
target.removeAttribute("disabled");
|
|
255
|
+
if (debug) {
|
|
256
|
+
console.log("[select-link] target enabled (value)");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (this.getOption("clearMessageOnValue") === true) {
|
|
261
|
+
target.setOption("messages.control", "");
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const params = Object.assign({}, target.getOption("filter.params", {}));
|
|
265
|
+
params[param] = value;
|
|
266
|
+
target.setOption("filter.params", params);
|
|
267
|
+
|
|
268
|
+
if (autoFetch && typeof target.fetch === "function") {
|
|
269
|
+
target.fetch().catch((e) => {
|
|
270
|
+
addErrorAttribute(target, e);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
registerCustomElement(SelectLink);
|