stickyflow 0.4.0 → 0.5.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +51 -5
  3. package/dist/binding/index.cjs +34 -0
  4. package/dist/binding/index.cjs.map +1 -0
  5. package/dist/binding/index.d.cts +11 -0
  6. package/dist/binding/index.d.ts +11 -0
  7. package/dist/binding/index.js +5 -0
  8. package/dist/binding/index.js.map +1 -0
  9. package/dist/{chunk-XEN5QIIJ.js → chunk-7VW2XKVB.js} +3 -3
  10. package/dist/{chunk-XEN5QIIJ.js.map → chunk-7VW2XKVB.js.map} +1 -1
  11. package/dist/chunk-BODZN3ZI.js +1182 -0
  12. package/dist/chunk-BODZN3ZI.js.map +1 -0
  13. package/dist/{chunk-CSXQD3ON.js → chunk-G7NRK5AG.js} +1128 -1081
  14. package/dist/chunk-G7NRK5AG.js.map +1 -0
  15. package/dist/{chunk-BYMIYXP5.js → chunk-IEHE6WVN.js} +197 -19
  16. package/dist/chunk-IEHE6WVN.js.map +1 -0
  17. package/dist/{chunk-HFOGKSNU.cjs → chunk-L3VJXZFD.cjs} +15 -15
  18. package/dist/{chunk-HFOGKSNU.cjs.map → chunk-L3VJXZFD.cjs.map} +1 -1
  19. package/dist/{chunk-65IVT4GK.js → chunk-LTGF5OHP.js} +1008 -631
  20. package/dist/chunk-LTGF5OHP.js.map +1 -0
  21. package/dist/chunk-TWDLOXRM.cjs +1189 -0
  22. package/dist/chunk-TWDLOXRM.cjs.map +1 -0
  23. package/dist/{chunk-UXDWH2JC.cjs → chunk-VK3T6O5Z.cjs} +1165 -1118
  24. package/dist/chunk-VK3T6O5Z.cjs.map +1 -0
  25. package/dist/{chunk-CXL254BT.cjs → chunk-XY2GZUHC.cjs} +204 -18
  26. package/dist/chunk-XY2GZUHC.cjs.map +1 -0
  27. package/dist/{chunk-DDCTNLLD.cjs → chunk-ZMLQIMJK.cjs} +1504 -1128
  28. package/dist/chunk-ZMLQIMJK.cjs.map +1 -0
  29. package/dist/index.cjs +53 -1013
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +22 -14
  32. package/dist/index.d.ts +22 -14
  33. package/dist/index.js +6 -993
  34. package/dist/index.js.map +1 -1
  35. package/dist/interaction/index.cjs +231 -231
  36. package/dist/interaction/index.cjs.map +1 -1
  37. package/dist/interaction/index.d.cts +2 -2
  38. package/dist/interaction/index.d.ts +2 -2
  39. package/dist/interaction/index.js +3 -3
  40. package/dist/interaction/index.js.map +1 -1
  41. package/dist/{render-C5X74hds.d.cts → render-CgX_y15a.d.cts} +193 -116
  42. package/dist/{render-C5X74hds.d.ts → render-CgX_y15a.d.ts} +193 -116
  43. package/dist/runtime-DnUxca3Y.d.ts +10 -0
  44. package/dist/runtime-reWgr7MP.d.cts +10 -0
  45. package/dist/{runtimeTypes-D8hPZ62T.d.ts → runtimeTypes-CEBGueYM.d.ts} +10 -5
  46. package/dist/{runtimeTypes-yTSAvtCn.d.cts → runtimeTypes-D60w6nyF.d.cts} +10 -5
  47. package/dist/stickyflow-diagram.global.js +35 -35
  48. package/dist/stickyflow-diagram.global.js.map +1 -1
  49. package/dist/{types-BDKDf4zr.d.cts → types-DYLC_lsk.d.ts} +3 -2
  50. package/dist/{types-CdgGdtoD.d.ts → types-DvhMpqrL.d.cts} +3 -2
  51. package/dist/viewer/index.cjs +9 -9
  52. package/dist/viewer/index.d.cts +4 -4
  53. package/dist/viewer/index.d.ts +4 -4
  54. package/dist/viewer/index.js +4 -4
  55. package/dist/web-component/index.cjs +6 -6
  56. package/dist/web-component/index.d.cts +2 -2
  57. package/dist/web-component/index.d.ts +2 -2
  58. package/dist/web-component/index.js +4 -4
  59. package/package.json +6 -1
  60. package/dist/chunk-65IVT4GK.js.map +0 -1
  61. package/dist/chunk-BYMIYXP5.js.map +0 -1
  62. package/dist/chunk-CSXQD3ON.js.map +0 -1
  63. package/dist/chunk-CXL254BT.cjs.map +0 -1
  64. package/dist/chunk-DDCTNLLD.cjs.map +0 -1
  65. package/dist/chunk-UXDWH2JC.cjs.map +0 -1
@@ -113,6 +113,181 @@ function deriveFaceFills(fill) {
113
113
  };
114
114
  }
115
115
 
116
+ // src/model/component/supportedTypes.ts
117
+ var BUILT_IN_COMPONENT_TYPES = ["rollingNumber", "tickScale", "ruler"];
118
+ function isBuiltInComponentType(value) {
119
+ return value !== void 0 && BUILT_IN_COMPONENT_TYPES.includes(value);
120
+ }
121
+
122
+ // src/model/component/guards.ts
123
+ function isGenericComponent(component) {
124
+ return !isBuiltInComponentType(component.type);
125
+ }
126
+
127
+ // src/model/component/builtIns.ts
128
+ var BUILT_IN_DESCRIPTORS = [
129
+ {
130
+ type: "rollingNumber",
131
+ group: "readout",
132
+ value: { type: "number", writable: false, default: 0 },
133
+ properties: {},
134
+ interaction: "none",
135
+ pointerScale: false,
136
+ size: { width: 160, height: 90 }
137
+ },
138
+ {
139
+ type: "tickScale",
140
+ group: "readout",
141
+ value: { type: "number", writable: false, default: 0 },
142
+ properties: {},
143
+ interaction: "none",
144
+ pointerScale: true,
145
+ size: { width: 200, height: 200 }
146
+ },
147
+ {
148
+ type: "ruler",
149
+ group: "input",
150
+ value: { type: "number", writable: false, default: 0 },
151
+ properties: {},
152
+ interaction: "scale",
153
+ pointerScale: true,
154
+ size: { width: 120, height: 360 }
155
+ },
156
+ {
157
+ type: "switch",
158
+ group: "input",
159
+ value: { type: "boolean", writable: true, default: false },
160
+ properties: {
161
+ accent: { type: "color", default: "#5a6bff" },
162
+ track: { type: "color", default: "#cbd5e1" },
163
+ thumb: { type: "color", default: "#ffffff" }
164
+ },
165
+ interaction: "toggle",
166
+ pointerScale: false,
167
+ size: { width: 52, height: 30, minWidth: 36, minHeight: 20, aspect: 52 / 30 },
168
+ role: "switch"
169
+ },
170
+ {
171
+ type: "checkbox",
172
+ group: "input",
173
+ value: { type: "boolean", writable: true, default: false },
174
+ properties: {
175
+ accent: { type: "color", default: "#5a6bff" },
176
+ stroke: { type: "color", default: "#94a3b8" },
177
+ check: { type: "color", default: "#ffffff" },
178
+ textColor: { type: "color", default: "#0f172a" },
179
+ fontSize: { type: "number", default: 14, min: 6, max: 200 }
180
+ },
181
+ interaction: "toggle",
182
+ pointerScale: false,
183
+ size: { width: 160, height: 24, minWidth: 18, minHeight: 18 },
184
+ role: "checkbox"
185
+ },
186
+ {
187
+ type: "toggleButton",
188
+ group: "input",
189
+ value: { type: "boolean", writable: true, default: false },
190
+ properties: {
191
+ accent: { type: "color", default: "#5a6bff" },
192
+ stroke: { type: "color", default: "#94a3b8" },
193
+ textColor: { type: "color", default: "#0f172a" },
194
+ onTextColor: { type: "color", default: "#ffffff" },
195
+ fontSize: { type: "number", default: 14, min: 6, max: 200 }
196
+ },
197
+ interaction: "toggle",
198
+ pointerScale: false,
199
+ size: { width: 120, height: 40, minWidth: 40, minHeight: 24 },
200
+ role: "button"
201
+ },
202
+ {
203
+ type: "button",
204
+ group: "action",
205
+ properties: {
206
+ accent: { type: "color", default: "#5a6bff" },
207
+ textColor: { type: "color", default: "#ffffff" },
208
+ radius: { type: "number", default: 8, min: 0, max: 200 },
209
+ fontSize: { type: "number", default: 14, min: 6, max: 200 }
210
+ },
211
+ interaction: "press",
212
+ pointerScale: false,
213
+ size: { width: 120, height: 40, minWidth: 40, minHeight: 24 },
214
+ role: "button"
215
+ }
216
+ ];
217
+
218
+ // src/model/component/registry.ts
219
+ var version = 0;
220
+ var descriptors = new Map(
221
+ BUILT_IN_DESCRIPTORS.map((descriptor) => [descriptor.type, descriptor])
222
+ );
223
+ var TYPE_NAME = /^[A-Za-z][A-Za-z0-9]*$/;
224
+ function registerComponentDescriptor(descriptor) {
225
+ if (!TYPE_NAME.test(descriptor.type)) {
226
+ throw new Error(`'${descriptor.type}' is not a valid component type name.`);
227
+ }
228
+ if (descriptors.has(descriptor.type)) {
229
+ throw new Error(`A component of type '${descriptor.type}' is already defined.`);
230
+ }
231
+ descriptors.set(descriptor.type, descriptor);
232
+ version += 1;
233
+ return () => {
234
+ if (descriptors.get(descriptor.type) === descriptor) {
235
+ descriptors.delete(descriptor.type);
236
+ version += 1;
237
+ }
238
+ };
239
+ }
240
+ function componentRegistryVersion() {
241
+ return version;
242
+ }
243
+ function getComponentDescriptor(type) {
244
+ return type === void 0 ? void 0 : descriptors.get(type);
245
+ }
246
+ function componentTypes() {
247
+ return [...descriptors.keys()];
248
+ }
249
+ function isComponentType(value) {
250
+ return getComponentDescriptor(value) !== void 0;
251
+ }
252
+
253
+ // src/model/component/format.ts
254
+ function formatRollingNumber(value, digits) {
255
+ const text = String(value);
256
+ if (digits === void 0) {
257
+ return text;
258
+ }
259
+ if (!Number.isInteger(digits) || digits < 1) {
260
+ return text;
261
+ }
262
+ return text.padStart(digits, "0");
263
+ }
264
+
265
+ // src/model/component/theme.ts
266
+ var DEFAULT_ROLLING_NUMBER_STYLE = {
267
+ color: "#000000",
268
+ surface: "rgba(255, 255, 255, 0.28)",
269
+ divider: "rgba(0, 0, 0, 0.2)",
270
+ labelColor: "rgba(0, 0, 0, 0.62)",
271
+ fontFamily: "'Roboto Mono', 'SFMono-Regular', Consolas, monospace",
272
+ variant: "flip",
273
+ motion: "roll",
274
+ fontWeight: "300",
275
+ fontSize: 0
276
+ };
277
+ function resolveRollingNumberStyle(style) {
278
+ return {
279
+ color: style.color ?? DEFAULT_ROLLING_NUMBER_STYLE.color,
280
+ surface: style.surface ?? DEFAULT_ROLLING_NUMBER_STYLE.surface,
281
+ divider: style.divider ?? DEFAULT_ROLLING_NUMBER_STYLE.divider,
282
+ labelColor: style.labelColor ?? DEFAULT_ROLLING_NUMBER_STYLE.labelColor,
283
+ fontFamily: style.fontFamily ?? DEFAULT_ROLLING_NUMBER_STYLE.fontFamily,
284
+ variant: style.variant ?? DEFAULT_ROLLING_NUMBER_STYLE.variant,
285
+ motion: style.motion ?? DEFAULT_ROLLING_NUMBER_STYLE.motion,
286
+ fontWeight: style.fontWeight ?? DEFAULT_ROLLING_NUMBER_STYLE.fontWeight,
287
+ fontSize: style.fontSize ?? DEFAULT_ROLLING_NUMBER_STYLE.fontSize
288
+ };
289
+ }
290
+
116
291
  // src/sflLanguage/lexing/cursor.ts
117
292
  var SourceCursor = class {
118
293
  constructor(input) {
@@ -512,6 +687,7 @@ var NAMED_BLOCK_KINDS = [
512
687
  "Path",
513
688
  "Chart",
514
689
  "Widget",
690
+ "Component",
515
691
  "Shape",
516
692
  "Text",
517
693
  "Isometric",
@@ -530,6 +706,7 @@ var NAMED_BLOCK_KINDS = [
530
706
  ];
531
707
  var SIDES = ["top", "bottom", "left", "right"];
532
708
  var isSide = (s) => SIDES.includes(s);
709
+ var isComponentBlockKind = (kind) => kind === "Component" || kind === "Widget";
533
710
  var isNamedBlockKind = (s) => NAMED_BLOCK_KINDS.includes(s);
534
711
 
535
712
  // src/sflLanguage/parsing/values.ts
@@ -969,14 +1146,14 @@ var DocumentParser = class {
969
1146
  if (header.value !== "sfl") {
970
1147
  throw new SflParseError(`document must start with 'sfl', got '${header.value}'`, header.line, header.col);
971
1148
  }
972
- const version = this.cursor.expect("number", "version number");
1149
+ const version2 = this.cursor.expect("number", "version number");
973
1150
  this.cursor.skipNewlines();
974
1151
  const blocks = [];
975
1152
  while (!this.cursor.at("eof")) {
976
1153
  blocks.push(this.blocks.parseBlock());
977
1154
  this.cursor.skipNewlines();
978
1155
  }
979
- return { version: version.value, blocks };
1156
+ return { version: version2.value, blocks };
980
1157
  }
981
1158
  };
982
1159
 
@@ -1423,6 +1600,7 @@ var CANVAS_OBJECT_BLOCK_KINDS = [
1423
1600
  "Path",
1424
1601
  "Chart",
1425
1602
  "Widget",
1603
+ "Component",
1426
1604
  "Isometric"
1427
1605
  ];
1428
1606
  var canvasObjectBlockKinds = new Set(CANVAS_OBJECT_BLOCK_KINDS);
@@ -1914,7 +2092,7 @@ function declaredCanvasObjectKind(block2, properties) {
1914
2092
  if (block2.kind === "Chart") {
1915
2093
  return "chart";
1916
2094
  }
1917
- if (block2.kind === "Widget") {
2095
+ if (isComponentBlockKind(block2.kind)) {
1918
2096
  return asString(properties.get("type")) ?? "widget";
1919
2097
  }
1920
2098
  if (block2.kind === "Text") {
@@ -1938,8 +2116,8 @@ function canvasObjectTypeForKind(kind) {
1938
2116
  if (kind === "chart") {
1939
2117
  return "chart";
1940
2118
  }
1941
- if (kind === "rollingNumber" || kind === "tickScale" || kind === "ruler") {
1942
- return "widget";
2119
+ if (isBuiltInComponentType(kind)) {
2120
+ return "component";
1943
2121
  }
1944
2122
  if (kind === "isometric") {
1945
2123
  return "isometric";
@@ -1951,7 +2129,7 @@ function classifyCanvasObject(block2, properties, symbolDefinitions) {
1951
2129
  const shapeReference = asString(properties.get("shape"));
1952
2130
  const symbol = shapeReference ? symbolDefinitions.get(shapeReference) : void 0;
1953
2131
  return {
1954
- objectType: block2.kind === "Widget" ? "widget" : canvasObjectTypeForKind(kind),
2132
+ objectType: isComponentBlockKind(block2.kind) ? "component" : canvasObjectTypeForKind(kind),
1955
2133
  kind,
1956
2134
  shapeType: symbol ? "symbol" : shapeReference,
1957
2135
  symbol
@@ -2013,11 +2191,11 @@ function resolveCanvasObject(block2, origin, context, frameId, positionOverride)
2013
2191
  return resolveSwimlaneObject(base, properties);
2014
2192
  case "frame":
2015
2193
  return { ...base, objectType: "frame" };
2016
- case "widget":
2194
+ case "component":
2017
2195
  return {
2018
2196
  ...base,
2019
- objectType: "widget",
2020
- widget: {
2197
+ objectType: "component",
2198
+ component: {
2021
2199
  type: asString(properties.get("type")) ?? "rollingNumber",
2022
2200
  value: asString(properties.get("value")) ?? "0",
2023
2201
  digits: asNumber(properties.get("digits")),
@@ -2450,18 +2628,18 @@ function collectUnsupportedGridShapes(doc) {
2450
2628
  return diagnostics;
2451
2629
  }
2452
2630
 
2453
- // src/sflSemantic/diagnostics/widgets.ts
2454
- function collectUnsupportedWidgetTypes(sflDocument) {
2631
+ // src/sflSemantic/diagnostics/components.ts
2632
+ function collectUnsupportedComponentTypes(sflDocument) {
2455
2633
  const diagnostics = [];
2456
2634
  const visit = (block2) => {
2457
- if (block2.kind === "Widget") {
2635
+ if (isComponentBlockKind(block2.kind)) {
2458
2636
  const type = asString(directProperties(block2).get("type")) ?? "rollingNumber";
2459
- if (type !== "rollingNumber" && type !== "tickScale" && type !== "ruler") {
2637
+ if (!isComponentType(type)) {
2460
2638
  diagnostics.push({
2461
2639
  severity: "warning",
2462
- code: "unsupported-widget-type",
2640
+ code: "unsupported-component-type",
2463
2641
  ownerId: block2.name,
2464
- message: `Unsupported widget type '${type}'. Supported: rollingNumber, tickScale, ruler.`
2642
+ message: `Unsupported component type '${type}'. Supported: ${componentTypes().join(", ")}.`
2465
2643
  });
2466
2644
  }
2467
2645
  }
@@ -2485,7 +2663,7 @@ function createCanvasResolution(doc) {
2485
2663
  ...collectUnsupportedChartTypes(doc),
2486
2664
  ...collectUnsupportedGridShapes(doc),
2487
2665
  ...collectEmptySeries(doc),
2488
- ...collectUnsupportedWidgetTypes(doc)
2666
+ ...collectUnsupportedComponentTypes(doc)
2489
2667
  ],
2490
2668
  canvasObjectResolutionContext: createCanvasObjectPropertyReaders(definitions)
2491
2669
  };
@@ -4703,6 +4881,7 @@ exports.CORNER_RADIUS_ATTR = CORNER_RADIUS_ATTR;
4703
4881
  exports.DEFAULT_FONT = DEFAULT_FONT;
4704
4882
  exports.DEFAULT_HEATMAP_ZONES = DEFAULT_HEATMAP_ZONES;
4705
4883
  exports.DEFAULT_HEX_RADIUS = DEFAULT_HEX_RADIUS;
4884
+ exports.DEFAULT_ROLLING_NUMBER_STYLE = DEFAULT_ROLLING_NUMBER_STYLE;
4706
4885
  exports.DEFAULT_ZONE_FILL = DEFAULT_ZONE_FILL;
4707
4886
  exports.DOM_CONTRACT_VERSION = DOM_CONTRACT_VERSION;
4708
4887
  exports.EMPTY_BOUNDS = EMPTY_BOUNDS;
@@ -4735,6 +4914,7 @@ exports.chartText = chartText;
4735
4914
  exports.chartTicks = chartTicks;
4736
4915
  exports.clipSegmentToRect = clipSegmentToRect;
4737
4916
  exports.colorWithAlpha = colorWithAlpha;
4917
+ exports.componentRegistryVersion = componentRegistryVersion;
4738
4918
  exports.computeBoxplotStats = computeBoxplotStats;
4739
4919
  exports.contrastTextColor = contrastTextColor;
4740
4920
  exports.cornersRoundedRectPath = cornersRoundedRectPath;
@@ -4750,13 +4930,17 @@ exports.estimateTextWidth = estimateTextWidth;
4750
4930
  exports.finite = finite;
4751
4931
  exports.formatBarLabel = formatBarLabel;
4752
4932
  exports.formatFieldValue = formatFieldValue;
4933
+ exports.formatRollingNumber = formatRollingNumber;
4753
4934
  exports.freeformPathData = freeformPathData;
4754
4935
  exports.gapInsetAngle = gapInsetAngle;
4936
+ exports.getComponentDescriptor = getComponentDescriptor;
4755
4937
  exports.getLineMidpoint = getLineMidpoint;
4756
4938
  exports.heuristicRichMeasure = heuristicRichMeasure;
4757
4939
  exports.horizontalRows = horizontalRows;
4758
4940
  exports.interpolateHexColorStops = interpolateHexColorStops;
4941
+ exports.isBuiltInComponentType = isBuiltInComponentType;
4759
4942
  exports.isChartObject = isChartObject;
4943
+ exports.isGenericComponent = isGenericComponent;
4760
4944
  exports.isHorizontalBar = isHorizontalBar;
4761
4945
  exports.isIsometricObject = isIsometricObject;
4762
4946
  exports.isLightColor = isLightColor;
@@ -4790,11 +4974,13 @@ exports.radarRadiusForValue = radarRadiusForValue;
4790
4974
  exports.radarSeriesPath = radarSeriesPath;
4791
4975
  exports.radarValueAtPoint = radarValueAtPoint;
4792
4976
  exports.radarVertexPoint = radarVertexPoint;
4977
+ exports.registerComponentDescriptor = registerComponentDescriptor;
4793
4978
  exports.relativeOffsetOnRectangleSide = relativeOffsetOnRectangleSide;
4794
4979
  exports.renderPieLabels = renderPieLabels;
4795
4980
  exports.representativeColor = representativeColor;
4796
4981
  exports.resolveChartShadow = resolveChartShadow;
4797
4982
  exports.resolvePieRadii = resolvePieRadii;
4983
+ exports.resolveRollingNumberStyle = resolveRollingNumberStyle;
4798
4984
  exports.rightRoundedRectPath = rightRoundedRectPath;
4799
4985
  exports.rotatedBounds = rotatedBounds;
4800
4986
  exports.roundedBarPath = roundedBarPath;
@@ -4821,5 +5007,5 @@ exports.tokenizeSource = tokenizeSource;
4821
5007
  exports.topRoundedRectPath = topRoundedRectPath;
4822
5008
  exports.wrapText = wrapText;
4823
5009
  exports.zoneColorAtValue = zoneColorAtValue;
4824
- //# sourceMappingURL=chunk-CXL254BT.cjs.map
4825
- //# sourceMappingURL=chunk-CXL254BT.cjs.map
5010
+ //# sourceMappingURL=chunk-XY2GZUHC.cjs.map
5011
+ //# sourceMappingURL=chunk-XY2GZUHC.cjs.map