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