@elliemae/ds-treeview 2.3.0-alpha.2 → 2.3.0-alpha.3

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.
Files changed (93) hide show
  1. package/cjs/TreeView.js +1 -3
  2. package/cjs/TreeView.js.map +2 -2
  3. package/cjs/TreeViewContext.js +2 -8
  4. package/cjs/TreeViewContext.js.map +2 -2
  5. package/cjs/config/useTreeview.js +14 -28
  6. package/cjs/config/useTreeview.js.map +2 -2
  7. package/cjs/hoc/DnDTreeContext.js +45 -0
  8. package/cjs/hoc/DnDTreeContext.js.map +7 -0
  9. package/cjs/hoc/SortableItemContext.js +46 -0
  10. package/cjs/hoc/SortableItemContext.js.map +7 -0
  11. package/cjs/hoc/WithConditionalDnDContext.js +128 -0
  12. package/cjs/hoc/WithConditionalDnDContext.js.map +7 -0
  13. package/cjs/hoc/WithDnDSortableItemContext.js +69 -0
  14. package/cjs/hoc/WithDnDSortableItemContext.js.map +7 -0
  15. package/cjs/parts/DnDHandle.js +57 -0
  16. package/cjs/parts/DnDHandle.js.map +7 -0
  17. package/cjs/parts/DropIndicator.js +80 -0
  18. package/cjs/parts/DropIndicator.js.map +7 -0
  19. package/cjs/parts/TreeItem.js +37 -62
  20. package/cjs/parts/TreeItem.js.map +2 -2
  21. package/cjs/parts/TreeList.js +13 -18
  22. package/cjs/parts/TreeList.js.map +2 -2
  23. package/cjs/plugins/dnd/TreeDndPlugin.js +0 -24
  24. package/cjs/plugins/dnd/TreeDndPlugin.js.map +2 -2
  25. package/cjs/react-desc-prop-types.js +1 -0
  26. package/cjs/react-desc-prop-types.js.map +2 -2
  27. package/cjs/sharedTypes.js.map +1 -1
  28. package/cjs/utils/keyboard-helpers.js +7 -7
  29. package/cjs/utils/keyboard-helpers.js.map +2 -2
  30. package/cjs/utils/refs-helpers.js.map +1 -1
  31. package/cjs/utils/tree-helpers.js +21 -1
  32. package/cjs/utils/tree-helpers.js.map +2 -2
  33. package/cjs/utils/useTree.js +3 -1
  34. package/cjs/utils/useTree.js.map +2 -2
  35. package/esm/TreeView.js +1 -3
  36. package/esm/TreeView.js.map +2 -2
  37. package/esm/TreeViewContext.js +2 -8
  38. package/esm/TreeViewContext.js.map +2 -2
  39. package/esm/config/useTreeview.js +15 -29
  40. package/esm/config/useTreeview.js.map +2 -2
  41. package/esm/hoc/DnDTreeContext.js +16 -0
  42. package/esm/hoc/DnDTreeContext.js.map +7 -0
  43. package/esm/hoc/SortableItemContext.js +17 -0
  44. package/esm/hoc/SortableItemContext.js.map +7 -0
  45. package/esm/hoc/WithConditionalDnDContext.js +99 -0
  46. package/esm/hoc/WithConditionalDnDContext.js.map +7 -0
  47. package/esm/hoc/WithDnDSortableItemContext.js +40 -0
  48. package/esm/hoc/WithDnDSortableItemContext.js.map +7 -0
  49. package/esm/parts/DnDHandle.js +28 -0
  50. package/esm/parts/DnDHandle.js.map +7 -0
  51. package/esm/parts/DropIndicator.js +51 -0
  52. package/esm/parts/DropIndicator.js.map +7 -0
  53. package/esm/parts/TreeItem.js +37 -62
  54. package/esm/parts/TreeItem.js.map +2 -2
  55. package/esm/parts/TreeList.js +12 -17
  56. package/esm/parts/TreeList.js.map +2 -2
  57. package/esm/plugins/dnd/TreeDndPlugin.js +0 -24
  58. package/esm/plugins/dnd/TreeDndPlugin.js.map +2 -2
  59. package/esm/react-desc-prop-types.js +1 -0
  60. package/esm/react-desc-prop-types.js.map +2 -2
  61. package/esm/utils/keyboard-helpers.js +7 -7
  62. package/esm/utils/keyboard-helpers.js.map +2 -2
  63. package/esm/utils/refs-helpers.js.map +1 -1
  64. package/esm/utils/tree-helpers.js +21 -1
  65. package/esm/utils/tree-helpers.js.map +2 -2
  66. package/esm/utils/useTree.js +4 -2
  67. package/esm/utils/useTree.js.map +2 -2
  68. package/package.json +34 -18
  69. package/types/hoc/DnDTreeContext.d.ts +14 -0
  70. package/types/hoc/SortableItemContext.d.ts +19 -0
  71. package/types/hoc/WithConditionalDnDContext.d.ts +4 -0
  72. package/types/hoc/WithDnDSortableItemContext.d.ts +4 -0
  73. package/types/parts/DnDHandle.d.ts +6 -0
  74. package/types/parts/DropIndicator.d.ts +10 -0
  75. package/types/parts/TreeItem.d.ts +4 -11
  76. package/types/parts/TreeList.d.ts +0 -4
  77. package/types/plugins/dnd/TreeDndPlugin.d.ts +0 -2
  78. package/types/react-desc-prop-types.d.ts +17 -3
  79. package/types/sharedTypes.d.ts +1 -8
  80. package/types/utils/keyboard-helpers.d.ts +2 -1
  81. package/types/utils/refs-helpers.d.ts +1 -1
  82. package/types/utils/tree-helpers.d.ts +4 -1
  83. package/types/utils/useTree.d.ts +1 -0
  84. package/cjs/utils/dnd-helpers.js +0 -146
  85. package/cjs/utils/dnd-helpers.js.map +0 -7
  86. package/cjs/utils/useDnDHelpers.js +0 -199
  87. package/cjs/utils/useDnDHelpers.js.map +0 -7
  88. package/esm/utils/dnd-helpers.js +0 -117
  89. package/esm/utils/dnd-helpers.js.map +0 -7
  90. package/esm/utils/useDnDHelpers.js +0 -170
  91. package/esm/utils/useDnDHelpers.js.map +0 -7
  92. package/types/utils/dnd-helpers.d.ts +0 -39
  93. package/types/utils/useDnDHelpers.d.ts +0 -26
@@ -0,0 +1,99 @@
1
+ import * as React from "react";
2
+ import React2, { useCallback, useContext, useMemo } from "react";
3
+ import { DndContext, DragOverlay } from "@dnd-kit/core";
4
+ import { SortableContext } from "@dnd-kit/sortable";
5
+ import { useTreeDndkitConfig } from "@elliemae/ds-drag-and-drop";
6
+ import TreeViewContext from "../TreeViewContext";
7
+ import { TreeItem } from "../parts/TreeItem";
8
+ import { DnDTreeContext } from "./DnDTreeContext";
9
+ const ensure = (argument, message = "This should never happen") => {
10
+ if (argument === void 0 || argument === null) {
11
+ throw new TypeError(message);
12
+ }
13
+ return argument;
14
+ };
15
+ const withConditionalDnDRowContext = (Component) => (props) => {
16
+ const [lastActiveId, setLastActiveId] = React2.useState("");
17
+ const {
18
+ props: { data, onOrderChange, getIsDropValid },
19
+ flattenedItems,
20
+ visibleItems: flattenedVisibleTree,
21
+ withDragAndDrop
22
+ } = useContext(TreeViewContext);
23
+ const flattenedVisibleTreeForDnD = useMemo(() => flattenedVisibleTree.map((item, index) => ({
24
+ uid: item.id.toString(),
25
+ depth: (item.treeDepth ?? 1) - 1,
26
+ realIndex: index,
27
+ childrenCount: item.children?.length ?? 0,
28
+ parentId: item.node.parent?.model?.id?.toString() ?? null,
29
+ original: item
30
+ })), [flattenedVisibleTree]);
31
+ const onReorder = useCallback((tree, indexes) => {
32
+ const nodes = {};
33
+ tree.forEach((item) => {
34
+ const originalItem = item.original;
35
+ originalItem.children = [];
36
+ nodes[item.uid] = item.original;
37
+ });
38
+ const newUserTree = [];
39
+ tree.forEach((item) => {
40
+ if (item.parentId !== null && item.parentId !== void 0 && item.parentId !== "__ds_tree_root") {
41
+ const parentNode = nodes[item.parentId];
42
+ parentNode.children?.push(item.original);
43
+ } else if (item.uid !== "__ds_tree_root")
44
+ newUserTree.push(item.original);
45
+ });
46
+ onOrderChange(newUserTree, data, flattenedItems[indexes.fromIndex]);
47
+ }, [onOrderChange, data, flattenedItems]);
48
+ const {
49
+ dndContextProps,
50
+ sortableContextProps,
51
+ activeId,
52
+ activeIndex,
53
+ depth,
54
+ dropIndicatorPosition,
55
+ visibleItems,
56
+ isDropValid
57
+ } = useTreeDndkitConfig({
58
+ flattenedItems,
59
+ visibleItems: flattenedVisibleTreeForDnD,
60
+ isHorizontalDnD: false,
61
+ isExpandable: true,
62
+ onReorder,
63
+ getIsDropValid,
64
+ maxDragAndDropLevel: Infinity
65
+ });
66
+ if (lastActiveId !== activeId && activeId)
67
+ setLastActiveId(activeId);
68
+ if (withDragAndDrop)
69
+ return /* @__PURE__ */ React2.createElement(DndContext, {
70
+ ...dndContextProps
71
+ }, /* @__PURE__ */ React2.createElement(SortableContext, {
72
+ ...sortableContextProps
73
+ }, /* @__PURE__ */ React2.createElement(DnDTreeContext.Provider, {
74
+ value: {
75
+ activeIndex,
76
+ depth,
77
+ visibleItems: visibleItems.map((item) => item.original),
78
+ dropIndicatorPosition,
79
+ lastActiveId,
80
+ setLastActiveId,
81
+ isDropValid
82
+ }
83
+ }, /* @__PURE__ */ React2.createElement(Component, {
84
+ ...props
85
+ }))), /* @__PURE__ */ React2.createElement(DragOverlay, {
86
+ style: { width: "auto" }
87
+ }, activeId ? /* @__PURE__ */ React2.createElement(TreeItem, {
88
+ itemIndex: activeIndex,
89
+ item: ensure(flattenedVisibleTree.find((item) => item.id.toString() === activeId)),
90
+ isDragOverlay: true
91
+ }) : null));
92
+ return /* @__PURE__ */ React2.createElement(Component, {
93
+ ...props
94
+ });
95
+ };
96
+ export {
97
+ withConditionalDnDRowContext
98
+ };
99
+ //# sourceMappingURL=WithConditionalDnDContext.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hoc/WithConditionalDnDContext.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useContext, useMemo } from 'react';\nimport { DndContext, DragOverlay } from '@dnd-kit/core';\nimport { SortableContext } from '@dnd-kit/sortable';\nimport { useTreeDndkitConfig } from '@elliemae/ds-drag-and-drop';\nimport { DSTreeviewT } from '../react-desc-prop-types';\nimport TreeViewContext from '../TreeViewContext';\nimport { TreeItem } from '../parts/TreeItem';\nimport { DnDTreeContext } from './DnDTreeContext';\n\ntype FunctionalHOC = <T = unknown>(Component: React.ComponentType<T>, ...other: unknown[]) => (props: T) => JSX.Element;\n\nconst ensure = <T,>(argument: T | undefined | null, message = 'This should never happen'): T => {\n if (argument === undefined || argument === null) {\n throw new TypeError(message);\n }\n\n return argument;\n};\n\n// only wraps in \"DnDContext\" and \"DnDTreeContext\" if any Drag and Drop functionality is requested\nexport const withConditionalDnDRowContext: FunctionalHOC = (Component) => (props) => {\n const [lastActiveId, setLastActiveId] = React.useState('');\n\n const {\n props: { data, onOrderChange, getIsDropValid },\n flattenedItems,\n visibleItems: flattenedVisibleTree,\n withDragAndDrop,\n } = useContext(TreeViewContext);\n\n const flattenedVisibleTreeForDnD = useMemo(\n () =>\n flattenedVisibleTree.map((item, index) => ({\n uid: item.id.toString(),\n depth: (item.treeDepth ?? 1) - 1,\n realIndex: index,\n childrenCount: item.children?.length ?? 0,\n parentId: item.node.parent?.model?.id?.toString() ?? null,\n original: item,\n })),\n [flattenedVisibleTree],\n );\n\n const onReorder = useCallback(\n (tree: DSTreeviewT.DndItem[], indexes: { targetIndex: number; fromIndex: number }) => {\n // Pull the row's original data into an object\n const nodes: Record<DSTreeviewT.StringOrNum, DSTreeviewT.SimpleItem> = {};\n tree.forEach((item) => {\n const originalItem = item.original;\n originalItem.children = [];\n nodes[item.uid] = item.original;\n });\n\n const newUserTree: DSTreeviewT.SimpleItem[] = [];\n tree.forEach((item) => {\n // If row has parent, insert it to it's subrows\n // otherwise append it to the new user data\n if (item.parentId !== null && item.parentId !== undefined && item.parentId !== '__ds_tree_root') {\n const parentNode = nodes[item.parentId];\n parentNode.children?.push(item.original);\n } else if (item.uid !== '__ds_tree_root') newUserTree.push(item.original);\n });\n // Tell the user that the order has change, he can chose to commit it or not\n onOrderChange(newUserTree, data, flattenedItems[indexes.fromIndex]);\n },\n [onOrderChange, data, flattenedItems],\n );\n\n const {\n dndContextProps,\n sortableContextProps,\n activeId,\n activeIndex,\n depth,\n dropIndicatorPosition,\n visibleItems,\n isDropValid,\n } = useTreeDndkitConfig({\n flattenedItems,\n visibleItems: flattenedVisibleTreeForDnD,\n isHorizontalDnD: false,\n isExpandable: true,\n onReorder,\n getIsDropValid,\n maxDragAndDropLevel: Infinity,\n });\n\n if (lastActiveId !== activeId && activeId) setLastActiveId(activeId);\n\n if (withDragAndDrop)\n return (\n <DndContext {...dndContextProps}>\n <SortableContext {...sortableContextProps}>\n <DnDTreeContext.Provider\n value={{\n activeIndex,\n depth,\n visibleItems: visibleItems.map((item) => item.original) as DSTreeviewT.Item[],\n dropIndicatorPosition,\n lastActiveId,\n setLastActiveId,\n isDropValid,\n }}\n >\n <Component {...props} />\n </DnDTreeContext.Provider>\n </SortableContext>\n <DragOverlay style={{ width: 'auto' }}>\n {activeId ? (\n <TreeItem\n itemIndex={activeIndex}\n item={ensure(flattenedVisibleTree.find((item) => item.id.toString() === activeId))}\n isDragOverlay\n />\n ) : null}\n </DragOverlay>\n </DndContext>\n );\n return <Component {...props} />;\n};\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAIA,MAAM,SAAS,CAAK,UAAgC,UAAU,+BAAkC;AAC9F,MAAI,aAAa,UAAa,aAAa,MAAM;AAC/C,UAAM,IAAI,UAAU;AAAA;AAGtB,SAAO;AAAA;AAIF,MAAM,+BAA8C,CAAC,cAAc,CAAC,UAAU;AACnF,QAAM,CAAC,cAAc,mBAAmB,OAAM,SAAS;AAEvD,QAAM;AAAA,IACJ,OAAO,EAAE,MAAM,eAAe;AAAA,IAC9B;AAAA,IACA,cAAc;AAAA,IACd;AAAA,MACE,WAAW;AAEf,QAAM,6BAA6B,QACjC,MACE,qBAAqB,IAAI,CAAC,MAAM,UAAW;AAAA,IACzC,KAAK,KAAK,GAAG;AAAA,IACb,OAAQ,MAAK,aAAa,KAAK;AAAA,IAC/B,WAAW;AAAA,IACX,eAAe,KAAK,UAAU,UAAU;AAAA,IACxC,UAAU,KAAK,KAAK,QAAQ,OAAO,IAAI,cAAc;AAAA,IACrD,UAAU;AAAA,OAEd,CAAC;AAGH,QAAM,YAAY,YAChB,CAAC,MAA6B,YAAwD;AAEpF,UAAM,QAAiE;AACvE,SAAK,QAAQ,CAAC,SAAS;AACrB,YAAM,eAAe,KAAK;AAC1B,mBAAa,WAAW;AACxB,YAAM,KAAK,OAAO,KAAK;AAAA;AAGzB,UAAM,cAAwC;AAC9C,SAAK,QAAQ,CAAC,SAAS;AAGrB,UAAI,KAAK,aAAa,QAAQ,KAAK,aAAa,UAAa,KAAK,aAAa,kBAAkB;AAC/F,cAAM,aAAa,MAAM,KAAK;AAC9B,mBAAW,UAAU,KAAK,KAAK;AAAA,iBACtB,KAAK,QAAQ;AAAkB,oBAAY,KAAK,KAAK;AAAA;AAGlE,kBAAc,aAAa,MAAM,eAAe,QAAQ;AAAA,KAE1D,CAAC,eAAe,MAAM;AAGxB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,oBAAoB;AAAA,IACtB;AAAA,IACA,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA;AAGvB,MAAI,iBAAiB,YAAY;AAAU,oBAAgB;AAE3D,MAAI;AACF,WACE,qCAAC,YAAD;AAAA,SAAgB;AAAA,OACd,qCAAC,iBAAD;AAAA,SAAqB;AAAA,OACnB,qCAAC,eAAe,UAAhB;AAAA,MACE,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA,cAAc,aAAa,IAAI,CAAC,SAAS,KAAK;AAAA,QAC9C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,OAGF,qCAAC,WAAD;AAAA,SAAe;AAAA,UAGnB,qCAAC,aAAD;AAAA,MAAa,OAAO,EAAE,OAAO;AAAA,OAC1B,WACC,qCAAC,UAAD;AAAA,MACE,WAAW;AAAA,MACX,MAAM,OAAO,qBAAqB,KAAK,CAAC,SAAS,KAAK,GAAG,eAAe;AAAA,MACxE,eAAa;AAAA,SAEb;AAIZ,SAAO,qCAAC,WAAD;AAAA,OAAe;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,40 @@
1
+ import * as React from "react";
2
+ import React2, { useContext, useMemo } from "react";
3
+ import { useSortable } from "@dnd-kit/sortable";
4
+ import { SortableItemContext } from "./SortableItemContext";
5
+ import TreeViewContext from "../TreeViewContext";
6
+ import { DnDTreeContext } from "./DnDTreeContext";
7
+ const withDnDSortableItemContext = (Component) => (props) => {
8
+ const { withDragAndDrop } = useContext(TreeViewContext);
9
+ const { dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid } = useContext(DnDTreeContext);
10
+ const id = props.item.id.toString();
11
+ const draggableOptions = useMemo(() => ({
12
+ id
13
+ }), [id]);
14
+ const useSortableHelpers = useSortable(draggableOptions);
15
+ const draggableProps = useMemo(() => {
16
+ if (!withDragAndDrop)
17
+ return false;
18
+ const { index, overIndex } = useSortableHelpers;
19
+ return {
20
+ ...useSortableHelpers,
21
+ shouldShowDropIndicatorPosition: overIndex === index,
22
+ dropIndicatorPosition,
23
+ lastActiveId,
24
+ setLastActiveId,
25
+ isDropValid
26
+ };
27
+ }, [withDragAndDrop, useSortableHelpers, dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid]);
28
+ const ctx = useMemo(() => ({
29
+ draggableProps
30
+ }), [draggableProps]);
31
+ return /* @__PURE__ */ React2.createElement(SortableItemContext.Provider, {
32
+ value: ctx
33
+ }, /* @__PURE__ */ React2.createElement(Component, {
34
+ ...props
35
+ }));
36
+ };
37
+ export {
38
+ withDnDSortableItemContext
39
+ };
40
+ //# sourceMappingURL=WithDnDSortableItemContext.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hoc/WithDnDSortableItemContext.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport React, { useContext, useMemo } from 'react';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { SortableItemContext, SortableItemContextType } from './SortableItemContext';\nimport TreeViewContext from '../TreeViewContext';\nimport { DnDTreeContext } from './DnDTreeContext';\nimport { DSTreeviewT } from '../react-desc-prop-types';\n\ntype FunctionalHOC = <T = unknown>(Component: React.ComponentType<T>, ...other: unknown[]) => (props: T) => JSX.Element;\n\nexport const withDnDSortableItemContext: FunctionalHOC = (Component) => (props: any) => {\n const { withDragAndDrop } = useContext(TreeViewContext);\n const { dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid } = useContext(DnDTreeContext);\n\n const id = (props as { item: DSTreeviewT.Item }).item.id.toString();\n\n // onMount generate unique options, so everyting is only ran once\n const draggableOptions = useMemo(\n () => ({\n id,\n }),\n [id],\n );\n\n const useSortableHelpers = useSortable(draggableOptions);\n\n // calculate all the \"useSortable\" values as per required\n const draggableProps = useMemo(() => {\n if (!withDragAndDrop) return false;\n\n const { index, overIndex } = useSortableHelpers;\n\n return {\n ...useSortableHelpers,\n shouldShowDropIndicatorPosition: overIndex === index,\n dropIndicatorPosition,\n lastActiveId,\n setLastActiveId,\n isDropValid,\n };\n }, [withDragAndDrop, useSortableHelpers, dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid]);\n\n // we use a context so we can easly access information wherever without bubbling down\n // this context is all Memoized so as long as component is not re-mounted,\n // the context won't trigger un-required renders per-se...\n const ctx: SortableItemContextType = useMemo(\n () => ({\n draggableProps,\n }),\n [draggableProps],\n );\n // we always add the context, if draggableProps===false we don't have the DnD enabled.\n return (\n <SortableItemContext.Provider value={ctx}>\n <Component {...props} />\n </SortableItemContext.Provider>\n );\n};\n"],
5
+ "mappings": "AAAA;ACGA;AACA;AACA;AACA;AACA;AAKO,MAAM,6BAA4C,CAAC,cAAc,CAAC,UAAe;AACtF,QAAM,EAAE,oBAAoB,WAAW;AACvC,QAAM,EAAE,uBAAuB,cAAc,iBAAiB,gBAAgB,WAAW;AAEzF,QAAM,KAAM,MAAqC,KAAK,GAAG;AAGzD,QAAM,mBAAmB,QACvB,MAAO;AAAA,IACL;AAAA,MAEF,CAAC;AAGH,QAAM,qBAAqB,YAAY;AAGvC,QAAM,iBAAiB,QAAQ,MAAM;AACnC,QAAI,CAAC;AAAiB,aAAO;AAE7B,UAAM,EAAE,OAAO,cAAc;AAE7B,WAAO;AAAA,SACF;AAAA,MACH,iCAAiC,cAAc;AAAA,MAC/C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,KAED,CAAC,iBAAiB,oBAAoB,uBAAuB,cAAc,iBAAiB;AAK/F,QAAM,MAA+B,QACnC,MAAO;AAAA,IACL;AAAA,MAEF,CAAC;AAGH,SACE,qCAAC,oBAAoB,UAArB;AAAA,IAA8B,OAAO;AAAA,KACnC,qCAAC,WAAD;AAAA,OAAe;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,28 @@
1
+ import * as React from "react";
2
+ import React2, { useContext } from "react";
3
+ import { GripperVertical } from "@elliemae/ds-icons";
4
+ import { SortableItemContext } from "../hoc/SortableItemContext";
5
+ const DnDHandle = ({ id, isDragOverlay }) => {
6
+ const { draggableProps } = useContext(SortableItemContext);
7
+ const isDragging = draggableProps && draggableProps.isDragging;
8
+ return /* @__PURE__ */ React2.createElement(GripperVertical, {
9
+ role: "button",
10
+ ...draggableProps && {
11
+ ...draggableProps.listeners,
12
+ ...draggableProps.attributes
13
+ },
14
+ "data-testid": "drag-handle",
15
+ "data-isactive": draggableProps && !!draggableProps.active,
16
+ "data-isdragoverlay": isDragOverlay,
17
+ id: `${id}-drag-handle`,
18
+ key: `${id}-drag-handle`,
19
+ className: `drag-handle ${isDragging ? "" : "focuseable"}`,
20
+ color: ["brand-primary", "800"],
21
+ size: "s",
22
+ tabIndex: 0
23
+ });
24
+ };
25
+ export {
26
+ DnDHandle
27
+ };
28
+ //# sourceMappingURL=DnDHandle.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/DnDHandle.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { GripperVertical } from '@elliemae/ds-icons';\nimport { SortableItemContext } from '../hoc/SortableItemContext';\nimport { DSTreeviewT } from '../react-desc-prop-types';\n\nexport const DnDHandle = ({ id, isDragOverlay }: { id: DSTreeviewT.StringOrNum; isDragOverlay: boolean }) => {\n const { draggableProps } = useContext(SortableItemContext);\n\n const isDragging = draggableProps && draggableProps.isDragging;\n\n return (\n <GripperVertical\n role=\"button\"\n {...(draggableProps && {\n ...draggableProps.listeners,\n ...draggableProps.attributes,\n })}\n data-testid=\"drag-handle\"\n data-isactive={draggableProps && !!draggableProps.active}\n data-isdragoverlay={isDragOverlay}\n id={`${id}-drag-handle`}\n key={`${id}-drag-handle`}\n className={`drag-handle ${isDragging ? '' : 'focuseable'}`}\n color={['brand-primary', '800']}\n size=\"s\"\n tabIndex={0}\n />\n );\n};\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;AAGO,MAAM,YAAY,CAAC,EAAE,IAAI,oBAA6E;AAC3G,QAAM,EAAE,mBAAmB,WAAW;AAEtC,QAAM,aAAa,kBAAkB,eAAe;AAEpD,SACE,qCAAC,iBAAD;AAAA,IACE,MAAK;AAAA,OACA,kBAAkB;AAAA,SAClB,eAAe;AAAA,SACf,eAAe;AAAA;AAAA,IAEpB,eAAY;AAAA,IACZ,iBAAe,kBAAkB,CAAC,CAAC,eAAe;AAAA,IAClD,sBAAoB;AAAA,IACpB,IAAI,GAAG;AAAA,IACP,KAAK,GAAG;AAAA,IACR,WAAW,eAAe,aAAa,KAAK;AAAA,IAC5C,OAAO,CAAC,iBAAiB;AAAA,IACzB,MAAK;AAAA,IACL,UAAU;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,51 @@
1
+ import * as React from "react";
2
+ import React2 from "react";
3
+ import styled from "styled-components";
4
+ import { DropIndicatorPosition } from "../hoc/SortableItemContext";
5
+ const getPositionStyles = ({ dropIndicatorPosition }) => `
6
+ top: ${dropIndicatorPosition === DropIndicatorPosition.Before ? "0" : "unset"};
7
+ bottom: ${dropIndicatorPosition === DropIndicatorPosition.After ? "0" : "unset"};
8
+ left: -2px;
9
+ `;
10
+ const getCircleStyles = ({ dropIndicatorPosition }) => ({
11
+ position: "absolute",
12
+ zIndex: 20,
13
+ top: dropIndicatorPosition === DropIndicatorPosition.After ? "unset" : "-2px",
14
+ bottom: dropIndicatorPosition === DropIndicatorPosition.Before ? "unset" : "-2px",
15
+ left: "0px",
16
+ opacity: 1
17
+ });
18
+ const StyledIndicator = styled.div`
19
+ position: absolute;
20
+ ${getPositionStyles}
21
+ box-sizing: border-box;
22
+ width: ${(props) => props.vertical ? "2px" : "100%"};
23
+ height: ${(props) => props.vertical ? "100%" : "2px"};
24
+ background-color: ${({ isDropValid, theme }) => isDropValid ? theme.colors.brand[600] : theme.colors.danger[900]};
25
+ z-index: 20;
26
+ `;
27
+ const CircleIndicator = (style, isDropValid) => /* @__PURE__ */ React2.createElement("svg", {
28
+ height: "6",
29
+ width: "6",
30
+ style
31
+ }, /* @__PURE__ */ React2.createElement("circle", {
32
+ cx: "3",
33
+ cy: "3",
34
+ r: "3",
35
+ strokeWidth: "0",
36
+ fill: isDropValid ? "#1E79C2" : "#C64252"
37
+ }));
38
+ const DropIndicator = ({ dropIndicatorPosition, isLast, isDropValid }) => {
39
+ if (![DropIndicatorPosition.After, DropIndicatorPosition.Before].includes(dropIndicatorPosition))
40
+ return null;
41
+ const safeDropIndicatorPosition = isLast ? DropIndicatorPosition.Before : dropIndicatorPosition;
42
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, CircleIndicator(getCircleStyles({ dropIndicatorPosition: safeDropIndicatorPosition }), isDropValid), /* @__PURE__ */ React2.createElement(StyledIndicator, {
43
+ dropIndicatorPosition: safeDropIndicatorPosition,
44
+ isDropValid
45
+ }));
46
+ };
47
+ var DropIndicator_default = DropIndicator;
48
+ export {
49
+ DropIndicator_default as default
50
+ };
51
+ //# sourceMappingURL=DropIndicator.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/DropIndicator.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport styled from 'styled-components';\nimport { DropIndicatorPosition } from '../hoc/SortableItemContext';\n\ninterface DropIndicatorProps {\n vertical?: boolean;\n dropIndicatorPosition: DropIndicatorPosition | false;\n isLast?: boolean;\n isDropValid?: boolean;\n}\n\nconst getPositionStyles = ({ dropIndicatorPosition }: DropIndicatorProps) => `\n top: ${dropIndicatorPosition === DropIndicatorPosition.Before ? '0' : 'unset'};\n bottom: ${dropIndicatorPosition === DropIndicatorPosition.After ? '0' : 'unset'};\n left: -2px;\n `;\n\nconst getCircleStyles = ({ dropIndicatorPosition }: DropIndicatorProps) => ({\n position: 'absolute',\n zIndex: 20,\n top: dropIndicatorPosition === DropIndicatorPosition.After ? 'unset' : '-2px',\n bottom: dropIndicatorPosition === DropIndicatorPosition.Before ? 'unset' : '-2px',\n left: '0px',\n opacity: 1,\n});\n\nconst StyledIndicator = styled.div<DropIndicatorProps>`\n position: absolute;\n ${getPositionStyles}\n box-sizing: border-box;\n width: ${(props) => (props.vertical ? '2px' : '100%')};\n height: ${(props) => (props.vertical ? '100%' : '2px')};\n background-color: ${({ isDropValid, theme }) => (isDropValid ? theme.colors.brand[600] : theme.colors.danger[900])};\n z-index: 20;\n`;\n\nconst CircleIndicator = (style: Record<string, unknown>, isDropValid: boolean | null | undefined) => (\n <svg height=\"6\" width=\"6\" style={style}>\n <circle cx=\"3\" cy=\"3\" r=\"3\" strokeWidth=\"0\" fill={isDropValid ? '#1E79C2' : '#C64252'} />\n </svg>\n);\n\nconst DropIndicator: React.ComponentType<DropIndicatorProps> = ({ dropIndicatorPosition, isLast, isDropValid }) => {\n if (\n ![DropIndicatorPosition.After, DropIndicatorPosition.Before].includes(\n dropIndicatorPosition as DropIndicatorPosition,\n )\n )\n return null;\n\n const safeDropIndicatorPosition = isLast ? DropIndicatorPosition.Before : dropIndicatorPosition;\n\n return (\n <>\n {CircleIndicator(getCircleStyles({ dropIndicatorPosition: safeDropIndicatorPosition }), isDropValid)}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2B;AAAA;AAAA;AAKzE,IAAO,wBAAQ;",
6
+ "names": []
7
+ }
@@ -1,8 +1,6 @@
1
1
  import * as React from "react";
2
- import React2, { useContext, useState, useMemo, useRef, useCallback } from "react";
3
- import { SortableElement, SortableHandle } from "@elliemae/react-sortable-hoc";
2
+ import React2, { useContext, useMemo, useCallback } from "react";
4
3
  import { aggregatedClasses } from "@elliemae/ds-classnames";
5
- import { GripperVertical } from "@elliemae/ds-icons";
6
4
  import RadioSelectable from "./RadioSelectable";
7
5
  import CheckboxSelectable from "./CheckboxSelectable";
8
6
  import TreeViewContext from "../TreeViewContext";
@@ -13,23 +11,15 @@ import { Icon } from "./Icon";
13
11
  import { ExpandCaret } from "./ExpandCaret";
14
12
  import { TreeItemText } from "./TreeItemText";
15
13
  import { DSTreeViewPrefix, treeItemBlockName } from "../config/cssClassesConstants";
14
+ import { DnDHandle } from "./DnDHandle";
15
+ import { withDnDSortableItemContext } from "../hoc/WithDnDSortableItemContext";
16
+ import { DropIndicatorPosition, SortableItemContext } from "../hoc/SortableItemContext";
17
+ import DropIndicator from "./DropIndicator";
16
18
  const TreeListItem = aggregatedClasses("li", {
17
19
  "data-testid": treeItemBlockName,
18
20
  role: "treeitem"
19
21
  })(treeItemBlockName);
20
22
  const TreeListItemAddonsWrapper = aggregatedClasses("div")(treeItemBlockName, "addons");
21
- const DnDHandle = SortableHandle(({ id }) => /* @__PURE__ */ React2.createElement(GripperVertical, {
22
- "data-testid": "drag-handle",
23
- key: `${id}-drag-handle`,
24
- className: "drag-handle",
25
- size: "s",
26
- onMouseDown: (e) => {
27
- if (e) {
28
- e.preventDefault();
29
- }
30
- },
31
- tabIndex: "0"
32
- }));
33
23
  const TreeItem = (props) => {
34
24
  const {
35
25
  item,
@@ -37,47 +27,43 @@ const TreeItem = (props) => {
37
27
  itemWrapperStyle = {},
38
28
  virtualItemRef,
39
29
  spaceForNestingLevel = 1.5,
40
- onMouseDragOverItem
30
+ isDragOverlay = false
41
31
  } = props;
42
32
  const { id, node } = item;
43
33
  const { nodeItemRef } = node.model;
44
- const openFolderOnHoverTimeout = useRef(null);
45
- const [isDraggingOverThis, setIsDraggingOverThis] = useState(false);
46
- const onItemKeyDown = useOnItemKeyDown(item);
34
+ const { draggableProps } = useContext(SortableItemContext);
35
+ const onItemKeyDown = useOnItemKeyDown(item, draggableProps);
47
36
  const ctx = useContext(TreeViewContext);
48
37
  const {
49
38
  props: { disableIcons, rightAddons, onItemClick, onItemFocus, rowSize, labelOverflow },
50
- relativeMouseCord,
51
39
  withRadioChecks,
52
40
  withCheckboxChecks,
53
41
  withDragAndDrop,
54
42
  selectedItem,
55
43
  selectedCheckboxes,
56
44
  hoverItem,
57
- isDragging,
58
45
  virtualListHelpers: { scrollToIndex },
59
46
  setHoverItem,
60
47
  setSelectedItem,
61
48
  setFocusedItem
62
49
  } = ctx;
63
50
  const setItemRefs = (ref) => {
64
- setMultipleRefs(virtualItemRef, nodeItemRef)(ref);
51
+ setMultipleRefs(virtualItemRef, !isDragOverlay && nodeItemRef, !isDragOverlay && draggableProps && draggableProps.setNodeRef)(ref);
65
52
  };
53
+ const dropIndicatorPosition = draggableProps && draggableProps.shouldShowDropIndicatorPosition && draggableProps.dropIndicatorPosition;
54
+ const isDropIndicatorPositionInside = dropIndicatorPosition === DropIndicatorPosition.Inside;
55
+ const isDragging = draggableProps && draggableProps.isDragging;
56
+ const isDropValid = draggableProps && draggableProps.isDropValid;
66
57
  const dropPreviewClassName = useMemo(() => {
67
- if (!withDragAndDrop || !relativeMouseCord || !isDraggingOverThis)
68
- return "";
69
- const { isBefore, isAfter, isValid } = relativeMouseCord;
70
- let className = `${DSTreeViewPrefix}-${treeItemBlockName}${isValid ? "--valid" : "--invalid"}`;
71
- if (isBefore)
72
- className += "-drop-before";
73
- else if (isAfter)
74
- className += "-drop-after";
75
- else
76
- className += "-drop-in";
77
- return className;
78
- }, [withDragAndDrop, relativeMouseCord, isDraggingOverThis]);
79
- const selectedClassName = useMemo(() => selectedItem?.id === item.id ? "selected" : "", [item.id, selectedItem?.id]);
80
- const hoverClassName = useMemo(() => hoverItem?.id !== item.id || withDragAndDrop && isDragging ? "" : "hover", [hoverItem?.id, item.id, withDragAndDrop, isDragging]);
58
+ if (isDropIndicatorPositionInside) {
59
+ const className = `${DSTreeViewPrefix}-${treeItemBlockName}${isDropValid ? "--valid" : "--invalid"}-drop-in`;
60
+ return className;
61
+ }
62
+ return "";
63
+ }, [isDropIndicatorPositionInside, isDropValid]);
64
+ const dragOverlayClassName = useMemo(() => isDragOverlay ? "drag-overlay" : "", [isDragOverlay]);
65
+ const selectedClassName = useMemo(() => selectedItem?.id === item.id && !isDragOverlay ? "selected" : "", [isDragOverlay, item.id, selectedItem?.id]);
66
+ const hoverClassName = useMemo(() => !isDragOverlay && (hoverItem?.id === item.id || isDragging) ? "hover" : "", [isDragOverlay, hoverItem?.id, item.id, isDragging]);
81
67
  const fixedHeightClassname = useMemo(() => {
82
68
  if (labelOverflow === "truncate") {
83
69
  if (rowSize === "compact")
@@ -86,7 +72,7 @@ const TreeItem = (props) => {
86
72
  }
87
73
  return "";
88
74
  }, [labelOverflow, rowSize]);
89
- const finalClassName = useMemo(() => `${dropPreviewClassName} ${fixedHeightClassname} ${selectedClassName} ${hoverClassName}`, [dropPreviewClassName, selectedClassName, hoverClassName, fixedHeightClassname]);
75
+ const finalClassName = useMemo(() => `${dropPreviewClassName} ${fixedHeightClassname} ${selectedClassName} ${hoverClassName} ${dragOverlayClassName}`, [dropPreviewClassName, selectedClassName, hoverClassName, fixedHeightClassname, dragOverlayClassName]);
90
76
  const handleItemClick = useCallback((e) => {
91
77
  onItemClick(item, e);
92
78
  setFocusedItem(item);
@@ -100,23 +86,7 @@ const TreeItem = (props) => {
100
86
  }, [item, scrollToIndex, onItemClick, onItemFocus, setSelectedItem, setFocusedItem]);
101
87
  return /* @__PURE__ */ React2.createElement(TreeListItem, {
102
88
  tabIndex: 0,
103
- onMouseMove: (event) => {
104
- if (withDragAndDrop && onMouseDragOverItem) {
105
- onMouseDragOverItem({
106
- event,
107
- item,
108
- itemIndex,
109
- setIsDraggingOverThis,
110
- openFolderOnHoverTimeout
111
- });
112
- }
113
- },
114
89
  onMouseLeave: () => {
115
- if (withDragAndDrop) {
116
- setIsDraggingOverThis(false);
117
- if (openFolderOnHoverTimeout?.current)
118
- clearTimeout(openFolderOnHoverTimeout.current);
119
- }
120
90
  if (hoverItem?.id === item.id) {
121
91
  setHoverItem(null);
122
92
  }
@@ -125,6 +95,7 @@ const TreeItem = (props) => {
125
95
  setHoverItem(item);
126
96
  },
127
97
  onClick: handleItemClick,
98
+ onBlur: () => setFocusedItem(null),
128
99
  ref: setItemRefs,
129
100
  style: { ...itemWrapperStyle },
130
101
  className: finalClassName,
@@ -134,29 +105,33 @@ const TreeItem = (props) => {
134
105
  "data-index": item.virtualIndex,
135
106
  onKeyDown: onItemKeyDown
136
107
  }, /* @__PURE__ */ React2.createElement(TreeListItemAddonsWrapper, null, withDragAndDrop ? /* @__PURE__ */ React2.createElement(DnDHandle, {
137
- id
138
- }) : null, withRadioChecks ? /* @__PURE__ */ React2.createElement(RadioSelectable, {
108
+ id,
109
+ isDragOverlay
110
+ }) : null, withRadioChecks && !isDragOverlay ? /* @__PURE__ */ React2.createElement(RadioSelectable, {
139
111
  item,
140
112
  itemIndex
141
- }) : null, withCheckboxChecks ? /* @__PURE__ */ React2.createElement(CheckboxSelectable, {
113
+ }) : null, withCheckboxChecks && !isDragOverlay ? /* @__PURE__ */ React2.createElement(CheckboxSelectable, {
142
114
  item,
143
115
  itemIndex
144
- }) : null, /* @__PURE__ */ React2.createElement(NestingSpace, {
116
+ }) : null, !isDragOverlay && /* @__PURE__ */ React2.createElement(NestingSpace, {
145
117
  item,
146
118
  spaceForNestingLevel
147
- }), /* @__PURE__ */ React2.createElement(ExpandCaret, {
119
+ }), !isDragOverlay && /* @__PURE__ */ React2.createElement(ExpandCaret, {
148
120
  item
149
121
  }), !disableIcons ? /* @__PURE__ */ React2.createElement(Icon, {
150
122
  item
151
123
  }) : null), /* @__PURE__ */ React2.createElement(TreeItemText, {
152
124
  item
153
- }), rightAddons && /* @__PURE__ */ React2.createElement(TreeListItemAddonsWrapper, null, typeof rightAddons === "function" ? rightAddons(item) : rightAddons));
125
+ }), rightAddons && /* @__PURE__ */ React2.createElement(TreeListItemAddonsWrapper, null, typeof rightAddons === "function" ? rightAddons(item) : rightAddons), /* @__PURE__ */ React2.createElement(DropIndicator, {
126
+ dropIndicatorPosition,
127
+ isDropValid
128
+ }));
154
129
  };
155
- const DragAndDropTreeItem = SortableElement(TreeItem);
130
+ var TreeItem_default = withDnDSortableItemContext(TreeItem);
156
131
  export {
157
- DragAndDropTreeItem,
158
132
  TreeItem,
159
133
  TreeListItem,
160
- TreeListItemAddonsWrapper
134
+ TreeListItemAddonsWrapper,
135
+ TreeItem_default as default
161
136
  };
162
137
  //# sourceMappingURL=TreeItem.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/TreeItem.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useContext, useState, useMemo, useRef, useCallback } from 'react';\nimport { SortableElement, SortableHandle } from '@elliemae/react-sortable-hoc';\n\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { GripperVertical } from '@elliemae/ds-icons';\n\nimport RadioSelectable from './RadioSelectable';\nimport CheckboxSelectable from './CheckboxSelectable';\nimport TreeViewContext from '../TreeViewContext';\nimport { setMultipleRefs } from '../utils/refs-helpers';\nimport { useOnItemKeyDown } from '../utils/keyboard-helpers';\nimport { NestingSpace } from './NestingSpace';\nimport { Icon } from './Icon';\nimport { ExpandCaret } from './ExpandCaret';\nimport { TreeItemText } from './TreeItemText';\nimport { DSTreeViewPrefix, treeItemBlockName } from '../config/cssClassesConstants';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\n\nexport const TreeListItem = aggregatedClasses('li', {\n 'data-testid': treeItemBlockName,\n role: 'treeitem',\n // temp fix untill we move to styled components\n})(treeItemBlockName) as unknown as React.ComponentType<React.ComponentProps<'li'>>;\n\nexport const TreeListItemAddonsWrapper = aggregatedClasses('div')(\n treeItemBlockName,\n 'addons',\n // temp fix untill we move to styled components\n) as unknown as React.ComponentType;\n\nconst DnDHandle = SortableHandle(({ id }: { id: DSTreeviewT.StringOrNum }) => (\n <GripperVertical\n data-testid=\"drag-handle\"\n key={`${id}-drag-handle`}\n className=\"drag-handle\"\n size=\"s\"\n onMouseDown={(e: React.MouseEvent) => {\n // prevent focusing the drag-handle to avoid borders\n if (e) {\n e.preventDefault();\n }\n }}\n tabIndex=\"0\"\n />\n));\ninterface PropsT {\n item: DSTreeviewT.Item;\n itemIndex: number;\n virtualItemRef: React.RefObject<HTMLLIElement>;\n itemWrapperStyle?: { [key: string]: unknown };\n spaceForNestingLevel?: number;\n onMouseDragOverItem?: (opts: {\n event: React.MouseEvent<HTMLLIElement>;\n item: DSTreeviewT.Item;\n itemIndex: number;\n setIsDraggingOverThis: React.Dispatch<React.SetStateAction<boolean>>;\n openFolderOnHoverTimeout: React.MutableRefObject<NodeJS.Timeout | null>;\n }) => void;\n}\nexport const TreeItem = (props: PropsT): JSX.Element => {\n const {\n item,\n itemIndex,\n itemWrapperStyle = {},\n virtualItemRef,\n spaceForNestingLevel = 1.5,\n onMouseDragOverItem,\n } = props;\n const { id, node } = item;\n const { nodeItemRef } = node.model;\n const openFolderOnHoverTimeout = useRef<NodeJS.Timeout | null>(null);\n\n const [isDraggingOverThis, setIsDraggingOverThis] = useState(false);\n const onItemKeyDown = useOnItemKeyDown(item);\n\n const ctx = useContext(TreeViewContext);\n const {\n props: { disableIcons, rightAddons, onItemClick, onItemFocus, rowSize, labelOverflow },\n relativeMouseCord,\n withRadioChecks,\n withCheckboxChecks,\n withDragAndDrop,\n selectedItem,\n selectedCheckboxes,\n hoverItem,\n isDragging,\n virtualListHelpers: { scrollToIndex },\n setHoverItem,\n setSelectedItem,\n setFocusedItem,\n } = ctx;\n\n // Sortable Items needs to update\n // - the virtual list ref (for react-virtual requirement)\n // - nodeItemRef which is a prop avaiable in the TreeModel nodes\n const setItemRefs: React.LegacyRef<HTMLLIElement> | undefined = (ref: HTMLLIElement) => {\n setMultipleRefs(virtualItemRef, nodeItemRef)(ref);\n };\n\n const dropPreviewClassName = useMemo(() => {\n if (!withDragAndDrop || !relativeMouseCord || !isDraggingOverThis) return '';\n const { isBefore, isAfter, isValid } = relativeMouseCord;\n let className = `${DSTreeViewPrefix}-${treeItemBlockName}${isValid ? '--valid' : '--invalid'}`;\n\n if (isBefore) className += '-drop-before';\n else if (isAfter) className += '-drop-after';\n else className += '-drop-in';\n return className;\n }, [withDragAndDrop, relativeMouseCord, isDraggingOverThis]);\n\n const selectedClassName = useMemo(\n () => (selectedItem?.id === item.id ? 'selected' : ''),\n [item.id, selectedItem?.id],\n );\n const hoverClassName = useMemo(\n () => (hoverItem?.id !== item.id || (withDragAndDrop && isDragging) ? '' : 'hover'),\n [hoverItem?.id, item.id, withDragAndDrop, isDragging],\n );\n const fixedHeightClassname = useMemo(() => {\n if (labelOverflow === 'truncate') {\n if (rowSize === 'compact') return `${DSTreeViewPrefix}-${treeItemBlockName}--fixed-height-compact`;\n return `${DSTreeViewPrefix}-${treeItemBlockName}--fixed-height`;\n }\n return '';\n }, [labelOverflow, rowSize]);\n\n const finalClassName = useMemo(\n () => `${dropPreviewClassName} ${fixedHeightClassname} ${selectedClassName} ${hoverClassName}`,\n [dropPreviewClassName, selectedClassName, hoverClassName, fixedHeightClassname],\n );\n\n const handleItemClick = useCallback(\n (e: React.MouseEvent<HTMLLIElement>) => {\n onItemClick(item, e);\n setFocusedItem(item);\n setSelectedItem(item);\n const itemVirtualIndex = typeof item.virtualIndex === 'number' ? item.virtualIndex : -1;\n onItemFocus({\n itemIndex: itemVirtualIndex,\n scrollToItem: (opts = { align: 'start' }) => scrollToIndex(itemVirtualIndex, opts),\n item,\n });\n },\n [item, scrollToIndex, onItemClick, onItemFocus, setSelectedItem, setFocusedItem],\n );\n\n return (\n <TreeListItem\n tabIndex={0}\n onMouseMove={(event) => {\n if (withDragAndDrop && onMouseDragOverItem) {\n onMouseDragOverItem({\n event,\n item,\n itemIndex,\n setIsDraggingOverThis,\n openFolderOnHoverTimeout,\n });\n }\n }}\n onMouseLeave={() => {\n if (withDragAndDrop) {\n setIsDraggingOverThis(false);\n if (openFolderOnHoverTimeout?.current) clearTimeout(openFolderOnHoverTimeout.current);\n }\n if (hoverItem?.id === item.id) {\n setHoverItem(null);\n }\n }}\n onMouseEnter={() => {\n setHoverItem(item);\n }}\n onClick={handleItemClick}\n ref={setItemRefs}\n style={{ ...itemWrapperStyle }}\n className={finalClassName}\n aria-expanded={!!item.isExpanded}\n aria-selected={!!selectedCheckboxes[item.id]}\n data-id={item.id}\n data-index={item.virtualIndex}\n onKeyDown={onItemKeyDown}\n >\n <TreeListItemAddonsWrapper>\n {withDragAndDrop ? <DnDHandle id={id} /> : null}\n {withRadioChecks ? <RadioSelectable item={item} itemIndex={itemIndex} /> : null}\n {withCheckboxChecks ? <CheckboxSelectable item={item} itemIndex={itemIndex} /> : null}\n <NestingSpace item={item} spaceForNestingLevel={spaceForNestingLevel} />\n <ExpandCaret item={item} />\n {!disableIcons ? <Icon item={item} /> : null}\n </TreeListItemAddonsWrapper>\n <TreeItemText item={item} />\n {rightAddons && (\n <TreeListItemAddonsWrapper>\n {typeof rightAddons === 'function' ? rightAddons(item) : rightAddons}\n </TreeListItemAddonsWrapper>\n )}\n </TreeListItem>\n );\n};\n\nexport const DragAndDropTreeItem = SortableElement(TreeItem);\n"],
5
- "mappings": "AAAA;ACCA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGO,MAAM,eAAe,kBAAkB,MAAM;AAAA,EAClD,eAAe;AAAA,EACf,MAAM;AAAA,GAEL;AAEI,MAAM,4BAA4B,kBAAkB,OAC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CAAC,CAAC,KAAK;AAAA,IACtB,iBAAe,CAAC,CAAC,mBAAmB,KAAK;AAAA,IACzC,WAAS,KAAK;AAAA,IACd,cAAY,KAAK;AAAA,IACjB,WAAW;AAAA,KAEX,qCAAC,2BAAD,MACG,kBAAkB,qCAAC,WAAD;AAAA,IAAW;AAAA,OAAa,MAC1C,kBAAkB,qCAAC,iBAAD;AAAA,IAAiB;AAAA,IAAY;AAAA,OAA2B,MAC1E,qBAAqB,qCAAC,oBAAD;AAAA,IAAoB;AAAA,IAAY;AAAA,OAA2B,MACjF,qCAAC,cAAD;AAAA,IAAc;AAAA,IAAY;AAAA,MAC1B,qCAAC,aAAD;AAAA,IAAa;AAAA,MACZ,CAAC,eAAe,qCAAC,MAAD;AAAA,IAAM;AAAA,OAAiB,OAE1C,qCAAC,cAAD;AAAA,IAAc;AAAA,MACb,eACC,qCAAC,2BAAD,MACG,OAAO,gBAAgB,aAAa,YAAY,QAAQ;AAAA;AAO5D,MAAM,sBAAsB,gBAAgB;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport React, { useContext, useMemo, useCallback } from 'react';\n\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\n\nimport RadioSelectable from './RadioSelectable';\nimport CheckboxSelectable from './CheckboxSelectable';\nimport TreeViewContext from '../TreeViewContext';\nimport { setMultipleRefs } from '../utils/refs-helpers';\nimport { useOnItemKeyDown } from '../utils/keyboard-helpers';\nimport { NestingSpace } from './NestingSpace';\nimport { Icon } from './Icon';\nimport { ExpandCaret } from './ExpandCaret';\nimport { TreeItemText } from './TreeItemText';\nimport { DSTreeViewPrefix, treeItemBlockName } from '../config/cssClassesConstants';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport { DnDHandle } from './DnDHandle';\nimport { withDnDSortableItemContext } from '../hoc/WithDnDSortableItemContext';\nimport { DropIndicatorPosition, SortableItemContext } from '../hoc/SortableItemContext';\nimport DropIndicator from './DropIndicator';\n\nexport const TreeListItem = aggregatedClasses('li', {\n 'data-testid': treeItemBlockName,\n role: 'treeitem',\n // temp fix untill we move to styled components\n})(treeItemBlockName) as unknown as React.ComponentType<React.ComponentProps<'li'>>;\n\nexport const TreeListItemAddonsWrapper = aggregatedClasses('div')(\n treeItemBlockName,\n 'addons',\n // temp fix untill we move to styled components\n) as unknown as React.ComponentType;\n\ninterface PropsT {\n item: DSTreeviewT.Item;\n itemIndex: number;\n isDragOverlay?: boolean;\n virtualItemRef?: React.RefObject<HTMLLIElement>;\n itemWrapperStyle?: { [key: string]: unknown };\n spaceForNestingLevel?: number;\n}\nexport const TreeItem = (props: PropsT): JSX.Element => {\n const {\n item,\n itemIndex,\n itemWrapperStyle = {},\n virtualItemRef,\n spaceForNestingLevel = 1.5,\n isDragOverlay = false,\n } = props;\n const { id, node } = item;\n const { nodeItemRef } = node.model;\n\n const { draggableProps } = useContext(SortableItemContext);\n\n const onItemKeyDown = useOnItemKeyDown(item, draggableProps);\n\n const ctx = useContext(TreeViewContext);\n const {\n props: { disableIcons, rightAddons, onItemClick, onItemFocus, rowSize, labelOverflow },\n withRadioChecks,\n withCheckboxChecks,\n withDragAndDrop,\n selectedItem,\n selectedCheckboxes,\n hoverItem,\n virtualListHelpers: { scrollToIndex },\n setHoverItem,\n setSelectedItem,\n setFocusedItem,\n } = ctx;\n\n // Sortable Items needs to update\n // - the virtual list ref (for react-virtual requirement)\n // - nodeItemRef which is a prop avaiable in the TreeModel nodes\n // - the drag and drop node reference\n const setItemRefs: React.LegacyRef<HTMLLIElement> | undefined = (ref: HTMLLIElement) => {\n setMultipleRefs(\n virtualItemRef,\n !isDragOverlay && nodeItemRef,\n !isDragOverlay && draggableProps && draggableProps.setNodeRef,\n )(ref);\n };\n\n const dropIndicatorPosition =\n draggableProps && draggableProps.shouldShowDropIndicatorPosition && draggableProps.dropIndicatorPosition;\n\n const isDropIndicatorPositionInside = dropIndicatorPosition === DropIndicatorPosition.Inside;\n\n const isDragging = draggableProps && draggableProps.isDragging;\n\n const isDropValid = draggableProps && draggableProps.isDropValid;\n\n const dropPreviewClassName = useMemo(() => {\n if (isDropIndicatorPositionInside) {\n const className = `${DSTreeViewPrefix}-${treeItemBlockName}${isDropValid ? '--valid' : '--invalid'}-drop-in`;\n return className;\n }\n return '';\n }, [isDropIndicatorPositionInside, isDropValid]);\n\n const dragOverlayClassName = useMemo(() => (isDragOverlay ? 'drag-overlay' : ''), [isDragOverlay]);\n\n const selectedClassName = useMemo(\n () => (selectedItem?.id === item.id && !isDragOverlay ? 'selected' : ''),\n [isDragOverlay, item.id, selectedItem?.id],\n );\n const hoverClassName = useMemo(\n () => (!isDragOverlay && (hoverItem?.id === item.id || isDragging) ? 'hover' : ''),\n [isDragOverlay, hoverItem?.id, item.id, isDragging],\n );\n const fixedHeightClassname = useMemo(() => {\n if (labelOverflow === 'truncate') {\n if (rowSize === 'compact') return `${DSTreeViewPrefix}-${treeItemBlockName}--fixed-height-compact`;\n return `${DSTreeViewPrefix}-${treeItemBlockName}--fixed-height`;\n }\n return '';\n }, [labelOverflow, rowSize]);\n\n const finalClassName = useMemo(\n () =>\n `${dropPreviewClassName} ${fixedHeightClassname} ${selectedClassName} ${hoverClassName} ${dragOverlayClassName}`,\n [dropPreviewClassName, selectedClassName, hoverClassName, fixedHeightClassname, dragOverlayClassName],\n );\n\n const handleItemClick = useCallback(\n (e: React.MouseEvent<HTMLLIElement>) => {\n onItemClick(item, e);\n setFocusedItem(item);\n setSelectedItem(item);\n const itemVirtualIndex = typeof item.virtualIndex === 'number' ? item.virtualIndex : -1;\n onItemFocus({\n itemIndex: itemVirtualIndex,\n scrollToItem: (opts = { align: 'start' }) => scrollToIndex(itemVirtualIndex, opts),\n item,\n });\n },\n [item, scrollToIndex, onItemClick, onItemFocus, setSelectedItem, setFocusedItem],\n );\n\n return (\n <TreeListItem\n tabIndex={0}\n onMouseLeave={() => {\n if (hoverItem?.id === item.id) {\n setHoverItem(null);\n }\n }}\n onMouseEnter={() => {\n setHoverItem(item);\n }}\n onClick={handleItemClick}\n onBlur={() => setFocusedItem(null)}\n ref={setItemRefs}\n style={{ ...itemWrapperStyle }}\n className={finalClassName}\n aria-expanded={!!item.isExpanded}\n aria-selected={!!selectedCheckboxes[item.id]}\n data-id={item.id}\n data-index={item.virtualIndex}\n onKeyDown={onItemKeyDown}\n >\n <TreeListItemAddonsWrapper>\n {withDragAndDrop ? <DnDHandle id={id} isDragOverlay={isDragOverlay} /> : null}\n {withRadioChecks && !isDragOverlay ? <RadioSelectable item={item} itemIndex={itemIndex} /> : null}\n {withCheckboxChecks && !isDragOverlay ? <CheckboxSelectable item={item} itemIndex={itemIndex} /> : null}\n {!isDragOverlay && <NestingSpace item={item} spaceForNestingLevel={spaceForNestingLevel} />}\n {!isDragOverlay && <ExpandCaret item={item} />}\n {!disableIcons ? <Icon item={item} /> : null}\n </TreeListItemAddonsWrapper>\n <TreeItemText item={item} />\n {rightAddons && (\n <TreeListItemAddonsWrapper>\n {typeof rightAddons === 'function' ? rightAddons(item) : rightAddons}\n </TreeListItemAddonsWrapper>\n )}\n <DropIndicator dropIndicatorPosition={dropIndicatorPosition} isDropValid={isDropValid} />\n </TreeListItem>\n );\n};\n\nexport default withDnDSortableItemContext(TreeItem);\n"],
5
+ "mappings": "AAAA;ACEA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEO,MAAM,eAAe,kBAAkB,MAAM;AAAA,EAClD,eAAe;AAAA,EACf,MAAM;AAAA,GAEL;AAEI,MAAM,4BAA4B,kBAAkB,OACzD,mBACA;AAYK,MAAM,WAAW,CAAC,UAA+B;AACtD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,IACnB;AAAA,IACA,uBAAuB;AAAA,IACvB,gBAAgB;AAAA,MACd;AACJ,QAAM,EAAE,IAAI,SAAS;AACrB,QAAM,EAAE,gBAAgB,KAAK;AAE7B,QAAM,EA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AAA,OAAiB,OAE1C,qCAAC,cAAD;AAAA,IAAc;AAAA,MACb,eACC,qCAAC,2BAAD,MACG,OAAO,gBAAgB,aAAa,YAAY,QAAQ,cAG7D,qCAAC,eAAD;AAAA,IAAe;AAAA,IAA8C;AAAA;AAAA;AAKnE,IAAO,mBAAQ,2BAA2B;",
6
6
  "names": []
7
7
  }
@@ -1,11 +1,12 @@
1
1
  import * as React from "react";
2
2
  import React2, { useContext } from "react";
3
- import { SortableContainer } from "@elliemae/react-sortable-hoc";
4
3
  import { aggregatedClasses } from "@elliemae/ds-classnames";
5
4
  import { DSCircularProgressIndicator } from "@elliemae/ds-circular-progress-indicator";
6
5
  import TreeViewContext from "../TreeViewContext";
7
6
  import { DSTreeViewPrefix, treeListBlockName } from "../config/cssClassesConstants";
8
- import { TreeItem, DragAndDropTreeItem } from "./TreeItem";
7
+ import TreeItem from "./TreeItem";
8
+ import { withConditionalDnDRowContext } from "../hoc/WithConditionalDnDContext";
9
+ import { DnDTreeContext } from "../hoc/DnDTreeContext";
9
10
  const treeListNoItemsBn = `${treeListBlockName}-no-items`;
10
11
  const TreeListNoItems = aggregatedClasses("div", {
11
12
  "data-testid": treeListNoItemsBn
@@ -18,18 +19,17 @@ const TreeListWrapper = aggregatedClasses("ul", {
18
19
  }));
19
20
  const compactRowClass = `${DSTreeViewPrefix}-tv-row-size-compact`;
20
21
  const normaRowClass = `${DSTreeViewPrefix}-tv-row-size-normal`;
21
- const TreeList = (props) => {
22
- const { onMouseDragOverItem } = props;
22
+ const TreeListComp = () => {
23
23
  const ctx = useContext(TreeViewContext);
24
24
  const {
25
25
  virtualListRef,
26
26
  virtualListHelpers,
27
- visibleItems,
28
- withDragAndDrop,
27
+ visibleItems: flattenedVisibleItems,
29
28
  props: { width, height, rowSize, noItemsPlaceholder, isLoading }
30
29
  } = ctx;
31
30
  const { totalSize, virtualItems } = virtualListHelpers;
32
31
  const className = `${rowSize === "compact" ? `${compactRowClass}` : `${normaRowClass}`}`;
32
+ const { visibleItems } = useContext(DnDTreeContext);
33
33
  return /* @__PURE__ */ React2.createElement(TreeListWrapper, {
34
34
  ref: virtualListRef,
35
35
  className,
@@ -60,15 +60,16 @@ const TreeList = (props) => {
60
60
  }
61
61
  }, virtualItems.map((virtualItem) => {
62
62
  const { index, measureRef, start } = virtualItem;
63
- const item = visibleItems[index];
63
+ const item = (visibleItems || flattenedVisibleItems)[index];
64
+ if (!item)
65
+ return null;
64
66
  item.virtualIndex = index;
65
67
  const { id } = item;
66
68
  const style = {
67
69
  position: "absolute",
68
- top: 0,
70
+ top: `${start}px`,
69
71
  left: 0,
70
- width: "100%",
71
- transform: `translateY(${start}px)`
72
+ width: "100%"
72
73
  };
73
74
  const listItemProps = {
74
75
  key: `DS-TreeView-List-Item-${id}`,
@@ -78,19 +79,13 @@ const TreeList = (props) => {
78
79
  item,
79
80
  itemWrapperStyle: style
80
81
  };
81
- if (withDragAndDrop)
82
- return /* @__PURE__ */ React2.createElement(DragAndDropTreeItem, {
83
- ...listItemProps,
84
- onMouseDragOverItem
85
- });
86
82
  return /* @__PURE__ */ React2.createElement(TreeItem, {
87
83
  ...listItemProps
88
84
  });
89
85
  })) : null);
90
86
  };
91
- const DragAndDropTreeList = SortableContainer(TreeList);
87
+ const TreeList = withConditionalDnDRowContext(TreeListComp);
92
88
  export {
93
- DragAndDropTreeList,
94
89
  TreeList,
95
90
  TreeListNoItems,
96
91
  TreeListWrapper,