jedison 0.3.17 → 0.3.19
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 +49 -24
- 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
|
@@ -1704,7 +1704,7 @@ class Instance extends EventEmitter {
|
|
|
1704
1704
|
return this.schema;
|
|
1705
1705
|
}
|
|
1706
1706
|
/**
|
|
1707
|
-
* Adds a child instance pointer to the
|
|
1707
|
+
* Adds a child instance pointer to the instance list
|
|
1708
1708
|
*/
|
|
1709
1709
|
register() {
|
|
1710
1710
|
this.jedison.register(this);
|
|
@@ -1718,10 +1718,18 @@ class Instance extends EventEmitter {
|
|
|
1718
1718
|
this.children.forEach(registerChildRecursive);
|
|
1719
1719
|
}
|
|
1720
1720
|
/**
|
|
1721
|
-
* Deletes a child instance pointer from the
|
|
1721
|
+
* Deletes a child instance pointer from the instance list
|
|
1722
1722
|
*/
|
|
1723
1723
|
unregister() {
|
|
1724
1724
|
this.jedison.unregister(this);
|
|
1725
|
+
if (this.children.length === 0) return;
|
|
1726
|
+
const unregisterChildRecursive = (child) => {
|
|
1727
|
+
this.jedison.unregister(child);
|
|
1728
|
+
if (child.children.length > 0) {
|
|
1729
|
+
child.children.forEach(unregisterChildRecursive);
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1732
|
+
this.children.forEach(unregisterChildRecursive);
|
|
1725
1733
|
}
|
|
1726
1734
|
/**
|
|
1727
1735
|
* Sets the default value of the instance based on it's type
|
|
@@ -2005,6 +2013,14 @@ class Editor {
|
|
|
2005
2013
|
const optionId = this.instance.jedison.options.id;
|
|
2006
2014
|
return optionId ? optionId + "-" + pathToAttribute(path) : pathToAttribute(path);
|
|
2007
2015
|
}
|
|
2016
|
+
/**
|
|
2017
|
+
* Determines the event type to use for validation trigger based on showErrors option
|
|
2018
|
+
* @returns {string} - 'input' or 'change'
|
|
2019
|
+
*/
|
|
2020
|
+
getValidationEventType() {
|
|
2021
|
+
const showErrors = getSchemaXOption(this.instance.schema, "showErrors") ?? this.instance.jedison.options.showErrors;
|
|
2022
|
+
return showErrors === "input" ? "input" : "change";
|
|
2023
|
+
}
|
|
2008
2024
|
/**
|
|
2009
2025
|
* Add event listeners to ui elements
|
|
2010
2026
|
*/
|
|
@@ -2398,7 +2414,6 @@ class InstanceMultiple extends Instance {
|
|
|
2398
2414
|
prepare() {
|
|
2399
2415
|
this.instances = [];
|
|
2400
2416
|
this.activeInstance = null;
|
|
2401
|
-
this.lastIndex = 0;
|
|
2402
2417
|
this.index = 0;
|
|
2403
2418
|
this.schemas = [];
|
|
2404
2419
|
this.switcherOptionValues = [];
|
|
@@ -2496,7 +2511,6 @@ class InstanceMultiple extends Instance {
|
|
|
2496
2511
|
this.switchInstance(fittestIndex, this.value);
|
|
2497
2512
|
}
|
|
2498
2513
|
switchInstance(index2, value, initiator = "api") {
|
|
2499
|
-
this.lastIndex = this.index;
|
|
2500
2514
|
this.index = index2;
|
|
2501
2515
|
this.activeInstance = this.instances[index2];
|
|
2502
2516
|
if (isSet(value)) {
|
|
@@ -3133,7 +3147,8 @@ class EditorStringTextarea extends EditorString {
|
|
|
3133
3147
|
this.theme.adaptForTableTextareaControl(this.control);
|
|
3134
3148
|
}
|
|
3135
3149
|
addEventListeners() {
|
|
3136
|
-
this.
|
|
3150
|
+
const eventType = this.getValidationEventType();
|
|
3151
|
+
this.control.input.addEventListener(eventType, () => {
|
|
3137
3152
|
this.instance.setValue(this.control.input.value, true, "user");
|
|
3138
3153
|
});
|
|
3139
3154
|
}
|
|
@@ -3257,7 +3272,8 @@ class EditorStringInput extends EditorString {
|
|
|
3257
3272
|
this.theme.adaptForTableInputControl(this.control);
|
|
3258
3273
|
}
|
|
3259
3274
|
addEventListeners() {
|
|
3260
|
-
this.
|
|
3275
|
+
const eventType = this.getValidationEventType();
|
|
3276
|
+
this.control.input.addEventListener(eventType, () => {
|
|
3261
3277
|
this.instance.setValue(this.control.input.value, true, "user");
|
|
3262
3278
|
});
|
|
3263
3279
|
}
|
|
@@ -3383,7 +3399,8 @@ class EditorNumberInput extends EditorNumber {
|
|
|
3383
3399
|
this.theme.adaptForTableInputControl(this.control);
|
|
3384
3400
|
}
|
|
3385
3401
|
addEventListeners() {
|
|
3386
|
-
this.
|
|
3402
|
+
const eventType = this.getValidationEventType();
|
|
3403
|
+
this.control.input.addEventListener(eventType, () => {
|
|
3387
3404
|
const value = this.sanitize(this.control.input.value);
|
|
3388
3405
|
this.instance.setValue(value, true, "user");
|
|
3389
3406
|
});
|
|
@@ -3411,7 +3428,8 @@ class EditorNumberInputNullable extends EditorNumberInput {
|
|
|
3411
3428
|
return isSet(format2) && format2 === "number-nullable" && isSet(schemaType) && isArray(schemaType) && schemaType.length === 2 && schemaType.includes("null") && (schemaType.includes("number") || schemaType.includes("integer"));
|
|
3412
3429
|
}
|
|
3413
3430
|
addEventListeners() {
|
|
3414
|
-
this.
|
|
3431
|
+
const eventType = this.getValidationEventType();
|
|
3432
|
+
this.control.input.addEventListener(eventType, () => {
|
|
3415
3433
|
const value = this.sanitize(this.control.input.value);
|
|
3416
3434
|
this.instance.setValue(value, true, "user");
|
|
3417
3435
|
});
|
|
@@ -3632,27 +3650,25 @@ class EditorObjectGrid extends EditorObject {
|
|
|
3632
3650
|
}
|
|
3633
3651
|
let row = this.theme.getRow();
|
|
3634
3652
|
this.control.childrenSlot.appendChild(row);
|
|
3635
|
-
let colCount = 0;
|
|
3636
3653
|
this.instance.children.forEach((child) => {
|
|
3637
3654
|
if (child.isActive) {
|
|
3638
3655
|
const childGridOptions = getSchemaXOption(child.schema, "grid") || {};
|
|
3639
|
-
const
|
|
3640
|
-
const
|
|
3641
|
-
const
|
|
3656
|
+
const gridColumns = getSchemaXOption(child.schema, "gridColumns") ?? void 0;
|
|
3657
|
+
const gridOffset = getSchemaXOption(child.schema, "gridOffset") ?? 0;
|
|
3658
|
+
const columnsMdRetro = childGridOptions.columns ?? void 0;
|
|
3659
|
+
const columnsXs = childGridOptions.columnsXs ?? gridColumns ?? 12;
|
|
3660
|
+
const columnsSm = childGridOptions.columnsSm ?? gridColumns ?? columnsXs;
|
|
3661
|
+
const columnsMd = childGridOptions.columnsMd ?? columnsMdRetro ?? gridColumns ?? columnsSm;
|
|
3662
|
+
const columnsLg = childGridOptions.columnsLg ?? gridColumns ?? columnsMd;
|
|
3663
|
+
const offset = childGridOptions.offset ?? gridOffset;
|
|
3664
|
+
const col = this.theme.getCol(columnsXs, columnsSm, columnsMd, columnsLg, offset);
|
|
3642
3665
|
const newRow = childGridOptions.newRow || false;
|
|
3643
|
-
colCount += columns + offset;
|
|
3644
3666
|
if (newRow) {
|
|
3645
3667
|
row = this.theme.getRow();
|
|
3646
3668
|
this.control.childrenSlot.appendChild(row);
|
|
3647
|
-
colCount = 0;
|
|
3648
3669
|
}
|
|
3649
3670
|
row.appendChild(col);
|
|
3650
3671
|
col.appendChild(child.ui.control.container);
|
|
3651
|
-
if (colCount >= 12) {
|
|
3652
|
-
const clearfix = this.theme.getClearfix();
|
|
3653
|
-
row.appendChild(clearfix);
|
|
3654
|
-
colCount = 0;
|
|
3655
|
-
}
|
|
3656
3672
|
if (this.disabled || this.instance.isReadOnly()) {
|
|
3657
3673
|
child.ui.disable();
|
|
3658
3674
|
} else {
|
|
@@ -4755,7 +4771,8 @@ class EditorNumberRange extends EditorNumber {
|
|
|
4755
4771
|
this.control.input.addEventListener("input", () => {
|
|
4756
4772
|
this.control.output.textContent = parseFloat(this.control.input.value);
|
|
4757
4773
|
});
|
|
4758
|
-
this.
|
|
4774
|
+
const eventType = this.getValidationEventType();
|
|
4775
|
+
this.control.input.addEventListener(eventType, () => {
|
|
4759
4776
|
const value = parseFloat(this.control.input.value);
|
|
4760
4777
|
this.control.output.textContent = value;
|
|
4761
4778
|
this.instance.setValue(value, true, "user");
|
|
@@ -7049,11 +7066,13 @@ class Theme {
|
|
|
7049
7066
|
/**
|
|
7050
7067
|
* A column to contain content to a specific width
|
|
7051
7068
|
*/
|
|
7052
|
-
getCol(xs, md, offsetMd) {
|
|
7069
|
+
getCol(xs, sm, md, lg, offsetMd) {
|
|
7053
7070
|
const col = document.createElement("div");
|
|
7054
7071
|
col.classList.add("jedi-col");
|
|
7055
7072
|
col.classList.add("jedi-col-xs-" + xs);
|
|
7073
|
+
col.classList.add("jedi-col-sm-" + sm);
|
|
7056
7074
|
col.classList.add("jedi-col-md-" + md);
|
|
7075
|
+
col.classList.add("jedi-col-lg-" + lg);
|
|
7057
7076
|
if (offsetMd) {
|
|
7058
7077
|
col.classList.add("jedi-col-md-offset-" + offsetMd);
|
|
7059
7078
|
}
|
|
@@ -7400,10 +7419,12 @@ class ThemeBootstrap3 extends Theme {
|
|
|
7400
7419
|
row.classList.add("row");
|
|
7401
7420
|
return row;
|
|
7402
7421
|
}
|
|
7403
|
-
getCol(xs, md, offsetMd) {
|
|
7422
|
+
getCol(xs, sm, md, lg, offsetMd) {
|
|
7404
7423
|
const col = super.getCol();
|
|
7405
7424
|
col.classList.add("col-xs-" + xs);
|
|
7425
|
+
col.classList.add("col-sm-" + sm);
|
|
7406
7426
|
col.classList.add("col-md-" + md);
|
|
7427
|
+
col.classList.add("col-lg-" + lg);
|
|
7407
7428
|
if (offsetMd) {
|
|
7408
7429
|
col.classList.add("col-md-offset-" + offsetMd);
|
|
7409
7430
|
}
|
|
@@ -7751,10 +7772,12 @@ class ThemeBootstrap4 extends Theme {
|
|
|
7751
7772
|
row.classList.add("row");
|
|
7752
7773
|
return row;
|
|
7753
7774
|
}
|
|
7754
|
-
getCol(xs, md, offsetMd) {
|
|
7775
|
+
getCol(xs, sm, md, lg, offsetMd) {
|
|
7755
7776
|
const col = super.getCol(xs, md, offsetMd);
|
|
7756
7777
|
col.classList.add("col-" + xs);
|
|
7778
|
+
col.classList.add("col-sm" + sm);
|
|
7757
7779
|
col.classList.add("col-md-" + md);
|
|
7780
|
+
col.classList.add("col-lg-" + lg);
|
|
7758
7781
|
if (offsetMd) {
|
|
7759
7782
|
col.classList.add("offset-md-" + offsetMd);
|
|
7760
7783
|
}
|
|
@@ -8100,10 +8123,12 @@ class ThemeBootstrap5 extends Theme {
|
|
|
8100
8123
|
row.classList.add("row");
|
|
8101
8124
|
return row;
|
|
8102
8125
|
}
|
|
8103
|
-
getCol(xs, md, offsetMd) {
|
|
8126
|
+
getCol(xs, sm, md, lg, offsetMd) {
|
|
8104
8127
|
const col = super.getCol(xs, md, offsetMd);
|
|
8105
8128
|
col.classList.add("col-" + xs);
|
|
8129
|
+
col.classList.add("col-sm" + sm);
|
|
8106
8130
|
col.classList.add("col-md-" + md);
|
|
8131
|
+
col.classList.add("col-lg-" + lg);
|
|
8107
8132
|
if (offsetMd) {
|
|
8108
8133
|
col.classList.add("offset-md-" + offsetMd);
|
|
8109
8134
|
}
|