@dnd-kit/modifiers 6.0.0 → 6.0.1-next-2022102925018

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @dnd-kit/modifiers
2
2
 
3
+ ## 6.0.1-next-2022102925018
4
+
5
+ ### Patch Changes
6
+
7
+ - [#823](https://github.com/clauderic/dnd-kit/pull/823) [`b065c37`](https://github.com/clauderic/dnd-kit/commit/b065c3750078bee43caa5a79f54196d4612d2375) Thanks [@DaniGuardiola](https://github.com/DaniGuardiola)! - Add missing peer dependency to @dnd-kit/modifiers
8
+
3
9
  ## 6.0.0
4
10
 
5
11
  ### Patch Changes
@@ -5,17 +5,21 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var utilities = require('@dnd-kit/utilities');
6
6
 
7
7
  function createSnapModifier(gridSize) {
8
- return ({
9
- transform
10
- }) => ({ ...transform,
11
- x: Math.ceil(transform.x / gridSize) * gridSize,
12
- y: Math.ceil(transform.y / gridSize) * gridSize
13
- });
8
+ return _ref => {
9
+ let {
10
+ transform
11
+ } = _ref;
12
+ return { ...transform,
13
+ x: Math.ceil(transform.x / gridSize) * gridSize,
14
+ y: Math.ceil(transform.y / gridSize) * gridSize
15
+ };
16
+ };
14
17
  }
15
18
 
16
- const restrictToHorizontalAxis = ({
17
- transform
18
- }) => {
19
+ const restrictToHorizontalAxis = _ref => {
20
+ let {
21
+ transform
22
+ } = _ref;
19
23
  return { ...transform,
20
24
  y: 0
21
25
  };
@@ -40,11 +44,13 @@ function restrictToBoundingRect(transform, rect, boundingRect) {
40
44
  return value;
41
45
  }
42
46
 
43
- const restrictToParentElement = ({
44
- containerNodeRect,
45
- draggingNodeRect,
46
- transform
47
- }) => {
47
+ const restrictToParentElement = _ref => {
48
+ let {
49
+ containerNodeRect,
50
+ draggingNodeRect,
51
+ transform
52
+ } = _ref;
53
+
48
54
  if (!draggingNodeRect || !containerNodeRect) {
49
55
  return transform;
50
56
  }
@@ -52,11 +58,12 @@ const restrictToParentElement = ({
52
58
  return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);
53
59
  };
54
60
 
55
- const restrictToFirstScrollableAncestor = ({
56
- draggingNodeRect,
57
- transform,
58
- scrollableAncestorRects
59
- }) => {
61
+ const restrictToFirstScrollableAncestor = _ref => {
62
+ let {
63
+ draggingNodeRect,
64
+ transform,
65
+ scrollableAncestorRects
66
+ } = _ref;
60
67
  const firstScrollableAncestorRect = scrollableAncestorRects[0];
61
68
 
62
69
  if (!draggingNodeRect || !firstScrollableAncestorRect) {
@@ -66,19 +73,22 @@ const restrictToFirstScrollableAncestor = ({
66
73
  return restrictToBoundingRect(transform, draggingNodeRect, firstScrollableAncestorRect);
67
74
  };
68
75
 
69
- const restrictToVerticalAxis = ({
70
- transform
71
- }) => {
76
+ const restrictToVerticalAxis = _ref => {
77
+ let {
78
+ transform
79
+ } = _ref;
72
80
  return { ...transform,
73
81
  x: 0
74
82
  };
75
83
  };
76
84
 
77
- const restrictToWindowEdges = ({
78
- transform,
79
- draggingNodeRect,
80
- windowRect
81
- }) => {
85
+ const restrictToWindowEdges = _ref => {
86
+ let {
87
+ transform,
88
+ draggingNodeRect,
89
+ windowRect
90
+ } = _ref;
91
+
82
92
  if (!draggingNodeRect || !windowRect) {
83
93
  return transform;
84
94
  }
@@ -86,11 +96,13 @@ const restrictToWindowEdges = ({
86
96
  return restrictToBoundingRect(transform, draggingNodeRect, windowRect);
87
97
  };
88
98
 
89
- const snapCenterToCursor = ({
90
- activatorEvent,
91
- draggingNodeRect,
92
- transform
93
- }) => {
99
+ const snapCenterToCursor = _ref => {
100
+ let {
101
+ activatorEvent,
102
+ draggingNodeRect,
103
+ transform
104
+ } = _ref;
105
+
94
106
  if (draggingNodeRect && activatorEvent) {
95
107
  const activatorCoordinates = utilities.getEventCoordinates(activatorEvent);
96
108
 
@@ -1 +1 @@
1
- {"version":3,"file":"modifiers.cjs.development.js","sources":["../src/createSnapModifier.ts","../src/restrictToHorizontalAxis.ts","../src/utilities/restrictToBoundingRect.ts","../src/restrictToParentElement.ts","../src/restrictToFirstScrollableAncestor.ts","../src/restrictToVerticalAxis.ts","../src/restrictToWindowEdges.ts","../src/snapCenterToCursor.ts"],"sourcesContent":["import type {Modifier} from '@dnd-kit/core';\n\nexport function createSnapModifier(gridSize: number): Modifier {\n return ({transform}) => ({\n ...transform,\n x: Math.ceil(transform.x / gridSize) * gridSize,\n y: Math.ceil(transform.y / gridSize) * gridSize,\n });\n}\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToHorizontalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n y: 0,\n };\n};\n","import type {ClientRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ClientRect,\n boundingRect: ClientRect\n): Transform {\n const value = {\n ...transform,\n };\n\n if (rect.top + transform.y <= boundingRect.top) {\n value.y = boundingRect.top - rect.top;\n } else if (\n rect.bottom + transform.y >=\n boundingRect.top + boundingRect.height\n ) {\n value.y = boundingRect.top + boundingRect.height - rect.bottom;\n }\n\n if (rect.left + transform.x <= boundingRect.left) {\n value.x = boundingRect.left - rect.left;\n } else if (\n rect.right + transform.x >=\n boundingRect.left + boundingRect.width\n ) {\n value.x = boundingRect.left + boundingRect.width - rect.right;\n }\n\n return value;\n}\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToParentElement: Modifier = ({\n containerNodeRect,\n draggingNodeRect,\n transform,\n}) => {\n if (!draggingNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToFirstScrollableAncestor: Modifier = ({\n draggingNodeRect,\n transform,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!draggingNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n draggingNodeRect,\n firstScrollableAncestorRect\n );\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToVerticalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n x: 0,\n };\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToWindowEdges: Modifier = ({\n transform,\n draggingNodeRect,\n windowRect,\n}) => {\n if (!draggingNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, windowRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {getEventCoordinates} from '@dnd-kit/utilities';\n\nexport const snapCenterToCursor: Modifier = ({\n activatorEvent,\n draggingNodeRect,\n transform,\n}) => {\n if (draggingNodeRect && activatorEvent) {\n const activatorCoordinates = getEventCoordinates(activatorEvent);\n\n if (!activatorCoordinates) {\n return transform;\n }\n\n const offsetX = activatorCoordinates.x - draggingNodeRect.left;\n const offsetY = activatorCoordinates.y - draggingNodeRect.top;\n\n return {\n ...transform,\n x: transform.x + offsetX - draggingNodeRect.width / 2,\n y: transform.y + offsetY - draggingNodeRect.height / 2,\n };\n }\n\n return transform;\n};\n"],"names":["createSnapModifier","gridSize","transform","x","Math","ceil","y","restrictToHorizontalAxis","restrictToBoundingRect","rect","boundingRect","value","top","bottom","height","left","right","width","restrictToParentElement","containerNodeRect","draggingNodeRect","restrictToFirstScrollableAncestor","scrollableAncestorRects","firstScrollableAncestorRect","restrictToVerticalAxis","restrictToWindowEdges","windowRect","snapCenterToCursor","activatorEvent","activatorCoordinates","getEventCoordinates","offsetX","offsetY"],"mappings":";;;;;;SAEgBA,mBAAmBC;AACjC,SAAO,CAAC;AAACC,IAAAA;AAAD,GAAD,MAAkB,EACvB,GAAGA,SADoB;AAEvBC,IAAAA,CAAC,EAAEC,IAAI,CAACC,IAAL,CAAUH,SAAS,CAACC,CAAV,GAAcF,QAAxB,IAAo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AACzB,aAAO3B,SAAP;AACD;;AAED,UAAM6B,OAAO,GAAGF,oBAAoB,CAAC1B,CAArB,GAAyBiB,gBAAgB,CAACL,IAA1D;AACA,UAAMiB,OAAO,GAAGH,oBAAoB,CAACvB,CAArB,GAAyBc,gBAAgB,CAACR,GAA1D;AAEA,WAAO,EACL,GAAGV,SADE;AAELC,MAAAA,CAAC,EAAED,SAAS,CAACC,CAAV,GAAc4B,OAAd,GAAwBX,gBAAgB,CAACH,KAAjB,GAAyB,CAF/C;AAGLX,MAAAA,CAAC,EAAEJ,SAAS,CAACI,CAAV,GAAc0B,OAAd,GAAwBZ,gBAAgB,CAACN,MAAjB,GAA0B;AAHhD,KAAP;AAKD;;AAED,SAAOZ,SAAP;AACD,CAvBM;;;;;;;;;;"}
1
+ {"version":3,"file":"modifiers.cjs.development.js","sources":["../src/createSnapModifier.ts","../src/restrictToHorizontalAxis.ts","../src/utilities/restrictToBoundingRect.ts","../src/restrictToParentElement.ts","../src/restrictToFirstScrollableAncestor.ts","../src/restrictToVerticalAxis.ts","../src/restrictToWindowEdges.ts","../src/snapCenterToCursor.ts"],"sourcesContent":["import type {Modifier} from '@dnd-kit/core';\n\nexport function createSnapModifier(gridSize: number): Modifier {\n return ({transform}) => ({\n ...transform,\n x: Math.ceil(transform.x / gridSize) * gridSize,\n y: Math.ceil(transform.y / gridSize) * gridSize,\n });\n}\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToHorizontalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n y: 0,\n };\n};\n","import type {ClientRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ClientRect,\n boundingRect: ClientRect\n): Transform {\n const value = {\n ...transform,\n };\n\n if (rect.top + transform.y <= boundingRect.top) {\n value.y = boundingRect.top - rect.top;\n } else if (\n rect.bottom + transform.y >=\n boundingRect.top + boundingRect.height\n ) {\n value.y = boundingRect.top + boundingRect.height - rect.bottom;\n }\n\n if (rect.left + transform.x <= boundingRect.left) {\n value.x = boundingRect.left - rect.left;\n } else if (\n rect.right + transform.x >=\n boundingRect.left + boundingRect.width\n ) {\n value.x = boundingRect.left + boundingRect.width - rect.right;\n }\n\n return value;\n}\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToParentElement: Modifier = ({\n containerNodeRect,\n draggingNodeRect,\n transform,\n}) => {\n if (!draggingNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToFirstScrollableAncestor: Modifier = ({\n draggingNodeRect,\n transform,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!draggingNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n draggingNodeRect,\n firstScrollableAncestorRect\n );\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToVerticalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n x: 0,\n };\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToWindowEdges: Modifier = ({\n transform,\n draggingNodeRect,\n windowRect,\n}) => {\n if (!draggingNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, windowRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {getEventCoordinates} from '@dnd-kit/utilities';\n\nexport const snapCenterToCursor: Modifier = ({\n activatorEvent,\n draggingNodeRect,\n transform,\n}) => {\n if (draggingNodeRect && activatorEvent) {\n const activatorCoordinates = getEventCoordinates(activatorEvent);\n\n if (!activatorCoordinates) {\n return transform;\n }\n\n const offsetX = activatorCoordinates.x - draggingNodeRect.left;\n const offsetY = activatorCoordinates.y - draggingNodeRect.top;\n\n return {\n ...transform,\n x: transform.x + offsetX - draggingNodeRect.width / 2,\n y: transform.y + offsetY - draggingNodeRect.height / 2,\n };\n }\n\n return transform;\n};\n"],"names":["createSnapModifier","gridSize","transform","x","Math","ceil","y","restrictToHorizontalAxis","restrictToBoundingRect","rect","boundingRect","value","top","bottom","height","left","right","width","restrictToParentElement","containerNodeRect","draggingNodeRect","restrictToFirstScrollableAncestor","scrollableAncestorRects","firstScrollableAncestorRect","restrictToVerticalAxis","restrictToWindowEdges","windowRect","snapCenterToCursor","activatorEvent","activatorCoordinates","getEventCoordinates","offsetX","offsetY"],"mappings":";;;;;;SAEgBA,mBAAmBC;EACjC,OAAO;IAAA,IAAC;MAACC;KAAF;IAAA,OAAkB,EACvB,GAAGA,SADoB;MAEvBC,CAAC,EAAEC,IAAI,CAACC,IAAL,CAAUH,SAAS,CAACC,CAAV,GAAcF,QAAxB,IAAoCA,QAFhB;MAGvBK,CAAC,EAAEF,IAAI,CAACC,IAAL,CAAUH,SAAS,CAACI,CAAV,GAAcL,QAAxB,IAAoCA;KAHlC;GAAP;AAKD;;MCNYM,wBAAwB,GAAa;MAAC;IAACL;;EAClD,OAAO,EACL,GAAGA,SADE;IAELI,CAAC,EAAE;GAFL;AAID,CALM;;SCCSE,uBACdN,WACAO,MACAC;EAEA,MAAMC,KAAK,GAAG,EACZ,GAAGT;GADL;;EAIA,IAAIO,IAAI,CAACG,GAAL,GAAWV,SAAS,CAACI,CAArB,IAA0BI,YAAY,CAACE,GAA3C,EAAgD;IAC9CD,KAAK,CAACL,CAAN,GAAUI,YAAY,CAACE,GAAb,GAAmBH,IAAI,CAACG,GAAlC;GADF,MAEO,IACLH,IAAI,CAACI,MAAL,GAAcX,SAAS,CAACI,CAAxB,IACAI,YAAY,CAACE,GAAb,GAAmBF,YAAY,CAACI,MAF3B,EAGL;IACAH,KAAK,CAACL,CAAN,GAAUI,YAAY,CAACE,GAAb,GAAmBF,YAAY,CAACI,MAAhC,GAAyCL,IAAI,CA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AAOM,sBAAsB,CAACN,SAAD,EAAYkB,gBAAZ,EAA8BM,UAA9B,CAA7B;AACD,CAVM;;MCDMC,kBAAkB,GAAa;MAAC;IAC3CC,cAD2C;IAE3CR,gBAF2C;IAG3ClB;;;EAEA,IAAIkB,gBAAgB,IAAIQ,cAAxB,EAAwC;IACtC,MAAMC,oBAAoB,GAAGC,6BAAmB,CAACF,cAAD,CAAhD;;IAEA,IAAI,CAACC,oBAAL,EAA2B;MACzB,OAAO3B,SAAP;;;IAGF,MAAM6B,OAAO,GAAGF,oBAAoB,CAAC1B,CAArB,GAAyBiB,gBAAgB,CAACL,IAA1D;IACA,MAAMiB,OAAO,GAAGH,oBAAoB,CAACvB,CAArB,GAAyBc,gBAAgB,CAACR,GAA1D;IAEA,OAAO,EACL,GAAGV,SADE;MAELC,CAAC,EAAED,SAAS,CAACC,CAAV,GAAc4B,OAAd,GAAwBX,gBAAgB,CAACH,KAAjB,GAAyB,CAF/C;MAGLX,CAAC,EAAEJ,SAAS,CAACI,CAAV,GAAc0B,OAAd,GAAwBZ,gBAAgB,CAACN,MAAjB,GAA0B;KAHvD;;;EAOF,OAAOZ,SAAP;AACD,CAvBM;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@dnd-kit/utilities");function e(t,e,r){const o={...t};return e.top+t.y<=r.top?o.y=r.top-e.top:e.bottom+t.y>=r.top+r.height&&(o.y=r.top+r.height-e.bottom),e.left+t.x<=r.left?o.x=r.left-e.left:e.right+t.x>=r.left+r.width&&(o.x=r.left+r.width-e.right),o}exports.createSnapModifier=function(t){return({transform:e})=>({...e,x:Math.ceil(e.x/t)*t,y:Math.ceil(e.y/t)*t})},exports.restrictToFirstScrollableAncestor=({draggingNodeRect:t,transform:r,scrollableAncestorRects:o})=>{const i=o[0];return t&&i?e(r,t,i):r},exports.restrictToHorizontalAxis=({transform:t})=>({...t,y:0}),exports.restrictToParentElement=({containerNodeRect:t,draggingNodeRect:r,transform:o})=>r&&t?e(o,r,t):o,exports.restrictToVerticalAxis=({transform:t})=>({...t,x:0}),exports.restrictToWindowEdges=({transform:t,draggingNodeRect:r,windowRect:o})=>r&&o?e(t,r,o):t,exports.snapCenterToCursor=({activatorEvent:e,draggingNodeRect:r,transform:o})=>{if(r&&e){const i=t.getEventCoordinates(e);if(!i)return o;const n=i.x-r.left,s=i.y-r.top;return{...o,x:o.x+n-r.width/2,y:o.y+s-r.height/2}}return o};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@dnd-kit/utilities");function e(t,e,r){const o={...t};return e.top+t.y<=r.top?o.y=r.top-e.top:e.bottom+t.y>=r.top+r.height&&(o.y=r.top+r.height-e.bottom),e.left+t.x<=r.left?o.x=r.left-e.left:e.right+t.x>=r.left+r.width&&(o.x=r.left+r.width-e.right),o}exports.createSnapModifier=function(t){return e=>{let{transform:r}=e;return{...r,x:Math.ceil(r.x/t)*t,y:Math.ceil(r.y/t)*t}}},exports.restrictToFirstScrollableAncestor=t=>{let{draggingNodeRect:r,transform:o,scrollableAncestorRects:n}=t;const i=n[0];return r&&i?e(o,r,i):o},exports.restrictToHorizontalAxis=t=>{let{transform:e}=t;return{...e,y:0}},exports.restrictToParentElement=t=>{let{containerNodeRect:r,draggingNodeRect:o,transform:n}=t;return o&&r?e(n,o,r):n},exports.restrictToVerticalAxis=t=>{let{transform:e}=t;return{...e,x:0}},exports.restrictToWindowEdges=t=>{let{transform:r,draggingNodeRect:o,windowRect:n}=t;return o&&n?e(r,o,n):r},exports.snapCenterToCursor=e=>{let{activatorEvent:r,draggingNodeRect:o,transform:n}=e;if(o&&r){const e=t.getEventCoordinates(r);if(!e)return n;const i=e.x-o.left,s=e.y-o.top;return{...n,x:n.x+i-o.width/2,y:n.y+s-o.height/2}}return n};
2
2
  //# sourceMappingURL=modifiers.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modifiers.cjs.production.min.js","sources":["../src/utilities/restrictToBoundingRect.ts","../src/createSnapModifier.ts","../src/restrictToFirstScrollableAncestor.ts","../src/restrictToHorizontalAxis.ts","../src/restrictToParentElement.ts","../src/restrictToVerticalAxis.ts","../src/restrictToWindowEdges.ts","../src/snapCenterToCursor.ts"],"sourcesContent":["import type {ClientRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ClientRect,\n boundingRect: ClientRect\n): Transform {\n const value = {\n ...transform,\n };\n\n if (rect.top + transform.y <= boundingRect.top) {\n value.y = boundingRect.top - rect.top;\n } else if (\n rect.bottom + transform.y >=\n boundingRect.top + boundingRect.height\n ) {\n value.y = boundingRect.top + boundingRect.height - rect.bottom;\n }\n\n if (rect.left + transform.x <= boundingRect.left) {\n value.x = boundingRect.left - rect.left;\n } else if (\n rect.right + transform.x >=\n boundingRect.left + boundingRect.width\n ) {\n value.x = boundingRect.left + boundingRect.width - rect.right;\n }\n\n return value;\n}\n","import type {Modifier} from '@dnd-kit/core';\n\nexport function createSnapModifier(gridSize: number): Modifier {\n return ({transform}) => ({\n ...transform,\n x: Math.ceil(transform.x / gridSize) * gridSize,\n y: Math.ceil(transform.y / gridSize) * gridSize,\n });\n}\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToFirstScrollableAncestor: Modifier = ({\n draggingNodeRect,\n transform,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!draggingNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n draggingNodeRect,\n firstScrollableAncestorRect\n );\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToHorizontalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n y: 0,\n };\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToParentElement: Modifier = ({\n containerNodeRect,\n draggingNodeRect,\n transform,\n}) => {\n if (!draggingNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToVerticalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n x: 0,\n };\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToWindowEdges: Modifier = ({\n transform,\n draggingNodeRect,\n windowRect,\n}) => {\n if (!draggingNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, windowRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {getEventCoordinates} from '@dnd-kit/utilities';\n\nexport const snapCenterToCursor: Modifier = ({\n activatorEvent,\n draggingNodeRect,\n transform,\n}) => {\n if (draggingNodeRect && activatorEvent) {\n const activatorCoordinates = getEventCoordinates(activatorEvent);\n\n if (!activatorCoordinates) {\n return transform;\n }\n\n const offsetX = activatorCoordinates.x - draggingNodeRect.left;\n const offsetY = activatorCoordinates.y - draggingNodeRect.top;\n\n return {\n ...transform,\n x: transform.x + offsetX - draggingNodeRect.width / 2,\n y: transform.y + offsetY - draggingNodeRect.height / 2,\n };\n }\n\n return transform;\n};\n"],"names":["restrictToBoundingRect","transform","rect","boundingRect","value","top","y","bottom","height","left","x","right","width","gridSize","Math","ceil","draggingNodeRect","scrollableAncestorRects","firstScrollableAncestorRect","containerNodeRect","windowRect","activatorEvent","activatorCoordinates","getEventCoordinates","offsetX","offsetY"],"mappings":"iHAGgBA,EACdC,EACAC,EACAC,SAEMC,EAAQ,IACTH,UAGDC,EAAKG,IAAMJ,EAAUK,GAAKH,EAAaE,IACzCD,EAAME,EAAIH,EAAaE,IAAMH,EAAKG,IAElCH,EAAKK,OAASN,EAAUK,GACxBH,EAAaE,IAAMF,EAAaK,SAEhCJ,EAAME,EAAIH,EAAaE,IAAMF,EAAaK,OAASN,EAAKK,QAGtDL,EAAKO,KAAOR,EAAUS,GAAKP,EAAaM,KAC1CL,EAAMM,EAAIP,EAAaM,KAAOP,EAAKO,KAEnCP,EAAKS,MAAQV,EAAUS,GACvBP,EAAaM,KAAON,EAAaS,QAEjCR,EAAMM,EAAIP,EAAaM,KAAON,EAAaS,MAAQV,EAAKS,OAGnDP,sCC5B0BS,SAC1B,EAAEZ,UAAAA,UACJA,EACHS,EAAGI,KAAKC,KAAKd,EAAUS,EAAIG,GAAYA,EACvCP,EAAGQ,KAAKC,KAAKd,EAAUK,EAAIO,GAAYA,+CCHgB,EACzDG,iBAAAA,EACAf,UAAAA,EACAgB,wBAAAA,YAEMC,EAA8BD,EAAwB,UAEvDD,GAAqBE,EAInBlB,EACLC,EACAe,EACAE,GANOjB,oCCTuC,EAAEA,UAAAA,MAC3C,IACFA,EACHK,EAAG,oCCF0C,EAC/Ca,kBAAAA,EACAH,iBAAAA,EACAf,UAAAA,KAEKe,GAAqBG,EAInBnB,EAAuBC,EAAWe,EAAkBG,GAHlDlB,iCCPqC,EAAEA,UAAAA,MACzC,IACFA,EACHS,EAAG,kCCDwC,EAC7CT,UAAAA,EACAe,iBAAAA,EACAI,WAAAA,KAEKJ,GAAqBI,EAInBpB,EAAuBC,EAAWe,EAAkBI,GAHlDnB,6BCPiC,EAC1CoB,eAAAA,EACAL,iBAAAA,EACAf,UAAAA,SAEIe,GAAoBK,EAAgB,OAChCC,EAAuBC,sBAAoBF,OAE5CC,SACIrB,QAGHuB,EAAUF,EAAqBZ,EAAIM,EAAiBP,KACpDgB,EAAUH,EAAqBhB,EAAIU,EAAiBX,UAEnD,IACFJ,EACHS,EAAGT,EAAUS,EAAIc,EAAUR,EAAiBJ,MAAQ,EACpDN,EAAGL,EAAUK,EAAImB,EAAUT,EAAiBR,OAAS,UAIlDP"}
1
+ {"version":3,"file":"modifiers.cjs.production.min.js","sources":["../src/utilities/restrictToBoundingRect.ts","../src/createSnapModifier.ts","../src/restrictToFirstScrollableAncestor.ts","../src/restrictToHorizontalAxis.ts","../src/restrictToParentElement.ts","../src/restrictToVerticalAxis.ts","../src/restrictToWindowEdges.ts","../src/snapCenterToCursor.ts"],"sourcesContent":["import type {ClientRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ClientRect,\n boundingRect: ClientRect\n): Transform {\n const value = {\n ...transform,\n };\n\n if (rect.top + transform.y <= boundingRect.top) {\n value.y = boundingRect.top - rect.top;\n } else if (\n rect.bottom + transform.y >=\n boundingRect.top + boundingRect.height\n ) {\n value.y = boundingRect.top + boundingRect.height - rect.bottom;\n }\n\n if (rect.left + transform.x <= boundingRect.left) {\n value.x = boundingRect.left - rect.left;\n } else if (\n rect.right + transform.x >=\n boundingRect.left + boundingRect.width\n ) {\n value.x = boundingRect.left + boundingRect.width - rect.right;\n }\n\n return value;\n}\n","import type {Modifier} from '@dnd-kit/core';\n\nexport function createSnapModifier(gridSize: number): Modifier {\n return ({transform}) => ({\n ...transform,\n x: Math.ceil(transform.x / gridSize) * gridSize,\n y: Math.ceil(transform.y / gridSize) * gridSize,\n });\n}\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToFirstScrollableAncestor: Modifier = ({\n draggingNodeRect,\n transform,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!draggingNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n draggingNodeRect,\n firstScrollableAncestorRect\n );\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToHorizontalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n y: 0,\n };\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToParentElement: Modifier = ({\n containerNodeRect,\n draggingNodeRect,\n transform,\n}) => {\n if (!draggingNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToVerticalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n x: 0,\n };\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToWindowEdges: Modifier = ({\n transform,\n draggingNodeRect,\n windowRect,\n}) => {\n if (!draggingNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, windowRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {getEventCoordinates} from '@dnd-kit/utilities';\n\nexport const snapCenterToCursor: Modifier = ({\n activatorEvent,\n draggingNodeRect,\n transform,\n}) => {\n if (draggingNodeRect && activatorEvent) {\n const activatorCoordinates = getEventCoordinates(activatorEvent);\n\n if (!activatorCoordinates) {\n return transform;\n }\n\n const offsetX = activatorCoordinates.x - draggingNodeRect.left;\n const offsetY = activatorCoordinates.y - draggingNodeRect.top;\n\n return {\n ...transform,\n x: transform.x + offsetX - draggingNodeRect.width / 2,\n y: transform.y + offsetY - draggingNodeRect.height / 2,\n };\n }\n\n return transform;\n};\n"],"names":["restrictToBoundingRect","transform","rect","boundingRect","value","top","y","bottom","height","left","x","right","width","gridSize","_ref","Math","ceil","draggingNodeRect","scrollableAncestorRects","firstScrollableAncestorRect","containerNodeRect","windowRect","activatorEvent","activatorCoordinates","getEventCoordinates","offsetX","offsetY"],"mappings":"iHAGgBA,EACdC,EACAC,EACAC,GAEA,MAAMC,EAAQ,IACTH,GAqBL,OAlBIC,EAAKG,IAAMJ,EAAUK,GAAKH,EAAaE,IACzCD,EAAME,EAAIH,EAAaE,IAAMH,EAAKG,IAElCH,EAAKK,OAASN,EAAUK,GACxBH,EAAaE,IAAMF,EAAaK,SAEhCJ,EAAME,EAAIH,EAAaE,IAAMF,EAAaK,OAASN,EAAKK,QAGtDL,EAAKO,KAAOR,EAAUS,G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1,17 +1,21 @@
1
1
  import { getEventCoordinates } from '@dnd-kit/utilities';
2
2
 
3
3
  function createSnapModifier(gridSize) {
4
- return ({
5
- transform
6
- }) => ({ ...transform,
7
- x: Math.ceil(transform.x / gridSize) * gridSize,
8
- y: Math.ceil(transform.y / gridSize) * gridSize
9
- });
4
+ return _ref => {
5
+ let {
6
+ transform
7
+ } = _ref;
8
+ return { ...transform,
9
+ x: Math.ceil(transform.x / gridSize) * gridSize,
10
+ y: Math.ceil(transform.y / gridSize) * gridSize
11
+ };
12
+ };
10
13
  }
11
14
 
12
- const restrictToHorizontalAxis = ({
13
- transform
14
- }) => {
15
+ const restrictToHorizontalAxis = _ref => {
16
+ let {
17
+ transform
18
+ } = _ref;
15
19
  return { ...transform,
16
20
  y: 0
17
21
  };
@@ -36,11 +40,13 @@ function restrictToBoundingRect(transform, rect, boundingRect) {
36
40
  return value;
37
41
  }
38
42
 
39
- const restrictToParentElement = ({
40
- containerNodeRect,
41
- draggingNodeRect,
42
- transform
43
- }) => {
43
+ const restrictToParentElement = _ref => {
44
+ let {
45
+ containerNodeRect,
46
+ draggingNodeRect,
47
+ transform
48
+ } = _ref;
49
+
44
50
  if (!draggingNodeRect || !containerNodeRect) {
45
51
  return transform;
46
52
  }
@@ -48,11 +54,12 @@ const restrictToParentElement = ({
48
54
  return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);
49
55
  };
50
56
 
51
- const restrictToFirstScrollableAncestor = ({
52
- draggingNodeRect,
53
- transform,
54
- scrollableAncestorRects
55
- }) => {
57
+ const restrictToFirstScrollableAncestor = _ref => {
58
+ let {
59
+ draggingNodeRect,
60
+ transform,
61
+ scrollableAncestorRects
62
+ } = _ref;
56
63
  const firstScrollableAncestorRect = scrollableAncestorRects[0];
57
64
 
58
65
  if (!draggingNodeRect || !firstScrollableAncestorRect) {
@@ -62,19 +69,22 @@ const restrictToFirstScrollableAncestor = ({
62
69
  return restrictToBoundingRect(transform, draggingNodeRect, firstScrollableAncestorRect);
63
70
  };
64
71
 
65
- const restrictToVerticalAxis = ({
66
- transform
67
- }) => {
72
+ const restrictToVerticalAxis = _ref => {
73
+ let {
74
+ transform
75
+ } = _ref;
68
76
  return { ...transform,
69
77
  x: 0
70
78
  };
71
79
  };
72
80
 
73
- const restrictToWindowEdges = ({
74
- transform,
75
- draggingNodeRect,
76
- windowRect
77
- }) => {
81
+ const restrictToWindowEdges = _ref => {
82
+ let {
83
+ transform,
84
+ draggingNodeRect,
85
+ windowRect
86
+ } = _ref;
87
+
78
88
  if (!draggingNodeRect || !windowRect) {
79
89
  return transform;
80
90
  }
@@ -82,11 +92,13 @@ const restrictToWindowEdges = ({
82
92
  return restrictToBoundingRect(transform, draggingNodeRect, windowRect);
83
93
  };
84
94
 
85
- const snapCenterToCursor = ({
86
- activatorEvent,
87
- draggingNodeRect,
88
- transform
89
- }) => {
95
+ const snapCenterToCursor = _ref => {
96
+ let {
97
+ activatorEvent,
98
+ draggingNodeRect,
99
+ transform
100
+ } = _ref;
101
+
90
102
  if (draggingNodeRect && activatorEvent) {
91
103
  const activatorCoordinates = getEventCoordinates(activatorEvent);
92
104
 
@@ -1 +1 @@
1
- {"version":3,"file":"modifiers.esm.js","sources":["../src/createSnapModifier.ts","../src/restrictToHorizontalAxis.ts","../src/utilities/restrictToBoundingRect.ts","../src/restrictToParentElement.ts","../src/restrictToFirstScrollableAncestor.ts","../src/restrictToVerticalAxis.ts","../src/restrictToWindowEdges.ts","../src/snapCenterToCursor.ts"],"sourcesContent":["import type {Modifier} from '@dnd-kit/core';\n\nexport function createSnapModifier(gridSize: number): Modifier {\n return ({transform}) => ({\n ...transform,\n x: Math.ceil(transform.x / gridSize) * gridSize,\n y: Math.ceil(transform.y / gridSize) * gridSize,\n });\n}\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToHorizontalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n y: 0,\n };\n};\n","import type {ClientRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ClientRect,\n boundingRect: ClientRect\n): Transform {\n const value = {\n ...transform,\n };\n\n if (rect.top + transform.y <= boundingRect.top) {\n value.y = boundingRect.top - rect.top;\n } else if (\n rect.bottom + transform.y >=\n boundingRect.top + boundingRect.height\n ) {\n value.y = boundingRect.top + boundingRect.height - rect.bottom;\n }\n\n if (rect.left + transform.x <= boundingRect.left) {\n value.x = boundingRect.left - rect.left;\n } else if (\n rect.right + transform.x >=\n boundingRect.left + boundingRect.width\n ) {\n value.x = boundingRect.left + boundingRect.width - rect.right;\n }\n\n return value;\n}\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToParentElement: Modifier = ({\n containerNodeRect,\n draggingNodeRect,\n transform,\n}) => {\n if (!draggingNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToFirstScrollableAncestor: Modifier = ({\n draggingNodeRect,\n transform,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!draggingNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n draggingNodeRect,\n firstScrollableAncestorRect\n );\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToVerticalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n x: 0,\n };\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToWindowEdges: Modifier = ({\n transform,\n draggingNodeRect,\n windowRect,\n}) => {\n if (!draggingNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, windowRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {getEventCoordinates} from '@dnd-kit/utilities';\n\nexport const snapCenterToCursor: Modifier = ({\n activatorEvent,\n draggingNodeRect,\n transform,\n}) => {\n if (draggingNodeRect && activatorEvent) {\n const activatorCoordinates = getEventCoordinates(activatorEvent);\n\n if (!activatorCoordinates) {\n return transform;\n }\n\n const offsetX = activatorCoordinates.x - draggingNodeRect.left;\n const offsetY = activatorCoordinates.y - draggingNodeRect.top;\n\n return {\n ...transform,\n x: transform.x + offsetX - draggingNodeRect.width / 2,\n y: transform.y + offsetY - draggingNodeRect.height / 2,\n };\n }\n\n return transform;\n};\n"],"names":["createSnapModifier","gridSize","transform","x","Math","ceil","y","restrictToHorizontalAxis","restrictToBoundingRect","rect","boundingRect","value","top","bottom","height","left","right","width","restrictToParentElement","containerNodeRect","draggingNodeRect","restrictToFirstScrollableAncestor","scrollableAncestorRects","firstScrollableAncestorRect","restrictToVerticalAxis","restrictToWindowEdges","windowRect","snapCenterToCursor","activatorEvent","activatorCoordinates","getEventCoordinates","offsetX","offsetY"],"mappings":";;SAEgBA,mBAAmBC;AACjC,SAAO,CAAC;AAACC,IAAAA;AAAD,GAAD,MAAkB,EACvB,GAAGA,SADoB;AAEvBC,IAAAA,CAAC,EAAEC,IAAI,CAACC,IAAL,CAAUH,SAAS,CAACC,CAAV,GAAcF,QAAxB,IAAoCA,QAFhB;AAGvBK,IAAAA,CAAC,EAAEF,IAAI,CAACC,IAAL,CAAUH,SAAS,CAACI,CAAV,GAAcL,QAAxB,IAAoCA;AAHhB,GAAlB,CAAP;AAKD;;MCNYM,wBAAwB,GAAa,CAAC;AAACL,EAAAA;AAAD,CAAD;AAChD,SAAO,EACL,GAAGA,SADE;AAELI,IAAAA,CAAC,EAAE;AAFE,GAAP;AAID,CALM;;SCCSE,uBACdN,WACAO,MACAC;AAEA,QAAMC,KAAK,GAAG,EACZ,GAAGT;AADS,GAAd;;AAIA,MAAIO,IAAI,CAACG,GAAL,GAAWV,SAAS,CAACI,CAArB,IAA0BI,YAAY,CAACE,GAA3C,EAAgD;AAC9CD,IAA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AOZ,SAAP;AACD,CAvBM;;;;"}
1
+ {"version":3,"file":"modifiers.esm.js","sources":["../src/createSnapModifier.ts","../src/restrictToHorizontalAxis.ts","../src/utilities/restrictToBoundingRect.ts","../src/restrictToParentElement.ts","../src/restrictToFirstScrollableAncestor.ts","../src/restrictToVerticalAxis.ts","../src/restrictToWindowEdges.ts","../src/snapCenterToCursor.ts"],"sourcesContent":["import type {Modifier} from '@dnd-kit/core';\n\nexport function createSnapModifier(gridSize: number): Modifier {\n return ({transform}) => ({\n ...transform,\n x: Math.ceil(transform.x / gridSize) * gridSize,\n y: Math.ceil(transform.y / gridSize) * gridSize,\n });\n}\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToHorizontalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n y: 0,\n };\n};\n","import type {ClientRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ClientRect,\n boundingRect: ClientRect\n): Transform {\n const value = {\n ...transform,\n };\n\n if (rect.top + transform.y <= boundingRect.top) {\n value.y = boundingRect.top - rect.top;\n } else if (\n rect.bottom + transform.y >=\n boundingRect.top + boundingRect.height\n ) {\n value.y = boundingRect.top + boundingRect.height - rect.bottom;\n }\n\n if (rect.left + transform.x <= boundingRect.left) {\n value.x = boundingRect.left - rect.left;\n } else if (\n rect.right + transform.x >=\n boundingRect.left + boundingRect.width\n ) {\n value.x = boundingRect.left + boundingRect.width - rect.right;\n }\n\n return value;\n}\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToParentElement: Modifier = ({\n containerNodeRect,\n draggingNodeRect,\n transform,\n}) => {\n if (!draggingNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToFirstScrollableAncestor: Modifier = ({\n draggingNodeRect,\n transform,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!draggingNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n draggingNodeRect,\n firstScrollableAncestorRect\n );\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nexport const restrictToVerticalAxis: Modifier = ({transform}) => {\n return {\n ...transform,\n x: 0,\n };\n};\n","import type {Modifier} from '@dnd-kit/core';\n\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToWindowEdges: Modifier = ({\n transform,\n draggingNodeRect,\n windowRect,\n}) => {\n if (!draggingNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, draggingNodeRect, windowRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {getEventCoordinates} from '@dnd-kit/utilities';\n\nexport const snapCenterToCursor: Modifier = ({\n activatorEvent,\n draggingNodeRect,\n transform,\n}) => {\n if (draggingNodeRect && activatorEvent) {\n const activatorCoordinates = getEventCoordinates(activatorEvent);\n\n if (!activatorCoordinates) {\n return transform;\n }\n\n const offsetX = activatorCoordinates.x - draggingNodeRect.left;\n const offsetY = activatorCoordinates.y - draggingNodeRect.top;\n\n return {\n ...transform,\n x: transform.x + offsetX - draggingNodeRect.width / 2,\n y: transform.y + offsetY - draggingNodeRect.height / 2,\n };\n }\n\n return transform;\n};\n"],"names":["createSnapModifier","gridSize","transform","x","Math","ceil","y","restrictToHorizontalAxis","restrictToBoundingRect","rect","boundingRect","value","top","bottom","height","left","right","width","restrictToParentElement","containerNodeRect","draggingNodeRect","restrictToFirstScrollableAncestor","scrollableAncestorRects","firstScrollableAncestorRect","restrictToVerticalAxis","restrictToWindowEdges","windowRect","snapCenterToCursor","activatorEvent","activatorCoordinates","getEventCoordinates","offsetX","offsetY"],"mappings":";;SAEgBA,mBAAmBC;EACjC,OAAO;IAAA,IAAC;MAACC;KAAF;IAAA,OAAkB,EACv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R,GAA1D;IAEA,OAAO,EACL,GAAGV,SADE;MAELC,CAAC,EAAED,SAAS,CAACC,CAAV,GAAc4B,OAAd,GAAwBX,gBAAgB,CAACH,KAAjB,GAAyB,CAF/C;MAGLX,CAAC,EAAEJ,SAAS,CAACI,CAAV,GAAc0B,OAAd,GAAwBZ,gBAAgB,CAACN,MAAjB,GAA0B;KAHvD;;;EAOF,OAAOZ,SAAP;AACD,CAvBM;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnd-kit/modifiers",
3
- "version": "6.0.0",
3
+ "version": "6.0.1-next-2022102925018",
4
4
  "description": "Translate modifier presets for use with `@dnd-kit` packages.",
5
5
  "author": "Claudéric Demers",
6
6
  "license": "MIT",
@@ -30,7 +30,8 @@
30
30
  "tslib": "^2.0.0"
31
31
  },
32
32
  "peerDependencies": {
33
- "@dnd-kit/core": "^6.0.0"
33
+ "@dnd-kit/core": "^6.0.0",
34
+ "react": ">=16.8.0"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@dnd-kit/core": "^6.0.0"