jedison 1.10.0 → 1.11.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 +11 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +78 -21
- 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 +9 -8
package/dist/esm/jedison.js
CHANGED
|
@@ -1821,8 +1821,6 @@ class Instance extends EventEmitter {
|
|
|
1821
1821
|
this.children = [];
|
|
1822
1822
|
this.ui = null;
|
|
1823
1823
|
this.isDirty = false;
|
|
1824
|
-
this.cachedErrors = null;
|
|
1825
|
-
this.cachedErrorsValue = void 0;
|
|
1826
1824
|
this.watched = {};
|
|
1827
1825
|
this.key = this.path.split(this.jedison.pathSeparator).pop();
|
|
1828
1826
|
this.arrayTemplateData = config.arrayTemplateData || {};
|
|
@@ -2034,7 +2032,6 @@ class Instance extends EventEmitter {
|
|
|
2034
2032
|
}
|
|
2035
2033
|
this.value = newValue;
|
|
2036
2034
|
this.isDirty = true;
|
|
2037
|
-
this.cachedErrors = null;
|
|
2038
2035
|
this.emit("set-value", newValue, initiator);
|
|
2039
2036
|
this.emit("change", initiator);
|
|
2040
2037
|
this.jedison.emit("instance-change", this, initiator);
|
|
@@ -2055,15 +2052,9 @@ class Instance extends EventEmitter {
|
|
|
2055
2052
|
if (!this.isActive) {
|
|
2056
2053
|
return [];
|
|
2057
2054
|
}
|
|
2058
|
-
|
|
2059
|
-
return this.cachedErrors;
|
|
2060
|
-
}
|
|
2061
|
-
const errors = removeDuplicatesFromArray(
|
|
2055
|
+
return removeDuplicatesFromArray(
|
|
2062
2056
|
this.jedison.validator.getErrors(this.getValueRaw(), this.originalSchema, this.getKey(), this.path)
|
|
2063
2057
|
);
|
|
2064
|
-
this.cachedErrorsValue = this.value;
|
|
2065
|
-
this.cachedErrors = errors;
|
|
2066
|
-
return errors;
|
|
2067
2058
|
}
|
|
2068
2059
|
/**
|
|
2069
2060
|
* Returns true if any leaf descendant is showing validation errors.
|
|
@@ -2800,8 +2791,8 @@ class InstanceMultiple extends Instance {
|
|
|
2800
2791
|
instance.off("notifyParent");
|
|
2801
2792
|
instance.on("notifyParent", (initiator) => {
|
|
2802
2793
|
this.value = this.activeInstance.getValueRaw();
|
|
2803
|
-
this.emit("notifyParent", initiator);
|
|
2804
2794
|
this.emit("change", initiator);
|
|
2795
|
+
this.emit("notifyParent", initiator);
|
|
2805
2796
|
});
|
|
2806
2797
|
this.instances.push(instance);
|
|
2807
2798
|
this.register();
|
|
@@ -2937,7 +2928,6 @@ class InstanceObject extends Instance {
|
|
|
2937
2928
|
Object.keys(value).forEach((propertyName) => {
|
|
2938
2929
|
const matchesPattern = compiledPatterns.some((re) => re.test(propertyName));
|
|
2939
2930
|
if (!hasOwn(this.properties, propertyName) && !matchesPattern) {
|
|
2940
|
-
console.warn("deleting", propertyName);
|
|
2941
2931
|
delete value[propertyName];
|
|
2942
2932
|
}
|
|
2943
2933
|
});
|
|
@@ -3266,7 +3256,8 @@ const glyphicons = {
|
|
|
3266
3256
|
info: "glyphicon glyphicon-question-sign",
|
|
3267
3257
|
close: "glyphicon glyphicon-remove",
|
|
3268
3258
|
edit: "glyphicon glyphicon-pencil",
|
|
3269
|
-
save: "glyphicon glyphicon-floppy-disk"
|
|
3259
|
+
save: "glyphicon glyphicon-floppy-disk",
|
|
3260
|
+
copy: "glyphicon glyphicon-copy"
|
|
3270
3261
|
};
|
|
3271
3262
|
const bootstrapIcons = {
|
|
3272
3263
|
properties: "bi bi-card-list",
|
|
@@ -3280,7 +3271,8 @@ const bootstrapIcons = {
|
|
|
3280
3271
|
info: "bi bi-question-circle",
|
|
3281
3272
|
close: "bi bi-x",
|
|
3282
3273
|
edit: "bi bi-pencil",
|
|
3283
|
-
save: "bi bi-floppy"
|
|
3274
|
+
save: "bi bi-floppy",
|
|
3275
|
+
copy: "bi bi-clipboard"
|
|
3284
3276
|
};
|
|
3285
3277
|
const fontAwesome3 = {
|
|
3286
3278
|
properties: "icon-list",
|
|
@@ -3294,7 +3286,8 @@ const fontAwesome3 = {
|
|
|
3294
3286
|
info: "icon-question-sign",
|
|
3295
3287
|
close: "icon-remove",
|
|
3296
3288
|
edit: "icon-pencil",
|
|
3297
|
-
save: "icon-save"
|
|
3289
|
+
save: "icon-save",
|
|
3290
|
+
copy: "icon-copy"
|
|
3298
3291
|
};
|
|
3299
3292
|
const fontAwesome4 = {
|
|
3300
3293
|
properties: "fa fa-list",
|
|
@@ -3308,7 +3301,8 @@ const fontAwesome4 = {
|
|
|
3308
3301
|
info: "fa fa-question-circle",
|
|
3309
3302
|
close: "fa fa-times",
|
|
3310
3303
|
edit: "fa fa-pencil",
|
|
3311
|
-
save: "fa fa-floppy-o"
|
|
3304
|
+
save: "fa fa-floppy-o",
|
|
3305
|
+
copy: "fa fa-clipboard"
|
|
3312
3306
|
};
|
|
3313
3307
|
const fontAwesome5 = {
|
|
3314
3308
|
properties: "fas fa-list",
|
|
@@ -3322,7 +3316,8 @@ const fontAwesome5 = {
|
|
|
3322
3316
|
info: "fas fa-question-circle",
|
|
3323
3317
|
close: "fas fa-times",
|
|
3324
3318
|
edit: "fas fa-pencil-alt",
|
|
3325
|
-
save: "fas fa-save"
|
|
3319
|
+
save: "fas fa-save",
|
|
3320
|
+
copy: "fas fa-clipboard"
|
|
3326
3321
|
};
|
|
3327
3322
|
const fontAwesome6 = {
|
|
3328
3323
|
properties: "fa-solid fa-list",
|
|
@@ -3336,7 +3331,8 @@ const fontAwesome6 = {
|
|
|
3336
3331
|
info: "fa-solid fa-circle-question",
|
|
3337
3332
|
close: "fa-solid fa-xmark",
|
|
3338
3333
|
edit: "fa-solid fa-pencil",
|
|
3339
|
-
save: "fa-solid fa-floppy-disk"
|
|
3334
|
+
save: "fa-solid fa-floppy-disk",
|
|
3335
|
+
copy: "fa-solid fa-clipboard"
|
|
3340
3336
|
};
|
|
3341
3337
|
class EditorBoolean extends Editor {
|
|
3342
3338
|
sanitize(value) {
|
|
@@ -4114,6 +4110,9 @@ class EditorObject extends Editor {
|
|
|
4114
4110
|
alert("Invalid JSON");
|
|
4115
4111
|
}
|
|
4116
4112
|
});
|
|
4113
|
+
this.control.jsonData.copyBtn.addEventListener("click", () => {
|
|
4114
|
+
navigator.clipboard.writeText(this.control.jsonData.input.value);
|
|
4115
|
+
});
|
|
4117
4116
|
this.control.jsonData.toggle.addEventListener("click", () => {
|
|
4118
4117
|
this.refreshJsonDataInputSize();
|
|
4119
4118
|
});
|
|
@@ -4586,6 +4585,9 @@ class EditorArray extends Editor {
|
|
|
4586
4585
|
this.addJsonDataEventListeners();
|
|
4587
4586
|
}
|
|
4588
4587
|
addJsonDataEventListeners() {
|
|
4588
|
+
this.control.jsonData.copyBtn.addEventListener("click", () => {
|
|
4589
|
+
navigator.clipboard.writeText(this.control.jsonData.input.value);
|
|
4590
|
+
});
|
|
4589
4591
|
this.control.jsonData.saveBtn.addEventListener("click", () => {
|
|
4590
4592
|
try {
|
|
4591
4593
|
const inputValue = JSON.parse(this.control.jsonData.input.value);
|
|
@@ -5313,7 +5315,7 @@ class EditorArrayNav extends EditorArray {
|
|
|
5313
5315
|
tabListCol.appendChild(tabList);
|
|
5314
5316
|
tabContentCol.appendChild(tabContent);
|
|
5315
5317
|
this.instance.children.forEach((child, index2) => {
|
|
5316
|
-
const { deleteBtn, moveUpBtn, moveDownBtn, btnGroup, addAfterBtn } = this.getButtons(index2);
|
|
5318
|
+
const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup, addAfterBtn } = this.getButtons(index2);
|
|
5317
5319
|
if (isSet(arrayDelete) && arrayDelete === true) {
|
|
5318
5320
|
btnGroup.appendChild(deleteBtn);
|
|
5319
5321
|
}
|
|
@@ -5324,6 +5326,9 @@ class EditorArrayNav extends EditorArray {
|
|
|
5324
5326
|
if (isSet(arrayAddAfter) && arrayAddAfter === true) {
|
|
5325
5327
|
btnGroup.appendChild(addAfterBtn);
|
|
5326
5328
|
}
|
|
5329
|
+
if (this.isSortable()) {
|
|
5330
|
+
btnGroup.appendChild(dragBtn);
|
|
5331
|
+
}
|
|
5327
5332
|
this.control.childrenSlot.appendChild(child.ui.control.container);
|
|
5328
5333
|
const schemaTitle = getSchemaTitle(child.schema);
|
|
5329
5334
|
const childTitle = isSet(schemaTitle) ? schemaTitle + " " + (index2 + 1) : child.getKey();
|
|
@@ -5370,11 +5375,32 @@ class EditorArrayNav extends EditorArray {
|
|
|
5370
5375
|
moveDownBtn.setAttribute("disabled", "");
|
|
5371
5376
|
}
|
|
5372
5377
|
});
|
|
5378
|
+
this.refreshSortable(tabList);
|
|
5373
5379
|
this.refreshDisabledState();
|
|
5374
5380
|
this.refreshAddBtn();
|
|
5375
5381
|
this.refreshDeleteAllBtn();
|
|
5376
5382
|
this.refreshJsonData();
|
|
5377
5383
|
}
|
|
5384
|
+
showValidationErrors(errors, force = false) {
|
|
5385
|
+
super.showValidationErrors(errors, force);
|
|
5386
|
+
this.refreshUI();
|
|
5387
|
+
}
|
|
5388
|
+
refreshSortable(container) {
|
|
5389
|
+
if (this.isSortable()) {
|
|
5390
|
+
if (this.sortable) {
|
|
5391
|
+
this.sortable.destroy();
|
|
5392
|
+
}
|
|
5393
|
+
this.sortable = window.Sortable.create(container, {
|
|
5394
|
+
animation: 150,
|
|
5395
|
+
handle: ".jedi-array-drag",
|
|
5396
|
+
disabled: this.disabled || this.readOnly,
|
|
5397
|
+
onEnd: (evt) => {
|
|
5398
|
+
this.activeItemIndex = evt.newIndex;
|
|
5399
|
+
this.instance.move(evt.oldIndex, evt.newIndex);
|
|
5400
|
+
}
|
|
5401
|
+
});
|
|
5402
|
+
}
|
|
5403
|
+
}
|
|
5378
5404
|
}
|
|
5379
5405
|
class EditorMultiple extends Editor {
|
|
5380
5406
|
static resolves(schema) {
|
|
@@ -5397,6 +5423,20 @@ class EditorMultiple extends Editor {
|
|
|
5397
5423
|
if (this.embedSwitcher) {
|
|
5398
5424
|
this.control.header.style.display = "none";
|
|
5399
5425
|
}
|
|
5426
|
+
this.instance.on("change", () => {
|
|
5427
|
+
const jedison = this.instance.jedison;
|
|
5428
|
+
const errors = jedison.getErrors(["error", "warning"]);
|
|
5429
|
+
const prefix = this.instance.path + "/";
|
|
5430
|
+
const matching = [];
|
|
5431
|
+
for (const inst of jedison.instances.values()) {
|
|
5432
|
+
if (inst.ui && inst.path.startsWith(prefix)) {
|
|
5433
|
+
matching.push(inst);
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
5436
|
+
for (const inst of matching.reverse()) {
|
|
5437
|
+
inst.ui.showValidationErrors(errors);
|
|
5438
|
+
}
|
|
5439
|
+
});
|
|
5400
5440
|
}
|
|
5401
5441
|
adaptForTable(td) {
|
|
5402
5442
|
this.theme.adaptForTableMultipleControl(this.control, td);
|
|
@@ -5842,16 +5882,20 @@ class EditorNumberRaty extends EditorNumber {
|
|
|
5842
5882
|
});
|
|
5843
5883
|
try {
|
|
5844
5884
|
const ratyOptions = getSchemaXOption(this.instance.schema, "raty") ?? {};
|
|
5845
|
-
this.raty = new Raty(this.control.placeholder, Object.assign({}, ratyOptions
|
|
5885
|
+
this.raty = new Raty(this.control.placeholder, Object.assign({}, ratyOptions, {
|
|
5846
5886
|
click: (score) => {
|
|
5847
5887
|
this.instance.setValue(score, true, "user");
|
|
5848
5888
|
}
|
|
5849
|
-
});
|
|
5889
|
+
}));
|
|
5850
5890
|
this.raty.init();
|
|
5851
5891
|
} catch (e) {
|
|
5852
5892
|
console.error("Raty is not available or not loaded correctly.", e);
|
|
5853
5893
|
}
|
|
5854
5894
|
}
|
|
5895
|
+
adaptForTable() {
|
|
5896
|
+
this.theme.visuallyHidden(this.control.label);
|
|
5897
|
+
this.theme.visuallyHidden(this.control.description);
|
|
5898
|
+
}
|
|
5855
5899
|
refreshDisabledState() {
|
|
5856
5900
|
if (this.disabled || this.readOnly) {
|
|
5857
5901
|
this.raty.readOnly(true);
|
|
@@ -7594,6 +7638,11 @@ class Theme {
|
|
|
7594
7638
|
input.style.overflowX = "auto";
|
|
7595
7639
|
input.style.resize = "both";
|
|
7596
7640
|
input.style.maxHeight = "60vh";
|
|
7641
|
+
const copyBtn = this.getButton({
|
|
7642
|
+
id: "jedi-json-data-copy-" + config.id,
|
|
7643
|
+
icon: "copy"
|
|
7644
|
+
});
|
|
7645
|
+
copyBtn.classList.add("jedi-json-data-copy");
|
|
7597
7646
|
const saveBtn = this.getButton({
|
|
7598
7647
|
// content: config.propertiesToggleContent, // todo: use text config or something
|
|
7599
7648
|
id: "jedi-json-data-save-" + config.id,
|
|
@@ -7602,12 +7651,14 @@ class Theme {
|
|
|
7602
7651
|
dialog.appendChild(control);
|
|
7603
7652
|
control.appendChild(label);
|
|
7604
7653
|
control.appendChild(input);
|
|
7654
|
+
dialog.appendChild(copyBtn);
|
|
7605
7655
|
dialog.appendChild(saveBtn);
|
|
7606
7656
|
return {
|
|
7607
7657
|
dialog,
|
|
7608
7658
|
toggle,
|
|
7609
7659
|
control,
|
|
7610
7660
|
input,
|
|
7661
|
+
copyBtn,
|
|
7611
7662
|
saveBtn
|
|
7612
7663
|
};
|
|
7613
7664
|
}
|
|
@@ -8874,6 +8925,8 @@ class ThemeBootstrap3 extends Theme {
|
|
|
8874
8925
|
const jsonData = super.getJsonData(config);
|
|
8875
8926
|
jsonData.control.classList.add("form-group");
|
|
8876
8927
|
jsonData.input.classList.add("form-control");
|
|
8928
|
+
jsonData.copyBtn.classList.add("btn-default");
|
|
8929
|
+
jsonData.copyBtn.classList.add("btn-block");
|
|
8877
8930
|
jsonData.saveBtn.classList.add("btn-primary");
|
|
8878
8931
|
jsonData.saveBtn.classList.add("btn-block");
|
|
8879
8932
|
return jsonData;
|
|
@@ -9239,6 +9292,8 @@ class ThemeBootstrap4 extends Theme {
|
|
|
9239
9292
|
const jsonData = super.getJsonData(config);
|
|
9240
9293
|
jsonData.control.classList.add("form-group");
|
|
9241
9294
|
jsonData.input.classList.add("form-control");
|
|
9295
|
+
jsonData.copyBtn.classList.add("btn-secondary");
|
|
9296
|
+
jsonData.copyBtn.classList.add("btn-block");
|
|
9242
9297
|
jsonData.saveBtn.classList.add("btn-primary");
|
|
9243
9298
|
jsonData.saveBtn.classList.add("btn-block");
|
|
9244
9299
|
return jsonData;
|
|
@@ -9623,6 +9678,8 @@ class ThemeBootstrap5 extends Theme {
|
|
|
9623
9678
|
const jsonData = super.getJsonData(config);
|
|
9624
9679
|
jsonData.control.classList.add("mb-3");
|
|
9625
9680
|
jsonData.input.classList.add("form-control");
|
|
9681
|
+
jsonData.copyBtn.classList.add("btn-secondary");
|
|
9682
|
+
jsonData.copyBtn.classList.add("w-100");
|
|
9626
9683
|
jsonData.saveBtn.classList.add("btn-primary");
|
|
9627
9684
|
jsonData.saveBtn.classList.add("w-100");
|
|
9628
9685
|
return jsonData;
|