@statewalker/fsm-charts 0.1.2 → 0.1.3
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/{chunk-UBYXED35.js → chunk-4KTXTN7J.js} +4 -6
- package/dist/{chunk-ZSGS37QH.js → chunk-OTGN3OYG.js} +14 -7
- package/dist/index-layout.js +1 -1
- package/dist/index-runtime.d.ts +2 -2
- package/dist/index-runtime.js +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/layout/buildFlatCharts.ts +13 -8
- package/src/runtime/RuntimeStatechartApi.ts +3 -3
- package/src/runtime/StateChartIndex.ts +1 -2
|
@@ -28,10 +28,10 @@ var RuntimeStatechartApi = class {
|
|
|
28
28
|
onTransitionClick(listener) {
|
|
29
29
|
return this._addListener(this._transitionsClickListeners, listener);
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
openStatePanels() {
|
|
32
32
|
this._setStatePanelStatus(`details[data-state-id]`, true);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
closeStatePanels() {
|
|
35
35
|
this._setStatePanelStatus(`details[data-state-id]`, false);
|
|
36
36
|
}
|
|
37
37
|
isStatePanelOpen(stateId) {
|
|
@@ -44,7 +44,7 @@ var RuntimeStatechartApi = class {
|
|
|
44
44
|
const lastId = stateIds[stateIds.length - 1];
|
|
45
45
|
const selected = this.isStateSelected(lastId);
|
|
46
46
|
this.deselectStates();
|
|
47
|
-
this.
|
|
47
|
+
this.closeStatePanels();
|
|
48
48
|
this.activateStates(...stateIds);
|
|
49
49
|
if (selected) {
|
|
50
50
|
this.deselectState(lastId);
|
|
@@ -242,9 +242,7 @@ var StateChartIndex = class {
|
|
|
242
242
|
if (!node)
|
|
243
243
|
break;
|
|
244
244
|
result.push(node.id);
|
|
245
|
-
list = node.children;
|
|
246
|
-
if (!list?.length)
|
|
247
|
-
list = node.nodes;
|
|
245
|
+
list = [...node.children || [], ...node.nodes || []];
|
|
248
246
|
}
|
|
249
247
|
return result.length === stack.length ? result : [];
|
|
250
248
|
}
|
|
@@ -2474,8 +2474,9 @@ function buildFlatCharts({
|
|
|
2474
2474
|
try {
|
|
2475
2475
|
setLodash(lodash);
|
|
2476
2476
|
const graph = new Graph({
|
|
2477
|
-
directed: true
|
|
2478
|
-
|
|
2477
|
+
directed: true,
|
|
2478
|
+
multigraph: true
|
|
2479
|
+
}).setGraph({ rankdir: vertical ? "tb" : "lr", multigraph: true });
|
|
2479
2480
|
const nodesIndex = {};
|
|
2480
2481
|
const getStateNodeId = (key, state = key) => {
|
|
2481
2482
|
let id = nodesIndex[key];
|
|
@@ -2492,12 +2493,18 @@ function buildFlatCharts({
|
|
|
2492
2493
|
const toStateKey = toState || finalStateKey;
|
|
2493
2494
|
const to = getStateNodeId(toStateKey, toState);
|
|
2494
2495
|
const params = getTransitionParams(fromStateKey, event, toStateKey);
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2496
|
+
const edgeId = newId("t");
|
|
2497
|
+
graph.setEdge(
|
|
2498
|
+
from,
|
|
2499
|
+
to,
|
|
2500
|
+
{
|
|
2501
|
+
id: edgeId,
|
|
2502
|
+
...params
|
|
2503
|
+
},
|
|
2504
|
+
edgeId
|
|
2505
|
+
);
|
|
2499
2506
|
}
|
|
2500
|
-
layout(graph, { rankdir:
|
|
2507
|
+
layout(graph, { rankdir: "lr" });
|
|
2501
2508
|
const [top, right, bottom, left] = getPadding(padding);
|
|
2502
2509
|
const nodes = graph.nodes().map((id) => {
|
|
2503
2510
|
const n = graph.node(id);
|
package/dist/index-layout.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-
|
|
1
|
+
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-OTGN3OYG.js';
|
|
2
2
|
import './chunk-NXWOFQMO.js';
|
|
3
3
|
import './chunk-XEO3YXBM.js';
|
package/dist/index-runtime.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ declare class RuntimeStatechartApi {
|
|
|
16
16
|
close(): void;
|
|
17
17
|
onStateClick(listener: RuntimeListener): () => void;
|
|
18
18
|
onTransitionClick(listener: RuntimeListener): () => void;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
openStatePanels(): void;
|
|
20
|
+
closeStatePanels(): void;
|
|
21
21
|
isStatePanelOpen(stateId: string): boolean;
|
|
22
22
|
toggleState(...stateIds: string[]): boolean;
|
|
23
23
|
activateStates(...stateIds: string[]): void;
|
package/dist/index-runtime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { RuntimeStatechartApi, StateChartIndex } from './chunk-
|
|
1
|
+
export { RuntimeStatechartApi, StateChartIndex } from './chunk-4KTXTN7J.js';
|
|
2
2
|
import './chunk-XEO3YXBM.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-
|
|
1
|
+
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-OTGN3OYG.js';
|
|
2
2
|
export { buildStatechartCss, buildStatechartStyles, buildStatechartSvg, buildStatechartsPanel, serializeCss, toKebabCase } from './chunk-YYNW6Q2T.js';
|
|
3
3
|
import './chunk-NXWOFQMO.js';
|
|
4
|
-
export { RuntimeStatechartApi, StateChartIndex } from './chunk-
|
|
4
|
+
export { RuntimeStatechartApi, StateChartIndex } from './chunk-4KTXTN7J.js';
|
|
5
5
|
import './chunk-XEO3YXBM.js';
|
package/package.json
CHANGED
|
@@ -49,9 +49,8 @@ export function buildFlatCharts({
|
|
|
49
49
|
setLodash(lodash);
|
|
50
50
|
const graph = new Graph({
|
|
51
51
|
directed: true,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.setDefaultEdgeLabel(() => ({}));
|
|
52
|
+
multigraph: true,
|
|
53
|
+
}).setGraph({ rankdir: vertical ? "tb" : "lr", multigraph: true });
|
|
55
54
|
|
|
56
55
|
const nodesIndex: Record<string, string> = {};
|
|
57
56
|
|
|
@@ -71,12 +70,18 @@ export function buildFlatCharts({
|
|
|
71
70
|
const toStateKey = toState || finalStateKey;
|
|
72
71
|
const to = getStateNodeId(toStateKey, toState);
|
|
73
72
|
const params = getTransitionParams(fromStateKey, event, toStateKey);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
const edgeId = newId("t");
|
|
74
|
+
graph.setEdge(
|
|
75
|
+
from,
|
|
76
|
+
to,
|
|
77
|
+
{
|
|
78
|
+
id: edgeId,
|
|
79
|
+
...params,
|
|
80
|
+
},
|
|
81
|
+
edgeId
|
|
82
|
+
);
|
|
78
83
|
}
|
|
79
|
-
layout(graph, { rankdir:
|
|
84
|
+
layout(graph, { rankdir: "lr" });
|
|
80
85
|
|
|
81
86
|
const [top, right, bottom, left] = getPadding(padding);
|
|
82
87
|
|
|
@@ -35,10 +35,10 @@ export class RuntimeStatechartApi {
|
|
|
35
35
|
return this._addListener(this._transitionsClickListeners, listener);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
openStatePanels() {
|
|
39
39
|
this._setStatePanelStatus(`details[data-state-id]`, true);
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
closeStatePanels() {
|
|
42
42
|
this._setStatePanelStatus(`details[data-state-id]`, false);
|
|
43
43
|
}
|
|
44
44
|
isStatePanelOpen(stateId: string) {
|
|
@@ -52,7 +52,7 @@ export class RuntimeStatechartApi {
|
|
|
52
52
|
const lastId = stateIds[stateIds.length - 1];
|
|
53
53
|
const selected = this.isStateSelected(lastId);
|
|
54
54
|
this.deselectStates();
|
|
55
|
-
this.
|
|
55
|
+
this.closeStatePanels();
|
|
56
56
|
this.activateStates(...stateIds);
|
|
57
57
|
if (selected) {
|
|
58
58
|
this.deselectState(lastId);
|
|
@@ -32,8 +32,7 @@ export class StateChartIndex {
|
|
|
32
32
|
const node = list.find((node) => node.key === key);
|
|
33
33
|
if (!node) break;
|
|
34
34
|
result.push(node.id);
|
|
35
|
-
list = node.children;
|
|
36
|
-
if (!list?.length) list = node.nodes;
|
|
35
|
+
list = [...(node.children || []), ...(node.nodes || [])];
|
|
37
36
|
}
|
|
38
37
|
return result.length === stack.length ? result : [];
|
|
39
38
|
}
|