@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/index.js
CHANGED
|
@@ -16139,7 +16139,7 @@ function \u63CF\u304F\u6A2A\u306E\u7AEF(n) {
|
|
|
16139
16139
|
if (n.isRoot || !n.isLeaf) return [n.x - n.w / 2, n.x + n.w / 2];
|
|
16140
16140
|
const \u8D77\u70B9 = n.x + (n.side === "right" ? -n.w / 2 : n.w / 2);
|
|
16141
16141
|
const \u540D\u524D = \u653E\u5C04\u306E\u884C(n)[0];
|
|
16142
|
-
const \u5E45 =
|
|
16142
|
+
const \u5E45 = textWidth(\u540D\u524D.text, \u540D\u524D.fontSize);
|
|
16143
16143
|
return n.side === "right" ? [\u8D77\u70B9, \u8D77\u70B9 + \u5E45] : [\u8D77\u70B9 - \u5E45, \u8D77\u70B9];
|
|
16144
16144
|
}
|
|
16145
16145
|
function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
@@ -16212,30 +16212,52 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
16212
16212
|
if (kids.length === 0) return 1;
|
|
16213
16213
|
return kids.reduce((sum, k) => sum + leafCountOf(k.id, seen), 0);
|
|
16214
16214
|
};
|
|
16215
|
-
const
|
|
16215
|
+
const leftBranches = firstLevel.slice(0, leftCount);
|
|
16216
|
+
const rightBranches = firstLevel.slice(leftCount);
|
|
16216
16217
|
const minLayer1XOffset = rootW / 2 + branchW / 2 + MIND_BOX_GAP;
|
|
16217
16218
|
const preferredSubDx = subBranchW + 20;
|
|
16218
|
-
const reserve = maxSubDepth > 0 ? branchW / 2 + maxSubDepth * preferredSubDx : 0;
|
|
16219
|
-
const maxLayer1XOffset = Math.max(minLayer1XOffset, canvasW / 2 - reserve);
|
|
16220
|
-
const layer1XOffset = Math.max(minLayer1XOffset, Math.min(canvasW * 0.32, maxLayer1XOffset));
|
|
16221
|
-
const room = canvasW / 2 - layer1XOffset;
|
|
16222
16219
|
const MIN_SUB_W = 56;
|
|
16223
16220
|
const PREFERRED_GAP = MIND_BOX_GAP;
|
|
16224
|
-
const
|
|
16225
|
-
|
|
16226
|
-
|
|
16227
|
-
|
|
16228
|
-
const
|
|
16229
|
-
|
|
16230
|
-
|
|
16231
|
-
|
|
16221
|
+
const \u679D\u306E\u540D\u524D\u306E\u5E45 = (title) => {
|
|
16222
|
+
const \u540D\u524D = \u653E\u5C04\u306E\u884C({ title, isRoot: false })[0];
|
|
16223
|
+
return textWidth(\u540D\u524D.text, \u540D\u524D.fontSize);
|
|
16224
|
+
};
|
|
16225
|
+
const \u679D\u306E\u6A2A\u3092\u6C7A\u3081\u308B = (br) => {
|
|
16226
|
+
const maxSubDepth = subDepthOf(br.id, /* @__PURE__ */ new Set());
|
|
16227
|
+
const \u4E0A\u9650 = maxSubDepth > 0 ? canvasW / 2 - (branchW / 2 + maxSubDepth * preferredSubDx) : canvasW / 2 + branchW / 2 - \u679D\u306E\u540D\u524D\u306E\u5E45(br.title);
|
|
16228
|
+
const layer1XOffset = Math.floor(Math.max(minLayer1XOffset, \u4E0A\u9650));
|
|
16229
|
+
const room = canvasW / 2 - layer1XOffset;
|
|
16230
|
+
const gapRoom = maxSubDepth > 0 ? (room - branchW / 2 - maxSubDepth * MIN_SUB_W) / maxSubDepth : 0;
|
|
16231
|
+
const gap = Math.floor(Math.max(8, Math.min(PREFERRED_GAP, gapRoom)));
|
|
16232
|
+
const effSubW = maxSubDepth > 0 ? Math.floor(
|
|
16233
|
+
Math.max(1, Math.min(subBranchW, (room - branchW / 2 - maxSubDepth * gap) / maxSubDepth))
|
|
16234
|
+
) : subBranchW;
|
|
16235
|
+
const step1 = (branchW + effSubW) / 2 + gap;
|
|
16236
|
+
const stepN = effSubW + gap;
|
|
16237
|
+
return {
|
|
16238
|
+
layer1XOffset,
|
|
16239
|
+
effSubW,
|
|
16240
|
+
subOffset: (subDepth) => subDepth <= 0 ? 0 : step1 + (subDepth - 1) * stepN
|
|
16241
|
+
};
|
|
16242
|
+
};
|
|
16243
|
+
const \u6A2A\u306E\u5272\u4ED8\u8868 = new Map(
|
|
16244
|
+
firstLevel.map((br) => [br.id, \u679D\u306E\u6A2A\u3092\u6C7A\u3081\u308B(br)])
|
|
16245
|
+
);
|
|
16246
|
+
const \u4E00\u756A\u5185\u5074\u306E\u96E2\u308C = Math.min(
|
|
16247
|
+
...firstLevel.length > 0 ? firstLevel.map((br) => \u6A2A\u306E\u5272\u4ED8\u8868.get(br.id).layer1XOffset) : [minLayer1XOffset]
|
|
16248
|
+
);
|
|
16232
16249
|
const leavesOfSide = (brs) => Math.max(
|
|
16233
16250
|
1,
|
|
16234
16251
|
brs.reduce((sum, br) => sum + leafCountOf(br.id, /* @__PURE__ */ new Set()), 0)
|
|
16235
16252
|
);
|
|
16236
16253
|
const sideLaneCount = Math.max(leavesOfSide(leftBranches), leavesOfSide(rightBranches));
|
|
16237
16254
|
const laneBandH = Math.max(0, canvasH - BRANCH_BOX_H_MAX);
|
|
16238
|
-
const rowGap = sideLaneCount > 1 ? Math.min(
|
|
16255
|
+
const rowGap = sideLaneCount > 1 ? Math.min(
|
|
16256
|
+
laneBandH / (sideLaneCount - 1),
|
|
16257
|
+
// 帯は図で 1 つなので、**一番内側の枝** から上限を取る (#966)。
|
|
16258
|
+
// 外へ出た枝に合わせると、内側に残った枝の傾きが 45 度を超える
|
|
16259
|
+
\u7E26\u306E\u9593\u9694\u306E\u4E0A\u9650(\u4E00\u756A\u5185\u5074\u306E\u96E2\u308C)
|
|
16260
|
+
) : subBranchH + 14;
|
|
16239
16261
|
const effSubH = Math.min(SUB_BOX_H_MAX, rowGap * 0.7);
|
|
16240
16262
|
const effBranchH = Math.min(BRANCH_BOX_H_MAX, rowGap * 0.7);
|
|
16241
16263
|
const \u7AEF\u306E\u4F59\u308A = Math.max(effSubH, effBranchH) / 2;
|
|
@@ -16251,11 +16273,11 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
16251
16273
|
const half = nodeHalfW.get(mindData.rootId) ?? rootW / 2;
|
|
16252
16274
|
return \u4E2D\u5FC3\u306Ex + (isLeft ? -half : half);
|
|
16253
16275
|
};
|
|
16254
|
-
const placeSubtree = (node, subDepth, isLeft, tone, placed, laneRef) => {
|
|
16276
|
+
const placeSubtree = (node, subDepth, isLeft, tone, placed, laneRef, \u6A2A) => {
|
|
16255
16277
|
placed.add(node.id);
|
|
16256
16278
|
const dirX = isLeft ? -1 : 1;
|
|
16257
|
-
const x = cx + dirX * (layer1XOffset + subOffset(subDepth));
|
|
16258
|
-
const w = subDepth === 0 ? branchW : effSubW;
|
|
16279
|
+
const x = cx + dirX * (\u6A2A.layer1XOffset + \u6A2A.subOffset(subDepth));
|
|
16280
|
+
const w = subDepth === 0 ? branchW : \u6A2A.effSubW;
|
|
16259
16281
|
const h = subDepth === 0 ? effBranchH : effSubH;
|
|
16260
16282
|
const myTone = node.tone ?? tone;
|
|
16261
16283
|
const kids = (childrenOf.get(node.id) ?? []).filter((k) => !placed.has(k.id));
|
|
@@ -16271,7 +16293,8 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
16271
16293
|
isLeft,
|
|
16272
16294
|
myTone ?? MIND_TONES[i % MIND_TONES.length],
|
|
16273
16295
|
placed,
|
|
16274
|
-
laneRef
|
|
16296
|
+
laneRef,
|
|
16297
|
+
\u6A2A
|
|
16275
16298
|
)
|
|
16276
16299
|
);
|
|
16277
16300
|
y = (ys[0] + ys[ys.length - 1]) / 2;
|
|
@@ -16304,7 +16327,7 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
16304
16327
|
const placed = /* @__PURE__ */ new Set();
|
|
16305
16328
|
brs.forEach((br, i) => {
|
|
16306
16329
|
const tone = br.tone ?? MIND_TONES[(toneBase + i) % MIND_TONES.length];
|
|
16307
|
-
placeSubtree(br, 0, isLeft, tone, placed, laneRef);
|
|
16330
|
+
placeSubtree(br, 0, isLeft, tone, placed, laneRef, \u6A2A\u306E\u5272\u4ED8\u8868.get(br.id) ?? \u679D\u306E\u6A2A\u3092\u6C7A\u3081\u308B(br));
|
|
16308
16331
|
});
|
|
16309
16332
|
};
|
|
16310
16333
|
placeSide(leftBranches, true, 0);
|
|
@@ -16315,7 +16338,8 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
16315
16338
|
let maxExtentX = rootW / 2;
|
|
16316
16339
|
let maxExtentY = rootH / 2;
|
|
16317
16340
|
for (const n of nodes) {
|
|
16318
|
-
|
|
16341
|
+
const [\u5DE6, \u53F3] = \u63CF\u304F\u6A2A\u306E\u7AEF(n);
|
|
16342
|
+
maxExtentX = Math.max(maxExtentX, Math.abs(\u5DE6 - cx), Math.abs(\u53F3 - cx));
|
|
16319
16343
|
maxExtentY = Math.max(maxExtentY, Math.abs(n.y - cy) + n.h / 2);
|
|
16320
16344
|
}
|
|
16321
16345
|
const scale = Math.min(1, drawableHalfW / maxExtentX, drawableHalfH / maxExtentY);
|