jedison 1.4.3 → 1.5.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.
@@ -2672,6 +2672,7 @@ class InstanceObject extends Instance {
2672
2672
  this.schemaAdditionalProperties = getSchemaAdditionalProperties(this.schema);
2673
2673
  const schemaProperties = getSchemaProperties(this.schema);
2674
2674
  const schemaRequired = getSchemaRequired(this.schema);
2675
+ const initialValue = clone(this.value);
2675
2676
  if (isSet(schemaProperties)) {
2676
2677
  Object.keys(schemaProperties).forEach((key) => {
2677
2678
  const schema = schemaProperties[key];
@@ -2695,7 +2696,7 @@ class InstanceObject extends Instance {
2695
2696
  musstCreateChild = false;
2696
2697
  }
2697
2698
  if (musstCreateChild) {
2698
- this.createChild(schema, key);
2699
+ this.createChild(schema, key, hasOwn(initialValue, key) ? initialValue[key] : void 0);
2699
2700
  }
2700
2701
  });
2701
2702
  }
@@ -2704,7 +2705,7 @@ class InstanceObject extends Instance {
2704
2705
  this.requiredProperties.add(requiredProperty);
2705
2706
  if (!hasOwn(this.properties, requiredProperty)) {
2706
2707
  this.properties[requiredProperty] = {};
2707
- this.createChild({}, requiredProperty);
2708
+ this.createChild({}, requiredProperty, hasOwn(initialValue, requiredProperty) ? initialValue[requiredProperty] : void 0);
2708
2709
  }
2709
2710
  });
2710
2711
  }
@@ -2973,7 +2974,7 @@ class InstanceArray extends Instance {
2973
2974
  addItem(initiator) {
2974
2975
  const tempEditor = this.createItemInstance();
2975
2976
  const raw = this.getValueRaw();
2976
- let value = isArray(raw) ? clone(raw) : [];
2977
+ const value = isArray(raw) ? clone(raw) : [];
2977
2978
  value.push(tempEditor.getValueRaw());
2978
2979
  tempEditor.destroy();
2979
2980
  this.setValue(value, true, initiator);
@@ -3866,6 +3867,91 @@ class EditorObjectGrid extends EditorObject {
3866
3867
  });
3867
3868
  }
3868
3869
  }
3870
+ class EditorObjectCategories extends EditorObject {
3871
+ static resolves(schema) {
3872
+ const format2 = getSchemaXOption(schema, "format");
3873
+ const regex = /^categories-(horizontal|vertical(?:-\d+)?)$/;
3874
+ return getSchemaType(schema) === "object" && regex.test(format2);
3875
+ }
3876
+ init() {
3877
+ super.init();
3878
+ this.activeCategoryName = null;
3879
+ }
3880
+ refreshEditors() {
3881
+ while (this.control.childrenSlot.firstChild) {
3882
+ this.control.childrenSlot.removeChild(this.control.childrenSlot.lastChild);
3883
+ }
3884
+ const format2 = getSchemaXOption(this.instance.schema, "format");
3885
+ const formatParts = format2.split("-");
3886
+ const variant = formatParts[1];
3887
+ const columns = formatParts[2];
3888
+ const navColumns = variant === "horizontal" ? 12 : columns ?? 4;
3889
+ const row = this.theme.getRow();
3890
+ const tabListCol = this.theme.getCol(12, 12, navColumns, navColumns);
3891
+ const tabContentCol = this.theme.getCol(12, 12, 12 - navColumns, 12 - navColumns);
3892
+ const tabContent = this.theme.getTabContent();
3893
+ const tabList = this.theme.getTabList({
3894
+ variant
3895
+ });
3896
+ this.control.childrenSlot.appendChild(row);
3897
+ row.appendChild(tabListCol);
3898
+ row.appendChild(tabContentCol);
3899
+ tabListCol.appendChild(tabList);
3900
+ tabContentCol.appendChild(tabContent);
3901
+ const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
3902
+ const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
3903
+ const defaultLabel = getSchemaXOption(this.instance.schema, "categoriesDefaultLabel") ?? "Basic";
3904
+ const categoriesMap = /* @__PURE__ */ new Map();
3905
+ this.instance.children.forEach((child) => {
3906
+ if (!child.isActive) return;
3907
+ const childSchemaType = getSchemaType(child.schema);
3908
+ const xCategory = getSchemaXOption(child.schema, "category");
3909
+ let categoryName;
3910
+ if (isSet(xCategory)) {
3911
+ categoryName = xCategory;
3912
+ } else if (childSchemaType === "object" || childSchemaType === "array") {
3913
+ const schemaTitle = getSchemaTitle(child.schema);
3914
+ categoryName = isSet(schemaTitle) ? schemaTitle : child.getKey();
3915
+ } else {
3916
+ categoryName = defaultLabel;
3917
+ }
3918
+ if (!categoriesMap.has(categoryName)) {
3919
+ categoriesMap.set(categoryName, { children: [], id: pathToAttribute(child.path) });
3920
+ }
3921
+ categoriesMap.get(categoryName).children.push(child);
3922
+ });
3923
+ if (!categoriesMap.has(this.activeCategoryName)) {
3924
+ this.activeCategoryName = categoriesMap.keys().next().value;
3925
+ }
3926
+ categoriesMap.forEach((category, categoryName) => {
3927
+ const active = categoryName === this.activeCategoryName;
3928
+ const { children, id } = category;
3929
+ const hasErrors = navWarning && children.some((child) => child.hasNestedValidationErrors());
3930
+ const tab = this.theme.getTab({
3931
+ hasErrors,
3932
+ navWarningMessage,
3933
+ title: categoryName,
3934
+ id,
3935
+ active
3936
+ });
3937
+ tab.list.addEventListener("click", () => {
3938
+ this.activeCategoryName = categoryName;
3939
+ });
3940
+ const pane = document.createElement("div");
3941
+ this.theme.setTabPaneAttributes(pane, active, id);
3942
+ children.forEach((child) => {
3943
+ pane.appendChild(child.ui.control.container);
3944
+ if (this.disabled || this.instance.isReadOnly()) {
3945
+ child.ui.disable();
3946
+ } else {
3947
+ child.ui.enable();
3948
+ }
3949
+ });
3950
+ tabList.appendChild(tab.list);
3951
+ tabContent.appendChild(pane);
3952
+ });
3953
+ }
3954
+ }
3869
3955
  class EditorObjectNav extends EditorObject {
3870
3956
  static resolves(schema) {
3871
3957
  const format2 = getSchemaXOption(schema, "format");
@@ -5227,6 +5313,7 @@ class UiResolver {
5227
5313
  EditorNumberSelect,
5228
5314
  EditorNumberInput,
5229
5315
  EditorObjectGrid,
5316
+ EditorObjectCategories,
5230
5317
  EditorObjectNav,
5231
5318
  EditorObject,
5232
5319
  EditorArrayChoices,
@@ -8804,6 +8891,7 @@ const index = {
8804
8891
  EditorNumberSelect,
8805
8892
  EditorNumberInput,
8806
8893
  EditorObjectGrid,
8894
+ EditorObjectCategories,
8807
8895
  EditorObjectNav,
8808
8896
  EditorObject,
8809
8897
  EditorArrayChoices,