@schukai/monster 4.136.11 → 4.136.12
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.12"}
|
|
@@ -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",
|
|
@@ -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
|
|