@elliemae/ds-drag-and-drop 3.51.0-rc.3 → 3.51.0-rc.5

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.
@@ -71,7 +71,7 @@ const customCollisionDetection = (sensorContext) => {
71
71
  if (intersectionPercentage > insideThreshold && flattenedItemsDictionary[collidingContainer?.id].depth + 1 <= maxDragAndDropLevel && collidingContainer?.id !== active.id) {
72
72
  dropIndicatorPosition = import_constants.DropIndicatorPosition.Inside;
73
73
  } else {
74
- const isFirstElement = flattenedItemsDictionary[collidingContainer?.id].realIndex === 0;
74
+ const isFirstElement = flattenedItemsDictionary[collidingContainer?.id].index === 0;
75
75
  if (isFirstElement) {
76
76
  dropIndicatorPosition = isBefore ? import_constants.DropIndicatorPosition.Before : import_constants.DropIndicatorPosition.After;
77
77
  } else {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/tree/customCollisionDetection.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { type CollisionDetection, rectIntersection, closestCorners } from '@dnd-kit/core';\nimport { DropIndicatorPosition } from './constants.js';\nimport type { DnDKitTree } from './types.js';\n// Percentage to be inside\nconst insideThreshold = 0.7;\n\nexport const customCollisionDetection = <T,>(sensorContext: DnDKitTree.SensorContext<T>): CollisionDetection => {\n const func: CollisionDetection = ({ droppableContainers, collisionRect, droppableRects, ...args }) => {\n const { active, flattenedItemsDictionary, maxDragAndDropLevel, containersRef } = sensorContext.current;\n\n if (!active) return [];\n\n const rectIntersectionCollisions = rectIntersection({\n ...args,\n droppableRects,\n collisionRect,\n droppableContainers: droppableContainers.filter(({ id }) => containersRef.current.includes(id)),\n });\n\n const { id: closestContainerOfContainersId } = rectIntersectionCollisions[0] ?? {};\n\n const possibleCollidingContainers = droppableContainers.filter(\n (container) =>\n !containersRef.current.includes(container?.id) &&\n flattenedItemsDictionary[container?.id].container === closestContainerOfContainersId,\n );\n\n const [collidingContainer, nearesCollidingContainer] = closestCorners({\n ...args,\n droppableRects,\n collisionRect,\n droppableContainers: possibleCollidingContainers,\n });\n\n let dropIndicatorPosition: DnDKitTree.DropIndicatorPositionValues = DropIndicatorPosition.None;\n\n // If we didn't find a match, return empty array\n if (!collidingContainer) {\n dropIndicatorPosition = DropIndicatorPosition.Inside;\n return [{ id: closestContainerOfContainersId, data: { dropIndicatorPosition } }];\n }\n\n const collidingRect = possibleCollidingContainers.find((container) => container.id === collidingContainer.id)?.rect\n ?.current;\n\n if (!collidingRect) return [];\n\n // Calculate the intersection interval\n const [top, bottom] = [\n Math.max(collisionRect.top, collidingRect.top),\n Math.min(collisionRect.top + collisionRect.height, collidingRect.top + collidingRect.height),\n ];\n\n // Calculate the percentage of intersection\n const intersectionPercentage = Math.abs(bottom - top) / Math.min(collisionRect.height, collidingRect.height);\n const isBefore = collisionRect.top + collisionRect.height / 2 < collidingRect.top + collidingRect.height / 2;\n if (\n intersectionPercentage > insideThreshold &&\n flattenedItemsDictionary[collidingContainer?.id].depth + 1 <= maxDragAndDropLevel &&\n collidingContainer?.id !== active.id\n ) {\n dropIndicatorPosition = DropIndicatorPosition.Inside;\n } else {\n const isFirstElement = flattenedItemsDictionary[collidingContainer?.id].realIndex === 0;\n if (isFirstElement) {\n dropIndicatorPosition = isBefore ? DropIndicatorPosition.Before : DropIndicatorPosition.After;\n } else {\n dropIndicatorPosition = DropIndicatorPosition.After;\n }\n }\n\n // Return the id of the match rectangle\n return [\n {\n id:\n isBefore && dropIndicatorPosition === DropIndicatorPosition.After\n ? nearesCollidingContainer?.id\n : collidingContainer?.id,\n data: { dropIndicatorPosition },\n },\n ];\n };\n return func;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,kBAA0E;AAC1E,uBAAsC;AA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,GAAG,IAAI,KAAK,IAAI,cAAc,QAAQ,cAAc,MAAM;AAC3G,UAAM,WAAW,cAAc,MAAM,cAAc,SAAS,IAAI,cAAc,MAAM,cAAc,SAAS;AAC3G,QACE,yBAAyB,mBACzB,yBAAyB,oBAAoB,EAAE,EAAE,QAAQ,KAAK,uBAC9D,oBAAoB,OAAO,OAAO,IAClC;AACA,8BAAwB,uCAAsB;AAAA,IAChD,OAAO;AACL,YAAM,iBAAiB,yBAAyB,oBAAoB,EAAE,EAAE,cAAc;AACtF,UAAI,gBAAgB;AAClB,gCAAwB,WAAW,uCAAsB,SAAS,uCAAsB;AAAA,MAC1F,OAAO;AACL,gCAAwB,uCAAsB;AAAA,MAChD;AAAA,IACF;AAGA,WAAO;AAAA,MACL;AAAA,QACE,IACE,YAAY,0BAA0B,uCAAsB,QACxD,0BAA0B,KAC1B,oBAAoB;AAAA,QAC1B,MAAM,EAAE,sBAAsB;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { type CollisionDetection, rectIntersection, closestCorners } from '@dnd-kit/core';\nimport { DropIndicatorPosition } from './constants.js';\nimport type { DnDKitTree } from './types.js';\n// Percentage to be inside\nconst insideThreshold = 0.7;\n\nexport const customCollisionDetection = <T,>(sensorContext: DnDKitTree.SensorContext<T>): CollisionDetection => {\n const func: CollisionDetection = ({ droppableContainers, collisionRect, droppableRects, ...args }) => {\n const { active, flattenedItemsDictionary, maxDragAndDropLevel, containersRef } = sensorContext.current;\n\n if (!active) return [];\n\n const rectIntersectionCollisions = rectIntersection({\n ...args,\n droppableRects,\n collisionRect,\n droppableContainers: droppableContainers.filter(({ id }) => containersRef.current.includes(id)),\n });\n\n const { id: closestContainerOfContainersId } = rectIntersectionCollisions[0] ?? {};\n\n const possibleCollidingContainers = droppableContainers.filter(\n (container) =>\n !containersRef.current.includes(container?.id) &&\n flattenedItemsDictionary[container?.id].container === closestContainerOfContainersId,\n );\n\n const [collidingContainer, nearesCollidingContainer] = closestCorners({\n ...args,\n droppableRects,\n collisionRect,\n droppableContainers: possibleCollidingContainers,\n });\n\n let dropIndicatorPosition: DnDKitTree.DropIndicatorPositionValues = DropIndicatorPosition.None;\n\n // If we didn't find a match, return empty array\n if (!collidingContainer) {\n dropIndicatorPosition = DropIndicatorPosition.Inside;\n return [{ id: closestContainerOfContainersId, data: { dropIndicatorPosition } }];\n }\n\n const collidingRect = possibleCollidingContainers.find((container) => container.id === collidingContainer.id)?.rect\n ?.current;\n\n if (!collidingRect) return [];\n\n // Calculate the intersection interval\n const [top, bottom] = [\n Math.max(collisionRect.top, collidingRect.top),\n Math.min(collisionRect.top + collisionRect.height, collidingRect.top + collidingRect.height),\n ];\n\n // Calculate the percentage of intersection\n const intersectionPercentage = Math.abs(bottom - top) / Math.min(collisionRect.height, collidingRect.height);\n const isBefore = collisionRect.top + collisionRect.height / 2 < collidingRect.top + collidingRect.height / 2;\n\n if (\n intersectionPercentage > insideThreshold &&\n flattenedItemsDictionary[collidingContainer?.id].depth + 1 <= maxDragAndDropLevel &&\n collidingContainer?.id !== active.id\n ) {\n dropIndicatorPosition = DropIndicatorPosition.Inside;\n } else {\n const isFirstElement = flattenedItemsDictionary[collidingContainer?.id].index === 0;\n if (isFirstElement) {\n dropIndicatorPosition = isBefore ? DropIndicatorPosition.Before : DropIndicatorPosition.After;\n } else {\n dropIndicatorPosition = DropIndicatorPosition.After;\n }\n }\n\n // Return the id of the match rectangle\n return [\n {\n id:\n isBefore && dropIndicatorPosition === DropIndicatorPosition.After\n ? nearesCollidingContainer?.id\n : collidingContainer?.id,\n data: { dropIndicatorPosition },\n },\n ];\n };\n return func;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,kBAA0E;AAC1E,uBAAsC;AAGtC,MAAM,kBA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AAK,IAAI,cAAc,QAAQ,cAAc,MAAM;AAC3G,UAAM,WAAW,cAAc,MAAM,cAAc,SAAS,IAAI,cAAc,MAAM,cAAc,SAAS;AAE3G,QACE,yBAAyB,mBACzB,yBAAyB,oBAAoB,EAAE,EAAE,QAAQ,KAAK,uBAC9D,oBAAoB,OAAO,OAAO,IAClC;AACA,8BAAwB,uCAAsB;AAAA,IAChD,OAAO;AACL,YAAM,iBAAiB,yBAAyB,oBAAoB,EAAE,EAAE,UAAU;AAClF,UAAI,gBAAgB;AAClB,gCAAwB,WAAW,uCAAsB,SAAS,uCAAsB;AAAA,MAC1F,OAAO;AACL,gCAAwB,uCAAsB;AAAA,MAChD;AAAA,IACF;AAGA,WAAO;AAAA,MACL;AAAA,QACE,IACE,YAAY,0BAA0B,uCAAsB,QACxD,0BAA0B,KAC1B,oBAAoB;AAAA,QAC1B,MAAM,EAAE,sBAAsB;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -38,7 +38,7 @@ const customCollisionDetection = (sensorContext) => {
38
38
  if (intersectionPercentage > insideThreshold && flattenedItemsDictionary[collidingContainer?.id].depth + 1 <= maxDragAndDropLevel && collidingContainer?.id !== active.id) {
39
39
  dropIndicatorPosition = DropIndicatorPosition.Inside;
40
40
  } else {
41
- const isFirstElement = flattenedItemsDictionary[collidingContainer?.id].realIndex === 0;
41
+ const isFirstElement = flattenedItemsDictionary[collidingContainer?.id].index === 0;
42
42
  if (isFirstElement) {
43
43
  dropIndicatorPosition = isBefore ? DropIndicatorPosition.Before : DropIndicatorPosition.After;
44
44
  } else {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/tree/customCollisionDetection.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { type CollisionDetection, rectIntersection, closestCorners } from '@dnd-kit/core';\nimport { DropIndicatorPosition } from './constants.js';\nimport type { DnDKitTree } from './types.js';\n// Percentage to be inside\nconst insideThreshold = 0.7;\n\nexport const customCollisionDetection = <T,>(sensorContext: DnDKitTree.SensorContext<T>): CollisionDetection => {\n const func: CollisionDetection = ({ droppableContainers, collisionRect, droppableRects, ...args }) => {\n const { active, flattenedItemsDictionary, maxDragAndDropLevel, containersRef } = sensorContext.current;\n\n if (!active) return [];\n\n const rectIntersectionCollisions = rectIntersection({\n ...args,\n droppableRects,\n collisionRect,\n droppableContainers: droppableContainers.filter(({ id }) => containersRef.current.includes(id)),\n });\n\n const { id: closestContainerOfContainersId } = rectIntersectionCollisions[0] ?? {};\n\n const possibleCollidingContainers = droppableContainers.filter(\n (container) =>\n !containersRef.current.includes(container?.id) &&\n flattenedItemsDictionary[container?.id].container === closestContainerOfContainersId,\n );\n\n const [collidingContainer, nearesCollidingContainer] = closestCorners({\n ...args,\n droppableRects,\n collisionRect,\n droppableContainers: possibleCollidingContainers,\n });\n\n let dropIndicatorPosition: DnDKitTree.DropIndicatorPositionValues = DropIndicatorPosition.None;\n\n // If we didn't find a match, return empty array\n if (!collidingContainer) {\n dropIndicatorPosition = DropIndicatorPosition.Inside;\n return [{ id: closestContainerOfContainersId, data: { dropIndicatorPosition } }];\n }\n\n const collidingRect = possibleCollidingContainers.find((container) => container.id === collidingContainer.id)?.rect\n ?.current;\n\n if (!collidingRect) return [];\n\n // Calculate the intersection interval\n const [top, bottom] = [\n Math.max(collisionRect.top, collidingRect.top),\n Math.min(collisionRect.top + collisionRect.height, collidingRect.top + collidingRect.height),\n ];\n\n // Calculate the percentage of intersection\n const intersectionPercentage = Math.abs(bottom - top) / Math.min(collisionRect.height, collidingRect.height);\n const isBefore = collisionRect.top + collisionRect.height / 2 < collidingRect.top + collidingRect.height / 2;\n if (\n intersectionPercentage > insideThreshold &&\n flattenedItemsDictionary[collidingContainer?.id].depth + 1 <= maxDragAndDropLevel &&\n collidingContainer?.id !== active.id\n ) {\n dropIndicatorPosition = DropIndicatorPosition.Inside;\n } else {\n const isFirstElement = flattenedItemsDictionary[collidingContainer?.id].realIndex === 0;\n if (isFirstElement) {\n dropIndicatorPosition = isBefore ? DropIndicatorPosition.Before : DropIndicatorPosition.After;\n } else {\n dropIndicatorPosition = DropIndicatorPosition.After;\n }\n }\n\n // Return the id of the match rectangle\n return [\n {\n id:\n isBefore && dropIndicatorPosition === DropIndicatorPosition.After\n ? nearesCollidingContainer?.id\n : collidingContainer?.id,\n data: { dropIndicatorPosition },\n },\n ];\n };\n return func;\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACEvB,SAAkC,kBAAkB,sBAAsB;AAC1E,SAAS,6BAA6B;AAGtC,MAAM,kBAAkB;AAEjB,MAAM,2BAA2B,CAAK,kBAAmE;AAC9G,QAAM,OAA2B,CAAC,EAAE,qBAAqB,eAAe,gBAAgB,GAAG,KAAK,MAAM;AACpG,UAAM,EAAE,QAAQ,0BAA0B,qBAAqB,cAAc,IAAI,cAAc;AAE/F,QAAI,CAAC,OAAQ,QAAO,CAAC;AAErB,UAAM,6BAA6B,iBAAiB;AAAA,MAClD,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA,qBAAqB,oBAAoB,OAAO,CAAC,EAAE,GAAG,MAAM,cAAc,QAAQ,SAAS,EAAE,CAAC;AAAA,IAChG,CAAC;AAED,UAAM,EAAE,IAAI,+BAA+B,IAAI,2BAA2B,CAAC,KAAK,CAAC;AAEjF,UAAM,8BAA8B,oBAAoB;AAAA,MACtD,CAAC,cACC,CAAC,cAAc,QAAQ,SAAS,WAAW,EAAE,KAC7C,yBAAyB,WAAW,EAAE,EAAE,cAAc;AAAA,IAC1D;AAEA,UAAM,CAAC,oBAAoB,wBAAwB,IAAI,eAAe;AAAA,MACpE,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA,qBAAqB;AAAA,IACvB,CAAC;AAED,QAAI,wBAAgE,sBAAsB;AAG1F,QAAI,CAAC,oBAAoB;AACvB,8BAAwB,sBAAsB;AAC9C,aAAO,CAAC,EAAE,IAAI,gCAAgC,MAAM,EAAE,sBAAsB,EAAE,CAAC;AAAA,IACjF;AAEA,UAAM,gBAAgB,4BAA4B,KAAK,CAAC,cAAc,UAAU,OAAO,mBAAmB,EAAE,GAAG,MAC3G;AAEJ,QAAI,CAAC,cAAe,QAAO,CAAC;AAG5B,UAAM,CAAC,KAAK,MAAM,IAAI;AAAA,MACpB,KAAK,IAAI,cAAc,KAAK,cAAc,GAAG;AAAA,MAC7C,KAAK,IAAI,cAAc,MAAM,cAAc,QAAQ,cAAc,MAAM,cAAc,MAAM;AAAA,IAC7F;AAGA,UAAM,yBAAyB,KAAK,IAAI,SAAS,GAAG,IAAI,KAAK,IAAI,cAAc,QAAQ,cAAc,MAAM;AAC3G,UAAM,WAAW,cAAc,MAAM,cAAc,SAAS,IAAI,cAAc,MAAM,cAAc,SAAS;AAC3G,QACE,yBAAyB,mBACzB,yBAAyB,oBAAoB,EAAE,EAAE,QAAQ,KAAK,uBAC9D,oBAAoB,OAAO,OAAO,IAClC;AACA,8BAAwB,sBAAsB;AAAA,IAChD,OAAO;AACL,YAAM,iBAAiB,yBAAyB,oBAAoB,EAAE,EAAE,cAAc;AACtF,UAAI,gBAAgB;AAClB,gCAAwB,WAAW,sBAAsB,SAAS,sBAAsB;AAAA,MAC1F,OAAO;AACL,gCAAwB,sBAAsB;AAAA,MAChD;AAAA,IACF;AAGA,WAAO;AAAA,MACL;AAAA,QACE,IACE,YAAY,0BAA0B,sBAAsB,QACxD,0BAA0B,KAC1B,oBAAoB;AAAA,QAC1B,MAAM,EAAE,sBAAsB;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { type CollisionDetection, rectIntersection, closestCorners } from '@dnd-kit/core';\nimport { DropIndicatorPosition } from './constants.js';\nimport type { DnDKitTree } from './types.js';\n// Percentage to be inside\nconst insideThreshold = 0.7;\n\nexport const customCollisionDetection = <T,>(sensorContext: DnDKitTree.SensorContext<T>): CollisionDetection => {\n const func: CollisionDetection = ({ droppableContainers, collisionRect, droppableRects, ...args }) => {\n const { active, flattenedItemsDictionary, maxDragAndDropLevel, containersRef } = sensorContext.current;\n\n if (!active) return [];\n\n const rectIntersectionCollisions = rectIntersection({\n ...args,\n droppableRects,\n collisionRect,\n droppableContainers: droppableContainers.filter(({ id }) => containersRef.current.includes(id)),\n });\n\n const { id: closestContainerOfContainersId } = rectIntersectionCollisions[0] ?? {};\n\n const possibleCollidingContainers = droppableContainers.filter(\n (container) =>\n !containersRef.current.includes(container?.id) &&\n flattenedItemsDictionary[container?.id].container === closestContainerOfContainersId,\n );\n\n const [collidingContainer, nearesCollidingContainer] = closestCorners({\n ...args,\n droppableRects,\n collisionRect,\n droppableContainers: possibleCollidingContainers,\n });\n\n let dropIndicatorPosition: DnDKitTree.DropIndicatorPositionValues = DropIndicatorPosition.None;\n\n // If we didn't find a match, return empty array\n if (!collidingContainer) {\n dropIndicatorPosition = DropIndicatorPosition.Inside;\n return [{ id: closestContainerOfContainersId, data: { dropIndicatorPosition } }];\n }\n\n const collidingRect = possibleCollidingContainers.find((container) => container.id === collidingContainer.id)?.rect\n ?.current;\n\n if (!collidingRect) return [];\n\n // Calculate the intersection interval\n const [top, bottom] = [\n Math.max(collisionRect.top, collidingRect.top),\n Math.min(collisionRect.top + collisionRect.height, collidingRect.top + collidingRect.height),\n ];\n\n // Calculate the percentage of intersection\n const intersectionPercentage = Math.abs(bottom - top) / Math.min(collisionRect.height, collidingRect.height);\n const isBefore = collisionRect.top + collisionRect.height / 2 < collidingRect.top + collidingRect.height / 2;\n\n if (\n intersectionPercentage > insideThreshold &&\n flattenedItemsDictionary[collidingContainer?.id].depth + 1 <= maxDragAndDropLevel &&\n collidingContainer?.id !== active.id\n ) {\n dropIndicatorPosition = DropIndicatorPosition.Inside;\n } else {\n const isFirstElement = flattenedItemsDictionary[collidingContainer?.id].index === 0;\n if (isFirstElement) {\n dropIndicatorPosition = isBefore ? DropIndicatorPosition.Before : DropIndicatorPosition.After;\n } else {\n dropIndicatorPosition = DropIndicatorPosition.After;\n }\n }\n\n // Return the id of the match rectangle\n return [\n {\n id:\n isBefore && dropIndicatorPosition === DropIndicatorPosition.After\n ? nearesCollidingContainer?.id\n : collidingContainer?.id,\n data: { dropIndicatorPosition },\n },\n ];\n };\n return func;\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACEvB,SAAkC,kBAAkB,sBAAsB;AAC1E,SAAS,6BAA6B;AAGtC,MAAM,kBAAkB;AAEjB,MAAM,2BAA2B,CAAK,kBAAmE;AAC9G,QAAM,OAA2B,CAAC,EAAE,qBAAqB,eAAe,gBAAgB,GAAG,KAAK,MAAM;AACpG,UAAM,EAAE,QAAQ,0BAA0B,qBAAqB,cAAc,IAAI,cAAc;AAE/F,QAAI,CAAC,OAAQ,QAAO,CAAC;AAErB,UAAM,6BAA6B,iBAAiB;AAAA,MAClD,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA,qBAAqB,oBAAoB,OAAO,CAAC,EAAE,GAAG,MAAM,cAAc,QAAQ,SAAS,EAAE,CAAC;AAAA,IAChG,CAAC;AAED,UAAM,EAAE,IAAI,+BAA+B,IAAI,2BAA2B,CAAC,KAAK,CAAC;AAEjF,UAAM,8BAA8B,oBAAoB;AAAA,MACtD,CAAC,cACC,CAAC,cAAc,QAAQ,SAAS,WAAW,EAAE,KAC7C,yBAAyB,WAAW,EAAE,EAAE,cAAc;AAAA,IAC1D;AAEA,UAAM,CAAC,oBAAoB,wBAAwB,IAAI,eAAe;AAAA,MACpE,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA,qBAAqB;AAAA,IACvB,CAAC;AAED,QAAI,wBAAgE,sBAAsB;AAG1F,QAAI,CAAC,oBAAoB;AACvB,8BAAwB,sBAAsB;AAC9C,aAAO,CAAC,EAAE,IAAI,gCAAgC,MAAM,EAAE,sBAAsB,EAAE,CAAC;AAAA,IACjF;AAEA,UAAM,gBAAgB,4BAA4B,KAAK,CAAC,cAAc,UAAU,OAAO,mBAAmB,EAAE,GAAG,MAC3G;AAEJ,QAAI,CAAC,cAAe,QAAO,CAAC;AAG5B,UAAM,CAAC,KAAK,MAAM,IAAI;AAAA,MACpB,KAAK,IAAI,cAAc,KAAK,cAAc,GAAG;AAAA,MAC7C,KAAK,IAAI,cAAc,MAAM,cAAc,QAAQ,cAAc,MAAM,cAAc,MAAM;AAAA,IAC7F;AAGA,UAAM,yBAAyB,KAAK,IAAI,SAAS,GAAG,IAAI,KAAK,IAAI,cAAc,QAAQ,cAAc,MAAM;AAC3G,UAAM,WAAW,cAAc,MAAM,cAAc,SAAS,IAAI,cAAc,MAAM,cAAc,SAAS;AAE3G,QACE,yBAAyB,mBACzB,yBAAyB,oBAAoB,EAAE,EAAE,QAAQ,KAAK,uBAC9D,oBAAoB,OAAO,OAAO,IAClC;AACA,8BAAwB,sBAAsB;AAAA,IAChD,OAAO;AACL,YAAM,iBAAiB,yBAAyB,oBAAoB,EAAE,EAAE,UAAU;AAClF,UAAI,gBAAgB;AAClB,gCAAwB,WAAW,sBAAsB,SAAS,sBAAsB;AAAA,MAC1F,OAAO;AACL,gCAAwB,sBAAsB;AAAA,MAChD;AAAA,IACF;AAGA,WAAO;AAAA,MACL;AAAA,QACE,IACE,YAAY,0BAA0B,sBAAsB,QACxD,0BAA0B,KAC1B,oBAAoB;AAAA,QAC1B,MAAM,EAAE,sBAAsB;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-drag-and-drop",
3
- "version": "3.51.0-rc.3",
3
+ "version": "3.51.0-rc.5",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Drag And Drop",
6
6
  "files": [
@@ -39,17 +39,17 @@
39
39
  "@dnd-kit/core": "~6.0.8",
40
40
  "@dnd-kit/modifiers": "~6.0.1",
41
41
  "@dnd-kit/sortable": "~7.0.2",
42
- "@elliemae/ds-fast-list": "3.51.0-rc.3",
43
- "@elliemae/ds-props-helpers": "3.51.0-rc.3",
44
- "@elliemae/ds-tree-model": "3.51.0-rc.3",
45
- "@elliemae/ds-system": "3.51.0-rc.3",
46
- "@elliemae/ds-typescript-helpers": "3.51.0-rc.3"
42
+ "@elliemae/ds-fast-list": "3.51.0-rc.5",
43
+ "@elliemae/ds-tree-model": "3.51.0-rc.5",
44
+ "@elliemae/ds-props-helpers": "3.51.0-rc.5",
45
+ "@elliemae/ds-system": "3.51.0-rc.5",
46
+ "@elliemae/ds-typescript-helpers": "3.51.0-rc.5"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@elliemae/pui-cli": "9.0.0-next.55",
50
50
  "jest": "~29.7.0",
51
51
  "styled-components": "~5.3.9",
52
- "@elliemae/ds-monorepo-devops": "3.51.0-rc.3"
52
+ "@elliemae/ds-monorepo-devops": "3.51.0-rc.5"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "lodash": "^4.17.21",