jedison 0.2.1 → 0.2.2
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 +4 -0
- package/README.md +65 -1885
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +56 -5
- 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
|
@@ -439,6 +439,33 @@ const Schema = {
|
|
|
439
439
|
getSchemaUnevaluatedProperties,
|
|
440
440
|
getSchemaUniqueItems
|
|
441
441
|
};
|
|
442
|
+
class SchemaGenerator {
|
|
443
|
+
static inferType(value) {
|
|
444
|
+
if (Array.isArray(value)) return "array";
|
|
445
|
+
if (value === null) return "null";
|
|
446
|
+
return typeof value;
|
|
447
|
+
}
|
|
448
|
+
static generate(obj) {
|
|
449
|
+
if (typeof obj !== "object" || obj === null) {
|
|
450
|
+
return { type: this.inferType(obj) };
|
|
451
|
+
}
|
|
452
|
+
if (Array.isArray(obj)) {
|
|
453
|
+
const itemSchemas = obj.map((item) => this.generate(item));
|
|
454
|
+
return {
|
|
455
|
+
type: "array",
|
|
456
|
+
items: itemSchemas.length ? itemSchemas[0] : {}
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
const properties2 = {};
|
|
460
|
+
for (const key in obj) {
|
|
461
|
+
properties2[key] = this.generate(obj[key]);
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
type: "object",
|
|
465
|
+
properties: properties2
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
}
|
|
442
469
|
function allOf(context) {
|
|
443
470
|
let errors = [];
|
|
444
471
|
const allOf2 = getSchemaAllOf(context.schema);
|
|
@@ -3958,13 +3985,13 @@ class EditorArrayNav extends EditorArray {
|
|
|
3958
3985
|
}
|
|
3959
3986
|
const active = index2 === this.activeItemIndex;
|
|
3960
3987
|
const id = pathToAttribute(child.path);
|
|
3961
|
-
const { list } = this.theme.getTab({
|
|
3988
|
+
const { list, arrayActions } = this.theme.getTab({
|
|
3962
3989
|
hasErrors: child.children.some((grandChild) => grandChild.ui.showingValidationErrors),
|
|
3963
3990
|
title: (titleTemplate == null ? void 0 : titleTemplate.length) ? titleTemplate : childTitle,
|
|
3964
3991
|
id,
|
|
3965
3992
|
active
|
|
3966
3993
|
});
|
|
3967
|
-
|
|
3994
|
+
arrayActions.appendChild(btnGroup);
|
|
3968
3995
|
list.addEventListener("click", () => {
|
|
3969
3996
|
this.activeItemIndex = index2;
|
|
3970
3997
|
});
|
|
@@ -5051,6 +5078,19 @@ class Jedison extends EventEmitter {
|
|
|
5051
5078
|
return filters.includes(error.type.toLowerCase());
|
|
5052
5079
|
});
|
|
5053
5080
|
}
|
|
5081
|
+
export() {
|
|
5082
|
+
const results = [];
|
|
5083
|
+
Object.keys(this.instances).forEach((key) => {
|
|
5084
|
+
const instance = this.instances[key];
|
|
5085
|
+
results.push({
|
|
5086
|
+
path: instance.path ?? "-",
|
|
5087
|
+
type: instance.schema.type ?? "-",
|
|
5088
|
+
title: instance.ui.getTitle() ?? "-",
|
|
5089
|
+
value: instance.getValue() ?? "-"
|
|
5090
|
+
});
|
|
5091
|
+
});
|
|
5092
|
+
return results;
|
|
5093
|
+
}
|
|
5054
5094
|
/**
|
|
5055
5095
|
* Displays validation errors in the respective editors.
|
|
5056
5096
|
* If an errors list is passed, it will display these errors;
|
|
@@ -6573,11 +6613,16 @@ class Theme {
|
|
|
6573
6613
|
getTab(config) {
|
|
6574
6614
|
const list = document.createElement("li");
|
|
6575
6615
|
const link = document.createElement("a");
|
|
6616
|
+
const arrayActions = document.createElement("span");
|
|
6617
|
+
const text = document.createElement("span");
|
|
6576
6618
|
link.classList.add("jedi-nav-link");
|
|
6577
6619
|
link.setAttribute("href", "#" + config.id);
|
|
6578
|
-
|
|
6620
|
+
text.classList.add("jedi-nav-text");
|
|
6621
|
+
text.textContent = config.hasErrors ? "⚠ " + config.title : config.title;
|
|
6622
|
+
link.appendChild(arrayActions);
|
|
6623
|
+
link.appendChild(text);
|
|
6579
6624
|
list.appendChild(link);
|
|
6580
|
-
return { list, link };
|
|
6625
|
+
return { list, link, arrayActions, text };
|
|
6581
6626
|
}
|
|
6582
6627
|
/**
|
|
6583
6628
|
* Wrapper for tabs
|
|
@@ -6899,6 +6944,7 @@ class ThemeBootstrap3 extends Theme {
|
|
|
6899
6944
|
}
|
|
6900
6945
|
getTab(config) {
|
|
6901
6946
|
const tab = super.getTab(config);
|
|
6947
|
+
tab.text.style.marginLeft = "15px";
|
|
6902
6948
|
if (config.active) {
|
|
6903
6949
|
tab.list.classList.add("active");
|
|
6904
6950
|
}
|
|
@@ -7232,6 +7278,8 @@ class ThemeBootstrap4 extends Theme {
|
|
|
7232
7278
|
getTab(config) {
|
|
7233
7279
|
const tab = super.getTab(config);
|
|
7234
7280
|
tab.list.classList.add("nav-item");
|
|
7281
|
+
tab.list.classList.add("mb-3");
|
|
7282
|
+
tab.text.classList.add("ml-3");
|
|
7235
7283
|
tab.link.classList.add("nav-link");
|
|
7236
7284
|
tab.link.setAttribute("data-toggle", "tab");
|
|
7237
7285
|
if (config.active) {
|
|
@@ -7562,6 +7610,8 @@ class ThemeBootstrap5 extends Theme {
|
|
|
7562
7610
|
getTab(config) {
|
|
7563
7611
|
const tab = super.getTab(config);
|
|
7564
7612
|
tab.list.classList.add("nav-item");
|
|
7613
|
+
tab.list.classList.add("mb-3");
|
|
7614
|
+
tab.text.classList.add("ms-3");
|
|
7565
7615
|
tab.link.classList.add("nav-link");
|
|
7566
7616
|
tab.link.setAttribute("data-bs-toggle", "tab");
|
|
7567
7617
|
if (config.active) {
|
|
@@ -7674,7 +7724,8 @@ const index = {
|
|
|
7674
7724
|
ThemeBootstrap4,
|
|
7675
7725
|
ThemeBootstrap5,
|
|
7676
7726
|
RefParser,
|
|
7677
|
-
Create: Jedison
|
|
7727
|
+
Create: Jedison,
|
|
7728
|
+
SchemaGenerator
|
|
7678
7729
|
};
|
|
7679
7730
|
export {
|
|
7680
7731
|
index as default
|