jedison 1.3.6 → 1.4.1
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 +64 -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) => {
|
|
@@ -2350,7 +2361,8 @@ class InstanceIfThenElse extends Instance {
|
|
|
2350
2361
|
schema: schemaClone,
|
|
2351
2362
|
originalSchema: this.originalSchema,
|
|
2352
2363
|
path: this.path,
|
|
2353
|
-
parent: this.parent
|
|
2364
|
+
parent: this.parent,
|
|
2365
|
+
arrayTemplateData: this.arrayTemplateData
|
|
2354
2366
|
});
|
|
2355
2367
|
this.schemas.forEach((schema) => {
|
|
2356
2368
|
const instance = this.jedison.createInstance({
|
|
@@ -2358,7 +2370,8 @@ class InstanceIfThenElse extends Instance {
|
|
|
2358
2370
|
schema,
|
|
2359
2371
|
originalSchema: this.originalSchema,
|
|
2360
2372
|
path: this.path,
|
|
2361
|
-
parent: this.parent
|
|
2373
|
+
parent: this.parent,
|
|
2374
|
+
arrayTemplateData: this.arrayTemplateData
|
|
2362
2375
|
});
|
|
2363
2376
|
this.instanceStartingValues.push(instance.getValue());
|
|
2364
2377
|
this.instances.push(instance);
|
|
@@ -2497,6 +2510,9 @@ class InstanceIfThenElse extends Instance {
|
|
|
2497
2510
|
});
|
|
2498
2511
|
return fittestIndex;
|
|
2499
2512
|
}
|
|
2513
|
+
hasNestedValidationErrors() {
|
|
2514
|
+
return this.activeInstance ? this.activeInstance.hasNestedValidationErrors() : false;
|
|
2515
|
+
}
|
|
2500
2516
|
destroy() {
|
|
2501
2517
|
this.instances.forEach((instance) => {
|
|
2502
2518
|
instance.destroy();
|
|
@@ -2640,6 +2656,9 @@ class InstanceMultiple extends Instance {
|
|
|
2640
2656
|
}
|
|
2641
2657
|
return fittestIndex;
|
|
2642
2658
|
}
|
|
2659
|
+
hasNestedValidationErrors() {
|
|
2660
|
+
return this.activeInstance ? this.activeInstance.hasNestedValidationErrors() : false;
|
|
2661
|
+
}
|
|
2643
2662
|
destroy() {
|
|
2644
2663
|
this.instances.forEach((instance) => {
|
|
2645
2664
|
instance.destroy();
|
|
@@ -3880,7 +3899,7 @@ class EditorObjectNav extends EditorObject {
|
|
|
3880
3899
|
const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
|
|
3881
3900
|
const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
|
|
3882
3901
|
const tab = this.theme.getTab({
|
|
3883
|
-
hasErrors: navWarning && child.
|
|
3902
|
+
hasErrors: navWarning && child.hasNestedValidationErrors(),
|
|
3884
3903
|
navWarningMessage,
|
|
3885
3904
|
title: isSet(schemaTitle) ? schemaTitle : child.getKey(),
|
|
3886
3905
|
id,
|
|
@@ -4072,6 +4091,45 @@ class EditorArray extends Editor {
|
|
|
4072
4091
|
this.refreshJsonData();
|
|
4073
4092
|
}
|
|
4074
4093
|
}
|
|
4094
|
+
class EditorArrayTuple extends EditorArray {
|
|
4095
|
+
static resolves(schema) {
|
|
4096
|
+
const type2 = getSchemaType(schema);
|
|
4097
|
+
const format2 = getSchemaX(schema, "format");
|
|
4098
|
+
const prefixItems2 = getSchemaPrefixItems(schema);
|
|
4099
|
+
return type2 === "array" && format2 === "tuple" && isSet(prefixItems2);
|
|
4100
|
+
}
|
|
4101
|
+
build() {
|
|
4102
|
+
super.build();
|
|
4103
|
+
this.control.addBtn.style.display = "none";
|
|
4104
|
+
}
|
|
4105
|
+
addEventListeners() {
|
|
4106
|
+
this.addJsonDataEventListeners();
|
|
4107
|
+
}
|
|
4108
|
+
refreshUI() {
|
|
4109
|
+
this.control.childrenSlot.innerHTML = "";
|
|
4110
|
+
const table = this.theme.getTable();
|
|
4111
|
+
this.control.childrenSlot.appendChild(table.container);
|
|
4112
|
+
const schemaPrefixItems = getSchemaPrefixItems(this.instance.schema);
|
|
4113
|
+
schemaPrefixItems.forEach((prefixItemSchema) => {
|
|
4114
|
+
const th = this.theme.getTableHeader();
|
|
4115
|
+
const { label } = this.theme.getFakeLabel({
|
|
4116
|
+
content: getSchemaTitle(prefixItemSchema) ?? ""
|
|
4117
|
+
});
|
|
4118
|
+
th.appendChild(label);
|
|
4119
|
+
table.thead.appendChild(th);
|
|
4120
|
+
});
|
|
4121
|
+
const tbodyRow = document.createElement("tr");
|
|
4122
|
+
this.instance.children.forEach((child) => {
|
|
4123
|
+
const td = this.theme.getTableDefinition();
|
|
4124
|
+
child.ui.adaptForTable(child, td);
|
|
4125
|
+
td.appendChild(child.ui.control.container);
|
|
4126
|
+
tbodyRow.appendChild(td);
|
|
4127
|
+
});
|
|
4128
|
+
table.tbody.appendChild(tbodyRow);
|
|
4129
|
+
this.refreshJsonData();
|
|
4130
|
+
this.refreshDisabledState();
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4075
4133
|
class EditorArrayTable extends EditorArray {
|
|
4076
4134
|
static resolves(schema, refParser) {
|
|
4077
4135
|
return getSchemaType(schema) === "array" && getSchemaXOption(schema, "format") === "table";
|
|
@@ -4463,7 +4521,7 @@ class EditorArrayNav extends EditorArray {
|
|
|
4463
4521
|
const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
|
|
4464
4522
|
const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
|
|
4465
4523
|
const { list, arrayActions } = this.theme.getTab({
|
|
4466
|
-
hasErrors: navWarning && child.
|
|
4524
|
+
hasErrors: navWarning && child.hasNestedValidationErrors(),
|
|
4467
4525
|
navWarningMessage,
|
|
4468
4526
|
title: (titleTemplate == null ? void 0 : titleTemplate.length) ? titleTemplate : childTitle,
|
|
4469
4527
|
id,
|
|
@@ -5166,6 +5224,7 @@ class UiResolver {
|
|
|
5166
5224
|
EditorObject,
|
|
5167
5225
|
EditorArrayChoices,
|
|
5168
5226
|
EditorArrayCheckboxes,
|
|
5227
|
+
EditorArrayTuple,
|
|
5169
5228
|
EditorArrayTableObject,
|
|
5170
5229
|
EditorArrayTable,
|
|
5171
5230
|
EditorArrayNav,
|