jedison 1.13.0 → 1.15.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 +8 -1
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +125 -3
- 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 +3 -3
package/dist/esm/jedison.js
CHANGED
|
@@ -4644,6 +4644,59 @@ class EditorObjectHorizontal extends EditorObject {
|
|
|
4644
4644
|
});
|
|
4645
4645
|
}
|
|
4646
4646
|
}
|
|
4647
|
+
class EditorObjectRadios extends Editor {
|
|
4648
|
+
static resolves(schema) {
|
|
4649
|
+
const format2 = getSchemaXOption(schema, "format");
|
|
4650
|
+
return getSchemaType(schema) === "object" && (format2 === "radios" || format2 === "radios-inline") && isSet(getSchemaEnum(schema));
|
|
4651
|
+
}
|
|
4652
|
+
build() {
|
|
4653
|
+
const enumValues = getSchemaEnum(this.instance.schema);
|
|
4654
|
+
const enumTitles = getSchemaXOption(this.instance.schema, "enumTitles") || enumValues.map((v) => JSON.stringify(v));
|
|
4655
|
+
const inline = getSchemaXOption(this.instance.schema, "format") === "radios-inline";
|
|
4656
|
+
this.control = this.theme.getRadiosControl({
|
|
4657
|
+
title: this.getTitle(),
|
|
4658
|
+
description: this.getDescription(),
|
|
4659
|
+
values: enumTitles,
|
|
4660
|
+
titles: enumTitles,
|
|
4661
|
+
id: this.getIdFromPath(this.instance.path),
|
|
4662
|
+
titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
|
|
4663
|
+
inline,
|
|
4664
|
+
info: this.getInfo()
|
|
4665
|
+
});
|
|
4666
|
+
this.control.radios.forEach((radio, index2) => {
|
|
4667
|
+
radio._enumValue = enumValues[index2];
|
|
4668
|
+
});
|
|
4669
|
+
}
|
|
4670
|
+
addEventListeners() {
|
|
4671
|
+
this.control.radios.forEach((radio) => {
|
|
4672
|
+
radio.addEventListener("change", () => {
|
|
4673
|
+
this.instance.setValue(radio._enumValue, true, "user");
|
|
4674
|
+
});
|
|
4675
|
+
});
|
|
4676
|
+
}
|
|
4677
|
+
refreshUI() {
|
|
4678
|
+
this.refreshDisabledState();
|
|
4679
|
+
const currentValue = this.instance.getValue();
|
|
4680
|
+
this.control.radios.forEach((radio) => {
|
|
4681
|
+
radio.checked = equal(radio._enumValue, currentValue);
|
|
4682
|
+
});
|
|
4683
|
+
}
|
|
4684
|
+
setAriaInvalid(invalid) {
|
|
4685
|
+
this.control.radios.forEach((radio) => {
|
|
4686
|
+
if (invalid) {
|
|
4687
|
+
radio.setAttribute("aria-invalid", "true");
|
|
4688
|
+
} else {
|
|
4689
|
+
radio.removeAttribute("aria-invalid");
|
|
4690
|
+
}
|
|
4691
|
+
});
|
|
4692
|
+
}
|
|
4693
|
+
adaptForTable() {
|
|
4694
|
+
this.theme.adaptForTableRadiosControl(this.control);
|
|
4695
|
+
}
|
|
4696
|
+
adaptForHorizontal(labelCol, inputCol) {
|
|
4697
|
+
this.theme.adaptForHorizontalRadiosControl(this.control, labelCol, inputCol);
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4647
4700
|
class EditorArray extends Editor {
|
|
4648
4701
|
static resolves(schema) {
|
|
4649
4702
|
return getSchemaType(schema) === "array";
|
|
@@ -5602,6 +5655,12 @@ class EditorMultiple extends Editor {
|
|
|
5602
5655
|
});
|
|
5603
5656
|
});
|
|
5604
5657
|
}
|
|
5658
|
+
if (this.switcherInput === "select-inline") {
|
|
5659
|
+
this.control.switcher.input.addEventListener("change", () => {
|
|
5660
|
+
const index2 = Number(this.control.switcher.input.value);
|
|
5661
|
+
this.instance.switchInstance(index2, void 0, "user");
|
|
5662
|
+
});
|
|
5663
|
+
}
|
|
5605
5664
|
}
|
|
5606
5665
|
refreshUI() {
|
|
5607
5666
|
var _a;
|
|
@@ -5619,7 +5678,7 @@ class EditorMultiple extends Editor {
|
|
|
5619
5678
|
this.control.header.appendChild(this.control.switcher.container);
|
|
5620
5679
|
}
|
|
5621
5680
|
}
|
|
5622
|
-
if (this.switcherInput === "modal") {
|
|
5681
|
+
if (this.switcherInput === "modal" || this.switcherInput === "select-inline") {
|
|
5623
5682
|
const childControl = this.instance.activeInstance.ui.control;
|
|
5624
5683
|
const infoContainer = childControl.infoContainer;
|
|
5625
5684
|
const titleEl = childControl.legendText || childControl.label;
|
|
@@ -5636,6 +5695,9 @@ class EditorMultiple extends Editor {
|
|
|
5636
5695
|
if (this.switcherInput === "select") {
|
|
5637
5696
|
this.control.switcher.input.value = this.instance.index;
|
|
5638
5697
|
}
|
|
5698
|
+
if (this.switcherInput === "select-inline") {
|
|
5699
|
+
this.control.switcher.input.value = this.instance.index;
|
|
5700
|
+
}
|
|
5639
5701
|
if (this.switcherInput === "radios" || this.switcherInput === "radios-inline") {
|
|
5640
5702
|
this.control.switcher.radios.forEach((radio) => {
|
|
5641
5703
|
const radioIndex = Number(radio.value);
|
|
@@ -6597,6 +6659,7 @@ class UiResolver {
|
|
|
6597
6659
|
EditorObjectNav,
|
|
6598
6660
|
EditorObjectAccordion,
|
|
6599
6661
|
EditorObjectHorizontal,
|
|
6662
|
+
EditorObjectRadios,
|
|
6600
6663
|
EditorObject,
|
|
6601
6664
|
EditorArrayChoices,
|
|
6602
6665
|
EditorArrayCheckboxes,
|
|
@@ -7855,6 +7918,7 @@ class Theme {
|
|
|
7855
7918
|
config.propertiesContainer.close();
|
|
7856
7919
|
} else {
|
|
7857
7920
|
config.propertiesContainer.showModal();
|
|
7921
|
+
config.propertiesContainer.focus();
|
|
7858
7922
|
}
|
|
7859
7923
|
});
|
|
7860
7924
|
return toggle;
|
|
@@ -8033,6 +8097,11 @@ class Theme {
|
|
|
8033
8097
|
* Group for property activators
|
|
8034
8098
|
*/
|
|
8035
8099
|
getPropertiesGroup(config = {}) {
|
|
8100
|
+
if (config.accordion && config.name) {
|
|
8101
|
+
const id = "jedi-prop-group-" + config.name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
8102
|
+
const item = this.getAccordionItem({ title: config.name, id });
|
|
8103
|
+
return { container: item.container, group: item.body, name: item.toggle };
|
|
8104
|
+
}
|
|
8036
8105
|
const container = document.createElement("div");
|
|
8037
8106
|
container.classList.add("jedi-properties-group-container");
|
|
8038
8107
|
const group = document.createElement("div");
|
|
@@ -8213,7 +8282,8 @@ class Theme {
|
|
|
8213
8282
|
dialog.classList.add("jedi-modal-dialog");
|
|
8214
8283
|
dialog.style.border = "1px solid #6c757d";
|
|
8215
8284
|
dialog.style.borderRadius = "4px";
|
|
8216
|
-
dialog.style.minWidth = "
|
|
8285
|
+
dialog.style.minWidth = "400px";
|
|
8286
|
+
dialog.style.maxWidth = "90vw";
|
|
8217
8287
|
return dialog;
|
|
8218
8288
|
}
|
|
8219
8289
|
/**
|
|
@@ -8790,7 +8860,7 @@ class Theme {
|
|
|
8790
8860
|
const messages = this.getMessagesSlot();
|
|
8791
8861
|
const childrenSlot = this.getChildrenSlot();
|
|
8792
8862
|
const randomId = generateRandomID(5);
|
|
8793
|
-
const knownSwitchers = ["select", "radios", "radios-inline", "modal"];
|
|
8863
|
+
const knownSwitchers = ["select", "radios", "radios-inline", "modal", "select-inline"];
|
|
8794
8864
|
const switcherType = knownSwitchers.includes(config.switcher) ? config.switcher : "select";
|
|
8795
8865
|
let switcher;
|
|
8796
8866
|
if (switcherType === "select") {
|
|
@@ -8826,6 +8896,14 @@ class Theme {
|
|
|
8826
8896
|
readOnly: config.readOnly
|
|
8827
8897
|
});
|
|
8828
8898
|
}
|
|
8899
|
+
if (switcherType === "select-inline") {
|
|
8900
|
+
switcher = this.getSwitcherSelectInline({
|
|
8901
|
+
values: config.switcherOptionValues,
|
|
8902
|
+
titles: config.switcherOptionsLabels,
|
|
8903
|
+
id: config.id + "-switcher-" + randomId,
|
|
8904
|
+
readOnly: config.readOnly
|
|
8905
|
+
});
|
|
8906
|
+
}
|
|
8829
8907
|
switcher.container.classList.add("jedi-switcher");
|
|
8830
8908
|
container.appendChild(header);
|
|
8831
8909
|
container.appendChild(body);
|
|
@@ -9343,6 +9421,31 @@ class Theme {
|
|
|
9343
9421
|
setSwitcherOptionActive(btn, active) {
|
|
9344
9422
|
btn.classList.toggle("jedi-switcher-option-active", active);
|
|
9345
9423
|
}
|
|
9424
|
+
/**
|
|
9425
|
+
* Compact inline <select> to switch between multiple editors options (no dialog)
|
|
9426
|
+
*/
|
|
9427
|
+
getSwitcherSelectInline(config) {
|
|
9428
|
+
const container = document.createElement("span");
|
|
9429
|
+
const input = document.createElement("select");
|
|
9430
|
+
container.classList.add("jedi-switcher-select-inline");
|
|
9431
|
+
container.style.display = "inline-block";
|
|
9432
|
+
input.classList.add("jedi-switcher-select-inline-input");
|
|
9433
|
+
input.style.width = "auto";
|
|
9434
|
+
input.setAttribute("aria-label", "Switch type");
|
|
9435
|
+
if (config.readOnly) {
|
|
9436
|
+
input.setAttribute("disabled", "");
|
|
9437
|
+
}
|
|
9438
|
+
config.values.forEach((value, index2) => {
|
|
9439
|
+
const option = document.createElement("option");
|
|
9440
|
+
option.setAttribute("value", value);
|
|
9441
|
+
if (config.titles && config.titles[index2]) {
|
|
9442
|
+
option.textContent = config.titles[index2];
|
|
9443
|
+
}
|
|
9444
|
+
input.appendChild(option);
|
|
9445
|
+
});
|
|
9446
|
+
container.appendChild(input);
|
|
9447
|
+
return { container, input };
|
|
9448
|
+
}
|
|
9346
9449
|
/**
|
|
9347
9450
|
* Another type of error message container used for more complex editors like
|
|
9348
9451
|
* object, array and multiple editors
|
|
@@ -9905,6 +10008,12 @@ class ThemeBootstrap3 extends Theme {
|
|
|
9905
10008
|
control.input.classList.add("input-sm");
|
|
9906
10009
|
return control;
|
|
9907
10010
|
}
|
|
10011
|
+
getSwitcherSelectInline(config) {
|
|
10012
|
+
const control = super.getSwitcherSelectInline(config);
|
|
10013
|
+
control.container.style.marginBottom = "5px";
|
|
10014
|
+
control.input.classList.add("input-sm");
|
|
10015
|
+
return control;
|
|
10016
|
+
}
|
|
9908
10017
|
getSwitcherModal(config) {
|
|
9909
10018
|
const control = super.getSwitcherModal(config);
|
|
9910
10019
|
control.trigger.classList.add("label", "label-primary");
|
|
@@ -10438,6 +10547,12 @@ class ThemeBootstrap4 extends Theme {
|
|
|
10438
10547
|
control.input.classList.add("form-control-sm");
|
|
10439
10548
|
return control;
|
|
10440
10549
|
}
|
|
10550
|
+
getSwitcherSelectInline(config) {
|
|
10551
|
+
const control = super.getSwitcherSelectInline(config);
|
|
10552
|
+
control.container.classList.add("mb-2");
|
|
10553
|
+
control.input.classList.add("form-control", "form-control-sm");
|
|
10554
|
+
return control;
|
|
10555
|
+
}
|
|
10441
10556
|
getSwitcherModal(config) {
|
|
10442
10557
|
const control = super.getSwitcherModal(config);
|
|
10443
10558
|
control.trigger.classList.add("badge", "badge-primary");
|
|
@@ -10983,6 +11098,12 @@ class ThemeBootstrap5 extends Theme {
|
|
|
10983
11098
|
control.input.classList.add("form-select-sm");
|
|
10984
11099
|
return control;
|
|
10985
11100
|
}
|
|
11101
|
+
getSwitcherSelectInline(config) {
|
|
11102
|
+
const control = super.getSwitcherSelectInline(config);
|
|
11103
|
+
control.container.classList.add("mb-1");
|
|
11104
|
+
control.input.classList.add("form-select", "form-select-sm");
|
|
11105
|
+
return control;
|
|
11106
|
+
}
|
|
10986
11107
|
getSwitcherModal(config) {
|
|
10987
11108
|
const control = super.getSwitcherModal(config);
|
|
10988
11109
|
control.trigger.classList.add("badge", "bg-primary");
|
|
@@ -11166,6 +11287,7 @@ const index = {
|
|
|
11166
11287
|
EditorObjectNav,
|
|
11167
11288
|
EditorObjectAccordion,
|
|
11168
11289
|
EditorObjectHorizontal,
|
|
11290
|
+
EditorObjectRadios,
|
|
11169
11291
|
EditorObject,
|
|
11170
11292
|
EditorArrayChoices,
|
|
11171
11293
|
EditorArrayNav,
|