jedison 1.4.4 → 1.5.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 +10 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +133 -26
- 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 +6 -2
package/dist/esm/jedison.js
CHANGED
|
@@ -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, hasOwn(
|
|
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, hasOwn(
|
|
2708
|
+
this.createChild({}, requiredProperty, hasOwn(initialValue, requiredProperty) ? initialValue[requiredProperty] : void 0);
|
|
2708
2709
|
}
|
|
2709
2710
|
});
|
|
2710
2711
|
}
|
|
@@ -3866,16 +3867,15 @@ class EditorObjectGrid extends EditorObject {
|
|
|
3866
3867
|
});
|
|
3867
3868
|
}
|
|
3868
3869
|
}
|
|
3869
|
-
class
|
|
3870
|
+
class EditorObjectCategories extends EditorObject {
|
|
3870
3871
|
static resolves(schema) {
|
|
3871
3872
|
const format2 = getSchemaXOption(schema, "format");
|
|
3872
|
-
const regex = /^
|
|
3873
|
-
|
|
3874
|
-
return getSchemaType(schema) === "object" && hasNavFormat;
|
|
3873
|
+
const regex = /^categories-(horizontal|vertical(?:-\d+)?)$/;
|
|
3874
|
+
return getSchemaType(schema) === "object" && regex.test(format2);
|
|
3875
3875
|
}
|
|
3876
3876
|
init() {
|
|
3877
3877
|
super.init();
|
|
3878
|
-
this.
|
|
3878
|
+
this.activeCategoryName = null;
|
|
3879
3879
|
}
|
|
3880
3880
|
refreshEditors() {
|
|
3881
3881
|
while (this.control.childrenSlot.firstChild) {
|
|
@@ -3898,31 +3898,136 @@ class EditorObjectNav extends EditorObject {
|
|
|
3898
3898
|
row.appendChild(tabContentCol);
|
|
3899
3899
|
tabListCol.appendChild(tabList);
|
|
3900
3900
|
tabContentCol.appendChild(tabContent);
|
|
3901
|
-
this.instance.
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
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 hidden = getSchemaXOption(child.schema, "hidden");
|
|
3908
|
+
if (isSet(hidden) && hidden === true) return;
|
|
3909
|
+
const childSchemaType = getSchemaType(child.schema);
|
|
3910
|
+
const xCategory = getSchemaXOption(child.schema, "category");
|
|
3911
|
+
let categoryName;
|
|
3912
|
+
if (isSet(xCategory)) {
|
|
3913
|
+
categoryName = xCategory;
|
|
3914
|
+
} else if (childSchemaType === "object" || childSchemaType === "array") {
|
|
3905
3915
|
const schemaTitle = getSchemaTitle(child.schema);
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3916
|
+
categoryName = isSet(schemaTitle) ? schemaTitle : child.getKey();
|
|
3917
|
+
} else {
|
|
3918
|
+
categoryName = defaultLabel;
|
|
3919
|
+
}
|
|
3920
|
+
if (!categoriesMap.has(categoryName)) {
|
|
3921
|
+
categoriesMap.set(categoryName, { children: [], id: pathToAttribute(child.path) });
|
|
3922
|
+
}
|
|
3923
|
+
categoriesMap.get(categoryName).children.push(child);
|
|
3924
|
+
});
|
|
3925
|
+
if (!categoriesMap.has(this.activeCategoryName)) {
|
|
3926
|
+
this.activeCategoryName = categoriesMap.keys().next().value;
|
|
3927
|
+
}
|
|
3928
|
+
categoriesMap.forEach((category, categoryName) => {
|
|
3929
|
+
const active = categoryName === this.activeCategoryName;
|
|
3930
|
+
const { children, id } = category;
|
|
3931
|
+
const hasErrors = navWarning && children.some((child) => child.hasNestedValidationErrors());
|
|
3932
|
+
const tab = this.theme.getTab({
|
|
3933
|
+
hasErrors,
|
|
3934
|
+
navWarningMessage,
|
|
3935
|
+
title: categoryName,
|
|
3936
|
+
id,
|
|
3937
|
+
active
|
|
3938
|
+
});
|
|
3939
|
+
tab.list.addEventListener("click", () => {
|
|
3940
|
+
this.activeCategoryName = categoryName;
|
|
3941
|
+
});
|
|
3942
|
+
const pane = document.createElement("div");
|
|
3943
|
+
this.theme.setTabPaneAttributes(pane, active, id);
|
|
3944
|
+
children.forEach((child) => {
|
|
3945
|
+
pane.appendChild(child.ui.control.container);
|
|
3921
3946
|
if (this.disabled || this.instance.isReadOnly()) {
|
|
3922
3947
|
child.ui.disable();
|
|
3923
3948
|
} else {
|
|
3924
3949
|
child.ui.enable();
|
|
3925
3950
|
}
|
|
3951
|
+
});
|
|
3952
|
+
tabList.appendChild(tab.list);
|
|
3953
|
+
tabContent.appendChild(pane);
|
|
3954
|
+
});
|
|
3955
|
+
}
|
|
3956
|
+
}
|
|
3957
|
+
class EditorObjectNav extends EditorObject {
|
|
3958
|
+
static resolves(schema) {
|
|
3959
|
+
const format2 = getSchemaXOption(schema, "format");
|
|
3960
|
+
const regex = /^nav-(horizontal|vertical(?:-\d+)?)$/;
|
|
3961
|
+
const hasNavFormat = regex.test(format2);
|
|
3962
|
+
return getSchemaType(schema) === "object" && hasNavFormat;
|
|
3963
|
+
}
|
|
3964
|
+
init() {
|
|
3965
|
+
super.init();
|
|
3966
|
+
this.activeTabIndex = 0;
|
|
3967
|
+
}
|
|
3968
|
+
isChildVisible(child) {
|
|
3969
|
+
if (!child.isActive) return false;
|
|
3970
|
+
const hidden = getSchemaXOption(child.schema, "hidden");
|
|
3971
|
+
return !(isSet(hidden) && hidden === true);
|
|
3972
|
+
}
|
|
3973
|
+
getVisibleChildIndices() {
|
|
3974
|
+
return this.instance.children.reduce((indices, child, index2) => {
|
|
3975
|
+
if (this.isChildVisible(child)) indices.push(index2);
|
|
3976
|
+
return indices;
|
|
3977
|
+
}, []);
|
|
3978
|
+
}
|
|
3979
|
+
ensureActiveTabIsVisible(visibleIndices) {
|
|
3980
|
+
if (!visibleIndices.includes(this.activeTabIndex)) {
|
|
3981
|
+
this.activeTabIndex = visibleIndices[0] ?? 0;
|
|
3982
|
+
}
|
|
3983
|
+
}
|
|
3984
|
+
refreshEditors() {
|
|
3985
|
+
while (this.control.childrenSlot.firstChild) {
|
|
3986
|
+
this.control.childrenSlot.removeChild(this.control.childrenSlot.lastChild);
|
|
3987
|
+
}
|
|
3988
|
+
const format2 = getSchemaXOption(this.instance.schema, "format");
|
|
3989
|
+
const formatParts = format2.split("-");
|
|
3990
|
+
const variant = formatParts[1];
|
|
3991
|
+
const columns = formatParts[2];
|
|
3992
|
+
const navColumns = variant === "horizontal" ? 12 : columns ?? 4;
|
|
3993
|
+
const row = this.theme.getRow();
|
|
3994
|
+
const tabListCol = this.theme.getCol(12, 12, navColumns, navColumns);
|
|
3995
|
+
const tabContentCol = this.theme.getCol(12, 12, 12 - navColumns, 12 - navColumns);
|
|
3996
|
+
const tabContent = this.theme.getTabContent();
|
|
3997
|
+
const tabList = this.theme.getTabList({
|
|
3998
|
+
variant
|
|
3999
|
+
});
|
|
4000
|
+
this.control.childrenSlot.appendChild(row);
|
|
4001
|
+
row.appendChild(tabListCol);
|
|
4002
|
+
row.appendChild(tabContentCol);
|
|
4003
|
+
tabListCol.appendChild(tabList);
|
|
4004
|
+
tabContentCol.appendChild(tabContent);
|
|
4005
|
+
const visibleIndices = this.getVisibleChildIndices();
|
|
4006
|
+
this.ensureActiveTabIsVisible(visibleIndices);
|
|
4007
|
+
this.instance.children.forEach((child, index2) => {
|
|
4008
|
+
if (!this.isChildVisible(child)) return;
|
|
4009
|
+
const active = index2 === this.activeTabIndex;
|
|
4010
|
+
const id = pathToAttribute(child.path);
|
|
4011
|
+
const schemaTitle = getSchemaTitle(child.schema);
|
|
4012
|
+
const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
|
|
4013
|
+
const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
|
|
4014
|
+
const tab = this.theme.getTab({
|
|
4015
|
+
hasErrors: navWarning && child.hasNestedValidationErrors(),
|
|
4016
|
+
navWarningMessage,
|
|
4017
|
+
title: isSet(schemaTitle) ? schemaTitle : child.getKey(),
|
|
4018
|
+
id,
|
|
4019
|
+
active
|
|
4020
|
+
});
|
|
4021
|
+
tab.list.addEventListener("click", () => {
|
|
4022
|
+
this.activeTabIndex = index2;
|
|
4023
|
+
});
|
|
4024
|
+
this.theme.setTabPaneAttributes(child.ui.control.container, active, id);
|
|
4025
|
+
tabList.appendChild(tab.list);
|
|
4026
|
+
tabContent.appendChild(child.ui.control.container);
|
|
4027
|
+
if (this.disabled || this.instance.isReadOnly()) {
|
|
4028
|
+
child.ui.disable();
|
|
4029
|
+
} else {
|
|
4030
|
+
child.ui.enable();
|
|
3926
4031
|
}
|
|
3927
4032
|
});
|
|
3928
4033
|
}
|
|
@@ -5227,6 +5332,7 @@ class UiResolver {
|
|
|
5227
5332
|
EditorNumberSelect,
|
|
5228
5333
|
EditorNumberInput,
|
|
5229
5334
|
EditorObjectGrid,
|
|
5335
|
+
EditorObjectCategories,
|
|
5230
5336
|
EditorObjectNav,
|
|
5231
5337
|
EditorObject,
|
|
5232
5338
|
EditorArrayChoices,
|
|
@@ -8804,6 +8910,7 @@ const index = {
|
|
|
8804
8910
|
EditorNumberSelect,
|
|
8805
8911
|
EditorNumberInput,
|
|
8806
8912
|
EditorObjectGrid,
|
|
8913
|
+
EditorObjectCategories,
|
|
8807
8914
|
EditorObjectNav,
|
|
8808
8915
|
EditorObject,
|
|
8809
8916
|
EditorArrayChoices,
|