@cardenelabs/cdl 0.10.0 → 0.11.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 +20 -1
- package/SPEC.md +15 -3
- package/dist/index.cjs +71 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +72 -26
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +71 -25
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +72 -26
- package/dist/react.js.map +1 -1
- package/dist/{render-CH1Qn3Jv.d.cts → render-DwH8v5Mb.d.cts} +9 -2
- package/dist/{render-CH1Qn3Jv.d.ts → render-DwH8v5Mb.d.ts} +9 -2
- package/package.json +1 -1
- package/src/kinds/chart-bar.tsx +49 -12
- package/src/kinds/chart-pie.tsx +80 -15
- package/src/render/nodes.tsx +18 -2
- package/src/types.ts +9 -2
- package/src/validate.ts +18 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as CdlState, f as CdlEventTarget, g as Computed, h as CdlDerivedValue, i as CdlScrollTrigger, L as LaidDiagram, j as CdlDiagramViewProps, k as LaidEdge, l as LaidNode, m as CdlEdge, B as BBox, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-
|
|
2
|
-
export { n as CdlDiagramView, o as CdlEventBinding, p as CdlEventKind, q as CdlFormula, r as CdlPhase, I as InteractiveHandlerMap, s as InteractiveSignalsAccessor, t as LaidLane, u as NODE_KINDS, v as ScrollProgressHandle, w as TONES, x as computeEventBindingKey, y as computeFormulaKey, z as computeInputSignalKey, A as computeScrollTriggerKey, D as computed, F as createInteractiveSignalsAccessor, G as createScrollProgressHandle, H as createScrollProgressSignals, K as hasInteractivePrimitives, M as signal } from './render-
|
|
1
|
+
import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as CdlState, f as CdlEventTarget, g as Computed, h as CdlDerivedValue, i as CdlScrollTrigger, L as LaidDiagram, j as CdlDiagramViewProps, k as LaidEdge, l as LaidNode, m as CdlEdge, B as BBox, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-DwH8v5Mb.cjs';
|
|
2
|
+
export { n as CdlDiagramView, o as CdlEventBinding, p as CdlEventKind, q as CdlFormula, r as CdlPhase, I as InteractiveHandlerMap, s as InteractiveSignalsAccessor, t as LaidLane, u as NODE_KINDS, v as ScrollProgressHandle, w as TONES, x as computeEventBindingKey, y as computeFormulaKey, z as computeInputSignalKey, A as computeScrollTriggerKey, D as computed, F as createInteractiveSignalsAccessor, G as createScrollProgressHandle, H as createScrollProgressSignals, K as hasInteractivePrimitives, M as signal } from './render-DwH8v5Mb.cjs';
|
|
3
3
|
import { JSX } from 'react';
|
|
4
4
|
|
|
5
5
|
declare function effect(fn: () => void | (() => void)): () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as CdlState, f as CdlEventTarget, g as Computed, h as CdlDerivedValue, i as CdlScrollTrigger, L as LaidDiagram, j as CdlDiagramViewProps, k as LaidEdge, l as LaidNode, m as CdlEdge, B as BBox, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-
|
|
2
|
-
export { n as CdlDiagramView, o as CdlEventBinding, p as CdlEventKind, q as CdlFormula, r as CdlPhase, I as InteractiveHandlerMap, s as InteractiveSignalsAccessor, t as LaidLane, u as NODE_KINDS, v as ScrollProgressHandle, w as TONES, x as computeEventBindingKey, y as computeFormulaKey, z as computeInputSignalKey, A as computeScrollTriggerKey, D as computed, F as createInteractiveSignalsAccessor, G as createScrollProgressHandle, H as createScrollProgressSignals, K as hasInteractivePrimitives, M as signal } from './render-
|
|
1
|
+
import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as CdlState, f as CdlEventTarget, g as Computed, h as CdlDerivedValue, i as CdlScrollTrigger, L as LaidDiagram, j as CdlDiagramViewProps, k as LaidEdge, l as LaidNode, m as CdlEdge, B as BBox, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-DwH8v5Mb.js';
|
|
2
|
+
export { n as CdlDiagramView, o as CdlEventBinding, p as CdlEventKind, q as CdlFormula, r as CdlPhase, I as InteractiveHandlerMap, s as InteractiveSignalsAccessor, t as LaidLane, u as NODE_KINDS, v as ScrollProgressHandle, w as TONES, x as computeEventBindingKey, y as computeFormulaKey, z as computeInputSignalKey, A as computeScrollTriggerKey, D as computed, F as createInteractiveSignalsAccessor, G as createScrollProgressHandle, H as createScrollProgressSignals, K as hasInteractivePrimitives, M as signal } from './render-DwH8v5Mb.js';
|
|
3
3
|
import { JSX } from 'react';
|
|
4
4
|
|
|
5
5
|
declare function effect(fn: () => void | (() => void)): () => void;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo, useEffect, useState, useSyncExternalStore, useRef, useCallback, useLayoutEffect } from 'react';
|
|
1
|
+
import { useMemo, useEffect, useState, useSyncExternalStore, useRef, useCallback, useLayoutEffect, useId } from 'react';
|
|
2
2
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
// src/reactive/internal.ts
|
|
@@ -15862,6 +15862,7 @@ function nodeTemplateTexts(node) {
|
|
|
15862
15862
|
|
|
15863
15863
|
// src/validate.ts
|
|
15864
15864
|
var TONES2 = new Set(TONES);
|
|
15865
|
+
var DRAW_KINDS = /* @__PURE__ */ new Set(["chart-line", "chart-bar", "chart-pie"]);
|
|
15865
15866
|
var KINDS = new Set(NODE_KINDS);
|
|
15866
15867
|
var ENG_BANNED = /\b(FUNCTION|STORAGE|EVENT LOG|BALANCES MAPPING|READ|WRITE|EMIT|CALL)\b/;
|
|
15867
15868
|
function validate(diag) {
|
|
@@ -15979,8 +15980,10 @@ function validate(diag) {
|
|
|
15979
15980
|
continue;
|
|
15980
15981
|
}
|
|
15981
15982
|
const kind = diag.nodes.find((n) => n.id === id)?.kind;
|
|
15982
|
-
if (kind
|
|
15983
|
-
warnings.push(
|
|
15983
|
+
if (!DRAW_KINDS.has(String(kind))) {
|
|
15984
|
+
warnings.push(
|
|
15985
|
+
`phase "${p.id}" \u306E draw "${id}" \u306F kind "${kind}" \u3067\u3001 \u8D77\u70B9\u304B\u3089\u63CF\u304F\u52D5\u304D\u3092\u6301\u305F\u306A\u3044 (\u5BFE\u8C61\u306F ${[...DRAW_KINDS].join(" / ")})`
|
|
15986
|
+
);
|
|
15984
15987
|
}
|
|
15985
15988
|
}
|
|
15986
15989
|
for (const t of p.tweens) {
|
|
@@ -21465,8 +21468,11 @@ function ChartLineNode({
|
|
|
21465
21468
|
function ChartPieNode({
|
|
21466
21469
|
node,
|
|
21467
21470
|
active,
|
|
21468
|
-
stateValues = {}
|
|
21471
|
+
stateValues = {},
|
|
21472
|
+
drawing = false,
|
|
21473
|
+
progress = 1
|
|
21469
21474
|
}) {
|
|
21475
|
+
const instanceId = useId().replace(/[^A-Za-z0-9_-]/g, "");
|
|
21470
21476
|
const x0 = node.cx - node.w / 2;
|
|
21471
21477
|
const y0 = node.cy - node.h / 2;
|
|
21472
21478
|
const data = resolveChartData(node.chartData ?? [], stateValues);
|
|
@@ -21479,20 +21485,26 @@ function ChartPieNode({
|
|
|
21479
21485
|
const cx = pieAreaW / 2;
|
|
21480
21486
|
const cy = PAD_TOP + chartAreaH / 2;
|
|
21481
21487
|
let cumAngle = -Math.PI / 2;
|
|
21488
|
+
let cumFrac = 0;
|
|
21482
21489
|
const slices = data.map((d) => {
|
|
21483
21490
|
const frac = d.value / total;
|
|
21484
21491
|
const angle = frac * Math.PI * 2;
|
|
21485
21492
|
const a0 = cumAngle;
|
|
21486
21493
|
const a1 = cumAngle + angle;
|
|
21487
21494
|
cumAngle = a1;
|
|
21495
|
+
const startFrac = cumFrac;
|
|
21496
|
+
cumFrac += frac;
|
|
21488
21497
|
const x1 = cx + radius * Math.cos(a0);
|
|
21489
21498
|
const y1 = cy + radius * Math.sin(a0);
|
|
21490
21499
|
const x2 = cx + radius * Math.cos(a1);
|
|
21491
21500
|
const y2 = cy + radius * Math.sin(a1);
|
|
21492
21501
|
const large = angle > Math.PI ? 1 : 0;
|
|
21493
21502
|
const path = `M ${cx} ${cy} L ${x1} ${y1} A ${radius} ${radius} 0 ${large} 1 ${x2} ${y2} Z`;
|
|
21494
|
-
return { d, frac, path };
|
|
21503
|
+
return { d, frac, path, startFrac };
|
|
21495
21504
|
});
|
|
21505
|
+
const \u958B\u304D = drawing ? Math.min(1, Math.max(0, Number.isFinite(progress) ? progress : 1)) : 1;
|
|
21506
|
+
const \u5207\u308A\u629C\u304Did = `cdl-pie-draw-${instanceId}`;
|
|
21507
|
+
const \u958B\u304D\u59CB\u3081\u305F = (startFrac) => !drawing || \u958B\u304D > startFrac;
|
|
21496
21508
|
const legendX = pieAreaW + 8;
|
|
21497
21509
|
const legendGap = Math.min(28, chartAreaH / Math.max(data.length, 1));
|
|
21498
21510
|
const legendStartY = PAD_TOP + (chartAreaH - legendGap * data.length) / 2 + legendGap / 2;
|
|
@@ -21511,7 +21523,8 @@ function ChartPieNode({
|
|
|
21511
21523
|
strokeWidth: active ? 3 : 1.25
|
|
21512
21524
|
}
|
|
21513
21525
|
),
|
|
21514
|
-
|
|
21526
|
+
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, \u958B\u304D) }) }),
|
|
21527
|
+
/* @__PURE__ */ jsx("g", { ...drawing ? { clipPath: `url(#${\u5207\u308A\u629C\u304Did})` } : {}, children: slices.map((s, idx) => /* @__PURE__ */ jsx(
|
|
21515
21528
|
"path",
|
|
21516
21529
|
{
|
|
21517
21530
|
"data-cdl-role": "chart-pie-slice",
|
|
@@ -21523,8 +21536,8 @@ function ChartPieNode({
|
|
|
21523
21536
|
strokeWidth: 1.5
|
|
21524
21537
|
},
|
|
21525
21538
|
`slice-${idx}`
|
|
21526
|
-
)),
|
|
21527
|
-
slices.map((s, idx) => /* @__PURE__ */ jsxs("g", { transform: `translate(${legendX} ${legendStartY + idx * legendGap})`, children: [
|
|
21539
|
+
)) }),
|
|
21540
|
+
slices.map((s, idx) => !\u958B\u304D\u59CB\u3081\u305F(s.startFrac) ? null : /* @__PURE__ */ jsxs("g", { transform: `translate(${legendX} ${legendStartY + idx * legendGap})`, children: [
|
|
21528
21541
|
/* @__PURE__ */ jsx(
|
|
21529
21542
|
"rect",
|
|
21530
21543
|
{
|
|
@@ -21562,6 +21575,15 @@ function ChartPieNode({
|
|
|
21562
21575
|
] }, `legend-${idx}`))
|
|
21563
21576
|
] });
|
|
21564
21577
|
}
|
|
21578
|
+
function \u6247\u5F62\u306E\u5207\u308A\u629C\u304D(cx, cy, r, \u958B\u304D) {
|
|
21579
|
+
if (\u958B\u304D <= 0) return null;
|
|
21580
|
+
if (\u958B\u304D >= 1) return /* @__PURE__ */ jsx("circle", { cx, cy, r });
|
|
21581
|
+
const a0 = -Math.PI / 2;
|
|
21582
|
+
const a1 = a0 + \u958B\u304D * Math.PI * 2;
|
|
21583
|
+
const large = \u958B\u304D > 0.5 ? 1 : 0;
|
|
21584
|
+
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`;
|
|
21585
|
+
return /* @__PURE__ */ jsx("path", { d });
|
|
21586
|
+
}
|
|
21565
21587
|
var FALLBACK_ORDER = ["accent", "teal", "warning", "success", "info", "error"];
|
|
21566
21588
|
function sliceColor(tone, idx) {
|
|
21567
21589
|
if (tone) return TONE[tone];
|
|
@@ -21570,7 +21592,9 @@ function sliceColor(tone, idx) {
|
|
|
21570
21592
|
function ChartBarNode({
|
|
21571
21593
|
node,
|
|
21572
21594
|
active,
|
|
21573
|
-
stateValues = {}
|
|
21595
|
+
stateValues = {},
|
|
21596
|
+
drawing = false,
|
|
21597
|
+
progress = 1
|
|
21574
21598
|
}) {
|
|
21575
21599
|
const x0 = node.cx - node.w / 2;
|
|
21576
21600
|
const y0 = node.cy - node.h / 2;
|
|
@@ -21593,6 +21617,8 @@ function ChartBarNode({
|
|
|
21593
21617
|
const v = vMax * i / gridCount;
|
|
21594
21618
|
return { y: yAt(v), value: v };
|
|
21595
21619
|
});
|
|
21620
|
+
const \u4F38\u3073 = drawing ? Math.min(1, Math.max(0, Number.isFinite(progress) ? progress : 1)) : 1;
|
|
21621
|
+
const \u6A2A\u8EF8\u306Ey = PAD_TOP + canvasH;
|
|
21596
21622
|
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
|
|
21597
21623
|
/* @__PURE__ */ jsx(
|
|
21598
21624
|
"rect",
|
|
@@ -21649,26 +21675,28 @@ function ChartBarNode({
|
|
|
21649
21675
|
const bx = xAt(idx);
|
|
21650
21676
|
const by = yAt(d.value);
|
|
21651
21677
|
const bh = PAD_TOP + canvasH - by;
|
|
21678
|
+
const \u898B\u3048\u3066\u3044\u308B\u982D = \u6A2A\u8EF8\u306Ey - (\u6A2A\u8EF8\u306Ey - by) * \u4F38\u3073;
|
|
21679
|
+
const \u68D2 = /* @__PURE__ */ jsx(
|
|
21680
|
+
"rect",
|
|
21681
|
+
{
|
|
21682
|
+
"data-cdl-role": "chart-bar",
|
|
21683
|
+
"data-cdl-unresolved": d.unresolved ? "true" : void 0,
|
|
21684
|
+
x: bx,
|
|
21685
|
+
y: by,
|
|
21686
|
+
width: barW,
|
|
21687
|
+
height: bh,
|
|
21688
|
+
rx: 2,
|
|
21689
|
+
fill: "var(--cdl-tone-accent, #2d6a8f)",
|
|
21690
|
+
fillOpacity: 0.9
|
|
21691
|
+
}
|
|
21692
|
+
);
|
|
21652
21693
|
return /* @__PURE__ */ jsxs("g", { children: [
|
|
21653
|
-
/* @__PURE__ */ jsx(
|
|
21654
|
-
"rect",
|
|
21655
|
-
{
|
|
21656
|
-
"data-cdl-role": "chart-bar",
|
|
21657
|
-
"data-cdl-unresolved": d.unresolved ? "true" : void 0,
|
|
21658
|
-
x: bx,
|
|
21659
|
-
y: by,
|
|
21660
|
-
width: barW,
|
|
21661
|
-
height: bh,
|
|
21662
|
-
rx: 2,
|
|
21663
|
-
fill: "var(--cdl-tone-accent, #2d6a8f)",
|
|
21664
|
-
fillOpacity: 0.9
|
|
21665
|
-
}
|
|
21666
|
-
),
|
|
21694
|
+
drawing ? /* @__PURE__ */ jsx("g", { transform: `translate(0 ${\u6A2A\u8EF8\u306Ey}) scale(1 ${\u4F38\u3073}) translate(0 ${-\u6A2A\u8EF8\u306Ey})`, children: \u68D2 }) : \u68D2,
|
|
21667
21695
|
/* @__PURE__ */ jsx(
|
|
21668
21696
|
"text",
|
|
21669
21697
|
{
|
|
21670
21698
|
x: bx + barW / 2,
|
|
21671
|
-
y:
|
|
21699
|
+
y: \u898B\u3048\u3066\u3044\u308B\u982D - 6,
|
|
21672
21700
|
fontSize: 11,
|
|
21673
21701
|
textAnchor: "middle",
|
|
21674
21702
|
fill: "var(--cdl-text, #1a1f2a)",
|
|
@@ -26802,9 +26830,27 @@ function CdlNodeView({
|
|
|
26802
26830
|
}
|
|
26803
26831
|
);
|
|
26804
26832
|
case "chart-pie":
|
|
26805
|
-
return /* @__PURE__ */ jsx(
|
|
26833
|
+
return /* @__PURE__ */ jsx(
|
|
26834
|
+
ChartPieNode,
|
|
26835
|
+
{
|
|
26836
|
+
node: resolvedNode,
|
|
26837
|
+
active,
|
|
26838
|
+
stateValues,
|
|
26839
|
+
drawing,
|
|
26840
|
+
progress
|
|
26841
|
+
}
|
|
26842
|
+
);
|
|
26806
26843
|
case "chart-bar":
|
|
26807
|
-
return /* @__PURE__ */ jsx(
|
|
26844
|
+
return /* @__PURE__ */ jsx(
|
|
26845
|
+
ChartBarNode,
|
|
26846
|
+
{
|
|
26847
|
+
node: resolvedNode,
|
|
26848
|
+
active,
|
|
26849
|
+
stateValues,
|
|
26850
|
+
drawing,
|
|
26851
|
+
progress
|
|
26852
|
+
}
|
|
26853
|
+
);
|
|
26808
26854
|
case "gantt-timeline":
|
|
26809
26855
|
return /* @__PURE__ */ jsx(GanttNode, { node: resolvedNode, active, stateValues });
|
|
26810
26856
|
case "mind-map":
|