@elliemae/ds-drag-and-drop 3.37.2 → 3.38.0-rc.0
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.
- package/dist/cjs/parts/DSDragAndDrop/DSDragAndDrop.js +13 -13
- package/dist/cjs/parts/DSDragAndDrop/DSDragAndDrop.js.map +2 -2
- package/dist/cjs/parts/DSSortableContainer/DSSortableContainer.js +22 -19
- package/dist/cjs/parts/DSSortableContainer/DSSortableContainer.js.map +2 -2
- package/dist/cjs/parts/DSSortableContainer/config/SortableContainerContext.js +44 -0
- package/dist/cjs/parts/DSSortableContainer/config/SortableContainerContext.js.map +7 -0
- package/dist/cjs/parts/DSSortableContainer/index.js +2 -1
- package/dist/cjs/parts/DSSortableContainer/index.js.map +2 -2
- package/dist/cjs/parts/DSSortableContainer/react-desc-prop-types.js.map +1 -1
- package/dist/cjs/parts/DSSortableItem/DSSortableItem.js +4 -4
- package/dist/cjs/parts/DSSortableItem/DSSortableItem.js.map +2 -2
- package/dist/cjs/tree/customCollisionDetection.js +5 -5
- package/dist/cjs/tree/customCollisionDetection.js.map +2 -2
- package/dist/esm/parts/DSDragAndDrop/DSDragAndDrop.js +10 -15
- package/dist/esm/parts/DSDragAndDrop/DSDragAndDrop.js.map +2 -2
- package/dist/esm/parts/DSSortableContainer/DSSortableContainer.js +20 -17
- package/dist/esm/parts/DSSortableContainer/DSSortableContainer.js.map +2 -2
- package/dist/esm/parts/DSSortableContainer/config/SortableContainerContext.js +14 -0
- package/dist/esm/parts/DSSortableContainer/config/SortableContainerContext.js.map +7 -0
- package/dist/esm/parts/DSSortableContainer/index.js +2 -1
- package/dist/esm/parts/DSSortableContainer/index.js.map +2 -2
- package/dist/esm/parts/DSSortableContainer/react-desc-prop-types.js.map +1 -1
- package/dist/esm/parts/DSSortableItem/DSSortableItem.js +2 -2
- package/dist/esm/parts/DSSortableItem/DSSortableItem.js.map +2 -2
- package/dist/esm/tree/customCollisionDetection.js +5 -5
- package/dist/esm/tree/customCollisionDetection.js.map +2 -2
- package/dist/types/parts/DSSortableContainer/DSSortableContainer.d.ts +0 -11
- package/dist/types/parts/DSSortableContainer/config/SortableContainerContext.d.ts +13 -0
- package/dist/types/parts/DSSortableContainer/index.d.ts +2 -1
- package/dist/types/parts/DSSortableContainer/react-desc-prop-types.d.ts +1 -1
- package/package.json +7 -7
|
@@ -36,9 +36,11 @@ var React = __toESM(require("react"));
|
|
|
36
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
37
|
var import_react = require("react");
|
|
38
38
|
var import_react_dom = require("react-dom");
|
|
39
|
-
var
|
|
40
|
-
var import_DSSortableContainer = require("../DSSortableContainer/index.js");
|
|
39
|
+
var import_modifiers = require("@dnd-kit/modifiers");
|
|
41
40
|
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
41
|
+
var import_core = require("@dnd-kit/core");
|
|
42
|
+
var import_tree = require("../../tree/index.js");
|
|
43
|
+
var import_SortableContainerContext = require("../DSSortableContainer/config/SortableContainerContext.js");
|
|
42
44
|
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
|
43
45
|
const flatten = (items, parentId = null, depth = 0, container = "root", iteration = { count: 0 }) => items.reduce((acc, item, index) => {
|
|
44
46
|
acc.push({
|
|
@@ -46,7 +48,7 @@ const flatten = (items, parentId = null, depth = 0, container = "root", iteratio
|
|
|
46
48
|
uid: item.dsId,
|
|
47
49
|
childrenCount: item?.subitems?.length || 0,
|
|
48
50
|
original: item,
|
|
49
|
-
realIndex: iteration.count
|
|
51
|
+
realIndex: iteration.count + 1,
|
|
50
52
|
parentId,
|
|
51
53
|
depth,
|
|
52
54
|
index,
|
|
@@ -76,7 +78,7 @@ const DSDragAndDrop = ({
|
|
|
76
78
|
),
|
|
77
79
|
[items]
|
|
78
80
|
);
|
|
79
|
-
const { dndContextProps, sortableContextProps, active, dropIndicatorPosition, isDropValid } = (0,
|
|
81
|
+
const { dndContextProps, sortableContextProps, active, dropIndicatorPosition, isDropValid } = (0, import_tree.useMultiTreeDndkitConfig)({
|
|
80
82
|
flattenedItems: itemsFlattened,
|
|
81
83
|
isHorizontalDnD: false,
|
|
82
84
|
isExpandable: true,
|
|
@@ -85,16 +87,14 @@ const DSDragAndDrop = ({
|
|
|
85
87
|
getIsDropValid: () => true,
|
|
86
88
|
...rest
|
|
87
89
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
),
|
|
90
|
+
const ctx = (0, import_react.useMemo)(
|
|
91
|
+
() => ({ sortableContextProps, dropIndicatorPosition, isDropValid, items: itemsFlattened, onCollapse }),
|
|
92
|
+
[dropIndicatorPosition, isDropValid, itemsFlattened, onCollapse, sortableContextProps]
|
|
93
|
+
);
|
|
94
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.DndContext, { ...dndContextProps, children: [
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SortableContainerContext.ContainersContext.Provider, { value: ctx, children }),
|
|
96
96
|
(0, import_react_dom.createPortal)(
|
|
97
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.DragOverlay, { style: { width: "auto", zIndex: 1001 }, modifiers: [import_modifiers.restrictToWindowEdges], children: active ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DragOverlayRenderer, { activeItem: active }) : null }),
|
|
98
98
|
document.body
|
|
99
99
|
)
|
|
100
100
|
] });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/DSDragAndDrop/DSDragAndDrop.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-params */\nimport React, { useMemo } from 'react';\nimport { createPortal } from 'react-dom';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-params */\nimport React, { useMemo } from 'react';\nimport { createPortal } from 'react-dom';\nimport { type UniqueIdentifier } from '@dnd-kit/core/dist/types';\nimport { restrictToWindowEdges } from '@dnd-kit/modifiers';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { DragOverlay, DndContext } from '@dnd-kit/core';\nimport { useMultiTreeDndkitConfig } from '../../tree/index.js';\nimport { ContainersContext } from '../DSSortableContainer/config/SortableContainerContext.js';\nimport type { DSDragAndDropT, Item } from './react-desc-prop-types.js';\nimport { DSDragAndDropPropTypes } from './react-desc-prop-types.js';\n\nconst flatten = <T,>(\n items: Item<T>[],\n parentId: UniqueIdentifier | null = null,\n depth = 0,\n container = 'root',\n iteration = { count: 0 },\n) =>\n items.reduce((acc, item, index) => {\n acc.push({\n ...item,\n uid: item.dsId,\n childrenCount: item?.subitems?.length || 0,\n original: item,\n realIndex: iteration.count + 1,\n parentId,\n depth,\n index,\n container,\n });\n if (item.subitems?.length > 0 && item.collapsed === false) {\n acc.push(...flatten(item.subitems, item.dsId, depth + 1, container, iteration));\n }\n return acc;\n }, [] as Item<T>[]);\n\nexport const DSDragAndDrop = <T,>({\n items,\n children,\n onReorder,\n onCollapse,\n DragOverlayRenderer,\n maxDragAndDropLevel = 0,\n ...rest\n}: DSDragAndDropT.Props<T>) => {\n const itemsFlattened = useMemo(\n () =>\n Object.keys(items).reduce(\n (acc, container) => {\n acc[container] = flatten(items[container] as Item<T>[], null, 0, container);\n return acc;\n },\n {} as Record<string, Item<T>[]>,\n ),\n [items],\n );\n const { dndContextProps, sortableContextProps, active, dropIndicatorPosition, isDropValid } =\n useMultiTreeDndkitConfig({\n flattenedItems: itemsFlattened,\n isHorizontalDnD: false,\n isExpandable: true,\n onReorder,\n maxDragAndDropLevel,\n getIsDropValid: () => true,\n ...rest,\n });\n\n const ctx = useMemo(\n () => ({ sortableContextProps, dropIndicatorPosition, isDropValid, items: itemsFlattened, onCollapse }),\n [dropIndicatorPosition, isDropValid, itemsFlattened, onCollapse, sortableContextProps],\n );\n\n return (\n <DndContext {...dndContextProps}>\n <ContainersContext.Provider value={ctx}>{children}</ContainersContext.Provider>\n {createPortal(\n <DragOverlay style={{ width: 'auto', zIndex: 1001 }} modifiers={[restrictToWindowEdges]}>\n {active ? <DragOverlayRenderer activeItem={active} /> : null}\n </DragOverlay>,\n document.body,\n )}\n </DndContext>\n );\n};\n\nconst DSDragAndDropWithSchema = describe(DSDragAndDrop);\n\nDSDragAndDropWithSchema.propTypes = DSDragAndDropPropTypes;\n\nexport { DSDragAndDropWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD0EnB;AAzEJ,mBAA+B;AAC/B,uBAA6B;AAE7B,uBAAsC;AACtC,8BAAyB;AACzB,kBAAwC;AACxC,kBAAyC;AACzC,sCAAkC;AAElC,mCAAuC;AAEvC,MAAM,UAAU,CACd,OACA,WAAoC,MACpC,QAAQ,GACR,YAAY,QACZ,YAAY,EAAE,OAAO,EAAE,MAEvB,MAAM,OAAO,CAAC,KAAK,MAAM,UAAU;AACjC,MAAI,KAAK;AAAA,IACP,GAAG;AAAA,IACH,KAAK,KAAK;AAAA,IACV,eAAe,MAAM,UAAU,UAAU;AAAA,IACzC,UAAU;AAAA,IACV,WAAW,UAAU,QAAQ;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,cAAc,OAAO;AACzD,QAAI,KAAK,GAAG,QAAQ,KAAK,UAAU,KAAK,MAAM,QAAQ,GAAG,WAAW,SAAS,CAAC;AAAA,EAChF;AACA,SAAO;AACT,G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S = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var DSSortableContainer_exports = {};
|
|
30
30
|
__export(DSSortableContainer_exports, {
|
|
31
|
-
ContainersContext: () => ContainersContext,
|
|
32
31
|
DSSortableContainer: () => DSSortableContainer,
|
|
33
|
-
DSSortableContainerSchema: () => DSSortableContainerSchema
|
|
34
|
-
createContainerContext: () => createContainerContext
|
|
32
|
+
DSSortableContainerSchema: () => DSSortableContainerSchema
|
|
35
33
|
});
|
|
36
34
|
module.exports = __toCommonJS(DSSortableContainer_exports);
|
|
37
35
|
var React = __toESM(require("react"));
|
|
@@ -39,30 +37,35 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
39
37
|
var import_react = __toESM(require("react"));
|
|
40
38
|
var import_ds_fast_list = require("@elliemae/ds-fast-list");
|
|
41
39
|
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
42
|
-
var
|
|
40
|
+
var import_core = require("@dnd-kit/core");
|
|
41
|
+
var import_sortable = require("@dnd-kit/sortable");
|
|
42
|
+
var import_DSSortableItem = require("../DSSortableItem/index.js");
|
|
43
43
|
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
|
44
|
-
|
|
45
|
-
return (0, import_react.createContext)({
|
|
46
|
-
sortableContextProps: {},
|
|
47
|
-
items: {}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
const ContainersContext = createContainerContext();
|
|
44
|
+
var import_SortableContainerContext = require("./config/SortableContainerContext.js");
|
|
51
45
|
const ContainerItemRenderer = (props) => {
|
|
52
|
-
const {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
46
|
+
const { index, extraItemProps } = props;
|
|
47
|
+
if (!extraItemProps) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const { items, ItemRenderer, ...rest } = extraItemProps;
|
|
56
51
|
const item = items[index];
|
|
57
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
53
|
+
import_DSSortableItem.DSSortableItem,
|
|
54
|
+
{
|
|
55
|
+
item,
|
|
56
|
+
ItemRenderer,
|
|
57
|
+
...rest,
|
|
58
|
+
extraItemProps
|
|
59
|
+
}
|
|
60
|
+
);
|
|
58
61
|
};
|
|
59
62
|
const ContainerItemRendererMemoized = import_react.default.memo(ContainerItemRenderer);
|
|
60
63
|
const DSSortableContainer = (props) => {
|
|
61
64
|
const { containerId, ItemRenderer, Component, extraItemProps, children } = props;
|
|
62
|
-
const { setNodeRef, isOver } = (0,
|
|
65
|
+
const { setNodeRef, isOver } = (0, import_core.useDroppable)({
|
|
63
66
|
id: containerId
|
|
64
67
|
});
|
|
65
|
-
const ctx = (0, import_react.useContext)(ContainersContext);
|
|
68
|
+
const ctx = (0, import_react.useContext)(import_SortableContainerContext.ContainersContext);
|
|
66
69
|
const { sortableContextProps, items } = ctx;
|
|
67
70
|
const containerSortableContextProps = sortableContextProps[containerId];
|
|
68
71
|
const render = (0, import_react.useMemo)(() => {
|
|
@@ -86,7 +89,7 @@ const DSSortableContainer = (props) => {
|
|
|
86
89
|
}
|
|
87
90
|
return null;
|
|
88
91
|
}, [ItemRenderer, children, containerId, extraItemProps, items]);
|
|
89
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sortable.SortableContext, { ...containerSortableContextProps, id: "container", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { innerRef: setNodeRef, isOver, children: render }) });
|
|
90
93
|
};
|
|
91
94
|
const DSSortableContainerSchema = (0, import_ds_props_helpers.describe)(DSSortableContainer);
|
|
92
95
|
DSSortableContainerSchema.propTypes = import_react_desc_prop_types.DSSortalContainerPropTypes;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/DSSortableContainer/DSSortableContainer.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useMemo } from 'react';\nimport { DSFastList } from '@elliemae/ds-fast-list';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { useDroppable } from '@dnd-kit/core';\nimport { SortableContext } from '@dnd-kit/sortable';\nimport { DSSortableItem } from '../DSSortableItem/index.js';\nimport type { DSSortableContainerT } from './react-desc-prop-types.js';\nimport { DSSortalContainerPropTypes } from './react-desc-prop-types.js';\nimport type { ItemRendererPropsT } from '../DSSortableItem/index.js';\nimport { ContainersContext } from './config/SortableContainerContext.js';\nimport type { Item } from '../DSDragAndDrop/index.js';\nconst ContainerItemRenderer = <T, K>(props: DSSortableContainerT.ContainerItemRendererT<T, K>) => {\n const { index, extraItemProps } = props;\n if (!extraItemProps) {\n return null;\n }\n const { items, ItemRenderer, ...rest } = extraItemProps;\n const item = items[index];\n return (\n <DSSortableItem\n item={item}\n ItemRenderer={\n ItemRenderer as React.ComponentType<\n ItemRendererPropsT<\n T,\n { items: Item<T>[]; extraItemProps: K; ItemRenderer: React.ComponentType<ItemRendererPropsT<T, K>> }\n >\n >\n }\n {...rest}\n extraItemProps={extraItemProps}\n />\n );\n};\n\nconst ContainerItemRendererMemoized = React.memo(ContainerItemRenderer);\n\nexport const DSSortableContainer = <T, K>(props: DSSortableContainerT.Props<T, K>) => {\n const { containerId, ItemRenderer, Component, extraItemProps, children } = props;\n const { setNodeRef, isOver } = useDroppable({\n id: containerId,\n });\n const ctx = useContext(ContainersContext);\n const { sortableContextProps, items } = ctx;\n const containerSortableContextProps = sortableContextProps[containerId];\n\n const render = useMemo(() => {\n if (children) {\n return children;\n }\n if (ItemRenderer) {\n return (\n <DSFastList\n count={items[containerId].length}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any\n ItemRenderer={ContainerItemRendererMemoized as any}\n extraItemProps={{\n items: items[containerId],\n ItemRenderer: ItemRenderer as React.ComponentType<ItemRendererPropsT<unknown, unknown>>,\n extraItemProps,\n }}\n getId={(index: number | string) => items[containerId][index as number].dsId}\n />\n );\n }\n return null;\n }, [ItemRenderer, children, containerId, extraItemProps, items]);\n\n return (\n <SortableContext {...containerSortableContextProps} id=\"container\">\n <Component innerRef={setNodeRef} isOver={isOver}>\n {render}\n </Component>\n </SortableContext>\n );\n};\n\nconst DSSortableContainerSchema = describe(DSSortableContainer);\nDSSortableContainerSchema.propTypes = DSSortalContainerPropTypes;\n\nexport { DSSortableContainerSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADmBnB;AAnBJ,mBAA2C;AAC3C,0BAA2B;AAC3B,8BAAyB;AACzB,kBAA6B;AAC7B,sBAAgC;AAChC,4BAA+B;AAE/B,mCAA2C;AAE3C,sCAAkC;AAElC,MAAM,wBAAwB,CAAO,UAA6D;AAChG,QAAM,EAAE,OAAO,eAAe,IAAI;AAClC,MAAI,CAAC,gBAAgB;AACnB,WAAO;AAAA,EACT;AACA,QAAM,EAAE,OAAO,cAAc,GAAG,KAAK,IAAI;AACzC,QAAM,OAAO,MAAM,KAAK;AACxB,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MAQC,GAAG;AAAA,MACJ;AAAA;AAAA,EACF;AAEJ;AAEA,MAAM,gCAAgC,aAAAA,QAAM,KAAK,qBAAqB;AAE/D,MAAM,sBAAsB,CAAO,UAA4C;AACpF,QAAM,EAAE,aAAa,cAAc,WAAW,gBAAgB,SAAS,IAAI;AAC3E,QAAM,EAAE,YAAY,OAAO,QAAI,0BAAa;AAAA,IAC1C,IAAI;AAAA,EACN,CAAC;AACD,QAAM,UAAM,yBAAW,iDAAiB;AACxC,QAAM,EAAE,sBAAsB,MAAM,IAAI;AACxC,QAAM,gCAAgC,qBAAqB,WAAW;AAEtE,QAAM,aAAS,sBAAQ,MAAM;AAC3B,QAAI,UAAU;AACZ,aAAO;AAAA,IACT;AACA,QAAI,cAAc;AAChB,aACE;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,MAAM,WAAW,EAAE;AAAA,UAE1B,cAAc;AAAA,UACd,gBAAgB;AAAA,YACd,OAAO,MAAM,WAAW;AAAA,YACxB;AAAA,YACA;AAAA,UACF;AAAA,UACA,OAAO,CAAC,UAA2B,MAAM,WAAW,EAAE,KAAe,EAAE;AAAA;AAAA,MACzE;AAAA,IAEJ;AACA,WAAO;AAAA,EACT,GAAG,CAAC,cAAc,UAAU,aAAa,gBAAgB,KAAK,CAAC;AAE/D,SACE,4CAAC,mCAAiB,GAAG,+BAA+B,IAAG,aACrD,sDAAC,aAAU,UAAU,YAAY,QAC9B,kBACH,GACF;AAEJ;AAEA,MAAM,gCAA4B,kCAAS,mBAAmB;AAC9D,0BAA0B,YAAY;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var SortableContainerContext_exports = {};
|
|
30
|
+
__export(SortableContainerContext_exports, {
|
|
31
|
+
ContainersContext: () => ContainersContext,
|
|
32
|
+
createContainerContext: () => createContainerContext
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(SortableContainerContext_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
function createContainerContext() {
|
|
38
|
+
return (0, import_react.createContext)({
|
|
39
|
+
sortableContextProps: {},
|
|
40
|
+
items: {}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const ContainersContext = createContainerContext();
|
|
44
|
+
//# sourceMappingURL=SortableContainerContext.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/parts/DSSortableContainer/config/SortableContainerContext.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react';\nimport type { DnDKitTree } from '../../../tree/types.js';\nimport type { DSSortableContainerT } from '../react-desc-prop-types.js';\n\ninterface ContainerContextT<T> {\n isDropValid?: boolean;\n dropIndicatorPosition?: string;\n sortableContextProps: Record<string, DnDKitTree.SortableContextPropsType>;\n items: Record<string, DSSortableContainerT.Item<T>[]>;\n onCollapse?: (nodeId: string) => void;\n}\n\nexport function createContainerContext<T>() {\n return createContext<ContainerContextT<T>>({\n sortableContextProps: {},\n items: {},\n });\n}\n\nexport const ContainersContext = createContainerContext();\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA8B;AAYvB,SAAS,yBAA4B;AAC1C,aAAO,4BAAoC;AAAA,IACzC,sBAAsB,CAAC;AAAA,IACvB,OAAO,CAAC;AAAA,EACV,CAAC;AACH;AAEO,MAAM,oBAAoB,uBAAuB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -28,11 +28,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var DSSortableContainer_exports = {};
|
|
30
30
|
__export(DSSortableContainer_exports, {
|
|
31
|
-
ContainersContext: () =>
|
|
31
|
+
ContainersContext: () => import_SortableContainerContext.ContainersContext,
|
|
32
32
|
DSSortableContainer: () => import_DSSortableContainer.DSSortableContainer,
|
|
33
33
|
DSSortableContainerSchema: () => import_DSSortableContainer.DSSortableContainerSchema
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(DSSortableContainer_exports);
|
|
36
36
|
var React = __toESM(require("react"));
|
|
37
37
|
var import_DSSortableContainer = require("./DSSortableContainer.js");
|
|
38
|
+
var import_SortableContainerContext = require("./config/SortableContainerContext.js");
|
|
38
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/DSSortableContainer/index.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["export { DSSortableContainer, DSSortableContainerSchema
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,
|
|
4
|
+
"sourcesContent": ["export { DSSortableContainer, DSSortableContainerSchema } from './DSSortableContainer.js';\nexport { ContainersContext } from './config/SortableContainerContext.js';\nexport type { DSSortableContainerT } from './react-desc-prop-types.js';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,iCAA+D;AAC/D,sCAAkC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/DSSortableContainer/react-desc-prop-types.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-empty-interface */\n/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\nimport type { XstyledProps } from '@elliemae/ds-props-helpers';\nimport type { UniqueIdentifier } from '@dnd-kit/core/dist/types';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\nimport type { DnDKitTree } from '../../tree/types.js';\nimport type { ItemRendererPropsT } from '../DSSortableItem/index.js';\nexport declare namespace DSSortableContainerT {\n export interface WrapperComponentProps {\n innerRef: React.MutableRefObject<HTMLDivElement | null> | ((ref: HTMLDivElement | null) => void);\n isOver: boolean;\n children: React.ReactNode;\n }\n export interface RequiredProps {\n containerId: UniqueIdentifier;\n Component: React.ComponentType<WrapperComponentProps>;\n }\n\n export interface ContainerItemRendererT<T, K> {\n extraItemProps
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-empty-interface */\n/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\nimport type { XstyledProps } from '@elliemae/ds-props-helpers';\nimport type { UniqueIdentifier } from '@dnd-kit/core/dist/types';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\nimport type { DnDKitTree } from '../../tree/types.js';\nimport type { ItemRendererPropsT } from '../DSSortableItem/index.js';\nexport declare namespace DSSortableContainerT {\n export interface WrapperComponentProps {\n innerRef: React.MutableRefObject<HTMLDivElement | null> | ((ref: HTMLDivElement | null) => void);\n isOver: boolean;\n children: React.ReactNode;\n }\n export interface RequiredProps {\n containerId: UniqueIdentifier;\n Component: React.ComponentType<WrapperComponentProps>;\n }\n\n export interface ContainerItemRendererT<T, K> {\n extraItemProps?: {\n items: Item<T>[];\n extraItemProps: K;\n ItemRenderer: React.ComponentType<ItemRendererPropsT<T, K>>;\n };\n index: number;\n }\n\n export type ItemProp<T> = {\n dsId: number | string;\n subitems: ItemProp<T>[];\n } & T;\n\n // opinionated item type\n export type Item<T> = DnDKitTree.Item<T> & {\n dsId: number | string;\n subitems: Item<T>[];\n } & T;\n\n export interface DefaultProps {}\n\n export interface OptionalProps<T, K> {\n items?: Record<string, Item<T>[]>;\n extraItemProps?: K;\n ItemRenderer?: React.ComponentType<ItemRendererPropsT<T, K>>;\n children?: React.ReactNode;\n }\n\n export interface Props<T, K> extends Partial<DefaultProps>, OptionalProps<T, K>, XstyledProps, RequiredProps {}\n\n export interface InternalProps<T, K> extends DefaultProps, OptionalProps<T, K>, XstyledProps, RequiredProps {}\n}\n\nexport const DSSortalContainerPropTypes = {\n containerId: PropTypes.string.description('The id of the container').isRequired,\n Component: PropTypes.node.description('The component to be rendered as the container').isRequired,\n children: PropTypes.node.description('The children to be rendered in the container'),\n items: PropTypes.object.description('The items to be rendered in the container'),\n extraItemProps: PropTypes.object.description('The extra item props to be passed to the item renderer'),\n ItemRenderer: PropTypes.node.description('The item renderer to be used'),\n} as React.WeakValidationMap<unknown>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,8BAA0B;AAgDnB,MAAM,6BAA6B;AAAA,EACxC,aAAa,kCAAU,OAAO,YAAY,yBAAyB,EAAE;AAAA,EACrE,WAAW,kCAAU,KAAK,YAAY,+CAA+C,EAAE;AAAA,EACvF,UAAU,kCAAU,KAAK,YAAY,8CAA8C;AAAA,EACnF,OAAO,kCAAU,OAAO,YAAY,2CAA2C;AAAA,EAC/E,gBAAgB,kCAAU,OAAO,YAAY,wDAAwD;AAAA,EACrG,cAAc,kCAAU,KAAK,YAAY,8BAA8B;AACzE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -36,12 +36,12 @@ var React = __toESM(require("react"));
|
|
|
36
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
37
|
var import_react = require("react");
|
|
38
38
|
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
39
|
-
var
|
|
40
|
-
var
|
|
39
|
+
var import_sortable = require("@dnd-kit/sortable");
|
|
40
|
+
var import_SortableContainerContext = require("../DSSortableContainer/config/SortableContainerContext.js");
|
|
41
41
|
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
|
42
42
|
const DSSortableItem = (props) => {
|
|
43
43
|
const { item, index: userIndex, containerId, ItemRenderer, extraItemProps } = props;
|
|
44
|
-
const ctx = (0, import_react.useContext)(
|
|
44
|
+
const ctx = (0, import_react.useContext)(import_SortableContainerContext.ContainersContext);
|
|
45
45
|
const currentItem = item || (userIndex !== void 0 ? ctx.items[containerId || "root"][userIndex] : void 0);
|
|
46
46
|
const { isDropValid, dropIndicatorPosition, onCollapse } = ctx;
|
|
47
47
|
const draggableOptions = (0, import_react.useMemo)(
|
|
@@ -50,7 +50,7 @@ const DSSortableItem = (props) => {
|
|
|
50
50
|
}),
|
|
51
51
|
[currentItem]
|
|
52
52
|
);
|
|
53
|
-
const useSortableHelpers = (0,
|
|
53
|
+
const useSortableHelpers = (0, import_sortable.useSortable)(draggableOptions);
|
|
54
54
|
const draggableProps = (0, import_react.useMemo)(() => {
|
|
55
55
|
const { index, overIndex } = useSortableHelpers;
|
|
56
56
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/DSSortableItem/DSSortableItem.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useMemo, useContext } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React, { useMemo, useContext } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { ContainersContext } from '../DSSortableContainer/config/SortableContainerContext.js';\nimport type { DSSortableItemT, DraggablePropsT } from './react-desc-prop-types.js';\nimport { DSSortalItemPropTypes } from './react-desc-prop-types.js';\n\nimport type { Item } from '../DSDragAndDrop/index.js';\nexport const DSSortableItem = <T, K>(props: DSSortableItemT.Props<T, K>) => {\n const { item, index: userIndex, containerId, ItemRenderer, extraItemProps } = props;\n const ctx = useContext(ContainersContext);\n\n const currentItem = item || (userIndex !== undefined ? ctx.items[containerId || 'root'][userIndex] : undefined);\n\n const { isDropValid, dropIndicatorPosition, onCollapse } = ctx;\n\n // onMount generate unique options, so everyting is only ran once\n const draggableOptions = useMemo(\n () => ({\n id: currentItem?.dsId || '',\n }),\n [currentItem],\n );\n\n const useSortableHelpers = useSortable(draggableOptions);\n\n const draggableProps: DraggablePropsT = useMemo(() => {\n const { index, overIndex } = useSortableHelpers;\n\n return {\n ...useSortableHelpers,\n shouldShowDropIndicatorPosition: overIndex === index,\n dropIndicatorPosition: dropIndicatorPosition || 'none',\n isDropValid: isDropValid || false,\n };\n }, [dropIndicatorPosition, isDropValid, useSortableHelpers]);\n\n if (!currentItem) {\n return null;\n }\n return (\n <div ref={draggableProps.setNodeRef} style={{ position: 'relative' }}>\n <ItemRenderer\n item={currentItem as Item<T>}\n draggableProps={draggableProps}\n onCollapse={onCollapse}\n extraItemProps={extraItemProps as K}\n />\n </div>\n );\n};\n\nconst DSSortableItemSchema = describe(DSSortableItem);\n\nDSSortableItemSchema.propTypes = DSSortalItemPropTypes;\n\nexport { DSSortableItemSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD0CjB;AA1CN,mBAA2C;AAC3C,8BAAyB;AACzB,sBAA4B;AAC5B,sCAAkC;AAElC,mCAAsC;AAG/B,MAAM,iBAAiB,CAAO,UAAuC;AAC1E,QAAM,EAAE,MAAM,OAAO,WAAW,aAAa,cAAc,eAAe,IAAI;AAC9E,QAAM,UAAM,yBAAW,iDAAiB;AAExC,QAAM,cAAc,SAAS,cAAc,SAAY,IAAI,MAAM,eAAe,MAAM,EAAE,SAAS,IAAI;AAErG,QAAM,EAAE,aAAa,uBAAuB,WAAW,IAAI;AAG3D,QAAM,uBAAmB;AAAA,IACvB,OAAO;AAAA,MACL,IAAI,aAAa,QAAQ;AAAA,IAC3B;AAAA,IACA,CAAC,WAAW;AAAA,EACd;AAEA,QAAM,yBAAqB,6BAAY,gBAAgB;AAEvD,QAAM,qBAAkC,sBAAQ,MAAM;AACpD,UAAM,EAAE,OAAO,UAAU,IAAI;AAE7B,WAAO;AAAA,MACL,GAAG;AAAA,MACH,iCAAiC,cAAc;AAAA,MAC/C,uBAAuB,yBAAyB;AAAA,MAChD,aAAa,eAAe;AAAA,IAC9B;AAAA,EACF,GAAG,CAAC,uBAAuB,aAAa,kBAAkB,CAAC;AAE3D,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AACA,SACE,4CAAC,SAAI,KAAK,eAAe,YAAY,OAAO,EAAE,UAAU,WAAW,GACjE;AAAA,IAAC;AAAA;AAAA,MACC,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF,GACF;AAEJ;AAEA,MAAM,2BAAuB,kCAAS,cAAc;AAEpD,qBAAqB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,8 +32,8 @@ __export(customCollisionDetection_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(customCollisionDetection_exports);
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
|
-
var import_constants = require("./constants.js");
|
|
36
35
|
var import_core = require("@dnd-kit/core");
|
|
36
|
+
var import_constants = require("./constants.js");
|
|
37
37
|
const insideThreshold = 0.7;
|
|
38
38
|
const customCollisionDetection = (sensorContext) => {
|
|
39
39
|
const func = ({ droppableContainers, collisionRect, droppableRects, ...args }) => {
|
|
@@ -47,7 +47,7 @@ const customCollisionDetection = (sensorContext) => {
|
|
|
47
47
|
});
|
|
48
48
|
const { id: closestContainerOfContainersId } = rectIntersectionCollisions[0] ?? {};
|
|
49
49
|
const possibleCollidingContainers = droppableContainers.filter(
|
|
50
|
-
(container) => !containersRef.current.includes(container
|
|
50
|
+
(container) => !containersRef.current.includes(container?.id) && flattenedItemsDictionary[container?.id].container === closestContainerOfContainersId
|
|
51
51
|
);
|
|
52
52
|
const [collidingContainer, nearesCollidingContainer] = (0, import_core.closestCorners)({
|
|
53
53
|
...args,
|
|
@@ -68,10 +68,10 @@ const customCollisionDetection = (sensorContext) => {
|
|
|
68
68
|
];
|
|
69
69
|
const intersectionPercentage = Math.abs(bottom - top) / Math.min(collisionRect.height, collidingRect.height);
|
|
70
70
|
const isBefore = collisionRect.top + collisionRect.height / 2 < collidingRect.top + collidingRect.height / 2;
|
|
71
|
-
if (intersectionPercentage > insideThreshold && flattenedItemsDictionary[collidingContainer
|
|
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
|
|
74
|
+
const isFirstElement = flattenedItemsDictionary[collidingContainer?.id].realIndex === 0;
|
|
75
75
|
if (isFirstElement) {
|
|
76
76
|
dropIndicatorPosition = isBefore ? import_constants.DropIndicatorPosition.Before : import_constants.DropIndicatorPosition.After;
|
|
77
77
|
} else {
|
|
@@ -80,7 +80,7 @@ const customCollisionDetection = (sensorContext) => {
|
|
|
80
80
|
}
|
|
81
81
|
return [
|
|
82
82
|
{
|
|
83
|
-
id: isBefore && dropIndicatorPosition === import_constants.DropIndicatorPosition.After ? nearesCollidingContainer
|
|
83
|
+
id: isBefore && dropIndicatorPosition === import_constants.DropIndicatorPosition.After ? nearesCollidingContainer?.id : collidingContainer?.id,
|
|
84
84
|
data: { dropIndicatorPosition }
|
|
85
85
|
}
|
|
86
86
|
];
|
|
@@ -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 {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,
|
|
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;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,iCAA6B,8BAAiB;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,QAAI,4BAAe;AAAA,MACpE,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA,qBAAqB;AAAA,IACvB,CAAC;AAED,QAA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
3
|
import { useMemo } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
|
-
import {
|
|
6
|
-
DndContext,
|
|
7
|
-
DragOverlay,
|
|
8
|
-
restrictToWindowEdges,
|
|
9
|
-
useMultiTreeDndkitConfig
|
|
10
|
-
} from "../../index.js";
|
|
11
|
-
import { ContainersContext } from "../DSSortableContainer/index.js";
|
|
5
|
+
import { restrictToWindowEdges } from "@dnd-kit/modifiers";
|
|
12
6
|
import { describe } from "@elliemae/ds-props-helpers";
|
|
7
|
+
import { DragOverlay, DndContext } from "@dnd-kit/core";
|
|
8
|
+
import { useMultiTreeDndkitConfig } from "../../tree/index.js";
|
|
9
|
+
import { ContainersContext } from "../DSSortableContainer/config/SortableContainerContext.js";
|
|
13
10
|
import { DSDragAndDropPropTypes } from "./react-desc-prop-types.js";
|
|
14
11
|
const flatten = (items, parentId = null, depth = 0, container = "root", iteration = { count: 0 }) => items.reduce((acc, item, index) => {
|
|
15
12
|
acc.push({
|
|
@@ -17,7 +14,7 @@ const flatten = (items, parentId = null, depth = 0, container = "root", iteratio
|
|
|
17
14
|
uid: item.dsId,
|
|
18
15
|
childrenCount: item?.subitems?.length || 0,
|
|
19
16
|
original: item,
|
|
20
|
-
realIndex: iteration.count
|
|
17
|
+
realIndex: iteration.count + 1,
|
|
21
18
|
parentId,
|
|
22
19
|
depth,
|
|
23
20
|
index,
|
|
@@ -56,14 +53,12 @@ const DSDragAndDrop = ({
|
|
|
56
53
|
getIsDropValid: () => true,
|
|
57
54
|
...rest
|
|
58
55
|
});
|
|
56
|
+
const ctx = useMemo(
|
|
57
|
+
() => ({ sortableContextProps, dropIndicatorPosition, isDropValid, items: itemsFlattened, onCollapse }),
|
|
58
|
+
[dropIndicatorPosition, isDropValid, itemsFlattened, onCollapse, sortableContextProps]
|
|
59
|
+
);
|
|
59
60
|
return /* @__PURE__ */ jsxs(DndContext, { ...dndContextProps, children: [
|
|
60
|
-
/* @__PURE__ */ jsx(
|
|
61
|
-
ContainersContext.Provider,
|
|
62
|
-
{
|
|
63
|
-
value: { sortableContextProps, dropIndicatorPosition, isDropValid, items: itemsFlattened, onCollapse },
|
|
64
|
-
children
|
|
65
|
-
}
|
|
66
|
-
),
|
|
61
|
+
/* @__PURE__ */ jsx(ContainersContext.Provider, { value: ctx, children }),
|
|
67
62
|
createPortal(
|
|
68
63
|
/* @__PURE__ */ jsx(DragOverlay, { style: { width: "auto", zIndex: 1001 }, modifiers: [restrictToWindowEdges], children: active ? /* @__PURE__ */ jsx(DragOverlayRenderer, { activeItem: active }) : null }),
|
|
69
64
|
document.body
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSDragAndDrop/DSDragAndDrop.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport React, { useMemo } from 'react';\nimport { createPortal } from 'react-dom';\nimport {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport React, { useMemo } from 'react';\nimport { createPortal } from 'react-dom';\nimport { type UniqueIdentifier } from '@dnd-kit/core/dist/types';\nimport { restrictToWindowEdges } from '@dnd-kit/modifiers';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { DragOverlay, DndContext } from '@dnd-kit/core';\nimport { useMultiTreeDndkitConfig } from '../../tree/index.js';\nimport { ContainersContext } from '../DSSortableContainer/config/SortableContainerContext.js';\nimport type { DSDragAndDropT, Item } from './react-desc-prop-types.js';\nimport { DSDragAndDropPropTypes } from './react-desc-prop-types.js';\n\nconst flatten = <T,>(\n items: Item<T>[],\n parentId: UniqueIdentifier | null = null,\n depth = 0,\n container = 'root',\n iteration = { count: 0 },\n) =>\n items.reduce((acc, item, index) => {\n acc.push({\n ...item,\n uid: item.dsId,\n childrenCount: item?.subitems?.length || 0,\n original: item,\n realIndex: iteration.count + 1,\n parentId,\n depth,\n index,\n container,\n });\n if (item.subitems?.length > 0 && item.collapsed === false) {\n acc.push(...flatten(item.subitems, item.dsId, depth + 1, container, iteration));\n }\n return acc;\n }, [] as Item<T>[]);\n\nexport const DSDragAndDrop = <T,>({\n items,\n children,\n onReorder,\n onCollapse,\n DragOverlayRenderer,\n maxDragAndDropLevel = 0,\n ...rest\n}: DSDragAndDropT.Props<T>) => {\n const itemsFlattened = useMemo(\n () =>\n Object.keys(items).reduce(\n (acc, container) => {\n acc[container] = flatten(items[container] as Item<T>[], null, 0, container);\n return acc;\n },\n {} as Record<string, Item<T>[]>,\n ),\n [items],\n );\n const { dndContextProps, sortableContextProps, active, dropIndicatorPosition, isDropValid } =\n useMultiTreeDndkitConfig({\n flattenedItems: itemsFlattened,\n isHorizontalDnD: false,\n isExpandable: true,\n onReorder,\n maxDragAndDropLevel,\n getIsDropValid: () => true,\n ...rest,\n });\n\n const ctx = useMemo(\n () => ({ sortableContextProps, dropIndicatorPosition, isDropValid, items: itemsFlattened, onCollapse }),\n [dropIndicatorPosition, isDropValid, itemsFlattened, onCollapse, sortableContextProps],\n );\n\n return (\n <DndContext {...dndContextProps}>\n <ContainersContext.Provider value={ctx}>{children}</ContainersContext.Provider>\n {createPortal(\n <DragOverlay style={{ width: 'auto', zIndex: 1001 }} modifiers={[restrictToWindowEdges]}>\n {active ? <DragOverlayRenderer activeItem={active} /> : null}\n </DragOverlay>,\n document.body,\n )}\n </DndContext>\n );\n};\n\nconst DSDragAndDropWithSchema = describe(DSDragAndDrop);\n\nDSDragAndDropWithSchema.propTypes = DSDragAndDropPropTypes;\n\nexport { DSDragAndDropWithSchema };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC0EnB,SACE,KADF;AAzEJ,SAAgB,eAAe;AAC/B,SAAS,oBAAoB;AAE7B,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AACzB,SAAS,aAAa,kBA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B,aAAa,OAAO,gBAAgB,WAAW;AAAA,IACrG,CAAC,uBAAuB,aAAa,gBAAgB,YAAY,oBAAoB;AAAA,EACvF;AAEA,SACE,qBAAC,cAAY,GAAG,iBACd;AAAA,wBAAC,kBAAkB,UAAlB,EAA2B,OAAO,KAAM,UAAS;AAAA,IACjD;AAAA,MACC,oBAAC,eAAY,OAAO,EAAE,OAAO,QAAQ,QAAQ,KAAK,GAAG,WAAW,CAAC,qBAAqB,GACnF,mBAAS,oBAAC,uBAAoB,YAAY,QAAQ,IAAK,MAC1D;AAAA,MACA,SAAS;AAAA,IACX;AAAA,KACF;AAEJ;AAEA,MAAM,0BAA0B,SAAS,aAAa;AAEtD,wBAAwB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import React2, { useContext,
|
|
3
|
+
import React2, { useContext, useMemo } from "react";
|
|
4
4
|
import { DSFastList } from "@elliemae/ds-fast-list";
|
|
5
5
|
import { describe } from "@elliemae/ds-props-helpers";
|
|
6
|
-
import {
|
|
6
|
+
import { useDroppable } from "@dnd-kit/core";
|
|
7
|
+
import { SortableContext } from "@dnd-kit/sortable";
|
|
8
|
+
import { DSSortableItem } from "../DSSortableItem/index.js";
|
|
7
9
|
import { DSSortalContainerPropTypes } from "./react-desc-prop-types.js";
|
|
8
|
-
|
|
9
|
-
return createContext({
|
|
10
|
-
sortableContextProps: {},
|
|
11
|
-
items: {}
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
const ContainersContext = createContainerContext();
|
|
10
|
+
import { ContainersContext } from "./config/SortableContainerContext.js";
|
|
15
11
|
const ContainerItemRenderer = (props) => {
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
12
|
+
const { index, extraItemProps } = props;
|
|
13
|
+
if (!extraItemProps) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const { items, ItemRenderer, ...rest } = extraItemProps;
|
|
20
17
|
const item = items[index];
|
|
21
|
-
return /* @__PURE__ */ jsx(
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
DSSortableItem,
|
|
20
|
+
{
|
|
21
|
+
item,
|
|
22
|
+
ItemRenderer,
|
|
23
|
+
...rest,
|
|
24
|
+
extraItemProps
|
|
25
|
+
}
|
|
26
|
+
);
|
|
22
27
|
};
|
|
23
28
|
const ContainerItemRendererMemoized = React2.memo(ContainerItemRenderer);
|
|
24
29
|
const DSSortableContainer = (props) => {
|
|
@@ -55,9 +60,7 @@ const DSSortableContainer = (props) => {
|
|
|
55
60
|
const DSSortableContainerSchema = describe(DSSortableContainer);
|
|
56
61
|
DSSortableContainerSchema.propTypes = DSSortalContainerPropTypes;
|
|
57
62
|
export {
|
|
58
|
-
ContainersContext,
|
|
59
63
|
DSSortableContainer,
|
|
60
|
-
DSSortableContainerSchema
|
|
61
|
-
createContainerContext
|
|
64
|
+
DSSortableContainerSchema
|
|
62
65
|
};
|
|
63
66
|
//# sourceMappingURL=DSSortableContainer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSSortableContainer/DSSortableContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext,
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { DSFastList } from '@elliemae/ds-fast-list';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { useDroppable } from '@dnd-kit/core';\nimport { SortableContext } from '@dnd-kit/sortable';\nimport { DSSortableItem } from '../DSSortableItem/index.js';\nimport type { DSSortableContainerT } from './react-desc-prop-types.js';\nimport { DSSortalContainerPropTypes } from './react-desc-prop-types.js';\nimport type { ItemRendererPropsT } from '../DSSortableItem/index.js';\nimport { ContainersContext } from './config/SortableContainerContext.js';\nimport type { Item } from '../DSDragAndDrop/index.js';\nconst ContainerItemRenderer = <T, K>(props: DSSortableContainerT.ContainerItemRendererT<T, K>) => {\n const { index, extraItemProps } = props;\n if (!extraItemProps) {\n return null;\n }\n const { items, ItemRenderer, ...rest } = extraItemProps;\n const item = items[index];\n return (\n <DSSortableItem\n item={item}\n ItemRenderer={\n ItemRenderer as React.ComponentType<\n ItemRendererPropsT<\n T,\n { items: Item<T>[]; extraItemProps: K; ItemRenderer: React.ComponentType<ItemRendererPropsT<T, K>> }\n >\n >\n }\n {...rest}\n extraItemProps={extraItemProps}\n />\n );\n};\n\nconst ContainerItemRendererMemoized = React.memo(ContainerItemRenderer);\n\nexport const DSSortableContainer = <T, K>(props: DSSortableContainerT.Props<T, K>) => {\n const { containerId, ItemRenderer, Component, extraItemProps, children } = props;\n const { setNodeRef, isOver } = useDroppable({\n id: containerId,\n });\n const ctx = useContext(ContainersContext);\n const { sortableContextProps, items } = ctx;\n const containerSortableContextProps = sortableContextProps[containerId];\n\n const render = useMemo(() => {\n if (children) {\n return children;\n }\n if (ItemRenderer) {\n return (\n <DSFastList\n count={items[containerId].length}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any\n ItemRenderer={ContainerItemRendererMemoized as any}\n extraItemProps={{\n items: items[containerId],\n ItemRenderer: ItemRenderer as React.ComponentType<ItemRendererPropsT<unknown, unknown>>,\n extraItemProps,\n }}\n getId={(index: number | string) => items[containerId][index as number].dsId}\n />\n );\n }\n return null;\n }, [ItemRenderer, children, containerId, extraItemProps, items]);\n\n return (\n <SortableContext {...containerSortableContextProps} id=\"container\">\n <Component innerRef={setNodeRef} isOver={isOver}>\n {render}\n </Component>\n </SortableContext>\n );\n};\n\nconst DSSortableContainerSchema = describe(DSSortableContainer);\nDSSortableContainerSchema.propTypes =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,IAEJ;AACA,WAAO;AAAA,EACT,GAAG,CAAC,cAAc,UAAU,aAAa,gBAAgB,KAAK,CAAC;AAE/D,SACE,oBAAC,mBAAiB,GAAG,+BAA+B,IAAG,aACrD,8BAAC,aAAU,UAAU,YAAY,QAC9B,kBACH,GACF;AAEJ;AAEA,MAAM,4BAA4B,SAAS,mBAAmB;AAC9D,0BAA0B,YAAY;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
function createContainerContext() {
|
|
4
|
+
return createContext({
|
|
5
|
+
sortableContextProps: {},
|
|
6
|
+
items: {}
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
const ContainersContext = createContainerContext();
|
|
10
|
+
export {
|
|
11
|
+
ContainersContext,
|
|
12
|
+
createContainerContext
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=SortableContainerContext.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/DSSortableContainer/config/SortableContainerContext.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext } from 'react';\nimport type { DnDKitTree } from '../../../tree/types.js';\nimport type { DSSortableContainerT } from '../react-desc-prop-types.js';\n\ninterface ContainerContextT<T> {\n isDropValid?: boolean;\n dropIndicatorPosition?: string;\n sortableContextProps: Record<string, DnDKitTree.SortableContextPropsType>;\n items: Record<string, DSSortableContainerT.Item<T>[]>;\n onCollapse?: (nodeId: string) => void;\n}\n\nexport function createContainerContext<T>() {\n return createContext<ContainerContextT<T>>({\n sortableContextProps: {},\n items: {},\n });\n}\n\nexport const ContainersContext = createContainerContext();\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB;AAYvB,SAAS,yBAA4B;AAC1C,SAAO,cAAoC;AAAA,IACzC,sBAAsB,CAAC;AAAA,IACvB,OAAO,CAAC;AAAA,EACV,CAAC;AACH;AAEO,MAAM,oBAAoB,uBAAuB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { DSSortableContainer, DSSortableContainerSchema
|
|
2
|
+
import { DSSortableContainer, DSSortableContainerSchema } from "./DSSortableContainer.js";
|
|
3
|
+
import { ContainersContext } from "./config/SortableContainerContext.js";
|
|
3
4
|
export {
|
|
4
5
|
ContainersContext,
|
|
5
6
|
DSSortableContainer,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSSortableContainer/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { DSSortableContainer, DSSortableContainerSchema
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { DSSortableContainer, DSSortableContainerSchema } from './DSSortableContainer.js';\nexport { ContainersContext } from './config/SortableContainerContext.js';\nexport type { DSSortableContainerT } from './react-desc-prop-types.js';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB,iCAAiC;AAC/D,SAAS,yBAAyB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSSortableContainer/react-desc-prop-types.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-empty-interface */\n/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\nimport type { XstyledProps } from '@elliemae/ds-props-helpers';\nimport type { UniqueIdentifier } from '@dnd-kit/core/dist/types';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\nimport type { DnDKitTree } from '../../tree/types.js';\nimport type { ItemRendererPropsT } from '../DSSortableItem/index.js';\nexport declare namespace DSSortableContainerT {\n export interface WrapperComponentProps {\n innerRef: React.MutableRefObject<HTMLDivElement | null> | ((ref: HTMLDivElement | null) => void);\n isOver: boolean;\n children: React.ReactNode;\n }\n export interface RequiredProps {\n containerId: UniqueIdentifier;\n Component: React.ComponentType<WrapperComponentProps>;\n }\n\n export interface ContainerItemRendererT<T, K> {\n extraItemProps
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-empty-interface */\n/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\nimport type { XstyledProps } from '@elliemae/ds-props-helpers';\nimport type { UniqueIdentifier } from '@dnd-kit/core/dist/types';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\nimport type { DnDKitTree } from '../../tree/types.js';\nimport type { ItemRendererPropsT } from '../DSSortableItem/index.js';\nexport declare namespace DSSortableContainerT {\n export interface WrapperComponentProps {\n innerRef: React.MutableRefObject<HTMLDivElement | null> | ((ref: HTMLDivElement | null) => void);\n isOver: boolean;\n children: React.ReactNode;\n }\n export interface RequiredProps {\n containerId: UniqueIdentifier;\n Component: React.ComponentType<WrapperComponentProps>;\n }\n\n export interface ContainerItemRendererT<T, K> {\n extraItemProps?: {\n items: Item<T>[];\n extraItemProps: K;\n ItemRenderer: React.ComponentType<ItemRendererPropsT<T, K>>;\n };\n index: number;\n }\n\n export type ItemProp<T> = {\n dsId: number | string;\n subitems: ItemProp<T>[];\n } & T;\n\n // opinionated item type\n export type Item<T> = DnDKitTree.Item<T> & {\n dsId: number | string;\n subitems: Item<T>[];\n } & T;\n\n export interface DefaultProps {}\n\n export interface OptionalProps<T, K> {\n items?: Record<string, Item<T>[]>;\n extraItemProps?: K;\n ItemRenderer?: React.ComponentType<ItemRendererPropsT<T, K>>;\n children?: React.ReactNode;\n }\n\n export interface Props<T, K> extends Partial<DefaultProps>, OptionalProps<T, K>, XstyledProps, RequiredProps {}\n\n export interface InternalProps<T, K> extends DefaultProps, OptionalProps<T, K>, XstyledProps, RequiredProps {}\n}\n\nexport const DSSortalContainerPropTypes = {\n containerId: PropTypes.string.description('The id of the container').isRequired,\n Component: PropTypes.node.description('The component to be rendered as the container').isRequired,\n children: PropTypes.node.description('The children to be rendered in the container'),\n items: PropTypes.object.description('The items to be rendered in the container'),\n extraItemProps: PropTypes.object.description('The extra item props to be passed to the item renderer'),\n ItemRenderer: PropTypes.node.description('The item renderer to be used'),\n} as React.WeakValidationMap<unknown>;\n"],
|
|
5
5
|
"mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,iBAAiB;AAgDnB,MAAM,6BAA6B;AAAA,EACxC,aAAa,UAAU,OAAO,YAAY,yBAAyB,EAAE;AAAA,EACrE,WAAW,UAAU,KAAK,YAAY,+CAA+C,EAAE;AAAA,EACvF,UAAU,UAAU,KAAK,YAAY,8CAA8C;AAAA,EACnF,OAAO,UAAU,OAAO,YAAY,2CAA2C;AAAA,EAC/E,gBAAgB,UAAU,OAAO,YAAY,wDAAwD;AAAA,EACrG,cAAc,UAAU,KAAK,YAAY,8BAA8B;AACzE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,8 +2,8 @@ import * as React from "react";
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo, useContext } from "react";
|
|
4
4
|
import { describe } from "@elliemae/ds-props-helpers";
|
|
5
|
-
import { useSortable } from "
|
|
6
|
-
import { ContainersContext } from "../DSSortableContainer/
|
|
5
|
+
import { useSortable } from "@dnd-kit/sortable";
|
|
6
|
+
import { ContainersContext } from "../DSSortableContainer/config/SortableContainerContext.js";
|
|
7
7
|
import { DSSortalItemPropTypes } from "./react-desc-prop-types.js";
|
|
8
8
|
const DSSortableItem = (props) => {
|
|
9
9
|
const { item, index: userIndex, containerId, ItemRenderer, extraItemProps } = props;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSSortableItem/DSSortableItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useMemo, useContext } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useMemo, useContext } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { ContainersContext } from '../DSSortableContainer/config/SortableContainerContext.js';\nimport type { DSSortableItemT, DraggablePropsT } from './react-desc-prop-types.js';\nimport { DSSortalItemPropTypes } from './react-desc-prop-types.js';\n\nimport type { Item } from '../DSDragAndDrop/index.js';\nexport const DSSortableItem = <T, K>(props: DSSortableItemT.Props<T, K>) => {\n const { item, index: userIndex, containerId, ItemRenderer, extraItemProps } = props;\n const ctx = useContext(ContainersContext);\n\n const currentItem = item || (userIndex !== undefined ? ctx.items[containerId || 'root'][userIndex] : undefined);\n\n const { isDropValid, dropIndicatorPosition, onCollapse } = ctx;\n\n // onMount generate unique options, so everyting is only ran once\n const draggableOptions = useMemo(\n () => ({\n id: currentItem?.dsId || '',\n }),\n [currentItem],\n );\n\n const useSortableHelpers = useSortable(draggableOptions);\n\n const draggableProps: DraggablePropsT = useMemo(() => {\n const { index, overIndex } = useSortableHelpers;\n\n return {\n ...useSortableHelpers,\n shouldShowDropIndicatorPosition: overIndex === index,\n dropIndicatorPosition: dropIndicatorPosition || 'none',\n isDropValid: isDropValid || false,\n };\n }, [dropIndicatorPosition, isDropValid, useSortableHelpers]);\n\n if (!currentItem) {\n return null;\n }\n return (\n <div ref={draggableProps.setNodeRef} style={{ position: 'relative' }}>\n <ItemRenderer\n item={currentItem as Item<T>}\n draggableProps={draggableProps}\n onCollapse={onCollapse}\n extraItemProps={extraItemProps as K}\n />\n </div>\n );\n};\n\nconst DSSortableItemSchema = describe(DSSortableItem);\n\nDSSortableItemSchema.propTypes = DSSortalItemPropTypes;\n\nexport { DSSortableItemSchema };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC0CjB;AA1CN,SAAgB,SAAS,kBAAkB;AAC3C,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAElC,SAAS,6BAA6B;AAG/B,MAAM,iBAAiB,CAAO,UAAuC;AAC1E,QAAM,EAAE,MAAM,OAAO,WAAW,aAAa,cAAc,eAAe,IAAI;AAC9E,QAAM,MAAM,WAAW,iBAAiB;AAExC,QAAM,cAAc,SAAS,cAAc,SAAY,IAAI,MAAM,eAAe,MAAM,EAAE,SAAS,IAAI;AAErG,QAAM,EAAE,aAAa,uBAAuB,WAAW,IAAI;AAG3D,QAAM,mBAAmB;AAAA,IACvB,OAAO;AAAA,MACL,IAAI,aAAa,QAAQ;AAAA,IAC3B;AAAA,IACA,CAAC,WAAW;AAAA,EACd;AAEA,QAAM,qBAAqB,YAAY,gBAAgB;AAEvD,QAAM,iBAAkC,QAAQ,MAAM;AACpD,UAAM,EAAE,OAAO,UAAU,IAAI;AAE7B,WAAO;AAAA,MACL,GAAG;AAAA,MACH,iCAAiC,cAAc;AAAA,MAC/C,uBAAuB,yBAAyB;AAAA,MAChD,aAAa,eAAe;AAAA,IAC9B;AAAA,EACF,GAAG,CAAC,uBAAuB,aAAa,kBAAkB,CAAC;AAE3D,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AACA,SACE,oBAAC,SAAI,KAAK,eAAe,YAAY,OAAO,EAAE,UAAU,WAAW,GACjE;AAAA,IAAC;AAAA;AAAA,MACC,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF,GACF;AAEJ;AAEA,MAAM,uBAAuB,SAAS,cAAc;AAEpD,qBAAqB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { DropIndicatorPosition } from "./constants.js";
|
|
3
2
|
import { rectIntersection, closestCorners } from "@dnd-kit/core";
|
|
3
|
+
import { DropIndicatorPosition } from "./constants.js";
|
|
4
4
|
const insideThreshold = 0.7;
|
|
5
5
|
const customCollisionDetection = (sensorContext) => {
|
|
6
6
|
const func = ({ droppableContainers, collisionRect, droppableRects, ...args }) => {
|
|
@@ -14,7 +14,7 @@ const customCollisionDetection = (sensorContext) => {
|
|
|
14
14
|
});
|
|
15
15
|
const { id: closestContainerOfContainersId } = rectIntersectionCollisions[0] ?? {};
|
|
16
16
|
const possibleCollidingContainers = droppableContainers.filter(
|
|
17
|
-
(container) => !containersRef.current.includes(container
|
|
17
|
+
(container) => !containersRef.current.includes(container?.id) && flattenedItemsDictionary[container?.id].container === closestContainerOfContainersId
|
|
18
18
|
);
|
|
19
19
|
const [collidingContainer, nearesCollidingContainer] = closestCorners({
|
|
20
20
|
...args,
|
|
@@ -35,10 +35,10 @@ const customCollisionDetection = (sensorContext) => {
|
|
|
35
35
|
];
|
|
36
36
|
const intersectionPercentage = Math.abs(bottom - top) / Math.min(collisionRect.height, collidingRect.height);
|
|
37
37
|
const isBefore = collisionRect.top + collisionRect.height / 2 < collidingRect.top + collidingRect.height / 2;
|
|
38
|
-
if (intersectionPercentage > insideThreshold && flattenedItemsDictionary[collidingContainer
|
|
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
|
|
41
|
+
const isFirstElement = flattenedItemsDictionary[collidingContainer?.id].realIndex === 0;
|
|
42
42
|
if (isFirstElement) {
|
|
43
43
|
dropIndicatorPosition = isBefore ? DropIndicatorPosition.Before : DropIndicatorPosition.After;
|
|
44
44
|
} else {
|
|
@@ -47,7 +47,7 @@ const customCollisionDetection = (sensorContext) => {
|
|
|
47
47
|
}
|
|
48
48
|
return [
|
|
49
49
|
{
|
|
50
|
-
id: isBefore && dropIndicatorPosition === DropIndicatorPosition.After ? nearesCollidingContainer
|
|
50
|
+
id: isBefore && dropIndicatorPosition === DropIndicatorPosition.After ? nearesCollidingContainer?.id : collidingContainer?.id,
|
|
51
51
|
data: { dropIndicatorPosition }
|
|
52
52
|
}
|
|
53
53
|
];
|
|
@@ -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 {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACEvB,
|
|
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
|
+
"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Q,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;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { DSSortableContainerT } from './react-desc-prop-types.js';
|
|
3
|
-
import type { DnDKitTree } from '../../tree/types.js';
|
|
4
|
-
interface ContainerContextT<T> {
|
|
5
|
-
isDropValid?: boolean;
|
|
6
|
-
dropIndicatorPosition?: string;
|
|
7
|
-
sortableContextProps: Record<string, DnDKitTree.SortableContextPropsType>;
|
|
8
|
-
items: Record<string, DSSortableContainerT.Item<T>[]>;
|
|
9
|
-
onCollapse?: (nodeId: string) => void;
|
|
10
|
-
}
|
|
11
|
-
export declare function createContainerContext<T>(): React.Context<ContainerContextT<T>>;
|
|
12
|
-
export declare const ContainersContext: React.Context<ContainerContextT<unknown>>;
|
|
13
2
|
export declare const DSSortableContainer: <T, K>(props: DSSortableContainerT.Props<T, K>) => import("react/jsx-runtime.js").JSX.Element;
|
|
14
3
|
declare const DSSortableContainerSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<DSSortableContainerT.Props<unknown, unknown>>;
|
|
15
4
|
export { DSSortableContainerSchema };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DnDKitTree } from '../../../tree/types.js';
|
|
3
|
+
import type { DSSortableContainerT } from '../react-desc-prop-types.js';
|
|
4
|
+
interface ContainerContextT<T> {
|
|
5
|
+
isDropValid?: boolean;
|
|
6
|
+
dropIndicatorPosition?: string;
|
|
7
|
+
sortableContextProps: Record<string, DnDKitTree.SortableContextPropsType>;
|
|
8
|
+
items: Record<string, DSSortableContainerT.Item<T>[]>;
|
|
9
|
+
onCollapse?: (nodeId: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function createContainerContext<T>(): import("react").Context<ContainerContextT<T>>;
|
|
12
|
+
export declare const ContainersContext: import("react").Context<ContainerContextT<unknown>>;
|
|
13
|
+
export {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { DSSortableContainer, DSSortableContainerSchema
|
|
1
|
+
export { DSSortableContainer, DSSortableContainerSchema } from './DSSortableContainer.js';
|
|
2
|
+
export { ContainersContext } from './config/SortableContainerContext.js';
|
|
2
3
|
export type { DSSortableContainerT } from './react-desc-prop-types.js';
|
|
@@ -14,7 +14,7 @@ export declare namespace DSSortableContainerT {
|
|
|
14
14
|
Component: React.ComponentType<WrapperComponentProps>;
|
|
15
15
|
}
|
|
16
16
|
interface ContainerItemRendererT<T, K> {
|
|
17
|
-
extraItemProps
|
|
17
|
+
extraItemProps?: {
|
|
18
18
|
items: Item<T>[];
|
|
19
19
|
extraItemProps: K;
|
|
20
20
|
ItemRenderer: React.ComponentType<ItemRendererPropsT<T, K>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-drag-and-drop",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.38.0-rc.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Drag And Drop",
|
|
6
6
|
"files": [
|
|
@@ -111,16 +111,16 @@
|
|
|
111
111
|
"@dnd-kit/core": "~6.0.8",
|
|
112
112
|
"@dnd-kit/modifiers": "~6.0.1",
|
|
113
113
|
"@dnd-kit/sortable": "~7.0.2",
|
|
114
|
-
"@elliemae/ds-fast-list": "3.
|
|
115
|
-
"@elliemae/ds-system": "3.
|
|
116
|
-
"@elliemae/ds-
|
|
117
|
-
"@elliemae/ds-
|
|
118
|
-
"@elliemae/ds-tree-model": "3.
|
|
114
|
+
"@elliemae/ds-fast-list": "3.38.0-rc.0",
|
|
115
|
+
"@elliemae/ds-system": "3.38.0-rc.0",
|
|
116
|
+
"@elliemae/ds-props-helpers": "3.38.0-rc.0",
|
|
117
|
+
"@elliemae/ds-typescript-helpers": "3.38.0-rc.0",
|
|
118
|
+
"@elliemae/ds-tree-model": "3.38.0-rc.0"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@elliemae/pui-cli": "9.0.0-next.50",
|
|
122
122
|
"styled-components": "~5.3.9",
|
|
123
|
-
"@elliemae/ds-monorepo-devops": "3.
|
|
123
|
+
"@elliemae/ds-monorepo-devops": "3.38.0-rc.0"
|
|
124
124
|
},
|
|
125
125
|
"peerDependencies": {
|
|
126
126
|
"lodash": "^4.17.21",
|