@elliemae/ds-treeview 2.2.0-next.5 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/cjs/TreeView.js +6 -2
  2. package/cjs/TreeViewContext.js +8 -2
  3. package/cjs/config/useTreeview.js +13 -3
  4. package/cjs/index.js +1 -0
  5. package/cjs/parts/TreeItem.js +68 -43
  6. package/cjs/parts/TreeList.js +17 -15
  7. package/cjs/plugins/dnd/TreeDndPlugin.js +37 -0
  8. package/cjs/plugins/dnd/index.js +1 -0
  9. package/cjs/plugins/index.js +1 -0
  10. package/cjs/react-desc-prop-types.js +0 -1
  11. package/cjs/utils/dnd-helpers.js +140 -0
  12. package/cjs/utils/keyboard-helpers.js +5 -6
  13. package/cjs/utils/tree-helpers.js +2 -28
  14. package/cjs/utils/useDnDHelpers.js +220 -0
  15. package/cjs/utils/useTree.js +2 -4
  16. package/esm/TreeView.js +6 -2
  17. package/esm/TreeViewContext.js +8 -2
  18. package/esm/config/useTreeview.js +14 -4
  19. package/esm/index.js +1 -1
  20. package/esm/parts/TreeItem.js +67 -42
  21. package/esm/parts/TreeList.js +17 -16
  22. package/esm/plugins/dnd/TreeDndPlugin.js +33 -1
  23. package/esm/plugins/dnd/index.js +1 -1
  24. package/esm/plugins/index.js +1 -1
  25. package/esm/react-desc-prop-types.js +0 -1
  26. package/esm/utils/dnd-helpers.js +132 -0
  27. package/esm/utils/keyboard-helpers.js +5 -6
  28. package/esm/utils/tree-helpers.js +3 -28
  29. package/esm/utils/useDnDHelpers.js +216 -0
  30. package/esm/utils/useTree.js +3 -5
  31. package/package.json +19 -35
  32. package/types/TreeView.d.ts +1 -1
  33. package/types/parts/TreeItem.d.ts +11 -4
  34. package/types/parts/TreeList.d.ts +4 -0
  35. package/types/plugins/dnd/TreeDndPlugin.d.ts +2 -0
  36. package/types/react-desc-prop-types.d.ts +3 -17
  37. package/types/sharedTypes.d.ts +8 -1
  38. package/types/utils/dnd-helpers.d.ts +39 -0
  39. package/types/utils/keyboard-helpers.d.ts +1 -2
  40. package/types/utils/refs-helpers.d.ts +1 -1
  41. package/types/utils/tree-helpers.d.ts +1 -4
  42. package/types/utils/useDnDHelpers.d.ts +26 -0
  43. package/types/utils/useTree.d.ts +0 -1
  44. package/cjs/hoc/DnDTreeContext.js +0 -18
  45. package/cjs/hoc/SortableItemContext.js +0 -21
  46. package/cjs/hoc/WithConditionalDnDContext.js +0 -138
  47. package/cjs/hoc/WithDnDSortableItemContext.js +0 -70
  48. package/cjs/parts/DnDHandle.js +0 -46
  49. package/cjs/parts/DropIndicator.js +0 -75
  50. package/esm/hoc/DnDTreeContext.js +0 -14
  51. package/esm/hoc/SortableItemContext.js +0 -17
  52. package/esm/hoc/WithConditionalDnDContext.js +0 -128
  53. package/esm/hoc/WithDnDSortableItemContext.js +0 -61
  54. package/esm/parts/DnDHandle.js +0 -38
  55. package/esm/parts/DropIndicator.js +0 -68
  56. package/types/hoc/DnDTreeContext.d.ts +0 -14
  57. package/types/hoc/SortableItemContext.d.ts +0 -19
  58. package/types/hoc/WithConditionalDnDContext.d.ts +0 -4
  59. package/types/hoc/WithDnDSortableItemContext.d.ts +0 -4
  60. package/types/parts/DnDHandle.d.ts +0 -6
  61. package/types/parts/DropIndicator.d.ts +0 -10
@@ -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 };
@@ -1,14 +0,0 @@
1
- /// <reference types="react" />
2
- import { DSTreeviewT } from '../react-desc-prop-types';
3
- import { DropIndicatorPosition } from './SortableItemContext';
4
- declare type DnDTreeContextType = {
5
- depth: number | undefined;
6
- activeIndex: number | undefined;
7
- visibleItems: DSTreeviewT.Item[] | undefined;
8
- dropIndicatorPosition: DropIndicatorPosition;
9
- lastActiveId: string | undefined;
10
- setLastActiveId: React.Dispatch<React.SetStateAction<string>> | undefined;
11
- isDropValid: boolean;
12
- };
13
- export declare const DnDTreeContext: import("react").Context<DnDTreeContextType>;
14
- export {};
@@ -1,19 +0,0 @@
1
- /// <reference types="react" />
2
- import { useSortable } from '@dnd-kit/sortable';
3
- export declare enum DropIndicatorPosition {
4
- None = 0,
5
- Before = 1,
6
- After = 2,
7
- Inside = 3
8
- }
9
- export declare type SortableItemContextType = {
10
- draggableProps: false | (ReturnType<typeof useSortable> & {
11
- dropIndicatorPosition: DropIndicatorPosition;
12
- shouldShowDropIndicatorPosition: boolean;
13
- lastActiveId?: string;
14
- setLastActiveId?: React.Dispatch<React.SetStateAction<string>>;
15
- isDropValid: boolean;
16
- });
17
- };
18
- /** Context for cross component communication */
19
- export declare const SortableItemContext: import("react").Context<SortableItemContextType>;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- declare type FunctionalHOC = <T = unknown>(Component: React.ComponentType<T>, ...other: unknown[]) => (props: T) => JSX.Element;
3
- export declare const withConditionalDnDRowContext: FunctionalHOC;
4
- export {};
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- declare type FunctionalHOC = <T = unknown>(Component: React.ComponentType<T>, ...other: unknown[]) => (props: T) => JSX.Element;
3
- export declare const withDnDSortableItemContext: FunctionalHOC;
4
- export {};
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import { DSTreeviewT } from '../react-desc-prop-types';
3
- export declare const DnDHandle: ({ id, isDragOverlay }: {
4
- id: DSTreeviewT.StringOrNum;
5
- isDragOverlay: boolean;
6
- }) => JSX.Element;
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import { DropIndicatorPosition } from '../hoc/SortableItemContext';
3
- interface DropIndicatorProps {
4
- vertical?: boolean;
5
- dropIndicatorPosition: DropIndicatorPosition | false;
6
- isLast?: boolean;
7
- isDropValid?: boolean;
8
- }
9
- declare const DropIndicator: React.ComponentType<DropIndicatorProps>;
10
- export default DropIndicator;