@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.mjs
CHANGED
|
@@ -1761,21 +1761,22 @@ function mountSpecTab(root, ctx) {
|
|
|
1761
1761
|
return;
|
|
1762
1762
|
}
|
|
1763
1763
|
const el2 = spec.elements[current];
|
|
1764
|
-
const
|
|
1764
|
+
const childKeys = getChildKeys(el2);
|
|
1765
|
+
const hasChildren = childKeys.length > 0;
|
|
1765
1766
|
if (!hasChildren) return;
|
|
1766
1767
|
if (!expanded.has(current)) {
|
|
1767
1768
|
expanded.add(current);
|
|
1768
1769
|
render();
|
|
1769
1770
|
scrollSelectedIntoView();
|
|
1770
1771
|
} else {
|
|
1771
|
-
moveSelection(
|
|
1772
|
+
moveSelection(childKeys[0]);
|
|
1772
1773
|
}
|
|
1773
1774
|
return;
|
|
1774
1775
|
}
|
|
1775
1776
|
if (key === "ArrowLeft") {
|
|
1776
1777
|
if (!current) return;
|
|
1777
1778
|
const el2 = spec.elements[current];
|
|
1778
|
-
const hasChildren =
|
|
1779
|
+
const hasChildren = getChildKeys(el2).length > 0;
|
|
1779
1780
|
if (hasChildren && expanded.has(current)) {
|
|
1780
1781
|
expanded.delete(current);
|
|
1781
1782
|
render();
|
|
@@ -1791,7 +1792,7 @@ function mountSpecTab(root, ctx) {
|
|
|
1791
1792
|
return;
|
|
1792
1793
|
}
|
|
1793
1794
|
const el = spec.elements[current];
|
|
1794
|
-
if (el
|
|
1795
|
+
if (getChildKeys(el).length > 0) {
|
|
1795
1796
|
toggleExpanded(current);
|
|
1796
1797
|
scrollSelectedIntoView();
|
|
1797
1798
|
}
|
|
@@ -1977,19 +1978,27 @@ function collectVisibleKeys(spec, expanded) {
|
|
|
1977
1978
|
function walk(key) {
|
|
1978
1979
|
list.push(key);
|
|
1979
1980
|
const el = spec.elements[key];
|
|
1980
|
-
|
|
1981
|
+
const childKeys = getChildKeys(el);
|
|
1982
|
+
if (childKeys.length === 0) return;
|
|
1981
1983
|
if (!expanded.has(key)) return;
|
|
1982
|
-
for (const child of
|
|
1984
|
+
for (const child of childKeys) walk(child);
|
|
1983
1985
|
}
|
|
1984
1986
|
walk(spec.root);
|
|
1985
1987
|
return list;
|
|
1986
1988
|
}
|
|
1987
1989
|
function findParent(spec, key) {
|
|
1988
1990
|
for (const [parentKey, el] of Object.entries(spec.elements)) {
|
|
1989
|
-
if (el.
|
|
1991
|
+
if (getChildKeys(el).includes(key)) return parentKey;
|
|
1990
1992
|
}
|
|
1991
1993
|
return null;
|
|
1992
1994
|
}
|
|
1995
|
+
function getChildKeys(element) {
|
|
1996
|
+
if (!element) return [];
|
|
1997
|
+
return [
|
|
1998
|
+
...element.children ?? [],
|
|
1999
|
+
...Object.values(element.slots ?? {}).flat()
|
|
2000
|
+
];
|
|
2001
|
+
}
|
|
1993
2002
|
function collectIssues(spec) {
|
|
1994
2003
|
const result = validateSpec(spec, { checkOrphans: true });
|
|
1995
2004
|
const byKey = /* @__PURE__ */ new Map();
|
|
@@ -2009,8 +2018,7 @@ function findPath(spec, key) {
|
|
|
2009
2018
|
return true;
|
|
2010
2019
|
}
|
|
2011
2020
|
const el = spec.elements[current];
|
|
2012
|
-
|
|
2013
|
-
for (const child of el.children) {
|
|
2021
|
+
for (const child of getChildKeys(el)) {
|
|
2014
2022
|
if (walk(child)) {
|
|
2015
2023
|
path.push(current);
|
|
2016
2024
|
return true;
|
|
@@ -2035,7 +2043,8 @@ function renderNode(spec, key, depth, expanded, selected, issues, ctx, onToggle,
|
|
|
2035
2043
|
h("span", { className: "jr-tree-key" }, key)
|
|
2036
2044
|
);
|
|
2037
2045
|
}
|
|
2038
|
-
const
|
|
2046
|
+
const childKeys = getChildKeys(el);
|
|
2047
|
+
const hasChildren = childKeys.length > 0;
|
|
2039
2048
|
const isExpanded = hasChildren && expanded.has(key);
|
|
2040
2049
|
const isSelected = selected === key;
|
|
2041
2050
|
const elementIssues = issues.byKey.get(key) ?? [];
|
|
@@ -2091,7 +2100,7 @@ function renderNode(spec, key, depth, expanded, selected, issues, ctx, onToggle,
|
|
|
2091
2100
|
);
|
|
2092
2101
|
const container = h("div", null, row);
|
|
2093
2102
|
if (isExpanded && hasChildren) {
|
|
2094
|
-
for (const childKey of
|
|
2103
|
+
for (const childKey of childKeys) {
|
|
2095
2104
|
const childNode = renderNode(
|
|
2096
2105
|
spec,
|
|
2097
2106
|
childKey,
|
|
@@ -2137,7 +2146,7 @@ function renderDetail(container, spec, key, issues) {
|
|
|
2137
2146
|
return;
|
|
2138
2147
|
}
|
|
2139
2148
|
const elIssues = issues.byKey.get(key) ?? [];
|
|
2140
|
-
const children = el.
|
|
2149
|
+
const children = getChildKeys(el).length;
|
|
2141
2150
|
replaceChildren(
|
|
2142
2151
|
container,
|
|
2143
2152
|
h(
|