@cardenelabs/cdl 0.114.0 → 0.116.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/CHANGELOG.md +71 -1
- package/dist/index.cjs +65 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +65 -6
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +28 -4
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +28 -4
- package/dist/react.js.map +1 -1
- package/dist/{render-oEmwYN-q.d.cts → render-A5AKjNuy.d.cts} +1 -1
- package/dist/{render-oEmwYN-q.d.ts → render-A5AKjNuy.d.ts} +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/kinds/tree.tsx +127 -4
- package/src/presets.ts +5 -1
package/dist/react.cjs
CHANGED
|
@@ -4701,6 +4701,8 @@ var PAD_TOP = 40;
|
|
|
4701
4701
|
var PAD_RIGHT = 24;
|
|
4702
4702
|
var PAD_BOTTOM = 40;
|
|
4703
4703
|
var PAD_LEFT = 24;
|
|
4704
|
+
var \u7BB1\u306E\u6700\u5927\u5E45 = 140;
|
|
4705
|
+
var \u7BB1\u306E\u6700\u5927\u9AD8\u3055 = 38;
|
|
4704
4706
|
var \u6728\u306E\u679D\u306E\u592A\u3055 = (\u6BB5) => Math.max(1.1, 2.6 - \u6BB5 * 0.45);
|
|
4705
4707
|
function \u6728\u306E\u4E2D\u8EAB(node, stateValues = {}) {
|
|
4706
4708
|
const treeNodes = resolveTreeData(node.treeData ?? [], stateValues);
|
|
@@ -4904,14 +4906,36 @@ function computeTreeLayout(treeNodes, canvasW, canvasH) {
|
|
|
4904
4906
|
);
|
|
4905
4907
|
const depthGap = canvasH / Math.max(maxDepth + 1, 1);
|
|
4906
4908
|
const slotW = canvasW / totalLeaves;
|
|
4907
|
-
const nodeH = Math.min(
|
|
4908
|
-
const nodeW = Math.min(
|
|
4909
|
+
const nodeH = Math.min(\u7BB1\u306E\u6700\u5927\u9AD8\u3055, depthGap * 0.7);
|
|
4910
|
+
const nodeW = Math.min(\u7BB1\u306E\u6700\u5927\u5E45, slotW * 0.85);
|
|
4909
4911
|
const \u7BB1\u306E\u5E45 = (n, depth) => {
|
|
4910
4912
|
const \u6750\u6599 = \u6728\u306E\u884C({ ...n, depth });
|
|
4911
4913
|
const \u540D\u524D = \u6750\u6599[0];
|
|
4912
4914
|
const \u8981\u308B = measureTextWidth(\u540D\u524D.text, { fontSize: \u540D\u524D.fontSize}) + (nodeW - \u4F7F\u3048\u308B\u5E45(nodeW));
|
|
4913
4915
|
return Math.min(Math.max(\u8981\u308B, nodeW), slotW * 0.92);
|
|
4914
4916
|
};
|
|
4917
|
+
const \u8449\u306E\u4E26\u3073 = [];
|
|
4918
|
+
const \u6BB5\u306E\u8868 = /* @__PURE__ */ new Map();
|
|
4919
|
+
const \u5E45\u306E\u8868 = /* @__PURE__ */ new Map();
|
|
4920
|
+
{
|
|
4921
|
+
const \u898B\u305F = /* @__PURE__ */ new Set();
|
|
4922
|
+
const \u4E0B\u898B = (n, depth) => {
|
|
4923
|
+
\u898B\u305F.add(n.id);
|
|
4924
|
+
\u6BB5\u306E\u8868.set(n.id, depth);
|
|
4925
|
+
\u5E45\u306E\u8868.set(n.id, \u7BB1\u306E\u5E45(n, depth));
|
|
4926
|
+
const kids = (childrenOf.get(n.id) ?? []).filter((k) => !\u898B\u305F.has(k.id));
|
|
4927
|
+
if (kids.length === 0) {
|
|
4928
|
+
\u8449\u306E\u4E26\u3073.push(n.id);
|
|
4929
|
+
return;
|
|
4930
|
+
}
|
|
4931
|
+
for (const k of kids) \u4E0B\u898B(k, depth + 1);
|
|
4932
|
+
};
|
|
4933
|
+
for (const r of roots) if (!\u898B\u305F.has(r.id)) \u4E0B\u898B(r, 0);
|
|
4934
|
+
}
|
|
4935
|
+
const \u8449\u306E\u6570 = Math.max(\u8449\u306E\u4E26\u3073.length, 1);
|
|
4936
|
+
const \u6BB5\u306E\u9699\u9593 = depthGap - nodeH;
|
|
4937
|
+
const \u8449\u306E\u9593\u9694 = Math.min(slotW, nodeW + \u6BB5\u306E\u9699\u9593);
|
|
4938
|
+
const \u8449\u306Ex = (i) => canvasW / 2 - (\u8449\u306E\u6570 - 1) * \u8449\u306E\u9593\u9694 / 2 + i * \u8449\u306E\u9593\u9694;
|
|
4915
4939
|
const posOf = /* @__PURE__ */ new Map();
|
|
4916
4940
|
const nodes = [];
|
|
4917
4941
|
const placed = /* @__PURE__ */ new Set();
|
|
@@ -4921,7 +4945,7 @@ function computeTreeLayout(treeNodes, canvasW, canvasH) {
|
|
|
4921
4945
|
const kids = (childrenOf.get(n.id) ?? []).filter((k) => !placed.has(k.id));
|
|
4922
4946
|
let x;
|
|
4923
4947
|
if (kids.length === 0) {
|
|
4924
|
-
x = leafCursor
|
|
4948
|
+
x = \u8449\u306Ex(leafCursor);
|
|
4925
4949
|
leafCursor += 1;
|
|
4926
4950
|
} else {
|
|
4927
4951
|
const xs = kids.map((k) => place(k, depth + 1));
|
|
@@ -4935,7 +4959,7 @@ function computeTreeLayout(treeNodes, canvasW, canvasH) {
|
|
|
4935
4959
|
...n.subtitle !== void 0 ? { subtitle: n.subtitle } : {},
|
|
4936
4960
|
x,
|
|
4937
4961
|
y,
|
|
4938
|
-
w: \u7BB1\u306E\u5E45(n, depth),
|
|
4962
|
+
w: \u5E45\u306E\u8868.get(n.id) ?? \u7BB1\u306E\u5E45(n, depth),
|
|
4939
4963
|
h: nodeH,
|
|
4940
4964
|
depth,
|
|
4941
4965
|
...n.unresolved ? { unresolved: true } : {}
|