jedison 1.7.0 → 1.9.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.
@@ -199,10 +199,20 @@ function getValueByJSONPath(data, path) {
199
199
  return value;
200
200
  }
201
201
  function compileTemplate(template, data) {
202
- return template.replace(/{{(.*?)}}/g, (match) => {
203
- match = match.replace(/\s/g, "");
204
- const path = match.split(/{{|}}/)[1];
205
- return getValueByJSONPath(data, path);
202
+ return template.replace(/{{(.*?)}}/g, (_, inner) => {
203
+ inner = inner.trim();
204
+ const pipeIdx = inner.indexOf("||");
205
+ let path, fallback;
206
+ if (pipeIdx !== -1) {
207
+ path = inner.slice(0, pipeIdx).trim();
208
+ const raw = inner.slice(pipeIdx + 2).trim();
209
+ fallback = raw.replace(/^['"]|['"]$/g, "");
210
+ } else {
211
+ path = inner;
212
+ fallback = "";
213
+ }
214
+ const value = getValueByJSONPath(data, path);
215
+ return value !== void 0 && value !== null ? value : fallback;
206
216
  });
207
217
  }
208
218
  function clamp(number, min, max) {
@@ -270,6 +280,15 @@ const Utils = {
270
280
  removeDuplicatesFromArray,
271
281
  generateRandomID
272
282
  };
283
+ const OPTION_ALIASES = {
284
+ enforceEnumDefault: "enforceEnum"
285
+ };
286
+ function resolveAlias(name) {
287
+ return OPTION_ALIASES[name] ?? name;
288
+ }
289
+ function getAliasesFor(canonicalName) {
290
+ return Object.keys(OPTION_ALIASES).filter((old) => OPTION_ALIASES[old] === canonicalName);
291
+ }
273
292
  function getSchemaX(schema, keyword) {
274
293
  const key = "x-" + keyword;
275
294
  return schema[key];
@@ -405,7 +424,21 @@ function getSchemaXOption(schema, option) {
405
424
  if (isSet(schema[xOption])) {
406
425
  return schema[xOption];
407
426
  }
408
- return schema["x-options"] && isSet(schema["x-options"][option]) ? schema["x-options"][option] : void 0;
427
+ if (schema["x-options"] && isSet(schema["x-options"][option])) {
428
+ return schema["x-options"][option];
429
+ }
430
+ for (const alias of getAliasesFor(option)) {
431
+ const xAlias = "x-" + alias;
432
+ if (isSet(schema[xAlias])) {
433
+ console.warn(`Jedison: schema option "${xAlias}" is deprecated. Use "${xOption}" instead.`);
434
+ return schema[xAlias];
435
+ }
436
+ if (schema["x-options"] && isSet(schema["x-options"][alias])) {
437
+ console.warn(`Jedison: schema x-options.${alias} is deprecated. Use x-options.${option} instead.`);
438
+ return schema["x-options"][alias];
439
+ }
440
+ }
441
+ return void 0;
409
442
  }
410
443
  function getSchemaPattern(schema) {
411
444
  return isString(schema.pattern) ? clone(schema.pattern) : void 0;
@@ -1802,7 +1835,7 @@ class Instance extends EventEmitter {
1802
1835
  this.setDefaultValue();
1803
1836
  this.registerWatcher();
1804
1837
  this.setValueFormTemplate();
1805
- if (this.jedison.options.container) {
1838
+ if (this.jedison.getOption("container")) {
1806
1839
  this.setUI();
1807
1840
  }
1808
1841
  this.on("notifyParent", (initiator) => {
@@ -1865,13 +1898,9 @@ class Instance extends EventEmitter {
1865
1898
  * Sets the default value of the instance based on it's type
1866
1899
  */
1867
1900
  setInitialValue() {
1868
- const schemaEnforceEnumDefault = getSchemaXOption(this.schema, "enforceEnumDefault");
1869
- const schemaEnforceEnum = getSchemaXOption(this.schema, "enforceEnum");
1870
- const enforceEnumDefault = schemaEnforceEnumDefault ?? this.jedison.options.enforceEnumDefault;
1871
- const enforceEnum = schemaEnforceEnum ?? this.jedison.options.enforceEnum;
1872
- const finalEnforceEnum = isSet(schemaEnforceEnum) ? enforceEnum : enforceEnumDefault;
1901
+ const enforceEnum = getSchemaXOption(this.schema, "enforceEnum") ?? this.jedison.getOption("enforceEnum");
1873
1902
  const schemaEnum = getSchemaEnum(this.schema);
1874
- if (isSet(schemaEnum) && !schemaEnum.includes(this.getValueRaw()) && isSet(schemaEnum[0]) && finalEnforceEnum) {
1903
+ if (isSet(schemaEnum) && !schemaEnum.includes(this.getValueRaw()) && isSet(schemaEnum[0]) && enforceEnum) {
1875
1904
  this.setValue(schemaEnum[0], false);
1876
1905
  }
1877
1906
  if (notSet(this.value)) {
@@ -1892,7 +1921,7 @@ class Instance extends EventEmitter {
1892
1921
  if (isSet(schemaDefault)) {
1893
1922
  this.setValue(schemaDefault, false);
1894
1923
  }
1895
- const enforceConst = getSchemaXOption(this.schema, "enforceConst") ?? this.jedison.options.enforceConst;
1924
+ const enforceConst = getSchemaXOption(this.schema, "enforceConst") ?? this.jedison.getOption("enforceConst");
1896
1925
  if (isSet(enforceConst) && equal(enforceConst, true)) {
1897
1926
  const schemaConst = getSchemaConst(this.schema);
1898
1927
  if (isSet(schemaConst)) {
@@ -1949,7 +1978,7 @@ class Instance extends EventEmitter {
1949
1978
  const templateData = {
1950
1979
  ...this.arrayTemplateData,
1951
1980
  value: this.getValueRaw(),
1952
- settings: this.jedison.options.settings
1981
+ settings: this.jedison.getOption("settings")
1953
1982
  };
1954
1983
  if (typeof this.value === "string") {
1955
1984
  templateData.length = this.value.length;
@@ -1959,7 +1988,7 @@ class Instance extends EventEmitter {
1959
1988
  }
1960
1989
  if (template == null ? void 0 : template.includes("{{ functions.")) {
1961
1990
  templateData.functions = this.resolveTemplateFunctions(
1962
- this.jedison.options.functions
1991
+ this.jedison.getOption("functions")
1963
1992
  );
1964
1993
  }
1965
1994
  if (this.parent) {
@@ -1974,7 +2003,7 @@ class Instance extends EventEmitter {
1974
2003
  return Object.fromEntries(Object.entries(functionsObject).map(([functionName, functionValue]) => [functionName, functionValue(context)]));
1975
2004
  }
1976
2005
  purify(value) {
1977
- if (typeof value === "string" && this.jedison.options.purifyData && typeof window !== "undefined" && window.DOMPurify) {
2006
+ if (typeof value === "string" && this.jedison.getOption("purifyData") && typeof window !== "undefined" && window.DOMPurify) {
1978
2007
  value = window.DOMPurify.sanitize(value);
1979
2008
  }
1980
2009
  return value;
@@ -1990,7 +2019,7 @@ class Instance extends EventEmitter {
1990
2019
  const purifiedValue = this.purify(newValue);
1991
2020
  const wasPurified = newValue !== purifiedValue;
1992
2021
  newValue = purifiedValue;
1993
- const enforceConst = getSchemaXOption(this.schema, "enforceConst") ?? this.jedison.options.enforceConst;
2022
+ const enforceConst = getSchemaXOption(this.schema, "enforceConst") ?? this.jedison.getOption("enforceConst");
1994
2023
  if (isSet(enforceConst) && equal(enforceConst, true)) {
1995
2024
  const schemaConst = getSchemaConst(this.schema);
1996
2025
  if (isSet(schemaConst)) {
@@ -2116,7 +2145,7 @@ class Editor {
2116
2145
  this.setVisibility();
2117
2146
  this.setContainerAttributes();
2118
2147
  this.refreshUI();
2119
- const alwaysShowErrors = this.instance.jedison.options.showErrors === "always" || getSchemaXOption(this.instance.schema, "showErrors") === "always";
2148
+ const alwaysShowErrors = this.instance.jedison.getOption("showErrors") === "always" || getSchemaXOption(this.instance.schema, "showErrors") === "always";
2120
2149
  if (alwaysShowErrors) {
2121
2150
  this.showValidationErrors(this.instance.getErrors());
2122
2151
  }
@@ -2133,8 +2162,8 @@ class Editor {
2133
2162
  */
2134
2163
  init() {
2135
2164
  this.theme = this.instance.jedison.theme;
2136
- this.markdownEnabled = getSchemaXOption(this.instance.schema, "parseMarkdown") ?? this.instance.jedison.options.parseMarkdown;
2137
- this.purifyEnabled = getSchemaXOption(this.instance.schema, "purifyHtml") ?? this.instance.jedison.options.purifyHtml;
2165
+ this.markdownEnabled = getSchemaXOption(this.instance.schema, "parseMarkdown") ?? this.instance.jedison.getOption("parseMarkdown");
2166
+ this.purifyEnabled = getSchemaXOption(this.instance.schema, "purifyHtml") ?? this.instance.jedison.getOption("purifyHtml");
2138
2167
  }
2139
2168
  /**
2140
2169
  * Gets the json path level by counting how many "/" it has
@@ -2200,7 +2229,7 @@ class Editor {
2200
2229
  }
2201
2230
  }
2202
2231
  getIdFromPath(path) {
2203
- const optionId = this.instance.jedison.options.id;
2232
+ const optionId = this.instance.jedison.getOption("id");
2204
2233
  return optionId ? optionId + "-" + pathToAttribute(path) : pathToAttribute(path);
2205
2234
  }
2206
2235
  /**
@@ -2208,7 +2237,7 @@ class Editor {
2208
2237
  * @returns {string} - 'input' or 'change'
2209
2238
  */
2210
2239
  getValidationEventType() {
2211
- const showErrors = getSchemaXOption(this.instance.schema, "showErrors") ?? this.instance.jedison.options.showErrors;
2240
+ const showErrors = getSchemaXOption(this.instance.schema, "showErrors") ?? this.instance.jedison.getOption("showErrors");
2212
2241
  return showErrors === "input" ? "input" : "change";
2213
2242
  }
2214
2243
  /**
@@ -2240,11 +2269,11 @@ class Editor {
2240
2269
  this.control.messages.innerHTML = "";
2241
2270
  this.showingValidationErrors = false;
2242
2271
  this.setAriaInvalid(false);
2243
- const neverShowErrors = this.instance.jedison.options.showErrors === "never" || getSchemaXOption(this.instance.schema, "showErrors") === "never";
2272
+ const neverShowErrors = this.instance.jedison.getOption("showErrors") === "never" || getSchemaXOption(this.instance.schema, "showErrors") === "never";
2244
2273
  if (neverShowErrors && !force || errors.length === 0) {
2245
2274
  return;
2246
2275
  }
2247
- const muteValidationMessages = getSchemaXOption(this.instance.schema, "muteValidationMessages") ?? this.instance.jedison.options.muteValidationMessages ?? [];
2276
+ const muteValidationMessages = getSchemaXOption(this.instance.schema, "muteValidationMessages") ?? this.instance.jedison.getOption("muteValidationMessages") ?? [];
2248
2277
  let hasErrors = false;
2249
2278
  errors.forEach((error) => {
2250
2279
  if (muteValidationMessages.includes(error.constraint)) {
@@ -2309,7 +2338,7 @@ class Editor {
2309
2338
  * Clean out HTML tags from txt
2310
2339
  */
2311
2340
  purifyContent(content, domPurifyOptions) {
2312
- if (this.instance.jedison.options.purifyHtml && typeof window !== "undefined" && window.DOMPurify) {
2341
+ if (this.instance.jedison.getOption("purifyHtml") && typeof window !== "undefined" && window.DOMPurify) {
2313
2342
  return window.DOMPurify.sanitize(content, domPurifyOptions);
2314
2343
  } else {
2315
2344
  const tmp = document.createElement("div");
@@ -2331,7 +2360,7 @@ class Editor {
2331
2360
  if (titleFromSchema) {
2332
2361
  this.title = compileTemplate(this.title, this.instance.getTemplateData(this.title));
2333
2362
  this.title = this.markdownEnabled ? this.getHtmlFromMarkdown(this.title) : this.title;
2334
- const domPurifyOptions = combineDeep({}, this.instance.jedison.options.domPurifyOptions, {
2363
+ const domPurifyOptions = combineDeep({}, this.instance.jedison.getOption("domPurifyOptions"), {
2335
2364
  FORBID_TAGS: ["p"]
2336
2365
  });
2337
2366
  this.title = this.purifyEnabled ? this.purifyContent(this.title, domPurifyOptions) : this.title;
@@ -2343,7 +2372,7 @@ class Editor {
2343
2372
  if (isSet(schemaDescription)) {
2344
2373
  this.description = compileTemplate(schemaDescription, this.instance.getTemplateData(this.description));
2345
2374
  this.description = this.markdownEnabled ? this.getHtmlFromMarkdown(this.description) : this.description;
2346
- const domPurifyOptions = this.instance.jedison.options.domPurifyOptions;
2375
+ const domPurifyOptions = this.instance.jedison.getOption("domPurifyOptions");
2347
2376
  this.description = this.purifyEnabled ? this.purifyContent(this.description, domPurifyOptions) : this.description;
2348
2377
  }
2349
2378
  return this.description;
@@ -2354,7 +2383,7 @@ class Editor {
2354
2383
  if (!isSet(schemaInfo)) {
2355
2384
  return schemaInfo;
2356
2385
  }
2357
- const domPurifyOptions = this.instance.jedison.options.domPurifyOptions;
2386
+ const domPurifyOptions = this.instance.jedison.getOption("domPurifyOptions");
2358
2387
  if (isSet(schemaInfo.title)) {
2359
2388
  schemaInfo.title = this.markdownEnabled ? this.getHtmlFromMarkdown(schemaInfo.title) : schemaInfo.title;
2360
2389
  schemaInfo.title = this.purifyEnabled ? this.purifyContent(schemaInfo.title, domPurifyOptions) : schemaInfo.title;
@@ -2561,7 +2590,7 @@ class InstanceIfThenElse extends Instance {
2561
2590
  if (indexChanged && initiator !== "api") {
2562
2591
  instanceValue = overwriteExistingProperties(startingValue, withoutIf);
2563
2592
  } else {
2564
- const audacity = this.jedison.options.audacity;
2593
+ const audacity = this.jedison.getOption("audacity");
2565
2594
  if (audacity && initiator === "api" && index2 === fittestIndex) {
2566
2595
  const prePassValue = mergeDeep({}, instance.getValue(), value);
2567
2596
  instance.setValue(prePassValue, false, "api");
@@ -2584,6 +2613,7 @@ class InstanceIfThenElse extends Instance {
2584
2613
  if (initiator === "api" && this.hasNullableFields(this.activeInstance)) {
2585
2614
  this.activeInstance.setValue(value, false, "secondary");
2586
2615
  }
2616
+ this.activeInstance.register();
2587
2617
  this.value = this.activeInstance.getValueRaw();
2588
2618
  }
2589
2619
  getWithoutIfValueFromValue(value) {
@@ -2773,11 +2803,15 @@ class InstanceMultiple extends Instance {
2773
2803
  this.switchInstance(fittestIndex, this.value);
2774
2804
  }
2775
2805
  switchInstance(index2, value, initiator = "api") {
2806
+ if (this.activeInstance) {
2807
+ this.activeInstance.children.forEach((child) => child.unregister());
2808
+ }
2776
2809
  this.index = index2;
2777
2810
  this.activeInstance = this.instances[index2];
2778
2811
  if (isSet(value)) {
2779
2812
  this.activeInstance.setValue(value, false, initiator);
2780
2813
  }
2814
+ this.activeInstance.children.forEach((child) => child.register());
2781
2815
  this.setValue(this.activeInstance.getValueRaw(), true, initiator);
2782
2816
  }
2783
2817
  onSetValue() {
@@ -2849,7 +2883,7 @@ class InstanceObject extends Instance {
2849
2883
  this.properties[key] = { schema };
2850
2884
  let musstCreateChild = true;
2851
2885
  const isRecursive = isSet(schema["x-recursive"]);
2852
- const optionsDeactivateNonRequired = this.jedison.options.deactivateNonRequired;
2886
+ const optionsDeactivateNonRequired = this.jedison.getOption("deactivateNonRequired");
2853
2887
  const deactivateNonRequired = getSchemaXOption(this.schema, "deactivateNonRequired");
2854
2888
  const schemaDeactivateNonRequired = getSchemaXOption(schema, "deactivateNonRequired");
2855
2889
  const isReq = this.isRequired(key);
@@ -2870,7 +2904,7 @@ class InstanceObject extends Instance {
2870
2904
  }
2871
2905
  });
2872
2906
  }
2873
- if (isSet(schemaRequired) && this.jedison.isEditor && this.jedison.options.enforceRequired === true) {
2907
+ if (isSet(schemaRequired) && this.jedison.isEditor && this.jedison.getOption("enforceRequired") === true) {
2874
2908
  schemaRequired.forEach((requiredProperty) => {
2875
2909
  this.requiredProperties.add(requiredProperty);
2876
2910
  if (!hasOwn(this.properties, requiredProperty)) {
@@ -2888,7 +2922,7 @@ class InstanceObject extends Instance {
2888
2922
  }
2889
2923
  removeNotListedPropertiesFromValue(value) {
2890
2924
  const schemaEnforceAdditionalProperties = getSchemaXOption(this.schema, "enforceAdditionalProperties");
2891
- const enforceAdditionalProperties = isSet(schemaEnforceAdditionalProperties) ? schemaEnforceAdditionalProperties : this.jedison.options.enforceAdditionalProperties;
2925
+ const enforceAdditionalProperties = isSet(schemaEnforceAdditionalProperties) ? schemaEnforceAdditionalProperties : this.jedison.getOption("enforceAdditionalProperties");
2892
2926
  const schemaAdditionalProperties = this.schemaAdditionalProperties;
2893
2927
  const schemaPatternProperties = this.schemaPatternProperties || {};
2894
2928
  if (this.jedison.isEditor && enforceAdditionalProperties && isSet(schemaAdditionalProperties) && schemaAdditionalProperties === false) {
@@ -2903,7 +2937,7 @@ class InstanceObject extends Instance {
2903
2937
  }
2904
2938
  }
2905
2939
  addMissingRequiredPropertiesToValue(value) {
2906
- const enforceRequired = getSchemaXOption(this.schema, "enforceRequired") ?? this.jedison.options.enforceRequired;
2940
+ const enforceRequired = getSchemaXOption(this.schema, "enforceRequired") ?? this.jedison.getOption("enforceRequired");
2907
2941
  if (this.jedison.isEditor && enforceRequired) {
2908
2942
  this.requiredProperties.forEach((propertyName) => {
2909
2943
  if (!hasOwn(value, propertyName)) {
@@ -2952,7 +2986,7 @@ class InstanceObject extends Instance {
2952
2986
  });
2953
2987
  this.children.push(instance);
2954
2988
  this.value[key] = instance.getValue();
2955
- const deactivateNonRequired = getSchemaXOption(this.schema, "deactivateNonRequired") ?? this.jedison.options.deactivateNonRequired;
2989
+ const deactivateNonRequired = getSchemaXOption(this.schema, "deactivateNonRequired") ?? this.jedison.getOption("deactivateNonRequired");
2956
2990
  if (!this.isRequired(key) && isSet(deactivateNonRequired) && deactivateNonRequired === true && !activate) {
2957
2991
  instance.deactivate();
2958
2992
  }
@@ -3086,10 +3120,14 @@ class InstanceObject extends Instance {
3086
3120
  class InstanceArray extends Instance {
3087
3121
  prepare() {
3088
3122
  this.schemaItems = getSchemaItems(this.schema);
3123
+ if (isObject(this.schemaItems) && this.jedison.refParser && this.jedison.refParser.hasRef(this.schemaItems) && !this.schemaItems["x-recursive"]) {
3124
+ this.schemaItems = this.jedison.refParser.expand(this.schemaItems);
3125
+ this.schema.items = this.schemaItems;
3126
+ }
3089
3127
  this.schemaPrefixItems = getSchemaPrefixItems(this.schema);
3090
3128
  const schemaMinItems = getSchemaMinItems(this.schema);
3091
3129
  const schemaEnforceMinItems = getSchemaXOption(this.schema, "enforceMinItems");
3092
- const enforceMinItems = isSet(schemaEnforceMinItems) ? schemaEnforceMinItems : this.jedison.options.enforceMinItems;
3130
+ const enforceMinItems = isSet(schemaEnforceMinItems) ? schemaEnforceMinItems : this.jedison.getOption("enforceMinItems");
3093
3131
  const isEditor = this.jedison.isEditor;
3094
3132
  const hasEnforceMinItems = isSet(enforceMinItems) && enforceMinItems === true;
3095
3133
  const hasMinItems = isSet(schemaMinItems);
@@ -3599,7 +3637,7 @@ class EditorStringTextarea extends EditorString {
3599
3637
  titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
3600
3638
  info: this.getInfo()
3601
3639
  });
3602
- const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.options.useConstraintAttributes;
3640
+ const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.getOption("useConstraintAttributes");
3603
3641
  if (useConstraintAttributes === true) {
3604
3642
  const schemaMinLength = getSchemaMinLength(this.instance.schema);
3605
3643
  const schemaMaxLength = getSchemaMaxLength(this.instance.schema);
@@ -3735,7 +3773,7 @@ class EditorStringInput extends EditorString {
3735
3773
  if (optionFormat === "color" && this.instance.value.length === 0) {
3736
3774
  this.instance.setValue("#000000", false, "user");
3737
3775
  }
3738
- const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.options.useConstraintAttributes;
3776
+ const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.getOption("useConstraintAttributes");
3739
3777
  if (useConstraintAttributes === true) {
3740
3778
  const schemaMinLength = getSchemaMinLength(this.instance.schema);
3741
3779
  const schemaMaxLength = getSchemaMaxLength(this.instance.schema);
@@ -3916,7 +3954,7 @@ class EditorNumberInput extends EditorNumber {
3916
3954
  info: this.getInfo()
3917
3955
  });
3918
3956
  this.control.input.setAttribute("step", "any");
3919
- const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.options.useConstraintAttributes;
3957
+ const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.getOption("useConstraintAttributes");
3920
3958
  if (useConstraintAttributes === true) {
3921
3959
  const schemaMinimum = getSchemaMinimum(this.instance.schema);
3922
3960
  const schemaMaximum = getSchemaMaximum(this.instance.schema);
@@ -4005,13 +4043,13 @@ class EditorObject extends Editor {
4005
4043
  if (isSet(additionalProperties2) && additionalProperties2 === false) {
4006
4044
  addProperty = false;
4007
4045
  }
4008
- const objectAdd = getSchemaXOption(this.instance.schema, "objectAdd") ?? this.instance.jedison.options.objectAdd;
4046
+ const objectAdd = getSchemaXOption(this.instance.schema, "objectAdd") ?? this.instance.jedison.getOption("objectAdd");
4009
4047
  if (isSet(objectAdd) && objectAdd === false) {
4010
4048
  addProperty = false;
4011
4049
  }
4012
4050
  let enablePropertiesToggle = false;
4013
- if (isSet(this.instance.jedison.options.enablePropertiesToggle)) {
4014
- enablePropertiesToggle = this.instance.jedison.options.enablePropertiesToggle;
4051
+ if (isSet(this.instance.jedison.getOption("enablePropertiesToggle"))) {
4052
+ enablePropertiesToggle = this.instance.jedison.getOption("enablePropertiesToggle");
4015
4053
  }
4016
4054
  const schemaEnablePropertiesToggle = getSchemaXOption(this.instance.schema, "enablePropertiesToggle");
4017
4055
  if (isSet(schemaEnablePropertiesToggle)) {
@@ -4024,11 +4062,11 @@ class EditorObject extends Editor {
4024
4062
  id: this.getIdFromPath(this.instance.path),
4025
4063
  enablePropertiesToggle,
4026
4064
  addProperty,
4027
- enableCollapseToggle: getSchemaXOption(this.instance.schema, "enableCollapseToggle") ?? this.instance.jedison.options.enableCollapseToggle,
4028
- startCollapsed: getSchemaXOption(this.instance.schema, "startCollapsed") ?? this.instance.jedison.options.startCollapsed,
4065
+ enableCollapseToggle: getSchemaXOption(this.instance.schema, "enableCollapseToggle") ?? this.instance.jedison.getOption("enableCollapseToggle"),
4066
+ startCollapsed: getSchemaXOption(this.instance.schema, "startCollapsed") ?? this.instance.jedison.getOption("startCollapsed"),
4029
4067
  readOnly: this.instance.isReadOnly(),
4030
4068
  info: this.getInfo(),
4031
- editJsonData: getSchemaXOption(this.instance.schema, "editJsonData") ?? this.instance.jedison.options.editJsonData,
4069
+ editJsonData: getSchemaXOption(this.instance.schema, "editJsonData") ?? this.instance.jedison.getOption("editJsonData"),
4032
4070
  propertiesToggleContent: getSchemaXOption(this.instance.schema, "propertiesToggleContent") ?? this.instance.jedison.translator.translate("propertiesToggle"),
4033
4071
  collapseToggleContent: getSchemaXOption(this.instance.schema, "collapseToggleContent") ?? this.instance.jedison.translator.translate("collapseToggle"),
4034
4072
  addPropertyContent: getSchemaXOption(this.instance.schema, "addPropertyContent") ?? this.instance.jedison.translator.translate("objectAddProperty")
@@ -4083,7 +4121,7 @@ class EditorObject extends Editor {
4083
4121
  return this.theme.getAlert(config);
4084
4122
  }
4085
4123
  refreshPropertiesSlot() {
4086
- const schemaOptionEnablePropertiesToggle = getSchemaXOption(this.instance.schema, "enablePropertiesToggle") ?? this.instance.jedison.options.enablePropertiesToggle;
4124
+ const schemaOptionEnablePropertiesToggle = getSchemaXOption(this.instance.schema, "enablePropertiesToggle") ?? this.instance.jedison.getOption("enablePropertiesToggle");
4087
4125
  if (equal(schemaOptionEnablePropertiesToggle, true)) {
4088
4126
  const declaredProperties = Object.keys(this.instance.properties);
4089
4127
  const instanceProperties = this.instance.children.map((child) => child.getKey());
@@ -4347,7 +4385,16 @@ class EditorObjectCategories extends EditorObject {
4347
4385
  if (!categoriesMap.has(this.activeCategoryName)) {
4348
4386
  this.activeCategoryName = categoriesMap.keys().next().value;
4349
4387
  }
4350
- categoriesMap.forEach((category, categoryName) => {
4388
+ const categoryOrder = getSchemaXOption(this.instance.schema, "categoryOrder");
4389
+ const allNames = Array.from(categoriesMap.keys());
4390
+ let orderedCategoryNames = allNames;
4391
+ if (isSet(categoryOrder) && isArray(categoryOrder)) {
4392
+ const specifiedFirst = categoryOrder.filter((name) => categoriesMap.has(name));
4393
+ const unspecified = allNames.filter((name) => !categoryOrder.includes(name));
4394
+ orderedCategoryNames = [...specifiedFirst, ...unspecified];
4395
+ }
4396
+ orderedCategoryNames.forEach((categoryName) => {
4397
+ const category = categoriesMap.get(categoryName);
4351
4398
  const active = categoryName === this.activeCategoryName;
4352
4399
  const { children, id } = category;
4353
4400
  const hasErrors = navWarning && children.some((child) => child.hasNestedValidationErrors());
@@ -4479,21 +4526,56 @@ class EditorArray extends Editor {
4479
4526
  description: this.getDescription(),
4480
4527
  titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
4481
4528
  id: this.getIdFromPath(this.instance.path),
4482
- enableCollapseToggle: getSchemaXOption(this.instance.schema, "enableCollapseToggle") ?? this.instance.jedison.options.enableCollapseToggle,
4483
- startCollapsed: getSchemaXOption(this.instance.schema, "startCollapsed") ?? this.instance.jedison.options.startCollapsed,
4529
+ enableCollapseToggle: getSchemaXOption(this.instance.schema, "enableCollapseToggle") ?? this.instance.jedison.getOption("enableCollapseToggle"),
4530
+ startCollapsed: getSchemaXOption(this.instance.schema, "startCollapsed") ?? this.instance.jedison.getOption("startCollapsed"),
4484
4531
  readOnly: this.instance.isReadOnly(),
4485
4532
  info: this.getInfo(),
4486
- editJsonData: getSchemaXOption(this.instance.schema, "editJsonData") ?? this.instance.jedison.options.editJsonData,
4487
- arrayAdd: getSchemaXOption(this.instance.schema, "arrayAdd") ?? this.instance.jedison.options.arrayAdd,
4533
+ editJsonData: getSchemaXOption(this.instance.schema, "editJsonData") ?? this.instance.jedison.getOption("editJsonData"),
4534
+ arrayAdd: getSchemaXOption(this.instance.schema, "arrayAdd") ?? this.instance.jedison.getOption("arrayAdd"),
4488
4535
  arrayAddContent: getSchemaXOption(this.instance.schema, "arrayAddContent") ?? this.instance.jedison.translator.translate("arrayAdd"),
4536
+ arrayFooterAdd: getSchemaXOption(this.instance.schema, "arrayFooterAdd") ?? this.instance.jedison.getOption("arrayFooterAdd"),
4537
+ arrayFooterAddContent: getSchemaXOption(this.instance.schema, "arrayFooterAddContent") ?? this.instance.jedison.translator.translate("arrayAdd"),
4538
+ arrayFooterButtonsPosition: getSchemaXOption(this.instance.schema, "arrayFooterButtonsPosition") ?? this.instance.jedison.getOption("arrayFooterButtonsPosition"),
4539
+ arrayDeleteAll: getSchemaXOption(this.instance.schema, "arrayDeleteAll") ?? this.instance.jedison.getOption("arrayDeleteAll"),
4540
+ arrayDeleteAllContent: getSchemaXOption(this.instance.schema, "arrayDeleteAllContent") ?? this.instance.jedison.translator.translate("arrayDeleteAll"),
4541
+ arrayFooterDeleteAll: getSchemaXOption(this.instance.schema, "arrayFooterDeleteAll") ?? this.instance.jedison.getOption("arrayFooterDeleteAll"),
4542
+ arrayFooterDeleteAllContent: getSchemaXOption(this.instance.schema, "arrayFooterDeleteAllContent") ?? this.instance.jedison.translator.translate("arrayDeleteAll"),
4489
4543
  collapseToggleContent: getSchemaXOption(this.instance.schema, "collapseToggleContent") ?? this.instance.jedison.translator.translate("collapseToggle")
4490
4544
  });
4491
4545
  this.control.jsonData.input.value = JSON.stringify(this.instance.getValue(), null, 2);
4492
4546
  }
4547
+ deleteAllItems() {
4548
+ const schemaConfirm = getSchemaXOption(this.instance.schema, "arrayDeleteConfirm");
4549
+ const globalConfirm = this.instance.jedison.getOption("arrayDeleteConfirm");
4550
+ const shouldConfirm = isSet(schemaConfirm) ? schemaConfirm : globalConfirm;
4551
+ const doDeleteAll = () => {
4552
+ this.instance.setValue([], true, "user");
4553
+ };
4554
+ if (shouldConfirm) {
4555
+ if (window.confirm(this.instance.jedison.translator.translate("arrayConfirmDeleteAll"))) {
4556
+ doDeleteAll();
4557
+ }
4558
+ } else {
4559
+ doDeleteAll();
4560
+ }
4561
+ }
4493
4562
  addEventListeners() {
4494
4563
  this.control.addBtn.addEventListener("click", () => {
4495
4564
  this.instance.addItem("user");
4496
4565
  });
4566
+ this.control.footerAddBtn.addEventListener("click", () => {
4567
+ this.instance.addItem("user");
4568
+ });
4569
+ if (this.control.deleteAllBtn) {
4570
+ this.control.deleteAllBtn.addEventListener("click", () => {
4571
+ this.deleteAllItems();
4572
+ });
4573
+ }
4574
+ if (this.control.footerDeleteAllBtn) {
4575
+ this.control.footerDeleteAllBtn.addEventListener("click", () => {
4576
+ this.deleteAllItems();
4577
+ });
4578
+ }
4497
4579
  this.addJsonDataEventListeners();
4498
4580
  }
4499
4581
  addJsonDataEventListeners() {
@@ -4543,7 +4625,7 @@ class EditorArray extends Editor {
4543
4625
  const btnGroup = this.theme.getBtnGroup();
4544
4626
  deleteBtn.addEventListener("click", () => {
4545
4627
  const schemaConfirm = getSchemaXOption(this.instance.schema, "arrayDeleteConfirm");
4546
- const globalConfirm = this.instance.jedison.options.arrayDeleteConfirm;
4628
+ const globalConfirm = this.instance.jedison.getOption("arrayDeleteConfirm");
4547
4629
  const shouldConfirm = isSet(schemaConfirm) ? schemaConfirm : globalConfirm;
4548
4630
  const doDelete = () => {
4549
4631
  this.activeItemIndex = clamp(index2 - 1, 0, this.instance.value.length - 1);
@@ -4597,12 +4679,33 @@ class EditorArray extends Editor {
4597
4679
  });
4598
4680
  }
4599
4681
  }
4682
+ refreshDeleteAllBtn() {
4683
+ if (!this.control.deleteAllBtn && !this.control.footerDeleteAllBtn) return;
4684
+ const isEmpty = this.instance.value.length === 0;
4685
+ const cannotDeleteAll = isEmpty;
4686
+ const btns = [this.control.deleteAllBtn, this.control.footerDeleteAllBtn].filter(Boolean);
4687
+ if (cannotDeleteAll || this.disabled || this.readOnly) {
4688
+ btns.forEach((btn) => {
4689
+ btn.setAttribute("disabled", "");
4690
+ btn.setAttribute("always-disabled", true);
4691
+ });
4692
+ } else {
4693
+ if (!this.disabled && !this.readOnly) {
4694
+ btns.forEach((btn) => {
4695
+ btn.removeAttribute("disabled");
4696
+ btn.removeAttribute("always-disabled");
4697
+ });
4698
+ }
4699
+ }
4700
+ }
4600
4701
  refreshAddBtn() {
4601
4702
  const maxItems2 = getSchemaMaxItems(this.instance.schema);
4602
- const enforceMaxItems = getSchemaXOption(this.instance.schema, "enforceMaxItems") ?? this.instance.jedison.options.enforceMaxItems;
4703
+ const enforceMaxItems = getSchemaXOption(this.instance.schema, "enforceMaxItems") ?? this.instance.jedison.getOption("enforceMaxItems");
4603
4704
  if (isSet(maxItems2) && enforceMaxItems && maxItems2 <= this.instance.value.length) {
4604
4705
  this.control.addBtn.setAttribute("disabled", "");
4605
4706
  this.control.addBtn.setAttribute("always-disabled", true);
4707
+ this.control.footerAddBtn.setAttribute("disabled", "");
4708
+ this.control.footerAddBtn.setAttribute("always-disabled", true);
4606
4709
  this.control.childrenSlot.querySelectorAll(".jedi-array-add-after").forEach((btn) => {
4607
4710
  btn.setAttribute("disabled", "");
4608
4711
  btn.setAttribute("always-disabled", true);
@@ -4611,6 +4714,8 @@ class EditorArray extends Editor {
4611
4714
  if (!this.disabled && !this.readOnly) {
4612
4715
  this.control.addBtn.removeAttribute("disabled");
4613
4716
  this.control.addBtn.removeAttribute("always-disabled");
4717
+ this.control.footerAddBtn.removeAttribute("disabled");
4718
+ this.control.footerAddBtn.removeAttribute("always-disabled");
4614
4719
  this.control.childrenSlot.querySelectorAll(".jedi-array-add-after").forEach((btn) => {
4615
4720
  btn.removeAttribute("disabled");
4616
4721
  btn.removeAttribute("always-disabled");
@@ -4621,9 +4726,9 @@ class EditorArray extends Editor {
4621
4726
  refreshUI() {
4622
4727
  super.refreshUI();
4623
4728
  const minItems2 = getSchemaMinItems(this.instance.schema);
4624
- const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
4625
- const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
4626
- const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.options.arrayAddAfter;
4729
+ const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.getOption("arrayDelete");
4730
+ const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.getOption("arrayMove");
4731
+ const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.getOption("arrayAddAfter");
4627
4732
  this.control.childrenSlot.innerHTML = "";
4628
4733
  this.instance.children.forEach((child, index2) => {
4629
4734
  const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup, addAfterBtn } = this.getButtons(index2);
@@ -4662,6 +4767,7 @@ class EditorArray extends Editor {
4662
4767
  child.ui.refreshUI();
4663
4768
  });
4664
4769
  this.refreshAddBtn();
4770
+ this.refreshDeleteAllBtn();
4665
4771
  this.refreshJsonData();
4666
4772
  this.refreshLegendWarning();
4667
4773
  }
@@ -4734,6 +4840,20 @@ class EditorArrayTable extends EditorArray {
4734
4840
  this.activeItemIndex = this.instance.value.length;
4735
4841
  this.instance.addItem("user");
4736
4842
  });
4843
+ this.control.footerAddBtn.addEventListener("click", () => {
4844
+ this.activeItemIndex = this.instance.value.length;
4845
+ this.instance.addItem("user");
4846
+ });
4847
+ if (this.control.deleteAllBtn) {
4848
+ this.control.deleteAllBtn.addEventListener("click", () => {
4849
+ this.deleteAllItems();
4850
+ });
4851
+ }
4852
+ if (this.control.footerDeleteAllBtn) {
4853
+ this.control.footerDeleteAllBtn.addEventListener("click", () => {
4854
+ this.deleteAllItems();
4855
+ });
4856
+ }
4737
4857
  this.addJsonDataEventListeners();
4738
4858
  }
4739
4859
  isSortable() {
@@ -4743,10 +4863,10 @@ class EditorArrayTable extends EditorArray {
4743
4863
  this.control.childrenSlot.innerHTML = "";
4744
4864
  const table = this.theme.getTable();
4745
4865
  this.control.childrenSlot.appendChild(table.container);
4746
- const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
4747
- const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
4748
- const arrayButtonsPosition = getSchemaXOption(this.instance.schema, "arrayButtonsPosition") ?? this.instance.jedison.options.arrayButtonsPosition;
4749
- const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.options.arrayAddAfter;
4866
+ const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.getOption("arrayDelete");
4867
+ const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.getOption("arrayMove");
4868
+ const arrayButtonsPosition = getSchemaXOption(this.instance.schema, "arrayButtonsPosition") ?? this.instance.jedison.getOption("arrayButtonsPosition");
4869
+ const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.getOption("arrayAddAfter");
4750
4870
  const th = this.theme.getTableHeader();
4751
4871
  const { label } = this.theme.getFakeLabel({
4752
4872
  content: "Controls",
@@ -4813,6 +4933,7 @@ class EditorArrayTable extends EditorArray {
4813
4933
  });
4814
4934
  this.refreshSortable(table.tbody);
4815
4935
  this.refreshAddBtn();
4936
+ this.refreshDeleteAllBtn();
4816
4937
  this.refreshJsonData();
4817
4938
  this.refreshDisabledState();
4818
4939
  this.refreshScrollPosition(table.container);
@@ -4863,6 +4984,20 @@ class EditorArrayTableObject extends EditorArray {
4863
4984
  this.activeItemIndex = this.instance.value.length;
4864
4985
  this.instance.addItem("user");
4865
4986
  });
4987
+ this.control.footerAddBtn.addEventListener("click", () => {
4988
+ this.activeItemIndex = this.instance.value.length;
4989
+ this.instance.addItem("user");
4990
+ });
4991
+ if (this.control.deleteAllBtn) {
4992
+ this.control.deleteAllBtn.addEventListener("click", () => {
4993
+ this.deleteAllItems();
4994
+ });
4995
+ }
4996
+ if (this.control.footerDeleteAllBtn) {
4997
+ this.control.footerDeleteAllBtn.addEventListener("click", () => {
4998
+ this.deleteAllItems();
4999
+ });
5000
+ }
4866
5001
  this.addJsonDataEventListeners();
4867
5002
  }
4868
5003
  isSortable() {
@@ -4872,10 +5007,10 @@ class EditorArrayTableObject extends EditorArray {
4872
5007
  this.control.childrenSlot.innerHTML = "";
4873
5008
  const table = this.theme.getTable();
4874
5009
  this.control.childrenSlot.appendChild(table.container);
4875
- const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
4876
- const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
4877
- const arrayButtonsPosition = getSchemaXOption(this.instance.schema, "arrayButtonsPosition") ?? this.instance.jedison.options.arrayButtonsPosition;
4878
- const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.options.arrayAddAfter;
5010
+ const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.getOption("arrayDelete");
5011
+ const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.getOption("arrayMove");
5012
+ const arrayButtonsPosition = getSchemaXOption(this.instance.schema, "arrayButtonsPosition") ?? this.instance.jedison.getOption("arrayButtonsPosition");
5013
+ const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.getOption("arrayAddAfter");
4879
5014
  const th = this.theme.getTableHeader();
4880
5015
  const { label } = this.theme.getFakeLabel({
4881
5016
  content: "Controls",
@@ -4957,6 +5092,7 @@ class EditorArrayTableObject extends EditorArray {
4957
5092
  });
4958
5093
  this.refreshSortable(table.tbody);
4959
5094
  this.refreshAddBtn();
5095
+ this.refreshDeleteAllBtn();
4960
5096
  this.refreshJsonData();
4961
5097
  this.refreshDisabledState();
4962
5098
  this.refreshScrollPosition(table.container);
@@ -5128,6 +5264,22 @@ class EditorArrayNav extends EditorArray {
5128
5264
  this.activeItemIndex = this.instance.value.length;
5129
5265
  this.instance.addItem("user");
5130
5266
  });
5267
+ this.control.footerAddBtn.addEventListener("click", () => {
5268
+ this.activeItemIndex = this.instance.value.length;
5269
+ this.instance.addItem("user");
5270
+ });
5271
+ if (this.control.deleteAllBtn) {
5272
+ this.control.deleteAllBtn.addEventListener("click", () => {
5273
+ this.activeItemIndex = 0;
5274
+ this.deleteAllItems();
5275
+ });
5276
+ }
5277
+ if (this.control.footerDeleteAllBtn) {
5278
+ this.control.footerDeleteAllBtn.addEventListener("click", () => {
5279
+ this.activeItemIndex = 0;
5280
+ this.deleteAllItems();
5281
+ });
5282
+ }
5131
5283
  this.addJsonDataEventListeners();
5132
5284
  }
5133
5285
  refreshUI() {
@@ -5145,9 +5297,9 @@ class EditorArrayNav extends EditorArray {
5145
5297
  const tabList = this.theme.getTabList({
5146
5298
  variant
5147
5299
  });
5148
- const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
5149
- const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
5150
- const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.options.arrayAddAfter;
5300
+ const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.getOption("arrayDelete");
5301
+ const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.getOption("arrayMove");
5302
+ const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.getOption("arrayAddAfter");
5151
5303
  this.control.childrenSlot.appendChild(row);
5152
5304
  row.appendChild(tabListCol);
5153
5305
  row.appendChild(tabContentCol);
@@ -5213,6 +5365,7 @@ class EditorArrayNav extends EditorArray {
5213
5365
  });
5214
5366
  this.refreshDisabledState();
5215
5367
  this.refreshAddBtn();
5368
+ this.refreshDeleteAllBtn();
5216
5369
  this.refreshJsonData();
5217
5370
  }
5218
5371
  }
@@ -5224,8 +5377,8 @@ class EditorMultiple extends Editor {
5224
5377
  return isSet(schemaAnyOf) || isSet(schemaOneOf) || schemaType === "any" || isArray(schemaType) || notSet(schemaType);
5225
5378
  }
5226
5379
  build() {
5227
- this.switcherInput = getSchemaXOption(this.instance.schema, "switcherInput") ?? this.instance.jedison.options.switcherInput;
5228
- this.embedSwitcher = getSchemaXOption(this.instance.schema, "embedSwitcher") ?? this.instance.jedison.options.embedSwitcher;
5380
+ this.switcherInput = getSchemaXOption(this.instance.schema, "switcherInput") ?? this.instance.jedison.getOption("switcherInput");
5381
+ this.embedSwitcher = getSchemaXOption(this.instance.schema, "embedSwitcher") ?? this.instance.jedison.getOption("embedSwitcher");
5229
5382
  this.control = this.theme.getMultipleControl({
5230
5383
  titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
5231
5384
  id: this.getIdFromPath(this.instance.path),
@@ -5532,7 +5685,7 @@ class EditorStringIMask extends EditorString {
5532
5685
  try {
5533
5686
  const schemaImask = getSchemaXOption(this.instance.schema, "imask") ?? {};
5534
5687
  const schemaImaskSettings = schemaImask["x-settings"];
5535
- const settings = schemaImaskSettings && this.instance.jedison.options.settings[schemaImaskSettings] ? this.instance.jedison.options.settings[schemaImaskSettings] : {};
5688
+ const settings = schemaImaskSettings && this.instance.jedison.getOption("settings")[schemaImaskSettings] ? this.instance.jedison.getOption("settings")[schemaImaskSettings] : {};
5536
5689
  const imaskOptions = { ...schemaImask, ...settings };
5537
5690
  this.imask = window.IMask(this.control.input, imaskOptions);
5538
5691
  this.useMaskedValue = schemaImask["x-masked"] ?? false;
@@ -5575,7 +5728,7 @@ class EditorNumberIMask extends EditorNumber {
5575
5728
  try {
5576
5729
  const schemaImask = getSchemaXOption(this.instance.schema, "imask") ?? {};
5577
5730
  const schemaImaskSettings = schemaImask["x-settings"];
5578
- const settings = schemaImaskSettings && this.instance.jedison.options.settings[schemaImaskSettings] ? this.instance.jedison.options.settings[schemaImaskSettings] : {};
5731
+ const settings = schemaImaskSettings && this.instance.jedison.getOption("settings")[schemaImaskSettings] ? this.instance.jedison.getOption("settings")[schemaImaskSettings] : {};
5579
5732
  const imaskOptions = {
5580
5733
  mask: Number,
5581
5734
  ...schemaImask,
@@ -5853,7 +6006,7 @@ class EditorNumberRange extends EditorNumber {
5853
6006
  titleHidden: getSchemaXOption(this.instance.schema, "titleHidden"),
5854
6007
  info: this.getInfo()
5855
6008
  });
5856
- const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.options.useConstraintAttributes;
6009
+ const useConstraintAttributes = getSchemaXOption(this.instance.schema, "useConstraintAttributes") ?? this.instance.jedison.getOption("useConstraintAttributes");
5857
6010
  if (useConstraintAttributes === true) {
5858
6011
  this.control.input.setAttribute("min", optionMin);
5859
6012
  this.control.input.setAttribute("max", optionMax);
@@ -6073,6 +6226,8 @@ const defaultTranslations = {
6073
6226
  arrayAdd: "Add item",
6074
6227
  arrayAddAfter: "Add after",
6075
6228
  arrayConfirmDelete: "Are you sure you want to delete this item?",
6229
+ arrayDeleteAll: "Delete all items",
6230
+ arrayConfirmDeleteAll: "Are you sure you want to delete all items?",
6076
6231
  objectAddProperty: "Add property",
6077
6232
  objectPropertyAdded: "field was added to the form",
6078
6233
  objectPropertyRemoved: "field was removed from the form",
@@ -6118,6 +6273,8 @@ const translations = {
6118
6273
  arrayDrag: "Drag",
6119
6274
  arrayAdd: "Add item",
6120
6275
  arrayConfirmDelete: "Are you sure you want to delete this item?",
6276
+ arrayDeleteAll: "Delete all items",
6277
+ arrayConfirmDeleteAll: "Are you sure you want to delete all items?",
6121
6278
  objectAddProperty: "Add property",
6122
6279
  objectPropertyAdded: "field was added to the form",
6123
6280
  objectPropertyRemoved: "field was removed from the form",
@@ -6162,6 +6319,8 @@ const translations = {
6162
6319
  arrayDrag: "Ziehen",
6163
6320
  arrayAdd: "Element hinzufügen",
6164
6321
  arrayConfirmDelete: "Möchten Sie dieses Element wirklich löschen?",
6322
+ arrayDeleteAll: "Alle Elemente löschen",
6323
+ arrayConfirmDeleteAll: "Möchten Sie wirklich alle Elemente löschen?",
6165
6324
  objectAddProperty: "Eigenschaft hinzufügen",
6166
6325
  objectPropertyAdded: "Feld wurde dem Formular hinzugefügt",
6167
6326
  objectPropertyRemoved: "Feld wurde aus dem Formular entfernt",
@@ -6206,6 +6365,8 @@ const translations = {
6206
6365
  arrayDrag: "Trascina",
6207
6366
  arrayAdd: "Aggiungi elemento",
6208
6367
  arrayConfirmDelete: "Sei sicuro di voler eliminare questo elemento?",
6368
+ arrayDeleteAll: "Elimina tutti gli elementi",
6369
+ arrayConfirmDeleteAll: "Sei sicuro di voler eliminare tutti gli elementi?",
6209
6370
  objectAddProperty: "Aggiungi proprietà",
6210
6371
  objectPropertyAdded: "Campo aggiunto al modulo",
6211
6372
  objectPropertyRemoved: "Campo rimosso dal modulo",
@@ -6250,6 +6411,8 @@ const translations = {
6250
6411
  arrayDrag: "Arrastrar",
6251
6412
  arrayAdd: "Agregar elemento",
6252
6413
  arrayConfirmDelete: "¿Estás seguro de que deseas eliminar este elemento?",
6414
+ arrayDeleteAll: "Eliminar todos los elementos",
6415
+ arrayConfirmDeleteAll: "¿Está seguro de que desea eliminar todos los elementos?",
6253
6416
  objectAddProperty: "Agregar propiedad",
6254
6417
  objectPropertyAdded: "campo fue añadido al formulario",
6255
6418
  objectPropertyRemoved: "campo fue eliminado del formulario",
@@ -6328,6 +6491,10 @@ class Jedison extends EventEmitter {
6328
6491
  arrayMove: true,
6329
6492
  arrayAdd: true,
6330
6493
  arrayAddAfter: false,
6494
+ arrayFooterAdd: false,
6495
+ arrayFooterButtonsPosition: "right",
6496
+ arrayDeleteAll: false,
6497
+ arrayFooterDeleteAll: false,
6331
6498
  objectAdd: true,
6332
6499
  arrayButtonsPosition: "left",
6333
6500
  startCollapsed: false,
@@ -6354,8 +6521,6 @@ class Jedison extends EventEmitter {
6354
6521
  mergeAllOf: false,
6355
6522
  enforceConst: false,
6356
6523
  enforceRequired: true,
6357
- enforceEnumDefault: true,
6358
- // todo: deprecated
6359
6524
  enforceAdditionalProperties: true,
6360
6525
  enforceMinItems: true,
6361
6526
  enforceMaxItems: true,
@@ -6573,9 +6738,6 @@ class Jedison extends EventEmitter {
6573
6738
  node.oneOf[index2] = this.refParser.expand(subschema);
6574
6739
  });
6575
6740
  }
6576
- if (isObject(node.items) && this.refParser.hasRef(node.items)) {
6577
- node.items = this.refParser.expand(node.items);
6578
- }
6579
6741
  });
6580
6742
  }
6581
6743
  if (this.isEditor) {
@@ -6604,10 +6766,11 @@ class Jedison extends EventEmitter {
6604
6766
  if (sequentialIfThenElse === null) {
6605
6767
  sequentialIfThenElse = conditionals[i];
6606
6768
  } else {
6769
+ const inner = sequentialIfThenElse;
6607
6770
  sequentialIfThenElse = {
6608
6771
  if: conditionals[i].if,
6609
- then: conditionals[i].then,
6610
- else: sequentialIfThenElse
6772
+ then: combineDeep({}, conditionals[i].then || {}, inner),
6773
+ else: combineDeep({}, conditionals[i].else || {}, inner)
6611
6774
  };
6612
6775
  }
6613
6776
  }
@@ -6696,6 +6859,18 @@ class Jedison extends EventEmitter {
6696
6859
  getInstance(path) {
6697
6860
  return this.instances.get(path);
6698
6861
  }
6862
+ /**
6863
+ * Returns the value of a jedison option
6864
+ * @param {string} option
6865
+ * @return {*}
6866
+ */
6867
+ getOption(option) {
6868
+ const canonical = resolveAlias(option);
6869
+ if (canonical !== option) {
6870
+ console.warn(`Jedison: option "${option}" is deprecated. Use "${canonical}" instead.`);
6871
+ }
6872
+ return this.options[canonical];
6873
+ }
6699
6874
  /**
6700
6875
  * Navigates to a specific instance by path, activating any ancestor nav/categories tabs as needed.
6701
6876
  * @param {string} path - The instance path (e.g. '#/address/street')
@@ -7150,6 +7325,16 @@ class Theme {
7150
7325
  html.classList.add("jedi-editor-card-body");
7151
7326
  return html;
7152
7327
  }
7328
+ /**
7329
+ * A footer for array cards
7330
+ */
7331
+ getArrayFooter() {
7332
+ const html = document.createElement("div");
7333
+ html.classList.add("jedi-array-footer");
7334
+ html.style.display = "flex";
7335
+ html.style.alignItems = "center";
7336
+ return html;
7337
+ }
7153
7338
  /**
7154
7339
  * Wrapper for editor actions buttons
7155
7340
  */
@@ -7445,6 +7630,17 @@ class Theme {
7445
7630
  html.classList.add("jedi-array-add");
7446
7631
  return html;
7447
7632
  }
7633
+ /**
7634
+ * Array "delete all" button
7635
+ */
7636
+ getArrayBtnDeleteAll(config) {
7637
+ const html = this.getButton({
7638
+ content: config.content,
7639
+ icon: "delete"
7640
+ });
7641
+ html.classList.add("jedi-array-delete-all");
7642
+ return html;
7643
+ }
7448
7644
  /**
7449
7645
  * Array "add after" item button
7450
7646
  */
@@ -7766,6 +7962,13 @@ class Theme {
7766
7962
  const addBtn = this.getArrayBtnAdd({
7767
7963
  content: config.arrayAddContent
7768
7964
  });
7965
+ const footerAddBtn = this.getArrayBtnAdd({
7966
+ content: config.arrayFooterAddContent
7967
+ });
7968
+ const deleteAllBtn = config.arrayDeleteAll === true ? this.getArrayBtnDeleteAll({ content: config.arrayDeleteAllContent }) : null;
7969
+ const footerDeleteAllBtn = config.arrayFooterDeleteAll === true ? this.getArrayBtnDeleteAll({ content: config.arrayFooterDeleteAllContent }) : null;
7970
+ const footerBtnGroup = this.getBtnGroup();
7971
+ const footer = this.getArrayFooter();
7769
7972
  const fieldset = this.getFieldset();
7770
7973
  const info = this.getInfo(config.info);
7771
7974
  const { legend, legendText, infoContainer, right } = this.getLegend({
@@ -7818,6 +8021,9 @@ class Theme {
7818
8021
  if (config.editJsonData) {
7819
8022
  btnGroup.appendChild(jsonData.toggle);
7820
8023
  }
8024
+ if (deleteAllBtn) {
8025
+ btnGroup.appendChild(deleteAllBtn);
8026
+ }
7821
8027
  if (isSet(config.arrayAdd) && config.arrayAdd === true) {
7822
8028
  btnGroup.appendChild(addBtn);
7823
8029
  }
@@ -7825,6 +8031,20 @@ class Theme {
7825
8031
  if (config.enableCollapseToggle) {
7826
8032
  actions.appendChild(collapseToggle);
7827
8033
  }
8034
+ const showFooter = (config.arrayFooterAdd === true || config.arrayFooterDeleteAll === true) && config.readOnly === false;
8035
+ if (showFooter) {
8036
+ if (footerDeleteAllBtn) {
8037
+ footerBtnGroup.appendChild(footerDeleteAllBtn);
8038
+ }
8039
+ if (config.arrayFooterAdd === true) {
8040
+ footerBtnGroup.appendChild(footerAddBtn);
8041
+ }
8042
+ if (config.arrayFooterButtonsPosition === "right") {
8043
+ footerBtnGroup.style.marginLeft = "auto";
8044
+ }
8045
+ footer.appendChild(footerBtnGroup);
8046
+ collapse.appendChild(footer);
8047
+ }
7828
8048
  return {
7829
8049
  container,
7830
8050
  collapseToggle,
@@ -7838,7 +8058,10 @@ class Theme {
7838
8058
  jsonData,
7839
8059
  legend,
7840
8060
  legendText,
7841
- switcherSlot
8061
+ switcherSlot,
8062
+ footerAddBtn,
8063
+ deleteAllBtn,
8064
+ footerDeleteAllBtn
7842
8065
  };
7843
8066
  }
7844
8067
  getArrayItem(config = {}) {
@@ -8629,6 +8852,11 @@ class ThemeBootstrap3 extends Theme {
8629
8852
  html.style.paddingBottom = "0";
8630
8853
  return html;
8631
8854
  }
8855
+ getArrayFooter() {
8856
+ const footer = super.getArrayFooter();
8857
+ footer.classList.add("panel-footer");
8858
+ return footer;
8859
+ }
8632
8860
  getBtnGroup() {
8633
8861
  const html = super.getBtnGroup();
8634
8862
  html.classList.add("btn-group");
@@ -8983,6 +9211,11 @@ class ThemeBootstrap4 extends Theme {
8983
9211
  html.classList.add("pb-0");
8984
9212
  return html;
8985
9213
  }
9214
+ getArrayFooter() {
9215
+ const footer = super.getArrayFooter();
9216
+ footer.classList.add("card-footer");
9217
+ return footer;
9218
+ }
8986
9219
  getBtnGroup() {
8987
9220
  const html = super.getBtnGroup();
8988
9221
  html.classList.add("btn-group");
@@ -9364,6 +9597,11 @@ class ThemeBootstrap5 extends Theme {
9364
9597
  html.classList.add("pb-0");
9365
9598
  return html;
9366
9599
  }
9600
+ getArrayFooter() {
9601
+ const footer = super.getArrayFooter();
9602
+ footer.classList.add("card-footer");
9603
+ return footer;
9604
+ }
9367
9605
  getControlSlot() {
9368
9606
  const controlSlot = super.getControlSlot();
9369
9607
  controlSlot.classList.add("mb-3");