jedison 1.2.0 → 1.3.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 +12 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +69 -8
- 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 -4
package/dist/esm/jedison.js
CHANGED
|
@@ -1817,6 +1817,12 @@ class Instance extends EventEmitter {
|
|
|
1817
1817
|
value: this.getValue(),
|
|
1818
1818
|
settings: this.jedison.options.settings
|
|
1819
1819
|
};
|
|
1820
|
+
if (typeof this.value === "string") {
|
|
1821
|
+
templateData.length = this.value.length;
|
|
1822
|
+
if (typeof this.schema.maxLength === "number") {
|
|
1823
|
+
templateData.remaining = this.schema.maxLength - this.value.length;
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1820
1826
|
if (template == null ? void 0 : template.includes("{{ functions.")) {
|
|
1821
1827
|
templateData.functions = this.resolveTemplateFunctions(
|
|
1822
1828
|
this.jedison.options.functions
|
|
@@ -2085,10 +2091,12 @@ class Editor {
|
|
|
2085
2091
|
if (neverShowErrors && !force || errors.length === 0) {
|
|
2086
2092
|
return;
|
|
2087
2093
|
}
|
|
2094
|
+
let counter = 0;
|
|
2088
2095
|
errors.forEach((error) => {
|
|
2089
2096
|
if (error.constraint === "properties") {
|
|
2090
2097
|
return;
|
|
2091
2098
|
}
|
|
2099
|
+
counter += 1;
|
|
2092
2100
|
error.messages.forEach((message) => {
|
|
2093
2101
|
let invalidFeedback;
|
|
2094
2102
|
if (error.type === "error") {
|
|
@@ -2103,7 +2111,7 @@ class Editor {
|
|
|
2103
2111
|
this.control.messages.appendChild(invalidFeedback);
|
|
2104
2112
|
});
|
|
2105
2113
|
});
|
|
2106
|
-
this.showingValidationErrors =
|
|
2114
|
+
this.showingValidationErrors = counter > 0;
|
|
2107
2115
|
}
|
|
2108
2116
|
/**
|
|
2109
2117
|
* Get an error message container
|
|
@@ -2905,6 +2913,9 @@ class InstanceArray extends Instance {
|
|
|
2905
2913
|
}
|
|
2906
2914
|
move(fromIndex, toIndex, initiator) {
|
|
2907
2915
|
const value = clone(this.getValue());
|
|
2916
|
+
if (!isArray(value)) {
|
|
2917
|
+
return;
|
|
2918
|
+
}
|
|
2908
2919
|
const item = value[fromIndex];
|
|
2909
2920
|
value.splice(fromIndex, 1);
|
|
2910
2921
|
value.splice(toIndex, 0, item);
|
|
@@ -2914,7 +2925,10 @@ class InstanceArray extends Instance {
|
|
|
2914
2925
|
}
|
|
2915
2926
|
addItem(initiator) {
|
|
2916
2927
|
const tempEditor = this.createItemInstance();
|
|
2917
|
-
|
|
2928
|
+
let value = clone(this.getValue());
|
|
2929
|
+
if (!isArray(value)) {
|
|
2930
|
+
value = [];
|
|
2931
|
+
}
|
|
2918
2932
|
value.push(tempEditor.getValue());
|
|
2919
2933
|
tempEditor.destroy();
|
|
2920
2934
|
this.setValue(value, true, initiator);
|
|
@@ -2924,6 +2938,9 @@ class InstanceArray extends Instance {
|
|
|
2924
2938
|
}
|
|
2925
2939
|
deleteItem(itemIndex, initiator) {
|
|
2926
2940
|
const currentValue = clone(this.getValue());
|
|
2941
|
+
if (!isArray(currentValue)) {
|
|
2942
|
+
return;
|
|
2943
|
+
}
|
|
2927
2944
|
const newValue = currentValue.filter((item, index2) => index2 !== itemIndex);
|
|
2928
2945
|
this.setValue(newValue, true, initiator);
|
|
2929
2946
|
this.emit("item-delete", initiator);
|
|
@@ -3225,6 +3242,17 @@ class EditorStringTextarea extends EditorString {
|
|
|
3225
3242
|
titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
|
|
3226
3243
|
info: this.getInfo()
|
|
3227
3244
|
});
|
|
3245
|
+
const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.options.useConstraintAttributes;
|
|
3246
|
+
if (useConstraintAttributes === true) {
|
|
3247
|
+
const schemaMinLength = getSchemaMinLength(this.instance.schema);
|
|
3248
|
+
const schemaMaxLength = getSchemaMaxLength(this.instance.schema);
|
|
3249
|
+
if (isSet(schemaMinLength)) {
|
|
3250
|
+
this.control.input.setAttribute("minlength", schemaMinLength);
|
|
3251
|
+
}
|
|
3252
|
+
if (isSet(schemaMaxLength)) {
|
|
3253
|
+
this.control.input.setAttribute("maxlength", schemaMaxLength);
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3228
3256
|
}
|
|
3229
3257
|
adaptForTable() {
|
|
3230
3258
|
this.theme.adaptForTableTextareaControl(this.control);
|
|
@@ -3236,7 +3264,7 @@ class EditorStringTextarea extends EditorString {
|
|
|
3236
3264
|
});
|
|
3237
3265
|
}
|
|
3238
3266
|
refreshUI() {
|
|
3239
|
-
|
|
3267
|
+
super.refreshUI();
|
|
3240
3268
|
this.control.input.value = this.instance.getValue();
|
|
3241
3269
|
}
|
|
3242
3270
|
}
|
|
@@ -3350,6 +3378,21 @@ class EditorStringInput extends EditorString {
|
|
|
3350
3378
|
if (optionFormat === "color" && this.instance.value.length === 0) {
|
|
3351
3379
|
this.instance.setValue("#000000", false, "user");
|
|
3352
3380
|
}
|
|
3381
|
+
const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.options.useConstraintAttributes;
|
|
3382
|
+
if (useConstraintAttributes === true) {
|
|
3383
|
+
const schemaMinLength = getSchemaMinLength(this.instance.schema);
|
|
3384
|
+
const schemaMaxLength = getSchemaMaxLength(this.instance.schema);
|
|
3385
|
+
const schemaPattern = getSchemaPattern(this.instance.schema);
|
|
3386
|
+
if (isSet(schemaMinLength)) {
|
|
3387
|
+
this.control.input.setAttribute("minlength", schemaMinLength);
|
|
3388
|
+
}
|
|
3389
|
+
if (isSet(schemaMaxLength)) {
|
|
3390
|
+
this.control.input.setAttribute("maxlength", schemaMaxLength);
|
|
3391
|
+
}
|
|
3392
|
+
if (isSet(schemaPattern)) {
|
|
3393
|
+
this.control.input.setAttribute("pattern", schemaPattern);
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3353
3396
|
}
|
|
3354
3397
|
adaptForTable() {
|
|
3355
3398
|
this.theme.adaptForTableInputControl(this.control);
|
|
@@ -3813,8 +3856,11 @@ class EditorObjectNav extends EditorObject {
|
|
|
3813
3856
|
const active = index2 === this.activeTabIndex;
|
|
3814
3857
|
const id = pathToAttribute(child.path);
|
|
3815
3858
|
const schemaTitle = getSchemaTitle(child.schema);
|
|
3859
|
+
const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
|
|
3860
|
+
const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
|
|
3816
3861
|
const tab = this.theme.getTab({
|
|
3817
|
-
hasErrors: child.children.some((grandChild) => grandChild.ui.showingValidationErrors),
|
|
3862
|
+
hasErrors: navWarning && child.children.some((grandChild) => grandChild.ui.showingValidationErrors),
|
|
3863
|
+
navWarningMessage,
|
|
3818
3864
|
title: isSet(schemaTitle) ? schemaTitle : child.getKey(),
|
|
3819
3865
|
id,
|
|
3820
3866
|
active
|
|
@@ -4392,8 +4438,11 @@ class EditorArrayNav extends EditorArray {
|
|
|
4392
4438
|
}
|
|
4393
4439
|
const active = index2 === this.activeItemIndex;
|
|
4394
4440
|
const id = pathToAttribute(child.path);
|
|
4441
|
+
const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
|
|
4442
|
+
const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
|
|
4395
4443
|
const { list, arrayActions } = this.theme.getTab({
|
|
4396
|
-
hasErrors: child.children.some((grandChild) => grandChild.ui.showingValidationErrors),
|
|
4444
|
+
hasErrors: navWarning && child.children.some((grandChild) => grandChild.ui.showingValidationErrors),
|
|
4445
|
+
navWarningMessage,
|
|
4397
4446
|
title: (titleTemplate == null ? void 0 : titleTemplate.length) ? titleTemplate : childTitle,
|
|
4398
4447
|
id,
|
|
4399
4448
|
active
|
|
@@ -4932,8 +4981,11 @@ class EditorNumberRange extends EditorNumber {
|
|
|
4932
4981
|
titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
|
|
4933
4982
|
info: this.getInfo()
|
|
4934
4983
|
});
|
|
4935
|
-
this.
|
|
4936
|
-
|
|
4984
|
+
const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.options.useConstraintAttributes;
|
|
4985
|
+
if (useConstraintAttributes === true) {
|
|
4986
|
+
this.control.input.setAttribute("min", optionMin);
|
|
4987
|
+
this.control.input.setAttribute("max", optionMax);
|
|
4988
|
+
}
|
|
4937
4989
|
this.control.input.setAttribute("step", optionStep);
|
|
4938
4990
|
const inputAttributes = getSchemaXOption(this.instance.schema, "inputAttributes");
|
|
4939
4991
|
if (inputAttributes && typeof inputAttributes === "object") {
|
|
@@ -7447,7 +7499,16 @@ class Theme {
|
|
|
7447
7499
|
link.classList.add("jedi-nav-link");
|
|
7448
7500
|
link.setAttribute("href", "#tab-pane-" + config.id);
|
|
7449
7501
|
text.classList.add("jedi-nav-text");
|
|
7450
|
-
text.textContent = config.
|
|
7502
|
+
text.textContent = config.title;
|
|
7503
|
+
if (config.hasErrors) {
|
|
7504
|
+
const warning = document.createElement("span");
|
|
7505
|
+
warning.classList.add("jedi-nav-warning");
|
|
7506
|
+
warning.textContent = "⚠ ";
|
|
7507
|
+
if (config.navWarningMessage) {
|
|
7508
|
+
warning.setAttribute("title", config.navWarningMessage);
|
|
7509
|
+
}
|
|
7510
|
+
text.insertBefore(warning, text.firstChild);
|
|
7511
|
+
}
|
|
7451
7512
|
link.appendChild(arrayActions);
|
|
7452
7513
|
link.appendChild(text);
|
|
7453
7514
|
list.appendChild(link);
|