@statewalker/fsm-charts 0.1.11 → 0.1.13
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/{StateChart-DlcWaRml.d.ts → StateChart-CdOU9XAq.d.ts} +10 -3
- package/dist/{chunk-2OGGKHD6.js → chunk-AVTSJE25.js} +4 -1
- package/dist/{chunk-SURKRLPB.js → chunk-GCVBCAOL.js} +2 -2
- package/dist/{chunk-HQZXOJPG.js → chunk-NWCC4WSF.js} +9 -3
- package/dist/index-config.d.ts +2 -2
- package/dist/index-dom.js +1 -1
- package/dist/{index-html-De8e33ol.d.ts → index-html-BKMwwc5Q.d.ts} +1 -1
- package/dist/index-html.d.ts +2 -2
- package/dist/index-html.js +1 -1
- package/dist/index-layout.d.ts +5 -3
- package/dist/index-layout.js +1 -1
- package/dist/index-runtime.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/src/dom/index.ts +4 -1
- package/src/html/buildStatechartSvg.ts +4 -4
- package/src/layout/getGraphParamsProvider.ts +18 -4
- package/src/types/GraphParamsProvider.ts +5 -5
- package/src/types/Label.ts +7 -0
- package/src/types/index.ts +1 -0
|
@@ -19,12 +19,19 @@ type FsmStateConfig = {
|
|
|
19
19
|
states?: FsmStateConfig[];
|
|
20
20
|
} & Record<string, any>;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Human-readable label
|
|
24
|
+
*/
|
|
25
|
+
type Label = {
|
|
26
|
+
text: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
22
29
|
/**
|
|
23
30
|
* Provides default functions measuring dimensions for state nodes and transition edges in the graph.
|
|
24
31
|
*/
|
|
25
32
|
type GraphParamsProvider = {
|
|
26
|
-
getStateParams: (stateKey: string, state?: string) => Dimensions & Record<string, any>;
|
|
27
|
-
getTransitionParams: (fromStateKey: string, event: string, toStateKey: string) => Dimensions & Record<string, any>;
|
|
33
|
+
getStateParams: (stateKey: string, state?: string) => Dimensions & Label & Record<string, any>;
|
|
34
|
+
getTransitionParams: (fromStateKey: string, event: string, toStateKey: string) => Dimensions & Label & Record<string, any>;
|
|
28
35
|
};
|
|
29
36
|
|
|
30
37
|
/**
|
|
@@ -72,4 +79,4 @@ type StateChart = TransitionsGraph & StateGraphNode & {
|
|
|
72
79
|
children?: StateChart[];
|
|
73
80
|
} & Record<string, any>;
|
|
74
81
|
|
|
75
|
-
export type { Dimensions as D, FsmStateConfig as F, GraphParamsProvider as G, Padding as P, StateChart as S, Transition as T, Position as a, StateGraphEdge as b, StateGraphNode as c, TransitionsGraph as d };
|
|
82
|
+
export type { Dimensions as D, FsmStateConfig as F, GraphParamsProvider as G, Label as L, Padding as P, StateChart as S, Transition as T, Position as a, StateGraphEdge as b, StateGraphNode as c, TransitionsGraph as d };
|
|
@@ -57,9 +57,12 @@ function getStateDescriptionRenderer({
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
function* visitDom(elm) {
|
|
60
|
+
if (isDomElement(elm) && elm.tagName === "TEMPLATE") {
|
|
61
|
+
elm = elm.content;
|
|
62
|
+
}
|
|
60
63
|
for (let node = elm.firstChild; node; node = node.nextSibling) {
|
|
61
64
|
if (isDomElement(node)) {
|
|
62
|
-
if (node.tagName === "DIV") {
|
|
65
|
+
if (node.tagName === "DIV" || node.tagName === "TEMPLATE") {
|
|
63
66
|
yield* visitDom(node);
|
|
64
67
|
} else {
|
|
65
68
|
yield node;
|
|
@@ -422,7 +422,7 @@ function buildStatechartSvg({
|
|
|
422
422
|
fill: "currentColor"
|
|
423
423
|
});
|
|
424
424
|
for (const edge of edges) {
|
|
425
|
-
const { id, points,
|
|
425
|
+
const { id, points, text } = edge;
|
|
426
426
|
println(` <g class="transition" data-transition-id="${id}">`);
|
|
427
427
|
const markerId = newId("marker");
|
|
428
428
|
println(` <defs>`);
|
|
@@ -495,7 +495,7 @@ function buildStatechartSvg({
|
|
|
495
495
|
const finalStateRadius = initialStateRadius / 2;
|
|
496
496
|
println(`<g class="statechart__states">`);
|
|
497
497
|
for (const node of nodes) {
|
|
498
|
-
const { key, id,
|
|
498
|
+
const { key, id, text } = node;
|
|
499
499
|
const { x, y, width: width2, height: height2 } = getBoxParams({ ...node, padding: shift });
|
|
500
500
|
println(` <g class="state" data-state-id="${id}">`);
|
|
501
501
|
if (key === initialStateKey || key === finalStateKey) {
|
|
@@ -2664,18 +2664,22 @@ function getGraphParamsProvider({
|
|
|
2664
2664
|
stateFontSize = fontSize,
|
|
2665
2665
|
stateTextPadding = 0,
|
|
2666
2666
|
transitionsFontSize = fontSize,
|
|
2667
|
-
transitionsTextPadding = 0
|
|
2667
|
+
transitionsTextPadding = 0,
|
|
2668
|
+
getStateLabel = (state) => state,
|
|
2669
|
+
getTransitionLabel = (fromState, event, toState) => event
|
|
2668
2670
|
} = {}) {
|
|
2669
2671
|
return {
|
|
2670
2672
|
getStateParams: (stateKey, state = stateKey) => {
|
|
2671
2673
|
const padding = getPadding(stateTextPadding);
|
|
2672
2674
|
const fontSize2 = stateFontSize;
|
|
2675
|
+
const stateLabel = getStateLabel(state);
|
|
2673
2676
|
return {
|
|
2674
|
-
...getLabelDimensions(
|
|
2677
|
+
...getLabelDimensions(stateLabel, {
|
|
2675
2678
|
padding,
|
|
2676
2679
|
fontSize: fontSize2
|
|
2677
2680
|
}),
|
|
2678
2681
|
state,
|
|
2682
|
+
text: stateLabel,
|
|
2679
2683
|
key: stateKey,
|
|
2680
2684
|
padding,
|
|
2681
2685
|
fontSize: fontSize2
|
|
@@ -2684,14 +2688,16 @@ function getGraphParamsProvider({
|
|
|
2684
2688
|
getTransitionParams: (fromStateKey, event, toStateKey) => {
|
|
2685
2689
|
const padding = getPadding(transitionsTextPadding);
|
|
2686
2690
|
const fontSize2 = transitionsFontSize;
|
|
2691
|
+
const eventLabel = getTransitionLabel(fromStateKey, event, toStateKey);
|
|
2687
2692
|
return {
|
|
2688
|
-
...getLabelDimensions(
|
|
2693
|
+
...getLabelDimensions(eventLabel, {
|
|
2689
2694
|
padding,
|
|
2690
2695
|
fontSize: fontSize2
|
|
2691
2696
|
}),
|
|
2692
2697
|
from: fromStateKey,
|
|
2693
2698
|
event,
|
|
2694
2699
|
to: toStateKey,
|
|
2700
|
+
text: eventLabel,
|
|
2695
2701
|
padding,
|
|
2696
2702
|
fontSize: fontSize2
|
|
2697
2703
|
};
|
package/dist/index-config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as Transition, F as FsmStateConfig } from './StateChart-
|
|
2
|
-
export { D as Dimensions, G as GraphParamsProvider, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, d as TransitionsGraph } from './StateChart-
|
|
1
|
+
import { T as Transition, F as FsmStateConfig } from './StateChart-CdOU9XAq.js';
|
|
2
|
+
export { D as Dimensions, G as GraphParamsProvider, L as Label, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, d as TransitionsGraph } from './StateChart-CdOU9XAq.js';
|
|
3
3
|
|
|
4
4
|
declare function concatTransitionsToString(transitions: Transition[]): string[];
|
|
5
5
|
|
package/dist/index-dom.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { buildSections, findSection, getStateDescriptionRenderer, renderSections, visitDom, visitSectionNodes, vistSections } from './chunk-
|
|
1
|
+
export { buildSections, findSection, getStateDescriptionRenderer, renderSections, visitDom, visitSectionNodes, vistSections } from './chunk-AVTSJE25.js';
|
package/dist/index-html.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, T as Transition, d as TransitionsGraph } from './StateChart-
|
|
2
|
-
export { c as activeStatesStyle, d as activeTransitionsStyle, f as buildStateDetailsStyle, g as buildStateDetailsStyleWithModifier, b as buildStatechartCss, i as buildStatechartStyles, h as buildStatechartStylesWithModifier, j as buildStatechartSvg, a as buildStatechartsPanel, s as selectedStatesStyle, e as selectedTransitionsStyle } from './index-html-
|
|
1
|
+
export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, L as Label, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, T as Transition, d as TransitionsGraph } from './StateChart-CdOU9XAq.js';
|
|
2
|
+
export { c as activeStatesStyle, d as activeTransitionsStyle, f as buildStateDetailsStyle, g as buildStateDetailsStyleWithModifier, b as buildStatechartCss, i as buildStatechartStyles, h as buildStatechartStylesWithModifier, j as buildStatechartSvg, a as buildStatechartsPanel, s as selectedStatesStyle, e as selectedTransitionsStyle } from './index-html-BKMwwc5Q.js';
|
package/dist/index-html.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle } from './chunk-
|
|
1
|
+
export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle } from './chunk-GCVBCAOL.js';
|
|
2
2
|
import './chunk-FIQDLBWD.js';
|
package/dist/index-layout.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as Transition, P as Padding, G as GraphParamsProvider, d as TransitionsGraph, F as FsmStateConfig, S as StateChart } from './StateChart-
|
|
2
|
-
export { D as Dimensions, a as Position, b as StateGraphEdge, c as StateGraphNode } from './StateChart-
|
|
1
|
+
import { T as Transition, P as Padding, G as GraphParamsProvider, d as TransitionsGraph, F as FsmStateConfig, S as StateChart } from './StateChart-CdOU9XAq.js';
|
|
2
|
+
export { D as Dimensions, L as Label, a as Position, b as StateGraphEdge, c as StateGraphNode } from './StateChart-CdOU9XAq.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Build graphs corresponding to the specified transitions.
|
|
@@ -52,12 +52,14 @@ declare function buildCharts({ lodash, config, newId, getStateParams, getTransit
|
|
|
52
52
|
* @param transitionsFontSize - The font size for the transition labels.
|
|
53
53
|
* @param transitionsTextPadding - The padding around the transition labels.
|
|
54
54
|
*/
|
|
55
|
-
declare function getGraphParamsProvider({ fontSize, stateFontSize, stateTextPadding, transitionsFontSize, transitionsTextPadding, }?: {
|
|
55
|
+
declare function getGraphParamsProvider({ fontSize, stateFontSize, stateTextPadding, transitionsFontSize, transitionsTextPadding, getStateLabel, getTransitionLabel, }?: {
|
|
56
56
|
fontSize?: number;
|
|
57
57
|
stateFontSize?: number;
|
|
58
58
|
stateTextPadding?: Padding;
|
|
59
59
|
transitionsFontSize?: number;
|
|
60
60
|
transitionsTextPadding?: Padding;
|
|
61
|
+
getStateLabel?: (state: string) => string;
|
|
62
|
+
getTransitionLabel?: (fromState: string, event: string, toState: string) => string;
|
|
61
63
|
}): GraphParamsProvider;
|
|
62
64
|
|
|
63
65
|
declare function getLabelDimensions(label: string, { padding, fontSize, getCharWidth, // Golden ratio and all that jazz :-)
|
package/dist/index-layout.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-
|
|
1
|
+
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-NWCC4WSF.js';
|
|
2
2
|
import './chunk-FIQDLBWD.js';
|
package/dist/index-runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as StateChart, c as StateGraphNode, b as StateGraphEdge } from './StateChart-
|
|
2
|
-
export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, P as Padding, a as Position, T as Transition, d as TransitionsGraph } from './StateChart-
|
|
1
|
+
import { S as StateChart, c as StateGraphNode, b as StateGraphEdge } from './StateChart-CdOU9XAq.js';
|
|
2
|
+
export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, L as Label, P as Padding, a as Position, T as Transition, d as TransitionsGraph } from './StateChart-CdOU9XAq.js';
|
|
3
3
|
|
|
4
4
|
type RuntimeListener = (id: string) => void;
|
|
5
5
|
declare class RuntimeStatechartApi {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, T as Transition, d as TransitionsGraph } from './StateChart-
|
|
1
|
+
export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, L as Label, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, T as Transition, d as TransitionsGraph } from './StateChart-CdOU9XAq.js';
|
|
2
2
|
export { DomSection, buildSections, findSection, getStateDescriptionRenderer, renderSections, visitDom, visitSectionNodes, vistSections } from './index-dom.js';
|
|
3
3
|
export { concatTransitionsToString, serializeProcessConfig, splitTransitionString, toFsmStateConfig } from './index-config.js';
|
|
4
4
|
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './index-layout.js';
|
|
5
|
-
export { C as CssTree, c as activeStatesStyle, d as activeTransitionsStyle, f as buildStateDetailsStyle, g as buildStateDetailsStyleWithModifier, b as buildStatechartCss, i as buildStatechartStyles, h as buildStatechartStylesWithModifier, j as buildStatechartSvg, a as buildStatechartsPanel, s as selectedStatesStyle, e as selectedTransitionsStyle, k as serializeCss } from './index-html-
|
|
5
|
+
export { C as CssTree, c as activeStatesStyle, d as activeTransitionsStyle, f as buildStateDetailsStyle, g as buildStateDetailsStyleWithModifier, b as buildStatechartCss, i as buildStatechartStyles, h as buildStatechartStylesWithModifier, j as buildStatechartSvg, a as buildStatechartsPanel, s as selectedStatesStyle, e as selectedTransitionsStyle, k as serializeCss } from './index-html-BKMwwc5Q.js';
|
|
6
6
|
export { RuntimeListener, RuntimeStatechartApi, StateChartIndex } from './index-runtime.js';
|
|
7
7
|
|
|
8
8
|
declare function toKebabCase(str?: string): string;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { concatTransitionsToString, serializeProcessConfig, splitTransitionString, toFsmStateConfig } from './chunk-SVKVQY7B.js';
|
|
2
|
-
export { buildSections, findSection, getStateDescriptionRenderer, renderSections, visitDom, visitSectionNodes, vistSections } from './chunk-
|
|
3
|
-
export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle, serializeCss, toKebabCase } from './chunk-
|
|
4
|
-
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-
|
|
2
|
+
export { buildSections, findSection, getStateDescriptionRenderer, renderSections, visitDom, visitSectionNodes, vistSections } from './chunk-AVTSJE25.js';
|
|
3
|
+
export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle, serializeCss, toKebabCase } from './chunk-GCVBCAOL.js';
|
|
4
|
+
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-NWCC4WSF.js';
|
|
5
5
|
import './chunk-FIQDLBWD.js';
|
|
6
6
|
export { RuntimeStatechartApi, StateChartIndex } from './chunk-N77KKO5K.js';
|
package/package.json
CHANGED
package/src/dom/index.ts
CHANGED
|
@@ -90,9 +90,12 @@ export function getStateDescriptionRenderer({
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export function* visitDom(elm: Node): Iterable<Node> {
|
|
93
|
+
if (isDomElement(elm) && elm.tagName === "TEMPLATE") {
|
|
94
|
+
elm = (elm as HTMLTemplateElement).content;
|
|
95
|
+
}
|
|
93
96
|
for (let node = elm.firstChild; node; node = node.nextSibling) {
|
|
94
97
|
if (isDomElement(node)) {
|
|
95
|
-
if (node.tagName === "DIV") {
|
|
98
|
+
if (node.tagName === "DIV" || node.tagName === "TEMPLATE") {
|
|
96
99
|
yield* visitDom(node);
|
|
97
100
|
} else {
|
|
98
101
|
yield node;
|
|
@@ -51,7 +51,7 @@ export function buildStatechartSvg({
|
|
|
51
51
|
height,
|
|
52
52
|
viewbox: `0 0 ${width} ${height}`,
|
|
53
53
|
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
-
})}
|
|
54
|
+
})}>`,
|
|
55
55
|
);
|
|
56
56
|
|
|
57
57
|
/*
|
|
@@ -79,7 +79,7 @@ export function buildStatechartSvg({
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
for (const edge of edges) {
|
|
82
|
-
const { id, points,
|
|
82
|
+
const { id, points, text } = edge;
|
|
83
83
|
println(` <g class="transition" data-transition-id="${id}">`);
|
|
84
84
|
const markerId = newId("marker");
|
|
85
85
|
|
|
@@ -98,7 +98,7 @@ export function buildStatechartSvg({
|
|
|
98
98
|
x1: number,
|
|
99
99
|
y1: number,
|
|
100
100
|
x2: number,
|
|
101
|
-
y2: number
|
|
101
|
+
y2: number,
|
|
102
102
|
) {
|
|
103
103
|
path.push("C" + round(x0, y0, x1, y1, x2, y2).join(","));
|
|
104
104
|
},
|
|
@@ -181,7 +181,7 @@ export function buildStatechartSvg({
|
|
|
181
181
|
|
|
182
182
|
println(`<g class="statechart__states">`);
|
|
183
183
|
for (const node of nodes) {
|
|
184
|
-
const { key, id,
|
|
184
|
+
const { key, id, text } = node;
|
|
185
185
|
const { x, y, width, height } = getBoxParams({ ...node, padding: shift });
|
|
186
186
|
|
|
187
187
|
println(` <g class="state" data-state-id="${id}">`);
|
|
@@ -4,6 +4,7 @@ import type { Padding } from "../types/Padding.ts";
|
|
|
4
4
|
|
|
5
5
|
import { getLabelDimensions } from "./getLabelDimensions.ts";
|
|
6
6
|
import { getPadding } from "../utils/getPadding.ts";
|
|
7
|
+
import { Label } from "../types/Label.ts";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Provides default functions measuring dimensions for state nodes and transition edges in the graph.
|
|
@@ -19,23 +20,34 @@ export function getGraphParamsProvider({
|
|
|
19
20
|
stateTextPadding = 0,
|
|
20
21
|
transitionsFontSize = fontSize,
|
|
21
22
|
transitionsTextPadding = 0,
|
|
23
|
+
getStateLabel = (state: string) => state,
|
|
24
|
+
getTransitionLabel = (fromState: string, event: string, toState: string) =>
|
|
25
|
+
event,
|
|
22
26
|
}: {
|
|
23
27
|
fontSize?: number;
|
|
24
28
|
stateFontSize?: number;
|
|
25
29
|
stateTextPadding?: Padding;
|
|
26
30
|
transitionsFontSize?: number;
|
|
27
31
|
transitionsTextPadding?: Padding;
|
|
32
|
+
getStateLabel?: (state: string) => string;
|
|
33
|
+
getTransitionLabel?: (
|
|
34
|
+
fromState: string,
|
|
35
|
+
event: string,
|
|
36
|
+
toState: string,
|
|
37
|
+
) => string;
|
|
28
38
|
} = {}): GraphParamsProvider {
|
|
29
39
|
return {
|
|
30
40
|
getStateParams: (stateKey: string, state: string = stateKey) => {
|
|
31
41
|
const padding = getPadding(stateTextPadding);
|
|
32
42
|
const fontSize = stateFontSize;
|
|
43
|
+
const stateLabel = getStateLabel(state);
|
|
33
44
|
return {
|
|
34
|
-
...getLabelDimensions(
|
|
45
|
+
...getLabelDimensions(stateLabel, {
|
|
35
46
|
padding,
|
|
36
47
|
fontSize,
|
|
37
48
|
}),
|
|
38
49
|
state,
|
|
50
|
+
text: stateLabel,
|
|
39
51
|
key: stateKey,
|
|
40
52
|
padding,
|
|
41
53
|
fontSize,
|
|
@@ -44,18 +56,20 @@ export function getGraphParamsProvider({
|
|
|
44
56
|
getTransitionParams: (
|
|
45
57
|
fromStateKey: string,
|
|
46
58
|
event: string,
|
|
47
|
-
toStateKey: string
|
|
48
|
-
)
|
|
59
|
+
toStateKey: string,
|
|
60
|
+
) => {
|
|
49
61
|
const padding = getPadding(transitionsTextPadding);
|
|
50
62
|
const fontSize = transitionsFontSize;
|
|
63
|
+
const eventLabel = getTransitionLabel(fromStateKey, event, toStateKey);
|
|
51
64
|
return {
|
|
52
|
-
...getLabelDimensions(
|
|
65
|
+
...getLabelDimensions(eventLabel, {
|
|
53
66
|
padding,
|
|
54
67
|
fontSize,
|
|
55
68
|
}),
|
|
56
69
|
from: fromStateKey,
|
|
57
70
|
event,
|
|
58
71
|
to: toStateKey,
|
|
72
|
+
text: eventLabel,
|
|
59
73
|
padding,
|
|
60
74
|
fontSize,
|
|
61
75
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Dimensions } from "./Dimensions.ts";
|
|
2
|
+
import { Label } from "./Label.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Provides default functions measuring dimensions for state nodes and transition edges in the graph.
|
|
@@ -6,12 +7,11 @@ import type { Dimensions } from "./Dimensions.ts";
|
|
|
6
7
|
export type GraphParamsProvider = {
|
|
7
8
|
getStateParams: (
|
|
8
9
|
stateKey: string,
|
|
9
|
-
state?: string
|
|
10
|
-
) => Dimensions & Record<string, any>;
|
|
10
|
+
state?: string,
|
|
11
|
+
) => Dimensions & Label & Record<string, any>;
|
|
11
12
|
getTransitionParams: (
|
|
12
13
|
fromStateKey: string,
|
|
13
14
|
event: string,
|
|
14
|
-
toStateKey: string
|
|
15
|
-
) => Dimensions & Record<string, any>;
|
|
15
|
+
toStateKey: string,
|
|
16
|
+
) => Dimensions & Label & Record<string, any>;
|
|
16
17
|
};
|
|
17
|
-
|
package/src/types/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type * from "./Dimensions.ts";
|
|
2
2
|
export type * from "./FsmStateConfig.ts";
|
|
3
3
|
export type * from "./GraphParamsProvider.ts";
|
|
4
|
+
export type * from "./Label.ts";
|
|
4
5
|
export type * from "./Padding.ts";
|
|
5
6
|
export type * from "./Position.ts";
|
|
6
7
|
export type * from "./StateChart.ts";
|