@xyflow/system 0.0.16 → 0.0.17

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.
@@ -1,3 +1,4 @@
1
+ import { CoordinateExtent } from '../types';
1
2
  import { getPointerPosition } from '../utils';
2
3
  import { ControlPosition } from './types';
3
4
  type GetResizeDirectionParams = {
@@ -42,32 +43,30 @@ type StartValues = PrevValues & {
42
43
  aspectRatio: number;
43
44
  };
44
45
  /**
45
- * Calculates new width & height of node after resize based on pointer position
46
+ * Calculates new width & height and x & y of node after resize based on pointer position
47
+ * @description - Buckle up, this is a chunky one! If you want to determine the new dimensions of a node after a resize,
48
+ * you have to account for all possible restrictions: min/max width/height of the node, the maximum extent the node is allowed
49
+ * to move in (in this case: resize into) determined by the parent node, the minimal extent determined by child nodes
50
+ * with expandParent or extent: 'parent' set and oh yeah, these things also have to work with keepAspectRatio!
51
+ * The way this is done is by determining how much each of these restricting actually restricts the resize and then applying the
52
+ * strongest restriction. Because the resize affects x, y and width, height and width, height of a opposing side with keepAspectRatio,
53
+ * the resize amount is always kept in distX & distY amount (the distance in mouse movement)
54
+ * Instead of clamping each value, we first calculate the biggest 'clamp' (for the lack of a better name) and then apply it to all values.
46
55
  * @param startValues - starting values of resize
47
56
  * @param controlDirection - dimensions affected by the resize
48
57
  * @param pointerPosition - the current pointer position corrected for snapping
49
58
  * @param boundaries - minimum and maximum dimensions of the node
50
59
  * @param keepAspectRatio - prevent changes of asprect ratio
51
- * @returns width: new width of node, height: new height of node
60
+ * @returns x, y, width and height of the node after resize
52
61
  */
53
62
  export declare function getDimensionsAfterResize(startValues: StartValues, controlDirection: ReturnType<typeof getControlDirection>, pointerPosition: ReturnType<typeof getPointerPosition>, boundaries: {
54
63
  minWidth: number;
55
64
  maxWidth: number;
56
65
  minHeight: number;
57
66
  maxHeight: number;
58
- }, keepAspectRatio: boolean): {
67
+ }, keepAspectRatio: boolean, extent?: CoordinateExtent, childExtent?: CoordinateExtent): {
59
68
  width: number;
60
69
  height: number;
61
- };
62
- /**
63
- * Determines new x & y position of node after resize based on new width & height
64
- * @param startValues - starting values of resize
65
- * @param controlDirection - dimensions affected by the resize
66
- * @param width - new width of node
67
- * @param height - new height of node
68
- * @returns x: new x position of node, y: new y position of node
69
- */
70
- export declare function getPositionAfterResize(startValues: StartValues, controlDirection: ReturnType<typeof getControlDirection>, width: number, height: number): {
71
70
  x: number;
72
71
  y: number;
73
72
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/xyresizer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,wBAAwB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,SAAS,EACT,MAAM,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,GACT,EAAE,wBAAwB,YAc1B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,eAAe;;;;;EAYnE;AAED,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,WAAW,GAAG,UAAU,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAg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M,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,WAAW,GAAG,UAAU,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAkBF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,EACxD,eAAe,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,EACtD,UAAU,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EACxF,eAAe,EAAE,OAAO,EACxB,MAAM,CAAC,EAAE,gBAAgB,EACzB,WAAW,CAAC,EAAE,gBAAgB;;;;;EAoJ/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyflow/system",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "xyflow core system that powers React Flow and Svelte Flow.",
5
5
  "keywords": [
6
6
  "node-based UI",
@@ -48,8 +48,8 @@
48
48
  "@types/node": "^18.7.16",
49
49
  "typescript": "5.1.3",
50
50
  "@xyflow/eslint-config": "0.0.0",
51
- "@xyflow/tsconfig": "0.0.0",
52
- "@xyflow/rollup-config": "0.0.0"
51
+ "@xyflow/rollup-config": "0.0.0",
52
+ "@xyflow/tsconfig": "0.0.0"
53
53
  },
54
54
  "rollup": {
55
55
  "globals": {