@elliemae/ds-treeview 2.2.0-next.4 → 2.3.0-alpha.2

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 (207) hide show
  1. package/cjs/TreeView.js +49 -27
  2. package/cjs/TreeView.js.map +7 -0
  3. package/cjs/TreeViewContext.js +61 -37
  4. package/cjs/TreeViewContext.js.map +7 -0
  5. package/cjs/config/cssClassesConstants.js +41 -13
  6. package/cjs/config/cssClassesConstants.js.map +7 -0
  7. package/cjs/config/useTreeview.js +116 -78
  8. package/cjs/config/useTreeview.js.map +7 -0
  9. package/cjs/index.js +37 -26
  10. package/cjs/index.js.map +7 -0
  11. package/cjs/parts/CheckboxSelectable.js +70 -59
  12. package/cjs/parts/CheckboxSelectable.js.map +7 -0
  13. package/cjs/parts/ChildrenCountDisplayer.js +45 -28
  14. package/cjs/parts/ChildrenCountDisplayer.js.map +7 -0
  15. package/cjs/parts/ExpandCaret.js +85 -83
  16. package/cjs/parts/ExpandCaret.js.map +7 -0
  17. package/cjs/parts/Icon.js +46 -31
  18. package/cjs/parts/Icon.js.map +7 -0
  19. package/cjs/parts/NestingSpace.js +43 -35
  20. package/cjs/parts/NestingSpace.js.map +7 -0
  21. package/cjs/parts/RadioSelectable.js +52 -37
  22. package/cjs/parts/RadioSelectable.js.map +7 -0
  23. package/cjs/parts/TreeItem.js +147 -141
  24. package/cjs/parts/TreeItem.js.map +7 -0
  25. package/cjs/parts/TreeItemText.js +88 -95
  26. package/cjs/parts/TreeItemText.js.map +7 -0
  27. package/cjs/parts/TreeList.js +119 -130
  28. package/cjs/parts/TreeList.js.map +7 -0
  29. package/cjs/plugins/dnd/TreeDndPlugin.js +59 -7
  30. package/cjs/plugins/dnd/TreeDndPlugin.js.map +7 -0
  31. package/cjs/plugins/dnd/index.js +28 -9
  32. package/cjs/plugins/dnd/index.js.map +7 -0
  33. package/cjs/plugins/index.js +34 -21
  34. package/cjs/plugins/index.js.map +7 -0
  35. package/cjs/plugins/roving/TreeRovingPlugin.js +35 -7
  36. package/cjs/plugins/roving/TreeRovingPlugin.js.map +7 -0
  37. package/cjs/plugins/roving/index.js +28 -9
  38. package/cjs/plugins/roving/index.js.map +7 -0
  39. package/cjs/plugins/searchable/SearchableTreePlugin.js +35 -7
  40. package/cjs/plugins/searchable/SearchableTreePlugin.js.map +7 -0
  41. package/cjs/plugins/searchable/index.js +28 -9
  42. package/cjs/plugins/searchable/index.js.map +7 -0
  43. package/cjs/plugins/selectable/SelectablePluginTree.js +35 -7
  44. package/cjs/plugins/selectable/SelectablePluginTree.js.map +7 -0
  45. package/cjs/plugins/selectable/index.js +28 -9
  46. package/cjs/plugins/selectable/index.js.map +7 -0
  47. package/cjs/plugins/toolbar/TreeToolbarPlugin.js +35 -7
  48. package/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
  49. package/cjs/plugins/toolbar/index.js +28 -9
  50. package/cjs/plugins/toolbar/index.js.map +7 -0
  51. package/cjs/plugins/tree/TreeDataPlugin.js +35 -7
  52. package/cjs/plugins/tree/TreeDataPlugin.js.map +7 -0
  53. package/cjs/plugins/tree/index.js +28 -9
  54. package/cjs/plugins/tree/index.js.map +7 -0
  55. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +35 -7
  56. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
  57. package/cjs/plugins/virtualization/index.js +28 -9
  58. package/cjs/plugins/virtualization/index.js.map +7 -0
  59. package/cjs/react-desc-prop-types.js +82 -54
  60. package/cjs/react-desc-prop-types.js.map +7 -0
  61. package/cjs/related-components/TreeViewSearchBar.js +42 -40
  62. package/cjs/related-components/TreeViewSearchBar.js.map +7 -0
  63. package/cjs/sharedTypes.js +27 -2
  64. package/cjs/sharedTypes.js.map +7 -0
  65. package/cjs/utils/array-helpers.js +35 -11
  66. package/cjs/utils/array-helpers.js.map +7 -0
  67. package/cjs/utils/dnd-helpers.js +146 -0
  68. package/cjs/utils/dnd-helpers.js.map +7 -0
  69. package/cjs/utils/group-expands-helpers.js +86 -59
  70. package/cjs/utils/group-expands-helpers.js.map +7 -0
  71. package/cjs/utils/keyboard-helpers.js +85 -90
  72. package/cjs/utils/keyboard-helpers.js.map +7 -0
  73. package/cjs/utils/object-helpers.js +43 -36
  74. package/cjs/utils/object-helpers.js.map +7 -0
  75. package/cjs/utils/refs-helpers.js +43 -22
  76. package/cjs/utils/refs-helpers.js.map +7 -0
  77. package/cjs/utils/selectable-helper.js +61 -53
  78. package/cjs/utils/selectable-helper.js.map +7 -0
  79. package/cjs/utils/string-helpers.js +35 -7
  80. package/cjs/utils/string-helpers.js.map +7 -0
  81. package/cjs/utils/tree-helpers.js +105 -161
  82. package/cjs/utils/tree-helpers.js.map +7 -0
  83. package/cjs/utils/useDnDHelpers.js +199 -0
  84. package/cjs/utils/useDnDHelpers.js.map +7 -0
  85. package/cjs/utils/useInstanceRefActions.js +54 -43
  86. package/cjs/utils/useInstanceRefActions.js.map +7 -0
  87. package/cjs/utils/useTree.js +76 -80
  88. package/cjs/utils/useTree.js.map +7 -0
  89. package/esm/TreeView.js +18 -16
  90. package/esm/TreeView.js.map +7 -0
  91. package/esm/TreeViewContext.js +32 -31
  92. package/esm/TreeViewContext.js.map +7 -0
  93. package/esm/config/cssClassesConstants.js +12 -6
  94. package/esm/config/cssClassesConstants.js.map +7 -0
  95. package/esm/config/useTreeview.js +73 -56
  96. package/esm/config/useTreeview.js.map +7 -0
  97. package/esm/index.js +8 -9
  98. package/esm/index.js.map +7 -0
  99. package/esm/parts/CheckboxSelectable.js +36 -46
  100. package/esm/parts/CheckboxSelectable.js.map +7 -0
  101. package/esm/parts/ChildrenCountDisplayer.js +16 -20
  102. package/esm/parts/ChildrenCountDisplayer.js.map +7 -0
  103. package/esm/parts/ExpandCaret.js +54 -72
  104. package/esm/parts/ExpandCaret.js.map +7 -0
  105. package/esm/parts/Icon.js +16 -22
  106. package/esm/parts/Icon.js.map +7 -0
  107. package/esm/parts/NestingSpace.js +14 -27
  108. package/esm/parts/NestingSpace.js.map +7 -0
  109. package/esm/parts/RadioSelectable.js +20 -28
  110. package/esm/parts/RadioSelectable.js.map +7 -0
  111. package/esm/parts/TreeItem.js +114 -125
  112. package/esm/parts/TreeItem.js.map +7 -0
  113. package/esm/parts/TreeItemText.js +58 -85
  114. package/esm/parts/TreeItemText.js.map +7 -0
  115. package/esm/parts/TreeList.js +91 -119
  116. package/esm/parts/TreeList.js.map +7 -0
  117. package/esm/plugins/dnd/TreeDndPlugin.js +30 -3
  118. package/esm/plugins/dnd/TreeDndPlugin.js.map +7 -0
  119. package/esm/plugins/dnd/index.js +3 -1
  120. package/esm/plugins/dnd/index.js.map +7 -0
  121. package/esm/plugins/index.js +9 -7
  122. package/esm/plugins/index.js.map +7 -0
  123. package/esm/plugins/roving/TreeRovingPlugin.js +6 -3
  124. package/esm/plugins/roving/TreeRovingPlugin.js.map +7 -0
  125. package/esm/plugins/roving/index.js +3 -1
  126. package/esm/plugins/roving/index.js.map +7 -0
  127. package/esm/plugins/searchable/SearchableTreePlugin.js +6 -3
  128. package/esm/plugins/searchable/SearchableTreePlugin.js.map +7 -0
  129. package/esm/plugins/searchable/index.js +3 -1
  130. package/esm/plugins/searchable/index.js.map +7 -0
  131. package/esm/plugins/selectable/SelectablePluginTree.js +6 -3
  132. package/esm/plugins/selectable/SelectablePluginTree.js.map +7 -0
  133. package/esm/plugins/selectable/index.js +3 -1
  134. package/esm/plugins/selectable/index.js.map +7 -0
  135. package/esm/plugins/toolbar/TreeToolbarPlugin.js +6 -3
  136. package/esm/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
  137. package/esm/plugins/toolbar/index.js +3 -1
  138. package/esm/plugins/toolbar/index.js.map +7 -0
  139. package/esm/plugins/tree/TreeDataPlugin.js +6 -3
  140. package/esm/plugins/tree/TreeDataPlugin.js.map +7 -0
  141. package/esm/plugins/tree/index.js +3 -1
  142. package/esm/plugins/tree/index.js.map +7 -0
  143. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +6 -3
  144. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
  145. package/esm/plugins/virtualization/index.js +3 -1
  146. package/esm/plugins/virtualization/index.js.map +7 -0
  147. package/esm/react-desc-prop-types.js +47 -44
  148. package/esm/react-desc-prop-types.js.map +7 -0
  149. package/esm/related-components/TreeViewSearchBar.js +13 -32
  150. package/esm/related-components/TreeViewSearchBar.js.map +7 -0
  151. package/esm/sharedTypes.js +2 -1
  152. package/esm/sharedTypes.js.map +7 -0
  153. package/esm/utils/array-helpers.js +6 -6
  154. package/esm/utils/array-helpers.js.map +7 -0
  155. package/esm/utils/dnd-helpers.js +117 -0
  156. package/esm/utils/dnd-helpers.js.map +7 -0
  157. package/esm/utils/group-expands-helpers.js +56 -46
  158. package/esm/utils/group-expands-helpers.js.map +7 -0
  159. package/esm/utils/keyboard-helpers.js +46 -74
  160. package/esm/utils/keyboard-helpers.js.map +7 -0
  161. package/esm/utils/object-helpers.js +14 -31
  162. package/esm/utils/object-helpers.js.map +7 -0
  163. package/esm/utils/refs-helpers.js +15 -19
  164. package/esm/utils/refs-helpers.js.map +7 -0
  165. package/esm/utils/selectable-helper.js +32 -43
  166. package/esm/utils/selectable-helper.js.map +7 -0
  167. package/esm/utils/string-helpers.js +6 -3
  168. package/esm/utils/string-helpers.js.map +7 -0
  169. package/esm/utils/tree-helpers.js +73 -143
  170. package/esm/utils/tree-helpers.js.map +7 -0
  171. package/esm/utils/useDnDHelpers.js +170 -0
  172. package/esm/utils/useDnDHelpers.js.map +7 -0
  173. package/esm/utils/useInstanceRefActions.js +21 -35
  174. package/esm/utils/useInstanceRefActions.js.map +7 -0
  175. package/esm/utils/useTree.js +35 -59
  176. package/esm/utils/useTree.js.map +7 -0
  177. package/package.json +19 -35
  178. package/types/TreeView.d.ts +1 -1
  179. package/types/parts/TreeItem.d.ts +11 -4
  180. package/types/parts/TreeList.d.ts +4 -0
  181. package/types/plugins/dnd/TreeDndPlugin.d.ts +2 -0
  182. package/types/react-desc-prop-types.d.ts +3 -17
  183. package/types/sharedTypes.d.ts +8 -1
  184. package/types/utils/dnd-helpers.d.ts +39 -0
  185. package/types/utils/keyboard-helpers.d.ts +1 -2
  186. package/types/utils/refs-helpers.d.ts +1 -1
  187. package/types/utils/tree-helpers.d.ts +1 -4
  188. package/types/utils/useDnDHelpers.d.ts +26 -0
  189. package/types/utils/useTree.d.ts +0 -1
  190. package/cjs/hoc/DnDTreeContext.js +0 -18
  191. package/cjs/hoc/SortableItemContext.js +0 -21
  192. package/cjs/hoc/WithConditionalDnDContext.js +0 -138
  193. package/cjs/hoc/WithDnDSortableItemContext.js +0 -70
  194. package/cjs/parts/DnDHandle.js +0 -46
  195. package/cjs/parts/DropIndicator.js +0 -75
  196. package/esm/hoc/DnDTreeContext.js +0 -14
  197. package/esm/hoc/SortableItemContext.js +0 -17
  198. package/esm/hoc/WithConditionalDnDContext.js +0 -128
  199. package/esm/hoc/WithDnDSortableItemContext.js +0 -61
  200. package/esm/parts/DnDHandle.js +0 -38
  201. package/esm/parts/DropIndicator.js +0 -68
  202. package/types/hoc/DnDTreeContext.d.ts +0 -14
  203. package/types/hoc/SortableItemContext.d.ts +0 -19
  204. package/types/hoc/WithConditionalDnDContext.d.ts +0 -4
  205. package/types/hoc/WithDnDSortableItemContext.d.ts +0 -4
  206. package/types/parts/DnDHandle.d.ts +0 -6
  207. package/types/parts/DropIndicator.d.ts +0 -10
@@ -1,138 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _jsx = require('@babel/runtime/helpers/jsx');
6
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
7
- require('core-js/modules/web.dom-collections.iterator.js');
8
- require('core-js/modules/esnext.async-iterator.map.js');
9
- require('core-js/modules/esnext.iterator.map.js');
10
- require('core-js/modules/esnext.async-iterator.for-each.js');
11
- require('core-js/modules/esnext.iterator.constructor.js');
12
- require('core-js/modules/esnext.iterator.for-each.js');
13
- require('core-js/modules/esnext.async-iterator.find.js');
14
- require('core-js/modules/esnext.iterator.find.js');
15
- require('core-js/modules/esnext.async-iterator.filter.js');
16
- require('core-js/modules/esnext.iterator.filter.js');
17
- var React = require('react');
18
- var core = require('@dnd-kit/core');
19
- var sortable = require('@dnd-kit/sortable');
20
- var dsDragAndDrop = require('@elliemae/ds-drag-and-drop');
21
- var TreeViewContext = require('../TreeViewContext.js');
22
- var TreeItem = require('../parts/TreeItem.js');
23
- var DnDTreeContext = require('./DnDTreeContext.js');
24
- var jsxRuntime = require('react/jsx-runtime');
25
-
26
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
27
-
28
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
29
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
30
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
31
-
32
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
33
-
34
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
35
-
36
- const ensure = function (argument) {
37
- let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'This should never happen';
38
-
39
- if (argument === undefined || argument === null) {
40
- throw new TypeError(message);
41
- }
42
-
43
- return argument;
44
- }; // only wraps in "DnDContext" and "DnDTreeContext" if any Drag and Drop functionality is requested
45
-
46
-
47
- const withConditionalDnDRowContext = Component => props => {
48
- const [lastActiveId, setLastActiveId] = React__default["default"].useState('');
49
- const {
50
- props: {
51
- data,
52
- onOrderChange,
53
- getIsDropValid
54
- },
55
- flattenedItems,
56
- visibleItems: flattenedVisibleTree,
57
- withDragAndDrop
58
- } = React.useContext(TreeViewContext["default"]);
59
- const flattenedVisibleTreeForDnD = React.useMemo(() => flattenedVisibleTree.map((item, index) => {
60
- var _item$treeDepth, _item$children$length, _item$children, _item$node$parent$mod, _item$node$parent, _item$node$parent$mod2, _item$node$parent$mod3;
61
-
62
- return {
63
- uid: item.id.toString(),
64
- depth: ((_item$treeDepth = item.treeDepth) !== null && _item$treeDepth !== void 0 ? _item$treeDepth : 1) - 1,
65
- realIndex: index,
66
- childrenCount: (_item$children$length = (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) !== null && _item$children$length !== void 0 ? _item$children$length : 0,
67
- parentId: (_item$node$parent$mod = (_item$node$parent = item.node.parent) === null || _item$node$parent === void 0 ? void 0 : (_item$node$parent$mod2 = _item$node$parent.model) === null || _item$node$parent$mod2 === void 0 ? void 0 : (_item$node$parent$mod3 = _item$node$parent$mod2.id) === null || _item$node$parent$mod3 === void 0 ? void 0 : _item$node$parent$mod3.toString()) !== null && _item$node$parent$mod !== void 0 ? _item$node$parent$mod : null,
68
- original: item
69
- };
70
- }), [flattenedVisibleTree]);
71
- const onReorder = React.useCallback((tree, indexes) => {
72
- // Pull the row's original data into an object
73
- const nodes = {};
74
- tree.forEach(item => {
75
- const originalItem = item.original;
76
- originalItem.children = [];
77
- nodes[item.uid] = item.original;
78
- });
79
- const newUserTree = [];
80
- tree.forEach(item => {
81
- // If row has parent, insert it to it's subrows
82
- // otherwise append it to the new user data
83
- if (item.parentId !== null && item.parentId !== undefined && item.parentId !== '__ds_tree_root') {
84
- var _parentNode$children;
85
-
86
- const parentNode = nodes[item.parentId];
87
- (_parentNode$children = parentNode.children) === null || _parentNode$children === void 0 ? void 0 : _parentNode$children.push(item.original);
88
- } else if (item.uid !== '__ds_tree_root') newUserTree.push(item.original);
89
- }); // Tell the user that the order has change, he can chose to commit it or not
90
-
91
- onOrderChange(newUserTree, data, flattenedItems[indexes.fromIndex]);
92
- }, [onOrderChange, data, flattenedItems]);
93
- const {
94
- dndContextProps,
95
- sortableContextProps,
96
- activeId,
97
- activeIndex,
98
- depth,
99
- dropIndicatorPosition,
100
- visibleItems,
101
- isDropValid
102
- } = dsDragAndDrop.useTreeDndkitConfig({
103
- flattenedItems,
104
- visibleItems: flattenedVisibleTreeForDnD,
105
- isHorizontalDnD: false,
106
- isExpandable: true,
107
- onReorder,
108
- getIsDropValid,
109
- maxDragAndDropLevel: Infinity
110
- });
111
- if (lastActiveId !== activeId && activeId) setLastActiveId(activeId);
112
- if (withDragAndDrop) return /*#__PURE__*/jsxRuntime.jsxs(core.DndContext, _objectSpread(_objectSpread({}, dndContextProps), {}, {
113
- children: [/*#__PURE__*/jsxRuntime.jsx(sortable.SortableContext, _objectSpread(_objectSpread({}, sortableContextProps), {}, {
114
- children: /*#__PURE__*/_jsx__default["default"](DnDTreeContext.DnDTreeContext.Provider, {
115
- value: {
116
- activeIndex,
117
- depth,
118
- visibleItems: visibleItems.map(item => item.original),
119
- dropIndicatorPosition,
120
- lastActiveId,
121
- setLastActiveId,
122
- isDropValid
123
- }
124
- }, void 0, /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread({}, props)))
125
- })), /*#__PURE__*/_jsx__default["default"](core.DragOverlay, {
126
- style: {
127
- width: 'auto'
128
- }
129
- }, void 0, activeId ? /*#__PURE__*/_jsx__default["default"](TreeItem.TreeItem, {
130
- itemIndex: activeIndex,
131
- item: ensure(flattenedVisibleTree.find(item => item.id.toString() === activeId)),
132
- isDragOverlay: true
133
- }) : null)]
134
- }));
135
- return /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread({}, props));
136
- };
137
-
138
- exports.withConditionalDnDRowContext = withConditionalDnDRowContext;
@@ -1,70 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('core-js/modules/esnext.async-iterator.filter.js');
6
- require('core-js/modules/esnext.iterator.constructor.js');
7
- require('core-js/modules/esnext.iterator.filter.js');
8
- require('core-js/modules/esnext.async-iterator.for-each.js');
9
- require('core-js/modules/esnext.iterator.for-each.js');
10
- var _jsx = require('@babel/runtime/helpers/jsx');
11
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
12
- var React = require('react');
13
- var sortable = require('@dnd-kit/sortable');
14
- var SortableItemContext = require('./SortableItemContext.js');
15
- var TreeViewContext = require('../TreeViewContext.js');
16
- var DnDTreeContext = require('./DnDTreeContext.js');
17
- var jsxRuntime = require('react/jsx-runtime');
18
-
19
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
-
21
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
22
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
- const withDnDSortableItemContext = Component => props => {
28
- const {
29
- withDragAndDrop
30
- } = React.useContext(TreeViewContext["default"]);
31
- const {
32
- dropIndicatorPosition,
33
- lastActiveId,
34
- setLastActiveId,
35
- isDropValid
36
- } = React.useContext(DnDTreeContext.DnDTreeContext);
37
- const id = props.item.id.toString(); // onMount generate unique options, so everyting is only ran once
38
-
39
- const draggableOptions = React.useMemo(() => ({
40
- id
41
- }), [id]);
42
- const useSortableHelpers = sortable.useSortable(draggableOptions); // calculate all the "useSortable" values as per required
43
-
44
- const draggableProps = React.useMemo(() => {
45
- if (!withDragAndDrop) return false;
46
- const {
47
- index,
48
- overIndex
49
- } = useSortableHelpers;
50
- return _objectSpread(_objectSpread({}, useSortableHelpers), {}, {
51
- shouldShowDropIndicatorPosition: overIndex === index,
52
- dropIndicatorPosition,
53
- lastActiveId,
54
- setLastActiveId,
55
- isDropValid
56
- });
57
- }, [withDragAndDrop, useSortableHelpers, dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid]); // we use a context so we can easly access information wherever without bubbling down
58
- // this context is all Memoized so as long as component is not re-mounted,
59
- // the context won't trigger un-required renders per-se...
60
-
61
- const ctx = React.useMemo(() => ({
62
- draggableProps
63
- }), [draggableProps]); // we always add the context, if draggableProps===false we don't have the DnD enabled.
64
-
65
- return /*#__PURE__*/_jsx__default["default"](SortableItemContext.SortableItemContext.Provider, {
66
- value: ctx
67
- }, void 0, /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread({}, props)));
68
- };
69
-
70
- exports.withDnDSortableItemContext = withDnDSortableItemContext;
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('core-js/modules/esnext.async-iterator.filter.js');
6
- require('core-js/modules/esnext.iterator.constructor.js');
7
- require('core-js/modules/esnext.iterator.filter.js');
8
- require('core-js/modules/esnext.async-iterator.for-each.js');
9
- require('core-js/modules/esnext.iterator.for-each.js');
10
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
11
- var React = require('react');
12
- var dsIcons = require('@elliemae/ds-icons');
13
- var SortableItemContext = require('../hoc/SortableItemContext.js');
14
-
15
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
-
17
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
18
-
19
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
-
21
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
22
- const DnDHandle = _ref => {
23
- let {
24
- id,
25
- isDragOverlay
26
- } = _ref;
27
- const {
28
- draggableProps
29
- } = React.useContext(SortableItemContext.SortableItemContext);
30
- const isDragging = draggableProps && draggableProps.isDragging;
31
- return /*#__PURE__*/React.createElement(dsIcons.GripperVertical, _objectSpread(_objectSpread({
32
- role: "button"
33
- }, draggableProps && _objectSpread(_objectSpread({}, draggableProps.listeners), draggableProps.attributes)), {}, {
34
- "data-testid": "drag-handle",
35
- "data-isactive": draggableProps && !!draggableProps.active,
36
- "data-isdragoverlay": isDragOverlay,
37
- id: "".concat(id, "-drag-handle"),
38
- key: "".concat(id, "-drag-handle"),
39
- className: "drag-handle ".concat(isDragging ? '' : 'focuseable'),
40
- color: ['brand-primary', '800'],
41
- size: "s",
42
- tabIndex: 0
43
- }));
44
- };
45
-
46
- exports.DnDHandle = DnDHandle;
@@ -1,75 +0,0 @@
1
- 'use strict';
2
-
3
- var _jsx = require('@babel/runtime/helpers/jsx');
4
- require('react');
5
- var styled = require('styled-components');
6
- var SortableItemContext = require('../hoc/SortableItemContext.js');
7
- var jsxRuntime = require('react/jsx-runtime');
8
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
12
- var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
13
-
14
- const getPositionStyles = _ref => {
15
- let {
16
- dropIndicatorPosition
17
- } = _ref;
18
- return "\n top: ".concat(dropIndicatorPosition === SortableItemContext.DropIndicatorPosition.Before ? '0' : 'unset', ";\n bottom: ").concat(dropIndicatorPosition === SortableItemContext.DropIndicatorPosition.After ? '0' : 'unset', ";\n left: -2px;\n ");
19
- };
20
-
21
- const getCircleStyles = _ref2 => {
22
- let {
23
- dropIndicatorPosition
24
- } = _ref2;
25
- return {
26
- position: 'absolute',
27
- zIndex: 20,
28
- top: dropIndicatorPosition === SortableItemContext.DropIndicatorPosition.After ? 'unset' : '-2px',
29
- bottom: dropIndicatorPosition === SortableItemContext.DropIndicatorPosition.Before ? 'unset' : '-2px',
30
- left: '0px',
31
- opacity: 1
32
- };
33
- };
34
-
35
- const StyledIndicator = /*#__PURE__*/styled__default["default"].div.withConfig({
36
- componentId: "sc-1812zh0-0"
37
- })(["position:absolute;", " box-sizing:border-box;width:", ";height:", ";background-color:", ";z-index:20;"], getPositionStyles, props => props.vertical ? '2px' : '100%', props => props.vertical ? '100%' : '2px', _ref3 => {
38
- let {
39
- isDropValid,
40
- theme
41
- } = _ref3;
42
- return isDropValid ? theme.colors.brand[600] : theme.colors.danger[900];
43
- });
44
-
45
- const CircleIndicator = (style, isDropValid) => /*#__PURE__*/_jsx__default["default"]("svg", {
46
- height: "6",
47
- width: "6",
48
- style: style
49
- }, void 0, /*#__PURE__*/_jsx__default["default"]("circle", {
50
- cx: "3",
51
- cy: "3",
52
- r: "3",
53
- strokeWidth: "0",
54
- fill: isDropValid ? '#1E79C2' : '#C64252'
55
- }));
56
-
57
- const DropIndicator = _ref4 => {
58
- let {
59
- dropIndicatorPosition,
60
- isLast,
61
- isDropValid
62
- } = _ref4;
63
- if (![SortableItemContext.DropIndicatorPosition.After, SortableItemContext.DropIndicatorPosition.Before].includes(dropIndicatorPosition)) return null;
64
- const safeDropIndicatorPosition = isLast ? SortableItemContext.DropIndicatorPosition.Before : dropIndicatorPosition;
65
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
66
- children: [CircleIndicator(getCircleStyles({
67
- dropIndicatorPosition: safeDropIndicatorPosition
68
- }), isDropValid), /*#__PURE__*/_jsx__default["default"](StyledIndicator, {
69
- dropIndicatorPosition: safeDropIndicatorPosition,
70
- isDropValid: isDropValid
71
- })]
72
- });
73
- };
74
-
75
- module.exports = DropIndicator;
@@ -1,14 +0,0 @@
1
- import { createContext } from 'react';
2
- import { DropIndicatorPosition } from './SortableItemContext.js';
3
-
4
- const DnDTreeContext = /*#__PURE__*/createContext({
5
- depth: undefined,
6
- activeIndex: undefined,
7
- visibleItems: undefined,
8
- dropIndicatorPosition: DropIndicatorPosition.None,
9
- lastActiveId: undefined,
10
- setLastActiveId: undefined,
11
- isDropValid: false
12
- });
13
-
14
- export { DnDTreeContext };
@@ -1,17 +0,0 @@
1
- import { createContext } from 'react';
2
-
3
- let DropIndicatorPosition;
4
-
5
- (function (DropIndicatorPosition) {
6
- DropIndicatorPosition[DropIndicatorPosition["None"] = 0] = "None";
7
- DropIndicatorPosition[DropIndicatorPosition["Before"] = 1] = "Before";
8
- DropIndicatorPosition[DropIndicatorPosition["After"] = 2] = "After";
9
- DropIndicatorPosition[DropIndicatorPosition["Inside"] = 3] = "Inside";
10
- })(DropIndicatorPosition || (DropIndicatorPosition = {}));
11
-
12
- /** Context for cross component communication */
13
- const SortableItemContext = /*#__PURE__*/createContext({
14
- draggableProps: false
15
- });
16
-
17
- export { DropIndicatorPosition, SortableItemContext };
@@ -1,128 +0,0 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.filter.js';
3
- import _jsx from '@babel/runtime/helpers/esm/jsx';
4
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
5
- import 'core-js/modules/web.dom-collections.iterator.js';
6
- import 'core-js/modules/esnext.async-iterator.map.js';
7
- import 'core-js/modules/esnext.iterator.map.js';
8
- import 'core-js/modules/esnext.async-iterator.for-each.js';
9
- import 'core-js/modules/esnext.iterator.constructor.js';
10
- import 'core-js/modules/esnext.iterator.for-each.js';
11
- import 'core-js/modules/esnext.async-iterator.find.js';
12
- import 'core-js/modules/esnext.iterator.find.js';
13
- import React, { useContext, useMemo, useCallback } from 'react';
14
- import { DndContext, DragOverlay } from '@dnd-kit/core';
15
- import { SortableContext } from '@dnd-kit/sortable';
16
- import { useTreeDndkitConfig } from '@elliemae/ds-drag-and-drop';
17
- import TreeViewContext from '../TreeViewContext.js';
18
- import { TreeItem } from '../parts/TreeItem.js';
19
- import { DnDTreeContext } from './DnDTreeContext.js';
20
- import { jsxs, jsx } from 'react/jsx-runtime';
21
-
22
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
-
24
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
-
26
- const ensure = function (argument) {
27
- let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'This should never happen';
28
-
29
- if (argument === undefined || argument === null) {
30
- throw new TypeError(message);
31
- }
32
-
33
- return argument;
34
- }; // only wraps in "DnDContext" and "DnDTreeContext" if any Drag and Drop functionality is requested
35
-
36
-
37
- const withConditionalDnDRowContext = Component => props => {
38
- const [lastActiveId, setLastActiveId] = React.useState('');
39
- const {
40
- props: {
41
- data,
42
- onOrderChange,
43
- getIsDropValid
44
- },
45
- flattenedItems,
46
- visibleItems: flattenedVisibleTree,
47
- withDragAndDrop
48
- } = useContext(TreeViewContext);
49
- const flattenedVisibleTreeForDnD = useMemo(() => flattenedVisibleTree.map((item, index) => {
50
- var _item$treeDepth, _item$children$length, _item$children, _item$node$parent$mod, _item$node$parent, _item$node$parent$mod2, _item$node$parent$mod3;
51
-
52
- return {
53
- uid: item.id.toString(),
54
- depth: ((_item$treeDepth = item.treeDepth) !== null && _item$treeDepth !== void 0 ? _item$treeDepth : 1) - 1,
55
- realIndex: index,
56
- childrenCount: (_item$children$length = (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) !== null && _item$children$length !== void 0 ? _item$children$length : 0,
57
- parentId: (_item$node$parent$mod = (_item$node$parent = item.node.parent) === null || _item$node$parent === void 0 ? void 0 : (_item$node$parent$mod2 = _item$node$parent.model) === null || _item$node$parent$mod2 === void 0 ? void 0 : (_item$node$parent$mod3 = _item$node$parent$mod2.id) === null || _item$node$parent$mod3 === void 0 ? void 0 : _item$node$parent$mod3.toString()) !== null && _item$node$parent$mod !== void 0 ? _item$node$parent$mod : null,
58
- original: item
59
- };
60
- }), [flattenedVisibleTree]);
61
- const onReorder = useCallback((tree, indexes) => {
62
- // Pull the row's original data into an object
63
- const nodes = {};
64
- tree.forEach(item => {
65
- const originalItem = item.original;
66
- originalItem.children = [];
67
- nodes[item.uid] = item.original;
68
- });
69
- const newUserTree = [];
70
- tree.forEach(item => {
71
- // If row has parent, insert it to it's subrows
72
- // otherwise append it to the new user data
73
- if (item.parentId !== null && item.parentId !== undefined && item.parentId !== '__ds_tree_root') {
74
- var _parentNode$children;
75
-
76
- const parentNode = nodes[item.parentId];
77
- (_parentNode$children = parentNode.children) === null || _parentNode$children === void 0 ? void 0 : _parentNode$children.push(item.original);
78
- } else if (item.uid !== '__ds_tree_root') newUserTree.push(item.original);
79
- }); // Tell the user that the order has change, he can chose to commit it or not
80
-
81
- onOrderChange(newUserTree, data, flattenedItems[indexes.fromIndex]);
82
- }, [onOrderChange, data, flattenedItems]);
83
- const {
84
- dndContextProps,
85
- sortableContextProps,
86
- activeId,
87
- activeIndex,
88
- depth,
89
- dropIndicatorPosition,
90
- visibleItems,
91
- isDropValid
92
- } = useTreeDndkitConfig({
93
- flattenedItems,
94
- visibleItems: flattenedVisibleTreeForDnD,
95
- isHorizontalDnD: false,
96
- isExpandable: true,
97
- onReorder,
98
- getIsDropValid,
99
- maxDragAndDropLevel: Infinity
100
- });
101
- if (lastActiveId !== activeId && activeId) setLastActiveId(activeId);
102
- if (withDragAndDrop) return /*#__PURE__*/jsxs(DndContext, _objectSpread(_objectSpread({}, dndContextProps), {}, {
103
- children: [/*#__PURE__*/jsx(SortableContext, _objectSpread(_objectSpread({}, sortableContextProps), {}, {
104
- children: /*#__PURE__*/_jsx(DnDTreeContext.Provider, {
105
- value: {
106
- activeIndex,
107
- depth,
108
- visibleItems: visibleItems.map(item => item.original),
109
- dropIndicatorPosition,
110
- lastActiveId,
111
- setLastActiveId,
112
- isDropValid
113
- }
114
- }, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)))
115
- })), /*#__PURE__*/_jsx(DragOverlay, {
116
- style: {
117
- width: 'auto'
118
- }
119
- }, void 0, activeId ? /*#__PURE__*/_jsx(TreeItem, {
120
- itemIndex: activeIndex,
121
- item: ensure(flattenedVisibleTree.find(item => item.id.toString() === activeId)),
122
- isDragOverlay: true
123
- }) : null)]
124
- }));
125
- return /*#__PURE__*/jsx(Component, _objectSpread({}, props));
126
- };
127
-
128
- export { withConditionalDnDRowContext };
@@ -1,61 +0,0 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.constructor.js';
3
- import 'core-js/modules/esnext.iterator.filter.js';
4
- import 'core-js/modules/esnext.async-iterator.for-each.js';
5
- import 'core-js/modules/esnext.iterator.for-each.js';
6
- import _jsx from '@babel/runtime/helpers/esm/jsx';
7
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
8
- import { useContext, useMemo } from 'react';
9
- import { useSortable } from '@dnd-kit/sortable';
10
- import { SortableItemContext } from './SortableItemContext.js';
11
- import TreeViewContext from '../TreeViewContext.js';
12
- import { DnDTreeContext } from './DnDTreeContext.js';
13
- import { jsx } from 'react/jsx-runtime';
14
-
15
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
-
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
- const withDnDSortableItemContext = Component => props => {
19
- const {
20
- withDragAndDrop
21
- } = useContext(TreeViewContext);
22
- const {
23
- dropIndicatorPosition,
24
- lastActiveId,
25
- setLastActiveId,
26
- isDropValid
27
- } = useContext(DnDTreeContext);
28
- const id = props.item.id.toString(); // onMount generate unique options, so everyting is only ran once
29
-
30
- const draggableOptions = useMemo(() => ({
31
- id
32
- }), [id]);
33
- const useSortableHelpers = useSortable(draggableOptions); // calculate all the "useSortable" values as per required
34
-
35
- const draggableProps = useMemo(() => {
36
- if (!withDragAndDrop) return false;
37
- const {
38
- index,
39
- overIndex
40
- } = useSortableHelpers;
41
- return _objectSpread(_objectSpread({}, useSortableHelpers), {}, {
42
- shouldShowDropIndicatorPosition: overIndex === index,
43
- dropIndicatorPosition,
44
- lastActiveId,
45
- setLastActiveId,
46
- isDropValid
47
- });
48
- }, [withDragAndDrop, useSortableHelpers, dropIndicatorPosition, lastActiveId, setLastActiveId, isDropValid]); // we use a context so we can easly access information wherever without bubbling down
49
- // this context is all Memoized so as long as component is not re-mounted,
50
- // the context won't trigger un-required renders per-se...
51
-
52
- const ctx = useMemo(() => ({
53
- draggableProps
54
- }), [draggableProps]); // we always add the context, if draggableProps===false we don't have the DnD enabled.
55
-
56
- return /*#__PURE__*/_jsx(SortableItemContext.Provider, {
57
- value: ctx
58
- }, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)));
59
- };
60
-
61
- export { withDnDSortableItemContext };
@@ -1,38 +0,0 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.constructor.js';
3
- import 'core-js/modules/esnext.iterator.filter.js';
4
- import 'core-js/modules/esnext.async-iterator.for-each.js';
5
- import 'core-js/modules/esnext.iterator.for-each.js';
6
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
- import { useContext, createElement } from 'react';
8
- import { GripperVertical } from '@elliemae/ds-icons';
9
- import { SortableItemContext } from '../hoc/SortableItemContext.js';
10
-
11
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
-
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
- const DnDHandle = _ref => {
15
- let {
16
- id,
17
- isDragOverlay
18
- } = _ref;
19
- const {
20
- draggableProps
21
- } = useContext(SortableItemContext);
22
- const isDragging = draggableProps && draggableProps.isDragging;
23
- return /*#__PURE__*/createElement(GripperVertical, _objectSpread(_objectSpread({
24
- role: "button"
25
- }, draggableProps && _objectSpread(_objectSpread({}, draggableProps.listeners), draggableProps.attributes)), {}, {
26
- "data-testid": "drag-handle",
27
- "data-isactive": draggableProps && !!draggableProps.active,
28
- "data-isdragoverlay": isDragOverlay,
29
- id: "".concat(id, "-drag-handle"),
30
- key: "".concat(id, "-drag-handle"),
31
- className: "drag-handle ".concat(isDragging ? '' : 'focuseable'),
32
- color: ['brand-primary', '800'],
33
- size: "s",
34
- tabIndex: 0
35
- }));
36
- };
37
-
38
- export { DnDHandle };
@@ -1,68 +0,0 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import 'react';
3
- import styled from 'styled-components';
4
- import { DropIndicatorPosition } from '../hoc/SortableItemContext.js';
5
- import { jsxs, Fragment } from 'react/jsx-runtime';
6
-
7
- const getPositionStyles = _ref => {
8
- let {
9
- dropIndicatorPosition
10
- } = _ref;
11
- return "\n top: ".concat(dropIndicatorPosition === DropIndicatorPosition.Before ? '0' : 'unset', ";\n bottom: ").concat(dropIndicatorPosition === DropIndicatorPosition.After ? '0' : 'unset', ";\n left: -2px;\n ");
12
- };
13
-
14
- const getCircleStyles = _ref2 => {
15
- let {
16
- dropIndicatorPosition
17
- } = _ref2;
18
- return {
19
- position: 'absolute',
20
- zIndex: 20,
21
- top: dropIndicatorPosition === DropIndicatorPosition.After ? 'unset' : '-2px',
22
- bottom: dropIndicatorPosition === DropIndicatorPosition.Before ? 'unset' : '-2px',
23
- left: '0px',
24
- opacity: 1
25
- };
26
- };
27
-
28
- const StyledIndicator = /*#__PURE__*/styled.div.withConfig({
29
- componentId: "sc-1812zh0-0"
30
- })(["position:absolute;", " box-sizing:border-box;width:", ";height:", ";background-color:", ";z-index:20;"], getPositionStyles, props => props.vertical ? '2px' : '100%', props => props.vertical ? '100%' : '2px', _ref3 => {
31
- let {
32
- isDropValid,
33
- theme
34
- } = _ref3;
35
- return isDropValid ? theme.colors.brand[600] : theme.colors.danger[900];
36
- });
37
-
38
- const CircleIndicator = (style, isDropValid) => /*#__PURE__*/_jsx("svg", {
39
- height: "6",
40
- width: "6",
41
- style: style
42
- }, void 0, /*#__PURE__*/_jsx("circle", {
43
- cx: "3",
44
- cy: "3",
45
- r: "3",
46
- strokeWidth: "0",
47
- fill: isDropValid ? '#1E79C2' : '#C64252'
48
- }));
49
-
50
- const DropIndicator = _ref4 => {
51
- let {
52
- dropIndicatorPosition,
53
- isLast,
54
- isDropValid
55
- } = _ref4;
56
- if (![DropIndicatorPosition.After, DropIndicatorPosition.Before].includes(dropIndicatorPosition)) return null;
57
- const safeDropIndicatorPosition = isLast ? DropIndicatorPosition.Before : dropIndicatorPosition;
58
- return /*#__PURE__*/jsxs(Fragment, {
59
- children: [CircleIndicator(getCircleStyles({
60
- dropIndicatorPosition: safeDropIndicatorPosition
61
- }), isDropValid), /*#__PURE__*/_jsx(StyledIndicator, {
62
- dropIndicatorPosition: safeDropIndicatorPosition,
63
- isDropValid: isDropValid
64
- })]
65
- });
66
- };
67
-
68
- export { DropIndicator as default };