@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.cjs
CHANGED
|
@@ -66,6 +66,8 @@ var Timeline = class {
|
|
|
66
66
|
rafHandle = null;
|
|
67
67
|
phaseIndex = 0;
|
|
68
68
|
phaseProgress = 0;
|
|
69
|
+
/** 曲線を通す前の進み (cdl#711)。 経過時間そのものの割合で、 描く動きが読む */
|
|
70
|
+
phaseLinearProgress = 0;
|
|
69
71
|
phaseStartedAt = 0;
|
|
70
72
|
status = "idle";
|
|
71
73
|
/**
|
|
@@ -94,12 +96,12 @@ var Timeline = class {
|
|
|
94
96
|
const initial = options.initialPhaseIndex;
|
|
95
97
|
if (initial != null && initial > 0 && initial < phases.length) {
|
|
96
98
|
this.phaseIndex = initial;
|
|
97
|
-
this.
|
|
99
|
+
this.setProgress(1);
|
|
98
100
|
this.status = initial === phases.length - 1 ? "settled" : "paused";
|
|
99
101
|
}
|
|
100
102
|
this.initialState = {
|
|
101
103
|
phaseIndex: this.phaseIndex,
|
|
102
|
-
|
|
104
|
+
phaseLinearProgress: this.phaseLinearProgress,
|
|
103
105
|
status: this.status
|
|
104
106
|
};
|
|
105
107
|
}
|
|
@@ -121,13 +123,14 @@ var Timeline = class {
|
|
|
121
123
|
}
|
|
122
124
|
snapshot() {
|
|
123
125
|
const cached = this.cachedSnapshot;
|
|
124
|
-
if (cached && cached.status === this.status && cached.phaseIndex === this.phaseIndex && cached.phaseProgress === this.phaseProgress && cached.totalPhases === this.phases.length) {
|
|
126
|
+
if (cached && cached.status === this.status && cached.phaseIndex === this.phaseIndex && cached.phaseProgress === this.phaseProgress && cached.phaseLinearProgress === this.phaseLinearProgress && cached.totalPhases === this.phases.length) {
|
|
125
127
|
return cached;
|
|
126
128
|
}
|
|
127
129
|
const next = {
|
|
128
130
|
status: this.status,
|
|
129
131
|
phaseIndex: this.phaseIndex,
|
|
130
132
|
phaseProgress: this.phaseProgress,
|
|
133
|
+
phaseLinearProgress: this.phaseLinearProgress,
|
|
131
134
|
totalPhases: this.phases.length
|
|
132
135
|
};
|
|
133
136
|
this.cachedSnapshot = next;
|
|
@@ -150,7 +153,7 @@ var Timeline = class {
|
|
|
150
153
|
const clamped = Math.max(0, Math.min(this.phases.length - 1, index));
|
|
151
154
|
this.cancelRaf();
|
|
152
155
|
this.phaseIndex = clamped;
|
|
153
|
-
this.
|
|
156
|
+
this.setProgress(1);
|
|
154
157
|
this.status = clamped === this.phases.length - 1 ? "settled" : "paused";
|
|
155
158
|
this.emit();
|
|
156
159
|
}
|
|
@@ -190,14 +193,14 @@ var Timeline = class {
|
|
|
190
193
|
if (this.phaseIndex <= 0) return;
|
|
191
194
|
this.cancelRaf();
|
|
192
195
|
this.phaseIndex -= 1;
|
|
193
|
-
this.
|
|
196
|
+
this.setProgress(1);
|
|
194
197
|
this.status = "paused";
|
|
195
198
|
this.emit();
|
|
196
199
|
}
|
|
197
200
|
reset() {
|
|
198
201
|
this.cancelRaf();
|
|
199
202
|
this.phaseIndex = 0;
|
|
200
|
-
this.
|
|
203
|
+
this.setProgress(0);
|
|
201
204
|
this.status = "idle";
|
|
202
205
|
this.emit();
|
|
203
206
|
}
|
|
@@ -218,7 +221,7 @@ var Timeline = class {
|
|
|
218
221
|
this.subscribers.clear();
|
|
219
222
|
this.status = this.initialState.status;
|
|
220
223
|
this.phaseIndex = this.initialState.phaseIndex;
|
|
221
|
-
this.
|
|
224
|
+
this.setProgress(this.initialState.phaseLinearProgress);
|
|
222
225
|
}
|
|
223
226
|
// ─── internals ───────────────────────────────────────────────
|
|
224
227
|
advancePhase() {
|
|
@@ -254,20 +257,20 @@ var Timeline = class {
|
|
|
254
257
|
}, ms);
|
|
255
258
|
}
|
|
256
259
|
beginPhaseTransition() {
|
|
257
|
-
this.
|
|
260
|
+
this.setProgress(0);
|
|
258
261
|
this.phaseStartedAt = performance.now();
|
|
259
262
|
this.cancelRaf();
|
|
260
263
|
const step = (now) => {
|
|
261
264
|
const duration = this.autoAdvanceMsOverride ?? this.getPhase().durationMs ?? 600;
|
|
262
265
|
const elapsed = now - this.phaseStartedAt;
|
|
263
266
|
const linearT = clamp01(elapsed / duration);
|
|
264
|
-
this.
|
|
267
|
+
this.setProgress(linearT);
|
|
265
268
|
this.emit();
|
|
266
269
|
if (linearT < 1) {
|
|
267
270
|
this.rafHandle = requestAnimationFrame(step);
|
|
268
271
|
return;
|
|
269
272
|
}
|
|
270
|
-
this.
|
|
273
|
+
this.setProgress(1);
|
|
271
274
|
this.emit();
|
|
272
275
|
if (this.status === "playing") {
|
|
273
276
|
if (this.phaseIndex < this.phases.length - 1) {
|
|
@@ -282,6 +285,19 @@ var Timeline = class {
|
|
|
282
285
|
};
|
|
283
286
|
this.rafHandle = requestAnimationFrame(step);
|
|
284
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* 段の進みを 2 つ同時に置く (cdl#711)。
|
|
290
|
+
*
|
|
291
|
+
* **代入する場所を 1 つに閉じる**。 曲げた進みと曲げる前の進みを別々に書くと、
|
|
292
|
+
* どちらかを更新し忘れた経路が「前の段の値のまま」 で残る。
|
|
293
|
+
*
|
|
294
|
+
* 両端 (0 と 1) は曲線を通さず、 そのまま置く。 曲線は差し替えられる欄なので、
|
|
295
|
+
* `easing(1)` が 1 を返す保証がない。 段の始まりと終わりの値は曲線に委ねない。
|
|
296
|
+
*/
|
|
297
|
+
setProgress(linear2) {
|
|
298
|
+
this.phaseLinearProgress = linear2;
|
|
299
|
+
this.phaseProgress = linear2 <= 0 ? 0 : linear2 >= 1 ? 1 : this.easing(linear2);
|
|
300
|
+
}
|
|
285
301
|
cancelRaf() {
|
|
286
302
|
if (this.rafHandle != null) {
|
|
287
303
|
cancelAnimationFrame(this.rafHandle);
|
|
@@ -13028,7 +13044,12 @@ function ChartSlopeNode({
|
|
|
13028
13044
|
const \u4E0A\u7AEF = PAD + (\u524D\u3042\u308A ? \u6642\u70B9\u306E\u7D1A + 12 : 0) + 6;
|
|
13029
13045
|
const \u4E0B\u7AEF = Math.max(\u4E0A\u7AEF + 10, node.h - PAD - 6);
|
|
13030
13046
|
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;
|
|
13031
|
-
const \
|
|
13047
|
+
const \u66F8\u3044\u305F\u5F62 = node.chartSlopeForm;
|
|
13048
|
+
const \u5F62 = \u524D\u3042\u308A && (\u66F8\u3044\u305F\u5F62 === "delta" || \u66F8\u3044\u305F\u5F62 === "rank") ? \u66F8\u3044\u305F\u5F62 : "values";
|
|
13049
|
+
const \u9806\u4F4D\u3092\u53D6\u308B = (v, \u5168\u90E8) => \u5168\u90E8.filter((x) => x > v).length + 1;
|
|
13050
|
+
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)));
|
|
13051
|
+
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)));
|
|
13052
|
+
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;
|
|
13032
13053
|
const \u5897\u6E1B\u8868\u8A18 = (\u524D, \u4ECA) => {
|
|
13033
13054
|
const \u5DEE = \u4ECA - \u524D;
|
|
13034
13055
|
return \u5DEE > 0 ? `+${\u5B9F\u5024\u8868\u8A18(\u5DEE)}` : \u5B9F\u5024\u8868\u8A18(\u5DEE);
|
|
@@ -13111,8 +13132,8 @@ function ChartSlopeNode({
|
|
|
13111
13132
|
)
|
|
13112
13133
|
] }),
|
|
13113
13134
|
\u7CFB\u5217\u305F\u3061.map((s, i) => {
|
|
13114
|
-
const \u5DE6y = y\u3092\u53D6\u308B(s.\u524D);
|
|
13115
|
-
const \u53F3y = y\u3092\u53D6\u308B(s.\u4ECA);
|
|
13135
|
+
const \u5DE6y = \u5F62 === "rank" ? \u6BB5\u306Ey\u3092\u53D6\u308B(\u524D\u306E\u9806\u4F4D[i]) : y\u3092\u53D6\u308B(s.\u524D);
|
|
13136
|
+
const \u53F3y = \u5F62 === "rank" ? \u6BB5\u306Ey\u3092\u53D6\u308B(\u4ECA\u306E\u9806\u4F4D[i]) : y\u3092\u53D6\u308B(s.\u4ECA);
|
|
13116
13137
|
const \u672A\u89E3\u6C7A = s.\u672A\u89E3\u6C7A ? "true" : void 0;
|
|
13117
13138
|
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
13118
13139
|
\u524D\u3042\u308A && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -18143,6 +18164,7 @@ function CdlStage({
|
|
|
18143
18164
|
laid,
|
|
18144
18165
|
currentPhase,
|
|
18145
18166
|
progress,
|
|
18167
|
+
drawProgress,
|
|
18146
18168
|
stateValues,
|
|
18147
18169
|
debug,
|
|
18148
18170
|
compact = false,
|
|
@@ -18200,7 +18222,8 @@ function CdlStage({
|
|
|
18200
18222
|
}
|
|
18201
18223
|
return scales;
|
|
18202
18224
|
}, [laid]);
|
|
18203
|
-
const \u63CF\u304F\u9032\u307F =
|
|
18225
|
+
const \u63CF\u304F\u7D20\u306E\u9032\u307F = drawProgress ?? progress;
|
|
18226
|
+
const \u63CF\u304F\u9032\u307F = \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(\u63CF\u304F\u7D20\u306E\u9032\u307F, currentPhase?.drawRatio);
|
|
18204
18227
|
const { lifelineStarts, uniformFooterTop } = react.useMemo(() => {
|
|
18205
18228
|
const starts = lifelineStartYs(laid.nodes);
|
|
18206
18229
|
return {
|
|
@@ -18379,7 +18402,7 @@ function CdlStage({
|
|
|
18379
18402
|
edge,
|
|
18380
18403
|
active: activeSet.has(edge.id),
|
|
18381
18404
|
drawing: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id),
|
|
18382
|
-
progress,
|
|
18405
|
+
progress: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id) ? \u63CF\u304F\u9032\u307F : progress,
|
|
18383
18406
|
stateValues
|
|
18384
18407
|
},
|
|
18385
18408
|
edge.id
|
|
@@ -27212,6 +27235,7 @@ function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hideMiniP
|
|
|
27212
27235
|
const phaseIdx = focusPhaseId ? laid.phases.findIndex((p) => p.id === focusPhaseId) : state.phaseIndex;
|
|
27213
27236
|
const currentPhase = laid.phases[Math.max(0, phaseIdx)] ?? laid.phases[0];
|
|
27214
27237
|
const progress = reduced ? 1 : state.phaseProgress;
|
|
27238
|
+
const drawProgress = reduced ? 1 : state.phaseLinearProgress;
|
|
27215
27239
|
const baseStateValues = computeStateValues(laid, phaseIdx, progress);
|
|
27216
27240
|
const isInteractive = hasInteractivePrimitives(diagram);
|
|
27217
27241
|
const interactive = useInteractiveIntegration(
|
|
@@ -27253,7 +27277,7 @@ function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hideMiniP
|
|
|
27253
27277
|
}
|
|
27254
27278
|
),
|
|
27255
27279
|
isInteractive && interactive.panel,
|
|
27256
|
-
/* @__PURE__ */ jsxRuntime.jsx(CdlStage, { laid, currentPhase, progress, stateValues, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
|
|
27280
|
+
/* @__PURE__ */ jsxRuntime.jsx(CdlStage, { laid, currentPhase, progress, drawProgress, stateValues, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
|
|
27257
27281
|
hideHeader && !hideMiniPhaseIndicator && currentPhase && laid.phases.length > 1 && /* @__PURE__ */ jsxRuntime.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: [
|
|
27258
27282
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
27259
27283
|
laid.phases.map((p, i) => /* @__PURE__ */ jsxRuntime.jsx(
|