jedison 0.2.3 → 0.3.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.
- package/CHANGELOG.md +5 -0
- package/README.md +3 -3
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +106 -1
- 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 +1 -1
package/dist/esm/jedison.js
CHANGED
|
@@ -3319,6 +3319,12 @@ class EditorNumberInput extends EditorNumber {
|
|
|
3319
3319
|
const value = this.sanitize(this.control.input.value);
|
|
3320
3320
|
this.instance.setValue(value, true, "user");
|
|
3321
3321
|
});
|
|
3322
|
+
this.control.input.addEventListener("focus", () => {
|
|
3323
|
+
this.control.input.value = this.instance.getValue().toString;
|
|
3324
|
+
});
|
|
3325
|
+
this.control.input.addEventListener("blur", () => {
|
|
3326
|
+
this.refreshUI();
|
|
3327
|
+
});
|
|
3322
3328
|
}
|
|
3323
3329
|
refreshUI() {
|
|
3324
3330
|
super.refreshUI();
|
|
@@ -3728,6 +3734,104 @@ class EditorArray extends Editor {
|
|
|
3728
3734
|
}
|
|
3729
3735
|
}
|
|
3730
3736
|
class EditorArrayTable extends EditorArray {
|
|
3737
|
+
static resolves(schema, refParser) {
|
|
3738
|
+
return getSchemaType(schema) === "array" && getSchemaXOption(schema, "format") === "table-generic";
|
|
3739
|
+
}
|
|
3740
|
+
addEventListeners() {
|
|
3741
|
+
this.control.addBtn.addEventListener("click", () => {
|
|
3742
|
+
this.activeItemIndex = this.instance.value.length;
|
|
3743
|
+
this.instance.addItem("user");
|
|
3744
|
+
});
|
|
3745
|
+
}
|
|
3746
|
+
isSortable() {
|
|
3747
|
+
return window.Sortable && isSet(getSchemaXOption(this.instance.schema, "sortable"));
|
|
3748
|
+
}
|
|
3749
|
+
refreshUI() {
|
|
3750
|
+
this.control.childrenSlot.innerHTML = "";
|
|
3751
|
+
const table = this.theme.getTable();
|
|
3752
|
+
this.control.childrenSlot.appendChild(table.container);
|
|
3753
|
+
const th = this.theme.getTableHeader();
|
|
3754
|
+
const { label } = this.theme.getFakeLabel({
|
|
3755
|
+
content: "Controls",
|
|
3756
|
+
visuallyHidden: true
|
|
3757
|
+
});
|
|
3758
|
+
th.appendChild(label);
|
|
3759
|
+
table.thead.appendChild(th);
|
|
3760
|
+
if (this.instance.children.length) {
|
|
3761
|
+
const schemaItems = getSchemaItems(this.instance.schema);
|
|
3762
|
+
const thTitle = this.theme.getTableHeader();
|
|
3763
|
+
if (schemaItems.title) {
|
|
3764
|
+
const fakeLabel = this.theme.getFakeLabel({
|
|
3765
|
+
content: schemaItems.title
|
|
3766
|
+
});
|
|
3767
|
+
thTitle.appendChild(fakeLabel.label);
|
|
3768
|
+
}
|
|
3769
|
+
const schemaXInfo = getSchemaXOption(schemaItems, "info");
|
|
3770
|
+
if (isSet(schemaXInfo)) {
|
|
3771
|
+
const infoContent = this.getInfo(schemaItems);
|
|
3772
|
+
const info = this.theme.getInfo(infoContent);
|
|
3773
|
+
if (schemaXInfo.variant === "modal") {
|
|
3774
|
+
this.theme.infoAsModal(info, this.getIdFromPath(this.instance.path), infoContent);
|
|
3775
|
+
}
|
|
3776
|
+
thTitle.appendChild(info.container);
|
|
3777
|
+
}
|
|
3778
|
+
table.thead.appendChild(thTitle);
|
|
3779
|
+
}
|
|
3780
|
+
const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
|
|
3781
|
+
const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
|
|
3782
|
+
this.instance.children.forEach((child, index2) => {
|
|
3783
|
+
const tbodyRow = document.createElement("tr");
|
|
3784
|
+
const buttonsTd = this.theme.getTableDefinition();
|
|
3785
|
+
const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup } = this.getButtons(index2);
|
|
3786
|
+
if (this.isSortable()) {
|
|
3787
|
+
btnGroup.appendChild(dragBtn);
|
|
3788
|
+
}
|
|
3789
|
+
if (isSet(arrayDelete) && arrayDelete === true) {
|
|
3790
|
+
btnGroup.appendChild(deleteBtn);
|
|
3791
|
+
}
|
|
3792
|
+
if (isSet(arrayMove) && arrayMove === true) {
|
|
3793
|
+
btnGroup.appendChild(moveUpBtn);
|
|
3794
|
+
btnGroup.appendChild(moveDownBtn);
|
|
3795
|
+
}
|
|
3796
|
+
buttonsTd.appendChild(btnGroup);
|
|
3797
|
+
tbodyRow.appendChild(buttonsTd);
|
|
3798
|
+
const td = this.theme.getTableDefinition();
|
|
3799
|
+
child.ui.adaptForTable(child, td);
|
|
3800
|
+
td.appendChild(child.ui.control.container);
|
|
3801
|
+
tbodyRow.appendChild(td);
|
|
3802
|
+
table.tbody.appendChild(tbodyRow);
|
|
3803
|
+
});
|
|
3804
|
+
this.refreshSortable(table.tbody);
|
|
3805
|
+
this.refreshDisabledState();
|
|
3806
|
+
this.refreshScrollPosition(table.container);
|
|
3807
|
+
table.container.addEventListener("scroll", () => {
|
|
3808
|
+
this.lastScrollTop = table.container.scrollTop;
|
|
3809
|
+
this.lastScrollLeft = table.container.scrollLeft;
|
|
3810
|
+
});
|
|
3811
|
+
}
|
|
3812
|
+
refreshScrollPosition(element) {
|
|
3813
|
+
element.scroll({
|
|
3814
|
+
top: this.lastScrollTop,
|
|
3815
|
+
left: this.lastScrollLeft
|
|
3816
|
+
});
|
|
3817
|
+
}
|
|
3818
|
+
refreshSortable(container) {
|
|
3819
|
+
if (this.isSortable()) {
|
|
3820
|
+
if (this.sortable) {
|
|
3821
|
+
this.sortable.destroy();
|
|
3822
|
+
}
|
|
3823
|
+
this.sortable = window.Sortable.create(container, {
|
|
3824
|
+
animation: 150,
|
|
3825
|
+
handle: ".jedi-array-drag",
|
|
3826
|
+
disabled: this.disabled || this.readOnly,
|
|
3827
|
+
onEnd: (evt) => {
|
|
3828
|
+
this.instance.move(evt.oldIndex, evt.newIndex);
|
|
3829
|
+
}
|
|
3830
|
+
});
|
|
3831
|
+
}
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
class EditorArrayTableObject extends EditorArray {
|
|
3731
3835
|
static resolves(schema, refParser) {
|
|
3732
3836
|
let schemaItems = getSchemaItems(schema);
|
|
3733
3837
|
if (!schemaItems) {
|
|
@@ -3740,7 +3844,7 @@ class EditorArrayTable extends EditorArray {
|
|
|
3740
3844
|
if (!itemType) {
|
|
3741
3845
|
return false;
|
|
3742
3846
|
}
|
|
3743
|
-
return getSchemaType(schema) === "array" && itemType === "object" && getSchemaXOption(schema, "format") === "table";
|
|
3847
|
+
return getSchemaType(schema) === "array" && itemType === "object" && getSchemaXOption(schema, "format") === "table-object";
|
|
3744
3848
|
}
|
|
3745
3849
|
addEventListeners() {
|
|
3746
3850
|
this.control.addBtn.addEventListener("click", () => {
|
|
@@ -4370,6 +4474,7 @@ class UiResolver {
|
|
|
4370
4474
|
EditorObject,
|
|
4371
4475
|
EditorArrayChoices,
|
|
4372
4476
|
EditorArrayCheckboxes,
|
|
4477
|
+
EditorArrayTableObject,
|
|
4373
4478
|
EditorArrayTable,
|
|
4374
4479
|
EditorArrayNav,
|
|
4375
4480
|
EditorArray,
|