stickyflow 0.11.0 → 0.11.2

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 (32) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/binding/index.cjs +8 -8
  3. package/dist/binding/index.js +2 -2
  4. package/dist/{chunk-FXGXUWSI.cjs → chunk-4KBU4CFU.cjs} +7 -7
  5. package/dist/{chunk-FXGXUWSI.cjs.map → chunk-4KBU4CFU.cjs.map} +1 -1
  6. package/dist/{chunk-RQYZNW2I.js → chunk-DGAVCN4D.js} +3 -3
  7. package/dist/{chunk-RQYZNW2I.js.map → chunk-DGAVCN4D.js.map} +1 -1
  8. package/dist/{chunk-5G3BEXQU.cjs → chunk-EHH6ZDK6.cjs} +9 -2
  9. package/dist/chunk-EHH6ZDK6.cjs.map +1 -0
  10. package/dist/{chunk-Q6QLU6YQ.js → chunk-TQIYK5OA.js} +9 -2
  11. package/dist/chunk-TQIYK5OA.js.map +1 -0
  12. package/dist/{chunk-UB2ANTWF.js → chunk-UD6IG2PG.js} +3 -3
  13. package/dist/{chunk-UB2ANTWF.js.map → chunk-UD6IG2PG.js.map} +1 -1
  14. package/dist/{chunk-F24JURN2.cjs → chunk-VYQ6N5SI.cjs} +4 -4
  15. package/dist/{chunk-F24JURN2.cjs.map → chunk-VYQ6N5SI.cjs.map} +1 -1
  16. package/dist/index.cjs +14 -14
  17. package/dist/index.js +3 -3
  18. package/dist/interaction/index.cjs +83 -19
  19. package/dist/interaction/index.cjs.map +1 -1
  20. package/dist/interaction/index.d.cts +2 -1
  21. package/dist/interaction/index.d.ts +2 -1
  22. package/dist/interaction/index.js +83 -20
  23. package/dist/interaction/index.js.map +1 -1
  24. package/dist/stickyflow-diagram.global.js +1 -1
  25. package/dist/stickyflow-diagram.global.js.map +1 -1
  26. package/dist/viewer/index.cjs +7 -7
  27. package/dist/viewer/index.js +2 -2
  28. package/dist/web-component/index.cjs +4 -4
  29. package/dist/web-component/index.js +2 -2
  30. package/package.json +1 -1
  31. package/dist/chunk-5G3BEXQU.cjs.map +0 -1
  32. package/dist/chunk-Q6QLU6YQ.js.map +0 -1
@@ -221,6 +221,7 @@ declare function applyLinkReconnectChange(sfl: string, event: LinkReconnectEvent
221
221
 
222
222
  declare function applyLinkSegmentChange(sfl: string, event: LinkSegmentChangeEvent): string;
223
223
 
224
+ declare function applyMoveChanges(sfl: string, events: readonly MoveChangeEvent[]): string;
224
225
  declare function applyMoveChange(sfl: string, event: MoveChangeEvent): string;
225
226
 
226
227
  declare function applyPathPointChange(sfl: string, event: PathPointChangeEvent): string;
@@ -280,4 +281,4 @@ interface EditingOptions {
280
281
  }
281
282
  declare function bindEditing(viewer: Viewer, options?: EditingOptions): Interaction;
282
283
 
283
- export { type ChartValueChangeEvent, type ColorEditHandle, type ColorPickerTheme, type ColorPickerThemeOption, type ColorPopoverHandle, type ColorPopoverOptions, type DeleteEvent, type EditableRules, type EditingOptions, type InsertCanvasObjectOptions, type InsertConnectionOptions, type InsertLinkOptions, type InsertPathOptions, type Interaction, type InteractionEventMap, type InteractionEventName, type IsometricQuickDuplicateDirection, type LinkReconnectEvent, type LinkSegmentChangeEvent, type LinkToEvent, type MoveChangeEvent, type PathDrawCompleteEvent, type PathDrawOptions, type PathPoint, type PathPointChangeEvent, type PickerValue, type PropertyChangeEvent, type PropertyEditingHandle, type PropertyEditingOptions, type PropertyValue, type QuickDuplicateEvent, type QuickDuplicateOptions, type RemoveCanvasObjectOptions, type ResizeChangeEvent, type SankeyNodeMoveEvent, type SankeyNodeRenameEvent, type TextChangeEvent, Unsubscribe, applyChartValueChange, applyLinkReconnectChange, applyLinkSegmentChange, applyMoveChange, applyPathPointChange, applyPropertyChange, applyQuickDuplicateChange, applyResizeChange, applySankeyNodeMoveChange, applySankeyNodeRenameChange, applyTextChange, bindEditing, bindPropertyEditing, cssBackground, formatPickerValue, insertCanvasObject, insertConnection, insertLink, insertPath, openColorPopover, readGradientValue, removeCanvasObject, removeLink, resolveTheme, seedFrom };
284
+ export { type ChartValueChangeEvent, type ColorEditHandle, type ColorPickerTheme, type ColorPickerThemeOption, type ColorPopoverHandle, type ColorPopoverOptions, type DeleteEvent, type EditableRules, type EditingOptions, type InsertCanvasObjectOptions, type InsertConnectionOptions, type InsertLinkOptions, type InsertPathOptions, type Interaction, type InteractionEventMap, type InteractionEventName, type IsometricQuickDuplicateDirection, type LinkReconnectEvent, type LinkSegmentChangeEvent, type LinkToEvent, type MoveChangeEvent, type PathDrawCompleteEvent, type PathDrawOptions, type PathPoint, type PathPointChangeEvent, type PickerValue, type PropertyChangeEvent, type PropertyEditingHandle, type PropertyEditingOptions, type PropertyValue, type QuickDuplicateEvent, type QuickDuplicateOptions, type RemoveCanvasObjectOptions, type ResizeChangeEvent, type SankeyNodeMoveEvent, type SankeyNodeRenameEvent, type TextChangeEvent, Unsubscribe, applyChartValueChange, applyLinkReconnectChange, applyLinkSegmentChange, applyMoveChange, applyMoveChanges, applyPathPointChange, applyPropertyChange, applyQuickDuplicateChange, applyResizeChange, applySankeyNodeMoveChange, applySankeyNodeRenameChange, applyTextChange, bindEditing, bindPropertyEditing, cssBackground, formatPickerValue, insertCanvasObject, insertConnection, insertLink, insertPath, openColorPopover, readGradientValue, removeCanvasObject, removeLink, resolveTheme, seedFrom };
@@ -221,6 +221,7 @@ declare function applyLinkReconnectChange(sfl: string, event: LinkReconnectEvent
221
221
 
222
222
  declare function applyLinkSegmentChange(sfl: string, event: LinkSegmentChangeEvent): string;
223
223
 
224
+ declare function applyMoveChanges(sfl: string, events: readonly MoveChangeEvent[]): string;
224
225
  declare function applyMoveChange(sfl: string, event: MoveChangeEvent): string;
225
226
 
226
227
  declare function applyPathPointChange(sfl: string, event: PathPointChangeEvent): string;
@@ -280,4 +281,4 @@ interface EditingOptions {
280
281
  }
281
282
  declare function bindEditing(viewer: Viewer, options?: EditingOptions): Interaction;
282
283
 
283
- export { type ChartValueChangeEvent, type ColorEditHandle, type ColorPickerTheme, type ColorPickerThemeOption, type ColorPopoverHandle, type ColorPopoverOptions, type DeleteEvent, type EditableRules, type EditingOptions, type InsertCanvasObjectOptions, type InsertConnectionOptions, type InsertLinkOptions, type InsertPathOptions, type Interaction, type InteractionEventMap, type InteractionEventName, type IsometricQuickDuplicateDirection, type LinkReconnectEvent, type LinkSegmentChangeEvent, type LinkToEvent, type MoveChangeEvent, type PathDrawCompleteEvent, type PathDrawOptions, type PathPoint, type PathPointChangeEvent, type PickerValue, type PropertyChangeEvent, type PropertyEditingHandle, type PropertyEditingOptions, type PropertyValue, type QuickDuplicateEvent, type QuickDuplicateOptions, type RemoveCanvasObjectOptions, type ResizeChangeEvent, type SankeyNodeMoveEvent, type SankeyNodeRenameEvent, type TextChangeEvent, Unsubscribe, applyChartValueChange, applyLinkReconnectChange, applyLinkSegmentChange, applyMoveChange, applyPathPointChange, applyPropertyChange, applyQuickDuplicateChange, applyResizeChange, applySankeyNodeMoveChange, applySankeyNodeRenameChange, applyTextChange, bindEditing, bindPropertyEditing, cssBackground, formatPickerValue, insertCanvasObject, insertConnection, insertLink, insertPath, openColorPopover, readGradientValue, removeCanvasObject, removeLink, resolveTheme, seedFrom };
284
+ export { type ChartValueChangeEvent, type ColorEditHandle, type ColorPickerTheme, type ColorPickerThemeOption, type ColorPopoverHandle, type ColorPopoverOptions, type DeleteEvent, type EditableRules, type EditingOptions, type InsertCanvasObjectOptions, type InsertConnectionOptions, type InsertLinkOptions, type InsertPathOptions, type Interaction, type InteractionEventMap, type InteractionEventName, type IsometricQuickDuplicateDirection, type LinkReconnectEvent, type LinkSegmentChangeEvent, type LinkToEvent, type MoveChangeEvent, type PathDrawCompleteEvent, type PathDrawOptions, type PathPoint, type PathPointChangeEvent, type PickerValue, type PropertyChangeEvent, type PropertyEditingHandle, type PropertyEditingOptions, type PropertyValue, type QuickDuplicateEvent, type QuickDuplicateOptions, type RemoveCanvasObjectOptions, type ResizeChangeEvent, type SankeyNodeMoveEvent, type SankeyNodeRenameEvent, type TextChangeEvent, Unsubscribe, applyChartValueChange, applyLinkReconnectChange, applyLinkSegmentChange, applyMoveChange, applyMoveChanges, applyPathPointChange, applyPropertyChange, applyQuickDuplicateChange, applyResizeChange, applySankeyNodeMoveChange, applySankeyNodeRenameChange, applyTextChange, bindEditing, bindPropertyEditing, cssBackground, formatPickerValue, insertCanvasObject, insertConnection, insertLink, insertPath, openColorPopover, readGradientValue, removeCanvasObject, removeLink, resolveTheme, seedFrom };
@@ -834,6 +834,14 @@ function trackDrag(node, onMove, onEnd) {
834
834
  var CHANNELS = ["r", "g", "b"];
835
835
  var GAP_BELOW_ANCHOR = 6;
836
836
  var VIEWPORT_MARGIN = 8;
837
+ function buildEyedropper(parent) {
838
+ const button = el("button", "sf-cp-eyedropper", parent);
839
+ button.type = "button";
840
+ button.title = "Pick a color from the screen";
841
+ button.setAttribute("aria-label", "Pick a color from the screen");
842
+ button.innerHTML = '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 22l1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="M15 6l3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4z"/></svg>';
843
+ return button;
844
+ }
837
845
  function buildSolidControls(root) {
838
846
  const area = el("div", "sf-cp-area", root);
839
847
  const matrix = el("div", "sf-cp-matrix", area);
@@ -857,6 +865,7 @@ function buildSolidControls(root) {
857
865
  const hexInput = el("input", "sf-cp-text", hexRow);
858
866
  hexInput.type = "text";
859
867
  hexInput.spellcheck = false;
868
+ const eyedropper = "EyeDropper" in window ? buildEyedropper(hexRow) : void 0;
860
869
  return {
861
870
  matrix,
862
871
  matrixCursor,
@@ -867,7 +876,8 @@ function buildSolidControls(root) {
867
876
  alphaRow,
868
877
  alphaRange,
869
878
  alphaNumber,
870
- hexInput
879
+ hexInput,
880
+ eyedropper
871
881
  };
872
882
  }
873
883
  function buildGradientControls(root, lockStops) {
@@ -1004,6 +1014,20 @@ function bindAngle(picker) {
1004
1014
  angleNumber.addEventListener("input", (event) => applyAngle(picker, read(event)));
1005
1015
  angleNumber.addEventListener("change", () => commit(picker));
1006
1016
  }
1017
+ function bindEyedropper(picker) {
1018
+ const { eyedropper } = picker.view;
1019
+ eyedropper?.addEventListener("click", async () => {
1020
+ const Dropper = window.EyeDropper;
1021
+ try {
1022
+ const hex = normalizeHex((await new Dropper().open()).sRGBHex);
1023
+ if (hex) {
1024
+ applyHex(picker, hex);
1025
+ commit(picker);
1026
+ }
1027
+ } catch {
1028
+ }
1029
+ });
1030
+ }
1007
1031
  function bindPickerEvents(picker) {
1008
1032
  const { view } = picker;
1009
1033
  const disposers = bindAreas(picker);
@@ -1015,6 +1039,7 @@ function bindPickerEvents(picker) {
1015
1039
  }
1016
1040
  bindAlpha(picker);
1017
1041
  bindHex(picker);
1042
+ bindEyedropper(picker);
1018
1043
  bindAngle(picker);
1019
1044
  return disposers;
1020
1045
  }
@@ -1312,6 +1337,25 @@ var FIELDS_CSS = `
1312
1337
  }
1313
1338
 
1314
1339
  .sf-cp-number,
1340
+ .sf-cp-eyedropper {
1341
+ flex: none;
1342
+ display: grid;
1343
+ place-items: center;
1344
+ width: 24px;
1345
+ height: 24px;
1346
+ margin-left: auto;
1347
+ padding: 0;
1348
+ border: 1px solid var(--sf-cp-field-border);
1349
+ border-radius: 6px;
1350
+ background: var(--sf-cp-field-bg);
1351
+ color: var(--sf-cp-fg);
1352
+ cursor: pointer;
1353
+ }
1354
+
1355
+ .sf-cp-eyedropper:hover {
1356
+ background: var(--sf-cp-hover);
1357
+ }
1358
+
1315
1359
  .sf-cp-text {
1316
1360
  flex: none;
1317
1361
  width: 52px;
@@ -5609,6 +5653,10 @@ function applyGeometryPreview(drag, bounds) {
5609
5653
  return;
5610
5654
  }
5611
5655
  drag.geometryNodes.forEach((node, index) => {
5656
+ if (node.tagName.toLowerCase() === "image") {
5657
+ applyCompositeScale([node], drag.startBounds, bounds, [drag.baseTransforms[index]]);
5658
+ return;
5659
+ }
5612
5660
  applySingleNodeBounds(node, drag.kind, applyInset(bounds, drag.insets[index] ?? NO_INSET));
5613
5661
  });
5614
5662
  }
@@ -7193,29 +7241,44 @@ function movePathPoints(lines, range, dx, dy) {
7193
7241
  );
7194
7242
  replacePropertyValue(lines, span, shifted);
7195
7243
  }
7196
- function applyMoveChange(sfl, event) {
7244
+ function applyMoveChanges(sfl, events) {
7197
7245
  const state = sflToCanvasState(sfl);
7198
- const canvasObject = state.canvasObjects.find((candidate) => candidate.id === event.owner.id);
7199
- if (!canvasObject) {
7200
- return sfl;
7201
- }
7202
- const parent = canvasObject.parentFrameId ? state.canvasObjects.find((candidate) => candidate.id === canvasObject.parentFrameId) : void 0;
7203
- const originX = parent?.x ?? 0;
7204
- const originY = parent?.y ?? 0;
7205
7246
  const lines = sfl.split("\n");
7206
- const range = findOwnerBlock(lines, event.owner.id);
7207
- if (!range) {
7208
- return sfl;
7209
- }
7210
- if (event.owner.role === "path") {
7211
- movePathPoints(lines, range, event.dx, event.dy);
7212
- return lines.join("\n");
7247
+ const parents = new Map(state.canvasObjects.map((candidate) => [candidate.id, candidate.parentFrameId]));
7248
+ const moving = new Set(events.map((event) => event.owner.id));
7249
+ const hasMovingAncestor = (id) => {
7250
+ const seen = /* @__PURE__ */ new Set();
7251
+ for (let parent = parents.get(id); parent && !seen.has(parent); parent = parents.get(parent)) {
7252
+ if (moving.has(parent)) {
7253
+ return true;
7254
+ }
7255
+ seen.add(parent);
7256
+ }
7257
+ return false;
7258
+ };
7259
+ for (const event of events) {
7260
+ if (hasMovingAncestor(event.owner.id)) {
7261
+ continue;
7262
+ }
7263
+ const canvasObject = state.canvasObjects.find((candidate) => candidate.id === event.owner.id);
7264
+ const range = canvasObject ? findOwnerBlock(lines, event.owner.id) : null;
7265
+ if (!canvasObject || !range) {
7266
+ continue;
7267
+ }
7268
+ if (event.owner.role === "path") {
7269
+ movePathPoints(lines, range, event.dx, event.dy);
7270
+ continue;
7271
+ }
7272
+ const parent = canvasObject.parentFrameId ? state.canvasObjects.find((candidate) => candidate.id === canvasObject.parentFrameId) : void 0;
7273
+ setOrInsertLayoutTuples(lines, range, [
7274
+ ["position", canvasObject.x - (parent?.x ?? 0) + event.dx, canvasObject.y - (parent?.y ?? 0) + event.dy]
7275
+ ]);
7213
7276
  }
7214
- setOrInsertLayoutTuples(lines, range, [
7215
- ["position", canvasObject.x - originX + event.dx, canvasObject.y - originY + event.dy]
7216
- ]);
7217
7277
  return lines.join("\n");
7218
7278
  }
7279
+ function applyMoveChange(sfl, event) {
7280
+ return applyMoveChanges(sfl, [event]);
7281
+ }
7219
7282
 
7220
7283
  // src/runtime/interaction/sflPatch/changes/pathPointChange.ts
7221
7284
  function applyPathPointChange(sfl, event) {
@@ -7792,6 +7855,6 @@ function bindEditing(viewer, options = {}) {
7792
7855
  };
7793
7856
  }
7794
7857
 
7795
- export { applyChartValueChange, applyLinkReconnectChange, applyLinkSegmentChange, applyMoveChange, applyPathPointChange, applyPropertyChange, applyQuickDuplicateChange, applyResizeChange, applySankeyNodeMoveChange, applySankeyNodeRenameChange, applyTextChange, bindEditing, bindPropertyEditing, cssBackground, formatPickerValue, insertCanvasObject, insertConnection, insertLink, insertPath, openColorPopover, readGradientValue, removeCanvasObject, removeLink, resolveTheme, seedFrom };
7858
+ export { applyChartValueChange, applyLinkReconnectChange, applyLinkSegmentChange, applyMoveChange, applyMoveChanges, applyPathPointChange, applyPropertyChange, applyQuickDuplicateChange, applyResizeChange, applySankeyNodeMoveChange, applySankeyNodeRenameChange, applyTextChange, bindEditing, bindPropertyEditing, cssBackground, formatPickerValue, insertCanvasObject, insertConnection, insertLink, insertPath, openColorPopover, readGradientValue, removeCanvasObject, removeLink, resolveTheme, seedFrom };
7796
7859
  //# sourceMappingURL=index.js.map
7797
7860
  //# sourceMappingURL=index.js.map