@dnd-kit/modifiers 1.0.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # @dnd-kit/modifiers
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`d39ab11`](https://github.com/clauderic/dnd-kit/commit/d39ab1112f9be78d467b2dfe488a7ea931d93767)]:
8
+ - @dnd-kit/core@3.1.0
9
+
10
+ ## 2.1.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`68960c4`](https://github.com/clauderic/dnd-kit/commit/68960c490f50962b47a57663ee0625d7704173ec) [#295](https://github.com/clauderic/dnd-kit/pull/295) Thanks [@akhmadullin](https://github.com/akhmadullin)! - `@dnd-kit/core` is now a `peerDependency` rather than a `dependency` for other `@dnd-kit` packages that depend on it, such as `@dnd-kit/sortable` and `@dnd-kit/modifiers`. This is done to avoid issues with multiple versions of `@dnd-kit/core` being installed by some package managers such as Yarn 2.
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [[`ae398de`](https://github.com/clauderic/dnd-kit/commit/ae398de012aee28f5e3bec10b438153d00f65630), [`8b938ce`](https://github.com/clauderic/dnd-kit/commit/8b938ceb158c67e9fdc4616351d1a3291ac614c3)]:
19
+ - @dnd-kit/core@3.0.4
20
+
21
+ ## 2.0.0
22
+
23
+ ### Major Changes
24
+
25
+ - [`a9d92cf`](https://github.com/clauderic/dnd-kit/commit/a9d92cf1fa35dd957e6c5915a13dfd2af134c103) [#174](https://github.com/clauderic/dnd-kit/pull/174) Thanks [@clauderic](https://github.com/clauderic)! - Distributed assets now only target modern browsers. [Browserlist](https://github.com/browserslist/browserslist) config:
26
+
27
+ ```
28
+ defaults
29
+ last 2 version
30
+ not IE 11
31
+ not dead
32
+ ```
33
+
34
+ If you need to support older browsers, include the appropriate polyfills in your project's build process.
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies [[`b7355d1`](https://github.com/clauderic/dnd-kit/commit/b7355d19d9e15bb1972627bb622c2487ddec82ad), [`a9d92cf`](https://github.com/clauderic/dnd-kit/commit/a9d92cf1fa35dd957e6c5915a13dfd2af134c103), [`b406cb9`](https://github.com/clauderic/dnd-kit/commit/b406cb9251beef8677d05c45ec42bab7581a86dc)]:
39
+ - @dnd-kit/core@3.0.0
40
+ - @dnd-kit/utilities@2.0.0
41
+
42
+ ## 1.0.5
43
+
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies [[`8583825`](https://github.com/clauderic/dnd-kit/commit/8583825380bc4d7c36e076be30bb5ca3fd20a26b)]:
47
+ - @dnd-kit/core@2.0.0
48
+
3
49
  ## 1.0.4
4
50
 
5
51
  ### Patch Changes
@@ -2,43 +2,26 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _extends() {
6
- _extends = Object.assign || function (target) {
7
- for (var i = 1; i < arguments.length; i++) {
8
- var source = arguments[i];
9
-
10
- for (var key in source) {
11
- if (Object.prototype.hasOwnProperty.call(source, key)) {
12
- target[key] = source[key];
13
- }
14
- }
15
- }
16
-
17
- return target;
18
- };
19
-
20
- return _extends.apply(this, arguments);
21
- }
22
-
23
5
  function createSnapModifier(gridSize) {
24
- return function (_ref) {
25
- var transform = _ref.transform;
26
- return _extends({}, transform, {
27
- x: Math.ceil(transform.x / gridSize) * gridSize,
28
- y: Math.ceil(transform.y / gridSize) * gridSize
29
- });
30
- };
6
+ return ({
7
+ transform
8
+ }) => ({ ...transform,
9
+ x: Math.ceil(transform.x / gridSize) * gridSize,
10
+ y: Math.ceil(transform.y / gridSize) * gridSize
11
+ });
31
12
  }
32
13
 
33
- var restrictToHorizontalAxis = function restrictToHorizontalAxis(_ref) {
34
- var transform = _ref.transform;
35
- return _extends({}, transform, {
14
+ const restrictToHorizontalAxis = ({
15
+ transform
16
+ }) => {
17
+ return { ...transform,
36
18
  y: 0
37
- });
19
+ };
38
20
  };
39
21
 
40
22
  function restrictToBoundingRect(transform, rect, boundingRect) {
41
- var value = _extends({}, transform);
23
+ const value = { ...transform
24
+ };
42
25
 
43
26
  if (rect.top + transform.y <= boundingRect.top) {
44
27
  value.y = boundingRect.top - rect.top;
@@ -55,11 +38,11 @@ function restrictToBoundingRect(transform, rect, boundingRect) {
55
38
  return value;
56
39
  }
57
40
 
58
- var restrictToParentElement = function restrictToParentElement(_ref) {
59
- var transform = _ref.transform,
60
- activeNodeRect = _ref.activeNodeRect,
61
- containerNodeRect = _ref.containerNodeRect;
62
-
41
+ const restrictToParentElement = ({
42
+ transform,
43
+ activeNodeRect,
44
+ containerNodeRect
45
+ }) => {
63
46
  if (!activeNodeRect || !containerNodeRect) {
64
47
  return transform;
65
48
  }
@@ -67,11 +50,12 @@ var restrictToParentElement = function restrictToParentElement(_ref) {
67
50
  return restrictToBoundingRect(transform, activeNodeRect, containerNodeRect);
68
51
  };
69
52
 
70
- var restrictToFirstScrollableAncestor = function restrictToFirstScrollableAncestor(_ref) {
71
- var transform = _ref.transform,
72
- activeNodeRect = _ref.activeNodeRect,
73
- scrollableAncestorRects = _ref.scrollableAncestorRects;
74
- var firstScrollableAncestorRect = scrollableAncestorRects[0];
53
+ const restrictToFirstScrollableAncestor = ({
54
+ transform,
55
+ activeNodeRect,
56
+ scrollableAncestorRects
57
+ }) => {
58
+ const firstScrollableAncestorRect = scrollableAncestorRects[0];
75
59
 
76
60
  if (!activeNodeRect || !firstScrollableAncestorRect) {
77
61
  return transform;
@@ -80,18 +64,19 @@ var restrictToFirstScrollableAncestor = function restrictToFirstScrollableAncest
80
64
  return restrictToBoundingRect(transform, activeNodeRect, firstScrollableAncestorRect);
81
65
  };
82
66
 
83
- var restrictToVerticalAxis = function restrictToVerticalAxis(_ref) {
84
- var transform = _ref.transform;
85
- return _extends({}, transform, {
67
+ const restrictToVerticalAxis = ({
68
+ transform
69
+ }) => {
70
+ return { ...transform,
86
71
  x: 0
87
- });
72
+ };
88
73
  };
89
74
 
90
- var restrictToWindowEdges = function restrictToWindowEdges(_ref) {
91
- var transform = _ref.transform,
92
- activeNodeRect = _ref.activeNodeRect,
93
- windowRect = _ref.windowRect;
94
-
75
+ const restrictToWindowEdges = ({
76
+ transform,
77
+ activeNodeRect,
78
+ windowRect
79
+ }) => {
95
80
  if (!activeNodeRect || !windowRect) {
96
81
  return transform;
97
82
  }
@@ -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"],"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 {ViewRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ViewRect,\n boundingRect: ViewRect\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 transform,\n activeNodeRect,\n containerNodeRect,\n}) => {\n if (!activeNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, containerNodeRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToFirstScrollableAncestor: Modifier = ({\n transform,\n activeNodeRect,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!activeNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n activeNodeRect,\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 activeNodeRect,\n windowRect,\n}) => {\n if (!activeNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, windowRect);\n};\n"],"names":["createSnapModifier","gridSize","transform","x","Math","ceil","y","restrictToHorizontalAxis","restrictToBoundingRect","rect","boundingRect","value","top","bottom","height","left","right","width","restrictToParentElement","activeNodeRect","containerNodeRect","restrictToFirstScrollableAncestor","scrollableAncestorRects","firstScrollableAncestorRect","restrictToVerticalAxis","restrictToWindowEdges","windowRect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;SAEgBA,mBAAmBC;AACjC,SAAO;AAAA,QAAEC,SAAF,QAAEA,SAAF;AAAA,wBACFA,SADE;AAELC,MAAAA,CAAC,EAAEC,IAAI,CAACC,IAAL,CAAUH,SAAS,CAACC,CAAV,GAAcF,QAAxB,IAAoCA,QAFlC;AAGLK,MAAAA,CAAC,EAAEF,IAAI,CAACC,IAAL,CAAUH,SAAS,CAACI,CAAV,GAAcL,QAAxB,IAAoCA;AAHlC;AAAA,GAAP;AAKD;;ICNYM,wBAAwB,GAAa,SAArCA,wBAAqC;MAAEL,iB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AA7B;AACD,CAVM;;ICAMC,iCAAiC,GAAa,SAA9CA,iCAA8C;MACzDnB,iBAAAA;MACAiB,sBAAAA;MACAG,+BAAAA;AAEA,MAAMC,2BAA2B,GAAGD,uBAAuB,CAAC,CAAD,CAA3D;;AAEA,MAAI,CAACH,cAAD,IAAmB,CAACI,2BAAxB,EAAqD;AACnD,WAAOrB,SAAP;AACD;;AAED,SAAOM,sBAAsB,CAC3BN,SAD2B,EAE3BiB,cAF2B,EAG3BI,2BAH2B,CAA7B;AAKD,CAhBM;;ICDMC,sBAAsB,GAAa,SAAnCA,sBAAmC;MAAEtB,iBAAAA;AAChD,sBACKA,SADL;AAEEC,IAAAA,CAAC,EAAE;AAFL;AAID,CALM;;ICEMsB,qBAAqB,GAAa,SAAlCA,qBAAkC;MAC7CvB,iBAAAA;MACAiB,sBAAAA;MACAO,kBAAAA;;AAEA,MAAI,CAACP,cAAD,IAAmB,CAACO,UAAxB,EAAoC;AAClC,WAAOxB,SAAP;AACD;;AAED,SAAOM,sBAAsB,CAACN,SAAD,EAAYiB,cAAZ,EAA4BO,UAA5B,CAA7B;AACD,CAVM;;;;;;;;;"}
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"],"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 {ViewRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ViewRect,\n boundingRect: ViewRect\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 transform,\n activeNodeRect,\n containerNodeRect,\n}) => {\n if (!activeNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, containerNodeRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToFirstScrollableAncestor: Modifier = ({\n transform,\n activeNodeRect,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!activeNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n activeNodeRect,\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 activeNodeRect,\n windowRect,\n}) => {\n if (!activeNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, windowRect);\n};\n"],"names":["createSnapModifier","gridSize","transform","x","Math","ceil","y","restrictToHorizontalAxis","restrictToBoundingRect","rect","boundingRect","value","top","bottom","height","left","right","width","restrictToParentElement","activeNodeRect","containerNodeRect","restrictToFirstScrollableAncestor","scrollableAncestorRects","firstScrollableAncestorRect","restrictToVerticalAxis","restrictToWindowEdges","windowRect"],"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,IAAAA,KAAK,CAACL,CAAN,GAAUI,YAAY,CAACE,GAAb,GAAmBH,IAAI,CAACG,GAAlC;AACD,GAFD,MAEO,IACLH,IAAI,CAACI,MAAL,GAAcX,SAAS,CAACI,CAAxB,IACAI,YAAY,CAACE,GAAb,GAAmBF,YAAY,CAACI,MAF3B,EAGL;AACAH,IAAAA,KAAK,CAACL,CAAN,GAAUI,YAAY,CAACE,GAAb,GAAmBF,YAAY,CAACI,MAAhC,GAAyCL,IAAI,CAACI,MAAxD;AACD;;AAED,MAAIJ,IAAI,CAACM,IAAL,GAAYb,SAAS,CAACC,CAAtB,IAA2BO,YAAY,CAACK,IAA5C,EAAkD;AAChDJ,IAAAA,KAAK,CAACR,CAAN,GAAUO,YAAY,CAACK,IAAb,GAAoB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N,SAAD,EAAYiB,cAAZ,EAA4BO,UAA5B,CAA7B;AACD,CAVM;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";function t(){return(t=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t}).apply(this,arguments)}function r(r,e,o){var n=t({},r);return e.top+r.y<=o.top?n.y=o.top-e.top:e.bottom+r.y>=o.top+o.height&&(n.y=o.top+o.height-e.bottom),e.left+r.x<=o.left?n.x=o.left-e.left:e.right+r.x>=o.left+o.width&&(n.x=o.left+o.width-e.right),n}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createSnapModifier=function(r){return function(e){var o=e.transform;return t({},o,{x:Math.ceil(o.x/r)*r,y:Math.ceil(o.y/r)*r})}},exports.restrictToFirstScrollableAncestor=function(t){var e=t.transform,o=t.activeNodeRect,n=t.scrollableAncestorRects[0];return o&&n?r(e,o,n):e},exports.restrictToHorizontalAxis=function(r){return t({},r.transform,{y:0})},exports.restrictToParentElement=function(t){var e=t.transform,o=t.activeNodeRect,n=t.containerNodeRect;return o&&n?r(e,o,n):e},exports.restrictToVerticalAxis=function(r){return t({},r.transform,{x:0})},exports.restrictToWindowEdges=function(t){var e=t.transform,o=t.activeNodeRect,n=t.windowRect;return o&&n?r(e,o,n):e};
1
+ "use strict";function t(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}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createSnapModifier=function(t){return({transform:e})=>({...e,x:Math.ceil(e.x/t)*t,y:Math.ceil(e.y/t)*t})},exports.restrictToFirstScrollableAncestor=({transform:e,activeNodeRect:r,scrollableAncestorRects:o})=>{const s=o[0];return r&&s?t(e,r,s):e},exports.restrictToHorizontalAxis=({transform:t})=>({...t,y:0}),exports.restrictToParentElement=({transform:e,activeNodeRect:r,containerNodeRect:o})=>r&&o?t(e,r,o):e,exports.restrictToVerticalAxis=({transform:t})=>({...t,x:0}),exports.restrictToWindowEdges=({transform:e,activeNodeRect:r,windowRect:o})=>r&&o?t(e,r,o):e;
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"],"sourcesContent":["import type {ViewRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ViewRect,\n boundingRect: ViewRect\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 transform,\n activeNodeRect,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!activeNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n activeNodeRect,\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 transform,\n activeNodeRect,\n containerNodeRect,\n}) => {\n if (!activeNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, 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 activeNodeRect,\n windowRect,\n}) => {\n if (!activeNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, windowRect);\n};\n"],"names":["restrictToBoundingRect","transform","rect","boundingRect","value","top","y","bottom","height","left","x","right","width","gridSize","Math","ceil","activeNodeRect","firstScrollableAncestorRect","scrollableAncestorRects","containerNodeRect","windowRect"],"mappings":"qOAGgBA,EACdC,EACAC,EACAC,OAEMC,OACDH,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,6FC5B0BS,UAC1B,gBAAEZ,IAAAA,sBACJA,GACHS,EAAGI,KAAKC,KAAKd,EAAUS,EAAIG,GAAYA,EACvCP,EAAGQ,KAAKC,KAAKd,EAAUK,EAAIO,GAAYA,gDCHgB,gBACzDZ,IAAAA,UACAe,IAAAA,eAGMC,IAFNC,wBAE4D,UAEvDF,GAAmBC,EAIjBjB,EACLC,EACAe,EACAC,GANOhB,oCCTuC,0BAAEA,WAGhDK,EAAG,qCCF0C,gBAC/CL,IAAAA,UACAe,IAAAA,eACAG,IAAAA,yBAEKH,GAAmBG,EAIjBnB,EAAuBC,EAAWe,EAAgBG,GAHhDlB,kCCPqC,0BAAEA,WAG9CS,EAAG,mCCDwC,gBAC7CT,IAAAA,UACAe,IAAAA,eACAI,IAAAA,kBAEKJ,GAAmBI,EAIjBpB,EAAuBC,EAAWe,EAAgBI,GAHhDnB"}
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"],"sourcesContent":["import type {ViewRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ViewRect,\n boundingRect: ViewRect\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 transform,\n activeNodeRect,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!activeNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n activeNodeRect,\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 transform,\n activeNodeRect,\n containerNodeRect,\n}) => {\n if (!activeNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, 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 activeNodeRect,\n windowRect,\n}) => {\n if (!activeNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, windowRect);\n};\n"],"names":["restrictToBoundingRect","transform","rect","boundingRect","value","top","y","bottom","height","left","x","right","width","gridSize","Math","ceil","activeNodeRect","scrollableAncestorRects","firstScrollableAncestorRect","containerNodeRect","windowRect"],"mappings":"sBAGgBA,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,6FC5B0BS,SAC1B,EAAEZ,UAAAA,UACJA,EACHS,EAAGI,KAAKC,KAAKd,EAAUS,EAAIG,GAAYA,EACvCP,EAAGQ,KAAKC,KAAKd,EAAUK,EAAIO,GAAYA,+CCHgB,EACzDZ,UAAAA,EACAe,eAAAA,EACAC,wBAAAA,YAEMC,EAA8BD,EAAwB,UAEvDD,GAAmBE,EAIjBlB,EACLC,EACAe,EACAE,GANOjB,oCCTuC,EAAEA,UAAAA,MAC3C,IACFA,EACHK,EAAG,oCCF0C,EAC/CL,UAAAA,EACAe,eAAAA,EACAG,kBAAAA,KAEKH,GAAmBG,EAIjBnB,EAAuBC,EAAWe,EAAgBG,GAHhDlB,iCCPqC,EAAEA,UAAAA,MACzC,IACFA,EACHS,EAAG,kCCDwC,EAC7CT,UAAAA,EACAe,eAAAA,EACAI,WAAAA,KAEKJ,GAAmBI,EAIjBpB,EAAuBC,EAAWe,EAAgBI,GAHhDnB"}
@@ -1,40 +1,23 @@
1
- function _extends() {
2
- _extends = Object.assign || function (target) {
3
- for (var i = 1; i < arguments.length; i++) {
4
- var source = arguments[i];
5
-
6
- for (var key in source) {
7
- if (Object.prototype.hasOwnProperty.call(source, key)) {
8
- target[key] = source[key];
9
- }
10
- }
11
- }
12
-
13
- return target;
14
- };
15
-
16
- return _extends.apply(this, arguments);
17
- }
18
-
19
1
  function createSnapModifier(gridSize) {
20
- return function (_ref) {
21
- var transform = _ref.transform;
22
- return _extends({}, transform, {
23
- x: Math.ceil(transform.x / gridSize) * gridSize,
24
- y: Math.ceil(transform.y / gridSize) * gridSize
25
- });
26
- };
2
+ return ({
3
+ transform
4
+ }) => ({ ...transform,
5
+ x: Math.ceil(transform.x / gridSize) * gridSize,
6
+ y: Math.ceil(transform.y / gridSize) * gridSize
7
+ });
27
8
  }
28
9
 
29
- var restrictToHorizontalAxis = function restrictToHorizontalAxis(_ref) {
30
- var transform = _ref.transform;
31
- return _extends({}, transform, {
10
+ const restrictToHorizontalAxis = ({
11
+ transform
12
+ }) => {
13
+ return { ...transform,
32
14
  y: 0
33
- });
15
+ };
34
16
  };
35
17
 
36
18
  function restrictToBoundingRect(transform, rect, boundingRect) {
37
- var value = _extends({}, transform);
19
+ const value = { ...transform
20
+ };
38
21
 
39
22
  if (rect.top + transform.y <= boundingRect.top) {
40
23
  value.y = boundingRect.top - rect.top;
@@ -51,11 +34,11 @@ function restrictToBoundingRect(transform, rect, boundingRect) {
51
34
  return value;
52
35
  }
53
36
 
54
- var restrictToParentElement = function restrictToParentElement(_ref) {
55
- var transform = _ref.transform,
56
- activeNodeRect = _ref.activeNodeRect,
57
- containerNodeRect = _ref.containerNodeRect;
58
-
37
+ const restrictToParentElement = ({
38
+ transform,
39
+ activeNodeRect,
40
+ containerNodeRect
41
+ }) => {
59
42
  if (!activeNodeRect || !containerNodeRect) {
60
43
  return transform;
61
44
  }
@@ -63,11 +46,12 @@ var restrictToParentElement = function restrictToParentElement(_ref) {
63
46
  return restrictToBoundingRect(transform, activeNodeRect, containerNodeRect);
64
47
  };
65
48
 
66
- var restrictToFirstScrollableAncestor = function restrictToFirstScrollableAncestor(_ref) {
67
- var transform = _ref.transform,
68
- activeNodeRect = _ref.activeNodeRect,
69
- scrollableAncestorRects = _ref.scrollableAncestorRects;
70
- var firstScrollableAncestorRect = scrollableAncestorRects[0];
49
+ const restrictToFirstScrollableAncestor = ({
50
+ transform,
51
+ activeNodeRect,
52
+ scrollableAncestorRects
53
+ }) => {
54
+ const firstScrollableAncestorRect = scrollableAncestorRects[0];
71
55
 
72
56
  if (!activeNodeRect || !firstScrollableAncestorRect) {
73
57
  return transform;
@@ -76,18 +60,19 @@ var restrictToFirstScrollableAncestor = function restrictToFirstScrollableAncest
76
60
  return restrictToBoundingRect(transform, activeNodeRect, firstScrollableAncestorRect);
77
61
  };
78
62
 
79
- var restrictToVerticalAxis = function restrictToVerticalAxis(_ref) {
80
- var transform = _ref.transform;
81
- return _extends({}, transform, {
63
+ const restrictToVerticalAxis = ({
64
+ transform
65
+ }) => {
66
+ return { ...transform,
82
67
  x: 0
83
- });
68
+ };
84
69
  };
85
70
 
86
- var restrictToWindowEdges = function restrictToWindowEdges(_ref) {
87
- var transform = _ref.transform,
88
- activeNodeRect = _ref.activeNodeRect,
89
- windowRect = _ref.windowRect;
90
-
71
+ const restrictToWindowEdges = ({
72
+ transform,
73
+ activeNodeRect,
74
+ windowRect
75
+ }) => {
91
76
  if (!activeNodeRect || !windowRect) {
92
77
  return transform;
93
78
  }
@@ -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"],"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 {ViewRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ViewRect,\n boundingRect: ViewRect\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 transform,\n activeNodeRect,\n containerNodeRect,\n}) => {\n if (!activeNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, containerNodeRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToFirstScrollableAncestor: Modifier = ({\n transform,\n activeNodeRect,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!activeNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n activeNodeRect,\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 activeNodeRect,\n windowRect,\n}) => {\n if (!activeNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, windowRect);\n};\n"],"names":["createSnapModifier","gridSize","transform","x","Math","ceil","y","restrictToHorizontalAxis","restrictToBoundingRect","rect","boundingRect","value","top","bottom","height","left","right","width","restrictToParentElement","activeNodeRect","containerNodeRect","restrictToFirstScrollableAncestor","scrollableAncestorRects","firstScrollableAncestorRect","restrictToVerticalAxis","restrictToWindowEdges","windowRect"],"mappings":";;;;;;;;;;;;;;;;;;SAEgBA,mBAAmBC;AACjC,SAAO;AAAA,QAAEC,SAAF,QAAEA,SAAF;AAAA,wBACFA,SADE;AAELC,MAAAA,CAAC,EAAEC,IAAI,CAACC,IAAL,CAAUH,SAAS,CAACC,CAAV,GAAcF,QAAxB,IAAoCA,QAFlC;AAGLK,MAAAA,CAAC,EAAEF,IAAI,CAACC,IAAL,CAAUH,SAAS,CAACI,CAAV,GAAcL,QAAxB,IAAoCA;AAHlC;AAAA,GAAP;AAKD;;ICNYM,wBAAwB,GAAa,SAArCA,wBAAqC;MAAEL,iBAAAA;AAClD,sBACKA,SADL;AAEEI,IAAAA,CAAC,EAAE;AAFL;AAID,CALM;;SCCSE,uBACdN,WACAO,MACAC;AAEA,MAAMC,KAAK,gBACNT,SADM,CAAX;;AAIA,MAAIO,IAAI,CAACG,GAAL,GAAWV,SAAS,CAACI,CAArB,IAA0BI,YAAY,CAACE,GAA3C,EAAgD;AAC9CD,IAAAA,KAAK,CAACL,CAAN,GAAUI,YAAY,CAACE,GAAb,GAAmBH,IAAI,CAACG,GAAlC;AACD,GAFD,MAEO,IACLH,IAAI,CAACI,MAAL,GAAcX,SAAS,CAACI,CAAxB,IACAI,YAAY,CAACE,GAAb,GAAmBF,YAAY,CAACI,MAF3B,EAGL;AACAH,IAAAA,KAAK,CAACL,CAAN,GAAUI,YAAY,CAACE,GAAb,GAAmBF,YAAY,CAACI,MAAhC,GAAyCL,IAAI,CAACI,MAAxD;AACD;;AAED,MAAIJ,IAAI,CAACM,IAAL,GAAYb,SAAS,CAACC,CAAtB,IAA2BO,YAAY,CAACK,IAA5C,EAAkD;AAChDJ,IAAAA,KAAK,CAACR,CAAN,GAAUO,YAAY,CAACK,IAAb,GAAoBN,IAAI,CAACM,IAAnC;AACD,GAFD,MAEO,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ier.ts","../src/restrictToHorizontalAxis.ts","../src/utilities/restrictToBoundingRect.ts","../src/restrictToParentElement.ts","../src/restrictToFirstScrollableAncestor.ts","../src/restrictToVerticalAxis.ts","../src/restrictToWindowEdges.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 {ViewRect} from '@dnd-kit/core';\nimport type {Transform} from '@dnd-kit/utilities';\n\nexport function restrictToBoundingRect(\n transform: Transform,\n rect: ViewRect,\n boundingRect: ViewRect\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 transform,\n activeNodeRect,\n containerNodeRect,\n}) => {\n if (!activeNodeRect || !containerNodeRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, containerNodeRect);\n};\n","import type {Modifier} from '@dnd-kit/core';\nimport {restrictToBoundingRect} from './utilities';\n\nexport const restrictToFirstScrollableAncestor: Modifier = ({\n transform,\n activeNodeRect,\n scrollableAncestorRects,\n}) => {\n const firstScrollableAncestorRect = scrollableAncestorRects[0];\n\n if (!activeNodeRect || !firstScrollableAncestorRect) {\n return transform;\n }\n\n return restrictToBoundingRect(\n transform,\n activeNodeRect,\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 activeNodeRect,\n windowRect,\n}) => {\n if (!activeNodeRect || !windowRect) {\n return transform;\n }\n\n return restrictToBoundingRect(transform, activeNodeRect, windowRect);\n};\n"],"names":["createSnapModifier","gridSize","transform","x","Math","ceil","y","restrictToHorizontalAxis","restrictToBoundingRect","rect","boundingRect","value","top","bottom","height","left","right","width","restrictToParentElement","activeNodeRect","containerNodeRect","restrictToFirstScrollableAncestor","scrollableAncestorRects","firstScrollableAncestorRect","restrictToVerticalAxis","restrictToWindowEdges","windowRect"],"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,IAAAA,KA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B,EAAqD;AACnD,WAAOrB,SAAP;AACD;;AAED,SAAOM,sBAAsB,CAC3BN,SAD2B,EAE3BiB,cAF2B,EAG3BI,2BAH2B,CAA7B;AAKD,CAhBM;;MCDMC,sBAAsB,GAAa,CAAC;AAACtB,EAAAA;AAAD,CAAD;AAC9C,SAAO,EACL,GAAGA,SADE;AAELC,IAAAA,CAAC,EAAE;AAFE,GAAP;AAID,CALM;;MCEMsB,qBAAqB,GAAa,CAAC;AAC9CvB,EAAAA,SAD8C;AAE9CiB,EAAAA,cAF8C;AAG9CO,EAAAA;AAH8C,CAAD;AAK7C,MAAI,CAACP,cAAD,IAAmB,CAACO,UAAxB,EAAoC;AAClC,WAAOxB,SAAP;AACD;;AAED,SAAOM,sBAAsB,CAACN,SAAD,EAAYiB,cAAZ,EAA4BO,UAA5B,CAA7B;AACD,CAVM;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnd-kit/modifiers",
3
- "version": "1.0.4",
3
+ "version": "3.0.0",
4
4
  "description": "Translate modifier presets for use with `@dnd-kit` packages.",
5
5
  "author": "Claudéric Demers",
6
6
  "license": "MIT",
@@ -26,10 +26,15 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@dnd-kit/core": "^1.2.0",
30
- "@dnd-kit/utilities": "^1.0.3",
29
+ "@dnd-kit/utilities": "^2.0.0",
31
30
  "tslib": "^2.0.0"
32
31
  },
32
+ "peerDependencies": {
33
+ "@dnd-kit/core": "^3.1.0"
34
+ },
35
+ "devDependencies": {
36
+ "@dnd-kit/core": "^3.1.0"
37
+ },
33
38
  "publishConfig": {
34
39
  "access": "public"
35
40
  }