@json-render/devtools 0.19.0 → 0.20.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/dist/index.js +21 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1814,21 +1814,22 @@ function mountSpecTab(root, ctx) {
|
|
|
1814
1814
|
return;
|
|
1815
1815
|
}
|
|
1816
1816
|
const el2 = spec.elements[current];
|
|
1817
|
-
const
|
|
1817
|
+
const childKeys = getChildKeys(el2);
|
|
1818
|
+
const hasChildren = childKeys.length > 0;
|
|
1818
1819
|
if (!hasChildren) return;
|
|
1819
1820
|
if (!expanded.has(current)) {
|
|
1820
1821
|
expanded.add(current);
|
|
1821
1822
|
render();
|
|
1822
1823
|
scrollSelectedIntoView();
|
|
1823
1824
|
} else {
|
|
1824
|
-
moveSelection(
|
|
1825
|
+
moveSelection(childKeys[0]);
|
|
1825
1826
|
}
|
|
1826
1827
|
return;
|
|
1827
1828
|
}
|
|
1828
1829
|
if (key === "ArrowLeft") {
|
|
1829
1830
|
if (!current) return;
|
|
1830
1831
|
const el2 = spec.elements[current];
|
|
1831
|
-
const hasChildren =
|
|
1832
|
+
const hasChildren = getChildKeys(el2).length > 0;
|
|
1832
1833
|
if (hasChildren && expanded.has(current)) {
|
|
1833
1834
|
expanded.delete(current);
|
|
1834
1835
|
render();
|
|
@@ -1844,7 +1845,7 @@ function mountSpecTab(root, ctx) {
|
|
|
1844
1845
|
return;
|
|
1845
1846
|
}
|
|
1846
1847
|
const el = spec.elements[current];
|
|
1847
|
-
if (el
|
|
1848
|
+
if (getChildKeys(el).length > 0) {
|
|
1848
1849
|
toggleExpanded(current);
|
|
1849
1850
|
scrollSelectedIntoView();
|
|
1850
1851
|
}
|
|
@@ -2030,19 +2031,27 @@ function collectVisibleKeys(spec, expanded) {
|
|
|
2030
2031
|
function walk(key) {
|
|
2031
2032
|
list.push(key);
|
|
2032
2033
|
const el = spec.elements[key];
|
|
2033
|
-
|
|
2034
|
+
const childKeys = getChildKeys(el);
|
|
2035
|
+
if (childKeys.length === 0) return;
|
|
2034
2036
|
if (!expanded.has(key)) return;
|
|
2035
|
-
for (const child of
|
|
2037
|
+
for (const child of childKeys) walk(child);
|
|
2036
2038
|
}
|
|
2037
2039
|
walk(spec.root);
|
|
2038
2040
|
return list;
|
|
2039
2041
|
}
|
|
2040
2042
|
function findParent(spec, key) {
|
|
2041
2043
|
for (const [parentKey, el] of Object.entries(spec.elements)) {
|
|
2042
|
-
if (el.
|
|
2044
|
+
if (getChildKeys(el).includes(key)) return parentKey;
|
|
2043
2045
|
}
|
|
2044
2046
|
return null;
|
|
2045
2047
|
}
|
|
2048
|
+
function getChildKeys(element) {
|
|
2049
|
+
if (!element) return [];
|
|
2050
|
+
return [
|
|
2051
|
+
...element.children ?? [],
|
|
2052
|
+
...Object.values(element.slots ?? {}).flat()
|
|
2053
|
+
];
|
|
2054
|
+
}
|
|
2046
2055
|
function collectIssues(spec) {
|
|
2047
2056
|
const result = (0, import_core.validateSpec)(spec, { checkOrphans: true });
|
|
2048
2057
|
const byKey = /* @__PURE__ */ new Map();
|
|
@@ -2062,8 +2071,7 @@ function findPath(spec, key) {
|
|
|
2062
2071
|
return true;
|
|
2063
2072
|
}
|
|
2064
2073
|
const el = spec.elements[current];
|
|
2065
|
-
|
|
2066
|
-
for (const child of el.children) {
|
|
2074
|
+
for (const child of getChildKeys(el)) {
|
|
2067
2075
|
if (walk(child)) {
|
|
2068
2076
|
path.push(current);
|
|
2069
2077
|
return true;
|
|
@@ -2088,7 +2096,8 @@ function renderNode(spec, key, depth, expanded, selected, issues, ctx, onToggle,
|
|
|
2088
2096
|
h("span", { className: "jr-tree-key" }, key)
|
|
2089
2097
|
);
|
|
2090
2098
|
}
|
|
2091
|
-
const
|
|
2099
|
+
const childKeys = getChildKeys(el);
|
|
2100
|
+
const hasChildren = childKeys.length > 0;
|
|
2092
2101
|
const isExpanded = hasChildren && expanded.has(key);
|
|
2093
2102
|
const isSelected = selected === key;
|
|
2094
2103
|
const elementIssues = issues.byKey.get(key) ?? [];
|
|
@@ -2144,7 +2153,7 @@ function renderNode(spec, key, depth, expanded, selected, issues, ctx, onToggle,
|
|
|
2144
2153
|
);
|
|
2145
2154
|
const container = h("div", null, row);
|
|
2146
2155
|
if (isExpanded && hasChildren) {
|
|
2147
|
-
for (const childKey of
|
|
2156
|
+
for (const childKey of childKeys) {
|
|
2148
2157
|
const childNode = renderNode(
|
|
2149
2158
|
spec,
|
|
2150
2159
|
childKey,
|
|
@@ -2190,7 +2199,7 @@ function renderDetail(container, spec, key, issues) {
|
|
|
2190
2199
|
return;
|
|
2191
2200
|
}
|
|
2192
2201
|
const elIssues = issues.byKey.get(key) ?? [];
|
|
2193
|
-
const children = el.
|
|
2202
|
+
const children = getChildKeys(el).length;
|
|
2194
2203
|
replaceChildren(
|
|
2195
2204
|
container,
|
|
2196
2205
|
h(
|