@statewalker/fsm-charts 0.2.5 → 0.2.7

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.
Files changed (75) hide show
  1. package/README.md +213 -1
  2. package/dist/StateChart-cXyVRcs-.d.ts +94 -0
  3. package/dist/StateChart-cXyVRcs-.d.ts.map +1 -0
  4. package/dist/StateChartIndex-BK2315qj.d.ts +142 -0
  5. package/dist/StateChartIndex-BK2315qj.d.ts.map +1 -0
  6. package/dist/StateChartIndex-BOIrc_nq.js +355 -0
  7. package/dist/StateChartIndex-BOIrc_nq.js.map +1 -0
  8. package/dist/buildStatechartsPanel-BX7e0GzA.js +494 -0
  9. package/dist/buildStatechartsPanel-BX7e0GzA.js.map +1 -0
  10. package/dist/buildStatechartsPanel-hCtZbdiF.d.ts +79 -0
  11. package/dist/buildStatechartsPanel-hCtZbdiF.d.ts.map +1 -0
  12. package/dist/defineProperty-C0rC37pP.js +39 -0
  13. package/dist/description-panels-DI2MNlbK.js +184 -0
  14. package/dist/description-panels-DI2MNlbK.js.map +1 -0
  15. package/dist/getLabelDimensions-BY0q7j3D.d.ts +79 -0
  16. package/dist/getLabelDimensions-BY0q7j3D.d.ts.map +1 -0
  17. package/dist/getPadding-Cw0e7G2v.js +25 -0
  18. package/dist/getPadding-Cw0e7G2v.js.map +1 -0
  19. package/dist/index-config.d.ts +3 -12
  20. package/dist/index-config.js +2 -2
  21. package/dist/index-dom.d.ts +2 -49
  22. package/dist/index-dom.js +2 -2
  23. package/dist/index-html.d.ts +3 -2
  24. package/dist/index-html.js +2 -3
  25. package/dist/index-layout.d.ts +3 -77
  26. package/dist/index-layout.js +2 -3
  27. package/dist/index-runtime.d.ts +3 -141
  28. package/dist/index-runtime.js +2 -2
  29. package/dist/index.d.ts +11 -10
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +6 -7
  32. package/dist/layout-Dp671N6q.js +2465 -0
  33. package/dist/layout-Dp671N6q.js.map +1 -0
  34. package/dist/newTreeBuilder-CvtLDjGj.d.ts +54 -0
  35. package/dist/newTreeBuilder-CvtLDjGj.d.ts.map +1 -0
  36. package/dist/toFsmStateConfig-DlJkyZni.js +135 -0
  37. package/dist/toFsmStateConfig-DlJkyZni.js.map +1 -0
  38. package/dist/toFsmStateConfig-DmOlTRjv.d.ts +15 -0
  39. package/dist/toFsmStateConfig-DmOlTRjv.d.ts.map +1 -0
  40. package/package.json +52 -27
  41. package/src/config/concatTransitionsToString.ts +2 -2
  42. package/src/config/splitTransitionString.ts +1 -3
  43. package/src/config/toFsmStateConfig.ts +2 -9
  44. package/src/dom/buildSections.ts +3 -11
  45. package/src/dom/description-panels.ts +2 -4
  46. package/src/dom/getStatesDescriptions.ts +3 -9
  47. package/src/html/buildStatechartStyles.ts +4 -14
  48. package/src/html/buildStatechartSvg.ts +2 -14
  49. package/src/html/buildStatechartsPanel.ts +1 -3
  50. package/src/layout/buildCharts.ts +1 -2
  51. package/src/layout/buildFlatCharts.ts +6 -8
  52. package/src/layout/getGraphParamsProvider.ts +3 -12
  53. package/src/runtime/RuntimeStatechartApi.ts +10 -32
  54. package/src/runtime/StateChartIndex.ts +6 -23
  55. package/src/types/GraphParamsProvider.ts +1 -4
  56. package/src/utils/BasisCurve.ts +5 -14
  57. package/src/utils/domToText.ts +2 -6
  58. package/src/utils/getPadding.ts +1 -2
  59. package/src/utils/newId.ts +2 -1
  60. package/src/utils/newRegistry.ts +12 -12
  61. package/src/utils/serializeAttrs.ts +3 -13
  62. package/src/utils/serializeCss.ts +1 -5
  63. package/src/utils/serializeStyle.ts +1 -4
  64. package/src/utils/toKebabCase.ts +1 -4
  65. package/dist/StateChart-BYBjTmC2.d.ts +0 -82
  66. package/dist/chunk-2LFUT2C6.js +0 -2691
  67. package/dist/chunk-ARZYBFNA.js +0 -133
  68. package/dist/chunk-CR2M4445.js +0 -608
  69. package/dist/chunk-FIQDLBWD.js +0 -9
  70. package/dist/chunk-GW2Z65BN.js +0 -429
  71. package/dist/chunk-PKBMQBKP.js +0 -5
  72. package/dist/chunk-RZ4FP6JB.js +0 -233
  73. package/dist/index-html-BBQqYoST.d.ts +0 -75
  74. package/src/full/index.ts +0 -1
  75. package/src/full/toFsmStateCharts.ts +0 -119
@@ -1,608 +0,0 @@
1
- import { getPadding } from './chunk-FIQDLBWD.js';
2
- import { __publicField } from './chunk-PKBMQBKP.js';
3
-
4
- // src/utils/toKebabCase.ts
5
- function toKebabCase(str) {
6
- str = (str || "").trim().replace(/\s+/gim, "-");
7
- str = str.replace(
8
- /([^A-Z]?)([A-Z])/g,
9
- (_, a, b) => `${a.toLowerCase()}-${b.toLowerCase()}`
10
- );
11
- return str;
12
- }
13
-
14
- // src/utils/serializeCss.ts
15
- function serializeCss(obj) {
16
- return visitStyle(obj).join("\n");
17
- function visitStyle(obj2, lines = [], prefixes = [""]) {
18
- for (const [key, style] of Object.entries(obj2)) {
19
- const selectors = [];
20
- for (const sel of key.split(",").map((_) => _.trim())) {
21
- for (const prefix of prefixes) {
22
- const selector = sel.replace(
23
- /^(.)/,
24
- (_, ch) => ch === "&" ? prefix : prefix.length > 0 ? `${prefix} ${ch}` : ch
25
- );
26
- selectors.push(selector);
27
- }
28
- }
29
- const selectorRules = [];
30
- const extensions = [];
31
- for (let [key2, value] of Object.entries(style)) {
32
- if (typeof value === "object") {
33
- visitStyle({ [key2]: value }, extensions, selectors);
34
- } else {
35
- key2 = toKebabCase(key2);
36
- selectorRules.push(` ${key2}: ${value};`);
37
- }
38
- }
39
- if (selectorRules.length) {
40
- lines.push(`${selectors.join(",\n")} {`);
41
- lines.push(...selectorRules);
42
- lines.push(`}`);
43
- }
44
- lines.push(...extensions);
45
- }
46
- return lines;
47
- }
48
- }
49
-
50
- // src/html/buildStatechartStyles.ts
51
- var activeStatesStyle = {
52
- backgroundColor: "white",
53
- borderColor: "red",
54
- borderWidth: "2px",
55
- labelColor: "red"
56
- };
57
- var activeTransitionsStyle = {
58
- backgroundColor: "#eee",
59
- borderColor: "none",
60
- borderWidth: "0",
61
- lineColor: "red",
62
- lineWidth: "1px",
63
- labelColor: "red"
64
- };
65
- var selectedStatesStyle = {
66
- backgroundColor: "white",
67
- borderColor: "navy",
68
- borderWidth: "2px",
69
- labelColor: "navy"
70
- };
71
- var selectedTransitionsStyle = {
72
- backgroundColor: "#eee",
73
- borderColor: "none",
74
- borderWidth: "0",
75
- lineColor: "navy",
76
- lineWidth: "1px",
77
- labelColor: "navy"
78
- };
79
- function buildStateDetailsStyle({
80
- root = ":root"
81
- }) {
82
- return {
83
- [root]: {
84
- // --------------------------
85
- // Panels
86
- ".state-details": {
87
- backgroundColor: "var(--state-background-color, white)",
88
- border: "var(--state-border-width, 1px) solid var(--state-border-color, currentColor)",
89
- borderRadius: "0.5em",
90
- padding: "0.5em"
91
- },
92
- ".state-details__label": {
93
- cursor: "pointer",
94
- color: "var(--transition-label-color, currentColor)",
95
- fontFamily: "var(--state-label-font-family, sans-serif)",
96
- fontSize: "var(--state-label-font-size, 14px)"
97
- },
98
- ".state-details__content": {
99
- display: "flex",
100
- flexDirection: "column",
101
- gap: "0.5em"
102
- },
103
- ".state-details__chart": {
104
- maxWidth: "100%",
105
- overflow: "auto",
106
- scrollbarWidth: "thin"
107
- }
108
- }
109
- };
110
- }
111
- function buildStateDetailsStyleWithModifier({
112
- root = ":root",
113
- modifier,
114
- states
115
- }) {
116
- return {
117
- [root]: {
118
- //
119
- ".state-details": {
120
- [`&.state-details--${modifier}`]: {
121
- backgroundColor: `var(--state-${modifier}-background-color, ${states.backgroundColor})`,
122
- border: `var(--state-${modifier}-border-width, 1px) solid var(--state-${modifier}-border-color, currentColor)`
123
- }
124
- },
125
- ".state-details__label": {
126
- [`&.state-details__label--${modifier}`]: {
127
- color: `var(--state-${modifier}-label-color)`
128
- }
129
- }
130
- }
131
- };
132
- }
133
- function buildStatechartStylesWithModifier({
134
- root = ":root",
135
- modifier,
136
- states,
137
- transitions
138
- }) {
139
- return {
140
- [root]: {
141
- // --------------------------------------
142
- // Default values for transitions
143
- [`--transition-${modifier}-background-color`]: transitions.backgroundColor,
144
- [`--transition-${modifier}-border-color`]: transitions.borderColor,
145
- [`--transition-${modifier}-border-width`]: transitions.borderWidth,
146
- [`--transition-${modifier}-line-color`]: transitions.lineColor,
147
- [`--transition-${modifier}-line-width`]: transitions.lineWidth,
148
- [`--transition-${modifier}-label-color`]: transitions.labelColor,
149
- // --------------------------------------
150
- // Default values for states
151
- [`--state-${modifier}-background-color`]: states.backgroundColor,
152
- [`--state-${modifier}-border-color`]: states.borderColor,
153
- [`--state-${modifier}-border-width`]: states.borderWidth,
154
- [`--state-${modifier}-label-color`]: states.labelColor,
155
- ".state": {
156
- [`&.state--${modifier}`]: {
157
- "--state-background-color": `var(--state-${modifier}-background-color)`,
158
- "--state-border-color": `var(--state-${modifier}-border-color)`,
159
- "--state-border-width": `var(--state-${modifier}-border-width)`,
160
- "--state-label-color": `var(--state-${modifier}-label-color)`
161
- }
162
- },
163
- ".transition": {
164
- [`&.transition--${modifier}`]: {
165
- "--transition-background-color": `var(--transition-${modifier}-background-color)`,
166
- "--transition-border-color": `var(--transition-${modifier}-border-color)`,
167
- "--transition-border-width": `var(--transition-${modifier}-border-width)`,
168
- "--transition-line-color": `var(--transition-${modifier}-line-color)`,
169
- "--transition-line-width": `var(--transition-${modifier}-line-width)`,
170
- "--transition-label-color": `var(--transition-${modifier}-label-color)`
171
- }
172
- }
173
- }
174
- };
175
- }
176
- function buildStatechartStyles({
177
- root = ":root"
178
- }) {
179
- return {
180
- [root]: {
181
- // --------------------------------------
182
- // Transitions
183
- "--transition-background-color": "rgba(255,255,255,0.7)",
184
- "--transition-border-color": "none",
185
- "--transition-border-width": "1px",
186
- "--transition-line-color": "silver",
187
- "--transition-line-width": "1px",
188
- "--transition-label-color": "gray",
189
- "--transition-label-font-size": "12px",
190
- "--transition-label-font-family": "sans-serif",
191
- ".transition__marker": {
192
- fill: "var(--transition-line-color, currentColor)",
193
- stroke: "none"
194
- },
195
- ".transition__line": {
196
- stroke: "var(--transition-line-color, currentColor)",
197
- strokeWidth: "var(--transition-line-width, 1px)"
198
- },
199
- ".transition__box": {
200
- fill: "var(--transition-background-color, rgba(255,255,255,0.7))",
201
- stroke: "var(--transition-border-color, none)",
202
- strokeWidth: "var(--transition-border-width, 1px)",
203
- borderRadius: "0.5em",
204
- cursor: "pointer"
205
- },
206
- ".transition__label": {
207
- fill: "var(--transition-label-color, currentColor)",
208
- fontSize: "var(--transition-label-font-size, 12px)",
209
- fontFamily: "var(--transition-label-font-family, sans-serif)",
210
- cursor: "pointer"
211
- },
212
- // --------------------------------------
213
- // Normal states
214
- "--state-background-color": "white",
215
- "--state-border-color": "silver",
216
- "--state-border-width": "1px",
217
- "--state-label-color": "gray",
218
- "--state-label-font-size": "14px",
219
- "--state-label-font-family": "sans-serif",
220
- ".state__box": {
221
- fill: "var(--state-background-color, white)",
222
- stroke: "var(--state-border-color, currentColor)",
223
- strokeWidth: "var(--state-border-width, 1px)",
224
- borderRadius: "0.5em",
225
- cursor: "pointer"
226
- },
227
- ".state__label": {
228
- color: "var(--state-label-color, currentColor)",
229
- fill: "var(--state-label-color, currentColor)",
230
- fontSize: "var(--state-label-font-size, 14px)",
231
- fontFamily: "var(--state-label-font-family, sans-serif)",
232
- cursor: "pointer"
233
- },
234
- ".state__initial": {
235
- fill: "var(--state-border-color, currentColor)",
236
- stroke: "var(--state-border-color, currentColor)",
237
- strokeWidth: "var(--state-border-width, 2px)"
238
- },
239
- ".state__final": {
240
- fill: "white",
241
- stroke: "var(--state-border-color, currentColor)",
242
- strokeWidth: "var(--state-border-width, 2px)",
243
- // ---------------------------
244
- "&.state__final--inner": {
245
- fill: "var(--state-border-color, currentColor)",
246
- stroke: "none",
247
- strokeWidth: "0"
248
- }
249
- }
250
- }
251
- };
252
- }
253
-
254
- // src/html/buildStatechartCss.ts
255
- function buildStatechartCss({ prefix = "" } = {}) {
256
- const root = prefix || ":root";
257
- return [
258
- buildStatechartStyles({ root }),
259
- buildStatechartStylesWithModifier({
260
- root,
261
- modifier: "selected",
262
- states: selectedStatesStyle,
263
- transitions: selectedTransitionsStyle
264
- }),
265
- buildStatechartStylesWithModifier({
266
- root,
267
- modifier: "active",
268
- states: activeStatesStyle,
269
- transitions: activeTransitionsStyle
270
- }),
271
- buildStateDetailsStyle({ root }),
272
- buildStateDetailsStyleWithModifier({
273
- root,
274
- modifier: "selected",
275
- states: selectedStatesStyle
276
- }),
277
- buildStateDetailsStyleWithModifier({
278
- root,
279
- modifier: "active",
280
- states: activeStatesStyle
281
- })
282
- ].map(serializeCss).join("\n");
283
- }
284
-
285
- // src/utils/BasisCurve.ts
286
- var BasisCurve = class {
287
- constructor(context) {
288
- __publicField(this, "_context");
289
- __publicField(this, "_x0", 0);
290
- __publicField(this, "_y0", 0);
291
- __publicField(this, "_x1", 0);
292
- __publicField(this, "_y1", 0);
293
- __publicField(this, "_point", 0);
294
- __publicField(this, "_line", 0);
295
- this._context = context;
296
- }
297
- $point(x, y) {
298
- this._context.bezierCurveTo(
299
- (2 * this._x0 + this._x1) / 3,
300
- (2 * this._y0 + this._y1) / 3,
301
- (this._x0 + 2 * this._x1) / 3,
302
- (this._y0 + 2 * this._y1) / 3,
303
- (this._x0 + 4 * this._x1 + x) / 6,
304
- (this._y0 + 4 * this._y1 + y) / 6
305
- );
306
- }
307
- areaStart() {
308
- this._line = 0;
309
- }
310
- areaEnd() {
311
- this._line = NaN;
312
- }
313
- lineStart() {
314
- this._x0 = this._x1 = this._y0 = this._y1 = NaN;
315
- this._point = 0;
316
- }
317
- lineEnd() {
318
- switch (this._point) {
319
- case 3:
320
- this.$point(this._x1, this._y1);
321
- // falls through
322
- case 2:
323
- this._context.lineTo(this._x1, this._y1);
324
- break;
325
- }
326
- if (this._line || this._line !== 0 && this._point === 1)
327
- this._context.closePath();
328
- this._line = 1 - this._line;
329
- }
330
- point(x, y) {
331
- x = +x, y = +y;
332
- switch (this._point) {
333
- case 0:
334
- this._point = 1;
335
- this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
336
- break;
337
- case 1:
338
- this._point = 2;
339
- break;
340
- case 2:
341
- this._point = 3;
342
- this._context.lineTo(
343
- (5 * this._x0 + this._x1) / 6,
344
- (5 * this._y0 + this._y1) / 6
345
- );
346
- // falls through
347
- default:
348
- this.$point(x, y);
349
- break;
350
- }
351
- this._x0 = this._x1, this._x1 = x;
352
- this._y0 = this._y1, this._y1 = y;
353
- }
354
- };
355
-
356
- // src/utils/serializeAttrs.ts
357
- function serializeAttrs(attrs = {}, {
358
- prefix = "",
359
- transform = false
360
- } = {}) {
361
- const result = [];
362
- for (const [key, value] of Object.entries(attrs || {}).sort(
363
- ([a], [b]) => a > b ? 1 : -1
364
- )) {
365
- if (value === void 0 || value === null || value === "") continue;
366
- result.push(
367
- `${prefix}${escapeValue(key)}${"=" + JSON.stringify(
368
- escapeValue(transform ? toKebabCase(String(value)) : value)
369
- )}`
370
- );
371
- }
372
- return result.join(" ");
373
- function escapeValue(value) {
374
- return String(value).replaceAll(/</gim, "&lt;").replaceAll(/>/gim, "&gt;").replaceAll(/"/gim, "&quot;");
375
- }
376
- }
377
-
378
- // src/html/buildStatechartSvg.ts
379
- function getBoxParams({
380
- x,
381
- y,
382
- width,
383
- height,
384
- padding = 0
385
- }) {
386
- const [top, right, bottom, left] = getPadding(padding);
387
- const h = Math.ceil(height - top - bottom);
388
- return {
389
- x: x + left,
390
- y: y - bottom - h,
391
- width: Math.ceil(width - left - right),
392
- height: h
393
- };
394
- }
395
- function buildStatechartSvg({
396
- graph: { width, height, nodes, edges },
397
- newId,
398
- stateFontSize = 14,
399
- transitionFontSize = 12,
400
- println,
401
- initialStateKey = "<initial>",
402
- finalStateKey = "<final>"
403
- }) {
404
- if (!nodes.length && !edges.length) return;
405
- width = Math.ceil(width);
406
- height = Math.ceil(height);
407
- println(
408
- `<svg ${serializeAttrs({
409
- class: "statechart",
410
- width,
411
- height,
412
- viewbox: `0 0 ${width} ${height}`,
413
- xmlns: "http://www.w3.org/2000/svg"
414
- })}>`
415
- );
416
- println(`<g class="statechart__transitions">`);
417
- const markerAttrs = serializeAttrs({
418
- refX: 19,
419
- refY: 7,
420
- markerWidth: 20,
421
- markerHeight: 14,
422
- orient: "auto",
423
- class: "transition__marker",
424
- stroke: "none",
425
- fill: "currentColor"
426
- });
427
- for (const edge of edges) {
428
- const { id, points, text } = edge;
429
- println(` <g class="transition" data-transition-id="${id}">`);
430
- const markerId = newId("marker");
431
- println(` <defs>`);
432
- println(` <marker id="${markerId}" ${markerAttrs}>`);
433
- println(` <path d="M 19,7 L9,13 L14,7 L9,1 Z"></path>`);
434
- println(` </marker>`);
435
- println(` </defs>`);
436
- const path = [];
437
- const round = (...n) => n.map(Math.round);
438
- const base = new BasisCurve({
439
- bezierCurveTo(x0, y0, x1, y1, x2, y2) {
440
- path.push(`C${round(x0, y0, x1, y1, x2, y2).join(",")}`);
441
- },
442
- moveTo(x, y) {
443
- path.push(`M${round(x, y).join(",")}`);
444
- },
445
- lineTo(x, y) {
446
- path.push(`L${round(x, y).join(",")}`);
447
- },
448
- closePath() {
449
- path.push("Z");
450
- }
451
- });
452
- base.lineStart();
453
- for (const point of points) {
454
- base.point(point.x, point.y);
455
- }
456
- base.lineEnd();
457
- const serializedAttrs = serializeAttrs({
458
- class: "transition__line",
459
- fill: "none",
460
- stroke: "currentColor",
461
- strokeWidth: "1px",
462
- d: path.join(""),
463
- "marker-end": `url(#${markerId})`
464
- });
465
- println(` <path ${serializedAttrs} />`);
466
- if (text) {
467
- const { x, y, width: width2, height: height2 } = getBoxParams({
468
- ...edge,
469
- padding: 0
470
- });
471
- const rectAttrs = serializeAttrs({
472
- x,
473
- y: y - transitionFontSize,
474
- width: width2,
475
- height: height2,
476
- rx: Math.ceil(transitionFontSize / 2),
477
- ry: Math.ceil(transitionFontSize / 2),
478
- fill: "rgba(255,255,255,0.7)",
479
- stroke: "none",
480
- strokeWidth: "1",
481
- class: "transition__box"
482
- });
483
- println(` <rect ${rectAttrs} />`);
484
- const textAttrs = serializeAttrs({
485
- class: "transition__label",
486
- "text-anchor": "middle",
487
- fill: "currentColor",
488
- x: Math.round(x + width2 / 2),
489
- y: Math.round(y + height2 / 2 - transitionFontSize / 2)
490
- });
491
- println(` <text ${textAttrs}>${text}</text>`);
492
- }
493
- println(` </g>`);
494
- }
495
- println("</g>");
496
- const shift = stateFontSize / 4;
497
- const initialStateRadius = 6;
498
- const finalStateRadius = initialStateRadius / 2;
499
- println(`<g class="statechart__states">`);
500
- for (const node of nodes) {
501
- const { key, id, text } = node;
502
- const { x, y, width: width2, height: height2 } = getBoxParams({ ...node, padding: shift });
503
- println(` <g class="state" data-state-id="${id}">`);
504
- if (key === initialStateKey || key === finalStateKey) {
505
- const cx = Math.round(x + width2 / 2);
506
- const cy = Math.round(y + height2 / 2);
507
- if (key === initialStateKey) {
508
- const serializedAttrs = serializeAttrs({
509
- class: "state__initial",
510
- cx,
511
- cy,
512
- r: initialStateRadius,
513
- fill: "none",
514
- stroke: "currentColor",
515
- strokeWidth: "2"
516
- });
517
- println(` <circle ${serializedAttrs} />`);
518
- } else {
519
- let serializedAttrs = serializeAttrs({
520
- class: "state__final",
521
- cx,
522
- cy,
523
- r: initialStateRadius,
524
- fill: "none",
525
- stroke: "currentColor",
526
- strokeWidth: 2
527
- });
528
- println(` <circle ${serializedAttrs} />`);
529
- serializedAttrs = serializeAttrs({
530
- class: "state__final state__final--inner",
531
- cx,
532
- cy,
533
- r: finalStateRadius,
534
- fill: "currentColor",
535
- stroke: "none",
536
- strokeWidth: 0
537
- });
538
- println(` <circle ${serializedAttrs} />`);
539
- }
540
- } else {
541
- const rectAttrs = serializeAttrs({
542
- x,
543
- y,
544
- width: width2,
545
- height: height2,
546
- rx: Math.ceil(stateFontSize / 2),
547
- ry: Math.ceil(stateFontSize / 2),
548
- fill: "none",
549
- stroke: "currentColor",
550
- strokeWidth: "2",
551
- class: "state__box"
552
- });
553
- println(` <rect ${rectAttrs} />`);
554
- const textAttrs = serializeAttrs({
555
- class: "state__label",
556
- "text-anchor": "middle",
557
- fill: "currentColor",
558
- x: Math.round(x + width2 / 2),
559
- y: Math.round(y + height2 / 2 + stateFontSize / 4)
560
- });
561
- println(` <text ${textAttrs}>${text}</text>`);
562
- }
563
- println(" </g>");
564
- }
565
- println("</g>");
566
- println("</svg>");
567
- }
568
-
569
- // src/html/buildStatechartsPanel.ts
570
- function buildStatechartsPanel({
571
- statechart,
572
- newId,
573
- println,
574
- initialStateKey = "<initial>",
575
- finalStateKey = "<final>"
576
- }) {
577
- render(statechart, println);
578
- function render(statechart2, println2) {
579
- println2(
580
- ` <details class="state-details" data-state-id="${statechart2.id}">`
581
- );
582
- println2(
583
- ` <summary class="state-details__label">${statechart2.text ?? statechart2.state}</summary>`
584
- );
585
- println2(` <div class="state-details__content">`);
586
- const printChildren = (str) => println2(` ${str}`);
587
- if (statechart2.nodes.length) {
588
- println2(` <div class="state-details__chart">`);
589
- buildStatechartSvg({
590
- graph: statechart2,
591
- newId,
592
- println: printChildren,
593
- initialStateKey,
594
- finalStateKey
595
- });
596
- println2(` </div>`);
597
- }
598
- println2(` <div class="state-details__description">`);
599
- println2(` </div>`);
600
- for (const child of statechart2.children || []) {
601
- render(child, printChildren);
602
- }
603
- println2(` </div>`);
604
- println2(` </details>`);
605
- }
606
- }
607
-
608
- export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle, serializeCss, toKebabCase };
@@ -1,9 +0,0 @@
1
- // src/utils/getPadding.ts
2
- function getPadding(padding) {
3
- if (typeof padding === "number") return [padding, padding, padding, padding];
4
- if (padding.length === 2)
5
- return [padding[0], padding[1], padding[0], padding[1]];
6
- return padding;
7
- }
8
-
9
- export { getPadding };