@startinblox/core 0.19.17 → 0.19.19
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/dist/index.js +73 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12857,17 +12857,22 @@ const SorterMixin = {
|
|
|
12857
12857
|
},
|
|
12858
12858
|
sortValuesByKey(key, asc) {
|
|
12859
12859
|
return function(a, b) {
|
|
12860
|
-
if (!a
|
|
12860
|
+
if (!a.hasOwnProperty(key))
|
|
12861
12861
|
return 1;
|
|
12862
|
-
if (!b
|
|
12862
|
+
if (!b.hasOwnProperty(key))
|
|
12863
12863
|
return -1;
|
|
12864
|
-
const varA =
|
|
12865
|
-
const varB =
|
|
12864
|
+
const varA = a[key];
|
|
12865
|
+
const varB = b[key];
|
|
12866
12866
|
let comparison = 0;
|
|
12867
|
-
if (varA
|
|
12868
|
-
comparison =
|
|
12869
|
-
|
|
12870
|
-
|
|
12867
|
+
if (typeof varA === "string" && typeof varB === "string") {
|
|
12868
|
+
comparison = varA.localeCompare(varB, void 0, { sensitivity: "base" });
|
|
12869
|
+
comparison = asc ? comparison : -comparison;
|
|
12870
|
+
} else {
|
|
12871
|
+
if (varA > varB)
|
|
12872
|
+
comparison = asc ? 1 : -1;
|
|
12873
|
+
else if (varA < varB)
|
|
12874
|
+
comparison = asc ? -1 : 1;
|
|
12875
|
+
}
|
|
12871
12876
|
return comparison;
|
|
12872
12877
|
};
|
|
12873
12878
|
},
|
|
@@ -50934,9 +50939,69 @@ const RichtextMixin = {
|
|
|
50934
50939
|
}
|
|
50935
50940
|
const ops = deltaMd.toDelta(this.value);
|
|
50936
50941
|
this.quill.setContents(ops);
|
|
50942
|
+
if (this.isRequired()) {
|
|
50943
|
+
this.createHiddenRequiredInput();
|
|
50944
|
+
this.quill.on("text-change", this.onTextChange.bind(this));
|
|
50945
|
+
}
|
|
50937
50946
|
const nextProcessor = listCallbacks.shift();
|
|
50938
50947
|
if (nextProcessor)
|
|
50939
50948
|
nextProcessor(value, listCallbacks);
|
|
50949
|
+
},
|
|
50950
|
+
isRequired() {
|
|
50951
|
+
return Array.from(this.element.attributes).some((attr) => attr.name === "required");
|
|
50952
|
+
},
|
|
50953
|
+
createHiddenRequiredInput() {
|
|
50954
|
+
const attributeName = this.getAttributeValue("name");
|
|
50955
|
+
this.hiddenInput = document.querySelector(`input[name="${attributeName + "-hidden"}"]`);
|
|
50956
|
+
if (!this.hiddenInput) {
|
|
50957
|
+
this.hiddenInput = this.createHiddenInput(attributeName + "-hidden");
|
|
50958
|
+
this.element.appendChild(this.hiddenInput);
|
|
50959
|
+
this.addInvalidEventListener();
|
|
50960
|
+
}
|
|
50961
|
+
this.hiddenInput.value = this.quill.getText();
|
|
50962
|
+
},
|
|
50963
|
+
createHiddenInput(attributeName) {
|
|
50964
|
+
const input = document.createElement("input");
|
|
50965
|
+
input.name = attributeName;
|
|
50966
|
+
input.setAttribute("required", "true");
|
|
50967
|
+
input.style.opacity = "0";
|
|
50968
|
+
input.style.position = "absolute";
|
|
50969
|
+
input.style.pointerEvents = "none";
|
|
50970
|
+
return input;
|
|
50971
|
+
},
|
|
50972
|
+
getAttributeValue(attributeName) {
|
|
50973
|
+
const attribute2 = Array.from(this.element.attributes).find((attr) => attr.name === attributeName);
|
|
50974
|
+
return attribute2 ? attribute2.value : "";
|
|
50975
|
+
},
|
|
50976
|
+
displayCustomErrorMessage(message) {
|
|
50977
|
+
const richtext = this.element.querySelector("[data-richtext]");
|
|
50978
|
+
if (richtext) {
|
|
50979
|
+
let errorMessageElement = richtext.querySelector(".required-error-message");
|
|
50980
|
+
if (!errorMessageElement) {
|
|
50981
|
+
errorMessageElement = document.createElement("div");
|
|
50982
|
+
errorMessageElement.className = "required-error-message";
|
|
50983
|
+
}
|
|
50984
|
+
richtext.appendChild(errorMessageElement);
|
|
50985
|
+
errorMessageElement.textContent = message;
|
|
50986
|
+
richtext.classList.add("error-border-richtext");
|
|
50987
|
+
}
|
|
50988
|
+
},
|
|
50989
|
+
addInvalidEventListener() {
|
|
50990
|
+
this.hiddenInput.addEventListener("invalid", (e) => {
|
|
50991
|
+
e.preventDefault();
|
|
50992
|
+
this.displayCustomErrorMessage("Please fill out this field.");
|
|
50993
|
+
});
|
|
50994
|
+
},
|
|
50995
|
+
onTextChange() {
|
|
50996
|
+
this.hiddenInput.value = this.quill.getText();
|
|
50997
|
+
this.removeErrorMessageAndStyling();
|
|
50998
|
+
},
|
|
50999
|
+
removeErrorMessageAndStyling() {
|
|
51000
|
+
const richtext = this.element.querySelector("[data-richtext]");
|
|
51001
|
+
let errorMessageElement = richtext.querySelector(".required-error-message");
|
|
51002
|
+
if (errorMessageElement)
|
|
51003
|
+
errorMessageElement.remove();
|
|
51004
|
+
richtext.classList.remove("error-border-richtext");
|
|
50940
51005
|
}
|
|
50941
51006
|
};
|
|
50942
51007
|
const callbackDirectory = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startinblox/core",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.19",
|
|
4
4
|
"description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|