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