@cardenelabs/cdl 0.112.0 → 0.114.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 +74 -1
- package/dist/index.cjs +45 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -21
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +45 -21
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +45 -21
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/src/kinds/mind-map.tsx +121 -41
package/dist/react.cjs
CHANGED
|
@@ -5122,7 +5122,7 @@ function \u63CF\u304F\u6A2A\u306E\u7AEF(n) {
|
|
|
5122
5122
|
if (n.isRoot || !n.isLeaf) return [n.x - n.w / 2, n.x + n.w / 2];
|
|
5123
5123
|
const \u8D77\u70B9 = n.x + (n.side === "right" ? -n.w / 2 : n.w / 2);
|
|
5124
5124
|
const \u540D\u524D = \u653E\u5C04\u306E\u884C(n)[0];
|
|
5125
|
-
const \u5E45 =
|
|
5125
|
+
const \u5E45 = textWidth(\u540D\u524D.text, \u540D\u524D.fontSize);
|
|
5126
5126
|
return n.side === "right" ? [\u8D77\u70B9, \u8D77\u70B9 + \u5E45] : [\u8D77\u70B9 - \u5E45, \u8D77\u70B9];
|
|
5127
5127
|
}
|
|
5128
5128
|
function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
@@ -5195,30 +5195,52 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
5195
5195
|
if (kids.length === 0) return 1;
|
|
5196
5196
|
return kids.reduce((sum, k) => sum + leafCountOf(k.id, seen), 0);
|
|
5197
5197
|
};
|
|
5198
|
-
const
|
|
5198
|
+
const leftBranches = firstLevel.slice(0, leftCount);
|
|
5199
|
+
const rightBranches = firstLevel.slice(leftCount);
|
|
5199
5200
|
const minLayer1XOffset = rootW / 2 + branchW / 2 + MIND_BOX_GAP;
|
|
5200
5201
|
const preferredSubDx = subBranchW + 20;
|
|
5201
|
-
const reserve = maxSubDepth > 0 ? branchW / 2 + maxSubDepth * preferredSubDx : 0;
|
|
5202
|
-
const maxLayer1XOffset = Math.max(minLayer1XOffset, canvasW / 2 - reserve);
|
|
5203
|
-
const layer1XOffset = Math.max(minLayer1XOffset, Math.min(canvasW * 0.32, maxLayer1XOffset));
|
|
5204
|
-
const room = canvasW / 2 - layer1XOffset;
|
|
5205
5202
|
const MIN_SUB_W = 56;
|
|
5206
5203
|
const PREFERRED_GAP = MIND_BOX_GAP;
|
|
5207
|
-
const
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
const
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5204
|
+
const \u679D\u306E\u540D\u524D\u306E\u5E45 = (title) => {
|
|
5205
|
+
const \u540D\u524D = \u653E\u5C04\u306E\u884C({ title, isRoot: false })[0];
|
|
5206
|
+
return textWidth(\u540D\u524D.text, \u540D\u524D.fontSize);
|
|
5207
|
+
};
|
|
5208
|
+
const \u679D\u306E\u6A2A\u3092\u6C7A\u3081\u308B = (br) => {
|
|
5209
|
+
const maxSubDepth = subDepthOf(br.id, /* @__PURE__ */ new Set());
|
|
5210
|
+
const \u4E0A\u9650 = maxSubDepth > 0 ? canvasW / 2 - (branchW / 2 + maxSubDepth * preferredSubDx) : canvasW / 2 + branchW / 2 - \u679D\u306E\u540D\u524D\u306E\u5E45(br.title);
|
|
5211
|
+
const layer1XOffset = Math.floor(Math.max(minLayer1XOffset, \u4E0A\u9650));
|
|
5212
|
+
const room = canvasW / 2 - layer1XOffset;
|
|
5213
|
+
const gapRoom = maxSubDepth > 0 ? (room - branchW / 2 - maxSubDepth * MIN_SUB_W) / maxSubDepth : 0;
|
|
5214
|
+
const gap = Math.floor(Math.max(8, Math.min(PREFERRED_GAP, gapRoom)));
|
|
5215
|
+
const effSubW = maxSubDepth > 0 ? Math.floor(
|
|
5216
|
+
Math.max(1, Math.min(subBranchW, (room - branchW / 2 - maxSubDepth * gap) / maxSubDepth))
|
|
5217
|
+
) : subBranchW;
|
|
5218
|
+
const step1 = (branchW + effSubW) / 2 + gap;
|
|
5219
|
+
const stepN = effSubW + gap;
|
|
5220
|
+
return {
|
|
5221
|
+
layer1XOffset,
|
|
5222
|
+
effSubW,
|
|
5223
|
+
subOffset: (subDepth) => subDepth <= 0 ? 0 : step1 + (subDepth - 1) * stepN
|
|
5224
|
+
};
|
|
5225
|
+
};
|
|
5226
|
+
const \u6A2A\u306E\u5272\u4ED8\u8868 = new Map(
|
|
5227
|
+
firstLevel.map((br) => [br.id, \u679D\u306E\u6A2A\u3092\u6C7A\u3081\u308B(br)])
|
|
5228
|
+
);
|
|
5229
|
+
const \u4E00\u756A\u5185\u5074\u306E\u96E2\u308C = Math.min(
|
|
5230
|
+
...firstLevel.length > 0 ? firstLevel.map((br) => \u6A2A\u306E\u5272\u4ED8\u8868.get(br.id).layer1XOffset) : [minLayer1XOffset]
|
|
5231
|
+
);
|
|
5215
5232
|
const leavesOfSide = (brs) => Math.max(
|
|
5216
5233
|
1,
|
|
5217
5234
|
brs.reduce((sum, br) => sum + leafCountOf(br.id, /* @__PURE__ */ new Set()), 0)
|
|
5218
5235
|
);
|
|
5219
5236
|
const sideLaneCount = Math.max(leavesOfSide(leftBranches), leavesOfSide(rightBranches));
|
|
5220
5237
|
const laneBandH = Math.max(0, canvasH - BRANCH_BOX_H_MAX);
|
|
5221
|
-
const rowGap = sideLaneCount > 1 ? Math.min(
|
|
5238
|
+
const rowGap = sideLaneCount > 1 ? Math.min(
|
|
5239
|
+
laneBandH / (sideLaneCount - 1),
|
|
5240
|
+
// 帯は図で 1 つなので、**一番内側の枝** から上限を取る (#966)。
|
|
5241
|
+
// 外へ出た枝に合わせると、内側に残った枝の傾きが 45 度を超える
|
|
5242
|
+
\u7E26\u306E\u9593\u9694\u306E\u4E0A\u9650(\u4E00\u756A\u5185\u5074\u306E\u96E2\u308C)
|
|
5243
|
+
) : subBranchH + 14;
|
|
5222
5244
|
const effSubH = Math.min(SUB_BOX_H_MAX, rowGap * 0.7);
|
|
5223
5245
|
const effBranchH = Math.min(BRANCH_BOX_H_MAX, rowGap * 0.7);
|
|
5224
5246
|
const \u7AEF\u306E\u4F59\u308A = Math.max(effSubH, effBranchH) / 2;
|
|
@@ -5234,11 +5256,11 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
5234
5256
|
const half = nodeHalfW.get(mindData.rootId) ?? rootW / 2;
|
|
5235
5257
|
return \u4E2D\u5FC3\u306Ex + (isLeft ? -half : half);
|
|
5236
5258
|
};
|
|
5237
|
-
const placeSubtree = (node, subDepth, isLeft, tone, placed, laneRef) => {
|
|
5259
|
+
const placeSubtree = (node, subDepth, isLeft, tone, placed, laneRef, \u6A2A) => {
|
|
5238
5260
|
placed.add(node.id);
|
|
5239
5261
|
const dirX = isLeft ? -1 : 1;
|
|
5240
|
-
const x = cx + dirX * (layer1XOffset + subOffset(subDepth));
|
|
5241
|
-
const w = subDepth === 0 ? branchW : effSubW;
|
|
5262
|
+
const x = cx + dirX * (\u6A2A.layer1XOffset + \u6A2A.subOffset(subDepth));
|
|
5263
|
+
const w = subDepth === 0 ? branchW : \u6A2A.effSubW;
|
|
5242
5264
|
const h = subDepth === 0 ? effBranchH : effSubH;
|
|
5243
5265
|
const myTone = node.tone ?? tone;
|
|
5244
5266
|
const kids = (childrenOf.get(node.id) ?? []).filter((k) => !placed.has(k.id));
|
|
@@ -5254,7 +5276,8 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
5254
5276
|
isLeft,
|
|
5255
5277
|
myTone ?? MIND_TONES[i % MIND_TONES.length],
|
|
5256
5278
|
placed,
|
|
5257
|
-
laneRef
|
|
5279
|
+
laneRef,
|
|
5280
|
+
\u6A2A
|
|
5258
5281
|
)
|
|
5259
5282
|
);
|
|
5260
5283
|
y = (ys[0] + ys[ys.length - 1]) / 2;
|
|
@@ -5287,7 +5310,7 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
5287
5310
|
const placed = /* @__PURE__ */ new Set();
|
|
5288
5311
|
brs.forEach((br, i) => {
|
|
5289
5312
|
const tone = br.tone ?? MIND_TONES[(toneBase + i) % MIND_TONES.length];
|
|
5290
|
-
placeSubtree(br, 0, isLeft, tone, placed, laneRef);
|
|
5313
|
+
placeSubtree(br, 0, isLeft, tone, placed, laneRef, \u6A2A\u306E\u5272\u4ED8\u8868.get(br.id) ?? \u679D\u306E\u6A2A\u3092\u6C7A\u3081\u308B(br));
|
|
5291
5314
|
});
|
|
5292
5315
|
};
|
|
5293
5316
|
placeSide(leftBranches, true, 0);
|
|
@@ -5298,7 +5321,8 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
5298
5321
|
let maxExtentX = rootW / 2;
|
|
5299
5322
|
let maxExtentY = rootH / 2;
|
|
5300
5323
|
for (const n of nodes) {
|
|
5301
|
-
|
|
5324
|
+
const [\u5DE6, \u53F3] = \u63CF\u304F\u6A2A\u306E\u7AEF(n);
|
|
5325
|
+
maxExtentX = Math.max(maxExtentX, Math.abs(\u5DE6 - cx), Math.abs(\u53F3 - cx));
|
|
5302
5326
|
maxExtentY = Math.max(maxExtentY, Math.abs(n.y - cy) + n.h / 2);
|
|
5303
5327
|
}
|
|
5304
5328
|
const scale = Math.min(1, drawableHalfW / maxExtentX, drawableHalfH / maxExtentY);
|