@elliemae/ds-treeview 2.4.2-rc.11 → 2.4.2-rc.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/config/cssClassesConstants.js +1 -1
- package/cjs/config/useTreeview.js +2 -3
- package/cjs/hoc/WithConditionalDnDContext.js +10 -15
- package/cjs/parts/ChildrenCountDisplayer.js +2 -2
- package/cjs/parts/DnDHandle.js +3 -3
- package/cjs/parts/DropIndicator.js +5 -1
- package/cjs/parts/ExpandCaret.js +1 -1
- package/cjs/parts/NestingSpace.js +1 -1
- package/cjs/parts/RadioSelectable.js +1 -1
- package/cjs/parts/TreeItem.js +8 -8
- package/cjs/parts/TreeItemText.js +6 -6
- package/cjs/parts/TreeList.js +10 -10
- package/cjs/utils/array-helpers.js +0 -2
- package/cjs/utils/group-expands-helpers.js +1 -1
- package/cjs/utils/object-helpers.js +1 -3
- package/cjs/utils/tree-helpers.js +5 -11
- package/cjs/utils/useInstanceRefActions.js +0 -1
- package/cjs/utils/useTree.js +1 -2
- package/esm/config/cssClassesConstants.js +1 -1
- package/esm/config/useTreeview.js +1 -2
- package/esm/hoc/WithConditionalDnDContext.js +10 -15
- package/esm/parts/ChildrenCountDisplayer.js +2 -2
- package/esm/parts/DnDHandle.js +3 -3
- package/esm/parts/DropIndicator.js +5 -1
- package/esm/parts/ExpandCaret.js +1 -1
- package/esm/parts/NestingSpace.js +1 -1
- package/esm/parts/RadioSelectable.js +1 -1
- package/esm/parts/TreeItem.js +8 -8
- package/esm/parts/TreeItemText.js +6 -6
- package/esm/parts/TreeList.js +10 -10
- package/esm/utils/array-helpers.js +0 -2
- package/esm/utils/group-expands-helpers.js +1 -1
- package/esm/utils/object-helpers.js +1 -3
- package/esm/utils/tree-helpers.js +5 -11
- package/esm/utils/useInstanceRefActions.js +0 -1
- package/esm/utils/useTree.js +0 -1
- package/package.json +10 -10
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const DSTreeViewPrefix = 'em-ds';
|
|
6
6
|
const treeItemBlockName = 'tree-item';
|
|
7
7
|
const treeListBlockName = 'tree-list';
|
|
8
|
-
const treeListNoItemsBn =
|
|
8
|
+
const treeListNoItemsBn = `${treeListBlockName}-no-items`;
|
|
9
9
|
|
|
10
10
|
exports.DSTreeViewPrefix = DSTreeViewPrefix;
|
|
11
11
|
exports.treeItemBlockName = treeItemBlockName;
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
5
|
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
8
6
|
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
7
|
require('core-js/modules/esnext.iterator.filter.js');
|
|
10
8
|
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
9
|
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
12
11
|
var React = require('react');
|
|
13
12
|
var reactVirtual = require('react-virtual');
|
|
14
13
|
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
@@ -75,7 +74,7 @@ const useTreeview = props => {
|
|
|
75
74
|
parentRef: virtualListRef,
|
|
76
75
|
overscan: 15
|
|
77
76
|
});
|
|
78
|
-
const withDragAndDrop = !!(plugins
|
|
77
|
+
const withDragAndDrop = !!(plugins?.includes(TreeDndPlugin.TreeDndPlugin) && onOrderChange);
|
|
79
78
|
const withRadioChecks = isSingleSelect && !isMultiSelect;
|
|
80
79
|
const withCheckboxChecks = !isSingleSelect && isMultiSelect;
|
|
81
80
|
const handleExpandGroup = React.useCallback(groupExpandsHelpers.toggleItemExpand, []);
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
6
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
|
+
require('core-js/modules/es.error.cause.js');
|
|
7
8
|
require('core-js/modules/esnext.async-iterator.map.js');
|
|
8
9
|
require('core-js/modules/esnext.iterator.map.js');
|
|
9
10
|
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
@@ -57,18 +58,14 @@ const withConditionalDnDRowContext = Component => props => {
|
|
|
57
58
|
visibleItems: flattenedVisibleTree,
|
|
58
59
|
withDragAndDrop
|
|
59
60
|
} = React.useContext(TreeViewContext["default"]);
|
|
60
|
-
const flattenedVisibleTreeForDnD = React.useMemo(() => flattenedVisibleTree.map((item, index) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
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,
|
|
69
|
-
original: item
|
|
70
|
-
};
|
|
71
|
-
}), [flattenedVisibleTree]);
|
|
61
|
+
const flattenedVisibleTreeForDnD = React.useMemo(() => flattenedVisibleTree.map((item, index) => ({
|
|
62
|
+
uid: item.id.toString(),
|
|
63
|
+
depth: (item.treeDepth ?? 1) - 1,
|
|
64
|
+
realIndex: index,
|
|
65
|
+
childrenCount: item.children?.length ?? 0,
|
|
66
|
+
parentId: item.node.parent?.model?.id?.toString() ?? null,
|
|
67
|
+
original: item
|
|
68
|
+
})), [flattenedVisibleTree]);
|
|
72
69
|
const onReorder = React.useCallback((tree, indexes) => {
|
|
73
70
|
// Pull the row's original data into an object
|
|
74
71
|
const nodes = {};
|
|
@@ -82,10 +79,8 @@ const withConditionalDnDRowContext = Component => props => {
|
|
|
82
79
|
// If row has parent, insert it to it's subrows
|
|
83
80
|
// otherwise append it to the new user data
|
|
84
81
|
if (item.parentId !== null && item.parentId !== undefined && item.parentId !== '__ds_tree_root') {
|
|
85
|
-
var _parentNode$children;
|
|
86
|
-
|
|
87
82
|
const parentNode = nodes[item.parentId];
|
|
88
|
-
|
|
83
|
+
parentNode.children?.push(item.original);
|
|
89
84
|
} else if (item.uid !== '__ds_tree_root') newUserTree.push(item.original);
|
|
90
85
|
}); // Tell the user that the order has change, he can chose to commit it or not
|
|
91
86
|
|
|
@@ -16,7 +16,7 @@ var _Separator;
|
|
|
16
16
|
const Separator = /*#__PURE__*/styled__default["default"].span.withConfig({
|
|
17
17
|
componentId: "sc-13smqda-0"
|
|
18
18
|
})(["width:1px;height:12px;margin:0 8px;border-left:1px solid ", ";font-size:12px;"], props => props.theme.colors.neutral['600']);
|
|
19
|
-
const className =
|
|
19
|
+
const className = `${cssClassesConstants.DSTreeViewPrefix}-${cssClassesConstants.treeItemBlockName}-children-count-displayer`;
|
|
20
20
|
const ChildrenCountDisplayer = props => {
|
|
21
21
|
const {
|
|
22
22
|
item
|
|
@@ -29,7 +29,7 @@ const ChildrenCountDisplayer = props => {
|
|
|
29
29
|
return /*#__PURE__*/_jsx__default["default"]("span", {
|
|
30
30
|
"data-testid": "tree-item-children-count-displayer",
|
|
31
31
|
className: className
|
|
32
|
-
}, void 0, _Separator || (_Separator = /*#__PURE__*/_jsx__default["default"](Separator, {})),
|
|
32
|
+
}, void 0, _Separator || (_Separator = /*#__PURE__*/_jsx__default["default"](Separator, {})), `${children.length} Items`);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
exports.ChildrenCountDisplayer = ChildrenCountDisplayer;
|
package/cjs/parts/DnDHandle.js
CHANGED
|
@@ -34,9 +34,9 @@ const DnDHandle = _ref => {
|
|
|
34
34
|
"data-testid": "drag-handle",
|
|
35
35
|
"data-isactive": draggableProps && !!draggableProps.active,
|
|
36
36
|
"data-isdragoverlay": isDragOverlay,
|
|
37
|
-
id:
|
|
38
|
-
key:
|
|
39
|
-
className:
|
|
37
|
+
id: `${id}-drag-handle`,
|
|
38
|
+
key: `${id}-drag-handle`,
|
|
39
|
+
className: `drag-handle ${isDragging ? '' : 'focuseable'}`,
|
|
40
40
|
color: isDragging ? ['neutral', '080'] : ['brand-primary', '800'],
|
|
41
41
|
size: "s",
|
|
42
42
|
tabIndex: 0
|
|
@@ -15,7 +15,11 @@ const getPositionStyles = _ref => {
|
|
|
15
15
|
let {
|
|
16
16
|
dropIndicatorPosition
|
|
17
17
|
} = _ref;
|
|
18
|
-
return
|
|
18
|
+
return `
|
|
19
|
+
top: ${dropIndicatorPosition === SortableItemContext.DropIndicatorPosition.Before ? '0' : 'unset'};
|
|
20
|
+
bottom: ${dropIndicatorPosition === SortableItemContext.DropIndicatorPosition.After ? '0' : 'unset'};
|
|
21
|
+
left: -2px;
|
|
22
|
+
`;
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
const getCircleStyles = _ref2 => {
|
package/cjs/parts/ExpandCaret.js
CHANGED
|
@@ -17,7 +17,7 @@ const getItemNestingLeftPadding = (level, opts) => {
|
|
|
17
17
|
const finalLeftPadding = groupLeftPadding + spaceForNestingLevel - 0.1; // root level left-padding would be negative and would not be applied
|
|
18
18
|
// if "root-level" nesting, then defaults to 0 left-padding.
|
|
19
19
|
|
|
20
|
-
return finalLeftPadding > 0 ?
|
|
20
|
+
return finalLeftPadding > 0 ? `${finalLeftPadding}em` : '0';
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const NestingSpace = props => {
|
|
@@ -43,7 +43,7 @@ function RadioSelectable(props) {
|
|
|
43
43
|
};
|
|
44
44
|
if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
|
|
45
45
|
}, [id, setSelectedCheckboxes, itemIndex, onSelectionChange, item, scrollToIndex]);
|
|
46
|
-
const radioName = React.useMemo(() =>
|
|
46
|
+
const radioName = React.useMemo(() => `radios-${uniqueTreeViewUUID}`, [uniqueTreeViewUUID]);
|
|
47
47
|
const isDisabled = React.useMemo(() => isItemDisabled(item), [item, isItemDisabled]);
|
|
48
48
|
return /*#__PURE__*/_jsx__default["default"](dsForm.DSRadio, {
|
|
49
49
|
checked: selectedCheckboxes[id] === true,
|
package/cjs/parts/TreeItem.js
CHANGED
|
@@ -99,28 +99,28 @@ const TreeItem = props => {
|
|
|
99
99
|
const isDropValid = draggableProps && draggableProps.isDropValid;
|
|
100
100
|
const dropPreviewClassName = React.useMemo(() => {
|
|
101
101
|
if (isDropIndicatorPositionInside) {
|
|
102
|
-
const className =
|
|
102
|
+
const className = `${cssClassesConstants.DSTreeViewPrefix}-${cssClassesConstants.treeItemBlockName}${isDropValid ? '--valid' : '--invalid'}-drop-in`;
|
|
103
103
|
return className;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
return '';
|
|
107
107
|
}, [isDropIndicatorPositionInside, isDropValid]);
|
|
108
108
|
const dragOverlayClassName = React.useMemo(() => isDragOverlay ? 'drag-overlay' : '', [isDragOverlay]);
|
|
109
|
-
const selectedClassName = React.useMemo(() =>
|
|
110
|
-
const hoverClassName = React.useMemo(() => !isDragOverlay &&
|
|
109
|
+
const selectedClassName = React.useMemo(() => selectedItem?.id === item.id && !isDragOverlay ? 'selected' : '', [isDragOverlay, item.id, selectedItem?.id]);
|
|
110
|
+
const hoverClassName = React.useMemo(() => !isDragOverlay && hoverItem?.id === item.id && !isDragging ? 'hover' : '', [isDragOverlay, hoverItem?.id, item.id, isDragging]);
|
|
111
111
|
const fixedHeightClassname = React.useMemo(() => {
|
|
112
112
|
if (labelOverflow === 'truncate') {
|
|
113
|
-
if (rowSize === 'compact') return
|
|
114
|
-
return
|
|
113
|
+
if (rowSize === 'compact') return `${cssClassesConstants.DSTreeViewPrefix}-${cssClassesConstants.treeItemBlockName}--fixed-height-compact`;
|
|
114
|
+
return `${cssClassesConstants.DSTreeViewPrefix}-${cssClassesConstants.treeItemBlockName}--fixed-height`;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
return '';
|
|
118
118
|
}, [labelOverflow, rowSize]);
|
|
119
119
|
const isDraggingClassname = React.useMemo(() => {
|
|
120
|
-
if (isDragging) return
|
|
120
|
+
if (isDragging) return `${cssClassesConstants.DSTreeViewPrefix}-${cssClassesConstants.treeItemBlockName}--dragging`;
|
|
121
121
|
return '';
|
|
122
122
|
}, [isDragging]);
|
|
123
|
-
const finalClassName = React.useMemo(() =>
|
|
123
|
+
const finalClassName = React.useMemo(() => `${dropPreviewClassName} ${fixedHeightClassname} ${selectedClassName} ${hoverClassName} ${dragOverlayClassName} ${isDraggingClassname}`, [dropPreviewClassName, fixedHeightClassname, selectedClassName, hoverClassName, dragOverlayClassName, isDraggingClassname]);
|
|
124
124
|
const handleItemClick = React.useCallback(e => {
|
|
125
125
|
onItemClick(item, e);
|
|
126
126
|
setFocusedItem(item);
|
|
@@ -140,7 +140,7 @@ const TreeItem = props => {
|
|
|
140
140
|
return /*#__PURE__*/jsxRuntime.jsxs(TreeListItem, {
|
|
141
141
|
tabIndex: 0,
|
|
142
142
|
onMouseLeave: () => {
|
|
143
|
-
if (
|
|
143
|
+
if (hoverItem?.id === item.id) {
|
|
144
144
|
setHoverItem(null);
|
|
145
145
|
}
|
|
146
146
|
},
|
|
@@ -17,11 +17,11 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
17
17
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
18
18
|
var Highlighter__default = /*#__PURE__*/_interopDefaultLegacy(Highlighter);
|
|
19
19
|
|
|
20
|
-
const ItemContent = dsClassnames.aggregatedClasses('div')(
|
|
20
|
+
const ItemContent = dsClassnames.aggregatedClasses('div')(`${cssClassesConstants.treeItemBlockName}-content`);
|
|
21
21
|
const ItemValue = dsClassnames.aggregatedClasses('span')(cssClassesConstants.treeItemBlockName, 'value'); // const wrapperClassName = `${DSTreeViewPrefix}-${treeItemBlockName}-content`;
|
|
22
22
|
|
|
23
|
-
const classNameModifierWrapAll =
|
|
24
|
-
const classNameModifierTruncate =
|
|
23
|
+
const classNameModifierWrapAll = `${cssClassesConstants.DSTreeViewPrefix}-${cssClassesConstants.treeItemBlockName}__value--wrap-all`;
|
|
24
|
+
const classNameModifierTruncate = `${cssClassesConstants.DSTreeViewPrefix}-${cssClassesConstants.treeItemBlockName}__value--truncate`; // eslint-disable-next-line react/prop-types
|
|
25
25
|
|
|
26
26
|
const CustomHighlight = _ref => {
|
|
27
27
|
let {
|
|
@@ -96,10 +96,10 @@ function TreeItemText(props) {
|
|
|
96
96
|
});
|
|
97
97
|
}, [item, searchQuery, nameKey, showChildrenAmount, labelOverflow]);
|
|
98
98
|
let className = '';
|
|
99
|
-
if (labelOverflow === 'wrap-all') className +=
|
|
100
|
-
if (labelOverflow === 'truncate') className +=
|
|
99
|
+
if (labelOverflow === 'wrap-all') className += `${classNameModifierWrapAll} `;
|
|
100
|
+
if (labelOverflow === 'truncate') className += `${classNameModifierTruncate} `;
|
|
101
101
|
return /*#__PURE__*/_jsx__default["default"](ItemContent, {
|
|
102
|
-
"data-testid":
|
|
102
|
+
"data-testid": `${cssClassesConstants.treeItemBlockName}-content`
|
|
103
103
|
}, void 0, /*#__PURE__*/_jsx__default["default"](ItemValue, {
|
|
104
104
|
className: className
|
|
105
105
|
}, void 0, Text));
|
package/cjs/parts/TreeList.js
CHANGED
|
@@ -29,7 +29,7 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
|
29
29
|
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; }
|
|
30
30
|
|
|
31
31
|
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; }
|
|
32
|
-
const treeListNoItemsBn =
|
|
32
|
+
const treeListNoItemsBn = `${cssClassesConstants.treeListBlockName}-no-items`;
|
|
33
33
|
const TreeListNoItems = dsClassnames.aggregatedClasses('div', {
|
|
34
34
|
'data-testid': treeListNoItemsBn
|
|
35
35
|
})(treeListNoItemsBn); // React.ComponentProps<'ul'> uses LegacyRef typings that existed pre-hook era
|
|
@@ -43,11 +43,11 @@ const TreeListWrapper = dsClassnames.aggregatedClasses('ul', {
|
|
|
43
43
|
rowSize
|
|
44
44
|
} = _ref;
|
|
45
45
|
return {
|
|
46
|
-
[
|
|
46
|
+
[`rowsize-${rowSize}`]: rowSize
|
|
47
47
|
};
|
|
48
48
|
});
|
|
49
|
-
const compactRowClass =
|
|
50
|
-
const normaRowClass =
|
|
49
|
+
const compactRowClass = `${cssClassesConstants.DSTreeViewPrefix}-tv-row-size-compact`;
|
|
50
|
+
const normaRowClass = `${cssClassesConstants.DSTreeViewPrefix}-tv-row-size-normal`;
|
|
51
51
|
|
|
52
52
|
const TreeListComp = () => {
|
|
53
53
|
const ctx = React.useContext(TreeViewContext["default"]);
|
|
@@ -67,7 +67,7 @@ const TreeListComp = () => {
|
|
|
67
67
|
totalSize,
|
|
68
68
|
virtualItems
|
|
69
69
|
} = virtualListHelpers;
|
|
70
|
-
const className =
|
|
70
|
+
const className = `${rowSize === 'compact' ? `${compactRowClass}` : `${normaRowClass}`}`;
|
|
71
71
|
const {
|
|
72
72
|
visibleItems
|
|
73
73
|
} = React.useContext(DnDTreeContext.DnDTreeContext);
|
|
@@ -75,8 +75,8 @@ const TreeListComp = () => {
|
|
|
75
75
|
ref: virtualListRef,
|
|
76
76
|
className: className,
|
|
77
77
|
style: {
|
|
78
|
-
height:
|
|
79
|
-
width:
|
|
78
|
+
height: `${typeof height === 'number' ? `${height}px` : height}`,
|
|
79
|
+
width: `${typeof width === 'number' ? `${width}px` : width}`,
|
|
80
80
|
overflow: 'auto'
|
|
81
81
|
},
|
|
82
82
|
children: [isLoading ? /*#__PURE__*/_jsx__default["default"]("div", {
|
|
@@ -95,7 +95,7 @@ const TreeListComp = () => {
|
|
|
95
95
|
showTooltip: false
|
|
96
96
|
})) : null, !isLoading && virtualItems.length === 0 ? /*#__PURE__*/_jsx__default["default"](TreeListNoItems, {}, void 0, noItemsPlaceholder) : null, !isLoading && virtualItems.length !== 0 ? /*#__PURE__*/_jsx__default["default"]("div", {
|
|
97
97
|
style: {
|
|
98
|
-
height:
|
|
98
|
+
height: `${totalSize}px`,
|
|
99
99
|
width: '100%',
|
|
100
100
|
position: 'relative'
|
|
101
101
|
}
|
|
@@ -113,12 +113,12 @@ const TreeListComp = () => {
|
|
|
113
113
|
} = item;
|
|
114
114
|
const style = {
|
|
115
115
|
position: 'absolute',
|
|
116
|
-
top:
|
|
116
|
+
top: `${start}px`,
|
|
117
117
|
left: 0,
|
|
118
118
|
width: '100%'
|
|
119
119
|
};
|
|
120
120
|
const listItemProps = {
|
|
121
|
-
key:
|
|
121
|
+
key: `DS-TreeView-List-Item-${id}`,
|
|
122
122
|
virtualItemRef: measureRef,
|
|
123
123
|
index,
|
|
124
124
|
// this is consumed by the DnD HOC
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
-
|
|
7
5
|
// https://github.com/sindresorhus/array-move/blob/master/index.js
|
|
8
6
|
const arrayMoveMutate = (array, from, to) => {
|
|
9
7
|
const startIndex = from < 0 ? array.length + from : from;
|
|
@@ -94,7 +94,7 @@ const useNotifyExpandedChange = (propsWithDefaults, _ref) => {
|
|
|
94
94
|
latestToggledItem,
|
|
95
95
|
expandedGroups
|
|
96
96
|
} = _ref;
|
|
97
|
-
const notifyExpandedChange = React.useCallback(expandedGroupHashmap => propsWithDefaults
|
|
97
|
+
const notifyExpandedChange = React.useCallback(expandedGroupHashmap => propsWithDefaults?.onExpandChange(expandedGroupHashmap || {}, latestToggledItem), [propsWithDefaults, latestToggledItem]);
|
|
98
98
|
React.useEffect(() => {
|
|
99
99
|
if (!propsWithDefaults.expanded) notifyExpandedChange(expandedGroups);
|
|
100
100
|
}, [expandedGroups, notifyExpandedChange, propsWithDefaults.expanded]);
|
|
@@ -16,9 +16,7 @@ require('core-js/modules/esnext.iterator.reduce.js');
|
|
|
16
16
|
|
|
17
17
|
/* eslint-disable guard-for-in */
|
|
18
18
|
function isObjectADate(o) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return (o === null || o === void 0 ? void 0 : (_o$constructor = o.constructor) === null || _o$constructor === void 0 ? void 0 : _o$constructor.name) === 'Date';
|
|
19
|
+
return o?.constructor?.name === 'Date';
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
function isObjectAnArray(o) {
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
6
6
|
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
7
|
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
|
-
require('core-js/modules/
|
|
8
|
+
require('core-js/modules/es.error.cause.js');
|
|
9
9
|
require('core-js/modules/esnext.async-iterator.find.js');
|
|
10
10
|
require('core-js/modules/esnext.iterator.find.js');
|
|
11
11
|
require('core-js/modules/esnext.async-iterator.every.js');
|
|
@@ -132,8 +132,6 @@ const getChildrenMatchesSearchQuery = function (parentNode) {
|
|
|
132
132
|
*/
|
|
133
133
|
|
|
134
134
|
const enrichNodeModelInPlace = function (node) {
|
|
135
|
-
var _node$model$children$, _node$model, _node$model$children;
|
|
136
|
-
|
|
137
135
|
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
138
136
|
let selection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
139
137
|
let expanded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
@@ -148,7 +146,7 @@ const enrichNodeModelInPlace = function (node) {
|
|
|
148
146
|
// this is useful to avoid having to always check both the flag and the children.length...
|
|
149
147
|
|
|
150
148
|
|
|
151
|
-
if (typeof node.model.isGroup !== 'boolean' && (
|
|
149
|
+
if (typeof node.model.isGroup !== 'boolean' && (node.model?.children?.length ?? 0) > 0) {
|
|
152
150
|
node.model.isGroup = true;
|
|
153
151
|
}
|
|
154
152
|
|
|
@@ -176,9 +174,7 @@ const enrichNodeModelInPlace = function (node) {
|
|
|
176
174
|
}
|
|
177
175
|
};
|
|
178
176
|
const focusItem = item => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
item === null || item === void 0 ? void 0 : (_item$nodeItemRef = item.nodeItemRef) === null || _item$nodeItemRef === void 0 ? void 0 : (_item$nodeItemRef$cur = _item$nodeItemRef.current) === null || _item$nodeItemRef$cur === void 0 ? void 0 : _item$nodeItemRef$cur.focus();
|
|
177
|
+
item?.nodeItemRef?.current?.focus();
|
|
182
178
|
};
|
|
183
179
|
const flattenTreeForDnD = function (data) {
|
|
184
180
|
let shouldDescend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => true;
|
|
@@ -186,20 +182,18 @@ const flattenTreeForDnD = function (data) {
|
|
|
186
182
|
let index = 0;
|
|
187
183
|
|
|
188
184
|
const doit = function (node) {
|
|
189
|
-
var _node$children$length, _node$children, _node$children2;
|
|
190
|
-
|
|
191
185
|
let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
192
186
|
let parentId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
193
187
|
flattenedTree.push({
|
|
194
188
|
uid: node.id.toString(),
|
|
195
189
|
depth,
|
|
196
190
|
realIndex: index,
|
|
197
|
-
childrenCount:
|
|
191
|
+
childrenCount: node.children?.length ?? 0,
|
|
198
192
|
parentId: parentId !== null ? parentId.toString() : null,
|
|
199
193
|
original: node
|
|
200
194
|
});
|
|
201
195
|
index += 1;
|
|
202
|
-
if (shouldDescend(node))
|
|
196
|
+
if (shouldDescend(node)) node.children?.forEach(child => doit(child, depth + 1, node.id.toString()));
|
|
203
197
|
};
|
|
204
198
|
|
|
205
199
|
data.forEach(datum => doit(datum));
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
5
|
var React = require('react');
|
|
7
6
|
var treeHelpers = require('./tree-helpers.js');
|
|
8
7
|
var groupExpandsHelpers = require('./group-expands-helpers.js');
|
package/cjs/utils/useTree.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
5
|
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
8
6
|
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
7
|
require('core-js/modules/esnext.iterator.filter.js');
|
|
10
8
|
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
9
|
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
12
11
|
var React = require('react');
|
|
13
12
|
var TreeModel = require('tree-model');
|
|
14
13
|
var lodash = require('lodash');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const DSTreeViewPrefix = 'em-ds';
|
|
2
2
|
const treeItemBlockName = 'tree-item';
|
|
3
3
|
const treeListBlockName = 'tree-list';
|
|
4
|
-
const treeListNoItemsBn =
|
|
4
|
+
const treeListNoItemsBn = `${treeListBlockName}-no-items`;
|
|
5
5
|
|
|
6
6
|
export { DSTreeViewPrefix, treeItemBlockName, treeListBlockName, treeListNoItemsBn };
|
|
@@ -4,7 +4,6 @@ import 'core-js/modules/esnext.iterator.filter.js';
|
|
|
4
4
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
5
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
7
|
import { useRef, useState, useCallback, useMemo, useEffect } from 'react';
|
|
9
8
|
import { useVirtual } from 'react-virtual';
|
|
10
9
|
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
|
|
@@ -67,7 +66,7 @@ const useTreeview = props => {
|
|
|
67
66
|
parentRef: virtualListRef,
|
|
68
67
|
overscan: 15
|
|
69
68
|
});
|
|
70
|
-
const withDragAndDrop = !!(plugins
|
|
69
|
+
const withDragAndDrop = !!(plugins?.includes(TreeDndPlugin) && onOrderChange);
|
|
71
70
|
const withRadioChecks = isSingleSelect && !isMultiSelect;
|
|
72
71
|
const withCheckboxChecks = !isSingleSelect && isMultiSelect;
|
|
73
72
|
const handleExpandGroup = useCallback(toggleItemExpand, []);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
+
import 'core-js/modules/es.error.cause.js';
|
|
3
4
|
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
4
5
|
import 'core-js/modules/esnext.iterator.map.js';
|
|
5
6
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
@@ -48,18 +49,14 @@ const withConditionalDnDRowContext = Component => props => {
|
|
|
48
49
|
visibleItems: flattenedVisibleTree,
|
|
49
50
|
withDragAndDrop
|
|
50
51
|
} = useContext(TreeViewContext);
|
|
51
|
-
const flattenedVisibleTreeForDnD = useMemo(() => flattenedVisibleTree.map((item, index) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
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,
|
|
60
|
-
original: item
|
|
61
|
-
};
|
|
62
|
-
}), [flattenedVisibleTree]);
|
|
52
|
+
const flattenedVisibleTreeForDnD = useMemo(() => flattenedVisibleTree.map((item, index) => ({
|
|
53
|
+
uid: item.id.toString(),
|
|
54
|
+
depth: (item.treeDepth ?? 1) - 1,
|
|
55
|
+
realIndex: index,
|
|
56
|
+
childrenCount: item.children?.length ?? 0,
|
|
57
|
+
parentId: item.node.parent?.model?.id?.toString() ?? null,
|
|
58
|
+
original: item
|
|
59
|
+
})), [flattenedVisibleTree]);
|
|
63
60
|
const onReorder = useCallback((tree, indexes) => {
|
|
64
61
|
// Pull the row's original data into an object
|
|
65
62
|
const nodes = {};
|
|
@@ -73,10 +70,8 @@ const withConditionalDnDRowContext = Component => props => {
|
|
|
73
70
|
// If row has parent, insert it to it's subrows
|
|
74
71
|
// otherwise append it to the new user data
|
|
75
72
|
if (item.parentId !== null && item.parentId !== undefined && item.parentId !== '__ds_tree_root') {
|
|
76
|
-
var _parentNode$children;
|
|
77
|
-
|
|
78
73
|
const parentNode = nodes[item.parentId];
|
|
79
|
-
|
|
74
|
+
parentNode.children?.push(item.original);
|
|
80
75
|
} else if (item.uid !== '__ds_tree_root') newUserTree.push(item.original);
|
|
81
76
|
}); // Tell the user that the order has change, he can chose to commit it or not
|
|
82
77
|
|
|
@@ -7,7 +7,7 @@ var _Separator;
|
|
|
7
7
|
const Separator = /*#__PURE__*/styled.span.withConfig({
|
|
8
8
|
componentId: "sc-13smqda-0"
|
|
9
9
|
})(["width:1px;height:12px;margin:0 8px;border-left:1px solid ", ";font-size:12px;"], props => props.theme.colors.neutral['600']);
|
|
10
|
-
const className =
|
|
10
|
+
const className = `${DSTreeViewPrefix}-${treeItemBlockName}-children-count-displayer`;
|
|
11
11
|
const ChildrenCountDisplayer = props => {
|
|
12
12
|
const {
|
|
13
13
|
item
|
|
@@ -20,7 +20,7 @@ const ChildrenCountDisplayer = props => {
|
|
|
20
20
|
return /*#__PURE__*/_jsx("span", {
|
|
21
21
|
"data-testid": "tree-item-children-count-displayer",
|
|
22
22
|
className: className
|
|
23
|
-
}, void 0, _Separator || (_Separator = /*#__PURE__*/_jsx(Separator, {})),
|
|
23
|
+
}, void 0, _Separator || (_Separator = /*#__PURE__*/_jsx(Separator, {})), `${children.length} Items`);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export { ChildrenCountDisplayer };
|
package/esm/parts/DnDHandle.js
CHANGED
|
@@ -26,9 +26,9 @@ const DnDHandle = _ref => {
|
|
|
26
26
|
"data-testid": "drag-handle",
|
|
27
27
|
"data-isactive": draggableProps && !!draggableProps.active,
|
|
28
28
|
"data-isdragoverlay": isDragOverlay,
|
|
29
|
-
id:
|
|
30
|
-
key:
|
|
31
|
-
className:
|
|
29
|
+
id: `${id}-drag-handle`,
|
|
30
|
+
key: `${id}-drag-handle`,
|
|
31
|
+
className: `drag-handle ${isDragging ? '' : 'focuseable'}`,
|
|
32
32
|
color: isDragging ? ['neutral', '080'] : ['brand-primary', '800'],
|
|
33
33
|
size: "s",
|
|
34
34
|
tabIndex: 0
|
|
@@ -8,7 +8,11 @@ const getPositionStyles = _ref => {
|
|
|
8
8
|
let {
|
|
9
9
|
dropIndicatorPosition
|
|
10
10
|
} = _ref;
|
|
11
|
-
return
|
|
11
|
+
return `
|
|
12
|
+
top: ${dropIndicatorPosition === DropIndicatorPosition.Before ? '0' : 'unset'};
|
|
13
|
+
bottom: ${dropIndicatorPosition === DropIndicatorPosition.After ? '0' : 'unset'};
|
|
14
|
+
left: -2px;
|
|
15
|
+
`;
|
|
12
16
|
};
|
|
13
17
|
|
|
14
18
|
const getCircleStyles = _ref2 => {
|
package/esm/parts/ExpandCaret.js
CHANGED
|
@@ -9,7 +9,7 @@ const getItemNestingLeftPadding = (level, opts) => {
|
|
|
9
9
|
const finalLeftPadding = groupLeftPadding + spaceForNestingLevel - 0.1; // root level left-padding would be negative and would not be applied
|
|
10
10
|
// if "root-level" nesting, then defaults to 0 left-padding.
|
|
11
11
|
|
|
12
|
-
return finalLeftPadding > 0 ?
|
|
12
|
+
return finalLeftPadding > 0 ? `${finalLeftPadding}em` : '0';
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const NestingSpace = props => {
|
|
@@ -37,7 +37,7 @@ function RadioSelectable(props) {
|
|
|
37
37
|
};
|
|
38
38
|
if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);
|
|
39
39
|
}, [id, setSelectedCheckboxes, itemIndex, onSelectionChange, item, scrollToIndex]);
|
|
40
|
-
const radioName = useMemo(() =>
|
|
40
|
+
const radioName = useMemo(() => `radios-${uniqueTreeViewUUID}`, [uniqueTreeViewUUID]);
|
|
41
41
|
const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);
|
|
42
42
|
return /*#__PURE__*/_jsx(DSRadio, {
|
|
43
43
|
checked: selectedCheckboxes[id] === true,
|
package/esm/parts/TreeItem.js
CHANGED
|
@@ -90,28 +90,28 @@ const TreeItem = props => {
|
|
|
90
90
|
const isDropValid = draggableProps && draggableProps.isDropValid;
|
|
91
91
|
const dropPreviewClassName = useMemo(() => {
|
|
92
92
|
if (isDropIndicatorPositionInside) {
|
|
93
|
-
const className =
|
|
93
|
+
const className = `${DSTreeViewPrefix}-${treeItemBlockName}${isDropValid ? '--valid' : '--invalid'}-drop-in`;
|
|
94
94
|
return className;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
return '';
|
|
98
98
|
}, [isDropIndicatorPositionInside, isDropValid]);
|
|
99
99
|
const dragOverlayClassName = useMemo(() => isDragOverlay ? 'drag-overlay' : '', [isDragOverlay]);
|
|
100
|
-
const selectedClassName = useMemo(() =>
|
|
101
|
-
const hoverClassName = useMemo(() => !isDragOverlay &&
|
|
100
|
+
const selectedClassName = useMemo(() => selectedItem?.id === item.id && !isDragOverlay ? 'selected' : '', [isDragOverlay, item.id, selectedItem?.id]);
|
|
101
|
+
const hoverClassName = useMemo(() => !isDragOverlay && hoverItem?.id === item.id && !isDragging ? 'hover' : '', [isDragOverlay, hoverItem?.id, item.id, isDragging]);
|
|
102
102
|
const fixedHeightClassname = useMemo(() => {
|
|
103
103
|
if (labelOverflow === 'truncate') {
|
|
104
|
-
if (rowSize === 'compact') return
|
|
105
|
-
return
|
|
104
|
+
if (rowSize === 'compact') return `${DSTreeViewPrefix}-${treeItemBlockName}--fixed-height-compact`;
|
|
105
|
+
return `${DSTreeViewPrefix}-${treeItemBlockName}--fixed-height`;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
return '';
|
|
109
109
|
}, [labelOverflow, rowSize]);
|
|
110
110
|
const isDraggingClassname = useMemo(() => {
|
|
111
|
-
if (isDragging) return
|
|
111
|
+
if (isDragging) return `${DSTreeViewPrefix}-${treeItemBlockName}--dragging`;
|
|
112
112
|
return '';
|
|
113
113
|
}, [isDragging]);
|
|
114
|
-
const finalClassName = useMemo(() =>
|
|
114
|
+
const finalClassName = useMemo(() => `${dropPreviewClassName} ${fixedHeightClassname} ${selectedClassName} ${hoverClassName} ${dragOverlayClassName} ${isDraggingClassname}`, [dropPreviewClassName, fixedHeightClassname, selectedClassName, hoverClassName, dragOverlayClassName, isDraggingClassname]);
|
|
115
115
|
const handleItemClick = useCallback(e => {
|
|
116
116
|
onItemClick(item, e);
|
|
117
117
|
setFocusedItem(item);
|
|
@@ -131,7 +131,7 @@ const TreeItem = props => {
|
|
|
131
131
|
return /*#__PURE__*/jsxs(TreeListItem, {
|
|
132
132
|
tabIndex: 0,
|
|
133
133
|
onMouseLeave: () => {
|
|
134
|
-
if (
|
|
134
|
+
if (hoverItem?.id === item.id) {
|
|
135
135
|
setHoverItem(null);
|
|
136
136
|
}
|
|
137
137
|
},
|
|
@@ -8,11 +8,11 @@ import { treeItemBlockName, DSTreeViewPrefix } from '../config/cssClassesConstan
|
|
|
8
8
|
import TreeViewContext from '../TreeViewContext.js';
|
|
9
9
|
import { jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
10
|
|
|
11
|
-
const ItemContent = aggregatedClasses('div')(
|
|
11
|
+
const ItemContent = aggregatedClasses('div')(`${treeItemBlockName}-content`);
|
|
12
12
|
const ItemValue = aggregatedClasses('span')(treeItemBlockName, 'value'); // const wrapperClassName = `${DSTreeViewPrefix}-${treeItemBlockName}-content`;
|
|
13
13
|
|
|
14
|
-
const classNameModifierWrapAll =
|
|
15
|
-
const classNameModifierTruncate =
|
|
14
|
+
const classNameModifierWrapAll = `${DSTreeViewPrefix}-${treeItemBlockName}__value--wrap-all`;
|
|
15
|
+
const classNameModifierTruncate = `${DSTreeViewPrefix}-${treeItemBlockName}__value--truncate`; // eslint-disable-next-line react/prop-types
|
|
16
16
|
|
|
17
17
|
const CustomHighlight = _ref => {
|
|
18
18
|
let {
|
|
@@ -87,10 +87,10 @@ function TreeItemText(props) {
|
|
|
87
87
|
});
|
|
88
88
|
}, [item, searchQuery, nameKey, showChildrenAmount, labelOverflow]);
|
|
89
89
|
let className = '';
|
|
90
|
-
if (labelOverflow === 'wrap-all') className +=
|
|
91
|
-
if (labelOverflow === 'truncate') className +=
|
|
90
|
+
if (labelOverflow === 'wrap-all') className += `${classNameModifierWrapAll} `;
|
|
91
|
+
if (labelOverflow === 'truncate') className += `${classNameModifierTruncate} `;
|
|
92
92
|
return /*#__PURE__*/_jsx(ItemContent, {
|
|
93
|
-
"data-testid":
|
|
93
|
+
"data-testid": `${treeItemBlockName}-content`
|
|
94
94
|
}, void 0, /*#__PURE__*/_jsx(ItemValue, {
|
|
95
95
|
className: className
|
|
96
96
|
}, void 0, Text));
|
package/esm/parts/TreeList.js
CHANGED
|
@@ -20,7 +20,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
20
20
|
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; }
|
|
21
21
|
|
|
22
22
|
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; }
|
|
23
|
-
const treeListNoItemsBn =
|
|
23
|
+
const treeListNoItemsBn = `${treeListBlockName}-no-items`;
|
|
24
24
|
const TreeListNoItems = aggregatedClasses('div', {
|
|
25
25
|
'data-testid': treeListNoItemsBn
|
|
26
26
|
})(treeListNoItemsBn); // React.ComponentProps<'ul'> uses LegacyRef typings that existed pre-hook era
|
|
@@ -34,11 +34,11 @@ const TreeListWrapper = aggregatedClasses('ul', {
|
|
|
34
34
|
rowSize
|
|
35
35
|
} = _ref;
|
|
36
36
|
return {
|
|
37
|
-
[
|
|
37
|
+
[`rowsize-${rowSize}`]: rowSize
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
|
-
const compactRowClass =
|
|
41
|
-
const normaRowClass =
|
|
40
|
+
const compactRowClass = `${DSTreeViewPrefix}-tv-row-size-compact`;
|
|
41
|
+
const normaRowClass = `${DSTreeViewPrefix}-tv-row-size-normal`;
|
|
42
42
|
|
|
43
43
|
const TreeListComp = () => {
|
|
44
44
|
const ctx = useContext(TreeViewContext);
|
|
@@ -58,7 +58,7 @@ const TreeListComp = () => {
|
|
|
58
58
|
totalSize,
|
|
59
59
|
virtualItems
|
|
60
60
|
} = virtualListHelpers;
|
|
61
|
-
const className =
|
|
61
|
+
const className = `${rowSize === 'compact' ? `${compactRowClass}` : `${normaRowClass}`}`;
|
|
62
62
|
const {
|
|
63
63
|
visibleItems
|
|
64
64
|
} = useContext(DnDTreeContext);
|
|
@@ -66,8 +66,8 @@ const TreeListComp = () => {
|
|
|
66
66
|
ref: virtualListRef,
|
|
67
67
|
className: className,
|
|
68
68
|
style: {
|
|
69
|
-
height:
|
|
70
|
-
width:
|
|
69
|
+
height: `${typeof height === 'number' ? `${height}px` : height}`,
|
|
70
|
+
width: `${typeof width === 'number' ? `${width}px` : width}`,
|
|
71
71
|
overflow: 'auto'
|
|
72
72
|
},
|
|
73
73
|
children: [isLoading ? /*#__PURE__*/_jsx("div", {
|
|
@@ -86,7 +86,7 @@ const TreeListComp = () => {
|
|
|
86
86
|
showTooltip: false
|
|
87
87
|
})) : null, !isLoading && virtualItems.length === 0 ? /*#__PURE__*/_jsx(TreeListNoItems, {}, void 0, noItemsPlaceholder) : null, !isLoading && virtualItems.length !== 0 ? /*#__PURE__*/_jsx("div", {
|
|
88
88
|
style: {
|
|
89
|
-
height:
|
|
89
|
+
height: `${totalSize}px`,
|
|
90
90
|
width: '100%',
|
|
91
91
|
position: 'relative'
|
|
92
92
|
}
|
|
@@ -104,12 +104,12 @@ const TreeListComp = () => {
|
|
|
104
104
|
} = item;
|
|
105
105
|
const style = {
|
|
106
106
|
position: 'absolute',
|
|
107
|
-
top:
|
|
107
|
+
top: `${start}px`,
|
|
108
108
|
left: 0,
|
|
109
109
|
width: '100%'
|
|
110
110
|
};
|
|
111
111
|
const listItemProps = {
|
|
112
|
-
key:
|
|
112
|
+
key: `DS-TreeView-List-Item-${id}`,
|
|
113
113
|
virtualItemRef: measureRef,
|
|
114
114
|
index,
|
|
115
115
|
// this is consumed by the DnD HOC
|
|
@@ -90,7 +90,7 @@ const useNotifyExpandedChange = (propsWithDefaults, _ref) => {
|
|
|
90
90
|
latestToggledItem,
|
|
91
91
|
expandedGroups
|
|
92
92
|
} = _ref;
|
|
93
|
-
const notifyExpandedChange = useCallback(expandedGroupHashmap => propsWithDefaults
|
|
93
|
+
const notifyExpandedChange = useCallback(expandedGroupHashmap => propsWithDefaults?.onExpandChange(expandedGroupHashmap || {}, latestToggledItem), [propsWithDefaults, latestToggledItem]);
|
|
94
94
|
useEffect(() => {
|
|
95
95
|
if (!propsWithDefaults.expanded) notifyExpandedChange(expandedGroups);
|
|
96
96
|
}, [expandedGroups, notifyExpandedChange, propsWithDefaults.expanded]);
|
|
@@ -12,9 +12,7 @@ import 'core-js/modules/esnext.iterator.reduce.js';
|
|
|
12
12
|
|
|
13
13
|
/* eslint-disable guard-for-in */
|
|
14
14
|
function isObjectADate(o) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return (o === null || o === void 0 ? void 0 : (_o$constructor = o.constructor) === null || _o$constructor === void 0 ? void 0 : _o$constructor.name) === 'Date';
|
|
15
|
+
return o?.constructor?.name === 'Date';
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
function isObjectAnArray(o) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
2
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
3
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
-
import 'core-js/modules/
|
|
4
|
+
import 'core-js/modules/es.error.cause.js';
|
|
5
5
|
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
6
6
|
import 'core-js/modules/esnext.iterator.find.js';
|
|
7
7
|
import 'core-js/modules/esnext.async-iterator.every.js';
|
|
@@ -128,8 +128,6 @@ const getChildrenMatchesSearchQuery = function (parentNode) {
|
|
|
128
128
|
*/
|
|
129
129
|
|
|
130
130
|
const enrichNodeModelInPlace = function (node) {
|
|
131
|
-
var _node$model$children$, _node$model, _node$model$children;
|
|
132
|
-
|
|
133
131
|
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
134
132
|
let selection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
135
133
|
let expanded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
@@ -144,7 +142,7 @@ const enrichNodeModelInPlace = function (node) {
|
|
|
144
142
|
// this is useful to avoid having to always check both the flag and the children.length...
|
|
145
143
|
|
|
146
144
|
|
|
147
|
-
if (typeof node.model.isGroup !== 'boolean' && (
|
|
145
|
+
if (typeof node.model.isGroup !== 'boolean' && (node.model?.children?.length ?? 0) > 0) {
|
|
148
146
|
node.model.isGroup = true;
|
|
149
147
|
}
|
|
150
148
|
|
|
@@ -172,9 +170,7 @@ const enrichNodeModelInPlace = function (node) {
|
|
|
172
170
|
}
|
|
173
171
|
};
|
|
174
172
|
const focusItem = item => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
item === null || item === void 0 ? void 0 : (_item$nodeItemRef = item.nodeItemRef) === null || _item$nodeItemRef === void 0 ? void 0 : (_item$nodeItemRef$cur = _item$nodeItemRef.current) === null || _item$nodeItemRef$cur === void 0 ? void 0 : _item$nodeItemRef$cur.focus();
|
|
173
|
+
item?.nodeItemRef?.current?.focus();
|
|
178
174
|
};
|
|
179
175
|
const flattenTreeForDnD = function (data) {
|
|
180
176
|
let shouldDescend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => true;
|
|
@@ -182,20 +178,18 @@ const flattenTreeForDnD = function (data) {
|
|
|
182
178
|
let index = 0;
|
|
183
179
|
|
|
184
180
|
const doit = function (node) {
|
|
185
|
-
var _node$children$length, _node$children, _node$children2;
|
|
186
|
-
|
|
187
181
|
let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
188
182
|
let parentId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
189
183
|
flattenedTree.push({
|
|
190
184
|
uid: node.id.toString(),
|
|
191
185
|
depth,
|
|
192
186
|
realIndex: index,
|
|
193
|
-
childrenCount:
|
|
187
|
+
childrenCount: node.children?.length ?? 0,
|
|
194
188
|
parentId: parentId !== null ? parentId.toString() : null,
|
|
195
189
|
original: node
|
|
196
190
|
});
|
|
197
191
|
index += 1;
|
|
198
|
-
if (shouldDescend(node))
|
|
192
|
+
if (shouldDescend(node)) node.children?.forEach(child => doit(child, depth + 1, node.id.toString()));
|
|
199
193
|
};
|
|
200
194
|
|
|
201
195
|
data.forEach(datum => doit(datum));
|
package/esm/utils/useTree.js
CHANGED
|
@@ -4,7 +4,6 @@ import 'core-js/modules/esnext.iterator.filter.js';
|
|
|
4
4
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
5
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
7
|
import { useMemo, useState, useEffect, useCallback } from 'react';
|
|
9
8
|
import TreeModel from 'tree-model';
|
|
10
9
|
import { cloneDeep } from 'lodash';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-treeview",
|
|
3
|
-
"version": "2.4.2-rc.
|
|
3
|
+
"version": "2.4.2-rc.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Tree View",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -229,15 +229,15 @@
|
|
|
229
229
|
"dependencies": {
|
|
230
230
|
"@dnd-kit/core": "~4.0.1",
|
|
231
231
|
"@dnd-kit/sortable": "~5.0.0",
|
|
232
|
-
"@elliemae/ds-button": "2.4.2-rc.
|
|
233
|
-
"@elliemae/ds-circular-progress-indicator": "2.4.2-rc.
|
|
234
|
-
"@elliemae/ds-classnames": "2.4.2-rc.
|
|
235
|
-
"@elliemae/ds-drag-and-drop": "2.4.2-rc.
|
|
236
|
-
"@elliemae/ds-form": "2.4.2-rc.
|
|
237
|
-
"@elliemae/ds-icons": "2.4.2-rc.
|
|
238
|
-
"@elliemae/ds-props-helpers": "2.4.2-rc.
|
|
239
|
-
"@elliemae/ds-truncated-tooltip-text": "2.4.2-rc.
|
|
240
|
-
"@elliemae/ds-utilities": "2.4.2-rc.
|
|
232
|
+
"@elliemae/ds-button": "2.4.2-rc.14",
|
|
233
|
+
"@elliemae/ds-circular-progress-indicator": "2.4.2-rc.14",
|
|
234
|
+
"@elliemae/ds-classnames": "2.4.2-rc.14",
|
|
235
|
+
"@elliemae/ds-drag-and-drop": "2.4.2-rc.14",
|
|
236
|
+
"@elliemae/ds-form": "2.4.2-rc.14",
|
|
237
|
+
"@elliemae/ds-icons": "2.4.2-rc.14",
|
|
238
|
+
"@elliemae/ds-props-helpers": "2.4.2-rc.14",
|
|
239
|
+
"@elliemae/ds-truncated-tooltip-text": "2.4.2-rc.14",
|
|
240
|
+
"@elliemae/ds-utilities": "2.4.2-rc.14",
|
|
241
241
|
"react-desc": "~4.1.3",
|
|
242
242
|
"react-highlight-words": "~0.17.0",
|
|
243
243
|
"react-virtual": "~2.8.2",
|