jedison 1.12.3 → 1.14.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.
@@ -2786,6 +2786,12 @@ class InstanceMultiple extends Instance {
2786
2786
  "Null"
2787
2787
  ];
2788
2788
  }
2789
+ const switcherTypeLabels = getSchemaXOption(this.schema, "switcherTypeLabels") ?? this.jedison.getOption("switcherTypeLabels");
2790
+ if (switcherTypeLabels && typeof switcherTypeLabels === "object") {
2791
+ this.switcherOptionsLabels = this.switcherOptionsLabels.map(
2792
+ (label) => hasOwn(switcherTypeLabels, label) ? switcherTypeLabels[label] : label
2793
+ );
2794
+ }
2789
2795
  this.schemas.forEach((schema) => {
2790
2796
  const instance = this.jedison.createInstance({
2791
2797
  jedison: this.jedison,
@@ -4638,6 +4644,59 @@ class EditorObjectHorizontal extends EditorObject {
4638
4644
  });
4639
4645
  }
4640
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
+ }
4641
4700
  class EditorArray extends Editor {
4642
4701
  static resolves(schema) {
4643
4702
  return getSchemaType(schema) === "array";
@@ -6591,6 +6650,7 @@ class UiResolver {
6591
6650
  EditorObjectNav,
6592
6651
  EditorObjectAccordion,
6593
6652
  EditorObjectHorizontal,
6653
+ EditorObjectRadios,
6594
6654
  EditorObject,
6595
6655
  EditorArrayChoices,
6596
6656
  EditorArrayCheckboxes,
@@ -6956,7 +7016,8 @@ class Jedison extends EventEmitter {
6956
7016
  enforceEnum: true,
6957
7017
  subErrors: false,
6958
7018
  debug: false,
6959
- audacity: true
7019
+ audacity: true,
7020
+ switcherTypeLabels: {}
6960
7021
  }, options);
6961
7022
  this.rootName = "#";
6962
7023
  this.pathSeparator = "/";
@@ -7848,6 +7909,7 @@ class Theme {
7848
7909
  config.propertiesContainer.close();
7849
7910
  } else {
7850
7911
  config.propertiesContainer.showModal();
7912
+ config.propertiesContainer.focus();
7851
7913
  }
7852
7914
  });
7853
7915
  return toggle;
@@ -8026,6 +8088,11 @@ class Theme {
8026
8088
  * Group for property activators
8027
8089
  */
8028
8090
  getPropertiesGroup(config = {}) {
8091
+ if (config.accordion && config.name) {
8092
+ const id = "jedi-prop-group-" + config.name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
8093
+ const item = this.getAccordionItem({ title: config.name, id });
8094
+ return { container: item.container, group: item.body, name: item.toggle };
8095
+ }
8029
8096
  const container = document.createElement("div");
8030
8097
  container.classList.add("jedi-properties-group-container");
8031
8098
  const group = document.createElement("div");
@@ -8206,7 +8273,8 @@ class Theme {
8206
8273
  dialog.classList.add("jedi-modal-dialog");
8207
8274
  dialog.style.border = "1px solid #6c757d";
8208
8275
  dialog.style.borderRadius = "4px";
8209
- dialog.style.minWidth = "200px";
8276
+ dialog.style.minWidth = "400px";
8277
+ dialog.style.maxWidth = "90vw";
8210
8278
  return dialog;
8211
8279
  }
8212
8280
  /**
@@ -11159,6 +11227,7 @@ const index = {
11159
11227
  EditorObjectNav,
11160
11228
  EditorObjectAccordion,
11161
11229
  EditorObjectHorizontal,
11230
+ EditorObjectRadios,
11162
11231
  EditorObject,
11163
11232
  EditorArrayChoices,
11164
11233
  EditorArrayNav,