@cardenelabs/cdl 0.113.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/dist/react.js CHANGED
@@ -5120,7 +5120,7 @@ function \u63CF\u304F\u6A2A\u306E\u7AEF(n) {
5120
5120
  if (n.isRoot || !n.isLeaf) return [n.x - n.w / 2, n.x + n.w / 2];
5121
5121
  const \u8D77\u70B9 = n.x + (n.side === "right" ? -n.w / 2 : n.w / 2);
5122
5122
  const \u540D\u524D = \u653E\u5C04\u306E\u884C(n)[0];
5123
- const \u5E45 = measureTextWidth(\u540D\u524D.text, { fontSize: \u540D\u524D.fontSize});
5123
+ const \u5E45 = textWidth(\u540D\u524D.text, \u540D\u524D.fontSize);
5124
5124
  return n.side === "right" ? [\u8D77\u70B9, \u8D77\u70B9 + \u5E45] : [\u8D77\u70B9 - \u5E45, \u8D77\u70B9];
5125
5125
  }
5126
5126
  function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
@@ -5193,38 +5193,52 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
5193
5193
  if (kids.length === 0) return 1;
5194
5194
  return kids.reduce((sum, k) => sum + leafCountOf(k.id, seen), 0);
5195
5195
  };
5196
- const maxSubDepth = firstLevel.length > 0 ? Math.max(0, ...firstLevel.map((br) => subDepthOf(br.id, /* @__PURE__ */ new Set()))) : 0;
5196
+ const leftBranches = firstLevel.slice(0, leftCount);
5197
+ const rightBranches = firstLevel.slice(leftCount);
5197
5198
  const minLayer1XOffset = rootW / 2 + branchW / 2 + MIND_BOX_GAP;
5198
5199
  const preferredSubDx = subBranchW + 20;
5199
- const reserve = maxSubDepth > 0 ? branchW / 2 + maxSubDepth * preferredSubDx : 0;
5200
- const maxLayer1XOffset = Math.max(minLayer1XOffset, canvasW / 2 - reserve);
5201
- const \u8449\u306E\u540D\u524D\u306E\u6700\u5927\u5E45 = Math.max(
5202
- 0,
5203
- ...firstLevel.filter((br) => (childrenOf.get(br.id) ?? []).length === 0).map((br) => {
5204
- const \u540D\u524D = \u653E\u5C04\u306E\u884C({ title: br.title, isRoot: false })[0];
5205
- return measureTextWidth(\u540D\u524D.text, { fontSize: \u540D\u524D.fontSize});
5206
- })
5207
- );
5208
- const \u540D\u524D\u3067\u6C7A\u307E\u308B\u4E0A\u9650 = canvasW / 2 + branchW / 2 - \u8449\u306E\u540D\u524D\u306E\u6700\u5927\u5E45;
5209
- const layer1XOffset = Math.max(minLayer1XOffset, Math.min(\u540D\u524D\u3067\u6C7A\u307E\u308B\u4E0A\u9650, maxLayer1XOffset));
5210
- const room = canvasW / 2 - layer1XOffset;
5211
5200
  const MIN_SUB_W = 56;
5212
5201
  const PREFERRED_GAP = MIND_BOX_GAP;
5213
- const gapRoom = maxSubDepth > 0 ? (room - branchW / 2 - maxSubDepth * MIN_SUB_W) / maxSubDepth : 0;
5214
- const gap = Math.max(8, Math.min(PREFERRED_GAP, gapRoom));
5215
- const effSubW = maxSubDepth > 0 ? Math.max(1, Math.min(subBranchW, (room - branchW / 2 - maxSubDepth * gap) / maxSubDepth)) : subBranchW;
5216
- const step1 = (branchW + effSubW) / 2 + gap;
5217
- const stepN = effSubW + gap;
5218
- const subOffset = (subDepth) => subDepth <= 0 ? 0 : step1 + (subDepth - 1) * stepN;
5219
- const leftBranches = firstLevel.slice(0, leftCount);
5220
- const rightBranches = firstLevel.slice(leftCount);
5202
+ const \u679D\u306E\u540D\u524D\u306E\u5E45 = (title) => {
5203
+ const \u540D\u524D = \u653E\u5C04\u306E\u884C({ title, isRoot: false })[0];
5204
+ return textWidth(\u540D\u524D.text, \u540D\u524D.fontSize);
5205
+ };
5206
+ const \u679D\u306E\u6A2A\u3092\u6C7A\u3081\u308B = (br) => {
5207
+ const maxSubDepth = subDepthOf(br.id, /* @__PURE__ */ new Set());
5208
+ const \u4E0A\u9650 = maxSubDepth > 0 ? canvasW / 2 - (branchW / 2 + maxSubDepth * preferredSubDx) : canvasW / 2 + branchW / 2 - \u679D\u306E\u540D\u524D\u306E\u5E45(br.title);
5209
+ const layer1XOffset = Math.floor(Math.max(minLayer1XOffset, \u4E0A\u9650));
5210
+ const room = canvasW / 2 - layer1XOffset;
5211
+ const gapRoom = maxSubDepth > 0 ? (room - branchW / 2 - maxSubDepth * MIN_SUB_W) / maxSubDepth : 0;
5212
+ const gap = Math.floor(Math.max(8, Math.min(PREFERRED_GAP, gapRoom)));
5213
+ const effSubW = maxSubDepth > 0 ? Math.floor(
5214
+ Math.max(1, Math.min(subBranchW, (room - branchW / 2 - maxSubDepth * gap) / maxSubDepth))
5215
+ ) : subBranchW;
5216
+ const step1 = (branchW + effSubW) / 2 + gap;
5217
+ const stepN = effSubW + gap;
5218
+ return {
5219
+ layer1XOffset,
5220
+ effSubW,
5221
+ subOffset: (subDepth) => subDepth <= 0 ? 0 : step1 + (subDepth - 1) * stepN
5222
+ };
5223
+ };
5224
+ const \u6A2A\u306E\u5272\u4ED8\u8868 = new Map(
5225
+ firstLevel.map((br) => [br.id, \u679D\u306E\u6A2A\u3092\u6C7A\u3081\u308B(br)])
5226
+ );
5227
+ const \u4E00\u756A\u5185\u5074\u306E\u96E2\u308C = Math.min(
5228
+ ...firstLevel.length > 0 ? firstLevel.map((br) => \u6A2A\u306E\u5272\u4ED8\u8868.get(br.id).layer1XOffset) : [minLayer1XOffset]
5229
+ );
5221
5230
  const leavesOfSide = (brs) => Math.max(
5222
5231
  1,
5223
5232
  brs.reduce((sum, br) => sum + leafCountOf(br.id, /* @__PURE__ */ new Set()), 0)
5224
5233
  );
5225
5234
  const sideLaneCount = Math.max(leavesOfSide(leftBranches), leavesOfSide(rightBranches));
5226
5235
  const laneBandH = Math.max(0, canvasH - BRANCH_BOX_H_MAX);
5227
- const rowGap = sideLaneCount > 1 ? Math.min(laneBandH / (sideLaneCount - 1), \u7E26\u306E\u9593\u9694\u306E\u4E0A\u9650(layer1XOffset)) : subBranchH + 14;
5236
+ const rowGap = sideLaneCount > 1 ? Math.min(
5237
+ laneBandH / (sideLaneCount - 1),
5238
+ // 帯は図で 1 つなので、**一番内側の枝** から上限を取る (#966)。
5239
+ // 外へ出た枝に合わせると、内側に残った枝の傾きが 45 度を超える
5240
+ \u7E26\u306E\u9593\u9694\u306E\u4E0A\u9650(\u4E00\u756A\u5185\u5074\u306E\u96E2\u308C)
5241
+ ) : subBranchH + 14;
5228
5242
  const effSubH = Math.min(SUB_BOX_H_MAX, rowGap * 0.7);
5229
5243
  const effBranchH = Math.min(BRANCH_BOX_H_MAX, rowGap * 0.7);
5230
5244
  const \u7AEF\u306E\u4F59\u308A = Math.max(effSubH, effBranchH) / 2;
@@ -5240,11 +5254,11 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
5240
5254
  const half = nodeHalfW.get(mindData.rootId) ?? rootW / 2;
5241
5255
  return \u4E2D\u5FC3\u306Ex + (isLeft ? -half : half);
5242
5256
  };
5243
- const placeSubtree = (node, subDepth, isLeft, tone, placed, laneRef) => {
5257
+ const placeSubtree = (node, subDepth, isLeft, tone, placed, laneRef, \u6A2A) => {
5244
5258
  placed.add(node.id);
5245
5259
  const dirX = isLeft ? -1 : 1;
5246
- const x = cx + dirX * (layer1XOffset + subOffset(subDepth));
5247
- const w = subDepth === 0 ? branchW : effSubW;
5260
+ const x = cx + dirX * (\u6A2A.layer1XOffset + \u6A2A.subOffset(subDepth));
5261
+ const w = subDepth === 0 ? branchW : \u6A2A.effSubW;
5248
5262
  const h = subDepth === 0 ? effBranchH : effSubH;
5249
5263
  const myTone = node.tone ?? tone;
5250
5264
  const kids = (childrenOf.get(node.id) ?? []).filter((k) => !placed.has(k.id));
@@ -5260,7 +5274,8 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
5260
5274
  isLeft,
5261
5275
  myTone ?? MIND_TONES[i % MIND_TONES.length],
5262
5276
  placed,
5263
- laneRef
5277
+ laneRef,
5278
+ \u6A2A
5264
5279
  )
5265
5280
  );
5266
5281
  y = (ys[0] + ys[ys.length - 1]) / 2;
@@ -5293,7 +5308,7 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
5293
5308
  const placed = /* @__PURE__ */ new Set();
5294
5309
  brs.forEach((br, i) => {
5295
5310
  const tone = br.tone ?? MIND_TONES[(toneBase + i) % MIND_TONES.length];
5296
- placeSubtree(br, 0, isLeft, tone, placed, laneRef);
5311
+ placeSubtree(br, 0, isLeft, tone, placed, laneRef, \u6A2A\u306E\u5272\u4ED8\u8868.get(br.id) ?? \u679D\u306E\u6A2A\u3092\u6C7A\u3081\u308B(br));
5297
5312
  });
5298
5313
  };
5299
5314
  placeSide(leftBranches, true, 0);