@cardenelabs/cdl 0.38.0 → 0.39.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.d.cts CHANGED
@@ -1,2 +1,2 @@
1
1
  import 'react';
2
- export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-BYdmSviQ.cjs';
2
+ export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-B1ArenZ7.cjs';
package/dist/react.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import 'react';
2
- export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-BYdmSviQ.js';
2
+ export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-B1ArenZ7.js';
package/dist/react.js CHANGED
@@ -9524,7 +9524,10 @@ var DRAW_KINDS = /* @__PURE__ */ new Set([
9524
9524
  "mind-map",
9525
9525
  "tree-hierarchy",
9526
9526
  "gantt-timeline",
9527
- "funnel-stages"
9527
+ "funnel-stages",
9528
+ "chart-gauge",
9529
+ "chart-radial",
9530
+ "chart-stacked-bar"
9528
9531
  ]);
9529
9532
  var KINDS = new Set(NODE_KINDS);
9530
9533
  var ENG_BANNED = /\b(FUNCTION|STORAGE|EVENT LOG|BALANCES MAPPING|READ|WRITE|EMIT|CALL)\b/;
@@ -11853,6 +11856,15 @@ function interpolateColor(template, stateValues, fallback) {
11853
11856
  if (!template) return fallback;
11854
11857
  return interpolate(template, stateValues);
11855
11858
  }
11859
+ function \u6247\u5F62\u306E\u5207\u308A\u629C\u304D(cx, cy, r, \u958B\u304D, \u8D77\u70B9 = -Math.PI / 2, \u5168\u5468 = Math.PI * 2) {
11860
+ if (\u958B\u304D <= 0) return null;
11861
+ if (\u958B\u304D >= 1 && \u5168\u5468 >= Math.PI * 2) return /* @__PURE__ */ jsx("circle", { cx, cy, r });
11862
+ const a0 = \u8D77\u70B9;
11863
+ const a1 = a0 + Math.min(1, \u958B\u304D) * \u5168\u5468;
11864
+ const large = a1 - a0 > Math.PI ? 1 : 0;
11865
+ const d = `M ${cx} ${cy} L ${cx + r * Math.cos(a0)} ${cy + r * Math.sin(a0)} A ${r} ${r} 0 ${large} 1 ${cx + r * Math.cos(a1)} ${cy + r * Math.sin(a1)} Z`;
11866
+ return /* @__PURE__ */ jsx("path", { d });
11867
+ }
11856
11868
 
11857
11869
  // src/kinds/chart-number.ts
11858
11870
  function \u5B9F\u5024\u8868\u8A18(v) {
@@ -12300,15 +12312,6 @@ function \u8F2A\u306E\u9053(cx, cy, R, r, a0, a1) {
12300
12312
  const large = a1 - a0 > Math.PI ? 1 : 0;
12301
12313
  return `M ${cx + R * Math.cos(a0)} ${cy + R * Math.sin(a0)} A ${R} ${R} 0 ${large} 1 ${cx + R * Math.cos(a1)} ${cy + R * Math.sin(a1)} L ${cx + r * Math.cos(a1)} ${cy + r * Math.sin(a1)} A ${r} ${r} 0 ${large} 0 ${cx + r * Math.cos(a0)} ${cy + r * Math.sin(a0)} Z`;
12302
12314
  }
12303
- function \u6247\u5F62\u306E\u5207\u308A\u629C\u304D(cx, cy, r, \u958B\u304D) {
12304
- if (\u958B\u304D <= 0) return null;
12305
- if (\u958B\u304D >= 1) return /* @__PURE__ */ jsx("circle", { cx, cy, r });
12306
- const a0 = -Math.PI / 2;
12307
- const a1 = a0 + \u958B\u304D * Math.PI * 2;
12308
- const large = \u958B\u304D > 0.5 ? 1 : 0;
12309
- const d = `M ${cx} ${cy} L ${cx + r * Math.cos(a0)} ${cy + r * Math.sin(a0)} A ${r} ${r} 0 ${large} 1 ${cx + r * Math.cos(a1)} ${cy + r * Math.sin(a1)} Z`;
12310
- return /* @__PURE__ */ jsx("path", { d });
12311
- }
12312
12315
  function sliceColor(tone, idx) {
12313
12316
  if (tone) return TONE[tone];
12314
12317
  return chartSeriesColor(idx);
@@ -12316,7 +12319,9 @@ function sliceColor(tone, idx) {
12316
12319
  function ChartGaugeNode({
12317
12320
  node,
12318
12321
  active,
12319
- stateValues = {}
12322
+ stateValues = {},
12323
+ drawing = false,
12324
+ progress = 1
12320
12325
  }) {
12321
12326
  const x0 = node.cx - node.w / 2;
12322
12327
  const y0 = node.cy - node.h / 2;
@@ -12361,6 +12366,21 @@ function ChartGaugeNode({
12361
12366
  const \u898B\u51FA\u3057\u306E\u7D1A = Math.max(9, Math.round(\u5408\u8A08\u306E\u7D1A * 0.38));
12362
12367
  const \u5185\u8A33\u306E\u5E45 = \u4F7F\u3048\u308B\u5E452 / Math.max(data.length, 1);
12363
12368
  const \u5185\u8A33\u306Ey = cy + \u5F27\u3068\u5185\u8A33\u306E\u9593;
12369
+ const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
12370
+ const \u5207\u308A\u629C\u304Did = `cdl-gauge-draw-${useId().replace(/[^A-Za-z0-9_-]/g, "")}`;
12371
+ const \u5F27\u305F\u3061 = slices.map((s, idx) => /* @__PURE__ */ jsx(
12372
+ "path",
12373
+ {
12374
+ "data-cdl-role": "chart-gauge-arc",
12375
+ "data-cdl-unresolved": s.d.unresolved ? "true" : void 0,
12376
+ d: s.path,
12377
+ fill: arcColor(s.d.tone, idx),
12378
+ stroke: "var(--cdl-node-fill, #ffffff)",
12379
+ strokeWidth: 3,
12380
+ strokeLinejoin: "round"
12381
+ },
12382
+ `arc-${idx}`
12383
+ ));
12364
12384
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
12365
12385
  /* @__PURE__ */ jsx(
12366
12386
  "rect",
@@ -12376,19 +12396,8 @@ function ChartGaugeNode({
12376
12396
  strokeWidth: active ? 3 : 1.25
12377
12397
  }
12378
12398
  ),
12379
- slices.map((s, idx) => /* @__PURE__ */ jsx(
12380
- "path",
12381
- {
12382
- "data-cdl-role": "chart-gauge-arc",
12383
- "data-cdl-unresolved": s.d.unresolved ? "true" : void 0,
12384
- d: s.path,
12385
- fill: arcColor(s.d.tone, idx),
12386
- stroke: "var(--cdl-node-fill, #ffffff)",
12387
- strokeWidth: 3,
12388
- strokeLinejoin: "round"
12389
- },
12390
- `arc-${idx}`
12391
- )),
12399
+ drawing && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: \u5207\u308A\u629C\u304Did, children: \u6247\u5F62\u306E\u5207\u308A\u629C\u304D(cx, cy, radius + 2, \u4F38\u3073, Math.PI, Math.PI) }) }),
12400
+ drawing ? /* @__PURE__ */ jsx("g", { clipPath: `url(#${\u5207\u308A\u629C\u304Did})`, children: \u5F27\u305F\u3061 }) : \u5F27\u305F\u3061,
12392
12401
  /* @__PURE__ */ jsx(
12393
12402
  "text",
12394
12403
  {
@@ -12453,7 +12462,9 @@ function arcColor(tone, idx) {
12453
12462
  function ChartRadialNode({
12454
12463
  node,
12455
12464
  active,
12456
- stateValues = {}
12465
+ stateValues = {},
12466
+ drawing = false,
12467
+ progress = 1
12457
12468
  }) {
12458
12469
  const x0 = node.cx - node.w / 2;
12459
12470
  const y0 = node.cy - node.h / 2;
@@ -12492,6 +12503,20 @@ function ChartRadialNode({
12492
12503
  };
12493
12504
  });
12494
12505
  const \u4E00\u89A7\u306E\u59CB\u307E\u308A = PAD + (\u4F7F\u3048\u308B\u9AD8\u3055 - \u884C\u306E\u9AD8\u3055 * data.length) / 2 + \u884C\u306E\u9AD8\u3055 / 2;
12506
+ const \u958B\u304D = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
12507
+ const \u5207\u308A\u629C\u304Did = `cdl-radial-draw-${useId().replace(/[^A-Za-z0-9_-]/g, "")}`;
12508
+ const \u53D6\u308A\u5206\u305F\u3061 = rings.map(
12509
+ (r, idx) => r.\u53D6\u308A\u5206 === null ? null : /* @__PURE__ */ jsx(
12510
+ "path",
12511
+ {
12512
+ "data-cdl-role": "chart-radial-arc",
12513
+ "data-cdl-unresolved": r.d.unresolved ? "true" : void 0,
12514
+ d: r.\u53D6\u308A\u5206,
12515
+ fill: arcColor2(r.d.tone, idx)
12516
+ },
12517
+ `arc-${idx}`
12518
+ )
12519
+ );
12495
12520
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
12496
12521
  /* @__PURE__ */ jsx(
12497
12522
  "rect",
@@ -12517,18 +12542,8 @@ function ChartRadialNode({
12517
12542
  },
12518
12543
  `track-${idx}`
12519
12544
  )),
12520
- rings.map(
12521
- (r, idx) => r.\u53D6\u308A\u5206 === null ? null : /* @__PURE__ */ jsx(
12522
- "path",
12523
- {
12524
- "data-cdl-role": "chart-radial-arc",
12525
- "data-cdl-unresolved": r.d.unresolved ? "true" : void 0,
12526
- d: r.\u53D6\u308A\u5206,
12527
- fill: arcColor2(r.d.tone, idx)
12528
- },
12529
- `arc-${idx}`
12530
- )
12531
- ),
12545
+ drawing && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: \u5207\u308A\u629C\u304Did, children: \u6247\u5F62\u306E\u5207\u308A\u629C\u304D(\u5F27\u306Ecx, cy, \u5916\u534A\u5F84 + \u5E2F\u306E\u5E45, \u958B\u304D) }) }),
12546
+ drawing ? /* @__PURE__ */ jsx("g", { clipPath: `url(#${\u5207\u308A\u629C\u304Did})`, children: \u53D6\u308A\u5206\u305F\u3061 }) : \u53D6\u308A\u5206\u305F\u3061,
12532
12547
  data.map((d, idx) => {
12533
12548
  const y = \u4E00\u89A7\u306E\u59CB\u307E\u308A + \u884C\u306E\u9AD8\u3055 * idx;
12534
12549
  return /* @__PURE__ */ jsxs("g", { "data-cdl-role": "chart-radial-item", children: [
@@ -12851,7 +12866,9 @@ var SLICE_MIN_W_FOR_VALUE = 84;
12851
12866
  function ChartStackedBarNode({
12852
12867
  node,
12853
12868
  active,
12854
- stateValues = {}
12869
+ stateValues = {},
12870
+ drawing = false,
12871
+ progress = 1
12855
12872
  }) {
12856
12873
  const x0 = node.cx - node.w / 2;
12857
12874
  const y0 = node.cy - node.h / 2;
@@ -12869,6 +12886,8 @@ function ChartStackedBarNode({
12869
12886
  const \u4E00\u89A7\u306E\u9AD8\u3055 = 26;
12870
12887
  const \u5168\u4F53\u306E\u9AD8\u3055 = \u5E2F\u305F\u3061.length * \u5E2F\u306E\u9AD8\u3055 + (\u5E2F\u305F\u3061.length - 1) * \u5E2F\u306E\u9593 + 16 + \u4E00\u89A7\u306E\u9AD8\u3055;
12871
12888
  const \u4E0A\u7AEF = Math.max(PAD, (node.h - \u5168\u4F53\u306E\u9AD8\u3055) / 2);
12889
+ const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
12890
+ const \u5207\u308A\u629C\u304Did = `cdl-stacked-bar-draw-${useId().replace(/[^A-Za-z0-9_-]/g, "")}`;
12872
12891
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
12873
12892
  /* @__PURE__ */ jsx(
12874
12893
  "rect",
@@ -12884,6 +12903,7 @@ function ChartStackedBarNode({
12884
12903
  strokeWidth: active ? 3 : 1.25
12885
12904
  }
12886
12905
  ),
12906
+ drawing && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: \u5207\u308A\u629C\u304Did, children: /* @__PURE__ */ jsx("rect", { x: 0, y: 0, width: \u5E2F\u306E\u5DE6 + \u5E2F\u306E\u5E45 * \u4F38\u3073, height: node.h }) }) }),
12887
12907
  \u5E2F\u305F\u3061.map((\u5E2F, \u6BB5) => {
12888
12908
  const y = \u4E0A\u7AEF + \u6BB5 * (\u5E2F\u306E\u9AD8\u3055 + \u5E2F\u306E\u9593);
12889
12909
  let \u5DE6 = \u5E2F\u306E\u5DE6;
@@ -12900,68 +12920,62 @@ function ChartStackedBarNode({
12900
12920
  children: \u5E2F.\u540D\u524D
12901
12921
  }
12902
12922
  ),
12903
- \u5E2F.\u533A\u753B.map((s, idx) => {
12904
- const w = \u5E2F\u306E\u5E45 * s.\u5272\u5408;
12905
- const x = \u5DE6;
12906
- \u5DE6 += w;
12907
- const \u8272 = \u5370\u306E\u82723(s.tone, idx);
12908
- return /* @__PURE__ */ jsxs("g", { children: [
12909
- /* @__PURE__ */ jsx(
12910
- "rect",
12911
- {
12912
- "data-cdl-role": "chart-stacked-bar-slice",
12913
- "data-cdl-unresolved": s.unresolved ? "true" : void 0,
12914
- x,
12915
- y,
12916
- width: Math.max(0, w),
12917
- height: \u5E2F\u306E\u9AD8\u3055,
12918
- fill: \u8272
12919
- }
12920
- ),
12921
- w >= SLICE_MIN_W_FOR_TEXT && /* @__PURE__ */ jsx(
12922
- "text",
12923
- {
12924
- "data-cdl-role": "chart-stacked-bar-slice-text",
12925
- x: x + w / 2,
12926
- y: y + \u5E2F\u306E\u9AD8\u3055 / 2 + (w >= SLICE_MIN_W_FOR_VALUE ? -2 : 4),
12927
- fontSize: \u533A\u753B\u306E\u7D1A,
12928
- fontWeight: 700,
12929
- textAnchor: "middle",
12930
- fill: "#ffffff",
12931
- children: \u5272\u5408\u8868\u8A18(s.\u5272\u5408)
12932
- }
12933
- ),
12934
- w >= SLICE_MIN_W_FOR_VALUE && /* @__PURE__ */ jsx(
12935
- "text",
12936
- {
12937
- "data-cdl-role": "chart-stacked-bar-slice-value",
12938
- x: x + w / 2,
12939
- y: y + \u5E2F\u306E\u9AD8\u3055 / 2 + 13,
12940
- fontSize: \u533A\u753B\u306E\u7D1A - 1,
12941
- textAnchor: "middle",
12942
- fill: "#ffffff",
12943
- fillOpacity: 0.85,
12944
- children: \u5B9F\u5024\u8868\u8A18(s.\u5B9F\u5024)
12945
- }
12946
- )
12947
- ] }, `slice-${idx}`);
12948
- })
12923
+ (() => {
12924
+ const \u533A\u753B\u305F\u3061 = \u5E2F.\u533A\u753B.map((s, idx) => {
12925
+ const w = \u5E2F\u306E\u5E45 * s.\u5272\u5408;
12926
+ const x = \u5DE6;
12927
+ \u5DE6 += w;
12928
+ const \u8272 = \u5370\u306E\u82723(s.tone, idx);
12929
+ return /* @__PURE__ */ jsxs("g", { children: [
12930
+ /* @__PURE__ */ jsx(
12931
+ "rect",
12932
+ {
12933
+ "data-cdl-role": "chart-stacked-bar-slice",
12934
+ "data-cdl-unresolved": s.unresolved ? "true" : void 0,
12935
+ x,
12936
+ y,
12937
+ width: Math.max(0, w),
12938
+ height: \u5E2F\u306E\u9AD8\u3055,
12939
+ fill: \u8272
12940
+ }
12941
+ ),
12942
+ w >= SLICE_MIN_W_FOR_TEXT && /* @__PURE__ */ jsx(
12943
+ "text",
12944
+ {
12945
+ "data-cdl-role": "chart-stacked-bar-slice-text",
12946
+ x: x + w / 2,
12947
+ y: y + \u5E2F\u306E\u9AD8\u3055 / 2 + (w >= SLICE_MIN_W_FOR_VALUE ? -2 : 4),
12948
+ fontSize: \u533A\u753B\u306E\u7D1A,
12949
+ fontWeight: 700,
12950
+ textAnchor: "middle",
12951
+ fill: "#ffffff",
12952
+ children: \u5272\u5408\u8868\u8A18(s.\u5272\u5408)
12953
+ }
12954
+ ),
12955
+ w >= SLICE_MIN_W_FOR_VALUE && /* @__PURE__ */ jsx(
12956
+ "text",
12957
+ {
12958
+ "data-cdl-role": "chart-stacked-bar-slice-value",
12959
+ x: x + w / 2,
12960
+ y: y + \u5E2F\u306E\u9AD8\u3055 / 2 + 13,
12961
+ fontSize: \u533A\u753B\u306E\u7D1A - 1,
12962
+ textAnchor: "middle",
12963
+ fill: "#ffffff",
12964
+ fillOpacity: 0.85,
12965
+ children: \u5B9F\u5024\u8868\u8A18(s.\u5B9F\u5024)
12966
+ }
12967
+ )
12968
+ ] }, `slice-${idx}`);
12969
+ });
12970
+ return drawing ? /* @__PURE__ */ jsx("g", { clipPath: `url(#${\u5207\u308A\u629C\u304Did})`, children: \u533A\u753B\u305F\u3061 }) : \u533A\u753B\u305F\u3061;
12971
+ })()
12949
12972
  ] }, `bar-${\u6BB5}`);
12950
12973
  }),
12951
12974
  \u4E00\u89A7\u306E\u4E26\u3073(data, \u5E2F\u306E\u5DE6, node.w - PAD, \u540D\u524D\u306E\u7D1A).map(({ d, idx, x, \u884C }) => {
12952
12975
  const y = \u4E0A\u7AEF + \u5E2F\u305F\u3061.length * (\u5E2F\u306E\u9AD8\u3055 + \u5E2F\u306E\u9593) - \u5E2F\u306E\u9593 + 16 + \u4E00\u89A7\u306E\u9AD8\u3055 / 2 + \u884C * \u4E00\u89A7\u306E\u9AD8\u3055;
12953
12976
  return /* @__PURE__ */ jsxs("g", { "data-cdl-role": "chart-stacked-bar-legend", children: [
12954
12977
  /* @__PURE__ */ jsx("rect", { x, y: y - 5, width: 10, height: 10, rx: 2, fill: \u5370\u306E\u82723(d.tone, idx) }),
12955
- /* @__PURE__ */ jsx(
12956
- "text",
12957
- {
12958
- x: x + 16,
12959
- y: y + 4,
12960
- fontSize: \u540D\u524D\u306E\u7D1A,
12961
- fill: "var(--cdl-text, #1a1f2a)",
12962
- children: d.label
12963
- }
12964
- )
12978
+ /* @__PURE__ */ jsx("text", { x: x + 16, y: y + 4, fontSize: \u540D\u524D\u306E\u7D1A, fill: "var(--cdl-text, #1a1f2a)", children: d.label })
12965
12979
  ] }, `legend-${idx}`);
12966
12980
  })
12967
12981
  ] });
@@ -17922,9 +17936,27 @@ function CdlNodeView({
17922
17936
  }
17923
17937
  );
17924
17938
  case "chart-gauge":
17925
- return /* @__PURE__ */ jsx(ChartGaugeNode, { node: resolvedNode, active, stateValues });
17939
+ return /* @__PURE__ */ jsx(
17940
+ ChartGaugeNode,
17941
+ {
17942
+ node: resolvedNode,
17943
+ active,
17944
+ stateValues,
17945
+ drawing,
17946
+ progress
17947
+ }
17948
+ );
17926
17949
  case "chart-stacked-bar":
17927
- return /* @__PURE__ */ jsx(ChartStackedBarNode, { node: resolvedNode, active, stateValues });
17950
+ return /* @__PURE__ */ jsx(
17951
+ ChartStackedBarNode,
17952
+ {
17953
+ node: resolvedNode,
17954
+ active,
17955
+ stateValues,
17956
+ drawing,
17957
+ progress
17958
+ }
17959
+ );
17928
17960
  case "chart-slope":
17929
17961
  return /* @__PURE__ */ jsx(
17930
17962
  ChartSlopeNode,
@@ -17941,7 +17973,16 @@ function CdlNodeView({
17941
17973
  case "chart-stat":
17942
17974
  return /* @__PURE__ */ jsx(ChartStatNode, { node: resolvedNode, active, stateValues });
17943
17975
  case "chart-radial":
17944
- return /* @__PURE__ */ jsx(ChartRadialNode, { node: resolvedNode, active, stateValues });
17976
+ return /* @__PURE__ */ jsx(
17977
+ ChartRadialNode,
17978
+ {
17979
+ node: resolvedNode,
17980
+ active,
17981
+ stateValues,
17982
+ drawing,
17983
+ progress
17984
+ }
17985
+ );
17945
17986
  case "chart-bar":
17946
17987
  return /* @__PURE__ */ jsx(
17947
17988
  ChartBarNode,