@cardenelabs/cdl 0.36.0 → 0.38.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 +47 -1
- package/README.md +32 -9
- package/dist/index.cjs +40 -16
- 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 +40 -16
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +40 -16
- 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 +40 -16
- package/dist/react.js.map +1 -1
- package/dist/{render-R7v2bfyz.d.cts → render-BYdmSviQ.d.cts} +19 -8
- package/dist/{render-R7v2bfyz.d.ts → render-BYdmSviQ.d.ts} +19 -8
- package/package.json +1 -1
- package/src/anim/core/timeline.ts +28 -10
- package/src/anim/core/types.ts +12 -0
- package/src/kinds/chart-slope.tsx +52 -8
- package/src/render/stage.tsx +17 -3
- package/src/render.tsx +8 -1
- package/src/types.ts +19 -8
package/dist/react.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-
|
|
2
|
+
export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-BYdmSviQ.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-
|
|
2
|
+
export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-BYdmSviQ.js';
|
package/dist/react.js
CHANGED
|
@@ -64,6 +64,8 @@ var Timeline = class {
|
|
|
64
64
|
rafHandle = null;
|
|
65
65
|
phaseIndex = 0;
|
|
66
66
|
phaseProgress = 0;
|
|
67
|
+
/** 曲線を通す前の進み (cdl#711)。 経過時間そのものの割合で、 描く動きが読む */
|
|
68
|
+
phaseLinearProgress = 0;
|
|
67
69
|
phaseStartedAt = 0;
|
|
68
70
|
status = "idle";
|
|
69
71
|
/**
|
|
@@ -92,12 +94,12 @@ var Timeline = class {
|
|
|
92
94
|
const initial = options.initialPhaseIndex;
|
|
93
95
|
if (initial != null && initial > 0 && initial < phases.length) {
|
|
94
96
|
this.phaseIndex = initial;
|
|
95
|
-
this.
|
|
97
|
+
this.setProgress(1);
|
|
96
98
|
this.status = initial === phases.length - 1 ? "settled" : "paused";
|
|
97
99
|
}
|
|
98
100
|
this.initialState = {
|
|
99
101
|
phaseIndex: this.phaseIndex,
|
|
100
|
-
|
|
102
|
+
phaseLinearProgress: this.phaseLinearProgress,
|
|
101
103
|
status: this.status
|
|
102
104
|
};
|
|
103
105
|
}
|
|
@@ -119,13 +121,14 @@ var Timeline = class {
|
|
|
119
121
|
}
|
|
120
122
|
snapshot() {
|
|
121
123
|
const cached = this.cachedSnapshot;
|
|
122
|
-
if (cached && cached.status === this.status && cached.phaseIndex === this.phaseIndex && cached.phaseProgress === this.phaseProgress && cached.totalPhases === this.phases.length) {
|
|
124
|
+
if (cached && cached.status === this.status && cached.phaseIndex === this.phaseIndex && cached.phaseProgress === this.phaseProgress && cached.phaseLinearProgress === this.phaseLinearProgress && cached.totalPhases === this.phases.length) {
|
|
123
125
|
return cached;
|
|
124
126
|
}
|
|
125
127
|
const next = {
|
|
126
128
|
status: this.status,
|
|
127
129
|
phaseIndex: this.phaseIndex,
|
|
128
130
|
phaseProgress: this.phaseProgress,
|
|
131
|
+
phaseLinearProgress: this.phaseLinearProgress,
|
|
129
132
|
totalPhases: this.phases.length
|
|
130
133
|
};
|
|
131
134
|
this.cachedSnapshot = next;
|
|
@@ -148,7 +151,7 @@ var Timeline = class {
|
|
|
148
151
|
const clamped = Math.max(0, Math.min(this.phases.length - 1, index));
|
|
149
152
|
this.cancelRaf();
|
|
150
153
|
this.phaseIndex = clamped;
|
|
151
|
-
this.
|
|
154
|
+
this.setProgress(1);
|
|
152
155
|
this.status = clamped === this.phases.length - 1 ? "settled" : "paused";
|
|
153
156
|
this.emit();
|
|
154
157
|
}
|
|
@@ -188,14 +191,14 @@ var Timeline = class {
|
|
|
188
191
|
if (this.phaseIndex <= 0) return;
|
|
189
192
|
this.cancelRaf();
|
|
190
193
|
this.phaseIndex -= 1;
|
|
191
|
-
this.
|
|
194
|
+
this.setProgress(1);
|
|
192
195
|
this.status = "paused";
|
|
193
196
|
this.emit();
|
|
194
197
|
}
|
|
195
198
|
reset() {
|
|
196
199
|
this.cancelRaf();
|
|
197
200
|
this.phaseIndex = 0;
|
|
198
|
-
this.
|
|
201
|
+
this.setProgress(0);
|
|
199
202
|
this.status = "idle";
|
|
200
203
|
this.emit();
|
|
201
204
|
}
|
|
@@ -216,7 +219,7 @@ var Timeline = class {
|
|
|
216
219
|
this.subscribers.clear();
|
|
217
220
|
this.status = this.initialState.status;
|
|
218
221
|
this.phaseIndex = this.initialState.phaseIndex;
|
|
219
|
-
this.
|
|
222
|
+
this.setProgress(this.initialState.phaseLinearProgress);
|
|
220
223
|
}
|
|
221
224
|
// ─── internals ───────────────────────────────────────────────
|
|
222
225
|
advancePhase() {
|
|
@@ -252,20 +255,20 @@ var Timeline = class {
|
|
|
252
255
|
}, ms);
|
|
253
256
|
}
|
|
254
257
|
beginPhaseTransition() {
|
|
255
|
-
this.
|
|
258
|
+
this.setProgress(0);
|
|
256
259
|
this.phaseStartedAt = performance.now();
|
|
257
260
|
this.cancelRaf();
|
|
258
261
|
const step = (now) => {
|
|
259
262
|
const duration = this.autoAdvanceMsOverride ?? this.getPhase().durationMs ?? 600;
|
|
260
263
|
const elapsed = now - this.phaseStartedAt;
|
|
261
264
|
const linearT = clamp01(elapsed / duration);
|
|
262
|
-
this.
|
|
265
|
+
this.setProgress(linearT);
|
|
263
266
|
this.emit();
|
|
264
267
|
if (linearT < 1) {
|
|
265
268
|
this.rafHandle = requestAnimationFrame(step);
|
|
266
269
|
return;
|
|
267
270
|
}
|
|
268
|
-
this.
|
|
271
|
+
this.setProgress(1);
|
|
269
272
|
this.emit();
|
|
270
273
|
if (this.status === "playing") {
|
|
271
274
|
if (this.phaseIndex < this.phases.length - 1) {
|
|
@@ -280,6 +283,19 @@ var Timeline = class {
|
|
|
280
283
|
};
|
|
281
284
|
this.rafHandle = requestAnimationFrame(step);
|
|
282
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* 段の進みを 2 つ同時に置く (cdl#711)。
|
|
288
|
+
*
|
|
289
|
+
* **代入する場所を 1 つに閉じる**。 曲げた進みと曲げる前の進みを別々に書くと、
|
|
290
|
+
* どちらかを更新し忘れた経路が「前の段の値のまま」 で残る。
|
|
291
|
+
*
|
|
292
|
+
* 両端 (0 と 1) は曲線を通さず、 そのまま置く。 曲線は差し替えられる欄なので、
|
|
293
|
+
* `easing(1)` が 1 を返す保証がない。 段の始まりと終わりの値は曲線に委ねない。
|
|
294
|
+
*/
|
|
295
|
+
setProgress(linear2) {
|
|
296
|
+
this.phaseLinearProgress = linear2;
|
|
297
|
+
this.phaseProgress = linear2 <= 0 ? 0 : linear2 >= 1 ? 1 : this.easing(linear2);
|
|
298
|
+
}
|
|
283
299
|
cancelRaf() {
|
|
284
300
|
if (this.rafHandle != null) {
|
|
285
301
|
cancelAnimationFrame(this.rafHandle);
|
|
@@ -13026,7 +13042,12 @@ function ChartSlopeNode({
|
|
|
13026
13042
|
const \u4E0A\u7AEF = PAD + (\u524D\u3042\u308A ? \u6642\u70B9\u306E\u7D1A + 12 : 0) + 6;
|
|
13027
13043
|
const \u4E0B\u7AEF = Math.max(\u4E0A\u7AEF + 10, node.h - PAD - 6);
|
|
13028
13044
|
const y\u3092\u53D6\u308B = (v) => \u5C3A\u306E\u5E45 > 0 ? \u4E0B\u7AEF - (v - \u6700\u5C0F) / \u5C3A\u306E\u5E45 * (\u4E0B\u7AEF - \u4E0A\u7AEF) : (\u4E0A\u7AEF + \u4E0B\u7AEF) / 2;
|
|
13029
|
-
const \
|
|
13045
|
+
const \u66F8\u3044\u305F\u5F62 = node.chartSlopeForm;
|
|
13046
|
+
const \u5F62 = \u524D\u3042\u308A && (\u66F8\u3044\u305F\u5F62 === "delta" || \u66F8\u3044\u305F\u5F62 === "rank") ? \u66F8\u3044\u305F\u5F62 : "values";
|
|
13047
|
+
const \u9806\u4F4D\u3092\u53D6\u308B = (v, \u5168\u90E8) => \u5168\u90E8.filter((x) => x > v).length + 1;
|
|
13048
|
+
const \u524D\u306E\u9806\u4F4D = \u7CFB\u5217\u305F\u3061.map((s) => \u9806\u4F4D\u3092\u53D6\u308B(s.\u524D, \u7CFB\u5217\u305F\u3061.map((x) => x.\u524D)));
|
|
13049
|
+
const \u4ECA\u306E\u9806\u4F4D = \u7CFB\u5217\u305F\u3061.map((s) => \u9806\u4F4D\u3092\u53D6\u308B(s.\u4ECA, \u7CFB\u5217\u305F\u3061.map((x) => x.\u4ECA)));
|
|
13050
|
+
const \u6BB5\u306Ey\u3092\u53D6\u308B = (\u9806\u4F4D) => \u7CFB\u5217\u305F\u3061.length > 1 ? \u4E0A\u7AEF + (\u9806\u4F4D - 1) / (\u7CFB\u5217\u305F\u3061.length - 1) * (\u4E0B\u7AEF - \u4E0A\u7AEF) : (\u4E0A\u7AEF + \u4E0B\u7AEF) / 2;
|
|
13030
13051
|
const \u5897\u6E1B\u8868\u8A18 = (\u524D, \u4ECA) => {
|
|
13031
13052
|
const \u5DEE = \u4ECA - \u524D;
|
|
13032
13053
|
return \u5DEE > 0 ? `+${\u5B9F\u5024\u8868\u8A18(\u5DEE)}` : \u5B9F\u5024\u8868\u8A18(\u5DEE);
|
|
@@ -13109,8 +13130,8 @@ function ChartSlopeNode({
|
|
|
13109
13130
|
)
|
|
13110
13131
|
] }),
|
|
13111
13132
|
\u7CFB\u5217\u305F\u3061.map((s, i) => {
|
|
13112
|
-
const \u5DE6y = y\u3092\u53D6\u308B(s.\u524D);
|
|
13113
|
-
const \u53F3y = y\u3092\u53D6\u308B(s.\u4ECA);
|
|
13133
|
+
const \u5DE6y = \u5F62 === "rank" ? \u6BB5\u306Ey\u3092\u53D6\u308B(\u524D\u306E\u9806\u4F4D[i]) : y\u3092\u53D6\u308B(s.\u524D);
|
|
13134
|
+
const \u53F3y = \u5F62 === "rank" ? \u6BB5\u306Ey\u3092\u53D6\u308B(\u4ECA\u306E\u9806\u4F4D[i]) : y\u3092\u53D6\u308B(s.\u4ECA);
|
|
13114
13135
|
const \u672A\u89E3\u6C7A = s.\u672A\u89E3\u6C7A ? "true" : void 0;
|
|
13115
13136
|
return /* @__PURE__ */ jsxs("g", { children: [
|
|
13116
13137
|
\u524D\u3042\u308A && /* @__PURE__ */ jsx(
|
|
@@ -18141,6 +18162,7 @@ function CdlStage({
|
|
|
18141
18162
|
laid,
|
|
18142
18163
|
currentPhase,
|
|
18143
18164
|
progress,
|
|
18165
|
+
drawProgress,
|
|
18144
18166
|
stateValues,
|
|
18145
18167
|
debug,
|
|
18146
18168
|
compact = false,
|
|
@@ -18198,7 +18220,8 @@ function CdlStage({
|
|
|
18198
18220
|
}
|
|
18199
18221
|
return scales;
|
|
18200
18222
|
}, [laid]);
|
|
18201
|
-
const \u63CF\u304F\u9032\u307F =
|
|
18223
|
+
const \u63CF\u304F\u7D20\u306E\u9032\u307F = drawProgress ?? progress;
|
|
18224
|
+
const \u63CF\u304F\u9032\u307F = \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(\u63CF\u304F\u7D20\u306E\u9032\u307F, currentPhase?.drawRatio);
|
|
18202
18225
|
const { lifelineStarts, uniformFooterTop } = useMemo(() => {
|
|
18203
18226
|
const starts = lifelineStartYs(laid.nodes);
|
|
18204
18227
|
return {
|
|
@@ -18377,7 +18400,7 @@ function CdlStage({
|
|
|
18377
18400
|
edge,
|
|
18378
18401
|
active: activeSet.has(edge.id),
|
|
18379
18402
|
drawing: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id),
|
|
18380
|
-
progress,
|
|
18403
|
+
progress: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id) ? \u63CF\u304F\u9032\u307F : progress,
|
|
18381
18404
|
stateValues
|
|
18382
18405
|
},
|
|
18383
18406
|
edge.id
|
|
@@ -27210,6 +27233,7 @@ function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hideMiniP
|
|
|
27210
27233
|
const phaseIdx = focusPhaseId ? laid.phases.findIndex((p) => p.id === focusPhaseId) : state.phaseIndex;
|
|
27211
27234
|
const currentPhase = laid.phases[Math.max(0, phaseIdx)] ?? laid.phases[0];
|
|
27212
27235
|
const progress = reduced ? 1 : state.phaseProgress;
|
|
27236
|
+
const drawProgress = reduced ? 1 : state.phaseLinearProgress;
|
|
27213
27237
|
const baseStateValues = computeStateValues(laid, phaseIdx, progress);
|
|
27214
27238
|
const isInteractive = hasInteractivePrimitives(diagram);
|
|
27215
27239
|
const interactive = useInteractiveIntegration(
|
|
@@ -27251,7 +27275,7 @@ function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hideMiniP
|
|
|
27251
27275
|
}
|
|
27252
27276
|
),
|
|
27253
27277
|
isInteractive && interactive.panel,
|
|
27254
|
-
/* @__PURE__ */ jsx(CdlStage, { laid, currentPhase, progress, stateValues, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
|
|
27278
|
+
/* @__PURE__ */ jsx(CdlStage, { laid, currentPhase, progress, drawProgress, stateValues, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
|
|
27255
27279
|
hideHeader && !hideMiniPhaseIndicator && currentPhase && laid.phases.length > 1 && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 border-t border-[var(--cdl-divider,#d4d4d8)]/40 bg-[var(--cdl-stage-bg,#f1f5f9)]/50 px-3 py-2 text-xs", children: [
|
|
27256
27280
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
27257
27281
|
laid.phases.map((p, i) => /* @__PURE__ */ jsx(
|