jedison 1.9.0 → 1.10.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 +10 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +90 -11
- package/dist/esm/jedison.js.map +1 -1
- package/dist/umd/jedison.umd.js +1 -1
- package/dist/umd/jedison.umd.js.map +1 -1
- package/package.json +8 -4
package/dist/esm/jedison.js
CHANGED
|
@@ -116,11 +116,13 @@ function getType(value) {
|
|
|
116
116
|
}
|
|
117
117
|
return type2;
|
|
118
118
|
}
|
|
119
|
+
const UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
119
120
|
function mergeDeep(target, ...sources) {
|
|
120
121
|
if (!sources.length) return target;
|
|
121
122
|
const source = sources.shift();
|
|
122
123
|
if (isObject(target) && isObject(source)) {
|
|
123
124
|
Object.keys(source).forEach((key) => {
|
|
125
|
+
if (UNSAFE_KEYS.has(key)) return;
|
|
124
126
|
if (isObject(source[key])) {
|
|
125
127
|
if (!target[key]) {
|
|
126
128
|
Object.assign(target, {
|
|
@@ -144,6 +146,7 @@ function combineDeep(target, ...sources) {
|
|
|
144
146
|
target.push(...source);
|
|
145
147
|
} else if (isObject(target) && isObject(source)) {
|
|
146
148
|
Object.keys(source).forEach((key) => {
|
|
149
|
+
if (UNSAFE_KEYS.has(key)) return;
|
|
147
150
|
if (isObject(source[key])) {
|
|
148
151
|
if (!target[key]) {
|
|
149
152
|
Object.assign(target, {
|
|
@@ -2478,6 +2481,7 @@ class Editor {
|
|
|
2478
2481
|
* Destroys the editor
|
|
2479
2482
|
*/
|
|
2480
2483
|
destroy() {
|
|
2484
|
+
this.clearStoredEventListeners();
|
|
2481
2485
|
if (this.control.container && this.control.container.parentNode) {
|
|
2482
2486
|
this.control.container.parentNode.removeChild(this.control.container);
|
|
2483
2487
|
}
|
|
@@ -2696,6 +2700,9 @@ class InstanceIfThenElse extends Instance {
|
|
|
2696
2700
|
return this.activeInstance ? this.activeInstance.hasNestedValidationErrors() : false;
|
|
2697
2701
|
}
|
|
2698
2702
|
destroy() {
|
|
2703
|
+
if (this.instanceWithoutIf) {
|
|
2704
|
+
this.instanceWithoutIf.destroy();
|
|
2705
|
+
}
|
|
2699
2706
|
this.instances.forEach((instance) => {
|
|
2700
2707
|
instance.destroy();
|
|
2701
2708
|
});
|
|
@@ -4891,7 +4898,7 @@ class EditorArrayTable extends EditorArray {
|
|
|
4891
4898
|
const infoContent = this.getInfo(schemaItems);
|
|
4892
4899
|
const info = this.theme.getInfo(infoContent);
|
|
4893
4900
|
if (schemaXInfo.variant === "modal") {
|
|
4894
|
-
this.theme.infoAsModal(info, this.getIdFromPath(this.instance.path), infoContent);
|
|
4901
|
+
this.theme.infoAsModal(info, this.getIdFromPath(this.instance.path) + "-item", infoContent);
|
|
4895
4902
|
}
|
|
4896
4903
|
thTitle.appendChild(info.container);
|
|
4897
4904
|
}
|
|
@@ -5029,7 +5036,7 @@ class EditorArrayTableObject extends EditorArray {
|
|
|
5029
5036
|
schemaItems = this.instance.jedison.refParser.expand(schemaItems);
|
|
5030
5037
|
}
|
|
5031
5038
|
const itemProperties = getSchemaProperties(schemaItems);
|
|
5032
|
-
Object.
|
|
5039
|
+
Object.entries(itemProperties).forEach(([propertyKey, propertySchema]) => {
|
|
5033
5040
|
const th2 = this.theme.getTableHeader();
|
|
5034
5041
|
if (propertySchema.title) {
|
|
5035
5042
|
const fakeLabel = this.theme.getFakeLabel({
|
|
@@ -5042,7 +5049,7 @@ class EditorArrayTableObject extends EditorArray {
|
|
|
5042
5049
|
const infoContent = this.getInfo(propertySchema);
|
|
5043
5050
|
const info = this.theme.getInfo(infoContent);
|
|
5044
5051
|
if (schemaXInfo.variant === "modal") {
|
|
5045
|
-
this.theme.infoAsModal(info, this.getIdFromPath(this.instance.path), infoContent);
|
|
5052
|
+
this.theme.infoAsModal(info, this.getIdFromPath(this.instance.path) + "-" + propertyKey, infoContent);
|
|
5046
5053
|
}
|
|
5047
5054
|
th2.appendChild(info.container);
|
|
5048
5055
|
}
|
|
@@ -5629,6 +5636,69 @@ class EditorStringJodit extends EditorString {
|
|
|
5629
5636
|
super.destroy();
|
|
5630
5637
|
}
|
|
5631
5638
|
}
|
|
5639
|
+
class EditorStringPickr extends EditorString {
|
|
5640
|
+
static resolves(schema) {
|
|
5641
|
+
const format2 = getSchemaXOption(schema, "format");
|
|
5642
|
+
return isSet(format2) && format2 === "pickr" && window.Pickr && getSchemaType(schema) === "string";
|
|
5643
|
+
}
|
|
5644
|
+
build() {
|
|
5645
|
+
this.control = this.theme.getPlaceholderControl({
|
|
5646
|
+
title: this.getTitle(),
|
|
5647
|
+
description: this.getDescription(),
|
|
5648
|
+
id: this.getIdFromPath(this.instance.path),
|
|
5649
|
+
titleIconClass: getSchemaXOption(this.instance.schema, "titleIconClass"),
|
|
5650
|
+
titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
|
|
5651
|
+
info: this.getInfo()
|
|
5652
|
+
});
|
|
5653
|
+
const pickrOptions = getSchemaXOption(this.instance.schema, "pickr") ?? {};
|
|
5654
|
+
try {
|
|
5655
|
+
this.pickr = window.Pickr.create({
|
|
5656
|
+
el: this.control.placeholder,
|
|
5657
|
+
default: this.instance.getValue() || "#000000",
|
|
5658
|
+
comparison: false,
|
|
5659
|
+
...pickrOptions
|
|
5660
|
+
});
|
|
5661
|
+
const updateValue = (color) => {
|
|
5662
|
+
const value = color ? color.toHEXA().toString() : "";
|
|
5663
|
+
this.updatingFromPickr = true;
|
|
5664
|
+
this.instance.setValue(value, true, "user");
|
|
5665
|
+
this.updatingFromPickr = false;
|
|
5666
|
+
};
|
|
5667
|
+
this.pickr.on("change", (color) => {
|
|
5668
|
+
updateValue(color);
|
|
5669
|
+
this.pickr.applyColor(true);
|
|
5670
|
+
});
|
|
5671
|
+
this.pickr.on("save", updateValue);
|
|
5672
|
+
this.pickr.on("hide", () => updateValue(this.pickr.getColor()));
|
|
5673
|
+
this.refreshUI();
|
|
5674
|
+
} catch (e) {
|
|
5675
|
+
console.error("Pickr is not available or not loaded correctly.", e);
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5678
|
+
addEventListeners() {
|
|
5679
|
+
}
|
|
5680
|
+
refreshUI() {
|
|
5681
|
+
if (!this.pickr) return;
|
|
5682
|
+
this.refreshTemplates();
|
|
5683
|
+
if (this.disabled) {
|
|
5684
|
+
this.pickr.disable();
|
|
5685
|
+
} else {
|
|
5686
|
+
this.pickr.enable();
|
|
5687
|
+
}
|
|
5688
|
+
if (!this.updatingFromPickr) {
|
|
5689
|
+
const value = this.instance.getValue();
|
|
5690
|
+
if (value) {
|
|
5691
|
+
this.pickr.setColor(value, true);
|
|
5692
|
+
}
|
|
5693
|
+
}
|
|
5694
|
+
}
|
|
5695
|
+
destroy() {
|
|
5696
|
+
if (this.pickr) {
|
|
5697
|
+
this.pickr.destroyAndRemove();
|
|
5698
|
+
}
|
|
5699
|
+
super.destroy();
|
|
5700
|
+
}
|
|
5701
|
+
}
|
|
5632
5702
|
class EditorStringFlatpickr extends EditorString {
|
|
5633
5703
|
static resolves(schema) {
|
|
5634
5704
|
const format2 = getSchemaXOption(schema, "format");
|
|
@@ -6149,6 +6219,7 @@ class UiResolver {
|
|
|
6149
6219
|
EditorStringSimpleMDE,
|
|
6150
6220
|
EditorStringQuill,
|
|
6151
6221
|
EditorStringJodit,
|
|
6222
|
+
EditorStringPickr,
|
|
6152
6223
|
EditorStringFlatpickr,
|
|
6153
6224
|
EditorStringIMask,
|
|
6154
6225
|
EditorStringAce,
|
|
@@ -6636,13 +6707,15 @@ class Jedison extends EventEmitter {
|
|
|
6636
6707
|
}, 0);
|
|
6637
6708
|
}
|
|
6638
6709
|
});
|
|
6639
|
-
|
|
6710
|
+
this._onFocus = (event) => {
|
|
6640
6711
|
this.lastKeyEvent = null;
|
|
6641
6712
|
this.lastFocusedId = event.target.id;
|
|
6642
|
-
}
|
|
6643
|
-
|
|
6713
|
+
};
|
|
6714
|
+
this._onKeydown = (event) => {
|
|
6644
6715
|
this.lastKeyEvent = event;
|
|
6645
|
-
}
|
|
6716
|
+
};
|
|
6717
|
+
document.addEventListener("focus", this._onFocus, true);
|
|
6718
|
+
document.addEventListener("keydown", this._onKeydown);
|
|
6646
6719
|
}
|
|
6647
6720
|
}
|
|
6648
6721
|
updateInstancesWatchedData() {
|
|
@@ -6954,6 +7027,10 @@ class Jedison extends EventEmitter {
|
|
|
6954
7027
|
* Destroy the root instance and it's children
|
|
6955
7028
|
*/
|
|
6956
7029
|
destroy() {
|
|
7030
|
+
if (this._onFocus) {
|
|
7031
|
+
document.removeEventListener("focus", this._onFocus, true);
|
|
7032
|
+
document.removeEventListener("keydown", this._onKeydown);
|
|
7033
|
+
}
|
|
6957
7034
|
this.root.destroy();
|
|
6958
7035
|
if (this.options.container) {
|
|
6959
7036
|
this.container.innerHTML = "";
|
|
@@ -7462,7 +7539,7 @@ class Theme {
|
|
|
7462
7539
|
const html = document.createElement("dialog");
|
|
7463
7540
|
html.classList.add("jedi-properties-slot");
|
|
7464
7541
|
html.setAttribute("id", config.id);
|
|
7465
|
-
|
|
7542
|
+
html.addEventListener("click", (event) => {
|
|
7466
7543
|
if (event.target === html) {
|
|
7467
7544
|
html.close();
|
|
7468
7545
|
}
|
|
@@ -7473,7 +7550,7 @@ class Theme {
|
|
|
7473
7550
|
const html = document.createElement("dialog");
|
|
7474
7551
|
html.classList.add("jedi-quick-add-property-slot");
|
|
7475
7552
|
html.setAttribute("id", config.id);
|
|
7476
|
-
|
|
7553
|
+
html.addEventListener("click", (event) => {
|
|
7477
7554
|
if (event.target === html) {
|
|
7478
7555
|
html.close();
|
|
7479
7556
|
}
|
|
@@ -7487,7 +7564,7 @@ class Theme {
|
|
|
7487
7564
|
const dialog = document.createElement("dialog");
|
|
7488
7565
|
dialog.classList.add("jedi-json-data");
|
|
7489
7566
|
dialog.setAttribute("id", config.id);
|
|
7490
|
-
|
|
7567
|
+
dialog.addEventListener("click", (event) => {
|
|
7491
7568
|
if (event.target === dialog) {
|
|
7492
7569
|
dialog.close();
|
|
7493
7570
|
}
|
|
@@ -7751,6 +7828,7 @@ class Theme {
|
|
|
7751
7828
|
icon: "close"
|
|
7752
7829
|
});
|
|
7753
7830
|
dialog.classList.add("jedi-modal-dialog");
|
|
7831
|
+
dialog.setAttribute("id", id + "-modal");
|
|
7754
7832
|
title.classList.add("jedi-modal-title");
|
|
7755
7833
|
if (isString(config.title)) {
|
|
7756
7834
|
title.innerHTML = config.title;
|
|
@@ -7761,7 +7839,7 @@ class Theme {
|
|
|
7761
7839
|
}
|
|
7762
7840
|
closeBtn.classList.add("jedi-modal-close");
|
|
7763
7841
|
closeBtn.setAttribute("always-enabled", "");
|
|
7764
|
-
|
|
7842
|
+
dialog.addEventListener("click", (event) => {
|
|
7765
7843
|
if (event.target === dialog) {
|
|
7766
7844
|
dialog.close();
|
|
7767
7845
|
}
|
|
@@ -9907,6 +9985,7 @@ const index = {
|
|
|
9907
9985
|
EditorStringSelect,
|
|
9908
9986
|
EditorStringTextarea,
|
|
9909
9987
|
EditorStringAwesomplete,
|
|
9988
|
+
EditorStringPickr,
|
|
9910
9989
|
EditorStringInput,
|
|
9911
9990
|
EditorNumberRange,
|
|
9912
9991
|
EditorNumber,
|