jedison 1.3.5 → 1.4.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 +9 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +62 -5
- 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 +2 -2
package/dist/esm/jedison.js
CHANGED
|
@@ -1912,6 +1912,16 @@ class Instance extends EventEmitter {
|
|
|
1912
1912
|
const errors = this.jedison.validator.getErrors(this.getValue(), this.originalSchema, this.getKey(), this.path);
|
|
1913
1913
|
return removeDuplicatesFromArray(errors);
|
|
1914
1914
|
}
|
|
1915
|
+
/**
|
|
1916
|
+
* Returns true if any leaf descendant is showing validation errors.
|
|
1917
|
+
* Only checks leaves to avoid stale container-level constraint flags.
|
|
1918
|
+
*/
|
|
1919
|
+
hasNestedValidationErrors() {
|
|
1920
|
+
if (this.children.length === 0) {
|
|
1921
|
+
return !!(this.ui && this.ui.showingValidationErrors);
|
|
1922
|
+
}
|
|
1923
|
+
return this.children.some((child) => child.hasNestedValidationErrors());
|
|
1924
|
+
}
|
|
1915
1925
|
/**
|
|
1916
1926
|
* Prepare data before building the editor
|
|
1917
1927
|
*/
|
|
@@ -2112,8 +2122,9 @@ class Editor {
|
|
|
2112
2122
|
if (neverShowErrors && !force || errors.length === 0) {
|
|
2113
2123
|
return;
|
|
2114
2124
|
}
|
|
2125
|
+
const muteValidationMessages = getSchemaXOption(this.instance.schema, "muteValidationMessages") ?? this.instance.jedison.options.muteValidationMessages ?? [];
|
|
2115
2126
|
errors.forEach((error) => {
|
|
2116
|
-
if (error.constraint
|
|
2127
|
+
if (muteValidationMessages.includes(error.constraint)) {
|
|
2117
2128
|
return;
|
|
2118
2129
|
}
|
|
2119
2130
|
error.messages.forEach((message) => {
|
|
@@ -2497,6 +2508,9 @@ class InstanceIfThenElse extends Instance {
|
|
|
2497
2508
|
});
|
|
2498
2509
|
return fittestIndex;
|
|
2499
2510
|
}
|
|
2511
|
+
hasNestedValidationErrors() {
|
|
2512
|
+
return this.activeInstance ? this.activeInstance.hasNestedValidationErrors() : false;
|
|
2513
|
+
}
|
|
2500
2514
|
destroy() {
|
|
2501
2515
|
this.instances.forEach((instance) => {
|
|
2502
2516
|
instance.destroy();
|
|
@@ -2640,6 +2654,9 @@ class InstanceMultiple extends Instance {
|
|
|
2640
2654
|
}
|
|
2641
2655
|
return fittestIndex;
|
|
2642
2656
|
}
|
|
2657
|
+
hasNestedValidationErrors() {
|
|
2658
|
+
return this.activeInstance ? this.activeInstance.hasNestedValidationErrors() : false;
|
|
2659
|
+
}
|
|
2643
2660
|
destroy() {
|
|
2644
2661
|
this.instances.forEach((instance) => {
|
|
2645
2662
|
instance.destroy();
|
|
@@ -2822,8 +2839,8 @@ class InstanceObject extends Instance {
|
|
|
2822
2839
|
});
|
|
2823
2840
|
this.value = value;
|
|
2824
2841
|
this.jedison.emit("instance-change", this, initiator);
|
|
2825
|
-
this.emit("notifyParent", initiator);
|
|
2826
2842
|
this.emit("change", initiator);
|
|
2843
|
+
this.emit("notifyParent", initiator);
|
|
2827
2844
|
}
|
|
2828
2845
|
/**
|
|
2829
2846
|
* Sorts the children of the current instance based on their `propertyOrder` value in ascending order.
|
|
@@ -2974,8 +2991,8 @@ class InstanceArray extends Instance {
|
|
|
2974
2991
|
});
|
|
2975
2992
|
this.value = value;
|
|
2976
2993
|
this.jedison.emit("instance-change", this, initiator);
|
|
2977
|
-
this.emit("notifyParent", initiator);
|
|
2978
2994
|
this.emit("change", initiator);
|
|
2995
|
+
this.emit("notifyParent", initiator);
|
|
2979
2996
|
}
|
|
2980
2997
|
refreshChildren() {
|
|
2981
2998
|
this.children = [];
|
|
@@ -3880,7 +3897,7 @@ class EditorObjectNav extends EditorObject {
|
|
|
3880
3897
|
const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
|
|
3881
3898
|
const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
|
|
3882
3899
|
const tab = this.theme.getTab({
|
|
3883
|
-
hasErrors: navWarning && child.
|
|
3900
|
+
hasErrors: navWarning && child.hasNestedValidationErrors(),
|
|
3884
3901
|
navWarningMessage,
|
|
3885
3902
|
title: isSet(schemaTitle) ? schemaTitle : child.getKey(),
|
|
3886
3903
|
id,
|
|
@@ -4072,6 +4089,45 @@ class EditorArray extends Editor {
|
|
|
4072
4089
|
this.refreshJsonData();
|
|
4073
4090
|
}
|
|
4074
4091
|
}
|
|
4092
|
+
class EditorArrayTuple extends EditorArray {
|
|
4093
|
+
static resolves(schema) {
|
|
4094
|
+
const type2 = getSchemaType(schema);
|
|
4095
|
+
const format2 = getSchemaX(schema, "format");
|
|
4096
|
+
const prefixItems2 = getSchemaPrefixItems(schema);
|
|
4097
|
+
return type2 === "array" && format2 === "tuple" && isSet(prefixItems2);
|
|
4098
|
+
}
|
|
4099
|
+
build() {
|
|
4100
|
+
super.build();
|
|
4101
|
+
this.control.addBtn.style.display = "none";
|
|
4102
|
+
}
|
|
4103
|
+
addEventListeners() {
|
|
4104
|
+
this.addJsonDataEventListeners();
|
|
4105
|
+
}
|
|
4106
|
+
refreshUI() {
|
|
4107
|
+
this.control.childrenSlot.innerHTML = "";
|
|
4108
|
+
const table = this.theme.getTable();
|
|
4109
|
+
this.control.childrenSlot.appendChild(table.container);
|
|
4110
|
+
const schemaPrefixItems = getSchemaPrefixItems(this.instance.schema);
|
|
4111
|
+
schemaPrefixItems.forEach((prefixItemSchema) => {
|
|
4112
|
+
const th = this.theme.getTableHeader();
|
|
4113
|
+
const { label } = this.theme.getFakeLabel({
|
|
4114
|
+
content: getSchemaTitle(prefixItemSchema) ?? ""
|
|
4115
|
+
});
|
|
4116
|
+
th.appendChild(label);
|
|
4117
|
+
table.thead.appendChild(th);
|
|
4118
|
+
});
|
|
4119
|
+
const tbodyRow = document.createElement("tr");
|
|
4120
|
+
this.instance.children.forEach((child) => {
|
|
4121
|
+
const td = this.theme.getTableDefinition();
|
|
4122
|
+
child.ui.adaptForTable(child, td);
|
|
4123
|
+
td.appendChild(child.ui.control.container);
|
|
4124
|
+
tbodyRow.appendChild(td);
|
|
4125
|
+
});
|
|
4126
|
+
table.tbody.appendChild(tbodyRow);
|
|
4127
|
+
this.refreshJsonData();
|
|
4128
|
+
this.refreshDisabledState();
|
|
4129
|
+
}
|
|
4130
|
+
}
|
|
4075
4131
|
class EditorArrayTable extends EditorArray {
|
|
4076
4132
|
static resolves(schema, refParser) {
|
|
4077
4133
|
return getSchemaType(schema) === "array" && getSchemaXOption(schema, "format") === "table";
|
|
@@ -4463,7 +4519,7 @@ class EditorArrayNav extends EditorArray {
|
|
|
4463
4519
|
const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
|
|
4464
4520
|
const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
|
|
4465
4521
|
const { list, arrayActions } = this.theme.getTab({
|
|
4466
|
-
hasErrors: navWarning && child.
|
|
4522
|
+
hasErrors: navWarning && child.hasNestedValidationErrors(),
|
|
4467
4523
|
navWarningMessage,
|
|
4468
4524
|
title: (titleTemplate == null ? void 0 : titleTemplate.length) ? titleTemplate : childTitle,
|
|
4469
4525
|
id,
|
|
@@ -5166,6 +5222,7 @@ class UiResolver {
|
|
|
5166
5222
|
EditorObject,
|
|
5167
5223
|
EditorArrayChoices,
|
|
5168
5224
|
EditorArrayCheckboxes,
|
|
5225
|
+
EditorArrayTuple,
|
|
5169
5226
|
EditorArrayTableObject,
|
|
5170
5227
|
EditorArrayTable,
|
|
5171
5228
|
EditorArrayNav,
|