jedison 1.3.6 → 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.
@@ -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 === "properties") {
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();
@@ -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.children.some((grandChild) => grandChild.ui.showingValidationErrors),
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.children.some((grandChild) => grandChild.ui.showingValidationErrors),
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,