@schukai/monster 4.136.11 → 4.136.13
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"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.136.
|
|
1
|
+
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"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.136.13"}
|
|
@@ -828,6 +828,16 @@ function initEventHandler() {
|
|
|
828
828
|
let suppressClickUntil = 0;
|
|
829
829
|
|
|
830
830
|
const isInteractiveDragTarget = (event) => {
|
|
831
|
+
if (
|
|
832
|
+
findTargetElementFromEvent(
|
|
833
|
+
event,
|
|
834
|
+
"data-monster-role",
|
|
835
|
+
"datatable-headers",
|
|
836
|
+
)
|
|
837
|
+
) {
|
|
838
|
+
return true;
|
|
839
|
+
}
|
|
840
|
+
|
|
831
841
|
if (
|
|
832
842
|
findTargetElementFromEvent(event, "data-monster-role", "resize-handle")
|
|
833
843
|
) {
|
|
@@ -1126,6 +1126,52 @@ function getSelectionSyncState() {
|
|
|
1126
1126
|
return { attrValue, selection, optionsLength };
|
|
1127
1127
|
}
|
|
1128
1128
|
|
|
1129
|
+
function hasSelectionLikeValue(candidate) {
|
|
1130
|
+
if (isArray(candidate)) {
|
|
1131
|
+
return candidate.some((entry) => {
|
|
1132
|
+
if (isObject(entry) && Object.prototype.hasOwnProperty.call(entry, "value")) {
|
|
1133
|
+
return hasSelectionLikeValue.call(this, entry.value);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
return hasSelectionLikeValue.call(this, entry);
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
if (isObject(candidate)) {
|
|
1141
|
+
for (const key of ["value", "id", "key"]) {
|
|
1142
|
+
if (Object.prototype.hasOwnProperty.call(candidate, key)) {
|
|
1143
|
+
return hasSelectionLikeValue.call(this, candidate[key]);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
if (candidate === undefined || candidate === null) {
|
|
1149
|
+
return false;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
if (isValueIsEmpty.call(this, candidate)) {
|
|
1153
|
+
return false;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
if (isString(candidate)) {
|
|
1157
|
+
return candidate.trim() !== "";
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
return true;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
function hasRequestedSelectionValue() {
|
|
1164
|
+
const pendingValue = this[pendingSelectionSymbol]?.value;
|
|
1165
|
+
const optionValue = this.getOption("value");
|
|
1166
|
+
const attrValue = this.getAttribute("value");
|
|
1167
|
+
|
|
1168
|
+
return (
|
|
1169
|
+
hasSelectionLikeValue.call(this, pendingValue) ||
|
|
1170
|
+
hasSelectionLikeValue.call(this, optionValue) ||
|
|
1171
|
+
hasSelectionLikeValue.call(this, attrValue)
|
|
1172
|
+
);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1129
1175
|
/**
|
|
1130
1176
|
* @private
|
|
1131
1177
|
* @param {number} version
|
|
@@ -2787,7 +2833,7 @@ function setSummaryAndControlText() {
|
|
|
2787
2833
|
current === msg ||
|
|
2788
2834
|
current === null
|
|
2789
2835
|
) {
|
|
2790
|
-
if (selections.length === 0) {
|
|
2836
|
+
if (selections.length === 0 && hasRequestedSelectionValue.call(this) !== true) {
|
|
2791
2837
|
this.setOption("messages.control", msg);
|
|
2792
2838
|
} else {
|
|
2793
2839
|
this.setOption("messages.control", "");
|
|
@@ -3988,7 +4034,7 @@ function areOptionsAvailableAndInitInternal() {
|
|
|
3988
4034
|
if (
|
|
3989
4035
|
selections === undefined ||
|
|
3990
4036
|
selections === null ||
|
|
3991
|
-
selections.length === 0
|
|
4037
|
+
(selections.length === 0 && hasRequestedSelectionValue.call(this) !== true)
|
|
3992
4038
|
) {
|
|
3993
4039
|
this.setOption(
|
|
3994
4040
|
"messages.control",
|
|
@@ -188,6 +188,55 @@ describe("Datatable drag scroll", function () {
|
|
|
188
188
|
expect(clickCount).to.equal(1);
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
+
it("does not start drag scroll from header interactions", async function () {
|
|
192
|
+
const mocks = document.getElementById("mocks");
|
|
193
|
+
const datatable = document.createElement("monster-datatable");
|
|
194
|
+
datatable.id = "drag-scroll-header-table";
|
|
195
|
+
datatable.innerHTML = `
|
|
196
|
+
<template id="drag-scroll-header-table-row">
|
|
197
|
+
<div data-monster-head="Name">Alpha</div>
|
|
198
|
+
<div data-monster-head="Value">Beta</div>
|
|
199
|
+
</template>
|
|
200
|
+
`;
|
|
201
|
+
datatable.setOption("data", [{}]);
|
|
202
|
+
mocks.appendChild(datatable);
|
|
203
|
+
|
|
204
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
205
|
+
|
|
206
|
+
const scroll = datatable.shadowRoot.querySelector(
|
|
207
|
+
"[data-monster-role=table-scroll]",
|
|
208
|
+
);
|
|
209
|
+
const headerCell = datatable.shadowRoot.querySelector(
|
|
210
|
+
"[data-monster-role=datatable-headers] > div",
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
expect(scroll).to.exist;
|
|
214
|
+
expect(headerCell).to.exist;
|
|
215
|
+
|
|
216
|
+
mockScrollableElement(scroll, {
|
|
217
|
+
clientWidth: 200,
|
|
218
|
+
scrollWidth: 600,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
scroll.scrollLeft = 120;
|
|
222
|
+
|
|
223
|
+
dispatchPointerEvent(headerCell, "pointerdown", {
|
|
224
|
+
clientX: 100,
|
|
225
|
+
clientY: 20,
|
|
226
|
+
});
|
|
227
|
+
dispatchPointerEvent(window, "pointermove", {
|
|
228
|
+
clientX: 40,
|
|
229
|
+
clientY: 24,
|
|
230
|
+
});
|
|
231
|
+
dispatchPointerEvent(window, "pointerup", {
|
|
232
|
+
clientX: 40,
|
|
233
|
+
clientY: 24,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
expect(scroll.scrollLeft).to.equal(120);
|
|
237
|
+
expect(scroll.classList.contains("is-dragging")).to.equal(false);
|
|
238
|
+
});
|
|
239
|
+
|
|
191
240
|
it("keeps double click copy for a single cell", async function () {
|
|
192
241
|
const mocks = document.getElementById("mocks");
|
|
193
242
|
const datatable = document.createElement("monster-datatable");
|
|
@@ -978,6 +978,44 @@ describe('Select', function () {
|
|
|
978
978
|
expect(select.getOption('messages.emptyOptions')).to.contain('Please consider modifying the filter');
|
|
979
979
|
});
|
|
980
980
|
|
|
981
|
+
it('should not show the select placeholder while a value sync is still pending', async function () {
|
|
982
|
+
this.timeout(3000);
|
|
983
|
+
|
|
984
|
+
let mocks = document.getElementById('mocks');
|
|
985
|
+
const savedGlobalQueueMicrotask = global.queueMicrotask;
|
|
986
|
+
const savedWindowQueueMicrotask = window.queueMicrotask;
|
|
987
|
+
const delayedQueueMicrotask = (callback) => setTimeout(callback, 50);
|
|
988
|
+
|
|
989
|
+
global.queueMicrotask = delayedQueueMicrotask;
|
|
990
|
+
window.queueMicrotask = delayedQueueMicrotask;
|
|
991
|
+
|
|
992
|
+
try {
|
|
993
|
+
const select = document.createElement('monster-select');
|
|
994
|
+
select.setOption('options', [
|
|
995
|
+
{label: 'Alpha', value: 'a'}
|
|
996
|
+
]);
|
|
997
|
+
select.setAttribute('value', 'a');
|
|
998
|
+
mocks.appendChild(select);
|
|
999
|
+
|
|
1000
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
1001
|
+
|
|
1002
|
+
expect(select.getOption('messages.control')).to.not.equal(
|
|
1003
|
+
select.getOption('labels.select-an-option')
|
|
1004
|
+
);
|
|
1005
|
+
|
|
1006
|
+
await waitForCondition(() => {
|
|
1007
|
+
return Array.isArray(select.getOption('selection')) &&
|
|
1008
|
+
select.getOption('selection').length === 1;
|
|
1009
|
+
});
|
|
1010
|
+
|
|
1011
|
+
expect(select.value).to.equal('a');
|
|
1012
|
+
expect(select.getOption('messages.control')).to.equal('');
|
|
1013
|
+
} finally {
|
|
1014
|
+
global.queueMicrotask = savedGlobalQueueMicrotask;
|
|
1015
|
+
window.queueMicrotask = savedWindowQueueMicrotask;
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
|
|
981
1019
|
it('should keep empty equivalent matching type-safe for numeric zero', function (done) {
|
|
982
1020
|
this.timeout(2000);
|
|
983
1021
|
|